@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
|
@@ -2,3 +2,14 @@ import type { Platform } from '../types.js';
|
|
|
2
2
|
import type { ValidationContext, ValidationResult } from './types.js';
|
|
3
3
|
export declare function scanSourceForCompliance(context: ValidationContext): Promise<ValidationResult[]>;
|
|
4
4
|
export declare function scanSourceForChannels(context: Omit<ValidationContext, 'channel'>, channels: Platform[]): Promise<ValidationResult[]>;
|
|
5
|
+
export type SourcePatternPresence = {
|
|
6
|
+
/** Absolute path of the first source file where the pattern occurs in executable code. */
|
|
7
|
+
file: string;
|
|
8
|
+
line: number;
|
|
9
|
+
evidence: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Finds where each pattern first occurs in executable project source (comments and strings in
|
|
13
|
+
* JavaScript-like files are ignored, as in the compliance scan). Absent patterns are left out.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findSourcePatterns(projectRoot: string, patterns: Record<string, RegExp>, sourceGlobs?: string[]): Promise<Map<string, SourcePatternPresence>>;
|
|
@@ -99,6 +99,37 @@ export async function scanSourceForChannels(context, channels) {
|
|
|
99
99
|
}
|
|
100
100
|
return results;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Finds where each pattern first occurs in executable project source (comments and strings in
|
|
104
|
+
* JavaScript-like files are ignored, as in the compliance scan). Absent patterns are left out.
|
|
105
|
+
*/
|
|
106
|
+
export async function findSourcePatterns(projectRoot, patterns, sourceGlobs) {
|
|
107
|
+
const found = new Map();
|
|
108
|
+
const ids = Object.keys(patterns);
|
|
109
|
+
for (const filePath of await collectSourceFiles(projectRoot, sourceGlobs)) {
|
|
110
|
+
if (found.size === ids.length)
|
|
111
|
+
break;
|
|
112
|
+
let content;
|
|
113
|
+
try {
|
|
114
|
+
content = await fs.readFile(filePath, 'utf-8');
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
for (const id of ids) {
|
|
120
|
+
if (found.has(id))
|
|
121
|
+
continue;
|
|
122
|
+
const match = findExecutableSourcePattern(filePath, content, patterns[id]);
|
|
123
|
+
if (match)
|
|
124
|
+
found.set(id, {
|
|
125
|
+
file: filePath,
|
|
126
|
+
line: lineOfIndex(content, match.index),
|
|
127
|
+
evidence: trimEvidence(match.evidence),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return found;
|
|
132
|
+
}
|
|
102
133
|
async function scanSourceFilesForChannel(context, sourceFiles, includeCommonPatterns) {
|
|
103
134
|
const results = [];
|
|
104
135
|
const requiredPatterns = CHANNEL_SOURCE_PATTERNS[context.channel] ?? [];
|
|
@@ -333,7 +364,6 @@ function maskJavaScriptLikeSource(content) {
|
|
|
333
364
|
maskRange(start, index);
|
|
334
365
|
return index;
|
|
335
366
|
};
|
|
336
|
-
let scanCode;
|
|
337
367
|
const scanTemplate = (start) => {
|
|
338
368
|
maskAt(start);
|
|
339
369
|
let index = start + 1;
|
|
@@ -361,7 +391,7 @@ function maskJavaScriptLikeSource(content) {
|
|
|
361
391
|
}
|
|
362
392
|
return index;
|
|
363
393
|
};
|
|
364
|
-
scanCode = (start, interpolation) => {
|
|
394
|
+
const scanCode = (start, interpolation) => {
|
|
365
395
|
let index = start;
|
|
366
396
|
let braceDepth = interpolation ? 1 : 0;
|
|
367
397
|
while (index < content.length) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BuildTool, EngineType, OutputFormat, Platform } from '../types.js';
|
|
2
|
-
export type ValidationStage = 'prebuild-source' | 'base-output' | 'html-artifact' | 'delivery-package' | 'runtime-manual' | 'external-validator';
|
|
2
|
+
export type ValidationStage = 'prebuild-source' | 'base-output' | 'html-artifact' | 'delivery-package' | 'runtime-load' | 'runtime-manual' | 'external-validator';
|
|
3
3
|
export type RuleSeverity = 'error' | 'warning' | 'info';
|
|
4
|
-
export type RuleStatus = 'pass' | 'fail' | 'warning' | 'manual' | 'external' | 'not-applicable';
|
|
4
|
+
export type RuleStatus = 'pass' | 'fail' | 'warning' | 'manual' | 'external' | 'not-applicable' | 'inconclusive';
|
|
5
5
|
export type RuleConfidence = 'high' | 'medium' | 'low';
|
|
6
6
|
export type RuleOwner = 'playcraft-build' | 'playcraft-delivery' | 'devkit' | 'manual' | 'external';
|
|
7
7
|
export type DeliveryMode = 'single-html' | 'zip' | 'html-backed-zip' | 'fragment-assets' | 'mixed';
|
|
@@ -59,7 +59,12 @@ export interface ValidationContext {
|
|
|
59
59
|
buildTool?: BuildTool;
|
|
60
60
|
buildChain: BuildChain;
|
|
61
61
|
htmlPath?: string;
|
|
62
|
+
/** Final HTML bytes; lets Business validate an uploaded object without staging it. */
|
|
63
|
+
htmlContent?: string | Uint8Array;
|
|
62
64
|
packagePath?: string;
|
|
65
|
+
/** Final ZIP bytes; no filesystem extraction is required. */
|
|
66
|
+
packageBytes?: Uint8Array;
|
|
67
|
+
format?: OutputFormat;
|
|
63
68
|
outputDir?: string;
|
|
64
69
|
sourceGlobs?: string[];
|
|
65
70
|
metadata?: Record<string, unknown>;
|
|
@@ -110,3 +115,197 @@ export interface ValidationReport {
|
|
|
110
115
|
manualChecklist: ManualChecklistItem[];
|
|
111
116
|
externalChecklist: ExternalChecklistItem[];
|
|
112
117
|
}
|
|
118
|
+
/** How a built artifact is stored on disk. */
|
|
119
|
+
export type ArtifactContainer = 'html' | 'zip' | 'directory';
|
|
120
|
+
/**
|
|
121
|
+
* How the playable is laid out inside its container: one self-contained HTML file,
|
|
122
|
+
* or an HTML entry with separate files (scripts, styles, assets).
|
|
123
|
+
*/
|
|
124
|
+
export type ArtifactLayout = 'single-html' | 'multi-file';
|
|
125
|
+
export interface ArtifactFile {
|
|
126
|
+
/** Path inside the artifact, `/`-separated, without a leading slash. */
|
|
127
|
+
path: string;
|
|
128
|
+
/** Uncompressed size in bytes. */
|
|
129
|
+
size: number;
|
|
130
|
+
}
|
|
131
|
+
export interface PlayableArtifact {
|
|
132
|
+
/** Absolute path of the file or directory that was read. */
|
|
133
|
+
sourcePath: string;
|
|
134
|
+
container: ArtifactContainer;
|
|
135
|
+
layout: ArtifactLayout;
|
|
136
|
+
/** Entry HTML path inside the artifact. */
|
|
137
|
+
entry: string;
|
|
138
|
+
files: ArtifactFile[];
|
|
139
|
+
/** Bytes on disk: the HTML or ZIP file size, or the sum of the directory's files. */
|
|
140
|
+
totalSize: number;
|
|
141
|
+
/** `sha256:<hex>`; stable for the same content regardless of where it is stored. */
|
|
142
|
+
digest: string;
|
|
143
|
+
readText(filePath: string): Promise<string | null>;
|
|
144
|
+
readBuffer(filePath: string): Promise<Buffer | null>;
|
|
145
|
+
}
|
|
146
|
+
export type ArtifactReadErrorCode = 'artifact_not_found' | 'artifact_unsupported' | 'artifact_zip_invalid' | 'artifact_entry_missing' | 'artifact_entry_ambiguous' | 'artifact_entry_invalid';
|
|
147
|
+
/**
|
|
148
|
+
* Artifact QA steps, in the order they run and are shown to users. Each step answers one question
|
|
149
|
+
* a user would ask about the playable; every rule belongs to exactly one step.
|
|
150
|
+
* - `code`: is the code in the artifact sound, with no development or debugging leftovers.
|
|
151
|
+
* - `resources`: are all resources inside the artifact, with nothing fetched from the network.
|
|
152
|
+
* - `launch`: does the game open without errors and display correctly on every screen.
|
|
153
|
+
* - `size`: how big the artifact is and what takes the space. A channel profile enforces the
|
|
154
|
+
* channel's limit; the `playcraft` profile has no hard limit, so the step is advisory there.
|
|
155
|
+
* - `cta`: does the CTA reach the channel's store API, with no redirect the user did not tap.
|
|
156
|
+
*/
|
|
157
|
+
export type QaStageId = 'code' | 'resources' | 'launch' | 'size' | 'cta';
|
|
158
|
+
export declare const QA_STAGES: readonly QaStageId[];
|
|
159
|
+
/**
|
|
160
|
+
* - `ran`: every check of the step ran; see its results.
|
|
161
|
+
* - `partial`: some checks ran, others could not (e.g. no browser); the QA is incomplete.
|
|
162
|
+
* - `skipped`: the step could not run at all; the QA is incomplete.
|
|
163
|
+
* - `not-applicable`: the step does not apply to this artifact.
|
|
164
|
+
*/
|
|
165
|
+
export type QaStageStatus = 'ran' | 'partial' | 'skipped' | 'not-applicable';
|
|
166
|
+
export interface QaStageReport {
|
|
167
|
+
stage: QaStageId;
|
|
168
|
+
status: QaStageStatus;
|
|
169
|
+
/** Why the step did not run, or which of its checks did not run. */
|
|
170
|
+
reason?: string;
|
|
171
|
+
/** Advisory steps never affect the overall summary or exit code. */
|
|
172
|
+
advisory: boolean;
|
|
173
|
+
durationMs: number;
|
|
174
|
+
summary: ValidationSummary;
|
|
175
|
+
results: ValidationResult[];
|
|
176
|
+
/** Project source findings that help locate this step's problems; never affect any result. */
|
|
177
|
+
hints: ValidationResult[];
|
|
178
|
+
/** Step-specific facts, e.g. the size limit used by `size`. */
|
|
179
|
+
details?: Record<string, unknown>;
|
|
180
|
+
}
|
|
181
|
+
export type QaProgressEvent = {
|
|
182
|
+
type: 'step-start';
|
|
183
|
+
stage: QaStageId;
|
|
184
|
+
index: number;
|
|
185
|
+
total: number;
|
|
186
|
+
} | {
|
|
187
|
+
type: 'step-end';
|
|
188
|
+
stage: QaStageId;
|
|
189
|
+
index: number;
|
|
190
|
+
total: number;
|
|
191
|
+
report: QaStageReport;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Report of `runArtifactQa`: one report per step, and an overall summary of the non-advisory
|
|
195
|
+
* steps that ran. Kept apart from `ValidationReport` so the existing delivery validation output,
|
|
196
|
+
* which is checked against strict schemas, stays unchanged.
|
|
197
|
+
*/
|
|
198
|
+
export interface ArtifactQaReport {
|
|
199
|
+
version: string;
|
|
200
|
+
rulesVersion: string;
|
|
201
|
+
profile: Platform;
|
|
202
|
+
artifact: {
|
|
203
|
+
sourcePath: string;
|
|
204
|
+
container: ArtifactContainer;
|
|
205
|
+
layout: ArtifactLayout;
|
|
206
|
+
entry: string;
|
|
207
|
+
digest: string;
|
|
208
|
+
totalSize: number;
|
|
209
|
+
fileCount: number;
|
|
210
|
+
};
|
|
211
|
+
summary: ValidationSummary;
|
|
212
|
+
/** A requested step was skipped or only partly run, so passing does not cover it. */
|
|
213
|
+
incomplete: boolean;
|
|
214
|
+
stages: QaStageReport[];
|
|
215
|
+
/** Whether project source was scanned for the steps' hints. */
|
|
216
|
+
sourceHints: {
|
|
217
|
+
status: 'ran' | 'skipped';
|
|
218
|
+
reason?: string;
|
|
219
|
+
};
|
|
220
|
+
/** Checks of the channel profile that need a person or the channel's own validator. */
|
|
221
|
+
manualChecklist: ManualChecklistItem[];
|
|
222
|
+
externalChecklist: ExternalChecklistItem[];
|
|
223
|
+
}
|
|
224
|
+
export interface ReadArtifactOptions {
|
|
225
|
+
/** Entry HTML path inside a ZIP or directory; defaults to `index.html`, then the only HTML file. */
|
|
226
|
+
entry?: string;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Browser access for runtime QA. `@playcraft/build` only defines this contract; hosts provide the
|
|
230
|
+
* implementation (the CLI uses playwright-core), so the build package does not depend on a browser.
|
|
231
|
+
*/
|
|
232
|
+
export interface RuntimeViewport {
|
|
233
|
+
width: number;
|
|
234
|
+
height: number;
|
|
235
|
+
deviceScaleFactor: number;
|
|
236
|
+
isMobile: boolean;
|
|
237
|
+
hasTouch: boolean;
|
|
238
|
+
}
|
|
239
|
+
export interface RuntimeResource {
|
|
240
|
+
body: Buffer;
|
|
241
|
+
contentType: string;
|
|
242
|
+
}
|
|
243
|
+
export interface RuntimePageOptions {
|
|
244
|
+
/** Origin the artifact is served from, e.g. `http://artifact.playcraft-qa.test`. */
|
|
245
|
+
origin: string;
|
|
246
|
+
/** Entry path inside the artifact, served at `${origin}/${entryPath}`. */
|
|
247
|
+
entryPath: string;
|
|
248
|
+
viewport: RuntimeViewport;
|
|
249
|
+
userAgent: string;
|
|
250
|
+
/** Runs before any page script. */
|
|
251
|
+
initScript: string;
|
|
252
|
+
/** Content-Security-Policy header sent with HTML responses; empty sends none. */
|
|
253
|
+
contentSecurityPolicy: string;
|
|
254
|
+
/** Browser locale, e.g. `en-US`; default the browser's own. */
|
|
255
|
+
locale?: string;
|
|
256
|
+
/**
|
|
257
|
+
* Answer cross-origin writes (ad SDK telemetry) locally with an empty JSON success instead of
|
|
258
|
+
* blocking them, as a channel container would. Nothing leaves the machine either way.
|
|
259
|
+
*/
|
|
260
|
+
containerTelemetry?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Let cross-origin GET and HEAD requests reach public hosts instead of blocking them. Only export
|
|
263
|
+
* validation of a real channel package uses it; private addresses stay blocked either way.
|
|
264
|
+
*/
|
|
265
|
+
remoteReads?: boolean;
|
|
266
|
+
/** Serves a path inside the artifact; null means the file does not exist (404). */
|
|
267
|
+
resolve(pathname: string): Promise<RuntimeResource | null>;
|
|
268
|
+
/** Navigation timeout in milliseconds. */
|
|
269
|
+
timeoutMs: number;
|
|
270
|
+
}
|
|
271
|
+
export interface RuntimePageEvents {
|
|
272
|
+
consoleErrors: string[];
|
|
273
|
+
pageErrors: string[];
|
|
274
|
+
/** Requests for artifact files that do not exist, or that failed to load. */
|
|
275
|
+
failedRequests: Array<{
|
|
276
|
+
url: string;
|
|
277
|
+
reason: string;
|
|
278
|
+
}>;
|
|
279
|
+
/** Requests to any host other than the artifact origin; they are blocked, never sent. */
|
|
280
|
+
blockedRequests: string[];
|
|
281
|
+
/** Top-level navigations away from the entry; they are blocked, never followed. */
|
|
282
|
+
navigationAttempts: string[];
|
|
283
|
+
/** Page exceptions with their stacks, in the order of `pageErrors`. */
|
|
284
|
+
pageErrorDetails?: Array<{
|
|
285
|
+
message: string;
|
|
286
|
+
stack?: string;
|
|
287
|
+
}>;
|
|
288
|
+
/** Cross-origin writes answered locally (`containerTelemetry`), as `METHOD url`. */
|
|
289
|
+
containerRequests?: string[];
|
|
290
|
+
/** The renderer crashed. */
|
|
291
|
+
crashed?: boolean;
|
|
292
|
+
}
|
|
293
|
+
export interface RuntimePage {
|
|
294
|
+
/** Whether the entry document loaded. */
|
|
295
|
+
loaded: boolean;
|
|
296
|
+
loadError?: string;
|
|
297
|
+
events(): RuntimePageEvents;
|
|
298
|
+
/** Evaluates a JavaScript expression in the page and returns its JSON-serializable result. */
|
|
299
|
+
evaluate<T>(expression: string): Promise<T>;
|
|
300
|
+
/** Dispatches a real pointer click at viewport coordinates. */
|
|
301
|
+
click(x: number, y: number): Promise<void>;
|
|
302
|
+
/** A touch tap on touch viewports; drivers without it fall back to `click`. */
|
|
303
|
+
tap?(x: number, y: number): Promise<void>;
|
|
304
|
+
/** PNG screenshot of the viewport. */
|
|
305
|
+
screenshot(): Promise<Buffer>;
|
|
306
|
+
wait(ms: number): Promise<void>;
|
|
307
|
+
close(): Promise<void>;
|
|
308
|
+
}
|
|
309
|
+
export interface BrowserDriver {
|
|
310
|
+
open(options: RuntimePageOptions): Promise<RuntimePage>;
|
|
311
|
+
}
|
package/dist/validation/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const QA_STAGES = ['code', 'resources', 'launch', 'size', 'cta'];
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
import type { Platform } from '../types.js';
|
|
2
|
-
import type { ValidationContext, ValidationReport, ValidationStage } from './types.js';
|
|
1
|
+
import type { OutputFormat, Platform } from '../types.js';
|
|
2
|
+
import type { ExternalChecklistItem, ManualChecklistItem, QaStageId, QaStageReport, ValidationContext, ValidationReport, ValidationResult, ValidationStage, ValidationSummary } from './types.js';
|
|
3
3
|
export declare const VALIDATION_REPORT_VERSION = "0.1.0";
|
|
4
4
|
export declare function runPlayableValidation(context: ValidationContext, stages?: ValidationStage[]): Promise<ValidationReport>;
|
|
5
|
+
export type ChannelArtifactValidationOptions = {
|
|
6
|
+
channel: Platform;
|
|
7
|
+
format: OutputFormat;
|
|
8
|
+
bytes: Uint8Array;
|
|
9
|
+
htmlBytes?: Uint8Array;
|
|
10
|
+
artifactName?: string;
|
|
11
|
+
projectRoot?: string;
|
|
12
|
+
};
|
|
13
|
+
/** Revalidates final HTML and ZIP bytes without trusting a Runner-side report or staging files. */
|
|
14
|
+
export declare function runChannelArtifactValidation(options: ChannelArtifactValidationOptions): Promise<ValidationReport>;
|
|
5
15
|
export declare function runPlayableSourceValidationForChannels(context: Omit<ValidationContext, 'channel'>, channels: Platform[]): Promise<ValidationReport>;
|
|
16
|
+
export declare function summarize(results: ValidationResult[], manualChecklist: ManualChecklistItem[], externalChecklist: ExternalChecklistItem[]): ValidationSummary;
|
|
17
|
+
/** Builds the report of a QA stage that ran. */
|
|
18
|
+
export declare function ranStageReport(stage: QaStageId, startedAt: number, results: ValidationResult[], extra?: {
|
|
19
|
+
status?: 'ran' | 'partial';
|
|
20
|
+
reason?: string;
|
|
21
|
+
advisory?: boolean;
|
|
22
|
+
hints?: ValidationResult[];
|
|
23
|
+
details?: Record<string, unknown>;
|
|
24
|
+
}): QaStageReport;
|
|
25
|
+
export declare function idleStageReport(stage: QaStageId, status: 'skipped' | 'not-applicable', reason: string, advisory?: boolean): QaStageReport;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { getChannelRuleProfile } from './profiles.js';
|
|
2
2
|
import { validateHtmlArtifact } from './html-validator.js';
|
|
3
|
-
import { validateDeliveryPackage } from './package-validator.js';
|
|
3
|
+
import { validateDeliveryPackage, validateSingleHtmlPackage } from './package-validator.js';
|
|
4
4
|
import { scanSourceForChannels, scanSourceForCompliance } from './source-scanner.js';
|
|
5
|
+
import { SimpleZipReader } from './zip-reader.js';
|
|
5
6
|
export const VALIDATION_REPORT_VERSION = '0.1.0';
|
|
6
7
|
export async function runPlayableValidation(context, stages) {
|
|
7
8
|
const profile = getChannelRuleProfile(context.channel);
|
|
8
9
|
const defaultStages = [...profile.defaultStages];
|
|
9
|
-
if (context.packagePath && profile.optionalStages.includes('delivery-package')) {
|
|
10
|
+
if ((context.packagePath || context.packageBytes) && profile.optionalStages.includes('delivery-package')) {
|
|
10
11
|
defaultStages.push('delivery-package');
|
|
11
12
|
}
|
|
12
13
|
const enabledStages = new Set(stages ?? defaultStages);
|
|
@@ -32,6 +33,40 @@ export async function runPlayableValidation(context, stages) {
|
|
|
32
33
|
externalChecklist,
|
|
33
34
|
};
|
|
34
35
|
}
|
|
36
|
+
/** Revalidates final HTML and ZIP bytes without trusting a Runner-side report or staging files. */
|
|
37
|
+
export async function runChannelArtifactValidation(options) {
|
|
38
|
+
const artifactName = options.artifactName ?? (options.format === 'html' ? 'index.html' : 'delivery.zip');
|
|
39
|
+
let htmlBytes = options.htmlBytes ?? (options.format === 'html' ? options.bytes : undefined);
|
|
40
|
+
if (!htmlBytes && options.format === 'zip') {
|
|
41
|
+
try {
|
|
42
|
+
htmlBytes = new SimpleZipReader(Buffer.from(options.bytes)).readEntry('index.html') ?? undefined;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// The package validator returns the structured readable/path failure below.
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const report = await runPlayableValidation({
|
|
49
|
+
projectRoot: options.projectRoot ?? '.',
|
|
50
|
+
channel: options.channel,
|
|
51
|
+
engine: 'unknown',
|
|
52
|
+
buildChain: 'generic',
|
|
53
|
+
format: options.format,
|
|
54
|
+
htmlPath: htmlBytes ? artifactName : undefined,
|
|
55
|
+
htmlContent: htmlBytes,
|
|
56
|
+
packagePath: options.format === 'zip' ? artifactName : undefined,
|
|
57
|
+
packageBytes: options.format === 'zip' ? options.bytes : undefined,
|
|
58
|
+
}, [
|
|
59
|
+
'html-artifact',
|
|
60
|
+
...(options.format === 'zip' ? ['delivery-package'] : []),
|
|
61
|
+
'runtime-manual',
|
|
62
|
+
'external-validator',
|
|
63
|
+
]);
|
|
64
|
+
if (options.format === 'html') {
|
|
65
|
+
report.results.push(...validateSingleHtmlPackage(options.channel, options.bytes, artifactName));
|
|
66
|
+
report.summary = summarize(report.results, report.manualChecklist, report.externalChecklist);
|
|
67
|
+
}
|
|
68
|
+
return report;
|
|
69
|
+
}
|
|
35
70
|
export async function runPlayableSourceValidationForChannels(context, channels) {
|
|
36
71
|
const uniqueChannels = Array.from(new Set(channels));
|
|
37
72
|
const results = await scanSourceForChannels(context, uniqueChannels);
|
|
@@ -71,7 +106,7 @@ function buildExternalChecklist(rules, enabledStages) {
|
|
|
71
106
|
owner: rule.owner,
|
|
72
107
|
}));
|
|
73
108
|
}
|
|
74
|
-
function summarize(results, manualChecklist, externalChecklist) {
|
|
109
|
+
export function summarize(results, manualChecklist, externalChecklist) {
|
|
75
110
|
const errorCount = results.filter((result) => result.status === 'fail').length;
|
|
76
111
|
const warningCount = results.filter((result) => result.status === 'warning').length;
|
|
77
112
|
const manualCount = manualChecklist.length;
|
|
@@ -94,3 +129,29 @@ function summarize(results, manualChecklist, externalChecklist) {
|
|
|
94
129
|
externalCount,
|
|
95
130
|
};
|
|
96
131
|
}
|
|
132
|
+
/** Builds the report of a QA stage that ran. */
|
|
133
|
+
export function ranStageReport(stage, startedAt, results, extra = {}) {
|
|
134
|
+
return {
|
|
135
|
+
stage,
|
|
136
|
+
status: extra.status ?? 'ran',
|
|
137
|
+
...(extra.reason ? { reason: extra.reason } : {}),
|
|
138
|
+
advisory: extra.advisory ?? false,
|
|
139
|
+
durationMs: Date.now() - startedAt,
|
|
140
|
+
summary: summarize(results, [], []),
|
|
141
|
+
results,
|
|
142
|
+
hints: extra.hints ?? [],
|
|
143
|
+
...(extra.details ? { details: extra.details } : {}),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
export function idleStageReport(stage, status, reason, advisory = false) {
|
|
147
|
+
return {
|
|
148
|
+
stage,
|
|
149
|
+
status,
|
|
150
|
+
reason,
|
|
151
|
+
advisory,
|
|
152
|
+
durationMs: 0,
|
|
153
|
+
summary: summarize([], [], []),
|
|
154
|
+
results: [],
|
|
155
|
+
hints: [],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -4,14 +4,21 @@ export interface ZipEntryInfo {
|
|
|
4
4
|
uncompressedSize: number;
|
|
5
5
|
compressionMethod: number;
|
|
6
6
|
isDirectory: boolean;
|
|
7
|
+
externalAttributes?: number;
|
|
8
|
+
creatorOs?: number;
|
|
9
|
+
encrypted?: boolean;
|
|
10
|
+
crc32?: number;
|
|
7
11
|
}
|
|
12
|
+
/** Bounded ZIP reader used for both local reports and untrusted uploaded bytes. */
|
|
8
13
|
export declare class SimpleZipReader {
|
|
9
14
|
private readonly buffer;
|
|
10
15
|
private entriesCache?;
|
|
11
16
|
constructor(buffer: Buffer);
|
|
12
17
|
listEntries(): ZipEntryInfo[];
|
|
13
18
|
readEntryText(entryPath: string): string | null;
|
|
19
|
+
readEntry(entryPath: string): Buffer | null;
|
|
14
20
|
private readCentralDirectory;
|
|
15
21
|
private readEntryData;
|
|
16
22
|
private findEndOfCentralDirectory;
|
|
23
|
+
private requireRange;
|
|
17
24
|
}
|