@realitycollective/iwsdk-uiextensions 0.1.0-preview.6 → 0.1.0-preview.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
9
9
  ### Added
10
10
 
11
11
  - `verify:pack` now lints the shape of what ships: publint over every package directory, with warnings counted as errors, and attw (Are The Types Wrong) over every packed tarball, resolving the published types under node10, node16 and bundler resolution. `cjs-resolves-to-esm` is ignored by design, because every package is ESM-only and a require() caller is expected to use a dynamic import. Both run offline on the tarballs the script already builds; `publint` and `@arethetypeswrong/cli` are dev dependencies. The script stays identical across the Reality Collective repositories.
12
+ - `verify:pack` now also type-checks the published declarations themselves, with library checking on, through `scripts/declaration-check.mjs`, runnable on its own as `node scripts/declaration-check.mjs`. Each package's declaration entry is compiled as a strict consumer would compile it, with `skipLibCheck: false`, under nodenext and then bundler resolution; a diagnostic inside the package fails the run, and diagnostics inside upstream declaration files are counted and ignored, because they are not ours to fix and would drown the signal. attw proves the published types resolve; this proves they compile, which is what a consumer with library checking on, or a package emitting declarations on top of ours, needs. The check is opt-in per repository, through `declarationCheck` in `scripts/release.config.json`, because only a foreign declaration can put a name into our emitted types that the build did not already check. This repository reaches around 950 of them, from the IWSDK and three.js typings the adapter is built against, and every run prints that count so the opt-in stays measured rather than habitual. It is the check that would have caught the bare `World` under Fixed.
12
13
  - `@realitycollective/webxr-uiextensions` - engine-free core: window manager, dock state and regions, drag maths, hold-to-drag, control models (stepper/toggle/expandable/log), the `SceneDescriptor` scene format, window chrome conventions and the platform-adapter contract.
13
14
  - `@realitycollective/iwsdk-uiextensions` - Meta IWSDK adapter binding the core onto IWSDK's ECS, UIKitML and interaction systems, with shipped examples.
14
15
  - `@realitycollective/xrblocks-uiextensions` - EXPERIMENTAL Google XR Blocks / plain three.js adapter: panel document, window host, follow and scale maths, desktop controls and locomotion, pointer forwarding.
@@ -43,6 +44,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
43
44
 
44
45
  ### Fixed
45
46
 
47
+ - `@realitycollective/iwsdk-uiextensions` shipped five declaration files (`controls-system`, `dock-region-system`, `dock-system`, `drag-system` and `window-system` under `dist/systems/`) whose `createSystem` base type named `World` without importing it, so a consumer with `skipLibCheck: false`, or one emitting declarations on top of the package, failed with TS2304 on its first import. Reported by the Anatomy Atlas XR client on 9 September 2026 against preview.4 and preview.6. The cause is upstream: `@iwsdk/core` 0.5.3's `dist/ecs/system.d.ts` imports `World` from `'./world'` with no extension, the only such import in the package, and under the NodeNext resolution this repository builds with that import does not resolve (TS2835), so `World` was an unresolved name inside the host's own declaration and TypeScript's declaration emitter preserved it verbatim. `skipLibCheck` hid the error on both sides. The adapter now takes `createSystem` from its own `src/create-system.ts`, a wrapper whose return type names `World` through `@iwsdk/core`'s barrel, so every emitted base type reads `import("@iwsdk/core").World`. The wrapper goes the day IWSDK ships `./world.js` there.
46
48
  - `createSceneHost(world)` returns the same host on every call for a world, where it previously built a new one each time. A second host registered a second readiness ECS system on the same world and repeated the panel upgrade pass, so two modules each asking for the host quietly doubled that work. It now memoises per world exactly as the window manager registry does, which also means separate modules can ask for the host without coordinating or passing it around.
47
49
  - Documented in `@realitycollective/iwsdk-uiextensions` that `onPanelReady` announces windows spawned by `createUIWindow`, not only by `host.createWindow`, so code holding factory entities has a readiness signal without changing how it spawns them. The readiness section now also warns against polling `getPanelHandle` on a timer, because a poll that gives up early leaves a window that draws and responds to nothing with no error, and records that a factory window created without an `id` is announced as `kind: 'panel'` with its config path, which a listener filtering on `kind === 'window'` will never see.
48
50
  - `@realitycollective/uix-devtools/cli` resolved to no types under TypeScript's legacy `node10` module resolution, which ignores the `exports` map; `typesVersions` now maps the subpath to `dist/cli/lib.d.ts`. Found by the attw step `verify:pack` gained in this release.
@@ -0,0 +1,33 @@
1
+ /**
2
+ * `createSystem` from `@iwsdk/core`, with its return type written out.
3
+ *
4
+ * Why this file exists. IWSDK 0.5.3 declares `createSystem` in
5
+ * `dist/ecs/system.d.ts` as returning `SystemConstructor<S, Q, World, System<S, Q>>`,
6
+ * and that file imports `World` from './world' with no extension, the only
7
+ * extensionless relative import in the package. This repository builds with
8
+ * `moduleResolution: NodeNext`, under which an extensionless relative import
9
+ * in an ES module does not resolve (TS2835), so inside the host's own
10
+ * declaration `World` is an unresolved name. `skipLibCheck` hides the error,
11
+ * and TypeScript's declaration emitter preserves an unresolved name verbatim,
12
+ * so every `export class X extends createSystem(...)` in this package was
13
+ * emitted with a bare `World` in its base type. A consumer that checks
14
+ * library files (`skipLibCheck: false`, or a package emitting declarations on
15
+ * top of ours) fails with TS2304 on its first import of this package. A file
16
+ * that happened to import `World` for another signature resolved the bare
17
+ * name by accident, which is how the sibling adapters looked clean.
18
+ *
19
+ * The annotation below names `World` through `@iwsdk/core`'s barrel, whose
20
+ * imports all carry extensions, so the emitter writes
21
+ * `import("@iwsdk/core").World` wherever the result is extended. Every system
22
+ * in this package takes `createSystem` from here, never from `@iwsdk/core`.
23
+ * `elics` is imported for its types only: it is `@iwsdk/core`'s own
24
+ * dependency, the import is erased at build time, and the emitted
25
+ * declarations already name `import("elics").SystemConstructor`.
26
+ *
27
+ * Delete this file, and import `createSystem` from `@iwsdk/core` again, once
28
+ * IWSDK ships `./world.js` there. `scripts/declaration-check.mjs`, run by
29
+ * `verify:pack`, is the check that fails while the bare name is emitted.
30
+ */
31
+ import { type System, type World } from '@iwsdk/core';
32
+ import type { SystemConstructor, SystemQueries, SystemSchema } from 'elics';
33
+ export declare function createSystem<S extends SystemSchema, Q extends SystemQueries>(queries?: Q, schema?: S): SystemConstructor<S, Q, World, System<S, Q>>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * `createSystem` from `@iwsdk/core`, with its return type written out.
3
+ *
4
+ * Why this file exists. IWSDK 0.5.3 declares `createSystem` in
5
+ * `dist/ecs/system.d.ts` as returning `SystemConstructor<S, Q, World, System<S, Q>>`,
6
+ * and that file imports `World` from './world' with no extension, the only
7
+ * extensionless relative import in the package. This repository builds with
8
+ * `moduleResolution: NodeNext`, under which an extensionless relative import
9
+ * in an ES module does not resolve (TS2835), so inside the host's own
10
+ * declaration `World` is an unresolved name. `skipLibCheck` hides the error,
11
+ * and TypeScript's declaration emitter preserves an unresolved name verbatim,
12
+ * so every `export class X extends createSystem(...)` in this package was
13
+ * emitted with a bare `World` in its base type. A consumer that checks
14
+ * library files (`skipLibCheck: false`, or a package emitting declarations on
15
+ * top of ours) fails with TS2304 on its first import of this package. A file
16
+ * that happened to import `World` for another signature resolved the bare
17
+ * name by accident, which is how the sibling adapters looked clean.
18
+ *
19
+ * The annotation below names `World` through `@iwsdk/core`'s barrel, whose
20
+ * imports all carry extensions, so the emitter writes
21
+ * `import("@iwsdk/core").World` wherever the result is extended. Every system
22
+ * in this package takes `createSystem` from here, never from `@iwsdk/core`.
23
+ * `elics` is imported for its types only: it is `@iwsdk/core`'s own
24
+ * dependency, the import is erased at build time, and the emitted
25
+ * declarations already name `import("elics").SystemConstructor`.
26
+ *
27
+ * Delete this file, and import `createSystem` from `@iwsdk/core` again, once
28
+ * IWSDK ships `./world.js` there. `scripts/declaration-check.mjs`, run by
29
+ * `verify:pack`, is the check that fails while the bare name is emitted.
30
+ */
31
+ import { createSystem as createIWSDKSystem } from '@iwsdk/core';
32
+ export function createSystem(queries, schema) {
33
+ return createIWSDKSystem(queries, schema);
34
+ }
35
+ //# sourceMappingURL=create-system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-system.js","sourceRoot":"","sources":["../src/create-system.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAA2B,MAAM,aAAa,CAAC;AAGzF,MAAM,UAAU,YAAY,CAC1B,OAAW,EACX,MAAU;IAEV,OAAO,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/**\n * `createSystem` from `@iwsdk/core`, with its return type written out.\n *\n * Why this file exists. IWSDK 0.5.3 declares `createSystem` in\n * `dist/ecs/system.d.ts` as returning `SystemConstructor<S, Q, World, System<S, Q>>`,\n * and that file imports `World` from './world' with no extension, the only\n * extensionless relative import in the package. This repository builds with\n * `moduleResolution: NodeNext`, under which an extensionless relative import\n * in an ES module does not resolve (TS2835), so inside the host's own\n * declaration `World` is an unresolved name. `skipLibCheck` hides the error,\n * and TypeScript's declaration emitter preserves an unresolved name verbatim,\n * so every `export class X extends createSystem(...)` in this package was\n * emitted with a bare `World` in its base type. A consumer that checks\n * library files (`skipLibCheck: false`, or a package emitting declarations on\n * top of ours) fails with TS2304 on its first import of this package. A file\n * that happened to import `World` for another signature resolved the bare\n * name by accident, which is how the sibling adapters looked clean.\n *\n * The annotation below names `World` through `@iwsdk/core`'s barrel, whose\n * imports all carry extensions, so the emitter writes\n * `import(\"@iwsdk/core\").World` wherever the result is extended. Every system\n * in this package takes `createSystem` from here, never from `@iwsdk/core`.\n * `elics` is imported for its types only: it is `@iwsdk/core`'s own\n * dependency, the import is erased at build time, and the emitted\n * declarations already name `import(\"elics\").SystemConstructor`.\n *\n * Delete this file, and import `createSystem` from `@iwsdk/core` again, once\n * IWSDK ships `./world.js` there. `scripts/declaration-check.mjs`, run by\n * `verify:pack`, is the check that fails while the bare name is emitted.\n */\nimport { createSystem as createIWSDKSystem, type System, type World } from '@iwsdk/core';\nimport type { SystemConstructor, SystemQueries, SystemSchema } from 'elics';\n\nexport function createSystem<S extends SystemSchema, Q extends SystemQueries>(\n queries?: Q,\n schema?: S,\n): SystemConstructor<S, Q, World, System<S, Q>> {\n return createIWSDKSystem(queries, schema);\n}\n"]}
@@ -15,7 +15,8 @@
15
15
  * `kind: 'panel'` and their config path as the id, so devtools and hand-built
16
16
  * entities show up in the same stream as managed windows.
17
17
  */
18
- import { PanelDocument, PanelUI, createSystem, } from '@iwsdk/core';
18
+ import { PanelDocument, PanelUI, } from '@iwsdk/core';
19
+ import { createSystem } from './create-system.js';
19
20
  import { upgradePanel, } from '@realitycollective/webxr-uiextensions';
20
21
  import { createDockRegion, createUIWindow, } from './factory.js';
21
22
  import { UIWindow } from './components.js';
