@arcgis/lumina 4.31.0-next.84

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 ADDED
@@ -0,0 +1,13 @@
1
+ # Licensing
2
+
3
+ COPYRIGHT © 2024 Esri
4
+
5
+ All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
6
+
7
+ 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.
8
+
9
+ See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
10
+
11
+ For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
12
+
13
+ email: contracts@esri.com
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # ArcGIS Maps SDK for JavaScript - Lit
2
+
3
+ **No Esri Technical Support included.**
4
+
5
+ Package that is part of the [ArcGIS Maps SDK for JavaScript](https://developers.arcgis.com/javascript).
6
+
7
+ It is not intended to be used directly, but rather used as a dependency by other packages in the SDK.
8
+
9
+ ## License
10
+
11
+ COPYRIGHT © 2024 Esri
12
+
13
+ All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
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
@@ -0,0 +1,213 @@
1
+ import type { CSSResultGroup, CSSResultOrNative, PropertyValues } from "lit";
2
+ import { LitElement as OriginalLitElement } from "lit";
3
+ import type { LitElementPropertyDeclaration } from "@arcgis/components-controllers";
4
+ import type { Runtime } from "./runtime";
5
+ import type { ProxyComponent } from "./lazyLoad";
6
+ type ComponentLifecycle = {
7
+ connectedCallback?: () => void;
8
+ disconnectedCallback?: () => void;
9
+ load?: () => Promise<void> | void;
10
+ loaded?: () => void;
11
+ };
12
+ /**
13
+ * Base Lit class that should be used by all components instead of the original
14
+ * Lit element.
15
+ *
16
+ * This class:
17
+ * - Handles being used in a lazy-loading build
18
+ * - Connects to the Controller Manager
19
+ * - Provides load/loaded lifecycle hooks
20
+ * (like componentWillLoad and componentDidLoad in Stencil)
21
+ * - Provides a .listen() method like Stencil's \@Listen decorator
22
+ *
23
+ * @remarks
24
+ * Even though all components will extend this class, it is not exposed in the
25
+ * public typings as we do not want to expose internal methods like
26
+ * addController() and connectedCallback() to the public typings.
27
+ *
28
+ * Instead, `@arcgis/lumina-compiler` will make it appear that your component
29
+ * extends `PublicLitElement`.
30
+ *
31
+ * `PublicLitElement` will never be called at runtime - it exists for typings
32
+ * only.
33
+ */
34
+ export declare class LitElement extends OriginalLitElement implements ComponentLifecycle {
35
+ /** @internal */
36
+ static runtime: Runtime;
37
+ static tagName: string;
38
+ static finalizeStyles(styles?: CSSResultGroup): CSSResultOrNative[];
39
+ static createProperty(name: PropertyKey,
40
+ /**
41
+ * While in vanilla Lit this type is always LitElementPropertyDeclaration,
42
+ * in Lumina it is always number or
43
+ * [number,LitElementPropertyDeclaration], so we don't even check for the
44
+ * LitElementPropertyDeclaration case. LitElementPropertyDeclaration is here
45
+ * only to satisfy the type checker.
46
+ */
47
+ options?: LitElementPropertyDeclaration | number | [number, LitElementPropertyDeclaration]): void;
48
+ /** @internal */
49
+ static lazy: ProxyComponent | undefined;
50
+ static readonly lumina = true;
51
+ /**
52
+ * In lazy build, the actual DOM element differs from the class instance:
53
+ * - "this.el" is a proxy custom element - it's physically present in the DOM
54
+ * even before the Lit component is loaded.
55
+ * - "this" is the actual Lit component - in case of Lazy builds, it's
56
+ * never directly attached to the DOM. Instead, all interactions with the
57
+ * proxy are forwarded to the actual Lit component. And, when Lit wants to
58
+ * render, it renders into the shadow root of the proxy.
59
+ *
60
+ * "this.el" should be used instead of "this" for all things involving the
61
+ * DOM (addEventListener, querySelector, children, setAttribute,
62
+ * MutationObserver, etc...)
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * // Generally, you shouldn't have to write logic specific to lazy or non-lazy
67
+ * // build, but if you have to, you can detect if you are in a lazy build like so:
68
+ * const isLazy = this.el !== this;
69
+ * ```
70
+ *
71
+ * @remarks
72
+ * Since we can't pass arguments to web component constructor, we are using
73
+ * a temporary static property instead
74
+ */
75
+ el: HTMLElement;
76
+ /**
77
+ * Controller Manager orchestrates all components used by this component,
78
+ * connecting their lifecycle hooks and providing context information.
79
+ */
80
+ manager: import("@arcgis/components-controllers").ControllerManager<never>;
81
+ /**
82
+ * Map with keys for any properties that have changed since the last
83
+ * update cycle with previous values.
84
+ *
85
+ * Do not access this directly as this value is only set during the update
86
+ * lifecycle. Instead, use the `changes` property that is provided
87
+ * to the shouldUpdate(), willUpdate() and didUpdate() lifecycle hooks.
88
+ *
89
+ * @internal
90
+ *
91
+ * @remarks
92
+ * The name does not start with `_` because in the future we may configure the
93
+ * minifier to mangle such properties - but this property is accessed from
94
+ * outside this package, so should not be mangled.
95
+ */
96
+ $changes: PropertyValues;
97
+ /** @internal */
98
+ _postLoad: ProxyComponent["_postLoad"];
99
+ /**
100
+ * Direct offspring that should be awaited before loaded() is emitted.
101
+ *
102
+ * `attachToAncestor()` will add elements to this array
103
+ *
104
+ * @internal
105
+ */
106
+ _offspring: ProxyComponent["_offspring"];
107
+ /**
108
+ * Promise that resolves once parent's load() completed. False if there is no
109
+ * parent
110
+ *
111
+ * @internal
112
+ */
113
+ _ancestorLoad: ProxyComponent["_ancestorLoad"];
114
+ private _originalShouldUpdate?;
115
+ private _enableUpdating;
116
+ private _postLoaded;
117
+ constructor();
118
+ connectedCallback(): void;
119
+ /** Do asynchronous component load */
120
+ private _load;
121
+ /**
122
+ * Overwrite Lit's default behavior of attaching shadow root to the lit
123
+ * element, and instead use this.el to support lazy builds.
124
+ *
125
+ * Also, support the case when component asked to not use shadow root
126
+ */
127
+ protected createRenderRoot(): DocumentFragment | HTMLElement;
128
+ /**
129
+ * Overwriting default shouldUpdate simply to get access to
130
+ * "changedProperties" so that we can later provide it to ControllerManager
131
+ */
132
+ protected shouldUpdate(_changedProperties: PropertyValues): boolean;
133
+ /**
134
+ * A helper for setting event listener on the current component.
135
+ *
136
+ * The event listener will be removed automatically when component
137
+ * disconnects, and added back if component re-comments, thus you don't have
138
+ * to clean it up manually.
139
+ *
140
+ * @remarks
141
+ * This listens for any event on the component or one of it's children.
142
+ * If you only want to listen for events originating from the component itself
143
+ * use `const isSelf = event.target === this.el;` to check.
144
+ *
145
+ * @example
146
+ * ```tsx
147
+ * constructor() {
148
+ * // Handle click will only be called while component is connected
149
+ * this.listen('click', this.handleClick);
150
+ * }
151
+ * handleClick(event: MouseEvent):void {
152
+ * console.log('clicked');
153
+ * }
154
+ * ```
155
+ */
156
+ listen<K extends keyof HTMLElementEventMap>(type: K, listener: (this: this, event: HTMLElementEventMap[K]) => unknown, options?: AddEventListenerOptions | boolean): void;
157
+ listen(type: string, listener: (this: this, event: Event) => unknown, options?: AddEventListenerOptions | boolean): void;
158
+ /**
159
+ * A helper for setting even listener on any element (or window / document).
160
+ *
161
+ * The event listener will be removed automatically when component
162
+ * disconnects, and added back if component re-comments, thus you don't have
163
+ * to clean it up manually.
164
+ *
165
+ * Use cases:
166
+ * - Listening for pointer events on the top-most element
167
+ * - Listening to events that are emitted exclusively on document/window/body
168
+ * - Imperatively listening for events on children components
169
+ * - Listening for events on non-Element objects (like Worker, WebSocket, etc)
170
+ * - Your component could emit a custom event, and then listen for that event
171
+ * on the window. This lets consumer of the component handle the event and
172
+ * stop propagation - and if they didn't and event reached the window, your
173
+ * component can handle the event itself using the default behavior.
174
+ *
175
+ * @example
176
+ * ```tsx
177
+ * constructor() {
178
+ * // Handle click will only be called while component is connected
179
+ * this.listenOn(window, 'click', this.handleWindowClick);
180
+ * }
181
+ * handleWindowClick(event: MouseEvent):void {
182
+ * console.log('clicked');
183
+ * }
184
+ * ```
185
+ */
186
+ listenOn<Name extends keyof WindowEventMap>(target: Window, name: Name, listener: Listener<this, WindowEventMap[Name] & {
187
+ currentTarget: Window;
188
+ }>, options?: AddEventListenerOptions | boolean): void;
189
+ listenOn<Name extends keyof DocumentEventMap>(target: Document, name: Name, listener: Listener<this, DocumentEventMap[Name] & {
190
+ currentTarget: Document;
191
+ }>, options?: AddEventListenerOptions | boolean): void;
192
+ listenOn<Name extends keyof HTMLElementEventMap>(target: HTMLElement, name: Name, listener: Listener<this, HTMLElementEventMap[Name] & {
193
+ currentTarget: HTMLElement;
194
+ }>, options?: AddEventListenerOptions | boolean): void;
195
+ listenOn<EventType extends Event = CustomEvent<"Provide type like this.listenOn<CustomEvent<MyType>>() to get type-checked payload type">, Target = EventTarget>(target: Target, name: string, listener: Listener<this, EventType & {
196
+ currentTarget: Target;
197
+ }>, options?: AddEventListenerOptions | boolean): void;
198
+ /**
199
+ * Create a promise that resolves once component is fully loaded.
200
+ *
201
+ * @example
202
+ * const map = document.createElement('arcgis-map');
203
+ * document.body.append(map);
204
+ * map.componentOnReady().then(() => {
205
+ * console.log('Map is ready to go!');
206
+ * });
207
+ */
208
+ componentOnReady(): Promise<this>;
209
+ }
210
+ type Listener<ThisType, EventType> = ((this: ThisType, event: EventType) => unknown) | {
211
+ handleEvent(event: EventType): unknown;
212
+ };
213
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The base public interface for all `@arcgis/lumina` components
3
+ */
4
+ export declare class PublicLitElement extends HTMLElement {
5
+ /**
6
+ * Create a promise that resolves once component is fully loaded.
7
+ *
8
+ * @example
9
+ * const map = document.createElement("arcgis-map");
10
+ * document.body.append(map);
11
+ * map.componentOnReady().then(() => {
12
+ * console.log("Map is ready to go!");
13
+ * });
14
+ */
15
+ componentOnReady(): Promise<this>;
16
+ }
@@ -0,0 +1,27 @@
1
+ // src/config.ts
2
+ var lazyMetaGroupJoiner = ";";
3
+ var lazyMetaItemJoiner = ",";
4
+ var lazyMetaSubItemJoiner = ":";
5
+ var defaultEventBubbles = true;
6
+ var defaultEventCancelable = true;
7
+ var defaultEventComposed = true;
8
+ var PropertyFlags = /* @__PURE__ */ ((PropertyFlags2) => {
9
+ PropertyFlags2[PropertyFlags2["ATTRIBUTE"] = 1] = "ATTRIBUTE";
10
+ PropertyFlags2[PropertyFlags2["REFLECT"] = 2] = "REFLECT";
11
+ PropertyFlags2[PropertyFlags2["BOOLEAN"] = 4] = "BOOLEAN";
12
+ PropertyFlags2[PropertyFlags2["NUMBER"] = 8] = "NUMBER";
13
+ PropertyFlags2[PropertyFlags2["STATE"] = 16] = "STATE";
14
+ PropertyFlags2[PropertyFlags2["READ_ONLY"] = 32] = "READ_ONLY";
15
+ PropertyFlags2[PropertyFlags2["NO_ACCESSOR"] = 64] = "NO_ACCESSOR";
16
+ return PropertyFlags2;
17
+ })(PropertyFlags || {});
18
+
19
+ export {
20
+ lazyMetaGroupJoiner,
21
+ lazyMetaItemJoiner,
22
+ lazyMetaSubItemJoiner,
23
+ defaultEventBubbles,
24
+ defaultEventCancelable,
25
+ defaultEventComposed,
26
+ PropertyFlags
27
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Configuration options that are shared between `@arcgis/lumina` and
3
+ * `@arcgis/lumina-compiler`. To avoid the need of loading DOM modules in Node.js,
4
+ * this file is extracted into a separate entrypoint.
5
+ */
6
+ export declare const lazyMetaGroupJoiner = ";";
7
+ export declare const lazyMetaItemJoiner = ",";
8
+ export declare const lazyMetaSubItemJoiner = ":";
9
+ /**
10
+ * While these defaults don't match DOM defaults (all false), they match
11
+ * Stencil and Shoelace defaults. Also, they make more sense for our
12
+ * usage (i.e why would you want events to not be cancelable by default?)
13
+ */
14
+ export declare const defaultEventBubbles = true;
15
+ export declare const defaultEventCancelable = true;
16
+ export declare const defaultEventComposed = true;
17
+ /**
18
+ * By default in Lit, the `@property()` decorator accepts an object. However, to
19
+ * keep the bundle size smaller, in production builds, instead of passing it an
20
+ * object, we pass it a compact number, that gets converted back to an object
21
+ * in createProperty() at runtime.
22
+ */
23
+ export declare enum PropertyFlags {
24
+ ATTRIBUTE = 1,
25
+ REFLECT = 2,
26
+ BOOLEAN = 4,
27
+ NUMBER = 8,
28
+ STATE = 16,
29
+ READ_ONLY = 32,
30
+ NO_ACCESSOR = 64
31
+ }
package/dist/config.js ADDED
@@ -0,0 +1,18 @@
1
+ import {
2
+ PropertyFlags,
3
+ defaultEventBubbles,
4
+ defaultEventCancelable,
5
+ defaultEventComposed,
6
+ lazyMetaGroupJoiner,
7
+ lazyMetaItemJoiner,
8
+ lazyMetaSubItemJoiner
9
+ } from "./chunk-CH52Q2MB.js";
10
+ export {
11
+ PropertyFlags,
12
+ defaultEventBubbles,
13
+ defaultEventCancelable,
14
+ defaultEventComposed,
15
+ lazyMetaGroupJoiner,
16
+ lazyMetaItemJoiner,
17
+ lazyMetaSubItemJoiner
18
+ };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * An event emitter object
3
+ */
4
+ export type EventEmitter<T = undefined> = {
5
+ emit(payload: T extends undefined ? void : T): CustomEvent<T>;
6
+ };
7
+ export type EventOptions = {
8
+ /**
9
+ * A Boolean indicating whether the event bubbles up through the DOM or not.
10
+ *
11
+ * @default true
12
+ */
13
+ bubbles?: boolean;
14
+ /**
15
+ * A Boolean indicating whether the event is cancelable. Defaults to `true`,
16
+ * unlike the DOM's default of `false`, as that is the desired behavior most
17
+ * of the time.
18
+ *
19
+ * @default true
20
+ */
21
+ cancelable?: boolean;
22
+ /**
23
+ * A Boolean value indicating whether or not the event can bubble across the
24
+ * boundary between the shadow DOM and the regular DOM.
25
+ *
26
+ * @default true
27
+ */
28
+ composed?: boolean;
29
+ };
30
+ /**
31
+ * While we don't actually return CustomEvent<T>, only EventEmitter<T>, claiming
32
+ * that we return CustomElement<T> simplifies typing.
33
+ *
34
+ * See:
35
+ * ```ts
36
+ * handleClick(event: ArcgisCounter['arcgisClick']): void {
37
+ * }
38
+ * ```
39
+ *
40
+ * Without it, you would have to do:
41
+ * ```ts
42
+ * handleClick(event: ReturnType<ArcgisCounter['arcgisClick']['emit']>): void {
43
+ * }
44
+ * ```
45
+ *
46
+ * It also simplifies the work for Lumina - having property claim to
47
+ * be an even makes it easy to find event properties to provide JSX type-checking,
48
+ * and to find events when doing docs generation.
49
+ */
50
+ export declare const createEventFactory: <T = undefined>(eventName?: string, options?: EventOptions, component?: import("@arcgis/components-controllers").BaseComponent) => CustomEvent<T> & EventEmitter<T>;
51
+ /**
52
+ * Creates an event emitter.
53
+ * Events emitted by your component will be included in the documentation.
54
+ *
55
+ * @example
56
+ * Declaring an event whose payload is of type `number`:
57
+ *
58
+ * ```ts
59
+ * class MyComponent extends LitElement {
60
+ * arcgisClick = createEvent<number>();
61
+ * }
62
+ * ```
63
+ *
64
+ */
65
+ export declare const createEvent: <T = undefined>(options?: EventOptions) => CustomEvent<T> & EventEmitter<T>;
@@ -0,0 +1,55 @@
1
+ import type { LitElementPropertyDeclaration } from "@arcgis/components-controllers";
2
+ export { state } from "@lit/reactive-element/decorators/state.js";
3
+ /**
4
+ * A class field or accessor decorator which creates a reactive property that
5
+ * reflects a corresponding attribute value. When a decorated property is set
6
+ * the element will update and render.
7
+ *
8
+ * This decorator should only be used for public fields. As public fields,
9
+ * properties should be considered as primarily settable by element users,
10
+ * either via attribute or the property itself.
11
+ *
12
+ * Generally, properties that are changed by the element should be private or
13
+ * protected fields and should use the `state()` decorator.
14
+ *
15
+ * However, sometimes element code does need to set a public property. This
16
+ * should typically only be done in response to user interaction, and an event
17
+ * should be fired informing the user; for example, a checkbox sets its
18
+ * `checked` property when clicked and fires a `changed` event. Mutating public
19
+ * properties should typically not be done for non-primitive (object or array)
20
+ * properties. In other cases when an element needs to manage state, a private
21
+ * property decorated via the `state()` decorator should be used. When
22
+ * needed, state properties can be initialized via public properties to
23
+ * facilitate complex interactions.
24
+ *
25
+ * @example
26
+ *
27
+ * ```ts
28
+ * class MyElement {
29
+ * \@property()
30
+ * clicked = false;
31
+ * }
32
+ * ```
33
+ *
34
+ * @example
35
+ * Declaring a readOnly property:
36
+ *
37
+ * ```ts
38
+ * class MyElement {
39
+ * \@property({ readOnly: true })
40
+ * state: State = "loading";
41
+ * }
42
+ * ```
43
+ */
44
+ export declare const property: (options?: Omit<LitElementPropertyDeclaration, "state">) => PropertyDecorator;
45
+ declare type CustomMethodDecorator<T> = (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
46
+ /**
47
+ * The `@method()` decorator is used to expose methods on the public API.
48
+ * Class methods decorated with the `@method()` decorator can be called directly
49
+ * from the element, meaning they are intended to be callable from the outside.
50
+ *
51
+ * @remarks
52
+ * This decorator does not exist at runtime and is only used as a hint for the
53
+ * compiler to declare certain methods as public.
54
+ */
55
+ export declare const method: () => CustomMethodDecorator<any>;
@@ -0,0 +1,11 @@
1
+ import type { LitElement } from "./LitElement";
2
+ /**
3
+ * When in lazy-build, the actual Lit element is never attached to the DOM.
4
+ * Instead, a proxy element is present and should be used for all DOM actions.
5
+ *
6
+ * In practice, this means using this.el.getAttribute() instead of
7
+ * this.getAttribute() and etc for each DOM method
8
+ *
9
+ * This code does not ship in production builds.
10
+ */
11
+ export declare function devOnlyDetectIncorrectLazyUsages(LitClass: typeof LitElement): void;
@@ -0,0 +1,29 @@
1
+ import type { ModuleNamespace } from "vite/types/hot.js";
2
+ /**
3
+ * Update web component proxies when a module is updated.
4
+ *
5
+ * @remarks
6
+ * You should not need to call this function directly - it will be inserted
7
+ * automatically when running in serve mode.
8
+ */
9
+ export declare function handleHmrUpdate(newModules: (ModuleNamespace | undefined)[]): void;
10
+ export type HmrComponentMeta = {
11
+ readonly tagName: string;
12
+ /**
13
+ * 2nd tuple element ("attribute") is missing when attribute name can be
14
+ * trivially inferred from the property name (using camelToKebab()).
15
+ * If 2nd tuple element is empty string, it means the property does not have
16
+ * an attribute.
17
+ */
18
+ readonly properties: (readonly [property: string, attribute: string] | readonly [property: string])[];
19
+ readonly asyncMethods: readonly string[];
20
+ readonly syncMethods: readonly string[];
21
+ };
22
+ /**
23
+ * Update lazy component meta
24
+ *
25
+ * @remarks
26
+ * You should not need to call this function directly - it will be inserted
27
+ * automatically when running in serve mode.
28
+ */
29
+ export declare function handleComponentMetaUpdate(meta: HmrComponentMeta): void;
@@ -0,0 +1,15 @@
1
+ export type { EventEmitter, EventOptions } from "./createEvent";
2
+ export { createEvent } from "./createEvent";
3
+ export { state, property, method } from "./decorators";
4
+ export type { HmrComponentMeta } from "./hmrSupport";
5
+ export { handleComponentMetaUpdate, handleHmrUpdate } from "./hmrSupport";
6
+ export type { DefineCustomElements, LazyLoadOptions } from "./lazyLoad";
7
+ export { makeDefineCustomElements } from "./lazyLoad";
8
+ export { LitElement } from "./LitElement";
9
+ export { PublicLitElement } from "./PublicLitElement";
10
+ export type { Runtime, RuntimeOptions, DevOnlyGlobalRuntime, DevOnlyGlobalComponentRefCallback } from "./runtime";
11
+ export { makeRuntime } from "./runtime";
12
+ export * from "./jsx/jsx";
13
+ export { safeClassMap, safeStyleMap } from "./jsx/directives";
14
+ export { noShadowRoot } from "./utils";
15
+ export { createPrototypeProxy } from "./wrappersUtils";