@arcgis/lumina 4.33.0-next.99 → 4.34.0-next.0
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/{Controller-CZ8Djohh.js → Controller-BQOv8BAL.js} +170 -210
- package/dist/LitElement.d.ts +22 -18
- package/dist/config.d.ts +7 -9
- package/dist/config.js +15 -12
- package/dist/context.d.ts +2 -2
- package/dist/controllers/Controller.d.ts +4 -10
- package/dist/controllers/ControllerInternals.d.ts +7 -13
- package/dist/controllers/ControllerManager.d.ts +6 -21
- package/dist/controllers/accessor/index.d.ts +3 -1
- package/dist/controllers/accessor/index.js +208 -222
- package/dist/controllers/accessor/reEmitEvent.d.ts +1 -1
- package/dist/controllers/accessor/store.d.ts +17 -0
- package/dist/controllers/accessor/useAccessor.d.ts +29 -32
- package/dist/controllers/index.d.ts +2 -2
- package/dist/controllers/index.js +45 -38
- package/dist/controllers/trackKey.d.ts +1 -1
- package/dist/controllers/trackPropKey.d.ts +1 -1
- package/dist/controllers/trackPropertyKey.d.ts +2 -2
- package/dist/controllers/types.d.ts +35 -0
- package/dist/controllers/usePropertyChange.d.ts +3 -1
- package/dist/controllers/utils.d.ts +6 -9
- package/dist/createEvent.d.ts +4 -4
- package/dist/hmrSupport.js +22 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.js +193 -200
- package/dist/jsx/generatedTypes.d.ts +414 -80
- package/dist/lazyLoad-DUvrNd2L.js +406 -0
- package/dist/lazyLoad.d.ts +22 -67
- package/dist/lifecycleSupport.d.ts +1 -1
- package/dist/makeRuntime.d.ts +40 -1
- package/dist/{proxyExports-CK5BLFLO.js → proxyExports-Cdzj7WL_.js} +8 -8
- package/dist/render.d.ts +1 -1
- package/dist/utils.d.ts +8 -0
- package/dist/wrappersUtils.d.ts +13 -1
- package/package.json +5 -5
- package/dist/utils-DBdf1Dqp.js +0 -405
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { isEsriInternalEnv, Deferred, camelToKebab } from "@arcgis/components-utils";
|
|
2
|
+
import { lazyMetaGroupJoiner, lazyMetaItemJoiner, lazyMetaSubItemJoiner } from "./config.js";
|
|
3
|
+
function devOnlyDetectIncorrectLazyUsages(LitClass) {
|
|
4
|
+
const genericPrototype = LitClass.prototype;
|
|
5
|
+
const descriptor = Object.getOwnPropertyDescriptor(genericPrototype, "innerText");
|
|
6
|
+
if (descriptor !== void 0 && descriptor.set?.name === "setWrapper") {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const allowList = /* @__PURE__ */ new Set([
|
|
10
|
+
// We shouldn't be overwriting this property
|
|
11
|
+
"constructor",
|
|
12
|
+
// Called by Lit - we proxy it to this.el in ProxyComponent
|
|
13
|
+
"setAttribute",
|
|
14
|
+
// Called by Lit SSR - we proxy it to this.el in ProxyComponent
|
|
15
|
+
"removeAttribute",
|
|
16
|
+
// Called by Lit - we proxy it to this.el in ProxyComponent
|
|
17
|
+
"isConnected",
|
|
18
|
+
// Called by Lit, but only in dev mode for warnings, so we don't have to proxy.
|
|
19
|
+
"localName",
|
|
20
|
+
// Called by Lit Context - we proxy it to this.el in ProxyComponent.
|
|
21
|
+
// Interestingly, they never call removeEventListener.
|
|
22
|
+
"addEventListener"
|
|
23
|
+
]);
|
|
24
|
+
const customErrorMessages = {
|
|
25
|
+
addEventListener: "use this.listen() or this.el.addEventListener()"
|
|
26
|
+
};
|
|
27
|
+
Object.entries({
|
|
28
|
+
...Object.getOwnPropertyDescriptors(HTMLElement.prototype),
|
|
29
|
+
...Object.getOwnPropertyDescriptors(Element.prototype),
|
|
30
|
+
...Object.getOwnPropertyDescriptors(Node.prototype),
|
|
31
|
+
...Object.getOwnPropertyDescriptors(EventTarget.prototype)
|
|
32
|
+
}).forEach(([key, value]) => {
|
|
33
|
+
if (allowList.has(key)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
function validateUsage(...args) {
|
|
37
|
+
const isDynamicallyCreatedComponentInTest = this === this.el;
|
|
38
|
+
if (isDynamicallyCreatedComponentInTest) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (key === "hasAttribute" && args[0] === "defer-hydration") {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(
|
|
45
|
+
`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}`}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (typeof value.value === "function") {
|
|
49
|
+
genericPrototype[key] = function functionWrapper(...args) {
|
|
50
|
+
return validateUsage.call(this, ...args) ?? value.value.call(this, ...args);
|
|
51
|
+
};
|
|
52
|
+
} else if (typeof value.get === "function") {
|
|
53
|
+
Object.defineProperty(genericPrototype, key, {
|
|
54
|
+
get() {
|
|
55
|
+
validateUsage.call(this);
|
|
56
|
+
return value.get.call(this);
|
|
57
|
+
},
|
|
58
|
+
set: typeof value.set === "function" ? function setWrapper(setValue) {
|
|
59
|
+
validateUsage.call(this);
|
|
60
|
+
value.set.call(this, setValue);
|
|
61
|
+
} : void 0
|
|
62
|
+
});
|
|
63
|
+
} else if (key === key.toUpperCase() && typeof value.value === "number") {
|
|
64
|
+
return;
|
|
65
|
+
} else {
|
|
66
|
+
throw new Error(`Unexpected value type for ${key}: ${value}`);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const attachToAncestor = (child) => {
|
|
71
|
+
let ancestor = child;
|
|
72
|
+
while (ancestor = ancestor.parentNode ?? ancestor.host) {
|
|
73
|
+
if (ancestor?.constructor?.lumina) {
|
|
74
|
+
const litParent = ancestor;
|
|
75
|
+
if (!litParent.manager?.loadedCalled) {
|
|
76
|
+
(litParent.J ?? litParent["_offspring"]).push(child);
|
|
77
|
+
}
|
|
78
|
+
return (litParent.I ?? litParent["_postLoad"]).promise;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
};
|
|
83
|
+
if (process.env.NODE_ENV !== "production") {
|
|
84
|
+
const litGlobalThis = globalThis;
|
|
85
|
+
litGlobalThis.litIssuedWarnings ??= /* @__PURE__ */ new Set();
|
|
86
|
+
litGlobalThis.litIssuedWarnings.add("dev-mode");
|
|
87
|
+
litGlobalThis.litIssuedWarnings.add(
|
|
88
|
+
"Overriding ReactiveElement.createProperty() is deprecated. The override will not be called with standard decorators See https://lit.dev/msg/no-override-create-property for more information."
|
|
89
|
+
);
|
|
90
|
+
litGlobalThis.litIssuedWarnings.add(
|
|
91
|
+
"Overriding ReactiveElement.getPropertyDescriptor() is deprecated. The override will not be called with standard decorators See https://lit.dev/msg/no-override-get-property-descriptor for more information."
|
|
92
|
+
);
|
|
93
|
+
if (isEsriInternalEnv()) {
|
|
94
|
+
globalThis.calciteConfig ??= { version: " " };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const noShadowRoot = {};
|
|
98
|
+
function emptyFunction() {
|
|
99
|
+
}
|
|
100
|
+
const devOnly$getLitElementTagNameAndRuntime = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (componentClass) => ({
|
|
101
|
+
tagName: componentClass.L,
|
|
102
|
+
runtime: componentClass.K
|
|
103
|
+
}) : void 0;
|
|
104
|
+
const makeDefineCustomElements = (runtime, structure) => function defineCustomElements(windowOrOptions, options) {
|
|
105
|
+
if (!globalThis.customElements) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const resolvedOptions = options ?? windowOrOptions ?? {};
|
|
109
|
+
const resourcesUrl = resolvedOptions.resourcesUrl;
|
|
110
|
+
if (resourcesUrl) {
|
|
111
|
+
runtime.setAssetPath(resourcesUrl);
|
|
112
|
+
}
|
|
113
|
+
for (const [tagName, [load, compactMeta = ""]] of Object.entries(structure)) {
|
|
114
|
+
if (customElements.get(tagName)) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const [compactObservedProps, compactAsyncMethods, compactSyncMethods] = compactMeta.split(lazyMetaGroupJoiner);
|
|
118
|
+
const observedProps = compactObservedProps ? compactObservedProps?.split(lazyMetaItemJoiner).map(parseCondensedProp) : void 0;
|
|
119
|
+
const observedProperties = observedProps?.map(([property]) => property);
|
|
120
|
+
const ProxyClass = class extends ProxyComponent {
|
|
121
|
+
static {
|
|
122
|
+
this.observedAttributes = observedProps?.map(([, attribute]) => attribute).filter((attribute) => attribute !== "");
|
|
123
|
+
}
|
|
124
|
+
static {
|
|
125
|
+
this.C = observedProperties;
|
|
126
|
+
}
|
|
127
|
+
static {
|
|
128
|
+
this.E = compactAsyncMethods ? compactAsyncMethods?.split(lazyMetaItemJoiner) : void 0;
|
|
129
|
+
}
|
|
130
|
+
static {
|
|
131
|
+
this.D = compactSyncMethods?.split(lazyMetaItemJoiner);
|
|
132
|
+
}
|
|
133
|
+
static {
|
|
134
|
+
this.L = tagName;
|
|
135
|
+
}
|
|
136
|
+
static {
|
|
137
|
+
this.K = runtime;
|
|
138
|
+
}
|
|
139
|
+
constructor() {
|
|
140
|
+
const isFirstInstanceOfType = !ProxyClass.B;
|
|
141
|
+
if (isFirstInstanceOfType) {
|
|
142
|
+
ProxyClass.B = load();
|
|
143
|
+
ProxyClass.F();
|
|
144
|
+
}
|
|
145
|
+
super();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
customElements.define(tagName, ProxyClass);
|
|
149
|
+
if (process.env.NODE_ENV !== "production") {
|
|
150
|
+
globalThis.devOnly$ownTagNames?.add(tagName);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const defineProperty = Object.defineProperty;
|
|
155
|
+
const parseCondensedProp = (propAndAttribute) => {
|
|
156
|
+
const name = propAndAttribute.split(lazyMetaSubItemJoiner);
|
|
157
|
+
return name.length === 1 ? [name[0], camelToKebab(name[0])] : name;
|
|
158
|
+
};
|
|
159
|
+
const HtmlElement = globalThis.HTMLElement ?? emptyFunction;
|
|
160
|
+
class ProxyComponent extends HtmlElement {
|
|
161
|
+
constructor() {
|
|
162
|
+
super();
|
|
163
|
+
this.#store = {};
|
|
164
|
+
this.#pendingAttributes = [];
|
|
165
|
+
this.I = new Deferred();
|
|
166
|
+
this.H = new Deferred();
|
|
167
|
+
this.J = [];
|
|
168
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
169
|
+
this.devOnly$hmrSetProps = /* @__PURE__ */ new Set();
|
|
170
|
+
this.devOnly$hmrSetAttributes = /* @__PURE__ */ new Set();
|
|
171
|
+
globalThis.devOnly$createdElements ??= [];
|
|
172
|
+
globalThis.devOnly$createdElements.push(new WeakRef(this));
|
|
173
|
+
this.devOnly$InitializeComponent = this.#initializeComponent.bind(this);
|
|
174
|
+
this.devOnly$hmrResetStore = (newStore) => {
|
|
175
|
+
this.#store = newStore;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const that = this;
|
|
179
|
+
const ProxyClass = that.constructor;
|
|
180
|
+
that["_offspring"] = that.J;
|
|
181
|
+
that["_postLoad"] = that.I;
|
|
182
|
+
ProxyClass.C?.forEach((propName) => {
|
|
183
|
+
if (Object.hasOwn(that, propName)) {
|
|
184
|
+
that.#store[propName] = that[propName];
|
|
185
|
+
delete that[propName];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
if (ProxyClass.A) {
|
|
189
|
+
that.#initializeComponent({ a: ProxyClass.A });
|
|
190
|
+
} else {
|
|
191
|
+
void ProxyClass.B.then(async (module) => {
|
|
192
|
+
await ProxyClass.K.p;
|
|
193
|
+
that.#initializeComponent(
|
|
194
|
+
/**
|
|
195
|
+
* "$$" is our top-level await polyfill due to broken top-level await
|
|
196
|
+
* support in Safari. Only applies in CDN build.
|
|
197
|
+
* See https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/3933
|
|
198
|
+
* and https://bugs.webkit.org/show_bug.cgi?id=242740
|
|
199
|
+
*/
|
|
200
|
+
await (module.default?.then(
|
|
201
|
+
(module2) => typeof module2 === "function" ? { a: module2 } : module2
|
|
202
|
+
) ?? module)
|
|
203
|
+
);
|
|
204
|
+
}).catch((error) => {
|
|
205
|
+
that.H.reject(error);
|
|
206
|
+
setTimeout(() => {
|
|
207
|
+
throw error;
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
212
|
+
ProxyClass.devOnly$hmrInstances ??= [];
|
|
213
|
+
ProxyClass.devOnly$hmrInstances.push(new WeakRef(this));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
static {
|
|
217
|
+
this.lumina = true;
|
|
218
|
+
}
|
|
219
|
+
static F() {
|
|
220
|
+
for (const propName of this.C ?? []) {
|
|
221
|
+
defineProperty(this.prototype, propName, {
|
|
222
|
+
configurable: true,
|
|
223
|
+
enumerable: true,
|
|
224
|
+
get() {
|
|
225
|
+
return this.#store[propName];
|
|
226
|
+
},
|
|
227
|
+
set(value) {
|
|
228
|
+
this.#store[propName] = value;
|
|
229
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
230
|
+
this.devOnly$hmrSetProps.add(propName);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
for (const methodName of this.E ?? []) {
|
|
236
|
+
defineProperty(this.prototype, methodName, {
|
|
237
|
+
async value(...args) {
|
|
238
|
+
if (!this.#litElement) {
|
|
239
|
+
await this.H.promise;
|
|
240
|
+
}
|
|
241
|
+
const genericLitElement = this.#litElement;
|
|
242
|
+
return await genericLitElement[methodName](...args);
|
|
243
|
+
},
|
|
244
|
+
configurable: true
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
for (const methodName of this.D ?? []) {
|
|
248
|
+
defineProperty(this.prototype, methodName, {
|
|
249
|
+
value(...args) {
|
|
250
|
+
if (process.env.NODE_ENV !== "production" && !this.#litElement) {
|
|
251
|
+
const ProxyClass = this.constructor;
|
|
252
|
+
throw new Error(
|
|
253
|
+
`Tried to call method ${methodName}() on <${ProxyClass.L}> component before it's fully loaded. Please do 'await component.componentOnReady();' before calling this method.`
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
const genericLitElement = this.#litElement;
|
|
257
|
+
return genericLitElement[methodName](...args);
|
|
258
|
+
},
|
|
259
|
+
configurable: true
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
#litElement;
|
|
264
|
+
#store;
|
|
265
|
+
#pendingAttributes;
|
|
266
|
+
get manager() {
|
|
267
|
+
return this.#litElement?.manager;
|
|
268
|
+
}
|
|
269
|
+
/*
|
|
270
|
+
* This method must be statically present rather than added later, or else,
|
|
271
|
+
* browsers won't call it. Same for connected and disconnected callbacks.
|
|
272
|
+
*/
|
|
273
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
274
|
+
this.#litElement?.attributeChangedCallback(name, oldValue, newValue);
|
|
275
|
+
if (!this.#litElement) {
|
|
276
|
+
this.#pendingAttributes.push(name);
|
|
277
|
+
}
|
|
278
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
279
|
+
this.devOnly$hmrSetAttributes.add(name);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
connectedCallback() {
|
|
283
|
+
if (this.#litElement) {
|
|
284
|
+
this.#litElement.connectedCallback?.();
|
|
285
|
+
} else {
|
|
286
|
+
queueMicrotask(() => this.G = attachToAncestor(this));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
disconnectedCallback() {
|
|
290
|
+
this.#litElement?.disconnectedCallback?.();
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Create a promise that resolves once component is fully loaded
|
|
294
|
+
*/
|
|
295
|
+
async componentOnReady() {
|
|
296
|
+
await this.H.promise;
|
|
297
|
+
return this;
|
|
298
|
+
}
|
|
299
|
+
#initializeComponent(module) {
|
|
300
|
+
const ProxyClass = this.constructor;
|
|
301
|
+
const tagName = ProxyClass.L;
|
|
302
|
+
const store = this.#store;
|
|
303
|
+
const LitConstructor = Object.values(module).find(
|
|
304
|
+
(LitConstructor2) => LitConstructor2.L === tagName
|
|
305
|
+
);
|
|
306
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !LitConstructor) {
|
|
307
|
+
throw new Error(
|
|
308
|
+
`Unable to find the LitElement class for the "${tagName}" custom element in the lazy-loaded module`
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
const lazyTagName = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (ProxyClass.devOnly$hmrIndex ?? 0) === 0 ? `${tagName}--lazy` : `${tagName}--lazy-${ProxyClass.devOnly$hmrIndex}` : `${tagName}--lazy`;
|
|
312
|
+
let parentClass = LitConstructor;
|
|
313
|
+
while (parentClass && !Object.hasOwn(parentClass, "lumina")) {
|
|
314
|
+
parentClass = Object.getPrototypeOf(parentClass);
|
|
315
|
+
}
|
|
316
|
+
patchLitElement(parentClass);
|
|
317
|
+
const isFirstInitialization = !ProxyClass.A;
|
|
318
|
+
if (isFirstInitialization) {
|
|
319
|
+
ProxyClass.A = LitConstructor;
|
|
320
|
+
customElements.define(lazyTagName, LitConstructor);
|
|
321
|
+
}
|
|
322
|
+
LitConstructor.N = this;
|
|
323
|
+
const litElement = document.createElement(lazyTagName);
|
|
324
|
+
LitConstructor.N = void 0;
|
|
325
|
+
this.#litElement = litElement;
|
|
326
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
327
|
+
Object.defineProperty(this, "$component", { value: litElement, configurable: true, enumerable: false });
|
|
328
|
+
}
|
|
329
|
+
this.#store = litElement;
|
|
330
|
+
this.#pendingAttributes.forEach(
|
|
331
|
+
(name) => litElement.attributeChangedCallback(
|
|
332
|
+
name,
|
|
333
|
+
// Lit doesn't look at this value, thus even if attribute already exists, that's ok
|
|
334
|
+
null,
|
|
335
|
+
this.getAttribute(name)
|
|
336
|
+
)
|
|
337
|
+
);
|
|
338
|
+
Object.entries(store).forEach(syncLitElement, litElement);
|
|
339
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
340
|
+
const litObserved = LitConstructor.observedAttributes ?? [];
|
|
341
|
+
const lazyObserved = ProxyClass.observedAttributes ?? [];
|
|
342
|
+
const missingFromLazy = litObserved.filter((attribute) => !lazyObserved.includes(attribute));
|
|
343
|
+
const missingFromLit = lazyObserved.filter((attribute) => !litObserved.includes(attribute));
|
|
344
|
+
if (missingFromLazy.length > 0) {
|
|
345
|
+
console.warn(
|
|
346
|
+
`The following attributes on <${ProxyClass.L}> 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`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
if (missingFromLit.length > 0) {
|
|
350
|
+
console.warn(
|
|
351
|
+
`The following attributes on <${ProxyClass.L}> 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`
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const isStillConnected = this.isConnected;
|
|
356
|
+
if (isStillConnected || this.G) {
|
|
357
|
+
litElement.connectedCallback?.();
|
|
358
|
+
if (!isStillConnected) {
|
|
359
|
+
litElement.disconnectedCallback();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Implemented on the proxy for compatibility with Lit Context.
|
|
365
|
+
*/
|
|
366
|
+
addController() {
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Implemented on the proxy for compatibility with Lit Context.
|
|
370
|
+
*/
|
|
371
|
+
requestUpdate() {
|
|
372
|
+
this.#litElement?.requestUpdate();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function syncLitElement([key, value]) {
|
|
376
|
+
this[key] = value;
|
|
377
|
+
}
|
|
378
|
+
const patchLitElement = (parentClass) => {
|
|
379
|
+
const litElementPrototype = parentClass.prototype;
|
|
380
|
+
const elementPrototype = Element.prototype;
|
|
381
|
+
const alreadyPatched = Object.hasOwn(litElementPrototype, "isConnected");
|
|
382
|
+
if (!alreadyPatched) {
|
|
383
|
+
litElementPrototype.setAttribute = function(qualifiedName, value) {
|
|
384
|
+
elementPrototype.setAttribute.call(this.el, qualifiedName, value);
|
|
385
|
+
};
|
|
386
|
+
litElementPrototype.removeAttribute = function(qualifiedName) {
|
|
387
|
+
elementPrototype.removeAttribute.call(this.el, qualifiedName);
|
|
388
|
+
};
|
|
389
|
+
defineProperty(litElementPrototype, "isConnected", {
|
|
390
|
+
get() {
|
|
391
|
+
return Reflect.get(elementPrototype, "isConnected", this.el);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
396
|
+
devOnlyDetectIncorrectLazyUsages(parentClass);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
export {
|
|
400
|
+
ProxyComponent as P,
|
|
401
|
+
attachToAncestor as a,
|
|
402
|
+
devOnly$getLitElementTagNameAndRuntime as d,
|
|
403
|
+
emptyFunction as e,
|
|
404
|
+
makeDefineCustomElements as m,
|
|
405
|
+
noShadowRoot as n
|
|
406
|
+
};
|
package/dist/lazyLoad.d.ts
CHANGED
|
@@ -50,102 +50,59 @@ declare const HtmlElement: {
|
|
|
50
50
|
* @private
|
|
51
51
|
*/
|
|
52
52
|
export declare abstract class ProxyComponent extends HtmlElement {
|
|
53
|
+
#private;
|
|
53
54
|
static observedAttributes?: readonly string[];
|
|
54
|
-
|
|
55
|
-
static
|
|
56
|
-
/** private */
|
|
57
|
-
static _LitConstructor?: typeof LitElement;
|
|
55
|
+
static _LitElementLoadPromise: Promise<Record<string, typeof LitElement>> | undefined;
|
|
56
|
+
static _LitElementConstructor?: typeof LitElement;
|
|
58
57
|
/**
|
|
59
58
|
* A list of instances of this component. This allows hot module replacement
|
|
60
59
|
* to update all proxy component to use a new LitElement instance.
|
|
61
|
-
*
|
|
62
|
-
* private
|
|
63
60
|
*/
|
|
64
|
-
static
|
|
65
|
-
|
|
66
|
-
static
|
|
67
|
-
|
|
68
|
-
static
|
|
69
|
-
|
|
70
|
-
static
|
|
71
|
-
/** private */
|
|
72
|
-
static _syncMethods?: readonly string[];
|
|
73
|
-
protected static _name: string;
|
|
61
|
+
static devOnly$hmrInstances: WeakRef<ProxyComponent>[] | undefined;
|
|
62
|
+
static devOnly$hmrIndex: number | undefined;
|
|
63
|
+
static _proxiedProperties?: readonly string[];
|
|
64
|
+
static _proxiedAsyncMethods?: readonly string[];
|
|
65
|
+
static _proxiedSyncMethods?: readonly string[];
|
|
66
|
+
static __runtime: Runtime;
|
|
67
|
+
protected static __tagName: string;
|
|
74
68
|
static readonly lumina = true;
|
|
75
|
-
|
|
76
|
-
static _initializePrototype(): void;
|
|
77
|
-
private static _bindProp;
|
|
78
|
-
private static _bindAsync;
|
|
79
|
-
private static _bindSync;
|
|
69
|
+
static _initializeProxyPrototype(): void;
|
|
80
70
|
/**
|
|
81
71
|
* On HMR, preserve the values of all properties that at least once were set
|
|
82
72
|
* by someone other than component itself.
|
|
83
|
-
*
|
|
84
|
-
* private
|
|
85
73
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_litElement: LitElement | undefined;
|
|
91
|
-
/** private */
|
|
92
|
-
_store: LitElement | Record<string, unknown>;
|
|
74
|
+
devOnly$hmrSetProps: Set<PropertyKey>;
|
|
75
|
+
devOnly$hmrSetAttributes: Set<string>;
|
|
76
|
+
devOnly$InitializeComponent?: (module: Record<string, typeof LitElement>) => void;
|
|
77
|
+
devOnly$hmrResetStore?: (newStore: Record<string, unknown>) => void;
|
|
93
78
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
79
|
+
* This property is only set in development mode and exists only for usage in
|
|
80
|
+
* tests or during debugging
|
|
96
81
|
*/
|
|
97
|
-
|
|
82
|
+
$component: LitElement | undefined;
|
|
98
83
|
/**
|
|
99
84
|
* Resolved once LitElement's load() is complete.
|
|
100
85
|
* Not read inside of this class, but needed for LitElement to determine if
|
|
101
86
|
* it's closest ancestor finished load()
|
|
102
87
|
*/
|
|
103
|
-
|
|
88
|
+
__postLoadDeferred: Deferred<void>;
|
|
104
89
|
/**
|
|
105
90
|
* Resolved once LitElement's loaded() is complete
|
|
106
91
|
*/
|
|
107
|
-
|
|
92
|
+
_postLoadedDeferred: Deferred<void>;
|
|
108
93
|
/**
|
|
109
94
|
* Direct offspring that should be awaited before loaded() is emitted
|
|
110
95
|
*/
|
|
111
|
-
|
|
96
|
+
__offspringComponents: (CommonInterface & {
|
|
112
97
|
manager?: LitElement["manager"];
|
|
113
98
|
})[];
|
|
114
99
|
/**
|
|
115
100
|
* Promise that resolves once parent's load() completed. False if there is no
|
|
116
101
|
* parent
|
|
117
102
|
*/
|
|
118
|
-
|
|
103
|
+
_ancestorLoadPromise?: Promise<void> | false;
|
|
119
104
|
get manager(): ControllerManager | undefined;
|
|
120
105
|
constructor();
|
|
121
|
-
/**
|
|
122
|
-
* Until the custom element is registered on the page, an instance of that
|
|
123
|
-
* element can be constructed and some properties on that instance set.
|
|
124
|
-
*
|
|
125
|
-
* These properties are set before the element prototype is set to this proxy
|
|
126
|
-
* class and thus none of our getters/setters are yet registered - such
|
|
127
|
-
* properties will be set by JavaScript on the instance directly.
|
|
128
|
-
*
|
|
129
|
-
* Once element is registered, the properties set in the meanwhile will shadow
|
|
130
|
-
* the getter/setters, and thus break reactivity. The fix is to delete these
|
|
131
|
-
* properties from the instance, and re-apply them once accessors are set.
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```ts
|
|
135
|
-
* import { defineCustomElements } from '@arcgis/map-components';
|
|
136
|
-
* const map = document.createElement('arcgis-map');
|
|
137
|
-
* // This will shadow the getter/setters
|
|
138
|
-
* map.itemId = '...';
|
|
139
|
-
* // This finally defines the custom elements and sets the property accessors
|
|
140
|
-
* defineCustomElements();
|
|
141
|
-
* ```
|
|
142
|
-
*
|
|
143
|
-
* @remarks
|
|
144
|
-
* This is an equivalent of the __saveInstanceProperties method in Lit's
|
|
145
|
-
* ReactiveElement. Lit takes care of this on LitElement, but we have to take
|
|
146
|
-
* care of this on the lazy proxy
|
|
147
|
-
*/
|
|
148
|
-
protected _saveInstanceProperties(): void;
|
|
149
106
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
150
107
|
connectedCallback(): void;
|
|
151
108
|
disconnectedCallback(): void;
|
|
@@ -153,8 +110,6 @@ export declare abstract class ProxyComponent extends HtmlElement {
|
|
|
153
110
|
* Create a promise that resolves once component is fully loaded
|
|
154
111
|
*/
|
|
155
112
|
componentOnReady(): Promise<this>;
|
|
156
|
-
/** private */
|
|
157
|
-
_initializeComponent(module: Record<string, typeof LitElement>): void;
|
|
158
113
|
/**
|
|
159
114
|
* Implemented on the proxy for compatibility with Lit Context.
|
|
160
115
|
*/
|
|
@@ -5,4 +5,4 @@ import { ProxyComponent } from './lazyLoad';
|
|
|
5
5
|
* Also, return a promise that will delay our load() until parent's load()
|
|
6
6
|
* is completed.
|
|
7
7
|
*/
|
|
8
|
-
export declare
|
|
8
|
+
export declare const attachToAncestor: (child: ProxyComponent["__offspringComponents"][number]) => Promise<void> | false;
|
package/dist/makeRuntime.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSResult } from 'lit';
|
|
2
2
|
import { LitElement } from './LitElement';
|
|
3
|
+
import { AccessorObservableLike, ReactiveTrackingTarget } from './controllers/types';
|
|
3
4
|
/**
|
|
4
5
|
* `@arcgis/lumina` package may be bundled once but used by multiple packages with
|
|
5
6
|
* different configuration options. For that reason, the configuration options
|
|
@@ -53,6 +54,44 @@ export type Runtime = RuntimeOptions & {
|
|
|
53
54
|
* ```
|
|
54
55
|
*/
|
|
55
56
|
readonly customElement: (tagName: string, component: typeof LitElement) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Short for trackAccess. A reference to JS API's accessor's trackAccess
|
|
59
|
+
* function to mark an observable as accessed.
|
|
60
|
+
* Used in the getter for each property in component packages that use @arcgis/core.
|
|
61
|
+
*
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
t?: (observable: AccessorObservableLike) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Short for createObservable. A callback to create a JS API Accessor's
|
|
67
|
+
* SimpleObservable. Such observable will be created for each property in
|
|
68
|
+
* component packages that use @arcgis/core to bring reactiveUtils integration.
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
o?: () => AccessorObservableLike;
|
|
72
|
+
/**
|
|
73
|
+
* In CDN build, we can only import @arcgis/core async, so the lazy loader will need
|
|
74
|
+
* to await this promise before beginning hydration so that the reactiveUtils
|
|
75
|
+
* integration modules had time to load.
|
|
76
|
+
*
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
p?: Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* A possible reference to JS API's createTrackingTarget() function to create
|
|
82
|
+
* an observer that will keep track of what properties were accessed during
|
|
83
|
+
* render().
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
c?: (callback: () => void) => ReactiveTrackingTarget;
|
|
88
|
+
/**
|
|
89
|
+
* A possible reference to JS API's runTracked() function to run update() with
|
|
90
|
+
* property accesses tracking enabled.
|
|
91
|
+
*
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
r?: (target: ReactiveTrackingTarget, callback: () => void) => void;
|
|
56
95
|
};
|
|
57
96
|
export type RuntimeOptions = {
|
|
58
97
|
/**
|
|
@@ -88,7 +127,7 @@ export type RuntimeOptions = {
|
|
|
88
127
|
* The options object will be provided by Lumina compiler at build-time.
|
|
89
128
|
* It should not be specified in the source code.
|
|
90
129
|
*/
|
|
91
|
-
export declare
|
|
130
|
+
export declare const makeRuntime: (options?: RuntimeOptions) => Runtime;
|
|
92
131
|
/**
|
|
93
132
|
* Exposing the reference to the runtime globally when in tests or development.
|
|
94
133
|
* This is primarily for usage by dynamically created components in tests
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as setParentController, e as retrieveParentControllers, o as setAmbientChildController, t as trackKey, h as bypassReadOnly } from "./Controller-BQOv8BAL.js";
|
|
2
2
|
const proxyExports = (Class) => (...args) => {
|
|
3
3
|
const ambientControllers = retrieveParentControllers();
|
|
4
4
|
const instance = new Class(...args);
|
|
5
5
|
const initialExports = instance.exports;
|
|
6
6
|
setParentController(ambientControllers.at(-1));
|
|
7
7
|
const manager = instance.component.manager;
|
|
8
|
-
manager.
|
|
9
|
-
instance.watchExports(
|
|
8
|
+
manager.W(instance, initialExports);
|
|
9
|
+
instance.watchExports(manager.W.bind(manager, instance));
|
|
10
10
|
setAmbientChildController(instance);
|
|
11
11
|
const hostCandidates = [instance.component, ...ambientControllers].reverse();
|
|
12
12
|
return trackKey(
|
|
@@ -15,7 +15,7 @@ const proxyExports = (Class) => (...args) => {
|
|
|
15
15
|
initialExports
|
|
16
16
|
);
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
const setProxy = (controller, { host, key, isReactive: assignedToProp }, initialExports) => {
|
|
19
19
|
const genericHost = host;
|
|
20
20
|
const controllerValueChanged = genericHost[key] !== controller.exports;
|
|
21
21
|
const hostValueChanged = genericHost[key] !== initialExports;
|
|
@@ -28,18 +28,18 @@ function setProxy(controller, { host, key, isReactive: assignedToProp }, initial
|
|
|
28
28
|
if (assignedToProp) {
|
|
29
29
|
const manager = controller.component.manager;
|
|
30
30
|
if (hostValueChanged) {
|
|
31
|
-
manager.
|
|
31
|
+
manager.W(controller, genericHost[key]);
|
|
32
32
|
}
|
|
33
33
|
controller.onUpdate((changes) => {
|
|
34
34
|
if (changes.has(key)) {
|
|
35
35
|
const value = genericHost[key];
|
|
36
36
|
if (value !== controller.exports) {
|
|
37
|
-
manager.
|
|
37
|
+
manager.W(controller, value);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
controller.
|
|
42
|
+
controller.O = assignedToProp ? void 0 : key;
|
|
43
43
|
}
|
|
44
44
|
const isReadOnly = controller.component.constructor.elementProperties.get(key)?.readOnly;
|
|
45
45
|
controller.watchExports(() => {
|
|
@@ -54,7 +54,7 @@ function setProxy(controller, { host, key, isReactive: assignedToProp }, initial
|
|
|
54
54
|
genericHost[key] = controller.exports;
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
-
}
|
|
57
|
+
};
|
|
58
58
|
export {
|
|
59
59
|
proxyExports as p
|
|
60
60
|
};
|
package/dist/render.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { JsxNode } from './jsx/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Retrieve an HTML element to be manually appended to an existing component.
|
|
4
4
|
*/
|
|
5
|
-
export declare
|
|
5
|
+
export declare const renderElement: <Element extends HTMLElement = HTMLElement>(element: JsxNode) => Element;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LitElement } from './LitElement';
|
|
2
|
+
import { Runtime } from './makeRuntime';
|
|
1
3
|
/**
|
|
2
4
|
* Add this static property to your component to disable shadow root.
|
|
3
5
|
*
|
|
@@ -18,3 +20,9 @@ export declare const noShadowRoot: ShadowRootInit;
|
|
|
18
20
|
* attachShadow() since we use this exact empty object as a magic value to opt
|
|
19
21
|
* out of shadow root.
|
|
20
22
|
*/
|
|
23
|
+
export declare function emptyFunction(): undefined;
|
|
24
|
+
/** @private */
|
|
25
|
+
export declare const devOnly$getLitElementTagNameAndRuntime: ((componentClass: typeof LitElement) => {
|
|
26
|
+
tagName: string;
|
|
27
|
+
runtime: Runtime;
|
|
28
|
+
}) | undefined;
|