@@ -1 +1 @@
1
- {"version":3,"file":"scene-host.js","sourceRoot":"","sources":["../src/scene-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACL,aAAa,EACb,OAAO,EAEP,YAAY,GAGb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,GASb,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,cAAc,GAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,kDAAkD;AAClD,SAAS,cAAc,CAAC,QAAuB;IAC7C,OAAO;QACL,IAAI,IAAI;YACN,OAAO,QAAQ,CAAC,WAAoC,CAAC;QACvD,CAAC;QACD,cAAc,EAAE,CAAC,EAAE,EAAE,EAAE,CACpB,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAuB,IAAI,SAAS;QACjE,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CACrC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC;QAC7C,OAAO,EAAE,GAAG,EAAE;YACZ,uDAAuD;QACzD,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAE5C,CAAC;IACd,OAAO,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,OAAiC;IAC1D,OAAO,MA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AAW,KAAK,SAAS;oBAClC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE;oBACrC,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,MAAM,CAAC,eAAe,KAAK,SAAS;oBACtC,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE;oBAC7C,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpE,GAAG,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvE,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,SAAS;oBAClC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE;oBACrC,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxE,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * IWSDK implementation of the core's `WindowHost` + `SceneTarget`.\n *\n * This is what makes a portable `SceneDescriptor` build the SAME playground\n * on IWSDK as on plain three.js, and lets app behaviour be wired through\n * `onPanelReady` instead of hand-written ECS queries:\n *\n * const host = createSceneHost(world);\n * applyScene(host, PLAYGROUND);\n * host.onPanelReady(({ id, panel }) => wireMyPanel(id, panel));\n *\n * Readiness is detected with a single ECS query on `PanelUI + PanelDocument`\n * - the engine-specific mechanism stays here, behind the portable interface.\n * Bare panels (a `PanelUI` entity with no `UIWindow`) are announced too, with\n * `kind: 'panel'` and their config path as the id, so devtools and hand-built\n * entities show up in the same stream as managed windows.\n */\nimport {\n PanelDocument,\n PanelUI,\n UIKitDocument,\n createSystem,\n type Entity,\n type World,\n} from '@iwsdk/core';\nimport {\n upgradePanel,\n type PanelHandle,\n type PanelReadyEvent,\n type SceneRegion,\n type SceneTarget,\n type SceneWindow,\n type UixElement,\n type WindowHandle,\n type WindowHost,\n} from '@realitycollective/webxr-uiextensions';\nimport {\n createDockRegion,\n createUIWindow,\n type CreateWindowOptions,\n} from './factory.js';\nimport { UIWindow } from './components.js';\n\n/** Panel handle over an IWSDK `UIKitDocument`. */\nfunction panelHandleFor(document: UIKitDocument): PanelHandle {\n return {\n get root(): UixElement {\n return document.rootElement as unknown as UixElement;\n },\n getElementById: (id) =>\n (document.getElementById(id) as UixElement | null) ?? undefined,\n setTargetDimensions: (width, height) =>\n document.setTargetDimensions(width, height),\n dispose: () => {\n /* IWSDK owns the document lifecycle via the entity. */\n },\n };\n}\n\n/**\n * The live panel on an entity, or `undefined` while IWSDK is still loading\n * its document. Use it to reach a panel from an entity you already hold;\n * `onPanelReady` stays the way to be TOLD when one appears.\n */\nexport function getPanelHandle(entity: Entity): PanelHandle | undefined {\n const document = PanelDocument.data.document[entity.index] as\n | UIKitDocument\n | undefined;\n return document ? panelHandleFor(document) : undefined;\n}\n\n/**\n * Bridges panel loading into `onPanelReady`. Registered once per host; the\n * query fires as each panel's document is attached by IWSDK's UI system.\n */\nfunction createReadySystem(onReady: (entity: Entity) => void) {\n return class UixPanelReadySystem extends createSystem({\n panels: { required: [PanelUI, PanelDocument] },\n }) {\n override init(): void {\n this.cleanupFuncs.push(\n this.queries.panels.subscribe('qualify', (entity) => onReady(entity)),\n );\n this.queries.panels.entities.forEach((entity) => onReady(entity));\n }\n };\n}\n\n/** A window spawned by {@link IwsdkSceneHost.createWindow}. */\nexport interface IwsdkWindowHandle extends WindowHandle {\n /** The ECS entity carrying `PanelUI`, `UIWindow` and the interaction tags. */\n readonly entity: Entity;\n}\n\nexport interface IwsdkSceneHost extends WindowHost, SceneTarget {\n readonly world: World;\n /**\n * Spawn a managed window and get a handle back straight away. IWSDK loads\n * the markup over later frames, so `handle.panel` is `undefined` at first\n * and `handle.onReady` is how you wait for it without an ECS query.\n */\n createWindow(options: CreateWindowOptions): IwsdkWindowHandle;\n}\n\nconst hosts = new WeakMap<World, IwsdkSceneHost>();\n\n/**\n * The host for a world: built on the first call, and the same instance every\n * call after that. Call AFTER `registerUIExtensions(world)`.\n *\n * One host per world is deliberate. A host owns an ECS system, the record of\n * which documents it has already announced, and the panel upgrade pass, so a\n * second independent host on the same world would run a second copy of all\n * three. Two modules can each ask for the host without coordinating, exactly\n * as they do for the window manager registry.\n */\nexport function createSceneHost(world: World): IwsdkSceneHost {\n const existing = hosts.get(world);\n if (existing) {\n return existing;\n }\n const host = buildSceneHost(world);\n hosts.set(world, host);\n return host;\n}\n\nfunction buildSceneHost(world: World): IwsdkSceneHost {\n const readyListeners = new Set<(event: PanelReadyEvent) => void>();\n const ready = new Map<string, PanelReadyEvent>();\n const seen = new WeakSet<object>();\n\n const announce = (entity: Entity): void => {\n const document = PanelDocument.data.document[entity.index] as\n | UIKitDocument\n | undefined;\n if (!document || seen.has(document)) {\n return;\n }\n seen.add(document);\n // Window id comes from the UIWindow component the factory attached. A\n // panel without one is a bare panel - still worth announcing, keyed by\n // its config path, which is the only stable id IWSDK gives it.\n const windowId = entity.hasComponent(UIWindow)\n ? (UIWindow.data.windowId[entity.index] as string)\n : '';\n const kind: 'window' | 'panel' = windowId ? 'window' : 'panel';\n const id = windowId || (PanelUI.data.config[entity.index] as string);\n const panel = panelHandleFor(document);\n // Upgrade `data-uix` controls exactly as the ECS controls system does,\n // so wiring code sees the same handles on every adapter (idempotent).\n upgradePanel(document, document.rootElement as unknown as UixElement);\n const event: PanelReadyEvent = { id, panel, kind };\n ready.set(id, event);\n for (const listener of readyListeners) {\n try {\n listener(event);\n } catch (error) {\n console.error(`[uix] panel-ready listener failed for \"${id}\":`, error);\n }\n }\n };\n\n world.registerSystem(createReadySystem(announce));\n\n let windowSequence = 0;\n\n const host: IwsdkSceneHost = {\n world,\n\n // IWSDK owns panel lifecycles through the ECS, so there is no bare-panel\n // path here - `createPanel` throws rather than half-working.\n supportsStandalonePanels: false,\n\n createPanel(): PanelHandle {\n throw new Error(\n '[uix] createPanel() is not supported on the IWSDK host - spawn a window ' +\n '(spawnWindow/createUIWindow) so IWSDK owns the panel lifecycle.',\n );\n },\n\n onPanelReady(listener) {\n readyListeners.add(listener);\n for (const event of ready.values()) {\n listener(event);\n }\n return () => void readyListeners.delete(listener);\n },\n\n createWindow(options: CreateWindowOptions): IwsdkWindowHandle {\n const id = options.id ?? `uix-window-${(windowSequence += 1)}`;\n const entity = createUIWindow(world, { ...options, id });\n return {\n entity,\n id,\n get panel(): PanelHandle | undefined {\n return ready.get(id)?.panel;\n },\n onReady(listener: (panel: PanelHandle) => void): () => void {\n const existing = ready.get(id)?.panel;\n if (existing) {\n listener(existing);\n return () => {};\n }\n // `onPanelReady` replays panels that are already live, but this id\n // is not one of them, so the callback only ever runs later.\n const unsubscribe = host.onPanelReady((event) => {\n if (event.id === id) {\n unsubscribe();\n listener(event.panel);\n }\n });\n return unsubscribe;\n },\n };\n },\n\n spawnRegion(region: SceneRegion): void {\n createDockRegion(world, {\n id: region.id,\n ...(region.flow !== undefined ? { flow: region.flow } : {}),\n ...(region.pitch !== undefined ? { pitch: region.pitch } : {}),\n ...(region.columns !== undefined ? { columns: region.columns } : {}),\n ...(region.capacity !== undefined ? { capacity: region.capacity } : {}),\n ...(region.snapRadius !== undefined\n ? { snapRadius: region.snapRadius }\n : {}),\n ...(region.position !== undefined\n ? { position: [...region.position] as [number, number, number] }\n : {}),\n ...(region.follow !== undefined ? { follow: region.follow } : {}),\n ...(region.followOffset !== undefined\n ? { followOffset: [...region.followOffset] as [number, number, number] }\n : {}),\n });\n },\n\n spawnWindow(window: SceneWindow): void {\n host.createWindow({\n id: window.id,\n title: window.title,\n config: window.config,\n ...(window.position !== undefined\n ? { position: [...window.position] as [number, number, number] }\n : {}),\n ...(window.maxWidth !== undefined ? { maxWidth: window.maxWidth } : {}),\n ...(window.maxHeight !== undefined ? { maxHeight: window.maxHeight } : {}),\n ...(window.dockMode !== undefined ? { dockMode: window.dockMode } : {}),\n ...(window.region !== undefined ? { region: window.region } : {}),\n ...(window.followOffset !== undefined\n ? { followOffset: [...window.followOffset] as [number, number, number] }\n : {}),\n ...(window.followSpeed !== undefined\n ? { followSpeed: window.followSpeed }\n : {}),\n ...(window.followTolerance !== undefined\n ? { followTolerance: window.followTolerance }\n : {}),\n ...(window.movable !== undefined ? { movable: window.movable } : {}),\n ...(window.closable !== undefined ? { closable: window.closable } : {}),\n ...(window.minimizable !== undefined\n ? { minimizable: window.minimizable }\n : {}),\n ...(window.pinnable !== undefined ? { pinnable: window.pinnable } : {}),\n });\n },\n };\n\n return host;\n}\n"]}
1
+ {"version":3,"file":"scene-host.js","sourceRoot":"","sources":["../src/scene-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACL,aAAa,EACb,OAAO,GAIR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,YAAY,GASb,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,cAAc,GAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,kDAAkD;AAClD,SAAS,cAAc,CAAC,QAAuB;IAC7C,OAAO;QACL,IAAI,IAAI;YACN,OAAO,QAAQ,CAAC,WAAoC,CAAC;QACvD,CAAC;QACD,cAAc,EAAE,CAAC,EAAE,EAAE,EAAE,CACpB,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAuB,IAAI,SAAS;QACjE,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM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C,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxE,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * IWSDK implementation of the core's `WindowHost` + `SceneTarget`.\n *\n * This is what makes a portable `SceneDescriptor` build the SAME playground\n * on IWSDK as on plain three.js, and lets app behaviour be wired through\n * `onPanelReady` instead of hand-written ECS queries:\n *\n * const host = createSceneHost(world);\n * applyScene(host, PLAYGROUND);\n * host.onPanelReady(({ id, panel }) => wireMyPanel(id, panel));\n *\n * Readiness is detected with a single ECS query on `PanelUI + PanelDocument`\n * - the engine-specific mechanism stays here, behind the portable interface.\n * Bare panels (a `PanelUI` entity with no `UIWindow`) are announced too, with\n * `kind: 'panel'` and their config path as the id, so devtools and hand-built\n * entities show up in the same stream as managed windows.\n */\nimport {\n PanelDocument,\n PanelUI,\n UIKitDocument,\n type Entity,\n type World,\n} from '@iwsdk/core';\nimport { createSystem } from './create-system.js';\nimport {\n upgradePanel,\n type PanelHandle,\n type PanelReadyEvent,\n type SceneRegion,\n type SceneTarget,\n type SceneWindow,\n type UixElement,\n type WindowHandle,\n type WindowHost,\n} from '@realitycollective/webxr-uiextensions';\nimport {\n createDockRegion,\n createUIWindow,\n type CreateWindowOptions,\n} from './factory.js';\nimport { UIWindow } from './components.js';\n\n/** Panel handle over an IWSDK `UIKitDocument`. */\nfunction panelHandleFor(document: UIKitDocument): PanelHandle {\n return {\n get root(): UixElement {\n return document.rootElement as unknown as UixElement;\n },\n getElementById: (id) =>\n (document.getElementById(id) as UixElement | null) ?? undefined,\n setTargetDimensions: (width, height) =>\n document.setTargetDimensions(width, height),\n dispose: () => {\n /* IWSDK owns the document lifecycle via the entity. */\n },\n };\n}\n\n/**\n * The live panel on an entity, or `undefined` while IWSDK is still loading\n * its document. Use it to reach a panel from an entity you already hold;\n * `onPanelReady` stays the way to be TOLD when one appears.\n */\nexport function getPanelHandle(entity: Entity): PanelHandle | undefined {\n const document = PanelDocument.data.document[entity.index] as\n | UIKitDocument\n | undefined;\n return document ? panelHandleFor(document) : undefined;\n}\n\n/**\n * Bridges panel loading into `onPanelReady`. Registered once per host; the\n * query fires as each panel's document is attached by IWSDK's UI system.\n */\nfunction createReadySystem(onReady: (entity: Entity) => void) {\n return class UixPanelReadySystem extends createSystem({\n panels: { required: [PanelUI, PanelDocument] },\n }) {\n override init(): void {\n this.cleanupFuncs.push(\n this.queries.panels.subscribe('qualify', (entity) => onReady(entity)),\n );\n this.queries.panels.entities.forEach((entity) => onReady(entity));\n }\n };\n}\n\n/** A window spawned by {@link IwsdkSceneHost.createWindow}. */\nexport interface IwsdkWindowHandle extends WindowHandle {\n /** The ECS entity carrying `PanelUI`, `UIWindow` and the interaction tags. */\n readonly entity: Entity;\n}\n\nexport interface IwsdkSceneHost extends WindowHost, SceneTarget {\n readonly world: World;\n /**\n * Spawn a managed window and get a handle back straight away. IWSDK loads\n * the markup over later frames, so `handle.panel` is `undefined` at first\n * and `handle.onReady` is how you wait for it without an ECS query.\n */\n createWindow(options: CreateWindowOptions): IwsdkWindowHandle;\n}\n\nconst hosts = new WeakMap<World, IwsdkSceneHost>();\n\n/**\n * The host for a world: built on the first call, and the same instance every\n * call after that. Call AFTER `registerUIExtensions(world)`.\n *\n * One host per world is deliberate. A host owns an ECS system, the record of\n * which documents it has already announced, and the panel upgrade pass, so a\n * second independent host on the same world would run a second copy of all\n * three. Two modules can each ask for the host without coordinating, exactly\n * as they do for the window manager registry.\n */\nexport function createSceneHost(world: World): IwsdkSceneHost {\n const existing = hosts.get(world);\n if (existing) {\n return existing;\n }\n const host = buildSceneHost(world);\n hosts.set(world, host);\n return host;\n}\n\nfunction buildSceneHost(world: World): IwsdkSceneHost {\n const readyListeners = new Set<(event: PanelReadyEvent) => void>();\n const ready = new Map<string, PanelReadyEvent>();\n const seen = new WeakSet<object>();\n\n const announce = (entity: Entity): void => {\n const document = PanelDocument.data.document[entity.index] as\n | UIKitDocument\n | undefined;\n if (!document || seen.has(document)) {\n return;\n }\n seen.add(document);\n // Window id comes from the UIWindow component the factory attached. A\n // panel without one is a bare panel - still worth announcing, keyed by\n // its config path, which is the only stable id IWSDK gives it.\n const windowId = entity.hasComponent(UIWindow)\n ? (UIWindow.data.windowId[entity.index] as string)\n : '';\n const kind: 'window' | 'panel' = windowId ? 'window' : 'panel';\n const id = windowId || (PanelUI.data.config[entity.index] as string);\n const panel = panelHandleFor(document);\n // Upgrade `data-uix` controls exactly as the ECS controls system does,\n // so wiring code sees the same handles on every adapter (idempotent).\n upgradePanel(document, document.rootElement as unknown as UixElement);\n const event: PanelReadyEvent = { id, panel, kind };\n ready.set(id, event);\n for (const listener of readyListeners) {\n try {\n listener(event);\n } catch (error) {\n console.error(`[uix] panel-ready listener failed for \"${id}\":`, error);\n }\n }\n };\n\n world.registerSystem(createReadySystem(announce));\n\n let windowSequence = 0;\n\n const host: IwsdkSceneHost = {\n world,\n\n // IWSDK owns panel lifecycles through the ECS, so there is no bare-panel\n // path here - `createPanel` throws rather than half-working.\n supportsStandalonePanels: false,\n\n createPanel(): PanelHandle {\n throw new Error(\n '[uix] createPanel() is not supported on the IWSDK host - spawn a window ' +\n '(spawnWindow/createUIWindow) so IWSDK owns the panel lifecycle.',\n );\n },\n\n onPanelReady(listener) {\n readyListeners.add(listener);\n for (const event of ready.values()) {\n listener(event);\n }\n return () => void readyListeners.delete(listener);\n },\n\n createWindow(options: CreateWindowOptions): IwsdkWindowHandle {\n const id = options.id ?? `uix-window-${(windowSequence += 1)}`;\n const entity = createUIWindow(world, { ...options, id });\n return {\n entity,\n id,\n get panel(): PanelHandle | undefined {\n return ready.get(id)?.panel;\n },\n onReady(listener: (panel: PanelHandle) => void): () => void {\n const existing = ready.get(id)?.panel;\n if (existing) {\n listener(existing);\n return () => {};\n }\n // `onPanelReady` replays panels that are already live, but this id\n // is not one of them, so the callback only ever runs later.\n const unsubscribe = host.onPanelReady((event) => {\n if (event.id === id) {\n unsubscribe();\n listener(event.panel);\n }\n });\n return unsubscribe;\n },\n };\n },\n\n spawnRegion(region: SceneRegion): void {\n createDockRegion(world, {\n id: region.id,\n ...(region.flow !== undefined ? { flow: region.flow } : {}),\n ...(region.pitch !== undefined ? { pitch: region.pitch } : {}),\n ...(region.columns !== undefined ? { columns: region.columns } : {}),\n ...(region.capacity !== undefined ? { capacity: region.capacity } : {}),\n ...(region.snapRadius !== undefined\n ? { snapRadius: region.snapRadius }\n : {}),\n ...(region.position !== undefined\n ? { position: [...region.position] as [number, number, number] }\n : {}),\n ...(region.follow !== undefined ? { follow: region.follow } : {}),\n ...(region.followOffset !== undefined\n ? { followOffset: [...region.followOffset] as [number, number, number] }\n : {}),\n });\n },\n\n spawnWindow(window: SceneWindow): void {\n host.createWindow({\n id: window.id,\n title: window.title,\n config: window.config,\n ...(window.position !== undefined\n ? { position: [...window.position] as [number, number, number] }\n : {}),\n ...(window.maxWidth !== undefined ? { maxWidth: window.maxWidth } : {}),\n ...(window.maxHeight !== undefined ? { maxHeight: window.maxHeight } : {}),\n ...(window.dockMode !== undefined ? { dockMode: window.dockMode } : {}),\n ...(window.region !== undefined ? { region: window.region } : {}),\n ...(window.followOffset !== undefined\n ? { followOffset: [...window.followOffset] as [number, number, number] }\n : {}),\n ...(window.followSpeed !== undefined\n ? { followSpeed: window.followSpeed }\n : {}),\n ...(window.followTolerance !== undefined\n ? { followTolerance: window.followTolerance }\n : {}),\n ...(window.movable !== undefined ? { movable: window.movable } : {}),\n ...(window.closable !== undefined ? { closable: window.closable } : {}),\n ...(window.minimizable !== undefined\n ? { minimizable: window.minimizable }\n : {}),\n ...(window.pinnable !== undefined ? { pinnable: window.pinnable } : {}),\n });\n },\n };\n\n return host;\n}\n"]}
@@ -7,7 +7,7 @@ declare const UIControlsSystem_base: import("elics").SystemConstructor<import("e
7
7
  };
