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