@arcgis/lumina-compiler 4.34.0-next.16 → 4.34.0-next.160

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 (36) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -10
  3. package/dist/context/index.d.ts +12 -2
  4. package/dist/dependencies/arcgisCore.d.ts +1 -1
  5. package/dist/dependencies/discover.d.ts +7 -2
  6. package/dist/dependencies/lumina.d.ts +1 -1
  7. package/dist/dependencies/stencil.d.ts +2 -2
  8. package/dist/dependencies/testSetupFiles.d.ts +1 -0
  9. package/dist/dependencies/updateLumina.d.ts +3 -3
  10. package/dist/entrypoints/resolveTagName.d.ts +2 -2
  11. package/dist/frameworkTypes/preact.d.ts +1 -0
  12. package/dist/frameworkTypes/preact10.d.ts +10 -0
  13. package/dist/index.js +2397 -2317
  14. package/dist/jsxToLitHtml/importsConfig.d.ts +10 -0
  15. package/dist/jsxToLitHtml/types.d.ts +4 -2
  16. package/dist/loader/{hideUntilHydrated.d.ts → css.d.ts} +6 -1
  17. package/dist/loader/index.d.ts +1 -1
  18. package/dist/loader/lazy.d.ts +1 -1
  19. package/dist/logger-hJvg0JOj.js +34 -0
  20. package/dist/plugins/buildCdn.d.ts +6 -0
  21. package/dist/plugins/loadLitCss.d.ts +52 -11
  22. package/dist/publicTypes.d.ts +70 -118
  23. package/dist/puppeteerTesting/globalSetup.d.ts +1 -1
  24. package/dist/puppeteerTesting/index.js +1 -1
  25. package/dist/puppeteerTesting/vitest/matchers/index.d.ts +12 -12
  26. package/dist/testing/failOnConsole.d.ts +6 -0
  27. package/dist/testing/index.js +79 -60
  28. package/dist/testing/mount.d.ts +2 -2
  29. package/dist/testing/vitestTypes.d.ts +8 -0
  30. package/dist/transformers/injectRuntimeOptions.d.ts +12 -2
  31. package/dist/transformers/internalTypeScriptApis.d.ts +4 -1
  32. package/dist/transformers/utils.d.ts +2 -7
  33. package/package.json +20 -18
  34. package/dist/jsxToLitHtml/escapeForTemplateLiteral.d.ts +0 -45
  35. package/dist/logger-KpGU2b3R.js +0 -28
  36. package/dist/plugins/buildStencilHydrate.d.ts +0 -16
@@ -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/components-utils";
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();
@@ -0,0 +1,8 @@
1
+ export type VitestBrowserModeProvider = "playwright" | "preview" | "webdriverio" | (string & {}) | undefined;
2
+ export type VitestPartialConfig = {
3
+ globalSetup?: string[] | string;
4
+ runner?: string;
5
+ include?: string[];
6
+ environment?: "edge-runtime" | "happy-dom" | "jsdom" | "node" | (Record<never, never> & string);
7
+ forceRerunTriggers?: string[];
8
+ };
@@ -1,3 +1,13 @@
1
- import { SourceDescription } from 'rollup';
2
1
  import { CompilerContext } from '../context';
3
- export declare function injectRuntimeOptions(runtimeTsCode: string, context: CompilerContext): SourceDescription;
2
+ import { Plugin } from 'vite';
3
+ export declare const injectRuntimeOptions: (context: CompilerContext) => Plugin;
4
+ /**
5
+ * Add to chunks/runtime.js import statement for the global CSS file.
6
+ * This way CSS is injected automatically, simplifying get started instructions.
7
+ * We also inject CSS imports for Lumina dependencies this package uses - this
8
+ * is needed to ensure CSS is loaded in correct order - this does not cause
9
+ * duplicate CSS bundling.
10
+ *
11
+ * Research notes: https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/1824#discussioncomment-12625
12
+ */
13
+ export declare function getGlobalCssImport(context: CompilerContext): string;
@@ -1,5 +1,8 @@
1
- import { SourceMap } from 'rollup';
2
1
  import { default as ts } from 'typescript';
2
+ import { TransformResult } from 'vite';
3
+ type SourceMap = Extract<NonNullable<TransformResult["map"]>, {
4
+ file: string;
5
+ }>;
3
6
  export type UndocumentedTypeScript = {
4
7
  readonly createSourceMapGenerator?: (host: ts.CompilerHost, basename: string, sourceRoot: string, dirname: string, compilerOptions: ts.CompilerOptions) => SourceMapGenerator;
5
8
  readonly createTextWriter?: (newLine: string) => EmitTextWriter;
@@ -1,14 +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
- /**
10
- * For performance reasons, to avoid the need to re-create the source map
11
- * after this change, replace the given code string with a comment string of
12
- * equal length :)
13
- */
14
- export declare const commentOutCode: (match: string) => string;
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.16",
3
+ "version": "4.34.0-next.160",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -18,25 +18,27 @@
18
18
  ],
