@arcgis/lumina 4.33.0-next.16 → 4.33.0-next.160

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 (58) 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 +68 -0
  9. package/dist/controllers/accessor/index.d.ts +4 -0
  10. package/dist/controllers/accessor/index.js +245 -0
  11. package/dist/controllers/accessor/reEmitEvent.d.ts +10 -0
  12. package/dist/controllers/accessor/store.d.ts +17 -0
  13. package/dist/controllers/accessor/useAccessor.d.ts +76 -0
  14. package/dist/controllers/functional.d.ts +19 -0
  15. package/dist/controllers/index.d.ts +24 -0
  16. package/dist/controllers/index.js +270 -0
  17. package/dist/controllers/load.d.ts +6 -0
  18. package/dist/controllers/proxyExports.d.ts +27 -0
  19. package/dist/controllers/tests/autoDestroyMock.d.ts +5 -0
  20. package/dist/controllers/tests/utils.d.ts +1 -0
  21. package/dist/controllers/toFunction.d.ts +8 -0
  22. package/dist/controllers/trackKey.d.ts +8 -0
  23. package/dist/controllers/trackPropKey.d.ts +21 -0
  24. package/dist/controllers/trackPropertyKey.d.ts +29 -0
  25. package/dist/controllers/types.d.ts +187 -0
  26. package/dist/controllers/useDirection.d.ts +11 -0
  27. package/dist/controllers/useMedia.d.ts +8 -0
  28. package/dist/controllers/usePropertyChange.d.ts +14 -0
  29. package/dist/controllers/useT9n.d.ts +48 -0
  30. package/dist/controllers/useWatchAttributes.d.ts +7 -0
  31. package/dist/controllers/utils.d.ts +12 -0
  32. package/dist/createEvent.d.ts +8 -3
  33. package/dist/decorators.d.ts +2 -2
  34. package/dist/devOnlyDetectIncorrectLazyUsages.d.ts +1 -1
  35. package/dist/hmrSupport.d.ts +1 -1
  36. package/dist/hmrSupport.js +22 -28
  37. package/dist/index.d.ts +17 -16
  38. package/dist/index.js +423 -194
  39. package/dist/jsx/baseTypes.d.ts +13 -9
  40. package/dist/jsx/directives.d.ts +25 -7
  41. package/dist/jsx/generatedTypes.d.ts +420 -90
  42. package/dist/jsx/types.d.ts +5 -32
  43. package/dist/lazyLoad-DUvrNd2L.js +406 -0
  44. package/dist/lazyLoad.d.ts +27 -72
  45. package/dist/lifecycleSupport.d.ts +2 -2
  46. package/dist/makeRuntime.d.ts +148 -0
  47. package/dist/proxyExports-Cdzj7WL_.js +60 -0
  48. package/dist/render.d.ts +5 -0
  49. package/dist/runtime.d.ts +4 -107
  50. package/dist/stencilSsrCompatibility/index.d.ts +2 -6
  51. package/dist/stencilSsrCompatibility/index.js +2 -3
  52. package/dist/typings/importMeta.d.ts +2 -2
  53. package/dist/utils.d.ts +8 -0
  54. package/dist/wrappersUtils.d.ts +13 -1
  55. package/package.json +7 -6
  56. package/dist/chunk-NO7HOBNA.js +0 -421
  57. package/dist/chunk-PGHUBTOM.js +0 -21
  58. 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-DUvrNd2L.js";
7
+ import { d, m } from "./lazyLoad-DUvrNd2L.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,108 @@ 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.constructor.K.c?.(() => 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.constructor.K.r(
379
+ this.#trackingTarget,
380
+ () => super.update(changedProperties)
381
+ );
382
+ } catch (error) {
383
+ this.#trackingTarget.clear();
384
+ throw error;
385
+ }
386
+ }
387
+ disconnectedCallback() {
388
+ super.disconnectedCallback();
389
+ this.#trackingTarget?.destroy();
390
+ this.#trackingTarget = void 0;
391
+ }
210
392
  /**
211
393
  * Overwrite Lit's default behavior of attaching shadow root to the lit
212
394
  * element, and instead use this.el to support lazy builds.
@@ -219,13 +401,9 @@ var LitElement = class _LitElement extends OriginalLitElement {
219
401
  const options = Class.shadowRootOptions;
220
402
  const useLightDom = options === noShadowRoot;
221
403
  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
404
  if (existingShadowRoot) {
227
405
  if (process.env.NODE_ENV === "production") {
228
- OriginalLitElement.prototype.createRenderRoot.call(this);
406
+ LitElement$1.prototype.createRenderRoot.call(this);
229
407
  }
230
408
  return existingShadowRoot;
231
409
  }
@@ -242,32 +420,60 @@ var LitElement = class _LitElement extends OriginalLitElement {
242
420
  return renderRoot;
243
421
  }
244
422
  /** Do asynchronous component load */
