diff --git a/fixtures/webstudio-features/.webstudio/data.json b/fixtures/webstudio-features/.webstudio/data.json index aaa100ed3307..ffdef2f45829 100644 --- a/fixtures/webstudio-features/.webstudio/data.json +++ b/fixtures/webstudio-features/.webstudio/data.json @@ -1,10 +1,10 @@ { "build": { - "id": "3173a7d8-1af3-4e23-87fd-94c3b0cb1018", + "id": "fce42d58-8a67-4f4b-8427-ea7500132e28", "projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d", - "version": 474, - "createdAt": "2025-01-22T17:59:53.714+00:00", - "updatedAt": "2025-01-22T17:59:53.714+00:00", + "version": 477, + "createdAt": "2025-02-28T14:52:36.082+00:00", + "updatedAt": "2025-02-28T14:52:36.082+00:00", "pages": { "meta": { "siteName": "KittyGuardedZone", @@ -3214,6 +3214,19 @@ "scopeInstanceId": "1NipO5NmaHukA_dxzfVRF", "name": "system" } + ], + [ + "rKNaaGjEYnq4XPiTrSlfe", + { + "type": "variable", + "id": "rKNaaGjEYnq4XPiTrSlfe", + "scopeInstanceId": ":root", + "name": "globalVariable", + "value": { + "type": "string", + "value": "globalValue" + } + } ] ], "resources": [ @@ -4294,6 +4307,10 @@ { "type": "id", "value": "sHn4Mh7DJ5X0RiETB-zVc" + }, + { + "type": "id", + "value": "ABEvi07-c3_3dU6v4w-MS" } ] } @@ -5136,6 +5153,20 @@ "label": "Link", "children": [] } + ], + [ + "ABEvi07-c3_3dU6v4w-MS", + { + "type": "instance", + "id": "ABEvi07-c3_3dU6v4w-MS", + "component": "Box", + "children": [ + { + "type": "expression", + "value": "$ws$dataSource$rKNaaGjEYnq4XPiTrSlfe" + } + ] + } ] ], "deployment": { diff --git a/fixtures/webstudio-features/app/__generated__/$resources.sitemap.xml.ts b/fixtures/webstudio-features/app/__generated__/$resources.sitemap.xml.ts index 1bad56e430a3..7b8438c2278b 100644 --- a/fixtures/webstudio-features/app/__generated__/$resources.sitemap.xml.ts +++ b/fixtures/webstudio-features/app/__generated__/$resources.sitemap.xml.ts @@ -1,26 +1,26 @@ export const sitemap = [ { path: "/", - lastModified: "2025-01-22", + lastModified: "2025-02-28", }, { path: "/_route_with_symbols_", - lastModified: "2025-01-22", + lastModified: "2025-02-28", }, { path: "/form", - lastModified: "2025-01-22", + lastModified: "2025-02-28", }, { path: "/heading-with-id", - lastModified: "2025-01-22", + lastModified: "2025-02-28", }, { path: "/resources", - lastModified: "2025-01-22", + lastModified: "2025-02-28", }, { path: "/nested/nested-page", - lastModified: "2025-01-22", + lastModified: "2025-02-28", }, ]; diff --git a/fixtures/webstudio-features/app/__generated__/[expressions]._index.tsx b/fixtures/webstudio-features/app/__generated__/[expressions]._index.tsx index 199ee50bba2a..c392f49818c4 100644 --- a/fixtures/webstudio-features/app/__generated__/[expressions]._index.tsx +++ b/fixtures/webstudio-features/app/__generated__/[expressions]._index.tsx @@ -8,6 +8,7 @@ import { Body as Body } from "@webstudio-is/sdk-components-react-router"; import { Heading as Heading, HtmlEmbed as HtmlEmbed, + Box as Box, } from "@webstudio-is/sdk-components-react"; export const siteName = "KittyGuardedZone"; @@ -32,6 +33,8 @@ export const pageBackgroundImageAssets: ImageAsset[] = []; const Page = (_props: { system: any }) => { let jsonResourceVariable = useResource("jsonResourceVariable_1"); let [jsonVar, set$jsonVar] = useVariableState({ hello: "world" }); + let [globalVariable, set$globalVariable] = + useVariableState("globalValue"); return ( @@ -47,6 +50,7 @@ console.log(a, b); `} className={`w-html-embed`} /> + {globalVariable} ); }; diff --git a/fixtures/webstudio-features/package.json b/fixtures/webstudio-features/package.json index 8b8c6f7c2b58..30d942db54c9 100644 --- a/fixtures/webstudio-features/package.json +++ b/fixtures/webstudio-features/package.json @@ -6,7 +6,7 @@ "dev": "react-router dev", "cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio", "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'", - "fixtures:sync": "pnpm cli sync --buildId 3173a7d8-1af3-4e23-87fd-94c3b0cb1018 && pnpm prettier --write ./.webstudio/", + "fixtures:sync": "pnpm cli sync --buildId fce42d58-8a67-4f4b-8427-ea7500132e28 && pnpm prettier --write ./.webstudio/", "fixtures:build": "pnpm cli build --template react-router --template ./.template && pnpm prettier --write ./app/ ./package.json ./tsconfig.json" }, "private": true, diff --git a/packages/cli/src/prebuild.ts b/packages/cli/src/prebuild.ts index 638664695651..4ae6520d8ba2 100644 --- a/packages/cli/src/prebuild.ts +++ b/packages/cli/src/prebuild.ts @@ -48,6 +48,7 @@ import { coreMetas, SYSTEM_VARIABLE_ID, generateCss, + ROOT_INSTANCE_ID, } from "@webstudio-is/sdk"; import type { Data } from "@webstudio-is/http-client"; import { LOCAL_DATA_FILE } from "./config"; @@ -314,6 +315,8 @@ export const prebuild = async (options: { instanceMap, page.rootInstanceId ); + // support global data variables + pageInstanceSet.add(ROOT_INSTANCE_ID); const instances: [Instance["id"], Instance][] = siteData.build.instances.filter(([id]) => pageInstanceSet.has(id)); const dataSources: [DataSource["id"], DataSource][] = [];