@arcgis/lumina 4.33.0-next.124 → 4.33.0-next.126
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-B3mB4uaz.js} +173 -211
- 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 +26 -22
- package/dist/controllers/accessor/index.d.ts +1 -1
- package/dist/controllers/accessor/index.js +177 -211
- package/dist/controllers/accessor/reEmitEvent.d.ts +1 -1
- package/dist/controllers/accessor/useAccessor.d.ts +29 -32
- package/dist/controllers/index.d.ts +2 -2
- package/dist/controllers/index.js +42 -39
- 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/utils.d.ts +7 -9
- package/dist/hmrSupport.js +22 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.js +186 -192
- package/dist/{utils-BdB9g3GU.js → lazyLoad-ByH-FaBP.js} +173 -185
- package/dist/lazyLoad.d.ts +22 -67
- package/dist/lifecycleSupport.d.ts +1 -1
- package/dist/makeRuntime.d.ts +23 -1
- package/dist/{proxyExports-CK5BLFLO.js → proxyExports-DQobuu44.js} +8 -8
- package/dist/render.d.ts +1 -1
- package/dist/utils.d.ts +8 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isEsriInternalEnv, Deferred, camelToKebab } from "@arcgis/components-utils";
|
|
2
|
+
import { lazyMetaGroupJoiner, lazyMetaItemJoiner, lazyMetaSubItemJoiner } from "./config.js";
|
|
3
3
|
function devOnlyDetectIncorrectLazyUsages(LitClass) {
|
|
4
4
|
const genericPrototype = LitClass.prototype;
|
|
5
5
|
const descriptor = Object.getOwnPropertyDescriptor(genericPrototype, "innerText");
|
|
@@ -67,19 +67,19 @@ function devOnlyDetectIncorrectLazyUsages(LitClass) {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
const attachToAncestor = (child) => {
|
|
71
71
|
let ancestor = child;
|
|
72
72
|
while (ancestor = ancestor.parentNode ?? ancestor.host) {
|
|
73
73
|
if (ancestor?.constructor?.lumina) {
|
|
74
74
|
const litParent = ancestor;
|
|
75
75
|
if (!litParent.manager?.loadedCalled) {
|
|
76
|
-
litParent._offspring.push(child);
|
|
76
|
+
(litParent.J ?? litParent["_offspring"]).push(child);
|
|
77
77
|
}
|
|
78
|
-
return litParent._postLoad.promise;
|
|
78
|
+
return (litParent.I ?? litParent["_postLoad"]).promise;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
return false;
|
|
82
|
-
}
|
|
82
|
+
};
|
|
83
83
|
if (process.env.NODE_ENV !== "production") {
|
|
84
84
|
const litGlobalThis = globalThis;
|
|
85
85
|
litGlobalThis.litIssuedWarnings ??= /* @__PURE__ */ new Set();
|
|
@@ -91,6 +91,13 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
91
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
92
|
);
|
|
93
93
|
}
|
|
94
|
+
const noShadowRoot = {};
|
|
95
|
+
function emptyFunction() {
|
|
96
|
+
}
|
|
97
|
+
const devOnly$getLitElementTagNameAndRuntime = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (componentClass) => ({
|
|
98
|
+
tagName: componentClass.L,
|
|
99
|
+
runtime: componentClass.K
|
|
100
|
+
}) : void 0;
|
|
94
101
|
const makeDefineCustomElements = (runtime, structure) => function defineCustomElements(windowOrOptions, options) {
|
|
95
102
|
if (!globalThis.customElements) {
|
|
96
103
|
return;
|
|
@@ -100,248 +107,231 @@ const makeDefineCustomElements = (runtime, structure) => function defineCustomEl
|
|
|
100
107
|
if (resourcesUrl) {
|
|
101
108
|
runtime.setAssetPath(resourcesUrl);
|
|
102
109
|
}
|
|
103
|
-
Object.entries(structure)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (customElements.get(tagName)) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const [compactObservedProps, compactAsyncMethods, compactSyncMethods] = compactMeta.split(lazyMetaGroupJoiner);
|
|
110
|
-
const observedProps = compactObservedProps ? compactObservedProps?.split(lazyMetaItemJoiner).map(parseCondensedProp) : void 0;
|
|
111
|
-
const observedProperties = observedProps?.map(([property]) => property);
|
|
112
|
-
const ProxyClass = class extends ProxyComponent {
|
|
113
|
-
static {
|
|
114
|
-
this.observedAttributes = observedProps?.map(([, attribute]) => attribute).filter((attribute) => attribute !== "");
|
|
115
|
-
}
|
|
116
|
-
static {
|
|
117
|
-
this._properties = observedProperties;
|
|
110
|
+
for (const [tagName, [load, compactMeta = ""]] of Object.entries(structure)) {
|
|
111
|
+
if (customElements.get(tagName)) {
|
|
112
|
+
continue;
|
|
118
113
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
114
|
+
const [compactObservedProps, compactAsyncMethods, compactSyncMethods] = compactMeta.split(lazyMetaGroupJoiner);
|
|
115
|
+
const observedProps = compactObservedProps ? compactObservedProps?.split(lazyMetaItemJoiner).map(parseCondensedProp) : void 0;
|
|
116
|
+
const observedProperties = observedProps?.map(([property]) => property);
|
|
117
|
+
const ProxyClass = class extends ProxyComponent {
|
|
118
|
+
static {
|
|
119
|
+
this.observedAttributes = observedProps?.map(([, attribute]) => attribute).filter((attribute) => attribute !== "");
|
|
120
|
+
}
|
|
121
|
+
static {
|
|
122
|
+
this.C = observedProperties;
|
|
123
|
+
}
|
|
124
|
+
static {
|
|
125
|
+
this.E = compactAsyncMethods ? compactAsyncMethods?.split(lazyMetaItemJoiner) : void 0;
|
|
126
|
+
}
|
|
127
|
+
static {
|
|
128
|
+
this.D = compactSyncMethods?.split(lazyMetaItemJoiner);
|
|
129
|
+
}
|
|
130
|
+
static {
|
|
131
|
+
this.L = tagName;
|
|
132
|
+
}
|
|
133
|
+
static {
|
|
134
|
+
this.K = runtime;
|
|
133
135
|
}
|
|
134
|
-
|
|
136
|
+
constructor() {
|
|
137
|
+
const isFirstInstanceOfType = !ProxyClass.B;
|
|
138
|
+
if (isFirstInstanceOfType) {
|
|
139
|
+
ProxyClass.B = load();
|
|
140
|
+
ProxyClass.F();
|
|
141
|
+
}
|
|
142
|
+
super();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
customElements.define(tagName, ProxyClass);
|
|
146
|
+
if (process.env.NODE_ENV !== "production") {
|
|
147
|
+
globalThis.devOnly$ownTagNames?.add(tagName);
|
|
135
148
|
}
|
|
136
|
-
};
|
|
137
|
-
customElements.define(tagName, ProxyClass);
|
|
138
|
-
if (process.env.NODE_ENV !== "production") {
|
|
139
|
-
globalThis.devOnly$ownTagNames?.add(tagName);
|
|
140
149
|
}
|
|
141
|
-
}
|
|
150
|
+
};
|
|
142
151
|
const defineProperty = Object.defineProperty;
|
|
143
|
-
|
|
152
|
+
const parseCondensedProp = (propAndAttribute) => {
|
|
144
153
|
const name = propAndAttribute.split(lazyMetaSubItemJoiner);
|
|
145
154
|
return name.length === 1 ? [name[0], camelToKebab(name[0])] : name;
|
|
146
|
-
}
|
|
147
|
-
const HtmlElement = globalThis.HTMLElement ??
|
|
155
|
+
};
|
|
156
|
+
const HtmlElement = globalThis.HTMLElement ?? emptyFunction;
|
|
148
157
|
class ProxyComponent extends HtmlElement {
|
|
149
158
|
constructor() {
|
|
150
159
|
super();
|
|
151
|
-
this
|
|
152
|
-
this
|
|
153
|
-
this.
|
|
154
|
-
this.
|
|
155
|
-
this.
|
|
160
|
+
this.#store = {};
|
|
161
|
+
this.#pendingAttributes = [];
|
|
162
|
+
this.I = new Deferred();
|
|
163
|
+
this.H = new Deferred();
|
|
164
|
+
this.J = [];
|
|
156
165
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
157
|
-
this.
|
|
158
|
-
this.
|
|
166
|
+
this.devOnly$hmrSetProps = /* @__PURE__ */ new Set();
|
|
167
|
+
this.devOnly$hmrSetAttributes = /* @__PURE__ */ new Set();
|
|
159
168
|
globalThis.devOnly$createdElements ??= [];
|
|
160
169
|
globalThis.devOnly$createdElements.push(new WeakRef(this));
|
|
170
|
+
this.devOnly$InitializeComponent = this.#initializeComponent.bind(this);
|
|
171
|
+
this.devOnly$hmrResetStore = (newStore) => {
|
|
172
|
+
this.#store = newStore;
|
|
173
|
+
};
|
|
161
174
|
}
|
|
162
|
-
this
|
|
163
|
-
const ProxyClass =
|
|
164
|
-
|
|
165
|
-
|
|
175
|
+
const that = this;
|
|
176
|
+
const ProxyClass = that.constructor;
|
|
177
|
+
that["_offspring"] = that.J;
|
|
178
|
+
that["_postLoad"] = that.I;
|
|
179
|
+
ProxyClass.C?.forEach((propName) => {
|
|
180
|
+
if (Object.hasOwn(that, propName)) {
|
|
181
|
+
that.#store[propName] = that[propName];
|
|
182
|
+
delete that[propName];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
if (ProxyClass.A) {
|
|
186
|
+
that.#initializeComponent({ a: ProxyClass.A });
|
|
166
187
|
} else {
|
|
167
|
-
void ProxyClass.
|
|
168
|
-
|
|
188
|
+
void ProxyClass.B.then(async (module) => {
|
|
189
|
+
await ProxyClass.K.p;
|
|
190
|
+
that.#initializeComponent(
|
|
191
|
+
/**
|
|
192
|
+
* "$$" is our top-level await polyfill due to broken top-level await
|
|
193
|
+
* support in Safari. Only applies in CDN build.
|
|
194
|
+
* See https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/3933
|
|
195
|
+
* and https://bugs.webkit.org/show_bug.cgi?id=242740
|
|
196
|
+
*/
|
|
197
|
+
await (module.default?.then(
|
|
198
|
+
(module2) => typeof module2 === "function" ? { a: module2 } : module2
|
|
199
|
+
) ?? module)
|
|
200
|
+
);
|
|
201
|
+
}).catch((error) => {
|
|
202
|
+
that.H.reject(error);
|
|
169
203
|
setTimeout(() => {
|
|
170
204
|
throw error;
|
|
171
205
|
});
|
|
172
206
|
});
|
|
173
207
|
}
|
|
174
208
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
175
|
-
ProxyClass.
|
|
176
|
-
ProxyClass.
|
|
177
|
-
Object.defineProperty(this, "_store", { value: this._store, enumerable: false, configurable: true });
|
|
209
|
+
ProxyClass.devOnly$hmrInstances ??= [];
|
|
210
|
+
ProxyClass.devOnly$hmrInstances.push(new WeakRef(this));
|
|
178
211
|
}
|
|
179
212
|
}
|
|
180
213
|
static {
|
|
181
214
|
this.lumina = true;
|
|
182
215
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
set(value) {
|
|
197
|
-
this._store[propName] = value;
|
|
198
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
199
|
-
this._hmrSetProps.add(propName);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
static _bindAsync(methodName) {
|
|
205
|
-
defineProperty(this.prototype, methodName, {
|
|
206
|
-
async value(...args) {
|
|
207
|
-
if (!this._litElement) {
|
|
208
|
-
await this._postLoaded.promise;
|
|
209
|
-
}
|
|
210
|
-
const genericLitElement = this._litElement;
|
|
211
|
-
return await genericLitElement[methodName](...args);
|
|
212
|
-
},
|
|
213
|
-
configurable: true
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
static _bindSync(methodName) {
|
|
217
|
-
defineProperty(this.prototype, methodName, {
|
|
218
|
-
value(...args) {
|
|
219
|
-
if (process.env.NODE_ENV !== "production" && !this._litElement) {
|
|
220
|
-
const ProxyClass = this.constructor;
|
|
221
|
-
throw new Error(
|
|
222
|
-
`Tried to call method ${methodName}() on <${ProxyClass._name}> component before it's fully loaded. Please do 'await component.componentOnReady();' before calling this method.`
|
|
223
|
-
);
|
|
216
|
+
static F() {
|
|
217
|
+
for (const propName of this.C ?? []) {
|
|
218
|
+
defineProperty(this.prototype, propName, {
|
|
219
|
+
configurable: true,
|
|
220
|
+
enumerable: true,
|
|
221
|
+
get() {
|
|
222
|
+
return this.#store[propName];
|
|
223
|
+
},
|
|
224
|
+
set(value) {
|
|
225
|
+
this.#store[propName] = value;
|
|
226
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
227
|
+
this.devOnly$hmrSetProps.add(propName);
|
|
228
|
+
}
|
|
224
229
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
for (const methodName of this.E ?? []) {
|
|
233
|
+
defineProperty(this.prototype, methodName, {
|
|
234
|
+
async value(...args) {
|
|
235
|
+
if (!this.#litElement) {
|
|
236
|
+
await this.H.promise;
|
|
237
|
+
}
|
|
238
|
+
const genericLitElement = this.#litElement;
|
|
239
|
+
return await genericLitElement[methodName](...args);
|
|
240
|
+
},
|
|
241
|
+
configurable: true
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
for (const methodName of this.D ?? []) {
|
|
245
|
+
defineProperty(this.prototype, methodName, {
|
|
246
|
+
value(...args) {
|
|
247
|
+
if (process.env.NODE_ENV !== "production" && !this.#litElement) {
|
|
248
|
+
const ProxyClass = this.constructor;
|
|
249
|
+
throw new Error(
|
|
250
|
+
`Tried to call method ${methodName}() on <${ProxyClass.L}> component before it's fully loaded. Please do 'await component.componentOnReady();' before calling this method.`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
const genericLitElement = this.#litElement;
|
|
254
|
+
return genericLitElement[methodName](...args);
|
|
255
|
+
},
|
|
256
|
+
configurable: true
|
|
257
|
+
});
|
|
258
|
+
}
|
|
230
259
|
}
|
|
260
|
+
#litElement;
|
|
261
|
+
#store;
|
|
262
|
+
#pendingAttributes;
|
|
231
263
|
get manager() {
|
|
232
|
-
return this
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Until the custom element is registered on the page, an instance of that
|
|
236
|
-
* element can be constructed and some properties on that instance set.
|
|
237
|
-
*
|
|
238
|
-
* These properties are set before the element prototype is set to this proxy
|
|
239
|
-
* class and thus none of our getters/setters are yet registered - such
|
|
240
|
-
* properties will be set by JavaScript on the instance directly.
|
|
241
|
-
*
|
|
242
|
-
* Once element is registered, the properties set in the meanwhile will shadow
|
|
243
|
-
* the getter/setters, and thus break reactivity. The fix is to delete these
|
|
244
|
-
* properties from the instance, and re-apply them once accessors are set.
|
|
245
|
-
*
|
|
246
|
-
* @example
|
|
247
|
-
* ```ts
|
|
248
|
-
* import { defineCustomElements } from '@arcgis/map-components';
|
|
249
|
-
* const map = document.createElement('arcgis-map');
|
|
250
|
-
* // This will shadow the getter/setters
|
|
251
|
-
* map.itemId = '...';
|
|
252
|
-
* // This finally defines the custom elements and sets the property accessors
|
|
253
|
-
* defineCustomElements();
|
|
254
|
-
* ```
|
|
255
|
-
*
|
|
256
|
-
* @remarks
|
|
257
|
-
* This is an equivalent of the __saveInstanceProperties method in Lit's
|
|
258
|
-
* ReactiveElement. Lit takes care of this on LitElement, but we have to take
|
|
259
|
-
* care of this on the lazy proxy
|
|
260
|
-
*/
|
|
261
|
-
_saveInstanceProperties() {
|
|
262
|
-
const ProxyClass = this.constructor;
|
|
263
|
-
const genericThis = this;
|
|
264
|
-
ProxyClass._properties?.forEach((propName) => {
|
|
265
|
-
if (Object.hasOwn(this, propName)) {
|
|
266
|
-
this._store[propName] = genericThis[propName];
|
|
267
|
-
delete genericThis[propName];
|
|
268
|
-
}
|
|
269
|
-
});
|
|
264
|
+
return this.#litElement?.manager;
|
|
270
265
|
}
|
|
271
266
|
/*
|
|
272
267
|
* This method must be statically present rather than added later, or else,
|
|
273
268
|
* browsers won't call it. Same for connected and disconnected callbacks.
|
|
274
269
|
*/
|
|
275
270
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
276
|
-
this
|
|
277
|
-
if (!this
|
|
278
|
-
this.
|
|
271
|
+
this.#litElement?.attributeChangedCallback(name, oldValue, newValue);
|
|
272
|
+
if (!this.#litElement) {
|
|
273
|
+
this.#pendingAttributes.push(name);
|
|
279
274
|
}
|
|
280
275
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
281
|
-
this.
|
|
276
|
+
this.devOnly$hmrSetAttributes.add(name);
|
|
282
277
|
}
|
|
283
278
|
}
|
|
284
279
|
connectedCallback() {
|
|
285
|
-
if (this
|
|
286
|
-
this.
|
|
280
|
+
if (this.#litElement) {
|
|
281
|
+
this.#litElement.connectedCallback?.();
|
|
287
282
|
} else {
|
|
288
|
-
queueMicrotask(() =>
|
|
289
|
-
this._ancestorLoad = attachToAncestor(this);
|
|
290
|
-
});
|
|
283
|
+
queueMicrotask(() => this.G = attachToAncestor(this));
|
|
291
284
|
}
|
|
292
285
|
}
|
|
293
286
|
disconnectedCallback() {
|
|
294
|
-
this
|
|
287
|
+
this.#litElement?.disconnectedCallback?.();
|
|
295
288
|
}
|
|
296
289
|
/**
|
|
297
290
|
* Create a promise that resolves once component is fully loaded
|
|
298
291
|
*/
|
|
299
292
|
async componentOnReady() {
|
|
300
|
-
await this.
|
|
293
|
+
await this.H.promise;
|
|
301
294
|
return this;
|
|
302
295
|
}
|
|
303
|
-
|
|
304
|
-
_initializeComponent(module) {
|
|
296
|
+
#initializeComponent(module) {
|
|
305
297
|
const ProxyClass = this.constructor;
|
|
306
|
-
const tagName = ProxyClass.
|
|
307
|
-
const store = this
|
|
298
|
+
const tagName = ProxyClass.L;
|
|
299
|
+
const store = this.#store;
|
|
308
300
|
const LitConstructor = Object.values(module).find(
|
|
309
|
-
(LitConstructor2) => LitConstructor2.
|
|
301
|
+
(LitConstructor2) => LitConstructor2.L === tagName
|
|
310
302
|
);
|
|
311
303
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !LitConstructor) {
|
|
312
304
|
throw new Error(
|
|
313
305
|
`Unable to find the LitElement class for the "${tagName}" custom element in the lazy-loaded module`
|
|
314
306
|
);
|
|
315
307
|
}
|
|
316
|
-
const lazyTagName = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (ProxyClass.
|
|
308
|
+
const lazyTagName = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (ProxyClass.devOnly$hmrIndex ?? 0) === 0 ? `${tagName}--lazy` : `${tagName}--lazy-${ProxyClass.devOnly$hmrIndex}` : `${tagName}--lazy`;
|
|
317
309
|
let parentClass = LitConstructor;
|
|
318
310
|
while (parentClass && !Object.hasOwn(parentClass, "lumina")) {
|
|
319
311
|
parentClass = Object.getPrototypeOf(parentClass);
|
|
320
312
|
}
|
|
321
313
|
patchLitElement(parentClass);
|
|
322
|
-
const isFirstInitialization = !ProxyClass.
|
|
314
|
+
const isFirstInitialization = !ProxyClass.A;
|
|
323
315
|
if (isFirstInitialization) {
|
|
324
|
-
ProxyClass.
|
|
316
|
+
ProxyClass.A = LitConstructor;
|
|
325
317
|
customElements.define(lazyTagName, LitConstructor);
|
|
326
318
|
}
|
|
327
|
-
LitConstructor.
|
|
319
|
+
LitConstructor.N = this;
|
|
328
320
|
const litElement = document.createElement(lazyTagName);
|
|
329
|
-
LitConstructor.
|
|
321
|
+
LitConstructor.N = void 0;
|
|
322
|
+
this.#litElement = litElement;
|
|
330
323
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
331
|
-
Object.defineProperty(this, "
|
|
332
|
-
} else {
|
|
333
|
-
this._litElement = litElement;
|
|
324
|
+
Object.defineProperty(this, "$component", { value: litElement, configurable: true, enumerable: false });
|
|
334
325
|
}
|
|
335
|
-
this
|
|
336
|
-
this.
|
|
337
|
-
|
|
338
|
-
litElement.attributeChangedCallback(
|
|
326
|
+
this.#store = litElement;
|
|
327
|
+
this.#pendingAttributes.forEach(
|
|
328
|
+
(name) => litElement.attributeChangedCallback(
|
|
339
329
|
name,
|
|
340
330
|
// Lit doesn't look at this value, thus even if attribute already exists, that's ok
|
|
341
331
|
null,
|
|
342
|
-
|
|
343
|
-
)
|
|
344
|
-
|
|
332
|
+
this.getAttribute(name)
|
|
333
|
+
)
|
|
334
|
+
);
|
|
345
335
|
Object.entries(store).forEach(syncLitElement, litElement);
|
|
346
336
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
347
337
|
const litObserved = LitConstructor.observedAttributes ?? [];
|
|
@@ -350,17 +340,17 @@ class ProxyComponent extends HtmlElement {
|
|
|
350
340
|
const missingFromLit = lazyObserved.filter((attribute) => !litObserved.includes(attribute));
|
|
351
341
|
if (missingFromLazy.length > 0) {
|
|
352
342
|
console.warn(
|
|
353
|
-
`The following attributes on <${ProxyClass.
|
|
343
|
+
`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`
|
|
354
344
|
);
|
|
355
345
|
}
|
|
356
346
|
if (missingFromLit.length > 0) {
|
|
357
347
|
console.warn(
|
|
358
|
-
`The following attributes on <${ProxyClass.
|
|
348
|
+
`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`
|
|
359
349
|
);
|
|
360
350
|
}
|
|
361
351
|
}
|
|
362
352
|
const isStillConnected = this.isConnected;
|
|
363
|
-
if (isStillConnected || this.
|
|
353
|
+
if (isStillConnected || this.G) {
|
|
364
354
|
litElement.connectedCallback?.();
|
|
365
355
|
if (!isStillConnected) {
|
|
366
356
|
litElement.disconnectedCallback();
|
|
@@ -376,13 +366,13 @@ class ProxyComponent extends HtmlElement {
|
|
|
376
366
|
* Implemented on the proxy for compatibility with Lit Context.
|
|
377
367
|
*/
|
|
378
368
|
requestUpdate() {
|
|
379
|
-
this
|
|
369
|
+
this.#litElement?.requestUpdate();
|
|
380
370
|
}
|
|
381
371
|
}
|
|
382
372
|
function syncLitElement([key, value]) {
|
|
383
373
|
this[key] = value;
|
|
384
374
|
}
|
|
385
|
-
|
|
375
|
+
const patchLitElement = (parentClass) => {
|
|
386
376
|
const litElementPrototype = parentClass.prototype;
|
|
387
377
|
const elementPrototype = Element.prototype;
|
|
388
378
|
const alreadyPatched = Object.hasOwn(litElementPrototype, "isConnected");
|
|
@@ -402,14 +392,12 @@ function patchLitElement(parentClass) {
|
|
|
402
392
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
403
393
|
devOnlyDetectIncorrectLazyUsages(parentClass);
|
|
404
394
|
}
|
|
405
|
-
}
|
|
406
|
-
const awaitTopLevelPolyfill = async (module) => await (module.default?.then(
|
|
407
|
-
(module2) => typeof module2 === "function" ? { a: module2 } : module2
|
|
408
|
-
) ?? module);
|
|
409
|
-
const noShadowRoot = {};
|
|
395
|
+
};
|
|
410
396
|
export {
|
|
411
397
|
ProxyComponent as P,
|
|
412
398
|
attachToAncestor as a,
|
|
399
|
+
devOnly$getLitElementTagNameAndRuntime as d,
|
|
400
|
+
emptyFunction as e,
|
|
413
401
|
makeDefineCustomElements as m,
|
|
414
402
|
noShadowRoot as n
|
|
415
403
|
};
|
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;
|