@omnitron-dev/lumen-ui 0.4.6 → 0.4.8

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/README.md CHANGED
@@ -1,29 +1,20 @@
1
1
  # @omnitron-dev/lumen-ui
2
2
 
3
- React components for Lumen documentation: a shared Prism context, selectively
4
- activated interactive islands, navigation, document blocks, search and sandboxed
5
- code execution. The `@omnitron-dev/lumen` builder bundles this runtime with Vite;
6
- it does not generate a second implementation of these components.
3
+ React components for Lumen documentation: navigation, document blocks, search and interactive islands that share the host's Prism context. Use the Lumen CLI for a complete site, or embed this package in an existing React application.
7
4
 
8
- Requires React/React DOM 19. For a complete site, start with the Lumen CLI. Use
9
- this package directly when embedding documentation in an existing React app.
5
+ ## Capabilities
10
6
 
11
- ## Public entry points
7
+ - A shared document shell and selective island activation.
8
+ - Document tabs preserve labelled sections in static HTML. The shell adds Prism tabs with keyboard selection, fragment navigation and optional same-page synchronization through `syncKey`.
9
+ - Navigation, mathematical blocks, code examples and reference cards.
10
+ - Pagefind and Netron search adapters.
11
+ - Mermaid diagrams and host-controlled API or Netron playgrounds.
12
12
 
13
- | Import | Purpose |
14
- | --- | --- |
15
- | `@omnitron-dev/lumen-ui` | All public components, adapters and types, including `ApiExplorer`, `MermaidDiagram` and `NetronPlayground`. |
16
- | `@omnitron-dev/lumen-ui/runtime` | `LumenShell`, `PortalIslandHost`, `PortalIslandManager`, `useLumen` and activation triggers. |
17
- | `@omnitron-dev/lumen-ui/layout` | `LumenNavbar`, `LumenFooter`, `DocLayout`, `DocSectionNav` and `DocPagination`. |
18
- | `@omnitron-dev/lumen-ui/blocks` | `MathTheoremBlock`, `HoverReferenceCard`, `CodeBlock`, `BacklinksSection` and `PageAgentActions`. |
19
- | `@omnitron-dev/lumen-ui/search` | `LumenSearchDialog`, `PagefindAdapter`, `NetronAdapter` and their contracts. |
13
+ ## Quick start
20
14
 
21
- The layout components expose semantic markup and `lumen-*` CSS classes. The
22
- site builder supplies the default stylesheet; an embedding app owns its layout
23
- styles. `LumenShell` supplies Prism by default. Set `disablePrismProvider` when
24
- the host application already owns that provider, to retain its theme and cache.
25
-
26
- ## One context, selective activation
15
+ ```sh
16
+ pnpm add @omnitron-dev/lumen-ui react react-dom
17
+ ```
27
18
 
28
19
  ```tsx
29
20
  import { useState } from 'react';
@@ -38,7 +29,7 @@ export function Documentation() {
38
29
  return (
39
30
  <LumenShell theme="dark" locale="en" currentPath="/guide" islands={{ Counter }}>
40
31
  <PortalIslandHost
41
- islandId="example-counter"
32
+ islandId="guide-counter"
42
33
  component="Counter"
43
34
  hydrate="visible"
44
35
  props={{ initial: 3 }}
@@ -50,134 +41,54 @@ export function Documentation() {
50
41
  }
51
42
  ```
52
43
 
53
- The host renders static fallback content and serialized props. The manager
54
- mounts the registered React component into that element when its trigger fires;
55
- it retains the shell's context. This is portal mounting, not independent React
56
- roots or hydration of arbitrary third-party HTML. Keep one manager per document.
57
- Use unique island IDs and explicit component names. Props use the shared
58
- `lumen-ast/islands` plain-JSON contract (256 KiB, 64 levels). Cycles, accessors,
59
- BigInt and values JSON cannot preserve are errors; repeated references remain
60
- valid. Invalid DOM metadata displays a local error without mounting the
61
- component with empty props. Corrected metadata can recover; changes to props
62
- and triggers on an existing element are observed. Unknown components retain
63
- their static content until registered; replacing a DOM element creates a new
64
- activation lifecycle, even when it reuses the old ID.
65
-
66
- Triggers are `load`, `visible`, `interaction` and `idle` (the default). A custom
67
- `on<Event>` trigger listens for the lowercased event name. `interaction` includes
68
- pointer, touch and keyboard/focus events. `useLumen()` exposes the current theme,
69
- locale and path, `registerIsland(name, component)`, `getIsland(name)`,
70
- `hydrateIsland(idOrComponentName)` and the active island IDs. The registry
71
- contains application code: do not populate it from untrusted document imports.
72
-
73
- ## Search
44
+ React and React DOM 19 are required. The Lumen builder supplies default layout styles; embedding applications own their styles. `LumenShell` supplies Prism by default. Set `disablePrismProvider` when the host already owns that provider.
45
+
46
+ ## Current section navigation
47
+
48
+ `DocSectionNav` from `/layout` renders native anchor links on the server. Mount it as an island to track the current section of an existing document:
74
49
 
75
50
  ```tsx
76
- import { useState } from 'react';
77
- import { LumenSearchDialog } from '@omnitron-dev/lumen-ui/search';
78
-
79
- export function Search() {
80
- const [open, setOpen] = useState(false);
81
- return <>
82
- <button onClick={() => setOpen(true)}>Search documentation</button>
83
- <LumenSearchDialog
84
- open={open}
85
- onClose={() => setOpen(false)}
86
- pagefindUrl="/pagefind/pagefind.js"
87
- maxResults={10}
88
- />
89
- </>;
90
- }
51
+ <PortalIslandHost islandId="page-toc" component="DocSectionNav" hydrate="load" props={{ headings }}>
52
+ <DocSectionNav headings={headings} />
53
+ </PortalIslandHost>
91
54
  ```
92
55
 
