@arcgis/lumina 4.33.0-next.99 → 4.33.1

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 (36) hide show
  1. package/dist/{Controller-CZ8Djohh.js → Controller-BQOv8BAL.js} +170 -210
  2. package/dist/LitElement.d.ts +22 -18
  3. package/dist/config.d.ts +7 -9
  4. package/dist/config.js +15 -12
  5. package/dist/context.d.ts +2 -2
  6. package/dist/controllers/Controller.d.ts +4 -10
  7. package/dist/controllers/ControllerInternals.d.ts +7 -13
  8. package/dist/controllers/ControllerManager.d.ts +6 -21
  9. package/dist/controllers/accessor/index.d.ts +3 -1
  10. package/dist/controllers/accessor/index.js +208 -222
  11. package/dist/controllers/accessor/reEmitEvent.d.ts +1 -1
  12. package/dist/controllers/accessor/store.d.ts +17 -0
  13. package/dist/controllers/accessor/useAccessor.d.ts +34 -32
  14. package/dist/controllers/index.d.ts +2 -2
  15. package/dist/controllers/index.js +45 -38
  16. package/dist/controllers/trackKey.d.ts +1 -1
  17. package/dist/controllers/trackPropKey.d.ts +1 -1
  18. package/dist/controllers/trackPropertyKey.d.ts +2 -2
  19. package/dist/controllers/types.d.ts +35 -0
  20. package/dist/controllers/usePropertyChange.d.ts +3 -1
  21. package/dist/controllers/utils.d.ts +6 -9
  22. package/dist/createEvent.d.ts +4 -4
  23. package/dist/hmrSupport.js +22 -22
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +193 -200
  26. package/dist/jsx/generatedTypes.d.ts +414 -80
  27. package/dist/lazyLoad-DUvrNd2L.js +406 -0
  28. package/dist/lazyLoad.d.ts +22 -67
  29. package/dist/lifecycleSupport.d.ts +1 -1
  30. package/dist/makeRuntime.d.ts +40 -1
  31. package/dist/{proxyExports-CK5BLFLO.js → proxyExports-Cdzj7WL_.js} +8 -8
  32. package/dist/render.d.ts +1 -1
  33. package/dist/utils.d.ts +8 -0
  34. package/dist/wrappersUtils.d.ts +13 -1
  35. package/package.json +5 -5
  36. package/dist/utils-DBdf1Dqp.js +0 -405
@@ -1,259 +1,245 @@
1
- import { p as devOnlySetPersistentControllerData, q as devOnlyGetPersistentControllerData, G as GenericController, n as trackPropKey, h as bypassGetter, l as bypassReadOnly, t as trackKey, r as retrieveComponent, g as createEventFactory } from "../../Controller-CZ8Djohh.js";
2
- import { p as proxyExports } from "../../proxyExports-CK5BLFLO.js";
3
1
  import { isEsriInternalEnv } from "@arcgis/components-utils";
