@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,130 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import type { Reference } from "custom-elements-manifest/schema";
|
|
3
|
+
import { type FullerJsonDocValue } from "./typeToEnum";
|
|
4
|
+
import type { ContextDirectories } from "../../context/types";
|
|
5
|
+
export declare const addPropMetadataPluginName = "@arcgis/lumina:addPropMetadata";
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a type annotation, using the TypeScript typechecker to convert a
|
|
8
|
+
* {@link ts.Type} record to a string.
|
|
9
|
+
*
|
|
10
|
+
* For instance, assume there's a module `foo.ts` which exports a type `Foo`
|
|
11
|
+
* which looks like this:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* // foo.ts
|
|
15
|
+
* type Foo = (b: string) => boolean;
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* and then a module `bar.ts` which imports `Foo` and uses it to annotate a
|
|
19
|
+
* variable declaration like so:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* // bar.ts
|
|
23
|
+
* import { Foo } from './foo';
|
|
24
|
+
*
|
|
25
|
+
* let foo: Foo | undefined;
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* If this function is called with the {@link ts.Type} object corresponding to
|
|
29
|
+
* the {@link ts.Node} object for the `foo` variable, it will return something
|
|
30
|
+
* like:
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* "(b: string) => boolean | undefined";
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param checker a typescript typechecker
|
|
37
|
+
* @param type the type to resolve
|
|
38
|
+
* @returns a resolved, user-readable string
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* Based on Stencil's resolveType function:
|
|
42
|
+
* https://github.com/ionic-team/stencil/blob/b40ebb937869aa16f9adc672129639167406cd07/src/compiler/transformers/transform-utils.ts#L616
|
|
43
|
+
*/
|
|
44
|
+
export declare function typeNodeToTypeValues(typeNode: ts.TypeNode): FullerJsonDocValue[];
|
|
45
|
+
export declare const typeValuesToString: (typeValues: FullerJsonDocValue[]) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Formats a TypeScript `TypeNode` entity as a string
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* Based on TypeScripts's typeToString function
|
|
51
|
+
* (defined in https://github.com/microsoft/TypeScript/blob/main/src/compiler/checker.ts)
|
|
52
|
+
*
|
|
53
|
+
* Using this function is almost equivalent to calling TypeScript's
|
|
54
|
+
* `checker.typeToString(type, undefined, typeFormatFlags);`, but our version
|
|
55
|
+
* correctly prints multiline object literals rather than glueing it into one
|
|
56
|
+
* unreadable line (thanks to textWriter using "\n" line separator, vs "" in the
|
|
57
|
+
* TypeScript's implementation).
|
|
58
|
+
*
|
|
59
|
+
* Also, TypeScript's typeToString converts the Type it receives to TypeNode.
|
|
60
|
+
* Since we need a TypeNode reference anyway for other purposes, that is a bit
|
|
61
|
+
* redundant - thus our version accepts at TypeNode directly
|
|
62
|
+
*/
|
|
63
|
+
export declare function typeNodeToString(typeNode: ts.TypeNode): string;
|
|
64
|
+
/**
|
|
65
|
+
* For documentation purposes, we care about resolved type rather than the
|
|
66
|
+
* unresolved type.
|
|
67
|
+
* The unresolved type can leak implementation details or be less helpful to the
|
|
68
|
+
* user.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* In case like:
|
|
72
|
+
* ```tsx
|
|
73
|
+
* const someInternalStyleVariable: CSSResult!;
|
|
74
|
+
* \@property() style?: typeof someInternalStyleVariable;
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* The resolved type is `CSSResult | undefined`, which is more helpful
|
|
78
|
+
* than the unresolved type `typeof someInternalStyleVariable | undefined`
|
|
79
|
+
*/
|
|
80
|
+
export declare function typeToResolvedTypeNode(checker: ts.TypeChecker, type: ts.Type,
|
|
81
|
+
/** Optional callback to call for each traversed type */
|
|
82
|
+
callback?: (type: Partial<ts.Type>, isElReference: boolean) => void): ts.TypeNode;
|
|
83
|
+
export declare function typeToResolvedTypeNodeWithReferences(checker: ts.TypeChecker, type: ts.Type, sourceFile: ts.SourceFile, dirs: ContextDirectories): {
|
|
84
|
+
typeNode: ts.TypeNode;
|
|
85
|
+
references: Reference[];
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* This is not made up by us - defined in the custom-elements-manifest spec
|
|
89
|
+
*/
|
|
90
|
+
export declare const globalPackageIdentifier = "global:";
|
|
91
|
+
/**
|
|
92
|
+
* Given an absolute path to a module, parse the package name and module name
|
|
93
|
+
* in case of external module reference, or return relative path in case of
|
|
94
|
+
* internal references
|
|
95
|
+
*/
|
|
96
|
+
declare function parseModulePath(absoluteModulePath: string, dirs: ContextDirectories): ModulePath;
|
|
97
|
+
/**
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* parsePackageSpecifier("@esri/calcite-components/dist/components");
|
|
101
|
+
* // { packageName: "@esri/calcite-components", moduleName: "dist/components" }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function parsePackageSpecifier(packageSpecifier: string): ModulePath;
|
|
105
|
+
export declare const isExternalFile: (modulePath: string) => boolean;
|
|
106
|
+
export type ModulePath = {
|
|
107
|
+
readonly packageName: string | undefined;
|
|
108
|
+
readonly moduleName: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Helper method for retrieving modifiers from a TypeScript {@link ts.Node} entity.
|
|
112
|
+
*
|
|
113
|
+
* Starting with TypeScript v4.8, decorators and modifiers have been coalesced into a single field, and retrieving
|
|
114
|
+
* modifiers directly has been deprecated. This helper function is a utility that wraps various helper functions that
|
|
115
|
+
* the TypeScript compiler exposes for pulling modifiers out of said field.
|
|
116
|
+
*
|
|
117
|
+
* @see {@link https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#decorators-are-placed-on-modifiers-on-typescripts-syntax-trees|The TypeScript 4.8 Announcement}
|
|
118
|
+
*
|
|
119
|
+
* @param node the node to pull modifiers out of
|
|
120
|
+
* @returns a list containing 1+ modifiers on the node, otherwise undefined
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* Based on Stencil's retrieveTsModifiers function:
|
|
124
|
+
* https://github.com/ionic-team/stencil/blob/b40ebb937869aa16f9adc672129639167406cd07/src/compiler/transformers/transform-utils.ts#L945
|
|
125
|
+
*/
|
|
126
|
+
export declare const retrieveTsModifiers: (node: ts.Node) => readonly ts.Modifier[] | undefined;
|
|
127
|
+
export declare const exportsForTests: {
|
|
128
|
+
parseModulePath: typeof parseModulePath;
|
|
129
|
+
};
|
|
130
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JsonDocsValue } from "@stencil/core/internal";
|
|
2
|
+
export type FullerJsonDocValue = JsonDocsValue & {
|
|
3
|
+
raw: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* @remarks
|
|
7
|
+
* Based on Stencil's parseTypeIntoValues function:
|
|
8
|
+
* https://github.com/ionic-team/stencil/blob/446d194118756d38d024138eb9e83efe7d9e679e/src/compiler/docs/generate-doc-data.ts#L233
|
|
9
|
+
*
|
|
10
|
+
* But, instead of re-parsing the resolved type string, we are formatting each
|
|
11
|
+
* type union part right away. That is because Stencil's version incorrectly
|
|
12
|
+
* re-parses type strings like `{ value: string | undefined }`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatTypeString(raw: string): FullerJsonDocValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { CustomElementField, Package, Reference } from "custom-elements-manifest/schema";
|
|
2
|
+
import type { Type, ClassMethod, CustomElement, Event } from "custom-elements-manifest/schema";
|
|
3
|
+
/**
|
|
4
|
+
* Information about a type used in a project
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Based on Stencil's ComponentCompilerTypeReferences type:
|
|
8
|
+
* https://github.com/ionic-team/stencil/blob/b40ebb937869aa16f9adc672129639167406cd07/src/declarations/stencil-private.ts#L700
|
|
9
|
+
*/
|
|
10
|
+
export type ComponentCompilerPropertyComplexType = {
|
|
11
|
+
/**
|
|
12
|
+
* The string of the original type annotation in the Lit source code
|
|
13
|
+
*/
|
|
14
|
+
readonly original: Type["text"];
|
|
15
|
+
/**
|
|
16
|
+
* A 'resolved' type, where e.g. imported types have been resolved and inlined
|
|
17
|
+
*
|
|
18
|
+
* For instance, an annotation like `(foo: Foo) => string;` will be
|
|
19
|
+
* converted to `(foo: { foo: string }) => string;`.
|
|
20
|
+
*/
|
|
21
|
+
readonly resolved: string;
|
|
22
|
+
/**
|
|
23
|
+
* A record of the types which were referenced in the assorted type
|
|
24
|
+
* annotation in the original source file.
|
|
25
|
+
*/
|
|
26
|
+
readonly references: Exclude<Type["references"], undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Whether `@property` decorator has readonly:true
|
|
29
|
+
*/
|
|
30
|
+
readonly isReadonly: boolean;
|
|
31
|
+
values: {
|
|
32
|
+
value?: string;
|
|
33
|
+
type: string;
|
|
34
|
+
}[] | undefined;
|
|
35
|
+
readonly isAttributeEligible: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type ComponentCompilerEventType = ComponentCompilerPropertyComplexType & Pick<ExtendedManifestEvent, "bubbles" | "cancelable" | "composed"> & {
|
|
38
|
+
readonly eventName: string;
|
|
39
|
+
};
|
|
40
|
+
export type ExtendedComponentManifest = Package & {
|
|
41
|
+
/**
|
|
42
|
+
* The timestamp at which the metadata was generated, in the format YYYY-MM-DDThh:mm:ss
|
|
43
|
+
*/
|
|
44
|
+
timestamp: string;
|
|
45
|
+
compiler: {
|
|
46
|
+
/**
|
|
47
|
+
* The name of the compiler that generated the metadata
|
|
48
|
+
*/
|
|
49
|
+
name: string;
|
|
50
|
+
/**
|
|
51
|
+
* The version of the compiler that generated the metadata
|
|
52
|
+
*/
|
|
53
|
+
version: string;
|
|
54
|
+
/**
|
|
55
|
+
* The version of TypeScript that was used to generate the metadata
|
|
56
|
+
*/
|
|
57
|
+
typescriptVersion: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type ExtendedManifestCustomElement = CustomElement & {
|
|
61
|
+
/**
|
|
62
|
+
* This is added by custom-elements-manifest, not us, but they forgot to add
|
|
63
|
+
* it to their typings...
|
|
64
|
+
*/
|
|
65
|
+
kind: "class";
|
|
66
|
+
docsTags?: JsonDocsTag[];
|
|
67
|
+
/** @example "src/components/area-measurement-2d/area-measurement-2d.tsx" */
|
|
68
|
+
sourcePath: string;
|
|
69
|
+
/**
|
|
70
|
+
* The path from which the component can be imported.
|
|
71
|
+
*
|
|
72
|
+
* @example "components/arcgis-area-measurement-2d"
|
|
73
|
+
*/
|
|
74
|
+
importPath: string;
|
|
75
|
+
encapsulation: "none" | "shadow";
|
|
76
|
+
/** @example "HTMLArcgisCounterElement" */
|
|
77
|
+
typeName: string;
|
|
78
|
+
};
|
|
79
|
+
export type ExtendedManifestField = CustomElementField & {
|
|
80
|
+
hasQuestionToken?: boolean;
|
|
81
|
+
docsTags?: JsonDocsTag[];
|
|
82
|
+
type?: ExtendedManifestType;
|
|
83
|
+
/**
|
|
84
|
+
* If field has both getter and setter, and their types are different, this
|
|
85
|
+
* will contain the getter type.
|
|
86
|
+
*/
|
|
87
|
+
getterType?: ExtendedManifestType;
|
|
88
|
+
/**
|
|
89
|
+
* This is added by custom-elements-manifest, not us, but they forgot to add
|
|
90
|
+
* it to their typings...
|
|
91
|
+
*/
|
|
92
|
+
readonly?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* For some properties, we show them as read-only in the docs and in the
|
|
95
|
+
* typings but don't actually enforce read-only at runtime.
|
|
96
|
+
*
|
|
97
|
+
* Such properties are represented in the manifest with both `readonly` and
|
|
98
|
+
* `docsOnlyReadonly` set to true.
|
|
99
|
+
*
|
|
100
|
+
* Runtime read-only properties are represented with only `readonly` true.
|
|
101
|
+
*/
|
|
102
|
+
docsOnlyReadonly?: boolean;
|
|
103
|
+
};
|
|
104
|
+
export type ExtendedManifestMethod = ClassMethod & {
|
|
105
|
+
docsTags?: JsonDocsTag[];
|
|
106
|
+
type: {
|
|
107
|
+
signature: string;
|
|
108
|
+
references: Reference[];
|
|
109
|
+
};
|
|
110
|
+
async?: boolean;
|
|
111
|
+
};
|
|
112
|
+
export type ExtendedManifestEvent = Event & {
|
|
113
|
+
type?: ExtendedManifestType;
|
|
114
|
+
docsTags?: JsonDocsTag[];
|
|
115
|
+
bubbles: boolean;
|
|
116
|
+
cancelable: boolean;
|
|
117
|
+
composed: boolean;
|
|
118
|
+
};
|
|
119
|
+
export type InternalManifestField = {
|
|
120
|
+
isAttributeEligible?: boolean;
|
|
121
|
+
};
|
|
122
|
+
export type ExtendedManifestType = Pick<ComponentCompilerPropertyComplexType, "original" | "values"> & Type;
|
|
123
|
+
/**
|
|
124
|
+
* A descriptor for a single JSDoc tag found in a block comment
|
|
125
|
+
*/
|
|
126
|
+
export type JsonDocsTag = {
|
|
127
|
+
/**
|
|
128
|
+
* The tag name (immediately following the '@')
|
|
129
|
+
*/
|
|
130
|
+
name: string;
|
|
131
|
+
/**
|
|
132
|
+
* The description that immediately follows the tag name
|
|
133
|
+
*/
|
|
134
|
+
text?: string;
|
|
135
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference path="../../src/manifests/createManifestTyping.d.ts" />
|
|
2
|
+
import { create } from "@custom-elements-manifest/analyzer/src/browser-entrypoint.js";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import type { PropMetadataContext } from "./complexTypes/addPropMetadata";
|
|
5
|
+
import { type ComponentManifest } from "./utils";
|
|
6
|
+
import type { ExtendedComponentManifest } from "./complexTypes/types";
|
|
7
|
+
import type { CompilerContext } from "../context";
|
|
8
|
+
/**
|
|
9
|
+
* Based on https://github.com/Kamiapp-fr/vite-plugin-cem/blob/main/src/create.ts
|
|
10
|
+
*
|
|
11
|
+
* PERF: this includes a lot of default plugins we don't need (for extracting
|
|
12
|
+
* variables, functions and mixins). We can't exclude them by default without
|
|
13
|
+
* implementing our own create() (which is quite doable as it's only 100 lines
|
|
14
|
+
* of code) or using patch-package. Opened a feature request:
|
|
15
|
+
* https://github.com/open-wc/custom-elements-manifest/issues/262
|
|
16
|
+
*/
|
|
17
|
+
export declare function createManifest(props: Parameters<typeof create>[0], context: CompilerContext,
|
|
18
|
+
/** Whether we are simply patching existing manifest */
|
|
19
|
+
isHmr: boolean): ExtendedComponentManifest;
|
|
20
|
+
/**
|
|
21
|
+
* These members are always present on the proxy element, thus should not be
|
|
22
|
+
* added in the lazy meta like all others. They are also not applicable for JSX
|
|
23
|
+
* typings.
|
|
24
|
+
*/
|
|
25
|
+
export declare const speciallyInheritedMembers: Set<string>;
|
|
26
|
+
export type CustomElementManifestPluginContext = {
|
|
27
|
+
sourceFile?: ts.SourceFile;
|
|
28
|
+
lastAccessors?: Record<string, ts.AccessorDeclaration>;
|
|
29
|
+
lonelyGetters?: Set<string>;
|
|
30
|
+
state?: ManifestState;
|
|
31
|
+
states: ManifestState[];
|
|
32
|
+
thirdPartyCEMs?: ExtendedComponentManifest[];
|
|
33
|
+
};
|
|
34
|
+
type ManifestState = {
|
|
35
|
+
readonly component: ComponentManifest;
|
|
36
|
+
readonly events: PropMetadataContext;
|
|
37
|
+
};
|
|
38
|
+
export declare const initialManifestContext: CustomElementManifestPluginContext;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In order to have TypeScript be aware of your custom elements, the following
|
|
3
|
+
* needs to be present inside the library:
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* declare global {
|
|
7
|
+
* interface DeclareElements {
|
|
8
|
+
* "arcgis-your-component": ArcgisYourComponent;
|
|
9
|
+
* }
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* We can't simply add this at build time, as the above needs to be present
|
|
14
|
+
* when your IDE or the CI type-checks the project.
|
|
15
|
+
*
|
|
16
|
+
* While we could add the above in a central components.d.ts file like with
|
|
17
|
+
* Stencil, doing so may cause merge conflicts, would require having a compiler
|
|
18
|
+
* running in the background to regenerate components.d.ts on change, and can
|
|
19
|
+
* accidentally cause stale components.d.ts to be committed (if developer forgot
|
|
20
|
+
* to run the build process before committing)
|
|
21
|
+
*
|
|
22
|
+
* So instead, we will add "declare global" inside of each component file.
|
|
23
|
+
*
|
|
24
|
+
* To minimize boilerplate, we are going to auto-add the `@customElement()`
|
|
25
|
+
* decorator at build time since the "declare global" structure above has
|
|
26
|
+
* the necessary information (the tag name and the class name), and since
|
|
27
|
+
* decorators don't affect the runtime behavior of the component.
|
|
28
|
+
*
|
|
29
|
+
* While "declare global" is helpful for type checking the project itself,
|
|
30
|
+
* for external typings, we remove it and add component declarations in
|
|
31
|
+
* dist/index.d.ts file (along with event types and etc). This is to match
|
|
32
|
+
* Stencil's behavior in order to minimize breaking changes on migration to
|
|
33
|
+
* Lit.
|
|
34
|
+
*
|
|
35
|
+
* FEATURE: for usages in tests, allow `static override tagName = "te-st";` to define a component? and adapt transformers and plugins to look for nested components too when context.isInTest
|
|
36
|
+
*/
|
|
37
|
+
import type { Plugin as ManifestPlugin } from "@custom-elements-manifest/analyzer";
|
|
38
|
+
import type { FileTransformer } from "../publicTypes";
|
|
39
|
+
import type { CompilerContext } from "../context";
|
|
40
|
+
/**
|
|
41
|
+
* The manifest creation process is using ts.SourceFile instances created
|
|
42
|
+
* by generateTypes() plugin rather than the transform() hooks (to have
|
|
43
|
+
* access to the AST and types).
|
|
44
|
+
* And, to make sure plugins can get access to the final manifest as soon as
|
|
45
|
+
* possible, the manifest generation process is running before any file
|
|
46
|
+
* transform().
|
|
47
|
+
* At the same time, the manifest generation is not aware of our web
|
|
48
|
+
* components because `@customElement()` decorators are not present yet
|
|
49
|
+
* (will be added in transform() hook in vite plugin below). So we have to
|
|
50
|
+
* manually augment "moduleDoc.exports" in this plugin, and later on add the
|
|
51
|
+
* `@customElement()` decorator in the vite plugin.
|
|
52
|
+
*/
|
|
53
|
+
export declare const addCustomElementDecoratorManifestPlugin: (context: CompilerContext) => ManifestPlugin;
|
|
54
|
+
export declare const addCustomElementDecoratorTransformer: FileTransformer;
|
|
55
|
+
export declare function findDeclaredComponents(code: string): (readonly [tagName: string, className: string])[] | undefined;
|
|
56
|
+
export declare const exportsForTests: {
|
|
57
|
+
findDeclaredComponents: typeof findDeclaredComponents;
|
|
58
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CompilerContext } from "../context";
|
|
2
|
+
export declare function addGlobalCss(context: CompilerContext): string;
|
|
3
|
+
export declare const defaultHydratedAttribute = "hydrated";
|
|
4
|
+
/**
|
|
5
|
+
* Auto-inject the CSS when in dev server or when building for CDN to remove the
|
|
6
|
+
* need for adding the `<link>` tag. Wrap styles in `@layer{}` to have lower
|
|
7
|
+
* precedence than other styles in the head.
|
|
8
|
+
*
|
|
9
|
+
* @see https://discord.com/channels/1012791295170859069/1274527043614150708
|
|
10
|
+
*/
|
|
11
|
+
export declare function getGlobalCssInjectionCode(globalCssString: string | undefined, context: CompilerContext): string;
|
|
12
|
+
/**
|
|
13
|
+
* Get a CSS string that can be printed into a .css file
|
|
14
|
+
*/
|
|
15
|
+
export declare const getGlobalCssAsString: (context: CompilerContext) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Plugin as VitePlugin } from "vite";
|
|
2
|
+
import type { CompilerContext } from "../context";
|
|
3
|
+
/**
|
|
4
|
+
* Generate component structure manifest.
|
|
5
|
+
* Generate entrypoint for lazy-loading components.
|
|
6
|
+
*
|
|
7
|
+
* The manifest is then used by componentTransformPipeline() and by
|
|
8
|
+
* generateDocs(), among others
|
|
9
|
+
*
|
|
10
|
+
* @see https://custom-elements-manifest.open-wc.org/analyzer/getting-started/
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateManifest(context: CompilerContext): VitePlugin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentManifest } from "./utils";
|
|
2
|
+
/**
|
|
3
|
+
* By default lit converts property names to attributes to get an attribute name.
|
|
4
|
+
* That is consistent with native DOM attributes.
|
|
5
|
+
*
|
|
6
|
+
* However, that is not consistent with Stencil and would be a breaking change
|
|
7
|
+
* for us. Also, kebab-case is more common among the web components. But the
|
|
8
|
+
* most important reason is that we have some pretty long attribute names,
|
|
9
|
+
* which would be utterly unreadable in lowercase.
|
|
10
|
+
* Also, if browsers add new attributes, that may cause a conflict with our
|
|
11
|
+
* attributes.
|
|
12
|
+
*
|
|
13
|
+
* Thus, in the runtime code, we overwrote Lit's default behavior to use
|
|
14
|
+
* kebab-case.
|
|
15
|
+
*
|
|
16
|
+
* This plugin updates the manifest file to reflect that change
|
|
17
|
+
*/
|
|
18
|
+
export declare function makeAttributesKebabCaseByDefault(customElement: ComponentManifest): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentManifest } from "./utils";
|
|
2
|
+
import type { CompilerContext } from "../context";
|
|
3
|
+
import type { HmrComponentMeta } from "@arcgis/lumina";
|
|
4
|
+
/**
|
|
5
|
+
* To power bundle splitting for lazy loadable components, as well as to support
|
|
6
|
+
* calling async methods before the component loaded, and to ensure frameworks
|
|
7
|
+
* like React 19+ correctly pass properties to the lazy instance, we need to
|
|
8
|
+
* generate a small metadata structure for each component. This will be
|
|
9
|
+
* inserted into the root index.ts file in the package
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildLoaderJs(context: CompilerContext): string;
|
|
12
|
+
export declare const loaderDts = "import \"./index\";\nexport declare const defineCustomElements: import(\"@arcgis/lumina\").DefineCustomElements;";
|
|
13
|
+
/**
|
|
14
|
+
* For each component, build as compact definition as possible of all the public
|
|
15
|
+
* properties, attributes, asynchronous methods and synchronous methods.
|
|
16
|
+
*/
|
|
17
|
+
declare function buildCompactLazyMeta(customElement: Pick<ComponentManifest, "members" | "tagName">): string;
|
|
18
|
+
export declare function buildLazyBeta(customElement: Pick<ComponentManifest, "members" | "tagName">): HmrComponentMeta;
|
|
19
|
+
export declare const exportsForTests: {
|
|
20
|
+
buildCompactLazyMeta: typeof buildCompactLazyMeta;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JsonDocs } from "@stencil/core/internal";
|
|
2
|
+
import type { CompilerContext } from "../context";
|
|
3
|
+
/**
|
|
4
|
+
* Create a stencil-compatible docs.json manifest.
|
|
5
|
+
* While custom-elements-manifest is the most popular community standard and is
|
|
6
|
+
* natively supported by Storybook and other tools, Esri has several internal
|
|
7
|
+
* tools that expect the Stencil-style docs.json manifest.
|
|
8
|
+
* Since they are similar in content, generating a Stencil-compatible manifest
|
|
9
|
+
* will smooth the migration path.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* To make it easier for people to diff the docs.json before and after migration
|
|
13
|
+
* to Lit, we make sure that the order of properties matches what Stencil
|
|
14
|
+
* generates:
|
|
15
|
+
* https://github.com/ionic-team/stencil/blob/9f5f9cdd023b8c8dfb5417a1a970605ba724ae28/src/compiler/docs/generate-doc-data.ts#L98
|
|
16
|
+
*/
|
|
17
|
+
export declare const generateStencilManifest: (context: CompilerContext) => JsonDocs;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExtendedComponentManifest } from "./complexTypes/types";
|
|
2
|
+
/**
|
|
3
|
+
* Providing custom elements manifest to Storybook.
|
|
4
|
+
* See https://github.com/storybookjs/storybook/tree/next/code/addons/docs/web-components
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildStorybookManifestSetter(manifest: ExtendedComponentManifest): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ManifestType = "manifest" | "stencilLikeDocsJson" | "vsCodeCss" | "vsCodeHtml" | "webTypes";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Package, Module, ClassLike } from "custom-elements-manifest/schema";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import type { ExtendedManifestCustomElement, ExtendedManifestField, ExtendedManifestMethod } from "./complexTypes/types";
|
|
4
|
+
/**
|
|
5
|
+
* Custom element object in the manifest may be accessed at different stages
|
|
6
|
+
* of the analysis - some properties (even requires ones) may be missing at
|
|
7
|
+
* earlier stage of the analysis. That is why Partial<> is used.
|
|
8
|
+
*/
|
|
9
|
+
export type ComponentManifest = ClassLike & Partial<ExtendedManifestCustomElement>;
|
|
10
|
+
/**
|
|
11
|
+
* Find all custom elements in a module
|
|
12
|
+
*/
|
|
13
|
+
export declare const extractCustomElements: (module: Partial<Module>, strict?: boolean) => ComponentManifest[];
|
|
14
|
+
export declare function findComponent(componentName: string | undefined, moduleDoc: Partial<Module>): ComponentManifest | undefined;
|
|
15
|
+
export declare function findMember(component: ComponentManifest, memberNode: ts.AccessorDeclaration | ts.MethodDeclaration | ts.PropertyDeclaration): ExtendedManifestField | ExtendedManifestMethod | undefined;
|
|
16
|
+
export declare function getMemberName(memberNode: ts.AccessorDeclaration | ts.MethodDeclaration | ts.PropertyDeclaration): string | undefined;
|
|
17
|
+
export declare function findFileManifest(filePath: string, rootDir: string, manifest: Package): Module | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { CompilerContext } from "../context";
|
|
3
|
+
/**
|
|
4
|
+
* Restricted due to collisions with Lumina's dist/ folder names or
|
|
5
|
+
* Stencil's dist/ folder names
|
|
6
|
+
*/
|
|
7
|
+
export declare const restrictedNamespaceNames: Set<string>;
|
|
8
|
+
export declare const defaultNamespace = "cdn";
|
|
9
|
+
/**
|
|
10
|
+
* CDN build works by reading the lazy NPM build and bundling-in all used
|
|
11
|
+
* dependencies (except for imports of web components from dependencies - those
|
|
12
|
+
* are assumed to be defined in the environment separately)
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildCdn(context: CompilerContext): Plugin | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { CompilerContext } from "../context";
|
|
3
|
+
/**
|
|
4
|
+
* Emit output compatible with Stencil's dist-hydrate-script build.
|
|
5
|
+
*
|
|
6
|
+
* Based on https://github.com/ionic-team/stencil/blob/main/src/compiler/output-targets/dist-hydrate-script/write-hydrate-outputs.ts
|
|
7
|
+
*
|
|
8
|
+
* @deprecated
|
|
9
|
+
* This option should be used to smooth the migration path from Stencil.
|
|
10
|
+
* You should instruct your SSR users to migrate to Lit's SSR implementation,
|
|
11
|
+
* and then stop using this option.
|
|
12
|
+
*
|
|
13
|
+
* @see https://stenciljs.com/docs/hydrate-app
|
|
14
|
+
* @see https://lit.dev/docs/ssr/overview/
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildStencilHydrate(context: CompilerContext): Plugin | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { CompilerContext } from "../context";
|
|
3
|
+
import type { PuppeteerLaunchOptions } from "puppeteer";
|
|
4
|
+
import type { InlineConfig } from "vitest/node";
|
|
5
|
+
export type PuppeteerVitestConfigOptions = InlineConfig & {
|
|
6
|
+
puppeteerLaunchOptions?: PuppeteerLaunchOptions;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Plugin to set up the common Vite configuration.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* In order to respect the options user provided directly to Vite, we must
|
|
13
|
+
* apply the user-provided options, and only fallback to our value if user did
|
|
14
|
+
* not set a value.
|
|
15
|
+
* Though, as per Vite's config merge logic, we only need to look up the default
|
|
16
|
+
* value for literal value properties - objects and arrays are merged.
|
|
17
|
+
* https://github.com/vitejs/vite/blob/bb4ba9f448da01782f585369f80c4517da087000/packages/vite/src/node/utils.ts#L1074
|
|
18
|
+
*/
|
|
19
|
+
export declare const configureVite: (context: CompilerContext) => Plugin;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { Nil } from "@arcgis/components-utils";
|
|
3
|
+
import type { CompilerContext } from "../context";
|
|
4
|
+
/**
|
|
5
|
+
* By default, Rollup will bundle-in all dependencies.
|
|
6
|
+
*
|
|
7
|
+
* We change it as follows:
|
|
8
|
+
* Externalize all packages that are defined as
|
|
9
|
+
* "dependency" or "peerDependency" in the package.json.
|
|
10
|
+
* If you wish to bundle-in some package, define it as a "devDependency".
|
|
11
|
+
*
|
|
12
|
+
* Bundling-in packages is not recommended because:
|
|
13
|
+
* - it makes our build take longer
|
|
14
|
+
* - it pushes larger packages to NPM
|
|
15
|
+
* - user of our library is locked into the version of the package we bundled in
|
|
16
|
+
* - if user has two packages using the same library, there will be two copies
|
|
17
|
+
* served on the page
|
|
18
|
+
* - It may break some libraries/prevent them from optimizing correctly
|
|
19
|
+
* depending on the production/development mode, or prevent them from loading
|
|
20
|
+
* correct code depending on browser/node.js environment.
|
|
21
|
+
*
|
|
22
|
+
* For example, see this statement from Lit:
|
|
23
|
+
* https://lit.dev/docs/ssr/authoring/#:~:text=Don%27t%20bundle%20Lit,based%20on%20environment.
|
|
24
|
+
*
|
|
25
|
+
* @see {@link ./buildCdn.ts} for CDN dependency bundling details
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* If a dependency is both a peerDependency and a devDependency, it will still
|
|
29
|
+
* be externalized (because all peerDependencies are externalized).
|
|
30
|
+
*/
|
|
31
|
+
export declare function externalizeDependencies(context: CompilerContext): Plugin;
|
|
32
|
+
export declare const exportsForTests: {
|
|
33
|
+
normalizeGlobs: (option: Nil | RegExp | string | false) => RegExp | undefined;
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CompilerContext } from "../context";
|
|
2
|
+
import type { Plugin } from "vite";
|
|
3
|
+
/**
|
|
4
|
+
* Generate JSON component metadata in 4 formats ()
|
|
5
|
+
* - community standard
|
|
6
|
+
* - Stencil-like format
|
|
7
|
+
* - VS Code standard
|
|
8
|
+
* - JetBrains standard
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateDocs(context: CompilerContext): Plugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { CompilerContext } from "../context";
|
|
3
|
+
/**
|
|
4
|
+
* This is similar to Stencil's assets hosting, but to improve DX, the assets
|
|
5
|
+
* belonging to each component are moved into a folder named after the component
|
|
6
|
+
* to prevent collisions (or to remove need for manually creating redundant
|
|
7
|
+
* sub-directories to avoid collisions).
|
|
8
|
+
*/
|
|
9
|
+
export declare function handleStaticAssets(context: CompilerContext): Plugin;
|