@arcgis/lumina 4.33.0-next.15 → 4.33.0-next.151

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.
Files changed (58) hide show
  1. package/dist/Controller-BQOv8BAL.js +587 -0
  2. package/dist/LitElement.d.ts +56 -45
  3. package/dist/config.d.ts +7 -9
  4. package/dist/config.js +18 -8
  5. package/dist/context.d.ts +14 -4
  6. package/dist/controllers/Controller.d.ts +147 -0
  7. package/dist/controllers/ControllerInternals.d.ts +53 -0
  8. package/dist/controllers/ControllerManager.d.ts +68 -0
  9. package/dist/controllers/accessor/index.d.ts +4 -0
  10. package/dist/controllers/accessor/index.js +245 -0
  11. package/dist/controllers/accessor/reEmitEvent.d.ts +10 -0
  12. package/dist/controllers/accessor/store.d.ts +17 -0
  13. package/dist/controllers/accessor/useAccessor.d.ts +71 -0
  14. package/dist/controllers/functional.d.ts +19 -0
  15. package/dist/controllers/index.d.ts +24 -0
  16. package/dist/controllers/index.js +270 -0
  17. package/dist/controllers/load.d.ts +6 -0
  18. package/dist/controllers/proxyExports.d.ts +27 -0
  19. package/dist/controllers/tests/autoDestroyMock.d.ts +5 -0
  20. package/dist/controllers/tests/utils.d.ts +1 -0
  21. package/dist/controllers/toFunction.d.ts +8 -0
  22. package/dist/controllers/trackKey.d.ts +8 -0
  23. package/dist/controllers/trackPropKey.d.ts +21 -0
  24. package/dist/controllers/trackPropertyKey.d.ts +29 -0
  25. package/dist/controllers/types.d.ts +187 -0
  26. package/dist/controllers/useDirection.d.ts +11 -0
  27. package/dist/controllers/useMedia.d.ts +8 -0
  28. package/dist/controllers/usePropertyChange.d.ts +14 -0
  29. package/dist/controllers/useT9n.d.ts +48 -0
  30. package/dist/controllers/useWatchAttributes.d.ts +7 -0
  31. package/dist/controllers/utils.d.ts +12 -0
  32. package/dist/createEvent.d.ts +8 -3
  33. package/dist/decorators.d.ts +2 -2
  34. package/dist/devOnlyDetectIncorrectLazyUsages.d.ts +1 -1
  35. package/dist/hmrSupport.d.ts +1 -1
  36. package/dist/hmrSupport.js +22 -28
  37. package/dist/index.d.ts +17 -16
  38. package/dist/index.js +423 -194
  39. package/dist/jsx/baseTypes.d.ts +13 -9
  40. package/dist/jsx/directives.d.ts +25 -7
  41. package/dist/jsx/generatedTypes.d.ts +420 -90
  42. package/dist/jsx/types.d.ts +5 -32
  43. package/dist/lazyLoad-DUvrNd2L.js +406 -0
  44. package/dist/lazyLoad.d.ts +27 -72
  45. package/dist/lifecycleSupport.d.ts +2 -2
  46. package/dist/makeRuntime.d.ts +148 -0
  47. package/dist/proxyExports-Cdzj7WL_.js +60 -0
  48. package/dist/render.d.ts +5 -0
  49. package/dist/runtime.d.ts +4 -107
  50. package/dist/stencilSsrCompatibility/index.d.ts +2 -6
  51. package/dist/stencilSsrCompatibility/index.js +2 -3
  52. package/dist/typings/importMeta.d.ts +2 -2
  53. package/dist/utils.d.ts +8 -0
  54. package/dist/wrappersUtils.d.ts +13 -1
  55. package/package.json +7 -6
  56. package/dist/chunk-NO7HOBNA.js +0 -421
  57. package/dist/chunk-PGHUBTOM.js +0 -21
  58. package/dist/wrappersUtils.test.d.ts +0 -1
