@playcraft/build 0.2.13 → 0.2.15-test-a
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 +21 -0
- package/dist/delivery/command-isolation.js +327 -0
- package/dist/delivery/commands.d.ts +5 -0
- package/dist/delivery/commands.js +146 -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 +131 -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/engines/playable-scripts-adapter.js +2 -5
- package/dist/index.d.ts +21 -4
- package/dist/index.js +12 -2
- package/dist/platforms/adikteev.js +1 -0
- package/dist/platforms/applovin.js +1 -0
- package/dist/platforms/base.d.ts +4 -0
- package/dist/platforms/base.js +25 -6
- 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/redirect-policy.d.ts +23 -0
- package/dist/redirect-policy.js +25 -0
- package/dist/types.d.ts +10 -2
- package/dist/validation/artifact-qa.d.ts +36 -0
- package/dist/validation/artifact-qa.js +263 -0
- package/dist/validation/artifact-rules.d.ts +39 -0
- package/dist/validation/artifact-rules.js +451 -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 +5 -0
- package/dist/validation/index.js +5 -0
- package/dist/validation/package-validator.d.ts +2 -0
- package/dist/validation/package-validator.js +25 -64
- package/dist/validation/playwright-driver.d.ts +37 -0
- package/dist/validation/playwright-driver.js +302 -0
- package/dist/validation/profiles.d.ts +13 -1
- package/dist/validation/profiles.js +27 -0
- package/dist/validation/runtime-cover.d.ts +32 -0
- package/dist/validation/runtime-cover.js +120 -0
- package/dist/validation/runtime-load.d.ts +141 -0
- package/dist/validation/runtime-load.js +812 -0
- package/dist/validation/source-scanner.d.ts +11 -0
- package/dist/validation/source-scanner.js +32 -2
- package/dist/validation/types.d.ts +201 -2
- package/dist/validation/types.js +1 -1
- package/dist/validation/validation-runner.d.ts +22 -2
- package/dist/validation/validation-runner.js +64 -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 +16 -30
- 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 +30 -4
- package/templates/patches/playcraft-redirect-policy.js +115 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { parse } from 'parse5';
|
|
3
|
+
import { workspaceCssResourceSpecifiers } from './workspace-css-imports.js';
|
|
4
|
+
import JSON5 from 'json5';
|
|
5
|
+
export class WorkspacePublicSourceError extends Error {
|
|
6
|
+
constructor(code, file) {
|
|
7
|
+
super(file ? `${code}:${file}` : code);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.file = file;
|
|
10
|
+
this.name = 'WorkspacePublicSourceError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function unsupported(path) {
|
|
14
|
+
throw new WorkspacePublicSourceError('workspace_public_dependency_unsupported', path);
|
|
15
|
+
}
|
|
16
|
+
function scriptDependencies(path, text) {
|
|
17
|
+
const file = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true, /\.tsx$/i.test(path) ? ts.ScriptKind.TSX : /\.jsx$/i.test(path) ? ts.ScriptKind.JSX : /\.[cm]?ts$/i.test(path) ? ts.ScriptKind.TS : ts.ScriptKind.JS);
|
|
18
|
+
if (file.parseDiagnostics.length)
|
|
19
|
+
unsupported(path);
|
|
20
|
+
const result = [];
|
|
21
|
+
for (const reference of file.referencedFiles) {
|
|
22
|
+
if (/^(?:\/|[a-z][a-z\d+.-]*:)/i.test(reference.fileName) || reference.fileName.includes('\\'))
|
|
23
|
+
unsupported(path);
|
|
24
|
+
result.push({ specifier: reference.fileName.startsWith('.') ? reference.fileName : './' + reference.fileName, kind: 'module' });
|
|
25
|
+
}
|
|
26
|
+
for (const reference of file.typeReferenceDirectives)
|
|
27
|
+
result.push({ specifier: reference.fileName, kind: 'types' });
|
|
28
|
+
// Compiler-provided lib files require a toolchain contract, not a project file lookup.
|
|
29
|
+
if (file.libReferenceDirectives.length)
|
|
30
|
+
unsupported(path);
|
|
31
|
+
const literal = (node) => node && (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) ? node.text : undefined;
|
|
32
|
+
const add = (node, kind = 'module') => {
|
|
33
|
+
const specifier = literal(node);
|
|
34
|
+
if (specifier === undefined)
|
|
35
|
+
unsupported(path);
|
|
36
|
+
result.push({ specifier, kind });
|
|
37
|
+
};
|
|
38
|
+
const isImportMeta = (node) => ts.isMetaProperty(node) && node.keywordToken === ts.SyntaxKind.ImportKeyword;
|
|
39
|
+
const visit = (node) => {
|
|
40
|
+
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier)
|
|
41
|
+
add(node.moduleSpecifier);
|
|
42
|
+
else if (ts.isImportTypeNode(node) && ts.isLiteralTypeNode(node.argument))
|
|
43
|
+
add(node.argument.literal);
|
|
44
|
+
else if (ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference))
|
|
45
|
+
add(node.moduleReference.expression);
|
|
46
|
+
else if (ts.isCallExpression(node)) {
|
|
47
|
+
if (node.expression.kind === ts.SyntaxKind.ImportKeyword || ts.isIdentifier(node.expression) && node.expression.text === 'require') {
|
|
48
|
+
if (node.arguments.length !== 1 && node.expression.kind !== ts.SyntaxKind.ImportKeyword)
|
|
49
|
+
unsupported(path);
|
|
50
|
+
add(node.arguments[0]);
|
|
51
|
+
}
|
|
52
|
+
else if (ts.isPropertyAccessExpression(node.expression)) {
|
|
53
|
+
if (isImportMeta(node.expression.expression) && ['glob', 'globEager'].includes(node.expression.name.text))
|
|
54
|
+
unsupported(path);
|
|
55
|
+
if (ts.isIdentifier(node.expression.expression) && node.expression.expression.text === 'require' && node.expression.name.text === 'resolve')
|
|
56
|
+
add(node.arguments[0]);
|
|
57
|
+
}
|
|
58
|
+
if (ts.isIdentifier(node.expression) && node.expression.text === 'fetch') {
|
|
59
|
+
const value = literal(node.arguments[0]);
|
|
60
|
+
if (value && /^(?:\.{0,2}\/|[^:?#]+\.[a-z0-9]+(?:[?#]|$))/i.test(value))
|
|
61
|
+
result.push({ specifier: value, kind: 'resource' });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (ts.isNewExpression(node) && ts.isIdentifier(node.expression)) {
|
|
65
|
+
if (node.expression.text === 'URL' && node.arguments?.[1] && ts.isPropertyAccessExpression(node.arguments[1]) &&
|
|
66
|
+
isImportMeta(node.arguments[1].expression) && node.arguments[1].name.text === 'url') {
|
|
67
|
+
const directoryLocator = ['.', './'].includes(literal(node.arguments[0]) ?? '') && ts.isCallExpression(node.parent) &&
|
|
68
|
+
ts.isIdentifier(node.parent.expression) && node.parent.expression.text === 'fileURLToPath' && node.parent.arguments[0] === node;
|
|
69
|
+
if (!directoryLocator)
|
|
70
|
+
add(node.arguments[0], 'resource');
|
|
71
|
+
}
|
|
72
|
+
if (['Worker', 'SharedWorker'].includes(node.expression.text)) {
|
|
73
|
+
const value = node.arguments?.[0];
|
|
74
|
+
if (value && ts.isNewExpression(value) && ts.isIdentifier(value.expression) && value.expression.text === 'URL') {
|
|
75
|
+
// The nested URL expression is inspected independently.
|
|
76
|
+
}
|
|
77
|
+
else
|
|
78
|
+
add(value);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
ts.forEachChild(node, visit);
|
|
82
|
+
};
|
|
83
|
+
visit(file);
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
function cssDependencies(path, text) {
|
|
87
|
+
try {
|
|
88
|
+
return workspaceCssResourceSpecifiers(text, () => unsupported(path))
|
|
89
|
+
.map(specifier => ({ specifier, kind: 'resource' }));
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return unsupported(path);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function htmlDependencies(path, text) {
|
|
96
|
+
const result = [];
|
|
97
|
+
const visit = (node) => {
|
|
98
|
+
if ('tagName' in node) {
|
|
99
|
+
const attrs = new Map(node.attrs.map(item => [item.name, item.value]));
|
|
100
|
+
if (node.tagName === 'base' && attrs.has('href'))
|
|
101
|
+
unsupported(path);
|
|
102
|
+
const add = (attribute, kind = 'resource') => {
|
|
103
|
+
const specifier = attrs.get(attribute);
|
|
104
|
+
if (specifier)
|
|
105
|
+
result.push({ specifier, kind });
|
|
106
|
+
};
|
|
107
|
+
if (node.tagName === 'script') {
|
|
108
|
+
if (attrs.has('src'))
|
|
109
|
+
add('src', 'module');
|
|
110
|
+
else {
|
|
111
|
+
const type = attrs.get('type') ?? 'text/javascript';
|
|
112
|
+
if (['module', 'text/javascript', 'application/javascript'].includes(type))
|
|
113
|
+
result.push(...scriptDependencies(path + '.js', node.childNodes.filter(child => 'value' in child).map(child => 'value' in child ? child.value : '').join('')));
|
|
114
|
+
else if (type === 'importmap')
|
|
115
|
+
unsupported(path);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (node.tagName === 'link' && /(?:stylesheet|icon|preload|modulepreload)/.test(attrs.get('rel') ?? ''))
|
|
119
|
+
add('href');
|
|
120
|
+
if (['img', 'source', 'audio', 'video', 'track', 'iframe', 'embed', 'input'].includes(node.tagName))
|
|
121
|
+
add('src');
|
|
122
|
+
if (node.tagName === 'video')
|
|
123
|
+
add('poster');
|
|
124
|
+
if (node.tagName === 'object')
|
|
125
|
+
add('data');
|
|
126
|
+
if (['image', 'use'].includes(node.tagName)) {
|
|
127
|
+
add('href');
|
|
128
|
+
add('xlink:href');
|
|
129
|
+
}
|
|
130
|
+
if (attrs.has('srcset')) {
|
|
131
|
+
if (attrs.get('srcset').includes('data:'))
|
|
132
|
+
unsupported(path);
|
|
133
|
+
for (const candidate of attrs.get('srcset').split(',')) {
|
|
134
|
+
const specifier = candidate.trim().split(/\s+/)[0];
|
|
135
|
+
if (specifier)
|
|
136
|
+
result.push({ specifier, kind: 'resource' });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (attrs.has('style'))
|
|
140
|
+
result.push(...cssDependencies(path, `x{${attrs.get('style')}}`));
|
|
141
|
+
if (node.tagName === 'style')
|
|
142
|
+
result.push(...cssDependencies(path, node.childNodes.filter(child => 'value' in child).map(child => 'value' in child ? child.value : '').join('')));
|
|
143
|
+
if (node.tagName === 'template')
|
|
144
|
+
visit(node.content);
|
|
145
|
+
}
|
|
146
|
+
if ('childNodes' in node)
|
|
147
|
+
node.childNodes.forEach(visit);
|
|
148
|
+
};
|
|
149
|
+
visit(parse(text));
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
function jsonDependencies(path, text) {
|
|
153
|
+
let value;
|
|
154
|
+
try {
|
|
155
|
+
value = JSON5.parse(text);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return unsupported(path);
|
|
159
|
+
}
|
|
160
|
+
const result = [];
|
|
161
|
+
const visit = (node, depth = 0) => {
|
|
162
|
+
if (depth > 128)
|
|
163
|
+
unsupported(path);
|
|
164
|
+
if (Array.isArray(node)) {
|
|
165
|
+
node.forEach(item => visit(item, depth + 1));
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!node || typeof node !== 'object')
|
|
169
|
+
return;
|
|
170
|
+
for (const [key, item] of Object.entries(node)) {
|
|
171
|
+
if (key === '$ref' || key === '$schema') {
|
|
172
|
+
if (typeof item !== 'string')
|
|
173
|
+
unsupported(path);
|
|
174
|
+
if (key === '$schema' && /^https?:\/\/(?:json-schema\.org|www\.json-schema\.org)\/(?:draft-0[467]\/schema|draft\/20(?:19-09|20-12)\/schema)#?$/.test(item))
|
|
175
|
+
continue;
|
|
176
|
+
if (/^[a-z][a-z\d+.-]*:/i.test(item) || item.startsWith('//'))
|
|
177
|
+
unsupported(path);
|
|
178
|
+
if (!item.startsWith('#'))
|
|
179
|
+
result.push({ specifier: item, kind: 'resource' });
|
|
180
|
+
}
|
|
181
|
+
else
|
|
182
|
+
visit(item, depth + 1);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
visit(value);
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
function modelDependencies(path, body) {
|
|
189
|
+
let bytes = body;
|
|
190
|
+
if (/\.glb$/i.test(path)) {
|
|
191
|
+
if (body.length < 20 || body.readUInt32LE(0) !== 0x46546c67 || body.readUInt32LE(4) !== 2 || body.readUInt32LE(8) !== body.length || body.readUInt32LE(16) !== 0x4e4f534a)
|
|
192
|
+
return unsupported(path);
|
|
193
|
+
const size = body.readUInt32LE(12);
|
|
194
|
+
if (size < 2 || size > 8 * 1024 * 1024 || size + 20 > body.length)
|
|
195
|
+
return unsupported(path);
|
|
196
|
+
bytes = body.subarray(20, 20 + size);
|
|
197
|
+
}
|
|
198
|
+
let value;
|
|
199
|
+
try {
|
|
200
|
+
value = JSON.parse(bytes.toString('utf8').replace(/\0+$/, ''));
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
return unsupported(path);
|
|
204
|
+
}
|
|
205
|
+
if (!value || value.asset?.version !== '2.0' || value.images !== undefined && !Array.isArray(value.images) || value.buffers !== undefined && !Array.isArray(value.buffers))
|
|
206
|
+
return unsupported(path);
|
|
207
|
+
const result = [];
|
|
208
|
+
for (const item of [...value.images ?? [], ...value.buffers ?? []]) {
|
|
209
|
+
if (item?.uri === undefined)
|
|
210
|
+
continue;
|
|
211
|
+
if (typeof item.uri !== 'string')
|
|
212
|
+
return unsupported(path);
|
|
213
|
+
result.push({ specifier: item.uri, kind: 'resource' });
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
/** Static syntax only. No project config, plugin, module or package code is executed. */
|
|
218
|
+
export function workspacePublicSourceDependencies(path, body) {
|
|
219
|
+
if (/\.[cm]?[jt]sx?$/i.test(path))
|
|
220
|
+
return scriptDependencies(path, body.toString('utf8'));
|
|
221
|
+
if (/\.css$/i.test(path))
|
|
222
|
+
return cssDependencies(path, body.toString('utf8'));
|
|
223
|
+
if (/\.(?:html?|svg)$/i.test(path))
|
|
224
|
+
return htmlDependencies(path, body.toString('utf8'));
|
|
225
|
+
if (/\.json5?$/i.test(path))
|
|
226
|
+
return jsonDependencies(path, body.toString('utf8'));
|
|
227
|
+
if (/\.(?:glb|gltf)$/i.test(path))
|
|
228
|
+
return modelDependencies(path, body);
|
|
229
|
+
if (/\.(?:scss|sass|less|vue|svelte)$/i.test(path))
|
|
230
|
+
return unsupported(path);
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { WorkspacePublicSourceError } from './workspace-public-imports.js';
|
|
2
|
+
export type WorkspacePublicSourceFile = {
|
|
3
|
+
body: Buffer;
|
|
4
|
+
mode: '100644' | '100755';
|
|
5
|
+
};
|
|
6
|
+
export type WorkspacePublicSourceClosure = {
|
|
7
|
+
files: Map<string, WorkspacePublicSourceFile>;
|
|
8
|
+
requiredPaths: string[];
|
|
9
|
+
/** Physical bytes, including the unprojected declaration, for publication read guards. */
|
|
10
|
+
observedFiles: Map<string, WorkspacePublicSourceFile>;
|
|
11
|
+
};
|
|
12
|
+
/** Old source rules can diagnose capabilities without changing their file set or fingerprint. */
|
|
13
|
+
export declare function hasWorkspacePublicSourceDeclaration(root: string): Promise<boolean>;
|
|
14
|
+
/** A source snapshot only: no inference, build script, plugin, provider or admission is executed. */
|
|
15
|
+
export declare function readWorkspacePublicSourceClosure(root: string): Promise<WorkspacePublicSourceClosure>;
|