webstudio 0.142.0 → 0.143.1

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
@@ -259,23 +259,23 @@ import ora2 from "ora";
259
259
  import merge from "deepmerge";
260
260
  import {
261
261
  generateCss,
262
- generateUtilsExport,
263
262
  generateWebstudioComponent,
264
263
  getIndexesWithinAncestors,
265
264
  namespaceMeta,
266
265
  normalizeProps,
267
266
  generateRemixRoute,
268
267
  generateRemixParams,
269
- generateResourcesLoader,
270
- collectionComponent,
271
- generatePageMeta,
272
- executeExpression
268
+ collectionComponent
273
269
  } from "@webstudio-is/react-sdk";
274
270
  import {
275
271
  createScope,
276
272
  findTreeInstanceIds,
277
273
  getPagePath,
278
- parseComponentName
274
+ parseComponentName,
275
+ executeExpression,
276
+ generateFormsProperties,
277
+ generateResourcesLoader,
278
+ generatePageMeta
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";
@@ -514,12 +514,6 @@ var prebuild = async (options) => {
514
514
  backgroundImageAssetsByPage[page.id] = backgroundImageAssets;
515
515
  }
516
516
  const assetsToDownload = [];
517
- const imageAssets = [];
518
- for (const asset of siteData.assets) {
519
- if (asset.type === "image") {
520
- imageAssets.push(asset);
521
- }
522
- }
523
517
  const appDomain = options.preview ? "wstd.work" : "wstd.io";
524
518
  const assetBuildUrl = `https://${domain}.${appDomain}/cgi/asset/`;
525
519
  const imageLoader = createImageLoader({
@@ -549,6 +543,7 @@ var prebuild = async (options) => {
549
543
  }
550
544
  }
551
545
  }
546
+ const assets = new Map(siteData.assets.map((asset) => [asset.id, asset]));
552
547
  spinner.text = "Generating css file";
553
548
  const { cssText, classesMap } = generateCss(
554
549
  {
@@ -577,17 +572,6 @@ var prebuild = async (options) => {
577
572
  "useState",
578
573
  "Fragment",
579
574
  "useResource",
580
- "PageMeta",
581
- "createPageMeta",
582
- "PageData",
583
- "Asset",
584
- "ProjectMeta",
585
- "System",
586
- "fontAssets",
587
- "pageData",
588
- "user",
589
- "projectId",
590
- "formsProperties",
591
575
  "Page",
592
576
  "_props"
593
577
  ]);
@@ -624,15 +608,11 @@ var prebuild = async (options) => {
624
608
  const pageData = siteDataByPage[pageId];
625
609
  const pageFontAssets = fontAssetsByPage[pageId];
626
610
  const pageBackgroundImageAssets = backgroundImageAssetsByPage[pageId];
627
- const renderedPageData = {
628
- project: siteData.build.pages.meta
629
- };
630
611
  const rootInstanceId = pageData.page.rootInstanceId;
631
612
  const instances = new Map(pageData.build.instances);
632
613
  const props = new Map(pageData.build.props);
633
614
  const dataSources = new Map(pageData.build.dataSources);
634
615
  const resources = new Map(pageData.build.resources);
635
- const utilsExport = generateUtilsExport({ props });
636
616
  const pageComponent = generateWebstudioComponent({
637
617
  scope,
638
618
  name: "Page",
@@ -656,39 +636,67 @@ var prebuild = async (options) => {
656
636
  [rootInstanceId]
657
637
  )
658
638
  });
639
+ const projectMeta = siteData.build.pages.meta;
640
+ const pageMeta = pageData.page.meta;
641
+ const favIconAsset = assets.get(projectMeta?.faviconAssetId ?? "");
642
+ const socialImageAsset = assets.get(pageMeta.socialImageAssetId ?? "");
659
643
  const pageExports = `/* eslint-disable */
660
644
  /* This is a auto generated file for building the project */
661
645
 
646
+
662
647
  import { Fragment, useState } from "react";
663
- import type { Asset, FontAsset, ImageAsset, ProjectMeta, System } from "@webstudio-is/sdk";
648
+ import type { FontAsset, ImageAsset } from "@webstudio-is/sdk";
664
649
  import { useResource } from "@webstudio-is/react-sdk";
665
- import type { PageMeta } from "@webstudio-is/react-sdk";
666
650
  ${componentImports}
667
- import type { PageData } from "~/routes/_index";
668
- export const imageAssets: ImageAsset[] = ${JSON.stringify(imageAssets)}
651
+
652
+ export const favIconAsset: ImageAsset | undefined =
653
+ ${JSON.stringify(favIconAsset)};
654
+
655
+ export const socialImageAsset: ImageAsset | undefined =
656
+ ${JSON.stringify(socialImageAsset)};
669
657
 
670
658
  // Font assets on current page (can be preloaded)
671
- export const pageFontAssets: FontAsset[] = ${JSON.stringify(pageFontAssets)}
659
+ export const pageFontAssets: FontAsset[] =
660
+ ${JSON.stringify(pageFontAssets)}
672
661
 
673
- export const pageBackgroundImageAssets: ImageAsset[] = ${JSON.stringify(
674
- pageBackgroundImageAssets
675
- )}
662
+ export const pageBackgroundImageAssets: ImageAsset[] =
663
+ ${JSON.stringify(pageBackgroundImageAssets)}
676
664
 
677
- export const pageData: PageData = ${JSON.stringify(renderedPageData)};
678
- export const user: { email: string | null } | undefined = ${JSON.stringify(
679
- siteData.user
680
- )};
681
- export const projectId = "${siteData.build.projectId}";
682
665
 
683
- ${generatePageMeta({ globalScope: scope, page: pageData.page, dataSources })}
684
666
 
685
667
  ${pageComponent}
686
668
 
687
669
  export { Page }
670
+ `;
671
+ const serverExports = `/* eslint-disable */
672
+ /* This is a auto generated file for building the project */
673
+
674
+
675
+ import type { ProjectMeta, PageMeta } from "@webstudio-is/sdk";
676
+ ${generateResourcesLoader({
677
+ scope,
678
+ page: pageData.page,
679
+ dataSources,
680
+ resources
681
+ })}
682
+
683
+ ${generatePageMeta({
684
+ globalScope: scope,
685
+ page: pageData.page,
686
+ dataSources
687
+ })}
688
+
689
+ ${generateFormsProperties(props)}
688
690
 
689
691
  ${generateRemixParams(pageData.page.path)}
690
692
 
691
- ${utilsExport}
693
+ export const projectId = "${siteData.build.projectId}";
694
+
695
+ export const user: { email: string | null } | undefined =
696
+ ${JSON.stringify(siteData.user)};
697
+
698
+ export const projectMeta: ProjectMeta =
699
+ ${JSON.stringify(projectMeta)};
692
700
  `;
693
701
  const pagePath = getPagePath(pageData.page.id, siteData.build.pages);
694
702
  const remixRoute = generateRemixRoute(pagePath);
@@ -704,12 +712,7 @@ ${utilsExport}
704
712
  await ensureFileInPath(join4(generatedDir, fileName), pageExports);
705
713
  await ensureFileInPath(
706
714
  join4(generatedDir, `${remixRoute}.server.tsx`),
707
- generateResourcesLoader({
708
- scope,
709
- page: pageData.page,
710
- dataSources,
711
- resources
712
- })
715
+ serverExports
713
716
  );
714
717
  }
715
718
  await writeFile4(
@@ -918,7 +921,7 @@ import makeCLI from "yargs";
918
921
  // package.json
919
922
  var package_default = {
920
923
  name: "webstudio",
921
- version: "0.142.0",
924
+ version: "0.143.1",
922
925
  description: "Webstudio CLI",
923
926
  author: "Webstudio <github@webstudio.is>",
924
927
  homepage: "https://webstudio.is",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webstudio",
3
- "version": "0.142.0",
3
+ "version": "0.143.1",
4
4
  "description": "Webstudio CLI",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -28,20 +28,20 @@
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.142.0",
32
- "@webstudio-is/react-sdk": "0.142.0",
33
- "@webstudio-is/sdk": "0.142.0",
34
- "@webstudio-is/sdk-components-react": "0.142.0",
35
- "@webstudio-is/image": "0.142.0",
36
- "@webstudio-is/sdk-components-react-remix": "0.142.0",
37
- "@webstudio-is/sdk-components-react-radix": "0.142.0"
31
+ "@webstudio-is/image": "0.143.1",
32
+ "@webstudio-is/http-client": "0.143.1",
33
+ "@webstudio-is/react-sdk": "0.143.1",
34
+ "@webstudio-is/sdk": "0.143.1",
35
+ "@webstudio-is/sdk-components-react-radix": "0.143.1",
36
+ "@webstudio-is/sdk-components-react": "0.143.1",
37
+ "@webstudio-is/sdk-components-react-remix": "0.143.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^18.17.1",
41
41
  "@types/prompts": "^2.4.5",
42
42
  "tsx": "^3.12.8",
43
43
  "typescript": "5.2.2",
44
- "@webstudio-is/form-handlers": "0.142.0",
44
+ "@webstudio-is/form-handlers": "0.143.1",
45
45
  "@webstudio-is/tsconfig": "1.0.7"
46
46
  },
47
47
  "scripts": {
@@ -10,34 +10,34 @@ import {
10
10
  redirect,
11
11
  } from "@remix-run/server-runtime";
12
12
  import { useLoaderData } from "@remix-run/react";
13
- import type { ProjectMeta } from "@webstudio-is/sdk";
14
13
  import { ReactSdkContext } from "@webstudio-is/react-sdk";
15
14
  import { n8nHandler, getFormId } from "@webstudio-is/form-handlers";
16
15
  import {
17
- pageData,
18
- user,
19
- projectId,
20
- formsProperties,
21
16
  Page,
22
- imageAssets,
23
- getRemixParams,
24
- getPageMeta,
17
+ favIconAsset,
18
+ socialImageAsset,
25
19
  pageFontAssets,
26
20
  pageBackgroundImageAssets,
27
21
  } from "../../../__generated__/_index";
28
- import { loadResources } from "../../../__generated__/_index.server";
22
+ import {
23
+ formsProperties,
24
+ loadResources,
25
+ getPageMeta,
26
+ getRemixParams,
27
+ projectId,
28
+ user,
29
+ projectMeta,
30
+ } from "../../../__generated__/_index.server";
31
+
29
32
  import css from "../__generated__/index.css";
30
33
  import { assetBaseUrl, imageBaseUrl, imageLoader } from "~/constants.mjs";
31
34
 
32
- export type PageData = {
33
- project?: ProjectMeta;
34
- };
35
-
36
35
  export const loader = async (arg: LoaderArgs) => {
36
+ const url = new URL(arg.request.url);
37
37
  const params = getRemixParams(arg.params);
38
38
  const system = {
39
39
  params,
40
- search: {},
40
+ search: Object.fromEntries(url.searchParams),
41
41
  };
42
42
  const resources = await loadResources({ system });
43
43
  const pageMeta = getPageMeta({ system, resources });
@@ -55,7 +55,6 @@ export const loader = async (arg: LoaderArgs) => {
55
55
  arg.request.headers.get("host") ||
56
56
  "";
57
57
 
58
- const url = new URL(arg.request.url);
59
58
  url.host = host;
60
59
  url.protocol = "https";
61
60
 
@@ -70,6 +69,7 @@ export const loader = async (arg: LoaderArgs) => {
70
69
  system,
71
70
  resources,
72
71
  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,8 +95,7 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {
95
95
  if (data === undefined) {
96
96
  return metas;
97
97
  }
98
- const { pageMeta } = data;
99
- const { project } = pageData;
98
+ const { pageMeta, projectMeta } = data;
100
99
 
101
100
  if (data.url) {
102
101
  metas.push({
@@ -118,16 +117,16 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {
118
117
 
119
118
  const origin = `https://${data.host}`;
120
119
 
121
- if (project?.siteName) {
120
+ if (projectMeta?.siteName) {
122
121
  metas.push({
123
122
  property: "og:site_name",
124
- content: project.siteName,
123
+ content: projectMeta.siteName,
125
124
  });
126
125
  metas.push({
127
126
  "script:ld+json": {
128
127
  "@context": "https://schema.org",
129
128
  "@type": "WebSite",
130
- name: project.siteName,
129
+ name: projectMeta.siteName,
131
130
  url: origin,
132
131
  },
133
132
  });
@@ -151,21 +150,15 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {
151
150
  });
152
151
  }
153
152
 
154
- if (pageMeta.socialImageAssetId) {
155
- const imageAsset = imageAssets.find(
156
- (asset) => asset.id === pageMeta.socialImageAssetId
157
- );
158
-
159
- if (imageAsset) {
160
- metas.push({
161
- property: "og:image",
162
- content: `https://${data.host}${imageLoader({
163
- src: imageAsset.name,
164
- // Do not transform social image (not enough information do we need to do this)
165
- format: "raw",
166
- })}`,
167
- });
168
- }
153
+ if (socialImageAsset) {
154
+ metas.push({
155
+ property: "og:image",
156
+ content: `https://${data.host}${imageLoader({
157
+ src: socialImageAsset.name,
158
+ // Do not transform social image (not enough information do we need to do this)
159
+ format: "raw",
160
+ })}`,
161
+ });
169
162
  } else if (pageMeta.socialImageUrl) {
170
163
  metas.push({
171
164
  property: "og:image",
@@ -186,25 +179,17 @@ export const links: LinksFunction = () => {
186
179
  href: css,
187
180
  });
188
181
 
189
- const { project } = pageData;
190
-
191
- if (project?.faviconAssetId) {
192
- const imageAsset = imageAssets.find(
193
- (asset) => asset.id === project.faviconAssetId
194
- );
195
-
196
- if (imageAsset) {
197
- result.push({
198
- rel: "icon",
199
- href: imageLoader({
200
- src: imageAsset.name,
201
- width: 128,
202
- quality: 100,
203
- format: "auto",
204
- }),
205
- type: undefined,
206
- });
207
- }
182
+ if (favIconAsset) {
183
+ result.push({
184
+ rel: "icon",
185
+ href: imageLoader({
186
+ src: favIconAsset.name,
187
+ width: 128,
188
+ quality: 100,
189
+ format: "auto",
190
+ }),
191
+ type: undefined,
192
+ });
208
193
  } else {
209
194
  result.push({
210
195
  rel: "icon",
@@ -10,13 +10,13 @@
10
10
  "@remix-run/react": "^1.19.2",
11
11
  "@remix-run/server-runtime": "^1.19.2",
12
12
  "@remix-run/node": "^1.19.2",
13
- "@webstudio-is/react-sdk": "0.142.0",
14
- "@webstudio-is/sdk-components-react-radix": "0.142.0",
15
- "@webstudio-is/sdk-components-react-remix": "0.142.0",
16
- "@webstudio-is/sdk-components-react": "0.142.0",
17
- "@webstudio-is/form-handlers": "0.142.0",
18
- "@webstudio-is/image": "0.142.0",
19
- "@webstudio-is/sdk": "0.142.0",
13
+ "@webstudio-is/react-sdk": "0.143.1",
14
+ "@webstudio-is/sdk-components-react-radix": "0.143.1",
15
+ "@webstudio-is/sdk-components-react-remix": "0.143.1",
16
+ "@webstudio-is/sdk-components-react": "0.143.1",
17
+ "@webstudio-is/form-handlers": "0.143.1",
18
+ "@webstudio-is/image": "0.143.1",
19
+ "@webstudio-is/sdk": "0.143.1",
20
20
  "isbot": "^3.6.8",
21
21
  "react": "^18.2.0",
22
22
  "react-dom": "^18.2.0"
@@ -5,7 +5,6 @@ module.exports = {
5
5
  serverDependenciesToBundle: [
6
6
  /@webstudio-is\//,
7
7
  "nanoid",
8
- "@jsep-plugin/assignment",
9
8
  "change-case",
10
9
  "title-case",
11
10
  ],
@@ -8,7 +8,6 @@ const baseConfig =
8
8
  serverDependenciesToBundle: [
9
9
  /@webstudio-is\//,
10
10
  "nanoid",
11
- "@jsep-plugin/assignment",
12
11
  "change-case",
13
12
  "title-case",
14
13
  ],
@@ -16,7 +16,6 @@ module.exports = {
16
16
  serverDependenciesToBundle: [
17
17
  /@webstudio-is\//,
18
18
  "nanoid",
19
- "@jsep-plugin/assignment",
20
19
  "change-case",
21
20
  "title-case",
22
21
  ],