@arcgis/lumina 4.32.0-next.11 → 4.32.0-next.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,22 +1,40 @@
1
1
  import {
2
- lazyMetaGroupJoiner,
3
- lazyMetaItemJoiner,
4
- lazyMetaSubItemJoiner
5
- } from "./chunk-PGHUBTOM.js";
2
+ attachToAncestor,
3
+ makeDefineCustomElements,
4
+ noShadowRoot
5
+ } from "./chunk-6HCCSL5F.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) {
12
+ const component = retrieveComponent();
13
+ const controller = new ContextProvider(component.el, options);
14
+ component.addController(controller);
15
+ return controller;
16
+ }
17
+ function useContextConsumer(options) {
18
+ const component = retrieveComponent();
19
+ const controller = new ContextConsumer(component.el, options);
20
+ component.addController(controller);
21
+ return controller;
22
+ }
6
23
 
7
24
  // src/createEvent.ts
8
- import { retrieveComponent, trackPropertyKey, keyTrackResolve } from "@arcgis/components-controllers";
9
- var createEventFactory = (eventName = "", options = {}, component = retrieveComponent()) => {
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()) => {
10
28
  const emitter = {
11
29
  emit: (payload) => {
12
- if (process.env.NODE_ENV !== "production" && !component.el.isConnected) {
30
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !component.el.isConnected) {
13
31
  console.warn(
14
32
  `Trying to emit an ${eventName} event on a disconnected element ${component.el.tagName.toLowerCase()}`
15
33
  );
16
34
  }
17
35
  if (eventName === "") {
18
36
  keyTrackResolve();
19
- if (process.env.NODE_ENV !== "production" && eventName === "") {
37
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && eventName === "") {
20
38
  throw new Error("Unable to resolve event name from property name");
21
39
  }
22
40
  }
@@ -32,13 +50,13 @@ var createEventFactory = (eventName = "", options = {}, component = retrieveComp
32
50
  }
33
51
  };
34
52
  if (eventName === "") {
35
- trackPropertyKey(
36
- component,
37
- (key) => {
38
- if (process.env.NODE_ENV !== "production" && key === void 0) {
53
+ trackKey(
54
+ void 0,
55
+ (resolution) => {
56
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && resolution === void 0) {
39
57
  throw new Error(`createEvent must be called in property default value only`);
40
58
  }
41
- eventName = key;
59
+ eventName = resolution.key;
42
60
  },
43
61
  emitter
44
62
  );
@@ -53,497 +71,8 @@ import { property as litProperty } from "@lit/reactive-element/decorators/proper
53
71
  var property = litProperty;
54
72
  var method = void 0;
55
73
 
56
- // src/lazyLoad.ts
57
- import { Deferred, camelToKebab } from "@arcgis/components-utils";
58
-
59
- // src/devOnlyDetectIncorrectLazyUsages.ts
60
- function devOnlyDetectIncorrectLazyUsages(LitClass) {
61
- const genericPrototype = LitClass.prototype;
62
- const descriptor = Object.getOwnPropertyDescriptor(genericPrototype, "innerText");
63
- if (descriptor !== void 0 && descriptor.get === descriptor.set) {
64
- return;
65
- }
66
- const allowList = /* @__PURE__ */ new Set([
67
- // We shouldn't be overwriting this property
68
- "constructor",
69
- // Called by Lit - we proxy it to this.el in ProxyComponent
70
- "setAttribute",
71
- // Called by Lit SSR - we proxy it to this.el in ProxyComponent
72
- "removeAttribute",
73
- // Called by Lit - we proxy it to this.el in ProxyComponent
74
- "isConnected",
75
- // Called by Lit, but only in dev mode for warnings, so we don't have to proxy.
76
- "localName"
77
- ]);
78
- const customErrorMessages = {
79
- addEventListener: "use this.listen() or this.el.addEventListener()"
80
- };
81
- Object.entries({
82
- ...Object.getOwnPropertyDescriptors(HTMLElement.prototype),
83
- ...Object.getOwnPropertyDescriptors(Element.prototype),
84
- ...Object.getOwnPropertyDescriptors(Node.prototype),
85
- ...Object.getOwnPropertyDescriptors(EventTarget.prototype)
86
- }).forEach(([key, value]) => {
87
- if (allowList.has(key)) {
88
- return;
89
- }
90
- const callback = (...args) => {
91
- if (key === "hasAttribute" && args[0] === "defer-hydration") {
92
- return false;
93
- }
94
- throw new Error(
95
- `You should not be trying to access this.${key} directly as it won't work correctly in lazy-builds. Instead, ${customErrorMessages[key] ?? `use this.el.${key}`}`
96
- );
97
- };
98
- if (typeof value.value === "function") {
99
- genericPrototype[key] = callback;
100
- } else {
101
- Object.defineProperty(genericPrototype, key, { get: callback, set: callback });
102
- }
103
- });
104
- }
105
-
106
- // src/lifecycleSupport.ts
107
- function attachToAncestor(child) {
108
- let ancestor = child;
109
- while (ancestor = ancestor.parentNode ?? ancestor.host) {
110
- if (ancestor?.constructor?.lumina) {
111
- const litParent = ancestor;
112
- if (!litParent.manager?.loadedCalled) {
113
- litParent._offspring.push(child);
114
- }
115
- return litParent._postLoad.promise;
116
- }
117
- }
118
- return false;
119
- }
120
-
121
- // src/utils.ts
122
- var noShadowRoot = {};
123
-
124
- // src/lazyLoad.ts
125
- var makeDefineCustomElements = (runtime, structure) => function defineCustomElements(windowOrOptions, options) {
126
- if (!globalThis.customElements) {
127
- return;
128
- }
129
- const resolvedOptions = options ?? windowOrOptions ?? {};
130
- const resourcesUrl = resolvedOptions.resourcesUrl;
131
- if (resourcesUrl) {
132
- runtime.setAssetPath(resourcesUrl);
133
- }
134
- Object.entries(structure).forEach(createLazyElement);
135
- };
136
- function createLazyElement([tagName, [load, compactMeta = ""]]) {
137
- if (customElements.get(tagName)) {
138
- return;
139
- }
140
- const [compactObservedProps, compactAsyncMethods, compactSyncMethods] = compactMeta.split(lazyMetaGroupJoiner);
141
- const observedProps = compactObservedProps ? compactObservedProps?.split(lazyMetaItemJoiner).map(parseCondensedProp) : void 0;
142
- const observedProperties = observedProps?.map(([property2]) => property2);
143
- const ProxyClass = class extends ProxyComponent {
144
- static {
145
- this.observedAttributes = observedProps?.map(([, attribute]) => attribute).filter((attribute) => attribute !== "");
146
- }
147
- static {
148
- this._properties = observedProperties;
149
- }
150
- static {
151
- this._asyncMethods = compactAsyncMethods ? compactAsyncMethods?.split(lazyMetaItemJoiner) : void 0;
152
- }
153
- static {
154
- this._syncMethods = compactSyncMethods?.split(lazyMetaItemJoiner);
155
- }
156
- static {
157
- this._name = tagName;
158
- }
159
- constructor() {
160
- const isFirstInstanceOfType = !ProxyClass._loadPromise;
161
- if (isFirstInstanceOfType) {
162
- ProxyClass._loadPromise = load();
163
- ProxyClass._initializePrototype();
164
- }
165
- super();
166
- }
167
- };
168
- customElements.define(tagName, ProxyClass);
169
- }
170
- var defineProperty = Object.defineProperty;
171
- function parseCondensedProp(propAndAttribute) {
172
- const name = propAndAttribute.split(lazyMetaSubItemJoiner);
173
- return name.length === 1 ? [name[0], camelToKebab(name[0])] : name;
174
- }
175
- var HtmlElement = globalThis.HTMLElement ?? parseCondensedProp;
176
- var ProxyComponent = class extends HtmlElement {
177
- constructor() {
178
- super();
179
- /** @internal */
180
- this._store = {};
181
- /**
182
- * If attributeChangedCallback() is called before the LitElement is loaded,
183
- * store the attributes here, and replay later
184
- */
185
- this._pendingAttributes = [];
186
- /**
187
- * Resolved once LitElement's load() is complete.
188
- * Not read inside of this class, but needed for LitElement to determine if
189
- * it's closest ancestor finished load()
190
- */
191
- this._postLoad = new Deferred();
192
- /**
193
- * Resolved once LitElement's loaded() is complete
194
- */
195
- this._postLoaded = new Deferred();
196
- /**
197
- * Direct offspring that should be awaited before loaded() is emitted
198
- */
199
- this._offspring = [];
200
- if (process.env.NODE_ENV !== "production") {
201
- this._hmrSetProps = /* @__PURE__ */ new Set();
202
- this._hmrSetAttributes = /* @__PURE__ */ new Set();
203
- globalThis.devOnly$createdElements ??= [];
204
- globalThis.devOnly$createdElements.push(new WeakRef(this));
205
- }
206
- this._saveInstanceProperties();
207
- const ProxyClass = this.constructor;
208
- if (ProxyClass._LitConstructor) {
209
- this._initializeComponent({ a: ProxyClass._LitConstructor });
210
- } else {
211
- void ProxyClass._loadPromise.then(this._initializeComponent.bind(this)).catch((error) => {
212
- this._postLoaded.reject(error);
213
- setTimeout(() => {
214
- throw error;
215
- });
216
- });
217
- }
218
- if (process.env.NODE_ENV !== "production") {
219
- ProxyClass._hmrInstances ??= [];
220
- ProxyClass._hmrInstances.push(new WeakRef(this));
221
- Object.defineProperty(this, "_store", {
222
- value: this._store,
223
- enumerable: false,
224
- configurable: true
225
- });
226
- }
227
- }
228
- static {
229
- this.lumina = true;
230
- }
231
- /** @internal */
232
- static _initializePrototype() {
233
- this._properties?.forEach(this._bindProp, this);
234
- this._asyncMethods?.forEach(this._bindAsync, this);
235
- this._syncMethods?.forEach(this._bindSync, this);
236
- }
237
- static _bindProp(propName) {
238
- defineProperty(this.prototype, propName, {
239
- configurable: true,
240
- enumerable: true,
241
- get() {
242
- return this._store[propName];
243
- },
244
- set(value) {
245
- this._store[propName] = value;
246
- if (process.env.NODE_ENV !== "production") {
247
- this._hmrSetProps.add(propName);
248
- }
249
- }
250
- });
251
- }
252
- static _bindAsync(methodName) {
253
- defineProperty(this.prototype, methodName, {
254
- async value(...args) {
255
- if (!this._litElement) {
256
- await this._postLoaded.promise;
257
- }
258
- const genericLitElement = this._litElement;
259
- return await genericLitElement[methodName](...args);
260
- },
261
- configurable: true
262
- });
263
- }
264
- static _bindSync(methodName) {
265
- defineProperty(this.prototype, methodName, {
266
- value(...args) {
267
- if (process.env.NODE_ENV === "development" && !this._litElement) {
268
- const ProxyClass = this.constructor;
269
- throw new Error(
270
- `Tried to call method ${methodName}() on <${ProxyClass._name}> component before it's fully loaded. Please do 'await component.componentOnReady();' before calling this method.`
271
- );
272
- }
273
- const genericLitElement = this._litElement;
274
- return genericLitElement[methodName](...args);
275
- },
276
- configurable: true
277
- });
278
- }
279
- get manager() {
280
- return this._litElement?.manager;
281
- }
282
- /**
283
- * Until the custom element is registered on the page, an instance of that
284
- * element can be constructed and some properties on that instance set.
285
- *
286
- * These properties are set before the element prototype is set to this proxy
287
- * class and thus none of our getters/setters are yet registered - such
288
- * properties will be set by JavaScript on the instance directly.
289
- *
290
- * Once element is registered, the properties set in the meanwhile will shadow
291
- * the getter/setters, and thus break reactivity. The fix is to delete these
292
- * properties from the instance, and re-apply them once accessors are set.
293
- *
294
- * @example
295
- * ```ts
296
- * import { defineCustomElements } from '@arcgis/map-components';
297
- * const map = document.createElement('arcgis-map');
298
- * // This will shadow the getter/setters
299
- * map.itemId = '...';
300
- * // This finally defines the custom elements and sets the property accessors
301
- * defineCustomElements();
302
- * ```
303
- *
304
- * @remarks
305
- * This is an equivalent of the __saveInstanceProperties method in Lit's
306
- * ReactiveElement. Lit takes care of this on LitElement, but we have to take
307
- * care of this on the lazy proxy
308
- */
309
- _saveInstanceProperties() {
310
- const ProxyClass = this.constructor;
311
- const genericThis = this;
312
- ProxyClass._properties?.forEach((propName) => {
313
- if (Object.hasOwn(this, propName)) {
314
- this._store[propName] = genericThis[propName];
315
- delete genericThis[propName];
316
- }
317
- });
318
- }
319
- /*
320
- * This method must be statically present rather than added later, or else,
321
- * browsers won't call it. Same for connected and disconnected callbacks.
322
- */
323
- attributeChangedCallback(name, oldValue, newValue) {
324
- this._litElement?.attributeChangedCallback(name, oldValue, newValue);
325
- if (!this._litElement) {
326
- this._pendingAttributes.push(name);
327
- }
328
- if (process.env.NODE_ENV !== "production") {
329
- this._hmrSetAttributes.add(name);
330
- }
331
- }
332
- connectedCallback() {
333
- if (this._litElement) {
334
- this._litElement.connectedCallback();
335
- } else {
336
- queueMicrotask(() => {
337
- this._ancestorLoad = attachToAncestor(this);
338
- });
339
- }
340
- }
341
- disconnectedCallback() {
342
- this._litElement?.disconnectedCallback();
343
- }
344
- /**
345
- * Create a promise that resolves once component is fully loaded
346
- */
347
- async componentOnReady() {
348
- await this._postLoaded.promise;
349
- return this;
350
- }
351
- /** @internal */
352
- _initializeComponent(module) {
353
- const ProxyClass = this.constructor;
354
- const tagName = ProxyClass._name;
355
- if (process.env.NODE_ENV !== "production") {
356
- Object.entries(module).forEach(([name, LitConstructor2]) => {
357
- if (name !== "exportsForTests" && typeof LitConstructor2 !== "function" || typeof LitConstructor2.tagName !== "string") {
358
- console.warn(
359
- `Found non-component export "${name}" in the file for the "${tagName}" component. This will interfere with hot module replacement. Please move "${name}" into a separate file.`
360
- );
361
- }
362
- });
363
- }
364
- const LitConstructor = Object.values(module).find(
365
- (LitConstructor2) => LitConstructor2.tagName === tagName
366
- );
367
- if (process.env.NODE_ENV !== "production" && !LitConstructor) {
368
- throw new Error(
369
- `Unable to find the LitElement class for the "${tagName}" custom element in the lazy-loaded module`
370
- );
371
- }
372
- const lazyTagName = process.env.NODE_ENV === "production" ? `${tagName}--lazy` : (ProxyClass._hmrIndex ?? 0) === 0 ? `${tagName}--lazy` : `${tagName}--lazy-${ProxyClass._hmrIndex}`;
373
- const isFirstInitialization = !ProxyClass._LitConstructor;
374
- if (isFirstInitialization) {
375
- ProxyClass._LitConstructor = LitConstructor;
376
- LitConstructor.prototype.removeAttribute = function(qualifiedName) {
377
- HTMLElement.prototype.removeAttribute.call(this.el, qualifiedName);
378
- };
379
- LitConstructor.prototype.setAttribute = function(qualifiedName, value) {
380
- HTMLElement.prototype.setAttribute.call(this.el, qualifiedName, value);
381
- };
382
- defineProperty(LitConstructor.prototype, "isConnected", {
383
- get() {
384
- return this.el.isConnected;
385
- }
386
- });
387
- if (process.env.NODE_ENV !== "production" && LitConstructor.shadowRootOptions !== noShadowRoot) {
388
- let prototype = LitConstructor;
389
- while (prototype && !Object.hasOwn(prototype, "lumina")) {
390
- prototype = Object.getPrototypeOf(prototype);
391
- }
392
- devOnlyDetectIncorrectLazyUsages(prototype);
393
- }
394
- customElements.define(lazyTagName, LitConstructor);
395
- }
396
- LitConstructor.lazy = this;
397
- const litElement = document.createElement(lazyTagName);
398
- LitConstructor.lazy = void 0;
399
- if (process.env.NODE_ENV !== "production") {
400
- Object.defineProperty(this, "_litElement", {
401
- value: litElement,
402
- configurable: true,
403
- enumerable: false
404
- });
405
- } else {
406
- this._litElement = litElement;
407
- }
408
- this._pendingAttributes.forEach((name) => {
409
- const value = this.getAttribute(name);
410
- litElement.attributeChangedCallback(
411
- name,
412
- // Lit doesn't look at this value, thus even if attribute already exists, that's ok
413
- null,
414
- value
415
- );
416
- });
417
- Object.entries(this._store).forEach(syncLitElement, litElement);
418
- this._store = litElement;
419
- if (process.env.NODE_ENV !== "production") {
420
- const litObserved = LitConstructor.observedAttributes ?? [];
421
- const lazyObserved = ProxyClass.observedAttributes ?? [];
422
- const missingFromLazy = litObserved.filter((attribute) => !lazyObserved.includes(attribute));
423
- const missingFromLit = lazyObserved.filter((attribute) => !litObserved.includes(attribute));
424
- if (missingFromLazy.length > 0) {
425
- console.warn(
426
- `The following attributes on <${ProxyClass._name}> are present on the Lit element, but are missing from the lazy proxy component: ${missingFromLazy.join(", ")}. This either indicates a bug in Lumina, or you are creating the attribute dynamically in a way that compiler cannot infer statically. For these attributes, lazy-loading version of your component won't work correctly, thus this must be resolved`
427
- );
428
- }
429
- if (missingFromLit.length > 0) {
430
- console.warn(
431
- `The following attributes on <${ProxyClass._name}> are defined on the lazy proxy component, but not on the actual Lit element: ${missingFromLit.join(", ")}. This either indicates a bug in Lumina, or you are creating the attribute dynamically in a way that compiler cannot infer statically. This is a non-critical issue, but does indicate that something is going wrong and should be fixed`
432
- );
433
- }
434
- }
435
- const isStillConnected = this.isConnected;
436
- if (isStillConnected || this._ancestorLoad) {
437
- litElement.connectedCallback?.();
438
- if (!isStillConnected) {
439
- litElement.disconnectedCallback();
440
- }
441
- }
442
- }
443
- };
444
- function syncLitElement([key, value]) {
445
- this[key] = value;
446
- }
447
-
448
- // src/hmrSupport.ts
449
- import { camelToKebab as camelToKebab2 } from "@arcgis/components-utils";
450
- function handleHmrUpdate(newModules) {
451
- newModules.forEach((newModule) => {
452
- if (newModule === void 0) {
453
- return;
454
- }
455
- Object.values(newModule).forEach((exported) => {
456
- if (typeof exported !== "function" || typeof exported.tagName !== "string") {
457
- return;
458
- }
459
- const LitConstructor = exported;
460
- const ProxyClass = customElements.get(LitConstructor.tagName);
461
- if (ProxyClass === void 0) {
462
- throw new Error(`Failed to find custom element proxy for tag name: ${LitConstructor.tagName}`);
463
- }
464
- ProxyClass._LitConstructor = void 0;
465
- ProxyClass._loadPromise = void 0;
466
- ProxyClass._hmrIndex ??= 0;
467
- ProxyClass._hmrIndex += 1;
468
- ProxyClass._initializePrototype();
469
- ProxyClass._hmrInstances?.forEach((instanceWeakRef) => {
470
- const instance = instanceWeakRef.deref();
471
- if (instance === void 0) {
472
- return;
473
- }
474
- if (instance._litElement === void 0) {
475
- void ProxyClass._loadPromise.then(() => reInitialize(instance, newModule));
476
- } else {
477
- reInitialize(instance, newModule);
478
- }
479
- });
480
- return;
481
- });
482
- });
483
- }
484
- function reInitialize(instance, newModule) {
485
- const PreviousLitConstructor = instance._litElement.constructor;
486
- const properties = PreviousLitConstructor.elementProperties;
487
- const preservedProperties = Array.from(properties.entries()).filter(
488
- ([propertyName, descriptor]) => typeof propertyName === "string" && (instance._hmrSetProps.has(propertyName) || typeof descriptor.attribute === "string" && instance._hmrSetAttributes.has(descriptor.attribute))
489
- ).map(([key]) => [key, instance[key]]);
490
- instance._store = Object.fromEntries(preservedProperties);
491
- const isConnected = instance.isConnected;
492
- if (isConnected) {
493
- instance._litElement.disconnectedCallback();
494
- }
495
- instance._initializeComponent(newModule);
496
- }
497
- function handleComponentMetaUpdate(meta) {
498
- const ProxyClass = customElements.get(meta.tagName);
499
- if (ProxyClass === void 0) {
500
- return;
501
- }
502
- const attributes = meta.properties.map(([property2, attribute]) => attribute ?? camelToKebab2(property2)).filter(Boolean);
503
- const observedAttributes = initializeAttributeObserver();
504
- observedAttributes[meta.tagName] ??= {};
505
- observedAttributes[meta.tagName].original ??= new Set(ProxyClass.observedAttributes);
506
- const originallyObserved = observedAttributes[meta.tagName].original;
507
- observedAttributes[meta.tagName].manuallyObserved = new Set(
508
- /**
509
- * Never manually observe attributes that were in the original
510
- * observedAttributes as those would be observed by the browser
511
- */
512
- attributes.filter((attribute) => !originallyObserved.has(attribute))
513
- );
514
- ProxyClass._asyncMethods = meta.asyncMethods;
515
- ProxyClass._syncMethods = meta.syncMethods;
516
- ProxyClass._properties = meta.properties.map(([name]) => name);
517
- ProxyClass.observedAttributes = attributes;
518
- }
519
- function initializeAttributeObserver() {
520
- const observedAttributesSymbol = Symbol.for("@arcgis/lumina:observedAttributes");
521
- const globalThisWithObservedAttributes = globalThis;
522
- const alreadyHadObservers = observedAttributesSymbol in globalThisWithObservedAttributes;
523
- globalThisWithObservedAttributes[observedAttributesSymbol] ??= {};
524
- const observedAttributes = globalThisWithObservedAttributes[observedAttributesSymbol];
525
- if (!alreadyHadObservers) {
526
- const makeObserver = (original) => function observeAttributes(qualifiedName, ...rest) {
527
- const observed = observedAttributes[this.tagName.toLowerCase()]?.manuallyObserved;
528
- if (observed?.has(qualifiedName)) {
529
- const oldValue = this.getAttribute(qualifiedName);
530
- const returns = original.call(this, qualifiedName, ...rest);
531
- const newValue = this.getAttribute(qualifiedName);
532
- this.attributeChangedCallback(qualifiedName, oldValue, newValue);
533
- return returns;
534
- } else {
535
- return original.call(this, qualifiedName, ...rest);
536
- }
537
- };
538
- ProxyComponent.prototype.setAttribute = makeObserver(ProxyComponent.prototype.setAttribute);
539
- ProxyComponent.prototype.toggleAttribute = makeObserver(ProxyComponent.prototype.toggleAttribute);
540
- ProxyComponent.prototype.removeAttribute = makeObserver(ProxyComponent.prototype.removeAttribute);
541
- }
542
- return observedAttributes;
543
- }
544
-
545
74
  // src/LitElement.ts
546
- import { Deferred as Deferred2, camelToKebab as camelToKebab3 } from "@arcgis/components-utils";
75
+ import { Deferred, camelToKebab, isEsriInternalEnv as isEsriInternalEnv2 } from "@arcgis/components-utils";
547
76
  import { LitElement as OriginalLitElement, isServer } from "lit";
548
77
  import { useControllerManager } from "@arcgis/components-controllers";
549
78
  var emptyFunction = () => void 0;
@@ -572,12 +101,12 @@ var LitElement = class _LitElement extends OriginalLitElement {
572
101
  */
573
102
  this.el = this.constructor.lazy ?? this;
574
103
  /**
575
- * Controller Manager orchestrates all components used by this component,
104
+ * Controller Manager orchestrates all controllers used by this component,
576
105
  * connecting their lifecycle hooks and providing context information.
577
106
  */
578
107
  this.manager = useControllerManager(this);
579
108
  /** @internal */
580
- this._postLoad = this.constructor.lazy?._postLoad ?? new Deferred2();
109
+ this._postLoad = this.constructor.lazy?._postLoad ?? new Deferred();
581
110
  /**
582
111
  * Direct offspring that should be awaited before loaded() is emitted.
583
112
  *
@@ -586,7 +115,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
586
115
  * @internal
587
116
  */
588
117
  this._offspring = this.constructor.lazy?._offspring ?? [];
589
- this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred2();
118
+ this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred();
590
119
  this._enableUpdating = this.enableUpdating;
591
120
  this.enableUpdating = emptyFunction;
592
121
  const ourShouldUpdate = _LitElement.prototype.shouldUpdate;
@@ -595,7 +124,17 @@ var LitElement = class _LitElement extends OriginalLitElement {
595
124
  this.shouldUpdate = ourShouldUpdate;
596
125
  }
597
126
  if (process.env.NODE_ENV !== "production") {
598
- globalThis.devOnly$luminaComponentRefCallback?.(this);
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;
132
+ if (!isOwnComponent && !warningsWereCustomized) {
133
+ constructor.disableWarning?.("change-in-update");
134
+ }
135
+ if (isEsriInternalEnv2()) {
136
+ globalThis.devOnly$luminaComponentRefCallback?.(this);
137
+ }
599
138
  }
600
139
  if (isServer) {
601
140
  this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
@@ -609,8 +148,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
609
148
  styles = styles.filter(Boolean);
610
149
  }
611
150
  const finalizedStyles = super.finalizeStyles(styles);
612
- const options = this.constructor.shadowRootOptions;
613
- const useLightDom = options === noShadowRoot;
151
+ const useLightDom = this.shadowRootOptions === noShadowRoot;
614
152
  return this.runtime?.commonStyles === void 0 || useLightDom ? finalizedStyles : [this.runtime.commonStyles, ...finalizedStyles];
615
153
  }
616
154
  static createProperty(name, options) {
@@ -633,7 +171,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
633
171
  *
634
172
  * Thus, overwriting Lit's default behavior to use kebab-case:
635
173
  */
636
- attribute: !!(flags & 1 /* ATTRIBUTE */) && typeof name === "string" ? camelToKebab3(name) : false,
174
+ attribute: !!(flags & 1 /* ATTRIBUTE */) && typeof name === "string" ? camelToKebab(name) : false,
637
175
  reflect: !!(flags & 2 /* REFLECT */),
638
176
  type: flags & 4 /* BOOLEAN */ ? Boolean : flags & 8 /* NUMBER */ ? Number : void 0,
639
177
  /**
@@ -758,7 +296,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
758
296
  }
759
297
  };
760
298
  LitElement.$createEvent = createEventFactory;
761
- if (process.env.NODE_ENV !== "production") {
299
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv2()) {
762
300
  const globalWithLit = globalThis;
763
301
  globalWithLit.litIssuedWarnings ??= /* @__PURE__ */ new Set();
764
302
  globalWithLit.litIssuedWarnings.add(
@@ -767,10 +305,31 @@ if (process.env.NODE_ENV !== "production") {
767
305
  }
768
306
 
769
307
  // src/runtime.ts
308
+ import { isEsriInternalEnv as isEsriInternalEnv3 } from "@arcgis/components-utils";
770
309
  function makeRuntime(options) {
771
310
  let assetPath;
772
311
  const setAssetPath = (path) => {
773
- assetPath = new URL(path, globalThis.location?.href).href;
312
+ assetPath = new URL(
313
+ path,
314
+ /**
315
+ * setAssetPath() is called in global scope whenever Lumina runtime is
316
+ * imported. Thus we need to carefully handle different environments.
317
+ *
318
+ * Need `|| undefined` because Stencil's unit tests mock-dock defines
319
+ * `location.href` as empty string, which crashes `new URL()`. Stencil's
320
+ * test environment does not define `NODE_ENV` by default, so we have to
321
+ * add a few bytes to production.
322
+ *
323
+ * For happy-dom and jsdom, we are assuming that `NODE_ENV` is set.
324
+ * Depending on configuration, `location?.href` is either undefined (not
325
+ * an exception) or `about:blank` (an exception - thus handling that case
326
+ * explicitly).
327
+ *
328
+ * For Node.js without a DOM environment, `location?.href` is undefined so
329
+ * all is good.
330
+ */
331
+ process.env.NODE_ENV === "test" ? globalThis.location?.href === "about:blank" ? void 0 : globalThis.location?.href || void 0 : globalThis.location?.href || void 0
332
+ ).href;
774
333
  };
775
334
  const runtime = {
776
335
  ...options,
@@ -789,13 +348,13 @@ function makeRuntime(options) {
789
348
  }
790
349
  };
791
350
  setAssetPath(options.defaultAssetPath);
792
- if (process.env.NODE_ENV !== "production") {
351
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv3()) {
793
352
  globalThis.devOnly$luminaRuntime = runtime;
794
353
  }
795
354
  return runtime;
796
355
  }
797
356
 
798
- // src/jsx/jsx.ts
357
+ // src/jsx/types.ts
799
358
  var Fragment = void 0;
800
359
  var bindAttribute = void 0;
801
360
  var bindBooleanAttribute = void 0;
@@ -828,24 +387,46 @@ var stringOrBoolean = {
828
387
  };
829
388
 
830
389
  // src/wrappersUtils.ts
831
- function createPrototypeProxy(tagName) {
832
- const customElement = {
390
+ var emptyObject = {};
391
+ var makeReactWrapperFactory = (react, createComponent) => (options) => {
392
+ const tagName = options.tagName;
393
+ let customElementPrototype = emptyObject;
394
+ const elementClass = {
833
395
  name: tagName,
396
+ /**
397
+ * Lit's createComponent tries to access the elementClass.prototype in
398
+ * global scope (in development mode). The elementClass may not be defined
399
+ * yet (because we are in a lazy loading build, or because current app
400
+ * doesn't import a given custom element as it doesn't use it).
401
+ *
402
+ * Thus, we return an empty object as a fake prototype.
403
+ *
404
+ * Right after the call to `createComponent`, we set to
405
+ * customElementPrototype undefined so that the next access of
406
+ * `.prototype` tries to get the real prototype.
407
+ * `createPrototypeProxy()` is called, this small proxy delays retrieving the custom
408
+ * element prototype until it is actually needed, and caches the result for future calls.
409
+ */
834
410
  get prototype() {
835
- const customElementPrototype = customElements.get(tagName)?.prototype;
836
- if (!customElementPrototype) {
837
- if (process.env.NODE_ENV === "production") {
411
+ if (customElementPrototype === void 0) {
412
+ customElementPrototype = customElements.get(tagName)?.prototype;
413
+ if (!customElementPrototype) {
838
414
  throw new Error(`Custom element "${tagName}" not found`);
839
- } else {
840
- return Object.create(HTMLElement.prototype);
841
415
  }
416
+ Object.defineProperty(elementClass, "prototype", { value: customElementPrototype });
842
417
  }
843
- Object.defineProperty(customElement, "prototype", customElementPrototype);
844
418
  return customElementPrototype;
845
419
  }
846
420
  };
847
- return customElement;
848
- }
421
+ const result = createComponent({
422
+ ...options,
423
+ react,
424
+ elementClass
425
+ });
426
+ customElementPrototype = void 0;
427
+ return result;
428
+ };
429
+ var getReactWrapperOptions = (tagNameAndElement, events) => ({ tagName: tagNameAndElement, events });
849
430
  export {
850
431
  Fragment,
851
432
  LitElement,
@@ -854,12 +435,11 @@ export {
854
435
  bindEvent,
855
436
  bindProperty,
856
437
  createEvent,
857
- createPrototypeProxy,
858
438
  directive,
859
- handleComponentMetaUpdate,
860
- handleHmrUpdate,
439
+ getReactWrapperOptions,
861
440
  live,
862
441
  makeDefineCustomElements,
442
+ makeReactWrapperFactory,
863
443
  makeRuntime,
864
444
  method,
865
445
  noChange,
@@ -870,5 +450,7 @@ export {
870
450
  safeStyleMap,
871
451
  setAttribute,
872
452
  state,
873
- stringOrBoolean
453
+ stringOrBoolean,
454
+ useContextConsumer,
455
+ useContextProvider
874
456
  };