@arcgis/lumina 4.33.0-next.13 → 4.33.0-next.132

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 (57) hide show
  1. package/dist/Controller-BQOv8BAL.js +587 -0
  2. package/dist/LitElement.d.ts +56 -45
  3. package/dist/config.d.ts +7 -9
  4. package/dist/config.js +18 -8
  5. package/dist/context.d.ts +14 -4
  6. package/dist/controllers/Controller.d.ts +147 -0
  7. package/dist/controllers/ControllerInternals.d.ts +53 -0
  8. package/dist/controllers/ControllerManager.d.ts +87 -0
  9. package/dist/controllers/accessor/index.d.ts +2 -0
  10. package/dist/controllers/accessor/index.js +225 -0
  11. package/dist/controllers/accessor/reEmitEvent.d.ts +10 -0
  12. package/dist/controllers/accessor/useAccessor.d.ts +71 -0
  13. package/dist/controllers/functional.d.ts +19 -0
  14. package/dist/controllers/index.d.ts +24 -0
  15. package/dist/controllers/index.js +270 -0
  16. package/dist/controllers/load.d.ts +6 -0
  17. package/dist/controllers/proxyExports.d.ts +27 -0
  18. package/dist/controllers/tests/autoDestroyMock.d.ts +5 -0
  19. package/dist/controllers/tests/utils.d.ts +1 -0
  20. package/dist/controllers/toFunction.d.ts +8 -0
  21. package/dist/controllers/trackKey.d.ts +8 -0
  22. package/dist/controllers/trackPropKey.d.ts +21 -0
  23. package/dist/controllers/trackPropertyKey.d.ts +29 -0
  24. package/dist/controllers/types.d.ts +187 -0
  25. package/dist/controllers/useDirection.d.ts +11 -0
  26. package/dist/controllers/useMedia.d.ts +8 -0
  27. package/dist/controllers/usePropertyChange.d.ts +14 -0
  28. package/dist/controllers/useT9n.d.ts +48 -0
  29. package/dist/controllers/useWatchAttributes.d.ts +7 -0
  30. package/dist/controllers/utils.d.ts +12 -0
  31. package/dist/createEvent.d.ts +8 -3
  32. package/dist/decorators.d.ts +2 -2
  33. package/dist/devOnlyDetectIncorrectLazyUsages.d.ts +1 -1
  34. package/dist/hmrSupport.d.ts +1 -1
  35. package/dist/hmrSupport.js +22 -28
  36. package/dist/index.d.ts +17 -16
  37. package/dist/index.js +415 -192
  38. package/dist/jsx/baseTypes.d.ts +13 -9
  39. package/dist/jsx/directives.d.ts +25 -7
  40. package/dist/jsx/generatedTypes.d.ts +420 -90
  41. package/dist/jsx/types.d.ts +5 -32
  42. package/dist/lazyLoad-ByH-FaBP.js +403 -0
  43. package/dist/lazyLoad.d.ts +27 -72
  44. package/dist/lifecycleSupport.d.ts +2 -2
  45. package/dist/makeRuntime.d.ts +131 -0
  46. package/dist/proxyExports-Cdzj7WL_.js +60 -0
  47. package/dist/render.d.ts +5 -0
  48. package/dist/runtime.d.ts +4 -107
  49. package/dist/stencilSsrCompatibility/index.d.ts +2 -6
  50. package/dist/stencilSsrCompatibility/index.js +2 -3
  51. package/dist/typings/importMeta.d.ts +2 -2
  52. package/dist/utils.d.ts +8 -0
  53. package/dist/wrappersUtils.d.ts +13 -1
  54. package/package.json +7 -6
  55. package/dist/chunk-NO7HOBNA.js +0 -421
  56. package/dist/chunk-PGHUBTOM.js +0 -21
  57. package/dist/wrappersUtils.test.d.ts +0 -1
