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