245
- async _load() {
246
- const parentLoadPromise = this.el._ancestorLoad ?? attachToAncestor(this.el);
423
+ async #load() {
424
+ const parentLoadPromise = this.el.G ?? attachToAncestor(this.el);
247
425
  if (parentLoadPromise) {
248
426
  await parentLoadPromise;
249
427
  }
250
- await this.manager._load();
251
- this._enableUpdating(true);
428
+ const promises = [];
429
+ for (const controller of this.M) {
430
+ if ("triggerLoad" in controller) {
431
+ promises.push(controller.triggerLoad());
432
+ } else {
433
+ promises.push(safeAsyncCall(controller.hostLoad, controller));
434
+ }
435
+ }
436
+ await Promise.all(promises);
437
+ await this.load?.();
438
+ if (this.manager.hasDestroy) {
439
+ this.manager.onUpdate(
440
+ (changes) => changes.has(autoDestroyDisabledPropName) && this.manager.U()
441
+ );
442
+ }
443
+ this.#enableUpdating(true);
252
444
  this.performUpdate();
253
- this._postLoad.resolve();
445
+ this.I.resolve();
254
446
  await Promise.resolve();
255
- const pendingChildren = this._offspring.filter((loaded) => !loaded.manager?.loadedCalled);
447
+ const pendingChildren = this.J.filter((loaded) => !loaded.manager?.loadedCalled);
256
448
  if (pendingChildren.length) {
257
449
  await Promise.allSettled(pendingChildren.map(async (child) => await child.componentOnReady()));
258
450
  }
259
- this._offspring.length = 0;
260
- this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
261
- this.manager._loaded();
262
- this._postLoaded.resolve();
451
+ this.J.length = 0;
452
+ this.el.setAttribute(this.constructor.K.hydratedAttribute, "");
453
+ for (const controller of this.M) {
454
+ if ("triggerLoaded" in controller) {
455
+ controller.triggerLoaded();
456
+ } else {
457
+ safeCall(controller.hostLoaded, controller);
458
+ }
459
+ }
460
+ this.loaded?.();
461
+ this.#postLoadedDeferred.resolve();
263
462
  }
264
463
  /**
265
464
  * Overwriting default shouldUpdate simply to get access to
266
465
  * "changedProperties" so that we can later provide it to ControllerManager
267
466
  */
268
467
  shouldUpdate(_changedProperties) {
269
- this.$changes = _changedProperties;
270
- return this._originalShouldUpdate?.(_changedProperties) ?? true;
468
+ this.manager.Q = _changedProperties;
469
+ return this.#originalShouldUpdate?.(_changedProperties) ?? true;
470
+ }
471
+ update(changedProperties) {
472
+ if (this.#trackingTarget) {
473
+ this.#doTrackedUpdate(changedProperties);
474
+ } else {
475
+ super.update(changedProperties);
476
+ }
271
477
  }
272
478
  listen(name, listener, options) {
273
479
  const boundListener = listener?.bind(this) ?? listener;
@@ -294,22 +500,33 @@ var LitElement = class _LitElement extends OriginalLitElement {
294
500
  * });
295
501
  */
296
502
  async componentOnReady() {
297
- await this._postLoaded.promise;
503
+ await this.#postLoadedDeferred.promise;
298
504
  return this;
299
505
  }
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
- );
506
+ /**
507
+ * Adds a controller to the host, which connects the controller's lifecycle
508
+ * methods to the host's lifecycle.
509
+ *
510
+ * @remarks
511
+ * Even though Lit's LitElement already has addController,
512
+ * we overwrite it with a compatible version to have more control over
513
+ * timing, and to add support for load/loaded lifecycle hooks.
514
+ */
515
+ addController(controller) {
516
+ this.M.push(controller);
517
+ if (!(controllerSymbol in controller) && this.renderRoot && this.el.isConnected) {
518
+ controller.hostConnected?.();
519
+ }
520
+ }
521
+ /**
522
+ * Removes a controller from the host.
523
+ */
524
+ removeController(controller) {
525
+ this.M.splice(this.M.indexOf(controller), 1);
526
+ controller.controllerRemoved?.();
527
+ }
308
528
  }
