@kurot/cli 1.0.2
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/CHANGELOG.md +128 -0
- package/README.md +296 -0
- package/dist/commands/build.d.ts +3 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +59 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/clean.d.ts +3 -0
- package/dist/commands/clean.d.ts.map +1 -0
- package/dist/commands/clean.js +15 -0
- package/dist/commands/clean.js.map +1 -0
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +24 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +25 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/core/config.d.ts +94 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +70 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/dev-server.d.ts +21 -0
- package/dist/core/dev-server.d.ts.map +1 -0
- package/dist/core/dev-server.js +113 -0
- package/dist/core/dev-server.js.map +1 -0
- package/dist/core/errors.d.ts +16 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +23 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/exml/ast.d.ts +243 -0
- package/dist/core/exml/ast.d.ts.map +1 -0
- package/dist/core/exml/ast.js +8 -0
- package/dist/core/exml/ast.js.map +1 -0
- package/dist/core/exml/codegen.d.ts +23 -0
- package/dist/core/exml/codegen.d.ts.map +1 -0
- package/dist/core/exml/codegen.js +422 -0
- package/dist/core/exml/codegen.js.map +1 -0
- package/dist/core/exml/exml-parser.d.ts +27 -0
- package/dist/core/exml/exml-parser.d.ts.map +1 -0
- package/dist/core/exml/exml-parser.js +466 -0
- package/dist/core/exml/exml-parser.js.map +1 -0
- package/dist/core/exml/index.d.ts +52 -0
- package/dist/core/exml/index.d.ts.map +1 -0
- package/dist/core/exml/index.js +51 -0
- package/dist/core/exml/index.js.map +1 -0
- package/dist/core/exml/registry.d.ts +92 -0
- package/dist/core/exml/registry.d.ts.map +1 -0
- package/dist/core/exml/registry.js +177 -0
- package/dist/core/exml/registry.js.map +1 -0
- package/dist/core/exml/xml-parser.d.ts +61 -0
- package/dist/core/exml/xml-parser.d.ts.map +1 -0
- package/dist/core/exml/xml-parser.js +201 -0
- package/dist/core/exml/xml-parser.js.map +1 -0
- package/dist/core/namespace-external-plugin.d.ts +45 -0
- package/dist/core/namespace-external-plugin.d.ts.map +1 -0
- package/dist/core/namespace-external-plugin.js +66 -0
- package/dist/core/namespace-external-plugin.js.map +1 -0
- package/dist/core/pipeline.d.ts +75 -0
- package/dist/core/pipeline.d.ts.map +1 -0
- package/dist/core/pipeline.js +30 -0
- package/dist/core/pipeline.js.map +1 -0
- package/dist/core/plugins/clean-output.d.ts +3 -0
- package/dist/core/plugins/clean-output.d.ts.map +1 -0
- package/dist/core/plugins/clean-output.js +11 -0
- package/dist/core/plugins/clean-output.js.map +1 -0
- package/dist/core/plugins/compile-custom-namespaces.d.ts +19 -0
- package/dist/core/plugins/compile-custom-namespaces.d.ts.map +1 -0
- package/dist/core/plugins/compile-custom-namespaces.js +104 -0
- package/dist/core/plugins/compile-custom-namespaces.js.map +1 -0
- package/dist/core/plugins/compile-engine.d.ts +19 -0
- package/dist/core/plugins/compile-engine.d.ts.map +1 -0
- package/dist/core/plugins/compile-engine.js +75 -0
- package/dist/core/plugins/compile-engine.js.map +1 -0
- package/dist/core/plugins/compile-exml.d.ts +14 -0
- package/dist/core/plugins/compile-exml.d.ts.map +1 -0
- package/dist/core/plugins/compile-exml.js +223 -0
- package/dist/core/plugins/compile-exml.js.map +1 -0
- package/dist/core/plugins/compile-source.d.ts +14 -0
- package/dist/core/plugins/compile-source.d.ts.map +1 -0
- package/dist/core/plugins/compile-source.js +132 -0
- package/dist/core/plugins/compile-source.js.map +1 -0
- package/dist/core/plugins/copy-assets.d.ts +12 -0
- package/dist/core/plugins/copy-assets.d.ts.map +1 -0
- package/dist/core/plugins/copy-assets.js +33 -0
- package/dist/core/plugins/copy-assets.js.map +1 -0
- package/dist/core/plugins/generate-html.d.ts +16 -0
- package/dist/core/plugins/generate-html.d.ts.map +1 -0
- package/dist/core/plugins/generate-html.js +137 -0
- package/dist/core/plugins/generate-html.js.map +1 -0
- package/dist/core/plugins/index.d.ts +21 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/index.js +39 -0
- package/dist/core/plugins/index.js.map +1 -0
- package/dist/core/plugins/manifest.d.ts +14 -0
- package/dist/core/plugins/manifest.d.ts.map +1 -0
- package/dist/core/plugins/manifest.js +28 -0
- package/dist/core/plugins/manifest.js.map +1 -0
- package/dist/core/project.d.ts +95 -0
- package/dist/core/project.d.ts.map +1 -0
- package/dist/core/project.js +79 -0
- package/dist/core/project.js.map +1 -0
- package/dist/core/template.d.ts +13 -0
- package/dist/core/template.d.ts.map +1 -0
- package/dist/core/template.js +79 -0
- package/dist/core/template.js.map +1 -0
- package/dist/define.d.ts +2 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +2 -0
- package/dist/define.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/fs.d.ts +5 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +30 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +18 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +45 -0
- package/templates/empty/kurot.config.ts +13 -0
- package/templates/empty/package.json +17 -0
- package/templates/empty/pnpm-workspace.yaml +3 -0
- package/templates/empty/src/Main.ts +32 -0
- package/templates/empty/template/web/index.html +38 -0
- package/templates/empty/tsconfig.json +10 -0
- package/templates/game/kurot.config.ts +16 -0
- package/templates/game/package.json +19 -0
- package/templates/game/pnpm-workspace.yaml +3 -0
- package/templates/game/resource/assets/eui.json +24 -0
- package/templates/game/resource/assets/eui.png +0 -0
- package/templates/game/resource/default.res.json +15 -0
- package/templates/game/resource/default.thm.json +19 -0
- package/templates/game/resource/skins/ButtonSkin.exml +16 -0
- package/templates/game/resource/skins/CheckBoxSkin.exml +18 -0
- package/templates/game/resource/skins/ComboBoxSkin.exml +31 -0
- package/templates/game/resource/skins/GroupSkin.exml +4 -0
- package/templates/game/resource/skins/HScrollBarSkin.exml +6 -0
- package/templates/game/resource/skins/HSliderSkin.exml +7 -0
- package/templates/game/resource/skins/ImageSkin.exml +4 -0
- package/templates/game/resource/skins/ItemRendererSkin.exml +15 -0
- package/templates/game/resource/skins/LabelSkin.exml +7 -0
- package/templates/game/resource/skins/ListSkin.exml +11 -0
- package/templates/game/resource/skins/PanelSkin.exml +15 -0
- package/templates/game/resource/skins/ProgressBarSkin.exml +11 -0
- package/templates/game/resource/skins/RadioButtonSkin.exml +18 -0
- package/templates/game/resource/skins/ScrollerSkin.exml +8 -0
- package/templates/game/resource/skins/TabBarSkin.exml +6 -0
- package/templates/game/resource/skins/TextInputSkin.exml +22 -0
- package/templates/game/resource/skins/ToggleButtonSkin.exml +21 -0
- package/templates/game/resource/skins/ToggleSwitchSkin.exml +15 -0
- package/templates/game/resource/skins/VScrollBarSkin.exml +6 -0
- package/templates/game/resource/skins/VSliderSkin.exml +7 -0
- package/templates/game/resource/skins/ViewStackSkin.exml +4 -0
- package/templates/game/src/LoadingUI.ts +27 -0
- package/templates/game/src/Main.ts +165 -0
- package/templates/game/template/web/index.html +109 -0
- package/templates/game/template/web/logo.png +0 -0
- package/templates/game/tsconfig.json +10 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes an absolute file path into a namespace-module lookup key by
|
|
4
|
+
* stripping its extension, if present.
|
|
5
|
+
*
|
|
6
|
+
* Both sides of the lookup go through this: `compile-custom-namespaces.ts`
|
|
7
|
+
* keys `ctx.outputs.namespaceModules` by the exact files esbuild reports it
|
|
8
|
+
* inlined (`metafile.outputs[x].inputs`), and `namespaceModuleExternalPlugin`
|
|
9
|
+
* normalizes a resolved import path the same way before checking the map.
|
|
10
|
+
* Stripping the extension is what lets a `./HeroNarrowIR.js` import (the
|
|
11
|
+
* `.js`-suffixed ESM import convention used throughout this codebase, e.g.
|
|
12
|
+
* `import { HeroNarrowIR } from './ui/index.js'`) match its `HeroNarrowIR.ts`
|
|
13
|
+
* source file (the metafile key).
|
|
14
|
+
*
|
|
15
|
+
* @param absolutePath - Absolute file path to normalize
|
|
16
|
+
* @returns The path with its extension stripped, if any
|
|
17
|
+
*/
|
|
18
|
+
export function normalizeModuleKey(absolutePath) {
|
|
19
|
+
const ext = path.extname(absolutePath);
|
|
20
|
+
return ext ? absolutePath.slice(0, -ext.length) : absolutePath;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Rewrites imports that resolve to a project-defined namespace's source files
|
|
24
|
+
* to that namespace's virtual specifier, marking them external.
|
|
25
|
+
*
|
|
26
|
+
* A custom-namespace class (e.g. `HeroNarrowIR`) can be referenced two ways:
|
|
27
|
+
* game code imports it by relative path (`./ui/HeroNarrowIR.js`), while
|
|
28
|
+
* EXML-generated skins import it by the virtual specifier (`#ns/game`,
|
|
29
|
+
* resolved via the HTML import map — see `compile-custom-namespaces.ts`).
|
|
30
|
+
* `external: [specifier]` alone only catches the second case; esbuild matches
|
|
31
|
+
* externals by the literal import string, so the relative import would
|
|
32
|
+
* otherwise get inlined as a second, distinct copy of the class with
|
|
33
|
+
* mismatched `instanceof` identity.
|
|
34
|
+
*
|
|
35
|
+
* `namespaceModules` is precise (sourced from esbuild's own metafile, not a
|
|
36
|
+
* guess), so this covers every file a namespace chunk actually inlined — not
|
|
37
|
+
* just its barrel entry point. Deliberately synchronous and does no file
|
|
38
|
+
* system I/O: esbuild's own docs warn against calling `build.resolve()`
|
|
39
|
+
* recursively from within `onResolve` (no loop detection), and this codebase's
|
|
40
|
+
* `.js`-suffixed import convention (see `normalizeModuleKey`) makes that
|
|
41
|
+
* unnecessary — a plain path + extension-strip is enough to match.
|
|
42
|
+
*
|
|
43
|
+
* @param namespaceModules - Extensionless absolute path → virtual specifier,
|
|
44
|
+
* populated from esbuild's `metafile.outputs[x].inputs` (see `compile-custom-namespaces.ts`)
|
|
45
|
+
* @returns An esbuild plugin implementing the rewrite
|
|
46
|
+
*/
|
|
47
|
+
export function namespaceModuleExternalPlugin(namespaceModules) {
|
|
48
|
+
return {
|
|
49
|
+
name: 'kurot-namespace-external',
|
|
50
|
+
setup(build) {
|
|
51
|
+
if (namespaceModules.size === 0)
|
|
52
|
+
return;
|
|
53
|
+
build.onResolve({ filter: /^\./ }, args => {
|
|
54
|
+
// Entry points resolve normally; only rewrite actual import statements.
|
|
55
|
+
if (args.kind !== 'import-statement' && args.kind !== 'dynamic-import')
|
|
56
|
+
return undefined;
|
|
57
|
+
const resolved = path.resolve(args.resolveDir, args.path);
|
|
58
|
+
const specifier = namespaceModules.get(normalizeModuleKey(resolved));
|
|
59
|
+
if (!specifier)
|
|
60
|
+
return undefined;
|
|
61
|
+
return { path: specifier, external: true };
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=namespace-external-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace-external-plugin.js","sourceRoot":"","sources":["../../src/core/namespace-external-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,kBAAkB,CAAC,YAAoB;IACtD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;AAChE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,6BAA6B,CAAC,gBAA6C;IAC1F,OAAO;QACN,IAAI,EAAE,0BAA0B;QAChC,KAAK,CAAC,KAAK;YACV,IAAI,gBAAgB,CAAC,IAAI,KAAK,CAAC;gBAAE,OAAO;YAExC,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE;gBACzC,wEAAwE;gBACxE,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB;oBAAE,OAAO,SAAS,CAAC;gBAEzF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC1D,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACrE,IAAI,CAAC,SAAS;oBAAE,OAAO,SAAS,CAAC;gBAEjC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC5C,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Project } from './project.js';
|
|
2
|
+
/**
|
|
3
|
+
* Shared state threaded through every build plugin.
|
|
4
|
+
*
|
|
5
|
+
* Plugins read the immutable `project` and `options`, and communicate results
|
|
6
|
+
* to later plugins through `outputs` (e.g. the source compiler reports the
|
|
7
|
+
* generated entry script name so the HTML generator can reference it).
|
|
8
|
+
*/
|
|
9
|
+
export interface BuildContext {
|
|
10
|
+
readonly project: Project;
|
|
11
|
+
readonly sourcemap: boolean;
|
|
12
|
+
readonly analyze: boolean;
|
|
13
|
+
readonly watch: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Artifacts produced during the build, populated incrementally by plugins.
|
|
16
|
+
*/
|
|
17
|
+
readonly outputs: {
|
|
18
|
+
/**
|
|
19
|
+
* Entry script path, relative to the output dir (e.g. `Main.js`, `js/main.min_ab12.js`).
|
|
20
|
+
*/
|
|
21
|
+
entryScript?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Compiled skins module path, relative to the output dir (e.g. `js/default.thm.js`).
|
|
24
|
+
*/
|
|
25
|
+
skinsScript?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Engine import-map: package specifier → chunk path relative to output dir.
|
|
28
|
+
*/
|
|
29
|
+
engine: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Every source file bundled into a custom-namespace chunk (see
|
|
32
|
+
* `compile-custom-namespaces.ts`), keyed by its extensionless absolute
|
|
33
|
+
* path (see `normalizeModuleKey` in `namespace-external-plugin.ts`) and
|
|
34
|
+
* mapped to that namespace's virtual specifier (e.g. `#ns/game`).
|
|
35
|
+
*
|
|
36
|
+
* Populated from esbuild's `metafile.outputs[x].inputs` — the exact set
|
|
37
|
+
* of files a chunk inlined, not a guess. Two consumers rely on this:
|
|
38
|
+
* `compile-source.ts` excludes these files from its per-file dev output
|
|
39
|
+
* (re-emitting them as separate entry points would bundle a second,
|
|
40
|
+
* distinct copy of the same classes), and `namespaceModuleExternalPlugin`
|
|
41
|
+
* rewrites any import resolving to one of these paths — even a relative
|
|
42
|
+
* import that bypasses the namespace's barrel file — to the matching
|
|
43
|
+
* specifier instead of inlining it.
|
|
44
|
+
*/
|
|
45
|
+
namespaceModules: Map<string, string>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Cleanup callbacks registered by long-lived plugins (watchers, contexts).
|
|
49
|
+
*/
|
|
50
|
+
readonly disposers: Array<() => Promise<void> | void>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A single, named step in the build pipeline.
|
|
54
|
+
*/
|
|
55
|
+
export interface BuildPlugin {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
apply(ctx: BuildContext): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a fresh build context for a project.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createContext(project: Project, options?: {
|
|
63
|
+
sourcemap?: boolean;
|
|
64
|
+
analyze?: boolean;
|
|
65
|
+
watch?: boolean;
|
|
66
|
+
}): BuildContext;
|
|
67
|
+
/**
|
|
68
|
+
* Runs plugins in order, logging each step.
|
|
69
|
+
*/
|
|
70
|
+
export declare function runPipeline(ctx: BuildContext, plugins: BuildPlugin[]): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Invokes every registered disposer, ignoring individual failures.
|
|
73
|
+
*/
|
|
74
|
+
export declare function disposeContext(ctx: BuildContext): Promise<void>;
|
|
75
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE;QACjB;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB;;WAEG;QACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/B;;;;;;;;;;;;;;WAcG;QACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACtC,CAAC;IACF;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;CACtD;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACvE,YAAY,CASd;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1F;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAErE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { logger } from '../utils/logger.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a fresh build context for a project.
|
|
4
|
+
*/
|
|
5
|
+
export function createContext(project, options = {}) {
|
|
6
|
+
return {
|
|
7
|
+
project,
|
|
8
|
+
sourcemap: options.sourcemap ?? false,
|
|
9
|
+
analyze: options.analyze ?? false,
|
|
10
|
+
watch: options.watch ?? false,
|
|
11
|
+
outputs: { engine: {}, namespaceModules: new Map() },
|
|
12
|
+
disposers: [],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Runs plugins in order, logging each step.
|
|
17
|
+
*/
|
|
18
|
+
export async function runPipeline(ctx, plugins) {
|
|
19
|
+
for (const plugin of plugins) {
|
|
20
|
+
logger.step(plugin.name);
|
|
21
|
+
await plugin.apply(ctx);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Invokes every registered disposer, ignoring individual failures.
|
|
26
|
+
*/
|
|
27
|
+
export async function disposeContext(ctx) {
|
|
28
|
+
await Promise.allSettled(ctx.disposers.map(dispose => dispose()));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AA8D5C;;GAEG;AACH,MAAM,UAAU,aAAa,CAC5B,OAAgB,EAChB,UAAuE,EAAE;IAEzE,OAAO;QACN,OAAO;QACP,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK;QACrC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;QACjC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;QAC7B,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,EAAE,IAAI,GAAG,EAAE,EAAE;QACpD,SAAS,EAAE,EAAE;KACb,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAiB,EAAE,OAAsB;IAC1E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAiB;IACrD,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-output.d.ts","sourceRoot":"","sources":["../../../src/core/plugins/clean-output.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,wBAAgB,WAAW,IAAI,WAAW,CAOzC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
// Removes artifacts from previous builds before writing the new output.
|
|
3
|
+
export function cleanOutput() {
|
|
4
|
+
return {
|
|
5
|
+
name: 'clean output',
|
|
6
|
+
async apply(ctx) {
|
|
7
|
+
await fs.rm(ctx.project.outputDir, { recursive: true, force: true });
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=clean-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-output.js","sourceRoot":"","sources":["../../../src/core/plugins/clean-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGvC,wEAAwE;AACxE,MAAM,UAAU,WAAW;IAC1B,OAAO;QACN,IAAI,EAAE,cAAc;QACpB,KAAK,CAAC,KAAK,CAAC,GAAG;YACd,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BuildPlugin } from '../pipeline.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bundles each project-defined EXML namespace (`exml.namespaces` in
|
|
4
|
+
* `kurot.config.ts`, matching Egret's `xmlns:game="game.*"` convention)
|
|
5
|
+
* into its own chunk under `js/`.
|
|
6
|
+
*
|
|
7
|
+
* A namespace barrel (e.g. `src/ui/index.ts` re-exporting `HeroNarrowIR`,
|
|
8
|
+
* etc.) is compiled exactly once and wired into the page via the same import
|
|
9
|
+
* map used for `@kurot/*` engine chunks (see `compile-engine.ts`). Both the
|
|
10
|
+
* app bundle (`compile-source.ts`) and the compiled skins bundle
|
|
11
|
+
* (`compile-exml.ts`) mark the namespace specifier as external, so a class
|
|
12
|
+
* referenced from EXML and from game code resolves to the same module
|
|
13
|
+
* instance — never two copies with mismatched `instanceof` identity.
|
|
14
|
+
*
|
|
15
|
+
* In watch mode each barrel is rebuilt on change; the browser still needs a
|
|
16
|
+
* manual refresh to pick up the new chunk, matching the rest of `kurot dev`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function compileCustomNamespaces(): BuildPlugin;
|
|
19
|
+
//# sourceMappingURL=compile-custom-namespaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-custom-namespaces.d.ts","sourceRoot":"","sources":["../../../src/core/plugins/compile-custom-namespaces.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGhE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,IAAI,WAAW,CAmBrD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { ensureDir } from '../../utils/fs.js';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { namespaceModuleExternalPlugin, normalizeModuleKey } from '../namespace-external-plugin.js';
|
|
6
|
+
/**
|
|
7
|
+
* Bundles each project-defined EXML namespace (`exml.namespaces` in
|
|
8
|
+
* `kurot.config.ts`, matching Egret's `xmlns:game="game.*"` convention)
|
|
9
|
+
* into its own chunk under `js/`.
|
|
10
|
+
*
|
|
11
|
+
* A namespace barrel (e.g. `src/ui/index.ts` re-exporting `HeroNarrowIR`,
|
|
12
|
+
* etc.) is compiled exactly once and wired into the page via the same import
|
|
13
|
+
* map used for `@kurot/*` engine chunks (see `compile-engine.ts`). Both the
|
|
14
|
+
* app bundle (`compile-source.ts`) and the compiled skins bundle
|
|
15
|
+
* (`compile-exml.ts`) mark the namespace specifier as external, so a class
|
|
16
|
+
* referenced from EXML and from game code resolves to the same module
|
|
17
|
+
* instance — never two copies with mismatched `instanceof` identity.
|
|
18
|
+
*
|
|
19
|
+
* In watch mode each barrel is rebuilt on change; the browser still needs a
|
|
20
|
+
* manual refresh to pick up the new chunk, matching the rest of `kurot dev`.
|
|
21
|
+
*/
|
|
22
|
+
export function compileCustomNamespaces() {
|
|
23
|
+
return {
|
|
24
|
+
name: 'compile custom namespaces',
|
|
25
|
+
async apply(ctx) {
|
|
26
|
+
const { project } = ctx;
|
|
27
|
+
if (project.customNamespaces.length === 0)
|
|
28
|
+
return;
|
|
29
|
+
const jsDir = path.join(project.outputDir, 'js');
|
|
30
|
+
await ensureDir(jsDir);
|
|
31
|
+
for (const ns of project.customNamespaces) {
|
|
32
|
+
const { chunk, inputs } = await bundleNamespace(project, ns, jsDir, ctx);
|
|
33
|
+
ctx.outputs.engine[ns.specifier] = `js/${chunk}`;
|
|
34
|
+
for (const input of inputs)
|
|
35
|
+
ctx.outputs.namespaceModules.set(normalizeModuleKey(input), ns.specifier);
|
|
36
|
+
}
|
|
37
|
+
logger.step(`bundled ${project.customNamespaces.length} custom namespace chunk(s) → js/`);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* External specifiers a namespace chunk must not inline: engine packages and
|
|
43
|
+
* every other namespace.
|
|
44
|
+
*/
|
|
45
|
+
function externalFor(project, ns) {
|
|
46
|
+
return [...project.enginePackages, ...project.customNamespaces.filter(n => n !== ns).map(n => n.specifier)];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Bundles a single namespace barrel (its entry is already an absolute file).
|
|
50
|
+
*/
|
|
51
|
+
async function bundleNamespace(project, ns, jsDir, ctx) {
|
|
52
|
+
const base = chunkBaseName(ns.prefix);
|
|
53
|
+
const minify = project.mode === 'release';
|
|
54
|
+
const options = {
|
|
55
|
+
absWorkingDir: project.root,
|
|
56
|
+
entryPoints: { [base]: ns.entry },
|
|
57
|
+
outdir: jsDir,
|
|
58
|
+
entryNames: minify ? '[name].min_[hash]' : '[name]',
|
|
59
|
+
bundle: true,
|
|
60
|
+
format: 'esm',
|
|
61
|
+
platform: 'browser',
|
|
62
|
+
target: 'es2022',
|
|
63
|
+
minify,
|
|
64
|
+
metafile: true,
|
|
65
|
+
logLevel: 'warning',
|
|
66
|
+
external: externalFor(project, ns),
|
|
67
|
+
// Catches a barrel importing a *different* namespace's module by relative
|
|
68
|
+
// path (rather than its virtual specifier) — same rewrite as in compile-source.ts.
|
|
69
|
+
// Only namespaces bundled *before* this one have entries in `namespaceModules`
|
|
70
|
+
// yet, which is fine: namespaces don't import each other in the supported
|
|
71
|
+
// migration pattern (independent barrels), and self-references are already
|
|
72
|
+
// excluded by construction (a namespace's own files aren't in the map when
|
|
73
|
+
// bundling that same namespace — see the loop in `compileCustomNamespaces`).
|
|
74
|
+
plugins: [namespaceModuleExternalPlugin(ctx.outputs.namespaceModules)],
|
|
75
|
+
};
|
|
76
|
+
if (ctx.watch) {
|
|
77
|
+
const context = await esbuild.context(options);
|
|
78
|
+
const result = await context.rebuild();
|
|
79
|
+
await context.watch();
|
|
80
|
+
ctx.disposers.push(() => context.dispose());
|
|
81
|
+
return toBundleResult(project, result, base);
|
|
82
|
+
}
|
|
83
|
+
const result = await esbuild.build(options);
|
|
84
|
+
return toBundleResult(project, result, base);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Extracts the output chunk filename and every source file it inlined from
|
|
88
|
+
* an esbuild result's metafile.
|
|
89
|
+
*/
|
|
90
|
+
function toBundleResult(project, result, base) {
|
|
91
|
+
const outputs = result.metafile.outputs;
|
|
92
|
+
const outputPath = Object.keys(outputs).find(f => f.endsWith('.js'));
|
|
93
|
+
const inputs = outputPath
|
|
94
|
+
? Object.keys(outputs[outputPath].inputs).map(input => path.resolve(project.root, input))
|
|
95
|
+
: [];
|
|
96
|
+
return { chunk: path.basename(outputPath ?? `${base}.js`), inputs };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* `game` → `ns.game` (kept distinct from `@kurot/*` engine chunk names).
|
|
100
|
+
*/
|
|
101
|
+
function chunkBaseName(prefix) {
|
|
102
|
+
return `ns.${prefix}`;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=compile-custom-namespaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-custom-namespaces.js","sourceRoot":"","sources":["../../../src/core/plugins/compile-custom-namespaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAIpG;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,uBAAuB;IACtC,OAAO;QACN,IAAI,EAAE,2BAA2B;QACjC,KAAK,CAAC,KAAK,CAAC,GAAiB;YAC5B,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;YACxB,IAAI,OAAO,CAAC,gBAAgB,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO;YAElD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACjD,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;YAEvB,KAAK,MAAM,EAAE,IAAI,OAAO,CAAC,gBAAgB,E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C,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,UAAU;QACxB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACzF,CAAC,CAAC,EAAE,CAAC;IACN,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,GAAG,IAAI,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,MAAc;IACpC,OAAO,MAAM,MAAM,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BuildPlugin } from '../pipeline.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bundles each `@kurot/*` engine package into its own chunk under `js/`,
|
|
4
|
+
* externalizing the other engine packages so code is never duplicated.
|
|
5
|
+
*
|
|
6
|
+
* The resulting chunks are wired into the page via an import map (see
|
|
7
|
+
* `generate-html`), e.g. `@kurot/core` → `js/kurot.core.js`. This mirrors
|
|
8
|
+
* Egret's split `egret.min.js` / `eui.min.js` layout while staying ESM, so the
|
|
9
|
+
* browser-side dependency graph resolves bare specifiers to cached chunks.
|
|
10
|
+
*
|
|
11
|
+
* Engine chunks change rarely, so in release mode they carry a content hash for
|
|
12
|
+
* long-term caching.
|
|
13
|
+
*/
|
|
14
|
+
export declare function compileEngine(): BuildPlugin;
|
|
15
|
+
/**
|
|
16
|
+
* `@kurot/core` → `kurot.core`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function chunkBaseName(pkg: string): string;
|
|
19
|
+
//# sourceMappingURL=compile-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-engine.d.ts","sourceRoot":"","sources":["../../../src/core/plugins/compile-engine.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGhE;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,IAAI,WAAW,CA0B3C;AAoCD;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
|
+
import * as fs from 'node:fs/promises';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { ensureDir } from '../../utils/fs.js';
|
|
5
|
+
import { logger } from '../../utils/logger.js';
|
|
6
|
+
/**
|
|
7
|
+
* Bundles each `@kurot/*` engine package into its own chunk under `js/`,
|
|
8
|
+
* externalizing the other engine packages so code is never duplicated.
|
|
9
|
+
*
|
|
10
|
+
* The resulting chunks are wired into the page via an import map (see
|
|
11
|
+
* `generate-html`), e.g. `@kurot/core` → `js/kurot.core.js`. This mirrors
|
|
12
|
+
* Egret's split `egret.min.js` / `eui.min.js` layout while staying ESM, so the
|
|
13
|
+
* browser-side dependency graph resolves bare specifiers to cached chunks.
|
|
14
|
+
*
|
|
15
|
+
* Engine chunks change rarely, so in release mode they carry a content hash for
|
|
16
|
+
* long-term caching.
|
|
17
|
+
*/
|
|
18
|
+
export function compileEngine() {
|
|
19
|
+
return {
|
|
20
|
+
name: 'compile engine',
|
|
21
|
+
async apply(ctx) {
|
|
22
|
+
const { project } = ctx;
|
|
23
|
+
if (project.enginePackages.length === 0)
|
|
24
|
+
return;
|
|
25
|
+
const jsDir = path.join(project.outputDir, 'js');
|
|
26
|
+
await ensureDir(jsDir);
|
|
27
|
+
// Stub entry files (`export * from '<pkg>'`) keep package resolution
|
|
28
|
+
// and output naming under our control. They live inside the project's
|
|
29
|
+
// node_modules so esbuild resolves engine packages correctly.
|
|
30
|
+
const stubDir = await fs.mkdtemp(path.join(project.root, 'node_modules', '.kurot-engine-'));
|
|
31
|
+
try {
|
|
32
|
+
for (const pkg of project.enginePackages) {
|
|
33
|
+
const chunk = await bundlePackage(project, pkg, stubDir, jsDir, project.mode === 'release');
|
|
34
|
+
ctx.outputs.engine[pkg] = `js/${chunk}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await fs.rm(stubDir, { recursive: true, force: true });
|
|
39
|
+
}
|
|
40
|
+
logger.step(`bundled ${project.enginePackages.length} engine chunk(s) → js/`);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Bundles a single engine package, returning its output filename.
|
|
46
|
+
*/
|
|
47
|
+
async function bundlePackage(project, pkg, stubDir, jsDir, minify) {
|
|
48
|
+
const base = chunkBaseName(pkg);
|
|
49
|
+
const stub = path.join(stubDir, `${base}.ts`);
|
|
50
|
+
await fs.writeFile(stub, `export * from '${pkg}';\n`);
|
|
51
|
+
const result = await esbuild.build({
|
|
52
|
+
absWorkingDir: project.root,
|
|
53
|
+
entryPoints: [stub],
|
|
54
|
+
outdir: jsDir,
|
|
55
|
+
entryNames: minify ? '[name].min_[hash]' : '[name]',
|
|
56
|
+
bundle: true,
|
|
57
|
+
format: 'esm',
|
|
58
|
+
platform: 'browser',
|
|
59
|
+
target: 'es2022',
|
|
60
|
+
minify,
|
|
61
|
+
metafile: true,
|
|
62
|
+
logLevel: 'warning',
|
|
63
|
+
// Other engine packages stay external — resolved via the import map.
|
|
64
|
+
external: project.enginePackages.filter(p => p !== pkg),
|
|
65
|
+
});
|
|
66
|
+
const output = Object.keys(result.metafile.outputs).find(f => f.endsWith('.js'));
|
|
67
|
+
return path.basename(output ?? `${base}.js`);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* `@kurot/core` → `kurot.core`.
|
|
71
|
+
*/
|
|
72
|
+
export function chunkBaseName(pkg) {
|
|
73
|
+
return pkg.replace(/^@/, '').replace(/\//g, '.');
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=compile-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-engine.js","sourceRoot":"","sources":["../../../src/core/plugins/compile-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAI/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa;IAC5B,OAAO;QACN,IAAI,EAAE,gBAAgB;QACtB,KAAK,CAAC,KAAK,CAAC,GAAiB;YAC5B,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;YACxB,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO;YAEhD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACjD,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;YAEvB,qEAAqE;YACrE,sEAAsE;YACtE,8DAA8D;YAC9D,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;YAC5F,IAAI,CAAC;gBACJ,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;oBAC1C,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;oBAC5F,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,M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CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAClF,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACxC,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BuildPlugin } from '../pipeline.js';
|
|
2
|
+
/**
|
|
3
|
+
* Compiles `.exml` skin files into a single ESM module and rewrites the theme.
|
|
4
|
+
*
|
|
5
|
+
* Each skin becomes a real JS factory (`import { Skin, ... } from '@kurot/ui'`)
|
|
6
|
+
* bundled into `js/default.thm.js` (dev) or `js/default.thm.min_<hash>.js`
|
|
7
|
+
* (release). The module registers each factory on `globalThis` under its class
|
|
8
|
+
* name. The output `default.thm.json` keeps only the `skins` mapping plus a
|
|
9
|
+
* `skinsJs` pointer to that module, which the runtime `Theme` imports.
|
|
10
|
+
*
|
|
11
|
+
* The input theme follows Egret conventions; no `.exml` is shipped.
|
|
12
|
+
*/
|
|
13
|
+
export declare function compileExml(): BuildPlugin;
|
|
14
|
+
//# sourceMappingURL=compile-exml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-exml.d.ts","sourceRoot":"","sources":["../../../src/core/plugins/compile-exml.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA6ChE;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,IAAI,WAAW,CA6BzC"}
|