@arcgis/lumina 4.32.0-next.8 → 4.32.0-next.80

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