webstudio 0.201.0 → 0.203.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
@@ -28,7 +28,6 @@ import { kebabCase, camelCase } from "change-case";
28
28
  import "nanoid";
29
29
  import { parseExpressionAt } from "acorn";
30
30
  import { simple } from "acorn-walk";
31
- import warnOnce from "warn-once";
32
31
  import reservedIdentifiers from "reserved-identifiers";
33
32
  import hash from "@emotion/hash";
34
33
  import { x } from "tinyexec";
@@ -80,13 +79,18 @@ const PROJECT_TEMPLATES = [
80
79
  {
81
80
  value: "docker",
82
81
  label: "Docker",
83
- expand: ["react-router-docker"]
82
+ expand: ["react-router", "react-router-docker"]
84
83
  },
85
84
  {
86
85
  value: "vercel",
87
86
  label: "Vercel",
88
87
  expand: ["defaults", "vercel"]
89
88
  },
89
+ {
90
+ value: "netlify",
91
+ label: "Netlify",
92
+ expand: ["react-router", "react-router-netlify"]
93
+ },
90
94
  {
91
95
  value: "netlify-functions",
92
96
  label: "Netlify Functions",
@@ -746,15 +750,6 @@ const prefixStyles = (styleMap) => {
746
750
  }
747
751
  return newStyleMap;
748
752
  };
749
- const captureError = (error, value) => {
750
- if (process.env.NODE_ENV === "development") {
751
- throw error;
752
- }
753
- setTimeout(() => {
754
- throw error;
755
- });
756
- return value;
757
- };
758
753
  const fallbackTransform = (styleValue) => {
759
754
  var _a;
760
755
  if (styleValue.type !== "fontFamily") {
@@ -846,7 +841,7 @@ const toValue = (styleValue, transformValue) => {
846
841
  if (value.type === "guaranteedInvalid") {
847
842
  return "";
848
843
  }
849
- return captureError(new Error("Unknown value type"), value);
844
+ return "";
850
845
  };
851
846
  const Unit = z.string();
852
847
  const UnitValue = z.object({
@@ -2497,6 +2492,7 @@ const generateExpression = ({
2497
2492
  usedDataSources == null ? void 0 : usedDataSources.set(dep.id, dep);
2498
2493
  return scope.getName(dep.id, dep.name);
2499
2494
  }
2495
+ return "undefined";
2500
2496
  }
2501
2497
  });
2502
2498
  };
@@ -3446,7 +3442,7 @@ ${prop.name}={${propValue}}`;
3446
3442
  return "";
3447
3443
  }
3448
3444
  const indexVariable = scope.getName(`${instance.id}-index`, "index");
3449
- generatedElement += `{${collectionDataValue}?.map((${collectionItemValue}: any, ${indexVariable}: number) =>
3445
+ generatedElement += `{${collectionDataValue}?.map?.((${collectionItemValue}: any, ${indexVariable}: number) =>
3450
3446
  `;
3451
3447
  generatedElement += `<Fragment key={${indexVariable}}>
3452
3448
  `;
@@ -3644,47 +3640,6 @@ const generateWebstudioComponent = ({
3644
3640
  `;
3645
3641
  return generatedComponent;
3646
3642
  };
3647
- const imageSizes = [16, 32, 48, 64, 96, 128, 256, 384];
3648
- const deviceSizes = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
3649
- const allSizes = [...imageSizes, ...deviceSizes];
3650
- const NON_EXISTING_DOMAIN = "https://a3cbcbec-cdb1-4ea4-ad60-43c795308ddc.ddc";
3651
- const joinPath = (...segments) => {
3652
- return segments.filter((segment) => segment !== "").map((segment) => segment.replace(/(^\/+|\/+$)/g, "")).join("/");
3653
- };
3654
- const encodePathFragment = (fragment) => {
3655
- return encodeURIComponent(fragment).replace(/%2F/g, "/");
3656
- };
3657
- const wsImageLoader = (props2) => {
3658
- const width = props2.format === "raw" ? 16 : props2.width;
3659
- const quality = props2.format === "raw" ? 100 : props2.quality;
3660
- if (process.env.NODE_ENV !== "production") {
3661
- warnOnce(
3662
- allSizes.includes(width) === false,
3663
- "Width must be only from allowed values"
3664
- );
3665
- }
3666
- let src = props2.src;
3667
- if (src.startsWith("/cgi/asset")) {
3668
- src = src.slice("/cgi/asset".length);
3669
- }
3670
- const resultUrl = new URL("/cgi/image/", NON_EXISTING_DOMAIN);
3671
- if (props2.format !== "raw") {
3672
- resultUrl.searchParams.set("width", width.toString());
3673
- resultUrl.searchParams.set("quality", quality.toString());
3674
- if (props2.height != null) {
3675
- resultUrl.searchParams.set("height", props2.height.toString());
3676
- }
3677
- if (props2.fit != null) {
3678
- resultUrl.searchParams.set("fit", props2.fit);
3679
- }
3680
- }
3681
- resultUrl.searchParams.set("format", props2.format ?? "auto");
3682
- resultUrl.pathname = joinPath(resultUrl.pathname, encodePathFragment(src));
3683
- if (resultUrl.href.startsWith(NON_EXISTING_DOMAIN)) {
3684
- return `${resultUrl.pathname}?${resultUrl.searchParams.toString()}`;
3685
- }
3686
- return resultUrl.href;
3687
- };
3688
3643
  const BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
3689
3644
  "async",
3690
3645
  "autofocus",
@@ -5917,7 +5872,7 @@ Please check webstudio --help for more details`
5917
5872
  let framework;
5918
5873
  if (options.template.includes("ssg")) {
5919
5874
  framework = await createFramework();
5920
- } else if (options.template.includes("react-router-docker")) {
5875
+ } else if (options.template.includes("react-router")) {
5921
5876
  framework = await createFramework$1();
5922
5877
  } else {
5923
5878
  framework = await createFramework$2();
@@ -6033,14 +5988,10 @@ Please check webstudio --help for more details`
6033
5988
  const assetOrigin = siteData.origin;
6034
5989
  for (const asset of siteData.assets) {
6035
5990
  if (asset.type === "image") {
6036
- const imagePath = wsImageLoader({
6037
- src: asset.name,
6038
- format: "raw"
6039
- });
6040
5991
  assetsToDownload.push(
6041
5992
  limit(
6042
5993
  () => downloadAsset(
6043
- `${assetOrigin}${imagePath}`,
5994
+ `${assetOrigin}/cgi/image/${asset.name}?format=raw`,
6044
5995
  asset.name,
6045
5996
  assetBaseUrl
6046
5997
  )
@@ -6457,6 +6408,7 @@ const getDeploymentInstructions = (deployTarget) => {
6457
6408
  switch (deployTarget) {
6458
6409
  case "vercel":
6459
6410
  return `Run ${pc.dim("npx vercel")} to publish on Vercel.`;
6411
+ case "netlify":
6460
6412
  case "netlify-functions":
6461
6413
  case "netlify-edge-functions":
6462
6414
  return [
@@ -6471,7 +6423,7 @@ const getDeploymentInstructions = (deployTarget) => {
6471
6423
  }
6472
6424
  };
6473
6425
  const name = "webstudio";
6474
- const version = "0.201.0";
6426
+ const version = "0.203.0";
6475
6427
  const description = "Webstudio CLI";
6476
6428
  const author = "Webstudio <github@webstudio.is>";
6477
6429
  const homepage = "https://webstudio.is";
@@ -6513,18 +6465,17 @@ const dependencies = {
6513
6465
  "p-limit": "^6.2.0",
6514
6466
  parse5: "7.2.1",
6515
6467
  picocolors: "^1.1.1",
6516
- react: "18.3.0-canary-14898b6a9-20240318",
6517
6468
  "reserved-identifiers": "^1.0.0",
6518
6469
  tinyexec: "^0.3.2",
6519
- "warn-once": "^0.1.1",
6520
6470
  yargs: "^17.7.2",
6521
6471
  zod: "^3.22.4"
6522
6472
  };
6523
6473
  const devDependencies = {
6524
6474
  "@netlify/remix-adapter": "^2.5.1",
6525
6475
  "@netlify/remix-edge-adapter": "3.4.2",
6526
- "@react-router/dev": "^7.1.3",
6527
- "@react-router/fs-routes": "^7.1.3",
6476
+ "@netlify/vite-plugin-react-router": "^1.0.0",
6477
+ "@react-router/dev": "^7.1.5",
6478
+ "@react-router/fs-routes": "^7.1.5",
6528
6479
  "@remix-run/cloudflare": "^2.15.2",
6529
6480
  "@remix-run/cloudflare-pages": "^2.15.2",
6530
6481
  "@remix-run/dev": "^2.15.2",
@@ -6548,10 +6499,11 @@ const devDependencies = {
6548
6499
  h3: "^1.14.0",
6549
6500
  ipx: "^3.0.1",
6550
6501
  prettier: "3.4.2",
6502
+ react: "18.3.0-canary-14898b6a9-20240318",
6551
6503
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
6552
- "react-router": "^7.1.3",
6504
+ "react-router": "^7.1.5",
6553
6505
  "ts-expect": "^1.3.0",
6554
- vike: "^0.4.219",
6506
+ vike: "^0.4.220",
6555
6507
  vite: "^5.4.11",
6556
6508
  vitest: "^3.0.2",
6557
6509
  wrangler: "^3.63.2"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webstudio",
3
- "version": "0.201.0",
3
+ "version": "0.203.0",
4
4
  "description": "Webstudio CLI",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -37,18 +37,17 @@
37
37
  "p-limit": "^6.2.0",
38
38
  "parse5": "7.2.1",
39
39
  "picocolors": "^1.1.1",
40
- "react": "18.3.0-canary-14898b6a9-20240318",
41
40
  "reserved-identifiers": "^1.0.0",
42
41
  "tinyexec": "^0.3.2",
43
- "warn-once": "^0.1.1",
44
42
  "yargs": "^17.7.2",
45
43
  "zod": "^3.22.4"
46
44
  },
47
45
  "devDependencies": {
48
46
  "@netlify/remix-adapter": "^2.5.1",
49
47
  "@netlify/remix-edge-adapter": "3.4.2",
50
- "@react-router/dev": "^7.1.3",
51
- "@react-router/fs-routes": "^7.1.3",
48
+ "@netlify/vite-plugin-react-router": "^1.0.0",
49
+ "@react-router/dev": "^7.1.5",
50
+ "@react-router/fs-routes": "^7.1.5",
52
51
  "@remix-run/cloudflare": "^2.15.2",
53
52
  "@remix-run/cloudflare-pages": "^2.15.2",
54
53
  "@remix-run/dev": "^2.15.2",
@@ -62,22 +61,23 @@
62
61
  "h3": "^1.14.0",
63
62
  "ipx": "^3.0.1",
64
63
  "prettier": "3.4.2",
64
+ "react": "18.3.0-canary-14898b6a9-20240318",
65
65
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
66
- "react-router": "^7.1.3",
66
+ "react-router": "^7.1.5",
67
67
  "ts-expect": "^1.3.0",
68
- "vike": "^0.4.219",
68
+ "vike": "^0.4.220",
69
69
  "vite": "^5.4.11",
70
70
  "vitest": "^3.0.2",
71
71
  "wrangler": "^3.63.2",
72
- "@webstudio-is/http-client": "0.201.0",
73
- "@webstudio-is/image": "0.201.0",
74
- "@webstudio-is/react-sdk": "0.201.0",
75
- "@webstudio-is/sdk": "0.201.0",
76
- "@webstudio-is/sdk-components-animation": "0.201.0",
77
- "@webstudio-is/sdk-components-react": "0.201.0",
78
- "@webstudio-is/sdk-components-react-radix": "0.201.0",
79
- "@webstudio-is/sdk-components-react-remix": "0.201.0",
80
- "@webstudio-is/sdk-components-react-router": "0.201.0",
72
+ "@webstudio-is/image": "0.203.0",
73
+ "@webstudio-is/react-sdk": "0.203.0",
74
+ "@webstudio-is/http-client": "0.203.0",
75
+ "@webstudio-is/sdk": "0.203.0",
76
+ "@webstudio-is/sdk-components-animation": "0.203.0",
77
+ "@webstudio-is/sdk-components-react": "0.203.0",
78
+ "@webstudio-is/sdk-components-react-radix": "0.203.0",
79
+ "@webstudio-is/sdk-components-react-remix": "0.203.0",
80
+ "@webstudio-is/sdk-components-react-router": "0.203.0",
81
81
  "@webstudio-is/tsconfig": "1.0.7"
82
82
  },
83
83
  "scripts": {
@@ -11,14 +11,14 @@
11
11
  "@remix-run/node": "2.15.2",
12
12
  "@remix-run/react": "2.15.2",
13
13
  "@remix-run/server-runtime": "2.15.2",
14
- "@webstudio-is/image": "0.201.0",
15
- "@webstudio-is/react-sdk": "0.201.0",
16
- "@webstudio-is/sdk": "0.201.0",
17
- "@webstudio-is/sdk-components-react": "0.201.0",
18
- "@webstudio-is/sdk-components-animation": "0.201.0",
19
- "@webstudio-is/sdk-components-react-radix": "0.201.0",
20
- "@webstudio-is/sdk-components-react-remix": "0.201.0",
21
- "isbot": "^5.1.21",
14
+ "@webstudio-is/image": "0.203.0",
15
+ "@webstudio-is/react-sdk": "0.203.0",
16
+ "@webstudio-is/sdk": "0.203.0",
17
+ "@webstudio-is/sdk-components-react": "0.203.0",
18
+ "@webstudio-is/sdk-components-animation": "0.203.0",
19
+ "@webstudio-is/sdk-components-react-radix": "0.203.0",
20
+ "@webstudio-is/sdk-components-react-remix": "0.203.0",
21
+ "isbot": "^5.1.22",
22
22
  "react": "18.3.0-canary-14898b6a9-20240318",
23
23
  "react-dom": "18.3.0-canary-14898b6a9-20240318"
24
24
  },
@@ -0,0 +1,34 @@
1
+ {
2
+ "type": "module",
3
+ "private": true,
4
+ "sideEffects": false,
5
+ "scripts": {
6
+ "build": "react-router build",
7
+ "dev": "react-router dev",
8
+ "typecheck": "tsc"
9
+ },
10
+ "dependencies": {
11
+ "@react-router/dev": "^7.1.5",
12
+ "@react-router/fs-routes": "^7.1.5",
13
+ "@webstudio-is/image": "0.203.0",
14
+ "@webstudio-is/react-sdk": "0.203.0",
15
+ "@webstudio-is/sdk": "0.203.0",
16
+ "@webstudio-is/sdk-components-animation": "0.203.0",
17
+ "@webstudio-is/sdk-components-react-radix": "0.203.0",
18
+ "@webstudio-is/sdk-components-react-router": "0.203.0",
19
+ "@webstudio-is/sdk-components-react": "0.203.0",
20
+ "isbot": "^5.1.22",
21
+ "react": "18.3.0-canary-14898b6a9-20240318",
22
+ "react-dom": "18.3.0-canary-14898b6a9-20240318",
23
+ "react-router": "^7.1.5",
24
+ "vite": "^5.4.11"
25
+ },
26
+ "devDependencies": {
27
+ "@types/react": "^18.2.70",
28
+ "@types/react-dom": "^18.2.25",
29
+ "typescript": "5.7.3"
30
+ },
31
+ "engines": {
32
+ "node": ">=20.0.0"
33
+ }
34
+ }
@@ -1,39 +1,11 @@
1
1
  {
2
- "type": "module",
3
- "private": true,
4
- "sideEffects": false,
5
2
  "scripts": {
6
- "build": "react-router build",
7
- "dev": "react-router dev",
8
- "start": "react-router-serve ./build/server/index.js",
9
- "typecheck": "tsc"
3
+ "start": "react-router-serve ./build/server/index.js"
10
4
  },
11
5
  "dependencies": {
12
- "@react-router/dev": "^7.1.3",
13
- "@react-router/fs-routes": "^7.1.3",
14
- "@react-router/node": "^7.1.3",
15
- "@react-router/serve": "^7.1.3",
16
- "@webstudio-is/image": "0.201.0",
17
- "@webstudio-is/react-sdk": "0.201.0",
18
- "@webstudio-is/sdk": "0.201.0",
19
- "@webstudio-is/sdk-components-animation": "0.201.0",
20
- "@webstudio-is/sdk-components-react-radix": "0.201.0",
21
- "@webstudio-is/sdk-components-react-router": "0.201.0",
22
- "@webstudio-is/sdk-components-react": "0.201.0",
6
+ "@react-router/node": "^7.1.5",
7
+ "@react-router/serve": "^7.1.5",
23
8
  "h3": "^1.14.0",
24
- "ipx": "^3.0.1",
25
- "isbot": "^5.1.21",
26
- "react": "18.3.0-canary-14898b6a9-20240318",
27
- "react-dom": "18.3.0-canary-14898b6a9-20240318",
28
- "react-router": "^7.1.3",
29
- "vite": "^5.4.11"
30
- },
31
- "devDependencies": {
32
- "@types/react": "^18.2.70",
33
- "@types/react-dom": "^18.2.25",
34
- "typescript": "5.7.3"
35
- },
36
- "engines": {
37
- "node": ">=20.0.0"
9
+ "ipx": "^3.0.1"
38
10
  }
39
11
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * We use mjs extension as constants in this file is shared with the build script
3
+ * and we use `node --eval` to extract the constants.
4
+ */
5
+ export const assetBaseUrl = "/assets/";
6
+
7
+ /**
8
+ * @type {import("@webstudio-is/image").ImageLoader}
9
+ */
10
+ export const imageLoader = (props) => {
11
+ if (import.meta.env.DEV) {
12
+ return props.src;
13
+ }
14
+
15
+ if (props.format === "raw") {
16
+ return props.src;
17
+ }
18
+
19
+ // https://docs.netlify.com/image-cdn/overview/
20
+ const searchParams = new URLSearchParams();
21
+ searchParams.set("url", props.src);
22
+ searchParams.set("w", props.width.toString());
23
+ if (props.height) {
24
+ searchParams.set("h", props.height.toString());
25
+ }
26
+ searchParams.set("q", props.quality.toString());
27
+ // fit=contain by default
28
+ return `/.netlify/images?${searchParams}`;
29
+ };
@@ -0,0 +1,6 @@
1
+ [build]
2
+ command = "react-router build"
3
+ publish = "build/client"
4
+
5
+ [dev]
6
+ command = "react-router dev"
@@ -0,0 +1,10 @@
1
+ {
2
+ "scripts": {
3
+ "start": "npx netlify-cli serve",
4
+ "deploy": "npx netlify-cli deploy --build --prod"
5
+ },
6
+ "dependencies": {
7
+ "@netlify/vite-plugin-react-router": "^1.0.0",
8
+ "@react-router/node": "^7.1.5"
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ import { reactRouter } from "@react-router/dev/vite";
2
+ import { defineConfig } from "vite";
3
+ import netlifyPlugin from "@netlify/vite-plugin-react-router";
4
+
5
+ export default defineConfig({
6
+ plugins: [reactRouter(), netlifyPlugin()],
7
+ });
@@ -8,15 +8,15 @@
8
8
  "typecheck": "tsc"
9
9
  },
10
10
  "dependencies": {
11
- "@webstudio-is/image": "0.201.0",
12
- "@webstudio-is/react-sdk": "0.201.0",
13
- "@webstudio-is/sdk": "0.201.0",
14
- "@webstudio-is/sdk-components-react": "0.201.0",
15
- "@webstudio-is/sdk-components-animation": "0.201.0",
16
- "@webstudio-is/sdk-components-react-radix": "0.201.0",
11
+ "@webstudio-is/image": "0.203.0",
12
+ "@webstudio-is/react-sdk": "0.203.0",
13
+ "@webstudio-is/sdk": "0.203.0",
14
+ "@webstudio-is/sdk-components-react": "0.203.0",
15
+ "@webstudio-is/sdk-components-animation": "0.203.0",
16
+ "@webstudio-is/sdk-components-react-radix": "0.203.0",
17
17
  "react": "18.3.0-canary-14898b6a9-20240318",
18
18
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
19
- "vike": "^0.4.219"
19
+ "vike": "^0.4.220"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/react": "^18.2.70",