@arcgis/lumina 4.33.0-next.135 → 4.33.0-next.137

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.
@@ -1,4 +1,4 @@
1
- import { BaseController, ReactiveTrackingTarget } from './types';
1
+ import { BaseController } from './types';
2
2
  import { GenericController } from './Controller';
3
3
  import { PropertyValues } from 'lit';
4
4
  import { LitElement } from '../LitElement';
@@ -28,25 +28,6 @@ export declare class ControllerManager extends GenericController<undefined> {
28
28
  * @private
29
29
  */
30
30
  _isEnforcingReadonly: boolean;
31
- /**
32
- * A possible reference to JS API's createTrackingTarget() function to create
33
- * an observer that will keep track of what properties were accessed during
34
- * render().
35
- *
36
- * This property is set by useAccessor() if it was used on the component
37
- *
38
- * @private
39
- */
40
- _createTrackingTarget?: (callback: () => void) => ReactiveTrackingTarget;
41
- /**
42
- * A possible reference to JS API's runTracked() function to run update() with
43
- * property accesses tracking enabled.
44
- *
45
- * This property is set by useAccessor() if it was used on the component
46
- *
47
- * @private
48
- */
49
- _runTracked?: (target: ReactiveTrackingTarget, callback: () => void) => void;
50
31
  /** @private */
51
32
  _trackedValue: unknown;
52
33
  /** @private */
@@ -1,2 +1,4 @@
1
- export { makeAccessorController, AccessorController, reCreateAccessor, makeBinderProxy, getAccessorControllerBoundProperties, } from './useAccessor';
2
1
  export { reEmitEvent } from './reEmitEvent';
2
+ export { makeAccessorController, AccessorController, reCreateAccessor, makeBinderProxy, getAccessorControllerBoundProperties, } from './useAccessor';
3
+ export { createStore, createLegacyStore } from './store';
4
+ export type { ObservableMap } from './store';
@@ -1,8 +1,22 @@
1
- import { G as GenericController, l as trackPropKey, t as trackKey, r as retrieveComponent, f as createEventFactory } from "../../Controller-BQOv8BAL.js";
2
- import { p as proxyExports } from "../../proxyExports-Cdzj7WL_.js";
3
1
  import { isEsriInternalEnv } from "@arcgis/components-utils";
4
- import { watch, on } from "@arcgis/core/core/reactiveUtils.js";
5
- import { createObservable, createTrackingTarget, runTracked, trackAccess } from "@arcgis/core/applications/Components/reactiveUtils.js";
2
+ import { r as retrieveComponent, f as createEventFactory, G as GenericController, l as trackPropKey, t as trackKey } from "../../Controller-BQOv8BAL.js";
3
+ import { on, watch } from "@arcgis/core/core/reactiveUtils.js";
4
+ import { p as proxyExports } from "../../proxyExports-Cdzj7WL_.js";
5
+ import { createObservable, trackAccess } from "@arcgis/core/applications/Components/reactiveUtils.js";
6
+ import { property, subclass } from "@arcgis/core/core/accessorSupport/decorators.js";
7
+ import Accessor from "@arcgis/core/core/Accessor.js";
8
+ const reEmitEvent = (getEventedAccessor, eventName) => {
9
+ const component = retrieveComponent();
10
+ const manager = component.manager;
11
+ manager.onLoaded(() => manager.onLifecycle(() => on(getEventedAccessor, eventName, emitter.emit)));
12
+ const emitter = createEventFactory();
13
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
14
+ if (typeof emitter !== "object" || emitter === null || !("emit" in emitter) || typeof emitter.emit !== "function") {
15
+ throw new Error(`Expected to find $createEvent static property on Lumina's LitElement`);
16
+ }
17
+ }
18
+ return emitter;
19
+ };
6
20
  const makeAccessorController = (createInstance, _options) => (component) => proxy(component, createInstance);
