@arcgis/lumina 4.33.0-next.10 → 4.33.0-next.101

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.
Files changed (53) hide show
  1. package/dist/Controller-CZ8Djohh.js +627 -0
  2. package/dist/LitElement.d.ts +36 -29
  3. package/dist/config.js +13 -6
  4. package/dist/context.d.ts +13 -3
  5. package/dist/controllers/Controller.d.ts +153 -0
  6. package/dist/controllers/ControllerInternals.d.ts +59 -0
  7. package/dist/controllers/ControllerManager.d.ts +83 -0
  8. package/dist/controllers/accessor/index.d.ts +2 -0
  9. package/dist/controllers/accessor/index.js +259 -0
  10. package/dist/controllers/accessor/reEmitEvent.d.ts +10 -0
  11. package/dist/controllers/accessor/useAccessor.d.ts +74 -0
  12. package/dist/controllers/functional.d.ts +19 -0
  13. package/dist/controllers/index.d.ts +24 -0
  14. package/dist/controllers/index.js +263 -0
  15. package/dist/controllers/load.d.ts +6 -0
  16. package/dist/controllers/proxyExports.d.ts +27 -0
  17. package/dist/controllers/tests/autoDestroyMock.d.ts +5 -0
  18. package/dist/controllers/tests/utils.d.ts +1 -0
  19. package/dist/controllers/toFunction.d.ts +8 -0
  20. package/dist/controllers/trackKey.d.ts +8 -0
  21. package/dist/controllers/trackPropKey.d.ts +21 -0
  22. package/dist/controllers/trackPropertyKey.d.ts +29 -0
  23. package/dist/controllers/types.d.ts +152 -0
  24. package/dist/controllers/useDirection.d.ts +11 -0
  25. package/dist/controllers/useMedia.d.ts +8 -0
  26. package/dist/controllers/usePropertyChange.d.ts +12 -0
  27. package/dist/controllers/useT9n.d.ts +48 -0
  28. package/dist/controllers/useWatchAttributes.d.ts +7 -0
  29. package/dist/controllers/utils.d.ts +15 -0
  30. package/dist/createEvent.d.ts +7 -2
  31. package/dist/decorators.d.ts +2 -2
  32. package/dist/devOnlyDetectIncorrectLazyUsages.d.ts +1 -1
  33. package/dist/hmrSupport.d.ts +1 -1
  34. package/dist/hmrSupport.js +1 -7
  35. package/dist/index.d.ts +17 -16
  36. package/dist/index.js +386 -150
  37. package/dist/jsx/baseTypes.d.ts +13 -9
  38. package/dist/jsx/directives.d.ts +25 -7
  39. package/dist/jsx/generatedTypes.d.ts +6 -10
  40. package/dist/jsx/types.d.ts +5 -32
  41. package/dist/lazyLoad.d.ts +18 -18
  42. package/dist/lifecycleSupport.d.ts +1 -1
  43. package/dist/makeRuntime.d.ts +109 -0
  44. package/dist/proxyExports-CK5BLFLO.js +60 -0
  45. package/dist/render.d.ts +5 -0
  46. package/dist/runtime.d.ts +4 -107
  47. package/dist/stencilSsrCompatibility/index.d.ts +2 -6
  48. package/dist/stencilSsrCompatibility/index.js +2 -3
  49. package/dist/typings/importMeta.d.ts +2 -2
  50. package/dist/{chunk-NO7HOBNA.js → utils-DBdf1Dqp.js} +45 -61
  51. package/package.json +4 -3
  52. package/dist/chunk-PGHUBTOM.js +0 -21
  53. package/dist/wrappersUtils.test.d.ts +0 -1