309
-
310
- // src/runtime.ts
311
- import { isEsriInternalEnv as isEsriInternalEnv3 } from "@arcgis/components-utils";
312
- function makeRuntime(options) {
529
+ const makeRuntime = (options) => {
313
530
  let assetPath;
314
531
  const setAssetPath = (path) => {
315
532
  assetPath = new URL(
@@ -343,41 +560,43 @@ function makeRuntime(options) {
343
560
  },
344
561
  setAssetPath,
345
562
  customElement(tagName, component) {
346
- component.runtime = runtime;
347
- component.tagName = tagName;
563
+ component.K = runtime;
564
+ component.L = tagName;
348
565
  if (!customElements.get(tagName)) {
349
566
  customElements.define(tagName, component);
350
567
  }
351
568
  }
352
569
  };
353
570
  setAssetPath(options.defaultAssetPath);
354
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv3()) {
571
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
355
572
  globalThis.devOnly$luminaRuntime = runtime;
356
573
  }
357
574
  return runtime;
575
+ };
576
+ const Fragment = void 0;
577
+ const bindAttribute = void 0;
578
+ const bindBooleanAttribute = void 0;
579
+ const bindProperty = void 0;
580
+ const bindEvent = void 0;
581
+ const safeClassMap = (parameters) => typeof parameters === "object" && parameters != null ? classMap(parameters) : parameters;
582
+ const safeStyleMap = (parameters) => typeof parameters === "object" && parameters != null ? styleMap(parameters) : parameters;
583
+ class DeferLoad extends Directive {
584
+ update(part) {
585
+ const tagName = part.element.localName;
586
+ if (!customElements.get(tagName)) {
587
+ void deferredLoaders.get(tagName)?.();
588
+ }
589
+ }
590
+ render() {
591
+ return noChange$1;
592
+ }
358
593
  }
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;
594
+ const deferLoad = /* @__PURE__ */ directive$1(DeferLoad)();
595
+ const deferredLoaders = /* @__PURE__ */ new Map();
596
+ const directive = directive$1;
597
+ const live = live$1;
598
+ const nothing = nothing$2;
599
+ const noChange = noChange$2;
381
600
  function setAttribute(element, attributeName, value) {
382
601
  if (value == null) {
383
602
  element.removeAttribute(attributeName);
@@ -385,13 +604,11 @@ function setAttribute(element, attributeName, value) {
385
604
  element.setAttribute(attributeName, value);
386
605
  }
387
606
  }
388
- var stringOrBoolean = {
607
+ const stringOrBoolean = {
389
608
  toAttribute: (value) => value === true ? "" : value === false ? null : value
390
609
  };
391
-
392
- // src/wrappersUtils.ts
393
- var emptyObject = {};
394
- var makeReactWrapperFactory = (react, createComponent) => (options) => {
610
+ const emptyObject = {};
611
+ const makeReactWrapperFactory = (react, createComponent) => (options) => {
395
612
  const tagName = options.tagName;
396
613
  let customElementPrototype = emptyObject;
397
614
  const elementClass = {
@@ -412,10 +629,13 @@ var makeReactWrapperFactory = (react, createComponent) => (options) => {
412
629
  */
413
630
  get prototype() {
414
631
  if (customElementPrototype === void 0) {
415
- customElementPrototype = customElements.get(tagName)?.prototype;
416
- if (!customElementPrototype) {
632
+ const customElement = customElements.get(tagName);
633
+ if (!customElement) {
417
634
  throw new Error(`Custom element "${tagName}" not found`);
418
635
  }
636
+ customElement.F?.();
637
+ customElement.F = emptyFunction;
638
+ customElementPrototype = customElement.prototype;
419
639
  Object.defineProperty(elementClass, "prototype", { value: customElementPrototype });
420
640
  }
421
641
  return customElementPrototype;
@@ -429,7 +649,12 @@ var makeReactWrapperFactory = (react, createComponent) => (options) => {
429
649
  customElementPrototype = void 0;
430
650
  return result;
431
651
  };
432
- var getReactWrapperOptions = (tagNameAndElement, events) => ({ tagName: tagNameAndElement, events });
652
+ const getReactWrapperOptions = (tagNameAndElement, events) => ({ tagName: tagNameAndElement, events });
653
+ const renderElement = (element) => {
654
+ const container = document.createElement("div");
655
+ render(element, container);
656
+ return container.firstElementChild;
657
+ };
433
658
  export {
434
659
  Fragment,
435
660
  LitElement,
@@ -437,11 +662,14 @@ export {
437
662
  bindBooleanAttribute,
438
663
  bindEvent,
439
664
  bindProperty,
440
- createEvent,
665
+ b as createEvent,
666
+ deferLoad,
667
+ deferredLoaders,
668
+ d as devOnly$getLitElementTagNameAndRuntime,
441
669
  directive,
442
670
  getReactWrapperOptions,
443
671
  live,
444
- makeDefineCustomElements,
672
+ m as makeDefineCustomElements,
445
673
  makeReactWrapperFactory,
446
674
  makeRuntime,
447
675
  method,
@@ -449,6 +677,7 @@ export {
449
677
  noShadowRoot,
450
678
  nothing,
451
679
  property,
680
+ renderElement,
452
681
  safeClassMap,
453
682
  safeStyleMap,
454
683
  setAttribute,