93
- The dialog focuses the input, contains keyboard focus, closes on Escape and
94
- restores the prior focus when removed. Requests are debounced and stale results
95
- are ignored. Service/index failures are visible errors, distinct from a valid
96
- query with no matches. Snippets are rendered as escaped text with supported
97
- highlight marks; result links pass URL validation.
98
-
99
- `PagefindAdapter` imports the configured generated Pagefind module, with one
100
- concurrent initialization per adapter. It never substitutes `window.pagefind`
101
- or permanently poisons another adapter after a failure. A subsequent search can
102
- retry failed initialization. `search(query, maxResults)` accepts up to 4 KiB of
103
- UTF-8 text and 0–100 results; empty queries and a zero limit do not load an index.
104
- The module URL is trusted application configuration, not a user-entered URL.
105
- Serve the generated Pagefind JS/WASM/index assets alongside the site, including
106
- the correct base path when hosting under a subdirectory.
107
-
108
- For live search, pass `rpcClient` obtained through the application's existing
109
- Netron query. Its structural contract is `search(query, { limit })`, returning
110
- `{ documentId, title, path, snippet, score }[]`. `NetronAdapter` performs only the
111
- UI mapping; it does not open another transport or authenticate independently.
112
- The live-search tab appears only when this client is present. Authorization and
113
- corpus projection remain in `LumenService`, not in a browser role list. Index
114
- exclusion and UI filtering are not access-control boundaries.
115
-
116
- ## Executable examples
56
+ Each heading has `{ id, title, level }` and must refer to a real document anchor. The default Lumen client registers this component; custom clients add `DocSectionNav` to their existing `LumenShell` island registry. Style `[aria-current="location"]` or `.is-active` in the host stylesheet.
57
+
58
+ `DocPagination` from `/layout` renders native previous and next links with the document titles and directional Prism icons. Pass each available neighbour as `{ href, label }`. Set `labels={{ navigation, previous, next }}` to translate the landmark and directions. The links work before hydration and follow the document's reading direction.
59
+
60
+ The shared Prism scrollspy tracks the last section start above the reading line, including long sections and the final short section at the bottom. CSS `scroll-padding-top` on the scrolling element and `scroll-margin-top` on headings account for fixed headers; an explicit `offset` overrides the reading-line padding. Native links retain keyboard behavior and browser history, with no forced smooth scrolling. An explicit anchor destination near the bottom remains selected until the reader scrolls. Supplying `activeId` instead makes the indicator controlled by the host.
61
+
62
+ ## Live component examples
63
+
64
+ `ComponentExample` from `@omnitron-dev/lumen-ui/blocks` displays a trusted component and the source used to build it. With Vite, import that module normally for its preview and with `?raw` for its source.
117
65
 
118
66
  ```tsx
119
- import { NetronPlayground } from '@omnitron-dev/lumen-ui';
67
+ import { ComponentExample } from '@omnitron-dev/lumen-ui/blocks';
68
+ import Counter from './counter';
69
+ import source from './counter.tsx?raw';
120
70
 
121
- <NetronPlayground code="return [1, 2, 3].map(value => value * 2)" />;
71
+ <ComponentExample title="Counter" code={source} resettable>
72
+ <Counter />
73
+ </ComponentExample>
122
74
  ```
123
75
 
124
- Local runs load the shipped ESM worker and the shared Lumen QuickJS WASM
125
- interpreter. Each run has an independent worker, a bounded deadline (1–5000 ms,
126
- including startup), and a 64 KiB code/output limit. There is no host-window
127
- JavaScript evaluator, network/storage capability or successful fallback after
128
- an execution failure. `snapshot` is optional recorded output, labelled
129
- separately; it never substitutes for execution. `readOnly` prevents editing and
130
- execution, and `onExecute` receives `{ code, result, error?, executionTimeMs }`.
131
-
132
- For server execution, pass `mode="server"` and
133
- `execute={code => lumenService.executePlayground(code)}`, where `lumenService`
134
- is obtained through the existing Netron query. The service result is
135
- `{ code, result, error? }`. Netron enforces authentication and permissions.
136
- The UI deadline stops waiting; the server enforces its own execution limits.
137
- A missing server executor is an error, not a switch to local execution.
138
-
139
- The production bundler must process
140
- `new Worker(new URL(..., import.meta.url), { type: 'module' })` and retain the
141
- emitted worker asset. Lumen's Vite build does this. CSP needs `worker-src 'self'`
142
- and WebAssembly compilation permission
143
- (`script-src 'self' 'wasm-unsafe-eval'`); host JavaScript string evaluation and
144
- Blob workers are not required.
145
-
146
- ## Diagrams
147
-
148
- `MermaidDiagram` accepts `code`, runs the actual Mermaid/ELK browser engine and
149
- uses the current Prism/MUI palette. The default Lumen client registers this
150
- island for Mermaid fences; a custom `LumenShell` registry must register it too.
151
- Loading, syntax errors and the original source are visible. No alternate graph
152
- renderer fabricates a successful result for unsupported syntax. Theme changes
153
- rerender the same source. Without JavaScript the static page retains its source
154
- fallback. See `lumen-ast/diagrams` for admission, source/output limits and the
155
- browser execution boundary.
156
-
157
- ## Navigation and document blocks
158
-
159
- - `DocLayout` accepts document children, sidebar and section-navigation slots.
160
- `LumenNavbar` accepts links, version/locale choices and callbacks for search,
161
- theme and selection. The host owns URL changes and persisted preferences.
162
- - `ApiExplorer` displays supplied symbol/method metadata and emits
163
- `onSelectSymbol`. Arrow keys, Home/End and Page Up/Down navigate the windowed
164
- symbol list; Enter/Space select. `tags` are informational labels. It is a documentation view; it does not fetch an OpenAPI
165
- specification or invoke methods based on an endpoint string.
166
- - `MathTheoremBlock` renders an identified mathematical environment and a proof
167
- terminator. Parsing, numbering, access projection and graph validation belong
168
- to `lumen-ast` and the builder. The block does not prove a theorem.
169
- - `CodeBlock` renders escaped source; `copyable` enables the shared Prism clipboard
170
- action with success/failure feedback. `BacklinksSection` and
171
- `HoverReferenceCard` display supplied references. `PageAgentActions` links to
172
- the clean Markdown mirror for the supplied path; that mirror must be produced
173
- and authorized by the builder/service.
174
-
175
- ## Verification
176
-
177
- Build this package and its dependencies before running `test:browser`.
178
- Production-browser tests execute the bundled module and actual interpreter in
179
- Chromium, including constructor access, host storage/network isolation,
180
- allocation/output limits, worker termination and recovery. Unit tests cover UI
181
- state and lifecycle. The website's separate acceptance covers generated pages,
182
- real Pagefind search, themes and narrow viewports. Passing component tests alone
183
- does not establish accessibility or performance for every consuming application.
76
+ Both the preview and source render on the server. The native source disclosure works with a keyboard and with JavaScript disabled. After hydration, `resettable` lets readers restore the preview's initial state while keeping the source open. Set `language` for a non-TSX module and translate the control labels through `labels.source` and `labels.reset`.
77
+
78
+ ## Runtime boundaries
79
+
80
+ Islands mount through portals into static hosts, preserving the shell's context. They do not create independent React roots or hydrate arbitrary third-party HTML. Use one manager per document, unique island IDs and host-owned component registrations. Activation supports `load`, `visible`, `interaction` and `idle`.
81
+
82
+ Props use the shared Lumen AST JSON codec. Invalid metadata reports an error instead of mounting with empty props; unknown components retain their static fallback. Documents cannot register application code or grant network permissions. Live API and Netron playgrounds require explicit host capabilities and server authorization. Mermaid uses strict configuration and sanitized SVG images.
83
+
84
+ A component that throws while rendering shows an alert at its own island with its registered name and the error message. Other islands retain their state. Correcting the failed island's props or replacing its registered component retries that island.
85
+
86
+ ## Documentation
87
+
88
+ [Public API](src/index.ts) · [Package exports](package.json) · [Lumen](../lumen/README.md)
89
+
90
+ The `/runtime`, `/layout`, `/blocks` and `/search` entries expose their corresponding components without requiring a root import.
91
+
92
+ ## License
93
+
94
+ [MIT](../../LICENSE).
@@ -0,0 +1,16 @@
1
+ import React, { type ReactNode } from 'react';
2
+ export interface ComponentExampleProps {
3
+ title: string;
4
+ /** The build-time source of the trusted component supplied as children. */
5
+ code: string;
6
+ children: ReactNode;
7
+ language?: string;
8
+ resettable?: boolean;
9
+ labels?: {
10
+ source?: string;
11
+ reset?: string;
12
+ };
13
+ }
14
+ /** A rendered example and its exact source, both present in the server HTML. */
15
+ export declare function ComponentExample({ title, code, children, language, resettable, labels, }: ComponentExampleProps): React.JSX.Element;
16
+ //# sourceMappingURL=component-example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-example.d.ts","sourceRoot":"","sources":["../../src/blocks/component-example.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKzE,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9C;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAgB,EAAE,UAAkB,EAAE,MAAM,GACpE,EAAE,qBAAqB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA6B3C"}
@@ -1,6 +1,7 @@
1
1
  export * from './theorem-block.js';
