Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
build: Ability to publish Pages with document type XML (#3316)
Ivan Starkov0571d2d50efc
diff --git a/fixtures/webstudio-cloudflare-template/.npmrc b/fixtures/webstudio-cloudflare-template/.npmrcnew file mode 100644index 0000000000..5e3cde50ab--- /dev/null+++ b/fixtures/webstudio-cloudflare-template/.npmrc@@ -0,0 +1 @@+force=truediff --git a/fixtures/webstudio-cloudflare-template/app/__generated__/[sitemap.xml].ts b/fixtures/webstudio-cloudflare-template/app/__generated__/$resources.sitemap.xml.tssimilarity index 100%rename from fixtures/webstudio-cloudflare-template/app/__generated__/[sitemap.xml].tsrename to fixtures/webstudio-cloudflare-template/app/__generated__/$resources.sitemap.xml.tsdiff --git a/fixtures/webstudio-cloudflare-template/app/routes/[sitemap.xml].tsx b/fixtures/webstudio-cloudflare-template/app/routes/[sitemap.xml]._index.tsxsimilarity index 91%rename from fixtures/webstudio-cloudflare-template/app/routes/[sitemap.xml].tsxrename to fixtures/webstudio-cloudflare-template/app/routes/[sitemap.xml]._index.tsxindex a9a3faa696..2a57cb3721 100644--- a/fixtures/webstudio-cloudflare-template/app/routes/[sitemap.xml].tsx+++ b/fixtures/webstudio-cloudflare-template/app/routes/[sitemap.xml]._index.tsx@@ -1,5 +1,5 @@import type { LoaderFunctionArgs } from "@remix-run/server-runtime";-import { sitemap } from "../__generated__/[sitemap.xml]";+import { sitemap } from "../__generated__/$resources.sitemap.xml";export const loader = (arg: LoaderFunctionArgs) => {const host =diff --git a/fixtures/webstudio-custom-template/.npmrc b/fixtures/webstudio-custom-template/.npmrcnew file mode 100644index 0000000000..5e3cde50ab--- /dev/null+++ b/fixtures/webstudio-custom-template/.npmrc@@ -0,0 +1 @@+force=truediff --git a/fixtures/webstudio-custom-template/.webstudio/data.json b/fixtures/webstudio-custom-template/.webstudio/data.jsonindex 72e2f58379..6530f55731 100644--- a/fixtures/webstudio-custom-template/.webstudio/data.json+++ b/fixtures/webstudio-custom-template/.webstudio/data.json@@ -1,10 +1,10 @@{"build": {- "id": "a7480f00-e7b3-467d-a3f0-45d8b339fe11",+ "id": "d48c7c5e-fdd3-4ef6-9173-ff2eaaf851d9","projectId": "0d856812-61d8-4014-a20a-82e01c0eb8ee",- "version": 228,- "createdAt": "2024-04-23T17:26:49.325Z",- "updatedAt": "2024-04-23T17:26:49.325Z",+ "version": 244,+ "createdAt": "2024-05-06T21:23:44.086Z",+ "updatedAt": "2024-05-06T21:23:44.086Z","pages": {"meta": {"siteName": "Fixture Site",@@ -69,7 +69,7 @@},{"id": "2HLHiU2IwQkvfO0Uuodgo",- "name": "sitemap-html",+ "name": "sitemap.xml","title": "\"Untitled\"","meta": {"description": "\"\"",@@ -78,11 +78,12 @@"socialImageUrl": "\"\"","status": "200","redirect": "\"\"",+ "documentType": "xml","custom": []},"rootInstanceId": "rve0BYRbzAkSCr3Lq-wzi","systemDataSourceId": "6AKzkKHNkIHWUGJDCoXNz",- "path": "/sitemap-html"+ "path": "/sitemap.xml"}],"folders": [@@ -1227,80 +1228,6 @@"alpha": 1}}- ],- [- "y72KMNELJQv7WCC2EVikH:mIDIDBHsdlix3RVZAVmv7:marginLeft:",- {- "styleSourceId": "y72KMNELJQv7WCC2EVikH",- "breakpointId": "mIDIDBHsdlix3RVZAVmv7",- "property": "marginLeft",- "value": {- "type": "unit",- "unit": "px",- "value": 20- }- }- ],- [- "y72KMNELJQv7WCC2EVikH:mIDIDBHsdlix3RVZAVmv7:display:",- {- "styleSourceId": "y72KMNELJQv7WCC2EVikH",- "breakpointId": "mIDIDBHsdlix3RVZAVmv7",- "property": "display",- "value": {- "type": "keyword",- "value": "flex"- }- }- ],- [- "crYPhCE3T9eEs-5p-HERt:mIDIDBHsdlix3RVZAVmv7:marginLeft:",- {- "styleSourceId": "crYPhCE3T9eEs-5p-HERt",- "breakpointId": "mIDIDBHsdlix3RVZAVmv7",- "property": "marginLeft",- "value": {- "type": "unit",- "unit": "px",- "value": 20- }- }- ],- [- "crYPhCE3T9eEs-5p-HERt:mIDIDBHsdlix3RVZAVmv7:display:",- {- "styleSourceId": "crYPhCE3T9eEs-5p-HERt",- "breakpointId": "mIDIDBHsdlix3RVZAVmv7",- "property": "display",- "value": {- "type": "keyword",- "value": "flex"- }- }- ],- [- "CPXm9ByL_tFAhAz2Yjh_g:mIDIDBHsdlix3RVZAVmv7:fontWeight:",- {- "styleSourceId": "CPXm9ByL_tFAhAz2Yjh_g",- "breakpointId": "mIDIDBHsdlix3RVZAVmv7",- "property": "fontWeight",- "value": {- "type": "keyword",- "value": "600"- }- }- ],- [- "5eoCM_8Q2H8ijgCjCDE08:mIDIDBHsdlix3RVZAVmv7:fontWeight:",- {- "styleSourceId": "5eoCM_8Q2H8ijgCjCDE08",- "breakpointId": "mIDIDBHsdlix3RVZAVmv7",- "property": "fontWeight",- "value": {- "type": "keyword",- "value": "600"- }- }]],"styleSources": [@@ -1404,34 +1331,6 @@"id": "iBzrDKfBww47SfmKZnSMO","name": "color:lastmod"}- ],- [- "y72KMNELJQv7WCC2EVikH",- {- "type": "local",- "id": "y72KMNELJQv7WCC2EVikH"- }- ],- [- "CPXm9ByL_tFAhAz2Yjh_g",- {- "type": "local",- "id": "CPXm9ByL_tFAhAz2Yjh_g"- }- ],- [- "crYPhCE3T9eEs-5p-HERt",- {- "type": "local",- "id": "crYPhCE3T9eEs-5p-HERt"- }- ],- [- "5eoCM_8Q2H8ijgCjCDE08",- {- "type": "local",- "id": "5eoCM_8Q2H8ijgCjCDE08"- }]],"styleSourceSelections": [@@ -1511,76 +1410,6 @@"instanceId": "COafOppxs73Ne4O0Geik0","values": ["jGTUoz0ux0EK-bikmqnw7"]}- ],- [- "FD1zWHCq5TVsTSBKWbtV3",- {- "instanceId": "FD1zWHCq5TVsTSBKWbtV3",- "values": ["3JNfFwmMATeV1bH2RfBgF"]- }- ],- [- "eSgI63Vtow0HYHYWUXn3U",- {- "instanceId": "eSgI63Vtow0HYHYWUXn3U",- "values": ["y72KMNELJQv7WCC2EVikH"]- }- ],- [- "YT4punX-Bdhl0Dw8l6kum",- {- "instanceId": "YT4punX-Bdhl0Dw8l6kum",- "values": ["nS9BC-b89uRhQ6jI-6el4"]- }- ],- [- "85KbQ_KRH5fQsA0pDR9G9",- {- "instanceId": "85KbQ_KRH5fQsA0pDR9G9",- "values": ["CPXm9ByL_tFAhAz2Yjh_g"]- }- ],- [- "qdI0BY3e4j8USqw370Qrs",- {- "instanceId": "qdI0BY3e4j8USqw370Qrs",- "values": ["nS9BC-b89uRhQ6jI-6el4"]- }- ],- [- "rRH1A7WUjY-_pfauYCmKU",- {- "instanceId": "rRH1A7WUjY-_pfauYCmKU",- "values": ["crYPhCE3T9eEs-5p-HERt"]- }- ],- [- "6NZJcVjrr4WHS6eqNG1SF",- {- "instanceId": "6NZJcVjrr4WHS6eqNG1SF",- "values": ["iBzrDKfBww47SfmKZnSMO"]- }- ],- [- "i0u7W1XIPYHdwcD4bmm4Z",- {- "instanceId": "i0u7W1XIPYHdwcD4bmm4Z",- "values": ["5eoCM_8Q2H8ijgCjCDE08"]- }- ],- [- "NR5D_PEUVi_P7Agy2g1Zr",- {- "instanceId": "NR5D_PEUVi_P7Agy2g1Zr",- "values": ["iBzrDKfBww47SfmKZnSMO"]- }- ],- [- "Q1mx0RlJAIT37qXjHlt95",- {- "instanceId": "Q1mx0RlJAIT37qXjHlt95",- "values": ["3JNfFwmMATeV1bH2RfBgF"]- }]],"props": [@@ -1805,23 +1634,73 @@}],[- "fBGXDGATUkuv7EEF6Q7Oq",+ "g0jOVrFDusEjaGcraMHBo",{- "id": "fBGXDGATUkuv7EEF6Q7Oq",- "instanceId": "fN6n7cnYEEOejAQTZHd46",+ "id": "g0jOVrFDusEjaGcraMHBo",+ "instanceId": "PjSYDNWuQ4oIg52BShwxB","name": "data","type": "expression","value": "$ws$dataSource$kysfQMiYfpyLK8Z0BwHTn.data"}],[- "brJHBwmzzpg0rp5ZyU_VP",+ "PUdpnvEE2lyVs7OfBwc7T",{- "id": "brJHBwmzzpg0rp5ZyU_VP",- "instanceId": "fN6n7cnYEEOejAQTZHd46",+ "id": "PUdpnvEE2lyVs7OfBwc7T",+ "instanceId": "PjSYDNWuQ4oIg52BShwxB","name": "item","type": "parameter",- "value": "Jli9j5EFM9nbJJKyjmG5N"+ "value": "C3teXw_3uxq4VBGE_J2yo"+ }+ ],+ [+ "9JRtdabNdYoyqICQaqsF4",+ {+ "id": "9JRtdabNdYoyqICQaqsF4",+ "instanceId": "SKzEKWw1VtVVFvUcIWuUp",+ "name": "tag",+ "type": "string",+ "value": "url"+ }+ ],+ [+ "fVOxC1Eyp2-f4iAh_-u_O",+ {+ "id": "fVOxC1Eyp2-f4iAh_-u_O",+ "instanceId": "9NJGnzZG3iPZs78XPTHhH",+ "name": "tag",+ "type": "string",+ "value": "loc"+ }+ ],+ [+ "L3gLkXqCMivcNj9pLrKZs",+ {+ "id": "L3gLkXqCMivcNj9pLrKZs",+ "instanceId": "IjNaHLHI4gWStV8GvhijX",+ "name": "tag",+ "type": "string",+ "value": "lastmod"+ }+ ],+ [+ "sDNoSuQSDz9hSGBTNmkay",+ {+ "id": "sDNoSuQSDz9hSGBTNmkay",+ "instanceId": "cgaMXxOMMAh4H-u-MB3_0",+ "name": "tag",+ "type": "string",+ "value": "urlset"+ }+ ],+ [+ "PLqbTfaDLOS5hxJ_dERqI",+ {+ "id": "PLqbTfaDLOS5hxJ_dERqI",+ "instanceId": "cgaMXxOMMAh4H-u-MB3_0",+ "name": "xmlns",+ "type": "string",+ "value": "http://www.sitemaps.org/schemas/sitemap/0.9"}]],@@ -1873,26 +1752,13 @@}],[- "Jli9j5EFM9nbJJKyjmG5N",+ "C3teXw_3uxq4VBGE_J2yo",{"type": "parameter",- "id": "Jli9j5EFM9nbJJKyjmG5N",- "scopeInstanceId": "fN6n7cnYEEOejAQTZHd46",+ "id": "C3teXw_3uxq4VBGE_J2yo",+ "scopeInstanceId": "PjSYDNWuQ4oIg52BShwxB","name": "url"}- ],- [- "-tLBLywqXy2NSb7eonEuq",- {- "type": "variable",- "id": "-tLBLywqXy2NSb7eonEuq",- "scopeInstanceId": "rve0BYRbzAkSCr3Lq-wzi",- "name": "origin",- "value": {- "type": "string",- "value": "https://my-site.cc"- }- }]],"resources": [@@ -2250,215 +2116,82 @@"children": [{"type": "id",- "value": "fN6n7cnYEEOejAQTZHd46"+ "value": "cgaMXxOMMAh4H-u-MB3_0"}]}],[- "fN6n7cnYEEOejAQTZHd46",+ "cgaMXxOMMAh4H-u-MB3_0",{"type": "instance",- "id": "fN6n7cnYEEOejAQTZHd46",- "component": "ws:collection",- "label": "SitemapXml",+ "id": "cgaMXxOMMAh4H-u-MB3_0",+ "component": "XmlNode","children": [{"type": "id",- "value": "qNCcAfJQFIBEGM99hOGcj"+ "value": "PjSYDNWuQ4oIg52BShwxB"}]}],[- "qNCcAfJQFIBEGM99hOGcj",+ "PjSYDNWuQ4oIg52BShwxB",{"type": "instance",- "id": "qNCcAfJQFIBEGM99hOGcj",- "component": "Box",- "label": "url",+ "id": "PjSYDNWuQ4oIg52BShwxB",+ "component": "ws:collection",+ "label": "urls","children": [{"type": "id",- "value": "FD1zWHCq5TVsTSBKWbtV3"- },- {- "type": "id",- "value": "eSgI63Vtow0HYHYWUXn3U"- },- {- "type": "id",- "value": "rRH1A7WUjY-_pfauYCmKU"- },- {- "type": "id",- "value": "Q1mx0RlJAIT37qXjHlt95"- }- ]- }- ],- [- "FD1zWHCq5TVsTSBKWbtV3",- {- "type": "instance",- "id": "FD1zWHCq5TVsTSBKWbtV3",- "component": "Text",- "label": "<url>",- "children": [- {- "type": "text",- "value": "<url>"+ "value": "SKzEKWw1VtVVFvUcIWuUp"}]}],[- "eSgI63Vtow0HYHYWUXn3U",+ "SKzEKWw1VtVVFvUcIWuUp",{"type": "instance",- "id": "eSgI63Vtow0HYHYWUXn3U",- "component": "Box",- "label": "loc",+ "id": "SKzEKWw1VtVVFvUcIWuUp",+ "component": "XmlNode","children": [{"type": "id",- "value": "YT4punX-Bdhl0Dw8l6kum"- },- {- "type": "id",- "value": "85KbQ_KRH5fQsA0pDR9G9"+ "value": "9NJGnzZG3iPZs78XPTHhH"},{"type": "id",- "value": "qdI0BY3e4j8USqw370Qrs"+ "value": "IjNaHLHI4gWStV8GvhijX"}]}],[- "YT4punX-Bdhl0Dw8l6kum",+ "9NJGnzZG3iPZs78XPTHhH",{"type": "instance",- "id": "YT4punX-Bdhl0Dw8l6kum",- "component": "Text",- "label": "<loc>",- "children": [- {- "type": "text",- "value": "<loc>"- }- ]- }- ],- [- "85KbQ_KRH5fQsA0pDR9G9",- {- "type": "instance",- "id": "85KbQ_KRH5fQsA0pDR9G9",- "component": "Text",- "label": "value",+ "id": "9NJGnzZG3iPZs78XPTHhH",+ "component": "XmlNode","children": [{"type": "expression",- "value": "$ws$dataSource$__DASH__tLBLywqXy2NSb7eonEuq + $ws$dataSource$Jli9j5EFM9nbJJKyjmG5N.path"- }- ]- }- ],- [- "qdI0BY3e4j8USqw370Qrs",- {- "type": "instance",- "id": "qdI0BY3e4j8USqw370Qrs",- "component": "Text",- "label": "</loc>",- "children": [- {- "type": "text",- "value": "</loc>"- }- ]- }- ],- [- "rRH1A7WUjY-_pfauYCmKU",- {- "type": "instance",- "id": "rRH1A7WUjY-_pfauYCmKU",- "component": "Box",- "label": "lastmod",- "children": [- {- "type": "id",- "value": "6NZJcVjrr4WHS6eqNG1SF"- },- {- "type": "id",- "value": "i0u7W1XIPYHdwcD4bmm4Z"- },- {- "type": "id",- "value": "NR5D_PEUVi_P7Agy2g1Zr"+ "value": "`${$ws$dataSource$6AKzkKHNkIHWUGJDCoXNz.origin ?? '${ORIGIN}'}${$ws$dataSource$C3teXw_3uxq4VBGE_J2yo.path}`"}]}],[- "6NZJcVjrr4WHS6eqNG1SF",+ "IjNaHLHI4gWStV8GvhijX",{"type": "instance",- "id": "6NZJcVjrr4WHS6eqNG1SF",- "component": "Text",- "label": "<lastmod>",- "children": [- {- "type": "text",- "value": "<lastmod>"- }- ]- }- ],- [- "i0u7W1XIPYHdwcD4bmm4Z",- {- "type": "instance",- "id": "i0u7W1XIPYHdwcD4bmm4Z",- "component": "Text",- "label": "value",+ "id": "IjNaHLHI4gWStV8GvhijX",+ "component": "XmlNode","children": [{"type": "expression",- "value": "$ws$dataSource$Jli9j5EFM9nbJJKyjmG5N.lastModified"- }- ]- }- ],- [- "NR5D_PEUVi_P7Agy2g1Zr",- {- "type": "instance",- "id": "NR5D_PEUVi_P7Agy2g1Zr",- "component": "Text",- "label": "</lastmod>",- "children": [- {- "type": "text",- "value": "</lastmod>"- }- ]- }- ],- [- "Q1mx0RlJAIT37qXjHlt95",- {- "type": "instance",- "id": "Q1mx0RlJAIT37qXjHlt95",- "component": "Text",- "label": "</url>",- "children": [- {- "type": "text",- "value": "</url>"+ "value": "$ws$dataSource$C3teXw_3uxq4VBGE_J2yo.lastModified"}]}@@ -2533,7 +2266,7 @@},{"id": "2HLHiU2IwQkvfO0Uuodgo",- "name": "sitemap-html",+ "name": "sitemap.xml","title": "\"Untitled\"","meta": {"description": "\"\"",@@ -2542,11 +2275,12 @@"socialImageUrl": "\"\"","status": "200","redirect": "\"\"",+ "documentType": "xml","custom": []},"rootInstanceId": "rve0BYRbzAkSCr3Lq-wzi","systemDataSourceId": "6AKzkKHNkIHWUGJDCoXNz",- "path": "/sitemap-html"+ "path": "/sitemap.xml"}],"assets": [diff --git a/fixtures/webstudio-custom-template/app/__generated__/$resources.sitemap.xml.ts b/fixtures/webstudio-custom-template/app/__generated__/$resources.sitemap.xml.tsnew file mode 100644index 0000000000..4c1ab55cac--- /dev/null+++ b/fixtures/webstudio-custom-template/app/__generated__/$resources.sitemap.xml.ts@@ -0,0 +1,14 @@+export const sitemap = [+ {+ path: "/",+ lastModified: "2024-05-06",+ },+ {+ path: "/script-test",+ lastModified: "2024-05-06",+ },+ {+ path: "/world",+ lastModified: "2024-05-06",+ },+];diff --git a/fixtures/webstudio-custom-template/app/__generated__/[sitemap-html]._index.tsx b/fixtures/webstudio-custom-template/app/__generated__/[sitemap-html]._index.tsxdeleted file mode 100644index 53b70d2992..0000000000--- a/fixtures/webstudio-custom-template/app/__generated__/[sitemap-html]._index.tsx+++ /dev/null@@ -1,114 +0,0 @@-/* eslint-disable */-/* This is a auto generated file for building the project */--import { Fragment, useState } from "react";-import type { FontAsset, ImageAsset } from "@webstudio-is/sdk";-import { useResource } from "@webstudio-is/react-sdk";-import { Body as Body } from "@webstudio-is/sdk-components-react-remix";-import { Box as Box, Text as Text } from "@webstudio-is/sdk-components-react";--export const siteName = "Fixture Site";--export const favIconAsset: ImageAsset | undefined = {- id: "cd1e9fad-8df1-45c6-800f-05fda2d2469f",- name: "home_wsKvRSqvkajPPBeycZ-C8.svg",- description: null,- projectId: "0d856812-61d8-4014-a20a-82e01c0eb8ee",- size: 3350,- type: "image",- format: "svg",- createdAt: "2023-10-30T20:35:47.113Z",- meta: { width: 16, height: 16 },-};--export const socialImageAsset: ImageAsset | undefined = undefined;--// Font assets on current page (can be preloaded)-export const pageFontAssets: FontAsset[] = [];--export const pageBackgroundImageAssets: ImageAsset[] = [];--const Page = ({}: { system: any }) => {- let [origin, set$origin] = useState<any>("https://my-site.cc");- let sitemapxml = useResource("sitemapxml_1");- return (- <Body data-ws-id="rve0BYRbzAkSCr3Lq-wzi" data-ws-component="Body">- {sitemapxml?.data?.map((url: any, index: number) => (- <Fragment key={index}>- <Box data-ws-id="qNCcAfJQFIBEGM99hOGcj" data-ws-component="Box">- <Text- data-ws-id="FD1zWHCq5TVsTSBKWbtV3"- data-ws-component="Text"- className="cwnydv4"- >- {"<url>"}- </Text>- <Box- data-ws-id="eSgI63Vtow0HYHYWUXn3U"- data-ws-component="Box"- className="cnvcd8b cxb89wn"- >- <Text- data-ws-id="YT4punX-Bdhl0Dw8l6kum"- data-ws-component="Text"- className="c1s70es7"- >- {"<loc>"}- </Text>- <Text- data-ws-id="85KbQ_KRH5fQsA0pDR9G9"- data-ws-component="Text"- className="c5fu8k4"- >- {origin + url?.path}- </Text>- <Text- data-ws-id="qdI0BY3e4j8USqw370Qrs"- data-ws-component="Text"- className="c1s70es7"- >- {"</loc>"}- </Text>- </Box>- <Box- data-ws-id="rRH1A7WUjY-_pfauYCmKU"- data-ws-component="Box"- className="cnvcd8b cxb89wn"- >- <Text- data-ws-id="6NZJcVjrr4WHS6eqNG1SF"- data-ws-component="Text"- className="cgkkof0"- >- {"<lastmod>"}- </Text>- <Text- data-ws-id="i0u7W1XIPYHdwcD4bmm4Z"- data-ws-component="Text"- className="c5fu8k4"- >- {url?.lastModified}- </Text>- <Text- data-ws-id="NR5D_PEUVi_P7Agy2g1Zr"- data-ws-component="Text"- className="cgkkof0"- >- {"</lastmod>"}- </Text>- </Box>- <Text- data-ws-id="Q1mx0RlJAIT37qXjHlt95"- data-ws-component="Text"- className="cwnydv4"- >- {"</url>"}- </Text>- </Box>- </Fragment>- ))}- </Body>- );-};--export { Page };diff --git a/fixtures/webstudio-custom-template/app/__generated__/[sitemap-html]._index.server.tsx b/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml]._index.server.tsxsimilarity index 97%rename from fixtures/webstudio-custom-template/app/__generated__/[sitemap-html]._index.server.tsxrename to fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml]._index.server.tsxindex 065bf11aa7..3b21ec5193 100644--- a/fixtures/webstudio-custom-template/app/__generated__/[sitemap-html]._index.server.tsx+++ b/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml]._index.server.tsx@@ -3,7 +3,7 @@import type { PageMeta } from "@webstudio-is/sdk";import { loadResource, isLocalResource, type System } from "@webstudio-is/sdk";-import { sitemap } from "./[sitemap.xml]";+import { sitemap } from "./$resources.sitemap.xml";export const loadResources = async (_props: { system: System }) => {const customFetch: typeof fetch = (input, init) => {if (typeof input !== "string") {diff --git a/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml]._index.tsx b/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml]._index.tsxnew file mode 100644index 0000000000..caf94e2bbf--- /dev/null+++ b/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml]._index.tsx@@ -0,0 +1,71 @@+/* eslint-disable */+/* This is a auto generated file for building the project */++import { Fragment, useState } from "react";+import type { FontAsset, ImageAsset } from "@webstudio-is/sdk";+import { useResource } from "@webstudio-is/react-sdk";+import { XmlNode } from "@webstudio-is/sdk-components-react";++export const siteName = "Fixture Site";++export const favIconAsset: ImageAsset | undefined = {+ id: "cd1e9fad-8df1-45c6-800f-05fda2d2469f",+ name: "home_wsKvRSqvkajPPBeycZ-C8.svg",+ description: null,+ projectId: "0d856812-61d8-4014-a20a-82e01c0eb8ee",+ size: 3350,+ type: "image",+ format: "svg",+ createdAt: "2023-10-30T20:35:47.113Z",+ meta: { width: 16, height: 16 },+};++export const socialImageAsset: ImageAsset | undefined = undefined;++// Font assets on current page (can be preloaded)+export const pageFontAssets: FontAsset[] = [];++export const pageBackgroundImageAssets: ImageAsset[] = [];++const Body = (props: any) => props.children;++const Page = ({ system: system }: { system: any }) => {+ let sitemapxml = useResource("sitemapxml_1");+ return (+ <Body data-ws-id="rve0BYRbzAkSCr3Lq-wzi" data-ws-component="Body">+ <XmlNode+ data-ws-id="cgaMXxOMMAh4H-u-MB3_0"+ data-ws-component="XmlNode"+ tag={"urlset"}+ xmlns={"http://www.sitemaps.org/schemas/sitemap/0.9"}+ >+ {sitemapxml?.data?.map((url: any, index: number) => (+ <Fragment key={index}>+ <XmlNode+ data-ws-id="SKzEKWw1VtVVFvUcIWuUp"+ data-ws-component="XmlNode"+ tag={"url"}+ >+ <XmlNode+ data-ws-id="9NJGnzZG3iPZs78XPTHhH"+ data-ws-component="XmlNode"+ tag={"loc"}+ >+ {`${system?.origin ?? "${ORIGIN}"}${url?.path}`}+ </XmlNode>+ <XmlNode+ data-ws-id="IjNaHLHI4gWStV8GvhijX"+ data-ws-component="XmlNode"+ tag={"lastmod"}+ >+ {url?.lastModified}+ </XmlNode>+ </XmlNode>+ </Fragment>+ ))}+ </XmlNode>+ </Body>+ );+};++export { Page };diff --git a/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml].ts b/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml].tsdeleted file mode 100644index f01802de47..0000000000--- a/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml].ts+++ /dev/null@@ -1,18 +0,0 @@-export const sitemap = [- {- path: "/",- lastModified: "2024-04-23",- },- {- path: "/script-test",- lastModified: "2024-04-23",- },- {- path: "/world",- lastModified: "2024-04-23",- },- {- path: "/sitemap-html",- lastModified: "2024-04-23",- },-];diff --git a/fixtures/webstudio-custom-template/app/__generated__/index.css b/fixtures/webstudio-custom-template/app/__generated__/index.cssindex c284bf04b2..a909162781 100644--- a/fixtures/webstudio-custom-template/app/__generated__/index.css+++ b/fixtures/webstudio-custom-template/app/__generated__/index.css@@ -223,15 +223,6 @@ html {display: block;height: auto;}- div:where([data-ws-component="Text"]) {- box-sizing: border-box;- border-top-width: 1px;- border-right-width: 1px;- border-bottom-width: 1px;- border-left-width: 1px;- outline-width: 1px;- min-height: 1em;- }}@media all {.c12poxag {@@ -419,19 +410,4 @@ html {.cub4hpc {flex-basis: 0px;}- .cwnydv4 {- color: rgba(36, 12, 233, 1);- }- .cnvcd8b {- margin-left: 20px;- }- .c1s70es7 {- color: rgba(8, 137, 17, 1);- }- .c5fu8k4 {- font-weight: 600;- }- .cgkkof0 {- color: rgba(208, 24, 79, 1);- }}diff --git a/fixtures/webstudio-custom-template/app/routes/[sitemap-html]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[sitemap-html]._index.tsxdeleted file mode 100644index 1bc27c25b7..0000000000--- a/fixtures/webstudio-custom-template/app/routes/[sitemap-html]._index.tsx+++ /dev/null@@ -1,321 +0,0 @@-/* eslint-disable camelcase */-import {- type ServerRuntimeMetaFunction as MetaFunction,- type LinksFunction,- type LinkDescriptor,- type ActionFunctionArgs,- type LoaderFunctionArgs,- type HeadersFunction,- json,- redirect,-} from "@remix-run/server-runtime";-import { useLoaderData } from "@remix-run/react";-import { ReactSdkContext } from "@webstudio-is/react-sdk";-import { n8nHandler, getFormId } from "@webstudio-is/form-handlers";-import {- Page,- siteName,- favIconAsset,- socialImageAsset,- pageFontAssets,- pageBackgroundImageAssets,-} from "../__generated__/[sitemap-html]._index";-import {- formsProperties,- loadResources,- getPageMeta,- getRemixParams,- projectId,- contactEmail,-} from "../__generated__/[sitemap-html]._index.server";--import css from "../__generated__/index.css?url";-import { assetBaseUrl, imageBaseUrl, imageLoader } from "../constants.mjs";--export const loader = async (arg: LoaderFunctionArgs) => {- const url = new URL(arg.request.url);- const host =- arg.request.headers.get("x-forwarded-host") ||- arg.request.headers.get("host") ||- "";- url.host = host;- url.protocol = "https";-- const params = getRemixParams(arg.params);- const system = {- params,- search: Object.fromEntries(url.searchParams),- origin: url.origin,- };-- const resources = await loadResources({ system });- const pageMeta = getPageMeta({ system, resources });-- if (pageMeta.redirect) {- const status =- pageMeta.status === 301 || pageMeta.status === 302- ? pageMeta.status- : 302;- return redirect(pageMeta.redirect, status);- }-- // typecheck- arg.context.EXCLUDE_FROM_SEARCH satisfies boolean;-- return json(- {- host,- url: url.href,- excludeFromSearch: arg.context.EXCLUDE_FROM_SEARCH,- system,- resources,- pageMeta,- },- // No way for current information to change, so add cache for 10 minutes- // In case of CRM Data, this should be set to 0- {- status: pageMeta.status,- headers: {- "Cache-Control": "public, max-age=600",- "x-ws-language": pageMeta.language ?? "en",- },- }- );-};--export const headers: HeadersFunction = ({ loaderHeaders }) => {- return {- "Cache-Control": "public, max-age=0, must-revalidate",- "x-ws-language": loaderHeaders.get("x-ws-language") ?? "",- };-};--export const meta: MetaFunction<typeof loader> = ({ data }) => {- const metas: ReturnType<MetaFunction> = [];- if (data === undefined) {- return metas;- }- const { pageMeta } = data;-- if (data.url) {- metas.push({- property: "og:url",- content: data.url,- });- }-- if (pageMeta.title) {- metas.push({ title: pageMeta.title });-- metas.push({- property: "og:title",- content: pageMeta.title,- });- }-- metas.push({ property: "og:type", content: "website" });-- const origin = `https://${data.host}`;-- if (siteName) {- metas.push({- property: "og:site_name",- content: siteName,- });- metas.push({- "script:ld+json": {- "@context": "https://schema.org",- "@type": "WebSite",- name: siteName,- url: origin,- },- });- }-- if (pageMeta.excludePageFromSearch || data.excludeFromSearch) {- metas.push({- name: "robots",- content: "noindex, nofollow",- });- }-- if (pageMeta.description) {- metas.push({- name: "description",- content: pageMeta.description,- });- metas.push({- property: "og:description",- content: pageMeta.description,- });- }-- if (socialImageAsset) {- metas.push({- property: "og:image",- content: `https://${data.host}${imageLoader({- src: socialImageAsset.name,- // Do not transform social image (not enough information do we need to do this)- format: "raw",- })}`,- });- } else if (pageMeta.socialImageUrl) {- metas.push({- property: "og:image",- content: pageMeta.socialImageUrl,- });- }-- metas.push(...pageMeta.custom);-- return metas;-};--export const links: LinksFunction = () => {- const result: LinkDescriptor[] = [];-- result.push({- rel: "stylesheet",- href: css,- });-- if (favIconAsset) {- result.push({- rel: "icon",- href: imageLoader({- src: favIconAsset.name,- width: 128,- quality: 100,- format: "auto",- }),- type: undefined,- });- } else {- result.push({- rel: "icon",- href: "/favicon.ico",- type: "image/x-icon",- });-- result.push({- rel: "shortcut icon",- href: "/favicon.ico",- type: "image/x-icon",- });- }-- for (const asset of pageFontAssets) {- result.push({- rel: "preload",- href: `${assetBaseUrl}${asset.name}`,- as: "font",- crossOrigin: "anonymous",- });- }-- for (const backgroundImageAsset of pageBackgroundImageAssets) {- result.push({- rel: "preload",- href: `${assetBaseUrl}${backgroundImageAsset.name}`,- as: "image",- });- }-- return result;-};--const getRequestHost = (request: Request): string =>- request.headers.get("x-forwarded-host") || request.headers.get("host") || "";--const getMethod = (value: string | undefined) => {- if (value === undefined) {- return "post";- }-- switch (value.toLowerCase()) {- case "get":- return "get";- default:- return "post";- }-};--export const action = async ({ request, context }: ActionFunctionArgs) => {- const formData = await request.formData();-- const formId = getFormId(formData);- if (formId === undefined) {- // We're throwing rather than returning { success: false }- // because this isn't supposed to happen normally: bug or malicious user- throw json("Form not found", { status: 404 });- }-- const formProperties = formsProperties.get(formId);-- // form properties are not defined when defaults are used- const { action, method } = formProperties ?? {};-- if (contactEmail === undefined) {- return { success: false };- }-- // wrapped in try/catch just in cases new URL() throws- // (should not happen)- let pageUrl: URL;- try {- pageUrl = new URL(request.url);- pageUrl.host = getRequestHost(request);- } catch {- return { success: false };- }-- if (action !== undefined) {- try {- // Test that action is full URL- new URL(action);- } catch {- return json(- {- success: false,- error: "Invalid action URL, must be valid http/https protocol",- },- { status: 200 }- );- }- }-- const formInfo = {- formData,- projectId,- action: action ?? null,- method: getMethod(method),- pageUrl: pageUrl.toString(),- toEmail: contactEmail,- fromEmail: pageUrl.hostname + "@webstudio.email",- } as const;-- const result = await n8nHandler({- formInfo,- hookUrl: context.N8N_FORM_EMAIL_HOOK,- });-- return result;-};--const Outlet = () => {- const { system, resources } = useLoaderData<typeof loader>();- return (- <ReactSdkContext.Provider- value={{- imageLoader,- assetBaseUrl,- imageBaseUrl,- resources,- }}- >- <Page system={system} />- </ReactSdkContext.Provider>- );-};--export default Outlet;diff --git a/fixtures/webstudio-custom-template/app/routes/[sitemap.xml]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[sitemap.xml]._index.tsxnew file mode 100644index 0000000000..6a0ca519fa--- /dev/null+++ b/fixtures/webstudio-custom-template/app/routes/[sitemap.xml]._index.tsx@@ -0,0 +1,61 @@+/* eslint-disable camelcase */+import { type LoaderFunctionArgs, redirect } from "@remix-run/server-runtime";+import { ReactSdkContext } from "@webstudio-is/react-sdk";+import { Page } from "../__generated__/[sitemap.xml]._index";+import {+ loadResources,+ getPageMeta,+ getRemixParams,+} from "../__generated__/[sitemap.xml]._index.server";++import { assetBaseUrl, imageBaseUrl, imageLoader } from "../constants.mjs";+import { renderToString } from "react-dom/server";++export const loader = async (arg: LoaderFunctionArgs) => {+ const url = new URL(arg.request.url);+ const host =+ arg.request.headers.get("x-forwarded-host") ||+ arg.request.headers.get("host") ||+ "";+ url.host = host;+ url.protocol = "https";++ const params = getRemixParams(arg.params);++ const system = {+ params,+ search: Object.fromEntries(url.searchParams),+ origin: url.origin,+ };++ const resources = await loadResources({ system });+ const pageMeta = getPageMeta({ system, resources });++ if (pageMeta.redirect) {+ const status =+ pageMeta.status === 301 || pageMeta.status === 302+ ? pageMeta.status+ : 302;+ return redirect(pageMeta.redirect, status);+ }++ // typecheck+ arg.context.EXCLUDE_FROM_SEARCH satisfies boolean;++ const text = renderToString(+ <ReactSdkContext.Provider+ value={{+ imageLoader,+ assetBaseUrl,+ imageBaseUrl,+ resources,+ }}+ >+ <Page system={system} />+ </ReactSdkContext.Provider>+ );++ return new Response(`<?xml version="1.0" encoding="UTF-8"?>\n${text}`, {+ headers: { "Content-Type": "application/xml" },+ });+};diff --git a/fixtures/webstudio-remix-netlify-edge-functions/.npmrc b/fixtures/webstudio-remix-netlify-edge-functions/.npmrcnew file mode 100644index 0000000000..5e3cde50ab--- /dev/null+++ b/fixtures/webstudio-remix-netlify-edge-functions/.npmrc@@ -0,0 +1 @@+force=truediff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/__generated__/[sitemap.xml].ts b/fixtures/webstudio-remix-netlify-edge-functions/app/__generated__/$resources.sitemap.xml.tssimilarity index 100%rename from fixtures/webstudio-remix-netlify-edge-functions/app/__generated__/[sitemap.xml].tsrename to fixtures/webstudio-remix-netlify-edge-functions/app/__generated__/$resources.sitemap.xml.tsdiff --git a/fixtures/webstudio-custom-template/app/routes/[sitemap.xml].tsx b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[sitemap.xml]._index.tsxsimilarity index 91%rename from fixtures/webstudio-custom-template/app/routes/[sitemap.xml].tsxrename to fixtures/webstudio-remix-netlify-edge-functions/app/routes/[sitemap.xml]._index.tsxindex a9a3faa696..2a57cb3721 100644--- a/fixtures/webstudio-custom-template/app/routes/[sitemap.xml].tsx+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[sitemap.xml]._index.tsx@@ -1,5 +1,5 @@import type { LoaderFunctionArgs } from "@remix-run/server-runtime";-import { sitemap } from "../__generated__/[sitemap.xml]";+import { sitemap } from "../__generated__/$resources.sitemap.xml";export const loader = (arg: LoaderFunctionArgs) => {const host =diff --git a/fixtures/webstudio-remix-netlify-functions/.npmrc b/fixtures/webstudio-remix-netlify-functions/.npmrcnew file mode 100644index 0000000000..5e3cde50ab--- /dev/null+++ b/fixtures/webstudio-remix-netlify-functions/.npmrc@@ -0,0 +1 @@+force=truediff --git a/fixtures/webstudio-remix-netlify-functions/app/__generated__/[sitemap.xml].ts b/fixtures/webstudio-remix-netlify-functions/app/__generated__/$resources.sitemap.xml.tssimilarity index 100%rename from fixtures/webstudio-remix-netlify-functions/app/__generated__/[sitemap.xml].tsrename to fixtures/webstudio-remix-netlify-functions/app/__generated__/$resources.sitemap.xml.tsdiff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[sitemap.xml].tsx b/fixtures/webstudio-remix-netlify-functions/app/routes/[sitemap.xml]._index.tsxsimilarity index 91%rename from fixtures/webstudio-remix-netlify-edge-functions/app/routes/[sitemap.xml].tsxrename to fixtures/webstudio-remix-netlify-functions/app/routes/[sitemap.xml]._index.tsxindex a9a3faa696..2a57cb3721 100644--- a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[sitemap.xml].tsx+++ b/fixtures/webstudio-remix-netlify-functions/app/routes/[sitemap.xml]._index.tsx@@ -1,5 +1,5 @@import type { LoaderFunctionArgs } from "@remix-run/server-runtime";-import { sitemap } from "../__generated__/[sitemap.xml]";+import { sitemap } from "../__generated__/$resources.sitemap.xml";export const loader = (arg: LoaderFunctionArgs) => {const host =diff --git a/fixtures/webstudio-remix-vercel/.npmrc b/fixtures/webstudio-remix-vercel/.npmrcnew file mode 100644index 0000000000..5e3cde50ab--- /dev/null+++ b/fixtures/webstudio-remix-vercel/.npmrc@@ -0,0 +1 @@+force=truediff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[sitemap.xml].ts b/fixtures/webstudio-remix-vercel/app/__generated__/$resources.sitemap.xml.tssimilarity index 100%rename from fixtures/webstudio-remix-vercel/app/__generated__/[sitemap.xml].tsrename to fixtures/webstudio-remix-vercel/app/__generated__/$resources.sitemap.xml.tsdiff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[resources]._index.server.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[resources]._index.server.tsxindex 2e54f03c1f..81f92eb46c 100644--- a/fixtures/webstudio-remix-vercel/app/__generated__/[resources]._index.server.tsx+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[resources]._index.server.tsx@@ -3,7 +3,7 @@import type { PageMeta } from "@webstudio-is/sdk";import { loadResource, isLocalResource, type System } from "@webstudio-is/sdk";-import { sitemap } from "./[sitemap.xml]";+import { sitemap } from "./$resources.sitemap.xml";export const loadResources = async (_props: { system: System }) => {const customFetch: typeof fetch = (input, init) => {if (typeof input !== "string") {diff --git a/fixtures/webstudio-remix-netlify-functions/app/routes/[sitemap.xml].tsx b/fixtures/webstudio-remix-vercel/app/routes/[sitemap.xml]._index.tsxsimilarity index 91%rename from fixtures/webstudio-remix-netlify-functions/app/routes/[sitemap.xml].tsxrename to fixtures/webstudio-remix-vercel/app/routes/[sitemap.xml]._index.tsxindex a9a3faa696..2a57cb3721 100644--- a/fixtures/webstudio-remix-netlify-functions/app/routes/[sitemap.xml].tsx+++ b/fixtures/webstudio-remix-vercel/app/routes/[sitemap.xml]._index.tsx@@ -1,5 +1,5 @@import type { LoaderFunctionArgs } from "@remix-run/server-runtime";-import { sitemap } from "../__generated__/[sitemap.xml]";+import { sitemap } from "../__generated__/$resources.sitemap.xml";export const loader = (arg: LoaderFunctionArgs) => {const host =diff --git a/fixtures/webstudio-remix-vercel/app/routes/[sitemap.xml].tsx b/fixtures/webstudio-remix-vercel/app/routes/[sitemap.xml].tsxdeleted file mode 100644index a9a3faa696..0000000000--- a/fixtures/webstudio-remix-vercel/app/routes/[sitemap.xml].tsx+++ /dev/null@@ -1,34 +0,0 @@-import type { LoaderFunctionArgs } from "@remix-run/server-runtime";-import { sitemap } from "../__generated__/[sitemap.xml]";--export const loader = (arg: LoaderFunctionArgs) => {- const host =- arg.request.headers.get("x-forwarded-host") ||- arg.request.headers.get("host") ||- "";-- const urls = sitemap.map((page) => {- const url = new URL(`https://${host}${page.path}`);-- return `- <url>- <loc>${url.href}</loc>- <lastmod>${page.lastModified.split("T")[0]}</lastmod>- </url>- `;- });-- return new Response(- `<?xml version="1.0" encoding="UTF-8"?>-<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">-${urls.join("")}-</urlset>- `,- {- headers: {- "Content-Type": "application/xml",- },- status: 200,- }- );-};diff --git a/packages/cli/templates/defaults/app/__generated__/[sitemap.xml].ts b/packages/cli/__generated__/$resources.sitemap.xml.tssimilarity index 100%rename from packages/cli/templates/defaults/app/__generated__/[sitemap.xml].tsrename to packages/cli/__generated__/$resources.sitemap.xml.tsdiff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.tsindex 2dd6a24bca..81c3da86dc 100644--- a/packages/cli/src/cli.ts+++ b/packages/cli/src/cli.ts@@ -2,7 +2,7 @@ import { exit, argv } from "node:process";// eslint-disable-next-line import/no-internal-modulesimport { hideBin } from "yargs/helpers";import { GLOBAL_CONFIG_FILE } from "./config";-import { ensureFileInPath } from "./fs-utils";+import { createFileIfNotExists } from "./fs-utils";import { link, linkOptions } from "./commands/link";import { sync, syncOptions } from "./commands/sync";import { build, buildOptions } from "./commands/build";@@ -13,7 +13,7 @@ import type { CommonYargsArgv } from "./commands/yargs-types";export const main = async () => {try {- await ensureFileInPath(GLOBAL_CONFIG_FILE, "{}");+ await createFileIfNotExists(GLOBAL_CONFIG_FILE, "{}");const cmd: CommonYargsArgv = makeCLI(hideBin(argv)).strict()diff --git a/packages/cli/src/commands/init-flow.ts b/packages/cli/src/commands/init-flow.tsindex e5c49eaeef..420c78e71b 100644--- a/packages/cli/src/commands/init-flow.ts+++ b/packages/cli/src/commands/init-flow.ts@@ -1,4 +1,4 @@-import { ensureFolderExists, isFileExists } from "../fs-utils";+import { createFolderIfNotExists, isFileExists } from "../fs-utils";import { chdir, cwd } from "node:process";import { join } from "node:path";import ora from "ora";@@ -43,7 +43,7 @@ export const initFlow = async (if (folderName === undefined) {throw new Error("Folder name is required");}- await ensureFolderExists(join(cwd(), folderName));+ await createFolderIfNotExists(join(cwd(), folderName));chdir(join(cwd(), folderName));}diff --git a/packages/cli/src/commands/link.ts b/packages/cli/src/commands/link.tsindex e52f152222..215f0d5769 100644--- a/packages/cli/src/commands/link.ts+++ b/packages/cli/src/commands/link.ts@@ -9,7 +9,7 @@ import {jsonToGlobalConfig,type LocalConfig,} from "../config";-import { ensureFileInPath } from "../fs-utils";+import { createFileIfNotExists } from "../fs-utils";import type {CommonYargsArgv,StrictYargsOptionsToInterface,@@ -72,7 +72,7 @@ export const link = async (projectId,};- await ensureFileInPath(+ await createFileIfNotExists(join(cwd(), LOCAL_CONFIG_FILE),JSON.stringify(localConfig, null, 2));diff --git a/packages/cli/src/commands/sync.ts b/packages/cli/src/commands/sync.tsindex 1fb073aa12..9e406443c3 100644--- a/packages/cli/src/commands/sync.ts+++ b/packages/cli/src/commands/sync.ts@@ -9,7 +9,7 @@ import {} from "@webstudio-is/http-client";import pc from "picocolors";-import { ensureFileInPath, isFileExists } from "../fs-utils";+import { createFileIfNotExists, isFileExists } from "../fs-utils";import {GLOBAL_CONFIG_FILE,LOCAL_CONFIG_FILE,@@ -118,7 +118,7 @@ export const sync = async (spinner.text = "Saving project data to config file";const localBuildFilePath = join(cwd(), LOCAL_DATA_FILE);- await ensureFileInPath(localBuildFilePath);+ await createFileIfNotExists(localBuildFilePath);await writeFile(localBuildFilePath, JSON.stringify(project, null, 2), "utf8");spinner.succeed("Project data synced successfully");diff --git a/packages/cli/src/fs-utils.ts b/packages/cli/src/fs-utils.tsindex bcbbdefb41..c8dae8658f 100644--- a/packages/cli/src/fs-utils.ts+++ b/packages/cli/src/fs-utils.ts@@ -16,10 +16,13 @@ export const isFileExists = async (filePath: string) => {}};-export const ensureFileInPath = async (filePath: string, content?: string) => {+export const createFileIfNotExists = async (+ filePath: string,+ content?: string+) => {const dir = dirname(filePath);- await ensureFolderExists(dir);+ await createFolderIfNotExists(dir);try {await access(filePath, constants.F_OK);@@ -28,7 +31,7 @@ export const ensureFileInPath = async (filePath: string, content?: string) => {}};-export const ensureFolderExists = async (folderPath: string) => {+export const createFolderIfNotExists = async (folderPath: string) => {try {await access(folderPath, constants.F_OK);} catch {diff --git a/packages/cli/src/prebuild.ts b/packages/cli/src/prebuild.tsindex 7903a244c4..95e73a5a76 100644--- a/packages/cli/src/prebuild.ts+++ b/packages/cli/src/prebuild.ts@@ -55,8 +55,8 @@ import * as remixComponentMetas from "@webstudio-is/sdk-components-react-remix/mimport * as radixComponentMetas from "@webstudio-is/sdk-components-react-radix/metas";import { LOCAL_DATA_FILE } from "./config";import {- ensureFileInPath,- ensureFolderExists,+ createFileIfNotExists,+ createFolderIfNotExists,loadJSONFile,isFileExists,} from "./fs-utils";@@ -97,7 +97,7 @@ export const downloadAsset = async (try {await access(assetPath);} catch {- await ensureFolderExists(dirname(assetPath));+ await createFolderIfNotExists(dirname(assetPath));try {const response = await fetch(url);@@ -489,15 +489,23 @@ export const prebuild = async (options: {atomic: siteData.build.pages.compiler?.atomicStyles ?? true,});- await ensureFileInPath(join(generatedDir, "index.css"), cssText);+ await createFileIfNotExists(join(generatedDir, "index.css"), cssText);spinner.text = "Generating routes and pages";- const routeTemplatePath = normalize(join(cwd(), "app/routes/template.tsx"));+ // MARK: - Route templates read+ const routeTemplatesDir = join(cwd(), "app/route-templates");- const routeFileTemplate = await readFile(routeTemplatePath, "utf8");+ const routeTemplatePath = normalize(join(routeTemplatesDir, "html.tsx"));+ const routeXmlTemplatePath = normalize(join(routeTemplatesDir, "xml.tsx"));+ const defaultSiteMapXmlPath = normalize(+ join(routeTemplatesDir, "default-sitemap.tsx")+ );- await rm(routeTemplatePath);+ const routeFileTemplate = await readFile(routeTemplatePath, "utf8");+ const routeXmlFileTemplate = await readFile(routeXmlTemplatePath, "utf8");+ const defaultSiteMapTemplate = await readFile(defaultSiteMapXmlPath, "utf8");+ await rm(routeTemplatesDir, { recursive: true, force: true });for (const [pageId, pageComponents] of Object.entries(componentsByPage)) {const scope = createScope([@@ -508,10 +516,12 @@ export const prebuild = async (options: {"Page","_props",]);+const namespaces = new Map<string,Set<[shortName: string, componentName: string]>>();+const BASE_NAMESPACE = "@webstudio-is/sdk-components-react";const REMIX_NAMESPACE = "@webstudio-is/sdk-components-react-remix";@@ -539,17 +549,50 @@ export const prebuild = async (options: {}let componentImports = "";+ let xmlPresentationComponents = "";++ const pageData = siteDataByPage[pageId];+ const documentType = pageData.page.meta.documentType ?? "html";+for (const [namespace, componentsSet] of namespaces.entries()) {- const specifiers = Array.from(componentsSet)- .map(- ([shortName, component]) =>- `${shortName} as ${scope.getName(component, shortName)}`- )- .join(", ");- componentImports += `import { ${specifiers} } from "${namespace}";\n`;+ switch (documentType) {+ case "html":+ {+ const specifiers = Array.from(componentsSet)+ .map(+ ([shortName, component]) =>+ `${shortName} as ${scope.getName(component, shortName)}`+ )+ .join(", ");+ componentImports += `import { ${specifiers} } from "${namespace}";\n`;+ }+ break;++ case "xml":+ {+ // In case of xml it's the only component we are supporting+ componentImports = `import { XmlNode } from "@webstudio-is/sdk-components-react";\n`;++ // Passthrough (render children) for Body, do not render all other components+ xmlPresentationComponents += Array.from(componentsSet)+ .map(([shortName, component]) =>+ scope.getName(component, shortName)+ )+ .filter((scopedName) => scopedName !== "XmlNode")+ .map((scopedName) =>+ scopedName === "Body"+ ? `const ${scopedName} = (props: any) => props.children;`+ : `const ${scopedName} = () => null;`+ )+ .join("\n");+ }+ break;+ default: {+ documentType satisfies never;+ }+ }}- const pageData = siteDataByPage[pageId];const pageFontAssets = fontAssetsByPage[pageId];const pageBackgroundImageAssets = backgroundImageAssetsByPage[pageId];@@ -589,62 +632,67 @@ export const prebuild = async (options: {const pageMeta = pageData.page.meta;const favIconAsset = assets.get(projectMeta?.faviconAssetId ?? "");const socialImageAsset = assets.get(pageMeta.socialImageAssetId ?? "");++ // MARK: - TODO: XML GENERATIONconst pageExports = `/* eslint-disable */-/* This is a auto generated file for building the project */ \n+ /* This is a auto generated file for building the project */ \n-import { Fragment, useState } from "react";-import type { FontAsset, ImageAsset } from "@webstudio-is/sdk";-import { useResource } from "@webstudio-is/react-sdk";-${componentImports}+ import { Fragment, useState } from "react";+ import type { FontAsset, ImageAsset } from "@webstudio-is/sdk";+ import { useResource } from "@webstudio-is/react-sdk";+ ${componentImports}-export const siteName = ${JSON.stringify(projectMeta?.siteName)};+ export const siteName = ${JSON.stringify(projectMeta?.siteName)};-export const favIconAsset: ImageAsset | undefined =- ${JSON.stringify(favIconAsset)};+ export const favIconAsset: ImageAsset | undefined =+ ${JSON.stringify(favIconAsset)};-export const socialImageAsset: ImageAsset | undefined =- ${JSON.stringify(socialImageAsset)};+ export const socialImageAsset: ImageAsset | undefined =+ ${JSON.stringify(socialImageAsset)};-// Font assets on current page (can be preloaded)-export const pageFontAssets: FontAsset[] =- ${JSON.stringify(pageFontAssets)}+ // Font assets on current page (can be preloaded)+ export const pageFontAssets: FontAsset[] =+ ${JSON.stringify(pageFontAssets)}-export const pageBackgroundImageAssets: ImageAsset[] =- ${JSON.stringify(pageBackgroundImageAssets)}+ export const pageBackgroundImageAssets: ImageAsset[] =+ ${JSON.stringify(pageBackgroundImageAssets)}+ ${xmlPresentationComponents}+ ${pageComponent}-${pageComponent}+ export { Page }+ `;-export { Page }-`;const serverExports = `/* eslint-disable */-/* This is a auto generated file for building the project */ \n+ /* This is a auto generated file for building the project */ \n-import type { PageMeta } from "@webstudio-is/sdk";-${generateResourcesLoader({- scope,- page: pageData.page,- dataSources,- resources,-})}+ import type { PageMeta } from "@webstudio-is/sdk";+ ${generateResourcesLoader({+ scope,+ page: pageData.page,+ dataSources,+ resources,+ })}-${generatePageMeta({- globalScope: scope,- page: pageData.page,- dataSources,-})}+ ${generatePageMeta({+ globalScope: scope,+ page: pageData.page,+ dataSources,+ })}-${generateFormsProperties(props)}+ ${generateFormsProperties(props)}-${generateRemixParams(pageData.page.path)}+ ${generateRemixParams(pageData.page.path)}-export const projectId = "${siteData.build.projectId}";+ export const projectId = "${siteData.build.projectId}";-export const contactEmail = ${JSON.stringify(contactEmail)};+ export const contactEmail = ${JSON.stringify(contactEmail)};-export const customCode = ${JSON.stringify(projectMeta?.code?.trim() ?? "")};-`;+ export const customCode = ${JSON.stringify(+ projectMeta?.code?.trim() ?? ""+ )};+ `;/*The _index is mandatory.@@ -662,7 +710,9 @@ export const customCode = ${JSON.stringify(projectMeta?.code?.trim() ?? "")};const remixRoute = generateRemixRoute(pagePath);const fileName = `${remixRoute}.tsx`;- const routeFileContent = routeFileTemplate+ const routeFileContent = (+ documentType === "html" ? routeFileTemplate : routeXmlFileTemplate+ ).replace(/".*\/__generated__\/_index"/,`"../__generated__/${remixRoute}"`@@ -672,17 +722,24 @@ export const customCode = ${JSON.stringify(projectMeta?.code?.trim() ?? "")};`"../__generated__/${remixRoute}.server"`);- await ensureFileInPath(join(routesDir, fileName), routeFileContent);- await ensureFileInPath(join(generatedDir, fileName), pageExports);+ await createFileIfNotExists(join(routesDir, fileName), routeFileContent);++ await createFileIfNotExists(join(generatedDir, fileName), pageExports);- await ensureFileInPath(+ await createFileIfNotExists(join(generatedDir, `${remixRoute}.server.tsx`),serverExports);}- await writeFile(- join(generatedDir, "[sitemap.xml].ts"),+ // MARK: - Default sitemap.xml+ await createFileIfNotExists(+ join(routesDir, "[sitemap.xml]._index.tsx"),+ defaultSiteMapTemplate.replace(/".*\/__generated__\//, `"../__generated__/`)+ );++ await createFileIfNotExists(+ join(generatedDir, "$resources.sitemap.xml.ts"),`export const sitemap = ${JSON.stringify(getStaticSiteMapXml(siteData.build.pages, siteData.build.updatedAt),@@ -702,12 +759,12 @@ export const customCode = ${JSON.stringify(projectMeta?.code?.trim() ?? "")};const content = `import { type LoaderFunctionArgs, redirect } from "@remix-run/server-runtime";-export const loader = (arg: LoaderFunctionArgs) => {- return redirect("${redirect.new}", ${redirect.status ?? 301});-};-`;+ export const loader = (arg: LoaderFunctionArgs) => {+ return redirect("${redirect.new}", ${redirect.status ?? 301});+ };+ `;- await ensureFileInPath(join(routesDir, redirectFileName), content);+ await createFileIfNotExists(join(routesDir, redirectFileName), content);}}diff --git a/packages/cli/templates/defaults/app/route-templates/default-sitemap.tsx b/packages/cli/templates/defaults/app/route-templates/default-sitemap.tsxnew file mode 100644index 0000000000..b3e25011ab--- /dev/null+++ b/packages/cli/templates/defaults/app/route-templates/default-sitemap.tsx@@ -0,0 +1,34 @@+import type { LoaderFunctionArgs } from "@remix-run/server-runtime";+import { sitemap } from "../../../../__generated__/$resources.sitemap.xml";++export const loader = (arg: LoaderFunctionArgs) => {+ const host =+ arg.request.headers.get("x-forwarded-host") ||+ arg.request.headers.get("host") ||+ "";++ const urls = sitemap.map((page) => {+ const url = new URL(`https://${host}${page.path}`);++ return `+ <url>+ <loc>${url.href}</loc>+ <lastmod>${page.lastModified.split("T")[0]}</lastmod>+ </url>+ `;+ });++ return new Response(+ `<?xml version="1.0" encoding="UTF-8"?>+<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">+${urls.join("")}+</urlset>+ `,+ {+ headers: {+ "Content-Type": "application/xml",+ },+ status: 200,+ }+ );+};diff --git a/packages/cli/templates/defaults/app/routes/template.tsx b/packages/cli/templates/defaults/app/route-templates/html.tsxsimilarity index 100%rename from packages/cli/templates/defaults/app/routes/template.tsxrename to packages/cli/templates/defaults/app/route-templates/html.tsxdiff --git a/packages/cli/templates/defaults/app/route-templates/xml.tsx b/packages/cli/templates/defaults/app/route-templates/xml.tsxnew file mode 100644index 0000000000..1454fcac28--- /dev/null+++ b/packages/cli/templates/defaults/app/route-templates/xml.tsx@@ -0,0 +1,61 @@+/* eslint-disable camelcase */+import { type LoaderFunctionArgs, redirect } from "@remix-run/server-runtime";+import { ReactSdkContext } from "@webstudio-is/react-sdk";+import { Page } from "../../../../__generated__/_index";+import {+ loadResources,+ getPageMeta,+ getRemixParams,+} from "../../../../__generated__/_index.server";++import { assetBaseUrl, imageBaseUrl, imageLoader } from "../constants.mjs";+import { renderToString } from "react-dom/server";++export const loader = async (arg: LoaderFunctionArgs) => {+ const url = new URL(arg.request.url);+ const host =+ arg.request.headers.get("x-forwarded-host") ||+ arg.request.headers.get("host") ||+ "";+ url.host = host;+ url.protocol = "https";++ const params = getRemixParams(arg.params);++ const system = {+ params,+ search: Object.fromEntries(url.searchParams),+ origin: url.origin,+ };++ const resources = await loadResources({ system });+ const pageMeta = getPageMeta({ system, resources });++ if (pageMeta.redirect) {+ const status =+ pageMeta.status === 301 || pageMeta.status === 302+ ? pageMeta.status+ : 302;+ return redirect(pageMeta.redirect, status);+ }++ // typecheck+ arg.context.EXCLUDE_FROM_SEARCH satisfies boolean;++ const text = renderToString(+ <ReactSdkContext.Provider+ value={{+ imageLoader,+ assetBaseUrl,+ imageBaseUrl,+ resources,+ }}+ >+ <Page system={system} />+ </ReactSdkContext.Provider>+ );++ return new Response(`<?xml version="1.0" encoding="UTF-8"?>\n${text}`, {+ headers: { "Content-Type": "application/xml" },+ });+};diff --git a/packages/cli/templates/defaults/app/routes/[sitemap.xml].tsx b/packages/cli/templates/defaults/app/routes/[sitemap.xml].tsxdeleted file mode 100644index a9a3faa696..0000000000--- a/packages/cli/templates/defaults/app/routes/[sitemap.xml].tsx+++ /dev/null@@ -1,34 +0,0 @@-import type { LoaderFunctionArgs } from "@remix-run/server-runtime";-import { sitemap } from "../__generated__/[sitemap.xml]";--export const loader = (arg: LoaderFunctionArgs) => {- const host =- arg.request.headers.get("x-forwarded-host") ||- arg.request.headers.get("host") ||- "";-- const urls = sitemap.map((page) => {- const url = new URL(`https://${host}${page.path}`);-- return `- <url>- <loc>${url.href}</loc>- <lastmod>${page.lastModified.split("T")[0]}</lastmod>- </url>- `;- });-- return new Response(- `<?xml version="1.0" encoding="UTF-8"?>-<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">-${urls.join("")}-</urlset>- `,- {- headers: {- "Content-Type": "application/xml",- },- status: 200,- }- );-};diff --git a/packages/sdk-components-react/src/xml-node.tsx b/packages/sdk-components-react/src/xml-node.tsxindex ce429e7655..ea553d368d 100644--- a/packages/sdk-components-react/src/xml-node.tsx+++ b/packages/sdk-components-react/src/xml-node.tsx@@ -1,15 +1,46 @@-import { Children, forwardRef, type ElementRef, type ReactNode } from "react";+import {+ idAttribute,+ componentAttribute,+ ReactSdkContext,+} from "@webstudio-is/react-sdk";+import {+ Children,+ createElement,+ forwardRef,+ useContext,+ type ElementRef,+ type ReactNode,+} from "react";export const defaultTag = "div";// We don't want to enable all tags because Box is usually a container and we have specific components for many tags.type Props = {tag: string;+ xmlns?: string;children: ReactNode;+ // xxxAttribute is used for typings only+ [idAttribute]: string;+ [componentAttribute]: string;};export const XmlNode = forwardRef<ElementRef<"div">, Props>(({ tag = "", children, ...props }, ref) => {+ const { renderer } = useContext(ReactSdkContext);++ const attributeEntries = Object.entries(props)+ .filter(+ ([key]) =>+ key.startsWith("data-") === false && key.startsWith("aria-") === false+ )+ .filter(([key]) => key !== "tabIndex")+ .filter(([, value]) => typeof value !== "function");++ if (renderer === undefined) {+ const attrProps = Object.fromEntries(attributeEntries);+ return createElement(tag, attrProps, children);+ }+const isTextChild = Children.toArray(children).every((child) => typeof child === "string");@@ -20,14 +51,9 @@ export const XmlNode = forwardRef<ElementRef<"div">, Props>(// Clear all non letter, number, underscore, dot, and dash.replaceAll(/[^\p{L}\p{N}\-._]+/gu, "");- const attributes = Object.entries(props)- .filter(- ([key]) =>- key.startsWith("data-") === false && key.startsWith("aria-") === false- )- .filter(([key]) => key !== "tabIndex")- .filter(([, value]) => typeof value !== "function")- .map(([key, value]) => `${key}=${JSON.stringify(value)}`);+ const attributes = attributeEntries.map(+ ([key, value]) => `${key}=${JSON.stringify(value)}`+ );return (<div style={{ display: isTextChild ? "flex" : "contents" }} {...props}>diff --git a/packages/sdk/src/page-utils.ts b/packages/sdk/src/page-utils.tsindex 23e5c2e79e..0e46801aaf 100644--- a/packages/sdk/src/page-utils.ts+++ b/packages/sdk/src/page-utils.ts@@ -79,6 +79,7 @@ export const getStaticSiteMapXml = (pages: Pages, updatedAt: string) => {const allPages = [pages.homePage, ...pages.pages];return (allPages+ .filter((page) => (page.meta.documentType ?? "html") === "html")// ignore pages with excludePageFromSearch bound to variables// because there is no data from cms available at build time.filter(diff --git a/packages/sdk/src/resources-generator.test.ts b/packages/sdk/src/resources-generator.test.tsindex 2fcac83e85..f10f123eff 100644--- a/packages/sdk/src/resources-generator.test.ts+++ b/packages/sdk/src/resources-generator.test.ts@@ -33,7 +33,7 @@ test("generate resources loader", () => {})).toMatchInlineSnapshot(`"import { loadResource, isLocalResource, type System } from "@webstudio-is/sdk";-import { sitemap } from "./[sitemap.xml]";+import { sitemap } from "./$resources.sitemap.xml";export const loadResources = async (_props: { system: System }) => {const customFetch: typeof fetch = (input, init) => {@@ -115,7 +115,7 @@ test("generate variable and use in resources loader", () => {})).toMatchInlineSnapshot(`"import { loadResource, isLocalResource, type System } from "@webstudio-is/sdk";-import { sitemap } from "./[sitemap.xml]";+import { sitemap } from "./$resources.sitemap.xml";export const loadResources = async (_props: { system: System }) => {let AccessToken = "my-token"@@ -191,7 +191,7 @@ test("generate system variable and use in resources loader", () => {})).toMatchInlineSnapshot(`"import { loadResource, isLocalResource, type System } from "@webstudio-is/sdk";-import { sitemap } from "./[sitemap.xml]";+import { sitemap } from "./$resources.sitemap.xml";export const loadResources = async (_props: { system: System }) => {const system = _props.systemdiff --git a/packages/sdk/src/resources-generator.ts b/packages/sdk/src/resources-generator.tsindex 73d6ad3fdf..1634b7733b 100644--- a/packages/sdk/src/resources-generator.ts+++ b/packages/sdk/src/resources-generator.ts@@ -89,7 +89,7 @@ export const generateResourcesLoader = ({generated += `import { loadResource, isLocalResource, type System } from "@webstudio-is/sdk";\n`;if (hasResources) {- generated += `import { sitemap } from "./[sitemap.xml]";\n`;+ generated += `import { sitemap } from "./$resources.sitemap.xml";\n`;}generated += `export const loadResources = async (_props: { system: System }) => {\n`;