@arcgis/lumina 4.34.0-next.39 → 4.34.0-next.40

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.
@@ -1,121 +1,6 @@
1
- import { isEsriInternalEnv, safeCall, Deferred, safeAsyncCall } from "@arcgis/components-utils";
1
+ import { safeCall, isEsriInternalEnv, Deferred, safeAsyncCall } from "@arcgis/components-utils";
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-DOZNgCJl.js";
2
3
  import { nothing } from "lit";
3
- const controllerSymbol = Symbol.for("controller");
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;
119
4
  const trackPropertyKey = (object, onResolved, defaultValue) => {
120
5
  const keys = Object.keys(object);
121
6
  const keyCount = keys.length;
@@ -566,22 +451,10 @@ const accessBeforeLoad = process.env.NODE_ENV !== "production" && isEsriInternal
566
451
  export {
567
452
  Controller as C,
568
453
  GenericController as G,
569
- shouldBypassReadOnly as a,
570
- createEvent as b,
571
- controllerSymbol as c,
572
- setParentController as d,
573
- retrieveParentControllers as e,
574
- createEventFactory as f,
575
- bypassSetter as g,
576
- bypassReadOnly as h,
577
- isPromise as i,
578
- trackPropertyKey as j,
454
+ createEventFactory as a,
455
+ trackPropertyKey as b,
456
+ createEvent as c,
457
+ trackPropKey as d,
579
458
  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,
586
459
  trackKey as t
587
460
  };
@@ -0,0 +1,134 @@
1
+ import { isEsriInternalEnv } from "@arcgis/components-utils";
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. If so, ",
24
+ "please wrap your controller definition in an arrow function (like",
25
+ "`const myController = ()=>makeController(...);`) and call that",
26
+ "function inside the component (`my = myController();`), or ",
27
+ "define your controller using makeGenericController/GenericController ",
28
+ "instead.\n",
29
+ "- You tried to create a controller inside an async function. ",
30
+ "This is allowed without calling controller.use(). Make sure you ",
31
+ "use it like `await controller.use(useController())`."
32
+ ] : []
33
+ ].join("")
34
+ );
35
+ }
36
+ return ambientComponent;
37
+ };
38
+ let ambientControllers = [];
39
+ const setParentController = (controller) => {
40
+ if (controller === void 0) {
41
+ ambientControllers = [];
42
+ return;
43
+ }
44
+ const index = ambientControllers.indexOf(controller);
45
+ ambientControllers = index === -1 ? [...ambientControllers, controller] : ambientControllers.slice(0, index + 1);
46
+ queueMicrotask(() => ambientControllers = []);
47
+ };
48
+ const retrieveParentControllers = () => ambientControllers;
49
+ let ambientChildController;
50
+ const setAmbientChildController = (controller) => {
51
+ if (ambientChildController === controller) {
52
+ return;
53
+ }
54
+ ambientChildController = controller;
55
+ queueMicrotask(() => ambientChildController === controller ? ambientChildController = void 0 : 0);
56
+ };
57
+ const retrieveAmbientChildController = () => {
58
+ const controller = ambientChildController;
59
+ ambientChildController = void 0;
60
+ return controller;
61
+ };
62
+ const use = async (value, watchExports) => {
63
+ const controller = useRefSync(value);
64
+ if (controller === void 0) {
65
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && typeof watchExports === "function") {
66
+ throw new Error(
67
+ `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`
68
+ );
69
+ }
70
+ return value;
71
+ }
72
+ await controller.ready;
73
+ if (typeof watchExports === "function") {
74
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && controller.watchExports === void 0) {
75
+ throw new Error(`The controller must implement watchExports method to support watching exports`);
76
+ }
77
+ const unsubscribe = controller.watchExports(
78
+ (exports) => watchExports(exports, unsubscribe)
79
+ );
80
+ }
81
+ return controller.exports;
82
+ };
83
+ const useRef = async (value) => {
84
+ const controller = useRefSync(value);
85
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && controller === void 0) {
86
+ throw new Error(
87
+ `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`
88
+ );
89
+ }
90
+ await controller.ready;
91
+ return controller;
92
+ };
93
+ const useRefSync = (value) => {
94
+ const component = retrieveComponent();
95
+ const controller = component.manager.X(value);
96
+ if (controller !== void 0) {
97
+ return controller;
98
+ }
99
+ if (isController(value)) {
100
+ return value;
101
+ }
102
+ const ambientChildController2 = retrieveAmbientChildController();
103
+ if (ambientChildController2 !== void 0) {
104
+ return ambientChildController2;
105
+ }
106
+ return void 0;
107
+ };
108
+ let shouldBypassReadOnly = false;
109
+ const bypassReadOnly = (callback) => {
110
+ shouldBypassReadOnly = true;
111
+ try {
112
+ return callback();
113
+ } finally {
114
+ shouldBypassReadOnly = false;
115
+ }
116
+ };
117
+ const bypassSetter = bypassReadOnly;
118
+ export {
119
+ shouldBypassReadOnly as a,
120
+ setParentController as b,
121
+ controllerSymbol as c,
122
+ retrieveParentControllers as d,
123
+ bypassSetter as e,
124
+ bypassReadOnly as f,
125
+ isController as g,
126
+ getControllersCount as h,
127
+ isPromise as i,
128
+ setAmbientChildController as j,
129
+ useRef as k,
130
+ useRefSync as l,
131
+ retrieveComponent as r,
132
+ setAmbientComponent as s,
133
+ use as u
134
+ };
@@ -0,0 +1,18 @@
1
+ import { ContextProvider, ContextConsumer } from "@lit/context";
2
+ import { r as retrieveComponent } from "./ControllerInternals-DOZNgCJl.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,7 +1,8 @@
1
1
  import { isEsriInternalEnv } from "@arcgis/components-utils";