19
19
  "license": "SEE LICENSE IN LICENSE.md",
20
20
  "dependencies": {
21
- "@arcgis/api-extractor": "4.34.0-next.16",
22
- "@arcgis/components-build-utils": "4.34.0-next.16",
23
- "@arcgis/components-utils": "4.34.0-next.16",
24
- "chalk": "^5.3.0",
25
- "esbuild": "^0.25.4",
26
- "glob": "^11.0.0",
27
- "js-beautify": "^1.15.1",
28
- "mime-types": "^2.1.35",
29
- "rollup": "^4.40.2",
30
- "rollup-plugin-node-externals": "^8.0.0",
31
- "sass-embedded": "^1.79.3",
21
+ "@arcgis/api-extractor": "4.34.0-next.160",
22
+ "@arcgis/components-build-utils": "4.34.0-next.160",
23
+ "@arcgis/toolkit": "~4.34.0-next.160",
24
+ "chalk": "^5.4.1",
25
+ "esbuild": "^0.25.5",
26
+ "glob": "^11.0.3",
27
+ "js-beautify": "^1.15.4",
28
+ "mime-types": "^3.0.1",
32
29
  "tslib": "^2.8.1",
33
- "typescript": "~5.8.3",
34
- "vite": "^6.3.4",
35
- "vite-plugin-dts": "^4.5.3",
36
- "vitest": "^3.1.3",
37
- "vitest-fail-on-console": "^0.7.1"
30
+ "vite-plugin-dts": "^4.5.4"
38
31
  },
39
32
  "peerDependencies": {
40
- "@arcgis/lumina": "~4.34.0-next.16"
33
+ "@arcgis/lumina": "~4.34.0-next.160",
34
+ "lit": "^3.3.0",
35
+ "typescript": "~5.8.3",
36
+ "vite": "^7.0.0",
37
+ "vitest": "^3.2.4"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "vitest": {
41
+ "optional": true
42
+ }
41
43
  }
42
44
  }
@@ -1,45 +0,0 @@
1
- /**
2
- * This file is a workaround for a TypeScript bug:
3
- * https://github.com/microsoft/TypeScript/issues/59150
4
- *
5
- * Once that bug is fixed, the code can be simplified like so:
6
- * - This file can be removed
7
- * - For each place where `escapeBackticks` or `escapeForTemplateLiteral` was
8
- * used and the result was passed as the 1st AND 2nd parameter to one of
9
- * ts.factory.createNoSubstitutionTemplateLiteral,
10
- * ts.factory.createTemplateHead, ts.factory.createTemplateMiddle, or
11
- * ts.factory.createTemplateTail, change those places like so:
12
- * - DO NOT call `escapeBackticks` or `escapeForTemplateLiteral` anymore -
13
- * pass the value as is.
14
- * - DO NOT provide the 2nd parameter to the factory function.
15
- * - If `escapeForTemplateLiteral` was used in some other place, it can
16
- * potentially be replaced with a function like this:
17
- * string=>escapeTemplateSubstitution(string).replaceAll('`','\`')
18
- * (where escapeTemplateSubstitution is defined in the current file - move it)
19
- *
20
- * More details:
21
- *
22
- * In template literals, even though we *really* only need to escape ${ and
23
- * backticks, we are escaping non-ASCII characters too as that improves scanner
24
- * performance in JavaScript engines.
25
- *
26
- * This is what esbuild does (https://esbuild.github.io/api/#charset), what
27
- * V8 recommends (https://v8.dev/blog/scanner) and what TypeScript does.
28
- *
29
- * The code in this file has been copied from TypeScript's code for escaping
30
- * template literals (but simplified to remove dead branches and fix eslint
31
- * warnings):
32
- * https://github.com/microsoft/TypeScript/blob/3163fe7e3898c1f48cd9bc097b96e3426cd2a453/src/compiler/utilities.ts#L5918-L5986
33
- *
34
- * TypeScript can automatically escape template literals for us, but we opt out
35
- * of that as, due to a bug, they also escape new line characters which is not
36
- * good as it decreases readability when debugging code.
37
- *
38
- * TypeScript does not expose the template literal escaping utils so we had
39
- * to copy the code here, but modify to not escape new lines.
40
- *
41
- */
42
- declare function escapeNonAsciiString(s: string): string;
43
- export declare const escapeBackticks: typeof escapeNonAsciiString;
44
- export declare const escapeTemplateSubstitution: (str: string) => string;
45
- export {};
@@ -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
- };
@@ -1,16 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { 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;