@arcgis/lumina-compiler 5.2.0-next.2 → 5.2.0-next.21

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.
Files changed (102) hide show
  1. package/dist/context/index.d.ts +158 -296
  2. package/dist/context/types.d.ts +18 -34
  3. package/dist/defaultAssetsUrl.d.ts +6 -6
  4. package/dist/dependencies/discover.d.ts +43 -35
  5. package/dist/dependencies/updateLumina.d.ts +10 -11
  6. package/dist/docs/vsCodeCustomData/types.d.ts +5 -42
  7. package/dist/docs/webTypes/types.d.ts +5 -76
  8. package/dist/index.d.ts +20 -20
  9. package/dist/index.js +12 -8
  10. package/dist/jsxToLitHtml/config.d.ts +93 -121
  11. package/dist/options.d.ts +675 -0
  12. package/dist/puppeteerTesting/index.d.ts +18 -11
  13. package/dist/puppeteerTesting/index.js +104 -7
  14. package/dist/puppeteerTesting/puppeteer/element.d.ts +250 -217
  15. package/dist/puppeteerTesting/puppeteer/events.d.ts +15 -21
  16. package/dist/puppeteerTesting/puppeteer/page.d.ts +8 -5
  17. package/dist/puppeteerTesting/puppeteer/types.d.ts +130 -132
  18. package/dist/puppeteerTesting/vitest/matchers/index.d.ts +33 -30
  19. package/dist/testing/index.d.ts +4 -11
  20. package/dist/testing/mount.d.ts +113 -93
  21. package/dist/testing/wrapController.d.ts +5 -11
  22. package/dist/useLumina.d.ts +5 -2
  23. package/package.json +15 -7
  24. package/dist/context/logger.d.ts +0 -8
  25. package/dist/context/typeScript.d.ts +0 -6
  26. package/dist/context/utils.d.ts +0 -4
  27. package/dist/dependencies/arcgisCore.d.ts +0 -30
  28. package/dist/dependencies/index.d.ts +0 -12
  29. package/dist/dependencies/loaders.d.ts +0 -5
  30. package/dist/dependencies/lumina.d.ts +0 -3
  31. package/dist/dependencies/stencil.d.ts +0 -17
  32. package/dist/dependencies/testSetupFiles.d.ts +0 -13
  33. package/dist/dependencies/utils.d.ts +0 -15
  34. package/dist/docs/config.d.ts +0 -9
  35. package/dist/docs/index.d.ts +0 -10
  36. package/dist/docs/stencilDocsJson.d.ts +0 -130
  37. package/dist/docs/types.d.ts +0 -1
  38. package/dist/docs/vsCodeCustomData/index.d.ts +0 -16
  39. package/dist/docs/vsCodeCustomData/utils.d.ts +0 -3
  40. package/dist/docs/webTypes/description.d.ts +0 -2
  41. package/dist/docs/webTypes/index.d.ts +0 -19
  42. package/dist/docs/webTypes/utils.d.ts +0 -6
  43. package/dist/entrypoints/addNonLazyImports.d.ts +0 -13
  44. package/dist/entrypoints/config.d.ts +0 -17
  45. package/dist/entrypoints/dtsUtils.d.ts +0 -19
  46. package/dist/entrypoints/findUtils.d.ts +0 -6
  47. package/dist/entrypoints/handleComponentImports.d.ts +0 -13
  48. package/dist/entrypoints/resolveTagName.d.ts +0 -18
  49. package/dist/jsxToLitHtml/autoAddNothing.d.ts +0 -8
  50. package/dist/jsxToLitHtml/comments.d.ts +0 -19
  51. package/dist/jsxToLitHtml/convertProps.d.ts +0 -10
  52. package/dist/jsxToLitHtml/imports.d.ts +0 -27
  53. package/dist/jsxToLitHtml/importsConfig.d.ts +0 -17
  54. package/dist/jsxToLitHtml/index.d.ts +0 -20
  55. package/dist/jsxToLitHtml/inferPropType.d.ts +0 -40
  56. package/dist/jsxToLitHtml/insertRepeatCall.d.ts +0 -51
  57. package/dist/jsxToLitHtml/jsxVisitor.d.ts +0 -15
  58. package/dist/jsxToLitHtml/templateParts.d.ts +0 -17
  59. package/dist/jsxToLitHtml/throwOnImportingExternalized.d.ts +0 -10
  60. package/dist/jsxToLitHtml/types.d.ts +0 -74
  61. package/dist/jsxToLitHtml/utils.d.ts +0 -14
  62. package/dist/loader/css.d.ts +0 -20
  63. package/dist/loader/extractor.d.ts +0 -2
  64. package/dist/loader/index.d.ts +0 -21
  65. package/dist/loader/lazy.d.ts +0 -21
  66. package/dist/loader/storybookApiJson.d.ts +0 -6
  67. package/dist/plugins/buildCdn.d.ts +0 -73
  68. package/dist/plugins/buildWebApp.d.ts +0 -3
  69. package/dist/plugins/buildWrappers.d.ts +0 -4
  70. package/dist/plugins/configureVite.d.ts +0 -20
  71. package/dist/plugins/externalizeDependencies.d.ts +0 -30
  72. package/dist/plugins/handleDynamicAssets.d.ts +0 -8
  73. package/dist/plugins/handleStaticAssets.d.ts +0 -9
  74. package/dist/plugins/loadLitCss.d.ts +0 -127
  75. package/dist/plugins/printTotalBuildSize.d.ts +0 -7
  76. package/dist/plugins/provideAssets.d.ts +0 -35
  77. package/dist/plugins/setAssetsPath.d.ts +0 -10
  78. package/dist/plugins/updatePackageJson.d.ts +0 -14
  79. package/dist/publicTypes.d.ts +0 -653
  80. package/dist/puppeteerTesting/globalSetup.d.ts +0 -73
  81. package/dist/puppeteerTesting/injected.d.ts +0 -8
  82. package/dist/puppeteerTesting/puppeteer/browser.d.ts +0 -6
  83. package/dist/puppeteerTesting/vitest/matchers/attributes.d.ts +0 -4
  84. package/dist/puppeteerTesting/vitest/matchers/classList.d.ts +0 -4
  85. package/dist/puppeteerTesting/vitest/matchers/events.d.ts +0 -7
  86. package/dist/puppeteerTesting/vitest/matchers/text.d.ts +0 -2
  87. package/dist/puppeteerTesting/vitest/matchers/utils.d.ts +0 -1
  88. package/dist/puppeteerTesting/vitest/runner.d.ts +0 -19
  89. package/dist/puppeteerTesting/vitest/setupFile.d.ts +0 -1
  90. package/dist/puppeteerTesting/vitest/types.d.ts +0 -6
  91. package/dist/testing/failOnConsole.d.ts +0 -6
  92. package/dist/testing/setupFile.d.ts +0 -1
  93. package/dist/testing/snapshotSerializer.d.ts +0 -12
  94. package/dist/tests/utils.d.ts +0 -4
  95. package/dist/transformers/customElementDeclaration.d.ts +0 -2
  96. package/dist/transformers/index.d.ts +0 -20
  97. package/dist/transformers/injectRuntimeOptions.d.ts +0 -18
  98. package/dist/transformers/liftDecorators.d.ts +0 -21
  99. package/dist/transformers/members.d.ts +0 -10
  100. package/dist/transformers/property.d.ts +0 -10
  101. package/dist/transformers/propertyOptions.d.ts +0 -110
  102. package/dist/transformers/utils.d.ts +0 -9
