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