@ignifx/editor-host 0.11.0 → 0.13.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/dist/error-codes.d.ts +3 -3
- package/dist/error-codes.js +3 -3
- package/dist/error-codes.js.map +1 -1
- package/dist/index.d.ts +559 -240
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2207 -938
- package/dist/index.js.map +1 -1
- package/dist/vite.d.ts +6 -4
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +86 -15
- package/dist/vite.js.map +1 -1
- package/package.json +10 -8
- package/skills/editor-host/SKILL.md +58 -17
package/dist/vite.d.ts
CHANGED
|
@@ -175,7 +175,7 @@ export declare function playControlsModuleSource(options: PlayControlsModuleOpti
|
|
|
175
175
|
*/
|
|
176
176
|
interface EditorHostPluginOptions {
|
|
177
177
|
/**
|
|
178
|
-
* The origin the editor is served from, for example `"ignifx://app"` when packaged or
|
|
178
|
+
* The origin the editor is served from, for example `"ignifx-editor://app"` when packaged or
|
|
179
179
|
* `"http://localhost:5173"` while the editor itself runs from a dev server. Only this origin may
|
|
180
180
|
* frame either view in `vite dev`, and only it can hand either view a port.
|
|
181
181
|
*/
|
|
@@ -217,8 +217,10 @@ export declare function readProjectEngineVersion(root: string): string | null;
|
|
|
217
217
|
* - `ignifx-editor-host:play-controls` (every command) serves `virtual:ignifx/editor`: the play
|
|
218
218
|
* controls under `vite dev`, an empty function under `vite build`. Under `vite dev` and
|
|
219
219
|
* `vite preview` it also answers 404 to any request into `.ignifx/`, the editor's private
|
|
220
|
-
* directory, by path or through a symbolic link, as `ignifx()` does;
|
|
221
|
-
*
|
|
220
|
+
* directory, by path or through a symbolic link, as `ignifx()` does; under `vite build` it fails
|
|
221
|
+
* the build, after removing them, when the output holds a `.ignifx` directory or a copy of a
|
|
222
|
+
* `publicDir` file that links into one. This covers a config that lists this plugin without
|
|
223
|
+
* `ignifx()`.
|
|
222
224
|
*
|
|
223
225
|
* List it after `ignifx()` from `@ignifx/vite-plugin`, which serves the two modules the scene
|
|
224
226
|
* view imports.
|
|
@@ -236,7 +238,7 @@ export declare function readProjectEngineVersion(root: string): string | null;
|
|
|
236
238
|
* import { defineConfig } from "vite";
|
|
237
239
|
*
|
|
238
240
|
* export default defineConfig({
|
|
239
|
-
* plugins: [ignifx(), editorHostPlugin({ editorOrigin: "ignifx://app" })],
|
|
241
|
+
* plugins: [ignifx(), editorHostPlugin({ editorOrigin: "ignifx-editor://app" })],
|
|
240
242
|
* });
|
|
241
243
|
* ```
|
|
242
244
|
*
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite/errors.ts","../src/vite/modules.ts","../src/vite/plugin.ts"],"mappings":";;;;;;;;;qBAiBa,8BAA8B;;WAEhC,MAAM;;;;;;;EAQf,YAAY,MAAM,qBAAqB;;;;;;;;;qBCR5B;;;;;;;;;;;;;qBAcA;;;;;;qBAOA;;;;;;qBAOA;;;;;;qBAOA;;;;;;;qBAQA;;;;;;;qBAQA;;;;;;qBAOA;;;;;;UAUI;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;UAQM;;WAEN;;WAEA;;WAEA;;;;;WAKA;;;;;;;;;;;wBAYK,0BAA0B;;;;;;;;;;;;;;;;;wBAyC1B,wBAAwB,SAAS;;;;;;;;wBAoCjC;;;;;;;;;;;;;;;;;;;wBAwCA,yBAAyB,SAAS;;;;;;;;
|
|
1
|
+
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite/errors.ts","../src/vite/modules.ts","../src/vite/plugin.ts"],"mappings":";;;;;;;;;qBAiBa,8BAA8B;;WAEhC,MAAM;;;;;;;EAQf,YAAY,MAAM,qBAAqB;;;;;;;;;qBCR5B;;;;;;;;;;;;;qBAcA;;;;;;qBAOA;;;;;;qBAOA;;;;;;qBAOA;;;;;;;qBAQA;;;;;;;qBAQA;;;;;;qBAOA;;;;;;UAUI;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;UAQM;;WAEN;;WAEA;;WAEA;;;;;WAKA;;;;;;;;;;;wBAYK,0BAA0B;;;;;;;;;;;;;;;;;wBAyC1B,wBAAwB,SAAS;;;;;;;;wBAoCjC;;;;;;;;;;;;;;;;;;;wBAwCA,yBAAyB,SAAS;;;;;;;;UCjNjC;;;;;;WAMN;;;;;;WAMA;;WAEA;;WAEA;;;;;;;;;;wBAkBK,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqFzB,iBAAiB,SAAS,0BAA0B"}
|
package/dist/vite.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ASSET_CHANGED_EVENT, IGNIFX_CONFIG_DEFINE_KEY, MANIFEST_MODULE_ID, SCRI
|
|
|
3
3
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
|
+
import { readdir, rm, stat } from "node:fs/promises";
|
|
6
7
|
//#region src/vite/errors.ts
|
|
7
8
|
/**
|
|
8
9
|
* The error every `@ignifx/editor-host/vite` API throws for a misconfiguration
|
|
@@ -234,16 +235,6 @@ function playControlsModuleSource(options) {
|
|
|
234
235
|
""
|
|
235
236
|
].join("\n");
|
|
236
237
|
}
|
|
237
|
-
//#endregion
|
|
238
|
-
//#region src/vite/private-dir.ts
|
|
239
|
-
/**
|
|
240
|
-
* A copy of `@ignifx/vite-plugin`'s `.ignifx/` request guard (`src/private-dir.ts` there), kept
|
|
241
|
-
* here as defence in depth: a project whose Vite config lists `editorHostPlugin()` without
|
|
242
|
-
* `ignifx()` would otherwise serve `.ignifx/mcp.json`, the editor's MCP token, to any page.
|
|
243
|
-
* `@ignifx/vite-plugin` is an optional peer, so this package cannot import it; keep the two in step.
|
|
244
|
-
*/
|
|
245
|
-
/** The editor-private directory at a project's root. */
|
|
246
|
-
const PRIVATE_DIR_NAME = ".ignifx";
|
|
247
238
|
/** Percent-decoding passes before a path counts as private regardless of what it decodes to. */
|
|
248
239
|
const MAX_DECODE_PASSES = 8;
|
|
249
240
|
/** Windows 8.3 short names of `.ignifx` (`IGNIFX~1`), which resolve to it on NTFS. */
|
|
@@ -266,7 +257,7 @@ function decodeEscapes(text) {
|
|
|
266
257
|
*/
|
|
267
258
|
function isPrivateSegment(segment) {
|
|
268
259
|
const name = (segment.normalize("NFKC").toLowerCase().split(":")[0] ?? "").replace(/[. ]+$/u, "");
|
|
269
|
-
return name ===
|
|
260
|
+
return name === ".ignifx" || SHORT_NAME_RE.test(name);
|
|
270
261
|
}
|
|
271
262
|
/**
|
|
272
263
|
* The path part of a request URL with every escape decoded, nested ones included.
|
|
@@ -434,6 +425,73 @@ function createPrivateDirGuard(options) {
|
|
|
434
425
|
next();
|
|
435
426
|
};
|
|
436
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Lists what a build put in its output directory from a private directory: any entry with a
|
|
430
|
+
* `.ignifx` segment, any link whose real path is private, and the copy of any `publicDir` entry
|
|
431
|
+
* whose real path is private (Vite copies `publicDir` following symbolic links, so
|
|
432
|
+
* `public/tok.json -> ../.ignifx/mcp.json` arrives as a plain file holding the token).
|
|
433
|
+
*
|
|
434
|
+
* @param outDir - The absolute output directory.
|
|
435
|
+
* @param publicDir - The absolute `publicDir` the build copied, or `null` when it copied none.
|
|
436
|
+
* @returns The absolute paths to remove from `outDir`, outermost first; `[]` when there are none.
|
|
437
|
+
*/
|
|
438
|
+
async function findPrivateOutputs(outDir, publicDir) {
|
|
439
|
+
const found = /* @__PURE__ */ new Set();
|
|
440
|
+
const entries = await readdir(outDir, {
|
|
441
|
+
recursive: true,
|
|
442
|
+
withFileTypes: true
|
|
443
|
+
}).catch(() => []);
|
|
444
|
+
const realOutDir = realPathOrSelf(outDir);
|
|
445
|
+
for (const entry of entries) {
|
|
446
|
+
const path = join(entry.parentPath, entry.name);
|
|
447
|
+
const segments = relative(outDir, path).split(/[/\\]/u);
|
|
448
|
+
const index = segments.findIndex(isPrivateSegment);
|
|
449
|
+
if (index !== -1) found.add(join(outDir, ...segments.slice(0, index + 1)));
|
|
450
|
+
else if (entry.isSymbolicLink() && isPrivateRealPath(realOutDir, path)) found.add(path);
|
|
451
|
+
}
|
|
452
|
+
if (publicDir !== null) {
|
|
453
|
+
const realPublic = realPathOrSelf(publicDir);
|
|
454
|
+
await collectPrivatePublicEntries(publicDir, realPublic, outDir, /* @__PURE__ */ new Set([realPublic]), found);
|
|
455
|
+
}
|
|
456
|
+
return [...found].toSorted();
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Walks `publicDir` the way Vite's copy does and records the output path of every private entry.
|
|
460
|
+
*
|
|
461
|
+
* @param directory - The directory being read.
|
|
462
|
+
* @param realPublic - The real path of `publicDir`.
|
|
463
|
+
* @param outDirectory - Where `directory`'s entries are copied to.
|
|
464
|
+
* @param visited - Real directories already walked, so a link cycle ends.
|
|
465
|
+
* @param found - Receives the output paths.
|
|
466
|
+
*/
|
|
467
|
+
async function collectPrivatePublicEntries(directory, realPublic, outDirectory, visited, found) {
|
|
468
|
+
const names = await readdir(directory).catch(() => []);
|
|
469
|
+
await Promise.all(names.map(async (name) => {
|
|
470
|
+
const source = join(directory, name);
|
|
471
|
+
const target = join(outDirectory, name);
|
|
472
|
+
if (isPrivateRealPath(realPublic, source)) {
|
|
473
|
+
found.add(target);
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const isDirectory = await stat(source).then((stats) => stats.isDirectory(), () => false);
|
|
477
|
+
const real = realPathOrSelf(source);
|
|
478
|
+
if (isDirectory && !visited.has(real)) {
|
|
479
|
+
visited.add(real);
|
|
480
|
+
await collectPrivatePublicEntries(source, realPublic, target, visited, found);
|
|
481
|
+
}
|
|
482
|
+
}));
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Removes the private entries {@link findPrivateOutputs} found.
|
|
486
|
+
*
|
|
487
|
+
* @param paths - The paths to remove.
|
|
488
|
+
*/
|
|
489
|
+
async function removePrivateOutputs(paths) {
|
|
490
|
+
await Promise.all(paths.map((path) => rm(path, {
|
|
491
|
+
recursive: true,
|
|
492
|
+
force: true
|
|
493
|
+
})));
|
|
494
|
+
}
|
|
437
495
|
//#endregion
|
|
438
496
|
//#region src/vite/plugin.ts
|
|
439
497
|
/**
|
|
@@ -471,7 +529,7 @@ function readProjectEngineVersion(root) {
|
|
|
471
529
|
* @throws EditorHostPluginError `IGX-1801` for a malformed origin, `IGX-1803` for a bad option.
|
|
472
530
|
*/
|
|
473
531
|
function checkOptions(options) {
|
|
474
|
-
if (!isEditorOrigin(options.editorOrigin)) throw new EditorHostPluginError(EditorHostErrorCode.invalidEditorOrigin, `editorOrigin "${options.editorOrigin}" is not an origin; pass one such as "ignifx://app" or "http://localhost:5173".`);
|
|
532
|
+
if (!isEditorOrigin(options.editorOrigin)) throw new EditorHostPluginError(EditorHostErrorCode.invalidEditorOrigin, `editorOrigin "${options.editorOrigin}" is not an origin; pass one such as "ignifx-editor://app" or "http://localhost:5173".`);
|
|
475
533
|
const interval = options.heartbeatIntervalMs;
|
|
476
534
|
if (interval !== void 0 && (!Number.isFinite(interval) || interval <= 0)) throw new EditorHostPluginError(EditorHostErrorCode.invalidOption, `heartbeatIntervalMs must be a positive number of milliseconds; got ${String(interval)}.`);
|
|
477
535
|
return {
|
|
@@ -496,8 +554,10 @@ function checkOptions(options) {
|
|
|
496
554
|
* - `ignifx-editor-host:play-controls` (every command) serves `virtual:ignifx/editor`: the play
|
|
497
555
|
* controls under `vite dev`, an empty function under `vite build`. Under `vite dev` and
|
|
498
556
|
* `vite preview` it also answers 404 to any request into `.ignifx/`, the editor's private
|
|
499
|
-
* directory, by path or through a symbolic link, as `ignifx()` does;
|
|
500
|
-
*
|
|
557
|
+
* directory, by path or through a symbolic link, as `ignifx()` does; under `vite build` it fails
|
|
558
|
+
* the build, after removing them, when the output holds a `.ignifx` directory or a copy of a
|
|
559
|
+
* `publicDir` file that links into one. This covers a config that lists this plugin without
|
|
560
|
+
* `ignifx()`.
|
|
501
561
|
*
|
|
502
562
|
* List it after `ignifx()` from `@ignifx/vite-plugin`, which serves the two modules the scene
|
|
503
563
|
* view imports.
|
|
@@ -515,7 +575,7 @@ function checkOptions(options) {
|
|
|
515
575
|
* import { defineConfig } from "vite";
|
|
516
576
|
*
|
|
517
577
|
* export default defineConfig({
|
|
518
|
-
* plugins: [ignifx(), editorHostPlugin({ editorOrigin: "ignifx://app" })],
|
|
578
|
+
* plugins: [ignifx(), editorHostPlugin({ editorOrigin: "ignifx-editor://app" })],
|
|
519
579
|
* });
|
|
520
580
|
* ```
|
|
521
581
|
*
|
|
@@ -528,6 +588,7 @@ function editorHostPlugin(options) {
|
|
|
528
588
|
let base = "/";
|
|
529
589
|
let command = "serve";
|
|
530
590
|
let engineVersion = null;
|
|
591
|
+
let copiedPublicDir = null;
|
|
531
592
|
const extensionsFile = () => resolve(root, `.${extensions}`);
|
|
532
593
|
const framePolicy = `frame-ancestors ${editorOrigin}`;
|
|
533
594
|
/**
|
|
@@ -614,6 +675,8 @@ function editorHostPlugin(options) {
|
|
|
614
675
|
root = resolvedConfig.root;
|
|
615
676
|
command = resolvedConfig.command;
|
|
616
677
|
engineVersion = readProjectEngineVersion(root);
|
|
678
|
+
const { publicDir } = resolvedConfig;
|
|
679
|
+
copiedPublicDir = resolvedConfig.build.copyPublicDir && publicDir !== "" ? publicDir : null;
|
|
617
680
|
},
|
|
618
681
|
configureServer(server) {
|
|
619
682
|
const realRoot = realPathOrSelf(server.config.root);
|
|
@@ -650,6 +713,14 @@ function editorHostPlugin(options) {
|
|
|
650
713
|
const file = id.split("?", 1)[0] ?? "";
|
|
651
714
|
if (!id.startsWith("\0") && isAbsolute(file) && isPrivateRealPath(realPathOrSelf(root), file)) this.error(`"${file}" is in the editor-private .ignifx/ directory, which holds the editor's MCP token; nothing may import or serve it. Remove the import or link.`);
|
|
652
715
|
return null;
|
|
716
|
+
},
|
|
717
|
+
async writeBundle(output) {
|
|
718
|
+
const outDir = output.dir ?? (output.file === void 0 ? null : dirname(output.file));
|
|
719
|
+
if (outDir === null) return;
|
|
720
|
+
const leaked = await findPrivateOutputs(outDir, copiedPublicDir);
|
|
721
|
+
if (leaked.length === 0) return;
|
|
722
|
+
await removePrivateOutputs(leaked);
|
|
723
|
+
this.error(`The build output held files from the editor-private .ignifx/ directory, which holds the editor's MCP token: ${leaked.map((path) => relative(outDir, path)).join(", ")}. They were removed and the build failed. Move .ignifx/ out of publicDir and remove any link into it from publicDir.`);
|
|
653
724
|
}
|
|
654
725
|
}];
|
|
655
726
|
}
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite/errors.ts","../src/vite/modules.ts","../src/vite/private-dir.ts","../src/vite/plugin.ts"],"sourcesContent":["/**\n * The error the Vite plugin throws.\n *\n * @remarks\n * The plugin runs in the dev server's Node process, where loading `@ignifx/core` (and through it\n * Babylon Lite) to throw its `IgnifxError` would be pure cost. Like `@ignifx/vite-plugin`'s own\n * error, it carries the same registered `IGX-####` codes the page half throws.\n */\n\nimport type { EditorHostErrorCode } from \"../error-codes.js\";\n\n/**\n * The error every `@ignifx/editor-host/vite` API throws for a misconfiguration\n * (`CONSTITUTION.md` §3.9).\n *\n * @beta\n */\nexport class EditorHostPluginError extends Error {\n /** The stable diagnostic code for this failure. */\n readonly code: EditorHostErrorCode;\n\n /**\n * Creates a plugin error.\n *\n * @param code - The stable `IGX-####` code for the failure.\n * @param message - An actionable description of what went wrong and how to fix it.\n */\n constructor(code: EditorHostErrorCode, message: string) {\n super(message);\n this.name = \"EditorHostPluginError\";\n this.code = code;\n }\n}\n","/**\n * The page and the two modules the plugin generates: the scene view's HTML entry, the module that\n * page runs, and `virtual:ignifx/editor`, the play view's controls.\n */\n\nimport {\n ASSET_CHANGED_EVENT,\n IGNIFX_CONFIG_DEFINE_KEY,\n MANIFEST_MODULE_ID,\n SCRIPTS_MODULE_ID,\n} from \"@ignifx/vite-plugin\";\nimport { EditorHostErrorCode } from \"../error-codes.js\";\nimport { EditorHostPluginError } from \"./errors.js\";\n\n/**\n * The path the scene view is served at, below the dev server's `base`.\n *\n * @beta\n */\nexport const EDITOR_PAGE_PATH = \"/__ignifx_editor__/\";\n\n/**\n * The module a game imports to hand its app to the editor's play controls.\n *\n * @example\n * ```ts\n * import { attachEditorPlayControls } from \"virtual:ignifx/editor\";\n *\n * attachEditorPlayControls(app);\n * ```\n *\n * @beta\n */\nexport const EDITOR_MODULE_ID = \"virtual:ignifx/editor\";\n\n/**\n * The resolved id of {@link EDITOR_MODULE_ID}. The `\\0` prefix marks it as owned by a plugin.\n *\n * @beta\n */\nexport const RESOLVED_EDITOR_MODULE_ID: string = `\\0${EDITOR_MODULE_ID}`;\n\n/**\n * The module the scene view's page runs. Only the generated page imports it.\n *\n * @beta\n */\nexport const EDITOR_ENTRY_MODULE_ID = \"virtual:ignifx/editor-host-entry\";\n\n/**\n * The resolved id of {@link EDITOR_ENTRY_MODULE_ID}.\n *\n * @beta\n */\nexport const RESOLVED_EDITOR_ENTRY_MODULE_ID: string = `\\0${EDITOR_ENTRY_MODULE_ID}`;\n\n/**\n * The function `virtual:ignifx/editor` exports. It takes the game's app and returns a function that\n * detaches the controls; in a production build it does nothing.\n *\n * @beta\n */\nexport const EDITOR_PLAY_CONTROLS_EXPORT = \"attachEditorPlayControls\";\n\n/**\n * The module the scene view imports the project's extensions from, unless the plugin is told\n * otherwise. It exports `extensions()`, which returns the list `main.ts` passes to `createApp`.\n *\n * @beta\n */\nexport const DEFAULT_EXTENSIONS_MODULE = \"/src/extensions.ts\";\n\n/**\n * The `id` of the scene view's canvas.\n *\n * @beta\n */\nexport const EDITOR_CANVAS_ID = \"ignifx-editor-view\";\n\n/** The package the generated modules import the host from, resolved from the project's root. */\nconst HOST_PACKAGE = \"@ignifx/editor-host\";\n\n/**\n * Options accepted by {@link editorEntryModuleSource}.\n *\n * @beta\n */\nexport interface EditorEntryModuleOptions {\n /** The origin the editor is served from. */\n readonly editorOrigin: string;\n /** The root-absolute path of the project's extensions module, or `null` when it has none. */\n readonly extensionsModule: string | null;\n /** A scene address to load before the app starts, or `null`. */\n readonly bootScene: string | null;\n /** The project's `@ignifx/core` version, or `null` when it could not be read. */\n readonly engineVersion: string | null;\n /** Milliseconds between heartbeats, or `null` for the host's default. */\n readonly heartbeatIntervalMs: number | null;\n}\n\n/**\n * Options accepted by {@link playControlsModuleSource}.\n *\n * @beta\n */\nexport interface PlayControlsModuleOptions {\n /** The origin the editor is served from. */\n readonly editorOrigin: string;\n /** The project's `@ignifx/core` version, or `null` when it could not be read. */\n readonly engineVersion: string | null;\n /** Milliseconds between heartbeats, or `null` for the host's default. */\n readonly heartbeatIntervalMs: number | null;\n /**\n * Emit the development module. `false` emits the production no-op, which imports nothing and has\n * no `import.meta.hot` reference.\n */\n readonly hot: boolean;\n}\n\n/**\n * Turns the `extensions` option into the root-absolute path the generated module imports.\n *\n * @param path - The path as configured, relative to the Vite root or already root-absolute.\n * @returns The root-absolute path, for example `\"/src/extensions.ts\"`.\n * @throws EditorHostPluginError `IGX-1803` when the path is empty or leaves the root with `..`.\n *\n * @beta\n */\nexport function normalizeExtensionsModule(path: string): string {\n const trimmed = path.startsWith(\"./\") ? path.slice(2) : path;\n if (trimmed === \"\" || trimmed === \"/\" || trimmed.split(\"/\").some((segment) => segment === \"..\")) {\n throw new EditorHostPluginError(\n EditorHostErrorCode.invalidOption,\n `The \"extensions\" option must name a module inside the Vite root, for example \"src/extensions.ts\"; got \"${path}\".`,\n );\n }\n return trimmed.startsWith(\"/\") ? trimmed : `/${trimmed}`;\n}\n\n/**\n * The fields shared by both generated calls, as source text.\n *\n * @param engineVersion - The version to report, or `null`.\n * @param heartbeatIntervalMs - The heartbeat period, or `null`.\n * @returns Zero, one, or two `key: value,` lines.\n */\nfunction reportingLines(engineVersion: string | null, heartbeatIntervalMs: number | null): readonly string[] {\n return [\n ...(engineVersion === null ? [] : [` engineVersion: ${JSON.stringify(engineVersion)},`]),\n ...(heartbeatIntervalMs === null ? [] : [` heartbeatIntervalMs: ${JSON.stringify(heartbeatIntervalMs)},`]),\n ];\n}\n\n/**\n * Generates the module the scene view's page runs.\n *\n * @remarks\n * The module is the only code with an import-time effect: it creates the host. The package itself\n * creates nothing when imported (`CONSTITUTION.md` §3.5). Every import is resolved from the\n * project's root, so the host, the scripts, and the extensions share the project's one copy of\n * `@ignifx/core`. It hands every `ignifx:asset-changed` event to `host.assetChanged`, which\n * reloads the asset in place; the `import.meta.hot` calls are written out literally, because Vite\n * finds them by reading the source.\n *\n * @param options - The editor origin, the project's extensions module, and the reporting options.\n * @returns The ES module source.\n *\n * @beta\n */\nexport function editorEntryModuleSource(options: EditorEntryModuleOptions): string {\n const { extensionsModule } = options;\n return [\n `import { startEditorHost } from ${JSON.stringify(HOST_PACKAGE)};`,\n `import { manifest } from ${JSON.stringify(MANIFEST_MODULE_ID)};`,\n `import { acceptHotReload, scripts } from ${JSON.stringify(SCRIPTS_MODULE_ID)};`,\n ...(extensionsModule === null ? [] : [`import { extensions } from ${JSON.stringify(extensionsModule)};`]),\n \"\",\n \"const host = await startEditorHost({\",\n ` editorOrigin: ${JSON.stringify(options.editorOrigin)},`,\n ' hostKind: \"scene\",',\n ` canvas: document.getElementById(${JSON.stringify(EDITOR_CANVAS_ID)}),`,\n ` settings: ${IGNIFX_CONFIG_DEFINE_KEY},`,\n \" assets: { manifest },\",\n ` extensions: ${extensionsModule === null ? \"[]\" : \"extensions()\"},`,\n \" scripts,\",\n ` bootScene: ${JSON.stringify(options.bootScene)},`,\n ...reportingLines(options.engineVersion, options.heartbeatIntervalMs),\n \"});\",\n \"acceptHotReload(host.app);\",\n \"if (import.meta.hot) {\",\n ` import.meta.hot.on(${JSON.stringify(ASSET_CHANGED_EVENT)}, (change) => {`,\n \" void host.assetChanged(change);\",\n \" });\",\n \"}\",\n \"\",\n ].join(\"\\n\");\n}\n\n/**\n * Generates the scene view's HTML page, before Vite's own `transformIndexHtml` adds its client.\n *\n * @returns The HTML document.\n *\n * @beta\n */\nexport function editorPageHtml(): string {\n return [\n \"<!doctype html>\",\n '<html lang=\"en\">',\n \" <head>\",\n ' <meta charset=\"utf-8\" />',\n ' <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />',\n \" <title>ignifx editor host</title>\",\n \" <style>\",\n \" html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }\",\n ` #${EDITOR_CANVAS_ID} { display: block; width: 100%; height: 100%; }`,\n \" </style>\",\n \" </head>\",\n \" <body>\",\n ` <canvas id=\"${EDITOR_CANVAS_ID}\"></canvas>`,\n ` <script type=\"module\" src=\"/@id/${EDITOR_ENTRY_MODULE_ID}\"></script>`,\n \" </body>\",\n \"</html>\",\n \"\",\n ].join(\"\\n\");\n}\n\n/**\n * Generates `virtual:ignifx/editor`.\n *\n * @remarks\n * In development, the module listens for the editor's connect message as soon as it is evaluated,\n * which is before the game's `main.ts` runs, and keeps the port\n * (`listenForEditorPlayControls`); `attachEditorPlayControls(app)` then starts the play controls on\n * it, so the editor's first connect message is never lost to `await createApp(...)`. Vite replacing\n * the module stops both. The `import.meta.hot` calls are written out literally because Vite\n * finds them by reading the source, not by running it. In a production build the export is an empty\n * function, the same shape as `acceptHotReload` from `virtual:ignifx/scripts`, so the game's\n * `main.ts` builds either way and ships no editor code.\n *\n * @param options - The editor origin, the reporting options, and whether to emit the development module.\n * @returns The ES module source.\n *\n * @beta\n */\nexport function playControlsModuleSource(options: PlayControlsModuleOptions): string {\n if (!options.hot) {\n return [`export function ${EDITOR_PLAY_CONTROLS_EXPORT}() {`, \" return () => {};\", \"}\", \"\"].join(\"\\n\");\n }\n return [\n `import { listenForEditorPlayControls } from ${JSON.stringify(HOST_PACKAGE)};`,\n \"\",\n \"// Listens now, before main.ts awaits createApp, so the editor's first port is kept.\",\n \"const connector = listenForEditorPlayControls({\",\n ` editorOrigin: ${JSON.stringify(options.editorOrigin)},`,\n ...reportingLines(options.engineVersion, options.heartbeatIntervalMs),\n \"});\",\n \"if (import.meta.hot) {\",\n \" import.meta.hot.dispose(() => {\",\n \" connector.dispose();\",\n \" });\",\n \"}\",\n \"\",\n `export function ${EDITOR_PLAY_CONTROLS_EXPORT}(app) {`,\n \" const controls = connector.attach(app);\",\n \" return () => {\",\n \" controls.dispose();\",\n \" };\",\n \"}\",\n \"\",\n ].join(\"\\n\");\n}\n","/**\n * A copy of `@ignifx/vite-plugin`'s `.ignifx/` request guard (`src/private-dir.ts` there), kept\n * here as defence in depth: a project whose Vite config lists `editorHostPlugin()` without\n * `ignifx()` would otherwise serve `.ignifx/mcp.json`, the editor's MCP token, to any page.\n * `@ignifx/vite-plugin` is an optional peer, so this package cannot import it; keep the two in step.\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { basename, dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport type { Connect } from \"vite\";\n\n/** The editor-private directory at a project's root. */\nconst PRIVATE_DIR_NAME = \".ignifx\";\n\n/** Percent-decoding passes before a path counts as private regardless of what it decodes to. */\nconst MAX_DECODE_PASSES = 8;\n\n/** Windows 8.3 short names of `.ignifx` (`IGNIFX~1`), which resolve to it on NTFS. */\nconst SHORT_NAME_RE = /^ignifx~\\d+$/u;\n\n/**\n * Decodes every `%XX` escape, byte by byte, so a malformed sequence never stops decoding.\n *\n * @param text - The text to decode.\n * @returns The text with each escape replaced by the byte it names.\n */\nfunction decodeEscapes(text: string): string {\n return text.replaceAll(/%([0-9a-f]{2})/giu, (_match, hex: string) => String.fromCodePoint(Number.parseInt(hex, 16)));\n}\n\n/**\n * Reports whether one path segment names the private directory.\n *\n * @param segment - One decoded segment.\n * @returns `true` for `.ignifx` in any case, with Windows' ignored trailing dots and spaces, an\n * alternate data stream suffix, or as an 8.3 short name.\n */\nfunction isPrivateSegment(segment: string): boolean {\n const name = (segment.normalize(\"NFKC\").toLowerCase().split(\":\")[0] ?? \"\").replace(/[. ]+$/u, \"\");\n return name === PRIVATE_DIR_NAME || SHORT_NAME_RE.test(name);\n}\n\n/**\n * Reports whether a request URL reaches into the private directory.\n *\n * @remarks\n * The query and fragment are dropped, then escapes are decoded until the path stops changing (so\n * `%252e` counts as `.`). Every segment between `/`, `\\`, `?` and `#` is checked: resolving `.` and\n * `..` only removes segments, so a path that names no `.ignifx` segment cannot reach one, and this\n * covers `/@fs/<absolute path>` and `/@id/` forms alike.\n *\n * @param url - The request URL as the server received it.\n * @returns `true` when the request must be refused.\n */\nexport function isPrivateRequestPath(url: string): boolean {\n const path = decodedRequestPath(url);\n return path === null || hasPrivateSegment(path);\n}\n\n/**\n * The path part of a request URL with every escape decoded, nested ones included.\n *\n * @param url - The request URL as the server received it.\n * @returns The decoded path, or `null` when it still changes after the last decoding pass.\n */\nfunction decodedRequestPath(url: string): string | null {\n let path = url.split(/[?#]/u, 1)[0] ?? \"\";\n for (let pass = 0; ; pass += 1) {\n const decoded = decodeEscapes(path);\n if (decoded === path) {\n return path;\n }\n if (pass === MAX_DECODE_PASSES) {\n return null;\n }\n path = decoded;\n }\n}\n\n/**\n * Reports whether a path names the private directory in any of its segments.\n *\n * @param path - A path with `/` or `\\` separators, relative or absolute.\n * @returns `true` when a segment between separators is a spelling of `.ignifx`.\n */\nfunction hasPrivateSegment(path: string): boolean {\n return path.split(/[/\\\\?#]/u).some(isPrivateSegment);\n}\n\n/**\n * Reports whether a file, once every symbolic link on its path is followed, lies in a private\n * directory.\n *\n * @remarks\n * A link such as `src/link -> ../.ignifx` hides the directory from every check that reads the path\n * as written. The deepest part of `path` that exists is resolved with `realpath` and the rest\n * appended, so a request for a file the server would find by adding an extension is judged too.\n * Only the part of the real path below `realBase` and its common ancestor with the file counts:\n * a project that itself lives under some `.ignifx` directory is not refused wholesale.\n *\n * @param realBase - The real path the result is measured from, normally the project root.\n * @param path - An absolute path, existing or not.\n * @returns `true` when the real path has a `.ignifx` segment, or when it cannot be resolved for a\n * reason other than not existing (the check fails closed).\n *\n * It is synchronous, like Vite's own file lookups: a few `realpath` calls per request or module.\n */\nexport function isPrivateRealPath(realBase: string, path: string): boolean {\n let current = path;\n const rest: string[] = [];\n for (;;) {\n try {\n return hasPrivateSegment(relative(realBase, join(realpathSync.native(current), ...rest)));\n } catch (error) {\n const missing = isMissingFileError(error);\n const parent = dirname(current);\n if (!missing || parent === current) {\n return !missing;\n }\n rest.unshift(basename(current));\n current = parent;\n }\n }\n}\n\n/**\n * Reports whether a caught failure means \"there is no such file\".\n *\n * @param error - The caught value.\n * @returns `true` for `ENOENT` and `ENOTDIR`.\n */\nfunction isMissingFileError(error: unknown): boolean {\n const code = typeof error === \"object\" && error !== null && \"code\" in error ? error.code : null;\n return code === \"ENOENT\" || code === \"ENOTDIR\";\n}\n\n/**\n * Resolves a path to its real path, or returns it unchanged when it cannot be resolved.\n *\n * @param path - An absolute path.\n * @returns The real path.\n */\nexport function realPathOrSelf(path: string): string {\n try {\n return realpathSync.native(path);\n } catch {\n return path;\n }\n}\n\n/**\n * Answers 404 with no body and no caching.\n *\n * @param response - The response to end.\n */\nfunction refuse(response: Parameters<Connect.NextHandleFunction>[1]): void {\n response.statusCode = 404;\n response.setHeader(\"Cache-Control\", \"no-store\");\n response.end();\n}\n\n/** Where a server finds the file a request URL names. */\ninterface PrivateDirGuardOptions {\n /** The real path of the project root, which real paths are judged against. */\n readonly realRoot: string;\n /** The server's `base`; a URL is tried with and without it. */\n readonly base: string;\n /** The directories a root-relative URL is served from: the root and `publicDir` in dev, `outDir` in preview. */\n readonly serveDirs: readonly string[];\n /** `resolve.alias`, which Vite's static middleware applies to request paths in dev; `[]` in preview. */\n readonly alias: readonly { readonly find: string | RegExp; readonly replacement: string }[];\n /** `resolve.extensions`, which Vite tries for a module request whose file does not exist. */\n readonly extensions: readonly string[];\n}\n\n/** The `/@fs/` prefix Vite serves absolute paths under, and `/@id/` for unresolved ids. */\nconst FS_PREFIX = \"/@fs/\";\nconst ID_PREFIX = \"/@id/\";\nconst DRIVE_RE = /^[a-z]:/iu;\n\n/**\n * The files a decoded request path could be served from.\n *\n * @param path - The decoded request path, `/`-separated.\n * @param options - The server's directories and base.\n * @returns Absolute paths, existing or not.\n */\nfunction candidateFiles(path: string, options: PrivateDirGuardOptions): string[] {\n const basePath = options.base.startsWith(\"/\") ? options.base : \"/\";\n const forms = [path];\n if (basePath !== \"/\" && path.startsWith(basePath)) {\n forms.push(`/${path.slice(basePath.length)}`);\n }\n const candidates: string[] = [];\n for (const form of forms) {\n const relativeForms = [form];\n // Vite's static middleware rewrites a path the first alias matches and serves it from the root.\n const alias = options.alias.find(({ find }) =>\n typeof find === \"string\" ? form.startsWith(find) : find.test(form),\n );\n if (alias !== undefined) {\n const redirected = form.replace(alias.find, alias.replacement);\n candidates.push(redirected);\n relativeForms.push(redirected);\n }\n for (const prefix of [FS_PREFIX, ID_PREFIX]) {\n if (form.startsWith(prefix)) {\n const rest = form.slice(prefix.length);\n candidates.push(DRIVE_RE.test(rest) ? rest : `/${rest.replace(/^\\/+/u, \"\")}`);\n relativeForms.push(`/${rest}`);\n }\n }\n for (const directory of options.serveDirs) {\n candidates.push(...relativeForms.map((relativeForm) => join(directory, relativeForm)));\n }\n }\n // `resolve` folds `.` and `..` the way a server normalises a URL, before anything is looked up.\n return candidates.filter((candidate) => isAbsolute(candidate)).map((candidate) => resolve(candidate));\n}\n\n/**\n * Reports whether a candidate file, or the file Vite would find by adding an extension to it, is\n * private once links are followed.\n *\n * @param file - An absolute candidate path.\n * @param options - The real root and `resolve.extensions`.\n * @returns `true` when the request must be refused.\n */\nfunction isPrivateCandidate(file: string, options: PrivateDirGuardOptions): boolean {\n if (isPrivateRealPath(options.realRoot, file)) {\n return true;\n }\n // Extensions are only worth trying where Vite would: the file is missing and its directory is not.\n if (existsSync(file) || !existsSync(dirname(file))) {\n return false;\n }\n return options.extensions.some((extension) => isPrivateRealPath(options.realRoot, `${file}${extension}`));\n}\n\n/**\n * Connect middleware that answers 404, with no body, to every request into the private directory:\n * one whose path names it ({@link isPrivateRequestPath}), and one whose file lies in it once\n * symbolic links are followed (`src/link -> ../.ignifx`).\n *\n * @remarks\n * For the second, it maps the URL to the files Vite could serve for it (root, `publicDir` or\n * `outDir`, `/@fs/` and `/@id/` absolute paths, with and without `base`, and the path a\n * `resolve.alias` entry rewrites it to) and checks each with {@link isPrivateRealPath}. A missing\n * file is judged by its deepest existing ancestor and, when its directory exists, with each of\n * `resolve.extensions` appended, as Vite completes a module request. The plugin's `load` hook\n * covers what Vite resolves some other way.\n *\n * @param options - Returns the server's directories; read per request, as they are only known once\n * the config is resolved.\n * @returns The middleware.\n */\nexport function createPrivateDirGuard(options: () => PrivateDirGuardOptions): Connect.NextHandleFunction {\n return (request, response, next) => {\n const decoded = decodedRequestPath(request.url ?? \"\");\n if (decoded === null || hasPrivateSegment(decoded)) {\n refuse(response);\n return;\n }\n const resolved = options();\n const path = decoded.replaceAll(\"\\\\\", \"/\");\n if (candidateFiles(path, resolved).some((file) => isPrivateCandidate(file, resolved))) {\n refuse(response);\n return;\n }\n next();\n };\n}\n","/**\n * The editor host's Vite plugin: the scene view's page on the project's own dev server, and\n * `virtual:ignifx/editor` for the play view (`docs/architecture/17-editor-host.md` §3).\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport { EditorHostErrorCode, isEditorOrigin } from \"../error-codes.js\";\nimport { EditorHostPluginError } from \"./errors.js\";\nimport {\n DEFAULT_EXTENSIONS_MODULE,\n EDITOR_ENTRY_MODULE_ID,\n EDITOR_MODULE_ID,\n EDITOR_PAGE_PATH,\n editorEntryModuleSource,\n editorPageHtml,\n normalizeExtensionsModule,\n playControlsModuleSource,\n RESOLVED_EDITOR_ENTRY_MODULE_ID,\n RESOLVED_EDITOR_MODULE_ID,\n} from \"./modules.js\";\nimport { createPrivateDirGuard, isPrivateRealPath, realPathOrSelf } from \"./private-dir.js\";\nimport type { ConfigEnv, Plugin, ViteDevServer } from \"vite\";\n\n/**\n * Options accepted by {@link editorHostPlugin}.\n *\n * @beta\n */\nexport interface EditorHostPluginOptions {\n /**\n * The origin the editor is served from, for example `\"ignifx://app\"` when packaged or\n * `\"http://localhost:5173\"` while the editor itself runs from a dev server. Only this origin may\n * frame either view in `vite dev`, and only it can hand either view a port.\n */\n readonly editorOrigin: string;\n /**\n * The project's extensions module, relative to the Vite root. It exports `extensions()`, which\n * returns the list `main.ts` passes to `createApp`. When the file does not exist the scene view\n * runs with no extensions. Defaults to `\"/src/extensions.ts\"`.\n */\n readonly extensions?: string;\n /** A scene address the scene view loads before it starts. Defaults to none. */\n readonly bootScene?: string | null;\n /** Milliseconds between heartbeats in both views. Defaults to the host's `1000`. */\n readonly heartbeatIntervalMs?: number;\n}\n\n/** The plugin names, as they appear in Vite's logs. */\nconst PAGE_PLUGIN_NAME = \"ignifx-editor-host\";\nconst PLAY_PLUGIN_NAME = \"ignifx-editor-host:play-controls\";\n\n/** What Vite crawls for dependencies when `optimizeDeps.entries` is not set. */\nconst DEFAULT_OPTIMIZE_ENTRIES = \"**/*.html\";\n\n/**\n * Reads the version of the project's own `@ignifx/core`.\n *\n * @param root - The Vite root.\n * @returns The version, or `null` when the project does not resolve `@ignifx/core`.\n *\n * @beta\n */\nexport function readProjectEngineVersion(root: string): string | null {\n try {\n const requireFromProject = createRequire(join(root, \"package.json\"));\n const manifest: unknown = JSON.parse(readFileSync(requireFromProject.resolve(\"@ignifx/core/package.json\"), \"utf8\"));\n if (typeof manifest === \"object\" && manifest !== null && \"version\" in manifest) {\n return typeof manifest.version === \"string\" ? manifest.version : null;\n }\n return null;\n } catch {\n // An unresolvable core is reported by the host as core's own `VERSION`, not as a failure here.\n return null;\n }\n}\n\n/**\n * Checks the options and applies their defaults.\n *\n * @param options - The options as given.\n * @returns The extensions module path and the heartbeat period.\n * @throws EditorHostPluginError `IGX-1801` for a malformed origin, `IGX-1803` for a bad option.\n */\nfunction checkOptions(options: EditorHostPluginOptions): { extensions: string; heartbeatIntervalMs: number | null } {\n if (!isEditorOrigin(options.editorOrigin)) {\n throw new EditorHostPluginError(\n EditorHostErrorCode.invalidEditorOrigin,\n `editorOrigin \"${options.editorOrigin}\" is not an origin; pass one such as \"ignifx://app\" or \"http://localhost:5173\".`,\n );\n }\n const interval = options.heartbeatIntervalMs;\n if (interval !== undefined && (!Number.isFinite(interval) || interval <= 0)) {\n throw new EditorHostPluginError(\n EditorHostErrorCode.invalidOption,\n `heartbeatIntervalMs must be a positive number of milliseconds; got ${String(interval)}.`,\n );\n }\n return {\n extensions: normalizeExtensionsModule(options.extensions ?? DEFAULT_EXTENSIONS_MODULE),\n heartbeatIntervalMs: interval ?? null,\n };\n}\n\n/**\n * The editor host's Vite plugin.\n *\n * @remarks\n * It is two plugins, because the two halves run under different commands:\n *\n * - `ignifx-editor-host` (`vite dev` only) serves the scene view at `/__ignifx_editor__/` with\n * `Content-Security-Policy: frame-ancestors <editorOrigin>`, and adds the same header to every\n * page a browser navigates to, so the game's own `index.html` (the play view) can be framed by the\n * editor and by nothing else. A `Content-Security-Policy` in `server.headers` replaces it. The page's module imports the host,\n * `virtual:ignifx/scripts`, `virtual:ignifx/manifest` and the project's extensions module from\n * the project's own graph, and calls `startEditorHost`. It adds the extensions module to\n * `optimizeDeps.entries` (keeping Vite's default crawl) and keeps `@ignifx/editor-host` out of\n * pre-bundling, so the host reaches the same pre-bundled `@ignifx/core` as the game.\n * - `ignifx-editor-host:play-controls` (every command) serves `virtual:ignifx/editor`: the play\n * controls under `vite dev`, an empty function under `vite build`. Under `vite dev` and\n * `vite preview` it also answers 404 to any request into `.ignifx/`, the editor's private\n * directory, by path or through a symbolic link, as `ignifx()` does; this covers a config that\n * lists this plugin without `ignifx()`.\n *\n * List it after `ignifx()` from `@ignifx/vite-plugin`, which serves the two modules the scene\n * view imports.\n *\n * @param options - The editor's origin and the scene view's options.\n * @returns The plugins, to be listed in `vite.config.ts`.\n * @throws EditorHostPluginError `IGX-1801` for a malformed `editorOrigin`, `IGX-1803` for a bad\n * `extensions` path or `heartbeatIntervalMs`.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { ignifx } from \"@ignifx/vite-plugin\";\n * import { editorHostPlugin } from \"@ignifx/editor-host/vite\";\n * import { defineConfig } from \"vite\";\n *\n * export default defineConfig({\n * plugins: [ignifx(), editorHostPlugin({ editorOrigin: \"ignifx://app\" })],\n * });\n * ```\n *\n * @beta\n */\nexport function editorHostPlugin(options: EditorHostPluginOptions): Plugin[] {\n const { extensions, heartbeatIntervalMs } = checkOptions(options);\n const { editorOrigin } = options;\n let root = process.cwd();\n let base = \"/\";\n let command: ConfigEnv[\"command\"] = \"serve\";\n let engineVersion: string | null = null;\n\n const extensionsFile = (): string => resolve(root, `.${extensions}`);\n // Only the editor may put either view in a frame; any other page that tries is blocked. A tab the\n // developer opens on the dev server is not a frame, so the policy leaves it alone.\n const framePolicy = `frame-ancestors ${editorOrigin}`;\n\n /**\n * Sends the frame policy with every page a browser navigates to, the game's `index.html` (the\n * play view) included. Navigations and frames ask for `text/html`; module and asset requests do\n * not, and a policy on them would do nothing anyway.\n *\n * @param server - The dev server.\n */\n const installPlayViewPolicy = (server: ViteDevServer): void => {\n server.middlewares.use((request, response, next) => {\n const isRead = request.method === \"GET\" || request.method === \"HEAD\";\n if (isRead && (request.headers.accept ?? \"\").includes(\"text/html\")) {\n response.setHeader(\"Content-Security-Policy\", framePolicy);\n }\n next();\n });\n };\n\n /**\n * Serves the scene view's page and redirects the path without its trailing slash.\n *\n * @param server - The dev server.\n */\n const installPage = (server: ViteDevServer): void => {\n const pagePath = `${base.endsWith(\"/\") ? base.slice(0, -1) : base}${EDITOR_PAGE_PATH}`;\n server.middlewares.use((request, response, next) => {\n const url = request.url ?? \"\";\n const path = url.split(\"?\")[0] ?? \"\";\n if (path === pagePath.slice(0, -1)) {\n response.statusCode = 302;\n response.setHeader(\"Location\", `${pagePath}${url.slice(path.length)}`);\n response.end();\n return;\n }\n if (path !== pagePath && path !== `${pagePath}index.html`) {\n next();\n return;\n }\n server.transformIndexHtml(EDITOR_PAGE_PATH, editorPageHtml(), request.originalUrl).then(\n (html) => {\n response.statusCode = 200;\n response.setHeader(\"Content-Type\", \"text/html; charset=utf-8\");\n response.setHeader(\"Cache-Control\", \"no-store\");\n response.setHeader(\"Content-Security-Policy\", framePolicy);\n response.end(html);\n },\n (error: unknown) => {\n next(error);\n },\n );\n });\n };\n\n const page: Plugin = {\n name: PAGE_PLUGIN_NAME,\n // A production build must never contain the scene view.\n apply: \"serve\",\n\n config(userConfig) {\n const projectRoot = resolve(process.cwd(), userConfig.root ?? \".\");\n const scanExtensions = existsSync(resolve(projectRoot, `.${extensions}`));\n // Vite concatenates arrays when it merges this into the user's config, and setting `entries`\n // at all replaces its default crawl of every HTML file, so the default is restated only when\n // the user set nothing.\n const entries =\n userConfig.optimizeDeps?.entries === undefined\n ? [DEFAULT_OPTIMIZE_ENTRIES, extensions.slice(1)]\n : [extensions.slice(1)];\n return {\n optimizeDeps: {\n ...(scanExtensions ? { entries } : {}),\n // Served as it is, its `@ignifx/core` import resolves to the game's own pre-bundled core.\n exclude: [\"@ignifx/editor-host\"],\n },\n };\n },\n\n configResolved(resolvedConfig) {\n root = resolvedConfig.root;\n base = resolvedConfig.base;\n engineVersion = readProjectEngineVersion(root);\n },\n\n configureServer(server) {\n // Registered directly rather than returned as a post hook, so they run before Vite's own HTML\n // fallback and index middleware.\n installPlayViewPolicy(server);\n installPage(server);\n },\n\n resolveId(id) {\n return id === EDITOR_ENTRY_MODULE_ID ? RESOLVED_EDITOR_ENTRY_MODULE_ID : null;\n },\n\n load(id) {\n if (id !== RESOLVED_EDITOR_ENTRY_MODULE_ID) {\n return null;\n }\n return editorEntryModuleSource({\n editorOrigin,\n extensionsModule: existsSync(extensionsFile()) ? extensions : null,\n bootScene: options.bootScene ?? null,\n engineVersion,\n heartbeatIntervalMs,\n });\n },\n };\n\n const play: Plugin = {\n name: PLAY_PLUGIN_NAME,\n\n configResolved(resolvedConfig) {\n root = resolvedConfig.root;\n command = resolvedConfig.command;\n engineVersion = readProjectEngineVersion(root);\n },\n\n // Defence in depth for a config without `ignifx()`, whose guard otherwise keeps `.ignifx/` (the\n // editor's MCP token) off the server; registered in the hook body, ahead of Vite's file serving.\n configureServer(server) {\n const realRoot = realPathOrSelf(server.config.root);\n const { publicDir } = server.config;\n server.middlewares.use(\n createPrivateDirGuard(() => ({\n realRoot,\n base: server.config.base,\n serveDirs: publicDir === \"\" ? [server.config.root] : [server.config.root, publicDir],\n alias: server.config.resolve.alias,\n extensions: server.config.resolve.extensions,\n })),\n );\n },\n\n configurePreviewServer(server) {\n const realRoot = realPathOrSelf(server.config.root);\n const outDir = resolve(server.config.root, server.config.build.outDir);\n server.middlewares.use(\n createPrivateDirGuard(() => ({\n realRoot,\n base: server.config.base,\n serveDirs: [outDir],\n alias: [],\n extensions: [],\n })),\n );\n },\n\n resolveId(id) {\n return id === EDITOR_MODULE_ID ? RESOLVED_EDITOR_MODULE_ID : null;\n },\n\n load(id) {\n if (id === RESOLVED_EDITOR_MODULE_ID) {\n return playControlsModuleSource({ editorOrigin, engineVersion, heartbeatIntervalMs, hot: command === \"serve\" });\n }\n // Whatever resolved to it (an alias, `/@id/`, an import through a link), a module whose real\n // path is in `.ignifx/` is never loaded: in dev it would be served, in a build bundled.\n const file = id.split(\"?\", 1)[0] ?? \"\";\n if (!id.startsWith(\"\\0\") && isAbsolute(file) && isPrivateRealPath(realPathOrSelf(root), file)) {\n this.error(\n `\"${file}\" is in the editor-private .ignifx/ directory, which holds the editor's MCP token; ` +\n \"nothing may import or serve it. Remove the import or link.\",\n );\n }\n return null;\n },\n };\n\n return [page, play];\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,IAAa,wBAAb,cAA2C,MAAM;;CAE/C;;;;;;;CAQA,YAAY,MAA2B,SAAiB;EACtD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;;;;;;;;;;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AK,CAAC,OAAO,OAAO,IAAI,IAAI,CAAC,OAAO,OAAO,MAAM,SAAS;IACnF,OAAO,OAAO,OAAO,QAAQ;IAC7B,YAAY,OAAO,OAAO,QAAQ;GACpC,EAAE,CACJ;EACF;EAEA,uBAAuB,QAAQ;GAC7B,MAAM,WAAW,eAAe,OAAO,OAAO,IAAI;GAClD,MAAM,SAAS,QAAQ,OAAO,OAAO,MAAM,OAAO,OAAO,MAAM,MAAM;GACrE,OAAO,YAAY,IACjB,6BAA6B;IAC3B;IACA,MAAM,OAAO,OAAO;IACpB,WAAW,CAAC,MAAM;IAClB,OAAO,CAAC;IACR,YAAY,CAAC;GACf,EAAE,CACJ;EACF;EAEA,UAAU,IAAI;GACZ,OAAO,OAAA,0BAA0B,4BAA4B;EAC/D;EAEA,KAAK,IAAI;GACP,IAAI,OAAO,2BACT,OAAO,yBAAyB;IAAE;IAAc;IAAe;IAAqB,KAAK,YAAY;GAAQ,CAAC;GAIhH,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,MAAM;GACpC,IAAI,CAAC,GAAG,WAAW,IAAI,KAAK,WAAW,IAAI,KAAK,kBAAkB,eAAe,IAAI,GAAG,IAAI,GAC1F,KAAK,MACH,IAAI,KAAK,8IAEX;GAEF,OAAO;EACT;CAGe,CAAC;AACpB"}
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite/errors.ts","../src/vite/modules.ts","../src/vite/private-dir.ts","../src/vite/plugin.ts"],"sourcesContent":["/**\n * The error the Vite plugin throws.\n *\n * @remarks\n * The plugin runs in the dev server's Node process, where loading `@ignifx/core` (and through it\n * Babylon Lite) to throw its `IgnifxError` would be pure cost. Like `@ignifx/vite-plugin`'s own\n * error, it carries the same registered `IGX-####` codes the page half throws.\n */\n\nimport type { EditorHostErrorCode } from \"../error-codes.js\";\n\n/**\n * The error every `@ignifx/editor-host/vite` API throws for a misconfiguration\n * (`CONSTITUTION.md` §3.9).\n *\n * @beta\n */\nexport class EditorHostPluginError extends Error {\n /** The stable diagnostic code for this failure. */\n readonly code: EditorHostErrorCode;\n\n /**\n * Creates a plugin error.\n *\n * @param code - The stable `IGX-####` code for the failure.\n * @param message - An actionable description of what went wrong and how to fix it.\n */\n constructor(code: EditorHostErrorCode, message: string) {\n super(message);\n this.name = \"EditorHostPluginError\";\n this.code = code;\n }\n}\n","/**\n * The page and the two modules the plugin generates: the scene view's HTML entry, the module that\n * page runs, and `virtual:ignifx/editor`, the play view's controls.\n */\n\nimport {\n ASSET_CHANGED_EVENT,\n IGNIFX_CONFIG_DEFINE_KEY,\n MANIFEST_MODULE_ID,\n SCRIPTS_MODULE_ID,\n} from \"@ignifx/vite-plugin\";\nimport { EditorHostErrorCode } from \"../error-codes.js\";\nimport { EditorHostPluginError } from \"./errors.js\";\n\n/**\n * The path the scene view is served at, below the dev server's `base`.\n *\n * @beta\n */\nexport const EDITOR_PAGE_PATH = \"/__ignifx_editor__/\";\n\n/**\n * The module a game imports to hand its app to the editor's play controls.\n *\n * @example\n * ```ts\n * import { attachEditorPlayControls } from \"virtual:ignifx/editor\";\n *\n * attachEditorPlayControls(app);\n * ```\n *\n * @beta\n */\nexport const EDITOR_MODULE_ID = \"virtual:ignifx/editor\";\n\n/**\n * The resolved id of {@link EDITOR_MODULE_ID}. The `\\0` prefix marks it as owned by a plugin.\n *\n * @beta\n */\nexport const RESOLVED_EDITOR_MODULE_ID: string = `\\0${EDITOR_MODULE_ID}`;\n\n/**\n * The module the scene view's page runs. Only the generated page imports it.\n *\n * @beta\n */\nexport const EDITOR_ENTRY_MODULE_ID = \"virtual:ignifx/editor-host-entry\";\n\n/**\n * The resolved id of {@link EDITOR_ENTRY_MODULE_ID}.\n *\n * @beta\n */\nexport const RESOLVED_EDITOR_ENTRY_MODULE_ID: string = `\\0${EDITOR_ENTRY_MODULE_ID}`;\n\n/**\n * The function `virtual:ignifx/editor` exports. It takes the game's app and returns a function that\n * detaches the controls; in a production build it does nothing.\n *\n * @beta\n */\nexport const EDITOR_PLAY_CONTROLS_EXPORT = \"attachEditorPlayControls\";\n\n/**\n * The module the scene view imports the project's extensions from, unless the plugin is told\n * otherwise. It exports `extensions()`, which returns the list `main.ts` passes to `createApp`.\n *\n * @beta\n */\nexport const DEFAULT_EXTENSIONS_MODULE = \"/src/extensions.ts\";\n\n/**\n * The `id` of the scene view's canvas.\n *\n * @beta\n */\nexport const EDITOR_CANVAS_ID = \"ignifx-editor-view\";\n\n/** The package the generated modules import the host from, resolved from the project's root. */\nconst HOST_PACKAGE = \"@ignifx/editor-host\";\n\n/**\n * Options accepted by {@link editorEntryModuleSource}.\n *\n * @beta\n */\nexport interface EditorEntryModuleOptions {\n /** The origin the editor is served from. */\n readonly editorOrigin: string;\n /** The root-absolute path of the project's extensions module, or `null` when it has none. */\n readonly extensionsModule: string | null;\n /** A scene address to load before the app starts, or `null`. */\n readonly bootScene: string | null;\n /** The project's `@ignifx/core` version, or `null` when it could not be read. */\n readonly engineVersion: string | null;\n /** Milliseconds between heartbeats, or `null` for the host's default. */\n readonly heartbeatIntervalMs: number | null;\n}\n\n/**\n * Options accepted by {@link playControlsModuleSource}.\n *\n * @beta\n */\nexport interface PlayControlsModuleOptions {\n /** The origin the editor is served from. */\n readonly editorOrigin: string;\n /** The project's `@ignifx/core` version, or `null` when it could not be read. */\n readonly engineVersion: string | null;\n /** Milliseconds between heartbeats, or `null` for the host's default. */\n readonly heartbeatIntervalMs: number | null;\n /**\n * Emit the development module. `false` emits the production no-op, which imports nothing and has\n * no `import.meta.hot` reference.\n */\n readonly hot: boolean;\n}\n\n/**\n * Turns the `extensions` option into the root-absolute path the generated module imports.\n *\n * @param path - The path as configured, relative to the Vite root or already root-absolute.\n * @returns The root-absolute path, for example `\"/src/extensions.ts\"`.\n * @throws EditorHostPluginError `IGX-1803` when the path is empty or leaves the root with `..`.\n *\n * @beta\n */\nexport function normalizeExtensionsModule(path: string): string {\n const trimmed = path.startsWith(\"./\") ? path.slice(2) : path;\n if (trimmed === \"\" || trimmed === \"/\" || trimmed.split(\"/\").some((segment) => segment === \"..\")) {\n throw new EditorHostPluginError(\n EditorHostErrorCode.invalidOption,\n `The \"extensions\" option must name a module inside the Vite root, for example \"src/extensions.ts\"; got \"${path}\".`,\n );\n }\n return trimmed.startsWith(\"/\") ? trimmed : `/${trimmed}`;\n}\n\n/**\n * The fields shared by both generated calls, as source text.\n *\n * @param engineVersion - The version to report, or `null`.\n * @param heartbeatIntervalMs - The heartbeat period, or `null`.\n * @returns Zero, one, or two `key: value,` lines.\n */\nfunction reportingLines(engineVersion: string | null, heartbeatIntervalMs: number | null): readonly string[] {\n return [\n ...(engineVersion === null ? [] : [` engineVersion: ${JSON.stringify(engineVersion)},`]),\n ...(heartbeatIntervalMs === null ? [] : [` heartbeatIntervalMs: ${JSON.stringify(heartbeatIntervalMs)},`]),\n ];\n}\n\n/**\n * Generates the module the scene view's page runs.\n *\n * @remarks\n * The module is the only code with an import-time effect: it creates the host. The package itself\n * creates nothing when imported (`CONSTITUTION.md` §3.5). Every import is resolved from the\n * project's root, so the host, the scripts, and the extensions share the project's one copy of\n * `@ignifx/core`. It hands every `ignifx:asset-changed` event to `host.assetChanged`, which\n * reloads the asset in place; the `import.meta.hot` calls are written out literally, because Vite\n * finds them by reading the source.\n *\n * @param options - The editor origin, the project's extensions module, and the reporting options.\n * @returns The ES module source.\n *\n * @beta\n */\nexport function editorEntryModuleSource(options: EditorEntryModuleOptions): string {\n const { extensionsModule } = options;\n return [\n `import { startEditorHost } from ${JSON.stringify(HOST_PACKAGE)};`,\n `import { manifest } from ${JSON.stringify(MANIFEST_MODULE_ID)};`,\n `import { acceptHotReload, scripts } from ${JSON.stringify(SCRIPTS_MODULE_ID)};`,\n ...(extensionsModule === null ? [] : [`import { extensions } from ${JSON.stringify(extensionsModule)};`]),\n \"\",\n \"const host = await startEditorHost({\",\n ` editorOrigin: ${JSON.stringify(options.editorOrigin)},`,\n ' hostKind: \"scene\",',\n ` canvas: document.getElementById(${JSON.stringify(EDITOR_CANVAS_ID)}),`,\n ` settings: ${IGNIFX_CONFIG_DEFINE_KEY},`,\n \" assets: { manifest },\",\n ` extensions: ${extensionsModule === null ? \"[]\" : \"extensions()\"},`,\n \" scripts,\",\n ` bootScene: ${JSON.stringify(options.bootScene)},`,\n ...reportingLines(options.engineVersion, options.heartbeatIntervalMs),\n \"});\",\n \"acceptHotReload(host.app);\",\n \"if (import.meta.hot) {\",\n ` import.meta.hot.on(${JSON.stringify(ASSET_CHANGED_EVENT)}, (change) => {`,\n \" void host.assetChanged(change);\",\n \" });\",\n \"}\",\n \"\",\n ].join(\"\\n\");\n}\n\n/**\n * Generates the scene view's HTML page, before Vite's own `transformIndexHtml` adds its client.\n *\n * @returns The HTML document.\n *\n * @beta\n */\nexport function editorPageHtml(): string {\n return [\n \"<!doctype html>\",\n '<html lang=\"en\">',\n \" <head>\",\n ' <meta charset=\"utf-8\" />',\n ' <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />',\n \" <title>ignifx editor host</title>\",\n \" <style>\",\n \" html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }\",\n ` #${EDITOR_CANVAS_ID} { display: block; width: 100%; height: 100%; }`,\n \" </style>\",\n \" </head>\",\n \" <body>\",\n ` <canvas id=\"${EDITOR_CANVAS_ID}\"></canvas>`,\n ` <script type=\"module\" src=\"/@id/${EDITOR_ENTRY_MODULE_ID}\"></script>`,\n \" </body>\",\n \"</html>\",\n \"\",\n ].join(\"\\n\");\n}\n\n/**\n * Generates `virtual:ignifx/editor`.\n *\n * @remarks\n * In development, the module listens for the editor's connect message as soon as it is evaluated,\n * which is before the game's `main.ts` runs, and keeps the port\n * (`listenForEditorPlayControls`); `attachEditorPlayControls(app)` then starts the play controls on\n * it, so the editor's first connect message is never lost to `await createApp(...)`. Vite replacing\n * the module stops both. The `import.meta.hot` calls are written out literally because Vite\n * finds them by reading the source, not by running it. In a production build the export is an empty\n * function, the same shape as `acceptHotReload` from `virtual:ignifx/scripts`, so the game's\n * `main.ts` builds either way and ships no editor code.\n *\n * @param options - The editor origin, the reporting options, and whether to emit the development module.\n * @returns The ES module source.\n *\n * @beta\n */\nexport function playControlsModuleSource(options: PlayControlsModuleOptions): string {\n if (!options.hot) {\n return [`export function ${EDITOR_PLAY_CONTROLS_EXPORT}() {`, \" return () => {};\", \"}\", \"\"].join(\"\\n\");\n }\n return [\n `import { listenForEditorPlayControls } from ${JSON.stringify(HOST_PACKAGE)};`,\n \"\",\n \"// Listens now, before main.ts awaits createApp, so the editor's first port is kept.\",\n \"const connector = listenForEditorPlayControls({\",\n ` editorOrigin: ${JSON.stringify(options.editorOrigin)},`,\n ...reportingLines(options.engineVersion, options.heartbeatIntervalMs),\n \"});\",\n \"if (import.meta.hot) {\",\n \" import.meta.hot.dispose(() => {\",\n \" connector.dispose();\",\n \" });\",\n \"}\",\n \"\",\n `export function ${EDITOR_PLAY_CONTROLS_EXPORT}(app) {`,\n \" const controls = connector.attach(app);\",\n \" return () => {\",\n \" controls.dispose();\",\n \" };\",\n \"}\",\n \"\",\n ].join(\"\\n\");\n}\n","/**\n * A copy of `@ignifx/vite-plugin`'s `.ignifx/` request guard and build-output check\n * (`src/private-dir.ts` there), kept here as defence in depth: a project whose Vite config lists\n * `editorHostPlugin()` without `ignifx()` would otherwise serve `.ignifx/mcp.json`, the editor's MCP\n * token, to any page, or copy it into `dist/` through a link under `public/`. `@ignifx/vite-plugin`\n * is an optional peer, so this package cannot import it. Below this comment the file is\n * byte-identical to that one, which `test/private-dir-copy.test.ts` checks; change both together.\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { readdir, rm, stat } from \"node:fs/promises\";\nimport { basename, dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport type { Connect } from \"vite\";\n\n/** The editor-private directory at a project's root. */\nexport const PRIVATE_DIR_NAME = \".ignifx\";\n\n/**\n * `server.fs.deny` patterns for the private directory. Vite matches a pattern without a `/` at any\n * depth, so `.ignifx` denies the directory itself wherever it is and the glob denies its contents.\n */\nexport const PRIVATE_DIR_DENY: readonly string[] = [PRIVATE_DIR_NAME, `**/${PRIVATE_DIR_NAME}/**`];\n\n/**\n * Vite 8's own `server.fs.deny` defaults. A deny list returned from a `config` hook replaces them\n * when the user set none, so the plugin restates them; a test compares this list with Vite's.\n */\nexport const VITE_DEFAULT_FS_DENY: readonly string[] = [\n \".env\",\n \".env.*\",\n \"*.{crt,pem,key,p12,pfx,cer,der}\",\n \".npmrc\",\n \".yarnrc.yml\",\n \"**/.git/**\",\n];\n\n/** Percent-decoding passes before a path counts as private regardless of what it decodes to. */\nconst MAX_DECODE_PASSES = 8;\n\n/** Windows 8.3 short names of `.ignifx` (`IGNIFX~1`), which resolve to it on NTFS. */\nconst SHORT_NAME_RE = /^ignifx~\\d+$/u;\n\n/**\n * The `server.fs.deny` list the plugin contributes to the user's config.\n *\n * @param userDeny - The deny list the config holds so far, or `undefined` when none is set.\n * @returns The patterns to return from the `config` hook. Vite concatenates them with a list the user\n * set; with none set, Vite's defaults come first so returning a list does not drop them.\n */\nexport function privateDirDenyPatterns(userDeny: readonly string[] | undefined): string[] {\n return userDeny === undefined ? [...VITE_DEFAULT_FS_DENY, ...PRIVATE_DIR_DENY] : [...PRIVATE_DIR_DENY];\n}\n\n/**\n * Decodes every `%XX` escape, byte by byte, so a malformed sequence never stops decoding.\n *\n * @param text - The text to decode.\n * @returns The text with each escape replaced by the byte it names.\n */\nfunction decodeEscapes(text: string): string {\n return text.replaceAll(/%([0-9a-f]{2})/giu, (_match, hex: string) => String.fromCodePoint(Number.parseInt(hex, 16)));\n}\n\n/**\n * Reports whether one path segment names the private directory.\n *\n * @param segment - One decoded segment.\n * @returns `true` for `.ignifx` in any case, with Windows' ignored trailing dots and spaces, an\n * alternate data stream suffix, or as an 8.3 short name.\n */\nfunction isPrivateSegment(segment: string): boolean {\n const name = (segment.normalize(\"NFKC\").toLowerCase().split(\":\")[0] ?? \"\").replace(/[. ]+$/u, \"\");\n return name === PRIVATE_DIR_NAME || SHORT_NAME_RE.test(name);\n}\n\n/**\n * Reports whether a request URL reaches into the private directory.\n *\n * @remarks\n * The query and fragment are dropped, then escapes are decoded until the path stops changing (so\n * `%252e` counts as `.`). Every segment between `/`, `\\`, `?` and `#` is checked: resolving `.` and\n * `..` only removes segments, so a path that names no `.ignifx` segment cannot reach one, and this\n * covers `/@fs/<absolute path>` and `/@id/` forms alike.\n *\n * @param url - The request URL as the server received it.\n * @returns `true` when the request must be refused.\n */\nexport function isPrivateRequestPath(url: string): boolean {\n const path = decodedRequestPath(url);\n return path === null || hasPrivateSegment(path);\n}\n\n/**\n * The path part of a request URL with every escape decoded, nested ones included.\n *\n * @param url - The request URL as the server received it.\n * @returns The decoded path, or `null` when it still changes after the last decoding pass.\n */\nfunction decodedRequestPath(url: string): string | null {\n let path = url.split(/[?#]/u, 1)[0] ?? \"\";\n for (let pass = 0; ; pass += 1) {\n const decoded = decodeEscapes(path);\n if (decoded === path) {\n return path;\n }\n if (pass === MAX_DECODE_PASSES) {\n return null;\n }\n path = decoded;\n }\n}\n\n/**\n * Reports whether a path names the private directory in any of its segments.\n *\n * @param path - A path with `/` or `\\` separators, relative or absolute.\n * @returns `true` when a segment between separators is a spelling of `.ignifx`.\n */\nexport function hasPrivateSegment(path: string): boolean {\n return path.split(/[/\\\\?#]/u).some(isPrivateSegment);\n}\n\n/**\n * Reports whether a file, once every symbolic link on its path is followed, lies in a private\n * directory.\n *\n * @remarks\n * A link such as `src/link -> ../.ignifx` hides the directory from every check that reads the path\n * as written. The deepest part of `path` that exists is resolved with `realpath` and the rest\n * appended, so a request for a file the server would find by adding an extension is judged too.\n * Only the part of the real path below `realBase` and its common ancestor with the file counts:\n * a project that itself lives under some `.ignifx` directory is not refused wholesale.\n *\n * @param realBase - The real path the result is measured from, normally the project root.\n * @param path - An absolute path, existing or not.\n * @returns `true` when the real path has a `.ignifx` segment, or when it cannot be resolved for a\n * reason other than not existing (the check fails closed).\n *\n * It is synchronous, like Vite's own file lookups: a few `realpath` calls per request or module.\n */\nexport function isPrivateRealPath(realBase: string, path: string): boolean {\n let current = path;\n const rest: string[] = [];\n for (;;) {\n try {\n return hasPrivateSegment(relative(realBase, join(realpathSync.native(current), ...rest)));\n } catch (error) {\n const missing = isMissingFileError(error);\n const parent = dirname(current);\n if (!missing || parent === current) {\n return !missing;\n }\n rest.unshift(basename(current));\n current = parent;\n }\n }\n}\n\n/**\n * Reports whether a caught failure means \"there is no such file\".\n *\n * @param error - The caught value.\n * @returns `true` for `ENOENT` and `ENOTDIR`.\n */\nfunction isMissingFileError(error: unknown): boolean {\n const code = typeof error === \"object\" && error !== null && \"code\" in error ? error.code : null;\n return code === \"ENOENT\" || code === \"ENOTDIR\";\n}\n\n/**\n * Resolves a path to its real path, or returns it unchanged when it cannot be resolved.\n *\n * @param path - An absolute path.\n * @returns The real path.\n */\nexport function realPathOrSelf(path: string): string {\n try {\n return realpathSync.native(path);\n } catch {\n return path;\n }\n}\n\n/**\n * Answers 404 with no body and no caching.\n *\n * @param response - The response to end.\n */\nfunction refuse(response: Parameters<Connect.NextHandleFunction>[1]): void {\n response.statusCode = 404;\n response.setHeader(\"Cache-Control\", \"no-store\");\n response.end();\n}\n\n/** Where a server finds the file a request URL names. */\nexport interface PrivateDirGuardOptions {\n /** The real path of the project root, which real paths are judged against. */\n readonly realRoot: string;\n /** The server's `base`; a URL is tried with and without it. */\n readonly base: string;\n /** The directories a root-relative URL is served from: the root and `publicDir` in dev, `outDir` in preview. */\n readonly serveDirs: readonly string[];\n /** `resolve.alias`, which Vite's static middleware applies to request paths in dev; `[]` in preview. */\n readonly alias: readonly { readonly find: string | RegExp; readonly replacement: string }[];\n /** `resolve.extensions`, which Vite tries for a module request whose file does not exist. */\n readonly extensions: readonly string[];\n}\n\n/** The `/@fs/` prefix Vite serves absolute paths under, and `/@id/` for unresolved ids. */\nconst FS_PREFIX = \"/@fs/\";\nconst ID_PREFIX = \"/@id/\";\nconst DRIVE_RE = /^[a-z]:/iu;\n\n/**\n * The files a decoded request path could be served from.\n *\n * @param path - The decoded request path, `/`-separated.\n * @param options - The server's directories and base.\n * @returns Absolute paths, existing or not.\n */\nfunction candidateFiles(path: string, options: PrivateDirGuardOptions): string[] {\n const basePath = options.base.startsWith(\"/\") ? options.base : \"/\";\n const forms = [path];\n if (basePath !== \"/\" && path.startsWith(basePath)) {\n forms.push(`/${path.slice(basePath.length)}`);\n }\n const candidates: string[] = [];\n for (const form of forms) {\n const relativeForms = [form];\n // Vite's static middleware rewrites a path the first alias matches and serves it from the root.\n const alias = options.alias.find(({ find }) =>\n typeof find === \"string\" ? form.startsWith(find) : find.test(form),\n );\n if (alias !== undefined) {\n const redirected = form.replace(alias.find, alias.replacement);\n candidates.push(redirected);\n relativeForms.push(redirected);\n }\n for (const prefix of [FS_PREFIX, ID_PREFIX]) {\n if (form.startsWith(prefix)) {\n const rest = form.slice(prefix.length);\n candidates.push(DRIVE_RE.test(rest) ? rest : `/${rest.replace(/^\\/+/u, \"\")}`);\n relativeForms.push(`/${rest}`);\n }\n }\n for (const directory of options.serveDirs) {\n candidates.push(...relativeForms.map((relativeForm) => join(directory, relativeForm)));\n }\n }\n // `resolve` folds `.` and `..` the way a server normalises a URL, before anything is looked up.\n return candidates.filter((candidate) => isAbsolute(candidate)).map((candidate) => resolve(candidate));\n}\n\n/**\n * Reports whether a candidate file, or the file Vite would find by adding an extension to it, is\n * private once links are followed.\n *\n * @param file - An absolute candidate path.\n * @param options - The real root and `resolve.extensions`.\n * @returns `true` when the request must be refused.\n */\nfunction isPrivateCandidate(file: string, options: PrivateDirGuardOptions): boolean {\n if (isPrivateRealPath(options.realRoot, file)) {\n return true;\n }\n // Extensions are only worth trying where Vite would: the file is missing and its directory is not.\n if (existsSync(file) || !existsSync(dirname(file))) {\n return false;\n }\n return options.extensions.some((extension) => isPrivateRealPath(options.realRoot, `${file}${extension}`));\n}\n\n/**\n * Connect middleware that answers 404, with no body, to every request into the private directory:\n * one whose path names it ({@link isPrivateRequestPath}), and one whose file lies in it once\n * symbolic links are followed (`src/link -> ../.ignifx`).\n *\n * @remarks\n * For the second, it maps the URL to the files Vite could serve for it (root, `publicDir` or\n * `outDir`, `/@fs/` and `/@id/` absolute paths, with and without `base`, and the path a\n * `resolve.alias` entry rewrites it to) and checks each with {@link isPrivateRealPath}. A missing\n * file is judged by its deepest existing ancestor and, when its directory exists, with each of\n * `resolve.extensions` appended, as Vite completes a module request. The plugin's `load` hook\n * covers what Vite resolves some other way.\n *\n * @param options - Returns the server's directories; read per request, as they are only known once\n * the config is resolved.\n * @returns The middleware.\n */\nexport function createPrivateDirGuard(options: () => PrivateDirGuardOptions): Connect.NextHandleFunction {\n return (request, response, next) => {\n const decoded = decodedRequestPath(request.url ?? \"\");\n if (decoded === null || hasPrivateSegment(decoded)) {\n refuse(response);\n return;\n }\n const resolved = options();\n const path = decoded.replaceAll(\"\\\\\", \"/\");\n if (candidateFiles(path, resolved).some((file) => isPrivateCandidate(file, resolved))) {\n refuse(response);\n return;\n }\n next();\n };\n}\n\n/**\n * Lists what a build put in its output directory from a private directory: any entry with a\n * `.ignifx` segment, any link whose real path is private, and the copy of any `publicDir` entry\n * whose real path is private (Vite copies `publicDir` following symbolic links, so\n * `public/tok.json -> ../.ignifx/mcp.json` arrives as a plain file holding the token).\n *\n * @param outDir - The absolute output directory.\n * @param publicDir - The absolute `publicDir` the build copied, or `null` when it copied none.\n * @returns The absolute paths to remove from `outDir`, outermost first; `[]` when there are none.\n */\nexport async function findPrivateOutputs(outDir: string, publicDir: string | null): Promise<string[]> {\n const found = new Set<string>();\n const entries = await readdir(outDir, { recursive: true, withFileTypes: true }).catch(() => []);\n const realOutDir = realPathOrSelf(outDir);\n for (const entry of entries) {\n const path = join(entry.parentPath, entry.name);\n const segments = relative(outDir, path).split(/[/\\\\]/u);\n const index = segments.findIndex(isPrivateSegment);\n if (index !== -1) {\n found.add(join(outDir, ...segments.slice(0, index + 1)));\n } else if (entry.isSymbolicLink() && isPrivateRealPath(realOutDir, path)) {\n found.add(path);\n }\n }\n if (publicDir !== null) {\n const realPublic = realPathOrSelf(publicDir);\n await collectPrivatePublicEntries(publicDir, realPublic, outDir, new Set([realPublic]), found);\n }\n return [...found].toSorted();\n}\n\n/**\n * Walks `publicDir` the way Vite's copy does and records the output path of every private entry.\n *\n * @param directory - The directory being read.\n * @param realPublic - The real path of `publicDir`.\n * @param outDirectory - Where `directory`'s entries are copied to.\n * @param visited - Real directories already walked, so a link cycle ends.\n * @param found - Receives the output paths.\n */\nasync function collectPrivatePublicEntries(\n directory: string,\n realPublic: string,\n outDirectory: string,\n visited: Set<string>,\n found: Set<string>,\n): Promise<void> {\n const names = await readdir(directory).catch(() => []);\n await Promise.all(\n names.map(async (name) => {\n const source = join(directory, name);\n const target = join(outDirectory, name);\n if (isPrivateRealPath(realPublic, source)) {\n found.add(target);\n return;\n }\n const isDirectory = await stat(source).then(\n (stats) => stats.isDirectory(),\n () => false,\n );\n const real = realPathOrSelf(source);\n if (isDirectory && !visited.has(real)) {\n visited.add(real);\n await collectPrivatePublicEntries(source, realPublic, target, visited, found);\n }\n }),\n );\n}\n\n/**\n * Removes the private entries {@link findPrivateOutputs} found.\n *\n * @param paths - The paths to remove.\n */\nexport async function removePrivateOutputs(paths: readonly string[]): Promise<void> {\n await Promise.all(paths.map((path) => rm(path, { recursive: true, force: true })));\n}\n","/**\n * The editor host's Vite plugin: the scene view's page on the project's own dev server, and\n * `virtual:ignifx/editor` for the play view (`docs/architecture/17-editor-host.md` §3).\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { EditorHostErrorCode, isEditorOrigin } from \"../error-codes.js\";\nimport { EditorHostPluginError } from \"./errors.js\";\nimport {\n DEFAULT_EXTENSIONS_MODULE,\n EDITOR_ENTRY_MODULE_ID,\n EDITOR_MODULE_ID,\n EDITOR_PAGE_PATH,\n editorEntryModuleSource,\n editorPageHtml,\n normalizeExtensionsModule,\n playControlsModuleSource,\n RESOLVED_EDITOR_ENTRY_MODULE_ID,\n RESOLVED_EDITOR_MODULE_ID,\n} from \"./modules.js\";\nimport {\n createPrivateDirGuard,\n findPrivateOutputs,\n isPrivateRealPath,\n realPathOrSelf,\n removePrivateOutputs,\n} from \"./private-dir.js\";\nimport type { ConfigEnv, Plugin, ViteDevServer } from \"vite\";\n\n/**\n * Options accepted by {@link editorHostPlugin}.\n *\n * @beta\n */\nexport interface EditorHostPluginOptions {\n /**\n * The origin the editor is served from, for example `\"ignifx-editor://app\"` when packaged or\n * `\"http://localhost:5173\"` while the editor itself runs from a dev server. Only this origin may\n * frame either view in `vite dev`, and only it can hand either view a port.\n */\n readonly editorOrigin: string;\n /**\n * The project's extensions module, relative to the Vite root. It exports `extensions()`, which\n * returns the list `main.ts` passes to `createApp`. When the file does not exist the scene view\n * runs with no extensions. Defaults to `\"/src/extensions.ts\"`.\n */\n readonly extensions?: string;\n /** A scene address the scene view loads before it starts. Defaults to none. */\n readonly bootScene?: string | null;\n /** Milliseconds between heartbeats in both views. Defaults to the host's `1000`. */\n readonly heartbeatIntervalMs?: number;\n}\n\n/** The plugin names, as they appear in Vite's logs. */\nconst PAGE_PLUGIN_NAME = \"ignifx-editor-host\";\nconst PLAY_PLUGIN_NAME = \"ignifx-editor-host:play-controls\";\n\n/** What Vite crawls for dependencies when `optimizeDeps.entries` is not set. */\nconst DEFAULT_OPTIMIZE_ENTRIES = \"**/*.html\";\n\n/**\n * Reads the version of the project's own `@ignifx/core`.\n *\n * @param root - The Vite root.\n * @returns The version, or `null` when the project does not resolve `@ignifx/core`.\n *\n * @beta\n */\nexport function readProjectEngineVersion(root: string): string | null {\n try {\n const requireFromProject = createRequire(join(root, \"package.json\"));\n const manifest: unknown = JSON.parse(readFileSync(requireFromProject.resolve(\"@ignifx/core/package.json\"), \"utf8\"));\n if (typeof manifest === \"object\" && manifest !== null && \"version\" in manifest) {\n return typeof manifest.version === \"string\" ? manifest.version : null;\n }\n return null;\n } catch {\n // An unresolvable core is reported by the host as core's own `VERSION`, not as a failure here.\n return null;\n }\n}\n\n/**\n * Checks the options and applies their defaults.\n *\n * @param options - The options as given.\n * @returns The extensions module path and the heartbeat period.\n * @throws EditorHostPluginError `IGX-1801` for a malformed origin, `IGX-1803` for a bad option.\n */\nfunction checkOptions(options: EditorHostPluginOptions): { extensions: string; heartbeatIntervalMs: number | null } {\n if (!isEditorOrigin(options.editorOrigin)) {\n throw new EditorHostPluginError(\n EditorHostErrorCode.invalidEditorOrigin,\n `editorOrigin \"${options.editorOrigin}\" is not an origin; pass one such as \"ignifx-editor://app\" or \"http://localhost:5173\".`,\n );\n }\n const interval = options.heartbeatIntervalMs;\n if (interval !== undefined && (!Number.isFinite(interval) || interval <= 0)) {\n throw new EditorHostPluginError(\n EditorHostErrorCode.invalidOption,\n `heartbeatIntervalMs must be a positive number of milliseconds; got ${String(interval)}.`,\n );\n }\n return {\n extensions: normalizeExtensionsModule(options.extensions ?? DEFAULT_EXTENSIONS_MODULE),\n heartbeatIntervalMs: interval ?? null,\n };\n}\n\n/**\n * The editor host's Vite plugin.\n *\n * @remarks\n * It is two plugins, because the two halves run under different commands:\n *\n * - `ignifx-editor-host` (`vite dev` only) serves the scene view at `/__ignifx_editor__/` with\n * `Content-Security-Policy: frame-ancestors <editorOrigin>`, and adds the same header to every\n * page a browser navigates to, so the game's own `index.html` (the play view) can be framed by the\n * editor and by nothing else. A `Content-Security-Policy` in `server.headers` replaces it. The page's module imports the host,\n * `virtual:ignifx/scripts`, `virtual:ignifx/manifest` and the project's extensions module from\n * the project's own graph, and calls `startEditorHost`. It adds the extensions module to\n * `optimizeDeps.entries` (keeping Vite's default crawl) and keeps `@ignifx/editor-host` out of\n * pre-bundling, so the host reaches the same pre-bundled `@ignifx/core` as the game.\n * - `ignifx-editor-host:play-controls` (every command) serves `virtual:ignifx/editor`: the play\n * controls under `vite dev`, an empty function under `vite build`. Under `vite dev` and\n * `vite preview` it also answers 404 to any request into `.ignifx/`, the editor's private\n * directory, by path or through a symbolic link, as `ignifx()` does; under `vite build` it fails\n * the build, after removing them, when the output holds a `.ignifx` directory or a copy of a\n * `publicDir` file that links into one. This covers a config that lists this plugin without\n * `ignifx()`.\n *\n * List it after `ignifx()` from `@ignifx/vite-plugin`, which serves the two modules the scene\n * view imports.\n *\n * @param options - The editor's origin and the scene view's options.\n * @returns The plugins, to be listed in `vite.config.ts`.\n * @throws EditorHostPluginError `IGX-1801` for a malformed `editorOrigin`, `IGX-1803` for a bad\n * `extensions` path or `heartbeatIntervalMs`.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { ignifx } from \"@ignifx/vite-plugin\";\n * import { editorHostPlugin } from \"@ignifx/editor-host/vite\";\n * import { defineConfig } from \"vite\";\n *\n * export default defineConfig({\n * plugins: [ignifx(), editorHostPlugin({ editorOrigin: \"ignifx-editor://app\" })],\n * });\n * ```\n *\n * @beta\n */\nexport function editorHostPlugin(options: EditorHostPluginOptions): Plugin[] {\n const { extensions, heartbeatIntervalMs } = checkOptions(options);\n const { editorOrigin } = options;\n let root = process.cwd();\n let base = \"/\";\n let command: ConfigEnv[\"command\"] = \"serve\";\n let engineVersion: string | null = null;\n let copiedPublicDir: string | null = null;\n\n const extensionsFile = (): string => resolve(root, `.${extensions}`);\n // Only the editor may put either view in a frame; any other page that tries is blocked. A tab the\n // developer opens on the dev server is not a frame, so the policy leaves it alone.\n const framePolicy = `frame-ancestors ${editorOrigin}`;\n\n /**\n * Sends the frame policy with every page a browser navigates to, the game's `index.html` (the\n * play view) included. Navigations and frames ask for `text/html`; module and asset requests do\n * not, and a policy on them would do nothing anyway.\n *\n * @param server - The dev server.\n */\n const installPlayViewPolicy = (server: ViteDevServer): void => {\n server.middlewares.use((request, response, next) => {\n const isRead = request.method === \"GET\" || request.method === \"HEAD\";\n if (isRead && (request.headers.accept ?? \"\").includes(\"text/html\")) {\n response.setHeader(\"Content-Security-Policy\", framePolicy);\n }\n next();\n });\n };\n\n /**\n * Serves the scene view's page and redirects the path without its trailing slash.\n *\n * @param server - The dev server.\n */\n const installPage = (server: ViteDevServer): void => {\n const pagePath = `${base.endsWith(\"/\") ? base.slice(0, -1) : base}${EDITOR_PAGE_PATH}`;\n server.middlewares.use((request, response, next) => {\n const url = request.url ?? \"\";\n const path = url.split(\"?\")[0] ?? \"\";\n if (path === pagePath.slice(0, -1)) {\n response.statusCode = 302;\n response.setHeader(\"Location\", `${pagePath}${url.slice(path.length)}`);\n response.end();\n return;\n }\n if (path !== pagePath && path !== `${pagePath}index.html`) {\n next();\n return;\n }\n server.transformIndexHtml(EDITOR_PAGE_PATH, editorPageHtml(), request.originalUrl).then(\n (html) => {\n response.statusCode = 200;\n response.setHeader(\"Content-Type\", \"text/html; charset=utf-8\");\n response.setHeader(\"Cache-Control\", \"no-store\");\n response.setHeader(\"Content-Security-Policy\", framePolicy);\n response.end(html);\n },\n (error: unknown) => {\n next(error);\n },\n );\n });\n };\n\n const page: Plugin = {\n name: PAGE_PLUGIN_NAME,\n // A production build must never contain the scene view.\n apply: \"serve\",\n\n config(userConfig) {\n const projectRoot = resolve(process.cwd(), userConfig.root ?? \".\");\n const scanExtensions = existsSync(resolve(projectRoot, `.${extensions}`));\n // Vite concatenates arrays when it merges this into the user's config, and setting `entries`\n // at all replaces its default crawl of every HTML file, so the default is restated only when\n // the user set nothing.\n const entries =\n userConfig.optimizeDeps?.entries === undefined\n ? [DEFAULT_OPTIMIZE_ENTRIES, extensions.slice(1)]\n : [extensions.slice(1)];\n return {\n optimizeDeps: {\n ...(scanExtensions ? { entries } : {}),\n // Served as it is, its `@ignifx/core` import resolves to the game's own pre-bundled core.\n exclude: [\"@ignifx/editor-host\"],\n },\n };\n },\n\n configResolved(resolvedConfig) {\n root = resolvedConfig.root;\n base = resolvedConfig.base;\n engineVersion = readProjectEngineVersion(root);\n },\n\n configureServer(server) {\n // Registered directly rather than returned as a post hook, so they run before Vite's own HTML\n // fallback and index middleware.\n installPlayViewPolicy(server);\n installPage(server);\n },\n\n resolveId(id) {\n return id === EDITOR_ENTRY_MODULE_ID ? RESOLVED_EDITOR_ENTRY_MODULE_ID : null;\n },\n\n load(id) {\n if (id !== RESOLVED_EDITOR_ENTRY_MODULE_ID) {\n return null;\n }\n return editorEntryModuleSource({\n editorOrigin,\n extensionsModule: existsSync(extensionsFile()) ? extensions : null,\n bootScene: options.bootScene ?? null,\n engineVersion,\n heartbeatIntervalMs,\n });\n },\n };\n\n const play: Plugin = {\n name: PLAY_PLUGIN_NAME,\n\n configResolved(resolvedConfig) {\n root = resolvedConfig.root;\n command = resolvedConfig.command;\n engineVersion = readProjectEngineVersion(root);\n const { publicDir } = resolvedConfig;\n copiedPublicDir = resolvedConfig.build.copyPublicDir && publicDir !== \"\" ? publicDir : null;\n },\n\n // Defence in depth for a config without `ignifx()`, whose guard otherwise keeps `.ignifx/` (the\n // editor's MCP token) off the server; registered in the hook body, ahead of Vite's file serving.\n configureServer(server) {\n const realRoot = realPathOrSelf(server.config.root);\n const { publicDir } = server.config;\n server.middlewares.use(\n createPrivateDirGuard(() => ({\n realRoot,\n base: server.config.base,\n serveDirs: publicDir === \"\" ? [server.config.root] : [server.config.root, publicDir],\n alias: server.config.resolve.alias,\n extensions: server.config.resolve.extensions,\n })),\n );\n },\n\n configurePreviewServer(server) {\n const realRoot = realPathOrSelf(server.config.root);\n const outDir = resolve(server.config.root, server.config.build.outDir);\n server.middlewares.use(\n createPrivateDirGuard(() => ({\n realRoot,\n base: server.config.base,\n serveDirs: [outDir],\n alias: [],\n extensions: [],\n })),\n );\n },\n\n resolveId(id) {\n return id === EDITOR_MODULE_ID ? RESOLVED_EDITOR_MODULE_ID : null;\n },\n\n load(id) {\n if (id === RESOLVED_EDITOR_MODULE_ID) {\n return playControlsModuleSource({ editorOrigin, engineVersion, heartbeatIntervalMs, hot: command === \"serve\" });\n }\n // Whatever resolved to it (an alias, `/@id/`, an import through a link), a module whose real\n // path is in `.ignifx/` is never loaded: in dev it would be served, in a build bundled.\n const file = id.split(\"?\", 1)[0] ?? \"\";\n if (!id.startsWith(\"\\0\") && isAbsolute(file) && isPrivateRealPath(realPathOrSelf(root), file)) {\n this.error(\n `\"${file}\" is in the editor-private .ignifx/ directory, which holds the editor's MCP token; ` +\n \"nothing may import or serve it. Remove the import or link.\",\n );\n }\n return null;\n },\n\n // As `ignifx()` does: Vite copies `publicDir` into the output whole, dot-directories and link\n // targets included, so `public/tok.json -> ../.ignifx/mcp.json` would ship the MCP token.\n async writeBundle(output) {\n const outDir = output.dir ?? (output.file === undefined ? null : dirname(output.file));\n if (outDir === null) {\n return;\n }\n const leaked = await findPrivateOutputs(outDir, copiedPublicDir);\n if (leaked.length === 0) {\n return;\n }\n await removePrivateOutputs(leaked);\n this.error(\n \"The build output held files from the editor-private .ignifx/ directory, which holds the \" +\n `editor's MCP token: ${leaked.map((path) => relative(outDir, path)).join(\", \")}. They were ` +\n \"removed and the build failed. Move .ignifx/ out of publicDir and remove any link into it \" +\n \"from publicDir.\",\n );\n },\n };\n\n return [page, play];\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,IAAa,wBAAb,cAA2C,MAAM;;CAE/C;;;;;;;CAQA,YAAY,MAA2B,SAAiB;EACtD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;ACbA,MAAa,mBAAmB;;;;;;;;;;;;;AAchC,MAAa,mBAAmB;;;;;;AAOhC,MAAa,4BAAoC,KAAK;;;;;;AAOtD,MAAa,yBAAyB;;;;;;AAOtC,MAAa,kCAA0C,KAAK;;;;;;;AAQ5D,MAAa,8BAA8B;;;;;;;AAQ3C,MAAa,4BAA4B;;;;;;AAOzC,MAAa,mBAAmB;;AAGhC,MAAM,eAAe;;;;;;;;;;AAgDrB,SAAgB,0BAA0B,MAAsB;CAC9D,MAAM,UAAU,KAAK,WAAW,IAAI,IAAI,KAAK,MAAM,CAAC,IAAI;CACxD,IAAI,YAAY,MAAM,YAAY,OAAO,QAAQ,MAAM,GAAG,CAAC,CAAC,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C7B,YAAY,OAAO,OAAO,QAAQ;GACpC,EAAE,CACJ;EACF;EAEA,uBAAuB,QAAQ;GAC7B,MAAM,WAAW,eAAe,OAAO,OAAO,IAAI;GAClD,MAAM,SAAS,QAAQ,OAAO,OAAO,MAAM,OAAO,OAAO,MAAM,MAAM;GACrE,OAAO,YAAY,IACjB,6BAA6B;IAC3B;IACA,MAAM,OAAO,OAAO;IACpB,WAAW,CAAC,MAAM;IAClB,OAAO,CAAC;IACR,YAAY,CAAC;GACf,EAAE,CACJ;EACF;EAEA,UAAU,IAAI;GACZ,OAAO,OAAA,0BAA0B,4BAA4B;EAC/D;EAEA,KAAK,IAAI;GACP,IAAI,OAAO,2BACT,OAAO,yBAAyB;IAAE;IAAc;IAAe;IAAqB,KAAK,YAAY;GAAQ,CAAC;GAIhH,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,MAAM;GACpC,IAAI,CAAC,GAAG,WAAW,IAAI,KAAK,WAAW,IAAI,KAAK,kBAAkB,eAAe,IAAI,GAAG,IAAI,GAC1F,KAAK,MACH,IAAI,KAAK,8IAEX;GAEF,OAAO;EACT;EAIA,MAAM,YAAY,QAAQ;GACxB,MAAM,SAAS,OAAO,QAAQ,OAAO,SAAS,KAAA,IAAY,OAAO,QAAQ,OAAO,IAAI;GACpF,IAAI,WAAW,MACb;GAEF,MAAM,SAAS,MAAM,mBAAmB,QAAQ,eAAe;GAC/D,IAAI,OAAO,WAAW,GACpB;GAEF,MAAM,qBAAqB,MAAM;GACjC,KAAK,MACH,+GACyB,OAAO,KAAK,SAAS,SAAS,QAAQ,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,qHAGnF;EACF;CAGe,CAAC;AACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ignifx/editor-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "ignifx editor host: runs a project's own engine inside the ignifx editor's scene view and play view, over a versioned protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ignifx"
|
|
@@ -52,17 +52,19 @@
|
|
|
52
52
|
"typescript-native": "npm:typescript@7.0.2",
|
|
53
53
|
"vite": "^8.2.2",
|
|
54
54
|
"vitest": "^5.0.0",
|
|
55
|
-
"@ignifx/2d": "0.
|
|
56
|
-
"@ignifx/
|
|
57
|
-
"@ignifx/
|
|
58
|
-
"@ignifx/
|
|
59
|
-
"@ignifx/
|
|
55
|
+
"@ignifx/2d": "0.13.0",
|
|
56
|
+
"@ignifx/3d": "0.13.0",
|
|
57
|
+
"@ignifx/core": "0.13.0",
|
|
58
|
+
"@ignifx/input": "0.13.0",
|
|
59
|
+
"@ignifx/physics": "0.13.0",
|
|
60
|
+
"@ignifx/physics-2d": "0.13.0",
|
|
61
|
+
"@ignifx/vite-plugin": "0.13.0"
|
|
60
62
|
},
|
|
61
63
|
"peerDependencies": {
|
|
62
64
|
"@babylonjs/lite": "1.34.0",
|
|
63
65
|
"vite": "^8.2.2",
|
|
64
|
-
"@ignifx/core": "0.
|
|
65
|
-
"@ignifx/vite-plugin": "0.
|
|
66
|
+
"@ignifx/core": "0.13.0",
|
|
67
|
+
"@ignifx/vite-plugin": "0.13.0"
|
|
66
68
|
},
|
|
67
69
|
"peerDependenciesMeta": {
|
|
68
70
|
"@ignifx/vite-plugin": {
|