@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.
@@ -0,0 +1,154 @@
1
+ import { Deferred } from "@arcgis/components-utils";
2
+ import type { LitElement } from "./LitElement";
3
+ import type { Runtime } from "./runtime";
4
+ import type { ControllerManager } from "@arcgis/components-controllers";
5
+ /**
6
+ * Defines lazy-loading proxy components for all web components in this package.
7
+ *
8
+ * As soon as a proxied web component is created (e.g. by adding it to the DOM),
9
+ * it will start loading the actual web component source code.
10
+ */
11
+ export interface DefineCustomElements {
12
+ (_window?: Window, options?: LazyLoadOptions): void;
13
+ (options?: LazyLoadOptions): void;
14
+ }
15
+ export type LazyLoadOptions = {
16
+ readonly resourcesUrl?: string;
17
+ };
18
+ export declare const makeDefineCustomElements: (runtime: Runtime, structure: Readonly<Record<string, CompactMeta>>) => DefineCustomElements;
19
+ /**
20
+ * Use compact meta to reduce bundle size (otherwise, it would be ~65kb for
21
+ * map-components). Also, the meta is a string to speed-up parsing
22
+ * (browsers parse strings much faster).
23
+ * See https://twitter.com/mathias/status/1143551692732030979
24
+ */
25
+ type CompactMeta = readonly [load: () => Promise<Record<string, typeof LitElement>>, compact?: string];
26
+ /**
27
+ * If this file is run from a Node.js environment, HTMLElement won't be defined.
28
+ * Falling back to uselessly extending parseCondensedProp in that case
29
+ * (that particular function chosen just because it already exists, rather than
30
+ * needlessly creating mock class/function)
31
+ * That will error if you try to instantiate a ProxyComponent in Node.js, but
32
+ * that is expected - if you need to instantiate ProxyComponent, HTMLElement
33
+ * must be defined
34
+ */
35
+ declare const HtmlElement: {
36
+ new (): HTMLElement;
37
+ prototype: HTMLElement;
38
+ };
39
+ /**
40
+ * A web-component that, once connected to the page, starts loading the actual
41
+ * component, and set's up two-way forwarding of attributes and methods.
42
+ *
43
+ * It also makes the actual component render it's content in this 'proxy'
44
+ * component, so as to have identical DOM structure for lazy vs non-lazy builds
45
+ * (otherwise, css selectors may break)
46
+ *
47
+ * @internal
48
+ */
49
+ export declare abstract class ProxyComponent extends HtmlElement {
50
+ static observedAttributes?: readonly string[];
51
+ /** @internal */
52
+ static _loadPromise: Promise<Record<string, typeof LitElement>> | undefined;
53
+ /** @internal */
54
+ static _LitConstructor?: typeof LitElement;
55
+ /**
56
+ * A list of instances of this component. This allows hot module replacement
57
+ * to update all proxy component to use a new LitElement instance.
58
+ *
59
+ * @internal
60
+ */
61
+ static _hmrInstances: WeakRef<ProxyComponent>[] | undefined;
62
+ /** @internal */
63
+ static _hmrIndex: number | undefined;
64
+ /** @internal */
65
+ static _properties?: readonly string[];
66
+ /** @internal */
67
+ static _asyncMethods?: readonly string[];
68
+ /** @internal */
69
+ static _syncMethods?: readonly string[];
70
+ protected static _name: string;
71
+ static readonly lumina = true;
72
+ /** @internal */
73
+ static _initializePrototype(): void;
74
+ private static _bindProp;
75
+ private static _bindAsync;
76
+ private static _bindSync;
77
+ /**
78
+ * On HMR, preserve the values of all properties that at least once were set
79
+ * by someone other than component itself.
80
+ *
81
+ * @internal
82
+ */
83
+ _hmrSetProps: Set<PropertyKey>;
84
+ /** @internal */
85
+ _hmrSetAttributes: Set<string>;
86
+ /** @internal */
87
+ _litElement: LitElement | undefined;
88
+ /** @internal */
89
+ _store: LitElement | Record<string, unknown>;
90
+ /**
91
+ * If attributeChangedCallback() is called before the LitElement is loaded,
92
+ * store the attributes here, and replay later
93
+ */
94
+ private _pendingAttributes;
95
+ /**
96
+ * Resolved once LitElement's load() is complete.
97
+ * Not read inside of this class, but needed for LitElement to determine if
98
+ * it's closest ancestor finished load()
99
+ */
100
+ _postLoad: Deferred<void>;
101
+ /**
102
+ * Resolved once LitElement's loaded() is complete
103
+ */
104
+ _postLoaded: Deferred<void>;
105
+ /**
106
+ * Direct offspring that should be awaited before loaded() is emitted
107
+ */
108
+ _offspring: (Partial<Pick<LitElement, "manager">> & Pick<LitElement, "componentOnReady">)[];
109
+ /**
110
+ * Promise that resolves once parent's load() completed. False if there is no
111
+ * parent
112
+ */
113
+ _ancestorLoad?: Promise<void> | false;
114
+ get manager(): ControllerManager | undefined;
115
+ constructor();
116
+ /**
117
+ * Until the custom element is registered on the page, an instance of that
118
+ * element can be constructed and some properties on that instance set.
119
+ *
120
+ * These properties are set before the element prototype is set to this proxy
121
+ * class and thus none of our getters/setters are yet registered - such
122
+ * properties will be set by JavaScript on the instance directly.
123
+ *
124
+ * Once element is registered, the properties set in the meanwhile will shadow
125
+ * the getter/setters, and thus break reactivity. The fix is to delete these
126
+ * properties from the instance, and re-apply them once accessors are set.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * import { defineCustomElements } from '@arcgis/map-components';
131
+ * const map = document.createElement('arcgis-map');
132
+ * // This will shadow the getter/setters
133
+ * map.itemId = '...';
134
+ * // This finally defines the custom elements and sets the property accessors
135
+ * defineCustomElements();
136
+ * ```
137
+ *
138
+ * @remarks
139
+ * This is an equivalent of the __saveInstanceProperties method in Lit's
140
+ * ReactiveElement. Lit takes care of this on LitElement, but we have to take
141
+ * care of this on the lazy proxy
142
+ */
143
+ protected _saveInstanceProperties(): void;
144
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
145
+ connectedCallback(): void;
146
+ disconnectedCallback(): void;
147
+ /**
148
+ * Create a promise that resolves once component is fully loaded
149
+ */
150
+ componentOnReady(): Promise<LitElement>;
151
+ /** @internal */
152
+ _initializeComponent(module: Record<string, typeof LitElement>): void;
153
+ }
154
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ProxyComponent } from "./lazyLoad";
2
+ /**
3
+ * If there is a parent component, tell it to await it's loaded() until we
4
+ * completed load().
5
+ * Also, return a promise that will delay our load() until parent's load()
6
+ * is completed.
7
+ */
8
+ export declare function attachToAncestor(child: ProxyComponent["_offspring"][number], el: HTMLElement): Promise<void> | false;
@@ -0,0 +1,105 @@
1
+ import type { CSSResult } from "lit";
2
+ import type { 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
+ * can not be a global object, but has to be an object that you pass around.
7
+ */
8
+ export type Runtime = {
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
+ readonly defaultAssetsUrl: RuntimeOptions["defaultAssetsUrl"];
57
+ readonly hydratedAttribute: NonNullable<RuntimeOptions["hydratedAttribute"]>;
58
+ readonly commonStyles: readonly NonNullable<RuntimeOptions["commonStyles"]>[];
59
+ readonly globalStyles: RuntimeOptions["globalStyles"];
60
+ };
61
+ export type RuntimeOptions = {
62
+ /**
63
+ * The default base URL to use for loading assets.
64
+ * Set this to `import.meta.env.BASE_URL`, which would be resolved by Vite
65
+ * based on the value you provided to the useLumina() plugin
66
+ */
67
+ readonly defaultAssetsUrl: URL | string;
68
+ /**
69
+ * The attribute that indicates a component has been fully loaded and ready to
70
+ * use. Defaults to "hydrated"
71
+ */
72
+ readonly hydratedAttribute?: string;
73
+ /**
74
+ * Styles that you wish to make available in each component's shadow root, but
75
+ * to not apply outside the shadow root
76
+ *
77
+ * @example
78
+ * import { styles } from "./styles/index.css";
79
+ * export const runtime = makeRuntime({
80
+ * defaultAssetsUrl: import.meta.env.BASE_URL,
81
+ * commonStyles: styles,
82
+ * });
83
+ */
84
+ readonly commonStyles?: CSSResult;
85
+ /**
86
+ * Styles that you wish to applied to the entire page, even outside the shadow
87
+ * dom. Useful for declaring CSS variables.
88
+ */
89
+ readonly globalStyles?: CSSResult;
90
+ };
91
+ export declare function makeRuntime({ defaultAssetsUrl, hydratedAttribute, commonStyles, globalStyles, }: 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
+ export type DevOnlyGlobalRuntime = typeof globalThis & {
97
+ devOnly$luminaRuntime?: Runtime;
98
+ };
99
+ /**
100
+ * Called from the component constructor when in development or test mode.
101
+ * Used primarily by renderElement to get a reference to the rendered component.
102
+ */
103
+ export type DevOnlyGlobalComponentRefCallback = typeof globalThis & {
104
+ devOnly$luminaComponentRefCallback?: (component: LitElement) => void;
105
+ };
@@ -0,0 +1,14 @@
1
+ interface ImportMetaEnv {
2
+ [key: string]: any;
3
+ BASE_URL: string;
4
+ MODE: string;
5
+ DEV: boolean;
6
+ PROD: boolean;
7
+ SSR: boolean;
8
+ }
9
+ interface ImportMeta {
10
+ url: string;
11
+ readonly hot?: import("vite/types/hot.d.ts").ViteHotContext;
12
+ readonly env: ImportMetaEnv;
13
+ glob: import("vite/types/importGlob.d.ts").ImportGlobFunction;
14
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference path="jsxGlobals.d.ts" />
2
+ /// <reference path="loadLitCss.d.ts" />
3
+ /// <reference path="viteEnv.d.ts" />
4
+ /// <reference path="importMeta.d.ts" />
@@ -0,0 +1,38 @@
1
+ export {};
2
+ declare global {
3
+ /**
4
+ * This interface will be extended in each source file that defines a LitElement.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * declare global {
9
+ * interface DeclareElements {
10
+ * "arcgis-root": ArcgisRoot;
11
+ * }
12
+ * }
13
+ * ```
14
+ */
15
+ export interface DeclareElements {
16
+ }
17
+ interface HTMLElementTagNameMap extends DeclareElements {
18
+ }
19
+ /**
20
+ * Extend this interface with Stencil web components that you wish to use
21
+ * in Lit
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import type { JSX as CalciteJSX } from "@esri/calcite-components/dist/types/components";
26
+ * import type { JSX as CommonComponentsJsx } from "@arcgis/common-components/dist/types/components";
27
+ *
28
+ * declare global {
29
+ * interface ImportStencilElements
30
+ * extends CalciteJSX.IntrinsicElements,
31
+ * CommonComponentsJsx.IntrinsicElements {
32
+ * }
33
+ * }
34
+ * ```
35
+ */
36
+ export interface ImportStencilElements {
37
+ }
38
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Tell TypeScript that .css imports will be replaced by Lit's CSSResult at
3
+ * build-time.
4
+ *
5
+ * @see `@arcgis/lumina-compiler/plugins/loadLitCss.ts`
6
+ */
7
+ declare module "*.css" {
8
+ import type { CSSResult } from "lit";
9
+ export const styles: CSSResult & {
10
+ get styleSheet(): CSSStyleSheet;
11
+ };
12
+ export default styles;
13
+ }
14
+ declare module "*.scss" {
15
+ import type { CSSResult } from "lit";
16
+ export const styles: CSSResult & {
17
+ get styleSheet(): CSSStyleSheet;
18
+ };
19
+ export default styles;
20
+ }
21
+ declare module "*.sass" {
22
+ import type { CSSResult } from "lit";
23
+ export const styles: CSSResult & {
24
+ get styleSheet(): CSSStyleSheet;
25
+ };
26
+ export default styles;
27
+ }
28
+ declare module "*.less" {
29
+ import type { CSSResult } from "lit";
30
+ export const styles: CSSResult & {
31
+ get styleSheet(): CSSStyleSheet;
32
+ };
33
+ export default styles;
34
+ }
35
+ declare module "*.styl" {
36
+ import type { CSSResult } from "lit";
37
+ export const styles: CSSResult & {
38
+ get styleSheet(): CSSStyleSheet;
39
+ };
40
+ export default styles;
41
+ }
42
+ declare module "*.stylus" {
43
+ import type { CSSResult } from "lit";
44
+ export const styles: CSSResult & {
45
+ get styleSheet(): CSSStyleSheet;
46
+ };
47
+ export default styles;
48
+ }
49
+ declare module "*.pcss" {
50
+ import type { CSSResult } from "lit";
51
+ export const styles: CSSResult & {
52
+ get styleSheet(): CSSStyleSheet;
53
+ };
54
+ export default styles;
55
+ }
56
+ declare module "*.sss" {
57
+ import type { CSSResult } from "lit";
58
+ export const styles: CSSResult & {
59
+ get styleSheet(): CSSStyleSheet;
60
+ };
61
+ export default styles;
62
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The following are a subset of types from vite/client.d.ts
3
+ * Removed the types related to static assets since we handle assets differently
4
+ */
5
+ declare module "*.wasm?init" {
6
+ const initWasm: (options?: WebAssembly.Imports) => Promise<WebAssembly.Instance>;
7
+ export default initWasm;
8
+ }
9
+ declare module "*?worker" {
10
+ const workerConstructor: new (options?: {
11
+ name?: string;
12
+ }) => Worker;
13
+ export default workerConstructor;
14
+ }
15
+ declare module "*?worker&inline" {
16
+ const workerConstructor: new (options?: {
17
+ name?: string;
18
+ }) => Worker;
19
+ export default workerConstructor;
20
+ }
21
+ declare module "*?worker&url" {
22
+ const src: string;
23
+ export default src;
24
+ }
25
+ declare module "*?sharedworker" {
26
+ const sharedWorkerConstructor: new (options?: {
27
+ name?: string;
28
+ }) => SharedWorker;
29
+ export default sharedWorkerConstructor;
30
+ }
31
+ declare module "*?sharedworker&inline" {
32
+ const sharedWorkerConstructor: new (options?: {
33
+ name?: string;
34
+ }) => SharedWorker;
35
+ export default sharedWorkerConstructor;
36
+ }
37
+ declare module "*?sharedworker&url" {
38
+ const src: string;
39
+ export default src;
40
+ }
41
+ declare module "*?raw" {
42
+ const src: string;
43
+ export default src;
44
+ }
45
+ declare module "*?inline" {
46
+ const src: string;
47
+ export default src;
48
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Add this static property to your component to disable shadow root.
3
+ *
4
+ * @remarks
5
+ * Without shadow root, any styles added using the `styles` property will
6
+ * be applied to the entire DOM that the component is attached to, not just to
7
+ * the insides of this component.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * static override shadowRootOptions = noShadowRoot;
12
+ * ```
13
+ */
14
+ export declare const noShadowRoot: ShadowRootInit;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns a proxy object for a custom element prototype.
3
+ * The function that creates a React wrapper component for a custom element,
4
+ * if rendered, will need the custom element prototype to define the React component properties.
5
+ * Because the custom element may not yet be defined in global scope when
6
+ * `createPrototypeProxy()` is called, this small proxy delays retrieving the custom
7
+ * element prototype until it is actually needed, and caches the result for future calls.
8
+ */
9
+ export declare function createPrototypeProxy<T extends HTMLElement>(tagName: string): new () => T;
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@arcgis/lumina",
3
+ "version": "4.31.0-next.84",
4
+ "type": "module",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": "./dist/index.js",
10
+ "./config": "./dist/config.js",
11
+ "./typings": {
12
+ "types": "./dist/typings/index.d.ts"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist/"
18
+ ],
19
+ "publishConfig": {
20
+ "registry": "https://registry.npmjs.org/",
21
+ "access": "public"
22
+ },
23
+ "license": "SEE LICENSE IN LICENSE.md",
24
+ "scripts": {
25
+ "build": "tsup",
26
+ "build:dev": "tsup --sourcemap",
27
+ "watch": "yarn build:dev --watch",
28
+ "clean": "rimraf ./dist ./build ./turbo ./node_modules"
29
+ },
30
+ "dependencies": {
31
+ "@arcgis/components-controllers": "4.31.0-next.84",
32
+ "@arcgis/components-utils": "4.31.0-next.84",
33
+ "csstype": "^3.1.3",
34
+ "lit": "^3.1.2"
35
+ },
36
+ "devDependencies": {
37
+ "@arcgis/typescript-config": "4.31.0-next.84",
38
+ "@types/node": "^20.2.5",
39
+ "eslint": "^8.55.0",
40
+ "rimraf": "^5.0.0",
41
+ "tsup": "^8.1.0",
42
+ "typescript": "~5.4.0"
43
+ },
44
+ "gitHead": "283c379920730793219fcd5c4e69616e92d691dd"
45
+ }