@fluid-app/widget-runtime 0.1.281 → 0.1.283
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/{remote-dom-renderer-BGIZ0FRi.d.mts → remote-dom-renderer-BnqVsw6k.d.mts} +4 -8
- package/dist/remote-dom-renderer-BnqVsw6k.d.mts.map +1 -0
- package/dist/remote-dom-renderer-CMpuJrkw.cjs +471 -0
- package/dist/remote-dom-renderer-CMpuJrkw.cjs.map +1 -0
- package/dist/remote-dom-renderer-D2FspToS.mjs +466 -0
- package/dist/remote-dom-renderer-D2FspToS.mjs.map +1 -0
- package/dist/{remote-dom-renderer-BoB9jd3B.d.cts → remote-dom-renderer-D3Jz1sOH.d.cts} +4 -8
- package/dist/remote-dom-renderer-D3Jz1sOH.d.cts.map +1 -0
- package/dist/{remote-dom-renderer-m5bn0hcE.mjs → remote-dom-styles-CmHfrrKz.mjs} +261 -702
- package/dist/remote-dom-styles-CmHfrrKz.mjs.map +1 -0
- package/dist/{remote-dom-renderer-VA5axIKk.cjs → remote-dom-styles-RV40tYyt.cjs} +328 -698
- package/dist/remote-dom-styles-RV40tYyt.cjs.map +1 -0
- package/dist/{remote-dom-ui-contract-B140dMly.d.mts → remote-dom-ui-contract-Dr0q3O4E.d.cts} +75 -77
- package/dist/remote-dom-ui-contract-Dr0q3O4E.d.cts.map +1 -0
- package/dist/{remote-dom-ui-contract-BLOyWbT2.d.cts → remote-dom-ui-contract-Dr0q3O4E.d.mts} +75 -77
- package/dist/remote-dom-ui-contract-Dr0q3O4E.d.mts.map +1 -0
- package/dist/remote-dom-values-BBN5u_Mj.mjs +1358 -0
- package/dist/remote-dom-values-BBN5u_Mj.mjs.map +1 -0
- package/dist/{remote-dom-values-D4AgBNWr.d.cts → remote-dom-values-BR8Qnhg9.d.cts} +1 -3
- package/dist/remote-dom-values-BR8Qnhg9.d.cts.map +1 -0
- package/dist/remote-dom-values-D1Fi2ibn.cjs +1441 -0
- package/dist/remote-dom-values-D1Fi2ibn.cjs.map +1 -0
- package/dist/{remote-dom-values-EwoLXnSn.d.mts → remote-dom-values-D8qikv8I.d.mts} +2 -3
- package/dist/remote-dom-values-D8qikv8I.d.mts.map +1 -0
- package/dist/remote-dom.cjs +2 -2
- package/dist/remote-dom.d.cts +2 -2
- package/dist/remote-dom.d.mts +2 -2
- package/dist/remote-dom.mjs +2 -2
- package/dist/site-host.cjs +372 -0
- package/dist/site-host.cjs.map +1 -0
- package/dist/site-host.d.cts +61 -0
- package/dist/site-host.d.cts.map +1 -0
- package/dist/site-host.d.mts +61 -0
- package/dist/site-host.d.mts.map +1 -0
- package/dist/site-host.mjs +369 -0
- package/dist/site-host.mjs.map +1 -0
- package/dist/{worker-react-bootstrap-C7tCMYGA.mjs → worker-react-bootstrap-CwlNMpMT.mjs} +2 -3
- package/dist/{worker-react-bootstrap-C7tCMYGA.mjs.map → worker-react-bootstrap-CwlNMpMT.mjs.map} +1 -1
- package/dist/{worker-react-bootstrap-N8jcWZ3L.cjs → worker-react-bootstrap-Dbq9hU1k.cjs} +2 -3
- package/dist/{worker-react-bootstrap-N8jcWZ3L.cjs.map → worker-react-bootstrap-Dbq9hU1k.cjs.map} +1 -1
- package/dist/{worker-react-renderer-ByjjgyrY.cjs → worker-react-renderer-CsI-dsP5.cjs} +5 -6
- package/dist/worker-react-renderer-CsI-dsP5.cjs.map +1 -0
- package/dist/{worker-react-renderer-ggcPIDLl.mjs → worker-react-renderer-LC2Dr-gj.mjs} +5 -5
- package/dist/{worker-react-renderer-ggcPIDLl.mjs.map → worker-react-renderer-LC2Dr-gj.mjs.map} +1 -1
- package/dist/worker.cjs +12 -17
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +15 -13
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +16 -14
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +9 -13
- package/dist/worker.mjs.map +1 -1
- package/package.json +11 -6
- package/dist/Thread-0eUyc0Hw.cjs +0 -591
- package/dist/Thread-0eUyc0Hw.cjs.map +0 -1
- package/dist/Thread-BiW7rXts.mjs +0 -574
- package/dist/Thread-BiW7rXts.mjs.map +0 -1
- package/dist/remote-dom-renderer-BGIZ0FRi.d.mts.map +0 -1
- package/dist/remote-dom-renderer-BoB9jd3B.d.cts.map +0 -1
- package/dist/remote-dom-renderer-VA5axIKk.cjs.map +0 -1
- package/dist/remote-dom-renderer-m5bn0hcE.mjs.map +0 -1
- package/dist/remote-dom-ui-contract-B140dMly.d.mts.map +0 -1
- package/dist/remote-dom-ui-contract-BLOyWbT2.d.cts.map +0 -1
- package/dist/remote-dom-values-B5UZPDRy.cjs +0 -849
- package/dist/remote-dom-values-B5UZPDRy.cjs.map +0 -1
- package/dist/remote-dom-values-D4AgBNWr.d.cts.map +0 -1
- package/dist/remote-dom-values-EwoLXnSn.d.mts.map +0 -1
- package/dist/remote-dom-values-wEbrw5iW.mjs +0 -790
- package/dist/remote-dom-values-wEbrw5iW.mjs.map +0 -1
- package/dist/worker-react-renderer-ByjjgyrY.cjs.map +0 -1
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { a as isRemoteDomSerializableValue, f as Thread, i as createRemoteDomUrlOriginPolicy, l as REMOTE_DOM_SUPPORTED_UI_CONTRACT_VERSIONS, m as retain, p as release, t as REMOTE_DOM_ALLOWED_TAG_NAMES, u as REMOTE_DOM_UI_COMPONENTS } from "./remote-dom-values-BBN5u_Mj.mjs";
|
|
2
|
+
import { a as collectCleanupErrors, c as enforceAllowedAnchorSafety, d as normalizeNavigationOrigin, f as reportCleanupErrors, i as callRemoteDomCapability, l as handleRemoteDomNavigationIntent, m as createSanitizingRemoteConnection, n as attachRemoteDomStyles, o as createSubmitPreventionListener, p as reportHostError, s as deliverRemoteDomEvent, u as hasCloserRemoteEventListener } from "./remote-dom-styles-CmHfrrKz.mjs";
|
|
3
|
+
import { MUTATION_TYPE_REMOVE_CHILD, ROOT_ID } from "@remote-dom/core";
|
|
4
|
+
import { RemoteFragmentRenderer, RemoteReceiver, RemoteRootRenderer, renderRemoteNode, useRemoteReceived } from "@remote-dom/react/host";
|
|
5
|
+
import { createElement, useEffect, useLayoutEffect, useRef } from "react";
|
|
6
|
+
import { flushSync } from "react-dom";
|
|
7
|
+
import { createRoot } from "react-dom/client";
|
|
8
|
+
// src/remote-dom-renderer.ts
|
|
9
|
+
const DEFAULT_MAX_MUTATION_BATCH_SIZE = 1e3;
|
|
10
|
+
const DEFAULT_MAX_DOM_NODE_COUNT = 1e3;
|
|
11
|
+
const BOOLEAN_ATTRIBUTE_REACT_PROPERTIES = /* @__PURE__ */ new Map([
|
|
12
|
+
["allowfullscreen", "allowFullScreen"],
|
|
13
|
+
["async", "async"],
|
|
14
|
+
["autofocus", "autoFocus"],
|
|
15
|
+
["autoplay", "autoPlay"],
|
|
16
|
+
["checked", "checked"],
|
|
17
|
+
["controls", "controls"],
|
|
18
|
+
["default", "default"],
|
|
19
|
+
["defer", "defer"],
|
|
20
|
+
["disabled", "disabled"],
|
|
21
|
+
["disablepictureinpicture", "disablePictureInPicture"],
|
|
22
|
+
["disableremoteplayback", "disableRemotePlayback"],
|
|
23
|
+
["formnovalidate", "formNoValidate"],
|
|
24
|
+
["hidden", "hidden"],
|
|
25
|
+
["inert", "inert"],
|
|
26
|
+
["itemscope", "itemScope"],
|
|
27
|
+
["loop", "loop"],
|
|
28
|
+
["multiple", "multiple"],
|
|
29
|
+
["muted", "muted"],
|
|
30
|
+
["nomodule", "noModule"],
|
|
31
|
+
["novalidate", "noValidate"],
|
|
32
|
+
["open", "open"],
|
|
33
|
+
["playsinline", "playsInline"],
|
|
34
|
+
["readonly", "readOnly"],
|
|
35
|
+
["required", "required"],
|
|
36
|
+
["reversed", "reversed"],
|
|
37
|
+
["selected", "selected"]
|
|
38
|
+
]);
|
|
39
|
+
function createRemoteComponentRenderers(options, isDisposed) {
|
|
40
|
+
const renderers = /* @__PURE__ */ new Map();
|
|
41
|
+
const fluidTags = new Set(REMOTE_DOM_UI_COMPONENTS.map(({ tagName }) => tagName));
|
|
42
|
+
for (const tagName of REMOTE_DOM_ALLOWED_TAG_NAMES) {
|
|
43
|
+
if (fluidTags.has(tagName)) continue;
|
|
44
|
+
renderers.set(tagName, createNativeRemoteComponentRenderer(tagName, options, isDisposed));
|
|
45
|
+
}
|
|
46
|
+
for (const definition of REMOTE_DOM_UI_COMPONENTS) {
|
|
47
|
+
if (definition.contractVersion !== "1") continue;
|
|
48
|
+
renderers.set(definition.tagName, createNativeRemoteComponentRenderer(definition.tagName, options, isDisposed));
|
|
49
|
+
}
|
|
50
|
+
renderers.set("remote-fragment", RemoteFragmentRenderer);
|
|
51
|
+
for (const [tagName, renderer] of options.componentRenderers ?? []) {
|
|
52
|
+
if (!fluidTags.has(tagName)) continue;
|
|
53
|
+
renderers.set(tagName, renderer);
|
|
54
|
+
}
|
|
55
|
+
return renderers;
|
|
56
|
+
}
|
|
57
|
+
function createNativeRemoteComponentRenderer(tagName, options, isDisposed) {
|
|
58
|
+
function NativeRemoteComponent({ element, receiver, components }) {
|
|
59
|
+
const attachedElement = useRemoteReceived(element, receiver);
|
|
60
|
+
const elementRef = useRef(null);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const hostElement = elementRef.current;
|
|
63
|
+
if (!hostElement || !attachedElement) return;
|
|
64
|
+
const cleanup = [];
|
|
65
|
+
for (const [eventName, listener] of Object.entries(attachedElement.eventListeners)) {
|
|
66
|
+
if (typeof listener !== "function") continue;
|
|
67
|
+
const handleEvent = (event) => {
|
|
68
|
+
if (hasCloserRemoteEventListener(event, attachedElement.id, (id) => receiverHasEventListener(receiver, id, eventName))) return;
|
|
69
|
+
deliverRemoteDomEvent({
|
|
70
|
+
event,
|
|
71
|
+
eventName,
|
|
72
|
+
currentTargetId: attachedElement.id,
|
|
73
|
+
currentTargetTagName: tagName,
|
|
74
|
+
listener,
|
|
75
|
+
reporter: options,
|
|
76
|
+
isDisposed
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
hostElement.addEventListener(eventName, handleEvent);
|
|
80
|
+
cleanup.push(() => hostElement.removeEventListener(eventName, handleEvent));
|
|
81
|
+
}
|
|
82
|
+
return () => {
|
|
83
|
+
for (const dispose of cleanup) dispose();
|
|
84
|
+
};
|
|
85
|
+
}, [
|
|
86
|
+
attachedElement,
|
|
87
|
+
attachedElement?.version,
|
|
88
|
+
receiver
|
|
89
|
+
]);
|
|
90
|
+
useLayoutEffect(() => {
|
|
91
|
+
const hostElement = elementRef.current;
|
|
92
|
+
if (!(hostElement instanceof HTMLInputElement) || !attachedElement) return;
|
|
93
|
+
const value = attachedElement.properties.value;
|
|
94
|
+
if (typeof value === "string" && hostElement.value !== value) hostElement.value = value;
|
|
95
|
+
const checked = attachedElement.properties.checked;
|
|
96
|
+
if (typeof checked === "boolean" && hostElement.checked !== checked) hostElement.checked = checked;
|
|
97
|
+
}, [attachedElement, attachedElement?.version]);
|
|
98
|
+
if (!attachedElement) return null;
|
|
99
|
+
const domProps = {};
|
|
100
|
+
for (const [name, value] of Object.entries({
|
|
101
|
+
...attachedElement.attributes,
|
|
102
|
+
...attachedElement.properties
|
|
103
|
+
})) {
|
|
104
|
+
if (tagName === "input" && (name === "checked" || name === "value")) continue;
|
|
105
|
+
const booleanProperty = BOOLEAN_ATTRIBUTE_REACT_PROPERTIES.get(name);
|
|
106
|
+
domProps[booleanProperty ?? toReactDomPropertyName(name)] = booleanProperty && typeof value === "string" ? true : value;
|
|
107
|
+
}
|
|
108
|
+
domProps["data-fluid-remote-dom-node-id"] = attachedElement.id;
|
|
109
|
+
domProps.ref = elementRef;
|
|
110
|
+
const renderOptions = {
|
|
111
|
+
receiver,
|
|
112
|
+
components
|
|
113
|
+
};
|
|
114
|
+
return createElement(tagName, domProps, ...attachedElement.children.map((child) => renderRemoteNode(child, renderOptions)));
|
|
115
|
+
}
|
|
116
|
+
NativeRemoteComponent.displayName = `RemoteDomNative(${tagName})`;
|
|
117
|
+
return NativeRemoteComponent;
|
|
118
|
+
}
|
|
119
|
+
function RemoteRootEventBoundary({ receiver, container, options, isDisposed, children }) {
|
|
120
|
+
const root = useRemoteReceived(receiver.root, receiver);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (!root) return;
|
|
123
|
+
const cleanup = [];
|
|
124
|
+
for (const [eventName, listener] of Object.entries(root.eventListeners)) {
|
|
125
|
+
if (typeof listener !== "function") continue;
|
|
126
|
+
const handleEvent = (event) => {
|
|
127
|
+
if (hasCloserRemoteEventListener(event, ROOT_ID, (id) => receiverHasEventListener(receiver, id, eventName))) return;
|
|
128
|
+
deliverRemoteDomEvent({
|
|
129
|
+
event,
|
|
130
|
+
eventName,
|
|
131
|
+
currentTargetId: ROOT_ID,
|
|
132
|
+
listener,
|
|
133
|
+
reporter: options,
|
|
134
|
+
isDisposed
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
container.addEventListener(eventName, handleEvent, { capture: true });
|
|
138
|
+
cleanup.push(() => container.removeEventListener(eventName, handleEvent, { capture: true }));
|
|
139
|
+
}
|
|
140
|
+
return () => {
|
|
141
|
+
for (const dispose of cleanup) dispose();
|
|
142
|
+
};
|
|
143
|
+
}, [
|
|
144
|
+
container,
|
|
145
|
+
isDisposed,
|
|
146
|
+
options,
|
|
147
|
+
receiver,
|
|
148
|
+
root,
|
|
149
|
+
root?.version
|
|
150
|
+
]);
|
|
151
|
+
return children;
|
|
152
|
+
}
|
|
153
|
+
function receiverHasEventListener(receiver, id, eventName) {
|
|
154
|
+
const remoteNode = receiver.get({ id });
|
|
155
|
+
return Boolean(remoteNode && "eventListeners" in remoteNode && typeof remoteNode.eventListeners[eventName] === "function");
|
|
156
|
+
}
|
|
157
|
+
function toReactDomPropertyName(name) {
|
|
158
|
+
switch (name) {
|
|
159
|
+
case "class": return "className";
|
|
160
|
+
case "for": return "htmlFor";
|
|
161
|
+
case "readonly": return "readOnly";
|
|
162
|
+
case "tabindex": return "tabIndex";
|
|
163
|
+
default: return name;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function getSupportedUiContractVersions(componentRenderers) {
|
|
167
|
+
return REMOTE_DOM_UI_COMPONENTS.every(({ contractVersion, tagName }) => contractVersion !== "2" || componentRenderers.has(tagName)) ? REMOTE_DOM_SUPPORTED_UI_CONTRACT_VERSIONS : REMOTE_DOM_SUPPORTED_UI_CONTRACT_VERSIONS.filter((version) => version !== "2");
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Mounts one Remote DOM widget worker into an isolated shadow root.
|
|
171
|
+
*
|
|
172
|
+
* The low-level runtime supports native Remote DOM elements by default. A host
|
|
173
|
+
* that supports worker-facing Fluid UI components must also provide the full
|
|
174
|
+
* reviewed {@link MountRemoteDomWidgetOptions.componentRenderers} map, a
|
|
175
|
+
* containment-aware {@link MountRemoteDomWidgetOptions.wrapRemoteRoot}, and
|
|
176
|
+
* the matching Fluid component CSS. The runtime advertises Fluid UI contract
|
|
177
|
+
* v2 only when every v2 renderer is present.
|
|
178
|
+
*/
|
|
179
|
+
function mountRemoteDomWidget(options) {
|
|
180
|
+
const initialProps = options.props ?? null;
|
|
181
|
+
assertSerializable(initialProps, "Initial widget props");
|
|
182
|
+
const shadowRoot = createShadowRoot(options.host);
|
|
183
|
+
const navigationOrigin = normalizeNavigationOrigin(options.hostOrigin);
|
|
184
|
+
const urlOriginPolicy = createRemoteDomUrlOriginPolicy({
|
|
185
|
+
artifactUrls: collectArtifactUrls(options.artifact),
|
|
186
|
+
...options.mediaOrigins === void 0 ? {} : { mediaOrigins: options.mediaOrigins },
|
|
187
|
+
...navigationOrigin === void 0 ? {} : { navigationOrigin }
|
|
188
|
+
});
|
|
189
|
+
const styles = attachRemoteDomStyles({
|
|
190
|
+
artifact: options.artifact,
|
|
191
|
+
root: shadowRoot,
|
|
192
|
+
urlOriginPolicy,
|
|
193
|
+
onFailure: (count) => {
|
|
194
|
+
reportHostError(options, `${count} Remote DOM widget styles failed to load`);
|
|
195
|
+
},
|
|
196
|
+
...options.cssText === void 0 ? {} : { cssText: options.cssText },
|
|
197
|
+
...options.widgetCssText === void 0 ? {} : { widgetCssText: options.widgetCssText },
|
|
198
|
+
...options.cssUrls === void 0 ? {} : { cssUrls: options.cssUrls },
|
|
199
|
+
...options.fluidComponentCssText === void 0 ? {} : { fluidComponentCssText: options.fluidComponentCssText },
|
|
200
|
+
...options.fluidComponentCssUrls === void 0 ? {} : { fluidComponentCssUrls: options.fluidComponentCssUrls },
|
|
201
|
+
...options.themeBridgeCssText === void 0 ? {} : { themeBridgeCssText: options.themeBridgeCssText },
|
|
202
|
+
...options.themeBridge === void 0 ? {} : { themeBridge: options.themeBridge },
|
|
203
|
+
...options.fetchCss === void 0 ? {} : { fetchCss: options.fetchCss },
|
|
204
|
+
...options.useConstructableStylesheets === void 0 ? {} : { useConstructableStylesheets: options.useConstructableStylesheets }
|
|
205
|
+
});
|
|
206
|
+
let worker;
|
|
207
|
+
try {
|
|
208
|
+
worker = (options.workerFactory ?? createDefaultWorker)(options.artifact.workerEntryUrl, { type: "module" });
|
|
209
|
+
} catch (error) {
|
|
210
|
+
reportCleanupErrors(options, "Remote DOM widget setup cleanup failed", collectCleanupErrors([() => styles.dispose(), () => clearRenderedRemoteDomNodes(shadowRoot)]));
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
let thread;
|
|
214
|
+
try {
|
|
215
|
+
thread = new Thread(createWorkerMessageTarget(worker));
|
|
216
|
+
} catch (error) {
|
|
217
|
+
reportCleanupErrors(options, "Remote DOM widget setup cleanup failed", collectCleanupErrors([
|
|
218
|
+
() => styles.dispose(),
|
|
219
|
+
() => worker.terminate(),
|
|
220
|
+
() => clearRenderedRemoteDomNodes(shadowRoot)
|
|
221
|
+
]));
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
let state;
|
|
225
|
+
const receiver = new RemoteReceiver({
|
|
226
|
+
retain,
|
|
227
|
+
release
|
|
228
|
+
});
|
|
229
|
+
const renderContainer = document.createElement("div");
|
|
230
|
+
renderContainer.setAttribute("data-fluid-remote-dom-render-root", "");
|
|
231
|
+
const portalContainer = document.createElement("div");
|
|
232
|
+
portalContainer.setAttribute("data-fluid-remote-dom-portal-container", "");
|
|
233
|
+
shadowRoot.append(renderContainer, portalContainer);
|
|
234
|
+
const submitListener = createSubmitPreventionListener();
|
|
235
|
+
const navigationListener = (event) => {
|
|
236
|
+
handleRemoteDomNavigationIntent({
|
|
237
|
+
shadowRoot,
|
|
238
|
+
urlOriginPolicy,
|
|
239
|
+
navigationOrigin,
|
|
240
|
+
allowedAnchorUrls: options.allowedAnchorUrls,
|
|
241
|
+
onNavigate: options.onNavigate,
|
|
242
|
+
onError: options.onError,
|
|
243
|
+
isDisposed: () => state.disposed
|
|
244
|
+
}, event);
|
|
245
|
+
};
|
|
246
|
+
const reactRoot = createRoot(renderContainer, { onUncaughtError(error) {
|
|
247
|
+
reportHostError(options, "Remote DOM host rendering failed", error);
|
|
248
|
+
queueMicrotask(() => {
|
|
249
|
+
if (!state.disposed) disposeAfterFailure(state, false);
|
|
250
|
+
});
|
|
251
|
+
} });
|
|
252
|
+
state = {
|
|
253
|
+
options,
|
|
254
|
+
shadowRoot,
|
|
255
|
+
worker,
|
|
256
|
+
thread,
|
|
257
|
+
styles,
|
|
258
|
+
urlOriginPolicy,
|
|
259
|
+
navigationOrigin,
|
|
260
|
+
receiver,
|
|
261
|
+
reactRoot,
|
|
262
|
+
renderContainer,
|
|
263
|
+
portalContainer,
|
|
264
|
+
submitListener,
|
|
265
|
+
navigationListener,
|
|
266
|
+
disposed: false,
|
|
267
|
+
cleanupStarted: false
|
|
268
|
+
};
|
|
269
|
+
const componentRenderers = createRemoteComponentRenderers(options, () => state.disposed);
|
|
270
|
+
const remoteRoot = createElement(RemoteRootEventBoundary, {
|
|
271
|
+
receiver,
|
|
272
|
+
container: renderContainer,
|
|
273
|
+
options,
|
|
274
|
+
isDisposed: () => state?.disposed ?? false
|
|
275
|
+
}, createElement(RemoteRootRenderer, {
|
|
276
|
+
receiver,
|
|
277
|
+
components: componentRenderers
|
|
278
|
+
}));
|
|
279
|
+
flushSync(() => {
|
|
280
|
+
reactRoot.render(options.wrapRemoteRoot ? options.wrapRemoteRoot(remoteRoot, portalContainer) : remoteRoot);
|
|
281
|
+
});
|
|
282
|
+
const connection = createSanitizingRemoteConnection({
|
|
283
|
+
connection: receiver.connection,
|
|
284
|
+
...options.allowedAnchorUrls ? { allowedAnchorUrls: options.allowedAnchorUrls } : {},
|
|
285
|
+
urlOriginPolicy,
|
|
286
|
+
maxMutationBatchSize: options.maxMutationBatchSize ?? DEFAULT_MAX_MUTATION_BATCH_SIZE,
|
|
287
|
+
maxDomNodeCount: options.maxDomNodeCount ?? DEFAULT_MAX_DOM_NODE_COUNT,
|
|
288
|
+
onNodeLimitExceeded: () => {
|
|
289
|
+
reportHostError(options, "Remote DOM widget exceeded its DOM node limit");
|
|
290
|
+
},
|
|
291
|
+
onInvalidRecord: (message) => reportHostError(options, message),
|
|
292
|
+
onMutateError: (error) => reportHostError(options, "Remote DOM mutation could not be applied", error)
|
|
293
|
+
});
|
|
294
|
+
shadowRoot.addEventListener("submit", submitListener, { capture: true });
|
|
295
|
+
shadowRoot.addEventListener("click", navigationListener, { capture: true });
|
|
296
|
+
worker.onerror = (event) => {
|
|
297
|
+
event.preventDefault?.();
|
|
298
|
+
if (state.disposed) return;
|
|
299
|
+
reportHostError(options, event.message || "Remote DOM widget worker failed", event.error);
|
|
300
|
+
disposeAfterFailure(state, false);
|
|
301
|
+
};
|
|
302
|
+
const hostApi = {
|
|
303
|
+
mutate(records) {
|
|
304
|
+
if (state.disposed) return;
|
|
305
|
+
flushSync(() => connection.mutate(records));
|
|
306
|
+
enforceAllowedAnchorSafety(state.shadowRoot, state.options.allowedAnchorUrls);
|
|
307
|
+
},
|
|
308
|
+
callCapability(capability, method, payload) {
|
|
309
|
+
return callRemoteDomCapability({
|
|
310
|
+
declared: options.artifact.capabilities,
|
|
311
|
+
host: options.host,
|
|
312
|
+
shadowRoot,
|
|
313
|
+
callCapability: options.callCapability,
|
|
314
|
+
onFullscreen: options.onFullscreen,
|
|
315
|
+
onError: options.onError,
|
|
316
|
+
isDisposed: () => state.disposed
|
|
317
|
+
}, capability, method, payload);
|
|
318
|
+
},
|
|
319
|
+
reportError(error) {
|
|
320
|
+
reportHostError(options, error.message);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
const ready = Promise.all([styles.ready, thread.imports.mount({
|
|
324
|
+
widgetType: options.artifact.widgetType,
|
|
325
|
+
props: initialProps,
|
|
326
|
+
supportedUiContractVersions: getSupportedUiContractVersions(componentRenderers),
|
|
327
|
+
...options.artifact.networkAccessGranted === true ? {
|
|
328
|
+
networkAccessGranted: true,
|
|
329
|
+
hostOrigin: options.hostOrigin
|
|
330
|
+
} : {}
|
|
331
|
+
}, hostApi)]).then(() => void 0);
|
|
332
|
+
ready.catch((error) => {
|
|
333
|
+
if (state.disposed) return;
|
|
334
|
+
reportHostError(options, "Remote DOM widget failed to mount", error);
|
|
335
|
+
disposeAfterFailure(state);
|
|
336
|
+
});
|
|
337
|
+
return {
|
|
338
|
+
shadowRoot,
|
|
339
|
+
styles,
|
|
340
|
+
ready,
|
|
341
|
+
updateProps(props) {
|
|
342
|
+
if (state.disposed) return;
|
|
343
|
+
assertSerializable(props, "Widget props");
|
|
344
|
+
state.thread.imports.updateProps(props).catch((error) => {
|
|
345
|
+
if (!state.disposed) reportHostError(options, "Remote DOM widget props update failed", error);
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
dispose() {
|
|
349
|
+
disposeMount(state);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function disposeMount(state, notifyWorker = true) {
|
|
354
|
+
if (state.cleanupStarted) return;
|
|
355
|
+
state.cleanupStarted = true;
|
|
356
|
+
state.disposed = true;
|
|
357
|
+
const cleanupSteps = [
|
|
358
|
+
() => {
|
|
359
|
+
state.worker.onerror = null;
|
|
360
|
+
},
|
|
361
|
+
() => {
|
|
362
|
+
state.shadowRoot.removeEventListener("submit", state.submitListener, { capture: true });
|
|
363
|
+
},
|
|
364
|
+
() => {
|
|
365
|
+
state.shadowRoot.removeEventListener("click", state.navigationListener, { capture: true });
|
|
366
|
+
}
|
|
367
|
+
];
|
|
368
|
+
cleanupSteps.push(() => flushSync(() => state.reactRoot.unmount()), () => clearRemoteReceiver(state.receiver), () => state.styles.dispose(), () => clearRenderedRemoteDomNodes(state.shadowRoot));
|
|
369
|
+
const cleanupErrors = collectCleanupErrors(cleanupSteps);
|
|
370
|
+
if (notifyWorker) Promise.resolve(state.thread.imports.dispose()).catch(() => void 0);
|
|
371
|
+
queueMicrotask(() => {
|
|
372
|
+
reportCleanupErrors(state.options, "Remote DOM widget asynchronous cleanup failed", collectCleanupErrors([() => state.thread.close(), () => state.worker.terminate()]));
|
|
373
|
+
});
|
|
374
|
+
if (cleanupErrors.length > 0) throw new AggregateError(cleanupErrors, "Remote DOM widget cleanup failed");
|
|
375
|
+
}
|
|
376
|
+
function disposeAfterFailure(state, notifyWorker = true) {
|
|
377
|
+
try {
|
|
378
|
+
disposeMount(state, notifyWorker);
|
|
379
|
+
} catch (cleanupError) {
|
|
380
|
+
reportHostError(state.options, "Remote DOM widget cleanup failed after an earlier error", cleanupError);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function createShadowRoot(host) {
|
|
384
|
+
if (host.shadowRoot) {
|
|
385
|
+
host.shadowRoot.replaceChildren();
|
|
386
|
+
return host.shadowRoot;
|
|
387
|
+
}
|
|
388
|
+
return host.attachShadow({ mode: "open" });
|
|
389
|
+
}
|
|
390
|
+
function collectArtifactUrls(artifact) {
|
|
391
|
+
return [
|
|
392
|
+
artifact.workerEntryUrl,
|
|
393
|
+
...artifact.cssUrls,
|
|
394
|
+
...artifact.assetUrls
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
function isWidgetStyleNode(node) {
|
|
398
|
+
return node instanceof HTMLStyleElement && node.hasAttribute("data-fluid-widget-style");
|
|
399
|
+
}
|
|
400
|
+
function clearRenderedRemoteDomNodes(shadowRoot) {
|
|
401
|
+
for (const child of Array.from(shadowRoot.childNodes)) if (!isWidgetStyleNode(child)) child.remove();
|
|
402
|
+
}
|
|
403
|
+
function clearRemoteReceiver(receiver) {
|
|
404
|
+
while (receiver.root.children.length > 0) receiver.connection.mutate([[
|
|
405
|
+
MUTATION_TYPE_REMOVE_CHILD,
|
|
406
|
+
ROOT_ID,
|
|
407
|
+
0
|
|
408
|
+
]]);
|
|
409
|
+
}
|
|
410
|
+
function assertSerializable(value, description) {
|
|
411
|
+
if (!isRemoteDomSerializableValue(value)) throw new TypeError(`${description} must be serializable`);
|
|
412
|
+
}
|
|
413
|
+
function createWorkerMessageTarget(worker) {
|
|
414
|
+
return {
|
|
415
|
+
send(message, transferables) {
|
|
416
|
+
worker.postMessage(message, transferables ?? []);
|
|
417
|
+
},
|
|
418
|
+
listen(listener, { signal }) {
|
|
419
|
+
const onMessage = (event) => {
|
|
420
|
+
listener(event.data);
|
|
421
|
+
};
|
|
422
|
+
if (worker.addEventListener) worker.addEventListener("message", onMessage, { signal });
|
|
423
|
+
else {
|
|
424
|
+
worker.onmessage = onMessage;
|
|
425
|
+
signal?.addEventListener("abort", () => {
|
|
426
|
+
worker.onmessage = null;
|
|
427
|
+
}, { once: true });
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function createDefaultWorker(workerEntryUrl, options) {
|
|
433
|
+
if (typeof Worker === "undefined") throw new Error("Remote DOM Worker is not available in this environment");
|
|
434
|
+
if (!shouldWrapWorkerEntryUrl(workerEntryUrl)) return new Worker(workerEntryUrl, options);
|
|
435
|
+
return createBlobWrappedWorker(workerEntryUrl, options);
|
|
436
|
+
}
|
|
437
|
+
function shouldWrapWorkerEntryUrl(workerEntryUrl) {
|
|
438
|
+
if (typeof location === "undefined" || typeof Blob === "undefined" || typeof URL.createObjectURL !== "function") return false;
|
|
439
|
+
try {
|
|
440
|
+
return new URL(workerEntryUrl, location.href).origin !== location.origin;
|
|
441
|
+
} catch {
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
function createBlobWrappedWorker(workerEntryUrl, options) {
|
|
446
|
+
const blobUrl = URL.createObjectURL(new Blob([`import ${JSON.stringify(workerEntryUrl)};\n`], { type: "application/javascript" }));
|
|
447
|
+
let worker;
|
|
448
|
+
try {
|
|
449
|
+
worker = new Worker(blobUrl, options);
|
|
450
|
+
} catch (error) {
|
|
451
|
+
URL.revokeObjectURL(blobUrl);
|
|
452
|
+
throw error;
|
|
453
|
+
}
|
|
454
|
+
const terminate = worker.terminate.bind(worker);
|
|
455
|
+
worker.terminate = () => {
|
|
456
|
+
try {
|
|
457
|
+
terminate();
|
|
458
|
+
} finally {
|
|
459
|
+
URL.revokeObjectURL(blobUrl);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
return worker;
|
|
463
|
+
}
|
|
464
|
+
export { mountRemoteDomWidget as t };
|
|
465
|
+
|
|
466
|
+
//# sourceMappingURL=remote-dom-renderer-D2FspToS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-dom-renderer-D2FspToS.mjs","names":["REMOTE_DOM_ROOT_ID"],"sources":["../src/remote-dom-renderer.ts"],"sourcesContent":["import {\n release,\n retain,\n Thread,\n type ThreadMessageTarget,\n} from \"@quilted/threads\";\nimport {\n MUTATION_TYPE_REMOVE_CHILD,\n ROOT_ID as REMOTE_DOM_ROOT_ID,\n} from \"@remote-dom/core\";\nimport {\n RemoteFragmentRenderer,\n RemoteReceiver,\n RemoteRootRenderer,\n renderRemoteNode,\n useRemoteReceived,\n type RemoteComponentRendererProps,\n type RemoteComponentRendererMap,\n type RemoteReceiverNode,\n} from \"@remote-dom/react/host\";\nimport {\n createElement,\n type ComponentType,\n type ReactElement,\n type ReactNode,\n useEffect,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createRoot, type Root } from \"react-dom/client\";\nimport { createSanitizingRemoteConnection } from \"./remote-dom-sanitizing-connection\";\nimport {\n callRemoteDomCapability,\n collectCleanupErrors,\n createSubmitPreventionListener,\n deliverRemoteDomEvent,\n enforceAllowedAnchorSafety,\n handleRemoteDomNavigationIntent,\n hasCloserRemoteEventListener,\n normalizeNavigationOrigin,\n reportCleanupErrors,\n reportHostError,\n} from \"./remote-dom-host-shared\";\nimport {\n attachRemoteDomStyles,\n REMOTE_DOM_WIDGET_STYLE_ATTRIBUTE,\n type RemoteDomCssFetcher,\n type RemoteDomCssUrlInput,\n type RemoteDomStyleAttachment,\n type RemoteDomStyleArtifact,\n type RemoteDomThemeBridgeOptions,\n} from \"./remote-dom-styles\";\nimport {\n createRemoteDomUrlOriginPolicy,\n isRemoteDomSerializableValue,\n REMOTE_DOM_ALLOWED_TAG_NAMES,\n type RemoteDomNavigationIntent,\n type RemoteDomSerializableValue,\n type RemoteDomUrlOriginPolicy,\n} from \"./remote-dom-values\";\nimport {\n REMOTE_DOM_UI_COMPONENTS,\n REMOTE_DOM_SUPPORTED_UI_CONTRACT_VERSIONS,\n} from \"./remote-dom-ui-contract\";\nimport type {\n RemoteDomWidgetWorkerApi,\n RemoteDomWidgetWorkerHostApi,\n} from \"./worker-runtime\";\n\nexport type { RemoteDomNavigationIntent };\nexport { resolveAllowedAnchorUrl } from \"./remote-dom-host-shared\";\n\nexport interface RemoteDomCapabilityDeclaration {\n readonly name: string;\n readonly version: string;\n}\n\nexport interface RemoteDomWidgetArtifact extends RemoteDomStyleArtifact {\n readonly widgetType: string;\n readonly capabilities: readonly RemoteDomCapabilityDeclaration[];\n readonly networkAccessGranted?: boolean | undefined;\n}\n\nexport interface RemoteDomFullscreenRequest {\n readonly method: string;\n readonly payload?: RemoteDomSerializableValue | undefined;\n readonly host: HTMLElement;\n readonly shadowRoot: ShadowRoot;\n}\n\nexport interface MountRemoteDomWidgetOptions {\n readonly host: HTMLElement;\n readonly artifact: RemoteDomWidgetArtifact;\n readonly props?: RemoteDomSerializableValue | undefined;\n readonly callCapability?:\n | ((\n capability: string,\n method: string,\n payload?: RemoteDomSerializableValue,\n ) => RemoteDomSerializableValue | Promise<RemoteDomSerializableValue>)\n | undefined;\n readonly onNavigate?:\n | ((intent: RemoteDomNavigationIntent) => void | Promise<void>)\n | undefined;\n readonly onFullscreen?:\n | ((\n request: RemoteDomFullscreenRequest,\n ) => RemoteDomSerializableValue | Promise<RemoteDomSerializableValue>)\n | undefined;\n readonly onError?: ((error: Error) => void) | undefined;\n readonly workerFactory?: RemoteDomWorkerFactory | undefined;\n readonly hostOrigin?: string | undefined;\n readonly mediaOrigins?: readonly string[] | undefined;\n /** Canonical absolute HTTP(S) URLs registered for native new-tab anchors. */\n readonly allowedAnchorUrls?: ReadonlySet<string> | undefined;\n readonly maxMutationBatchSize?: number | undefined;\n readonly maxDomNodeCount?: number | undefined;\n readonly cssText?: string | undefined;\n readonly widgetCssText?: string | undefined;\n readonly cssUrls?: readonly RemoteDomCssUrlInput[] | undefined;\n /**\n * Compiled Fluid UI CSS attached inside the widget shadow root. Supply this\n * with {@link MountRemoteDomWidgetOptions.componentRenderers} and\n * {@link MountRemoteDomWidgetOptions.wrapRemoteRoot} when the host supports\n * the Fluid UI contract.\n */\n readonly fluidComponentCssText?: string | undefined;\n /**\n * Compiled Fluid UI stylesheets attached inside the widget shadow root.\n * Supply these with {@link MountRemoteDomWidgetOptions.componentRenderers}\n * and {@link MountRemoteDomWidgetOptions.wrapRemoteRoot} when the host\n * supports the Fluid UI contract.\n */\n readonly fluidComponentCssUrls?: readonly RemoteDomCssUrlInput[] | undefined;\n readonly themeBridgeCssText?: string | undefined;\n readonly themeBridge?:\n | Omit<RemoteDomThemeBridgeOptions, \"root\">\n | false\n | undefined;\n readonly fetchCss?: RemoteDomCssFetcher | undefined;\n readonly useConstructableStylesheets?: boolean | undefined;\n /**\n * Host-owned Fluid component renderers keyed by reviewed remote tag. The\n * runtime advertises UI contract v2 only when every v2 tag has a renderer.\n */\n readonly componentRenderers?: RemoteComponentRendererMap | undefined;\n /**\n * Wraps the receiver tree with host providers such as portal containment.\n * Fluid UI hosts must keep overlays inside the supplied portal container.\n */\n readonly wrapRemoteRoot?:\n | ((root: ReactElement, portalContainer: HTMLElement) => ReactNode)\n | undefined;\n}\n\nexport interface RemoteDomWidgetHandle {\n readonly shadowRoot: ShadowRoot;\n readonly styles: RemoteDomStyleAttachment;\n readonly ready: Promise<void>;\n updateProps(props: RemoteDomSerializableValue): void;\n dispose(): void;\n}\n\nexport interface RemoteDomWorkerLike {\n onmessage: ((event: MessageEvent<unknown>) => void) | null;\n onerror: ((event: ErrorEvent) => void) | null;\n postMessage(message: unknown, transfer?: Transferable[]): void;\n terminate(): void;\n addEventListener?: (\n type: \"message\",\n listener: (event: MessageEvent<unknown>) => void,\n options?: { signal?: AbortSignal },\n ) => void;\n}\n\nexport type RemoteDomWorkerFactory = (\n workerEntryUrl: string,\n options: WorkerOptions,\n) => RemoteDomWorkerLike;\n\ninterface MountState {\n readonly options: MountRemoteDomWidgetOptions;\n readonly shadowRoot: ShadowRoot;\n readonly worker: RemoteDomWorkerLike;\n readonly thread: Thread<RemoteDomWidgetWorkerApi>;\n readonly styles: RemoteDomStyleAttachment;\n readonly urlOriginPolicy: RemoteDomUrlOriginPolicy;\n readonly navigationOrigin: string | undefined;\n readonly receiver: RemoteReceiver;\n readonly reactRoot: Root;\n readonly renderContainer: HTMLElement;\n readonly portalContainer: HTMLElement;\n readonly submitListener: EventListener;\n readonly navigationListener: EventListener;\n disposed: boolean;\n cleanupStarted: boolean;\n}\n\n// Complex Fluid UI trees can emit hundreds of records during their initial\n// mount. Keep the batch limit aligned with the existing per-widget node cap.\nconst DEFAULT_MAX_MUTATION_BATCH_SIZE = 1_000;\nconst DEFAULT_MAX_DOM_NODE_COUNT = 1_000;\n\nconst BOOLEAN_ATTRIBUTE_REACT_PROPERTIES = new Map<string, string>([\n [\"allowfullscreen\", \"allowFullScreen\"],\n [\"async\", \"async\"],\n [\"autofocus\", \"autoFocus\"],\n [\"autoplay\", \"autoPlay\"],\n [\"checked\", \"checked\"],\n [\"controls\", \"controls\"],\n [\"default\", \"default\"],\n [\"defer\", \"defer\"],\n [\"disabled\", \"disabled\"],\n [\"disablepictureinpicture\", \"disablePictureInPicture\"],\n [\"disableremoteplayback\", \"disableRemotePlayback\"],\n [\"formnovalidate\", \"formNoValidate\"],\n [\"hidden\", \"hidden\"],\n [\"inert\", \"inert\"],\n [\"itemscope\", \"itemScope\"],\n [\"loop\", \"loop\"],\n [\"multiple\", \"multiple\"],\n [\"muted\", \"muted\"],\n [\"nomodule\", \"noModule\"],\n [\"novalidate\", \"noValidate\"],\n [\"open\", \"open\"],\n [\"playsinline\", \"playsInline\"],\n [\"readonly\", \"readOnly\"],\n [\"required\", \"required\"],\n [\"reversed\", \"reversed\"],\n [\"selected\", \"selected\"],\n]);\n\nfunction createRemoteComponentRenderers(\n options: MountRemoteDomWidgetOptions,\n isDisposed: () => boolean,\n): RemoteComponentRendererMap {\n const renderers: RemoteComponentRendererMap = new Map();\n const fluidTags = new Set<string>(\n REMOTE_DOM_UI_COMPONENTS.map(({ tagName }) => tagName),\n );\n for (const tagName of REMOTE_DOM_ALLOWED_TAG_NAMES) {\n if (fluidTags.has(tagName)) continue;\n renderers.set(\n tagName,\n createNativeRemoteComponentRenderer(tagName, options, isDisposed),\n );\n }\n for (const definition of REMOTE_DOM_UI_COMPONENTS) {\n if (definition.contractVersion !== \"1\") continue;\n renderers.set(\n definition.tagName,\n createNativeRemoteComponentRenderer(\n definition.tagName,\n options,\n isDisposed,\n ),\n );\n }\n renderers.set(\"remote-fragment\", RemoteFragmentRenderer);\n for (const [tagName, renderer] of options.componentRenderers ?? []) {\n if (!fluidTags.has(tagName)) continue;\n renderers.set(tagName, renderer);\n }\n return renderers;\n}\n\nfunction createNativeRemoteComponentRenderer(\n tagName: string,\n options: MountRemoteDomWidgetOptions,\n isDisposed: () => boolean,\n): ComponentType<RemoteComponentRendererProps> {\n function NativeRemoteComponent({\n element,\n receiver,\n components,\n }: RemoteComponentRendererProps): ReactElement | null {\n const attachedElement = useRemoteReceived(element, receiver);\n const elementRef = useRef<HTMLElement | null>(null);\n // RemoteReceiver mutates a stable object; version makes prop and listener\n // updates observable when the element identity does not change.\n useEffect(() => {\n const hostElement = elementRef.current;\n if (!hostElement || !attachedElement) return;\n const cleanup: Array<() => void> = [];\n for (const [eventName, listener] of Object.entries(\n attachedElement.eventListeners,\n )) {\n if (typeof listener !== \"function\") continue;\n const handleEvent = (event: Event): void => {\n if (\n hasCloserRemoteEventListener(event, attachedElement.id, (id) =>\n receiverHasEventListener(receiver, id, eventName),\n )\n ) {\n return;\n }\n deliverRemoteDomEvent({\n event,\n eventName,\n currentTargetId: attachedElement.id,\n currentTargetTagName: tagName,\n listener,\n reporter: options,\n isDisposed,\n });\n };\n hostElement.addEventListener(eventName, handleEvent);\n cleanup.push(() =>\n hostElement.removeEventListener(eventName, handleEvent),\n );\n }\n return () => {\n for (const dispose of cleanup) dispose();\n };\n }, [attachedElement, attachedElement?.version, receiver]);\n useLayoutEffect(() => {\n const hostElement = elementRef.current;\n if (!(hostElement instanceof HTMLInputElement) || !attachedElement) {\n return;\n }\n const value = attachedElement.properties.value;\n if (typeof value === \"string\" && hostElement.value !== value) {\n hostElement.value = value;\n }\n const checked = attachedElement.properties.checked;\n if (typeof checked === \"boolean\" && hostElement.checked !== checked) {\n hostElement.checked = checked;\n }\n }, [attachedElement, attachedElement?.version]);\n if (!attachedElement) return null;\n const domProps: Record<string, unknown> = {};\n for (const [name, value] of Object.entries({\n ...attachedElement.attributes,\n ...attachedElement.properties,\n })) {\n if (tagName === \"input\" && (name === \"checked\" || name === \"value\")) {\n continue;\n }\n const booleanProperty = BOOLEAN_ATTRIBUTE_REACT_PROPERTIES.get(name);\n domProps[booleanProperty ?? toReactDomPropertyName(name)] =\n booleanProperty && typeof value === \"string\" ? true : value;\n }\n domProps[\"data-fluid-remote-dom-node-id\"] = attachedElement.id;\n domProps.ref = elementRef;\n\n const renderOptions = { receiver, components };\n return createElement(\n tagName,\n domProps,\n ...attachedElement.children.map((child) =>\n renderRemoteNode(child, renderOptions),\n ),\n );\n }\n NativeRemoteComponent.displayName = `RemoteDomNative(${tagName})`;\n return NativeRemoteComponent;\n}\n\ninterface RemoteRootEventBoundaryProps {\n readonly receiver: RemoteReceiver;\n readonly container: HTMLElement;\n readonly options: MountRemoteDomWidgetOptions;\n readonly isDisposed: () => boolean;\n readonly children?: ReactNode;\n}\n\nfunction RemoteRootEventBoundary({\n receiver,\n container,\n options,\n isDisposed,\n children,\n}: RemoteRootEventBoundaryProps): ReactNode {\n const root = useRemoteReceived(receiver.root, receiver);\n useEffect(() => {\n if (!root) return;\n const cleanup: Array<() => void> = [];\n for (const [eventName, listener] of Object.entries(root.eventListeners)) {\n if (typeof listener !== \"function\") continue;\n const handleEvent = (event: Event): void => {\n if (\n hasCloserRemoteEventListener(event, REMOTE_DOM_ROOT_ID, (id) =>\n receiverHasEventListener(receiver, id, eventName),\n )\n ) {\n return;\n }\n deliverRemoteDomEvent({\n event,\n eventName,\n currentTargetId: REMOTE_DOM_ROOT_ID,\n listener,\n reporter: options,\n isDisposed,\n });\n };\n container.addEventListener(eventName, handleEvent, { capture: true });\n cleanup.push(() =>\n container.removeEventListener(eventName, handleEvent, {\n capture: true,\n }),\n );\n }\n return () => {\n for (const dispose of cleanup) dispose();\n };\n }, [container, isDisposed, options, receiver, root, root?.version]);\n return children;\n}\n\nfunction receiverHasEventListener(\n receiver: RemoteReceiver,\n id: string,\n eventName: string,\n): boolean {\n const remoteNode = receiver.get<RemoteReceiverNode>({ id });\n return Boolean(\n remoteNode &&\n \"eventListeners\" in remoteNode &&\n typeof remoteNode.eventListeners[eventName] === \"function\",\n );\n}\n\nfunction toReactDomPropertyName(name: string): string {\n switch (name) {\n case \"class\":\n return \"className\";\n case \"for\":\n return \"htmlFor\";\n case \"readonly\":\n return \"readOnly\";\n case \"tabindex\":\n return \"tabIndex\";\n default:\n return name;\n }\n}\n\nfunction getSupportedUiContractVersions(\n componentRenderers: RemoteComponentRendererMap,\n): readonly string[] {\n const hasEveryV2Renderer = REMOTE_DOM_UI_COMPONENTS.every(\n ({ contractVersion, tagName }) =>\n contractVersion !== \"2\" || componentRenderers.has(tagName),\n );\n return hasEveryV2Renderer\n ? REMOTE_DOM_SUPPORTED_UI_CONTRACT_VERSIONS\n : REMOTE_DOM_SUPPORTED_UI_CONTRACT_VERSIONS.filter(\n (version) => version !== \"2\",\n );\n}\n\n/**\n * Mounts one Remote DOM widget worker into an isolated shadow root.\n *\n * The low-level runtime supports native Remote DOM elements by default. A host\n * that supports worker-facing Fluid UI components must also provide the full\n * reviewed {@link MountRemoteDomWidgetOptions.componentRenderers} map, a\n * containment-aware {@link MountRemoteDomWidgetOptions.wrapRemoteRoot}, and\n * the matching Fluid component CSS. The runtime advertises Fluid UI contract\n * v2 only when every v2 renderer is present.\n */\nexport function mountRemoteDomWidget(\n options: MountRemoteDomWidgetOptions,\n): RemoteDomWidgetHandle {\n const initialProps = options.props ?? null;\n assertSerializable(initialProps, \"Initial widget props\");\n\n const shadowRoot = createShadowRoot(options.host);\n const navigationOrigin = normalizeNavigationOrigin(options.hostOrigin);\n const urlOriginPolicy = createRemoteDomUrlOriginPolicy({\n artifactUrls: collectArtifactUrls(options.artifact),\n ...(options.mediaOrigins === undefined\n ? {}\n : { mediaOrigins: options.mediaOrigins }),\n ...(navigationOrigin === undefined ? {} : { navigationOrigin }),\n });\n const styles = attachRemoteDomStyles({\n artifact: options.artifact,\n root: shadowRoot,\n urlOriginPolicy,\n onFailure: (count) => {\n reportHostError(\n options,\n `${count} Remote DOM widget styles failed to load`,\n );\n },\n ...(options.cssText === undefined ? {} : { cssText: options.cssText }),\n ...(options.widgetCssText === undefined\n ? {}\n : { widgetCssText: options.widgetCssText }),\n ...(options.cssUrls === undefined ? {} : { cssUrls: options.cssUrls }),\n ...(options.fluidComponentCssText === undefined\n ? {}\n : { fluidComponentCssText: options.fluidComponentCssText }),\n ...(options.fluidComponentCssUrls === undefined\n ? {}\n : { fluidComponentCssUrls: options.fluidComponentCssUrls }),\n ...(options.themeBridgeCssText === undefined\n ? {}\n : { themeBridgeCssText: options.themeBridgeCssText }),\n ...(options.themeBridge === undefined\n ? {}\n : { themeBridge: options.themeBridge }),\n ...(options.fetchCss === undefined ? {} : { fetchCss: options.fetchCss }),\n ...(options.useConstructableStylesheets === undefined\n ? {}\n : { useConstructableStylesheets: options.useConstructableStylesheets }),\n });\n\n let worker: RemoteDomWorkerLike;\n try {\n worker = (options.workerFactory ?? createDefaultWorker)(\n options.artifact.workerEntryUrl,\n { type: \"module\" },\n );\n } catch (error) {\n reportCleanupErrors(\n options,\n \"Remote DOM widget setup cleanup failed\",\n collectCleanupErrors([\n () => styles.dispose(),\n () => clearRenderedRemoteDomNodes(shadowRoot),\n ]),\n );\n throw error;\n }\n\n let thread: Thread<RemoteDomWidgetWorkerApi>;\n try {\n thread = new Thread<RemoteDomWidgetWorkerApi>(\n createWorkerMessageTarget(worker),\n );\n } catch (error) {\n reportCleanupErrors(\n options,\n \"Remote DOM widget setup cleanup failed\",\n collectCleanupErrors([\n () => styles.dispose(),\n () => worker.terminate(),\n () => clearRenderedRemoteDomNodes(shadowRoot),\n ]),\n );\n throw error;\n }\n\n let state: MountState;\n const receiver = new RemoteReceiver({ retain, release });\n const renderContainer = document.createElement(\"div\");\n renderContainer.setAttribute(\"data-fluid-remote-dom-render-root\", \"\");\n const portalContainer = document.createElement(\"div\");\n portalContainer.setAttribute(\"data-fluid-remote-dom-portal-container\", \"\");\n shadowRoot.append(renderContainer, portalContainer);\n const submitListener = createSubmitPreventionListener();\n const navigationListener: EventListener = (event) => {\n handleRemoteDomNavigationIntent(\n {\n shadowRoot,\n urlOriginPolicy,\n navigationOrigin,\n allowedAnchorUrls: options.allowedAnchorUrls,\n onNavigate: options.onNavigate,\n onError: options.onError,\n isDisposed: () => state.disposed,\n },\n event,\n );\n };\n const reactRoot = createRoot(renderContainer, {\n onUncaughtError(error) {\n reportHostError(options, \"Remote DOM host rendering failed\", error);\n queueMicrotask(() => {\n if (!state.disposed) disposeAfterFailure(state, false);\n });\n },\n });\n state = {\n options,\n shadowRoot,\n worker,\n thread,\n styles,\n urlOriginPolicy,\n navigationOrigin,\n receiver,\n reactRoot,\n renderContainer,\n portalContainer,\n submitListener,\n navigationListener,\n disposed: false,\n cleanupStarted: false,\n };\n const componentRenderers = createRemoteComponentRenderers(\n options,\n () => state.disposed,\n );\n const remoteRoot = createElement(\n RemoteRootEventBoundary,\n {\n receiver,\n container: renderContainer,\n options,\n isDisposed: () => state?.disposed ?? false,\n },\n createElement(RemoteRootRenderer, {\n receiver,\n components: componentRenderers,\n }),\n );\n flushSync(() => {\n reactRoot.render(\n options.wrapRemoteRoot\n ? options.wrapRemoteRoot(remoteRoot, portalContainer)\n : remoteRoot,\n );\n });\n const connection = createSanitizingRemoteConnection({\n connection: receiver.connection,\n ...(options.allowedAnchorUrls\n ? { allowedAnchorUrls: options.allowedAnchorUrls }\n : {}),\n urlOriginPolicy,\n maxMutationBatchSize:\n options.maxMutationBatchSize ?? DEFAULT_MAX_MUTATION_BATCH_SIZE,\n maxDomNodeCount: options.maxDomNodeCount ?? DEFAULT_MAX_DOM_NODE_COUNT,\n onNodeLimitExceeded: () => {\n reportHostError(options, \"Remote DOM widget exceeded its DOM node limit\");\n },\n onInvalidRecord: (message) => reportHostError(options, message),\n onMutateError: (error) =>\n reportHostError(\n options,\n \"Remote DOM mutation could not be applied\",\n error,\n ),\n });\n\n shadowRoot.addEventListener(\"submit\", submitListener, { capture: true });\n shadowRoot.addEventListener(\"click\", navigationListener, { capture: true });\n worker.onerror = (event) => {\n // Cancel the event FIRST, and regardless of `disposed`. An uncaught\n // throw inside a worker is re-reported on the *host* document unless\n // this event is canceled, so without preventDefault every widget\n // crash lands in the host page's `window.onerror` — which in Mist\n // Desktop is Sentry's global handler. A widget failure the runtime\n // already handles (onError → inline \"couldn't render this widget\")\n // was being filed a second time as an unhandled production error\n // against the host app. Sandboxed widget faults must not escape into\n // host telemetry.\n event.preventDefault?.();\n if (state.disposed) return;\n reportHostError(\n options,\n event.message || \"Remote DOM widget worker failed\",\n event.error,\n );\n disposeAfterFailure(state, false);\n };\n\n const hostApi: RemoteDomWidgetWorkerHostApi = {\n mutate(records) {\n if (state.disposed) return;\n flushSync(() => connection.mutate(records));\n enforceAllowedAnchorSafety(\n state.shadowRoot,\n state.options.allowedAnchorUrls,\n );\n },\n callCapability(capability, method, payload) {\n return callRemoteDomCapability(\n {\n declared: options.artifact.capabilities,\n host: options.host,\n shadowRoot,\n callCapability: options.callCapability,\n onFullscreen: options.onFullscreen,\n onError: options.onError,\n isDisposed: () => state.disposed,\n },\n capability,\n method,\n payload,\n );\n },\n reportError(error) {\n reportHostError(options, error.message);\n },\n };\n\n const ready = Promise.all([\n styles.ready,\n thread.imports.mount(\n {\n widgetType: options.artifact.widgetType,\n props: initialProps,\n supportedUiContractVersions:\n getSupportedUiContractVersions(componentRenderers),\n ...(options.artifact.networkAccessGranted === true\n ? {\n networkAccessGranted: true,\n hostOrigin: options.hostOrigin,\n }\n : {}),\n },\n hostApi,\n ),\n ]).then(() => undefined);\n void ready.catch((error: unknown) => {\n if (state.disposed) return;\n reportHostError(options, \"Remote DOM widget failed to mount\", error);\n disposeAfterFailure(state);\n });\n\n return {\n shadowRoot,\n styles,\n ready,\n updateProps(props) {\n if (state.disposed) return;\n assertSerializable(props, \"Widget props\");\n void state.thread.imports.updateProps(props).catch((error: unknown) => {\n if (!state.disposed) {\n reportHostError(\n options,\n \"Remote DOM widget props update failed\",\n error,\n );\n }\n });\n },\n dispose() {\n disposeMount(state);\n },\n };\n}\n\nfunction disposeMount(state: MountState, notifyWorker = true): void {\n if (state.cleanupStarted) return;\n state.cleanupStarted = true;\n state.disposed = true;\n const cleanupSteps: Array<() => void> = [\n () => {\n state.worker.onerror = null;\n },\n () => {\n state.shadowRoot.removeEventListener(\"submit\", state.submitListener, {\n capture: true,\n });\n },\n () => {\n state.shadowRoot.removeEventListener(\"click\", state.navigationListener, {\n capture: true,\n });\n },\n ];\n cleanupSteps.push(\n () => flushSync(() => state.reactRoot.unmount()),\n () => clearRemoteReceiver(state.receiver),\n () => state.styles.dispose(),\n () => clearRenderedRemoteDomNodes(state.shadowRoot),\n );\n\n const cleanupErrors = collectCleanupErrors(cleanupSteps);\n\n if (notifyWorker) {\n void Promise.resolve(state.thread.imports.dispose()).catch(() => undefined);\n }\n queueMicrotask(() => {\n reportCleanupErrors(\n state.options,\n \"Remote DOM widget asynchronous cleanup failed\",\n collectCleanupErrors([\n () => state.thread.close(),\n () => state.worker.terminate(),\n ]),\n );\n });\n\n if (cleanupErrors.length > 0) {\n throw new AggregateError(cleanupErrors, \"Remote DOM widget cleanup failed\");\n }\n}\n\nfunction disposeAfterFailure(state: MountState, notifyWorker = true): void {\n try {\n disposeMount(state, notifyWorker);\n } catch (cleanupError) {\n reportHostError(\n state.options,\n \"Remote DOM widget cleanup failed after an earlier error\",\n cleanupError,\n );\n }\n}\n\nfunction createShadowRoot(host: HTMLElement): ShadowRoot {\n if (host.shadowRoot) {\n host.shadowRoot.replaceChildren();\n return host.shadowRoot;\n }\n return host.attachShadow({ mode: \"open\" });\n}\n\nfunction collectArtifactUrls(\n artifact: RemoteDomWidgetArtifact,\n): readonly string[] {\n return [artifact.workerEntryUrl, ...artifact.cssUrls, ...artifact.assetUrls];\n}\n\nfunction isWidgetStyleNode(node: Node): boolean {\n return (\n node instanceof HTMLStyleElement &&\n node.hasAttribute(REMOTE_DOM_WIDGET_STYLE_ATTRIBUTE)\n );\n}\n\nfunction clearRenderedRemoteDomNodes(shadowRoot: ShadowRoot): void {\n for (const child of Array.from(shadowRoot.childNodes)) {\n if (!isWidgetStyleNode(child)) child.remove();\n }\n}\n\nfunction clearRemoteReceiver(receiver: RemoteReceiver): void {\n while (receiver.root.children.length > 0) {\n receiver.connection.mutate([\n [MUTATION_TYPE_REMOVE_CHILD, REMOTE_DOM_ROOT_ID, 0],\n ]);\n }\n}\n\nfunction assertSerializable(\n value: unknown,\n description: string,\n): asserts value is RemoteDomSerializableValue {\n if (!isRemoteDomSerializableValue(value)) {\n throw new TypeError(`${description} must be serializable`);\n }\n}\n\nfunction createWorkerMessageTarget(\n worker: RemoteDomWorkerLike,\n): ThreadMessageTarget {\n return {\n send(message, transferables) {\n worker.postMessage(message, transferables ?? []);\n },\n listen(listener, { signal }) {\n const onMessage = (event: MessageEvent<unknown>): void => {\n listener(event.data);\n };\n if (worker.addEventListener) {\n worker.addEventListener(\"message\", onMessage, { signal });\n } else {\n worker.onmessage = onMessage;\n signal?.addEventListener(\n \"abort\",\n () => {\n worker.onmessage = null;\n },\n { once: true },\n );\n }\n },\n };\n}\n\nexport function createDefaultWorker(\n workerEntryUrl: string,\n options: WorkerOptions,\n): RemoteDomWorkerLike {\n if (typeof Worker === \"undefined\") {\n throw new Error(\"Remote DOM Worker is not available in this environment\");\n }\n if (!shouldWrapWorkerEntryUrl(workerEntryUrl)) {\n return new Worker(workerEntryUrl, options);\n }\n return createBlobWrappedWorker(workerEntryUrl, options);\n}\n\nfunction shouldWrapWorkerEntryUrl(workerEntryUrl: string): boolean {\n if (\n typeof location === \"undefined\" ||\n typeof Blob === \"undefined\" ||\n typeof URL.createObjectURL !== \"function\"\n ) {\n return false;\n }\n try {\n return new URL(workerEntryUrl, location.href).origin !== location.origin;\n } catch {\n return false;\n }\n}\n\nfunction createBlobWrappedWorker(\n workerEntryUrl: string,\n options: WorkerOptions,\n): RemoteDomWorkerLike {\n const blobUrl = URL.createObjectURL(\n new Blob([`import ${JSON.stringify(workerEntryUrl)};\\n`], {\n type: \"application/javascript\",\n }),\n );\n let worker: Worker;\n try {\n worker = new Worker(blobUrl, options);\n } catch (error) {\n URL.revokeObjectURL(blobUrl);\n throw error;\n }\n const terminate = worker.terminate.bind(worker);\n worker.terminate = (): void => {\n try {\n terminate();\n } finally {\n URL.revokeObjectURL(blobUrl);\n }\n };\n return worker;\n}\n"],"mappings":";;;;;;;;AAyMA,MAAM,kCAAkC;AACxC,MAAM,6BAA6B;AAEnC,MAAM,qDAAqC,IAAI,IAAoB;CACjE,CAAC,mBAAmB,iBAAiB;CACrC,CAAC,SAAS,OAAO;CACjB,CAAC,aAAa,WAAW;CACzB,CAAC,YAAY,UAAU;CACvB,CAAC,WAAW,SAAS;CACrB,CAAC,YAAY,UAAU;CACvB,CAAC,WAAW,SAAS;CACrB,CAAC,SAAS,OAAO;CACjB,CAAC,YAAY,UAAU;CACvB,CAAC,2BAA2B,yBAAyB;CACrD,CAAC,yBAAyB,uBAAuB;CACjD,CAAC,kBAAkB,gBAAgB;CACnC,CAAC,UAAU,QAAQ;CACnB,CAAC,SAAS,OAAO;CACjB,CAAC,aAAa,WAAW;CACzB,CAAC,QAAQ,MAAM;CACf,CAAC,YAAY,UAAU;CACvB,CAAC,SAAS,OAAO;CACjB,CAAC,YAAY,UAAU;CACvB,CAAC,cAAc,YAAY;CAC3B,CAAC,QAAQ,MAAM;CACf,CAAC,eAAe,aAAa;CAC7B,CAAC,YAAY,UAAU;CACvB,CAAC,YAAY,UAAU;CACvB,CAAC,YAAY,UAAU;CACvB,CAAC,YAAY,UAAU;AACzB,CAAC;AAED,SAAS,+BACP,SACA,YAC4B;CAC5B,MAAM,4BAAwC,IAAI,IAAI;CACtD,MAAM,YAAY,IAAI,IACpB,yBAAyB,KAAK,EAAE,cAAc,OAAO,CACvD;CACA,KAAK,MAAM,WAAW,8BAA8B;EAClD,IAAI,UAAU,IAAI,OAAO,GAAG;EAC5B,UAAU,IACR,SACA,oCAAoC,SAAS,SAAS,UAAU,CAClE;CACF;CACA,KAAK,MAAM,cAAc,0BAA0B;EACjD,IAAI,WAAW,oBAAoB,KAAK;EACxC,UAAU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S,wBACP,gBACA,SACqB;CACrB,MAAM,UAAU,IAAI,gBAClB,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,cAAc,EAAE,IAAI,GAAG,EACxD,MAAM,yBACR,CAAC,CACH;CACA,IAAI;CACJ,IAAI;EACF,SAAS,IAAI,OAAO,SAAS,OAAO;CACtC,SAAS,OAAO;EACd,IAAI,gBAAgB,OAAO;EAC3B,MAAM;CACR;CACA,MAAM,YAAY,OAAO,UAAU,KAAK,MAAM;CAC9C,OAAO,kBAAwB;EAC7B,IAAI;GACF,UAAU;EACZ,UAAU;GACR,IAAI,gBAAgB,OAAO;EAC7B;CACF;CACA,OAAO;AACT"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { n as RemoteDomSerializableValue, t as RemoteDomNavigationIntent } from "./remote-dom-values-
|
|
1
|
+
import { n as RemoteDomSerializableValue, t as RemoteDomNavigationIntent } from "./remote-dom-values-BR8Qnhg9.cjs";
|
|
2
2
|
import { RemoteComponentRendererMap } from "@remote-dom/react/host";
|
|
3
3
|
import { ReactElement, ReactNode } from "react";
|
|
4
|
-
|
|
5
|
-
//#region src/remote-dom-styles.d.ts
|
|
6
4
|
interface RemoteDomStyleAttachment {
|
|
7
5
|
readonly ready: Promise<void>;
|
|
8
6
|
readonly dispose: () => void;
|
|
@@ -30,8 +28,7 @@ interface RemoteDomThemeBridgeOptions {
|
|
|
30
28
|
readonly classNames?: readonly string[] | "all" | undefined;
|
|
31
29
|
readonly copyAllDataAttributes?: boolean | undefined;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
//#region src/remote-dom-renderer.d.ts
|
|
31
|
+
type RemoteDomCapabilityHandler = (capability: string, method: string, payload?: RemoteDomSerializableValue) => RemoteDomSerializableValue | Promise<RemoteDomSerializableValue>;
|
|
35
32
|
interface RemoteDomCapabilityDeclaration {
|
|
36
33
|
readonly name: string;
|
|
37
34
|
readonly version: string;
|
|
@@ -122,6 +119,5 @@ type RemoteDomWorkerFactory = (workerEntryUrl: string, options: WorkerOptions) =
|
|
|
122
119
|
* v2 only when every v2 renderer is present.
|
|
123
120
|
*/
|
|
124
121
|
declare function mountRemoteDomWidget(options: MountRemoteDomWidgetOptions): RemoteDomWidgetHandle;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//# sourceMappingURL=remote-dom-renderer-BoB9jd3B.d.cts.map
|
|
122
|
+
export { RemoteDomWidgetHandle as a, mountRemoteDomWidget as c, RemoteDomCssUrlInput as d, RemoteDomStyleAttachment as f, RemoteDomWidgetArtifact as i, RemoteDomCapabilityHandler as l, RemoteDomCapabilityDeclaration as n, RemoteDomWorkerFactory as o, RemoteDomThemeBridgeOptions as p, RemoteDomFullscreenRequest as r, RemoteDomWorkerLike as s, MountRemoteDomWidgetOptions as t, RemoteDomCssFetcher as u };
|
|
123
|
+
//# sourceMappingURL=remote-dom-renderer-D3Jz1sOH.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-dom-renderer-D3Jz1sOH.d.cts","names":[],"sources":["../src/remote-dom-styles.ts","../src/remote-dom-host-shared.ts","../src/remote-dom-renderer.ts"],"mappings":";;;UASiB;WACN,OAAO;WACP;;UAGM;WACN;WACA;WACA;WACA;WACA;;UAGM;WACN;WACA;;KAGC,gCAAgC;KAEhC,uBAAuB,gBAAgB;UAOlC;WACN,MAAM;WACN,gBAAgB;WAChB,gBAAgB;WAChB;WACA;WACA;WACA;WACA;;KCnBC,8BACV,oBACA,gBACA,UAAU,+BACP,6BAA6B,QAAQ;UC4CzB;WACN;WACA;;UAGM,gCAAgC;WACtC;WACA,uBAAuB;WACvB;;UAGM;WACN;WACA,UAAU;WACV,MAAM;WACN,YAAY;;UAGN;WACN,MAAM;WACN,UAAU;WACV,QAAQ;WACR,mBAEH,oBACA,gBACA,UAAU,+BACP,6BAA6B,QAAQ;WAErC,eACH,QAAQ,qCAAqC;WAE1C,iBAEH,SAAS,+BACN,6BAA6B,QAAQ;WAErC,YAAY,OAAO;WACnB,gBAAgB;WAChB;WACA;;WAEA,oBAAoB;WACpB;WACA;WACA;WACA;WACA,mBAAmB;;;;;;;WAOnB;;;;;;;WAOA,iCAAiC;WACjC;WACA,cACL,KAAK;WAGA,WAAW;WACX;;;;;WAKA,qBAAqB;;;;;WAKrB,mBACH,MAAM,cAAc,iBAAiB,gBAAgB;;UAI5C;WACN,YAAY;WACZ,QAAQ;WACR,OAAO;EAChB,YAAY,OAAO;EACnB;;UAGe;EACf,aAAa,OAAO;EACpB,WAAW,OAAO;EAClB,YAAY,kBAAkB,WAAW;EACzC;EACA,oBACE,iBACA,WAAW,OAAO,gCAClB;IAAY,SAAS;;;KAIb,0BACV,wBACA,SAAS,kBACN;;;;;;;;;;;iBA4RW,qBACd,SAAS,8BACR"}
|