hiepdh-playable-toolkit 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/3x/build-inline.js +85 -0
  2. package/3x/build-templates/web-mobile/index.ejs +47 -0
  3. package/3x/extensions/super-html/README-CN.md +16 -0
  4. package/3x/extensions/super-html/dist/2x/main.js +64 -0
  5. package/3x/extensions/super-html/dist/2x/panel/index.js +66 -0
  6. package/3x/extensions/super-html/dist/3x/builder.js +8 -0
  7. package/3x/extensions/super-html/dist/3x/hooks.js +24 -0
  8. package/3x/extensions/super-html/dist/3x/main.js +27 -0
  9. package/3x/extensions/super-html/dist/3x/panel/index.js +63 -0
  10. package/3x/extensions/super-html/dist/core/build.js +58 -0
  11. package/3x/extensions/super-html/dist/core/common/cache.js +124 -0
  12. package/3x/extensions/super-html/dist/core/common/log.js +46 -0
  13. package/3x/extensions/super-html/dist/core/common/utils.js +107 -0
  14. package/3x/extensions/super-html/dist/core/config.js +71 -0
  15. package/3x/extensions/super-html/dist/core/task.js +356 -0
  16. package/3x/extensions/super-html/dist/custom_script/23x/custom-23x.js +290 -0
  17. package/3x/extensions/super-html/dist/custom_script/23x/index-23x.js +86 -0
  18. package/3x/extensions/super-html/dist/custom_script/24x/custom-24x.js +298 -0
  19. package/3x/extensions/super-html/dist/custom_script/24x/index-24x.js +87 -0
  20. package/3x/extensions/super-html/dist/custom_script/34x/custom-34x.js +244 -0
  21. package/3x/extensions/super-html/dist/custom_script/34x/index-34x.js +59 -0
  22. package/3x/extensions/super-html/dist/custom_script/javascript-obfuscator.js +9719 -0
  23. package/3x/extensions/super-html/dist/custom_script/pako.js +1462 -0
  24. package/3x/extensions/super-html/dist/test/_test.js +27 -0
  25. package/3x/extensions/super-html/i18n/en.js +5 -0
  26. package/3x/extensions/super-html/i18n/zh.js +5 -0
  27. package/3x/extensions/super-html/package-lock.json +744 -0
  28. package/3x/extensions/super-html/package.json +59 -0
  29. package/3x/extensions/super-html/static/index.html +44 -0
  30. package/3x/extensions/super-html/tsconfig.json +14 -0
  31. package/3x/plugins/exitapi.js +7 -0
  32. package/3x/plugins/facebook_api.js +31 -0
  33. package/3x/plugins/fixmraid.js +17 -0
  34. package/3x/plugins/ironsource_api.js +58 -0
  35. package/3x/plugins/mindworkapi.js +6 -0
  36. package/3x/plugins/playable-sdk.js +5 -0
  37. package/README.md +3 -3
  38. package/ironSource_api.js +86 -0
  39. package/package.json +13 -13
  40. package/setup.js +79 -50
  41. /package/{injectCustomScript.js → 3x/injectCustomScript.js} +0 -0
  42. /package/{patch-template-unityReject.js → 3x/patch-template-unityReject.js} +0 -0
