@playcraft/build 0.2.19-test-a → 0.2.20

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.
Files changed (123) hide show
  1. package/dist/base-builder.js +2 -42
  2. package/dist/engines/engine-detector.js +0 -4
  3. package/dist/engines/generic-adapter.js +19 -14
  4. package/dist/engines/playable-scripts-adapter.js +5 -2
  5. package/dist/index.d.ts +4 -21
  6. package/dist/index.js +2 -12
  7. package/dist/platforms/adikteev.js +0 -1
  8. package/dist/platforms/applovin.js +0 -1
  9. package/dist/platforms/base.d.ts +0 -4
  10. package/dist/platforms/base.js +6 -25
  11. package/dist/platforms/bigo.js +0 -1
  12. package/dist/platforms/facebook.js +0 -1
  13. package/dist/platforms/google.js +0 -1
  14. package/dist/platforms/inmobi.js +0 -1
  15. package/dist/platforms/ironsource.js +0 -1
  16. package/dist/platforms/liftoff.js +0 -1
  17. package/dist/platforms/mintegral.js +0 -1
  18. package/dist/platforms/moloco.js +0 -1
  19. package/dist/platforms/playcraft.js +0 -1
  20. package/dist/platforms/remerge.js +0 -1
  21. package/dist/platforms/snapchat.js +0 -1
  22. package/dist/platforms/tiktok.js +0 -1
  23. package/dist/platforms/unity.js +0 -1
  24. package/dist/types.d.ts +2 -12
  25. package/dist/validation/html-validator.d.ts +0 -5
  26. package/dist/validation/html-validator.js +17 -19
  27. package/dist/validation/index.d.ts +0 -5
  28. package/dist/validation/index.js +0 -5
  29. package/dist/validation/package-validator.d.ts +0 -2
  30. package/dist/validation/package-validator.js +64 -25
  31. package/dist/validation/profiles.d.ts +1 -13
  32. package/dist/validation/profiles.js +0 -27
  33. package/dist/validation/source-scanner.d.ts +0 -11
  34. package/dist/validation/source-scanner.js +2 -32
  35. package/dist/validation/types.d.ts +2 -201
  36. package/dist/validation/types.js +1 -1
  37. package/dist/validation/validation-runner.d.ts +2 -22
  38. package/dist/validation/validation-runner.js +3 -64
  39. package/dist/validation/zip-reader.d.ts +0 -7
  40. package/dist/validation/zip-reader.js +26 -159
  41. package/dist/vite/config-builder-generic.d.ts +1 -3
  42. package/dist/vite/config-builder-generic.js +7 -9
  43. package/dist/vite/config-builder.js +1 -1
  44. package/dist/vite/plugin-platform.js +30 -16
  45. package/dist/vite/plugin-source-builder.d.ts +14 -2
  46. package/dist/vite/plugin-source-builder.js +997 -61
  47. package/dist/vite-builder.d.ts +5 -4
  48. package/dist/vite-builder.js +34 -33
  49. package/package.json +4 -30
  50. package/templates/patches/one-page-mraid-resize-canvas.js +2 -0
  51. package/dist/audio-source-files.d.ts +0 -5
  52. package/dist/audio-source-files.js +0 -135
  53. package/dist/delivery/agent-build-runner.d.ts +0 -44
  54. package/dist/delivery/agent-build-runner.js +0 -365
  55. package/dist/delivery/agent-build-source.d.ts +0 -8
  56. package/dist/delivery/agent-build-source.js +0 -25
  57. package/dist/delivery/artifact-descriptor.d.ts +0 -31
  58. package/dist/delivery/artifact-descriptor.js +0 -237
  59. package/dist/delivery/artifact-package.d.ts +0 -43
  60. package/dist/delivery/artifact-package.js +0 -283
  61. package/dist/delivery/build-plan.d.ts +0 -4
  62. package/dist/delivery/build-plan.js +0 -189
  63. package/dist/delivery/build-plan.types.d.ts +0 -51
  64. package/dist/delivery/build-plan.types.js +0 -1
  65. package/dist/delivery/command-isolation.d.ts +0 -21
  66. package/dist/delivery/command-isolation.js +0 -327
  67. package/dist/delivery/commands.d.ts +0 -5
  68. package/dist/delivery/commands.js +0 -146
  69. package/dist/delivery/files.d.ts +0 -9
  70. package/dist/delivery/files.js +0 -144
  71. package/dist/delivery/git-source-fingerprint.d.ts +0 -2
  72. package/dist/delivery/git-source-fingerprint.js +0 -58
  73. package/dist/delivery/isolated-source.d.ts +0 -5
  74. package/dist/delivery/isolated-source.js +0 -148
  75. package/dist/delivery/output-publication.d.ts +0 -21
  76. package/dist/delivery/output-publication.js +0 -444
  77. package/dist/delivery/project-delivery.d.ts +0 -6
  78. package/dist/delivery/project-delivery.js +0 -287
  79. package/dist/delivery/recipe-build-plan.d.ts +0 -4
  80. package/dist/delivery/recipe-build-plan.js +0 -53
  81. package/dist/delivery/recipe.d.ts +0 -20
  82. package/dist/delivery/recipe.js +0 -211
  83. package/dist/delivery/safe-path.d.ts +0 -2
  84. package/dist/delivery/safe-path.js +0 -18
  85. package/dist/delivery/types.d.ts +0 -81
  86. package/dist/delivery/types.js +0 -1
  87. package/dist/production-animation-presence.d.ts +0 -2
  88. package/dist/production-animation-presence.js +0 -146
  89. package/dist/production-inputs.d.ts +0 -30
  90. package/dist/production-inputs.js +0 -262
  91. package/dist/production-source-paths.d.ts +0 -5
  92. package/dist/production-source-paths.js +0 -27
  93. package/dist/redirect-policy.d.ts +0 -23
  94. package/dist/redirect-policy.js +0 -25
  95. package/dist/validation/artifact-qa.d.ts +0 -36
  96. package/dist/validation/artifact-qa.js +0 -263
  97. package/dist/validation/artifact-rules.d.ts +0 -39
  98. package/dist/validation/artifact-rules.js +0 -451
  99. package/dist/validation/artifact.d.ts +0 -14
  100. package/dist/validation/artifact.js +0 -188
  101. package/dist/validation/playwright-driver.d.ts +0 -37
  102. package/dist/validation/playwright-driver.js +0 -302
  103. package/dist/validation/runtime-cover.d.ts +0 -32
  104. package/dist/validation/runtime-cover.js +0 -120
  105. package/dist/validation/runtime-load.d.ts +0 -141
  106. package/dist/validation/runtime-load.js +0 -812
  107. package/dist/vite/source-builder-asset-paths.d.ts +0 -25
  108. package/dist/vite/source-builder-asset-paths.js +0 -154
  109. package/dist/vite/source-builder-esm.d.ts +0 -7
  110. package/dist/vite/source-builder-esm.js +0 -877
  111. package/dist/vite/source-builder-types.d.ts +0 -14
  112. package/dist/vite/source-builder-types.js +0 -1
  113. package/dist/vite/workspace.d.ts +0 -6
  114. package/dist/vite/workspace.js +0 -41
  115. package/dist/workspace-css-imports.d.ts +0 -2
  116. package/dist/workspace-css-imports.js +0 -139
  117. package/dist/workspace-model-source.d.ts +0 -14
  118. package/dist/workspace-model-source.js +0 -184
  119. package/dist/workspace-public-imports.d.ts +0 -11
  120. package/dist/workspace-public-imports.js +0 -232
  121. package/dist/workspace-public-source.d.ts +0 -15
  122. package/dist/workspace-public-source.js +0 -564
  123. package/templates/patches/playcraft-redirect-policy.js +0 -115
