@torpor/view 0.4.13 → 0.4.15
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/CHANGELOG.md +16 -0
- package/dist/{Cleanup-BGQ5zaxE.d.cts → Cleanup-CYsytTEc.d.cts} +1 -1
- package/dist/Cleanup-CYsytTEc.d.cts.map +1 -0
- package/dist/{Cleanup-Ca8IspaG.d.ts → Cleanup-CgjyN0lW.d.mts} +1 -1
- package/dist/Cleanup-CgjyN0lW.d.mts.map +1 -0
- package/dist/{Component-BDUCwkBQ.d.cts → Component-DmWGMgak.d.mts} +1 -1
- package/dist/{Component-BDUCwkBQ.d.cts.map → Component-DmWGMgak.d.mts.map} +1 -1
- package/dist/{Component-JVwSemf-.d.ts → Component-kGLRFYg2.d.cts} +1 -1
- package/dist/Component-kGLRFYg2.d.cts.map +1 -0
- package/dist/{Region-BrsZLZUe.d.ts → Region-Bb6HAb-F.d.cts} +2 -2
- package/dist/{Region-Cf7OeBIQ.d.cts.map → Region-Bb6HAb-F.d.cts.map} +1 -1
- package/dist/{Region-Cf7OeBIQ.d.cts → Region-CTchywkr.d.mts} +2 -2
- package/dist/Region-CTchywkr.d.mts.map +1 -0
- package/dist/compile.cjs +238 -68
- package/dist/compile.d.cts +1 -1
- package/dist/{compile.d.ts → compile.d.mts} +2 -2
- package/dist/compile.d.mts.map +1 -0
- package/dist/{compile.js → compile.mjs} +238 -67
- package/dist/compile.mjs.map +1 -0
- package/dist/dev.cjs +1 -2
- package/dist/dev.d.cts +2 -2
- package/dist/{dev.d.ts → dev.d.mts} +3 -3
- package/dist/dev.d.mts.map +1 -0
- package/dist/{dev.js → dev.mjs} +2 -2
- package/dist/{dev.cjs.map → dev.mjs.map} +1 -1
- package/dist/devContext-B3yskfhA.cjs +1 -2
- package/dist/{devContext-CevrTlUO.js → devContext-CQ8RhBX-.mjs} +1 -1
- package/dist/{devContext-B3yskfhA.cjs.map → devContext-CQ8RhBX-.mjs.map} +1 -1
- package/dist/{formatText-Ck04q8_X.cjs → formatText--9zsK5Nq.cjs} +4 -4
- package/dist/{formatText-OyD8MNAM.js → formatText-B8u71S_K.mjs} +4 -3
- package/dist/formatText-B8u71S_K.mjs.map +1 -0
- package/dist/{formatText-BlLF3PPm.d.ts → formatText-BNP3P38F.d.cts} +3 -3
- package/dist/formatText-BNP3P38F.d.cts.map +1 -0
- package/dist/{formatText-Bcb1JvW5.d.cts → formatText-D6Ov8Ub0.d.mts} +3 -3
- package/dist/formatText-D6Ov8Ub0.d.mts.map +1 -0
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +4 -4
- package/dist/{index.d.ts → index.d.mts} +5 -5
- package/dist/index.d.mts.map +1 -0
- package/dist/{index.js → index.mjs} +3 -3
- package/dist/{index.cjs.map → index.mjs.map} +1 -1
- package/dist/ssr.cjs +2 -3
- package/dist/ssr.d.cts +2 -2
- package/dist/{ssr.d.ts → ssr.d.mts} +3 -3
- package/dist/ssr.d.mts.map +1 -0
- package/dist/{ssr.js → ssr.mjs} +2 -2
- package/dist/{ssr.cjs.map → ssr.mjs.map} +1 -1
- package/package.json +17 -17
- package/scripts/copyToRepl.ts +6 -6
- package/src/compile/build/client/addMappedTextWithOffsets.ts +31 -0
- package/src/compile/build/client/buildAddFragment.ts +11 -11
- package/src/compile/build/client/buildComponentNode.ts +126 -29
- package/src/compile/build/client/buildElementNode.ts +65 -8
- package/src/compile/build/client/buildIfNode.ts +1 -1
- package/src/compile/build/client/buildSwitchNode.ts +1 -1
- package/src/compile/build/client/buildTextNode.ts +13 -6
- package/src/compile/build/client/getAttributeOffsets.ts +90 -0
- package/src/compile/build/client/stashRunWithOffsets.ts +7 -1
- package/src/compile/build/server/buildServerElementNode.ts +1 -1
- package/src/compile/parse/parseTag.ts +1 -7
- package/src/compile/parse/parseText.ts +1 -1
- package/src/render/buildClasses.ts +1 -1
- package/src/render/buildStyles.ts +3 -1
- package/src/types/ClassValue.ts +6 -1
- package/src/types/StyleValue.ts +6 -1
- package/test/class/class.test.ts +31 -12
- package/test/class/components/output/Class-client.ts +62 -17
- package/test/class/components/output/Class-server.ts +40 -6
- package/test/class/components/temp/Class-client-c100fef7474dd892108c52b2cfed5825a3412e8b.ts +123 -0
- package/test/class/components/temp/Class-server-f42d0611a27002b493da55392baf7244d31e0d39.ts +78 -0
- package/test/source-maps/interpolated.test.ts +88 -0
- package/test/source-maps/parse.test.ts +1 -1
- package/tsdown.config.ts +2 -9
- package/vitest.config.ts +3 -3
- package/dist/Cleanup-BGQ5zaxE.d.cts.map +0 -1
- package/dist/Cleanup-Ca8IspaG.d.ts.map +0 -1
- package/dist/Component-JVwSemf-.d.ts.map +0 -1
- package/dist/Region-BrsZLZUe.d.ts.map +0 -1
- package/dist/compile.cjs.map +0 -1
- package/dist/compile.d.ts.map +0 -1
- package/dist/compile.js.map +0 -1
- package/dist/dev.d.ts.map +0 -1
- package/dist/dev.js.map +0 -1
- package/dist/devContext-CevrTlUO.js.map +0 -1
- package/dist/formatText-Bcb1JvW5.d.cts.map +0 -1
- package/dist/formatText-BlLF3PPm.d.ts.map +0 -1
- package/dist/formatText-Ck04q8_X.cjs.map +0 -1
- package/dist/formatText-OyD8MNAM.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ssr.d.ts.map +0 -1
- package/dist/ssr.js.map +0 -1
- package/test/class/components/temp/Class-client-d17977d356d8c8f964eaa1ac5a381814b33c22ba.ts +0 -78
- package/test/class/components/temp/Class-server-e4adcf242d5620acfcfa31c57b9b35c323a15664.ts +0 -44
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { build } from "../../src/compile";
|
|
3
|
+
import parse from "../../src/compile/parse";
|
|
4
|
+
|
|
5
|
+
test("source maps with interpolated attributes in element", () => {
|
|
6
|
+
const input = `
|
|
7
|
+
export default function Source() {
|
|
8
|
+
@render {
|
|
9
|
+
<div id="{a}-{bc}-{d}"></div>
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`.trim();
|
|
13
|
+
|
|
14
|
+
const parsed = parse(input);
|
|
15
|
+
const built = build(parsed.template!, { mapped: true });
|
|
16
|
+
|
|
17
|
+
//console.log(built.code);
|
|
18
|
+
//console.log(built.map);
|
|
19
|
+
|
|
20
|
+
const matches = built.map.filter(
|
|
21
|
+
(m) => m.script === 't_attribute(t_div_1, "id", `${a}-${bc}-${d}`);',
|
|
22
|
+
);
|
|
23
|
+
expect(matches.length).toBe(3);
|
|
24
|
+
|
|
25
|
+
expect(matches[0].source.start).toBe(input.indexOf("{a}") + 1);
|
|
26
|
+
expect(matches[0].compiled.start).toBe(built.code.indexOf("{a}") + 1);
|
|
27
|
+
expect(matches[1].source.start).toBe(input.indexOf("{bc}") + 1);
|
|
28
|
+
expect(matches[1].compiled.start).toBe(built.code.indexOf("{bc}") + 1);
|
|
29
|
+
expect(matches[2].source.start).toBe(input.indexOf("{d}") + 1);
|
|
30
|
+
expect(matches[2].compiled.start).toBe(built.code.indexOf("{d}") + 1);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("source maps with interpolated attributes in component", () => {
|
|
34
|
+
const input = `
|
|
35
|
+
export default function Source() {
|
|
36
|
+
@render {
|
|
37
|
+
<Child id="{a}-{bc}-{d}" />
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`.trim();
|
|
41
|
+
|
|
42
|
+
const parsed = parse(input);
|
|
43
|
+
const built = build(parsed.template!, { mapped: true });
|
|
44
|
+
|
|
45
|
+
//console.log(built.code);
|
|
46
|
+
//console.log(built.map);
|
|
47
|
+
|
|
48
|
+
const matches = built.map.filter((m) => m.script === "id: `${a}-${bc}-${d}`,");
|
|
49
|
+
expect(matches.length).toBe(3);
|
|
50
|
+
|
|
51
|
+
expect(matches[0].source.start).toBe(input.indexOf("{a}") + 1);
|
|
52
|
+
expect(matches[0].compiled.start).toBe(built.code.indexOf("{a}") + 1);
|
|
53
|
+
expect(matches[1].source.start).toBe(input.indexOf("{bc}") + 1);
|
|
54
|
+
expect(matches[1].compiled.start).toBe(built.code.indexOf("{bc}") + 1);
|
|
55
|
+
expect(matches[2].source.start).toBe(input.indexOf("{d}") + 1);
|
|
56
|
+
expect(matches[2].compiled.start).toBe(built.code.indexOf("{d}") + 1);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("source maps with interpolated text", () => {
|
|
60
|
+
const input = `
|
|
61
|
+
export default function Source() {
|
|
62
|
+
@render {
|
|
63
|
+
<div>
|
|
64
|
+
id={a}
|
|
65
|
+
and {bc}, {d}
|
|
66
|
+
</div>
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`.trim();
|
|
70
|
+
|
|
71
|
+
const parsed = parse(input);
|
|
72
|
+
const built = build(parsed.template!, { mapped: true });
|
|
73
|
+
|
|
74
|
+
//console.log(built.code);
|
|
75
|
+
//console.log(built.map);
|
|
76
|
+
|
|
77
|
+
const matches = built.map.filter(
|
|
78
|
+
(m) => m.script === "t_text_1.textContent = ` id=${t_fmt(a)} and ${t_fmt(bc)}, ${t_fmt(d)} `;",
|
|
79
|
+
);
|
|
80
|
+
expect(matches.length).toBe(3);
|
|
81
|
+
|
|
82
|
+
expect(matches[0].source.start).toBe(input.indexOf("{a}") + 1);
|
|
83
|
+
expect(matches[0].compiled.start).toBe(built.code.indexOf("(a)") + 1);
|
|
84
|
+
expect(matches[1].source.start).toBe(input.indexOf("{bc}") + 1);
|
|
85
|
+
expect(matches[1].compiled.start).toBe(built.code.indexOf("(bc)") + 1);
|
|
86
|
+
expect(matches[2].source.start).toBe(input.indexOf("{d}") + 1);
|
|
87
|
+
expect(matches[2].compiled.start).toBe(built.code.indexOf("(d)") + 1);
|
|
88
|
+
});
|
|
@@ -2,7 +2,7 @@ import { assert, expect, test } from "vitest";
|
|
|
2
2
|
import { build } from "../../src/compile";
|
|
3
3
|
import parse from "../../src/compile/parse";
|
|
4
4
|
|
|
5
|
-
test("source maps", () => {
|
|
5
|
+
test("parse source maps", () => {
|
|
6
6
|
const input = `
|
|
7
7
|
export default function Source($props: { counter: number }) {
|
|
8
8
|
const x = 5;
|
package/tsdown.config.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
type Config =
|
|
4
|
-
| Options
|
|
5
|
-
| Options[]
|
|
6
|
-
| ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
|
1
|
+
import { type UserConfig, defineConfig } from "tsdown";
|
|
7
2
|
|
|
8
3
|
export default defineConfig({
|
|
9
4
|
entry: ["src/index.ts", "src/compile.ts", "src/ssr.ts", "src/dev.ts"],
|
|
10
5
|
format: ["esm", "cjs"],
|
|
11
|
-
|
|
12
|
-
sourcemap: true,
|
|
13
|
-
}) satisfies Config as Config;
|
|
6
|
+
}) satisfies UserConfig as UserConfig;
|
package/vitest.config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import torpor from "../unplugin/dist/vite";
|
|
1
|
+
import { type ViteUserConfigFnObject, defineConfig } from "vitest/config";
|
|
2
|
+
import torpor from "../unplugin/dist/vite.mjs";
|
|
3
3
|
|
|
4
4
|
export default defineConfig(({ mode }) => ({
|
|
5
5
|
plugins: [torpor()],
|
|
@@ -10,4 +10,4 @@ export default defineConfig(({ mode }) => ({
|
|
|
10
10
|
environment: "jsdom",
|
|
11
11
|
globalSetup: "./test/globalSetup.ts",
|
|
12
12
|
},
|
|
13
|
-
})) satisfies
|
|
13
|
+
})) satisfies ViteUserConfigFnObject as ViteUserConfigFnObject;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cleanup-BGQ5zaxE.d.cts","names":[],"sources":["../src/types/Cleanup.ts"],"sourcesContent":[],"mappings":";;;;;KAIK,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cleanup-Ca8IspaG.d.ts","names":[],"sources":["../src/types/Cleanup.ts"],"sourcesContent":[],"mappings":";;;;;KAIK,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Component-JVwSemf-.d.ts","names":[],"sources":["../src/types/SlotRender.ts","../src/types/Component.ts"],"sourcesContent":[],"mappings":";KAAK,UAAA,cACM,sBACA,uBACA,OAAO,8BACN,OAAO;;;;;;KCCd,SAAA,GDFa,CAAA,OAAA,ECGR,UDHQ,EAAA,OAAA,ECIR,IDJQ,GAAA,IAAA,EAAA,MAAA,CAAA,ECKR,MDLQ,CCKD,WDLC,EAAA,GAAA,CAAA,EAAA,QAAA,CAAA,ECMN,MDNM,CCMC,WDND,EAAA,GAAA,CAAA,EAAA,MAAA,CAAA,ECOR,MDPQ,CAAA,MAAA,ECOO,UDPP,CAAA,EAAA,GAAA,IAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Region-BrsZLZUe.d.ts","names":[],"sources":["../src/types/constants.ts","../src/types/Computed.ts","../src/types/ProxySignal.ts","../src/types/Subscription.ts","../src/types/Effect.ts","../src/types/Region.ts"],"sourcesContent":[],"mappings":";;;;;;AAGa,cAAA,WAAA,GAAA,CAAA;AAKb;AAKA;;cALa,aAAA;;ACPiB;;AAgBtB,cDJK,WAAA,GCIL,CAAA;;;;ADdR;AAKA;AAKA;;UCLyB;;AAPK;;EAgBtB,IAAA,EAAA,OALM,aAKN;EAKI;;;EAiCD,KAAA,EAtCH,CAsCG;EAAA;;;aAjCC;ECrBgB;;;EAoBP,WAAA,EDMP,YCNO,GAAA,IAAA;EAAA;;;eDWP;EE9Be;;;;;;EA2BhB,MAAA,EAAA,OAAA;EAQI;;;;;ACnCW;;EAehB,QAAA,EAAA,OAAA;EAKF;;;EAoBQ,QAAA,EHaP,YGbO,GAAA,IAAA;EAAA;;;;;;;;AJvClB;AAKA;AAKA;UENyB,WAAA;;;ADNK;EAWhB,IAAA,EAAA,OCDA,WDCA;EAKN;;;EAeM,WAAA,EChBA,YDgBA,GAAA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