2
2
  export * from './hover-reference-card.js';
3
3
  export * from './code-block.js';
4
+ export * from './component-example.js';
4
5
  export * from './backlinks.js';
5
6
  export * from './page-agent-actions.js';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  "use client";
2
- export { BacklinksSection, CodeBlock, HoverReferenceCard, MathTheoremBlock, PageAgentActions } from '../chunk-BUM4MVKF.js';
2
+ export { BacklinksSection, CodeBlock, ComponentExample, HoverReferenceCard, MathTheoremBlock, PageAgentActions } from '../chunk-XUGEOYWY.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,11 @@
1
1
  import { LumenContext } from './chunk-L2KGVOK3.js';
2
2
  import { parseHydrationTrigger, serializeIslandProps, parseIslandProps } from '@omnitron-dev/lumen-ast/islands';
3
- import React2, { useState, useRef, useEffect, useMemo, useCallback } from 'react';
3
+ import React3, { useState, useRef, useEffect, useMemo, useCallback, useId, useLayoutEffect } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
  import { PrismProvider } from '@omnitron-dev/prism/core';
6
- import { jsx } from 'react/jsx-runtime';
6
+ import { ErrorBoundary } from '@omnitron-dev/prism/components/error-boundary';
7
+ import { Tabs } from '@omnitron-dev/prism/components/tabs';
8
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
9
 
