webstudio 0.145.0 → 0.151.0

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/lib/cli.js CHANGED
@@ -272,10 +272,10 @@ import {
272
272
  findTreeInstanceIds,
273
273
  getPagePath,
274
274
  parseComponentName,
275
- executeExpression,
276
275
  generateFormsProperties,
277
276
  generateResourcesLoader,
278
- generatePageMeta
277
+ generatePageMeta,
278
+ getStaticSiteMapXml
279
279
  } from "@webstudio-is/sdk";
280
280
  import { createImageLoader } from "@webstudio-is/image";
281
281
  import * as baseComponentMetas from "@webstudio-is/sdk-components-react/metas";
@@ -557,11 +557,9 @@ var prebuild = async (options) => {
557
557
  });
558
558
  await ensureFileInPath(join4(generatedDir, "index.css"), cssText);
559
559
  spinner.text = "Generating routes and pages";
560
- const routeTemplatePath = normalize(
561
- join4(cwd3(), "__templates__", "route-template.tsx")
562
- );
560
+ const routeTemplatePath = normalize(join4(cwd3(), "app/routes/template.tsx"));
563
561
  const routeFileTemplate = await readFile4(routeTemplatePath, "utf8");
564
- await rm(dirname2(routeTemplatePath), { recursive: true });
562
+ await rm(routeTemplatePath);
565
563
  for (const [pageId, pageComponents] of Object.entries(componentsByPage)) {
566
564
  const scope = createScope([
567
565
  // manually maintained list of occupied identifiers
@@ -633,6 +631,10 @@ var prebuild = async (options) => {
633
631
  )
634
632
  });
635
633
  const projectMeta = siteData.build.pages.meta;
634
+ const contactEmail = (
635
+ // fallback to user email when contact email is empty string
636
+ projectMeta?.contactEmail || siteData.user?.email || void 0
637
+ );
636
638
  const pageMeta = pageData.page.meta;
637
639
  const favIconAsset = assets.get(projectMeta?.faviconAssetId ?? "");
638
640
  const socialImageAsset = assets.get(pageMeta.socialImageAssetId ?? "");
@@ -645,6 +647,8 @@ import type { FontAsset, ImageAsset } from "@webstudio-is/sdk";
645
647
  import { useResource } from "@webstudio-is/react-sdk";
646
648
  ${componentImports}
647
649
 
650
+ export const siteName = ${JSON.stringify(projectMeta?.siteName)};
651
+
648
652
  export const favIconAsset: ImageAsset | undefined =
649
653
  ${JSON.stringify(favIconAsset)};
650
654
 
@@ -668,7 +672,7 @@ export { Page }
668
672
  /* This is a auto generated file for building the project */
669
673
 
670
674
 
671
- import type { ProjectMeta, PageMeta } from "@webstudio-is/sdk";
675
+ import type { PageMeta } from "@webstudio-is/sdk";
672
676
  ${generateResourcesLoader({
673
677
  scope,
674
678
  page: pageData.page,
@@ -688,11 +692,9 @@ ${generateRemixParams(pageData.page.path)}
688
692
 
689
693
  export const projectId = "${siteData.build.projectId}";
690
694
 
691
- export const user: { email: string | null } | undefined =
692
- ${JSON.stringify(siteData.user)};
695
+ export const contactEmail = ${JSON.stringify(contactEmail)};
693
696
 
694
- export const projectMeta: ProjectMeta =
695
- ${JSON.stringify(projectMeta)};
697
+ export const customCode = ${JSON.stringify(projectMeta?.code?.trim() ?? "")};
696
698
  `;
697
699
  const pagePath = getPagePath(pageData.page.id, siteData.build.pages);
698
700
  const remixRoute = generateRemixRoute(pagePath);
@@ -715,14 +717,7 @@ export const projectMeta: ProjectMeta =
715
717
  join4(generatedDir, "[sitemap.xml].ts"),
716
718
  `
717
719
  export const sitemap = ${JSON.stringify(
718
- {
719
- pages: siteData.pages.filter(
720
- (page) => executeExpression(page.meta.excludePageFromSearch) !== true
721
- ).map((page) => ({
722
- path: page.path,
723
- lastModified: siteData.build.updatedAt
724
- }))
725
- },
720
+ getStaticSiteMapXml(siteData.build.pages, siteData.build.updatedAt),
726
721
  null,
727
722
  2
728
723
  )};
@@ -917,7 +912,7 @@ import makeCLI from "yargs";
917
912
  // package.json
918
913
  var package_default = {
919
914
  name: "webstudio",
920
- version: "0.145.0",
915
+ version: "0.151.0",
921
916
  description: "Webstudio CLI",
922
917
  author: "Webstudio <github@webstudio.is>",
923
918
  homepage: "https://webstudio.is",
@@ -961,24 +956,26 @@ var package_default = {
961
956
  zod: "^3.22.4"
962
957
  },
963
958
  devDependencies: {
964
- "@netlify/remix-adapter": "^2.3.0",
965
- "@netlify/remix-edge-adapter": "3.2.0",
966
- "@remix-run/cloudflare": "^2.8.1",
967
- "@remix-run/cloudflare-pages": "^2.8.1",
968
- "@remix-run/dev": "^2.8.1",
969
- "@remix-run/node": "^2.8.1",
970
- "@remix-run/react": "^2.8.1",
971
- "@remix-run/server-runtime": "^2.8.1",
972
- "@types/node": "^18.17.1",
959
+ "@netlify/remix-adapter": "^2.3.1",
960
+ "@netlify/remix-edge-adapter": "3.2.2",
961
+ "@remix-run/cloudflare": "^2.9.1",
962
+ "@remix-run/cloudflare-pages": "^2.9.1",
963
+ "@remix-run/dev": "^2.9.1",
964
+ "@remix-run/node": "^2.9.1",
965
+ "@remix-run/react": "^2.9.1",
966
+ "@remix-run/server-runtime": "^2.9.1",
967
+ "@types/node": "^20.12.7",
973
968
  "@types/prompts": "^2.4.5",
974
969
  "@types/react": "^18.2.70",
975
970
  "@types/react-dom": "^18.2.25",
976
971
  "@types/yargs": "^17.0.32",
977
972
  "@webstudio-is/form-handlers": "workspace:*",
978
973
  "@webstudio-is/tsconfig": "workspace:*",
974
+ react: "18.3.0-canary-14898b6a9-20240318",
975
+ "react-dom": "18.3.0-canary-14898b6a9-20240318",
979
976
  tsx: "^4.7.2",
980
977
  typescript: "5.4.5",
981
- "vite-tsconfig-paths": "^4.3.2",
978
+ vite: "^5.2.11",
982
979
  wrangler: "^3.48.0"
983
980
  }
984
981
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webstudio",
3
- "version": "0.145.0",
3
+ "version": "0.151.0",
4
4
  "description": "Webstudio CLI",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -28,33 +28,35 @@
28
28
  "title-case": "^4.1.0",
29
29
  "yargs": "^17.7.2",
30
30
  "zod": "^3.22.4",
31
- "@webstudio-is/http-client": "0.145.0",
32
- "@webstudio-is/image": "0.145.0",
33
- "@webstudio-is/sdk": "0.145.0",
34
- "@webstudio-is/react-sdk": "0.145.0",
35
- "@webstudio-is/sdk-components-react": "0.145.0",
36
- "@webstudio-is/sdk-components-react-radix": "0.145.0",
37
- "@webstudio-is/sdk-components-react-remix": "0.145.0"
31
+ "@webstudio-is/http-client": "0.151.0",
32
+ "@webstudio-is/react-sdk": "0.151.0",
33
+ "@webstudio-is/image": "0.151.0",
34
+ "@webstudio-is/sdk": "0.151.0",
35
+ "@webstudio-is/sdk-components-react-radix": "0.151.0",
36
+ "@webstudio-is/sdk-components-react-remix": "0.151.0",
37
+ "@webstudio-is/sdk-components-react": "0.151.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@netlify/remix-adapter": "^2.3.0",
41
- "@netlify/remix-edge-adapter": "3.2.0",
42
- "@remix-run/cloudflare": "^2.8.1",
43
- "@remix-run/cloudflare-pages": "^2.8.1",
44
- "@remix-run/dev": "^2.8.1",
45
- "@remix-run/node": "^2.8.1",
46
- "@remix-run/react": "^2.8.1",
47
- "@remix-run/server-runtime": "^2.8.1",
48
- "@types/node": "^18.17.1",
40
+ "@netlify/remix-adapter": "^2.3.1",
41
+ "@netlify/remix-edge-adapter": "3.2.2",
42
+ "@remix-run/cloudflare": "^2.9.1",
43
+ "@remix-run/cloudflare-pages": "^2.9.1",
44
+ "@remix-run/dev": "^2.9.1",
45
+ "@remix-run/node": "^2.9.1",
46
+ "@remix-run/react": "^2.9.1",
47
+ "@remix-run/server-runtime": "^2.9.1",
48
+ "@types/node": "^20.12.7",
49
49
  "@types/prompts": "^2.4.5",
50
50
  "@types/react": "^18.2.70",
51
51
  "@types/react-dom": "^18.2.25",
52
52
  "@types/yargs": "^17.0.32",
53
+ "react": "18.3.0-canary-14898b6a9-20240318",
54
+ "react-dom": "18.3.0-canary-14898b6a9-20240318",
53
55
  "tsx": "^4.7.2",
54
56
  "typescript": "5.4.5",
55
- "vite-tsconfig-paths": "^4.3.2",
57
+ "vite": "^5.2.11",
56
58
  "wrangler": "^3.48.0",
57
- "@webstudio-is/form-handlers": "0.145.0",
59
+ "@webstudio-is/form-handlers": "0.151.0",
58
60
  "@webstudio-is/tsconfig": "1.0.7"
59
61
  },
60
62
  "scripts": {
@@ -12,17 +12,13 @@
12
12
  "build-cf-types": "wrangler types"
13
13
  },
14
14
  "dependencies": {
15
- "@remix-run/cloudflare": "^2.8.1",
16
- "@remix-run/cloudflare-pages": "^2.8.1",
15
+ "@remix-run/cloudflare": "2.9.1",
16
+ "@remix-run/cloudflare-pages": "2.9.1",
17
17
  "isbot": "^4.1.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@cloudflare/workers-types": "^4.20240405.0",
21
- "vite-tsconfig-paths": "^4.2.1",
22
21
  "wrangler": "^3.48.0",
23
22
  "miniflare": "^3.20231030.4"
24
- },
25
- "engines": {
26
- "node": ">=18.0.0"
27
23
  }
28
24
  }
@@ -26,9 +26,6 @@
26
26
  "skipLibCheck": true,
27
27
  "forceConsistentCasingInFileNames": true,
28
28
  "baseUrl": ".",
29
- "paths": {
30
- "~/*": ["./app/*"]
31
- },
32
29
 
33
30
  // Vite takes care of building everything, not tsc.
34
31
  "noEmit": true
@@ -3,13 +3,11 @@ import {
3
3
  cloudflareDevProxyVitePlugin as remixCloudflareDevProxy,
4
4
  } from "@remix-run/dev";
5
5
  import { defineConfig } from "vite";
6
- import tsconfigPaths from "vite-tsconfig-paths";
7
6
 
8
7
  export default defineConfig(({ mode }) => ({
9
8
  plugins: [
10
9
  // without this, remixCloudflareDevProxy trying to load workerd even for production (it's not needed for production)
11
10
  mode === "production" ? undefined : remixCloudflareDevProxy(),
12
11
  remix(),
13
- tsconfigPaths(),
14
12
  ].filter(Boolean),
15
13
  }));
@@ -1,11 +1,9 @@
1
1
  /**
2
2
  * The only intent of this file is to support typings inside ../routes/[sitemap.xml].tsx for easier development.
3
3
  **/
4
- export const sitemap = {
5
- pages: [
6
- {
7
- path: "",
8
- lastModified: "2021-10-13T12:00:00.000Z",
9
- },
10
- ],
11
- };
4
+ export const sitemap = [
5
+ {
6
+ path: "",
7
+ lastModified: "2021-10-13T12:00:00.000Z",
8
+ },
9
+ ];
@@ -7,7 +7,7 @@ export const loader = (arg: LoaderFunctionArgs) => {
7
7
  arg.request.headers.get("host") ||
8
8
  "";
9
9
 
10
- const urls = sitemap.pages.map((page) => {
10
+ const urls = sitemap.map((page) => {
11
11
  const url = new URL(`https://${host}${page.path}`);
12
12
 
13
13
  return `
@@ -14,31 +14,40 @@ import { ReactSdkContext } from "@webstudio-is/react-sdk";
14
14
  import { n8nHandler, getFormId } from "@webstudio-is/form-handlers";
15
15
  import {
16
16
  Page,
17
+ siteName,
17
18
  favIconAsset,
18
19
  socialImageAsset,
19
20
  pageFontAssets,
20
21
  pageBackgroundImageAssets,
21
- } from "../../../__generated__/_index";
22
+ } from "../../../../__generated__/_index";
22
23
  import {
23
24
  formsProperties,
24
25
  loadResources,
25
26
  getPageMeta,
26
27
  getRemixParams,
27
28
  projectId,
28
- user,
29
- projectMeta,
30
- } from "../../../__generated__/_index.server";
29
+ contactEmail,
30
+ } from "../../../../__generated__/_index.server";
31
31
 
32
32
  import css from "../__generated__/index.css?url";
33
- import { assetBaseUrl, imageBaseUrl, imageLoader } from "~/constants.mjs";
33
+ import { assetBaseUrl, imageBaseUrl, imageLoader } from "../constants.mjs";
34
34
 
35
35
  export const loader = async (arg: LoaderFunctionArgs) => {
36
36
  const url = new URL(arg.request.url);
37
+ const host =
38
+ arg.request.headers.get("x-forwarded-host") ||
39
+ arg.request.headers.get("host") ||
40
+ "";
41
+ url.host = host;
42
+ url.protocol = "https";
43
+
37
44
  const params = getRemixParams(arg.params);
38
45
  const system = {
39
46
  params,
40
47
  search: Object.fromEntries(url.searchParams),
48
+ origin: url.origin,
41
49
  };
50
+
42
51
  const resources = await loadResources({ system });
43
52
  const pageMeta = getPageMeta({ system, resources });
44
53
 
@@ -50,14 +59,6 @@ export const loader = async (arg: LoaderFunctionArgs) => {
50
59
  return redirect(pageMeta.redirect, status);
51
60
  }
52
61
 
53
- const host =
54
- arg.request.headers.get("x-forwarded-host") ||
55
- arg.request.headers.get("host") ||
56
- "";
57
-
58
- url.host = host;
59
- url.protocol = "https";
60
-
61
62
  // typecheck
62
63
  arg.context.EXCLUDE_FROM_SEARCH satisfies boolean;
63
64
 
@@ -69,7 +70,6 @@ export const loader = async (arg: LoaderFunctionArgs) => {
69
70
  system,
70
71
  resources,
71
72
  pageMeta,
72
- projectMeta,
73
73
  },
74
74
  // No way for current information to change, so add cache for 10 minutes
75
75
  // In case of CRM Data, this should be set to 0
@@ -95,7 +95,7 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
95
95
  if (data === undefined) {
96
96
  return metas;
97
97
  }
98
- const { pageMeta, projectMeta } = data;
98
+ const { pageMeta } = data;
99
99
 
100
100
  if (data.url) {
101
101
  metas.push({
@@ -117,16 +117,16 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
117
117
 
118
118
  const origin = `https://${data.host}`;
119
119
 
120
- if (projectMeta?.siteName) {
120
+ if (siteName) {
121
121
  metas.push({
122
122
  property: "og:site_name",
123
- content: projectMeta.siteName,
123
+ content: siteName,
124
124
  });
125
125
  metas.push({
126
126
  "script:ld+json": {
127
127
  "@context": "https://schema.org",
128
128
  "@type": "WebSite",
129
- name: projectMeta.siteName,
129
+ name: siteName,
130
130
  url: origin,
131
131
  },
132
132
  });
@@ -255,9 +255,7 @@ export const action = async ({ request, context }: ActionFunctionArgs) => {
255
255
  // form properties are not defined when defaults are used
256
256
  const { action, method } = formProperties ?? {};
257
257
 
258
- const email = user?.email;
259
-
260
- if (email == null) {
258
+ if (contactEmail === undefined) {
261
259
  return { success: false };
262
260
  }
263
261
 
@@ -292,7 +290,7 @@ export const action = async ({ request, context }: ActionFunctionArgs) => {
292
290
  action: action ?? null,
293
291
  method: getMethod(method),
294
292
  pageUrl: pageUrl.toString(),
295
- toEmail: email,
293
+ toEmail: contactEmail,
296
294
  fromEmail: pageUrl.hostname + "@webstudio.email",
297
295
  } as const;
298
296
 
@@ -8,28 +8,28 @@
8
8
  "typecheck": "tsc"
9
9
  },
10
10
  "dependencies": {
11
- "@remix-run/react": "^2.8.1",
12
- "@remix-run/server-runtime": "^2.8.1",
13
- "@remix-run/node": "^2.8.1",
14
- "@webstudio-is/react-sdk": "0.145.0",
15
- "@webstudio-is/sdk-components-react-radix": "0.145.0",
16
- "@webstudio-is/sdk-components-react-remix": "0.145.0",
17
- "@webstudio-is/sdk-components-react": "0.145.0",
18
- "@webstudio-is/form-handlers": "0.145.0",
19
- "@webstudio-is/image": "0.145.0",
20
- "@webstudio-is/sdk": "0.145.0",
11
+ "@remix-run/node": "2.9.1",
12
+ "@remix-run/react": "2.9.1",
13
+ "@remix-run/server-runtime": "2.9.1",
14
+ "@webstudio-is/react-sdk": "0.151.0",
15
+ "@webstudio-is/sdk-components-react-radix": "0.151.0",
16
+ "@webstudio-is/sdk-components-react-remix": "0.151.0",
17
+ "@webstudio-is/sdk-components-react": "0.151.0",
18
+ "@webstudio-is/form-handlers": "0.151.0",
19
+ "@webstudio-is/image": "0.151.0",
20
+ "@webstudio-is/sdk": "0.151.0",
21
21
  "isbot": "^3.6.8",
22
22
  "react": "18.3.0-canary-14898b6a9-20240318",
23
23
  "react-dom": "18.3.0-canary-14898b6a9-20240318"
24
24
  },
25
25
  "devDependencies": {
26
- "@remix-run/dev": "^2.8.1",
26
+ "@remix-run/dev": "2.9.1",
27
27
  "@types/react": "^18.2.70",
28
28
  "@types/react-dom": "^18.2.25",
29
29
  "typescript": "5.4.5",
30
- "vite": "^5.2.8"
30
+ "vite": "^5.2.11"
31
31
  },
32
32
  "engines": {
33
- "node": ">=18.0.0"
33
+ "node": ">=20.0.0"
34
34
  }
35
35
  }
@@ -16,11 +16,6 @@
16
16
  "forceConsistentCasingInFileNames": true,
17
17
  "allowImportingTsExtensions": true,
18
18
  "baseUrl": ".",
19
- "paths": {
20
- "~/*": ["./app/*"]
21
- },
22
- "customConditions": ["webstudio"],
23
-
24
19
  // Remix takes care of building everything in `remix build`.
25
20
  "noEmit": true,
26
21
  "skipLibCheck": true
@@ -1,15 +1,6 @@
1
- import { resolve } from "node:path";
2
1
  import { defineConfig } from "vite";
3
2
  import { vitePlugin as remix } from "@remix-run/dev";
4
3
 
5
4
  export default defineConfig({
6
5
  plugins: [remix()],
7
- resolve: {
8
- alias: [
9
- {
10
- find: "~",
11
- replacement: resolve("app"),
12
- },
13
- ],
14
- },
15
6
  });
@@ -0,0 +1,25 @@
1
+ {
2
+ "include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
3
+ "compilerOptions": {
4
+ "lib": ["DOM", "DOM.Iterable", "ES2022"],
5
+ "types": ["@remix-run/node", "vite/client"],
6
+ "isolatedModules": true,
7
+ "esModuleInterop": true,
8
+ "jsx": "react-jsx",
9
+ "module": "ESNext",
10
+ "moduleResolution": "bundler",
11
+ "resolveJsonModule": true,
12
+ "target": "ES2022",
13
+ "strict": true,
14
+ "allowJs": true,
15
+ "checkJs": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "allowImportingTsExtensions": true,
18
+ "baseUrl": ".",
19
+ "customConditions": ["webstudio"],
20
+
21
+ // Remix takes care of building everything in `remix build`.
22
+ "noEmit": true,
23
+ "skipLibCheck": true
24
+ }
25
+ }
@@ -3,7 +3,7 @@
3
3
  "start": "netlify serve"
4
4
  },
5
5
  "dependencies": {
6
- "@netlify/edge-functions": "^2.3.1",
7
- "@netlify/remix-edge-adapter": "3.2.0"
6
+ "@netlify/edge-functions": "^2.6.0",
7
+ "@netlify/remix-edge-adapter": "^3.2.2"
8
8
  }
9
9
  }
@@ -1,16 +1,7 @@
1
- import { resolve } from "node:path";
2
1
  import { vitePlugin as remix } from "@remix-run/dev";
3
2
  import { defineConfig } from "vite";
4
3
  import { netlifyPlugin } from "@netlify/remix-edge-adapter/plugin";
5
4
 
6
5
  export default defineConfig({
7
6
  plugins: [remix(), netlifyPlugin()],
8
- resolve: {
9
- alias: [
10
- {
11
- find: "~",
12
- replacement: resolve("app"),
13
- },
14
- ],
15
- },
16
7
  });
@@ -4,6 +4,6 @@
4
4
  },
5
5
  "dependencies": {
6
6
  "@netlify/functions": "^2.6.0",
7
- "@netlify/remix-adapter": "^2.3.0"
7
+ "@netlify/remix-adapter": "^2.3.1"
8
8
  }
9
9
  }
@@ -1,16 +1,7 @@
1
- import { resolve } from "node:path";
2
1
  import { vitePlugin as remix } from "@remix-run/dev";
3
2
  import { defineConfig } from "vite";
4
3
  import { netlifyPlugin } from "@netlify/remix-adapter/plugin";
5
4
 
6
5
  export default defineConfig({
7
6
  plugins: [remix(), netlifyPlugin()],
8
- resolve: {
9
- alias: [
10
- {
11
- find: "~",
12
- replacement: resolve("app"),
13
- },
14
- ],
15
- },
16
7
  });
@@ -0,0 +1,34 @@
1
+ {
2
+ "include": [
3
+ "**/*.ts",
4
+ "**/*.tsx",
5
+ "**/.server/**/*.ts",
6
+ "**/.server/**/*.tsx",
7
+ "**/.client/**/*.ts",
8
+ "**/.client/**/*.tsx"
9
+ ],
10
+ "compilerOptions": {
11
+ "lib": ["DOM", "DOM.Iterable", "ES2022"],
12
+ "types": [
13
+ "@remix-run/cloudflare",
14
+ "vite/client",
15
+ "@cloudflare/workers-types/2023-07-01"
16
+ ],
17
+ "isolatedModules": true,
18
+ "esModuleInterop": true,
19
+ "jsx": "react-jsx",
20
+ "module": "ESNext",
21
+ "moduleResolution": "Bundler",
22
+ "resolveJsonModule": true,
23
+ "target": "ES2022",
24
+ "strict": true,
25
+ "allowJs": true,
26
+ "skipLibCheck": true,
27
+ "forceConsistentCasingInFileNames": true,
28
+ "baseUrl": ".",
29
+ "customConditions": ["webstudio"],
30
+
31
+ // Vite takes care of building everything, not tsc.
32
+ "noEmit": true
33
+ }
34
+ }