@arcgis/lumina-compiler 4.31.0-next.100
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 +13 -0
- package/README.md +21 -0
- package/dist/chunk-BQ4U6HQL.js +1 -0
- package/dist/chunk-JFKSI6I7.js +1 -0
- package/dist/context/index.d.ts +241 -0
- package/dist/context/types.d.ts +34 -0
- package/dist/context/utils.d.ts +23 -0
- package/dist/context/utils.spec.d.ts +1 -0
- package/dist/defaultAssetsUrl.d.ts +21 -0
- package/dist/defaultAssetsUrl.spec.d.ts +1 -0
- package/dist/dependencies/arcgisCore.d.ts +30 -0
- package/dist/dependencies/discover.d.ts +62 -0
- package/dist/dependencies/index.d.ts +11 -0
- package/dist/dependencies/lit.d.ts +2 -0
- package/dist/dependencies/loaders.d.ts +8 -0
- package/dist/dependencies/stencil.d.ts +6 -0
- package/dist/dependencies/testSetupFiles.d.ts +21 -0
- package/dist/dependencies/updateLumina.d.ts +8 -0
- package/dist/dependencies/updateLumina.spec.d.ts +1 -0
- package/dist/dependencies/utils.d.ts +23 -0
- package/dist/entrypoints/addNonLazyImports.d.ts +13 -0
- package/dist/entrypoints/config.d.ts +23 -0
- package/dist/entrypoints/dtsUtils.d.ts +22 -0
- package/dist/entrypoints/dtsUtils.spec.d.ts +1 -0
- package/dist/entrypoints/findUtils.d.ts +21 -0
- package/dist/entrypoints/findUtils.spec.d.ts +1 -0
- package/dist/entrypoints/handleComponentImports.d.ts +13 -0
- package/dist/entrypoints/pathMapping.d.ts +25 -0
- package/dist/entrypoints/resolveTagName.d.ts +14 -0
- package/dist/entrypoints/resolveTagName.spec.d.ts +1 -0
- package/dist/frameworkTypes/index.d.ts +15 -0
- package/dist/frameworkTypes/lumina.d.ts +5 -0
- package/dist/frameworkTypes/preact.d.ts +6 -0
- package/dist/frameworkTypes/react.d.ts +6 -0
- package/dist/frameworkTypes/stencil.d.ts +5 -0
- package/dist/frameworkTypes/utils.d.ts +8 -0
- package/dist/frameworkTypes/vanilla.d.ts +3 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +248 -0
- package/dist/jsxToLitHtml/autoAddNothing.d.ts +8 -0
- package/dist/jsxToLitHtml/comments.d.ts +19 -0
- package/dist/jsxToLitHtml/config.d.ts +148 -0
- package/dist/jsxToLitHtml/convertProps.d.ts +10 -0
- package/dist/jsxToLitHtml/escapeForTemplateLiteral.d.ts +45 -0
- package/dist/jsxToLitHtml/imports.d.ts +32 -0
- package/dist/jsxToLitHtml/index.d.ts +17 -0
- package/dist/jsxToLitHtml/inferPropType.d.ts +40 -0
- package/dist/jsxToLitHtml/insertRepeatCall.d.ts +49 -0
- package/dist/jsxToLitHtml/jsxVisitor.d.ts +11 -0
- package/dist/jsxToLitHtml/templateParts.d.ts +17 -0
- package/dist/jsxToLitHtml/throwOnImportingExternalized.d.ts +10 -0
- package/dist/jsxToLitHtml/types.d.ts +80 -0
- package/dist/jsxToLitHtml/utils.d.ts +14 -0
- package/dist/jsxToLitHtml/utils.spec.d.ts +1 -0
- package/dist/manifests/complexTypes/addComponentMetadata.d.ts +5 -0
- package/dist/manifests/complexTypes/addMethodMetadata.d.ts +6 -0
- package/dist/manifests/complexTypes/addPropMetadata.d.ts +8 -0
- package/dist/manifests/complexTypes/docsUtils.d.ts +18 -0
- package/dist/manifests/complexTypes/event.d.ts +9 -0
- package/dist/manifests/complexTypes/getComplexPropertyType.d.ts +11 -0
- package/dist/manifests/complexTypes/transformUtils.d.ts +130 -0
- package/dist/manifests/complexTypes/transformUtils.spec.d.ts +1 -0
- package/dist/manifests/complexTypes/typeToEnum.d.ts +14 -0
- package/dist/manifests/complexTypes/typeToEnum.spec.d.ts +1 -0
- package/dist/manifests/complexTypes/types.d.ts +135 -0
- package/dist/manifests/config.d.ts +2 -0
- package/dist/manifests/createManifest.d.ts +39 -0
- package/dist/manifests/customElementDecoratorPlugins.d.ts +58 -0
- package/dist/manifests/customElementDecoratorPlugins.spec.d.ts +1 -0
- package/dist/manifests/hideUntilHydrated.d.ts +15 -0
- package/dist/manifests/index.d.ts +12 -0
- package/dist/manifests/kebabCaseAttributes.d.ts +18 -0
- package/dist/manifests/lazy.d.ts +22 -0
- package/dist/manifests/lazy.spec.d.ts +1 -0
- package/dist/manifests/stencilManifest.d.ts +17 -0
- package/dist/manifests/storybookManifest.d.ts +6 -0
- package/dist/manifests/types.d.ts +1 -0
- package/dist/manifests/utils.d.ts +17 -0
- package/dist/plugins/buildCdn.d.ts +14 -0
- package/dist/plugins/buildStencilHydrate.d.ts +16 -0
- package/dist/plugins/buildWrappers.d.ts +3 -0
- package/dist/plugins/configureVite.d.ts +19 -0
- package/dist/plugins/externalizeDependencies.d.ts +34 -0
- package/dist/plugins/externalizeDependencies.spec.d.ts +1 -0
- package/dist/plugins/generateDocs.d.ts +10 -0
- package/dist/plugins/handleDynamicAssets.d.ts +3 -0
- package/dist/plugins/handleStaticAssets.d.ts +9 -0
- package/dist/plugins/loadLitCss.d.ts +89 -0
- package/dist/plugins/printTotalBuildSize.d.ts +7 -0
- package/dist/plugins/provideAssets.d.ts +53 -0
- package/dist/plugins/provideAssets.spec.d.ts +1 -0
- package/dist/plugins/setAssetsPath.d.ts +10 -0
- package/dist/plugins/updatePackageJson.d.ts +9 -0
- package/dist/plugins/updatePackageJson.spec.d.ts +1 -0
- package/dist/publicTypes.d.ts +626 -0
- package/dist/puppeteer-testing/globalSetup.d.ts +72 -0
- package/dist/puppeteer-testing/globalSetup.js +11 -0
- package/dist/puppeteer-testing/index.d.ts +9 -0
- package/dist/puppeteer-testing/index.js +6 -0
- package/dist/puppeteer-testing/injected.d.ts +8 -0
- package/dist/puppeteer-testing/puppeteer/browser.d.ts +6 -0
- package/dist/puppeteer-testing/puppeteer/element.d.ts +219 -0
- package/dist/puppeteer-testing/puppeteer/events.d.ts +21 -0
- package/dist/puppeteer-testing/puppeteer/page.d.ts +5 -0
- package/dist/puppeteer-testing/puppeteer/types.d.ts +124 -0
- package/dist/puppeteer-testing/vitest/matchers/attributes.d.ts +4 -0
- package/dist/puppeteer-testing/vitest/matchers/classList.d.ts +4 -0
- package/dist/puppeteer-testing/vitest/matchers/events.d.ts +7 -0
- package/dist/puppeteer-testing/vitest/matchers/index.d.ts +38 -0
- package/dist/puppeteer-testing/vitest/matchers/text.d.ts +2 -0
- package/dist/puppeteer-testing/vitest/matchers/utils.d.ts +1 -0
- package/dist/puppeteer-testing/vitest/runner.d.ts +15 -0
- package/dist/puppeteer-testing/vitest/setupFile.d.ts +1 -0
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/mount.d.ts +106 -0
- package/dist/testing/setupFile.d.ts +1 -0
- package/dist/testing/snapshotSerializer.d.ts +12 -0
- package/dist/testing/wrapController.d.ts +33 -0
- package/dist/tests/utils.d.ts +4 -0
- package/dist/transformers/guardAgainstInternalJsDoc.d.ts +11 -0
- package/dist/transformers/index.d.ts +22 -0
- package/dist/transformers/injectRuntimeOptions.d.ts +3 -0
- package/dist/transformers/internalTypeScriptApis.d.ts +29 -0
- package/dist/transformers/liftDecorators.d.ts +21 -0
- package/dist/transformers/members.d.ts +12 -0
- package/dist/transformers/property.d.ts +9 -0
- package/dist/transformers/propertyOptions.d.ts +111 -0
- package/dist/transformers/updateOriginalFile.d.ts +20 -0
- package/dist/transformers/utils.d.ts +14 -0
- package/dist/types/astTransformers.d.ts +3 -0
- package/dist/types/hideInternalLitElement.d.ts +9 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/liftSetterTypes.d.ts +33 -0
- package/dist/types/textTransformers.d.ts +4 -0
- package/dist/types/transformComponentMembers.d.ts +10 -0
- package/dist/useLumina.d.ts +13 -0
- package/dist/utils/error.d.ts +4 -0
- package/dist/utils/packageJson.d.ts +24 -0
- package/dist/utils/path.d.ts +25 -0
- package/dist/utils/path.spec.d.ts +1 -0
- package/package.json +80 -0
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 @@
|
|
|
1
|
+
import{sep as i}from"path";import o from"path/posix";import r from"path/win32";var n=i===o.sep,e=s=>s.includes(r.sep)?s.replaceAll(r.sep,o.sep):s,c=s=>s.includes(o.sep)?s.replaceAll(o.sep,r.sep):s,u=n?s=>s:c,m=n?process.cwd:()=>e(process.cwd()),x=n?o:{...r,sep:o.sep,join(...s){let t=r.join(...s);return e(t)},normalize(s){let t=r.normalize(s);return e(t)},relative(s,t){let p=r.relative(s,t);return e(p)},dirname(s){let t=r.dirname(s);return e(t)},resolve(...s){let t=r.resolve(...s);return e(t)},toNamespacedPath(s){let t=r.toNamespacedPath(s);return e(t)}};export{n as a,e as b,u as c,m as d,x as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var j=(g,b,d,c)=>{for(var a=c>1?void 0:c?i(b,d):b,e=g.length-1,f;e>=0;e--)(f=g[e])&&(a=(c?f(b,d,a):f(a))||a);return c&&a&&h(b,d,a),a};export{j as a};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import type { ConfigEnv, Plugin, ResolvedConfig, ViteDevServer } from "vite";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import type { LuminaOptions, AssetSpec, AssetTransformer, DeclarationTextTransformer, ProvideAssetsOptions } from "../publicTypes";
|
|
4
|
+
import type { ExtendedComponentManifest } from "../manifests/complexTypes/types";
|
|
5
|
+
import type { ComponentPathMapping } from "../entrypoints/pathMapping";
|
|
6
|
+
import type { ManifestType } from "../manifests/types";
|
|
7
|
+
import type { ComponentManifest } from "../manifests/utils";
|
|
8
|
+
import type { ContextDirectories } from "./types";
|
|
9
|
+
export declare class CompilerContext {
|
|
10
|
+
/**
|
|
11
|
+
* The path to a resolved TypeScript config file
|
|
12
|
+
*/
|
|
13
|
+
readonly typeScriptConfigPath: string;
|
|
14
|
+
/**
|
|
15
|
+
* The resolved TypeScript config file
|
|
16
|
+
*/
|
|
17
|
+
readonly typeScriptConfig: ts.ParsedCommandLine;
|
|
18
|
+
/**
|
|
19
|
+
* An instance of TypeScript program. Contains all .tsx source files present
|
|
20
|
+
* in the project
|
|
21
|
+
*
|
|
22
|
+
* TypeScript program is created only in build mode, not in serve
|
|
23
|
+
*/
|
|
24
|
+
typeScriptProgram?: ts.Program;
|
|
25
|
+
/**
|
|
26
|
+
* An instance of TypeScript type checker
|
|
27
|
+
*
|
|
28
|
+
* TypeScript type checker is created only in build mode, not in serve
|
|
29
|
+
*/
|
|
30
|
+
typeScriptTypeChecker?: ts.TypeChecker;
|
|
31
|
+
/**
|
|
32
|
+
* An instance of TypeScript compiler host
|
|
33
|
+
*/
|
|
34
|
+
typeScriptHost: ts.CompilerHost;
|
|
35
|
+
/**
|
|
36
|
+
* TypeScript source file instances created in serve mode
|
|
37
|
+
*/
|
|
38
|
+
private _typeScriptSourceFiles;
|
|
39
|
+
/**
|
|
40
|
+
* Whether minification is enabled for transformed JSX (lit-html templates)
|
|
41
|
+
* and generated component code
|
|
42
|
+
*/
|
|
43
|
+
shouldMinify: boolean;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* A vite plugin that sets the initial context information based on Vite
|
|
47
|
+
* environment
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
readonly plugin: Plugin;
|
|
52
|
+
/**
|
|
53
|
+
* List of directories of common interest to the compiler
|
|
54
|
+
*/
|
|
55
|
+
dir: ContextDirectories;
|
|
56
|
+
/**
|
|
57
|
+
* The custom-element-manifest, also known as custom-element.json
|
|
58
|
+
*
|
|
59
|
+
* Stores information about the structure of all components in the package
|
|
60
|
+
* (their properties, methods, events, JSDoc and etc).
|
|
61
|
+
*
|
|
62
|
+
* You can augment the manifest generation using the `manifest` option on
|
|
63
|
+
* `useLumina()`
|
|
64
|
+
*
|
|
65
|
+
* @see https://custom-elements-manifest.open-wc.org/analyzer/getting-started/
|
|
66
|
+
*/
|
|
67
|
+
manifest: ExtendedComponentManifest;
|
|
68
|
+
/**
|
|
69
|
+
* A flattened custom-element-manifest listing all components in this package.
|
|
70
|
+
*/
|
|
71
|
+
manifestComponents: ComponentManifest[];
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
componentPathMapping: ComponentPathMapping;
|
|
76
|
+
/**
|
|
77
|
+
* The environment that Vite is running in
|
|
78
|
+
*
|
|
79
|
+
* By default, `npx vite` will run in `development` mode. and `npx vite build`
|
|
80
|
+
* will run in `production` mode. However, you can do a development-mode build
|
|
81
|
+
* using `npx vite build --mode development`
|
|
82
|
+
*
|
|
83
|
+
* - By default, source maps are generated only in development builds.
|
|
84
|
+
* - Minification happens in production builds.
|
|
85
|
+
*/
|
|
86
|
+
environment: "development" | "production";
|
|
87
|
+
/**
|
|
88
|
+
* It is a best practice to keep local build behavior as similar as possible
|
|
89
|
+
* to CI build. Thus, only use this option if some behavior really
|
|
90
|
+
* needs to be different in the CI.
|
|
91
|
+
*
|
|
92
|
+
* For example, `@arcgis/lumina-compiler` will by default automatically update
|
|
93
|
+
* your package's package.json if it is missing some properties. However, this
|
|
94
|
+
* behavior is disabled on the CI machine.
|
|
95
|
+
*
|
|
96
|
+
* @default Boolean(process.env.CI)
|
|
97
|
+
*/
|
|
98
|
+
readonly isInCi: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* It is a best practice to keep production behavior as similar as possible
|
|
101
|
+
* to test environment. Thus, only use this option if some behavior really
|
|
102
|
+
* needs to be different in test environment.
|
|
103
|
+
*
|
|
104
|
+
* For example, `@arcgis/lumina-compiler` will by default automatically update
|
|
105
|
+
* your package's package.json if it is missing some properties. However, this
|
|
106
|
+
* behavior is disabled in test environment.
|
|
107
|
+
*
|
|
108
|
+
* Test environment is detected in the following cases:
|
|
109
|
+
* - Running in test mode (`npx vite build --mode test`). In such case
|
|
110
|
+
* CompilerContext.environment will still be set to `development`
|
|
111
|
+
* - Running in vitest - a test runner for Vite (`npx vitest`)
|
|
112
|
+
* - Running vitest performance benchmark (`npx vitest benchmark`)
|
|
113
|
+
*/
|
|
114
|
+
isInTest: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* If running inside of Vitest as part of Puppeteer test integration
|
|
117
|
+
*/
|
|
118
|
+
isInPuppeteerTestBackEnd: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* If running in a Vite instance created by Vitest Puppeteer integration.
|
|
121
|
+
*/
|
|
122
|
+
isInPuppeteerTestFrontEnd: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Whether Vite build/serve is running inside of Storybook.
|
|
125
|
+
*/
|
|
126
|
+
isInStorybook: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Whether HMR is enabled during the current Vite run
|
|
129
|
+
*/
|
|
130
|
+
hmrEnabled: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Vite can be run in two modes:
|
|
133
|
+
* - Serve the project (with watching for changes and hot module reloading).
|
|
134
|
+
* This is the case when you run Vite as `npx vite`
|
|
135
|
+
* - Build the project (with bundling and optimizations).
|
|
136
|
+
* This is the case when you run Vite as `npx vite build`
|
|
137
|
+
*
|
|
138
|
+
* `@arcgis/lumina-compiler` does not know what environment Vite is running
|
|
139
|
+
* in until the `apply()` Vite plugin hook is called by Vite. That means, you
|
|
140
|
+
* should not try to read this property before the `apply()` hook is called.
|
|
141
|
+
*/
|
|
142
|
+
viteCommand: ConfigEnv["command"];
|
|
143
|
+
readonly banner: string;
|
|
144
|
+
/**
|
|
145
|
+
* `@arcgis/lumina-compiler` plugins may register additional `.d.ts`
|
|
146
|
+
* transformers. For public consumption of Lumina, instead of using this
|
|
147
|
+
* option, use the `types.declarationTextTransformers` option on the
|
|
148
|
+
* `useLumina` Vite plugin.
|
|
149
|
+
*
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
readonly declarationTextTransformers: DeclarationTextTransformer[];
|
|
153
|
+
/**
|
|
154
|
+
* Options passed to `useLumina()`
|
|
155
|
+
*/
|
|
156
|
+
options: LuminaOptions;
|
|
157
|
+
/**
|
|
158
|
+
* Resolved file names for documentation files
|
|
159
|
+
*
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
162
|
+
documentationFileNames: Record<ManifestType, string>;
|
|
163
|
+
/**
|
|
164
|
+
* Resolved Vite configuration
|
|
165
|
+
*/
|
|
166
|
+
viteConfig: ResolvedConfig;
|
|
167
|
+
/**
|
|
168
|
+
* Vite's dev server. Set only if Vite is running in serve mode
|
|
169
|
+
*/
|
|
170
|
+
server: ViteDevServer;
|
|
171
|
+
/**
|
|
172
|
+
* Whether configServer() hook has already been called
|
|
173
|
+
*
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
serverConfigured: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Assets pending to be served
|
|
179
|
+
*
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
182
|
+
assetsToProvide: ProvideAssetsOptions[] | undefined;
|
|
183
|
+
/**
|
|
184
|
+
* A promise that resolves to list of file names that declare one or more
|
|
185
|
+
* components
|
|
186
|
+
*/
|
|
187
|
+
componentFilesPromise: Promise<string[]>;
|
|
188
|
+
/**
|
|
189
|
+
* Style for hiding custom elements before they are loaded. This is appended
|
|
190
|
+
* to the global stylesheet.
|
|
191
|
+
*
|
|
192
|
+
* @internal
|
|
193
|
+
*/
|
|
194
|
+
globalHydratedCssString: string;
|
|
195
|
+
/**
|
|
196
|
+
* Contents of the bundled global CSS file
|
|
197
|
+
*
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
globalCssString?: string;
|
|
201
|
+
/**
|
|
202
|
+
* A list of file names that declare one or more components
|
|
203
|
+
*/
|
|
204
|
+
componentFiles: string[];
|
|
205
|
+
constructor(options: LuminaOptions);
|
|
206
|
+
private _inferBuildSetup;
|
|
207
|
+
/**
|
|
208
|
+
* Get TypeScript ts.SourceFile based on file name and code. Reuses existing
|
|
209
|
+
* source file instance if already created one for that file, and code has not
|
|
210
|
+
* changed.
|
|
211
|
+
*/
|
|
212
|
+
getSourceFile(fileName: string, code: string): ts.SourceFile;
|
|
213
|
+
/**
|
|
214
|
+
* A utility for making Vite copy assets to the output folder during build or
|
|
215
|
+
* making Vite serve them when running in serve mode
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* // vite.config.ts
|
|
220
|
+
* import { defineConfig } from "vite";
|
|
221
|
+
* import { useLumina } from "@arcgis/lumina-compiler";
|
|
222
|
+
*
|
|
223
|
+
* export default defineConfig((env) => {
|
|
224
|
+
* const lumina = useLumina();
|
|
225
|
+
*
|
|
226
|
+
* lumina.context.provideAssets([
|
|
227
|
+
* {
|
|
228
|
+
* type: "dynamic",
|
|
229
|
+
* source: () => new Date().toString(),
|
|
230
|
+
* destination: "build_date.txt",
|
|
231
|
+
* },
|
|
232
|
+
* ]);
|
|
233
|
+
*
|
|
234
|
+
* return {
|
|
235
|
+
* plugins: [lumina],
|
|
236
|
+
* };
|
|
237
|
+
* });
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
provideAssets(assets: AssetSpec[], transformers?: AssetTransformer[], apply?: CompilerContext["viteCommand"]): void;
|
|
241
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type ContextDirectories = {
|
|
2
|
+
/**
|
|
3
|
+
* The project root directory. Usually equals to process.cwd() + '/'
|
|
4
|
+
*/
|
|
5
|
+
root: string;
|
|
6
|
+
/**
|
|
7
|
+
* The source directory. Usually equals dir.root + `src/`
|
|
8
|
+
*/
|
|
9
|
+
src: string;
|
|
10
|
+
/**
|
|
11
|
+
* The components directory. Usually equals dir.src + `components/`
|
|
12
|
+
*/
|
|
13
|
+
srcComponents: string;
|
|
14
|
+
/**
|
|
15
|
+
* The root-relative path to the dist directory. Usually 'dist/'
|
|
16
|
+
*/
|
|
17
|
+
relativeDist: string;
|
|
18
|
+
/**
|
|
19
|
+
* The output directory. Usually equals dir.root + `dist/`
|
|
20
|
+
*/
|
|
21
|
+
dist: string;
|
|
22
|
+
/**
|
|
23
|
+
* The CDN output directory. Usually equals dir.output + `cdn/`
|
|
24
|
+
*/
|
|
25
|
+
distCdn: string;
|
|
26
|
+
/**
|
|
27
|
+
* The components output directory. Usually equals dir.output + `components/`
|
|
28
|
+
*/
|
|
29
|
+
distComponents: string;
|
|
30
|
+
/**
|
|
31
|
+
* The assets output directory. Usually equals dir.output + `cdn/assets/`
|
|
32
|
+
*/
|
|
33
|
+
distCdnAssets: string;
|
|
34
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* While vite-plugin-dts already parses tsconfig, it overwrites the resolved
|
|
4
|
+
* tsconfig.target with ESNext, which is not what we want (we need the real
|
|
5
|
+
* tsconfig.target for the CDN build). Thus, have to resolve the tsconfig
|
|
6
|
+
* ahead of time manually. This is partially redundant and slows down the
|
|
7
|
+
* build a bit
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadTypeScriptConfig(tsConfigPath?: string): {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly config: ts.ParsedCommandLine;
|
|
12
|
+
};
|
|
13
|
+
export declare function inferPreamble(packageJson?: import("../utils/packageJson").MiniPackageJson): string;
|
|
14
|
+
export declare const preambleToComment: (preamble: string) => string;
|
|
15
|
+
export declare const throwOnReadBeforeSet: (createdDuring: string) => PropertyDecorator;
|
|
16
|
+
/**
|
|
17
|
+
* Convert TypeScript ECMA target version number into an ESBuild target version
|
|
18
|
+
* string
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveTargetVersion(typeScriptConfig: {
|
|
21
|
+
options: Pick<ts.CompilerOptions, "target">;
|
|
22
|
+
}): string;
|
|
23
|
+
export declare function normalizeDocumentationFileName(fileName: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a URL like this from the provided package json:
|
|
3
|
+
* `https://js.arcgis.com/<simplified-package-name>/<released-verion>/`
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* `https://js.arcgis.com/map-components/4.30/`
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* If package version number includes "next", `jsdev.arcgis.com` CDN is used
|
|
10
|
+
* instead of `js.arcgis.com`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function inferCdnUrl(packageJson?: {
|
|
13
|
+
name: string;
|
|
14
|
+
version: string;
|
|
15
|
+
}, preferNext?: boolean,
|
|
16
|
+
/**
|
|
17
|
+
* Whether to include the patch semver component in the URL (1.1.x <- the x)
|
|
18
|
+
*
|
|
19
|
+
* @default false, unless packageJson.name is `@esri/calcite-components`
|
|
20
|
+
*/
|
|
21
|
+
includePatch?: boolean): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type DependencyInjectionMode, type DependencyInjectionResult } from "./utils";
|
|
2
|
+
export declare const hasCore: boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Thanks to Vite's dependency pre-bundling, we do not have to use the CDN
|
|
5
|
+
* during local development, but can instead consume the pre-bundled
|
|
6
|
+
* `@arcgis/core` from the node_modules directory.
|
|
7
|
+
*
|
|
8
|
+
* This has benefits:
|
|
9
|
+
* - using the ESM CDN involves making a lot of network requests, often for
|
|
10
|
+
* small files. With pre-bundling, performance can be improved
|
|
11
|
+
* - by using `@arcgis/core` from node_modules, the dev server is guaranteed to
|
|
12
|
+
* use the version of `@arcgis/core` that the package.json specifies. Where as
|
|
13
|
+
* the CDN could be out of date, or point to `next` (which is somewhat
|
|
14
|
+
* ambiguous around release time)
|
|
15
|
+
* - by using `@arcgis/core` from node_modules, you can edit the package in
|
|
16
|
+
* node_modules to quickly preview the result of your edits. This is useful
|
|
17
|
+
* if you are debugging a bug and not yet sure if the bug is with your package
|
|
18
|
+
* or with `@arcgis/core`. More on this:
|
|
19
|
+
* https://vitejs.dev/guide/dep-pre-bundling#browser-cache
|
|
20
|
+
*
|
|
21
|
+
* In builds, all dependencies are externalized so this is not a concern.
|
|
22
|
+
*
|
|
23
|
+
* In storybook builds, we use the ESM CDN. Reasons:
|
|
24
|
+
* - dependency pre-bundling is not available in build mode, only in serve mode
|
|
25
|
+
* - bundling `@arcgis/core` makes the build output huge, creating logistical
|
|
26
|
+
* challenges around deploying many preview branches
|
|
27
|
+
* - for external users, having both storybook and docs use the ESM CDN means
|
|
28
|
+
* they benefit from caching the ESM CDN across both sites
|
|
29
|
+
*/
|
|
30
|
+
export declare function produceArcgisCoreTags(baseUrl: string, mode: DependencyInjectionMode): Promise<DependencyInjectionResult[]>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Package } from "custom-elements-manifest/schema";
|
|
2
|
+
import type { WebTypesJson } from "../jsxToLitHtml/types";
|
|
3
|
+
import type { ModulePath } from "../manifests/complexTypes/transformUtils";
|
|
4
|
+
export type ResolvedDependencyComponents = {
|
|
5
|
+
readonly packageName: string;
|
|
6
|
+
readonly type: "@arcgis/lumina" | "stencil" | "unknown";
|
|
7
|
+
readonly components: Readonly<Record<string, ResolvedDependencyComponent>>;
|
|
8
|
+
};
|
|
9
|
+
export type ResolvedDependencyComponent = ModulePath & {
|
|
10
|
+
/**
|
|
11
|
+
* If jsx property has a static value, and we see that an equivalent attribute
|
|
12
|
+
* exists, jsx property will be converted to an attribute rather than
|
|
13
|
+
* property. If we failed to read all attributes from a package, it's not a
|
|
14
|
+
* big deal as we will then play safe and leave jsx properties as properties.
|
|
15
|
+
*/
|
|
16
|
+
readonly propToAttribute: Readonly<Record<string, string>>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Read information about our web component dependencies. This will be used to:
|
|
20
|
+
* - know where to auto-import a component from
|
|
21
|
+
* - detect usages of unknown components
|
|
22
|
+
* - convert properties to attributes (JSX is authored using property names, not
|
|
23
|
+
* attribute names, but if property is assigned a static value, setting it as
|
|
24
|
+
* an attribute is better for performance)
|
|
25
|
+
* - I was hoping lit-html would allow this syntax to set a property:
|
|
26
|
+
* .property="staticValue", but no, static values are only allowed for
|
|
27
|
+
* attributes. For static parts of the template, Lit would just copy them
|
|
28
|
+
* from the compiled template without any processing, keeping initial render
|
|
29
|
+
* and re-render fast.
|
|
30
|
+
* - Benchmark: setting static attributes: 3.7s (dev), 3.2s (production)
|
|
31
|
+
* setting properties that don't change: 5.1s (dev) and 3.3s (production)
|
|
32
|
+
* - negligible difference in production
|
|
33
|
+
* - Seeing the attribute in HTML would make for easier debugging
|
|
34
|
+
*
|
|
35
|
+
* Process:
|
|
36
|
+
* - For each peer and dev dependency:
|
|
37
|
+
* - If it has manifest.json, read from there (Lumina libraries
|
|
38
|
+
* and popular community libraries)
|
|
39
|
+
* - Else if has web-types.json, read from there (Vaadin and others)
|
|
40
|
+
* - Else, if it has dist/esm/loader.js (Stencil), read from there
|
|
41
|
+
* - Else, if has dist/components/*.d.ts, read from there (Stencil in dev
|
|
42
|
+
* mode and many non-Stencil libraries)
|
|
43
|
+
*
|
|
44
|
+
* If this does not work for one of your dependencies, provide a custom resolver
|
|
45
|
+
* to autoAddImports() or useLumina().
|
|
46
|
+
*/
|
|
47
|
+
export declare function initializeComponentDependencies(cwd?: string): Promise<readonly ResolvedDependencyComponents[]>;
|
|
48
|
+
export declare function retrieveComponentDependencies(): readonly ResolvedDependencyComponents[];
|
|
49
|
+
export declare function retrieveFlatComponentDependencies(): ResolvedDependencyComponents["components"];
|
|
50
|
+
export declare let componentDependenciesPromise: Promise<readonly ResolvedDependencyComponents[]> | undefined;
|
|
51
|
+
export declare function findPackageComponents(packageName: string, cwd?: string): Promise<ResolvedDependencyComponents | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Given the custom element manifest, find custom elements defined in it
|
|
54
|
+
*/
|
|
55
|
+
export declare const manifestToDependencyComponents: (manifest: Package, dependency: Omit<ModulePath, "moduleName"> & {
|
|
56
|
+
readonly getImportPath: (tagName: string) => string;
|
|
57
|
+
}) => ResolvedDependencyComponents["components"];
|
|
58
|
+
export declare const webTypesToDependencyComponents: (webTypes: WebTypesJson, dependency: Omit<ModulePath, "moduleName"> & {
|
|
59
|
+
readonly packageRoot: string | undefined;
|
|
60
|
+
readonly getImportPath: (tagName: string) => string;
|
|
61
|
+
}) => ResolvedDependencyComponents["components"];
|
|
62
|
+
export declare const inferDependencyComponentModuleName: (usesExports: boolean, tagName: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { CompilerContext } from "../context";
|
|
3
|
+
/**
|
|
4
|
+
* In serve mode, augment index.html by adding the necessary script tags for
|
|
5
|
+
* each web component dependency.
|
|
6
|
+
*
|
|
7
|
+
* In case of Storybook, we apply this plugin to iframe.html, not just in serve
|
|
8
|
+
* mode, but also in build mode.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare const provideDependencySupport: (context: CompilerContext) => Plugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CompilerContext } from "../context";
|
|
2
|
+
import { type ResolvedDependencyComponents } from "./discover";
|
|
3
|
+
import type { DependencyInjectionResult } from "./utils";
|
|
4
|
+
export declare const serveOnlyDependencies: WeakMap<CompilerContext, Promise<readonly ResolvedDependencyComponents[]>>;
|
|
5
|
+
export declare function makeLoaders(context: CompilerContext): Promise<DependencyInjectionResult[]>;
|
|
6
|
+
export declare const silenceLitWarnings: {
|
|
7
|
+
javascriptCode: string[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type DependencyInjectionMode, type DependencyInjectionResult } from "./utils";
|
|
2
|
+
export declare function makeStencilLoader(baseUrl: string, packageName: string, mode: DependencyInjectionMode, index: number): Promise<DependencyInjectionResult[]>;
|
|
3
|
+
export declare function findCdnFiles(distDirectory: string): Promise<{
|
|
4
|
+
readonly cdnName: string;
|
|
5
|
+
readonly hasCss: boolean;
|
|
6
|
+
} | undefined>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CompilerContext } from "../context";
|
|
2
|
+
export declare const testLitSetupFileName = "/@arcgis/lumina-compiler/testLitSetupFile";
|
|
3
|
+
/**
|
|
4
|
+
* For browser tests, this file lazy-loads all dependencies, and then the
|
|
5
|
+
* current package itself.
|
|
6
|
+
* It also does misc test setup logic (mocking console, setting timeouts,
|
|
7
|
+
* etc).
|
|
8
|
+
*/
|
|
9
|
+
export declare const testSetupFileName = "/@arcgis/lumina-compiler/testSetupFile";
|
|
10
|
+
export declare const testSetupFileNames: string[];
|
|
11
|
+
export declare const litTestSetupFileContent: string;
|
|
12
|
+
/**
|
|
13
|
+
* Get the entrypoint code for lazy-loading all components and their
|
|
14
|
+
* dependencies when running a web component test in the browser.
|
|
15
|
+
*
|
|
16
|
+
* Lazy loading is critical for performance. Since each test runs in isolation,
|
|
17
|
+
* we wouldn't want to load all possible components in each test (and tracking
|
|
18
|
+
* precisely which components were used is tricky and bug prone - i.e won't
|
|
19
|
+
* catch dynamic references).
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildTestSetupFile(context: CompilerContext): Promise<string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResolvedDependencyComponents } from "./discover";
|
|
2
|
+
import type { BrowserConfigOptions } from "vitest/node";
|
|
3
|
+
export declare function updateLuminaTs(dependencies: readonly ResolvedDependencyComponents[], srcDir: string, hasCore: boolean, browserProvider?: BrowserConfigOptions["provider"]): Promise<void>;
|
|
4
|
+
declare function produceLuminaTs(dependencies: readonly ResolvedDependencyComponents[], hasCore: boolean, browserProvider?: BrowserConfigOptions["provider"], packageJson?: import("../utils/packageJson").MiniPackageJson): string;
|
|
5
|
+
export declare const exportsForTests: {
|
|
6
|
+
produceLuminaTs: typeof produceLuminaTs;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HtmlTagDescriptor } from "vite";
|
|
2
|
+
export type DependencyInjectionMode = "lazy" | "storybookBuild";
|
|
3
|
+
export type DependencyInjectionResult = HtmlTagDescriptor | {
|
|
4
|
+
cssHref: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
} | {
|
|
7
|
+
javascriptCode: string[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Convert a path like C:/Users/test into /C:/Users/test
|
|
11
|
+
*
|
|
12
|
+
* Leaves posix paths unchanged
|
|
13
|
+
*
|
|
14
|
+
* Mirrors what Vite does:
|
|
15
|
+
* https://github.com/vitejs/vite/blob/564c8f45f5429bd149b441d7dca4f44347dedfb1/packages/vite/src/node/server/warmup.ts#L66
|
|
16
|
+
*/
|
|
17
|
+
export declare const absolutePathToUrl: (absolutePath: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* The `baseUrl` should be set to `context.viteConfig.base`
|
|
20
|
+
* Vite always normalized `base` to end with `/`, and, if in serve mode, to not
|
|
21
|
+
* include domain name
|
|
22
|
+
*/
|
|
23
|
+
export declare const toFsUrl: (baseUrl: string, absolutePath: string) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { CompilerContext } from "../context";
|
|
3
|
+
/**
|
|
4
|
+
* When component is imported in a non-lazy-loading way, we need to make sure
|
|
5
|
+
* the component file has explicit import statements for all web component it
|
|
6
|
+
* depends on - this ensures dependencies get bundled correctly.
|
|
7
|
+
*
|
|
8
|
+
* However, in lazy-loading mode, we don't need to do this because all dependent
|
|
9
|
+
* components are assumed to be lazy-loadable too.
|
|
10
|
+
*
|
|
11
|
+
* This plugin creates an index.js for each component for non-lazy-loading mode.
|
|
12
|
+
*/
|
|
13
|
+
export declare const addNonLazyImports: (context: CompilerContext) => Plugin;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CompilerContext } from "../context";
|
|
2
|
+
export declare const customElementEntrypointName = "customElement.js";
|
|
3
|
+
export declare const customElementDtsFileName = "customElement.d.ts";
|
|
4
|
+
export type CustomElementInterdependencies = Record<string, {
|
|
5
|
+
/**
|
|
6
|
+
* All local or foreign custom elements referenced in current file.
|
|
7
|
+
*
|
|
8
|
+
* If this is a component entrypoint file, these imports will be added to
|
|
9
|
+
* the component-name/index.js file so that non-lazy esm usages would
|
|
10
|
+
* include this import.
|
|
11
|
+
* If this is not an entrypoint file (i.e a util functional component), then
|
|
12
|
+
* the referencedBy array will be used to find the entrypoint files that
|
|
13
|
+
* referenced this file (directly or indirectly), and any import specifiers
|
|
14
|
+
* will be added to those components instead of this file.
|
|
15
|
+
*/
|
|
16
|
+
referencedTagNames: string[];
|
|
17
|
+
readonly referencedBy: string[];
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* This is used in build mode only.
|
|
21
|
+
*/
|
|
22
|
+
export declare const customElementDependencies: WeakMap<CompilerContext, CustomElementInterdependencies>;
|
|
23
|
+
export declare const defaultBrowserTestProvider = "playwright";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DeclarationTextTransformer } from "../publicTypes";
|
|
2
|
+
import { path } from "../utils/path";
|
|
3
|
+
import type { CompilerContext } from "../context";
|
|
4
|
+
export declare const rewriteDtsComponentFileNames: DeclarationTextTransformer;
|
|
5
|
+
export declare const rePath: RegExp;
|
|
6
|
+
/**
|
|
7
|
+
* Rewrite references to `./components/component-folder-name/component-file-name.js` with
|
|
8
|
+
* `./components/component-tag-name/customElement.js` in `.js` and `.d.ts` files.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Assuming content includes POSIX paths only (as that's what import specifiers
|
|
12
|
+
* in ECMAScript use)
|
|
13
|
+
*/
|
|
14
|
+
export declare const rewriteComponentImportSpecifiers: (code: string, context: Pick<CompilerContext, "componentPathMapping" | "dir">, cwd: string, originalCwd: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* The result of relative() is a path that does not start with `./`.
|
|
17
|
+
* In import statements the path must begin with ../ or ./ to be interpreted as
|
|
18
|
+
* a relative path rather than a package name.
|
|
19
|
+
* This function makes sure that the result of relative() is normalized to start
|
|
20
|
+
* with `./` or `../`
|
|
21
|
+
*/
|
|
22
|
+
export declare const toRelativeImportSpecifier: (typeof path)["relative"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CompilerContext } from "../context";
|
|
2
|
+
/**
|
|
3
|
+
* Create a separate entrypoint for each component to allow consuming
|
|
4
|
+
* applications to only load the necessary code.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Finds all components in the src/components folder. With support for nested
|
|
8
|
+
* components (looking for .tsx files whose name matches their folder name)
|
|
9
|
+
*/
|
|
10
|
+
export declare const getComponentEntrypoints: (context: CompilerContext) => Promise<Readonly<Record<string, string>>>;
|
|
11
|
+
/**
|
|
12
|
+
* @example
|
|
13
|
+
* `src/components/component-name/component-name.tsx` =>
|
|
14
|
+
* `./components/component-name/customElement`
|
|
15
|
+
*/
|
|
16
|
+
export declare const entrypointPathToDistPath: (sourceFileName: string, srcPath?: string) => string;
|
|
17
|
+
export declare const findComponentFiles: (context: CompilerContext, componentsDirectory: string, searchBase?: string) => Promise<string[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if absolute file path looks like a component entrypoint
|
|
20
|
+
*/
|
|
21
|
+
export declare function pathIsEntrypoint(absolutePath: string, componentsFolder: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|