@playcraft/adsdk 1.0.18-beta.3 → 1.0.19
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/LICENSE +21 -21
- package/defines.d.ts +130 -130
- package/dist/esm/index.js +46 -113
- package/dist/iife/index.js +46 -112
- package/dist/index.d.mts +2 -19
- package/dist/index.d.ts +2 -19
- package/dist/index.js +46 -114
- package/package.json +56 -56
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025-present Smoud
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Smoud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/defines.d.ts
CHANGED
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
declare const mraid: {
|
|
2
|
-
getVersion: () => string; // MRAID 规范必需:返回 MRAID 版本(如 "3.0")
|
|
3
|
-
isReady: () => boolean;
|
|
4
|
-
isViewable: () => boolean;
|
|
5
|
-
getState: () => string;
|
|
6
|
-
addEventListener: (
|
|
7
|
-
event: 'viewableChange' | 'sizeChange' | 'ready' | 'audioVolumeChange' | 'stateChange' | 'error' | 'orientationChange' | 'resize',
|
|
8
|
-
callback: (...args: any[]) => void
|
|
9
|
-
) => void;
|
|
10
|
-
removeEventListener: (
|
|
11
|
-
event: 'viewableChange' | 'sizeChange' | 'ready' | 'audioVolumeChange' | 'stateChange' | 'error' | 'orientationChange' | 'resize',
|
|
12
|
-
callback: (...args: any[]) => void
|
|
13
|
-
) => void;
|
|
14
|
-
getMaxSize: () => { width: number; height: number };
|
|
15
|
-
openStoreUrl: () => void;
|
|
16
|
-
open: (url: string) => void;
|
|
17
|
-
close: () => void; // Unity Ads 必需:关闭广告
|
|
18
|
-
getAudioVolume: () => number;
|
|
19
|
-
fireTrackingEvent?: (event: string) => void; // Unity Ads 可选:跟踪事件
|
|
20
|
-
preloadStore?: () => void;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
declare const dapi: {
|
|
24
|
-
addEventListener: (
|
|
25
|
-
event: 'viewableChange' | 'adResized' | 'ready' | 'audioVolumeChange' | 'error',
|
|
26
|
-
callback: (...args: any[]) => void
|
|
27
|
-
) => void;
|
|
28
|
-
removeEventListener: (
|
|
29
|
-
event: 'viewableChange' | 'adResized' | 'ready' | 'audioVolumeChange' | 'error',
|
|
30
|
-
callback: (...args: any[]) => void
|
|
31
|
-
) => void;
|
|
32
|
-
getScreenSize: () => { width: number; height: number };
|
|
33
|
-
openStoreUrl: () => void;
|
|
34
|
-
getAudioVolume: () => number;
|
|
35
|
-
isViewable: () => boolean;
|
|
36
|
-
isReady: () => boolean;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
declare const NUC: {
|
|
40
|
-
trigger: {
|
|
41
|
-
convert: (destinationUrl: string) => void;
|
|
42
|
-
tryAgain: Function;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
declare const ScPlayableAd: { onCTAClick: () => void };
|
|
47
|
-
|
|
48
|
-
// Adikteev 占位符变量
|
|
49
|
-
declare const AK_CLICK_DESTINATION_URL: string;
|
|
50
|
-
declare const AK_CLICK_PIXEL_URL: string;
|
|
51
|
-
declare const FbPlayableAd: { onCTAClick: () => void };
|
|
52
|
-
declare const smxTracking: { redirect: () => void };
|
|
53
|
-
declare const ExitApi: { exit: () => void };
|
|
54
|
-
|
|
55
|
-
declare const AD_NETWORK:
|
|
56
|
-
| 'preview'
|
|
57
|
-
| 'applovin'
|
|
58
|
-
| 'unity'
|
|
59
|
-
| 'google'
|
|
60
|
-
| 'ironsource'
|
|
61
|
-
| 'facebook'
|
|
62
|
-
| 'moloco'
|
|
63
|
-
| 'mintegral'
|
|
64
|
-
| 'vungle'
|
|
65
|
-
| 'adcolony'
|
|
66
|
-
| 'tapjoy'
|
|
67
|
-
| 'snapchat'
|
|
68
|
-
| 'tiktok'
|
|
69
|
-
| 'appreciate'
|
|
70
|
-
| 'chartboost'
|
|
71
|
-
| 'pangle'
|
|
72
|
-
| 'mytarget'
|
|
73
|
-
| 'liftoff'
|
|
74
|
-
| 'smadex'
|
|
75
|
-
| 'adikteev'
|
|
76
|
-
| 'bigabid'
|
|
77
|
-
| 'inmobi'
|
|
78
|
-
| 'bigoads';
|
|
79
|
-
|
|
80
|
-
declare const AD_PROTOCOL: 'mraid' | 'dapi' | 'nucleo' | 'none';
|
|
81
|
-
declare const GOOGLE_PLAY_URL: string;
|
|
82
|
-
declare const APP_STORE_URL: string;
|
|
83
|
-
declare const BUILD_HASH: string;
|
|
84
|
-
|
|
85
|
-
interface Window {
|
|
86
|
-
PlayableSDK: any;
|
|
87
|
-
ADS_MRAID_CONFIG: {
|
|
88
|
-
landUrl: string;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// AppLovin Playable Analytics
|
|
92
|
-
// 文档: https://support.axon.ai/en/growth/promoting-your-apps/creatives/playable-analytics-integration
|
|
93
|
-
ALPlayableAnalytics?: {
|
|
94
|
-
trackEvent: (event: string) => void;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// BigoAds SDK
|
|
98
|
-
// 文档: https://www.bigoads.com/help/detail?id=143&moduleId=7¤tLan=CN
|
|
99
|
-
BGY_MRAID: {
|
|
100
|
-
open: () => void; // 打开应用商店/推广地址
|
|
101
|
-
gameReady: () => void; // 素材准备完毕时调用
|
|
102
|
-
gameEnd: () => void; // 游戏结束时调用
|
|
103
|
-
isViewable: () => boolean;
|
|
104
|
-
addEventListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
105
|
-
removeEventListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Mintegral functions
|
|
109
|
-
gameReady: Function;
|
|
110
|
-
gameEnd: Function;
|
|
111
|
-
gameRetry: Function;
|
|
112
|
-
install: Function;
|
|
113
|
-
mintGameStart: Function;
|
|
114
|
-
mintGameClose: Function;
|
|
115
|
-
|
|
116
|
-
// Tapjoy functions
|
|
117
|
-
TJ_API: {
|
|
118
|
-
objectiveComplete: Function;
|
|
119
|
-
playableFinished: Function;
|
|
120
|
-
gameplayFinished: Function;
|
|
121
|
-
setPlayableBuild: Function;
|
|
122
|
-
setPlayableAPI: Function;
|
|
123
|
-
click: Function;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
BIGABID_BIDTIMEMACROS?: Record<string, string>
|
|
127
|
-
INMOBI_DSPMACROS?: Record<string, string>
|
|
128
|
-
|
|
129
|
-
openAppStore: Function;
|
|
130
|
-
}
|
|
1
|
+
declare const mraid: {
|
|
2
|
+
getVersion: () => string; // MRAID 规范必需:返回 MRAID 版本(如 "3.0")
|
|
3
|
+
isReady: () => boolean;
|
|
4
|
+
isViewable: () => boolean;
|
|
5
|
+
getState: () => string;
|
|
6
|
+
addEventListener: (
|
|
7
|
+
event: 'viewableChange' | 'sizeChange' | 'ready' | 'audioVolumeChange' | 'stateChange' | 'error' | 'orientationChange' | 'resize',
|
|
8
|
+
callback: (...args: any[]) => void
|
|
9
|
+
) => void;
|
|
10
|
+
removeEventListener: (
|
|
11
|
+
event: 'viewableChange' | 'sizeChange' | 'ready' | 'audioVolumeChange' | 'stateChange' | 'error' | 'orientationChange' | 'resize',
|
|
12
|
+
callback: (...args: any[]) => void
|
|
13
|
+
) => void;
|
|
14
|
+
getMaxSize: () => { width: number; height: number };
|
|
15
|
+
openStoreUrl: () => void;
|
|
16
|
+
open: (url: string) => void;
|
|
17
|
+
close: () => void; // Unity Ads 必需:关闭广告
|
|
18
|
+
getAudioVolume: () => number;
|
|
19
|
+
fireTrackingEvent?: (event: string) => void; // Unity Ads 可选:跟踪事件
|
|
20
|
+
preloadStore?: () => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
declare const dapi: {
|
|
24
|
+
addEventListener: (
|
|
25
|
+
event: 'viewableChange' | 'adResized' | 'ready' | 'audioVolumeChange' | 'error',
|
|
26
|
+
callback: (...args: any[]) => void
|
|
27
|
+
) => void;
|
|
28
|
+
removeEventListener: (
|
|
29
|
+
event: 'viewableChange' | 'adResized' | 'ready' | 'audioVolumeChange' | 'error',
|
|
30
|
+
callback: (...args: any[]) => void
|
|
31
|
+
) => void;
|
|
32
|
+
getScreenSize: () => { width: number; height: number };
|
|
33
|
+
openStoreUrl: () => void;
|
|
34
|
+
getAudioVolume: () => number;
|
|
35
|
+
isViewable: () => boolean;
|
|
36
|
+
isReady: () => boolean;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
declare const NUC: {
|
|
40
|
+
trigger: {
|
|
41
|
+
convert: (destinationUrl: string) => void;
|
|
42
|
+
tryAgain: Function;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
declare const ScPlayableAd: { onCTAClick: () => void };
|
|
47
|
+
|
|
48
|
+
// Adikteev 占位符变量
|
|
49
|
+
declare const AK_CLICK_DESTINATION_URL: string;
|
|
50
|
+
declare const AK_CLICK_PIXEL_URL: string;
|
|
51
|
+
declare const FbPlayableAd: { onCTAClick: () => void };
|
|
52
|
+
declare const smxTracking: { redirect: () => void };
|
|
53
|
+
declare const ExitApi: { exit: () => void };
|
|
54
|
+
|
|
55
|
+
declare const AD_NETWORK:
|
|
56
|
+
| 'preview'
|
|
57
|
+
| 'applovin'
|
|
58
|
+
| 'unity'
|
|
59
|
+
| 'google'
|
|
60
|
+
| 'ironsource'
|
|
61
|
+
| 'facebook'
|
|
62
|
+
| 'moloco'
|
|
63
|
+
| 'mintegral'
|
|
64
|
+
| 'vungle'
|
|
65
|
+
| 'adcolony'
|
|
66
|
+
| 'tapjoy'
|
|
67
|
+
| 'snapchat'
|
|
68
|
+
| 'tiktok'
|
|
69
|
+
| 'appreciate'
|
|
70
|
+
| 'chartboost'
|
|
71
|
+
| 'pangle'
|
|
72
|
+
| 'mytarget'
|
|
73
|
+
| 'liftoff'
|
|
74
|
+
| 'smadex'
|
|
75
|
+
| 'adikteev'
|
|
76
|
+
| 'bigabid'
|
|
77
|
+
| 'inmobi'
|
|
78
|
+
| 'bigoads';
|
|
79
|
+
|
|
80
|
+
declare const AD_PROTOCOL: 'mraid' | 'dapi' | 'nucleo' | 'none';
|
|
81
|
+
declare const GOOGLE_PLAY_URL: string;
|
|
82
|
+
declare const APP_STORE_URL: string;
|
|
83
|
+
declare const BUILD_HASH: string;
|
|
84
|
+
|
|
85
|
+
interface Window {
|
|
86
|
+
PlayableSDK: any;
|
|
87
|
+
ADS_MRAID_CONFIG: {
|
|
88
|
+
landUrl: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// AppLovin Playable Analytics
|
|
92
|
+
// 文档: https://support.axon.ai/en/growth/promoting-your-apps/creatives/playable-analytics-integration
|
|
93
|
+
ALPlayableAnalytics?: {
|
|
94
|
+
trackEvent: (event: string) => void;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// BigoAds SDK
|
|
98
|
+
// 文档: https://www.bigoads.com/help/detail?id=143&moduleId=7¤tLan=CN
|
|
99
|
+
BGY_MRAID: {
|
|
100
|
+
open: () => void; // 打开应用商店/推广地址
|
|
101
|
+
gameReady: () => void; // 素材准备完毕时调用
|
|
102
|
+
gameEnd: () => void; // 游戏结束时调用
|
|
103
|
+
isViewable: () => boolean;
|
|
104
|
+
addEventListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
105
|
+
removeEventListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Mintegral functions
|
|
109
|
+
gameReady: Function;
|
|
110
|
+
gameEnd: Function;
|
|
111
|
+
gameRetry: Function;
|
|
112
|
+
install: Function;
|
|
113
|
+
mintGameStart: Function;
|
|
114
|
+
mintGameClose: Function;
|
|
115
|
+
|
|
116
|
+
// Tapjoy functions
|
|
117
|
+
TJ_API: {
|
|
118
|
+
objectiveComplete: Function;
|
|
119
|
+
playableFinished: Function;
|
|
120
|
+
gameplayFinished: Function;
|
|
121
|
+
setPlayableBuild: Function;
|
|
122
|
+
setPlayableAPI: Function;
|
|
123
|
+
click: Function;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
BIGABID_BIDTIMEMACROS?: Record<string, string>
|
|
127
|
+
INMOBI_DSPMACROS?: Record<string, string>
|
|
128
|
+
|
|
129
|
+
openAppStore: Function;
|
|
130
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -532,6 +532,7 @@ function detectCandidates() {
|
|
|
532
532
|
var SUPPORTED_LANG_CODES = [
|
|
533
533
|
"en",
|
|
534
534
|
"zh",
|
|
535
|
+
"zh-TW",
|
|
535
536
|
"ja",
|
|
536
537
|
"ko",
|
|
537
538
|
"de",
|
|
@@ -548,9 +549,31 @@ var SUPPORTED_LANG_CODES = [
|
|
|
548
549
|
"ms",
|
|
549
550
|
"id"
|
|
550
551
|
];
|
|
552
|
+
var LANG_TAG_TO_I18N_CODE = {
|
|
553
|
+
// 简体中文 → zh
|
|
554
|
+
"zh": "zh",
|
|
555
|
+
"zh-cn": "zh",
|
|
556
|
+
"zh-sg": "zh",
|
|
557
|
+
"zh-my": "zh",
|
|
558
|
+
"zh-hans": "zh",
|
|
559
|
+
"zh-hans-cn": "zh",
|
|
560
|
+
"zh-hans-sg": "zh",
|
|
561
|
+
"zh-hans-my": "zh",
|
|
562
|
+
// 繁体中文 → zh-TW
|
|
563
|
+
"zh-tw": "zh-TW",
|
|
564
|
+
"zh-hk": "zh-TW",
|
|
565
|
+
"zh-mo": "zh-TW",
|
|
566
|
+
"zh-hant": "zh-TW",
|
|
567
|
+
"zh-hant-tw": "zh-TW",
|
|
568
|
+
"zh-hant-hk": "zh-TW",
|
|
569
|
+
"zh-hant-mo": "zh-TW"
|
|
570
|
+
};
|
|
551
571
|
function normalizeLangTag(tag) {
|
|
552
572
|
if (!tag || typeof tag !== "string") return void 0;
|
|
553
|
-
const
|
|
573
|
+
const lower = tag.toLowerCase();
|
|
574
|
+
const mapped = LANG_TAG_TO_I18N_CODE[lower];
|
|
575
|
+
if (mapped) return mapped;
|
|
576
|
+
const primary = lower.split(/[-_]/)[0];
|
|
554
577
|
return SUPPORTED_LANG_CODES.indexOf(primary) >= 0 ? primary : void 0;
|
|
555
578
|
}
|
|
556
579
|
function getLanguageCode() {
|
|
@@ -561,97 +584,6 @@ function getLanguageCode() {
|
|
|
561
584
|
}
|
|
562
585
|
return "en";
|
|
563
586
|
}
|
|
564
|
-
var LANGUAGE_MAP = {
|
|
565
|
-
// 英语
|
|
566
|
-
"en": "EN",
|
|
567
|
-
// 中文(简体)
|
|
568
|
-
"zh": "CN_S",
|
|
569
|
-
"zh-cn": "CN_S",
|
|
570
|
-
"zh-sg": "CN_S",
|
|
571
|
-
"zh-my": "CN_S",
|
|
572
|
-
"zh-hans": "CN_S",
|
|
573
|
-
"zh-hans-cn": "CN_S",
|
|
574
|
-
"zh-hans-sg": "CN_S",
|
|
575
|
-
"zh-hans-my": "CN_S",
|
|
576
|
-
// 中文(繁体)
|
|
577
|
-
"zh-tw": "CN_T",
|
|
578
|
-
"zh-hk": "CN_T",
|
|
579
|
-
"zh-mo": "CN_T",
|
|
580
|
-
"zh-hant": "CN_T",
|
|
581
|
-
"zh-hant-tw": "CN_T",
|
|
582
|
-
"zh-hant-hk": "CN_T",
|
|
583
|
-
"zh-hant-mo": "CN_T",
|
|
584
|
-
// 德语
|
|
585
|
-
"de": "DE",
|
|
586
|
-
// 法语
|
|
587
|
-
"fr": "FR",
|
|
588
|
-
// 西班牙语
|
|
589
|
-
"es": "ES",
|
|
590
|
-
// 日语
|
|
591
|
-
"ja": "JA",
|
|
592
|
-
// 韩语
|
|
593
|
-
"ko": "KO",
|
|
594
|
-
// 葡萄牙语
|
|
595
|
-
"pt": "PT",
|
|
596
|
-
// 意大利语
|
|
597
|
-
"it": "IT",
|
|
598
|
-
// 印地语
|
|
599
|
-
"hi": "HI",
|
|
600
|
-
// 孟加拉语
|
|
601
|
-
"bn": "BN",
|
|
602
|
-
// 乌尔都语
|
|
603
|
-
"ur": "UR",
|
|
604
|
-
// 阿拉伯语
|
|
605
|
-
"ar": "AR",
|
|
606
|
-
// 土耳其语
|
|
607
|
-
"tr": "TR",
|
|
608
|
-
// 俄语
|
|
609
|
-
"ru": "RU",
|
|
610
|
-
// 马来语
|
|
611
|
-
"ms": "MS",
|
|
612
|
-
// 印尼语
|
|
613
|
-
"id": "ID"
|
|
614
|
-
};
|
|
615
|
-
var SUPPORTED_PROJECT_LANGUAGES = /* @__PURE__ */ new Set([
|
|
616
|
-
"EN",
|
|
617
|
-
"CN_S",
|
|
618
|
-
"CN_T",
|
|
619
|
-
"DE",
|
|
620
|
-
"FR",
|
|
621
|
-
"ES",
|
|
622
|
-
"JA",
|
|
623
|
-
"KO",
|
|
624
|
-
"PT",
|
|
625
|
-
"IT",
|
|
626
|
-
"HI",
|
|
627
|
-
"BN",
|
|
628
|
-
"UR",
|
|
629
|
-
"AR",
|
|
630
|
-
"TR",
|
|
631
|
-
"RU",
|
|
632
|
-
"MS",
|
|
633
|
-
"IN",
|
|
634
|
-
"ID"
|
|
635
|
-
]);
|
|
636
|
-
function resolveLanguageTag(tag) {
|
|
637
|
-
if (!tag || typeof tag !== "string") return void 0;
|
|
638
|
-
const normalized = tag.trim();
|
|
639
|
-
if (!normalized) return void 0;
|
|
640
|
-
const projectCode = normalized.toUpperCase().replace(/-/g, "_");
|
|
641
|
-
if (SUPPORTED_PROJECT_LANGUAGES.has(projectCode)) return projectCode;
|
|
642
|
-
const lower = normalized.toLowerCase();
|
|
643
|
-
if (LANGUAGE_MAP[lower]) return LANGUAGE_MAP[lower];
|
|
644
|
-
const primary = lower.split(/[-_]/)[0];
|
|
645
|
-
return LANGUAGE_MAP[primary];
|
|
646
|
-
}
|
|
647
|
-
function getLanguage() {
|
|
648
|
-
const candidates = detectCandidates();
|
|
649
|
-
for (const tag of candidates) {
|
|
650
|
-
const code = resolveLanguageTag(tag);
|
|
651
|
-
if (code) return code;
|
|
652
|
-
}
|
|
653
|
-
return "EN";
|
|
654
|
-
}
|
|
655
587
|
|
|
656
588
|
// src/theme-config.ts
|
|
657
589
|
function extractDefaultsFromSchema(schema) {
|
|
@@ -671,14 +603,20 @@ function extractDefaultsFromSchema(schema) {
|
|
|
671
603
|
}
|
|
672
604
|
return void 0;
|
|
673
605
|
}
|
|
606
|
+
var LANG_FALLBACK_MAP = {
|
|
607
|
+
// 繁体中文:优先查专用键,没有则回退通用简体,最后回退 en
|
|
608
|
+
"zh-TW": ["zh-TW", "zh", "en"]
|
|
609
|
+
};
|
|
674
610
|
function lookupI18nRuntime(runtime, key, langCode) {
|
|
611
|
+
var _a;
|
|
675
612
|
const map = runtime[key];
|
|
676
613
|
if (!map || typeof map !== "object") return void 0;
|
|
677
|
-
const
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
614
|
+
const fallbackChain = (_a = LANG_FALLBACK_MAP[langCode]) != null ? _a : [langCode, "en"];
|
|
615
|
+
for (const code of fallbackChain) {
|
|
616
|
+
const val = map[code];
|
|
617
|
+
if (typeof val === "string") return val;
|
|
618
|
+
}
|
|
619
|
+
return Object.values(map).find((v) => typeof v === "string");
|
|
682
620
|
}
|
|
683
621
|
function mergeI18nRuntimes(runtimes) {
|
|
684
622
|
const merged = {};
|
|
@@ -707,7 +645,7 @@ function resolveI18nRefs(config, i18nRecord, langCode) {
|
|
|
707
645
|
if (resolved !== void 0) {
|
|
708
646
|
config[key] = resolved;
|
|
709
647
|
} else {
|
|
710
|
-
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback
|
|
648
|
+
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback.`);
|
|
711
649
|
config[key] = i18nKey;
|
|
712
650
|
}
|
|
713
651
|
}
|
|
@@ -1113,6 +1051,15 @@ function initSDK() {
|
|
|
1113
1051
|
destinationUrl = /android/i.test(navigator.userAgent) ? GOOGLE_PLAY_URL : APP_STORE_URL;
|
|
1114
1052
|
console.log("[SDK DEBUG] destinationUrl set to:", destinationUrl, "length:", destinationUrl.length);
|
|
1115
1053
|
ensureProtocol();
|
|
1054
|
+
document.addEventListener("visibilitychange", function lockScreenAudioHandler() {
|
|
1055
|
+
if (document.visibilityState === "hidden") {
|
|
1056
|
+
changeVolume(0);
|
|
1057
|
+
} else if (document.visibilityState === "visible") {
|
|
1058
|
+
if (!sdk.isPaused) {
|
|
1059
|
+
changeVolume(actualVolume);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1116
1063
|
if ("mraid" === AD_PROTOCOL && typeof mraid === "undefined") {
|
|
1117
1064
|
console.warn("[SDK] MRAID protocol detected but mraid.js not loaded, creating fallback mock (MRAID 2.0)");
|
|
1118
1065
|
window.mraid = {
|
|
@@ -1576,19 +1523,6 @@ var _sdk = class _sdk {
|
|
|
1576
1523
|
static getLanguageCode() {
|
|
1577
1524
|
return getLanguageCode();
|
|
1578
1525
|
}
|
|
1579
|
-
/**
|
|
1580
|
-
* 获取当前用户语言的业务代号。
|
|
1581
|
-
* 多源探测(querystring → localStorage → cookie → navigator → html tag),
|
|
1582
|
-
* 并映射到业务语言代号(区分简繁中文)。
|
|
1583
|
-
*
|
|
1584
|
-
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
1585
|
-
*
|
|
1586
|
-
* @example
|
|
1587
|
-
* const lang = sdk.getLanguage(); // 'CN_S'
|
|
1588
|
-
*/
|
|
1589
|
-
static getLanguage() {
|
|
1590
|
-
return getLanguage();
|
|
1591
|
-
}
|
|
1592
1526
|
/**
|
|
1593
1527
|
* 设置主题配置,支持传入多份 JSON5 配置。
|
|
1594
1528
|
* 每一份配置都可以是 JSON Schema(带 $schema 字段),会自动提取其中的 default 值。
|
|
@@ -1651,7 +1585,7 @@ var _sdk = class _sdk {
|
|
|
1651
1585
|
}
|
|
1652
1586
|
};
|
|
1653
1587
|
/** Current version of the SDK */
|
|
1654
|
-
_sdk.version = "1.0.
|
|
1588
|
+
_sdk.version = "1.0.19";
|
|
1655
1589
|
/** Current maximum width of the playable ad container in pixels */
|
|
1656
1590
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
1657
1591
|
/** Current maximum height of the playable ad container in pixels */
|
|
@@ -1681,7 +1615,6 @@ export {
|
|
|
1681
1615
|
sdk as default,
|
|
1682
1616
|
disableCustomCursor,
|
|
1683
1617
|
enableCustomCursor,
|
|
1684
|
-
getLanguage,
|
|
1685
1618
|
getLanguageCode,
|
|
1686
1619
|
hideWechatGuide,
|
|
1687
1620
|
removeWechatGuide,
|
package/dist/iife/index.js
CHANGED
|
@@ -770,6 +770,7 @@
|
|
|
770
770
|
var SUPPORTED_LANG_CODES = [
|
|
771
771
|
"en",
|
|
772
772
|
"zh",
|
|
773
|
+
"zh-TW",
|
|
773
774
|
"ja",
|
|
774
775
|
"ko",
|
|
775
776
|
"de",
|
|
@@ -786,9 +787,31 @@
|
|
|
786
787
|
"ms",
|
|
787
788
|
"id"
|
|
788
789
|
];
|
|
790
|
+
var LANG_TAG_TO_I18N_CODE = {
|
|
791
|
+
// 简体中文 → zh
|
|
792
|
+
"zh": "zh",
|
|
793
|
+
"zh-cn": "zh",
|
|
794
|
+
"zh-sg": "zh",
|
|
795
|
+
"zh-my": "zh",
|
|
796
|
+
"zh-hans": "zh",
|
|
797
|
+
"zh-hans-cn": "zh",
|
|
798
|
+
"zh-hans-sg": "zh",
|
|
799
|
+
"zh-hans-my": "zh",
|
|
800
|
+
// 繁体中文 → zh-TW
|
|
801
|
+
"zh-tw": "zh-TW",
|
|
802
|
+
"zh-hk": "zh-TW",
|
|
803
|
+
"zh-mo": "zh-TW",
|
|
804
|
+
"zh-hant": "zh-TW",
|
|
805
|
+
"zh-hant-tw": "zh-TW",
|
|
806
|
+
"zh-hant-hk": "zh-TW",
|
|
807
|
+
"zh-hant-mo": "zh-TW"
|
|
808
|
+
};
|
|
789
809
|
function normalizeLangTag(tag) {
|
|
790
810
|
if (!tag || typeof tag !== "string") return void 0;
|
|
791
|
-
const
|
|
811
|
+
const lower = tag.toLowerCase();
|
|
812
|
+
const mapped = LANG_TAG_TO_I18N_CODE[lower];
|
|
813
|
+
if (mapped) return mapped;
|
|
814
|
+
const primary = lower.split(/[-_]/)[0];
|
|
792
815
|
return SUPPORTED_LANG_CODES.indexOf(primary) >= 0 ? primary : void 0;
|
|
793
816
|
}
|
|
794
817
|
function getLanguageCode() {
|
|
@@ -799,97 +822,6 @@
|
|
|
799
822
|
}
|
|
800
823
|
return "en";
|
|
801
824
|
}
|
|
802
|
-
var LANGUAGE_MAP = {
|
|
803
|
-
// 英语
|
|
804
|
-
"en": "EN",
|
|
805
|
-
// 中文(简体)
|
|
806
|
-
"zh": "CN_S",
|
|
807
|
-
"zh-cn": "CN_S",
|
|
808
|
-
"zh-sg": "CN_S",
|
|
809
|
-
"zh-my": "CN_S",
|
|
810
|
-
"zh-hans": "CN_S",
|
|
811
|
-
"zh-hans-cn": "CN_S",
|
|
812
|
-
"zh-hans-sg": "CN_S",
|
|
813
|
-
"zh-hans-my": "CN_S",
|
|
814
|
-
// 中文(繁体)
|
|
815
|
-
"zh-tw": "CN_T",
|
|
816
|
-
"zh-hk": "CN_T",
|
|
817
|
-
"zh-mo": "CN_T",
|
|
818
|
-
"zh-hant": "CN_T",
|
|
819
|
-
"zh-hant-tw": "CN_T",
|
|
820
|
-
"zh-hant-hk": "CN_T",
|
|
821
|
-
"zh-hant-mo": "CN_T",
|
|
822
|
-
// 德语
|
|
823
|
-
"de": "DE",
|
|
824
|
-
// 法语
|
|
825
|
-
"fr": "FR",
|
|
826
|
-
// 西班牙语
|
|
827
|
-
"es": "ES",
|
|
828
|
-
// 日语
|
|
829
|
-
"ja": "JA",
|
|
830
|
-
// 韩语
|
|
831
|
-
"ko": "KO",
|
|
832
|
-
// 葡萄牙语
|
|
833
|
-
"pt": "PT",
|
|
834
|
-
// 意大利语
|
|
835
|
-
"it": "IT",
|
|
836
|
-
// 印地语
|
|
837
|
-
"hi": "HI",
|
|
838
|
-
// 孟加拉语
|
|
839
|
-
"bn": "BN",
|
|
840
|
-
// 乌尔都语
|
|
841
|
-
"ur": "UR",
|
|
842
|
-
// 阿拉伯语
|
|
843
|
-
"ar": "AR",
|
|
844
|
-
// 土耳其语
|
|
845
|
-
"tr": "TR",
|
|
846
|
-
// 俄语
|
|
847
|
-
"ru": "RU",
|
|
848
|
-
// 马来语
|
|
849
|
-
"ms": "MS",
|
|
850
|
-
// 印尼语
|
|
851
|
-
"id": "ID"
|
|
852
|
-
};
|
|
853
|
-
var SUPPORTED_PROJECT_LANGUAGES = /* @__PURE__ */ new Set([
|
|
854
|
-
"EN",
|
|
855
|
-
"CN_S",
|
|
856
|
-
"CN_T",
|
|
857
|
-
"DE",
|
|
858
|
-
"FR",
|
|
859
|
-
"ES",
|
|
860
|
-
"JA",
|
|
861
|
-
"KO",
|
|
862
|
-
"PT",
|
|
863
|
-
"IT",
|
|
864
|
-
"HI",
|
|
865
|
-
"BN",
|
|
866
|
-
"UR",
|
|
867
|
-
"AR",
|
|
868
|
-
"TR",
|
|
869
|
-
"RU",
|
|
870
|
-
"MS",
|
|
871
|
-
"IN",
|
|
872
|
-
"ID"
|
|
873
|
-
]);
|
|
874
|
-
function resolveLanguageTag(tag) {
|
|
875
|
-
if (!tag || typeof tag !== "string") return void 0;
|
|
876
|
-
const normalized = tag.trim();
|
|
877
|
-
if (!normalized) return void 0;
|
|
878
|
-
const projectCode = normalized.toUpperCase().replace(/-/g, "_");
|
|
879
|
-
if (SUPPORTED_PROJECT_LANGUAGES.has(projectCode)) return projectCode;
|
|
880
|
-
const lower = normalized.toLowerCase();
|
|
881
|
-
if (LANGUAGE_MAP[lower]) return LANGUAGE_MAP[lower];
|
|
882
|
-
const primary = lower.split(/[-_]/)[0];
|
|
883
|
-
return LANGUAGE_MAP[primary];
|
|
884
|
-
}
|
|
885
|
-
function getLanguage() {
|
|
886
|
-
const candidates = detectCandidates();
|
|
887
|
-
for (const tag of candidates) {
|
|
888
|
-
const code = resolveLanguageTag(tag);
|
|
889
|
-
if (code) return code;
|
|
890
|
-
}
|
|
891
|
-
return "EN";
|
|
892
|
-
}
|
|
893
825
|
|
|
894
826
|
// src/theme-config.ts
|
|
895
827
|
function extractDefaultsFromSchema(schema) {
|
|
@@ -909,14 +841,20 @@
|
|
|
909
841
|
}
|
|
910
842
|
return void 0;
|
|
911
843
|
}
|
|
844
|
+
var LANG_FALLBACK_MAP = {
|
|
845
|
+
// 繁体中文:优先查专用键,没有则回退通用简体,最后回退 en
|
|
846
|
+
"zh-TW": ["zh-TW", "zh", "en"]
|
|
847
|
+
};
|
|
912
848
|
function lookupI18nRuntime(runtime, key, langCode) {
|
|
849
|
+
var _a;
|
|
913
850
|
const map = runtime[key];
|
|
914
851
|
if (!map || typeof map !== "object") return void 0;
|
|
915
|
-
const
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
852
|
+
const fallbackChain = (_a = LANG_FALLBACK_MAP[langCode]) != null ? _a : [langCode, "en"];
|
|
853
|
+
for (const code of fallbackChain) {
|
|
854
|
+
const val = map[code];
|
|
855
|
+
if (typeof val === "string") return val;
|
|
856
|
+
}
|
|
857
|
+
return Object.values(map).find((v) => typeof v === "string");
|
|
920
858
|
}
|
|
921
859
|
function mergeI18nRuntimes(runtimes) {
|
|
922
860
|
const merged = {};
|
|
@@ -945,7 +883,7 @@
|
|
|
945
883
|
if (resolved !== void 0) {
|
|
946
884
|
config[key] = resolved;
|
|
947
885
|
} else {
|
|
948
|
-
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback
|
|
886
|
+
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback.`);
|
|
949
887
|
config[key] = i18nKey;
|
|
950
888
|
}
|
|
951
889
|
}
|
|
@@ -1351,6 +1289,15 @@
|
|
|
1351
1289
|
destinationUrl = /android/i.test(navigator.userAgent) ? GOOGLE_PLAY_URL : APP_STORE_URL;
|
|
1352
1290
|
console.log("[SDK DEBUG] destinationUrl set to:", destinationUrl, "length:", destinationUrl.length);
|
|
1353
1291
|
ensureProtocol();
|
|
1292
|
+
document.addEventListener("visibilitychange", function lockScreenAudioHandler() {
|
|
1293
|
+
if (document.visibilityState === "hidden") {
|
|
1294
|
+
changeVolume(0);
|
|
1295
|
+
} else if (document.visibilityState === "visible") {
|
|
1296
|
+
if (!sdk.isPaused) {
|
|
1297
|
+
changeVolume(actualVolume);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1354
1301
|
if ("mraid" === AD_PROTOCOL && typeof mraid === "undefined") {
|
|
1355
1302
|
console.warn("[SDK] MRAID protocol detected but mraid.js not loaded, creating fallback mock (MRAID 2.0)");
|
|
1356
1303
|
window.mraid = {
|
|
@@ -1814,19 +1761,6 @@
|
|
|
1814
1761
|
static getLanguageCode() {
|
|
1815
1762
|
return getLanguageCode();
|
|
1816
1763
|
}
|
|
1817
|
-
/**
|
|
1818
|
-
* 获取当前用户语言的业务代号。
|
|
1819
|
-
* 多源探测(querystring → localStorage → cookie → navigator → html tag),
|
|
1820
|
-
* 并映射到业务语言代号(区分简繁中文)。
|
|
1821
|
-
*
|
|
1822
|
-
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
1823
|
-
*
|
|
1824
|
-
* @example
|
|
1825
|
-
* const lang = sdk.getLanguage(); // 'CN_S'
|
|
1826
|
-
*/
|
|
1827
|
-
static getLanguage() {
|
|
1828
|
-
return getLanguage();
|
|
1829
|
-
}
|
|
1830
1764
|
/**
|
|
1831
1765
|
* 设置主题配置,支持传入多份 JSON5 配置。
|
|
1832
1766
|
* 每一份配置都可以是 JSON Schema(带 $schema 字段),会自动提取其中的 default 值。
|
|
@@ -1889,7 +1823,7 @@
|
|
|
1889
1823
|
}
|
|
1890
1824
|
};
|
|
1891
1825
|
/** Current version of the SDK */
|
|
1892
|
-
_sdk.version = "1.0.
|
|
1826
|
+
_sdk.version = "1.0.19";
|
|
1893
1827
|
/** Current maximum width of the playable ad container in pixels */
|
|
1894
1828
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
1895
1829
|
/** Current maximum height of the playable ad container in pixels */
|
package/dist/index.d.mts
CHANGED
|
@@ -276,17 +276,6 @@ declare class sdk {
|
|
|
276
276
|
* const langCode = sdk.getLanguageCode(); // 'zh'
|
|
277
277
|
*/
|
|
278
278
|
static getLanguageCode(): string;
|
|
279
|
-
/**
|
|
280
|
-
* 获取当前用户语言的业务代号。
|
|
281
|
-
* 多源探测(querystring → localStorage → cookie → navigator → html tag),
|
|
282
|
-
* 并映射到业务语言代号(区分简繁中文)。
|
|
283
|
-
*
|
|
284
|
-
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* const lang = sdk.getLanguage(); // 'CN_S'
|
|
288
|
-
*/
|
|
289
|
-
static getLanguage(): string;
|
|
290
279
|
/**
|
|
291
280
|
* 设置主题配置,支持传入多份 JSON5 配置。
|
|
292
281
|
* 每一份配置都可以是 JSON Schema(带 $schema 字段),会自动提取其中的 default 值。
|
|
@@ -378,14 +367,8 @@ declare function removeWechatGuide(): void;
|
|
|
378
367
|
/**
|
|
379
368
|
* 多源探测当前用户语言,并归一化为 i18n 简码。
|
|
380
369
|
*
|
|
381
|
-
* @returns i18n 简码:en | zh | ja | ko | de | fr | es | pt | it | hi | bn | ur | ar | tr | ru | ms | id,默认 'en'
|
|
370
|
+
* @returns i18n 简码:en | zh | zh-TW | ja | ko | de | fr | es | pt | it | hi | bn | ur | ar | tr | ru | ms | id,默认 'en'
|
|
382
371
|
*/
|
|
383
372
|
declare function getLanguageCode(): string;
|
|
384
|
-
/**
|
|
385
|
-
* 多源探测当前用户语言,返回业务语言代号。
|
|
386
|
-
*
|
|
387
|
-
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
388
|
-
*/
|
|
389
|
-
declare function getLanguage(): string;
|
|
390
373
|
|
|
391
|
-
export { type CursorOptions, type I18nRecord, sdk as default, disableCustomCursor, enableCustomCursor,
|
|
374
|
+
export { type CursorOptions, type I18nRecord, sdk as default, disableCustomCursor, enableCustomCursor, getLanguageCode, hideWechatGuide, removeWechatGuide, sdk, showWechatGuide };
|
package/dist/index.d.ts
CHANGED
|
@@ -276,17 +276,6 @@ declare class sdk {
|
|
|
276
276
|
* const langCode = sdk.getLanguageCode(); // 'zh'
|
|
277
277
|
*/
|
|
278
278
|
static getLanguageCode(): string;
|
|
279
|
-
/**
|
|
280
|
-
* 获取当前用户语言的业务代号。
|
|
281
|
-
* 多源探测(querystring → localStorage → cookie → navigator → html tag),
|
|
282
|
-
* 并映射到业务语言代号(区分简繁中文)。
|
|
283
|
-
*
|
|
284
|
-
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* const lang = sdk.getLanguage(); // 'CN_S'
|
|
288
|
-
*/
|
|
289
|
-
static getLanguage(): string;
|
|
290
279
|
/**
|
|
291
280
|
* 设置主题配置,支持传入多份 JSON5 配置。
|
|
292
281
|
* 每一份配置都可以是 JSON Schema(带 $schema 字段),会自动提取其中的 default 值。
|
|
@@ -378,14 +367,8 @@ declare function removeWechatGuide(): void;
|
|
|
378
367
|
/**
|
|
379
368
|
* 多源探测当前用户语言,并归一化为 i18n 简码。
|
|
380
369
|
*
|
|
381
|
-
* @returns i18n 简码:en | zh | ja | ko | de | fr | es | pt | it | hi | bn | ur | ar | tr | ru | ms | id,默认 'en'
|
|
370
|
+
* @returns i18n 简码:en | zh | zh-TW | ja | ko | de | fr | es | pt | it | hi | bn | ur | ar | tr | ru | ms | id,默认 'en'
|
|
382
371
|
*/
|
|
383
372
|
declare function getLanguageCode(): string;
|
|
384
|
-
/**
|
|
385
|
-
* 多源探测当前用户语言,返回业务语言代号。
|
|
386
|
-
*
|
|
387
|
-
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
388
|
-
*/
|
|
389
|
-
declare function getLanguage(): string;
|
|
390
373
|
|
|
391
|
-
export { type CursorOptions, type I18nRecord, sdk as default, disableCustomCursor, enableCustomCursor,
|
|
374
|
+
export { type CursorOptions, type I18nRecord, sdk as default, disableCustomCursor, enableCustomCursor, getLanguageCode, hideWechatGuide, removeWechatGuide, sdk, showWechatGuide };
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,6 @@ __export(index_exports, {
|
|
|
40
40
|
default: () => sdk,
|
|
41
41
|
disableCustomCursor: () => disableCustomCursor,
|
|
42
42
|
enableCustomCursor: () => enableCustomCursor,
|
|
43
|
-
getLanguage: () => getLanguage,
|
|
44
43
|
getLanguageCode: () => getLanguageCode,
|
|
45
44
|
hideWechatGuide: () => hideWechatGuide,
|
|
46
45
|
removeWechatGuide: () => removeWechatGuide,
|
|
@@ -563,6 +562,7 @@ function detectCandidates() {
|
|
|
563
562
|
var SUPPORTED_LANG_CODES = [
|
|
564
563
|
"en",
|
|
565
564
|
"zh",
|
|
565
|
+
"zh-TW",
|
|
566
566
|
"ja",
|
|
567
567
|
"ko",
|
|
568
568
|
"de",
|
|
@@ -579,9 +579,31 @@ var SUPPORTED_LANG_CODES = [
|
|
|
579
579
|
"ms",
|
|
580
580
|
"id"
|
|
581
581
|
];
|
|
582
|
+
var LANG_TAG_TO_I18N_CODE = {
|
|
583
|
+
// 简体中文 → zh
|
|
584
|
+
"zh": "zh",
|
|
585
|
+
"zh-cn": "zh",
|
|
586
|
+
"zh-sg": "zh",
|
|
587
|
+
"zh-my": "zh",
|
|
588
|
+
"zh-hans": "zh",
|
|
589
|
+
"zh-hans-cn": "zh",
|
|
590
|
+
"zh-hans-sg": "zh",
|
|
591
|
+
"zh-hans-my": "zh",
|
|
592
|
+
// 繁体中文 → zh-TW
|
|
593
|
+
"zh-tw": "zh-TW",
|
|
594
|
+
"zh-hk": "zh-TW",
|
|
595
|
+
"zh-mo": "zh-TW",
|
|
596
|
+
"zh-hant": "zh-TW",
|
|
597
|
+
"zh-hant-tw": "zh-TW",
|
|
598
|
+
"zh-hant-hk": "zh-TW",
|
|
599
|
+
"zh-hant-mo": "zh-TW"
|
|
600
|
+
};
|
|
582
601
|
function normalizeLangTag(tag) {
|
|
583
602
|
if (!tag || typeof tag !== "string") return void 0;
|
|
584
|
-
const
|
|
603
|
+
const lower = tag.toLowerCase();
|
|
604
|
+
const mapped = LANG_TAG_TO_I18N_CODE[lower];
|
|
605
|
+
if (mapped) return mapped;
|
|
606
|
+
const primary = lower.split(/[-_]/)[0];
|
|
585
607
|
return SUPPORTED_LANG_CODES.indexOf(primary) >= 0 ? primary : void 0;
|
|
586
608
|
}
|
|
587
609
|
function getLanguageCode() {
|
|
@@ -592,97 +614,6 @@ function getLanguageCode() {
|
|
|
592
614
|
}
|
|
593
615
|
return "en";
|
|
594
616
|
}
|
|
595
|
-
var LANGUAGE_MAP = {
|
|
596
|
-
// 英语
|
|
597
|
-
"en": "EN",
|
|
598
|
-
// 中文(简体)
|
|
599
|
-
"zh": "CN_S",
|
|
600
|
-
"zh-cn": "CN_S",
|
|
601
|
-
"zh-sg": "CN_S",
|
|
602
|
-
"zh-my": "CN_S",
|
|
603
|
-
"zh-hans": "CN_S",
|
|
604
|
-
"zh-hans-cn": "CN_S",
|
|
605
|
-
"zh-hans-sg": "CN_S",
|
|
606
|
-
"zh-hans-my": "CN_S",
|
|
607
|
-
// 中文(繁体)
|
|
608
|
-
"zh-tw": "CN_T",
|
|
609
|
-
"zh-hk": "CN_T",
|
|
610
|
-
"zh-mo": "CN_T",
|
|
611
|
-
"zh-hant": "CN_T",
|
|
612
|
-
"zh-hant-tw": "CN_T",
|
|
613
|
-
"zh-hant-hk": "CN_T",
|
|
614
|
-
"zh-hant-mo": "CN_T",
|
|
615
|
-
// 德语
|
|
616
|
-
"de": "DE",
|
|
617
|
-
// 法语
|
|
618
|
-
"fr": "FR",
|
|
619
|
-
// 西班牙语
|
|
620
|
-
"es": "ES",
|
|
621
|
-
// 日语
|
|
622
|
-
"ja": "JA",
|
|
623
|
-
// 韩语
|
|
624
|
-
"ko": "KO",
|
|
625
|
-
// 葡萄牙语
|
|
626
|
-
"pt": "PT",
|
|
627
|
-
// 意大利语
|
|
628
|
-
"it": "IT",
|
|
629
|
-
// 印地语
|
|
630
|
-
"hi": "HI",
|
|
631
|
-
// 孟加拉语
|
|
632
|
-
"bn": "BN",
|
|
633
|
-
// 乌尔都语
|
|
634
|
-
"ur": "UR",
|
|
635
|
-
// 阿拉伯语
|
|
636
|
-
"ar": "AR",
|
|
637
|
-
// 土耳其语
|
|
638
|
-
"tr": "TR",
|
|
639
|
-
// 俄语
|
|
640
|
-
"ru": "RU",
|
|
641
|
-
// 马来语
|
|
642
|
-
"ms": "MS",
|
|
643
|
-
// 印尼语
|
|
644
|
-
"id": "ID"
|
|
645
|
-
};
|
|
646
|
-
var SUPPORTED_PROJECT_LANGUAGES = /* @__PURE__ */ new Set([
|
|
647
|
-
"EN",
|
|
648
|
-
"CN_S",
|
|
649
|
-
"CN_T",
|
|
650
|
-
"DE",
|
|
651
|
-
"FR",
|
|
652
|
-
"ES",
|
|
653
|
-
"JA",
|
|
654
|
-
"KO",
|
|
655
|
-
"PT",
|
|
656
|
-
"IT",
|
|
657
|
-
"HI",
|
|
658
|
-
"BN",
|
|
659
|
-
"UR",
|
|
660
|
-
"AR",
|
|
661
|
-
"TR",
|
|
662
|
-
"RU",
|
|
663
|
-
"MS",
|
|
664
|
-
"IN",
|
|
665
|
-
"ID"
|
|
666
|
-
]);
|
|
667
|
-
function resolveLanguageTag(tag) {
|
|
668
|
-
if (!tag || typeof tag !== "string") return void 0;
|
|
669
|
-
const normalized = tag.trim();
|
|
670
|
-
if (!normalized) return void 0;
|
|
671
|
-
const projectCode = normalized.toUpperCase().replace(/-/g, "_");
|
|
672
|
-
if (SUPPORTED_PROJECT_LANGUAGES.has(projectCode)) return projectCode;
|
|
673
|
-
const lower = normalized.toLowerCase();
|
|
674
|
-
if (LANGUAGE_MAP[lower]) return LANGUAGE_MAP[lower];
|
|
675
|
-
const primary = lower.split(/[-_]/)[0];
|
|
676
|
-
return LANGUAGE_MAP[primary];
|
|
677
|
-
}
|
|
678
|
-
function getLanguage() {
|
|
679
|
-
const candidates = detectCandidates();
|
|
680
|
-
for (const tag of candidates) {
|
|
681
|
-
const code = resolveLanguageTag(tag);
|
|
682
|
-
if (code) return code;
|
|
683
|
-
}
|
|
684
|
-
return "EN";
|
|
685
|
-
}
|
|
686
617
|
|
|
687
618
|
// src/theme-config.ts
|
|
688
619
|
function extractDefaultsFromSchema(schema) {
|
|
@@ -702,14 +633,20 @@ function extractDefaultsFromSchema(schema) {
|
|
|
702
633
|
}
|
|
703
634
|
return void 0;
|
|
704
635
|
}
|
|
636
|
+
var LANG_FALLBACK_MAP = {
|
|
637
|
+
// 繁体中文:优先查专用键,没有则回退通用简体,最后回退 en
|
|
638
|
+
"zh-TW": ["zh-TW", "zh", "en"]
|
|
639
|
+
};
|
|
705
640
|
function lookupI18nRuntime(runtime, key, langCode) {
|
|
641
|
+
var _a;
|
|
706
642
|
const map = runtime[key];
|
|
707
643
|
if (!map || typeof map !== "object") return void 0;
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
644
|
+
const fallbackChain = (_a = LANG_FALLBACK_MAP[langCode]) != null ? _a : [langCode, "en"];
|
|
645
|
+
for (const code of fallbackChain) {
|
|
646
|
+
const val = map[code];
|
|
647
|
+
if (typeof val === "string") return val;
|
|
648
|
+
}
|
|
649
|
+
return Object.values(map).find((v) => typeof v === "string");
|
|
713
650
|
}
|
|
714
651
|
function mergeI18nRuntimes(runtimes) {
|
|
715
652
|
const merged = {};
|
|
@@ -738,7 +675,7 @@ function resolveI18nRefs(config, i18nRecord, langCode) {
|
|
|
738
675
|
if (resolved !== void 0) {
|
|
739
676
|
config[key] = resolved;
|
|
740
677
|
} else {
|
|
741
|
-
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback
|
|
678
|
+
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback.`);
|
|
742
679
|
config[key] = i18nKey;
|
|
743
680
|
}
|
|
744
681
|
}
|
|
@@ -1144,6 +1081,15 @@ function initSDK() {
|
|
|
1144
1081
|
destinationUrl = /android/i.test(navigator.userAgent) ? GOOGLE_PLAY_URL : APP_STORE_URL;
|
|
1145
1082
|
console.log("[SDK DEBUG] destinationUrl set to:", destinationUrl, "length:", destinationUrl.length);
|
|
1146
1083
|
ensureProtocol();
|
|
1084
|
+
document.addEventListener("visibilitychange", function lockScreenAudioHandler() {
|
|
1085
|
+
if (document.visibilityState === "hidden") {
|
|
1086
|
+
changeVolume(0);
|
|
1087
|
+
} else if (document.visibilityState === "visible") {
|
|
1088
|
+
if (!sdk.isPaused) {
|
|
1089
|
+
changeVolume(actualVolume);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1147
1093
|
if ("mraid" === AD_PROTOCOL && typeof mraid === "undefined") {
|
|
1148
1094
|
console.warn("[SDK] MRAID protocol detected but mraid.js not loaded, creating fallback mock (MRAID 2.0)");
|
|
1149
1095
|
window.mraid = {
|
|
@@ -1607,19 +1553,6 @@ var _sdk = class _sdk {
|
|
|
1607
1553
|
static getLanguageCode() {
|
|
1608
1554
|
return getLanguageCode();
|
|
1609
1555
|
}
|
|
1610
|
-
/**
|
|
1611
|
-
* 获取当前用户语言的业务代号。
|
|
1612
|
-
* 多源探测(querystring → localStorage → cookie → navigator → html tag),
|
|
1613
|
-
* 并映射到业务语言代号(区分简繁中文)。
|
|
1614
|
-
*
|
|
1615
|
-
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
1616
|
-
*
|
|
1617
|
-
* @example
|
|
1618
|
-
* const lang = sdk.getLanguage(); // 'CN_S'
|
|
1619
|
-
*/
|
|
1620
|
-
static getLanguage() {
|
|
1621
|
-
return getLanguage();
|
|
1622
|
-
}
|
|
1623
1556
|
/**
|
|
1624
1557
|
* 设置主题配置,支持传入多份 JSON5 配置。
|
|
1625
1558
|
* 每一份配置都可以是 JSON Schema(带 $schema 字段),会自动提取其中的 default 值。
|
|
@@ -1682,7 +1615,7 @@ var _sdk = class _sdk {
|
|
|
1682
1615
|
}
|
|
1683
1616
|
};
|
|
1684
1617
|
/** Current version of the SDK */
|
|
1685
|
-
_sdk.version = "1.0.
|
|
1618
|
+
_sdk.version = "1.0.19";
|
|
1686
1619
|
/** Current maximum width of the playable ad container in pixels */
|
|
1687
1620
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
1688
1621
|
/** Current maximum height of the playable ad container in pixels */
|
|
@@ -1712,7 +1645,6 @@ window.PlayableSDK = sdk;
|
|
|
1712
1645
|
0 && (module.exports = {
|
|
1713
1646
|
disableCustomCursor,
|
|
1714
1647
|
enableCustomCursor,
|
|
1715
|
-
getLanguage,
|
|
1716
1648
|
getLanguageCode,
|
|
1717
1649
|
hideWechatGuide,
|
|
1718
1650
|
removeWechatGuide,
|
package/package.json
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@playcraft/adsdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "统一的 Playable SDK,支持 MRAID、Google、Facebook、Vungle、BigoAds 等多广告渠道",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/esm/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"dist",
|
|
13
|
-
"LICENSE",
|
|
14
|
-
"defines.d.ts"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "npx tsup",
|
|
18
|
-
"test": "jest",
|
|
19
|
-
"deploy": "npm run build && node scripts/publish.js",
|
|
20
|
-
"deploy:beta": "npm run build && node scripts/publish.js --tag beta"
|
|
21
|
-
},
|
|
22
|
-
"author": "Tencent ADS Team",
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@types/jest": "^29.5.14",
|
|
26
|
-
"jest": "^29.7.0",
|
|
27
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
28
|
-
"ts-jest": "^29.2.5",
|
|
29
|
-
"tsup": "^8.4.0",
|
|
30
|
-
"typescript": "^5.7.2"
|
|
31
|
-
},
|
|
32
|
-
"keywords": [
|
|
33
|
-
"playable",
|
|
34
|
-
"sdk",
|
|
35
|
-
"playable-sdk",
|
|
36
|
-
"PlayableSDK",
|
|
37
|
-
"playable-ads",
|
|
38
|
-
"html5",
|
|
39
|
-
"tencent",
|
|
40
|
-
"bigoads",
|
|
41
|
-
"mraid",
|
|
42
|
-
"google-ads",
|
|
43
|
-
"facebook-playable",
|
|
44
|
-
"unity-ads",
|
|
45
|
-
"vungle",
|
|
46
|
-
"ironsource",
|
|
47
|
-
"javascript-sdk",
|
|
48
|
-
"typescript-sdk"
|
|
49
|
-
],
|
|
50
|
-
"publishConfig": {
|
|
51
|
-
"registry": "https://mirrors.tencent.com/npm/"
|
|
52
|
-
},
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"@playcraft/ads-tracking": "*"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@playcraft/adsdk",
|
|
3
|
+
"version": "1.0.19",
|
|
4
|
+
"description": "统一的 Playable SDK,支持 MRAID、Google、Facebook、Vungle、BigoAds 等多广告渠道",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"defines.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "npx tsup",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"deploy": "npm run build && node scripts/publish.js",
|
|
20
|
+
"deploy:beta": "npm run build && node scripts/publish.js --tag beta"
|
|
21
|
+
},
|
|
22
|
+
"author": "Tencent ADS Team",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/jest": "^29.5.14",
|
|
26
|
+
"jest": "^29.7.0",
|
|
27
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
28
|
+
"ts-jest": "^29.2.5",
|
|
29
|
+
"tsup": "^8.4.0",
|
|
30
|
+
"typescript": "^5.7.2"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"playable",
|
|
34
|
+
"sdk",
|
|
35
|
+
"playable-sdk",
|
|
36
|
+
"PlayableSDK",
|
|
37
|
+
"playable-ads",
|
|
38
|
+
"html5",
|
|
39
|
+
"tencent",
|
|
40
|
+
"bigoads",
|
|
41
|
+
"mraid",
|
|
42
|
+
"google-ads",
|
|
43
|
+
"facebook-playable",
|
|
44
|
+
"unity-ads",
|
|
45
|
+
"vungle",
|
|
46
|
+
"ironsource",
|
|
47
|
+
"javascript-sdk",
|
|
48
|
+
"typescript-sdk"
|
|
49
|
+
],
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"registry": "https://mirrors.tencent.com/npm/"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@playcraft/ads-tracking": "*"
|
|
55
|
+
}
|
|
56
|
+
}
|