@arcgis/lumina 4.33.0-next.97 → 4.33.0-next.99
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/{useWatch-CFtSpNnN.js → Controller-CZ8Djohh.js} +70 -368
- package/dist/LitElement.d.ts +33 -25
- package/dist/context.d.ts +12 -2
- package/dist/controllers/Controller.d.ts +18 -17
- package/dist/controllers/ControllerInternals.d.ts +19 -12
- package/dist/controllers/ControllerManager.d.ts +62 -42
- package/dist/controllers/accessor/index.js +12 -60
- package/dist/controllers/accessor/reEmitEvent.d.ts +1 -5
- package/dist/controllers/accessor/useAccessor.d.ts +6 -7
- package/dist/controllers/functional.d.ts +4 -4
- package/dist/controllers/index.d.ts +6 -5
- package/dist/controllers/index.js +35 -55
- package/dist/controllers/proxyExports.d.ts +1 -1
- package/dist/controllers/trackKey.d.ts +4 -4
- package/dist/controllers/trackPropKey.d.ts +6 -6
- package/dist/controllers/trackPropertyKey.d.ts +8 -7
- package/dist/controllers/types.d.ts +15 -45
- package/dist/controllers/usePropertyChange.d.ts +4 -3
- package/dist/controllers/useT9n.d.ts +1 -1
- package/dist/createEvent.d.ts +7 -2
- package/dist/hmrSupport.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +331 -14
- package/dist/lazyLoad.d.ts +14 -14
- package/dist/proxyExports-CK5BLFLO.js +60 -0
- package/dist/{utils-GhKD5Lo-.js → utils-DBdf1Dqp.js} +4 -12
- package/package.json +2 -2
- package/dist/ControllerManager-B2comd8J.js +0 -310
- package/dist/controllers/ComponentInternals.d.ts +0 -92
- package/dist/controllers/framework.d.ts +0 -45
- package/dist/controllers/getSet.d.ts +0 -116
- package/dist/controllers/readonly.d.ts +0 -29
- package/dist/controllers/useWatch.d.ts +0 -27
- package/dist/proxyExports-Dl5CHmHQ.js +0 -150
package/dist/index.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { ContextProvider, ContextConsumer } from "@lit/context";
|
|
2
|
-
import { r as retrieveComponent } from "./
|
|
3
|
-
import {
|
|
2
|
+
import { r as retrieveComponent, G as GenericController, k as keyTrackResolve, s as setAmbientComponent, a as shouldBypassGetter, b as shouldBypassReadOnly, c as controllerSymbol } from "./Controller-CZ8Djohh.js";
|
|
3
|
+
import { d } from "./Controller-CZ8Djohh.js";
|
|
4
4
|
import { state } from "@lit/reactive-element/decorators/state.js";
|
|
5
5
|
import { property as property$1 } from "@lit/reactive-element/decorators/property.js";
|
|
6
|
-
import { n as noShadowRoot, a as attachToAncestor } from "./utils-
|
|
7
|
-
import { m } from "./utils-
|
|
8
|
-
import {
|
|
9
|
-
import { LitElement as LitElement$1, isServer, noChange as noChange$1 } from "lit";
|
|
6
|
+
import { n as noShadowRoot, a as attachToAncestor } from "./utils-DBdf1Dqp.js";
|
|
7
|
+
import { m } from "./utils-DBdf1Dqp.js";
|
|
8
|
+
import { isEsriInternalEnv, safeCall, devToolsAwareTimeout, Deferred, camelToKebab, safeAsyncCall } from "@arcgis/components-utils";
|
|
9
|
+
import { nothing as nothing$1, LitElement as LitElement$1, isServer, noChange as noChange$1 } from "lit";
|
|
10
10
|
import { PropertyFlags } from "./config.js";
|
|
11
|
-
import { u as useControllerManager } from "./ControllerManager-B2comd8J.js";
|
|
12
11
|
import { classMap } from "lit-html/directives/class-map.js";
|
|
13
12
|
import { styleMap } from "lit/directives/style-map.js";
|
|
14
13
|
import { directive as directive$1, Directive } from "lit-html/directive.js";
|
|
15
14
|
import { live as live$1 } from "lit-html/directives/live.js";
|
|
16
|
-
import { nothing as nothing$
|
|
15
|
+
import { nothing as nothing$2, noChange as noChange$2, render } from "lit-html";
|
|
17
16
|
function useContextProvider(options) {
|
|
18
17
|
const component = retrieveComponent();
|
|
19
18
|
const controller = new ContextProvider(component.el, options);
|
|
@@ -28,12 +27,271 @@ function useContextConsumer(options) {
|
|
|
28
27
|
}
|
|
29
28
|
const property = property$1;
|
|
30
29
|
const method = void 0;
|
|
30
|
+
class ControllerManager extends GenericController {
|
|
31
|
+
constructor(component) {
|
|
32
|
+
super(component);
|
|
33
|
+
this.destroyed = false;
|
|
34
|
+
this._enforceReadonly = false;
|
|
35
|
+
this._trackedValue = nothing$1;
|
|
36
|
+
this._keyTrackers = [];
|
|
37
|
+
this._accessorGetter = {};
|
|
38
|
+
this._accessorSetter = {};
|
|
39
|
+
this._exportsStore = /* @__PURE__ */ new WeakMap();
|
|
40
|
+
this.exports = void 0;
|
|
41
|
+
this.hasDestroy = autoDestroyDisabledPropName in component && typeof component.destroy === "function";
|
|
42
|
+
LitElement$1.prototype.addController.call(component, {
|
|
43
|
+
// Lit will call these callbacks
|
|
44
|
+
// We do not directly implement hostConnected and etc on ControllerManager
|
|
45
|
+
// because ControllerManager is also included in the list of controllers
|
|
46
|
+
// we manage - and for each controller we manage we call hostConnected
|
|
47
|
+
// (from inside of .triggerConnected). So there would be an infinite
|
|
48
|
+
// loop if Lit calls hostConnected which in turn calls
|
|
49
|
+
// triggerConnected which calls hostConnected again.
|
|
50
|
+
hostConnected: () => {
|
|
51
|
+
if (this.destroyed) {
|
|
52
|
+
const tagName = component.el.localName;
|
|
53
|
+
component.el.remove();
|
|
54
|
+
throw new Error(
|
|
55
|
+
`The ${tagName} component has already been destroyed. It cannot be used again. If you meant to disconnect and reconnect a component without automatic destroy, set the ${autoDestroyDisabledPropName} prop.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
if (this._autoDestroyTimeout !== void 0) {
|
|
59
|
+
clearTimeout(this._autoDestroyTimeout);
|
|
60
|
+
}
|
|
61
|
+
keyTrackResolve();
|
|
62
|
+
for (const controller of component._controllers) {
|
|
63
|
+
if ("triggerConnected" in controller) {
|
|
64
|
+
controller.triggerConnected();
|
|
65
|
+
} else {
|
|
66
|
+
safeCall(controller.hostConnected, controller);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
hostDisconnected: () => {
|
|
71
|
+
for (const controller of component._controllers) {
|
|
72
|
+
if ("triggerDisconnected" in controller) {
|
|
73
|
+
controller.triggerDisconnected();
|
|
74
|
+
} else {
|
|
75
|
+
safeCall(controller.hostDisconnected, controller);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (this.hasDestroy && !this.destroyed) {
|
|
79
|
+
this._setAutoDestroyTimeout();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
hostUpdate: () => {
|
|
83
|
+
for (const controller of component._controllers) {
|
|
84
|
+
if ("triggerUpdate" in controller) {
|
|
85
|
+
controller.triggerUpdate(this._changes);
|
|
86
|
+
} else {
|
|
87
|
+
safeCall(controller.hostUpdate, controller, this._changes);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
hostUpdated: () => {
|
|
92
|
+
for (const controller of component._controllers) {
|
|
93
|
+
if ("triggerUpdated" in controller) {
|
|
94
|
+
controller.triggerUpdated(this._changes);
|
|
95
|
+
} else {
|
|
96
|
+
safeCall(controller.hostUpdated, controller, this._changes);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this._changes = void 0;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
component.constructor.elementProperties.forEach((descriptor, name) => {
|
|
103
|
+
if (!descriptor.noAccessor) {
|
|
104
|
+
this._accessorGetter[name] = defaultGetterSetter;
|
|
105
|
+
this._accessorSetter[name] = defaultGetterSetter;
|
|
106
|
+
this._getSetProxy(name, descriptor.readOnly);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
queueMicrotask(() => {
|
|
110
|
+
this._enforceReadonly = true;
|
|
111
|
+
});
|
|
112
|
+
setAmbientComponent(component);
|
|
113
|
+
}
|
|
114
|
+
// Keep this method async needlessly for now to avoid a breaking change if we
|
|
115
|
+
// would need to make it async in the future
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
117
|
+
async destroy() {
|
|
118
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
119
|
+
this._ensureHasDestroy?.();
|
|
120
|
+
}
|
|
121
|
+
if (this.destroyed) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (this.component.el.isConnected) {
|
|
125
|
+
this.hasDestroy = false;
|
|
126
|
+
try {
|
|
127
|
+
this.component.el.remove();
|
|
128
|
+
} finally {
|
|
129
|
+
this.hasDestroy = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this._autoDestroyTimeout = void 0;
|
|
133
|
+
this.destroyed = true;
|
|
134
|
+
for (const controller of this.component._controllers) {
|
|
135
|
+
if ("triggerDestroy" in controller) {
|
|
136
|
+
controller.triggerDestroy();
|
|
137
|
+
} else {
|
|
138
|
+
safeCall(controller.hostDestroy, controller);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
this.component._controllers.clear();
|
|
142
|
+
}
|
|
143
|
+
/** @private */
|
|
144
|
+
_setAutoDestroyTimeout() {
|
|
145
|
+
if (this._autoDestroyTimeout !== void 0) {
|
|
146
|
+
clearTimeout(this._autoDestroyTimeout);
|
|
147
|
+
}
|
|
148
|
+
if (!this.component.el.isConnected && !this.component.autoDestroyDisabled) {
|
|
149
|
+
const destroy = () => void this.component.destroy();
|
|
150
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && autoDestroyOnDisconnectTimeout === 0) ;
|
|
151
|
+
else {
|
|
152
|
+
this._autoDestroyTimeout = devToolsAwareTimeout(destroy, autoDestroyOnDisconnectTimeout);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** @private */
|
|
157
|
+
_firePropTrackers(key, value) {
|
|
158
|
+
const trackers = this._keyTrackers;
|
|
159
|
+
this._trackedValue = nothing$1;
|
|
160
|
+
this._keyTrackers = [];
|
|
161
|
+
trackers.forEach((tracker) => tracker(key, value));
|
|
162
|
+
}
|
|
163
|
+
// REFACTOR: once Stencil is no longer supported, simplify this with Lit's getPropertyDescriptor(), or https://github.com/shoelace-style/shoelace/issues/1990
|
|
164
|
+
/**
|
|
165
|
+
* Configure a getter or setter for a given \@property/\@state
|
|
166
|
+
*
|
|
167
|
+
* Since props are defined on the prototype, they are shared between all
|
|
168
|
+
* instances of a component. Thus, instead of passing a reference to the
|
|
169
|
+
* getter/setter function, you should update the
|
|
170
|
+
* ComponentInternals.getters/setters properties, and then call getSetProxy
|
|
171
|
+
* to apply the changes to the prototype
|
|
172
|
+
*
|
|
173
|
+
* @deprecated
|
|
174
|
+
*/
|
|
175
|
+
_getSetProxy(name, isReadOnly) {
|
|
176
|
+
let prototype = this.component.constructor.prototype;
|
|
177
|
+
let descriptor;
|
|
178
|
+
do {
|
|
179
|
+
descriptor = Object.getOwnPropertyDescriptor(prototype, name);
|
|
180
|
+
} while (!descriptor && (prototype = Object.getPrototypeOf(prototype)));
|
|
181
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
182
|
+
if (descriptor?.set === void 0 || descriptor.get === void 0) {
|
|
183
|
+
if (descriptor !== void 0 && "value" in descriptor) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`getSet() should only be used on @property/@state properties. For internal component properties, use regular get/set syntax. Tried to use it on "${name}" in ${this.component.el.localName}`
|
|
186
|
+
);
|
|
187
|
+
} else {
|
|
188
|
+
throw new Error(`Unable to find "${name}" property on the ${this.component.el.localName} component`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
} else if (!descriptor) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const originalGet = descriptor.get;
|
|
195
|
+
const originalSet = descriptor.set;
|
|
196
|
+
const isGetterAlreadyOverwritten = customAccessor in originalGet;
|
|
197
|
+
const isSetterAlreadyOverwritten = customAccessor in originalSet;
|
|
198
|
+
if (isGetterAlreadyOverwritten && isSetterAlreadyOverwritten) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const shouldOverwriteGet = !isGetterAlreadyOverwritten;
|
|
202
|
+
const shouldOverwriteSet = !isSetterAlreadyOverwritten;
|
|
203
|
+
const finalGetter = shouldOverwriteGet ? function getter() {
|
|
204
|
+
const value = originalGet.call(this);
|
|
205
|
+
if (shouldBypassGetter) {
|
|
206
|
+
return value;
|
|
207
|
+
}
|
|
208
|
+
return this.manager._accessorGetter[name](value, name);
|
|
209
|
+
} : originalGet;
|
|
210
|
+
const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
|
|
211
|
+
const oldValue = originalGet.call(this);
|
|
212
|
+
let newValue = rawNewValue ?? void 0;
|
|
213
|
+
const manager = this.manager;
|
|
214
|
+
if (newValue !== oldValue) {
|
|
215
|
+
if (isReadOnly && !shouldBypassReadOnly && (manager._enforceReadonly || manager.connectedCalled)) {
|
|
216
|
+
throw new Error(
|
|
217
|
+
`Cannot assign to read-only property "${name}" of ${this.el.localName}. Trying to assign "${String(
|
|
218
|
+
newValue
|
|
219
|
+
)}"`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
newValue = manager._accessorSetter[name](newValue, oldValue, name);
|
|
223
|
+
}
|
|
224
|
+
originalSet.call(this, newValue);
|
|
225
|
+
if (manager._keyTrackers.length > 0) {
|
|
226
|
+
manager?._firePropTrackers(name, rawNewValue);
|
|
227
|
+
}
|
|
228
|
+
} : originalSet;
|
|
229
|
+
if (shouldOverwriteGet) {
|
|
230
|
+
finalGetter[customAccessor] = true;
|
|
231
|
+
}
|
|
232
|
+
if (shouldOverwriteSet) {
|
|
233
|
+
finalSetter[customAccessor] = true;
|
|
234
|
+
}
|
|
235
|
+
Object.defineProperty(prototype, name, { ...descriptor, get: finalGetter, set: finalSetter });
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Associate an exports object with a controller for reverse lookup in
|
|
239
|
+
* controller.use
|
|
240
|
+
*
|
|
241
|
+
* @private
|
|
242
|
+
*/
|
|
243
|
+
_markExports(controller, exports) {
|
|
244
|
+
if (typeof exports === "object" && exports !== null || typeof exports === "function") {
|
|
245
|
+
this._exportsStore.set(exports, controller);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/** @private */
|
|
249
|
+
_resolveExports(exports) {
|
|
250
|
+
if (typeof exports === "object" && exports !== null || typeof exports === "function") {
|
|
251
|
+
return this._exportsStore.get(exports);
|
|
252
|
+
} else {
|
|
253
|
+
return void 0;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
258
|
+
ControllerManager.prototype._ensureHasDestroy = function ensureHasDestroy() {
|
|
259
|
+
if (!this.hasDestroy) {
|
|
260
|
+
throw new Error(
|
|
261
|
+
`
|
|
262
|
+
If the component uses a controller that uses destroy() method, then the
|
|
263
|
+
component must have the following properties:
|
|
264
|
+
/**
|
|
265
|
+
* If true, the component will not be destroyed automatically when it is
|
|
266
|
+
* disconnected from the document. This is useful when you want to move the
|
|
267
|
+
* component to a different place on the page, or temporarily hide it. If this
|
|
268
|
+
* is set, make sure to call the \`destroy\` method when you are done to prevent
|
|
269
|
+
* memory leaks.
|
|
270
|
+
*/
|
|
271
|
+
@property() ${autoDestroyDisabledPropName} = false;
|
|
272
|
+
|
|
273
|
+
/** Permanently destroy the component */
|
|
274
|
+
@method()
|
|
275
|
+
async destroy(): Promise<void> {
|
|
276
|
+
await this.manager.destroy();
|
|
277
|
+
}
|
|
278
|
+
`.trim().split("\n").map((line) => line.trim()).join("\n")
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
let autoDestroyOnDisconnectTimeout = 1e3;
|
|
284
|
+
const autoDestroyDisabledPropName = "autoDestroyDisabled";
|
|
285
|
+
process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? {} : void 0;
|
|
286
|
+
const defaultGetterSetter = (value) => value;
|
|
287
|
+
const customAccessor = Symbol();
|
|
31
288
|
const emptyFunction = () => void 0;
|
|
32
289
|
class LitElement extends LitElement$1 {
|
|
33
290
|
constructor() {
|
|
34
291
|
super();
|
|
35
292
|
this.el = this.constructor.lazy ?? this;
|
|
36
|
-
this.
|
|
293
|
+
this._controllers = /* @__PURE__ */ new Set();
|
|
294
|
+
this.manager = new ControllerManager(this);
|
|
37
295
|
this._postLoad = this.constructor.lazy?._postLoad ?? new Deferred();
|
|
38
296
|
this._offspring = this.constructor.lazy?._offspring ?? [];
|
|
39
297
|
this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred();
|
|
@@ -53,6 +311,22 @@ class LitElement extends LitElement$1 {
|
|
|
53
311
|
}
|
|
54
312
|
if (isEsriInternalEnv()) {
|
|
55
313
|
globalThis.devOnly$luminaComponentRefCallback?.(this);
|
|
314
|
+
const stencilToLitMapping = {
|
|
315
|
+
componentDidLoad: "loaded",
|
|
316
|
+
componentDidRender: "updated",
|
|
317
|
+
componentDidUpdate: "updated",
|
|
318
|
+
componentShouldUpdate: "shouldUpdate",
|
|
319
|
+
componentWillLoad: "load",
|
|
320
|
+
componentWillRender: "willUpdate",
|
|
321
|
+
componentWillUpdate: "willUpdate"
|
|
322
|
+
};
|
|
323
|
+
Object.entries(stencilToLitMapping).forEach(([stencilMethod, litMethod]) => {
|
|
324
|
+
if (stencilMethod in this) {
|
|
325
|
+
throw new Error(
|
|
326
|
+
`Unexpected ${stencilMethod}() in a Lit component ${this.el.localName}. In Lit, you should use ${litMethod}() instead`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
56
330
|
}
|
|
57
331
|
}
|
|
58
332
|
if (isServer) {
|
|
@@ -162,7 +436,21 @@ class LitElement extends LitElement$1 {
|
|
|
162
436
|
if (parentLoadPromise) {
|
|
163
437
|
await parentLoadPromise;
|
|
164
438
|
}
|
|
165
|
-
|
|
439
|
+
const promises = [];
|
|
440
|
+
for (const controller of this._controllers) {
|
|
441
|
+
if ("triggerLoad" in controller) {
|
|
442
|
+
promises.push(controller.triggerLoad());
|
|
443
|
+
} else {
|
|
444
|
+
promises.push(safeAsyncCall(controller.hostLoad, controller));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
await Promise.all(promises);
|
|
448
|
+
await this.load?.();
|
|
449
|
+
if (this.manager.hasDestroy) {
|
|
450
|
+
this.manager.onUpdate(
|
|
451
|
+
(changes) => changes.has(autoDestroyDisabledPropName) && this.manager._setAutoDestroyTimeout()
|
|
452
|
+
);
|
|
453
|
+
}
|
|
166
454
|
this._enableUpdating(true);
|
|
167
455
|
this.performUpdate();
|
|
168
456
|
this._postLoad.resolve();
|
|
@@ -173,7 +461,14 @@ class LitElement extends LitElement$1 {
|
|
|
173
461
|
}
|
|
174
462
|
this._offspring.length = 0;
|
|
175
463
|
this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
|
|
176
|
-
this.
|
|
464
|
+
for (const controller of this._controllers) {
|
|
465
|
+
if ("triggerLoaded" in controller) {
|
|
466
|
+
controller.triggerLoaded();
|
|
467
|
+
} else {
|
|
468
|
+
safeCall(controller.hostLoaded, controller);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
this.loaded?.();
|
|
177
472
|
this._postLoaded.resolve();
|
|
178
473
|
}
|
|
179
474
|
/**
|
|
@@ -181,7 +476,7 @@ class LitElement extends LitElement$1 {
|
|
|
181
476
|
* "changedProperties" so that we can later provide it to ControllerManager
|
|
182
477
|
*/
|
|
183
478
|
shouldUpdate(_changedProperties) {
|
|
184
|
-
this
|
|
479
|
+
this.manager._changes = _changedProperties;
|
|
185
480
|
return this._originalShouldUpdate?.(_changedProperties) ?? true;
|
|
186
481
|
}
|
|
187
482
|
listen(name, listener, options) {
|
|
@@ -212,6 +507,28 @@ class LitElement extends LitElement$1 {
|
|
|
212
507
|
await this._postLoaded.promise;
|
|
213
508
|
return this;
|
|
214
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* Adds a controller to the host, which connects the controller's lifecycle
|
|
512
|
+
* methods to the host's lifecycle.
|
|
513
|
+
*
|
|
514
|
+
* @remarks
|
|
515
|
+
* Even though Lit's LitElement already has addController,
|
|
516
|
+
* we overwrite it with a compatible version to have more control over
|
|
517
|
+
* timing, and to add support for load/loaded lifecycle hooks.
|
|
518
|
+
*/
|
|
519
|
+
addController(controller) {
|
|
520
|
+
this._controllers.add(controller);
|
|
521
|
+
if (!(controllerSymbol in controller) && this.renderRoot && this.el.isConnected) {
|
|
522
|
+
controller.hostConnected?.();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Removes a controller from the host.
|
|
527
|
+
*/
|
|
528
|
+
removeController(controller) {
|
|
529
|
+
this._controllers.delete(controller);
|
|
530
|
+
controller.controllerRemoved?.();
|
|
531
|
+
}
|
|
215
532
|
}
|
|
216
533
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
217
534
|
const globalWithLit = globalThis;
|
|
@@ -289,7 +606,7 @@ const deferLoad = /* @__PURE__ */ directive$1(DeferLoad)();
|
|
|
289
606
|
const deferredLoaders = /* @__PURE__ */ new Map();
|
|
290
607
|
const directive = directive$1;
|
|
291
608
|
const live = live$1;
|
|
292
|
-
const nothing = nothing$
|
|
609
|
+
const nothing = nothing$2;
|
|
293
610
|
const noChange = noChange$2;
|
|
294
611
|
function setAttribute(element, attributeName, value) {
|
|
295
612
|
if (value == null) {
|
|
@@ -353,7 +670,7 @@ export {
|
|
|
353
670
|
bindBooleanAttribute,
|
|
354
671
|
bindEvent,
|
|
355
672
|
bindProperty,
|
|
356
|
-
|
|
673
|
+
d as createEvent,
|
|
357
674
|
deferLoad,
|
|
358
675
|
deferredLoaders,
|
|
359
676
|
directive,
|
package/dist/lazyLoad.d.ts
CHANGED
|
@@ -47,32 +47,32 @@ declare const HtmlElement: {
|
|
|
47
47
|
* component, so as to have identical DOM structure for lazy vs non-lazy builds
|
|
48
48
|
* (otherwise, css selectors may break)
|
|
49
49
|
*
|
|
50
|
-
* @
|
|
50
|
+
* @private
|
|
51
51
|
*/
|
|
52
52
|
export declare abstract class ProxyComponent extends HtmlElement {
|
|
53
53
|
static observedAttributes?: readonly string[];
|
|
54
|
-
/** @
|
|
54
|
+
/** @private */
|
|
55
55
|
static _loadPromise: Promise<Record<string, typeof LitElement>> | undefined;
|
|
56
|
-
/**
|
|
56
|
+
/** private */
|
|
57
57
|
static _LitConstructor?: typeof LitElement;
|
|
58
58
|
/**
|
|
59
59
|
* A list of instances of this component. This allows hot module replacement
|
|
60
60
|
* to update all proxy component to use a new LitElement instance.
|
|
61
61
|
*
|
|
62
|
-
*
|
|
62
|
+
* private
|
|
63
63
|
*/
|
|
64
64
|
static _hmrInstances: WeakRef<ProxyComponent>[] | undefined;
|
|
65
|
-
/**
|
|
65
|
+
/** private */
|
|
66
66
|
static _hmrIndex: number | undefined;
|
|
67
|
-
/**
|
|
67
|
+
/** private */
|
|
68
68
|
static _properties?: readonly string[];
|
|
69
|
-
/**
|
|
69
|
+
/** private */
|
|
70
70
|
static _asyncMethods?: readonly string[];
|
|
71
|
-
/**
|
|
71
|
+
/** private */
|
|
72
72
|
static _syncMethods?: readonly string[];
|
|
73
73
|
protected static _name: string;
|
|
74
74
|
static readonly lumina = true;
|
|
75
|
-
/**
|
|
75
|
+
/** private */
|
|
76
76
|
static _initializePrototype(): void;
|
|
77
77
|
private static _bindProp;
|
|
78
78
|
private static _bindAsync;
|
|
@@ -81,14 +81,14 @@ export declare abstract class ProxyComponent extends HtmlElement {
|
|
|
81
81
|
* On HMR, preserve the values of all properties that at least once were set
|
|
82
82
|
* by someone other than component itself.
|
|
83
83
|
*
|
|
84
|
-
*
|
|
84
|
+
* private
|
|
85
85
|
*/
|
|
86
86
|
_hmrSetProps: Set<PropertyKey>;
|
|
87
|
-
/**
|
|
87
|
+
/** private */
|
|
88
88
|
_hmrSetAttributes: Set<string>;
|
|
89
|
-
/**
|
|
89
|
+
/** private */
|
|
90
90
|
_litElement: LitElement | undefined;
|
|
91
|
-
/**
|
|
91
|
+
/** private */
|
|
92
92
|
_store: LitElement | Record<string, unknown>;
|
|
93
93
|
/**
|
|
94
94
|
* If attributeChangedCallback() is called before the LitElement is loaded,
|
|
@@ -153,7 +153,7 @@ export declare abstract class ProxyComponent extends HtmlElement {
|
|
|
153
153
|
* Create a promise that resolves once component is fully loaded
|
|
154
154
|
*/
|
|
155
155
|
componentOnReady(): Promise<this>;
|
|
156
|
-
/**
|
|
156
|
+
/** private */
|
|
157
157
|
_initializeComponent(module: Record<string, typeof LitElement>): void;
|
|
158
158
|
/**
|
|
159
159
|
* Implemented on the proxy for compatibility with Lit Context.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { e as setParentController, f as retrieveParentControllers, u as setAmbientChildController, t as trackKey, l as bypassReadOnly } from "./Controller-CZ8Djohh.js";
|
|
2
|
+
const proxyExports = (Class) => (...args) => {
|
|
3
|
+
const ambientControllers = retrieveParentControllers();
|
|
4
|
+
const instance = new Class(...args);
|
|
5
|
+
const initialExports = instance.exports;
|
|
6
|
+
setParentController(ambientControllers.at(-1));
|
|
7
|
+
const manager = instance.component.manager;
|
|
8
|
+
manager._markExports(instance, initialExports);
|
|
9
|
+
instance.watchExports((exports) => manager._markExports(instance, exports));
|
|
10
|
+
setAmbientChildController(instance);
|
|
11
|
+
const hostCandidates = [instance.component, ...ambientControllers].reverse();
|
|
12
|
+
return trackKey(
|
|
13
|
+
hostCandidates,
|
|
14
|
+
(resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution, initialExports),
|
|
15
|
+
initialExports
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
function setProxy(controller, { host, key, isReactive: assignedToProp }, initialExports) {
|
|
19
|
+
const genericHost = host;
|
|
20
|
+
const controllerValueChanged = genericHost[key] !== controller.exports;
|
|
21
|
+
const hostValueChanged = genericHost[key] !== initialExports;
|
|
22
|
+
const controllerUpdatedExports = initialExports !== controller.exports;
|
|
23
|
+
if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports) {
|
|
24
|
+
genericHost[key] = controller.exports;
|
|
25
|
+
}
|
|
26
|
+
const isProxyExportsOnComponent = host === controller.component;
|
|
27
|
+
if (isProxyExportsOnComponent) {
|
|
28
|
+
if (assignedToProp) {
|
|
29
|
+
const manager = controller.component.manager;
|
|
30
|
+
if (hostValueChanged) {
|
|
31
|
+
manager._markExports(controller, genericHost[key]);
|
|
32
|
+
}
|
|
33
|
+
controller.onUpdate((changes) => {
|
|
34
|
+
if (changes.has(key)) {
|
|
35
|
+
const value = genericHost[key];
|
|
36
|
+
if (value !== controller.exports) {
|
|
37
|
+
manager._markExports(controller, value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
controller.assignedProperty = assignedToProp ? void 0 : key;
|
|
43
|
+
}
|
|
44
|
+
const isReadOnly = controller.component.constructor.elementProperties.get(key)?.readOnly;
|
|
45
|
+
controller.watchExports(() => {
|
|
46
|
+
if (genericHost[key] === controller.exports) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (isReadOnly) {
|
|
50
|
+
bypassReadOnly(() => {
|
|
51
|
+
genericHost[key] = controller.exports;
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
genericHost[key] = controller.exports;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
proxyExports as p
|
|
60
|
+
};
|
|
@@ -163,17 +163,13 @@ class ProxyComponent extends HtmlElement {
|
|
|
163
163
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
164
164
|
ProxyClass._hmrInstances ??= [];
|
|
165
165
|
ProxyClass._hmrInstances.push(new WeakRef(this));
|
|
166
|
-
Object.defineProperty(this, "_store", {
|
|
167
|
-
value: this._store,
|
|
168
|
-
enumerable: false,
|
|
169
|
-
configurable: true
|
|
170
|
-
});
|
|
166
|
+
Object.defineProperty(this, "_store", { value: this._store, enumerable: false, configurable: true });
|
|
171
167
|
}
|
|
172
168
|
}
|
|
173
169
|
static {
|
|
174
170
|
this.lumina = true;
|
|
175
171
|
}
|
|
176
|
-
/**
|
|
172
|
+
/** private */
|
|
177
173
|
static _initializePrototype() {
|
|
178
174
|
this._properties?.forEach(this._bindProp, this);
|
|
179
175
|
this._asyncMethods?.forEach(this._bindAsync, this);
|
|
@@ -293,7 +289,7 @@ class ProxyComponent extends HtmlElement {
|
|
|
293
289
|
await this._postLoaded.promise;
|
|
294
290
|
return this;
|
|
295
291
|
}
|
|
296
|
-
/**
|
|
292
|
+
/** private */
|
|
297
293
|
_initializeComponent(module) {
|
|
298
294
|
const ProxyClass = this.constructor;
|
|
299
295
|
const tagName = ProxyClass._name;
|
|
@@ -321,11 +317,7 @@ class ProxyComponent extends HtmlElement {
|
|
|
321
317
|
const litElement = document.createElement(lazyTagName);
|
|
322
318
|
LitConstructor.lazy = void 0;
|
|
323
319
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
324
|
-
Object.defineProperty(this, "_litElement", {
|
|
325
|
-
value: litElement,
|
|
326
|
-
configurable: true,
|
|
327
|
-
enumerable: false
|
|
328
|
-
});
|
|
320
|
+
Object.defineProperty(this, "_litElement", { value: litElement, configurable: true, enumerable: false });
|
|
329
321
|
} else {
|
|
330
322
|
this._litElement = litElement;
|
|
331
323
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/lumina",
|
|
3
|
-
"version": "4.33.0-next.
|
|
3
|
+
"version": "4.33.0-next.99",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@arcgis/components-utils": "4.33.0-next.
|
|
25
|
+
"@arcgis/components-utils": "4.33.0-next.99",
|
|
26
26
|
"@lit-labs/ssr": "^3.2.2",
|
|
27
27
|
"@lit-labs/ssr-client": "^1.1.7",
|
|
28
28
|
"@lit/context": "^1.1.3",
|