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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/ControllerManager-B2comd8J.js +310 -0
  2. package/dist/LitElement.d.ts +3 -3
  3. package/dist/context.d.ts +1 -1
  4. package/dist/controllers/ComponentInternals.d.ts +92 -0
  5. package/dist/controllers/Controller.d.ts +152 -0
  6. package/dist/controllers/ControllerInternals.d.ts +52 -0
  7. package/dist/controllers/ControllerManager.d.ts +63 -0
  8. package/dist/controllers/accessor/index.d.ts +2 -0
  9. package/dist/controllers/accessor/index.js +1045 -0
  10. package/dist/controllers/accessor/reEmitEvent.d.ts +14 -0
  11. package/dist/controllers/accessor/useAccessor.d.ts +75 -0
  12. package/dist/controllers/framework.d.ts +45 -0
  13. package/dist/controllers/functional.d.ts +19 -0
  14. package/dist/controllers/getSet.d.ts +116 -0
  15. package/dist/controllers/index.d.ts +23 -0
  16. package/dist/controllers/index.js +283 -0
  17. package/dist/controllers/load.d.ts +6 -0
  18. package/dist/controllers/proxyExports.d.ts +27 -0
  19. package/dist/controllers/readonly.d.ts +29 -0
  20. package/dist/controllers/tests/autoDestroyMock.d.ts +5 -0
  21. package/dist/controllers/tests/utils.d.ts +1 -0
  22. package/dist/controllers/toFunction.d.ts +8 -0
  23. package/dist/controllers/trackKey.d.ts +8 -0
  24. package/dist/controllers/trackPropKey.d.ts +21 -0
  25. package/dist/controllers/trackPropertyKey.d.ts +28 -0
  26. package/dist/controllers/types.d.ts +182 -0
  27. package/dist/controllers/useDirection.d.ts +11 -0
  28. package/dist/controllers/useMedia.d.ts +8 -0
  29. package/dist/controllers/usePropertyChange.d.ts +11 -0
  30. package/dist/controllers/useT9n.d.ts +48 -0
  31. package/dist/controllers/useWatch.d.ts +27 -0
  32. package/dist/controllers/useWatchAttributes.d.ts +7 -0
  33. package/dist/controllers/utils.d.ts +15 -0
  34. package/dist/createEvent.d.ts +1 -1
  35. package/dist/decorators.d.ts +1 -1
  36. package/dist/index.d.ts +2 -2
  37. package/dist/index.js +5 -42
  38. package/dist/lazyLoad.d.ts +2 -2
  39. package/dist/makeRuntime.d.ts +109 -0
  40. package/dist/proxyExports-Dl5CHmHQ.js +150 -0
  41. package/dist/runtime.d.ts +4 -107
  42. package/dist/useWatch-CFtSpNnN.js +925 -0
  43. package/package.json +4 -3
