@arcgis/lumina 4.34.0-next.2 → 4.34.0-next.21

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.
@@ -22,6 +22,7 @@ class AccessorController extends GenericController {
22
22
  constructor(component, createInstance) {
23
23
  super(component);
24
24
  this.Y = /* @__PURE__ */ new Map();
25
+ this.A = void 0;
25
26
  this.#exportsObservable = createObservable();
26
27
  const that = this;
27
28
  that.#createInstance = createInstance;
@@ -107,9 +108,12 @@ const makeBinderProxy = (component, accessorControllerRef, accessorControllerInd
107
108
  ) {
108
109
  return value;
109
110
  }
111
+ const accessorController = component.M[accessorControllerIndex];
112
+ accessorController.A = propertyName;
110
113
  return trackKey(
111
114
  component,
112
115
  (resolved) => {
116
+ accessorController.A = void 0;
113
117
  if (resolved !== void 0) {
114
118
  const propName = resolved.key;
115
119
  boundProperties.set(propertyName, propName);
@@ -120,15 +124,15 @@ const makeBinderProxy = (component, accessorControllerRef, accessorControllerInd
120
124
  if (!(propertyName in instance)) {
121
125
  throw new Error(`"${propertyName}" does not exist on the accessor instance`);
122
126
  }
123
- const accessorController = component.M[accessorControllerIndex];
127
+ const accessorController2 = component.M[accessorControllerIndex];
124
128
  if (descriptor.i !== void 0 && descriptor.i !== accessorControllerIndex) {
125
- console.error(component.M[descriptor.i], accessorController);
129
+ console.error(component.M[descriptor.i], accessorController2);
126
130
  throw Error(
127
131
  `Expected property "${propName}" to be bound to the controller at index ${descriptor.i}, but tried to bind it to a controller at index ${accessorControllerIndex}. Double check whether you are calling useAccessor() conditionally in a way that is not supported.`
128
132
  );
129
133
  }
130
- if (accessorController !== accessorControllerRef.deref()) {
131
- console.error(accessorController);
134
+ if (accessorController2 !== accessorControllerRef.deref()) {
135
+ console.error(accessorController2);
132
136
  throw Error(
133
137
  `Expected controller at index ${accessorControllerIndex} to be instance of useAccessor but it is not.`
134
138
  );
@@ -156,13 +160,6 @@ const makeBinderProxy = (component, accessorControllerRef, accessorControllerInd
156
160
  },
157
161
  value
158
162
  );
159
- },
160
- set(_target, propertyName, newValue) {
161
- if (boundProperties.has(propertyName) || // But some properties may be never bound, yet set in the constructor - let them through
162
- newValue !== (instance[propertyName] ?? void 0)) {
163
- instance[propertyName] = newValue;
164
- }
165
- return true;
166
163
  }
167
164
  });
168
165
  const watchBoundProperty = (controllerRef, descriptor, propertyName, propName, shouldFlipBoolean, _handle) => _handle = watch(
@@ -199,7 +196,10 @@ const bindPropToProperty = (descriptor, accessorControllerIndex, propertyName, s
199
196
  return shouldFlipBoolean ? !value : value;
200
197
  };
201
198
  descriptor.d.set = function(newValue) {
202
- this.M[accessorControllerIndex].exports[propertyName] = shouldFlipBoolean ? !newValue : newValue;
199
+ const accessorController = this.M[accessorControllerIndex];
200
+ if (accessorController.A !== propertyName) {
201
+ accessorController.exports[propertyName] = shouldFlipBoolean ? !newValue : newValue;
202
+ }
203
203
  };
204
204
  };
205
205
  const getAccessorControllerBoundProperties = (controller) => controller.Y;
@@ -212,10 +212,15 @@ const reCreateAccessor = (instance, component) => {
212
212
  console.error("Unable to resolve the useAccessor controller from the provided value");
213
213
  }
214
214
  };
215
- const createStore = (defaultValues) => {
215
+ const createStore = (initializer) => {
216
216
  const SubClass = class extends Accessor {
217
217
  };
218
- Object.entries(defaultValues).forEach(([name, value]) => property({ value })(SubClass.prototype, name));
218
+ const defaultValues = typeof initializer === "function" ? initializer() : initializer;
219
+ const descriptors = Object.getOwnPropertyDescriptors(defaultValues);
220
+ for (const [key, descriptor] of Object.entries(descriptors)) {
221
+ Object.defineProperty(SubClass.prototype, key, descriptor);
222
+ property()(SubClass.prototype, key);
223
+ }
219
224
  const State = subclass()(SubClass);
220
225
  return new State();
221
226
  };
@@ -2,7 +2,7 @@ import { default as Accessor } from '@arcgis/core/core/Accessor.js';
2
2
  /**
3
3
  * See https://qawebgis.esri.com/components/lumina/controllers/useAccessor#createstore-utility
4
4
  */
5
- export declare const createStore: <T extends Record<string, unknown>>(defaultValues: T | (() => T)) => __esri.Accessor & T;
5
+ export declare const createStore: <T extends Record<string, unknown>>(initializer: T | (() => T)) => __esri.Accessor & T;
6
6
  /** @deprecated Use {@link createStore} instead */
7
7
  export declare const createLegacyStore: <T extends Record<string, unknown>>(defaultState: T | (() => T)) => ObservableMap<T>;
8
8
  /** @deprecated Use {@link createStore} instead */
@@ -1,4 +1,4 @@
1
- import { Controller, GenericController } from '../Controller';
1
+ import { GenericController } from '../Controller';
2
2
  import { LitElement } from '../../LitElement';
3
3
  type Requires<Props, Accessor extends __esri.Accessor, OmitProps extends string = never> = LitElement & Omit<Pick<Accessor, keyof Accessor & keyof Props>, AlwaysOmit | OmitProps> & {
4
4
  autoDestroyDisabled: boolean;
@@ -46,6 +46,8 @@ export declare class AccessorController<Props, Accessor extends __esri.Accessor,
46
46
  * @private
47
47
  */
48
48
  _boundAccessorProperties: Map<string & keyof Accessor, string>;
49
+ /** @private */
50
+ _currentlyBindingPropertyName?: string;
49
51
  /**
50
52
  * (development only) Allow these props to mismatch the name of the Accessor's
51
53
  * property to avoid collisions
@@ -61,8 +63,11 @@ export declare class AccessorController<Props, Accessor extends __esri.Accessor,
61
63
  hostConnected(): void;
62
64
  hostDestroy(): void;
63
65
  }
64
- export declare const makeBinderProxy: (component: LitElement, accessorControllerRef: WeakRef<Pick<Controller<__esri.Accessor>, "component" | "exports"> & {
65
- constructor: (typeof __esri.Accessor)["constructor"] & {
66
+ type MinimalAccessorController = Pick<AccessorController<never, __esri.Accessor>, "_currentlyBindingPropertyName" | "exports"> & {
67
+ component: LitElement;
68
+ };
69
+ export declare const makeBinderProxy: (component: LitElement, accessorControllerRef: WeakRef<MinimalAccessorController & {
70
+ constructor: MinimalAccessorController["constructor"] & {
66
71
  devOnly$allowedPropNameMismatches?: ReadonlySet<string>;
67
72
  };
68
73
  }>, accessorControllerIndex: number, instance: __esri.Accessor, boundProperties: Map<string, string>) => unknown;
@@ -127,7 +127,7 @@ const useDirection = () => makeController((component, controller) => {
127
127
  (resolved) => {
128
128
  if (resolved?.key === "dir") {
129
129
  throw new Error(
130
- `Do not assign this controller to a prop called \`dir\` as that will overwrite the \`dir\` attribute on the host element - component should not be setting the \`dir\` attribute on itself. Instead, assign this controller to a property called \`direction\`.`
130
+ "Do not assign this controller to a prop called `dir` as that will overwrite the HTMLElement's built-in `dir` attribute - component should not be setting the `dir` attribute on itself. Instead, assign this controller to a property called `direction`."
131
131
  );
132
132
  }
133
133
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/lumina",
3
- "version": "4.34.0-next.2",
3
+ "version": "4.34.0-next.21",
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.34.0-next.2",
25
+ "@arcgis/components-utils": "4.34.0-next.21",
26
26
  "@lit-labs/ssr": "^3.2.2",
27
27
  "@lit-labs/ssr-client": "^1.1.7",
28
28
  "@lit/context": "^1.1.5",