
                (function() {
                    var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
                    var __module = nodeEnv ? module : {exports:{}};
                    var __filename = 'preview-scripts/__node_modules/simba-cc-resutils/dist/index.js';
                    var __require = nodeEnv ? function (request) {
                        return cc.require(request);
                    } : function (request) {
                        return __quick_compile_project__.require(request, __filename);
                    };
                    function __define (exports, require, module) {
                        if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResUtils = void 0;
var ResUtils;
(function (ResUtils) {
    async function loadRes(resource, type, maxTryCount = 3) {
        return new Promise((resolve, reject) => {
            let tryCount = 0;
            function loadFunc() {
                tryCount++;
                cc.resources.load(resource, type, (err, res) => {
                    if (err) {
                        if (tryCount < maxTryCount) {
                            setTimeout(() => {
                                loadFunc();
                            }, 500);
                        }
                        else {
                            reject(err);
                        }
                    }
                    else {
                        if (res.json) {
                            resolve(res.json);
                        }
                        else if (res.text) {
                            resolve(res.text);
                        }
                        else {
                            resolve(res);
                        }
                    }
                });
            }
            loadFunc();
        });
    }
    ResUtils.loadRes = loadRes;
    //动态加载图片的方法
    async function loadOnlineImg(container, url) {
        return new Promise((resolve, reject) => {
            cc.assetManager.loadRemote(url, function (err, texture) {
                if (err) {
                    reject(err);
                }
                else {
                    var sprite = new cc.SpriteFrame(texture);
                    container.spriteFrame = sprite;
                    resolve(null);
                }
            });
        });
    }
    ResUtils.loadOnlineImg = loadOnlineImg;
    /**释放资源 */
    function releaseRes(resource) {
        cc.resources.release(resource);
    }
    ResUtils.releaseRes = releaseRes;
    /**批量释放资源 */
    function releaseResArray(resources) {
        for (let i = 0; i < resources.length; i++) {
            cc.resources.release(resources[i]);
        }
    }
    ResUtils.releaseResArray = releaseResArray;
    function releaseAsset(asset) {
        cc.assetManager.releaseAsset(asset);
    }
    ResUtils.releaseAsset = releaseAsset;
    function releaseAssetArray(assets) {
        assets.forEach((asset) => cc.assetManager.releaseAsset(asset));
    }
    ResUtils.releaseAssetArray = releaseAssetArray;
    /**加载预制体并实例化node */
    async function createWithPrefab(resource) {
        let prefab = await ResUtils.loadRes(resource, cc.Prefab);
        if (!prefab)
            throw new Error("Load prefab failed!");
        let node = cc.instantiate(prefab);
        if (node) {
            return node;
        }
        else {
            throw new Error("Instantiate node failed!");
        }
    }
    ResUtils.createWithPrefab = createWithPrefab;
    async function loadJsonRes(path, maxTryCount = 3) {
        return loadRes(path, cc.JsonAsset);
    }
    ResUtils.loadJsonRes = loadJsonRes;
    /**加载压缩过后的json文件并返回json文件 */
    async function loadManifestResToJson(path, maxTryCount = 3) {
        let data = await loadRes(path, cc.Asset);
        ;
        let nativeAsset = data['_$nativeAsset'];
        if (nativeAsset) {
            let pako = require('pako');
            let jsonObj = JSON.parse(pako.inflate(nativeAsset, { to: 'string' }));
            return jsonObj;
        }
        else {
            return console.error('_$nativeAsset is null');
        }
    }
    ResUtils.loadManifestResToJson = loadManifestResToJson;
    async function loadTextRes(path, maxTryCount = 3) {
        return loadRes(path, cc.TextAsset);
    }
    ResUtils.loadTextRes = loadTextRes;
})(ResUtils = exports.ResUtils || (exports.ResUtils = {}));

                    }
                    if (nodeEnv) {
                        __define(__module.exports, __require, __module);
                    }
                    else {
                        __quick_compile_project__.registerModuleFunc(__filename, function () {
                            __define(__module.exports, __require, __module);
                        });
                    }
                })();