@@ -0,0 +1,150 @@
1
+ import { r as retrieveComponent, f as trackPropKey, o as devOnlyGetPersistentControllerData, p as shouldBypass, a as setParentController, b as retrieveParentControllers, q as setAmbientChildController, t as trackKey, w as watch } from "./useWatch-CFtSpNnN.js";
2
+ import { isEsriInternalEnv } from "@arcgis/components-utils";
3
+ function getSet(defaultValue, getSet2) {
4
+ const component = retrieveComponent();
5
+ return trackPropKey(
6
+ component,
7
+ (rawName) => {
8
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && rawName === void 0) {
9
+ throw new Error(
10
+ "Unable to resolve get/set's prop name. Make sure you are using it like @Prop() someProp = getSet(defaultValue,{get,set})"
11
+ );
12
+ }
13
+ const name = rawName;
14
+ const manager = component.manager;
15
+ const genericComponent = component;
16
+ const value = genericComponent[name];
17
+ const isStencilHotReload = process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !manager.isLit && devOnlyGetPersistentControllerData?.(manager) === true;
18
+ if (value != null && value !== defaultValue && typeof getSet2.set === "function" && !isStencilHotReload) {
19
+ const newValue = getSet2.set(value, defaultValue, name);
20
+ if (newValue !== value) {
21
+ if (manager.isLit) {
22
+ genericComponent[name] = newValue;
23
+ } else {
24
+ let firstConnected = true;
25
+ manager.onConnected(() => {
26
+ if (!firstConnected) {
27
+ return;
28
+ }
29
+ firstConnected = true;
30
+ bypassSetter(() => {
31
+ genericComponent[name] = newValue;
32
+ });
33
+ });
34
+ }
35
+ }
36
+ }
37
+ genericGetSet(component, name, getSet2);
38
+ },
39
+ defaultValue
40
+ );
41
+ }
42
+ const dynamicGetSet = (component, property, getSet2) => genericGetSet(component, property, getSet2);
43
+ function bypassSetter(callback) {
44
+ shouldBypass.setter = true;
45
+ try {
46
+ return callback();
47
+ } finally {
48
+ shouldBypass.setter = false;
49
+ }
50
+ }
51
+ function bypassGetter(callback) {
52
+ shouldBypass.getter = true;
53
+ try {
54
+ return callback();
55
+ } finally {
56
+ shouldBypass.getter = false;
57
+ }
58
+ }
59
+ function genericGetSet(component, property, getSet2) {
60
+ const genericGetSet2 = getSet2;
61
+ const internals = component.manager.internals;
62
+ const get = typeof genericGetSet2.get === "function" ? genericGetSet2.get : void 0;
63
+ if (get) {
64
+ internals.getters[property] ??= [];
65
+ internals.getters[property].unshift(get);
66
+ }
67
+ const set = genericGetSet2.set === "ignore" ? ignoreSet : genericGetSet2.set;
68
+ if (set) {
69
+ internals.setters[property] ??= [];
70
+ internals.setters[property].unshift(
71
+ set
72
+ );
73
+ }
74
+ }
75
+ const ignoreSet = (_, value) => value;
76
+ function readonly(value) {
77
+ const component = retrieveComponent();
78
+ return getSet(value, { set: component.manager.internals.readonlySetter });
79
+ }
80
+ function bypassReadOnly(callback) {
81
+ shouldBypass.readOnly = true;
82
+ try {
83
+ return callback();
84
+ } finally {
85
+ shouldBypass.readOnly = false;
86
+ }
87
+ }
88
+ const proxyExports = (Class) => (...args) => {
89
+ const ambientControllers = retrieveParentControllers();
90
+ const instance = new Class(...args);
91
+ const initialExports = instance.exports;
92
+ setParentController(ambientControllers.at(-1));
93
+ const internals = instance.component.manager.internals;
94
+ internals.markExports(instance, initialExports);
95
+ instance.watchExports((exports) => internals.markExports(instance, exports));
96
+ setAmbientChildController(instance);
97
+ const hostCandidates = [instance.component, ...ambientControllers].reverse();
98
+ return trackKey(
99
+ hostCandidates,
100
+ (resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution, initialExports),
101
+ initialExports
102
+ );
103
+ };
104
+ function setProxy(controller, { host, key, isReactive: assignedToProp }, initialExports) {
105
+ const genericHost = host;
106
+ const controllerValueChanged = genericHost[key] !== controller.exports;
107
+ const hostValueChanged = genericHost[key] !== initialExports;
108
+ const controllerUpdatedExports = initialExports !== controller.exports;
109
+ if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports) {
110
+ genericHost[key] = controller.exports;
111
+ }
112
+ const isProxyExportsOnComponent = host === controller.component;
113
+ if (isProxyExportsOnComponent) {
114
+ if (assignedToProp) {
115
+ const internals = controller.component.manager.internals;
116
+ if (hostValueChanged) {
117
+ internals.markExports(controller, genericHost[key]);
118
+ }
119
+ watch(controller.component, key, (value) => {
120
+ if (value !== controller.exports) {
121
+ internals.markExports(controller, value);
122
+ }
123
+ });
124
+ }
125
+ controller.assignedProperty = assignedToProp ? void 0 : key;
126
+ }
127
+ controller.watchExports(() => {
128
+ if (genericHost[key] === controller.exports) {
129
+ return;
130
+ }
131
+ const manager = controller.component.manager;
132
+ const isReadOnly = manager.internals.setters[key]?.includes(manager.internals.readonlySetter);
133
+ if (isReadOnly) {
134
+ bypassReadOnly(() => {
135
+ genericHost[key] = controller.exports;
136
+ });
137
+ } else {
138
+ genericHost[key] = controller.exports;
139
+ }
140
+ });
141
+ }
142
+ export {
143
+ bypassGetter as a,
144
+ bypassReadOnly as b,
145
+ bypassSetter as c,
146
+ dynamicGetSet as d,
147
+ getSet as g,
148
+ proxyExports as p,
149
+ readonly as r
150
+ };
package/dist/runtime.d.ts CHANGED
@@ -1,109 +1,6 @@
1
- import { CSSResult } from 'lit';
2
- import { LitElement } from './LitElement';
1
+ export declare const runtime: import('./makeRuntime').Runtime;
3
2
  /**
4
- * `@arcgis/lumina` package may be bundled once but used by multiple packages with
5
- * different configuration options. For that reason, the configuration options
6
- * cannot be a global object, but has to be an object that you pass around.
3
+ * "customElement" needs to be exported - it will be used by the build system.
4
+ * You should not call it directly.
7
5
  */
