chayns-api 3.0.1 → 3.1.0-beta.1

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.
Files changed (142) hide show
  1. package/dist/cjs/calls/index.js +4 -1
  2. package/dist/cjs/calls/visibilityChangeListener.js +4 -4
  3. package/dist/cjs/components/ChaynsProvider.js +34 -6
  4. package/dist/cjs/components/withHydrationBoundary.js +2 -2
  5. package/dist/cjs/constants/index.js +0 -22
  6. package/dist/cjs/contexts/HistoryLayerContext.js +89 -0
  7. package/dist/cjs/contexts/index.js +38 -0
  8. package/dist/cjs/handler/history/FrameHistoryLayer.js +100 -0
  9. package/dist/cjs/handler/history/HistoryLayer.js +321 -0
  10. package/dist/cjs/handler/history/index.js +19 -0
  11. package/dist/cjs/hooks/history.js +454 -0
  12. package/dist/cjs/hooks/index.js +62 -1
  13. package/dist/cjs/host/ChaynsHost.js +113 -54
  14. package/dist/cjs/host/iframe/HostIframe.js +70 -5
  15. package/dist/cjs/host/module/ModuleHost.js +50 -44
  16. package/dist/cjs/index.js +139 -6
  17. package/dist/cjs/types/history.js +1 -0
  18. package/dist/cjs/umd.index.js +2 -2
  19. package/dist/cjs/utils/EventBus.js +33 -0
  20. package/dist/cjs/{util → utils}/appStorage.js +2 -2
  21. package/dist/cjs/utils/equality.js +19 -0
  22. package/dist/cjs/utils/history/BlockRegistry.js +153 -0
  23. package/dist/cjs/utils/history/NavigationQueue.js +389 -0
  24. package/dist/cjs/utils/history/layerTree.js +32 -0
  25. package/dist/cjs/utils/history/nativeBackHandling.js +61 -0
  26. package/dist/cjs/utils/history/navigationIndex.js +74 -0
  27. package/dist/cjs/utils/history/rootLayer.js +213 -0
  28. package/dist/cjs/utils/history/segments.js +15 -0
  29. package/dist/cjs/utils/history/stateProjector.js +156 -0
  30. package/dist/cjs/utils/history/url.js +47 -0
  31. package/dist/cjs/utils/history/window.js +9 -0
  32. package/dist/cjs/wrapper/AppWrapper.js +24 -24
  33. package/dist/cjs/wrapper/FrameWrapper.js +35 -2
  34. package/dist/cjs/wrapper/ModuleFederationWrapper.js +2 -0
  35. package/dist/cjs/wrapper/StaticChaynsApi.js +1 -1
  36. package/dist/esm/calls/index.js +2 -0
  37. package/dist/esm/calls/visibilityChangeListener.js +1 -1
  38. package/dist/esm/components/ChaynsProvider.js +34 -6
  39. package/dist/esm/components/withHydrationBoundary.js +1 -1
  40. package/dist/esm/constants/index.js +1 -3
  41. package/dist/esm/contexts/HistoryLayerContext.js +76 -0
  42. package/dist/esm/contexts/index.js +3 -0
  43. package/dist/esm/handler/history/FrameHistoryLayer.js +105 -0
  44. package/dist/esm/handler/history/HistoryLayer.js +321 -0
  45. package/dist/esm/handler/history/index.js +2 -0
  46. package/dist/esm/hooks/history.js +428 -0
  47. package/dist/esm/hooks/index.js +2 -1
  48. package/dist/esm/host/ChaynsHost.js +113 -54
  49. package/dist/esm/host/iframe/HostIframe.js +70 -5
  50. package/dist/esm/host/module/ModuleHost.js +50 -44
  51. package/dist/esm/index.js +15 -6
  52. package/dist/esm/types/history.js +1 -0
  53. package/dist/esm/umd.index.js +2 -2
  54. package/dist/esm/utils/EventBus.js +31 -0
  55. package/dist/esm/{util → utils}/appStorage.js +1 -1
  56. package/dist/esm/utils/equality.js +12 -0
  57. package/dist/esm/utils/history/BlockRegistry.js +151 -0
  58. package/dist/esm/utils/history/NavigationQueue.js +386 -0
  59. package/dist/esm/utils/history/layerTree.js +24 -0
  60. package/dist/esm/utils/history/nativeBackHandling.js +59 -0
  61. package/dist/esm/utils/history/navigationIndex.js +62 -0
  62. package/dist/esm/utils/history/rootLayer.js +205 -0
  63. package/dist/esm/utils/history/segments.js +7 -0
  64. package/dist/esm/utils/history/stateProjector.js +147 -0
  65. package/dist/esm/utils/history/url.js +40 -0
  66. package/dist/esm/utils/history/window.js +3 -0
  67. package/dist/esm/wrapper/AppWrapper.js +6 -6
  68. package/dist/esm/wrapper/FrameWrapper.js +35 -2
  69. package/dist/esm/wrapper/ModuleFederationWrapper.js +2 -0
  70. package/dist/esm/wrapper/StaticChaynsApi.js +2 -1
  71. package/dist/types/calls/index.d.ts +5 -0
  72. package/dist/types/components/ChaynsProvider.d.ts +21 -0
  73. package/dist/types/constants/index.d.ts +0 -2
  74. package/dist/types/contexts/HistoryLayerContext.d.ts +33 -0
  75. package/dist/types/contexts/index.d.ts +3 -0
  76. package/dist/types/handler/history/FrameHistoryLayer.d.ts +99 -0
  77. package/dist/types/handler/history/HistoryLayer.d.ts +117 -0
  78. package/dist/types/handler/history/index.d.ts +2 -0
  79. package/dist/types/hooks/history.d.ts +89 -0
  80. package/dist/types/hooks/index.d.ts +1 -0
  81. package/dist/types/host/ChaynsHost.d.ts +12 -0
  82. package/dist/types/host/iframe/HostIframe.d.ts +4 -0
  83. package/dist/types/host/module/ModuleHost.d.ts +4 -0
  84. package/dist/types/index.d.ts +15 -6
  85. package/dist/types/types/IChaynsReact.d.ts +3 -0
  86. package/dist/types/types/history.d.ts +74 -0
  87. package/dist/types/umd.index.d.ts +2 -2
  88. package/dist/types/utils/EventBus.d.ts +10 -0
  89. package/dist/types/{util → utils}/collectCssChunks.d.ts +1 -1
  90. package/dist/types/utils/equality.d.ts +2 -0
  91. package/dist/types/utils/history/BlockRegistry.d.ts +45 -0
  92. package/dist/types/utils/history/NavigationQueue.d.ts +118 -0
  93. package/dist/types/utils/history/layerTree.d.ts +10 -0
  94. package/dist/types/utils/history/nativeBackHandling.d.ts +47 -0
  95. package/dist/types/utils/history/navigationIndex.d.ts +17 -0
  96. package/dist/types/utils/history/rootLayer.d.ts +42 -0
  97. package/dist/types/utils/history/segments.d.ts +2 -0
  98. package/dist/types/utils/history/stateProjector.d.ts +24 -0
  99. package/dist/types/utils/history/url.d.ts +17 -0
  100. package/dist/types/utils/history/window.d.ts +1 -0
  101. package/dist/types/wrapper/FrameWrapper.d.ts +1 -0
  102. package/dist/types/wrapper/StaticChaynsApi.d.ts +1 -0
  103. package/package.json +2 -1
  104. /package/dist/cjs/{constants → contexts}/hydrationContext.js +0 -0
  105. /package/dist/cjs/{constants → contexts}/moduleContext.js +0 -0
  106. /package/dist/cjs/{helper/apiListenerHelper.js → utils/apiListener.js} +0 -0
  107. /package/dist/cjs/{util → utils}/appCall.js +0 -0
  108. /package/dist/cjs/{util → utils}/bindChaynsApi.js +0 -0
  109. /package/dist/cjs/{util → utils}/collectCssChunks.js +0 -0
  110. /package/dist/cjs/{util → utils}/deviceHelper.js +0 -0
  111. /package/dist/cjs/{util → utils}/heightHelper.js +0 -0
  112. /package/dist/cjs/{util → utils}/initModuleFederationSharing.js +0 -0
  113. /package/dist/cjs/{util → utils}/is.js +0 -0
  114. /package/dist/cjs/{util → utils}/postIframeForm.js +0 -0
  115. /package/dist/cjs/{util → utils}/transferNestedFunctions.js +0 -0
  116. /package/dist/cjs/{util → utils}/url.js +0 -0
  117. /package/dist/esm/{constants → contexts}/hydrationContext.js +0 -0
  118. /package/dist/esm/{constants → contexts}/moduleContext.js +0 -0
  119. /package/dist/esm/{helper/apiListenerHelper.js → utils/apiListener.js} +0 -0
  120. /package/dist/esm/{util → utils}/appCall.js +0 -0
  121. /package/dist/esm/{util → utils}/bindChaynsApi.js +0 -0
  122. /package/dist/esm/{util → utils}/collectCssChunks.js +0 -0
  123. /package/dist/esm/{util → utils}/deviceHelper.js +0 -0
  124. /package/dist/esm/{util → utils}/heightHelper.js +0 -0
  125. /package/dist/esm/{util → utils}/initModuleFederationSharing.js +0 -0
  126. /package/dist/esm/{util → utils}/is.js +0 -0
  127. /package/dist/esm/{util → utils}/postIframeForm.js +0 -0
  128. /package/dist/esm/{util → utils}/transferNestedFunctions.js +0 -0
  129. /package/dist/esm/{util → utils}/url.js +0 -0
  130. /package/dist/types/{constants → contexts}/hydrationContext.d.ts +0 -0
  131. /package/dist/types/{constants → contexts}/moduleContext.d.ts +0 -0
  132. /package/dist/types/{helper/apiListenerHelper.d.ts → utils/apiListener.d.ts} +0 -0
  133. /package/dist/types/{util → utils}/appCall.d.ts +0 -0
  134. /package/dist/types/{util → utils}/appStorage.d.ts +0 -0
  135. /package/dist/types/{util → utils}/bindChaynsApi.d.ts +0 -0
  136. /package/dist/types/{util → utils}/deviceHelper.d.ts +0 -0
  137. /package/dist/types/{util → utils}/heightHelper.d.ts +0 -0
  138. /package/dist/types/{util → utils}/initModuleFederationSharing.d.ts +0 -0
  139. /package/dist/types/{util → utils}/is.d.ts +0 -0
  140. /package/dist/types/{util → utils}/postIframeForm.d.ts +0 -0
  141. /package/dist/types/{util → utils}/transferNestedFunctions.d.ts +0 -0
  142. /package/dist/types/{util → utils}/url.d.ts +0 -0
