@arcgis/lumina-compiler 4.34.0-next.99 → 5.0.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.
@@ -68,5 +68,7 @@ export type LitTag = (typeof litTagsArray)[number];
68
68
  export declare const jsxImportNames: readonly ["keyed", "ref", "repeat", "live", "css", "html", "mathml", "staticHtml", "staticSvg", "svg", "safeClassMap", "safeStyleMap", "deferLoad", "stabilizedRef", "nothing"];
69
69
  export type JsxImportName = (typeof jsxImportNames)[number];
70
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;
71
73
  export declare const isJsxHost: (node: ts.Node) => node is JsxHost;
72
74
  export {};
@@ -10,4 +10,4 @@ import { CompilerContext } from '../context';
10
10
  * The generated api.json is then used by componentTransformPipeline() and by
11
11
  * generateDocs(), among others.
12
12
  */
13
- export declare function generateVirtualFiles(context: CompilerContext): VitePlugin;
13
+ export declare function generateVirtualFiles(context: CompilerContext): readonly [VitePlugin, VitePlugin];
@@ -15,7 +15,7 @@ export declare const loaderDts = "import \"./index\";\nexport declare const defi
15
15
  * properties, attributes, asynchronous methods and synchronous methods.
16
16
  */
17
17
  declare function buildCompactLazyMeta(customElement: Pick<ApiCustomElementDeclaration, "members" | "tagName">): string;
18
- export declare function buildLazyBeta(customElement: Pick<ApiCustomElementDeclaration, "members" | "tagName">): HmrComponentMeta;
18
+ export declare function buildLazyMeta(customElement: Pick<ApiCustomElementDeclaration, "members" | "tagName">): HmrComponentMeta;
19
19
  export declare const exportsForTests: {
20
20
  buildCompactLazyMeta: typeof buildCompactLazyMeta;
21
21
  };
