@arcgis/lumina 4.33.0-next.94 → 4.33.0-next.96
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 +307 -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,48 @@
|
|
|
1
|
+
import { GenericT9nStrings, LocaleObserver } from '@arcgis/components-utils';
|
|
2
|
+
export type T9nMeta<T9nStrings extends GenericT9nStrings> = {
|
|
3
|
+
_lang: LocaleObserver["lang"];
|
|
4
|
+
_t9nLocale: LocaleObserver["t9nLocale"];
|
|
5
|
+
_loading: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The "_overrides" property won't actually exist at runtime and exists only
|
|
8
|
+
* to simplify typing like so:
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Type of the messageOverrides is set automatically based on _overrides:
|
|
13
|
+
* @Prop() messageOverrides?: typeof this.messages._overrides;
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
_overrides: DeepPartial<T9nStrings>;
|
|
17
|
+
/**
|
|
18
|
+
* If messageOverrides are in effect, this will contain original strings
|
|
19
|
+
*/
|
|
20
|
+
_original?: T9nStrings;
|
|
21
|
+
};
|
|
22
|
+
type DeepPartial<T> = T extends object ? {
|
|
23
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
24
|
+
} : T;
|
|
25
|
+
type Options = {
|
|
26
|
+
readonly name?: string | null;
|
|
27
|
+
/** @default false */
|
|
28
|
+
readonly blocking?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export interface UseT9n {
|
|
31
|
+
<Strings extends GenericT9nStrings>(options: Options & {
|
|
32
|
+
readonly blocking: true;
|
|
33
|
+
}): Strings & T9nMeta<Strings>;
|
|
34
|
+
<Strings extends GenericT9nStrings>(options?: Options & {
|
|
35
|
+
readonly blocking?: false;
|
|
36
|
+
}): Partial<Strings> & T9nMeta<Strings>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Load component's localization strings.
|
|
40
|
+
*
|
|
41
|
+
* Documentation: https://qawebgis.esri.com/components/lumina/controllers/useT9n
|
|
42
|
+
*
|
|
43
|
+
* Design decisions:
|
|
44
|
+
* - https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/969
|
|
45
|
+
* - https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/987
|
|
46
|
+
*/
|
|
47
|
+
export declare const makeT9nController: (getAssetPath: (path: string) => string) => UseT9n;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseComponent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Dynamically set a watcher for any reactive property
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* this.manager.onLifecycle(()=>
|
|
8
|
+
* watch(this, "myProp", (newValue,oldValue)=>console.log(newValue,oldValue))
|
|
9
|
+
* )
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* If you are in Lit, you should prefer the willUpdate() lifecycle method
|
|
14
|
+
* over watch(). willUpdate() is going to be more memory-efficient, and more
|
|
15
|
+
* flexible (can watch multiple props at once or provide dynamic prop name)
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* willUpdate(changes: PropertyValues<this>) {
|
|
19
|
+
* if (changes.has('firstName') || changes.has('lastName')) {
|
|
20
|
+
* this.sha = computeSHA(`${this.firstName} ${this.lastName}`);
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @deprecated see https://qawebgis.esri.com/components/lumina/lifecycle#willupdate and https://qawebgis.esri.com/components/lumina/controllers/lifecycle
|
|
26
|
+
*/
|
|
27
|
+
export declare function watch<Component extends BaseComponent, Property extends keyof Component>(component: Component, property: Property, callback: (newValue: Component[Property], oldValue: Component[Property], property: Property) => void): () => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Controller } from './Controller';
|
|
2
|
+
/**
|
|
3
|
+
* Watch when given attributes change on the component element.
|
|
4
|
+
*
|
|
5
|
+
* Documentation: https://qawebgis.esri.com/components/lumina/controllers/useWatchAttributes
|
|
6
|
+
*/
|
|
7
|
+
export declare const useWatchAttributes: <T extends string>(attributes: readonly T[], callback: (newValue: string | null, oldValue: string | null, attribute: T) => void) => Controller;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Controller } from './Controller';
|
|
2
|
+
import { ControllerLifecycleMethods } from './types';
|
|
3
|
+
export declare const isController: (value: unknown) => value is ControllerLifecycleMethods;
|
|
4
|
+
/**
|
|
5
|
+
* In development, on hot module reload, controller would be re-initialized
|
|
6
|
+
* with all Props and State values persistent, but properties lost. This unsafe
|
|
7
|
+
* development-only API lets you set or get data for a controller that would
|
|
8
|
+
* persist across hot reloads.
|
|
9
|
+
*/
|
|
10
|
+
export declare const devOnlySetPersistentControllerData: ((controller: Controller<unknown>, data: unknown) => void) | undefined;
|
|
11
|
+
export declare const devOnlyGetPersistentControllerData: (<T>(controller: Controller<unknown>) => T | undefined) | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the argument is a promise by checking if it has a `then` method.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isPromise<T>(arg: Promise<T> | T): arg is Promise<T>;
|
package/dist/createEvent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseComponent, EventEmitter } from '
|
|
1
|
+
import { BaseComponent, EventEmitter } from './controllers/types';
|
|
2
2
|
/**
|
|
3
3
|
* While these defaults don't match DOM defaults (all false), they match
|
|
4
4
|
* Stencil and Shoelace defaults. Also, they make more sense for our
|
package/dist/decorators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LuminaPropertyDeclaration } from '
|
|
1
|
+
import { LuminaPropertyDeclaration } from './controllers/types';
|
|
2
2
|
export { state } from '@lit/reactive-element/decorators/state.js';
|
|
3
3
|
/**
|
|
4
4
|
* A class field or accessor decorator which creates a reactive property that
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export type { DefineCustomElements, LazyLoadOptions, GlobalThisWithPuppeteerEnv
|
|
|
6
6
|
export { makeDefineCustomElements } from './lazyLoad';
|
|
7
7
|
export { LitElement } from './LitElement';
|
|
8
8
|
export type { PublicLitElement } from './PublicLitElement';
|
|
9
|
-
export type { Runtime, RuntimeOptions, DevOnlyGlobalRuntime, DevOnlyGlobalComponentRefCallback } from './
|
|
10
|
-
export { makeRuntime } from './
|
|
9
|
+
export type { Runtime, RuntimeOptions, DevOnlyGlobalRuntime, DevOnlyGlobalComponentRefCallback } from './makeRuntime';
|
|
10
|
+
export { makeRuntime } from './makeRuntime';
|
|
11
11
|
export type { EventHandler } from './jsx/baseTypes';
|
|
12
12
|
export * from './jsx/types';
|
|
13
13
|
export { safeClassMap, safeStyleMap, deferLoad, deferredLoaders, directive, live } from './jsx/directives';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { retrieveComponent, trackKey, keyTrackResolve, useControllerManager } from "@arcgis/components-controllers";
|
|
2
1
|
import { ContextProvider, ContextConsumer } from "@lit/context";
|
|
3
|
-
import {
|
|
2
|
+
import { r as retrieveComponent } from "./useWatch-CFtSpNnN.js";
|
|
3
|
+
import { c } from "./useWatch-CFtSpNnN.js";
|
|
4
4
|
import { state } from "@lit/reactive-element/decorators/state.js";
|
|
5
5
|
import { property as property$1 } from "@lit/reactive-element/decorators/property.js";
|
|
6
6
|
import { n as noShadowRoot, a as attachToAncestor } from "./utils-GhKD5Lo-.js";
|
|
7
7
|
import { m } from "./utils-GhKD5Lo-.js";
|
|
8
|
+
import { Deferred, isEsriInternalEnv, camelToKebab } from "@arcgis/components-utils";
|
|
8
9
|
import { LitElement as LitElement$1, isServer, noChange as noChange$1 } from "lit";
|
|
9
10
|
import { PropertyFlags } from "./config.js";
|
|
11
|
+
import { u as useControllerManager } from "./ControllerManager-B2comd8J.js";
|
|
10
12
|
import { classMap } from "lit-html/directives/class-map.js";
|
|
11
13
|
import { styleMap } from "lit/directives/style-map.js";
|
|
12
14
|
import { directive as directive$1, Directive } from "lit-html/directive.js";
|
|
@@ -24,44 +26,6 @@ function useContextConsumer(options) {
|
|
|
24
26
|
component.addController(controller);
|
|
25
27
|
return controller;
|
|
26
28
|
}
|
|
27
|
-
const createEventFactory = (eventName = "", options = {}, component = retrieveComponent()) => {
|
|
28
|
-
const emitter = {
|
|
29
|
-
emit: (payload) => {
|
|
30
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !component.el.isConnected) {
|
|
31
|
-
console.warn(`Trying to emit an ${eventName} event on a disconnected element ${component.el.localName}`);
|
|
32
|
-
}
|
|
33
|
-
if (eventName === "") {
|
|
34
|
-
keyTrackResolve();
|
|
35
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && eventName === "") {
|
|
36
|
-
throw new Error("Unable to resolve event name from property name");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const event = new CustomEvent(eventName, {
|
|
40
|
-
detail: payload,
|
|
41
|
-
cancelable: true,
|
|
42
|
-
bubbles: true,
|
|
43
|
-
composed: true,
|
|
44
|
-
...options
|
|
45
|
-
});
|
|
46
|
-
component.el.dispatchEvent(event);
|
|
47
|
-
return event;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
if (eventName === "") {
|
|
51
|
-
trackKey(
|
|
52
|
-
void 0,
|
|
53
|
-
(resolution) => {
|
|
54
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && resolution === void 0) {
|
|
55
|
-
throw new Error(`createEvent must be called in property default value only`);
|
|
56
|
-
}
|
|
57
|
-
eventName = resolution.key;
|
|
58
|
-
},
|
|
59
|
-
emitter
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
return emitter;
|
|
63
|
-
};
|
|
64
|
-
const createEvent = createEventFactory.bind(null, "");
|
|
65
29
|
const property = property$1;
|
|
66
30
|
const method = void 0;
|
|
67
31
|
const emptyFunction = () => void 0;
|
|
@@ -249,7 +213,6 @@ class LitElement extends LitElement$1 {
|
|
|
249
213
|
return this;
|
|
250
214
|
}
|
|
251
215
|
}
|
|
252
|
-
LitElement.$createEvent = createEventFactory;
|
|
253
216
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
254
217
|
const globalWithLit = globalThis;
|
|
255
218
|
globalWithLit.litIssuedWarnings ??= /* @__PURE__ */ new Set();
|
|
@@ -390,7 +353,7 @@ export {
|
|
|
390
353
|
bindBooleanAttribute,
|
|
391
354
|
bindEvent,
|
|
392
355
|
bindProperty,
|
|
393
|
-
createEvent,
|
|
356
|
+
c as createEvent,
|
|
394
357
|
deferLoad,
|
|
395
358
|
deferredLoaders,
|
|
396
359
|
directive,
|
package/dist/lazyLoad.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Deferred } from '@arcgis/components-utils';
|
|
2
2
|
import { LitElement } from './LitElement';
|
|
3
|
-
import { Runtime } from './
|
|
4
|
-
import { ControllerManager } from '
|
|
3
|
+
import { Runtime } from './makeRuntime';
|
|
4
|
+
import { ControllerManager } from './controllers/ControllerManager';
|
|
5
5
|
/**
|
|
6
6
|
* Defines lazy-loading proxy components for all web components in this package.
|
|
7
7
|
*
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { LitElement } from './LitElement';
|
|
3
|
+
/**
|
|
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.
|
|
7
|
+
*/
|
|
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
|
+
};
|
|
@@ -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
|
-
|
|
2
|
-
import { LitElement } from './LitElement';
|
|
1
|
+
export declare const runtime: import('./makeRuntime').Runtime;
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
|
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;
|