@arcgis/lumina 4.33.0-next.98 → 4.33.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/dist/{Controller-CZ8Djohh.js → Controller-BQOv8BAL.js} +170 -210
- package/dist/LitElement.d.ts +22 -18
- package/dist/config.d.ts +7 -9
- package/dist/config.js +15 -12
- package/dist/context.d.ts +2 -2
- package/dist/controllers/Controller.d.ts +4 -10
- package/dist/controllers/ControllerInternals.d.ts +7 -13
- package/dist/controllers/ControllerManager.d.ts +6 -21
- package/dist/controllers/accessor/index.d.ts +3 -1
- package/dist/controllers/accessor/index.js +208 -222
- package/dist/controllers/accessor/reEmitEvent.d.ts +1 -1
- package/dist/controllers/accessor/store.d.ts +17 -0
- package/dist/controllers/accessor/useAccessor.d.ts +34 -32
- package/dist/controllers/index.d.ts +2 -2
- package/dist/controllers/index.js +45 -38
- package/dist/controllers/trackKey.d.ts +1 -1
- package/dist/controllers/trackPropKey.d.ts +1 -1
- package/dist/controllers/trackPropertyKey.d.ts +2 -2
- package/dist/controllers/types.d.ts +35 -0
- package/dist/controllers/usePropertyChange.d.ts +3 -1
- package/dist/controllers/utils.d.ts +6 -9
- package/dist/createEvent.d.ts +4 -4
- package/dist/hmrSupport.js +22 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.js +193 -200
- package/dist/jsx/generatedTypes.d.ts +414 -80
- package/dist/lazyLoad-DUvrNd2L.js +406 -0
- package/dist/lazyLoad.d.ts +22 -67
- package/dist/lifecycleSupport.d.ts +1 -1
- package/dist/makeRuntime.d.ts +40 -1
- package/dist/{proxyExports-CK5BLFLO.js → proxyExports-Cdzj7WL_.js} +8 -8
- package/dist/render.d.ts +1 -1
- package/dist/utils.d.ts +8 -0
- package/dist/wrappersUtils.d.ts +13 -1
- package/package.json +5 -5
- package/dist/utils-DBdf1Dqp.js +0 -405
|
@@ -1,50 +1,22 @@
|
|
|
1
1
|
import { isEsriInternalEnv, safeCall, Deferred, safeAsyncCall } from "@arcgis/components-utils";
|
|
2
2
|
import { nothing } from "lit";
|
|
3
3
|
const controllerSymbol = Symbol.for("controller");
|
|
4
|
-
const name = "@arcgis/lumina";
|
|
5
4
|
const isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const index = Array.from(controllers).indexOf(controller);
|
|
9
|
-
if (index === -1) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const devOnlyControllerData = Symbol.for(`${name}: devOnlyControllerData`);
|
|
13
|
-
const el = controller.component.el;
|
|
14
|
-
el[devOnlyControllerData] ??= {};
|
|
15
|
-
el[devOnlyControllerData][index] = data;
|
|
16
|
-
} : void 0;
|
|
17
|
-
const devOnlyGetPersistentControllerData = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (controller) => {
|
|
18
|
-
const manager = controller.component.manager;
|
|
19
|
-
const controllers = "_controllers" in manager ? manager._controllers : void 0;
|
|
20
|
-
if (controllers === void 0) {
|
|
21
|
-
return void 0;
|
|
22
|
-
}
|
|
23
|
-
const index = Array.from(controllers).indexOf(controller);
|
|
24
|
-
const devOnlyControllerData = Symbol.for(`${name}: devOnlyControllerData`);
|
|
25
|
-
const el = controller.component.el;
|
|
26
|
-
return el[devOnlyControllerData]?.[index];
|
|
27
|
-
} : void 0;
|
|
28
|
-
function isPromise(arg) {
|
|
29
|
-
return typeof arg?.then === "function";
|
|
30
|
-
}
|
|
5
|
+
const isPromise = (arg) => typeof arg?.then === "function";
|
|
6
|
+
const getControllersCount = (component) => component.M.length;
|
|
31
7
|
let ambientComponent;
|
|
32
|
-
|
|
8
|
+
const setAmbientComponent = (component) => {
|
|
33
9
|
if (ambientComponent === component) {
|
|
34
10
|
return;
|
|
35
11
|
}
|
|
36
12
|
ambientComponent = component;
|
|
37
|
-
queueMicrotask(() =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function retrieveComponent(name2) {
|
|
13
|
+
queueMicrotask(() => ambientComponent === component ? ambientComponent = void 0 : 0);
|
|
14
|
+
};
|
|
15
|
+
const retrieveComponent = (name) => {
|
|
44
16
|
if (process.env.NODE_ENV !== "production" && ambientComponent === void 0) {
|
|
45
17
|
throw new Error(
|
|
46
18
|
[
|
|
47
|
-
`Unable to find out which component ${
|
|
19
|
+
`Unable to find out which component ${name || "this"} controller `,
|
|
48
20
|
"belongs to. Possible causes:\n",
|
|
49
21
|
"- You might have multiple versions of ",
|
|
50
22
|
"@arcgis/lumina package installed\n",
|
|
@@ -63,39 +35,31 @@ function retrieveComponent(name2) {
|
|
|
63
35
|
);
|
|
64
36
|
}
|
|
65
37
|
return ambientComponent;
|
|
66
|
-
}
|
|
38
|
+
};
|
|
67
39
|
let ambientControllers = [];
|
|
68
|
-
|
|
40
|
+
const setParentController = (controller) => {
|
|
69
41
|
if (controller === void 0) {
|
|
70
42
|
ambientControllers = [];
|
|
71
43
|
return;
|
|
72
44
|
}
|
|
73
45
|
const index = ambientControllers.indexOf(controller);
|
|
74
46
|
ambientControllers = index === -1 ? [...ambientControllers, controller] : ambientControllers.slice(0, index + 1);
|
|
75
|
-
queueMicrotask(() =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
function retrieveParentControllers() {
|
|
80
|
-
return ambientControllers;
|
|
81
|
-
}
|
|
47
|
+
queueMicrotask(() => ambientControllers = []);
|
|
48
|
+
};
|
|
49
|
+
const retrieveParentControllers = () => ambientControllers;
|
|
82
50
|
let ambientChildController;
|
|
83
|
-
|
|
51
|
+
const setAmbientChildController = (controller) => {
|
|
84
52
|
if (ambientChildController === controller) {
|
|
85
53
|
return;
|
|
86
54
|
}
|
|
87
55
|
ambientChildController = controller;
|
|
88
|
-
queueMicrotask(() =>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function retrieveAmbientChildController() {
|
|
56
|
+
queueMicrotask(() => ambientChildController === controller ? ambientChildController = void 0 : 0);
|
|
57
|
+
};
|
|
58
|
+
const retrieveAmbientChildController = () => {
|
|
95
59
|
const controller = ambientChildController;
|
|
96
60
|
ambientChildController = void 0;
|
|
97
61
|
return controller;
|
|
98
|
-
}
|
|
62
|
+
};
|
|
99
63
|
const use = async (value, watchExports) => {
|
|
100
64
|
const controller = useRefSync(value);
|
|
101
65
|
if (controller === void 0) {
|
|
@@ -129,7 +93,7 @@ const useRef = async (value) => {
|
|
|
129
93
|
};
|
|
130
94
|
const useRefSync = (value) => {
|
|
131
95
|
const component = retrieveComponent();
|
|
132
|
-
const controller = component.manager.
|
|
96
|
+
const controller = component.manager.X(value);
|
|
133
97
|
if (controller !== void 0) {
|
|
134
98
|
return controller;
|
|
135
99
|
}
|
|
@@ -142,26 +106,17 @@ const useRefSync = (value) => {
|
|
|
142
106
|
}
|
|
143
107
|
return void 0;
|
|
144
108
|
};
|
|
145
|
-
let shouldBypassGetter = false;
|
|
146
109
|
let shouldBypassReadOnly = false;
|
|
147
|
-
|
|
110
|
+
const bypassReadOnly = (callback) => {
|
|
148
111
|
shouldBypassReadOnly = true;
|
|
149
112
|
try {
|
|
150
113
|
return callback();
|
|
151
114
|
} finally {
|
|
152
115
|
shouldBypassReadOnly = false;
|
|
153
116
|
}
|
|
154
|
-
}
|
|
117
|
+
};
|
|
155
118
|
const bypassSetter = bypassReadOnly;
|
|
156
|
-
|
|
157
|
-
shouldBypassGetter = true;
|
|
158
|
-
try {
|
|
159
|
-
return callback();
|
|
160
|
-
} finally {
|
|
161
|
-
shouldBypassGetter = false;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function trackPropertyKey(object, onResolved, defaultValue) {
|
|
119
|
+
const trackPropertyKey = (object, onResolved, defaultValue) => {
|
|
165
120
|
const keys = Object.keys(object);
|
|
166
121
|
const keyCount = keys.length;
|
|
167
122
|
if (keyTrackMap === void 0) {
|
|
@@ -190,31 +145,31 @@ function trackPropertyKey(object, onResolved, defaultValue) {
|
|
|
190
145
|
}
|
|
191
146
|
});
|
|
192
147
|
return defaultValue;
|
|
193
|
-
}
|
|
148
|
+
};
|
|
194
149
|
let keyTrackMap = void 0;
|
|
195
|
-
|
|
150
|
+
const keyTrackResolve = () => {
|
|
196
151
|
keyTrackMap?.forEach(({ callbacks }, object) => {
|
|
197
152
|
const keys = Object.keys(object);
|
|
198
153
|
callbacks.forEach((commit) => commit(keys));
|
|
199
154
|
});
|
|
200
155
|
keyTrackMap = void 0;
|
|
201
|
-
}
|
|
202
|
-
|
|
156
|
+
};
|
|
157
|
+
const trackPropKey = (component, onResolved, defaultValue) => {
|
|
203
158
|
const manager = component.manager;
|
|
204
|
-
if (manager.
|
|
205
|
-
manager.
|
|
159
|
+
if (manager.V !== nothing && manager.V !== defaultValue) {
|
|
160
|
+
manager.S(void 0, void 0);
|
|
206
161
|
}
|
|
207
|
-
if (manager.
|
|
208
|
-
queueMicrotask(() => manager.
|
|
162
|
+
if (manager.T.length === 0) {
|
|
163
|
+
queueMicrotask(() => manager.S(void 0, void 0));
|
|
209
164
|
}
|
|
210
|
-
manager.
|
|
211
|
-
manager.
|
|
165
|
+
manager.V = defaultValue;
|
|
166
|
+
manager.T.push((key, value) => safeCall(onResolved, void 0, defaultValue === value ? key : void 0));
|
|
212
167
|
return defaultValue;
|
|
213
|
-
}
|
|
214
|
-
|
|
168
|
+
};
|
|
169
|
+
const trackKey = (hostsCandidates = [
|
|
215
170
|
retrieveComponent(),
|
|
216
171
|
...retrieveParentControllers()
|
|
217
|
-
], onResolved, defaultValue) {
|
|
172
|
+
], onResolved, defaultValue) => {
|
|
218
173
|
const candidateHosts = Array.isArray(hostsCandidates) ? hostsCandidates : [hostsCandidates];
|
|
219
174
|
let leftToResolve = candidateHosts.length + 1;
|
|
220
175
|
const resolved = (resolution) => {
|
|
@@ -234,7 +189,7 @@ function trackKey(hostsCandidates = [
|
|
|
234
189
|
)
|
|
235
190
|
);
|
|
236
191
|
for (const host of candidateHosts) {
|
|
237
|
-
if ("manager" in host &&
|
|
192
|
+
if ("manager" in host && host.manager.component === host) {
|
|
238
193
|
trackPropKey(
|
|
239
194
|
host,
|
|
240
195
|
(key) => resolved(key === void 0 ? void 0 : { key, host, isReactive: true }),
|
|
@@ -244,7 +199,7 @@ function trackKey(hostsCandidates = [
|
|
|
244
199
|
}
|
|
245
200
|
}
|
|
246
201
|
return defaultValue;
|
|
247
|
-
}
|
|
202
|
+
};
|
|
248
203
|
const createEventFactory = (eventName = "", options = {}, component = retrieveComponent()) => {
|
|
249
204
|
const emitter = {
|
|
250
205
|
emit: (payload) => {
|
|
@@ -271,12 +226,12 @@ const createEventFactory = (eventName = "", options = {}, component = retrieveCo
|
|
|
271
226
|
if (eventName === "") {
|
|
272
227
|
trackKey(
|
|
273
228
|
void 0,
|
|
274
|
-
(resolution) => {
|
|
275
|
-
if (
|
|
229
|
+
process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (resolution) => {
|
|
230
|
+
if (resolution === void 0) {
|
|
276
231
|
throw new Error(`createEvent must be called in property default value only`);
|
|
277
232
|
}
|
|
278
233
|
eventName = resolution.key;
|
|
279
|
-
},
|
|
234
|
+
} : (resolution) => eventName = resolution.key,
|
|
280
235
|
emitter
|
|
281
236
|
);
|
|
282
237
|
}
|
|
@@ -287,26 +242,26 @@ var _a;
|
|
|
287
242
|
_a = controllerSymbol;
|
|
288
243
|
class Controller {
|
|
289
244
|
constructor(component) {
|
|
290
|
-
this
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
this.
|
|
301
|
-
this._lifecycleCleanups = [];
|
|
245
|
+
this.#hostConnected = [];
|
|
246
|
+
this.#hostDisconnected = [];
|
|
247
|
+
this.#hostLoad = [];
|
|
248
|
+
this.#hostLoaded = [];
|
|
249
|
+
this.#hostUpdate = [];
|
|
250
|
+
this.#hostUpdated = [];
|
|
251
|
+
this.#hostDestroy = [];
|
|
252
|
+
this.#hostLifecycle = [];
|
|
253
|
+
this.#lifecycleCleanups = [];
|
|
254
|
+
this.#loadCalled = false;
|
|
255
|
+
this.P = new Deferred();
|
|
302
256
|
this.connectedCalled = false;
|
|
303
|
-
this._loadCalled = false;
|
|
304
257
|
this.loadedCalled = false;
|
|
305
258
|
this[_a] = true;
|
|
306
|
-
this
|
|
307
|
-
|
|
308
|
-
this._exportWatchers = /* @__PURE__ */ new Set();
|
|
259
|
+
this.#exportWatchers = [];
|
|
260
|
+
const that = this;
|
|
309
261
|
const resolvedComponent = component ?? retrieveComponent(new.target.name);
|
|
262
|
+
that.#component = resolvedComponent;
|
|
263
|
+
that.ready = that.P.promise;
|
|
264
|
+
that.#exports = makeProvisionalValue(that);
|
|
310
265
|
if (process.env.NODE_ENV !== "production") {
|
|
311
266
|
Object.defineProperty(this, "component", {
|
|
312
267
|
writable: false,
|
|
@@ -315,43 +270,54 @@ class Controller {
|
|
|
315
270
|
value: resolvedComponent
|
|
316
271
|
});
|
|
317
272
|
if ("hostDestroy" in this) {
|
|
318
|
-
|
|
273
|
+
that.#component.manager.devOnly$ensureHasDestroy?.();
|
|
319
274
|
}
|
|
320
275
|
} else {
|
|
321
|
-
|
|
276
|
+
that.component = resolvedComponent;
|
|
322
277
|
}
|
|
323
|
-
|
|
324
|
-
const manager =
|
|
278
|
+
that.#component.addController(that);
|
|
279
|
+
const manager = that.#component.manager;
|
|
325
280
|
const isInControllerManager = manager === void 0;
|
|
326
281
|
if (!isInControllerManager) {
|
|
327
|
-
setParentController(
|
|
328
|
-
queueMicrotask(() =>
|
|
282
|
+
setParentController(that);
|
|
283
|
+
queueMicrotask(() => that.catchUpLifecycle());
|
|
329
284
|
}
|
|
330
285
|
}
|
|
286
|
+
#hostConnected;
|
|
287
|
+
#hostDisconnected;
|
|
288
|
+
#hostLoad;
|
|
289
|
+
#hostLoaded;
|
|
290
|
+
#hostUpdate;
|
|
291
|
+
#hostUpdated;
|
|
292
|
+
#hostDestroy;
|
|
293
|
+
#hostLifecycle;
|
|
294
|
+
#lifecycleCleanups;
|
|
295
|
+
#loadCalled;
|
|
296
|
+
#component;
|
|
331
297
|
/**
|
|
332
298
|
* If controller is being added dynamically, after the component
|
|
333
299
|
* construction, then trigger connected and load right away
|
|
334
300
|
*/
|
|
335
301
|
catchUpLifecycle() {
|
|
336
|
-
const { manager } = this
|
|
302
|
+
const { manager } = this.#component;
|
|
337
303
|
const connectedWillStillHappen = !manager.connectedCalled;
|
|
338
304
|
if (!connectedWillStillHappen && !this.connectedCalled) {
|
|
339
305
|
this.triggerConnected();
|
|
340
306
|
}
|
|
341
|
-
const loadWillStillHappen = !manager
|
|
307
|
+
const loadWillStillHappen = !manager.#loadCalled;
|
|
342
308
|
if (loadWillStillHappen) {
|
|
343
309
|
return;
|
|
344
310
|
}
|
|
345
|
-
this.triggerLoad().then(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
311
|
+
this.triggerLoad().then(
|
|
312
|
+
() => (
|
|
313
|
+
// Call loaded ourself, unless manager is going to do it
|
|
314
|
+
manager.loadedCalled && this.triggerLoaded()
|
|
315
|
+
)
|
|
316
|
+
).catch(console.error);
|
|
317
|
+
}
|
|
318
|
+
#exports;
|
|
353
319
|
get exports() {
|
|
354
|
-
return this
|
|
320
|
+
return this.#exports;
|
|
355
321
|
}
|
|
356
322
|
/**
|
|
357
323
|
* Set controller's exports property (for usage with proxyExports()) and mark
|
|
@@ -359,24 +325,25 @@ class Controller {
|
|
|
359
325
|
* re-render of the component
|
|
360
326
|
*/
|
|
361
327
|
set exports(exports) {
|
|
362
|
-
const oldExports = this
|
|
328
|
+
const oldExports = this.#exports;
|
|
363
329
|
if (oldExports !== exports) {
|
|
364
|
-
this
|
|
365
|
-
this.
|
|
366
|
-
if (this.connectedCalled && this.
|
|
367
|
-
this
|
|
330
|
+
this.#exports = exports;
|
|
331
|
+
this.#exportWatchers.forEach(safeCall);
|
|
332
|
+
if (this.connectedCalled && this.O !== false) {
|
|
333
|
+
this.#component.requestUpdate(this.O, oldExports);
|
|
368
334
|
}
|
|
369
335
|
}
|
|
370
|
-
this.
|
|
336
|
+
this.P.resolve(exports);
|
|
371
337
|
}
|
|
372
338
|
setProvisionalExports(exports, proxy = true) {
|
|
373
|
-
this
|
|
374
|
-
this.
|
|
339
|
+
this.#exports = proxy ? makeProvisionalValue(exports) : exports;
|
|
340
|
+
this.#exportWatchers.forEach(safeCall);
|
|
375
341
|
}
|
|
342
|
+
#exportWatchers;
|
|
376
343
|
watchExports(callback) {
|
|
377
|
-
const safeCallback = () => callback(this
|
|
378
|
-
this.
|
|
379
|
-
return () => void this.
|
|
344
|
+
const safeCallback = () => callback(this.#exports);
|
|
345
|
+
this.#exportWatchers.push(safeCallback);
|
|
346
|
+
return () => void this.#exportWatchers.splice(this.#exportWatchers.indexOf(safeCallback), 1);
|
|
380
347
|
}
|
|
381
348
|
/**
|
|
382
349
|
* A flexible utility for making sure a controller is loaded before it's used,
|
|
@@ -399,7 +366,7 @@ class Controller {
|
|
|
399
366
|
* require awaiting them as they are guaranteed to be loaded by then.
|
|
400
367
|
*/
|
|
401
368
|
get use() {
|
|
402
|
-
setAmbientComponent(this
|
|
369
|
+
setAmbientComponent(this.#component);
|
|
403
370
|
return use;
|
|
404
371
|
}
|
|
405
372
|
/**
|
|
@@ -416,7 +383,7 @@ class Controller {
|
|
|
416
383
|
* some other method on the controller
|
|
417
384
|
*/
|
|
418
385
|
get useRef() {
|
|
419
|
-
setAmbientComponent(this
|
|
386
|
+
setAmbientComponent(this.#component);
|
|
420
387
|
return useRef;
|
|
421
388
|
}
|
|
422
389
|
/**
|
|
@@ -425,135 +392,130 @@ class Controller {
|
|
|
425
392
|
* @private
|
|
426
393
|
*/
|
|
427
394
|
get useRefSync() {
|
|
428
|
-
setAmbientComponent(this
|
|
395
|
+
setAmbientComponent(this.#component);
|
|
429
396
|
return useRefSync;
|
|
430
397
|
}
|
|
431
398
|
controllerRemoved() {
|
|
432
|
-
if (this
|
|
399
|
+
if (this.#component.el.isConnected) {
|
|
433
400
|
this.triggerDisconnected();
|
|
434
401
|
}
|
|
435
402
|
this.triggerDestroy();
|
|
436
403
|
}
|
|
437
404
|
// Register a lifecycle callback
|
|
438
405
|
onConnected(callback) {
|
|
439
|
-
this
|
|
406
|
+
this.#hostConnected.push(callback);
|
|
440
407
|
}
|
|
441
408
|
onDisconnected(callback) {
|
|
442
|
-
this
|
|
409
|
+
this.#hostDisconnected.push(callback);
|
|
443
410
|
}
|
|
444
411
|
onLoad(callback) {
|
|
445
|
-
this
|
|
412
|
+
this.#hostLoad.push(callback);
|
|
446
413
|
}
|
|
447
414
|
onLoaded(callback) {
|
|
448
|
-
this
|
|
415
|
+
this.#hostLoaded.push(callback);
|
|
449
416
|
}
|
|
450
417
|
onUpdate(callback) {
|
|
451
|
-
this
|
|
418
|
+
this.#hostUpdate.push(callback);
|
|
452
419
|
}
|
|
453
420
|
onUpdated(callback) {
|
|
454
|
-
this
|
|
421
|
+
this.#hostUpdated.push(callback);
|
|
455
422
|
}
|
|
456
423
|
onDestroy(callback) {
|
|
457
424
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
458
|
-
this
|
|
425
|
+
this.#component.manager.devOnly$ensureHasDestroy?.();
|
|
459
426
|
}
|
|
460
|
-
this
|
|
427
|
+
this.#hostDestroy.push(callback);
|
|
461
428
|
}
|
|
462
429
|
onLifecycle(callback) {
|
|
463
|
-
this
|
|
464
|
-
if (this.connectedCalled && this
|
|
465
|
-
this
|
|
430
|
+
this.#hostLifecycle.push(callback);
|
|
431
|
+
if (this.connectedCalled && this.#component.el.isConnected) {
|
|
432
|
+
this.#callLifecycle(callback);
|
|
466
433
|
}
|
|
467
434
|
}
|
|
468
435
|
// Call each lifecycle hook
|
|
469
436
|
/** @private */
|
|
470
437
|
triggerConnected() {
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
safeCall(
|
|
438
|
+
const that = this;
|
|
439
|
+
if (that.hostConnected) {
|
|
440
|
+
safeCall(that.hostConnected, that);
|
|
474
441
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
442
|
+
that.#hostConnected.forEach(safeCall);
|
|
443
|
+
that.triggerLifecycle();
|
|
444
|
+
that.connectedCalled = true;
|
|
478
445
|
}
|
|
479
446
|
/** @private */
|
|
480
447
|
triggerDisconnected() {
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
safeCall(
|
|
448
|
+
const that = this;
|
|
449
|
+
if (that.hostDisconnected) {
|
|
450
|
+
safeCall(that.hostDisconnected, that);
|
|
484
451
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
452
|
+
that.#hostDisconnected.forEach(safeCall);
|
|
453
|
+
that.#lifecycleCleanups.forEach(safeCall);
|
|
454
|
+
that.#lifecycleCleanups = [];
|
|
488
455
|
}
|
|
489
456
|
/** @private */
|
|
490
457
|
async triggerLoad() {
|
|
491
|
-
if (this
|
|
458
|
+
if (this.#loadCalled) {
|
|
492
459
|
return;
|
|
493
460
|
}
|
|
494
|
-
this
|
|
461
|
+
this.#loadCalled = true;
|
|
495
462
|
const genericController = this;
|
|
496
463
|
if (genericController.hostLoad) {
|
|
497
464
|
await safeAsyncCall(genericController.hostLoad, genericController);
|
|
498
465
|
}
|
|
499
|
-
if (this
|
|
500
|
-
await Promise.allSettled(this
|
|
466
|
+
if (this.#hostLoad.length > 0) {
|
|
467
|
+
await Promise.allSettled(this.#hostLoad.map(safeAsyncCall));
|
|
501
468
|
}
|
|
502
|
-
this.
|
|
469
|
+
this.P.resolve(this.#exports);
|
|
503
470
|
}
|
|
504
471
|
/** @private */
|
|
505
472
|
triggerLoaded() {
|
|
506
473
|
if (this.loadedCalled) {
|
|
507
474
|
return;
|
|
508
475
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
safeCall(genericController.hostLoaded, genericController);
|
|
476
|
+
if (this.hostLoaded) {
|
|
477
|
+
safeCall(this.hostLoaded, this);
|
|
512
478
|
}
|
|
513
|
-
this
|
|
479
|
+
this.#hostLoaded.forEach(safeCall);
|
|
514
480
|
this.loadedCalled = true;
|
|
515
481
|
}
|
|
516
482
|
/** @private */
|
|
517
483
|
triggerUpdate(changes) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
safeCall(genericController.hostUpdate, genericController, changes);
|
|
484
|
+
if (this.hostUpdate) {
|
|
485
|
+
safeCall(this.hostUpdate, this, changes);
|
|
521
486
|
}
|
|
522
|
-
this
|
|
487
|
+
this.#hostUpdate.forEach(callUpdate, changes);
|
|
523
488
|
}
|
|
524
489
|
/** @private */
|
|
525
490
|
triggerUpdated(changes) {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
safeCall(genericController.hostUpdated, genericController, changes);
|
|
491
|
+
if (this.hostUpdated) {
|
|
492
|
+
safeCall(this.hostUpdated, this, changes);
|
|
529
493
|
}
|
|
530
|
-
this
|
|
494
|
+
this.#hostUpdated.forEach(callUpdate, changes);
|
|
531
495
|
}
|
|
532
496
|
/** @private */
|
|
533
497
|
triggerDestroy() {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
safeCall(genericController.hostDestroy, genericController);
|
|
498
|
+
if (this.hostDestroy) {
|
|
499
|
+
safeCall(this.hostDestroy, this);
|
|
537
500
|
}
|
|
538
|
-
this
|
|
501
|
+
this.#hostDestroy.forEach(safeCall);
|
|
539
502
|
}
|
|
540
503
|
/** @private */
|
|
541
504
|
triggerLifecycle() {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
this._callLifecycle(() => genericController.hostLifecycle());
|
|
505
|
+
if (this.hostLifecycle) {
|
|
506
|
+
this.#callLifecycle(() => this.hostLifecycle());
|
|
545
507
|
}
|
|
546
|
-
this
|
|
508
|
+
this.#hostLifecycle.forEach(this.#callLifecycle, this);
|
|
547
509
|
}
|
|
548
|
-
|
|
549
|
-
setAmbientComponent(this
|
|
510
|
+
#callLifecycle(callback) {
|
|
511
|
+
setAmbientComponent(this.#component);
|
|
550
512
|
const cleanupRaw = safeCall(callback);
|
|
551
513
|
const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
|
|
552
514
|
cleanup.forEach((cleanup2) => {
|
|
553
515
|
if (typeof cleanup2 === "function") {
|
|
554
|
-
this.
|
|
516
|
+
this.#lifecycleCleanups.push(cleanup2);
|
|
555
517
|
} else if (typeof cleanup2 === "object" && typeof cleanup2.remove === "function") {
|
|
556
|
-
this.
|
|
518
|
+
this.#lifecycleCleanups.push(cleanup2.remove);
|
|
557
519
|
}
|
|
558
520
|
});
|
|
559
521
|
}
|
|
@@ -562,11 +524,11 @@ function callUpdate(callback) {
|
|
|
562
524
|
safeCall(callback, void 0, this);
|
|
563
525
|
}
|
|
564
526
|
const GenericController = Controller;
|
|
565
|
-
|
|
527
|
+
const makeProvisionalValue = (base) => {
|
|
566
528
|
if (typeof base !== "object" && typeof base !== "function" || base === null) {
|
|
567
529
|
return base;
|
|
568
530
|
}
|
|
569
|
-
const
|
|
531
|
+
const proxyDefinition = {
|
|
570
532
|
get(target, prop, receiver) {
|
|
571
533
|
if ((prop === "exports" || prop === "_exports") && prop in target && target[prop] === proxy) {
|
|
572
534
|
return void 0;
|
|
@@ -583,16 +545,17 @@ function makeProvisionalValue(base) {
|
|
|
583
545
|
);
|
|
584
546
|
}
|
|
585
547
|
return void 0;
|
|
586
|
-
},
|
|
587
|
-
set: (target, prop, newValue, receiver) => {
|
|
588
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
589
|
-
console.error(`Trying to set "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
|
|
590
|
-
}
|
|
591
|
-
return Reflect.set(target, prop, newValue, receiver);
|
|
592
548
|
}
|
|
593
|
-
}
|
|
549
|
+
};
|
|
550
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
551
|
+
proxyDefinition.set = (target, prop, newValue, receiver) => {
|
|
552
|
+
console.error(`Trying to set "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
|
|
553
|
+
return Reflect.set(target, prop, newValue, receiver);
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
const proxy = new Proxy(base, proxyDefinition);
|
|
594
557
|
return proxy;
|
|
595
|
-
}
|
|
558
|
+
};
|
|
596
559
|
const accessBeforeLoad = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? [
|
|
597
560
|
"This might be the case if you are trying to access an async controller in ",
|
|
598
561
|
"connectedCallback(). Or, if you are using it inside of ",
|
|
@@ -603,25 +566,22 @@ const accessBeforeLoad = process.env.NODE_ENV !== "production" && isEsriInternal
|
|
|
603
566
|
export {
|
|
604
567
|
Controller as C,
|
|
605
568
|
GenericController as G,
|
|
606
|
-
|
|
607
|
-
|
|
569
|
+
shouldBypassReadOnly as a,
|
|
570
|
+
createEvent as b,
|
|
608
571
|
controllerSymbol as c,
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
572
|
+
setParentController as d,
|
|
573
|
+
retrieveParentControllers as e,
|
|
574
|
+
createEventFactory as f,
|
|
575
|
+
bypassSetter as g,
|
|
576
|
+
bypassReadOnly as h,
|
|
614
577
|
isPromise as i,
|
|
615
|
-
|
|
578
|
+
trackPropertyKey as j,
|
|
616
579
|
keyTrackResolve as k,
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
devOnlySetPersistentControllerData as p,
|
|
622
|
-
devOnlyGetPersistentControllerData as q,
|
|
580
|
+
trackPropKey as l,
|
|
581
|
+
isController as m,
|
|
582
|
+
getControllersCount as n,
|
|
583
|
+
setAmbientChildController as o,
|
|
623
584
|
retrieveComponent as r,
|
|
624
585
|
setAmbientComponent as s,
|
|
625
|
-
trackKey as t
|
|
626
|
-
setAmbientChildController as u
|
|
586
|
+
trackKey as t
|
|
627
587
|
};
|