forgeframe 0.0.3 → 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.
@@ -26,14 +26,14 @@ const p = {
26
26
  RESIZE: "resize",
27
27
  /** Emitted when component receives focus */
28
28
  FOCUS: "focus"
29
- }, I = {
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
- }, T = {
36
+ }, $ = {
37
37
  /** Request message expecting a response */
38
38
  REQUEST: "request",
39
39
  /** Response to a previous request */
@@ -63,14 +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
- }, F = "__forgeframe__", ye = (() => {
67
- if ("0.0.3".trim().length === 0)
66
+ }, F = "__forgeframe__", _e = (() => {
67
+ if ("0.0.4".trim().length === 0)
68
68
  throw new Error(
69
69
  "ForgeFrame VERSION injection is missing. Configure __FORGEFRAME_VERSION__ in build/test tooling."
70
70
  );
71
- return "0.0.3";
71
+ return "0.0.4";
72
72
  })();
73
- class we {
73
+ class Ee {
74
74
  /**
75
75
  * Internal storage for event listeners mapped by event name.
76
76
  * @internal
@@ -221,14 +221,14 @@ class we {
221
221
  return this.listeners.get(e)?.size ?? 0;
222
222
  }
223
223
  }
224
- function Fe() {
224
+ function He() {
225
225
  const s = Date.now().toString(36), e = Math.random().toString(36).slice(2, 11);
226
226
  return `${s}_${e}`;
227
227
  }
228
- function z() {
228
+ function N() {
229
229
  return Math.random().toString(36).slice(2, 11);
230
230
  }
231
- class Ne {
231
+ class Le {
232
232
  /**
233
233
  * Array of registered cleanup tasks awaiting execution.
234
234
  * @internal
@@ -346,7 +346,7 @@ class Ne {
346
346
  this.tasks = [], this.cleaned = !1;
347
347
  }
348
348
  }
349
- function _e() {
349
+ function be() {
350
350
  let s, e;
351
351
  return { promise: new Promise((n, i) => {
352
352
  s = n, e = i;
@@ -365,10 +365,10 @@ function ke(s, e, t = "Operation timed out") {
365
365
  });
366
366
  }
367
367
  const j = "forgeframe:";
368
- function M(s) {
368
+ function W(s) {
369
369
  return j + JSON.stringify(s);
370
370
  }
371
- function $e(s) {
371
+ function Ae(s) {
372
372
  if (typeof s != "string" || !s.startsWith(j)) return null;
373
373
  try {
374
374
  const e = s.slice(j.length), t = JSON.parse(e);
@@ -380,16 +380,16 @@ function $e(s) {
380
380
  function ce(s, e, t, n) {
381
381
  return {
382
382
  id: s,
383
- type: T.REQUEST,
383
+ type: $.REQUEST,
384
384
  name: e,
385
385
  data: t,
386
386
  source: n
387
387
  };
388
388
  }
389
- function Le(s, e, t, n) {
389
+ function Ue(s, e, t, n) {
390
390
  return {
391
391
  id: s,
392
- type: T.RESPONSE,
392
+ type: $.RESPONSE,
393
393
  name: "response",
394
394
  data: e,
395
395
  source: t,
@@ -399,7 +399,19 @@ function Le(s, e, t, n) {
399
399
  } : void 0
400
400
  };
401
401
  }
402
- class Ee {
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 {
403
415
  /**
404
416
  * Creates a new Messenger instance.
405
417
  *
@@ -423,6 +435,10 @@ class Ee {
423
435
  allowedOrigins = /* @__PURE__ */ new Set();
424
436
  /** @internal */
425
437
  allowedOriginPatterns = [];
438
+ /** @internal */
439
+ wildcardPatternRegistry = /* @__PURE__ */ new Map();
440
+ /** @internal */
441
+ sourceUidRegistry = /* @__PURE__ */ new WeakMap();
426
442
  /**
427
443
  * Adds a trusted domain that can send messages to this messenger.
428
444
  *
@@ -431,8 +447,13 @@ class Ee {
431
447
  addTrustedDomain(e) {
432
448
  if (Array.isArray(e))
433
449
  for (const t of e)
434
- this.allowedOrigins.add(t);
435
- else e instanceof RegExp ? this.allowedOriginPatterns.push(e) : this.allowedOrigins.add(e);
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
+ }
436
457
  }
437
458
  /**
438
459
  * Removes a trusted domain from this messenger.
@@ -442,8 +463,15 @@ class Ee {
442
463
  removeTrustedDomain(e) {
443
464
  if (Array.isArray(e))
444
465
  for (const t of e)
445
- this.allowedOrigins.delete(t);
446
- else e instanceof RegExp ? this.allowedOriginPatterns = this.allowedOriginPatterns.filter((t) => t !== e) : this.allowedOrigins.delete(e);
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
+ }
447
475
  }
448
476
  /**
449
477
  * Checks if an origin is trusted.
@@ -456,10 +484,21 @@ class Ee {
456
484
  if (this.allowedOrigins.has(e))
457
485
  return !0;
458
486
  for (const t of this.allowedOriginPatterns)
459
- if (t.test(e))
487
+ if (ze(t, e))
460
488
  return !0;
461
489
  return !1;
462
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
+ }
463
502
  /**
464
503
  * Sends a message and waits for a response.
465
504
  *
@@ -476,10 +515,10 @@ class Ee {
476
515
  async send(e, t, n, i, r = 1e4) {
477
516
  if (this.destroyed)
478
517
  throw new Error("Messenger has been destroyed");
479
- const o = z(), a = ce(o, n, i, {
518
+ const o = N(), a = ce(o, n, i, {
480
519
  uid: this.uid,
481
520
  domain: this.domain
482
- }), c = _e(), l = setTimeout(() => {
521
+ }), c = be(), l = setTimeout(() => {
483
522
  this.pending.delete(o), c.reject(new Error(`Message "${n}" timed out after ${r}ms`));
484
523
  }, r);
485
524
  this.pending.set(o, {
@@ -487,7 +526,7 @@ class Ee {
487
526
  timeout: l
488
527
  });
489
528
  try {
490
- e.postMessage(M(a), t);
529
+ e.postMessage(W(a), t);
491
530
  } catch (h) {
492
531
  throw this.pending.delete(o), clearTimeout(l), h;
493
532
  }
@@ -506,11 +545,11 @@ class Ee {
506
545
  post(e, t, n, i) {
507
546
  if (this.destroyed)
508
547
  throw new Error("Messenger has been destroyed");
509
- const r = z(), o = ce(r, n, i, {
548
+ const r = N(), o = ce(r, n, i, {
510
549
  uid: this.uid,
511
550
  domain: this.domain
512
551
  });
513
- e.postMessage(M(o), t);
552
+ e.postMessage(W(o), t);
514
553
  }
515
554
  /**
516
555
  * Registers a handler for incoming messages of a specific type.
@@ -532,8 +571,10 @@ class Ee {
532
571
  this.listener = (e) => {
533
572
  if (e.source === this.win || !this.isOriginTrusted(e.origin))
534
573
  return;
535
- const t = $e(e.data);
536
- t && this.handleMessage(t, e.source, e.origin);
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);
537
578
  }, this.win.addEventListener("message", this.listener);
538
579
  }
539
580
  /**
@@ -541,7 +582,7 @@ class Ee {
541
582
  * @internal
542
583
  */
543
584
  async handleMessage(e, t, n) {
544
- if (e.type === T.RESPONSE) {
585
+ if (e.type === $.RESPONSE) {
545
586
  const i = this.pending.get(e.id);
546
587
  if (i)
547
588
  if (this.pending.delete(e.id), clearTimeout(i.timeout), e.error) {
@@ -551,24 +592,29 @@ class Ee {
551
592
  i.deferred.resolve(e.data);
552
593
  return;
553
594
  }
554
- if (e.type === T.REQUEST) {
595
+ if (e.type === $.REQUEST) {
555
596
  const i = this.handlers.get(e.name);
556
597
  if (!i)
557
598
  return;
558
599
  let r, o;
559
600
  try {
560
- r = await i(e.data, e.source);
601
+ const c = this.resolveVerifiedSource(
602
+ t,
603
+ n,
604
+ e.source
605
+ );
606
+ r = await i(e.data, c);
561
607
  } catch (c) {
562
608
  o = c instanceof Error ? c : new Error(String(c));
563
609
  }
564
- const a = Le(
610
+ const a = Ue(
565
611
  e.id,
566
612
  r,
567
613
  { uid: this.uid, domain: this.domain },
568
614
  o
569
615
  );
570
616
  try {
571
- t.postMessage(M(a), n);
617
+ t.postMessage(W(a), n);
572
618
  } catch {
573
619
  }
574
620
  }
@@ -629,7 +675,7 @@ class J {
629
675
  const i = this.localFunctions.keys().next().value;
630
676
  i && this.localFunctions.delete(i);
631
677
  }
632
- const n = z();
678
+ const n = N();
633
679
  return this.localFunctions.set(n, e), this.currentBatchIds.add(n), {
634
680
  __type__: "function",
635
681
  __id__: n,
@@ -768,16 +814,25 @@ function B(s, e, t = /* @__PURE__ */ new WeakSet()) {
768
814
  if (Array.isArray(s)) {
769
815
  if (t.has(s))
770
816
  throw new Error("Circular reference detected in props - arrays cannot contain circular references");
771
- return t.add(s), s.map((n) => B(n, e, t));
817
+ t.add(s);
818
+ try {
819
+ return s.map((n) => B(n, e, t));
820
+ } finally {
821
+ t.delete(s);
822
+ }
772
823
  }
773
824
  if (typeof s == "object" && s !== null) {
774
825
  if (t.has(s))
775
826
  throw new Error("Circular reference detected in props - objects cannot contain circular references");
776
827
  t.add(s);
777
- const n = {};
778
- for (const [i, r] of Object.entries(s))
779
- n[i] = B(r, e, t);
780
- return n;
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
+ }
781
836
  }
782
837
  return s;
783
838
  }
@@ -787,21 +842,42 @@ function V(s, e, t, n, i = /* @__PURE__ */ new WeakSet()) {
787
842
  if (Array.isArray(s)) {
788
843
  if (i.has(s))
789
844
  throw new Error("Circular reference detected in serialized props");
790
- return i.add(s), s.map(
791
- (r) => V(r, e, t, n, i)
792
- );
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
+ }
793
853
  }
794
854
  if (typeof s == "object" && s !== null) {
795
855
  if (i.has(s))
796
856
  throw new Error("Circular reference detected in serialized props");
797
857
  i.add(s);
798
- const r = {};
799
- for (const [o, a] of Object.entries(s))
800
- r[o] = V(a, e, t, n, i);
801
- return r;
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
+ }
802
866
  }
803
867
  return s;
804
868
  }
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
+ }
805
881
  function q(s = window) {
806
882
  try {
807
883
  return s.location.origin;
@@ -809,17 +885,22 @@ function q(s = window) {
809
885
  return "";
810
886
  }
811
887
  }
812
- function be(s, e = window) {
888
+ function Re(s, e = window) {
813
889
  try {
814
890
  return s.location.origin === e.location.origin;
815
891
  } catch {
816
892
  return !1;
817
893
  }
818
894
  }
819
- function L(s, e) {
820
- return typeof s == "string" ? s === "*" ? !0 : s === e : s instanceof RegExp ? s.test(e) : Array.isArray(s) ? s.some((t) => L(t, e)) : !1;
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;
821
902
  }
822
- function Pe(s) {
903
+ function Oe(s) {
823
904
  if (!s) return !0;
824
905
  try {
825
906
  return s.closed;
@@ -827,14 +908,14 @@ function Pe(s) {
827
908
  return !0;
828
909
  }
829
910
  }
830
- function He(s = window) {
911
+ function qe(s = window) {
831
912
  try {
832
913
  return s.opener;
833
914
  } catch {
834
915
  return null;
835
916
  }
836
917
  }
837
- function Ae(s = window) {
918
+ function Je(s = window) {
838
919
  try {
839
920
  const e = s.parent;
840
921
  return e && e !== s ? e : null;
@@ -842,14 +923,14 @@ function Ae(s = window) {
842
923
  return null;
843
924
  }
844
925
  }
845
- function Ue(s = window) {
926
+ function Xe(s = window) {
846
927
  try {
847
928
  return s.parent !== s;
848
929
  } catch {
849
930
  return !0;
850
931
  }
851
932
  }
852
- function Me(s = window) {
933
+ function Ke(s = window) {
853
934
  try {
854
935
  return s.opener !== null && s.opener !== void 0;
855
936
  } catch {
@@ -857,15 +938,15 @@ function Me(s = window) {
857
938
  }
858
939
  }
859
940
  const ue = 32 * 1024;
860
- function We(s) {
861
- const e = ze(s);
941
+ function Ye(s) {
942
+ const e = Ge(s);
862
943
  return `${F}${e}`;
863
944
  }
864
- function Oe(s) {
945
+ function xe(s) {
865
946
  if (!s || !s.startsWith(F))
866
947
  return null;
867
948
  const e = s.slice(F.length);
868
- return je(e);
949
+ return Ze(e);
869
950
  }
870
951
  function X(s = window) {
871
952
  try {
@@ -874,10 +955,10 @@ function X(s = window) {
874
955
  return !1;
875
956
  }
876
957
  }
877
- function W(s, e = window) {
878
- return Oe(e.name)?.tag === s;
958
+ function z(s, e = window) {
959
+ return xe(e.name)?.tag === s;
879
960
  }
880
- function ze(s) {
961
+ function Ge(s) {
881
962
  try {
882
963
  const e = JSON.stringify(s), t = btoa(encodeURIComponent(e)), n = new Blob([t]).size;
883
964
  if (n > ue)
@@ -889,7 +970,7 @@ function ze(s) {
889
970
  throw e instanceof Error && e.message.includes("Payload size") ? e : new Error(`Failed to encode payload: ${e}`);
890
971
  }
891
972
  }
892
- function je(s) {
973
+ function Ze(s) {
893
974
  try {
894
975
  const e = decodeURIComponent(atob(s));
895
976
  return JSON.parse(e);
@@ -897,11 +978,11 @@ function je(s) {
897
978
  return null;
898
979
  }
899
980
  }
900
- function Be(s) {
981
+ function Qe(s) {
901
982
  return {
902
983
  uid: s.uid,
903
984
  tag: s.tag,
904
- version: ye,
985
+ version: _e,
905
986
  context: s.context,
906
987
  consumerDomain: s.consumerDomain,
907
988
  props: s.props,
@@ -909,27 +990,30 @@ function Be(s) {
909
990
  children: s.children
910
991
  };
911
992
  }
912
- function Ve(s = window) {
913
- return Oe(s.name);
993
+ function et(s = window) {
994
+ return xe(s.name);
914
995
  }
915
996
  const he = 100, E = /* @__PURE__ */ new Map();
916
- function qe() {
997
+ function tt() {
917
998
  const s = [];
918
999
  for (const [e, t] of E.entries())
919
- Pe(t) && s.push(e);
1000
+ Oe(t) && s.push(e);
920
1001
  for (const e of s)
921
1002
  E.delete(e);
922
1003
  }
923
- function Je(s, e) {
924
- if (E.size >= he && qe(), E.size >= he) {
1004
+ function st(s, e) {
1005
+ if (E.size >= he && tt(), E.size >= he) {
925
1006
  const t = E.keys().next().value;
926
1007
  t && E.delete(t);
927
1008
  }
928
1009
  E.set(s, e);
929
1010
  }
930
- function Xe(s) {
1011
+ function nt(s) {
931
1012
  E.delete(s);
932
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
+ }
933
1017
  class y {
934
1018
  /** @internal */
935
1019
  _optional = !1;
@@ -1023,7 +1107,7 @@ class K extends y {
1023
1107
  issues: [
1024
1108
  { message: `String must be at most ${this._maxLength} characters` }
1025
1109
  ]
1026
- } : this._pattern && !this._pattern.test(t) ? {
1110
+ } : this._pattern && !it(this._pattern, t) ? {
1027
1111
  issues: [
1028
1112
  {
1029
1113
  message: this._patternMessage || `String must match pattern ${this._pattern}`
@@ -1158,7 +1242,7 @@ class K extends y {
1158
1242
  return e._minLength = 1, e;
1159
1243
  }
1160
1244
  }
1161
- class G extends y {
1245
+ class Y extends y {
1162
1246
  /** @internal */
1163
1247
  _min;
1164
1248
  /** @internal */
@@ -1173,7 +1257,7 @@ class G extends y {
1173
1257
  }
1174
1258
  /** @internal */
1175
1259
  _clone() {
1176
- const e = new G();
1260
+ const e = new Y();
1177
1261
  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;
1178
1262
  }
1179
1263
  /**
@@ -1253,7 +1337,7 @@ class G extends y {
1253
1337
  return e._max = -Number.MIN_VALUE, e;
1254
1338
  }
1255
1339
  }
1256
- class Y extends y {
1340
+ class G extends y {
1257
1341
  /** @internal */
1258
1342
  _validate(e) {
1259
1343
  return typeof e != "boolean" ? {
@@ -1262,7 +1346,7 @@ class Y extends y {
1262
1346
  }
1263
1347
  /** @internal */
1264
1348
  _clone() {
1265
- const e = new Y();
1349
+ const e = new G();
1266
1350
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1267
1351
  }
1268
1352
  }
@@ -1279,7 +1363,7 @@ class Z extends y {
1279
1363
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1280
1364
  }
1281
1365
  }
1282
- class N extends y {
1366
+ class H extends y {
1283
1367
  /** @internal */
1284
1368
  _itemSchema;
1285
1369
  /** @internal */
@@ -1327,7 +1411,7 @@ class N extends y {
1327
1411
  }
1328
1412
  /** @internal */
1329
1413
  _clone() {
1330
- const e = new N();
1414
+ const e = new H();
1331
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;
1332
1416
  }
1333
1417
  /**
@@ -1343,7 +1427,7 @@ class N extends y {
1343
1427
  * ```
1344
1428
  */
1345
1429
  of(e) {
1346
- const t = new N();
1430
+ const t = new H();
1347
1431
  return t._optional = this._optional, t._nullable = this._nullable, t._itemSchema = e, t._minLength = this._minLength, t._maxLength = this._maxLength, t;
1348
1432
  }
1349
1433
  /**
@@ -1386,7 +1470,7 @@ class N extends y {
1386
1470
  return this.min(1);
1387
1471
  }
1388
1472
  }
1389
- class k extends y {
1473
+ class L extends y {
1390
1474
  /** @internal */
1391
1475
  _shape;
1392
1476
  /** @internal */
@@ -1435,7 +1519,7 @@ class k extends y {
1435
1519
  }
1436
1520
  /** @internal */
1437
1521
  _clone() {
1438
- const e = new k();
1522
+ const e = new L();
1439
1523
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._shape = this._shape, e._strict = this._strict, e;
1440
1524
  }
1441
1525
  /**
@@ -1453,7 +1537,7 @@ class k extends y {
1453
1537
  * ```
1454
1538
  */
1455
1539
  shape(e) {
1456
- const t = new k();
1540
+ const t = new L();
1457
1541
  return t._optional = this._optional, t._nullable = this._nullable, t._shape = e, t._strict = this._strict, t;
1458
1542
  }
1459
1543
  /**
@@ -1548,7 +1632,7 @@ const d = {
1548
1632
  * prop.number().positive()
1549
1633
  * ```
1550
1634
  */
1551
- number: () => new G(),
1635
+ number: () => new Y(),
1552
1636
  /**
1553
1637
  * Creates a boolean schema.
1554
1638
  *
@@ -1558,7 +1642,7 @@ const d = {
1558
1642
  * prop.boolean().default(false)
1559
1643
  * ```
1560
1644
  */
1561
- boolean: () => new Y(),
1645
+ boolean: () => new G(),
1562
1646
  /**
1563
1647
  * Creates a function schema.
1564
1648
  *
@@ -1584,7 +1668,7 @@ const d = {
1584
1668
  * prop.array().of(prop.number()).min(1).max(10)
1585
1669
  * ```
1586
1670
  */
1587
- array: () => new N(),
1671
+ array: () => new H(),
1588
1672
  /**
1589
1673
  * Creates an object schema.
1590
1674
  *
@@ -1600,7 +1684,7 @@ const d = {
1600
1684
  * prop.object().shape({ key: prop.string() }).strict()
1601
1685
  * ```
1602
1686
  */
1603
- object: () => new k(),
1687
+ object: () => new L(),
1604
1688
  /**
1605
1689
  * Creates a literal schema for exact value matching.
1606
1690
  *
@@ -1708,19 +1792,19 @@ const d = {
1708
1792
  function b(s) {
1709
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";
1710
1794
  }
1711
- function Ke(s, e, t) {
1795
+ function rt(s, e, t) {
1712
1796
  const n = s["~standard"].validate(e);
1713
1797
  if (n instanceof Promise)
1714
1798
  throw new Error(
1715
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.`
1716
1800
  );
1717
1801
  if (n.issues) {
1718
- const i = n.issues.map((r) => `${Ge(r.path, t)}: ${r.message}`);
1802
+ const i = n.issues.map((r) => `${ot(r.path, t)}: ${r.message}`);
1719
1803
  throw new Error(`Validation failed: ${i.join("; ")}`);
1720
1804
  }
1721
1805
  return n.value;
1722
1806
  }
1723
- function Ge(s, e) {
1807
+ function ot(s, e) {
1724
1808
  if (!s || s.length === 0)
1725
1809
  return e;
1726
1810
  const t = s.map((n) => {
@@ -1752,14 +1836,14 @@ function de(s, e, t) {
1752
1836
  else if (c.default !== void 0)
1753
1837
  l = typeof c.default == "function" ? c.default(t) : c.default;
1754
1838
  else if (c.schema && b(c.schema)) {
1755
- const O = c.schema["~standard"].validate(void 0);
1756
- !(O instanceof Promise) && !O.issues && (l = O.value);
1839
+ const R = c.schema["~standard"].validate(void 0);
1840
+ !(R instanceof Promise) && !R.issues && (l = R.value);
1757
1841
  }
1758
1842
  l !== void 0 && c.decorate && (l = c.decorate({ value: l, props: i })), i[r] = l;
1759
1843
  }
1760
1844
  return i;
1761
1845
  }
1762
- function Ye(s, e) {
1846
+ function fe(s, e) {
1763
1847
  const t = {
1764
1848
  ...P,
1765
1849
  ...e
@@ -1770,13 +1854,13 @@ function Ye(s, e) {
1770
1854
  if (o.required && a === void 0)
1771
1855
  throw new Error(`Prop "${n}" is required but was not provided`);
1772
1856
  if (o.schema && b(o.schema))
1773
- (a !== void 0 || r) && (a = Ke(o.schema, a, n), s[n] = a);
1857
+ (a !== void 0 || r) && (a = rt(o.schema, a, n), s[n] = a);
1774
1858
  else if (a === void 0)
1775
1859
  continue;
1776
1860
  o.validate && o.validate({ value: a, props: s });
1777
1861
  }
1778
1862
  }
1779
- function fe(s, e, t, n) {
1863
+ function pe(s, e, t, n) {
1780
1864
  const i = {
1781
1865
  ...P,
1782
1866
  ...e
@@ -1786,14 +1870,14 @@ function fe(s, e, t, n) {
1786
1870
  if (l.sendToHost === !1 || l.sameDomain && !n) continue;
1787
1871
  if (l.trustedDomains) {
1788
1872
  const _ = l.trustedDomains;
1789
- if (!L(_, t)) continue;
1873
+ if (!D(_, t)) continue;
1790
1874
  }
1791
1875
  let w = h;
1792
1876
  l.hostDecorate && h !== void 0 && (w = l.hostDecorate({ value: h, props: s })), r[o] = w;
1793
1877
  }
1794
1878
  return r;
1795
1879
  }
1796
- function Ze(s, e) {
1880
+ function at(s, e) {
1797
1881
  const t = new URLSearchParams(), n = {
1798
1882
  ...P,
1799
1883
  ...e
@@ -1807,7 +1891,7 @@ function Ze(s, e) {
1807
1891
  }
1808
1892
  return t;
1809
1893
  }
1810
- function Qe(s, e) {
1894
+ function ct(s, e) {
1811
1895
  const t = new URLSearchParams(), n = {
1812
1896
  ...P,
1813
1897
  ...e
@@ -1821,12 +1905,12 @@ function Qe(s, e) {
1821
1905
  }
1822
1906
  return t;
1823
1907
  }
1824
- function Re(s, e = "") {
1908
+ function Se(s, e = "") {
1825
1909
  const t = [];
1826
1910
  for (const [n, i] of Object.entries(s)) {
1827
1911
  const r = e ? `${e}.${n}` : n;
1828
1912
  if (i !== null && typeof i == "object" && !Array.isArray(i))
1829
- t.push(Re(i, r));
1913
+ t.push(Se(i, r));
1830
1914
  else {
1831
1915
  const o = encodeURIComponent(JSON.stringify(i));
1832
1916
  t.push(`${r}=${o}`);
@@ -1834,7 +1918,7 @@ function Re(s, e = "") {
1834
1918
  }
1835
1919
  return t.filter(Boolean).join("&");
1836
1920
  }
1837
- function et(s) {
1921
+ function lt(s) {
1838
1922
  const e = {};
1839
1923
  if (!s) return e;
1840
1924
  const t = s.split("&");
@@ -1857,10 +1941,10 @@ function et(s) {
1857
1941
  }
1858
1942
  return e;
1859
1943
  }
1860
- function tt(s) {
1944
+ function ut(s) {
1861
1945
  return typeof s == "object" && s !== null && s.__type__ === "dotify" && typeof s.__value__ == "string";
1862
1946
  }
1863
- function pe(s, e, t) {
1947
+ function me(s, e, t) {
1864
1948
  const n = {
1865
1949
  ...P,
1866
1950
  ...e
@@ -1868,34 +1952,34 @@ function pe(s, e, t) {
1868
1952
  for (const [r, o] of Object.entries(s)) {
1869
1953
  if (o === void 0) continue;
1870
1954
  const a = n[r];
1871
- i[r] = st(o, a, t);
1955
+ i[r] = ht(o, a, t);
1872
1956
  }
1873
1957
  return i;
1874
1958
  }
1875
- function st(s, e, t) {
1959
+ function ht(s, e, t) {
1876
1960
  if (typeof s == "function")
1877
1961
  return t.serialize(s);
1878
- const n = e?.serialization ?? I.JSON;
1879
- if (n === I.BASE64 && typeof s == "object") {
1962
+ const n = e?.serialization ?? T.JSON;
1963
+ if (n === T.BASE64 && typeof s == "object") {
1880
1964
  const i = JSON.stringify(s);
1881
1965
  return {
1882
1966
  __type__: "base64",
1883
1967
  __value__: btoa(encodeURIComponent(i))
1884
1968
  };
1885
1969
  }
1886
- return n === I.DOTIFY && typeof s == "object" && s !== null && !Array.isArray(s) ? {
1970
+ return n === T.DOTIFY && typeof s == "object" && s !== null && !Array.isArray(s) ? {
1887
1971
  __type__: "dotify",
1888
- __value__: Re(s)
1972
+ __value__: Se(s)
1889
1973
  } : B(s, t);
1890
1974
  }
1891
- function me(s, e, t, n, i, r) {
1975
+ function ge(s, e, t, n, i, r) {
1892
1976
  const o = {
1893
1977
  ...P,
1894
1978
  ...e
1895
1979
  }, a = {};
1896
1980
  for (const [c, l] of Object.entries(s)) {
1897
1981
  const h = o[c];
1898
- a[c] = nt(
1982
+ a[c] = dt(
1899
1983
  l,
1900
1984
  h,
1901
1985
  t,
@@ -1906,65 +1990,65 @@ function me(s, e, t, n, i, r) {
1906
1990
  }
1907
1991
  return a;
1908
1992
  }
1909
- function nt(s, e, t, n, i, r) {
1910
- if (it(s))
1993
+ function dt(s, e, t, n, i, r) {
1994
+ if (ft(s))
1911
1995
  try {
1912
1996
  const o = decodeURIComponent(atob(s.__value__));
1913
1997
  return JSON.parse(o);
1914
1998
  } catch {
1915
1999
  return s;
1916
2000
  }
1917
- if (tt(s))
2001
+ if (ut(s))
1918
2002
  try {
1919
- return et(s.__value__);
2003
+ return lt(s.__value__);
1920
2004
  } catch {
1921
2005
  return s;
1922
2006
  }
1923
2007
  return V(s, n, i, r);
1924
2008
  }
1925
- function it(s) {
2009
+ function ft(s) {
1926
2010
  return typeof s == "object" && s !== null && s.__type__ === "base64" && typeof s.__value__ == "string";
1927
2011
  }
1928
- function R(s, e = "100%") {
2012
+ function O(s, e = "100%") {
1929
2013
  return s === void 0 ? e : typeof s == "number" ? `${s}px` : s;
1930
2014
  }
1931
- function $(s, e) {
2015
+ function k(s, e) {
1932
2016
  if (s === void 0) return e;
1933
2017
  if (typeof s == "number") return s;
1934
2018
  const t = parseInt(s, 10);
1935
2019
  return isNaN(t) ? e : t;
1936
2020
  }
1937
- function rt(s) {
2021
+ function pt(s) {
1938
2022
  try {
1939
2023
  s.src = "about:blank", s.parentNode?.removeChild(s);
1940
2024
  } catch {
1941
2025
  }
1942
2026
  }
1943
- function ot(s, e) {
1944
- lt(s, e);
2027
+ function mt(s, e) {
2028
+ wt(s, e);
1945
2029
  }
1946
- function at(s) {
2030
+ function gt(s) {
1947
2031
  s.style.display = "", s.style.visibility = "visible";
1948
2032
  }
1949
- function ge(s) {
2033
+ function ye(s) {
1950
2034
  s.style.display = "none", s.style.visibility = "hidden";
1951
2035
  }
1952
- function ct(s) {
2036
+ function yt(s) {
1953
2037
  try {
1954
2038
  s.focus(), s.contentWindow?.focus();
1955
2039
  } catch {
1956
2040
  }
1957
2041
  }
1958
- function lt(s, e) {
1959
- e.width !== void 0 && (s.style.width = R(e.width)), e.height !== void 0 && (s.style.height = R(e.height));
2042
+ function wt(s, e) {
2043
+ e.width !== void 0 && (s.style.width = O(e.width)), e.height !== void 0 && (s.style.height = O(e.height));
1960
2044
  }
1961
2045
  class ve extends Error {
1962
2046
  constructor(e = "Popup blocked by browser") {
1963
2047
  super(e), this.name = "PopupOpenError";
1964
2048
  }
1965
2049
  }
1966
- function ut(s) {
1967
- const { url: e, name: t, dimensions: n } = s, i = $(n.width, 500), r = $(n.height, 500), o = Math.floor(window.screenX + (window.outerWidth - i) / 2), a = Math.floor(window.screenY + (window.outerHeight - r) / 2), c = [
2050
+ function _t(s) {
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 = [
1968
2052
  `width=${i}`,
1969
2053
  `height=${r}`,
1970
2054
  `left=${o}`,
@@ -1977,23 +2061,23 @@ function ut(s) {
1977
2061
  "resizable=yes",
1978
2062
  "scrollbars=yes"
1979
2063
  ].join(","), l = window.open(e, t, c);
1980
- if (!l || ft(l))
2064
+ if (!l || Pt(l))
1981
2065
  throw new ve();
1982
2066
  return l;
1983
2067
  }
1984
- function ht(s) {
2068
+ function Et(s) {
1985
2069
  try {
1986
2070
  s.closed || s.close();
1987
2071
  } catch {
1988
2072
  }
1989
2073
  }
1990
- function dt(s) {
2074
+ function bt(s) {
1991
2075
  try {
1992
2076
  s.closed || s.focus();
1993
2077
  } catch {
1994
2078
  }
1995
2079
  }
1996
- function ft(s) {
2080
+ function Pt(s) {
1997
2081
  if (!s) return !0;
1998
2082
  try {
1999
2083
  return !!(s.closed || s.innerHeight === 0 || s.innerWidth === 0);
@@ -2001,7 +2085,7 @@ function ft(s) {
2001
2085
  return !0;
2002
2086
  }
2003
2087
  }
2004
- function pt(s, e, t = {}) {
2088
+ function Rt(s, e, t = {}) {
2005
2089
  const {
2006
2090
  initialInterval: n = 100,
2007
2091
  // Start fast to catch quick closes
@@ -2035,9 +2119,9 @@ function pt(s, e, t = {}) {
2035
2119
  c = !0, clearTimeout(a);
2036
2120
  };
2037
2121
  }
2038
- function mt(s, e) {
2122
+ function Ot(s, e) {
2039
2123
  try {
2040
- const t = $(e.width, s.outerWidth), n = $(
2124
+ const t = k(e.width, s.outerWidth), n = k(
2041
2125
  e.height,
2042
2126
  s.outerHeight
2043
2127
  );
@@ -2045,24 +2129,42 @@ function mt(s, e) {
2045
2129
  } catch {
2046
2130
  }
2047
2131
  }
2048
- function gt(s) {
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) {
2049
2149
  const { doc: e, dimensions: t, uid: n, tag: i } = s, r = e.createElement("div");
2050
2150
  return r.id = `forgeframe-container-${n}`, r.setAttribute("data-forgeframe-tag", i), Object.assign(r.style, {
2051
2151
  display: "inline-block",
2052
2152
  position: "relative",
2053
- width: R(t.width),
2054
- height: R(t.height),
2153
+ width: O(t.width),
2154
+ height: O(t.height),
2055
2155
  overflow: "hidden"
2056
2156
  }), r;
2057
2157
  }
2058
- function yt(s) {
2059
- const { doc: e, dimensions: t, cspNonce: n } = s, i = e.createElement("div");
2158
+ function vt(s) {
2159
+ const { doc: e, dimensions: t, cspNonce: n } = s;
2160
+ xt(e, n);
2161
+ const i = e.createElement("div");
2060
2162
  Object.assign(i.style, {
2061
2163
  display: "flex",
2062
2164
  alignItems: "center",
2063
2165
  justifyContent: "center",
2064
- width: R(t.width),
2065
- height: R(t.height),
2166
+ width: O(t.width),
2167
+ height: O(t.height),
2066
2168
  backgroundColor: "#f5f5f5",
2067
2169
  position: "absolute",
2068
2170
  top: "0",
@@ -2070,33 +2172,27 @@ function yt(s) {
2070
2172
  zIndex: "100"
2071
2173
  });
2072
2174
  const r = e.createElement("div");
2073
- Object.assign(r.style, {
2175
+ return Object.assign(r.style, {
2074
2176
  width: "40px",
2075
2177
  height: "40px",
2076
2178
  border: "3px solid #e0e0e0",
2077
2179
  borderTopColor: "#3498db",
2078
2180
  borderRadius: "50%",
2079
2181
  animation: "forgeframe-spin 1s linear infinite"
2080
- });
2081
- const o = e.createElement("style");
2082
- return n && o.setAttribute("nonce", n), o.textContent = `
2083
- @keyframes forgeframe-spin {
2084
- to { transform: rotate(360deg); }
2085
- }
2086
- `, i.appendChild(o), i.appendChild(r), i;
2182
+ }), i.appendChild(r), i;
2087
2183
  }
2088
- function wt(s, e = 200) {
2184
+ function Dt(s, e = 200) {
2089
2185
  return new Promise((t) => {
2090
2186
  s.style.opacity = "0", s.style.transition = `opacity ${e}ms ease-in`, s.offsetHeight, s.style.opacity = "1", setTimeout(t, e);
2091
2187
  });
2092
2188
  }
2093
- function _t(s, e = 200) {
2189
+ function It(s, e = 200) {
2094
2190
  return new Promise((t) => {
2095
2191
  s.style.transition = `opacity ${e}ms ease-out`, s.style.opacity = "0", setTimeout(t, e);
2096
2192
  });
2097
2193
  }
2098
- async function Et(s, e, t) {
2099
- e && (await _t(e, 150), e.remove()), t.style.display = "", t.style.visibility = "visible", t.style.opacity = "0", await wt(t, 150);
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);
2100
2196
  }
2101
2197
  class se {
2102
2198
  /** Event emitter for lifecycle events. */
@@ -2143,6 +2239,8 @@ class se {
2143
2239
  /** @internal */
2144
2240
  initPromise = null;
2145
2241
  /** @internal */
2242
+ hostInitialized = !1;
2243
+ /** @internal */
2146
2244
  rendered = !1;
2147
2245
  /** @internal */
2148
2246
  destroyed = !1;
@@ -2153,11 +2251,11 @@ class se {
2153
2251
  * @param props - Initial props to pass to the component
2154
2252
  */
2155
2253
  constructor(e, t = {}) {
2156
- this._uid = Fe(), this.options = this.normalizeOptions(e), this.context = this.options.defaultContext, this.event = new we(), this.cleanup = new Ne();
2254
+ this._uid = He(), this.options = this.normalizeOptions(e), this.context = this.options.defaultContext, this.event = new Ee(), this.cleanup = new Le();
2157
2255
  const n = this.createPropContext();
2158
2256
  this.props = de(t, this.options.props, n);
2159
2257
  const i = this.buildTrustedDomains();
2160
- this.messenger = new Ee(this.uid, window, q(), i), this.bridge = new J(this.messenger), this.setupMessageHandlers(), this.setupCleanup();
2258
+ this.messenger = new Pe(this.uid, window, q(), i), this.bridge = new J(this.messenger), this.setupMessageHandlers(), this.setupCleanup();
2161
2259
  }
2162
2260
  /**
2163
2261
  * Builds the list of trusted domains for messenger communication.
@@ -2165,15 +2263,8 @@ class se {
2165
2263
  */
2166
2264
  buildTrustedDomains() {
2167
2265
  const e = [], t = this.resolveUrlOrigin(this.resolveUrl());
2168
- if (t && (e.push(t), this.dynamicUrlTrustedOrigin = t), this.options.domain) {
2169
- if (typeof this.options.domain == "string")
2170
- e.push(this.options.domain);
2171
- else if (Array.isArray(this.options.domain))
2172
- e.push(...this.options.domain);
2173
- else if (this.options.domain instanceof RegExp)
2174
- return this.options.domain;
2175
- }
2176
- 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;
2177
2268
  }
2178
2269
  /**
2179
2270
  * Renders the component into a DOM container.
@@ -2198,11 +2289,18 @@ class se {
2198
2289
  throw new Error("Component has been destroyed");
2199
2290
  if (this.rendered)
2200
2291
  throw new Error("Component has already been rendered");
2201
- this.context = t ?? this.options.defaultContext, this.checkEligibility(), Ye(this.props, this.options.props), this.options.validate?.({ props: this.props }), this.container = this.resolveContainer(e), this.event.emit(f.PRERENDER), this.callPropCallback("onPrerender"), await this.prerender(), this.event.emit(f.PRERENDERED), this.callPropCallback("onPrerendered"), this.event.emit(f.RENDER), this.callPropCallback("onRender"), await this.open(), await this.waitForHost(), this.context === p.IFRAME && this.iframe && this.prerenderElement && (await Et(
2202
- this.container,
2203
- this.prerenderElement,
2204
- this.iframe
2205
- ), this.prerenderElement = null), this.rendered = !0, this.event.emit(f.RENDERED), this.callPropCallback("onRendered"), this.event.emit(f.DISPLAY), this.callPropCallback("onDisplay");
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");
2206
2304
  }
2207
2305
  /**
2208
2306
  * Renders the component into a container in a different window.
@@ -2234,7 +2332,7 @@ class se {
2234
2332
  * For iframes, focuses the iframe element. For popups, brings the window to front.
2235
2333
  */
2236
2334
  async focus() {
2237
- this.context === p.IFRAME && this.iframe ? ct(this.iframe) : this.context === p.POPUP && this.hostWindow && dt(this.hostWindow), this.event.emit(f.FOCUS), this.callPropCallback("onFocus");
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");
2238
2336
  }
2239
2337
  /**
2240
2338
  * Resizes the component to the specified dimensions.
@@ -2242,7 +2340,7 @@ class se {
2242
2340
  * @param dimensions - New width and height for the component
2243
2341
  */
2244
2342
  async resize(e) {
2245
- this.context === p.IFRAME && this.iframe ? ot(this.iframe, e) : this.context === p.POPUP && this.hostWindow && mt(this.hostWindow, e), this.event.emit(f.RESIZE, e), this.callPropCallback("onResize", e);
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);
2246
2344
  }
2247
2345
  /**
2248
2346
  * Shows the component if hidden.
@@ -2251,7 +2349,7 @@ class se {
2251
2349
  * Only applicable to iframe context.
2252
2350
  */
2253
2351
  async show() {
2254
- this.context === p.IFRAME && this.iframe && at(this.iframe);
2352
+ this.context === p.IFRAME && this.iframe && gt(this.iframe);
2255
2353
  }
2256
2354
  /**
2257
2355
  * Hides the component.
@@ -2260,13 +2358,13 @@ class se {
2260
2358
  * Only applicable to iframe context.
2261
2359
  */
2262
2360
  async hide() {
2263
- this.context === p.IFRAME && this.iframe && ge(this.iframe);
2361
+ this.context === p.IFRAME && this.iframe && ye(this.iframe);
2264
2362
  }
2265
2363
  /**
2266
2364
  * Updates the component props and sends them to the host.
2267
2365
  *
2268
2366
  * @remarks
2269
- * Props are normalized and serialized before being sent to the host window.
2367
+ * Props are normalized and validated before being sent to the host window.
2270
2368
  *
2271
2369
  * @param newProps - Partial props object to merge with existing props
2272
2370
  */
@@ -2276,19 +2374,19 @@ class se {
2276
2374
  this.options.props,
2277
2375
  t
2278
2376
  );
2279
- this.options.validate?.({ props: n });
2377
+ fe(n, this.options.props), this.options.validate?.({ props: n });
2280
2378
  const i = this.resolveUrl(n), r = this.resolveUrlOrigin(i);
2281
2379
  if (this.rendered && this.openedHostDomain && r && r !== this.openedHostDomain)
2282
2380
  throw new Error(
2283
2381
  `Cannot change component URL origin after render (from "${this.openedHostDomain}" to "${r}")`
2284
2382
  );
2285
- if (this.props = n, this.rendered || this.syncTrustedDomainForUrl(i), this.hostWindow && !Pe(this.hostWindow)) {
2286
- const o = this.openedHostDomain ?? this.getHostDomain(), a = fe(
2383
+ if (this.props = n, this.rendered || this.syncTrustedDomainForUrl(i), this.hostWindow && !Oe(this.hostWindow)) {
2384
+ const o = this.openedHostDomain ?? this.getHostDomain(), a = pe(
2287
2385
  n,
2288
2386
  this.options.props,
2289
2387
  o,
2290
- be(this.hostWindow)
2291
- ), c = pe(
2388
+ Re(this.hostWindow)
2389
+ ), c = me(
2292
2390
  a,
2293
2391
  this.options.props,
2294
2392
  this.bridge
@@ -2362,7 +2460,7 @@ class se {
2362
2460
  * @internal
2363
2461
  */
2364
2462
  isExplicitDomainTrust(e) {
2365
- return !this.options.domain || this.options.domain instanceof RegExp ? !1 : typeof this.options.domain == "string" ? this.options.domain === e : this.options.domain.includes(e);
2463
+ return this.options.domain ? D(this.options.domain, e) : !1;
2366
2464
  }
2367
2465
  /**
2368
2466
  * Ensures the messenger trusts the origin for a resolved host URL.
@@ -2422,10 +2520,10 @@ class se {
2422
2520
  */
2423
2521
  async prerender() {
2424
2522
  if (!this.container) return;
2425
- const e = this.options.prerenderTemplate ?? yt, t = this.options.containerTemplate ?? gt, n = this.resolveDimensions(), i = this.props.cspNonce;
2523
+ const e = this.options.prerenderTemplate ?? vt, t = this.options.containerTemplate ?? St, n = this.resolveDimensions(), i = this.props.cspNonce;
2426
2524
  if (this.context === p.IFRAME) {
2427
2525
  const c = this.buildWindowName();
2428
- this.iframe = this.createIframeElement(c), ge(this.iframe);
2526
+ this.iframe = this.createIframeElement(c), ye(this.iframe);
2429
2527
  }
2430
2528
  const r = {
2431
2529
  uid: this.uid,
@@ -2495,24 +2593,24 @@ class se {
2495
2593
  i ? this.submitBodyForm(this.iframe.name, t, n) : this.iframe.src = t, this.hostWindow = this.iframe.contentWindow;
2496
2594
  } else {
2497
2595
  const r = this.buildWindowName();
2498
- this.hostWindow = ut({
2596
+ this.hostWindow = _t({
2499
2597
  url: i ? "about:blank" : t,
2500
2598
  name: r,
2501
2599
  dimensions: this.resolveDimensions()
2502
2600
  }), i && this.submitBodyForm(r, t, n);
2503
- const o = pt(this.hostWindow, () => {
2504
- this.destroy();
2601
+ const o = Rt(this.hostWindow, () => {
2602
+ this.close();
2505
2603
  });
2506
2604
  this.cleanup.register(o);
2507
2605
  }
2508
- this.hostWindow && Je(this.uid, this.hostWindow);
2606
+ this.hostWindow && st(this.uid, this.hostWindow);
2509
2607
  }
2510
2608
  /**
2511
2609
  * Builds the URL for the host window including query parameters.
2512
2610
  * @internal
2513
2611
  */
2514
2612
  buildUrl(e = this.resolveUrl()) {
2515
- const n = Ze(this.props, this.options.props).toString();
2613
+ const n = at(this.props, this.options.props).toString();
2516
2614
  if (!n) return e;
2517
2615
  const i = e.includes("?") ? "&" : "?";
2518
2616
  return `${e}${i}${n}`;
@@ -2522,7 +2620,7 @@ class se {
2522
2620
  * @internal
2523
2621
  */
2524
2622
  buildBodyParams() {
2525
- return Qe(this.props, this.options.props);
2623
+ return ct(this.props, this.options.props);
2526
2624
  }
2527
2625
  /**
2528
2626
  * Submits a hidden form to navigate a target window via POST.
@@ -2550,17 +2648,17 @@ class se {
2550
2648
  * @internal
2551
2649
  */
2552
2650
  buildWindowName() {
2553
- const e = this.getHostDomain(), t = fe(
2651
+ const e = this.getHostDomain(), t = pe(
2554
2652
  this.props,
2555
2653
  this.options.props,
2556
2654
  e,
2557
2655
  !1
2558
2656
  // Assume cross-domain for initial payload
2559
- ), n = pe(
2657
+ ), n = me(
2560
2658
  t,
2561
2659
  this.options.props,
2562
2660
  this.bridge
2563
- ), i = this.buildNestedHostRefs(), r = Be({
2661
+ ), i = this.buildNestedHostRefs(), r = Qe({
2564
2662
  uid: this.uid,
2565
2663
  tag: this.options.tag,
2566
2664
  context: this.context,
@@ -2569,7 +2667,7 @@ class se {
2569
2667
  exports: this.createConsumerExports(),
2570
2668
  children: i
2571
2669
  });
2572
- return We(r);
2670
+ return Ye(r);
2573
2671
  }
2574
2672
  /**
2575
2673
  * Builds component references for nested host components.
@@ -2579,7 +2677,7 @@ class se {
2579
2677
  if (!this.options.children) return;
2580
2678
  const e = this.options.children({ props: this.props }), t = {};
2581
2679
  for (const [n, i] of Object.entries(e)) {
2582
- const r = Ct(i);
2680
+ const r = At(i);
2583
2681
  if (!r)
2584
2682
  throw new Error(`Nested component "${n}" is missing component metadata`);
2585
2683
  if (typeof r.url != "string")
@@ -2624,15 +2722,20 @@ class se {
2624
2722
  * @internal
2625
2723
  */
2626
2724
  async waitForHost() {
2627
- this.initPromise = _e();
2725
+ if (this.hostInitialized)
2726
+ return;
2727
+ const e = be();
2728
+ this.initPromise = e;
2628
2729
  try {
2629
2730
  await ke(
2630
- this.initPromise.promise,
2731
+ e.promise,
2631
2732
  this.options.timeout,
2632
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.`
2633
2734
  );
2634
- } catch (e) {
2635
- throw this.handleError(e), e;
2735
+ } catch (t) {
2736
+ throw this.handleError(t), t;
2737
+ } finally {
2738
+ this.initPromise === e && (this.initPromise = null);
2636
2739
  }
2637
2740
  }
2638
2741
  /**
@@ -2640,34 +2743,54 @@ class se {
2640
2743
  * @internal
2641
2744
  */
2642
2745
  setupMessageHandlers() {
2643
- this.messenger.on(u.INIT, () => (this.initPromise && this.initPromise.resolve(), { success: !0 })), this.messenger.on(u.CLOSE, async () => (await this.close(), { success: !0 })), this.messenger.on(u.RESIZE, async (e) => (await this.resize(e), { success: !0 })), this.messenger.on(u.FOCUS, async () => (await this.focus(), { success: !0 })), this.messenger.on(u.SHOW, async () => (await this.show(), { success: !0 })), this.messenger.on(u.HIDE, async () => (await this.hide(), { success: !0 })), this.messenger.on(
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(
2644
2754
  u.ERROR,
2645
2755
  async (e) => {
2646
2756
  const t = new Error(e.message);
2647
2757
  return t.stack = e.stack, this.handleError(t), { success: !0 };
2648
2758
  }
2649
- ), this.messenger.on(u.EXPORT, async (e) => (this.exports = e, { success: !0 })), this.messenger.on(u.CONSUMER_EXPORT, async (e) => (this.consumerExports = e, { success: !0 })), this.messenger.on(
2759
+ );
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(
2650
2767
  u.GET_SIBLINGS,
2651
- async (e) => {
2652
- const t = [], n = xt(e.tag);
2653
- if (n)
2654
- for (const i of n.instances)
2655
- i.uid !== e.uid && t.push({
2656
- uid: i.uid,
2657
- tag: e.tag,
2658
- exports: i.exports
2659
- });
2660
- return t;
2661
- }
2768
+ async (e) => this.getSiblingInstances(e)
2662
2769
  );
2663
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
+ }
2664
2787
  /**
2665
2788
  * Registers cleanup handlers for the instance.
2666
2789
  * @internal
2667
2790
  */
2668
2791
  setupCleanup() {
2669
2792
  this.cleanup.register(() => {
2670
- this.messenger.destroy(), this.bridge.destroy(), Xe(this.uid);
2793
+ this.messenger.destroy(), this.bridge.destroy(), nt(this.uid);
2671
2794
  });
2672
2795
  }
2673
2796
  /**
@@ -2700,10 +2823,11 @@ class se {
2700
2823
  async destroy() {
2701
2824
  this.destroyed || (this.destroyed = !0, this.initPromise && (this.initPromise.reject(
2702
2825
  new Error(`Component "${this.options.tag}" was destroyed before initialization completed`)
2703
- ), this.initPromise = null), this.iframe && (rt(this.iframe), this.iframe = null), this.context === p.POPUP && this.hostWindow && ht(this.hostWindow), this.hostWindow = null, this.openedHostDomain = null, this.dynamicUrlTrustedOrigin = null, this.prerenderElement && (this.prerenderElement.remove(), this.prerenderElement = null), await this.cleanup.cleanup(), this.event.emit(f.DESTROY), this.callPropCallback("onDestroy"), this.event.removeAllListeners());
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());
2704
2827
  }
2705
2828
  }
2706
- class bt {
2829
+ const De = "Could not resolve consumer window";
2830
+ class Tt {
2707
2831
  /**
2708
2832
  * Creates a new HostComponent instance.
2709
2833
  *
@@ -2713,7 +2837,13 @@ class bt {
2713
2837
  * @param deferInit - Whether to defer INIT until a later explicit flush
2714
2838
  */
2715
2839
  constructor(e, t = {}, n, i = !1) {
2716
- this.propDefinitions = t, this.allowedConsumerDomains = n, this.deferInit = i, this.uid = e.uid, this.tag = e.tag, this.consumerDomain = e.consumerDomain, this.validateConsumerDomain(), this.event = new we(), this.messenger = new Ee(this.uid, window, q(), this.consumerDomain), this.setupMessageHandlers(), this.consumerWindow = this.resolveConsumerWindow(), this.bridge = new J(this.messenger), this.hostProps = this.buildHostProps(e), this.exposeHostProps(), this.deferInit || this.flushInit();
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
+ }
2717
2847
  }
2718
2848
  /** The hostProps object containing props and control methods passed from the consumer. */
2719
2849
  hostProps;
@@ -2785,7 +2915,7 @@ class bt {
2785
2915
  * @internal
2786
2916
  */
2787
2917
  validateConsumerDomain() {
2788
- if (this.allowedConsumerDomains && !L(this.allowedConsumerDomains, this.consumerDomain))
2918
+ if (this.allowedConsumerDomains && !D(this.allowedConsumerDomains, this.consumerDomain))
2789
2919
  throw new Error(
2790
2920
  `Consumer domain "${this.consumerDomain}" is not allowed for component "${this.tag}"`
2791
2921
  );
@@ -2803,22 +2933,22 @@ class bt {
2803
2933
  * @internal
2804
2934
  */
2805
2935
  resolveConsumerWindow() {
2806
- if (Ue()) {
2807
- const e = Ae();
2936
+ if (Xe()) {
2937
+ const e = Je();
2808
2938
  if (e) return e;
2809
2939
  }
2810
- if (Me()) {
2811
- const e = He();
2940
+ if (Ke()) {
2941
+ const e = qe();
2812
2942
  if (e) return e;
2813
2943
  }
2814
- throw new Error("Could not resolve consumer window");
2944
+ throw new Error(De);
2815
2945
  }
2816
2946
  /**
2817
2947
  * Builds the hostProps object with deserialized props and control methods.
2818
2948
  * @internal
2819
2949
  */
2820
2950
  buildHostProps(e) {
2821
- const t = me(
2951
+ const t = ge(
2822
2952
  e.props,
2823
2953
  this.propDefinitions,
2824
2954
  this.messenger,
@@ -3006,7 +3136,7 @@ class bt {
3006
3136
  const t = {};
3007
3137
  for (const [n, i] of Object.entries(e))
3008
3138
  try {
3009
- t[n] = xe({
3139
+ t[n] = Ce({
3010
3140
  tag: i.tag,
3011
3141
  url: i.url,
3012
3142
  props: i.props,
@@ -3025,7 +3155,7 @@ class bt {
3025
3155
  setupMessageHandlers() {
3026
3156
  this.messenger.on(u.PROPS, (e) => {
3027
3157
  try {
3028
- const t = me(
3158
+ const t = ge(
3029
3159
  e,
3030
3160
  this.propDefinitions,
3031
3161
  this.messenger,
@@ -3033,7 +3163,7 @@ class bt {
3033
3163
  this.consumerWindow,
3034
3164
  this.consumerDomain
3035
3165
  );
3036
- Object.assign(this.hostProps, t);
3166
+ this.consumerProps = t, Object.assign(this.hostProps, t), this.hostProps.consumer.props = this.consumerProps;
3037
3167
  for (const n of this.propsHandlers)
3038
3168
  try {
3039
3169
  n(t);
@@ -3059,8 +3189,8 @@ function ne(s, e, t = {}) {
3059
3189
  if (g) {
3060
3190
  if (e) {
3061
3191
  const i = g.getProps().getConsumerDomain();
3062
- if (!L(e, i))
3063
- throw vt(), new Error(
3192
+ if (!D(e, i))
3193
+ throw Ht(), new Error(
3064
3194
  `Consumer domain "${i}" is not allowed for this host component`
3065
3195
  );
3066
3196
  }
@@ -3068,28 +3198,37 @@ function ne(s, e, t = {}) {
3068
3198
  }
3069
3199
  if (!X())
3070
3200
  return null;
3071
- const n = Ve();
3072
- return n ? (g = new bt(
3073
- n,
3074
- s,
3075
- e,
3076
- t.deferInit ?? !1
3077
- ), g) : (console.error("Failed to parse ForgeFrame payload from window.name"), null);
3078
- }
3079
- function Pt() {
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() {
3080
3219
  return X();
3081
3220
  }
3082
- function Ot() {
3221
+ function $t() {
3083
3222
  return X();
3084
3223
  }
3085
- function Rt() {
3224
+ function Ft() {
3086
3225
  return window.hostProps;
3087
3226
  }
3088
- function vt() {
3227
+ function Ht() {
3089
3228
  g && (g.destroy(), g = null), delete window.hostProps;
3090
3229
  }
3091
- const C = /* @__PURE__ */ new Map(), Se = /* @__PURE__ */ Symbol("forgeframe.component.options");
3092
- function St(s) {
3230
+ const I = /* @__PURE__ */ new Map(), Ie = /* @__PURE__ */ Symbol("forgeframe.component.options");
3231
+ function Lt(s) {
3093
3232
  if (!s.tag)
3094
3233
  throw new Error("Component tag is required");
3095
3234
  if (!/^[a-z][a-z0-9-]*$/.test(s.tag))
@@ -3106,14 +3245,14 @@ function St(s) {
3106
3245
  `Invalid component URL "${s.url}". Must be a valid absolute or relative URL.`
3107
3246
  );
3108
3247
  }
3109
- if (C.has(s.tag))
3248
+ if (I.has(s.tag))
3110
3249
  throw new Error(`Component "${s.tag}" is already registered`);
3111
3250
  }
3112
- function xe(s) {
3113
- St(s);
3251
+ function Ce(s) {
3252
+ Lt(s);
3114
3253
  const e = [];
3115
3254
  let t;
3116
- if (W(s.tag)) {
3255
+ if (z(s.tag)) {
3117
3256
  const i = ne(s.props, s.allowedConsumerDomains);
3118
3257
  i && (t = i.hostProps);
3119
3258
  }
@@ -3124,34 +3263,34 @@ function xe(s) {
3124
3263
  o !== -1 && e.splice(o, 1);
3125
3264
  }), r;
3126
3265
  };
3127
- return n.instances = e, n.isHost = () => W(s.tag), n.isEmbedded = () => W(s.tag), n.hostProps = t, n[Se] = s, n.canRenderTo = async (i) => {
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) => {
3128
3267
  try {
3129
- return !!(be(i) || s.domain);
3268
+ return !!(Re(i) || s.domain);
3130
3269
  } catch {
3131
3270
  return !1;
3132
3271
  }
3133
- }, C.set(s.tag, n), n;
3272
+ }, I.set(s.tag, n), n;
3134
3273
  }
3135
- function xt(s) {
3136
- return C.get(s);
3274
+ function kt(s) {
3275
+ return I.get(s);
3137
3276
  }
3138
- function Ct(s) {
3139
- return s[Se];
3277
+ function At(s) {
3278
+ return s[Ie];
3140
3279
  }
3141
- async function Dt(s) {
3280
+ async function Ut(s) {
3142
3281
  await s.close();
3143
3282
  }
3144
- async function Ce(s) {
3145
- const e = C.get(s);
3283
+ async function Te(s) {
3284
+ const e = I.get(s);
3146
3285
  if (!e) return;
3147
3286
  const t = [...e.instances];
3148
3287
  await Promise.all(t.map((n) => n.close()));
3149
3288
  }
3150
- async function It() {
3151
- const s = Array.from(C.keys());
3152
- await Promise.all(s.map((e) => Ce(e)));
3289
+ async function Mt() {
3290
+ const s = Array.from(I.keys());
3291
+ await Promise.all(s.map((e) => Te(e)));
3153
3292
  }
3154
- function Tt(s, e) {
3293
+ function Wt(s, e) {
3155
3294
  const t = Object.keys(s), n = Object.keys(e);
3156
3295
  if (t.length !== n.length)
3157
3296
  return !1;
@@ -3160,37 +3299,37 @@ function Tt(s, e) {
3160
3299
  return !1;
3161
3300
  return !0;
3162
3301
  }
3163
- function Ft(s, e) {
3302
+ function zt(s, e) {
3164
3303
  const { React: t } = e, { createElement: n, useRef: i, useEffect: r, useState: o, forwardRef: a } = t, c = a(
3165
3304
  function(w, _) {
3166
3305
  const {
3167
- onRendered: O,
3168
- onError: v,
3306
+ onRendered: R,
3307
+ onError: x,
3169
3308
  onClose: ie,
3170
- context: De,
3309
+ context: Ne,
3171
3310
  className: re,
3172
3311
  style: oe,
3173
- ...H
3174
- } = w, D = i(null), A = i(null), U = i(null), [ae, Ie] = o(null);
3312
+ ...A
3313
+ } = w, C = i(null), U = i(null), M = i(null), [ae, $e] = o(null);
3175
3314
  return r(() => {
3176
- const S = D.current;
3315
+ const S = C.current;
3177
3316
  if (!S) return;
3178
- const m = s(H);
3179
- return A.current = m, O && m.event.once("rendered", O), ie && m.event.once("close", ie), v && m.event.on("error", v), m.render(S, De).catch((x) => {
3180
- Ie(x), v?.(x);
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);
3181
3320
  }), () => {
3182
3321
  m.close().catch(() => {
3183
- }), A.current = null, U.current = null;
3322
+ }), U.current = null, M.current = null;
3184
3323
  };
3185
3324
  }, []), r(() => {
3186
- const S = A.current;
3325
+ const S = U.current;
3187
3326
  if (!S) return;
3188
- const m = H, x = U.current;
3189
- x && Tt(x, m) || (U.current = m, S.updateProps(m).catch((Te) => {
3190
- v?.(Te);
3327
+ const m = A, v = M.current;
3328
+ v && Wt(v, m) || (M.current = m, S.updateProps(m).catch((Fe) => {
3329
+ x?.(Fe);
3191
3330
  }));
3192
- }, [H, v]), r(() => {
3193
- _ && typeof _ == "object" && D.current && (_.current = D.current);
3331
+ }, [A, x]), r(() => {
3332
+ _ && typeof _ == "object" && C.current && (_.current = C.current);
3194
3333
  }, [_]), ae ? n(
3195
3334
  "div",
3196
3335
  {
@@ -3199,7 +3338,7 @@ function Ft(s, e) {
3199
3338
  },
3200
3339
  `Error: ${ae.message}`
3201
3340
  ) : n("div", {
3202
- ref: D,
3341
+ ref: C,
3203
3342
  className: re,
3204
3343
  style: {
3205
3344
  display: "inline-block",
@@ -3210,13 +3349,13 @@ function Ft(s, e) {
3210
3349
  ), l = `ForgeFrame(${s.name || "Component"})`;
3211
3350
  return c.displayName = l, c;
3212
3351
  }
3213
- function kt(s) {
3352
+ function Bt(s) {
3214
3353
  return function(t) {
3215
- return Ft(t, { React: s });
3354
+ return zt(t, { React: s });
3216
3355
  };
3217
3356
  }
3218
3357
  ne(void 0, void 0, { deferInit: !0 });
3219
- const $t = {
3358
+ const Vt = {
3220
3359
  /**
3221
3360
  * Create a new component definition.
3222
3361
  *
@@ -3241,23 +3380,23 @@ const $t = {
3241
3380
  * await instance.render('#container');
3242
3381
  * ```
3243
3382
  */
3244
- create: xe,
3383
+ create: Ce,
3245
3384
  /**
3246
3385
  * Destroy a single component instance.
3247
3386
  *
3248
3387
  * @param instance - The component instance to destroy
3249
3388
  */
3250
- destroy: Dt,
3389
+ destroy: Ut,
3251
3390
  /**
3252
3391
  * Destroy all instances of a specific component by tag.
3253
3392
  *
3254
3393
  * @param tag - The component tag name
3255
3394
  */
3256
- destroyByTag: Ce,
3395
+ destroyByTag: Te,
3257
3396
  /**
3258
3397
  * Destroy all ForgeFrame component instances.
3259
3398
  */
3260
- destroyAll: It,
3399
+ destroyAll: Mt,
3261
3400
  /**
3262
3401
  * Check if the current window is a host component context.
3263
3402
  *
@@ -3267,7 +3406,7 @@ const $t = {
3267
3406
  *
3268
3407
  * @returns True if running inside a ForgeFrame iframe/popup
3269
3408
  */
3270
- isHost: Pt,
3409
+ isHost: Nt,
3271
3410
  /**
3272
3411
  * Check if the current window is embedded by ForgeFrame.
3273
3412
  *
@@ -3276,7 +3415,7 @@ const $t = {
3276
3415
  *
3277
3416
  * @returns True if running inside a ForgeFrame iframe/popup
3278
3417
  */
3279
- isEmbedded: Ot,
3418
+ isEmbedded: $t,
3280
3419
  /**
3281
3420
  * Get hostProps from the current host window.
3282
3421
  *
@@ -3285,7 +3424,7 @@ const $t = {
3285
3424
  *
3286
3425
  * @returns The hostProps object if in host context, undefined otherwise
3287
3426
  */
3288
- getHostProps: Rt,
3427
+ getHostProps: Ft,
3289
3428
  /**
3290
3429
  * Flush host initialization in embedded contexts.
3291
3430
  *
@@ -3301,7 +3440,7 @@ const $t = {
3301
3440
  * Serialization strategy constants.
3302
3441
  * @see {@link PROP_SERIALIZATION}
3303
3442
  */
3304
- PROP_SERIALIZATION: I,
3443
+ PROP_SERIALIZATION: T,
3305
3444
  /**
3306
3445
  * Rendering context constants (IFRAME, POPUP).
3307
3446
  * @see {@link CONTEXT}
@@ -3319,7 +3458,7 @@ const $t = {
3319
3458
  /**
3320
3459
  * Current library version.
3321
3460
  */
3322
- VERSION: ye,
3461
+ VERSION: _e,
3323
3462
  /**
3324
3463
  * Check if a value is a Standard Schema (Zod, Valibot, ArkType, etc.)
3325
3464
  *
@@ -3363,32 +3502,32 @@ const $t = {
3363
3502
  };
3364
3503
  export {
3365
3504
  te as AnySchema,
3366
- N as ArraySchema,
3367
- Y as BooleanSchema,
3505
+ H as ArraySchema,
3506
+ G as BooleanSchema,
3368
3507
  p as CONTEXT,
3369
3508
  f as EVENT,
3370
3509
  ee as EnumSchema,
3371
- $t as ForgeFrame,
3510
+ Vt as ForgeFrame,
3372
3511
  Z as FunctionSchema,
3373
3512
  Q as LiteralSchema,
3374
- G as NumberSchema,
3375
- k as ObjectSchema,
3376
- I as PROP_SERIALIZATION,
3513
+ Y as NumberSchema,
3514
+ L as ObjectSchema,
3515
+ T as PROP_SERIALIZATION,
3377
3516
  ve as PopupOpenError,
3378
3517
  y as PropSchema,
3379
3518
  K as StringSchema,
3380
- ye as VERSION,
3381
- xe as create,
3382
- Ft as createReactComponent,
3383
- $t as default,
3384
- Dt as destroy,
3385
- It as destroyAll,
3386
- Ce as destroyByTag,
3387
- Rt as getHostProps,
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,
3388
3527
  ne as initHost,
3389
- Ot as isEmbedded,
3390
- Pt as isHost,
3528
+ $t as isEmbedded,
3529
+ Nt as isHost,
3391
3530
  b as isStandardSchema,
3392
3531
  d as prop,
3393
- kt as withReactComponent
3532
+ Bt as withReactComponent
3394
3533
  };