2
- import { r as retrieveComponent, f as createEventFactory, G as GenericController, l as trackPropKey, t as trackKey } from "../../Controller-BQOv8BAL.js";
2
+ import { r as retrieveComponent } from "../../ControllerInternals-DOZNgCJl.js";
3
3
  import { on, watch } from "@arcgis/core/core/reactiveUtils.js";
4
- import { p as proxyExports } from "../../proxyExports-Cdzj7WL_.js";
4
+ import { a as createEventFactory, G as GenericController, d as trackPropKey, t as trackKey } from "../../Controller-6vd9TSNE.js";
5
+ import { p as proxyExports } from "../../proxyExports-BgcDxXBO.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";
@@ -1,6 +1,8 @@
1
- import { C as Controller, s as setAmbientComponent, i as isPromise, d as setParentController, e as retrieveParentControllers, t as trackKey, r as retrieveComponent, f as createEventFactory } from "../Controller-BQOv8BAL.js";
2
- import { G, h, g, c, n, m, k, l, j } from "../Controller-BQOv8BAL.js";
3
- import { p as proxyExports } from "../proxyExports-Cdzj7WL_.js";
1
+ import { C as Controller, t as trackKey, a as createEventFactory } from "../Controller-6vd9TSNE.js";
2
+ import { G, k, d, b } from "../Controller-6vd9TSNE.js";
3
+ import { s as setAmbientComponent, i as isPromise, b as setParentController, d as retrieveParentControllers, r as retrieveComponent } from "../ControllerInternals-DOZNgCJl.js";
4
+ import { f, e, c, h, g } from "../ControllerInternals-DOZNgCJl.js";
5
+ import { p as proxyExports } from "../proxyExports-BgcDxXBO.js";
4
6
  import { isServer } from "lit";
5
7
  import { observeAncestorsMutation, isEsriInternalEnv, getElementAttribute, getElementLocales, startLocaleObserver } from "@arcgis/components-utils";
6
8
  const makeController = (constructor) => proxy(void 0, constructor);
