@realitycollective/iwsdk-uiextensions 0.1.0-preview.0 → 0.1.0-preview.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @realitycollective/iwsdk-uiextensions might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -13,5 +13,26 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
13
13
  - `@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.
14
14
  - `@realitycollective/uix-devtools` - dev-only tooling: edit-session launch gate, runtime UIKitML compilation, and the `uix-dev` CLI (Cloudflare quick tunnel, QR onboarding, environment doctor).
15
15
  - Demo clients: the IWSDK showcase, the devtools playground, and the multiplatform lab that picks its pipeline from the hardware.
16
+ - `uixComponentSet`, exported from `@realitycollective/iwsdk-uiextensions`. Pass it to `spatialUI.componentSets` so the IWSDK 0.5 parser accepts the `<uix-*>` control elements. Without it a panel using any control fails to parse and never attaches. No equivalent is needed on the three.js or XR Blocks adapters.
17
+ - `WindowHandle` and `WindowOptionsBase` in `@realitycollective/webxr-uiextensions`. `WindowHandle` is what every adapter's `createWindow` hands back: an `id`, a `panel` that is `undefined` until the adapter has attached the document, and `onReady(listener)`, which runs once and fires immediately if the panel is already there. `WindowOptionsBase` holds the options every adapter understands, and both adapters' option types now extend it, so an option name means the same thing on each. `createWindow` itself stays adapter-specific, because the `config` payload differs per engine.
18
+ - `WindowHost.supportsStandalonePanels`. It says whether `createPanel` works on a host, rather than leaving callers to find out by catching. `false` on the IWSDK host, where the ECS owns panel lifecycles and `createPanel` throws; `true` on the three.js / XR Blocks host.
19
+ - `PanelReadyEvent.kind`, either `window` or `panel`. `window` means the panel came from the adapter's window factory and is managed by the window manager. `panel` means a bare panel the adapter noticed, whose `id` is then the adapter's best stable identifier for it - the config path on IWSDK. The field is optional, so existing listeners keep compiling.
20
+ - `createWindow` on the IWSDK scene host, returning an `IwsdkWindowHandle`: a `WindowHandle` plus the ECS `entity`. It spawns through `createUIWindow`, names the window `uix-window-<n>` when no id is given, and resolves `panel` and `onReady` once the document attaches, so wiring one window needs neither an ECS query nor a filtered `onPanelReady`. `createUIWindow` is unchanged and still returns the entity.
21
+ - `getPanelHandle(entity)` in `@realitycollective/iwsdk-uiextensions`: the panel handle for an entity you already hold, or `undefined` while IWSDK is still loading its document.
22
+
23
+ ### Changed
24
+
25
+ - **Controls are declared as custom elements rather than attributes.** `<uix-stepper>` replaces `<div data-uix="stepper">`, and each part is its own element: `<uix-value>`, `<uix-line>`, `<uix-label>` and so on, replacing `data-uix-role`. Parameters are unchanged and stay `data-uix-*`. This is what makes one markup file portable: IWSDK 0.5 parses with `@drawcall/uikitml`, which rejects every `data-*` attribute on a built-in tag but accepts custom tags declared in a component set, while the three.js and XR Blocks parser accepts custom tags with no registration at all. Both expose the declared tag on `userData.customElement.componentName`, so the engine-free upgraders read one contract on every adapter.
26
+ - The expandable label's `toggle` part is now `<uix-more>`. As an element the old name would have collided with the `<uix-toggle>` control.
27
+ - `@realitycollective/iwsdk-uiextensions` targets **IWSDK 0.5.x**: peer range `>=0.5.0 <0.6.0`, developed against `@iwsdk/core` 0.5.3. `PanelUI` in 0.5 declares a single field, `config`, holding the URL of the UIKitML **source**; the compiled JSON it took on 0.4.x, and the `@iwsdk/vite-plugin-uikitml` step that produced it, are both gone. `maxWidth` and `maxHeight` were removed from the component schema, and ECS ignores unknown fields silently, so a panel that still writes them is mis-sized with no error. Size through `createUIWindow`, which routes to `UIWindow.targetWidth/Height`.
28
+ - `UixWindowHost` resolves a window's `config` by fetching the `.uikitml` source and parsing it, where it previously fetched compiled JSON. Supplying `loadConfig` is no longer necessary for an ordinary panel; override it only for an unusual transport.
29
+ - `compilePanelSource` in `@realitycollective/uix-devtools` serves the **source** on its `blob:` URL rather than compiled JSON, matching what 0.5 fetches. `CompiledPanel.json` is now `CompiledPanel.source`, and the `resolveFile` option is gone because the 0.5 parser has no `<link ref>` stylesheet resolution; put shared rules in a `<style>` block, of which several are allowed and merge. Validation now runs on `@drawcall/uikitml`, pinned to the version `@iwsdk/core` depends on, so a source that passes here is one `PanelUISystem` will accept and no second parser enters the tree.
30
+ - Example and demo markup uses `rgba()` or eight-digit hex rather than `background-opacity`, which the 0.5 parser removed. Both parsers accept the replacement, so one stylesheet serves every adapter.
31
+ - The IWSDK component kit is selected by name, `spatialUI: { kit: 'horizon' }`, rather than by passing an imported kit module. The kits now live inside the parser.
32
+ - `@types/three` is pinned to `0.184.0` across the workspace. IWSDK 0.5.3 and xrblocks resolved different copies, and two copies of the three typings make structurally identical `Object3D` types mutually unassignable, which surfaces as spurious errors far from their cause.
33
+ - `onPanelReady` on the IWSDK host announces bare panels as well as managed windows. A `PanelUI` entity with no `UIWindow`, or with an empty `windowId`, used to be dropped silently; it is now announced with `kind: 'panel'` and its config path as the id. Listeners that only want managed windows should check `kind`.
34
+ - `id` is optional in the XR Blocks host's `CreateWindowOptions`; a window created without one is named `uix-window-<n>`, as on IWSDK. The options also accept `movable` for parity, but this host has no title-bar drag of its own yet, so the flag is recorded and not acted on.
35
+ - The XR Blocks window handle gains `panel` - the document, which already implements `PanelHandle` - and `onReady`, which fires synchronously because uikitml interprets the markup during `createWindow`. The interface is now named `XrBlocksWindowHandle`, with `WindowHandle` kept as an alias, because the core exports a `WindowHandle` of its own.
36
+ - Coverage gates `packages/iwsdk-uiextensions/src/factory.ts` and `src/scene-host.ts` at the same 100% as the core. `new World()` from `@iwsdk/core` constructs headlessly - no renderer, no WebGL, no XR session - so the factories, the scene host and its ECS query all run for real in a node test. The per-frame ECS systems still need a live world and stay outside the gate.
16
37
 
17
38
  [0.1.0]: https://github.com/realitycollective/WebXR-UIExtensions/commits/main
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Basic window - chrome, focus, docking and drag with one call.
3
- * Put window.uikitml in your app's ui/ folder (compiles to /ui/window.json).
3
+ * Put window.uikitml in your app's public/ui/ folder - IWSDK 0.5 fetches and
4
+ * parses the source at runtime, so there is no compile step.
4
5
  */
5
6
  import { World } from '@iwsdk/core';
6
7
  import {
@@ -19,7 +20,7 @@ export async function start(container: HTMLDivElement) {
19
20
  createUIWindow(world, {
20
21
  id: 'hello',
21
22
  title: 'Hello Window',
22
- config: './ui/window.json',
23
+ config: './ui/window.uikitml',
23
24
  dockMode: DockMode.BodyFollow, // follows until pinned or dragged
24
25
  followOffset: [0, -0.15, -1.2],
25
26
  });
@@ -3,8 +3,7 @@
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  width: 300;
6
- background-color: #101a26;
7
- background-opacity: 0.92;
6
+ background-color: rgba(16, 26, 38, 0.92);
8
7
  border-radius: 12.5;
9
8
  border-color: #2e4a66;
10
9
  border-width: 0.75;
@@ -4,8 +4,7 @@
4
4
  flex-direction: column;
5
5
  width: 300;
6
6
  padding: 10;
7
- background-color: #101a26;
8
- background-opacity: 0.92;
7
+ background-color: rgba(16, 26, 38, 0.92);
9
8
  border-radius: 12.5;
10
9
  }
11
10
  .row { display: flex; flex-direction: row; align-items: center; justify-content: space-between; width: 100%; margin-top: 7; }
@@ -17,16 +17,20 @@ export async function start(container: HTMLDivElement) {
17
17
  });
18
18
  registerUIExtensions(world);
19
19
 
20
+ // `config` is the only field PanelUI carries in IWSDK 0.5. maxWidth/maxHeight
21
+ // were removed from the schema; ECS ignores unknown fields silently, so
22
+ // writing them here would mis-size the panel with no error. Size a panel
23
+ // through createUIWindow instead, which routes to UIWindow.targetWidth/Height.
20
24
  const panel = world
21
25
  .createTransformEntity()
22
- .addComponent(PanelUI, { config: './ui/controls.json', maxWidth: 0.8, maxHeight: 1 });
26
+ .addComponent(PanelUI, { config: './ui/controls.uikitml' });
23
27
  panel.object3D!.position.set(0, 1.5, -1.2);
24
28
 
25
29
  // Wire the handles once the panel loads.
26
30
  class WireSystem extends createSystem({
27
31
  panel: {
28
32
  required: [PanelUI, PanelDocument],
29
- where: [eq(PanelUI, 'config', './ui/controls.json')],
33
+ where: [eq(PanelUI, 'config', './ui/controls.uikitml')],
30
34
  },
31
35
  }) {
32
36
  override init(): void {
@@ -41,7 +41,7 @@ export async function start(container: HTMLDivElement) {
41
41
  createUIWindow(world, {
42
42
  id: 'docked',
43
43
  title: 'Docked Window',
44
- config: './ui/window.json',
44
+ config: './ui/window.uikitml',
45
45
  region: 'wall',
46
46
  });
47
47
 
@@ -49,7 +49,7 @@ export async function start(container: HTMLDivElement) {
49
49
  createUIWindow(world, {
50
50
  id: 'floating',
51
51
  title: 'Drag Me Into A Region',
52
- config: './ui/window.json',
52
+ config: './ui/window.uikitml',
53
53
  position: [0, 1.5, -1.4],
54
54
  });
55
55
  }
package/README.md CHANGED
@@ -20,7 +20,7 @@ Everything is authored in plain UIKitML (HTML/CSS-like) - no new markup language
20
20
 
21
21
  ```bash
