@yali-engine/vite 0.0.0-stage → 0.4.0

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/client.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ // Types for the modules `@yali-engine/vite` serves. Add "@yali-engine/vite/client" to `compilerOptions.types`.
2
+
3
+ declare module 'virtual:yali/assets' {
4
+ import type { AssetWatch } from '@yali-engine/core';
5
+ /**
6
+ * Hot reload for the asset server in dev: pass it to `assetsPlugin({ watch: assetWatch })`.
7
+ * Undefined in a production build.
8
+ */
9
+ export const assetWatch: AssetWatch | undefined;
10
+ }
11
+
12
+ declare module 'virtual:yali/threads' {
13
+ import type { LoadedCore, ThreadsOptions, WorkerSystem } from '@yali-engine/core';
14
+ /** The worker systems listed in `yali.config.ts` (`workerSystems`). */
15
+ export const systems: readonly WorkerSystem[];
16
+ /**
17
+ * `loadCore` with the core's two builds bound (ADR-0076): threaded with `autoWorkers()`
18
+ * workers where the page is cross-origin isolated, else single-threaded, and why.
19
+ *
20
+ * @example
21
+ * const loaded = await loadCore();
22
+ * const app = App.create({ core: loaded.core, threads: threads(loaded), plugins });
23
+ */
24
+ export function loadCore(options?: { workers?: 'auto' | number; initialPages?: number }): Promise<LoadedCore>;
25
+ /** The `App.create({ threads })` object for `loaded`: the configured systems and a spawn for the generated pool worker. */
26
+ export function threads(loaded: LoadedCore, options?: Partial<ThreadsOptions>): ThreadsOptions;
27
+ }
@@ -0,0 +1,9 @@
1
+ import type { BuildStep } from './config.ts';
2
+ /** Newest modification time (ms) of the matching files under `paths`; 0 when none exist. */
3
+ export declare function newestSource(root: string, paths: readonly string[], extensions?: readonly string[]): number;
4
+ /** Whether a step's outputs are missing or older than its newest source. */
5
+ export declare function isStale(root: string, step: BuildStep): boolean;
6
+ /** Runs a step's commands in order. Fails with a `BUILD_FAILED` error carrying the output tail. */
7
+ export declare function runStep(root: string, step: BuildStep): Promise<{
8
+ ms: number;
9
+ }>;
package/dist/builds.js ADDED
@@ -0,0 +1,66 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync, readdirSync, statSync } from 'node:fs';
3
+ import { extname, join, resolve } from 'node:path';
4
+ import { YaliError } from '@yali-engine/core';
5
+ /** Directories never scanned for sources. */
6
+ const SKIP = new Set(['node_modules', 'target', '.git', 'dist']);
7
+ /** Newest modification time (ms) of the matching files under `paths`; 0 when none exist. */
8
+ export function newestSource(root, paths, extensions) {
9
+ let newest = 0;
10
+ const walk = (p) => {
11
+ let st;
12
+ try {
13
+ st = statSync(p);
14
+ }
15
+ catch {
16
+ return;
17
+ }
18
+ if (st.isDirectory()) {
19
+ for (const e of readdirSync(p))
20
+ if (!SKIP.has(e))
21
+ walk(join(p, e));
22
+ }
23
+ else if (!extensions || extensions.includes(extname(p))) {
24
+ newest = Math.max(newest, st.mtimeMs);
25
+ }
26
+ };
27
+ for (const p of paths)
28
+ walk(resolve(root, p));
29
+ return newest;
30
+ }
31
+ /** Whether a step's outputs are missing or older than its newest source. */
32
+ export function isStale(root, step) {
33
+ const src = newestSource(root, step.sources, step.extensions);
34
+ for (const o of step.outputs) {
35
+ const p = resolve(root, o);
36
+ if (!existsSync(p) || statSync(p).mtimeMs < src)
37
+ return true;
38
+ }
39
+ return false;
40
+ }
41
+ /** Runs one argv in `cwd`; resolves with the combined output, rejects with its tail. */
42
+ function run(argv, cwd) {
43
+ const [cmd, ...args] = argv;
44
+ return new Promise((ok, no) => {
45
+ const child = spawn(cmd === 'node' ? process.execPath : cmd, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
46
+ let out = '';
47
+ child.stdout.on('data', (d) => (out += d));
48
+ child.stderr.on('data', (d) => (out += d));
49
+ child.on('error', (e) => no(e));
50
+ child.on('close', (code) => (code === 0 ? ok(out) : no(new Error(`exit ${code}\n${out.split('\n').slice(-25).join('\n')}`))));
51
+ });
52
+ }
53
+ /** Runs a step's commands in order. Fails with a `BUILD_FAILED` error carrying the output tail. */
54
+ export async function runStep(root, step) {
55
+ const t0 = performance.now();
56
+ for (const argv of step.commands) {
57
+ try {
58
+ await run(argv, root);
59
+ }
60
+ catch (err) {
61
+ throw new YaliError('BUILD_FAILED', `Build step ${step.name} failed running \`${argv.join(' ')}\`: ${err instanceof Error ? err.message : String(err)}`, 'Fix the error above; the step reruns when its sources change.');
62
+ }
63
+ }
64
+ return { ms: performance.now() - t0 };
65
+ }
66
+ //# sourceMappingURL=builds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builds.js","sourceRoot":"","sources":["../src/builds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI9C,6CAA6C;AAC7C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEjE,4FAA4F;AAC5F,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,KAAwB,EAAE,UAA8B;IACjG,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE;QACzB,IAAI,EAAE,CAAC;QACP,IAAI,CAAC;YACH,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;QACD,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;YACrB,KAAK,MAAM,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC;gBAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;oBAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAA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,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EACnH,+DAA+D,CAChE,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,83 @@
1
+ /** A generated output rebuilt when its sources change (the core WASM, linked shaders). */
2
+ export interface BuildStep {
3
+ /** Shown in logs (`wasm`, `shaders`). */
4
+ readonly name: string;
5
+ /** Directories or files, relative to the Vite root, whose changes make the outputs stale. */
6
+ readonly sources: readonly string[];
7
+ /** Source file extensions that count (default: every file). */
8
+ readonly extensions?: readonly string[];
9
+ /** Files the command writes, relative to the Vite root. Missing or older = stale. */
10
+ readonly outputs: readonly string[];
11
+ /** Commands run in order in the Vite root, as argv arrays (`node` is this Node). */
12
+ readonly commands: readonly (readonly string[])[];
13
+ /** What the dev server runs instead (default `commands`): e.g. a WASM build without
14
+ * `wasm-opt`, so a Rust edit reloads sooner. A production build always runs `commands`. */
15
+ readonly devCommands?: readonly (readonly string[])[];
16
+ /** Reload the page after a rebuild in dev (default true; Vite HMRs `.ts` outputs itself). */
17
+ readonly reload?: boolean;
18
+ }
19
+ /** `yali.config.ts`: what a Yali project tells its tools. */
20
+ export interface YaliConfig {
21
+ /** Dev and preview port. The server refuses another one rather than drifting. */
22
+ readonly port?: number;
23
+ /** Serve COOP/COEP so the page is cross-origin isolated and threads work (default true). */
24
+ readonly threads?: boolean;
25
+ /** Files in this directory hot-reload through the asset server instead of reloading the
26
+ * page (default: Vite's `publicDir`). Relative to the Vite root. */
27
+ readonly assetsDir?: string;
28
+ /** Generated outputs to keep fresh. */
29
+ readonly builds?: readonly BuildStep[];
30
+ /**
31
+ * The headless entry (`yali headless`, MCP `run_headless`): a module, relative to the
32
+ * project, whose default export builds the app for a run without a browser or GPU
33
+ * (`HeadlessEntry` in `@yali-engine/core`, ADR-0041).
34
+ */
35
+ readonly headless?: string;
36
+ /**
37
+ * TS worker systems the app's pool runs (ADR-0076): modules, relative to the Vite root,
38
+ * whose default export is a `defineWorkerSystem(…)`. `virtual:yali/threads` imports them
39
+ * and generates the pool worker that serves them, so the app writes no worker file.
40
+ */
41
+ readonly workerSystems?: readonly string[];
42
+ /**
43
+ * The two core modules `virtual:yali/threads` loads (default: `@yali-engine/core`'s). A game crate
44
+ * built together with the core (ADR-0077) points these at its own build, relative to the
45
+ * Vite root (`build-wasm.mjs --crate … --out …` writes `game.wasm` and `game.threads.wasm`).
46
+ */
47
+ readonly coreWasm?: {
48
+ readonly single: string;
49
+ readonly threads: string;
50
+ };
51
+ /**
52
+ * Runtime plugins compiled into the core module `virtual:yali/threads` loads (ADR-0082):
53
+ * `'anim'` for `@yali-engine/animation`, `'physics'` for `@yali-engine/physics`. Default: those whose
54
+ * package the project depends on (its package.json). Ignored with `coreWasm`, whose module
55
+ * carries what its game crate was built with (`yali game --features …`).
56
+ */
57
+ readonly features?: readonly CoreFeatureName[];
58
+ }
59
+ /** A runtime plugin a core variant can carry (ADR-0082). */
60
+ export type CoreFeatureName = 'anim' | 'physics';
61
+ /** Each core feature and the package that needs it, in variant file-name order. */
62
+ export declare const CORE_FEATURES: readonly {
63
+ readonly feature: CoreFeatureName;
64
+ readonly pkg: string;
65
+ }[];
66
+ /**
67
+ * Types a `yali.config.ts`.
68
+ *
69
+ * @example
70
+ * // yali.config.ts
71
+ * import { defineConfig } from '@yali-engine/vite';
72
+ * export default defineConfig({ port: 3150, threads: true });
73
+ */
74
+ export declare function defineConfig(config: YaliConfig): YaliConfig;
75
+ /** Config file names, in the order they are looked for. */
76
+ export declare const CONFIG_FILES: readonly ["yali.config.ts", "yali.config.mts", "yali.config.js", "yali.config.mjs"];
77
+ /** The config file in `root`, or null. */
78
+ export declare function findConfigFile(root: string): string | null;
79
+ /**
80
+ * Checks a config and fills defaults. Every error names the field (`builds[1].outputs`),
81
+ * what is wrong and the fix.
82
+ */
83
+ export declare function validateConfig(raw: unknown): Required<Pick<YaliConfig, 'threads' | 'builds'>> & YaliConfig;
package/dist/config.js ADDED
@@ -0,0 +1,107 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { YaliError } from '@yali-engine/core';
4
+ /** Each core feature and the package that needs it, in variant file-name order. */
5
+ export const CORE_FEATURES = [
6
+ { feature: 'anim', pkg: '@yali-engine/animation' },
7
+ { feature: 'physics', pkg: '@yali-engine/physics' },
8
+ ];
9
+ /**
10
+ * Types a `yali.config.ts`.
11
+ *
12
+ * @example
13
+ * // yali.config.ts
14
+ * import { defineConfig } from '@yali-engine/vite';
15
+ * export default defineConfig({ port: 3150, threads: true });
16
+ */
17
+ export function defineConfig(config) {
18
+ return config;
19
+ }
20
+ /** Config file names, in the order they are looked for. */
21
+ export const CONFIG_FILES = ['yali.config.ts', 'yali.config.mts', 'yali.config.js', 'yali.config.mjs'];
22
+ /** The config file in `root`, or null. */
23
+ export function findConfigFile(root) {
24
+ for (const f of CONFIG_FILES) {
25
+ const p = join(root, f);
26
+ if (existsSync(p))
27
+ return p;
28
+ }
29
+ return null;
30
+ }
31
+ function fail(path, message, fix) {
32
+ throw new YaliError('CONFIG_INVALID', `yali.config: ${path}: ${message}`, fix);
33
+ }
34
+ /**
35
+ * Checks a config and fills defaults. Every error names the field (`builds[1].outputs`),
36
+ * what is wrong and the fix.
37
+ */
38
+ export function validateConfig(raw) {
39
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
40
+ fail('(root)', `expected an object, got ${raw === null ? 'null' : Array.isArray(raw) ? 'an array' : typeof raw}`, 'Export `defineConfig({ … })` as the default export.');
41
+ }
42
+ const c = raw;
43
+ const known = new Set(['port', 'threads', 'assetsDir', 'builds', 'headless', 'workerSystems', 'coreWasm', 'features']);
44
+ for (const k of Object.keys(c)) {
45
+ if (!known.has(k))
46
+ fail(k, 'unknown field', `Known fields: ${[...known].join(', ')}.`);
47
+ }
48
+ if (c.port !== undefined && !(Number.isInteger(c.port) && c.port >= 1024 && c.port <= 65535)) {
49
+ fail('port', `expected an integer 1024–65535, got ${JSON.stringify(c.port)}`, 'Use the port registered for this project.');
50
+ }
51
+ if (c.threads !== undefined && typeof c.threads !== 'boolean')
52
+ fail('threads', `expected a boolean, got ${JSON.stringify(c.threads)}`, 'Use true or false.');
53
+ if (c.assetsDir !== undefined && typeof c.assetsDir !== 'string')
54
+ fail('assetsDir', 'expected a string', 'Give a directory relative to the Vite root.');
55
+ if (c.headless !== undefined && (typeof c.headless !== 'string' || !c.headless))
56
+ fail('headless', 'expected a module path', "Give the headless entry relative to the project, e.g. 'src/headless.ts'.");
57
+ if (c.workerSystems !== undefined && !(Array.isArray(c.workerSystems) && c.workerSystems.every((x) => typeof x === 'string' && x))) {
58
+ fail('workerSystems', 'expected an array of module paths', "List the worker system modules relative to the Vite root, e.g. ['src/orbit.system.ts'].");
59
+ }
60
+ if (c.coreWasm !== undefined) {
61
+ const w = c.coreWasm;
62
+ for (const k of ['single', 'threads']) {
63
+ if (!w || typeof w !== 'object' || typeof w[k] !== 'string' || !w[k]) {
64
+ fail(`coreWasm.${k}`, 'expected a .wasm path', "Give both builds relative to the Vite root, e.g. { single: 'wasm/game.wasm', threads: 'wasm/game.threads.wasm' }.");
65
+ }
66
+ }
67
+ }
68
+ if (c.features !== undefined) {
69
+ const names = CORE_FEATURES.map((f) => f.feature);
70
+ if (!Array.isArray(c.features) || !c.features.every((f) => typeof f === 'string' && names.includes(f))) {
71
+ fail('features', `expected an array of ${names.map((n) => `'${n}'`).join(' / ')}, got ${JSON.stringify(c.features)}`, `List the runtime plugins the app uses, e.g. features: ['physics'].`);
72
+ }
73
+ }
74
+ const builds = c.builds ?? [];
75
+ if (!Array.isArray(builds))
76
+ fail('builds', 'expected an array', 'Use `builds: [{ name, sources, outputs, commands }]`.');
77
+ const names = new Set();
78
+ builds.forEach((b, i) => {
79
+ const at = `builds[${i}]`;
80
+ if (b === null || typeof b !== 'object')
81
+ fail(at, 'expected an object', 'Use `{ name, sources, outputs, commands }`.');
82
+ const s = b;
83
+ if (typeof s.name !== 'string' || !s.name)
84
+ fail(`${at}.name`, 'expected a non-empty string', 'Name the step (`wasm`, `shaders`).');
85
+ if (names.has(s.name))
86
+ fail(`${at}.name`, `duplicate step name ${s.name}`, 'Give each step a unique name.');
87
+ names.add(s.name);
88
+ for (const f of ['sources', 'outputs']) {
89
+ if (!Array.isArray(s[f]) || s[f].length === 0 || !s[f].every((x) => typeof x === 'string')) {
90
+ fail(`${at}.${f}`, 'expected a non-empty array of paths', 'Paths are relative to the Vite root.');
91
+ }
92
+ }
93
+ if (s.extensions !== undefined && !(Array.isArray(s.extensions) && s.extensions.every((x) => typeof x === 'string' && x.startsWith('.')))) {
94
+ fail(`${at}.extensions`, 'expected an array like [".rs", ".toml"]', 'Each extension starts with a dot.');
95
+ }
96
+ for (const f of ['commands', 'devCommands']) {
97
+ if (f === 'devCommands' && s[f] === undefined)
98
+ continue;
99
+ const v = s[f];
100
+ if (!Array.isArray(v) || v.length === 0 || !v.every((cmd) => Array.isArray(cmd) && cmd.length > 0 && cmd.every((a) => typeof a === 'string'))) {
101
+ fail(`${at}.${f}`, 'expected a non-empty array of argv arrays', `Use \`${f}: [["node", "scripts/build.mjs"]]\`.`);
102
+ }
103
+ }
104
+ });
105
+ return { ...c, threads: c.threads ?? true, builds: builds };
106
+ }
107
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AA8D9C,mFAAmF;AACnF,MAAM,CAAC,MAAM,aAAa,GAA2E;IACnG,EAAE,OAAO,EAAE,MAAM,EAAE,GAA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IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,2CAA2C,EAAE,SAAS,CAAC,sCAAsC,CAAC,CAAC;YACpH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,GAAI,CAAgB,EAAE,OAAO,EAAG,CAAC,CAAC,OAA+B,IAAI,IAAI,EAAE,MAAM,EAAE,MAAqB,EAAE,CAAC;AACtH,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type Plugin } from 'vite';
2
+ import { type CoreFeatureName, type YaliConfig } from './config.ts';
3
+ export { type BuildStep, CONFIG_FILES, CORE_FEATURES, type CoreFeatureName, defineConfig, findConfigFile, validateConfig, type YaliConfig } from './config.ts';
4
+ export { isStale, newestSource, runStep } from './builds.ts';
5
+ /** The custom HMR event the plugin sends when a file in the assets directory changes. */
6
+ export declare const ASSET_EVENT = "yali:asset-changed";
7
+ /**
8
+ * The core features an app needs (ADR-0082): `features` from the config when given, else
9
+ * those whose package `root`'s package.json depends on, in variant file-name order.
10
+ */
11
+ export declare function resolveFeatures(root: string, configured?: readonly CoreFeatureName[]): CoreFeatureName[];
12
+ /** `@yali-engine/core`'s module for a feature set: `yali_core[.anim][.physics][.threads].wasm`. */
13
+ export declare function coreVariant(features: readonly CoreFeatureName[], threads: boolean): string;
14
+ /** Loads `yali.config.*` from `root` (TypeScript included), or returns `{}` when there is none. */
15
+ export declare function loadConfig(root: string): Promise<{
16
+ config: YaliConfig;
17
+ file: string | null;
18
+ }>;
19
+ /**
20
+ * The Yali Vite plugin. Inline options override `yali.config.ts` field by field.
21
+ *
22
+ * - **Port:** `port` is applied to dev and preview with `strictPort`, so the server
23
+ * refuses to drift to another port. A port given explicitly (`--port`) wins.
24
+ * - **Threads:** `threads` (default true) serves the COOP/COEP headers that cross-origin
25
+ * isolate the page (SharedArrayBuffer, the threaded core, script workers).
26
+ * - **Core variant:** `virtual:yali/threads` loads the core module carrying the runtime
27
+ * plugins the app uses (`features`, or its `@yali-engine/animation` / `@yali-engine/physics`
28
+ * dependencies; ADR-0082). An app that uses neither loads the base core.
29
+ * - **Build steps:** outputs that are stale are rebuilt before the dev server or a build
30
+ * starts. In dev, a source change rebuilds them and reloads the page; a failure shows
31
+ * Vite's error overlay.
32
+ * - **Asset hot reload:** a change under the assets directory (default `publicDir`) is
33
+ * sent as a `yali:asset-changed` event instead of reloading the page.
34
+ * `virtual:yali/assets` turns it into a `watch` function for `assetsPlugin`.
35
+ */
36
+ export declare function yali(inline?: YaliConfig): Plugin;
package/dist/index.js ADDED
@@ -0,0 +1,288 @@
1
+ /**
2
+ * `@yali-engine/vite`: the Vite plugin for Yali projects (DESIGN.md §13, §19).
3
+ *
4
+ * @example
5
+ * // vite.config.ts
6
+ * import { defineConfig } from 'vite';
7
+ * import { yali } from '@yali-engine/vite';
8
+ * export default defineConfig({ plugins: [yali()] });
9
+ *
10
+ * // game code: asset hot reload in dev
11
+ * import { assetWatch } from 'virtual:yali/assets';
12
+ * assetsPlugin({ loaders: [jsonLoader], watch: assetWatch });
13
+ */
14
+ import { existsSync, readFileSync } from 'node:fs';
15
+ import { relative, resolve, sep } from 'node:path';
16
+ import { YaliError } from '@yali-engine/core';
17
+ import { runnerImport } from 'vite';
18
+ import { isStale, runStep } from "./builds.js";
19
+ import { CORE_FEATURES, findConfigFile, validateConfig } from "./config.js";
20
+ export { CONFIG_FILES, CORE_FEATURES, defineConfig, findConfigFile, validateConfig } from "./config.js";
21
+ export { isStale, newestSource, runStep } from "./builds.js";
22
+ /** The custom HMR event the plugin sends when a file in the assets directory changes. */
23
+ export const ASSET_EVENT = 'yali:asset-changed';
24
+ const VIRTUAL_ASSETS = 'virtual:yali/assets';
25
+ const RESOLVED_ASSETS = `\0${VIRTUAL_ASSETS}`;
26
+ /** What `virtual:yali/assets` contains: a watch function in dev, undefined in a build. */
27
+ const ASSETS_MODULE = `export const assetWatch = import.meta.hot
28
+ ? (reload) => {
29
+ const on = (data) => reload(data.path);
30
+ import.meta.hot.on(${JSON.stringify(ASSET_EVENT)}, on);
31
+ return () => import.meta.hot.off?.(${JSON.stringify(ASSET_EVENT)}, on);
32
+ }
33
+ : undefined;
34
+ `;
35
+ const ISOLATION = {
36
+ 'Cross-Origin-Opener-Policy': 'same-origin',
37
+ 'Cross-Origin-Embedder-Policy': 'require-corp',
38
+ };
39
+ const VIRTUAL_THREADS = 'virtual:yali/threads';
40
+ const RESOLVED_THREADS = `\0${VIRTUAL_THREADS}`;
41
+ const VIRTUAL_POOL_WORKER = 'virtual:yali/pool-worker';
42
+ // The pool worker resolves to a path inside the root that no file has: Vite's dev server
43
+ // gives a worker outside the root a /@fs/ URL, which a virtual id (with or without \0)
44
+ // cannot be served from (measured with Vite 7.3.7). Served as /yali-pool-worker.virtual.js.
45
+ const POOL_WORKER_FILE = 'yali-pool-worker.virtual.js';
46
+ const poolWorkerId = (root) => `${root.split(sep).join('/')}/${POOL_WORKER_FILE}`;
47
+ /** The worker system modules as import lines and their names, checked to exist. */
48
+ function systemImports(root, paths) {
49
+ const lines = paths.map((p, i) => {
50
+ const abs = resolve(root, p);
51
+ if (!existsSync(abs)) {
52
+ throw new YaliError('CONFIG_INVALID', `yali.config: workerSystems[${i}]: ${p} does not exist`, 'Paths are relative to the Vite root; each module default-exports a defineWorkerSystem(…).');
53
+ }
54
+ return `import s${i} from ${JSON.stringify(abs.split(sep).join('/'))};`;
55
+ });
56
+ return { lines: lines.join('\n'), names: paths.map((_, i) => `s${i}`).join(', ') };
57
+ }
58
+ /**
59
+ * The core features an app needs (ADR-0082): `features` from the config when given, else
60
+ * those whose package `root`'s package.json depends on, in variant file-name order.
61
+ */
62
+ export function resolveFeatures(root, configured) {
63
+ let wanted;
64
+ if (configured) {
65
+ wanted = (f) => configured.includes(f.feature);
66
+ }
67
+ else {
68
+ const file = resolve(root, 'package.json');
69
+ let deps = {};
70
+ if (existsSync(file)) {
71
+ const json = JSON.parse(readFileSync(file, 'utf8'));
72
+ deps = { ...json.devDependencies, ...json.dependencies };
73
+ }
74
+ wanted = (f) => f.pkg in deps;
75
+ }
76
+ return CORE_FEATURES.filter(wanted).map((f) => f.feature);
77
+ }
78
+ /** `@yali-engine/core`'s module for a feature set: `yali_core[.anim][.physics][.threads].wasm`. */
79
+ export function coreVariant(features, threads) {
80
+ if (features.length === 0)
81
+ return threads ? '@yali-engine/core/wasm/threads' : '@yali-engine/core/wasm';
82
+ return `@yali-engine/core/wasm/yali_core${features.map((f) => `.${f}`).join('')}${threads ? '.threads' : ''}.wasm`;
83
+ }
84
+ /**
85
+ * `virtual:yali/threads` (ADR-0076): `loadCore()` with the core's two builds bound (threads
86
+ * where the page can run them), and `threads(loaded)`, the `App.create({ threads })` object:
87
+ * the configured worker systems and a spawn for the generated pool worker. The builds are the
88
+ * core variant carrying `features` (ADR-0082), or a game crate's module (`coreWasm`).
89
+ */
90
+ function threadsModule(root, paths, coreWasm, features) {
91
+ const { lines, names } = systemImports(root, paths);
92
+ const file = (p) => JSON.stringify(`${resolve(root, p).split(sep).join('/')}?url`);
93
+ const [single, threaded] = coreWasm
94
+ ? [file(coreWasm.single), file(coreWasm.threads)]
95
+ : [JSON.stringify(`${coreVariant(features, false)}?url`), JSON.stringify(`${coreVariant(features, true)}?url`)];
96
+ return `import { loadCore as load } from '@yali-engine/core';
97
+ import wasmUrl from ${single};
98
+ import threadsWasmUrl from ${threaded};
99
+ import PoolWorker from '${VIRTUAL_POOL_WORKER}?worker';
100
+ ${lines}
101
+ export const systems = [${names}];
102
+ export const features = ${JSON.stringify(coreWasm ? null : features)};
103
+ export const loadCore = (options = {}) => load({ wasm: () => fetch(wasmUrl), threadsWasm: () => fetch(threadsWasmUrl), ...options });
104
+ export function threads(loaded, options = {}) {
105
+ const spawn = (boot) => {
106
+ const w = new PoolWorker({ name: 'yali-pool' });
107
+ w.postMessage(boot);
108
+ return w;
109
+ };
110
+ return { workers: loaded.workers, reason: loaded.reason, systems, spawn, ...options };
111
+ }
112
+ `;
113
+ }
114
+ /** The pool worker `virtual:yali/threads` spawns: the configured worker systems and the core's Rust jobs. */
115
+ function poolWorkerModule(root, paths) {
116
+ const { lines, names } = systemImports(root, paths);
117
+ return `import { servePoolWorker } from '@yali-engine/core/pool-worker';
118
+ ${lines}
119
+ servePoolWorker([${names}]);
120
+ `;
121
+ }
122
+ /** Resolves the virtual modules (a `?worker` or other query is kept on the resolved id). */
123
+ function resolveVirtual(id, root) {
124
+ const [bare, query] = id.split('?', 2);
125
+ const pool = poolWorkerId(root);
126
+ const resolved = bare === VIRTUAL_ASSETS ? RESOLVED_ASSETS
127
+ : bare === VIRTUAL_THREADS ? RESOLVED_THREADS
128
+ : bare === VIRTUAL_POOL_WORKER || bare === `/${POOL_WORKER_FILE}` || bare === pool ? pool
129
+ : undefined;
130
+ return resolved && (query ? `${resolved}?${query}` : resolved);
131
+ }
132
+ /** The virtual modules' code, from the root and the configured worker systems. */
133
+ function loadVirtual(id, root, cfg) {
134
+ const workerSystems = cfg.workerSystems ?? [];
135
+ const bare = id.split('?', 1)[0];
136
+ if (bare === RESOLVED_ASSETS)
137
+ return ASSETS_MODULE;
138
+ if (bare === RESOLVED_THREADS)
139
+ return threadsModule(root, workerSystems, cfg.coreWasm, resolveFeatures(root, cfg.features));
140
+ if (bare === poolWorkerId(root))
141
+ return poolWorkerModule(root, workerSystems);
142
+ return undefined;
143
+ }
144
+ /** The virtual modules, for worker bundles (they don't run the main plugin). */
145
+ function virtualModules(root, cfg) {
146
+ return {
147
+ name: '@yali-engine/vite:virtual',
148
+ resolveId: (id) => resolveVirtual(id, root()),
149
+ load: (id) => loadVirtual(id, root(), cfg()),
150
+ };
151
+ }
152
+ /** Loads `yali.config.*` from `root` (TypeScript included), or returns `{}` when there is none. */
153
+ export async function loadConfig(root) {
154
+ const file = findConfigFile(root);
155
+ if (!file)
156
+ return { config: {}, file: null };
157
+ const { module } = await runnerImport(file, { root, logLevel: 'silent', configFile: false });
158
+ return { config: (module.default ?? {}), file };
159
+ }
160
+ /**
161
+ * The Yali Vite plugin. Inline options override `yali.config.ts` field by field.
162
+ *
163
+ * - **Port:** `port` is applied to dev and preview with `strictPort`, so the server
164
+ * refuses to drift to another port. A port given explicitly (`--port`) wins.
165
+ * - **Threads:** `threads` (default true) serves the COOP/COEP headers that cross-origin
166
+ * isolate the page (SharedArrayBuffer, the threaded core, script workers).
167
+ * - **Core variant:** `virtual:yali/threads` loads the core module carrying the runtime
168
+ * plugins the app uses (`features`, or its `@yali-engine/animation` / `@yali-engine/physics`
169
+ * dependencies; ADR-0082). An app that uses neither loads the base core.
170
+ * - **Build steps:** outputs that are stale are rebuilt before the dev server or a build
171
+ * starts. In dev, a source change rebuilds them and reloads the page; a failure shows
172
+ * Vite's error overlay.
173
+ * - **Asset hot reload:** a change under the assets directory (default `publicDir`) is
174
+ * sent as a `yali:asset-changed` event instead of reloading the page.
175
+ * `virtual:yali/assets` turns it into a `watch` function for `assetsPlugin`.
176
+ */
177
+ export function yali(inline = {}) {
178
+ let cfg;
179
+ let root = process.cwd();
180
+ let assetsDir = '';
181
+ let configFile = null;
182
+ let server = null;
183
+ let serving = false;
184
+ // Vite's logger honours logLevel ('silent' under `yali … --json`, whose stdout is one JSON
185
+ // document); it is set in configResolved, before any step can run.
186
+ let logger = { info: () => { }, error: () => { } };
187
+ const log = (msg) => logger.info(`[yali] ${msg}`);
188
+ const building = new Map();
189
+ const rerun = new Set();
190
+ const build = (step, why) => {
191
+ const running = building.get(step.name);
192
+ if (running) {
193
+ rerun.add(step.name); // a change arrived mid-build: build once more after it
194
+ return running;
195
+ }
196
+ log(`${step.name}: rebuilding (${why})`);
197
+ // The dev server may run a faster variant (devCommands); a production build never does.
198
+ const p = runStep(root, serving && step.devCommands ? { ...step, commands: step.devCommands } : step)
199
+ .then(({ ms }) => {
200
+ log(`${step.name}: built in ${(ms / 1000).toFixed(1)} s`);
201
+ if (server && (step.reload ?? true))
202
+ server.ws.send({ type: 'full-reload' });
203
+ })
204
+ .catch((err) => {
205
+ if (!server)
206
+ throw err;
207
+ logger.error(`[yali] ${err.message}`);
208
+ server.ws.send({ type: 'error', err: { message: err.message, stack: '', plugin: '@yali-engine/vite' } });
209
+ })
210
+ .finally(() => {
211
+ building.delete(step.name);
212
+ if (rerun.delete(step.name))
213
+ void build(step, 'changed during the last build');
214
+ });
215
+ building.set(step.name, p);
216
+ return p;
217
+ };
218
+ return {
219
+ name: '@yali-engine/vite',
220
+ async config(user, env) {
221
+ serving = env?.command === 'serve';
222
+ root = resolve(user.root ?? process.cwd());
223
+ const { config: fromFile, file } = await loadConfig(root);
224
+ cfg = validateConfig({ ...fromFile, ...inline });
225
+ configFile = file;
226
+ const headers = cfg.threads ? ISOLATION : undefined;
227
+ // An explicit port (`vite preview --port 3160`) wins over the file's: the GPU check
228
+ // serves a production build beside the dev server (canon port registry).
229
+ const port = (explicit) => (explicit ?? cfg.port) === undefined ? {} : { port: explicit ?? cfg.port, strictPort: true };
230
+ return {
231
+ server: { ...port(user.server?.port), ...(headers ? { headers } : {}) },
232
+ preview: { ...port(user.preview?.port), ...(headers ? { headers } : {}) },
233
+ // Workers are bundled with their own plugin list: they need the virtual module too
234
+ // (a render worker imports the same game code as the page, ADR-0034).
235
+ worker: { format: 'es', plugins: () => [virtualModules(() => root, () => cfg)] },
236
+ build: { target: user.build?.target ?? 'es2023' },
237
+ };
238
+ },
239
+ configResolved(resolved) {
240
+ root = resolved.root;
241
+ logger = resolved.logger;
242
+ if (configFile)
243
+ log(`config: ${relative(root, configFile)}`);
244
+ const features = resolveFeatures(root, cfg.features);
245
+ if (!cfg.coreWasm && features.length > 0)
246
+ log(`core variant: ${features.join(' + ')}`);
247
+ assetsDir = resolve(root, cfg.assetsDir ?? resolved.publicDir ?? 'public');
248
+ },
249
+ async buildStart() {
250
+ for (const step of cfg.builds) {
251
+ if (isStale(root, step))
252
+ await build(step, 'outputs older than sources');
253
+ }
254
+ },
255
+ resolveId(id) {
256
+ return resolveVirtual(id, root);
257
+ },
258
+ load(id) {
259
+ return loadVirtual(id, root, cfg);
260
+ },
261
+ configureServer(s) {
262
+ server = s;
263
+ const sources = cfg.builds.map((step) => ({ step, dirs: step.sources.map((p) => resolve(root, p)) }));
264
+ s.watcher.add(sources.flatMap((x) => x.dirs));
265
+ const timers = new Map();
266
+ const onFile = (file) => {
267
+ const abs = resolve(file);
268
+ if (abs.startsWith(assetsDir + sep)) {
269
+ const path = relative(assetsDir, abs).split(sep).join('/');
270
+ s.ws.send({ type: 'custom', event: ASSET_EVENT, data: { path } });
271
+ return;
272
+ }
273
+ for (const { step, dirs } of sources) {
274
+ if (!dirs.some((d) => abs === d || abs.startsWith(d + sep)))
275
+ continue;
276
+ if (step.extensions && !step.extensions.some((e) => abs.endsWith(e)))
277
+ continue;
278
+ clearTimeout(timers.get(step.name));
279
+ timers.set(step.name, setTimeout(() => void build(step, relative(root, abs)), 200));
280
+ }
281
+ };
282
+ s.watcher.on('change', onFile);
283
+ s.watcher.on('add', onFile);
284
+ s.watcher.on('unlink', onFile);
285
+ },
286
+ };
287
+ }
288
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAiD,YAAY,EAAsB,MAAM,MAAM,CAAC;AAEvG,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAkB,aAAa,EAAwB,cAAc,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAC;AAEnI,OAAO,EAAkB,YAAY,EAAE,aAAa,EAAwB,YAAY,EAAE,cAAc,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAC;AAC/J,OAAO,EAA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E,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;gBACtF,CAAC;YACH,CAAC,CAAC;YACF,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC/B,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAC5B,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@yali-engine/vite",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.4.0",
4
+ "description": "Yali's Vite plugin: yali.config.ts, threads headers, rebuilt WASM and shaders, asset hot reload.",
5
+ "license": "MIT OR Apache-2.0",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./client.d.ts"
15
+ }
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "client.d.ts"
23
+ ],
24
+ "dependencies": {
25
+ "@yali-engine/core": "0.4.0"
26
+ },
27
+ "peerDependencies": {
28
+ "vite": "^7.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "vite": "^7.0.0"
32
+ },
33
+ "scripts": {
34
+ "typecheck": "tsc -p tsconfig.json",
35
+ "test": "node --experimental-strip-types --no-warnings --test \"test/*.test.ts\""
36
+ }
6
37
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.