@fluid-app/widget-runtime 0.1.282 → 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
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as isRemoteDomSerializableValue, c as REMOTE_DOM_SUPPORTED_UI_CONTRACT_VERSIONS, i as createRemoteDomUrlOriginPolicy, l as REMOTE_DOM_UI_COMPONENTS, o as isSafeRemoteDomPropertyKey, r as SUPPORTED_REMOTE_DOM_EVENTS, t as REMOTE_DOM_ALLOWED_TAG_NAMES, u as getRemoteDomUiComponent } from "./remote-dom-values-wEbrw5iW.mjs";
|
|
1
|
+
import { a as isRemoteDomSerializableValue, d as getRemoteDomUiComponent, i as createRemoteDomUrlOriginPolicy, o as isSafeRemoteDomPropertyKey, r as SUPPORTED_REMOTE_DOM_EVENTS, t as REMOTE_DOM_ALLOWED_TAG_NAMES } from "./remote-dom-values-BBN5u_Mj.mjs";
|
|
3
2
|
import { MUTATION_TYPE_INSERT_CHILD, MUTATION_TYPE_REMOVE_CHILD, MUTATION_TYPE_UPDATE_PROPERTY, MUTATION_TYPE_UPDATE_TEXT, NODE_TYPE_ELEMENT, NODE_TYPE_TEXT, ROOT_ID, UPDATE_PROPERTY_TYPE_ATTRIBUTE, UPDATE_PROPERTY_TYPE_EVENT_LISTENER, UPDATE_PROPERTY_TYPE_PROPERTY } 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
3
|
import postcssParse from "postcss/lib/parse";
|
|
9
4
|
import valueParser from "postcss-value-parser";
|
|
10
|
-
|
|
11
|
-
const REMOTE_DOM_DENIED_TAG_NAMES = new Set([
|
|
5
|
+
// src/remote-dom-sanitizer.ts
|
|
6
|
+
const REMOTE_DOM_DENIED_TAG_NAMES = /* @__PURE__ */ new Set([
|
|
12
7
|
"applet",
|
|
13
8
|
"base",
|
|
14
9
|
"body",
|
|
@@ -30,7 +25,7 @@ const REMOTE_DOM_DENIED_TAG_NAMES = new Set([
|
|
|
30
25
|
"title"
|
|
31
26
|
]);
|
|
32
27
|
const REMOTE_DOM_ALLOWED_TAG_NAME_SET = new Set(REMOTE_DOM_ALLOWED_TAG_NAMES);
|
|
33
|
-
const GLOBAL_ALLOWED_ATTRIBUTES = new Set([
|
|
28
|
+
const GLOBAL_ALLOWED_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
34
29
|
"aria-activedescendant",
|
|
35
30
|
"aria-atomic",
|
|
36
31
|
"aria-autocomplete",
|
|
@@ -92,7 +87,7 @@ const GLOBAL_ALLOWED_ATTRIBUTES = new Set([
|
|
|
92
87
|
"translate"
|
|
93
88
|
]);
|
|
94
89
|
const TAG_ALLOWED_ATTRIBUTES = {
|
|
95
|
-
a: new Set([
|
|
90
|
+
a: /* @__PURE__ */ new Set([
|
|
96
91
|
"download",
|
|
97
92
|
"href",
|
|
98
93
|
"hreflang",
|
|
@@ -100,7 +95,7 @@ const TAG_ALLOWED_ATTRIBUTES = {
|
|
|
100
95
|
"target",
|
|
101
96
|
"type"
|
|
102
97
|
]),
|
|
103
|
-
audio: new Set([
|
|
98
|
+
audio: /* @__PURE__ */ new Set([
|
|
104
99
|
"autoplay",
|
|
105
100
|
"controls",
|
|
106
101
|
"loop",
|
|
@@ -108,21 +103,21 @@ const TAG_ALLOWED_ATTRIBUTES = {
|
|
|
108
103
|
"preload",
|
|
109
104
|
"src"
|
|
110
105
|
]),
|
|
111
|
-
blockquote: new Set(["cite"]),
|
|
112
|
-
button: new Set([
|
|
106
|
+
blockquote: /* @__PURE__ */ new Set(["cite"]),
|
|
107
|
+
button: /* @__PURE__ */ new Set([
|
|
113
108
|
"disabled",
|
|
114
109
|
"name",
|
|
115
110
|
"type",
|
|
116
111
|
"value"
|
|
117
112
|
]),
|
|
118
|
-
col: new Set(["span"]),
|
|
119
|
-
colgroup: new Set(["span"]),
|
|
120
|
-
data: new Set(["value"]),
|
|
121
|
-
del: new Set(["cite", "datetime"]),
|
|
122
|
-
details: new Set(["open"]),
|
|
123
|
-
dialog: new Set(["open"]),
|
|
124
|
-
form: new Set(["autocomplete", "name"]),
|
|
125
|
-
img: new Set([
|
|
113
|
+
col: /* @__PURE__ */ new Set(["span"]),
|
|
114
|
+
colgroup: /* @__PURE__ */ new Set(["span"]),
|
|
115
|
+
data: /* @__PURE__ */ new Set(["value"]),
|
|
116
|
+
del: /* @__PURE__ */ new Set(["cite", "datetime"]),
|
|
117
|
+
details: /* @__PURE__ */ new Set(["open"]),
|
|
118
|
+
dialog: /* @__PURE__ */ new Set(["open"]),
|
|
119
|
+
form: /* @__PURE__ */ new Set(["autocomplete", "name"]),
|
|
120
|
+
img: /* @__PURE__ */ new Set([
|
|
126
121
|
"alt",
|
|
127
122
|
"decoding",
|
|
128
123
|
"height",
|
|
@@ -130,7 +125,7 @@ const TAG_ALLOWED_ATTRIBUTES = {
|
|
|
130
125
|
"src",
|
|
131
126
|
"width"
|
|
132
127
|
]),
|
|
133
|
-
input: new Set([
|
|
128
|
+
input: /* @__PURE__ */ new Set([
|
|
134
129
|
"accept",
|
|
135
130
|
"autocomplete",
|
|
136
131
|
"checked",
|
|
@@ -148,9 +143,9 @@ const TAG_ALLOWED_ATTRIBUTES = {
|
|
|
148
143
|
"type",
|
|
149
144
|
"value"
|
|
150
145
|
]),
|
|
151
|
-
ins: new Set(["cite", "datetime"]),
|
|
152
|
-
label: new Set(["for"]),
|
|
153
|
-
meter: new Set([
|
|
146
|
+
ins: /* @__PURE__ */ new Set(["cite", "datetime"]),
|
|
147
|
+
label: /* @__PURE__ */ new Set(["for"]),
|
|
148
|
+
meter: /* @__PURE__ */ new Set([
|
|
154
149
|
"high",
|
|
155
150
|
"low",
|
|
156
151
|
"max",
|
|
@@ -158,17 +153,17 @@ const TAG_ALLOWED_ATTRIBUTES = {
|
|
|
158
153
|
"optimum",
|
|
159
154
|
"value"
|
|
160
155
|
]),
|
|
161
|
-
optgroup: new Set(["disabled", "label"]),
|
|
162
|
-
option: new Set([
|
|
156
|
+
optgroup: /* @__PURE__ */ new Set(["disabled", "label"]),
|
|
157
|
+
option: /* @__PURE__ */ new Set([
|
|
163
158
|
"disabled",
|
|
164
159
|
"label",
|
|
165
160
|
"selected",
|
|
166
161
|
"value"
|
|
167
162
|
]),
|
|
168
|
-
output: new Set(["for", "name"]),
|
|
169
|
-
progress: new Set(["max", "value"]),
|
|
170
|
-
q: new Set(["cite"]),
|
|
171
|
-
select: new Set([
|
|
163
|
+
output: /* @__PURE__ */ new Set(["for", "name"]),
|
|
164
|
+
progress: /* @__PURE__ */ new Set(["max", "value"]),
|
|
165
|
+
q: /* @__PURE__ */ new Set(["cite"]),
|
|
166
|
+
select: /* @__PURE__ */ new Set([
|
|
172
167
|
"autocomplete",
|
|
173
168
|
"disabled",
|
|
174
169
|
"multiple",
|
|
@@ -176,7 +171,7 @@ const TAG_ALLOWED_ATTRIBUTES = {
|
|
|
176
171
|
"required",
|
|
177
172
|
"size"
|
|
178
173
|
]),
|
|
179
|
-
source: new Set([
|
|
174
|
+
source: /* @__PURE__ */ new Set([
|
|
180
175
|
"height",
|
|
181
176
|
"media",
|
|
182
177
|
"sizes",
|
|
@@ -184,12 +179,12 @@ const TAG_ALLOWED_ATTRIBUTES = {
|
|
|
184
179
|
"type",
|
|
185
180
|
"width"
|
|
186
181
|
]),
|
|
187
|
-
td: new Set([
|
|
182
|
+
td: /* @__PURE__ */ new Set([
|
|
188
183
|
"colspan",
|
|
189
184
|
"headers",
|
|
190
185
|
"rowspan"
|
|
191
186
|
]),
|
|
192
|
-
textarea: new Set([
|
|
187
|
+
textarea: /* @__PURE__ */ new Set([
|
|
193
188
|
"autocomplete",
|
|
194
189
|
"cols",
|
|
195
190
|
"disabled",
|
|
@@ -203,22 +198,22 @@ const TAG_ALLOWED_ATTRIBUTES = {
|
|
|
203
198
|
"value",
|
|
204
199
|
"wrap"
|
|
205
200
|
]),
|
|
206
|
-
th: new Set([
|
|
201
|
+
th: /* @__PURE__ */ new Set([
|
|
207
202
|
"abbr",
|
|
208
203
|
"colspan",
|
|
209
204
|
"headers",
|
|
210
205
|
"rowspan",
|
|
211
206
|
"scope"
|
|
212
207
|
]),
|
|
213
|
-
time: new Set(["datetime"]),
|
|
214
|
-
track: new Set([
|
|
208
|
+
time: /* @__PURE__ */ new Set(["datetime"]),
|
|
209
|
+
track: /* @__PURE__ */ new Set([
|
|
215
210
|
"default",
|
|
216
211
|
"kind",
|
|
217
212
|
"label",
|
|
218
213
|
"src",
|
|
219
214
|
"srclang"
|
|
220
215
|
]),
|
|
221
|
-
video: new Set([
|
|
216
|
+
video: /* @__PURE__ */ new Set([
|
|
222
217
|
"autoplay",
|
|
223
218
|
"controls",
|
|
224
219
|
"height",
|
|
@@ -231,7 +226,7 @@ const TAG_ALLOWED_ATTRIBUTES = {
|
|
|
231
226
|
"width"
|
|
232
227
|
])
|
|
233
228
|
};
|
|
234
|
-
const BOOLEAN_ATTRIBUTES = new Set([
|
|
229
|
+
const BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
235
230
|
"autoplay",
|
|
236
231
|
"checked",
|
|
237
232
|
"controls",
|
|
@@ -248,7 +243,7 @@ const BOOLEAN_ATTRIBUTES = new Set([
|
|
|
248
243
|
"required",
|
|
249
244
|
"selected"
|
|
250
245
|
]);
|
|
251
|
-
const SAFE_INPUT_TYPES = new Set([
|
|
246
|
+
const SAFE_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
252
247
|
"button",
|
|
253
248
|
"checkbox",
|
|
254
249
|
"color",
|
|
@@ -271,36 +266,36 @@ const SAFE_INPUT_TYPES = new Set([
|
|
|
271
266
|
"url",
|
|
272
267
|
"week"
|
|
273
268
|
]);
|
|
274
|
-
const SAFE_BUTTON_TYPES = new Set([
|
|
269
|
+
const SAFE_BUTTON_TYPES = /* @__PURE__ */ new Set([
|
|
275
270
|
"button",
|
|
276
271
|
"reset",
|
|
277
272
|
"submit"
|
|
278
273
|
]);
|
|
279
|
-
const SAFE_LOADING_VALUES = new Set(["eager", "lazy"]);
|
|
280
|
-
const SAFE_DECODING_VALUES = new Set([
|
|
274
|
+
const SAFE_LOADING_VALUES = /* @__PURE__ */ new Set(["eager", "lazy"]);
|
|
275
|
+
const SAFE_DECODING_VALUES = /* @__PURE__ */ new Set([
|
|
281
276
|
"async",
|
|
282
277
|
"auto",
|
|
283
278
|
"sync"
|
|
284
279
|
]);
|
|
285
|
-
const SAFE_PRELOAD_VALUES = new Set([
|
|
280
|
+
const SAFE_PRELOAD_VALUES = /* @__PURE__ */ new Set([
|
|
286
281
|
"auto",
|
|
287
282
|
"metadata",
|
|
288
283
|
"none"
|
|
289
284
|
]);
|
|
290
|
-
const SAFE_TRACK_KIND_VALUES = new Set([
|
|
285
|
+
const SAFE_TRACK_KIND_VALUES = /* @__PURE__ */ new Set([
|
|
291
286
|
"captions",
|
|
292
287
|
"chapters",
|
|
293
288
|
"descriptions",
|
|
294
289
|
"metadata",
|
|
295
290
|
"subtitles"
|
|
296
291
|
]);
|
|
297
|
-
const URL_VALUED_ATTRIBUTES = new Set([
|
|
292
|
+
const URL_VALUED_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
298
293
|
"cite",
|
|
299
294
|
"href",
|
|
300
295
|
"poster",
|
|
301
296
|
"src"
|
|
302
297
|
]);
|
|
303
|
-
const MEDIA_SOURCE_TAGS = new Set([
|
|
298
|
+
const MEDIA_SOURCE_TAGS = /* @__PURE__ */ new Set([
|
|
304
299
|
"audio",
|
|
305
300
|
"img",
|
|
306
301
|
"source",
|
|
@@ -592,7 +587,7 @@ function escapeCssString(value) {
|
|
|
592
587
|
}
|
|
593
588
|
const CSS_URL_FUNCTION_NAME = "url";
|
|
594
589
|
const CSS_IMPORT_RULE_NAME = "import";
|
|
595
|
-
const CSS_REJECTED_URL_FUNCTION_NAMES = new Set(["image-set", "-webkit-image-set"]);
|
|
590
|
+
const CSS_REJECTED_URL_FUNCTION_NAMES = /* @__PURE__ */ new Set(["image-set", "-webkit-image-set"]);
|
|
596
591
|
function sanitizeCssTextUrlReferences(cssText, originPolicy) {
|
|
597
592
|
let stylesheet;
|
|
598
593
|
try {
|
|
@@ -848,8 +843,7 @@ function readPointerState(event) {
|
|
|
848
843
|
function isObjectRecord$1(value) {
|
|
849
844
|
return typeof value === "object" && value !== null;
|
|
850
845
|
}
|
|
851
|
-
|
|
852
|
-
//#region src/remote-dom-sanitizing-connection.ts
|
|
846
|
+
// src/remote-dom-sanitizing-connection.ts
|
|
853
847
|
var RemoteDomConnectionCallDeniedError = class extends Error {
|
|
854
848
|
constructor(method) {
|
|
855
849
|
super(`Remote DOM element method "${method}" was blocked; host method calls are denied.`);
|
|
@@ -857,7 +851,7 @@ var RemoteDomConnectionCallDeniedError = class extends Error {
|
|
|
857
851
|
}
|
|
858
852
|
};
|
|
859
853
|
function createSanitizingRemoteConnection(options) {
|
|
860
|
-
const state = { nodes: new Map([[ROOT_ID, {
|
|
854
|
+
const state = { nodes: /* @__PURE__ */ new Map([[ROOT_ID, {
|
|
861
855
|
kind: "element",
|
|
862
856
|
localName: "",
|
|
863
857
|
childIds: []
|
|
@@ -935,7 +929,7 @@ function normalizeMutationRecordForHost(options, state, mutation, pendingEventLi
|
|
|
935
929
|
ok: false,
|
|
936
930
|
message: "Remote DOM insertChild index was invalid."
|
|
937
931
|
};
|
|
938
|
-
const normalized = normalizeRemoteNodeForHost(options,
|
|
932
|
+
const normalized = normalizeRemoteNodeForHost(options, child, new Set(state.nodes.keys()), pendingEventListenerUpdates);
|
|
939
933
|
if (!normalized.ok) return normalized;
|
|
940
934
|
if (Math.max(0, state.nodes.size - 1) + normalized.nodeCount > options.maxDomNodeCount) return {
|
|
941
935
|
ok: false,
|
|
@@ -1074,7 +1068,7 @@ function normalizeUpdatePropertyRecordForHost(options, state, mutation, pendingE
|
|
|
1074
1068
|
]
|
|
1075
1069
|
};
|
|
1076
1070
|
}
|
|
1077
|
-
function normalizeRemoteNodeForHost(options,
|
|
1071
|
+
function normalizeRemoteNodeForHost(options, value, seen, pendingEventListenerUpdates) {
|
|
1078
1072
|
if (!isObjectRecord(value)) return {
|
|
1079
1073
|
ok: false,
|
|
1080
1074
|
message: "Remote DOM render payload was not a node."
|
|
@@ -1116,7 +1110,7 @@ function normalizeRemoteNodeForHost(options, state, value, seen, pendingEventLis
|
|
|
1116
1110
|
const children = [];
|
|
1117
1111
|
let nodeCount = 1;
|
|
1118
1112
|
for (const child of value.children) {
|
|
1119
|
-
const normalized = normalizeRemoteNodeForHost(options,
|
|
1113
|
+
const normalized = normalizeRemoteNodeForHost(options, child, seen, pendingEventListenerUpdates);
|
|
1120
1114
|
if (!normalized.ok) return normalized;
|
|
1121
1115
|
children.push(normalized.node);
|
|
1122
1116
|
nodeCount += normalized.nodeCount;
|
|
@@ -1234,8 +1228,215 @@ function parseRemoteMutationRecord(value) {
|
|
|
1234
1228
|
function isObjectRecord(value) {
|
|
1235
1229
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1236
1230
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1231
|
+
// src/remote-dom-host-shared.ts
|
|
1232
|
+
const REMOTE_DOM_NODE_ID_ATTRIBUTE = "data-fluid-remote-dom-node-id";
|
|
1233
|
+
/** Serializes a DOM event and hands it to the worker's listener. */
|
|
1234
|
+
function deliverRemoteDomEvent({ event, eventName, currentTargetId, currentTargetTagName, listener, reporter, isDisposed }) {
|
|
1235
|
+
if (eventName === "submit" && event.cancelable) event.preventDefault();
|
|
1236
|
+
const targetId = resolveRenderedRemoteNodeId(event) ?? currentTargetId;
|
|
1237
|
+
const payload = serializeRemoteDomEvent(event, targetId, currentTargetId, currentTargetTagName);
|
|
1238
|
+
if (!payload) return;
|
|
1239
|
+
try {
|
|
1240
|
+
const result = listener({
|
|
1241
|
+
targetId,
|
|
1242
|
+
detail: toSerializableEventPayload(payload)
|
|
1243
|
+
});
|
|
1244
|
+
if (isPromiseLike(result)) result.catch((error) => {
|
|
1245
|
+
if (!isDisposed()) reportHostError(reporter, "Remote DOM event delivery failed", error);
|
|
1246
|
+
});
|
|
1247
|
+
} catch (error) {
|
|
1248
|
+
if (!isDisposed()) reportHostError(reporter, "Remote DOM event delivery failed", error);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* True when an element between the event's target and `currentTargetId`
|
|
1253
|
+
* has its own listener for the event, so the closer one handles it.
|
|
1254
|
+
*/
|
|
1255
|
+
function hasCloserRemoteEventListener(event, currentTargetId, hasListener) {
|
|
1256
|
+
for (const pathTarget of event.composedPath()) {
|
|
1257
|
+
if (!(pathTarget instanceof Element)) continue;
|
|
1258
|
+
const id = pathTarget.getAttribute(REMOTE_DOM_NODE_ID_ATTRIBUTE);
|
|
1259
|
+
if (!id) continue;
|
|
1260
|
+
if (id === currentTargetId) return false;
|
|
1261
|
+
if (hasListener(id)) return true;
|
|
1262
|
+
}
|
|
1263
|
+
return false;
|
|
1264
|
+
}
|
|
1265
|
+
function resolveRenderedRemoteNodeId(event) {
|
|
1266
|
+
for (const pathTarget of event.composedPath()) {
|
|
1267
|
+
if (!(pathTarget instanceof Element)) continue;
|
|
1268
|
+
const id = pathTarget.getAttribute(REMOTE_DOM_NODE_ID_ATTRIBUTE);
|
|
1269
|
+
if (id) return id;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
/** Answers a worker's capability call, checked against what it declared. */
|
|
1273
|
+
function callRemoteDomCapability(context, capability, method, payload) {
|
|
1274
|
+
if (context.isDisposed()) return Promise.reject(/* @__PURE__ */ new Error("Remote DOM widget has been disposed"));
|
|
1275
|
+
if (!context.declared.some((declaration) => declaration.name === capability)) return Promise.reject(/* @__PURE__ */ new Error(`Remote DOM capability "${capability}" was not declared`));
|
|
1276
|
+
if (payload !== void 0 && !isRemoteDomSerializableValue(payload)) return Promise.reject(/* @__PURE__ */ new Error("Remote DOM capability payload was not serializable"));
|
|
1277
|
+
if (capability === "fullscreen" && context.onFullscreen) return Promise.resolve().then(() => context.onFullscreen?.({
|
|
1278
|
+
method,
|
|
1279
|
+
...payload === void 0 ? {} : { payload },
|
|
1280
|
+
host: context.host,
|
|
1281
|
+
shadowRoot: context.shadowRoot
|
|
1282
|
+
})).then((result) => {
|
|
1283
|
+
if (result === void 0) throw new Error("Remote DOM fullscreen handler returned no result");
|
|
1284
|
+
return assertSerializableCapabilityResult(result);
|
|
1285
|
+
});
|
|
1286
|
+
if (!context.callCapability) return Promise.reject(/* @__PURE__ */ new Error(`No host handler is configured for capability "${capability}"`));
|
|
1287
|
+
return Promise.resolve().then(() => context.callCapability?.(capability, method, payload)).then((result) => {
|
|
1288
|
+
if (result === void 0) throw new Error(`Capability handler for "${capability}" returned no result`);
|
|
1289
|
+
return assertSerializableCapabilityResult(result);
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
function assertSerializableCapabilityResult(result) {
|
|
1293
|
+
if (!isRemoteDomSerializableValue(result)) throw new Error("Remote DOM capability result was not serializable");
|
|
1294
|
+
return result;
|
|
1295
|
+
}
|
|
1296
|
+
/** Routes a click on a drawn anchor to the host's navigation handler. */
|
|
1297
|
+
function handleRemoteDomNavigationIntent(context, event) {
|
|
1298
|
+
if (!(event instanceof MouseEvent)) return;
|
|
1299
|
+
const anchor = (event.target instanceof Element ? event.target : event.target instanceof Text ? event.target.parentElement : null)?.closest("a[href]");
|
|
1300
|
+
if (!(anchor instanceof HTMLAnchorElement)) return;
|
|
1301
|
+
if (!context.shadowRoot.contains(anchor)) return;
|
|
1302
|
+
if (resolveAllowedAnchorUrl(anchor.getAttribute("href"), context.allowedAnchorUrls)) {
|
|
1303
|
+
enforceAllowedAnchorSafetyAttributes(anchor);
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
if (event.cancelable) event.preventDefault();
|
|
1307
|
+
const href = sanitizeRemoteDomUrl(anchor.getAttribute("href"), {
|
|
1308
|
+
allowHashOnly: true,
|
|
1309
|
+
allowMailTo: false,
|
|
1310
|
+
allowRelative: true,
|
|
1311
|
+
allowTel: false,
|
|
1312
|
+
allowedHttpOriginGroups: ["navigation"],
|
|
1313
|
+
originPolicy: context.urlOriginPolicy,
|
|
1314
|
+
relativeUrlBase: "navigation"
|
|
1315
|
+
});
|
|
1316
|
+
const url = href ? resolveInternalNavigationUrl(href, context.navigationOrigin) : void 0;
|
|
1317
|
+
if (!href || !url || !context.onNavigate) {
|
|
1318
|
+
reportHostError(context, "Remote DOM navigation was blocked because no allowed internal route handler was available");
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
const targetId = anchor.closest(`[data-fluid-remote-dom-node-id]`)?.getAttribute("data-fluid-remote-dom-node-id") ?? void 0;
|
|
1322
|
+
Promise.resolve(context.onNavigate({
|
|
1323
|
+
href,
|
|
1324
|
+
url,
|
|
1325
|
+
source: "anchor",
|
|
1326
|
+
...targetId === void 0 ? {} : { targetId },
|
|
1327
|
+
altKey: event.altKey,
|
|
1328
|
+
button: event.button,
|
|
1329
|
+
ctrlKey: event.ctrlKey,
|
|
1330
|
+
metaKey: event.metaKey,
|
|
1331
|
+
shiftKey: event.shiftKey
|
|
1332
|
+
})).catch((error) => {
|
|
1333
|
+
if (!context.isDisposed()) reportHostError(context, "Remote DOM navigation handler failed", error);
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
function resolveAllowedAnchorUrl(href, allowedAnchorUrls) {
|
|
1337
|
+
if (!href || !allowedAnchorUrls) return void 0;
|
|
1338
|
+
let parsed;
|
|
1339
|
+
try {
|
|
1340
|
+
parsed = new URL(href);
|
|
1341
|
+
} catch {
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return;
|
|
1345
|
+
return allowedAnchorUrls.has(parsed.href) ? parsed.href : void 0;
|
|
1346
|
+
}
|
|
1347
|
+
/** Forces new-tab safety on every drawn anchor whose URL is allowed. */
|
|
1348
|
+
function enforceAllowedAnchorSafety(root, allowedAnchorUrls) {
|
|
1349
|
+
if (!allowedAnchorUrls) return;
|
|
1350
|
+
for (const anchor of root.querySelectorAll("a[href]")) if (resolveAllowedAnchorUrl(anchor.getAttribute("href"), allowedAnchorUrls)) enforceAllowedAnchorSafetyAttributes(anchor);
|
|
1351
|
+
}
|
|
1352
|
+
function enforceAllowedAnchorSafetyAttributes(anchor) {
|
|
1353
|
+
anchor.target = "_blank";
|
|
1354
|
+
const relTokens = new Set(anchor.rel.split(/\s+/u).filter(Boolean));
|
|
1355
|
+
relTokens.add("noopener");
|
|
1356
|
+
relTokens.add("noreferrer");
|
|
1357
|
+
anchor.rel = Array.from(relTokens).join(" ");
|
|
1358
|
+
anchor.removeAttribute("download");
|
|
1359
|
+
}
|
|
1360
|
+
function normalizeNavigationOrigin(value) {
|
|
1361
|
+
if (!value) return void 0;
|
|
1362
|
+
try {
|
|
1363
|
+
const url = new URL(value);
|
|
1364
|
+
return url.protocol === "http:" || url.protocol === "https:" ? url.origin : void 0;
|
|
1365
|
+
} catch {
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
function resolveInternalNavigationUrl(href, navigationOrigin) {
|
|
1370
|
+
if (href.startsWith("#")) return href;
|
|
1371
|
+
if (href.startsWith("//") || /^https?:(?!\/\/)/iu.test(href)) return;
|
|
1372
|
+
try {
|
|
1373
|
+
const url = new URL(href, navigationOrigin ?? "https://fluid.local");
|
|
1374
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return;
|
|
1375
|
+
if (/^[a-z][a-z\d+.-]*:/iu.test(href) && (!navigationOrigin || url.origin !== navigationOrigin)) return;
|
|
1376
|
+
return `${url.pathname}${url.search}${url.hash}`;
|
|
1377
|
+
} catch {
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
function createSubmitPreventionListener() {
|
|
1382
|
+
return (event) => {
|
|
1383
|
+
if (event.cancelable) event.preventDefault();
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
function toSerializableEventPayload(payload) {
|
|
1387
|
+
const result = {
|
|
1388
|
+
bubbles: payload.bubbles,
|
|
1389
|
+
cancelable: payload.cancelable,
|
|
1390
|
+
currentTargetId: payload.currentTargetId,
|
|
1391
|
+
defaultPrevented: payload.defaultPrevented,
|
|
1392
|
+
targetId: payload.targetId,
|
|
1393
|
+
type: payload.type
|
|
1394
|
+
};
|
|
1395
|
+
for (const key of [
|
|
1396
|
+
"altKey",
|
|
1397
|
+
"button",
|
|
1398
|
+
"buttons",
|
|
1399
|
+
"checked",
|
|
1400
|
+
"clientX",
|
|
1401
|
+
"clientY",
|
|
1402
|
+
"code",
|
|
1403
|
+
"ctrlKey",
|
|
1404
|
+
"detailJson",
|
|
1405
|
+
"isPrimary",
|
|
1406
|
+
"key",
|
|
1407
|
+
"metaKey",
|
|
1408
|
+
"pointerId",
|
|
1409
|
+
"pointerType",
|
|
1410
|
+
"shiftKey",
|
|
1411
|
+
"value"
|
|
1412
|
+
]) {
|
|
1413
|
+
const value = payload[key];
|
|
1414
|
+
if (value !== void 0) result[key] = value;
|
|
1415
|
+
}
|
|
1416
|
+
return result;
|
|
1417
|
+
}
|
|
1418
|
+
function isPromiseLike(value) {
|
|
1419
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
1420
|
+
}
|
|
1421
|
+
function reportHostError(reporter, message, cause) {
|
|
1422
|
+
try {
|
|
1423
|
+
reporter.onError?.(new Error(message, cause === void 0 ? {} : { cause }));
|
|
1424
|
+
} catch {}
|
|
1425
|
+
}
|
|
1426
|
+
function collectCleanupErrors(cleanupSteps) {
|
|
1427
|
+
const errors = [];
|
|
1428
|
+
for (const cleanup of cleanupSteps) try {
|
|
1429
|
+
cleanup();
|
|
1430
|
+
} catch (error) {
|
|
1431
|
+
errors.push(error);
|
|
1432
|
+
}
|
|
1433
|
+
return errors;
|
|
1434
|
+
}
|
|
1435
|
+
function reportCleanupErrors(reporter, message, errors) {
|
|
1436
|
+
if (errors.length === 0) return;
|
|
1437
|
+
reportHostError(reporter, message, errors.length === 1 ? errors[0] : new AggregateError(errors, "Multiple cleanup operations failed"));
|
|
1438
|
+
}
|
|
1439
|
+
// src/remote-dom-styles.ts
|
|
1239
1440
|
const remoteDomCssArtifactCache = /* @__PURE__ */ new Map();
|
|
1240
1441
|
const DEFAULT_THEME_DATA_ATTRIBUTES = [
|
|
1241
1442
|
"data-theme",
|
|
@@ -1251,7 +1452,7 @@ function attachRemoteDomStyles({ artifact, root, cssText, widgetCssText, cssUrls
|
|
|
1251
1452
|
const acquiredArtifacts = [];
|
|
1252
1453
|
let disposed = false;
|
|
1253
1454
|
let failureReported = false;
|
|
1254
|
-
const resolvedUrlOriginPolicy = urlOriginPolicy ?? createRemoteDomUrlOriginPolicy({ artifactUrls: collectArtifactUrls
|
|
1455
|
+
const resolvedUrlOriginPolicy = urlOriginPolicy ?? createRemoteDomUrlOriginPolicy({ artifactUrls: collectArtifactUrls(artifact) });
|
|
1255
1456
|
const { sources, failedSourceCount: rejectedSourceCount } = createStyleSources({
|
|
1256
1457
|
artifact,
|
|
1257
1458
|
cssText,
|
|
@@ -1421,7 +1622,7 @@ function createRemoteDomThemeBridge(options) {
|
|
|
1421
1622
|
}
|
|
1422
1623
|
};
|
|
1423
1624
|
}
|
|
1424
|
-
function collectArtifactUrls
|
|
1625
|
+
function collectArtifactUrls(artifact) {
|
|
1425
1626
|
return [
|
|
1426
1627
|
artifact.workerEntryUrl,
|
|
1427
1628
|
...artifact.cssUrls,
|
|
@@ -1734,648 +1935,6 @@ function mirrorClasses({ host, sourceElement, classNames, managedClasses, origin
|
|
|
1734
1935
|
host.classList.add(className);
|
|
1735
1936
|
}
|
|
1736
1937
|
}
|
|
1737
|
-
|
|
1738
|
-
//#region src/remote-dom-renderer.ts
|
|
1739
|
-
const DEFAULT_MAX_MUTATION_BATCH_SIZE = 1e3;
|
|
1740
|
-
const DEFAULT_MAX_DOM_NODE_COUNT = 1e3;
|
|
1741
|
-
const BOOLEAN_ATTRIBUTE_REACT_PROPERTIES = new Map([
|
|
1742
|
-
["allowfullscreen", "allowFullScreen"],
|
|
1743
|
-
["async", "async"],
|
|
1744
|
-
["autofocus", "autoFocus"],
|
|
1745
|
-
["autoplay", "autoPlay"],
|
|
1746
|
-
["checked", "checked"],
|
|
1747
|
-
["controls", "controls"],
|
|
1748
|
-
["default", "default"],
|
|
1749
|
-
["defer", "defer"],
|
|
1750
|
-
["disabled", "disabled"],
|
|
1751
|
-
["disablepictureinpicture", "disablePictureInPicture"],
|
|
1752
|
-
["disableremoteplayback", "disableRemotePlayback"],
|
|
1753
|
-
["formnovalidate", "formNoValidate"],
|
|
1754
|
-
["hidden", "hidden"],
|
|
1755
|
-
["inert", "inert"],
|
|
1756
|
-
["itemscope", "itemScope"],
|
|
1757
|
-
["loop", "loop"],
|
|
1758
|
-
["multiple", "multiple"],
|
|
1759
|
-
["muted", "muted"],
|
|
1760
|
-
["nomodule", "noModule"],
|
|
1761
|
-
["novalidate", "noValidate"],
|
|
1762
|
-
["open", "open"],
|
|
1763
|
-
["playsinline", "playsInline"],
|
|
1764
|
-
["readonly", "readOnly"],
|
|
1765
|
-
["required", "required"],
|
|
1766
|
-
["reversed", "reversed"],
|
|
1767
|
-
["selected", "selected"]
|
|
1768
|
-
]);
|
|
1769
|
-
function createRemoteComponentRenderers(options, isDisposed) {
|
|
1770
|
-
const renderers = /* @__PURE__ */ new Map();
|
|
1771
|
-
const fluidTags = new Set(REMOTE_DOM_UI_COMPONENTS.map(({ tagName }) => tagName));
|
|
1772
|
-
for (const tagName of REMOTE_DOM_ALLOWED_TAG_NAMES) {
|
|
1773
|
-
if (fluidTags.has(tagName)) continue;
|
|
1774
|
-
renderers.set(tagName, createNativeRemoteComponentRenderer(tagName, options, isDisposed));
|
|
1775
|
-
}
|
|
1776
|
-
for (const definition of REMOTE_DOM_UI_COMPONENTS) {
|
|
1777
|
-
if (definition.contractVersion !== "1") continue;
|
|
1778
|
-
renderers.set(definition.tagName, createNativeRemoteComponentRenderer(definition.tagName, options, isDisposed));
|
|
1779
|
-
}
|
|
1780
|
-
renderers.set("remote-fragment", RemoteFragmentRenderer);
|
|
1781
|
-
for (const [tagName, renderer] of options.componentRenderers ?? []) {
|
|
1782
|
-
if (!fluidTags.has(tagName)) continue;
|
|
1783
|
-
renderers.set(tagName, renderer);
|
|
1784
|
-
}
|
|
1785
|
-
return renderers;
|
|
1786
|
-
}
|
|
1787
|
-
function createNativeRemoteComponentRenderer(tagName, options, isDisposed) {
|
|
1788
|
-
function NativeRemoteComponent({ element, receiver, components }) {
|
|
1789
|
-
const attachedElement = useRemoteReceived(element, receiver);
|
|
1790
|
-
const elementRef = useRef(null);
|
|
1791
|
-
useEffect(() => {
|
|
1792
|
-
const hostElement = elementRef.current;
|
|
1793
|
-
if (!hostElement || !attachedElement) return;
|
|
1794
|
-
const cleanup = [];
|
|
1795
|
-
for (const [eventName, listener] of Object.entries(attachedElement.eventListeners)) {
|
|
1796
|
-
if (typeof listener !== "function") continue;
|
|
1797
|
-
const handleEvent = (event) => {
|
|
1798
|
-
if (hasCloserRemoteEventListener(receiver, event, attachedElement.id, eventName)) return;
|
|
1799
|
-
deliverRemoteDomEvent({
|
|
1800
|
-
event,
|
|
1801
|
-
eventName,
|
|
1802
|
-
currentTargetId: attachedElement.id,
|
|
1803
|
-
currentTargetTagName: tagName,
|
|
1804
|
-
listener,
|
|
1805
|
-
options,
|
|
1806
|
-
isDisposed
|
|
1807
|
-
});
|
|
1808
|
-
};
|
|
1809
|
-
hostElement.addEventListener(eventName, handleEvent);
|
|
1810
|
-
cleanup.push(() => hostElement.removeEventListener(eventName, handleEvent));
|
|
1811
|
-
}
|
|
1812
|
-
return () => {
|
|
1813
|
-
for (const dispose of cleanup) dispose();
|
|
1814
|
-
};
|
|
1815
|
-
}, [
|
|
1816
|
-
attachedElement,
|
|
1817
|
-
attachedElement?.version,
|
|
1818
|
-
receiver
|
|
1819
|
-
]);
|
|
1820
|
-
useLayoutEffect(() => {
|
|
1821
|
-
const hostElement = elementRef.current;
|
|
1822
|
-
if (!(hostElement instanceof HTMLInputElement) || !attachedElement) return;
|
|
1823
|
-
const value = attachedElement.properties.value;
|
|
1824
|
-
if (typeof value === "string" && hostElement.value !== value) hostElement.value = value;
|
|
1825
|
-
const checked = attachedElement.properties.checked;
|
|
1826
|
-
if (typeof checked === "boolean" && hostElement.checked !== checked) hostElement.checked = checked;
|
|
1827
|
-
}, [attachedElement, attachedElement?.version]);
|
|
1828
|
-
if (!attachedElement) return null;
|
|
1829
|
-
const domProps = {};
|
|
1830
|
-
for (const [name, value] of Object.entries({
|
|
1831
|
-
...attachedElement.attributes,
|
|
1832
|
-
...attachedElement.properties
|
|
1833
|
-
})) {
|
|
1834
|
-
if (tagName === "input" && (name === "checked" || name === "value")) continue;
|
|
1835
|
-
const booleanProperty = BOOLEAN_ATTRIBUTE_REACT_PROPERTIES.get(name);
|
|
1836
|
-
domProps[booleanProperty ?? toReactDomPropertyName(name)] = booleanProperty && typeof value === "string" ? true : value;
|
|
1837
|
-
}
|
|
1838
|
-
domProps["data-fluid-remote-dom-node-id"] = attachedElement.id;
|
|
1839
|
-
domProps.ref = elementRef;
|
|
1840
|
-
const renderOptions = {
|
|
1841
|
-
receiver,
|
|
1842
|
-
components
|
|
1843
|
-
};
|
|
1844
|
-
return createElement(tagName, domProps, ...attachedElement.children.map((child) => renderRemoteNode(child, renderOptions)));
|
|
1845
|
-
}
|
|
1846
|
-
NativeRemoteComponent.displayName = `RemoteDomNative(${tagName})`;
|
|
1847
|
-
return NativeRemoteComponent;
|
|
1848
|
-
}
|
|
1849
|
-
function RemoteRootEventBoundary({ receiver, container, options, isDisposed, children }) {
|
|
1850
|
-
const root = useRemoteReceived(receiver.root, receiver);
|
|
1851
|
-
useEffect(() => {
|
|
1852
|
-
if (!root) return;
|
|
1853
|
-
const cleanup = [];
|
|
1854
|
-
for (const [eventName, listener] of Object.entries(root.eventListeners)) {
|
|
1855
|
-
if (typeof listener !== "function") continue;
|
|
1856
|
-
const handleEvent = (event) => {
|
|
1857
|
-
if (hasCloserRemoteEventListener(receiver, event, ROOT_ID, eventName)) return;
|
|
1858
|
-
deliverRemoteDomEvent({
|
|
1859
|
-
event,
|
|
1860
|
-
eventName,
|
|
1861
|
-
currentTargetId: ROOT_ID,
|
|
1862
|
-
listener,
|
|
1863
|
-
options,
|
|
1864
|
-
isDisposed
|
|
1865
|
-
});
|
|
1866
|
-
};
|
|
1867
|
-
container.addEventListener(eventName, handleEvent, { capture: true });
|
|
1868
|
-
cleanup.push(() => container.removeEventListener(eventName, handleEvent, { capture: true }));
|
|
1869
|
-
}
|
|
1870
|
-
return () => {
|
|
1871
|
-
for (const dispose of cleanup) dispose();
|
|
1872
|
-
};
|
|
1873
|
-
}, [
|
|
1874
|
-
container,
|
|
1875
|
-
isDisposed,
|
|
1876
|
-
options,
|
|
1877
|
-
receiver,
|
|
1878
|
-
root,
|
|
1879
|
-
root?.version
|
|
1880
|
-
]);
|
|
1881
|
-
return children;
|
|
1882
|
-
}
|
|
1883
|
-
function deliverRemoteDomEvent({ event, eventName, currentTargetId, currentTargetTagName, listener, options, isDisposed }) {
|
|
1884
|
-
if (eventName === "submit" && event.cancelable) event.preventDefault();
|
|
1885
|
-
const targetId = resolveRenderedRemoteNodeId(event) ?? currentTargetId;
|
|
1886
|
-
const payload = serializeRemoteDomEvent(event, targetId, currentTargetId, currentTargetTagName);
|
|
1887
|
-
if (!payload) return;
|
|
1888
|
-
try {
|
|
1889
|
-
const result = listener({
|
|
1890
|
-
targetId,
|
|
1891
|
-
detail: toSerializableEventPayload(payload)
|
|
1892
|
-
});
|
|
1893
|
-
if (isPromiseLike(result)) result.catch((error) => {
|
|
1894
|
-
if (!isDisposed()) reportError(options, "Remote DOM event delivery failed", error);
|
|
1895
|
-
});
|
|
1896
|
-
} catch (error) {
|
|
1897
|
-
if (!isDisposed()) reportError(options, "Remote DOM event delivery failed", error);
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
function hasCloserRemoteEventListener(receiver, event, currentTargetId, eventName) {
|
|
1901
|
-
for (const pathTarget of event.composedPath()) {
|
|
1902
|
-
if (!(pathTarget instanceof Element)) continue;
|
|
1903
|
-
const id = pathTarget.getAttribute("data-fluid-remote-dom-node-id");
|
|
1904
|
-
if (!id) continue;
|
|
1905
|
-
if (id === currentTargetId) return false;
|
|
1906
|
-
const remoteNode = receiver.get({ id });
|
|
1907
|
-
if (remoteNode && "eventListeners" in remoteNode && typeof remoteNode.eventListeners[eventName] === "function") return true;
|
|
1908
|
-
}
|
|
1909
|
-
return false;
|
|
1910
|
-
}
|
|
1911
|
-
function resolveRenderedRemoteNodeId(event) {
|
|
1912
|
-
for (const pathTarget of event.composedPath()) {
|
|
1913
|
-
if (!(pathTarget instanceof Element)) continue;
|
|
1914
|
-
const id = pathTarget.getAttribute("data-fluid-remote-dom-node-id");
|
|
1915
|
-
if (id) return id;
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
function toReactDomPropertyName(name) {
|
|
1919
|
-
switch (name) {
|
|
1920
|
-
case "class": return "className";
|
|
1921
|
-
case "for": return "htmlFor";
|
|
1922
|
-
case "readonly": return "readOnly";
|
|
1923
|
-
case "tabindex": return "tabIndex";
|
|
1924
|
-
default: return name;
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
function getSupportedUiContractVersions(componentRenderers) {
|
|
1928
|
-
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");
|
|
1929
|
-
}
|
|
1930
|
-
/**
|
|
1931
|
-
* Mounts one Remote DOM widget worker into an isolated shadow root.
|
|
1932
|
-
*
|
|
1933
|
-
* The low-level runtime supports native Remote DOM elements by default. A host
|
|
1934
|
-
* that supports worker-facing Fluid UI components must also provide the full
|
|
1935
|
-
* reviewed {@link MountRemoteDomWidgetOptions.componentRenderers} map, a
|
|
1936
|
-
* containment-aware {@link MountRemoteDomWidgetOptions.wrapRemoteRoot}, and
|
|
1937
|
-
* the matching Fluid component CSS. The runtime advertises Fluid UI contract
|
|
1938
|
-
* v2 only when every v2 renderer is present.
|
|
1939
|
-
*/
|
|
1940
|
-
function mountRemoteDomWidget(options) {
|
|
1941
|
-
const initialProps = options.props ?? null;
|
|
1942
|
-
assertSerializable(initialProps, "Initial widget props");
|
|
1943
|
-
const shadowRoot = createShadowRoot(options.host);
|
|
1944
|
-
const navigationOrigin = normalizeNavigationOrigin(options.hostOrigin);
|
|
1945
|
-
const urlOriginPolicy = createRemoteDomUrlOriginPolicy({
|
|
1946
|
-
artifactUrls: collectArtifactUrls(options.artifact),
|
|
1947
|
-
...options.mediaOrigins === void 0 ? {} : { mediaOrigins: options.mediaOrigins },
|
|
1948
|
-
...navigationOrigin === void 0 ? {} : { navigationOrigin }
|
|
1949
|
-
});
|
|
1950
|
-
const styles = attachRemoteDomStyles({
|
|
1951
|
-
artifact: options.artifact,
|
|
1952
|
-
root: shadowRoot,
|
|
1953
|
-
urlOriginPolicy,
|
|
1954
|
-
onFailure: (count) => {
|
|
1955
|
-
reportError(options, `${count} Remote DOM widget styles failed to load`);
|
|
1956
|
-
},
|
|
1957
|
-
...options.cssText === void 0 ? {} : { cssText: options.cssText },
|
|
1958
|
-
...options.widgetCssText === void 0 ? {} : { widgetCssText: options.widgetCssText },
|
|
1959
|
-
...options.cssUrls === void 0 ? {} : { cssUrls: options.cssUrls },
|
|
1960
|
-
...options.fluidComponentCssText === void 0 ? {} : { fluidComponentCssText: options.fluidComponentCssText },
|
|
1961
|
-
...options.fluidComponentCssUrls === void 0 ? {} : { fluidComponentCssUrls: options.fluidComponentCssUrls },
|
|
1962
|
-
...options.themeBridgeCssText === void 0 ? {} : { themeBridgeCssText: options.themeBridgeCssText },
|
|
1963
|
-
...options.themeBridge === void 0 ? {} : { themeBridge: options.themeBridge },
|
|
1964
|
-
...options.fetchCss === void 0 ? {} : { fetchCss: options.fetchCss },
|
|
1965
|
-
...options.useConstructableStylesheets === void 0 ? {} : { useConstructableStylesheets: options.useConstructableStylesheets }
|
|
1966
|
-
});
|
|
1967
|
-
let worker;
|
|
1968
|
-
try {
|
|
1969
|
-
worker = (options.workerFactory ?? createDefaultWorker)(options.artifact.workerEntryUrl, { type: "module" });
|
|
1970
|
-
} catch (error) {
|
|
1971
|
-
reportCleanupErrors(options, "Remote DOM widget setup cleanup failed", collectCleanupErrors([() => styles.dispose(), () => clearRenderedRemoteDomNodes(shadowRoot)]));
|
|
1972
|
-
throw error;
|
|
1973
|
-
}
|
|
1974
|
-
let thread;
|
|
1975
|
-
try {
|
|
1976
|
-
thread = new Thread(createWorkerMessageTarget(worker));
|
|
1977
|
-
} catch (error) {
|
|
1978
|
-
reportCleanupErrors(options, "Remote DOM widget setup cleanup failed", collectCleanupErrors([
|
|
1979
|
-
() => styles.dispose(),
|
|
1980
|
-
() => worker.terminate(),
|
|
1981
|
-
() => clearRenderedRemoteDomNodes(shadowRoot)
|
|
1982
|
-
]));
|
|
1983
|
-
throw error;
|
|
1984
|
-
}
|
|
1985
|
-
let state;
|
|
1986
|
-
const receiver = new RemoteReceiver({
|
|
1987
|
-
retain,
|
|
1988
|
-
release
|
|
1989
|
-
});
|
|
1990
|
-
const renderContainer = document.createElement("div");
|
|
1991
|
-
renderContainer.setAttribute("data-fluid-remote-dom-render-root", "");
|
|
1992
|
-
const portalContainer = document.createElement("div");
|
|
1993
|
-
portalContainer.setAttribute("data-fluid-remote-dom-portal-container", "");
|
|
1994
|
-
shadowRoot.append(renderContainer, portalContainer);
|
|
1995
|
-
const submitListener = createSubmitPreventionListener();
|
|
1996
|
-
const navigationListener = (event) => {
|
|
1997
|
-
handleNavigationIntent(state, event);
|
|
1998
|
-
};
|
|
1999
|
-
const reactRoot = createRoot(renderContainer, { onUncaughtError(error) {
|
|
2000
|
-
reportError(options, "Remote DOM host rendering failed", error);
|
|
2001
|
-
queueMicrotask(() => {
|
|
2002
|
-
if (!state.disposed) disposeAfterFailure(state, false);
|
|
2003
|
-
});
|
|
2004
|
-
} });
|
|
2005
|
-
state = {
|
|
2006
|
-
options,
|
|
2007
|
-
shadowRoot,
|
|
2008
|
-
worker,
|
|
2009
|
-
thread,
|
|
2010
|
-
styles,
|
|
2011
|
-
urlOriginPolicy,
|
|
2012
|
-
navigationOrigin,
|
|
2013
|
-
receiver,
|
|
2014
|
-
reactRoot,
|
|
2015
|
-
renderContainer,
|
|
2016
|
-
portalContainer,
|
|
2017
|
-
submitListener,
|
|
2018
|
-
navigationListener,
|
|
2019
|
-
disposed: false,
|
|
2020
|
-
cleanupStarted: false
|
|
2021
|
-
};
|
|
2022
|
-
const componentRenderers = createRemoteComponentRenderers(options, () => state.disposed);
|
|
2023
|
-
const remoteRoot = createElement(RemoteRootEventBoundary, {
|
|
2024
|
-
receiver,
|
|
2025
|
-
container: renderContainer,
|
|
2026
|
-
options,
|
|
2027
|
-
isDisposed: () => state?.disposed ?? false
|
|
2028
|
-
}, createElement(RemoteRootRenderer, {
|
|
2029
|
-
receiver,
|
|
2030
|
-
components: componentRenderers
|
|
2031
|
-
}));
|
|
2032
|
-
flushSync(() => {
|
|
2033
|
-
reactRoot.render(options.wrapRemoteRoot ? options.wrapRemoteRoot(remoteRoot, portalContainer) : remoteRoot);
|
|
2034
|
-
});
|
|
2035
|
-
const connection = createSanitizingRemoteConnection({
|
|
2036
|
-
connection: receiver.connection,
|
|
2037
|
-
...options.allowedAnchorUrls ? { allowedAnchorUrls: options.allowedAnchorUrls } : {},
|
|
2038
|
-
urlOriginPolicy,
|
|
2039
|
-
maxMutationBatchSize: options.maxMutationBatchSize ?? DEFAULT_MAX_MUTATION_BATCH_SIZE,
|
|
2040
|
-
maxDomNodeCount: options.maxDomNodeCount ?? DEFAULT_MAX_DOM_NODE_COUNT,
|
|
2041
|
-
onNodeLimitExceeded: () => {
|
|
2042
|
-
reportError(options, "Remote DOM widget exceeded its DOM node limit");
|
|
2043
|
-
},
|
|
2044
|
-
onInvalidRecord: (message) => reportError(options, message),
|
|
2045
|
-
onMutateError: (error) => reportError(options, "Remote DOM mutation could not be applied", error)
|
|
2046
|
-
});
|
|
2047
|
-
shadowRoot.addEventListener("submit", submitListener, { capture: true });
|
|
2048
|
-
shadowRoot.addEventListener("click", navigationListener, { capture: true });
|
|
2049
|
-
worker.onerror = (event) => {
|
|
2050
|
-
event.preventDefault?.();
|
|
2051
|
-
if (state.disposed) return;
|
|
2052
|
-
reportError(options, event.message || "Remote DOM widget worker failed", event.error);
|
|
2053
|
-
disposeAfterFailure(state, false);
|
|
2054
|
-
};
|
|
2055
|
-
const hostApi = {
|
|
2056
|
-
mutate(records) {
|
|
2057
|
-
if (state.disposed) return;
|
|
2058
|
-
flushSync(() => connection.mutate(records));
|
|
2059
|
-
enforceAllowedAnchorSafety(state);
|
|
2060
|
-
},
|
|
2061
|
-
callCapability(capability, method, payload) {
|
|
2062
|
-
return callCapability(state, capability, method, payload);
|
|
2063
|
-
},
|
|
2064
|
-
reportError(error) {
|
|
2065
|
-
reportError(options, error.message);
|
|
2066
|
-
}
|
|
2067
|
-
};
|
|
2068
|
-
const ready = Promise.all([styles.ready, thread.imports.mount({
|
|
2069
|
-
widgetType: options.artifact.widgetType,
|
|
2070
|
-
props: initialProps,
|
|
2071
|
-
supportedUiContractVersions: getSupportedUiContractVersions(componentRenderers),
|
|
2072
|
-
...options.artifact.networkAccessGranted === true ? {
|
|
2073
|
-
networkAccessGranted: true,
|
|
2074
|
-
hostOrigin: options.hostOrigin
|
|
2075
|
-
} : {}
|
|
2076
|
-
}, hostApi)]).then(() => void 0);
|
|
2077
|
-
ready.catch((error) => {
|
|
2078
|
-
if (state.disposed) return;
|
|
2079
|
-
reportError(options, "Remote DOM widget failed to mount", error);
|
|
2080
|
-
disposeAfterFailure(state);
|
|
2081
|
-
});
|
|
2082
|
-
return {
|
|
2083
|
-
shadowRoot,
|
|
2084
|
-
styles,
|
|
2085
|
-
ready,
|
|
2086
|
-
updateProps(props) {
|
|
2087
|
-
if (state.disposed) return;
|
|
2088
|
-
assertSerializable(props, "Widget props");
|
|
2089
|
-
state.thread.imports.updateProps(props).catch((error) => {
|
|
2090
|
-
if (!state.disposed) reportError(options, "Remote DOM widget props update failed", error);
|
|
2091
|
-
});
|
|
2092
|
-
},
|
|
2093
|
-
dispose() {
|
|
2094
|
-
disposeMount(state);
|
|
2095
|
-
}
|
|
2096
|
-
};
|
|
2097
|
-
}
|
|
2098
|
-
function callCapability(state, capability, method, payload) {
|
|
2099
|
-
if (state.disposed) return Promise.reject(/* @__PURE__ */ new Error("Remote DOM widget has been disposed"));
|
|
2100
|
-
if (!state.options.artifact.capabilities.some((declaration) => declaration.name === capability)) return Promise.reject(/* @__PURE__ */ new Error(`Remote DOM capability "${capability}" was not declared`));
|
|
2101
|
-
if (payload !== void 0 && !isRemoteDomSerializableValue(payload)) return Promise.reject(/* @__PURE__ */ new Error("Remote DOM capability payload was not serializable"));
|
|
2102
|
-
if (capability === "fullscreen" && state.options.onFullscreen) return Promise.resolve().then(() => state.options.onFullscreen?.({
|
|
2103
|
-
method,
|
|
2104
|
-
...payload === void 0 ? {} : { payload },
|
|
2105
|
-
host: state.options.host,
|
|
2106
|
-
shadowRoot: state.shadowRoot
|
|
2107
|
-
})).then((result) => {
|
|
2108
|
-
if (result === void 0) throw new Error("Remote DOM fullscreen handler returned no result");
|
|
2109
|
-
return assertSerializableCapabilityResult(result);
|
|
2110
|
-
});
|
|
2111
|
-
if (!state.options.callCapability) return Promise.reject(/* @__PURE__ */ new Error(`No host handler is configured for capability "${capability}"`));
|
|
2112
|
-
return Promise.resolve().then(() => state.options.callCapability?.(capability, method, payload)).then((result) => {
|
|
2113
|
-
if (result === void 0) throw new Error(`Capability handler for "${capability}" returned no result`);
|
|
2114
|
-
return assertSerializableCapabilityResult(result);
|
|
2115
|
-
});
|
|
2116
|
-
}
|
|
2117
|
-
function assertSerializableCapabilityResult(result) {
|
|
2118
|
-
if (!isRemoteDomSerializableValue(result)) throw new Error("Remote DOM capability result was not serializable");
|
|
2119
|
-
return result;
|
|
2120
|
-
}
|
|
2121
|
-
function handleNavigationIntent(state, event) {
|
|
2122
|
-
if (!(event instanceof MouseEvent)) return;
|
|
2123
|
-
const anchor = (event.target instanceof Element ? event.target : event.target instanceof Text ? event.target.parentElement : null)?.closest("a[href]");
|
|
2124
|
-
if (!(anchor instanceof HTMLAnchorElement)) return;
|
|
2125
|
-
if (!state.shadowRoot.contains(anchor)) return;
|
|
2126
|
-
if (resolveAllowedAnchorUrl(anchor.getAttribute("href"), state.options.allowedAnchorUrls)) {
|
|
2127
|
-
enforceAllowedAnchorSafetyAttributes(anchor);
|
|
2128
|
-
return;
|
|
2129
|
-
}
|
|
2130
|
-
if (event.cancelable) event.preventDefault();
|
|
2131
|
-
const href = sanitizeRemoteDomUrl(anchor.getAttribute("href"), {
|
|
2132
|
-
allowHashOnly: true,
|
|
2133
|
-
allowMailTo: false,
|
|
2134
|
-
allowRelative: true,
|
|
2135
|
-
allowTel: false,
|
|
2136
|
-
allowedHttpOriginGroups: ["navigation"],
|
|
2137
|
-
originPolicy: state.urlOriginPolicy,
|
|
2138
|
-
relativeUrlBase: "navigation"
|
|
2139
|
-
});
|
|
2140
|
-
const url = href ? resolveInternalNavigationUrl(href, state.navigationOrigin) : void 0;
|
|
2141
|
-
if (!href || !url || !state.options.onNavigate) {
|
|
2142
|
-
reportError(state.options, "Remote DOM navigation was blocked because no allowed internal route handler was available");
|
|
2143
|
-
return;
|
|
2144
|
-
}
|
|
2145
|
-
const targetId = findNodeId(state, anchor);
|
|
2146
|
-
Promise.resolve(state.options.onNavigate({
|
|
2147
|
-
href,
|
|
2148
|
-
url,
|
|
2149
|
-
source: "anchor",
|
|
2150
|
-
...targetId === void 0 ? {} : { targetId },
|
|
2151
|
-
altKey: event.altKey,
|
|
2152
|
-
button: event.button,
|
|
2153
|
-
ctrlKey: event.ctrlKey,
|
|
2154
|
-
metaKey: event.metaKey,
|
|
2155
|
-
shiftKey: event.shiftKey
|
|
2156
|
-
})).catch((error) => {
|
|
2157
|
-
if (!state.disposed) reportError(state.options, "Remote DOM navigation handler failed", error);
|
|
2158
|
-
});
|
|
2159
|
-
}
|
|
2160
|
-
function disposeMount(state, notifyWorker = true) {
|
|
2161
|
-
if (state.cleanupStarted) return;
|
|
2162
|
-
state.cleanupStarted = true;
|
|
2163
|
-
state.disposed = true;
|
|
2164
|
-
const cleanupSteps = [
|
|
2165
|
-
() => {
|
|
2166
|
-
state.worker.onerror = null;
|
|
2167
|
-
},
|
|
2168
|
-
() => {
|
|
2169
|
-
state.shadowRoot.removeEventListener("submit", state.submitListener, { capture: true });
|
|
2170
|
-
},
|
|
2171
|
-
() => {
|
|
2172
|
-
state.shadowRoot.removeEventListener("click", state.navigationListener, { capture: true });
|
|
2173
|
-
}
|
|
2174
|
-
];
|
|
2175
|
-
cleanupSteps.push(() => flushSync(() => state.reactRoot.unmount()), () => clearRemoteReceiver(state.receiver), () => state.styles.dispose(), () => clearRenderedRemoteDomNodes(state.shadowRoot));
|
|
2176
|
-
const cleanupErrors = collectCleanupErrors(cleanupSteps);
|
|
2177
|
-
if (notifyWorker) Promise.resolve(state.thread.imports.dispose()).catch(() => void 0);
|
|
2178
|
-
queueMicrotask(() => {
|
|
2179
|
-
reportCleanupErrors(state.options, "Remote DOM widget asynchronous cleanup failed", collectCleanupErrors([() => state.thread.close(), () => state.worker.terminate()]));
|
|
2180
|
-
});
|
|
2181
|
-
if (cleanupErrors.length > 0) throw new AggregateError(cleanupErrors, "Remote DOM widget cleanup failed");
|
|
2182
|
-
}
|
|
2183
|
-
function disposeAfterFailure(state, notifyWorker = true) {
|
|
2184
|
-
try {
|
|
2185
|
-
disposeMount(state, notifyWorker);
|
|
2186
|
-
} catch (cleanupError) {
|
|
2187
|
-
reportError(state.options, "Remote DOM widget cleanup failed after an earlier error", cleanupError);
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
function createShadowRoot(host) {
|
|
2191
|
-
if (host.shadowRoot) {
|
|
2192
|
-
host.shadowRoot.replaceChildren();
|
|
2193
|
-
return host.shadowRoot;
|
|
2194
|
-
}
|
|
2195
|
-
return host.attachShadow({ mode: "open" });
|
|
2196
|
-
}
|
|
2197
|
-
function createSubmitPreventionListener() {
|
|
2198
|
-
return (event) => {
|
|
2199
|
-
if (event.cancelable) event.preventDefault();
|
|
2200
|
-
};
|
|
2201
|
-
}
|
|
2202
|
-
function collectArtifactUrls(artifact) {
|
|
2203
|
-
return [
|
|
2204
|
-
artifact.workerEntryUrl,
|
|
2205
|
-
...artifact.cssUrls,
|
|
2206
|
-
...artifact.assetUrls
|
|
2207
|
-
];
|
|
2208
|
-
}
|
|
2209
|
-
function normalizeNavigationOrigin(value) {
|
|
2210
|
-
if (!value) return void 0;
|
|
2211
|
-
try {
|
|
2212
|
-
const url = new URL(value);
|
|
2213
|
-
return url.protocol === "http:" || url.protocol === "https:" ? url.origin : void 0;
|
|
2214
|
-
} catch {
|
|
2215
|
-
return;
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
function resolveAllowedAnchorUrl(href, allowedAnchorUrls) {
|
|
2219
|
-
if (!href || !allowedAnchorUrls) return void 0;
|
|
2220
|
-
let parsed;
|
|
2221
|
-
try {
|
|
2222
|
-
parsed = new URL(href);
|
|
2223
|
-
} catch {
|
|
2224
|
-
return;
|
|
2225
|
-
}
|
|
2226
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return;
|
|
2227
|
-
return allowedAnchorUrls.has(parsed.href) ? parsed.href : void 0;
|
|
2228
|
-
}
|
|
2229
|
-
function enforceAllowedAnchorSafety(state) {
|
|
2230
|
-
for (const anchor of state.shadowRoot.querySelectorAll("a[href]")) {
|
|
2231
|
-
if (!resolveAllowedAnchorUrl(anchor.getAttribute("href"), state.options.allowedAnchorUrls)) continue;
|
|
2232
|
-
enforceAllowedAnchorSafetyAttributes(anchor);
|
|
2233
|
-
}
|
|
2234
|
-
}
|
|
2235
|
-
function enforceAllowedAnchorSafetyAttributes(anchor) {
|
|
2236
|
-
anchor.target = "_blank";
|
|
2237
|
-
const relTokens = new Set(anchor.rel.split(/\s+/u).filter(Boolean));
|
|
2238
|
-
relTokens.add("noopener");
|
|
2239
|
-
relTokens.add("noreferrer");
|
|
2240
|
-
anchor.rel = Array.from(relTokens).join(" ");
|
|
2241
|
-
anchor.removeAttribute("download");
|
|
2242
|
-
}
|
|
2243
|
-
function resolveInternalNavigationUrl(href, navigationOrigin) {
|
|
2244
|
-
if (href.startsWith("#")) return href;
|
|
2245
|
-
if (href.startsWith("//") || /^https?:(?!\/\/)/iu.test(href)) return;
|
|
2246
|
-
try {
|
|
2247
|
-
const url = new URL(href, navigationOrigin ?? "https://fluid.local");
|
|
2248
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") return;
|
|
2249
|
-
if (/^[a-z][a-z\d+.-]*:/iu.test(href) && (!navigationOrigin || url.origin !== navigationOrigin)) return;
|
|
2250
|
-
return `${url.pathname}${url.search}${url.hash}`;
|
|
2251
|
-
} catch {
|
|
2252
|
-
return;
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
|
-
function findNodeId(_state, node) {
|
|
2256
|
-
return (node instanceof Element ? node : node.parentElement)?.closest("[data-fluid-remote-dom-node-id]")?.getAttribute("data-fluid-remote-dom-node-id") ?? void 0;
|
|
2257
|
-
}
|
|
2258
|
-
function isWidgetStyleNode(node) {
|
|
2259
|
-
return node instanceof HTMLStyleElement && node.hasAttribute("data-fluid-widget-style");
|
|
2260
|
-
}
|
|
2261
|
-
function clearRenderedRemoteDomNodes(shadowRoot) {
|
|
2262
|
-
for (const child of Array.from(shadowRoot.childNodes)) if (!isWidgetStyleNode(child)) child.remove();
|
|
2263
|
-
}
|
|
2264
|
-
function clearRemoteReceiver(receiver) {
|
|
2265
|
-
while (receiver.root.children.length > 0) receiver.connection.mutate([[
|
|
2266
|
-
MUTATION_TYPE_REMOVE_CHILD,
|
|
2267
|
-
ROOT_ID,
|
|
2268
|
-
0
|
|
2269
|
-
]]);
|
|
2270
|
-
}
|
|
2271
|
-
function toSerializableEventPayload(payload) {
|
|
2272
|
-
const result = {
|
|
2273
|
-
bubbles: payload.bubbles,
|
|
2274
|
-
cancelable: payload.cancelable,
|
|
2275
|
-
currentTargetId: payload.currentTargetId,
|
|
2276
|
-
defaultPrevented: payload.defaultPrevented,
|
|
2277
|
-
targetId: payload.targetId,
|
|
2278
|
-
type: payload.type
|
|
2279
|
-
};
|
|
2280
|
-
for (const key of [
|
|
2281
|
-
"altKey",
|
|
2282
|
-
"button",
|
|
2283
|
-
"buttons",
|
|
2284
|
-
"checked",
|
|
2285
|
-
"clientX",
|
|
2286
|
-
"clientY",
|
|
2287
|
-
"code",
|
|
2288
|
-
"ctrlKey",
|
|
2289
|
-
"detailJson",
|
|
2290
|
-
"isPrimary",
|
|
2291
|
-
"key",
|
|
2292
|
-
"metaKey",
|
|
2293
|
-
"pointerId",
|
|
2294
|
-
"pointerType",
|
|
2295
|
-
"shiftKey",
|
|
2296
|
-
"value"
|
|
2297
|
-
]) {
|
|
2298
|
-
const value = payload[key];
|
|
2299
|
-
if (value !== void 0) result[key] = value;
|
|
2300
|
-
}
|
|
2301
|
-
return result;
|
|
2302
|
-
}
|
|
2303
|
-
function assertSerializable(value, description) {
|
|
2304
|
-
if (!isRemoteDomSerializableValue(value)) throw new TypeError(`${description} must be serializable`);
|
|
2305
|
-
}
|
|
2306
|
-
function createWorkerMessageTarget(worker) {
|
|
2307
|
-
return {
|
|
2308
|
-
send(message, transferables) {
|
|
2309
|
-
worker.postMessage(message, transferables ?? []);
|
|
2310
|
-
},
|
|
2311
|
-
listen(listener, { signal }) {
|
|
2312
|
-
const onMessage = (event) => {
|
|
2313
|
-
listener(event.data);
|
|
2314
|
-
};
|
|
2315
|
-
if (worker.addEventListener) worker.addEventListener("message", onMessage, { signal });
|
|
2316
|
-
else {
|
|
2317
|
-
worker.onmessage = onMessage;
|
|
2318
|
-
signal?.addEventListener("abort", () => {
|
|
2319
|
-
worker.onmessage = null;
|
|
2320
|
-
}, { once: true });
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
};
|
|
2324
|
-
}
|
|
2325
|
-
function createDefaultWorker(workerEntryUrl, options) {
|
|
2326
|
-
if (typeof Worker === "undefined") throw new Error("Remote DOM Worker is not available in this environment");
|
|
2327
|
-
if (!shouldWrapWorkerEntryUrl(workerEntryUrl)) return new Worker(workerEntryUrl, options);
|
|
2328
|
-
return createBlobWrappedWorker(workerEntryUrl, options);
|
|
2329
|
-
}
|
|
2330
|
-
function shouldWrapWorkerEntryUrl(workerEntryUrl) {
|
|
2331
|
-
if (typeof location === "undefined" || typeof Blob === "undefined" || typeof URL.createObjectURL !== "function") return false;
|
|
2332
|
-
try {
|
|
2333
|
-
return new URL(workerEntryUrl, location.href).origin !== location.origin;
|
|
2334
|
-
} catch {
|
|
2335
|
-
return false;
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
function createBlobWrappedWorker(workerEntryUrl, options) {
|
|
2339
|
-
const blobUrl = URL.createObjectURL(new Blob([`import ${JSON.stringify(workerEntryUrl)};\n`], { type: "application/javascript" }));
|
|
2340
|
-
let worker;
|
|
2341
|
-
try {
|
|
2342
|
-
worker = new Worker(blobUrl, options);
|
|
2343
|
-
} catch (error) {
|
|
2344
|
-
URL.revokeObjectURL(blobUrl);
|
|
2345
|
-
throw error;
|
|
2346
|
-
}
|
|
2347
|
-
const terminate = worker.terminate.bind(worker);
|
|
2348
|
-
worker.terminate = () => {
|
|
2349
|
-
try {
|
|
2350
|
-
terminate();
|
|
2351
|
-
} finally {
|
|
2352
|
-
URL.revokeObjectURL(blobUrl);
|
|
2353
|
-
}
|
|
2354
|
-
};
|
|
2355
|
-
return worker;
|
|
2356
|
-
}
|
|
2357
|
-
function reportError(options, message, cause) {
|
|
2358
|
-
try {
|
|
2359
|
-
options.onError?.(new Error(message, cause === void 0 ? {} : { cause }));
|
|
2360
|
-
} catch {}
|
|
2361
|
-
}
|
|
2362
|
-
function collectCleanupErrors(cleanupSteps) {
|
|
2363
|
-
const errors = [];
|
|
2364
|
-
for (const cleanup of cleanupSteps) try {
|
|
2365
|
-
cleanup();
|
|
2366
|
-
} catch (error) {
|
|
2367
|
-
errors.push(error);
|
|
2368
|
-
}
|
|
2369
|
-
return errors;
|
|
2370
|
-
}
|
|
2371
|
-
function reportCleanupErrors(options, message, errors) {
|
|
2372
|
-
if (errors.length === 0) return;
|
|
2373
|
-
reportError(options, message, errors.length === 1 ? errors[0] : new AggregateError(errors, "Multiple cleanup operations failed"));
|
|
2374
|
-
}
|
|
2375
|
-
function isPromiseLike(value) {
|
|
2376
|
-
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
2377
|
-
}
|
|
2378
|
-
//#endregion
|
|
2379
|
-
export { mountRemoteDomWidget as t };
|
|
1938
|
+
export { collectCleanupErrors as a, enforceAllowedAnchorSafety as c, normalizeNavigationOrigin as d, reportCleanupErrors as f, callRemoteDomCapability as i, handleRemoteDomNavigationIntent as l, createSanitizingRemoteConnection as m, attachRemoteDomStyles as n, createSubmitPreventionListener as o, reportHostError as p, REMOTE_DOM_NODE_ID_ATTRIBUTE as r, deliverRemoteDomEvent as s, REMOTE_DOM_WIDGET_STYLE_ATTRIBUTE as t, hasCloserRemoteEventListener as u };
|
|
2380
1939
|
|
|
2381
|
-
//# sourceMappingURL=remote-dom-
|
|
1940
|
+
//# sourceMappingURL=remote-dom-styles-CmHfrrKz.mjs.map
|