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
package/dist/cjs/index.js
CHANGED
|
@@ -15,9 +15,28 @@ var _exportNames = {
|
|
|
15
15
|
loadComponent: true,
|
|
16
16
|
loadModule: true,
|
|
17
17
|
DialogHandler: true,
|
|
18
|
+
initRootChaynsHistoryLayer: true,
|
|
19
|
+
getOrInitRootChaynsHistoryLayer: true,
|
|
20
|
+
NavigationQueue: true,
|
|
21
|
+
BlockRegistry: true,
|
|
22
|
+
projectToUrl: true,
|
|
23
|
+
parseFromUrl: true,
|
|
24
|
+
projectToState: true,
|
|
25
|
+
applyStateToTree: true,
|
|
26
|
+
diffIncomingState: true,
|
|
27
|
+
hasChaynsHistoryState: true,
|
|
28
|
+
getChaynsHistoryActiveChain: true,
|
|
29
|
+
findChaynsHistoryLayerById: true,
|
|
30
|
+
isInChaynsHistoryActiveChain: true,
|
|
18
31
|
dialog: true,
|
|
19
32
|
getChaynsApi: true
|
|
20
33
|
};
|
|
34
|
+
Object.defineProperty(exports, "BlockRegistry", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return _BlockRegistry.BlockRegistry;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
21
40
|
Object.defineProperty(exports, "ChaynsHost", {
|
|
22
41
|
enumerable: true,
|
|
23
42
|
get: function () {
|
|
@@ -36,19 +55,49 @@ Object.defineProperty(exports, "DialogHandler", {
|
|
|
36
55
|
return _DialogHandler.default;
|
|
37
56
|
}
|
|
38
57
|
});
|
|
58
|
+
Object.defineProperty(exports, "NavigationQueue", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () {
|
|
61
|
+
return _NavigationQueue.NavigationQueue;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
39
64
|
Object.defineProperty(exports, "StaticChaynsApi", {
|
|
40
65
|
enumerable: true,
|
|
41
66
|
get: function () {
|
|
42
67
|
return _StaticChaynsApi.default;
|
|
43
68
|
}
|
|
44
69
|
});
|
|
70
|
+
Object.defineProperty(exports, "applyStateToTree", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () {
|
|
73
|
+
return _stateProjector.applyStateToTree;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
45
76
|
exports.dialog = void 0;
|
|
77
|
+
Object.defineProperty(exports, "diffIncomingState", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () {
|
|
80
|
+
return _stateProjector.diffIncomingState;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(exports, "findChaynsHistoryLayerById", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () {
|
|
86
|
+
return _layerTree.findChaynsHistoryLayerById;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
46
89
|
Object.defineProperty(exports, "getChaynsApi", {
|
|
47
90
|
enumerable: true,
|
|
48
91
|
get: function () {
|
|
49
92
|
return _moduleWrapper.getChaynsApi;
|
|
50
93
|
}
|
|
51
94
|
});
|
|
95
|
+
Object.defineProperty(exports, "getChaynsHistoryActiveChain", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () {
|
|
98
|
+
return _layerTree.getChaynsHistoryActiveChain;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
52
101
|
Object.defineProperty(exports, "getClientDeviceInfo", {
|
|
53
102
|
enumerable: true,
|
|
54
103
|
get: function () {
|
|
@@ -61,12 +110,36 @@ Object.defineProperty(exports, "getDeviceInfo", {
|
|
|
61
110
|
return _deviceHelper.default;
|
|
62
111
|
}
|
|
63
112
|
});
|
|
113
|
+
Object.defineProperty(exports, "getOrInitRootChaynsHistoryLayer", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return _rootLayer.getOrInitRootChaynsHistoryLayer;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
64
119
|
Object.defineProperty(exports, "getScreenSize", {
|
|
65
120
|
enumerable: true,
|
|
66
121
|
get: function () {
|
|
67
122
|
return _deviceHelper.getScreenSize;
|
|
68
123
|
}
|
|
69
124
|
});
|
|
125
|
+
Object.defineProperty(exports, "hasChaynsHistoryState", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () {
|
|
128
|
+
return _stateProjector.hasChaynsHistoryState;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(exports, "initRootChaynsHistoryLayer", {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return _rootLayer.initRootChaynsHistoryLayer;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(exports, "isInChaynsHistoryActiveChain", {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function () {
|
|
140
|
+
return _layerTree.isInChaynsHistoryActiveChain;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
70
143
|
Object.defineProperty(exports, "loadComponent", {
|
|
71
144
|
enumerable: true,
|
|
72
145
|
get: function () {
|
|
@@ -79,6 +152,24 @@ Object.defineProperty(exports, "loadModule", {
|
|
|
79
152
|
return _loadComponent.loadModule;
|
|
80
153
|
}
|
|
81
154
|
});
|
|
155
|
+
Object.defineProperty(exports, "parseFromUrl", {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
get: function () {
|
|
158
|
+
return _url.parseFromUrl;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(exports, "projectToState", {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
get: function () {
|
|
164
|
+
return _stateProjector.projectToState;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
Object.defineProperty(exports, "projectToUrl", {
|
|
168
|
+
enumerable: true,
|
|
169
|
+
get: function () {
|
|
170
|
+
return _url.projectToUrl;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
82
173
|
Object.defineProperty(exports, "withCompatMode", {
|
|
83
174
|
enumerable: true,
|
|
84
175
|
get: function () {
|
|
@@ -92,7 +183,7 @@ Object.defineProperty(exports, "withHydrationBoundary", {
|
|
|
92
183
|
}
|
|
93
184
|
});
|
|
94
185
|
var _ChaynsProvider = _interopRequireDefault(require("./components/ChaynsProvider"));
|
|
95
|
-
var _deviceHelper = _interopRequireWildcard(require("./
|
|
186
|
+
var _deviceHelper = _interopRequireWildcard(require("./utils/deviceHelper"));
|
|
96
187
|
var _ChaynsHost = _interopRequireDefault(require("./host/ChaynsHost"));
|
|
97
188
|
var _withCompatMode = require("./components/withCompatMode");
|
|
98
189
|
var _calls = require("./calls");
|
|
@@ -143,7 +234,19 @@ Object.keys(_IChaynsReact).forEach(function (key) {
|
|
|
143
234
|
}
|
|
144
235
|
});
|
|
145
236
|
});
|
|
146
|
-
var
|
|
237
|
+
var _history = require("./types/history");
|
|
238
|
+
Object.keys(_history).forEach(function (key) {
|
|
239
|
+
if (key === "default" || key === "__esModule") return;
|
|
240
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
241
|
+
if (key in exports && exports[key] === _history[key]) return;
|
|
242
|
+
Object.defineProperty(exports, key, {
|
|
243
|
+
enumerable: true,
|
|
244
|
+
get: function () {
|
|
245
|
+
return _history[key];
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
var _is = require("./utils/is");
|
|
147
250
|
Object.keys(_is).forEach(function (key) {
|
|
148
251
|
if (key === "default" || key === "__esModule") return;
|
|
149
252
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -171,6 +274,24 @@ var _withHydrationBoundary = _interopRequireDefault(require("./components/withHy
|
|
|
171
274
|
var _StaticChaynsApi = _interopRequireDefault(require("./wrapper/StaticChaynsApi"));
|
|
172
275
|
var _loadComponent = _interopRequireWildcard(require("./host/module/utils/loadComponent"));
|
|
173
276
|
var _DialogHandler = _interopRequireDefault(require("./handler/DialogHandler"));
|
|
277
|
+
var _history2 = require("./handler/history");
|
|
278
|
+
Object.keys(_history2).forEach(function (key) {
|
|
279
|
+
if (key === "default" || key === "__esModule") return;
|
|
280
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
281
|
+
if (key in exports && exports[key] === _history2[key]) return;
|
|
282
|
+
Object.defineProperty(exports, key, {
|
|
283
|
+
enumerable: true,
|
|
284
|
+
get: function () {
|
|
285
|
+
return _history2[key];
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
var _rootLayer = require("./utils/history/rootLayer");
|
|
290
|
+
var _NavigationQueue = require("./utils/history/NavigationQueue");
|
|
291
|
+
var _BlockRegistry = require("./utils/history/BlockRegistry");
|
|
292
|
+
var _url = require("./utils/history/url");
|
|
293
|
+
var _stateProjector = require("./utils/history/stateProjector");
|
|
294
|
+
var _layerTree = require("./utils/history/layerTree");
|
|
174
295
|
var _dialog = _interopRequireWildcard(require("./calls/dialogs/index"));
|
|
175
296
|
exports.dialog = _dialog;
|
|
176
297
|
var _plugins = require("./plugins");
|
|
@@ -185,7 +306,7 @@ Object.keys(_plugins).forEach(function (key) {
|
|
|
185
306
|
}
|
|
186
307
|
});
|
|
187
308
|
});
|
|
188
|
-
var _initModuleFederationSharing = require("./
|
|
309
|
+
var _initModuleFederationSharing = require("./utils/initModuleFederationSharing");
|
|
189
310
|
Object.keys(_initModuleFederationSharing).forEach(function (key) {
|
|
190
311
|
if (key === "default" || key === "__esModule") return;
|
|
191
312
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -197,7 +318,7 @@ Object.keys(_initModuleFederationSharing).forEach(function (key) {
|
|
|
197
318
|
}
|
|
198
319
|
});
|
|
199
320
|
});
|
|
200
|
-
var _bindChaynsApi = require("./
|
|
321
|
+
var _bindChaynsApi = require("./utils/bindChaynsApi");
|
|
201
322
|
Object.keys(_bindChaynsApi).forEach(function (key) {
|
|
202
323
|
if (key === "default" || key === "__esModule") return;
|
|
203
324
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -209,7 +330,7 @@ Object.keys(_bindChaynsApi).forEach(function (key) {
|
|
|
209
330
|
}
|
|
210
331
|
});
|
|
211
332
|
});
|
|
212
|
-
var _appStorage = require("./
|
|
333
|
+
var _appStorage = require("./utils/appStorage");
|
|
213
334
|
Object.keys(_appStorage).forEach(function (key) {
|
|
214
335
|
if (key === "default" || key === "__esModule") return;
|
|
215
336
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -221,7 +342,7 @@ Object.keys(_appStorage).forEach(function (key) {
|
|
|
221
342
|
}
|
|
222
343
|
});
|
|
223
344
|
});
|
|
224
|
-
var _collectCssChunks = require("./
|
|
345
|
+
var _collectCssChunks = require("./utils/collectCssChunks");
|
|
225
346
|
Object.keys(_collectCssChunks).forEach(function (key) {
|
|
226
347
|
if (key === "default" || key === "__esModule") return;
|
|
227
348
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -233,6 +354,18 @@ Object.keys(_collectCssChunks).forEach(function (key) {
|
|
|
233
354
|
}
|
|
234
355
|
});
|
|
235
356
|
});
|
|
357
|
+
var _contexts = require("./contexts");
|
|
358
|
+
Object.keys(_contexts).forEach(function (key) {
|
|
359
|
+
if (key === "default" || key === "__esModule") return;
|
|
360
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
361
|
+
if (key in exports && exports[key] === _contexts[key]) return;
|
|
362
|
+
Object.defineProperty(exports, key, {
|
|
363
|
+
enumerable: true,
|
|
364
|
+
get: function () {
|
|
365
|
+
return _contexts[key];
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
236
369
|
var _moduleWrapper = require("./components/moduleWrapper");
|
|
237
370
|
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); }
|
|
238
371
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/cjs/umd.index.js
CHANGED
|
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "getScreenSize", {
|
|
|
42
42
|
return _deviceHelper.getScreenSize;
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
var _deviceHelper = _interopRequireWildcard(require("./
|
|
45
|
+
var _deviceHelper = _interopRequireWildcard(require("./utils/deviceHelper"));
|
|
46
46
|
var _calls = require("./calls");
|
|
47
47
|
Object.keys(_calls).forEach(function (key) {
|
|
48
48
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -67,7 +67,7 @@ Object.keys(_IChaynsReact).forEach(function (key) {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
|
-
var _is = require("./
|
|
70
|
+
var _is = require("./utils/is");
|
|
71
71
|
Object.keys(_is).forEach(function (key) {
|
|
72
72
|
if (key === "default" || key === "__esModule") return;
|
|
73
73
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EventBus = void 0;
|
|
7
|
+
class EventBus {
|
|
8
|
+
listeners = new Map();
|
|
9
|
+
on(type, handler) {
|
|
10
|
+
let set = this.listeners.get(type);
|
|
11
|
+
if (!set) {
|
|
12
|
+
set = new Set();
|
|
13
|
+
this.listeners.set(type, set);
|
|
14
|
+
}
|
|
15
|
+
set.add(handler);
|
|
16
|
+
return () => set.delete(handler);
|
|
17
|
+
}
|
|
18
|
+
emit(type, event) {
|
|
19
|
+
const set = this.listeners.get(type);
|
|
20
|
+
if (!set) return;
|
|
21
|
+
for (const fn of [...set]) {
|
|
22
|
+
try {
|
|
23
|
+
fn(event);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.error('[chaynsHistory] listener threw', err);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
clear() {
|
|
30
|
+
this.listeners.clear();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.EventBus = EventBus;
|
|
@@ -9,7 +9,7 @@ exports.getAppStorageItem = getAppStorageItem;
|
|
|
9
9
|
exports.isAppStorageAvailable = isAppStorageAvailable;
|
|
10
10
|
exports.removeAppStorageItem = removeAppStorageItem;
|
|
11
11
|
exports.setAppStorageItem = setAppStorageItem;
|
|
12
|
-
var
|
|
12
|
+
var _apiListener = require("./apiListener");
|
|
13
13
|
var _IChaynsReact = require("../types/IChaynsReact");
|
|
14
14
|
function isAppStorageAvailable() {
|
|
15
15
|
var _this$values$device$a, _this$values$device$a2;
|
|
@@ -83,7 +83,7 @@ async function addAppStorageListener(storeName, prefix, callback, callbackPrefix
|
|
|
83
83
|
const callbackName = `${callbackPrefix}_${this.counter++}`;
|
|
84
84
|
const {
|
|
85
85
|
shouldInitialize
|
|
86
|
-
} = (0,
|
|
86
|
+
} = (0, _apiListener.addApiListener)(`appStorageListener/${storeName}`, callback);
|
|
87
87
|
const handleValue = value => {
|
|
88
88
|
var _value$key;
|
|
89
89
|
if (value.action === 0 && (_value$key = value.key) !== null && _value$key !== void 0 && _value$key.startsWith(prefix)) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shallowEqualArr = shallowEqualArr;
|
|
7
|
+
exports.shallowEqualObj = shallowEqualObj;
|
|
8
|
+
function shallowEqualArr(a, b) {
|
|
9
|
+
if (a.length !== b.length) return false;
|
|
10
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
function shallowEqualObj(a, b) {
|
|
14
|
+
const ak = Object.keys(a);
|
|
15
|
+
const bk = Object.keys(b);
|
|
16
|
+
if (ak.length !== bk.length) return false;
|
|
17
|
+
for (const k of ak) if (a[k] !== b[k]) return false;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BlockRegistry = void 0;
|
|
7
|
+
const BLOCK_TIMEOUT_MS = 30000;
|
|
8
|
+
let _nextId = 1;
|
|
9
|
+
class BlockRegistry {
|
|
10
|
+
layerBlocks = new Map();
|
|
11
|
+
beforeUnloadCount = 0;
|
|
12
|
+
beforeUnloadHandler = e => {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
e.returnValue = '';
|
|
15
|
+
};
|
|
16
|
+
add(layer, callback, opts = {}) {
|
|
17
|
+
var _opts$scope, _opts$isBeforeUnload;
|
|
18
|
+
const entry = {
|
|
19
|
+
id: String(_nextId++),
|
|
20
|
+
callback,
|
|
21
|
+
opts: {
|
|
22
|
+
scope: (_opts$scope = opts.scope) !== null && _opts$scope !== void 0 ? _opts$scope : 'local',
|
|
23
|
+
isBeforeUnload: (_opts$isBeforeUnload = opts.isBeforeUnload) !== null && _opts$isBeforeUnload !== void 0 ? _opts$isBeforeUnload : false
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
let set = this.layerBlocks.get(layer.id);
|
|
27
|
+
if (!set) {
|
|
28
|
+
set = new Set();
|
|
29
|
+
this.layerBlocks.set(layer.id, set);
|
|
30
|
+
}
|
|
31
|
+
set.add(entry);
|
|
32
|
+
if (entry.opts.isBeforeUnload) {
|
|
33
|
+
this.incrementBeforeUnload();
|
|
34
|
+
}
|
|
35
|
+
return () => this.remove(layer.id, entry);
|
|
36
|
+
}
|
|
37
|
+
remove(layerId, entry) {
|
|
38
|
+
const set = this.layerBlocks.get(layerId);
|
|
39
|
+
if (!set) return;
|
|
40
|
+
set.delete(entry);
|
|
41
|
+
if (set.size === 0) this.layerBlocks.delete(layerId);
|
|
42
|
+
if (entry.opts.isBeforeUnload) {
|
|
43
|
+
this.decrementBeforeUnload();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
removeAllForLayer(layerId) {
|
|
47
|
+
const set = this.layerBlocks.get(layerId);
|
|
48
|
+
if (!set) return;
|
|
49
|
+
for (const entry of set) {
|
|
50
|
+
if (entry.opts.isBeforeUnload) this.decrementBeforeUnload();
|
|
51
|
+
}
|
|
52
|
+
this.layerBlocks.delete(layerId);
|
|
53
|
+
}
|
|
54
|
+
collectApplicableBlocks(targetLayer) {
|
|
55
|
+
const result = [];
|
|
56
|
+
const localSet = this.layerBlocks.get(targetLayer.id);
|
|
57
|
+
if (localSet) {
|
|
58
|
+
for (const entry of localSet) {
|
|
59
|
+
result.push(entry);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
this.collectGlobalFromActiveDescendants(targetLayer, result);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
collectGlobalFromActiveDescendants(layer, out) {
|
|
66
|
+
const activeChildId = layer.getActiveChildId();
|
|
67
|
+
if (!activeChildId) return;
|
|
68
|
+
const child = layer.getChildLayer(activeChildId);
|
|
69
|
+
if (!child) return;
|
|
70
|
+
const childSet = this.layerBlocks.get(child.id);
|
|
71
|
+
if (childSet) {
|
|
72
|
+
for (const entry of childSet) {
|
|
73
|
+
if (entry.opts.scope === 'global') {
|
|
74
|
+
out.push(entry);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.collectGlobalFromActiveDescendants(child, out);
|
|
79
|
+
}
|
|
80
|
+
async checkBlocks(targetLayer) {
|
|
81
|
+
const blocks = this.collectApplicableBlocks(targetLayer);
|
|
82
|
+
if (blocks.length === 0) return true;
|
|
83
|
+
const results = await Promise.all(blocks.map(b => this.runBlock(b)));
|
|
84
|
+
return results.every(Boolean);
|
|
85
|
+
}
|
|
86
|
+
async runBlock(entry) {
|
|
87
|
+
try {
|
|
88
|
+
const result = await Promise.race([entry.callback(), new Promise(resolve => setTimeout(() => {
|
|
89
|
+
resolve(false);
|
|
90
|
+
}, BLOCK_TIMEOUT_MS))]);
|
|
91
|
+
return result;
|
|
92
|
+
} catch (err) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
incrementBeforeUnload() {
|
|
97
|
+
this.beforeUnloadCount++;
|
|
98
|
+
if (this.beforeUnloadCount === 1 && typeof window !== 'undefined') {
|
|
99
|
+
window.addEventListener('beforeunload', this.beforeUnloadHandler);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
decrementBeforeUnload() {
|
|
103
|
+
if (this.beforeUnloadCount === 0) return;
|
|
104
|
+
this.beforeUnloadCount--;
|
|
105
|
+
if (this.beforeUnloadCount === 0 && typeof window !== 'undefined') {
|
|
106
|
+
window.removeEventListener('beforeunload', this.beforeUnloadHandler);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.BlockRegistry = BlockRegistry;
|