@@ -0,0 +1,290 @@
1
+ "use strict";
2
+ window.__custom = function () {
3
+ function _getRes(item) {
4
+ return window.__res[item.url] || item.url;
5
+ }
6
+ function downloadText(item, callback) {
7
+ var data = _getRes(item);
8
+ callback(null, data);
9
+ }
10
+ ;
11
+ function downloadImage(item, callback, isCrossOrigin, img) {
12
+ if (isCrossOrigin === undefined) {
13
+ isCrossOrigin = true;
14
+ }
15
+ var url = _getRes(item);
16
+ img = img || new Image();
17
+ if (isCrossOrigin && window.location.protocol !== 'file:') {
18
+ img.crossOrigin = 'anonymous';
19
+ }
20
+ else {
21
+ img.crossOrigin = null;
22
+ }
23
+ if (img.complete && img.naturalWidth > 0 && img.src === url) {
24
+ return img;
25
+ }
26
+ else {
27
+ function loadCallback() {
28
+ img.removeEventListener('load', loadCallback);
29
+ img.removeEventListener('error', errorCallback);
30
+ img.id = item.id;
31
+ callback(null, img);
32
+ }
33
+ function errorCallback() {
34
+ img.removeEventListener('load', loadCallback);
35
+ img.removeEventListener('error', errorCallback);
36
+ // Retry without crossOrigin mark if crossOrigin loading fails
37
+ // Do not retry if protocol is https, even if the image is loaded, cross origin image isn't renderable.
38
+ if (window.location.protocol !== 'https:' && img.crossOrigin && img.crossOrigin.toLowerCase() === 'anonymous') {
39
+ downloadImage(item, callback, false, img);
40
+ }
41
+ else {
42
+ callback(new Error(debug.getError(4930, url)));
43
+ }
44
+ }
45
+ img.addEventListener('load', loadCallback);
46
+ img.addEventListener('error', errorCallback);
47
+ img.src = url;
48
+ }
49
+ }
50
+ ;
51
+ //音频
52
+ var downloadAudio = null;
53
+ (function () {
54
+ var __audioSupport = cc.sys.__audioSupport;
55
+ var formatSupport = __audioSupport.format;
56
+ var context = __audioSupport.context;
57
+ function convertBase64(data) {
58
+ data = data.replace(/-/g, '+');
59
+ data = data.replace(/_/g, '/');
60
+ return data;
61
+ }
62
+ ;
63
+ // cocos2.0以上版本加载domaudio,兼容1X版本
64
+ function loadDomAudio2X(item, callback) {
65
+ var data = _getRes(item);
66
+ var dom = document.createElement('audio');
67
+ dom.muted = false;
68
+ if (data == null) {
69
+ callback();
70
+ return;
71
+ }
72
+ else {
73
+ dom.src = data;
74
+ }
75
+ ;
76
+ var clearEvent = function () {
77
+ clearTimeout(timer);
78
+ dom.removeEventListener("canplaythrough", success, false);
79
+ dom.removeEventListener("error", failure, false);
80
+ if (__audioSupport.USE_LOADER_EVENT)
81
+ dom.removeEventListener(__audioSupport.USE_LOADER_EVENT, success, false);
82
+ };
83
+ var timer = setTimeout(function () {
84
+ if (dom.readyState === 0)
85
+ failure();
86
+ else
87
+ success();
88
+ }, 8000);
89
+ var success = function () {
90
+ clearEvent();
91
+ callback(null, dom);
92
+ };
93
+ var failure = function () {
94
+ clearEvent();
95
+ var message = 'load audio failure - ' + item.url;
96
+ cc.log(message);
97
+ callback(message);
98
+ };
99
+ dom.addEventListener("canplaythrough", success, false);
100
+ dom.addEventListener("error", failure, false);
101
+ if (__audioSupport.USE_LOADER_EVENT)
102
+ dom.addEventListener(__audioSupport.USE_LOADER_EVENT, success, false);
103
+ }
104
+ ;
105
+ // cocos2.0以上版本加载webaudio,兼容1X版本
106
+ function loadWebAudio2X(item, callback) {
107
+ if (!context)
108
+ callback(new Error('Audio Downloader: no web audio context.'));
109
+ var data = _getRes(item);
110
+ if (data == null) {
111
+ callback();
112
+ return;
113
+ }
114
+ data = convertBase64(data);
115
+ data = base64toArray(data);
116
+ if (data) {
117
+ context["decodeAudioData"](data.buffer, function (buffer) {
118
+ //success
119
+ callback(null, buffer);
120
+ }, function () {
121
+ //error
122
+ callback('decode error - ' + item.id, null);
123
+ });
124
+ }
125
+ else {
126
+ callback('request error - ' + item.id, null);
127
+ }
128
+ ;
129
+ }
130
+ ;
131
+ // web加载音频
132
+ function loadWebAudio(item, callback) {
133
+ loadWebAudio2X(item, callback);
134
+ }
135
+ ;
136
+ // dom加载音频
137
+ function loadDomAudio(item, callback) {
138
+ loadDomAudio2X(item, callback);
139
+ }
140
+ ;
141
+ // web加载音频
142
+ downloadAudio = function (item, callback) {
143
+ if (formatSupport.length === 0) {
144
+ return new Error('Audio Downloader: audio not supported on this browser!');
145
+ }
146
+ ;
147
+ var loader;
148
+ if (!__audioSupport.WEB_AUDIO) {
149
+ // If WebAudio is not supported, load using DOM mode
150
+ loader = loadDomAudio;
151
+ }
152
+ else {
153
+ var loadByDeserializedAudio = item._owner instanceof cc.AudioClip;
154
+ if (loadByDeserializedAudio) {
155
+ loader = (item._owner.loadMode === cc.AudioClip.LoadMode.WEB_AUDIO) ?
156
+ loadWebAudio : loadDomAudio;
157
+ }
158
+ else {
159
+ loader = (item.urlParam && item.urlParam['useDom']) ? loadDomAudio :
160
+ loadWebAudio;
161
+ }
162
+ ;
163
+ }
164
+ ;
165
+ if (!loader) {
166
+ loader = loadDomAudio;
167
+ }
168
+ ;
169
+ loader(item, callback);
170
+ };
171
+ })();
172
+ function base64toArray(base64) {
173
+ // 将base64转为Unicode规则编码
174
+ var bstr = atob(base64.substring(base64.indexOf(',') + 1)), n = bstr.length, u8arr = new Uint8Array(n);
175
+ while (n--) {
176
+ u8arr[n] = bstr.charCodeAt(n); // 转换编码后才可以使用charCodeAt 找到Unicode编码
177
+ }
178
+ ;
179
+ return u8arr;
180
+ }
181
+ ;
182
+ // 二进制
183
+ var downloadBinary = null;
184
+ (function () {
185
+ downloadBinary = function (item, callback) {
186
+ var data = _getRes(item);
187
+ if (data == null) {
188
+ callback();
189
+ return;
190
+ }
191
+ ;
192
+ data = base64toArray(data);
193
+ callback(null, data);
194
+ };
195
+ }());
196
+ // 字体
197
+ function loadFont(item, callback) {
198
+ var url = item.url;
199
+ var fontFamilyName = url.replace(/[.\/ "'\\]*/g, "");
200
+ var data = _getRes(item);
201
+ if (data == null) {
202
+ callback();
203
+ return;
204
+ }
205
+ ;
206
+ var fontFace = new FontFace(fontFamilyName, `url(${data})`);
207
+ document.fonts.add(fontFace);
208
+ fontFace.load();
209
+ fontFace.loaded.then(function () {
210
+ callback(null, fontFamilyName);
211
+ }, function () {
212
+ cc.warnID(4933, fontFamilyName);
213
+ callback(null, fontFamilyName);
214
+ });
215
+ }
216
+ ;
217
+ // 添加加载函数
218
+ cc.loader.addDownloadHandlers({
219
+ // Images
220
+ 'png': downloadImage,
221
+ 'jpg': downloadImage,
222
+ 'bmp': downloadImage,
223
+ 'jpeg': downloadImage,
224
+ 'gif': downloadImage,
225
+ 'ico': downloadImage,
226
+ 'tiff': downloadImage,
227
+ 'webp': downloadImage,
228
+ 'image': downloadImage,
229
+ // Audio
230
+ 'mp3': downloadAudio,
231
+ 'ogg': downloadAudio,
232
+ 'wav': downloadAudio,
233
+ 'm4a': downloadAudio,
234
+ // Txt
235
+ 'txt': downloadText,
236
+ 'xml': downloadText,
237
+ 'vsh': downloadText,
238
+ 'fsh': downloadText,
239
+ 'atlas': downloadText,
240
+ 'tmx': downloadText,
241
+ 'tsx': downloadText,
242
+ 'json': downloadText,
243
+ 'ExportJson': downloadText,
244
+ 'plist': downloadText,
245
+ 'fnt': downloadText,
246
+ // Binary
247
+ 'binary': downloadBinary,
248
+ 'bin': downloadBinary,
249
+ 'dbbin': downloadBinary,
250
+ 'pvr': downloadBinary,
251
+ 'pkm': downloadBinary,
252
+ 'default': downloadText
253
+ });
254
+ cc.loader.addLoadHandlers({
255
+ // Font
256
+ 'ttf': loadFont,
257
+ 'font': loadFont,
258
+ 'eot': loadFont,
259
+ 'woff': loadFont,
260
+ 'svg': loadFont,
261
+ 'ttc': loadFont,
262
+ });
263
+ function base64ToBlob(base64, fileType) {
264
+ let audioSrc = base64;
265
+ let arr = audioSrc.split(',');
266
+ let array = arr[0].match(/:(.*?);/);
267
+ let mime = (array && array.length > 1 ? array[1] : type) || type;
268
+ let bytes = window.atob(arr[1]);
269
+ let ab = new ArrayBuffer(bytes.length);
270
+ let ia = new Uint8Array(ab);
271
+ for (let i = 0; i < bytes.length; i++) {
272
+ ia[i] = bytes.charCodeAt(i);
273
+ }
274
+ return new Blob([ab], {
275
+ type: mime
276
+ });
277
+ }
278
+ if (cc.VideoPlayer) {
279
+ const setURL = cc.VideoPlayer.Impl.prototype.setURL;
280
+ cc.VideoPlayer.Impl.prototype.setURL = function (url, muted) {
281
+ var res = _getRes({ url: url });
282
+ if (res) {
283
+ res = base64ToBlob(res);
284
+ res = URL.createObjectURL(res);
285
+ return setURL.call(this, res, muted);
286
+ }
287
+ return setURL.call(this, url, muted);
288
+ };
289
+ }
290
+ };
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ (function () {
3
+ console.timeEnd("load html");
4
+ if (!window["JSZip"]) {
5
+ _initJs();
6
+ return;
7
+ }
8
+ _zip();
9
+ function _zip() {
10
+ console.time("load res");
11
+ window.__res = window.__res || {};
12
+ const zip = new JSZip();
13
+ let progress = 0;
14
+ zip.loadAsync(window.__zip, {
15
+ base64: true
16
+ }).then(function (zip) {
17
+ for (var filePath in zip.files) {
18
+ if (zip.files[filePath].dir)
19
+ continue;
20
+ progress++;
21
+ // console.log(filePath, type);
22
+ let key = filePath;
23
+ zip.file(key).async("string").then(function (data) {
24
+ window.__res[key] = data;
25
+ progress--;
26
+ if (progress == 0) {
27
+ window.__zip = null;
28
+ console.timeEnd("load res");
29
+ _initJs();
30
+ }
31
+ });
32
+ }
33
+ ;
34
+ }).catch((err) => {
35
+ throw err;
36
+ });
37
+ }
38
+ function _eval(txt) {
39
+ eval.call(window, txt);
40
+ }
41
+ function _initJs() {
42
+ window.__js = {};
43
+ for (var filePath in window.__res) {
44
+ let suffix = filePath.split(".");
45
+ suffix = "." + suffix[suffix.length - 1];
46
+ if (suffix == ".js") {
47
+ window.__js[filePath] = window.__res[filePath];
48
+ }
49
+ }
50
+ var arr = ["src/settings.js", "main.js", "cocos2d-js.js", "cocos2d-js-min.js", "physics.js", "physics-min.js"];
51
+ for (let i = 0; i < arr.length; i++) {
52
+ _eval(window.__js[arr[i]]);
53
+ if (arr[i] == "src/settings.js") {
54
+ let jsList = window._CCSettings.jsList;
55
+ if (jsList) {
56
+ jsList = jsList.map(function (x) {
57
+ return 'src/' + x;
58
+ });
59
+ arr.push(...jsList);
60
+ }
61
+ arr.push("src/project.dev.js");
62
+ arr.push("src/project.js");
63
+ window._CCSettings.jsList = [];
64
+ }
65
+ }
66
+ _success();
67
+ }
68
+ function _vconsole() {
69
+ if (window.__js["vconsole.min.js"]) {
70
+ _eval(window.__js["vconsole.min.js"]);
71
+ delete window.__js["vconsole.min.js"];
72
+ window.VConsole && (window.vConsole = new VConsole());
73
+ }
74
+ }
75
+ function _success() {
76
+ _vconsole();
77
+ var funGameRun = cc.game.run;
78
+ cc.game.run = function (option, onStart) {
79
+ option.jsList = [];
80
+ funGameRun.call(cc.game, option, onStart);
81
+ };
82
+ window.__custom();
83
+ // 游戏启动脚本
84
+ window.boot();
85
+ }
86
+ })();
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ window.__custom = function () {
3
+ console.log("init hook");
4
+ function _getRes(url) {
5
+ return window.__res[url] || url;
6
+ }
7
+ function base64toArray(base64) {
8
+ // 将base64转为Unicode规则编码
9
+ var bstr = atob(base64.substring(base64.indexOf(',') + 1)), n = bstr.length, u8arr = new Uint8Array(n);
10
+ while (n--) {
11
+ u8arr[n] = bstr.charCodeAt(n); // 转换编码后才可以使用charCodeAt 找到Unicode编码
12
+ }
13
+ ;
14
+ return u8arr;
15
+ }
16
+ ;
17
+ function convertBase64(data) {
18
+ data = data.replace(/-/g, '+');
19
+ data = data.replace(/_/g, '/');
20
+ return data;
21
+ }
22
+ ;
23
+ function downloadText(url, options, onComplete) {
24
+ options.responseType = "text"; //.
25
+ var data = _getRes(url);
26
+ onComplete(null, data);
27
+ }
28
+ ;
29
+ function downloadJson(url, options, onComplete) {
30
+ options.responseType = "text"; //.
31
+ var data = _getRes(url);
32
+ onComplete(null, JSON.parse(data));
33
+ }
34
+ function downloadImage(url, options, onComplete) {
35
+ var img = new Image();
36
+ var data = _getRes(url);
37
+ function loadCallback() {
38
+ img.removeEventListener('load', loadCallback);
39
+ img.removeEventListener('error', errorCallback);
40
+ onComplete && onComplete(null, img);
41
+ }
42
+ ;
43
+ function errorCallback() {
44
+ img.removeEventListener('load', loadCallback);
45
+ img.removeEventListener('error', errorCallback);
46
+ onComplete && onComplete(new Error('Load image (' + url + ') failed'));
47
+ }
48
+ ;
49
+ img.addEventListener('load', loadCallback);
50
+ img.addEventListener('error', errorCallback);
51
+ img.src = data;
52
+ return img;
53
+ }
54
+ ;
55
+ //音频
56
+ var downloadAudio = null;
57
+ (function () {
58
+ var __audioSupport = cc.sys.__audioSupport;
59
+ var formatSupport = __audioSupport.format;
60
+ var context = __audioSupport.context;
61
+ /** 下载数组缓冲区 */
62
+ var downloadArrayBuffer = function (url, options, onComplete) {
63
+ options.responseType = "arraybuffer";
64
+ var data = _getRes(url);
65
+ data = convertBase64(data);
66
+ data = base64toArray(data);
67
+ if (data) {
68
+ context["decodeAudioData"](data.buffer, function (buffer) {
69
+ //success
70
+ onComplete && onComplete(null, buffer);
71
+ }, function () {
72
+ //error
73
+ onComplete && onComplete('decode error - ' + url, null);
74
+ });
75
+ }
76
+ else {
77
+ onComplete('request error - ' + url, null);
78
+ }
79
+ ;
80
+ };
81
+ function loadDomAudio(url, options, onComplete) {
82
+ var dom = document.createElement('audio');
83
+ dom.muted = false;
84
+ var data = _getRes(url);
85
+ dom.src = data;
86
+ var clearEvent = function () {
87
+ clearTimeout(timer);
88
+ dom.removeEventListener("canplaythrough", success, false);
89
+ dom.removeEventListener("error", failure, false);
90
+ if (__audioSupport.USE_LOADER_EVENT)
91
+ dom.removeEventListener(__audioSupport.USE_LOADER_EVENT, success, false);
92
+ };
93
+ var timer = setTimeout(function () {
94
+ if (dom.readyState === 0)
95
+ failure();
96
+ else
97
+ success();
98
+ }, 8000);
99
+ var success = function () {
100
+ clearEvent();
101
+ onComplete && onComplete(null, dom);
102
+ };
103
+ var failure = function () {
104
+ clearEvent();
105
+ var message = 'load audio failure - ' + url;
106
+ cc.log(message);
107
+ onComplete && onComplete(new Error(message));
108
+ };
109
+ dom.addEventListener("canplaythrough", success, false);
110
+ dom.addEventListener("error", failure, false);
111
+ if (__audioSupport.USE_LOADER_EVENT)
112
+ dom.addEventListener(__audioSupport.USE_LOADER_EVENT, success, false);
113
+ return dom;
114
+ }
115
+ ;
116
+ function loadWebAudio(url, options, onComplete) {
117
+ // web audio need to download file as arrayBuffer
118
+ if (options.audioLoadMode !== cc.AudioClip.LoadMode.DOM_AUDIO) {
119
+ downloadArrayBuffer(url, options, onComplete);
120
+ }
121
+ else {
122
+ loadDomAudio(url, options, onComplete);
123
+ }
124
+ }
125
+ ;
126
+ // web加载音频
127
+ downloadAudio = function (url, options, onComplete) {
128
+ if (formatSupport.length === 0) {
129
+ return new Error('Audio Downloader: audio not supported on this browser!');
130
+ }
131
+ ;
132
+ var loader = __audioSupport.WEB_AUDIO ? loadWebAudio : loadDomAudio;
133
+ loader(url, options, onComplete);
134
+ };
135
+ })();
136
+ // 二进制
137
+ var downloadBinary = null;
138
+ (function () {
139
+ downloadBinary = function (url, options, onComplete) {
140
+ var data = _getRes(url);
141
+ data = base64toArray(data);
142
+ onComplete(null, data);
143
+ };
144
+ }());
145
+ /** 下载视频 */
146
+ var downloadVideo = function (url, options, onComplete) {
147
+ var data = _getRes(url);
148
+ data = convertBase64(data);
149
+ data = base64toArray(data);
150
+ onComplete && onComplete(null, data);
151
+ };
152
+ // 字体
153
+ function loadFont(url, options, onComplete) {
154
+ var fontFamilyName = url.replace(/[.\/ "'\\]*/g, "");
155
+ var data = _getRes(url);
156
+ if (data == null) {
157
+ onComplete();
158
+ return;
159
+ }
160
+ ;
161
+ var fontFace = new FontFace(fontFamilyName, `url(${data})`);
162
+ document.fonts.add(fontFace);
163
+ fontFace.load();
164
+ fontFace.loaded.then(function () {
165
+ onComplete(null, fontFamilyName);
166
+ }, function () {
167
+ cc.warnID(4933, fontFamilyName);
168
+ onComplete(null, fontFamilyName);
169
+ });
170
+ }
171
+ ;
172
+ /** 下载脚本 */
173
+ function downloadScript(url, options, onComplete) {
174
+ eval(_getRes(url));
175
+ onComplete && onComplete(null);
176
+ }
177
+ var downloadBundle = null;
178
+ (function () {
179
+ /** 下载捆绑包 */
180
+ const REGEX = /^(?:\w+:\/\/|\.+\/).+/;
181
+ downloadBundle = function (nameOrUrl, options, onComplete) {
182
+ let bundleName = cc.path.basename(nameOrUrl);
183
+ let url = nameOrUrl;
184
+ if (!REGEX.test(url))
185
+ url = 'assets/' + bundleName;
186
+ var version = options.version || cc.assetManager.downloader.bundleVers[bundleName];
187
+ var count = 0;
188
+ var config = `${url}/config.${version ? version + '.' : ''}json`;
189
+ let out = null, error = null;
190
+ downloadJson(config, options, function (err, response) {
191
+ if (err) {
192
+ error = err;
193
+ }
194
+ out = response;
195
+ out && (out.base = url + '/');
196
+ count++;
197
+ if (count === 2) {
198
+ onComplete && onComplete(error, out);
199
+ }
200
+ });
201
+ var js = `${url}/index.${version ? version + '.' : ''}js`;
202
+ downloadScript(js, options, function (err) {
203
+ if (err) {
204
+ error = err;
205
+ }
206
+ count++;
207
+ if (count === 2) {
208
+ onComplete && onComplete(error, out);
209
+ }
210
+ });
211
+ };
212
+ })();
213
+ var downloaders = {
214
+ // Images
215
+ '.png': downloadImage,
216
+ '.jpg': downloadImage,
217
+ '.bmp': downloadImage,
218
+ '.jpeg': downloadImage,
219
+ '.gif': downloadImage,
220
+ '.ico': downloadImage,
221
+ '.tiff': downloadImage,
222
+ '.webp': downloadImage,
223
+ '.image': downloadImage,
224
+ // Audio
225
+ '.mp3': downloadAudio,
226
+ '.ogg': downloadAudio,
227
+ '.wav': downloadAudio,
228
+ '.m4a': downloadAudio,
229
+ // Txt
230
+ '.txt': downloadText,
231
+ '.xml': downloadText,
232
+ '.vsh': downloadText,
233
+ '.fsh': downloadText,
234
+ '.atlas': downloadText,
235
+ '.tmx': downloadText,
236
+ '.tsx': downloadText,
237
+ '.plist': downloadText,
238
+ '.fnt': downloadText,
239
+ // Json
240
+ '.json': downloadJson,
241
+ '.ExportJson': downloadJson,
242
+ // Video
243
+ '.mp4': downloadVideo,
244
+ '.avi': downloadVideo,
245
+ '.mov': downloadVideo,
246
+ '.mpg': downloadVideo,
247
+ '.mpeg': downloadVideo,
248
+ '.rm': downloadVideo,
249
+ '.rmvb': downloadVideo,
250
+ // Binary
251
+ '.binary': downloadBinary,
252
+ '.bin': downloadBinary,
253
+ '.dbbin': downloadBinary,
254
+ '.skel': downloadBinary,
255
+ '.pvr': downloadBinary,
256
+ '.pkm': downloadBinary,
257
+ // Font
258
+ '.ttf': loadFont,
259
+ '.font': loadFont,
260
+ '.eot': loadFont,
261
+ '.woff': loadFont,
262
+ '.svg': loadFont,
263
+ '.ttc': loadFont,
264
+ ".js": downloadScript,
265
+ 'bundle': downloadBundle,
266
+ // 'downloadFile': downloadText,
267
+ 'default': downloadText
268
+ };
269
+ cc.assetManager.downloader.loadScript = downloadScript;
270
+ cc.assetManager.downloader.register(downloaders);
271
+ function base64ToBlob(base64, fileType) {
272
+ let audioSrc = base64;
273
+ let arr = audioSrc.split(',');
274
+ let array = arr[0].match(/:(.*?);/);
275
+ let mime = (array && array.length > 1 ? array[1] : type) || type;
276
+ let bytes = window.atob(arr[1]);
277
+ let ab = new ArrayBuffer(bytes.length);
278
+ let ia = new Uint8Array(ab);
279
+ for (let i = 0; i < bytes.length; i++) {
280
+ ia[i] = bytes.charCodeAt(i);
281
+ }
282
+ return new Blob([ab], {
283
+ type: mime
284
+ });
285
+ }
286
+ if (cc.VideoPlayer) {
287
+ const setURL = cc.VideoPlayer.Impl.prototype.setURL;
288
+ cc.VideoPlayer.Impl.prototype.setURL = function (url, muted) {
289
+ var res = _getRes(url);
290
+ if (res) {
291
+ res = base64ToBlob(res);
292
+ res = URL.createObjectURL(res);
293
+ return setURL.call(this, res, muted);
294
+ }
295
+ return setURL.call(this, url, muted);
296
+ };
297
+ }
298
+ };