@playcraft/build 0.1.91 → 0.1.93-test
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 -155
- package/dist/validation/types.js +1 -1
- package/dist/validation/validation-runner.d.ts +2 -22
- package/dist/validation/validation-runner.js +3 -68
- 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 -7
- package/dist/delivery/command-isolation.js +0 -252
- package/dist/delivery/commands.d.ts +0 -5
- package/dist/delivery/commands.js +0 -137
- 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 -126
- 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 -44
- package/dist/validation/artifact-qa.js +0 -170
- package/dist/validation/artifact-rules.d.ts +0 -28
- package/dist/validation/artifact-rules.js +0 -440
- package/dist/validation/artifact.d.ts +0 -14
- package/dist/validation/artifact.js +0 -188
- package/dist/validation/runtime-load.d.ts +0 -89
- package/dist/validation/runtime-load.js +0 -654
- 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/delivery/types.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/delivery/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,146 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
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>;
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { constants } from 'node:fs';
|
|
4
|
-
import { lstat, open, readdir, realpath } from 'node:fs/promises';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import { promisify } from 'node:util';
|
|
7
|
-
import { PRODUCTION_INPUTS_MANIFEST_PATH, workspaceProductionInputsManifestSchema, computeProductionInputClosureHash, workspaceAudioBindingSchema, inspectAudioArtifactPackage, FRAME_ANIMATION_BINDINGS_PATH, frameAnimationBindingsSchema, inspectFrameAnimationBindings, assertUniqueJsonKeys, } from '@playcraft/common/cloud-workspace/runtime';
|
|
8
|
-
import { productionImmutableAudioPath, readProductionAudioFiles } from './audio-source-files.js';
|
|
9
|
-
import { hasWorkspacePublicSourceDeclaration, readWorkspacePublicSourceClosure } from './workspace-public-source.js';
|
|
10
|
-
import { PUBLIC_METADATA, productionSourcePathAllowed, sourcePathAllowed, materializedPathAllowed } from './production-source-paths.js';
|
|
11
|
-
import { assertNoUnanchoredFrameAnimationSources } from './production-animation-presence.js';
|
|
12
|
-
export { productionSourcePathAllowed } from './production-source-paths.js';
|
|
13
|
-
/** Legacy capability advertisement; newer builders explicitly enumerate supported rules. */
|
|
14
|
-
export const PRODUCTION_SOURCE_RULES_VERSION = 1;
|
|
15
|
-
export const SUPPORTED_PRODUCTION_SOURCE_RULES_VERSIONS = [1, 2];
|
|
16
|
-
export class ProductionSourceError extends Error {
|
|
17
|
-
constructor(code, file) {
|
|
18
|
-
super(file ? `${code}: ${file}` : code);
|
|
19
|
-
this.code = code;
|
|
20
|
-
this.file = file;
|
|
21
|
-
this.name = 'ProductionSourceError';
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const execute = promisify(execFile);
|
|
25
|
-
const digest = (body) => createHash('sha256').update(body).digest('hex');
|
|
26
|
-
const AUXILIARY_METADATA = new Set(['.playcraft/skills.json', '.playcraft/skills.lock.json', '.playcraft/remix-references.json']);
|
|
27
|
-
/** Locked engineering guidance is saved with the project, but does not masquerade as build input. */
|
|
28
|
-
export function productionAuxiliaryPathAllowed(value) {
|
|
29
|
-
if (AUXILIARY_METADATA.has(value) || /^\.playcraft\/skill-artifacts\/[a-f0-9]{64}\.tar\.gz$/.test(value))
|
|
30
|
-
return true;
|
|
31
|
-
return value.startsWith('.agents/skills/') && productionSourcePathAllowed(value.slice('.agents/'.length));
|
|
32
|
-
}
|
|
33
|
-
/** Bounded, no-link reads used for both declarations and the exact production file set. */
|
|
34
|
-
export async function readProductionSourceFile(root, relative, maximum = 64 * 1024 * 1024) {
|
|
35
|
-
return readSourceFile(root, relative, maximum, false);
|
|
36
|
-
}
|
|
37
|
-
async function readSourceFile(root, relative, maximum, immutableAudio, selectedMember = false) {
|
|
38
|
-
if (!productionSourcePathAllowed(relative) && !(immutableAudio && sourcePathAllowed(relative, true) && productionImmutableAudioPath(relative)) && !(selectedMember && materializedPathAllowed(relative)))
|
|
39
|
-
throw new ProductionSourceError('production_input_path_forbidden', relative);
|
|
40
|
-
let current = root;
|
|
41
|
-
const parts = relative.split('/');
|
|
42
|
-
for (let index = 0; index < parts.length; index++) {
|
|
43
|
-
current = path.join(current, parts[index]);
|
|
44
|
-
const stat = await lstat(current);
|
|
45
|
-
if (stat.isSymbolicLink() || (index < parts.length - 1 ? !stat.isDirectory() : !stat.isFile() || stat.nlink !== 1 || stat.size > maximum))
|
|
46
|
-
throw new ProductionSourceError('production_input_path_unsafe', relative);
|
|
47
|
-
}
|
|
48
|
-
const file = await open(current, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
49
|
-
try {
|
|
50
|
-
const before = await file.stat();
|
|
51
|
-
if (!before.isFile() || before.nlink !== 1 || before.size > maximum)
|
|
52
|
-
throw new ProductionSourceError('production_input_path_unsafe', relative);
|
|
53
|
-
const body = await file.readFile(), after = await file.stat(), named = await lstat(current);
|
|
54
|
-
if (body.length !== before.size || before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size ||
|
|
55
|
-
before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs || named.ino !== after.ino || named.dev !== after.dev)
|
|
56
|
-
throw new ProductionSourceError('production_input_changed', relative);
|
|
57
|
-
return { body, mode: before.mode & 0o111 ? '100755' : '100644' };
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
await file.close();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async function boundAudioFiles(root) {
|
|
64
|
-
const files = new Map();
|
|
65
|
-
for (const name of ['source', 'source/audio-bindings']) {
|
|
66
|
-
const entry = await lstat(path.join(root, name)).catch((error) => {
|
|
67
|
-
if (error.code === 'ENOENT')
|
|
68
|
-
return undefined;
|
|
69
|
-
throw error;
|
|
70
|
-
});
|
|
71
|
-
if (!entry || (name === 'source' && entry.isFile()))
|
|
72
|
-
return files;
|
|
73
|
-
if (!entry.isDirectory() || entry.isSymbolicLink())
|
|
74
|
-
throw new ProductionSourceError('production_input_path_unsafe', name);
|
|
75
|
-
}
|
|
76
|
-
const entries = await readdir(path.join(root, 'source/audio-bindings'), { withFileTypes: true });
|
|
77
|
-
if (entries.length > 1024)
|
|
78
|
-
throw new ProductionSourceError('production_input_limit');
|
|
79
|
-
for (const entry of entries) {
|
|
80
|
-
if (!entry.name.endsWith('.json'))
|
|
81
|
-
continue;
|
|
82
|
-
const bindingPath = `source/audio-bindings/${entry.name}`;
|
|
83
|
-
const file = await readProductionSourceFile(root, bindingPath, 16384);
|
|
84
|
-
const binding = workspaceAudioBindingSchema.parse(JSON.parse(file.body.toString('utf8')));
|
|
85
|
-
const directory = `dist/audio/${digest(binding.sourcePath)}/${binding.sourceContentHash}/${binding.representationSetHash}`;
|
|
86
|
-
if (bindingPath !== `source/audio-bindings/${binding.eventName}.json` || binding.modulePath !== `${directory}/sound.mjs`)
|
|
87
|
-
throw new ProductionSourceError('production_audio_binding_invalid', bindingPath);
|
|
88
|
-
files.set(bindingPath, file);
|
|
89
|
-
files.set(binding.sourcePath, await readProductionSourceFile(root, binding.sourcePath));
|
|
90
|
-
const bundle = await inspectAudioArtifactPackage(`${directory}/sound.${binding.sourcePath.endsWith('.pcscore.json') ? 'pcscore' : 'pcaudio'}.json`, async (name, maximum) => {
|
|
91
|
-
const member = await readSourceFile(root, name, maximum, true);
|
|
92
|
-
files.set(name, member);
|
|
93
|
-
return member.body;
|
|
94
|
-
});
|
|
95
|
-
if (bundle.sourcePath !== binding.sourcePath || bundle.sourceContentHash !== binding.sourceContentHash ||
|
|
96
|
-
digest(files.get(`${directory}/audition.wav`).body) !== binding.auditionContentHash)
|
|
97
|
-
throw new ProductionSourceError('production_audio_binding_invalid', bindingPath);
|
|
98
|
-
}
|
|
99
|
-
return files;
|
|
100
|
-
}
|
|
101
|
-
async function sourcePaths(root) {
|
|
102
|
-
const marker = await lstat(path.join(root, '.git')).catch(() => undefined);
|
|
103
|
-
if (marker) {
|
|
104
|
-
const { stdout } = await execute('git', ['-c', 'core.hooksPath=/dev/null', '-c', 'core.fsmonitor=false', '-C', root,
|
|
105
|
-
'ls-files', '--cached', '--others', '--exclude-standard', '-z'], { timeout: 60000, maxBuffer: 16 * 1024 * 1024,
|
|
106
|
-
env: { PATH: process.env.PATH, HOME: root, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', GIT_OPTIONAL_LOCKS: '0', GIT_TERMINAL_PROMPT: '0' } });
|
|
107
|
-
return stdout.split('\0').filter(Boolean);
|
|
108
|
-
}
|
|
109
|
-
const paths = [];
|
|
110
|
-
async function visit(prefix = '') {
|
|
111
|
-
for (const entry of await readdir(path.join(root, prefix), { withFileTypes: true })) {
|
|
112
|
-
const name = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
113
|
-
if (!productionSourcePathAllowed(name) &&
|
|
114
|
-
!(entry.isDirectory() && [...PUBLIC_METADATA].some(file => file.startsWith(`${name}/`))))
|
|
115
|
-
continue;
|
|
116
|
-
if (entry.isDirectory())
|
|
117
|
-
await visit(name);
|
|
118
|
-
else
|
|
119
|
-
paths.push(name);
|
|
120
|
-
if (paths.length > 8192)
|
|
121
|
-
throw new ProductionSourceError('production_input_limit');
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
await visit();
|
|
125
|
-
return paths;
|
|
126
|
-
}
|
|
127
|
-
/** Undefined preserves the exact legacy fingerprint and save rules for older projects. */
|
|
128
|
-
export async function readProductionSourceSnapshot(root, options = {}) {
|
|
129
|
-
root = await realpath(root);
|
|
130
|
-
let declaration;
|
|
131
|
-
try {
|
|
132
|
-
declaration = await readProductionSourceFile(root, PRODUCTION_INPUTS_MANIFEST_PATH, 2 * 1024 * 1024);
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
if (error.code === 'ENOENT') {
|
|
136
|
-
await assertNoUnanchoredFrameAnimationSources(root);
|
|
137
|
-
return undefined;
|
|
138
|
-
}
|
|
139
|
-
throw error;
|
|
140
|
-
}
|
|
141
|
-
let manifest;
|
|
142
|
-
try {
|
|
143
|
-
manifest = workspaceProductionInputsManifestSchema.parse(JSON.parse(declaration.body.toString('utf8')));
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
throw new ProductionSourceError('production_inputs_manifest_invalid', PRODUCTION_INPUTS_MANIFEST_PATH);
|
|
147
|
-
}
|
|
148
|
-
if (manifest.schemaVersion !== 3) {
|
|
149
|
-
try {
|
|
150
|
-
if (await hasWorkspacePublicSourceDeclaration(root))
|
|
151
|
-
throw new ProductionSourceError('production_public_workspace_upgrade_required', '.playcraft/workspace.json');
|
|
152
|
-
}
|
|
153
|
-
catch (error) {
|
|
154
|
-
if (error instanceof ProductionSourceError)
|
|
155
|
-
throw error;
|
|
156
|
-
throw new ProductionSourceError('production_public_workspace_invalid', '.playcraft/workspace.json');
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const required = new Map();
|
|
160
|
-
for (const input of manifest.inputs) {
|
|
161
|
-
const { closureHash, ...body } = input;
|
|
162
|
-
if (computeProductionInputClosureHash(body) !== closureHash)
|
|
163
|
-
throw new ProductionSourceError('production_input_closure_changed');
|
|
164
|
-
for (const file of input.files) {
|
|
165
|
-
if (!materializedPathAllowed(file.path))
|
|
166
|
-
throw new ProductionSourceError('production_input_path_forbidden', file.path);
|
|
167
|
-
const previous = required.get(file.path);
|
|
168
|
-
if (previous && JSON.stringify(previous) !== JSON.stringify({ contentHash: file.contentHash, bytes: file.bytes, mode: file.mode }))
|
|
169
|
-
throw new ProductionSourceError('production_input_conflict', file.path);
|
|
170
|
-
required.set(file.path, { contentHash: file.contentHash, bytes: file.bytes, mode: file.mode });
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
const animationFiles = new Map();
|
|
174
|
-
const animationIndex = await readProductionSourceFile(root, FRAME_ANIMATION_BINDINGS_PATH, 2 * 1024 * 1024).catch((error) => {
|
|
175
|
-
if (error.code === 'ENOENT')
|
|
176
|
-
return undefined;
|
|
177
|
-
throw error;
|
|
178
|
-
});
|
|
179
|
-
const animationAnchor = manifest.schemaVersion === 1 ? undefined : manifest.animationBindings;
|
|
180
|
-
if (!animationAnchor)
|
|
181
|
-
await assertNoUnanchoredFrameAnimationSources(root);
|
|
182
|
-
if (animationAnchor && (!animationIndex || digest(animationIndex.body) !== animationAnchor.contentHash))
|
|
183
|
-
throw new ProductionSourceError('production_animation_index_changed', FRAME_ANIMATION_BINDINGS_PATH);
|
|
184
|
-
if (animationIndex) {
|
|
185
|
-
if (!animationAnchor)
|
|
186
|
-
throw new ProductionSourceError('production_animation_manifest_required', PRODUCTION_INPUTS_MANIFEST_PATH);
|
|
187
|
-
assertUniqueJsonKeys(animationIndex.body.toString('utf8'));
|
|
188
|
-
const index = frameAnimationBindingsSchema.parse(JSON.parse(animationIndex.body.toString('utf8')));
|
|
189
|
-
const closure = await inspectFrameAnimationBindings(index, manifest, async (name, maximum) => {
|
|
190
|
-
const file = await readProductionSourceFile(root, name, maximum);
|
|
191
|
-
return { bytes: file.body, mode: file.mode };
|
|
192
|
-
});
|
|
193
|
-
animationFiles.set(FRAME_ANIMATION_BINDINGS_PATH, animationIndex);
|
|
194
|
-
for (const [name, file] of closure)
|
|
195
|
-
animationFiles.set(name, { body: Buffer.from(file.bytes), mode: file.mode });
|
|
196
|
-
for (const [name, file] of animationFiles)
|
|
197
|
-
required.set(name, { contentHash: digest(file.body), bytes: file.body.length, mode: file.mode });
|
|
198
|
-
}
|
|
199
|
-
const audio = await readProductionAudioFiles(root, (name, maximum) => readSourceFile(root, name, maximum, true));
|
|
200
|
-
for (const [name, file] of await boundAudioFiles(root)) {
|
|
201
|
-
const previous = audio.get(name);
|
|
202
|
-
if (previous && (previous.mode !== file.mode || !previous.body.equals(file.body)))
|
|
203
|
-
throw new ProductionSourceError('production_input_changed', name);
|
|
204
|
-
audio.set(name, file);
|
|
205
|
-
}
|
|
206
|
-
for (const [name, file] of audio)
|
|
207
|
-
required.set(name, { contentHash: digest(file.body), bytes: file.body.length, mode: file.mode });
|
|
208
|
-
const publicFiles = manifest.schemaVersion === 3
|
|
209
|
-
? (await readWorkspacePublicSourceClosure(root)).files
|
|
210
|
-
: new Map();
|
|
211
|
-
for (const [name, file] of publicFiles) {
|
|
212
|
-
const previous = animationFiles.get(name) ?? audio.get(name);
|
|
213
|
-
if (previous && (previous.mode !== file.mode || !previous.body.equals(file.body)))
|
|
214
|
-
throw new ProductionSourceError('production_input_conflict', name);
|
|
215
|
-
const immutable = required.get(name);
|
|
216
|
-
const current = { contentHash: digest(file.body), bytes: file.body.length, mode: file.mode };
|
|
217
|
-
if (immutable && JSON.stringify(immutable) !== JSON.stringify(current))
|
|
218
|
-
throw new ProductionSourceError('production_input_conflict', name);
|
|
219
|
-
required.set(name, current);
|
|
220
|
-
}
|
|
221
|
-
const excluded = options.excludedDirectories ?? [];
|
|
222
|
-
const excludedPath = (name) => options.excludedPath?.(name) || excluded.some(prefix => name === prefix || name.startsWith(`${prefix}/`));
|
|
223
|
-
for (const name of required.keys())
|
|
224
|
-
if (excludedPath(name))
|
|
225
|
-
throw new ProductionSourceError('production_input_is_generated', name);
|
|
226
|
-
const candidates = new Set([...(await sourcePaths(root)), PRODUCTION_INPUTS_MANIFEST_PATH, ...required.keys()]);
|
|
227
|
-
const files = new Map();
|
|
228
|
-
let total = 0;
|
|
229
|
-
for (const name of [...candidates].sort()) {
|
|
230
|
-
if ((!productionSourcePathAllowed(name) && !audio.has(name) && !publicFiles.has(name) && !(required.has(name) && materializedPathAllowed(name))) || excludedPath(name))
|
|
231
|
-
continue;
|
|
232
|
-
let file;
|
|
233
|
-
try {
|
|
234
|
-
file = name === PRODUCTION_INPUTS_MANIFEST_PATH ? declaration : publicFiles.get(name) ?? animationFiles.get(name) ?? audio.get(name) ?? await readSourceFile(root, name, 64 * 1024 * 1024, false, required.has(name));
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
if (!required.has(name) && error.code === 'ENOENT')
|
|
238
|
-
continue;
|
|
239
|
-
throw error;
|
|
240
|
-
}
|
|
241
|
-
const expected = required.get(name);
|
|
242
|
-
if (expected && (expected.contentHash !== digest(file.body) || expected.bytes !== file.body.length || expected.mode !== file.mode))
|
|
243
|
-
throw new ProductionSourceError('production_input_changed', name);
|
|
244
|
-
total += file.body.length;
|
|
245
|
-
if (files.size >= 8192 || total > 256 * 1024 * 1024)
|
|
246
|
-
throw new ProductionSourceError('production_input_limit');
|
|
247
|
-
files.set(name, file);
|
|
248
|
-
}
|
|
249
|
-
const sourceRulesVersion = manifest.schemaVersion === 3 ? 2 : 1;
|
|
250
|
-
const hash = createHash('sha256').update(`playcraft-production-source-v${sourceRulesVersion}\0`);
|
|
251
|
-
for (const [name, file] of files)
|
|
252
|
-
hash.update(name).update('\0').update(file.mode).update('\0').update(file.body).update('\0');
|
|
253
|
-
return { sourceRulesVersion, files, requiredPaths: new Set([PRODUCTION_INPUTS_MANIFEST_PATH, ...required.keys()]), fingerprint: hash.digest('hex') };
|
|
254
|
-
}
|
|
255
|
-
/** Check actual Git-tree bytes and executable bits before declaring save/freeze successful. */
|
|
256
|
-
export async function verifyProductionSourceSnapshot(snapshot, read) {
|
|
257
|
-
for (const [name, expected] of snapshot.files) {
|
|
258
|
-
const actual = await read(name);
|
|
259
|
-
if (!actual || actual.mode !== expected.mode || !actual.body.equals(expected.body))
|
|
260
|
-
throw new ProductionSourceError('production_input_not_committed', name);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const PUBLIC_METADATA: Set<string>;
|
|
2
|
-
/** Credentials and process paths are never promoted merely because a declaration names them. */
|
|
3
|
-
export declare function productionSourcePathAllowed(value: string): boolean;
|
|
4
|
-
export declare function materializedPathAllowed(value: string): boolean;
|
|
5
|
-
export declare function sourcePathAllowed(value: string, selectedMember: boolean): boolean;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { workspaceProductionInputPathSchema } from '@playcraft/common/cloud-workspace/runtime';
|
|
2
|
-
const PRIVATE_NAMES = new Set([
|
|
3
|
-
'.git', 'node_modules', '.ssh', '.aws', '.azure', '.gnupg', '.codex', '.npm', '.pnpm-store',
|
|
4
|
-
'.config', '.npmrc', '.yarnrc', '.yarnrc.yml', '.netrc', '.git-credentials', 'credentials',
|
|
5
|
-
'credentials.json', 'secrets', 'id_rsa', 'id_ed25519', 'settings.local.json',
|
|
6
|
-
'.playcraft.json', 'playcraft.config.json', '.agents', '.claude',
|
|
7
|
-
]);
|
|
8
|
-
const PROCESS_NAMES = new Set(['work', '.tmp', '.temp', '.cache', '.next', '.vite', '.turbo',
|
|
9
|
-
'coverage', '.playcraft-temp', '.playcraft-preview-out', 'dist', 'dist-all', '.ds_store', 'thumbs.db', '.eslintcache', '.parcel-cache']);
|
|
10
|
-
export const PUBLIC_METADATA = new Set(['.playcraft/model-build-inputs.json']);
|
|
11
|
-
/** Credentials and process paths are never promoted merely because a declaration names them. */
|
|
12
|
-
export function productionSourcePathAllowed(value) {
|
|
13
|
-
return sourcePathAllowed(value, false);
|
|
14
|
-
}
|
|
15
|
-
export function materializedPathAllowed(value) {
|
|
16
|
-
return workspaceProductionInputPathSchema.safeParse(value).success && sourcePathAllowed(value, true);
|
|
17
|
-
}
|
|
18
|
-
export function sourcePathAllowed(value, selectedMember) {
|
|
19
|
-
if (!value || value.includes('\\') || value.includes('\0') || value.startsWith('/') || value.includes(':') ||
|
|
20
|
-
value.split('/').some(segment => !segment || segment === '.' || segment === '..'))
|
|
21
|
-
return false;
|
|
22
|
-
const parts = value.split('/');
|
|
23
|
-
if (parts.some(segment => PRIVATE_NAMES.has(segment.toLowerCase()) || (!selectedMember && PROCESS_NAMES.has(segment.toLowerCase())) ||
|
|
24
|
-
/^\.env(?:$|\.)/i.test(segment) || /\.(?:pem|key|p12|pfx)$/i.test(segment)))
|
|
25
|
-
return false;
|
|
26
|
-
return !parts.some(segment => segment.toLowerCase() === '.playcraft') || PUBLIC_METADATA.has(value);
|
|
27
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { Platform } from '../types.js';
|
|
2
|
-
import { type RuntimeLoadOptions } from './runtime-load.js';
|
|
3
|
-
import { type ArtifactQaReport, type BrowserDriver, type PlayableArtifact, type QaStageId, type QaStageReport } from './types.js';
|
|
4
|
-
export declare const ARTIFACT_QA_REPORT_VERSION = "0.2.0";
|
|
5
|
-
/** Bump when an artifact rule, its severity or its matching changes. */
|
|
6
|
-
export declare const ARTIFACT_QA_RULES_VERSION = "2026-11-10.1";
|
|
7
|
-
export interface RunArtifactQaOptions {
|
|
8
|
-
/** Rules to judge by: `playcraft` (default) checks the playable itself; a channel adds its rules. */
|
|
9
|
-
profile?: Platform;
|
|
10
|
-
/** Stages to run, in this order; default all of `QA_STAGES`. */
|
|
11
|
-
stages?: QaStageId[];
|
|
12
|
-
/** Size limit of the profile, e.g. from the channel's platform adapter (`base` stage). */
|
|
13
|
-
sizeLimitBytes?: number;
|
|
14
|
-
/** Project source root (`source-hints` stage). */
|
|
15
|
-
projectRoot?: string;
|
|
16
|
-
sourceGlobs?: string[];
|
|
17
|
-
/** Headless browser (`runtime-load` stage); without it the stage is reported as skipped. */
|
|
18
|
-
driver?: BrowserDriver;
|
|
19
|
-
/** Why no driver was provided, e.g. Chromium is missing; becomes the runtime-load skip reason. */
|
|
20
|
-
driverUnavailableReason?: string;
|
|
21
|
-
runtime?: Pick<RuntimeLoadOptions, 'viewports' | 'settleMs' | 'timeoutMs'>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Judges a built artifact by running each requested stage independently and collecting their
|
|
25
|
-
* reports. Stages never read each other's results, so any stage can also be called on its own.
|
|
26
|
-
* Results depend only on the artifact and the options, never on how the artifact was built.
|
|
27
|
-
*/
|
|
28
|
-
export declare function runArtifactQa(artifact: PlayableArtifact, options?: RunArtifactQaOptions): Promise<ArtifactQaReport>;
|
|
29
|
-
/**
|
|
30
|
-
* `channel` stage: the channel's existing `html-artifact` / `delivery-package` rules, the same
|
|
31
|
-
* rules export validation uses. Needs only the artifact and a channel profile.
|
|
32
|
-
*/
|
|
33
|
-
export declare function runChannelStage(artifact: PlayableArtifact, options: {
|
|
34
|
-
profile: Platform;
|
|
35
|
-
}): Promise<QaStageReport>;
|
|
36
|
-
/**
|
|
37
|
-
* `source-hints` stage: scans project source to help locate problems. Advisory: it never affects
|
|
38
|
-
* the overall result. Needs only the project root.
|
|
39
|
-
*/
|
|
40
|
-
export declare function runSourceHintsStage(options: {
|
|
41
|
-
projectRoot: string;
|
|
42
|
-
profile?: Platform;
|
|
43
|
-
sourceGlobs?: string[];
|
|
44
|
-
}): Promise<QaStageReport>;
|