@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.
- package/dist/ControllerManager-B2comd8J.js +310 -0
- package/dist/LitElement.d.ts +3 -3
- package/dist/context.d.ts +1 -1
- package/dist/controllers/ComponentInternals.d.ts +92 -0
- package/dist/controllers/Controller.d.ts +152 -0
- package/dist/controllers/ControllerInternals.d.ts +52 -0
- package/dist/controllers/ControllerManager.d.ts +63 -0
- package/dist/controllers/accessor/index.d.ts +2 -0
- package/dist/controllers/accessor/index.js +1045 -0
- package/dist/controllers/accessor/reEmitEvent.d.ts +14 -0
- package/dist/controllers/accessor/useAccessor.d.ts +75 -0
- package/dist/controllers/framework.d.ts +45 -0
- package/dist/controllers/functional.d.ts +19 -0
- package/dist/controllers/getSet.d.ts +116 -0
- package/dist/controllers/index.d.ts +23 -0
- package/dist/controllers/index.js +283 -0
- package/dist/controllers/load.d.ts +6 -0
- package/dist/controllers/proxyExports.d.ts +27 -0
- package/dist/controllers/readonly.d.ts +29 -0
- package/dist/controllers/tests/autoDestroyMock.d.ts +5 -0
- package/dist/controllers/tests/utils.d.ts +1 -0
- package/dist/controllers/toFunction.d.ts +8 -0
- package/dist/controllers/trackKey.d.ts +8 -0
- package/dist/controllers/trackPropKey.d.ts +21 -0
- package/dist/controllers/trackPropertyKey.d.ts +28 -0
- package/dist/controllers/types.d.ts +182 -0
- package/dist/controllers/useDirection.d.ts +11 -0
- package/dist/controllers/useMedia.d.ts +8 -0
- package/dist/controllers/usePropertyChange.d.ts +11 -0
- package/dist/controllers/useT9n.d.ts +48 -0
- package/dist/controllers/useWatch.d.ts +27 -0
- package/dist/controllers/useWatchAttributes.d.ts +7 -0
- package/dist/controllers/utils.d.ts +15 -0
- package/dist/createEvent.d.ts +1 -1
- package/dist/decorators.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -42
- package/dist/lazyLoad.d.ts +2 -2
- package/dist/makeRuntime.d.ts +109 -0
- package/dist/proxyExports-Dl5CHmHQ.js +150 -0
- package/dist/runtime.d.ts +4 -107
- package/dist/useWatch-CFtSpNnN.js +925 -0
- package/package.json +4 -3
|
@@ -0,0 +1,925 @@
|
|
|
1
|
+
import { isEsriInternalEnv, safeCall, isNotUndefined, Deferred, safeAsyncCall } from "@arcgis/components-utils";
|
|
2
|
+
const controllerSymbol = Symbol.for("controller");
|
|
3
|
+
const name = "@arcgis/lumina";
|
|
4
|
+
const isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
|
|
5
|
+
const devOnlySetPersistentControllerData = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (controller, data) => {
|
|
6
|
+
const manager = controller.component.manager;
|
|
7
|
+
const controllers = "_controllers" in manager ? manager._controllers : void 0;
|
|
8
|
+
if (controllers === void 0) {
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
const index = Array.from(controllers).indexOf(controller);
|
|
12
|
+
if (index === -1) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const devOnlyControllerData = Symbol.for(`${name}: devOnlyControllerData`);
|
|
16
|
+
const el = controller.component.el;
|
|
17
|
+
el[devOnlyControllerData] ??= {};
|
|
18
|
+
el[devOnlyControllerData][index] = data;
|
|
19
|
+
} : void 0;
|
|
20
|
+
const devOnlyGetPersistentControllerData = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (controller) => {
|
|
21
|
+
const manager = controller.component.manager;
|
|
22
|
+
const controllers = "_controllers" in manager ? manager._controllers : void 0;
|
|
23
|
+
if (controllers === void 0) {
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
const index = Array.from(controllers).indexOf(controller);
|
|
27
|
+
const devOnlyControllerData = Symbol.for(`${name}: devOnlyControllerData`);
|
|
28
|
+
const el = controller.component.el;
|
|
29
|
+
return el[devOnlyControllerData]?.[index];
|
|
30
|
+
} : void 0;
|
|
31
|
+
function isPromise(arg) {
|
|
32
|
+
return typeof arg?.then === "function";
|
|
33
|
+
}
|
|
34
|
+
let ambientComponent;
|
|
35
|
+
function setAmbientComponent(component) {
|
|
36
|
+
if (ambientComponent === component) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
ambientComponent = component;
|
|
40
|
+
queueMicrotask(() => {
|
|
41
|
+
if (ambientComponent === component) {
|
|
42
|
+
ambientComponent = void 0;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function retrieveComponent(name2) {
|
|
47
|
+
if (process.env.NODE_ENV !== "production" && ambientComponent === void 0) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
[
|
|
50
|
+
`Unable to find out which component ${name2 || "this"} controller `,
|
|
51
|
+
"belongs to. Possible causes:\n",
|
|
52
|
+
"- You might have multiple versions of ",
|
|
53
|
+
"@arcgis/lumina package installed\n",
|
|
54
|
+
...isEsriInternalEnv() ? [
|
|
55
|
+
"- You tried to create controller outside the component. If so, ",
|
|
56
|
+
"please wrap your controller definition in an arrow function (like",
|
|
57
|
+
"`const myController = ()=>makeController(...);`) and call that",
|
|
58
|
+
"function inside the component (`my = myController();`), or ",
|
|
59
|
+
"define your controller using makeGenericController/GenericController ",
|
|
60
|
+
"instead.\n",
|
|
61
|
+
"- You tried to create a controller inside an async function. ",
|
|
62
|
+
"This is allowed without calling controller.use(). Make sure you ",
|
|
63
|
+
"use it like `await controller.use(useController())`."
|
|
64
|
+
] : []
|
|
65
|
+
].join("")
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return ambientComponent;
|
|
69
|
+
}
|
|
70
|
+
let ambientControllers = [];
|
|
71
|
+
function setParentController(controller) {
|
|
72
|
+
if (controller === void 0) {
|
|
73
|
+
ambientControllers = [];
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const index = ambientControllers.indexOf(controller);
|
|
77
|
+
ambientControllers = index === -1 ? [...ambientControllers, controller] : ambientControllers.slice(0, index + 1);
|
|
78
|
+
queueMicrotask(() => {
|
|
79
|
+
ambientControllers = [];
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function retrieveParentControllers() {
|
|
83
|
+
return ambientControllers;
|
|
84
|
+
}
|
|
85
|
+
let ambientChildController;
|
|
86
|
+
function setAmbientChildController(controller) {
|
|
87
|
+
if (ambientChildController === controller) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
ambientChildController = controller;
|
|
91
|
+
queueMicrotask(() => {
|
|
92
|
+
if (ambientChildController === controller) {
|
|
93
|
+
ambientChildController = void 0;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function retrieveAmbientChildController() {
|
|
98
|
+
const controller = ambientChildController;
|
|
99
|
+
ambientChildController = void 0;
|
|
100
|
+
return controller;
|
|
101
|
+
}
|
|
102
|
+
const use = async (value, watchExports) => {
|
|
103
|
+
const controller = useRefSync(value);
|
|
104
|
+
if (controller === void 0) {
|
|
105
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && typeof watchExports === "function") {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`Unable to resolve a controller from the provided value, so can't watch it's exports. The value you passed is not a controller and not a controller exports. If your controller exports a literal value, try making your controller export an object instead`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
await controller.ready;
|
|
113
|
+
if (typeof watchExports === "function") {
|
|
114
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && controller.watchExports === void 0) {
|
|
115
|
+
throw new Error(`The controller must implement watchExports method to support watching exports`);
|
|
116
|
+
}
|
|
117
|
+
const unsubscribe = controller.watchExports(
|
|
118
|
+
(exports) => watchExports(exports, unsubscribe)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return controller.exports;
|
|
122
|
+
};
|
|
123
|
+
const useRef = async (value) => {
|
|
124
|
+
const controller = useRefSync(value);
|
|
125
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && controller === void 0) {
|
|
126
|
+
throw new Error(
|
|
127
|
+
`Unable to resolve a controller from the provided value. The value you passed is not a controller and not a controller exports. If your controller exports a literal value, try making your controller export an object instead`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
await controller.ready;
|
|
131
|
+
return controller;
|
|
132
|
+
};
|
|
133
|
+
const useRefSync = (value) => {
|
|
134
|
+
const component = retrieveComponent();
|
|
135
|
+
const controller = component.manager.internals.resolveExports(value);
|
|
136
|
+
if (controller !== void 0) {
|
|
137
|
+
return controller;
|
|
138
|
+
}
|
|
139
|
+
if (isController(value)) {
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
const ambientChildController2 = retrieveAmbientChildController();
|
|
143
|
+
if (ambientChildController2 !== void 0) {
|
|
144
|
+
return ambientChildController2;
|
|
145
|
+
}
|
|
146
|
+
return void 0;
|
|
147
|
+
};
|
|
148
|
+
const shouldBypass = {
|
|
149
|
+
setter: false,
|
|
150
|
+
getter: false,
|
|
151
|
+
readOnly: false
|
|
152
|
+
};
|
|
153
|
+
const elementToInstance = /* @__PURE__ */ new WeakMap();
|
|
154
|
+
function trackPropertyKey(object, onResolved, defaultValue) {
|
|
155
|
+
const keys = Object.keys(object);
|
|
156
|
+
const keyCount = keys.length;
|
|
157
|
+
if (keyTrackMap === void 0) {
|
|
158
|
+
queueMicrotask(keyTrackResolve);
|
|
159
|
+
}
|
|
160
|
+
keyTrackMap ??= /* @__PURE__ */ new Map();
|
|
161
|
+
let pendingTrackers = keyTrackMap.get(object);
|
|
162
|
+
if (pendingTrackers === void 0) {
|
|
163
|
+
pendingTrackers = { callbacks: [], keyCount };
|
|
164
|
+
keyTrackMap.set(object, pendingTrackers);
|
|
165
|
+
}
|
|
166
|
+
if (pendingTrackers.keyCount !== keyCount) {
|
|
167
|
+
pendingTrackers.callbacks.forEach((resolve) => resolve(keys));
|
|
168
|
+
pendingTrackers.callbacks = [];
|
|
169
|
+
pendingTrackers.keyCount = keyCount;
|
|
170
|
+
}
|
|
171
|
+
pendingTrackers.callbacks.push((keys2) => {
|
|
172
|
+
const callback = (key2) => safeCall(onResolved, null, key2);
|
|
173
|
+
const key = keys2[keyCount];
|
|
174
|
+
if (key === void 0) {
|
|
175
|
+
callback(void 0);
|
|
176
|
+
} else if (object[key] === defaultValue) {
|
|
177
|
+
callback(key);
|
|
178
|
+
} else {
|
|
179
|
+
callback(void 0);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return defaultValue;
|
|
183
|
+
}
|
|
184
|
+
let keyTrackMap = void 0;
|
|
185
|
+
function keyTrackResolve() {
|
|
186
|
+
Array.from(keyTrackMap?.entries() ?? []).forEach(([object, { callbacks }]) => {
|
|
187
|
+
const keys = Object.keys(object);
|
|
188
|
+
callbacks.forEach((commit) => commit(keys));
|
|
189
|
+
});
|
|
190
|
+
keyTrackMap = void 0;
|
|
191
|
+
}
|
|
192
|
+
var PropTypes = /* @__PURE__ */ ((PropTypes2) => {
|
|
193
|
+
PropTypes2[PropTypes2["String"] = 1] = "String";
|
|
194
|
+
PropTypes2[PropTypes2["Number"] = 2] = "Number";
|
|
195
|
+
PropTypes2[PropTypes2["Boolean"] = 4] = "Boolean";
|
|
196
|
+
PropTypes2[PropTypes2["Any"] = 8] = "Any";
|
|
197
|
+
PropTypes2[PropTypes2["Unknown"] = 16] = "Unknown";
|
|
198
|
+
PropTypes2[PropTypes2["State"] = 32] = "State";
|
|
199
|
+
PropTypes2[PropTypes2["Method"] = 64] = "Method";
|
|
200
|
+
PropTypes2[PropTypes2["Event"] = 128] = "Event";
|
|
201
|
+
PropTypes2[PropTypes2["Element"] = 256] = "Element";
|
|
202
|
+
PropTypes2[PropTypes2["ReflectAttr"] = 512] = "ReflectAttr";
|
|
203
|
+
PropTypes2[PropTypes2["Mutable"] = 1024] = "Mutable";
|
|
204
|
+
PropTypes2[PropTypes2["Prop"] = 31] = "Prop";
|
|
205
|
+
PropTypes2[PropTypes2["HasAttribute"] = 15] = "HasAttribute";
|
|
206
|
+
PropTypes2[PropTypes2["PropLike"] = 63] = "PropLike";
|
|
207
|
+
PropTypes2[PropTypes2["ReadOnly"] = 2048] = "ReadOnly";
|
|
208
|
+
return PropTypes2;
|
|
209
|
+
})(PropTypes || {});
|
|
210
|
+
function retrieveComponentMembers(component, isLit) {
|
|
211
|
+
if (isLit) {
|
|
212
|
+
const elementProperties = component.constructor.elementProperties;
|
|
213
|
+
component.manager.internals.members = Object.fromEntries(
|
|
214
|
+
Array.from(
|
|
215
|
+
elementProperties,
|
|
216
|
+
([name2, descriptor]) => descriptor.noAccessor ? void 0 : [
|
|
217
|
+
name2,
|
|
218
|
+
[
|
|
219
|
+
(descriptor.readOnly ? 2048 : 0) | (descriptor.state ? 32 : 16)
|
|
220
|
+
]
|
|
221
|
+
]
|
|
222
|
+
).filter(isNotUndefined)
|
|
223
|
+
);
|
|
224
|
+
} else {
|
|
225
|
+
const constructor = component.constructor;
|
|
226
|
+
const members = constructor.__registerControllers?.(component) ?? void 0;
|
|
227
|
+
constructor.__registerControllers = void 0;
|
|
228
|
+
if (typeof members !== "object") {
|
|
229
|
+
throw new Error(
|
|
230
|
+
process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? "Failed to retrieve internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config." : "Failed to retrieve component meta"
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
component.manager.internals.members = Object.fromEntries(
|
|
234
|
+
Object.entries(members).filter(([_name, [propType]]) => (propType & 63) !== 0)
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function parsePropertyValue(value, type = 8) {
|
|
239
|
+
const isComplex = value == null || typeof value === "object" || typeof value === "function";
|
|
240
|
+
if (isComplex) {
|
|
241
|
+
return value;
|
|
242
|
+
}
|
|
243
|
+
if ((type & 4) !== 0) {
|
|
244
|
+
return value === "false" ? false : value === "" || !!value;
|
|
245
|
+
} else if ((type & 2) !== 0) {
|
|
246
|
+
return Number.parseFloat(value);
|
|
247
|
+
} else if ((type & 1) !== 0) {
|
|
248
|
+
return String(value);
|
|
249
|
+
} else {
|
|
250
|
+
return value;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const getMemberType = (component, name2) => component.manager.internals.members?.[name2]?.[0];
|
|
254
|
+
class ComponentInternals {
|
|
255
|
+
constructor(component) {
|
|
256
|
+
this.enabledWatchers = {};
|
|
257
|
+
this.allWatchers = {};
|
|
258
|
+
this.enableReadonly = () => {
|
|
259
|
+
this.enableReadonly = void 0;
|
|
260
|
+
if (!this.component.manager.isLit) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const internals = this.component.manager.internals;
|
|
264
|
+
Object.entries(internals.members).forEach(([name2, [type]]) => {
|
|
265
|
+
const isReadOnly = type & PropTypes.ReadOnly;
|
|
266
|
+
if (isReadOnly) {
|
|
267
|
+
internals.setters[name2] ??= [];
|
|
268
|
+
internals.setters[name2].push(internals.readonlySetter);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
this.trackedValue = nothing;
|
|
273
|
+
this.keyTrackers = [];
|
|
274
|
+
this.getters = {};
|
|
275
|
+
this.setters = {};
|
|
276
|
+
this.accessorGetter = {};
|
|
277
|
+
this.accessorSetter = {};
|
|
278
|
+
this._exports = /* @__PURE__ */ new WeakMap();
|
|
279
|
+
this.readonlySetter = (newValue, _oldValue, property) => {
|
|
280
|
+
if (shouldBypass.readOnly) {
|
|
281
|
+
return newValue;
|
|
282
|
+
}
|
|
283
|
+
throw new Error(
|
|
284
|
+
`Cannot assign to read-only property "${property}" of ${this.component.el.localName}. Trying to assign "${String(
|
|
285
|
+
newValue
|
|
286
|
+
)}"`
|
|
287
|
+
);
|
|
288
|
+
};
|
|
289
|
+
if (process.env.NODE_ENV !== "production") {
|
|
290
|
+
Object.defineProperty(this, "component", {
|
|
291
|
+
writable: false,
|
|
292
|
+
enumerable: false,
|
|
293
|
+
configurable: true,
|
|
294
|
+
value: component
|
|
295
|
+
});
|
|
296
|
+
} else {
|
|
297
|
+
this.component = component;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
firePropTrackers(key, value) {
|
|
301
|
+
const trackers = this.keyTrackers;
|
|
302
|
+
this.trackedValue = nothing;
|
|
303
|
+
this.keyTrackers = [];
|
|
304
|
+
trackers.forEach((tracker) => tracker(key, value));
|
|
305
|
+
}
|
|
306
|
+
// REFACTOR: once Stencil is no longer supported, simplify this with Lit's getPropertyDescriptor(), or https://github.com/shoelace-style/shoelace/issues/1990
|
|
307
|
+
/**
|
|
308
|
+
* Configure a getter or setter for a given \@Prop/\@State
|
|
309
|
+
*
|
|
310
|
+
* Since props are defined on the prototype, they are shared between all
|
|
311
|
+
* instances of a component. Thus, instead of passing a reference to the
|
|
312
|
+
* getter/setter function, you should update the
|
|
313
|
+
* ComponentInternals.getters/setters properties, and then call getSetProxy
|
|
314
|
+
* to apply the changes to the prototype
|
|
315
|
+
*/
|
|
316
|
+
getSetProxy(property) {
|
|
317
|
+
const component = this.component;
|
|
318
|
+
const classPrototype = component.constructor.prototype;
|
|
319
|
+
this._getSetProxy(classPrototype, property, "class");
|
|
320
|
+
if (component.manager.isLit) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const htmlPrototype = component.el.constructor.prototype;
|
|
324
|
+
if (classPrototype !== htmlPrototype) {
|
|
325
|
+
this._getSetProxy(htmlPrototype, property, "html");
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
_getSetProxy(prototype, name2, type) {
|
|
329
|
+
const component = this.component;
|
|
330
|
+
const propType = getMemberType(component, name2);
|
|
331
|
+
let descriptor;
|
|
332
|
+
do {
|
|
333
|
+
descriptor = Object.getOwnPropertyDescriptor(prototype, name2);
|
|
334
|
+
} while (!descriptor && (prototype = Object.getPrototypeOf(prototype)));
|
|
335
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
336
|
+
const tolerateNotFound = type === "html";
|
|
337
|
+
if (descriptor?.set === void 0 || descriptor.get === void 0) {
|
|
338
|
+
if (descriptor !== void 0 && "value" in descriptor) {
|
|
339
|
+
throw new Error(
|
|
340
|
+
`getSet() should only be used on @Prop/@property/@State/@state properties. For internal component properties, use regular get/set syntax. Tried to use it on "${name2}" in ${component.el.localName}`
|
|
341
|
+
);
|
|
342
|
+
} else if (tolerateNotFound) {
|
|
343
|
+
return;
|
|
344
|
+
} else {
|
|
345
|
+
throw new Error(`Unable to find "${name2}" property on the ${component.el.localName} component`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (propType === void 0) {
|
|
349
|
+
throw new Error("Unable to retrieve prop type");
|
|
350
|
+
}
|
|
351
|
+
} else if (!descriptor) {
|
|
352
|
+
return void 0;
|
|
353
|
+
}
|
|
354
|
+
const originalGet = descriptor.get;
|
|
355
|
+
const originalSet = descriptor.set;
|
|
356
|
+
const isGetterAlreadyOverwritten = customAccessor in originalGet;
|
|
357
|
+
const isSetterAlreadyOverwritten = customAccessor in originalSet;
|
|
358
|
+
if (isGetterAlreadyOverwritten && isSetterAlreadyOverwritten) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const shouldOverwriteGet = !isGetterAlreadyOverwritten;
|
|
362
|
+
const shouldOverwriteSet = !isSetterAlreadyOverwritten;
|
|
363
|
+
const finalGetter = shouldOverwriteGet ? function getter() {
|
|
364
|
+
let value = originalGet.call(this);
|
|
365
|
+
const component2 = elementToInstance.get(this);
|
|
366
|
+
if (shouldBypass.getter || component2 === void 0) {
|
|
367
|
+
return value;
|
|
368
|
+
}
|
|
369
|
+
const internals = component2.manager.internals;
|
|
370
|
+
value = internals.accessorGetter[name2](value, name2);
|
|
371
|
+
const getters = internals.getters[name2] ?? emptyArray;
|
|
372
|
+
for (let i = 0; i < getters.length; i++) {
|
|
373
|
+
value = getters[i](value, name2);
|
|
374
|
+
}
|
|
375
|
+
return value;
|
|
376
|
+
} : originalGet;
|
|
377
|
+
const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
|
|
378
|
+
const oldValue = originalGet.call(this);
|
|
379
|
+
const component2 = elementToInstance.get(this);
|
|
380
|
+
if (component2 === void 0) {
|
|
381
|
+
originalSet.call(this, rawNewValue);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
let newValue = component2.manager.isLit ? (
|
|
385
|
+
/*
|
|
386
|
+
* Cast `null` to `undefined`.
|
|
387
|
+
* See https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/1299
|
|
388
|
+
*/
|
|
389
|
+
rawNewValue ?? void 0
|
|
390
|
+
) : parsePropertyValue(rawNewValue, propType);
|
|
391
|
+
const internals = component2.manager.internals;
|
|
392
|
+
if (newValue === oldValue) {
|
|
393
|
+
originalSet.call(this, newValue);
|
|
394
|
+
} else {
|
|
395
|
+
const setters = shouldBypass.setter ? emptyArray : internals.setters[name2] ?? emptyArray;
|
|
396
|
+
for (let i = 0; i < setters.length; i++) {
|
|
397
|
+
newValue = setters[i](newValue, oldValue, name2);
|
|
398
|
+
if (newValue === oldValue) {
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
newValue = internals.accessorSetter[name2](newValue, oldValue, name2);
|
|
403
|
+
originalSet.call(this, newValue);
|
|
404
|
+
if (newValue !== oldValue) {
|
|
405
|
+
internals.enabledWatchers[name2]?.forEach((watcher) => watcher(newValue, oldValue, name2));
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (internals.keyTrackers.length > 0) {
|
|
409
|
+
internals?.firePropTrackers(name2, rawNewValue);
|
|
410
|
+
}
|
|
411
|
+
} : originalSet;
|
|
412
|
+
if (shouldOverwriteGet) {
|
|
413
|
+
finalGetter[customAccessor] = true;
|
|
414
|
+
}
|
|
415
|
+
if (shouldOverwriteSet) {
|
|
416
|
+
finalSetter[customAccessor] = true;
|
|
417
|
+
}
|
|
418
|
+
Object.defineProperty(prototype, name2, {
|
|
419
|
+
...descriptor,
|
|
420
|
+
get: finalGetter,
|
|
421
|
+
set: finalSetter
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Associate an exports object with a controller for reverse lookup in
|
|
426
|
+
* controller.use
|
|
427
|
+
*/
|
|
428
|
+
markExports(controller, exports) {
|
|
429
|
+
if (typeof exports === "object" && exports !== null || typeof exports === "function") {
|
|
430
|
+
this._exports.set(exports, controller);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
resolveExports(exports) {
|
|
434
|
+
if (typeof exports === "object" && exports !== null || typeof exports === "function") {
|
|
435
|
+
return this._exports.get(exports);
|
|
436
|
+
} else {
|
|
437
|
+
return void 0;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
const emptyArray = [];
|
|
442
|
+
const customAccessor = Symbol();
|
|
443
|
+
const nothing = process.env.NODE_ENV !== "production" ? Symbol.for(
|
|
444
|
+
// Use Symbol.for in dev mode to make it easier to maintain state when doing HMR.
|
|
445
|
+
`${name}: nothing`
|
|
446
|
+
) : (
|
|
447
|
+
// eslint-disable-next-line symbol-description
|
|
448
|
+
Symbol()
|
|
449
|
+
);
|
|
450
|
+
function trackPropKey(component, onResolved, defaultValue) {
|
|
451
|
+
const internals = component.manager.internals;
|
|
452
|
+
if (internals.trackedValue !== nothing && internals.trackedValue !== defaultValue) {
|
|
453
|
+
internals.firePropTrackers(void 0, void 0);
|
|
454
|
+
}
|
|
455
|
+
if (internals.keyTrackers.length === 0) {
|
|
456
|
+
queueMicrotask(() => internals.firePropTrackers(void 0, void 0));
|
|
457
|
+
}
|
|
458
|
+
internals.trackedValue = defaultValue;
|
|
459
|
+
internals.keyTrackers.push((key, value) => safeCall(onResolved, void 0, defaultValue === value ? key : void 0));
|
|
460
|
+
return defaultValue;
|
|
461
|
+
}
|
|
462
|
+
function trackKey(hostsCandidates = [
|
|
463
|
+
retrieveComponent(),
|
|
464
|
+
...retrieveParentControllers()
|
|
465
|
+
], onResolved, defaultValue) {
|
|
466
|
+
const candidateHosts = Array.isArray(hostsCandidates) ? hostsCandidates : [hostsCandidates];
|
|
467
|
+
let leftToResolve = candidateHosts.length + 1;
|
|
468
|
+
const resolved = (resolution) => {
|
|
469
|
+
leftToResolve -= 1;
|
|
470
|
+
if (resolution !== void 0) {
|
|
471
|
+
leftToResolve = Math.min(leftToResolve, 0);
|
|
472
|
+
}
|
|
473
|
+
if (leftToResolve === 0) {
|
|
474
|
+
onResolved(resolution);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
candidateHosts.forEach(
|
|
478
|
+
(host) => trackPropertyKey(
|
|
479
|
+
host,
|
|
480
|
+
(key) => resolved(
|
|
481
|
+
key === void 0 ? void 0 : {
|
|
482
|
+
key,
|
|
483
|
+
host,
|
|
484
|
+
isReactive: false
|
|
485
|
+
}
|
|
486
|
+
),
|
|
487
|
+
defaultValue
|
|
488
|
+
)
|
|
489
|
+
);
|
|
490
|
+
const component = candidateHosts.find(
|
|
491
|
+
(host) => "manager" in host && typeof host.manager === "object" && host.manager.component === host
|
|
492
|
+
);
|
|
493
|
+
if (component) {
|
|
494
|
+
trackPropKey(
|
|
495
|
+
component,
|
|
496
|
+
(key) => resolved(
|
|
497
|
+
key === void 0 ? void 0 : {
|
|
498
|
+
key,
|
|
499
|
+
host: component,
|
|
500
|
+
isReactive: true
|
|
501
|
+
}
|
|
502
|
+
),
|
|
503
|
+
defaultValue
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
return defaultValue;
|
|
507
|
+
}
|
|
508
|
+
const createEventFactory = (eventName = "", options = {}, component = retrieveComponent()) => {
|
|
509
|
+
const emitter = {
|
|
510
|
+
emit: (payload) => {
|
|
511
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !component.el.isConnected) {
|
|
512
|
+
console.warn(`Trying to emit an ${eventName} event on a disconnected element ${component.el.localName}`);
|
|
513
|
+
}
|
|
514
|
+
if (eventName === "") {
|
|
515
|
+
keyTrackResolve();
|
|
516
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && eventName === "") {
|
|
517
|
+
throw new Error("Unable to resolve event name from property name");
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
const event = new CustomEvent(eventName, {
|
|
521
|
+
detail: payload,
|
|
522
|
+
cancelable: true,
|
|
523
|
+
bubbles: true,
|
|
524
|
+
composed: true,
|
|
525
|
+
...options
|
|
526
|
+
});
|
|
527
|
+
component.el.dispatchEvent(event);
|
|
528
|
+
return event;
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
if (eventName === "") {
|
|
532
|
+
trackKey(
|
|
533
|
+
void 0,
|
|
534
|
+
(resolution) => {
|
|
535
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && resolution === void 0) {
|
|
536
|
+
throw new Error(`createEvent must be called in property default value only`);
|
|
537
|
+
}
|
|
538
|
+
eventName = resolution.key;
|
|
539
|
+
},
|
|
540
|
+
emitter
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
return emitter;
|
|
544
|
+
};
|
|
545
|
+
const createEvent = createEventFactory.bind(null, "");
|
|
546
|
+
var _a;
|
|
547
|
+
_a = controllerSymbol;
|
|
548
|
+
class Controller {
|
|
549
|
+
constructor(component) {
|
|
550
|
+
this._callbacks = {
|
|
551
|
+
hostConnected: [],
|
|
552
|
+
hostDisconnected: [],
|
|
553
|
+
hostLoad: [],
|
|
554
|
+
hostLoaded: [],
|
|
555
|
+
hostUpdate: [],
|
|
556
|
+
hostUpdated: [],
|
|
557
|
+
hostDestroy: [],
|
|
558
|
+
hostLifecycle: []
|
|
559
|
+
};
|
|
560
|
+
this._ready = new Deferred();
|
|
561
|
+
this._lifecycleCleanups = [];
|
|
562
|
+
this.connectedCalled = false;
|
|
563
|
+
this._loadCalled = false;
|
|
564
|
+
this.loadedCalled = false;
|
|
565
|
+
this[_a] = true;
|
|
566
|
+
this.ready = this._ready.promise;
|
|
567
|
+
this._exports = makeProvisionalValue(this);
|
|
568
|
+
this._exportWatchers = /* @__PURE__ */ new Set();
|
|
569
|
+
const resolvedComponent = toControllerHost(component ?? retrieveComponent(new.target.name));
|
|
570
|
+
if (process.env.NODE_ENV !== "production") {
|
|
571
|
+
Object.defineProperty(this, "component", {
|
|
572
|
+
writable: false,
|
|
573
|
+
enumerable: false,
|
|
574
|
+
configurable: true,
|
|
575
|
+
value: resolvedComponent
|
|
576
|
+
});
|
|
577
|
+
if ("hostDestroy" in this) {
|
|
578
|
+
this.component.manager.ensureHasDestroy?.();
|
|
579
|
+
}
|
|
580
|
+
} else {
|
|
581
|
+
this.component = resolvedComponent;
|
|
582
|
+
}
|
|
583
|
+
this.component.addController(this);
|
|
584
|
+
const manager = this.component.manager;
|
|
585
|
+
const isInControllerManager = manager === void 0;
|
|
586
|
+
if (!isInControllerManager) {
|
|
587
|
+
setParentController(this);
|
|
588
|
+
queueMicrotask(() => this.catchUpLifecycle());
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* If controller is being added dynamically, after the component
|
|
593
|
+
* construction, then trigger connected and load right away
|
|
594
|
+
*/
|
|
595
|
+
catchUpLifecycle() {
|
|
596
|
+
const { manager } = this.component;
|
|
597
|
+
const connectedWillStillHappen = !manager.connectedCalled;
|
|
598
|
+
if (!connectedWillStillHappen && !this.connectedCalled) {
|
|
599
|
+
this.triggerConnected();
|
|
600
|
+
}
|
|
601
|
+
const loadWillStillHappen = !manager._loadCalled;
|
|
602
|
+
if (loadWillStillHappen) {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
this.triggerLoad().then(() => {
|
|
606
|
+
const loadedWillStillHappen = !manager.loadedCalled;
|
|
607
|
+
if (loadedWillStillHappen) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
this.triggerLoaded();
|
|
611
|
+
}).catch(console.error);
|
|
612
|
+
}
|
|
613
|
+
get exports() {
|
|
614
|
+
return this._exports;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Set controller's exports property (for usage with proxyExports()) and mark
|
|
618
|
+
* controller as ready (for usage in other controllers). Also, triggers
|
|
619
|
+
* re-render of the component
|
|
620
|
+
*/
|
|
621
|
+
set exports(exports) {
|
|
622
|
+
const oldExports = this._exports;
|
|
623
|
+
if (oldExports !== exports) {
|
|
624
|
+
this._exports = exports;
|
|
625
|
+
this._exportWatchers.forEach(safeCall);
|
|
626
|
+
if (this.connectedCalled && this.assignedProperty !== false) {
|
|
627
|
+
this.component.requestUpdate(this.assignedProperty, oldExports);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
this._ready.resolve(exports);
|
|
631
|
+
}
|
|
632
|
+
setProvisionalExports(exports, proxy = true) {
|
|
633
|
+
this._exports = proxy ? makeProvisionalValue(exports) : exports;
|
|
634
|
+
this._exportWatchers.forEach(safeCall);
|
|
635
|
+
}
|
|
636
|
+
watchExports(callback) {
|
|
637
|
+
const safeCallback = () => callback(this._exports);
|
|
638
|
+
this._exportWatchers.add(safeCallback);
|
|
639
|
+
return () => void this._exportWatchers.delete(safeCallback);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* A flexible utility for making sure a controller is loaded before it's used,
|
|
643
|
+
* regardless of how or where a controller was defined:
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* makeGenericController(async (component, controller) => {
|
|
647
|
+
* // Await some controller from the component:
|
|
648
|
+
* await controller.use(component.someController);
|
|
649
|
+
* // Initialize new controllers
|
|
650
|
+
* await controller.use(load(importCoreReactiveUtils));
|
|
651
|
+
* await controller.use(new ViewModelController(component,newWidgetsHomeHomeViewModel));
|
|
652
|
+
* await controller.use(someController(component));
|
|
653
|
+
* });
|
|
654
|
+
*
|
|
655
|
+
* @remarks
|
|
656
|
+
* If your controller is not async, and you are not creating it async, then
|
|
657
|
+
* you are not required to use controller.use - you can use it directly.
|
|
658
|
+
* Similarly, accessing controllers after componentWillLoad callback does not
|
|
659
|
+
* require awaiting them as they are guaranteed to be loaded by then.
|
|
660
|
+
*/
|
|
661
|
+
get use() {
|
|
662
|
+
setAmbientComponent(this.component);
|
|
663
|
+
return use;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Just like controller.use, but returns the controller itself, rather than it's
|
|
667
|
+
* exports
|
|
668
|
+
*
|
|
669
|
+
* Use cases:
|
|
670
|
+
* - You have a controller and you want to make sure it's loaded before you
|
|
671
|
+
* try to use it
|
|
672
|
+
* - Your controller is not using exports, so you wish to access some props on
|
|
673
|
+
* it directly
|
|
674
|
+
* - You have a controller exports only, and you want to retrieve the
|
|
675
|
+
* controller itself. This is useful if you wish to call .watchExports() or
|
|
676
|
+
* some other method on the controller
|
|
677
|
+
*/
|
|
678
|
+
get useRef() {
|
|
679
|
+
setAmbientComponent(this.component);
|
|
680
|
+
return useRef;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Like useRef, but doesn't wait for the controller to get ready
|
|
684
|
+
*
|
|
685
|
+
* @internal
|
|
686
|
+
*/
|
|
687
|
+
get useRefSync() {
|
|
688
|
+
setAmbientComponent(this.component);
|
|
689
|
+
return useRefSync;
|
|
690
|
+
}
|
|
691
|
+
controllerRemoved() {
|
|
692
|
+
if (this.component.el.isConnected) {
|
|
693
|
+
this.triggerDisconnected();
|
|
694
|
+
}
|
|
695
|
+
this.triggerDestroy();
|
|
696
|
+
}
|
|
697
|
+
// Register a lifecycle callback
|
|
698
|
+
onConnected(callback) {
|
|
699
|
+
this._callbacks.hostConnected.push(callback);
|
|
700
|
+
}
|
|
701
|
+
onDisconnected(callback) {
|
|
702
|
+
this._callbacks.hostDisconnected.push(callback);
|
|
703
|
+
}
|
|
704
|
+
onLoad(callback) {
|
|
705
|
+
this._callbacks.hostLoad.push(callback);
|
|
706
|
+
}
|
|
707
|
+
onLoaded(callback) {
|
|
708
|
+
this._callbacks.hostLoaded.push(callback);
|
|
709
|
+
}
|
|
710
|
+
onUpdate(callback) {
|
|
711
|
+
this._callbacks.hostUpdate.push(callback);
|
|
712
|
+
}
|
|
713
|
+
onUpdated(callback) {
|
|
714
|
+
this._callbacks.hostUpdated.push(callback);
|
|
715
|
+
}
|
|
716
|
+
onDestroy(callback) {
|
|
717
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
718
|
+
this.component.manager.ensureHasDestroy?.();
|
|
719
|
+
}
|
|
720
|
+
this._callbacks.hostDestroy.push(callback);
|
|
721
|
+
}
|
|
722
|
+
onLifecycle(callback) {
|
|
723
|
+
this._callbacks.hostLifecycle.push(callback);
|
|
724
|
+
if (this.connectedCalled && this.component.el.isConnected) {
|
|
725
|
+
this._callLifecycle(callback);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
// Call each lifecycle hook
|
|
729
|
+
/** @internal */
|
|
730
|
+
triggerConnected() {
|
|
731
|
+
const genericController = this;
|
|
732
|
+
if (genericController.hostConnected) {
|
|
733
|
+
safeCall(genericController.hostConnected, genericController);
|
|
734
|
+
}
|
|
735
|
+
this._callbacks.hostConnected.forEach(safeCall);
|
|
736
|
+
this.triggerLifecycle();
|
|
737
|
+
this.connectedCalled = true;
|
|
738
|
+
}
|
|
739
|
+
/** @internal */
|
|
740
|
+
triggerDisconnected() {
|
|
741
|
+
const genericController = this;
|
|
742
|
+
if (genericController.hostDisconnected) {
|
|
743
|
+
safeCall(genericController.hostDisconnected, genericController);
|
|
744
|
+
}
|
|
745
|
+
this._callbacks.hostDisconnected.forEach(safeCall);
|
|
746
|
+
this._lifecycleCleanups.forEach(safeCall);
|
|
747
|
+
this._lifecycleCleanups = [];
|
|
748
|
+
}
|
|
749
|
+
/** @internal */
|
|
750
|
+
async triggerLoad() {
|
|
751
|
+
if (this._loadCalled) {
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
this._loadCalled = true;
|
|
755
|
+
const genericController = this;
|
|
756
|
+
if (genericController.hostLoad) {
|
|
757
|
+
await safeAsyncCall(genericController.hostLoad, genericController);
|
|
758
|
+
}
|
|
759
|
+
if (this._callbacks.hostLoad.length > 0) {
|
|
760
|
+
await Promise.allSettled(this._callbacks.hostLoad.map(safeAsyncCall));
|
|
761
|
+
}
|
|
762
|
+
this._ready.resolve(this._exports);
|
|
763
|
+
}
|
|
764
|
+
/** @internal */
|
|
765
|
+
triggerLoaded() {
|
|
766
|
+
if (this.loadedCalled) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
const genericController = this;
|
|
770
|
+
if (genericController.hostLoaded) {
|
|
771
|
+
safeCall(genericController.hostLoaded, genericController);
|
|
772
|
+
}
|
|
773
|
+
this._callbacks.hostLoaded.forEach(safeCall);
|
|
774
|
+
this.loadedCalled = true;
|
|
775
|
+
}
|
|
776
|
+
/** @internal */
|
|
777
|
+
triggerUpdate(changes) {
|
|
778
|
+
const genericController = this;
|
|
779
|
+
if (genericController.hostUpdate) {
|
|
780
|
+
safeCall(genericController.hostUpdate, genericController, changes);
|
|
781
|
+
}
|
|
782
|
+
this._callbacks.hostUpdate.forEach(callUpdate, changes);
|
|
783
|
+
}
|
|
784
|
+
/** @internal */
|
|
785
|
+
triggerUpdated(changes) {
|
|
786
|
+
const genericController = this;
|
|
787
|
+
if (genericController.hostUpdated) {
|
|
788
|
+
safeCall(genericController.hostUpdated, genericController, changes);
|
|
789
|
+
}
|
|
790
|
+
this._callbacks.hostUpdated.forEach(callUpdate, changes);
|
|
791
|
+
}
|
|
792
|
+
/** @internal */
|
|
793
|
+
triggerDestroy() {
|
|
794
|
+
const genericController = this;
|
|
795
|
+
if (genericController.hostDestroy) {
|
|
796
|
+
safeCall(genericController.hostDestroy, genericController);
|
|
797
|
+
}
|
|
798
|
+
this._callbacks.hostDestroy.forEach(safeCall);
|
|
799
|
+
}
|
|
800
|
+
/** @internal */
|
|
801
|
+
triggerLifecycle() {
|
|
802
|
+
const genericController = this;
|
|
803
|
+
if (genericController.hostLifecycle) {
|
|
804
|
+
this._callLifecycle(() => genericController.hostLifecycle());
|
|
805
|
+
}
|
|
806
|
+
this._callbacks.hostLifecycle.forEach(this._callLifecycle, this);
|
|
807
|
+
}
|
|
808
|
+
_callLifecycle(callback) {
|
|
809
|
+
setAmbientComponent(this.component);
|
|
810
|
+
const cleanupRaw = safeCall(callback);
|
|
811
|
+
const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
|
|
812
|
+
cleanup.forEach((cleanup2) => {
|
|
813
|
+
if (typeof cleanup2 === "function") {
|
|
814
|
+
this._lifecycleCleanups.push(cleanup2);
|
|
815
|
+
} else if (typeof cleanup2 === "object" && typeof cleanup2.remove === "function") {
|
|
816
|
+
this._lifecycleCleanups.push(cleanup2.remove);
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
function callUpdate(callback) {
|
|
822
|
+
safeCall(callback, void 0, this);
|
|
823
|
+
}
|
|
824
|
+
const GenericController = Controller;
|
|
825
|
+
function makeProvisionalValue(base) {
|
|
826
|
+
if (typeof base !== "object" && typeof base !== "function" || base === null) {
|
|
827
|
+
return base;
|
|
828
|
+
}
|
|
829
|
+
const proxy = new Proxy(base, {
|
|
830
|
+
get(target, prop, receiver) {
|
|
831
|
+
if (cyclical.has(prop) && prop in target && target[prop] === proxy) {
|
|
832
|
+
return void 0;
|
|
833
|
+
}
|
|
834
|
+
if (prop in target || prop in Promise.prototype || typeof prop === "symbol") {
|
|
835
|
+
return typeof target === "function" ? target[prop] : Reflect.get(target, prop, receiver);
|
|
836
|
+
}
|
|
837
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
838
|
+
if (process.env.NODE_ENV === "test" && (prop.startsWith("$$") || prop.startsWith("@@") || prop === "nodeType" || prop === "tagName" || prop === "toJSON" || prop === "hasAttribute")) {
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
console.error(
|
|
842
|
+
`Trying to access "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`
|
|
843
|
+
);
|
|
844
|
+
}
|
|
845
|
+
return void 0;
|
|
846
|
+
},
|
|
847
|
+
set: (target, prop, newValue, receiver) => {
|
|
848
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
849
|
+
console.error(`Trying to set "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
|
|
850
|
+
}
|
|
851
|
+
return Reflect.set(target, prop, newValue, receiver);
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
return proxy;
|
|
855
|
+
}
|
|
856
|
+
const cyclical = /* @__PURE__ */ new Set(["exports", "_exports"]);
|
|
857
|
+
const accessBeforeLoad = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? [
|
|
858
|
+
"This might be the case if you are trying to access an async controller in ",
|
|
859
|
+
"connectedCallback(). Or, if you are using it inside of ",
|
|
860
|
+
"componentWillLoad()/another controller without controller.use. Example correct ",
|
|
861
|
+
"usage:\n",
|
|
862
|
+
"makeController(async (component, controller)=>{ await controller.use(someOtherController); });"
|
|
863
|
+
].join("") : void 0;
|
|
864
|
+
function toControllerHost(component) {
|
|
865
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
866
|
+
if ("addController" in component) {
|
|
867
|
+
return component;
|
|
868
|
+
} else {
|
|
869
|
+
throw new Error(
|
|
870
|
+
"Component does not implement ControllerHost. This might be because you forgot to add 'manager: Controller<this> = useControllerManager(this);' in your component, or you tried to use some controller before that line"
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
} else {
|
|
874
|
+
return component;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
function watch(component, property, callback) {
|
|
878
|
+
const genericProperty = property;
|
|
879
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
880
|
+
const type = getMemberType(component, genericProperty);
|
|
881
|
+
if (type === void 0) {
|
|
882
|
+
throw new Error(
|
|
883
|
+
component.manager.isLit ? `Trying to watch a non-@property, non-@state property "${genericProperty}". Either convert it into a @state() to be able to use watch() on it, or use the get/set syntax` : `Trying to watch a non-@Prop, non-@State property "${genericProperty}". Convert it into a @State() or @Prop property if you need to use watch() on it`
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
const internals = component.manager.internals;
|
|
888
|
+
internals.allWatchers[genericProperty] ??= [];
|
|
889
|
+
const watchers = internals.allWatchers[genericProperty];
|
|
890
|
+
const genericCallback = callback;
|
|
891
|
+
const safeCallback = (newValue, oldValue, propertyName) => safeCall(genericCallback, null, newValue, oldValue, propertyName);
|
|
892
|
+
watchers.push(safeCallback);
|
|
893
|
+
return () => {
|
|
894
|
+
const index = watchers.indexOf(safeCallback);
|
|
895
|
+
if (index !== -1) {
|
|
896
|
+
watchers.splice(index, 1);
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
export {
|
|
901
|
+
Controller as C,
|
|
902
|
+
GenericController as G,
|
|
903
|
+
PropTypes as P,
|
|
904
|
+
setParentController as a,
|
|
905
|
+
retrieveParentControllers as b,
|
|
906
|
+
createEvent as c,
|
|
907
|
+
createEventFactory as d,
|
|
908
|
+
trackPropertyKey as e,
|
|
909
|
+
trackPropKey as f,
|
|
910
|
+
isController as g,
|
|
911
|
+
controllerSymbol as h,
|
|
912
|
+
isPromise as i,
|
|
913
|
+
ComponentInternals as j,
|
|
914
|
+
keyTrackResolve as k,
|
|
915
|
+
retrieveComponentMembers as l,
|
|
916
|
+
elementToInstance as m,
|
|
917
|
+
devOnlySetPersistentControllerData as n,
|
|
918
|
+
devOnlyGetPersistentControllerData as o,
|
|
919
|
+
shouldBypass as p,
|
|
920
|
+
setAmbientChildController as q,
|
|
921
|
+
retrieveComponent as r,
|
|
922
|
+
setAmbientComponent as s,
|
|
923
|
+
trackKey as t,
|
|
924
|
+
watch as w
|
|
925
|
+
};
|