hiepdh-playable-toolkit 3.0.1 → 3.0.3
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.
- package/2x/build-inline.js +397 -0
- package/2x/fireworks.js +8 -0
- package/2x/templates/package-lock.json +2 -2
- package/3x/build-templates/web-mobile/index.ejs +47 -47
- package/3x/extensions/super-html/README-CN.md +16 -16
- package/3x/extensions/super-html/dist/2x/main.js +64 -64
- package/3x/extensions/super-html/dist/2x/panel/index.js +66 -66
- package/3x/extensions/super-html/dist/3x/builder.js +8 -8
- package/3x/extensions/super-html/dist/3x/hooks.js +24 -24
- package/3x/extensions/super-html/dist/3x/main.js +27 -27
- package/3x/extensions/super-html/dist/3x/panel/index.js +63 -63
- package/3x/extensions/super-html/dist/core/build.js +58 -58
- package/3x/extensions/super-html/dist/core/common/cache.js +124 -124
- package/3x/extensions/super-html/dist/core/common/log.js +46 -46
- package/3x/extensions/super-html/dist/core/common/utils.js +107 -107
- package/3x/extensions/super-html/dist/core/config.js +71 -71
- package/3x/extensions/super-html/dist/core/task.js +356 -356
- package/3x/extensions/super-html/dist/custom_script/23x/custom-23x.js +290 -290
- package/3x/extensions/super-html/dist/custom_script/23x/index-23x.js +86 -86
- package/3x/extensions/super-html/dist/custom_script/24x/custom-24x.js +298 -298
- package/3x/extensions/super-html/dist/custom_script/24x/index-24x.js +87 -87
- package/3x/extensions/super-html/dist/custom_script/34x/custom-34x.js +244 -244
- package/3x/extensions/super-html/dist/custom_script/34x/index-34x.js +59 -59
- package/3x/extensions/super-html/dist/custom_script/javascript-obfuscator.js +9719 -9719
- package/3x/extensions/super-html/dist/custom_script/pako.js +1462 -1462
- package/3x/extensions/super-html/dist/test/_test.js +27 -27
- package/3x/extensions/super-html/i18n/en.js +4 -4
- package/3x/extensions/super-html/i18n/zh.js +4 -4
- package/3x/extensions/super-html/package-lock.json +744 -744
- package/3x/extensions/super-html/package.json +59 -59
- package/3x/extensions/super-html/static/index.html +44 -44
- package/3x/extensions/super-html/tsconfig.json +13 -13
- package/3x/plugins/ironsource_api.js +77 -46
- package/3x/templates/package-lock.json +2 -2
- package/package.json +33 -33
- package/setup.js +60 -56
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { minify } from "minify";
|
|
4
|
+
|
|
5
|
+
const buildPathCocos = "./build/web-mobile/";
|
|
6
|
+
const buildPathTarget = "./build-inline/";
|
|
7
|
+
const outputImagesPath = "./extracted_images/";
|
|
8
|
+
|
|
9
|
+
const ASSET_OVERRIDES = {
|
|
10
|
+
"assets/main/native/58/58b02edc-9090-4f84-a46b-4184481562ef.jpg": "",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
buildInlineHTML();
|
|
14
|
+
|
|
15
|
+
async function buildInlineHTML() {
|
|
16
|
+
if (!fs.existsSync(buildPathTarget))
|
|
17
|
+
fs.mkdirSync(buildPathTarget, { recursive: true });
|
|
18
|
+
|
|
19
|
+
let htmlFileContent = await fs.promises.readFile(
|
|
20
|
+
`${buildPathCocos}index.html`,
|
|
21
|
+
"utf8"
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
htmlFileContent = htmlFileContent.replace(/<link(.+?)\/>/gs, "");
|
|
25
|
+
|
|
26
|
+
let cssFileContent = await fs.promises.readFile(
|
|
27
|
+
`${buildPathCocos}style-mobile.css`,
|
|
28
|
+
"utf8"
|
|
29
|
+
);
|
|
30
|
+
cssFileContent = cssFileContent.replace("./splash.png", "");
|
|
31
|
+
htmlFileContent = await addScriptContentToHTML(
|
|
32
|
+
htmlFileContent,
|
|
33
|
+
cssFileContent,
|
|
34
|
+
"head",
|
|
35
|
+
"style"
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
htmlFileContent = htmlFileContent.replace(/<script(.+?)\/script>/gs, "");
|
|
39
|
+
|
|
40
|
+
const fireworksPath = "./fireworks.js";
|
|
41
|
+
let fireworksLib = "";
|
|
42
|
+
if (fs.existsSync(fireworksPath)) {
|
|
43
|
+
fireworksLib = await fs.promises.readFile(fireworksPath, "utf8");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const customInjections = `
|
|
47
|
+
<script>
|
|
48
|
+
window.GameConfig = {
|
|
49
|
+
|
|
50
|
+
};
|
|
51
|
+
</script>
|
|
52
|
+
<script>
|
|
53
|
+
${fireworksLib}
|
|
54
|
+
</script>
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
htmlFileContent = htmlFileContent.replace(
|
|
58
|
+
"<body>",
|
|
59
|
+
`<body>\n${customInjections}`
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
let cocosLibContent = await fs.promises.readFile(
|
|
63
|
+
`${buildPathCocos}cocos2d-js-min.js`,
|
|
64
|
+
"utf8"
|
|
65
|
+
);
|
|
66
|
+
cocosLibContent = cocosLibContent.replace(
|
|
67
|
+
/new XMLHttpRequest/g,
|
|
68
|
+
"new CustomXMLHttpRequest"
|
|
69
|
+
);
|
|
70
|
+
cocosLibContent = cocosLibContent.replace(
|
|
71
|
+
/new Image\)/g,
|
|
72
|
+
`new Image);${getFunctionBody(injectLoadDomImage.toString())}`
|
|
73
|
+
);
|
|
74
|
+
cocosLibContent = cocosLibContent.replace(
|
|
75
|
+
'document.createElement("script")',
|
|
76
|
+
"new CustomCreateScript()"
|
|
77
|
+
);
|
|
78
|
+
cocosLibContent = cocosLibContent.replace(
|
|
79
|
+
".textContent=",
|
|
80
|
+
".textContent = loadFontURL(arguments[0]),window.thisIsATempParamOnly="
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
cocosLibContent = cocosLibContent.replace(
|
|
84
|
+
/window\.top&&window\.top\.scrollTo\(0,0\)/g,
|
|
85
|
+
"window.scrollTo(0,0)"
|
|
86
|
+
);
|
|
87
|
+
cocosLibContent = cocosLibContent.replace(
|
|
88
|
+
/\?\s*window\.scrollTo\(0,0\)\s*:\s*window\.top&&window\.top\.scrollTo\(0,0\)/g,
|
|
89
|
+
"? window.scrollTo(0,0)"
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
htmlFileContent = await addScriptContentToHTML(
|
|
93
|
+
htmlFileContent,
|
|
94
|
+
cocosLibContent
|
|
95
|
+
);
|
|
96
|
+
htmlFileContent = await addScriptToHTML(
|
|
97
|
+
htmlFileContent,
|
|
98
|
+
`${buildPathCocos}src/settings.js`
|
|
99
|
+
);
|
|
100
|
+
htmlFileContent = await addScriptToHTML(
|
|
101
|
+
htmlFileContent,
|
|
102
|
+
`${buildPathCocos}main.js`
|
|
103
|
+
);
|
|
104
|
+
htmlFileContent = await addScriptContentToHTML(
|
|
105
|
+
htmlFileContent,
|
|
106
|
+
`${injectCustomScript.toString()};injectCustomScript();`,
|
|
107
|
+
"body"
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (fs.existsSync(`${buildPathCocos}physics-min.js`)) {
|
|
111
|
+
let cocosLibPhysic = await fs.promises.readFile(
|
|
112
|
+
`${buildPathCocos}physics-min.js`,
|
|
113
|
+
"utf8"
|
|
114
|
+
);
|
|
115
|
+
htmlFileContent = await addScriptContentToHTML(
|
|
116
|
+
htmlFileContent,
|
|
117
|
+
cocosLibPhysic
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 7. ĐÓNG GÓI ASSETS VÀ MINIFY
|
|
122
|
+
htmlFileContent = htmlFileContent.replace(/<\/script><script>/g, ";");
|
|
123
|
+
htmlFileContent = await addScriptContentToHTML(
|
|
124
|
+
htmlFileContent,
|
|
125
|
+
await bundleAssetToScript(),
|
|
126
|
+
"body"
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
htmlFileContent = htmlFileContent.replace(/<\/script><script>/g, ";");
|
|
130
|
+
await fs.promises.writeFile(
|
|
131
|
+
`${buildPathTarget}index-full.html`,
|
|
132
|
+
htmlFileContent,
|
|
133
|
+
"utf8"
|
|
134
|
+
);
|
|
135
|
+
console.log(
|
|
136
|
+
`Output saved to: ${buildPathTarget}index-full.html (${await formatBytes(
|
|
137
|
+
htmlFileContent.length
|
|
138
|
+
)})`
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const minifyOptions = {
|
|
142
|
+
html: { removeOptionalTags: false, removeAttributeQuotes: false },
|
|
143
|
+
};
|
|
144
|
+
const minifyFileContent = await minify(
|
|
145
|
+
`${buildPathTarget}index-full.html`,
|
|
146
|
+
minifyOptions
|
|
147
|
+
);
|
|
148
|
+
await fs.promises.writeFile(
|
|
149
|
+
`${buildPathTarget}index.html`,
|
|
150
|
+
htmlFileContent,
|
|
151
|
+
"utf8"
|
|
152
|
+
);
|
|
153
|
+
console.log(
|
|
154
|
+
`Minify File saved to: ${buildPathTarget}index.html (${await formatBytes(
|
|
155
|
+
minifyFileContent.length
|
|
156
|
+
)})`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function getFunctionBody(fnStr) {
|
|
160
|
+
return fnStr.slice(fnStr.indexOf("{") + 1, fnStr.lastIndexOf("}"));
|
|
161
|
+
}
|
|
162
|
+
function injectLoadDomImage() {
|
|
163
|
+
var temp = new Image();
|
|
164
|
+
temp.src = window.bundleAsset[arguments[0]];
|
|
165
|
+
setTimeout(() => {
|
|
166
|
+
arguments[2] && arguments[2](null, temp);
|
|
167
|
+
}, 10);
|
|
168
|
+
return temp;
|
|
169
|
+
}
|
|
170
|
+
function injectCustomScript() {
|
|
171
|
+
window.runMyGame = function () {
|
|
172
|
+
if (window.isGameStarted) return;
|
|
173
|
+
window.isGameStarted = true;
|
|
174
|
+
console.log("UnityAds: Video ended, starting Playable now...");
|
|
175
|
+
setTimeout(window.boot, 1);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// 2. Kiểm tra môi trường MRAID (Unity Ads, AppLovin, Ironsource...)
|
|
179
|
+
if (typeof mraid !== "undefined") {
|
|
180
|
+
if (mraid.getState() === 'loading') {
|
|
181
|
+
mraid.addEventListener('ready', onMraidReady);
|
|
182
|
+
} else {
|
|
183
|
+
onMraidReady();
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
console.log("MRAID not found, running on browser...");
|
|
187
|
+
setTimeout(window.runMyGame, 100);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function onMraidReady() {
|
|
191
|
+
if (mraid.isViewable()) {
|
|
192
|
+
window.runMyGame();
|
|
193
|
+
} else {
|
|
194
|
+
mraid.addEventListener('viewableChange', function (viewable) {
|
|
195
|
+
if (viewable) {
|
|
196
|
+
window.runMyGame();
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
window.CustomCreateScript = function () {
|
|
203
|
+
var scriptElement = document.createElement("script");
|
|
204
|
+
scriptElement.removeEventListener = function () { };
|
|
205
|
+
scriptElement.addEventListener = function (eventName, cb) {
|
|
206
|
+
this.src = "";
|
|
207
|
+
if (eventName === "load")
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
cb && cb();
|
|
210
|
+
}, 10);
|
|
211
|
+
};
|
|
212
|
+
return scriptElement;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
window.loadFontURL = function (url) {
|
|
216
|
+
var base64Font = window.bundleAsset[url];
|
|
217
|
+
var fontFamilyName = getFontFamily(url);
|
|
218
|
+
var fontStr = "";
|
|
219
|
+
fontStr += "@font-face { font-family:'" + fontFamilyName + "'; src:";
|
|
220
|
+
fontStr += "url(data:application/octet-stream;";
|
|
221
|
+
fontStr += "base64," + base64Font + ");}";
|
|
222
|
+
return fontStr;
|
|
223
|
+
};
|
|
224
|
+
window.getFontFamily = function (fontHandle) {
|
|
225
|
+
var ttfIndex = fontHandle.lastIndexOf(".ttf");
|
|
226
|
+
if (-1 === ttfIndex) return fontHandle;
|
|
227
|
+
var slashPos = fontHandle.lastIndexOf("/");
|
|
228
|
+
var fontFamilyName;
|
|
229
|
+
fontFamilyName =
|
|
230
|
+
-1 === slashPos
|
|
231
|
+
? fontHandle.substring(0, ttfIndex) + "_LABEL"
|
|
232
|
+
: fontHandle.substring(slashPos + 1, ttfIndex) + "_LABEL";
|
|
233
|
+
-1 !== fontFamilyName.indexOf(" ") &&
|
|
234
|
+
(fontFamilyName = '"' + fontFamilyName + '"');
|
|
235
|
+
return fontFamilyName;
|
|
236
|
+
};
|
|
237
|
+
var xmlHttp = (window.CustomXMLHttpRequest = function () { });
|
|
238
|
+
xmlHttp.prototype.send = function () { };
|
|
239
|
+
xmlHttp.prototype.open = function (method, url) {
|
|
240
|
+
const self = this;
|
|
241
|
+
this.status = 200;
|
|
242
|
+
this.url = url;
|
|
243
|
+
this.isloaded = true;
|
|
244
|
+
|
|
245
|
+
const jsonExtension = url.match(/\.(json)(\?[a-z0-9=&.]+)?$/);
|
|
246
|
+
const imageExtension = url.match(
|
|
247
|
+
/\.(jpe?g|png|svg|bmp|gif)(\?[a-z0-9=&.]+)?$/
|
|
248
|
+
);
|
|
249
|
+
const audioExtension = url.match(/\.(wav|mp3|ogg)(\?[a-z0-9=&.]+)?$/);
|
|
250
|
+
const binaryExtension = url.match(/\.(bin)(\?[a-z0-9=&.]+)?$/);
|
|
251
|
+
const fontExtension = url.match(/\.(ttf)(\?[a-z0-9=&.]+)?$/);
|
|
252
|
+
|
|
253
|
+
if (jsonExtension) {
|
|
254
|
+
this.response = atob(window.bundleAsset[url]);
|
|
255
|
+
} else if (imageExtension) {
|
|
256
|
+
this.isloaded = false;
|
|
257
|
+
fetch(window.bundleAsset[url])
|
|
258
|
+
.then((res) => res.blob())
|
|
259
|
+
.then((res) => {
|
|
260
|
+
self.response = res;
|
|
261
|
+
self.onload && self.onload();
|
|
262
|
+
});
|
|
263
|
+
} else if (fontExtension) {
|
|
264
|
+
//do nothing
|
|
265
|
+
} else if (binaryExtension) {
|
|
266
|
+
this.response = Uint8Array.from(atob(window.bundleAsset[url]), (c) =>
|
|
267
|
+
c.charCodeAt(0)
|
|
268
|
+
).buffer;
|
|
269
|
+
} else if (audioExtension) {
|
|
270
|
+
this.response = Uint8Array.from(atob(window.bundleAsset[url]), (c) =>
|
|
271
|
+
c.charCodeAt(0)
|
|
272
|
+
).buffer;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
xmlHttp.prototype.setRequestHeader = function () { };
|
|
276
|
+
xmlHttp.prototype.send = function () {
|
|
277
|
+
this.isloaded && this.onload && this.onload();
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
async function addScriptToHTML(htmlFileContent, scriptPath, htmlTag = "head") {
|
|
281
|
+
const scriptContent = await fs.promises.readFile(scriptPath, "utf8");
|
|
282
|
+
return addScriptContentToHTML(htmlFileContent, scriptContent, htmlTag);
|
|
283
|
+
}
|
|
284
|
+
async function addScriptContentToHTML(
|
|
285
|
+
htmlFileContent,
|
|
286
|
+
scriptContent,
|
|
287
|
+
htmlTag = "head",
|
|
288
|
+
scriptTag = "script"
|
|
289
|
+
) {
|
|
290
|
+
console.log(
|
|
291
|
+
`Add ${scriptTag} to HTML <${htmlTag}>: ` + scriptContent.substr(0, 50)
|
|
292
|
+
);
|
|
293
|
+
const lastIndex = htmlFileContent.lastIndexOf(`</${htmlTag}>`);
|
|
294
|
+
return `${htmlFileContent.substr(
|
|
295
|
+
0,
|
|
296
|
+
lastIndex
|
|
297
|
+
)}<${scriptTag}>${scriptContent}</${scriptTag}>${htmlFileContent.substr(
|
|
298
|
+
lastIndex
|
|
299
|
+
)}`;
|
|
300
|
+
}
|
|
301
|
+
async function bundleAssetToScript() {
|
|
302
|
+
const listAssets = await getAllAssetFiles();
|
|
303
|
+
let bundleAssetScript = "window.bundleAsset={";
|
|
304
|
+
|
|
305
|
+
console.log("\n--- 🖼️ DANH SÁCH ASSET ẢNH ĐƯỢC XỬ LÝ ---");
|
|
306
|
+
let totalImageSize = 0;
|
|
307
|
+
let imageCount = 0;
|
|
308
|
+
|
|
309
|
+
for (const assetPath of listAssets) {
|
|
310
|
+
const assetLocalPath = assetPath.replace(
|
|
311
|
+
buildPathCocos.replace("./", ""),
|
|
312
|
+
""
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
if (ASSET_OVERRIDES[assetLocalPath]) {
|
|
316
|
+
console.log(`[Override] Đã thay thế ảnh: ${assetLocalPath}`);
|
|
317
|
+
bundleAssetScript += `'${assetLocalPath}':'${ASSET_OVERRIDES[assetLocalPath]}',`;
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const stats = fs.statSync(assetPath);
|
|
322
|
+
const fileSizeInBytes = stats.size;
|
|
323
|
+
|
|
324
|
+
const imageExtension = assetPath.match(
|
|
325
|
+
/\.(jpe?g|png|svg|bmp|gif)(\?[a-z0-9=&.]+)?$/
|
|
326
|
+
);
|
|
327
|
+
const scriptExtension = assetPath.match(/\.(js)(\?[a-z0-9=&.]+)?$/);
|
|
328
|
+
const jsonExtension = assetPath.match(/\.(json)(\?[a-z0-9=&.]+)?$/);
|
|
329
|
+
const audioExtension = assetPath.match(/\.(wav|mp3|ogg)(\?[a-z0-9=&.]+)?$/);
|
|
330
|
+
const binaryExtension = assetPath.match(/\.(bin)(\?[a-z0-9=&.]+)?$/);
|
|
331
|
+
const fontExtension = assetPath.match(/\.(ttf)(\?[a-z0-9=&.]+)?$/);
|
|
332
|
+
|
|
333
|
+
if (imageExtension) {
|
|
334
|
+
imageCount++;
|
|
335
|
+
totalImageSize += fileSizeInBytes;
|
|
336
|
+
|
|
337
|
+
const formattedSize = await formatBytes(fileSizeInBytes);
|
|
338
|
+
console.log(
|
|
339
|
+
`[Image ${imageCount}] ${assetLocalPath.padEnd(
|
|
340
|
+
60
|
|
341
|
+
)} | Size: ${formattedSize}`
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
let imageExt = imageExtension[1];
|
|
345
|
+
if (imageExt === "jpg") imageExt = "jpeg";
|
|
346
|
+
|
|
347
|
+
const base64Data = await fs.promises.readFile(assetPath, "base64");
|
|
348
|
+
bundleAssetScript += `'${assetLocalPath}':'data:image/${imageExt};base64,${base64Data}',`;
|
|
349
|
+
} else if (
|
|
350
|
+
audioExtension ||
|
|
351
|
+
binaryExtension ||
|
|
352
|
+
fontExtension ||
|
|
353
|
+
jsonExtension
|
|
354
|
+
) {
|
|
355
|
+
const base64Data = await fs.promises.readFile(assetPath, "base64");
|
|
356
|
+
bundleAssetScript += `'${assetLocalPath}':'${base64Data}',`;
|
|
357
|
+
} else if (scriptExtension) {
|
|
358
|
+
const content = await fs.promises.readFile(assetPath, "utf8");
|
|
359
|
+
bundleAssetScript = `${content};${bundleAssetScript}`;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
bundleAssetScript += "};";
|
|
364
|
+
console.log("---------------------------------------------------------\n");
|
|
365
|
+
|
|
366
|
+
return bundleAssetScript;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
async function getAllAssetFiles() {
|
|
370
|
+
let listFiles = [];
|
|
371
|
+
|
|
372
|
+
const getAllFilesInFolderRecursive = (folderPath) => {
|
|
373
|
+
fs.readdirSync(folderPath).forEach((filePath) => {
|
|
374
|
+
const fileAbsolutePath = path
|
|
375
|
+
.join(folderPath, filePath)
|
|
376
|
+
.replace(/\\/g, "/");
|
|
377
|
+
if (fs.statSync(fileAbsolutePath).isDirectory())
|
|
378
|
+
getAllFilesInFolderRecursive(fileAbsolutePath);
|
|
379
|
+
else listFiles.push(fileAbsolutePath);
|
|
380
|
+
});
|
|
381
|
+
};
|
|
382
|
+
getAllFilesInFolderRecursive(buildPathCocos + "assets");
|
|
383
|
+
|
|
384
|
+
return listFiles;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async function formatBytes(bytes, decimals = 2) {
|
|
388
|
+
if (bytes === 0) return "0 Bytes";
|
|
389
|
+
|
|
390
|
+
const k = 1024;
|
|
391
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
392
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
393
|
+
|
|
394
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
395
|
+
|
|
396
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
397
|
+
}
|
package/2x/fireworks.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* name: fireworks-js
|
|
3
|
+
* version: 2.10.8
|
|
4
|
+
* author: Vitalij Ryndin (https://crashmax.ru)
|
|
5
|
+
* homepage: https://fireworks.js.org
|
|
6
|
+
* license MIT
|
|
7
|
+
*/
|
|
8
|
+
(function(c,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(c=typeof globalThis<"u"?globalThis:c||self,u(c.Fireworks={}))})(this,function(c){"use strict";function u(e){return Math.abs(Math.floor(e))}function p(e,t){return Math.random()*(t-e)+e}function o(e,t){return Math.floor(p(e,t+1))}function g(e,t,i,s){const n=Math.pow;return Math.sqrt(n(e-i,2)+n(t-s,2))}function f(e,t,i=1){if(e>360||e<0)throw new Error(`Expected hue 0-360 range, got \`${e}\``);if(t>100||t<0)throw new Error(`Expected lightness 0-100 range, got \`${t}\``);if(i>1||i<0)throw new Error(`Expected alpha 0-1 range, got \`${i}\``);return`hsla(${e}, 100%, ${t}%, ${i})`}const v=e=>{if(typeof e=="object"&&e!==null){if(typeof Object.getPrototypeOf=="function"){const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}return Object.prototype.toString.call(e)==="[object Object]"}return!1},b=["__proto__","constructor","prototype"],w=(...e)=>e.reduce((t,i)=>(Object.keys(i).forEach(s=>{b.includes(s)||(Array.isArray(t[s])&&Array.isArray(i[s])?t[s]=i[s]:v(t[s])&&v(i[s])?t[s]=w(t[s],i[s]):t[s]=i[s])}),t),{});function S(e,t){let i;return(...s)=>{i&&clearTimeout(i),i=setTimeout(()=>e(...s),t)}}class O{x;y;ctx;hue;friction;gravity;flickering;lineWidth;explosionLength;angle;speed;brightness;coordinates=[];decay;alpha=1;constructor({x:t,y:i,ctx:s,hue:n,decay:h,gravity:a,friction:r,brightness:l,flickering:d,lineWidth:x,explosionLength:m}){for(this.x=t,this.y=i,this.ctx=s,this.hue=n,this.gravity=a,this.friction=r,this.flickering=d,this.lineWidth=x,this.explosionLength=m,this.angle=p(0,Math.PI*2),this.speed=o(1,10),this.brightness=o(l.min,l.max),this.decay=p(h.min,h.max);this.explosionLength--;)this.coordinates.push([t,i])}update(t){this.coordinates.pop(),this.coordinates.unshift([this.x,this.y]),this.speed*=this.friction,this.x+=Math.cos(this.angle)*this.speed,this.y+=Math.sin(this.angle)*this.speed+this.gravity,this.alpha-=this.decay,this.alpha<=this.decay&&t()}draw(){const t=this.coordinates.length-1;this.ctx.beginPath(),this.ctx.lineWidth=this.lineWidth,this.ctx.fillStyle=f(this.hue,this.brightness,this.alpha),this.ctx.moveTo(this.coordinates[t][0],this.coordinates[t][1]),this.ctx.lineTo(this.x,this.y),this.ctx.strokeStyle=f(this.hue,this.flickering?p(0,this.brightness):this.brightness,this.alpha),this.ctx.stroke()}}class E{constructor(t,i){this.options=t,this.canvas=i,this.pointerDown=this.pointerDown.bind(this),this.pointerUp=this.pointerUp.bind(this),this.pointerMove=this.pointerMove.bind(this)}active=!1;x;y;get mouseOptions(){return this.options.mouse}mount(){this.canvas.addEventListener("pointerdown",this.pointerDown),this.canvas.addEventListener("pointerup",this.pointerUp),this.canvas.addEventListener("pointermove",this.pointerMove)}unmount(){this.canvas.removeEventListener("pointerdown",this.pointerDown),this.canvas.removeEventListener("pointerup",this.pointerUp),this.canvas.removeEventListener("pointermove",this.pointerMove)}usePointer(t,i){const{click:s,move:n}=this.mouseOptions;(s||n)&&(this.x=t.pageX-this.canvas.offsetLeft,this.y=t.pageY-this.canvas.offsetTop,this.active=i)}pointerDown(t){this.usePointer(t,this.mouseOptions.click)}pointerUp(t){this.usePointer(t,!1)}pointerMove(t){this.usePointer(t,this.active)}}class M{hue;rocketsPoint;opacity;acceleration;friction;gravity;particles;explosion;mouse;boundaries;sound;delay;brightness;decay;flickering;intensity;traceLength;traceSpeed;lineWidth;lineStyle;autoresize;constructor(){this.autoresize=!0,this.lineStyle="round",this.flickering=50,this.traceLength=3,this.traceSpeed=10,this.intensity=30,this.explosion=5,this.gravity=1.5,this.opacity=.5,this.particles=50,this.friction=.95,this.acceleration=1.05,this.hue={min:0,max:360},this.rocketsPoint={min:50,max:50},this.lineWidth={explosion:{min:1,max:3},trace:{min:1,max:2}},this.mouse={click:!1,move:!1,max:1},this.delay={min:30,max:60},this.brightness={min:50,max:80},this.decay={min:.015,max:.03},this.sound={enabled:!1,files:["explosion0.mp3","explosion1.mp3","explosion2.mp3"],volume:{min:4,max:8}},this.boundaries={debug:!1,height:0,width:0,x:50,y:50}}update(t){Object.assign(this,w(this,t))}}class z{constructor(t,i){this.options=t,this.render=i}tick=0;rafId=0;fps=60;tolerance=.1;now;mount(){this.now=performance.now();const t=1e3/this.fps,i=s=>{this.rafId=requestAnimationFrame(i);const n=s-this.now;n>=t-this.tolerance&&(this.render(),this.now=s-n%t,this.tick+=n*(this.options.intensity*Math.PI)/1e3)};this.rafId=requestAnimationFrame(i)}unmount(){cancelAnimationFrame(this.rafId)}}class L{constructor(t,i,s){this.options=t,this.updateSize=i,this.container=s}resizer;mount(){if(!this.resizer){const t=S(()=>this.updateSize(),100);this.resizer=new ResizeObserver(t)}this.options.autoresize&&this.resizer.observe(this.container)}unmount(){this.resizer&&this.resizer.unobserve(this.container)}}class T{constructor(t){this.options=t,this.init()}buffers=[];audioContext;onInit=!1;get isEnabled(){return this.options.sound.enabled}get soundOptions(){return this.options.sound}init(){!this.onInit&&this.isEnabled&&(this.onInit=!0,this.audioContext=new(window.AudioContext||window.webkitAudioContext),this.loadSounds())}async loadSounds(){for(const t of this.soundOptions.files){const i=await(await fetch(t)).arrayBuffer();this.audioContext.decodeAudioData(i).then(s=>{this.buffers.push(s)}).catch(s=>{throw s})}}play(){if(this.isEnabled&&this.buffers.length){const t=this.audioContext.createBufferSource(),i=this.buffers[o(0,this.buffers.length-1)],s=this.audioContext.createGain();t.buffer=i,s.gain.value=p(this.soundOptions.volume.min/100,this.soundOptions.volume.max/100),s.connect(this.audioContext.destination),t.connect(s),t.start(0)}else this.init()}}class C{x;y;sx;sy;dx;dy;ctx;hue;speed;acceleration;traceLength;totalDistance;angle;brightness;coordinates=[];currentDistance=0;constructor({x:t,y:i,dx:s,dy:n,ctx:h,hue:a,speed:r,traceLength:l,acceleration:d}){for(this.x=t,this.y=i,this.sx=t,this.sy=i,this.dx=s,this.dy=n,this.ctx=h,this.hue=a,this.speed=r,this.traceLength=l,this.acceleration=d,this.totalDistance=g(t,i,s,n),this.angle=Math.atan2(n-i,s-t),this.brightness=o(50,70);this.traceLength--;)this.coordinates.push([t,i])}update(t){this.coordinates.pop(),this.coordinates.unshift([this.x,this.y]),this.speed*=this.acceleration;const i=Math.cos(this.angle)*this.speed,s=Math.sin(this.angle)*this.speed;this.currentDistance=g(this.sx,this.sy,this.x+i,this.y+s),this.currentDistance>=this.totalDistance?t(this.dx,this.dy,this.hue):(this.x+=i,this.y+=s)}draw(){const t=this.coordinates.length-1;this.ctx.beginPath(),this.ctx.moveTo(this.coordinates[t][0],this.coordinates[t][1]),this.ctx.lineTo(this.x,this.y),this.ctx.strokeStyle=f(this.hue,this.brightness),this.ctx.stroke()}}class y{target;container;canvas;ctx;width;height;traces=[];explosions=[];waitStopRaf;running=!1;opts;sound;resize;mouse;raf;constructor(t,i={}){this.target=t,this.container=t,this.opts=new M,this.createCanvas(this.target),this.updateOptions(i),this.sound=new T(this.opts),this.resize=new L(this.opts,this.updateSize.bind(this),this.container),this.mouse=new E(this.opts,this.canvas),this.raf=new z(this.opts,this.render.bind(this))}get isRunning(){return this.running}get version(){return"2.10.8"}get currentOptions(){return this.opts}start(){this.running||(this.canvas.isConnected||this.createCanvas(this.target),this.running=!0,this.resize.mount(),this.mouse.mount(),this.raf.mount())}stop(t=!1){this.running&&(this.running=!1,this.resize.unmount(),this.mouse.unmount(),this.raf.unmount(),this.clear(),t&&this.canvas.remove())}async waitStop(t){if(this.running)return new Promise(i=>{this.waitStopRaf=()=>{this.waitStopRaf&&(requestAnimationFrame(this.waitStopRaf),!this.traces.length&&!this.explosions.length&&(this.waitStopRaf=null,this.stop(t),i()))},this.waitStopRaf()})}pause(){this.running=!this.running,this.running?this.raf.mount():this.raf.unmount()}clear(){this.ctx&&(this.traces=[],this.explosions=[],this.ctx.clearRect(0,0,this.width,this.height))}launch(t=1){for(let i=0;i<t;i++)this.createTrace();this.waitStopRaf||(this.start(),this.waitStop())}updateOptions(t){this.opts.update(t)}updateSize({width:t=this.container.clientWidth,height:i=this.container.clientHeight}={}){this.width=t,this.height=i,this.canvas.width=t,this.canvas.height=i,this.updateBoundaries({...this.opts.boundaries,width:t,height:i})}updateBoundaries(t){this.updateOptions({boundaries:t})}createCanvas(t){t instanceof HTMLCanvasElement?(t.isConnected||document.body.append(t),this.canvas=t):(this.canvas=document.createElement("canvas"),this.container.append(this.canvas)),this.ctx=this.canvas.getContext("2d"),this.updateSize()}render(){if(!this.ctx||!this.running)return;const{opacity:t,lineStyle:i,lineWidth:s}=this.opts;this.ctx.globalCompositeOperation="destination-out",this.ctx.fillStyle=`rgba(0, 0, 0, ${t})`,this.ctx.fillRect(0,0,this.width,this.height),this.ctx.globalCompositeOperation="lighter",this.ctx.lineCap=i,this.ctx.lineJoin="round",this.ctx.lineWidth=p(s.trace.min,s.trace.max),this.initTrace(),this.drawTrace(),this.drawExplosion()}createTrace(){const{hue:t,rocketsPoint:i,boundaries:s,traceLength:n,traceSpeed:h,acceleration:a,mouse:r}=this.opts;this.traces.push(new C({x:this.width*o(i.min,i.max)/100,y:this.height,dx:this.mouse.x&&r.move||this.mouse.active?this.mouse.x:o(s.x,s.width-s.x*2),dy:this.mouse.y&&r.move||this.mouse.active?this.mouse.y:o(s.y,s.height*.5),ctx:this.ctx,hue:o(t.min,t.max),speed:h,acceleration:a,traceLength:u(n)}))}initTrace(){if(this.waitStopRaf)return;const{delay:t,mouse:i}=this.opts;(this.raf.tick>o(t.min,t.max)||this.mouse.active&&i.max>this.traces.length)&&(this.createTrace(),this.raf.tick=0)}drawTrace(){let t=this.traces.length;for(;t--;)this.traces[t].draw(),this.traces[t].update((i,s,n)=>{this.initExplosion(i,s,n),this.sound.play(),this.traces.splice(t,1)})}initExplosion(t,i,s){const{particles:n,flickering:h,lineWidth:a,explosion:r,brightness:l,friction:d,gravity:x,decay:m}=this.opts;let P=u(n);for(;P--;)this.explosions.push(new O({x:t,y:i,ctx:this.ctx,hue:s,friction:d,gravity:x,flickering:o(0,100)<=h,lineWidth:p(a.explosion.min,a.explosion.max),explosionLength:u(r),brightness:l,decay:m}))}drawExplosion(){let t=this.explosions.length;for(;t--;)this.explosions[t].draw(),this.explosions[t].update(()=>{this.explosions.splice(t,1)})}}c.Fireworks=y,c.default=y,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "ahihi",
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
|
-
"name": "
|
|
8
|
+
"name": "ahihi",
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
|
|
6
|
-
<title>Cocos Creator | <%= projectName %></title>
|
|
7
|
-
|
|
8
|
-
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
|
|
9
|
-
<meta name="viewport"
|
|
10
|
-
content="width=device-width,user-scalable=no,initial-scale=1,minimum-scale=1,maximum-scale=1,minimal-ui=true"/>
|
|
11
|
-
|
|
12
|
-
<!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
|
|
13
|
-
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
14
|
-
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
15
|
-
<meta name="format-detection" content="telephone=no">
|
|
16
|
-
|
|
17
|
-
<!-- force webkit on 360 -->
|
|
18
|
-
<meta name="renderer" content="webkit"/>
|
|
19
|
-
<meta name="force-rendering" content="webkit"/>
|
|
20
|
-
<!-- force edge on IE -->
|
|
21
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
|
22
|
-
<meta name="msapplication-tap-highlight" content="no">
|
|
23
|
-
|
|
24
|
-
<!-- force full screen on some browser -->
|
|
25
|
-
<meta name="full-screen" content="yes"/>
|
|
26
|
-
<meta name="x5-fullscreen" content="true"/>
|
|
27
|
-
<meta name="360-fullscreen" content="true"/>
|
|
28
|
-
|
|
29
|
-
<!--fix fireball/issues/3568 -->
|
|
30
|
-
<!--<meta name="browsermode" content="application">-->
|
|
31
|
-
<meta name="x5-page-mode" content="app">
|
|
32
|
-
|
|
33
|
-
<!--<link rel="apple-touch-icon" href=".png" />-->
|
|
34
|
-
<!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
|
|
35
|
-
|
|
36
|
-
<link rel="stylesheet" type="text/css" href="<%= cssUrl %>"/>
|
|
37
|
-
|
|
38
|
-
</head>
|
|
39
|
-
<body>
|
|
40
|
-
<div id="GameDiv">
|
|
41
|
-
<div id="Cocos3dGameContainer">
|
|
42
|
-
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
<%- include(cocosTemplate, {}) %>
|
|
46
|
-
</body>
|
|
47
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
|
|
6
|
+
<title>Cocos Creator | <%= projectName %></title>
|
|
7
|
+
|
|
8
|
+
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
|
|
9
|
+
<meta name="viewport"
|
|
10
|
+
content="width=device-width,user-scalable=no,initial-scale=1,minimum-scale=1,maximum-scale=1,minimal-ui=true"/>
|
|
11
|
+
|
|
12
|
+
<!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
|
|
13
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
14
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
15
|
+
<meta name="format-detection" content="telephone=no">
|
|
16
|
+
|
|
17
|
+
<!-- force webkit on 360 -->
|
|
18
|
+
<meta name="renderer" content="webkit"/>
|
|
19
|
+
<meta name="force-rendering" content="webkit"/>
|
|
20
|
+
<!-- force edge on IE -->
|
|
21
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
|
22
|
+
<meta name="msapplication-tap-highlight" content="no">
|
|
23
|
+
|
|
24
|
+
<!-- force full screen on some browser -->
|
|
25
|
+
<meta name="full-screen" content="yes"/>
|
|
26
|
+
<meta name="x5-fullscreen" content="true"/>
|
|
27
|
+
<meta name="360-fullscreen" content="true"/>
|
|
28
|
+
|
|
29
|
+
<!--fix fireball/issues/3568 -->
|
|
30
|
+
<!--<meta name="browsermode" content="application">-->
|
|
31
|
+
<meta name="x5-page-mode" content="app">
|
|
32
|
+
|
|
33
|
+
<!--<link rel="apple-touch-icon" href=".png" />-->
|
|
34
|
+
<!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
|
|
35
|
+
|
|
36
|
+
<link rel="stylesheet" type="text/css" href="<%= cssUrl %>"/>
|
|
37
|
+
|
|
38
|
+
</head>
|
|
39
|
+
<body>
|
|
40
|
+
<div id="GameDiv">
|
|
41
|
+
<div id="Cocos3dGameContainer">
|
|
42
|
+
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<%- include(cocosTemplate, {}) %>
|
|
46
|
+
</body>
|
|
47
|
+
</html>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
# 项目简介
|
|
2
|
-
|
|
3
|
-
一份空白的扩展。
|
|
4
|
-
|
|
5
|
-
## 开发环境
|
|
6
|
-
|
|
7
|
-
Node.js
|
|
8
|
-
|
|
9
|
-
## 安装
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
# 安装依赖模块
|
|
13
|
-
npm install
|
|
14
|
-
# 构建
|
|
15
|
-
npm run build
|
|
16
|
-
```
|
|
1
|
+
# 项目简介
|
|
2
|
+
|
|
3
|
+
一份空白的扩展。
|
|
4
|
+
|
|
5
|
+
## 开发环境
|
|
6
|
+
|
|
7
|
+
Node.js
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# 安装依赖模块
|
|
13
|
+
npm install
|
|
14
|
+
# 构建
|
|
15
|
+
npm run build
|
|
16
|
+
```
|