@playcraft/build 0.2.19-test-a → 0.2.21

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 -42
  2. package/dist/engines/engine-detector.js +0 -4
  3. package/dist/engines/generic-adapter.js +19 -14
  4. package/dist/engines/playable-scripts-adapter.js +5 -2
  5. package/dist/index.d.ts +6 -19
  6. package/dist/index.js +3 -11
  7. package/dist/platforms/adikteev.js +0 -1
  8. package/dist/platforms/applovin.js +0 -1
  9. package/dist/platforms/base.js +6 -33
  10. package/dist/platforms/bigo.js +0 -1
  11. package/dist/platforms/facebook.js +0 -1
  12. package/dist/platforms/google.js +0 -1
  13. package/dist/platforms/inmobi.js +0 -1
  14. package/dist/platforms/ironsource.js +0 -1
  15. package/dist/platforms/liftoff.js +0 -1
  16. package/dist/platforms/mintegral.js +0 -1
  17. package/dist/platforms/moloco.js +0 -1
  18. package/dist/platforms/playcraft.js +0 -1
  19. package/dist/platforms/remerge.js +0 -1
  20. package/dist/platforms/snapchat.js +0 -1
  21. package/dist/platforms/tiktok.js +0 -1
  22. package/dist/platforms/unity.js +0 -1
  23. package/dist/redirect-artifact.d.ts +30 -0
  24. package/dist/redirect-artifact.js +83 -0
  25. package/dist/types.d.ts +2 -9
  26. package/dist/validation/html-validator.d.ts +0 -5
  27. package/dist/validation/html-validator.js +17 -19
  28. package/dist/validation/index.d.ts +0 -5
  29. package/dist/validation/index.js +0 -5
  30. package/dist/validation/package-validator.d.ts +0 -2
  31. package/dist/validation/package-validator.js +64 -25
  32. package/dist/validation/profiles.d.ts +1 -13
  33. package/dist/validation/profiles.js +0 -27
  34. package/dist/validation/source-scanner.d.ts +0 -11
  35. package/dist/validation/source-scanner.js +2 -32
  36. package/dist/validation/types.d.ts +2 -201
  37. package/dist/validation/types.js +1 -1
  38. package/dist/validation/validation-runner.d.ts +2 -22
  39. package/dist/validation/validation-runner.js +3 -64
  40. package/dist/validation/zip-reader.d.ts +0 -7
  41. package/dist/validation/zip-reader.js +26 -159
  42. package/dist/vite/config-builder-generic.d.ts +1 -3
  43. package/dist/vite/config-builder-generic.js +7 -9
  44. package/dist/vite/config-builder.js +1 -1
  45. package/dist/vite/plugin-platform.js +30 -16
  46. package/dist/vite/plugin-source-builder.d.ts +14 -2
  47. package/dist/vite/plugin-source-builder.js +997 -61
  48. package/dist/vite-builder.d.ts +5 -4
  49. package/dist/vite-builder.js +34 -33
  50. package/package.json +4 -30
  51. package/templates/patches/one-page-mraid-resize-canvas.js +2 -0
  52. package/templates/patches/playcraft-redirect-policy.js +17 -1
  53. package/dist/audio-source-files.d.ts +0 -5
  54. package/dist/audio-source-files.js +0 -135
  55. package/dist/delivery/agent-build-runner.d.ts +0 -44
  56. package/dist/delivery/agent-build-runner.js +0 -365
  57. package/dist/delivery/agent-build-source.d.ts +0 -8
  58. package/dist/delivery/agent-build-source.js +0 -25
  59. package/dist/delivery/artifact-descriptor.d.ts +0 -31
  60. package/dist/delivery/artifact-descriptor.js +0 -237
  61. package/dist/delivery/artifact-package.d.ts +0 -43
  62. package/dist/delivery/artifact-package.js +0 -283
  63. package/dist/delivery/build-plan.d.ts +0 -4
  64. package/dist/delivery/build-plan.js +0 -189
  65. package/dist/delivery/build-plan.types.d.ts +0 -51
  66. package/dist/delivery/build-plan.types.js +0 -1
  67. package/dist/delivery/command-isolation.d.ts +0 -21
  68. package/dist/delivery/command-isolation.js +0 -327
  69. package/dist/delivery/commands.d.ts +0 -5
  70. package/dist/delivery/commands.js +0 -146
  71. package/dist/delivery/files.d.ts +0 -9
  72. package/dist/delivery/files.js +0 -144
  73. package/dist/delivery/git-source-fingerprint.d.ts +0 -2
  74. package/dist/delivery/git-source-fingerprint.js +0 -58
  75. package/dist/delivery/isolated-source.d.ts +0 -5
  76. package/dist/delivery/isolated-source.js +0 -148
  77. package/dist/delivery/output-publication.d.ts +0 -21
  78. package/dist/delivery/output-publication.js +0 -444
  79. package/dist/delivery/project-delivery.d.ts +0 -6
  80. package/dist/delivery/project-delivery.js +0 -287
  81. package/dist/delivery/recipe-build-plan.d.ts +0 -4
  82. package/dist/delivery/recipe-build-plan.js +0 -53
  83. package/dist/delivery/recipe.d.ts +0 -20
  84. package/dist/delivery/recipe.js +0 -211
  85. package/dist/delivery/safe-path.d.ts +0 -2
  86. package/dist/delivery/safe-path.js +0 -18
  87. package/dist/delivery/types.d.ts +0 -81
  88. package/dist/delivery/types.js +0 -1
  89. package/dist/production-animation-presence.d.ts +0 -2
  90. package/dist/production-animation-presence.js +0 -146
  91. package/dist/production-inputs.d.ts +0 -30
  92. package/dist/production-inputs.js +0 -262
  93. package/dist/production-source-paths.d.ts +0 -5
  94. package/dist/production-source-paths.js +0 -27
  95. package/dist/validation/artifact-qa.d.ts +0 -36
  96. package/dist/validation/artifact-qa.js +0 -263
  97. package/dist/validation/artifact-rules.d.ts +0 -39
  98. package/dist/validation/artifact-rules.js +0 -451
  99. package/dist/validation/artifact.d.ts +0 -14
  100. package/dist/validation/artifact.js +0 -188
  101. package/dist/validation/playwright-driver.d.ts +0 -37
  102. package/dist/validation/playwright-driver.js +0 -302
  103. package/dist/validation/runtime-cover.d.ts +0 -32
  104. package/dist/validation/runtime-cover.js +0 -120
  105. package/dist/validation/runtime-load.d.ts +0 -141
  106. package/dist/validation/runtime-load.js +0 -812
  107. package/dist/vite/source-builder-asset-paths.d.ts +0 -25
  108. package/dist/vite/source-builder-asset-paths.js +0 -154
  109. package/dist/vite/source-builder-esm.d.ts +0 -7
  110. package/dist/vite/source-builder-esm.js +0 -877
  111. package/dist/vite/source-builder-types.d.ts +0 -14
  112. package/dist/vite/source-builder-types.js +0 -1
  113. package/dist/vite/workspace.d.ts +0 -6
  114. package/dist/vite/workspace.js +0 -41
  115. package/dist/workspace-css-imports.d.ts +0 -2
  116. package/dist/workspace-css-imports.js +0 -139
  117. package/dist/workspace-model-source.d.ts +0 -14
  118. package/dist/workspace-model-source.js +0 -184
  119. package/dist/workspace-public-imports.d.ts +0 -11
  120. package/dist/workspace-public-imports.js +0 -232
  121. package/dist/workspace-public-source.d.ts +0 -15
  122. package/dist/workspace-public-source.js +0 -564
