@playcraft/devkit 1.0.23 → 1.0.25
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.
|
@@ -94,6 +94,12 @@ const hasHeadContent=headContent.length>0;const decompressCodeReadable=`
|
|
|
94
94
|
// 提取并放在模板 head 中,这里只需追加未被模板覆盖的内联脚本和样式
|
|
95
95
|
// 如果原始 HTML 是片段(__hasHeadContent=false),如 Adikteev 格式,
|
|
96
96
|
// 所有资源引用都在压缩数据中,需要完整恢复——包括外部脚本和样式表
|
|
97
|
+
//
|
|
98
|
+
// 重要:动态注入的外部脚本在页面解析完成后才异步加载执行,
|
|
99
|
+
// 此时 DOMContentLoaded 已触发,脚本内的事件监听器将永远无法执行。
|
|
100
|
+
// 因此在外部脚本加载完成后手动 dispatch DOMContentLoaded,确保游戏等代码正常初始化。
|
|
101
|
+
var __extScriptCount = 0;
|
|
102
|
+
var __extScriptLoaded = 0;
|
|
97
103
|
Array.from(doc.head.children).forEach(function(child) {
|
|
98
104
|
if (child.tagName === 'SCRIPT') {
|
|
99
105
|
if (!child.src && child.textContent) {
|
|
@@ -105,11 +111,18 @@ const hasHeadContent=headContent.length>0;const decompressCodeReadable=`
|
|
|
105
111
|
} else if (child.src && !__hasHeadContent) {
|
|
106
112
|
// 外部 script(有 src 属性,如 <script src="creative.js">)
|
|
107
113
|
// 仅在原始 HTML 无 <head> 时恢复,避免与模板中已提取的重复
|
|
114
|
+
__extScriptCount++;
|
|
108
115
|
var extScript = document.createElement('script');
|
|
109
116
|
extScript.src = child.src;
|
|
110
117
|
if (child.type) extScript.type = child.type;
|
|
111
118
|
if (child.async) extScript.async = true;
|
|
112
119
|
if (child.defer) extScript.defer = true;
|
|
120
|
+
extScript.onload = function() {
|
|
121
|
+
__extScriptLoaded++;
|
|
122
|
+
if (__extScriptLoaded >= __extScriptCount) {
|
|
123
|
+
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
124
|
+
}
|
|
125
|
+
};
|
|
113
126
|
document.head.appendChild(extScript);
|
|
114
127
|
}
|
|
115
128
|
} else if (child.tagName === 'STYLE') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";/** @type {string[]} List of supported advertising networks */const allowedAdNetworks=["preview","applovin","unity","google","ironsource","facebook","moloco","adcolony","mintegral","vungle","tapjoy","snapchat","tiktok","appreciate","chartboost","pangle","mytarget","liftoff","smadex","adikteev","bigabid","inmobi","bigoads"];/** @type {AD_PROTOCOL[]} List of supported advertising protocols */const allowedAdProtocols=["none","mraid","dapi"];/** @type {AD_NETWORK[]} List of advertising partners that support MRAID protocol */const mraidPartners=["ironsource","applovin","unity","appreciate","chartboost","mytarget","liftoff","adcolony","adikteev","bigabid","inmobi"];/** @type {LANGUAGE[]} */const allowedLanguages=["auto","en","es","zh","hi","ar","fr","de","ja","pt"];/** @type {ORIENTATION[]} */const allowedOrientations=["both","portrait","landscape","square"];/**
|
|
1
|
+
"use strict";/** @type {string[]} List of supported advertising networks */const allowedAdNetworks=["preview","applovin","unity","google","ironsource","facebook","moloco","adcolony","mintegral","vungle","tapjoy","snapchat","tiktok","appreciate","chartboost","pangle","mytarget","liftoff","smadex","adikteev","bigabid","inmobi","bigoads","social_media"];/** @type {AD_PROTOCOL[]} List of supported advertising protocols */const allowedAdProtocols=["none","mraid","dapi"];/** @type {AD_NETWORK[]} List of advertising partners that support MRAID protocol */const mraidPartners=["ironsource","applovin","unity","appreciate","chartboost","mytarget","liftoff","adcolony","adikteev","bigabid","inmobi"];/** @type {LANGUAGE[]} */const allowedLanguages=["auto","en","es","zh","hi","ar","fr","de","ja","pt"];/** @type {ORIENTATION[]} */const allowedOrientations=["both","portrait","landscape","square"];/**
|
|
2
2
|
* Parses command line arguments based on provided options configuration
|
|
3
3
|
* @param {import('../index').CLIOptionConfig[]} posiibleOptions - Array of possible options to parse
|
|
4
4
|
* @returns {Record<string, any>} Parsed options object with values from command line arguments
|
|
@@ -43,7 +43,8 @@ if(!fs.existsSync(schemaPath)){return{defaultData:null,mergedData:null,isPlainDa
|
|
|
43
43
|
if(!isJsonSchema(schemaContent)){return{defaultData:schemaContent,mergedData:schemaContent,isPlainData:true,errors:null}}// 从 schema 提取默认值
|
|
44
44
|
const defaultData=extractDefaultsFromSchema(schemaContent)||{};let themeData={};if(fs.existsSync(dataPath)){themeData=JSON5.parse(fs.readFileSync(dataPath,"utf8"))}// 深度合并(主题数据覆盖 schema 默认值),然后校验
|
|
45
45
|
const merged=deepMerge(defaultData,themeData);// --- 根据 schema 校验合并后的数据 ---
|
|
46
|
-
const ajv=new Ajv({allErrors:true,strict:false});
|
|
46
|
+
const ajv=new Ajv({allErrors:true,strict:false});let validate;try{validate=ajv.compile(schemaContent)}catch(schemaErr){// schema 文件被之前的构建中断污染(mergedData 覆盖了 schema)→ 按纯数据恢复
|
|
47
|
+
console.warn(`[validateThemeData] schema 编译失败(可能被覆盖),降级为纯数据: ${schemaErr.message}`);return{defaultData:merged,mergedData:merged,isPlainData:true,errors:null}}const valid=validate(merged);if(!valid){const errors=validate.errors.map(err=>{const field=err.instancePath||"(root)";return`${field} ${err.message}`});return{defaultData,mergedData:merged,isPlainData:false,errors}}return{defaultData,mergedData:merged,isPlainData:false,errors:null}}/**
|
|
47
48
|
* 深度合并两个普通对象。`override` 中的值优先。
|
|
48
49
|
* 数组会被整体替换(不会拼接)。
|
|
49
50
|
*
|
package/defines.d.ts
CHANGED