hiepdh-playable-toolkit 1.0.0 → 2.0.1

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 (41) 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/package.json +22 -13
  39. package/setup.js +79 -50
  40. /package/{injectCustomScript.js → 3x/injectCustomScript.js} +0 -0
  41. /package/{patch-template-unityReject.js → 3x/patch-template-unityReject.js} +0 -0
@@ -0,0 +1,87 @@
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.log("init unzip");
11
+ console.time("load res");
12
+ window.__res = window.__res || {};
13
+ const zip = new JSZip();
14
+ let progress = 0;
15
+ zip.loadAsync(window.__zip, {
16
+ base64: true
17
+ }).then(function (zip) {
18
+ for (var filePath in zip.files) {
19
+ if (zip.files[filePath].dir)
20
+ continue;
21
+ progress++;
22
+ // console.log(filePath, type);
23
+ let key = filePath;
24
+ zip.file(key).async("string").then(function (data) {
25
+ window.__res[key] = data;
26
+ progress--;
27
+ if (progress == 0) {
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
+ console.log("init js");
43
+ window.__js = {};
44
+ for (var filePath in window.__res) {
45
+ let suffix = filePath.split(".");
46
+ suffix = "." + suffix[suffix.length - 1];
47
+ if (suffix == ".js") {
48
+ window.__js[filePath] = window.__res[filePath];
49
+ }
50
+ }
51
+ var arr = ["src/settings.js", "main.js", "cocos2d-js.js", "cocos2d-js-min.js", "physics.js", "physics-min.js"];
52
+ for (let i = 0; i < arr.length; i++) {
53
+ _eval(window.__js[arr[i]]);
54
+ if (arr[i] == "src/settings.js") {
55
+ let jsList = window._CCSettings.jsList;
56
+ if (jsList) {
57
+ jsList = jsList.map(function (x) {
58
+ return 'src/' + x;
59
+ });
60
+ arr.push(...jsList);
61
+ }
62
+ arr.push("src/project.dev.js");
63
+ arr.push("src/project.js");
64
+ window._CCSettings.jsList = [];
65
+ }
66
+ }
67
+ _success();
68
+ }
69
+ function _vconsole() {
70
+ if (window.__js["vconsole.min.js"]) {
71
+ _eval(window.__js["vconsole.min.js"]);
72
+ delete window.__js["vconsole.min.js"];
73
+ window.VConsole && (window.vConsole = new VConsole());
74
+ }
75
+ }
76
+ function _success() {
77
+ _vconsole();
78
+ var funGameRun = cc.game.run;
79
+ cc.game.run = function (option, onStart) {
80
+ option.jsList = [];
81
+ funGameRun.call(cc.game, option, onStart);
82
+ };
83
+ window.__custom();
84
+ // 游戏启动脚本
85
+ window.boot();
86
+ }
87
+ })();
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ window._custom = function () {
3
+ function _importMap() {
4
+ var script = document.createElement('script');
5
+ script.type = "systemjs-importmap";
6
+ script.text = getRes("src/import-map.json");
7
+ document.body.appendChild(script);
8
+ }
9
+ _importMap();
10
+ function getResPath(key, target, log) {
11
+ for (var k in target) {
12
+ if (k == key) {
13
+ return k;
14
+ }
15
+ const index = key.indexOf(k);
16
+ if (index != -1 && index + k.length == key.length) {
17
+ return k;
18
+ }
19
+ }
20
+ return null;
21
+ }
22
+ function getRes(key) {
23
+ return window.__res[getResPath(key, window.__res)];
24
+ }
25
+ function getScript(key) {
26
+ if (key.indexOf("bullet.wasm") != -1) {
27
+ for (var k2 in window.__js) {
28
+ if (k2.indexOf("bullet.cocos") != -1) {
29
+ key = k2;
30
+ break;
31
+ }
32
+ }
33
+ }
34
+ let _key = getResPath(key, window.__js);
35
+ var res = window.__js[_key];
36
+ if (res) {
37
+ delete window.__js[_key];
38
+ }
39
+ return res;
40
+ }
41
+ function _initScript() {
42
+ window["_createLocalJSElement"] = function _XMLLocalRequest() {
43
+ let node = document.createElement("_my");
44
+ node.src = "";
45
+ node.addEventListener = function (type, func) {
46
+ //type : load error
47
+ this[type] = func;
48
+ if (type == "load") {
49
+ setTimeout(() => {
50
+ console.log("load _script:", node.src);
51
+ let res = getScript(node.src);
52
+ if (!res) {
53
+ console.log("no find", node.src);
54
+ return;
55
+ }
56
+ _eval(res);
57
+ setTimeout(() => {
58
+ if (window.cc) {
59
+ _custom_cc();
60
+ }
61
+ func();
62
+ });
63
+ });
64
+ }
65
+ };
66
+ return node;
67
+ };
68
+ }
69
+ function _custom_cc() {
70
+ if (window.xxxx__) {
71
+ return;
72
+ }
73
+ window.xxxx__ = true;
74
+ function base64ToBlob(base64, fileType) {
75
+ let audioSrc = base64;
76
+ let arr = audioSrc.split(',');
77
+ let array = arr[0].match(/:(.*?);/);
78
+ let mime = (array && array.length > 1 ? array[1] : type) || type;
79
+ let bytes = window.atob(arr[1]);
80
+ let ab = new ArrayBuffer(bytes.length);
81
+ let ia = new Uint8Array(ab);
82
+ for (let i = 0; i < bytes.length; i++) {
83
+ ia[i] = bytes.charCodeAt(i);
84
+ }
85
+ return new Blob([ab], {
86
+ type: mime
87
+ });
88
+ }
89
+ if (cc.internal.VideoPlayerImplManager) {
90
+ function downloadVideo(url, options, onComplete) {
91
+ var video = document.createElement('video');
92
+ var source = document.createElement('source');
93
+ video.appendChild(source);
94
+ onComplete(null, video);
95
+ }
96
+ cc.assetManager.downloader.register({
97
+ '.mp4': downloadVideo,
98
+ '.avi': downloadVideo,
99
+ '.mov': downloadVideo,
100
+ '.mpg': downloadVideo,
101
+ '.mpeg': downloadVideo,
102
+ '.rm': downloadVideo,
103
+ '.rmvb': downloadVideo
104
+ });
105
+ const getImpl = cc.internal.VideoPlayerImplManager.getImpl;
106
+ cc.internal.VideoPlayerImplManager.getImpl = function (comp) {
107
+ const impl = getImpl.call(this, comp);
108
+ const createVideoPlayer = impl.createVideoPlayer;
109
+ impl.createVideoPlayer = function (url) {
110
+ var res = getRes(url);
111
+ if (res) {
112
+ res = base64ToBlob(res);
113
+ res = URL.createObjectURL(res);
114
+ return createVideoPlayer.call(this, res);
115
+ }
116
+ return createVideoPlayer.call(this, url);
117
+ };
118
+ return impl;
119
+ };
120
+ }
121
+ function _initFont() {
122
+ function loadFont(url, options, onComplete) {
123
+ var fontFamilyName = url.replace(/[.\/ "'\\]*/g, "");
124
+ var data = getRes(url);
125
+ if (data == null) {
126
+ onComplete();
127
+ return;
128
+ }
129
+ ;
130
+ var fontFace = new FontFace(fontFamilyName, `url(${data})`);
131
+ document.fonts.add(fontFace);
132
+ fontFace.load();
133
+ fontFace.loaded.then(function () {
134
+ onComplete(null, fontFamilyName);
135
+ }, function () {
136
+ console.error(`url${url}load fail`);
137
+ onComplete(null, fontFamilyName);
138
+ });
139
+ }
140
+ ;
141
+ cc.assetManager.downloader.register({
142
+ '.font': loadFont,
143
+ '.eot': loadFont,
144
+ '.ttf': loadFont,
145
+ '.woff': loadFont,
146
+ '.svg': loadFont,
147
+ '.ttc': loadFont,
148
+ });
149
+ }
150
+ _initFont();
151
+ function _initImage() {
152
+ function downloadImage(url, options, onComplete) {
153
+ var img = new Image();
154
+ function loadCallback() {
155
+ img.removeEventListener('load', loadCallback);
156
+ img.removeEventListener('error', errorCallback);
157
+ if (onComplete) {
158
+ onComplete(null, img);
159
+ }
160
+ }
161
+ function errorCallback() {
162
+ img.removeEventListener('load', loadCallback);
163
+ img.removeEventListener('error', errorCallback);
164
+ if (onComplete) {
165
+ onComplete(new Error(getError(4930, url)));
166
+ }
167
+ }
168
+ img.addEventListener('load', loadCallback);
169
+ img.addEventListener('error', errorCallback);
170
+ img.src = getRes(url);
171
+ return img;
172
+ }
173
+ // function downloadImage(url, options, onComplete) {
174
+ // var func = sys.hasFeature(sys.Feature.IMAGE_BITMAP) && legacyCC.assetManager.allowImageBitmap ? downloadBlob : downloadDomImage;
175
+ // func(url, options, onComplete);
176
+ // };
177
+ cc.assetManager.downloader.register({
178
+ '.png': downloadImage,
179
+ '.jpg': downloadImage,
180
+ '.bmp': downloadImage,
181
+ '.jpeg': downloadImage,
182
+ '.gif': downloadImage,
183
+ '.ico': downloadImage,
184
+ '.tiff': downloadImage,
185
+ '.webp': downloadImage,
186
+ '.image': downloadImage,
187
+ });
188
+ }
189
+ _initImage();
190
+ }
191
+ _initScript();
192
+ function base64toArrayBuffer(base64) {
193
+ // 将base64转为Unicode规则编码
194
+ var bstr = atob(base64.substring(base64.indexOf(',') + 1)), n = bstr.length, u8arr = new Uint8Array(n);
195
+ while (n--) {
196
+ u8arr[n] = bstr.charCodeAt(n); // 转换编码后才可以使用charCodeAt 找到Unicode编码
197
+ }
198
+ ;
199
+ return u8arr.buffer;
200
+ }
201
+ function _initXMLHttp() {
202
+ window["_XMLLocalRequest"] = function _XMLLocalRequest() {
203
+ this.open = function (method, url, async, password) {
204
+ this.url = url;
205
+ this.status = 200;
206
+ };
207
+ this.overrideMimeType = function () {
208
+ };
209
+ this.setRequestHeader = function () {
210
+ };
211
+ this.send = function () {
212
+ const res = getRes(this.url);
213
+ let _response = null;
214
+ switch (this.responseType) {
215
+ case "json":
216
+ _response = JSON.parse(res);
217
+ break;
218
+ case "text":
219
+ _response = res;
220
+ break;
221
+ case "arraybuffer":
222
+ _response = base64toArrayBuffer(res);
223
+ break;
224
+ default:
225
+ console.err("type error", url, this.responseType);
226
+ break;
227
+ }
228
+ this.response = _response;
229
+ setTimeout(() => {
230
+ this.onload();
231
+ });
232
+ };
233
+ };
234
+ }
235
+ _initXMLHttp();
236
+ function _eval(res) {
237
+ eval(res);
238
+ }
239
+ _eval(getScript("src/polyfills.bundle.js"));
240
+ _eval(getScript("src/system.bundle.js"));
241
+ System.import("./index.js").catch(function (err) {
242
+ console.error(err);
243
+ });
244
+ };
@@ -0,0 +1,59 @@
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
+ console.timeEnd("load res");
28
+ _initJs();
29
+ }
30
+ });
31
+ }
32
+ ;
33
+ }).catch((err) => {
34
+ throw err;
35
+ });
36
+ }
37
+ function _initJs() {
38
+ window.__js = {};
39
+ for (var filePath in window.__res) {
40
+ let suffix = filePath.split(".");
41
+ suffix = "." + suffix[suffix.length - 1];
42
+ if (suffix == ".js") {
43
+ window.__js[filePath] = window.__res[filePath];
44
+ }
45
+ }
46
+ _success();
47
+ }
48
+ function _vconsole() {
49
+ if (window.__js["vconsole.min.js"]) {
50
+ eval(window.__js["vconsole.min.js"]);
51
+ delete window.__js["vconsole.min.js"];
52
+ window.VConsole && (window.vConsole = new VConsole());
53
+ }
54
+ }
55
+ function _success() {
56
+ _vconsole();
57
+ _custom();
58
+ }
59
+ })();