@@ -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
- private resolvedOutputDir?;
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
  */
@@ -21,8 +21,7 @@ import { formatValidationSummary, hasBlockingValidationErrors, runPlayableValida
21
21
  * - 其他引擎:使用 GenericViteConfigBuilder(通用 HTML 内联 + 平台 SDK 注入)
22
22
  */
23
23
  export class ViteBuilder {
24
- constructor(baseBuildDir, options, workspace) {
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?.deliveryRecipeDigest
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' && !metadata?.deliveryRecipeDigest) {
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, this.workspace);
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 (buildError.id) {
72
- console.error(` - 问题文件: ${buildError.id}`);
64
+ if (error.id) {
65
+ console.error(` - 问题文件: ${error.id}`);
73
66
  }
74
- if (buildError.loc) {
75
- console.error(` - 位置: 行 ${buildError.loc.line}, 列 ${buildError.loc.column}`);
67
+ if (error.loc) {
68
+ console.error(` - 位置: 行 ${error.loc.line}, 列 ${error.loc.column}`);
76
69
  }
77
- if (buildError.frame) {
78
- console.error(` - 代码片段:\n${buildError.frame}`);
70
+ if (error.frame) {
71
+ console.error(` - 代码片段:\n${error.frame}`);
79
72
  }
80
- if (buildError.plugin) {
81
- console.error(` - 插件: ${buildError.plugin}`);
73
+ if (error.plugin) {
74
+ console.error(` - 插件: ${error.plugin}`);
82
75
  }
83
- if (buildError.pluginCode) {
84
- console.error(` - 插件错误码: ${buildError.pluginCode}`);
76
+ if (error.pluginCode) {
77
+ console.error(` - 插件错误码: ${error.pluginCode}`);
85
78
  }
86
- if (buildError.cause) {
87
- console.error(` - 原因:`, buildError.cause);
79
+ if (error.cause) {
80
+ console.error(` - 原因:`, error.cause);
88
81
  }
89
- console.error(` - 完整错误:`, buildError.stack || buildError.message || 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' && !metadata?.deliveryRecipeDigest) {
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.resolvedOutputDir ?? this.options.outputDir ?? './dist';
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.resolvedOutputDir ?? this.options.outputDir,
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((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i];
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.2.19-test-a",
3
+ "version": "0.2.20",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,16 +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
- "./qa-driver": {
30
- "types": "./dist/validation/playwright-driver.d.ts",
31
- "import": "./dist/validation/playwright-driver.js",
32
- "require": "./dist/validation/playwright-driver.js"
33
- },
34
24
  "./dist/*": "./dist/*"
35
25
  },
36
26
  "files": [
@@ -40,50 +30,34 @@
40
30
  "README.md"
41
31
  ],
42
32
  "dependencies": {
33
+ "@playcraft/ads-tracking": "^1.0.0",
43
34
  "@gltf-transform/core": "^4.3.0",
44
35
  "@gltf-transform/extensions": "^4.3.0",
45
36
  "@gltf-transform/functions": "^4.3.0",
46
- "@playcraft/ads-tracking": "^1.0.0",
47
37
  "@vheemstra/vite-plugin-imagemin": "^2.2.1",
48
38
  "archiver": "^7.0.1",
49
- "css-tree": "3.2.1",
50
39
  "draco3dgltf": "^1.5.7",
51
40
  "fflate": "^0.8.2",
52
41
  "imagemin-mozjpeg": "^10.0.0",
53
42
  "imagemin-pngquant": "^10.0.0",
54
43
  "imagemin-webp": "^8.0.0",
55
44
  "javascript-obfuscator": "^5.3.0",
56
- "json5": "^2.2.3",
57
45
  "lightningcss": "^1.31.1",
58
46
  "mime-types": "^2.1.35",
59
- "parse5": "^7.3.0",
60
47
  "rollup-plugin-visualizer": "^6.0.5",
61
48
  "sharp": "^0.34.5",
62
49
  "terser": "^5.46.0",
63
- "typescript": "^5.9.3",
64
50
  "vite": "^8.0.3",
65
- "vite-plugin-singlefile": "^2.3.2",
66
- "@playcraft/common": "0.2.19-test-a"
67
- },
68
- "peerDependencies": {
69
- "playwright-core": ">=1.52.0"
70
- },
71
- "peerDependenciesMeta": {
72
- "playwright-core": {
73
- "optional": true
74
- }
51
+ "vite-plugin-singlefile": "^2.3.2"
75
52
  },
76
53
  "devDependencies": {
77
54
  "@playcraft/ads-tracking": "^1.0.0",
78
55
  "@types/archiver": "^6.0.4",
79
- "@types/css-tree": "3.2.0",
80
56
  "@types/mime-types": "^2.1.4",
81
57
  "@types/node": "^22.19.8",
82
- "playwright-core": "1.52.0",
83
- "vitest": "^3.2.4"
58
+ "typescript": "^5.9.3"
84
59
  },
85
60
  "scripts": {
86
- "test": "vitest run",
87
61
  "lint": "pnpm -w run lint:eslint packages/build",
88
62
  "dev": "tsc -w",
89
63
  "build": "tsc",
@@ -1,4 +1,6 @@
1
1
  (function () {
2
+ if (typeof pc === 'undefined' || !pc || !pc.Application || !pc.Application.prototype) return;
3
+
2
4
  pc.Application.prototype.resizeCanvas = function (width, height) {
3
5
  if (!this._allowResize) return; // prevent resizing (e.g. if presenting in VR HMD)
4
6
 
@@ -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';