4
- import { watch, on } from "@arcgis/core/core/reactiveUtils.js";
5
- const makeAccessorController = (loadAccessor, _options) => (component, options) => proxy(component, loadAccessor, options);
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
+ };
20
+ const makeAccessorController = (createInstance, _options) => (component) => proxy(component, createInstance);
6
21
  class AccessorController extends GenericController {
7
- constructor(component, _loadAccessor, _options) {
22
+ constructor(component, createInstance) {
8
23
  super(component);
9
- this._loadAccessor = _loadAccessor;
10
- this._options = _options;
11
- this._watchedProperties = /* @__PURE__ */ new Map();
12
- this._isBinding = { value: true };
13
- this.setProvisionalExports(
14
- accessorSupport.makeGetterProxy(
24
+ this.Y = /* @__PURE__ */ new Map();
25
+ this.A = void 0;
26
+ this.#exportsObservable = createObservable();
27
+ const that = this;
28
+ that.#createInstance = createInstance;
29
+ that.Z();
30
+ that.setProvisionalExports(
31
+ makeBinderProxy(
15
32
  component,
16
- this._watchedProperties,
17
- this._isBinding,
18
- this.constructor.allowedPropNameMismatches
19
- )
33
+ new WeakRef(that),
34
+ component.M.length - 1,
35
+ that.instance,
36
+ that.Y
37
+ ),
38
+ false
20
39
  );
21
40
  trackPropKey(
22
41
  component,
23
42
  (resolved) => {
24
43
  if (resolved) {
25
- this._instancePropName = resolved;
44
+ const handle = watch(
45
+ // If the property to which controller is assigned is public, the user may
46
+ // manually create an accessor instance and assign it to this property
47
+ // We pick it up and replace our created accessor instance with user's.
48
+ () => component[resolved],
49
+ (newInstance) => {
50
+ if (newInstance === that.instance) {
51
+ return;
52
+ }
53
+ const oldInstance = that.instance;
54
+ that.exports = newInstance;
55
+ that.instance = newInstance;
56
+ that.Y.forEach(
57
+ (propName, propertyName) => component.requestUpdate(propName, oldInstance[propertyName])
58
+ );
59
+ if (that.#isInstanceOwner) {
60
+ oldInstance.destroy();
61
+ }
62
+ that.#isInstanceOwner = false;
63
+ },
64
+ { sync: true }
65
+ );
66
+ that.onDestroy(handle.remove);
26
67
  }
27
68
  },
28
- this.exports
69
+ that.exports
29
70
  );
30
71
  }
31
- hostConnected() {
32
- this._isBinding.value = false;
72
+ #isInstanceOwner;
73
+ #exportsObservable;
74
+ #createInstance;
75
+ get exports() {
76
+ trackAccess(this.#exportsObservable);
77
+ return super.exports;
33
78
  }
34
- async hostLoad() {
35
- const component = this.component;
36
- const parameters = this._gatherParameters();
37
- const finalParameters = this._options?.editConstructorProperties?.call(component, parameters) ?? parameters;
38
- const awaitedParameters = finalParameters instanceof Promise ? await finalParameters : finalParameters;
39
- const genericComponent = component;
40
- const existingInstance = typeof this._instancePropName === "string" ? genericComponent[this._instancePropName] : void 0;
41
- const hasInstance = existingInstance != null && existingInstance !== this.exports;
42
- if (hasInstance) {
43
- this._instance = existingInstance;
44
- existingInstance.set(awaitedParameters);
45
- } else {
46
- this._instance = await this._createInstance(awaitedParameters);
47
- }
48
- if (component.manager.destroyed) {
49
- return;
50
- }
51
- accessorSupport.watchComponentUpdates(this, this._instance, this._watchedProperties);
52
- accessorSupport.watchAccessorUpdates(this, this._instance, this._watchedProperties);
53
- this.exports = this._instance;
54
- }
55
- _gatherParameters() {
56
- const data = Object.fromEntries(
57
- Array.from(
58
- this._watchedProperties,
59
- ([prop, property]) => [property, this.component[prop]]
60
- ).filter(([, value]) => value !== void 0)
61
- );
62
- const props = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? filterWatchedProperties?.(this, data) ?? data : data;
63
- return props;
79
+ set exports(value) {
80
+ super.exports = value;
81
+ this.#exportsObservable.notify();
64
82
  }
65
- async _createInstance(parameters) {
66
- if (this._isAccessorConstructor(this._loadAccessor)) {
67
- return new this._loadAccessor(parameters);
68
- } else {
69
- return await this._loadAccessor(parameters);
70
- }
83
+ /** @private */
84
+ Z() {
85
+ const that = this;
86
+ that.instance = "prototype" in that.#createInstance && "declaredClass" in that.#createInstance.prototype ? new that.#createInstance() : that.#createInstance();
87
+ that.#isInstanceOwner = true;
71
88
  }
72
- _isAccessorConstructor(loader) {
73
- return "prototype" in loader && "declaredClass" in loader.prototype;
89
+ hostConnected() {
90
+ this.exports = this.instance;
74
91
  }
92
+ // FEATURE: is there a way to detect that accessor does not need to be destroyed?
93
+ // Is it possible to write accessors that don't need to be destroyed?
75
94
  hostDestroy() {
76
- if (this._instance) {
77
- this._instance.destroy();
95
+ if (this.#isInstanceOwner) {
96
+ this.instance.destroy?.();
78
97
  }
79
98
  }
80
- async reCreate() {
81
- this.hostDestroy();
82
- await this.hostLoad();
83
- }
84
99
  }
85
100
  const proxy = proxyExports(AccessorController);
86
- const accessorSupport = {
87
- makeGetterProxy: (component, watchedProperties, isBinding, allowedPropNameMismatches) => new Proxy(
88
- {},
89
- {
90
- /*
91
- * Without this, makeProvisionalValue() will throw on accessing
92
- * non-existent prop
93
- */
94
- has: (target, prop) => typeof prop === "string" || prop in target,
95
- get: (target, prop) => {
96
- const value = Reflect.get(target, prop);
97
- if (typeof prop === "symbol" || prop in Promise.prototype) {
98
- return value;
99
- }
100
- const hasProp = prop in target;
101
- const doBinding = isBinding?.value ?? true;
102
- if (hasProp || !doBinding) {
103
- return value;
104
- }
105
- if (watchedProperties.has(prop)) {
106
- return;
107
- }
108
- return trackKey(
109
- component,
110
- (resolved) => {
111
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
112
- if (resolved === void 0) {
113
- return;
114
- }
115
- const isFlippingBoolean = resolved.key.toLowerCase().includes("disable");
116
- const collidesWithNativeProp = prop in HTMLElement.prototype;
117
- const collidesWithCustomProp = allowedPropNameMismatches?.has(prop) === true;
118
- if (resolved.key !== prop && !collidesWithNativeProp && !collidesWithCustomProp && !isFlippingBoolean) {
119
- throw new Error(
120
- `Tried to bind "${resolved?.key}" property to "${prop.toString()}" - property names must match`
121
- );
122
- }
123
- if (!resolved.isReactive) {
124
- throw new Error(
125
- `For two-way binding with Accessor to work, the property on your component must have @property() or @state() decorator. "${prop.toString()}" has neither`
126
- );
127
- }
101
+ const makeBinderProxy = (component, accessorControllerRef, accessorControllerIndex, instance, boundProperties) => new Proxy(instance, {
102
+ get: (target, propertyName) => {
103
+ const value = target[propertyName];
104
+ if (
105
+ // Possibly called by the JS engine
106
+ typeof propertyName === "symbol" || // Already bound?
107
+ boundProperties.has(propertyName)
108
+ ) {
109
+ return value;
110
+ }
111
+ const accessorController = component.M[accessorControllerIndex];
112
+ accessorController.A = propertyName;
113
+ return trackKey(
114
+ component,
115
+ (resolved) => {
116
+ accessorController.A = void 0;
117
+ if (resolved !== void 0) {
118
+ const propName = resolved.key;
119
+ boundProperties.set(propertyName, propName);
120
+ const descriptor = component.constructor.getPropertyOptions(
121
+ propName
122
+ );
123
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
124
+ if (!(propertyName in instance)) {
125
+ throw new Error(`"${propertyName}" does not exist on the accessor instance`);
128
126
  }
129
- if (resolved !== void 0) {
130
- watchedProperties.set(resolved.key, prop);
127
+ const accessorController2 = component.M[accessorControllerIndex];
128
+ if (descriptor.i !== void 0 && descriptor.i !== accessorControllerIndex) {
129
+ console.error(component.M[descriptor.i], accessorController2);
130
+ throw Error(
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.`
132
+ );
133
+ }
134
+ if (accessorController2 !== accessorControllerRef.deref()) {
135
+ console.error(accessorController2);
136
+ throw Error(
137
+ `Expected controller at index ${accessorControllerIndex} to be instance of useAccessor but it is not.`
138
+ );
139
+ }
140
+ const isFlippingBoolean = resolved.key.toLowerCase().includes("disable");
141
+ const collidesWithNativeProp = propertyName in HTMLElement.prototype;
142
+ const collidesWithCustomProp = accessorControllerRef.deref().constructor.devOnly$allowedPropNameMismatches?.has(propName) === true;
143
+ if (resolved.key !== propertyName && !collidesWithNativeProp && !collidesWithCustomProp && !isFlippingBoolean) {
144
+ throw new Error(
145
+ `Tried to bind "${resolved?.key}" property to "${propertyName.toString()}" - property names must match`
146
+ );
147
+ }
148
+ if (!resolved.isReactive) {
149
+ throw new Error(
150
+ `For two-way binding with Accessor to work, the property on your component must have @property() or @state() decorator. "${propertyName.toString()}" has neither`
151
+ );
131
152
  }
132
- },
133
- value
134
- );
135
- }
136
- }
137
- ),
138
- // Update Accessor on component prop change
139
- watchComponentUpdates(controller, instance, watchedProperties) {
140
- function getter(_value, propName) {
141
- const propertyName = watchedProperties.get(propName);
142
- const value = instance[propertyName];
143
- const flipBoolean = typeof value === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
144
- return flipBoolean ? !value : value;
145
- }
146
- const setter = (newValue, _oldValue, propName) => {
147
- const propertyName = watchedProperties.get(propName);
148
- const value = instance[propertyName];
149
- const flipBoolean = typeof value === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
150
- const currentValue = flipBoolean ? !value : value ?? void 0;
151
- if (currentValue === newValue) {
152
- return newValue;
153
- }
154
- instance[propertyName] = flipBoolean ? !newValue : newValue;
155
- const finalValue = instance[propertyName];
156
- return flipBoolean ? !finalValue : finalValue;
157
- };
158
- const manager = controller.component.manager;
159
- watchedProperties.forEach((_propName, propertyName) => {
160
- manager._accessorGetter[propertyName] = getter;
161
- manager._accessorSetter[propertyName] = setter;
162
- });
163
- },
164
- // Update component on Accessor prop change
165
- watchAccessorUpdates(controller, instance, watchedProperties) {
166
- const { component } = controller;
167
- const genericComponent = component;
168
- const genericInstance = instance;
169
- const readonlyProps = findReadOnlyAccessorProps(instance);
170
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
171
- setReadonlyProps?.(controller, readonlyProps);
172
- }
173
- bypassGetter(
174
- () => (
175
- // Careful: Map's forEach callback arguments are (value, key), not (key, value)
176
- watchedProperties.forEach((propertyName, propName) => {
177
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !(propertyName in instance)) {
178
- throw new Error(`"${propertyName}" does not exist on the accessor instance`);
179
- }
180
- if (readonlyProps.has(propertyName)) {
181
- return;
182
153
  }
183
- const domValue = genericComponent[propName];
184
- const modelValue = genericInstance[propertyName] ?? void 0;
185
- const flipBoolean = typeof domValue === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
186
- const resolvedDomValue = flipBoolean ? !domValue : domValue;
187
- if (resolvedDomValue != null && modelValue !== resolvedDomValue) {
188
- genericInstance[propertyName] = resolvedDomValue;
154
+ const shouldFlipBoolean = propertyName !== propName && propName.toLowerCase().includes("disable");
155
+ watchBoundProperty(accessorControllerRef, descriptor, propertyName, propName, shouldFlipBoolean);
156
+ if (descriptor.i === void 0) {
157
+ bindPropToProperty(descriptor, accessorControllerIndex, propertyName, shouldFlipBoolean);
189
158
  }
190
- })
191
- )
159
+ }
160
+ },
161
+ value
192
162
  );
193
- controller.onLifecycle(() => {
194
- if (instance.destroyed) {
195
- return;
196
- }
197
- return Array.from(
198
- watchedProperties,
199
- ([propName, propertyName]) => watch(
200
- () => genericInstance[propertyName],
201
- () => {
202
- const newValue = genericInstance[propertyName];
203
- const flipBoolean = typeof newValue === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
204
- const resolvedNewValue = flipBoolean ? !newValue : newValue;
205
- bypassReadOnly(() => {
206
- genericComponent[propName] = resolvedNewValue;
207
- });
208
- },
209
- { initial: true }
210
- )
211
- );
212
- });
163
+ }
164
+ });
165
+ const watchBoundProperty = (controllerRef, descriptor, propertyName, propName, shouldFlipBoolean, _handle) => _handle = watch(
166
+ () => {
167
+ const controller = controllerRef.deref();
168
+ return controller === void 0 || controller.component.manager.destroyed ? _handle = _handle.remove() : controller.exports[propertyName];
213
169
  },
214
- async reCreate(instance, component) {
215
- const accessorController = component.manager.useRefSync(instance);
216
- if (accessorController === void 0) {
217
- if (process.env.NODE_ENV !== "production") {
218
- console.error("Unable to resolve the useAccessor controller from the provided value");
219
- }
170
+ (_, oldValue) => {
171
+ if (!_handle) {
220
172
  return;
221
173
  }
222
- await accessorController.reCreate();
223
- }
224
- };
225
- function findReadOnlyAccessorProps(instance) {
226
- const accessor = instance;
227
- const properties = Object.entries(accessor.__accessor__?.metadata ?? {});
228
- return new Set(
229
- properties.filter(([_property, descriptor]) => descriptor?.readOnly === true).map(([property]) => property)
230
- );
231
- }
232
- const setReadonlyProps = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (controller, properties) => {
233
- devOnlySetPersistentControllerData?.(controller, properties);
234
- } : void 0;
235
- const filterWatchedProperties = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (controller, data) => {
236
- const readonlyProperties = devOnlyGetPersistentControllerData?.(controller);
237
- if (readonlyProperties instanceof Set) {
238
- return Object.fromEntries(Object.entries(data).filter(([key]) => !readonlyProperties.has(key)));
239
- }
240
- return data;
241
- } : void 0;
242
- function reEmitEvent(getEventedAccessor, eventName) {
243
- const component = retrieveComponent();
244
- const manager = component.manager;
245
- manager.onLoaded(() => manager.onLifecycle(() => on(getEventedAccessor, eventName, emitter.emit)));
246
- const emitter = createEventFactory();
247
- if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
248
- if (typeof emitter !== "object" || emitter === null || !("emit" in emitter) || typeof emitter.emit !== "function") {
249
- throw new Error(`Expected to find $createEvent static property on Lumina's LitElement`);
174
+ const component = controllerRef.deref().component;
175
+ component?.requestUpdate(propName, shouldFlipBoolean ? !oldValue : oldValue);
176
+ descriptor.c = false;
177
+ },
178
+ // At present, since useAccessor initializes the Accessor instance without
179
+ // any properties, it assumes that there is no need to do initial sync of
180
+ // accessor properties to the component, especially since the component
181
+ // setter always gets the newest value from the Accessor instance anyway.
182
+ // We might wish to change that if view model is shared between multiple
183
+ // components and has default value for some property. Even then, this issue
184
+ // will only manifest itself in default value not being reflected to
185
+ // attribute (). If fixing above becomes important, can do so by adding
186
+ // `initial: true` here and updating the above code to only call .notify()
187
+ // if hasChanged returns true (see reference implementation in
188
+ // _handleInstanceChanged). Not doing so yet as it is an edge case that is
189
+ // easy to work around and proper fix will add overhead to the startup of
190
+ // each component.
191
+ { sync: true }
192
+ );
193
+ const bindPropToProperty = (descriptor, accessorControllerIndex, propertyName, shouldFlipBoolean) => {
194
+ descriptor.d.get = function() {
195
+ const value = this.M[accessorControllerIndex]?.exports[propertyName];
196
+ return shouldFlipBoolean ? !value : value;
197
+ };
198
+ descriptor.d.set = function(newValue) {
199
+ const accessorController = this.M[accessorControllerIndex];
200
+ if (accessorController.A !== propertyName) {
201
+ accessorController.exports[propertyName] = shouldFlipBoolean ? !newValue : newValue;
250
202
  }
203
+ };
204
+ };
205
+ const getAccessorControllerBoundProperties = (controller) => controller.Y;
206
+ const reCreateAccessor = (instance, component) => {
207
+ const accessorController = component.manager.useRefSync(instance);
208
+ accessorController?.hostDestroy();
209
+ accessorController?.Z();
210
+ accessorController?.hostConnected();
211
+ if (process.env.NODE_ENV !== "production" && accessorController === void 0) {
212
+ console.error("Unable to resolve the useAccessor controller from the provided value");
251
213
  }
252
- return emitter;
253
- }
214
+ };
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
+ };
235
+ };
254
236
  export {
255
237
  AccessorController,
256
- accessorSupport,
238
+ createLegacyStore,
239
+ createStore,
240
+ getAccessorControllerBoundProperties,
257
241
  makeAccessorController,
242
+ makeBinderProxy,
243
+ reCreateAccessor,
258
244
  reEmitEvent
259
245
  };
@@ -7,4 +7,4 @@ import { EventEmitter } from '../../createEvent';
7
7
  * arcgisGo = reEmitEvent<__esri.HomeViewModelGoEvent>(() => this.viewModel, "go");
8
8
  * ```
9
9
  */
10
- export declare function reEmitEvent<T>(getEventedAccessor: () => __esri.Evented, eventName: string): EventEmitter<T>;
10
+ export declare const reEmitEvent: <T>(getEventedAccessor: () => __esri.Evented, eventName: string) => EventEmitter<T>;
@@ -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
+ };
@@ -1,16 +1,18 @@
1
- import { Controller, GenericController } from '../Controller';
1
+ import { GenericController } from '../Controller';
2
2
  import { LitElement } from '../../LitElement';
3
- type Requires<Props, Accessor extends __esri.Accessor> = LitElement & Pick<Accessor, keyof Accessor & keyof Props> & {
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;
5
5
  destroy: () => Promise<void>;
6
6
  };
7
+ type AlwaysOmit = "addHandles" | "declaredClass" | "destroyed" | "hasHandles" | "initialized" | "removeHandles" | "set" | "watch";
7
8
  /**
8
9
  * Given an Accessor class, create a controller that will do two-way binding of
9
- * props between the component and the Accessor
10
+ * props between the component and the Accessor.
10
11
  *
11
- * See 4.accessor.tsx for documentation & examples
12
+ * See https://qawebgis.esri.com/components/lumina/controllers/useAccessor for
13
+ * documentation & examples.
12
14
  */
13
- export declare const makeAccessorController: <Props, Accessor extends __esri.Accessor, OmitProps extends string = never>(loadAccessor: ((props: Props) => Accessor | Promise<Accessor>) | (new (props: Props) => Accessor), _options?: {
15
+ export declare const makeAccessorController: <Props, Accessor extends __esri.Accessor, OmitProps extends string = never>(createInstance: ((props?: Props) => Accessor) | (new (props?: Props) => Accessor), _options?: {
14
16
  /**
15
17
  * By default, to ensure that you didn't accidentally forget to bind any
16
18
  * of the Accessor's properties on your component, every property that
@@ -35,40 +37,40 @@ export declare const makeAccessorController: <Props, Accessor extends __esri.Acc
35
37
  * `makeAccessorController(..., {} as { omitProps: ["propName"] })`
36
38
  */
37
39
  omitProps: OmitProps[];
38
- }) => (component: Requires<Omit<Props, OmitProps>, Accessor>, options?: {
39
- editConstructorProperties(props: Props): Promise<Props> | Props;
40
- }) => Accessor;
40
+ }) => (component: Requires<Props, Accessor, OmitProps>) => Accessor;
41
41
  export declare class AccessorController<Props, Accessor extends __esri.Accessor, ExtraRequires = Record<never, never>> extends GenericController<Accessor, ExtraRequires & Requires<Props, Accessor>> {
42
- private _loadAccessor;
43
- private _options?;
44
- protected _instance: Accessor;
45
- protected _watchedProperties: Map<string, string & keyof Props>;
46
- private _instancePropName;
47
- private _isBinding;
42
+ #private;
43
+ protected instance: Accessor;
48
44
  /**
49
- * (development only) Allow these props to mismatch the name of the Accessor's property
50
- * to avoid collisions
45
+ * Use getAccessorControllerBoundProperties() helper to get access to this map
46
+ * @private
47
+ */
48
+ _boundAccessorProperties: Map<string & keyof Accessor, string>;
49
+ /** @private */
50
+ _currentlyBindingPropertyName?: string;
51
+ /**
52
+ * (development only) Allow these props to mismatch the name of the Accessor's
53
+ * property to avoid collisions
51
54
  *
52
55
  * @private
53
56
  */
54
- static allowedPropNameMismatches?: Set<string>;
55
- constructor(component: ExtraRequires & Requires<Props, Accessor>, _loadAccessor: ((props: Props) => Accessor | Promise<Accessor>) | (new (props: Props) => Accessor), _options?: {
56
- editConstructorProperties?(props: Props): Promise<Props> | Props;
57
- } | undefined);
57
+ static devOnly$allowedPropNameMismatches?: ReadonlySet<string>;
58
+ get exports(): Accessor;
59
+ set exports(value: Accessor);
60
+ constructor(component: ExtraRequires & Requires<Props, Accessor>, createInstance: ((props?: Props) => Accessor) | (new (props?: Props) => Accessor));
61
+ /** @private */
62
+ _createAccessorInstance(): void;
58
63
  hostConnected(): void;
59
- hostLoad(): Promise<void>;
60
- private _gatherParameters;
61
- private _createInstance;
62
- private _isAccessorConstructor;
63
64
  hostDestroy(): void;
64
- reCreate(): Promise<void>;
65
65
  }
66
- export declare const accessorSupport: {
67
- makeGetterProxy: (component: LitElement, watchedProperties: Map<string, string>, isBinding?: {
68
- value: boolean;
69
- }, allowedPropNameMismatches?: Set<string>) => unknown;
70
- watchComponentUpdates<T>(controller: Controller<T>, instance: __esri.Accessor, watchedProperties: Map<string, string>): void;
71
- watchAccessorUpdates<T>(controller: Controller<T>, instance: __esri.Accessor, watchedProperties: Map<string, string>): void;
72
- reCreate(instance: __esri.Accessor, component: LitElement): Promise<void>;
66
+ type MinimalAccessorController = Pick<AccessorController<never, __esri.Accessor>, "_currentlyBindingPropertyName" | "exports"> & {
67
+ component: LitElement;
73
68
  };
69
+ export declare const makeBinderProxy: (component: LitElement, accessorControllerRef: WeakRef<MinimalAccessorController & {
70
+ constructor: MinimalAccessorController["constructor"] & {
71
+ devOnly$allowedPropNameMismatches?: ReadonlySet<string>;
72
+ };
73
+ }>, accessorControllerIndex: number, instance: __esri.Accessor, boundProperties: Map<string, string>) => unknown;
74
+ export declare const getAccessorControllerBoundProperties: <Accessor extends __esri.Accessor>(controller: AccessorController<unknown, Accessor>) => Map<string & keyof Accessor, string>;
75
+ export declare const reCreateAccessor: (instance: __esri.Accessor, component: LitElement) => void;
74
76
  export {};
@@ -2,7 +2,7 @@ import { EventEmitter as _EventEmitter } from '../createEvent';
2
2
  export type { GenericControllerType } from './Controller';
3
3
  export { Controller, GenericController } from './Controller';
4
4
  export type { ControllerManager } from './ControllerManager';
5
- export { retrieveComponent, bypassGetter, bypassSetter, bypassReadOnly } from './ControllerInternals';
5
+ export { retrieveComponent, bypassSetter, bypassReadOnly } from './ControllerInternals';
6
6
  export { trackPropertyKey, keyTrackResolve } from './trackPropertyKey';
7
7
  export { trackPropKey } from './trackPropKey';
8
8
  export { trackKey } from './trackKey';
@@ -17,7 +17,7 @@ export { useDirection } from './useDirection';
17
17
  export type { UseT9n, T9nMeta } from './useT9n';
18
18
  export { makeT9nController } from './useT9n';
19
19
  export { usePropertyChange } from './usePropertyChange';
20
- export { isController } from './utils';
20
+ export { isController, getControllersCount } from './utils';
21
21
  /**
22
22
  * @deprecated import from "@arcgis/lumina" instead
23
23
  */