@arcgis/lumina-compiler 4.33.0-next.99 → 4.34.0-next.0

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.
@@ -36,7 +36,7 @@ export declare const nativeAlwaysAttributes: Set<string>;
36
36
  * These don't exist as a property, only as an attribute.
37
37
  * Or, the property is read-only, but the attribute is not.
38
38
  */
39
- export declare const htmlAlwaysAttributes: Record<string, Set<string>>;
39
+ export declare const htmlAlwaysAttributes: Record<string, Set<string> | undefined>;
40
40
  /**
41
41
  * The mappings between native DOM property and the equivalent attribute it
42
42
  * reflects to.
@@ -1,6 +1,5 @@
1
1
  import { default as ts } from 'typescript';
2
2
  import { JsxContext } from './types';
3
- export declare const dynamicallyInsertedImportPaths: Set<string>;
4
3
  /**
5
4
  * This runs before we know what imports will be needed.
6
5
  *
@@ -0,0 +1,28 @@
1
+ import { toSystemPathSeparators as i, path as c } from "@arcgis/components-build-utils";
2
+ import a from "chalk";
3
+ import { createLogger as g } from "vite";
4
+ let n = g(), s = process.cwd();
5
+ function e(r, o, t) {
6
+ return typeof t == "string" ? (t = t.startsWith(s) ? i(c.relative(s, t)) : t, t = `${t}: `) : t = "", `${r} ${t}${o}`;
7
+ }
8
+ const f = {
9
+ initialize(r, o) {
10
+ n = r, s = o;
11
+ },
12
+ info(r, o, t) {
13
+ n.info(e(a.cyan(`[${r}]`), o, t));
14
+ },
15
+ warn(r, o, t) {
16
+ n.warn(e(a.yellow(`[${r}]`), o, t));
17
+ },
18
+ error(r, o, t) {
19
+ n.error(e(a.red(`[${r}]`), o, t)), process.exitCode = 1;
20
+ }
21
+ };
22
+ function u(r, o, t) {
23
+ return o instanceof Error ? (o.message = e(r, o.message, t), o) : e(a.red(`[${r}]`), o, t);
24
+ }
25
+ export {
26
+ u as f,
27
+ f as l
28
+ };
@@ -1,21 +1,24 @@
1
1
  import { Plugin } from 'vite';
2
2
  import { CompilerContext } from '../context';
3
+ import { CdnChunk } from '../publicTypes';
3
4
  /**
4
5
  * Restricted due to collisions with Lumina's dist/ folder names or
5
6
  * Stencil's dist/ folder names
6
7
  */
7
8
  export declare const restrictedNamespaceNames: Set<string>;
8
9
  export declare const defaultNamespace = "cdn";
10
+ export declare const defaultEntryJsName = "index";
11
+ export declare const globalCssName = "main";
9
12
  /**
10
13
  * CDN build works by reading the lazy NPM build and bundling-in all used
11
14
  * dependencies (except for imports of web components from dependencies - those
12
15
  * are assumed to be defined in the environment separately)
13
16
  */
14
17
  export declare function buildCdn(context: CompilerContext): Plugin | undefined;