7
21
  class AccessorController extends GenericController {
8
22
  constructor(component, createInstance) {
@@ -12,8 +26,6 @@ class AccessorController extends GenericController {
12
26
  const that = this;
13
27
  that.#createInstance = createInstance;
14
28
  that.Z();
15
- component.manager.A = createTrackingTarget;
16
- component.manager.B = runTracked;
17
29
  that.setProvisionalExports(
18
30
  makeBinderProxy(
19
31
  component,
@@ -156,10 +168,7 @@ const makeBinderProxy = (component, accessorControllerRef, accessorControllerInd
156
168
  const watchBoundProperty = (controllerRef, descriptor, propertyName, propName, shouldFlipBoolean, _handle) => _handle = watch(
157
169
  () => {
158
170
  const controller = controllerRef.deref();
159
- return controller === void 0 || controller.component.manager.destroyed ? (
160
- // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
161
- _handle = _handle.remove()
162
- ) : controller.exports[propertyName];
171
+ return controller === void 0 || controller.component.manager.destroyed ? _handle = _handle.remove() : controller.exports[propertyName];
163
172
  },
164
173
  (_, oldValue) => {
165
174
  if (!_handle) {
@@ -203,20 +212,31 @@ const reCreateAccessor = (instance, component) => {
203
212
  console.error("Unable to resolve the useAccessor controller from the provided value");
204
213
  }
205
214
  };
206
- const reEmitEvent = (getEventedAccessor, eventName) => {
207
- const component = retrieveComponent();
208
- const manager = component.manager;
209
- manager.onLoaded(() => manager.onLifecycle(() => on(getEventedAccessor, eventName, emitter.emit)));
210
- const emitter = createEventFactory();
211
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
212
- if (typeof emitter !== "object" || emitter === null || !("emit" in emitter) || typeof emitter.emit !== "function") {
213
- throw new Error(`Expected to find $createEvent static property on Lumina's LitElement`);
214
- }
215
- }
216
- return emitter;
215
+ const createStore = (defaultValues) => {
216
+ const SubClass = class extends Accessor {
217
+ };
218
+ Object.entries(defaultValues).forEach(([name, value]) => property({ value })(SubClass.prototype, name));
219
+ const State = subclass()(SubClass);
220
+ return new State();
221
+ };
222
+ const createLegacyStore = (defaultState) => {
223
+ const defaultValues = typeof defaultState === "function" ? defaultState() : defaultState;
224
+ const state = createStore(defaultValues);
225
+ return {
226
+ state,
227
+ get: (propName) => state[propName],
228
+ set: (propName, value) => state.set(propName, value),
229
+ onChange: (propName, callback) => watch(
230
+ () => state[propName],
231
+ (newValue) => callback(newValue),
232
+ { sync: true }
233
+ ).remove
234
+ };
217
235
  };
218
236
  export {
219
237
  AccessorController,
238
+ createLegacyStore,
239
+ createStore,
220
240
  getAccessorControllerBoundProperties,
221
241
  makeAccessorController,
222
242
  makeBinderProxy,
@@ -0,0 +1,17 @@
1
+ import { default as Accessor } from '@arcgis/core/core/Accessor.js';
2
+ /**
3
+ * See https://qawebgis.esri.com/components/lumina/controllers/useAccessor#createstore-utility
4
+ */
5
+ export declare const createStore: <T extends Record<string, unknown>>(defaultValues: T | (() => T)) => __esri.Accessor & T;
6
+ /** @deprecated Use {@link createStore} instead */
7
+ export declare const createLegacyStore: <T extends Record<string, unknown>>(defaultState: T | (() => T)) => ObservableMap<T>;
8
+ /** @deprecated Use {@link createStore} instead */
9
+ export type ObservableMap<T> = {
10
+ state: Accessor & T;
11
+ /** @deprecated Use state[propertyName] instead */
12
+ get: <P extends keyof T>(propName: P & string) => T[P];
13
+ /** @deprecated Use state[propertyName]=value instead */
14
+ set: <P extends keyof T>(propName: P & string, value: T[P]) => void;
15
+ /** @deprecated Use reactiveUtils.watch instead */
16
+ onChange: <Key extends keyof T>(propName: Key, callback: (newValue: T[Key]) => void) => () => void;
17
+ };
package/dist/index.js CHANGED
@@ -354,7 +354,7 @@ class LitElement extends LitElement$1 {
354
354
  if (this.el.hasAttribute("defer-hydration")) {
355
355
  return;
356
356
  }
357
- const trackingTarget = this.manager.A?.(() => this.requestUpdate());
357
+ const trackingTarget = this.constructor.K.c?.(() => this.requestUpdate());
358
358
  this.#trackingTarget = trackingTarget;
359
359
  const isFirstCall = !this.manager.connectedCalled;
360
360
  super.connectedCallback();
@@ -375,7 +375,10 @@ class LitElement extends LitElement$1 {
375
375
  #doTrackedUpdate(changedProperties) {
376
376
  try {
377
377
  this.#trackingTarget.clear();
378
- this.manager.B(this.#trackingTarget, () => super.update(changedProperties));
378
+ this.constructor.K.r(
379
+ this.#trackingTarget,
380
+ () => super.update(changedProperties)
381
+ );
379
382
  } catch (error) {
380
383
  this.#trackingTarget.clear();
381
384
  throw error;
@@ -626,10 +629,13 @@ const makeReactWrapperFactory = (react, createComponent) => (options) => {
626
629
  */
627
630
  get prototype() {
628
631
  if (customElementPrototype === void 0) {
629
- customElementPrototype = customElements.get(tagName)?.prototype;
630
- if (!customElementPrototype) {
632
+ const customElement = customElements.get(tagName);
633
+ if (!customElement) {
631
634
  throw new Error(`Custom element "${tagName}" not found`);
632
635
  }
636
+ customElement.F?.();
637
+ customElement.F = emptyFunction;
638
+ customElementPrototype = customElement.prototype;
633
639
  Object.defineProperty(elementClass, "prototype", { value: customElementPrototype });
634
640
  }
635
641
  return customElementPrototype;
@@ -1,6 +1,6 @@
1
1
  import { CSSResult } from 'lit';
2
2
  import { LitElement } from './LitElement';
3
- import { AccessorObservableLike } from './controllers/types';
3
+ import { AccessorObservableLike, ReactiveTrackingTarget } from './controllers/types';
4
4
  /**
5
5
  * `@arcgis/lumina` package may be bundled once but used by multiple packages with
6
6
  * different configuration options. For that reason, the configuration options
@@ -73,8 +73,25 @@ export type Runtime = RuntimeOptions & {
73
73
  * In CDN build, we can only import @arcgis/core async, so the lazy loader will need
74
74
  * to await this promise before beginning hydration so that the reactiveUtils
75
75
  * integration modules had time to load.
76
+ *
77
+ * @private
76
78
  */
77
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;
78
95
  };
79
96
  export type RuntimeOptions = {
80
97
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/lumina",
3
- "version": "4.33.0-next.135",
3
+ "version": "4.33.0-next.137",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "license": "SEE LICENSE IN LICENSE.md",
24
24
  "dependencies": {
25
- "@arcgis/components-utils": "4.33.0-next.135",
25
+ "@arcgis/components-utils": "4.33.0-next.137",
26
26
  "@lit-labs/ssr": "^3.2.2",
27
27
  "@lit-labs/ssr-client": "^1.1.7",
28
28
  "@lit/context": "^1.1.5",