<commit_before>namespace fgui {

    export class UIPackage {
        private _id: string;
        private _name: string;
        private _items: PackageItem[];
        private _itemsById: Object;
        private _itemsByName: Object;
        private _resKey: string;
        private _customId: string;
        private _sprites: Object;
        private _dependencies: Array<any>;
        private _branches: Array<string>;
        public _branchIndex: number;

        public static _constructing: number = 0;

        private static _instById: Object = {};
        private static _instByName: Object = {};
        private static _branch: string = "";
        private static _vars: any = {};

        constructor() {
            this._items = [];
            this._itemsById = {};
            this._itemsByName = {};
            this._sprites = {};
            this._dependencies = Array<any>();
            this._branches = Array<string>();
            this._branchIndex = -1;
        }

        public static get branch(): string {
            return UIPackage._branch;
        }

        public static set branch(value: string) {
            UIPackage._branch = value;
            for (var pkgId in UIPackage._instById) {
                var pkg: UIPackage = UIPackage._instById[pkgId];
                if (pkg._branches) {
                    pkg._branchIndex = pkg._branches.indexOf(value);
                }
            }
        }

        public static getVar(key: string): any {
            return UIPackage._vars[key];
        }

        public static setVar(key: string, value: any) {
            UIPackage._vars[key] = value;
        }

        public static getById(id: string): UIPackage {
            return UIPackage._instById[id];
        }

        public static getByName(name: string): UIPackage {
            return UIPackage._instByName[name];
        }

        public static addPackage(resKey: string, descData?: ArrayBuffer): UIPackage {
            if (!descData) {
                descData = AssetProxy.inst.getRes(resKey + "." + UIConfig.packageFileExtension);
                if (!descData || descData.byteLength == 0)
                    throw new Error("resource '" + resKey + "' not found");
            }

            var buffer: ByteBuffer = new ByteBuffer(descData);

            var pkg: UIPackage = new UIPackage();
            pkg._resKey = resKey;
            pkg.loadPackage(buffer);
            UIPackage._instById[pkg.id] = pkg;
            UIPackage._instByName[pkg.name] = pkg;
            UIPackage._instById[resKey] = pkg;
            return pkg;
        }

        public static loadPackage(resKey: string, completeHandler: Laya.Handler): void {
            let pkg: UIPackage = UIPackage._instById[resKey];
            if (pkg) {
                completeHandler.runWith(pkg);
                return;
            }

            let url: string = resKey + "." + UIConfig.packageFileExtension;

            var descCompleteHandler: Laya.Handler = Laya.Handler.create(this, function (asset) {
                let pkg: UIPackage = new UIPackage();
                pkg._resKey = resKey;
                pkg.loadPackage(new ByteBuffer(asset));
                let cnt: number = pkg._items.length;
                let urls = [];
                for (var i: number = 0; i < cnt; i++) {
                    var pi: PackageItem = pkg._items[i];
                    if (pi.type == PackageItemType.Atlas)
                        urls.push({ url: pi.file, type: Laya.Loader.IMAGE });
                    else if (pi.type == PackageItemType.Sound)
                        urls.push({ url: pi.file, type: Laya.Loader.SOUND });
                }

                if (urls.length > 0) {
                    AssetProxy.inst.load(urls, Laya.Handler.create(this, function (): void {
                        UIPackage._instById[pkg.id] = pkg;
                        UIPackage._instByName[pkg.name] = pkg;
                        UIPackage._instByName[pkg._resKey] = pkg;

                        completeHandler.runWith(pkg);
                    }, null, true));
                }
                else {
                    UIPackage._instById[pkg.id] = pkg;
                    UIPackage._instByName[pkg.name] = pkg;<commit_msg>- modify loadPackage with assets loading progressHandler<commit_after>namespace fgui {

    export class UIPackage {
        private _id: string;
        private _name: string;
        private _items: PackageItem[];
        private _itemsById: Object;
        private _itemsByName: Object;
        private _resKey: string;
        private _customId: string;
        private _sprites: Object;
        private _dependencies: Array<any>;
        private _branches: Array<string>;
        public _branchIndex: number;

        public static _constructing: number = 0;

        private static _instById: Object = {};
        private static _instByName: Object = {};
        private static _branch: string = "";
        private static _vars: any = {};

        constructor() {
            this._items = [];
            this._itemsById = {};
            this._itemsByName = {};
            this._sprites = {};
            this._dependencies = Array<any>();
            this._branches = Array<string>();
            this._branchIndex = -1;
        }

        public static get branch(): string {
            return UIPackage._branch;
        }

        public static set branch(value: string) {
            UIPackage._branch = value;
            for (var pkgId in UIPackage._instById) {
                var pkg: UIPackage = UIPackage._instById[pkgId];
                if (pkg._branches) {
                    pkg._branchIndex = pkg._branches.indexOf(value);
                }
            }
        }

        public static getVar(key: string): any {
            return UIPackage._vars[key];
        }

        public static setVar(key: string, value: any) {
            UIPackage._vars[key] = value;
        }

        public static getById(id: string): UIPackage {
            return UIPackage._instById[id];
        }

        public static getByName(name: string): UIPackage {
            return UIPackage._instByName[name];
        }

        public static addPackage(resKey: string, descData?: ArrayBuffer): UIPackage {
            if (!descData) {
                descData = AssetProxy.inst.getRes(resKey + "." + UIConfig.packageFileExtension);
                if (!descData || descData.byteLength == 0)
                    throw new Error("resource '" + resKey + "' not found");
            }

            var buffer: ByteBuffer = new ByteBuffer(descData);

            var pkg: UIPackage = new UIPackage();
            pkg._resKey = resKey;
            pkg.loadPackage(buffer);
            UIPackage._instById[pkg.id] = pkg;
            UIPackage._instByName[pkg.name] = pkg;
            UIPackage._instById[resKey] = pkg;
            return pkg;
        }

        public static loadPackage(resKey: string, completeHandler: Laya.Handler, progressHandler?: Laya.Handler): void {
            let pkg: UIPackage = UIPackage._instById[resKey];
            if (pkg) {
                completeHandler.runWith(pkg);
                return;
            }

            let url: string = resKey + "." + UIConfig.packageFileExtension;

            var descCompleteHandler: Laya.Handler = Laya.Handler.create(this, function (asset) {
                let pkg: UIPackage = new UIPackage();
                pkg._resKey = resKey;
                pkg.loadPackage(new ByteBuffer(asset));
                let cnt: number = pkg._items.length;
                let urls = [];
                for (var i: number = 0; i < cnt; i++) {
                    var pi: PackageItem = pkg._items[i];
                    if (pi.type == PackageItemType.Atlas)
                        urls.push({ url: pi.file, type: Laya.Loader.IMAGE });
                    else if (pi.type == PackageItemType.Sound)
                        urls.push({ url: pi.file, type: Laya.Loader.SOUND });
                }

                if (urls.length > 0) {
                    AssetProxy.inst.load(urls, Laya.Handler.create(this, function (): void {
                        UIPackage._instById[pkg.id] = pkg;
                        UIPackage._instByName[pkg.name] = pkg;
                        UIPackage._instByName[pkg._resKey] = pkg;

                        completeHandler.runWith(pkg);
                    }, null, true), progressHandler);
                }
                else {
                    UIPackage._instById[pkg.id] = pkg;
                    UIPackage._instByName[pkg.name] = pkg;
{'fraction_non_alphanumeric': 0.10183678214368752, 'fraction_numerical': 0.0011625203441060219, 'mean_word_length': 1.5604166666666666, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3724110', 'n_tokens_mistral': 2410, 'n_tokens_neox': 2217, 'n_words': 528}