zitejs 0.10.0-start.7 → 0.10.0-start.8
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/cjs/sync/lib.js +4 -7
- package/dist/cjs/vite/index.js +8 -3
- package/dist/cjs/vite/index.test.js +10 -2
- package/dist/esm/start/airtable/arrayFields.d.ts +10 -0
- package/dist/esm/start/airtable/arrayFields.js +30 -0
- package/dist/esm/start/airtable/dispatch.d.ts +54 -0
- package/dist/esm/start/airtable/dispatch.js +465 -0
- package/dist/esm/start/airtable/formulas.d.ts +69 -0
- package/dist/esm/start/airtable/formulas.js +235 -0
- package/dist/esm/start/airtable/index.d.ts +11 -0
- package/dist/esm/start/airtable/index.js +70 -0
- package/dist/esm/start/data/baseRunner.d.ts +92 -0
- package/dist/esm/start/data/baseRunner.js +83 -0
- package/dist/esm/start/data/dispatch.d.ts +16 -0
- package/dist/esm/start/data/dispatch.js +198 -0
- package/dist/esm/start/data/index.d.ts +18 -0
- package/dist/esm/start/data/index.js +76 -0
- package/dist/esm/start/data/sqlNameMappings.d.ts +58 -0
- package/dist/esm/start/data/sqlNameMappings.js +92 -0
- package/dist/esm/start/data/transformations.d.ts +128 -0
- package/dist/esm/start/data/transformations.js +318 -0
- package/dist/esm/start/data/types.d.ts +91 -0
- package/dist/esm/start/data/types.js +14 -0
- package/dist/esm/start/server.js +54 -5
- package/dist/esm/start/types.d.ts +40 -0
- package/dist/esm/start/version.d.ts +1 -1
- package/dist/esm/start/version.js +1 -1
- package/dist/esm/start/vite.js +2 -1
- package/dist/esm/sync/lib.js +4 -7
- package/dist/esm/vite/index.js +8 -3
- package/dist/esm/vite/index.test.js +10 -2
- package/package.json +1 -1
package/dist/esm/vite/index.js
CHANGED
|
@@ -69,11 +69,12 @@ export function ziteId() {
|
|
|
69
69
|
name: "vite-plugin-zite-id",
|
|
70
70
|
enforce: "pre",
|
|
71
71
|
async transform(code, id) {
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
// TanStack's route code splitting moves a route's component into its own module, `route.tsx?tsr-split=…`.
|
|
73
|
+
const file = id.split("?")[0];
|
|
74
|
+
if (!validExtensions.has(path.extname(file)) || file.includes("node_modules")) {
|
|
74
75
|
return null;
|
|
75
76
|
}
|
|
76
|
-
const relativePath = path.relative(cwd,
|
|
77
|
+
const relativePath = path.relative(cwd, file);
|
|
77
78
|
try {
|
|
78
79
|
const ast = parse(code, {
|
|
79
80
|
sourceType: "module",
|
|
@@ -128,6 +129,10 @@ export function ziteId() {
|
|
|
128
129
|
if (!isTagged) {
|
|
129
130
|
return;
|
|
130
131
|
}
|
|
132
|
+
// A module split from one already tagged keeps its tags.
|
|
133
|
+
if (openingElement.attributes?.some((attr) => attr.type === "JSXAttribute" && attr.name?.name === "data-zite-id")) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
131
136
|
const line = openingElement.loc?.start?.line ?? 0;
|
|
132
137
|
const col = openingElement.loc?.start?.column ?? 0;
|
|
133
138
|
const dataComponentId = `${relativePath}|${line}|${col}`;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { ziteId } from './index.js';
|
|
4
|
-
async function transform(code) {
|
|
4
|
+
async function transform(code, file = 'src/App.tsx') {
|
|
5
5
|
const plugin = ziteId();
|
|
6
6
|
const handler = plugin.transform;
|
|
7
|
-
const result = await handler(code, path.join(process.cwd(),
|
|
7
|
+
const result = await handler(code, path.join(process.cwd(), file));
|
|
8
8
|
if (!result) {
|
|
9
9
|
throw new Error('transform returned null');
|
|
10
10
|
}
|
|
11
11
|
return result.code;
|
|
12
12
|
}
|
|
13
13
|
describe('ziteId', () => {
|
|
14
|
+
it("tags a route's component that TanStack split into its own module, by the source file", async () => {
|
|
15
|
+
const code = await transform('const a = <p>Hi</p>;', 'src/routes/index.tsx?tsr-split=component');
|
|
16
|
+
expect(code).toContain('<p data-zite-id="src/routes/index.tsx|1|10" data-zite-editable="true">');
|
|
17
|
+
});
|
|
18
|
+
it('leaves an element that already has its tag', async () => {
|
|
19
|
+
const code = await transform('const a = <p data-zite-id="src/routes/index.tsx|1|10">Hi</p>;');
|
|
20
|
+
expect(code.match(/data-zite-id/g)).toHaveLength(1);
|
|
21
|
+
});
|
|
14
22
|
it('tags html and svg elements without a component name', async () => {
|
|
15
23
|
const code = await transform('const a = <div><svg><path d="M0" /></svg><p>Hello</p></div>;');
|
|
16
24
|
expect(code).toContain('<div data-zite-id="src/App.tsx|1|10">');
|