@playcraft/build 0.2.15-test-a → 0.2.16-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.
Files changed (122) hide show
  1. package/dist/base-builder.js +2 -41
  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 -10
  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/dist/audio-source-files.d.ts +0 -5
  51. package/dist/audio-source-files.js +0 -135
  52. package/dist/delivery/agent-build-runner.d.ts +0 -44
  53. package/dist/delivery/agent-build-runner.js +0 -365
  54. package/dist/delivery/agent-build-source.d.ts +0 -8
  55. package/dist/delivery/agent-build-source.js +0 -25
  56. package/dist/delivery/artifact-descriptor.d.ts +0 -31
  57. package/dist/delivery/artifact-descriptor.js +0 -237
  58. package/dist/delivery/artifact-package.d.ts +0 -43
  59. package/dist/delivery/artifact-package.js +0 -283
  60. package/dist/delivery/build-plan.d.ts +0 -4
  61. package/dist/delivery/build-plan.js +0 -189
  62. package/dist/delivery/build-plan.types.d.ts +0 -51
  63. package/dist/delivery/build-plan.types.js +0 -1
  64. package/dist/delivery/command-isolation.d.ts +0 -21
  65. package/dist/delivery/command-isolation.js +0 -327
  66. package/dist/delivery/commands.d.ts +0 -5
  67. package/dist/delivery/commands.js +0 -146
  68. package/dist/delivery/files.d.ts +0 -9
  69. package/dist/delivery/files.js +0 -144
  70. package/dist/delivery/git-source-fingerprint.d.ts +0 -2
  71. package/dist/delivery/git-source-fingerprint.js +0 -58
  72. package/dist/delivery/isolated-source.d.ts +0 -5
  73. package/dist/delivery/isolated-source.js +0 -131
  74. package/dist/delivery/output-publication.d.ts +0 -21
  75. package/dist/delivery/output-publication.js +0 -444
  76. package/dist/delivery/project-delivery.d.ts +0 -6
  77. package/dist/delivery/project-delivery.js +0 -287
  78. package/dist/delivery/recipe-build-plan.d.ts +0 -4
  79. package/dist/delivery/recipe-build-plan.js +0 -53
  80. package/dist/delivery/recipe.d.ts +0 -20
  81. package/dist/delivery/recipe.js +0 -211
  82. package/dist/delivery/safe-path.d.ts +0 -2
  83. package/dist/delivery/safe-path.js +0 -18
  84. package/dist/delivery/types.d.ts +0 -76
  85. package/dist/delivery/types.js +0 -1
  86. package/dist/production-animation-presence.d.ts +0 -2
  87. package/dist/production-animation-presence.js +0 -146
  88. package/dist/production-inputs.d.ts +0 -30
  89. package/dist/production-inputs.js +0 -262
  90. package/dist/production-source-paths.d.ts +0 -5
  91. package/dist/production-source-paths.js +0 -27
  92. package/dist/redirect-policy.d.ts +0 -23
  93. package/dist/redirect-policy.js +0 -25
  94. package/dist/validation/artifact-qa.d.ts +0 -36
  95. package/dist/validation/artifact-qa.js +0 -263
  96. package/dist/validation/artifact-rules.d.ts +0 -39
  97. package/dist/validation/artifact-rules.js +0 -451
  98. package/dist/validation/artifact.d.ts +0 -14
  99. package/dist/validation/artifact.js +0 -188
  100. package/dist/validation/playwright-driver.d.ts +0 -37
  101. package/dist/validation/playwright-driver.js +0 -302
  102. package/dist/validation/runtime-cover.d.ts +0 -32
  103. package/dist/validation/runtime-cover.js +0 -120
  104. package/dist/validation/runtime-load.d.ts +0 -141
  105. package/dist/validation/runtime-load.js +0 -812
  106. package/dist/vite/source-builder-asset-paths.d.ts +0 -25
  107. package/dist/vite/source-builder-asset-paths.js +0 -154
  108. package/dist/vite/source-builder-esm.d.ts +0 -7
  109. package/dist/vite/source-builder-esm.js +0 -877
  110. package/dist/vite/source-builder-types.d.ts +0 -14
  111. package/dist/vite/source-builder-types.js +0 -1
  112. package/dist/vite/workspace.d.ts +0 -6
  113. package/dist/vite/workspace.js +0 -41
  114. package/dist/workspace-css-imports.d.ts +0 -2
  115. package/dist/workspace-css-imports.js +0 -139
  116. package/dist/workspace-model-source.d.ts +0 -14
  117. package/dist/workspace-model-source.js +0 -184
  118. package/dist/workspace-public-imports.d.ts +0 -11
  119. package/dist/workspace-public-imports.js +0 -232
  120. package/dist/workspace-public-source.d.ts +0 -15
  121. package/dist/workspace-public-source.js +0 -564
  122. package/templates/patches/playcraft-redirect-policy.js +0 -115
