@playcraft/build 0.1.91 → 0.1.93-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-builder.js +2 -41
- package/dist/engines/engine-detector.js +0 -4
- package/dist/engines/generic-adapter.js +19 -14
- package/dist/index.d.ts +4 -19
- package/dist/index.js +2 -11
- package/dist/platforms/adikteev.js +0 -1
- package/dist/platforms/applovin.js +0 -1
- package/dist/platforms/base.js +2 -2
- package/dist/platforms/bigo.js +0 -1
- package/dist/platforms/facebook.js +0 -1
- package/dist/platforms/google.js +0 -1
- package/dist/platforms/inmobi.js +0 -1
- package/dist/platforms/ironsource.js +0 -1
- package/dist/platforms/liftoff.js +0 -1
- package/dist/platforms/mintegral.js +0 -1
- package/dist/platforms/moloco.js +0 -1
- package/dist/platforms/playcraft.js +0 -1
- package/dist/platforms/remerge.js +0 -1
- package/dist/platforms/snapchat.js +0 -1
- package/dist/platforms/tiktok.js +0 -1
- package/dist/platforms/unity.js +0 -1
- package/dist/types.d.ts +0 -5
- package/dist/validation/html-validator.d.ts +0 -5
- package/dist/validation/html-validator.js +17 -19
- package/dist/validation/index.d.ts +0 -4
- package/dist/validation/index.js +0 -4
- package/dist/validation/package-validator.d.ts +0 -2
- package/dist/validation/package-validator.js +64 -25
- package/dist/validation/profiles.d.ts +1 -13
- package/dist/validation/profiles.js +0 -27
- package/dist/validation/source-scanner.d.ts +0 -11
- package/dist/validation/source-scanner.js +2 -32
- package/dist/validation/types.d.ts +2 -155
- package/dist/validation/types.js +1 -1
- package/dist/validation/validation-runner.d.ts +2 -22
- package/dist/validation/validation-runner.js +3 -68
- package/dist/validation/zip-reader.d.ts +0 -7
- package/dist/validation/zip-reader.js +26 -159
- package/dist/vite/config-builder-generic.d.ts +1 -3
- package/dist/vite/config-builder-generic.js +7 -9
- package/dist/vite/config-builder.js +1 -1
- package/dist/vite/plugin-platform.js +54 -30
- package/dist/vite/plugin-source-builder.d.ts +14 -2
- package/dist/vite/plugin-source-builder.js +997 -61
- package/dist/vite-builder.d.ts +5 -4
- package/dist/vite-builder.js +34 -33
- package/package.json +4 -16
- package/dist/audio-source-files.d.ts +0 -5
- package/dist/audio-source-files.js +0 -135
- package/dist/delivery/agent-build-runner.d.ts +0 -44
- package/dist/delivery/agent-build-runner.js +0 -365
- package/dist/delivery/agent-build-source.d.ts +0 -8
- package/dist/delivery/agent-build-source.js +0 -25
- package/dist/delivery/artifact-descriptor.d.ts +0 -31
- package/dist/delivery/artifact-descriptor.js +0 -237
- package/dist/delivery/artifact-package.d.ts +0 -43
- package/dist/delivery/artifact-package.js +0 -283
- package/dist/delivery/build-plan.d.ts +0 -4
- package/dist/delivery/build-plan.js +0 -189
- package/dist/delivery/build-plan.types.d.ts +0 -51
- package/dist/delivery/build-plan.types.js +0 -1
- package/dist/delivery/command-isolation.d.ts +0 -7
- package/dist/delivery/command-isolation.js +0 -252
- package/dist/delivery/commands.d.ts +0 -5
- package/dist/delivery/commands.js +0 -137
- package/dist/delivery/files.d.ts +0 -9
- package/dist/delivery/files.js +0 -144
- package/dist/delivery/git-source-fingerprint.d.ts +0 -2
- package/dist/delivery/git-source-fingerprint.js +0 -58
- package/dist/delivery/isolated-source.d.ts +0 -5
- package/dist/delivery/isolated-source.js +0 -126
- package/dist/delivery/output-publication.d.ts +0 -21
- package/dist/delivery/output-publication.js +0 -444
- package/dist/delivery/project-delivery.d.ts +0 -6
- package/dist/delivery/project-delivery.js +0 -287
- package/dist/delivery/recipe-build-plan.d.ts +0 -4
- package/dist/delivery/recipe-build-plan.js +0 -53
- package/dist/delivery/recipe.d.ts +0 -20
- package/dist/delivery/recipe.js +0 -211
- package/dist/delivery/safe-path.d.ts +0 -2
- package/dist/delivery/safe-path.js +0 -18
- package/dist/delivery/types.d.ts +0 -76
- package/dist/delivery/types.js +0 -1
- package/dist/production-animation-presence.d.ts +0 -2
- package/dist/production-animation-presence.js +0 -146
- package/dist/production-inputs.d.ts +0 -30
- package/dist/production-inputs.js +0 -262
- package/dist/production-source-paths.d.ts +0 -5
- package/dist/production-source-paths.js +0 -27
- package/dist/validation/artifact-qa.d.ts +0 -44
- package/dist/validation/artifact-qa.js +0 -170
- package/dist/validation/artifact-rules.d.ts +0 -28
- package/dist/validation/artifact-rules.js +0 -440
- package/dist/validation/artifact.d.ts +0 -14
- package/dist/validation/artifact.js +0 -188
- package/dist/validation/runtime-load.d.ts +0 -89
- package/dist/validation/runtime-load.js +0 -654
- package/dist/vite/source-builder-asset-paths.d.ts +0 -25
- package/dist/vite/source-builder-asset-paths.js +0 -154
- package/dist/vite/source-builder-esm.d.ts +0 -7
- package/dist/vite/source-builder-esm.js +0 -877
- package/dist/vite/source-builder-types.d.ts +0 -14
- package/dist/vite/source-builder-types.js +0 -1
- package/dist/vite/workspace.d.ts +0 -6
- package/dist/vite/workspace.js +0 -41
- package/dist/workspace-css-imports.d.ts +0 -2
- package/dist/workspace-css-imports.js +0 -139
- package/dist/workspace-model-source.d.ts +0 -14
- package/dist/workspace-model-source.js +0 -184
- package/dist/workspace-public-imports.d.ts +0 -11
- package/dist/workspace-public-imports.js +0 -232
- package/dist/workspace-public-source.d.ts +0 -15
- package/dist/workspace-public-source.js +0 -564
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { runBaseStage } from './artifact-rules.js';
|
|
4
|
-
import { runRuntimeLoadStage } from './runtime-load.js';
|
|
5
|
-
import { findSourcePatterns, scanSourceForCompliance } from './source-scanner.js';
|
|
6
|
-
import { idleStageReport, ranStageReport, runPlayableValidation, summarize, } from './validation-runner.js';
|
|
7
|
-
import { QA_STAGES, } from './types.js';
|
|
8
|
-
export const ARTIFACT_QA_REPORT_VERSION = '0.2.0';
|
|
9
|
-
/** Bump when an artifact rule, its severity or its matching changes. */
|
|
10
|
-
export const ARTIFACT_QA_RULES_VERSION = '2026-11-10.1';
|
|
11
|
-
const ADSDK_PACKAGE = '@playcraft/adsdk';
|
|
12
|
-
/** Published adsdk methods are `playcraftInit` etc.; the short names appear in skills and templates. */
|
|
13
|
-
const ADSDK_CALLS = {
|
|
14
|
-
init: /\bsdk\s*\.\s*(?:init|playcraftInit)\s*\(/g,
|
|
15
|
-
start: /\bsdk\s*\.\s*(?:start|playcraftStart)\s*\(/g,
|
|
16
|
-
interactive: /\bsdk\s*\.\s*(?:interactive|playcraftInteractive)\s*\(/g,
|
|
17
|
-
finish: /\bsdk\s*\.\s*(?:finish|playcraftFinish)\s*\(/g,
|
|
18
|
-
install: /\bsdk\s*\.\s*(?:install|playcraftInstall)\s*\(/g,
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Judges a built artifact by running each requested stage independently and collecting their
|
|
22
|
-
* reports. Stages never read each other's results, so any stage can also be called on its own.
|
|
23
|
-
* Results depend only on the artifact and the options, never on how the artifact was built.
|
|
24
|
-
*/
|
|
25
|
-
export async function runArtifactQa(artifact, options = {}) {
|
|
26
|
-
const profile = options.profile ?? 'playcraft';
|
|
27
|
-
const stages = [];
|
|
28
|
-
for (const stage of options.stages ?? QA_STAGES)
|
|
29
|
-
stages.push(await runStage(stage, artifact, { ...options, profile }));
|
|
30
|
-
const counted = stages.filter((stage) => stage.status === 'ran' && !stage.advisory);
|
|
31
|
-
return {
|
|
32
|
-
version: ARTIFACT_QA_REPORT_VERSION,
|
|
33
|
-
rulesVersion: ARTIFACT_QA_RULES_VERSION,
|
|
34
|
-
profile,
|
|
35
|
-
artifact: {
|
|
36
|
-
sourcePath: artifact.sourcePath,
|
|
37
|
-
container: artifact.container,
|
|
38
|
-
layout: artifact.layout,
|
|
39
|
-
entry: artifact.entry,
|
|
40
|
-
digest: artifact.digest,
|
|
41
|
-
totalSize: artifact.totalSize,
|
|
42
|
-
fileCount: artifact.files.length,
|
|
43
|
-
},
|
|
44
|
-
summary: summarize(counted.flatMap((stage) => stage.results), counted.flatMap((stage) => stage.manualChecklist), counted.flatMap((stage) => stage.externalChecklist)),
|
|
45
|
-
incomplete: stages.some((stage) => stage.status === 'skipped' && !stage.advisory),
|
|
46
|
-
stages,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function runStage(stage, artifact, options) {
|
|
50
|
-
switch (stage) {
|
|
51
|
-
case 'base':
|
|
52
|
-
return runBaseStage(artifact, {
|
|
53
|
-
profile: options.profile,
|
|
54
|
-
...(options.sizeLimitBytes !== undefined ? { sizeLimitBytes: options.sizeLimitBytes } : {}),
|
|
55
|
-
});
|
|
56
|
-
case 'channel':
|
|
57
|
-
return runChannelStage(artifact, { profile: options.profile });
|
|
58
|
-
case 'runtime-load':
|
|
59
|
-
return options.driver
|
|
60
|
-
? runRuntimeLoadStage(artifact, {
|
|
61
|
-
driver: options.driver,
|
|
62
|
-
profile: options.profile,
|
|
63
|
-
...options.runtime,
|
|
64
|
-
})
|
|
65
|
-
: Promise.resolve(idleStageReport('runtime-load', 'skipped', options.driverUnavailableReason ?? 'No headless browser driver was provided'));
|
|
66
|
-
case 'source-hints':
|
|
67
|
-
return options.projectRoot
|
|
68
|
-
? runSourceHintsStage({
|
|
69
|
-
projectRoot: options.projectRoot,
|
|
70
|
-
profile: options.profile,
|
|
71
|
-
...(options.sourceGlobs ? { sourceGlobs: options.sourceGlobs } : {}),
|
|
72
|
-
})
|
|
73
|
-
: Promise.resolve(idleStageReport('source-hints', 'skipped', 'No project root was provided', true));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* `channel` stage: the channel's existing `html-artifact` / `delivery-package` rules, the same
|
|
78
|
-
* rules export validation uses. Needs only the artifact and a channel profile.
|
|
79
|
-
*/
|
|
80
|
-
export async function runChannelStage(artifact, options) {
|
|
81
|
-
if (options.profile === 'playcraft')
|
|
82
|
-
return idleStageReport('channel', 'not-applicable', 'The playcraft profile has no channel rules');
|
|
83
|
-
const startedAt = Date.now();
|
|
84
|
-
const report = await runPlayableValidation({
|
|
85
|
-
projectRoot: path.dirname(artifact.sourcePath),
|
|
86
|
-
channel: options.profile,
|
|
87
|
-
engine: 'unknown',
|
|
88
|
-
buildChain: 'generic',
|
|
89
|
-
...channelPaths(artifact),
|
|
90
|
-
}, stagesFor(artifact));
|
|
91
|
-
return ranStageReport('channel', startedAt, report.results, {
|
|
92
|
-
manualChecklist: report.manualChecklist,
|
|
93
|
-
externalChecklist: report.externalChecklist,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* `source-hints` stage: scans project source to help locate problems. Advisory: it never affects
|
|
98
|
-
* the overall result. Needs only the project root.
|
|
99
|
-
*/
|
|
100
|
-
export async function runSourceHintsStage(options) {
|
|
101
|
-
const startedAt = Date.now();
|
|
102
|
-
const results = await collectSourceHints(options.projectRoot, options.profile ?? 'playcraft', options.sourceGlobs);
|
|
103
|
-
return ranStageReport('source-hints', startedAt, results, { advisory: true });
|
|
104
|
-
}
|
|
105
|
-
/** Same stage choice as the workspace delivery re-check: HTML artifacts, or the delivery package. */
|
|
106
|
-
function stagesFor(artifact) {
|
|
107
|
-
if (artifact.container === 'html')
|
|
108
|
-
return ['html-artifact'];
|
|
109
|
-
if (artifact.container === 'zip')
|
|
110
|
-
return ['delivery-package'];
|
|
111
|
-
return ['html-artifact', 'delivery-package'];
|
|
112
|
-
}
|
|
113
|
-
function channelPaths(artifact) {
|
|
114
|
-
if (artifact.container === 'html')
|
|
115
|
-
return { htmlPath: artifact.sourcePath };
|
|
116
|
-
if (artifact.container === 'zip')
|
|
117
|
-
return { packagePath: artifact.sourcePath };
|
|
118
|
-
return {
|
|
119
|
-
htmlPath: path.join(artifact.sourcePath, artifact.entry),
|
|
120
|
-
packagePath: artifact.sourcePath,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
async function collectSourceHints(projectRoot, profile, sourceGlobs) {
|
|
124
|
-
const root = path.resolve(projectRoot);
|
|
125
|
-
const relative = (file) => file && path.isAbsolute(file) ? path.relative(root, file).replace(/\\/g, '/') : file;
|
|
126
|
-
const hints = (await scanSourceForCompliance({
|
|
127
|
-
projectRoot: root,
|
|
128
|
-
channel: profile,
|
|
129
|
-
engine: 'unknown',
|
|
130
|
-
buildChain: 'generic',
|
|
131
|
-
...(sourceGlobs ? { sourceGlobs } : {}),
|
|
132
|
-
})).filter((hint) => hint.status !== 'pass');
|
|
133
|
-
hints.push(...(await adsdkHints(root, sourceGlobs)));
|
|
134
|
-
return hints.map((hint) => ({
|
|
135
|
-
...hint,
|
|
136
|
-
...(hint.file ? { file: relative(hint.file) } : {}),
|
|
137
|
-
}));
|
|
138
|
-
}
|
|
139
|
-
async function adsdkHints(root, sourceGlobs) {
|
|
140
|
-
const hint = (ruleId, message, recommendation) => ({
|
|
141
|
-
ruleId,
|
|
142
|
-
channel: 'common',
|
|
143
|
-
stage: 'prebuild-source',
|
|
144
|
-
severity: 'warning',
|
|
145
|
-
status: 'warning',
|
|
146
|
-
message,
|
|
147
|
-
recommendation,
|
|
148
|
-
owner: 'playcraft-build',
|
|
149
|
-
confidence: 'medium',
|
|
150
|
-
});
|
|
151
|
-
if (!(await dependsOn(root, ADSDK_PACKAGE)))
|
|
152
|
-
return [
|
|
153
|
-
hint('common.adsdk.dependency.missing', `The project does not depend on ${ADSDK_PACKAGE}.`, `Install ${ADSDK_PACKAGE} and wire sdk.init, start, interactive, finish and install, so CTA and lifecycle signals reach every channel.`),
|
|
154
|
-
];
|
|
155
|
-
const found = await findSourcePatterns(root, ADSDK_CALLS, sourceGlobs);
|
|
156
|
-
return Object.keys(ADSDK_CALLS)
|
|
157
|
-
.filter((call) => !found.has(call))
|
|
158
|
-
.map((call) => hint(`common.adsdk.${call}.missing`, `No sdk.${call}() call was found in the project source.`, call === 'install'
|
|
159
|
-
? 'Call sdk.install() from the download / CTA button.'
|
|
160
|
-
: `Call sdk.${call}() at the matching lifecycle point (init → start → interactive → finish → install).`));
|
|
161
|
-
}
|
|
162
|
-
async function dependsOn(root, name) {
|
|
163
|
-
try {
|
|
164
|
-
const manifest = JSON.parse(await fs.readFile(path.join(root, 'package.json'), 'utf-8'));
|
|
165
|
-
return Boolean(manifest.dependencies?.[name] ?? manifest.devDependencies?.[name]);
|
|
166
|
-
}
|
|
167
|
-
catch {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Platform } from '../types.js';
|
|
2
|
-
import type { PlayableArtifact, QaStageReport } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* `base-output` rules: channel-independent checks that read the built artifact only. They do not
|
|
5
|
-
* depend on the engine or the build tool that produced the artifact.
|
|
6
|
-
*/
|
|
7
|
-
export declare const BASE_OUTPUT_RULE_IDS: {
|
|
8
|
-
readonly entryParsable: "common.artifact.entry.parsable";
|
|
9
|
-
readonly sizeBudget: "common.artifact.size.budget";
|
|
10
|
-
readonly localReference: "common.artifact.local-reference.resolvable";
|
|
11
|
-
readonly externalResource: "common.artifact.external-resource.forbidden";
|
|
12
|
-
readonly devAddress: "common.artifact.dev-address.forbidden";
|
|
13
|
-
readonly inlineData: "common.artifact.inline-data.valid";
|
|
14
|
-
readonly sizeBreakdown: "common.artifact.size.breakdown";
|
|
15
|
-
readonly debugResidue: "common.artifact.debug-residue.review";
|
|
16
|
-
readonly directRedirect: "common.artifact.redirect.direct.review";
|
|
17
|
-
readonly persistentStorage: "common.artifact.storage.persistent.review";
|
|
18
|
-
readonly viewportMeta: "common.artifact.viewport-meta.present";
|
|
19
|
-
};
|
|
20
|
-
export type BaseOutputRuleId = (typeof BASE_OUTPUT_RULE_IDS)[keyof typeof BASE_OUTPUT_RULE_IDS];
|
|
21
|
-
export interface BaseStageOptions {
|
|
22
|
-
/** Profile whose external-resource allowlist applies; default `playcraft`. */
|
|
23
|
-
profile?: Platform;
|
|
24
|
-
/** Size limit of the profile; default 5 MB, the cap most channels use. */
|
|
25
|
-
sizeLimitBytes?: number;
|
|
26
|
-
}
|
|
27
|
-
/** `base` stage: static checks of the artifact files. Needs only the artifact. */
|
|
28
|
-
export declare function runBaseStage(artifact: PlayableArtifact, options?: BaseStageOptions): Promise<QaStageReport>;
|
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { formatBytes } from '../utils.js';
|
|
3
|
-
import { collectExternalResources, collectLocalResourceReferences, isAllowedExternalResource, } from './html-validator.js';
|
|
4
|
-
import { getChannelRuleProfile } from './profiles.js';
|
|
5
|
-
import { ranStageReport } from './validation-runner.js';
|
|
6
|
-
/**
|
|
7
|
-
* `base-output` rules: channel-independent checks that read the built artifact only. They do not
|
|
8
|
-
* depend on the engine or the build tool that produced the artifact.
|
|
9
|
-
*/
|
|
10
|
-
export const BASE_OUTPUT_RULE_IDS = {
|
|
11
|
-
entryParsable: 'common.artifact.entry.parsable',
|
|
12
|
-
sizeBudget: 'common.artifact.size.budget',
|
|
13
|
-
localReference: 'common.artifact.local-reference.resolvable',
|
|
14
|
-
externalResource: 'common.artifact.external-resource.forbidden',
|
|
15
|
-
devAddress: 'common.artifact.dev-address.forbidden',
|
|
16
|
-
inlineData: 'common.artifact.inline-data.valid',
|
|
17
|
-
sizeBreakdown: 'common.artifact.size.breakdown',
|
|
18
|
-
debugResidue: 'common.artifact.debug-residue.review',
|
|
19
|
-
directRedirect: 'common.artifact.redirect.direct.review',
|
|
20
|
-
persistentStorage: 'common.artifact.storage.persistent.review',
|
|
21
|
-
viewportMeta: 'common.artifact.viewport-meta.present',
|
|
22
|
-
};
|
|
23
|
-
/** Reference limit when no finite limit is given: most channels cap creatives at 5 MB. */
|
|
24
|
-
const DEFAULT_SIZE_LIMIT = 5 * 1024 * 1024;
|
|
25
|
-
/** `base` stage: static checks of the artifact files. Needs only the artifact. */
|
|
26
|
-
export async function runBaseStage(artifact, options = {}) {
|
|
27
|
-
const startedAt = Date.now();
|
|
28
|
-
const sizeLimitBytes = options.sizeLimitBytes !== undefined && Number.isFinite(options.sizeLimitBytes)
|
|
29
|
-
? options.sizeLimitBytes
|
|
30
|
-
: DEFAULT_SIZE_LIMIT;
|
|
31
|
-
const externalCheck = getChannelRuleProfile(options.profile ?? 'playcraft').rules.find((rule) => rule.stage === 'html-artifact' && rule.check?.kind === 'external-resources')?.check;
|
|
32
|
-
const allowedExternalPatterns = externalCheck?.kind === 'external-resources' ? externalCheck.allowedPatterns : undefined;
|
|
33
|
-
const results = await runBaseOutputChecks(artifact, {
|
|
34
|
-
sizeLimitBytes,
|
|
35
|
-
...(allowedExternalPatterns ? { allowedExternalPatterns } : {}),
|
|
36
|
-
});
|
|
37
|
-
return ranStageReport('base', startedAt, results, { details: { sizeLimitBytes } });
|
|
38
|
-
}
|
|
39
|
-
const RULES = {
|
|
40
|
-
[BASE_OUTPUT_RULE_IDS.entryParsable]: {
|
|
41
|
-
title: 'Entry HTML is valid UTF-8 and contains HTML markup',
|
|
42
|
-
severity: 'error',
|
|
43
|
-
recommendation: 'Make the build write a UTF-8 HTML entry file.',
|
|
44
|
-
confidence: 'high',
|
|
45
|
-
},
|
|
46
|
-
[BASE_OUTPUT_RULE_IDS.sizeBudget]: {
|
|
47
|
-
title: 'Artifact stays within the size limit',
|
|
48
|
-
severity: 'error',
|
|
49
|
-
recommendation: 'Compress images and audio, remove unused assets, or enable image compression when exporting. The final channel package size decides delivery.',
|
|
50
|
-
confidence: 'medium',
|
|
51
|
-
},
|
|
52
|
-
[BASE_OUTPUT_RULE_IDS.localReference]: {
|
|
53
|
-
title: 'Every local file the artifact references is inside the artifact',
|
|
54
|
-
severity: 'error',
|
|
55
|
-
recommendation: 'Inline the referenced file, or include it in the build output at the referenced path.',
|
|
56
|
-
confidence: 'high',
|
|
57
|
-
},
|
|
58
|
-
[BASE_OUTPUT_RULE_IDS.externalResource]: {
|
|
59
|
-
title: 'Artifact does not load remote scripts, styles, images, fonts or media',
|
|
60
|
-
severity: 'error',
|
|
61
|
-
recommendation: 'Bundle or inline the resource; a playable must run without network access except for channel SDKs the channel provides.',
|
|
62
|
-
confidence: 'high',
|
|
63
|
-
},
|
|
64
|
-
[BASE_OUTPUT_RULE_IDS.devAddress]: {
|
|
65
|
-
title: 'Artifact contains no local development addresses or machine paths',
|
|
66
|
-
severity: 'error',
|
|
67
|
-
recommendation: 'Build in production mode and remove references to localhost, the dev server or absolute local paths.',
|
|
68
|
-
confidence: 'medium',
|
|
69
|
-
},
|
|
70
|
-
[BASE_OUTPUT_RULE_IDS.inlineData]: {
|
|
71
|
-
title: 'Inline base64 data decodes and matches its declared type',
|
|
72
|
-
severity: 'error',
|
|
73
|
-
recommendation: 'Re-encode the asset, or fix the declared MIME type of the data URI.',
|
|
74
|
-
confidence: 'high',
|
|
75
|
-
},
|
|
76
|
-
[BASE_OUTPUT_RULE_IDS.sizeBreakdown]: {
|
|
77
|
-
title: 'Size breakdown by asset type',
|
|
78
|
-
severity: 'info',
|
|
79
|
-
recommendation: 'Start size reductions with the largest categories and items.',
|
|
80
|
-
confidence: 'high',
|
|
81
|
-
},
|
|
82
|
-
[BASE_OUTPUT_RULE_IDS.debugResidue]: {
|
|
83
|
-
title: 'Artifact contains no source maps or debugging tools',
|
|
84
|
-
severity: 'warning',
|
|
85
|
-
recommendation: 'Disable source maps in the production build and remove debug panels, consoles and debugger statements.',
|
|
86
|
-
confidence: 'medium',
|
|
87
|
-
},
|
|
88
|
-
[BASE_OUTPUT_RULE_IDS.directRedirect]: {
|
|
89
|
-
title: 'Artifact does not redirect directly',
|
|
90
|
-
severity: 'warning',
|
|
91
|
-
recommendation: 'Open the store through the ad SDK CTA (sdk.install()) after a user tap instead of window.open or location.',
|
|
92
|
-
confidence: 'medium',
|
|
93
|
-
},
|
|
94
|
-
[BASE_OUTPUT_RULE_IDS.viewportMeta]: {
|
|
95
|
-
title: 'Entry HTML declares a mobile viewport',
|
|
96
|
-
severity: 'error',
|
|
97
|
-
recommendation: 'Add <meta name="viewport" content="width=device-width, initial-scale=1"> to the entry HTML head; without it mobile browsers lay the page out at desktop width.',
|
|
98
|
-
confidence: 'high',
|
|
99
|
-
},
|
|
100
|
-
[BASE_OUTPUT_RULE_IDS.persistentStorage]: {
|
|
101
|
-
title: 'Artifact does not depend on persistent browser storage',
|
|
102
|
-
severity: 'warning',
|
|
103
|
-
recommendation: 'Ad containers may block storage; keep state in memory, or make storage access optional and guarded.',
|
|
104
|
-
confidence: 'low',
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
const TEXT_FILE = /\.(?:html?|m?js|css|json|svg|txt)$/i;
|
|
108
|
-
const MARKUP_FILE = /\.(?:html?|css)$/i;
|
|
109
|
-
const INJECTED_SCRIPT = /<script\b[^>]*\bdata-playcraft-injected\b[^>]*>[\s\S]*?<\/script>/gi;
|
|
110
|
-
const DATA_URI = /data:([a-z]+\/[a-z0-9.+-]+)((?:;[a-z0-9-]+=[^;,"'\s)]+)*);base64,([A-Za-z0-9+/]+={0,2})/gi;
|
|
111
|
-
const MAX_DATA_URIS = 2000;
|
|
112
|
-
const MAX_EVIDENCE = 10;
|
|
113
|
-
const DEV_ADDRESS_PATTERNS = [
|
|
114
|
-
/\bhttps?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(?::\d+)?/gi,
|
|
115
|
-
/\/@vite\/client\b/g,
|
|
116
|
-
/\/@react-refresh\b/g,
|
|
117
|
-
/\bfile:\/\/\//gi,
|
|
118
|
-
/["'`](?:\/Users\/|\/home\/)[^"'`\s]+/g,
|
|
119
|
-
/["'`][A-Za-z]:\\\\(?:Users|Documents and Settings)\\\\[^"'`\s]+/g,
|
|
120
|
-
];
|
|
121
|
-
const SOURCE_MAP = /(?:\/\/|\/\*)[#@]\s*sourceMappingURL=(?!data:)[^\s'"<>*]+/g;
|
|
122
|
-
const DEBUG_TOOLS = /\b(?:lil-gui|dat\.gui|vConsole|VConsole|eruda)\b|\bdebugger\s*;/g;
|
|
123
|
-
const DIRECT_REDIRECT = /\bwindow\s*\.\s*open\s*\(|\blocation\s*\.\s*(?:assign|replace)\s*\(|\blocation(?:\s*\.\s*href)?\s*=(?!=)/g;
|
|
124
|
-
const PERSISTENT_STORAGE = /\b(?:localStorage|sessionStorage|indexedDB)\b/g;
|
|
125
|
-
const INLINE_CATEGORIES = new Set(['image', 'audio', 'video', 'font']);
|
|
126
|
-
const CATEGORY_BY_EXTENSION = {
|
|
127
|
-
png: 'image',
|
|
128
|
-
jpg: 'image',
|
|
129
|
-
jpeg: 'image',
|
|
130
|
-
gif: 'image',
|
|
131
|
-
webp: 'image',
|
|
132
|
-
avif: 'image',
|
|
133
|
-
svg: 'image',
|
|
134
|
-
mp3: 'audio',
|
|
135
|
-
ogg: 'audio',
|
|
136
|
-
wav: 'audio',
|
|
137
|
-
m4a: 'audio',
|
|
138
|
-
aac: 'audio',
|
|
139
|
-
mp4: 'video',
|
|
140
|
-
webm: 'video',
|
|
141
|
-
woff: 'font',
|
|
142
|
-
woff2: 'font',
|
|
143
|
-
ttf: 'font',
|
|
144
|
-
otf: 'font',
|
|
145
|
-
glb: 'model',
|
|
146
|
-
gltf: 'model',
|
|
147
|
-
bin: 'model',
|
|
148
|
-
js: 'code',
|
|
149
|
-
mjs: 'code',
|
|
150
|
-
css: 'code',
|
|
151
|
-
html: 'code',
|
|
152
|
-
htm: 'code',
|
|
153
|
-
json: 'code',
|
|
154
|
-
};
|
|
155
|
-
async function runBaseOutputChecks(artifact, options) {
|
|
156
|
-
const results = [];
|
|
157
|
-
const entryResult = await checkEntryParsable(artifact);
|
|
158
|
-
results.push(entryResult);
|
|
159
|
-
if (entryResult.status === 'fail')
|
|
160
|
-
return results;
|
|
161
|
-
const textFiles = await readTextFiles(artifact);
|
|
162
|
-
results.push(checkViewportMeta(artifact.entry, textFiles));
|
|
163
|
-
results.push(checkSizeBudget(artifact, options));
|
|
164
|
-
results.push(checkLocalReferences(artifact, textFiles));
|
|
165
|
-
results.push(checkExternalResources(textFiles, options.allowedExternalPatterns));
|
|
166
|
-
results.push(patternResult(BASE_OUTPUT_RULE_IDS.devAddress, textFiles, DEV_ADDRESS_PATTERNS, artifact.entry));
|
|
167
|
-
results.push(checkInlineData(textFiles, artifact.entry));
|
|
168
|
-
results.push(sizeBreakdown(artifact, textFiles));
|
|
169
|
-
results.push(checkDebugResidue(artifact, textFiles));
|
|
170
|
-
results.push(patternResult(BASE_OUTPUT_RULE_IDS.directRedirect, textFiles, [DIRECT_REDIRECT], artifact.entry));
|
|
171
|
-
results.push(patternResult(BASE_OUTPUT_RULE_IDS.persistentStorage, textFiles, [PERSISTENT_STORAGE], artifact.entry));
|
|
172
|
-
return results;
|
|
173
|
-
}
|
|
174
|
-
async function checkEntryParsable(artifact) {
|
|
175
|
-
const id = BASE_OUTPUT_RULE_IDS.entryParsable;
|
|
176
|
-
const buffer = await artifact.readBuffer(artifact.entry);
|
|
177
|
-
if (!buffer)
|
|
178
|
-
return result(id, false, { file: artifact.entry, evidence: 'entry is not readable' });
|
|
179
|
-
let content;
|
|
180
|
-
try {
|
|
181
|
-
content = new TextDecoder('utf-8', { fatal: true }).decode(buffer);
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
return result(id, false, { file: artifact.entry, evidence: 'entry is not valid UTF-8' });
|
|
185
|
-
}
|
|
186
|
-
const markup = /<(?:html|head|body|script|canvas)\b/i.test(content);
|
|
187
|
-
return result(id, markup, {
|
|
188
|
-
file: artifact.entry,
|
|
189
|
-
...(markup ? {} : { evidence: 'no <html>, <head>, <body>, <script> or <canvas> tag found' }),
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function checkViewportMeta(entry, textFiles) {
|
|
193
|
-
const html = textFiles.find((file) => file.path === entry)?.scan ?? '';
|
|
194
|
-
const tag = Array.from(html.matchAll(/<meta\b[^>]*>/gi))
|
|
195
|
-
.map((match) => match[0])
|
|
196
|
-
.find((item) => /\bname\s*=\s*["']?viewport\b/i.test(item));
|
|
197
|
-
const content = tag?.match(/\bcontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i);
|
|
198
|
-
const value = content?.[1] ?? content?.[2] ?? '';
|
|
199
|
-
const ok = /\bwidth\s*=\s*device-width\b/i.test(value);
|
|
200
|
-
return result(BASE_OUTPUT_RULE_IDS.viewportMeta, ok, {
|
|
201
|
-
file: entry,
|
|
202
|
-
evidence: tag ? `found ${tag.slice(0, 200)}` : 'no <meta name="viewport"> tag',
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
function checkSizeBudget(artifact, options) {
|
|
206
|
-
const limit = options.sizeLimitBytes;
|
|
207
|
-
const size = artifact.totalSize;
|
|
208
|
-
const margin = limit - size;
|
|
209
|
-
const evidence = `size=${formatBytes(size)}, limit=${formatBytes(limit)}, margin=${margin >= 0 ? formatBytes(margin) : `-${formatBytes(-margin)}`}`;
|
|
210
|
-
if (size > limit)
|
|
211
|
-
return result(BASE_OUTPUT_RULE_IDS.sizeBudget, false, { evidence });
|
|
212
|
-
if (margin < limit * 0.1)
|
|
213
|
-
return result(BASE_OUTPUT_RULE_IDS.sizeBudget, false, {
|
|
214
|
-
evidence: `${evidence}; less than 10% of the limit remains`,
|
|
215
|
-
status: 'warning',
|
|
216
|
-
});
|
|
217
|
-
return result(BASE_OUTPUT_RULE_IDS.sizeBudget, true, { evidence });
|
|
218
|
-
}
|
|
219
|
-
function checkLocalReferences(artifact, textFiles) {
|
|
220
|
-
const paths = new Set(artifact.files.map((file) => file.path));
|
|
221
|
-
const missing = [];
|
|
222
|
-
for (const file of textFiles.filter((item) => MARKUP_FILE.test(item.path))) {
|
|
223
|
-
for (const reference of collectLocalResourceReferences(file.scan)) {
|
|
224
|
-
const target = resolveReference(file.path, reference);
|
|
225
|
-
if (target === undefined || !paths.has(target))
|
|
226
|
-
missing.push(`${file.path} → ${reference}`);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return result(BASE_OUTPUT_RULE_IDS.localReference, missing.length === 0, {
|
|
230
|
-
file: artifact.entry,
|
|
231
|
-
...(missing.length > 0 ? { evidence: summarizeList(missing) } : {}),
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
function resolveReference(fromFile, reference) {
|
|
235
|
-
const withoutQuery = reference.split(/[?#]/, 1)[0] ?? '';
|
|
236
|
-
if (!withoutQuery)
|
|
237
|
-
return fromFile;
|
|
238
|
-
let decoded;
|
|
239
|
-
try {
|
|
240
|
-
decoded = decodeURIComponent(withoutQuery);
|
|
241
|
-
}
|
|
242
|
-
catch {
|
|
243
|
-
decoded = withoutQuery;
|
|
244
|
-
}
|
|
245
|
-
const joined = decoded.startsWith('/')
|
|
246
|
-
? decoded.slice(1)
|
|
247
|
-
: path.posix.join(path.posix.dirname(fromFile), decoded);
|
|
248
|
-
const normalized = path.posix.normalize(joined);
|
|
249
|
-
return normalized.startsWith('../') || normalized === '..' ? undefined : normalized;
|
|
250
|
-
}
|
|
251
|
-
function checkExternalResources(textFiles, allowedPatterns) {
|
|
252
|
-
const external = [];
|
|
253
|
-
for (const file of textFiles.filter((item) => MARKUP_FILE.test(item.path))) {
|
|
254
|
-
for (const url of collectExternalResources(file.scan)) {
|
|
255
|
-
if (!isAllowedExternalResource(url, allowedPatterns))
|
|
256
|
-
external.push(`${file.path} → ${url}`);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return result(BASE_OUTPUT_RULE_IDS.externalResource, external.length === 0, {
|
|
260
|
-
...(external.length > 0 ? { evidence: summarizeList(external) } : {}),
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
function checkInlineData(textFiles, entry) {
|
|
264
|
-
const problems = [];
|
|
265
|
-
let checked = 0;
|
|
266
|
-
let firstFile;
|
|
267
|
-
for (const file of textFiles) {
|
|
268
|
-
for (const match of file.scan.matchAll(DATA_URI)) {
|
|
269
|
-
if (checked >= MAX_DATA_URIS)
|
|
270
|
-
break;
|
|
271
|
-
checked += 1;
|
|
272
|
-
const mime = match[1].toLowerCase();
|
|
273
|
-
const payload = match[3];
|
|
274
|
-
const problem = inlineDataProblem(mime, payload);
|
|
275
|
-
if (problem) {
|
|
276
|
-
firstFile ?? (firstFile = file.path);
|
|
277
|
-
problems.push(`${file.path}:${lineOf(file.content, match.index ?? 0)} ${mime} ${problem}`);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return result(BASE_OUTPUT_RULE_IDS.inlineData, problems.length === 0, {
|
|
282
|
-
file: firstFile ?? entry,
|
|
283
|
-
evidence: problems.length > 0 ? summarizeList(problems) : `checked ${checked} inline data URI(s)`,
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
function inlineDataProblem(mime, payload) {
|
|
287
|
-
if (payload.length % 4 === 1)
|
|
288
|
-
return 'has a truncated base64 payload';
|
|
289
|
-
const bytes = Buffer.from(payload, 'base64');
|
|
290
|
-
if (bytes.length === 0)
|
|
291
|
-
return 'is empty';
|
|
292
|
-
const signature = SIGNATURES_BY_MIME.get(mime);
|
|
293
|
-
if (!signature || signature(bytes))
|
|
294
|
-
return undefined;
|
|
295
|
-
return `does not start with a ${mime} signature`;
|
|
296
|
-
}
|
|
297
|
-
const startsWith = (...values) => (bytes) => values.every((value, index) => bytes[index] === value);
|
|
298
|
-
const ascii = (offset, text) => (bytes) => bytes.subarray(offset, offset + text.length).toString('latin1') === text;
|
|
299
|
-
const all = (...signatures) => (bytes) => signatures.every((signature) => signature(bytes));
|
|
300
|
-
const any = (...signatures) => (bytes) => signatures.some((signature) => signature(bytes));
|
|
301
|
-
const mpegFrame = (bytes) => bytes[0] === 0xff && ((bytes[1] ?? 0) & 0xe0) === 0xe0;
|
|
302
|
-
/** Leading bytes of each MIME type checked; other types are not checked. */
|
|
303
|
-
const SIGNATURES = [
|
|
304
|
-
[['image/png'], startsWith(0x89, 0x50, 0x4e, 0x47)],
|
|
305
|
-
[['image/jpeg', 'image/jpg'], startsWith(0xff, 0xd8, 0xff)],
|
|
306
|
-
[['image/gif'], ascii(0, 'GIF8')],
|
|
307
|
-
[['image/webp'], all(ascii(0, 'RIFF'), ascii(8, 'WEBP'))],
|
|
308
|
-
[['audio/mpeg', 'audio/mp3'], any(ascii(0, 'ID3'), mpegFrame)],
|
|
309
|
-
[['audio/ogg', 'video/ogg'], ascii(0, 'OggS')],
|
|
310
|
-
[['audio/wav', 'audio/wave', 'audio/x-wav'], all(ascii(0, 'RIFF'), ascii(8, 'WAVE'))],
|
|
311
|
-
[['audio/mp4', 'audio/aac', 'video/mp4'], any(ascii(4, 'ftyp'), startsWith(0xff, 0xf1))],
|
|
312
|
-
[['font/woff', 'application/font-woff'], ascii(0, 'wOFF')],
|
|
313
|
-
[['font/woff2'], ascii(0, 'wOF2')],
|
|
314
|
-
[
|
|
315
|
-
['font/ttf', 'font/sfnt', 'application/x-font-ttf'],
|
|
316
|
-
any(startsWith(0x00, 0x01, 0x00, 0x00), ascii(0, 'true')),
|
|
317
|
-
],
|
|
318
|
-
[['font/otf'], ascii(0, 'OTTO')],
|
|
319
|
-
];
|
|
320
|
-
const SIGNATURES_BY_MIME = new Map(SIGNATURES.flatMap(([mimes, signature]) => mimes.map((mime) => [mime, signature])));
|
|
321
|
-
function sizeBreakdown(artifact, textFiles) {
|
|
322
|
-
const categories = new Map();
|
|
323
|
-
const items = [];
|
|
324
|
-
const add = (category, bytes) => categories.set(category, (categories.get(category) ?? 0) + bytes);
|
|
325
|
-
const textByPath = new Map(textFiles.map((file) => [file.path, file]));
|
|
326
|
-
for (const file of artifact.files) {
|
|
327
|
-
const text = textByPath.get(file.path);
|
|
328
|
-
let inlineBytes = 0;
|
|
329
|
-
if (text) {
|
|
330
|
-
let index = 0;
|
|
331
|
-
for (const match of text.content.matchAll(DATA_URI)) {
|
|
332
|
-
const bytes = match[0].length;
|
|
333
|
-
inlineBytes += bytes;
|
|
334
|
-
index += 1;
|
|
335
|
-
const kind = match[1].toLowerCase().split('/')[0];
|
|
336
|
-
add(INLINE_CATEGORIES.has(kind) ? kind : 'other', bytes);
|
|
337
|
-
items.push({ label: `${file.path} inline ${match[1]} #${index}`, bytes });
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
const extension = path.posix.extname(file.path).slice(1).toLowerCase();
|
|
341
|
-
const remaining = Math.max(0, file.size - inlineBytes);
|
|
342
|
-
add(CATEGORY_BY_EXTENSION[extension] ?? 'other', remaining);
|
|
343
|
-
items.push({ label: file.path, bytes: remaining });
|
|
344
|
-
}
|
|
345
|
-
const total = [...categories.values()].reduce((sum, bytes) => sum + bytes, 0) || 1;
|
|
346
|
-
const byCategory = [...categories.entries()]
|
|
347
|
-
.filter(([, bytes]) => bytes > 0)
|
|
348
|
-
.sort((a, b) => b[1] - a[1])
|
|
349
|
-
.map(([category, bytes]) => `${category}=${formatBytes(bytes)} (${Math.round((bytes / total) * 100)}%)`)
|
|
350
|
-
.join(', ');
|
|
351
|
-
const largest = items
|
|
352
|
-
.filter((item) => item.bytes > 0)
|
|
353
|
-
.sort((a, b) => b.bytes - a.bytes)
|
|
354
|
-
.slice(0, 5)
|
|
355
|
-
.map((item) => `${item.label} ${formatBytes(item.bytes)}`)
|
|
356
|
-
.join('; ');
|
|
357
|
-
return result(BASE_OUTPUT_RULE_IDS.sizeBreakdown, true, {
|
|
358
|
-
evidence: `${byCategory}. Largest: ${largest}`,
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
function checkDebugResidue(artifact, textFiles) {
|
|
362
|
-
const findings = collectMatches(textFiles, [SOURCE_MAP, DEBUG_TOOLS]);
|
|
363
|
-
for (const file of artifact.files)
|
|
364
|
-
if (file.path.endsWith('.map'))
|
|
365
|
-
findings.unshift({ file: file.path, line: 1, text: 'source map file' });
|
|
366
|
-
return findingsResult(BASE_OUTPUT_RULE_IDS.debugResidue, findings, artifact.entry);
|
|
367
|
-
}
|
|
368
|
-
function patternResult(id, textFiles, patterns, entry) {
|
|
369
|
-
return findingsResult(id, collectMatches(textFiles, patterns), entry);
|
|
370
|
-
}
|
|
371
|
-
function collectMatches(textFiles, patterns) {
|
|
372
|
-
const findings = [];
|
|
373
|
-
for (const file of textFiles) {
|
|
374
|
-
for (const pattern of patterns) {
|
|
375
|
-
for (const match of file.scan.matchAll(new RegExp(pattern.source, pattern.flags))) {
|
|
376
|
-
findings.push({
|
|
377
|
-
file: file.path,
|
|
378
|
-
line: lineOf(file.content, match.index ?? 0),
|
|
379
|
-
text: match[0].slice(0, 120),
|
|
380
|
-
});
|
|
381
|
-
if (findings.length >= 50)
|
|
382
|
-
return findings;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
return findings;
|
|
387
|
-
}
|
|
388
|
-
function findingsResult(id, findings, entry) {
|
|
389
|
-
const first = findings[0];
|
|
390
|
-
return result(id, findings.length === 0, {
|
|
391
|
-
file: first?.file ?? entry,
|
|
392
|
-
...(first ? { line: first.line } : {}),
|
|
393
|
-
...(findings.length > 0
|
|
394
|
-
? { evidence: summarizeList(findings.map((item) => `${item.file}:${item.line} ${item.text}`)) }
|
|
395
|
-
: {}),
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
async function readTextFiles(artifact) {
|
|
399
|
-
const files = [];
|
|
400
|
-
for (const file of artifact.files.filter((item) => TEXT_FILE.test(item.path))) {
|
|
401
|
-
const content = await artifact.readText(file.path);
|
|
402
|
-
if (content === null)
|
|
403
|
-
continue;
|
|
404
|
-
files.push({ path: file.path, content, scan: maskInjectedScripts(content) });
|
|
405
|
-
}
|
|
406
|
-
return files;
|
|
407
|
-
}
|
|
408
|
-
/** Blanks scripts the platform injected at build time, keeping line numbers intact. */
|
|
409
|
-
function maskInjectedScripts(content) {
|
|
410
|
-
return content.replace(INJECTED_SCRIPT, (match) => match.replace(/[^\n]/g, ' '));
|
|
411
|
-
}
|
|
412
|
-
function lineOf(content, index) {
|
|
413
|
-
let line = 1;
|
|
414
|
-
for (let position = 0; position < index; position += 1)
|
|
415
|
-
if (content.charCodeAt(position) === 10)
|
|
416
|
-
line += 1;
|
|
417
|
-
return line;
|
|
418
|
-
}
|
|
419
|
-
function summarizeList(items) {
|
|
420
|
-
const shown = items.slice(0, MAX_EVIDENCE).join('; ');
|
|
421
|
-
return items.length > MAX_EVIDENCE ? `${shown}; … ${items.length - MAX_EVIDENCE} more` : shown;
|
|
422
|
-
}
|
|
423
|
-
function result(id, passed, details) {
|
|
424
|
-
const rule = RULES[id];
|
|
425
|
-
const status = details.status ?? (passed ? 'pass' : rule.severity === 'error' ? 'fail' : 'warning');
|
|
426
|
-
return {
|
|
427
|
-
ruleId: id,
|
|
428
|
-
channel: 'common',
|
|
429
|
-
stage: 'base-output',
|
|
430
|
-
severity: rule.severity,
|
|
431
|
-
status,
|
|
432
|
-
message: passed ? `${rule.title}: passed` : rule.title,
|
|
433
|
-
recommendation: rule.recommendation,
|
|
434
|
-
...(details.file ? { file: details.file } : {}),
|
|
435
|
-
...(details.line ? { line: details.line } : {}),
|
|
436
|
-
...(details.evidence ? { evidence: details.evidence } : {}),
|
|
437
|
-
owner: 'playcraft-build',
|
|
438
|
-
confidence: rule.confidence,
|
|
439
|
-
};
|
|
440
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type ZipEntryInfo } from './zip-reader.js';
|
|
2
|
-
import type { ArtifactReadErrorCode, PlayableArtifact, ReadArtifactOptions } from './types.js';
|
|
3
|
-
export declare class ArtifactReadError extends Error {
|
|
4
|
-
readonly code: ArtifactReadErrorCode;
|
|
5
|
-
constructor(code: ArtifactReadErrorCode, message: string);
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Reads a built playable from a single HTML file, a ZIP file or a directory, and resolves its
|
|
9
|
-
* entry HTML. Only the artifact is inspected; how it was built does not matter.
|
|
10
|
-
*/
|
|
11
|
-
export declare function readArtifact(inputPath: string, options?: ReadArtifactOptions): Promise<PlayableArtifact>;
|
|
12
|
-
/** Lists a directory like a ZIP central directory: files and `/`-terminated directories. */
|
|
13
|
-
export declare function listDirectoryEntries(dir: string): Promise<ZipEntryInfo[]>;
|
|
14
|
-
export declare function directorySize(dir: string): Promise<number>;
|