@@ -8,11 +8,13 @@ var _reactCompilerRuntime = require("react-compiler-runtime");
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _HostIframe = _interopRequireDefault(require("./iframe/HostIframe"));
10
10
  var _ModuleHost = _interopRequireDefault(require("./module/ModuleHost"));
11
+ var _HistoryLayerContext = require("../contexts/HistoryLayerContext");
12
+ var _rootLayer = require("../utils/history/rootLayer");
11
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
14
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
15
  const subscribeToHydration = () => () => {};
14
16
  const ChaynsHost = t0 => {
15
- const $ = (0, _reactCompilerRuntime.c)(38);
17
+ const $ = (0, _reactCompilerRuntime.c)(53);
16
18
  const {
17
19
  type,
18
20
  iFrameProps,
@@ -34,24 +36,51 @@ const ChaynsHost = t0 => {
34
36
  environment,
35
37
  preventStagingReplacement,
36
38
  dialog,
37
- styleSettings
39
+ styleSettings,
40
+ historyLayer,
41
+ historyChildId,
42
+ isHistoryDisabled: t3
38
43
  } = t0;
39
44
  const iFrameRef = t1 === undefined ? undefined : t1;
40
45
  const loadingComponent = t2 === undefined ? undefined : t2;
46
+ const isHistoryDisabled = t3 === undefined ? true : t3;
41
47
  const isInitiallyVisible = type !== "client-module" && (type !== "server-module" || !!(system !== null && system !== void 0 && system.serverUrl));
42
48
  const isHydrated = (0, _react.useSyncExternalStore)(subscribeToHydration, _temp, _temp2);
43
49
  const isVisible = (0, _react.useDeferredValue)(isInitiallyVisible || isHydrated);
44
50
  if (!isVisible) {
45
51
  return null;
46
52
  }
53
+ let t4;
54
+ if ($[0] !== historyLayer) {
55
+ t4 = historyLayer !== null && historyLayer !== void 0 ? historyLayer : (0, _rootLayer.getOrInitRootChaynsHistoryLayer)().rootLayer;
56
+ $[0] = historyLayer;
57
+ $[1] = t4;
58
+ } else {
59
+ t4 = $[1];
60
+ }
61
+ const resolvedLayer = t4;
62
+ let layer;
63
+ if (!isHistoryDisabled) {
64
+ let t5;
65
+ if ($[2] !== historyChildId || $[3] !== resolvedLayer) {
66
+ var _resolvedLayer$getChi;
67
+ t5 = historyChildId ? (_resolvedLayer$getChi = resolvedLayer.getChildLayer(historyChildId)) !== null && _resolvedLayer$getChi !== void 0 ? _resolvedLayer$getChi : resolvedLayer.createChildLayer(historyChildId) : resolvedLayer;
68
+ $[2] = historyChildId;
69
+ $[3] = resolvedLayer;
70
+ $[4] = t5;
71
+ } else {
72
+ t5 = $[4];
73
+ }
74
+ layer = t5;
75
+ }
47
76
  switch (type) {
48
77
  case "client-iframe":
49
78
  case "server-iframe":
50
79
  {
51
- const t3 = type === "server-iframe";
52
- let t4;
53
- if ($[0] !== currentPage || $[1] !== customData || $[2] !== customFunctions || $[3] !== device || $[4] !== dialog || $[5] !== environment || $[6] !== functions || $[7] !== iFrameProps || $[8] !== iFrameRef || $[9] !== isAdminModeActive || $[10] !== language || $[11] !== pages || $[12] !== parameters || $[13] !== preventStagingReplacement || $[14] !== site || $[15] !== src || $[16] !== styleSettings || $[17] !== t3 || $[18] !== user) {
54
- t4 = _react.default.createElement(_HostIframe.default, {
80
+ const t5 = type === "server-iframe";
81
+ let t6;
82
+ if ($[5] !== currentPage || $[6] !== customData || $[7] !== customFunctions || $[8] !== device || $[9] !== dialog || $[10] !== environment || $[11] !== functions || $[12] !== iFrameProps || $[13] !== iFrameRef || $[14] !== isAdminModeActive || $[15] !== isHistoryDisabled || $[16] !== language || $[17] !== layer || $[18] !== pages || $[19] !== parameters || $[20] !== preventStagingReplacement || $[21] !== site || $[22] !== src || $[23] !== styleSettings || $[24] !== t5 || $[25] !== user) {
83
+ t6 = _react.default.createElement(_HostIframe.default, {
55
84
  iFrameRef: iFrameRef,
56
85
  iFrameProps: iFrameProps,
57
86
  pages: pages,
@@ -63,46 +92,61 @@ const ChaynsHost = t0 => {
63
92
  functions: functions,
64
93
  customFunctions: customFunctions,
65
94
  src: src,
66
- postForm: t3,
95
+ postForm: t5,
67
96
  language: language,
68
97
  parameters: parameters,
69
98
  environment: environment,
70
99
  customData: customData,
71
100
  preventStagingReplacement: preventStagingReplacement,
72
101
  dialog: dialog,
73
- styleSettings: styleSettings
102
+ styleSettings: styleSettings,
103
+ historyLayer: layer,
104
+ isHistoryDisabled: isHistoryDisabled
74
105
  });
75
- $[0] = currentPage;
76
- $[1] = customData;
77
- $[2] = customFunctions;
78
- $[3] = device;
79
- $[4] = dialog;
80
- $[5] = environment;
81
- $[6] = functions;
82
- $[7] = iFrameProps;
83
- $[8] = iFrameRef;
84
- $[9] = isAdminModeActive;
85
- $[10] = language;
86
- $[11] = pages;
87
- $[12] = parameters;
88
- $[13] = preventStagingReplacement;
89
- $[14] = site;
90
- $[15] = src;
91
- $[16] = styleSettings;
92
- $[17] = t3;
93
- $[18] = user;
94
- $[19] = t4;
106
+ $[5] = currentPage;
107
+ $[6] = customData;
108
+ $[7] = customFunctions;
109
+ $[8] = device;
110
+ $[9] = dialog;
111
+ $[10] = environment;
112
+ $[11] = functions;
113
+ $[12] = iFrameProps;
114
+ $[13] = iFrameRef;
115
+ $[14] = isAdminModeActive;
116
+ $[15] = isHistoryDisabled;
117
+ $[16] = language;
118
+ $[17] = layer;
119
+ $[18] = pages;
120
+ $[19] = parameters;
121
+ $[20] = preventStagingReplacement;
122
+ $[21] = site;
123
+ $[22] = src;
124
+ $[23] = styleSettings;
125
+ $[24] = t5;
126
+ $[25] = user;
127
+ $[26] = t6;
128
+ } else {
129
+ t6 = $[26];
130
+ }
131
+ let t7;
132
+ if ($[27] !== resolvedLayer || $[28] !== t6) {
133
+ t7 = _react.default.createElement(_HistoryLayerContext.ChaynsHistoryLayerProvider, {
134
+ layer: resolvedLayer
135
+ }, t6);
136
+ $[27] = resolvedLayer;
137
+ $[28] = t6;
138
+ $[29] = t7;
95
139
  } else {
96
- t4 = $[19];
140
+ t7 = $[29];
97
141
  }
98
- return t4;
142
+ return t7;
99
143
  }
100
144
  case "client-module":
101
145
  case "server-module":
102
146
  {
103
- let t3;
104
- if ($[20] !== currentPage || $[21] !== customData || $[22] !== customFunctions || $[23] !== device || $[24] !== dialog || $[25] !== environment || $[26] !== functions || $[27] !== isAdminModeActive || $[28] !== language || $[29] !== loadingComponent || $[30] !== pages || $[31] !== parameters || $[32] !== preventStagingReplacement || $[33] !== site || $[34] !== styleSettings || $[35] !== system || $[36] !== user) {
105
- t3 = _react.default.createElement(_ModuleHost.default, {
147
+ let t5;
148
+ if ($[30] !== currentPage || $[31] !== customData || $[32] !== customFunctions || $[33] !== device || $[34] !== dialog || $[35] !== environment || $[36] !== functions || $[37] !== isAdminModeActive || $[38] !== isHistoryDisabled || $[39] !== language || $[40] !== layer || $[41] !== loadingComponent || $[42] !== pages || $[43] !== parameters || $[44] !== preventStagingReplacement || $[45] !== site || $[46] !== styleSettings || $[47] !== system || $[48] !== user) {
149
+ t5 = _react.default.createElement(_ModuleHost.default, {
106
150
  system: system,
107
151
  pages: pages,
108
152
  isAdminModeActive: isAdminModeActive,
@@ -119,30 +163,45 @@ const ChaynsHost = t0 => {
119
163
  environment: environment,
120
164
  preventStagingReplacement: preventStagingReplacement,
121
165
  dialog: dialog,
122
- styleSettings: styleSettings
166
+ styleSettings: styleSettings,
167
+ historyLayer: layer,
168
+ isHistoryDisabled: isHistoryDisabled
123
169
  });
124
- $[20] = currentPage;
125
- $[21] = customData;
126
- $[22] = customFunctions;
127
- $[23] = device;
128
- $[24] = dialog;
129
- $[25] = environment;
130
- $[26] = functions;
131
- $[27] = isAdminModeActive;
132
- $[28] = language;
133
- $[29] = loadingComponent;
134
- $[30] = pages;
135
- $[31] = parameters;
136
- $[32] = preventStagingReplacement;
137
- $[33] = site;
138
- $[34] = styleSettings;
139
- $[35] = system;
140
- $[36] = user;
141
- $[37] = t3;
170
+ $[30] = currentPage;
171
+ $[31] = customData;
172
+ $[32] = customFunctions;
173
+ $[33] = device;
174
+ $[34] = dialog;
175
+ $[35] = environment;
176
+ $[36] = functions;
177
+ $[37] = isAdminModeActive;
178
+ $[38] = isHistoryDisabled;
179
+ $[39] = language;
180
+ $[40] = layer;
181
+ $[41] = loadingComponent;
182
+ $[42] = pages;
183
+ $[43] = parameters;
184
+ $[44] = preventStagingReplacement;
185
+ $[45] = site;
186
+ $[46] = styleSettings;
187
+ $[47] = system;
188
+ $[48] = user;
189
+ $[49] = t5;
190
+ } else {
191
+ t5 = $[49];
192
+ }
193
+ let t6;
194
+ if ($[50] !== resolvedLayer || $[51] !== t5) {
195
+ t6 = _react.default.createElement(_HistoryLayerContext.ChaynsHistoryLayerProvider, {
196
+ layer: resolvedLayer
197
+ }, t5);
198
+ $[50] = resolvedLayer;
199
+ $[51] = t5;
200
+ $[52] = t6;
142
201
  } else {
143
- t3 = $[37];
202
+ t6 = $[52];
144
203
  }
145
- return t3;
204
+ return t6;
146
205
  }
147
206
  default:
148
207
  {
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var comlink = _interopRequireWildcard(require("comlink"));
9
- var _postIframeForm = _interopRequireDefault(require("../../util/postIframeForm"));
9
+ var _postIframeForm = _interopRequireDefault(require("../../utils/postIframeForm"));
10
10
  var _useUpdateData = _interopRequireDefault(require("./utils/useUpdateData"));
11
- var _url = require("../../util/url");
12
- var _transferNestedFunctions = require("../../util/transferNestedFunctions");
11
+ var _url = require("../../utils/url");
12
+ var _transferNestedFunctions = require("../../utils/transferNestedFunctions");
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
14
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
15
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
@@ -32,13 +32,17 @@ const HostIframe = ({
32
32
  customData,
33
33
  preventStagingReplacement,
34
34
  dialog,
35
- styleSettings
35
+ styleSettings,
36
+ historyLayer,
37
+ isHistoryDisabled
36
38
  }) => {
37
39
  const eventTarget = (0, _react.useRef)();
38
40
  const ref = (0, _react.useRef)();
39
41
  const currentDataRef = (0, _react.useRef)();
40
42
  const customFunctionsRef = (0, _react.useRef)();
41
43
  customFunctionsRef.current = customFunctions;
44
+ const historyLayerRef = (0, _react.useRef)(undefined);
45
+ historyLayerRef.current = historyLayer;
42
46
  if (!eventTarget.current) {
43
47
  eventTarget.current = global.document ? document.createElement('div') : undefined;
44
48
  }
@@ -50,6 +54,7 @@ const HostIframe = ({
50
54
  const initialData = {
51
55
  site,
52
56
  isAdminModeActive,
57
+ isHistoryDisabled,
53
58
  pages,
54
59
  currentPage,
55
60
  device,
@@ -95,7 +100,66 @@ const HostIframe = ({
95
100
  addDataListener: cb => {
96
101
  if (eventTarget.current) eventTarget.current.addEventListener('data_update', e => e.detail && cb(e.detail));
97
102
  },
98
- getInitialData: () => currentDataRef.current
103
+ getInitialData: () => currentDataRef.current,
104
+ history: historyLayerRef.current ? {
105
+ getInitialState: () => {
106
+ const l = historyLayerRef.current;
107
+ if (!l) return null;
108
+ return {
109
+ id: l.id,
110
+ depth: l.depth,
111
+ segments: l.getRoute(),
112
+ params: l.getParams(),
113
+ hash: l.getHash(),
114
+ state: l.getState(),
115
+ activeChildId: l.getActiveChildId(),
116
+ segmentCount: l.getSegmentCount()
117
+ };
118
+ },
119
+ setRoute: (route, opts) => {
120
+ var _historyLayerRef$curr;
121
+ return (_historyLayerRef$curr = historyLayerRef.current) === null || _historyLayerRef$curr === void 0 ? void 0 : _historyLayerRef$curr.setRoute(route, opts);
122
+ },
123
+ setParams: (params, opts) => {
124
+ var _historyLayerRef$curr2;
125
+ return (_historyLayerRef$curr2 = historyLayerRef.current) === null || _historyLayerRef$curr2 === void 0 ? void 0 : _historyLayerRef$curr2.setParams(params, opts);
126
+ },
127
+ setHash: (hash, opts) => {
128
+ var _historyLayerRef$curr3;
129
+ return (_historyLayerRef$curr3 = historyLayerRef.current) === null || _historyLayerRef$curr3 === void 0 ? void 0 : _historyLayerRef$curr3.setHash(hash, opts);
130
+ },
131
+ setState: (state, opts) => {
132
+ var _historyLayerRef$curr4;
133
+ return (_historyLayerRef$curr4 = historyLayerRef.current) === null || _historyLayerRef$curr4 === void 0 ? void 0 : _historyLayerRef$curr4.setState(state, opts);
134
+ },
135
+ navigate: opts => {
136
+ var _historyLayerRef$curr5;
137
+ return (_historyLayerRef$curr5 = historyLayerRef.current) === null || _historyLayerRef$curr5 === void 0 ? void 0 : _historyLayerRef$curr5.navigate(opts);
138
+ },
139
+ setActiveChild: (id, init) => {
140
+ var _historyLayerRef$curr6;
141
+ return (_historyLayerRef$curr6 = historyLayerRef.current) === null || _historyLayerRef$curr6 === void 0 ? void 0 : _historyLayerRef$curr6.setActiveChild(id, init);
142
+ },
143
+ setSegmentCount: n => {
144
+ var _historyLayerRef$curr7;
145
+ return (_historyLayerRef$curr7 = historyLayerRef.current) === null || _historyLayerRef$curr7 === void 0 ? void 0 : _historyLayerRef$curr7.setSegmentCount(n);
146
+ },
147
+ addChangeListener: callback => {
148
+ var _historyLayerRef$curr8, _historyLayerRef$curr9;
149
+ const unsub = (_historyLayerRef$curr8 = (_historyLayerRef$curr9 = historyLayerRef.current) === null || _historyLayerRef$curr9 === void 0 ? void 0 : _historyLayerRef$curr9.addEventListener('change', callback)) !== null && _historyLayerRef$curr8 !== void 0 ? _historyLayerRef$curr8 : () => {};
150
+ return comlink.proxy(unsub);
151
+ },
152
+ addPopstateListener: callback => {
153
+ var _historyLayerRef$curr0, _historyLayerRef$curr1;
154
+ const unsub = (_historyLayerRef$curr0 = (_historyLayerRef$curr1 = historyLayerRef.current) === null || _historyLayerRef$curr1 === void 0 ? void 0 : _historyLayerRef$curr1.addEventListener('popstate', callback)) !== null && _historyLayerRef$curr0 !== void 0 ? _historyLayerRef$curr0 : () => {};
155
+ return comlink.proxy(unsub);
156
+ },
157
+ addBlock: (callback, opts) => {
158
+ var _historyLayerRef$curr10, _historyLayerRef$curr11;
159
+ const unsub = (_historyLayerRef$curr10 = (_historyLayerRef$curr11 = historyLayerRef.current) === null || _historyLayerRef$curr11 === void 0 ? void 0 : _historyLayerRef$curr11.addBlock(callback, opts)) !== null && _historyLayerRef$curr10 !== void 0 ? _historyLayerRef$curr10 : () => {};
160
+ return comlink.proxy(unsub);
161
+ }
162
+ } : undefined
99
163
  }
100
164
  };
101
165
  comlink.expose(obj, comlink.windowEndpoint(ref.current.contentWindow));
@@ -106,6 +170,7 @@ const HostIframe = ({
106
170
  }
107
171
  return undefined;
108
172
  }, []);
173
+ (0, _useUpdateData.default)(eventTarget.current, 'isHistoryDisabled', isHistoryDisabled);
109
174
  (0, _useUpdateData.default)(eventTarget.current, 'isAdminModeActive', isAdminModeActive);
110
175
  (0, _useUpdateData.default)(eventTarget.current, 'user', user);
111
176
  (0, _useUpdateData.default)(eventTarget.current, 'site', site);
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _reactCompilerRuntime = require("react-compiler-runtime");
8
8
  var _react = _interopRequireWildcard(require("react"));
9
- var _moduleContext = require("../../constants/moduleContext");
9
+ var _moduleContext = require("../../contexts/moduleContext");
10
10
  var _loadComponent = _interopRequireDefault(require("./utils/loadComponent"));
11
- var _url = require("../../util/url");
11
+ var _url = require("../../utils/url");
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
14
  const System = ({
@@ -32,7 +32,7 @@ const System = ({
32
32
  }, _react.default.createElement(Component, props));
33
33
  };
34
34
  const ModuleHost = t0 => {
35
- const $ = (0, _reactCompilerRuntime.c)(34);
35
+ const $ = (0, _reactCompilerRuntime.c)(36);
36
36
  const {
37
37
  system,
38
38
  children: t1,
@@ -50,14 +50,17 @@ const ModuleHost = t0 => {
50
50
  dialog,
51
51
  environment,
52
52
  preventStagingReplacement,
53
- styleSettings
53
+ styleSettings,
54
+ historyLayer,
55
+ isHistoryDisabled
54
56
  } = t0;
55
57
  const children = t1 === undefined ? null : t1;
56
58
  let result;
57
- if ($[0] !== currentPage || $[1] !== customData || $[2] !== device || $[3] !== dialog || $[4] !== environment || $[5] !== isAdminModeActive || $[6] !== language || $[7] !== pages || $[8] !== parameters || $[9] !== site || $[10] !== styleSettings || $[11] !== user) {
59
+ if ($[0] !== currentPage || $[1] !== customData || $[2] !== device || $[3] !== dialog || $[4] !== environment || $[5] !== isAdminModeActive || $[6] !== isHistoryDisabled || $[7] !== language || $[8] !== pages || $[9] !== parameters || $[10] !== site || $[11] !== styleSettings || $[12] !== user) {
58
60
  result = {
59
61
  site,
60
62
  isAdminModeActive,
63
+ isHistoryDisabled,
61
64
  pages,
62
65
  currentPage,
63
66
  device,
@@ -79,49 +82,50 @@ const ModuleHost = t0 => {
79
82
  $[3] = dialog;
80
83
  $[4] = environment;
81
84
  $[5] = isAdminModeActive;
82
- $[6] = language;
83
- $[7] = pages;
84
- $[8] = parameters;
85
- $[9] = site;
86
- $[10] = styleSettings;
87
- $[11] = user;
88
- $[12] = result;
85
+ $[6] = isHistoryDisabled;
86
+ $[7] = language;
87
+ $[8] = pages;
88
+ $[9] = parameters;
89
+ $[10] = site;
90
+ $[11] = styleSettings;
91
+ $[12] = user;
92
+ $[13] = result;
89
93
  } else {
90
- result = $[12];
94
+ result = $[13];
91
95
  }
92
96
  const data = result;
93
97
  let t2;
94
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
98
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
95
99
  t2 = _react.default.createElement("div", {
96
100
  className: "module-css"
97
101
  });
98
- $[13] = t2;
102
+ $[14] = t2;
99
103
  } else {
100
- t2 = $[13];
104
+ t2 = $[14];
101
105
  }
102
106
  const t3 = system.scope;
103
107
  let t4;
104
- if ($[14] !== environment.buildEnvironment || $[15] !== preventStagingReplacement || $[16] !== system.url) {
108
+ if ($[15] !== environment.buildEnvironment || $[16] !== preventStagingReplacement || $[17] !== system.url) {
105
109
  t4 = (0, _url.replaceStagingUrl)(preventStagingReplacement, system.url, environment.buildEnvironment);
106
- $[14] = environment.buildEnvironment;
107
- $[15] = preventStagingReplacement;
108
- $[16] = system.url;
109
- $[17] = t4;
110
+ $[15] = environment.buildEnvironment;
111
+ $[16] = preventStagingReplacement;
112
+ $[17] = system.url;
113
+ $[18] = t4;
110
114
  } else {
111
- t4 = $[17];
115
+ t4 = $[18];
112
116
  }
113
117
  let t5;
114
- if ($[18] !== environment.buildEnvironment || $[19] !== preventStagingReplacement || $[20] !== system.serverUrl) {
118
+ if ($[19] !== environment.buildEnvironment || $[20] !== preventStagingReplacement || $[21] !== system.serverUrl) {
115
119
  t5 = (0, _url.replaceStagingUrl)(preventStagingReplacement, system.serverUrl, environment.buildEnvironment);
116
- $[18] = environment.buildEnvironment;
117
- $[19] = preventStagingReplacement;
118
- $[20] = system.serverUrl;
119
- $[21] = t5;
120
+ $[19] = environment.buildEnvironment;
121
+ $[20] = preventStagingReplacement;
122
+ $[21] = system.serverUrl;
123
+ $[22] = t5;
120
124
  } else {
121
- t5 = $[21];
125
+ t5 = $[22];
122
126
  }
123
127
  let t6;
124
- if ($[22] !== system.module || $[23] !== system.preventSingleton || $[24] !== system.scope || $[25] !== t4 || $[26] !== t5) {
128
+ if ($[23] !== system.module || $[24] !== system.preventSingleton || $[25] !== system.scope || $[26] !== t4 || $[27] !== t5) {
125
129
  t6 = {
126
130
  scope: t3,
127
131
  url: t4,
@@ -129,33 +133,35 @@ const ModuleHost = t0 => {
129
133
  module: system.module,
130
134
  preventSingleton: system.preventSingleton
131
135
  };
132
- $[22] = system.module;
133
- $[23] = system.preventSingleton;
134
- $[24] = system.scope;
135
- $[25] = t4;
136
- $[26] = t5;
137
- $[27] = t6;
136
+ $[23] = system.module;
137
+ $[24] = system.preventSingleton;
138
+ $[25] = system.scope;
139
+ $[26] = t4;
140
+ $[27] = t5;
141
+ $[28] = t6;
138
142
  } else {
139
- t6 = $[27];
143
+ t6 = $[28];
140
144
  }
141
145
  let t7;
142
- if ($[28] !== children || $[29] !== customFunctions || $[30] !== data || $[31] !== functions || $[32] !== t6) {
146
+ if ($[29] !== children || $[30] !== customFunctions || $[31] !== data || $[32] !== functions || $[33] !== historyLayer || $[34] !== t6) {
143
147
  t7 = _react.default.createElement(_react.default.Fragment, null, t2, _react.default.createElement(System, {
144
148
  system: t6,
145
149
  data: data,
146
150
  functions: functions,
147
151
  customFunctions: customFunctions,
148
152
  fallback: children,
153
+ historyLayer: historyLayer,
149
154
  isModule: true
150
155
  }));
151
- $[28] = children;
152
- $[29] = customFunctions;
153
- $[30] = data;
154
- $[31] = functions;
155
- $[32] = t6;
156
- $[33] = t7;
156
+ $[29] = children;
157
+ $[30] = customFunctions;
158
+ $[31] = data;
159
+ $[32] = functions;
160
+ $[33] = historyLayer;
161
+ $[34] = t6;
162
+ $[35] = t7;
157
163
  } else {
158
- t7 = $[33];
164
+ t7 = $[35];
159
165
  }
160
166
  return t7;
161
167
  };