@arcgis/lumina 4.33.0-next.94 → 4.33.0-next.95

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 (43) hide show
  1. package/dist/ControllerManager-B2comd8J.js +310 -0
  2. package/dist/LitElement.d.ts +3 -3
  3. package/dist/context.d.ts +1 -1
  4. package/dist/controllers/ComponentInternals.d.ts +92 -0
  5. package/dist/controllers/Controller.d.ts +152 -0
  6. package/dist/controllers/ControllerInternals.d.ts +52 -0
  7. package/dist/controllers/ControllerManager.d.ts +63 -0
  8. package/dist/controllers/accessor/index.d.ts +2 -0
  9. package/dist/controllers/accessor/index.js +1045 -0
  10. package/dist/controllers/accessor/reEmitEvent.d.ts +14 -0
  11. package/dist/controllers/accessor/useAccessor.d.ts +75 -0
  12. package/dist/controllers/framework.d.ts +45 -0
  13. package/dist/controllers/functional.d.ts +19 -0
  14. package/dist/controllers/getSet.d.ts +116 -0
  15. package/dist/controllers/index.d.ts +23 -0
  16. package/dist/controllers/index.js +283 -0
  17. package/dist/controllers/load.d.ts +6 -0
  18. package/dist/controllers/proxyExports.d.ts +27 -0
  19. package/dist/controllers/readonly.d.ts +29 -0
  20. package/dist/controllers/tests/autoDestroyMock.d.ts +5 -0
  21. package/dist/controllers/tests/utils.d.ts +1 -0
  22. package/dist/controllers/toFunction.d.ts +8 -0
  23. package/dist/controllers/trackKey.d.ts +8 -0
  24. package/dist/controllers/trackPropKey.d.ts +21 -0
  25. package/dist/controllers/trackPropertyKey.d.ts +28 -0
  26. package/dist/controllers/types.d.ts +182 -0
  27. package/dist/controllers/useDirection.d.ts +11 -0
  28. package/dist/controllers/useMedia.d.ts +8 -0
  29. package/dist/controllers/usePropertyChange.d.ts +11 -0
  30. package/dist/controllers/useT9n.d.ts +48 -0
  31. package/dist/controllers/useWatch.d.ts +27 -0
  32. package/dist/controllers/useWatchAttributes.d.ts +7 -0
  33. package/dist/controllers/utils.d.ts +15 -0
  34. package/dist/createEvent.d.ts +1 -1
  35. package/dist/decorators.d.ts +1 -1
  36. package/dist/index.d.ts +2 -2
  37. package/dist/index.js +5 -42
  38. package/dist/lazyLoad.d.ts +2 -2
  39. package/dist/makeRuntime.d.ts +109 -0
  40. package/dist/proxyExports-Dl5CHmHQ.js +150 -0
  41. package/dist/runtime.d.ts +4 -107
  42. package/dist/useWatch-CFtSpNnN.js +925 -0
  43. package/package.json +4 -3
