@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,1358 @@
|
|
|
1
|
+
// ../../../node_modules/.pnpm/@quilted+threads@4.1.0_@preact+signals-core@1.14.3/node_modules/@quilted/threads/build/esm/constants.mjs
|
|
2
|
+
const SERIALIZE_METHOD = Symbol.for("quilt.threads.serialize");
|
|
3
|
+
const TRANSFERABLE = Symbol.for("quilt.threads.transferable");
|
|
4
|
+
// ../../../node_modules/.pnpm/@quilted+threads@4.1.0_@preact+signals-core@1.14.3/node_modules/@quilted/threads/build/esm/memory.mjs
|
|
5
|
+
const RETAIN_METHOD = Symbol.for("quilt.threads.retain");
|
|
6
|
+
const RELEASE_METHOD = Symbol.for("quilt.threads.release");
|
|
7
|
+
/**
|
|
8
|
+
* Indicates that a value is being manually memory-managed across threads by this library.
|
|
9
|
+
*/
|
|
10
|
+
function isMemoryManageable(value) {
|
|
11
|
+
return Boolean(value && value[RETAIN_METHOD] && value[RELEASE_METHOD]);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Marks a value as being used so it will not be automatically released. Calling `retain` will,
|
|
15
|
+
* by default, deeply retain the value — that is, it will traverse into nested array elements
|
|
16
|
+
* and object properties, and retain every `retain`-able thing it finds.
|
|
17
|
+
*
|
|
18
|
+
* You will typically use this alongside also storing that value in a variable that lives outside
|
|
19
|
+
* the context of the function where that value was received.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import {retain} from '@quilted/threads';
|
|
23
|
+
*
|
|
24
|
+
* const allUsers = new Set<User>();
|
|
25
|
+
*
|
|
26
|
+
* async function sayHello(user: User) {
|
|
27
|
+
* allUsers.add(user);
|
|
28
|
+
* retain(user);
|
|
29
|
+
* return `Hey, ${await user.fullName()}!`;
|
|
30
|
+
* }
|
|
31
|
+
*/
|
|
32
|
+
function retain(value, { deep = true } = {}) {
|
|
33
|
+
return retainInternal(value, deep, /* @__PURE__ */ new Map());
|
|
34
|
+
}
|
|
35
|
+
function retainInternal(value, deep, seen) {
|
|
36
|
+
const seenValue = seen.get(value);
|
|
37
|
+
if (seenValue) return seenValue;
|
|
38
|
+
const canRetain = isMemoryManageable(value);
|
|
39
|
+
if (canRetain) value[RETAIN_METHOD]();
|
|
40
|
+
seen.set(value, canRetain);
|
|
41
|
+
if (deep) {
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
const nestedCanRetain = value.reduce((canRetain, item) => retainInternal(item, deep, seen) || canRetain, canRetain);
|
|
44
|
+
seen.set(value, nestedCanRetain);
|
|
45
|
+
return nestedCanRetain;
|
|
46
|
+
}
|
|
47
|
+
if (isBasicObject$1(value)) {
|
|
48
|
+
const nestedCanRetain = Object.keys(value).reduce((canRetain, key) => retainInternal(value[key], deep, seen) || canRetain, canRetain);
|
|
49
|
+
seen.set(value, nestedCanRetain);
|
|
50
|
+
return nestedCanRetain;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return canRetain;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Once you are no longer using the a `retain`-ed value, you can use this function to mark it as
|
|
57
|
+
* being unused. Like `retain()`, this function will apply to all nested array elements and object
|
|
58
|
+
* properties.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* import {retain} from '@quilted/threads';
|
|
62
|
+
*
|
|
63
|
+
* const allUsers = new Set<User>();
|
|
64
|
+
*
|
|
65
|
+
* function removeUser(user: User) {
|
|
66
|
+
* allUsers.delete(user);
|
|
67
|
+
* release(user);
|
|
68
|
+
* }
|
|
69
|
+
*/
|
|
70
|
+
function release(value, { deep = true } = {}) {
|
|
71
|
+
return releaseInternal(value, deep, /* @__PURE__ */ new Map());
|
|
72
|
+
}
|
|
73
|
+
function releaseInternal(value, deep, seen) {
|
|
74
|
+
const seenValue = seen.get(value);
|
|
75
|
+
if (seenValue) return seenValue;
|
|
76
|
+
const canRelease = isMemoryManageable(value);
|
|
77
|
+
if (canRelease) value[RELEASE_METHOD]();
|
|
78
|
+
seen.set(value, canRelease);
|
|
79
|
+
if (deep) {
|
|
80
|
+
if (Array.isArray(value)) {
|
|
81
|
+
const nestedCanRelease = value.reduce((canRelease, item) => releaseInternal(item, deep, seen) || canRelease, canRelease);
|
|
82
|
+
seen.set(value, nestedCanRelease);
|
|
83
|
+
return nestedCanRelease;
|
|
84
|
+
}
|
|
85
|
+
if (isBasicObject$1(value)) {
|
|
86
|
+
const nestedCanRelease = Object.keys(value).reduce((canRelease, key) => releaseInternal(value[key], deep, seen) || canRelease, canRelease);
|
|
87
|
+
seen.set(value, nestedCanRelease);
|
|
88
|
+
return nestedCanRelease;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return canRelease;
|
|
92
|
+
}
|
|
93
|
+
function isBasicObject$1(value) {
|
|
94
|
+
if (value == null || typeof value !== "object") return false;
|
|
95
|
+
const prototype = Object.getPrototypeOf(value);
|
|
96
|
+
return prototype == null || prototype === Object.prototype;
|
|
97
|
+
}
|
|
98
|
+
// ../../../node_modules/.pnpm/@quilted+events@2.1.5/node_modules/@quilted/events/build/esm/abort/NestedAbortController.mjs
|
|
99
|
+
/**
|
|
100
|
+
* An `AbortController` that will automatically abort when any of
|
|
101
|
+
* its "parent" `AbortController`s abort. This is useful for when
|
|
102
|
+
* you have nested asynchronous operations that may abort independently.
|
|
103
|
+
* The `AbortController` can also be independently aborted.
|
|
104
|
+
*
|
|
105
|
+
* To associate the parent `AbortController`s, pass their signals
|
|
106
|
+
* as arguments to the constructor.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* import {NestedAbortController} from '@shopify/events';
|
|
110
|
+
*
|
|
111
|
+
* const parent = new AbortController();
|
|
112
|
+
* const nested = new NestedAbortController(parent.signal);
|
|
113
|
+
*
|
|
114
|
+
* parent.abort();
|
|
115
|
+
* nested.signal.aborted; // true
|
|
116
|
+
*/
|
|
117
|
+
var NestedAbortController = class extends AbortController {
|
|
118
|
+
constructor(...parents) {
|
|
119
|
+
super();
|
|
120
|
+
const abortedSignal = parents.find((signal) => signal.aborted);
|
|
121
|
+
if (abortedSignal) this.abort(abortedSignal.reason);
|
|
122
|
+
else {
|
|
123
|
+
const abort = (event) => this.abort(event.target.reason);
|
|
124
|
+
const options = { signal: this.signal };
|
|
125
|
+
for (const signal of parents) signal.addEventListener("abort", abort, options);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
// ../../../node_modules/.pnpm/@quilted+threads@4.1.0_@preact+signals-core@1.14.3/node_modules/@quilted/threads/build/esm/errors.mjs
|
|
130
|
+
var ThreadClosedError = class extends Error {
|
|
131
|
+
constructor() {
|
|
132
|
+
super("You attempted to call a function on a closed thread.");
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
// ../../../node_modules/.pnpm/@quilted+threads@4.1.0_@preact+signals-core@1.14.3/node_modules/@quilted/threads/build/esm/nanoid.mjs
|
|
136
|
+
let a = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
137
|
+
function nanoid(e = 21) {
|
|
138
|
+
let t = "", r = crypto.getRandomValues(new Uint8Array(e));
|
|
139
|
+
for (let n = 0; n < e; n++) t += a[63 & r[n]];
|
|
140
|
+
return t;
|
|
141
|
+
}
|
|
142
|
+
// ../../../node_modules/.pnpm/@quilted+threads@4.1.0_@preact+signals-core@1.14.3/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs
|
|
143
|
+
/**
|
|
144
|
+
* A strategy for managing functions across threads that automatically releases
|
|
145
|
+
* functions when they are no longer needed. This is done by deserializing functions
|
|
146
|
+
* into a proxy that can be called, and wrapping that proxy in a `FinalizationRegistry`,
|
|
147
|
+
* which allows us to send a message to the parent thread when the function is no
|
|
148
|
+
* longer used.
|
|
149
|
+
*
|
|
150
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry
|
|
151
|
+
*/
|
|
152
|
+
var ThreadFunctionsAutomatic = class {
|
|
153
|
+
#functionsToId = (() => /* @__PURE__ */ new Map())();
|
|
154
|
+
#idsToFunction = (() => /* @__PURE__ */ new Map())();
|
|
155
|
+
#idsToProxy = (() => /* @__PURE__ */ new Map())();
|
|
156
|
+
#finalization = (() => /* @__PURE__ */ new WeakMap())();
|
|
157
|
+
get(id) {
|
|
158
|
+
return this.#idsToFunction.get(id);
|
|
159
|
+
}
|
|
160
|
+
release(id) {
|
|
161
|
+
const func = this.#idsToFunction.get(id);
|
|
162
|
+
if (func) {
|
|
163
|
+
this.#idsToFunction.delete(id);
|
|
164
|
+
this.#functionsToId.delete(func);
|
|
165
|
+
}
|
|
166
|
+
return Boolean(func);
|
|
167
|
+
}
|
|
168
|
+
serialize(func) {
|
|
169
|
+
let id = this.#functionsToId.get(func);
|
|
170
|
+
if (id == null) {
|
|
171
|
+
id = nanoid();
|
|
172
|
+
this.#functionsToId.set(func, id);
|
|
173
|
+
this.#idsToFunction.set(id, func);
|
|
174
|
+
}
|
|
175
|
+
return id;
|
|
176
|
+
}
|
|
177
|
+
deserialize(id, thread) {
|
|
178
|
+
let proxy = this.#idsToProxy.get(id)?.deref();
|
|
179
|
+
if (proxy) return proxy;
|
|
180
|
+
proxy = (...args) => {
|
|
181
|
+
if (!this.#idsToProxy.has(id)) throw new Error("You attempted to call a function that was already revoked.");
|
|
182
|
+
return thread.call((callID, args, transferable) => {
|
|
183
|
+
thread.messages.send([
|
|
184
|
+
3,
|
|
185
|
+
callID,
|
|
186
|
+
id,
|
|
187
|
+
args
|
|
188
|
+
], transferable);
|
|
189
|
+
}, args);
|
|
190
|
+
};
|
|
191
|
+
this.#finalizationRegistry(thread)?.register(proxy, id);
|
|
192
|
+
this.#idsToProxy.set(id, new WeakRef(proxy));
|
|
193
|
+
return proxy;
|
|
194
|
+
}
|
|
195
|
+
#finalizationRegistry(thread) {
|
|
196
|
+
let finalization = this.#finalization.get(thread);
|
|
197
|
+
if (typeof FinalizationRegistry === "undefined") return;
|
|
198
|
+
if (!finalization) {
|
|
199
|
+
finalization = new FinalizationRegistry((id) => {
|
|
200
|
+
thread.messages.send([5, id]);
|
|
201
|
+
});
|
|
202
|
+
this.#finalization.set(thread, finalization);
|
|
203
|
+
}
|
|
204
|
+
return finalization;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
// ../../../node_modules/.pnpm/@quilted+threads@4.1.0_@preact+signals-core@1.14.3/node_modules/@quilted/threads/build/esm/serialization/shared.mjs
|
|
208
|
+
function isIterator(value) {
|
|
209
|
+
return value != null && (Symbol.asyncIterator in value || Symbol.iterator in value) && typeof value.next === "function";
|
|
210
|
+
}
|
|
211
|
+
function isBasicObject(value) {
|
|
212
|
+
if (value == null || typeof value !== "object") return false;
|
|
213
|
+
const prototype = Object.getPrototypeOf(value);
|
|
214
|
+
return prototype == null || prototype === Object.prototype;
|
|
215
|
+
}
|
|
216
|
+
// ../../../node_modules/.pnpm/@quilted+threads@4.1.0_@preact+signals-core@1.14.3/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs
|
|
217
|
+
const FUNCTION = "_@f";
|
|
218
|
+
const ASYNC_ITERATOR = "_@i";
|
|
219
|
+
/**
|
|
220
|
+
* A thread encoder that can transfer supports a wide variety of JavaScript types by
|
|
221
|
+
* converting them to a format that the [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
|
|
222
|
+
* algorithm can process. This
|
|
223
|
+
*
|
|
224
|
+
* Additionally, this encoder will convert functions into a JSON-friendly representation.
|
|
225
|
+
* These functions will use a manual memory management technique to ensure they can be
|
|
226
|
+
* garbage collected by default, but can be configured to use a `WeakRef`-based automatic
|
|
227
|
+
* memory management system by setting the `garbageCollection: 'weak-ref'` option.
|
|
228
|
+
*/
|
|
229
|
+
var ThreadSerializationStructuredClone = class {
|
|
230
|
+
#customSerializer;
|
|
231
|
+
#customDeserializer;
|
|
232
|
+
constructor(options) {
|
|
233
|
+
this.#customSerializer = options?.serialize;
|
|
234
|
+
this.#customDeserializer = options?.deserialize;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Serializes a value into a structured cloning-compatible format that can be transferred between threads.
|
|
238
|
+
*/
|
|
239
|
+
serialize(value, thread, transferable) {
|
|
240
|
+
return this.#serializeInternal(value, thread, transferable);
|
|
241
|
+
}
|
|
242
|
+
#serializeInternal(value, thread, transferable, seen = /* @__PURE__ */ new Map(), isApplyingDefault = false) {
|
|
243
|
+
if (value == null) return value;
|
|
244
|
+
if (seen.has(value)) return seen.get(value);
|
|
245
|
+
seen.set(value, void 0);
|
|
246
|
+
if (typeof value === "object") {
|
|
247
|
+
if (this.#customSerializer && !isApplyingDefault) {
|
|
248
|
+
const customValue = this.#customSerializer(value, (value) => this.#serializeInternal(value, thread, transferable, seen, true), thread, transferable);
|
|
249
|
+
if (customValue !== void 0) {
|
|
250
|
+
seen.set(value, customValue);
|
|
251
|
+
return customValue;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (value[TRANSFERABLE]) {
|
|
255
|
+
transferable?.push(value);
|
|
256
|
+
seen.set(value, value);
|
|
257
|
+
return value;
|
|
258
|
+
}
|
|
259
|
+
const serializeValue = (value) => {
|
|
260
|
+
return this.#serializeInternal(value, thread, transferable, seen);
|
|
261
|
+
};
|
|
262
|
+
if (typeof value[SERIALIZE_METHOD] === "function") {
|
|
263
|
+
const result = value[SERIALIZE_METHOD]({ serialize: serializeValue });
|
|
264
|
+
seen.set(value, result);
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
if (Array.isArray(value)) {
|
|
268
|
+
const result = value.map((item) => serializeValue(item));
|
|
269
|
+
seen.set(value, result);
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
if (value instanceof Map) {
|
|
273
|
+
const entries = [...value.entries()].map(([key, value]) => {
|
|
274
|
+
return [serializeValue(key), serializeValue(value)];
|
|
275
|
+
});
|
|
276
|
+
const result = new Map(entries);
|
|
277
|
+
seen.set(value, result);
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
if (value instanceof Set) {
|
|
281
|
+
const entries = [...value].map((entry) => serializeValue(entry));
|
|
282
|
+
const result = new Set(entries);
|
|
283
|
+
seen.set(value, result);
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
const valueIsIterator = isIterator(value);
|
|
287
|
+
if (isBasicObject(value) || valueIsIterator) {
|
|
288
|
+
const result = {};
|
|
289
|
+
for (const key of Object.keys(value)) result[key] = serializeValue(value[key]);
|
|
290
|
+
if (valueIsIterator) {
|
|
291
|
+
result.next ??= serializeValue(value.next.bind(value));
|
|
292
|
+
result.return ??= serializeValue(value.return.bind(value));
|
|
293
|
+
result.throw ??= serializeValue(value.throw.bind(value));
|
|
294
|
+
result[ASYNC_ITERATOR] = true;
|
|
295
|
+
}
|
|
296
|
+
seen.set(value, result);
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (typeof value === "function") {
|
|
301
|
+
const serialized = thread.functions.serialize(value, thread, transferable);
|
|
302
|
+
const result = { [FUNCTION]: serialized };
|
|
303
|
+
seen.set(value, result);
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
306
|
+
seen.set(value, value);
|
|
307
|
+
return value;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Deserializes a structured cloning-compatible value from another thread.
|
|
311
|
+
*/
|
|
312
|
+
deserialize(value, thread) {
|
|
313
|
+
return this.#deserializeInternal(value, thread);
|
|
314
|
+
}
|
|
315
|
+
#deserializeInternal(value, thread, isApplyingDefault = false) {
|
|
316
|
+
if (value == null) return value;
|
|
317
|
+
if (typeof value === "object") {
|
|
318
|
+
if (this.#customDeserializer && !isApplyingDefault) {
|
|
319
|
+
const customValue = this.#customDeserializer(value, (value) => this.#deserializeInternal(value, thread, true), thread);
|
|
320
|
+
if (customValue !== void 0) return customValue;
|
|
321
|
+
}
|
|
322
|
+
if (value == null) return value;
|
|
323
|
+
if (Array.isArray(value)) return value.map((value) => this.#deserializeInternal(value, thread));
|
|
324
|
+
if (value instanceof Map) return new Map([...value].map(([key, value]) => [this.#deserializeInternal(key, thread), this.#deserializeInternal(value, thread)]));
|
|
325
|
+
if (value instanceof Set) return new Set([...value].map((entry) => this.#deserializeInternal(entry, thread)));
|
|
326
|
+
if (FUNCTION in value) return thread.functions.deserialize(value[FUNCTION], thread);
|
|
327
|
+
if (!isBasicObject(value)) return value;
|
|
328
|
+
const result = {};
|
|
329
|
+
for (const key of Object.keys(value)) if (key === ASYNC_ITERATOR) result[Symbol.asyncIterator] = () => result;
|
|
330
|
+
else result[key] = this.#deserializeInternal(value[key], thread);
|
|
331
|
+
return result;
|
|
332
|
+
}
|
|
333
|
+
return value;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
// ../../../node_modules/.pnpm/@quilted+threads@4.1.0_@preact+signals-core@1.14.3/node_modules/@quilted/threads/build/esm/Thread.mjs
|
|
337
|
+
/**
|
|
338
|
+
* An object that can serialize and deserialize values communicated between two threads.
|
|
339
|
+
*/
|
|
340
|
+
/**
|
|
341
|
+
* An object that can serialize and deserialize values communicated between two threads.
|
|
342
|
+
*/
|
|
343
|
+
/**
|
|
344
|
+
* Options to customize the creation of a `ThreadSerialization` instance.
|
|
345
|
+
*/
|
|
346
|
+
/**
|
|
347
|
+
* Options to customize the creation of a `Thread` instance.
|
|
348
|
+
*/
|
|
349
|
+
/**
|
|
350
|
+
* An object backing a `Thread` that provides the message-passing interface
|
|
351
|
+
* that allows communication to flow between environments. This message-passing
|
|
352
|
+
* interface is based on the [`postMessage` interface](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage),
|
|
353
|
+
* which is easily adaptable to many JavaScript objects and environments.
|
|
354
|
+
*/
|
|
355
|
+
/**
|
|
356
|
+
* A map of messages that can be sent between threads.
|
|
357
|
+
*/
|
|
358
|
+
/**
|
|
359
|
+
* The possible data payloads that can be transferred between threads.
|
|
360
|
+
*/
|
|
361
|
+
/**
|
|
362
|
+
* A helper type that extracts all callable methods that can be safely proxied
|
|
363
|
+
* between threads; that is, ones which return a promise or async iterator.
|
|
364
|
+
*/
|
|
365
|
+
/**
|
|
366
|
+
* A thread represents a target JavaScript environment that exposes a set
|
|
367
|
+
* of callable, asynchronous methods. The thread takes care of automatically
|
|
368
|
+
* encoding and decoding its arguments and return values, so you can interact
|
|
369
|
+
* with it as if its methods were implemented in the same environment as your
|
|
370
|
+
* own code.
|
|
371
|
+
*/
|
|
372
|
+
var Thread = class {
|
|
373
|
+
/**
|
|
374
|
+
* An object that exposes the methods that can be called on the paired thread.
|
|
375
|
+
* This object will automatically encode and decode arguments and return values
|
|
376
|
+
* as necessary.
|
|
377
|
+
*/
|
|
378
|
+
/**
|
|
379
|
+
* An object that exposes the methods that can be called on this thread by the
|
|
380
|
+
* paired thread. To set these methods, pass the `exports` option when creating
|
|
381
|
+
* a new `Thread`.
|
|
382
|
+
*/
|
|
383
|
+
/**
|
|
384
|
+
* An object that provides the message-passing interface that allows communication
|
|
385
|
+
* to flow between environments.
|
|
386
|
+
*/
|
|
387
|
+
/**
|
|
388
|
+
* An object that manages how functions are proxied between threads.
|
|
389
|
+
*/
|
|
390
|
+
/**
|
|
391
|
+
* An object that manages how values are serialized and deserialized between threads.
|
|
392
|
+
*/
|
|
393
|
+
/**
|
|
394
|
+
* An `AbortSignal` that indicates whether the communication channel is still open.
|
|
395
|
+
*/
|
|
396
|
+
get signal() {
|
|
397
|
+
return this.#abort.signal;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* A boolean indicating whether the communication channel is still open.
|
|
401
|
+
*/
|
|
402
|
+
get closed() {
|
|
403
|
+
return this.#abort.signal.aborted;
|
|
404
|
+
}
|
|
405
|
+
#abort;
|
|
406
|
+
#idsToResolver = (() => /* @__PURE__ */ new Map())();
|
|
407
|
+
constructor(messages, { imports, exports, functions = new ThreadFunctionsAutomatic(), serialization = new ThreadSerializationStructuredClone(), signal } = {}) {
|
|
408
|
+
this.messages = messages;
|
|
409
|
+
this.#abort = signal ? new NestedAbortController(signal) : new AbortController();
|
|
410
|
+
this.exports = exports ?? {};
|
|
411
|
+
this.imports = createThreadImports(this.#handlerForCall.bind(this), imports);
|
|
412
|
+
this.functions = functions;
|
|
413
|
+
this.serialization = serialization;
|
|
414
|
+
this.functions.start?.(this);
|
|
415
|
+
this.serialization.start?.(this);
|
|
416
|
+
this.signal.addEventListener("abort", () => {
|
|
417
|
+
for (const id of this.#idsToResolver.keys()) this.#resolveCall(id, void 0, new ThreadClosedError());
|
|
418
|
+
this.#idsToResolver.clear();
|
|
419
|
+
}, { once: true });
|
|
420
|
+
messages.listen(async (rawData) => {
|
|
421
|
+
if (!(Array.isArray(rawData) && typeof rawData[0] === "number")) return;
|
|
422
|
+
const data = rawData;
|
|
423
|
+
switch (data[0]) {
|
|
424
|
+
case 1: {
|
|
425
|
+
const [, id, property, args] = data;
|
|
426
|
+
const func = this.exports[property] ?? (() => {
|
|
427
|
+
throw new Error(`No '${property}' method is exported from this thread`);
|
|
428
|
+
});
|
|
429
|
+
await this.#callLocal(func, args, (value, error, transferable) => {
|
|
430
|
+
this.messages.send([
|
|
431
|
+
2,
|
|
432
|
+
id,
|
|
433
|
+
value,
|
|
434
|
+
error
|
|
435
|
+
], transferable);
|
|
436
|
+
});
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
case 3: {
|
|
440
|
+
const [, callID, funcID, args] = data;
|
|
441
|
+
const func = this.functions.get(funcID, this) ?? missingThreadFunction;
|
|
442
|
+
await this.#callLocal(func, args, (value, error, transferable) => {
|
|
443
|
+
this.messages.send([
|
|
444
|
+
4,
|
|
445
|
+
callID,
|
|
446
|
+
value,
|
|
447
|
+
error
|
|
448
|
+
], transferable);
|
|
449
|
+
});
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
case 2:
|
|
453
|
+
case 4:
|
|
454
|
+
this.#resolveCall(...data.slice(1));
|
|
455
|
+
break;
|
|
456
|
+
case 5: {
|
|
457
|
+
const id = data[1];
|
|
458
|
+
this.functions.release(id, this);
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}, { signal: this.signal });
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Closes the communication channel between the two threads. This will prevent
|
|
466
|
+
* any further communication between the threads, and will clean up any memory
|
|
467
|
+
* associated with in-progress communication. It will also reject any inflight
|
|
468
|
+
* function calls between threads with a `ThreadClosedError`.
|
|
469
|
+
*/
|
|
470
|
+
close() {
|
|
471
|
+
this.#abort.abort();
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Requests that the thread provide the context needed to make a function
|
|
475
|
+
* call between threads. You provide this method a function to call and the
|
|
476
|
+
* unserialized arguments you wish to call it with, and the thread will call
|
|
477
|
+
* the function you provided with a serialized call ID, the serialized arguments,
|
|
478
|
+
* and any transferable objects that need to be passed between threads.
|
|
479
|
+
*/
|
|
480
|
+
call(func, args) {
|
|
481
|
+
if (this.closed) return Promise.reject(new ThreadClosedError());
|
|
482
|
+
const transferable = [];
|
|
483
|
+
const serialized = this.serialization.serialize(args, this, transferable);
|
|
484
|
+
const id = nanoid();
|
|
485
|
+
const done = this.#waitForResult(id);
|
|
486
|
+
func(id, serialized, transferable);
|
|
487
|
+
return done;
|
|
488
|
+
}
|
|
489
|
+
async #callLocal(func, args, withResult) {
|
|
490
|
+
try {
|
|
491
|
+
const result = this.functions.call ? await this.functions.call(func, args, this) : await func(...this.serialization.deserialize(args, this));
|
|
492
|
+
const transferable = [];
|
|
493
|
+
withResult(this.serialization.serialize(result, this, transferable), void 0, transferable);
|
|
494
|
+
} catch (error) {
|
|
495
|
+
withResult(void 0, this.serialization.serialize(error, this));
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
#handlerForCall(property) {
|
|
499
|
+
return (...args) => {
|
|
500
|
+
try {
|
|
501
|
+
if (typeof property !== "string" && typeof property !== "number") throw new Error(`Can’t call a symbol method on a thread: ${property.toString()}`);
|
|
502
|
+
return this.call((id, serializedArgs, transferable) => {
|
|
503
|
+
this.messages.send([
|
|
504
|
+
1,
|
|
505
|
+
id,
|
|
506
|
+
property,
|
|
507
|
+
serializedArgs
|
|
508
|
+
], transferable);
|
|
509
|
+
}, args);
|
|
510
|
+
} catch (error) {
|
|
511
|
+
return Promise.reject(error);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
#resolveCall(...args) {
|
|
516
|
+
const callID = args[0];
|
|
517
|
+
const resolver = this.#idsToResolver.get(callID);
|
|
518
|
+
if (resolver) {
|
|
519
|
+
resolver(...args);
|
|
520
|
+
this.#idsToResolver.delete(callID);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
#waitForResult(id) {
|
|
524
|
+
const promise = new Promise((resolve, reject) => {
|
|
525
|
+
this.#idsToResolver.set(id, (_, value, error) => {
|
|
526
|
+
if (error == null) resolve(this.serialization.deserialize(value, this));
|
|
527
|
+
else reject(this.serialization.deserialize(error, this));
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
Object.defineProperty(promise, Symbol.asyncIterator, { async *value() {
|
|
531
|
+
const result = await promise;
|
|
532
|
+
Object.defineProperty(result, Symbol.asyncIterator, { value: () => result });
|
|
533
|
+
yield* result;
|
|
534
|
+
} });
|
|
535
|
+
return promise;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
function createThreadImports(handlerForImport, imported) {
|
|
539
|
+
let call;
|
|
540
|
+
if (imported == null) {
|
|
541
|
+
if (typeof Proxy !== "function") throw new Error(`You must pass an array of callable methods in environments without Proxies.`);
|
|
542
|
+
const cache = /* @__PURE__ */ new Map();
|
|
543
|
+
call = new Proxy({}, { get(_target, property) {
|
|
544
|
+
if (cache.has(property)) return cache.get(property);
|
|
545
|
+
const handler = handlerForImport(property);
|
|
546
|
+
cache.set(property, handler);
|
|
547
|
+
return handler;
|
|
548
|
+
} });
|
|
549
|
+
} else {
|
|
550
|
+
call = {};
|
|
551
|
+
for (const method of imported) Object.defineProperty(call, method, {
|
|
552
|
+
value: handlerForImport(method),
|
|
553
|
+
writable: false,
|
|
554
|
+
configurable: true,
|
|
555
|
+
enumerable: true
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
return call;
|
|
559
|
+
}
|
|
560
|
+
function missingThreadFunction() {
|
|
561
|
+
throw new Error(`You attempted to call a function that is not stored. It may have already been released.`);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* The contract of the member-site host (`site-host.ts`). It draws native
|
|
565
|
+
* elements with no React; Fluid's components join it as they are rebuilt
|
|
566
|
+
* without React (O-W.14). Portal's host doesn't offer it, and a worker runs on
|
|
567
|
+
* a site only when its build names it (O-W.24), so a package built for Portal,
|
|
568
|
+
* which carries React, never mounts on a site (INV-17.27).
|
|
569
|
+
*/
|
|
570
|
+
const REMOTE_DOM_SITE_UI_CONTRACT_VERSION = "site-1";
|
|
571
|
+
const REMOTE_DOM_SUPPORTED_UI_CONTRACT_VERSIONS = ["1", "2"];
|
|
572
|
+
const noProperties = {};
|
|
573
|
+
const noEvents = [];
|
|
574
|
+
const commonProperties = {
|
|
575
|
+
"aria-label": "string",
|
|
576
|
+
disabled: "boolean",
|
|
577
|
+
id: "string"
|
|
578
|
+
};
|
|
579
|
+
const disclosureProperties = {
|
|
580
|
+
defaultOpen: "boolean",
|
|
581
|
+
open: "boolean"
|
|
582
|
+
};
|
|
583
|
+
const disclosureEvents = [{
|
|
584
|
+
propName: "onOpenChange",
|
|
585
|
+
eventName: "open-change",
|
|
586
|
+
payload: "boolean"
|
|
587
|
+
}];
|
|
588
|
+
const valueProperties = {
|
|
589
|
+
defaultValue: "string",
|
|
590
|
+
value: "string"
|
|
591
|
+
};
|
|
592
|
+
const valueEvents = [{
|
|
593
|
+
propName: "onValueChange",
|
|
594
|
+
eventName: "value-change",
|
|
595
|
+
payload: "string"
|
|
596
|
+
}];
|
|
597
|
+
const singleOrMultipleValueEvents = [{
|
|
598
|
+
propName: "onValueChange",
|
|
599
|
+
eventName: "value-change",
|
|
600
|
+
payload: "string-or-string-array"
|
|
601
|
+
}];
|
|
602
|
+
function component(exportName, properties = noProperties, events = noEvents) {
|
|
603
|
+
return {
|
|
604
|
+
exportName,
|
|
605
|
+
tagName: `fluid-ui-${exportName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()}`,
|
|
606
|
+
properties,
|
|
607
|
+
events,
|
|
608
|
+
contractVersion: "2"
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Reviewed positive allowlist for host-rendered Fluid UI in Remote DOM widgets.
|
|
613
|
+
* This is runtime security policy; it must never be inferred from React props.
|
|
614
|
+
*/
|
|
615
|
+
const REMOTE_DOM_UI_COMPONENTS = [
|
|
616
|
+
component("Accordion", {
|
|
617
|
+
...commonProperties,
|
|
618
|
+
collapsible: "boolean",
|
|
619
|
+
defaultValue: "string-or-string-array",
|
|
620
|
+
dir: "string",
|
|
621
|
+
orientation: "string",
|
|
622
|
+
type: "string",
|
|
623
|
+
value: "string-or-string-array"
|
|
624
|
+
}, singleOrMultipleValueEvents),
|
|
625
|
+
component("AccordionItem", {
|
|
626
|
+
...commonProperties,
|
|
627
|
+
value: "string"
|
|
628
|
+
}),
|
|
629
|
+
component("AccordionTrigger", commonProperties),
|
|
630
|
+
component("AccordionContent", noProperties),
|
|
631
|
+
component("Alert", {
|
|
632
|
+
...commonProperties,
|
|
633
|
+
variant: "string"
|
|
634
|
+
}),
|
|
635
|
+
component("AlertTitle"),
|
|
636
|
+
component("AlertDescription"),
|
|
637
|
+
component("AlertDialog", disclosureProperties, disclosureEvents),
|
|
638
|
+
component("AlertDialogTrigger", commonProperties),
|
|
639
|
+
component("AlertDialogContent"),
|
|
640
|
+
component("AlertDialogHeader"),
|
|
641
|
+
component("AlertDialogFooter"),
|
|
642
|
+
component("AlertDialogTitle"),
|
|
643
|
+
component("AlertDialogDescription"),
|
|
644
|
+
component("AlertDialogMedia"),
|
|
645
|
+
component("AlertDialogAction", commonProperties),
|
|
646
|
+
component("AlertDialogCancel", commonProperties),
|
|
647
|
+
component("Avatar", { size: "string" }),
|
|
648
|
+
component("AvatarImage", {
|
|
649
|
+
alt: "string",
|
|
650
|
+
src: "url"
|
|
651
|
+
}),
|
|
652
|
+
component("AvatarFallback", { delayMs: "finite-number" }),
|
|
653
|
+
component("AvatarBadge"),
|
|
654
|
+
component("AvatarGroup"),
|
|
655
|
+
component("AvatarGroupCount"),
|
|
656
|
+
component("Badge", { variant: "string" }),
|
|
657
|
+
component("Breadcrumb"),
|
|
658
|
+
component("BreadcrumbList"),
|
|
659
|
+
component("BreadcrumbItem"),
|
|
660
|
+
component("BreadcrumbLink", { href: "navigation-url" }),
|
|
661
|
+
component("BreadcrumbPage"),
|
|
662
|
+
component("BreadcrumbSeparator"),
|
|
663
|
+
component("BreadcrumbEllipsis"),
|
|
664
|
+
component("Button", {
|
|
665
|
+
...commonProperties,
|
|
666
|
+
name: "string",
|
|
667
|
+
size: "string",
|
|
668
|
+
type: "string",
|
|
669
|
+
value: "string",
|
|
670
|
+
variant: "string"
|
|
671
|
+
}, [{
|
|
672
|
+
propName: "onPress",
|
|
673
|
+
eventName: "press",
|
|
674
|
+
payload: "void"
|
|
675
|
+
}]),
|
|
676
|
+
component("Calendar", {
|
|
677
|
+
defaultMonth: "string",
|
|
678
|
+
disabledDates: "string-array",
|
|
679
|
+
fromDate: "string",
|
|
680
|
+
month: "string",
|
|
681
|
+
selected: "string",
|
|
682
|
+
showOutsideDays: "boolean",
|
|
683
|
+
toDate: "string"
|
|
684
|
+
}, [{
|
|
685
|
+
propName: "onMonthChange",
|
|
686
|
+
eventName: "month-change",
|
|
687
|
+
payload: "string"
|
|
688
|
+
}, {
|
|
689
|
+
propName: "onSelectedChange",
|
|
690
|
+
eventName: "selected-change",
|
|
691
|
+
payload: "string"
|
|
692
|
+
}]),
|
|
693
|
+
component("Checkbox", {
|
|
694
|
+
...commonProperties,
|
|
695
|
+
checked: "boolean",
|
|
696
|
+
defaultChecked: "boolean",
|
|
697
|
+
name: "string",
|
|
698
|
+
required: "boolean",
|
|
699
|
+
value: "string"
|
|
700
|
+
}, [{
|
|
701
|
+
propName: "onCheckedChange",
|
|
702
|
+
eventName: "checked-change",
|
|
703
|
+
payload: "boolean"
|
|
704
|
+
}]),
|
|
705
|
+
component("Card"),
|
|
706
|
+
component("CardHeader"),
|
|
707
|
+
component("CardFooter"),
|
|
708
|
+
component("CardTitle"),
|
|
709
|
+
component("CardAction"),
|
|
710
|
+
component("CardDescription"),
|
|
711
|
+
component("CardContent"),
|
|
712
|
+
component("Collapsible", disclosureProperties, disclosureEvents),
|
|
713
|
+
component("CollapsibleTrigger", commonProperties),
|
|
714
|
+
component("CollapsibleContent"),
|
|
715
|
+
component("Command", {
|
|
716
|
+
loop: "boolean",
|
|
717
|
+
shouldFilter: "boolean",
|
|
718
|
+
value: "string"
|
|
719
|
+
}, valueEvents),
|
|
720
|
+
component("CommandInput", {
|
|
721
|
+
...commonProperties,
|
|
722
|
+
placeholder: "string",
|
|
723
|
+
value: "string"
|
|
724
|
+
}, valueEvents),
|
|
725
|
+
component("CommandList"),
|
|
726
|
+
component("CommandEmpty"),
|
|
727
|
+
component("CommandGroup", {
|
|
728
|
+
heading: "string",
|
|
729
|
+
value: "string"
|
|
730
|
+
}),
|
|
731
|
+
component("CommandItem", {
|
|
732
|
+
...commonProperties,
|
|
733
|
+
keywords: "string-array",
|
|
734
|
+
value: "string"
|
|
735
|
+
}, [{
|
|
736
|
+
propName: "onSelect",
|
|
737
|
+
eventName: "select",
|
|
738
|
+
payload: "string"
|
|
739
|
+
}]),
|
|
740
|
+
component("CommandShortcut"),
|
|
741
|
+
component("CommandSeparator", { alwaysRender: "boolean" }),
|
|
742
|
+
component("DatePicker", {
|
|
743
|
+
...commonProperties,
|
|
744
|
+
placeholder: "string",
|
|
745
|
+
value: "string"
|
|
746
|
+
}, [{
|
|
747
|
+
propName: "onChange",
|
|
748
|
+
eventName: "change",
|
|
749
|
+
payload: "string"
|
|
750
|
+
}]),
|
|
751
|
+
component("Dialog", disclosureProperties, disclosureEvents),
|
|
752
|
+
component("DialogTrigger", commonProperties),
|
|
753
|
+
component("DialogContent", {
|
|
754
|
+
...commonProperties,
|
|
755
|
+
showCloseButton: "boolean"
|
|
756
|
+
}),
|
|
757
|
+
component("DialogHeader"),
|
|
758
|
+
component("DialogFooter"),
|
|
759
|
+
component("DialogTitle"),
|
|
760
|
+
component("DialogDescription"),
|
|
761
|
+
component("DialogClose", commonProperties),
|
|
762
|
+
component("DropdownMenu", disclosureProperties, disclosureEvents),
|
|
763
|
+
component("DropdownMenuTrigger", commonProperties),
|
|
764
|
+
component("DropdownMenuContent", {
|
|
765
|
+
align: "string",
|
|
766
|
+
alignOffset: "finite-number",
|
|
767
|
+
side: "string",
|
|
768
|
+
sideOffset: "finite-number"
|
|
769
|
+
}),
|
|
770
|
+
component("DropdownMenuGroup"),
|
|
771
|
+
component("DropdownMenuLabel", { inset: "boolean" }),
|
|
772
|
+
component("DropdownMenuItem", {
|
|
773
|
+
...commonProperties,
|
|
774
|
+
inset: "boolean"
|
|
775
|
+
}, [{
|
|
776
|
+
propName: "onSelect",
|
|
777
|
+
eventName: "select",
|
|
778
|
+
payload: "void"
|
|
779
|
+
}]),
|
|
780
|
+
component("DropdownMenuCheckboxItem", {
|
|
781
|
+
...commonProperties,
|
|
782
|
+
checked: "boolean"
|
|
783
|
+
}, [{
|
|
784
|
+
propName: "onCheckedChange",
|
|
785
|
+
eventName: "checked-change",
|
|
786
|
+
payload: "boolean"
|
|
787
|
+
}]),
|
|
788
|
+
component("DropdownMenuRadioGroup", valueProperties, valueEvents),
|
|
789
|
+
component("DropdownMenuRadioItem", {
|
|
790
|
+
...commonProperties,
|
|
791
|
+
value: "string"
|
|
792
|
+
}),
|
|
793
|
+
component("DropdownMenuSeparator"),
|
|
794
|
+
component("DropdownMenuShortcut"),
|
|
795
|
+
component("DropdownMenuSub", disclosureProperties, disclosureEvents),
|
|
796
|
+
component("DropdownMenuSubTrigger", {
|
|
797
|
+
...commonProperties,
|
|
798
|
+
inset: "boolean"
|
|
799
|
+
}),
|
|
800
|
+
component("DropdownMenuSubContent", {
|
|
801
|
+
alignOffset: "finite-number",
|
|
802
|
+
sideOffset: "finite-number"
|
|
803
|
+
}),
|
|
804
|
+
component("Input", {
|
|
805
|
+
...commonProperties,
|
|
806
|
+
autoComplete: "string",
|
|
807
|
+
checked: "boolean",
|
|
808
|
+
max: "string",
|
|
809
|
+
maxLength: "finite-number",
|
|
810
|
+
min: "string",
|
|
811
|
+
minLength: "finite-number",
|
|
812
|
+
name: "string",
|
|
813
|
+
pattern: "string",
|
|
814
|
+
placeholder: "string",
|
|
815
|
+
readOnly: "boolean",
|
|
816
|
+
required: "boolean",
|
|
817
|
+
step: "string",
|
|
818
|
+
type: "string",
|
|
819
|
+
value: "string"
|
|
820
|
+
}, [
|
|
821
|
+
{
|
|
822
|
+
propName: "onBlur",
|
|
823
|
+
eventName: "blur",
|
|
824
|
+
payload: "void"
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
propName: "onFocus",
|
|
828
|
+
eventName: "focus",
|
|
829
|
+
payload: "void"
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
propName: "onValueChange",
|
|
833
|
+
eventName: "value-change",
|
|
834
|
+
payload: "string"
|
|
835
|
+
}
|
|
836
|
+
]),
|
|
837
|
+
component("Label", { htmlFor: "string" }),
|
|
838
|
+
component("Pagination"),
|
|
839
|
+
component("PaginationContent"),
|
|
840
|
+
component("PaginationItem"),
|
|
841
|
+
component("PaginationLink", {
|
|
842
|
+
...commonProperties,
|
|
843
|
+
href: "navigation-url",
|
|
844
|
+
isActive: "boolean",
|
|
845
|
+
size: "string"
|
|
846
|
+
}),
|
|
847
|
+
component("PaginationPrevious", { href: "navigation-url" }),
|
|
848
|
+
component("PaginationNext", { href: "navigation-url" }),
|
|
849
|
+
component("PaginationEllipsis"),
|
|
850
|
+
component("Popover", {
|
|
851
|
+
...disclosureProperties,
|
|
852
|
+
modal: "boolean"
|
|
853
|
+
}, disclosureEvents),
|
|
854
|
+
component("PopoverTrigger", commonProperties),
|
|
855
|
+
component("PopoverAnchor"),
|
|
856
|
+
component("PopoverContent", {
|
|
857
|
+
align: "string",
|
|
858
|
+
alignOffset: "finite-number",
|
|
859
|
+
side: "string",
|
|
860
|
+
sideOffset: "finite-number"
|
|
861
|
+
}),
|
|
862
|
+
component("PopoverHeader"),
|
|
863
|
+
component("PopoverTitle"),
|
|
864
|
+
component("PopoverDescription"),
|
|
865
|
+
component("Progress", {
|
|
866
|
+
max: "finite-number",
|
|
867
|
+
value: "finite-number"
|
|
868
|
+
}),
|
|
869
|
+
component("RadioGroup", {
|
|
870
|
+
...commonProperties,
|
|
871
|
+
...valueProperties,
|
|
872
|
+
orientation: "string",
|
|
873
|
+
required: "boolean"
|
|
874
|
+
}, valueEvents),
|
|
875
|
+
component("RadioGroupItem", {
|
|
876
|
+
...commonProperties,
|
|
877
|
+
value: "string"
|
|
878
|
+
}),
|
|
879
|
+
component("ScrollArea", {
|
|
880
|
+
dir: "string",
|
|
881
|
+
type: "string"
|
|
882
|
+
}),
|
|
883
|
+
component("ScrollBar", { orientation: "string" }),
|
|
884
|
+
component("Select", {
|
|
885
|
+
...commonProperties,
|
|
886
|
+
...valueProperties,
|
|
887
|
+
name: "string",
|
|
888
|
+
open: "boolean",
|
|
889
|
+
required: "boolean"
|
|
890
|
+
}, [...valueEvents, ...disclosureEvents]),
|
|
891
|
+
component("SelectGroup"),
|
|
892
|
+
component("SelectValue", { placeholder: "string" }),
|
|
893
|
+
component("SelectTrigger", {
|
|
894
|
+
...commonProperties,
|
|
895
|
+
size: "string"
|
|
896
|
+
}),
|
|
897
|
+
component("SelectContent", {
|
|
898
|
+
align: "string",
|
|
899
|
+
position: "string",
|
|
900
|
+
side: "string",
|
|
901
|
+
sideOffset: "finite-number"
|
|
902
|
+
}),
|
|
903
|
+
component("SelectLabel"),
|
|
904
|
+
component("SelectItem", {
|
|
905
|
+
...commonProperties,
|
|
906
|
+
textValue: "string",
|
|
907
|
+
value: "string"
|
|
908
|
+
}),
|
|
909
|
+
component("SelectSeparator"),
|
|
910
|
+
component("SelectScrollUpButton"),
|
|
911
|
+
component("SelectScrollDownButton"),
|
|
912
|
+
component("Separator", {
|
|
913
|
+
decorative: "boolean",
|
|
914
|
+
orientation: "string"
|
|
915
|
+
}),
|
|
916
|
+
component("Sheet", disclosureProperties, disclosureEvents),
|
|
917
|
+
component("SheetTrigger", commonProperties),
|
|
918
|
+
component("SheetContent", {
|
|
919
|
+
...commonProperties,
|
|
920
|
+
side: "string"
|
|
921
|
+
}),
|
|
922
|
+
component("SheetHeader"),
|
|
923
|
+
component("SheetFooter"),
|
|
924
|
+
component("SheetTitle"),
|
|
925
|
+
component("SheetDescription"),
|
|
926
|
+
component("SheetClose", commonProperties),
|
|
927
|
+
component("Skeleton", { "aria-label": "string" }),
|
|
928
|
+
component("Slider", {
|
|
929
|
+
...commonProperties,
|
|
930
|
+
defaultValue: "finite-number-array",
|
|
931
|
+
inverted: "boolean",
|
|
932
|
+
max: "finite-number",
|
|
933
|
+
min: "finite-number",
|
|
934
|
+
name: "string",
|
|
935
|
+
orientation: "string",
|
|
936
|
+
step: "finite-number",
|
|
937
|
+
value: "finite-number-array"
|
|
938
|
+
}, [{
|
|
939
|
+
propName: "onValueChange",
|
|
940
|
+
eventName: "value-change",
|
|
941
|
+
payload: "finite-number-array"
|
|
942
|
+
}, {
|
|
943
|
+
propName: "onValueCommit",
|
|
944
|
+
eventName: "value-commit",
|
|
945
|
+
payload: "finite-number-array"
|
|
946
|
+
}]),
|
|
947
|
+
component("Spinner", { "aria-label": "string" }),
|
|
948
|
+
component("SpinnerWithText", {
|
|
949
|
+
text: "string",
|
|
950
|
+
variant: "string"
|
|
951
|
+
}),
|
|
952
|
+
component("Switch", {
|
|
953
|
+
...commonProperties,
|
|
954
|
+
checked: "boolean",
|
|
955
|
+
defaultChecked: "boolean",
|
|
956
|
+
name: "string",
|
|
957
|
+
required: "boolean",
|
|
958
|
+
value: "string"
|
|
959
|
+
}, [{
|
|
960
|
+
propName: "onCheckedChange",
|
|
961
|
+
eventName: "checked-change",
|
|
962
|
+
payload: "boolean"
|
|
963
|
+
}]),
|
|
964
|
+
component("Table"),
|
|
965
|
+
component("TableHeader"),
|
|
966
|
+
component("TableBody"),
|
|
967
|
+
component("TableFooter"),
|
|
968
|
+
component("TableRow"),
|
|
969
|
+
component("TableHead"),
|
|
970
|
+
component("TableCell"),
|
|
971
|
+
component("TableCaption"),
|
|
972
|
+
component("Tabs", {
|
|
973
|
+
...commonProperties,
|
|
974
|
+
...valueProperties,
|
|
975
|
+
activationMode: "string",
|
|
976
|
+
orientation: "string"
|
|
977
|
+
}, valueEvents),
|
|
978
|
+
component("TabsList", { loop: "boolean" }),
|
|
979
|
+
component("TabsTrigger", {
|
|
980
|
+
...commonProperties,
|
|
981
|
+
value: "string"
|
|
982
|
+
}),
|
|
983
|
+
component("TabsContent", { value: "string" }),
|
|
984
|
+
component("Textarea", {
|
|
985
|
+
...commonProperties,
|
|
986
|
+
autoComplete: "string",
|
|
987
|
+
maxLength: "finite-number",
|
|
988
|
+
minLength: "finite-number",
|
|
989
|
+
name: "string",
|
|
990
|
+
placeholder: "string",
|
|
991
|
+
readOnly: "boolean",
|
|
992
|
+
required: "boolean",
|
|
993
|
+
rows: "finite-number",
|
|
994
|
+
value: "string"
|
|
995
|
+
}, [
|
|
996
|
+
{
|
|
997
|
+
propName: "onBlur",
|
|
998
|
+
eventName: "blur",
|
|
999
|
+
payload: "void"
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
propName: "onFocus",
|
|
1003
|
+
eventName: "focus",
|
|
1004
|
+
payload: "void"
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
propName: "onValueChange",
|
|
1008
|
+
eventName: "value-change",
|
|
1009
|
+
payload: "string"
|
|
1010
|
+
}
|
|
1011
|
+
]),
|
|
1012
|
+
component("Toggle", {
|
|
1013
|
+
...commonProperties,
|
|
1014
|
+
defaultPressed: "boolean",
|
|
1015
|
+
pressed: "boolean",
|
|
1016
|
+
size: "string",
|
|
1017
|
+
variant: "string"
|
|
1018
|
+
}, [{
|
|
1019
|
+
propName: "onPressedChange",
|
|
1020
|
+
eventName: "pressed-change",
|
|
1021
|
+
payload: "boolean"
|
|
1022
|
+
}]),
|
|
1023
|
+
component("ToggleGroup", {
|
|
1024
|
+
...commonProperties,
|
|
1025
|
+
defaultValue: "string-or-string-array",
|
|
1026
|
+
orientation: "string",
|
|
1027
|
+
rovingFocus: "boolean",
|
|
1028
|
+
spacing: "finite-number",
|
|
1029
|
+
type: "string",
|
|
1030
|
+
value: "string-or-string-array"
|
|
1031
|
+
}, singleOrMultipleValueEvents),
|
|
1032
|
+
component("ToggleGroupItem", {
|
|
1033
|
+
...commonProperties,
|
|
1034
|
+
value: "string"
|
|
1035
|
+
}),
|
|
1036
|
+
component("Tooltip", {
|
|
1037
|
+
defaultOpen: "boolean",
|
|
1038
|
+
delayDuration: "finite-number",
|
|
1039
|
+
open: "boolean"
|
|
1040
|
+
}, disclosureEvents),
|
|
1041
|
+
component("TooltipTrigger", commonProperties),
|
|
1042
|
+
component("TooltipContent", {
|
|
1043
|
+
align: "string",
|
|
1044
|
+
side: "string",
|
|
1045
|
+
sideOffset: "finite-number"
|
|
1046
|
+
}),
|
|
1047
|
+
component("Combobox", {
|
|
1048
|
+
...commonProperties,
|
|
1049
|
+
emptyText: "string",
|
|
1050
|
+
options: "option-array",
|
|
1051
|
+
placeholder: "string",
|
|
1052
|
+
value: "string",
|
|
1053
|
+
zIndex: "finite-number"
|
|
1054
|
+
}, valueEvents),
|
|
1055
|
+
component("InfiniteScrollSentinel", {
|
|
1056
|
+
hasMore: "boolean",
|
|
1057
|
+
isLoading: "boolean",
|
|
1058
|
+
rootMargin: "string"
|
|
1059
|
+
}, [{
|
|
1060
|
+
propName: "onLoadMore",
|
|
1061
|
+
eventName: "load-more",
|
|
1062
|
+
payload: "void"
|
|
1063
|
+
}]),
|
|
1064
|
+
component("PhoneInput", {
|
|
1065
|
+
...commonProperties,
|
|
1066
|
+
defaultCountry: "string",
|
|
1067
|
+
emptyText: "string",
|
|
1068
|
+
error: "boolean",
|
|
1069
|
+
searchPlaceholder: "string",
|
|
1070
|
+
value: "string"
|
|
1071
|
+
}, [
|
|
1072
|
+
{
|
|
1073
|
+
propName: "onBlur",
|
|
1074
|
+
eventName: "blur",
|
|
1075
|
+
payload: "void"
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
propName: "onFocus",
|
|
1079
|
+
eventName: "focus",
|
|
1080
|
+
payload: "void"
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
propName: "onValueChange",
|
|
1084
|
+
eventName: "value-change",
|
|
1085
|
+
payload: "string"
|
|
1086
|
+
}
|
|
1087
|
+
]),
|
|
1088
|
+
{
|
|
1089
|
+
exportName: "SearchSort",
|
|
1090
|
+
tagName: "fluid-ui-search-sort",
|
|
1091
|
+
properties: {
|
|
1092
|
+
clearLabel: "string",
|
|
1093
|
+
placeholder: "string",
|
|
1094
|
+
searchValue: "string",
|
|
1095
|
+
sortLabel: "string",
|
|
1096
|
+
sortOptions: "option-array",
|
|
1097
|
+
sortValue: "string"
|
|
1098
|
+
},
|
|
1099
|
+
events: [{
|
|
1100
|
+
propName: "onSearchChange",
|
|
1101
|
+
eventName: "search-change",
|
|
1102
|
+
payload: "string"
|
|
1103
|
+
}, {
|
|
1104
|
+
propName: "onSortChange",
|
|
1105
|
+
eventName: "sort-change",
|
|
1106
|
+
payload: "string"
|
|
1107
|
+
}],
|
|
1108
|
+
contractVersion: "1"
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
exportName: "FluidSpacerWidget",
|
|
1112
|
+
tagName: "fluid-spacer-widget",
|
|
1113
|
+
properties: {
|
|
1114
|
+
customHeight: "string",
|
|
1115
|
+
previewMode: "boolean"
|
|
1116
|
+
},
|
|
1117
|
+
events: noEvents,
|
|
1118
|
+
contractVersion: "1"
|
|
1119
|
+
}
|
|
1120
|
+
];
|
|
1121
|
+
const REMOTE_DOM_UI_COMPONENT_BY_TAG = new Map(REMOTE_DOM_UI_COMPONENTS.map((definition) => [definition.tagName, definition]));
|
|
1122
|
+
function getRemoteDomUiComponent(tagName) {
|
|
1123
|
+
return REMOTE_DOM_UI_COMPONENT_BY_TAG.get(tagName);
|
|
1124
|
+
}
|
|
1125
|
+
// src/remote-dom-values.ts
|
|
1126
|
+
const REMOTE_DOM_FULLSCREEN_CAPABILITY = "fullscreen";
|
|
1127
|
+
/** Canonical element allowlist shared by the worker registration and host sanitizer. */
|
|
1128
|
+
const REMOTE_DOM_ALLOWED_TAG_NAMES = [
|
|
1129
|
+
"a",
|
|
1130
|
+
"abbr",
|
|
1131
|
+
"address",
|
|
1132
|
+
"article",
|
|
1133
|
+
"aside",
|
|
1134
|
+
"audio",
|
|
1135
|
+
"b",
|
|
1136
|
+
"bdi",
|
|
1137
|
+
"bdo",
|
|
1138
|
+
"blockquote",
|
|
1139
|
+
"br",
|
|
1140
|
+
"button",
|
|
1141
|
+
"caption",
|
|
1142
|
+
"cite",
|
|
1143
|
+
"code",
|
|
1144
|
+
"col",
|
|
1145
|
+
"colgroup",
|
|
1146
|
+
"data",
|
|
1147
|
+
"dd",
|
|
1148
|
+
"del",
|
|
1149
|
+
"details",
|
|
1150
|
+
"dfn",
|
|
1151
|
+
"dialog",
|
|
1152
|
+
"div",
|
|
1153
|
+
"dl",
|
|
1154
|
+
"dt",
|
|
1155
|
+
"em",
|
|
1156
|
+
"fieldset",
|
|
1157
|
+
"figcaption",
|
|
1158
|
+
"figure",
|
|
1159
|
+
"footer",
|
|
1160
|
+
"form",
|
|
1161
|
+
"h1",
|
|
1162
|
+
"h2",
|
|
1163
|
+
"h3",
|
|
1164
|
+
"h4",
|
|
1165
|
+
"h5",
|
|
1166
|
+
"h6",
|
|
1167
|
+
"header",
|
|
1168
|
+
"hr",
|
|
1169
|
+
"i",
|
|
1170
|
+
"img",
|
|
1171
|
+
"input",
|
|
1172
|
+
"ins",
|
|
1173
|
+
"kbd",
|
|
1174
|
+
"label",
|
|
1175
|
+
"legend",
|
|
1176
|
+
"li",
|
|
1177
|
+
"main",
|
|
1178
|
+
"mark",
|
|
1179
|
+
"meter",
|
|
1180
|
+
"nav",
|
|
1181
|
+
"ol",
|
|
1182
|
+
"optgroup",
|
|
1183
|
+
"option",
|
|
1184
|
+
"output",
|
|
1185
|
+
"p",
|
|
1186
|
+
"picture",
|
|
1187
|
+
"pre",
|
|
1188
|
+
"progress",
|
|
1189
|
+
"q",
|
|
1190
|
+
"rp",
|
|
1191
|
+
"rt",
|
|
1192
|
+
"ruby",
|
|
1193
|
+
"s",
|
|
1194
|
+
"samp",
|
|
1195
|
+
"section",
|
|
1196
|
+
"select",
|
|
1197
|
+
"small",
|
|
1198
|
+
"source",
|
|
1199
|
+
"span",
|
|
1200
|
+
"strong",
|
|
1201
|
+
"sub",
|
|
1202
|
+
"summary",
|
|
1203
|
+
"sup",
|
|
1204
|
+
"table",
|
|
1205
|
+
"tbody",
|
|
1206
|
+
"td",
|
|
1207
|
+
"textarea",
|
|
1208
|
+
"tfoot",
|
|
1209
|
+
"th",
|
|
1210
|
+
"thead",
|
|
1211
|
+
"time",
|
|
1212
|
+
"tr",
|
|
1213
|
+
"track",
|
|
1214
|
+
"u",
|
|
1215
|
+
"ul",
|
|
1216
|
+
"var",
|
|
1217
|
+
"video",
|
|
1218
|
+
"wbr",
|
|
1219
|
+
...REMOTE_DOM_UI_COMPONENTS.map(({ tagName }) => tagName)
|
|
1220
|
+
];
|
|
1221
|
+
/** Canonical event allowlist shared by worker elements and host forwarding. */
|
|
1222
|
+
const SUPPORTED_REMOTE_DOM_EVENTS = [
|
|
1223
|
+
"blur",
|
|
1224
|
+
"change",
|
|
1225
|
+
"click",
|
|
1226
|
+
"contextmenu",
|
|
1227
|
+
"dblclick",
|
|
1228
|
+
"focus",
|
|
1229
|
+
"input",
|
|
1230
|
+
"keydown",
|
|
1231
|
+
"keypress",
|
|
1232
|
+
"keyup",
|
|
1233
|
+
"mousedown",
|
|
1234
|
+
"mouseenter",
|
|
1235
|
+
"mouseleave",
|
|
1236
|
+
"mousemove",
|
|
1237
|
+
"mouseout",
|
|
1238
|
+
"mouseover",
|
|
1239
|
+
"mouseup",
|
|
1240
|
+
"pointercancel",
|
|
1241
|
+
"pointerdown",
|
|
1242
|
+
"pointerenter",
|
|
1243
|
+
"pointerleave",
|
|
1244
|
+
"pointermove",
|
|
1245
|
+
"pointerout",
|
|
1246
|
+
"pointerover",
|
|
1247
|
+
"pointerup",
|
|
1248
|
+
"submit"
|
|
1249
|
+
];
|
|
1250
|
+
[...new Set(REMOTE_DOM_UI_COMPONENTS.flatMap(({ events }) => events.map(({ eventName }) => eventName)))];
|
|
1251
|
+
const REMOTE_DOM_UNSAFE_PROPERTY_KEYS = /* @__PURE__ */ new Set([
|
|
1252
|
+
"__proto__",
|
|
1253
|
+
"constructor",
|
|
1254
|
+
"prototype"
|
|
1255
|
+
]);
|
|
1256
|
+
const MAX_REMOTE_DOM_SERIALIZATION_DEPTH = 50;
|
|
1257
|
+
function isSafeRemoteDomPropertyKey(key) {
|
|
1258
|
+
return !REMOTE_DOM_UNSAFE_PROPERTY_KEYS.has(key);
|
|
1259
|
+
}
|
|
1260
|
+
/** Converts an arbitrary value into a structured-clone-safe Remote DOM value. */
|
|
1261
|
+
function toRemoteDomSerializableValue(value) {
|
|
1262
|
+
return serializeRemoteDomValue(value, /* @__PURE__ */ new WeakSet(), 0);
|
|
1263
|
+
}
|
|
1264
|
+
function serializeRemoteDomValue(value, ancestors, depth) {
|
|
1265
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
|
|
1266
|
+
if (typeof value === "bigint") return value.toString();
|
|
1267
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
1268
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
1269
|
+
if (typeof value !== "object") return null;
|
|
1270
|
+
if (depth > MAX_REMOTE_DOM_SERIALIZATION_DEPTH || ancestors.has(value)) return null;
|
|
1271
|
+
if (value instanceof Date) return Number.isFinite(value.getTime()) ? value.toISOString() : null;
|
|
1272
|
+
if (value instanceof Error) return {
|
|
1273
|
+
name: value.name,
|
|
1274
|
+
message: value.message
|
|
1275
|
+
};
|
|
1276
|
+
ancestors.add(value);
|
|
1277
|
+
try {
|
|
1278
|
+
if (Array.isArray(value)) return value.map((item) => serializeRemoteDomValue(item, ancestors, depth + 1) ?? null);
|
|
1279
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1280
|
+
if (prototype !== Object.prototype && prototype !== null) return null;
|
|
1281
|
+
const serialized = {};
|
|
1282
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1283
|
+
if (!isSafeRemoteDomPropertyKey(key)) continue;
|
|
1284
|
+
const serializedItem = serializeRemoteDomValue(item, ancestors, depth + 1);
|
|
1285
|
+
if (serializedItem !== void 0) serialized[key] = serializedItem;
|
|
1286
|
+
}
|
|
1287
|
+
return serialized;
|
|
1288
|
+
} finally {
|
|
1289
|
+
ancestors.delete(value);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
function isRemoteDomSerializableValue(value) {
|
|
1293
|
+
return isRemoteDomSerializableValueInternal(value, /* @__PURE__ */ new WeakSet(), 0);
|
|
1294
|
+
}
|
|
1295
|
+
function isRemoteDomSerializableValueInternal(value, seen, depth) {
|
|
1296
|
+
if (value === null) return true;
|
|
1297
|
+
switch (typeof value) {
|
|
1298
|
+
case "boolean":
|
|
1299
|
+
case "string": return true;
|
|
1300
|
+
case "number": return Number.isFinite(value);
|
|
1301
|
+
case "object": return isRemoteDomSerializableObject(value, seen, depth);
|
|
1302
|
+
default: return false;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
function isRemoteDomSerializableObject(value, ancestors, depth) {
|
|
1306
|
+
if (depth > 50 || ancestors.has(value)) return false;
|
|
1307
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1308
|
+
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) return false;
|
|
1309
|
+
ancestors.add(value);
|
|
1310
|
+
try {
|
|
1311
|
+
if (Array.isArray(value)) return value.every((item) => isRemoteDomSerializableValueInternal(item, ancestors, depth + 1));
|
|
1312
|
+
return Object.entries(value).every(([key, item]) => isSafeRemoteDomPropertyKey(key) && isRemoteDomSerializableValueInternal(item, ancestors, depth + 1));
|
|
1313
|
+
} finally {
|
|
1314
|
+
ancestors.delete(value);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
const DEFAULT_REMOTE_DOM_MEDIA_ORIGINS = [
|
|
1318
|
+
"https://assets.fluid.app",
|
|
1319
|
+
"https://cdn.fluid.app",
|
|
1320
|
+
"https://ik.imagekit.io",
|
|
1321
|
+
"https://media.fluid.app"
|
|
1322
|
+
];
|
|
1323
|
+
function createRemoteDomUrlOriginPolicy({ artifactUrls, mediaOrigins = DEFAULT_REMOTE_DOM_MEDIA_ORIGINS, navigationOrigin }) {
|
|
1324
|
+
const artifactOriginSet = /* @__PURE__ */ new Set();
|
|
1325
|
+
let artifactBaseUrl;
|
|
1326
|
+
for (const artifactUrl of artifactUrls) {
|
|
1327
|
+
const normalizedUrl = normalizeRemoteDomHttpUrl(artifactUrl);
|
|
1328
|
+
if (!normalizedUrl) continue;
|
|
1329
|
+
artifactOriginSet.add(normalizedUrl.origin);
|
|
1330
|
+
artifactBaseUrl ??= normalizedUrl.href;
|
|
1331
|
+
}
|
|
1332
|
+
const mediaOriginSet = /* @__PURE__ */ new Set();
|
|
1333
|
+
for (const mediaOrigin of mediaOrigins) {
|
|
1334
|
+
const origin = normalizeRemoteDomHttpOrigin(mediaOrigin);
|
|
1335
|
+
if (origin) mediaOriginSet.add(origin);
|
|
1336
|
+
}
|
|
1337
|
+
const navigationHttpOrigin = navigationOrigin ? normalizeRemoteDomHttpOrigin(navigationOrigin) : void 0;
|
|
1338
|
+
return {
|
|
1339
|
+
artifactOrigins: Array.from(artifactOriginSet),
|
|
1340
|
+
...artifactBaseUrl ? { artifactBaseUrl } : {},
|
|
1341
|
+
mediaOrigins: Array.from(mediaOriginSet),
|
|
1342
|
+
...navigationHttpOrigin === void 0 ? {} : { navigationOrigin: navigationHttpOrigin }
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
function normalizeRemoteDomHttpOrigin(value) {
|
|
1346
|
+
return normalizeRemoteDomHttpUrl(value)?.origin;
|
|
1347
|
+
}
|
|
1348
|
+
function normalizeRemoteDomHttpUrl(value) {
|
|
1349
|
+
try {
|
|
1350
|
+
const parsedUrl = new URL(value);
|
|
1351
|
+
return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:" ? parsedUrl : void 0;
|
|
1352
|
+
} catch {
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
export { isRemoteDomSerializableValue as a, REMOTE_DOM_SITE_UI_CONTRACT_VERSION as c, getRemoteDomUiComponent as d, Thread as f, createRemoteDomUrlOriginPolicy as i, REMOTE_DOM_SUPPORTED_UI_CONTRACT_VERSIONS as l, retain as m, REMOTE_DOM_FULLSCREEN_CAPABILITY as n, isSafeRemoteDomPropertyKey as o, release as p, SUPPORTED_REMOTE_DOM_EVENTS as r, toRemoteDomSerializableValue as s, REMOTE_DOM_ALLOWED_TAG_NAMES as t, REMOTE_DOM_UI_COMPONENTS as u };
|
|
1357
|
+
|
|
1358
|
+
//# sourceMappingURL=remote-dom-values-BBN5u_Mj.mjs.map
|