package/dist/index.js CHANGED
@@ -1,143 +1,258 @@
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";
11
- function useContextProvider(options) {
1
+ import { ContextProvider, ContextConsumer } from "@lit/context";
2
+ import { r as retrieveComponent, G as GenericController, k as keyTrackResolve, s as setAmbientComponent, c as controllerSymbol, a as shouldBypassReadOnly } from "./Controller-BQOv8BAL.js";
3
+ import { b } from "./Controller-BQOv8BAL.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 { e as emptyFunction, n as noShadowRoot, a as attachToAncestor } from "./lazyLoad-ByH-FaBP.js";
7
+ import { d, m } from "./lazyLoad-ByH-FaBP.js";
8
+ import { isEsriInternalEnv, safeCall, devToolsAwareTimeout, Deferred, camelToKebab, safeAsyncCall } from "@arcgis/components-utils";
9
+ import { nothing as nothing$1, LitElement as LitElement$1, isServer, notEqual, noChange as noChange$1 } from "lit";
10
+ import { propertyFlagAttribute, propertyFlagNoAccessor, propertyFlagReadOnly, propertyFlagState, propertyFlagBoolean, propertyFlagNumber, propertyFlagReflect } 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";
16
+ const useContextProvider = (options) => {
12
17
  const component = retrieveComponent();
13
18
  const controller = new ContextProvider(component.el, options);
14
19
  component.addController(controller);
15
20
  return controller;
16
- }
17
- function useContextConsumer(options) {
21
+ };
22
+ const useContextConsumer = (options) => {
18
23
  const component = retrieveComponent();
19
24
  const controller = new ContextConsumer(component.el, options);
20
25
  component.addController(controller);
21
26
  return controller;
22
- }
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 === "") {
27
+ };
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.R = false;
35
+ this.V = nothing$1;
36
+ this.T = [];
37
+ this.#exportsStore = /* @__PURE__ */ new WeakMap();
38
+ this.#component = component;
39
+ this.exports = void 0;
40
+ this.hasDestroy = autoDestroyDisabledPropName in component && typeof component.destroy === "function";
41
+ LitElement$1.prototype.addController.call(component, {
42
+ // Lit will call these callbacks
43
+ // We do not directly implement hostConnected and etc on ControllerManager
44
+ // because ControllerManager is also included in the list of controllers
45
+ // we manage - and for each controller we manage we call hostConnected
46
+ // (from inside of .triggerConnected). So there would be an infinite
47
+ // loop if Lit calls hostConnected which in turn calls
48
+ // triggerConnected which calls hostConnected again.
49
+ hostConnected: () => {
50
+ if (this.destroyed) {
51
+ const tagName = component.el.localName;
52
+ component.el.remove();
53
+ throw new Error(
54
+ `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.`
55
+ );
56
+ }
57
+ if (this.#autoDestroyTimeout !== void 0) {
58
+ clearTimeout(this.#autoDestroyTimeout);
59
+ }
36
60
  keyTrackResolve();
37
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && eventName === "") {
38
- throw new Error("Unable to resolve event name from property name");
61
+ for (const controller of component.M) {
62
+ if ("triggerConnected" in controller) {
63
+ controller.triggerConnected();
64
+ } else {
65
+ safeCall(controller.hostConnected, controller);
66
+ }
39
67
  }
40
- }
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;
50
- }
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`);
68
+ },
69
+ hostDisconnected: () => {
70
+ for (const controller of component.M) {
71
+ if ("triggerDisconnected" in controller) {
72
+ controller.triggerDisconnected();
73
+ } else {
74
+ safeCall(controller.hostDisconnected, controller);
75
+ }
76
+ }
77
+ if (this.hasDestroy && !this.destroyed) {
78
+ this.U();
58
79
  }
59
- eventName = resolution.key;
60
80
  },
61
- emitter
62
- );
81
+ hostUpdate: () => {
82
+ for (const controller of component.M) {
83
+ if ("triggerUpdate" in controller) {
84
+ controller.triggerUpdate(this.Q);
85
+ } else {
86
+ safeCall(controller.hostUpdate, controller, this.Q);
87
+ }
88
+ }
89
+ },
90
+ hostUpdated: () => {
91
+ for (const controller of component.M) {
92
+ if ("triggerUpdated" in controller) {
93
+ controller.triggerUpdated(this.Q);
94
+ } else {
95
+ safeCall(controller.hostUpdated, controller, this.Q);
96
+ }
97
+ }
98
+ this.Q = void 0;
99
+ }
100
+ });
101
+ queueMicrotask(() => this.R = true);
102
+ setAmbientComponent(component);
63
103
  }
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;
104
+ #autoDestroyTimeout;
105
+ #component;
106
+ // Keep this method async needlessly for now to avoid a breaking change if we
107
+ // would need to make it async in the future
108
+ // eslint-disable-next-line @typescript-eslint/require-await
109
+ async destroy() {
110
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
111
+ this.devOnly$ensureHasDestroy?.();
112
+ }
113
+ if (this.destroyed) {
114
+ return;
115
+ }
116
+ if (this.#component.el.isConnected) {
117
+ this.hasDestroy = false;
118
+ this.#component.el.remove();
119
+ }
120
+ this.#autoDestroyTimeout = void 0;
121
+ this.destroyed = true;
122
+ for (const controller of this.#component.M) {
123
+ if ("triggerDestroy" in controller) {
124
+ controller.triggerDestroy();
125
+ } else {
126
+ safeCall(controller.hostDestroy, controller);
127
+ }
128
+ }
129
+ this.#component.M.splice(0);
130
+ }
131
+ /** @private */
132
+ U() {
133
+ if (this.#autoDestroyTimeout !== void 0) {
134
+ clearTimeout(this.#autoDestroyTimeout);
135
+ }
136
+ if (!this.#component.el.isConnected && !this.#component.autoDestroyDisabled) {
137
+ const destroy = () => void this.#component.destroy();
138
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && autoDestroyOnDisconnectTimeout === 0) ;
139
+ else {
140
+ this.#autoDestroyTimeout = devToolsAwareTimeout(destroy, autoDestroyOnDisconnectTimeout);
141
+ }
142
+ }
143
+ }
144
+ /** @private */
145
+ S(key, value) {
146
+ const trackers = this.T;
147
+ this.V = nothing$1;
148
+ this.T = [];
149
+ trackers.forEach((tracker) => tracker(key, value));
150
+ }
151
+ #exportsStore;
152
+ /**
153
+ * Associate an exports object with a controller for reverse lookup in
154
+ * controller.use
155
+ *
156
+ * @private
157
+ */
158
+ W(controller, exports) {
159
+ if (typeof exports === "object" && exports !== null || typeof exports === "function") {
160
+ this.#exportsStore.set(exports, controller);
161
+ }
162
+ }
163
+ /** @private */
164
+ X(exports) {
165
+ if (typeof exports === "object" && exports !== null || typeof exports === "function") {
166
+ return this.#exportsStore.get(exports);
167
+ } else {
168
+ return void 0;
169
+ }
170
+ }
171
+ }
172
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
173
+ ControllerManager.prototype.devOnly$ensureHasDestroy = function ensureHasDestroy() {
174
+ if (!this.hasDestroy) {
175
+ throw new Error(
176
+ `
177
+ If the component uses a controller that uses destroy() method, then the
178
+ component must have the following properties:
179
+ /**
180
+ * If true, the component will not be destroyed automatically when it is
181
+ * disconnected from the document. This is useful when you want to move the
182
+ * component to a different place on the page, or temporarily hide it. If this
183
+ * is set, make sure to call the \`destroy\` method when you are done to prevent
184
+ * memory leaks.
185
+ */
186
+ @property() ${autoDestroyDisabledPropName} = false;
73
187
 
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 {
188
+ /** Permanently destroy the component */
189
+ @method()
190
+ async destroy(): Promise<void> {
191
+ await this.manager.destroy();
192
+ }
193
+ `.trim().split("\n").map((line) => line.trim()).join("\n")
194
+ );
195
+ }
196
+ };
197
+ }
198
+ let autoDestroyOnDisconnectTimeout = 1e3;
199
+ const autoDestroyDisabledPropName = "autoDestroyDisabled";
200
+ process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? {} : void 0;
201
+ class LitElement extends LitElement$1 {
80
202
  constructor() {
81
203
  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
- 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 */
109
- 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
- this._offspring = this.constructor.lazy?._offspring ?? [];
118
- this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred();
119
- this._enableUpdating = this.enableUpdating;
120
- this.enableUpdating = emptyFunction;
121
- const ourShouldUpdate = _LitElement.prototype.shouldUpdate;
122
- if (this.shouldUpdate !== ourShouldUpdate) {
123
- this._originalShouldUpdate = this.shouldUpdate;
124
- this.shouldUpdate = ourShouldUpdate;
204
+ this.M = [];
205
+ this.manager = new ControllerManager(this);
206
+ const that = this;
207
+ const constructor = that.constructor;
208
+ const lazy = constructor.N;
209
+ const createObservable = constructor.K.o;
210
+ const ourShouldUpdate = LitElement.prototype.shouldUpdate;
211
+ that.#postLoadedDeferred = lazy?.H ?? new Deferred();
212
+ that.I = lazy?.I ?? new Deferred();
213
+ that.J = lazy?.J ?? [];
214
+ that["_offspring"] = that.J;
215
+ that["_postLoad"] = that.I;
216
+ that.el = lazy ?? that;
217
+ that.#enableUpdating = that.enableUpdating;
218
+ that.enableUpdating = emptyFunction;
219
+ if (that.shouldUpdate !== ourShouldUpdate) {
220
+ that.#originalShouldUpdate = that.shouldUpdate;
221
+ that.shouldUpdate = ourShouldUpdate;
125
222
  }
126
223
  if (process.env.NODE_ENV !== "production") {
127
- const isOwnComponent = globalThis.devOnly$ownTagNames?.has(
128
- this.el.tagName.toLowerCase()
129
- );
130
- const constructor = this.constructor;
131
- const warningsWereCustomized = constructor.enabledWarnings !== OriginalLitElement.enabledWarnings;
224
+ const isOwnComponent = globalThis.devOnly$ownTagNames?.has(that.el.localName);
225
+ const constructor2 = this.constructor;
226
+ const warningsWereCustomized = constructor2.enabledWarnings !== LitElement$1.enabledWarnings;
132
227
  if (!isOwnComponent && !warningsWereCustomized) {
133
- constructor.disableWarning?.("change-in-update");
228
+ constructor2.disableWarning?.("change-in-update");
134
229
  }
135
- if (isEsriInternalEnv2()) {
230
+ if (isEsriInternalEnv()) {
136
231
  globalThis.devOnly$luminaComponentRefCallback?.(this);
232
+ const stencilToLitMapping = {
233
+ componentDidLoad: "loaded",
234
+ componentDidRender: "updated",
235
+ componentDidUpdate: "updated",
236
+ componentShouldUpdate: "shouldUpdate",
237
+ componentWillLoad: "load",
238
+ componentWillRender: "willUpdate",
239
+ componentWillUpdate: "willUpdate"
240
+ };
241
+ Object.entries(stencilToLitMapping).forEach(([stencilMethod, litMethod]) => {
242
+ if (stencilMethod in this) {
243
+ throw new Error(
244
+ `Unexpected ${stencilMethod}() in a Lit component ${this.el.localName}. In Lit, you should use ${litMethod}() instead`
245
+ );
246
+ }
247
+ });
137
248
  }
138
249
  }
250
+ if (createObservable) {
251
+ that.#observables = /* @__PURE__ */ new Map();
252
+ constructor.elementProperties.forEach((_, name) => that.#observables.set(name, createObservable()));
253
+ }
139
254
  if (isServer) {
140
- this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
255
+ that.el.setAttribute(constructor.K.hydratedAttribute, "");
141
256
  }
142
257
  }
143
258
  /**
@@ -149,12 +264,13 @@ var LitElement = class _LitElement extends OriginalLitElement {
149
264
  }
150
265
  const finalizedStyles = super.finalizeStyles(styles);
151
266
  const useLightDom = this.shadowRootOptions === noShadowRoot;
152
- return this.runtime?.commonStyles === void 0 || useLightDom ? finalizedStyles : [this.runtime.commonStyles, ...finalizedStyles];
267
+ return this.K?.commonStyles === void 0 || useLightDom ? finalizedStyles : [this.K.commonStyles, ...finalizedStyles];
153
268
  }
154
269
  static createProperty(name, options) {
155
270
  const flags = typeof options === "number" ? options : Array.isArray(options) ? options[0] : 0;
156
271
  const rest = Array.isArray(options) ? options[1] : void 0;
157
- super.createProperty(name, {
272
+ const hasChanged = rest?.hasChanged ?? notEqual;
273
+ const normalizedOptions = {
158
274
  /**
159
275
  * By default to infer attribute name from property name, Lit just
160
276
  * converts property name to lowercase. That is consistent with
@@ -171,42 +287,105 @@ var LitElement = class _LitElement extends OriginalLitElement {
171
287
  *
172
288
  * Thus, overwriting Lit's default behavior to use kebab-case:
173
289
  */
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,
290
+ attribute: !!(flags & propertyFlagAttribute) && typeof name === "string" ? camelToKebab(name) : false,
291
+ reflect: !!(flags & propertyFlagReflect),
292
+ type: flags & propertyFlagBoolean ? Boolean : flags & propertyFlagNumber ? Number : void 0,
177
293
  /**
178
294
  * At the moment in Lit, state:true just means attribute:false, so this
179
295
  * line is technically redundant, but let's keep it here just in case Lit
180
296
  * will add more meaning to state:true in the future.
181
297
  */
182
- state: !!(flags & 16 /* STATE */),
298
+ state: !!(flags & propertyFlagState),
183
299
  // Controllers add this option to Lit
184
- readOnly: !!(flags & 32 /* READ_ONLY */),
185
- noAccessor: !!(flags & 64 /* NO_ACCESSOR */),
186
- ...rest
187
- });
300
+ readOnly: !!(flags & propertyFlagReadOnly),
301
+ noAccessor: !!(flags & propertyFlagNoAccessor),
302
+ c: false,
303
+ ...rest,
304
+ hasChanged(newValue, oldValue) {
305
+ const changed = hasChanged(newValue, oldValue);
306
+ normalizedOptions.c = changed;
307
+ return changed;
308
+ }
309
+ };
310
+ super.createProperty(name, normalizedOptions);
311
+ }
312
+ static getPropertyDescriptor(name, key, options) {
313
+ const runtime = this.K;
314
+ const accessor = super.getPropertyDescriptor(name, key, options);
315
+ options.d = accessor;
316
+ return {
317
+ ...accessor,
318
+ get() {
319
+ runtime.t?.(this.#observables.get(name));
320
+ return accessor.get?.call(this);
321
+ },
322
+ set(rawNewValue) {
323
+ const manager = this.manager;
324
+ if (options.readOnly && !shouldBypassReadOnly && (manager.R || manager.connectedCalled)) {
325
+ throw Error(
326
+ `Cannot assign to read-only property "${name}" of ${this.el.localName}. Trying to assign "${rawNewValue}"`
327
+ );
328
+ }
329
+ accessor.set.call(this, rawNewValue ?? void 0);
330
+ if (options.c) {
331
+ this.#observables?.get(name)?.notify();
332
+ }
333
+ if (manager.T.length > 0) {
334
+ manager?.S(name, rawNewValue);
335
+ }
336
+ }
337
+ };
188
338
  }
189
339
  static {
190
340
  this.lumina = true;
191
341
  }
342
+ /**
343
+ * The JS API's Accessor observables. This is used to integrate with the JS
344
+ * API's reactivity system.
345
+ *
346
+ * @private
347
+ */
348
+ #observables;
349
+ #originalShouldUpdate;
350
+ #enableUpdating;
351
+ #postLoadedDeferred;
352
+ #trackingTarget;
192
353
  connectedCallback() {
193
354
  if (this.el.hasAttribute("defer-hydration")) {
194
355
  return;
195
356
  }
357
+ const trackingTarget = this.manager.A?.(() => this.requestUpdate());
358
+ this.#trackingTarget = trackingTarget;
196
359
  const isFirstCall = !this.manager.connectedCalled;
197
360
  super.connectedCallback();
198
361
  if (isFirstCall) {
199
362
  queueMicrotask(
200
- // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/promise-function-async
201
- () => this._load().catch((error) => {
202
- this._postLoaded.reject(error);
363
+ // eslint-disable-next-line @typescript-eslint/promise-function-async, @typescript-eslint/no-misused-promises
364
+ () => this.#load().catch((error) => {
365
+ this.#postLoadedDeferred.reject(error);
203
366
  setTimeout(() => {
204
367
  throw error;
205
368
  });
206
369
  })
207
370
  );
371
+ } else if (trackingTarget) {
372
+ this.requestUpdate();
208
373
  }
209
374
  }
375
+ #doTrackedUpdate(changedProperties) {
376
+ try {
377
+ this.#trackingTarget.clear();
378
+ this.manager.B(this.#trackingTarget, () => super.update(changedProperties));
379
+ } catch (error) {
380
+ this.#trackingTarget.clear();
381
+ throw error;
382
+ }
383
+ }
384
+ disconnectedCallback() {
385
+ super.disconnectedCallback();
386
+ this.#trackingTarget?.destroy();
387
+ this.#trackingTarget = void 0;
388
+ }
210
389
  /**
211
390
  * Overwrite Lit's default behavior of attaching shadow root to the lit
212
391
  * element, and instead use this.el to support lazy builds.
@@ -219,13 +398,9 @@ var LitElement = class _LitElement extends OriginalLitElement {
219
398
  const options = Class.shadowRootOptions;
220
399
  const useLightDom = options === noShadowRoot;
221
400
  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
401
  if (existingShadowRoot) {
227
402
  if (process.env.NODE_ENV === "production") {
228
- OriginalLitElement.prototype.createRenderRoot.call(this);
403
+ LitElement$1.prototype.createRenderRoot.call(this);
229
404
  }
230
405
  return existingShadowRoot;
231
406
  }
@@ -242,32 +417,60 @@ var LitElement = class _LitElement extends OriginalLitElement {
242
417
  return renderRoot;
243
418
  }
244
419
  /** Do asynchronous component load */
245
- async _load() {
246
- const parentLoadPromise = this.el._ancestorLoad ?? attachToAncestor(this.el);
420
+ async #load() {
421
+ const parentLoadPromise = this.el.G ?? attachToAncestor(this.el);
247
422
  if (parentLoadPromise) {
248
423
  await parentLoadPromise;
249
424
  }
250
- await this.manager._load();
251
- this._enableUpdating(true);
425
+ const promises = [];
426
+ for (const controller of this.M) {
427
+ if ("triggerLoad" in controller) {
428
+ promises.push(controller.triggerLoad());
429
+ } else {
430
+ promises.push(safeAsyncCall(controller.hostLoad, controller));
431
+ }
432
+ }
433
+ await Promise.all(promises);
434
+ await this.load?.();
435
+ if (this.manager.hasDestroy) {
436
+ this.manager.onUpdate(
437
+ (changes) => changes.has(autoDestroyDisabledPropName) && this.manager.U()
438
+ );
439
+ }
440
+ this.#enableUpdating(true);
252
441
  this.performUpdate();
253
- this._postLoad.resolve();
442
+ this.I.resolve();
254
443
  await Promise.resolve();
255
- const pendingChildren = this._offspring.filter((loaded) => !loaded.manager?.loadedCalled);
444
+ const pendingChildren = this.J.filter((loaded) => !loaded.manager?.loadedCalled);
256
445
  if (pendingChildren.length) {
257
446
  await Promise.allSettled(pendingChildren.map(async (child) => await child.componentOnReady()));
258
447
  }
259
- this._offspring.length = 0;
260
- this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
261
- this.manager._loaded();
262
- this._postLoaded.resolve();
448
+ this.J.length = 0;
449
+ this.el.setAttribute(this.constructor.K.hydratedAttribute, "");
450
+ for (const controller of this.M) {
451
+ if ("triggerLoaded" in controller) {
452
+ controller.triggerLoaded();
453
+ } else {
454
+ safeCall(controller.hostLoaded, controller);
455
+ }
456
+ }
457
+ this.loaded?.();
458
+ this.#postLoadedDeferred.resolve();
263
459
  }
264
460
  /**
265
461
  * Overwriting default shouldUpdate simply to get access to
266
462
  * "changedProperties" so that we can later provide it to ControllerManager
267
463
  */
268
464
  shouldUpdate(_changedProperties) {
269
- this.$changes = _changedProperties;
270
- return this._originalShouldUpdate?.(_changedProperties) ?? true;
465
+ this.manager.Q = _changedProperties;
466
+ return this.#originalShouldUpdate?.(_changedProperties) ?? true;
467
+ }
468
+ update(changedProperties) {
469
+ if (this.#trackingTarget) {
470
+ this.#doTrackedUpdate(changedProperties);
471
+ } else {
472
+ super.update(changedProperties);
473
+ }
271
474
  }
272
475
  listen(name, listener, options) {
273
476
  const boundListener = listener?.bind(this) ?? listener;
@@ -294,22 +497,33 @@ var LitElement = class _LitElement extends OriginalLitElement {
294
497
  * });
295
498
  */
296
499
  async componentOnReady() {
297
- await this._postLoaded.promise;
500
+ await this.#postLoadedDeferred.promise;
298
501
  return this;
299
502
  }
300
- };
301
- LitElement.$createEvent = createEventFactory;
302
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv2()) {
303
- const globalWithLit = globalThis;
304
- globalWithLit.litIssuedWarnings ??= /* @__PURE__ */ new Set();
305
- globalWithLit.litIssuedWarnings.add(
306
- "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
- );
503
+ /**
504
+ * Adds a controller to the host, which connects the controller's lifecycle
505
+ * methods to the host's lifecycle.
506
+ *
507
+ * @remarks
508
+ * Even though Lit's LitElement already has addController,
509
+ * we overwrite it with a compatible version to have more control over
510
+ * timing, and to add support for load/loaded lifecycle hooks.
511
+ */
512
+ addController(controller) {
513
+ this.M.push(controller);
514
+ if (!(controllerSymbol in controller) && this.renderRoot && this.el.isConnected) {
515
+ controller.hostConnected?.();
516
+ }
517
+ }
518
+ /**
519
+ * Removes a controller from the host.
520
+ */
521
+ removeController(controller) {
522
+ this.M.splice(this.M.indexOf(controller), 1);
523
+ controller.controllerRemoved?.();
524
+ }
308
525
  }
309
-
310
- // src/runtime.ts
311
- import { isEsriInternalEnv as isEsriInternalEnv3 } from "@arcgis/components-utils";
312
- function makeRuntime(options) {
526
+ const makeRuntime = (options) => {
313
527
  let assetPath;
314
528
  const setAssetPath = (path) => {
315
529
  assetPath = new URL(
@@ -343,41 +557,43 @@ function makeRuntime(options) {
343
557
  },
344
558
  setAssetPath,
345
559
  customElement(tagName, component) {
346
- component.runtime = runtime;
347
- component.tagName = tagName;
560
+ component.K = runtime;
561
+ component.L = tagName;
348
562
  if (!customElements.get(tagName)) {
349
563
  customElements.define(tagName, component);
350
564
  }
351
565
  }
352
566
  };
353
567
  setAssetPath(options.defaultAssetPath);
354
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv3()) {
568
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
355
569
  globalThis.devOnly$luminaRuntime = runtime;
356
570
  }
357
571
  return runtime;
572
+ };
573
+ const Fragment = void 0;
574
+ const bindAttribute = void 0;
575
+ const bindBooleanAttribute = void 0;
576
+ const bindProperty = void 0;
577
+ const bindEvent = void 0;
578
+ const safeClassMap = (parameters) => typeof parameters === "object" && parameters != null ? classMap(parameters) : parameters;
579
+ const safeStyleMap = (parameters) => typeof parameters === "object" && parameters != null ? styleMap(parameters) : parameters;
580
+ class DeferLoad extends Directive {
581
+ update(part) {
582
+ const tagName = part.element.localName;
583
+ if (!customElements.get(tagName)) {
584
+ void deferredLoaders.get(tagName)?.();
585
+ }
586
+ }
587
+ render() {
588
+ return noChange$1;
589
+ }
358
590
  }
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;
591
+ const deferLoad = /* @__PURE__ */ directive$1(DeferLoad)();
592
+ const deferredLoaders = /* @__PURE__ */ new Map();
593
+ const directive = directive$1;
594
+ const live = live$1;
595
+ const nothing = nothing$2;
596
+ const noChange = noChange$2;
381
597
  function setAttribute(element, attributeName, value) {
382
598
  if (value == null) {
383
599
  element.removeAttribute(attributeName);
@@ -385,13 +601,11 @@ function setAttribute(element, attributeName, value) {
385
601
  element.setAttribute(attributeName, value);
386
602
  }
387
603
  }
388
- var stringOrBoolean = {
604
+ const stringOrBoolean = {
389
605
  toAttribute: (value) => value === true ? "" : value === false ? null : value
390
606
  };
391
-
392
- // src/wrappersUtils.ts
393
- var emptyObject = {};
394
- var makeReactWrapperFactory = (react, createComponent) => (options) => {
607
+ const emptyObject = {};
608
+ const makeReactWrapperFactory = (react, createComponent) => (options) => {
395
609
  const tagName = options.tagName;
396
610
  let customElementPrototype = emptyObject;
397
611
  const elementClass = {
@@ -429,7 +643,12 @@ var makeReactWrapperFactory = (react, createComponent) => (options) => {
429
643
  customElementPrototype = void 0;
430
644
  return result;
431
645
  };
432
- var getReactWrapperOptions = (tagNameAndElement, events) => ({ tagName: tagNameAndElement, events });
646
+ const getReactWrapperOptions = (tagNameAndElement, events) => ({ tagName: tagNameAndElement, events });
647
+ const renderElement = (element) => {
648
+ const container = document.createElement("div");
649
+ render(element, container);
650
+ return container.firstElementChild;
651
+ };
433
652
  export {
434
653
  Fragment,
435
654
  LitElement,
@@ -437,11 +656,14 @@ export {
437
656
  bindBooleanAttribute,
438
657
  bindEvent,
439
658
  bindProperty,
440
- createEvent,
659
+ b as createEvent,
660
+ deferLoad,
661
+ deferredLoaders,
662
+ d as devOnly$getLitElementTagNameAndRuntime,
441
663
  directive,
442
664
  getReactWrapperOptions,
443
665
  live,
444
- makeDefineCustomElements,
666
+ m as makeDefineCustomElements,
445
667
  makeReactWrapperFactory,
446
668
  makeRuntime,
447
669
  method,
@@ -449,6 +671,7 @@ export {
449
671
  noShadowRoot,
450
672
  nothing,
451
673
  property,
674
+ renderElement,
452
675
  safeClassMap,
453
676
  safeStyleMap,
454
677
  setAttribute,