@@ -0,0 +1,14 @@
1
+ import { EventEmitter } from '../types';
2
+ /**
3
+ * Re-emit an event from the accessor instance on the component
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * arcgisGo = reEmitEvent<__esri.HomeViewModelGoEvent>(() => this.viewModel, "go");
8
+ * ```
9
+ *
10
+ * @remarks
11
+ * `reEmitEvent()` only works in Lumina. Consult documentation for equivalent
12
+ * Stencil pattern.
13
+ */
14
+ export declare function reEmitEvent<T>(getEventedAccessor: () => __esri.Evented, eventName: string): EventEmitter<T>;
@@ -0,0 +1,75 @@
1
+ import { Controller, GenericController } from '../Controller';
2
+ import { BaseComponent } from '../types';
3
+ type Requires<Props, Accessor extends __esri.Accessor> = BaseComponent & Pick<Accessor, keyof Accessor & keyof Props> & {
4
+ autoDestroyDisabled: boolean;
5
+ destroy: () => Promise<void>;
6
+ };
7
+ /**
8
+ * Given an Accessor class, create a controller that will do two-way binding of
9
+ * props between the component and the Accessor
10
+ *
11
+ * See 4.accessor.tsx for documentation & examples
12
+ */
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?: {
14
+ /**
15
+ * By default, to ensure that you didn't accidentally forget to bind any
16
+ * of the Accessor's properties on your component, every property that
17
+ * is accepted by the Accessor's constructor will be required to be bound
18
+ * on your component. If you do not wish to bind certain properties
19
+ * (or you wish to bind them but with a different type), you can omit
20
+ * them using this option.
21
+ *
22
+ * You can also bind the property to \@State rather than \@Prop if you
23
+ * wish to use it internally only:
24
+ * @example
25
+ * ```tsx
26
+ * \@State() timeZone = this.viewModel.timeZone;
27
+ * ```
28
+ *
29
+ * @remarks
30
+ * This option affects the TypeScript error checking only - it has
31
+ * no runtime impact. Thus, if you wish to save a few bytes in the
32
+ * bundle, rather than simply setting this property like
33
+ * `makeAccessorController(..., { omitProps: ["propName"] })`, you can
34
+ * set it like this:
35
+ * `makeAccessorController(..., {} as { omitProps: ["propName"] })`
36
+ */
37
+ omitProps: OmitProps[];
38
+ }) => (component: Requires<Omit<Props, OmitProps>, Accessor>, options?: {
39
+ editConstructorProperties(props: Props): Promise<Props> | Props;
40
+ }) => Accessor;
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;
48
+ /**
49
+ * (development only) Allow these props to mismatch the name of the Accessor's property
50
+ * to avoid collisions
51
+ *
52
+ * @internal
53
+ */
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);
58
+ hostConnected(): void;
59
+ hostLoad(): Promise<void>;
60
+ private _gatherParameters;
61
+ private _createInstance;
62
+ private _isAccessorConstructor;
63
+ hostDestroy(): void;
64
+ reCreate(): Promise<void>;
65
+ }
66
+ export declare const accessorSupport: {
67
+ makeGetterProxy: (component: BaseComponent, 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
+ reEmitAccessorEvents<T>(controller: Controller<T>, instance: __esri.Accessor, prefix: string): void;
73
+ reCreate(instance: __esri.Accessor, component: BaseComponent): Promise<void>;
74
+ };
75
+ export {};
@@ -0,0 +1,45 @@
1
+ import { BaseComponent } from './types';
2
+ /**
3
+ * Do not consume this enum directly. Instead, consume one of the wrapper
4
+ * functions defined in this file.
5
+ */
6
+ export declare enum PropTypes {
7
+ String = 1,
8
+ Number = 2,
9
+ Boolean = 4,
10
+ Any = 8,
11
+ Unknown = 16,
12
+ State = 32,
13
+ Method = 64,
14
+ Event = 128,
15
+ Element = 256,
16
+ ReflectAttr = 512,
17
+ Mutable = 1024,
18
+ Prop = 31,
19
+ HasAttribute = 15,
20
+ PropLike = 63,
21
+ ReadOnly = 2048
22
+ }
23
+ /**
24
+ * Retrieve list of members on a Stencil/Lit component and their types
25
+ *
26
+ * Warning:
27
+ * - this may break on Stencil updates
28
+ * - component meta is not component instance specific, thus any modifications
29
+ * would affect all instances of that component
30
+ */
31
+ export declare function retrieveComponentMembers(component: BaseComponent, isLit: boolean): void;
32
+ /**
33
+ * This function is only expected to be called in Stencil, not Lit
34
+ *
35
+ * Based on https://github.com/ionic-team/stencil/blob/9c82ffb782f69bfbca28a8aced35c515e711f5fa/src/runtime/parse-property-value.ts#L31-L46
36
+ */
37
+ export declare function parsePropertyValue(value: unknown, type?: PropTypes): unknown;
38
+ /**
39
+ * Get a number representing different flags for a given prop. To get a value
40
+ * of individual flag, use the PropTypes enum.
41
+ *
42
+ * @example
43
+ * const isBoolean = (getMemberType(component, "myProp") & PropTypes.Boolean) !== 0;
44
+ */
45
+ export declare const getMemberType: (component: BaseComponent, name: string) => number | undefined;
@@ -0,0 +1,19 @@
1
+ import { GenericControllerType, Controller } from './Controller';
2
+ import { BaseComponent, ControllerHost } from './types';
3
+ /**
4
+ * Controller is a function that takes a component instance and then can
5
+ * export some values to the component, or hook into component's lifecycle
6
+ *
7
+ * See controllers documentation for many example controllers and their usages
8
+ */
9
+ export declare const makeController: <Exports>(constructor: (component: BaseComponent & ControllerHost, controller: Controller<Exports>) => Exports | Promise<Exports>) => Exports;
10
+ /**
11
+ * If your controller requires some specific properties to be present on the
12
+ * component, besides what's included in the BaseComponent, use
13
+ * makeGenericController
14
+ *
15
+ * When using a controller created using makeGenericController(), consumer must
16
+ * pass in "this" explicitly for proper type-checking. If controller was
17
+ * created using makeController(), that is not necessary
18
+ */
19
+ export declare const makeGenericController: <Exports, Component = BaseComponent>(constructor: (component: BaseComponent & Component & ControllerHost, controller: GenericControllerType<Exports, Component>) => Exports | Promise<Exports>) => (component: BaseComponent & Component) => Exports;
@@ -0,0 +1,116 @@
1
+ import { BaseComponent } from './types';
2
+ /**
3
+ * Listen for any component's @State()/@Prop() change, and mutate it's
4
+ * value before it is set.
5
+ * This is necessary because Stencil's Compiler does not support get/set for
6
+ * @State()/@Prop().
7
+ * For private component properties, you should use regular get/set syntax.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * @Prop() exampleProp = getSet(defaultValue,{get,set})
12
+ * @Prop() someProp = getSet(
13
+ * undefined as string | undefined,
14
+ * {
15
+ * get: (value)=>value.trim(),
16
+ * set: (newValue,oldValue) => newValue.trim() ?? oldValue
17
+ * }
18
+ * )
19
+ * ```
20
+ *
21
+ * @remarks
22
+ * Unlike a native get/set, the get function receives the current attribute
23
+ * value, and can modify it before returning it (or can disregard the current
24
+ * value and get it from elsewhere instead).
25
+ * Similarly, setter is called with the new and old value, and is expected to
26
+ * return the final new value (or return the old value to undo the change)
27
+ *
28
+ * @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
29
+ */
30
+ export declare function getSet<T>(
31
+ /**
32
+ * Default value is used only if user did not set a value in the DOM before
33
+ * component was loaded
34
+ */
35
+ defaultValue: T, getSet: {
36
+ get?(newValue: T, propertyName: string): T;
37
+ set(newValue: T, oldValue: T, propertyName: string): T;
38
+ } | {
39
+ get(newValue: T, propertyName: string): T;
40
+ set?(newValue: T, oldValue: T, propertyName: string): T;
41
+ } | {
42
+ get(newValue: T, propertyName: string): T;
43
+ set: "ignore";
44
+ }): T;
45
+ /**
46
+ * Like getSet(), but can be called on any component's
47
+ * state/prop from anywhere, rather than just from the default value
48
+ *
49
+ * @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
50
+ */
51
+ export declare const dynamicGetSet: <Component extends BaseComponent, Property extends keyof (BaseComponent & Component)>(component: Component, property: Property, getSet: {
52
+ get?(newValue: (BaseComponent & Component)[Property], propertyName: Property): (BaseComponent & Component)[Property];
53
+ set(newValue: (BaseComponent & Component)[Property], oldValue: (BaseComponent & Component)[Property], propertyName: Property): (BaseComponent & Component)[Property];
54
+ } | {
55
+ get(newValue: (BaseComponent & Component)[Property], propertyName: Property): (BaseComponent & Component)[Property];
56
+ set?(newValue: (BaseComponent & Component)[Property], oldValue: (BaseComponent & Component)[Property], propertyName: Property): (BaseComponent & Component)[Property];
57
+ }) => void;
58
+ /**
59
+ * If you need to set a prop/state without triggering the custom setter you
60
+ * defined with getSet()/dynamicGetSet()/readonly(), set the value inside
61
+ * of this function
62
+ *
63
+ * @example
64
+ * ```tsx
65
+ * @Prop() readOnly = readOnly(true);
66
+ *
67
+ * someAction(): void {
68
+ * bypassSetter(()=>{
69
+ * this.readOnly = false;
70
+ * });
71
+ * }
72
+ * ```
73
+ *
74
+ * @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
75
+ */
76
+ export declare function bypassSetter<T = void>(callback: () => T): T | void;
77
+ /**
78
+ * Property reads inside of this function will bypass any custom getter you
79
+ * may have, and read the value directly from what's stored in Stencil/Lit.
80
+ *
81
+ * This also bypasses reactiveUtils integration - reading a property inside of
82
+ * bypassGetter won't make that property tracked.
83
+ *
84
+ * @example
85
+ * ```tsx
86
+ * reactiveUtils.watch(
87
+ * ()=>{
88
+ * bypassGetter(()=>{
89
+ * console.log(this.someProp);
90
+ * });
91
+ * return this.prop;
92
+ * },
93
+ * console.log
94
+ * );
95
+ * ```
96
+ *
97
+ * @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
98
+ */
99
+ export declare function bypassGetter<T = void>(callback: () => T): T | void;
100
+ /**
101
+ * Like dynamicGetSet, but less type-safe. Useful in cases when trying to set
102
+ * getters/setters in place where property names & types are not known
103
+ * statically
104
+ *
105
+ * @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
106
+ */
107
+ export declare function genericGetSet<Type>(component: BaseComponent, property: string, getSet: {
108
+ get?(newValue: Type, propertyName: string): Type;
109
+ set(newValue: Type, oldValue: Type, propertyName: string): Type;
110
+ } | {
111
+ get(newValue: Type, propertyName: string): Type;
112
+ set?(newValue: Type, oldValue: Type, propertyName: string): Type;
113
+ } | {
114
+ get(newValue: Type, propertyName: string): Type;
115
+ set: "ignore";
116
+ }): void;
@@ -0,0 +1,23 @@
1
+ export type { GenericControllerType } from './Controller';
2
+ export { Controller, GenericController } from './Controller';
3
+ export type { ControllerManager } from './ControllerManager';
4
+ export { retrieveComponent } from './ControllerInternals';
5
+ export { useControllerManager } from './ControllerManager';
6
+ export { trackPropertyKey, keyTrackResolve } from './trackPropertyKey';
7
+ export { trackPropKey } from './trackPropKey';
8
+ export { trackKey } from './trackKey';
9
+ export { makeController, makeGenericController } from './functional';
10
+ export { readonly, bypassReadOnly } from './readonly';
11
+ export { getSet, dynamicGetSet, bypassGetter, bypassSetter } from './getSet';
12
+ export { watch } from './useWatch';
13
+ export { useWatchAttributes } from './useWatchAttributes';
14
+ export { load } from './load';
15
+ export { proxyExports } from './proxyExports';
16
+ export { toFunction } from './toFunction';
17
+ export * from './types';
18
+ export { useMedia } from './useMedia';
19
+ export { useDirection } from './useDirection';
20
+ export type { UseT9n, T9nMeta } from './useT9n';
21
+ export { makeT9nController } from './useT9n';
22
+ export { usePropertyChange } from './usePropertyChange';
23
+ export { isController } from './utils';
@@ -0,0 +1,283 @@
1
+ import { C as Controller, s as setAmbientComponent, i as isPromise, a as setParentController, b as retrieveParentControllers, t as trackKey, w as watch, r as retrieveComponent, d as createEventFactory, P as PropTypes } from "../useWatch-CFtSpNnN.js";
2
+ import { G, h, g, k, f, e } from "../useWatch-CFtSpNnN.js";
3
+ import { u } from "../ControllerManager-B2comd8J.js";
4
+ import { p as proxyExports } from "../proxyExports-Dl5CHmHQ.js";
5
+ import { a, b, c, d, g as g2, r } from "../proxyExports-Dl5CHmHQ.js";
6
+ import { observeAncestorsMutation, isEsriInternalEnv, getElementAttribute, getElementLocales, startLocaleObserver } from "@arcgis/components-utils";
7
+ const makeController = (constructor) => proxy(void 0, constructor);
8
+ const makeGenericController = (constructor) => (component) => proxy(
9
+ component,
10
+ /**
11
+ * GenericController is identical to Controller, in all except for typing.
12
+ * So dying a type-cast here so as not to needlessly add one more object
13
+ * to the prototype chain
14
+ */
15
+ constructor
16
+ );
17
+ class FunctionalController extends Controller {
18
+ constructor(component, constructor) {
19
+ super(component);
20
+ const originalExports = this.exports;
21
+ try {
22
+ setAmbientComponent(this.component);
23
+ const value = constructor(this.component, this);
24
+ const constructorChangedExports = this.exports !== originalExports;
25
+ if (isPromise(value)) {
26
+ if (!constructorChangedExports) {
27
+ this.setProvisionalExports(value);
28
+ }
29
+ const resolved = value.then((result) => {
30
+ this.exports = result;
31
+ super.catchUpLifecycle();
32
+ }).catch((error) => {
33
+ this._ready.reject(error);
34
+ console.error(error);
35
+ });
36
+ this.onLoad(async () => await resolved);
37
+ } else {
38
+ if (!constructorChangedExports || value !== void 0) {
39
+ this.exports = value;
40
+ }
41
+ queueMicrotask(() => super.catchUpLifecycle());
42
+ }
43
+ } catch (error) {
44
+ this._ready.reject(error);
45
+ console.error(error);
46
+ }
47
+ }
48
+ /** Noop - will be called in the constructor instead */
49
+ catchUpLifecycle() {
50
+ return;
51
+ }
52
+ }
53
+ const proxy = proxyExports(FunctionalController);
54
+ const useWatchAttributes = (attributes, callback) => new AttributeWatchController(attributes, callback);
55
+ class AttributeWatchController extends Controller {
56
+ constructor(_attributes, _callback) {
57
+ super();
58
+ this._attributes = _attributes;
59
+ this._callback = _callback;
60
+ this._observer = new MutationObserver((mutations) => {
61
+ mutations.forEach((mutation) => {
62
+ if (_attributes.includes(mutation.attributeName)) {
63
+ _callback.call(
64
+ this.component,
65
+ this.component.el.getAttribute(mutation.attributeName),
66
+ mutation.oldValue,
67
+ mutation.attributeName
68
+ );
69
+ }
70
+ });
71
+ });
72
+ }
73
+ hostConnected() {
74
+ this._attributes.forEach((attribute) => {
75
+ if (this.component.el.hasAttribute(attribute)) {
76
+ this._callback.call(this.component, null, this.component.el.getAttribute(attribute), attribute);
77
+ }
78
+ });
79
+ this._observer.observe(this.component.el, {
80
+ attributes: true,
81
+ attributeOldValue: true,
82
+ attributeFilter: this._attributes
83
+ });
84
+ }
85
+ hostDisconnected() {
86
+ this._observer.disconnect();
87
+ }
88
+ }
89
+ const load = makeController;
90
+ const toFunction = (Class) => (...args) => {
91
+ const ambientControllers = retrieveParentControllers();
92
+ const instance = new Class(...args);
93
+ setParentController(ambientControllers.at(-1));
94
+ return instance;
95
+ };
96
+ const useMedia = (query) => makeController((_component, controller) => {
97
+ const media = globalThis.matchMedia(query);
98
+ function changed() {
99
+ controller.exports = media.matches;
100
+ }
101
+ changed();
102
+ controller.onLifecycle(() => {
103
+ media.addEventListener("change", changed);
104
+ return () => media.removeEventListener("change", changed);
105
+ });
106
+ return void 0;
107
+ });
108
+ const defaultDirection = "ltr";
109
+ const useDirection = () => makeController((component, controller) => {
110
+ controller.exports = defaultDirection;
111
+ controller.onLifecycle(() => {
112
+ function callback() {
113
+ const dir = getElementAttribute(component.el, "dir", defaultDirection);
114
+ controller.exports = dir === "rtl" ? "rtl" : "ltr";
115
+ }
116
+ callback();
117
+ return observeAncestorsMutation(component.el, ["dir"], callback);
118
+ });
119
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
120
+ trackKey(
121
+ component,
122
+ (resolved) => {
123
+ if (resolved?.key === "dir") {
124
+ throw new Error(
125
+ `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\`.`
126
+ );
127
+ }
128
+ },
129
+ controller.exports
130
+ );
131
+ }
132
+ return void 0;
133
+ });
134
+ const makeT9nController = (getAssetPath) => (options = {}) => (
135
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
136
+ makeController((component, controller) => {
137
+ const locale = getElementLocales(component.el);
138
+ const pending = {
139
+ _lang: locale.lang,
140
+ _t9nLocale: locale.t9nLocale,
141
+ _loading: true
142
+ };
143
+ const componentWithOverrides = component;
144
+ controller.onLifecycle(
145
+ () => startLocaleObserver(
146
+ component.el,
147
+ () => getAssetPath("./assets"),
148
+ ({ t9nLocale, t9nStrings, lang }) => {
149
+ const withoutOverrides = {
150
+ ...t9nStrings,
151
+ _lang: lang,
152
+ _t9nLocale: t9nLocale,
153
+ _loading: false
154
+ };
155
+ controller.exports = withoutOverrides;
156
+ const label = t9nStrings.componentLabel;
157
+ if (typeof label === "string" && "label" in component && component.label == null) {
158
+ component.label ??= label;
159
+ }
160
+ applyOverrides(componentWithOverrides.messageOverrides);
161
+ },
162
+ options.name
163
+ )
164
+ );
165
+ function applyOverrides(messageOverrides) {
166
+ const currentValue = controller.exports;
167
+ const rawMessages = currentValue._original ?? currentValue;
168
+ const updated = deepMerge(rawMessages, messageOverrides);
169
+ if (messageOverrides) {
170
+ updated._original = rawMessages;
171
+ }
172
+ controller.exports = updated;
173
+ }
174
+ if ("messageOverrides" in componentWithOverrides) {
175
+ controller.onLifecycle(() => watch(componentWithOverrides, "messageOverrides", applyOverrides));
176
+ }
177
+ if (options.blocking) {
178
+ controller.setProvisionalExports(pending, false);
179
+ return controller.ready;
180
+ } else {
181
+ return pending;
182
+ }
183
+ })
184
+ );
185
+ function deepMerge(original, overwrites) {
186
+ if (!overwrites) {
187
+ return original;
188
+ }
189
+ const merged = { ...original };
190
+ Object.entries(overwrites).forEach(([key, value]) => {
191
+ if (typeof value === "object") {
192
+ merged[key] = deepMerge(original[key], value);
193
+ } else {
194
+ merged[key] = value ?? original[key];
195
+ }
196
+ });
197
+ return merged;
198
+ }
199
+ const usePropertyChange = (_component) => propertyChangeController;
200
+ const eventName = "arcgisPropertyChange";
201
+ function propertyChangeController(...toWatch) {
202
+ const component = retrieveComponent();
203
+ const eventedComponent = component;
204
+ let eventEmitter = eventedComponent[eventName];
205
+ if (component.manager.isLit) {
206
+ eventEmitter = createEventFactory(eventName, void 0, component);
207
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
208
+ if (typeof eventEmitter !== "object" || eventEmitter === null || !("emit" in eventEmitter) || typeof eventEmitter.emit !== "function") {
209
+ throw new Error(`Expected to find $createEvent static property on Lumina's LitElement"`);
210
+ }
211
+ }
212
+ }
213
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
214
+ if (typeof eventEmitter !== "object" || eventEmitter === null || !("emit" in eventEmitter) || typeof eventEmitter.emit !== "function") {
215
+ throw new Error(
216
+ `For consistency, usePropertyChange must be assigned to an arcgisPropertyChange property that has an @Event() decorator`
217
+ );
218
+ }
219
+ const allProps = new Set(
220
+ Object.entries(component.manager.internals.members).filter(([_name, [propType]]) => (propType & PropTypes.Prop) !== 0).map(([name]) => name)
221
+ );
222
+ toWatch.forEach((prop) => {
223
+ if (!allProps.has(prop)) {
224
+ throw new Error(
225
+ prop in component ? `For usePropertyChange to emit event on "${prop}" property change, you should add @${component.manager.isLit ? "property" : "Prop"}() to ${prop} in ${component.el.localName}` : `usePropertyChange can't emit event on "${prop}" property change as such property does not exist in ${component.el.localName}`
226
+ );
227
+ }
228
+ });
229
+ }
230
+ component.manager.onLoad(
231
+ () => component.manager.onLifecycle(
232
+ () => toWatch.map(
233
+ (name) => (
234
+ // Casting to 'el' to simplify dynamic prop name typing
235
+ watch(component, name, () => eventEmitter.emit({ name }))
236
+ )
237
+ )
238
+ )
239
+ );
240
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && component.manager.isLit) {
241
+ trackKey(
242
+ component,
243
+ (resolution) => {
244
+ if (resolution === void 0 || resolution.isReactive || resolution.key !== eventName) {
245
+ throw new Error(
246
+ `For consistency, usePropertyChange must be assigned to an arcgisPropertyChange property and that property should not have @property() or @state() decorators: arcgisPropertyChange = usePropertyChange<this>()("prop1", "prop2");`
247
+ );
248
+ }
249
+ },
250
+ eventEmitter
251
+ );
252
+ }
253
+ return eventEmitter;
254
+ }
255
+ export {
256
+ Controller,
257
+ G as GenericController,
258
+ a as bypassGetter,
259
+ b as bypassReadOnly,
260
+ c as bypassSetter,
261
+ h as controllerSymbol,
262
+ d as dynamicGetSet,
263
+ g2 as getSet,
264
+ g as isController,
265
+ k as keyTrackResolve,
266
+ load,
267
+ makeController,
268
+ makeGenericController,
269
+ makeT9nController,
270
+ proxyExports,
271
+ r as readonly,
272
+ retrieveComponent,
273
+ toFunction,
274
+ trackKey,
275
+ f as trackPropKey,
276
+ e as trackPropertyKey,
277
+ u as useControllerManager,
278
+ useDirection,
279
+ useMedia,
280
+ usePropertyChange,
281
+ useWatchAttributes,
282
+ watch
283
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Load a value from a promise and provide it to the component
3
+ *
4
+ * Documentation: https://qawebgis.esri.com/components/lumina/controllers/load
5
+ */
6
+ export declare const load: <T>(loader: () => Promise<T>) => T;
@@ -0,0 +1,27 @@
1
+ import { Controller } from './Controller';
2
+ import { ControllerLifecycleMethods } from './types';
3
+ /**
4
+ * If you wish to directly expose the "exports" property of your controller,
5
+ * rather than the entire controller class, wrap your class definition in
6
+ * "proxyExports".
7
+ *
8
+ * This is especially convenient when your exports is not an object, or it is a
9
+ * dynamically created object, and so you don't want your Controller's methods
10
+ * interfering with the keys on the exported value.
11
+ *
12
+ * "proxyExports" is the default behavior for all controllers declared using
13
+ * the makeController()/makeGenericController() function
14
+ *
15
+ * @remarks
16
+ * If using readonly(), and controller updates its exports, the readonly prop
17
+ * will still get updated
18
+ *
19
+ * @remarks
20
+ * (Advanced) If you wish to use proxyExports() in a class that does not
21
+ * extend Controller class and does not have a useControllerManager(), then your
22
+ * class must subclass a class with the following constructor:
23
+ * `constructor() { setAmbientController(this); }`. This
24
+ * is necessary for proxyExports() to receive a reference to your object
25
+ * implicitly, and before any of your default values are assigned.
26
+ */
27
+ export declare const proxyExports: <Exports, const Parameters extends unknown[]>(Class: new (...args: Parameters) => ControllerLifecycleMethods & Pick<Controller<Exports>, "component" | "exports" | "watchExports">) => ((...args: Parameters) => Exports);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Make a @Prop() or @State() readonly (prevent overwriting default value).
3
+ *
4
+ * For internal properties, prefer TypeScript's "readonly" modifier instead.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * // Defining readonly prop
9
+ * @Prop({ reflect: true }) prop = readonly('a');
10
+ * ```
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // Overwriting readonly prop internally
15
+ * bypassReadOnly(()=>{
16
+ * this.prop = 'b';
17
+ * });
18
+ * ```
19
+ *
20
+ * @deprecated see https://qawebgis.esri.com/components/lumina/properties#read-only-properties
21
+ */
22
+ export declare function readonly<T>(value: T): T;
23
+ /**
24
+ * Like bypassSetter(), but only bypasses readonly(), rather that
25
+ * all setters set using getSet()
26
+ *
27
+ * @deprecated see https://qawebgis.esri.com/components/lumina/properties#read-only-properties
28
+ */
29
+ export declare function bypassReadOnly<T = void>(callback: () => T): T | void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Mocking utility for changing auto-destroy timeout in ControllerManager to 0ms.
3
+ * Also, returns a convenient promise that resolves after the timeout.
4
+ */
5
+ export declare function autoDestroyMock(timeout?: number): () => Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function captureConsoleErrors(): unknown[][];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A tiny helper for using a class-based controller as if it's a function.
3
+ * Main advantage of this is that it's a bit shorter to type.
4
+ *
5
+ * This utility can be used for converting non-controller classes to functions
6
+ * too
7
+ */
8
+ export declare const toFunction: <T, const P extends unknown[]>(Class: new (...args: P) => T) => ((...args: P) => T);
@@ -0,0 +1,8 @@
1
+ import { TrackKeyResolution } from './ComponentInternals';
2
+ import { BaseComponent, BaseController } from './types';
3
+ /**
4
+ * A combination of trackPropertyKey() and trackPropKey(). For usage when
5
+ * you want to track a property, but don't know if it will be defined with the
6
+ * \@Prop() decorator or not
7
+ */
8
+ export declare function trackKey<T>(hostsCandidates: ((BaseComponent | BaseController)[] | BaseComponent | BaseController) | undefined, onResolved: (resolution: TrackKeyResolution | undefined) => void, defaultValue: T): T;