@arcgis/lumina 4.32.0-next.20 → 4.32.0-next.22
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/PublicLitElement.d.ts +1 -0
- package/dist/chunk-PEVP6JYY.js +424 -0
- package/dist/context.d.ts +26 -0
- package/dist/hmrSupport.d.ts +5 -0
- package/dist/hmrSupport.js +121 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +30 -518
- package/dist/jsx/directives.d.ts +4 -0
- package/dist/jsx/jsx.d.ts +32 -9
- package/dist/lazyLoad.d.ts +13 -2
- package/dist/runtime.d.ts +4 -0
- package/dist/typings/jsxGlobals.d.ts +17 -19
- package/dist/wrappersUtils.d.ts +2 -0
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
2
|
+
attachToAncestor,
|
|
3
|
+
makeDefineCustomElements,
|
|
4
|
+
noShadowRoot
|
|
5
|
+
} from "./chunk-PEVP6JYY.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 =
|
|
25
|
+
import { retrieveComponent as retrieveComponent2, trackPropertyKey, keyTrackResolve } from "@arcgis/components-controllers";
|
|
26
|
+
var createEventFactory = (eventName = "", options = {}, component = retrieveComponent2()) => {
|
|
10
27
|
const emitter = {
|
|
11
28
|
emit: (payload) => {
|
|
12
29
|
if (process.env.NODE_ENV !== "production" && !component.el.isConnected) {
|
|
@@ -53,513 +70,8 @@ import { property as litProperty } from "@lit/reactive-element/decorators/proper
|
|
|
53
70
|
var property = litProperty;
|
|
54
71
|
var method = void 0;
|
|
55
72
|
|
|
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
|
-
const store = this._store;
|
|
356
|
-
if (process.env.NODE_ENV !== "production") {
|
|
357
|
-
Object.entries(module).forEach(([name, LitConstructor2]) => {
|
|
358
|
-
if (name !== "exportsForTests" && typeof LitConstructor2 !== "function" || typeof LitConstructor2.tagName !== "string") {
|
|
359
|
-
console.warn(
|
|
360
|
-
`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.`
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
const LitConstructor = Object.values(module).find(
|
|
366
|
-
(LitConstructor2) => LitConstructor2.tagName === tagName
|
|
367
|
-
);
|
|
368
|
-
if (process.env.NODE_ENV !== "production" && !LitConstructor) {
|
|
369
|
-
throw new Error(
|
|
370
|
-
`Unable to find the LitElement class for the "${tagName}" custom element in the lazy-loaded module`
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
const lazyTagName = process.env.NODE_ENV === "production" ? `${tagName}--lazy` : (ProxyClass._hmrIndex ?? 0) === 0 ? `${tagName}--lazy` : `${tagName}--lazy-${ProxyClass._hmrIndex}`;
|
|
374
|
-
const isFirstInitialization = !ProxyClass._LitConstructor;
|
|
375
|
-
if (isFirstInitialization) {
|
|
376
|
-
ProxyClass._LitConstructor = LitConstructor;
|
|
377
|
-
LitConstructor.prototype.removeAttribute = function(qualifiedName) {
|
|
378
|
-
HTMLElement.prototype.removeAttribute.call(this.el, qualifiedName);
|
|
379
|
-
};
|
|
380
|
-
LitConstructor.prototype.setAttribute = function(qualifiedName, value) {
|
|
381
|
-
HTMLElement.prototype.setAttribute.call(this.el, qualifiedName, value);
|
|
382
|
-
};
|
|
383
|
-
defineProperty(LitConstructor.prototype, "isConnected", {
|
|
384
|
-
get() {
|
|
385
|
-
return this.el.isConnected;
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
if (process.env.NODE_ENV !== "production" && LitConstructor.shadowRootOptions !== noShadowRoot) {
|
|
389
|
-
let prototype = LitConstructor;
|
|
390
|
-
while (prototype && !Object.hasOwn(prototype, "lumina")) {
|
|
391
|
-
prototype = Object.getPrototypeOf(prototype);
|
|
392
|
-
}
|
|
393
|
-
devOnlyDetectIncorrectLazyUsages(prototype);
|
|
394
|
-
}
|
|
395
|
-
customElements.define(lazyTagName, LitConstructor);
|
|
396
|
-
}
|
|
397
|
-
LitConstructor.lazy = this;
|
|
398
|
-
const litElement = document.createElement(lazyTagName);
|
|
399
|
-
LitConstructor.lazy = void 0;
|
|
400
|
-
if (process.env.NODE_ENV !== "production") {
|
|
401
|
-
Object.defineProperty(this, "_litElement", {
|
|
402
|
-
value: litElement,
|
|
403
|
-
configurable: true,
|
|
404
|
-
enumerable: false
|
|
405
|
-
});
|
|
406
|
-
} else {
|
|
407
|
-
this._litElement = litElement;
|
|
408
|
-
}
|
|
409
|
-
this._store = litElement;
|
|
410
|
-
this._pendingAttributes.forEach((name) => {
|
|
411
|
-
const value = this.getAttribute(name);
|
|
412
|
-
litElement.attributeChangedCallback(
|
|
413
|
-
name,
|
|
414
|
-
// Lit doesn't look at this value, thus even if attribute already exists, that's ok
|
|
415
|
-
null,
|
|
416
|
-
value
|
|
417
|
-
);
|
|
418
|
-
});
|
|
419
|
-
Object.entries(store).forEach(syncLitElement, litElement);
|
|
420
|
-
if (process.env.NODE_ENV !== "production") {
|
|
421
|
-
const litObserved = LitConstructor.observedAttributes ?? [];
|
|
422
|
-
const lazyObserved = ProxyClass.observedAttributes ?? [];
|
|
423
|
-
const missingFromLazy = litObserved.filter((attribute) => !lazyObserved.includes(attribute));
|
|
424
|
-
const missingFromLit = lazyObserved.filter((attribute) => !litObserved.includes(attribute));
|
|
425
|
-
if (missingFromLazy.length > 0) {
|
|
426
|
-
console.warn(
|
|
427
|
-
`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`
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
if (missingFromLit.length > 0) {
|
|
431
|
-
console.warn(
|
|
432
|
-
`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`
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
const isStillConnected = this.isConnected;
|
|
437
|
-
if (isStillConnected || this._ancestorLoad) {
|
|
438
|
-
litElement.connectedCallback?.();
|
|
439
|
-
if (!isStillConnected) {
|
|
440
|
-
litElement.disconnectedCallback();
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
function syncLitElement([key, value]) {
|
|
446
|
-
this[key] = value;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// src/hmrSupport.ts
|
|
450
|
-
import { camelToKebab as camelToKebab2 } from "@arcgis/components-utils";
|
|
451
|
-
function handleHmrUpdate(newModules) {
|
|
452
|
-
newModules.forEach((newModule) => {
|
|
453
|
-
if (newModule === void 0) {
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
|
-
Object.values(newModule).forEach((exported) => {
|
|
457
|
-
if (typeof exported !== "function" || typeof exported.tagName !== "string") {
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
const LitConstructor = exported;
|
|
461
|
-
const ProxyClass = customElements.get(LitConstructor.tagName);
|
|
462
|
-
if (ProxyClass === void 0) {
|
|
463
|
-
throw new Error(`Failed to find custom element proxy for tag name: ${LitConstructor.tagName}`);
|
|
464
|
-
}
|
|
465
|
-
ProxyClass._LitConstructor = void 0;
|
|
466
|
-
ProxyClass._loadPromise = void 0;
|
|
467
|
-
ProxyClass._hmrIndex ??= 0;
|
|
468
|
-
ProxyClass._hmrIndex += 1;
|
|
469
|
-
ProxyClass._initializePrototype();
|
|
470
|
-
ProxyClass._hmrInstances?.forEach((instanceWeakRef) => {
|
|
471
|
-
const instance = instanceWeakRef.deref();
|
|
472
|
-
if (instance === void 0) {
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
if (instance._litElement === void 0) {
|
|
476
|
-
void ProxyClass._loadPromise.then(() => reInitialize(instance, newModule));
|
|
477
|
-
} else {
|
|
478
|
-
reInitialize(instance, newModule);
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
return;
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
function reInitialize(instance, newModule) {
|
|
486
|
-
const PreviousLitConstructor = instance._litElement.constructor;
|
|
487
|
-
const isShadowRoot = PreviousLitConstructor.shadowRootOptions !== noShadowRoot;
|
|
488
|
-
if (!isShadowRoot) {
|
|
489
|
-
const root = instance.getRootNode() ?? document;
|
|
490
|
-
if ("adoptedStyleSheets" in root) {
|
|
491
|
-
const rootStyles = Array.from(root.adoptedStyleSheets);
|
|
492
|
-
PreviousLitConstructor.elementStyles.forEach((style) => {
|
|
493
|
-
const styleSheet = "styleSheet" in style ? style.styleSheet : style;
|
|
494
|
-
const index = rootStyles.lastIndexOf(styleSheet);
|
|
495
|
-
if (index > -1) {
|
|
496
|
-
rootStyles.splice(index, 1);
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
root.adoptedStyleSheets = rootStyles;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
const properties = PreviousLitConstructor.elementProperties;
|
|
503
|
-
const preservedProperties = Array.from(properties.entries()).filter(
|
|
504
|
-
([propertyName, descriptor]) => typeof propertyName === "string" && (instance._hmrSetProps.has(propertyName) || typeof descriptor.attribute === "string" && instance._hmrSetAttributes.has(descriptor.attribute))
|
|
505
|
-
).map(([key]) => [key, instance[key]]);
|
|
506
|
-
instance._store = Object.fromEntries(preservedProperties);
|
|
507
|
-
const isConnected = instance.isConnected;
|
|
508
|
-
if (isConnected) {
|
|
509
|
-
instance._litElement.disconnectedCallback();
|
|
510
|
-
}
|
|
511
|
-
instance._initializeComponent(newModule);
|
|
512
|
-
}
|
|
513
|
-
function handleComponentMetaUpdate(meta) {
|
|
514
|
-
const ProxyClass = customElements.get(meta.tagName);
|
|
515
|
-
if (ProxyClass === void 0) {
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
const attributes = meta.properties.map(([property2, attribute]) => attribute ?? camelToKebab2(property2)).filter(Boolean);
|
|
519
|
-
const observedAttributes = initializeAttributeObserver();
|
|
520
|
-
observedAttributes[meta.tagName] ??= {};
|
|
521
|
-
observedAttributes[meta.tagName].original ??= new Set(ProxyClass.observedAttributes);
|
|
522
|
-
const originallyObserved = observedAttributes[meta.tagName].original;
|
|
523
|
-
observedAttributes[meta.tagName].manuallyObserved = new Set(
|
|
524
|
-
/**
|
|
525
|
-
* Never manually observe attributes that were in the original
|
|
526
|
-
* observedAttributes as those would be observed by the browser
|
|
527
|
-
*/
|
|
528
|
-
attributes.filter((attribute) => !originallyObserved.has(attribute))
|
|
529
|
-
);
|
|
530
|
-
ProxyClass._asyncMethods = meta.asyncMethods;
|
|
531
|
-
ProxyClass._syncMethods = meta.syncMethods;
|
|
532
|
-
ProxyClass._properties = meta.properties.map(([name]) => name);
|
|
533
|
-
ProxyClass.observedAttributes = attributes;
|
|
534
|
-
}
|
|
535
|
-
function initializeAttributeObserver() {
|
|
536
|
-
const observedAttributesSymbol = Symbol.for("@arcgis/lumina:observedAttributes");
|
|
537
|
-
const globalThisWithObservedAttributes = globalThis;
|
|
538
|
-
const alreadyHadObservers = observedAttributesSymbol in globalThisWithObservedAttributes;
|
|
539
|
-
globalThisWithObservedAttributes[observedAttributesSymbol] ??= {};
|
|
540
|
-
const observedAttributes = globalThisWithObservedAttributes[observedAttributesSymbol];
|
|
541
|
-
if (!alreadyHadObservers) {
|
|
542
|
-
const makeObserver = (original) => function observeAttributes(qualifiedName, ...rest) {
|
|
543
|
-
const observed = observedAttributes[this.tagName.toLowerCase()]?.manuallyObserved;
|
|
544
|
-
if (observed?.has(qualifiedName)) {
|
|
545
|
-
const oldValue = this.getAttribute(qualifiedName);
|
|
546
|
-
const returns = original.call(this, qualifiedName, ...rest);
|
|
547
|
-
const newValue = this.getAttribute(qualifiedName);
|
|
548
|
-
this.attributeChangedCallback(qualifiedName, oldValue, newValue);
|
|
549
|
-
return returns;
|
|
550
|
-
} else {
|
|
551
|
-
return original.call(this, qualifiedName, ...rest);
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
ProxyComponent.prototype.setAttribute = makeObserver(ProxyComponent.prototype.setAttribute);
|
|
555
|
-
ProxyComponent.prototype.toggleAttribute = makeObserver(ProxyComponent.prototype.toggleAttribute);
|
|
556
|
-
ProxyComponent.prototype.removeAttribute = makeObserver(ProxyComponent.prototype.removeAttribute);
|
|
557
|
-
}
|
|
558
|
-
return observedAttributes;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
73
|
// src/LitElement.ts
|
|
562
|
-
import { Deferred
|
|
74
|
+
import { Deferred, camelToKebab } from "@arcgis/components-utils";
|
|
563
75
|
import { LitElement as OriginalLitElement, isServer } from "lit";
|
|
564
76
|
import { useControllerManager } from "@arcgis/components-controllers";
|
|
565
77
|
var emptyFunction = () => void 0;
|
|
@@ -593,7 +105,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
|
|
|
593
105
|
*/
|
|
594
106
|
this.manager = useControllerManager(this);
|
|
595
107
|
/** @internal */
|
|
596
|
-
this._postLoad = this.constructor.lazy?._postLoad ?? new
|
|
108
|
+
this._postLoad = this.constructor.lazy?._postLoad ?? new Deferred();
|
|
597
109
|
/**
|
|
598
110
|
* Direct offspring that should be awaited before loaded() is emitted.
|
|
599
111
|
*
|
|
@@ -602,7 +114,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
|
|
|
602
114
|
* @internal
|
|
603
115
|
*/
|
|
604
116
|
this._offspring = this.constructor.lazy?._offspring ?? [];
|
|
605
|
-
this._postLoaded = this.constructor.lazy?._postLoaded ?? new
|
|
117
|
+
this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred();
|
|
606
118
|
this._enableUpdating = this.enableUpdating;
|
|
607
119
|
this.enableUpdating = emptyFunction;
|
|
608
120
|
const ourShouldUpdate = _LitElement.prototype.shouldUpdate;
|
|
@@ -648,7 +160,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
|
|
|
648
160
|
*
|
|
649
161
|
* Thus, overwriting Lit's default behavior to use kebab-case:
|
|
650
162
|
*/
|
|
651
|
-
attribute: !!(flags & 1 /* ATTRIBUTE */) && typeof name === "string" ?
|
|
163
|
+
attribute: !!(flags & 1 /* ATTRIBUTE */) && typeof name === "string" ? camelToKebab(name) : false,
|
|
652
164
|
reflect: !!(flags & 2 /* REFLECT */),
|
|
653
165
|
type: flags & 4 /* BOOLEAN */ ? Boolean : flags & 8 /* NUMBER */ ? Number : void 0,
|
|
654
166
|
/**
|
|
@@ -871,8 +383,6 @@ export {
|
|
|
871
383
|
createEvent,
|
|
872
384
|
createPrototypeProxy,
|
|
873
385
|
directive,
|
|
874
|
-
handleComponentMetaUpdate,
|
|
875
|
-
handleHmrUpdate,
|
|
876
386
|
live,
|
|
877
387
|
makeDefineCustomElements,
|
|
878
388
|
makeRuntime,
|
|
@@ -885,5 +395,7 @@ export {
|
|
|
885
395
|
safeStyleMap,
|
|
886
396
|
setAttribute,
|
|
887
397
|
state,
|
|
888
|
-
stringOrBoolean
|
|
398
|
+
stringOrBoolean,
|
|
399
|
+
useContextConsumer,
|
|
400
|
+
useContextProvider
|
|
889
401
|
};
|
package/dist/jsx/directives.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ import type { DirectiveClass } from "lit-html/directive.js";
|
|
|
26
26
|
* Instead, if the prop value is a object definition, variable reference,
|
|
27
27
|
* ternary expression or etc, the `safeClassMap` will be called, which will
|
|
28
28
|
* determine at runtime if directive should be called
|
|
29
|
+
*
|
|
30
|
+
* @private
|
|
29
31
|
*/
|
|
30
32
|
export declare const safeClassMap: (parameters: ClassInfo | Nil | string) => DirectiveResult<typeof ClassMapDirective> | Nil | string;
|
|
31
33
|
/**
|
|
@@ -49,6 +51,8 @@ export declare const safeClassMap: (parameters: ClassInfo | Nil | string) => Dir
|
|
|
49
51
|
* Instead, if the prop value is a object definition, variable reference,
|
|
50
52
|
* ternary expression or etc, the `safeStyleMap` will be called, which will
|
|
51
53
|
* determine at runtime if directive should be called
|
|
54
|
+
*
|
|
55
|
+
* @private
|
|
52
56
|
*/
|
|
53
57
|
export declare const safeStyleMap: (parameters: CssProperties | Nil | string) => DirectiveResult<typeof StyleMapDirective> | Nil | string;
|
|
54
58
|
/**
|