15
- type Chunk = {
16
- code: string;
17
- isAsync: boolean | undefined;
18
- };
18
+ export declare function buildLoaderCode(runtimeVariableName: string, customEntrypoints: {
19
+ in: string;
20
+ out: string;
21
+ }[]): string;
19
22
  /**
20
23
  * Transform each core-importing chunk to use $arcgis.t for loading core in
21
24
  * order to be both ESM and AMD CDN compatible.
@@ -27,9 +30,9 @@ type Chunk = {
27
30
  * and https://bugs.webkit.org/show_bug.cgi?id=242740), we are no longer using
28
31
  * top-level await.
29
32
  *
30
- * Instead, we insert a top-level await polyfill - a promise called $$ is
31
- * exported by core-containing modules - such promise needs to be awaited by the
32
- * consuming modules before the imported variables are available.
33
+ * Instead, we insert a top-level await polyfill - any module that imports core
34
+ * directly or indirectly is transformed to have a promise as a default export -
35
+ * such promise, once awaited, yields the actual exports of the module.
33
36
  *
34
37
  * List of other solutions considered:
35
38
  * https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/3999
@@ -45,43 +48,24 @@ type Chunk = {
45
48
  * export { s as ArcgisNavigationToggle };
46
49
  *
47
50
  * /// AFTER
48
- * // $$ is a promise we need to await before imports from that module are available
49
- * import { $$ as _0, b } from "./U7MU7PMX.js";
50
- * var _1,
51
- * $$ = $arcgis.t(
52
- * ([{ when: M }]) => {
53
- * // The "meat" of the file is kept unchanged by the transform
54
- * // (we only touch the imports, and the very last export line)
55
- * s = class extends v {
56
- * // ...
57
- * };
58
- * // Assign exported variables to global scope variables
59
- * _1 = s;
60
- * },
61
- * "core/reactiveUtils",
62
- * _0,
63
- * );
64
- * // _1 will only be assigned once $$ resolves
65
- * export { $$, _1 as ArcgisNavigationToggle };
66
- * ```
67
- */
68
- declare function transformChunk(chunk: Chunk, chunks: Map<string, Chunk>): void;
69
- /**
70
- * @example Dynamic core import
71
- * ```diff
72
- * - import("core/Handles");
73
- * + $arcgis.t(_=>_[0],"core/Handles")
74
- * ```
75
- *
76
- * @example Dynamic import of a chunk with top-level await
77
- * ```diff
78
- * - import("./chunk.js");
79
- * + import("./chunk.js").then(m=>m.$$.then(_=>m))
51
+ * import a from "./U7MU7PMX.js";
52
+ * export default $arcgis.t(
53
+ * ([{ when: M }, { b }]) => {
54
+ * // The "meat" of the file is kept unchanged by the transform
55
+ * // (we only touch the imports, and the very last export line)
56
+ * s = class extends v {
57
+ * // ...
58
+ * };
59
+ * // Resolve the promise by returning the exported class
60
+ * return s;
61
+ * },
62
+ * "core/reactiveUtils",
63
+ * a,
64
+ * );
80
65
  * ```
81
66
  */
82
- declare function transformDynamicCoreImports(code: string, chunks: Map<string, Chunk>): string;
67
+ declare function transformChunk(chunk: CdnChunk, chunks: Map<string, CdnChunk>): void;
83
68
  export declare const exportsForTests: {
84
- transformDynamicCoreImports: typeof transformDynamicCoreImports;
85
69
  transformChunk: typeof transformChunk;
86
70
  };
87
71
  export {};
@@ -1,9 +1,9 @@
1
1
  import { Plugin } from 'vite';
2
2
  import { CompilerContext } from '../context';
3
- import { PuppeteerLaunchOptions } from 'puppeteer';
4
3
  import { InlineConfig } from 'vitest/node';
4
+ import { PuppeteerTestingOptions } from '../publicTypes';
5
5
  export type PuppeteerVitestConfigOptions = InlineConfig & {
6
- puppeteerLaunchOptions?: PuppeteerLaunchOptions;
6
+ puppeteerLaunchOptions?: PuppeteerTestingOptions["launchOptions"];
7
7
  puppeteerWaitForChangesDelay?: number;
8
8
  };
