@playcraft/build 0.1.89 → 0.1.90
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/dist/audio-source-files.d.ts +5 -0
- package/dist/audio-source-files.js +135 -0
- package/dist/base-builder.js +41 -2
- package/dist/delivery/agent-build-runner.d.ts +44 -0
- package/dist/delivery/agent-build-runner.js +365 -0
- package/dist/delivery/agent-build-source.d.ts +8 -0
- package/dist/delivery/agent-build-source.js +25 -0
- package/dist/delivery/artifact-descriptor.d.ts +31 -0
- package/dist/delivery/artifact-descriptor.js +237 -0
- package/dist/delivery/artifact-package.d.ts +43 -0
- package/dist/delivery/artifact-package.js +283 -0
- package/dist/delivery/build-plan.d.ts +4 -0
- package/dist/delivery/build-plan.js +189 -0
- package/dist/delivery/build-plan.types.d.ts +51 -0
- package/dist/delivery/build-plan.types.js +1 -0
- package/dist/delivery/command-isolation.d.ts +7 -0
- package/dist/delivery/command-isolation.js +252 -0
- package/dist/delivery/commands.d.ts +5 -0
- package/dist/delivery/commands.js +137 -0
- package/dist/delivery/files.d.ts +9 -0
- package/dist/delivery/files.js +144 -0
- package/dist/delivery/git-source-fingerprint.d.ts +2 -0
- package/dist/delivery/git-source-fingerprint.js +58 -0
- package/dist/delivery/isolated-source.d.ts +5 -0
- package/dist/delivery/isolated-source.js +126 -0
- package/dist/delivery/output-publication.d.ts +21 -0
- package/dist/delivery/output-publication.js +444 -0
- package/dist/delivery/project-delivery.d.ts +6 -0
- package/dist/delivery/project-delivery.js +287 -0
- package/dist/delivery/recipe-build-plan.d.ts +4 -0
- package/dist/delivery/recipe-build-plan.js +53 -0
- package/dist/delivery/recipe.d.ts +20 -0
- package/dist/delivery/recipe.js +211 -0
- package/dist/delivery/safe-path.d.ts +2 -0
- package/dist/delivery/safe-path.js +18 -0
- package/dist/delivery/types.d.ts +76 -0
- package/dist/delivery/types.js +1 -0
- package/dist/engines/engine-detector.js +4 -0
- package/dist/engines/generic-adapter.js +14 -19
- package/dist/index.d.ts +19 -4
- package/dist/index.js +11 -2
- package/dist/platforms/adikteev.js +1 -0
- package/dist/platforms/applovin.js +1 -0
- package/dist/platforms/base.js +2 -2
- package/dist/platforms/bigo.js +1 -0
- package/dist/platforms/facebook.js +1 -0
- package/dist/platforms/google.js +1 -0
- package/dist/platforms/inmobi.js +1 -0
- package/dist/platforms/ironsource.js +1 -0
- package/dist/platforms/liftoff.js +1 -0
- package/dist/platforms/mintegral.js +1 -0
- package/dist/platforms/moloco.js +1 -0
- package/dist/platforms/playcraft.js +1 -0
- package/dist/platforms/remerge.js +1 -0
- package/dist/platforms/snapchat.js +1 -0
- package/dist/platforms/tiktok.js +1 -0
- package/dist/platforms/unity.js +1 -0
- package/dist/production-animation-presence.d.ts +2 -0
- package/dist/production-animation-presence.js +146 -0
- package/dist/production-inputs.d.ts +30 -0
- package/dist/production-inputs.js +262 -0
- package/dist/production-source-paths.d.ts +5 -0
- package/dist/production-source-paths.js +27 -0
- package/dist/types.d.ts +5 -0
- package/dist/validation/artifact-qa.d.ts +44 -0
- package/dist/validation/artifact-qa.js +170 -0
- package/dist/validation/artifact-rules.d.ts +28 -0
- package/dist/validation/artifact-rules.js +440 -0
- package/dist/validation/artifact.d.ts +14 -0
- package/dist/validation/artifact.js +188 -0
- package/dist/validation/html-validator.d.ts +5 -0
- package/dist/validation/html-validator.js +19 -17
- package/dist/validation/index.d.ts +4 -0
- package/dist/validation/index.js +4 -0
- package/dist/validation/package-validator.d.ts +2 -0
- package/dist/validation/package-validator.js +25 -64
- package/dist/validation/profiles.d.ts +13 -1
- package/dist/validation/profiles.js +27 -0
- package/dist/validation/runtime-load.d.ts +89 -0
- package/dist/validation/runtime-load.js +654 -0
- package/dist/validation/source-scanner.d.ts +11 -0
- package/dist/validation/source-scanner.js +32 -2
- package/dist/validation/types.d.ts +155 -2
- package/dist/validation/types.js +1 -1
- package/dist/validation/validation-runner.d.ts +22 -2
- package/dist/validation/validation-runner.js +68 -3
- package/dist/validation/zip-reader.d.ts +7 -0
- package/dist/validation/zip-reader.js +159 -26
- package/dist/vite/config-builder-generic.d.ts +3 -1
- package/dist/vite/config-builder-generic.js +9 -7
- package/dist/vite/config-builder.js +1 -1
- package/dist/vite/plugin-platform.js +30 -54
- package/dist/vite/plugin-source-builder.d.ts +2 -14
- package/dist/vite/plugin-source-builder.js +61 -997
- package/dist/vite/source-builder-asset-paths.d.ts +25 -0
- package/dist/vite/source-builder-asset-paths.js +154 -0
- package/dist/vite/source-builder-esm.d.ts +7 -0
- package/dist/vite/source-builder-esm.js +877 -0
- package/dist/vite/source-builder-types.d.ts +14 -0
- package/dist/vite/source-builder-types.js +1 -0
- package/dist/vite/workspace.d.ts +6 -0
- package/dist/vite/workspace.js +41 -0
- package/dist/vite-builder.d.ts +4 -5
- package/dist/vite-builder.js +33 -34
- package/dist/workspace-css-imports.d.ts +2 -0
- package/dist/workspace-css-imports.js +139 -0
- package/dist/workspace-model-source.d.ts +14 -0
- package/dist/workspace-model-source.js +184 -0
- package/dist/workspace-public-imports.d.ts +11 -0
- package/dist/workspace-public-imports.js +232 -0
- package/dist/workspace-public-source.d.ts +15 -0
- package/dist/workspace-public-source.js +564 -0
- package/package.json +15 -3
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ProductionSourceSnapshot } from '../production-inputs.js';
|
|
2
|
+
export type DeliveryCommand = {
|
|
3
|
+
argv: string[];
|
|
4
|
+
cwd?: string;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
};
|
|
7
|
+
export type ProjectDeliveryRecipe = {
|
|
8
|
+
version: 1;
|
|
9
|
+
command: DeliveryCommand;
|
|
10
|
+
prepareCommands?: DeliveryCommand[];
|
|
11
|
+
/** Explicit compiler caches/additional generated directories; source inputs remain fingerprinted. */
|
|
12
|
+
generatedDirectories?: string[];
|
|
13
|
+
output: {
|
|
14
|
+
kind: 'web-bundle' | 'channel-package';
|
|
15
|
+
/** Relative to the project root. */
|
|
16
|
+
directory: string;
|
|
17
|
+
/** Relative to output.directory. */
|
|
18
|
+
entry: string;
|
|
19
|
+
};
|
|
20
|
+
toolchain?: {
|
|
21
|
+
executables: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type DeliveryPreparationStamp = {
|
|
25
|
+
sourceRulesVersion?: ProductionSourceSnapshot['sourceRulesVersion'];
|
|
26
|
+
recipeDigest: string;
|
|
27
|
+
sourceFingerprint: string;
|
|
28
|
+
channel?: string;
|
|
29
|
+
format?: 'html' | 'zip';
|
|
30
|
+
};
|
|
31
|
+
export type ProjectDeliveryIssue = {
|
|
32
|
+
code: string;
|
|
33
|
+
message: string;
|
|
34
|
+
path?: string;
|
|
35
|
+
};
|
|
36
|
+
export type ProjectDeliveryInspection = {
|
|
37
|
+
sourceRulesVersion?: ProductionSourceSnapshot['sourceRulesVersion'];
|
|
38
|
+
status: 'missing' | 'invalid' | 'stale' | 'ready';
|
|
39
|
+
checkedAt: string;
|
|
40
|
+
errors: ProjectDeliveryIssue[];
|
|
41
|
+
sourceFingerprint?: string;
|
|
42
|
+
recipeDigest?: string;
|
|
43
|
+
recipe?: ProjectDeliveryRecipe;
|
|
44
|
+
channel?: string;
|
|
45
|
+
format?: 'html' | 'zip';
|
|
46
|
+
};
|
|
47
|
+
export type ProjectDeliveryOptions = {
|
|
48
|
+
channel?: string;
|
|
49
|
+
format?: 'html' | 'zip';
|
|
50
|
+
/** A Runtime-owned directory can hold receipts outside the Agent's writable project. */
|
|
51
|
+
receiptDirectory?: string;
|
|
52
|
+
receiptPath?: string;
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
/** Runtime injects its existing restricted developer-command launcher. */
|
|
55
|
+
runCommand?: (command: DeliveryCommand & {
|
|
56
|
+
cwd: string;
|
|
57
|
+
}) => Promise<{
|
|
58
|
+
code: number | null;
|
|
59
|
+
stdout?: string;
|
|
60
|
+
stderr?: string;
|
|
61
|
+
timedOut?: boolean;
|
|
62
|
+
canceled?: boolean;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
export type ExecuteProjectDeliveryOptions = ProjectDeliveryOptions & {
|
|
66
|
+
outputDir: string;
|
|
67
|
+
expectedPreparation?: DeliveryPreparationStamp;
|
|
68
|
+
};
|
|
69
|
+
export type ProjectDeliveryOutput = {
|
|
70
|
+
sourceRulesVersion?: ProductionSourceSnapshot['sourceRulesVersion'];
|
|
71
|
+
kind: ProjectDeliveryRecipe['output']['kind'];
|
|
72
|
+
directory: string;
|
|
73
|
+
entry: string;
|
|
74
|
+
recipeDigest: string;
|
|
75
|
+
sourceFingerprint: string;
|
|
76
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -309,6 +309,10 @@ export class EngineDetector {
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
if (matches.length === 0) {
|
|
312
|
+
// Creator projects carry their editor version here; Node's engine version is unrelated.
|
|
313
|
+
if (isRecord(pkg.creator) && typeof pkg.creator.version === 'string' &&
|
|
314
|
+
/^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/.test(pkg.creator.version))
|
|
315
|
+
return 'cocos';
|
|
312
316
|
return null;
|
|
313
317
|
}
|
|
314
318
|
// 按优先级排序,返回最高优先级的引擎
|
|
@@ -30,23 +30,8 @@ export class GenericAdapter {
|
|
|
30
30
|
// 1. 检测包管理器
|
|
31
31
|
const packageManager = await this.detectPackageManager();
|
|
32
32
|
console.log(`[GenericAdapter] 检测到包管理器: ${packageManager}`);
|
|
33
|
-
// 2.
|
|
34
|
-
|
|
35
|
-
if (hasNodeModules) {
|
|
36
|
-
console.log('[GenericAdapter] node_modules 已存在,跳过依赖安装');
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
// 3. 执行安装
|
|
40
|
-
console.log('[GenericAdapter] 执行依赖安装...');
|
|
41
|
-
await this.runNpmInstall(packageManager);
|
|
42
|
-
}
|
|
43
|
-
// 4. 检测构建命令。**必须先构建、再取产物**,不允许因为「找不到脚本」就
|
|
44
|
-
// 复用工程里现成的目录:那会把残留的 `dist/` 或 Vite 的 `public/` 当成
|
|
45
|
-
// 构建结果,用户拿到的是过期或完全不对的内容。
|
|
46
|
-
//
|
|
47
|
-
// 平台导入的工程都带 `builds.config.js`,由 playable-scripts 构建链负责
|
|
48
|
-
// 产出产物,正常路径下这里必然能拿到 build 脚本;拿不到就是工程本身有问题,
|
|
49
|
-
// 应当明确报错而不是静默降级。
|
|
33
|
+
// 2. 安装前验证 package.json 和构建命令,避免无效工程产生安装副作用。
|
|
34
|
+
// 必须先构建、再取产物,不允许复用残留的 dist/ 或 public/。
|
|
50
35
|
const buildScript = await this.detectBuildScript();
|
|
51
36
|
if (!buildScript) {
|
|
52
37
|
throw new Error(`[GenericAdapter] 未找到可用的构建命令,拒绝复用工程内现成的目录。\n` +
|
|
@@ -55,6 +40,15 @@ export class GenericAdapter {
|
|
|
55
40
|
`build:production / dist / compile 之一)。`);
|
|
56
41
|
}
|
|
57
42
|
console.log(`[GenericAdapter] 检测到构建命令: ${buildScript}`);
|
|
43
|
+
// 3. 检查 node_modules 是否存在
|
|
44
|
+
const hasNodeModules = await this.checkNodeModules();
|
|
45
|
+
if (hasNodeModules) {
|
|
46
|
+
console.log('[GenericAdapter] node_modules 已存在,跳过依赖安装');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log('[GenericAdapter] 执行依赖安装...');
|
|
50
|
+
await this.runNpmInstall(packageManager);
|
|
51
|
+
}
|
|
58
52
|
// 5. 执行构建
|
|
59
53
|
console.log('[GenericAdapter] 执行项目构建...');
|
|
60
54
|
const originalBuildDir = await this.runNpmBuild(packageManager, buildScript);
|
|
@@ -346,7 +340,9 @@ export class GenericAdapter {
|
|
|
346
340
|
*/
|
|
347
341
|
getNestedValue(obj, path) {
|
|
348
342
|
return path.split('.').reduce((current, key) => {
|
|
349
|
-
|
|
343
|
+
if (current === null || typeof current !== 'object')
|
|
344
|
+
return undefined;
|
|
345
|
+
return current[key];
|
|
350
346
|
}, obj);
|
|
351
347
|
}
|
|
352
348
|
/**
|
|
@@ -421,7 +417,6 @@ export class GenericAdapter {
|
|
|
421
417
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
422
418
|
for (const entry of entries) {
|
|
423
419
|
const fullPath = path.join(dir, entry.name);
|
|
424
|
-
const relativePath = path.relative(basePath, fullPath);
|
|
425
420
|
if (entry.isDirectory()) {
|
|
426
421
|
await scanDir(fullPath, basePath);
|
|
427
422
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
export { BaseBuilder } from './base-builder.js';
|
|
2
2
|
export type { BaseBuildOptions, BaseBuildOutput } from './base-builder.js';
|
|
3
|
+
export { inspectProjectDelivery, prepareProjectDelivery, executeProjectDelivery, } from './delivery/project-delivery.js';
|
|
4
|
+
export { parseProjectDeliveryRecipe, readProjectDeliveryRecipe, recipeDigest, ProjectDeliveryError, } from './delivery/recipe.js';
|
|
5
|
+
export type { DeliveryCommand, ProjectDeliveryRecipe, DeliveryPreparationStamp, ProjectDeliveryIssue, ProjectDeliveryInspection, ProjectDeliveryOptions, ExecuteProjectDeliveryOptions, ProjectDeliveryOutput, } from './delivery/types.js';
|
|
6
|
+
export { parseBuildPlan, buildPlanDigest } from './delivery/build-plan.js';
|
|
7
|
+
export { createRecipeBuildPlan } from './delivery/recipe-build-plan.js';
|
|
8
|
+
export type { BuildPlan, BuildPackageManager, RecipeBuildPlanOptions } from './delivery/build-plan.types.js';
|
|
9
|
+
export { parseArtifactDescriptor, assertArtifactDescriptorDigest, artifactBytesDigest, artifactFileDescriptor, } from './delivery/artifact-descriptor.js';
|
|
10
|
+
export type { ArtifactDescriptor, ArtifactFileDescriptor, ArtifactIdentity, } from './delivery/artifact-descriptor.js';
|
|
11
|
+
export { ARTIFACT_LIMITS, normalizeArtifactPath, validateArtifactFiles, readArtifactDirectory, createNormalizedZip, readZipArtifact, packageChannelArtifact, describeChannelArtifact, verifyChannelArtifactDescriptor, } from './delivery/artifact-package.js';
|
|
12
|
+
export type { ArtifactInputFile, PackageChannelArtifactOptions, DescribeChannelArtifactOptions, } from './delivery/artifact-package.js';
|
|
13
|
+
export type { ViteWorkspace } from './vite/workspace.js';
|
|
14
|
+
export { readProductionSourceSnapshot, readProductionSourceFile, verifyProductionSourceSnapshot, productionSourcePathAllowed, productionAuxiliaryPathAllowed, ProductionSourceError, PRODUCTION_SOURCE_RULES_VERSION, SUPPORTED_PRODUCTION_SOURCE_RULES_VERSIONS } from './production-inputs.js';
|
|
15
|
+
export type { ProductionSourceSnapshot, ProductionSourceFile } from './production-inputs.js';
|
|
16
|
+
export { readWorkspacePublicSourceClosure } from './workspace-public-source.js';
|
|
17
|
+
export { assertNoUnanchoredFrameAnimationSources } from './production-animation-presence.js';
|
|
3
18
|
export { ViteBuilder } from './vite-builder.js';
|
|
4
19
|
export type { ViteBuildOutput } from './vite-builder.js';
|
|
5
20
|
export { PlayableBuilder } from './playable-builder.js';
|
|
6
21
|
export type { PlayableBuildOutput } from './playable-builder.js';
|
|
7
22
|
export { OnePageConverter } from './converter.js';
|
|
8
|
-
export { EngineDetector, PlayCanvasAdapter, GenericAdapter, PlayableScriptsAdapter } from './engines/index.js';
|
|
23
|
+
export { EngineDetector, PlayCanvasAdapter, GenericAdapter, PlayableScriptsAdapter, } from './engines/index.js';
|
|
9
24
|
export { BuildStateManager, BUILD_STATE_VERSION } from './state/index.js';
|
|
10
25
|
export type { AssetType, ProcessingStage, OptimizationType, AssetProcessingInfo, AssetState, BuildStageInfo, BuildState, } from './state/index.js';
|
|
11
26
|
export { StateToReportConverter } from './state/index.js';
|
|
@@ -13,8 +28,8 @@ export type { UnifiedReportData, ReportAsset, ProcessingStep, TypeStatistics, Ca
|
|
|
13
28
|
export { BuildAnalyzer } from './analyzers/build-analyzer.js';
|
|
14
29
|
export type { BuildAnalysisReport, FileAnalysis } from './analyzers/build-analyzer.js';
|
|
15
30
|
export { PlayableAnalyzer } from './analyzers/playable-analyzer.js';
|
|
16
|
-
export type { PlayableAnalysisReport, PlayableAssetAnalysis } from './analyzers/playable-analyzer.js';
|
|
17
|
-
export { analyzeSceneDependencies, collectScenesAssets, printSceneDependencies } from './analyzers/scene-asset-collector.js';
|
|
31
|
+
export type { PlayableAnalysisReport, PlayableAssetAnalysis, } from './analyzers/playable-analyzer.js';
|
|
32
|
+
export { analyzeSceneDependencies, collectScenesAssets, printSceneDependencies, } from './analyzers/scene-asset-collector.js';
|
|
18
33
|
export type { SceneDependencies } from './analyzers/scene-asset-collector.js';
|
|
19
34
|
export { detectAmmoUsage } from './utils/ammo-detector.js';
|
|
20
35
|
export { createPlatformAdapter, PlatformAdapter } from './platforms/index.js';
|
|
@@ -24,6 +39,6 @@ export { ViteConfigBuilder } from './vite/config-builder.js';
|
|
|
24
39
|
export { PLATFORM_CONFIGS } from './vite/platform-configs.js';
|
|
25
40
|
export type { PlatformViteConfig } from './vite/platform-configs.js';
|
|
26
41
|
export { AudioOptimizer } from './audio-optimizer.js';
|
|
27
|
-
export type { AudioAssetInfo, AudioOptimizationReport, AudioOptimizerOptions } from './audio-optimizer.js';
|
|
42
|
+
export type { AudioAssetInfo, AudioOptimizationReport, AudioOptimizerOptions, } from './audio-optimizer.js';
|
|
28
43
|
export * from './validation/index.js';
|
|
29
44
|
export * from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
// 导出构建器
|
|
2
2
|
export { BaseBuilder } from './base-builder.js';
|
|
3
|
+
export { inspectProjectDelivery, prepareProjectDelivery, executeProjectDelivery, } from './delivery/project-delivery.js';
|
|
4
|
+
export { parseProjectDeliveryRecipe, readProjectDeliveryRecipe, recipeDigest, ProjectDeliveryError, } from './delivery/recipe.js';
|
|
5
|
+
export { parseBuildPlan, buildPlanDigest } from './delivery/build-plan.js';
|
|
6
|
+
export { createRecipeBuildPlan } from './delivery/recipe-build-plan.js';
|
|
7
|
+
export { parseArtifactDescriptor, assertArtifactDescriptorDigest, artifactBytesDigest, artifactFileDescriptor, } from './delivery/artifact-descriptor.js';
|
|
8
|
+
export { ARTIFACT_LIMITS, normalizeArtifactPath, validateArtifactFiles, readArtifactDirectory, createNormalizedZip, readZipArtifact, packageChannelArtifact, describeChannelArtifact, verifyChannelArtifactDescriptor, } from './delivery/artifact-package.js';
|
|
9
|
+
export { readProductionSourceSnapshot, readProductionSourceFile, verifyProductionSourceSnapshot, productionSourcePathAllowed, productionAuxiliaryPathAllowed, ProductionSourceError, PRODUCTION_SOURCE_RULES_VERSION, SUPPORTED_PRODUCTION_SOURCE_RULES_VERSIONS } from './production-inputs.js';
|
|
10
|
+
export { readWorkspacePublicSourceClosure } from './workspace-public-source.js';
|
|
11
|
+
export { assertNoUnanchoredFrameAnimationSources } from './production-animation-presence.js';
|
|
3
12
|
export { ViteBuilder } from './vite-builder.js';
|
|
4
13
|
export { PlayableBuilder } from './playable-builder.js';
|
|
5
14
|
export { OnePageConverter } from './converter.js';
|
|
6
15
|
// 导出引擎检测器和适配器
|
|
7
|
-
export { EngineDetector, PlayCanvasAdapter, GenericAdapter, PlayableScriptsAdapter } from './engines/index.js';
|
|
16
|
+
export { EngineDetector, PlayCanvasAdapter, GenericAdapter, PlayableScriptsAdapter, } from './engines/index.js';
|
|
8
17
|
// 导出状态管理器
|
|
9
18
|
export { BuildStateManager, BUILD_STATE_VERSION } from './state/index.js';
|
|
10
19
|
export { StateToReportConverter } from './state/index.js';
|
|
11
20
|
// 导出分析器
|
|
12
21
|
export { BuildAnalyzer } from './analyzers/build-analyzer.js';
|
|
13
22
|
export { PlayableAnalyzer } from './analyzers/playable-analyzer.js';
|
|
14
|
-
export { analyzeSceneDependencies, collectScenesAssets, printSceneDependencies } from './analyzers/scene-asset-collector.js';
|
|
23
|
+
export { analyzeSceneDependencies, collectScenesAssets, printSceneDependencies, } from './analyzers/scene-asset-collector.js';
|
|
15
24
|
export { detectAmmoUsage } from './utils/ammo-detector.js';
|
|
16
25
|
// 导出平台适配器
|
|
17
26
|
export { createPlatformAdapter, PlatformAdapter } from './platforms/index.js';
|
package/dist/platforms/base.js
CHANGED
|
@@ -188,8 +188,8 @@ export class PlatformAdapter {
|
|
|
188
188
|
cachedAdsTrackingScript = minified;
|
|
189
189
|
return `<script>${minified}</script>`;
|
|
190
190
|
}
|
|
191
|
-
catch (
|
|
192
|
-
console.warn('[Tracking] 无法加载 @playcraft/ads-tracking:',
|
|
191
|
+
catch (error) {
|
|
192
|
+
console.warn('[Tracking] 无法加载 @playcraft/ads-tracking:', error instanceof Error ? error.message : error);
|
|
193
193
|
return '';
|
|
194
194
|
}
|
|
195
195
|
}
|
package/dist/platforms/bigo.js
CHANGED
package/dist/platforms/google.js
CHANGED
package/dist/platforms/inmobi.js
CHANGED
|
@@ -11,6 +11,7 @@ export class MintegralAdapter extends PlatformAdapter {
|
|
|
11
11
|
return 'html';
|
|
12
12
|
}
|
|
13
13
|
async modifyHTML(html, assets) {
|
|
14
|
+
void assets;
|
|
14
15
|
// Mintegral 要求 charset 为 utf-8,确保存在
|
|
15
16
|
if (!html.includes('charset') && html.includes('<head>')) {
|
|
16
17
|
html = html.replace('<head>', '<head>\n<meta charset="utf-8">');
|
package/dist/platforms/moloco.js
CHANGED
|
@@ -32,6 +32,7 @@ export class PlayCraftAdapter extends PlatformAdapter {
|
|
|
32
32
|
* PlayCraft 构建注入 CTA 适配器
|
|
33
33
|
*/
|
|
34
34
|
async modifyHTML(html, _assets) {
|
|
35
|
+
void _assets;
|
|
35
36
|
html = await this.injectCTAAdapterAsync(html);
|
|
36
37
|
html = await this.injectTrackingAdapterAsync(html);
|
|
37
38
|
return html;
|
|
@@ -13,6 +13,7 @@ export class RemergeAdapter extends PlatformAdapter {
|
|
|
13
13
|
return 'zip';
|
|
14
14
|
}
|
|
15
15
|
async modifyHTML(html, assets) {
|
|
16
|
+
void assets;
|
|
16
17
|
// Remerge 使用 FbPlayableAd API(与 Facebook/Moloco 相同)
|
|
17
18
|
const remergeScriptCode = `
|
|
18
19
|
window.FbPlayableAd = window.FbPlayableAd || {
|
package/dist/platforms/tiktok.js
CHANGED
package/dist/platforms/unity.js
CHANGED
|
@@ -42,6 +42,7 @@ export class UnityAdapter extends PlatformAdapter {
|
|
|
42
42
|
return 'html';
|
|
43
43
|
}
|
|
44
44
|
async modifyHTML(html, assets) {
|
|
45
|
+
void assets;
|
|
45
46
|
const unityScript = await this.minifyPlatformScript(this.getPlatformScript(), 'unity-mraid');
|
|
46
47
|
const comment = `<!-- Unity Ads: MRAID 2.0, 等待viewableChange, 使用mraid.open() -->`;
|
|
47
48
|
// 保留 charset 在文档开头,同时确保可见性门控早于首个业务脚本。
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { lstat, opendir, realpath } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const INDEX = 'frame-animation-bindings.json';
|
|
4
|
+
const MAX_DIRECTORIES = 1024;
|
|
5
|
+
const MAX_ENTRIES = 2048;
|
|
6
|
+
const HASH_DIRECTORY = /^[a-f0-9]{64}$/;
|
|
7
|
+
class AnimationPresenceError extends Error {
|
|
8
|
+
constructor(code, file) {
|
|
9
|
+
super(`${code}: ${file}`);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.file = file;
|
|
12
|
+
this.name = 'AnimationPresenceError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Missing anchors cannot turn a previously managed animation into unchecked ordinary source. */
|
|
16
|
+
export async function assertNoUnanchoredFrameAnimationSources(root) {
|
|
17
|
+
const base = await realpath(root);
|
|
18
|
+
const directories = new Map();
|
|
19
|
+
const fail = (code, path) => {
|
|
20
|
+
throw new AnimationPresenceError(code, path);
|
|
21
|
+
};
|
|
22
|
+
const optional = async (path) => {
|
|
23
|
+
try {
|
|
24
|
+
return await lstat(path);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error.code === 'ENOENT')
|
|
28
|
+
return undefined;
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const directory = async (relative) => {
|
|
33
|
+
const path = relative ? join(base, relative) : base;
|
|
34
|
+
const stat = await optional(path);
|
|
35
|
+
if (!stat)
|
|
36
|
+
return false;
|
|
37
|
+
if (stat.isSymbolicLink())
|
|
38
|
+
fail('production_animation_presence_unsafe', relative);
|
|
39
|
+
if (!stat.isDirectory())
|
|
40
|
+
return false;
|
|
41
|
+
if (directories.size >= MAX_DIRECTORIES)
|
|
42
|
+
fail('production_animation_presence_limit', relative);
|
|
43
|
+
directories.set(path, stat);
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
const marker = async (relative, maximum) => {
|
|
47
|
+
const stat = await optional(join(base, relative));
|
|
48
|
+
if (!stat)
|
|
49
|
+
return;
|
|
50
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1 || stat.size > maximum)
|
|
51
|
+
fail('production_animation_presence_unsafe', relative);
|
|
52
|
+
// File names in the content-addressed managed namespace are sufficient evidence.
|
|
53
|
+
// No project bytes are opened, imported, or granted additional authority here.
|
|
54
|
+
fail('production_animation_manifest_required', INDEX);
|
|
55
|
+
};
|
|
56
|
+
await directory('');
|
|
57
|
+
if (await directory('sources')) {
|
|
58
|
+
for (const [relative, markers] of [
|
|
59
|
+
['sources/animations', ['binding.json', 'binding.ts']],
|
|
60
|
+
['sources/playcraft-animation', ['timeline.ts', 'phaser.ts', 'three.ts', 'assets.d.ts']],
|
|
61
|
+
]) {
|
|
62
|
+
if (!(await directory(relative)))
|
|
63
|
+
continue;
|
|
64
|
+
const entries = await opendir(join(base, relative));
|
|
65
|
+
let count = 0;
|
|
66
|
+
for await (const entry of entries) {
|
|
67
|
+
if (++count > MAX_ENTRIES)
|
|
68
|
+
fail('production_animation_presence_limit', relative);
|
|
69
|
+
if (!HASH_DIRECTORY.test(entry.name))
|
|
70
|
+
continue;
|
|
71
|
+
const path = `${relative}/${entry.name}`;
|
|
72
|
+
if (!(await directory(path)))
|
|
73
|
+
continue;
|
|
74
|
+
for (const name of markers)
|
|
75
|
+
await marker(`${path}/${name}`, name === 'binding.json' ? 2 * 1024 * 1024 : 1024 * 1024);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (await directory('assets')) {
|
|
80
|
+
await marker('assets/playcraft-animation.meta', 1024 * 1024);
|
|
81
|
+
if (await directory('assets/playcraft-animation')) {
|
|
82
|
+
const entries = await opendir(join(base, 'assets/playcraft-animation'));
|
|
83
|
+
let count = 0;
|
|
84
|
+
for await (const entry of entries) {
|
|
85
|
+
if (++count > MAX_ENTRIES)
|
|
86
|
+
fail('production_animation_presence_limit', 'assets/playcraft-animation');
|
|
87
|
+
if (HASH_DIRECTORY.test(entry.name)) {
|
|
88
|
+
const path = `assets/playcraft-animation/${entry.name}`;
|
|
89
|
+
if (await directory(path))
|
|
90
|
+
await marker(`${path}/binding.ts`, 1024 * 1024);
|
|
91
|
+
}
|
|
92
|
+
else if (entry.name.endsWith('.meta') && HASH_DIRECTORY.test(entry.name.slice(0, -5))) {
|
|
93
|
+
await marker(`assets/playcraft-animation/${entry.name}`, 1024 * 1024);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (await directory('assets/playcraft-animation/runtime')) {
|
|
97
|
+
const runtimes = await opendir(join(base, 'assets/playcraft-animation/runtime'));
|
|
98
|
+
let count = 0;
|
|
99
|
+
for await (const entry of runtimes) {
|
|
100
|
+
if (++count > MAX_ENTRIES)
|
|
101
|
+
fail('production_animation_presence_limit', 'assets/playcraft-animation/runtime');
|
|
102
|
+
if (!HASH_DIRECTORY.test(entry.name))
|
|
103
|
+
continue;
|
|
104
|
+
const path = `assets/playcraft-animation/runtime/${entry.name}`;
|
|
105
|
+
if (await directory(path))
|
|
106
|
+
for (const name of ['timeline.ts', 'cocos.ts', 'timeline.ts.meta', 'cocos.ts.meta'])
|
|
107
|
+
await marker(`${path}/${name}`, 1024 * 1024);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (await directory('assets/resources')) {
|
|
112
|
+
await marker('assets/resources/playcraft-animation.meta', 1024 * 1024);
|
|
113
|
+
if (await directory('assets/resources/playcraft-animation')) {
|
|
114
|
+
const entries = await opendir(join(base, 'assets/resources/playcraft-animation'));
|
|
115
|
+
let count = 0;
|
|
116
|
+
for await (const entry of entries) {
|
|
117
|
+
if (++count > MAX_ENTRIES)
|
|
118
|
+
fail('production_animation_presence_limit', 'assets/resources/playcraft-animation');
|
|
119
|
+
if (!HASH_DIRECTORY.test(entry.name))
|
|
120
|
+
continue;
|
|
121
|
+
const path = `assets/resources/playcraft-animation/${entry.name}`;
|
|
122
|
+
if (!(await directory(path)))
|
|
123
|
+
continue;
|
|
124
|
+
const members = await opendir(join(base, path));
|
|
125
|
+
let memberCount = 0;
|
|
126
|
+
for await (const member of members) {
|
|
127
|
+
if (++memberCount > MAX_ENTRIES)
|
|
128
|
+
fail('production_animation_presence_limit', path);
|
|
129
|
+
if (/^(?:frame-\d+|atlas)\.png(?:\.meta)?$/.test(member.name))
|
|
130
|
+
await marker(`${path}/${member.name}`, 32 * 1024 * 1024);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for (const [path, before] of directories) {
|
|
137
|
+
const after = await optional(path);
|
|
138
|
+
if (!after?.isDirectory() ||
|
|
139
|
+
after.isSymbolicLink() ||
|
|
140
|
+
before.dev !== after.dev ||
|
|
141
|
+
before.ino !== after.ino ||
|
|
142
|
+
before.mtimeMs !== after.mtimeMs ||
|
|
143
|
+
before.ctimeMs !== after.ctimeMs)
|
|
144
|
+
fail('production_animation_presence_changed', INDEX);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { productionSourcePathAllowed } from './production-source-paths.js';
|
|
2
|
+
/** Legacy capability advertisement; newer builders explicitly enumerate supported rules. */
|
|
3
|
+
export declare const PRODUCTION_SOURCE_RULES_VERSION: 1;
|
|
4
|
+
export declare const SUPPORTED_PRODUCTION_SOURCE_RULES_VERSIONS: readonly [1, 2];
|
|
5
|
+
export type ProductionSourceFile = {
|
|
6
|
+
body: Buffer;
|
|
7
|
+
mode: '100644' | '100755';
|
|
8
|
+
};
|
|
9
|
+
export type ProductionSourceSnapshot = {
|
|
10
|
+
sourceRulesVersion: 1 | 2;
|
|
11
|
+
files: Map<string, ProductionSourceFile>;
|
|
12
|
+
requiredPaths: ReadonlySet<string>;
|
|
13
|
+
fingerprint: string;
|
|
14
|
+
};
|
|
15
|
+
export declare class ProductionSourceError extends Error {
|
|
16
|
+
readonly code: string;
|
|
17
|
+
readonly file?: string | undefined;
|
|
18
|
+
constructor(code: string, file?: string | undefined);
|
|
19
|
+
}
|
|
20
|
+
/** Locked engineering guidance is saved with the project, but does not masquerade as build input. */
|
|
21
|
+
export declare function productionAuxiliaryPathAllowed(value: string): boolean;
|
|
22
|
+
/** Bounded, no-link reads used for both declarations and the exact production file set. */
|
|
23
|
+
export declare function readProductionSourceFile(root: string, relative: string, maximum?: number): Promise<ProductionSourceFile>;
|
|
24
|
+
/** Undefined preserves the exact legacy fingerprint and save rules for older projects. */
|
|
25
|
+
export declare function readProductionSourceSnapshot(root: string, options?: {
|
|
26
|
+
excludedDirectories?: readonly string[];
|
|
27
|
+
excludedPath?: (path: string) => boolean;
|
|
28
|
+
}): Promise<ProductionSourceSnapshot | undefined>;
|
|
29
|
+
/** Check actual Git-tree bytes and executable bits before declaring save/freeze successful. */
|
|
30
|
+
export declare function verifyProductionSourceSnapshot(snapshot: ProductionSourceSnapshot, read: (relative: string) => Promise<ProductionSourceFile | undefined>): Promise<void>;
|