8
- export type Runtime = RuntimeOptions & {
9
- /**
10
- * Get the base path to where the package assets can be found.
11
- * By default, the package asset path is set to `https://js.arcgis.com/<simplified-package-name>/<released-verion>/`.
12
- * We are hosting our assets on a CDN (Content Delivery Network) to ensure fast and reliable access.
13
- * It is CORS-enabled, so you can load the assets from any domain.
14
- * Use "setAssetPath(path)" if the path needs to be customized.
15
- */
16
- readonly getAssetPath: (suffix: string) => string;
17
- /**
18
- * Used to manually set the base path where package assets (like localization
19
- * and icons) can be found.
20
- *
21
- * By default, the package asset path is set to `https://js.arcgis.com/<simplified-package-name>/<released-verion>/`.
22
- * For example, `https://js.arcgis.com/map-components/4.30/`.
23
- * We are hosting our assets on a CDN (Content Delivery Network) to ensure fast and reliable access.
24
- * It is CORS-enabled, so you can load the assets from any domain.
25
- * This is the recommended way to load the assets and avoid bundling them with your application.
26
- * It means that by default, you don't need to use "setAssetPath" since the path is already set.
27
- *
28
- * However, if you need to host the assets locally, you can use "setAssetPath" to set the base path.
29
- * If the script is used as "module", it's recommended to use "import.meta.url",
30
- * such as "setAssetPath(import.meta.url)". Other options include
31
- * "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
32
- * dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
33
- * But do note that this configuration depends on how your script is bundled, or lack of
34
- * bundling, and where your assets can be loaded from. Additionally custom bundling
35
- * will have to ensure the static assets are copied to its build directory.
36
- */
37
- readonly setAssetPath: (path: URL | string) => void;
38
- /**
39
- * The customElement decorator. Unlike default Lit's decorator this one
40
- * provides runtime instance to the LitElement class
41
- *
42
- * @remarks
43
- * You do not need to call this decorator in your component.
44
- * It will be added automatically at build time.
45
- *
46
- * Instead, make sure your component file has the following:
47
- * ```ts
48
- * declare global {
49
- * interface DeclareElements {
50
- * "arcgis-your-component": ArcgisYourComponent;
51
- * }
52
- * }
53
- * ```
54
- */
55
- readonly customElement: (tagName: string, component: typeof LitElement) => void;
56
- };
57
- export type RuntimeOptions = {
58
- /**
59
- * The default asset path to use in NPM and CDN builds.
60
- *
61
- * This option will be set by Lumina compiler based on the value of the
62
- * `assets.defaultPath` option in the `useLumina()` plugin.
63
- */
64
- readonly defaultAssetPath: string;
65
- /**
66
- * The attribute that indicates a component has rendered it's content.
67
- * Usually this attribute is added after your component's `loaded()` lifecycle
68
- * happened. However, during SSR, "hydrated" is added right away on the
69
- * server.
70
- *
71
- * Until element has this attribute, it will have `visibility:hidden` style
72
- * applied.
73
- *
74
- * This option will be set by the Lumina compiler based on the value of
75
- * the `css.hydratedAttribute` option in the `useLumina()` plugin.
76
- */
77
- readonly hydratedAttribute: string;
78
- /**
79
- * Styles that you wish to make available in each component's shadow root, but
80
- * to not apply outside the shadow root
81
- *
82
- * This option will be set by Lumina compiler based on the value of the
83
- * `css.commonStylesPath` option in the `useLumina()` plugin.
84
- */
85
- readonly commonStyles?: CSSResult;
86
- };
87
- /**
88
- * The options object will be provided by Lumina compiler at build-time.
89
- * It should not be specified in the source code.
90
- */
91
- export declare function makeRuntime(options?: RuntimeOptions): Runtime;
92
- /**
93
- * Exposing the reference to the runtime globally when in tests or development.
94
- * This is primarily for usage by dynamically created components in tests
95
- *
96
- * @private
97
- */
98
- export type DevOnlyGlobalRuntime = typeof globalThis & {
99
- devOnly$luminaRuntime?: Runtime;
100
- };
101
- /**
102
- * Called from the component constructor when in development or test mode.
103
- * Used primarily by mount to get a reference to the rendered component.
104
- *
105
- * @private
106
- */
107
- export type DevOnlyGlobalComponentRefCallback = typeof globalThis & {
108
- devOnly$luminaComponentRefCallback?: (component: LitElement) => void;
109
- };
6
+ export declare const customElement: (tagName: string, component: typeof import('./LitElement').LitElement) => void;