@playcraft/build 0.1.93-test → 0.1.95-test-a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audio-source-files.d.ts +5 -0
- package/dist/audio-source-files.js +135 -0
- package/dist/base-builder.js +41 -2
- package/dist/delivery/agent-build-runner.d.ts +44 -0
- package/dist/delivery/agent-build-runner.js +365 -0
- package/dist/delivery/agent-build-source.d.ts +8 -0
- package/dist/delivery/agent-build-source.js +25 -0
- package/dist/delivery/artifact-descriptor.d.ts +31 -0
- package/dist/delivery/artifact-descriptor.js +237 -0
- package/dist/delivery/artifact-package.d.ts +43 -0
- package/dist/delivery/artifact-package.js +283 -0
- package/dist/delivery/build-plan.d.ts +4 -0
- package/dist/delivery/build-plan.js +189 -0
- package/dist/delivery/build-plan.types.d.ts +51 -0
- package/dist/delivery/build-plan.types.js +1 -0
- package/dist/delivery/command-isolation.d.ts +20 -0
- package/dist/delivery/command-isolation.js +324 -0
- package/dist/delivery/commands.d.ts +5 -0
- package/dist/delivery/commands.js +146 -0
- package/dist/delivery/files.d.ts +9 -0
- package/dist/delivery/files.js +144 -0
- package/dist/delivery/git-source-fingerprint.d.ts +2 -0
- package/dist/delivery/git-source-fingerprint.js +58 -0
- package/dist/delivery/isolated-source.d.ts +5 -0
- package/dist/delivery/isolated-source.js +126 -0
- package/dist/delivery/output-publication.d.ts +21 -0
- package/dist/delivery/output-publication.js +444 -0
- package/dist/delivery/project-delivery.d.ts +6 -0
- package/dist/delivery/project-delivery.js +287 -0
- package/dist/delivery/recipe-build-plan.d.ts +4 -0
- package/dist/delivery/recipe-build-plan.js +53 -0
- package/dist/delivery/recipe.d.ts +20 -0
- package/dist/delivery/recipe.js +211 -0
- package/dist/delivery/safe-path.d.ts +2 -0
- package/dist/delivery/safe-path.js +18 -0
- package/dist/delivery/types.d.ts +76 -0
- package/dist/delivery/types.js +1 -0
- package/dist/engines/engine-detector.js +4 -0
- package/dist/engines/generic-adapter.js +14 -19
- package/dist/index.d.ts +19 -4
- package/dist/index.js +11 -2
- package/dist/platforms/adikteev.js +1 -0
- package/dist/platforms/applovin.js +1 -0
- package/dist/platforms/base.js +2 -2
- package/dist/platforms/bigo.js +1 -0
- package/dist/platforms/facebook.js +1 -0
- package/dist/platforms/google.js +1 -0
- package/dist/platforms/inmobi.js +1 -0
- package/dist/platforms/ironsource.js +1 -0
- package/dist/platforms/liftoff.js +1 -0
- package/dist/platforms/mintegral.js +1 -0
- package/dist/platforms/moloco.js +1 -0
- package/dist/platforms/playcraft.js +1 -0
- package/dist/platforms/remerge.js +1 -0
- package/dist/platforms/snapchat.js +1 -0
- package/dist/platforms/tiktok.js +1 -0
- package/dist/platforms/unity.js +1 -0
- package/dist/production-animation-presence.d.ts +2 -0
- package/dist/production-animation-presence.js +146 -0
- package/dist/production-inputs.d.ts +30 -0
- package/dist/production-inputs.js +262 -0
- package/dist/production-source-paths.d.ts +5 -0
- package/dist/production-source-paths.js +27 -0
- package/dist/types.d.ts +5 -0
- package/dist/validation/artifact-qa.d.ts +44 -0
- package/dist/validation/artifact-qa.js +170 -0
- package/dist/validation/artifact-rules.d.ts +28 -0
- package/dist/validation/artifact-rules.js +440 -0
- package/dist/validation/artifact.d.ts +14 -0
- package/dist/validation/artifact.js +188 -0
- package/dist/validation/html-validator.d.ts +5 -0
- package/dist/validation/html-validator.js +19 -17
- package/dist/validation/index.d.ts +4 -0
- package/dist/validation/index.js +4 -0
- package/dist/validation/package-validator.d.ts +2 -0
- package/dist/validation/package-validator.js +25 -64
- package/dist/validation/profiles.d.ts +13 -1
- package/dist/validation/profiles.js +27 -0
- package/dist/validation/runtime-load.d.ts +89 -0
- package/dist/validation/runtime-load.js +654 -0
- package/dist/validation/source-scanner.d.ts +11 -0
- package/dist/validation/source-scanner.js +32 -2
- package/dist/validation/types.d.ts +155 -2
- package/dist/validation/types.js +1 -1
- package/dist/validation/validation-runner.d.ts +22 -2
- package/dist/validation/validation-runner.js +68 -3
- package/dist/validation/zip-reader.d.ts +7 -0
- package/dist/validation/zip-reader.js +159 -26
- package/dist/vite/config-builder-generic.d.ts +3 -1
- package/dist/vite/config-builder-generic.js +9 -7
- package/dist/vite/config-builder.js +1 -1
- package/dist/vite/plugin-platform.js +30 -54
- package/dist/vite/plugin-source-builder.d.ts +2 -14
- package/dist/vite/plugin-source-builder.js +61 -997
- package/dist/vite/source-builder-asset-paths.d.ts +25 -0
- package/dist/vite/source-builder-asset-paths.js +154 -0
- package/dist/vite/source-builder-esm.d.ts +7 -0
- package/dist/vite/source-builder-esm.js +877 -0
- package/dist/vite/source-builder-types.d.ts +14 -0
- package/dist/vite/source-builder-types.js +1 -0
- package/dist/vite/workspace.d.ts +6 -0
- package/dist/vite/workspace.js +41 -0
- package/dist/vite-builder.d.ts +4 -5
- package/dist/vite-builder.js +33 -34
- package/dist/workspace-css-imports.d.ts +2 -0
- package/dist/workspace-css-imports.js +139 -0
- package/dist/workspace-model-source.d.ts +14 -0
- package/dist/workspace-model-source.js +184 -0
- package/dist/workspace-public-imports.d.ts +11 -0
- package/dist/workspace-public-imports.js +232 -0
- package/dist/workspace-public-source.d.ts +15 -0
- package/dist/workspace-public-source.js +564 -0
- package/package.json +16 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger, defineConfig } from 'vite';
|
|
1
|
+
import { createLogger, defineConfig, } from 'vite';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { viteSingleFile } from 'vite-plugin-singlefile';
|
|
@@ -9,6 +9,7 @@ import imageminWebp from 'imagemin-webp';
|
|
|
9
9
|
import { PLATFORM_CONFIGS } from './platform-configs.js';
|
|
10
10
|
import { vitePlatformPlugin } from './plugin-platform.js';
|
|
11
11
|
import { createPlatformAdapter } from '../platforms/index.js';
|
|
12
|
+
import { resolveViteWorkspace } from './workspace.js';
|
|
12
13
|
/**
|
|
13
14
|
* 通用 Vite 配置构建器(外部引擎专用)
|
|
14
15
|
*
|
|
@@ -21,11 +22,12 @@ import { createPlatformAdapter } from '../platforms/index.js';
|
|
|
21
22
|
* - viteImagemin:图片压缩
|
|
22
23
|
*/
|
|
23
24
|
export class GenericViteConfigBuilder {
|
|
24
|
-
constructor(baseBuildDir, platform, options, baseBuildMetadata) {
|
|
25
|
+
constructor(baseBuildDir, platform, options, baseBuildMetadata, workspace) {
|
|
25
26
|
this.baseBuildDir = baseBuildDir;
|
|
26
27
|
this.platform = platform;
|
|
27
28
|
this.options = options;
|
|
28
29
|
this.baseBuildMetadata = baseBuildMetadata;
|
|
30
|
+
this.workspace = workspace;
|
|
29
31
|
this.finalOutputDir = '';
|
|
30
32
|
this.viteOutputDir = '';
|
|
31
33
|
// 统一规范化 baseBuildDir(与 ViteConfigBuilder 一致)
|
|
@@ -43,18 +45,18 @@ export class GenericViteConfigBuilder {
|
|
|
43
45
|
const outputDir = this.options.outputDir || './dist';
|
|
44
46
|
const playableOptions = this.getPlayableOptions(platformConfig);
|
|
45
47
|
const rootDir = this.baseBuildDir;
|
|
46
|
-
const
|
|
47
|
-
const viteOutputDirAbsolute = path.join(rootDir,
|
|
48
|
-
const finalOutputDir = path.isAbsolute(outputDir)
|
|
48
|
+
const workspace = this.workspace ? resolveViteWorkspace(rootDir, this.workspace) : undefined;
|
|
49
|
+
const viteOutputDirAbsolute = workspace?.intermediateDir ?? path.join(rootDir, '__dist__');
|
|
50
|
+
const finalOutputDir = workspace?.finalOutputDir ?? (path.isAbsolute(outputDir)
|
|
49
51
|
? outputDir
|
|
50
|
-
: path.resolve(process.cwd(), outputDir);
|
|
52
|
+
: path.resolve(process.cwd(), outputDir));
|
|
51
53
|
this.finalOutputDir = finalOutputDir;
|
|
52
54
|
this.viteOutputDir = viteOutputDirAbsolute;
|
|
53
55
|
console.log(`[GenericViteConfigBuilder] 路径配置:`);
|
|
54
56
|
console.log(` - root: ${rootDir}`);
|
|
55
57
|
console.log(` - viteOutputDir: ${viteOutputDirAbsolute}`);
|
|
56
58
|
console.log(` - finalOutputDir: ${finalOutputDir}`);
|
|
57
|
-
return this.createConfig(platformConfig,
|
|
59
|
+
return this.createConfig(platformConfig, workspace ? viteOutputDirAbsolute : '__dist__', playableOptions, rootDir);
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* 获取 Vite 的临时输出目录
|
|
@@ -62,7 +62,7 @@ export function vitePlatformPlugin(options) {
|
|
|
62
62
|
}
|
|
63
63
|
if (options.outputFormat === 'zip') {
|
|
64
64
|
// 等待 ZIP 创建完成
|
|
65
|
-
await createZipOutput(options.outputDir
|
|
65
|
+
await createZipOutput(options.outputDir);
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
};
|
|
@@ -70,8 +70,8 @@ export function vitePlatformPlugin(options) {
|
|
|
70
70
|
/**
|
|
71
71
|
* 创建 ZIP 输出
|
|
72
72
|
*/
|
|
73
|
-
function createZipOutput(outDir
|
|
74
|
-
return new Promise(
|
|
73
|
+
function createZipOutput(outDir) {
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
75
|
const zipPath = path.join(outDir, 'playable.zip');
|
|
76
76
|
const output = createWriteStream(zipPath);
|
|
77
77
|
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
@@ -88,7 +88,7 @@ function createZipOutput(outDir, htmlFileName) {
|
|
|
88
88
|
cwd: outDir,
|
|
89
89
|
ignore: ['playable.zip'],
|
|
90
90
|
});
|
|
91
|
-
archive.finalize();
|
|
91
|
+
void archive.finalize().catch(reject);
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
async function keepSingleHtml(outDir, htmlFileName) {
|
|
@@ -96,7 +96,7 @@ async function keepSingleHtml(outDir, htmlFileName) {
|
|
|
96
96
|
try {
|
|
97
97
|
entries = await fs.readdir(outDir, { withFileTypes: true });
|
|
98
98
|
}
|
|
99
|
-
catch
|
|
99
|
+
catch {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
// 如果目标文件名不是 index.html,先重命名
|
|
@@ -107,7 +107,7 @@ async function keepSingleHtml(outDir, htmlFileName) {
|
|
|
107
107
|
await fs.rename(indexPath, targetPath);
|
|
108
108
|
console.log(`[Platform] 已重命名 index.html -> ${htmlFileName}`);
|
|
109
109
|
}
|
|
110
|
-
catch
|
|
110
|
+
catch {
|
|
111
111
|
// index.html 可能不存在,忽略错误
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -147,7 +147,6 @@ async function applyExternFiles(outDir, externFiles) {
|
|
|
147
147
|
const configFilename = `${folderName}/config.json`;
|
|
148
148
|
await rewriteIndexHtml(outDir, assetPrefix, configFilename);
|
|
149
149
|
await rewriteSettings(folderPath, assetPrefix, configFilename);
|
|
150
|
-
await rewriteConfig(path.join(folderPath), folderPath, folderName);
|
|
151
150
|
}
|
|
152
151
|
async function rewriteIndexHtml(outDir, assetPrefix, configFilename) {
|
|
153
152
|
const indexPath = path.join(outDir, 'index.html');
|
|
@@ -235,17 +234,7 @@ async function rewriteSettings(folderPath, assetPrefix, configFilename) {
|
|
|
235
234
|
}
|
|
236
235
|
await fs.writeFile(settingsPath, code);
|
|
237
236
|
}
|
|
238
|
-
catch
|
|
239
|
-
// 忽略缺失
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
async function rewriteConfig(configDir, _folderPath, _folderName) {
|
|
243
|
-
// config.json 已移入资产文件夹,在此处可对其进行后处理
|
|
244
|
-
const configPath = path.join(configDir, 'config.json');
|
|
245
|
-
try {
|
|
246
|
-
await fs.access(configPath);
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
237
|
+
catch {
|
|
249
238
|
// 忽略缺失
|
|
250
239
|
}
|
|
251
240
|
}
|
|
@@ -357,27 +346,25 @@ async function stripAmmoAssetsFromConfig(outDir) {
|
|
|
357
346
|
try {
|
|
358
347
|
const raw = await fs.readFile(configPath, 'utf-8');
|
|
359
348
|
const configJson = JSON.parse(raw);
|
|
360
|
-
if (!configJson.assets)
|
|
361
|
-
return;
|
|
362
349
|
const assets = configJson.assets;
|
|
350
|
+
if (!assets)
|
|
351
|
+
return;
|
|
363
352
|
const ammoAssetIds = new Set();
|
|
364
353
|
const ammoRelatedIds = new Set();
|
|
365
354
|
// 找出所有 ammo 相关的 wasm assets 及其关联的 glue/fallback script
|
|
366
355
|
for (const [id, asset] of Object.entries(assets)) {
|
|
367
|
-
|
|
368
|
-
if (a.type === 'wasm' && a.data?.moduleName?.toLowerCase().includes('ammo')) {
|
|
356
|
+
if (asset.type === 'wasm' && asset.data?.moduleName?.toLowerCase().includes('ammo')) {
|
|
369
357
|
ammoAssetIds.add(id);
|
|
370
|
-
if (
|
|
371
|
-
ammoRelatedIds.add(String(
|
|
372
|
-
if (
|
|
373
|
-
ammoRelatedIds.add(String(
|
|
358
|
+
if (asset.data.glueScriptId != null)
|
|
359
|
+
ammoRelatedIds.add(String(asset.data.glueScriptId));
|
|
360
|
+
if (asset.data.fallbackScriptId != null)
|
|
361
|
+
ammoRelatedIds.add(String(asset.data.fallbackScriptId));
|
|
374
362
|
}
|
|
375
363
|
}
|
|
376
364
|
// 也检查 file.url 中包含 ammo 的 assets
|
|
377
365
|
for (const [id, asset] of Object.entries(assets)) {
|
|
378
|
-
const
|
|
379
|
-
const
|
|
380
|
-
const name = (a.name || '').toLowerCase();
|
|
366
|
+
const url = asset.file?.url?.toLowerCase() || '';
|
|
367
|
+
const name = (asset.name || '').toLowerCase();
|
|
381
368
|
if (url.includes('ammo') || name.includes('ammo')) {
|
|
382
369
|
ammoRelatedIds.add(id);
|
|
383
370
|
}
|
|
@@ -407,26 +394,9 @@ function isAmmoModule(module) {
|
|
|
407
394
|
fallbackUrl.includes('ammo'));
|
|
408
395
|
}
|
|
409
396
|
async function applyMraidSupport(outDir) {
|
|
410
|
-
//
|
|
411
|
-
// The MRAID resize patch handles the sizing correctly with any fillMode
|
|
412
|
-
// await patchConfigFillMode(outDir); // Removed: causes canvas scaling issues
|
|
397
|
+
// MRAID resize patch 会处理画布尺寸,不再修改 fillMode,避免缩放问题
|
|
413
398
|
await patchStylesForMraid(outDir);
|
|
414
399
|
}
|
|
415
|
-
async function patchConfigFillMode(outDir) {
|
|
416
|
-
const configPath = path.join(outDir, 'config.json');
|
|
417
|
-
try {
|
|
418
|
-
const raw = await fs.readFile(configPath, 'utf-8');
|
|
419
|
-
const json = JSON.parse(raw);
|
|
420
|
-
json.application_properties = {
|
|
421
|
-
...(json.application_properties || {}),
|
|
422
|
-
fillMode: 'NONE',
|
|
423
|
-
};
|
|
424
|
-
await fs.writeFile(configPath, JSON.stringify(json));
|
|
425
|
-
}
|
|
426
|
-
catch (error) {
|
|
427
|
-
// 忽略缺失
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
400
|
async function patchStylesForMraid(outDir) {
|
|
431
401
|
const cssPath = path.join(outDir, 'styles.css');
|
|
432
402
|
try {
|
|
@@ -436,7 +406,7 @@ async function patchStylesForMraid(outDir) {
|
|
|
436
406
|
await fs.writeFile(cssPath, css);
|
|
437
407
|
}
|
|
438
408
|
}
|
|
439
|
-
catch
|
|
409
|
+
catch {
|
|
440
410
|
// 忽略缺失
|
|
441
411
|
}
|
|
442
412
|
}
|
|
@@ -523,7 +493,7 @@ async function minifyJSFilesInDir(dir) {
|
|
|
523
493
|
const ratio = originalSize > 0 ? ((saved / originalSize) * 100).toFixed(1) : '0';
|
|
524
494
|
console.log(` ✓ ${relativePath}: ${(originalSize / 1024).toFixed(1)}KB → ${(minifiedSize / 1024).toFixed(1)}KB (-${ratio}%)`);
|
|
525
495
|
}
|
|
526
|
-
catch
|
|
496
|
+
catch {
|
|
527
497
|
console.warn(` ⚠ ${path.relative(dir, filePath)}: 压缩失败,保留原文件`);
|
|
528
498
|
}
|
|
529
499
|
}
|
|
@@ -609,7 +579,7 @@ async function inlineUnsupportedAssetsIntoConfig(outDir) {
|
|
|
609
579
|
console.warn(`[Platform] inlineUnsupportedAssets: 无法读取 config.json: ${error}`);
|
|
610
580
|
return;
|
|
611
581
|
}
|
|
612
|
-
if (!configJson
|
|
582
|
+
if (!configJson.assets) {
|
|
613
583
|
return;
|
|
614
584
|
}
|
|
615
585
|
const configDir = path.dirname(configPath);
|
|
@@ -623,7 +593,7 @@ async function inlineUnsupportedAssetsIntoConfig(outDir) {
|
|
|
623
593
|
const url = file.url;
|
|
624
594
|
if (url.startsWith('data:') || url.startsWith('http://') || url.startsWith('https://'))
|
|
625
595
|
continue;
|
|
626
|
-
const cleanUrl = url.split('?')[0];
|
|
596
|
+
const cleanUrl = url.split('?')[0] ?? url;
|
|
627
597
|
// 检查此文件是否为 Google 不支持的类型
|
|
628
598
|
if (isGoogleSupportedFile(cleanUrl))
|
|
629
599
|
continue;
|
|
@@ -706,7 +676,9 @@ async function findConfigJson(outDir) {
|
|
|
706
676
|
await fs.access(directPath);
|
|
707
677
|
return directPath;
|
|
708
678
|
}
|
|
709
|
-
catch {
|
|
679
|
+
catch {
|
|
680
|
+
// 根目录没有 config.json,继续搜索子目录
|
|
681
|
+
}
|
|
710
682
|
// 在子目录中查找(externFiles 场景)
|
|
711
683
|
const entries = await fs.readdir(outDir, { withFileTypes: true });
|
|
712
684
|
for (const entry of entries) {
|
|
@@ -716,7 +688,9 @@ async function findConfigJson(outDir) {
|
|
|
716
688
|
await fs.access(subPath);
|
|
717
689
|
return subPath;
|
|
718
690
|
}
|
|
719
|
-
catch {
|
|
691
|
+
catch {
|
|
692
|
+
// 继续尝试其他子目录
|
|
693
|
+
}
|
|
720
694
|
}
|
|
721
695
|
}
|
|
722
696
|
return null;
|
|
@@ -732,7 +706,9 @@ async function cleanEmptyDirs(dir) {
|
|
|
732
706
|
try {
|
|
733
707
|
await fs.rmdir(fullPath);
|
|
734
708
|
}
|
|
735
|
-
catch {
|
|
709
|
+
catch {
|
|
710
|
+
// 忽略删除失败
|
|
711
|
+
}
|
|
736
712
|
}
|
|
737
713
|
else {
|
|
738
714
|
isEmpty = false;
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
+
import type { SourceBuilderPluginOptions } from './source-builder-types.js';
|
|
2
|
+
export type { SourceBuilderPluginOptions, UserScript } from './source-builder-types.js';
|
|
1
3
|
import type { Plugin } from 'vite';
|
|
2
|
-
import { type ImportMapAsset } from '../loaders/playcanvas-loader.js';
|
|
3
|
-
export interface SourceBuilderPluginOptions {
|
|
4
|
-
projectDir: string;
|
|
5
|
-
outputDir: string;
|
|
6
|
-
selectedScenes?: string[];
|
|
7
|
-
buildMode?: 'classic' | 'esm';
|
|
8
|
-
importMap?: ImportMapAsset;
|
|
9
|
-
}
|
|
10
|
-
export interface UserScript {
|
|
11
|
-
id: string;
|
|
12
|
-
path: string;
|
|
13
|
-
code: string;
|
|
14
|
-
name: string;
|
|
15
|
-
}
|
|
16
4
|
/**
|
|
17
5
|
* Vite 插件:从源代码构建 PlayCanvas 项目
|
|
18
6
|
*/
|