@@ -1,40 +0,0 @@
1
- import { default as ts } from 'typescript';
2
- import { dynamicHtmlSymbol, dynamicSvgSymbol } from './config.ts';
3
- /**
4
- * Check if prop initializer has bindProperty(), bindAttribute(),
5
- * bindBooleanAttribute() or bindEvent() call - these explicitly indicate the
6
- * prop type.
7
- *
8
- * @remarks
9
- * Not checking for now if function is actually coming from `@arcgis/lumina` - if
10
- * this is an issue, can add later
11
- */
12
- export declare function checkExplicitPropType(initializer: ts.JsxAttributeValue | undefined): {
13
- readonly propType: JsxPropType;
14
- readonly initializer: ts.JsxExpression | undefined;
15
- } | undefined;
16
- /**
17
- * Decide whether a JSX prop should be converted to property, attribute or event
18
- *
19
- * Unless there is a good reason to do otherwise, most props are converted into
20
- * properties rather than attributes. Reasons:
21
- * - For third-party web components, since we are consuming them in JSX, the
22
- * typings will most likely include names of properties not attributes.
23
- * - Setting attributes is more bug-prone in lit as `a=${undefined}` is still
24
- * considered truthy (you have to use `a=${nothing}` to unset an attribute)
25
- * - If you want to conditionally display a boolean html attribute, there is
26
- * the `?a=${someBoolean}` syntax.
27
- * - The above two cases add complexity and bugs - properties are much simpler
28
- * - Setting property is more performant than setting attribute
29
- *
30
- * For most HTML attributes, setting the property will reflect to the attribute.
31
- * If the third-party web component expects to have the attribute set (for
32
- * styling or other reasons), it should reflect the property.
33
- * There are also flag functions available (bindAttribute and etc) if you
34
- * explicitly want to overwrite the below prop type inference logic.
35
- */
36
- export declare function inferPropType(propName: string, initializer: ts.JsxAttributeValue | undefined, tagName: string | typeof dynamicHtmlSymbol | typeof dynamicSvgSymbol): JsxPropType;
37
- declare const specialPropsArray: readonly ["class", "style", "ref", "directives", "key", "deferLoad"];
38
- type SpecialProp = (typeof specialPropsArray)[number];
39
- export type JsxPropType = SpecialProp | "attribute" | "booleanAttribute" | "event" | "property";
40
- export {};
@@ -1,51 +0,0 @@
1
- import { default as ts } from 'typescript';
2
- import { JsxContext } from './types.ts';
3
- /**
4
- * By default, when we see a `key=""` prop, we convert it like this:
5
- * ```tsx
6
- * // before:
7
- * <div key="value" />
8
- * // after:
9
- * keyed('value', html`<div></div>`);
10
- * ```
11
- *
12
- * However, when mapping over items, if key was provided, using `repeat()` Lit
13
- * directive is better for performance as that directive can track when items
14
- * change order.
15
- *
16
- * Without repeat, calling `keyed()` inside of `.map()` is going to be quite
17
- * expensive when a single item is added to the top - that will destroy each
18
- * element below it and re-create it.
19
- *
20
- * When key wasn't provided, we assume that the order of items is static or that
21
- * modifying the item dom node is cheaper than getting the key and reordering.
22
- *
23
- * We could have the Stencil to Lit codemod do the `.map()` to `repeat()`
24
- * conversion in cases when the map was given an arrow function with a JSX
25
- * element with a key, however, some issues with that:
26
- *
27
- * - For people coming from Stencil or React, it would be confusing to see
28
- * `repeat()` in the code rather than the familiar `.map()`.
29
- * - People may not know when to use which, or forget and use `.map()` with a
30
- * `key` inside.
31
- * - Since many JSX frameworks handle `key` inside a `.map()` correctly, if in
32
- * the future we move from Lit, it would be nice to have the `key` prop
33
- * already in the source code.
34
- *
35
- * Thus, instead of doing the conversion in the codemod, I am doing it at build
36
- * time in the _JSX to lit-html_ transformer.
37
- *
38
- * If we were to do this in the codemod, the same code would have to be written
39
- * anyway, but here we get ongoing benefit of having code always using the
40
- * correct, performant pattern.
41
- *
42
- * We are only replacing `.map()` with `repeat()` if the map JSX element has a
43
- * key prop. There may be some more complex patterns where key was used that we
44
- * can't yet detect - those may have worse performance, but the developer can
45
- * always call `repeat()` manually.
46
- *
47
- * @see https://github.com/lit/lit.dev/issues/1351
48
- */
49
- export declare function maybeInsertRepeatCall(context: JsxContext, node: ts.CallExpression): ts.CallExpression;
50
- export declare const unwrapExpression: <T extends ts.Node>(expression: T) => T | ts.Expression;
51
- export declare const isLiftedKey: (name: ts.JsxAttributeName, context: JsxContext) => boolean;
@@ -1,15 +0,0 @@
1
- import { default as ts } from 'typescript';
2
- import { TemplatePart } from './templateParts.ts';
3
- import { JsxContext } from './types.ts';
4
- /**
5
- * Recursively traverse the entire AST top-down, converting JSX to lit-html.
6
- */
7
- export declare function jsxVisitor<Type extends ts.Node = ts.Node>(context: JsxContext,
8
- /**
9
- * Only provide this if the node is in a place where we have to guard against
10
- * rendering "false" to the screen (as lit-html as an anti-feature of
11
- * rendering booleans as strings rather than ignoring them)
12
- */
13
- parent: ts.Node | undefined, node: Type): Type;
14
- export declare const findKeyPropertyIndex: (jsxElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement) => number;
15
- export declare function jsxExpressionToTemplateParts(context: JsxContext, jsxExpression: ts.JsxExpression, parent: Parameters<typeof jsxVisitor>[1]): [] | [TemplatePart];
@@ -1,17 +0,0 @@
1
- import { default as ts } from 'typescript';
2
- import { JsxContext, LitTag, ambiguousSvgTag } from './types.ts';
3
- /**
4
- * Template part is a convenient intermediate representation for template
5
- * literal expressions.
6
- *
7
- * String template literal parts will be joined together, and expressions will
8
- * be put inside of `${}`.
9
- */
10
- export type TemplatePart = ts.Expression | string;
11
- export type JsxHostTemplateParts = {
12
- readonly key: ts.Expression | undefined;
13
- readonly parts: TemplatePart[];
14
- readonly litTag: LitTag | typeof ambiguousSvgTag | undefined;
15
- };
16
- export declare const isNonEmptyTemplatePart: (part: TemplatePart) => boolean;
17
- export declare function templatePartsToLitExpression({ key, parts, litTag }: JsxHostTemplateParts, context: JsxContext): ts.Expression;
@@ -1,10 +0,0 @@
1
- import { JsxContext } from './types.ts';
2
- /**
3
- * Throw if encountered an explicit non-type-only import for a Calcite component
4
- * or some `@arcgis/*` component package - such packages should be externalized,
5
- * so there should not be explicit imports from them (otherwise, they would get
6
- * bundled in)
7
- *
8
- * If there are exceptions to this rule, please notify Lumina maintainers.
9
- */
10
- export declare function throwOnImportingExternalized(context: JsxContext): [];
@@ -1,74 +0,0 @@
1
- import { default as ts } from 'typescript';
2
- import { ResolvedDependencyComponents } from '../dependencies/discover.ts';
3
- import { CompilerContext } from '../context/index.ts';
4
- export type JsxContext = {
5
- readonly compiler: CompilerContext;
6
- /** Source file before the _JSX to lit-html_ transformation */
7
- readonly sourceFile: ts.SourceFile;
8
- readonly transformationContext: ts.TransformationContext;
9
- /**
10
- * All encountered native HTML elements and custom-elements along with a
11
- * reference to a TypeScript JSX node where first occurrence was. You can use
12
- * the TypeScript node to find the location where component was declared and
13
- * thus inform what import paths need to be added in the current file.
14
- *
15
- * If you successfully resolved some element from this map, then please
16
- * remove it from the map to not confuse any following resolvers.
17
- */
18
- readonly customElementsToImport: Set<string>;
19
- readonly customElementsToImportDeferred: Set<string>;
20
- /**
21
- * Existing imported modules.
22
- *
23
- * If original specifier was for an external package, this will include the
24
- * specifier as is.
25
- *
26
- * If original specifier was to a relative file, the path will be resolved
27
- * to an absolute path, but without a file extension.
28
- *
29
- * Can be used to inform what custom elements are already imported
30
- */
31
- readonly existingImportedModules: Set<string>;
32
- /**
33
- * A set of absolute paths to modules in the current package from which the
34
- * current file imported capitalized identifiers (capitalized identifier is
35
- * often a functional component, though not always)
36
- */
37
- readonly importedFunctionComponentsFromModules: Set<string>;
38
- readonly existingLitImports: Set<JsxImportName>;
39
- /**
40
- * If there already is an identifier with a given name in the class, rename
41
- * the imported identifier to avoid conflicts.
42
- */
43
- readonly importRenames: Record<JsxImportName, string>;
44
- readonly neededImports: Set<JsxImportName>;
45
- readonly externalComponents: ResolvedDependencyComponents["components"];
46
- readonly localComponents: ResolvedDependencyComponents["components"];
47
- /**
48
- * `key={}` attributes that were converted to `repeat()` calls and thus should
49
- * not be converted to `keyed()` directives.
50
- */
51
- readonly liftedKeys: Set<ts.JsxAttributeName>;
52
- readonly isInLightDomComponent: boolean;
53
- hasNonLuminaJsxImport: boolean;
54
- };
55
- /**
56
- * Funny that lit called the "dynamic html" version of "html" as "staticHtml"
57
- */
58
- export declare const staticHtmlTag = "staticHtml";
59
- export declare const staticSvgTag = "staticSvg";
60
- export declare const htmlTag = "html";
61
- export declare const svgTag = "svg";
62
- export declare const ambiguousSvgTag: unique symbol;
63
- export declare const cssTag = "css";
64
- export declare const mathMlTag = "mathml";
65
- declare const litTagsArray: readonly ["css", "html", "mathml", "staticHtml", "staticSvg", "svg"];
66
- export declare const litTags: Set<"html" | "svg" | "css" | "mathml" | "staticHtml" | "staticSvg">;
67
- export type LitTag = (typeof litTagsArray)[number];
68
- export declare const jsxImportNames: readonly ["keyed", "ref", "repeat", "live", "css", "html", "mathml", "staticHtml", "staticSvg", "svg", "safeClassMap", "safeStyleMap", "deferLoad", "stabilizedRef", "nothing"];
69
- export type JsxImportName = (typeof jsxImportNames)[number];
70
- export type JsxHost = ts.JsxElement | ts.JsxFragment | ts.JsxSelfClosingElement;
71
- /** Returns `true` if the given node is an array expression containing jsx nodes */
72
- export declare const isJsxArray: (node: ts.Node) => node is ts.ArrayLiteralExpression;
73
- export declare const isJsxHost: (node: ts.Node) => node is JsxHost;
74
- export {};
@@ -1,14 +0,0 @@
1
- /**
2
- * Trim whitespace in the jsx text where safe, without breaking cases like this:
3
- * ```tsx
4
- * <p>Format: {text}</p>
5
- * ```
6
- *
7
- * This does not handle some cases if they are already handled by Prettier
8
- * (like trailing whitespace on a line, or two consecutive non-indent white-spaces)
9
- */
10
- export declare function safeTrimText(text: string): string;
11
- export declare const escapeForTemplateLiteral: (string: string) => string;
12
- export declare const shouldQuoteAttributeValue: (value: string) => boolean;
13
- export declare const escapeForHtml: (string: string) => string;
14
- export declare const isCustomElement: (tagName: string | symbol) => tagName is string;
@@ -1,20 +0,0 @@
1
- import { CompilerContext } from '../context/index.ts';
2
- export declare function addGlobalCss(context: Pick<CompilerContext, "_globalHydratedCssString" | "apiJsonComponents" | "dir" | "isInStorybook" | "options" | "shouldMinify" | "viteCommand">): 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: Pick<CompilerContext, "_globalHydratedCssString" | "shouldMinify">): string;
12
- /**a
13
- * Get a CSS string that can be printed into a .css file
14
- *
15
- * Global CSS is auto-imported by bundlers. To ensure it is always loaded with
16
- * lower precedence order than user styles, we wrap it in `@layer{}`.
17
- *
18
- * @see https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/1824#discussioncomment-12625
19
- */
20
- export declare const getGlobalCssAsString: (context: CompilerContext) => string;
@@ -1,2 +0,0 @@
1
- import { CompilerContext } from '../context/index.ts';
2
- export declare function configureApiExtractor(context: CompilerContext): Promise<void>;
@@ -1,21 +0,0 @@
1
- import { Plugin as VitePlugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
3
- /**
4
- * Generate virtual files:
5
- * - loader.ts (for lazy loading components)
6
- * - to generate this file, this plugin also generates api.json, and
7
- * re-generates it in HMR
8
- * - setup files for tests
9
- *
10
- * The generated api.json is then used by componentTransformPipeline() and by
11
- * generateDocs(), among others.
12
- */
13
- export declare function generateVirtualFiles(context: CompilerContext): readonly [VitePlugin, VitePlugin, VitePlugin];
14
- /**
15
- * This function alone won't trigger a page refresh. However, if a page
16
- * is reloaded separately (by the browser or by lumina-compiler), the load()
17
- * plugin hook for loader.ts will be triggered, which would include updated
18
- * lazy meta
19
- */
20
- export declare function clearLoaderTsCache(context: CompilerContext): void;
21
- export declare const requestServerReload: (context: CompilerContext) => void;
@@ -1,21 +0,0 @@
1
- import { CompilerContext } from '../context/index.ts';
2
- import { HmrComponentMeta } from '@arcgis/lumina/hmrSupport';
3
- import { ApiCustomElementDeclaration } from '@arcgis/api-extractor/apiJson';
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 buildLoaderTs(context: Pick<CompilerContext, "_globalHydratedCssString" | "apiJson" | "apiJsonComponents" | "dir" | "hmrEnabled" | "isInStorybook" | "options" | "privateApiJson" | "shouldMinify" | "viteCommand">): string;
12
- /**
13
- * For each component, build as compact definition as possible of all the public
14
- * properties, attributes, asynchronous methods and synchronous methods.
15
- */
16
- declare function buildCompactLazyMeta(customElement: Pick<ApiCustomElementDeclaration, "formAssociated" | "members" | "tagName">): string;
17
- export declare function buildLazyMeta(customElement: Pick<ApiCustomElementDeclaration, "formAssociated" | "members" | "tagName">): HmrComponentMeta;
18
- export declare const exportsForTests: {
19
- buildCompactLazyMeta: typeof buildCompactLazyMeta;
20
- };
21
- export {};
@@ -1,6 +0,0 @@
1
- import { ApiJson } from '@arcgis/api-extractor/apiJson';
2
- /**
3
- * Providing api.json to Storybook.
4
- * See https://github.com/storybookjs/storybook/tree/next/code/addons/docs/web-components
5
- */
6
- export declare function createStorybookApiJsonSetter(manifest: ApiJson): string;
@@ -1,73 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
3
- import { CdnChunk } from '../publicTypes.ts';
4
- /**
5
- * Restricted due to collisions with Lumina's dist/ folder names or
6
- * Stencil's dist/ folder names
7
- */
8
- export declare const restrictedNamespaceNames: Set<string>;
9
- export declare const defaultNamespace = "cdn";
10
- export declare const defaultEntryJsName = "index";
11
- export declare const globalCssName = "main";
12
- /**
13
- * CDN build works by reading the lazy NPM build and bundling-in all used
14
- * dependencies (except for imports of web components from dependencies - those
15
- * are assumed to be defined in the environment separately)
16
- */
17
- export declare function buildCdn(context: CompilerContext): Plugin | undefined;
18
- /**
19
- * Transform each core-importing chunk to use $arcgis.t for loading core in
20
- * order to be both ESM and AMD CDN compatible.
21
- *
22
- * Previous solution
23
- * (https://devtopia.esri.com/WebGIS/arcgis-web-components/pull/2995) relied on
24
- * top-level await. However, due to a Safari bug
25
- * (see https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/3933
26
- * and https://bugs.webkit.org/show_bug.cgi?id=242740), we are no longer using
27
- * top-level await.
28
- *
29
- * Instead, we insert a top-level await polyfill - any module that imports core
30
- * directly or indirectly is transformed to have a promise as a default export -
31
- * such promise, once awaited, yields the actual exports of the module.
32
- *
33
- * List of other solutions considered:
34
- * https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/3999
35
- *
36
- * @example
37
- * ```js
38
- * /// BEFORE
39
- * import { b } from "./U7MU7PMX.js";
40
- * import { when as M } from "@arcgis/core/core/reactiveUtils.js";
41
- * var s = class extends v {
42
- * // ...
43
- * };
44
- * export { s as ArcgisNavigationToggle };
45
- *
46
- * /// AFTER
47
- * import a from "./U7MU7PMX.js";
48
- * export default $arcgis.t(
49
- * ([{ when: M }, { b }]) => {
50
- * // The "meat" of the file is kept unchanged by the transform
51
- * // (we only touch the imports, and the very last export line)
52
- * s = class extends v {
53
- * // ...
54
- * };
55
- * // Resolve the promise by returning the exported class
56
- * return s;
57
- * },
58
- * "core/reactiveUtils",
59
- * a,
60
- * );
61
- * ```
62
- */
63
- declare function transformChunk(chunk: CdnChunk, chunks: Map<string, CdnChunk>): void;
64
- /**
65
- * Given set of identifiers, produce the shortest possible ASCII-only identifier.
66
- * We restrict to ASCII-range as it is faster to parse for engines.
67
- */
68
- declare function createIdentifierGenerator(seen: Set<string>): () => string;
69
- export declare const exportsForTests: {
70
- transformChunk: typeof transformChunk;
71
- createIdentifierGenerator: typeof createIdentifierGenerator;
72
- };
73
- export {};
@@ -1,3 +0,0 @@
1
- import { CompilerContext } from '../context/index.ts';
2
- /** @deprecated */
3
- export declare function buildWebApp(context: CompilerContext, rawDestination: string, cdnEntryName: string): Promise<void>;
@@ -1,4 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
3
- /** @deprecated */
4
- export declare function buildWrappers(context: CompilerContext): Plugin;
@@ -1,20 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
3
- import { InlineConfig } from 'vitest/node';
4
- import { PuppeteerTestingOptions } from '../publicTypes.ts';
5
- export type PuppeteerVitestConfigOptions = InlineConfig & {
6
- puppeteerLaunchOptions?: PuppeteerTestingOptions["launchOptions"];
7
- puppeteerWaitForChangesDelay?: number;
8
- };
9
- /**
10
- * Plugin to set up the common Vite configuration.
11
- *
12
- * @remarks
13
- * In order to respect the options user provided directly to Vite, we must
14
- * apply the user-provided options, and only fallback to our value if user did
15
- * not set a value.
16
- * Though, as per Vite's config merge logic, we only need to look up the default
17
- * value for literal value properties - objects and arrays are merged.
18
- * https://github.com/vitejs/vite/blob/bb4ba9f448da01782f585369f80c4517da087000/packages/vite/src/node/utils.ts#L1074
19
- */
20
- export declare const configureVite: (context: CompilerContext) => Plugin;
@@ -1,30 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
3
- /**
4
- * By default, Rollup will bundle-in all dependencies.
5
- *
6
- * We change it as follows:
7
- * Externalize all packages that are defined as
8
- * "dependency" or "peerDependency" in the package.json.
9
- * If you wish to bundle-in some package, define it as a "devDependency".
10
- *
11
- * Bundling-in packages is not recommended because:
12
- * - it makes our build take longer
13
- * - it pushes larger packages to NPM
14
- * - user of our library is locked into the version of the package we bundled in
15
- * - if user has two packages using the same library, there will be two copies
16
- * served on the page
17
- * - It may break some libraries/prevent them from optimizing correctly
18
- * depending on the production/development mode, or prevent them from loading
19
- * correct code depending on browser/node.js environment.
20
- *
21
- * For example, see this statement from Lit:
22
- * https://lit.dev/docs/ssr/authoring/#:~:text=Don%27t%20bundle%20Lit,based%20on%20environment.
23
- *
24
- * @see {@link ./buildCdn.ts} for CDN dependency bundling details
25
- *
26
- * @remarks
27
- * If a dependency is both a peerDependency and a devDependency, it will still
28
- * be externalized (because all peerDependencies are externalized).
29
- */
30
- export declare function externalizeDependencies(context: CompilerContext): Plugin;
@@ -1,8 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
3
- /**
4
- * Handle emit and serve for dynamically generated assets.
5
- * These assets are added by Lumina's plugins, as well as can be added by the
6
- * Lumina component package via the `assets.extra` option.
7
- */
8
- export declare const handleDynamicAssets: (context: CompilerContext) => Plugin;
@@ -1,9 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
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;
@@ -1,127 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
3
- /**
4
- * CSS extension list taken from https://github.com/vitejs/vite/blob/a8c7083a3d7d7fe2e83e994ff008f39ee4f298f8/packages/vite/src/node/constants.ts#L50
5
- */
6
- export declare const cssLangsRe: RegExp;
7
- /**
8
- * A flag added by Lumina at compile time to named CSS imports to turn
9
- * them into Lit css`` tagged template literals (using `styles` named import).
10
- *
11
- * We do not automatically process every CSS file to allow for both:
12
- * - keeping side-effect CSS imports inside external library code as is
13
- * - tricky to do using resolveId() because ESBuild is used for some files in
14
- * dev server.
15
- * - explicitly importing external library's CSS as Lit css into shadow root
16
- * - example: monaco or ckeditor styles, but attached into shadow root, rather
17
- * than global
18
- */
19
- export declare const litCssFlag = "?litCss";
20
- /**
21
- * The `.adoptedStyleSheets` API is very convenient, but it has one issue: it
22
- * has higher precedence order than the `<link>` or `<style>` tags. This API was
23
- * designed with apps in mind, not libraries.
24
- *
25
- * As a workaround, we are wrapping the CSS in a `@layer {}` syntax to reduce
26
- * it's precedence.
27
- *
28
- * More information:
29
- * https://discord.com/channels/1012791295170859069/1274527043614150708
30
- */
31
- export declare const layeredLitCssFlag = "?layeredLitCss";
32
- /**
33
- * Vite's library mode has CSS support (https://vite.dev/guide/build.html#css-support).
34
- * However, if global css file references assets, the library mode will insert
35
- * the assets base path in the CSS file. This does not work for us since the
36
- * asset path is determined at runtime - provided by the user.
37
- *
38
- * Additionally, Vite's library mode css handling does not quite fit our use case:
39
- * - We need to transform the global CSS to add hydrate CSS
40
- * - Trickier given that we need to emit hydrate CSS even if user did not
41
- * provide global css
42
- * - Vite has css chunking support, which we don't need
43
- * - We need to add an import for our CSS file (and those of libraries we are
44
- * consuming) in runtime.ts, without processing the external CSS files
45
- *
46
- * It is possible to make Vite's library mode css work, but requires too much
47
- * effort. Instead, we are bypassing Vite's global CSS handling and doing the
48
- * simple handling sufficient for our single global css file:
49
- * - During build, we insert a import into the loader.ts file purely
50
- * so that the transform() is triggered for that file so that we can piggy back
51
- * on the transformed output (and create a separate .css file out of it).
52
- * Such import has no side-effects and is removed by Rollup.
53
- *
54
- * This is the only way to trigger the CSS transform without getting it added
55
- * to the bundle because of this Vite behavior:
56
- * https://github.com/vitejs/vite/pull/11469#:~:text=Further%2C%20this.load%20is%20supposed%20to%20trigger%20transform%20and%20moduleParsed%20%2D%20this%20does%20not%20(in%20accordance%20with%20vite%27s%20on%2Ddemand%20nature
57
- * - We manually write dist/main.css based on hydrate CSS and global CSS.
58
- * - During generateBundle() stage, we transform the emitted chunks/runtime.js
59
- * to add the import to global CSS for our library and web component libraries
60
- * we are consuming. We do this in generateBundle() stage so that such imports
61
- * are not processed by bundler. Additionally, our loadLitCss plugin's
62
- * transform() has a detection of side-effect CSS imports to error for them
63
- * saying they should be import as named to be added to the shadow root - by
64
- * doing this in generateBundle(), we bypass that check.
65
- */
66
- export declare const globalCssFileFlag = "?globalFileLitCss";
67
- /**
68
- * Given a CSS file like:
69
- *
70
- * ```css
71
- * // counter.css
72
- * :host {
73
- * display: flex;
74
- * gap: 1rem;
75
- * }
76
- * button {
77
- * padding: 1rem;
78
- * }
79
- * ```
80
- *
81
- * and an import like this:
82
- *
83
- * ```ts
84
- * import styles from './counter.css';
85
- * export class ArcgisCounter extends LitElement {
86
- * static override styles = [styles];
87
- * }
88
- * ```
89
- *
90
- * This plugin will tell Vite to inline the css file (rather than produce a
91
- * separate asset). Vite transformer will transform the css file into this:
92
- *
93
- * ```js
94
- * export default ":host{display:flex;gap:1rem}button{padding:1rem}"
95
- * ```
96
- *
97
- * Then, we augment it into this:
98
- * ```js
99
- * import { css } from 'lit/css-tag.js';
100
- * const styles = css`:host{display:flex;gap:1rem}button{padding:1rem}`;
101
- * export default styles;
102
- * ```
103
- *
104
- * The Lumina runtime later loads it like this:
105
- *
106
- * ```js
107
- * host.adoptedStyleSheets = [...document.adoptedStyleSheets, styles.styleSheet];
108
- * // Host is the shadow root of the component for shadow root components. Host
109
- * // is the document for non-shadow root components or global styles.
110
- * ```
111
- *
112
- * @remarks
113
- * We inline the css rather than produce a separate asset because:
114
- * - Loading assets adds complexity:
115
- * - need to call getAssetPath() to get correct asset location
116
- * (can't do that easily in a .css file)
117
- * - the consuming application might not have had the chance to call
118
- * setAssetPath() yet when getAssetPath() is called by us
119
- * - the network request might fail
120
- * - Loading assets creates "a flash of unstyled content" issue (i.e font
121
- * changing after being loaded)
122
- *
123
- * Same goes for assets references inside the css file (icons and fonts) - they
124
- * will be inlined as base64 to simplify our life.
125
- */
126
- export declare const loadLitCss: (context: CompilerContext) => Plugin;
127
- export declare function viteCssModuleToLit(code: string, withHmr: boolean, minify: boolean, isLayered: boolean): string;
@@ -1,7 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
3
- /**
4
- * Augmenting vite's default reporter to not just report bundle sizes, but to
5
- * also print the total size
6
- */
7
- export declare const printTotalBuildSize: (context: CompilerContext) => Plugin;
@@ -1,35 +0,0 @@
1
- import { CompilerContext } from '../context/index.ts';
2
- import { AssetSpec, AssetTransformer } from '../publicTypes.ts';
3
- import { ContextDirectories } from '../context/types.ts';
4
- export declare function serveAssets(context: CompilerContext, assets: AssetSpec[], transformers?: AssetTransformer[]): void;
5
- export declare function writeAssets(context: CompilerContext, assets: AssetSpec[], transformers?: AssetTransformer[]): Promise<void>;
6
- /**
7
- * If trying to serve a file and destination does not include file name, take
8
- * file name from source
9
- */
10
- declare function addImplicitDistFileName(spec: AssetSpec): string;
11
- /**
12
- * Taking an absolute or relative destination path, resolve it as follows:
13
- * - Make absolute path be relative to the output base
14
- * - Prepend relative path with the serve base
15
- * - Ensure the resulting path does not escape above the output directory
16
- * - Ensure the path separators are correct for the current system
17
- */
18
- declare function resolveDistPath({ dist, distCdnAssets }: Pick<ContextDirectories, "dist" | "distCdnAssets">, rawDestination: string): string;
19
- /**
20
- * Take a resolved absolute file path in the dist directory, and from it infer
21
- * the path at which the file will be served.
22
- */
23
- declare function resolveServePath(baseUrl: string, resolvedDistPath: string, distCdnDir: string): string;
24
- /**
25
- * Given an array of absolute paths, make sure a parent directory for each file
26
- * exists
27
- */
28
- export declare function makeDirectoriesForFiles(files: readonly string[]): Promise<void>;
29
- export declare const defaultAssetTransformers: AssetTransformer[];
30
- export declare const exportsForTests: {
31
- addImplicitDistFileName: typeof addImplicitDistFileName;
32
- resolveDistPath: typeof resolveDistPath;
33
- resolveServePath: typeof resolveServePath;
34
- };
35
- export {};
@@ -1,10 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { CompilerContext } from '../context/index.ts';
3
- /**
4
- * Plugin to set the base URL for assets in the package
5
- *
6
- * @remarks
7
- * In `@arcgis/storybook-utils` this plugin is removed so that the original
8
- * base URL is used (./)
9
- */
10
- export declare const setAssetPath: (context: CompilerContext) => Plugin;