@@ -247,11 +249,11 @@ const propertyChangeController = (...toWatch) => {
247
249
  export {
248
250
  Controller,
249
251
  G as GenericController,
250
- h as bypassReadOnly,
251
- g as bypassSetter,
252
+ f as bypassReadOnly,
253
+ e as bypassSetter,
252
254
  c as controllerSymbol,
253
- n as getControllersCount,
254
- m as isController,
255
+ h as getControllersCount,
256
+ g as isController,
255
257
  k as keyTrackResolve,
256
258
  load,
257
259
  makeController,
@@ -261,8 +263,8 @@ export {
261
263
  retrieveComponent,
262
264
  toFunction,
263
265
  trackKey,
264
- l as trackPropKey,
265
- j as trackPropertyKey,
266
+ d as trackPropKey,
267
+ b as trackPropertyKey,
266
268
  useDirection,
267
269
  useMedia,
268
270
  usePropertyChange,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { useContextProvider, useContextConsumer } from './context';
1
+ import { useContextProvider as useContextProviderImplementation, useContextConsumer as useContextConsumerImplementation } from './context';
2
2
  export type { EventEmitter, EventOptions } from './createEvent';
3
3
  export { createEvent } from './createEvent';
4
4
  export { state, property, method } from './decorators';
@@ -15,3 +15,11 @@ export { nothing, noChange, setAttribute, stringOrBoolean } from './jsx/utils';
15
15
  export { noShadowRoot, devOnly$getLitElementTagNameAndRuntime } from './utils';
16
16
  export { makeReactWrapperFactory, getReactWrapperOptions } from './wrappersUtils';
17
17
  export { renderElement } from './render';
18
+ /**
19
+ * @deprecated Use `useContextProvider` from `@arcgis/lumina/context` instead.
20
+ */
21
+ export declare const useContextProvider: typeof useContextProviderImplementation;
22
+ /**
23
+ * @deprecated Use `useContextConsumer` from `@arcgis/lumina/context` instead.
24
+ */
25
+ export declare const useContextConsumer: typeof useContextConsumerImplementation;
package/dist/index.js CHANGED
@@ -1,30 +1,19 @@
1
- import { ContextProvider, ContextConsumer } from "@lit/context";
2
- import { r as retrieveComponent, G as GenericController, k as keyTrackResolve, s as setAmbientComponent, c as controllerSymbol, a as shouldBypassReadOnly } from "./Controller-BQOv8BAL.js";
3
- import { b } from "./Controller-BQOv8BAL.js";
1
+ import { G as GenericController, k as keyTrackResolve } from "./Controller-6vd9TSNE.js";
2
+ import { c } from "./Controller-6vd9TSNE.js";
4
3
  import { state } from "@lit/reactive-element/decorators/state.js";
5
4
  import { property as property$1 } from "@lit/reactive-element/decorators/property.js";
6
5
  import { e as emptyFunction, n as noShadowRoot, a as attachToAncestor } from "./lazyLoad-DUvrNd2L.js";
7
6
  import { d, m } from "./lazyLoad-DUvrNd2L.js";
8
7
  import { isEsriInternalEnv, safeCall, devToolsAwareTimeout, Deferred, camelToKebab, safeAsyncCall } from "@arcgis/components-utils";
9
8
  import { nothing as nothing$1, LitElement as LitElement$1, isServer, notEqual, noChange as noChange$1 } from "lit";
9
+ import { s as setAmbientComponent, c as controllerSymbol, a as shouldBypassReadOnly } from "./ControllerInternals-DOZNgCJl.js";
10
10
  import { propertyFlagAttribute, propertyFlagNoAccessor, propertyFlagReadOnly, propertyFlagState, propertyFlagBoolean, propertyFlagNumber, propertyFlagReflect } from "./config.js";
11
11
  import { classMap } from "lit-html/directives/class-map.js";
12
12
  import { styleMap } from "lit/directives/style-map.js";
13
13
  import { directive as directive$1, Directive } from "lit-html/directive.js";
14
14
  import { live as live$1 } from "lit-html/directives/live.js";
15
15
  import { nothing as nothing$2, noChange as noChange$2, render } from "lit-html";
16
- const useContextProvider = (options) => {
17
- const component = retrieveComponent();
18
- const controller = new ContextProvider(component.el, options);
19
- component.addController(controller);
20
- return controller;
21
- };
22
- const useContextConsumer = (options) => {
23
- const component = retrieveComponent();
24
- const controller = new ContextConsumer(component.el, options);
25
- component.addController(controller);
26
- return controller;
27
- };
16
+ import { useContextProvider as useContextProvider$1, useContextConsumer as useContextConsumer$1 } from "./context.js";
28
17
  const property = property$1;
29
18
  const method = void 0;
30
19
  class ControllerManager extends GenericController {
@@ -655,6 +644,8 @@ const renderElement = (element) => {
655
644
  render(element, container);
656
645
  return container.firstElementChild;
657
646
  };
647
+ const useContextProvider = useContextProvider$1;
648
+ const useContextConsumer = useContextConsumer$1;
658
649
  export {
659
650
  Fragment,
660
651
  LitElement,
@@ -662,7 +653,7 @@ export {
662
653
  bindBooleanAttribute,
663
654
  bindEvent,
664
655
  bindProperty,
665
- b as createEvent,
656
+ c as createEvent,
666
657
  deferLoad,
667
658
  deferredLoaders,
668
659
  d as devOnly$getLitElementTagNameAndRuntime,
@@ -1,4 +1,5 @@
1
- import { d as setParentController, e as retrieveParentControllers, o as setAmbientChildController, t as trackKey, h as bypassReadOnly } from "./Controller-BQOv8BAL.js";
1
+ import { b as setParentController, d as retrieveParentControllers, j as setAmbientChildController, f as bypassReadOnly } from "./ControllerInternals-DOZNgCJl.js";
2
+ import { t as trackKey } from "./Controller-6vd9TSNE.js";
2
3
  const proxyExports = (Class) => (...args) => {
3
4
  const ambientControllers = retrieveParentControllers();
4
5
  const instance = new Class(...args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/lumina",
3
- "version": "4.34.0-next.39",
3
+ "version": "4.34.0-next.40",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -8,6 +8,7 @@
8
8
  "exports": {
9
9
  ".": "./dist/index.js",
10
10
  "./config": "./dist/config.js",
11
+ "./context": "./dist/context.js",
11
12
  "./hmrSupport": "./dist/hmrSupport.js",
12
13
  "./stencilSsrCompatibility": "./dist/stencilSsrCompatibility/index.js",
13
14
  "./typings": {
@@ -22,7 +23,7 @@
22
23
  ],
23
24
  "license": "SEE LICENSE IN LICENSE.md",
24
25
  "dependencies": {
25
- "@arcgis/components-utils": "4.34.0-next.39",
26
+ "@arcgis/components-utils": "4.34.0-next.40",
26
27
  "@lit-labs/ssr": "^3.2.2",
27
28
  "@lit-labs/ssr-client": "^1.1.7",
28
29
  "@lit/context": "^1.1.5",