22
22
  npm install @realitycollective/iwsdk-uiextensions
23
- # peer: @iwsdk/core >= 0.4
23
+ # peer: @iwsdk/core >=0.5.0 <0.6.0
24
24
  ```
25
25
 
26
26
  ## Quick start
@@ -45,7 +45,7 @@ createDockRegion(world, { id: 'wall', flow: 'column', position: [1.5, 1.8, -1.5]
45
45
  createUIWindow(world, {
46
46
  id: 'status',
47
47
  title: 'Player Status',
48
- config: './ui/status.json', // compiled UIKitML
48
+ config: './ui/status.uikitml', // UIKitML source; IWSDK 0.5 parses it at runtime
49
49
  dockMode: DockMode.BodyFollow, // follows until the user pins it
50
50
  });
51
51
 
@@ -103,6 +103,44 @@ controls.stepper('health').events.on('change', (hp) => setHealth(hp));
103
103
 
104
104
  See `Examples/` (shipped in this package) and the deployable showcase client in the repository for complete, working demonstrations of every feature.
105
105
 
106
+ ## Windows and panel readiness
107
+
108
+ `createUIWindow` returns the ECS entity, which is what you want when you are going to add components to it. When you want the PANEL, use the scene host: `createWindow` gives you a handle that resolves itself.
109
+
110
+ ```ts
111
+ import { createSceneHost, getPanelHandle } from '@realitycollective/iwsdk-uiextensions';
112
+
113
+ const host = createSceneHost(world); // call after registerUIExtensions(world)
114
+
115
+ const status = host.createWindow({
116
+ id: 'status', // optional - omit and you get uix-window-<n>
117
+ title: 'Player Status',
118
+ config: './ui/status.uikitml',
119
+ });
120
+
121
+ status.panel; // undefined until IWSDK attaches the document
122
+ status.onReady((panel) => { // runs once, immediately if it is already there
123
+ panel.getElementById('uix-title');
124
+ });
125
+ status.entity; // still the entity, for ECS work
126
+ ```
127
+
128
+ `getPanelHandle(entity)` does the same lookup for an entity you already hold, and returns `undefined` while the document is still loading.
129
+
130
+ Across a whole scene, subscribe to the host instead:
131
+
132
+ ```ts
133
+ host.onPanelReady(({ id, panel, kind }) => {
134
+ if (kind === 'panel') {
135
+ // A bare PanelUI entity with no UIWindow: `id` is its config path.
136
+ return;
137
+ }
138
+ wireMyWindow(id, panel);
139
+ });
140
+ ```
141
+
142
+ Bare panels are announced as well as managed windows, which is how devtools and hand-built `PanelUI` entities show up in the same stream. `supportsStandalonePanels` is `false` on this host: IWSDK owns panel lifecycles through the ECS, so `createPanel()` throws rather than half-working. Spawn a window instead.
143
+
106
144
  ## Headless core
107
145
 
108
146
  All decision logic (window manager, dock state machine, region slot math, drag math, control models) lives in `@realitycollective/webxr-uiextensions` - pure TypeScript with no engine imports, tested at 100% coverage. The ECS systems in this package are thin appliers of that core onto `@iwsdk/core` components.
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The UIKitML component set for `<uix-*>` control elements.
3
+ *
4
+ * IWSDK 0.5 parses panels with `@drawcall/uikitml`, which validates every tag
5
+ * against a component schema and rejects anything it does not know - including
6
+ * every `data-*` attribute on a built-in tag. Declaring the control elements
7
+ * here is the supported way to extend that vocabulary.
8
+ *
9
+ * The three.js and XR Blocks adapters need no equivalent: their parser accepts
10
+ * custom tags unregistered, exposing the tag on
11
+ * `userData.customElement.componentName`. This set reproduces that convention
12
+ * on the IWSDK side - the constructor below stamps the same key and lifts
13
+ * `data-uix-*` attributes into `userData` - so ONE markup file drives every
14
+ * adapter and the engine-free upgraders read it identically everywhere.
15
+ *
16
+ * Register it when creating the world:
17
+ * ```ts
18
+ * const world = await World.create(container, {
19
+ * features: { spatialUI: { kit: 'horizon', componentSets: [uixComponentSet] } },
20
+ * });
21
+ * ```
22
+ */
23
+ import { type ComponentSet } from '@drawcall/uikitml';
24
+ /**
25
+ * Pass to `spatialUI.componentSets` so `<uix-*>` elements parse on IWSDK 0.5.
26
+ * Without it, a panel using any control fails to parse and never attaches.
27
+ */
28
+ export declare const uixComponentSet: ComponentSet;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The UIKitML component set for `<uix-*>` control elements.
3
+ *
4
+ * IWSDK 0.5 parses panels with `@drawcall/uikitml`, which validates every tag
5
+ * against a component schema and rejects anything it does not know - including
6
+ * every `data-*` attribute on a built-in tag. Declaring the control elements
7
+ * here is the supported way to extend that vocabulary.
8
+ *
9
+ * The three.js and XR Blocks adapters need no equivalent: their parser accepts
10
+ * custom tags unregistered, exposing the tag on
11
+ * `userData.customElement.componentName`. This set reproduces that convention
12
+ * on the IWSDK side - the constructor below stamps the same key and lifts
13
+ * `data-uix-*` attributes into `userData` - so ONE markup file drives every
14
+ * adapter and the engine-free upgraders read it identically everywhere.
15
+ *
16
+ * Register it when creating the world:
17
+ * ```ts
18
+ * const world = await World.create(container, {
19
+ * features: { spatialUI: { kit: 'horizon', componentSets: [uixComponentSet] } },
20
+ * });
21
+ * ```
22
+ */
23
+ import { htmlComponentSet } from '@drawcall/uikitml';
24
+ import { z } from 'zod';
25
+ /**
26
+ * Base container, taken from the parser's own `<div>` definition rather than
27
+ * imported from `@pmndrs/uikit` directly - that keeps a single copy of uikit
28
+ * in the tree, whichever version `@iwsdk/core` resolves.
29
+ */
30
+ const BaseContainer = htmlComponentSet['div']
31
+ ?.component;
32
+ /** Control elements an author writes, and the parts that live inside them. */
33
+ const CONTROL_TAGS = [
34
+ 'uix-stepper',
35
+ 'uix-toggle',
36
+ 'uix-expandable-label',
37
+ 'uix-log-view',
38
+ ];
39
+ const ROLE_TAGS = [
40
+ 'uix-decrement',
41
+ 'uix-value',
42
+ 'uix-increment',
43
+ 'uix-label',
44
+ 'uix-line',
45
+ 'uix-up',
46
+ 'uix-down',
47
+ 'uix-clear',
48
+ 'uix-status',
49
+ 'uix-text',
50
+ 'uix-more',
51
+ ];
52
+ /**
53
+ * `data-uix-min` → `uixMin`, matching how the other parser fills userData.
54
+ *
55
+ * The parser hands properties over already camelCased, so `data-uix-min`
56
+ * arrives as `dataUixMin`; both spellings are normalised here.
57
+ */
58
+ function toUserDataKey(attribute) {
59
+ if (/^data[A-Z]/.test(attribute)) {
60
+ const rest = attribute.slice(4);
61
+ return rest.charAt(0).toLowerCase() + rest.slice(1);
62
+ }
63
+ return attribute
64
+ .replace(/^data-/, '')
65
+ .replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
66
+ }
67
+ /**
68
+ * A plain uikit Container that records what it was declared as.
69
+ *
70
+ * Anything the schema let through that is not a uikit property - the
71
+ * `data-uix-*` parameters - is moved into `userData` rather than handed to
72
+ * uikit, which would warn about properties it does not recognise.
73
+ */
74
+ function controlComponent(tag) {
75
+ return class UixControlContainer extends BaseContainer {
76
+ constructor(properties = {}) {
77
+ const uikitProps = {};
78
+ const userData = {};
79
+ for (const [key, value] of Object.entries(properties)) {
80
+ if (key.startsWith('data-') || /^data[A-Z]/.test(key)) {
81
+ userData[toUserDataKey(key)] = value;
82
+ }
83
+ else {
84
+ uikitProps[key] = value;
85
+ }
86
+ }
87
+ super(uikitProps);
88
+ Object.assign(this.userData, userData, {
89
+ customElement: { componentName: tag, sourceTag: tag },
90
+ });
91
+ }
92
+ };
93
+ }
94
+ /** Permissive: the parameters are ours, and the upgraders validate them. */
95
+ const schema = z.object({}).passthrough();
96
+ function define(tag) {
97
+ return {
98
+ component: controlComponent(tag),
99
+ schema,
100
+ canHaveChildren: true,
101
+ };
102
+ }
103
+ /**
104
+ * Pass to `spatialUI.componentSets` so `<uix-*>` elements parse on IWSDK 0.5.
105
+ * Without it, a panel using any control fails to parse and never attaches.
106
+ */
107
+ export const uixComponentSet = Object.fromEntries([...CONTROL_TAGS, ...ROLE_TAGS].map((tag) => [tag, define(tag)]));
108
+ //# sourceMappingURL=component-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-set.js","sourceRoot":"","sources":["../src/component-set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,gBAAgB,EAA+C,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC;IAC3C,EAAE,SAEH,CAAC;AAEF,8EAA8E;AAC9E,MAAM,YAAY,GAAG;IACnB,aAAa;IACb,YAAY;IACZ,sBAAsB;IACtB,cAAc;CACN,CAAC;AAEX,MAAM,SAAS,GAAG;IAChB,eAAe;IACf,WAAW;IACX,eAAe;IACf,WAAW;IACX,UAAU;IACV,QAAQ;IACR,UAAU;IACV,WAAW;IACX,YAAY;IACZ,UAAU;IACV,UAAU;CACF,CAAC;AAEX;;;;;GAKG;AACH,SAAS,aAAa,CAAC,SAAiB;IACtC,IAAI,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,SAAS;SACb,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,C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C","sourcesContent":["/**\n * The UIKitML component set for `<uix-*>` control elements.\n *\n * IWSDK 0.5 parses panels with `@drawcall/uikitml`, which validates every tag\n * against a component schema and rejects anything it does not know - including\n * every `data-*` attribute on a built-in tag. Declaring the control elements\n * here is the supported way to extend that vocabulary.\n *\n * The three.js and XR Blocks adapters need no equivalent: their parser accepts\n * custom tags unregistered, exposing the tag on\n * `userData.customElement.componentName`. This set reproduces that convention\n * on the IWSDK side - the constructor below stamps the same key and lifts\n * `data-uix-*` attributes into `userData` - so ONE markup file drives every\n * adapter and the engine-free upgraders read it identically everywhere.\n *\n * Register it when creating the world:\n * ```ts\n * const world = await World.create(container, {\n * features: { spatialUI: { kit: 'horizon', componentSets: [uixComponentSet] } },\n * });\n * ```\n */\nimport { htmlComponentSet, type ComponentSet, type ComponentDefinition } from '@drawcall/uikitml';\nimport { z } from 'zod';\n\n/**\n * Base container, taken from the parser's own `<div>` definition rather than\n * imported from `@pmndrs/uikit` directly - that keeps a single copy of uikit\n * in the tree, whichever version `@iwsdk/core` resolves.\n */\nconst BaseContainer = htmlComponentSet['div']\n ?.component as unknown as new (properties?: Record<string, unknown>) => {\n userData: Record<string, unknown>;\n};\n\n/** Control elements an author writes, and the parts that live inside them. */\nconst CONTROL_TAGS = [\n 'uix-stepper',\n 'uix-toggle',\n 'uix-expandable-label',\n 'uix-log-view',\n] as const;\n\nconst ROLE_TAGS = [\n 'uix-decrement',\n 'uix-value',\n 'uix-increment',\n 'uix-label',\n 'uix-line',\n 'uix-up',\n 'uix-down',\n 'uix-clear',\n 'uix-status',\n 'uix-text',\n 'uix-more',\n] as const;\n\n/**\n * `data-uix-min` → `uixMin`, matching how the other parser fills userData.\n *\n * The parser hands properties over already camelCased, so `data-uix-min`\n * arrives as `dataUixMin`; both spellings are normalised here.\n */\nfunction toUserDataKey(attribute: string): string {\n if (/^data[A-Z]/.test(attribute)) {\n const rest = attribute.slice(4);\n return rest.charAt(0).toLowerCase() + rest.slice(1);\n }\n return attribute\n .replace(/^data-/, '')\n .replace(/-([a-z0-9])/g, (_, c: string) => c.toUpperCase());\n}\n\n/**\n * A plain uikit Container that records what it was declared as.\n *\n * Anything the schema let through that is not a uikit property - the\n * `data-uix-*` parameters - is moved into `userData` rather than handed to\n * uikit, which would warn about properties it does not recognise.\n */\nfunction controlComponent(tag: string): typeof BaseContainer {\n return class UixControlContainer extends BaseContainer {\n constructor(properties: Record<string, unknown> = {}) {\n const uikitProps: Record<string, unknown> = {};\n const userData: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(properties)) {\n if (key.startsWith('data-') || /^data[A-Z]/.test(key)) {\n userData[toUserDataKey(key)] = value;\n } else {\n uikitProps[key] = value;\n }\n }\n super(uikitProps);\n Object.assign(this.userData, userData, {\n customElement: { componentName: tag, sourceTag: tag },\n });\n }\n };\n}\n\n/** Permissive: the parameters are ours, and the upgraders validate them. */\nconst schema = z.object({}).passthrough();\n\nfunction define(tag: string): ComponentDefinition {\n return {\n component: controlComponent(tag) as unknown as ComponentDefinition['component'],\n schema,\n canHaveChildren: true,\n };\n}\n\n/**\n * Pass to `spatialUI.componentSets` so `<uix-*>` elements parse on IWSDK 0.5.\n * Without it, a panel using any control fails to parse and never attaches.\n */\nexport const uixComponentSet: ComponentSet = Object.fromEntries(\n [...CONTROL_TAGS, ...ROLE_TAGS].map((tag) => [tag, define(tag)]),\n);\n"]}
package/dist/factory.d.ts CHANGED
@@ -5,35 +5,24 @@
5
5
  */
6
6
  import { type Entity, type World } from '@iwsdk/core';
7
7
  import { RegionFlowType } from './components.js';
8
- import { type DockModeValue } from '@realitycollective/webxr-uiextensions';
9
- export interface CreateWindowOptions {
8
+ import { type WindowOptionsBase } from '@realitycollective/webxr-uiextensions';
9
+ /**
10
+ * Options for {@link createUIWindow}.
11
+ *
12
+ * Everything but `config` comes from the portable {@link WindowOptionsBase},
13
+ * so the same option names mean the same thing on every adapter. `maxWidth`
14
+ * and `maxHeight` route to `UIWindow.targetWidth/Height` here, because IWSDK
15
+ * 0.5 removed those fields from `PanelUI`; omit them to keep the markup's
16
+ * intrinsic size and scale through the entity transform.
17
+ */
18
+ export interface CreateWindowOptions extends WindowOptionsBase {
10
19
  /**
11
20
  * URL of the UIKitML source (e.g. "/ui/my-window.uikitml"). IWSDK 0.5 parses
12
21
  * UIKitML at runtime - the build-time plugin and its generated JSON are gone.
13
22
  */
14
23
  config: string;
15
- id?: string;
16
- title?: string;
17
- dockMode?: DockModeValue;
18
- /** World position for world-locked windows. */
19
- position?: [number, number, number];
20
- /**
21
- * Fit the panel into this world-space box (meters), preserving aspect ratio.
22
- * Replaces the `PanelUI.maxWidth/maxHeight` fields removed in IWSDK 0.5.
23
- * Omit to keep the markup's intrinsic size and scale via the entity transform.
24
- */
25
- maxWidth?: number;
26
- maxHeight?: number;
27
- movable?: boolean;
28
- closable?: boolean;
29
- minimizable?: boolean;
30
- pinnable?: boolean;
24
+ /** Keep the window yawed toward the viewer while it is being dragged. */
31
25
  billboardWhileDragging?: boolean;
32
- followOffset?: [number, number, number];
33
- followSpeed?: number;
34
- followTolerance?: number;
35
- /** Dock straight into this region on spawn. */
36
- region?: string;
37
26
  }
38
27
  export declare function createUIWindow(world: World, options: CreateWindowOptions): Entity;
39
28
  export interface CreateDockRegionOptions {
package/dist/factory.js CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { Follower, FollowBehavior, PanelUI, PokeInteractable, RayInteractable, } from '@iwsdk/core';
7
7
  import { UIDockRegion, UIDockedTo, UIWindow, RegionFlowType } from './components.js';
8
- import { DockMode } from '@realitycollective/webxr-uiextensions';
8
+ import { DockMode, } from '@realitycollective/webxr-uiextensions';
9
9
  export function createUIWindow(world, options) {
10
10
  const entity = world
11
11
  .createTransformEntity()
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,eAAe,GAGh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to spawn a managed window or dock region.\n * Thin sugar over `createTransformEntity().addComponent(...)`; everything\n * they do can be done manually with the components.\n */\nimport {\n Follower,\n FollowBehavior,\n PanelUI,\n PokeInteractable,\n RayInteractable,\n type Entity,\n type World,\n} from '@iwsdk/core';\nimport { UIDockRegion, UIDockedTo, UIWindow, RegionFlowType } from './components.js';\nimport { DockMode, type DockModeValue } from '@realitycollective/webxr-uiextensions';\n\nexport interface CreateWindowOptions {\n /**\n * URL of the UIKitML source (e.g. \"/ui/my-window.uikitml\"). IWSDK 0.5 parses\n * UIKitML at runtime - the build-time plugin and its generated JSON are gone.\n */\n config: string;\n id?: string;\n title?: string;\n dockMode?: DockModeValue;\n /** World position for world-locked windows. */\n position?: [number, number, number];\n /**\n * Fit the panel into this world-space box (meters), preserving aspect ratio.\n * Replaces the `PanelUI.maxWidth/maxHeight` fields removed in IWSDK 0.5.\n * Omit to keep the markup's intrinsic size and scale via the entity transform.\n */\n maxWidth?: number;\n maxHeight?: number;\n movable?: boolean;\n closable?: boolean;\n minimizable?: boolean;\n pinnable?: boolean;\n billboardWhileDragging?: boolean;\n followOffset?: [number, number, number];\n followSpeed?: number;\n followTolerance?: number;\n /** Dock straight into this region on spawn. */\n region?: string;\n}\n\nexport function createUIWindow(world: World, options: CreateWindowOptions): Entity {\n const entity = world\n .createTransformEntity()\n .addComponent(PanelUI, {\n config: options.config,\n })\n .addComponent(UIWindow, {\n // Applied by UIWindowSystem once the document loads - see components.ts.\n targetWidth: options.maxWidth ?? 0,\n targetHeight: options.maxHeight ?? 0,\n windowId: options.id ?? '',\n title: options.title ?? '',\n dockMode: options.dockMode ?? DockMode.WorldLocked,\n movable: options.movable ?? true,\n closable: options.closable ?? true,\n minimizable: options.minimizable ?? true,\n pinnable: options.pinnable ?? true,\n billboardWhileDragging: options.billboardWhileDragging ?? true,\n followOffset: options.followOffset ?? [0, -0.15, -1.2],\n followSpeed: options.followSpeed ?? 3,\n followTolerance: options.followTolerance ?? 0.35,\n })\n .addComponent(RayInteractable)\n .addComponent(PokeInteractable);\n\n if (options.position) {\n entity.object3D?.position.set(...options.position);\n }\n if (options.region) {\n entity.addComponent(UIDockedTo, { regionId: options.region });\n }\n return entity;\n}\n\nexport interface CreateDockRegionOptions {\n id: string;\n flow?: (typeof RegionFlowType)[keyof typeof RegionFlowType];\n pitch?: number;\n columns?: number;\n capacity?: number;\n snapRadius?: number;\n /** World position of the region origin. */\n position?: [number, number, number];\n /**\n * Body-lock the region itself: it follows the player's head at\n * `followOffset`, and every window docked into it comes along.\n */\n follow?: boolean;\n followOffset?: [number, number, number];\n}\n\nexport function createDockRegion(world: World, options: CreateDockRegionOptions): Entity {\n const entity = world.createTransformEntity().addComponent(UIDockRegion, {\n regionId: options.id,\n flow: options.flow ?? RegionFlowType.Column,\n pitch: options.pitch ?? 0.35,\n columns: options.columns ?? 2,\n capacity: options.capacity ?? 0,\n snapRadius: options.snapRadius ?? 0.5,\n });\n if (options.position) {\n entity.object3D?.position.set(...options.position);\n }\n if (options.follow) {\n entity.addComponent(Follower, {\n // Camera, not player.head - the head rig is origin-locked outside XR.\n target: world.camera,\n offsetPosition: options.followOffset ?? [0, -0.2, -1.4],\n behavior: FollowBehavior.PivotY,\n });\n }\n return entity;\n}\n"]}
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,eAAe,GAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EACL,QAAQ,GAET,MAAM,uCAAuC,CAAC;AAqB/C,MAAM,UAAU,cAAc,CAAC,KAAY,EAAE,OAA4B;IACvE,MAAM,MAAM,GAAG,KAAK;SACjB,qBAAqB,EAAE;SACvB,YAAY,CAAC,OAAO,EAAE;QACrB,MAAM,EAAE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AY,EAAE,OAAgC;IAC7E,MAAM,MAAM,GAAG,KAAK,CAAC,qBAAqB,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE;QACtE,QAAQ,EAAE,OAAO,CAAC,EAAE;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,cAAc,CAAC,MAAM;QAC3C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI;QAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC;QAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;QAC/B,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,GAAG;KACtC,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE;YAC5B,sEAAsE;YACtE,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,cAAc,EAAE,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;YACvD,QAAQ,EAAE,cAAc,CAAC,MAAM;SAChC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Convenience factories - one call to spawn a managed window or dock region.\n * Thin sugar over `createTransformEntity().addComponent(...)`; everything\n * they do can be done manually with the components.\n */\nimport {\n Follower,\n FollowBehavior,\n PanelUI,\n PokeInteractable,\n RayInteractable,\n type Entity,\n type World,\n} from '@iwsdk/core';\nimport { UIDockRegion, UIDockedTo, UIWindow, RegionFlowType } from './components.js';\nimport {\n DockMode,\n type WindowOptionsBase,\n} from '@realitycollective/webxr-uiextensions';\n\n/**\n * Options for {@link createUIWindow}.\n *\n * Everything but `config` comes from the portable {@link WindowOptionsBase},\n * so the same option names mean the same thing on every adapter. `maxWidth`\n * and `maxHeight` route to `UIWindow.targetWidth/Height` here, because IWSDK\n * 0.5 removed those fields from `PanelUI`; omit them to keep the markup's\n * intrinsic size and scale through the entity transform.\n */\nexport interface CreateWindowOptions extends WindowOptionsBase {\n /**\n * URL of the UIKitML source (e.g. \"/ui/my-window.uikitml\"). IWSDK 0.5 parses\n * UIKitML at runtime - the build-time plugin and its generated JSON are gone.\n */\n config: string;\n /** Keep the window yawed toward the viewer while it is being dragged. */\n billboardWhileDragging?: boolean;\n}\n\nexport function createUIWindow(world: World, options: CreateWindowOptions): Entity {\n const entity = world\n .createTransformEntity()\n .addComponent(PanelUI, {\n config: options.config,\n })\n .addComponent(UIWindow, {\n // Applied by UIWindowSystem once the document loads - see components.ts.\n targetWidth: options.maxWidth ?? 0,\n targetHeight: options.maxHeight ?? 0,\n windowId: options.id ?? '',\n title: options.title ?? '',\n dockMode: options.dockMode ?? DockMode.WorldLocked,\n movable: options.movable ?? true,\n closable: options.closable ?? true,\n minimizable: options.minimizable ?? true,\n pinnable: options.pinnable ?? true,\n billboardWhileDragging: options.billboardWhileDragging ?? true,\n followOffset: options.followOffset ?? [0, -0.15, -1.2],\n followSpeed: options.followSpeed ?? 3,\n followTolerance: options.followTolerance ?? 0.35,\n })\n .addComponent(RayInteractable)\n .addComponent(PokeInteractable);\n\n if (options.position) {\n entity.object3D?.position.set(...options.position);\n }\n if (options.region) {\n entity.addComponent(UIDockedTo, { regionId: options.region });\n }\n return entity;\n}\n\nexport interface CreateDockRegionOptions {\n id: string;\n flow?: (typeof RegionFlowType)[keyof typeof RegionFlowType];\n pitch?: number;\n columns?: number;\n capacity?: number;\n snapRadius?: number;\n /** World position of the region origin. */\n position?: [number, number, number];\n /**\n * Body-lock the region itself: it follows the player's head at\n * `followOffset`, and every window docked into it comes along.\n */\n follow?: boolean;\n followOffset?: [number, number, number];\n}\n\nexport function createDockRegion(world: World, options: CreateDockRegionOptions): Entity {\n const entity = world.createTransformEntity().addComponent(UIDockRegion, {\n regionId: options.id,\n flow: options.flow ?? RegionFlowType.Column,\n pitch: options.pitch ?? 0.35,\n columns: options.columns ?? 2,\n capacity: options.capacity ?? 0,\n snapRadius: options.snapRadius ?? 0.5,\n });\n if (options.position) {\n entity.object3D?.position.set(...options.position);\n }\n if (options.follow) {\n entity.addComponent(Follower, {\n // Camera, not player.head - the head rig is origin-locked outside XR.\n target: world.camera,\n offsetPosition: options.followOffset ?? [0, -0.2, -1.4],\n behavior: FollowBehavior.PivotY,\n });\n }\n return entity;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from '@realitycollective/webxr-uiextensions';
14
14
  export * from './components.js';
15
15
  export * from './manager-registry.js';
16
16
  export * from './region-registry-store.js';
17
+ export * from './component-set.js';
17
18
  export * from './factory.js';
18
19
  export * from './scene-host.js';
19
20
  export * from './register.js';
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ export * from '@realitycollective/webxr-uiextensions';
16
16
  export * from './components.js';
17
17
  export * from './manager-registry.js';
18
18
  export * from './region-registry-store.js';
19
+ export * from './component-set.js';
19
20
  export * from './factory.js';
20
21
  export * from './scene-host.js';
21
22
  export * from './register.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,sEAAsE;AACtE,cAAc,uCAAuC,CAAC;AAEtD,oBAAoB;AACpB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC","sourcesContent":["/**\n * @realitycollective/iwsdk-uiextensions - the Meta IWSDK adapter.\n *\n * The engine-free UX core (window manager, dock state, region math, drag\n * math, control models, markup upgraders, adapter interfaces) lives in\n * `@realitycollective/webxr-uiextensions` and is re-exported here in full,\n * so this package remains a drop-in single dependency for IWSDK apps.\n *\n * What this package adds is the IWSDK binding: ECS components + systems\n * that apply the core onto `@iwsdk/core` entities, plus the one-call\n * factories and `registerUIExtensions`.\n */\n// The portable core - re-exported for a single-dependency experience.\nexport * from '@realitycollective/webxr-uiextensions';\n\n// IWSDK ECS binding\nexport * from './components.js';\nexport * from './manager-registry.js';\nexport * from './region-registry-store.js';\nexport * from './factory.js';\nexport * from './scene-host.js';\nexport * from './register.js';\nexport * from './systems/window-system.js';\nexport * from './systems/dock-system.js';\nexport * from './systems/drag-system.js';\nexport * from './systems/dock-region-system.js';\nexport * from './systems/controls-system.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,sEAAsE;AACtE,cAAc,uCAAuC,CAAC;AAEtD,oBAAoB;AACpB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC","sourcesContent":["/**\n * @realitycollective/iwsdk-uiextensions - the Meta IWSDK adapter.\n *\n * The engine-free UX core (window manager, dock state, region math, drag\n * math, control models, markup upgraders, adapter interfaces) lives in\n * `@realitycollective/webxr-uiextensions` and is re-exported here in full,\n * so this package remains a drop-in single dependency for IWSDK apps.\n *\n * What this package adds is the IWSDK binding: ECS components + systems\n * that apply the core onto `@iwsdk/core` entities, plus the one-call\n * factories and `registerUIExtensions`.\n */\n// The portable core - re-exported for a single-dependency experience.\nexport * from '@realitycollective/webxr-uiextensions';\n\n// IWSDK ECS binding\nexport * from './components.js';\nexport * from './manager-registry.js';\nexport * from './region-registry-store.js';\nexport * from './component-set.js';\nexport * from './factory.js';\nexport * from './scene-host.js';\nexport * from './register.js';\nexport * from './systems/window-system.js';\nexport * from './systems/dock-system.js';\nexport * from './systems/drag-system.js';\nexport * from './systems/dock-region-system.js';\nexport * from './systems/controls-system.js';\n"]}
@@ -11,11 +11,32 @@
11
11
  *
12
12
  * Readiness is detected with a single ECS query on `PanelUI + PanelDocument`
13
13
  * - the engine-specific mechanism stays here, behind the portable interface.
14
+ * Bare panels (a `PanelUI` entity with no `UIWindow`) are announced too, with
15
+ * `kind: 'panel'` and their config path as the id, so devtools and hand-built
16
+ * entities show up in the same stream as managed windows.
14
17
  */
15
- import { type World } from '@iwsdk/core';
16
- import { type SceneTarget, type WindowHost } from '@realitycollective/webxr-uiextensions';
18
+ import { type Entity, type World } from '@iwsdk/core';
19
+ import { type PanelHandle, type SceneTarget, type WindowHandle, type WindowHost } from '@realitycollective/webxr-uiextensions';
20
+ import { type CreateWindowOptions } from './factory.js';
21
+ /**
22
+ * The live panel on an entity, or `undefined` while IWSDK is still loading
23
+ * its document. Use it to reach a panel from an entity you already hold;
24
+ * `onPanelReady` stays the way to be TOLD when one appears.
25
+ */
26
+ export declare function getPanelHandle(entity: Entity): PanelHandle | undefined;
27
+ /** A window spawned by {@link IwsdkSceneHost.createWindow}. */
28
+ export interface IwsdkWindowHandle extends WindowHandle {
29
+ /** The ECS entity carrying `PanelUI`, `UIWindow` and the interaction tags. */
30
+ readonly entity: Entity;
31
+ }
17
32
  export interface IwsdkSceneHost extends WindowHost, SceneTarget {
18
33
  readonly world: World;
34
+ /**
35
+ * Spawn a managed window and get a handle back straight away. IWSDK loads
36
+ * the markup over later frames, so `handle.panel` is `undefined` at first
37
+ * and `handle.onReady` is how you wait for it without an ECS query.
38
+ */
39
+ createWindow(options: CreateWindowOptions): IwsdkWindowHandle;
19
40
  }
20
41
  /**
21
42
  * Create the host for a world. Call AFTER `registerUIExtensions(world)`.
@@ -11,10 +11,13 @@
11
11
  *
12
12
  * Readiness is detected with a single ECS query on `PanelUI + PanelDocument`
13
13
  * - the engine-specific mechanism stays here, behind the portable interface.
14
+ * Bare panels (a `PanelUI` entity with no `UIWindow`) are announced too, with
15
+ * `kind: 'panel'` and their config path as the id, so devtools and hand-built
16
+ * entities show up in the same stream as managed windows.
14
17
  */
15
18
  import { PanelDocument, PanelUI, createSystem, } from '@iwsdk/core';
16
19
  import { upgradePanel, } from '@realitycollective/webxr-uiextensions';
17
- import { createDockRegion, createUIWindow } from './factory.js';
20
+ import { createDockRegion, createUIWindow, } from './factory.js';
18
21
  import { UIWindow } from './components.js';
19
22
  /** Panel handle over an IWSDK `UIKitDocument`. */
20
23
  function panelHandleFor(document) {
@@ -29,6 +32,15 @@ function panelHandleFor(document) {
29
32
  },
30
33
  };
31
34
  }
35
+ /**
36
+ * The live panel on an entity, or `undefined` while IWSDK is still loading
37
+ * its document. Use it to reach a panel from an entity you already hold;
38
+ * `onPanelReady` stays the way to be TOLD when one appears.
39
+ */
40
+ export function getPanelHandle(entity) {
41
+ const document = PanelDocument.data.document[entity.index];
42
+ return document ? panelHandleFor(document) : undefined;
43
+ }
32
44
  /**
33
45
  * Bridges panel loading into `onPanelReady`. Registered once per host; the
34
46
  * query fires as each panel's document is attached by IWSDK's UI system.
@@ -56,18 +68,19 @@ export function createSceneHost(world) {
56
68
  return;
57
69
  }
58
70
  seen.add(document);
59
- // Window id comes from the UIWindow component the factory attached.
60
- const id = entity.hasComponent(UIWindow)
71
+ // Window id comes from the UIWindow component the factory attached. A
72
+ // panel without one is a bare panel - still worth announcing, keyed by
73
+ // its config path, which is the only stable id IWSDK gives it.
74
+ const windowId = entity.hasComponent(UIWindow)
61
75
  ? UIWindow.data.windowId[entity.index]
62
76
  : '';
63
- if (!id) {
64
- return; // a bare panel, not a managed window - nothing to wire by id
65
- }
77
+ const kind = windowId ? 'window' : 'panel';
78
+ const id = windowId || PanelUI.data.config[entity.index];
66
79
  const panel = panelHandleFor(document);
67
80
  // Upgrade `data-uix` controls exactly as the ECS controls system does,
68
81
  // so wiring code sees the same handles on every adapter (idempotent).
69
82
  upgradePanel(document, document.rootElement);
70
- const event = { id, panel };
83
+ const event = { id, panel, kind };
71
84
  ready.set(id, event);
72
85
  for (const listener of readyListeners) {
73
86
  try {
@@ -79,8 +92,12 @@ export function createSceneHost(world) {
79
92
  }
80
93
  };
81
94
  world.registerSystem(createReadySystem(announce));
82
- return {
95
+ let windowSequence = 0;
96
+ const host = {
83
97
  world,
98
+ // IWSDK owns panel lifecycles through the ECS, so there is no bare-panel
99
+ // path here - `createPanel` throws rather than half-working.
100
+ supportsStandalonePanels: false,
84
101
  createPanel() {
85
102
  throw new Error('[uix] createPanel() is not supported on the IWSDK host - spawn a window ' +
86
103
  '(spawnWindow/createUIWindow) so IWSDK owns the panel lifecycle.');
@@ -92,6 +109,33 @@ export function createSceneHost(world) {
92
109
  }
93
110
  return () => void readyListeners.delete(listener);
94
111
  },
112
+ createWindow(options) {
113
+ const id = options.id ?? `uix-window-${(windowSequence += 1)}`;
114
+ const entity = createUIWindow(world, { ...options, id });
115
+ return {
116
+ entity,
117
+ id,
118
+ get panel() {
119
+ return ready.get(id)?.panel;
120
+ },
121
+ onReady(listener) {
122
+ const existing = ready.get(id)?.panel;
123
+ if (existing) {
124
+ listener(existing);
125
+ return () => { };
126
+ }
127
+ // `onPanelReady` replays panels that are already live, but this id
128
+ // is not one of them, so the callback only ever runs later.
129
+ const unsubscribe = host.onPanelReady((event) => {
130
+ if (event.id === id) {
131
+ unsubscribe();
132
+ listener(event.panel);
133
+ }
134
+ });
135
+ return unsubscribe;
136
+ },
137
+ };
138
+ },
95
139
  spawnRegion(region) {
96
140
  createDockRegion(world, {
97
141
  id: region.id,
@@ -112,7 +156,7 @@ export function createSceneHost(world) {
112
156
  });
113
157
  },
114
158
  spawnWindow(window) {
115
- createUIWindow(world, {
159
+ host.createWindow({
116
160
  id: window.id,
117
161
  title: window.title,
118
162
  config: window.config,
@@ -141,5 +185,6 @@ export function createSceneHost(world) {
141
185
  });
142
186
  },
143
187
  };
188
+ return host;
144
189
  }
145
190
  //# sourceMappingURL=scene-host.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scene-host.js","sourceRoot":"","sources":["../src/scene-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,aAAa,EACb,OAAO,EAEP,YAAY,GAGb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,GAQb,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAChE,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;;;GAGG;AACH,SAAS,iBAAiB,CAAC,OAAiC;IAC1D,OAAO,MAAM,mBAAoB,SAAQ,YAAY,CAAC;QACpD,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE;KAC/C,CAAC;QACS,IAAI;YACX,IAAI,C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AE,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;AACJ,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 */\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 WindowHost,\n} from '@realitycollective/webxr-uiextensions';\nimport { createDockRegion, createUIWindow } 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 * 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\nexport interface IwsdkSceneHost extends WindowHost, SceneTarget {\n readonly world: World;\n}\n\n/**\n * Create the host for a world. Call AFTER `registerUIExtensions(world)`.\n */\nexport function createSceneHost(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.\n const id = entity.hasComponent(UIWindow)\n ? (UIWindow.data.windowId[entity.index] as string)\n : '';\n if (!id) {\n return; // a bare panel, not a managed window - nothing to wire by id\n }\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 };\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 return {\n world,\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 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 createUIWindow(world, {\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"]}
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;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E,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\n/**\n * Create the host for a world. Call AFTER `registerUIExtensions(world)`.\n */\nexport function createSceneHost(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"]}
@@ -80,14 +80,6 @@ declare const UIWindowSystem_base: import("elics").SystemConstructor<import("eli
80
80
  type: import("@iwsdk/core").Types.String;
81
81
  default: string;
82
82
  };
83
- maxWidth: {
84
- type: import("@iwsdk/core").Types.Float32;
85
- default: number;
86
- };
87
- maxHeight: {
88
- type: import("@iwsdk/core").Types.Float32;
89
- default: number;
90
- };
91
83
  }> | import("elics").Component<{
92
84
  document: {
93
85
  type: import("@iwsdk/core").Types.Object;
@@ -293,14 +285,6 @@ declare const UIWindowSystem_base: import("elics").SystemConstructor<import("eli
293
285
  type: import("@iwsdk/core").Types.String;
294
286
  default: string;
295
287
  };
296
- maxWidth: {
297
- type: import("@iwsdk/core").Types.Float32;
298
- default: number;
299
- };
300
- maxHeight: {
301
- type: import("@iwsdk/core").Types.Float32;
302
- default: number;
303
- };
304
288
  }> | import("elics").Component<{
305
289
  document: {
306
290
  type: import("@iwsdk/core").Types.Object;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realitycollective/iwsdk-uiextensions",
3
- "version": "0.1.0-preview.0",
3
+ "version": "0.1.0-preview.2",
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",
@@ -36,16 +36,18 @@
36
36
  "typecheck": "tsc -p tsconfig.json --noEmit"
37
37
  },
38
38
  "dependencies": {
39
+ "@drawcall/uikitml": "0.1.8",
40
+ "zod": "^4.4.3",
39
41
  "@pmndrs/handle": "^6.6.16",
40
- "@realitycollective/webxr-uiextensions": "^0.1.0-preview.0"
42
+ "@realitycollective/webxr-uiextensions": "^0.1.0-preview.2"
41
43
  },
42
44
  "peerDependencies": {
43
- "@iwsdk/core": ">=0.4.0 <0.6.0"
45
+ "@iwsdk/core": ">=0.5.0 <0.6.0"
44
46
  },
45
47
  "devDependencies": {
46
- "@iwsdk/core": "0.4.2",
48
+ "@iwsdk/core": "0.5.3",
47
49
  "three": "npm:super-three@0.181.0",
48
- "@types/three": "*"
50
+ "@types/three": "0.184.0"
49
51
  },
50
52
  "repository": {
51
53
  "type": "git",