Skip to content

Commit 238e300

Browse files
authored
refactor: simplify xml generation (#4942)
- got rid of svg hacks, suffix seems work well - filtered data instead of generating empty components - fixed sitemap in features fixture
1 parent 85f83b6 commit 238e300

File tree

9 files changed

+110
-144
lines changed

9 files changed

+110
-144
lines changed

fixtures/webstudio-features/.template/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { defineConfig } from "vite";
33
import { reactRouter } from "@react-router/dev/vite";
44
// @ts-ignore
55
import { dedupeMeta } from "./proxy-emulator/dedupe-meta";
6-
import { existsSync, readdirSync } from "fs";
6+
import { existsSync } from "fs";
77
// @ts-ignore
88
import path from "path";
99
// @ts-ignore

fixtures/webstudio-features/.webstudio/data.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"build": {
3-
"id": "fce42d58-8a67-4f4b-8427-ea7500132e28",
3+
"id": "6f14cdae-073c-4f2c-b535-da3f404f3e36",
44
"projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d",
5-
"version": 477,
6-
"createdAt": "2025-02-28T14:52:36.082+00:00",
7-
"updatedAt": "2025-02-28T14:52:36.082+00:00",
5+
"version": 479,
6+
"createdAt": "2025-03-04T16:25:33.097+00:00",
7+
"updatedAt": "2025-03-04T16:25:33.097+00:00",
88
"pages": {
99
"meta": {
1010
"siteName": "KittyGuardedZone",
@@ -2867,7 +2867,7 @@
28672867
"instanceId": "SVI6fI342JAxCvwsg4Oc6",
28682868
"name": "xmlns:xhtml",
28692869
"type": "string",
2870-
"value": "http://www.w3.org/1999/xhtml"
2870+
"value": "http://www.w3.org/TR/xhtml11/xhtml11_schema.html"
28712871
}
28722872
],
28732873
[

fixtures/webstudio-features/app/__generated__/$resources.sitemap.xml.ts

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/webstudio-features/app/__generated__/[sitemap.xml]._index.tsx

Lines changed: 45 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/webstudio-features/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dev": "react-router dev",
77
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
88
"fixtures:link": "pnpm cli link --link https://p-cddc1d44-af37-4cb6-a430-d300cf6f932d-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=1cdc6026-dd5b-4624-b89b-9bd45e9bcc3d'",
9-
"fixtures:sync": "pnpm cli sync --buildId fce42d58-8a67-4f4b-8427-ea7500132e28 && pnpm prettier --write ./.webstudio/",
9+
"fixtures:sync": "pnpm cli sync --buildId 6f14cdae-073c-4f2c-b535-da3f404f3e36 && pnpm prettier --write ./.webstudio/",
1010
"fixtures:build": "pnpm cli build --template react-router --template ./.template && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
1111
},
1212
"private": true,

fixtures/webstudio-features/proxy-emulator/dedupe-meta.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ export const dedupeMeta: Plugin = {
1717
const originalWrite = res.write;
1818
const originalEnd = res.end;
1919

20-
let body = "";
20+
const buffers: Buffer[] = [];
2121

2222
res.write = (chunk) => {
23-
body += chunk.toString();
23+
buffers.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
2424
return true;
2525
};
2626

2727
res.end = (chunk) => {
2828
if (chunk) {
29-
body += chunk.toString();
29+
buffers.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
3030
}
3131

32+
const body = Buffer.concat(buffers).toString("utf8");
3233
const response = new Response(body);
3334

3435
const metasSet = new Set<string>();

fixtures/webstudio-features/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { defineConfig } from "vite";
33
import { reactRouter } from "@react-router/dev/vite";
44
// @ts-ignore
55
import { dedupeMeta } from "./proxy-emulator/dedupe-meta";
6-
import { existsSync, readdirSync } from "fs";
6+
import { existsSync } from "fs";
77
// @ts-ignore
88
import path from "path";
99
// @ts-ignore

0 commit comments

Comments
 (0)