<commit_before>import { ensurePublicExtension, Concat, ensureUserPath } from "./Utils";
import { ModuleCollection } from "./core/ModuleCollection";
import { WorkFlowContext } from "./core/WorkflowContext";
import { BundleData } from "./arithmetic/Arithmetic";
import { File } from "./core/File";
import { Config } from "./Config";
import * as path from "path";
import * as fs from "fs";

/**
 *
 *
 * @export
 * @class BundleSource
 */
export class BundleSource {
    /**
     *
     *
     *
     * @memberOf BundleSource
     */
    public standalone = false;
    /**
     *
     *
     * @private
     * @type {*}
     * @memberOf BundleSource
     */
    public concat: Concat;

    private collectionSource: any;

    public bundleInfoObject: any;

    /**
     * Creates an instance of BundleSource.
     *
     * @param {WorkFlowContext} context
     *
     * @memberOf BundleSource
     */
    constructor(public context: WorkFlowContext) {
        this.concat = new Concat(true, "", "\n");
    }

    /**
     *
     *
     * @memberOf BundleSource
     */
    public init() {
        this.concat.add(null, "(function(FuseBox){FuseBox.$fuse$=FuseBox;");
    }

    public annotate(comment: string) {
        if (this.context.rollupOptions) {
            this.collectionSource.add(null, comment);
        }
    }

    /**
     *
     *
     * @param {ModuleCollection} collection
     *
     * @memberOf BundleSource
     */
    public createCollection(collection: ModuleCollection) {
        this.collectionSource = new Concat(true, collection.name, "\n");
    }

    public addContentToCurrentCollection(data: string) {
        if (this.collectionSource) {
            this.collectionSource.add(null, data);
        }
    }

    public startCollection(collection: ModuleCollection) {
        let conflicting = {};
        if (collection.conflictingVersions) {
            collection.conflictingVersions.forEach((version, name) => {
                conflicting[name] = version;
            });
        }

        this.collectionSource.add(null, `FuseBox.pkg("${collection.name}", ${JSON.stringify(
            conflicting)}, function(___scope___){`);

        this.annotate(`/* fuse:start-collection "${collection.name}"*/`);
    }

    /**
     *
     *
     * @param {ModuleCollection} collection
     *
     * @memberOf BundleSource
     */
    public endCollection(collection: ModuleCollection) {
        let entry = collection.entryFile ? collection.entryFile.info.fuseBoxPath : "";

        if (entry) {<commit_msg>Fix #522<commit_after>import { ensurePublicExtension, Concat, ensureUserPath } from "./Utils";
import { ModuleCollection } from "./core/ModuleCollection";
import { WorkFlowContext } from "./core/WorkflowContext";
import { BundleData } from "./arithmetic/Arithmetic";
import { File } from "./core/File";
import { Config } from "./Config";
import * as path from "path";
import * as fs from "fs";

/**
 *
 *
 * @export
 * @class BundleSource
 */
export class BundleSource {
    /**
     *
     *
     *
     * @memberOf BundleSource
     */
    public standalone = false;
    /**
     *
     *
     * @private
     * @type {*}
     * @memberOf BundleSource
     */
    public concat: Concat;

    private collectionSource: any;

    public bundleInfoObject: any;

    /**
     * Creates an instance of BundleSource.
     *
     * @param {WorkFlowContext} context
     *
     * @memberOf BundleSource
     */
    constructor(public context: WorkFlowContext) {
        this.concat = new Concat(true, "", "\n");
    }

    /**
     *
     *
     * @memberOf BundleSource
     */
    public init() {
        this.concat.add(null, "(function(FuseBox){FuseBox.$fuse$=FuseBox;");
    }

    public annotate(comment: string) {
        if (this.context.rollupOptions) {
            this.collectionSource.add(null, comment);
        }
    }

    /**
     *
     *
     * @param {ModuleCollection} collection
     *
     * @memberOf BundleSource
     */
    public createCollection(collection: ModuleCollection) {
        this.collectionSource = new Concat(true, collection.name, "\n");
    }

    public addContentToCurrentCollection(data: string) {
        if (this.collectionSource) {
            this.collectionSource.add(null, data);
        }
    }

    public startCollection(collection: ModuleCollection) {
        let conflicting = {};
        if (collection.conflictingVersions) {
            collection.conflictingVersions.forEach((version, name) => {
                conflicting[name] = version;
            });
        }

        this.collectionSource.add(null, `FuseBox.pkg("${collection.name}", ${JSON.stringify(
            conflicting)}, function(___scope___){`);

        this.annotate(`/* fuse:start-collection "${collection.name}"*/`);
    }

    /**
     *
     *
     * @param {ModuleCollection} collection
     *
     * @memberOf BundleSource
     */
    public endCollection(collection: ModuleCollection) {
        let entry = collection.entryFile ? collection.entryFile.info.fuseBoxPath : "";

        if (entry && collection.acceptFiles) {
{'fraction_non_alphanumeric': 0.13304467624483368, 'fraction_numerical': 0.000590434953749262, 'mean_word_length': 2.3193990855649904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7349195', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1425, 'n_words': 288}