webstudio 0.132.0 → 0.134.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
|
@@ -419,6 +419,8 @@ var prebuild = async (options) => {
|
|
|
419
419
|
const projectMetas = /* @__PURE__ */ new Map();
|
|
420
420
|
const componentsByPage = {};
|
|
421
421
|
const siteDataByPage = {};
|
|
422
|
+
const fontAssetsByPage = {};
|
|
423
|
+
const backgroundImageAssetsByPage = {};
|
|
422
424
|
for (const page of Object.values(siteData.pages)) {
|
|
423
425
|
const instanceMap = new Map(siteData.build.instances);
|
|
424
426
|
const pageInstanceSet = findTreeInstanceIds(
|
|
@@ -476,9 +478,31 @@ var prebuild = async (options) => {
|
|
|
476
478
|
projectMetas.set(instance.component, meta);
|
|
477
479
|
}
|
|
478
480
|
}
|
|
481
|
+
const styleSourceSelections = siteData.build?.styleSourceSelections ?? [];
|
|
482
|
+
const pageStyleSourceIds = new Set(
|
|
483
|
+
styleSourceSelections.filter(([, { instanceId }]) => pageInstanceSet.has(instanceId)).map(([, { values }]) => values).flat()
|
|
484
|
+
);
|
|
485
|
+
const pageStyles = siteData.build?.styles?.filter(
|
|
486
|
+
([, { styleSourceId }]) => pageStyleSourceIds.has(styleSourceId)
|
|
487
|
+
);
|
|
488
|
+
const pageFontFamilySet = new Set(
|
|
489
|
+
pageStyles.filter(([, { property }]) => property === "fontFamily").map(
|
|
490
|
+
([, { value }]) => value.type === "fontFamily" ? value.value : void 0
|
|
491
|
+
).flat().filter((value) => value !== void 0)
|
|
492
|
+
);
|
|
493
|
+
const pageFontAssets = siteData.assets.filter((asset) => asset.type === "font").filter((fontAsset) => pageFontFamilySet.has(fontAsset.meta.family));
|
|
494
|
+
fontAssetsByPage[page.id] = pageFontAssets;
|
|
495
|
+
const backgroundImageAssetIdSet = new Set(
|
|
496
|
+
pageStyles.filter(([, { property }]) => property === "backgroundImage").map(
|
|
497
|
+
([, { value }]) => value.type === "layers" ? value.value.map(
|
|
498
|
+
(layer) => layer.type === "image" ? layer.value.type === "asset" ? layer.value.value : void 0 : void 0
|
|
499
|
+
) : void 0
|
|
500
|
+
).flat().filter((value) => value !== void 0)
|
|
501
|
+
);
|
|
502
|
+
const backgroundImageAssets = siteData.assets.filter((asset) => asset.type === "image").filter((imageAsset) => backgroundImageAssetIdSet.has(imageAsset.id));
|
|
503
|
+
backgroundImageAssetsByPage[page.id] = backgroundImageAssets;
|
|
479
504
|
}
|
|
480
505
|
const assetsToDownload = [];
|
|
481
|
-
const fontAssets = [];
|
|
482
506
|
const imageAssets = [];
|
|
483
507
|
for (const asset of siteData.assets) {
|
|
484
508
|
if (asset.type === "image") {
|
|
@@ -511,7 +535,6 @@ var prebuild = async (options) => {
|
|
|
511
535
|
)
|
|
512
536
|
)
|
|
513
537
|
);
|
|
514
|
-
fontAssets.push(asset);
|
|
515
538
|
}
|
|
516
539
|
}
|
|
517
540
|
}
|
|
@@ -586,6 +609,8 @@ var prebuild = async (options) => {
|
|
|
586
609
|
`;
|
|
587
610
|
}
|
|
588
611
|
const pageData = siteDataByPage[pageId];
|
|
612
|
+
const pageFontAssets = fontAssetsByPage[pageId];
|
|
613
|
+
const pageBackgroundImageAssets = backgroundImageAssetsByPage[pageId];
|
|
589
614
|
const renderedPageData = {
|
|
590
615
|
project: siteData.build.pages.meta
|
|
591
616
|
};
|
|
@@ -598,25 +623,25 @@ var prebuild = async (options) => {
|
|
|
598
623
|
pages: siteData.build.pages,
|
|
599
624
|
props
|
|
600
625
|
});
|
|
601
|
-
const
|
|
602
|
-
if (pageData.page.
|
|
603
|
-
dataSources.set(
|
|
604
|
-
id:
|
|
605
|
-
name: "
|
|
626
|
+
const pathParamsDataSourceId = pageData.page.pathParamsDataSourceId ?? "pathParamsDataSourceId";
|
|
627
|
+
if (pageData.page.pathParamsDataSourceId === void 0) {
|
|
628
|
+
dataSources.set(pathParamsDataSourceId, {
|
|
629
|
+
id: pathParamsDataSourceId,
|
|
630
|
+
name: "Path Params",
|
|
606
631
|
type: "parameter"
|
|
607
632
|
});
|
|
608
633
|
}
|
|
609
634
|
const pageComponent = generateWebstudioComponent({
|
|
610
635
|
scope,
|
|
611
636
|
name: "Page",
|
|
612
|
-
rootInstanceId
|
|
637
|
+
rootInstanceId,
|
|
613
638
|
parameters: [
|
|
614
639
|
{
|
|
615
640
|
id: `params`,
|
|
616
641
|
instanceId: "",
|
|
617
642
|
name: "params",
|
|
618
643
|
type: "parameter",
|
|
619
|
-
value:
|
|
644
|
+
value: pathParamsDataSourceId
|
|
620
645
|
}
|
|
621
646
|
],
|
|
622
647
|
instances,
|
|
@@ -633,20 +658,27 @@ var prebuild = async (options) => {
|
|
|
633
658
|
/* This is a auto generated file for building the project */
|
|
634
659
|
|
|
635
660
|
import { Fragment, useState } from "react";
|
|
636
|
-
import type { Asset, ImageAsset, ProjectMeta } from "@webstudio-is/sdk";
|
|
661
|
+
import type { Asset, FontAsset, ImageAsset, ProjectMeta } from "@webstudio-is/sdk";
|
|
637
662
|
import { useResource } from "@webstudio-is/react-sdk";
|
|
638
663
|
import type { PageMeta } from "@webstudio-is/react-sdk";
|
|
639
664
|
${componentImports}
|
|
640
665
|
import type { PageData } from "~/routes/_index";
|
|
641
|
-
export const fontAssets: Asset[] = ${JSON.stringify(fontAssets)}
|
|
642
666
|
export const imageAssets: ImageAsset[] = ${JSON.stringify(imageAssets)}
|
|
667
|
+
|
|
668
|
+
// Font assets on current page (can be preloaded)
|
|
669
|
+
export const pageFontAssets: FontAsset[] = ${JSON.stringify(pageFontAssets)}
|
|
670
|
+
|
|
671
|
+
export const pageBackgroundImageAssets: ImageAsset[] = ${JSON.stringify(
|
|
672
|
+
pageBackgroundImageAssets
|
|
673
|
+
)}
|
|
674
|
+
|
|
643
675
|
export const pageData: PageData = ${JSON.stringify(renderedPageData)};
|
|
644
676
|
export const user: { email: string | null } | undefined = ${JSON.stringify(
|
|
645
677
|
siteData.user
|
|
646
678
|
)};
|
|
647
679
|
export const projectId = "${siteData.build.projectId}";
|
|
648
680
|
|
|
649
|
-
${generatePageMeta({ scope, page: pageData.page, dataSources })}
|
|
681
|
+
${generatePageMeta({ globalScope: scope, page: pageData.page, dataSources })}
|
|
650
682
|
|
|
651
683
|
${pageComponent}
|
|
652
684
|
|
|
@@ -656,8 +688,8 @@ ${generateRemixParams(pageData.page.path)}
|
|
|
656
688
|
|
|
657
689
|
${utilsExport}
|
|
658
690
|
`;
|
|
659
|
-
const
|
|
660
|
-
const remixRoute = generateRemixRoute(
|
|
691
|
+
const pagePath = getPagePath(pageData.page.id, siteData.build.pages);
|
|
692
|
+
const remixRoute = generateRemixRoute(pagePath);
|
|
661
693
|
const fileName = `${remixRoute}.tsx`;
|
|
662
694
|
const routeFileContent = routeFileTemplate.replace(
|
|
663
695
|
/".*\/__generated__\/_index"/,
|
|
@@ -695,6 +727,21 @@ ${utilsExport}
|
|
|
695
727
|
)};
|
|
696
728
|
`
|
|
697
729
|
);
|
|
730
|
+
const redirects = siteData.build.pages?.redirects;
|
|
731
|
+
if (redirects !== void 0 && redirects.length > 0) {
|
|
732
|
+
spinner.text = "Generating redirects";
|
|
733
|
+
for (const redirect of redirects) {
|
|
734
|
+
const redirectPagePath = generateRemixRoute(redirect.old);
|
|
735
|
+
const redirectFileName = `${redirectPagePath}.ts`;
|
|
736
|
+
const content = `import { type LoaderArgs, redirect } from "@remix-run/server-runtime";
|
|
737
|
+
|
|
738
|
+
export const loader = (arg: LoaderArgs) => {
|
|
739
|
+
return redirect("${redirect.new}", ${redirect.status ?? 301});
|
|
740
|
+
};
|
|
741
|
+
`;
|
|
742
|
+
await ensureFileInPath(join4(routesDir, redirectFileName), content);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
698
745
|
spinner.text = "Downloading fonts and images";
|
|
699
746
|
await Promise.all(assetsToDownload);
|
|
700
747
|
spinner.succeed("Build finished");
|
|
@@ -868,7 +915,7 @@ import makeCLI from "yargs";
|
|
|
868
915
|
// package.json
|
|
869
916
|
var package_default = {
|
|
870
917
|
name: "webstudio",
|
|
871
|
-
version: "0.
|
|
918
|
+
version: "0.134.0",
|
|
872
919
|
description: "Webstudio CLI",
|
|
873
920
|
author: "Webstudio <github@webstudio.is>",
|
|
874
921
|
homepage: "https://webstudio.is",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webstudio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.134.0",
|
|
4
4
|
"description": "Webstudio CLI",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -28,21 +28,21 @@
|
|
|
28
28
|
"title-case": "^4.1.0",
|
|
29
29
|
"yargs": "^17.7.2",
|
|
30
30
|
"zod": "^3.21.4",
|
|
31
|
-
"@webstudio-is/
|
|
32
|
-
"@webstudio-is/
|
|
33
|
-
"@webstudio-is/
|
|
34
|
-
"@webstudio-is/sdk": "0.
|
|
35
|
-
"@webstudio-is/sdk-components-react": "0.
|
|
36
|
-
"@webstudio-is/sdk-components-react-remix": "0.
|
|
37
|
-
"@webstudio-is/sdk-components-react
|
|
31
|
+
"@webstudio-is/image": "0.134.0",
|
|
32
|
+
"@webstudio-is/http-client": "0.134.0",
|
|
33
|
+
"@webstudio-is/sdk": "0.134.0",
|
|
34
|
+
"@webstudio-is/react-sdk": "0.134.0",
|
|
35
|
+
"@webstudio-is/sdk-components-react-radix": "0.134.0",
|
|
36
|
+
"@webstudio-is/sdk-components-react-remix": "0.134.0",
|
|
37
|
+
"@webstudio-is/sdk-components-react": "0.134.0"
|
|
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/
|
|
45
|
-
"@webstudio-is/
|
|
44
|
+
"@webstudio-is/tsconfig": "1.0.7",
|
|
45
|
+
"@webstudio-is/form-handlers": "0.134.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"typecheck": "tsc",
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
type ActionArgs,
|
|
7
7
|
type LoaderArgs,
|
|
8
8
|
json,
|
|
9
|
+
redirect,
|
|
9
10
|
} from "@remix-run/server-runtime";
|
|
10
11
|
import { useLoaderData } from "@remix-run/react";
|
|
11
12
|
import type { ProjectMeta } from "@webstudio-is/sdk";
|
|
12
13
|
import { ReactSdkContext } from "@webstudio-is/react-sdk";
|
|
13
14
|
import { n8nHandler, getFormId } from "@webstudio-is/form-handlers";
|
|
14
15
|
import {
|
|
15
|
-
fontAssets,
|
|
16
16
|
pageData,
|
|
17
17
|
user,
|
|
18
18
|
projectId,
|
|
@@ -22,6 +22,8 @@ import {
|
|
|
22
22
|
imageAssets,
|
|
23
23
|
getRemixParams,
|
|
24
24
|
getPageMeta,
|
|
25
|
+
pageFontAssets,
|
|
26
|
+
pageBackgroundImageAssets,
|
|
25
27
|
} from "../../../__generated__/_index";
|
|
26
28
|
import { loadResources } from "../../../__generated__/_index.server";
|
|
27
29
|
import css from "../__generated__/index.css";
|
|
@@ -36,6 +38,14 @@ export const loader = async (arg: LoaderArgs) => {
|
|
|
36
38
|
const resources = await loadResources({ params });
|
|
37
39
|
const pageMeta = getPageMeta({ params, resources });
|
|
38
40
|
|
|
41
|
+
if (pageMeta.redirect) {
|
|
42
|
+
const status =
|
|
43
|
+
pageMeta.status === 301 || pageMeta.status === 302
|
|
44
|
+
? pageMeta.status
|
|
45
|
+
: 302;
|
|
46
|
+
return redirect(pageMeta.redirect, status);
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
const host =
|
|
40
50
|
arg.request.headers.get("x-forwarded-host") ||
|
|
41
51
|
arg.request.headers.get("host") ||
|
|
@@ -59,7 +69,10 @@ export const loader = async (arg: LoaderArgs) => {
|
|
|
59
69
|
},
|
|
60
70
|
// No way for current information to change, so add cache for 10 minutes
|
|
61
71
|
// In case of CRM Data, this should be set to 0
|
|
62
|
-
{
|
|
72
|
+
{
|
|
73
|
+
status: pageMeta.status,
|
|
74
|
+
headers: { "Cache-Control": "public, max-age=600" },
|
|
75
|
+
}
|
|
63
76
|
);
|
|
64
77
|
};
|
|
65
78
|
|
|
@@ -198,17 +211,23 @@ export const links: LinksFunction = () => {
|
|
|
198
211
|
});
|
|
199
212
|
}
|
|
200
213
|
|
|
201
|
-
for (const asset of
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
214
|
+
for (const asset of pageFontAssets) {
|
|
215
|
+
result.push({
|
|
216
|
+
rel: "preload",
|
|
217
|
+
href: assetBaseUrl + asset.name,
|
|
218
|
+
as: "font",
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
for (const backgroundImageAsset of pageBackgroundImageAssets) {
|
|
223
|
+
result.push({
|
|
224
|
+
rel: "preload",
|
|
225
|
+
href: imageLoader({
|
|
226
|
+
src: backgroundImageAsset.name,
|
|
227
|
+
format: "raw",
|
|
228
|
+
}),
|
|
229
|
+
as: "image",
|
|
230
|
+
});
|
|
212
231
|
}
|
|
213
232
|
|
|
214
233
|
return result;
|
|
@@ -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.
|
|
14
|
-
"@webstudio-is/sdk-components-react-radix": "0.
|
|
15
|
-
"@webstudio-is/sdk-components-react-remix": "0.
|
|
16
|
-
"@webstudio-is/sdk-components-react": "0.
|
|
17
|
-
"@webstudio-is/form-handlers": "0.
|
|
18
|
-
"@webstudio-is/image": "0.
|
|
19
|
-
"@webstudio-is/sdk": "0.
|
|
13
|
+
"@webstudio-is/react-sdk": "0.134.0",
|
|
14
|
+
"@webstudio-is/sdk-components-react-radix": "0.134.0",
|
|
15
|
+
"@webstudio-is/sdk-components-react-remix": "0.134.0",
|
|
16
|
+
"@webstudio-is/sdk-components-react": "0.134.0",
|
|
17
|
+
"@webstudio-is/form-handlers": "0.134.0",
|
|
18
|
+
"@webstudio-is/image": "0.134.0",
|
|
19
|
+
"@webstudio-is/sdk": "0.134.0",
|
|
20
20
|
"isbot": "^3.6.8",
|
|
21
21
|
"react": "^18.2.0",
|
|
22
22
|
"react-dom": "^18.2.0"
|