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
experimental: Error support on components level (#5136)
Ivan Starkova068bc9ab49b
diff --git a/.github/workflows/main.yml b/.github/workflows/main.ymlindex 64d38a25e4..1ccceceb6e 100644--- a/.github/workflows/main.yml+++ b/.github/workflows/main.yml@@ -133,7 +133,7 @@ jobs:}}const results = [- await assertSize('./fixtures/ssg/dist/client', 352),+ await assertSize('./fixtures/ssg/dist/client', 356),await assertSize('./fixtures/react-router-netlify/build/client', 368),await assertSize('./fixtures/webstudio-features/build/client', 1052),]diff --git a/apps/builder/app/canvas/canvas.tsx b/apps/builder/app/canvas/canvas.tsxindex 965e4dd867..b24632391b 100644--- a/apps/builder/app/canvas/canvas.tsx+++ b/apps/builder/app/canvas/canvas.tsx@@ -77,6 +77,7 @@ import { createInstanceElement } from "./elements";import { Body } from "./shared/body";import { subscribeScrollbarSize } from "./scrollbar-width";import { compareMedia } from "@webstudio-is/css-engine";+import { builderApi } from "~/shared/builder-api";registerContainers();@@ -98,6 +99,16 @@ const FallbackComponent = ({ error, resetErrorBoundary }: FallbackProps) => {);};+const handleError = (error: unknown) => {+ if (error instanceof Error) {+ builderApi.toast.error(error.message);+ return;+ }++ builderApi.toast.error(`Unknown error: ${String(error)}`);+ console.error(error);+};+const useElementsTree = (components: Components, instances: Instances) => {const page = useStore($selectedPage);const isPreviewMode = useStore($isPreviewMode);@@ -128,6 +139,8 @@ const useElementsTree = (components: Components, instances: Instances) => {imageLoader: wsImageLoader,resources: {},breakpoints,+ // error reporting+ onError: handleError,}}>{createInstanceElement({diff --git a/fixtures/react-router-docker/app/routes/[another-page]._index.tsx b/fixtures/react-router-docker/app/routes/[another-page]._index.tsxindex 664eabf2a9..11b08fc442 100644--- a/fixtures/react-router-docker/app/routes/[another-page]._index.tsx+++ b/fixtures/react-router-docker/app/routes/[another-page]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/react-router-docker/app/routes/_index.tsx b/fixtures/react-router-docker/app/routes/_index.tsxindex ecae1c8d88..c909d7735d 100644--- a/fixtures/react-router-docker/app/routes/_index.tsx+++ b/fixtures/react-router-docker/app/routes/_index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/react-router-netlify/app/routes/[another-page]._index.tsx b/fixtures/react-router-netlify/app/routes/[another-page]._index.tsxindex 664eabf2a9..11b08fc442 100644--- a/fixtures/react-router-netlify/app/routes/[another-page]._index.tsx+++ b/fixtures/react-router-netlify/app/routes/[another-page]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/react-router-netlify/app/routes/_index.tsx b/fixtures/react-router-netlify/app/routes/_index.tsxindex ecae1c8d88..c909d7735d 100644--- a/fixtures/react-router-netlify/app/routes/_index.tsx+++ b/fixtures/react-router-netlify/app/routes/_index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/react-router-vercel/app/routes/[another-page]._index.tsx b/fixtures/react-router-vercel/app/routes/[another-page]._index.tsxindex 664eabf2a9..11b08fc442 100644--- a/fixtures/react-router-vercel/app/routes/[another-page]._index.tsx+++ b/fixtures/react-router-vercel/app/routes/[another-page]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/react-router-vercel/app/routes/_index.tsx b/fixtures/react-router-vercel/app/routes/_index.tsxindex ecae1c8d88..c909d7735d 100644--- a/fixtures/react-router-vercel/app/routes/_index.tsx+++ b/fixtures/react-router-vercel/app/routes/_index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/ssg-netlify-by-project-id/pages/index/+Page.tsx b/fixtures/ssg-netlify-by-project-id/pages/index/+Page.tsxindex d316d31c54..2aecc01909 100644--- a/fixtures/ssg-netlify-by-project-id/pages/index/+Page.tsx+++ b/fixtures/ssg-netlify-by-project-id/pages/index/+Page.tsx@@ -12,6 +12,7 @@ const PageComponent = ({ data }: { data: PageContext["data"] }) => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/ssg/pages/another-page/+Page.tsx b/fixtures/ssg/pages/another-page/+Page.tsxindex ff30fd1acd..2d568eff92 100644--- a/fixtures/ssg/pages/another-page/+Page.tsx+++ b/fixtures/ssg/pages/another-page/+Page.tsx@@ -15,6 +15,7 @@ const PageComponent = ({ data }: { data: PageContext["data"] }) => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/ssg/pages/index/+Page.tsx b/fixtures/ssg/pages/index/+Page.tsxindex d316d31c54..2aecc01909 100644--- a/fixtures/ssg/pages/index/+Page.tsx+++ b/fixtures/ssg/pages/index/+Page.tsx@@ -12,6 +12,7 @@ const PageComponent = ({ data }: { data: PageContext["data"] }) => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx b/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsxindex d8c7f3c724..2ad19d5dc8 100644--- a/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx+++ b/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx@@ -275,6 +275,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsxindex 705279b078..a176476859 100644--- a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx+++ b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx@@ -275,6 +275,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[_route_with_symbols_]._index.tsx b/fixtures/webstudio-features/app/routes/[_route_with_symbols_]._index.tsxindex 6cdd83dfb1..3cd7e27088 100644--- a/fixtures/webstudio-features/app/routes/[_route_with_symbols_]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[_route_with_symbols_]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[animations]._index.tsx b/fixtures/webstudio-features/app/routes/[animations]._index.tsxindex 6a642fbaf3..61c80ec7c5 100644--- a/fixtures/webstudio-features/app/routes/[animations]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[animations]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[class-names]._index.tsx b/fixtures/webstudio-features/app/routes/[class-names]._index.tsxindex 0f52a3ae46..b875a9a49a 100644--- a/fixtures/webstudio-features/app/routes/[class-names]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[class-names]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[content-block]._index.tsx b/fixtures/webstudio-features/app/routes/[content-block]._index.tsxindex 5949026903..a639e47c27 100644--- a/fixtures/webstudio-features/app/routes/[content-block]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[content-block]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[duration]._index.tsx b/fixtures/webstudio-features/app/routes/[duration]._index.tsxindex e8aa649fc1..9a5176587a 100644--- a/fixtures/webstudio-features/app/routes/[duration]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[duration]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[expressions]._index.tsx b/fixtures/webstudio-features/app/routes/[expressions]._index.tsxindex 48f70bbfa8..764940dcec 100644--- a/fixtures/webstudio-features/app/routes/[expressions]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[expressions]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[form]._index.tsx b/fixtures/webstudio-features/app/routes/[form]._index.tsxindex 5b26ad8780..6c9b6804d0 100644--- a/fixtures/webstudio-features/app/routes/[form]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[form]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[head-tag]._index.tsx b/fixtures/webstudio-features/app/routes/[head-tag]._index.tsxindex 3ca6236581..43f32f3b6e 100644--- a/fixtures/webstudio-features/app/routes/[head-tag]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[head-tag]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[heading-with-id]._index.tsx b/fixtures/webstudio-features/app/routes/[heading-with-id]._index.tsxindex adde5975d4..38e8efe122 100644--- a/fixtures/webstudio-features/app/routes/[heading-with-id]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[heading-with-id]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[nested].[nested-page]._index.tsx b/fixtures/webstudio-features/app/routes/[nested].[nested-page]._index.tsxindex f1b0043376..778143e440 100644--- a/fixtures/webstudio-features/app/routes/[nested].[nested-page]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[nested].[nested-page]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[radix]._index.tsx b/fixtures/webstudio-features/app/routes/[radix]._index.tsxindex 953da2f2af..fa1eb61272 100644--- a/fixtures/webstudio-features/app/routes/[radix]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[radix]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[resources]._index.tsx b/fixtures/webstudio-features/app/routes/[resources]._index.tsxindex 36509959e8..b8cf43aa49 100644--- a/fixtures/webstudio-features/app/routes/[resources]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[resources]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/[sitemap.xml]._index.tsx b/fixtures/webstudio-features/app/routes/[sitemap.xml]._index.tsxindex 4f16ea7a46..ff394e97f7 100644--- a/fixtures/webstudio-features/app/routes/[sitemap.xml]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[sitemap.xml]._index.tsx@@ -70,6 +70,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}><Page system={system} />diff --git a/fixtures/webstudio-features/app/routes/[text-duration]._index.tsx b/fixtures/webstudio-features/app/routes/[text-duration]._index.tsxindex 3fa76b5cd9..23ff00c3d8 100644--- a/fixtures/webstudio-features/app/routes/[text-duration]._index.tsx+++ b/fixtures/webstudio-features/app/routes/[text-duration]._index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/fixtures/webstudio-features/app/routes/_index.tsx b/fixtures/webstudio-features/app/routes/_index.tsxindex ecae1c8d88..c909d7735d 100644--- a/fixtures/webstudio-features/app/routes/_index.tsx+++ b/fixtures/webstudio-features/app/routes/_index.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/packages/cli/templates/defaults/app/route-templates/html.tsx b/packages/cli/templates/defaults/app/route-templates/html.tsxindex 37b417caa7..40b5d144ca 100644--- a/packages/cli/templates/defaults/app/route-templates/html.tsx+++ b/packages/cli/templates/defaults/app/route-templates/html.tsx@@ -275,6 +275,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/packages/cli/templates/defaults/app/route-templates/xml.tsx b/packages/cli/templates/defaults/app/route-templates/xml.tsxindex 35bc3f4f13..354b7d9ab1 100644--- a/packages/cli/templates/defaults/app/route-templates/xml.tsx+++ b/packages/cli/templates/defaults/app/route-templates/xml.tsx@@ -66,6 +66,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}><Page system={system} />diff --git a/packages/cli/templates/react-router/app/route-templates/html.tsx b/packages/cli/templates/react-router/app/route-templates/html.tsxindex 478fd9320c..624fb38fc6 100644--- a/packages/cli/templates/react-router/app/route-templates/html.tsx+++ b/packages/cli/templates/react-router/app/route-templates/html.tsx@@ -274,6 +274,7 @@ const Outlet = () => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/packages/cli/templates/react-router/app/route-templates/xml.tsx b/packages/cli/templates/react-router/app/route-templates/xml.tsxindex dc1103685e..edf9e3e1f4 100644--- a/packages/cli/templates/react-router/app/route-templates/xml.tsx+++ b/packages/cli/templates/react-router/app/route-templates/xml.tsx@@ -66,6 +66,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}><Page system={system} />diff --git a/packages/cli/templates/ssg/app/route-templates/html/+Page.tsx b/packages/cli/templates/ssg/app/route-templates/html/+Page.tsxindex 6a2a12eaf6..fd37e42efc 100644--- a/packages/cli/templates/ssg/app/route-templates/html/+Page.tsx+++ b/packages/cli/templates/ssg/app/route-templates/html/+Page.tsx@@ -12,6 +12,7 @@ const PageComponent = ({ data }: { data: PageContext["data"] }) => {assetBaseUrl,resources,breakpoints,+ onError: console.error,}}>{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}diff --git a/packages/react-sdk/src/context.tsx b/packages/react-sdk/src/context.tsxindex f7b0816a01..6a731c50c0 100644--- a/packages/react-sdk/src/context.tsx+++ b/packages/react-sdk/src/context.tsx@@ -33,12 +33,16 @@ export const ReactSdkContext = createContext<// eslint-disable-next-line @typescript-eslint/no-explicit-anyresources: Record<string, any>;breakpoints: { id: string; minWidth?: number; maxWidth?: number }[];+ onError: (error: Error) => void;}>({assetBaseUrl: "/",imageLoader: ({ src }) => src,resources: {},breakpoints: [],+ onError: (error) => {+ console.error(error);+ },});export const useResource = (name: string) => {diff --git a/packages/sdk-components-react/src/html-embed.test.tsx b/packages/sdk-components-react/src/html-embed.test.tsxindex 48086b9f24..a083a9f2ab 100644--- a/packages/sdk-components-react/src/html-embed.test.tsx+++ b/packages/sdk-components-react/src/html-embed.test.tsx@@ -36,6 +36,7 @@ const App = (props: {renderer: props.renderer,resources: {},breakpoints: [],+ onError: console.error,}}><div key={page}>@@ -283,6 +284,7 @@ describe("Builder renderer= canvas | preview", () => {renderer: "canvas",resources: {},breakpoints: [],+ onError: console.error,}}><HtmlEmbed code={code} executeScriptOnCanvas={true} />diff --git a/packages/sdk-components-react/src/xml-node.stories.tsx b/packages/sdk-components-react/src/xml-node.stories.tsxindex ea0475de04..3beb9b6c6c 100644--- a/packages/sdk-components-react/src/xml-node.stories.tsx+++ b/packages/sdk-components-react/src/xml-node.stories.tsx@@ -10,6 +10,7 @@ const Component = () => {imageLoader: ({ src }) => src,resources: {},breakpoints: [],+ onError: console.error,}}><XmlNode tag="root">