@@ -1,421 +0,0 @@
1
- import {
2
- lazyMetaGroupJoiner,
3
- lazyMetaItemJoiner,
4
- lazyMetaSubItemJoiner
5
- } from "./chunk-PGHUBTOM.js";
6
-
7
- // src/lazyLoad.ts
8
- import { Deferred, camelToKebab, isEsriInternalEnv } from "@arcgis/components-utils";
9
-
10
- // src/devOnlyDetectIncorrectLazyUsages.ts
11
- function devOnlyDetectIncorrectLazyUsages(LitClass) {
12
- const genericPrototype = LitClass.prototype;
13
- const descriptor = Object.getOwnPropertyDescriptor(genericPrototype, "innerText");
14
- if (descriptor !== void 0 && descriptor.get === descriptor.set) {
15
- return;
16
- }
17
- const allowList = /* @__PURE__ */ new Set([
18
- // We shouldn't be overwriting this property
19
- "constructor",
20
- // Called by Lit - we proxy it to this.el in ProxyComponent
21
- "setAttribute",
22
- // Called by Lit SSR - we proxy it to this.el in ProxyComponent
23
- "removeAttribute",
24
- // Called by Lit - we proxy it to this.el in ProxyComponent
25
- "isConnected",
26
- // Called by Lit, but only in dev mode for warnings, so we don't have to proxy.
27
- "localName",
28
- // Called by Lit Context - we proxy it to this.el in ProxyComponent.
29
- // Interestingly, they never call removeEventListener.
30
- "addEventListener"
31
- ]);
32
- const customErrorMessages = {
33
- addEventListener: "use this.listen() or this.el.addEventListener()"
34
- };
35
- Object.entries({
36
- ...Object.getOwnPropertyDescriptors(HTMLElement.prototype),
37
- ...Object.getOwnPropertyDescriptors(Element.prototype),
38
- ...Object.getOwnPropertyDescriptors(Node.prototype),
39
- ...Object.getOwnPropertyDescriptors(EventTarget.prototype)
40
- }).forEach(([key, value]) => {
41
- if (allowList.has(key)) {
42
- return;
43
- }
44
- const callback = (...args) => {
45
- if (key === "hasAttribute" && args[0] === "defer-hydration") {
46
- return false;
47
- }
48
- throw new Error(
49
- `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}`}`
50
- );
51
- };
52
- if (typeof value.value === "function") {
53
- genericPrototype[key] = callback;
54
- } else {
55
- Object.defineProperty(genericPrototype, key, { get: callback, set: callback });
56
- }
57
- });
58
- }
59
-
60
- // src/lifecycleSupport.ts
61
- function attachToAncestor(child) {
62
- let ancestor = child;
63
- while (ancestor = ancestor.parentNode ?? ancestor.host) {
64
- if (ancestor?.constructor?.lumina) {
65
- const litParent = ancestor;
66
- if (!litParent.manager?.loadedCalled) {
67
- litParent._offspring.push(child);
68
- }
69
- return litParent._postLoad.promise;
70
- }
71
- }
72
- return false;
73
- }
74
-
75
- // src/lazyLoad.ts
76
- var makeDefineCustomElements = (runtime, structure) => function defineCustomElements(windowOrOptions, options) {
77
- if (!globalThis.customElements) {
78
- return;
79
- }
80
- const resolvedOptions = options ?? windowOrOptions ?? {};
81
- const resourcesUrl = resolvedOptions.resourcesUrl;
82
- if (resourcesUrl) {
83
- runtime.setAssetPath(resourcesUrl);
84
- }
85
- Object.entries(structure).forEach(createLazyElement);
86
- };
87
- function createLazyElement([tagName, [load, compactMeta = ""]]) {
88
- if (customElements.get(tagName)) {
89
- return;
90
- }
91
- const [compactObservedProps, compactAsyncMethods, compactSyncMethods] = compactMeta.split(lazyMetaGroupJoiner);
92
- const observedProps = compactObservedProps ? compactObservedProps?.split(lazyMetaItemJoiner).map(parseCondensedProp) : void 0;
93
- const observedProperties = observedProps?.map(([property]) => property);
94
- const ProxyClass = class extends ProxyComponent {
95
- static {
96
- this.observedAttributes = observedProps?.map(([, attribute]) => attribute).filter((attribute) => attribute !== "");
97
- }
98
- static {
99
- this._properties = observedProperties;
100
- }
101
- static {
102
- this._asyncMethods = compactAsyncMethods ? compactAsyncMethods?.split(lazyMetaItemJoiner) : void 0;
103
- }
104
- static {
105
- this._syncMethods = compactSyncMethods?.split(lazyMetaItemJoiner);
106
- }
107
- static {
108
- this._name = tagName;
109
- }
110
- constructor() {
111
- const isFirstInstanceOfType = !ProxyClass._loadPromise;
112
- if (isFirstInstanceOfType) {
113
- ProxyClass._loadPromise = load();
114
- ProxyClass._initializePrototype();
115
- }
116
- super();
117
- }
118
- };
119
- customElements.define(tagName, ProxyClass);
120
- if (process.env.NODE_ENV !== "production") {
121
- globalThis.devOnly$ownTagNames?.add(tagName);
122
- }
123
- }
124
- var defineProperty = Object.defineProperty;
125
- function parseCondensedProp(propAndAttribute) {
126
- const name = propAndAttribute.split(lazyMetaSubItemJoiner);
127
- return name.length === 1 ? [name[0], camelToKebab(name[0])] : name;
128
- }
129
- var HtmlElement = globalThis.HTMLElement ?? parseCondensedProp;
130
- var ProxyComponent = class extends HtmlElement {
131
- constructor() {
132
- super();
133
- /** @internal */
134
- this._store = {};
135
- /**
136
- * If attributeChangedCallback() is called before the LitElement is loaded,
137
- * store the attributes here, and replay later
138
- */
139
- this._pendingAttributes = [];
140
- /**
141
- * Resolved once LitElement's load() is complete.
142
- * Not read inside of this class, but needed for LitElement to determine if
143
- * it's closest ancestor finished load()
144
- */
145
- this._postLoad = new Deferred();
146
- /**
147
- * Resolved once LitElement's loaded() is complete
148
- */
149
- this._postLoaded = new Deferred();
150
- /**
151
- * Direct offspring that should be awaited before loaded() is emitted
152
- */
153
- this._offspring = [];
154
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
155
- this._hmrSetProps = /* @__PURE__ */ new Set();
156
- this._hmrSetAttributes = /* @__PURE__ */ new Set();
157
- globalThis.devOnly$createdElements ??= [];
158
- globalThis.devOnly$createdElements.push(new WeakRef(this));
159
- }
160
- this._saveInstanceProperties();
161
- const ProxyClass = this.constructor;
162
- if (ProxyClass._LitConstructor) {
163
- this._initializeComponent({ a: ProxyClass._LitConstructor });
164
- } else {
165
- void ProxyClass._loadPromise.then(this._initializeComponent.bind(this)).catch((error) => {
166
- this._postLoaded.reject(error);
167
- setTimeout(() => {
168
- throw error;
169
- });
170
- });
171
- }
172
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
173
- ProxyClass._hmrInstances ??= [];
174
- ProxyClass._hmrInstances.push(new WeakRef(this));
175
- Object.defineProperty(this, "_store", {
176
- value: this._store,
177
- enumerable: false,
178
- configurable: true
179
- });
180
- }
181
- }
182
- static {
183
- this.lumina = true;
184
- }
185
- /** @internal */
186
- static _initializePrototype() {
187
- this._properties?.forEach(this._bindProp, this);
188
- this._asyncMethods?.forEach(this._bindAsync, this);
189
- this._syncMethods?.forEach(this._bindSync, this);
190
- }
191
- static _bindProp(propName) {
192
- defineProperty(this.prototype, propName, {
193
- configurable: true,
194
- enumerable: true,
195
- get() {
196
- return this._store[propName];
197
- },
198
- set(value) {
199
- this._store[propName] = value;
200
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
201
- this._hmrSetProps.add(propName);
202
- }
203
- }
204
- });
205
- }
206
- static _bindAsync(methodName) {
207
- defineProperty(this.prototype, methodName, {
208
- async value(...args) {
209
- if (!this._litElement) {
210
- await this._postLoaded.promise;
211
- }
212
- const genericLitElement = this._litElement;
213
- return await genericLitElement[methodName](...args);
214
- },
215
- configurable: true
216
- });
217
- }
218
- static _bindSync(methodName) {
219
- defineProperty(this.prototype, methodName, {
220
- value(...args) {
221
- if (process.env.NODE_ENV !== "production" && !this._litElement) {
222
- const ProxyClass = this.constructor;
223
- throw new Error(
224
- `Tried to call method ${methodName}() on <${ProxyClass._name}> component before it's fully loaded. Please do 'await component.componentOnReady();' before calling this method.`
225
- );
226
- }
227
- const genericLitElement = this._litElement;
228
- return genericLitElement[methodName](...args);
229
- },
230
- configurable: true
231
- });
232
- }
233
- get manager() {
234
- return this._litElement?.manager;
235
- }
236
- /**
237
- * Until the custom element is registered on the page, an instance of that
238
- * element can be constructed and some properties on that instance set.
239
- *
240
- * These properties are set before the element prototype is set to this proxy
241
- * class and thus none of our getters/setters are yet registered - such
242
- * properties will be set by JavaScript on the instance directly.
243
- *
244
- * Once element is registered, the properties set in the meanwhile will shadow
245
- * the getter/setters, and thus break reactivity. The fix is to delete these
246
- * properties from the instance, and re-apply them once accessors are set.
247
- *
248
- * @example
249
- * ```ts
250
- * import { defineCustomElements } from '@arcgis/map-components';
251
- * const map = document.createElement('arcgis-map');
252
- * // This will shadow the getter/setters
253
- * map.itemId = '...';
254
- * // This finally defines the custom elements and sets the property accessors
255
- * defineCustomElements();
256
- * ```
257
- *
258
- * @remarks
259
- * This is an equivalent of the __saveInstanceProperties method in Lit's
260
- * ReactiveElement. Lit takes care of this on LitElement, but we have to take
261
- * care of this on the lazy proxy
262
- */
263
- _saveInstanceProperties() {
264
- const ProxyClass = this.constructor;
265
- const genericThis = this;
266
- ProxyClass._properties?.forEach((propName) => {
267
- if (Object.hasOwn(this, propName)) {
268
- this._store[propName] = genericThis[propName];
269
- delete genericThis[propName];
270
- }
271
- });
272
- }
273
- /*
274
- * This method must be statically present rather than added later, or else,
275
- * browsers won't call it. Same for connected and disconnected callbacks.
276
- */
277
- attributeChangedCallback(name, oldValue, newValue) {
278
- this._litElement?.attributeChangedCallback(name, oldValue, newValue);
279
- if (!this._litElement) {
280
- this._pendingAttributes.push(name);
281
- }
282
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
283
- this._hmrSetAttributes.add(name);
284
- }
285
- }
286
- connectedCallback() {
287
- if (this._litElement) {
288
- this._litElement.connectedCallback?.();
289
- } else {
290
- queueMicrotask(() => {
291
- this._ancestorLoad = attachToAncestor(this);
292
- });
293
- }
294
- }
295
- disconnectedCallback() {
296
- this._litElement?.disconnectedCallback?.();
297
- }
298
- /**
299
- * Create a promise that resolves once component is fully loaded
300
- */
301
- async componentOnReady() {
302
- await this._postLoaded.promise;
303
- return this;
304
- }
305
- /** @internal */
306
- _initializeComponent(module) {
307
- const ProxyClass = this.constructor;
308
- const tagName = ProxyClass._name;
309
- const store = this._store;
310
- const LitConstructor = Object.values(module).find(
311
- (LitConstructor2) => LitConstructor2.tagName === tagName
312
- );
313
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !LitConstructor) {
314
- throw new Error(
315
- `Unable to find the LitElement class for the "${tagName}" custom element in the lazy-loaded module`
316
- );
317
- }
318
- const lazyTagName = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (ProxyClass._hmrIndex ?? 0) === 0 ? `${tagName}--lazy` : `${tagName}--lazy-${ProxyClass._hmrIndex}` : `${tagName}--lazy`;
319
- let parentClass = LitConstructor;
320
- while (parentClass && !Object.hasOwn(parentClass, "lumina")) {
321
- parentClass = Object.getPrototypeOf(parentClass);
322
- }
323
- patchLitElement(parentClass);
324
- const isFirstInitialization = !ProxyClass._LitConstructor;
325
- if (isFirstInitialization) {
326
- ProxyClass._LitConstructor = LitConstructor;
327
- customElements.define(lazyTagName, LitConstructor);
328
- }
329
- LitConstructor.lazy = this;
330
- const litElement = document.createElement(lazyTagName);
331
- LitConstructor.lazy = void 0;
332
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
333
- Object.defineProperty(this, "_litElement", {
334
- value: litElement,
335
- configurable: true,
336
- enumerable: false
337
- });
338
- } else {
339
- this._litElement = litElement;
340
- }
341
- this._store = litElement;
342
- this._pendingAttributes.forEach((name) => {
343
- const value = this.getAttribute(name);
344
- litElement.attributeChangedCallback(
345
- name,
346
- // Lit doesn't look at this value, thus even if attribute already exists, that's ok
347
- null,
348
- value
349
- );
350
- });
351
- Object.entries(store).forEach(syncLitElement, litElement);
352
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
353
- const litObserved = LitConstructor.observedAttributes ?? [];
354
- const lazyObserved = ProxyClass.observedAttributes ?? [];
355
- const missingFromLazy = litObserved.filter((attribute) => !lazyObserved.includes(attribute));
356
- const missingFromLit = lazyObserved.filter((attribute) => !litObserved.includes(attribute));
357
- if (missingFromLazy.length > 0) {
358
- console.warn(
359
- `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`
360
- );
361
- }
362
- if (missingFromLit.length > 0) {
363
- console.warn(
364
- `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`
365
- );
366
- }
367
- }
368
- const isStillConnected = this.isConnected;
369
- if (isStillConnected || this._ancestorLoad) {
370
- litElement.connectedCallback?.();
371
- if (!isStillConnected) {
372
- litElement.disconnectedCallback();
373
- }
374
- }
375
- }
376
- /**
377
- * Implemented on the proxy for compatibility with Lit Context.
378
- */
379
- addController() {
380
- }
381
- /**
382
- * Implemented on the proxy for compatibility with Lit Context.
383
- */
384
- requestUpdate() {
385
- this._litElement?.requestUpdate();
386
- }
387
- };
388
- function syncLitElement([key, value]) {
389
- this[key] = value;
390
- }
391
- function patchLitElement(parentClass) {
392
- const litElementPrototype = parentClass.prototype;
393
- const elementPrototype = Element.prototype;
394
- const alreadyPatched = Object.hasOwn(litElementPrototype, "isConnected");
395
- if (!alreadyPatched) {
396
- litElementPrototype.setAttribute = function(qualifiedName, value) {
397
- elementPrototype.setAttribute.call(this.el, qualifiedName, value);
398
- };
399
- litElementPrototype.removeAttribute = function(qualifiedName) {
400
- elementPrototype.removeAttribute.call(this.el, qualifiedName);
401
- };
402
- defineProperty(litElementPrototype, "isConnected", {
403
- get() {
404
- return Reflect.get(elementPrototype, "isConnected", this.el);
405
- }
406
- });
407
- }
408
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
409
- devOnlyDetectIncorrectLazyUsages(parentClass);
410
- }
411
- }
412
-
413
- // src/utils.ts
414
- var noShadowRoot = {};
415
-
416
- export {
417
- attachToAncestor,
418
- makeDefineCustomElements,
419
- ProxyComponent,
420
- noShadowRoot
421
- };
@@ -1,21 +0,0 @@
1
- // src/config.ts
2
- var lazyMetaGroupJoiner = ";";
3
- var lazyMetaItemJoiner = ",";
4
- var lazyMetaSubItemJoiner = ":";
5
- var PropertyFlags = /* @__PURE__ */ ((PropertyFlags2) => {
6
- PropertyFlags2[PropertyFlags2["ATTRIBUTE"] = 1] = "ATTRIBUTE";
7
- PropertyFlags2[PropertyFlags2["REFLECT"] = 2] = "REFLECT";
8
- PropertyFlags2[PropertyFlags2["BOOLEAN"] = 4] = "BOOLEAN";
9
- PropertyFlags2[PropertyFlags2["NUMBER"] = 8] = "NUMBER";
10
- PropertyFlags2[PropertyFlags2["STATE"] = 16] = "STATE";
11
- PropertyFlags2[PropertyFlags2["READ_ONLY"] = 32] = "READ_ONLY";
12
- PropertyFlags2[PropertyFlags2["NO_ACCESSOR"] = 64] = "NO_ACCESSOR";
13
- return PropertyFlags2;
14
- })(PropertyFlags || {});
15
-
16
- export {
17
- lazyMetaGroupJoiner,
18
- lazyMetaItemJoiner,
19
- lazyMetaSubItemJoiner,
20
- PropertyFlags
21
- };
@@ -1 +0,0 @@
1
- export {};