@playcraft/build 0.1.96-test-a → 0.1.98
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/base-builder.js +2 -41
- package/dist/engines/engine-detector.js +0 -4
- package/dist/engines/generic-adapter.js +19 -14
- package/dist/index.d.ts +4 -19
- package/dist/index.js +2 -11
- package/dist/platforms/adikteev.js +0 -1
- package/dist/platforms/applovin.js +0 -1
- package/dist/platforms/base.js +2 -2
- package/dist/platforms/bigo.js +0 -1
- package/dist/platforms/facebook.js +0 -1
- package/dist/platforms/google.js +0 -1
- package/dist/platforms/inmobi.js +0 -1
- package/dist/platforms/ironsource.js +0 -1
- package/dist/platforms/liftoff.js +0 -1
- package/dist/platforms/mintegral.js +0 -1
- package/dist/platforms/moloco.js +0 -1
- package/dist/platforms/playcraft.js +0 -1
- package/dist/platforms/remerge.js +0 -1
- package/dist/platforms/snapchat.js +0 -1
- package/dist/platforms/tiktok.js +0 -1
- package/dist/platforms/unity.js +0 -1
- package/dist/types.d.ts +0 -5
- package/dist/validation/html-validator.d.ts +0 -5
- package/dist/validation/html-validator.js +17 -19
- package/dist/validation/index.d.ts +0 -4
- package/dist/validation/index.js +0 -4
- package/dist/validation/package-validator.d.ts +0 -2
- package/dist/validation/package-validator.js +64 -25
- package/dist/validation/profiles.d.ts +1 -13
- package/dist/validation/profiles.js +0 -27
- package/dist/validation/source-scanner.d.ts +0 -11
- package/dist/validation/source-scanner.js +2 -32
- package/dist/validation/types.d.ts +2 -178
- package/dist/validation/types.js +1 -1
- package/dist/validation/validation-runner.d.ts +2 -22
- package/dist/validation/validation-runner.js +3 -64
- package/dist/validation/zip-reader.d.ts +0 -7
- package/dist/validation/zip-reader.js +26 -159
- package/dist/vite/config-builder-generic.d.ts +1 -3
- package/dist/vite/config-builder-generic.js +7 -9
- package/dist/vite/config-builder.js +1 -1
- package/dist/vite/plugin-platform.js +54 -30
- package/dist/vite/plugin-source-builder.d.ts +14 -2
- package/dist/vite/plugin-source-builder.js +997 -61
- package/dist/vite-builder.d.ts +5 -4
- package/dist/vite-builder.js +34 -33
- package/package.json +4 -16
- package/dist/audio-source-files.d.ts +0 -5
- package/dist/audio-source-files.js +0 -135
- package/dist/delivery/agent-build-runner.d.ts +0 -44
- package/dist/delivery/agent-build-runner.js +0 -365
- package/dist/delivery/agent-build-source.d.ts +0 -8
- package/dist/delivery/agent-build-source.js +0 -25
- package/dist/delivery/artifact-descriptor.d.ts +0 -31
- package/dist/delivery/artifact-descriptor.js +0 -237
- package/dist/delivery/artifact-package.d.ts +0 -43
- package/dist/delivery/artifact-package.js +0 -283
- package/dist/delivery/build-plan.d.ts +0 -4
- package/dist/delivery/build-plan.js +0 -189
- package/dist/delivery/build-plan.types.d.ts +0 -51
- package/dist/delivery/build-plan.types.js +0 -1
- package/dist/delivery/command-isolation.d.ts +0 -21
- package/dist/delivery/command-isolation.js +0 -327
- package/dist/delivery/commands.d.ts +0 -5
- package/dist/delivery/commands.js +0 -146
- package/dist/delivery/files.d.ts +0 -9
- package/dist/delivery/files.js +0 -144
- package/dist/delivery/git-source-fingerprint.d.ts +0 -2
- package/dist/delivery/git-source-fingerprint.js +0 -58
- package/dist/delivery/isolated-source.d.ts +0 -5
- package/dist/delivery/isolated-source.js +0 -131
- package/dist/delivery/output-publication.d.ts +0 -21
- package/dist/delivery/output-publication.js +0 -444
- package/dist/delivery/project-delivery.d.ts +0 -6
- package/dist/delivery/project-delivery.js +0 -287
- package/dist/delivery/recipe-build-plan.d.ts +0 -4
- package/dist/delivery/recipe-build-plan.js +0 -53
- package/dist/delivery/recipe.d.ts +0 -20
- package/dist/delivery/recipe.js +0 -211
- package/dist/delivery/safe-path.d.ts +0 -2
- package/dist/delivery/safe-path.js +0 -18
- package/dist/delivery/types.d.ts +0 -76
- package/dist/delivery/types.js +0 -1
- package/dist/production-animation-presence.d.ts +0 -2
- package/dist/production-animation-presence.js +0 -146
- package/dist/production-inputs.d.ts +0 -30
- package/dist/production-inputs.js +0 -262
- package/dist/production-source-paths.d.ts +0 -5
- package/dist/production-source-paths.js +0 -27
- package/dist/validation/artifact-qa.d.ts +0 -36
- package/dist/validation/artifact-qa.js +0 -261
- package/dist/validation/artifact-rules.d.ts +0 -39
- package/dist/validation/artifact-rules.js +0 -451
- package/dist/validation/artifact.d.ts +0 -14
- package/dist/validation/artifact.js +0 -188
- package/dist/validation/runtime-load.d.ts +0 -94
- package/dist/validation/runtime-load.js +0 -653
- package/dist/vite/source-builder-asset-paths.d.ts +0 -25
- package/dist/vite/source-builder-asset-paths.js +0 -154
- package/dist/vite/source-builder-esm.d.ts +0 -7
- package/dist/vite/source-builder-esm.js +0 -877
- package/dist/vite/source-builder-types.d.ts +0 -14
- package/dist/vite/source-builder-types.js +0 -1
- package/dist/vite/workspace.d.ts +0 -6
- package/dist/vite/workspace.js +0 -41
- package/dist/workspace-css-imports.d.ts +0 -2
- package/dist/workspace-css-imports.js +0 -139
- package/dist/workspace-model-source.d.ts +0 -14
- package/dist/workspace-model-source.js +0 -184
- package/dist/workspace-public-imports.d.ts +0 -11
- package/dist/workspace-public-imports.js +0 -232
- package/dist/workspace-public-source.d.ts +0 -15
- package/dist/workspace-public-source.js +0 -564
package/dist/vite-builder.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BuildOptions, SizeReport } from './types.js';
|
|
2
|
-
import type { ViteWorkspace } from './vite/workspace.js';
|
|
3
2
|
export interface ViteBuildOutput {
|
|
4
3
|
outputPath: string;
|
|
5
4
|
size: number;
|
|
@@ -22,13 +21,11 @@ export interface ViteBuildOutput {
|
|
|
22
21
|
* - 其他引擎:使用 GenericViteConfigBuilder(通用 HTML 内联 + 平台 SDK 注入)
|
|
23
22
|
*/
|
|
24
23
|
export declare class ViteBuilder {
|
|
25
|
-
private workspace?;
|
|
26
24
|
private baseBuildDir;
|
|
27
25
|
private options;
|
|
28
26
|
private sizeReport;
|
|
29
27
|
private engine;
|
|
30
|
-
|
|
31
|
-
constructor(baseBuildDir: string, options: BuildOptions, workspace?: ViteWorkspace | undefined);
|
|
28
|
+
constructor(baseBuildDir: string, options: BuildOptions);
|
|
32
29
|
/**
|
|
33
30
|
* 执行构建
|
|
34
31
|
*/
|
|
@@ -74,6 +71,10 @@ export declare class ViteBuilder {
|
|
|
74
71
|
* 计算 Base Build 目录的总大小
|
|
75
72
|
*/
|
|
76
73
|
private calculateBaseBuildSize;
|
|
74
|
+
/**
|
|
75
|
+
* 生成报告
|
|
76
|
+
*/
|
|
77
|
+
private generateReport;
|
|
77
78
|
/**
|
|
78
79
|
* 获取大小报告
|
|
79
80
|
*/
|
package/dist/vite-builder.js
CHANGED
|
@@ -21,8 +21,7 @@ import { formatValidationSummary, hasBlockingValidationErrors, runPlayableValida
|
|
|
21
21
|
* - 其他引擎:使用 GenericViteConfigBuilder(通用 HTML 内联 + 平台 SDK 注入)
|
|
22
22
|
*/
|
|
23
23
|
export class ViteBuilder {
|
|
24
|
-
constructor(baseBuildDir, options
|
|
25
|
-
this.workspace = workspace;
|
|
24
|
+
constructor(baseBuildDir, options) {
|
|
26
25
|
this.engine = 'playcanvas';
|
|
27
26
|
this.baseBuildDir = baseBuildDir;
|
|
28
27
|
this.options = options;
|
|
@@ -40,24 +39,19 @@ export class ViteBuilder {
|
|
|
40
39
|
async build() {
|
|
41
40
|
// 1. 读取构建元数据获取引擎类型
|
|
42
41
|
const metadata = await this.readBuildMetadata();
|
|
43
|
-
this.engine = metadata?.
|
|
44
|
-
? 'generic'
|
|
45
|
-
: (this.options.engine ?? metadata?.engine ?? 'playcanvas');
|
|
42
|
+
this.engine = this.options.engine ?? metadata?.engine ?? 'playcanvas';
|
|
46
43
|
console.log(`[ViteBuilder] 使用引擎: ${this.engine}`);
|
|
47
44
|
// 2. 验证输入
|
|
48
45
|
await this.validateBaseBuild(metadata);
|
|
49
46
|
// 3. 根据引擎类型创建对应的配置构建器
|
|
50
47
|
let configBuilder;
|
|
51
|
-
if (this.engine === 'playcanvas'
|
|
52
|
-
if (this.workspace) {
|
|
53
|
-
throw new Error('The legacy PlayCanvas packager does not support isolated Vite workspaces');
|
|
54
|
-
}
|
|
48
|
+
if (this.engine === 'playcanvas') {
|
|
55
49
|
console.log('[ViteBuilder] 使用 PlayCanvas 配置构建器');
|
|
56
50
|
configBuilder = new ViteConfigBuilder(this.baseBuildDir, this.options.platform, this.options);
|
|
57
51
|
}
|
|
58
52
|
else {
|
|
59
53
|
console.log('[ViteBuilder] 使用通用配置构建器(外部引擎)');
|
|
60
|
-
configBuilder = new GenericViteConfigBuilder(this.baseBuildDir, this.options.platform, this.options, metadata
|
|
54
|
+
configBuilder = new GenericViteConfigBuilder(this.baseBuildDir, this.options.platform, this.options, metadata);
|
|
61
55
|
}
|
|
62
56
|
const viteConfig = await configBuilder.create();
|
|
63
57
|
// 4. 执行 Vite 构建
|
|
@@ -65,34 +59,32 @@ export class ViteBuilder {
|
|
|
65
59
|
await viteBuild(viteConfig);
|
|
66
60
|
}
|
|
67
61
|
catch (error) {
|
|
68
|
-
const buildError = error;
|
|
69
62
|
// 打印完整的 Vite/Rollup 错误信息,便于定位构建失败原因
|
|
70
63
|
console.error('[ViteBuilder] Vite 构建失败:');
|
|
71
|
-
if (
|
|
72
|
-
console.error(` - 问题文件: ${
|
|
64
|
+
if (error.id) {
|
|
65
|
+
console.error(` - 问题文件: ${error.id}`);
|
|
73
66
|
}
|
|
74
|
-
if (
|
|
75
|
-
console.error(` - 位置: 行 ${
|
|
67
|
+
if (error.loc) {
|
|
68
|
+
console.error(` - 位置: 行 ${error.loc.line}, 列 ${error.loc.column}`);
|
|
76
69
|
}
|
|
77
|
-
if (
|
|
78
|
-
console.error(` - 代码片段:\n${
|
|
70
|
+
if (error.frame) {
|
|
71
|
+
console.error(` - 代码片段:\n${error.frame}`);
|
|
79
72
|
}
|
|
80
|
-
if (
|
|
81
|
-
console.error(` - 插件: ${
|
|
73
|
+
if (error.plugin) {
|
|
74
|
+
console.error(` - 插件: ${error.plugin}`);
|
|
82
75
|
}
|
|
83
|
-
if (
|
|
84
|
-
console.error(` - 插件错误码: ${
|
|
76
|
+
if (error.pluginCode) {
|
|
77
|
+
console.error(` - 插件错误码: ${error.pluginCode}`);
|
|
85
78
|
}
|
|
86
|
-
if (
|
|
87
|
-
console.error(` - 原因:`,
|
|
79
|
+
if (error.cause) {
|
|
80
|
+
console.error(` - 原因:`, error.cause);
|
|
88
81
|
}
|
|
89
|
-
console.error(` - 完整错误:`,
|
|
82
|
+
console.error(` - 完整错误:`, error.stack || error.message || error);
|
|
90
83
|
throw error;
|
|
91
84
|
}
|
|
92
85
|
// 5. 将输出从临时目录复制到最终目录
|
|
93
86
|
const viteOutputDir = configBuilder.getViteOutputDir();
|
|
94
87
|
const finalOutputDir = configBuilder.getFinalOutputDir();
|
|
95
|
-
this.resolvedOutputDir = finalOutputDir || undefined;
|
|
96
88
|
if (viteOutputDir && finalOutputDir && viteOutputDir !== finalOutputDir) {
|
|
97
89
|
await this.copyOutputToFinalDir(viteOutputDir, finalOutputDir);
|
|
98
90
|
}
|
|
@@ -100,6 +92,8 @@ export class ViteBuilder {
|
|
|
100
92
|
const outputPath = this.getOutputPath();
|
|
101
93
|
await this.validateSize(outputPath);
|
|
102
94
|
await this.runComplianceValidation(outputPath, metadata);
|
|
95
|
+
// 7. 生成报告
|
|
96
|
+
this.generateReport(outputPath);
|
|
103
97
|
return outputPath;
|
|
104
98
|
}
|
|
105
99
|
/**
|
|
@@ -113,7 +107,7 @@ export class ViteBuilder {
|
|
|
113
107
|
console.log(`[ViteBuilder] 读取构建元数据: engine=${metadata.engine}, mode=${metadata.mode}`);
|
|
114
108
|
return metadata;
|
|
115
109
|
}
|
|
116
|
-
catch {
|
|
110
|
+
catch (error) {
|
|
117
111
|
console.warn('[ViteBuilder] 无法读取构建元数据,假设为 PlayCanvas');
|
|
118
112
|
return null;
|
|
119
113
|
}
|
|
@@ -124,7 +118,7 @@ export class ViteBuilder {
|
|
|
124
118
|
*/
|
|
125
119
|
async validateBaseBuild(metadata) {
|
|
126
120
|
const engine = this.options.engine ?? metadata?.engine ?? 'playcanvas';
|
|
127
|
-
if (engine === 'playcanvas'
|
|
121
|
+
if (engine === 'playcanvas') {
|
|
128
122
|
await this.validatePlayCanvasBuild();
|
|
129
123
|
}
|
|
130
124
|
else {
|
|
@@ -260,7 +254,7 @@ export class ViteBuilder {
|
|
|
260
254
|
*/
|
|
261
255
|
getOutputPath() {
|
|
262
256
|
const platformConfig = PLATFORM_CONFIGS[this.options.platform];
|
|
263
|
-
const outputDir = this.
|
|
257
|
+
const outputDir = this.options.outputDir || './dist';
|
|
264
258
|
// 使用用户指定的格式,如果没有则使用平台默认格式
|
|
265
259
|
const outputFormat = this.options.format || platformConfig.outputFormat;
|
|
266
260
|
if (outputFormat === 'zip') {
|
|
@@ -301,7 +295,7 @@ export class ViteBuilder {
|
|
|
301
295
|
console.warn(`⚠️ ============================================================\n`);
|
|
302
296
|
}
|
|
303
297
|
}
|
|
304
|
-
catch {
|
|
298
|
+
catch (error) {
|
|
305
299
|
console.warn(`警告: 无法读取输出文件: ${outputPath}`);
|
|
306
300
|
}
|
|
307
301
|
}
|
|
@@ -342,6 +336,13 @@ export class ViteBuilder {
|
|
|
342
336
|
}
|
|
343
337
|
return totalSize;
|
|
344
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* 生成报告
|
|
341
|
+
*/
|
|
342
|
+
generateReport(outputPath) {
|
|
343
|
+
// 报告已在 validateSize 中生成
|
|
344
|
+
// 这里可以添加额外的报告逻辑
|
|
345
|
+
}
|
|
345
346
|
/**
|
|
346
347
|
* 获取大小报告
|
|
347
348
|
*/
|
|
@@ -360,8 +361,8 @@ export class ViteBuilder {
|
|
|
360
361
|
return;
|
|
361
362
|
}
|
|
362
363
|
const isZip = outputPath.toLowerCase().endsWith('.zip');
|
|
363
|
-
const stages = validationOptions?.stages
|
|
364
|
-
(isZip ? ['delivery-package'] : ['html-artifact']);
|
|
364
|
+
const stages = validationOptions?.stages
|
|
365
|
+
?? (isZip ? ['delivery-package'] : ['html-artifact']);
|
|
365
366
|
const report = await runPlayableValidation({
|
|
366
367
|
projectRoot: this.baseBuildDir,
|
|
367
368
|
channel: this.options.platform,
|
|
@@ -374,7 +375,7 @@ export class ViteBuilder {
|
|
|
374
375
|
: 'generic',
|
|
375
376
|
htmlPath: isZip ? undefined : outputPath,
|
|
376
377
|
packagePath: isZip ? outputPath : undefined,
|
|
377
|
-
outputDir: this.
|
|
378
|
+
outputDir: this.options.outputDir,
|
|
378
379
|
sourceGlobs: validationOptions?.sourceGlobs,
|
|
379
380
|
metadata: metadata ? { ...metadata } : undefined,
|
|
380
381
|
}, stages);
|
|
@@ -398,6 +399,6 @@ export class ViteBuilder {
|
|
|
398
399
|
const k = 1024;
|
|
399
400
|
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
400
401
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
401
|
-
return Math.round(
|
|
402
|
+
return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i];
|
|
402
403
|
}
|
|
403
404
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcraft/build",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.98",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,11 +21,6 @@
|
|
|
21
21
|
"require": "./dist/analyzers/scene-asset-collector.js",
|
|
22
22
|
"types": "./dist/analyzers/scene-asset-collector.d.ts"
|
|
23
23
|
},
|
|
24
|
-
"./agent-runner": {
|
|
25
|
-
"import": "./dist/delivery/agent-build-runner.js",
|
|
26
|
-
"require": "./dist/delivery/agent-build-runner.js",
|
|
27
|
-
"types": "./dist/delivery/agent-build-runner.d.ts"
|
|
28
|
-
},
|
|
29
24
|
"./dist/*": "./dist/*"
|
|
30
25
|
},
|
|
31
26
|
"files": [
|
|
@@ -35,41 +30,34 @@
|
|
|
35
30
|
"README.md"
|
|
36
31
|
],
|
|
37
32
|
"dependencies": {
|
|
33
|
+
"@playcraft/ads-tracking": "^1.0.0",
|
|
38
34
|
"@gltf-transform/core": "^4.3.0",
|
|
39
35
|
"@gltf-transform/extensions": "^4.3.0",
|
|
40
36
|
"@gltf-transform/functions": "^4.3.0",
|
|
41
|
-
"@playcraft/ads-tracking": "^1.0.0",
|
|
42
37
|
"@vheemstra/vite-plugin-imagemin": "^2.2.1",
|
|
43
38
|
"archiver": "^7.0.1",
|
|
44
|
-
"css-tree": "3.2.1",
|
|
45
39
|
"draco3dgltf": "^1.5.7",
|
|
46
40
|
"fflate": "^0.8.2",
|
|
47
41
|
"imagemin-mozjpeg": "^10.0.0",
|
|
48
42
|
"imagemin-pngquant": "^10.0.0",
|
|
49
43
|
"imagemin-webp": "^8.0.0",
|
|
50
44
|
"javascript-obfuscator": "^5.3.0",
|
|
51
|
-
"json5": "^2.2.3",
|
|
52
45
|
"lightningcss": "^1.31.1",
|
|
53
46
|
"mime-types": "^2.1.35",
|
|
54
|
-
"parse5": "^7.3.0",
|
|
55
47
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
56
48
|
"sharp": "^0.34.5",
|
|
57
49
|
"terser": "^5.46.0",
|
|
58
|
-
"typescript": "^5.9.3",
|
|
59
50
|
"vite": "^8.0.3",
|
|
60
|
-
"vite-plugin-singlefile": "^2.3.2"
|
|
61
|
-
"@playcraft/common": "0.1.96-test-a"
|
|
51
|
+
"vite-plugin-singlefile": "^2.3.2"
|
|
62
52
|
},
|
|
63
53
|
"devDependencies": {
|
|
64
54
|
"@playcraft/ads-tracking": "^1.0.0",
|
|
65
55
|
"@types/archiver": "^6.0.4",
|
|
66
|
-
"@types/css-tree": "3.2.0",
|
|
67
56
|
"@types/mime-types": "^2.1.4",
|
|
68
57
|
"@types/node": "^22.19.8",
|
|
69
|
-
"
|
|
58
|
+
"typescript": "^5.9.3"
|
|
70
59
|
},
|
|
71
60
|
"scripts": {
|
|
72
|
-
"test": "vitest run",
|
|
73
61
|
"lint": "pnpm -w run lint:eslint packages/build",
|
|
74
62
|
"dev": "tsc -w",
|
|
75
63
|
"build": "tsc",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ProductionSourceFile } from './production-inputs.js';
|
|
2
|
-
/** This only permits reads by the package inspector; a path alone never selects a file. */
|
|
3
|
-
export declare const productionImmutableAudioPath: (value: string) => boolean;
|
|
4
|
-
/** Keep the legacy sound/program closures, including unbound immutable packages. */
|
|
5
|
-
export declare function readProductionAudioFiles(root: string, read: (path: string, maximum: number) => Promise<ProductionSourceFile>): Promise<Map<string, ProductionSourceFile>>;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { lstat, readdir } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { inspectAudioArtifactPackage } from '@playcraft/common/cloud-workspace/runtime';
|
|
4
|
-
import { inspectAudioProgramPackage, audioPackageRendererScript, audioProgramGameRuntime, audioProgramPrerenderRuntime, } from '@playcraft/common/audio-package-node';
|
|
5
|
-
const HASH = /^[a-f0-9]{64}$/;
|
|
6
|
-
// Legacy sound and program inputs each permit 64 MiB and 256 packages.
|
|
7
|
-
const MAXIMUM_BYTES = 128 * 1024 * 1024;
|
|
8
|
-
const MAXIMUM_PACKAGES = 512;
|
|
9
|
-
const MAXIMUM_ENTRIES = 8192;
|
|
10
|
-
const SOUND_MEMBER = '(?:manifest\\.json|sound\\.(?:pcaudio\\.json|pcscore\\.json|mjs)|runtime\\.mjs|audition\\.wav)';
|
|
11
|
-
const PROGRAM_MEMBER = '(?:manifest\\.json|program\\.pcaudioprogram\\.json|program\\.mjs|prerender\\.mjs)';
|
|
12
|
-
const H = '[a-f0-9]{64}';
|
|
13
|
-
const IMMUTABLE_AUDIO = new RegExp(`^dist/audio/(?:${H}/${H}/${H}/${SOUND_MEMBER}|programs/${H}/${H}/${H}/${PROGRAM_MEMBER}|shared/${H}/(?:runtime\\.mjs|state\\.wav))$`);
|
|
14
|
-
/** This only permits reads by the package inspector; a path alone never selects a file. */
|
|
15
|
-
export const productionImmutableAudioPath = (value) => IMMUTABLE_AUDIO.test(value) ||
|
|
16
|
-
// Existing programs also reference imported PCM samples below hashed audio
|
|
17
|
-
// paths. The inspector proves the full dependency closure and WAV bytes;
|
|
18
|
-
// the caller separately rejects private paths before allowing this read.
|
|
19
|
-
(/^dist\/audio\/[a-zA-Z0-9._/-]+$/.test(value) && value.split('/').some((part) => HASH.test(part)));
|
|
20
|
-
function invalid(code = 'production_audio_package_invalid') {
|
|
21
|
-
throw Object.assign(new Error(code), { code });
|
|
22
|
-
}
|
|
23
|
-
/** Keep the legacy sound/program closures, including unbound immutable packages. */
|
|
24
|
-
export async function readProductionAudioFiles(root, read) {
|
|
25
|
-
const result = new Map();
|
|
26
|
-
let entries = 0, packages = 0, total = 0;
|
|
27
|
-
const add = (name, file) => {
|
|
28
|
-
const previous = result.get(name);
|
|
29
|
-
if (previous && (previous.mode !== file.mode || !previous.body.equals(file.body)))
|
|
30
|
-
invalid('production_audio_input_changed');
|
|
31
|
-
if (!previous) {
|
|
32
|
-
total += file.body.length;
|
|
33
|
-
if (total > MAXIMUM_BYTES)
|
|
34
|
-
invalid('production_audio_input_limit');
|
|
35
|
-
result.set(name, file);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const directory = async (relative) => {
|
|
39
|
-
let current = root;
|
|
40
|
-
for (const part of relative.split('/')) {
|
|
41
|
-
current = path.join(current, part);
|
|
42
|
-
const entry = await lstat(current).catch((error) => {
|
|
43
|
-
if (error.code === 'ENOENT')
|
|
44
|
-
return undefined;
|
|
45
|
-
throw error;
|
|
46
|
-
});
|
|
47
|
-
if (!entry)
|
|
48
|
-
return false;
|
|
49
|
-
if (!entry.isDirectory() || entry.isSymbolicLink())
|
|
50
|
-
invalid('production_audio_path_unsafe');
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
};
|
|
54
|
-
const candidates = [];
|
|
55
|
-
const visit = async (prefix, depth, program) => {
|
|
56
|
-
if (!(await directory(prefix)))
|
|
57
|
-
return;
|
|
58
|
-
const members = await readdir(path.join(root, prefix), { withFileTypes: true });
|
|
59
|
-
entries += members.length;
|
|
60
|
-
if (entries > MAXIMUM_ENTRIES)
|
|
61
|
-
invalid('production_audio_input_limit');
|
|
62
|
-
if (depth === 3) {
|
|
63
|
-
const names = program ? ['manifest.json'] : ['sound.pcaudio.json', 'sound.pcscore.json'];
|
|
64
|
-
for (const name of names) {
|
|
65
|
-
const entry = members.find((member) => member.name === name);
|
|
66
|
-
if (!entry)
|
|
67
|
-
continue;
|
|
68
|
-
if (++packages > MAXIMUM_PACKAGES)
|
|
69
|
-
invalid('production_audio_input_limit');
|
|
70
|
-
if (program && (!entry.isFile() || entry.isSymbolicLink()))
|
|
71
|
-
invalid();
|
|
72
|
-
candidates.push({ path: `${prefix}/${name}`, program });
|
|
73
|
-
}
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
for (const entry of members.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
77
|
-
if (!HASH.test(entry.name))
|
|
78
|
-
continue;
|
|
79
|
-
if (!entry.isDirectory() || entry.isSymbolicLink()) {
|
|
80
|
-
if (program)
|
|
81
|
-
invalid();
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
await visit(`${prefix}/${entry.name}`, depth + 1, program);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
await visit('dist/audio', 0, false);
|
|
88
|
-
await visit('dist/audio/programs', 0, true);
|
|
89
|
-
const engines = {
|
|
90
|
-
soundRuntime: audioPackageRendererScript,
|
|
91
|
-
gameRuntime: audioProgramGameRuntime,
|
|
92
|
-
prerenderRuntime: audioProgramPrerenderRuntime,
|
|
93
|
-
};
|
|
94
|
-
for (const candidate of candidates) {
|
|
95
|
-
const members = new Map();
|
|
96
|
-
const bytes = async (name, maximum) => {
|
|
97
|
-
const file = members.get(name) ?? await read(name, maximum);
|
|
98
|
-
if (file.body.length > maximum)
|
|
99
|
-
invalid();
|
|
100
|
-
members.set(name, file);
|
|
101
|
-
return file.body;
|
|
102
|
-
};
|
|
103
|
-
let sourcePath;
|
|
104
|
-
if (candidate.program) {
|
|
105
|
-
const bundle = await inspectAudioProgramPackage(candidate.path, bytes, engines);
|
|
106
|
-
sourcePath = bundle.sourcePath;
|
|
107
|
-
// Only the verified manifest/dependency closure is eligible. Do not promote
|
|
108
|
-
// unrelated files merely because they neighbor a valid immutable package.
|
|
109
|
-
for (const name of bundle.files.keys())
|
|
110
|
-
add(name, members.get(name));
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
let bundle;
|
|
114
|
-
try {
|
|
115
|
-
bundle = await inspectAudioArtifactPackage(candidate.path, bytes);
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
continue;
|
|
119
|
-
} // Existing unbound invalid sound candidates are ignored.
|
|
120
|
-
sourcePath = bundle.sourcePath;
|
|
121
|
-
for (const [name, file] of members)
|
|
122
|
-
add(name, file);
|
|
123
|
-
}
|
|
124
|
-
// Editable source may have a newer revision or be absent; immutable package
|
|
125
|
-
// bytes remain selected. Other read failures, including private paths, fail.
|
|
126
|
-
const source = await read(sourcePath, 65536).catch((error) => {
|
|
127
|
-
if (error.code === 'ENOENT')
|
|
128
|
-
return undefined;
|
|
129
|
-
throw error;
|
|
130
|
-
});
|
|
131
|
-
if (source)
|
|
132
|
-
add(sourcePath, source);
|
|
133
|
-
}
|
|
134
|
-
return result;
|
|
135
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { BuildPlan } from './build-plan.types.js';
|
|
2
|
-
import type { ArtifactDescriptor } from './artifact-descriptor.js';
|
|
3
|
-
export declare const AGENT_BUILD_RUNNER_VERSION = "agent-build-runner-v1";
|
|
4
|
-
export type AgentBuildRunnerRequest = {
|
|
5
|
-
version: 1;
|
|
6
|
-
operationId: string;
|
|
7
|
-
requestId: string;
|
|
8
|
-
inputHash: string;
|
|
9
|
-
bindingHash: string;
|
|
10
|
-
buildId: string;
|
|
11
|
-
attempt: number;
|
|
12
|
-
phase: 'plan' | 'build';
|
|
13
|
-
projectRoot: string;
|
|
14
|
-
attemptRoot: string;
|
|
15
|
-
channel: 'applovin' | 'google';
|
|
16
|
-
format: 'html' | 'zip';
|
|
17
|
-
commitHash: string;
|
|
18
|
-
recipeDigest: string;
|
|
19
|
-
fingerprint: string;
|
|
20
|
-
plan?: BuildPlan;
|
|
21
|
-
environmentDigest?: string;
|
|
22
|
-
};
|
|
23
|
-
export type AgentBuildRunnerSuccess = {
|
|
24
|
-
outcome: 'settled';
|
|
25
|
-
status: 'success';
|
|
26
|
-
fingerprint: string;
|
|
27
|
-
phase: 'plan' | 'build';
|
|
28
|
-
plan?: BuildPlan;
|
|
29
|
-
environmentDigest?: string;
|
|
30
|
-
descriptor?: ArtifactDescriptor;
|
|
31
|
-
artifactName?: string;
|
|
32
|
-
};
|
|
33
|
-
export declare class AgentBuildRunnerError extends Error {
|
|
34
|
-
readonly code: string;
|
|
35
|
-
readonly stage: string;
|
|
36
|
-
readonly retryable: boolean;
|
|
37
|
-
constructor(code: string, stage: string, message: string, retryable?: boolean);
|
|
38
|
-
}
|
|
39
|
-
export declare function runAgentBuildRunner(request: AgentBuildRunnerRequest): Promise<AgentBuildRunnerSuccess>;
|
|
40
|
-
export { parseBuildPlan } from './build-plan.js';
|
|
41
|
-
export { parseArtifactDescriptor } from './artifact-descriptor.js';
|
|
42
|
-
export { verifyChannelArtifactDescriptor } from './artifact-package.js';
|
|
43
|
-
export type { BuildPlan } from './build-plan.types.js';
|
|
44
|
-
export type { ArtifactDescriptor } from './artifact-descriptor.js';
|