forgeframe 0.0.2 → 0.0.4
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 +44 -4
- package/dist/communication/bridge.d.ts +2 -2
- package/dist/communication/messenger.d.ts +9 -0
- package/dist/constants.d.ts +1 -5
- package/dist/core/consumer.d.ts +28 -1
- package/dist/forgeframe.js +563 -368
- package/dist/forgeframe.umd.cjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/props/index.d.ts +1 -1
- package/dist/props/normalize.d.ts +11 -0
- package/dist/props/schema.d.ts +11 -3
- package/dist/types.d.ts +9 -4
- package/dist/window/helpers.d.ts +5 -1
- package/package.json +7 -2
package/dist/forgeframe.js
CHANGED
|
@@ -26,19 +26,19 @@ const p = {
|
|
|
26
26
|
RESIZE: "resize",
|
|
27
27
|
/** Emitted when component receives focus */
|
|
28
28
|
FOCUS: "focus"
|
|
29
|
-
},
|
|
29
|
+
}, T = {
|
|
30
30
|
/** Default JSON serialization */
|
|
31
31
|
JSON: "json",
|
|
32
32
|
/** Base64 encoding for binary or large data */
|
|
33
33
|
BASE64: "base64",
|
|
34
34
|
/** Dot notation for nested objects (e.g., "a.b.c=value") */
|
|
35
35
|
DOTIFY: "dotify"
|
|
36
|
-
},
|
|
36
|
+
}, $ = {
|
|
37
37
|
/** Request message expecting a response */
|
|
38
38
|
REQUEST: "request",
|
|
39
39
|
/** Response to a previous request */
|
|
40
40
|
RESPONSE: "response"
|
|
41
|
-
},
|
|
41
|
+
}, u = {
|
|
42
42
|
/** Host initialization complete */
|
|
43
43
|
INIT: "forgeframe_init",
|
|
44
44
|
/** Props update from consumer to host */
|
|
@@ -63,8 +63,14 @@ const p = {
|
|
|
63
63
|
CONSUMER_EXPORT: "forgeframe_consumer_export",
|
|
64
64
|
/** Get sibling components request */
|
|
65
65
|
GET_SIBLINGS: "forgeframe_get_siblings"
|
|
66
|
-
},
|
|
67
|
-
|
|
66
|
+
}, F = "__forgeframe__", _e = (() => {
|
|
67
|
+
if ("0.0.4".trim().length === 0)
|
|
68
|
+
throw new Error(
|
|
69
|
+
"ForgeFrame VERSION injection is missing. Configure __FORGEFRAME_VERSION__ in build/test tooling."
|
|
70
|
+
);
|
|
71
|
+
return "0.0.4";
|
|
72
|
+
})();
|
|
73
|
+
class Ee {
|
|
68
74
|
/**
|
|
69
75
|
* Internal storage for event listeners mapped by event name.
|
|
70
76
|
* @internal
|
|
@@ -215,14 +221,14 @@ class we {
|
|
|
215
221
|
return this.listeners.get(e)?.size ?? 0;
|
|
216
222
|
}
|
|
217
223
|
}
|
|
218
|
-
function
|
|
224
|
+
function He() {
|
|
219
225
|
const s = Date.now().toString(36), e = Math.random().toString(36).slice(2, 11);
|
|
220
226
|
return `${s}_${e}`;
|
|
221
227
|
}
|
|
222
|
-
function
|
|
228
|
+
function N() {
|
|
223
229
|
return Math.random().toString(36).slice(2, 11);
|
|
224
230
|
}
|
|
225
|
-
class
|
|
231
|
+
class Le {
|
|
226
232
|
/**
|
|
227
233
|
* Array of registered cleanup tasks awaiting execution.
|
|
228
234
|
* @internal
|
|
@@ -340,13 +346,13 @@ class Fe {
|
|
|
340
346
|
this.tasks = [], this.cleaned = !1;
|
|
341
347
|
}
|
|
342
348
|
}
|
|
343
|
-
function
|
|
349
|
+
function be() {
|
|
344
350
|
let s, e;
|
|
345
351
|
return { promise: new Promise((n, i) => {
|
|
346
352
|
s = n, e = i;
|
|
347
353
|
}), resolve: s, reject: e };
|
|
348
354
|
}
|
|
349
|
-
function
|
|
355
|
+
function ke(s, e, t = "Operation timed out") {
|
|
350
356
|
return new Promise((n, i) => {
|
|
351
357
|
const r = setTimeout(() => {
|
|
352
358
|
i(new Error(`${t} (${e}ms)`));
|
|
@@ -359,10 +365,10 @@ function $e(s, e, t = "Operation timed out") {
|
|
|
359
365
|
});
|
|
360
366
|
}
|
|
361
367
|
const j = "forgeframe:";
|
|
362
|
-
function
|
|
368
|
+
function W(s) {
|
|
363
369
|
return j + JSON.stringify(s);
|
|
364
370
|
}
|
|
365
|
-
function
|
|
371
|
+
function Ae(s) {
|
|
366
372
|
if (typeof s != "string" || !s.startsWith(j)) return null;
|
|
367
373
|
try {
|
|
368
374
|
const e = s.slice(j.length), t = JSON.parse(e);
|
|
@@ -374,16 +380,16 @@ function ke(s) {
|
|
|
374
380
|
function ce(s, e, t, n) {
|
|
375
381
|
return {
|
|
376
382
|
id: s,
|
|
377
|
-
type:
|
|
383
|
+
type: $.REQUEST,
|
|
378
384
|
name: e,
|
|
379
385
|
data: t,
|
|
380
386
|
source: n
|
|
381
387
|
};
|
|
382
388
|
}
|
|
383
|
-
function
|
|
389
|
+
function Ue(s, e, t, n) {
|
|
384
390
|
return {
|
|
385
391
|
id: s,
|
|
386
|
-
type:
|
|
392
|
+
type: $.RESPONSE,
|
|
387
393
|
name: "response",
|
|
388
394
|
data: e,
|
|
389
395
|
source: t,
|
|
@@ -393,7 +399,19 @@ function Le(s, e, t, n) {
|
|
|
393
399
|
} : void 0
|
|
394
400
|
};
|
|
395
401
|
}
|
|
396
|
-
|
|
402
|
+
function Me(s) {
|
|
403
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
404
|
+
}
|
|
405
|
+
function We(s) {
|
|
406
|
+
if (!s.includes("*"))
|
|
407
|
+
return null;
|
|
408
|
+
const e = s.split("*").map((t) => Me(t)).join(".*");
|
|
409
|
+
return new RegExp(`^${e}$`);
|
|
410
|
+
}
|
|
411
|
+
function ze(s, e) {
|
|
412
|
+
return s.global || s.sticky ? new RegExp(s.source, s.flags.replace(/[gy]/g, "")).test(e) : s.test(e);
|
|
413
|
+
}
|
|
414
|
+
class Pe {
|
|
397
415
|
/**
|
|
398
416
|
* Creates a new Messenger instance.
|
|
399
417
|
*
|
|
@@ -417,6 +435,10 @@ class Ee {
|
|
|
417
435
|
allowedOrigins = /* @__PURE__ */ new Set();
|
|
418
436
|
/** @internal */
|
|
419
437
|
allowedOriginPatterns = [];
|
|
438
|
+
/** @internal */
|
|
439
|
+
wildcardPatternRegistry = /* @__PURE__ */ new Map();
|
|
440
|
+
/** @internal */
|
|
441
|
+
sourceUidRegistry = /* @__PURE__ */ new WeakMap();
|
|
420
442
|
/**
|
|
421
443
|
* Adds a trusted domain that can send messages to this messenger.
|
|
422
444
|
*
|
|
@@ -425,8 +447,13 @@ class Ee {
|
|
|
425
447
|
addTrustedDomain(e) {
|
|
426
448
|
if (Array.isArray(e))
|
|
427
449
|
for (const t of e)
|
|
428
|
-
this.
|
|
429
|
-
else e instanceof RegExp
|
|
450
|
+
this.addTrustedDomain(t);
|
|
451
|
+
else if (e instanceof RegExp)
|
|
452
|
+
this.allowedOriginPatterns.push(e);
|
|
453
|
+
else {
|
|
454
|
+
const t = We(e);
|
|
455
|
+
t ? this.wildcardPatternRegistry.has(e) || (this.wildcardPatternRegistry.set(e, t), this.allowedOriginPatterns.push(t)) : this.allowedOrigins.add(e);
|
|
456
|
+
}
|
|
430
457
|
}
|
|
431
458
|
/**
|
|
432
459
|
* Removes a trusted domain from this messenger.
|
|
@@ -436,8 +463,15 @@ class Ee {
|
|
|
436
463
|
removeTrustedDomain(e) {
|
|
437
464
|
if (Array.isArray(e))
|
|
438
465
|
for (const t of e)
|
|
439
|
-
this.
|
|
440
|
-
else e instanceof RegExp
|
|
466
|
+
this.removeTrustedDomain(t);
|
|
467
|
+
else if (e instanceof RegExp)
|
|
468
|
+
this.allowedOriginPatterns = this.allowedOriginPatterns.filter((t) => t !== e);
|
|
469
|
+
else {
|
|
470
|
+
const t = this.wildcardPatternRegistry.get(e);
|
|
471
|
+
t && (this.allowedOriginPatterns = this.allowedOriginPatterns.filter(
|
|
472
|
+
(n) => n !== t
|
|
473
|
+
), this.wildcardPatternRegistry.delete(e)), this.allowedOrigins.delete(e);
|
|
474
|
+
}
|
|
441
475
|
}
|
|
442
476
|
/**
|
|
443
477
|
* Checks if an origin is trusted.
|
|
@@ -450,10 +484,21 @@ class Ee {
|
|
|
450
484
|
if (this.allowedOrigins.has(e))
|
|
451
485
|
return !0;
|
|
452
486
|
for (const t of this.allowedOriginPatterns)
|
|
453
|
-
if (t
|
|
487
|
+
if (ze(t, e))
|
|
454
488
|
return !0;
|
|
455
489
|
return !1;
|
|
456
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* Resolves source identity from the browser event context.
|
|
493
|
+
* @internal
|
|
494
|
+
*/
|
|
495
|
+
resolveVerifiedSource(e, t, n) {
|
|
496
|
+
const i = e, r = this.sourceUidRegistry.get(i);
|
|
497
|
+
if (r)
|
|
498
|
+
return { uid: r, domain: t };
|
|
499
|
+
const o = n && typeof n.uid == "string" && n.uid.length > 0 ? n.uid : N();
|
|
500
|
+
return this.sourceUidRegistry.set(i, o), { uid: o, domain: t };
|
|
501
|
+
}
|
|
457
502
|
/**
|
|
458
503
|
* Sends a message and waits for a response.
|
|
459
504
|
*
|
|
@@ -470,10 +515,10 @@ class Ee {
|
|
|
470
515
|
async send(e, t, n, i, r = 1e4) {
|
|
471
516
|
if (this.destroyed)
|
|
472
517
|
throw new Error("Messenger has been destroyed");
|
|
473
|
-
const o =
|
|
518
|
+
const o = N(), a = ce(o, n, i, {
|
|
474
519
|
uid: this.uid,
|
|
475
520
|
domain: this.domain
|
|
476
|
-
}), c =
|
|
521
|
+
}), c = be(), l = setTimeout(() => {
|
|
477
522
|
this.pending.delete(o), c.reject(new Error(`Message "${n}" timed out after ${r}ms`));
|
|
478
523
|
}, r);
|
|
479
524
|
this.pending.set(o, {
|
|
@@ -481,9 +526,9 @@ class Ee {
|
|
|
481
526
|
timeout: l
|
|
482
527
|
});
|
|
483
528
|
try {
|
|
484
|
-
e.postMessage(
|
|
485
|
-
} catch (
|
|
486
|
-
throw this.pending.delete(o), clearTimeout(l),
|
|
529
|
+
e.postMessage(W(a), t);
|
|
530
|
+
} catch (h) {
|
|
531
|
+
throw this.pending.delete(o), clearTimeout(l), h;
|
|
487
532
|
}
|
|
488
533
|
return c.promise;
|
|
489
534
|
}
|
|
@@ -500,11 +545,11 @@ class Ee {
|
|
|
500
545
|
post(e, t, n, i) {
|
|
501
546
|
if (this.destroyed)
|
|
502
547
|
throw new Error("Messenger has been destroyed");
|
|
503
|
-
const r =
|
|
548
|
+
const r = N(), o = ce(r, n, i, {
|
|
504
549
|
uid: this.uid,
|
|
505
550
|
domain: this.domain
|
|
506
551
|
});
|
|
507
|
-
e.postMessage(
|
|
552
|
+
e.postMessage(W(o), t);
|
|
508
553
|
}
|
|
509
554
|
/**
|
|
510
555
|
* Registers a handler for incoming messages of a specific type.
|
|
@@ -526,8 +571,10 @@ class Ee {
|
|
|
526
571
|
this.listener = (e) => {
|
|
527
572
|
if (e.source === this.win || !this.isOriginTrusted(e.origin))
|
|
528
573
|
return;
|
|
529
|
-
const t =
|
|
530
|
-
|
|
574
|
+
const t = Ae(e.data);
|
|
575
|
+
if (!t) return;
|
|
576
|
+
const n = e.source;
|
|
577
|
+
!n || typeof n.postMessage != "function" || this.handleMessage(t, n, e.origin);
|
|
531
578
|
}, this.win.addEventListener("message", this.listener);
|
|
532
579
|
}
|
|
533
580
|
/**
|
|
@@ -535,7 +582,7 @@ class Ee {
|
|
|
535
582
|
* @internal
|
|
536
583
|
*/
|
|
537
584
|
async handleMessage(e, t, n) {
|
|
538
|
-
if (e.type ===
|
|
585
|
+
if (e.type === $.RESPONSE) {
|
|
539
586
|
const i = this.pending.get(e.id);
|
|
540
587
|
if (i)
|
|
541
588
|
if (this.pending.delete(e.id), clearTimeout(i.timeout), e.error) {
|
|
@@ -545,24 +592,29 @@ class Ee {
|
|
|
545
592
|
i.deferred.resolve(e.data);
|
|
546
593
|
return;
|
|
547
594
|
}
|
|
548
|
-
if (e.type ===
|
|
595
|
+
if (e.type === $.REQUEST) {
|
|
549
596
|
const i = this.handlers.get(e.name);
|
|
550
597
|
if (!i)
|
|
551
598
|
return;
|
|
552
599
|
let r, o;
|
|
553
600
|
try {
|
|
554
|
-
|
|
601
|
+
const c = this.resolveVerifiedSource(
|
|
602
|
+
t,
|
|
603
|
+
n,
|
|
604
|
+
e.source
|
|
605
|
+
);
|
|
606
|
+
r = await i(e.data, c);
|
|
555
607
|
} catch (c) {
|
|
556
608
|
o = c instanceof Error ? c : new Error(String(c));
|
|
557
609
|
}
|
|
558
|
-
const a =
|
|
610
|
+
const a = Ue(
|
|
559
611
|
e.id,
|
|
560
612
|
r,
|
|
561
613
|
{ uid: this.uid, domain: this.domain },
|
|
562
614
|
o
|
|
563
615
|
);
|
|
564
616
|
try {
|
|
565
|
-
t.postMessage(
|
|
617
|
+
t.postMessage(W(a), n);
|
|
566
618
|
} catch {
|
|
567
619
|
}
|
|
568
620
|
}
|
|
@@ -623,7 +675,7 @@ class J {
|
|
|
623
675
|
const i = this.localFunctions.keys().next().value;
|
|
624
676
|
i && this.localFunctions.delete(i);
|
|
625
677
|
}
|
|
626
|
-
const n =
|
|
678
|
+
const n = N();
|
|
627
679
|
return this.localFunctions.set(n, e), this.currentBatchIds.add(n), {
|
|
628
680
|
__type__: "function",
|
|
629
681
|
__id__: n,
|
|
@@ -649,7 +701,7 @@ class J {
|
|
|
649
701
|
const a = this.remoteFunctions.keys().next().value;
|
|
650
702
|
a && this.remoteFunctions.delete(a);
|
|
651
703
|
}
|
|
652
|
-
const o = async (...a) => this.messenger.send(t, n,
|
|
704
|
+
const o = async (...a) => this.messenger.send(t, n, u.CALL, {
|
|
653
705
|
id: e.__id__,
|
|
654
706
|
args: a
|
|
655
707
|
});
|
|
@@ -673,7 +725,7 @@ class J {
|
|
|
673
725
|
*/
|
|
674
726
|
setupCallHandler() {
|
|
675
727
|
this.messenger.on(
|
|
676
|
-
|
|
728
|
+
u.CALL,
|
|
677
729
|
async ({ id: e, args: t }) => {
|
|
678
730
|
const n = this.localFunctions.get(e);
|
|
679
731
|
if (!n)
|
|
@@ -762,58 +814,93 @@ function B(s, e, t = /* @__PURE__ */ new WeakSet()) {
|
|
|
762
814
|
if (Array.isArray(s)) {
|
|
763
815
|
if (t.has(s))
|
|
764
816
|
throw new Error("Circular reference detected in props - arrays cannot contain circular references");
|
|
765
|
-
|
|
817
|
+
t.add(s);
|
|
818
|
+
try {
|
|
819
|
+
return s.map((n) => B(n, e, t));
|
|
820
|
+
} finally {
|
|
821
|
+
t.delete(s);
|
|
822
|
+
}
|
|
766
823
|
}
|
|
767
824
|
if (typeof s == "object" && s !== null) {
|
|
768
825
|
if (t.has(s))
|
|
769
826
|
throw new Error("Circular reference detected in props - objects cannot contain circular references");
|
|
770
827
|
t.add(s);
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
828
|
+
try {
|
|
829
|
+
const n = {};
|
|
830
|
+
for (const [i, r] of Object.entries(s))
|
|
831
|
+
n[i] = B(r, e, t);
|
|
832
|
+
return n;
|
|
833
|
+
} finally {
|
|
834
|
+
t.delete(s);
|
|
835
|
+
}
|
|
775
836
|
}
|
|
776
837
|
return s;
|
|
777
838
|
}
|
|
778
|
-
function
|
|
839
|
+
function V(s, e, t, n, i = /* @__PURE__ */ new WeakSet()) {
|
|
779
840
|
if (J.isFunctionRef(s))
|
|
780
841
|
return e.deserialize(s, t, n);
|
|
781
842
|
if (Array.isArray(s)) {
|
|
782
843
|
if (i.has(s))
|
|
783
844
|
throw new Error("Circular reference detected in serialized props");
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
845
|
+
i.add(s);
|
|
846
|
+
try {
|
|
847
|
+
return s.map(
|
|
848
|
+
(r) => V(r, e, t, n, i)
|
|
849
|
+
);
|
|
850
|
+
} finally {
|
|
851
|
+
i.delete(s);
|
|
852
|
+
}
|
|
787
853
|
}
|
|
788
854
|
if (typeof s == "object" && s !== null) {
|
|
789
855
|
if (i.has(s))
|
|
790
856
|
throw new Error("Circular reference detected in serialized props");
|
|
791
857
|
i.add(s);
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
858
|
+
try {
|
|
859
|
+
const r = {};
|
|
860
|
+
for (const [o, a] of Object.entries(s))
|
|
861
|
+
r[o] = V(a, e, t, n, i);
|
|
862
|
+
return r;
|
|
863
|
+
} finally {
|
|
864
|
+
i.delete(s);
|
|
865
|
+
}
|
|
796
866
|
}
|
|
797
867
|
return s;
|
|
798
868
|
}
|
|
799
|
-
function
|
|
869
|
+
function je(s) {
|
|
870
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
871
|
+
}
|
|
872
|
+
function Be(s) {
|
|
873
|
+
if (!s.includes("*"))
|
|
874
|
+
return null;
|
|
875
|
+
const e = s.split("*").map((t) => je(t)).join(".*");
|
|
876
|
+
return new RegExp(`^${e}$`);
|
|
877
|
+
}
|
|
878
|
+
function Ve(s, e) {
|
|
879
|
+
return s.global || s.sticky ? new RegExp(s.source, s.flags.replace(/[gy]/g, "")).test(e) : s.test(e);
|
|
880
|
+
}
|
|
881
|
+
function q(s = window) {
|
|
800
882
|
try {
|
|
801
883
|
return s.location.origin;
|
|
802
884
|
} catch {
|
|
803
885
|
return "";
|
|
804
886
|
}
|
|
805
887
|
}
|
|
806
|
-
function
|
|
888
|
+
function Re(s, e = window) {
|
|
807
889
|
try {
|
|
808
890
|
return s.location.origin === e.location.origin;
|
|
809
891
|
} catch {
|
|
810
892
|
return !1;
|
|
811
893
|
}
|
|
812
894
|
}
|
|
813
|
-
function
|
|
814
|
-
|
|
895
|
+
function D(s, e) {
|
|
896
|
+
if (typeof s == "string") {
|
|
897
|
+
if (s === "*") return !0;
|
|
898
|
+
const t = Be(s);
|
|
899
|
+
return t ? t.test(e) : s === e;
|
|
900
|
+
}
|
|
901
|
+
return s instanceof RegExp ? Ve(s, e) : Array.isArray(s) ? s.some((t) => D(t, e)) : !1;
|
|
815
902
|
}
|
|
816
|
-
function
|
|
903
|
+
function Oe(s) {
|
|
817
904
|
if (!s) return !0;
|
|
818
905
|
try {
|
|
819
906
|
return s.closed;
|
|
@@ -821,14 +908,14 @@ function Pe(s) {
|
|
|
821
908
|
return !0;
|
|
822
909
|
}
|
|
823
910
|
}
|
|
824
|
-
function
|
|
911
|
+
function qe(s = window) {
|
|
825
912
|
try {
|
|
826
913
|
return s.opener;
|
|
827
914
|
} catch {
|
|
828
915
|
return null;
|
|
829
916
|
}
|
|
830
917
|
}
|
|
831
|
-
function
|
|
918
|
+
function Je(s = window) {
|
|
832
919
|
try {
|
|
833
920
|
const e = s.parent;
|
|
834
921
|
return e && e !== s ? e : null;
|
|
@@ -836,54 +923,54 @@ function Ae(s = window) {
|
|
|
836
923
|
return null;
|
|
837
924
|
}
|
|
838
925
|
}
|
|
839
|
-
function
|
|
926
|
+
function Xe(s = window) {
|
|
840
927
|
try {
|
|
841
928
|
return s.parent !== s;
|
|
842
929
|
} catch {
|
|
843
930
|
return !0;
|
|
844
931
|
}
|
|
845
932
|
}
|
|
846
|
-
function
|
|
933
|
+
function Ke(s = window) {
|
|
847
934
|
try {
|
|
848
935
|
return s.opener !== null && s.opener !== void 0;
|
|
849
936
|
} catch {
|
|
850
937
|
return !1;
|
|
851
938
|
}
|
|
852
939
|
}
|
|
853
|
-
const
|
|
854
|
-
function
|
|
855
|
-
const e =
|
|
856
|
-
return `${
|
|
940
|
+
const ue = 32 * 1024;
|
|
941
|
+
function Ye(s) {
|
|
942
|
+
const e = Ge(s);
|
|
943
|
+
return `${F}${e}`;
|
|
857
944
|
}
|
|
858
|
-
function
|
|
859
|
-
if (!s || !s.startsWith(
|
|
945
|
+
function xe(s) {
|
|
946
|
+
if (!s || !s.startsWith(F))
|
|
860
947
|
return null;
|
|
861
|
-
const e = s.slice(
|
|
862
|
-
return
|
|
948
|
+
const e = s.slice(F.length);
|
|
949
|
+
return Ze(e);
|
|
863
950
|
}
|
|
864
951
|
function X(s = window) {
|
|
865
952
|
try {
|
|
866
|
-
return s.name.startsWith(
|
|
953
|
+
return s.name.startsWith(F);
|
|
867
954
|
} catch {
|
|
868
955
|
return !1;
|
|
869
956
|
}
|
|
870
957
|
}
|
|
871
|
-
function
|
|
872
|
-
return
|
|
958
|
+
function z(s, e = window) {
|
|
959
|
+
return xe(e.name)?.tag === s;
|
|
873
960
|
}
|
|
874
|
-
function
|
|
961
|
+
function Ge(s) {
|
|
875
962
|
try {
|
|
876
963
|
const e = JSON.stringify(s), t = btoa(encodeURIComponent(e)), n = new Blob([t]).size;
|
|
877
|
-
if (n >
|
|
964
|
+
if (n > ue)
|
|
878
965
|
throw new Error(
|
|
879
|
-
`Payload size (${Math.round(n / 1024)}KB) exceeds maximum allowed size (${
|
|
966
|
+
`Payload size (${Math.round(n / 1024)}KB) exceeds maximum allowed size (${ue / 1024}KB). Consider reducing the amount of data passed via props.`
|
|
880
967
|
);
|
|
881
968
|
return t;
|
|
882
969
|
} catch (e) {
|
|
883
970
|
throw e instanceof Error && e.message.includes("Payload size") ? e : new Error(`Failed to encode payload: ${e}`);
|
|
884
971
|
}
|
|
885
972
|
}
|
|
886
|
-
function
|
|
973
|
+
function Ze(s) {
|
|
887
974
|
try {
|
|
888
975
|
const e = decodeURIComponent(atob(s));
|
|
889
976
|
return JSON.parse(e);
|
|
@@ -891,11 +978,11 @@ function je(s) {
|
|
|
891
978
|
return null;
|
|
892
979
|
}
|
|
893
980
|
}
|
|
894
|
-
function
|
|
981
|
+
function Qe(s) {
|
|
895
982
|
return {
|
|
896
983
|
uid: s.uid,
|
|
897
984
|
tag: s.tag,
|
|
898
|
-
version:
|
|
985
|
+
version: _e,
|
|
899
986
|
context: s.context,
|
|
900
987
|
consumerDomain: s.consumerDomain,
|
|
901
988
|
props: s.props,
|
|
@@ -903,27 +990,30 @@ function Be(s) {
|
|
|
903
990
|
children: s.children
|
|
904
991
|
};
|
|
905
992
|
}
|
|
906
|
-
function
|
|
907
|
-
return
|
|
993
|
+
function et(s = window) {
|
|
994
|
+
return xe(s.name);
|
|
908
995
|
}
|
|
909
|
-
const
|
|
910
|
-
function
|
|
996
|
+
const he = 100, E = /* @__PURE__ */ new Map();
|
|
997
|
+
function tt() {
|
|
911
998
|
const s = [];
|
|
912
999
|
for (const [e, t] of E.entries())
|
|
913
|
-
|
|
1000
|
+
Oe(t) && s.push(e);
|
|
914
1001
|
for (const e of s)
|
|
915
1002
|
E.delete(e);
|
|
916
1003
|
}
|
|
917
|
-
function
|
|
918
|
-
if (E.size >=
|
|
1004
|
+
function st(s, e) {
|
|
1005
|
+
if (E.size >= he && tt(), E.size >= he) {
|
|
919
1006
|
const t = E.keys().next().value;
|
|
920
1007
|
t && E.delete(t);
|
|
921
1008
|
}
|
|
922
1009
|
E.set(s, e);
|
|
923
1010
|
}
|
|
924
|
-
function
|
|
1011
|
+
function nt(s) {
|
|
925
1012
|
E.delete(s);
|
|
926
1013
|
}
|
|
1014
|
+
function it(s, e) {
|
|
1015
|
+
return s.global || s.sticky ? new RegExp(s.source, s.flags.replace(/[gy]/g, "")).test(e) : s.test(e);
|
|
1016
|
+
}
|
|
927
1017
|
class y {
|
|
928
1018
|
/** @internal */
|
|
929
1019
|
_optional = !1;
|
|
@@ -1017,7 +1107,7 @@ class K extends y {
|
|
|
1017
1107
|
issues: [
|
|
1018
1108
|
{ message: `String must be at most ${this._maxLength} characters` }
|
|
1019
1109
|
]
|
|
1020
|
-
} : this._pattern && !this._pattern
|
|
1110
|
+
} : this._pattern && !it(this._pattern, t) ? {
|
|
1021
1111
|
issues: [
|
|
1022
1112
|
{
|
|
1023
1113
|
message: this._patternMessage || `String must match pattern ${this._pattern}`
|
|
@@ -1247,7 +1337,7 @@ class Y extends y {
|
|
|
1247
1337
|
return e._max = -Number.MIN_VALUE, e;
|
|
1248
1338
|
}
|
|
1249
1339
|
}
|
|
1250
|
-
class
|
|
1340
|
+
class G extends y {
|
|
1251
1341
|
/** @internal */
|
|
1252
1342
|
_validate(e) {
|
|
1253
1343
|
return typeof e != "boolean" ? {
|
|
@@ -1256,11 +1346,11 @@ class Z extends y {
|
|
|
1256
1346
|
}
|
|
1257
1347
|
/** @internal */
|
|
1258
1348
|
_clone() {
|
|
1259
|
-
const e = new
|
|
1349
|
+
const e = new G();
|
|
1260
1350
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
|
|
1261
1351
|
}
|
|
1262
1352
|
}
|
|
1263
|
-
class
|
|
1353
|
+
class Z extends y {
|
|
1264
1354
|
/** @internal */
|
|
1265
1355
|
_validate(e) {
|
|
1266
1356
|
return typeof e != "function" ? {
|
|
@@ -1269,11 +1359,11 @@ class G extends y {
|
|
|
1269
1359
|
}
|
|
1270
1360
|
/** @internal */
|
|
1271
1361
|
_clone() {
|
|
1272
|
-
const e = new
|
|
1362
|
+
const e = new Z();
|
|
1273
1363
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
|
|
1274
1364
|
}
|
|
1275
1365
|
}
|
|
1276
|
-
class
|
|
1366
|
+
class H extends y {
|
|
1277
1367
|
/** @internal */
|
|
1278
1368
|
_itemSchema;
|
|
1279
1369
|
/** @internal */
|
|
@@ -1321,7 +1411,7 @@ class F extends y {
|
|
|
1321
1411
|
}
|
|
1322
1412
|
/** @internal */
|
|
1323
1413
|
_clone() {
|
|
1324
|
-
const e = new
|
|
1414
|
+
const e = new H();
|
|
1325
1415
|
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;
|
|
1326
1416
|
}
|
|
1327
1417
|
/**
|
|
@@ -1337,7 +1427,7 @@ class F extends y {
|
|
|
1337
1427
|
* ```
|
|
1338
1428
|
*/
|
|
1339
1429
|
of(e) {
|
|
1340
|
-
const t = new
|
|
1430
|
+
const t = new H();
|
|
1341
1431
|
return t._optional = this._optional, t._nullable = this._nullable, t._itemSchema = e, t._minLength = this._minLength, t._maxLength = this._maxLength, t;
|
|
1342
1432
|
}
|
|
1343
1433
|
/**
|
|
@@ -1380,7 +1470,7 @@ class F extends y {
|
|
|
1380
1470
|
return this.min(1);
|
|
1381
1471
|
}
|
|
1382
1472
|
}
|
|
1383
|
-
class
|
|
1473
|
+
class L extends y {
|
|
1384
1474
|
/** @internal */
|
|
1385
1475
|
_shape;
|
|
1386
1476
|
/** @internal */
|
|
@@ -1429,7 +1519,7 @@ class $ extends y {
|
|
|
1429
1519
|
}
|
|
1430
1520
|
/** @internal */
|
|
1431
1521
|
_clone() {
|
|
1432
|
-
const e = new
|
|
1522
|
+
const e = new L();
|
|
1433
1523
|
return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._shape = this._shape, e._strict = this._strict, e;
|
|
1434
1524
|
}
|
|
1435
1525
|
/**
|
|
@@ -1447,7 +1537,7 @@ class $ extends y {
|
|
|
1447
1537
|
* ```
|
|
1448
1538
|
*/
|
|
1449
1539
|
shape(e) {
|
|
1450
|
-
const t = new
|
|
1540
|
+
const t = new L();
|
|
1451
1541
|
return t._optional = this._optional, t._nullable = this._nullable, t._shape = e, t._strict = this._strict, t;
|
|
1452
1542
|
}
|
|
1453
1543
|
/**
|
|
@@ -1552,7 +1642,7 @@ const d = {
|
|
|
1552
1642
|
* prop.boolean().default(false)
|
|
1553
1643
|
* ```
|
|
1554
1644
|
*/
|
|
1555
|
-
boolean: () => new
|
|
1645
|
+
boolean: () => new G(),
|
|
1556
1646
|
/**
|
|
1557
1647
|
* Creates a function schema.
|
|
1558
1648
|
*
|
|
@@ -1565,7 +1655,7 @@ const d = {
|
|
|
1565
1655
|
* prop.function<(data: { id: string }) => Promise<void>>()
|
|
1566
1656
|
* ```
|
|
1567
1657
|
*/
|
|
1568
|
-
function: () => new
|
|
1658
|
+
function: () => new Z(),
|
|
1569
1659
|
/**
|
|
1570
1660
|
* Creates an array schema.
|
|
1571
1661
|
*
|
|
@@ -1578,7 +1668,7 @@ const d = {
|
|
|
1578
1668
|
* prop.array().of(prop.number()).min(1).max(10)
|
|
1579
1669
|
* ```
|
|
1580
1670
|
*/
|
|
1581
|
-
array: () => new
|
|
1671
|
+
array: () => new H(),
|
|
1582
1672
|
/**
|
|
1583
1673
|
* Creates an object schema.
|
|
1584
1674
|
*
|
|
@@ -1594,7 +1684,7 @@ const d = {
|
|
|
1594
1684
|
* prop.object().shape({ key: prop.string() }).strict()
|
|
1595
1685
|
* ```
|
|
1596
1686
|
*/
|
|
1597
|
-
object: () => new
|
|
1687
|
+
object: () => new L(),
|
|
1598
1688
|
/**
|
|
1599
1689
|
* Creates a literal schema for exact value matching.
|
|
1600
1690
|
*
|
|
@@ -1632,7 +1722,7 @@ const d = {
|
|
|
1632
1722
|
* ```
|
|
1633
1723
|
*/
|
|
1634
1724
|
any: () => new te()
|
|
1635
|
-
},
|
|
1725
|
+
}, P = {
|
|
1636
1726
|
uid: {
|
|
1637
1727
|
schema: d.string().optional(),
|
|
1638
1728
|
sendToHost: !0
|
|
@@ -1700,54 +1790,62 @@ const d = {
|
|
|
1700
1790
|
}
|
|
1701
1791
|
};
|
|
1702
1792
|
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";
|
|
1793
|
+
return typeof s == "object" && s !== null && "~standard" in s && typeof s["~standard"] == "object" && s["~standard"] !== null && s["~standard"].version === 1 && typeof s["~standard"].vendor == "string" && typeof s["~standard"].validate == "function";
|
|
1704
1794
|
}
|
|
1705
|
-
function
|
|
1795
|
+
function rt(s, e, t) {
|
|
1706
1796
|
const n = s["~standard"].validate(e);
|
|
1707
1797
|
if (n instanceof Promise)
|
|
1708
1798
|
throw new Error(
|
|
1709
1799
|
`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.`
|
|
1710
1800
|
);
|
|
1711
1801
|
if (n.issues) {
|
|
1712
|
-
const i = n.issues.map((r) => `${
|
|
1802
|
+
const i = n.issues.map((r) => `${ot(r.path, t)}: ${r.message}`);
|
|
1713
1803
|
throw new Error(`Validation failed: ${i.join("; ")}`);
|
|
1714
1804
|
}
|
|
1715
1805
|
return n.value;
|
|
1716
1806
|
}
|
|
1717
|
-
function
|
|
1807
|
+
function ot(s, e) {
|
|
1718
1808
|
if (!s || s.length === 0)
|
|
1719
1809
|
return e;
|
|
1720
|
-
const t = s.map((n) =>
|
|
1810
|
+
const t = s.map((n) => {
|
|
1811
|
+
if (typeof n == "object" && n !== null) {
|
|
1812
|
+
if ("key" in n && n.key !== void 0)
|
|
1813
|
+
return String(n.key);
|
|
1814
|
+
if ("index" in n && typeof n.index == "number")
|
|
1815
|
+
return String(n.index);
|
|
1816
|
+
}
|
|
1817
|
+
return String(n);
|
|
1818
|
+
});
|
|
1721
1819
|
return `${e}.${t.join(".")}`;
|
|
1722
1820
|
}
|
|
1723
1821
|
function de(s, e, t) {
|
|
1724
1822
|
const n = {
|
|
1725
|
-
...
|
|
1823
|
+
...P,
|
|
1726
1824
|
...e
|
|
1727
1825
|
}, i = {};
|
|
1728
1826
|
for (const [r, o] of Object.entries(n)) {
|
|
1729
1827
|
const c = b(o) ? { schema: o } : o;
|
|
1730
1828
|
let l;
|
|
1731
|
-
const
|
|
1829
|
+
const h = c.alias, w = r in s, _ = h && h in s;
|
|
1732
1830
|
if (w)
|
|
1733
1831
|
l = s[r];
|
|
1734
1832
|
else if (_)
|
|
1735
|
-
l = s[
|
|
1833
|
+
l = s[h];
|
|
1736
1834
|
else if (c.value)
|
|
1737
1835
|
l = c.value(t);
|
|
1738
1836
|
else if (c.default !== void 0)
|
|
1739
1837
|
l = typeof c.default == "function" ? c.default(t) : c.default;
|
|
1740
1838
|
else if (c.schema && b(c.schema)) {
|
|
1741
|
-
const
|
|
1742
|
-
!(
|
|
1839
|
+
const R = c.schema["~standard"].validate(void 0);
|
|
1840
|
+
!(R instanceof Promise) && !R.issues && (l = R.value);
|
|
1743
1841
|
}
|
|
1744
1842
|
l !== void 0 && c.decorate && (l = c.decorate({ value: l, props: i })), i[r] = l;
|
|
1745
1843
|
}
|
|
1746
1844
|
return i;
|
|
1747
1845
|
}
|
|
1748
|
-
function
|
|
1846
|
+
function fe(s, e) {
|
|
1749
1847
|
const t = {
|
|
1750
|
-
...
|
|
1848
|
+
...P,
|
|
1751
1849
|
...e
|
|
1752
1850
|
};
|
|
1753
1851
|
for (const [n, i] of Object.entries(t)) {
|
|
@@ -1756,49 +1854,63 @@ function Ze(s, e) {
|
|
|
1756
1854
|
if (o.required && a === void 0)
|
|
1757
1855
|
throw new Error(`Prop "${n}" is required but was not provided`);
|
|
1758
1856
|
if (o.schema && b(o.schema))
|
|
1759
|
-
(a !== void 0 || r) && (a =
|
|
1857
|
+
(a !== void 0 || r) && (a = rt(o.schema, a, n), s[n] = a);
|
|
1760
1858
|
else if (a === void 0)
|
|
1761
1859
|
continue;
|
|
1762
1860
|
o.validate && o.validate({ value: a, props: s });
|
|
1763
1861
|
}
|
|
1764
1862
|
}
|
|
1765
|
-
function
|
|
1863
|
+
function pe(s, e, t, n) {
|
|
1766
1864
|
const i = {
|
|
1767
|
-
...
|
|
1865
|
+
...P,
|
|
1768
1866
|
...e
|
|
1769
1867
|
}, r = {};
|
|
1770
1868
|
for (const [o, a] of Object.entries(i)) {
|
|
1771
|
-
const l = b(a) ? { schema: a } : a,
|
|
1869
|
+
const l = b(a) ? { schema: a } : a, h = s[o];
|
|
1772
1870
|
if (l.sendToHost === !1 || l.sameDomain && !n) continue;
|
|
1773
1871
|
if (l.trustedDomains) {
|
|
1774
1872
|
const _ = l.trustedDomains;
|
|
1775
|
-
if (!
|
|
1873
|
+
if (!D(_, t)) continue;
|
|
1776
1874
|
}
|
|
1777
|
-
let w =
|
|
1778
|
-
l.hostDecorate &&
|
|
1875
|
+
let w = h;
|
|
1876
|
+
l.hostDecorate && h !== void 0 && (w = l.hostDecorate({ value: h, props: s })), r[o] = w;
|
|
1779
1877
|
}
|
|
1780
1878
|
return r;
|
|
1781
1879
|
}
|
|
1782
|
-
function
|
|
1880
|
+
function at(s, e) {
|
|
1783
1881
|
const t = new URLSearchParams(), n = {
|
|
1784
|
-
...
|
|
1882
|
+
...P,
|
|
1785
1883
|
...e
|
|
1786
1884
|
};
|
|
1787
1885
|
for (const [i, r] of Object.entries(n)) {
|
|
1788
1886
|
const a = b(r) ? { schema: r } : r, c = s[i];
|
|
1789
1887
|
if (c === void 0 || typeof c == "function" || !a.queryParam) continue;
|
|
1790
1888
|
const l = typeof a.queryParam == "string" ? a.queryParam : i;
|
|
1791
|
-
let
|
|
1792
|
-
typeof a.queryParam == "function" ?
|
|
1889
|
+
let h;
|
|
1890
|
+
typeof a.queryParam == "function" ? h = a.queryParam({ value: c }) : typeof c == "object" ? h = JSON.stringify(c) : h = String(c), t.set(l, h);
|
|
1891
|
+
}
|
|
1892
|
+
return t;
|
|
1893
|
+
}
|
|
1894
|
+
function ct(s, e) {
|
|
1895
|
+
const t = new URLSearchParams(), n = {
|
|
1896
|
+
...P,
|
|
1897
|
+
...e
|
|
1898
|
+
};
|
|
1899
|
+
for (const [i, r] of Object.entries(n)) {
|
|
1900
|
+
const a = b(r) ? { schema: r } : r, c = s[i];
|
|
1901
|
+
if (c === void 0 || typeof c == "function" || !a.bodyParam) continue;
|
|
1902
|
+
const l = typeof a.bodyParam == "string" ? a.bodyParam : i;
|
|
1903
|
+
let h;
|
|
1904
|
+
typeof a.bodyParam == "function" ? h = a.bodyParam({ value: c }) : typeof c == "object" ? h = JSON.stringify(c) : h = String(c), t.set(l, h);
|
|
1793
1905
|
}
|
|
1794
1906
|
return t;
|
|
1795
1907
|
}
|
|
1796
|
-
function
|
|
1908
|
+
function Se(s, e = "") {
|
|
1797
1909
|
const t = [];
|
|
1798
1910
|
for (const [n, i] of Object.entries(s)) {
|
|
1799
1911
|
const r = e ? `${e}.${n}` : n;
|
|
1800
1912
|
if (i !== null && typeof i == "object" && !Array.isArray(i))
|
|
1801
|
-
t.push(
|
|
1913
|
+
t.push(Se(i, r));
|
|
1802
1914
|
else {
|
|
1803
1915
|
const o = encodeURIComponent(JSON.stringify(i));
|
|
1804
1916
|
t.push(`${r}=${o}`);
|
|
@@ -1806,7 +1918,7 @@ function Re(s, e = "") {
|
|
|
1806
1918
|
}
|
|
1807
1919
|
return t.filter(Boolean).join("&");
|
|
1808
1920
|
}
|
|
1809
|
-
function
|
|
1921
|
+
function lt(s) {
|
|
1810
1922
|
const e = {};
|
|
1811
1923
|
if (!s) return e;
|
|
1812
1924
|
const t = s.split("&");
|
|
@@ -1822,54 +1934,54 @@ function Qe(s) {
|
|
|
1822
1934
|
const a = i.split(".");
|
|
1823
1935
|
let c = e;
|
|
1824
1936
|
for (let l = 0; l < a.length - 1; l++) {
|
|
1825
|
-
const
|
|
1826
|
-
(!(
|
|
1937
|
+
const h = a[l];
|
|
1938
|
+
(!(h in c) || typeof c[h] != "object") && (c[h] = {}), c = c[h];
|
|
1827
1939
|
}
|
|
1828
1940
|
c[a[a.length - 1]] = o;
|
|
1829
1941
|
}
|
|
1830
1942
|
return e;
|
|
1831
1943
|
}
|
|
1832
|
-
function
|
|
1944
|
+
function ut(s) {
|
|
1833
1945
|
return typeof s == "object" && s !== null && s.__type__ === "dotify" && typeof s.__value__ == "string";
|
|
1834
1946
|
}
|
|
1835
|
-
function
|
|
1947
|
+
function me(s, e, t) {
|
|
1836
1948
|
const n = {
|
|
1837
|
-
...
|
|
1949
|
+
...P,
|
|
1838
1950
|
...e
|
|
1839
1951
|
}, i = {};
|
|
1840
1952
|
for (const [r, o] of Object.entries(s)) {
|
|
1841
1953
|
if (o === void 0) continue;
|
|
1842
1954
|
const a = n[r];
|
|
1843
|
-
i[r] =
|
|
1955
|
+
i[r] = ht(o, a, t);
|
|
1844
1956
|
}
|
|
1845
1957
|
return i;
|
|
1846
1958
|
}
|
|
1847
|
-
function
|
|
1959
|
+
function ht(s, e, t) {
|
|
1848
1960
|
if (typeof s == "function")
|
|
1849
1961
|
return t.serialize(s);
|
|
1850
|
-
const n = e?.serialization ??
|
|
1851
|
-
if (n ===
|
|
1962
|
+
const n = e?.serialization ?? T.JSON;
|
|
1963
|
+
if (n === T.BASE64 && typeof s == "object") {
|
|
1852
1964
|
const i = JSON.stringify(s);
|
|
1853
1965
|
return {
|
|
1854
1966
|
__type__: "base64",
|
|
1855
1967
|
__value__: btoa(encodeURIComponent(i))
|
|
1856
1968
|
};
|
|
1857
1969
|
}
|
|
1858
|
-
return n ===
|
|
1970
|
+
return n === T.DOTIFY && typeof s == "object" && s !== null && !Array.isArray(s) ? {
|
|
1859
1971
|
__type__: "dotify",
|
|
1860
|
-
__value__:
|
|
1972
|
+
__value__: Se(s)
|
|
1861
1973
|
} : B(s, t);
|
|
1862
1974
|
}
|
|
1863
|
-
function
|
|
1975
|
+
function ge(s, e, t, n, i, r) {
|
|
1864
1976
|
const o = {
|
|
1865
|
-
...
|
|
1977
|
+
...P,
|
|
1866
1978
|
...e
|
|
1867
1979
|
}, a = {};
|
|
1868
1980
|
for (const [c, l] of Object.entries(s)) {
|
|
1869
|
-
const
|
|
1870
|
-
a[c] =
|
|
1981
|
+
const h = o[c];
|
|
1982
|
+
a[c] = dt(
|
|
1871
1983
|
l,
|
|
1872
|
-
|
|
1984
|
+
h,
|
|
1873
1985
|
t,
|
|
1874
1986
|
n,
|
|
1875
1987
|
i,
|
|
@@ -1878,23 +1990,23 @@ function me(s, e, t, n, i, r) {
|
|
|
1878
1990
|
}
|
|
1879
1991
|
return a;
|
|
1880
1992
|
}
|
|
1881
|
-
function
|
|
1882
|
-
if (
|
|
1993
|
+
function dt(s, e, t, n, i, r) {
|
|
1994
|
+
if (ft(s))
|
|
1883
1995
|
try {
|
|
1884
1996
|
const o = decodeURIComponent(atob(s.__value__));
|
|
1885
1997
|
return JSON.parse(o);
|
|
1886
1998
|
} catch {
|
|
1887
1999
|
return s;
|
|
1888
2000
|
}
|
|
1889
|
-
if (
|
|
2001
|
+
if (ut(s))
|
|
1890
2002
|
try {
|
|
1891
|
-
return
|
|
2003
|
+
return lt(s.__value__);
|
|
1892
2004
|
} catch {
|
|
1893
2005
|
return s;
|
|
1894
2006
|
}
|
|
1895
|
-
return
|
|
2007
|
+
return V(s, n, i, r);
|
|
1896
2008
|
}
|
|
1897
|
-
function
|
|
2009
|
+
function ft(s) {
|
|
1898
2010
|
return typeof s == "object" && s !== null && s.__type__ === "base64" && typeof s.__value__ == "string";
|
|
1899
2011
|
}
|
|
1900
2012
|
function O(s, e = "100%") {
|
|
@@ -1906,36 +2018,36 @@ function k(s, e) {
|
|
|
1906
2018
|
const t = parseInt(s, 10);
|
|
1907
2019
|
return isNaN(t) ? e : t;
|
|
1908
2020
|
}
|
|
1909
|
-
function
|
|
2021
|
+
function pt(s) {
|
|
1910
2022
|
try {
|
|
1911
2023
|
s.src = "about:blank", s.parentNode?.removeChild(s);
|
|
1912
2024
|
} catch {
|
|
1913
2025
|
}
|
|
1914
2026
|
}
|
|
1915
|
-
function
|
|
1916
|
-
|
|
2027
|
+
function mt(s, e) {
|
|
2028
|
+
wt(s, e);
|
|
1917
2029
|
}
|
|
1918
|
-
function
|
|
2030
|
+
function gt(s) {
|
|
1919
2031
|
s.style.display = "", s.style.visibility = "visible";
|
|
1920
2032
|
}
|
|
1921
|
-
function
|
|
2033
|
+
function ye(s) {
|
|
1922
2034
|
s.style.display = "none", s.style.visibility = "hidden";
|
|
1923
2035
|
}
|
|
1924
|
-
function
|
|
2036
|
+
function yt(s) {
|
|
1925
2037
|
try {
|
|
1926
2038
|
s.focus(), s.contentWindow?.focus();
|
|
1927
2039
|
} catch {
|
|
1928
2040
|
}
|
|
1929
2041
|
}
|
|
1930
|
-
function
|
|
2042
|
+
function wt(s, e) {
|
|
1931
2043
|
e.width !== void 0 && (s.style.width = O(e.width)), e.height !== void 0 && (s.style.height = O(e.height));
|
|
1932
2044
|
}
|
|
1933
|
-
class
|
|
2045
|
+
class ve extends Error {
|
|
1934
2046
|
constructor(e = "Popup blocked by browser") {
|
|
1935
2047
|
super(e), this.name = "PopupOpenError";
|
|
1936
2048
|
}
|
|
1937
2049
|
}
|
|
1938
|
-
function
|
|
2050
|
+
function _t(s) {
|
|
1939
2051
|
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 = [
|
|
1940
2052
|
`width=${i}`,
|
|
1941
2053
|
`height=${r}`,
|
|
@@ -1949,23 +2061,23 @@ function lt(s) {
|
|
|
1949
2061
|
"resizable=yes",
|
|
1950
2062
|
"scrollbars=yes"
|
|
1951
2063
|
].join(","), l = window.open(e, t, c);
|
|
1952
|
-
if (!l ||
|
|
1953
|
-
throw new
|
|
2064
|
+
if (!l || Pt(l))
|
|
2065
|
+
throw new ve();
|
|
1954
2066
|
return l;
|
|
1955
2067
|
}
|
|
1956
|
-
function
|
|
2068
|
+
function Et(s) {
|
|
1957
2069
|
try {
|
|
1958
2070
|
s.closed || s.close();
|
|
1959
2071
|
} catch {
|
|
1960
2072
|
}
|
|
1961
2073
|
}
|
|
1962
|
-
function
|
|
2074
|
+
function bt(s) {
|
|
1963
2075
|
try {
|
|
1964
2076
|
s.closed || s.focus();
|
|
1965
2077
|
} catch {
|
|
1966
2078
|
}
|
|
1967
2079
|
}
|
|
1968
|
-
function
|
|
2080
|
+
function Pt(s) {
|
|
1969
2081
|
if (!s) return !0;
|
|
1970
2082
|
try {
|
|
1971
2083
|
return !!(s.closed || s.innerHeight === 0 || s.innerWidth === 0);
|
|
@@ -1973,7 +2085,7 @@ function dt(s) {
|
|
|
1973
2085
|
return !0;
|
|
1974
2086
|
}
|
|
1975
2087
|
}
|
|
1976
|
-
function
|
|
2088
|
+
function Rt(s, e, t = {}) {
|
|
1977
2089
|
const {
|
|
1978
2090
|
initialInterval: n = 100,
|
|
1979
2091
|
// Start fast to catch quick closes
|
|
@@ -1989,7 +2101,7 @@ function ft(s, e, t = {}) {
|
|
|
1989
2101
|
} catch (w) {
|
|
1990
2102
|
console.error("Error in popup close callback:", w);
|
|
1991
2103
|
}
|
|
1992
|
-
},
|
|
2104
|
+
}, h = () => {
|
|
1993
2105
|
if (!c) {
|
|
1994
2106
|
try {
|
|
1995
2107
|
if (s.closed) {
|
|
@@ -2000,14 +2112,14 @@ function ft(s, e, t = {}) {
|
|
|
2000
2112
|
l();
|
|
2001
2113
|
return;
|
|
2002
2114
|
}
|
|
2003
|
-
o = Math.min(o * r, i), a = setTimeout(
|
|
2115
|
+
o = Math.min(o * r, i), a = setTimeout(h, o);
|
|
2004
2116
|
}
|
|
2005
2117
|
};
|
|
2006
|
-
return a = setTimeout(
|
|
2118
|
+
return a = setTimeout(h, o), () => {
|
|
2007
2119
|
c = !0, clearTimeout(a);
|
|
2008
2120
|
};
|
|
2009
2121
|
}
|
|
2010
|
-
function
|
|
2122
|
+
function Ot(s, e) {
|
|
2011
2123
|
try {
|
|
2012
2124
|
const t = k(e.width, s.outerWidth), n = k(
|
|
2013
2125
|
e.height,
|
|
@@ -2017,7 +2129,23 @@ function pt(s, e) {
|
|
|
2017
2129
|
} catch {
|
|
2018
2130
|
}
|
|
2019
2131
|
}
|
|
2020
|
-
|
|
2132
|
+
const we = "forgeframe-spinner-style";
|
|
2133
|
+
function xt(s, e) {
|
|
2134
|
+
const t = s.getElementById(we);
|
|
2135
|
+
if (t) {
|
|
2136
|
+
const i = t.getAttribute("nonce");
|
|
2137
|
+
if (!e || i === e)
|
|
2138
|
+
return;
|
|
2139
|
+
t.remove();
|
|
2140
|
+
}
|
|
2141
|
+
const n = s.createElement("style");
|
|
2142
|
+
n.id = we, e && n.setAttribute("nonce", e), n.textContent = `
|
|
2143
|
+
@keyframes forgeframe-spin {
|
|
2144
|
+
to { transform: rotate(360deg); }
|
|
2145
|
+
}
|
|
2146
|
+
`, (s.head ?? s.documentElement).appendChild(n);
|
|
2147
|
+
}
|
|
2148
|
+
function St(s) {
|
|
2021
2149
|
const { doc: e, dimensions: t, uid: n, tag: i } = s, r = e.createElement("div");
|
|
2022
2150
|
return r.id = `forgeframe-container-${n}`, r.setAttribute("data-forgeframe-tag", i), Object.assign(r.style, {
|
|
2023
2151
|
display: "inline-block",
|
|
@@ -2027,8 +2155,10 @@ function mt(s) {
|
|
|
2027
2155
|
overflow: "hidden"
|
|
2028
2156
|
}), r;
|
|
2029
2157
|
}
|
|
2030
|
-
function
|
|
2031
|
-
const { doc: e, dimensions: t, cspNonce: n } = s
|
|
2158
|
+
function vt(s) {
|
|
2159
|
+
const { doc: e, dimensions: t, cspNonce: n } = s;
|
|
2160
|
+
xt(e, n);
|
|
2161
|
+
const i = e.createElement("div");
|
|
2032
2162
|
Object.assign(i.style, {
|
|
2033
2163
|
display: "flex",
|
|
2034
2164
|
alignItems: "center",
|
|
@@ -2042,33 +2172,27 @@ function gt(s) {
|
|
|
2042
2172
|
zIndex: "100"
|
|
2043
2173
|
});
|
|
2044
2174
|
const r = e.createElement("div");
|
|
2045
|
-
Object.assign(r.style, {
|
|
2175
|
+
return Object.assign(r.style, {
|
|
2046
2176
|
width: "40px",
|
|
2047
2177
|
height: "40px",
|
|
2048
2178
|
border: "3px solid #e0e0e0",
|
|
2049
2179
|
borderTopColor: "#3498db",
|
|
2050
2180
|
borderRadius: "50%",
|
|
2051
2181
|
animation: "forgeframe-spin 1s linear infinite"
|
|
2052
|
-
});
|
|
2053
|
-
const o = e.createElement("style");
|
|
2054
|
-
return n && o.setAttribute("nonce", n), o.textContent = `
|
|
2055
|
-
@keyframes forgeframe-spin {
|
|
2056
|
-
to { transform: rotate(360deg); }
|
|
2057
|
-
}
|
|
2058
|
-
`, i.appendChild(o), i.appendChild(r), i;
|
|
2182
|
+
}), i.appendChild(r), i;
|
|
2059
2183
|
}
|
|
2060
|
-
function
|
|
2184
|
+
function Dt(s, e = 200) {
|
|
2061
2185
|
return new Promise((t) => {
|
|
2062
2186
|
s.style.opacity = "0", s.style.transition = `opacity ${e}ms ease-in`, s.offsetHeight, s.style.opacity = "1", setTimeout(t, e);
|
|
2063
2187
|
});
|
|
2064
2188
|
}
|
|
2065
|
-
function
|
|
2189
|
+
function It(s, e = 200) {
|
|
2066
2190
|
return new Promise((t) => {
|
|
2067
2191
|
s.style.transition = `opacity ${e}ms ease-out`, s.style.opacity = "0", setTimeout(t, e);
|
|
2068
2192
|
});
|
|
2069
2193
|
}
|
|
2070
|
-
async function
|
|
2071
|
-
e && (await
|
|
2194
|
+
async function Ct(s, e, t) {
|
|
2195
|
+
e && (await It(e, 150), e.remove()), t.style.display = "", t.style.visibility = "visible", t.style.opacity = "0", await Dt(t, 150);
|
|
2072
2196
|
}
|
|
2073
2197
|
class se {
|
|
2074
2198
|
/** Event emitter for lifecycle events. */
|
|
@@ -2115,6 +2239,8 @@ class se {
|
|
|
2115
2239
|
/** @internal */
|
|
2116
2240
|
initPromise = null;
|
|
2117
2241
|
/** @internal */
|
|
2242
|
+
hostInitialized = !1;
|
|
2243
|
+
/** @internal */
|
|
2118
2244
|
rendered = !1;
|
|
2119
2245
|
/** @internal */
|
|
2120
2246
|
destroyed = !1;
|
|
@@ -2125,11 +2251,11 @@ class se {
|
|
|
2125
2251
|
* @param props - Initial props to pass to the component
|
|
2126
2252
|
*/
|
|
2127
2253
|
constructor(e, t = {}) {
|
|
2128
|
-
this._uid =
|
|
2254
|
+
this._uid = He(), this.options = this.normalizeOptions(e), this.context = this.options.defaultContext, this.event = new Ee(), this.cleanup = new Le();
|
|
2129
2255
|
const n = this.createPropContext();
|
|
2130
2256
|
this.props = de(t, this.options.props, n);
|
|
2131
2257
|
const i = this.buildTrustedDomains();
|
|
2132
|
-
this.messenger = new
|
|
2258
|
+
this.messenger = new Pe(this.uid, window, q(), i), this.bridge = new J(this.messenger), this.setupMessageHandlers(), this.setupCleanup();
|
|
2133
2259
|
}
|
|
2134
2260
|
/**
|
|
2135
2261
|
* Builds the list of trusted domains for messenger communication.
|
|
@@ -2137,15 +2263,8 @@ class se {
|
|
|
2137
2263
|
*/
|
|
2138
2264
|
buildTrustedDomains() {
|
|
2139
2265
|
const e = [], t = this.resolveUrlOrigin(this.resolveUrl());
|
|
2140
|
-
if (t && (e.push(t), this.dynamicUrlTrustedOrigin = t), this.options.domain)
|
|
2141
|
-
|
|
2142
|
-
e.push(this.options.domain);
|
|
2143
|
-
else if (Array.isArray(this.options.domain))
|
|
2144
|
-
e.push(...this.options.domain);
|
|
2145
|
-
else if (this.options.domain instanceof RegExp)
|
|
2146
|
-
return this.options.domain;
|
|
2147
|
-
}
|
|
2148
|
-
return e.length > 0 ? e : void 0;
|
|
2266
|
+
if (t && (e.push(t), this.dynamicUrlTrustedOrigin = t), this.options.domain && (typeof this.options.domain == "string" ? e.push(this.options.domain) : Array.isArray(this.options.domain) ? e.push(...this.options.domain) : this.options.domain instanceof RegExp && e.push(this.options.domain)), e.length !== 0)
|
|
2267
|
+
return e.length === 1 ? e[0] : e;
|
|
2149
2268
|
}
|
|
2150
2269
|
/**
|
|
2151
2270
|
* Renders the component into a DOM container.
|
|
@@ -2170,11 +2289,18 @@ class se {
|
|
|
2170
2289
|
throw new Error("Component has been destroyed");
|
|
2171
2290
|
if (this.rendered)
|
|
2172
2291
|
throw new Error("Component has already been rendered");
|
|
2173
|
-
this.context = t ?? this.options.defaultContext, this.checkEligibility(),
|
|
2174
|
-
|
|
2175
|
-
this.prerenderElement
|
|
2176
|
-
|
|
2177
|
-
|
|
2292
|
+
this.context = t ?? this.options.defaultContext, this.checkEligibility(), fe(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");
|
|
2293
|
+
try {
|
|
2294
|
+
await this.open(), await this.waitForHost(), this.context === p.IFRAME && this.iframe && this.prerenderElement && (await Ct(
|
|
2295
|
+
this.container,
|
|
2296
|
+
this.prerenderElement,
|
|
2297
|
+
this.iframe
|
|
2298
|
+
), this.prerenderElement = null);
|
|
2299
|
+
} catch (n) {
|
|
2300
|
+
throw await this.destroy().catch(() => {
|
|
2301
|
+
}), n;
|
|
2302
|
+
}
|
|
2303
|
+
this.rendered = !0, this.event.emit(f.RENDERED), this.callPropCallback("onRendered"), this.event.emit(f.DISPLAY), this.callPropCallback("onDisplay");
|
|
2178
2304
|
}
|
|
2179
2305
|
/**
|
|
2180
2306
|
* Renders the component into a container in a different window.
|
|
@@ -2206,7 +2332,7 @@ class se {
|
|
|
2206
2332
|
* For iframes, focuses the iframe element. For popups, brings the window to front.
|
|
2207
2333
|
*/
|
|
2208
2334
|
async focus() {
|
|
2209
|
-
this.context === p.IFRAME && this.iframe ?
|
|
2335
|
+
this.context === p.IFRAME && this.iframe ? yt(this.iframe) : this.context === p.POPUP && this.hostWindow && bt(this.hostWindow), this.event.emit(f.FOCUS), this.callPropCallback("onFocus");
|
|
2210
2336
|
}
|
|
2211
2337
|
/**
|
|
2212
2338
|
* Resizes the component to the specified dimensions.
|
|
@@ -2214,7 +2340,7 @@ class se {
|
|
|
2214
2340
|
* @param dimensions - New width and height for the component
|
|
2215
2341
|
*/
|
|
2216
2342
|
async resize(e) {
|
|
2217
|
-
this.context === p.IFRAME && this.iframe ?
|
|
2343
|
+
this.context === p.IFRAME && this.iframe ? mt(this.iframe, e) : this.context === p.POPUP && this.hostWindow && Ot(this.hostWindow, e), this.event.emit(f.RESIZE, e), this.callPropCallback("onResize", e);
|
|
2218
2344
|
}
|
|
2219
2345
|
/**
|
|
2220
2346
|
* Shows the component if hidden.
|
|
@@ -2223,7 +2349,7 @@ class se {
|
|
|
2223
2349
|
* Only applicable to iframe context.
|
|
2224
2350
|
*/
|
|
2225
2351
|
async show() {
|
|
2226
|
-
this.context === p.IFRAME && this.iframe &&
|
|
2352
|
+
this.context === p.IFRAME && this.iframe && gt(this.iframe);
|
|
2227
2353
|
}
|
|
2228
2354
|
/**
|
|
2229
2355
|
* Hides the component.
|
|
@@ -2232,13 +2358,13 @@ class se {
|
|
|
2232
2358
|
* Only applicable to iframe context.
|
|
2233
2359
|
*/
|
|
2234
2360
|
async hide() {
|
|
2235
|
-
this.context === p.IFRAME && this.iframe &&
|
|
2361
|
+
this.context === p.IFRAME && this.iframe && ye(this.iframe);
|
|
2236
2362
|
}
|
|
2237
2363
|
/**
|
|
2238
2364
|
* Updates the component props and sends them to the host.
|
|
2239
2365
|
*
|
|
2240
2366
|
* @remarks
|
|
2241
|
-
* Props are normalized and
|
|
2367
|
+
* Props are normalized and validated before being sent to the host window.
|
|
2242
2368
|
*
|
|
2243
2369
|
* @param newProps - Partial props object to merge with existing props
|
|
2244
2370
|
*/
|
|
@@ -2248,19 +2374,19 @@ class se {
|
|
|
2248
2374
|
this.options.props,
|
|
2249
2375
|
t
|
|
2250
2376
|
);
|
|
2251
|
-
this.options.validate?.({ props: n });
|
|
2377
|
+
fe(n, this.options.props), this.options.validate?.({ props: n });
|
|
2252
2378
|
const i = this.resolveUrl(n), r = this.resolveUrlOrigin(i);
|
|
2253
2379
|
if (this.rendered && this.openedHostDomain && r && r !== this.openedHostDomain)
|
|
2254
2380
|
throw new Error(
|
|
2255
2381
|
`Cannot change component URL origin after render (from "${this.openedHostDomain}" to "${r}")`
|
|
2256
2382
|
);
|
|
2257
|
-
if (this.props = n, this.rendered || this.syncTrustedDomainForUrl(i), this.hostWindow && !
|
|
2258
|
-
const o = this.openedHostDomain ?? this.getHostDomain(), a =
|
|
2383
|
+
if (this.props = n, this.rendered || this.syncTrustedDomainForUrl(i), this.hostWindow && !Oe(this.hostWindow)) {
|
|
2384
|
+
const o = this.openedHostDomain ?? this.getHostDomain(), a = pe(
|
|
2259
2385
|
n,
|
|
2260
2386
|
this.options.props,
|
|
2261
2387
|
o,
|
|
2262
|
-
|
|
2263
|
-
), c =
|
|
2388
|
+
Re(this.hostWindow)
|
|
2389
|
+
), c = me(
|
|
2264
2390
|
a,
|
|
2265
2391
|
this.options.props,
|
|
2266
2392
|
this.bridge
|
|
@@ -2268,7 +2394,7 @@ class se {
|
|
|
2268
2394
|
await this.messenger.send(
|
|
2269
2395
|
this.hostWindow,
|
|
2270
2396
|
o,
|
|
2271
|
-
|
|
2397
|
+
u.PROPS,
|
|
2272
2398
|
c
|
|
2273
2399
|
);
|
|
2274
2400
|
}
|
|
@@ -2334,7 +2460,7 @@ class se {
|
|
|
2334
2460
|
* @internal
|
|
2335
2461
|
*/
|
|
2336
2462
|
isExplicitDomainTrust(e) {
|
|
2337
|
-
return
|
|
2463
|
+
return this.options.domain ? D(this.options.domain, e) : !1;
|
|
2338
2464
|
}
|
|
2339
2465
|
/**
|
|
2340
2466
|
* Ensures the messenger trusts the origin for a resolved host URL.
|
|
@@ -2394,10 +2520,10 @@ class se {
|
|
|
2394
2520
|
*/
|
|
2395
2521
|
async prerender() {
|
|
2396
2522
|
if (!this.container) return;
|
|
2397
|
-
const e = this.options.prerenderTemplate ??
|
|
2523
|
+
const e = this.options.prerenderTemplate ?? vt, t = this.options.containerTemplate ?? St, n = this.resolveDimensions(), i = this.props.cspNonce;
|
|
2398
2524
|
if (this.context === p.IFRAME) {
|
|
2399
2525
|
const c = this.buildWindowName();
|
|
2400
|
-
this.iframe = this.createIframeElement(c),
|
|
2526
|
+
this.iframe = this.createIframeElement(c), ye(this.iframe);
|
|
2401
2527
|
}
|
|
2402
2528
|
const r = {
|
|
2403
2529
|
uid: this.uid,
|
|
@@ -2460,60 +2586,88 @@ class se {
|
|
|
2460
2586
|
async open() {
|
|
2461
2587
|
const e = this.resolveUrl();
|
|
2462
2588
|
this.syncTrustedDomainForUrl(e), this.openedHostDomain = this.resolveUrlOrigin(e);
|
|
2463
|
-
const t = this.buildUrl(e);
|
|
2589
|
+
const t = this.buildUrl(e), n = this.buildBodyParams(), i = n.toString().length > 0;
|
|
2464
2590
|
if (this.context === p.IFRAME) {
|
|
2465
2591
|
if (!this.iframe)
|
|
2466
2592
|
throw new Error("Iframe not created during prerender");
|
|
2467
|
-
this.iframe.src = t, this.hostWindow = this.iframe.contentWindow;
|
|
2593
|
+
i ? this.submitBodyForm(this.iframe.name, t, n) : this.iframe.src = t, this.hostWindow = this.iframe.contentWindow;
|
|
2468
2594
|
} else {
|
|
2469
|
-
const
|
|
2470
|
-
this.hostWindow =
|
|
2471
|
-
url: t,
|
|
2472
|
-
name:
|
|
2595
|
+
const r = this.buildWindowName();
|
|
2596
|
+
this.hostWindow = _t({
|
|
2597
|
+
url: i ? "about:blank" : t,
|
|
2598
|
+
name: r,
|
|
2473
2599
|
dimensions: this.resolveDimensions()
|
|
2600
|
+
}), i && this.submitBodyForm(r, t, n);
|
|
2601
|
+
const o = Rt(this.hostWindow, () => {
|
|
2602
|
+
this.close();
|
|
2474
2603
|
});
|
|
2475
|
-
|
|
2476
|
-
this.destroy();
|
|
2477
|
-
});
|
|
2478
|
-
this.cleanup.register(i);
|
|
2604
|
+
this.cleanup.register(o);
|
|
2479
2605
|
}
|
|
2480
|
-
this.hostWindow &&
|
|
2606
|
+
this.hostWindow && st(this.uid, this.hostWindow);
|
|
2481
2607
|
}
|
|
2482
2608
|
/**
|
|
2483
2609
|
* Builds the URL for the host window including query parameters.
|
|
2484
2610
|
* @internal
|
|
2485
2611
|
*/
|
|
2486
2612
|
buildUrl(e = this.resolveUrl()) {
|
|
2487
|
-
const n =
|
|
2613
|
+
const n = at(this.props, this.options.props).toString();
|
|
2488
2614
|
if (!n) return e;
|
|
2489
2615
|
const i = e.includes("?") ? "&" : "?";
|
|
2490
2616
|
return `${e}${i}${n}`;
|
|
2491
2617
|
}
|
|
2618
|
+
/**
|
|
2619
|
+
* Builds POST body parameters from props marked with bodyParam.
|
|
2620
|
+
* @internal
|
|
2621
|
+
*/
|
|
2622
|
+
buildBodyParams() {
|
|
2623
|
+
return ct(this.props, this.options.props);
|
|
2624
|
+
}
|
|
2625
|
+
/**
|
|
2626
|
+
* Submits a hidden form to navigate a target window via POST.
|
|
2627
|
+
* @internal
|
|
2628
|
+
*/
|
|
2629
|
+
submitBodyForm(e, t, n) {
|
|
2630
|
+
const i = this.container?.ownerDocument ?? document, r = i.body ?? i.documentElement;
|
|
2631
|
+
if (!r)
|
|
2632
|
+
throw new Error("Document root is unavailable for bodyParam form submission");
|
|
2633
|
+
const o = i.createElement("form");
|
|
2634
|
+
o.method = "POST", o.action = t, o.target = e, o.style.display = "none";
|
|
2635
|
+
for (const [a, c] of n.entries()) {
|
|
2636
|
+
const l = i.createElement("input");
|
|
2637
|
+
l.type = "hidden", l.name = a, l.value = c, o.appendChild(l);
|
|
2638
|
+
}
|
|
2639
|
+
r.appendChild(o);
|
|
2640
|
+
try {
|
|
2641
|
+
o.submit();
|
|
2642
|
+
} finally {
|
|
2643
|
+
o.remove();
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2492
2646
|
/**
|
|
2493
2647
|
* Builds the window.name payload for the host window.
|
|
2494
2648
|
* @internal
|
|
2495
2649
|
*/
|
|
2496
2650
|
buildWindowName() {
|
|
2497
|
-
const e = this.getHostDomain(), t =
|
|
2651
|
+
const e = this.getHostDomain(), t = pe(
|
|
2498
2652
|
this.props,
|
|
2499
2653
|
this.options.props,
|
|
2500
2654
|
e,
|
|
2501
2655
|
!1
|
|
2502
2656
|
// Assume cross-domain for initial payload
|
|
2503
|
-
), n =
|
|
2657
|
+
), n = me(
|
|
2504
2658
|
t,
|
|
2505
2659
|
this.options.props,
|
|
2506
2660
|
this.bridge
|
|
2507
|
-
), i = this.buildNestedHostRefs(), r =
|
|
2661
|
+
), i = this.buildNestedHostRefs(), r = Qe({
|
|
2508
2662
|
uid: this.uid,
|
|
2509
2663
|
tag: this.options.tag,
|
|
2510
2664
|
context: this.context,
|
|
2511
|
-
consumerDomain:
|
|
2665
|
+
consumerDomain: q(),
|
|
2512
2666
|
props: n,
|
|
2513
2667
|
exports: this.createConsumerExports(),
|
|
2514
2668
|
children: i
|
|
2515
2669
|
});
|
|
2516
|
-
return
|
|
2670
|
+
return Ye(r);
|
|
2517
2671
|
}
|
|
2518
2672
|
/**
|
|
2519
2673
|
* Builds component references for nested host components.
|
|
@@ -2523,7 +2677,7 @@ class se {
|
|
|
2523
2677
|
if (!this.options.children) return;
|
|
2524
2678
|
const e = this.options.children({ props: this.props }), t = {};
|
|
2525
2679
|
for (const [n, i] of Object.entries(e)) {
|
|
2526
|
-
const r =
|
|
2680
|
+
const r = At(i);
|
|
2527
2681
|
if (!r)
|
|
2528
2682
|
throw new Error(`Nested component "${n}" is missing component metadata`);
|
|
2529
2683
|
if (typeof r.url != "string")
|
|
@@ -2546,14 +2700,14 @@ class se {
|
|
|
2546
2700
|
*/
|
|
2547
2701
|
createConsumerExports() {
|
|
2548
2702
|
return {
|
|
2549
|
-
init:
|
|
2550
|
-
close:
|
|
2551
|
-
resize:
|
|
2552
|
-
show:
|
|
2553
|
-
hide:
|
|
2554
|
-
onError:
|
|
2555
|
-
updateProps:
|
|
2556
|
-
export:
|
|
2703
|
+
init: u.INIT,
|
|
2704
|
+
close: u.CLOSE,
|
|
2705
|
+
resize: u.RESIZE,
|
|
2706
|
+
show: u.SHOW,
|
|
2707
|
+
hide: u.HIDE,
|
|
2708
|
+
onError: u.ERROR,
|
|
2709
|
+
updateProps: u.PROPS,
|
|
2710
|
+
export: u.EXPORT
|
|
2557
2711
|
};
|
|
2558
2712
|
}
|
|
2559
2713
|
/**
|
|
@@ -2568,15 +2722,20 @@ class se {
|
|
|
2568
2722
|
* @internal
|
|
2569
2723
|
*/
|
|
2570
2724
|
async waitForHost() {
|
|
2571
|
-
this.
|
|
2725
|
+
if (this.hostInitialized)
|
|
2726
|
+
return;
|
|
2727
|
+
const e = be();
|
|
2728
|
+
this.initPromise = e;
|
|
2572
2729
|
try {
|
|
2573
|
-
await
|
|
2574
|
-
|
|
2730
|
+
await ke(
|
|
2731
|
+
e.promise,
|
|
2575
2732
|
this.options.timeout,
|
|
2576
2733
|
`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.`
|
|
2577
2734
|
);
|
|
2578
|
-
} catch (
|
|
2579
|
-
throw this.handleError(
|
|
2735
|
+
} catch (t) {
|
|
2736
|
+
throw this.handleError(t), t;
|
|
2737
|
+
} finally {
|
|
2738
|
+
this.initPromise === e && (this.initPromise = null);
|
|
2580
2739
|
}
|
|
2581
2740
|
}
|
|
2582
2741
|
/**
|
|
@@ -2584,34 +2743,54 @@ class se {
|
|
|
2584
2743
|
* @internal
|
|
2585
2744
|
*/
|
|
2586
2745
|
setupMessageHandlers() {
|
|
2587
|
-
this.
|
|
2588
|
-
|
|
2746
|
+
this.setupHostLifecycleHandlers(), this.setupHostDataHandlers();
|
|
2747
|
+
}
|
|
2748
|
+
/**
|
|
2749
|
+
* Sets up host lifecycle command handlers.
|
|
2750
|
+
* @internal
|
|
2751
|
+
*/
|
|
2752
|
+
setupHostLifecycleHandlers() {
|
|
2753
|
+
this.messenger.on(u.INIT, () => (this.hostInitialized = !0, this.initPromise && this.initPromise.resolve(), { success: !0 })), this.messenger.on(u.CLOSE, async () => (await this.close(), { success: !0 })), this.messenger.on(u.RESIZE, async (e) => (await this.resize(e), { success: !0 })), this.messenger.on(u.FOCUS, async () => (await this.focus(), { success: !0 })), this.messenger.on(u.SHOW, async () => (await this.show(), { success: !0 })), this.messenger.on(u.HIDE, async () => (await this.hide(), { success: !0 })), this.messenger.on(
|
|
2754
|
+
u.ERROR,
|
|
2589
2755
|
async (e) => {
|
|
2590
2756
|
const t = new Error(e.message);
|
|
2591
2757
|
return t.stack = e.stack, this.handleError(t), { success: !0 };
|
|
2592
2758
|
}
|
|
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,
|
|
2595
|
-
async (e) => {
|
|
2596
|
-
const t = [], n = vt(e.tag);
|
|
2597
|
-
if (n)
|
|
2598
|
-
for (const i of n.instances)
|
|
2599
|
-
i.uid !== e.uid && t.push({
|
|
2600
|
-
uid: i.uid,
|
|
2601
|
-
tag: e.tag,
|
|
2602
|
-
exports: i.exports
|
|
2603
|
-
});
|
|
2604
|
-
return t;
|
|
2605
|
-
}
|
|
2606
2759
|
);
|
|
2607
2760
|
}
|
|
2761
|
+
/**
|
|
2762
|
+
* Sets up host data exchange handlers.
|
|
2763
|
+
* @internal
|
|
2764
|
+
*/
|
|
2765
|
+
setupHostDataHandlers() {
|
|
2766
|
+
this.messenger.on(u.EXPORT, async (e) => (this.exports = e, { success: !0 })), this.messenger.on(u.CONSUMER_EXPORT, async (e) => (this.consumerExports = e, { success: !0 })), this.messenger.on(
|
|
2767
|
+
u.GET_SIBLINGS,
|
|
2768
|
+
async (e) => this.getSiblingInstances(e)
|
|
2769
|
+
);
|
|
2770
|
+
}
|
|
2771
|
+
/**
|
|
2772
|
+
* Gets sibling component instances for a request.
|
|
2773
|
+
* @internal
|
|
2774
|
+
*/
|
|
2775
|
+
getSiblingInstances(e) {
|
|
2776
|
+
const t = [], n = kt(e.tag);
|
|
2777
|
+
if (!n)
|
|
2778
|
+
return t;
|
|
2779
|
+
for (const i of n.instances)
|
|
2780
|
+
i.uid !== e.uid && t.push({
|
|
2781
|
+
uid: i.uid,
|
|
2782
|
+
tag: e.tag,
|
|
2783
|
+
exports: i.exports
|
|
2784
|
+
});
|
|
2785
|
+
return t;
|
|
2786
|
+
}
|
|
2608
2787
|
/**
|
|
2609
2788
|
* Registers cleanup handlers for the instance.
|
|
2610
2789
|
* @internal
|
|
2611
2790
|
*/
|
|
2612
2791
|
setupCleanup() {
|
|
2613
2792
|
this.cleanup.register(() => {
|
|
2614
|
-
this.messenger.destroy(), this.bridge.destroy(),
|
|
2793
|
+
this.messenger.destroy(), this.bridge.destroy(), nt(this.uid);
|
|
2615
2794
|
});
|
|
2616
2795
|
}
|
|
2617
2796
|
/**
|
|
@@ -2644,10 +2823,11 @@ class se {
|
|
|
2644
2823
|
async destroy() {
|
|
2645
2824
|
this.destroyed || (this.destroyed = !0, this.initPromise && (this.initPromise.reject(
|
|
2646
2825
|
new Error(`Component "${this.options.tag}" was destroyed before initialization completed`)
|
|
2647
|
-
), this.initPromise = null), this.iframe && (
|
|
2826
|
+
), this.initPromise = null), this.hostInitialized = !1, this.iframe && (pt(this.iframe), this.iframe = null), this.context === p.POPUP && this.hostWindow && Et(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());
|
|
2648
2827
|
}
|
|
2649
2828
|
}
|
|
2650
|
-
|
|
2829
|
+
const De = "Could not resolve consumer window";
|
|
2830
|
+
class Tt {
|
|
2651
2831
|
/**
|
|
2652
2832
|
* Creates a new HostComponent instance.
|
|
2653
2833
|
*
|
|
@@ -2657,7 +2837,13 @@ class Et {
|
|
|
2657
2837
|
* @param deferInit - Whether to defer INIT until a later explicit flush
|
|
2658
2838
|
*/
|
|
2659
2839
|
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
|
|
2840
|
+
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 Ee(), this.messenger = new Pe(this.uid, window, q(), this.consumerDomain);
|
|
2841
|
+
let r = null;
|
|
2842
|
+
try {
|
|
2843
|
+
this.setupMessageHandlers(), this.consumerWindow = this.resolveConsumerWindow(), r = new J(this.messenger), this.bridge = r, this.hostProps = this.buildHostProps(e), this.exposeHostProps(), this.deferInit || this.flushInit();
|
|
2844
|
+
} catch (o) {
|
|
2845
|
+
throw r?.destroy(), this.messenger.destroy(), this.event.removeAllListeners(), this.propsHandlers.clear(), o;
|
|
2846
|
+
}
|
|
2661
2847
|
}
|
|
2662
2848
|
/** The hostProps object containing props and control methods passed from the consumer. */
|
|
2663
2849
|
hostProps;
|
|
@@ -2729,7 +2915,7 @@ class Et {
|
|
|
2729
2915
|
* @internal
|
|
2730
2916
|
*/
|
|
2731
2917
|
validateConsumerDomain() {
|
|
2732
|
-
if (this.allowedConsumerDomains && !
|
|
2918
|
+
if (this.allowedConsumerDomains && !D(this.allowedConsumerDomains, this.consumerDomain))
|
|
2733
2919
|
throw new Error(
|
|
2734
2920
|
`Consumer domain "${this.consumerDomain}" is not allowed for component "${this.tag}"`
|
|
2735
2921
|
);
|
|
@@ -2747,22 +2933,22 @@ class Et {
|
|
|
2747
2933
|
* @internal
|
|
2748
2934
|
*/
|
|
2749
2935
|
resolveConsumerWindow() {
|
|
2750
|
-
if (
|
|
2751
|
-
const e =
|
|
2936
|
+
if (Xe()) {
|
|
2937
|
+
const e = Je();
|
|
2752
2938
|
if (e) return e;
|
|
2753
2939
|
}
|
|
2754
|
-
if (
|
|
2755
|
-
const e =
|
|
2940
|
+
if (Ke()) {
|
|
2941
|
+
const e = qe();
|
|
2756
2942
|
if (e) return e;
|
|
2757
2943
|
}
|
|
2758
|
-
throw new Error(
|
|
2944
|
+
throw new Error(De);
|
|
2759
2945
|
}
|
|
2760
2946
|
/**
|
|
2761
2947
|
* Builds the hostProps object with deserialized props and control methods.
|
|
2762
2948
|
* @internal
|
|
2763
2949
|
*/
|
|
2764
2950
|
buildHostProps(e) {
|
|
2765
|
-
const t =
|
|
2951
|
+
const t = ge(
|
|
2766
2952
|
e.props,
|
|
2767
2953
|
this.propDefinitions,
|
|
2768
2954
|
this.messenger,
|
|
@@ -2801,7 +2987,7 @@ class Et {
|
|
|
2801
2987
|
await this.messenger.send(
|
|
2802
2988
|
this.consumerWindow,
|
|
2803
2989
|
this.consumerDomain,
|
|
2804
|
-
|
|
2990
|
+
u.INIT,
|
|
2805
2991
|
{ uid: this.uid, tag: this.tag }
|
|
2806
2992
|
);
|
|
2807
2993
|
} catch (e) {
|
|
@@ -2829,7 +3015,7 @@ class Et {
|
|
|
2829
3015
|
await this.messenger.send(
|
|
2830
3016
|
this.consumerWindow,
|
|
2831
3017
|
this.consumerDomain,
|
|
2832
|
-
|
|
3018
|
+
u.CLOSE,
|
|
2833
3019
|
{}
|
|
2834
3020
|
);
|
|
2835
3021
|
}
|
|
@@ -2841,7 +3027,7 @@ class Et {
|
|
|
2841
3027
|
window.focus(), await this.messenger.send(
|
|
2842
3028
|
this.consumerWindow,
|
|
2843
3029
|
this.consumerDomain,
|
|
2844
|
-
|
|
3030
|
+
u.FOCUS,
|
|
2845
3031
|
{}
|
|
2846
3032
|
);
|
|
2847
3033
|
}
|
|
@@ -2853,7 +3039,7 @@ class Et {
|
|
|
2853
3039
|
await this.messenger.send(
|
|
2854
3040
|
this.consumerWindow,
|
|
2855
3041
|
this.consumerDomain,
|
|
2856
|
-
|
|
3042
|
+
u.RESIZE,
|
|
2857
3043
|
e
|
|
2858
3044
|
);
|
|
2859
3045
|
}
|
|
@@ -2865,7 +3051,7 @@ class Et {
|
|
|
2865
3051
|
await this.messenger.send(
|
|
2866
3052
|
this.consumerWindow,
|
|
2867
3053
|
this.consumerDomain,
|
|
2868
|
-
|
|
3054
|
+
u.SHOW,
|
|
2869
3055
|
{}
|
|
2870
3056
|
);
|
|
2871
3057
|
}
|
|
@@ -2877,7 +3063,7 @@ class Et {
|
|
|
2877
3063
|
await this.messenger.send(
|
|
2878
3064
|
this.consumerWindow,
|
|
2879
3065
|
this.consumerDomain,
|
|
2880
|
-
|
|
3066
|
+
u.HIDE,
|
|
2881
3067
|
{}
|
|
2882
3068
|
);
|
|
2883
3069
|
}
|
|
@@ -2898,7 +3084,7 @@ class Et {
|
|
|
2898
3084
|
await this.messenger.send(
|
|
2899
3085
|
this.consumerWindow,
|
|
2900
3086
|
this.consumerDomain,
|
|
2901
|
-
|
|
3087
|
+
u.ERROR,
|
|
2902
3088
|
{
|
|
2903
3089
|
message: e.message,
|
|
2904
3090
|
stack: e.stack
|
|
@@ -2913,7 +3099,7 @@ class Et {
|
|
|
2913
3099
|
await this.messenger.send(
|
|
2914
3100
|
this.consumerWindow,
|
|
2915
3101
|
this.consumerDomain,
|
|
2916
|
-
|
|
3102
|
+
u.EXPORT,
|
|
2917
3103
|
e
|
|
2918
3104
|
);
|
|
2919
3105
|
}
|
|
@@ -2925,7 +3111,7 @@ class Et {
|
|
|
2925
3111
|
await this.messenger.send(
|
|
2926
3112
|
this.consumerWindow,
|
|
2927
3113
|
this.consumerDomain,
|
|
2928
|
-
|
|
3114
|
+
u.CONSUMER_EXPORT,
|
|
2929
3115
|
e
|
|
2930
3116
|
);
|
|
2931
3117
|
}
|
|
@@ -2937,7 +3123,7 @@ class Et {
|
|
|
2937
3123
|
return await this.messenger.send(
|
|
2938
3124
|
this.consumerWindow,
|
|
2939
3125
|
this.consumerDomain,
|
|
2940
|
-
|
|
3126
|
+
u.GET_SIBLINGS,
|
|
2941
3127
|
{ uid: this.uid, tag: this.tag, options: e }
|
|
2942
3128
|
) ?? [];
|
|
2943
3129
|
}
|
|
@@ -2950,7 +3136,7 @@ class Et {
|
|
|
2950
3136
|
const t = {};
|
|
2951
3137
|
for (const [n, i] of Object.entries(e))
|
|
2952
3138
|
try {
|
|
2953
|
-
t[n] =
|
|
3139
|
+
t[n] = Ce({
|
|
2954
3140
|
tag: i.tag,
|
|
2955
3141
|
url: i.url,
|
|
2956
3142
|
props: i.props,
|
|
@@ -2967,9 +3153,9 @@ class Et {
|
|
|
2967
3153
|
* @internal
|
|
2968
3154
|
*/
|
|
2969
3155
|
setupMessageHandlers() {
|
|
2970
|
-
this.messenger.on(
|
|
3156
|
+
this.messenger.on(u.PROPS, (e) => {
|
|
2971
3157
|
try {
|
|
2972
|
-
const t =
|
|
3158
|
+
const t = ge(
|
|
2973
3159
|
e,
|
|
2974
3160
|
this.propDefinitions,
|
|
2975
3161
|
this.messenger,
|
|
@@ -2977,7 +3163,7 @@ class Et {
|
|
|
2977
3163
|
this.consumerWindow,
|
|
2978
3164
|
this.consumerDomain
|
|
2979
3165
|
);
|
|
2980
|
-
Object.assign(this.hostProps, t);
|
|
3166
|
+
this.consumerProps = t, Object.assign(this.hostProps, t), this.hostProps.consumer.props = this.consumerProps;
|
|
2981
3167
|
for (const n of this.propsHandlers)
|
|
2982
3168
|
try {
|
|
2983
3169
|
n(t);
|
|
@@ -3003,8 +3189,8 @@ function ne(s, e, t = {}) {
|
|
|
3003
3189
|
if (g) {
|
|
3004
3190
|
if (e) {
|
|
3005
3191
|
const i = g.getProps().getConsumerDomain();
|
|
3006
|
-
if (!
|
|
3007
|
-
throw
|
|
3192
|
+
if (!D(e, i))
|
|
3193
|
+
throw Ht(), new Error(
|
|
3008
3194
|
`Consumer domain "${i}" is not allowed for this host component`
|
|
3009
3195
|
);
|
|
3010
3196
|
}
|
|
@@ -3012,28 +3198,37 @@ function ne(s, e, t = {}) {
|
|
|
3012
3198
|
}
|
|
3013
3199
|
if (!X())
|
|
3014
3200
|
return null;
|
|
3015
|
-
const n =
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3201
|
+
const n = et();
|
|
3202
|
+
if (!n)
|
|
3203
|
+
return console.error("Failed to parse ForgeFrame payload from window.name"), null;
|
|
3204
|
+
try {
|
|
3205
|
+
g = new Tt(
|
|
3206
|
+
n,
|
|
3207
|
+
s,
|
|
3208
|
+
e,
|
|
3209
|
+
t.deferInit ?? !1
|
|
3210
|
+
);
|
|
3211
|
+
} catch (i) {
|
|
3212
|
+
if (i instanceof Error && i.message === De)
|
|
3213
|
+
return null;
|
|
3214
|
+
throw i;
|
|
3215
|
+
}
|
|
3216
|
+
return g;
|
|
3217
|
+
}
|
|
3218
|
+
function Nt() {
|
|
3024
3219
|
return X();
|
|
3025
3220
|
}
|
|
3026
|
-
function
|
|
3221
|
+
function $t() {
|
|
3027
3222
|
return X();
|
|
3028
3223
|
}
|
|
3029
|
-
function
|
|
3224
|
+
function Ft() {
|
|
3030
3225
|
return window.hostProps;
|
|
3031
3226
|
}
|
|
3032
|
-
function
|
|
3227
|
+
function Ht() {
|
|
3033
3228
|
g && (g.destroy(), g = null), delete window.hostProps;
|
|
3034
3229
|
}
|
|
3035
|
-
const
|
|
3036
|
-
function
|
|
3230
|
+
const I = /* @__PURE__ */ new Map(), Ie = /* @__PURE__ */ Symbol("forgeframe.component.options");
|
|
3231
|
+
function Lt(s) {
|
|
3037
3232
|
if (!s.tag)
|
|
3038
3233
|
throw new Error("Component tag is required");
|
|
3039
3234
|
if (!/^[a-z][a-z0-9-]*$/.test(s.tag))
|
|
@@ -3050,14 +3245,14 @@ function xt(s) {
|
|
|
3050
3245
|
`Invalid component URL "${s.url}". Must be a valid absolute or relative URL.`
|
|
3051
3246
|
);
|
|
3052
3247
|
}
|
|
3053
|
-
if (
|
|
3248
|
+
if (I.has(s.tag))
|
|
3054
3249
|
throw new Error(`Component "${s.tag}" is already registered`);
|
|
3055
3250
|
}
|
|
3056
|
-
function
|
|
3057
|
-
|
|
3251
|
+
function Ce(s) {
|
|
3252
|
+
Lt(s);
|
|
3058
3253
|
const e = [];
|
|
3059
3254
|
let t;
|
|
3060
|
-
if (
|
|
3255
|
+
if (z(s.tag)) {
|
|
3061
3256
|
const i = ne(s.props, s.allowedConsumerDomains);
|
|
3062
3257
|
i && (t = i.hostProps);
|
|
3063
3258
|
}
|
|
@@ -3068,34 +3263,34 @@ function Se(s) {
|
|
|
3068
3263
|
o !== -1 && e.splice(o, 1);
|
|
3069
3264
|
}), r;
|
|
3070
3265
|
};
|
|
3071
|
-
return n.instances = e, n.isHost = () =>
|
|
3266
|
+
return n.instances = e, n.isHost = () => z(s.tag), n.isEmbedded = () => z(s.tag), n.hostProps = t, n[Ie] = s, n.canRenderTo = async (i) => {
|
|
3072
3267
|
try {
|
|
3073
|
-
return !!(
|
|
3268
|
+
return !!(Re(i) || s.domain);
|
|
3074
3269
|
} catch {
|
|
3075
3270
|
return !1;
|
|
3076
3271
|
}
|
|
3077
|
-
},
|
|
3272
|
+
}, I.set(s.tag, n), n;
|
|
3078
3273
|
}
|
|
3079
|
-
function
|
|
3080
|
-
return
|
|
3274
|
+
function kt(s) {
|
|
3275
|
+
return I.get(s);
|
|
3081
3276
|
}
|
|
3082
|
-
function
|
|
3083
|
-
return s[
|
|
3277
|
+
function At(s) {
|
|
3278
|
+
return s[Ie];
|
|
3084
3279
|
}
|
|
3085
|
-
async function
|
|
3280
|
+
async function Ut(s) {
|
|
3086
3281
|
await s.close();
|
|
3087
3282
|
}
|
|
3088
|
-
async function
|
|
3089
|
-
const e =
|
|
3283
|
+
async function Te(s) {
|
|
3284
|
+
const e = I.get(s);
|
|
3090
3285
|
if (!e) return;
|
|
3091
3286
|
const t = [...e.instances];
|
|
3092
3287
|
await Promise.all(t.map((n) => n.close()));
|
|
3093
3288
|
}
|
|
3094
|
-
async function
|
|
3095
|
-
const s = Array.from(
|
|
3096
|
-
await Promise.all(s.map((e) =>
|
|
3289
|
+
async function Mt() {
|
|
3290
|
+
const s = Array.from(I.keys());
|
|
3291
|
+
await Promise.all(s.map((e) => Te(e)));
|
|
3097
3292
|
}
|
|
3098
|
-
function
|
|
3293
|
+
function Wt(s, e) {
|
|
3099
3294
|
const t = Object.keys(s), n = Object.keys(e);
|
|
3100
3295
|
if (t.length !== n.length)
|
|
3101
3296
|
return !1;
|
|
@@ -3104,37 +3299,37 @@ function It(s, e) {
|
|
|
3104
3299
|
return !1;
|
|
3105
3300
|
return !0;
|
|
3106
3301
|
}
|
|
3107
|
-
function
|
|
3302
|
+
function zt(s, e) {
|
|
3108
3303
|
const { React: t } = e, { createElement: n, useRef: i, useEffect: r, useState: o, forwardRef: a } = t, c = a(
|
|
3109
3304
|
function(w, _) {
|
|
3110
3305
|
const {
|
|
3111
|
-
onRendered:
|
|
3306
|
+
onRendered: R,
|
|
3112
3307
|
onError: x,
|
|
3113
3308
|
onClose: ie,
|
|
3114
|
-
context:
|
|
3309
|
+
context: Ne,
|
|
3115
3310
|
className: re,
|
|
3116
3311
|
style: oe,
|
|
3117
|
-
...
|
|
3118
|
-
} = w,
|
|
3312
|
+
...A
|
|
3313
|
+
} = w, C = i(null), U = i(null), M = i(null), [ae, $e] = o(null);
|
|
3119
3314
|
return r(() => {
|
|
3120
|
-
const
|
|
3121
|
-
if (!
|
|
3122
|
-
const m = s(
|
|
3123
|
-
return
|
|
3124
|
-
|
|
3315
|
+
const S = C.current;
|
|
3316
|
+
if (!S) return;
|
|
3317
|
+
const m = s(A);
|
|
3318
|
+
return U.current = m, R && m.event.once("rendered", R), ie && m.event.once("close", ie), x && m.event.on("error", x), m.render(S, Ne).catch((v) => {
|
|
3319
|
+
$e(v), x?.(v);
|
|
3125
3320
|
}), () => {
|
|
3126
3321
|
m.close().catch(() => {
|
|
3127
|
-
}),
|
|
3322
|
+
}), U.current = null, M.current = null;
|
|
3128
3323
|
};
|
|
3129
3324
|
}, []), r(() => {
|
|
3130
|
-
const
|
|
3131
|
-
if (!
|
|
3132
|
-
const m =
|
|
3133
|
-
|
|
3134
|
-
x?.(
|
|
3325
|
+
const S = U.current;
|
|
3326
|
+
if (!S) return;
|
|
3327
|
+
const m = A, v = M.current;
|
|
3328
|
+
v && Wt(v, m) || (M.current = m, S.updateProps(m).catch((Fe) => {
|
|
3329
|
+
x?.(Fe);
|
|
3135
3330
|
}));
|
|
3136
|
-
}, [
|
|
3137
|
-
_ && typeof _ == "object" &&
|
|
3331
|
+
}, [A, x]), r(() => {
|
|
3332
|
+
_ && typeof _ == "object" && C.current && (_.current = C.current);
|
|
3138
3333
|
}, [_]), ae ? n(
|
|
3139
3334
|
"div",
|
|
3140
3335
|
{
|
|
@@ -3143,7 +3338,7 @@ function Tt(s, e) {
|
|
|
3143
3338
|
},
|
|
3144
3339
|
`Error: ${ae.message}`
|
|
3145
3340
|
) : n("div", {
|
|
3146
|
-
ref:
|
|
3341
|
+
ref: C,
|
|
3147
3342
|
className: re,
|
|
3148
3343
|
style: {
|
|
3149
3344
|
display: "inline-block",
|
|
@@ -3154,13 +3349,13 @@ function Tt(s, e) {
|
|
|
3154
3349
|
), l = `ForgeFrame(${s.name || "Component"})`;
|
|
3155
3350
|
return c.displayName = l, c;
|
|
3156
3351
|
}
|
|
3157
|
-
function
|
|
3352
|
+
function Bt(s) {
|
|
3158
3353
|
return function(t) {
|
|
3159
|
-
return
|
|
3354
|
+
return zt(t, { React: s });
|
|
3160
3355
|
};
|
|
3161
3356
|
}
|
|
3162
3357
|
ne(void 0, void 0, { deferInit: !0 });
|
|
3163
|
-
const
|
|
3358
|
+
const Vt = {
|
|
3164
3359
|
/**
|
|
3165
3360
|
* Create a new component definition.
|
|
3166
3361
|
*
|
|
@@ -3185,23 +3380,23 @@ const $t = {
|
|
|
3185
3380
|
* await instance.render('#container');
|
|
3186
3381
|
* ```
|
|
3187
3382
|
*/
|
|
3188
|
-
create:
|
|
3383
|
+
create: Ce,
|
|
3189
3384
|
/**
|
|
3190
3385
|
* Destroy a single component instance.
|
|
3191
3386
|
*
|
|
3192
3387
|
* @param instance - The component instance to destroy
|
|
3193
3388
|
*/
|
|
3194
|
-
destroy:
|
|
3389
|
+
destroy: Ut,
|
|
3195
3390
|
/**
|
|
3196
3391
|
* Destroy all instances of a specific component by tag.
|
|
3197
3392
|
*
|
|
3198
3393
|
* @param tag - The component tag name
|
|
3199
3394
|
*/
|
|
3200
|
-
destroyByTag:
|
|
3395
|
+
destroyByTag: Te,
|
|
3201
3396
|
/**
|
|
3202
3397
|
* Destroy all ForgeFrame component instances.
|
|
3203
3398
|
*/
|
|
3204
|
-
destroyAll:
|
|
3399
|
+
destroyAll: Mt,
|
|
3205
3400
|
/**
|
|
3206
3401
|
* Check if the current window is a host component context.
|
|
3207
3402
|
*
|
|
@@ -3211,7 +3406,7 @@ const $t = {
|
|
|
3211
3406
|
*
|
|
3212
3407
|
* @returns True if running inside a ForgeFrame iframe/popup
|
|
3213
3408
|
*/
|
|
3214
|
-
isHost:
|
|
3409
|
+
isHost: Nt,
|
|
3215
3410
|
/**
|
|
3216
3411
|
* Check if the current window is embedded by ForgeFrame.
|
|
3217
3412
|
*
|
|
@@ -3220,7 +3415,7 @@ const $t = {
|
|
|
3220
3415
|
*
|
|
3221
3416
|
* @returns True if running inside a ForgeFrame iframe/popup
|
|
3222
3417
|
*/
|
|
3223
|
-
isEmbedded:
|
|
3418
|
+
isEmbedded: $t,
|
|
3224
3419
|
/**
|
|
3225
3420
|
* Get hostProps from the current host window.
|
|
3226
3421
|
*
|
|
@@ -3229,7 +3424,7 @@ const $t = {
|
|
|
3229
3424
|
*
|
|
3230
3425
|
* @returns The hostProps object if in host context, undefined otherwise
|
|
3231
3426
|
*/
|
|
3232
|
-
getHostProps:
|
|
3427
|
+
getHostProps: Ft,
|
|
3233
3428
|
/**
|
|
3234
3429
|
* Flush host initialization in embedded contexts.
|
|
3235
3430
|
*
|
|
@@ -3245,7 +3440,7 @@ const $t = {
|
|
|
3245
3440
|
* Serialization strategy constants.
|
|
3246
3441
|
* @see {@link PROP_SERIALIZATION}
|
|
3247
3442
|
*/
|
|
3248
|
-
PROP_SERIALIZATION:
|
|
3443
|
+
PROP_SERIALIZATION: T,
|
|
3249
3444
|
/**
|
|
3250
3445
|
* Rendering context constants (IFRAME, POPUP).
|
|
3251
3446
|
* @see {@link CONTEXT}
|
|
@@ -3259,11 +3454,11 @@ const $t = {
|
|
|
3259
3454
|
/**
|
|
3260
3455
|
* Error thrown when popup window fails to open.
|
|
3261
3456
|
*/
|
|
3262
|
-
PopupOpenError:
|
|
3457
|
+
PopupOpenError: ve,
|
|
3263
3458
|
/**
|
|
3264
3459
|
* Current library version.
|
|
3265
3460
|
*/
|
|
3266
|
-
VERSION:
|
|
3461
|
+
VERSION: _e,
|
|
3267
3462
|
/**
|
|
3268
3463
|
* Check if a value is a Standard Schema (Zod, Valibot, ArkType, etc.)
|
|
3269
3464
|
*
|
|
@@ -3307,32 +3502,32 @@ const $t = {
|
|
|
3307
3502
|
};
|
|
3308
3503
|
export {
|
|
3309
3504
|
te as AnySchema,
|
|
3310
|
-
|
|
3311
|
-
|
|
3505
|
+
H as ArraySchema,
|
|
3506
|
+
G as BooleanSchema,
|
|
3312
3507
|
p as CONTEXT,
|
|
3313
3508
|
f as EVENT,
|
|
3314
3509
|
ee as EnumSchema,
|
|
3315
|
-
|
|
3316
|
-
|
|
3510
|
+
Vt as ForgeFrame,
|
|
3511
|
+
Z as FunctionSchema,
|
|
3317
3512
|
Q as LiteralSchema,
|
|
3318
3513
|
Y as NumberSchema,
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3514
|
+
L as ObjectSchema,
|
|
3515
|
+
T as PROP_SERIALIZATION,
|
|
3516
|
+
ve as PopupOpenError,
|
|
3322
3517
|
y as PropSchema,
|
|
3323
3518
|
K as StringSchema,
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3519
|
+
_e as VERSION,
|
|
3520
|
+
Ce as create,
|
|
3521
|
+
zt as createReactComponent,
|
|
3522
|
+
Vt as default,
|
|
3523
|
+
Ut as destroy,
|
|
3524
|
+
Mt as destroyAll,
|
|
3525
|
+
Te as destroyByTag,
|
|
3526
|
+
Ft as getHostProps,
|
|
3332
3527
|
ne as initHost,
|
|
3333
|
-
|
|
3334
|
-
|
|
3528
|
+
$t as isEmbedded,
|
|
3529
|
+
Nt as isHost,
|
|
3335
3530
|
b as isStandardSchema,
|
|
3336
3531
|
d as prop,
|
|
3337
|
-
|
|
3532
|
+
Bt as withReactComponent
|
|
3338
3533
|
};
|