@@ -3,33 +3,31 @@ import { getRulesForStage } from './profiles.js';
3
3
  const RESOURCE_ATTR_RE = /\b(?:src|href|data)\s*=\s*["']([^"']+)["']/gi;
4
4
  const CSS_URL_RE = /url\(\s*["']?([^"')]+)["']?\s*\)/gi;
5
5
  export async function validateHtmlArtifact(context, profile) {
6
- if (context.htmlContent !== undefined) {
7
- return validateHtmlArtifactContent(context, context.htmlContent, context.htmlPath, profile);
8
- }
6
+ const rules = profile?.rules.filter((rule) => rule.stage === 'html-artifact')
7
+ ?? getRulesForStage(context.channel, 'html-artifact');
9
8
  if (!context.htmlPath) {
10
9
  return [missingHtmlResult(context.channel)];
11
10
  }
11
+ let artifact;
12
12
  try {
13
- const content = await fs.readFile(context.htmlPath);
14
- return validateHtmlArtifactContent(context, content, context.htmlPath, profile);
13
+ const [content, stat] = await Promise.all([
14
+ fs.readFile(context.htmlPath, 'utf-8'),
15
+ fs.stat(context.htmlPath),
16
+ ]);
17
+ artifact = {
18
+ path: context.htmlPath,
19
+ content,
20
+ size: stat.size,
21
+ };
15
22
  }
16
23
  catch (error) {
17
24
  return [missingHtmlResult(context.channel, context.htmlPath, error)];
18
25
  }
19
- }
20
- /** Validates the exact final bytes, including objects downloaded by Business. */
21
- export function validateHtmlArtifactContent(context, content, displayPath = 'index.html', profile) {
22
- const rules = profile?.rules.filter((rule) => rule.stage === 'html-artifact')
23
- ?? getRulesForStage(context.channel, 'html-artifact');
24
- const artifact = {
25
- path: displayPath,
26
- content: typeof content === 'string' ? content : Buffer.from(content).toString('utf-8'),
27
- size: typeof content === 'string' ? Buffer.byteLength(content) : content.byteLength,
28
- };
29
26
  const results = [];
30
27
  for (const rule of rules) {
31
- if (!rule.detectable || !rule.check)
28
+ if (!rule.detectable || !rule.check) {
32
29
  continue;
30
+ }
33
31
  results.push(evaluateHtmlRule(rule, artifact));
34
32
  }
35
33
  return results;
@@ -89,10 +87,10 @@ function resultFromBoolean(rule, passed, file, evidence) {
89
87
  confidence: rule.confidence,
90
88
  };
91
89
  }