package/dist/index.js CHANGED
@@ -1,13 +1,18 @@
1
- import {
2
- attachToAncestor,
3
- makeDefineCustomElements,
4
- noShadowRoot
5
- } from "./chunk-NO7HOBNA.js";
6
- import "./chunk-PGHUBTOM.js";
7
-
8
- // src/context.ts
9
- import { retrieveComponent } from "@arcgis/components-controllers";
10
- import { ContextConsumer, ContextProvider } from "@lit/context";
1
+ import { ContextProvider, ContextConsumer } from "@lit/context";
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
+ import { state } from "@lit/reactive-element/decorators/state.js";
5
+ import { property as property$1 } from "@lit/reactive-element/decorators/property.js";
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
+ import { PropertyFlags } from "./config.js";
11
+ import { classMap } from "lit-html/directives/class-map.js";
12
+ import { styleMap } from "lit/directives/style-map.js";
13
+ import { directive as directive$1, Directive } from "lit-html/directive.js";
14
+ import { live as live$1 } from "lit-html/directives/live.js";
15
+ import { nothing as nothing$2, noChange as noChange$2, render } from "lit-html";
11
16
  function useContextProvider(options) {
12
17
  const component = retrieveComponent();
13
18
  const controller = new ContextProvider(component.el, options);
@@ -20,120 +25,308 @@ function useContextConsumer(options) {
20
25
  component.addController(controller);
21
26
  return controller;
22
27
  }
23
-
24
- // src/createEvent.ts
25
- import { retrieveComponent as retrieveComponent2, keyTrackResolve, trackKey } from "@arcgis/components-controllers";
26
- import { isEsriInternalEnv } from "@arcgis/components-utils";
27
- var createEventFactory = (eventName = "", options = {}, component = retrieveComponent2()) => {
28
- const emitter = {
29
- emit: (payload) => {
30
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !component.el.isConnected) {
31
- console.warn(
32
- `Trying to emit an ${eventName} event on a disconnected element ${component.el.tagName.toLowerCase()}`
33
- );
34
- }
35
- if (eventName === "") {
28
+ const property = property$1;
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
+ }
36
61
  keyTrackResolve();
37
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && eventName === "") {
38
- throw new Error("Unable to resolve event name from property name");
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
+ }
39
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);
40
107
  }
41
- const event = new CustomEvent(eventName, {
42
- detail: payload,
43
- cancelable: true,
44
- bubbles: true,
45
- composed: true,
46
- ...options
47
- });
48
- component.el.dispatchEvent(event);
49
- return event;
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?.();
50
120
  }
