hiepdh-playable-toolkit 2.0.0 → 2.0.4

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/package.json CHANGED
@@ -1,11 +1,23 @@
1
1
  {
2
2
  "name": "hiepdh-playable-toolkit",
3
- "version": "2.0.0",
3
+ "version": "2.0.4",
4
4
  "main": "setup.js",
5
5
  "dependencies": {
6
6
  "fs-extra": "^11.1.0",
7
7
  "adm-zip": "^0.5.10"
8
8
  },
9
+ "scripts": {
10
+ "postinstall": "node setup.js"
11
+ },
12
+ "bin": {
13
+ "hiepdh-setup": "setup.js"
14
+ },
15
+ "files": [
16
+ "2x",
17
+ "3x",
18
+ "setup.js",
19
+ "README.md"
20
+ ],
9
21
  "keywords": [],
10
22
  "author": "HiepDH",
11
23
  "license": "ISC",
package/setup.js CHANGED
@@ -1,11 +1,15 @@
1
- const fs = require('fs');
1
+ const fs = require('fs-extra');
2
2
  const path = require('path');
3
3
  const { execSync } = require('child_process');
4
4
 
5
5
  // Xác định thư mục gốc của dự án người dùng
6
- const projectRoot = process.env.INIT_CWD || path.resolve(__dirname, "../../");
6
+ const projectRoot = process.env.INIT_CWD || process.cwd();
7
+ const toolkitRoot = __dirname;
7
8
  const pkgPath = path.join(projectRoot, "package.json");
8
9
 
10
+ console.log("--- Đang cài đặt từ: " + toolkitRoot);
11
+ console.log("--- Đích đến: " + projectRoot);
12
+
9
13
  console.log("--- HiepDH Playable Toolkit: Khởi tạo cấu hình đa phiên bản ---");
10
14
 
11
15
  if (!fs.existsSync(pkgPath)) {
package/ironSource_api.js DELETED
@@ -1,86 +0,0 @@
1
- function userClickedDownloadButton(url) {
2
- if (typeof mraid !== "undefined") {
3
- mraid.open(url);
4
- } else {
5
- console.log("Open Store clicked (No MRAID environment)", url);
6
- if(url) window.open(url, "_blank");
7
- }
8
- }
9
-
10
- (function () {
11
- var mraid = window.mraid;
12
- var isMraidLoaded = typeof mraid !== "undefined";
13
-
14
- function handleAudioLogic() {
15
- if (!isMraidLoaded) return;
16
-
17
- var isViewable = mraid.isViewable();
18
- var currentVolume = 100;
19
-
20
- try {
21
- if (typeof mraid.getAudioVolume === "function") {
22
- currentVolume = mraid.getAudioVolume();
23
- }
24
- } catch (e) {
25
- console.log("MRAID getAudioVolume not supported");
26
- }
27
-
28
- var shouldMute = !isViewable || (currentVolume === 0);
29
-
30
- if (shouldMute) {
31
- console.log("MRAID: Audio OFF (Viewable: " + isViewable + ", Volume: " + currentVolume + ")");
32
- if (typeof window.gamePause === 'function') window.gamePause();
33
- localStorage.setItem("cocosSoundState", 2); // Tắt tiếng
34
- } else {
35
- console.log("MRAID: Audio ON (Viewable: " + isViewable + ", Volume: " + currentVolume + ")");
36
- if (typeof window.gameResume === 'function') window.gameResume();
37
- localStorage.setItem("cocosSoundState", 1); // Bật tiếng
38
- }
39
- }
40
-
41
- function onReady() {
42
- console.log("MRAID is Ready");
43
-
44
- mraid.addEventListener("viewableChange", function (viewable) {
45
- console.log("MRAID Event: viewableChange -> " + viewable);
46
- handleAudioLogic();
47
- });
48
-
49
- if (mraid.supports && mraid.supports("audioVolumeChange")) {
50
- mraid.addEventListener("audioVolumeChange", function (volume) {
51
- console.log("MRAID Event: audioVolumeChange -> " + volume);
52
- handleAudioLogic();
53
- });
54
- }
55
-
56
- handleAudioLogic();
57
-
58
- if (mraid.isViewable()) {
59
- startGame();
60
- }
61
- }
62
-
63
- function startGame() {
64
- if (typeof window.onReadyCallback === "function") {
65
- window.onReadyCallback();
66
- } else {
67
- var checkGameLoad = setInterval(function() {
68
- if (typeof window.onReadyCallback === "function") {
69
- window.onReadyCallback();
70
- clearInterval(checkGameLoad);
71
- }
72
- }, 100);
73
- }
74
- }
75
-
76
- if (isMraidLoaded) {
77
- if (mraid.getState() === "loading") {
78
- mraid.addEventListener("ready", onReady);
79
- } else {
80
- onReady();
81
- }
82
- } else {
83
- console.log("MRAID not found, auto starting game for testing...");
84
- setTimeout(startGame, 500);
85
- }
86
- })();