8
10
  function setupTrigger(element, trigger, onTrigger, options) {
9
11
  switch (parseHydrationTrigger(trigger)) {
@@ -111,7 +113,7 @@ function PortalIslandHost({
111
113
  className = "lumen-portal-island",
112
114
  style
113
115
  }) {
114
- return React2.createElement(
116
+ return React3.createElement(
115
117
  "div",
116
118
  {
117
119
  className,
@@ -124,6 +126,109 @@ function PortalIslandHost({
124
126
  children
125
127
  );
126
128
  }
129
+ var syncEvent = "lumen:document-tab-change";
130
+ function fragmentTarget(doc) {
131
+ const hash = doc.defaultView?.location.hash;
132
+ if (!hash) return null;
133
+ try {
134
+ return doc.getElementById(decodeURIComponent(hash.slice(1)));
135
+ } catch {
136
+ return null;
137
+ }
138
+ }
139
+ function DocumentTabs() {
140
+ const strip = useRef(null);
141
+ const instance = useId();
142
+ const [panels, setPanels] = useState([]);
143
+ const [selected, setSelected] = useState(0);
144
+ const group = strip.current?.closest(".lumen-tabs");
145
+ const syncKey = group?.dataset.syncKey;
146
+ useLayoutEffect(() => {
147
+ const container = strip.current?.closest(".lumen-tabs");
148
+ if (!container) return;
149
+ const sections = Array.from(container.querySelectorAll(":scope > .lumen-tab-item"));
150
+ const items = [];
151
+ for (const section of sections) {
152
+ const heading = section.querySelector(":scope > .lumen-tab-label");
153
+ if (!heading) return;
154
+ items.push({ section, heading, value: section.dataset.value ?? heading.textContent ?? "" });
155
+ }
156
+ const doc = container.ownerDocument;
157
+ const anchor = fragmentTarget(doc);
158
+ const peer = container.dataset.syncKey && Array.from(doc.querySelectorAll(".lumen-tabs[data-active-value]")).find((item) => item !== container && item.dataset.syncKey === container.dataset.syncKey);
159
+ const anchored = items.findIndex((item) => anchor && item.section.contains(anchor));
160
+ const anchorPanel = anchor?.closest(".lumen-tab-item");
161
+ const anchorGroup = anchorPanel?.parentElement;
162
+ const anchorValue = container.dataset.syncKey && anchorGroup?.dataset.syncKey === container.dataset.syncKey ? anchorPanel?.dataset.value : void 0;
163
+ const synced = items.findIndex((item) => item.value === (anchorValue ?? (peer && peer.dataset.activeValue)));
164
+ setSelected(anchored >= 0 ? anchored : Math.max(0, synced));
165
+ setPanels(items);
166
+ }, []);
167
+ useLayoutEffect(() => {
168
+ const tabs = strip.current?.querySelectorAll('[role="tab"]');
169
+ if (!group || !panels.length || tabs?.length !== panels.length) return void 0;
170
+ panels.forEach(({ section, heading }, index) => {
171
+ const tab = tabs[index];
172
+ section.id = `${instance}-panel-${index}`;
173
+ section.setAttribute("role", "tabpanel");
174
+ section.setAttribute("aria-labelledby", tab.id);
175
+ section.tabIndex = 0;
176
+ tab.setAttribute("aria-controls", section.id);
177
+ heading.hidden = true;
178
+ section.hidden = index !== selected;
179
+ });
180
+ group.dataset.activeValue = panels[selected].value;
181
+ return () => {
182
+ delete group.dataset.activeValue;
183
+ for (const { section, heading } of panels) {
184
+ section.hidden = false;
185
+ heading.hidden = false;
186
+ for (const attribute of ["id", "role", "aria-labelledby", "tabindex"]) section.removeAttribute(attribute);
187
+ }
188
+ };
189
+ }, [group, instance, panels, selected]);
190
+ useEffect(() => {
191
+ if (!group || !panels.length) return void 0;
192
+ const doc = group.ownerDocument;
193
+ const onSync = (event) => {
194
+ const choice = event.detail;
195
+ if (!choice || choice.key !== syncKey) return;
196
+ const index = panels.findIndex((item) => item.value === choice.value);
197
+ if (index >= 0) setSelected(index);
198
+ };
199
+ const onHashChange = () => {
200
+ const anchor = fragmentTarget(doc);
201
+ const index = panels.findIndex((item) => anchor && item.section.contains(anchor));
202
+ if (index >= 0) {
203
+ setSelected(index);
204
+ if (syncKey) doc.dispatchEvent(new CustomEvent(syncEvent, { detail: { key: syncKey, value: panels[index].value } }));
205
+ }
206
+ };
207
+ if (syncKey) doc.addEventListener(syncEvent, onSync);
208
+ doc.defaultView?.addEventListener("hashchange", onHashChange);
209
+ return () => {
210
+ if (syncKey) doc.removeEventListener(syncEvent, onSync);
211
+ doc.defaultView?.removeEventListener("hashchange", onHashChange);
212
+ };
213
+ }, [group, panels, syncKey]);
214
+ function select(value) {
215
+ const index = Number(value);
216
+ setSelected(index);
217
+ if (syncKey) group?.ownerDocument.dispatchEvent(new CustomEvent(syncEvent, { detail: { key: syncKey, value: panels[index].value } }));
218
+ }
219
+ return /* @__PURE__ */ jsx("div", { ref: strip, children: panels.length > 0 && /* @__PURE__ */ jsx(
220
+ Tabs,
221
+ {
222
+ "aria-label": group?.dataset.label || panels.map((item) => item.heading.textContent).join(" / "),
223
+ tabs: panels.map((item, index) => ({ label: item.heading.textContent ?? item.value, value: String(index) })),
224
+ value: String(selected),
225
+ onChange: select,
226
+ selectionFollowsFocus: true,
227
+ variant: "scrollable",
228
+ scrollButtons: "auto"
229
+ }
230
+ ) });
231
+ }
127
232
  var ISLAND_SELECTOR = ".lumen-portal-island, [data-lumen-island], [data-widget]";
128
233
  var globalElementInstanceCounter = 0;
129
234
  var elementInstanceKeys = /* @__PURE__ */ new WeakMap();
@@ -360,11 +465,26 @@ function PortalIslandManager({
360
465
  clearedSsrElementsRef.current.add(item.element);
361
466
  item.element.replaceChildren();
362
467
  }
363
- portals.push(createPortal(React2.createElement(Component, item.props), item.element, item.instanceKey));
468
+ portals.push(createPortal(
469
+ /* @__PURE__ */ jsx(
470
+ ErrorBoundary,
471
+ {
472
+ resetKeys: [Component, item.islandId, item.rawProps],
473
+ fallback: ({ error }) => /* @__PURE__ */ jsxs("p", { className: "lumen-island-error", role: "alert", children: [
474
+ item.componentName,
475
+ " could not render. ",
476
+ error.message
477
+ ] }),
478
+ children: React3.createElement(Component, item.props)
479
+ }
480
+ ),
481
+ item.element,
482
+ item.instanceKey
483
+ ));
364
484
  }
365
485
  }
366
486
  }
367
- return portals.length > 0 ? React2.createElement(React2.Fragment, null, ...portals) : null;
487
+ return portals.length > 0 ? React3.createElement(React3.Fragment, null, ...portals) : null;
368
488
  }
369
489
  function LumenShellProvider({
370
490
  children,
@@ -375,7 +495,7 @@ function LumenShellProvider({
375
495
  }) {
376
496
  const [dynamicIslands, setDynamicIslands] = useState({});
377
497
  const [activeIslands, setActiveIslands] = useState(() => /* @__PURE__ */ new Set());
378
- const mergedIslands = useMemo(() => ({ ...islands, ...dynamicIslands }), [islands, dynamicIslands]);
498
+ const mergedIslands = useMemo(() => ({ LumenDocumentTabs: DocumentTabs, ...islands, ...dynamicIslands }), [islands, dynamicIslands]);
379
499
  const latestRegistryRef = useRef(mergedIslands);
380
500
  latestRegistryRef.current = mergedIslands;
381
501
  const hydrateHandlerRef = useRef(null);
@@ -418,18 +538,18 @@ function LumenShellProvider({
418
538
  }),
419
539
  [theme, locale, currentPath, mergedIslands, registerIsland, getIsland, activeIslands, hydrateIsland]
420
540
  );
421
- const shellDiv = React2.createElement(
541
+ const shellDiv = React3.createElement(
422
542
  "div",
423
543
  { className: "lumen-shell", "data-theme": theme, "data-locale": locale },
424
544
  children,
425
- React2.createElement(PortalIslandManager, {
545
+ React3.createElement(PortalIslandManager, {
426
546
  registry: mergedIslands,
427
547
  onActiveIslandsChange: handleActiveIslandsChange,
428
548
  hydrateHandlerRef,
429
549
  pendingHydrateIdsRef
430
550
  })
431
551
  );
432
- return React2.createElement(LumenContext.Provider, { value: contextValue }, shellDiv);
552
+ return React3.createElement(LumenContext.Provider, { value: contextValue }, shellDiv);
433
553
  }
434
554
  function LumenShell({
435
555
  children,
@@ -440,7 +560,7 @@ function LumenShell({
440
560
  disablePrismProvider = false
441
561
  }) {
442
562
  const resolvedMode = theme === "light" ? "light" : "dark";
443
- const providerElement = React2.createElement(LumenShellProvider, {
563
+ const providerElement = React3.createElement(LumenShellProvider, {
444
564
  theme,
445
565
  locale,
446
566
  currentPath,
@@ -466,5 +586,5 @@ function LumenShell({
466
586
  }
467
587
 
468
588
  export { LumenShell, PortalIslandHost, PortalIslandManager, setupEventTrigger, setupIdleTrigger, setupInteractionTrigger, setupLoadTrigger, setupTrigger, setupVisibleTrigger };
469
- //# sourceMappingURL=chunk-XUNS2BMG.js.map
470
- //# sourceMappingURL=chunk-XUNS2BMG.js.map
589
+ //# sourceMappingURL=chunk-AQ5PPDEV.js.map
590
+ //# sourceMappingURL=chunk-AQ5PPDEV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hydration/triggers.ts","../src/hydration/host.tsx","../src/hydration/document-tabs.tsx","../src/hydration/shell.tsx"],"names":["React","parseHydrationTrigger","useState","useRef","useEffect","jsx"],"mappings":";;;;;;;;;AAsBO,SAAS,YAAA,CACd,OAAA,EACA,OAAA,EACA,SAAA,EACA,OAAA,EACgB;AAChB,EAAA,QAAQ,qBAAA,CAAsB,OAAO,CAAA;AAAG,IACtC,KAAK,MAAA;AACH,MAAA,OAAO,iBAAiB,SAAS,CAAA;AAAA,IAEnC,KAAK,SAAA;AACH,MAAA,OAAO,mBAAA,CAAoB,OAAA,EAAS,SAAA,EAAW,OAAO,CAAA;AAAA,IAExD,KAAK,aAAA;AACH,MAAA,OAAO,uBAAA,CAAwB,SAAS,SAAS,CAAA;AAAA,IAEnD,KAAK,MAAA;AACH,MAAA,OAAO,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MAAAA,CAAM,cAAc,mBAAA,EAAqB;AAAA,MACvC,QAAA,EAAU,aAAA;AAAA,MACV,qBAAA,EAAuB,yBAAA;AAAA,MACvB,iBAAA;AAAA,MACA;AAAA,KACD;AAAA,GACH;AAEA,EAAA,OAAOA,MAAAA,CAAM,cAAc,YAAA,CAAa,QAAA,EAAU,EAAE,KAAA,EAAO,YAAA,IAAgB,QAAQ,CAAA;AACrF;AAEO,SAAS,UAAA,CAAW;AAAA,EACzB,QAAA;AAAA,EACA,KAAA,GAAQ,MAAA;AAAA,EACR,MAAA,GAAS,IAAA;AAAA,EACT,WAAA,GAAc,GAAA;AAAA,EACd,UAAU,EAAC;AAAA,EACX,oBAAA,GAAuB;AACzB,CAAA,EAAuC;AACrC,EAAA,MAAM,YAAA,GAAe,KAAA,KAAU,OAAA,GAAU,OAAA,GAAU,MAAA;AAEnD,EAAA,MAAM,eAAA,GAAkBA,MAAAA,CAAM,aAAA,CAAc,kBAAA,EAAoB;AAAA,IAC9D,KAAA;AAAA,IACA,MAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,IAAI,oBAAA,EAAsB;AACxB,IAAA,OAAO,eAAA;AAAA,EACT;AAEA,EAAA,uBACEK,GAAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,kBAAA,EAAkB,IAAA;AAAA,MAClB,IAAA,EAAM,YAAA;AAAA,MACN,MAAA,EAAQ;AAAA,QACN,KAAA,EAAO;AAAA,UACL,IAAA,EAAM;AAAA;AACR,OACF;AAAA,MAEC,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"chunk-AQ5PPDEV.js","sourcesContent":["/**\n * Hydration trigger definitions and lifecycle coordinators for Selective Portal Hydration.\n */\n\nimport { parseHydrationTrigger, type HydrationTrigger } from '@omnitron-dev/lumen-ast/islands';\nexport type { HydrationTrigger } from '@omnitron-dev/lumen-ast/islands';\n\nexport interface TriggerOptions {\n /** IntersectionObserver threshold (0.0 - 1.0). Default: 0.1 */\n threshold?: number;\n /** IntersectionObserver rootMargin. Default: '200px' */\n rootMargin?: string;\n /** requestIdleCallback timeout in ms. Default: 2000 */\n timeout?: number;\n}\n\nexport type TriggerCleanup = () => void;\n\n/**\n * Attaches a trigger listener to a DOM element.\n * Invokes onTrigger once when triggered, then automatically cleans up.\n */\nexport function setupTrigger(\n element: HTMLElement,\n trigger: HydrationTrigger,\n onTrigger: () => void,\n options?: TriggerOptions\n): TriggerCleanup {\n switch (parseHydrationTrigger(trigger)) {\n case 'load':\n return setupLoadTrigger(onTrigger);\n\n case 'visible':\n return setupVisibleTrigger(element, onTrigger, options);\n\n case 'interaction':\n return setupInteractionTrigger(element, onTrigger);\n\n case 'idle':\n return setupIdleTrigger(onTrigger, options);\n\n default:\n return setupEventTrigger(element, trigger.slice(2).toLowerCase(), onTrigger);\n }\n}\n\nexport function setupLoadTrigger(onTrigger: () => void): TriggerCleanup {\n if (typeof window === 'undefined') return () => {};\n\n if (document.readyState === 'complete' || document.readyState === 'interactive') {\n const handle = requestAnimationFrame(() => onTrigger());\n return () => cancelAnimationFrame(handle);\n }\n\n const handler = () => onTrigger();\n window.addEventListener('DOMContentLoaded', handler, { once: true });\n return () => window.removeEventListener('DOMContentLoaded', handler);\n}\n\nexport function setupVisibleTrigger(\n element: HTMLElement,\n onTrigger: () => void,\n options?: TriggerOptions\n): TriggerCleanup {\n if (typeof window === 'undefined') return () => {};\n\n if (typeof IntersectionObserver === 'undefined') {\n onTrigger();\n return () => {};\n }\n\n let observer: IntersectionObserver | null = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n onTrigger();\n break;\n }\n }\n },\n {\n rootMargin: options?.rootMargin ?? '200px',\n threshold: options?.threshold ?? 0.1,\n }\n );\n\n observer.observe(element);\n return () => {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n };\n}\n\nconst INTERACTION_EVENTS = ['pointerenter', 'focusin', 'click', 'touchstart', 'keydown'] as const;\n\nexport function setupInteractionTrigger(element: HTMLElement, onTrigger: () => void): TriggerCleanup {\n if (typeof window === 'undefined') return () => {};\n\n let fired = false;\n const handler = () => {\n if (fired) return;\n fired = true;\n cleanup();\n onTrigger();\n };\n\n const cleanup = () => {\n for (const evt of INTERACTION_EVENTS) {\n element.removeEventListener(evt, handler);\n }\n };\n\n for (const evt of INTERACTION_EVENTS) {\n element.addEventListener(evt, handler, { once: true, passive: true });\n }\n\n return cleanup;\n}\n\nexport function setupIdleTrigger(onTrigger: () => void, options?: TriggerOptions): TriggerCleanup {\n if (typeof window === 'undefined') return () => {};\n\n if ('requestIdleCallback' in window && typeof (window as any).requestIdleCallback === 'function') {\n const handle = (window as any).requestIdleCallback(() => onTrigger(), { timeout: options?.timeout ?? 2000 });\n return () => (window as any).cancelIdleCallback(handle);\n }\n\n const timer = setTimeout(() => onTrigger(), 200);\n return () => clearTimeout(timer);\n}\n\nexport function setupEventTrigger(element: HTMLElement, eventName: string, onTrigger: () => void): TriggerCleanup {\n if (typeof window === 'undefined') return () => {};\n\n const handler = () => onTrigger();\n element.addEventListener(eventName, handler, { once: true, passive: true });\n return () => element.removeEventListener(eventName, handler);\n}\n","import React, { type ReactNode } from 'react';\nimport { serializeIslandProps, parseHydrationTrigger } from '@omnitron-dev/lumen-ast/islands';\nimport type { HydrationTrigger } from './triggers.js';\n\nexport interface PortalIslandHostProps {\n islandId: string;\n component?: string;\n hydrate?: HydrationTrigger;\n props?: Record<string, unknown>;\n children?: ReactNode;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function PortalIslandHost({\n islandId,\n component,\n hydrate = 'idle',\n props = {},\n children,\n className = 'lumen-portal-island',\n style,\n}: PortalIslandHostProps): React.JSX.Element {\n return React.createElement(\n 'div',\n {\n className,\n 'data-lumen-island': islandId,\n ...(component ? { 'data-component': component } : {}),\n 'data-hydrate': parseHydrationTrigger(hydrate),\n 'data-props': serializeIslandProps(props),\n style,\n },\n children\n );\n}\n","import React, { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';\nimport { Tabs } from '@omnitron-dev/prism/components/tabs';\n\ninterface DocumentPanel {\n section: HTMLElement;\n heading: HTMLElement;\n value: string;\n}\n\ninterface TabPreference { key: string; value: string }\nconst syncEvent = 'lumen:document-tab-change';\n\nfunction fragmentTarget(doc: Document): HTMLElement | null {\n const hash = doc.defaultView?.location.hash;\n if (!hash) return null;\n try { return doc.getElementById(decodeURIComponent(hash.slice(1))); } catch { return null; }\n}\n\n/** Enhance just the controls. Panel DOM belongs to the document, including its links and islands. */\nexport function DocumentTabs(): React.JSX.Element {\n const strip = useRef<HTMLDivElement>(null);\n const instance = useId();\n const [panels, setPanels] = useState<DocumentPanel[]>([]);\n const [selected, setSelected] = useState(0);\n const group = strip.current?.closest<HTMLElement>('.lumen-tabs');\n const syncKey = group?.dataset.syncKey;\n\n useLayoutEffect(() => {\n const container = strip.current?.closest<HTMLElement>('.lumen-tabs');\n if (!container) return;\n const sections = Array.from(container.querySelectorAll<HTMLElement>(':scope > .lumen-tab-item'));\n const items: DocumentPanel[] = [];\n for (const section of sections) {\n const heading = section.querySelector<HTMLElement>(':scope > .lumen-tab-label');\n if (!heading) return;\n items.push({ section, heading, value: section.dataset.value ?? heading.textContent ?? '' });\n }\n const doc = container.ownerDocument;\n const anchor = fragmentTarget(doc);\n const peer = container.dataset.syncKey && Array.from(doc.querySelectorAll<HTMLElement>('.lumen-tabs[data-active-value]'))\n .find(item => item !== container && item.dataset.syncKey === container.dataset.syncKey);\n const anchored = items.findIndex(item => anchor && item.section.contains(anchor));\n const anchorPanel = anchor?.closest<HTMLElement>('.lumen-tab-item');\n const anchorGroup = anchorPanel?.parentElement;\n const anchorValue = container.dataset.syncKey && anchorGroup?.dataset.syncKey === container.dataset.syncKey\n ? anchorPanel?.dataset.value : undefined;\n const synced = items.findIndex(item => item.value === (anchorValue ?? (peer && peer.dataset.activeValue)));\n setSelected(anchored >= 0 ? anchored : Math.max(0, synced));\n setPanels(items);\n }, []);\n\n useLayoutEffect(() => {\n const tabs = strip.current?.querySelectorAll<HTMLElement>('[role=\"tab\"]');\n if (!group || !panels.length || tabs?.length !== panels.length) return undefined;\n panels.forEach(({ section, heading }, index) => {\n const tab = tabs[index]!;\n section.id = `${instance}-panel-${index}`;\n section.setAttribute('role', 'tabpanel');\n section.setAttribute('aria-labelledby', tab.id);\n section.tabIndex = 0;\n tab.setAttribute('aria-controls', section.id);\n heading.hidden = true;\n section.hidden = index !== selected;\n });\n group.dataset.activeValue = panels[selected]!.value;\n return () => {\n delete group.dataset.activeValue;\n for (const { section, heading } of panels) {\n section.hidden = false;\n heading.hidden = false;\n for (const attribute of ['id', 'role', 'aria-labelledby', 'tabindex']) section.removeAttribute(attribute);\n }\n };\n }, [group, instance, panels, selected]);\n\n useEffect(() => {\n if (!group || !panels.length) return undefined;\n const doc = group.ownerDocument;\n const onSync = (event: Event) => {\n const choice = (event as CustomEvent<TabPreference>).detail;\n if (!choice || choice.key !== syncKey) return;\n const index = panels.findIndex(item => item.value === choice.value);\n if (index >= 0) setSelected(index);\n };\n const onHashChange = () => {\n const anchor = fragmentTarget(doc);\n const index = panels.findIndex(item => anchor && item.section.contains(anchor));\n if (index >= 0) {\n setSelected(index);\n if (syncKey) doc.dispatchEvent(new CustomEvent<TabPreference>(syncEvent, { detail: { key: syncKey, value: panels[index]!.value } }));\n }\n };\n if (syncKey) doc.addEventListener(syncEvent, onSync);\n doc.defaultView?.addEventListener('hashchange', onHashChange);\n return () => {\n if (syncKey) doc.removeEventListener(syncEvent, onSync);\n doc.defaultView?.removeEventListener('hashchange', onHashChange);\n };\n }, [group, panels, syncKey]);\n\n function select(value: string) {\n const index = Number(value);\n setSelected(index);\n if (syncKey) group?.ownerDocument.dispatchEvent(new CustomEvent<TabPreference>(syncEvent, { detail: { key: syncKey, value: panels[index]!.value } }));\n }\n\n return <div ref={strip}>{panels.length > 0 && <Tabs\n aria-label={group?.dataset.label || panels.map(item => item.heading.textContent).join(' / ')}\n tabs={panels.map((item, index) => ({ label: item.heading.textContent ?? item.value, value: String(index) }))}\n value={String(selected)}\n onChange={select}\n selectionFollowsFocus\n variant=\"scrollable\"\n scrollButtons=\"auto\"\n />}</div>;\n}\n\n","import React, { useState, useEffect, useRef, useCallback, useMemo, type ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { PrismProvider } from '@omnitron-dev/prism/core';\nimport { ErrorBoundary } from '@omnitron-dev/prism/components/error-boundary';\nimport { parseIslandProps, parseHydrationTrigger } from '@omnitron-dev/lumen-ast/islands';\nimport { LumenContext, type LumenContextValue, type IslandComponent, type IslandRegistry } from './context.js';\nimport { setupTrigger, type HydrationTrigger } from './triggers.js';\nimport { DocumentTabs } from './document-tabs.js';\n\nexport interface LumenShellProps {\n children?: ReactNode;\n theme?: 'light' | 'dark' | string;\n locale?: string;\n currentPath?: string;\n islands?: IslandRegistry;\n disablePrismProvider?: boolean;\n}\n\nexport interface PortalIslandManagerProps {\n registry: IslandRegistry;\n onActiveIslandsChange?: (activeIds: Set<string>) => void;\n hydrateHandlerRef?: React.MutableRefObject<((islandId: string) => void) | null>;\n pendingHydrateIdsRef?: React.MutableRefObject<Set<string>>;\n}\n\ninterface DiscoveredIsland {\n instanceKey: string;\n islandId: string;\n componentName: string;\n trigger?: HydrationTrigger;\n props?: Record<string, unknown>;\n metadataError?: Error;\n rawProps: string | null;\n rawTrigger: string | null;\n element: HTMLElement;\n}\n\nconst ISLAND_SELECTOR = '.lumen-portal-island, [data-lumen-island], [data-widget]';\n\nlet globalElementInstanceCounter = 0;\nconst elementInstanceKeys = new WeakMap<HTMLElement, string>();\nconst syntheticElementIds = new WeakMap<HTMLElement, string>();\n\nfunction getOrCreateInstanceKey(el: HTMLElement): string {\n let key = elementInstanceKeys.get(el);\n if (!key) {\n globalElementInstanceCounter += 1;\n key = `lumen-island-inst-${globalElementInstanceCounter}`;\n elementInstanceKeys.set(el, key);\n }\n return key;\n}\n\nfunction resolveElementIslandIdentity(el: HTMLElement): { islandId: string; componentName: string } {\n const explicitIslandId = el.getAttribute('data-lumen-island') ?? '';\n const dataComponent = el.getAttribute('data-component') ?? '';\n const dataWidget = el.getAttribute('data-widget') ?? '';\n\n let islandId = explicitIslandId;\n if (!islandId) {\n let synthetic = syntheticElementIds.get(el);\n if (!synthetic) {\n const base = dataWidget || dataComponent || 'island';\n globalElementInstanceCounter += 1;\n synthetic = `${base}-${globalElementInstanceCounter}`;\n syntheticElementIds.set(el, synthetic);\n }\n islandId = synthetic;\n el.setAttribute('data-lumen-island', islandId);\n }\n\n const componentName = dataComponent || dataWidget || islandId;\n return { islandId, componentName };\n}\n\nfunction discoverIsland(element: HTMLElement, previous?: DiscoveredIsland): DiscoveredIsland {\n const { islandId, componentName } = resolveElementIslandIdentity(element);\n const rawProps = element.getAttribute('data-props');\n const rawTrigger = element.getAttribute('data-hydrate');\n if (previous?.islandId === islandId && previous.componentName === componentName &&\n previous.rawProps === rawProps && previous.rawTrigger === rawTrigger) return previous;\n const item = { instanceKey: getOrCreateInstanceKey(element), islandId, componentName, element, rawProps, rawTrigger };\n try {\n return { ...item, props: rawProps === null ? {} : parseIslandProps(rawProps), trigger: parseHydrationTrigger(rawTrigger ?? 'idle') };\n } catch (error) {\n const metadataError = error instanceof Error ? error : new Error('Invalid island metadata');\n console.error(`[LumenHydration] Invalid metadata for island \"${islandId}\":`, metadataError);\n return { ...item, metadataError };\n }\n}\n\nexport function PortalIslandManager({\n registry,\n onActiveIslandsChange,\n hydrateHandlerRef,\n pendingHydrateIdsRef,\n}: PortalIslandManagerProps): React.JSX.Element | null {\n const [, setRenderVersion] = useState(0);\n const [discovered, setDiscovered] = useState<DiscoveredIsland[]>([]);\n\n // Element-identity keyed lifecycle refs (prevents stale string-ID collisions across DOM replacements)\n const cleanupsRef = useRef<Map<HTMLElement, () => void>>(new Map());\n const activeElementsRef = useRef<Set<HTMLElement>>(new Set());\n const clearedSsrElementsRef = useRef<WeakSet<HTMLElement>>(new WeakSet());\n const discoveredListRef = useRef<DiscoveredIsland[]>([]);\n const registryRef = useRef<IslandRegistry>(registry);\n const onActiveIslandsChangeRef = useRef(onActiveIslandsChange);\n\n registryRef.current = registry;\n onActiveIslandsChangeRef.current = onActiveIslandsChange;\n\n useEffect(() => {\n if (typeof document === 'undefined') {\n return undefined;\n }\n\n const cleanups = cleanupsRef.current;\n const activeElements = activeElementsRef.current;\n\n const notifyActiveIds = () => {\n const nextIds = new Set<string>();\n for (const item of discoveredListRef.current) {\n if (item.element.isConnected && activeElements.has(item.element)) {\n nextIds.add(item.islandId);\n }\n }\n onActiveIslandsChangeRef.current?.(nextIds);\n };\n\n const clearStaticFallbackIfReady = (el: HTMLElement, componentName: string) => {\n if (clearedSsrElementsRef.current.has(el)) {\n return;\n }\n if (registryRef.current[componentName]) {\n clearedSsrElementsRef.current.add(el);\n el.replaceChildren();\n }\n };\n\n const activateElement = (el: HTMLElement) => {\n if (!el.isConnected) return;\n let item = discoveredListRef.current.find(candidate => candidate.element === el);\n const identity = resolveElementIslandIdentity(el);\n const triggerChanged = item?.rawTrigger !== el.getAttribute('data-hydrate');\n // Attributes may change and an interaction may fire in the same task, before MutationObserver runs.\n if (!item || item.rawProps !== el.getAttribute('data-props') || triggerChanged ||\n item.islandId !== identity.islandId || item.componentName !== identity.componentName) {\n scanAndAttach();\n if (triggerChanged) return;\n item = discoveredListRef.current.find(candidate => candidate.element === el);\n }\n if (!item || item.metadataError) return;\n\n // 1. Clean up ONLY this specific DOM element's trigger listener\n const cleanup = cleanups.get(el);\n if (cleanup) {\n cleanup();\n cleanups.delete(el);\n }\n\n // 2. Prevent redundant activation for the exact same connected DOM node\n if (activeElements.has(el)) {\n return;\n }\n activeElements.add(el);\n\n clearStaticFallbackIfReady(el, item.componentName);\n\n notifyActiveIds();\n setRenderVersion((v) => v + 1);\n };\n\n const scanAndAttach = () => {\n if (typeof document === 'undefined') return;\n\n const nodeList = document.querySelectorAll<HTMLElement>(ISLAND_SELECTOR);\n const connectedElements = new Set<HTMLElement>();\n nodeList.forEach((el) => {\n if (el.isConnected) {\n connectedElements.add(el);\n }\n });\n\n let activePruned = false;\n\n // 1. Prune detached elements from trigger listeners immediately\n cleanups.forEach((cleanup, el) => {\n if (!connectedElements.has(el) || !el.isConnected) {\n cleanup();\n cleanups.delete(el);\n }\n });\n\n // 2. Prune detached elements from active state so replaced nodes with same islandId must re-trigger\n activeElements.forEach((el) => {\n if (!connectedElements.has(el) || !el.isConnected) {\n activeElements.delete(el);\n activePruned = true;\n }\n });\n\n const prevList = discoveredListRef.current;\n const previousByElement = new Map(prevList.map(item => [item.element, item]));\n const nextList = [...connectedElements].map(el => discoverIsland(el, previousByElement.get(el)));\n const pendingElementsToActivate: HTMLElement[] = [];\n const listChanged = prevList.length !== nextList.length || nextList.some((item, index) => item !== prevList[index]);\n // Publish metadata before attaching triggers: visible fallback can activate synchronously.\n discoveredListRef.current = nextList;\n\n for (const item of nextList) {\n const { element: el, islandId, componentName } = item;\n const previous = previousByElement.get(el);\n if (item.metadataError || previous?.rawTrigger !== item.rawTrigger) {\n cleanups.get(el)?.();\n cleanups.delete(el);\n }\n if (item.metadataError) {\n el.setAttribute('data-lumen-error', 'metadata');\n if (activeElements.delete(el)) activePruned = true;\n continue;\n }\n el.removeAttribute('data-lumen-error');\n\n // Drain any pending imperative hydration requests for this island\n if (\n pendingHydrateIdsRef?.current &&\n (pendingHydrateIdsRef.current.has(islandId) || pendingHydrateIdsRef.current.has(componentName))\n ) {\n pendingHydrateIdsRef.current.delete(islandId);\n pendingHydrateIdsRef.current.delete(componentName);\n pendingElementsToActivate.push(el);\n continue;\n }\n\n // Skip if this exact element is already active or already has an attached trigger listener\n if (activeElements.has(el) || cleanups.has(el)) {\n continue;\n }\n\n const cleanup = setupTrigger(el, item.trigger!, () => {\n activateElement(el);\n });\n if (activeElements.has(el)) cleanup();\n else cleanups.set(el, cleanup);\n }\n\n for (const el of pendingElementsToActivate) {\n activateElement(el);\n }\n\n if (activePruned || listChanged) {\n notifyActiveIds();\n }\n\n if (listChanged || activePruned || pendingElementsToActivate.length > 0) {\n setDiscovered(nextList);\n }\n };\n\n const hydrateById = (targetId: string) => {\n if (!targetId) return;\n scanAndAttach();\n let matched = false;\n for (const item of discoveredListRef.current) {\n if (!item.metadataError && item.element.isConnected && (item.islandId === targetId || item.componentName === targetId)) {\n matched = true;\n activateElement(item.element);\n }\n }\n if (!matched && pendingHydrateIdsRef?.current) {\n pendingHydrateIdsRef.current.add(targetId);\n }\n };\n\n if (hydrateHandlerRef) {\n hydrateHandlerRef.current = hydrateById;\n }\n\n // Initial scan and trigger attachment on mount\n scanAndAttach();\n\n // Observe dynamic DOM changes (e.g. client router transitions, replaced island nodes, modals)\n let mutationObserver: MutationObserver | null = null;\n if (typeof MutationObserver !== 'undefined') {\n mutationObserver = new MutationObserver(() => {\n scanAndAttach();\n });\n mutationObserver.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-props', 'data-hydrate', 'data-component', 'data-widget', 'data-lumen-island'],\n });\n }\n\n return () => {\n if (hydrateHandlerRef) {\n hydrateHandlerRef.current = null;\n }\n mutationObserver?.disconnect();\n cleanups.forEach((cleanup) => cleanup());\n cleanups.clear();\n activeElements.clear();\n };\n }, [hydrateHandlerRef, pendingHydrateIdsRef]);\n\n if (typeof window === 'undefined' || discovered.length === 0) {\n return null;\n }\n\n const portals: React.ReactPortal[] = [];\n\n for (const item of discovered) {\n if (item.element.isConnected && item.metadataError) {\n if (!clearedSsrElementsRef.current.has(item.element)) {\n clearedSsrElementsRef.current.add(item.element);\n item.element.replaceChildren();\n }\n portals.push(createPortal(<p className=\"lumen-island-error\" role=\"alert\">Unable to load this component: invalid island metadata.</p>, item.element, item.instanceKey));\n continue;\n }\n if (item.element.isConnected && activeElementsRef.current.has(item.element)) {\n const Component = registry[item.componentName];\n if (Component) {\n // Clear static SSR fallback children once right before mounting the live portal component\n if (!clearedSsrElementsRef.current.has(item.element)) {\n clearedSsrElementsRef.current.add(item.element);\n item.element.replaceChildren();\n }\n portals.push(createPortal(\n <ErrorBoundary resetKeys={[Component, item.islandId, item.rawProps]}\n fallback={({ error }) => <p className=\"lumen-island-error\" role=\"alert\">\n {item.componentName} could not render. {error.message}\n </p>}>\n {React.createElement(Component, item.props)}\n </ErrorBoundary>,\n item.element, item.instanceKey,\n ));\n }\n }\n }\n\n return portals.length > 0 ? React.createElement(React.Fragment, null, ...portals) : null;\n}\n\nfunction LumenShellProvider({\n children,\n theme = 'dark',\n locale = 'en',\n currentPath = '/',\n islands = {},\n}: Omit<LumenShellProps, 'disablePrismProvider'>): React.JSX.Element {\n const [dynamicIslands, setDynamicIslands] = useState<IslandRegistry>({});\n const [activeIslands, setActiveIslands] = useState<Set<string>>(() => new Set());\n\n const mergedIslands = useMemo<IslandRegistry>(() => ({ LumenDocumentTabs: DocumentTabs, ...islands, ...dynamicIslands }), [islands, dynamicIslands]);\n\n // Synchronous ref ensures getIsland() immediately reflects registerIsland() within the same tick\n const latestRegistryRef = useRef<IslandRegistry>(mergedIslands);\n latestRegistryRef.current = mergedIslands;\n\n const hydrateHandlerRef = useRef<((islandId: string) => void) | null>(null);\n const pendingHydrateIdsRef = useRef<Set<string>>(new Set());\n\n const registerIsland = useCallback((name: string, component: IslandComponent) => {\n if (!name || !component) return;\n latestRegistryRef.current = { ...latestRegistryRef.current, [name]: component };\n setDynamicIslands((prev) => {\n if (prev[name] === component) return prev;\n return { ...prev, [name]: component };\n });\n }, []);\n\n const getIsland = useCallback((name: string): IslandComponent | undefined => latestRegistryRef.current[name], []);\n\n const hydrateIsland = useCallback((islandId: string) => {\n if (!islandId) return;\n if (hydrateHandlerRef.current) {\n hydrateHandlerRef.current(islandId);\n } else {\n pendingHydrateIdsRef.current.add(islandId);\n }\n }, []);\n\n const handleActiveIslandsChange = useCallback((nextIds: Set<string>) => {\n setActiveIslands((prev) => {\n if (prev.size === nextIds.size && Array.from(prev).every((id) => nextIds.has(id))) {\n return prev;\n }\n return new Set(nextIds);\n });\n }, []);\n\n const contextValue = useMemo<LumenContextValue>(\n () => ({\n theme,\n locale,\n currentPath,\n islands: mergedIslands,\n registerIsland,\n getIsland,\n activeIslands,\n hydrateIsland,\n }),\n [theme, locale, currentPath, mergedIslands, registerIsland, getIsland, activeIslands, hydrateIsland]\n );\n\n const shellDiv = React.createElement(\n 'div',\n { className: 'lumen-shell', 'data-theme': theme, 'data-locale': locale },\n children,\n React.createElement(PortalIslandManager, {\n registry: mergedIslands,\n onActiveIslandsChange: handleActiveIslandsChange,\n hydrateHandlerRef,\n pendingHydrateIdsRef,\n })\n );\n\n return React.createElement(LumenContext.Provider, { value: contextValue }, shellDiv);\n}\n\nexport function LumenShell({\n children,\n theme = 'dark',\n locale = 'en',\n currentPath = '/',\n islands = {},\n disablePrismProvider = false,\n}: LumenShellProps): React.JSX.Element {\n const resolvedMode = theme === 'light' ? 'light' : 'dark';\n\n const providerElement = React.createElement(LumenShellProvider, {\n theme,\n locale,\n currentPath,\n islands,\n children,\n });\n\n if (disablePrismProvider) {\n return providerElement;\n }\n\n return (\n <PrismProvider\n disableCssBaseline\n mode={resolvedMode}\n config={{\n theme: {\n mode: resolvedMode,\n },\n }}\n >\n {providerElement}\n </PrismProvider>\n );\n}\n"]}