@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
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
import type ts from "typescript";
|
|
2
|
+
import type { Plugin } from "vite";
|
|
3
|
+
import type { build as esbuildBuild } from "esbuild";
|
|
4
|
+
import type { CompilerContext } from "./context";
|
|
5
|
+
import type { Plugin as ManifestPlugin } from "@custom-elements-manifest/analyzer";
|
|
6
|
+
import type { PluginOptions as VitePluginDtsOptions } from "vite-plugin-dts";
|
|
7
|
+
import type { ExternalsOptions as RollupPluginNodeExternalsOptions } from "rollup-plugin-node-externals";
|
|
8
|
+
import type { Options as VsCodeDocOptions } from "custom-element-vs-code-integration";
|
|
9
|
+
import type { Options as JetBrainsDocOptions } from "custom-element-jet-brains-integration";
|
|
10
|
+
import type { ExtendedComponentManifest } from "./manifests/complexTypes/types";
|
|
11
|
+
import type { Module } from "custom-elements-manifest";
|
|
12
|
+
import type { PuppeteerLaunchOptions } from "puppeteer";
|
|
13
|
+
/**
|
|
14
|
+
* `useLumina()` returns an array of Vite plugins. The array additionally
|
|
15
|
+
* has a `context` property for accessing the compiler context.
|
|
16
|
+
*/
|
|
17
|
+
export type LuminaPlugins = Plugin[] & {
|
|
18
|
+
readonly context: CompilerContext;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Options for controlling the Lumina Compiler.
|
|
22
|
+
*/
|
|
23
|
+
export type LuminaOptions = {
|
|
24
|
+
/**
|
|
25
|
+
* Configuration for controlling the build output, dependency externalization
|
|
26
|
+
* and CDN build process.
|
|
27
|
+
*/
|
|
28
|
+
readonly build?: BuildOptions;
|
|
29
|
+
/**
|
|
30
|
+
* Configurations for controlling the types generation.
|
|
31
|
+
*/
|
|
32
|
+
readonly types?: GenerateTypesOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Configurations for controlling the serve and test environment.
|
|
35
|
+
*/
|
|
36
|
+
readonly serve?: ServeEnvironmentOptions;
|
|
37
|
+
/**
|
|
38
|
+
* Configuration for Puppeteer End-to-End tests.
|
|
39
|
+
* For more options, see Vite's "testing" option.
|
|
40
|
+
* This is equivalent to the `e2e` mode in Stencil.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* For new projects, we recommend using Vitest browser mode instead of
|
|
44
|
+
* Puppeteer. See documentation:
|
|
45
|
+
* https://qawebgis.esri.com/arcgis-components/?path=/docs/references-lumina-testing--docs
|
|
46
|
+
*/
|
|
47
|
+
readonly puppeteerTesting?: PuppeteerTestingOptions;
|
|
48
|
+
/**
|
|
49
|
+
* Configurations for controlling the generation of documentation.
|
|
50
|
+
*/
|
|
51
|
+
readonly documentation?: GenerateDocumentationOptions;
|
|
52
|
+
/**
|
|
53
|
+
* Configurations for controlling the extraction of components metadata and
|
|
54
|
+
* generation of extra files such as types, docs, and wrappers.
|
|
55
|
+
*
|
|
56
|
+
* This is for advanced users who want to customize the generation of metadata
|
|
57
|
+
* files.
|
|
58
|
+
*/
|
|
59
|
+
readonly manifests?: GenerateManifestOptions;
|
|
60
|
+
/**
|
|
61
|
+
* Configuration for CSS handling.
|
|
62
|
+
*/
|
|
63
|
+
readonly css?: CssHandlingOptions;
|
|
64
|
+
/**
|
|
65
|
+
* Configuration for assets handling.
|
|
66
|
+
*/
|
|
67
|
+
readonly assets?: AssetHandlingOptions;
|
|
68
|
+
};
|
|
69
|
+
export type BuildOptions = {
|
|
70
|
+
/**
|
|
71
|
+
* Configuration for CDN build.
|
|
72
|
+
*/
|
|
73
|
+
readonly cdn?: BuildCdnOptions;
|
|
74
|
+
/**
|
|
75
|
+
* Options for externalizing or bundling in dependencies.
|
|
76
|
+
*/
|
|
77
|
+
readonly dependencies?: DependencyManagementOptions;
|
|
78
|
+
/**
|
|
79
|
+
* Legal comment to add to the top of each entrypoint.
|
|
80
|
+
* New lines are accepted.
|
|
81
|
+
* Do not include // or /* - will be added automatically.
|
|
82
|
+
*
|
|
83
|
+
* @default require("@arcgis/components-utils").getPreamble()
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```js
|
|
87
|
+
* `All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
88
|
+
* See https://js.arcgis.com/{minorVersion}/esri/copyright.txt for details.
|
|
89
|
+
* v${version}`
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
readonly preamble?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Whether to include source maps even in production builds.
|
|
95
|
+
* Only set this to true if your library is open source.
|
|
96
|
+
*
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
readonly enableSourceMapsInProduction?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Wrappers to generate.
|
|
102
|
+
*/
|
|
103
|
+
readonly wrappers?: WrappersOptions[];
|
|
104
|
+
readonly ssr?: SsrOptions;
|
|
105
|
+
};
|
|
106
|
+
export type BuildCdnOptions = {
|
|
107
|
+
/**
|
|
108
|
+
* Whether to skip CDN build.
|
|
109
|
+
*
|
|
110
|
+
* @default false
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* Even if CDN build is skipped, assets will still be emitted to
|
|
114
|
+
* dist/cdn-folder-name/assets
|
|
115
|
+
*/
|
|
116
|
+
readonly skip?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Determines the CDN folder name and the name of the entrypoint file inside.
|
|
119
|
+
*
|
|
120
|
+
* @default "cdn"
|
|
121
|
+
*/
|
|
122
|
+
readonly namespace?: string;
|
|
123
|
+
/**
|
|
124
|
+
* To produce the CDN build, Lumina takes the lazy-loading build of your
|
|
125
|
+
* package, and post-processes it with ESBuild. You can customize the options
|
|
126
|
+
* passed to ESBuild.
|
|
127
|
+
*
|
|
128
|
+
* @see https://esbuild.github.io/api/#overview
|
|
129
|
+
*/
|
|
130
|
+
readonly esbuildOptions?: Parameters<typeof esbuildBuild>[0];
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Generic type for the different kinds of wrappers.
|
|
134
|
+
*
|
|
135
|
+
* Angular wrappers have been deprecated. See:
|
|
136
|
+
* https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/1281
|
|
137
|
+
*/
|
|
138
|
+
export type WrappersOptions = React18WrapperOptions;
|
|
139
|
+
export type SsrOptions = {
|
|
140
|
+
/**
|
|
141
|
+
* Emit output compatible with Stencil's dist-hydrate-script build.
|
|
142
|
+
*
|
|
143
|
+
* @deprecated
|
|
144
|
+
* This option should be used to smooth the migration path from Stencil.
|
|
145
|
+
* You should instruct your SSR users to migrate to Lit's SSR implementation,
|
|
146
|
+
* and then stop using this option.
|
|
147
|
+
*
|
|
148
|
+
* @see https://stenciljs.com/docs/hydrate-app
|
|
149
|
+
* @see https://lit.dev/docs/ssr/overview/
|
|
150
|
+
*/
|
|
151
|
+
readonly stencilCompatibility?: {
|
|
152
|
+
/**
|
|
153
|
+
* @default false
|
|
154
|
+
*/
|
|
155
|
+
enabled?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* By default, the hydrate directory is output to package root, outside
|
|
158
|
+
* of dist.
|
|
159
|
+
*
|
|
160
|
+
* @default "hydrate"
|
|
161
|
+
*/
|
|
162
|
+
path?: string;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Options for creating React 18 wrapper.
|
|
167
|
+
*/
|
|
168
|
+
export type React18WrapperOptions = {
|
|
169
|
+
readonly type: "react18";
|
|
170
|
+
/**
|
|
171
|
+
* The file path to the React 18 wrapper proxies file.
|
|
172
|
+
*
|
|
173
|
+
* Workflow:
|
|
174
|
+
* 1. Copy this starter package into your project:
|
|
175
|
+
* https://devtopia.esri.com/WebGIS/arcgis-web-components/tree/main/packages/starter-packages/lumina-components-react
|
|
176
|
+
* 2. Adjust the starter as necessary (package.json, README.md, LICENSE, etc.)
|
|
177
|
+
* 3. Set this option to the path to the src/components.ts file in the wrapper
|
|
178
|
+
* package
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* "../lumina-components-react/src/components.ts"
|
|
182
|
+
*/
|
|
183
|
+
readonly proxiesFile: string;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Options for externalizing dependencies.
|
|
187
|
+
*
|
|
188
|
+
* Reuse the options from rollup-plugin-node-externals, but rename two options for clarity.
|
|
189
|
+
* - `include` is renamed to `externalize` to make it clear that these are externalized
|
|
190
|
+
* - `exclude` is renamed to `bundleIn` to make it clear that these are bundled in
|
|
191
|
+
*
|
|
192
|
+
* @see https://www.npmjs.com/package/rollup-plugin-node-externals
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* If Vite is running under Storybook, these options are ignored. This is
|
|
196
|
+
* because in Storybook build, unlike in a library build, we want to bundle in
|
|
197
|
+
* all dependencies (with exception of @arcgis/core and web component
|
|
198
|
+
* dependencies, which are loaded using the ESM CDN).
|
|
199
|
+
*/
|
|
200
|
+
export type DependencyManagementOptions = Omit<RollupPluginNodeExternalsOptions, "exclude" | "include"> & {
|
|
201
|
+
/**
|
|
202
|
+
* Force bundle in these dependencies even if they are declared as
|
|
203
|
+
* dependencies or peerDependencies.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* This is desirable if you wish to control the version of a dependency or
|
|
207
|
+
* need to post-process the dependency in some way. Usually, you will declare
|
|
208
|
+
* such as a devDependency, but there is a use case for declaring it as a
|
|
209
|
+
* dependency instead:
|
|
210
|
+
*
|
|
211
|
+
* - If TypeScript types from the bundled in dependencies are referenced in
|
|
212
|
+
* the `.d.ts` files of your library, you will need to declare the package
|
|
213
|
+
* as a `dependency`, so that it is still installed on the consumer's
|
|
214
|
+
* computer so that TypeScript can correctly resolve the types of that
|
|
215
|
+
* library.
|
|
216
|
+
*/
|
|
217
|
+
readonly bundleIn?: NonNullable<RollupPluginNodeExternalsOptions>["exclude"];
|
|
218
|
+
/**
|
|
219
|
+
* Force externalize these dependencies, even if they are declared as
|
|
220
|
+
* devDependencies.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* This is desirable if you are sure the end user will have these dependencies
|
|
224
|
+
* available, yet do not wish to declare these as devDependencies for some
|
|
225
|
+
* technical reasons.
|
|
226
|
+
*/
|
|
227
|
+
readonly externalize?: NonNullable<RollupPluginNodeExternalsOptions>["include"];
|
|
228
|
+
};
|
|
229
|
+
export type ServeEnvironmentOptions = {
|
|
230
|
+
/**
|
|
231
|
+
* By default, web component peer dependencies and @arcgis/core are
|
|
232
|
+
* automatically injected when you are running your package in a test
|
|
233
|
+
* or serve environment (`npx vite`, `npx vitest`, or storybook serve).
|
|
234
|
+
*
|
|
235
|
+
* If some additional web component dependencies are needed in test/serve
|
|
236
|
+
* environment only, instead of declaring those as peer dependencies, you
|
|
237
|
+
* should add them as `devDependencies` and list them here to have their
|
|
238
|
+
* custom elements loaded in the test environment.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* Your package does not depend on `@arcgis/map-components`, but for testing
|
|
242
|
+
* purposes you wish to load Map Components when testing your package in
|
|
243
|
+
* `index.html`.
|
|
244
|
+
* In such case, you can set `extraDependencies: ["@arcgis/map-components"]`
|
|
245
|
+
*/
|
|
246
|
+
readonly extraDependencies?: string[];
|
|
247
|
+
};
|
|
248
|
+
export type PuppeteerTestingOptions = {
|
|
249
|
+
/**
|
|
250
|
+
* @default false
|
|
251
|
+
*/
|
|
252
|
+
readonly enabled?: boolean;
|
|
253
|
+
readonly launchOptions?: PuppeteerLaunchOptions;
|
|
254
|
+
};
|
|
255
|
+
export type GenerateDocumentationOptions = {
|
|
256
|
+
/**
|
|
257
|
+
* The name of the file to write the custom elements manifest to.
|
|
258
|
+
*
|
|
259
|
+
* @default "docs/manifest.json"
|
|
260
|
+
* @see https://custom-elements-manifest.open-wc.org/
|
|
261
|
+
*/
|
|
262
|
+
readonly manifestFileName?: string;
|
|
263
|
+
/**
|
|
264
|
+
* The name of the file to write the Stencil-like docs JSON to.
|
|
265
|
+
* For backwards compatibility.
|
|
266
|
+
*
|
|
267
|
+
* @default "docs/docs.json"
|
|
268
|
+
* @see https://stenciljs.com/docs/docs-json
|
|
269
|
+
*/
|
|
270
|
+
readonly stencilLikeDocsJsonFileName?: string;
|
|
271
|
+
/**
|
|
272
|
+
* Provide a URL to a page that documents the component.
|
|
273
|
+
* This URL will be visible in VS Code and IntelliJ when hovering over a
|
|
274
|
+
* component tag in an .html file
|
|
275
|
+
*/
|
|
276
|
+
readonly getComponentDocsUrl?: (tag: string, name: string) => string;
|
|
277
|
+
/**
|
|
278
|
+
* Provide a URL to a page that documents the component.
|
|
279
|
+
* This URL will be visible in VS Code and IntelliJ when hovering over a
|
|
280
|
+
* component tag in an .html file
|
|
281
|
+
*/
|
|
282
|
+
readonly getComponentDemoUrl?: (tag: string, name: string) => string;
|
|
283
|
+
/**
|
|
284
|
+
* Additional options for the custom-element-vs-code-integration plugin
|
|
285
|
+
*
|
|
286
|
+
* @see https://github.com/break-stuff/cem-tools/tree/main/packages/vs-code-integration
|
|
287
|
+
*/
|
|
288
|
+
readonly vsCode?: VsCodeDocOptions;
|
|
289
|
+
/**
|
|
290
|
+
* Additional options for the custom-element-jet-brains-integration plugin
|
|
291
|
+
*
|
|
292
|
+
* @see https://github.com/break-stuff/cem-tools/blob/main/packages/jet-brains-integration/README.md
|
|
293
|
+
*/
|
|
294
|
+
readonly jetBrains?: JetBrainsDocOptions;
|
|
295
|
+
};
|
|
296
|
+
export type GenerateTypesOptions = Omit<VitePluginDtsOptions, "beforeWriteFile" | "strictOutput"> & {
|
|
297
|
+
/**
|
|
298
|
+
* A callback for getting reference to the TypeScript Program and TypeScript
|
|
299
|
+
* host instances created by the compiler.
|
|
300
|
+
*
|
|
301
|
+
* @remarks
|
|
302
|
+
* This will only be called during build, as TypeScript program is not created
|
|
303
|
+
* when running in serve mode.
|
|
304
|
+
*/
|
|
305
|
+
readonly typeScriptInstanceCreated?: (program: ts.Program, host: ts.CompilerHost) => void;
|
|
306
|
+
/**
|
|
307
|
+
* Allows to modify the content of .d.ts files before they are emitted.
|
|
308
|
+
*
|
|
309
|
+
* The .d.ts files are modified as text strings - this is the most performant
|
|
310
|
+
* and simplest option for less complex transformations.
|
|
311
|
+
*
|
|
312
|
+
* Text transformers run after AST transformers.
|
|
313
|
+
*/
|
|
314
|
+
readonly declarationTextTransformers?: DeclarationTextTransformer[];
|
|
315
|
+
/**
|
|
316
|
+
* Allows to modify the content of .d.ts files before they are emitted.
|
|
317
|
+
*
|
|
318
|
+
* The .d.ts files are modified as TypeScript AST nodes - this is useful for
|
|
319
|
+
* advanced transformations.
|
|
320
|
+
*
|
|
321
|
+
* AST transformers run before text transformers.
|
|
322
|
+
*
|
|
323
|
+
* @remarks
|
|
324
|
+
* This transformer is used only on .d.ts files of your components. Any
|
|
325
|
+
* .d.ts files for utility files or other non-entrypoint files are not
|
|
326
|
+
* affected by this transformer. For those, you can use the
|
|
327
|
+
* `declarationAstTransformers` option.
|
|
328
|
+
*/
|
|
329
|
+
readonly declarationAstTransformers?: FileTransformer[];
|
|
330
|
+
/**
|
|
331
|
+
* Allows to modify the .tsx files as TypeScript AST nodes before they are
|
|
332
|
+
* emitted.
|
|
333
|
+
*
|
|
334
|
+
* This is useful for advanced transformations.
|
|
335
|
+
*
|
|
336
|
+
* @remarks
|
|
337
|
+
* It is advisable that your transformer preserves as many of the original
|
|
338
|
+
* source file nodes as possible as that will help in source map generation.
|
|
339
|
+
* Thus where possible, instead of using ts.factory.create* functions, use
|
|
340
|
+
* the ts.factory.update* functions.
|
|
341
|
+
*
|
|
342
|
+
* @remarks
|
|
343
|
+
* Any changes done in this transformer will not affect the generated typings.
|
|
344
|
+
* If you wish your changes to apply to typings too, you will need to
|
|
345
|
+
* implement a separate typings transformer
|
|
346
|
+
*
|
|
347
|
+
* @remarks
|
|
348
|
+
* If you wish to modify the code as a text string rather than AST, then add
|
|
349
|
+
* a Vite plugin to your vite.config.ts that will implement a transform()
|
|
350
|
+
* hook. In such case, do not forget to generate a source map for your changes.
|
|
351
|
+
* See https://rollupjs.org/plugin-development/#source-code-transformations
|
|
352
|
+
*/
|
|
353
|
+
readonly sourceFileTransformers?: FileTransformer[];
|
|
354
|
+
};
|
|
355
|
+
export type DeclarationTextTransformer = (original: DeclarationFile, context: CompilerContext) => DeclarationFile | false;
|
|
356
|
+
export type DeclarationFile = {
|
|
357
|
+
filePath: string;
|
|
358
|
+
content: string;
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* @example
|
|
362
|
+
* ```ts
|
|
363
|
+
* (sourceFile, context) =>
|
|
364
|
+
* context.fileManifest === undefined || !sourceFile.text.includes("@method")
|
|
365
|
+
* ? sourceFile.statements
|
|
366
|
+
* : sourceFile.statements.map((statement) =>
|
|
367
|
+
* statementVisitor(statement, context)
|
|
368
|
+
* );
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
export type FileTransformer = (sourceFile: ts.SourceFile, context: FileTransformContext) => readonly ts.Statement[];
|
|
372
|
+
export type FileTransformContext = {
|
|
373
|
+
readonly compiler: CompilerContext;
|
|
374
|
+
readonly transformation: ts.TransformationContext;
|
|
375
|
+
/**
|
|
376
|
+
* The custom element manifest for this file.
|
|
377
|
+
* if this file did not define any components, then this will be undefined.
|
|
378
|
+
*/
|
|
379
|
+
readonly fileManifest: Module | undefined;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* @see https://custom-elements-manifest.open-wc.org/
|
|
383
|
+
*/
|
|
384
|
+
export type GenerateManifestOptions = {
|
|
385
|
+
/**
|
|
386
|
+
* Additional plugins to use when creating the manifest.
|
|
387
|
+
* This is useful if you want to add additional metadata or customize how
|
|
388
|
+
* your component structure is analyzed
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* You can write a plugin that will automatically add JSDoc for some
|
|
392
|
+
* "well known" properties if JSDoc is not explicitly present in the code.
|
|
393
|
+
*/
|
|
394
|
+
readonly plugins?: ManifestPlugin[];
|
|
395
|
+
/**
|
|
396
|
+
* This function will be called after the manifest is created but before it is
|
|
397
|
+
* used to generate any output files.
|
|
398
|
+
*
|
|
399
|
+
* You can mutate the manifest to affect the typings, lazy component metadata
|
|
400
|
+
* and documentation.
|
|
401
|
+
*/
|
|
402
|
+
readonly afterManifestCreate?: (manifest: ExtendedComponentManifest) => void;
|
|
403
|
+
};
|
|
404
|
+
export type CssHandlingOptions = {
|
|
405
|
+
/**
|
|
406
|
+
* Path to a styles file that you wish to be applied to the entire page, even
|
|
407
|
+
* outside the shadow dom. Useful for declaring CSS variables.
|
|
408
|
+
*
|
|
409
|
+
* These styles will be applied automatically in the CDN build, thus users
|
|
410
|
+
* do not need a separate `<link>` tag. In the NPM build, users will need to
|
|
411
|
+
* manually apply these styles as appropriate in their bundler (either via
|
|
412
|
+
* import statement, or via `<link>` tag or etc).
|
|
413
|
+
*/
|
|
414
|
+
globalStylesPath?: string;
|
|
415
|
+
/**
|
|
416
|
+
* Styles that you wish to make available in each component's shadow root, but
|
|
417
|
+
* to not apply outside the shadow root.
|
|
418
|
+
*
|
|
419
|
+
* These styles do no apply to non-shadow-root components.
|
|
420
|
+
*
|
|
421
|
+
* @remarks
|
|
422
|
+
* If you are using SCSS, you can also use the following Vite config option to
|
|
423
|
+
* add a common SCSS import to every SCSS file:
|
|
424
|
+
* ```tsx
|
|
425
|
+
* css: {
|
|
426
|
+
* preprocessorOptions: {
|
|
427
|
+
* scss: {
|
|
428
|
+
* // Add "includes.scss" import to each scss file
|
|
429
|
+
* additionalData(code, id) {
|
|
430
|
+
* const commonCss = "/src/assets/styles/includes";
|
|
431
|
+
* if (!id.endsWith(".scss") || id.endsWith(`${commonCss}.sass`)) {
|
|
432
|
+
* return undefined;
|
|
433
|
+
* }
|
|
434
|
+
* return `@import "${commonCss}";\n${code}`;
|
|
435
|
+
* },
|
|
436
|
+
* },
|
|
437
|
+
* },
|
|
438
|
+
* }
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
commonStylesPath?: string;
|
|
442
|
+
/**
|
|
443
|
+
* The attribute that indicates a component has rendered it's content.
|
|
444
|
+
* Usually this attribute is added after your component's `loaded()` lifecycle
|
|
445
|
+
* happened. However, during SSR, "hydrated" is added right away on the
|
|
446
|
+
* server.
|
|
447
|
+
*
|
|
448
|
+
* Until element has this attribute, it will have `visibility:hidden` style
|
|
449
|
+
* applied.
|
|
450
|
+
*
|
|
451
|
+
* @default "hydrated"
|
|
452
|
+
*/
|
|
453
|
+
hydratedAttribute?: string;
|
|
454
|
+
/**
|
|
455
|
+
* By default, if a side effect CSS import is detected, an error will thrown.
|
|
456
|
+
* This is due to the requirement of handling shadow DOM styling.
|
|
457
|
+
* Instead, you should import the "styles" variable from the .css file and add
|
|
458
|
+
* it to your component.
|
|
459
|
+
*
|
|
460
|
+
* If there is a side effect CSS import from a file you don't control (i.e a
|
|
461
|
+
* library you are using), then assign this property to a function that would
|
|
462
|
+
* return "drop" to ignore those imports. In such case, you will be
|
|
463
|
+
* responsible for manually providing the styles to the web component.
|
|
464
|
+
*
|
|
465
|
+
* If neither of these is satisfactory, a more complex solution can be
|
|
466
|
+
* implemented in the future.
|
|
467
|
+
*
|
|
468
|
+
* @remarks
|
|
469
|
+
* In regular codebases, it's common to have an import statement like so:
|
|
470
|
+
* ```ts
|
|
471
|
+
* import 'some-library/styles.css';
|
|
472
|
+
* ```
|
|
473
|
+
*
|
|
474
|
+
* Doing so in a web component codebase is a bit trickier as the styles
|
|
475
|
+
* need to be attached not to the `<head>` of the page, but to the shadow
|
|
476
|
+
* root of the component that imported it. Doing so for transitive imports
|
|
477
|
+
* is even trickier (if your component imported a .js file, which in turn
|
|
478
|
+
* imported a .css file) as dependency tracking becomes necessary.
|
|
479
|
+
*
|
|
480
|
+
* That is why, for now, css imports need to be handled like so:
|
|
481
|
+
*
|
|
482
|
+
* - If import is originating from a file you control (your component file),
|
|
483
|
+
* import the "styles" variable from the css file:
|
|
484
|
+
*
|
|
485
|
+
* ```ts
|
|
486
|
+
* import { styles } from 'some-library/styles.css';
|
|
487
|
+
* ```
|
|
488
|
+
*
|
|
489
|
+
* And then add it to your component
|
|
490
|
+
*
|
|
491
|
+
* ```ts
|
|
492
|
+
* export class MyComponent extends LitElement {
|
|
493
|
+
* static override styles = styles;
|
|
494
|
+
* }
|
|
495
|
+
* ```
|
|
496
|
+
*
|
|
497
|
+
* - If the import is originating from a file you don't control (i.e a library
|
|
498
|
+
* code), you have to set this property to a function that will return
|
|
499
|
+
* "drop" for a given library import to ignore such import, and then you
|
|
500
|
+
* will have to manually provide the CSS file by importing "styles"
|
|
501
|
+
* variable.
|
|
502
|
+
*
|
|
503
|
+
* @default () => "throwError"
|
|
504
|
+
*
|
|
505
|
+
*/
|
|
506
|
+
readonly sideEffectImportHandling?: (specifier: string, importer: string) => "drop" | "throwError";
|
|
507
|
+
};
|
|
508
|
+
export type AssetHandlingOptions = {
|
|
509
|
+
/**
|
|
510
|
+
* Any additional assets you wish to provide, besides those located in the
|
|
511
|
+
* assets/ directories
|
|
512
|
+
*
|
|
513
|
+
* @remarks
|
|
514
|
+
* If you need additional flexibility, you can call the
|
|
515
|
+
* `compilerContext.provideAssets()` utility at any time
|
|
516
|
+
*
|
|
517
|
+
* ```ts
|
|
518
|
+
* // vite.config.ts
|
|
519
|
+
* import { defineConfig } from "vite";
|
|
520
|
+
* import { useLumina } from "@arcgis/lumina-compiler";
|
|
521
|
+
*
|
|
522
|
+
* export default defineConfig((env) => {
|
|
523
|
+
* const lumina = useLumina();
|
|
524
|
+
*
|
|
525
|
+
* lumina.context.provideAssets([
|
|
526
|
+
* {
|
|
527
|
+
* type: "dynamic",
|
|
528
|
+
* source: () => new Date().toString(),
|
|
529
|
+
* destination: "build_date.txt",
|
|
530
|
+
* },
|
|
531
|
+
* ]);
|
|
532
|
+
*
|
|
533
|
+
* return {
|
|
534
|
+
* plugins: [lumina],
|
|
535
|
+
* };
|
|
536
|
+
* });
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
readonly extra?: (AssetSpec | ProvideAssetsOptions)[];
|
|
540
|
+
/**
|
|
541
|
+
* The default asset path to use in NPM and CDN builds.
|
|
542
|
+
*
|
|
543
|
+
* @default require("@arcgis/lumina-compiler").inferCdnUrl()
|
|
544
|
+
*/
|
|
545
|
+
readonly defaultPath?: string;
|
|
546
|
+
/**
|
|
547
|
+
* Asset transformers to apply to assets in the assets/ directories in each
|
|
548
|
+
* component and to the assets/ directory in the package root.
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* Example use cases:
|
|
552
|
+
* - minify the assets in production builds
|
|
553
|
+
* - transform the asset files
|
|
554
|
+
* - throw errors if detected incorrect assets
|
|
555
|
+
*/
|
|
556
|
+
readonly transformers?: AssetTransformer[];
|
|
557
|
+
};
|
|
558
|
+
/**
|
|
559
|
+
* Provide additional assets to be copied to the output directory during build
|
|
560
|
+
* or served during development.
|
|
561
|
+
*/
|
|
562
|
+
export type ProvideAssetsOptions = {
|
|
563
|
+
readonly assets: AssetSpec[];
|
|
564
|
+
readonly transformers?: AssetTransformer[];
|
|
565
|
+
/**
|
|
566
|
+
* By default, provided assets are available both to the dev server and are
|
|
567
|
+
* written to dist/
|
|
568
|
+
* You can optionally configure to only apply the assets to the dev server or
|
|
569
|
+
* only to the build.
|
|
570
|
+
*/
|
|
571
|
+
readonly apply?: CompilerContext["viteCommand"];
|
|
572
|
+
};
|
|
573
|
+
export type AssetSpec = AssetDirectory | AssetDynamic | AssetFile;
|
|
574
|
+
type AssetDirectory = {
|
|
575
|
+
readonly type: "directory";
|
|
576
|
+
/**
|
|
577
|
+
* @example src/components/root/assets
|
|
578
|
+
*/
|
|
579
|
+
readonly source: string;
|
|
580
|
+
/**
|
|
581
|
+
* Base directory is /dist/cdn-folder-name/assets
|
|
582
|
+
*
|
|
583
|
+
* @example /root
|
|
584
|
+
* @example ../some-folder-outside-assets-dir/
|
|
585
|
+
*/
|
|
586
|
+
readonly destination: string;
|
|
587
|
+
};
|
|
588
|
+
type AssetFile = {
|
|
589
|
+
readonly type: "file";
|
|
590
|
+
/**
|
|
591
|
+
* @example docs.json
|
|
592
|
+
*/
|
|
593
|
+
readonly source: string;
|
|
594
|
+
/**
|
|
595
|
+
* Base directory is /dist/cdn-folder-name/assets
|
|
596
|
+
*
|
|
597
|
+
* @example docs.json
|
|
598
|
+
*/
|
|
599
|
+
readonly destination: string;
|
|
600
|
+
};
|
|
601
|
+
type AssetDynamic = {
|
|
602
|
+
readonly type: "dynamic";
|
|
603
|
+
/**
|
|
604
|
+
* @example () => new Date().toString()
|
|
605
|
+
*/
|
|
606
|
+
readonly source: () => Promise<string> | string;
|
|
607
|
+
readonly destination: string;
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* Transform static assets before serving then in development or before writing
|
|
611
|
+
* them to dist/ in production.
|
|
612
|
+
* Example use case: minifying JSON files, compressing SVGs, compressing images.
|
|
613
|
+
*
|
|
614
|
+
* @remarks
|
|
615
|
+
* Both in build and serve mode, the destination will be an absolute path to a
|
|
616
|
+
* file in the dist/ directory. The path will use POSIX path separators.
|
|
617
|
+
*/
|
|
618
|
+
export type AssetTransformer = {
|
|
619
|
+
readonly match: (destination: string, context: CompilerContext) => boolean;
|
|
620
|
+
/**
|
|
621
|
+
* Assuming for now that transformer will transform text files only.
|
|
622
|
+
* Also, for now only the first matching transformer will be used.
|
|
623
|
+
*/
|
|
624
|
+
readonly transform: (fileContent: string, destination: string, context: CompilerContext) => string;
|
|
625
|
+
};
|
|
626
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { GlobalSetupContext } from "vitest/dist/node.js";
|
|
2
|
+
import { type ConnectOptions } from "puppeteer";
|
|
3
|
+
declare module "vitest" {
|
|
4
|
+
interface ProvidedContext {
|
|
5
|
+
isDevToolsEnabled?: boolean;
|
|
6
|
+
isHeadlessBrowser?: boolean;
|
|
7
|
+
devServerHtml?: string;
|
|
8
|
+
devServerUrl?: string;
|
|
9
|
+
puppeteerConnectOptions?: ConnectOptions;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Global setup file for Vitest Puppeteer integration.
|
|
14
|
+
*
|
|
15
|
+
* This is run once, in the main thread, before any tests are run.
|
|
16
|
+
*
|
|
17
|
+
* We start browser via Puppeteer so that tests can render to it and interact
|
|
18
|
+
* with it.
|
|
19
|
+
*
|
|
20
|
+
* In the browser, we render the test suite. The browser sends requests for
|
|
21
|
+
* JavaScript files to the Vite dev server.
|
|
22
|
+
*
|
|
23
|
+
* We start that Vite dev server in this file too. It is separate from the
|
|
24
|
+
* Vite dev server started by Vitest.
|
|
25
|
+
*
|
|
26
|
+
* It has to be separate because Vitest's dev server resolves imports for the
|
|
27
|
+
* "node" import condition. If we instead tell Vitest to use browser export
|
|
28
|
+
* conditions, than Lit's "isServer" will be false both in browser and node.js,
|
|
29
|
+
* potentially breaking some components. While happy-dom is neat, it does match
|
|
30
|
+
* the actual browser API 100%. It is safer to run a separate Vite instance for
|
|
31
|
+
* Node.js (Vitest) and browser. This is a short-term issue anyway as we are
|
|
32
|
+
* looking to moving to Vitest browser mode feature, that would resolve this
|
|
33
|
+
* issue.
|
|
34
|
+
*
|
|
35
|
+
* Here is an example Vite configuration plugin that is needed if you wish to
|
|
36
|
+
* make Vitest's Vite instance somewhat usable directly by Playwright's browser:
|
|
37
|
+
* ```ts
|
|
38
|
+
* config: (config) => {
|
|
39
|
+
* const conditions = config.resolve?.conditions;
|
|
40
|
+
* // Remove "node" condition.
|
|
41
|
+
* // Can't do this imperatively as Vite's default configuration merging only
|
|
42
|
+
* // allows adding settings, not removing.
|
|
43
|
+
* if (conditions && conditions.includes("node")) {
|
|
44
|
+
* conditions.splice(conditions.indexOf("node"), 1);
|
|
45
|
+
* }
|
|
46
|
+
* return {
|
|
47
|
+
* server: {
|
|
48
|
+
* middlewareMode: false,
|
|
49
|
+
* },
|
|
50
|
+
* test: {
|
|
51
|
+
* api: true,
|
|
52
|
+
* environment: "happy-dom",
|
|
53
|
+
* },
|
|
54
|
+
* };
|
|
55
|
+
* },
|
|
56
|
+
*
|
|
57
|
+
* Vite's upcoming Environment API will make it possible to use a single dev
|
|
58
|
+
* server (https://github.com/vitejs/vite/pull/16089/files). However, we plan
|
|
59
|
+
* to provide Puppeteer integration only temporary to ease the Stencil
|
|
60
|
+
* migration, so optimizing it too much is not a goal.
|
|
61
|
+
*/
|
|
62
|
+
export declare function setup(context: GlobalSetupContext): Promise<() => Promise<void>>;
|
|
63
|
+
export type PuppeteerViteGlobals = {
|
|
64
|
+
/**
|
|
65
|
+
* Helps lumina-compiler dev server know that is it running for Puppeteer
|
|
66
|
+
* browser.
|
|
67
|
+
*
|
|
68
|
+
* Not exposing this in global typings for usage in tests because
|
|
69
|
+
* `import.meta.env.MODE` should be used instead.
|
|
70
|
+
*/
|
|
71
|
+
__IS_IN_PUPPETEER__?: true;
|
|
72
|
+
};
|