@arcgis/lumina 4.32.0-next.7 → 4.32.0-next.71

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.
@@ -0,0 +1,127 @@
1
+ import {
2
+ ProxyComponent,
3
+ noShadowRoot
4
+ } from "./chunk-J3BVM76V.js";
5
+ import "./chunk-PGHUBTOM.js";
6
+
7
+ // src/hmrSupport.ts
8
+ import { camelToKebab } from "@arcgis/components-utils";
9
+ function handleHmrUpdate(newModules) {
10
+ newModules.forEach((newModule) => {
11
+ if (newModule === void 0) {
12
+ return;
13
+ }
14
+ Object.values(newModule).forEach((exported) => {
15
+ if (typeof exported !== "function" || typeof exported.tagName !== "string") {
16
+ return;
17
+ }
18
+ const LitConstructor = exported;
19
+ const ProxyClass = customElements.get(LitConstructor.tagName);
20
+ if (ProxyClass === void 0) {
21
+ throw new Error(`Failed to find custom element proxy for tag name: ${LitConstructor.tagName}`);
22
+ }
23
+ ProxyClass._LitConstructor = void 0;
24
+ ProxyClass._loadPromise = void 0;
25
+ ProxyClass._hmrIndex ??= 0;
26
+ ProxyClass._hmrIndex += 1;
27
+ ProxyClass._initializePrototype();
28
+ ProxyClass._hmrInstances?.forEach((instanceWeakRef) => {
29
+ const instance = instanceWeakRef.deref();
30
+ if (instance === void 0) {
31
+ return;
32
+ }
33
+ if (instance._litElement === void 0) {
34
+ void ProxyClass._loadPromise.then(() => reInitialize(instance, newModule));
35
+ } else {
36
+ reInitialize(instance, newModule);
37
+ }
38
+ });
39
+ return;
40
+ });
41
+ });
42
+ }
43
+ function reInitialize(instance, newModule) {
44
+ const PreviousLitConstructor = instance._litElement.constructor;
45
+ const isShadowRoot = PreviousLitConstructor.shadowRootOptions !== noShadowRoot;
46
+ if (!isShadowRoot) {
47
+ const root = instance.getRootNode() ?? document;
48
+ if ("adoptedStyleSheets" in root) {
49
+ const rootStyles = Array.from(root.adoptedStyleSheets);
50
+ PreviousLitConstructor.elementStyles.forEach((style) => {
51
+ const styleSheet = "styleSheet" in style ? style.styleSheet : style;
52
+ const index = rootStyles.lastIndexOf(styleSheet);
53
+ if (index > -1) {
54
+ rootStyles.splice(index, 1);
55
+ }
56
+ });
57
+ root.adoptedStyleSheets = rootStyles;
58
+ }
59
+ }
60
+ const properties = PreviousLitConstructor.elementProperties;
61
+ const preservedProperties = Array.from(properties.entries()).filter(
62
+ ([propertyName, descriptor]) => typeof propertyName === "string" && (instance._hmrSetProps.has(propertyName) || typeof descriptor.attribute === "string" && instance._hmrSetAttributes.has(descriptor.attribute))
63
+ ).map(([key]) => [key, instance[key]]);
64
+ instance._store = Object.fromEntries(preservedProperties);
65
+ if (instance.isConnected) {
66
+ instance._litElement.disconnectedCallback();
67
+ }
68
+ const renderRoot = instance._litElement?.renderRoot;
69
+ if (renderRoot) {
70
+ renderRoot._$litPart$ = void 0;
71
+ while (renderRoot.firstChild) {
72
+ renderRoot.removeChild(renderRoot.firstChild);
73
+ }
74
+ }
75
+ instance._initializeComponent(newModule);
76
+ }
77
+ function handleComponentMetaUpdate(meta) {
78
+ const ProxyClass = customElements.get(meta.tagName);
79
+ if (ProxyClass === void 0) {
80
+ return;
81
+ }
82
+ const attributes = meta.properties.map(([property, attribute]) => attribute ?? camelToKebab(property)).filter(Boolean);
83
+ const observedAttributes = initializeAttributeObserver();
84
+ observedAttributes[meta.tagName] ??= {};
85
+ observedAttributes[meta.tagName].original ??= new Set(ProxyClass.observedAttributes);
86
+ const originallyObserved = observedAttributes[meta.tagName].original;
87
+ observedAttributes[meta.tagName].manuallyObserved = new Set(
88
+ /**
89
+ * Never manually observe attributes that were in the original
90
+ * observedAttributes as those would be observed by the browser
91
+ */
92
+ attributes.filter((attribute) => !originallyObserved.has(attribute))
93
+ );
94
+ ProxyClass._asyncMethods = meta.asyncMethods;
95
+ ProxyClass._syncMethods = meta.syncMethods;
96
+ ProxyClass._properties = meta.properties.map(([name]) => name);
97
+ ProxyClass.observedAttributes = attributes;
98
+ }
99
+ function initializeAttributeObserver() {
100
+ const observedAttributesSymbol = Symbol.for("@arcgis/lumina:observedAttributes");
101
+ const globalThisWithObservedAttributes = globalThis;
102
+ const alreadyHadObservers = observedAttributesSymbol in globalThisWithObservedAttributes;
103
+ globalThisWithObservedAttributes[observedAttributesSymbol] ??= {};
104
+ const observedAttributes = globalThisWithObservedAttributes[observedAttributesSymbol];
105
+ if (!alreadyHadObservers) {
106
+ const makeObserver = (original) => function observeAttributes(qualifiedName, ...rest) {
107
+ const observed = observedAttributes[this.tagName.toLowerCase()]?.manuallyObserved;
108
+ if (observed?.has(qualifiedName)) {
109
+ const oldValue = this.getAttribute(qualifiedName);
110
+ const returns = original.call(this, qualifiedName, ...rest);
111
+ const newValue = this.getAttribute(qualifiedName);
112
+ this.attributeChangedCallback(qualifiedName, oldValue, newValue);
113
+ return returns;
114
+ } else {
115
+ return original.call(this, qualifiedName, ...rest);
116
+ }
117
+ };
118
+ ProxyComponent.prototype.setAttribute = makeObserver(ProxyComponent.prototype.setAttribute);
119
+ ProxyComponent.prototype.toggleAttribute = makeObserver(ProxyComponent.prototype.toggleAttribute);
120
+ ProxyComponent.prototype.removeAttribute = makeObserver(ProxyComponent.prototype.removeAttribute);
121
+ }
122
+ return observedAttributes;
123
+ }
124
+ export {
125
+ handleComponentMetaUpdate,
126
+ handleHmrUpdate
127
+ };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
+ export { useContextProvider, useContextConsumer } from "./context";
1
2
  export type { EventOptions } from "./createEvent";
