forgeframe 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -8
- package/dist/communication/messenger.d.ts +6 -0
- package/dist/constants.d.ts +1 -5
- package/dist/core/component.d.ts +5 -0
- package/dist/core/consumer.d.ts +39 -0
- package/dist/core/host.d.ts +43 -3
- package/dist/forgeframe.js +815 -600
- package/dist/forgeframe.umd.cjs +2 -2
- package/dist/index.d.ts +14 -3
- package/dist/props/index.d.ts +1 -1
- package/dist/props/normalize.d.ts +11 -0
- package/dist/props/schema.d.ts +11 -3
- package/dist/types.d.ts +2 -2
- package/package.json +7 -2
package/dist/forgeframe.js
CHANGED
|
@@ -33,7 +33,7 @@ const p = {
|
|
|
33
33
|
BASE64: "base64",
|
|
34
34
|
/** Dot notation for nested objects (e.g., "a.b.c=value") */
|
|
35
35
|
DOTIFY: "dotify"
|
|
36
|
-
},
|
|
36
|
+
}, T = {
|
|
37
37
|
/** Request message expecting a response */
|
|
38
38
|
REQUEST: "request",
|
|
39
39
|
/** Response to a previous request */
|
|
@@ -63,8 +63,14 @@ const p = {
|
|
|
63
63
|
CONSUMER_EXPORT: "forgeframe_consumer_export",
|
|
64
64
|
/** Get sibling components request */
|
|
65
65
|
GET_SIBLINGS: "forgeframe_get_siblings"
|
|
66
|
-
},
|
|
67
|
-
|
|
66
|
+
}, F = "__forgeframe__", ye = (() => {
|
|
67
|
+
if ("0.0.3".trim().length === 0)
|
|
68
|
+
throw new Error(
|
|
69
|
+
"ForgeFrame VERSION injection is missing. Configure __FORGEFRAME_VERSION__ in build/test tooling."
|
|
70
|
+
);
|
|
71
|
+
return "0.0.3";
|
|
72
|
+
})();
|
|
73
|
+
class we {
|
|
68
74
|
/**
|
|
69
75
|
* Internal storage for event listeners mapped by event name.
|
|
70
76
|
* @internal
|
|
@@ -87,8 +93,8 @@ class me {
|
|
|
87
93
|
*
|
|
88
94
|
* @public
|
|
89
95
|
*/
|
|
90
|
-
on(e,
|
|
91
|
-
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(
|
|
96
|
+
on(e, t) {
|
|
97
|
+
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), () => this.off(e, t);
|
|
92
98
|
}
|
|
93
99
|
/**
|
|
94
100
|
* Subscribes a handler to an event that will automatically unsubscribe after the first invocation.
|
|
@@ -111,8 +117,8 @@ class me {
|
|
|
111
117
|
*
|
|
112
118
|
* @public
|
|
113
119
|
*/
|
|
114
|
-
once(e,
|
|
115
|
-
const n = (i) => (this.off(e, n),
|
|
120
|
+
once(e, t) {
|
|
121
|
+
const n = (i) => (this.off(e, n), t(i));
|
|
116
122
|
return this.on(e, n);
|
|
117
123
|
}
|
|
118
124
|
/**
|
|
@@ -134,12 +140,12 @@ class me {
|
|
|
134
140
|
*
|
|
135
141
|
* @public
|
|
136
142
|
*/
|
|
137
|
-
emit(e,
|
|
143
|
+
emit(e, t) {
|
|
138
144
|
const n = this.listeners.get(e);
|
|
139
145
|
if (n)
|
|
140
146
|
for (const i of n)
|
|
141
147
|
try {
|
|
142
|
-
const r = i(
|
|
148
|
+
const r = i(t);
|
|
143
149
|
r && typeof r == "object" && "catch" in r && typeof r.catch == "function" && r.catch((o) => {
|
|
144
150
|
console.error(`Error in async event handler for "${e}":`, o);
|
|
145
151
|
});
|
|
@@ -168,13 +174,13 @@ class me {
|
|
|
168
174
|
*
|
|
169
175
|
* @public
|
|
170
176
|
*/
|
|
171
|
-
off(e,
|
|
172
|
-
if (!
|
|
177
|
+
off(e, t) {
|
|
178
|
+
if (!t) {
|
|
173
179
|
this.listeners.delete(e);
|
|
174
180
|
return;
|
|
175
181
|
}
|
|
176
182
|
const n = this.listeners.get(e);
|
|
177
|
-
n && (n.delete(
|
|
183
|
+
n && (n.delete(t), n.size === 0 && this.listeners.delete(e));
|
|
178
184
|
}
|
|
179
185
|
/**
|
|
180
186
|
* Removes all event listeners from the emitter.
|
|
@@ -215,14 +221,14 @@ class me {
|
|
|
215
221
|
return this.listeners.get(e)?.size ?? 0;
|
|
216
222
|
}
|
|
217
223
|
}
|
|
218
|
-
function
|
|
219
|
-
const
|
|
220
|
-
return `${
|
|
224
|
+
function Fe() {
|
|
225
|
+
const s = Date.now().toString(36), e = Math.random().toString(36).slice(2, 11);
|
|
226
|
+
return `${s}_${e}`;
|
|
221
227
|
}
|
|
222
|
-
function
|
|
228
|
+
function z() {
|
|
223
229
|
return Math.random().toString(36).slice(2, 11);
|
|
224
230
|
}
|
|
225
|
-
class
|
|
231
|
+
class Ne {
|
|
226
232
|
/**
|
|
227
233
|
* Array of registered cleanup tasks awaiting execution.
|
|
228
234
|
* @internal
|
|
@@ -260,8 +266,8 @@ class De {
|
|
|
260
266
|
if (this.cleaned) {
|
|
261
267
|
try {
|
|
262
268
|
e();
|
|
263
|
-
} catch (
|
|
264
|
-
console.error("Error in cleanup task:",
|
|
269
|
+
} catch (t) {
|
|
270
|
+
console.error("Error in cleanup task:", t);
|
|
265
271
|
}
|
|
266
272
|
return;
|
|
267
273
|
}
|
|
@@ -293,9 +299,9 @@ class De {
|
|
|
293
299
|
this.cleaned = !0;
|
|
294
300
|
const e = this.tasks.reverse();
|
|
295
301
|
this.tasks = [];
|
|
296
|
-
for (const
|
|
302
|
+
for (const t of e)
|
|
297
303
|
try {
|
|
298
|
-
await
|
|
304
|
+
await t();
|
|
299
305
|
} catch (n) {
|
|
300
306
|
console.error("Error in cleanup task:", n);
|
|
301
307
|
}
|
|
@@ -340,60 +346,60 @@ class De {
|
|
|
340
346
|
this.tasks = [], this.cleaned = !1;
|
|
341
347
|
}
|
|
342
348
|
}
|
|
343
|
-
function
|
|
344
|
-
let
|
|
349
|
+
function _e() {
|
|
350
|
+
let s, e;
|
|
345
351
|
return { promise: new Promise((n, i) => {
|
|
346
|
-
|
|
347
|
-
}), resolve:
|
|
352
|
+
s = n, e = i;
|
|
353
|
+
}), resolve: s, reject: e };
|
|
348
354
|
}
|
|
349
|
-
function
|
|
355
|
+
function ke(s, e, t = "Operation timed out") {
|
|
350
356
|
return new Promise((n, i) => {
|
|
351
357
|
const r = setTimeout(() => {
|
|
352
|
-
i(new Error(`${
|
|
358
|
+
i(new Error(`${t} (${e}ms)`));
|
|
353
359
|
}, e);
|
|
354
|
-
|
|
360
|
+
s.then((o) => {
|
|
355
361
|
clearTimeout(r), n(o);
|
|
356
362
|
}).catch((o) => {
|
|
357
363
|
clearTimeout(r), i(o);
|
|
358
364
|
});
|
|
359
365
|
});
|
|
360
366
|
}
|
|
361
|
-
const
|
|
362
|
-
function
|
|
363
|
-
return
|
|
367
|
+
const j = "forgeframe:";
|
|
368
|
+
function M(s) {
|
|
369
|
+
return j + JSON.stringify(s);
|
|
364
370
|
}
|
|
365
|
-
function
|
|
366
|
-
if (typeof
|
|
371
|
+
function $e(s) {
|
|
372
|
+
if (typeof s != "string" || !s.startsWith(j)) return null;
|
|
367
373
|
try {
|
|
368
|
-
const e =
|
|
369
|
-
return !
|
|
374
|
+
const e = s.slice(j.length), t = JSON.parse(e);
|
|
375
|
+
return !t.id || !t.type || !t.name || !t.source ? null : t;
|
|
370
376
|
} catch {
|
|
371
377
|
return null;
|
|
372
378
|
}
|
|
373
379
|
}
|
|
374
|
-
function
|
|
380
|
+
function ce(s, e, t, n) {
|
|
375
381
|
return {
|
|
376
|
-
id:
|
|
377
|
-
type:
|
|
382
|
+
id: s,
|
|
383
|
+
type: T.REQUEST,
|
|
378
384
|
name: e,
|
|
379
|
-
data:
|
|
385
|
+
data: t,
|
|
380
386
|
source: n
|
|
381
387
|
};
|
|
382
388
|
}
|
|
383
|
-
function
|
|
389
|
+
function Le(s, e, t, n) {
|
|
384
390
|
return {
|
|
385
|
-
id:
|
|
386
|
-
type:
|
|
391
|
+
id: s,
|
|
392
|
+
type: T.RESPONSE,
|
|
387
393
|
name: "response",
|
|
388
394
|
data: e,
|
|
389
|
-
source:
|
|
395
|
+
source: t,
|
|
390
396
|
error: n ? {
|
|
391
397
|
message: n.message,
|
|
392
398
|
stack: n.stack
|
|
393
399
|
} : void 0
|
|
394
400
|
};
|
|
395
401
|
}
|
|
396
|
-
class
|
|
402
|
+
class Ee {
|
|
397
403
|
/**
|
|
398
404
|
* Creates a new Messenger instance.
|
|
399
405
|
*
|
|
@@ -402,8 +408,8 @@ class ye {
|
|
|
402
408
|
* @param domain - The origin domain of this messenger
|
|
403
409
|
* @param trustedDomains - Optional domains to trust for incoming messages
|
|
404
410
|
*/
|
|
405
|
-
constructor(e,
|
|
406
|
-
this.uid = e, this.win =
|
|
411
|
+
constructor(e, t = window, n = window.location.origin, i) {
|
|
412
|
+
this.uid = e, this.win = t, this.domain = n, this.allowedOrigins.add(n), i && this.addTrustedDomain(i), this.setupListener();
|
|
407
413
|
}
|
|
408
414
|
/** @internal */
|
|
409
415
|
pending = /* @__PURE__ */ new Map();
|
|
@@ -424,10 +430,21 @@ class ye {
|
|
|
424
430
|
*/
|
|
425
431
|
addTrustedDomain(e) {
|
|
426
432
|
if (Array.isArray(e))
|
|
427
|
-
for (const
|
|
428
|
-
this.allowedOrigins.add(
|
|
433
|
+
for (const t of e)
|
|
434
|
+
this.allowedOrigins.add(t);
|
|
429
435
|
else e instanceof RegExp ? this.allowedOriginPatterns.push(e) : this.allowedOrigins.add(e);
|
|
430
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* Removes a trusted domain from this messenger.
|
|
439
|
+
*
|
|
440
|
+
* @param domain - Domain pattern to remove (string, RegExp, or array)
|
|
441
|
+
*/
|
|
442
|
+
removeTrustedDomain(e) {
|
|
443
|
+
if (Array.isArray(e))
|
|
444
|
+
for (const t of e)
|
|
445
|
+
this.allowedOrigins.delete(t);
|
|
446
|
+
else e instanceof RegExp ? this.allowedOriginPatterns = this.allowedOriginPatterns.filter((t) => t !== e) : this.allowedOrigins.delete(e);
|
|
447
|
+
}
|
|
431
448
|
/**
|
|
432
449
|
* Checks if an origin is trusted.
|
|
433
450
|
*
|
|
@@ -438,8 +455,8 @@ class ye {
|
|
|
438
455
|
isOriginTrusted(e) {
|
|
439
456
|
if (this.allowedOrigins.has(e))
|
|
440
457
|
return !0;
|
|
441
|
-
for (const
|
|
442
|
-
if (
|
|
458
|
+
for (const t of this.allowedOriginPatterns)
|
|
459
|
+
if (t.test(e))
|
|
443
460
|
return !0;
|
|
444
461
|
return !1;
|
|
445
462
|
}
|
|
@@ -456,13 +473,13 @@ class ye {
|
|
|
456
473
|
* @returns Promise resolving to the response data
|
|
457
474
|
* @throws Error if messenger is destroyed or timeout occurs
|
|
458
475
|
*/
|
|
459
|
-
async send(e,
|
|
476
|
+
async send(e, t, n, i, r = 1e4) {
|
|
460
477
|
if (this.destroyed)
|
|
461
478
|
throw new Error("Messenger has been destroyed");
|
|
462
|
-
const o =
|
|
479
|
+
const o = z(), a = ce(o, n, i, {
|
|
463
480
|
uid: this.uid,
|
|
464
481
|
domain: this.domain
|
|
465
|
-
}), c =
|
|
482
|
+
}), c = _e(), l = setTimeout(() => {
|
|
466
483
|
this.pending.delete(o), c.reject(new Error(`Message "${n}" timed out after ${r}ms`));
|
|
467
484
|
}, r);
|
|
468
485
|
this.pending.set(o, {
|
|
@@ -470,7 +487,7 @@ class ye {
|
|
|
470
487
|
timeout: l
|
|
471
488
|
});
|
|
472
489
|
try {
|
|
473
|
-
e.postMessage(
|
|
490
|
+
e.postMessage(M(a), t);
|
|
474
491
|
} catch (h) {
|
|
475
492
|
throw this.pending.delete(o), clearTimeout(l), h;
|
|
476
493
|
}
|
|
@@ -486,14 +503,14 @@ class ye {
|
|
|
486
503
|
* @param data - Optional data payload
|
|
487
504
|
* @throws Error if messenger is destroyed
|
|
488
505
|
*/
|
|
489
|
-
post(e,
|
|
506
|
+
post(e, t, n, i) {
|
|
490
507
|
if (this.destroyed)
|
|
491
508
|
throw new Error("Messenger has been destroyed");
|
|
492
|
-
const r =
|
|
509
|
+
const r = z(), o = ce(r, n, i, {
|
|
493
510
|
uid: this.uid,
|
|
494
511
|
domain: this.domain
|
|
495
512
|
});
|
|
496
|
-
e.postMessage(
|
|
513
|
+
e.postMessage(M(o), t);
|
|
497
514
|
}
|
|
498
515
|
/**
|
|
499
516
|
* Registers a handler for incoming messages of a specific type.
|
|
@@ -504,8 +521,8 @@ class ye {
|
|
|
504
521
|
* @param handler - The handler function
|
|
505
522
|
* @returns Function to unregister the handler
|
|
506
523
|
*/
|
|
507
|
-
on(e,
|
|
508
|
-
return this.handlers.set(e,
|
|
524
|
+
on(e, t) {
|
|
525
|
+
return this.handlers.set(e, t), () => this.handlers.delete(e);
|
|
509
526
|
}
|
|
510
527
|
/**
|
|
511
528
|
* Sets up the postMessage event listener.
|
|
@@ -515,16 +532,16 @@ class ye {
|
|
|
515
532
|
this.listener = (e) => {
|
|
516
533
|
if (e.source === this.win || !this.isOriginTrusted(e.origin))
|
|
517
534
|
return;
|
|
518
|
-
const
|
|
519
|
-
|
|
535
|
+
const t = $e(e.data);
|
|
536
|
+
t && this.handleMessage(t, e.source, e.origin);
|
|
520
537
|
}, this.win.addEventListener("message", this.listener);
|
|
521
538
|
}
|
|
522
539
|
/**
|
|
523
540
|
* Processes a received message.
|
|
524
541
|
* @internal
|
|
525
542
|
*/
|
|
526
|
-
async handleMessage(e,
|
|
527
|
-
if (e.type ===
|
|
543
|
+
async handleMessage(e, t, n) {
|
|
544
|
+
if (e.type === T.RESPONSE) {
|
|
528
545
|
const i = this.pending.get(e.id);
|
|
529
546
|
if (i)
|
|
530
547
|
if (this.pending.delete(e.id), clearTimeout(i.timeout), e.error) {
|
|
@@ -534,7 +551,7 @@ class ye {
|
|
|
534
551
|
i.deferred.resolve(e.data);
|
|
535
552
|
return;
|
|
536
553
|
}
|
|
537
|
-
if (e.type ===
|
|
554
|
+
if (e.type === T.REQUEST) {
|
|
538
555
|
const i = this.handlers.get(e.name);
|
|
539
556
|
if (!i)
|
|
540
557
|
return;
|
|
@@ -544,14 +561,14 @@ class ye {
|
|
|
544
561
|
} catch (c) {
|
|
545
562
|
o = c instanceof Error ? c : new Error(String(c));
|
|
546
563
|
}
|
|
547
|
-
const a =
|
|
564
|
+
const a = Le(
|
|
548
565
|
e.id,
|
|
549
566
|
r,
|
|
550
567
|
{ uid: this.uid, domain: this.domain },
|
|
551
568
|
o
|
|
552
569
|
);
|
|
553
570
|
try {
|
|
554
|
-
|
|
571
|
+
t.postMessage(M(a), n);
|
|
555
572
|
} catch {
|
|
556
573
|
}
|
|
557
574
|
}
|
|
@@ -580,8 +597,8 @@ class ye {
|
|
|
580
597
|
return this.destroyed;
|
|
581
598
|
}
|
|
582
599
|
}
|
|
583
|
-
const
|
|
584
|
-
class
|
|
600
|
+
const le = 500;
|
|
601
|
+
class J {
|
|
585
602
|
/**
|
|
586
603
|
* Creates a new FunctionBridge instance.
|
|
587
604
|
*
|
|
@@ -607,16 +624,16 @@ class B {
|
|
|
607
624
|
* @param name - Optional name for debugging
|
|
608
625
|
* @returns A function reference that can be sent across domains
|
|
609
626
|
*/
|
|
610
|
-
serialize(e,
|
|
611
|
-
if (this.localFunctions.size >=
|
|
627
|
+
serialize(e, t) {
|
|
628
|
+
if (this.localFunctions.size >= le) {
|
|
612
629
|
const i = this.localFunctions.keys().next().value;
|
|
613
630
|
i && this.localFunctions.delete(i);
|
|
614
631
|
}
|
|
615
|
-
const n =
|
|
632
|
+
const n = z();
|
|
616
633
|
return this.localFunctions.set(n, e), this.currentBatchIds.add(n), {
|
|
617
634
|
__type__: "function",
|
|
618
635
|
__id__: n,
|
|
619
|
-
__name__:
|
|
636
|
+
__name__: t || e.name || "anonymous"
|
|
620
637
|
};
|
|
621
638
|
}
|
|
622
639
|
/**
|
|
@@ -631,14 +648,14 @@ class B {
|
|
|
631
648
|
* @param targetDomain - The origin of the target window
|
|
632
649
|
* @returns A callable wrapper function
|
|
633
650
|
*/
|
|
634
|
-
deserialize(e,
|
|
651
|
+
deserialize(e, t, n) {
|
|
635
652
|
const i = `${e.__id__}`, r = this.remoteFunctions.get(i);
|
|
636
653
|
if (r) return r;
|
|
637
|
-
if (this.remoteFunctions.size >=
|
|
654
|
+
if (this.remoteFunctions.size >= le) {
|
|
638
655
|
const a = this.remoteFunctions.keys().next().value;
|
|
639
656
|
a && this.remoteFunctions.delete(a);
|
|
640
657
|
}
|
|
641
|
-
const o = async (...a) => this.messenger.send(
|
|
658
|
+
const o = async (...a) => this.messenger.send(t, n, u.CALL, {
|
|
642
659
|
id: e.__id__,
|
|
643
660
|
args: a
|
|
644
661
|
});
|
|
@@ -663,11 +680,11 @@ class B {
|
|
|
663
680
|
setupCallHandler() {
|
|
664
681
|
this.messenger.on(
|
|
665
682
|
u.CALL,
|
|
666
|
-
async ({ id: e, args:
|
|
683
|
+
async ({ id: e, args: t }) => {
|
|
667
684
|
const n = this.localFunctions.get(e);
|
|
668
685
|
if (!n)
|
|
669
686
|
throw new Error(`Function with id "${e}" not found`);
|
|
670
|
-
return n(...
|
|
687
|
+
return n(...t);
|
|
671
688
|
}
|
|
672
689
|
);
|
|
673
690
|
}
|
|
@@ -710,8 +727,8 @@ class B {
|
|
|
710
727
|
this.currentBatchIds.clear();
|
|
711
728
|
return;
|
|
712
729
|
}
|
|
713
|
-
for (const
|
|
714
|
-
this.currentBatchIds.has(
|
|
730
|
+
for (const t of this.localFunctions.keys())
|
|
731
|
+
this.currentBatchIds.has(t) || this.localFunctions.delete(t);
|
|
715
732
|
this.currentBatchIds.clear();
|
|
716
733
|
}
|
|
717
734
|
/**
|
|
@@ -745,175 +762,175 @@ class B {
|
|
|
745
762
|
this.localFunctions.clear(), this.remoteFunctions.clear(), this.currentBatchIds.clear();
|
|
746
763
|
}
|
|
747
764
|
}
|
|
748
|
-
function
|
|
749
|
-
if (typeof
|
|
750
|
-
return e.serialize(
|
|
751
|
-
if (Array.isArray(
|
|
752
|
-
if (
|
|
765
|
+
function B(s, e, t = /* @__PURE__ */ new WeakSet()) {
|
|
766
|
+
if (typeof s == "function")
|
|
767
|
+
return e.serialize(s);
|
|
768
|
+
if (Array.isArray(s)) {
|
|
769
|
+
if (t.has(s))
|
|
753
770
|
throw new Error("Circular reference detected in props - arrays cannot contain circular references");
|
|
754
|
-
return
|
|
771
|
+
return t.add(s), s.map((n) => B(n, e, t));
|
|
755
772
|
}
|
|
756
|
-
if (typeof
|
|
757
|
-
if (
|
|
773
|
+
if (typeof s == "object" && s !== null) {
|
|
774
|
+
if (t.has(s))
|
|
758
775
|
throw new Error("Circular reference detected in props - objects cannot contain circular references");
|
|
759
|
-
|
|
776
|
+
t.add(s);
|
|
760
777
|
const n = {};
|
|
761
|
-
for (const [i, r] of Object.entries(
|
|
762
|
-
n[i] =
|
|
778
|
+
for (const [i, r] of Object.entries(s))
|
|
779
|
+
n[i] = B(r, e, t);
|
|
763
780
|
return n;
|
|
764
781
|
}
|
|
765
|
-
return
|
|
782
|
+
return s;
|
|
766
783
|
}
|
|
767
|
-
function
|
|
768
|
-
if (
|
|
769
|
-
return e.deserialize(
|
|
770
|
-
if (Array.isArray(
|
|
771
|
-
if (i.has(
|
|
784
|
+
function V(s, e, t, n, i = /* @__PURE__ */ new WeakSet()) {
|
|
785
|
+
if (J.isFunctionRef(s))
|
|
786
|
+
return e.deserialize(s, t, n);
|
|
787
|
+
if (Array.isArray(s)) {
|
|
788
|
+
if (i.has(s))
|
|
772
789
|
throw new Error("Circular reference detected in serialized props");
|
|
773
|
-
return i.add(
|
|
774
|
-
(r) =>
|
|
790
|
+
return i.add(s), s.map(
|
|
791
|
+
(r) => V(r, e, t, n, i)
|
|
775
792
|
);
|
|
776
793
|
}
|
|
777
|
-
if (typeof
|
|
778
|
-
if (i.has(
|
|
794
|
+
if (typeof s == "object" && s !== null) {
|
|
795
|
+
if (i.has(s))
|
|
779
796
|
throw new Error("Circular reference detected in serialized props");
|
|
780
|
-
i.add(
|
|
797
|
+
i.add(s);
|
|
781
798
|
const r = {};
|
|
782
|
-
for (const [o, a] of Object.entries(
|
|
783
|
-
r[o] =
|
|
799
|
+
for (const [o, a] of Object.entries(s))
|
|
800
|
+
r[o] = V(a, e, t, n, i);
|
|
784
801
|
return r;
|
|
785
802
|
}
|
|
786
|
-
return
|
|
803
|
+
return s;
|
|
787
804
|
}
|
|
788
|
-
function
|
|
805
|
+
function q(s = window) {
|
|
789
806
|
try {
|
|
790
|
-
return
|
|
807
|
+
return s.location.origin;
|
|
791
808
|
} catch {
|
|
792
809
|
return "";
|
|
793
810
|
}
|
|
794
811
|
}
|
|
795
|
-
function
|
|
812
|
+
function be(s, e = window) {
|
|
796
813
|
try {
|
|
797
|
-
return
|
|
814
|
+
return s.location.origin === e.location.origin;
|
|
798
815
|
} catch {
|
|
799
816
|
return !1;
|
|
800
817
|
}
|
|
801
818
|
}
|
|
802
|
-
function
|
|
803
|
-
return typeof
|
|
819
|
+
function L(s, e) {
|
|
820
|
+
return typeof s == "string" ? s === "*" ? !0 : s === e : s instanceof RegExp ? s.test(e) : Array.isArray(s) ? s.some((t) => L(t, e)) : !1;
|
|
804
821
|
}
|
|
805
|
-
function
|
|
806
|
-
if (!
|
|
822
|
+
function Pe(s) {
|
|
823
|
+
if (!s) return !0;
|
|
807
824
|
try {
|
|
808
|
-
return
|
|
825
|
+
return s.closed;
|
|
809
826
|
} catch {
|
|
810
827
|
return !0;
|
|
811
828
|
}
|
|
812
829
|
}
|
|
813
|
-
function
|
|
830
|
+
function He(s = window) {
|
|
814
831
|
try {
|
|
815
|
-
return
|
|
832
|
+
return s.opener;
|
|
816
833
|
} catch {
|
|
817
834
|
return null;
|
|
818
835
|
}
|
|
819
836
|
}
|
|
820
|
-
function
|
|
837
|
+
function Ae(s = window) {
|
|
821
838
|
try {
|
|
822
|
-
const e =
|
|
823
|
-
return e && e !==
|
|
839
|
+
const e = s.parent;
|
|
840
|
+
return e && e !== s ? e : null;
|
|
824
841
|
} catch {
|
|
825
842
|
return null;
|
|
826
843
|
}
|
|
827
844
|
}
|
|
828
|
-
function
|
|
845
|
+
function Ue(s = window) {
|
|
829
846
|
try {
|
|
830
|
-
return
|
|
847
|
+
return s.parent !== s;
|
|
831
848
|
} catch {
|
|
832
849
|
return !0;
|
|
833
850
|
}
|
|
834
851
|
}
|
|
835
|
-
function
|
|
852
|
+
function Me(s = window) {
|
|
836
853
|
try {
|
|
837
|
-
return
|
|
854
|
+
return s.opener !== null && s.opener !== void 0;
|
|
838
855
|
} catch {
|
|
839
856
|
return !1;
|
|
840
857
|
}
|
|
841
858
|
}
|
|
842
|
-
const
|
|
843
|
-
function
|
|
844
|
-
const e =
|
|
845
|
-
return `${
|
|
859
|
+
const ue = 32 * 1024;
|
|
860
|
+
function We(s) {
|
|
861
|
+
const e = ze(s);
|
|
862
|
+
return `${F}${e}`;
|
|
846
863
|
}
|
|
847
|
-
function
|
|
848
|
-
if (!
|
|
864
|
+
function Oe(s) {
|
|
865
|
+
if (!s || !s.startsWith(F))
|
|
849
866
|
return null;
|
|
850
|
-
const e =
|
|
851
|
-
return
|
|
867
|
+
const e = s.slice(F.length);
|
|
868
|
+
return je(e);
|
|
852
869
|
}
|
|
853
|
-
function
|
|
870
|
+
function X(s = window) {
|
|
854
871
|
try {
|
|
855
|
-
return
|
|
872
|
+
return s.name.startsWith(F);
|
|
856
873
|
} catch {
|
|
857
874
|
return !1;
|
|
858
875
|
}
|
|
859
876
|
}
|
|
860
|
-
function
|
|
861
|
-
return
|
|
877
|
+
function W(s, e = window) {
|
|
878
|
+
return Oe(e.name)?.tag === s;
|
|
862
879
|
}
|
|
863
|
-
function
|
|
880
|
+
function ze(s) {
|
|
864
881
|
try {
|
|
865
|
-
const e = JSON.stringify(
|
|
866
|
-
if (n >
|
|
882
|
+
const e = JSON.stringify(s), t = btoa(encodeURIComponent(e)), n = new Blob([t]).size;
|
|
883
|
+
if (n > ue)
|
|
867
884
|
throw new Error(
|
|
868
|
-
`Payload size (${Math.round(n / 1024)}KB) exceeds maximum allowed size (${
|
|
885
|
+
`Payload size (${Math.round(n / 1024)}KB) exceeds maximum allowed size (${ue / 1024}KB). Consider reducing the amount of data passed via props.`
|
|
869
886
|
);
|
|
870
|
-
return
|
|
887
|
+
return t;
|
|
871
888
|
} catch (e) {
|
|
872
889
|
throw e instanceof Error && e.message.includes("Payload size") ? e : new Error(`Failed to encode payload: ${e}`);
|
|
873
890
|
}
|
|
874
891
|
}
|
|
875
|
-
function
|
|
892
|
+
function je(s) {
|
|
876
893
|
try {
|
|
877
|
-
const e = decodeURIComponent(atob(
|
|
894
|
+
const e = decodeURIComponent(atob(s));
|
|
878
895
|
return JSON.parse(e);
|
|
879
896
|
} catch {
|
|
880
897
|
return null;
|
|
881
898
|
}
|
|
882
899
|
}
|
|
883
|
-
function
|
|
900
|
+
function Be(s) {
|
|
884
901
|
return {
|
|
885
|
-
uid:
|
|
886
|
-
tag:
|
|
887
|
-
version:
|
|
888
|
-
context:
|
|
889
|
-
consumerDomain:
|
|
890
|
-
props:
|
|
891
|
-
exports:
|
|
892
|
-
children:
|
|
902
|
+
uid: s.uid,
|
|
903
|
+
tag: s.tag,
|
|
904
|
+
version: ye,
|
|
905
|
+
context: s.context,
|
|
906
|
+
consumerDomain: s.consumerDomain,
|
|
907
|
+
props: s.props,
|
|
908
|
+
exports: s.exports,
|
|
909
|
+
children: s.children
|
|
893
910
|
};
|
|
894
911
|
}
|
|
895
|
-
function
|
|
896
|
-
return
|
|
912
|
+
function Ve(s = window) {
|
|
913
|
+
return Oe(s.name);
|
|
897
914
|
}
|
|
898
|
-
const
|
|
899
|
-
function
|
|
900
|
-
const
|
|
901
|
-
for (const [e,
|
|
902
|
-
|
|
903
|
-
for (const e of
|
|
904
|
-
|
|
915
|
+
const he = 100, E = /* @__PURE__ */ new Map();
|
|
916
|
+
function qe() {
|
|
917
|
+
const s = [];
|
|
918
|
+
for (const [e, t] of E.entries())
|
|
919
|
+
Pe(t) && s.push(e);
|
|
920
|
+
for (const e of s)
|
|
921
|
+
E.delete(e);
|
|
905
922
|
}
|
|
906
|
-
function
|
|
907
|
-
if (
|
|
908
|
-
const
|
|
909
|
-
|
|
923
|
+
function Je(s, e) {
|
|
924
|
+
if (E.size >= he && qe(), E.size >= he) {
|
|
925
|
+
const t = E.keys().next().value;
|
|
926
|
+
t && E.delete(t);
|
|
910
927
|
}
|
|
911
|
-
|
|
928
|
+
E.set(s, e);
|
|
912
929
|
}
|
|
913
|
-
function
|
|
914
|
-
|
|
930
|
+
function Xe(s) {
|
|
931
|
+
E.delete(s);
|
|
915
932
|
}
|
|
916
|
-
class
|
|
933
|
+
class y {
|
|
917
934
|
/** @internal */
|
|
918
935
|
_optional = !1;
|
|
919
936
|
/** @internal */
|
|
@@ -976,11 +993,11 @@ class m {
|
|
|
976
993
|
* ```
|
|
977
994
|
*/
|
|
978
995
|
default(e) {
|
|
979
|
-
const
|
|
980
|
-
return
|
|
996
|
+
const t = this._clone();
|
|
997
|
+
return t._default = e, t;
|
|
981
998
|
}
|
|
982
999
|
}
|
|
983
|
-
class
|
|
1000
|
+
class K extends y {
|
|
984
1001
|
/** @internal */
|
|
985
1002
|
_minLength;
|
|
986
1003
|
/** @internal */
|
|
@@ -997,26 +1014,26 @@ class V extends m {
|
|
|
997
1014
|
return {
|
|
998
1015
|
issues: [{ message: `Expected string, got ${typeof e}` }]
|
|
999
1016
|
};
|
|
1000
|
-
const
|
|
1001
|
-
return this._minLength !== void 0 &&
|
|
1017
|
+
const t = this._trim ? e.trim() : e;
|
|
1018
|
+
return this._minLength !== void 0 && t.length < this._minLength ? {
|
|
1002
1019
|
issues: [
|
|
1003
1020
|
{ message: `String must be at least ${this._minLength} characters` }
|
|
1004
1021
|
]
|
|
1005
|
-
} : this._maxLength !== void 0 &&
|
|
1022
|
+
} : this._maxLength !== void 0 && t.length > this._maxLength ? {
|
|
1006
1023
|
issues: [
|
|
1007
1024
|
{ message: `String must be at most ${this._maxLength} characters` }
|
|
1008
1025
|
]
|
|
1009
|
-
} : this._pattern && !this._pattern.test(
|
|
1026
|
+
} : this._pattern && !this._pattern.test(t) ? {
|
|
1010
1027
|
issues: [
|
|
1011
1028
|
{
|
|
1012
1029
|
message: this._patternMessage || `String must match pattern ${this._pattern}`
|
|
1013
1030
|
}
|
|
1014
1031
|
]
|
|
1015
|
-
} : { value:
|
|
1032
|
+
} : { value: t };
|
|
1016
1033
|
}
|
|
1017
1034
|
/** @internal */
|
|
1018
1035
|
_clone() {
|
|
1019
|
-
const e = new
|
|
1036
|
+
const e = new K();
|
|
1020
1037
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._minLength = this._minLength, e._maxLength = this._maxLength, e._pattern = this._pattern, e._patternMessage = this._patternMessage, e._trim = this._trim, e;
|
|
1021
1038
|
}
|
|
1022
1039
|
/**
|
|
@@ -1030,8 +1047,8 @@ class V extends m {
|
|
|
1030
1047
|
* ```
|
|
1031
1048
|
*/
|
|
1032
1049
|
min(e) {
|
|
1033
|
-
const
|
|
1034
|
-
return
|
|
1050
|
+
const t = this._clone();
|
|
1051
|
+
return t._minLength = e, t;
|
|
1035
1052
|
}
|
|
1036
1053
|
/**
|
|
1037
1054
|
* Requires maximum string length.
|
|
@@ -1044,8 +1061,8 @@ class V extends m {
|
|
|
1044
1061
|
* ```
|
|
1045
1062
|
*/
|
|
1046
1063
|
max(e) {
|
|
1047
|
-
const
|
|
1048
|
-
return
|
|
1064
|
+
const t = this._clone();
|
|
1065
|
+
return t._maxLength = e, t;
|
|
1049
1066
|
}
|
|
1050
1067
|
/**
|
|
1051
1068
|
* Requires exact string length.
|
|
@@ -1058,8 +1075,8 @@ class V extends m {
|
|
|
1058
1075
|
* ```
|
|
1059
1076
|
*/
|
|
1060
1077
|
length(e) {
|
|
1061
|
-
const
|
|
1062
|
-
return
|
|
1078
|
+
const t = this._clone();
|
|
1079
|
+
return t._minLength = e, t._maxLength = e, t;
|
|
1063
1080
|
}
|
|
1064
1081
|
/**
|
|
1065
1082
|
* Requires string to match a regex pattern.
|
|
@@ -1072,9 +1089,9 @@ class V extends m {
|
|
|
1072
1089
|
* slug: prop.string().pattern(/^[a-z0-9-]+$/, 'Invalid slug format')
|
|
1073
1090
|
* ```
|
|
1074
1091
|
*/
|
|
1075
|
-
pattern(e,
|
|
1092
|
+
pattern(e, t) {
|
|
1076
1093
|
const n = this._clone();
|
|
1077
|
-
return n._pattern = e, n._patternMessage =
|
|
1094
|
+
return n._pattern = e, n._patternMessage = t, n;
|
|
1078
1095
|
}
|
|
1079
1096
|
/**
|
|
1080
1097
|
* Validates as email address.
|
|
@@ -1141,7 +1158,7 @@ class V extends m {
|
|
|
1141
1158
|
return e._minLength = 1, e;
|
|
1142
1159
|
}
|
|
1143
1160
|
}
|
|
1144
|
-
class
|
|
1161
|
+
class G extends y {
|
|
1145
1162
|
/** @internal */
|
|
1146
1163
|
_min;
|
|
1147
1164
|
/** @internal */
|
|
@@ -1156,7 +1173,7 @@ class q extends m {
|
|
|
1156
1173
|
}
|
|
1157
1174
|
/** @internal */
|
|
1158
1175
|
_clone() {
|
|
1159
|
-
const e = new
|
|
1176
|
+
const e = new G();
|
|
1160
1177
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._min = this._min, e._max = this._max, e._int = this._int, e;
|
|
1161
1178
|
}
|
|
1162
1179
|
/**
|
|
@@ -1170,8 +1187,8 @@ class q extends m {
|
|
|
1170
1187
|
* ```
|
|
1171
1188
|
*/
|
|
1172
1189
|
min(e) {
|
|
1173
|
-
const
|
|
1174
|
-
return
|
|
1190
|
+
const t = this._clone();
|
|
1191
|
+
return t._min = e, t;
|
|
1175
1192
|
}
|
|
1176
1193
|
/**
|
|
1177
1194
|
* Requires maximum value.
|
|
@@ -1184,8 +1201,8 @@ class q extends m {
|
|
|
1184
1201
|
* ```
|
|
1185
1202
|
*/
|
|
1186
1203
|
max(e) {
|
|
1187
|
-
const
|
|
1188
|
-
return
|
|
1204
|
+
const t = this._clone();
|
|
1205
|
+
return t._max = e, t;
|
|
1189
1206
|
}
|
|
1190
1207
|
/**
|
|
1191
1208
|
* Requires integer value.
|
|
@@ -1236,7 +1253,7 @@ class q extends m {
|
|
|
1236
1253
|
return e._max = -Number.MIN_VALUE, e;
|
|
1237
1254
|
}
|
|
1238
1255
|
}
|
|
1239
|
-
class
|
|
1256
|
+
class Y extends y {
|
|
1240
1257
|
/** @internal */
|
|
1241
1258
|
_validate(e) {
|
|
1242
1259
|
return typeof e != "boolean" ? {
|
|
@@ -1245,11 +1262,11 @@ class X extends m {
|
|
|
1245
1262
|
}
|
|
1246
1263
|
/** @internal */
|
|
1247
1264
|
_clone() {
|
|
1248
|
-
const e = new
|
|
1265
|
+
const e = new Y();
|
|
1249
1266
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
|
|
1250
1267
|
}
|
|
1251
1268
|
}
|
|
1252
|
-
class
|
|
1269
|
+
class Z extends y {
|
|
1253
1270
|
/** @internal */
|
|
1254
1271
|
_validate(e) {
|
|
1255
1272
|
return typeof e != "function" ? {
|
|
@@ -1258,11 +1275,11 @@ class Y extends m {
|
|
|
1258
1275
|
}
|
|
1259
1276
|
/** @internal */
|
|
1260
1277
|
_clone() {
|
|
1261
|
-
const e = new
|
|
1278
|
+
const e = new Z();
|
|
1262
1279
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
|
|
1263
1280
|
}
|
|
1264
1281
|
}
|
|
1265
|
-
class
|
|
1282
|
+
class N extends y {
|
|
1266
1283
|
/** @internal */
|
|
1267
1284
|
_itemSchema;
|
|
1268
1285
|
/** @internal */
|
|
@@ -1288,7 +1305,7 @@ class T extends m {
|
|
|
1288
1305
|
]
|
|
1289
1306
|
};
|
|
1290
1307
|
if (this._itemSchema) {
|
|
1291
|
-
const
|
|
1308
|
+
const t = [];
|
|
1292
1309
|
for (let n = 0; n < e.length; n++) {
|
|
1293
1310
|
const i = this._itemSchema["~standard"].validate(e[n]);
|
|
1294
1311
|
if (i instanceof Promise)
|
|
@@ -1302,15 +1319,15 @@ class T extends m {
|
|
|
1302
1319
|
path: [n, ...r.path || []]
|
|
1303
1320
|
}))
|
|
1304
1321
|
};
|
|
1305
|
-
|
|
1322
|
+
t.push(i.value);
|
|
1306
1323
|
}
|
|
1307
|
-
return { value:
|
|
1324
|
+
return { value: t };
|
|
1308
1325
|
}
|
|
1309
1326
|
return { value: e };
|
|
1310
1327
|
}
|
|
1311
1328
|
/** @internal */
|
|
1312
1329
|
_clone() {
|
|
1313
|
-
const e = new
|
|
1330
|
+
const e = new N();
|
|
1314
1331
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._itemSchema = this._itemSchema, e._minLength = this._minLength, e._maxLength = this._maxLength, e;
|
|
1315
1332
|
}
|
|
1316
1333
|
/**
|
|
@@ -1326,8 +1343,8 @@ class T extends m {
|
|
|
1326
1343
|
* ```
|
|
1327
1344
|
*/
|
|
1328
1345
|
of(e) {
|
|
1329
|
-
const
|
|
1330
|
-
return
|
|
1346
|
+
const t = new N();
|
|
1347
|
+
return t._optional = this._optional, t._nullable = this._nullable, t._itemSchema = e, t._minLength = this._minLength, t._maxLength = this._maxLength, t;
|
|
1331
1348
|
}
|
|
1332
1349
|
/**
|
|
1333
1350
|
* Requires minimum array length.
|
|
@@ -1340,8 +1357,8 @@ class T extends m {
|
|
|
1340
1357
|
* ```
|
|
1341
1358
|
*/
|
|
1342
1359
|
min(e) {
|
|
1343
|
-
const
|
|
1344
|
-
return
|
|
1360
|
+
const t = this._clone();
|
|
1361
|
+
return t._minLength = e, t;
|
|
1345
1362
|
}
|
|
1346
1363
|
/**
|
|
1347
1364
|
* Requires maximum array length.
|
|
@@ -1354,8 +1371,8 @@ class T extends m {
|
|
|
1354
1371
|
* ```
|
|
1355
1372
|
*/
|
|
1356
1373
|
max(e) {
|
|
1357
|
-
const
|
|
1358
|
-
return
|
|
1374
|
+
const t = this._clone();
|
|
1375
|
+
return t._maxLength = e, t;
|
|
1359
1376
|
}
|
|
1360
1377
|
/**
|
|
1361
1378
|
* Requires non-empty array.
|
|
@@ -1369,7 +1386,7 @@ class T extends m {
|
|
|
1369
1386
|
return this.min(1);
|
|
1370
1387
|
}
|
|
1371
1388
|
}
|
|
1372
|
-
class k extends
|
|
1389
|
+
class k extends y {
|
|
1373
1390
|
/** @internal */
|
|
1374
1391
|
_shape;
|
|
1375
1392
|
/** @internal */
|
|
@@ -1384,18 +1401,18 @@ class k extends m {
|
|
|
1384
1401
|
}
|
|
1385
1402
|
]
|
|
1386
1403
|
};
|
|
1387
|
-
const
|
|
1404
|
+
const t = e, n = {};
|
|
1388
1405
|
if (this._shape) {
|
|
1389
1406
|
if (this._strict) {
|
|
1390
1407
|
const i = new Set(Object.keys(this._shape));
|
|
1391
|
-
for (const r of Object.keys(
|
|
1408
|
+
for (const r of Object.keys(t))
|
|
1392
1409
|
if (!i.has(r))
|
|
1393
1410
|
return {
|
|
1394
1411
|
issues: [{ message: `Unknown key: ${r}`, path: [r] }]
|
|
1395
1412
|
};
|
|
1396
1413
|
}
|
|
1397
1414
|
for (const [i, r] of Object.entries(this._shape)) {
|
|
1398
|
-
const o = r["~standard"].validate(
|
|
1415
|
+
const o = r["~standard"].validate(t[i]);
|
|
1399
1416
|
if (o instanceof Promise)
|
|
1400
1417
|
throw new Error(
|
|
1401
1418
|
"Async schema validation is not supported. Use synchronous schemas."
|
|
@@ -1410,8 +1427,8 @@ class k extends m {
|
|
|
1410
1427
|
n[i] = o.value;
|
|
1411
1428
|
}
|
|
1412
1429
|
if (!this._strict)
|
|
1413
|
-
for (const i of Object.keys(
|
|
1414
|
-
i in this._shape || (n[i] =
|
|
1430
|
+
for (const i of Object.keys(t))
|
|
1431
|
+
i in this._shape || (n[i] = t[i]);
|
|
1415
1432
|
return { value: n };
|
|
1416
1433
|
}
|
|
1417
1434
|
return { value: e };
|
|
@@ -1436,8 +1453,8 @@ class k extends m {
|
|
|
1436
1453
|
* ```
|
|
1437
1454
|
*/
|
|
1438
1455
|
shape(e) {
|
|
1439
|
-
const
|
|
1440
|
-
return
|
|
1456
|
+
const t = new k();
|
|
1457
|
+
return t._optional = this._optional, t._nullable = this._nullable, t._shape = e, t._strict = this._strict, t;
|
|
1441
1458
|
}
|
|
1442
1459
|
/**
|
|
1443
1460
|
* Rejects objects with unknown keys.
|
|
@@ -1452,7 +1469,7 @@ class k extends m {
|
|
|
1452
1469
|
return e._strict = !0, e;
|
|
1453
1470
|
}
|
|
1454
1471
|
}
|
|
1455
|
-
class
|
|
1472
|
+
class Q extends y {
|
|
1456
1473
|
/** @internal */
|
|
1457
1474
|
_value;
|
|
1458
1475
|
constructor(e) {
|
|
@@ -1466,11 +1483,11 @@ class Z extends m {
|
|
|
1466
1483
|
}
|
|
1467
1484
|
/** @internal */
|
|
1468
1485
|
_clone() {
|
|
1469
|
-
const e = new
|
|
1486
|
+
const e = new Q(this._value);
|
|
1470
1487
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
|
|
1471
1488
|
}
|
|
1472
1489
|
}
|
|
1473
|
-
class
|
|
1490
|
+
class ee extends y {
|
|
1474
1491
|
/** @internal */
|
|
1475
1492
|
_values;
|
|
1476
1493
|
constructor(e) {
|
|
@@ -1481,18 +1498,18 @@ class G extends m {
|
|
|
1481
1498
|
return this._values.includes(e) ? { value: e } : {
|
|
1482
1499
|
issues: [
|
|
1483
1500
|
{
|
|
1484
|
-
message: `Expected one of [${this._values.map((
|
|
1501
|
+
message: `Expected one of [${this._values.map((t) => JSON.stringify(t)).join(", ")}], got ${JSON.stringify(e)}`
|
|
1485
1502
|
}
|
|
1486
1503
|
]
|
|
1487
1504
|
};
|
|
1488
1505
|
}
|
|
1489
1506
|
/** @internal */
|
|
1490
1507
|
_clone() {
|
|
1491
|
-
const e = new
|
|
1508
|
+
const e = new ee(this._values);
|
|
1492
1509
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
|
|
1493
1510
|
}
|
|
1494
1511
|
}
|
|
1495
|
-
class
|
|
1512
|
+
class te extends y {
|
|
1496
1513
|
constructor() {
|
|
1497
1514
|
super(), this._nullable = !0;
|
|
1498
1515
|
}
|
|
@@ -1502,7 +1519,7 @@ class K extends m {
|
|
|
1502
1519
|
}
|
|
1503
1520
|
/** @internal */
|
|
1504
1521
|
_clone() {
|
|
1505
|
-
const e = new
|
|
1522
|
+
const e = new te();
|
|
1506
1523
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
|
|
1507
1524
|
}
|
|
1508
1525
|
}
|
|
@@ -1519,7 +1536,7 @@ const d = {
|
|
|
1519
1536
|
* prop.string().pattern(/^[a-z]+$/)
|
|
1520
1537
|
* ```
|
|
1521
1538
|
*/
|
|
1522
|
-
string: () => new
|
|
1539
|
+
string: () => new K(),
|
|
1523
1540
|
/**
|
|
1524
1541
|
* Creates a number schema.
|
|
1525
1542
|
*
|
|
@@ -1531,7 +1548,7 @@ const d = {
|
|
|
1531
1548
|
* prop.number().positive()
|
|
1532
1549
|
* ```
|
|
1533
1550
|
*/
|
|
1534
|
-
number: () => new
|
|
1551
|
+
number: () => new G(),
|
|
1535
1552
|
/**
|
|
1536
1553
|
* Creates a boolean schema.
|
|
1537
1554
|
*
|
|
@@ -1541,7 +1558,7 @@ const d = {
|
|
|
1541
1558
|
* prop.boolean().default(false)
|
|
1542
1559
|
* ```
|
|
1543
1560
|
*/
|
|
1544
|
-
boolean: () => new
|
|
1561
|
+
boolean: () => new Y(),
|
|
1545
1562
|
/**
|
|
1546
1563
|
* Creates a function schema.
|
|
1547
1564
|
*
|
|
@@ -1554,7 +1571,7 @@ const d = {
|
|
|
1554
1571
|
* prop.function<(data: { id: string }) => Promise<void>>()
|
|
1555
1572
|
* ```
|
|
1556
1573
|
*/
|
|
1557
|
-
function: () => new
|
|
1574
|
+
function: () => new Z(),
|
|
1558
1575
|
/**
|
|
1559
1576
|
* Creates an array schema.
|
|
1560
1577
|
*
|
|
@@ -1567,7 +1584,7 @@ const d = {
|
|
|
1567
1584
|
* prop.array().of(prop.number()).min(1).max(10)
|
|
1568
1585
|
* ```
|
|
1569
1586
|
*/
|
|
1570
|
-
array: () => new
|
|
1587
|
+
array: () => new N(),
|
|
1571
1588
|
/**
|
|
1572
1589
|
* Creates an object schema.
|
|
1573
1590
|
*
|
|
@@ -1596,7 +1613,7 @@ const d = {
|
|
|
1596
1613
|
* prop.literal(true)
|
|
1597
1614
|
* ```
|
|
1598
1615
|
*/
|
|
1599
|
-
literal: (
|
|
1616
|
+
literal: (s) => new Q(s),
|
|
1600
1617
|
/**
|
|
1601
1618
|
* Creates an enum schema for a set of allowed values.
|
|
1602
1619
|
*
|
|
@@ -1608,7 +1625,7 @@ const d = {
|
|
|
1608
1625
|
* prop.enum([1, 2, 3])
|
|
1609
1626
|
* ```
|
|
1610
1627
|
*/
|
|
1611
|
-
enum: (
|
|
1628
|
+
enum: (s) => new ee(s),
|
|
1612
1629
|
/**
|
|
1613
1630
|
* Creates a schema that accepts any value.
|
|
1614
1631
|
*
|
|
@@ -1620,8 +1637,8 @@ const d = {
|
|
|
1620
1637
|
* prop.any()
|
|
1621
1638
|
* ```
|
|
1622
1639
|
*/
|
|
1623
|
-
any: () => new
|
|
1624
|
-
},
|
|
1640
|
+
any: () => new te()
|
|
1641
|
+
}, P = {
|
|
1625
1642
|
uid: {
|
|
1626
1643
|
schema: d.string().optional(),
|
|
1627
1644
|
sendToHost: !0
|
|
@@ -1688,118 +1705,140 @@ const d = {
|
|
|
1688
1705
|
sendToHost: !1
|
|
1689
1706
|
}
|
|
1690
1707
|
};
|
|
1691
|
-
function
|
|
1692
|
-
return typeof
|
|
1708
|
+
function b(s) {
|
|
1709
|
+
return typeof s == "object" && s !== null && "~standard" in s && typeof s["~standard"] == "object" && s["~standard"] !== null && s["~standard"].version === 1 && typeof s["~standard"].vendor == "string" && typeof s["~standard"].validate == "function";
|
|
1693
1710
|
}
|
|
1694
|
-
function
|
|
1695
|
-
const n =
|
|
1711
|
+
function Ke(s, e, t) {
|
|
1712
|
+
const n = s["~standard"].validate(e);
|
|
1696
1713
|
if (n instanceof Promise)
|
|
1697
1714
|
throw new Error(
|
|
1698
|
-
`Prop "${
|
|
1715
|
+
`Prop "${t}" uses an async schema. ForgeFrame only supports synchronous schema validation. Please use a synchronous schema or remove async operations (like database lookups) from your schema definition.`
|
|
1699
1716
|
);
|
|
1700
1717
|
if (n.issues) {
|
|
1701
|
-
const i = n.issues.map((r) => `${
|
|
1718
|
+
const i = n.issues.map((r) => `${Ge(r.path, t)}: ${r.message}`);
|
|
1702
1719
|
throw new Error(`Validation failed: ${i.join("; ")}`);
|
|
1703
1720
|
}
|
|
1704
1721
|
return n.value;
|
|
1705
1722
|
}
|
|
1706
|
-
function
|
|
1707
|
-
if (!
|
|
1723
|
+
function Ge(s, e) {
|
|
1724
|
+
if (!s || s.length === 0)
|
|
1708
1725
|
return e;
|
|
1709
|
-
const
|
|
1710
|
-
|
|
1726
|
+
const t = s.map((n) => {
|
|
1727
|
+
if (typeof n == "object" && n !== null) {
|
|
1728
|
+
if ("key" in n && n.key !== void 0)
|
|
1729
|
+
return String(n.key);
|
|
1730
|
+
if ("index" in n && typeof n.index == "number")
|
|
1731
|
+
return String(n.index);
|
|
1732
|
+
}
|
|
1733
|
+
return String(n);
|
|
1734
|
+
});
|
|
1735
|
+
return `${e}.${t.join(".")}`;
|
|
1711
1736
|
}
|
|
1712
|
-
function
|
|
1737
|
+
function de(s, e, t) {
|
|
1713
1738
|
const n = {
|
|
1714
|
-
...
|
|
1739
|
+
...P,
|
|
1715
1740
|
...e
|
|
1716
1741
|
}, i = {};
|
|
1717
1742
|
for (const [r, o] of Object.entries(n)) {
|
|
1718
|
-
const c =
|
|
1743
|
+
const c = b(o) ? { schema: o } : o;
|
|
1719
1744
|
let l;
|
|
1720
|
-
const h = c.alias,
|
|
1721
|
-
if (
|
|
1722
|
-
l =
|
|
1723
|
-
else if (
|
|
1724
|
-
l =
|
|
1745
|
+
const h = c.alias, w = r in s, _ = h && h in s;
|
|
1746
|
+
if (w)
|
|
1747
|
+
l = s[r];
|
|
1748
|
+
else if (_)
|
|
1749
|
+
l = s[h];
|
|
1725
1750
|
else if (c.value)
|
|
1726
|
-
l = c.value(
|
|
1751
|
+
l = c.value(t);
|
|
1727
1752
|
else if (c.default !== void 0)
|
|
1728
|
-
l = typeof c.default == "function" ? c.default(
|
|
1729
|
-
else if (c.schema &&
|
|
1730
|
-
const
|
|
1731
|
-
!(
|
|
1753
|
+
l = typeof c.default == "function" ? c.default(t) : c.default;
|
|
1754
|
+
else if (c.schema && b(c.schema)) {
|
|
1755
|
+
const O = c.schema["~standard"].validate(void 0);
|
|
1756
|
+
!(O instanceof Promise) && !O.issues && (l = O.value);
|
|
1732
1757
|
}
|
|
1733
1758
|
l !== void 0 && c.decorate && (l = c.decorate({ value: l, props: i })), i[r] = l;
|
|
1734
1759
|
}
|
|
1735
1760
|
return i;
|
|
1736
1761
|
}
|
|
1737
|
-
function
|
|
1738
|
-
const
|
|
1739
|
-
...
|
|
1762
|
+
function Ye(s, e) {
|
|
1763
|
+
const t = {
|
|
1764
|
+
...P,
|
|
1740
1765
|
...e
|
|
1741
1766
|
};
|
|
1742
|
-
for (const [n, i] of Object.entries(
|
|
1743
|
-
const r =
|
|
1744
|
-
let a =
|
|
1767
|
+
for (const [n, i] of Object.entries(t)) {
|
|
1768
|
+
const r = b(i), o = r ? { schema: i } : i;
|
|
1769
|
+
let a = s[n];
|
|
1745
1770
|
if (o.required && a === void 0)
|
|
1746
1771
|
throw new Error(`Prop "${n}" is required but was not provided`);
|
|
1747
|
-
if (o.schema &&
|
|
1748
|
-
(a !== void 0 || r) && (a =
|
|
1772
|
+
if (o.schema && b(o.schema))
|
|
1773
|
+
(a !== void 0 || r) && (a = Ke(o.schema, a, n), s[n] = a);
|
|
1749
1774
|
else if (a === void 0)
|
|
1750
1775
|
continue;
|
|
1751
|
-
o.validate && o.validate({ value: a, props:
|
|
1776
|
+
o.validate && o.validate({ value: a, props: s });
|
|
1752
1777
|
}
|
|
1753
1778
|
}
|
|
1754
|
-
function
|
|
1779
|
+
function fe(s, e, t, n) {
|
|
1755
1780
|
const i = {
|
|
1756
|
-
...
|
|
1781
|
+
...P,
|
|
1757
1782
|
...e
|
|
1758
1783
|
}, r = {};
|
|
1759
1784
|
for (const [o, a] of Object.entries(i)) {
|
|
1760
|
-
const l =
|
|
1785
|
+
const l = b(a) ? { schema: a } : a, h = s[o];
|
|
1761
1786
|
if (l.sendToHost === !1 || l.sameDomain && !n) continue;
|
|
1762
1787
|
if (l.trustedDomains) {
|
|
1763
|
-
const
|
|
1764
|
-
if (!
|
|
1788
|
+
const _ = l.trustedDomains;
|
|
1789
|
+
if (!L(_, t)) continue;
|
|
1765
1790
|
}
|
|
1766
|
-
let
|
|
1767
|
-
l.hostDecorate && h !== void 0 && (
|
|
1791
|
+
let w = h;
|
|
1792
|
+
l.hostDecorate && h !== void 0 && (w = l.hostDecorate({ value: h, props: s })), r[o] = w;
|
|
1768
1793
|
}
|
|
1769
1794
|
return r;
|
|
1770
1795
|
}
|
|
1771
|
-
function
|
|
1772
|
-
const
|
|
1773
|
-
...
|
|
1796
|
+
function Ze(s, e) {
|
|
1797
|
+
const t = new URLSearchParams(), n = {
|
|
1798
|
+
...P,
|
|
1774
1799
|
...e
|
|
1775
1800
|
};
|
|
1776
1801
|
for (const [i, r] of Object.entries(n)) {
|
|
1777
|
-
const a =
|
|
1802
|
+
const a = b(r) ? { schema: r } : r, c = s[i];
|
|
1778
1803
|
if (c === void 0 || typeof c == "function" || !a.queryParam) continue;
|
|
1779
1804
|
const l = typeof a.queryParam == "string" ? a.queryParam : i;
|
|
1780
1805
|
let h;
|
|
1781
|
-
typeof a.queryParam == "function" ? h = a.queryParam({ value: c }) : typeof c == "object" ? h = JSON.stringify(c) : h = String(c),
|
|
1806
|
+
typeof a.queryParam == "function" ? h = a.queryParam({ value: c }) : typeof c == "object" ? h = JSON.stringify(c) : h = String(c), t.set(l, h);
|
|
1782
1807
|
}
|
|
1783
|
-
return
|
|
1808
|
+
return t;
|
|
1784
1809
|
}
|
|
1785
|
-
function
|
|
1786
|
-
const
|
|
1787
|
-
|
|
1810
|
+
function Qe(s, e) {
|
|
1811
|
+
const t = new URLSearchParams(), n = {
|
|
1812
|
+
...P,
|
|
1813
|
+
...e
|
|
1814
|
+
};
|
|
1815
|
+
for (const [i, r] of Object.entries(n)) {
|
|
1816
|
+
const a = b(r) ? { schema: r } : r, c = s[i];
|
|
1817
|
+
if (c === void 0 || typeof c == "function" || !a.bodyParam) continue;
|
|
1818
|
+
const l = typeof a.bodyParam == "string" ? a.bodyParam : i;
|
|
1819
|
+
let h;
|
|
1820
|
+
typeof a.bodyParam == "function" ? h = a.bodyParam({ value: c }) : typeof c == "object" ? h = JSON.stringify(c) : h = String(c), t.set(l, h);
|
|
1821
|
+
}
|
|
1822
|
+
return t;
|
|
1823
|
+
}
|
|
1824
|
+
function Re(s, e = "") {
|
|
1825
|
+
const t = [];
|
|
1826
|
+
for (const [n, i] of Object.entries(s)) {
|
|
1788
1827
|
const r = e ? `${e}.${n}` : n;
|
|
1789
1828
|
if (i !== null && typeof i == "object" && !Array.isArray(i))
|
|
1790
|
-
|
|
1829
|
+
t.push(Re(i, r));
|
|
1791
1830
|
else {
|
|
1792
1831
|
const o = encodeURIComponent(JSON.stringify(i));
|
|
1793
|
-
|
|
1832
|
+
t.push(`${r}=${o}`);
|
|
1794
1833
|
}
|
|
1795
1834
|
}
|
|
1796
|
-
return
|
|
1835
|
+
return t.filter(Boolean).join("&");
|
|
1797
1836
|
}
|
|
1798
|
-
function
|
|
1837
|
+
function et(s) {
|
|
1799
1838
|
const e = {};
|
|
1800
|
-
if (!
|
|
1801
|
-
const
|
|
1802
|
-
for (const n of
|
|
1839
|
+
if (!s) return e;
|
|
1840
|
+
const t = s.split("&");
|
|
1841
|
+
for (const n of t) {
|
|
1803
1842
|
const [i, r] = n.split("=");
|
|
1804
1843
|
if (!i || r === void 0) continue;
|
|
1805
1844
|
let o;
|
|
@@ -1818,48 +1857,48 @@ function Ze(t) {
|
|
|
1818
1857
|
}
|
|
1819
1858
|
return e;
|
|
1820
1859
|
}
|
|
1821
|
-
function
|
|
1822
|
-
return typeof
|
|
1860
|
+
function tt(s) {
|
|
1861
|
+
return typeof s == "object" && s !== null && s.__type__ === "dotify" && typeof s.__value__ == "string";
|
|
1823
1862
|
}
|
|
1824
|
-
function
|
|
1863
|
+
function pe(s, e, t) {
|
|
1825
1864
|
const n = {
|
|
1826
|
-
...
|
|
1865
|
+
...P,
|
|
1827
1866
|
...e
|
|
1828
1867
|
}, i = {};
|
|
1829
|
-
for (const [r, o] of Object.entries(
|
|
1868
|
+
for (const [r, o] of Object.entries(s)) {
|
|
1830
1869
|
if (o === void 0) continue;
|
|
1831
1870
|
const a = n[r];
|
|
1832
|
-
i[r] =
|
|
1871
|
+
i[r] = st(o, a, t);
|
|
1833
1872
|
}
|
|
1834
1873
|
return i;
|
|
1835
1874
|
}
|
|
1836
|
-
function
|
|
1837
|
-
if (typeof
|
|
1838
|
-
return
|
|
1875
|
+
function st(s, e, t) {
|
|
1876
|
+
if (typeof s == "function")
|
|
1877
|
+
return t.serialize(s);
|
|
1839
1878
|
const n = e?.serialization ?? I.JSON;
|
|
1840
|
-
if (n === I.BASE64 && typeof
|
|
1841
|
-
const i = JSON.stringify(
|
|
1879
|
+
if (n === I.BASE64 && typeof s == "object") {
|
|
1880
|
+
const i = JSON.stringify(s);
|
|
1842
1881
|
return {
|
|
1843
1882
|
__type__: "base64",
|
|
1844
1883
|
__value__: btoa(encodeURIComponent(i))
|
|
1845
1884
|
};
|
|
1846
1885
|
}
|
|
1847
|
-
return n === I.DOTIFY && typeof
|
|
1886
|
+
return n === I.DOTIFY && typeof s == "object" && s !== null && !Array.isArray(s) ? {
|
|
1848
1887
|
__type__: "dotify",
|
|
1849
|
-
__value__:
|
|
1850
|
-
} :
|
|
1888
|
+
__value__: Re(s)
|
|
1889
|
+
} : B(s, t);
|
|
1851
1890
|
}
|
|
1852
|
-
function
|
|
1891
|
+
function me(s, e, t, n, i, r) {
|
|
1853
1892
|
const o = {
|
|
1854
|
-
...
|
|
1893
|
+
...P,
|
|
1855
1894
|
...e
|
|
1856
1895
|
}, a = {};
|
|
1857
|
-
for (const [c, l] of Object.entries(
|
|
1896
|
+
for (const [c, l] of Object.entries(s)) {
|
|
1858
1897
|
const h = o[c];
|
|
1859
|
-
a[c] =
|
|
1898
|
+
a[c] = nt(
|
|
1860
1899
|
l,
|
|
1861
1900
|
h,
|
|
1862
|
-
|
|
1901
|
+
t,
|
|
1863
1902
|
n,
|
|
1864
1903
|
i,
|
|
1865
1904
|
r
|
|
@@ -1867,65 +1906,65 @@ function de(t, e, s, n, i, r) {
|
|
|
1867
1906
|
}
|
|
1868
1907
|
return a;
|
|
1869
1908
|
}
|
|
1870
|
-
function
|
|
1871
|
-
if (
|
|
1909
|
+
function nt(s, e, t, n, i, r) {
|
|
1910
|
+
if (it(s))
|
|
1872
1911
|
try {
|
|
1873
|
-
const o = decodeURIComponent(atob(
|
|
1912
|
+
const o = decodeURIComponent(atob(s.__value__));
|
|
1874
1913
|
return JSON.parse(o);
|
|
1875
1914
|
} catch {
|
|
1876
|
-
return
|
|
1915
|
+
return s;
|
|
1877
1916
|
}
|
|
1878
|
-
if (
|
|
1917
|
+
if (tt(s))
|
|
1879
1918
|
try {
|
|
1880
|
-
return
|
|
1919
|
+
return et(s.__value__);
|
|
1881
1920
|
} catch {
|
|
1882
|
-
return
|
|
1921
|
+
return s;
|
|
1883
1922
|
}
|
|
1884
|
-
return
|
|
1923
|
+
return V(s, n, i, r);
|
|
1885
1924
|
}
|
|
1886
|
-
function
|
|
1887
|
-
return typeof
|
|
1925
|
+
function it(s) {
|
|
1926
|
+
return typeof s == "object" && s !== null && s.__type__ === "base64" && typeof s.__value__ == "string";
|
|
1888
1927
|
}
|
|
1889
|
-
function
|
|
1890
|
-
return
|
|
1928
|
+
function R(s, e = "100%") {
|
|
1929
|
+
return s === void 0 ? e : typeof s == "number" ? `${s}px` : s;
|
|
1891
1930
|
}
|
|
1892
|
-
function $(
|
|
1893
|
-
if (
|
|
1894
|
-
if (typeof
|
|
1895
|
-
const
|
|
1896
|
-
return isNaN(
|
|
1931
|
+
function $(s, e) {
|
|
1932
|
+
if (s === void 0) return e;
|
|
1933
|
+
if (typeof s == "number") return s;
|
|
1934
|
+
const t = parseInt(s, 10);
|
|
1935
|
+
return isNaN(t) ? e : t;
|
|
1897
1936
|
}
|
|
1898
|
-
function
|
|
1937
|
+
function rt(s) {
|
|
1899
1938
|
try {
|
|
1900
|
-
|
|
1939
|
+
s.src = "about:blank", s.parentNode?.removeChild(s);
|
|
1901
1940
|
} catch {
|
|
1902
1941
|
}
|
|
1903
1942
|
}
|
|
1904
|
-
function
|
|
1905
|
-
|
|
1943
|
+
function ot(s, e) {
|
|
1944
|
+
lt(s, e);
|
|
1906
1945
|
}
|
|
1907
|
-
function
|
|
1908
|
-
|
|
1946
|
+
function at(s) {
|
|
1947
|
+
s.style.display = "", s.style.visibility = "visible";
|
|
1909
1948
|
}
|
|
1910
|
-
function
|
|
1911
|
-
|
|
1949
|
+
function ge(s) {
|
|
1950
|
+
s.style.display = "none", s.style.visibility = "hidden";
|
|
1912
1951
|
}
|
|
1913
|
-
function
|
|
1952
|
+
function ct(s) {
|
|
1914
1953
|
try {
|
|
1915
|
-
|
|
1954
|
+
s.focus(), s.contentWindow?.focus();
|
|
1916
1955
|
} catch {
|
|
1917
1956
|
}
|
|
1918
1957
|
}
|
|
1919
|
-
function
|
|
1920
|
-
e.width !== void 0 && (
|
|
1958
|
+
function lt(s, e) {
|
|
1959
|
+
e.width !== void 0 && (s.style.width = R(e.width)), e.height !== void 0 && (s.style.height = R(e.height));
|
|
1921
1960
|
}
|
|
1922
|
-
class
|
|
1961
|
+
class ve extends Error {
|
|
1923
1962
|
constructor(e = "Popup blocked by browser") {
|
|
1924
1963
|
super(e), this.name = "PopupOpenError";
|
|
1925
1964
|
}
|
|
1926
1965
|
}
|
|
1927
|
-
function
|
|
1928
|
-
const { url: e, name:
|
|
1966
|
+
function ut(s) {
|
|
1967
|
+
const { url: e, name: t, dimensions: n } = s, i = $(n.width, 500), r = $(n.height, 500), o = Math.floor(window.screenX + (window.outerWidth - i) / 2), a = Math.floor(window.screenY + (window.outerHeight - r) / 2), c = [
|
|
1929
1968
|
`width=${i}`,
|
|
1930
1969
|
`height=${r}`,
|
|
1931
1970
|
`left=${o}`,
|
|
@@ -1937,32 +1976,32 @@ function ot(t) {
|
|
|
1937
1976
|
"status=no",
|
|
1938
1977
|
"resizable=yes",
|
|
1939
1978
|
"scrollbars=yes"
|
|
1940
|
-
].join(","), l = window.open(e,
|
|
1941
|
-
if (!l ||
|
|
1942
|
-
throw new
|
|
1979
|
+
].join(","), l = window.open(e, t, c);
|
|
1980
|
+
if (!l || ft(l))
|
|
1981
|
+
throw new ve();
|
|
1943
1982
|
return l;
|
|
1944
1983
|
}
|
|
1945
|
-
function
|
|
1984
|
+
function ht(s) {
|
|
1946
1985
|
try {
|
|
1947
|
-
|
|
1986
|
+
s.closed || s.close();
|
|
1948
1987
|
} catch {
|
|
1949
1988
|
}
|
|
1950
1989
|
}
|
|
1951
|
-
function
|
|
1990
|
+
function dt(s) {
|
|
1952
1991
|
try {
|
|
1953
|
-
|
|
1992
|
+
s.closed || s.focus();
|
|
1954
1993
|
} catch {
|
|
1955
1994
|
}
|
|
1956
1995
|
}
|
|
1957
|
-
function
|
|
1958
|
-
if (!
|
|
1996
|
+
function ft(s) {
|
|
1997
|
+
if (!s) return !0;
|
|
1959
1998
|
try {
|
|
1960
|
-
return !!(
|
|
1999
|
+
return !!(s.closed || s.innerHeight === 0 || s.innerWidth === 0);
|
|
1961
2000
|
} catch {
|
|
1962
2001
|
return !0;
|
|
1963
2002
|
}
|
|
1964
2003
|
}
|
|
1965
|
-
function
|
|
2004
|
+
function pt(s, e, t = {}) {
|
|
1966
2005
|
const {
|
|
1967
2006
|
initialInterval: n = 100,
|
|
1968
2007
|
// Start fast to catch quick closes
|
|
@@ -1970,18 +2009,18 @@ function ut(t, e, s = {}) {
|
|
|
1970
2009
|
// Cap at 2 seconds
|
|
1971
2010
|
multiplier: r = 1.5
|
|
1972
2011
|
// Exponential backoff multiplier
|
|
1973
|
-
} =
|
|
2012
|
+
} = t;
|
|
1974
2013
|
let o = n, a, c = !1;
|
|
1975
2014
|
const l = () => {
|
|
1976
2015
|
try {
|
|
1977
2016
|
e();
|
|
1978
|
-
} catch (
|
|
1979
|
-
console.error("Error in popup close callback:",
|
|
2017
|
+
} catch (w) {
|
|
2018
|
+
console.error("Error in popup close callback:", w);
|
|
1980
2019
|
}
|
|
1981
2020
|
}, h = () => {
|
|
1982
2021
|
if (!c) {
|
|
1983
2022
|
try {
|
|
1984
|
-
if (
|
|
2023
|
+
if (s.closed) {
|
|
1985
2024
|
l();
|
|
1986
2025
|
return;
|
|
1987
2026
|
}
|
|
@@ -1996,34 +2035,34 @@ function ut(t, e, s = {}) {
|
|
|
1996
2035
|
c = !0, clearTimeout(a);
|
|
1997
2036
|
};
|
|
1998
2037
|
}
|
|
1999
|
-
function
|
|
2038
|
+
function mt(s, e) {
|
|
2000
2039
|
try {
|
|
2001
|
-
const
|
|
2040
|
+
const t = $(e.width, s.outerWidth), n = $(
|
|
2002
2041
|
e.height,
|
|
2003
|
-
|
|
2042
|
+
s.outerHeight
|
|
2004
2043
|
);
|
|
2005
|
-
|
|
2044
|
+
s.resizeTo(t, n);
|
|
2006
2045
|
} catch {
|
|
2007
2046
|
}
|
|
2008
2047
|
}
|
|
2009
|
-
function
|
|
2010
|
-
const { doc: e, dimensions:
|
|
2048
|
+
function gt(s) {
|
|
2049
|
+
const { doc: e, dimensions: t, uid: n, tag: i } = s, r = e.createElement("div");
|
|
2011
2050
|
return r.id = `forgeframe-container-${n}`, r.setAttribute("data-forgeframe-tag", i), Object.assign(r.style, {
|
|
2012
2051
|
display: "inline-block",
|
|
2013
2052
|
position: "relative",
|
|
2014
|
-
width:
|
|
2015
|
-
height:
|
|
2053
|
+
width: R(t.width),
|
|
2054
|
+
height: R(t.height),
|
|
2016
2055
|
overflow: "hidden"
|
|
2017
2056
|
}), r;
|
|
2018
2057
|
}
|
|
2019
|
-
function
|
|
2020
|
-
const { doc: e, dimensions:
|
|
2058
|
+
function yt(s) {
|
|
2059
|
+
const { doc: e, dimensions: t, cspNonce: n } = s, i = e.createElement("div");
|
|
2021
2060
|
Object.assign(i.style, {
|
|
2022
2061
|
display: "flex",
|
|
2023
2062
|
alignItems: "center",
|
|
2024
2063
|
justifyContent: "center",
|
|
2025
|
-
width:
|
|
2026
|
-
height:
|
|
2064
|
+
width: R(t.width),
|
|
2065
|
+
height: R(t.height),
|
|
2027
2066
|
backgroundColor: "#f5f5f5",
|
|
2028
2067
|
position: "absolute",
|
|
2029
2068
|
top: "0",
|
|
@@ -2046,20 +2085,20 @@ function ft(t) {
|
|
|
2046
2085
|
}
|
|
2047
2086
|
`, i.appendChild(o), i.appendChild(r), i;
|
|
2048
2087
|
}
|
|
2049
|
-
function
|
|
2050
|
-
return new Promise((
|
|
2051
|
-
|
|
2088
|
+
function wt(s, e = 200) {
|
|
2089
|
+
return new Promise((t) => {
|
|
2090
|
+
s.style.opacity = "0", s.style.transition = `opacity ${e}ms ease-in`, s.offsetHeight, s.style.opacity = "1", setTimeout(t, e);
|
|
2052
2091
|
});
|
|
2053
2092
|
}
|
|
2054
|
-
function
|
|
2055
|
-
return new Promise((
|
|
2056
|
-
|
|
2093
|
+
function _t(s, e = 200) {
|
|
2094
|
+
return new Promise((t) => {
|
|
2095
|
+
s.style.transition = `opacity ${e}ms ease-out`, s.style.opacity = "0", setTimeout(t, e);
|
|
2057
2096
|
});
|
|
2058
2097
|
}
|
|
2059
|
-
async function
|
|
2060
|
-
e && (await
|
|
2098
|
+
async function Et(s, e, t) {
|
|
2099
|
+
e && (await _t(e, 150), e.remove()), t.style.display = "", t.style.visibility = "visible", t.style.opacity = "0", await wt(t, 150);
|
|
2061
2100
|
}
|
|
2062
|
-
class
|
|
2101
|
+
class se {
|
|
2063
2102
|
/** Event emitter for lifecycle events. */
|
|
2064
2103
|
event;
|
|
2065
2104
|
/** Arbitrary state storage for the component instance. */
|
|
@@ -2092,6 +2131,10 @@ class Q {
|
|
|
2092
2131
|
/** @internal */
|
|
2093
2132
|
hostWindow = null;
|
|
2094
2133
|
/** @internal */
|
|
2134
|
+
openedHostDomain = null;
|
|
2135
|
+
/** @internal */
|
|
2136
|
+
dynamicUrlTrustedOrigin = null;
|
|
2137
|
+
/** @internal */
|
|
2095
2138
|
iframe = null;
|
|
2096
2139
|
/** @internal */
|
|
2097
2140
|
container = null;
|
|
@@ -2109,25 +2152,20 @@ class Q {
|
|
|
2109
2152
|
* @param options - Component configuration options
|
|
2110
2153
|
* @param props - Initial props to pass to the component
|
|
2111
2154
|
*/
|
|
2112
|
-
constructor(e,
|
|
2113
|
-
this._uid =
|
|
2114
|
-
const n = this.
|
|
2115
|
-
this.
|
|
2116
|
-
const i = this.
|
|
2117
|
-
this.
|
|
2155
|
+
constructor(e, t = {}) {
|
|
2156
|
+
this._uid = Fe(), this.options = this.normalizeOptions(e), this.context = this.options.defaultContext, this.event = new we(), this.cleanup = new Ne();
|
|
2157
|
+
const n = this.createPropContext();
|
|
2158
|
+
this.props = de(t, this.options.props, n);
|
|
2159
|
+
const i = this.buildTrustedDomains();
|
|
2160
|
+
this.messenger = new Ee(this.uid, window, q(), i), this.bridge = new J(this.messenger), this.setupMessageHandlers(), this.setupCleanup();
|
|
2118
2161
|
}
|
|
2119
2162
|
/**
|
|
2120
2163
|
* Builds the list of trusted domains for messenger communication.
|
|
2121
2164
|
* @internal
|
|
2122
2165
|
*/
|
|
2123
2166
|
buildTrustedDomains() {
|
|
2124
|
-
const e = [],
|
|
2125
|
-
|
|
2126
|
-
const n = new URL(s);
|
|
2127
|
-
e.push(n.origin);
|
|
2128
|
-
} catch {
|
|
2129
|
-
}
|
|
2130
|
-
if (this.options.domain) {
|
|
2167
|
+
const e = [], t = this.resolveUrlOrigin(this.resolveUrl());
|
|
2168
|
+
if (t && (e.push(t), this.dynamicUrlTrustedOrigin = t), this.options.domain) {
|
|
2131
2169
|
if (typeof this.options.domain == "string")
|
|
2132
2170
|
e.push(this.options.domain);
|
|
2133
2171
|
else if (Array.isArray(this.options.domain))
|
|
@@ -2155,12 +2193,12 @@ class Q {
|
|
|
2155
2193
|
* await instance.render(document.getElementById('target'), 'popup');
|
|
2156
2194
|
* ```
|
|
2157
2195
|
*/
|
|
2158
|
-
async render(e,
|
|
2196
|
+
async render(e, t) {
|
|
2159
2197
|
if (this.destroyed)
|
|
2160
2198
|
throw new Error("Component has been destroyed");
|
|
2161
2199
|
if (this.rendered)
|
|
2162
2200
|
throw new Error("Component has already been rendered");
|
|
2163
|
-
this.context =
|
|
2201
|
+
this.context = t ?? this.options.defaultContext, this.checkEligibility(), Ye(this.props, this.options.props), this.options.validate?.({ props: this.props }), this.container = this.resolveContainer(e), this.event.emit(f.PRERENDER), this.callPropCallback("onPrerender"), await this.prerender(), this.event.emit(f.PRERENDERED), this.callPropCallback("onPrerendered"), this.event.emit(f.RENDER), this.callPropCallback("onRender"), await this.open(), await this.waitForHost(), this.context === p.IFRAME && this.iframe && this.prerenderElement && (await Et(
|
|
2164
2202
|
this.container,
|
|
2165
2203
|
this.prerenderElement,
|
|
2166
2204
|
this.iframe
|
|
@@ -2177,8 +2215,8 @@ class Q {
|
|
|
2177
2215
|
* @param container - CSS selector or HTMLElement to render into
|
|
2178
2216
|
* @param context - Override the default rendering context
|
|
2179
2217
|
*/
|
|
2180
|
-
async renderTo(e,
|
|
2181
|
-
return this.render(
|
|
2218
|
+
async renderTo(e, t, n) {
|
|
2219
|
+
return this.render(t, n);
|
|
2182
2220
|
}
|
|
2183
2221
|
/**
|
|
2184
2222
|
* Closes and destroys the component.
|
|
@@ -2196,7 +2234,7 @@ class Q {
|
|
|
2196
2234
|
* For iframes, focuses the iframe element. For popups, brings the window to front.
|
|
2197
2235
|
*/
|
|
2198
2236
|
async focus() {
|
|
2199
|
-
this.context === p.IFRAME && this.iframe ?
|
|
2237
|
+
this.context === p.IFRAME && this.iframe ? ct(this.iframe) : this.context === p.POPUP && this.hostWindow && dt(this.hostWindow), this.event.emit(f.FOCUS), this.callPropCallback("onFocus");
|
|
2200
2238
|
}
|
|
2201
2239
|
/**
|
|
2202
2240
|
* Resizes the component to the specified dimensions.
|
|
@@ -2204,7 +2242,7 @@ class Q {
|
|
|
2204
2242
|
* @param dimensions - New width and height for the component
|
|
2205
2243
|
*/
|
|
2206
2244
|
async resize(e) {
|
|
2207
|
-
this.context === p.IFRAME && this.iframe ?
|
|
2245
|
+
this.context === p.IFRAME && this.iframe ? ot(this.iframe, e) : this.context === p.POPUP && this.hostWindow && mt(this.hostWindow, e), this.event.emit(f.RESIZE, e), this.callPropCallback("onResize", e);
|
|
2208
2246
|
}
|
|
2209
2247
|
/**
|
|
2210
2248
|
* Shows the component if hidden.
|
|
@@ -2213,7 +2251,7 @@ class Q {
|
|
|
2213
2251
|
* Only applicable to iframe context.
|
|
2214
2252
|
*/
|
|
2215
2253
|
async show() {
|
|
2216
|
-
this.context === p.IFRAME && this.iframe &&
|
|
2254
|
+
this.context === p.IFRAME && this.iframe && at(this.iframe);
|
|
2217
2255
|
}
|
|
2218
2256
|
/**
|
|
2219
2257
|
* Hides the component.
|
|
@@ -2222,7 +2260,7 @@ class Q {
|
|
|
2222
2260
|
* Only applicable to iframe context.
|
|
2223
2261
|
*/
|
|
2224
2262
|
async hide() {
|
|
2225
|
-
this.context === p.IFRAME && this.iframe &&
|
|
2263
|
+
this.context === p.IFRAME && this.iframe && ge(this.iframe);
|
|
2226
2264
|
}
|
|
2227
2265
|
/**
|
|
2228
2266
|
* Updates the component props and sends them to the host.
|
|
@@ -2233,27 +2271,33 @@ class Q {
|
|
|
2233
2271
|
* @param newProps - Partial props object to merge with existing props
|
|
2234
2272
|
*/
|
|
2235
2273
|
async updateProps(e) {
|
|
2236
|
-
const
|
|
2237
|
-
if (this.props = le(
|
|
2274
|
+
const t = this.createPropContext(), n = de(
|
|
2238
2275
|
{ ...this.props, ...e },
|
|
2239
2276
|
this.options.props,
|
|
2240
|
-
|
|
2241
|
-
)
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2277
|
+
t
|
|
2278
|
+
);
|
|
2279
|
+
this.options.validate?.({ props: n });
|
|
2280
|
+
const i = this.resolveUrl(n), r = this.resolveUrlOrigin(i);
|
|
2281
|
+
if (this.rendered && this.openedHostDomain && r && r !== this.openedHostDomain)
|
|
2282
|
+
throw new Error(
|
|
2283
|
+
`Cannot change component URL origin after render (from "${this.openedHostDomain}" to "${r}")`
|
|
2284
|
+
);
|
|
2285
|
+
if (this.props = n, this.rendered || this.syncTrustedDomainForUrl(i), this.hostWindow && !Pe(this.hostWindow)) {
|
|
2286
|
+
const o = this.openedHostDomain ?? this.getHostDomain(), a = fe(
|
|
2245
2287
|
n,
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2288
|
+
this.options.props,
|
|
2289
|
+
o,
|
|
2290
|
+
be(this.hostWindow)
|
|
2291
|
+
), c = pe(
|
|
2292
|
+
a,
|
|
2249
2293
|
this.options.props,
|
|
2250
2294
|
this.bridge
|
|
2251
2295
|
);
|
|
2252
2296
|
await this.messenger.send(
|
|
2253
2297
|
this.hostWindow,
|
|
2254
|
-
|
|
2298
|
+
o,
|
|
2255
2299
|
u.PROPS,
|
|
2256
|
-
|
|
2300
|
+
c
|
|
2257
2301
|
);
|
|
2258
2302
|
}
|
|
2259
2303
|
this.event.emit(f.PROPS, this.props), this.callPropCallback("onProps", this.props);
|
|
@@ -2264,7 +2308,7 @@ class Q {
|
|
|
2264
2308
|
* @returns A new unrendered component instance with identical configuration
|
|
2265
2309
|
*/
|
|
2266
2310
|
clone() {
|
|
2267
|
-
return new
|
|
2311
|
+
return new se(this.options, this.props);
|
|
2268
2312
|
}
|
|
2269
2313
|
/**
|
|
2270
2314
|
* Checks if the component is eligible to render based on the eligible option.
|
|
@@ -2283,11 +2327,54 @@ class Q {
|
|
|
2283
2327
|
...e,
|
|
2284
2328
|
props: e.props ?? {},
|
|
2285
2329
|
defaultContext: e.defaultContext ?? p.IFRAME,
|
|
2286
|
-
dimensions:
|
|
2330
|
+
dimensions: e.dimensions ?? { width: "100%", height: "100%" },
|
|
2287
2331
|
timeout: e.timeout ?? 1e4,
|
|
2288
2332
|
children: e.children
|
|
2289
2333
|
};
|
|
2290
2334
|
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Resolves the host URL from static or function options.
|
|
2337
|
+
* @internal
|
|
2338
|
+
*/
|
|
2339
|
+
resolveUrl(e = this.props) {
|
|
2340
|
+
return typeof this.options.url == "function" ? this.options.url(e) : this.options.url;
|
|
2341
|
+
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Resolves dimensions from static or function options.
|
|
2344
|
+
* @internal
|
|
2345
|
+
*/
|
|
2346
|
+
resolveDimensions() {
|
|
2347
|
+
return typeof this.options.dimensions == "function" ? this.options.dimensions(this.props) : this.options.dimensions;
|
|
2348
|
+
}
|
|
2349
|
+
/**
|
|
2350
|
+
* Resolves a URL to an origin, supporting relative URLs.
|
|
2351
|
+
* @internal
|
|
2352
|
+
*/
|
|
2353
|
+
resolveUrlOrigin(e) {
|
|
2354
|
+
try {
|
|
2355
|
+
return new URL(e, window.location.origin).origin;
|
|
2356
|
+
} catch {
|
|
2357
|
+
return null;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
/**
|
|
2361
|
+
* Returns true when the domain option explicitly includes this origin.
|
|
2362
|
+
* @internal
|
|
2363
|
+
*/
|
|
2364
|
+
isExplicitDomainTrust(e) {
|
|
2365
|
+
return !this.options.domain || this.options.domain instanceof RegExp ? !1 : typeof this.options.domain == "string" ? this.options.domain === e : this.options.domain.includes(e);
|
|
2366
|
+
}
|
|
2367
|
+
/**
|
|
2368
|
+
* Ensures the messenger trusts the origin for a resolved host URL.
|
|
2369
|
+
* @internal
|
|
2370
|
+
*/
|
|
2371
|
+
syncTrustedDomainForUrl(e) {
|
|
2372
|
+
const t = this.resolveUrlOrigin(e);
|
|
2373
|
+
if (!t)
|
|
2374
|
+
return;
|
|
2375
|
+
const n = this.dynamicUrlTrustedOrigin;
|
|
2376
|
+
n && n !== t && !this.isExplicitDomainTrust(n) && this.messenger.removeTrustedDomain(n), this.messenger.addTrustedDomain(t), this.dynamicUrlTrustedOrigin = t;
|
|
2377
|
+
}
|
|
2291
2378
|
/**
|
|
2292
2379
|
* Creates the prop context passed to prop callbacks and validators.
|
|
2293
2380
|
* @internal
|
|
@@ -2312,10 +2399,10 @@ class Q {
|
|
|
2312
2399
|
if (!e)
|
|
2313
2400
|
throw new Error("Container is required for rendering");
|
|
2314
2401
|
if (typeof e == "string") {
|
|
2315
|
-
const
|
|
2316
|
-
if (!
|
|
2402
|
+
const t = document.querySelector(e);
|
|
2403
|
+
if (!t)
|
|
2317
2404
|
throw new Error(`Container "${e}" not found`);
|
|
2318
|
-
return
|
|
2405
|
+
return t;
|
|
2319
2406
|
}
|
|
2320
2407
|
return e;
|
|
2321
2408
|
}
|
|
@@ -2335,10 +2422,10 @@ class Q {
|
|
|
2335
2422
|
*/
|
|
2336
2423
|
async prerender() {
|
|
2337
2424
|
if (!this.container) return;
|
|
2338
|
-
const e = this.options.prerenderTemplate ??
|
|
2425
|
+
const e = this.options.prerenderTemplate ?? yt, t = this.options.containerTemplate ?? gt, n = this.resolveDimensions(), i = this.props.cspNonce;
|
|
2339
2426
|
if (this.context === p.IFRAME) {
|
|
2340
2427
|
const c = this.buildWindowName();
|
|
2341
|
-
this.iframe = this.createIframeElement(c),
|
|
2428
|
+
this.iframe = this.createIframeElement(c), ge(this.iframe);
|
|
2342
2429
|
}
|
|
2343
2430
|
const r = {
|
|
2344
2431
|
uid: this.uid,
|
|
@@ -2368,7 +2455,7 @@ class Q {
|
|
|
2368
2455
|
close: () => this.close(),
|
|
2369
2456
|
focus: () => this.focus(),
|
|
2370
2457
|
cspNonce: i
|
|
2371
|
-
}, a =
|
|
2458
|
+
}, a = t(o);
|
|
2372
2459
|
a && (this.container.appendChild(a), this.container = a), this.prerenderElement && !this.prerenderElement.parentNode && this.container.appendChild(this.prerenderElement), this.iframe && !this.iframe.parentNode && this.container.appendChild(this.iframe);
|
|
2373
2460
|
}
|
|
2374
2461
|
/**
|
|
@@ -2377,82 +2464,112 @@ class Q {
|
|
|
2377
2464
|
* @internal
|
|
2378
2465
|
*/
|
|
2379
2466
|
createIframeElement(e) {
|
|
2380
|
-
const
|
|
2381
|
-
|
|
2467
|
+
const t = document.createElement("iframe"), n = this.resolveDimensions(), i = typeof this.options.attributes == "function" ? this.options.attributes(this.props) : this.options.attributes ?? {}, r = typeof this.options.style == "function" ? this.options.style(this.props) : this.options.style ?? {};
|
|
2468
|
+
t.name = e, t.setAttribute("frameborder", "0"), t.setAttribute("allowtransparency", "true"), t.setAttribute("scrolling", "auto"), n.width !== void 0 && (t.style.width = typeof n.width == "number" ? `${n.width}px` : n.width), n.height !== void 0 && (t.style.height = typeof n.height == "number" ? `${n.height}px` : n.height);
|
|
2382
2469
|
for (const [o, a] of Object.entries(i))
|
|
2383
|
-
a !== void 0 && (typeof a == "boolean" ? a &&
|
|
2470
|
+
a !== void 0 && (typeof a == "boolean" ? a && t.setAttribute(o, "") : t.setAttribute(o, a));
|
|
2384
2471
|
for (const [o, a] of Object.entries(r)) {
|
|
2385
2472
|
if (a === void 0) continue;
|
|
2386
2473
|
const c = typeof a == "number" ? `${a}px` : a;
|
|
2387
|
-
|
|
2474
|
+
t.style.setProperty(
|
|
2388
2475
|
o.replace(/([A-Z])/g, "-$1").toLowerCase(),
|
|
2389
2476
|
String(c)
|
|
2390
2477
|
);
|
|
2391
2478
|
}
|
|
2392
|
-
return i.sandbox ||
|
|
2479
|
+
return i.sandbox || t.setAttribute(
|
|
2393
2480
|
"sandbox",
|
|
2394
2481
|
"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"
|
|
2395
|
-
),
|
|
2482
|
+
), t;
|
|
2396
2483
|
}
|
|
2397
2484
|
/**
|
|
2398
2485
|
* Opens the host window (iframe or popup).
|
|
2399
2486
|
* @internal
|
|
2400
2487
|
*/
|
|
2401
2488
|
async open() {
|
|
2402
|
-
const e = this.
|
|
2489
|
+
const e = this.resolveUrl();
|
|
2490
|
+
this.syncTrustedDomainForUrl(e), this.openedHostDomain = this.resolveUrlOrigin(e);
|
|
2491
|
+
const t = this.buildUrl(e), n = this.buildBodyParams(), i = n.toString().length > 0;
|
|
2403
2492
|
if (this.context === p.IFRAME) {
|
|
2404
2493
|
if (!this.iframe)
|
|
2405
2494
|
throw new Error("Iframe not created during prerender");
|
|
2406
|
-
this.iframe.src =
|
|
2495
|
+
i ? this.submitBodyForm(this.iframe.name, t, n) : this.iframe.src = t, this.hostWindow = this.iframe.contentWindow;
|
|
2407
2496
|
} else {
|
|
2408
|
-
const
|
|
2409
|
-
this.hostWindow =
|
|
2410
|
-
url:
|
|
2411
|
-
name:
|
|
2412
|
-
dimensions: this.
|
|
2413
|
-
});
|
|
2414
|
-
const
|
|
2497
|
+
const r = this.buildWindowName();
|
|
2498
|
+
this.hostWindow = ut({
|
|
2499
|
+
url: i ? "about:blank" : t,
|
|
2500
|
+
name: r,
|
|
2501
|
+
dimensions: this.resolveDimensions()
|
|
2502
|
+
}), i && this.submitBodyForm(r, t, n);
|
|
2503
|
+
const o = pt(this.hostWindow, () => {
|
|
2415
2504
|
this.destroy();
|
|
2416
2505
|
});
|
|
2417
|
-
this.cleanup.register(
|
|
2506
|
+
this.cleanup.register(o);
|
|
2418
2507
|
}
|
|
2419
|
-
this.hostWindow &&
|
|
2508
|
+
this.hostWindow && Je(this.uid, this.hostWindow);
|
|
2420
2509
|
}
|
|
2421
2510
|
/**
|
|
2422
2511
|
* Builds the URL for the host window including query parameters.
|
|
2423
2512
|
* @internal
|
|
2424
2513
|
*/
|
|
2425
|
-
buildUrl() {
|
|
2426
|
-
const
|
|
2514
|
+
buildUrl(e = this.resolveUrl()) {
|
|
2515
|
+
const n = Ze(this.props, this.options.props).toString();
|
|
2427
2516
|
if (!n) return e;
|
|
2428
2517
|
const i = e.includes("?") ? "&" : "?";
|
|
2429
2518
|
return `${e}${i}${n}`;
|
|
2430
2519
|
}
|
|
2520
|
+
/**
|
|
2521
|
+
* Builds POST body parameters from props marked with bodyParam.
|
|
2522
|
+
* @internal
|
|
2523
|
+
*/
|
|
2524
|
+
buildBodyParams() {
|
|
2525
|
+
return Qe(this.props, this.options.props);
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* Submits a hidden form to navigate a target window via POST.
|
|
2529
|
+
* @internal
|
|
2530
|
+
*/
|
|
2531
|
+
submitBodyForm(e, t, n) {
|
|
2532
|
+
const i = this.container?.ownerDocument ?? document, r = i.body ?? i.documentElement;
|
|
2533
|
+
if (!r)
|
|
2534
|
+
throw new Error("Document root is unavailable for bodyParam form submission");
|
|
2535
|
+
const o = i.createElement("form");
|
|
2536
|
+
o.method = "POST", o.action = t, o.target = e, o.style.display = "none";
|
|
2537
|
+
for (const [a, c] of n.entries()) {
|
|
2538
|
+
const l = i.createElement("input");
|
|
2539
|
+
l.type = "hidden", l.name = a, l.value = c, o.appendChild(l);
|
|
2540
|
+
}
|
|
2541
|
+
r.appendChild(o);
|
|
2542
|
+
try {
|
|
2543
|
+
o.submit();
|
|
2544
|
+
} finally {
|
|
2545
|
+
o.remove();
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2431
2548
|
/**
|
|
2432
2549
|
* Builds the window.name payload for the host window.
|
|
2433
2550
|
* @internal
|
|
2434
2551
|
*/
|
|
2435
2552
|
buildWindowName() {
|
|
2436
|
-
const e = this.getHostDomain(),
|
|
2553
|
+
const e = this.getHostDomain(), t = fe(
|
|
2437
2554
|
this.props,
|
|
2438
2555
|
this.options.props,
|
|
2439
2556
|
e,
|
|
2440
2557
|
!1
|
|
2441
2558
|
// Assume cross-domain for initial payload
|
|
2442
|
-
), n =
|
|
2443
|
-
|
|
2559
|
+
), n = pe(
|
|
2560
|
+
t,
|
|
2444
2561
|
this.options.props,
|
|
2445
2562
|
this.bridge
|
|
2446
|
-
), i = this.buildNestedHostRefs(), r =
|
|
2563
|
+
), i = this.buildNestedHostRefs(), r = Be({
|
|
2447
2564
|
uid: this.uid,
|
|
2448
2565
|
tag: this.options.tag,
|
|
2449
2566
|
context: this.context,
|
|
2450
|
-
consumerDomain:
|
|
2567
|
+
consumerDomain: q(),
|
|
2451
2568
|
props: n,
|
|
2452
2569
|
exports: this.createConsumerExports(),
|
|
2453
2570
|
children: i
|
|
2454
2571
|
});
|
|
2455
|
-
return
|
|
2572
|
+
return We(r);
|
|
2456
2573
|
}
|
|
2457
2574
|
/**
|
|
2458
2575
|
* Builds component references for nested host components.
|
|
@@ -2460,15 +2577,24 @@ class Q {
|
|
|
2460
2577
|
*/
|
|
2461
2578
|
buildNestedHostRefs() {
|
|
2462
2579
|
if (!this.options.children) return;
|
|
2463
|
-
const e = this.options.children({ props: this.props }),
|
|
2580
|
+
const e = this.options.children({ props: this.props }), t = {};
|
|
2464
2581
|
for (const [n, i] of Object.entries(e)) {
|
|
2465
|
-
const r = i;
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2582
|
+
const r = Ct(i);
|
|
2583
|
+
if (!r)
|
|
2584
|
+
throw new Error(`Nested component "${n}" is missing component metadata`);
|
|
2585
|
+
if (typeof r.url != "string")
|
|
2586
|
+
throw new Error(
|
|
2587
|
+
`Nested component "${n}" must use a static string URL. Function URLs are not supported in children.`
|
|
2588
|
+
);
|
|
2589
|
+
t[n] = {
|
|
2590
|
+
tag: r.tag,
|
|
2591
|
+
url: r.url,
|
|
2592
|
+
props: r.props,
|
|
2593
|
+
dimensions: typeof r.dimensions == "function" ? void 0 : r.dimensions,
|
|
2594
|
+
defaultContext: r.defaultContext
|
|
2469
2595
|
};
|
|
2470
2596
|
}
|
|
2471
|
-
return Object.keys(
|
|
2597
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
2472
2598
|
}
|
|
2473
2599
|
/**
|
|
2474
2600
|
* Creates the exports object sent to the host.
|
|
@@ -2491,21 +2617,16 @@ class Q {
|
|
|
2491
2617
|
* @internal
|
|
2492
2618
|
*/
|
|
2493
2619
|
getHostDomain() {
|
|
2494
|
-
|
|
2495
|
-
try {
|
|
2496
|
-
return new URL(e, window.location.origin).origin;
|
|
2497
|
-
} catch {
|
|
2498
|
-
return "*";
|
|
2499
|
-
}
|
|
2620
|
+
return this.openedHostDomain ? this.openedHostDomain : this.resolveUrlOrigin(this.resolveUrl()) ?? "*";
|
|
2500
2621
|
}
|
|
2501
2622
|
/**
|
|
2502
2623
|
* Waits for the host to send the init message.
|
|
2503
2624
|
* @internal
|
|
2504
2625
|
*/
|
|
2505
2626
|
async waitForHost() {
|
|
2506
|
-
this.initPromise =
|
|
2627
|
+
this.initPromise = _e();
|
|
2507
2628
|
try {
|
|
2508
|
-
await
|
|
2629
|
+
await ke(
|
|
2509
2630
|
this.initPromise.promise,
|
|
2510
2631
|
this.options.timeout,
|
|
2511
2632
|
`Host component "${this.options.tag}" (uid: ${this._uid}) did not initialize within ${this.options.timeout}ms. Check that the host page loads correctly and calls the initialization code.`
|
|
@@ -2522,21 +2643,21 @@ class Q {
|
|
|
2522
2643
|
this.messenger.on(u.INIT, () => (this.initPromise && this.initPromise.resolve(), { success: !0 })), this.messenger.on(u.CLOSE, async () => (await this.close(), { success: !0 })), this.messenger.on(u.RESIZE, async (e) => (await this.resize(e), { success: !0 })), this.messenger.on(u.FOCUS, async () => (await this.focus(), { success: !0 })), this.messenger.on(u.SHOW, async () => (await this.show(), { success: !0 })), this.messenger.on(u.HIDE, async () => (await this.hide(), { success: !0 })), this.messenger.on(
|
|
2523
2644
|
u.ERROR,
|
|
2524
2645
|
async (e) => {
|
|
2525
|
-
const
|
|
2526
|
-
return
|
|
2646
|
+
const t = new Error(e.message);
|
|
2647
|
+
return t.stack = e.stack, this.handleError(t), { success: !0 };
|
|
2527
2648
|
}
|
|
2528
2649
|
), this.messenger.on(u.EXPORT, async (e) => (this.exports = e, { success: !0 })), this.messenger.on(u.CONSUMER_EXPORT, async (e) => (this.consumerExports = e, { success: !0 })), this.messenger.on(
|
|
2529
2650
|
u.GET_SIBLINGS,
|
|
2530
2651
|
async (e) => {
|
|
2531
|
-
const
|
|
2652
|
+
const t = [], n = xt(e.tag);
|
|
2532
2653
|
if (n)
|
|
2533
2654
|
for (const i of n.instances)
|
|
2534
|
-
i.uid !== e.uid &&
|
|
2655
|
+
i.uid !== e.uid && t.push({
|
|
2535
2656
|
uid: i.uid,
|
|
2536
2657
|
tag: e.tag,
|
|
2537
2658
|
exports: i.exports
|
|
2538
2659
|
});
|
|
2539
|
-
return
|
|
2660
|
+
return t;
|
|
2540
2661
|
}
|
|
2541
2662
|
);
|
|
2542
2663
|
}
|
|
@@ -2546,7 +2667,7 @@ class Q {
|
|
|
2546
2667
|
*/
|
|
2547
2668
|
setupCleanup() {
|
|
2548
2669
|
this.cleanup.register(() => {
|
|
2549
|
-
this.messenger.destroy(), this.bridge.destroy(),
|
|
2670
|
+
this.messenger.destroy(), this.bridge.destroy(), Xe(this.uid);
|
|
2550
2671
|
});
|
|
2551
2672
|
}
|
|
2552
2673
|
/**
|
|
@@ -2560,11 +2681,11 @@ class Q {
|
|
|
2560
2681
|
* Calls a prop callback if it exists.
|
|
2561
2682
|
* @internal
|
|
2562
2683
|
*/
|
|
2563
|
-
callPropCallback(e, ...
|
|
2684
|
+
callPropCallback(e, ...t) {
|
|
2564
2685
|
const n = this.props[e];
|
|
2565
2686
|
if (typeof n == "function")
|
|
2566
2687
|
try {
|
|
2567
|
-
const i = n(...
|
|
2688
|
+
const i = n(...t);
|
|
2568
2689
|
i && typeof i == "object" && "catch" in i && typeof i.catch == "function" && i.catch((r) => {
|
|
2569
2690
|
console.error(`Error in async ${e} callback:`, r);
|
|
2570
2691
|
});
|
|
@@ -2579,18 +2700,20 @@ class Q {
|
|
|
2579
2700
|
async destroy() {
|
|
2580
2701
|
this.destroyed || (this.destroyed = !0, this.initPromise && (this.initPromise.reject(
|
|
2581
2702
|
new Error(`Component "${this.options.tag}" was destroyed before initialization completed`)
|
|
2582
|
-
), this.initPromise = null), this.iframe && (
|
|
2703
|
+
), this.initPromise = null), this.iframe && (rt(this.iframe), this.iframe = null), this.context === p.POPUP && this.hostWindow && ht(this.hostWindow), this.hostWindow = null, this.openedHostDomain = null, this.dynamicUrlTrustedOrigin = null, this.prerenderElement && (this.prerenderElement.remove(), this.prerenderElement = null), await this.cleanup.cleanup(), this.event.emit(f.DESTROY), this.callPropCallback("onDestroy"), this.event.removeAllListeners());
|
|
2583
2704
|
}
|
|
2584
2705
|
}
|
|
2585
|
-
class
|
|
2706
|
+
class bt {
|
|
2586
2707
|
/**
|
|
2587
2708
|
* Creates a new HostComponent instance.
|
|
2588
2709
|
*
|
|
2589
2710
|
* @param payload - The payload parsed from window.name
|
|
2590
2711
|
* @param propDefinitions - Optional prop definitions for deserialization
|
|
2712
|
+
* @param allowedConsumerDomains - Optional allowlist of consumer domains
|
|
2713
|
+
* @param deferInit - Whether to defer INIT until a later explicit flush
|
|
2591
2714
|
*/
|
|
2592
|
-
constructor(e,
|
|
2593
|
-
this.propDefinitions =
|
|
2715
|
+
constructor(e, t = {}, n, i = !1) {
|
|
2716
|
+
this.propDefinitions = t, this.allowedConsumerDomains = n, this.deferInit = i, this.uid = e.uid, this.tag = e.tag, this.consumerDomain = e.consumerDomain, this.validateConsumerDomain(), this.event = new we(), this.messenger = new Ee(this.uid, window, q(), this.consumerDomain), this.setupMessageHandlers(), this.consumerWindow = this.resolveConsumerWindow(), this.bridge = new J(this.messenger), this.hostProps = this.buildHostProps(e), this.exposeHostProps(), this.deferInit || this.flushInit();
|
|
2594
2717
|
}
|
|
2595
2718
|
/** The hostProps object containing props and control methods passed from the consumer. */
|
|
2596
2719
|
hostProps;
|
|
@@ -2614,6 +2737,59 @@ class yt {
|
|
|
2614
2737
|
consumerProps;
|
|
2615
2738
|
/** @internal */
|
|
2616
2739
|
initError = null;
|
|
2740
|
+
/** @internal */
|
|
2741
|
+
destroyed = !1;
|
|
2742
|
+
/** @internal */
|
|
2743
|
+
initSent = !1;
|
|
2744
|
+
/** @internal */
|
|
2745
|
+
deferredInitFlushScheduled = !1;
|
|
2746
|
+
/**
|
|
2747
|
+
* Ensures the INIT handshake is sent at most once.
|
|
2748
|
+
* @internal
|
|
2749
|
+
*/
|
|
2750
|
+
flushInit() {
|
|
2751
|
+
this.destroyed || this.initSent || (this.initSent = !0, this.sendInit());
|
|
2752
|
+
}
|
|
2753
|
+
/**
|
|
2754
|
+
* Schedules deferred INIT flush on the next microtask.
|
|
2755
|
+
* This preserves legacy hostProps-only usage while giving same-tick
|
|
2756
|
+
* host configuration a chance to run allowlist checks first.
|
|
2757
|
+
* @internal
|
|
2758
|
+
*/
|
|
2759
|
+
scheduleDeferredInitFlush() {
|
|
2760
|
+
this.deferredInitFlushScheduled || this.destroyed || this.initSent || (this.deferredInitFlushScheduled = !0, queueMicrotask(() => {
|
|
2761
|
+
this.deferredInitFlushScheduled = !1, this.flushInit();
|
|
2762
|
+
}));
|
|
2763
|
+
}
|
|
2764
|
+
/**
|
|
2765
|
+
* Exposes hostProps on window and lazily flushes deferred init on first access.
|
|
2766
|
+
* @internal
|
|
2767
|
+
*/
|
|
2768
|
+
exposeHostProps() {
|
|
2769
|
+
const e = window;
|
|
2770
|
+
try {
|
|
2771
|
+
Object.defineProperty(e, "hostProps", {
|
|
2772
|
+
configurable: !0,
|
|
2773
|
+
enumerable: !0,
|
|
2774
|
+
get: () => (this.deferInit && !this.initSent && !this.destroyed && this.scheduleDeferredInitFlush(), this.hostProps),
|
|
2775
|
+
set: (t) => {
|
|
2776
|
+
t && (this.hostProps = t);
|
|
2777
|
+
}
|
|
2778
|
+
});
|
|
2779
|
+
} catch {
|
|
2780
|
+
e.hostProps = this.hostProps;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
/**
|
|
2784
|
+
* Validates that the consumer domain is allowed.
|
|
2785
|
+
* @internal
|
|
2786
|
+
*/
|
|
2787
|
+
validateConsumerDomain() {
|
|
2788
|
+
if (this.allowedConsumerDomains && !L(this.allowedConsumerDomains, this.consumerDomain))
|
|
2789
|
+
throw new Error(
|
|
2790
|
+
`Consumer domain "${this.consumerDomain}" is not allowed for component "${this.tag}"`
|
|
2791
|
+
);
|
|
2792
|
+
}
|
|
2617
2793
|
/**
|
|
2618
2794
|
* Returns the hostProps object.
|
|
2619
2795
|
*
|
|
@@ -2627,12 +2803,12 @@ class yt {
|
|
|
2627
2803
|
* @internal
|
|
2628
2804
|
*/
|
|
2629
2805
|
resolveConsumerWindow() {
|
|
2630
|
-
if (
|
|
2631
|
-
const e =
|
|
2806
|
+
if (Ue()) {
|
|
2807
|
+
const e = Ae();
|
|
2632
2808
|
if (e) return e;
|
|
2633
2809
|
}
|
|
2634
|
-
if (
|
|
2635
|
-
const e =
|
|
2810
|
+
if (Me()) {
|
|
2811
|
+
const e = He();
|
|
2636
2812
|
if (e) return e;
|
|
2637
2813
|
}
|
|
2638
2814
|
throw new Error("Could not resolve consumer window");
|
|
@@ -2642,7 +2818,7 @@ class yt {
|
|
|
2642
2818
|
* @internal
|
|
2643
2819
|
*/
|
|
2644
2820
|
buildHostProps(e) {
|
|
2645
|
-
const
|
|
2821
|
+
const t = me(
|
|
2646
2822
|
e.props,
|
|
2647
2823
|
this.propDefinitions,
|
|
2648
2824
|
this.messenger,
|
|
@@ -2650,8 +2826,8 @@ class yt {
|
|
|
2650
2826
|
this.consumerWindow,
|
|
2651
2827
|
this.consumerDomain
|
|
2652
2828
|
);
|
|
2653
|
-
return this.consumerProps =
|
|
2654
|
-
...
|
|
2829
|
+
return this.consumerProps = t, {
|
|
2830
|
+
...t,
|
|
2655
2831
|
uid: this.uid,
|
|
2656
2832
|
tag: this.tag,
|
|
2657
2833
|
close: () => this.close(),
|
|
@@ -2685,11 +2861,11 @@ class yt {
|
|
|
2685
2861
|
{ uid: this.uid, tag: this.tag }
|
|
2686
2862
|
);
|
|
2687
2863
|
} catch (e) {
|
|
2688
|
-
const
|
|
2689
|
-
this.initError =
|
|
2864
|
+
const t = e instanceof Error ? e : new Error(String(e));
|
|
2865
|
+
this.initError = t, this.event.emit(f.ERROR, {
|
|
2690
2866
|
type: "init_failed",
|
|
2691
|
-
message: `Failed to initialize host component: ${
|
|
2692
|
-
error:
|
|
2867
|
+
message: `Failed to initialize host component: ${t.message}`,
|
|
2868
|
+
error: t
|
|
2693
2869
|
}), console.error("Failed to send init message:", e);
|
|
2694
2870
|
}
|
|
2695
2871
|
}
|
|
@@ -2827,10 +3003,10 @@ class yt {
|
|
|
2827
3003
|
*/
|
|
2828
3004
|
buildNestedComponents(e) {
|
|
2829
3005
|
if (!e) return;
|
|
2830
|
-
const
|
|
3006
|
+
const t = {};
|
|
2831
3007
|
for (const [n, i] of Object.entries(e))
|
|
2832
3008
|
try {
|
|
2833
|
-
|
|
3009
|
+
t[n] = xe({
|
|
2834
3010
|
tag: i.tag,
|
|
2835
3011
|
url: i.url,
|
|
2836
3012
|
props: i.props,
|
|
@@ -2840,7 +3016,7 @@ class yt {
|
|
|
2840
3016
|
} catch (r) {
|
|
2841
3017
|
console.warn(`Failed to create nested component "${n}":`, r);
|
|
2842
3018
|
}
|
|
2843
|
-
return Object.keys(
|
|
3019
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
2844
3020
|
}
|
|
2845
3021
|
/**
|
|
2846
3022
|
* Sets up message handlers for consumer communication.
|
|
@@ -2849,7 +3025,7 @@ class yt {
|
|
|
2849
3025
|
setupMessageHandlers() {
|
|
2850
3026
|
this.messenger.on(u.PROPS, (e) => {
|
|
2851
3027
|
try {
|
|
2852
|
-
const
|
|
3028
|
+
const t = me(
|
|
2853
3029
|
e,
|
|
2854
3030
|
this.propDefinitions,
|
|
2855
3031
|
this.messenger,
|
|
@@ -2857,16 +3033,16 @@ class yt {
|
|
|
2857
3033
|
this.consumerWindow,
|
|
2858
3034
|
this.consumerDomain
|
|
2859
3035
|
);
|
|
2860
|
-
Object.assign(this.hostProps,
|
|
3036
|
+
Object.assign(this.hostProps, t);
|
|
2861
3037
|
for (const n of this.propsHandlers)
|
|
2862
3038
|
try {
|
|
2863
|
-
n(
|
|
3039
|
+
n(t);
|
|
2864
3040
|
} catch (i) {
|
|
2865
3041
|
console.error("Error in props handler:", i);
|
|
2866
3042
|
}
|
|
2867
|
-
return this.event.emit(f.PROPS,
|
|
2868
|
-
} catch (
|
|
2869
|
-
const n =
|
|
3043
|
+
return this.event.emit(f.PROPS, t), { success: !0 };
|
|
3044
|
+
} catch (t) {
|
|
3045
|
+
const n = t instanceof Error ? t : new Error(String(t));
|
|
2870
3046
|
throw console.error("Error deserializing props:", n), this.event.emit(f.ERROR, n), n;
|
|
2871
3047
|
}
|
|
2872
3048
|
});
|
|
@@ -2875,145 +3051,172 @@ class yt {
|
|
|
2875
3051
|
* Destroys the host component and cleans up resources.
|
|
2876
3052
|
*/
|
|
2877
3053
|
destroy() {
|
|
2878
|
-
this.messenger.destroy(), this.bridge.destroy(), this.event.removeAllListeners(), this.propsHandlers.clear();
|
|
3054
|
+
this.destroyed || (this.destroyed = !0, this.deferredInitFlushScheduled = !1, this.messenger.destroy(), this.bridge.destroy(), this.event.removeAllListeners(), this.propsHandlers.clear());
|
|
2879
3055
|
}
|
|
2880
3056
|
}
|
|
2881
|
-
let
|
|
2882
|
-
function
|
|
2883
|
-
if (
|
|
2884
|
-
|
|
2885
|
-
|
|
3057
|
+
let g = null;
|
|
3058
|
+
function ne(s, e, t = {}) {
|
|
3059
|
+
if (g) {
|
|
3060
|
+
if (e) {
|
|
3061
|
+
const i = g.getProps().getConsumerDomain();
|
|
3062
|
+
if (!L(e, i))
|
|
3063
|
+
throw vt(), new Error(
|
|
3064
|
+
`Consumer domain "${i}" is not allowed for this host component`
|
|
3065
|
+
);
|
|
3066
|
+
}
|
|
3067
|
+
return t.deferInit || g.flushInit(), g;
|
|
3068
|
+
}
|
|
3069
|
+
if (!X())
|
|
2886
3070
|
return null;
|
|
2887
|
-
const
|
|
2888
|
-
return
|
|
3071
|
+
const n = Ve();
|
|
3072
|
+
return n ? (g = new bt(
|
|
3073
|
+
n,
|
|
3074
|
+
s,
|
|
2889
3075
|
e,
|
|
2890
|
-
t
|
|
2891
|
-
),
|
|
3076
|
+
t.deferInit ?? !1
|
|
3077
|
+
), g) : (console.error("Failed to parse ForgeFrame payload from window.name"), null);
|
|
2892
3078
|
}
|
|
2893
|
-
function
|
|
2894
|
-
return
|
|
3079
|
+
function Pt() {
|
|
3080
|
+
return X();
|
|
2895
3081
|
}
|
|
2896
|
-
function
|
|
2897
|
-
return
|
|
3082
|
+
function Ot() {
|
|
3083
|
+
return X();
|
|
2898
3084
|
}
|
|
2899
|
-
function
|
|
3085
|
+
function Rt() {
|
|
2900
3086
|
return window.hostProps;
|
|
2901
3087
|
}
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
3088
|
+
function vt() {
|
|
3089
|
+
g && (g.destroy(), g = null), delete window.hostProps;
|
|
3090
|
+
}
|
|
3091
|
+
const C = /* @__PURE__ */ new Map(), Se = /* @__PURE__ */ Symbol("forgeframe.component.options");
|
|
3092
|
+
function St(s) {
|
|
3093
|
+
if (!s.tag)
|
|
2905
3094
|
throw new Error("Component tag is required");
|
|
2906
|
-
if (!/^[a-z][a-z0-9-]*$/.test(
|
|
3095
|
+
if (!/^[a-z][a-z0-9-]*$/.test(s.tag))
|
|
2907
3096
|
throw new Error(
|
|
2908
|
-
`Invalid component tag "${
|
|
3097
|
+
`Invalid component tag "${s.tag}". Must start with lowercase letter and contain only lowercase letters, numbers, and hyphens.`
|
|
2909
3098
|
);
|
|
2910
|
-
if (!
|
|
3099
|
+
if (!s.url)
|
|
2911
3100
|
throw new Error("Component url is required");
|
|
2912
|
-
if (typeof
|
|
3101
|
+
if (typeof s.url == "string")
|
|
2913
3102
|
try {
|
|
2914
|
-
new URL(
|
|
3103
|
+
new URL(s.url, window.location.origin);
|
|
2915
3104
|
} catch {
|
|
2916
3105
|
throw new Error(
|
|
2917
|
-
`Invalid component URL "${
|
|
3106
|
+
`Invalid component URL "${s.url}". Must be a valid absolute or relative URL.`
|
|
2918
3107
|
);
|
|
2919
3108
|
}
|
|
2920
|
-
if (
|
|
2921
|
-
throw new Error(`Component "${
|
|
3109
|
+
if (C.has(s.tag))
|
|
3110
|
+
throw new Error(`Component "${s.tag}" is already registered`);
|
|
2922
3111
|
}
|
|
2923
|
-
function
|
|
2924
|
-
|
|
3112
|
+
function xe(s) {
|
|
3113
|
+
St(s);
|
|
2925
3114
|
const e = [];
|
|
2926
|
-
let
|
|
2927
|
-
if (
|
|
2928
|
-
const i =
|
|
2929
|
-
i && (
|
|
3115
|
+
let t;
|
|
3116
|
+
if (W(s.tag)) {
|
|
3117
|
+
const i = ne(s.props, s.allowedConsumerDomains);
|
|
3118
|
+
i && (t = i.hostProps);
|
|
2930
3119
|
}
|
|
2931
3120
|
const n = function(i = {}) {
|
|
2932
|
-
const r = new
|
|
3121
|
+
const r = new se(s, i);
|
|
2933
3122
|
return e.push(r), r.event.once("destroy", () => {
|
|
2934
3123
|
const o = e.indexOf(r);
|
|
2935
3124
|
o !== -1 && e.splice(o, 1);
|
|
2936
3125
|
}), r;
|
|
2937
3126
|
};
|
|
2938
|
-
return n.instances = e, n.isHost = () =>
|
|
3127
|
+
return n.instances = e, n.isHost = () => W(s.tag), n.isEmbedded = () => W(s.tag), n.hostProps = t, n[Se] = s, n.canRenderTo = async (i) => {
|
|
2939
3128
|
try {
|
|
2940
|
-
return !!(
|
|
3129
|
+
return !!(be(i) || s.domain);
|
|
2941
3130
|
} catch {
|
|
2942
3131
|
return !1;
|
|
2943
3132
|
}
|
|
2944
|
-
},
|
|
3133
|
+
}, C.set(s.tag, n), n;
|
|
2945
3134
|
}
|
|
2946
|
-
function
|
|
2947
|
-
return
|
|
3135
|
+
function xt(s) {
|
|
3136
|
+
return C.get(s);
|
|
2948
3137
|
}
|
|
2949
|
-
|
|
2950
|
-
|
|
3138
|
+
function Ct(s) {
|
|
3139
|
+
return s[Se];
|
|
2951
3140
|
}
|
|
2952
|
-
async function
|
|
2953
|
-
|
|
3141
|
+
async function Dt(s) {
|
|
3142
|
+
await s.close();
|
|
3143
|
+
}
|
|
3144
|
+
async function Ce(s) {
|
|
3145
|
+
const e = C.get(s);
|
|
2954
3146
|
if (!e) return;
|
|
2955
|
-
const
|
|
2956
|
-
await Promise.all(
|
|
3147
|
+
const t = [...e.instances];
|
|
3148
|
+
await Promise.all(t.map((n) => n.close()));
|
|
3149
|
+
}
|
|
3150
|
+
async function It() {
|
|
3151
|
+
const s = Array.from(C.keys());
|
|
3152
|
+
await Promise.all(s.map((e) => Ce(e)));
|
|
2957
3153
|
}
|
|
2958
|
-
|
|
2959
|
-
const t =
|
|
2960
|
-
|
|
3154
|
+
function Tt(s, e) {
|
|
3155
|
+
const t = Object.keys(s), n = Object.keys(e);
|
|
3156
|
+
if (t.length !== n.length)
|
|
3157
|
+
return !1;
|
|
3158
|
+
for (const i of t)
|
|
3159
|
+
if (!Object.prototype.hasOwnProperty.call(e, i) || !Object.is(s[i], e[i]))
|
|
3160
|
+
return !1;
|
|
3161
|
+
return !0;
|
|
2961
3162
|
}
|
|
2962
|
-
function
|
|
2963
|
-
const { React:
|
|
2964
|
-
function(
|
|
3163
|
+
function Ft(s, e) {
|
|
3164
|
+
const { React: t } = e, { createElement: n, useRef: i, useEffect: r, useState: o, forwardRef: a } = t, c = a(
|
|
3165
|
+
function(w, _) {
|
|
2965
3166
|
const {
|
|
2966
|
-
onRendered:
|
|
2967
|
-
onError:
|
|
2968
|
-
onClose:
|
|
2969
|
-
context:
|
|
2970
|
-
className:
|
|
2971
|
-
style:
|
|
2972
|
-
...
|
|
2973
|
-
} =
|
|
3167
|
+
onRendered: O,
|
|
3168
|
+
onError: v,
|
|
3169
|
+
onClose: ie,
|
|
3170
|
+
context: De,
|
|
3171
|
+
className: re,
|
|
3172
|
+
style: oe,
|
|
3173
|
+
...H
|
|
3174
|
+
} = w, D = i(null), A = i(null), U = i(null), [ae, Ie] = o(null);
|
|
2974
3175
|
return r(() => {
|
|
2975
|
-
const
|
|
2976
|
-
if (!
|
|
2977
|
-
const
|
|
2978
|
-
return
|
|
2979
|
-
|
|
3176
|
+
const S = D.current;
|
|
3177
|
+
if (!S) return;
|
|
3178
|
+
const m = s(H);
|
|
3179
|
+
return A.current = m, O && m.event.once("rendered", O), ie && m.event.once("close", ie), v && m.event.on("error", v), m.render(S, De).catch((x) => {
|
|
3180
|
+
Ie(x), v?.(x);
|
|
2980
3181
|
}), () => {
|
|
2981
|
-
|
|
2982
|
-
}),
|
|
3182
|
+
m.close().catch(() => {
|
|
3183
|
+
}), A.current = null, U.current = null;
|
|
2983
3184
|
};
|
|
2984
3185
|
}, []), r(() => {
|
|
2985
|
-
const
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
}, [
|
|
3186
|
+
const S = A.current;
|
|
3187
|
+
if (!S) return;
|
|
3188
|
+
const m = H, x = U.current;
|
|
3189
|
+
x && Tt(x, m) || (U.current = m, S.updateProps(m).catch((Te) => {
|
|
3190
|
+
v?.(Te);
|
|
3191
|
+
}));
|
|
3192
|
+
}, [H, v]), r(() => {
|
|
3193
|
+
_ && typeof _ == "object" && D.current && (_.current = D.current);
|
|
3194
|
+
}, [_]), ae ? n(
|
|
2992
3195
|
"div",
|
|
2993
3196
|
{
|
|
2994
|
-
className:
|
|
2995
|
-
style: { color: "red", padding: "16px", ...
|
|
3197
|
+
className: re,
|
|
3198
|
+
style: { color: "red", padding: "16px", ...oe }
|
|
2996
3199
|
},
|
|
2997
|
-
`Error: ${
|
|
3200
|
+
`Error: ${ae.message}`
|
|
2998
3201
|
) : n("div", {
|
|
2999
|
-
ref:
|
|
3000
|
-
className:
|
|
3202
|
+
ref: D,
|
|
3203
|
+
className: re,
|
|
3001
3204
|
style: {
|
|
3002
3205
|
display: "inline-block",
|
|
3003
|
-
...
|
|
3206
|
+
...oe
|
|
3004
3207
|
}
|
|
3005
3208
|
});
|
|
3006
3209
|
}
|
|
3007
|
-
), l = `ForgeFrame(${
|
|
3210
|
+
), l = `ForgeFrame(${s.name || "Component"})`;
|
|
3008
3211
|
return c.displayName = l, c;
|
|
3009
3212
|
}
|
|
3010
|
-
function
|
|
3011
|
-
return function(
|
|
3012
|
-
return
|
|
3213
|
+
function kt(s) {
|
|
3214
|
+
return function(t) {
|
|
3215
|
+
return Ft(t, { React: s });
|
|
3013
3216
|
};
|
|
3014
3217
|
}
|
|
3015
|
-
|
|
3016
|
-
const
|
|
3218
|
+
ne(void 0, void 0, { deferInit: !0 });
|
|
3219
|
+
const $t = {
|
|
3017
3220
|
/**
|
|
3018
3221
|
* Create a new component definition.
|
|
3019
3222
|
*
|
|
@@ -3038,23 +3241,23 @@ const Ct = {
|
|
|
3038
3241
|
* await instance.render('#container');
|
|
3039
3242
|
* ```
|
|
3040
3243
|
*/
|
|
3041
|
-
create:
|
|
3244
|
+
create: xe,
|
|
3042
3245
|
/**
|
|
3043
3246
|
* Destroy a single component instance.
|
|
3044
3247
|
*
|
|
3045
3248
|
* @param instance - The component instance to destroy
|
|
3046
3249
|
*/
|
|
3047
|
-
destroy:
|
|
3250
|
+
destroy: Dt,
|
|
3048
3251
|
/**
|
|
3049
3252
|
* Destroy all instances of a specific component by tag.
|
|
3050
3253
|
*
|
|
3051
3254
|
* @param tag - The component tag name
|
|
3052
3255
|
*/
|
|
3053
|
-
destroyByTag:
|
|
3256
|
+
destroyByTag: Ce,
|
|
3054
3257
|
/**
|
|
3055
3258
|
* Destroy all ForgeFrame component instances.
|
|
3056
3259
|
*/
|
|
3057
|
-
destroyAll:
|
|
3260
|
+
destroyAll: It,
|
|
3058
3261
|
/**
|
|
3059
3262
|
* Check if the current window is a host component context.
|
|
3060
3263
|
*
|
|
@@ -3064,7 +3267,7 @@ const Ct = {
|
|
|
3064
3267
|
*
|
|
3065
3268
|
* @returns True if running inside a ForgeFrame iframe/popup
|
|
3066
3269
|
*/
|
|
3067
|
-
isHost:
|
|
3270
|
+
isHost: Pt,
|
|
3068
3271
|
/**
|
|
3069
3272
|
* Check if the current window is embedded by ForgeFrame.
|
|
3070
3273
|
*
|
|
@@ -3073,7 +3276,7 @@ const Ct = {
|
|
|
3073
3276
|
*
|
|
3074
3277
|
* @returns True if running inside a ForgeFrame iframe/popup
|
|
3075
3278
|
*/
|
|
3076
|
-
isEmbedded:
|
|
3279
|
+
isEmbedded: Ot,
|
|
3077
3280
|
/**
|
|
3078
3281
|
* Get hostProps from the current host window.
|
|
3079
3282
|
*
|
|
@@ -3082,7 +3285,18 @@ const Ct = {
|
|
|
3082
3285
|
*
|
|
3083
3286
|
* @returns The hostProps object if in host context, undefined otherwise
|
|
3084
3287
|
*/
|
|
3085
|
-
getHostProps:
|
|
3288
|
+
getHostProps: Rt,
|
|
3289
|
+
/**
|
|
3290
|
+
* Flush host initialization in embedded contexts.
|
|
3291
|
+
*
|
|
3292
|
+
* @remarks
|
|
3293
|
+
* Only required in host pages that access `window.hostProps` directly
|
|
3294
|
+
* without defining a component via `ForgeFrame.create(...)`.
|
|
3295
|
+
* When `create()` is used on the host side, init is flushed automatically.
|
|
3296
|
+
*
|
|
3297
|
+
* @returns The host component instance if running embedded, otherwise null
|
|
3298
|
+
*/
|
|
3299
|
+
initHost: ne,
|
|
3086
3300
|
/**
|
|
3087
3301
|
* Serialization strategy constants.
|
|
3088
3302
|
* @see {@link PROP_SERIALIZATION}
|
|
@@ -3101,11 +3315,11 @@ const Ct = {
|
|
|
3101
3315
|
/**
|
|
3102
3316
|
* Error thrown when popup window fails to open.
|
|
3103
3317
|
*/
|
|
3104
|
-
PopupOpenError:
|
|
3318
|
+
PopupOpenError: ve,
|
|
3105
3319
|
/**
|
|
3106
3320
|
* Current library version.
|
|
3107
3321
|
*/
|
|
3108
|
-
VERSION:
|
|
3322
|
+
VERSION: ye,
|
|
3109
3323
|
/**
|
|
3110
3324
|
* Check if a value is a Standard Schema (Zod, Valibot, ArkType, etc.)
|
|
3111
3325
|
*
|
|
@@ -3122,7 +3336,7 @@ const Ct = {
|
|
|
3122
3336
|
* }
|
|
3123
3337
|
* ```
|
|
3124
3338
|
*/
|
|
3125
|
-
isStandardSchema:
|
|
3339
|
+
isStandardSchema: b,
|
|
3126
3340
|
/**
|
|
3127
3341
|
* Prop schema builders for defining component props.
|
|
3128
3342
|
*
|
|
@@ -3148,32 +3362,33 @@ const Ct = {
|
|
|
3148
3362
|
prop: d
|
|
3149
3363
|
};
|
|
3150
3364
|
export {
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3365
|
+
te as AnySchema,
|
|
3366
|
+
N as ArraySchema,
|
|
3367
|
+
Y as BooleanSchema,
|
|
3154
3368
|
p as CONTEXT,
|
|
3155
3369
|
f as EVENT,
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3370
|
+
ee as EnumSchema,
|
|
3371
|
+
$t as ForgeFrame,
|
|
3372
|
+
Z as FunctionSchema,
|
|
3373
|
+
Q as LiteralSchema,
|
|
3374
|
+
G as NumberSchema,
|
|
3161
3375
|
k as ObjectSchema,
|
|
3162
3376
|
I as PROP_SERIALIZATION,
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3377
|
+
ve as PopupOpenError,
|
|
3378
|
+
y as PropSchema,
|
|
3379
|
+
K as StringSchema,
|
|
3380
|
+
ye as VERSION,
|
|
3381
|
+
xe as create,
|
|
3382
|
+
Ft as createReactComponent,
|
|
3383
|
+
$t as default,
|
|
3384
|
+
Dt as destroy,
|
|
3385
|
+
It as destroyAll,
|
|
3386
|
+
Ce as destroyByTag,
|
|
3387
|
+
Rt as getHostProps,
|
|
3388
|
+
ne as initHost,
|
|
3389
|
+
Ot as isEmbedded,
|
|
3390
|
+
Pt as isHost,
|
|
3391
|
+
b as isStandardSchema,
|
|
3177
3392
|
d as prop,
|
|
3178
|
-
|
|
3393
|
+
kt as withReactComponent
|
|
3179
3394
|
};
|