@arcgis/lumina 4.32.0-next.21 → 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/hmrSupport.d.ts +5 -0
- package/dist/hmrSupport.js +121 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +9 -536
- package/dist/jsx/directives.d.ts +4 -0
- package/dist/jsx/jsx.d.ts +31 -5
- package/dist/lazyLoad.d.ts +5 -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 +4 -3
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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";
|
|
6
7
|
|
|
7
8
|
// src/context.ts
|
|
8
9
|
import { retrieveComponent } from "@arcgis/components-controllers";
|
|
@@ -69,534 +70,8 @@ import { property as litProperty } from "@lit/reactive-element/decorators/proper
|
|
|
69
70
|
var property = litProperty;
|
|
70
71
|
var method = void 0;
|
|
71
72
|
|
|
72
|
-
// src/lazyLoad.ts
|
|
73
|
-
import { Deferred, camelToKebab } from "@arcgis/components-utils";
|
|
74
|
-
|
|
75
|
-
// src/devOnlyDetectIncorrectLazyUsages.ts
|
|
76
|
-
function devOnlyDetectIncorrectLazyUsages(LitClass) {
|
|
77
|
-
const genericPrototype = LitClass.prototype;
|
|
78
|
-
const descriptor = Object.getOwnPropertyDescriptor(genericPrototype, "innerText");
|
|
79
|
-
if (descriptor !== void 0 && descriptor.get === descriptor.set) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const allowList = /* @__PURE__ */ new Set([
|
|
83
|
-
// We shouldn't be overwriting this property
|
|
84
|
-
"constructor",
|
|
85
|
-
// Called by Lit - we proxy it to this.el in ProxyComponent
|
|
86
|
-
"setAttribute",
|
|
87
|
-
// Called by Lit SSR - we proxy it to this.el in ProxyComponent
|
|
88
|
-
"removeAttribute",
|
|
89
|
-
// Called by Lit - we proxy it to this.el in ProxyComponent
|
|
90
|
-
"isConnected",
|
|
91
|
-
// Called by Lit, but only in dev mode for warnings, so we don't have to proxy.
|
|
92
|
-
"localName",
|
|
93
|
-
// Called by Lit Context - we proxy it to this.el in ProxyComponent.
|
|
94
|
-
// Interestingly, they never call removeEventListener.
|
|
95
|
-
"addEventListener"
|
|
96
|
-
]);
|
|
97
|
-
const customErrorMessages = {
|
|
98
|
-
addEventListener: "use this.listen() or this.el.addEventListener()"
|
|
99
|
-
};
|
|
100
|
-
Object.entries({
|
|
101
|
-
...Object.getOwnPropertyDescriptors(HTMLElement.prototype),
|
|
102
|
-
...Object.getOwnPropertyDescriptors(Element.prototype),
|
|
103
|
-
...Object.getOwnPropertyDescriptors(Node.prototype),
|
|
104
|
-
...Object.getOwnPropertyDescriptors(EventTarget.prototype)
|
|
105
|
-
}).forEach(([key, value]) => {
|
|
106
|
-
if (allowList.has(key)) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const callback = (...args) => {
|
|
110
|
-
if (key === "hasAttribute" && args[0] === "defer-hydration") {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
throw new Error(
|
|
114
|
-
`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}`}`
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
if (typeof value.value === "function") {
|
|
118
|
-
genericPrototype[key] = callback;
|
|
119
|
-
} else {
|
|
120
|
-
Object.defineProperty(genericPrototype, key, { get: callback, set: callback });
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// src/lifecycleSupport.ts
|
|
126
|
-
function attachToAncestor(child) {
|
|
127
|
-
let ancestor = child;
|
|
128
|
-
while (ancestor = ancestor.parentNode ?? ancestor.host) {
|
|
129
|
-
if (ancestor?.constructor?.lumina) {
|
|
130
|
-
const litParent = ancestor;
|
|
131
|
-
if (!litParent.manager?.loadedCalled) {
|
|
132
|
-
litParent._offspring.push(child);
|
|
133
|
-
}
|
|
134
|
-
return litParent._postLoad.promise;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// src/lazyLoad.ts
|
|
141
|
-
var makeDefineCustomElements = (runtime, structure) => function defineCustomElements(windowOrOptions, options) {
|
|
142
|
-
if (!globalThis.customElements) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const resolvedOptions = options ?? windowOrOptions ?? {};
|
|
146
|
-
const resourcesUrl = resolvedOptions.resourcesUrl;
|
|
147
|
-
if (resourcesUrl) {
|
|
148
|
-
runtime.setAssetPath(resourcesUrl);
|
|
149
|
-
}
|
|
150
|
-
Object.entries(structure).forEach(createLazyElement);
|
|
151
|
-
};
|
|
152
|
-
function createLazyElement([tagName, [load, compactMeta = ""]]) {
|
|
153
|
-
if (customElements.get(tagName)) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const [compactObservedProps, compactAsyncMethods, compactSyncMethods] = compactMeta.split(lazyMetaGroupJoiner);
|
|
157
|
-
const observedProps = compactObservedProps ? compactObservedProps?.split(lazyMetaItemJoiner).map(parseCondensedProp) : void 0;
|
|
158
|
-
const observedProperties = observedProps?.map(([property2]) => property2);
|
|
159
|
-
const ProxyClass = class extends ProxyComponent {
|
|
160
|
-
static {
|
|
161
|
-
this.observedAttributes = observedProps?.map(([, attribute]) => attribute).filter((attribute) => attribute !== "");
|
|
162
|
-
}
|
|
163
|
-
static {
|
|
164
|
-
this._properties = observedProperties;
|
|
165
|
-
}
|
|
166
|
-
static {
|
|
167
|
-
this._asyncMethods = compactAsyncMethods ? compactAsyncMethods?.split(lazyMetaItemJoiner) : void 0;
|
|
168
|
-
}
|
|
169
|
-
static {
|
|
170
|
-
this._syncMethods = compactSyncMethods?.split(lazyMetaItemJoiner);
|
|
171
|
-
}
|
|
172
|
-
static {
|
|
173
|
-
this._name = tagName;
|
|
174
|
-
}
|
|
175
|
-
constructor() {
|
|
176
|
-
const isFirstInstanceOfType = !ProxyClass._loadPromise;
|
|
177
|
-
if (isFirstInstanceOfType) {
|
|
178
|
-
ProxyClass._loadPromise = load();
|
|
179
|
-
ProxyClass._initializePrototype();
|
|
180
|
-
}
|
|
181
|
-
super();
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
customElements.define(tagName, ProxyClass);
|
|
185
|
-
}
|
|
186
|
-
var defineProperty = Object.defineProperty;
|
|
187
|
-
function parseCondensedProp(propAndAttribute) {
|
|
188
|
-
const name = propAndAttribute.split(lazyMetaSubItemJoiner);
|
|
189
|
-
return name.length === 1 ? [name[0], camelToKebab(name[0])] : name;
|
|
190
|
-
}
|
|
191
|
-
var HtmlElement = globalThis.HTMLElement ?? parseCondensedProp;
|
|
192
|
-
var ProxyComponent = class extends HtmlElement {
|
|
193
|
-
constructor() {
|
|
194
|
-
super();
|
|
195
|
-
/** @internal */
|
|
196
|
-
this._store = {};
|
|
197
|
-
/**
|
|
198
|
-
* If attributeChangedCallback() is called before the LitElement is loaded,
|
|
199
|
-
* store the attributes here, and replay later
|
|
200
|
-
*/
|
|
201
|
-
this._pendingAttributes = [];
|
|
202
|
-
/**
|
|
203
|
-
* Resolved once LitElement's load() is complete.
|
|
204
|
-
* Not read inside of this class, but needed for LitElement to determine if
|
|
205
|
-
* it's closest ancestor finished load()
|
|
206
|
-
*/
|
|
207
|
-
this._postLoad = new Deferred();
|
|
208
|
-
/**
|
|
209
|
-
* Resolved once LitElement's loaded() is complete
|
|
210
|
-
*/
|
|
211
|
-
this._postLoaded = new Deferred();
|
|
212
|
-
/**
|
|
213
|
-
* Direct offspring that should be awaited before loaded() is emitted
|
|
214
|
-
*/
|
|
215
|
-
this._offspring = [];
|
|
216
|
-
if (process.env.NODE_ENV !== "production") {
|
|
217
|
-
this._hmrSetProps = /* @__PURE__ */ new Set();
|
|
218
|
-
this._hmrSetAttributes = /* @__PURE__ */ new Set();
|
|
219
|
-
globalThis.devOnly$createdElements ??= [];
|
|
220
|
-
globalThis.devOnly$createdElements.push(new WeakRef(this));
|
|
221
|
-
}
|
|
222
|
-
this._saveInstanceProperties();
|
|
223
|
-
const ProxyClass = this.constructor;
|
|
224
|
-
if (ProxyClass._LitConstructor) {
|
|
225
|
-
this._initializeComponent({ a: ProxyClass._LitConstructor });
|
|
226
|
-
} else {
|
|
227
|
-
void ProxyClass._loadPromise.then(this._initializeComponent.bind(this)).catch((error) => {
|
|
228
|
-
this._postLoaded.reject(error);
|
|
229
|
-
setTimeout(() => {
|
|
230
|
-
throw error;
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
if (process.env.NODE_ENV !== "production") {
|
|
235
|
-
ProxyClass._hmrInstances ??= [];
|
|
236
|
-
ProxyClass._hmrInstances.push(new WeakRef(this));
|
|
237
|
-
Object.defineProperty(this, "_store", {
|
|
238
|
-
value: this._store,
|
|
239
|
-
enumerable: false,
|
|
240
|
-
configurable: true
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
static {
|
|
245
|
-
this.lumina = true;
|
|
246
|
-
}
|
|
247
|
-
/** @internal */
|
|
248
|
-
static _initializePrototype() {
|
|
249
|
-
this._properties?.forEach(this._bindProp, this);
|
|
250
|
-
this._asyncMethods?.forEach(this._bindAsync, this);
|
|
251
|
-
this._syncMethods?.forEach(this._bindSync, this);
|
|
252
|
-
}
|
|
253
|
-
static _bindProp(propName) {
|
|
254
|
-
defineProperty(this.prototype, propName, {
|
|
255
|
-
configurable: true,
|
|
256
|
-
enumerable: true,
|
|
257
|
-
get() {
|
|
258
|
-
return this._store[propName];
|
|
259
|
-
},
|
|
260
|
-
set(value) {
|
|
261
|
-
this._store[propName] = value;
|
|
262
|
-
if (process.env.NODE_ENV !== "production") {
|
|
263
|
-
this._hmrSetProps.add(propName);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
static _bindAsync(methodName) {
|
|
269
|
-
defineProperty(this.prototype, methodName, {
|
|
270
|
-
async value(...args) {
|
|
271
|
-
if (!this._litElement) {
|
|
272
|
-
await this._postLoaded.promise;
|
|
273
|
-
}
|
|
274
|
-
const genericLitElement = this._litElement;
|
|
275
|
-
return await genericLitElement[methodName](...args);
|
|
276
|
-
},
|
|
277
|
-
configurable: true
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
static _bindSync(methodName) {
|
|
281
|
-
defineProperty(this.prototype, methodName, {
|
|
282
|
-
value(...args) {
|
|
283
|
-
if (process.env.NODE_ENV === "development" && !this._litElement) {
|
|
284
|
-
const ProxyClass = this.constructor;
|
|
285
|
-
throw new Error(
|
|
286
|
-
`Tried to call method ${methodName}() on <${ProxyClass._name}> component before it's fully loaded. Please do 'await component.componentOnReady();' before calling this method.`
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
const genericLitElement = this._litElement;
|
|
290
|
-
return genericLitElement[methodName](...args);
|
|
291
|
-
},
|
|
292
|
-
configurable: true
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
get manager() {
|
|
296
|
-
return this._litElement?.manager;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Until the custom element is registered on the page, an instance of that
|
|
300
|
-
* element can be constructed and some properties on that instance set.
|
|
301
|
-
*
|
|
302
|
-
* These properties are set before the element prototype is set to this proxy
|
|
303
|
-
* class and thus none of our getters/setters are yet registered - such
|
|
304
|
-
* properties will be set by JavaScript on the instance directly.
|
|
305
|
-
*
|
|
306
|
-
* Once element is registered, the properties set in the meanwhile will shadow
|
|
307
|
-
* the getter/setters, and thus break reactivity. The fix is to delete these
|
|
308
|
-
* properties from the instance, and re-apply them once accessors are set.
|
|
309
|
-
*
|
|
310
|
-
* @example
|
|
311
|
-
* ```ts
|
|
312
|
-
* import { defineCustomElements } from '@arcgis/map-components';
|
|
313
|
-
* const map = document.createElement('arcgis-map');
|
|
314
|
-
* // This will shadow the getter/setters
|
|
315
|
-
* map.itemId = '...';
|
|
316
|
-
* // This finally defines the custom elements and sets the property accessors
|
|
317
|
-
* defineCustomElements();
|
|
318
|
-
* ```
|
|
319
|
-
*
|
|
320
|
-
* @remarks
|
|
321
|
-
* This is an equivalent of the __saveInstanceProperties method in Lit's
|
|
322
|
-
* ReactiveElement. Lit takes care of this on LitElement, but we have to take
|
|
323
|
-
* care of this on the lazy proxy
|
|
324
|
-
*/
|
|
325
|
-
_saveInstanceProperties() {
|
|
326
|
-
const ProxyClass = this.constructor;
|
|
327
|
-
const genericThis = this;
|
|
328
|
-
ProxyClass._properties?.forEach((propName) => {
|
|
329
|
-
if (Object.hasOwn(this, propName)) {
|
|
330
|
-
this._store[propName] = genericThis[propName];
|
|
331
|
-
delete genericThis[propName];
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
/*
|
|
336
|
-
* This method must be statically present rather than added later, or else,
|
|
337
|
-
* browsers won't call it. Same for connected and disconnected callbacks.
|
|
338
|
-
*/
|
|
339
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
340
|
-
this._litElement?.attributeChangedCallback(name, oldValue, newValue);
|
|
341
|
-
if (!this._litElement) {
|
|
342
|
-
this._pendingAttributes.push(name);
|
|
343
|
-
}
|
|
344
|
-
if (process.env.NODE_ENV !== "production") {
|
|
345
|
-
this._hmrSetAttributes.add(name);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
connectedCallback() {
|
|
349
|
-
if (this._litElement) {
|
|
350
|
-
this._litElement.connectedCallback?.();
|
|
351
|
-
} else {
|
|
352
|
-
queueMicrotask(() => {
|
|
353
|
-
this._ancestorLoad = attachToAncestor(this);
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
disconnectedCallback() {
|
|
358
|
-
this._litElement?.disconnectedCallback?.();
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Create a promise that resolves once component is fully loaded
|
|
362
|
-
*/
|
|
363
|
-
async componentOnReady() {
|
|
364
|
-
await this._postLoaded.promise;
|
|
365
|
-
return this;
|
|
366
|
-
}
|
|
367
|
-
/** @internal */
|
|
368
|
-
_initializeComponent(module) {
|
|
369
|
-
const ProxyClass = this.constructor;
|
|
370
|
-
const tagName = ProxyClass._name;
|
|
371
|
-
const store = this._store;
|
|
372
|
-
if (process.env.NODE_ENV !== "production") {
|
|
373
|
-
Object.entries(module).forEach(([name, LitConstructor2]) => {
|
|
374
|
-
if (name !== "exportsForTests" && typeof LitConstructor2 !== "function" || typeof LitConstructor2.tagName !== "string") {
|
|
375
|
-
console.warn(
|
|
376
|
-
`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.`
|
|
377
|
-
);
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
const LitConstructor = Object.values(module).find(
|
|
382
|
-
(LitConstructor2) => LitConstructor2.tagName === tagName
|
|
383
|
-
);
|
|
384
|
-
if (process.env.NODE_ENV !== "production" && !LitConstructor) {
|
|
385
|
-
throw new Error(
|
|
386
|
-
`Unable to find the LitElement class for the "${tagName}" custom element in the lazy-loaded module`
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
const lazyTagName = process.env.NODE_ENV === "production" ? `${tagName}--lazy` : (ProxyClass._hmrIndex ?? 0) === 0 ? `${tagName}--lazy` : `${tagName}--lazy-${ProxyClass._hmrIndex}`;
|
|
390
|
-
let parentClass = LitConstructor;
|
|
391
|
-
while (parentClass && !Object.hasOwn(parentClass, "lumina")) {
|
|
392
|
-
parentClass = Object.getPrototypeOf(parentClass);
|
|
393
|
-
}
|
|
394
|
-
const litElementPrototype = parentClass.prototype;
|
|
395
|
-
const elementPrototype = Element.prototype;
|
|
396
|
-
const alreadyPatched = Object.hasOwn(litElementPrototype, "isConnected");
|
|
397
|
-
if (!alreadyPatched) {
|
|
398
|
-
litElementPrototype.setAttribute = function(qualifiedName, value) {
|
|
399
|
-
elementPrototype.setAttribute.call(this.el, qualifiedName, value);
|
|
400
|
-
};
|
|
401
|
-
litElementPrototype.removeAttribute = function(qualifiedName) {
|
|
402
|
-
elementPrototype.removeAttribute.call(this.el, qualifiedName);
|
|
403
|
-
};
|
|
404
|
-
defineProperty(litElementPrototype, "isConnected", {
|
|
405
|
-
get() {
|
|
406
|
-
return Reflect.get(elementPrototype, "isConnected", this.el);
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
if (process.env.NODE_ENV !== "production") {
|
|
411
|
-
devOnlyDetectIncorrectLazyUsages(parentClass);
|
|
412
|
-
}
|
|
413
|
-
const isFirstInitialization = !ProxyClass._LitConstructor;
|
|
414
|
-
if (isFirstInitialization) {
|
|
415
|
-
ProxyClass._LitConstructor = LitConstructor;
|
|
416
|
-
customElements.define(lazyTagName, LitConstructor);
|
|
417
|
-
}
|
|
418
|
-
LitConstructor.lazy = this;
|
|
419
|
-
const litElement = document.createElement(lazyTagName);
|
|
420
|
-
LitConstructor.lazy = void 0;
|
|
421
|
-
if (process.env.NODE_ENV !== "production") {
|
|
422
|
-
Object.defineProperty(this, "_litElement", {
|
|
423
|
-
value: litElement,
|
|
424
|
-
configurable: true,
|
|
425
|
-
enumerable: false
|
|
426
|
-
});
|
|
427
|
-
} else {
|
|
428
|
-
this._litElement = litElement;
|
|
429
|
-
}
|
|
430
|
-
this._store = litElement;
|
|
431
|
-
this._pendingAttributes.forEach((name) => {
|
|
432
|
-
const value = this.getAttribute(name);
|
|
433
|
-
litElement.attributeChangedCallback(
|
|
434
|
-
name,
|
|
435
|
-
// Lit doesn't look at this value, thus even if attribute already exists, that's ok
|
|
436
|
-
null,
|
|
437
|
-
value
|
|
438
|
-
);
|
|
439
|
-
});
|
|
440
|
-
Object.entries(store).forEach(syncLitElement, litElement);
|
|
441
|
-
if (process.env.NODE_ENV !== "production") {
|
|
442
|
-
const litObserved = LitConstructor.observedAttributes ?? [];
|
|
443
|
-
const lazyObserved = ProxyClass.observedAttributes ?? [];
|
|
444
|
-
const missingFromLazy = litObserved.filter((attribute) => !lazyObserved.includes(attribute));
|
|
445
|
-
const missingFromLit = lazyObserved.filter((attribute) => !litObserved.includes(attribute));
|
|
446
|
-
if (missingFromLazy.length > 0) {
|
|
447
|
-
console.warn(
|
|
448
|
-
`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`
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
|
-
if (missingFromLit.length > 0) {
|
|
452
|
-
console.warn(
|
|
453
|
-
`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`
|
|
454
|
-
);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
const isStillConnected = this.isConnected;
|
|
458
|
-
if (isStillConnected || this._ancestorLoad) {
|
|
459
|
-
litElement.connectedCallback?.();
|
|
460
|
-
if (!isStillConnected) {
|
|
461
|
-
litElement.disconnectedCallback();
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Implemented on the proxy for compatibility with Lit Context.
|
|
467
|
-
*/
|
|
468
|
-
addController() {
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Implemented on the proxy for compatibility with Lit Context.
|
|
472
|
-
*/
|
|
473
|
-
requestUpdate() {
|
|
474
|
-
this._litElement?.requestUpdate();
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
function syncLitElement([key, value]) {
|
|
478
|
-
this[key] = value;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
// src/hmrSupport.ts
|
|
482
|
-
import { camelToKebab as camelToKebab2 } from "@arcgis/components-utils";
|
|
483
|
-
|
|
484
|
-
// src/utils.ts
|
|
485
|
-
var noShadowRoot = {};
|
|
486
|
-
|
|
487
|
-
// src/hmrSupport.ts
|
|
488
|
-
function handleHmrUpdate(newModules) {
|
|
489
|
-
newModules.forEach((newModule) => {
|
|
490
|
-
if (newModule === void 0) {
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
Object.values(newModule).forEach((exported) => {
|
|
494
|
-
if (typeof exported !== "function" || typeof exported.tagName !== "string") {
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
const LitConstructor = exported;
|
|
498
|
-
const ProxyClass = customElements.get(LitConstructor.tagName);
|
|
499
|
-
if (ProxyClass === void 0) {
|
|
500
|
-
throw new Error(`Failed to find custom element proxy for tag name: ${LitConstructor.tagName}`);
|
|
501
|
-
}
|
|
502
|
-
ProxyClass._LitConstructor = void 0;
|
|
503
|
-
ProxyClass._loadPromise = void 0;
|
|
504
|
-
ProxyClass._hmrIndex ??= 0;
|
|
505
|
-
ProxyClass._hmrIndex += 1;
|
|
506
|
-
ProxyClass._initializePrototype();
|
|
507
|
-
ProxyClass._hmrInstances?.forEach((instanceWeakRef) => {
|
|
508
|
-
const instance = instanceWeakRef.deref();
|
|
509
|
-
if (instance === void 0) {
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
if (instance._litElement === void 0) {
|
|
513
|
-
void ProxyClass._loadPromise.then(() => reInitialize(instance, newModule));
|
|
514
|
-
} else {
|
|
515
|
-
reInitialize(instance, newModule);
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
return;
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
function reInitialize(instance, newModule) {
|
|
523
|
-
const PreviousLitConstructor = instance._litElement.constructor;
|
|
524
|
-
const isShadowRoot = PreviousLitConstructor.shadowRootOptions !== noShadowRoot;
|
|
525
|
-
if (!isShadowRoot) {
|
|
526
|
-
const root = instance.getRootNode() ?? document;
|
|
527
|
-
if ("adoptedStyleSheets" in root) {
|
|
528
|
-
const rootStyles = Array.from(root.adoptedStyleSheets);
|
|
529
|
-
PreviousLitConstructor.elementStyles.forEach((style) => {
|
|
530
|
-
const styleSheet = "styleSheet" in style ? style.styleSheet : style;
|
|
531
|
-
const index = rootStyles.lastIndexOf(styleSheet);
|
|
532
|
-
if (index > -1) {
|
|
533
|
-
rootStyles.splice(index, 1);
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
root.adoptedStyleSheets = rootStyles;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
const properties = PreviousLitConstructor.elementProperties;
|
|
540
|
-
const preservedProperties = Array.from(properties.entries()).filter(
|
|
541
|
-
([propertyName, descriptor]) => typeof propertyName === "string" && (instance._hmrSetProps.has(propertyName) || typeof descriptor.attribute === "string" && instance._hmrSetAttributes.has(descriptor.attribute))
|
|
542
|
-
).map(([key]) => [key, instance[key]]);
|
|
543
|
-
instance._store = Object.fromEntries(preservedProperties);
|
|
544
|
-
const isConnected = instance.isConnected;
|
|
545
|
-
if (isConnected) {
|
|
546
|
-
instance._litElement.disconnectedCallback();
|
|
547
|
-
}
|
|
548
|
-
instance._initializeComponent(newModule);
|
|
549
|
-
}
|
|
550
|
-
function handleComponentMetaUpdate(meta) {
|
|
551
|
-
const ProxyClass = customElements.get(meta.tagName);
|
|
552
|
-
if (ProxyClass === void 0) {
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
const attributes = meta.properties.map(([property2, attribute]) => attribute ?? camelToKebab2(property2)).filter(Boolean);
|
|
556
|
-
const observedAttributes = initializeAttributeObserver();
|
|
557
|
-
observedAttributes[meta.tagName] ??= {};
|
|
558
|
-
observedAttributes[meta.tagName].original ??= new Set(ProxyClass.observedAttributes);
|
|
559
|
-
const originallyObserved = observedAttributes[meta.tagName].original;
|
|
560
|
-
observedAttributes[meta.tagName].manuallyObserved = new Set(
|
|
561
|
-
/**
|
|
562
|
-
* Never manually observe attributes that were in the original
|
|
563
|
-
* observedAttributes as those would be observed by the browser
|
|
564
|
-
*/
|
|
565
|
-
attributes.filter((attribute) => !originallyObserved.has(attribute))
|
|
566
|
-
);
|
|
567
|
-
ProxyClass._asyncMethods = meta.asyncMethods;
|
|
568
|
-
ProxyClass._syncMethods = meta.syncMethods;
|
|
569
|
-
ProxyClass._properties = meta.properties.map(([name]) => name);
|
|
570
|
-
ProxyClass.observedAttributes = attributes;
|
|
571
|
-
}
|
|
572
|
-
function initializeAttributeObserver() {
|
|
573
|
-
const observedAttributesSymbol = Symbol.for("@arcgis/lumina:observedAttributes");
|
|
574
|
-
const globalThisWithObservedAttributes = globalThis;
|
|
575
|
-
const alreadyHadObservers = observedAttributesSymbol in globalThisWithObservedAttributes;
|
|
576
|
-
globalThisWithObservedAttributes[observedAttributesSymbol] ??= {};
|
|
577
|
-
const observedAttributes = globalThisWithObservedAttributes[observedAttributesSymbol];
|
|
578
|
-
if (!alreadyHadObservers) {
|
|
579
|
-
const makeObserver = (original) => function observeAttributes(qualifiedName, ...rest) {
|
|
580
|
-
const observed = observedAttributes[this.tagName.toLowerCase()]?.manuallyObserved;
|
|
581
|
-
if (observed?.has(qualifiedName)) {
|
|
582
|
-
const oldValue = this.getAttribute(qualifiedName);
|
|
583
|
-
const returns = original.call(this, qualifiedName, ...rest);
|
|
584
|
-
const newValue = this.getAttribute(qualifiedName);
|
|
585
|
-
this.attributeChangedCallback(qualifiedName, oldValue, newValue);
|
|
586
|
-
return returns;
|
|
587
|
-
} else {
|
|
588
|
-
return original.call(this, qualifiedName, ...rest);
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
ProxyComponent.prototype.setAttribute = makeObserver(ProxyComponent.prototype.setAttribute);
|
|
592
|
-
ProxyComponent.prototype.toggleAttribute = makeObserver(ProxyComponent.prototype.toggleAttribute);
|
|
593
|
-
ProxyComponent.prototype.removeAttribute = makeObserver(ProxyComponent.prototype.removeAttribute);
|
|
594
|
-
}
|
|
595
|
-
return observedAttributes;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
73
|
// src/LitElement.ts
|
|
599
|
-
import { Deferred
|
|
74
|
+
import { Deferred, camelToKebab } from "@arcgis/components-utils";
|
|
600
75
|
import { LitElement as OriginalLitElement, isServer } from "lit";
|
|
601
76
|
import { useControllerManager } from "@arcgis/components-controllers";
|
|
602
77
|
var emptyFunction = () => void 0;
|
|
@@ -630,7 +105,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
|
|
|
630
105
|
*/
|
|
631
106
|
this.manager = useControllerManager(this);
|
|
632
107
|
/** @internal */
|
|
633
|
-
this._postLoad = this.constructor.lazy?._postLoad ?? new
|
|
108
|
+
this._postLoad = this.constructor.lazy?._postLoad ?? new Deferred();
|
|
634
109
|
/**
|
|
635
110
|
* Direct offspring that should be awaited before loaded() is emitted.
|
|
636
111
|
*
|
|
@@ -639,7 +114,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
|
|
|
639
114
|
* @internal
|
|
640
115
|
*/
|
|
641
116
|
this._offspring = this.constructor.lazy?._offspring ?? [];
|
|
642
|
-
this._postLoaded = this.constructor.lazy?._postLoaded ?? new
|
|
117
|
+
this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred();
|
|
643
118
|
this._enableUpdating = this.enableUpdating;
|
|
644
119
|
this.enableUpdating = emptyFunction;
|
|
645
120
|
const ourShouldUpdate = _LitElement.prototype.shouldUpdate;
|
|
@@ -685,7 +160,7 @@ var LitElement = class _LitElement extends OriginalLitElement {
|
|
|
685
160
|
*
|
|
686
161
|
* Thus, overwriting Lit's default behavior to use kebab-case:
|
|
687
162
|
*/
|
|
688
|
-
attribute: !!(flags & 1 /* ATTRIBUTE */) && typeof name === "string" ?
|
|
163
|
+
attribute: !!(flags & 1 /* ATTRIBUTE */) && typeof name === "string" ? camelToKebab(name) : false,
|
|
689
164
|
reflect: !!(flags & 2 /* REFLECT */),
|
|
690
165
|
type: flags & 4 /* BOOLEAN */ ? Boolean : flags & 8 /* NUMBER */ ? Number : void 0,
|
|
691
166
|
/**
|
|
@@ -908,8 +383,6 @@ export {
|
|
|
908
383
|
createEvent,
|
|
909
384
|
createPrototypeProxy,
|
|
910
385
|
directive,
|
|
911
|
-
handleComponentMetaUpdate,
|
|
912
|
-
handleHmrUpdate,
|
|
913
386
|
live,
|
|
914
387
|
makeDefineCustomElements,
|
|
915
388
|
makeRuntime,
|
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
|
/**
|
package/dist/jsx/jsx.d.ts
CHANGED
|
@@ -27,13 +27,13 @@ export declare const Fragment: (props: {
|
|
|
27
27
|
children?: JsxNode;
|
|
28
28
|
}) => TemplateResult;
|
|
29
29
|
/**
|
|
30
|
-
* @
|
|
30
|
+
* @private
|
|
31
31
|
* The references to this function are removed at build time. You do not need
|
|
32
32
|
* to import it directly
|
|
33
33
|
*/
|
|
34
34
|
export declare function jsx(type: string, props: unknown, key?: unknown): JsxNode;
|
|
35
35
|
/**
|
|
36
|
-
* @
|
|
36
|
+
* @private
|
|
37
37
|
* The references to this function are removed at build time. You do not need
|
|
38
38
|
* to import it directly
|
|
39
39
|
*/
|
|
@@ -200,6 +200,26 @@ export type ToElement<Component> = Omit<Component, LuminaJsx.ExcludedProperties>
|
|
|
200
200
|
export type ToJsx<Component extends {
|
|
201
201
|
el: unknown;
|
|
202
202
|
}> = LuminaJsx.HTMLAttributes<Component["el"]> & LuminaJsx.RemapEvents<Component> & Partial<Omit<Component, LuminaJsx.ExcludedProperties | keyof HTMLElement | keyof LuminaJsx.RemapEvents<Component>>>;
|
|
203
|
+
/**
|
|
204
|
+
* This interface will be automatically extended in src/lumina.ts files to add
|
|
205
|
+
* typings for Stencil elements usages in Lumina. You do not need to manually
|
|
206
|
+
* extend this interface.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* import type { JSX as CalciteJSX } from "@esri/calcite-components/dist/types/components";
|
|
211
|
+
* import type { JSX as CommonComponentsJsx } from "@arcgis/common-components/dist/types/components";
|
|
212
|
+
*
|
|
213
|
+
* declare module "@arcgis/lumina" {
|
|
214
|
+
* interface ImportStencilElements
|
|
215
|
+
* extends CalciteJSX.IntrinsicElements,
|
|
216
|
+
* CommonComponentsJsx.IntrinsicElements {
|
|
217
|
+
* }
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export interface ImportStencilElements {
|
|
222
|
+
}
|
|
203
223
|
/**
|
|
204
224
|
* Get the type of all events for a given component. Includes native DOM events
|
|
205
225
|
* and custom events.
|
|
@@ -207,9 +227,9 @@ export type ToJsx<Component extends {
|
|
|
207
227
|
* @example
|
|
208
228
|
* ```tsx
|
|
209
229
|
* render() {
|
|
210
|
-
* return <arcgis-
|
|
230
|
+
* return <arcgis-map onArcgisViewClick={this._handleViewClick} />
|
|
211
231
|
* }
|
|
212
|
-
*
|
|
232
|
+
* _handleViewClick(event: ToEvents<HTMLArcgisMapElement>["arcgisViewClick"]) {
|
|
213
233
|
* // event.detail
|
|
214
234
|
* // event.currentTarget
|
|
215
235
|
* }
|
|
@@ -251,6 +271,12 @@ type GlobalEventTypes<Target = HTMLElement> = {
|
|
|
251
271
|
type ListenerToPayloadType<Listener> = unknown extends Listener ? void : Listener extends {
|
|
252
272
|
emit: (...rest: never[]) => infer PayloadType;
|
|
253
273
|
} ? PayloadType : Listener extends CustomEvent ? Listener : void;
|
|
274
|
+
/**
|
|
275
|
+
* Defined Lumina custom elements. This interface is used only for internal
|
|
276
|
+
* type-checking only.
|
|
277
|
+
*/
|
|
278
|
+
export interface DeclareElements {
|
|
279
|
+
}
|
|
254
280
|
/**
|
|
255
281
|
* These typings are based on dom-expressions typings:
|
|
256
282
|
* https://github.com/ryansolid/dom-expressions/blob/main/packages/dom-expressions/src/jsx.d.ts
|
|
@@ -306,7 +332,7 @@ export declare namespace LuminaJsx {
|
|
|
306
332
|
*/
|
|
307
333
|
key?: unknown;
|
|
308
334
|
}
|
|
309
|
-
interface IntrinsicElements extends HTMLElementTags, SVGElementTags, ReMappedComponents<
|
|
335
|
+
interface IntrinsicElements extends HTMLElementTags, SVGElementTags, ReMappedComponents<DeclareElements>, Omit<ReMapStencilComponents<ImportStencilElements>, keyof HTMLElementTags | keyof SVGElementTags> {
|
|
310
336
|
}
|
|
311
337
|
/**
|
|
312
338
|
* By not requiring to have some sort of typings generation watcher to run
|