51
- };
52
- if (eventName === "") {
53
- trackKey(
54
- void 0,
55
- (resolution) => {
56
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && resolution === void 0) {
57
- throw new Error(`createEvent must be called in property default value only`);
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`);
58
189
  }
59
- eventName = resolution.key;
60
- },
61
- emitter
62
- );
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 });
63
236
  }
64
- return emitter;
65
- };
66
- var createEvent = createEventFactory.bind(null, "");
67
-
68
- // src/decorators.ts
69
- import { state } from "@lit/reactive-element/decorators/state.js";
70
- import { property as litProperty } from "@lit/reactive-element/decorators/property.js";
71
- var property = litProperty;
72
- var method = void 0;
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;
73
272
 
74
- // src/LitElement.ts
75
- import { Deferred, camelToKebab, isEsriInternalEnv as isEsriInternalEnv2 } from "@arcgis/components-utils";
76
- import { LitElement as OriginalLitElement, isServer } from "lit";
77
- import { useControllerManager } from "@arcgis/components-controllers";
78
- var emptyFunction = () => void 0;
79
- var LitElement = class _LitElement extends OriginalLitElement {
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();
288
+ const emptyFunction = () => void 0;
289
+ class LitElement extends LitElement$1 {
80
290
  constructor() {
81
291
  super();
82
- /**
83
- * In lazy build, the actual DOM element differs from the class instance:
84
- * - "this.el" is a proxy custom element - it's physically present in the DOM
85
- * even before the Lit component is loaded.
86
- * - "this" is the actual Lit component - in case of Lazy builds, it's
87
- * never directly attached to the DOM. Instead, all interactions with the
88
- * proxy are forwarded to the actual Lit component. And, when Lit wants to
89
- * render, it renders into the shadow root of the proxy.
90
- *
91
- * "this.el" should be used instead of "this" for all things involving the
92
- * DOM (addEventListener, querySelector, children, setAttribute,
93
- * MutationObserver, etc...)
94
- *
95
- * @example
96
- * ```ts
97
- * // Generally, you shouldn't have to write logic specific to lazy or non-lazy
98
- * // build, but if you have to, you can detect if you are in a lazy build like so:
99
- * const isLazy = this.el !== this;
100
- * ```
101
- */
102
292
  this.el = this.constructor.lazy ?? this;
103
- /**
104
- * Controller Manager orchestrates all controllers used by this component,
105
- * connecting their lifecycle hooks and providing context information.
106
- */
107
- this.manager = useControllerManager(this);
108
- /** @internal */
293
+ this._controllers = /* @__PURE__ */ new Set();
294
+ this.manager = new ControllerManager(this);
109
295
  this._postLoad = this.constructor.lazy?._postLoad ?? new Deferred();
110
- /**
111
- * Direct offspring that should be awaited before loaded() is emitted.
112
- *
113
- * `attachToAncestor()` will add elements to this array
114
- *
115
- * @internal
116
- */
117
296
  this._offspring = this.constructor.lazy?._offspring ?? [];
118
297
  this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred();
119
298
  this._enableUpdating = this.enableUpdating;
120
299
  this.enableUpdating = emptyFunction;
121
- const ourShouldUpdate = _LitElement.prototype.shouldUpdate;
300
+ const ourShouldUpdate = LitElement.prototype.shouldUpdate;
122
301
  if (this.shouldUpdate !== ourShouldUpdate) {
123
302
  this._originalShouldUpdate = this.shouldUpdate;
124
303
  this.shouldUpdate = ourShouldUpdate;
125
304
  }
126
305
  if (process.env.NODE_ENV !== "production") {
127
- const isOwnComponent = globalThis.devOnly$ownTagNames?.has(
128
- this.el.tagName.toLowerCase()
129
- );
306
+ const isOwnComponent = globalThis.devOnly$ownTagNames?.has(this.el.localName);
130
307
  const constructor = this.constructor;
131
- const warningsWereCustomized = constructor.enabledWarnings !== OriginalLitElement.enabledWarnings;
308
+ const warningsWereCustomized = constructor.enabledWarnings !== LitElement$1.enabledWarnings;
132
309
  if (!isOwnComponent && !warningsWereCustomized) {
133
310
  constructor.disableWarning?.("change-in-update");
134
311
  }
135
- if (isEsriInternalEnv2()) {
312
+ if (isEsriInternalEnv()) {
136
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
+ });
137
330
  }
138
331
  }
139
332
  if (isServer) {
@@ -171,18 +364,18 @@ var LitElement = class _LitElement extends OriginalLitElement {
171
364
  *
172
365
  * Thus, overwriting Lit's default behavior to use kebab-case:
173
366
  */
174
- attribute: !!(flags & 1 /* ATTRIBUTE */) && typeof name === "string" ? camelToKebab(name) : false,
175
- reflect: !!(flags & 2 /* REFLECT */),
176
- type: flags & 4 /* BOOLEAN */ ? Boolean : flags & 8 /* NUMBER */ ? Number : void 0,
367
+ attribute: !!(flags & PropertyFlags.ATTRIBUTE) && typeof name === "string" ? camelToKebab(name) : false,
368
+ reflect: !!(flags & PropertyFlags.REFLECT),
369
+ type: flags & PropertyFlags.BOOLEAN ? Boolean : flags & PropertyFlags.NUMBER ? Number : void 0,
177
370
  /**
178
371
  * At the moment in Lit, state:true just means attribute:false, so this
179
372
  * line is technically redundant, but let's keep it here just in case Lit
180
373
  * will add more meaning to state:true in the future.
181
374
  */
182
- state: !!(flags & 16 /* STATE */),
375
+ state: !!(flags & PropertyFlags.STATE),
183
376
  // Controllers add this option to Lit
184
- readOnly: !!(flags & 32 /* READ_ONLY */),
185
- noAccessor: !!(flags & 64 /* NO_ACCESSOR */),
377
+ readOnly: !!(flags & PropertyFlags.READ_ONLY),
378
+ noAccessor: !!(flags & PropertyFlags.NO_ACCESSOR),
186
379
  ...rest
187
380
  });
188
381
  }
@@ -219,13 +412,9 @@ var LitElement = class _LitElement extends OriginalLitElement {
219
412
  const options = Class.shadowRootOptions;
220
413
  const useLightDom = options === noShadowRoot;
221
414
  const renderRoot = existingShadowRoot ?? (useLightDom ? this.el : this.el.attachShadow(options));
222
- Object.defineProperty(this, "shadowRoot", {
223
- // Create shadow root on the proxy instance, to make Lit render content there
224
- value: renderRoot
225
- });
226
415
  if (existingShadowRoot) {
227
416
  if (process.env.NODE_ENV === "production") {
228
- OriginalLitElement.prototype.createRenderRoot.call(this);
417
+ LitElement$1.prototype.createRenderRoot.call(this);
229
418
  }
230
419
  return existingShadowRoot;
231
420
  }
@@ -247,7 +436,21 @@ var LitElement = class _LitElement extends OriginalLitElement {
247
436
  if (parentLoadPromise) {
248
437
  await parentLoadPromise;
249
438
  }
250
- await this.manager._load();
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
+ }
251
454
  this._enableUpdating(true);
252
455
  this.performUpdate();
253
456
  this._postLoad.resolve();
@@ -258,7 +461,14 @@ var LitElement = class _LitElement extends OriginalLitElement {
258
461
  }
259
462
  this._offspring.length = 0;
260
463
  this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
261
- this.manager._loaded();
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?.();
262
472
  this._postLoaded.resolve();
263
473
  }
264
474
  /**
@@ -266,7 +476,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
266
476
  * "changedProperties" so that we can later provide it to ControllerManager
267
477
  */
268
478
  shouldUpdate(_changedProperties) {
269
- this.$changes = _changedProperties;
479
+ this.manager._changes = _changedProperties;
270
480
  return this._originalShouldUpdate?.(_changedProperties) ?? true;
271
481
  }
272
482
  listen(name, listener, options) {
@@ -297,18 +507,36 @@ var LitElement = class _LitElement extends OriginalLitElement {
297
507
  await this._postLoaded.promise;
298
508
  return this;
299
509
  }
300
- };
301
- LitElement.$createEvent = createEventFactory;
302
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv2()) {
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
+ }
532
+ }
533
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
303
534
  const globalWithLit = globalThis;
304
535
  globalWithLit.litIssuedWarnings ??= /* @__PURE__ */ new Set();
305
536
  globalWithLit.litIssuedWarnings.add(
306
537
  "Overriding ReactiveElement.createProperty() is deprecated. The override will not be called with standard decorators See https://lit.dev/msg/no-override-create-property for more information."
307
538
  );
308
539
  }
309
-
310
- // src/runtime.ts
311
- import { isEsriInternalEnv as isEsriInternalEnv3 } from "@arcgis/components-utils";
312
540
  function makeRuntime(options) {
313
541
  let assetPath;
314
542
  const setAssetPath = (path) => {
@@ -351,33 +579,35 @@ function makeRuntime(options) {
351
579
  }
352
580
  };
353
581
  setAssetPath(options.defaultAssetPath);
354
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv3()) {
582
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
355
583
  globalThis.devOnly$luminaRuntime = runtime;
356
584
  }
357
585
  return runtime;
358
586
  }
359
-
360
- // src/jsx/types.ts
361
- var Fragment = void 0;
362
- var bindAttribute = void 0;
363
- var bindBooleanAttribute = void 0;
364
- var bindProperty = void 0;
365
- var bindEvent = void 0;
366
-
367
- // src/jsx/directives.ts
368
- import { classMap } from "lit-html/directives/class-map.js";
369
- import { styleMap } from "lit/directives/style-map.js";
370
- import { directive as litDirective } from "lit-html/directive.js";
371
- import { live as litLive } from "lit-html/directives/live.js";
372
- var safeClassMap = (parameters) => typeof parameters === "object" && parameters != null ? classMap(parameters) : parameters;
373
- var safeStyleMap = (parameters) => typeof parameters === "object" && parameters != null ? styleMap(parameters) : parameters;
374
- var directive = litDirective;
375
- var live = litLive;
376
-
377
- // src/jsx/utils.ts
378
- import { noChange as litNoChange, nothing as litNothing } from "lit-html";
379
- var nothing = litNothing;
380
- var noChange = litNoChange;
587
+ const Fragment = void 0;
588
+ const bindAttribute = void 0;
589
+ const bindBooleanAttribute = void 0;
590
+ const bindProperty = void 0;
591
+ const bindEvent = void 0;
592
+ const safeClassMap = (parameters) => typeof parameters === "object" && parameters != null ? classMap(parameters) : parameters;
593
+ const safeStyleMap = (parameters) => typeof parameters === "object" && parameters != null ? styleMap(parameters) : parameters;
594
+ class DeferLoad extends Directive {
595
+ update(part) {
596
+ const tagName = part.element.localName;
597
+ if (!customElements.get(tagName)) {
598
+ void deferredLoaders.get(tagName)?.();
599
+ }
600
+ }
601
+ render() {
602
+ return noChange$1;
603
+ }
604
+ }
605
+ const deferLoad = /* @__PURE__ */ directive$1(DeferLoad)();
606
+ const deferredLoaders = /* @__PURE__ */ new Map();
607
+ const directive = directive$1;
608
+ const live = live$1;
609
+ const nothing = nothing$2;
610
+ const noChange = noChange$2;
381
611
  function setAttribute(element, attributeName, value) {
382
612
  if (value == null) {
383
613
  element.removeAttribute(attributeName);
@@ -385,13 +615,11 @@ function setAttribute(element, attributeName, value) {
385
615
  element.setAttribute(attributeName, value);
386
616
  }
387
617
  }
388
- var stringOrBoolean = {
618
+ const stringOrBoolean = {
389
619
  toAttribute: (value) => value === true ? "" : value === false ? null : value
390
620
  };
391
-
392
- // src/wrappersUtils.ts
393
- var emptyObject = {};
394
- var makeReactWrapperFactory = (react, createComponent) => (options) => {
621
+ const emptyObject = {};
622
+ const makeReactWrapperFactory = (react, createComponent) => (options) => {
395
623
  const tagName = options.tagName;
396
624
  let customElementPrototype = emptyObject;
397
625
  const elementClass = {
@@ -429,7 +657,12 @@ var makeReactWrapperFactory = (react, createComponent) => (options) => {
429
657
  customElementPrototype = void 0;
430
658
  return result;
431
659
  };
432
- var getReactWrapperOptions = (tagNameAndElement, events) => ({ tagName: tagNameAndElement, events });
660
+ const getReactWrapperOptions = (tagNameAndElement, events) => ({ tagName: tagNameAndElement, events });
661
+ function renderElement(element) {
662
+ const container = document.createElement("div");
663
+ render(element, container);
664
+ return container.firstElementChild;
665
+ }
433
666
  export {
434
667
  Fragment,
435
668
  LitElement,
@@ -437,11 +670,13 @@ export {
437
670
  bindBooleanAttribute,
438
671
  bindEvent,
439
672
  bindProperty,
440
- createEvent,
673
+ d as createEvent,
674
+ deferLoad,
675
+ deferredLoaders,
441
676
  directive,
442
677
  getReactWrapperOptions,
443
678
  live,
444
- makeDefineCustomElements,
679
+ m as makeDefineCustomElements,
445
680
  makeReactWrapperFactory,
446
681
  makeRuntime,
447
682
  method,
@@ -449,6 +684,7 @@ export {
449
684
  noShadowRoot,
450
685
  nothing,
451
686
  property,
687
+ renderElement,
452
688
  safeClassMap,
453
689
  safeStyleMap,
454
690
  setAttribute,