9
9
  /**
@@ -2,7 +2,7 @@ import { MiniPackageJson } from '@arcgis/components-build-utils';
2
2
  import { CompilerContext } from '../context';
3
3
  import { Plugin } from 'vite';
4
4
  export declare const updatePackageJson: (context: CompilerContext) => Plugin;
5
- declare function doPackageJsonUpdate(packageJson: MiniPackageJson, context: Pick<CompilerContext, "_documentationFileNames" | "dir">): MiniPackageJson | undefined;
5
+ declare function doPackageJsonUpdate(packageJson: MiniPackageJson, context: Pick<CompilerContext, "_documentationFileNames" | "dir" | "options">): MiniPackageJson | undefined;
6
6
  export declare const exportsForTests: {
7
7
  doPackageJsonUpdate: typeof doPackageJsonUpdate;
8
8
  };
@@ -4,10 +4,9 @@ import { build as esbuildBuild } from 'esbuild';
4
4
  import { CompilerContext } from './context';
5
5
  import { PluginOptions as VitePluginDtsOptions } from 'vite-plugin-dts';
6
6
  import { ExternalsOptions as RollupPluginNodeExternalsOptions } from 'rollup-plugin-node-externals';
7
- import { PuppeteerLaunchOptions } from 'puppeteer';
8
7
  import { WebTypesOptions } from './docs/webTypes/types';
9
8
  import { VsCodeDocOptions } from './docs/vsCodeCustomData/types';
10
- import { ApiJson, ApiModule } from '@arcgis/api-extractor';
9
+ import { ApiJson, ApiModule, CopyDocDefinitions } from '@arcgis/api-extractor';
11
10
  import { LuminaApiExtractor } from './extractor/extractor';
12
11
  /**
13
12
  * `useLumina()` returns an array of Vite plugins. The array additionally
@@ -71,6 +70,7 @@ export type BuildOptions = {
71
70
  * Configuration for CDN build.
72
71
  */
73
72
  readonly cdn?: BuildCdnOptions;
73
+ /** @deprecated Use Storybook build or separate test app package. */
74
74
  readonly webApp?: {
75
75
  /**
76
76
  * If set, will produce a web app build, based on index.html files and
@@ -127,19 +127,39 @@ export type BuildCdnOptions = {
127
127
  */
128
128
  readonly skip?: boolean;
129
129
  /**
130
+ * @deprecated To improve CDN experience and simplify redirect handling,
131
+ * deprecated namespace to use consistent CDN folder and file names.
132
+ *
133
+ * Reference: https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/5051#issuecomment-5482327
134
+ *
130
135
  * Determines the CDN folder name and the name of the entrypoint file inside.
131
136
  *
132
137
  * @default "cdn"
133
138
  */
134
139
  readonly namespace?: string;
135
140
  /**
136
- * To produce the CDN build, Lumina takes the lazy-loading build of your
137
- * package, and post-processes it with ESBuild. You can customize the options
138
- * passed to ESBuild.
141
+ * To produce the CDN build, Lumina takes the dist/loader.js file and
142
+ * and post-processes it with ESBuild to make it ready for consumption in the
143
+ * browser.
144
+ *
145
+ * You can customize the options passed to ESBuild. Note, some options may
146
+ * conflict with the Lumina build process.
139
147
  *
140
148
  * @see https://esbuild.github.io/api/#overview
141
149
  */
142
150
  readonly esbuildOptions?: Parameters<typeof esbuildBuild>[0];
151
+ /**
152
+ * A callback for mutating CDN chunks before they are written to disk.
153
+ * This callback is for advanced use cases only. The build output may change
154
+ * between Lumina versions without prior notice. Using this callback may
155
+ * corrupt the CDN source map if it is enabled.
156
+ */
157
+ readonly transformer?: (chunks: Map<string, CdnChunk>, context: CompilerContext) => void;
158
+ };
159
+ export type CdnChunk = {
160
+ code: string;
161
+ isAsync: boolean | undefined;
162
+ oldSingleExportName: string | undefined;
143
163
  };
144
164
  /**
145
165
  * Generic type for the different kinds of wrappers.
@@ -270,9 +290,20 @@ export type PuppeteerTestingOptions = {
270
290
  * @default 0
271
291
  */
272
292
  readonly waitForChangesDelay?: number;
273
- readonly launchOptions?: PuppeteerLaunchOptions;
293
+ /**
294
+ * @example
295
+ * ```ts
296
+ * import type { LaunchOptions } from "puppeteer";
297
+ * // ...
298
+ * launchOptions: {
299
+ * args: ["--no-sandbox", "--disable-setuid-sandbox"],
300
+ * } satisfies LaunchOptions;
301
+ * ```
302
+ */
303
+ readonly launchOptions?: Record<string, unknown>;
274
304
  };
