@arcgis/lumina-compiler 4.33.0-next.94 → 4.33.0-next.96
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.
- package/dist/index.js +559 -557
- package/dist/testing/index.js +73 -109
- package/dist/testing/wrapController.d.ts +1 -1
- package/package.json +5 -5
package/dist/testing/index.js
CHANGED
|
@@ -1,97 +1,98 @@
|
|
|
1
|
-
import { render as
|
|
2
|
-
import { unsafeStatic as
|
|
3
|
-
import { camelToKebab as
|
|
4
|
-
import { onTestFinished as
|
|
1
|
+
import { render as y } from "lit-html";
|
|
2
|
+
import { unsafeStatic as u, html as C } from "lit-html/static.js";
|
|
3
|
+
import { camelToKebab as N } from "@arcgis/components-utils";
|
|
4
|
+
import { onTestFinished as L, expect as _ } from "vitest";
|
|
5
5
|
import S from "vitest-fail-on-console";
|
|
6
|
-
import
|
|
7
|
-
import { LitElement as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
import x from "js-beautify";
|
|
7
|
+
import { LitElement as E } from "@arcgis/lumina";
|
|
8
|
+
import { toFunction as O } from "@arcgis/lumina/controllers";
|
|
9
|
+
async function W(e, { parent: t = document.body, afterConnect: n, dynamicComponents: r, cleanupAfterTest: i = !0 } = {}) {
|
|
10
|
+
const o = document.createElement("div");
|
|
11
|
+
o.style.display = "contents", t.append(o), i && L(() => M(o)), w(e);
|
|
12
|
+
const s = r?.some(w);
|
|
13
|
+
let c;
|
|
13
14
|
if (typeof e == "string")
|
|
14
|
-
|
|
15
|
+
c = C`<${u(e)}></${u(e)}>`;
|
|
15
16
|
else if (typeof e == "function")
|
|
16
|
-
|
|
17
|
+
c = "tagName" in e ? C`<${u(e.tagName)}></${u(e.tagName)}>` : e();
|
|
17
18
|
else {
|
|
18
19
|
if (s)
|
|
19
20
|
throw new Error(
|
|
20
21
|
'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 override tagName = "some-tag-name";` property with a unique tag name within the test file'
|
|
21
22
|
);
|
|
22
|
-
|
|
23
|
+
c = e;
|
|
23
24
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
26
|
-
|
|
25
|
+
const l = [];
|
|
26
|
+
function p(d) {
|
|
27
|
+
l.push(d.error), d.preventDefault(), d.stopPropagation();
|
|
27
28
|
}
|
|
28
|
-
if (window.addEventListener("error",
|
|
29
|
-
throw
|
|
30
|
-
if (
|
|
31
|
-
throw new AggregateError(
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
typeof
|
|
36
|
-
const
|
|
29
|
+
if (window.addEventListener("error", p), y(c, o), window.removeEventListener("error", p), l.length === 1)
|
|
30
|
+
throw l[0];
|
|
31
|
+
if (l.length > 1)
|
|
32
|
+
throw new AggregateError(l, "Multiple errors occurred while creating the custom element");
|
|
33
|
+
const a = b(o), $ = h, g = n?.(a);
|
|
34
|
+
g?.then !== void 0 && await g;
|
|
35
|
+
const m = a;
|
|
36
|
+
typeof m?.componentOnReady == "function" && await m.componentOnReady();
|
|
37
|
+
const f = m?._litElement ?? $ ?? a;
|
|
37
38
|
return {
|
|
38
|
-
el:
|
|
39
|
-
component:
|
|
39
|
+
el: a,
|
|
40
|
+
component: f,
|
|
40
41
|
async reRender() {
|
|
41
|
-
return typeof e == "function" && !("tagName" in e) &&
|
|
42
|
+
return typeof e == "function" && !("tagName" in e) && y(e(), t), f.requestUpdate(), await f.updateComplete;
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
|
-
let
|
|
46
|
+
let h;
|
|
46
47
|
const R = globalThis;
|
|
47
48
|
R.devOnly$luminaComponentRefCallback = (e) => {
|
|
48
|
-
|
|
49
|
+
h = e;
|
|
49
50
|
};
|
|
50
|
-
function
|
|
51
|
+
function M(e) {
|
|
51
52
|
for (; e.firstChild; )
|
|
52
53
|
e.removeChild(e.firstChild);
|
|
53
54
|
e instanceof HTMLElement && e.remove();
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function w(e) {
|
|
56
57
|
if (!j(e) || e.runtime !== void 0)
|
|
57
58
|
return !1;
|
|
58
|
-
let
|
|
59
|
-
if (!
|
|
60
|
-
|
|
61
|
-
const
|
|
59
|
+
let t = !1, n = e.tagName;
|
|
60
|
+
if (!n) {
|
|
61
|
+
t = !1;
|
|
62
|
+
const r = N(
|
|
62
63
|
/*
|
|
63
64
|
* If name is a single letter, it was probably minified - thus is not
|
|
64
65
|
* stable, thus don't use it. Example: class produced by wrapController()
|
|
65
66
|
*/
|
|
66
|
-
(e.name.length > 1 ? e.name.replaceAll(
|
|
67
|
-
), i =
|
|
68
|
-
|
|
69
|
-
for (let
|
|
70
|
-
|
|
67
|
+
(e.name.length > 1 ? e.name.replaceAll(z, "") : "") || "Test"
|
|
68
|
+
), i = r === "test" ? "te-st" : r.includes("-") ? r : `${r}-`;
|
|
69
|
+
n = i;
|
|
70
|
+
for (let o = 2, s = customElements.get(n); s !== e && s !== void 0; o += 1)
|
|
71
|
+
t = !0, n = `${i}-${o}`, s = customElements.get(n);
|
|
71
72
|
}
|
|
72
|
-
return globalThis.devOnly$luminaRuntime?.customElement(
|
|
73
|
+
return globalThis.devOnly$luminaRuntime?.customElement(n, e), Object.defineProperty(e.prototype, "tagName", { value: n.toUpperCase() }), t;
|
|
73
74
|
}
|
|
74
|
-
const j = (e) => typeof e == "function" && "lumina" in e,
|
|
75
|
-
function
|
|
76
|
-
for (const
|
|
77
|
-
if ("lumina" in
|
|
75
|
+
const j = (e) => typeof e == "function" && "lumina" in e, z = /\d+$/gu;
|
|
76
|
+
function b(e) {
|
|
77
|
+
for (const t of e.children)
|
|
78
|
+
if ("lumina" in t.constructor)
|
|
79
|
+
return t;
|
|
80
|
+
for (const t of e.children) {
|
|
81
|
+
const n = b(t);
|
|
82
|
+
if (n != null)
|
|
78
83
|
return n;
|
|
79
|
-
for (const n of e.children) {
|
|
80
|
-
const o = _(n);
|
|
81
|
-
if (o != null)
|
|
82
|
-
return o;
|
|
83
84
|
}
|
|
84
|
-
return e.firstElementChild ??
|
|
85
|
+
return e.firstElementChild ?? h?.el;
|
|
85
86
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
87
|
+
function F() {
|
|
88
|
+
_.addSnapshotSerializer({
|
|
88
89
|
// Using duck typing to detect ShadowRoot. Not using instanceof to keep test fast
|
|
89
90
|
test(e) {
|
|
90
91
|
return typeof e == "object" && e !== null && "innerHTML" in e && "onslotchange" in e;
|
|
91
92
|
},
|
|
92
93
|
serialize(e) {
|
|
93
|
-
const
|
|
94
|
-
return
|
|
94
|
+
const t = e.innerHTML.replaceAll(q, "");
|
|
95
|
+
return x.html(t, {
|
|
95
96
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
96
97
|
indent_size: 2,
|
|
97
98
|
indent_char: " ",
|
|
@@ -104,63 +105,26 @@ function A() {
|
|
|
104
105
|
}
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
|
-
const
|
|
108
|
-
function
|
|
109
|
-
if (
|
|
108
|
+
const q = /<!--\??(?:lit\$\d+\$)?-->/gu;
|
|
109
|
+
function G() {
|
|
110
|
+
if (T[v])
|
|
110
111
|
return;
|
|
111
|
-
|
|
112
|
+
T[v] = !0;
|
|
112
113
|
const e = { ...console };
|
|
113
114
|
S({
|
|
114
115
|
// Workaround for https://github.com/thomasbrodusch/vitest-fail-on-console/issues/61
|
|
115
|
-
silenceMessage(
|
|
116
|
-
return e[
|
|
116
|
+
silenceMessage(t, n) {
|
|
117
|
+
return e[n](t), !1;
|
|
117
118
|
}
|
|
118
|
-
}),
|
|
119
|
+
}), F();
|
|
119
120
|
}
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
let l = [];
|
|
124
|
-
function q(e) {
|
|
125
|
-
if (e === void 0) {
|
|
126
|
-
l = [];
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const n = l.indexOf(e);
|
|
130
|
-
l = n === -1 ? [...l, e] : l.slice(0, n + 1), queueMicrotask(() => {
|
|
131
|
-
l = [];
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function z() {
|
|
135
|
-
return l;
|
|
136
|
-
}
|
|
137
|
-
process.env.NODE_ENV !== "production" && a() && [
|
|
138
|
-
"This might be the case if you are trying to access an async controller in ",
|
|
139
|
-
"connectedCallback(). Or, if you are using it inside of ",
|
|
140
|
-
"componentWillLoad()/another controller without controller.use. Example correct ",
|
|
141
|
-
`usage:
|
|
142
|
-
`,
|
|
143
|
-
"makeController(async (component, controller)=>{ await controller.use(someOtherController); });"
|
|
144
|
-
].join("");
|
|
145
|
-
process.env.NODE_ENV !== "production" ? Symbol.for(
|
|
146
|
-
// Use Symbol.for in dev mode to make it easier to maintain state when doing HMR.
|
|
147
|
-
`${v}: nothing`
|
|
148
|
-
) : (
|
|
149
|
-
// eslint-disable-next-line symbol-description
|
|
150
|
-
Symbol()
|
|
151
|
-
);
|
|
152
|
-
process.env.NODE_ENV !== "production" && a();
|
|
153
|
-
process.env.NODE_ENV !== "production" && a();
|
|
154
|
-
const F = (e) => (...n) => {
|
|
155
|
-
const o = z(), t = new e(...n);
|
|
156
|
-
return q(o.at(-1)), t;
|
|
157
|
-
};
|
|
158
|
-
function X(e, n) {
|
|
159
|
-
class o extends M {
|
|
121
|
+
const v = Symbol.for("lumina:didSetupTest"), T = globalThis;
|
|
122
|
+
function I(e, t) {
|
|
123
|
+
class n extends E {
|
|
160
124
|
constructor() {
|
|
161
125
|
super();
|
|
162
|
-
const i = "prototype" in e ?
|
|
163
|
-
this.controller = i(this), Promise.resolve(
|
|
126
|
+
const i = "prototype" in e ? O(e) : e;
|
|
127
|
+
this.controller = i(this), Promise.resolve(t?.(this)).catch(console.error);
|
|
164
128
|
}
|
|
165
129
|
/*
|
|
166
130
|
* Emitting controller's exports here is useful to let controller tests
|
|
@@ -172,10 +136,10 @@ function X(e, n) {
|
|
|
172
136
|
);
|
|
173
137
|
}
|
|
174
138
|
}
|
|
175
|
-
return
|
|
139
|
+
return n;
|
|
176
140
|
}
|
|
177
141
|
export {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
142
|
+
W as mount,
|
|
143
|
+
G as setupLuminaTest,
|
|
144
|
+
I as wrapController
|
|
181
145
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseComponent, ControllerHost } from '@arcgis/components-controllers';
|
|
2
1
|
import { LitElement } from '@arcgis/lumina';
|
|
2
|
+
import { BaseComponent, ControllerHost } from '@arcgis/lumina/controllers';
|
|
3
3
|
/**
|
|
4
4
|
* Wrap a controller in a small component - useful when you are interested in
|
|
5
5
|
* only testing the controller behavior.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/lumina-compiler",
|
|
3
|
-
"version": "4.33.0-next.
|
|
3
|
+
"version": "4.33.0-next.96",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@arcgis/api-extractor": "4.33.0-next.
|
|
22
|
-
"@arcgis/components-build-utils": "4.33.0-next.
|
|
23
|
-
"@arcgis/components-utils": "4.33.0-next.
|
|
21
|
+
"@arcgis/api-extractor": "4.33.0-next.96",
|
|
22
|
+
"@arcgis/components-build-utils": "4.33.0-next.96",
|
|
23
|
+
"@arcgis/components-utils": "4.33.0-next.96",
|
|
24
24
|
"chalk": "^5.3.0",
|
|
25
25
|
"esbuild": "^0.24.0",
|
|
26
26
|
"glob": "^11.0.0",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"vitest-fail-on-console": "^0.7.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@arcgis/lumina": "~4.33.0-next.
|
|
40
|
+
"@arcgis/lumina": "~4.33.0-next.96"
|
|
41
41
|
}
|
|
42
42
|
}
|