@@ -2,11 +2,10 @@ import fs from 'fs/promises';
2
2
  import fsSync from 'fs';
3
3
  import path from 'path';
4
4
  import { getChannelRuleProfile } from './profiles.js';
5
- import { directorySize, listDirectoryEntries } from './artifact.js';
6
5
  import { SimpleZipReader } from './zip-reader.js';
7
6
  const FIVE_MB = 5 * 1024 * 1024;
8
7
  export async function validateDeliveryPackage(context, profile = getChannelRuleProfile(context.channel)) {
9
- if (!context.packagePath && !context.packageBytes) {
8
+ if (!context.packagePath) {
10
9
  return [{
11
10
  ruleId: `${context.channel}.package.path.required`,
12
11
  channel: context.channel,
@@ -19,10 +18,9 @@ export async function validateDeliveryPackage(context, profile = getChannelRuleP
19
18
  confidence: 'high',
20
19
  }];
21
20
  }
22
- const packagePath = context.packagePath ?? 'delivery.zip';
23
21
  let inventory;
24
22
  try {
25
- inventory = await readPackageInventory(packagePath, context.packageBytes);
23
+ inventory = await readPackageInventory(context.packagePath);
26
24
  }
27
25
  catch (error) {
28
26
  return [{
@@ -31,9 +29,9 @@ export async function validateDeliveryPackage(context, profile = getChannelRuleP
31
29
  stage: 'delivery-package',
32
30
  severity: 'error',
33
31
  status: 'fail',
34
- message: `Delivery package is not readable: ${packagePath}`,
32
+ message: `Delivery package is not readable: ${context.packagePath}`,
35
33
  recommendation: 'Verify the generated ZIP or delivery directory exists and is readable.',
36
- file: packagePath,
34
+ file: context.packagePath,
37
35
  evidence: error instanceof Error ? error.message : String(error),
38
36
  owner: 'playcraft-delivery',
39
37
  confidence: 'high',
@@ -64,26 +62,18 @@ export async function validateDeliveryPackage(context, profile = getChannelRuleP
64
62
  }
65
63
  return results;
66
64
  }
67
- export function validateSingleHtmlPackage(channel, bytes, artifactName = 'index.html') {
68
- return [
69
- boolResult(channel, 'package.size.max-5mb', bytes.byteLength <= FIVE_MB, 'Delivery HTML should be smaller than 5 MB.', 'Reduce artifact size or inline assets more aggressively.', artifactName, `actual=${bytes.byteLength}, limit=${FIVE_MB}`),
70
- boolResult(channel, 'package.single-html.required', bytes.byteLength > 0 && artifactName.toLowerCase().endsWith('.html'), 'Delivery must be one nonempty HTML file.', 'Provide exactly one nonempty HTML artifact.', artifactName),
71
- ];
72
- }
73
- async function readPackageInventory(packagePath, packageBytes) {
74
- if (packageBytes === undefined) {
75
- const stat = await fs.stat(packagePath);
76
- if (stat.isDirectory()) {
77
- const entries = await listDirectoryEntries(packagePath);
78
- return {
79
- packagePath,
80
- entries,
81
- readText: (entryPath) => readTextFromDirectorySyncUnsupported(packagePath, entryPath),
82
- size: await directorySize(packagePath),
83
- };
84
- }
65
+ async function readPackageInventory(packagePath) {
66
+ const stat = await fs.stat(packagePath);
67
+ if (stat.isDirectory()) {
68
+ const entries = await readDirectoryEntries(packagePath);
69
+ return {
70
+ packagePath,
71
+ entries,
72
+ readText: (entryPath) => readTextFromDirectorySyncUnsupported(packagePath, entryPath),
73
+ size: await calculateDirectorySize(packagePath),
74
+ };
85
75
  }
86
- const buffer = packageBytes === undefined ? await fs.readFile(packagePath) : Buffer.from(packageBytes);
76
+ const buffer = await fs.readFile(packagePath);
87
77
  const zip = new SimpleZipReader(buffer);
88
78
  return {
89
79
  packagePath,
@@ -92,6 +82,38 @@ async function readPackageInventory(packagePath, packageBytes) {
92
82
  size: buffer.length,
93
83
  };
94
84
  }
85
+ async function readDirectoryEntries(dir) {
86
+ const entries = [];
87
+ const walk = async (current) => {
88
+ const dirEntries = await fs.readdir(current, { withFileTypes: true });
89
+ for (const entry of dirEntries) {
90
+ const fullPath = path.join(current, entry.name);
91
+ const relative = path.relative(dir, fullPath).replace(/\\/g, '/');
92
+ if (entry.isDirectory()) {
93
+ entries.push({
94
+ path: `${relative}/`,
95
+ compressedSize: 0,
96
+ uncompressedSize: 0,
97
+ compressionMethod: 0,
98
+ isDirectory: true,
99
+ });
100
+ await walk(fullPath);
101
+ }
102
+ else {
103
+ const stat = await fs.stat(fullPath);
104
+ entries.push({
105
+ path: relative,
106
+ compressedSize: stat.size,
107
+ uncompressedSize: stat.size,
108
+ compressionMethod: 0,
109
+ isDirectory: false,
110
+ });
111
+ }
112
+ }
113
+ };
114
+ await walk(dir);
115
+ return entries;
116
+ }
95
117
  function readTextFromDirectorySyncUnsupported(_packagePath, _entryPath) {
96
118
  const filePath = path.join(_packagePath, _entryPath);
97
119
  try {
@@ -101,6 +123,23 @@ function readTextFromDirectorySyncUnsupported(_packagePath, _entryPath) {
101
123
  return null;
102
124
  }
103
125
  }
126
+ async function calculateDirectorySize(dir) {
127
+ let total = 0;
128
+ const walk = async (current) => {
129
+ const entries = await fs.readdir(current, { withFileTypes: true });
130
+ for (const entry of entries) {
131
+ const fullPath = path.join(current, entry.name);
132
+ if (entry.isDirectory()) {
133
+ await walk(fullPath);
134
+ }
135
+ else {
136
+ total += (await fs.stat(fullPath)).size;
137
+ }
138
+ }
139
+ };
140
+ await walk(dir);
141
+ return total;
142
+ }
104
143
  function validateZipLikePackage(channel, inventory) {
105
144
  const paths = new Set(inventory.entries.map((entry) => entry.path));
106
145
  return [
@@ -1,17 +1,5 @@
1
- import type { OutputFormat, Platform } from '../types.js';
1
+ import type { Platform } from '../types.js';
2
2
  import type { ChannelRuleProfile, ValidationRule, ValidationStage } from './types.js';
3
3
  export declare const CHANNEL_RULE_PROFILES: Record<Platform, ChannelRuleProfile>;
4
4
  export declare function getChannelRuleProfile(channel: Platform): ChannelRuleProfile;
5
5
  export declare function getRulesForStage(channel: Platform, stage: ValidationStage): ValidationRule[];
6
- export declare const CHANNEL_RULES_VERSION = "channel-rules-v1";
7
- export type ChannelCapability = {
8
- channel: Platform;
9
- channelRulesVersion: typeof CHANNEL_RULES_VERSION;
10
- supportedFormats: OutputFormat[];
11
- packageStrategy: 'single-html' | 'normalized-zip' | 'format-dependent';
12
- rootEntryRequired: boolean;
13
- maxFiles?: number;
14
- maxArtifactBytes?: number;
15
- };
16
- /** Versioned delivery facts shared by Runner packaging and Business revalidation. */
17
- export declare function getChannelCapability(channel: Platform): ChannelCapability;
@@ -219,30 +219,3 @@ export function getChannelRuleProfile(channel) {
219
219
  export function getRulesForStage(channel, stage) {
220
220
  return getChannelRuleProfile(channel).rules.filter((rule) => rule.stage === stage);
221
221
  }
222
- export const CHANNEL_RULES_VERSION = 'channel-rules-v1';
223
- /** Versioned delivery facts shared by Runner packaging and Business revalidation. */
224
- export function getChannelCapability(channel) {
225
- const profile = getChannelRuleProfile(channel);
226
- const supportsZip = profile.deliveryMode === 'zip' ||
227
- profile.deliveryMode === 'html-backed-zip' ||
228
- profile.deliveryMode === 'mixed';
229
- const supportsHtml = profile.deliveryMode === 'single-html' || profile.deliveryMode === 'mixed';
230
- return {
231
- channel,
232
- channelRulesVersion: CHANNEL_RULES_VERSION,
233
- supportedFormats: [
234
- ...(supportsHtml ? ['html'] : []),
235
- ...(supportsZip ? ['zip'] : []),
236
- ],
237
- packageStrategy: profile.deliveryMode === 'mixed'
238
- ? 'format-dependent'
239
- : profile.deliveryMode === 'single-html'
240
- ? 'single-html'
241
- : 'normalized-zip',
242
- rootEntryRequired: supportsZip,
243
- ...(channel === 'google' ? { maxFiles: 512 } : {}),
244
- ...(profile.rules.some((rule) => rule.check?.kind === 'max-size')
245
- ? { maxArtifactBytes: FIVE_MB }
246
- : {}),
247
- };
248
- }
@@ -2,14 +2,3 @@ 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,37 +99,6 @@ 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
- }
133
102
  async function scanSourceFilesForChannel(context, sourceFiles, includeCommonPatterns) {
134
103
  const results = [];
135
104
  const requiredPatterns = CHANNEL_SOURCE_PATTERNS[context.channel] ?? [];
@@ -364,6 +333,7 @@ function maskJavaScriptLikeSource(content) {
364
333
  maskRange(start, index);
365
334
  return index;
366
335
  };
336
+ let scanCode;
367
337
  const scanTemplate = (start) => {
368
338
  maskAt(start);
369
339
  let index = start + 1;
@@ -391,7 +361,7 @@ function maskJavaScriptLikeSource(content) {
391
361
  }
392
362
  return index;
393
363
  };
394
- const scanCode = (start, interpolation) => {
364
+ scanCode = (start, interpolation) => {
395
365
  let index = start;
396
366
  let braceDepth = interpolation ? 1 : 0;
397
367
  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-load' | 'runtime-manual' | 'external-validator';
2
+ export type ValidationStage = 'prebuild-source' | 'base-output' | 'html-artifact' | 'delivery-package' | 'runtime-manual' | 'external-validator';
3
3
  export type RuleSeverity = 'error' | 'warning' | 'info';
4
- export type RuleStatus = 'pass' | 'fail' | 'warning' | 'manual' | 'external' | 'not-applicable' | 'inconclusive';
4
+ export type RuleStatus = 'pass' | 'fail' | 'warning' | 'manual' | 'external' | 'not-applicable';
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,12 +59,7 @@ 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;
64
62
  packagePath?: string;
65
- /** Final ZIP bytes; no filesystem extraction is required. */
66
- packageBytes?: Uint8Array;
67
- format?: OutputFormat;
68
63
  outputDir?: string;
69
64
  sourceGlobs?: string[];
70
65
  metadata?: Record<string, unknown>;
@@ -115,197 +110,3 @@ export interface ValidationReport {
115
110
  manualChecklist: ManualChecklistItem[];
116
111
  externalChecklist: ExternalChecklistItem[];
117
112
  }
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
- }
@@ -1 +1 @@
1
- export const QA_STAGES = ['code', 'resources', 'launch', 'size', 'cta'];
1
+ export {};
@@ -1,25 +1,5 @@
1
- import type { OutputFormat, Platform } from '../types.js';
2
- import type { ExternalChecklistItem, ManualChecklistItem, QaStageId, QaStageReport, ValidationContext, ValidationReport, ValidationResult, ValidationStage, ValidationSummary } from './types.js';
1
+ import type { Platform } from '../types.js';
2
+ import type { ValidationContext, ValidationReport, ValidationStage } 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>;
15
5
  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,13 +1,12 @@
1
1
  import { getChannelRuleProfile } from './profiles.js';
2
2
  import { validateHtmlArtifact } from './html-validator.js';
3
- import { validateDeliveryPackage, validateSingleHtmlPackage } from './package-validator.js';
3
+ import { validateDeliveryPackage } from './package-validator.js';
4
4
  import { scanSourceForChannels, scanSourceForCompliance } from './source-scanner.js';
5
- import { SimpleZipReader } from './zip-reader.js';
6
5
  export const VALIDATION_REPORT_VERSION = '0.1.0';
7
6
  export async function runPlayableValidation(context, stages) {
8
7
  const profile = getChannelRuleProfile(context.channel);
9
8
  const defaultStages = [...profile.defaultStages];
10
- if ((context.packagePath || context.packageBytes) && profile.optionalStages.includes('delivery-package')) {
9
+ if (context.packagePath && profile.optionalStages.includes('delivery-package')) {
11
10
  defaultStages.push('delivery-package');
12
11
  }
13
12
  const enabledStages = new Set(stages ?? defaultStages);
@@ -33,40 +32,6 @@ export async function runPlayableValidation(context, stages) {
33
32
  externalChecklist,
34
33
  };
35
34
  }
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
- }
70
35
  export async function runPlayableSourceValidationForChannels(context, channels) {
71
36
  const uniqueChannels = Array.from(new Set(channels));
72
37
  const results = await scanSourceForChannels(context, uniqueChannels);
@@ -106,7 +71,7 @@ function buildExternalChecklist(rules, enabledStages) {
106
71
  owner: rule.owner,
107
72
  }));
108
73
  }
109
- export function summarize(results, manualChecklist, externalChecklist) {
74
+ function summarize(results, manualChecklist, externalChecklist) {
110
75
  const errorCount = results.filter((result) => result.status === 'fail').length;
111
76
  const warningCount = results.filter((result) => result.status === 'warning').length;
112
77
  const manualCount = manualChecklist.length;
@@ -129,29 +94,3 @@ export function summarize(results, manualChecklist, externalChecklist) {
129
94
  externalCount,
130
95
  };
131
96
  }
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,21 +4,14 @@ 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;
11
7
  }
12
- /** Bounded ZIP reader used for both local reports and untrusted uploaded bytes. */
13
8
  export declare class SimpleZipReader {
14
9
  private readonly buffer;
15
10
  private entriesCache?;
16
11
  constructor(buffer: Buffer);
17
12
  listEntries(): ZipEntryInfo[];
18
13
  readEntryText(entryPath: string): string | null;
19
- readEntry(entryPath: string): Buffer | null;
20
14
  private readCentralDirectory;
21
15
  private readEntryData;
22
16
  private findEndOfCentralDirectory;
23
- private requireRange;
24
17
  }