275
305
  export type GenerateDocumentationOptions = {
306
+ readonly copyDefinitions?: CopyDocDefinitions;
276
307
  /**
277
308
  * The name of the file to write the api.json to. api.json is a file format
278
309
  * based on custom-elements-manifest that describes all the components in the
@@ -285,22 +316,39 @@ export type GenerateDocumentationOptions = {
285
316
  * The name of the file to write the Stencil-like docs JSON to.
286
317
  * For backwards compatibility.
287
318
  *
319
+ * @deprecated Use api.json instead.
288
320
  * @default "docs/docs.json"
289
321
  * @see https://stenciljs.com/docs/docs-json
290
322
  */
291
323
  readonly stencilLikeDocsJsonFileName?: string | false;
324
+ /**
325
+ * Get a prefix for a public-facing URL for each component story.
326
+ *
327
+ * @example
328
+ * Set this to "https://developers.arcgis.com/javascript/latest/storybook/map-components/".
329
+ * This will produce URLs like
330
+ * "https://developers.arcgis.com/javascript/latest/storybook/map-components/?path=/story/arcgis-area-measurement-2d--demo&singleStory=true"
331
+ * @see https://qawebgis.esri.com/components/lumina/storybook
332
+ */
333
+ readonly publicStoryUrlPrefix?: string;
292
334
  /**
293
335
  * Provide a URL to a page that documents the component.
294
336
  * This URL will be visible in VS Code and IntelliJ when hovering over a
295
337
  * component tag in an .html file
338
+ *
339
+ * @example (tagName) => `https://developers.arcgis.com/javascript/latest/references/map-components/${tagName}/`
296
340
  */
297
- readonly getComponentDocsUrl?: (tag: string, name: string) => string | undefined;
341
+ readonly getComponentDocsUrl?: (tagName: string, className: string) => string | undefined;
298
342
  /**
299
343
  * Provide a URL to a page that documents the component.
300
344
  * This URL will be visible in VS Code and IntelliJ when hovering over a
301
345
  * component tag in an .html file
346
+ *
347
+ * If you wish to provide multiple URLs, use "getPublicStoryUrl" instead.
348
+ *
349
+ * @example (tagName) => `https://developers.arcgis.com/javascript/latest/storybook/map-components/?path=/story/${tagName}--demo&singleStory=true`
302
350
  */
303
- readonly getComponentDemoUrl?: (tag: string, name: string) => string | undefined;
351
+ readonly getComponentDemoUrl?: (tagName: string, className: string) => string | undefined;
304
352
  /**
305
353
  * Additional options for web component documentation for VS Code. This
306
354
  * documentation provides intellisense when editing .html and .css files.
@@ -425,7 +473,7 @@ export type ApiJsonOptions = {
425
473
  *
426
474
  * @default LuminaApiExtractor
427
475
  */
428
- readonly Extractor: typeof LuminaApiExtractor;
476
+ readonly Extractor?: typeof LuminaApiExtractor;
429
477
  /**
430
478
  * This function will be called after the api.json is created but before it is
431
479
  * used to generate any output files.
@@ -663,14 +711,14 @@ export type AssetTransformer = {
663
711
  };
664
712
  export type LintingOptions = {
665
713
  /**
666
- * Lumina emits build-time errors for common issues and possible bugs.
714
+ * Lumina includes build-time checks for common issues and possible bugs.
667
715
  * Most of those should be immediately addressable. However, some (like
668
716
  * updating default value for boolean properties) may require a breaking
669
717
  * change.
670
718
  *
671
- * This option exists to temporary turn these errors into warnings.
719
+ * This option exists to temporarily turn these errors into warnings.
672
720
  * @example
673
- * To silence an error in a file, add an entry like thw following with the
721
+ * To silence an error in a file, add an entry like the following with the
674
722
  * relative path to the file:
675
723
  *
676
724
  * ```ts
@@ -678,13 +726,6 @@ export type LintingOptions = {
678
726
  * ```
679
727
  */
680
728
  silence: {
681
- /**
682
- * Default values for boolean properties must default to false (or
683
- * undefined), never to true.
684
- *
685
- * [Documentation](https://qawebgis.esri.com/components/lumina/properties#boolean-properties)
686
- */
687
- booleanMustDefaultFalse?: string[];
688
729
  /**
689
730
  * Lumina components may declare required properties using `@required` JSDoc
690
731
  * tag.