@arcgis/lumina-compiler 4.33.0-next.98 → 4.33.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.
@@ -231,6 +251,24 @@ export type DependencyManagementOptions = Omit<RollupPluginNodeExternalsOptions,
231
251
  * technical reasons.
232
252
  */
233
253
  readonly externalize?: NonNullable<RollupPluginNodeExternalsOptions>["include"];
254
+ /**
255
+ * By default, Lumina will error if it encounters usage of an unknown custom
256
+ * element. This setting allows to silence such error if you are manually
257
+ * importing some custom elements.
258
+ *
259
+ * > [!IMPORTANT]
260
+ * >
261
+ * > This option is an escape hatch. Build-time optimizations are not applied
262
+ * > to such custom elements. Additionally, you assume the responsibility for
263
+ * > correctly loading the web component in lazy, non-lazy and CDN builds.
264
+ *
265
+ * @example
266
+ * ```ts
267
+ * // Silence errors for unknown custom elements that start with "fluent-"
268
+ * silenceUnknownJsxElementUsage: (tagName) => tagName.startsWith("fluent-")
269
+ * ```
270
+ */
271
+ readonly silenceUnknownJsxElementUsage?: (tagName: string, fileName: string, context: CompilerContext) => boolean;
234
272
  };
235
273
  export type ServeEnvironmentOptions = {
236
274
  /**
@@ -270,9 +308,20 @@ export type PuppeteerTestingOptions = {
270
308
  * @default 0
271
309
  */
272
310
  readonly waitForChangesDelay?: number;
273
- readonly launchOptions?: PuppeteerLaunchOptions;
311
+ /**
312
+ * @example
313
+ * ```ts
314
+ * import type { LaunchOptions } from "puppeteer";
315
+ * // ...
316
+ * launchOptions: {
317
+ * args: ["--no-sandbox", "--disable-setuid-sandbox"],
318
+ * } satisfies LaunchOptions;
319
+ * ```
320
+ */
321
+ readonly launchOptions?: Record<string, unknown>;
274
322
  };
275
323
  export type GenerateDocumentationOptions = {
324
+ readonly copyDefinitions?: CopyDocDefinitions;
276
325
  /**
277
326
  * The name of the file to write the api.json to. api.json is a file format
278
327
  * based on custom-elements-manifest that describes all the components in the
@@ -285,22 +334,39 @@ export type GenerateDocumentationOptions = {
285
334
  * The name of the file to write the Stencil-like docs JSON to.
286
335
  * For backwards compatibility.
287
336
  *
337
+ * @deprecated Use api.json instead.
288
338
  * @default "docs/docs.json"
289
339
  * @see https://stenciljs.com/docs/docs-json
290
340
  */
291
341
  readonly stencilLikeDocsJsonFileName?: string | false;
342
+ /**
343
+ * Get a prefix for a public-facing URL for each component story.
344
+ *
345
+ * @example
346
+ * Set this to "https://developers.arcgis.com/javascript/latest/storybook/map-components/".
347
+ * This will produce URLs like
348
+ * "https://developers.arcgis.com/javascript/latest/storybook/map-components/?path=/story/arcgis-area-measurement-2d--demo&singleStory=true"
349
+ * @see https://qawebgis.esri.com/components/lumina/storybook
350
+ */
351
+ readonly publicStoryUrlPrefix?: string;
292
352
  /**
293
353
  * Provide a URL to a page that documents the component.
294
354
  * This URL will be visible in VS Code and IntelliJ when hovering over a
295
355
  * component tag in an .html file
356
+ *
357
+ * @example (tagName) => `https://developers.arcgis.com/javascript/latest/references/map-components/${tagName}/`
296
358
  */
297
- readonly getComponentDocsUrl?: (tag: string, name: string) => string | undefined;
359
+ readonly getComponentDocsUrl?: (tagName: string, className: string) => string | undefined;
298
360
  /**
299
361
  * Provide a URL to a page that documents the component.
300
362
  * This URL will be visible in VS Code and IntelliJ when hovering over a
301
363
  * component tag in an .html file
364
+ *
365
+ * If you wish to provide multiple URLs, use "getPublicStoryUrl" instead.
366
+ *
367
+ * @example (tagName) => `https://developers.arcgis.com/javascript/latest/storybook/map-components/?path=/story/${tagName}--demo&singleStory=true`
302
368
  */
303
- readonly getComponentDemoUrl?: (tag: string, name: string) => string | undefined;
369
+ readonly getComponentDemoUrl?: (tagName: string, className: string) => string | undefined;
304
370
  /**
305
371
  * Additional options for web component documentation for VS Code. This
306
372
  * documentation provides intellisense when editing .html and .css files.
@@ -346,7 +412,7 @@ export type GenerateTypesOptions = Omit<VitePluginDtsOptions, "beforeWriteFile"
346
412
  * This transformer is used only on .d.ts files of your components. Any
347
413
  * .d.ts files for utility files or other non-entrypoint files are not
348
414
  * affected by this transformer. For those, you can use the
349
- * `declarationAstTransformers` option.
415
+ * `declarationTextTransformers` option.
350
416
  */
351
417
  readonly declarationAstTransformers?: FileTransformer[];
352
418
  /**
@@ -425,7 +491,7 @@ export type ApiJsonOptions = {
425
491
  *
426
492
  * @default LuminaApiExtractor
427
493
  */
428
- readonly Extractor: typeof LuminaApiExtractor;
494
+ readonly Extractor?: typeof LuminaApiExtractor;
429
495
  /**
430
496
  * This function will be called after the api.json is created but before it is
431
497
  * used to generate any output files.
@@ -663,14 +729,14 @@ export type AssetTransformer = {
663
729
  };
664
730
  export type LintingOptions = {
665
731
  /**
666
- * Lumina emits build-time errors for common issues and possible bugs.
732
+ * Lumina includes build-time checks for common issues and possible bugs.
667
733
  * Most of those should be immediately addressable. However, some (like
668
734
  * updating default value for boolean properties) may require a breaking
669
735
  * change.
670
736
  *
671
- * This option exists to temporary turn these errors into warnings.
737
+ * This option exists to temporarily turn these errors into warnings.
672
738
  * @example
673
- * To silence an error in a file, add an entry like thw following with the
739
+ * To silence an error in a file, add an entry like the following with the
674
740
  * relative path to the file:
675
741
  *
676
742
  * ```ts
@@ -678,13 +744,6 @@ export type LintingOptions = {
678
744
  * ```
679
745
  */
680
746
  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
747
  /**
689
748
  * Lumina components may declare required properties using `@required` JSDoc
690
749
  * tag.