2
3
  export { createEvent } from "./createEvent";
3
4
  export { state, property, method } from "./decorators";
4
- export type { HmrComponentMeta } from "./hmrSupport";
5
- export { handleComponentMetaUpdate, handleHmrUpdate } from "./hmrSupport";
6
5
  export type { DefineCustomElements, LazyLoadOptions, GlobalThisWithPuppeteerEnv } from "./lazyLoad";
7
6
  export { makeDefineCustomElements } from "./lazyLoad";
8
7
  export { LitElement } from "./LitElement";
9
8
  export type { PublicLitElement } from "./PublicLitElement";
10
9
  export type { Runtime, RuntimeOptions, DevOnlyGlobalRuntime, DevOnlyGlobalComponentRefCallback } from "./runtime";
11
10
  export { makeRuntime } from "./runtime";
12
- export * from "./jsx/jsx";
11
+ export type { EventHandler } from "./jsx/baseTypes";
12
+ export * from "./jsx/types";
13
13
  export { safeClassMap, safeStyleMap, directive, live } from "./jsx/directives";
14
14
  export { nothing, noChange, setAttribute, stringOrBoolean } from "./jsx/utils";
15
15
  export { noShadowRoot } from "./utils";
16
- export { createPrototypeProxy } from "./wrappersUtils";
16
+ export { makeReactWrapperFactory, getReactWrapperOptions } from "./wrappersUtils";