@next-core/runtime 1.31.0 → 1.31.2
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/dist/cjs/internal/Renderer.js +4 -4
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/RendererContext.js +92 -123
- package/dist/cjs/internal/RendererContext.js.map +1 -1
- package/dist/cjs/internal/Router.js +68 -110
- package/dist/cjs/internal/Router.js.map +1 -1
- package/dist/cjs/internal/Runtime.js +13 -19
- package/dist/cjs/internal/Runtime.js.map +1 -1
- package/dist/esm/CustomProcessors.js +6 -8
- package/dist/esm/CustomProcessors.js.map +1 -1
- package/dist/esm/CustomTemplates.js +6 -8
- package/dist/esm/CustomTemplates.js.map +1 -1
- package/dist/esm/internal/Renderer.js +4 -4
- package/dist/esm/internal/Renderer.js.map +1 -1
- package/dist/esm/internal/RendererContext.js +92 -123
- package/dist/esm/internal/RendererContext.js.map +1 -1
- package/dist/esm/internal/Router.js +76 -118
- package/dist/esm/internal/Router.js.map +1 -1
- package/dist/esm/internal/Runtime.js +13 -19
- package/dist/esm/internal/Runtime.js.map +1 -1
- package/dist/types/tsdoc-metadata.json +1 -1
- package/package.json +13 -13
|
@@ -2,9 +2,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _classPrivateMethodInitSpec from "@babel/runtime/helpers/classPrivateMethodInitSpec";
|
|
3
3
|
import _classPrivateFieldInitSpec from "@babel/runtime/helpers/classPrivateFieldInitSpec";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
6
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
7
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
8
8
|
import { isEmpty, remove } from "lodash";
|
|
9
9
|
import { listenerFactory } from "./bindListeners.js";
|
|
10
10
|
import { getHistory } from "../history.js";
|
|
@@ -25,18 +25,11 @@ var _memoized = /*#__PURE__*/new WeakMap();
|
|
|
25
25
|
var _allMenuRequests = /*#__PURE__*/new WeakMap();
|
|
26
26
|
var _memoizedMenuRequestMap = /*#__PURE__*/new WeakMap();
|
|
27
27
|
var _locationChangeCallbacks = /*#__PURE__*/new WeakMap();
|
|
28
|
-
var
|
|
29
|
-
var _initializeRerenderBricks = /*#__PURE__*/new WeakSet();
|
|
30
|
-
var _dispatchGeneralLifeCycle = /*#__PURE__*/new WeakSet();
|
|
31
|
-
var _addObserver = /*#__PURE__*/new WeakSet();
|
|
28
|
+
var _RendererContext_brand = /*#__PURE__*/new WeakSet();
|
|
32
29
|
export class RendererContext {
|
|
33
30
|
constructor(scope, options) {
|
|
34
31
|
var _options$unknownBrick;
|
|
35
|
-
_classPrivateMethodInitSpec(this,
|
|
36
|
-
// Note: no `onScrollIntoView` and `onMessage`
|
|
37
|
-
_classPrivateMethodInitSpec(this, _dispatchGeneralLifeCycle);
|
|
38
|
-
_classPrivateMethodInitSpec(this, _initializeRerenderBricks);
|
|
39
|
-
_classPrivateMethodInitSpec(this, _unmountBricks);
|
|
32
|
+
_classPrivateMethodInitSpec(this, _RendererContext_brand);
|
|
40
33
|
/**
|
|
41
34
|
* - page: render as whole page, triggering page life cycles.
|
|
42
35
|
* - fragment: render as fragment, not triggering page life cycles.
|
|
@@ -44,68 +37,41 @@ export class RendererContext {
|
|
|
44
37
|
_defineProperty(this, "scope", void 0);
|
|
45
38
|
_defineProperty(this, "unknownBricks", void 0);
|
|
46
39
|
_defineProperty(this, "renderId", void 0);
|
|
47
|
-
_classPrivateFieldInitSpec(this, _routeHelper,
|
|
48
|
-
writable: true,
|
|
49
|
-
value: void 0
|
|
50
|
-
});
|
|
40
|
+
_classPrivateFieldInitSpec(this, _routeHelper, void 0);
|
|
51
41
|
_classPrivateFieldInitSpec(this, _memoizedLifeCycle, {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
onMessage: [],
|
|
65
|
-
onMessageClose: []
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
_classPrivateFieldInitSpec(this, _observers, {
|
|
69
|
-
writable: true,
|
|
70
|
-
value: new Map()
|
|
71
|
-
});
|
|
72
|
-
_classPrivateFieldInitSpec(this, _mediaListener, {
|
|
73
|
-
writable: true,
|
|
74
|
-
value: void 0
|
|
75
|
-
});
|
|
76
|
-
_classPrivateFieldInitSpec(this, _arbitraryLifeCycle, {
|
|
77
|
-
writable: true,
|
|
78
|
-
value: new Map()
|
|
79
|
-
});
|
|
80
|
-
_classPrivateFieldInitSpec(this, _memoized, {
|
|
81
|
-
writable: true,
|
|
82
|
-
value: void 0
|
|
83
|
-
});
|
|
84
|
-
_classPrivateFieldInitSpec(this, _allMenuRequests, {
|
|
85
|
-
writable: true,
|
|
86
|
-
value: void 0
|
|
87
|
-
});
|
|
88
|
-
_classPrivateFieldInitSpec(this, _memoizedMenuRequestMap, {
|
|
89
|
-
writable: true,
|
|
90
|
-
value: void 0
|
|
91
|
-
});
|
|
92
|
-
_classPrivateFieldInitSpec(this, _locationChangeCallbacks, {
|
|
93
|
-
writable: true,
|
|
94
|
-
value: []
|
|
42
|
+
onBeforePageLoad: [],
|
|
43
|
+
onPageLoad: [],
|
|
44
|
+
onPageLeave: [],
|
|
45
|
+
onBeforePageLeave: [],
|
|
46
|
+
onAnchorLoad: [],
|
|
47
|
+
onAnchorUnload: [],
|
|
48
|
+
onMediaChange: [],
|
|
49
|
+
onScrollIntoView: [],
|
|
50
|
+
onMount: [],
|
|
51
|
+
onUnmount: [],
|
|
52
|
+
onMessage: [],
|
|
53
|
+
onMessageClose: []
|
|
95
54
|
});
|
|
55
|
+
_classPrivateFieldInitSpec(this, _observers, new Map());
|
|
56
|
+
_classPrivateFieldInitSpec(this, _mediaListener, void 0);
|
|
57
|
+
_classPrivateFieldInitSpec(this, _arbitraryLifeCycle, new Map());
|
|
58
|
+
_classPrivateFieldInitSpec(this, _memoized, void 0);
|
|
59
|
+
_classPrivateFieldInitSpec(this, _allMenuRequests, void 0);
|
|
60
|
+
_classPrivateFieldInitSpec(this, _memoizedMenuRequestMap, void 0);
|
|
61
|
+
_classPrivateFieldInitSpec(this, _locationChangeCallbacks, []);
|
|
96
62
|
this.scope = scope;
|
|
97
63
|
this.unknownBricks = (_options$unknownBrick = options === null || options === void 0 ? void 0 : options.unknownBricks) !== null && _options$unknownBrick !== void 0 ? _options$unknownBrick : "throw";
|
|
98
|
-
_classPrivateFieldSet(
|
|
64
|
+
_classPrivateFieldSet(_routeHelper, this, options === null || options === void 0 ? void 0 : options.routeHelper);
|
|
99
65
|
this.renderId = options === null || options === void 0 ? void 0 : options.renderId;
|
|
100
66
|
}
|
|
101
67
|
setInitialMenuRequests(menuRequests) {
|
|
102
|
-
_classPrivateFieldSet(
|
|
68
|
+
_classPrivateFieldSet(_allMenuRequests, this, menuRequests);
|
|
103
69
|
}
|
|
104
70
|
memoizeMenuRequests(route, menuRequests) {
|
|
105
|
-
if (!_classPrivateFieldGet(
|
|
106
|
-
_classPrivateFieldSet(
|
|
71
|
+
if (!_classPrivateFieldGet(_memoizedMenuRequestMap, this)) {
|
|
72
|
+
_classPrivateFieldSet(_memoizedMenuRequestMap, this, new WeakMap());
|
|
107
73
|
}
|
|
108
|
-
_classPrivateFieldGet(
|
|
74
|
+
_classPrivateFieldGet(_memoizedMenuRequestMap, this).set(route, menuRequests[0]);
|
|
109
75
|
}
|
|
110
76
|
reMergeMenuRequests(routes, currentRoute, menuRequests) {
|
|
111
77
|
var _this = this;
|
|
@@ -116,13 +82,13 @@ export class RendererContext {
|
|
|
116
82
|
var _classPrivateFieldGet2;
|
|
117
83
|
// If the sub-routes doesn't match, then `this.memoizeMenuRequests` will
|
|
118
84
|
// not be called, thus `this.#memoizedMenuRequestMap` is not set.
|
|
119
|
-
previousMenuRequest = (_classPrivateFieldGet2 = _classPrivateFieldGet(
|
|
85
|
+
previousMenuRequest = (_classPrivateFieldGet2 = _classPrivateFieldGet(_memoizedMenuRequestMap, _this)) === null || _classPrivateFieldGet2 === void 0 ? void 0 : _classPrivateFieldGet2.get(route);
|
|
120
86
|
if (previousMenuRequest) {
|
|
121
87
|
previousRoute = route;
|
|
122
88
|
break;
|
|
123
89
|
}
|
|
124
90
|
}
|
|
125
|
-
var mergedMenuRequests = _classPrivateFieldGet(
|
|
91
|
+
var mergedMenuRequests = _classPrivateFieldGet(_allMenuRequests, _this);
|
|
126
92
|
var previousIndex = previousMenuRequest ? mergedMenuRequests.indexOf(previousMenuRequest) : -1;
|
|
127
93
|
if (previousIndex === -1) {
|
|
128
94
|
if (!menuRequests.length) {
|
|
@@ -134,24 +100,24 @@ export class RendererContext {
|
|
|
134
100
|
}
|
|
135
101
|
if (previousRoute && previousRoute !== currentRoute) {
|
|
136
102
|
var _classPrivateFieldGet3;
|
|
137
|
-
(_classPrivateFieldGet3 = _classPrivateFieldGet(
|
|
103
|
+
(_classPrivateFieldGet3 = _classPrivateFieldGet(_memoizedMenuRequestMap, _this)) === null || _classPrivateFieldGet3 === void 0 || _classPrivateFieldGet3.delete(previousRoute);
|
|
138
104
|
}
|
|
139
|
-
yield _classPrivateFieldGet(
|
|
105
|
+
yield _classPrivateFieldGet(_routeHelper, _this).mergeMenus(mergedMenuRequests);
|
|
140
106
|
})();
|
|
141
107
|
}
|
|
142
108
|
reBailout(output) {
|
|
143
|
-
return _classPrivateFieldGet(
|
|
109
|
+
return _classPrivateFieldGet(_routeHelper, this).bailout(output);
|
|
144
110
|
}
|
|
145
111
|
reCatch(error, returnNode) {
|
|
146
|
-
return _classPrivateFieldGet(
|
|
112
|
+
return _classPrivateFieldGet(_routeHelper, this).catch(error, returnNode);
|
|
147
113
|
}
|
|
148
114
|
didPerformIncrementalRender(location, prevLocation) {
|
|
149
115
|
var _this2 = this;
|
|
150
116
|
return _asyncToGenerator(function* () {
|
|
151
117
|
// Perform incremental rendering from inside out.
|
|
152
118
|
// This allows nested incremental sub-routes.
|
|
153
|
-
for (var i = _classPrivateFieldGet(
|
|
154
|
-
var callback = _classPrivateFieldGet(
|
|
119
|
+
for (var i = _classPrivateFieldGet(_locationChangeCallbacks, _this2).length - 1; i >= 0; i--) {
|
|
120
|
+
var callback = _classPrivateFieldGet(_locationChangeCallbacks, _this2)[i];
|
|
155
121
|
if (yield callback(location, prevLocation)) {
|
|
156
122
|
return true;
|
|
157
123
|
}
|
|
@@ -165,7 +131,7 @@ export class RendererContext {
|
|
|
165
131
|
* ignore normal rendering.
|
|
166
132
|
*/
|
|
167
133
|
performIncrementalRender(callback) {
|
|
168
|
-
_classPrivateFieldGet(
|
|
134
|
+
_classPrivateFieldGet(_locationChangeCallbacks, this).push(callback);
|
|
169
135
|
}
|
|
170
136
|
registerBrickLifeCycle(brick, lifeCycle) {
|
|
171
137
|
if (!lifeCycle) {
|
|
@@ -175,7 +141,7 @@ export class RendererContext {
|
|
|
175
141
|
for (var key of lifeCycleTypes) {
|
|
176
142
|
var handlers = lifeCycle[key];
|
|
177
143
|
if (handlers) {
|
|
178
|
-
_classPrivateFieldGet(
|
|
144
|
+
_classPrivateFieldGet(_memoizedLifeCycle, this)[key].push({
|
|
179
145
|
brick,
|
|
180
146
|
handlers: handlers
|
|
181
147
|
});
|
|
@@ -188,22 +154,22 @@ export class RendererContext {
|
|
|
188
154
|
}
|
|
189
155
|
}
|
|
190
156
|
registerArbitraryLifeCycle(lifeCycle, fn) {
|
|
191
|
-
var arbitraryCallbacks = _classPrivateFieldGet(
|
|
157
|
+
var arbitraryCallbacks = _classPrivateFieldGet(_arbitraryLifeCycle, this).get(lifeCycle);
|
|
192
158
|
if (arbitraryCallbacks) {
|
|
193
159
|
arbitraryCallbacks.add(fn);
|
|
194
160
|
} else {
|
|
195
|
-
_classPrivateFieldGet(
|
|
161
|
+
_classPrivateFieldGet(_arbitraryLifeCycle, this).set(lifeCycle, new Set([fn]));
|
|
196
162
|
}
|
|
197
163
|
}
|
|
198
164
|
memoize(slotId, keyPath, node, returnNode) {
|
|
199
|
-
if (!_classPrivateFieldGet(
|
|
200
|
-
_classPrivateFieldSet(
|
|
165
|
+
if (!_classPrivateFieldGet(_memoized, this)) {
|
|
166
|
+
_classPrivateFieldSet(_memoized, this, new WeakMap());
|
|
201
167
|
}
|
|
202
168
|
var memKey = [slotId !== null && slotId !== void 0 ? slotId : "", ...keyPath].join(".");
|
|
203
|
-
var mem = _classPrivateFieldGet(
|
|
169
|
+
var mem = _classPrivateFieldGet(_memoized, this).get(returnNode);
|
|
204
170
|
if (!mem) {
|
|
205
171
|
mem = new Map();
|
|
206
|
-
_classPrivateFieldGet(
|
|
172
|
+
_classPrivateFieldGet(_memoized, this).set(returnNode, mem);
|
|
207
173
|
}
|
|
208
174
|
mem.set(memKey, {
|
|
209
175
|
node,
|
|
@@ -215,7 +181,7 @@ export class RendererContext {
|
|
|
215
181
|
reRender(slotId, keyPath, node, returnNode) {
|
|
216
182
|
var memKey = [slotId !== null && slotId !== void 0 ? slotId : "", ...keyPath].join(".");
|
|
217
183
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
218
|
-
var memoized = _classPrivateFieldGet(
|
|
184
|
+
var memoized = _classPrivateFieldGet(_memoized, this).get(returnNode).get(memKey);
|
|
219
185
|
var {
|
|
220
186
|
node: prevNode,
|
|
221
187
|
last: prevLast,
|
|
@@ -281,7 +247,7 @@ export class RendererContext {
|
|
|
281
247
|
|
|
282
248
|
// Unmount previous bricks, including their descendants
|
|
283
249
|
var removeBricks = getBrickRange(prevNode, prevLast);
|
|
284
|
-
|
|
250
|
+
_assertClassBrand(_RendererContext_brand, this, _unmountBricks).call(this, removeBricks);
|
|
285
251
|
mountTree(renderRoot);
|
|
286
252
|
|
|
287
253
|
// Connect back
|
|
@@ -330,76 +296,79 @@ export class RendererContext {
|
|
|
330
296
|
portal.insertBefore(portalFragment, insertPortalBeforeChild);
|
|
331
297
|
}
|
|
332
298
|
var newBricks = getBrickRange(node, last);
|
|
333
|
-
|
|
299
|
+
_assertClassBrand(_RendererContext_brand, this, _initializeRerenderBricks).call(this, newBricks);
|
|
334
300
|
}
|
|
335
301
|
dispose() {
|
|
336
|
-
for (var list of Object.values(_classPrivateFieldGet(
|
|
302
|
+
for (var list of Object.values(_classPrivateFieldGet(_memoizedLifeCycle, this))) {
|
|
337
303
|
list.length = 0;
|
|
338
304
|
}
|
|
339
|
-
for (var _list of _classPrivateFieldGet(
|
|
305
|
+
for (var _list of _classPrivateFieldGet(_observers, this).values()) {
|
|
340
306
|
for (var observer of _list) {
|
|
341
307
|
observer.disconnect();
|
|
342
308
|
}
|
|
343
309
|
_list.length = 0;
|
|
344
310
|
}
|
|
345
|
-
_classPrivateFieldGet(
|
|
346
|
-
if (_classPrivateFieldGet(
|
|
347
|
-
mediaEventTarget.removeEventListener("change", _classPrivateFieldGet(
|
|
348
|
-
_classPrivateFieldSet(
|
|
311
|
+
_classPrivateFieldGet(_observers, this).clear();
|
|
312
|
+
if (_classPrivateFieldGet(_mediaListener, this)) {
|
|
313
|
+
mediaEventTarget.removeEventListener("change", _classPrivateFieldGet(_mediaListener, this));
|
|
314
|
+
_classPrivateFieldSet(_mediaListener, this, undefined);
|
|
349
315
|
}
|
|
350
|
-
_classPrivateFieldSet(
|
|
351
|
-
_classPrivateFieldSet(
|
|
352
|
-
_classPrivateFieldSet(
|
|
353
|
-
_classPrivateFieldGet(
|
|
354
|
-
_classPrivateFieldGet(
|
|
316
|
+
_classPrivateFieldSet(_memoized, this, undefined);
|
|
317
|
+
_classPrivateFieldSet(_allMenuRequests, this, undefined);
|
|
318
|
+
_classPrivateFieldSet(_memoizedMenuRequestMap, this, undefined);
|
|
319
|
+
_classPrivateFieldGet(_arbitraryLifeCycle, this).clear();
|
|
320
|
+
_classPrivateFieldGet(_locationChangeCallbacks, this).length = 0;
|
|
355
321
|
}
|
|
322
|
+
|
|
323
|
+
// Note: no `onScrollIntoView` and `onMessage`
|
|
324
|
+
|
|
356
325
|
dispatchBeforePageLoad() {
|
|
357
|
-
|
|
326
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onBeforePageLoad", new CustomEvent("page.beforeLoad"));
|
|
358
327
|
}
|
|
359
328
|
dispatchPageLoad() {
|
|
360
329
|
var event = new CustomEvent("page.load");
|
|
361
|
-
|
|
330
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onPageLoad", event);
|
|
362
331
|
// Currently only for e2e testing
|
|
363
332
|
window.dispatchEvent(event);
|
|
364
333
|
}
|
|
365
334
|
dispatchBeforePageLeave(detail) {
|
|
366
|
-
|
|
335
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onBeforePageLeave", new CustomEvent("page.beforeLeave", {
|
|
367
336
|
detail
|
|
368
337
|
}));
|
|
369
338
|
}
|
|
370
339
|
dispatchPageLeave() {
|
|
371
|
-
|
|
340
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onPageLeave", new CustomEvent("page.leave"));
|
|
372
341
|
}
|
|
373
342
|
dispatchAnchorLoad() {
|
|
374
343
|
var {
|
|
375
344
|
hash
|
|
376
345
|
} = getHistory().location;
|
|
377
346
|
if (hash && hash !== "#") {
|
|
378
|
-
|
|
347
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onAnchorLoad", new CustomEvent("anchor.load", {
|
|
379
348
|
detail: {
|
|
380
349
|
hash,
|
|
381
350
|
anchor: hash.substring(1)
|
|
382
351
|
}
|
|
383
352
|
}));
|
|
384
353
|
} else {
|
|
385
|
-
|
|
354
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onAnchorUnload", new CustomEvent("anchor.unload"));
|
|
386
355
|
}
|
|
387
356
|
}
|
|
388
357
|
initializeScrollIntoView() {
|
|
389
358
|
for (var {
|
|
390
359
|
brick,
|
|
391
360
|
handlers: conf
|
|
392
|
-
} of _classPrivateFieldGet(
|
|
393
|
-
|
|
361
|
+
} of _classPrivateFieldGet(_memoizedLifeCycle, this).onScrollIntoView) {
|
|
362
|
+
_assertClassBrand(_RendererContext_brand, this, _addObserver).call(this, brick, conf);
|
|
394
363
|
}
|
|
395
364
|
}
|
|
396
365
|
initializeMediaChange() {
|
|
397
|
-
_classPrivateFieldSet(
|
|
398
|
-
|
|
366
|
+
_classPrivateFieldSet(_mediaListener, this, event => {
|
|
367
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onMediaChange", new CustomEvent("media.change", {
|
|
399
368
|
detail: getReadOnlyProxy(event.detail)
|
|
400
369
|
}));
|
|
401
370
|
});
|
|
402
|
-
mediaEventTarget.addEventListener("change", _classPrivateFieldGet(
|
|
371
|
+
mediaEventTarget.addEventListener("change", _classPrivateFieldGet(_mediaListener, this));
|
|
403
372
|
}
|
|
404
373
|
initializeMessageDispatcher() {
|
|
405
374
|
var _hooks$messageDispatc;
|
|
@@ -419,27 +388,27 @@ export class RendererContext {
|
|
|
419
388
|
for (var {
|
|
420
389
|
brick,
|
|
421
390
|
handlers: confList
|
|
422
|
-
} of _classPrivateFieldGet(
|
|
391
|
+
} of _classPrivateFieldGet(_memoizedLifeCycle, this).onMessage) {
|
|
423
392
|
_loop(brick);
|
|
424
393
|
}
|
|
425
394
|
hooks === null || hooks === void 0 || (_hooks$messageDispatc = hooks.messageDispatcher) === null || _hooks$messageDispatc === void 0 || _hooks$messageDispatc.onClose(() => {
|
|
426
|
-
|
|
395
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onMessageClose", new CustomEvent("message.close"));
|
|
427
396
|
});
|
|
428
397
|
}
|
|
429
398
|
dispatchOnMount() {
|
|
430
|
-
|
|
399
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onMount", new CustomEvent("mount"));
|
|
431
400
|
}
|
|
432
401
|
dispatchOnUnmount() {
|
|
433
|
-
|
|
402
|
+
_assertClassBrand(_RendererContext_brand, this, _dispatchGeneralLifeCycle).call(this, "onUnmount", new CustomEvent("unmount"));
|
|
434
403
|
}
|
|
435
404
|
}
|
|
436
|
-
function
|
|
405
|
+
function _unmountBricks(bricks) {
|
|
437
406
|
var lifeCycleTypes = [...commonLifeCycles, ...(this.scope === "page" ? pageOnlyLifeCycles : [])];
|
|
438
407
|
var unmountList = [];
|
|
439
408
|
|
|
440
409
|
// Clear life cycle handlers, record `onUnmount` at the same time
|
|
441
410
|
for (var key of lifeCycleTypes) {
|
|
442
|
-
var removed = remove(_classPrivateFieldGet(
|
|
411
|
+
var removed = remove(_classPrivateFieldGet(_memoizedLifeCycle, this)[key], item => bricks.has(item.brick));
|
|
443
412
|
if (key === "onUnmount") {
|
|
444
413
|
unmountList.push(...removed);
|
|
445
414
|
}
|
|
@@ -448,13 +417,13 @@ function _unmountBricks2(bricks) {
|
|
|
448
417
|
// Clear intersection observers
|
|
449
418
|
for (var brick of bricks) {
|
|
450
419
|
var _brick$element, _brick$element2;
|
|
451
|
-
var observers = _classPrivateFieldGet(
|
|
420
|
+
var observers = _classPrivateFieldGet(_observers, this).get(brick);
|
|
452
421
|
if (observers !== null && observers !== void 0 && observers.length) {
|
|
453
422
|
for (var observer of observers) {
|
|
454
423
|
observer.disconnect();
|
|
455
424
|
}
|
|
456
425
|
observers.length = 0;
|
|
457
|
-
_classPrivateFieldGet(
|
|
426
|
+
_classPrivateFieldGet(_observers, this).delete(brick);
|
|
458
427
|
}
|
|
459
428
|
unbindTemplateProxy(brick);
|
|
460
429
|
(_brick$element = brick.element) === null || _brick$element === void 0 || delete _brick$element.$$tplStateStore;
|
|
@@ -472,12 +441,12 @@ function _unmountBricks2(bricks) {
|
|
|
472
441
|
listenerFactory(handlers, _brick.runtimeContext, _brick)(unmountEvent);
|
|
473
442
|
}
|
|
474
443
|
}
|
|
475
|
-
function
|
|
444
|
+
function _initializeRerenderBricks(bricks) {
|
|
476
445
|
var mountEvent = new CustomEvent("mount");
|
|
477
446
|
for (var {
|
|
478
447
|
brick,
|
|
479
448
|
handlers
|
|
480
|
-
} of _classPrivateFieldGet(
|
|
449
|
+
} of _classPrivateFieldGet(_memoizedLifeCycle, this).onMount) {
|
|
481
450
|
if (bricks.has(brick)) {
|
|
482
451
|
listenerFactory(handlers, brick.runtimeContext, brick)(mountEvent);
|
|
483
452
|
}
|
|
@@ -485,13 +454,13 @@ function _initializeRerenderBricks2(bricks) {
|
|
|
485
454
|
for (var {
|
|
486
455
|
brick: _brick2,
|
|
487
456
|
handlers: conf
|
|
488
|
-
} of _classPrivateFieldGet(
|
|
457
|
+
} of _classPrivateFieldGet(_memoizedLifeCycle, this).onScrollIntoView) {
|
|
489
458
|
if (bricks.has(_brick2)) {
|
|
490
|
-
|
|
459
|
+
_assertClassBrand(_RendererContext_brand, this, _addObserver).call(this, _brick2, conf);
|
|
491
460
|
}
|
|
492
461
|
}
|
|
493
462
|
}
|
|
494
|
-
function
|
|
463
|
+
function _dispatchGeneralLifeCycle(type, event) {
|
|
495
464
|
// istanbul ignore next
|
|
496
465
|
if (process.env.NODE_ENV === "development" && this.scope === "fragment" && pageOnlyLifeCycles.includes(type)) {
|
|
497
466
|
throw new Error("`lifeCycle.".concat(type, "` cannot be used in ").concat(this.scope, ".\nThis is a bug of Brick Next, please report it."));
|
|
@@ -499,17 +468,17 @@ function _dispatchGeneralLifeCycle2(type, event) {
|
|
|
499
468
|
for (var {
|
|
500
469
|
brick,
|
|
501
470
|
handlers
|
|
502
|
-
} of _classPrivateFieldGet(
|
|
471
|
+
} of _classPrivateFieldGet(_memoizedLifeCycle, this)[type]) {
|
|
503
472
|
listenerFactory(handlers, brick.runtimeContext, brick)(event);
|
|
504
473
|
}
|
|
505
|
-
var arbitraryCallbacks = _classPrivateFieldGet(
|
|
474
|
+
var arbitraryCallbacks = _classPrivateFieldGet(_arbitraryLifeCycle, this).get(type);
|
|
506
475
|
if (arbitraryCallbacks) {
|
|
507
476
|
for (var fn of arbitraryCallbacks) {
|
|
508
477
|
fn();
|
|
509
478
|
}
|
|
510
479
|
}
|
|
511
480
|
}
|
|
512
|
-
function
|
|
481
|
+
function _addObserver(brick, conf) {
|
|
513
482
|
var _conf$threshold;
|
|
514
483
|
var threshold = (_conf$threshold = conf.threshold) !== null && _conf$threshold !== void 0 ? _conf$threshold : 0.1;
|
|
515
484
|
var observer = new IntersectionObserver((entries, observer) => {
|
|
@@ -525,10 +494,10 @@ function _addObserver2(brick, conf) {
|
|
|
525
494
|
threshold
|
|
526
495
|
});
|
|
527
496
|
observer.observe(brick.element);
|
|
528
|
-
var list = _classPrivateFieldGet(
|
|
497
|
+
var list = _classPrivateFieldGet(_observers, this).get(brick);
|
|
529
498
|
if (!list) {
|
|
530
499
|
list = [];
|
|
531
|
-
_classPrivateFieldGet(
|
|
500
|
+
_classPrivateFieldGet(_observers, this).set(brick, list);
|
|
532
501
|
}
|
|
533
502
|
list.push(observer);
|
|
534
503
|
}
|