@@ -0,0 +1,34 @@
1
+ import { setApiExtractorErrorLogger as c } from "@arcgis/api-extractor";
2
+ import { toSystemPathSeparators as i, path as g } from "@arcgis/components-build-utils";
3
+ import a from "chalk";
4
+ let e = {
5
+ // Temporary logger to use until vite config is loaded and we have access to
6
+ // actual logger.
7
+ info: console.log,
8
+ warn: console.warn,
9
+ error: console.error
10
+ }, s = process.cwd();
11
+ function n(t, r, o) {
12
+ return typeof o == "string" ? (o = o.startsWith(s) ? i(g.relative(s, o)) : o, o = `${o}: `) : o = "", `${t} ${o}${r}`;
13
+ }
14
+ const f = {
15
+ initialize(t, r) {
16
+ e = t, s = r, c(e.error);
17
+ },
18
+ info(t, r, o) {
19
+ e.info(n(a.cyan(`[${t}]`), r, o));
20
+ },
21
+ warn(t, r, o) {
22
+ e.warn(n(a.yellow(`[${t}]`), r, o));
23
+ },
24
+ error(t, r, o) {
25
+ e.error(n(a.red(`[${t}]`), r, o)), process.exitCode = 1;
26
+ }
27
+ };
28
+ function l(t, r, o) {
29
+ return r instanceof Error ? (r.message = n(t, r.message, o), r) : n(a.red(`[${t}]`), r, o);
30
+ }
31
+ export {
32
+ l as f,
33
+ f as l
34
+ };
@@ -65,7 +65,13 @@ export declare function buildLoaderCode(runtimeVariableName: string, customEntry
65
65
  * ```
66
66
  */
67
67
  declare function transformChunk(chunk: CdnChunk, chunks: Map<string, CdnChunk>): void;
68
+ /**
69
+ * Given set of identifiers, produce the shortest possible ASCII-only identifier.
70
+ * We restrict to ASCII-range as it is faster to parse for engines.
71
+ */
72
+ declare function createIdentifierGenerator(seen: Set<string>): () => string;
68
73
  export declare const exportsForTests: {
69
74
  transformChunk: typeof transformChunk;
75
+ createIdentifierGenerator: typeof createIdentifierGenerator;
70
76
  };
71
77
  export {};
@@ -96,7 +96,7 @@ export declare const globalCssFileFlag = "?globalFileLitCss";
96
96
  *
97
97
  * Then, we augment it into this:
98
98
  * ```js
99
- * import { css } from '@lit/reactive-element/css-tag.js';
99
+ * import { css } from 'lit/css-tag.js';
100
100
  * const styles = css`:host{display:flex;gap:1rem}button{padding:1rem}`;
101
101
  * export default styles;
102
102
  * ```
@@ -37,10 +37,9 @@ export type LuminaOptions = {
37
37
  * For more options, see Vite's "testing" option.
38
38
  * This is equivalent to the `e2e` mode in Stencil.
39
39
  *
40
- * @remarks
41
- * For new projects, we recommend using Vitest browser mode instead of
42
- * Puppeteer. See documentation:
43
- * https://qawebgis.esri.com/components/lumina/testing
40
+ * @deprecated
41
+ * For new projects, use Vitest browser mode instead of Puppeteer.
42
+ * See documentation: https://qawebgis.esri.com/components/lumina/testing
44
43
  */
45
44
  readonly puppeteerTesting?: PuppeteerTestingOptions;
46
45
  /**
@@ -100,7 +99,7 @@ export type BuildOptions = {
100
99
  * New lines are accepted.
101
100
  * Do not include // or /* - will be added automatically.
102
101
  *
103
- * @default require("@arcgis/components-utils").getPreamble()
102
+ * @default require("@arcgis/toolkit/string").getPreamble()
104
103
  *
105
104
  * @example
106
105
  * ```js
@@ -156,7 +155,15 @@ export type BuildCdnOptions = {
156
155
  */
157
156
  readonly esbuildOptions?: Parameters<typeof esbuildBuild>[0];
158
157
  /**
159
- * A callback for mutating CDN chunks before they are written to disk.
158
+ * Transform the CDN entrypoint before it is processed by ESBuild.
159
+ *
160
+ * This callback is for advanced use cases only. The build output may change
161
+ * between Lumina versions without prior notice.
162
+ */
163
+ readonly entrypointTransformer?: (code: string, context: CompilerContext) => string;
164
+ /**
165
+ * A callback for mutating CDN ESBuild output chunks before they are written
166
+ * to disk.
160
167
  * This callback is for advanced use cases only. The build output may change
161
168
  * between Lumina versions without prior notice. Using this callback may
162
169
  * corrupt the CDN source map if it is enabled.
@@ -165,6 +172,11 @@ export type BuildCdnOptions = {
165
172
  };
166
173
  export type CdnChunk = {
167
174
  code: string;
175
+ /**
176
+ * Whether chunk is currently being processed. Used to detect cyclical imports.
177
+ * @private
178
+ */
179
+ isProcessing: boolean;
168
180
  isAsync: boolean | undefined;
169
181
  oldSingleExportName: string | undefined;
170
182
  };
@@ -247,9 +259,17 @@ export type DetailedExtraDependency = {
247
259
  */
248
260
  getCdnUrl: (context: CompilerContext) => string;
249
261
  };
262
+ /**
263
+ * @deprecated
264
+ * For new projects, use Vitest browser mode instead of Puppeteer.
265
+ * See documentation: https://qawebgis.esri.com/components/lumina/testing
266
+ */
250
267
  export type PuppeteerTestingOptions = {
251
268
  /**
252
269
  * @default false
270
+ * @deprecated
271
+ * For new projects, use Vitest browser mode instead of Puppeteer.
272
+ * See documentation: https://qawebgis.esri.com/components/lumina/testing
253
273
  */
254
274
  readonly enabled?: boolean;
255
275
  /**
@@ -26,7 +26,7 @@ declare module "vitest" {
26
26
  *
27
27
  * It has to be separate because Vitest's dev server resolves imports for the
28
28
  * "node" import condition. If we instead tell Vitest to use browser export
29
- * conditions, than Lit's "isServer" will be false both in browser and node.js,
29
+ * conditions, then Lit's "isServer" will be false both in browser and node.js,
30
30
  * potentially breaking some components. While happy-dom is neat, it does match
31
31
  * the actual browser API 100%. It is safer to run a separate Vite instance for
32
32
  * Node.js (Vitest) and browser. This is a short-term issue anyway as we are
@@ -1,7 +1,7 @@
1
1
  import { expect as p, afterEach as V } from "vitest";
2
2
  import { toSystemPathSeparators as L, isPosix as S } from "@arcgis/components-build-utils";
3
3
  import { p as T, i as h } from "../types-C3YmWTVv.js";
4
- import { l as y } from "../logger-KpGU2b3R.js";
4
+ import { l as y } from "../logger-hJvg0JOj.js";
5
5
  async function D(s) {
6
6
  await s.exposeFunction("puppeteerOnEvent", (e, t) => {
7
7
  j(s._e2eEvents, e, t);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Based on https://github.com/thomasbrodusch/vitest-fail-on-console/, but
3
+ * simplified and with our fixes applied:
4
+ * https://github.com/thomasbrodusch/vitest-fail-on-console/issues/61
5
+ */
6
+ export declare function failOnConsole(): void;
@@ -1,39 +1,39 @@
1
- import { render as C } from "lit-html";
2
- import { unsafeStatic as m, html as w } from "lit-html/static.js";
3
- import { devOnly$getLitElementTagNameAndRuntime as $, LitElement as S } from "@arcgis/lumina";
4
- import { camelToKebab as _ } from "@arcgis/toolkit/string";
5
- import { onTestFinished as x, expect as E } from "vitest";
6
- import O from "vitest-fail-on-console";
7
- import R from "js-beautify";
8
- import { toFunction as D } from "@arcgis/lumina/controllers";
9
- async function G(e, { parent: t = document.body, afterConnect: o, dynamicComponents: f, cleanupAfterTest: s = !0 } = {}) {
1
+ import { render as C } from "lit";
2
+ import { unsafeStatic as m, html as w } from "lit/static-html.js";
3
+ import { devOnly$getLitElementTagNameAndRuntime as x, LitElement as O } from "@arcgis/lumina";
4
+ import { camelToKebab as S } from "@arcgis/toolkit/string";
5
+ import { onTestFinished as _, beforeEach as R, afterEach as D, expect as M } from "vitest";
6
+ import b from "chalk";
7
+ import j from "js-beautify";
8
+ import { toFunction as z } from "@arcgis/lumina/controllers";
9
+ async function X(e, { parent: t = document.body, afterConnect: o, dynamicComponents: f, cleanupAfterTest: r = !0 } = {}) {
10
10
  const n = document.createElement("div");
11
- n.style.display = "contents", t.append(n), s && x(() => j(n)), v(e);
11
+ n.style.display = "contents", t.append(n), r && _(() => F(n)), v(e);
12
12
  const l = f?.some(v);
13
- let r;
13
+ let i;
14
14
  if (typeof e == "string")
15
- r = w`<${m(e)}></${m(e)}>`;
15
+ i = w`<${m(e)}></${m(e)}>`;
16
16
  else if (typeof e == "function")
17
17
  if (p(e)) {
18
- const c = $(e).tagName;
19
- r = w`<${m(c)}></${m(c)}>`;
18
+ const a = x(e).tagName;
19
+ i = w`<${m(a)}></${m(a)}>`;
20
20
  } else
21
- r = e();
21
+ i = e();
22
22
  else {
23
23
  if (l)
24
24
  throw new Error(
25
25
  'When rendering a dynamically created custom element using Lit\'s html`` function, you must ensure that the custom element class name is unique in the test file, or the class should explicitly have the `static tagName = "some-tag-name";` property with a unique tag name within the test file'
26
26
  );
27
- r = e;
27
+ i = e;
28
28
  }
29
- const i = [];
30
- function a(c) {
31
- i.push(c.error), c.preventDefault(), c.stopPropagation();
29
+ const s = [];
30
+ function c(a) {
31
+ s.push(a.error), a.preventDefault(), a.stopPropagation();
32
32
  }
33
- if (window.addEventListener("error", a), C(r, n), window.removeEventListener("error", a), i.length === 1)
34
- throw i[0];
35
- if (i.length > 1)
36
- throw new AggregateError(i, "Multiple errors occurred while creating the custom element");
33
+ if (window.addEventListener("error", c), C(i, n), window.removeEventListener("error", c), s.length === 1)
34
+ throw s[0];
35
+ if (s.length > 1)
36
+ throw new AggregateError(s, "Multiple errors occurred while creating the custom element");
37
37
  const u = L(n), N = g, y = o?.(u);
38
38
  y?.then !== void 0 && await y;
39
39
  const d = u;
@@ -49,11 +49,11 @@ async function G(e, { parent: t = document.body, afterConnect: o, dynamicCompone
49
49
  };
50
50
  }
51
51
  let g;
52
- const M = globalThis;
53
- M.devOnly$luminaComponentRefCallback = (e) => {
52
+ const A = globalThis;
53
+ A.devOnly$luminaComponentRefCallback = (e) => {
54
54
  g = e;
55
55
  };
56
- function j(e) {
56
+ function F(e) {
57
57
  for (; e.firstChild; )
58
58
  e.removeChild(e.firstChild);
59
59
  e instanceof HTMLElement && e.remove();
@@ -61,25 +61,25 @@ function j(e) {
61
61
  function v(e) {
62
62
  if (!p(e))
63
63
  return !1;
64
- const { runtime: t, tagName: o = e.tagName } = $(e);
64
+ const { runtime: t, tagName: o = e.tagName } = x(e);
65
65
  if (t !== void 0)
66
66
  return !1;
67
- let s = !1, n = o;
67
+ let r = !1, n = o;
68
68
  if (n === void 0) {
69
- const l = _(
69
+ const l = S(
70
70
  /*
71
71
  * If name is a single letter, it was probably minified - thus is not
72
72
  * stable, thus don't use it. Example: class produced by wrapController()
73
73
  */
74
- (e.name.length > 1 ? e.name.replaceAll(z, "") : "") || "Test"
75
- ), r = l === "test" ? "te-st" : l.includes("-") ? l : `${l}-`;
76
- n = r;
77
- for (let i = 2, a = customElements.get(n); a !== e && a !== void 0; i += 1)
78
- s = !0, n = `${r}-${i}`, a = customElements.get(n);
74
+ (e.name.length > 1 ? e.name.replaceAll(q, "") : "") || "Test"
75
+ ), i = l === "test" ? "te-st" : l.includes("-") ? l : `${l}-`;
76
+ n = i;
77
+ for (let s = 2, c = customElements.get(n); c !== e && c !== void 0; s += 1)
78
+ r = !0, n = `${i}-${s}`, c = customElements.get(n);
79
79
  }
80
- return globalThis.devOnly$luminaRuntime?.customElement(n, e), Object.defineProperty(e.prototype, "tagName", { value: n.toUpperCase() }), s;
80
+ return globalThis.devOnly$luminaRuntime?.customElement(n, e), Object.defineProperty(e.prototype, "tagName", { value: n.toUpperCase() }), r;
81
81
  }
82
- const p = (e) => typeof e == "function" && "lumina" in e, z = /\d+$/gu;
82
+ const p = (e) => typeof e == "function" && "lumina" in e, q = /\d+$/gu;
83
83
  function L(e) {
84
84
  for (const t of e.children)
85
85
  if ("lumina" in t.constructor)
@@ -91,15 +91,43 @@ function L(e) {
91
91
  }
92
92
  return e.firstElementChild ?? g?.el;
93
93
  }
94
- function A() {
95
- E.addSnapshotSerializer({
94
+ function H() {
95
+ const e = $("warn"), t = $("error");
96
+ R(() => {
97
+ e.beforeEach(), t.beforeEach();
98
+ }), D(() => {
99
+ e.afterEach(), t.afterEach();
100
+ });
101
+ }
102
+ function $(e) {
103
+ let t = !1;
104
+ const o = console[e];
105
+ function f(...r) {
106
+ o(...r), t = !0;
107
+ }
108
+ return {
109
+ beforeEach() {
110
+ console[e] = f;
111
+ },
112
+ afterEach() {
113
+ if (t)
114
+ throw new Error(`[@arcgis/lumina:failOnConsole] Expected test not to call ${b.bold(`console.${e}()`)}.
115
+ If the ${e} is expected, test for it explicitly by mocking it out using:
116
+ ${b.bold(`vi.spyOn(console, '${e}').mockImplementation(() => {}) `)}
117
+ and test that the ${e} occurs.`);
118
+ console[e] = o;
119
+ }
120
+ };
121
+ }
122
+ function P() {
123
+ M.addSnapshotSerializer({
96
124
  // Using duck typing to detect ShadowRoot. Not using instanceof to keep test fast
97
125
  test(e) {
98
126
  return typeof e == "object" && e !== null && "innerHTML" in e && "onslotchange" in e;
99
127
  },
100
128
  serialize(e) {
101
- const t = e.innerHTML.replaceAll(F, "");
102
- return R.html(t, {
129
+ const t = e.innerHTML.replaceAll(U, "");
130
+ return j.html(t, {
103
131
  /* eslint-disable @typescript-eslint/naming-convention */
104
132
  indent_size: 2,
105
133
  indent_char: " ",
@@ -112,26 +140,17 @@ function A() {
112
140
  }
113
141
  });
114
142
  }
115
- const F = /<!--\??(?:lit\$\d+\$)?-->/gu;
116
- function I() {
117
- if (b[T])
118
- return;
119
- b[T] = !0;
120
- const e = { ...console };
121
- O({
122
- // Workaround for https://github.com/thomasbrodusch/vitest-fail-on-console/issues/61
123
- silenceMessage(t, o) {
124
- return e[o](t), !1;
125
- }
126
- }), A();
143
+ const U = /<!--\??(?:lit\$\d+\$)?-->/gu;
144
+ function Y() {
145
+ T[E] || (T[E] = !0, H(), P());
127
146
  }
128
- const T = Symbol.for("lumina:didSetupTest"), b = globalThis;
129
- function J(e, t) {
130
- class o extends S {
147
+ const E = Symbol.for("lumina:didSetupTest"), T = globalThis;
148
+ function Z(e, t) {
149
+ class o extends O {
131
150
  constructor() {
132
151
  super();
133
- const s = "prototype" in e ? D(e) : e;
134
- this.controller = s(this), Promise.resolve(t?.(this)).catch(console.error);
152
+ const r = "prototype" in e ? z(e) : e;
153
+ this.controller = r(this), Promise.resolve(t?.(this)).catch(console.error);
135
154
  }
136
155
  /*
137
156
  * Emitting controller's exports here is useful to let controller tests
@@ -146,7 +165,7 @@ function J(e, t) {
146
165
  return o;
147
166
  }
148
167
  export {
149
- G as mount,
150
- I as setupLuminaTest,
151
- J as wrapController
168
+ X as mount,
169
+ Y as setupLuminaTest,
170
+ Z as wrapController
152
171
  };
@@ -1,4 +1,4 @@
1
- import { TemplateResult } from 'lit-html';
1
+ import { TemplateResult } from 'lit';
2
2
  import { JsxNode, LitElement, ToElement } from '@arcgis/lumina';
3
3
  export type RenderResult<Component extends HTMLElement> = {
4
4
  /**
@@ -98,7 +98,7 @@ export type RenderOptions<Component extends HTMLElement = HTMLElement> = {
98
98
  * In it's simplest form, what this function is doing is the following:
99
99
  *
100
100
  * ```tsx
101
- * import { render } from "lit-html";
101
+ * import { render } from "lit";
102
102
  * render(<arcgis-counter />, document.body);
103
103
  * const el = document.querySelector("arcgis-counter")!;
104
104
  * await el.componentOnReady();
@@ -1,6 +1,6 @@
1
1
  import { CompilerContext } from '../context';
2
- import { TransformResult } from 'vite';
3
- export declare function injectRuntimeOptions(runtimeTsCode: string, context: CompilerContext): TransformResult;
2
+ import { Plugin } from 'vite';
3
+ export declare const injectRuntimeOptions: (context: CompilerContext) => Plugin;
4
4
  /**
5
5
  * Add to chunks/runtime.js import statement for the global CSS file.
6
6
  * This way CSS is injected automatically, simplifying get started instructions.
@@ -1,8 +1,9 @@
1
1
  import { default as ts } from 'typescript';
2
- import { FileTransformer } from '../publicTypes';
2
+ import { FileTransformContext, FileTransformer } from '../publicTypes';
3
3
  import { CompilerContext } from '../context';
4
4
  /**
5
5
  * Run a chain of transformers on a TypeScript .tsx or .d.ts file and return
6
6
  * the resulting source file
7
7
  */
8
8
  export declare function runTransformers(context: CompilerContext, transformationContext: ts.TransformationContext, sourceFile: ts.SourceFile, transformers: readonly FileTransformer[]): ts.SourceFile;
9
+ export declare function removeComments(node: ts.Node, context: FileTransformContext): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/lumina-compiler",
3
- "version": "4.34.0-next.99",
3
+ "version": "5.0.0-next.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -18,20 +18,19 @@
18
18
  ],
19
19
  "license": "SEE LICENSE IN LICENSE.md",
20
20
  "dependencies": {
21
- "@arcgis/api-extractor": "4.34.0-next.99",
22
- "@arcgis/components-build-utils": "4.34.0-next.99",
23
- "@arcgis/toolkit": "4.34.0-next.99",
21
+ "@arcgis/api-extractor": "5.0.0-next.0",
22
+ "@arcgis/components-build-utils": "5.0.0-next.0",
23
+ "@arcgis/toolkit": "~5.0.0-next.0",
24
24
  "chalk": "^5.4.1",
25
25
  "esbuild": "^0.25.5",
26
26
  "glob": "^11.0.3",
27
27
  "js-beautify": "^1.15.4",
28
28
  "mime-types": "^3.0.1",
29
29
  "tslib": "^2.8.1",
30
- "vite-plugin-dts": "^4.5.4",
31
- "vitest-fail-on-console": "^0.7.1"
30
+ "vite-plugin-dts": "^4.5.4"
32
31
  },
33
32
  "peerDependencies": {
34
- "@arcgis/lumina": "~4.34.0-next.99",
33
+ "@arcgis/lumina": "~5.0.0-next.0",
35
34
  "lit": "^3.3.0",
36
35
  "typescript": "~5.8.3",
37
36
  "vite": "^7.0.0",
@@ -1,28 +0,0 @@
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
- };