92
- export function collectExternalResources(html) {
90
+ function collectExternalResources(html) {
93
91
  return collectUrls(html).filter((url) => /^https?:\/\//i.test(url) || /^\/\//.test(url));
94
92
  }
95
- export function collectLocalResourceReferences(html) {
93
+ function collectLocalResourceReferences(html) {
96
94
  return collectUrls(html).filter((url) => {
97
95
  if (isInlineOrSpecialUrl(url))
98
96
  return false;
@@ -116,7 +114,7 @@ function collectUrls(html) {
116
114
  function isInlineOrSpecialUrl(url) {
117
115
  return /^(data:|blob:|javascript:|mailto:|tel:|about:)/i.test(url);
118
116
  }
119
- export function isAllowedExternalResource(url, allowedPatterns) {
117
+ function isAllowedExternalResource(url, allowedPatterns) {
120
118
  if (!allowedPatterns || allowedPatterns.length === 0) {
121
119
  return false;
122
120
  }
@@ -1,8 +1,4 @@
1
1
  export * from './types.js';
2
- export * from './artifact.js';
3
- export * from './artifact-rules.js';
4
- export * from './artifact-qa.js';
5
- export * from './runtime-load.js';
6
2
  export * from './profiles.js';
7
3
  export * from './html-validator.js';
8
4
  export * from './package-validator.js';
@@ -10,4 +6,3 @@ export * from './reporter.js';
10
6
  export * from './source-scanner.js';
11
7
  export * from './validation-runner.js';
12
8
  export * from './zip-reader.js';
13
- export * from './runtime-cover.js';
@@ -1,8 +1,4 @@
1
1
  export * from './types.js';
2
- export * from './artifact.js';
3
- export * from './artifact-rules.js';
4
- export * from './artifact-qa.js';
5
- export * from './runtime-load.js';
6
2
  export * from './profiles.js';
7
3
  export * from './html-validator.js';
8
4
  export * from './package-validator.js';
@@ -10,4 +6,3 @@ export * from './reporter.js';
10
6
  export * from './source-scanner.js';
11
7
  export * from './validation-runner.js';
12
8
  export * from './zip-reader.js';
13
- export * from './runtime-cover.js';
@@ -1,4 +1,2 @@
1
- import type { Platform } from '../types.js';
2
1
  import type { ChannelRuleProfile, ValidationContext, ValidationResult } from './types.js';
3
2
  export declare function validateDeliveryPackage(context: ValidationContext, profile?: ChannelRuleProfile): Promise<ValidationResult[]>;
4
- export declare function validateSingleHtmlPackage(channel: Platform, bytes: Uint8Array, artifactName?: string): ValidationResult[];
@@ -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;