chayns-api 3.0.0-beta.4 → 3.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -11
- package/dist/cjs/calls/index.js +4 -1
- package/dist/cjs/calls/visibilityChangeListener.js +4 -4
- package/dist/cjs/components/ChaynsProvider.js +34 -6
- package/dist/cjs/components/withHydrationBoundary.js +2 -2
- package/dist/cjs/constants/index.js +0 -22
- package/dist/cjs/contexts/HistoryLayerContext.js +89 -0
- package/dist/cjs/contexts/index.js +38 -0
- package/dist/cjs/handler/history/FrameHistoryLayer.js +100 -0
- package/dist/cjs/handler/history/HistoryLayer.js +321 -0
- package/dist/cjs/handler/history/index.js +19 -0
- package/dist/cjs/hooks/history.js +454 -0
- package/dist/cjs/hooks/index.js +62 -1
- package/dist/cjs/host/ChaynsHost.js +113 -54
- package/dist/cjs/host/iframe/HostIframe.js +70 -5
- package/dist/cjs/host/module/ModuleHost.js +50 -44
- package/dist/cjs/index.js +139 -6
- package/dist/cjs/types/history.js +1 -0
- package/dist/cjs/umd.index.js +2 -2
- package/dist/cjs/utils/EventBus.js +33 -0
- package/dist/cjs/{util → utils}/appStorage.js +2 -2
- package/dist/cjs/utils/equality.js +19 -0
- package/dist/cjs/utils/history/BlockRegistry.js +110 -0
- package/dist/cjs/utils/history/NavigationQueue.js +388 -0
- package/dist/cjs/utils/history/layerTree.js +32 -0
- package/dist/cjs/utils/history/navigationIndex.js +42 -0
- package/dist/cjs/utils/history/rootLayer.js +175 -0
- package/dist/cjs/utils/history/segments.js +15 -0
- package/dist/cjs/utils/history/stateProjector.js +156 -0
- package/dist/cjs/utils/history/url.js +47 -0
- package/dist/cjs/utils/history/window.js +9 -0
- package/dist/cjs/wrapper/AppWrapper.js +23 -23
- package/dist/cjs/wrapper/FrameWrapper.js +35 -2
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +2 -0
- package/dist/cjs/wrapper/StaticChaynsApi.js +1 -1
- package/dist/esm/calls/index.js +2 -0
- package/dist/esm/calls/visibilityChangeListener.js +1 -1
- package/dist/esm/components/ChaynsProvider.js +34 -6
- package/dist/esm/components/withHydrationBoundary.js +1 -1
- package/dist/esm/constants/index.js +1 -3
- package/dist/esm/contexts/HistoryLayerContext.js +76 -0
- package/dist/esm/contexts/index.js +3 -0
- package/dist/esm/handler/history/FrameHistoryLayer.js +105 -0
- package/dist/esm/handler/history/HistoryLayer.js +321 -0
- package/dist/esm/handler/history/index.js +2 -0
- package/dist/esm/hooks/history.js +428 -0
- package/dist/esm/hooks/index.js +2 -1
- package/dist/esm/host/ChaynsHost.js +113 -54
- package/dist/esm/host/iframe/HostIframe.js +70 -5
- package/dist/esm/host/module/ModuleHost.js +50 -44
- package/dist/esm/index.js +15 -6
- package/dist/esm/types/history.js +1 -0
- package/dist/esm/umd.index.js +2 -2
- package/dist/esm/utils/EventBus.js +31 -0
- package/dist/esm/{util → utils}/appStorage.js +1 -1
- package/dist/esm/utils/equality.js +12 -0
- package/dist/esm/utils/history/BlockRegistry.js +108 -0
- package/dist/esm/utils/history/NavigationQueue.js +385 -0
- package/dist/esm/utils/history/layerTree.js +24 -0
- package/dist/esm/utils/history/navigationIndex.js +33 -0
- package/dist/esm/utils/history/rootLayer.js +167 -0
- package/dist/esm/utils/history/segments.js +7 -0
- package/dist/esm/utils/history/stateProjector.js +147 -0
- package/dist/esm/utils/history/url.js +40 -0
- package/dist/esm/utils/history/window.js +3 -0
- package/dist/esm/wrapper/AppWrapper.js +5 -5
- package/dist/esm/wrapper/FrameWrapper.js +35 -2
- package/dist/esm/wrapper/ModuleFederationWrapper.js +2 -0
- package/dist/esm/wrapper/StaticChaynsApi.js +2 -1
- package/dist/types/calls/index.d.ts +5 -0
- package/dist/types/components/ChaynsProvider.d.ts +21 -0
- package/dist/types/constants/index.d.ts +0 -2
- package/dist/types/contexts/HistoryLayerContext.d.ts +33 -0
- package/dist/types/contexts/index.d.ts +3 -0
- package/dist/types/handler/history/FrameHistoryLayer.d.ts +99 -0
- package/dist/types/handler/history/HistoryLayer.d.ts +117 -0
- package/dist/types/handler/history/index.d.ts +2 -0
- package/dist/types/hooks/history.d.ts +89 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/host/ChaynsHost.d.ts +12 -0
- package/dist/types/host/iframe/HostIframe.d.ts +4 -0
- package/dist/types/host/module/ModuleHost.d.ts +4 -0
- package/dist/types/index.d.ts +15 -6
- package/dist/types/types/IChaynsReact.d.ts +3 -0
- package/dist/types/types/history.d.ts +74 -0
- package/dist/types/umd.index.d.ts +2 -2
- package/dist/types/utils/EventBus.d.ts +10 -0
- package/dist/types/{util → utils}/collectCssChunks.d.ts +1 -1
- package/dist/types/utils/equality.d.ts +2 -0
- package/dist/types/utils/history/BlockRegistry.d.ts +38 -0
- package/dist/types/utils/history/NavigationQueue.d.ts +109 -0
- package/dist/types/utils/history/layerTree.d.ts +10 -0
- package/dist/types/utils/history/navigationIndex.d.ts +14 -0
- package/dist/types/utils/history/rootLayer.d.ts +42 -0
- package/dist/types/utils/history/segments.d.ts +2 -0
- package/dist/types/utils/history/stateProjector.d.ts +24 -0
- package/dist/types/utils/history/url.d.ts +17 -0
- package/dist/types/utils/history/window.d.ts +1 -0
- package/dist/types/wrapper/FrameWrapper.d.ts +1 -0
- package/dist/types/wrapper/StaticChaynsApi.d.ts +1 -0
- package/package.json +2 -1
- /package/dist/cjs/{constants → contexts}/hydrationContext.js +0 -0
- /package/dist/cjs/{constants → contexts}/moduleContext.js +0 -0
- /package/dist/cjs/{helper/apiListenerHelper.js → utils/apiListener.js} +0 -0
- /package/dist/cjs/{util → utils}/appCall.js +0 -0
- /package/dist/cjs/{util → utils}/bindChaynsApi.js +0 -0
- /package/dist/cjs/{util → utils}/collectCssChunks.js +0 -0
- /package/dist/cjs/{util → utils}/deviceHelper.js +0 -0
- /package/dist/cjs/{util → utils}/heightHelper.js +0 -0
- /package/dist/cjs/{util → utils}/initModuleFederationSharing.js +0 -0
- /package/dist/cjs/{util → utils}/is.js +0 -0
- /package/dist/cjs/{util → utils}/postIframeForm.js +0 -0
- /package/dist/cjs/{util → utils}/transferNestedFunctions.js +0 -0
- /package/dist/cjs/{util → utils}/url.js +0 -0
- /package/dist/esm/{constants → contexts}/hydrationContext.js +0 -0
- /package/dist/esm/{constants → contexts}/moduleContext.js +0 -0
- /package/dist/esm/{helper/apiListenerHelper.js → utils/apiListener.js} +0 -0
- /package/dist/esm/{util → utils}/appCall.js +0 -0
- /package/dist/esm/{util → utils}/bindChaynsApi.js +0 -0
- /package/dist/esm/{util → utils}/collectCssChunks.js +0 -0
- /package/dist/esm/{util → utils}/deviceHelper.js +0 -0
- /package/dist/esm/{util → utils}/heightHelper.js +0 -0
- /package/dist/esm/{util → utils}/initModuleFederationSharing.js +0 -0
- /package/dist/esm/{util → utils}/is.js +0 -0
- /package/dist/esm/{util → utils}/postIframeForm.js +0 -0
- /package/dist/esm/{util → utils}/transferNestedFunctions.js +0 -0
- /package/dist/esm/{util → utils}/url.js +0 -0
- /package/dist/types/{constants → contexts}/hydrationContext.d.ts +0 -0
- /package/dist/types/{constants → contexts}/moduleContext.d.ts +0 -0
- /package/dist/types/{helper/apiListenerHelper.d.ts → utils/apiListener.d.ts} +0 -0
- /package/dist/types/{util → utils}/appCall.d.ts +0 -0
- /package/dist/types/{util → utils}/appStorage.d.ts +0 -0
- /package/dist/types/{util → utils}/bindChaynsApi.d.ts +0 -0
- /package/dist/types/{util → utils}/deviceHelper.d.ts +0 -0
- /package/dist/types/{util → utils}/heightHelper.d.ts +0 -0
- /package/dist/types/{util → utils}/initModuleFederationSharing.d.ts +0 -0
- /package/dist/types/{util → utils}/is.d.ts +0 -0
- /package/dist/types/{util → utils}/postIframeForm.d.ts +0 -0
- /package/dist/types/{util → utils}/transferNestedFunctions.d.ts +0 -0
- /package/dist/types/{util → utils}/url.d.ts +0 -0
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ChaynsHistoryLayerProvider", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _HistoryLayerContext.ChaynsHistoryLayerProvider;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.useChaynsHistoryActiveChild = useChaynsHistoryActiveChild;
|
|
13
|
+
exports.useChaynsHistoryBlock = useChaynsHistoryBlock;
|
|
14
|
+
exports.useChaynsHistoryChildLayer = useChaynsHistoryChildLayer;
|
|
15
|
+
exports.useChaynsHistoryEvent = useChaynsHistoryEvent;
|
|
16
|
+
exports.useChaynsHistoryHash = useChaynsHistoryHash;
|
|
17
|
+
exports.useChaynsHistoryLayer = useChaynsHistoryLayer;
|
|
18
|
+
Object.defineProperty(exports, "useChaynsHistoryLayerContext", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _HistoryLayerContext.useChaynsHistoryLayerContext;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
exports.useChaynsHistoryNavigate = useChaynsHistoryNavigate;
|
|
25
|
+
exports.useChaynsHistoryParams = useChaynsHistoryParams;
|
|
26
|
+
exports.useChaynsHistoryRoute = useChaynsHistoryRoute;
|
|
27
|
+
exports.useChaynsHistoryState = useChaynsHistoryState;
|
|
28
|
+
var _reactCompilerRuntime = require("react-compiler-runtime");
|
|
29
|
+
var _react = require("react");
|
|
30
|
+
var _HistoryLayerContext = require("../contexts/HistoryLayerContext");
|
|
31
|
+
var _equality = require("../utils/equality");
|
|
32
|
+
function useChaynsHistoryLayer() {
|
|
33
|
+
const $ = (0, _reactCompilerRuntime.c)(1);
|
|
34
|
+
const ctx = (0, _HistoryLayerContext.useChaynsHistoryLayerContext)();
|
|
35
|
+
if (ctx) {
|
|
36
|
+
return ctx;
|
|
37
|
+
}
|
|
38
|
+
let t0;
|
|
39
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
40
|
+
var _chaynsHost, _chaynsHost$getOwnLay;
|
|
41
|
+
t0 = typeof window !== "undefined" ? (_chaynsHost = window.__chaynsHost) === null || _chaynsHost === void 0 || (_chaynsHost = _chaynsHost.history) === null || _chaynsHost === void 0 || (_chaynsHost$getOwnLay = _chaynsHost.getOwnLayer) === null || _chaynsHost$getOwnLay === void 0 ? void 0 : _chaynsHost$getOwnLay.call(_chaynsHost) : undefined;
|
|
42
|
+
$[0] = t0;
|
|
43
|
+
} else {
|
|
44
|
+
t0 = $[0];
|
|
45
|
+
}
|
|
46
|
+
const globalLayer = t0;
|
|
47
|
+
if (globalLayer) {
|
|
48
|
+
return globalLayer;
|
|
49
|
+
}
|
|
50
|
+
throw new Error("[chaynsHistory] useChaynsHistoryLayer must be used inside a <ChaynsHistoryLayerProvider>.");
|
|
51
|
+
}
|
|
52
|
+
function useChaynsHistoryRoute() {
|
|
53
|
+
const $ = (0, _reactCompilerRuntime.c)(10);
|
|
54
|
+
const layer = useChaynsHistoryLayer();
|
|
55
|
+
let t0;
|
|
56
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
57
|
+
t0 = [];
|
|
58
|
+
$[0] = t0;
|
|
59
|
+
} else {
|
|
60
|
+
t0 = $[0];
|
|
61
|
+
}
|
|
62
|
+
const segRef = (0, _react.useRef)(t0);
|
|
63
|
+
let t1;
|
|
64
|
+
if ($[1] !== layer) {
|
|
65
|
+
t1 = () => {
|
|
66
|
+
const next = layer.getRoute();
|
|
67
|
+
const prev = segRef.current;
|
|
68
|
+
if (prev.length === next.length && prev.every((s, i) => s === next[i])) {
|
|
69
|
+
return prev;
|
|
70
|
+
}
|
|
71
|
+
return segRef.current = next;
|
|
72
|
+
};
|
|
73
|
+
$[1] = layer;
|
|
74
|
+
$[2] = t1;
|
|
75
|
+
} else {
|
|
76
|
+
t1 = $[2];
|
|
77
|
+
}
|
|
78
|
+
const getSnapshot = t1;
|
|
79
|
+
let t2;
|
|
80
|
+
if ($[3] !== layer) {
|
|
81
|
+
t2 = notify => {
|
|
82
|
+
const unsub1 = layer.addEventListener("change", notify);
|
|
83
|
+
const unsub2 = layer.addEventListener("popstate", notify);
|
|
84
|
+
return () => {
|
|
85
|
+
unsub1();
|
|
86
|
+
unsub2();
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
$[3] = layer;
|
|
90
|
+
$[4] = t2;
|
|
91
|
+
} else {
|
|
92
|
+
t2 = $[4];
|
|
93
|
+
}
|
|
94
|
+
const subscribe = t2;
|
|
95
|
+
const segments = (0, _react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
96
|
+
let t3;
|
|
97
|
+
if ($[5] !== layer) {
|
|
98
|
+
t3 = (route, opts) => layer.setRoute(route, opts);
|
|
99
|
+
$[5] = layer;
|
|
100
|
+
$[6] = t3;
|
|
101
|
+
} else {
|
|
102
|
+
t3 = $[6];
|
|
103
|
+
}
|
|
104
|
+
const setRoute = t3;
|
|
105
|
+
let t4;
|
|
106
|
+
if ($[7] !== segments || $[8] !== setRoute) {
|
|
107
|
+
t4 = {
|
|
108
|
+
segments,
|
|
109
|
+
setRoute
|
|
110
|
+
};
|
|
111
|
+
$[7] = segments;
|
|
112
|
+
$[8] = setRoute;
|
|
113
|
+
$[9] = t4;
|
|
114
|
+
} else {
|
|
115
|
+
t4 = $[9];
|
|
116
|
+
}
|
|
117
|
+
return t4;
|
|
118
|
+
}
|
|
119
|
+
function useChaynsHistoryState() {
|
|
120
|
+
const $ = (0, _reactCompilerRuntime.c)(9);
|
|
121
|
+
const layer = useChaynsHistoryLayer();
|
|
122
|
+
const stateRef = (0, _react.useRef)(undefined);
|
|
123
|
+
let t0;
|
|
124
|
+
if ($[0] !== layer) {
|
|
125
|
+
t0 = () => {
|
|
126
|
+
const next = layer.getState();
|
|
127
|
+
if (shallowEqualStateSnapshot(stateRef.current, next)) {
|
|
128
|
+
return stateRef.current;
|
|
129
|
+
}
|
|
130
|
+
return stateRef.current = next;
|
|
131
|
+
};
|
|
132
|
+
$[0] = layer;
|
|
133
|
+
$[1] = t0;
|
|
134
|
+
} else {
|
|
135
|
+
t0 = $[1];
|
|
136
|
+
}
|
|
137
|
+
const getSnapshot = t0;
|
|
138
|
+
let t1;
|
|
139
|
+
if ($[2] !== layer) {
|
|
140
|
+
t1 = notify => {
|
|
141
|
+
const unsub1 = layer.addEventListener("change", notify);
|
|
142
|
+
const unsub2 = layer.addEventListener("popstate", notify);
|
|
143
|
+
return () => {
|
|
144
|
+
unsub1();
|
|
145
|
+
unsub2();
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
$[2] = layer;
|
|
149
|
+
$[3] = t1;
|
|
150
|
+
} else {
|
|
151
|
+
t1 = $[3];
|
|
152
|
+
}
|
|
153
|
+
const subscribe = t1;
|
|
154
|
+
const state = (0, _react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
155
|
+
let t2;
|
|
156
|
+
if ($[4] !== layer) {
|
|
157
|
+
t2 = (s, opts) => layer.setState(s, opts);
|
|
158
|
+
$[4] = layer;
|
|
159
|
+
$[5] = t2;
|
|
160
|
+
} else {
|
|
161
|
+
t2 = $[5];
|
|
162
|
+
}
|
|
163
|
+
const setState = t2;
|
|
164
|
+
let t3;
|
|
165
|
+
if ($[6] !== setState || $[7] !== state) {
|
|
166
|
+
t3 = [state, setState];
|
|
167
|
+
$[6] = setState;
|
|
168
|
+
$[7] = state;
|
|
169
|
+
$[8] = t3;
|
|
170
|
+
} else {
|
|
171
|
+
t3 = $[8];
|
|
172
|
+
}
|
|
173
|
+
return t3;
|
|
174
|
+
}
|
|
175
|
+
function useChaynsHistoryNavigate() {
|
|
176
|
+
const $ = (0, _reactCompilerRuntime.c)(2);
|
|
177
|
+
const layer = useChaynsHistoryLayer();
|
|
178
|
+
let t0;
|
|
179
|
+
if ($[0] !== layer) {
|
|
180
|
+
t0 = opts => layer.navigate(opts);
|
|
181
|
+
$[0] = layer;
|
|
182
|
+
$[1] = t0;
|
|
183
|
+
} else {
|
|
184
|
+
t0 = $[1];
|
|
185
|
+
}
|
|
186
|
+
return t0;
|
|
187
|
+
}
|
|
188
|
+
function useChaynsHistoryParams() {
|
|
189
|
+
const $ = (0, _reactCompilerRuntime.c)(10);
|
|
190
|
+
const layer = useChaynsHistoryLayer();
|
|
191
|
+
let t0;
|
|
192
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
193
|
+
t0 = {};
|
|
194
|
+
$[0] = t0;
|
|
195
|
+
} else {
|
|
196
|
+
t0 = $[0];
|
|
197
|
+
}
|
|
198
|
+
const paramsRef = (0, _react.useRef)(t0);
|
|
199
|
+
let t1;
|
|
200
|
+
if ($[1] !== layer) {
|
|
201
|
+
t1 = () => {
|
|
202
|
+
const next = layer.getParams();
|
|
203
|
+
if ((0, _equality.shallowEqualObj)(paramsRef.current, next)) {
|
|
204
|
+
return paramsRef.current;
|
|
205
|
+
}
|
|
206
|
+
return paramsRef.current = next;
|
|
207
|
+
};
|
|
208
|
+
$[1] = layer;
|
|
209
|
+
$[2] = t1;
|
|
210
|
+
} else {
|
|
211
|
+
t1 = $[2];
|
|
212
|
+
}
|
|
213
|
+
const getSnapshot = t1;
|
|
214
|
+
let t2;
|
|
215
|
+
if ($[3] !== layer) {
|
|
216
|
+
t2 = notify => {
|
|
217
|
+
const unsub1 = layer.addEventListener("change", notify);
|
|
218
|
+
const unsub2 = layer.addEventListener("popstate", notify);
|
|
219
|
+
return () => {
|
|
220
|
+
unsub1();
|
|
221
|
+
unsub2();
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
$[3] = layer;
|
|
225
|
+
$[4] = t2;
|
|
226
|
+
} else {
|
|
227
|
+
t2 = $[4];
|
|
228
|
+
}
|
|
229
|
+
const subscribe = t2;
|
|
230
|
+
const params = (0, _react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
231
|
+
let t3;
|
|
232
|
+
if ($[5] !== layer) {
|
|
233
|
+
t3 = (p, opts) => layer.setParams(p, opts);
|
|
234
|
+
$[5] = layer;
|
|
235
|
+
$[6] = t3;
|
|
236
|
+
} else {
|
|
237
|
+
t3 = $[6];
|
|
238
|
+
}
|
|
239
|
+
const setParams = t3;
|
|
240
|
+
let t4;
|
|
241
|
+
if ($[7] !== params || $[8] !== setParams) {
|
|
242
|
+
t4 = [params, setParams];
|
|
243
|
+
$[7] = params;
|
|
244
|
+
$[8] = setParams;
|
|
245
|
+
$[9] = t4;
|
|
246
|
+
} else {
|
|
247
|
+
t4 = $[9];
|
|
248
|
+
}
|
|
249
|
+
return t4;
|
|
250
|
+
}
|
|
251
|
+
function useChaynsHistoryHash() {
|
|
252
|
+
const $ = (0, _reactCompilerRuntime.c)(11);
|
|
253
|
+
const layer = useChaynsHistoryLayer();
|
|
254
|
+
let t0;
|
|
255
|
+
if ($[0] !== layer) {
|
|
256
|
+
t0 = notify => {
|
|
257
|
+
const unsub1 = layer.addEventListener("change", notify);
|
|
258
|
+
const unsub2 = layer.addEventListener("popstate", notify);
|
|
259
|
+
return () => {
|
|
260
|
+
unsub1();
|
|
261
|
+
unsub2();
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
$[0] = layer;
|
|
265
|
+
$[1] = t0;
|
|
266
|
+
} else {
|
|
267
|
+
t0 = $[1];
|
|
268
|
+
}
|
|
269
|
+
const subscribe = t0;
|
|
270
|
+
let t1;
|
|
271
|
+
if ($[2] !== layer) {
|
|
272
|
+
t1 = () => layer.getHash();
|
|
273
|
+
$[2] = layer;
|
|
274
|
+
$[3] = t1;
|
|
275
|
+
} else {
|
|
276
|
+
t1 = $[3];
|
|
277
|
+
}
|
|
278
|
+
const getSnapshot = t1;
|
|
279
|
+
let t2;
|
|
280
|
+
if ($[4] !== layer) {
|
|
281
|
+
t2 = () => layer.getHash();
|
|
282
|
+
$[4] = layer;
|
|
283
|
+
$[5] = t2;
|
|
284
|
+
} else {
|
|
285
|
+
t2 = $[5];
|
|
286
|
+
}
|
|
287
|
+
const getServerSnapshot = t2;
|
|
288
|
+
const hash = (0, _react.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
|
|
289
|
+
let t3;
|
|
290
|
+
if ($[6] !== layer) {
|
|
291
|
+
t3 = (h, opts) => layer.setHash(h, opts);
|
|
292
|
+
$[6] = layer;
|
|
293
|
+
$[7] = t3;
|
|
294
|
+
} else {
|
|
295
|
+
t3 = $[7];
|
|
296
|
+
}
|
|
297
|
+
const setHash = t3;
|
|
298
|
+
let t4;
|
|
299
|
+
if ($[8] !== hash || $[9] !== setHash) {
|
|
300
|
+
t4 = [hash, setHash];
|
|
301
|
+
$[8] = hash;
|
|
302
|
+
$[9] = setHash;
|
|
303
|
+
$[10] = t4;
|
|
304
|
+
} else {
|
|
305
|
+
t4 = $[10];
|
|
306
|
+
}
|
|
307
|
+
return t4;
|
|
308
|
+
}
|
|
309
|
+
function useChaynsHistoryBlock(callback, t0) {
|
|
310
|
+
const $ = (0, _reactCompilerRuntime.c)(9);
|
|
311
|
+
let t1;
|
|
312
|
+
if ($[0] !== t0) {
|
|
313
|
+
t1 = t0 === undefined ? {} : t0;
|
|
314
|
+
$[0] = t0;
|
|
315
|
+
$[1] = t1;
|
|
316
|
+
} else {
|
|
317
|
+
t1 = $[1];
|
|
318
|
+
}
|
|
319
|
+
const opts = t1;
|
|
320
|
+
const layer = useChaynsHistoryLayer();
|
|
321
|
+
const {
|
|
322
|
+
isEnabled: t2,
|
|
323
|
+
scope,
|
|
324
|
+
isBeforeUnload
|
|
325
|
+
} = opts;
|
|
326
|
+
const isEnabled = t2 === undefined ? true : t2;
|
|
327
|
+
let t3;
|
|
328
|
+
let t4;
|
|
329
|
+
if ($[2] !== callback || $[3] !== isBeforeUnload || $[4] !== isEnabled || $[5] !== layer || $[6] !== scope) {
|
|
330
|
+
t3 = () => {
|
|
331
|
+
if (!isEnabled) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
return layer.addBlock(callback, {
|
|
335
|
+
scope,
|
|
336
|
+
isBeforeUnload
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
t4 = [layer, callback, isEnabled, scope, isBeforeUnload];
|
|
340
|
+
$[2] = callback;
|
|
341
|
+
$[3] = isBeforeUnload;
|
|
342
|
+
$[4] = isEnabled;
|
|
343
|
+
$[5] = layer;
|
|
344
|
+
$[6] = scope;
|
|
345
|
+
$[7] = t3;
|
|
346
|
+
$[8] = t4;
|
|
347
|
+
} else {
|
|
348
|
+
t3 = $[7];
|
|
349
|
+
t4 = $[8];
|
|
350
|
+
}
|
|
351
|
+
(0, _react.useEffect)(t3, t4);
|
|
352
|
+
}
|
|
353
|
+
function useChaynsHistoryEvent(type, handler) {
|
|
354
|
+
const $ = (0, _reactCompilerRuntime.c)(5);
|
|
355
|
+
const layer = useChaynsHistoryLayer();
|
|
356
|
+
let t0;
|
|
357
|
+
let t1;
|
|
358
|
+
if ($[0] !== handler || $[1] !== layer || $[2] !== type) {
|
|
359
|
+
t0 = () => layer.addEventListener(type, handler);
|
|
360
|
+
t1 = [layer, type, handler];
|
|
361
|
+
$[0] = handler;
|
|
362
|
+
$[1] = layer;
|
|
363
|
+
$[2] = type;
|
|
364
|
+
$[3] = t0;
|
|
365
|
+
$[4] = t1;
|
|
366
|
+
} else {
|
|
367
|
+
t0 = $[3];
|
|
368
|
+
t1 = $[4];
|
|
369
|
+
}
|
|
370
|
+
(0, _react.useEffect)(t0, t1);
|
|
371
|
+
}
|
|
372
|
+
function useChaynsHistoryChildLayer(id) {
|
|
373
|
+
const $ = (0, _reactCompilerRuntime.c)(6);
|
|
374
|
+
const layer = useChaynsHistoryLayer();
|
|
375
|
+
let t0;
|
|
376
|
+
if ($[0] !== id || $[1] !== layer) {
|
|
377
|
+
t0 = layer.getChildLayer(id);
|
|
378
|
+
$[0] = id;
|
|
379
|
+
$[1] = layer;
|
|
380
|
+
$[2] = t0;
|
|
381
|
+
} else {
|
|
382
|
+
t0 = $[2];
|
|
383
|
+
}
|
|
384
|
+
let child = t0;
|
|
385
|
+
if (!child) {
|
|
386
|
+
let t1;
|
|
387
|
+
if ($[3] !== id || $[4] !== layer) {
|
|
388
|
+
t1 = layer.createChildLayer(id);
|
|
389
|
+
$[3] = id;
|
|
390
|
+
$[4] = layer;
|
|
391
|
+
$[5] = t1;
|
|
392
|
+
} else {
|
|
393
|
+
t1 = $[5];
|
|
394
|
+
}
|
|
395
|
+
child = t1;
|
|
396
|
+
}
|
|
397
|
+
return child;
|
|
398
|
+
}
|
|
399
|
+
function useChaynsHistoryActiveChild() {
|
|
400
|
+
const $ = (0, _reactCompilerRuntime.c)(9);
|
|
401
|
+
const layer = useChaynsHistoryLayer();
|
|
402
|
+
let t0;
|
|
403
|
+
if ($[0] !== layer) {
|
|
404
|
+
t0 = notify => layer.addEventListener("change", notify);
|
|
405
|
+
$[0] = layer;
|
|
406
|
+
$[1] = t0;
|
|
407
|
+
} else {
|
|
408
|
+
t0 = $[1];
|
|
409
|
+
}
|
|
410
|
+
const subscribe = t0;
|
|
411
|
+
let t1;
|
|
412
|
+
if ($[2] !== layer) {
|
|
413
|
+
t1 = () => layer.getActiveChildId();
|
|
414
|
+
$[2] = layer;
|
|
415
|
+
$[3] = t1;
|
|
416
|
+
} else {
|
|
417
|
+
t1 = $[3];
|
|
418
|
+
}
|
|
419
|
+
const getSnapshot = t1;
|
|
420
|
+
const activeChildId = (0, _react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
421
|
+
let t2;
|
|
422
|
+
if ($[4] !== layer) {
|
|
423
|
+
t2 = (id, init) => layer.setActiveChild(id, init);
|
|
424
|
+
$[4] = layer;
|
|
425
|
+
$[5] = t2;
|
|
426
|
+
} else {
|
|
427
|
+
t2 = $[5];
|
|
428
|
+
}
|
|
429
|
+
const setActiveChild = t2;
|
|
430
|
+
let t3;
|
|
431
|
+
if ($[6] !== activeChildId || $[7] !== setActiveChild) {
|
|
432
|
+
t3 = {
|
|
433
|
+
activeChildId,
|
|
434
|
+
setActiveChild
|
|
435
|
+
};
|
|
436
|
+
$[6] = activeChildId;
|
|
437
|
+
$[7] = setActiveChild;
|
|
438
|
+
$[8] = t3;
|
|
439
|
+
} else {
|
|
440
|
+
t3 = $[8];
|
|
441
|
+
}
|
|
442
|
+
return t3;
|
|
443
|
+
}
|
|
444
|
+
function shallowEqualStateSnapshot(a, b) {
|
|
445
|
+
if (a === b) return true;
|
|
446
|
+
if (!a || !b) return false;
|
|
447
|
+
const ak = Object.keys(a);
|
|
448
|
+
const bk = Object.keys(b);
|
|
449
|
+
if (ak.length !== bk.length) return false;
|
|
450
|
+
for (const k of ak) {
|
|
451
|
+
if (a[k] !== b[k]) return false;
|
|
452
|
+
}
|
|
453
|
+
return true;
|
|
454
|
+
}
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -21,6 +21,66 @@ Object.defineProperty(exports, "useChaynsApiId", {
|
|
|
21
21
|
return _useChaynsApiId.useChaynsApiId;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "useChaynsHistoryActiveChild", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _history.useChaynsHistoryActiveChild;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "useChaynsHistoryBlock", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _history.useChaynsHistoryBlock;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "useChaynsHistoryChildLayer", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _history.useChaynsHistoryChildLayer;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "useChaynsHistoryEvent", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _history.useChaynsHistoryEvent;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "useChaynsHistoryHash", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _history.useChaynsHistoryHash;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "useChaynsHistoryLayer", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _history.useChaynsHistoryLayer;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "useChaynsHistoryNavigate", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _history.useChaynsHistoryNavigate;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "useChaynsHistoryParams", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _history.useChaynsHistoryParams;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "useChaynsHistoryRoute", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _history.useChaynsHistoryRoute;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "useChaynsHistoryState", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _history.useChaynsHistoryState;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
24
84
|
Object.defineProperty(exports, "useCurrentPage", {
|
|
25
85
|
enumerable: true,
|
|
26
86
|
get: function () {
|
|
@@ -197,4 +257,5 @@ var _useDialogState = require("./useDialogState");
|
|
|
197
257
|
var _useCustomCallbackFunction = require("./useCustomCallbackFunction");
|
|
198
258
|
var _useCustomFunction = require("./useCustomFunction");
|
|
199
259
|
var _useStyleSettings = require("./useStyleSettings");
|
|
200
|
-
var _useChaynsApiId = require("./useChaynsApiId");
|
|
260
|
+
var _useChaynsApiId = require("./useChaynsApiId");
|
|
261
|
+
var _history = require("./history");
|