@arcgis/lumina 4.34.0-next.13 → 4.34.0-next.130
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/LICENSE.md +1 -1
- package/README.md +2 -10
- package/dist/{Controller-BQOv8BAL.js → Controller-ftAEcdmI.js} +11 -137
- package/dist/ControllerInternals-CWQrfEA8.js +133 -0
- package/dist/LitElement.d.ts +19 -0
- package/dist/context.js +18 -0
- package/dist/controllers/Controller.d.ts +1 -3
- package/dist/controllers/ControllerInternals.d.ts +1 -1
- package/dist/controllers/accessor/index.js +23 -17
- package/dist/controllers/accessor/store.d.ts +2 -2
- package/dist/controllers/accessor/useAccessor.d.ts +8 -3
- package/dist/controllers/index.d.ts +5 -1
- package/dist/controllers/index.js +20 -14
- package/dist/controllers/trackPropertyKey.d.ts +1 -1
- package/dist/controllers/types.d.ts +1 -1
- package/dist/controllers/useT9n.d.ts +3 -3
- package/dist/decorators.d.ts +1 -1
- package/dist/hmrSupport.js +2 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +49 -36
- package/dist/jsx/baseTypes.d.ts +2 -2
- package/dist/jsx/directives.d.ts +34 -7
- package/dist/jsx/generatedTypes.d.ts +13 -5
- package/dist/jsx/types.d.ts +2 -2
- package/dist/{lazyLoad-DUvrNd2L.js → lazyLoad-BlK67lvm.js} +8 -6
- package/dist/lazyLoad.d.ts +1 -1
- package/dist/makeRuntime.d.ts +1 -1
- package/dist/{proxyExports-Cdzj7WL_.js → proxyExports-D906TEtL.js} +2 -1
- package/dist/render.d.ts +6 -0
- package/package.json +12 -7
- package/dist/stencilSsrCompatibility/index.d.ts +0 -73
- package/dist/stencilSsrCompatibility/index.js +0 -87
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -8,14 +8,6 @@ It is not intended to be used directly, but rather used as a dependency by other
|
|
|
8
8
|
|
|
9
9
|
## License
|
|
10
10
|
|
|
11
|
-
COPYRIGHT ©
|
|
11
|
+
COPYRIGHT © Esri
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
|
|
16
|
-
|
|
17
|
-
See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>
|
|
18
|
-
|
|
19
|
-
For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
|
|
20
|
-
|
|
21
|
-
email: contracts@esri.com
|
|
13
|
+
This package is licensed under the terms described in the `LICENSE.md` file, located in the root of the package.
|
|
@@ -1,126 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { safeCall, isEsriInternalEnv, safeAsyncCall } from "@arcgis/toolkit/error";
|
|
2
|
+
import { r as retrieveComponent, d as retrieveParentControllers, b as setParentController, s as setAmbientComponent, u as use, k as useRef, l as useRefSync, c as controllerSymbol } from "./ControllerInternals-CWQrfEA8.js";
|
|
2
3
|
import { nothing } from "lit";
|
|
3
|
-
|
|
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 isPromise = (arg) => typeof arg?.then === "function";
|
|
6
|
-
const getControllersCount = (component) => component.M.length;
|
|
7
|
-
let ambientComponent;
|
|
8
|
-
const setAmbientComponent = (component) => {
|
|
9
|
-
if (ambientComponent === component) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
ambientComponent = component;
|
|
13
|
-
queueMicrotask(() => ambientComponent === component ? ambientComponent = void 0 : 0);
|
|
14
|
-
};
|
|
15
|
-
const retrieveComponent = (name) => {
|
|
16
|
-
if (process.env.NODE_ENV !== "production" && ambientComponent === void 0) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
[
|
|
19
|
-
`Unable to find out which component ${name || "this"} controller `,
|
|
20
|
-
"belongs to. Possible causes:\n",
|
|
21
|
-
"- You might have multiple versions of ",
|
|
22
|
-
"@arcgis/lumina package installed\n",
|
|
23
|
-
...isEsriInternalEnv() ? [
|
|
24
|
-
"- You tried to create controller outside the component. If so, ",
|
|
25
|
-
"please wrap your controller definition in an arrow function (like",
|
|
26
|
-
"`const myController = ()=>makeController(...);`) and call that",
|
|
27
|
-
"function inside the component (`my = myController();`), or ",
|
|
28
|
-
"define your controller using makeGenericController/GenericController ",
|
|
29
|
-
"instead.\n",
|
|
30
|
-
"- You tried to create a controller inside an async function. ",
|
|
31
|
-
"This is allowed without calling controller.use(). Make sure you ",
|
|
32
|
-
"use it like `await controller.use(useController())`."
|
|
33
|
-
] : []
|
|
34
|
-
].join("")
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
return ambientComponent;
|
|
38
|
-
};
|
|
39
|
-
let ambientControllers = [];
|
|
40
|
-
const setParentController = (controller) => {
|
|
41
|
-
if (controller === void 0) {
|
|
42
|
-
ambientControllers = [];
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const index = ambientControllers.indexOf(controller);
|
|
46
|
-
ambientControllers = index === -1 ? [...ambientControllers, controller] : ambientControllers.slice(0, index + 1);
|
|
47
|
-
queueMicrotask(() => ambientControllers = []);
|
|
48
|
-
};
|
|
49
|
-
const retrieveParentControllers = () => ambientControllers;
|
|
50
|
-
let ambientChildController;
|
|
51
|
-
const setAmbientChildController = (controller) => {
|
|
52
|
-
if (ambientChildController === controller) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
ambientChildController = controller;
|
|
56
|
-
queueMicrotask(() => ambientChildController === controller ? ambientChildController = void 0 : 0);
|
|
57
|
-
};
|
|
58
|
-
const retrieveAmbientChildController = () => {
|
|
59
|
-
const controller = ambientChildController;
|
|
60
|
-
ambientChildController = void 0;
|
|
61
|
-
return controller;
|
|
62
|
-
};
|
|
63
|
-
const use = async (value, watchExports) => {
|
|
64
|
-
const controller = useRefSync(value);
|
|
65
|
-
if (controller === void 0) {
|
|
66
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && typeof watchExports === "function") {
|
|
67
|
-
throw new Error(
|
|
68
|
-
`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`
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
await controller.ready;
|
|
74
|
-
if (typeof watchExports === "function") {
|
|
75
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && controller.watchExports === void 0) {
|
|
76
|
-
throw new Error(`The controller must implement watchExports method to support watching exports`);
|
|
77
|
-
}
|
|
78
|
-
const unsubscribe = controller.watchExports(
|
|
79
|
-
(exports) => watchExports(exports, unsubscribe)
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
return controller.exports;
|
|
83
|
-
};
|
|
84
|
-
const useRef = async (value) => {
|
|
85
|
-
const controller = useRefSync(value);
|
|
86
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && controller === void 0) {
|
|
87
|
-
throw new Error(
|
|
88
|
-
`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`
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
await controller.ready;
|
|
92
|
-
return controller;
|
|
93
|
-
};
|
|
94
|
-
const useRefSync = (value) => {
|
|
95
|
-
const component = retrieveComponent();
|
|
96
|
-
const controller = component.manager.X(value);
|
|
97
|
-
if (controller !== void 0) {
|
|
98
|
-
return controller;
|
|
99
|
-
}
|
|
100
|
-
if (isController(value)) {
|
|
101
|
-
return value;
|
|
102
|
-
}
|
|
103
|
-
const ambientChildController2 = retrieveAmbientChildController();
|
|
104
|
-
if (ambientChildController2 !== void 0) {
|
|
105
|
-
return ambientChildController2;
|
|
106
|
-
}
|
|
107
|
-
return void 0;
|
|
108
|
-
};
|
|
109
|
-
let shouldBypassReadOnly = false;
|
|
110
|
-
const bypassReadOnly = (callback) => {
|
|
111
|
-
shouldBypassReadOnly = true;
|
|
112
|
-
try {
|
|
113
|
-
return callback();
|
|
114
|
-
} finally {
|
|
115
|
-
shouldBypassReadOnly = false;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
const bypassSetter = bypassReadOnly;
|
|
4
|
+
import { Deferred } from "@arcgis/toolkit/promise";
|
|
119
5
|
const trackPropertyKey = (object, onResolved, defaultValue) => {
|
|
120
6
|
const keys = Object.keys(object);
|
|
121
7
|
const keyCount = keys.length;
|
|
122
8
|
if (keyTrackMap === void 0) {
|
|
123
|
-
queueMicrotask(
|
|
9
|
+
queueMicrotask(propertyTrackResolve);
|
|
124
10
|
}
|
|
125
11
|
keyTrackMap ??= /* @__PURE__ */ new Map();
|
|
126
12
|
let pendingTrackers = keyTrackMap.get(object);
|
|
@@ -147,7 +33,7 @@ const trackPropertyKey = (object, onResolved, defaultValue) => {
|
|
|
147
33
|
return defaultValue;
|
|
148
34
|
};
|
|
149
35
|
let keyTrackMap = void 0;
|
|
150
|
-
const
|
|
36
|
+
const propertyTrackResolve = () => {
|
|
151
37
|
keyTrackMap?.forEach(({ callbacks }, object) => {
|
|
152
38
|
const keys = Object.keys(object);
|
|
153
39
|
callbacks.forEach((commit) => commit(keys));
|
|
@@ -207,7 +93,7 @@ const createEventFactory = (eventName = "", options = {}, component = retrieveCo
|
|
|
207
93
|
console.warn(`Trying to emit an ${eventName} event on a disconnected element ${component.el.localName}`);
|
|
208
94
|
}
|
|
209
95
|
if (eventName === "") {
|
|
210
|
-
|
|
96
|
+
propertyTrackResolve();
|
|
211
97
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && eventName === "") {
|
|
212
98
|
throw new Error("Unable to resolve event name from property name");
|
|
213
99
|
}
|
|
@@ -566,22 +452,10 @@ const accessBeforeLoad = process.env.NODE_ENV !== "production" && isEsriInternal
|
|
|
566
452
|
export {
|
|
567
453
|
Controller as C,
|
|
568
454
|
GenericController as G,
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
createEventFactory as f,
|
|
575
|
-
bypassSetter as g,
|
|
576
|
-
bypassReadOnly as h,
|
|
577
|
-
isPromise as i,
|
|
578
|
-
trackPropertyKey as j,
|
|
579
|
-
keyTrackResolve as k,
|
|
580
|
-
trackPropKey as l,
|
|
581
|
-
isController as m,
|
|
582
|
-
getControllersCount as n,
|
|
583
|
-
setAmbientChildController as o,
|
|
584
|
-
retrieveComponent as r,
|
|
585
|
-
setAmbientComponent as s,
|
|
455
|
+
createEventFactory as a,
|
|
456
|
+
trackPropertyKey as b,
|
|
457
|
+
createEvent as c,
|
|
458
|
+
trackPropKey as d,
|
|
459
|
+
propertyTrackResolve as p,
|
|
586
460
|
trackKey as t
|
|
587
461
|
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { isEsriInternalEnv } from "@arcgis/toolkit/error";
|
|
2
|
+
const controllerSymbol = Symbol.for("controller");
|
|
3
|
+
const isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
|
|
4
|
+
const isPromise = (arg) => typeof arg?.then === "function";
|
|
5
|
+
const getControllersCount = (component) => component.M.length;
|
|
6
|
+
let ambientComponent;
|
|
7
|
+
const setAmbientComponent = (component) => {
|
|
8
|
+
if (ambientComponent === component) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
ambientComponent = component;
|
|
12
|
+
queueMicrotask(() => ambientComponent === component ? ambientComponent = void 0 : 0);
|
|
13
|
+
};
|
|
14
|
+
const retrieveComponent = (name) => {
|
|
15
|
+
if (process.env.NODE_ENV !== "production" && ambientComponent === void 0) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
[
|
|
18
|
+
`Unable to find out which component ${name || "this"} controller `,
|
|
19
|
+
"belongs to. Possible causes:\n",
|
|
20
|
+
"- You might have multiple versions of ",
|
|
21
|
+
"@arcgis/lumina package installed\n",
|
|
22
|
+
...isEsriInternalEnv() ? [
|
|
23
|
+
"- You tried to create controller outside the component (in ",
|
|
24
|
+
"non-component class or in global scope).",
|
|
25
|
+
"- You accidentally defined the controller using const a = ",
|
|
26
|
+
"makeController(...); rather than const a = () => ",
|
|
27
|
+
"makeController(...);",
|
|
28
|
+
"- You tried to create a controller inside an async function. ",
|
|
29
|
+
"This is not allowed without calling controller.use(). Make ",
|
|
30
|
+
"sure you use it like `await controller.use(useController())`."
|
|
31
|
+
] : []
|
|
32
|
+
].join("")
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return ambientComponent;
|
|
36
|
+
};
|
|
37
|
+
let ambientControllers = [];
|
|
38
|
+
const setParentController = (controller) => {
|
|
39
|
+
if (controller === void 0) {
|
|
40
|
+
ambientControllers = [];
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const index = ambientControllers.indexOf(controller);
|
|
44
|
+
ambientControllers = index === -1 ? [...ambientControllers, controller] : ambientControllers.slice(0, index + 1);
|
|
45
|
+
queueMicrotask(() => ambientControllers = []);
|
|
46
|
+
};
|
|
47
|
+
const retrieveParentControllers = () => ambientControllers;
|
|
48
|
+
let ambientChildController;
|
|
49
|
+
const setAmbientChildController = (controller) => {
|
|
50
|
+
if (ambientChildController === controller) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
ambientChildController = controller;
|
|
54
|
+
queueMicrotask(() => ambientChildController === controller ? ambientChildController = void 0 : 0);
|
|
55
|
+
};
|
|
56
|
+
const retrieveAmbientChildController = () => {
|
|
57
|
+
const controller = ambientChildController;
|
|
58
|
+
ambientChildController = void 0;
|
|
59
|
+
return controller;
|
|
60
|
+
};
|
|
61
|
+
const use = async (value, watchExports) => {
|
|
62
|
+
const controller = useRefSync(value);
|
|
63
|
+
if (controller === void 0) {
|
|
64
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && typeof watchExports === "function") {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`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`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
await controller.ready;
|
|
72
|
+
if (typeof watchExports === "function") {
|
|
73
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && controller.watchExports === void 0) {
|
|
74
|
+
throw new Error(`The controller must implement watchExports method to support watching exports`);
|
|
75
|
+
}
|
|
76
|
+
const unsubscribe = controller.watchExports(
|
|
77
|
+
(exports) => watchExports(exports, unsubscribe)
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return controller.exports;
|
|
81
|
+
};
|
|
82
|
+
const useRef = async (value) => {
|
|
83
|
+
const controller = useRefSync(value);
|
|
84
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && controller === void 0) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`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`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
await controller.ready;
|
|
90
|
+
return controller;
|
|
91
|
+
};
|
|
92
|
+
const useRefSync = (value) => {
|
|
93
|
+
const component = retrieveComponent();
|
|
94
|
+
const controller = component.manager.X(value);
|
|
95
|
+
if (controller !== void 0) {
|
|
96
|
+
return controller;
|
|
97
|
+
}
|
|
98
|
+
if (isController(value)) {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
const ambientChildController2 = retrieveAmbientChildController();
|
|
102
|
+
if (ambientChildController2 !== void 0) {
|
|
103
|
+
return ambientChildController2;
|
|
104
|
+
}
|
|
105
|
+
return void 0;
|
|
106
|
+
};
|
|
107
|
+
let shouldBypassReadOnly = false;
|
|
108
|
+
const bypassReadOnly = (callback) => {
|
|
109
|
+
shouldBypassReadOnly = true;
|
|
110
|
+
try {
|
|
111
|
+
return callback();
|
|
112
|
+
} finally {
|
|
113
|
+
shouldBypassReadOnly = false;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const bypassSetter = bypassReadOnly;
|
|
117
|
+
export {
|
|
118
|
+
shouldBypassReadOnly as a,
|
|
119
|
+
setParentController as b,
|
|
120
|
+
controllerSymbol as c,
|
|
121
|
+
retrieveParentControllers as d,
|
|
122
|
+
bypassSetter as e,
|
|
123
|
+
bypassReadOnly as f,
|
|
124
|
+
isController as g,
|
|
125
|
+
getControllersCount as h,
|
|
126
|
+
isPromise as i,
|
|
127
|
+
setAmbientChildController as j,
|
|
128
|
+
useRef as k,
|
|
129
|
+
useRefSync as l,
|
|
130
|
+
retrieveComponent as r,
|
|
131
|
+
setAmbientComponent as s,
|
|
132
|
+
use as u
|
|
133
|
+
};
|
package/dist/LitElement.d.ts
CHANGED
|
@@ -252,4 +252,23 @@ type Listener<ThisType, EventType> = ((this: ThisType, event: EventType) => unkn
|
|
|
252
252
|
export type GlobalThisWithOwnTagNames = typeof globalThis & {
|
|
253
253
|
devOnly$ownTagNames?: Set<string>;
|
|
254
254
|
};
|
|
255
|
+
/**
|
|
256
|
+
* Lumina tracks accesses to JSAPI Accessor properties during render() and
|
|
257
|
+
* automatically re-renders the component when any tracked property changes.
|
|
258
|
+
*
|
|
259
|
+
* If your render() has imperative rendering logic or relies on specific render()
|
|
260
|
+
* call timing, you can temporarily disable this reactiveUtils integration to
|
|
261
|
+
* give you time to complete the migration and refactor the code.
|
|
262
|
+
*
|
|
263
|
+
* @deprecated Use this as a **temporary** workaround only.
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* import { disableReactiveUtilsIntegration } from "@arcgis/lumina";
|
|
267
|
+
* class MyComponent extends LitElement {
|
|
268
|
+
* // ...
|
|
269
|
+
* }
|
|
270
|
+
* disableReactiveUtilsIntegration(MyComponent);
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
export declare function disableReactiveUtilsIntegration(componentClass: typeof LitElement): void;
|
|
255
274
|
export {};
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ContextProvider, ContextConsumer } from "@lit/context";
|
|
2
|
+
import { r as retrieveComponent } from "./ControllerInternals-CWQrfEA8.js";
|
|
3
|
+
const useContextProvider = (options) => {
|
|
4
|
+
const component = retrieveComponent();
|
|
5
|
+
const controller = new ContextProvider(component.el, options);
|
|
6
|
+
component.addController(controller);
|
|
7
|
+
return controller;
|
|
8
|
+
};
|
|
9
|
+
const useContextConsumer = (options) => {
|
|
10
|
+
const component = retrieveComponent();
|
|
11
|
+
const controller = new ContextConsumer(component.el, options);
|
|
12
|
+
component.addController(controller);
|
|
13
|
+
return controller;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useContextConsumer,
|
|
17
|
+
useContextProvider
|
|
18
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Deferred } from '@arcgis/
|
|
1
|
+
import { Deferred } from '@arcgis/toolkit/promise';
|
|
2
2
|
import { BaseController, ControllerLifecycleMethods, controllerSymbol } from './types';
|
|
3
3
|
import { use, useRef, useRefSync } from './ControllerInternals';
|
|
4
4
|
import { PropertyValues } from 'lit';
|
|
@@ -8,8 +8,6 @@ import { LitElement } from '../LitElement';
|
|
|
8
8
|
* Defining controller using makeController() function is more succinct for smaller
|
|
9
9
|
* controllers. For controllers that need to declare several methods, or need
|
|
10
10
|
* more flexibility, this class may be used
|
|
11
|
-
*
|
|
12
|
-
* See ./examples.tsx for many example controllers and their usages.
|
|
13
11
|
*/
|
|
14
12
|
export declare abstract class Controller<Exports = never> implements BaseController {
|
|
15
13
|
#private;
|
|
@@ -42,7 +42,7 @@ type InferController<ControllerOrExports> = ControllerOrExports extends BaseCont
|
|
|
42
42
|
watchExports?: Controller["watchExports"];
|
|
43
43
|
} : Controller<ControllerOrExports>;
|
|
44
44
|
/**
|
|
45
|
-
* If controller never sets
|
|
45
|
+
* If controller never sets its exports, then its default exports is "this".
|
|
46
46
|
* This allows usage of controller.use with controllers that don't have exports
|
|
47
47
|
*/
|
|
48
48
|
type NotNever<T extends {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { isEsriInternalEnv } from "@arcgis/
|
|
2
|
-
import { r as retrieveComponent
|
|
1
|
+
import { isEsriInternalEnv } from "@arcgis/toolkit/error";
|
|
2
|
+
import { r as retrieveComponent } from "../../ControllerInternals-CWQrfEA8.js";
|
|
3
3
|
import { on, watch } from "@arcgis/core/core/reactiveUtils.js";
|
|
4
|
-
import {
|
|
4
|
+
import { a as createEventFactory, G as GenericController, d as trackPropKey, t as trackKey } from "../../Controller-ftAEcdmI.js";
|
|
5
|
+
import { p as proxyExports } from "../../proxyExports-D906TEtL.js";
|
|
5
6
|
import { createObservable, trackAccess } from "@arcgis/core/applications/Components/reactiveUtils.js";
|
|
6
7
|
import { property, subclass } from "@arcgis/core/core/accessorSupport/decorators.js";
|
|
7
8
|
import Accessor from "@arcgis/core/core/Accessor.js";
|
|
@@ -22,6 +23,7 @@ class AccessorController extends GenericController {
|
|
|
22
23
|
constructor(component, createInstance) {
|
|
23
24
|
super(component);
|
|
24
25
|
this.Y = /* @__PURE__ */ new Map();
|
|
26
|
+
this.A = void 0;
|
|
25
27
|
this.#exportsObservable = createObservable();
|
|
26
28
|
const that = this;
|
|
27
29
|
that.#createInstance = createInstance;
|
|
@@ -107,9 +109,12 @@ const makeBinderProxy = (component, accessorControllerRef, accessorControllerInd
|
|
|
107
109
|
) {
|
|
108
110
|
return value;
|
|
109
111
|
}
|
|
112
|
+
const accessorController = component.M[accessorControllerIndex];
|
|
113
|
+
accessorController.A = propertyName;
|
|
110
114
|
return trackKey(
|
|
111
115
|
component,
|
|
112
116
|
(resolved) => {
|
|
117
|
+
accessorController.A = void 0;
|
|
113
118
|
if (resolved !== void 0) {
|
|
114
119
|
const propName = resolved.key;
|
|
115
120
|
boundProperties.set(propertyName, propName);
|
|
@@ -120,15 +125,15 @@ const makeBinderProxy = (component, accessorControllerRef, accessorControllerInd
|
|
|
120
125
|
if (!(propertyName in instance)) {
|
|
121
126
|
throw new Error(`"${propertyName}" does not exist on the accessor instance`);
|
|
122
127
|
}
|
|
123
|
-
const
|
|
128
|
+
const accessorController2 = component.M[accessorControllerIndex];
|
|
124
129
|
if (descriptor.i !== void 0 && descriptor.i !== accessorControllerIndex) {
|
|
125
|
-
console.error(component.M[descriptor.i],
|
|
130
|
+
console.error(component.M[descriptor.i], accessorController2);
|
|
126
131
|
throw Error(
|
|
127
132
|
`Expected property "${propName}" to be bound to the controller at index ${descriptor.i}, but tried to bind it to a controller at index ${accessorControllerIndex}. Double check whether you are calling useAccessor() conditionally in a way that is not supported.`
|
|
128
133
|
);
|
|
129
134
|
}
|
|
130
|
-
if (
|
|
131
|
-
console.error(
|
|
135
|
+
if (accessorController2 !== accessorControllerRef.deref()) {
|
|
136
|
+
console.error(accessorController2);
|
|
132
137
|
throw Error(
|
|
133
138
|
`Expected controller at index ${accessorControllerIndex} to be instance of useAccessor but it is not.`
|
|
134
139
|
);
|
|
@@ -156,13 +161,6 @@ const makeBinderProxy = (component, accessorControllerRef, accessorControllerInd
|
|
|
156
161
|
},
|
|
157
162
|
value
|
|
158
163
|
);
|
|
159
|
-
},
|
|
160
|
-
set(_target, propertyName, newValue) {
|
|
161
|
-
if (boundProperties.has(propertyName) || // But some properties may be never bound, yet set in the constructor - let them through
|
|
162
|
-
newValue !== (instance[propertyName] ?? void 0)) {
|
|
163
|
-
instance[propertyName] = newValue;
|
|
164
|
-
}
|
|
165
|
-
return true;
|
|
166
164
|
}
|
|
167
165
|
});
|
|
168
166
|
const watchBoundProperty = (controllerRef, descriptor, propertyName, propName, shouldFlipBoolean, _handle) => _handle = watch(
|
|
@@ -199,7 +197,10 @@ const bindPropToProperty = (descriptor, accessorControllerIndex, propertyName, s
|
|
|
199
197
|
return shouldFlipBoolean ? !value : value;
|
|
200
198
|
};
|
|
201
199
|
descriptor.d.set = function(newValue) {
|
|
202
|
-
this.M[accessorControllerIndex]
|
|
200
|
+
const accessorController = this.M[accessorControllerIndex];
|
|
201
|
+
if (accessorController.A !== propertyName) {
|
|
202
|
+
accessorController.exports[propertyName] = shouldFlipBoolean ? !newValue : newValue;
|
|
203
|
+
}
|
|
203
204
|
};
|
|
204
205
|
};
|
|
205
206
|
const getAccessorControllerBoundProperties = (controller) => controller.Y;
|
|
@@ -212,10 +213,15 @@ const reCreateAccessor = (instance, component) => {
|
|
|
212
213
|
console.error("Unable to resolve the useAccessor controller from the provided value");
|
|
213
214
|
}
|
|
214
215
|
};
|
|
215
|
-
const createStore = (
|
|
216
|
+
const createStore = (initializer) => {
|
|
216
217
|
const SubClass = class extends Accessor {
|
|
217
218
|
};
|
|
218
|
-
|
|
219
|
+
const defaultValues = typeof initializer === "function" ? initializer() : initializer;
|
|
220
|
+
const descriptors = Object.getOwnPropertyDescriptors(defaultValues);
|
|
221
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
222
|
+
Object.defineProperty(SubClass.prototype, key, descriptor);
|
|
223
|
+
property()(SubClass.prototype, key);
|
|
224
|
+
}
|
|
219
225
|
const State = subclass()(SubClass);
|
|
220
226
|
return new State();
|
|
221
227
|
};
|
|
@@ -2,9 +2,9 @@ import { default as Accessor } from '@arcgis/core/core/Accessor.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* See https://qawebgis.esri.com/components/lumina/controllers/useAccessor#createstore-utility
|
|
4
4
|
*/
|
|
5
|
-
export declare const createStore: <T extends
|
|
5
|
+
export declare const createStore: <T extends object>(initializer: T | (() => T)) => __esri.Accessor & T;
|
|
6
6
|
/** @deprecated Use {@link createStore} instead */
|
|
7
|
-
export declare const createLegacyStore: <T extends
|
|
7
|
+
export declare const createLegacyStore: <T extends object>(defaultState: T | (() => T)) => ObservableMap<T>;
|
|
8
8
|
/** @deprecated Use {@link createStore} instead */
|
|
9
9
|
export type ObservableMap<T> = {
|
|
10
10
|
state: Accessor & T;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GenericController } from '../Controller';
|
|
2
2
|
import { LitElement } from '../../LitElement';
|
|
3
3
|
type Requires<Props, Accessor extends __esri.Accessor, OmitProps extends string = never> = LitElement & Omit<Pick<Accessor, keyof Accessor & keyof Props>, AlwaysOmit | OmitProps> & {
|
|
4
4
|
autoDestroyDisabled: boolean;
|
|
@@ -46,6 +46,8 @@ export declare class AccessorController<Props, Accessor extends __esri.Accessor,
|
|
|
46
46
|
* @private
|
|
47
47
|
*/
|
|
48
48
|
_boundAccessorProperties: Map<string & keyof Accessor, string>;
|
|
49
|
+
/** @private */
|
|
50
|
+
_currentlyBindingPropertyName?: string;
|
|
49
51
|
/**
|
|
50
52
|
* (development only) Allow these props to mismatch the name of the Accessor's
|
|
51
53
|
* property to avoid collisions
|
|
@@ -61,8 +63,11 @@ export declare class AccessorController<Props, Accessor extends __esri.Accessor,
|
|
|
61
63
|
hostConnected(): void;
|
|
62
64
|
hostDestroy(): void;
|
|
63
65
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
type MinimalAccessorController = Pick<AccessorController<never, __esri.Accessor>, "_currentlyBindingPropertyName" | "exports"> & {
|
|
67
|
+
component: LitElement;
|
|
68
|
+
};
|
|
69
|
+
export declare const makeBinderProxy: (component: LitElement, accessorControllerRef: WeakRef<MinimalAccessorController & {
|
|
70
|
+
constructor: MinimalAccessorController["constructor"] & {
|
|
66
71
|
devOnly$allowedPropNameMismatches?: ReadonlySet<string>;
|
|
67
72
|
};
|
|
68
73
|
}>, accessorControllerIndex: number, instance: __esri.Accessor, boundProperties: Map<string, string>) => unknown;
|
|
@@ -3,7 +3,7 @@ export type { GenericControllerType } from './Controller';
|
|
|
3
3
|
export { Controller, GenericController } from './Controller';
|
|
4
4
|
export type { ControllerManager } from './ControllerManager';
|
|
5
5
|
export { retrieveComponent, bypassSetter, bypassReadOnly } from './ControllerInternals';
|
|
6
|
-
export { trackPropertyKey,
|
|
6
|
+
export { trackPropertyKey, propertyTrackResolve } from './trackPropertyKey';
|
|
7
7
|
export { trackPropKey } from './trackPropKey';
|
|
8
8
|
export { trackKey } from './trackKey';
|
|
9
9
|
export { makeController, makeGenericController } from './functional';
|
|
@@ -22,3 +22,7 @@ export { isController, getControllersCount } from './utils';
|
|
|
22
22
|
* @deprecated import from "@arcgis/lumina" instead
|
|
23
23
|
*/
|
|
24
24
|
export type EventEmitter<T = undefined> = _EventEmitter<T>;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Let us know if someone is using this
|
|
27
|
+
*/
|
|
28
|
+
export declare const keyTrackResolve: () => void;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { C as Controller,
|
|
2
|
-
import { G,
|
|
3
|
-
import {
|
|
1
|
+
import { C as Controller, t as trackKey, a as createEventFactory, p as propertyTrackResolve } from "../Controller-ftAEcdmI.js";
|
|
2
|
+
import { G, d, b } from "../Controller-ftAEcdmI.js";
|
|
3
|
+
import { s as setAmbientComponent, i as isPromise, b as setParentController, d as retrieveParentControllers, r as retrieveComponent } from "../ControllerInternals-CWQrfEA8.js";
|
|
4
|
+
import { f, e, c, h, g } from "../ControllerInternals-CWQrfEA8.js";
|
|
5
|
+
import { p as proxyExports } from "../proxyExports-D906TEtL.js";
|
|
4
6
|
import { isServer } from "lit";
|
|
5
|
-
import {
|
|
7
|
+
import { isEsriInternalEnv } from "@arcgis/toolkit/error";
|
|
8
|
+
import { observeAncestorsMutation, getElementAttribute } from "@arcgis/toolkit/dom";
|
|
9
|
+
import { getElementLocale, startLocaleObserver } from "@arcgis/toolkit/intl";
|
|
6
10
|
const makeController = (constructor) => proxy(void 0, constructor);
|
|
7
11
|
const makeGenericController = (constructor) => (component) => proxy(
|
|
8
12
|
component,
|
|
9
13
|
/**
|
|
10
14
|
* GenericController is identical to Controller, in all except for typing.
|
|
11
|
-
* So
|
|
15
|
+
* So doing a type-cast here so as not to needlessly add one more object
|
|
12
16
|
* to the prototype chain
|
|
13
17
|
*/
|
|
14
18
|
constructor
|
|
@@ -127,7 +131,7 @@ const useDirection = () => makeController((component, controller) => {
|
|
|
127
131
|
(resolved) => {
|
|
128
132
|
if (resolved?.key === "dir") {
|
|
129
133
|
throw new Error(
|
|
130
|
-
|
|
134
|
+
"Do not assign this controller to a prop called `dir` as that will overwrite the HTMLElement's built-in `dir` attribute - component should not be setting the `dir` attribute on itself. Instead, assign this controller to a property called `direction`."
|
|
131
135
|
);
|
|
132
136
|
}
|
|
133
137
|
},
|
|
@@ -139,7 +143,7 @@ const useDirection = () => makeController((component, controller) => {
|
|
|
139
143
|
const makeT9nController = (getAssetPath) => (options = {}) => (
|
|
140
144
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
141
145
|
makeController((component, controller) => {
|
|
142
|
-
const locale =
|
|
146
|
+
const locale = getElementLocale(component.el);
|
|
143
147
|
const pending = { ["_lang"]: locale.lang, ["_t9nLocale"]: locale.t9nLocale, ["_loading"]: true };
|
|
144
148
|
const componentWithOverrides = component;
|
|
145
149
|
controller.onLifecycle(
|
|
@@ -244,25 +248,27 @@ const propertyChangeController = (...toWatch) => {
|
|
|
244
248
|
}
|
|
245
249
|
return eventEmitter;
|
|
246
250
|
};
|
|
251
|
+
const keyTrackResolve = propertyTrackResolve;
|
|
247
252
|
export {
|
|
248
253
|
Controller,
|
|
249
254
|
G as GenericController,
|
|
250
|
-
|
|
251
|
-
|
|
255
|
+
f as bypassReadOnly,
|
|
256
|
+
e as bypassSetter,
|
|
252
257
|
c as controllerSymbol,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
258
|
+
h as getControllersCount,
|
|
259
|
+
g as isController,
|
|
260
|
+
keyTrackResolve,
|
|
256
261
|
load,
|
|
257
262
|
makeController,
|
|
258
263
|
makeGenericController,
|
|
259
264
|
makeT9nController,
|
|
265
|
+
propertyTrackResolve,
|
|
260
266
|
proxyExports,
|
|
261
267
|
retrieveComponent,
|
|
262
268
|
toFunction,
|
|
263
269
|
trackKey,
|
|
264
|
-
|
|
265
|
-
|
|
270
|
+
d as trackPropKey,
|
|
271
|
+
b as trackPropertyKey,
|
|
266
272
|
useDirection,
|
|
267
273
|
useMedia,
|
|
268
274
|
usePropertyChange,
|
|
@@ -26,4 +26,4 @@ export declare const trackPropertyKey: <T>(object: BaseController | LitElement,
|
|
|
26
26
|
* property you are trying to resolve had it's default value set, thus after
|
|
27
27
|
* constructor. At the start of connectedCallback is a perfect place.
|
|
28
28
|
*/
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const propertyTrackResolve: () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHandle } from '@arcgis/
|
|
1
|
+
import { IHandle } from '@arcgis/toolkit/type';
|
|
2
2
|
import { ReactiveControllerHost, ReactiveController, PropertyDeclaration, PropertyValues } from 'lit';
|
|
3
3
|
import { LitElement } from '../LitElement';
|
|
4
4
|
export type TrackKeyResolution = {
|