8
8
  }>[];
9
9
  };
10
- }, World, import("@iwsdk/core").System<import("elics").SystemSchema, {
10
+ }, import("@iwsdk/core").World, import("@iwsdk/core").System<import("elics").SystemSchema, {
11
11
  panels: {
12
12
  required: import("elics").Component<{
13
13
  document: {
@@ -4,7 +4,8 @@
4
4
  * Runs against ALL `PanelDocument` panels, not just windows: any IWSDK panel
5
5
  * gains steppers, toggles, expandable labels and log views by markup alone.
6
6
  */
7
- import { PanelDocument, createSystem } from '@iwsdk/core';
7
+ import { PanelDocument } from '@iwsdk/core';
8
+ import { createSystem } from '../create-system.js';
8
9
  import { upgradePanel } from '@realitycollective/webxr-uiextensions';
9
10
  export class UIControlsSystem extends createSystem({
10
11
  panels: { required: [PanelDocument] },
@@ -1 +1 @@
1
- {"version":3,"file":"controls-system.js","sourceRoot":"","sources":["../../src/systems/controls-system.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAiB,YAAY,EAAe,MAAM,aAAa,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,MAAM,OAAO,gBAAiB,SAAQ,YAAY,CAAC;IACjD,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,aAAa,CAAC,EAAE;CACtC,CAAC;IACS,IAAI;QACX,IAAI,CAAC,YAAY,CAAC,IAAI,CACpB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAC3E,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,CAAC;IAEO,OAAO,CAAC,MAAc;QAC5B,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAE5C,CAAC;QACd,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;YAC3B,OAAO;QACT,CAAC;QACD,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,WAAoC,CAAC,CAAC;IACxE,CAAC;CACF","sourcesContent":["/**\n * UIControlsSystem - upgrades `data-uix` controls in every loaded panel.\n *\n * Runs against ALL `PanelDocument` panels, not just windows: any IWSDK panel\n * gains steppers, toggles, expandable labels and log views by markup alone.\n */\nimport { PanelDocument, UIKitDocument, createSystem, type Entity } from '@iwsdk/core';\nimport type { UixElement } from '@realitycollective/webxr-uiextensions';\nimport { upgradePanel } from '@realitycollective/webxr-uiextensions';\n\nexport class UIControlsSystem extends createSystem({\n panels: { required: [PanelDocument] },\n}) {\n override init(): void {\n this.cleanupFuncs.push(\n this.queries.panels.subscribe('qualify', (entity) => this.upgrade(entity)),\n );\n this.queries.panels.entities.forEach((entity) => this.upgrade(entity));\n }\n\n private upgrade(entity: Entity): void {\n const document = PanelDocument.data.document[entity.index] as\n | UIKitDocument\n | undefined;\n if (!document?.rootElement) {\n return;\n }\n upgradePanel(document, document.rootElement as unknown as UixElement);\n }\n}\n"]}
1
+ {"version":3,"file":"controls-system.js","sourceRoot":"","sources":["../../src/systems/controls-system.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAA8B,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,MAAM,OAAO,gBAAiB,SAAQ,YAAY,CAAC;IACjD,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,aAAa,CAAC,EAAE;CACtC,CAAC;IACS,IAAI;QACX,IAAI,CAAC,YAAY,CAAC,IAAI,CACpB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAC3E,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,CAAC;IAEO,OAAO,CAAC,MAAc;QAC5B,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAE5C,CAAC;QACd,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;YAC3B,OAAO;QACT,CAAC;QACD,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,WAAoC,CAAC,CAAC;IACxE,CAAC;CACF","sourcesContent":["/**\n * UIControlsSystem - upgrades `data-uix` controls in every loaded panel.\n *\n * Runs against ALL `PanelDocument` panels, not just windows: any IWSDK panel\n * gains steppers, toggles, expandable labels and log views by markup alone.\n */\nimport { PanelDocument, UIKitDocument, type Entity } from '@iwsdk/core';\nimport { createSystem } from '../create-system.js';\nimport type { UixElement } from '@realitycollective/webxr-uiextensions';\nimport { upgradePanel } from '@realitycollective/webxr-uiextensions';\n\nexport class UIControlsSystem extends createSystem({\n panels: { required: [PanelDocument] },\n}) {\n override init(): void {\n this.cleanupFuncs.push(\n this.queries.panels.subscribe('qualify', (entity) => this.upgrade(entity)),\n );\n this.queries.panels.entities.forEach((entity) => this.upgrade(entity));\n }\n\n private upgrade(entity: Entity): void {\n const document = PanelDocument.data.document[entity.index] as\n | UIKitDocument\n | undefined;\n if (!document?.rootElement) {\n return;\n }\n upgradePanel(document, document.rootElement as unknown as UixElement);\n }\n}\n"]}
@@ -106,7 +106,7 @@ declare const UIDockRegionSystem_base: import("elics").SystemConstructor<import(
106
106
  };
107
107
  }>)[];
108
108
  };
109
- }, World, import("@iwsdk/core").System<import("elics").SystemSchema, {
109
+ }, import("@iwsdk/core").World, import("@iwsdk/core").System<import("elics").SystemSchema, {
110
110
  regions: {
111
111
  required: import("elics").Component<{
112
112
  regionId: {
@@ -1,12 +1,4 @@
1
- /**
2
- * UIDockRegionSystem - keeps the region registry in sync with `UIDockRegion`
3
- * entities and lays docked windows out in their region's slots each frame.
4
- *
5
- * Regions are ordinary entities: give one a `Follower` and its docked
6
- * windows become a body-locked toolbar; leave it static for a world-locked
7
- * console wall.
8
- */
9
- import { createSystem } from '@iwsdk/core';
1
+ import { createSystem } from '../create-system.js';
10
2
  import { Quaternion, Vector3 } from 'three';
11
3
  import { UIDockRegion, UIDockedTo, UIWindow } from '../components.js';
12
4
  import { DockMode } from '@realitycollective/webxr-uiextensions';
@@ -1 +1 @@
1
- {"version":3,"file":"dock-region-system.js","sourceRoot":"","sources":["../../src/systems/dock-region-system.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB,MAAM,OAAO,kBAAmB,SAAQ,YAAY,CAAC;IACnD,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC,EAAE;IACrC,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE;CAC7C,CAAC;IACQ,QAAQ,CAAkB;IAC1B,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,YAAY,GAAG,IAAI,OAAO,EAAE,CAAC;IAC7B,gBAAgB,GAAG,IAAI,UAAU,EAAE,CAAC;IAEnC,IAAI;QACX,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,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,CAAC;QACnE,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3D,yEAAyE;YACzE,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YACnC,OAAO;QACT,CAAC;QACD,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACzC,CAAC;QAAC,MAAM,CAAC;YACP,mCAAmC;YACnC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YACnC,OAAO;QACT,CAAC;QACD,yEAAyE;QACzE,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC;YACnE,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,MAAc;QACjC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAW,CAAC;QACjE,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * UIDockRegionSystem - keeps the region registry in sync with `UIDockRegion`\n * entities and lays docked windows out in their region's slots each frame.\n *\n * Regions are ordinary entities: give one a `Follower` and its docked\n * windows become a body-locked toolbar; leave it static for a world-locked\n * console wall.\n */\nimport { createSystem, type Entity } from '@iwsdk/core';\nimport { Quaternion, Vector3 } from 'three';\nimport { UIDockRegion, UIDockedTo, UIWindow } from '../components.js';\nimport { DockMode } from '@realitycollective/webxr-uiextensions';\nimport type { RegionDefinition, RegionFlow } from '@realitycollective/webxr-uiextensions';\nimport { regionRegistryFor } from '../region-registry-store.js';\nimport type { RegionRegistry } from '@realitycollective/webxr-uiextensions';\n\nlet autoRegionId = 0;\n\nexport class UIDockRegionSystem extends createSystem({\n regions: { required: [UIDockRegion] },\n docked: { required: [UIWindow, UIDockedTo] },\n}) {\n private registry!: RegionRegistry;\n private regionEntities = new Map<string, Entity>();\n private slotPosition = new Vector3();\n private regionQuaternion = new Quaternion();\n\n override init(): void {\n this.registry = regionRegistryFor(this.world);\n\n this.cleanupFuncs.push(\n this.queries.regions.subscribe('qualify', (entity) => this.addRegion(entity)),\n this.queries.regions.subscribe('disqualify', (entity) => this.removeRegion(entity)),\n this.queries.docked.subscribe('qualify', (entity) => this.dockWindow(entity)),\n this.queries.docked.subscribe('disqualify', (entity) => this.undockWindow(entity)),\n );\n this.queries.regions.entities.forEach((entity) => this.addRegion(entity));\n this.queries.docked.entities.forEach((entity) => this.dockWindow(entity));\n }\n\n override update(): void {\n for (const entity of this.queries.docked.entities) {\n const windowId = entity.getValue(UIWindow, 'windowId') as string;\n const offset = this.registry.offsetOf(windowId);\n const regionId = this.registry.regionOf(windowId);\n const regionEntity = regionId === undefined ? undefined : this.regionEntities.get(regionId);\n const regionObject = regionEntity?.object3D;\n const object = entity.object3D;\n if (!offset || !regionObject || !object || !object.parent) {\n continue;\n }\n // Slot offset is region-local; express it in the window's parent space.\n this.slotPosition.set(offset[0], offset[1], offset[2]);\n regionObject.localToWorld(this.slotPosition);\n object.parent.worldToLocal(this.slotPosition);\n object.position.copy(this.slotPosition);\n regionObject.getWorldQuaternion(this.regionQuaternion);\n object.quaternion.copy(this.regionQuaternion);\n }\n }\n\n private addRegion(entity: Entity): void {\n let id = entity.getValue(UIDockRegion, 'regionId') as string;\n if (!id) {\n id = `uix-region-${autoRegionId++}`;\n entity.setValue(UIDockRegion, 'regionId', id);\n }\n if (this.registry.get(id)) {\n return;\n }\n const definition: Partial<RegionDefinition> = {\n flow: entity.getValue(UIDockRegion, 'flow') as RegionFlow,\n pitch: entity.getValue(UIDockRegion, 'pitch') as number,\n columns: Math.max(1, Math.round(entity.getValue(UIDockRegion, 'columns') as number)),\n capacity: Math.max(0, Math.round(entity.getValue(UIDockRegion, 'capacity') as number)),\n snapRadius: entity.getValue(UIDockRegion, 'snapRadius') as number,\n };\n this.registry.register(id, definition);\n this.regionEntities.set(id, entity);\n }\n\n private removeRegion(entity: Entity): void {\n const id = entity.getValue(UIDockRegion, 'regionId') as string;\n if (id && this.regionEntities.get(id) === entity) {\n this.registry.unregister(id);\n this.regionEntities.delete(id);\n }\n }\n\n private dockWindow(entity: Entity): void {\n const windowId = entity.getValue(UIWindow, 'windowId') as string;\n const regionId = entity.getValue(UIDockedTo, 'regionId') as string;\n if (!windowId || !regionId || !this.registry.get(regionId)) {\n // Unknown region (or the window has no id yet) - docking is meaningless.\n entity.removeComponent(UIDockedTo);\n return;\n }\n try {\n this.registry.dock(windowId, regionId);\n } catch {\n // Region is full: reject the dock.\n entity.removeComponent(UIDockedTo);\n return;\n }\n // Docked windows are world-locked by definition (the region may follow).\n if (entity.getValue(UIWindow, 'dockMode') !== DockMode.WorldLocked) {\n entity.setValue(UIWindow, 'dockMode', DockMode.WorldLocked);\n }\n }\n\n private undockWindow(entity: Entity): void {\n const windowId = entity.getValue(UIWindow, 'windowId') as string;\n if (windowId) {\n this.registry.undock(windowId);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"dock-region-system.js","sourceRoot":"","sources":["../../src/systems/dock-region-system.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,IAAI,YAAY,GAAG,CAAC,CA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,EAAE,CAAC;YACb,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * UIDockRegionSystem - keeps the region registry in sync with `UIDockRegion`\n * entities and lays docked windows out in their region's slots each frame.\n *\n * Regions are ordinary entities: give one a `Follower` and its docked\n * windows become a body-locked toolbar; leave it static for a world-locked\n * console wall.\n */\nimport type { Entity } from '@iwsdk/core';\nimport { createSystem } from '../create-system.js';\nimport { Quaternion, Vector3 } from 'three';\nimport { UIDockRegion, UIDockedTo, UIWindow } from '../components.js';\nimport { DockMode } from '@realitycollective/webxr-uiextensions';\nimport type { RegionDefinition, RegionFlow } from '@realitycollective/webxr-uiextensions';\nimport { regionRegistryFor } from '../region-registry-store.js';\nimport type { RegionRegistry } from '@realitycollective/webxr-uiextensions';\n\nlet autoRegionId = 0;\n\nexport class UIDockRegionSystem extends createSystem({\n regions: { required: [UIDockRegion] },\n docked: { required: [UIWindow, UIDockedTo] },\n}) {\n private registry!: RegionRegistry;\n private regionEntities = new Map<string, Entity>();\n private slotPosition = new Vector3();\n private regionQuaternion = new Quaternion();\n\n override init(): void {\n this.registry = regionRegistryFor(this.world);\n\n this.cleanupFuncs.push(\n this.queries.regions.subscribe('qualify', (entity) => this.addRegion(entity)),\n this.queries.regions.subscribe('disqualify', (entity) => this.removeRegion(entity)),\n this.queries.docked.subscribe('qualify', (entity) => this.dockWindow(entity)),\n this.queries.docked.subscribe('disqualify', (entity) => this.undockWindow(entity)),\n );\n this.queries.regions.entities.forEach((entity) => this.addRegion(entity));\n this.queries.docked.entities.forEach((entity) => this.dockWindow(entity));\n }\n\n override update(): void {\n for (const entity of this.queries.docked.entities) {\n const windowId = entity.getValue(UIWindow, 'windowId') as string;\n const offset = this.registry.offsetOf(windowId);\n const regionId = this.registry.regionOf(windowId);\n const regionEntity = regionId === undefined ? undefined : this.regionEntities.get(regionId);\n const regionObject = regionEntity?.object3D;\n const object = entity.object3D;\n if (!offset || !regionObject || !object || !object.parent) {\n continue;\n }\n // Slot offset is region-local; express it in the window's parent space.\n this.slotPosition.set(offset[0], offset[1], offset[2]);\n regionObject.localToWorld(this.slotPosition);\n object.parent.worldToLocal(this.slotPosition);\n object.position.copy(this.slotPosition);\n regionObject.getWorldQuaternion(this.regionQuaternion);\n object.quaternion.copy(this.regionQuaternion);\n }\n }\n\n private addRegion(entity: Entity): void {\n let id = entity.getValue(UIDockRegion, 'regionId') as string;\n if (!id) {\n id = `uix-region-${autoRegionId++}`;\n entity.setValue(UIDockRegion, 'regionId', id);\n }\n if (this.registry.get(id)) {\n return;\n }\n const definition: Partial<RegionDefinition> = {\n flow: entity.getValue(UIDockRegion, 'flow') as RegionFlow,\n pitch: entity.getValue(UIDockRegion, 'pitch') as number,\n columns: Math.max(1, Math.round(entity.getValue(UIDockRegion, 'columns') as number)),\n capacity: Math.max(0, Math.round(entity.getValue(UIDockRegion, 'capacity') as number)),\n snapRadius: entity.getValue(UIDockRegion, 'snapRadius') as number,\n };\n this.registry.register(id, definition);\n this.regionEntities.set(id, entity);\n }\n\n private removeRegion(entity: Entity): void {\n const id = entity.getValue(UIDockRegion, 'regionId') as string;\n if (id && this.regionEntities.get(id) === entity) {\n this.registry.unregister(id);\n this.regionEntities.delete(id);\n }\n }\n\n private dockWindow(entity: Entity): void {\n const windowId = entity.getValue(UIWindow, 'windowId') as string;\n const regionId = entity.getValue(UIDockedTo, 'regionId') as string;\n if (!windowId || !regionId || !this.registry.get(regionId)) {\n // Unknown region (or the window has no id yet) - docking is meaningless.\n entity.removeComponent(UIDockedTo);\n return;\n }\n try {\n this.registry.dock(windowId, regionId);\n } catch {\n // Region is full: reject the dock.\n entity.removeComponent(UIDockedTo);\n return;\n }\n // Docked windows are world-locked by definition (the region may follow).\n if (entity.getValue(UIWindow, 'dockMode') !== DockMode.WorldLocked) {\n entity.setValue(UIWindow, 'dockMode', DockMode.WorldLocked);\n }\n }\n\n private undockWindow(entity: Entity): void {\n const windowId = entity.getValue(UIWindow, 'windowId') as string;\n if (windowId) {\n this.registry.undock(windowId);\n }\n }\n}\n"]}
@@ -93,7 +93,7 @@ declare const UIDockSystem_base: import("elics").SystemConstructor<import("elics
93
93
  };
94
94
  }>)[];
95
95
  };
96
- }, World, import("@iwsdk/core").System<import("elics").SystemSchema, {
96
+ }, import("@iwsdk/core").World, import("@iwsdk/core").System<import("elics").SystemSchema, {
97
97
  windows: {
98
98
  required: (import("elics").Component<{
99
99
  windowId: {
@@ -5,7 +5,8 @@
5
5
  * `Follower` / `ScreenSpace` components (reuse, not recreation); this system
6
6
  * only plans and applies transitions with the pure dock state machine.
7
7
  */
8
- import { Follower, FollowBehavior, ScreenSpace, createSystem, } from '@iwsdk/core';
8
+ import { Follower, FollowBehavior, ScreenSpace, } from '@iwsdk/core';
9
+ import { createSystem } from '../create-system.js';
9
10
  import { Euler, Quaternion, Vector3 } from 'three';
10
11
  import { UIWindow, UIWindowState } from '../components.js';
11
12
  import { DockMode, isDockMode, planTransition, recipeFor, } from '@realitycollective/webxr-uiextensions';
@@ -1 +1 @@
1
- {"version":3,"file":"dock-system.js","sourceRoot":"","sources":["../../src/systems/dock-system.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,QAAQ,EACR,cAAc,EACd,WAAW,EACX,YAAY,GAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,QAAQ,EACR,UAAU,EACV,cAAc,EACd,SAAS,GAEV,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,MAAM,OAAO,YAAa,SAAQ,YAAY,CAAC;IAC7C,OAAO,EAA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MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE;YAC5B,gEAAgE;YAChE,iEAAiE;YACjE,uEAAuE;YACvE,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,cAAc,EAAE,MAAM;YACtB,QAAQ,EAAE,cAAc,CAAC,MAAM;YAC/B,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAW;YACzD,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAW;SAClE,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/**\n * UIDockSystem - realises dock modes by composing IWSDK components.\n *\n * `body-follow` and `head-locked` are implemented with the IWSDK's own\n * `Follower` / `ScreenSpace` components (reuse, not recreation); this system\n * only plans and applies transitions with the pure dock state machine.\n */\nimport {\n Follower,\n FollowBehavior,\n ScreenSpace,\n createSystem,\n type Entity,\n} from '@iwsdk/core';\nimport { Euler, Quaternion, Vector3 } from 'three';\nimport { UIWindow, UIWindowState } from '../components.js';\nimport {\n DockMode,\n isDockMode,\n planTransition,\n recipeFor,\n type DockModeValue,\n} from '@realitycollective/webxr-uiextensions';\nimport { faceViewerYaw } from '@realitycollective/webxr-uiextensions';\nimport { windowManagerFor } from '../manager-registry.js';\nimport type { WindowManager } from '@realitycollective/webxr-uiextensions';\n\nexport class UIDockSystem extends createSystem({\n windows: { required: [UIWindow, UIWindowState] },\n}) {\n private manager!: WindowManager;\n private windowPosition = new Vector3();\n private viewerPosition = new Vector3();\n\n override init(): void {\n this.manager = windowManagerFor(this.world);\n }\n\n override update(): void {\n for (const entity of this.queries.windows.entities) {\n const requested = entity.getValue(UIWindow, 'dockMode') as DockModeValue;\n const applied = entity.getValue(UIWindowState, 'appliedDockMode') as string;\n if (!isDockMode(requested) || applied === requested) {\n continue;\n }\n this.apply(entity, applied, requested);\n }\n }\n\n private apply(entity: Entity, applied: string, requested: DockModeValue): void {\n if (isDockMode(applied)) {\n const plan = planTransition(applied, requested);\n if (!plan) {\n return;\n }\n if (plan.removeFollower && entity.hasComponent(Follower)) {\n entity.removeComponent(Follower);\n }\n if (plan.removeFollower && requested === DockMode.WorldLocked) {\n // Pinning in place: leave the window facing the user at the spot it\n // was pinned, instead of freezing whatever lagging follow rotation\n // it happened to have this frame.\n this.faceViewer(entity);\n }\n if (plan.removeScreenSpace && entity.hasComponent(ScreenSpace)) {\n entity.removeComponent(ScreenSpace);\n }\n if (plan.addFollower) {\n // Unpinning: keep the window where the user left it, expressed\n // relative to their head, instead of snapping to the default offset.\n this.addFollower(entity, { fromCurrentPose: true });\n }\n if (plan.addScreenSpace) {\n entity.addComponent(ScreenSpace);\n }\n if (plan.snap && entity.hasComponent(Follower)) {\n entity.setValue(Follower, 'needsPositionSync', true);\n }\n } else {\n // First application after adoption: build the requested recipe from\n // scratch (the entity carries no dock components we own yet).\n const recipe = recipeFor(requested);\n if (recipe.follower && !entity.hasComponent(Follower)) {\n this.addFollower(entity);\n }\n if (!recipe.follower && entity.hasComponent(Follower)) {\n entity.removeComponent(Follower);\n }\n if (recipe.screenSpace && !entity.hasComponent(ScreenSpace)) {\n entity.addComponent(ScreenSpace);\n }\n if (!recipe.screenSpace && entity.hasComponent(ScreenSpace)) {\n entity.removeComponent(ScreenSpace);\n }\n }\n\n entity.setValue(UIWindowState, 'appliedDockMode', requested);\n\n const id = entity.getValue(UIWindow, 'windowId') as string;\n if (id && this.manager.has(id)) {\n this.manager.setDockMode(id, requested);\n }\n }\n\n private faceViewer(entity: Entity): void {\n const object = entity.object3D;\n if (!object) {\n return;\n }\n object.getWorldPosition(this.windowPosition);\n this.camera.getWorldPosition(this.viewerPosition);\n const yaw = faceViewerYaw(\n [this.windowPosition.x, this.windowPosition.y, this.windowPosition.z],\n [this.viewerPosition.x, this.viewerPosition.y, this.viewerPosition.z],\n object.rotation.y,\n );\n object.rotation.set(0, yaw, 0);\n }\n\n private offsetHelper = new Vector3();\n private yawQuaternion = new Quaternion();\n private yawEuler = new Euler();\n\n private addFollower(entity: Entity, options: { fromCurrentPose?: boolean } = {}): void {\n const configured = entity.getVectorView(UIWindow, 'followOffset');\n let offset: [number, number, number] = [\n configured[0] ?? 0,\n configured[1] ?? 0,\n configured[2] ?? 0,\n ];\n\n const object = entity.object3D;\n if (options.fromCurrentPose && object) {\n // Current window position in the viewer's yaw-local frame (matching\n // how Follower's PivotY applies offsets), so following resumes from\n // the same bearing and distance the window was unpinned at.\n object.getWorldPosition(this.offsetHelper);\n this.camera.getWorldPosition(this.windowPosition);\n this.camera.getWorldQuaternion(this.yawQuaternion);\n this.yawEuler.setFromQuaternion(this.yawQuaternion, 'YXZ');\n this.yawEuler.x = 0;\n this.yawEuler.z = 0;\n this.yawQuaternion.setFromEuler(this.yawEuler).conjugate();\n this.offsetHelper.sub(this.windowPosition).applyQuaternion(this.yawQuaternion);\n // Degenerate (window at the viewer): keep the configured offset.\n if (this.offsetHelper.lengthSq() > 0.01) {\n offset = [this.offsetHelper.x, this.offsetHelper.y, this.offsetHelper.z];\n }\n }\n\n entity.addComponent(Follower, {\n // The camera, not player.head: three.js syncs the camera to the\n // headset pose in-session, while the head rig sits at the origin\n // outside XR (desktop) - following it would park windows at the floor.\n target: this.camera,\n offsetPosition: offset,\n behavior: FollowBehavior.PivotY,\n speed: entity.getValue(UIWindow, 'followSpeed') as number,\n tolerance: entity.getValue(UIWindow, 'followTolerance') as number,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"dock-system.js","sourceRoot":"","sources":["../../src/systems/dock-system.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,QAAQ,EACR,cAAc,EACd,WAAW,GAEZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,qB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C,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;YACpB,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;YACpB,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC;YAC3D,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC/E,iEAAiE;YACjE,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC;gBACxC,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE;YAC5B,gEAAgE;YAChE,iEAAiE;YACjE,uEAAuE;YACvE,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,cAAc,EAAE,MAAM;YACtB,QAAQ,EAAE,cAAc,CAAC,MAAM;YAC/B,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAW;YACzD,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAW;SAClE,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/**\n * UIDockSystem - realises dock modes by composing IWSDK components.\n *\n * `body-follow` and `head-locked` are implemented with the IWSDK's own\n * `Follower` / `ScreenSpace` components (reuse, not recreation); this system\n * only plans and applies transitions with the pure dock state machine.\n */\nimport {\n Follower,\n FollowBehavior,\n ScreenSpace,\n type Entity,\n} from '@iwsdk/core';\nimport { createSystem } from '../create-system.js';\nimport { Euler, Quaternion, Vector3 } from 'three';\nimport { UIWindow, UIWindowState } from '../components.js';\nimport {\n DockMode,\n isDockMode,\n planTransition,\n recipeFor,\n type DockModeValue,\n} from '@realitycollective/webxr-uiextensions';\nimport { faceViewerYaw } from '@realitycollective/webxr-uiextensions';\nimport { windowManagerFor } from '../manager-registry.js';\nimport type { WindowManager } from '@realitycollective/webxr-uiextensions';\n\nexport class UIDockSystem extends createSystem({\n windows: { required: [UIWindow, UIWindowState] },\n}) {\n private manager!: WindowManager;\n private windowPosition = new Vector3();\n private viewerPosition = new Vector3();\n\n override init(): void {\n this.manager = windowManagerFor(this.world);\n }\n\n override update(): void {\n for (const entity of this.queries.windows.entities) {\n const requested = entity.getValue(UIWindow, 'dockMode') as DockModeValue;\n const applied = entity.getValue(UIWindowState, 'appliedDockMode') as string;\n if (!isDockMode(requested) || applied === requested) {\n continue;\n }\n this.apply(entity, applied, requested);\n }\n }\n\n private apply(entity: Entity, applied: string, requested: DockModeValue): void {\n if (isDockMode(applied)) {\n const plan = planTransition(applied, requested);\n if (!plan) {\n return;\n }\n if (plan.removeFollower && entity.hasComponent(Follower)) {\n entity.removeComponent(Follower);\n }\n if (plan.removeFollower && requested === DockMode.WorldLocked) {\n // Pinning in place: leave the window facing the user at the spot it\n // was pinned, instead of freezing whatever lagging follow rotation\n // it happened to have this frame.\n this.faceViewer(entity);\n }\n if (plan.removeScreenSpace && entity.hasComponent(ScreenSpace)) {\n entity.removeComponent(ScreenSpace);\n }\n if (plan.addFollower) {\n // Unpinning: keep the window where the user left it, expressed\n // relative to their head, instead of snapping to the default offset.\n this.addFollower(entity, { fromCurrentPose: true });\n }\n if (plan.addScreenSpace) {\n entity.addComponent(ScreenSpace);\n }\n if (plan.snap && entity.hasComponent(Follower)) {\n entity.setValue(Follower, 'needsPositionSync', true);\n }\n } else {\n // First application after adoption: build the requested recipe from\n // scratch (the entity carries no dock components we own yet).\n const recipe = recipeFor(requested);\n if (recipe.follower && !entity.hasComponent(Follower)) {\n this.addFollower(entity);\n }\n if (!recipe.follower && entity.hasComponent(Follower)) {\n entity.removeComponent(Follower);\n }\n if (recipe.screenSpace && !entity.hasComponent(ScreenSpace)) {\n entity.addComponent(ScreenSpace);\n }\n if (!recipe.screenSpace && entity.hasComponent(ScreenSpace)) {\n entity.removeComponent(ScreenSpace);\n }\n }\n\n entity.setValue(UIWindowState, 'appliedDockMode', requested);\n\n const id = entity.getValue(UIWindow, 'windowId') as string;\n if (id && this.manager.has(id)) {\n this.manager.setDockMode(id, requested);\n }\n }\n\n private faceViewer(entity: Entity): void {\n const object = entity.object3D;\n if (!object) {\n return;\n }\n object.getWorldPosition(this.windowPosition);\n this.camera.getWorldPosition(this.viewerPosition);\n const yaw = faceViewerYaw(\n [this.windowPosition.x, this.windowPosition.y, this.windowPosition.z],\n [this.viewerPosition.x, this.viewerPosition.y, this.viewerPosition.z],\n object.rotation.y,\n );\n object.rotation.set(0, yaw, 0);\n }\n\n private offsetHelper = new Vector3();\n private yawQuaternion = new Quaternion();\n private yawEuler = new Euler();\n\n private addFollower(entity: Entity, options: { fromCurrentPose?: boolean } = {}): void {\n const configured = entity.getVectorView(UIWindow, 'followOffset');\n let offset: [number, number, number] = [\n configured[0] ?? 0,\n configured[1] ?? 0,\n configured[2] ?? 0,\n ];\n\n const object = entity.object3D;\n if (options.fromCurrentPose && object) {\n // Current window position in the viewer's yaw-local frame (matching\n // how Follower's PivotY applies offsets), so following resumes from\n // the same bearing and distance the window was unpinned at.\n object.getWorldPosition(this.offsetHelper);\n this.camera.getWorldPosition(this.windowPosition);\n this.camera.getWorldQuaternion(this.yawQuaternion);\n this.yawEuler.setFromQuaternion(this.yawQuaternion, 'YXZ');\n this.yawEuler.x = 0;\n this.yawEuler.z = 0;\n this.yawQuaternion.setFromEuler(this.yawEuler).conjugate();\n this.offsetHelper.sub(this.windowPosition).applyQuaternion(this.yawQuaternion);\n // Degenerate (window at the viewer): keep the configured offset.\n if (this.offsetHelper.lengthSq() > 0.01) {\n offset = [this.offsetHelper.x, this.offsetHelper.y, this.offsetHelper.z];\n }\n }\n\n entity.addComponent(Follower, {\n // The camera, not player.head: three.js syncs the camera to the\n // headset pose in-session, while the head rig sits at the origin\n // outside XR (desktop) - following it would park windows at the floor.\n target: this.camera,\n offsetPosition: offset,\n behavior: FollowBehavior.PivotY,\n speed: entity.getValue(UIWindow, 'followSpeed') as number,\n tolerance: entity.getValue(UIWindow, 'followTolerance') as number,\n });\n }\n}\n"]}
@@ -131,7 +131,7 @@ declare const UIDragSystem_base: import("elics").SystemConstructor<import("elics
131
131
  };
132
132
  }>[];
133
133
  };
134
- }, World, import("@iwsdk/core").System<import("elics").SystemSchema, {
134
+ }, import("@iwsdk/core").World, import("@iwsdk/core").System<import("elics").SystemSchema, {
135
135
  windows: {
136
136
  required: (import("elics").Component<{
137
137
  windowId: {
@@ -12,7 +12,8 @@
12
12
  * switches to `world-locked`; on release near a region it docks there.
13
13
  */
14
14
  import { HandleStore } from '@pmndrs/handle';
15
- import { PanelDocument, createSystem, } from '@iwsdk/core';
15
+ import { PanelDocument, } from '@iwsdk/core';
16
+ import { createSystem } from '../create-system.js';
16
17
  import { Vector3 } from 'three';
17
18
  import { UIDockRegion, UIDockedTo, UIWindow, UIWindowState } from '../components.js';
18
19
  import { WINDOW_CHROME_IDS } from '@realitycollective/webxr-uiextensions';
@@ -1 +1 @@
1
- {"version":3,"file":"drag-system.js","sourceRoot":"","sources":["../../src/systems/drag-system.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,aAAa,EAEb,YAAY,GAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAiB,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EA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AQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * UIDragSystem - drag windows by the title bar.\n *\n * Reuses `@pmndrs/handle` (the exact library behind the IWSDK's grab\n * systems): a `HandleStore` targets the window entity's object while being\n * *bound* to the title-bar uikit element, so grabbing the title bar with the\n * ray (or a pinch) moves the whole window with the same feel as native IWSDK\n * grabbing. The system pumps its own stores, so it works even when the app\n * doesn't enable `features.grabbing`.\n *\n * Dragging implies placing: on grab the window leaves any dock region and\n * switches to `world-locked`; on release near a region it docks there.\n */\nimport { HandleStore } from '@pmndrs/handle';\nimport {\n PanelDocument,\n UIKitDocument,\n createSystem,\n type Entity,\n} from '@iwsdk/core';\nimport { Vector3, type Object3D } from 'three';\nimport { UIDockRegion, UIDockedTo, UIWindow, UIWindowState } from '../components.js';\nimport { WINDOW_CHROME_IDS } from '@realitycollective/webxr-uiextensions';\nimport { DockMode } from '@realitycollective/webxr-uiextensions';\nimport { faceViewerYaw } from '@realitycollective/webxr-uiextensions';\nimport { HoldToDrag } from '@realitycollective/webxr-uiextensions';\nimport type { Vec3 } from '@realitycollective/webxr-uiextensions';\nimport { regionRegistryFor } from '../region-registry-store.js';\nimport { windowManagerFor } from '../manager-registry.js';\n\ninterface DragState {\n store: HandleStore<unknown>;\n hold: HoldToDrag;\n}\n\nexport class UIDragSystem extends createSystem({\n windows: { required: [UIWindow, UIWindowState, PanelDocument] },\n regions: { required: [UIDockRegion] },\n}) {\n private states = new Map<Entity, DragState>();\n private worldPosition = new Vector3();\n private viewerPosition = new Vector3();\n\n override init(): void {\n this.cleanupFuncs.push(\n this.queries.windows.subscribe('qualify', (entity) => {\n this.attach(entity);\n }),\n this.queries.windows.subscribe('disqualify', (entity) => {\n this.detach(entity);\n }),\n );\n this.queries.windows.entities.forEach((entity) => this.attach(entity));\n }\n\n override update(delta: number): void {\n for (const [entity, state] of this.states) {\n const held = state.store.inputState.size > 0;\n const { phase, began, ended } = state.hold.update(held, delta);\n\n if (began) {\n this.onDragStart(entity);\n }\n if (phase === 'dragging') {\n // The store only runs while an actual drag is in progress: presses\n // shorter than the hold delay never move the window (they're\n // clicks), and skipping the release-frame update stops the handle\n // from restoring its grab-time rotation over our billboard yaw.\n state.store.update(delta);\n this.whileDragging(entity);\n }\n if (ended) {\n this.onDragEnd(entity);\n }\n }\n }\n\n private attach(entity: Entity): void {\n if (this.states.has(entity) || !entity.getValue(UIWindow, 'movable')) {\n return;\n }\n const document = PanelDocument.data.document[entity.index] as\n | UIKitDocument\n | undefined;\n const titlebar = document?.getElementById(WINDOW_CHROME_IDS.titlebar);\n const object = entity.object3D;\n if (!titlebar || !object) {\n return;\n }\n const store = new HandleStore(object, () => ({\n translate: true as const,\n rotate: false as const,\n scale: false as const,\n multitouch: false,\n projectRays: false,\n }));\n // The title-bar uikit element is an Object3D - bind it as the grab\n // surface while the store's target stays the window root.\n store.bind(titlebar as unknown as Object3D<never>);\n this.states.set(entity, {\n store,\n hold: new HoldToDrag(Math.max(0, entity.getValue(UIWindow, 'dragDelay') as number)),\n });\n }\n\n private detach(entity: Entity): void {\n const state = this.states.get(entity);\n if (!state) {\n return;\n }\n try {\n state.store.cancel();\n } catch {\n // Handle stores throw when cancelled with no active input; ignore.\n }\n this.states.delete(entity);\n }\n\n private onDragStart(entity: Entity): void {\n const id = entity.getValue(UIWindow, 'windowId') as string;\n const manager = windowManagerFor(this.world);\n if (id && manager.has(id)) {\n manager.focus(id);\n // Mark dragging BEFORE the dock change so the pin label reads \"PIN\"\n // (loose in hand) throughout the drag, not \"UNPIN\".\n manager.setDragging(id, true);\n }\n // Grabbing takes the window out of any region and out of follow mode -\n // the user is placing it by hand.\n if (entity.hasComponent(UIDockedTo)) {\n entity.removeComponent(UIDockedTo);\n }\n if (entity.getValue(UIWindow, 'dockMode') !== DockMode.WorldLocked) {\n entity.setValue(UIWindow, 'dockMode', DockMode.WorldLocked);\n }\n }\n\n private whileDragging(entity: Entity): void {\n if (!entity.getValue(UIWindow, 'billboardWhileDragging')) {\n return;\n }\n const object = entity.object3D;\n if (!object) {\n return;\n }\n object.getWorldPosition(this.worldPosition);\n this.camera.getWorldPosition(this.viewerPosition);\n const yaw = faceViewerYaw(\n [this.worldPosition.x, this.worldPosition.y, this.worldPosition.z],\n [this.viewerPosition.x, this.viewerPosition.y, this.viewerPosition.z],\n object.rotation.y,\n );\n object.rotation.set(0, yaw, 0);\n }\n\n private onDragEnd(entity: Entity): void {\n const id = entity.getValue(UIWindow, 'windowId') as string;\n const manager = windowManagerFor(this.world);\n if (id && manager.has(id)) {\n manager.setDragging(id, false); // released → placed → label \"UNPIN\"\n }\n // Settle facing the viewer at the drop spot - the window keeps the\n // orientation it was dragged in, not its pre-drag rotation.\n this.whileDragging(entity);\n const object = entity.object3D;\n if (!object) {\n return;\n }\n object.getWorldPosition(this.worldPosition);\n const dropPoint: Vec3 = [\n this.worldPosition.x,\n this.worldPosition.y,\n this.worldPosition.z,\n ];\n\n const registry = regionRegistryFor(this.world);\n const origins = new Map<string, Vec3>();\n this.queries.regions.entities.forEach((regionEntity) => {\n const regionId = regionEntity.getValue(UIDockRegion, 'regionId') as string;\n const regionObject = regionEntity.object3D;\n if (!regionId || !regionObject) {\n return;\n }\n regionObject.getWorldPosition(this.viewerPosition);\n origins.set(regionId, [\n this.viewerPosition.x,\n this.viewerPosition.y,\n this.viewerPosition.z,\n ]);\n });\n\n const captured = registry.capture(dropPoint, origins);\n if (captured !== undefined) {\n entity.addComponent(UIDockedTo, { regionId: captured });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"drag-system.js","sourceRoot":"","sources":["../../src/systems/drag-system.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,E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AM,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC;YAC3C,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE,CAAC;gBAC/B,OAAO;YACT,CAAC;YACD,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE;gBACpB,IAAI,CAAC,cAAc,CAAC,CAAC;gBACrB,IAAI,CAAC,cAAc,CAAC,CAAC;gBACrB,IAAI,CAAC,cAAc,CAAC,CAAC;aACtB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * UIDragSystem - drag windows by the title bar.\n *\n * Reuses `@pmndrs/handle` (the exact library behind the IWSDK's grab\n * systems): a `HandleStore` targets the window entity's object while being\n * *bound* to the title-bar uikit element, so grabbing the title bar with the\n * ray (or a pinch) moves the whole window with the same feel as native IWSDK\n * grabbing. The system pumps its own stores, so it works even when the app\n * doesn't enable `features.grabbing`.\n *\n * Dragging implies placing: on grab the window leaves any dock region and\n * switches to `world-locked`; on release near a region it docks there.\n */\nimport { HandleStore } from '@pmndrs/handle';\nimport {\n PanelDocument,\n UIKitDocument,\n type Entity,\n} from '@iwsdk/core';\nimport { createSystem } from '../create-system.js';\nimport { Vector3, type Object3D } from 'three';\nimport { UIDockRegion, UIDockedTo, UIWindow, UIWindowState } from '../components.js';\nimport { WINDOW_CHROME_IDS } from '@realitycollective/webxr-uiextensions';\nimport { DockMode } from '@realitycollective/webxr-uiextensions';\nimport { faceViewerYaw } from '@realitycollective/webxr-uiextensions';\nimport { HoldToDrag } from '@realitycollective/webxr-uiextensions';\nimport type { Vec3 } from '@realitycollective/webxr-uiextensions';\nimport { regionRegistryFor } from '../region-registry-store.js';\nimport { windowManagerFor } from '../manager-registry.js';\n\ninterface DragState {\n store: HandleStore<unknown>;\n hold: HoldToDrag;\n}\n\nexport class UIDragSystem extends createSystem({\n windows: { required: [UIWindow, UIWindowState, PanelDocument] },\n regions: { required: [UIDockRegion] },\n}) {\n private states = new Map<Entity, DragState>();\n private worldPosition = new Vector3();\n private viewerPosition = new Vector3();\n\n override init(): void {\n this.cleanupFuncs.push(\n this.queries.windows.subscribe('qualify', (entity) => {\n this.attach(entity);\n }),\n this.queries.windows.subscribe('disqualify', (entity) => {\n this.detach(entity);\n }),\n );\n this.queries.windows.entities.forEach((entity) => this.attach(entity));\n }\n\n override update(delta: number): void {\n for (const [entity, state] of this.states) {\n const held = state.store.inputState.size > 0;\n const { phase, began, ended } = state.hold.update(held, delta);\n\n if (began) {\n this.onDragStart(entity);\n }\n if (phase === 'dragging') {\n // The store only runs while an actual drag is in progress: presses\n // shorter than the hold delay never move the window (they're\n // clicks), and skipping the release-frame update stops the handle\n // from restoring its grab-time rotation over our billboard yaw.\n state.store.update(delta);\n this.whileDragging(entity);\n }\n if (ended) {\n this.onDragEnd(entity);\n }\n }\n }\n\n private attach(entity: Entity): void {\n if (this.states.has(entity) || !entity.getValue(UIWindow, 'movable')) {\n return;\n }\n const document = PanelDocument.data.document[entity.index] as\n | UIKitDocument\n | undefined;\n const titlebar = document?.getElementById(WINDOW_CHROME_IDS.titlebar);\n const object = entity.object3D;\n if (!titlebar || !object) {\n return;\n }\n const store = new HandleStore(object, () => ({\n translate: true as const,\n rotate: false as const,\n scale: false as const,\n multitouch: false,\n projectRays: false,\n }));\n // The title-bar uikit element is an Object3D - bind it as the grab\n // surface while the store's target stays the window root.\n store.bind(titlebar as unknown as Object3D<never>);\n this.states.set(entity, {\n store,\n hold: new HoldToDrag(Math.max(0, entity.getValue(UIWindow, 'dragDelay') as number)),\n });\n }\n\n private detach(entity: Entity): void {\n const state = this.states.get(entity);\n if (!state) {\n return;\n }\n try {\n state.store.cancel();\n } catch {\n // Handle stores throw when cancelled with no active input; ignore.\n }\n this.states.delete(entity);\n }\n\n private onDragStart(entity: Entity): void {\n const id = entity.getValue(UIWindow, 'windowId') as string;\n const manager = windowManagerFor(this.world);\n if (id && manager.has(id)) {\n manager.focus(id);\n // Mark dragging BEFORE the dock change so the pin label reads \"PIN\"\n // (loose in hand) throughout the drag, not \"UNPIN\".\n manager.setDragging(id, true);\n }\n // Grabbing takes the window out of any region and out of follow mode -\n // the user is placing it by hand.\n if (entity.hasComponent(UIDockedTo)) {\n entity.removeComponent(UIDockedTo);\n }\n if (entity.getValue(UIWindow, 'dockMode') !== DockMode.WorldLocked) {\n entity.setValue(UIWindow, 'dockMode', DockMode.WorldLocked);\n }\n }\n\n private whileDragging(entity: Entity): void {\n if (!entity.getValue(UIWindow, 'billboardWhileDragging')) {\n return;\n }\n const object = entity.object3D;\n if (!object) {\n return;\n }\n object.getWorldPosition(this.worldPosition);\n this.camera.getWorldPosition(this.viewerPosition);\n const yaw = faceViewerYaw(\n [this.worldPosition.x, this.worldPosition.y, this.worldPosition.z],\n [this.viewerPosition.x, this.viewerPosition.y, this.viewerPosition.z],\n object.rotation.y,\n );\n object.rotation.set(0, yaw, 0);\n }\n\n private onDragEnd(entity: Entity): void {\n const id = entity.getValue(UIWindow, 'windowId') as string;\n const manager = windowManagerFor(this.world);\n if (id && manager.has(id)) {\n manager.setDragging(id, false); // released → placed → label \"UNPIN\"\n }\n // Settle facing the viewer at the drop spot - the window keeps the\n // orientation it was dragged in, not its pre-drag rotation.\n this.whileDragging(entity);\n const object = entity.object3D;\n if (!object) {\n return;\n }\n object.getWorldPosition(this.worldPosition);\n const dropPoint: Vec3 = [\n this.worldPosition.x,\n this.worldPosition.y,\n this.worldPosition.z,\n ];\n\n const registry = regionRegistryFor(this.world);\n const origins = new Map<string, Vec3>();\n this.queries.regions.entities.forEach((regionEntity) => {\n const regionId = regionEntity.getValue(UIDockRegion, 'regionId') as string;\n const regionObject = regionEntity.object3D;\n if (!regionId || !regionObject) {\n return;\n }\n regionObject.getWorldPosition(this.viewerPosition);\n origins.set(regionId, [\n this.viewerPosition.x,\n this.viewerPosition.y,\n this.viewerPosition.z,\n ]);\n });\n\n const captured = registry.capture(dropPoint, origins);\n if (captured !== undefined) {\n entity.addComponent(UIDockedTo, { regionId: captured });\n }\n }\n}\n"]}
@@ -212,7 +212,7 @@ declare const UIWindowSystem_base: import("elics").SystemConstructor<import("eli
212
212
  };
213
213
  }>)[];
214
214
  };
215
- }, World, import("@iwsdk/core").System<import("elics").SystemSchema, {
215
+ }, import("@iwsdk/core").World, import("@iwsdk/core").System<import("elics").SystemSchema, {
216
216
  pendingWindows: {
217
217
  required: (import("elics").Component<{
218
218
  windowId: {
@@ -6,7 +6,8 @@
6
6
  * `PanelUISystem`; this system only discovers the chrome elements by their
7
7
  * well-known ids and drives them.
8
8
  */
9
- import { PanelDocument, PanelUI, createSystem, } from '@iwsdk/core';
9
+ import { PanelDocument, PanelUI, } from '@iwsdk/core';
10
+ import { createSystem } from '../create-system.js';
10
11
  import { Vector3 } from 'three';
11
12
  import { UIDockedTo, UIWindow, UIWindowState } from '../components.js';
12
13
  import { WINDOW_CHROME_IDS } from '@realitycollective/webxr-uiextensions';
@@ -1 +1 @@
1
- {"version":3,"file":"window-system.js","sourceRoot":"","sources":["../../src/systems/window-system.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,aAAa,EACb,OAAO,EAEP,YAAY,GAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,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C;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;QAED,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,CAAC;IAEO,cAAc,CAAC,EAAU,EAAE,SAAkB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC9D,MAAM,OAAO,GAAG,QAAQ,EAAE,cAAc,CAAC,iBAAiB,CAAC,OAAO,CAErD,CAAC;QACd,OAAO,EAAE,aAAa,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC;IAEO,UAAU,CAAC,MAAc;QAC/B,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAA8B,CAAC;IAChF,CAAC;CACF","sourcesContent":["/**\n * UIWindowSystem - wires window chrome, keeps the `WindowManager` in sync\n * with entities, applies focus ordering and minimize state.\n *\n * Reuse over recreation: the panel itself is loaded/rendered by the IWSDK's\n * `PanelUISystem`; this system only discovers the chrome elements by their\n * well-known ids and drives them.\n */\nimport {\n PanelDocument,\n PanelUI,\n UIKitDocument,\n createSystem,\n type Entity,\n} from '@iwsdk/core';\nimport { Vector3 } from 'three';\nimport { UIDockedTo, UIWindow, UIWindowState } from '../components.js';\nimport { WINDOW_CHROME_IDS } from '@realitycollective/webxr-uiextensions';\nimport { windowManagerFor } from '../manager-registry.js';\nimport {\n minimizeLabelFor,\n pinLabelFor,\n type WindowManager,\n type WindowRecord,\n} from '@realitycollective/webxr-uiextensions';\nimport { DockMode, isDockMode, type DockModeValue } from '@realitycollective/webxr-uiextensions';\n\ntype UikitElement = {\n addEventListener: (type: string, listener: (event?: unknown) => void) => void;\n setProperties: (props: Record<string, unknown>) => void;\n};\n\nlet autoId = 0;\n\nexport class UIWindowSystem extends createSystem({\n pendingWindows: {\n required: [UIWindow, PanelUI, PanelDocument],\n excluded: [UIWindowState],\n },\n windows: { required: [UIWindow, UIWindowState, PanelDocument] },\n}) {\n private manager!: WindowManager;\n private entitiesById = new Map<string, Entity>();\n private localCamera = new Vector3();\n\n override init(): void {\n this.manager = windowManagerFor(this.world);\n\n this.cleanupFuncs.push(\n this.queries.pendingWindows.subscribe('qualify', (entity) => {\n this.adoptWindow(entity);\n }),\n this.queries.windows.subscribe('disqualify', (entity) => {\n this.releaseWindow(entity);\n }),\n this.manager.events.on('minimized', ({ id }) => this.applyMinimized(id, true)),\n this.manager.events.on('restored', ({ id }) => this.applyMinimized(id, false)),\n this.manager.events.on('minimized', (record) => this.syncMinimizeLabel(record)),\n this.manager.events.on('restored', (record) => this.syncMinimizeLabel(record)),\n this.manager.events.on('dockChanged', ({ window }) => {\n const entity = this.entitiesById.get(window.id);\n if (entity && entity.getValue(UIWindow, 'dockMode') !== window.dockMode) {\n entity.setValue(UIWindow, 'dockMode', window.dockMode);\n }\n this.syncPinLabel(window);\n }),\n this.manager.events.on('dragStarted', (window) => this.syncPinLabel(window)),\n this.manager.events.on('dragEnded', (window) => this.syncPinLabel(window)),\n );\n }\n\n override update(): void {\n // Focus bias: nudge each window's document toward the viewer by a small\n // amount inversely related to focus depth, so overlapping windows resolve\n // in focus order. Computed in entity-local space so it holds for any\n // window orientation.\n for (const entity of this.queries.windows.entities) {\n const id = entity.getValue(UIWindow, 'windowId') as string;\n if (!this.manager.has(id)) {\n continue;\n }\n const document = this.documentOf(entity);\n const object = entity.object3D;\n if (!document || !object) {\n continue;\n }\n const bias = entity.getValue(UIWindow, 'focusBias') as number;\n const depth = this.manager.orderOf(id);\n const amount = bias * Math.max(0, this.manager.count - 1 - depth);\n if (amount === 0) {\n document.position.set(0, 0, 0);\n continue;\n }\n this.camera.getWorldPosition(this.localCamera);\n object.worldToLocal(this.localCamera);\n if (this.localCamera.lengthSq() === 0) {\n continue;\n }\n document.position.copy(this.localCamera.normalize().multiplyScalar(amount));\n }\n }\n\n entityFor(windowId: string): Entity | undefined {\n return this.entitiesById.get(windowId);\n }\n\n private adoptWindow(entity: Entity): void {\n let id = entity.getValue(UIWindow, 'windowId') as string;\n if (!id) {\n id = `uix-window-${autoId++}`;\n entity.setValue(UIWindow, 'windowId', id);\n }\n const title = entity.getValue(UIWindow, 'title') as string;\n const dockMode = entity.getValue(UIWindow, 'dockMode') as DockModeValue;\n this.entitiesById.set(id, entity);\n if (!this.manager.has(id)) {\n this.manager.open(id, { title, dockMode });\n }\n this.wireChrome(entity, id, title);\n\n // Snapshot \"home\" so the DOCK button can return the window: the spawn\n // region if it was born docked, otherwise its placement + dock mode.\n const object = entity.object3D;\n entity.addComponent(UIWindowState, {\n chromeWired: true,\n appliedDockMode: '',\n homeDockMode: dockMode,\n homeRegion: entity.hasComponent(UIDockedTo)\n ? (entity.getValue(UIDockedTo, 'regionId') as string)\n : '',\n homePosition: object ? [object.position.x, object.position.y, object.position.z] : [0, 0, 0],\n homeYaw: object ? object.rotation.y : 0,\n });\n this.syncPinLabel({ id, dockMode, dragging: false });\n }\n\n /** Return a window to its home: spawn region, or original placement/mode. */\n returnHome(entity: Entity): void {\n const homeRegion = entity.getValue(UIWindowState, 'homeRegion') as string;\n if (homeRegion) {\n if (\n entity.hasComponent(UIDockedTo) &&\n entity.getValue(UIDockedTo, 'regionId') === homeRegion\n ) {\n return; // already home\n }\n if (entity.hasComponent(UIDockedTo)) {\n entity.removeComponent(UIDockedTo);\n }\n entity.addComponent(UIDockedTo, { regionId: homeRegion });\n return;\n }\n if (entity.hasComponent(UIDockedTo)) {\n entity.removeComponent(UIDockedTo);\n }\n const homeDockMode = entity.getValue(UIWindowState, 'homeDockMode') as string;\n if (isDockMode(homeDockMode)) {\n entity.setValue(UIWindow, 'dockMode', homeDockMode);\n }\n if (homeDockMode === DockMode.WorldLocked) {\n const object = entity.object3D;\n const home = entity.getVectorView(UIWindowState, 'homePosition');\n if (object) {\n object.position.set(home[0] ?? 0, home[1] ?? 0, home[2] ?? 0);\n object.rotation.set(0, entity.getValue(UIWindowState, 'homeYaw') as number, 0);\n }\n }\n // Follow modes re-snap on their own (the dock system syncs the Follower).\n }\n\n /** MIN when open, MAX when minimized - the label names the next action. */\n private syncMinimizeLabel(record: Pick<WindowRecord, 'id' | 'minimized'>): void {\n const entity = this.entitiesById.get(record.id);\n const minimize = entity\n ? (this.documentOf(entity)?.getElementById(WINDOW_CHROME_IDS.minimize) as\n | UikitElement\n | undefined)\n : undefined;\n minimize?.setProperties({ text: minimizeLabelFor(record) });\n }\n\n private syncPinLabel(record: Pick<WindowRecord, 'id' | 'dockMode' | 'dragging'>): void {\n const entity = this.entitiesById.get(record.id);\n const pin = entity\n ? (this.documentOf(entity)?.getElementById(WINDOW_CHROME_IDS.pin) as\n | UikitElement\n | undefined)\n : undefined;\n pin?.setProperties({ text: pinLabelFor(record) });\n }\n\n private releaseWindow(entity: Entity): void {\n const id = entity.getValue(UIWindow, 'windowId') as string;\n if (id && this.entitiesById.get(id) === entity) {\n this.entitiesById.delete(id);\n if (this.manager.has(id)) {\n this.manager.close(id);\n }\n }\n }\n\n private wireChrome(entity: Entity, id: string, title: string): void {\n const document = this.documentOf(entity);\n if (!document) {\n return;\n }\n\n // IWSDK 0.5 removed PanelUI.maxWidth/maxHeight; world size is now the\n // document's own concern. Fit into the requested box, preserving aspect\n // ratio. Zero means \"leave intrinsic\" so the entity transform owns scale.\n const targetWidth = entity.getValue(UIWindow, 'targetWidth') ?? 0;\n const targetHeight = entity.getValue(UIWindow, 'targetHeight') ?? 0;\n if (targetWidth > 0 && targetHeight > 0) {\n document.setTargetDimensions(targetWidth, targetHeight);\n }\n\n const element = (elementId: string): UikitElement | undefined =>\n document.getElementById(elementId) as UikitElement | undefined;\n\n const titleEl = element(WINDOW_CHROME_IDS.title);\n if (titleEl && title) {\n titleEl.setProperties({ text: title });\n }\n\n // Chrome buttons live on the drag surface - keep their presses out of\n // the title-bar drag handle so clicks never turn into (or arm) drags.\n const swallowPress = (button: UikitElement | undefined): void => {\n button?.addEventListener('pointerdown', (event) => {\n (event as { stopPropagation?: () => void } | undefined)?.stopPropagation?.();\n });\n };\n swallowPress(element(WINDOW_CHROME_IDS.pin));\n swallowPress(element(WINDOW_CHROME_IDS.dock));\n swallowPress(element(WINDOW_CHROME_IDS.minimize));\n swallowPress(element(WINDOW_CHROME_IDS.close));\n\n // Any press anywhere on the window brings it to the front.\n const root = element(WINDOW_CHROME_IDS.window);\n root?.addEventListener('pointerdown', () => {\n if (this.manager.has(id)) {\n this.manager.focus(id);\n }\n });\n\n const close = element(WINDOW_CHROME_IDS.close);\n if (close) {\n if (entity.getValue(UIWindow, 'closable')) {\n close.addEventListener('click', () => {\n // Destroying the entity disqualifies it everywhere; releaseWindow\n // then closes the manager record.\n entity.destroy();\n });\n } else {\n close.setProperties({ display: 'none' });\n }\n }\n\n const minimize = element(WINDOW_CHROME_IDS.minimize);\n if (minimize) {\n if (entity.getValue(UIWindow, 'minimizable')) {\n minimize.addEventListener('click', () => {\n if (this.manager.has(id)) {\n this.manager.toggleMinimized(id);\n }\n });\n } else {\n minimize.setProperties({ display: 'none' });\n }\n }\n\n const pin = element(WINDOW_CHROME_IDS.pin);\n if (pin) {\n if (entity.getValue(UIWindow, 'pinnable')) {\n pin.addEventListener('click', () => {\n if (this.manager.has(id)) {\n this.manager.togglePin(id);\n }\n });\n } else {\n pin.setProperties({ display: 'none' });\n }\n }\n\n const dock = element(WINDOW_CHROME_IDS.dock);\n dock?.addEventListener('click', () => this.returnHome(entity));\n }\n\n private applyMinimized(id: string, minimized: boolean): void {\n const entity = this.entitiesById.get(id);\n const document = entity ? this.documentOf(entity) : undefined;\n const content = document?.getElementById(WINDOW_CHROME_IDS.content) as\n | UikitElement\n | undefined;\n content?.setProperties({ display: minimized ? 'none' : 'flex' });\n }\n\n private documentOf(entity: Entity): UIKitDocument | undefined {\n return PanelDocument.data.document[entity.index] as UIKitDocument | undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"window-system.js","sourceRoot":"","sources":["../../src/systems/window-system.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,aAAa,EACb,OAAO,GAGR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,WAAW,GAGZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAsB,MAAM,uCAAuC,CAAC;AAOjG,IAAI,MAAM,GAAG,CAAC,CAAC;AAEf,MAAM,OAAO,cAAe,SAAQ,YAAY,CAAC;IAC/C,cAAc,EAAE;QACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC;QAC5C,QAAQ,EAAE,CAAC,aAAa,CAAC;KAC1B;IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,aAAa,CAAC,EAAE;CAChE,CAAC;IACQ,OAAO,CAAiB;IACxB,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;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UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC9D,MAAM,OAAO,GAAG,QAAQ,EAAE,cAAc,CAAC,iBAAiB,CAAC,OAAO,CAErD,CAAC;QACd,OAAO,EAAE,aAAa,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC;IAEO,UAAU,CAAC,MAAc;QAC/B,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAA8B,CAAC;IAChF,CAAC;CACF","sourcesContent":["/**\n * UIWindowSystem - wires window chrome, keeps the `WindowManager` in sync\n * with entities, applies focus ordering and minimize state.\n *\n * Reuse over recreation: the panel itself is loaded/rendered by the IWSDK's\n * `PanelUISystem`; this system only discovers the chrome elements by their\n * well-known ids and drives them.\n */\nimport {\n PanelDocument,\n PanelUI,\n UIKitDocument,\n type Entity,\n} from '@iwsdk/core';\nimport { createSystem } from '../create-system.js';\nimport { Vector3 } from 'three';\nimport { UIDockedTo, UIWindow, UIWindowState } from '../components.js';\nimport { WINDOW_CHROME_IDS } from '@realitycollective/webxr-uiextensions';\nimport { windowManagerFor } from '../manager-registry.js';\nimport {\n minimizeLabelFor,\n pinLabelFor,\n type WindowManager,\n type WindowRecord,\n} from '@realitycollective/webxr-uiextensions';\nimport { DockMode, isDockMode, type DockModeValue } from '@realitycollective/webxr-uiextensions';\n\ntype UikitElement = {\n addEventListener: (type: string, listener: (event?: unknown) => void) => void;\n setProperties: (props: Record<string, unknown>) => void;\n};\n\nlet autoId = 0;\n\nexport class UIWindowSystem extends createSystem({\n pendingWindows: {\n required: [UIWindow, PanelUI, PanelDocument],\n excluded: [UIWindowState],\n },\n windows: { required: [UIWindow, UIWindowState, PanelDocument] },\n}) {\n private manager!: WindowManager;\n private entitiesById = new Map<string, Entity>();\n private localCamera = new Vector3();\n\n override init(): void {\n this.manager = windowManagerFor(this.world);\n\n this.cleanupFuncs.push(\n this.queries.pendingWindows.subscribe('qualify', (entity) => {\n this.adoptWindow(entity);\n }),\n this.queries.windows.subscribe('disqualify', (entity) => {\n this.releaseWindow(entity);\n }),\n this.manager.events.on('minimized', ({ id }) => this.applyMinimized(id, true)),\n this.manager.events.on('restored', ({ id }) => this.applyMinimized(id, false)),\n this.manager.events.on('minimized', (record) => this.syncMinimizeLabel(record)),\n this.manager.events.on('restored', (record) => this.syncMinimizeLabel(record)),\n this.manager.events.on('dockChanged', ({ window }) => {\n const entity = this.entitiesById.get(window.id);\n if (entity && entity.getValue(UIWindow, 'dockMode') !== window.dockMode) {\n entity.setValue(UIWindow, 'dockMode', window.dockMode);\n }\n this.syncPinLabel(window);\n }),\n this.manager.events.on('dragStarted', (window) => this.syncPinLabel(window)),\n this.manager.events.on('dragEnded', (window) => this.syncPinLabel(window)),\n );\n }\n\n override update(): void {\n // Focus bias: nudge each window's document toward the viewer by a small\n // amount inversely related to focus depth, so overlapping windows resolve\n // in focus order. Computed in entity-local space so it holds for any\n // window orientation.\n for (const entity of this.queries.windows.entities) {\n const id = entity.getValue(UIWindow, 'windowId') as string;\n if (!this.manager.has(id)) {\n continue;\n }\n const document = this.documentOf(entity);\n const object = entity.object3D;\n if (!document || !object) {\n continue;\n }\n const bias = entity.getValue(UIWindow, 'focusBias') as number;\n const depth = this.manager.orderOf(id);\n const amount = bias * Math.max(0, this.manager.count - 1 - depth);\n if (amount === 0) {\n document.position.set(0, 0, 0);\n continue;\n }\n this.camera.getWorldPosition(this.localCamera);\n object.worldToLocal(this.localCamera);\n if (this.localCamera.lengthSq() === 0) {\n continue;\n }\n document.position.copy(this.localCamera.normalize().multiplyScalar(amount));\n }\n }\n\n entityFor(windowId: string): Entity | undefined {\n return this.entitiesById.get(windowId);\n }\n\n private adoptWindow(entity: Entity): void {\n let id = entity.getValue(UIWindow, 'windowId') as string;\n if (!id) {\n id = `uix-window-${autoId++}`;\n entity.setValue(UIWindow, 'windowId', id);\n }\n const title = entity.getValue(UIWindow, 'title') as string;\n const dockMode = entity.getValue(UIWindow, 'dockMode') as DockModeValue;\n this.entitiesById.set(id, entity);\n if (!this.manager.has(id)) {\n this.manager.open(id, { title, dockMode });\n }\n this.wireChrome(entity, id, title);\n\n // Snapshot \"home\" so the DOCK button can return the window: the spawn\n // region if it was born docked, otherwise its placement + dock mode.\n const object = entity.object3D;\n entity.addComponent(UIWindowState, {\n chromeWired: true,\n appliedDockMode: '',\n homeDockMode: dockMode,\n homeRegion: entity.hasComponent(UIDockedTo)\n ? (entity.getValue(UIDockedTo, 'regionId') as string)\n : '',\n homePosition: object ? [object.position.x, object.position.y, object.position.z] : [0, 0, 0],\n homeYaw: object ? object.rotation.y : 0,\n });\n this.syncPinLabel({ id, dockMode, dragging: false });\n }\n\n /** Return a window to its home: spawn region, or original placement/mode. */\n returnHome(entity: Entity): void {\n const homeRegion = entity.getValue(UIWindowState, 'homeRegion') as string;\n if (homeRegion) {\n if (\n entity.hasComponent(UIDockedTo) &&\n entity.getValue(UIDockedTo, 'regionId') === homeRegion\n ) {\n return; // already home\n }\n if (entity.hasComponent(UIDockedTo)) {\n entity.removeComponent(UIDockedTo);\n }\n entity.addComponent(UIDockedTo, { regionId: homeRegion });\n return;\n }\n if (entity.hasComponent(UIDockedTo)) {\n entity.removeComponent(UIDockedTo);\n }\n const homeDockMode = entity.getValue(UIWindowState, 'homeDockMode') as string;\n if (isDockMode(homeDockMode)) {\n entity.setValue(UIWindow, 'dockMode', homeDockMode);\n }\n if (homeDockMode === DockMode.WorldLocked) {\n const object = entity.object3D;\n const home = entity.getVectorView(UIWindowState, 'homePosition');\n if (object) {\n object.position.set(home[0] ?? 0, home[1] ?? 0, home[2] ?? 0);\n object.rotation.set(0, entity.getValue(UIWindowState, 'homeYaw') as number, 0);\n }\n }\n // Follow modes re-snap on their own (the dock system syncs the Follower).\n }\n\n /** MIN when open, MAX when minimized - the label names the next action. */\n private syncMinimizeLabel(record: Pick<WindowRecord, 'id' | 'minimized'>): void {\n const entity = this.entitiesById.get(record.id);\n const minimize = entity\n ? (this.documentOf(entity)?.getElementById(WINDOW_CHROME_IDS.minimize) as\n | UikitElement\n | undefined)\n : undefined;\n minimize?.setProperties({ text: minimizeLabelFor(record) });\n }\n\n private syncPinLabel(record: Pick<WindowRecord, 'id' | 'dockMode' | 'dragging'>): void {\n const entity = this.entitiesById.get(record.id);\n const pin = entity\n ? (this.documentOf(entity)?.getElementById(WINDOW_CHROME_IDS.pin) as\n | UikitElement\n | undefined)\n : undefined;\n pin?.setProperties({ text: pinLabelFor(record) });\n }\n\n private releaseWindow(entity: Entity): void {\n const id = entity.getValue(UIWindow, 'windowId') as string;\n if (id && this.entitiesById.get(id) === entity) {\n this.entitiesById.delete(id);\n if (this.manager.has(id)) {\n this.manager.close(id);\n }\n }\n }\n\n private wireChrome(entity: Entity, id: string, title: string): void {\n const document = this.documentOf(entity);\n if (!document) {\n return;\n }\n\n // IWSDK 0.5 removed PanelUI.maxWidth/maxHeight; world size is now the\n // document's own concern. Fit into the requested box, preserving aspect\n // ratio. Zero means \"leave intrinsic\" so the entity transform owns scale.\n const targetWidth = entity.getValue(UIWindow, 'targetWidth') ?? 0;\n const targetHeight = entity.getValue(UIWindow, 'targetHeight') ?? 0;\n if (targetWidth > 0 && targetHeight > 0) {\n document.setTargetDimensions(targetWidth, targetHeight);\n }\n\n const element = (elementId: string): UikitElement | undefined =>\n document.getElementById(elementId) as UikitElement | undefined;\n\n const titleEl = element(WINDOW_CHROME_IDS.title);\n if (titleEl && title) {\n titleEl.setProperties({ text: title });\n }\n\n // Chrome buttons live on the drag surface - keep their presses out of\n // the title-bar drag handle so clicks never turn into (or arm) drags.\n const swallowPress = (button: UikitElement | undefined): void => {\n button?.addEventListener('pointerdown', (event) => {\n (event as { stopPropagation?: () => void } | undefined)?.stopPropagation?.();\n });\n };\n swallowPress(element(WINDOW_CHROME_IDS.pin));\n swallowPress(element(WINDOW_CHROME_IDS.dock));\n swallowPress(element(WINDOW_CHROME_IDS.minimize));\n swallowPress(element(WINDOW_CHROME_IDS.close));\n\n // Any press anywhere on the window brings it to the front.\n const root = element(WINDOW_CHROME_IDS.window);\n root?.addEventListener('pointerdown', () => {\n if (this.manager.has(id)) {\n this.manager.focus(id);\n }\n });\n\n const close = element(WINDOW_CHROME_IDS.close);\n if (close) {\n if (entity.getValue(UIWindow, 'closable')) {\n close.addEventListener('click', () => {\n // Destroying the entity disqualifies it everywhere; releaseWindow\n // then closes the manager record.\n entity.destroy();\n });\n } else {\n close.setProperties({ display: 'none' });\n }\n }\n\n const minimize = element(WINDOW_CHROME_IDS.minimize);\n if (minimize) {\n if (entity.getValue(UIWindow, 'minimizable')) {\n minimize.addEventListener('click', () => {\n if (this.manager.has(id)) {\n this.manager.toggleMinimized(id);\n }\n });\n } else {\n minimize.setProperties({ display: 'none' });\n }\n }\n\n const pin = element(WINDOW_CHROME_IDS.pin);\n if (pin) {\n if (entity.getValue(UIWindow, 'pinnable')) {\n pin.addEventListener('click', () => {\n if (this.manager.has(id)) {\n this.manager.togglePin(id);\n }\n });\n } else {\n pin.setProperties({ display: 'none' });\n }\n }\n\n const dock = element(WINDOW_CHROME_IDS.dock);\n dock?.addEventListener('click', () => this.returnHome(entity));\n }\n\n private applyMinimized(id: string, minimized: boolean): void {\n const entity = this.entitiesById.get(id);\n const document = entity ? this.documentOf(entity) : undefined;\n const content = document?.getElementById(WINDOW_CHROME_IDS.content) as\n | UikitElement\n | undefined;\n content?.setProperties({ display: minimized ? 'none' : 'flex' });\n }\n\n private documentOf(entity: Entity): UIKitDocument | undefined {\n return PanelDocument.data.document[entity.index] as UIKitDocument | undefined;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realitycollective/iwsdk-uiextensions",
3
- "version": "0.1.0-preview.6",
3
+ "version": "0.1.0-preview.7",
4
4
  "description": "Meta IWSDK adapter for the Reality Collective UI Extensions - windowing, docking, layout regions and extra controls, binding the engine-free @realitycollective/webxr-uiextensions core onto IWSDK's ECS, UIKitML and interaction systems.",
5
5
  "keywords": [
6
6
  "realitycollective",
@@ -39,7 +39,7 @@
39
39
  "@drawcall/uikitml": "0.1.8",
40
40
  "zod": "^4.4.3",
41
41
  "@pmndrs/handle": "^6.6.16",
42
- "@realitycollective/webxr-uiextensions": "^0.1.0-preview.6"
42
+ "@realitycollective/webxr-uiextensions": "^0.1.0-preview.7"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@iwsdk/core": ">=0.5.0 <0.6.0",