webstudio 0.272.0 → 0.273.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-BUDhVJgP.js → cli-CrqM2Hge.js} +1176 -994
- package/lib/cli.js +1 -1
- package/lib/{framework-react-router-BatECCQ0.js → framework-react-router-UzYgymrh.js} +2 -2
- package/lib/{framework-remix-B20CB9ZU.js → framework-remix-DWec4bEd.js} +2 -2
- package/lib/{framework-vike-ssg-CBh8RhfE.js → framework-vike-ssg-yIhvBUQn.js} +2 -2
- package/lib/{metas-BerOcifF.js → metas-BiAyZSWN.js} +1 -1
- package/package.json +16 -15
- package/templates/cloudflare/package.json +1 -1
- package/templates/defaults/app/extension.ts +1 -1
- package/templates/defaults/package.json +8 -8
- package/templates/react-router/app/extension.ts +1 -1
- package/templates/react-router/package.json +8 -8
- package/templates/react-router-cloudflare/package.json +1 -1
- package/templates/ssg/package.json +6 -6
|
@@ -8,7 +8,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
var __privateMethod = (obj, member,
|
|
11
|
+
var __privateMethod = (obj, member, method2) => (__accessCheck(obj, member, "access private method"), method2);
|
|
12
12
|
var _declarations, _dirtyBreakpoints, _selector, _descendantSuffix, _mixinRules, _mixins, _declarations2, _cache, _NestingRule_instances, getDeclarations_fn, _name, _cached, _options, _element, _name2, _cssText, _mediaRules, _plainRules, _mixinRules2, _fontFaceRules, _transformValue, _element2;
|
|
13
13
|
import { exit, cwd, stdin, stdout, chdir, argv } from "node:process";
|
|
14
14
|
import { hideBin } from "yargs/helpers";
|
|
@@ -18,6 +18,7 @@ import { z } from "zod";
|
|
|
18
18
|
import { access, constants, writeFile, readFile, mkdir, rm, rename, copyFile, readdir, cp } from "node:fs/promises";
|
|
19
19
|
import { text, isCancel, cancel, log, spinner, confirm, select as select$1 } from "@clack/prompts";
|
|
20
20
|
import { createTRPCUntypedClient, httpBatchLink } from "@trpc/client";
|
|
21
|
+
import { Upload } from "tus-js-client";
|
|
21
22
|
import { parseExpressionAt } from "acorn";
|
|
22
23
|
import { simple } from "acorn-walk";
|
|
23
24
|
import pc from "picocolors";
|
|
@@ -395,12 +396,12 @@ const FONT_FORMATS = /* @__PURE__ */ new Map([
|
|
|
395
396
|
Array.from(FONT_FORMATS.keys()).map((format) => `.${format}`).join(", ");
|
|
396
397
|
const FONT_STYLES = ["normal", "italic", "oblique"];
|
|
397
398
|
const sanitizeCssUrl$1 = (str) => JSON.stringify(str);
|
|
398
|
-
const formatFace = (
|
|
399
|
+
const formatFace = (asset2, format, url) => {
|
|
399
400
|
var _a;
|
|
400
|
-
if ("variationAxes" in
|
|
401
|
-
const { wght, wdth } = ((_a =
|
|
401
|
+
if ("variationAxes" in asset2.meta) {
|
|
402
|
+
const { wght, wdth } = ((_a = asset2.meta) == null ? void 0 : _a.variationAxes) ?? {};
|
|
402
403
|
return {
|
|
403
|
-
fontFamily:
|
|
404
|
+
fontFamily: asset2.meta.family,
|
|
404
405
|
fontStyle: "normal",
|
|
405
406
|
fontDisplay: "swap",
|
|
406
407
|
src: `url(${sanitizeCssUrl$1(url)}) format("${format}")`,
|
|
@@ -409,32 +410,32 @@ const formatFace = (asset, format, url) => {
|
|
|
409
410
|
};
|
|
410
411
|
}
|
|
411
412
|
return {
|
|
412
|
-
fontFamily:
|
|
413
|
-
fontStyle:
|
|
414
|
-
fontWeight:
|
|
413
|
+
fontFamily: asset2.meta.family,
|
|
414
|
+
fontStyle: asset2.meta.style,
|
|
415
|
+
fontWeight: asset2.meta.weight,
|
|
415
416
|
fontDisplay: "swap",
|
|
416
417
|
src: `url(${sanitizeCssUrl$1(url)}) format("${format}")`
|
|
417
418
|
};
|
|
418
419
|
};
|
|
419
|
-
const getKey = (
|
|
420
|
-
if ("variationAxes" in
|
|
421
|
-
return
|
|
420
|
+
const getKey = (asset2) => {
|
|
421
|
+
if ("variationAxes" in asset2.meta) {
|
|
422
|
+
return asset2.meta.family + Object.values(asset2.meta.variationAxes).join("");
|
|
422
423
|
}
|
|
423
|
-
return
|
|
424
|
+
return asset2.meta.family + asset2.meta.style + asset2.meta.weight;
|
|
424
425
|
};
|
|
425
426
|
const getFontFaces = (assets, options) => {
|
|
426
427
|
const { assetBaseUrl } = options;
|
|
427
428
|
const faces = /* @__PURE__ */ new Map();
|
|
428
|
-
for (const
|
|
429
|
-
const url = `${assetBaseUrl}${
|
|
430
|
-
const assetKey = getKey(
|
|
429
|
+
for (const asset2 of assets) {
|
|
430
|
+
const url = `${assetBaseUrl}${asset2.name}`;
|
|
431
|
+
const assetKey = getKey(asset2);
|
|
431
432
|
const face = faces.get(assetKey);
|
|
432
|
-
const format = FONT_FORMATS.get(
|
|
433
|
+
const format = FONT_FORMATS.get(asset2.format);
|
|
433
434
|
if (format === void 0) {
|
|
434
435
|
continue;
|
|
435
436
|
}
|
|
436
437
|
if (face === void 0) {
|
|
437
|
-
const face2 = formatFace(
|
|
438
|
+
const face2 = formatFace(asset2, format, url);
|
|
438
439
|
faces.set(assetKey, face2);
|
|
439
440
|
continue;
|
|
440
441
|
}
|
|
@@ -442,12 +443,12 @@ const getFontFaces = (assets, options) => {
|
|
|
442
443
|
}
|
|
443
444
|
return Array.from(faces.values());
|
|
444
445
|
};
|
|
445
|
-
const
|
|
446
|
+
const fontFormat = z.union([
|
|
446
447
|
z.literal("ttf"),
|
|
447
448
|
z.literal("woff"),
|
|
448
449
|
z.literal("woff2")
|
|
449
450
|
]);
|
|
450
|
-
const
|
|
451
|
+
const axisName = z.enum([
|
|
451
452
|
"wght",
|
|
452
453
|
"wdth",
|
|
453
454
|
"slnt",
|
|
@@ -463,8 +464,8 @@ const AxisName = z.enum([
|
|
|
463
464
|
"YTDE",
|
|
464
465
|
"YTFI"
|
|
465
466
|
]);
|
|
466
|
-
const
|
|
467
|
-
|
|
467
|
+
const variationAxes = z.record(
|
|
468
|
+
axisName,
|
|
468
469
|
z.object({
|
|
469
470
|
name: z.string(),
|
|
470
471
|
min: z.number(),
|
|
@@ -472,19 +473,19 @@ const VariationAxes = z.record(
|
|
|
472
473
|
max: z.number()
|
|
473
474
|
})
|
|
474
475
|
);
|
|
475
|
-
const
|
|
476
|
+
const fontMetaStatic = z.object({
|
|
476
477
|
family: z.string(),
|
|
477
478
|
style: z.enum(FONT_STYLES),
|
|
478
479
|
weight: z.number()
|
|
479
480
|
});
|
|
480
|
-
const
|
|
481
|
+
const fontMetaVariable = z.object({
|
|
481
482
|
family: z.string(),
|
|
482
|
-
variationAxes
|
|
483
|
+
variationAxes
|
|
483
484
|
});
|
|
484
|
-
const
|
|
485
|
-
const
|
|
485
|
+
const fontMeta = z.union([fontMetaStatic, fontMetaVariable]);
|
|
486
|
+
const assetId = z.string();
|
|
486
487
|
const baseAsset = {
|
|
487
|
-
id:
|
|
488
|
+
id: assetId,
|
|
488
489
|
projectId: z.string(),
|
|
489
490
|
size: z.number(),
|
|
490
491
|
name: z.string(),
|
|
@@ -492,33 +493,34 @@ const baseAsset = {
|
|
|
492
493
|
description: z.union([z.string().optional(), z.null()]),
|
|
493
494
|
createdAt: z.string()
|
|
494
495
|
};
|
|
495
|
-
const
|
|
496
|
+
const assetType = z.enum(["font", "image", "file"]);
|
|
497
|
+
const fontAsset = z.object({
|
|
496
498
|
...baseAsset,
|
|
497
|
-
format:
|
|
498
|
-
meta:
|
|
499
|
-
type: z.literal(
|
|
499
|
+
format: fontFormat,
|
|
500
|
+
meta: fontMeta,
|
|
501
|
+
type: z.literal(assetType.enum.font)
|
|
500
502
|
});
|
|
501
|
-
const
|
|
503
|
+
const imageMeta = z.object({
|
|
502
504
|
width: z.number(),
|
|
503
505
|
height: z.number()
|
|
504
506
|
});
|
|
505
|
-
const
|
|
507
|
+
const imageAsset = z.object({
|
|
506
508
|
...baseAsset,
|
|
507
509
|
format: z.string(),
|
|
508
|
-
meta:
|
|
509
|
-
type: z.literal(
|
|
510
|
+
meta: imageMeta,
|
|
511
|
+
type: z.literal(assetType.enum.image)
|
|
510
512
|
});
|
|
511
|
-
const
|
|
513
|
+
const fileAsset = z.object({
|
|
512
514
|
...baseAsset,
|
|
513
515
|
format: z.string(),
|
|
514
516
|
meta: z.object({}),
|
|
515
|
-
type: z.literal(
|
|
517
|
+
type: z.literal(assetType.enum.file)
|
|
516
518
|
});
|
|
517
|
-
const
|
|
518
|
-
z.map(
|
|
519
|
-
const
|
|
520
|
-
const
|
|
521
|
-
id:
|
|
519
|
+
const asset = z.union([fontAsset, imageAsset, fileAsset]);
|
|
520
|
+
z.map(assetId, asset);
|
|
521
|
+
const breakpointId = z.string();
|
|
522
|
+
const breakpoint = z.object({
|
|
523
|
+
id: breakpointId,
|
|
522
524
|
label: z.string(),
|
|
523
525
|
minWidth: z.number().optional(),
|
|
524
526
|
maxWidth: z.number().optional(),
|
|
@@ -537,9 +539,9 @@ const Breakpoint = z.object({
|
|
|
537
539
|
}
|
|
538
540
|
return true;
|
|
539
541
|
}, "Width-based (minWidth/maxWidth) and condition are mutually exclusive, and minWidth must be less than maxWidth");
|
|
540
|
-
z.map(
|
|
541
|
-
const
|
|
542
|
-
const
|
|
542
|
+
z.map(breakpointId, breakpoint);
|
|
543
|
+
const dataSourceId = z.string();
|
|
544
|
+
const dataSourceVariableValue = z.union([
|
|
543
545
|
z.object({
|
|
544
546
|
type: z.literal("number"),
|
|
545
547
|
// initial value of variable store
|
|
@@ -562,10 +564,10 @@ const DataSourceVariableValue = z.union([
|
|
|
562
564
|
value: z.unknown()
|
|
563
565
|
})
|
|
564
566
|
]);
|
|
565
|
-
const
|
|
567
|
+
const dataSource = z.union([
|
|
566
568
|
z.object({
|
|
567
569
|
type: z.literal("variable"),
|
|
568
|
-
id:
|
|
570
|
+
id: dataSourceId,
|
|
569
571
|
// The instance should always be specified for variables,
|
|
570
572
|
// however, there was a bug in the embed template
|
|
571
573
|
// which produced variables without an instance
|
|
@@ -573,24 +575,24 @@ const DataSource = z.union([
|
|
|
573
575
|
// if we make it required
|
|
574
576
|
scopeInstanceId: z.string().optional(),
|
|
575
577
|
name: z.string(),
|
|
576
|
-
value:
|
|
578
|
+
value: dataSourceVariableValue
|
|
577
579
|
}),
|
|
578
580
|
z.object({
|
|
579
581
|
type: z.literal("parameter"),
|
|
580
|
-
id:
|
|
582
|
+
id: dataSourceId,
|
|
581
583
|
scopeInstanceId: z.string().optional(),
|
|
582
584
|
name: z.string()
|
|
583
585
|
}),
|
|
584
586
|
z.object({
|
|
585
587
|
type: z.literal("resource"),
|
|
586
|
-
id:
|
|
588
|
+
id: dataSourceId,
|
|
587
589
|
scopeInstanceId: z.string().optional(),
|
|
588
590
|
name: z.string(),
|
|
589
591
|
resourceId: z.string()
|
|
590
592
|
})
|
|
591
593
|
]);
|
|
592
|
-
z.map(
|
|
593
|
-
const
|
|
594
|
+
z.map(dataSourceId, dataSource);
|
|
595
|
+
const templates = z.enum([
|
|
594
596
|
"docker",
|
|
595
597
|
"vercel",
|
|
596
598
|
"netlify",
|
|
@@ -598,13 +600,13 @@ const Templates = z.enum([
|
|
|
598
600
|
"ssg-netlify",
|
|
599
601
|
"ssg-vercel"
|
|
600
602
|
]);
|
|
601
|
-
const
|
|
603
|
+
const deployment = z.union([
|
|
602
604
|
z.object({
|
|
603
605
|
destination: z.literal("static"),
|
|
604
606
|
name: z.string(),
|
|
605
607
|
assetsDomain: z.string(),
|
|
606
608
|
// Must be validated very strictly
|
|
607
|
-
templates: z.array(
|
|
609
|
+
templates: z.array(templates)
|
|
608
610
|
}),
|
|
609
611
|
z.object({
|
|
610
612
|
destination: z.literal("saas").optional(),
|
|
@@ -617,30 +619,30 @@ const Deployment = z.union([
|
|
|
617
619
|
excludeWstdDomainFromSearch: z.boolean().optional()
|
|
618
620
|
})
|
|
619
621
|
]);
|
|
620
|
-
const
|
|
622
|
+
const textChild = z.object({
|
|
621
623
|
type: z.literal("text"),
|
|
622
624
|
value: z.string(),
|
|
623
625
|
placeholder: z.boolean().optional()
|
|
624
626
|
});
|
|
625
|
-
const
|
|
626
|
-
const
|
|
627
|
+
const instanceId$1 = z.string();
|
|
628
|
+
const idChild = z.object({
|
|
627
629
|
type: z.literal("id"),
|
|
628
|
-
value:
|
|
630
|
+
value: instanceId$1
|
|
629
631
|
});
|
|
630
|
-
const
|
|
632
|
+
const expressionChild = z.object({
|
|
631
633
|
type: z.literal("expression"),
|
|
632
634
|
value: z.string()
|
|
633
635
|
});
|
|
634
|
-
const
|
|
635
|
-
const
|
|
636
|
+
const instanceChild = z.union([idChild, textChild, expressionChild]);
|
|
637
|
+
const instance = z.object({
|
|
636
638
|
type: z.literal("instance"),
|
|
637
|
-
id:
|
|
639
|
+
id: instanceId$1,
|
|
638
640
|
component: z.string(),
|
|
639
641
|
tag: z.string().optional(),
|
|
640
642
|
label: z.string().optional(),
|
|
641
|
-
children: z.array(
|
|
643
|
+
children: z.array(instanceChild)
|
|
642
644
|
});
|
|
643
|
-
z.map(
|
|
645
|
+
z.map(instanceId$1, instance);
|
|
644
646
|
const basicLoginErrors = (login) => {
|
|
645
647
|
const issues = [];
|
|
646
648
|
if (login.length === 0) {
|
|
@@ -892,12 +894,12 @@ const buildWsAuth = (sources) => {
|
|
|
892
894
|
};
|
|
893
895
|
const createWsAuthResources = ({
|
|
894
896
|
projectContent = "",
|
|
895
|
-
pages,
|
|
897
|
+
pages: pages2,
|
|
896
898
|
projectSourceName = "Auth",
|
|
897
899
|
generatedSourceName = "Generated page auth"
|
|
898
900
|
}) => {
|
|
899
|
-
const generatedRoutes =
|
|
900
|
-
const route = createWsAuthRouteFromPage(
|
|
901
|
+
const generatedRoutes = pages2.flatMap((page2) => {
|
|
902
|
+
const route = createWsAuthRouteFromPage(page2);
|
|
901
903
|
return route === void 0 ? [] : [route];
|
|
902
904
|
});
|
|
903
905
|
const result = buildWsAuth([
|
|
@@ -919,26 +921,26 @@ const createWsAuthResources = ({
|
|
|
919
921
|
};
|
|
920
922
|
};
|
|
921
923
|
const MIN_TITLE_LENGTH = 2;
|
|
922
|
-
const
|
|
923
|
-
const
|
|
924
|
-
const
|
|
925
|
-
const
|
|
924
|
+
const pageId = z.string();
|
|
925
|
+
const folderId = z.string();
|
|
926
|
+
const folderName = z.string().refine((value) => value.trim() !== "", "Can't be empty");
|
|
927
|
+
const slug = z.string().refine(
|
|
926
928
|
(path) => /^[-a-z0-9]*$/.test(path),
|
|
927
929
|
"Only a-z, 0-9 and - are allowed"
|
|
928
930
|
);
|
|
929
|
-
const
|
|
930
|
-
id:
|
|
931
|
-
name:
|
|
932
|
-
slug
|
|
933
|
-
children: z.array(z.union([
|
|
931
|
+
const folder = z.object({
|
|
932
|
+
id: folderId,
|
|
933
|
+
name: folderName,
|
|
934
|
+
slug,
|
|
935
|
+
children: z.array(z.union([folderId, pageId]))
|
|
934
936
|
});
|
|
935
|
-
const
|
|
936
|
-
const
|
|
937
|
+
const pageName = z.string().refine((value) => value.trim() !== "", "Can't be empty");
|
|
938
|
+
const pageTitle = z.string().refine(
|
|
937
939
|
(val) => val.length >= MIN_TITLE_LENGTH,
|
|
938
940
|
`Minimum ${MIN_TITLE_LENGTH} characters required`
|
|
939
941
|
);
|
|
940
942
|
const documentTypes = ["html", "xml", "text"];
|
|
941
|
-
const
|
|
943
|
+
const basicAuthFields = {
|
|
942
944
|
login: z.string(),
|
|
943
945
|
password: z.string()
|
|
944
946
|
};
|
|
@@ -954,23 +956,23 @@ const validateBasicAuthFields = ({
|
|
|
954
956
|
});
|
|
955
957
|
}
|
|
956
958
|
};
|
|
957
|
-
const
|
|
959
|
+
const pageBasicAuth = z.object({
|
|
958
960
|
method: z.literal("basic"),
|
|
959
|
-
...
|
|
961
|
+
...basicAuthFields
|
|
960
962
|
}).superRefine(validateBasicAuthFields);
|
|
961
|
-
const
|
|
963
|
+
const legacyPageBasicAuth = z.object({
|
|
962
964
|
type: z.literal("basic"),
|
|
963
|
-
...
|
|
965
|
+
...basicAuthFields
|
|
964
966
|
}).superRefine(validateBasicAuthFields).transform(({ login, password }) => ({
|
|
965
967
|
method: "basic",
|
|
966
968
|
login,
|
|
967
969
|
password
|
|
968
970
|
}));
|
|
969
|
-
const
|
|
971
|
+
const pageAuth = z.union([pageBasicAuth, legacyPageBasicAuth]);
|
|
970
972
|
const commonPageFields = {
|
|
971
|
-
id:
|
|
972
|
-
name:
|
|
973
|
-
title:
|
|
973
|
+
id: pageId,
|
|
974
|
+
name: pageName,
|
|
975
|
+
title: pageTitle,
|
|
974
976
|
history: z.optional(z.array(z.string())),
|
|
975
977
|
rootInstanceId: z.string(),
|
|
976
978
|
systemDataSourceId: z.string().optional(),
|
|
@@ -985,7 +987,7 @@ const commonPageFields = {
|
|
|
985
987
|
redirect: z.string().optional(),
|
|
986
988
|
documentType: z.optional(z.enum(documentTypes)),
|
|
987
989
|
content: z.string().optional(),
|
|
988
|
-
auth:
|
|
990
|
+
auth: pageAuth.optional(),
|
|
989
991
|
custom: z.array(
|
|
990
992
|
z.object({
|
|
991
993
|
property: z.string(),
|
|
@@ -1001,8 +1003,8 @@ const commonPageFields = {
|
|
|
1001
1003
|
})
|
|
1002
1004
|
)
|
|
1003
1005
|
};
|
|
1004
|
-
const
|
|
1005
|
-
const
|
|
1006
|
+
const homePagePath = z.string().refine((path) => path === "", "Home page path must be empty");
|
|
1007
|
+
const defaultPagePath = z.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
|
|
1006
1008
|
(path) => /^[-_a-z0-9*:?\\/.]*$/.test(path),
|
|
1007
1009
|
"Only a-z, 0-9, -, _, /, :, ?, . and * are allowed"
|
|
1008
1010
|
).refine(
|
|
@@ -1015,7 +1017,7 @@ const DefaultPagePage = z.string().refine((path) => path !== "", "Can't be empty
|
|
|
1015
1017
|
(path) => path !== "/build" && path.startsWith("/build/") === false,
|
|
1016
1018
|
"/build prefix is reserved for the system"
|
|
1017
1019
|
).refine((path) => path.length <= 255, "Path can't exceed 255 characters");
|
|
1018
|
-
const
|
|
1020
|
+
const redirectSourcePath = z.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine(
|
|
1019
1021
|
(path) => path.startsWith("/") && path.startsWith("//") === false,
|
|
1020
1022
|
"Must start with a /"
|
|
1021
1023
|
).refine((path) => {
|
|
@@ -1035,23 +1037,23 @@ const RedirectSourcePath = z.string().refine((path) => path !== "", "Can't be em
|
|
|
1035
1037
|
(path) => path !== "/build" && path.startsWith("/build/") === false,
|
|
1036
1038
|
"/build prefix is reserved for the system"
|
|
1037
1039
|
);
|
|
1038
|
-
const
|
|
1040
|
+
const pagePath = defaultPagePath.refine(
|
|
1039
1041
|
(path) => path === "" || path.startsWith("/"),
|
|
1040
1042
|
"Must start with a / or a full URL e.g. https://website.org"
|
|
1041
1043
|
);
|
|
1042
|
-
const
|
|
1044
|
+
const page = z.object({
|
|
1043
1045
|
...commonPageFields,
|
|
1044
|
-
path: z.union([
|
|
1046
|
+
path: z.union([homePagePath, pagePath])
|
|
1045
1047
|
});
|
|
1046
|
-
const
|
|
1047
|
-
id:
|
|
1048
|
-
name:
|
|
1049
|
-
title:
|
|
1048
|
+
const pageTemplate = z.object({
|
|
1049
|
+
id: pageId,
|
|
1050
|
+
name: pageName,
|
|
1051
|
+
title: pageTitle,
|
|
1050
1052
|
rootInstanceId: z.string(),
|
|
1051
1053
|
systemDataSourceId: z.string().optional(),
|
|
1052
1054
|
meta: commonPageFields.meta
|
|
1053
1055
|
});
|
|
1054
|
-
const
|
|
1056
|
+
const projectMeta = z.object({
|
|
1055
1057
|
// All fields are optional to ensure consistency and allow for the addition of new fields without requiring migration
|
|
1056
1058
|
siteName: z.string().optional(),
|
|
1057
1059
|
contactEmail: z.string().optional(),
|
|
@@ -1059,7 +1061,7 @@ const ProjectMeta = z.object({
|
|
|
1059
1061
|
code: z.string().optional(),
|
|
1060
1062
|
auth: z.string().optional()
|
|
1061
1063
|
});
|
|
1062
|
-
const
|
|
1064
|
+
const projectNewRedirectPath = z.string().min(1, "Path is required").refine((data) => {
|
|
1063
1065
|
try {
|
|
1064
1066
|
new URL(data, "http://url.com");
|
|
1065
1067
|
return true;
|
|
@@ -1067,27 +1069,27 @@ const ProjectNewRedirectPath = z.string().min(1, "Path is required").refine((dat
|
|
|
1067
1069
|
return false;
|
|
1068
1070
|
}
|
|
1069
1071
|
}, "Must be a valid URL");
|
|
1070
|
-
const
|
|
1071
|
-
old:
|
|
1072
|
-
new:
|
|
1072
|
+
const pageRedirect = z.object({
|
|
1073
|
+
old: redirectSourcePath,
|
|
1074
|
+
new: projectNewRedirectPath,
|
|
1073
1075
|
status: z.enum(["301", "302"]).optional()
|
|
1074
1076
|
});
|
|
1075
|
-
const
|
|
1077
|
+
const compilerSettings = z.object({
|
|
1076
1078
|
// All fields are optional to ensure consistency and allow for the addition of new fields without requiring migration
|
|
1077
1079
|
atomicStyles: z.boolean().optional()
|
|
1078
1080
|
});
|
|
1079
|
-
const
|
|
1080
|
-
meta:
|
|
1081
|
-
compiler:
|
|
1082
|
-
redirects: z.array(
|
|
1083
|
-
homePageId:
|
|
1084
|
-
rootFolderId:
|
|
1085
|
-
pages: z.map(
|
|
1086
|
-
pageTemplates: z.map(
|
|
1087
|
-
folders: z.map(
|
|
1088
|
-
}).superRefine((
|
|
1089
|
-
const homePage =
|
|
1090
|
-
const rootFolder =
|
|
1081
|
+
const pages = z.object({
|
|
1082
|
+
meta: projectMeta.optional(),
|
|
1083
|
+
compiler: compilerSettings.optional(),
|
|
1084
|
+
redirects: z.array(pageRedirect).optional(),
|
|
1085
|
+
homePageId: pageId,
|
|
1086
|
+
rootFolderId: folderId,
|
|
1087
|
+
pages: z.map(pageId, page),
|
|
1088
|
+
pageTemplates: z.map(pageId, pageTemplate).optional(),
|
|
1089
|
+
folders: z.map(folderId, folder).refine((folders) => folders.size > 0, "Folders can't be empty")
|
|
1090
|
+
}).superRefine((pages2, context) => {
|
|
1091
|
+
const homePage = pages2.pages.get(pages2.homePageId);
|
|
1092
|
+
const rootFolder = pages2.folders.get(pages2.rootFolderId);
|
|
1091
1093
|
if (homePage === void 0) {
|
|
1092
1094
|
context.addIssue({
|
|
1093
1095
|
code: z.ZodIssueCode.custom,
|
|
@@ -1105,27 +1107,27 @@ const Pages = z.object({
|
|
|
1105
1107
|
if (homePage !== void 0 && homePage.path !== "") {
|
|
1106
1108
|
context.addIssue({
|
|
1107
1109
|
code: z.ZodIssueCode.custom,
|
|
1108
|
-
path: ["pages",
|
|
1110
|
+
path: ["pages", pages2.homePageId, "path"],
|
|
1109
1111
|
message: "Home page path must be empty"
|
|
1110
1112
|
});
|
|
1111
1113
|
}
|
|
1112
|
-
for (const [
|
|
1113
|
-
if (
|
|
1114
|
+
for (const [pageId2, page2] of pages2.pages) {
|
|
1115
|
+
if (page2.id !== pageId2) {
|
|
1114
1116
|
context.addIssue({
|
|
1115
1117
|
code: z.ZodIssueCode.custom,
|
|
1116
|
-
path: ["pages",
|
|
1118
|
+
path: ["pages", pageId2, "id"],
|
|
1117
1119
|
message: "Page id must match its record key"
|
|
1118
1120
|
});
|
|
1119
1121
|
}
|
|
1120
|
-
if (
|
|
1122
|
+
if (pageId2 !== pages2.homePageId && page2.path === "") {
|
|
1121
1123
|
context.addIssue({
|
|
1122
1124
|
code: z.ZodIssueCode.custom,
|
|
1123
|
-
path: ["pages",
|
|
1125
|
+
path: ["pages", pageId2, "path"],
|
|
1124
1126
|
message: "Page path can't be empty"
|
|
1125
1127
|
});
|
|
1126
1128
|
}
|
|
1127
1129
|
}
|
|
1128
|
-
for (const [templateId, template] of
|
|
1130
|
+
for (const [templateId, template] of pages2.pageTemplates ?? []) {
|
|
1129
1131
|
if (template.id !== templateId) {
|
|
1130
1132
|
context.addIssue({
|
|
1131
1133
|
code: z.ZodIssueCode.custom,
|
|
@@ -1133,7 +1135,7 @@ const Pages = z.object({
|
|
|
1133
1135
|
message: "Page template id must match its record key"
|
|
1134
1136
|
});
|
|
1135
1137
|
}
|
|
1136
|
-
if (
|
|
1138
|
+
if (pages2.pages.has(templateId)) {
|
|
1137
1139
|
context.addIssue({
|
|
1138
1140
|
code: z.ZodIssueCode.custom,
|
|
1139
1141
|
path: ["pageTemplates", templateId, "id"],
|
|
@@ -1141,75 +1143,75 @@ const Pages = z.object({
|
|
|
1141
1143
|
});
|
|
1142
1144
|
}
|
|
1143
1145
|
}
|
|
1144
|
-
for (const [
|
|
1145
|
-
if (
|
|
1146
|
+
for (const [folderId2, folder2] of pages2.folders) {
|
|
1147
|
+
if (folder2.id !== folderId2) {
|
|
1146
1148
|
context.addIssue({
|
|
1147
1149
|
code: z.ZodIssueCode.custom,
|
|
1148
|
-
path: ["folders",
|
|
1150
|
+
path: ["folders", folderId2, "id"],
|
|
1149
1151
|
message: "Folder id must match its record key"
|
|
1150
1152
|
});
|
|
1151
1153
|
}
|
|
1152
|
-
for (const [index, childId] of
|
|
1153
|
-
if (
|
|
1154
|
+
for (const [index, childId] of folder2.children.entries()) {
|
|
1155
|
+
if (pages2.pages.has(childId) === false && pages2.folders.has(childId) === false) {
|
|
1154
1156
|
context.addIssue({
|
|
1155
1157
|
code: z.ZodIssueCode.custom,
|
|
1156
|
-
path: ["folders",
|
|
1158
|
+
path: ["folders", folderId2, "children", index],
|
|
1157
1159
|
message: "Folder child must reference an existing page or folder"
|
|
1158
1160
|
});
|
|
1159
1161
|
}
|
|
1160
|
-
if (childId ===
|
|
1162
|
+
if (childId === pages2.rootFolderId) {
|
|
1161
1163
|
context.addIssue({
|
|
1162
1164
|
code: z.ZodIssueCode.custom,
|
|
1163
|
-
path: ["folders",
|
|
1165
|
+
path: ["folders", folderId2, "children", index],
|
|
1164
1166
|
message: "Root folder can't be nested"
|
|
1165
1167
|
});
|
|
1166
1168
|
}
|
|
1167
1169
|
}
|
|
1168
1170
|
}
|
|
1169
|
-
if (rootFolder !== void 0 && rootFolder.children[0] !==
|
|
1171
|
+
if (rootFolder !== void 0 && rootFolder.children[0] !== pages2.homePageId) {
|
|
1170
1172
|
context.addIssue({
|
|
1171
1173
|
code: z.ZodIssueCode.custom,
|
|
1172
|
-
path: ["folders",
|
|
1174
|
+
path: ["folders", pages2.rootFolderId, "children"],
|
|
1173
1175
|
message: "Root folder must start with the home page"
|
|
1174
1176
|
});
|
|
1175
1177
|
}
|
|
1176
1178
|
const childParents = /* @__PURE__ */ new Map();
|
|
1177
|
-
for (const [
|
|
1178
|
-
for (const [index, childId] of
|
|
1179
|
+
for (const [folderId2, folder2] of pages2.folders) {
|
|
1180
|
+
for (const [index, childId] of folder2.children.entries()) {
|
|
1179
1181
|
const parentId = childParents.get(childId);
|
|
1180
1182
|
if (parentId !== void 0) {
|
|
1181
1183
|
context.addIssue({
|
|
1182
1184
|
code: z.ZodIssueCode.custom,
|
|
1183
|
-
path: ["folders",
|
|
1185
|
+
path: ["folders", folderId2, "children", index],
|
|
1184
1186
|
message: `Child is already registered in folder "${parentId}"`
|
|
1185
1187
|
});
|
|
1186
1188
|
continue;
|
|
1187
1189
|
}
|
|
1188
|
-
childParents.set(childId,
|
|
1190
|
+
childParents.set(childId, folderId2);
|
|
1189
1191
|
}
|
|
1190
1192
|
}
|
|
1191
|
-
const hasFolderCycle = (
|
|
1192
|
-
if (path.has(
|
|
1193
|
+
const hasFolderCycle = (folderId2, path = /* @__PURE__ */ new Set()) => {
|
|
1194
|
+
if (path.has(folderId2)) {
|
|
1193
1195
|
return true;
|
|
1194
1196
|
}
|
|
1195
|
-
const
|
|
1196
|
-
if (
|
|
1197
|
+
const folder2 = pages2.folders.get(folderId2);
|
|
1198
|
+
if (folder2 === void 0) {
|
|
1197
1199
|
return false;
|
|
1198
1200
|
}
|
|
1199
|
-
path.add(
|
|
1200
|
-
for (const childId of
|
|
1201
|
-
if (
|
|
1201
|
+
path.add(folderId2);
|
|
1202
|
+
for (const childId of folder2.children) {
|
|
1203
|
+
if (pages2.folders.has(childId) && hasFolderCycle(childId, path)) {
|
|
1202
1204
|
return true;
|
|
1203
1205
|
}
|
|
1204
1206
|
}
|
|
1205
|
-
path.delete(
|
|
1207
|
+
path.delete(folderId2);
|
|
1206
1208
|
return false;
|
|
1207
1209
|
};
|
|
1208
|
-
for (const
|
|
1209
|
-
if (hasFolderCycle(
|
|
1210
|
+
for (const folderId2 of pages2.folders.keys()) {
|
|
1211
|
+
if (hasFolderCycle(folderId2)) {
|
|
1210
1212
|
context.addIssue({
|
|
1211
1213
|
code: z.ZodIssueCode.custom,
|
|
1212
|
-
path: ["folders",
|
|
1214
|
+
path: ["folders", folderId2, "children"],
|
|
1213
1215
|
message: "Folders can't contain cycles"
|
|
1214
1216
|
});
|
|
1215
1217
|
}
|
|
@@ -1251,12 +1253,19 @@ const prefixStyles = (styleMap) => {
|
|
|
1251
1253
|
}
|
|
1252
1254
|
return newStyleMap;
|
|
1253
1255
|
};
|
|
1254
|
-
const
|
|
1256
|
+
const cssWideKeywords = /* @__PURE__ */ new Set([
|
|
1257
|
+
"initial",
|
|
1258
|
+
"inherit",
|
|
1259
|
+
"unset",
|
|
1260
|
+
"revert",
|
|
1261
|
+
"revert-layer"
|
|
1262
|
+
]);
|
|
1263
|
+
const fallbackTransform = (styleValue2) => {
|
|
1255
1264
|
var _a;
|
|
1256
|
-
if (
|
|
1265
|
+
if (styleValue2.type !== "fontFamily") {
|
|
1257
1266
|
return;
|
|
1258
1267
|
}
|
|
1259
|
-
let { value } =
|
|
1268
|
+
let { value } = styleValue2;
|
|
1260
1269
|
if (value.length === 0) {
|
|
1261
1270
|
value = [DEFAULT_FONT_FALLBACK];
|
|
1262
1271
|
}
|
|
@@ -1270,12 +1279,12 @@ const fallbackTransform = (styleValue) => {
|
|
|
1270
1279
|
};
|
|
1271
1280
|
};
|
|
1272
1281
|
const sanitizeCssUrl = (str) => JSON.stringify(str);
|
|
1273
|
-
const toValue = (
|
|
1274
|
-
if (
|
|
1282
|
+
const toValue = (styleValue2, transformValue) => {
|
|
1283
|
+
if (styleValue2 === void 0) {
|
|
1275
1284
|
return "";
|
|
1276
1285
|
}
|
|
1277
|
-
const transformedValue = (transformValue == null ? void 0 : transformValue(
|
|
1278
|
-
const value = transformedValue ??
|
|
1286
|
+
const transformedValue = (transformValue == null ? void 0 : transformValue(styleValue2)) ?? fallbackTransform(styleValue2);
|
|
1287
|
+
const value = transformedValue ?? styleValue2;
|
|
1279
1288
|
if (value.type === "unit") {
|
|
1280
1289
|
return value.value + (value.unit === "number" ? "" : value.unit);
|
|
1281
1290
|
}
|
|
@@ -1404,173 +1413,6 @@ const toValue = (styleValue, transformValue) => {
|
|
|
1404
1413
|
}
|
|
1405
1414
|
return "";
|
|
1406
1415
|
};
|
|
1407
|
-
const Unit = z.string();
|
|
1408
|
-
const UnitValue = z.object({
|
|
1409
|
-
type: z.literal("unit"),
|
|
1410
|
-
unit: Unit,
|
|
1411
|
-
value: z.number(),
|
|
1412
|
-
hidden: z.boolean().optional()
|
|
1413
|
-
});
|
|
1414
|
-
const KeywordValue = z.object({
|
|
1415
|
-
type: z.literal("keyword"),
|
|
1416
|
-
// @todo use exact type
|
|
1417
|
-
value: z.string(),
|
|
1418
|
-
hidden: z.boolean().optional()
|
|
1419
|
-
});
|
|
1420
|
-
const UnparsedValue = z.object({
|
|
1421
|
-
type: z.literal("unparsed"),
|
|
1422
|
-
value: z.string(),
|
|
1423
|
-
// For the builder we want to be able to hide background-image
|
|
1424
|
-
hidden: z.boolean().optional()
|
|
1425
|
-
});
|
|
1426
|
-
const FontFamilyValue = z.object({
|
|
1427
|
-
type: z.literal("fontFamily"),
|
|
1428
|
-
value: z.array(z.string()),
|
|
1429
|
-
hidden: z.boolean().optional()
|
|
1430
|
-
});
|
|
1431
|
-
const RgbValue = z.object({
|
|
1432
|
-
type: z.literal("rgb"),
|
|
1433
|
-
r: z.number(),
|
|
1434
|
-
g: z.number(),
|
|
1435
|
-
b: z.number(),
|
|
1436
|
-
alpha: z.number(),
|
|
1437
|
-
hidden: z.boolean().optional()
|
|
1438
|
-
});
|
|
1439
|
-
const ColorValue = z.object({
|
|
1440
|
-
type: z.literal("color"),
|
|
1441
|
-
// all these color spaces are defined by design tokens specification
|
|
1442
|
-
colorSpace: z.union([
|
|
1443
|
-
z.literal("hex"),
|
|
1444
|
-
z.literal("srgb"),
|
|
1445
|
-
z.literal("p3"),
|
|
1446
|
-
z.literal("srgb-linear"),
|
|
1447
|
-
z.literal("hsl"),
|
|
1448
|
-
z.literal("hwb"),
|
|
1449
|
-
z.literal("lab"),
|
|
1450
|
-
z.literal("lch"),
|
|
1451
|
-
z.literal("oklab"),
|
|
1452
|
-
z.literal("oklch"),
|
|
1453
|
-
z.literal("a98rgb"),
|
|
1454
|
-
z.literal("prophoto"),
|
|
1455
|
-
z.literal("rec2020"),
|
|
1456
|
-
z.literal("xyz-d65"),
|
|
1457
|
-
z.literal("xyz-d50")
|
|
1458
|
-
]),
|
|
1459
|
-
components: z.tuple([z.number(), z.number(), z.number()]),
|
|
1460
|
-
alpha: z.union([z.number(), z.lazy(() => VarValue)]),
|
|
1461
|
-
hidden: z.boolean().optional()
|
|
1462
|
-
});
|
|
1463
|
-
const FunctionValue = z.object({
|
|
1464
|
-
type: z.literal("function"),
|
|
1465
|
-
name: z.string(),
|
|
1466
|
-
args: z.lazy(() => StyleValue),
|
|
1467
|
-
hidden: z.boolean().optional()
|
|
1468
|
-
});
|
|
1469
|
-
const ImageValue = z.object({
|
|
1470
|
-
type: z.literal("image"),
|
|
1471
|
-
value: z.union([
|
|
1472
|
-
z.object({ type: z.literal("asset"), value: z.string() }),
|
|
1473
|
-
// url is not stored in db and only used by css-engine transformValue
|
|
1474
|
-
// to prepare image value for rendering
|
|
1475
|
-
z.object({ type: z.literal("url"), url: z.string() })
|
|
1476
|
-
]),
|
|
1477
|
-
// For the builder we want to be able to hide images
|
|
1478
|
-
hidden: z.boolean().optional()
|
|
1479
|
-
});
|
|
1480
|
-
const GuaranteedInvalidValue = z.object({
|
|
1481
|
-
type: z.literal("guaranteedInvalid"),
|
|
1482
|
-
hidden: z.boolean().optional()
|
|
1483
|
-
});
|
|
1484
|
-
const InvalidValue = z.object({
|
|
1485
|
-
type: z.literal("invalid"),
|
|
1486
|
-
value: z.string(),
|
|
1487
|
-
hidden: z.boolean().optional()
|
|
1488
|
-
});
|
|
1489
|
-
const UnsetValue = z.object({
|
|
1490
|
-
type: z.literal("unset"),
|
|
1491
|
-
value: z.literal(""),
|
|
1492
|
-
hidden: z.boolean().optional()
|
|
1493
|
-
});
|
|
1494
|
-
const VarFallback = z.union([
|
|
1495
|
-
UnparsedValue,
|
|
1496
|
-
KeywordValue,
|
|
1497
|
-
UnitValue,
|
|
1498
|
-
ColorValue,
|
|
1499
|
-
RgbValue
|
|
1500
|
-
]);
|
|
1501
|
-
const VarValue = z.object({
|
|
1502
|
-
type: z.literal("var"),
|
|
1503
|
-
value: z.string(),
|
|
1504
|
-
fallback: VarFallback.optional(),
|
|
1505
|
-
hidden: z.boolean().optional()
|
|
1506
|
-
});
|
|
1507
|
-
const TupleValueItem = z.union([
|
|
1508
|
-
UnitValue,
|
|
1509
|
-
KeywordValue,
|
|
1510
|
-
UnparsedValue,
|
|
1511
|
-
ImageValue,
|
|
1512
|
-
ColorValue,
|
|
1513
|
-
RgbValue,
|
|
1514
|
-
FunctionValue,
|
|
1515
|
-
VarValue
|
|
1516
|
-
]);
|
|
1517
|
-
const TupleValue = z.object({
|
|
1518
|
-
type: z.literal("tuple"),
|
|
1519
|
-
value: z.array(TupleValueItem),
|
|
1520
|
-
hidden: z.boolean().optional()
|
|
1521
|
-
});
|
|
1522
|
-
const ShadowValue = z.object({
|
|
1523
|
-
type: z.literal("shadow"),
|
|
1524
|
-
hidden: z.boolean().optional(),
|
|
1525
|
-
position: z.union([z.literal("inset"), z.literal("outset")]),
|
|
1526
|
-
offsetX: z.union([UnitValue, VarValue]),
|
|
1527
|
-
offsetY: z.union([UnitValue, VarValue]),
|
|
1528
|
-
blur: z.union([UnitValue, VarValue]).optional(),
|
|
1529
|
-
spread: z.union([UnitValue, VarValue]).optional(),
|
|
1530
|
-
color: z.union([ColorValue, RgbValue, KeywordValue, VarValue]).optional()
|
|
1531
|
-
});
|
|
1532
|
-
const LayerValueItem = z.union([
|
|
1533
|
-
UnitValue,
|
|
1534
|
-
KeywordValue,
|
|
1535
|
-
UnparsedValue,
|
|
1536
|
-
ImageValue,
|
|
1537
|
-
TupleValue,
|
|
1538
|
-
ShadowValue,
|
|
1539
|
-
ColorValue,
|
|
1540
|
-
RgbValue,
|
|
1541
|
-
InvalidValue,
|
|
1542
|
-
FunctionValue,
|
|
1543
|
-
VarValue
|
|
1544
|
-
]);
|
|
1545
|
-
const LayersValue = z.object({
|
|
1546
|
-
type: z.literal("layers"),
|
|
1547
|
-
value: z.array(LayerValueItem),
|
|
1548
|
-
hidden: z.boolean().optional()
|
|
1549
|
-
});
|
|
1550
|
-
const StyleValue = z.union([
|
|
1551
|
-
ImageValue,
|
|
1552
|
-
LayersValue,
|
|
1553
|
-
UnitValue,
|
|
1554
|
-
KeywordValue,
|
|
1555
|
-
FontFamilyValue,
|
|
1556
|
-
ColorValue,
|
|
1557
|
-
RgbValue,
|
|
1558
|
-
UnparsedValue,
|
|
1559
|
-
TupleValue,
|
|
1560
|
-
FunctionValue,
|
|
1561
|
-
GuaranteedInvalidValue,
|
|
1562
|
-
InvalidValue,
|
|
1563
|
-
UnsetValue,
|
|
1564
|
-
VarValue,
|
|
1565
|
-
ShadowValue
|
|
1566
|
-
]);
|
|
1567
|
-
const cssWideKeywords = /* @__PURE__ */ new Set([
|
|
1568
|
-
"initial",
|
|
1569
|
-
"inherit",
|
|
1570
|
-
"unset",
|
|
1571
|
-
"revert",
|
|
1572
|
-
"revert-layer"
|
|
1573
|
-
]);
|
|
1574
1416
|
const isLonghandValue = (value) => {
|
|
1575
1417
|
if (value === void 0) {
|
|
1576
1418
|
return false;
|
|
@@ -1616,8 +1458,8 @@ const mergeWhiteSpaceAndTextWrap = (styleMap) => {
|
|
|
1616
1458
|
const collapse = toValue(collapseValue);
|
|
1617
1459
|
const modeValue = styleMap.get("text-wrap-mode");
|
|
1618
1460
|
const mode = toValue(modeValue);
|
|
1619
|
-
const
|
|
1620
|
-
const style = toValue(
|
|
1461
|
+
const styleValue2 = styleMap.get("text-wrap-style");
|
|
1462
|
+
const style = toValue(styleValue2);
|
|
1621
1463
|
styleMap.delete("text-wrap-mode");
|
|
1622
1464
|
styleMap.delete("text-wrap-style");
|
|
1623
1465
|
if (collapse === "collapse" || collapse === "initial" || mode === "wrap" || mode === "initial") {
|
|
@@ -1645,7 +1487,7 @@ const mergeWhiteSpaceAndTextWrap = (styleMap) => {
|
|
|
1645
1487
|
if (style === "balance" || style === "stable" || style === "pretty") {
|
|
1646
1488
|
styleMap.set("text-wrap", { type: "keyword", value: style });
|
|
1647
1489
|
}
|
|
1648
|
-
const textWrap = ((
|
|
1490
|
+
const textWrap = ((styleValue2 == null ? void 0 : styleValue2.type) !== "keyword" ? styleValue2 : void 0) ?? ((modeValue == null ? void 0 : modeValue.type) !== "keyword" ? modeValue : void 0);
|
|
1649
1491
|
if (textWrap) {
|
|
1650
1492
|
styleMap.set("text-wrap", textWrap);
|
|
1651
1493
|
}
|
|
@@ -1712,7 +1554,7 @@ const mergeDeclarations = (declarations) => {
|
|
|
1712
1554
|
(declaration) => declaration.breakpoint + declaration.selector
|
|
1713
1555
|
);
|
|
1714
1556
|
for (const groupDeclarations of groups.values()) {
|
|
1715
|
-
const { breakpoint, selector } = groupDeclarations[0];
|
|
1557
|
+
const { breakpoint: breakpoint2, selector } = groupDeclarations[0];
|
|
1716
1558
|
const merged = mergeStyles(
|
|
1717
1559
|
new Map(
|
|
1718
1560
|
groupDeclarations.map((item) => [item.property, item.value])
|
|
@@ -1720,7 +1562,7 @@ const mergeDeclarations = (declarations) => {
|
|
|
1720
1562
|
);
|
|
1721
1563
|
for (const [property, value] of merged) {
|
|
1722
1564
|
newDeclarations.push({
|
|
1723
|
-
breakpoint,
|
|
1565
|
+
breakpoint: breakpoint2,
|
|
1724
1566
|
selector,
|
|
1725
1567
|
property,
|
|
1726
1568
|
value
|
|
@@ -1749,8 +1591,8 @@ const normalizeDeclaration = (declaration) => ({
|
|
|
1749
1591
|
property: hyphenateProperty(declaration.property)
|
|
1750
1592
|
});
|
|
1751
1593
|
const getDeclarationKey = (declaraionKey) => {
|
|
1752
|
-
const { breakpoint, selector, property } = declaraionKey;
|
|
1753
|
-
return `${
|
|
1594
|
+
const { breakpoint: breakpoint2, selector, property } = declaraionKey;
|
|
1595
|
+
return `${breakpoint2}:${selector}:${property}`;
|
|
1754
1596
|
};
|
|
1755
1597
|
class MixinRule {
|
|
1756
1598
|
constructor() {
|
|
@@ -1761,8 +1603,8 @@ class MixinRule {
|
|
|
1761
1603
|
/*
|
|
1762
1604
|
* check if breakpoint was updated
|
|
1763
1605
|
*/
|
|
1764
|
-
isDirtyBreakpoint(
|
|
1765
|
-
return __privateGet(this, _dirtyBreakpoints).has(
|
|
1606
|
+
isDirtyBreakpoint(breakpoint2) {
|
|
1607
|
+
return __privateGet(this, _dirtyBreakpoints).has(breakpoint2);
|
|
1766
1608
|
}
|
|
1767
1609
|
/**
|
|
1768
1610
|
* reset breakpoints invalidation
|
|
@@ -1833,23 +1675,23 @@ class NestingRule {
|
|
|
1833
1675
|
return mergeDeclarations(__privateMethod(this, _NestingRule_instances, getDeclarations_fn).call(this));
|
|
1834
1676
|
}
|
|
1835
1677
|
toString({
|
|
1836
|
-
breakpoint,
|
|
1678
|
+
breakpoint: breakpoint2,
|
|
1837
1679
|
indent = 0,
|
|
1838
1680
|
transformValue
|
|
1839
1681
|
}) {
|
|
1840
1682
|
for (const mixin of __privateGet(this, _mixins)) {
|
|
1841
1683
|
const rule = __privateGet(this, _mixinRules).get(mixin);
|
|
1842
|
-
if (rule == null ? void 0 : rule.isDirtyBreakpoint(
|
|
1843
|
-
__privateGet(this, _cache).delete(
|
|
1684
|
+
if (rule == null ? void 0 : rule.isDirtyBreakpoint(breakpoint2)) {
|
|
1685
|
+
__privateGet(this, _cache).delete(breakpoint2);
|
|
1844
1686
|
}
|
|
1845
1687
|
}
|
|
1846
|
-
const cached = __privateGet(this, _cache).get(
|
|
1688
|
+
const cached = __privateGet(this, _cache).get(breakpoint2);
|
|
1847
1689
|
if (cached && cached.indent === indent && cached.transformValue === transformValue) {
|
|
1848
1690
|
return cached.generated;
|
|
1849
1691
|
}
|
|
1850
1692
|
const styleBySelector = /* @__PURE__ */ new Map();
|
|
1851
1693
|
for (const declaration of this.getMergedDeclarations()) {
|
|
1852
|
-
if (declaration.breakpoint !==
|
|
1694
|
+
if (declaration.breakpoint !== breakpoint2) {
|
|
1853
1695
|
continue;
|
|
1854
1696
|
}
|
|
1855
1697
|
let nestedSelector = declaration.selector;
|
|
@@ -1877,7 +1719,7 @@ ${content}
|
|
|
1877
1719
|
${spaces}}
|
|
1878
1720
|
`;
|
|
1879
1721
|
}).join("").trimEnd();
|
|
1880
|
-
__privateGet(this, _cache).set(
|
|
1722
|
+
__privateGet(this, _cache).set(breakpoint2, { generated, indent, transformValue });
|
|
1881
1723
|
return generated;
|
|
1882
1724
|
}
|
|
1883
1725
|
}
|
|
@@ -2247,6 +2089,166 @@ const generateAtomic = (sheet, options) => {
|
|
|
2247
2089
|
});
|
|
2248
2090
|
return { cssText, classes };
|
|
2249
2091
|
};
|
|
2092
|
+
const unit = z.string();
|
|
2093
|
+
const unitValue = z.object({
|
|
2094
|
+
type: z.literal("unit"),
|
|
2095
|
+
unit,
|
|
2096
|
+
value: z.number(),
|
|
2097
|
+
hidden: z.boolean().optional()
|
|
2098
|
+
});
|
|
2099
|
+
const keywordValue = z.object({
|
|
2100
|
+
type: z.literal("keyword"),
|
|
2101
|
+
// @todo use exact type
|
|
2102
|
+
value: z.string(),
|
|
2103
|
+
hidden: z.boolean().optional()
|
|
2104
|
+
});
|
|
2105
|
+
const unparsedValue = z.object({
|
|
2106
|
+
type: z.literal("unparsed"),
|
|
2107
|
+
value: z.string(),
|
|
2108
|
+
// For the builder we want to be able to hide background-image
|
|
2109
|
+
hidden: z.boolean().optional()
|
|
2110
|
+
});
|
|
2111
|
+
const fontFamilyValue = z.object({
|
|
2112
|
+
type: z.literal("fontFamily"),
|
|
2113
|
+
value: z.array(z.string()),
|
|
2114
|
+
hidden: z.boolean().optional()
|
|
2115
|
+
});
|
|
2116
|
+
const rgbValue = z.object({
|
|
2117
|
+
type: z.literal("rgb"),
|
|
2118
|
+
r: z.number(),
|
|
2119
|
+
g: z.number(),
|
|
2120
|
+
b: z.number(),
|
|
2121
|
+
alpha: z.number(),
|
|
2122
|
+
hidden: z.boolean().optional()
|
|
2123
|
+
});
|
|
2124
|
+
const colorValue = z.object({
|
|
2125
|
+
type: z.literal("color"),
|
|
2126
|
+
// all these color spaces are defined by design tokens specification
|
|
2127
|
+
colorSpace: z.union([
|
|
2128
|
+
z.literal("hex"),
|
|
2129
|
+
z.literal("srgb"),
|
|
2130
|
+
z.literal("p3"),
|
|
2131
|
+
z.literal("srgb-linear"),
|
|
2132
|
+
z.literal("hsl"),
|
|
2133
|
+
z.literal("hwb"),
|
|
2134
|
+
z.literal("lab"),
|
|
2135
|
+
z.literal("lch"),
|
|
2136
|
+
z.literal("oklab"),
|
|
2137
|
+
z.literal("oklch"),
|
|
2138
|
+
z.literal("a98rgb"),
|
|
2139
|
+
z.literal("prophoto"),
|
|
2140
|
+
z.literal("rec2020"),
|
|
2141
|
+
z.literal("xyz-d65"),
|
|
2142
|
+
z.literal("xyz-d50")
|
|
2143
|
+
]),
|
|
2144
|
+
components: z.tuple([z.number(), z.number(), z.number()]),
|
|
2145
|
+
alpha: z.union([z.number(), z.lazy(() => varValue)]),
|
|
2146
|
+
hidden: z.boolean().optional()
|
|
2147
|
+
});
|
|
2148
|
+
const functionValue = z.object({
|
|
2149
|
+
type: z.literal("function"),
|
|
2150
|
+
name: z.string(),
|
|
2151
|
+
args: z.lazy(() => styleValue),
|
|
2152
|
+
hidden: z.boolean().optional()
|
|
2153
|
+
});
|
|
2154
|
+
const imageValue = z.object({
|
|
2155
|
+
type: z.literal("image"),
|
|
2156
|
+
value: z.union([
|
|
2157
|
+
z.object({ type: z.literal("asset"), value: z.string() }),
|
|
2158
|
+
// url is not stored in db and only used by css-engine transformValue
|
|
2159
|
+
// to prepare image value for rendering
|
|
2160
|
+
z.object({ type: z.literal("url"), url: z.string() })
|
|
2161
|
+
]),
|
|
2162
|
+
// For the builder we want to be able to hide images
|
|
2163
|
+
hidden: z.boolean().optional()
|
|
2164
|
+
});
|
|
2165
|
+
const guaranteedInvalidValue = z.object({
|
|
2166
|
+
type: z.literal("guaranteedInvalid"),
|
|
2167
|
+
hidden: z.boolean().optional()
|
|
2168
|
+
});
|
|
2169
|
+
const invalidValue = z.object({
|
|
2170
|
+
type: z.literal("invalid"),
|
|
2171
|
+
value: z.string(),
|
|
2172
|
+
hidden: z.boolean().optional()
|
|
2173
|
+
});
|
|
2174
|
+
const unsetValue = z.object({
|
|
2175
|
+
type: z.literal("unset"),
|
|
2176
|
+
value: z.literal(""),
|
|
2177
|
+
hidden: z.boolean().optional()
|
|
2178
|
+
});
|
|
2179
|
+
const varFallback = z.union([
|
|
2180
|
+
unparsedValue,
|
|
2181
|
+
keywordValue,
|
|
2182
|
+
unitValue,
|
|
2183
|
+
colorValue,
|
|
2184
|
+
rgbValue
|
|
2185
|
+
]);
|
|
2186
|
+
const varValue = z.object({
|
|
2187
|
+
type: z.literal("var"),
|
|
2188
|
+
value: z.string(),
|
|
2189
|
+
fallback: varFallback.optional(),
|
|
2190
|
+
hidden: z.boolean().optional()
|
|
2191
|
+
});
|
|
2192
|
+
const tupleValueItem = z.union([
|
|
2193
|
+
unitValue,
|
|
2194
|
+
keywordValue,
|
|
2195
|
+
unparsedValue,
|
|
2196
|
+
imageValue,
|
|
2197
|
+
colorValue,
|
|
2198
|
+
rgbValue,
|
|
2199
|
+
functionValue,
|
|
2200
|
+
varValue
|
|
2201
|
+
]);
|
|
2202
|
+
const tupleValue = z.object({
|
|
2203
|
+
type: z.literal("tuple"),
|
|
2204
|
+
value: z.array(tupleValueItem),
|
|
2205
|
+
hidden: z.boolean().optional()
|
|
2206
|
+
});
|
|
2207
|
+
const shadowValue = z.object({
|
|
2208
|
+
type: z.literal("shadow"),
|
|
2209
|
+
hidden: z.boolean().optional(),
|
|
2210
|
+
position: z.union([z.literal("inset"), z.literal("outset")]),
|
|
2211
|
+
offsetX: z.union([unitValue, varValue]),
|
|
2212
|
+
offsetY: z.union([unitValue, varValue]),
|
|
2213
|
+
blur: z.union([unitValue, varValue]).optional(),
|
|
2214
|
+
spread: z.union([unitValue, varValue]).optional(),
|
|
2215
|
+
color: z.union([colorValue, rgbValue, keywordValue, varValue]).optional()
|
|
2216
|
+
});
|
|
2217
|
+
const layerValueItem = z.union([
|
|
2218
|
+
unitValue,
|
|
2219
|
+
keywordValue,
|
|
2220
|
+
unparsedValue,
|
|
2221
|
+
imageValue,
|
|
2222
|
+
tupleValue,
|
|
2223
|
+
shadowValue,
|
|
2224
|
+
colorValue,
|
|
2225
|
+
rgbValue,
|
|
2226
|
+
invalidValue,
|
|
2227
|
+
functionValue,
|
|
2228
|
+
varValue
|
|
2229
|
+
]);
|
|
2230
|
+
const layersValue = z.object({
|
|
2231
|
+
type: z.literal("layers"),
|
|
2232
|
+
value: z.array(layerValueItem),
|
|
2233
|
+
hidden: z.boolean().optional()
|
|
2234
|
+
});
|
|
2235
|
+
const styleValue = z.union([
|
|
2236
|
+
imageValue,
|
|
2237
|
+
layersValue,
|
|
2238
|
+
unitValue,
|
|
2239
|
+
keywordValue,
|
|
2240
|
+
fontFamilyValue,
|
|
2241
|
+
colorValue,
|
|
2242
|
+
rgbValue,
|
|
2243
|
+
unparsedValue,
|
|
2244
|
+
tupleValue,
|
|
2245
|
+
functionValue,
|
|
2246
|
+
guaranteedInvalidValue,
|
|
2247
|
+
invalidValue,
|
|
2248
|
+
unsetValue,
|
|
2249
|
+
varValue,
|
|
2250
|
+
shadowValue
|
|
2251
|
+
]);
|
|
2250
2252
|
const literalUnion = (arr) => z.union(
|
|
2251
2253
|
arr.map((val) => z.literal(val))
|
|
2252
2254
|
);
|
|
@@ -2294,12 +2296,12 @@ const RANGE_UNITS = [
|
|
|
2294
2296
|
"lvmax",
|
|
2295
2297
|
"dvmax"
|
|
2296
2298
|
];
|
|
2297
|
-
const
|
|
2298
|
-
const
|
|
2299
|
+
const rangeUnit = literalUnion(RANGE_UNITS);
|
|
2300
|
+
const rangeUnitValue = z.union([
|
|
2299
2301
|
z.object({
|
|
2300
2302
|
type: z.literal("unit"),
|
|
2301
2303
|
value: z.number(),
|
|
2302
|
-
unit:
|
|
2304
|
+
unit: rangeUnit
|
|
2303
2305
|
}),
|
|
2304
2306
|
z.object({
|
|
2305
2307
|
type: z.literal("unparsed"),
|
|
@@ -2311,32 +2313,32 @@ const rangeUnitValueSchema = z.union([
|
|
|
2311
2313
|
})
|
|
2312
2314
|
]);
|
|
2313
2315
|
const TIME_UNITS = ["ms", "s"];
|
|
2314
|
-
const
|
|
2315
|
-
const
|
|
2316
|
+
const timeUnit = literalUnion(TIME_UNITS);
|
|
2317
|
+
const durationUnitValue = z.union([
|
|
2316
2318
|
z.object({
|
|
2317
2319
|
type: z.literal("unit"),
|
|
2318
2320
|
value: z.number(),
|
|
2319
|
-
unit:
|
|
2321
|
+
unit: timeUnit
|
|
2320
2322
|
}),
|
|
2321
2323
|
z.object({
|
|
2322
2324
|
type: z.literal("var"),
|
|
2323
2325
|
value: z.string()
|
|
2324
2326
|
})
|
|
2325
2327
|
]);
|
|
2326
|
-
const
|
|
2327
|
-
const
|
|
2328
|
-
|
|
2328
|
+
const iterationsUnitValue = z.union([z.number(), z.literal("infinite")]);
|
|
2329
|
+
const insetUnitValue = z.union([
|
|
2330
|
+
rangeUnitValue,
|
|
2329
2331
|
z.object({
|
|
2330
2332
|
type: z.literal("keyword"),
|
|
2331
2333
|
value: z.literal("auto")
|
|
2332
2334
|
})
|
|
2333
2335
|
]);
|
|
2334
|
-
const
|
|
2335
|
-
const
|
|
2336
|
+
const keyframeStyles = z.record(styleValue);
|
|
2337
|
+
const animationKeyframe = z.object({
|
|
2336
2338
|
offset: z.number().optional(),
|
|
2337
|
-
styles:
|
|
2339
|
+
styles: keyframeStyles
|
|
2338
2340
|
});
|
|
2339
|
-
const
|
|
2341
|
+
const keyframeEffectOptions = z.object({
|
|
2340
2342
|
easing: z.string().optional(),
|
|
2341
2343
|
fill: z.union([
|
|
2342
2344
|
z.literal("none"),
|
|
@@ -2345,29 +2347,23 @@ const keyframeEffectOptionsSchema = z.object({
|
|
|
2345
2347
|
z.literal("both")
|
|
2346
2348
|
]).optional(),
|
|
2347
2349
|
// FillMode
|
|
2348
|
-
duration:
|
|
2349
|
-
delay:
|
|
2350
|
-
iterations:
|
|
2350
|
+
duration: durationUnitValue.optional(),
|
|
2351
|
+
delay: durationUnitValue.optional(),
|
|
2352
|
+
iterations: iterationsUnitValue.optional()
|
|
2351
2353
|
});
|
|
2352
|
-
const
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
scrollNamedRangeSchema,
|
|
2358
|
-
rangeUnitValueSchema
|
|
2359
|
-
]);
|
|
2360
|
-
const scrollRangeOptionsSchema = z.object({
|
|
2361
|
-
rangeStart: scrollRangeValueSchema.optional(),
|
|
2362
|
-
rangeEnd: scrollRangeValueSchema.optional()
|
|
2354
|
+
const scrollNamedRange = z.union([z.literal("start"), z.literal("end")]);
|
|
2355
|
+
const scrollRangeValue = z.tuple([scrollNamedRange, rangeUnitValue]);
|
|
2356
|
+
const scrollRangeOptions = z.object({
|
|
2357
|
+
rangeStart: scrollRangeValue.optional(),
|
|
2358
|
+
rangeEnd: scrollRangeValue.optional()
|
|
2363
2359
|
});
|
|
2364
|
-
const
|
|
2360
|
+
const animationAxis = z.union([
|
|
2365
2361
|
z.literal("block"),
|
|
2366
2362
|
z.literal("inline"),
|
|
2367
2363
|
z.literal("x"),
|
|
2368
2364
|
z.literal("y")
|
|
2369
2365
|
]);
|
|
2370
|
-
const
|
|
2366
|
+
const viewNamedRange = z.union([
|
|
2371
2367
|
z.literal("contain"),
|
|
2372
2368
|
z.literal("cover"),
|
|
2373
2369
|
z.literal("entry"),
|
|
@@ -2375,60 +2371,57 @@ const viewNamedRangeSchema = z.union([
|
|
|
2375
2371
|
z.literal("entry-crossing"),
|
|
2376
2372
|
z.literal("exit-crossing")
|
|
2377
2373
|
]);
|
|
2378
|
-
const
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
const viewRangeOptionsSchema = z.object({
|
|
2383
|
-
rangeStart: viewRangeValueSchema.optional(),
|
|
2384
|
-
rangeEnd: viewRangeValueSchema.optional()
|
|
2374
|
+
const viewRangeValue = z.tuple([viewNamedRange, rangeUnitValue]);
|
|
2375
|
+
const viewRangeOptions = z.object({
|
|
2376
|
+
rangeStart: viewRangeValue.optional(),
|
|
2377
|
+
rangeEnd: viewRangeValue.optional()
|
|
2385
2378
|
});
|
|
2386
2379
|
const baseAnimation = z.object({
|
|
2387
2380
|
name: z.string().optional(),
|
|
2388
2381
|
description: z.string().optional(),
|
|
2389
2382
|
enabled: z.array(z.tuple([z.string().describe("breakpointId"), z.boolean()])).optional(),
|
|
2390
|
-
keyframes: z.array(
|
|
2383
|
+
keyframes: z.array(animationKeyframe)
|
|
2391
2384
|
});
|
|
2392
|
-
const
|
|
2385
|
+
const scrollAnimation = baseAnimation.merge(
|
|
2393
2386
|
z.object({
|
|
2394
|
-
timing:
|
|
2387
|
+
timing: keyframeEffectOptions.merge(scrollRangeOptions)
|
|
2395
2388
|
})
|
|
2396
2389
|
);
|
|
2397
|
-
const
|
|
2390
|
+
const scrollAction = z.object({
|
|
2398
2391
|
type: z.literal("scroll"),
|
|
2399
2392
|
source: z.union([z.literal("closest"), z.literal("nearest"), z.literal("root")]).optional(),
|
|
2400
|
-
axis:
|
|
2401
|
-
animations: z.array(
|
|
2393
|
+
axis: animationAxis.optional(),
|
|
2394
|
+
animations: z.array(scrollAnimation),
|
|
2402
2395
|
isPinned: z.boolean().optional(),
|
|
2403
2396
|
debug: z.boolean().optional()
|
|
2404
2397
|
});
|
|
2405
|
-
const
|
|
2398
|
+
const viewAnimation = baseAnimation.merge(
|
|
2406
2399
|
z.object({
|
|
2407
|
-
timing:
|
|
2400
|
+
timing: keyframeEffectOptions.merge(viewRangeOptions)
|
|
2408
2401
|
})
|
|
2409
2402
|
);
|
|
2410
|
-
const
|
|
2403
|
+
const viewAction = z.object({
|
|
2411
2404
|
type: z.literal("view"),
|
|
2412
2405
|
subject: z.string().optional(),
|
|
2413
|
-
axis:
|
|
2414
|
-
animations: z.array(
|
|
2415
|
-
insetStart:
|
|
2416
|
-
insetEnd:
|
|
2406
|
+
axis: animationAxis.optional(),
|
|
2407
|
+
animations: z.array(viewAnimation),
|
|
2408
|
+
insetStart: insetUnitValue.optional(),
|
|
2409
|
+
insetEnd: insetUnitValue.optional(),
|
|
2417
2410
|
isPinned: z.boolean().optional(),
|
|
2418
2411
|
debug: z.boolean().optional()
|
|
2419
2412
|
});
|
|
2420
|
-
const
|
|
2421
|
-
|
|
2422
|
-
|
|
2413
|
+
const animationAction = z.discriminatedUnion("type", [
|
|
2414
|
+
scrollAction,
|
|
2415
|
+
viewAction
|
|
2423
2416
|
]);
|
|
2424
|
-
const
|
|
2417
|
+
const propId = z.string();
|
|
2425
2418
|
const baseProp = {
|
|
2426
|
-
id:
|
|
2419
|
+
id: propId,
|
|
2427
2420
|
instanceId: z.string(),
|
|
2428
2421
|
name: z.string(),
|
|
2429
2422
|
required: z.optional(z.boolean())
|
|
2430
2423
|
};
|
|
2431
|
-
const
|
|
2424
|
+
const prop = z.union([
|
|
2432
2425
|
z.object({
|
|
2433
2426
|
...baseProp,
|
|
2434
2427
|
type: z.literal("number"),
|
|
@@ -2504,22 +2497,22 @@ const Prop = z.union([
|
|
|
2504
2497
|
z.object({
|
|
2505
2498
|
...baseProp,
|
|
2506
2499
|
type: z.literal("animationAction"),
|
|
2507
|
-
value:
|
|
2500
|
+
value: animationAction
|
|
2508
2501
|
})
|
|
2509
2502
|
]);
|
|
2510
|
-
z.map(
|
|
2511
|
-
const
|
|
2512
|
-
const
|
|
2503
|
+
z.map(propId, prop);
|
|
2504
|
+
const resourceId = z.string();
|
|
2505
|
+
const method = z.union([
|
|
2513
2506
|
z.literal("get"),
|
|
2514
2507
|
z.literal("post"),
|
|
2515
2508
|
z.literal("put"),
|
|
2516
2509
|
z.literal("delete")
|
|
2517
2510
|
]);
|
|
2518
|
-
const
|
|
2519
|
-
id:
|
|
2511
|
+
const resource = z.object({
|
|
2512
|
+
id: resourceId,
|
|
2520
2513
|
name: z.string(),
|
|
2521
2514
|
control: z.optional(z.union([z.literal("system"), z.literal("graphql")])),
|
|
2522
|
-
method
|
|
2515
|
+
method,
|
|
2523
2516
|
// expression
|
|
2524
2517
|
url: z.string(),
|
|
2525
2518
|
searchParams: z.array(
|
|
@@ -2541,7 +2534,7 @@ const Resource = z.object({
|
|
|
2541
2534
|
});
|
|
2542
2535
|
z.object({
|
|
2543
2536
|
name: z.string(),
|
|
2544
|
-
method
|
|
2537
|
+
method,
|
|
2545
2538
|
url: z.string(),
|
|
2546
2539
|
searchParams: z.array(
|
|
2547
2540
|
z.object({
|
|
@@ -2559,38 +2552,38 @@ z.object({
|
|
|
2559
2552
|
),
|
|
2560
2553
|
body: z.optional(z.unknown())
|
|
2561
2554
|
});
|
|
2562
|
-
z.map(
|
|
2563
|
-
const
|
|
2564
|
-
const
|
|
2565
|
-
const
|
|
2566
|
-
instanceId
|
|
2567
|
-
values: z.array(
|
|
2555
|
+
z.map(resourceId, resource);
|
|
2556
|
+
const instanceId = z.string();
|
|
2557
|
+
const styleSourceId$1 = z.string();
|
|
2558
|
+
const styleSourceSelection = z.object({
|
|
2559
|
+
instanceId,
|
|
2560
|
+
values: z.array(styleSourceId$1)
|
|
2568
2561
|
});
|
|
2569
|
-
z.map(
|
|
2570
|
-
const
|
|
2571
|
-
const
|
|
2562
|
+
z.map(instanceId, styleSourceSelection);
|
|
2563
|
+
const styleSourceId = z.string();
|
|
2564
|
+
const styleSourceToken = z.object({
|
|
2572
2565
|
type: z.literal("token"),
|
|
2573
|
-
id:
|
|
2566
|
+
id: styleSourceId,
|
|
2574
2567
|
name: z.string(),
|
|
2575
2568
|
locked: z.boolean().optional()
|
|
2576
2569
|
});
|
|
2577
|
-
const
|
|
2570
|
+
const styleSourceLocal = z.object({
|
|
2578
2571
|
type: z.literal("local"),
|
|
2579
|
-
id:
|
|
2572
|
+
id: styleSourceId
|
|
2580
2573
|
});
|
|
2581
|
-
const
|
|
2582
|
-
z.map(
|
|
2583
|
-
const
|
|
2574
|
+
const styleSource = z.union([styleSourceToken, styleSourceLocal]);
|
|
2575
|
+
z.map(styleSourceId, styleSource);
|
|
2576
|
+
const styleDeclRaw = z.object({
|
|
2584
2577
|
styleSourceId: z.string(),
|
|
2585
2578
|
breakpointId: z.string(),
|
|
2586
2579
|
state: z.optional(z.string()),
|
|
2587
2580
|
// @todo can't figure out how to make property to be enum
|
|
2588
2581
|
property: z.string(),
|
|
2589
|
-
value:
|
|
2582
|
+
value: styleValue,
|
|
2590
2583
|
listed: z.boolean().optional().describe("Whether the style is from the Advanced panel")
|
|
2591
2584
|
});
|
|
2592
|
-
const
|
|
2593
|
-
z.map(z.string(),
|
|
2585
|
+
const styleDecl = styleDeclRaw;
|
|
2586
|
+
z.map(z.string(), styleDecl);
|
|
2594
2587
|
const ALLOWED_FILE_TYPES = {
|
|
2595
2588
|
// Documents
|
|
2596
2589
|
pdf: "application/pdf",
|
|
@@ -2703,37 +2696,37 @@ const detectAssetType = (fileName) => {
|
|
|
2703
2696
|
}
|
|
2704
2697
|
return "file";
|
|
2705
2698
|
};
|
|
2706
|
-
const getAssetUrl = (
|
|
2699
|
+
const getAssetUrl = (asset2, origin) => {
|
|
2707
2700
|
let path;
|
|
2708
|
-
const
|
|
2709
|
-
if (
|
|
2710
|
-
path = `/cgi/image/${
|
|
2701
|
+
const assetType2 = detectAssetType(asset2.name);
|
|
2702
|
+
if (assetType2 === "image") {
|
|
2703
|
+
path = `/cgi/image/${asset2.name}?format=raw`;
|
|
2711
2704
|
} else {
|
|
2712
|
-
path = `/cgi/asset/${
|
|
2705
|
+
path = `/cgi/asset/${asset2.name}?format=raw`;
|
|
2713
2706
|
}
|
|
2714
2707
|
return new URL(path, origin);
|
|
2715
2708
|
};
|
|
2716
|
-
const extractImageMetadata = (
|
|
2717
|
-
if (
|
|
2709
|
+
const extractImageMetadata = (asset2) => {
|
|
2710
|
+
if (asset2.type !== "image") {
|
|
2718
2711
|
return;
|
|
2719
2712
|
}
|
|
2720
|
-
if (
|
|
2713
|
+
if (asset2.meta.width && asset2.meta.height) {
|
|
2721
2714
|
return {
|
|
2722
|
-
width:
|
|
2723
|
-
height:
|
|
2715
|
+
width: asset2.meta.width,
|
|
2716
|
+
height: asset2.meta.height
|
|
2724
2717
|
};
|
|
2725
2718
|
}
|
|
2726
2719
|
};
|
|
2727
|
-
const extractFontMetadata = (
|
|
2728
|
-
if (
|
|
2720
|
+
const extractFontMetadata = (asset2) => {
|
|
2721
|
+
if (asset2.type !== "font") {
|
|
2729
2722
|
return;
|
|
2730
2723
|
}
|
|
2731
2724
|
const metadata = {
|
|
2732
|
-
family:
|
|
2725
|
+
family: asset2.meta.family
|
|
2733
2726
|
};
|
|
2734
|
-
if ("style" in
|
|
2735
|
-
metadata.style =
|
|
2736
|
-
metadata.weight =
|
|
2727
|
+
if ("style" in asset2.meta) {
|
|
2728
|
+
metadata.style = asset2.meta.style;
|
|
2729
|
+
metadata.weight = asset2.meta.weight;
|
|
2737
2730
|
}
|
|
2738
2731
|
return metadata;
|
|
2739
2732
|
};
|
|
@@ -2745,10 +2738,10 @@ const metadataExtractors = {
|
|
|
2745
2738
|
font: extractFontMetadata,
|
|
2746
2739
|
file: extractFileMetadata
|
|
2747
2740
|
};
|
|
2748
|
-
const toRuntimeAsset = (
|
|
2749
|
-
const extractor = metadataExtractors[
|
|
2750
|
-
const metadata = extractor(
|
|
2751
|
-
const url = getAssetUrl(
|
|
2741
|
+
const toRuntimeAsset = (asset2, origin) => {
|
|
2742
|
+
const extractor = metadataExtractors[asset2.type];
|
|
2743
|
+
const metadata = extractor(asset2);
|
|
2744
|
+
const url = getAssetUrl(asset2, origin);
|
|
2752
2745
|
const relativeUrl = url.pathname + url.search;
|
|
2753
2746
|
return {
|
|
2754
2747
|
url: relativeUrl,
|
|
@@ -3441,16 +3434,16 @@ const coreMetas = {
|
|
|
3441
3434
|
};
|
|
3442
3435
|
const isCoreComponent = (component) => component === rootComponent || component === elementComponent || component === collectionComponent || component === descendantComponent || component === blockComponent || component === blockTemplateComponent;
|
|
3443
3436
|
const ROOT_INSTANCE_ID = ":root";
|
|
3444
|
-
const traverseInstances = (instances,
|
|
3445
|
-
const
|
|
3446
|
-
if (
|
|
3437
|
+
const traverseInstances = (instances, instanceId2, callback) => {
|
|
3438
|
+
const instance2 = instances.get(instanceId2);
|
|
3439
|
+
if (instance2 === void 0) {
|
|
3447
3440
|
return;
|
|
3448
3441
|
}
|
|
3449
|
-
const skipTraversingChildren = callback(
|
|
3442
|
+
const skipTraversingChildren = callback(instance2);
|
|
3450
3443
|
if (skipTraversingChildren === false) {
|
|
3451
3444
|
return;
|
|
3452
3445
|
}
|
|
3453
|
-
for (const child of
|
|
3446
|
+
for (const child of instance2.children) {
|
|
3454
3447
|
if (child.type === "id") {
|
|
3455
3448
|
traverseInstances(instances, child.value, callback);
|
|
3456
3449
|
}
|
|
@@ -3458,8 +3451,8 @@ const traverseInstances = (instances, instanceId, callback) => {
|
|
|
3458
3451
|
};
|
|
3459
3452
|
const findTreeInstanceIds = (instances, rootInstanceId) => {
|
|
3460
3453
|
const ids = /* @__PURE__ */ new Set([rootInstanceId]);
|
|
3461
|
-
traverseInstances(instances, rootInstanceId, (
|
|
3462
|
-
ids.add(
|
|
3454
|
+
traverseInstances(instances, rootInstanceId, (instance2) => {
|
|
3455
|
+
ids.add(instance2.id);
|
|
3463
3456
|
});
|
|
3464
3457
|
return ids;
|
|
3465
3458
|
};
|
|
@@ -3476,30 +3469,30 @@ const parseComponentName = (componentName) => {
|
|
|
3476
3469
|
};
|
|
3477
3470
|
const getHtmlTagsFromProps = (props) => {
|
|
3478
3471
|
const tags2 = /* @__PURE__ */ new Map();
|
|
3479
|
-
for (const
|
|
3480
|
-
if (
|
|
3481
|
-
tags2.set(
|
|
3472
|
+
for (const prop2 of props.values()) {
|
|
3473
|
+
if (prop2.type === "string" && prop2.name === "tag") {
|
|
3474
|
+
tags2.set(prop2.instanceId, prop2.value);
|
|
3482
3475
|
}
|
|
3483
3476
|
}
|
|
3484
3477
|
return tags2;
|
|
3485
3478
|
};
|
|
3486
3479
|
const getHtmlTagFromInstance = ({
|
|
3487
|
-
instance,
|
|
3480
|
+
instance: instance2,
|
|
3488
3481
|
metas,
|
|
3489
3482
|
props,
|
|
3490
3483
|
htmlTagsByInstanceId
|
|
3491
3484
|
}) => {
|
|
3492
|
-
if (
|
|
3485
|
+
if (instance2.component === "XmlNode") {
|
|
3493
3486
|
return;
|
|
3494
3487
|
}
|
|
3495
|
-
if (
|
|
3496
|
-
return
|
|
3488
|
+
if (instance2.tag !== void 0) {
|
|
3489
|
+
return instance2.tag;
|
|
3497
3490
|
}
|
|
3498
|
-
const propTag = htmlTagsByInstanceId === void 0 ? props === void 0 ? void 0 : getHtmlTagsFromProps(props).get(
|
|
3491
|
+
const propTag = htmlTagsByInstanceId === void 0 ? props === void 0 ? void 0 : getHtmlTagsFromProps(props).get(instance2.id) : htmlTagsByInstanceId.get(instance2.id);
|
|
3499
3492
|
if (propTag !== void 0) {
|
|
3500
3493
|
return propTag;
|
|
3501
3494
|
}
|
|
3502
|
-
const meta = metas.get(
|
|
3495
|
+
const meta = metas.get(instance2.component);
|
|
3503
3496
|
const metaTag = Object.keys((meta == null ? void 0 : meta.presetStyle) ?? {}).at(0);
|
|
3504
3497
|
return metaTag;
|
|
3505
3498
|
};
|
|
@@ -3511,17 +3504,17 @@ const getIndexesWithinAncestors = (metas, instances, rootIds) => {
|
|
|
3511
3504
|
}
|
|
3512
3505
|
}
|
|
3513
3506
|
const indexes = /* @__PURE__ */ new Map();
|
|
3514
|
-
const traverseInstances2 = (instances2,
|
|
3515
|
-
const
|
|
3516
|
-
if (
|
|
3507
|
+
const traverseInstances2 = (instances2, instanceId2, latestIndexes2 = /* @__PURE__ */ new Map()) => {
|
|
3508
|
+
const instance2 = instances2.get(instanceId2);
|
|
3509
|
+
if (instance2 === void 0) {
|
|
3517
3510
|
return;
|
|
3518
3511
|
}
|
|
3519
|
-
const meta = metas.get(
|
|
3520
|
-
if (ancestors.has(
|
|
3512
|
+
const meta = metas.get(instance2.component);
|
|
3513
|
+
if (ancestors.has(instance2.component)) {
|
|
3521
3514
|
latestIndexes2 = new Map(latestIndexes2);
|
|
3522
|
-
latestIndexes2.set(
|
|
3515
|
+
latestIndexes2.set(instance2.component, /* @__PURE__ */ new Map());
|
|
3523
3516
|
}
|
|
3524
|
-
if (
|
|
3517
|
+
if (instance2.component === blockTemplateComponent) {
|
|
3525
3518
|
latestIndexes2 = new Map(latestIndexes2);
|
|
3526
3519
|
for (const key of latestIndexes2.keys()) {
|
|
3527
3520
|
latestIndexes2.set(key, /* @__PURE__ */ new Map());
|
|
@@ -3530,21 +3523,21 @@ const getIndexesWithinAncestors = (metas, instances, rootIds) => {
|
|
|
3530
3523
|
if ((meta == null ? void 0 : meta.indexWithinAncestor) !== void 0) {
|
|
3531
3524
|
const ancestorIndexes = latestIndexes2.get(meta.indexWithinAncestor);
|
|
3532
3525
|
if (ancestorIndexes) {
|
|
3533
|
-
let index = ancestorIndexes.get(
|
|
3526
|
+
let index = ancestorIndexes.get(instance2.component) ?? -1;
|
|
3534
3527
|
index += 1;
|
|
3535
|
-
ancestorIndexes.set(
|
|
3536
|
-
indexes.set(
|
|
3528
|
+
ancestorIndexes.set(instance2.component, index);
|
|
3529
|
+
indexes.set(instance2.id, index);
|
|
3537
3530
|
}
|
|
3538
3531
|
}
|
|
3539
|
-
for (const child of
|
|
3532
|
+
for (const child of instance2.children) {
|
|
3540
3533
|
if (child.type === "id") {
|
|
3541
3534
|
traverseInstances2(instances2, child.value, latestIndexes2);
|
|
3542
3535
|
}
|
|
3543
3536
|
}
|
|
3544
3537
|
};
|
|
3545
3538
|
const latestIndexes = /* @__PURE__ */ new Map();
|
|
3546
|
-
for (const
|
|
3547
|
-
traverseInstances2(instances,
|
|
3539
|
+
for (const instanceId2 of rootIds) {
|
|
3540
|
+
traverseInstances2(instances, instanceId2, latestIndexes);
|
|
3548
3541
|
}
|
|
3549
3542
|
return indexes;
|
|
3550
3543
|
};
|
|
@@ -3734,72 +3727,72 @@ const tokenRegex = new RegExp(":(?<name>\\w+)(?<modifier>[?*]?)|(?<wildcard>(?<!
|
|
|
3734
3727
|
const isPathnamePattern = (pathname) => tokenRegex.test(pathname);
|
|
3735
3728
|
const ROOT_FOLDER_ID = "root";
|
|
3736
3729
|
const isRootFolder = ({ id }) => id === ROOT_FOLDER_ID;
|
|
3737
|
-
const getPageById = (
|
|
3738
|
-
return
|
|
3730
|
+
const getPageById = (pages2, pageId2) => {
|
|
3731
|
+
return pages2.pages.get(pageId2);
|
|
3739
3732
|
};
|
|
3740
|
-
const getAllPages = (
|
|
3741
|
-
return Array.from(
|
|
3733
|
+
const getAllPages = (pages2) => {
|
|
3734
|
+
return Array.from(pages2.pages.values());
|
|
3742
3735
|
};
|
|
3743
|
-
const getAllFolders = (
|
|
3744
|
-
return Array.from(
|
|
3736
|
+
const getAllFolders = (pages2) => {
|
|
3737
|
+
return Array.from(pages2.folders.values());
|
|
3745
3738
|
};
|
|
3746
|
-
const getHomePage = (
|
|
3747
|
-
const homePage = getPageById(
|
|
3739
|
+
const getHomePage = (pages2) => {
|
|
3740
|
+
const homePage = getPageById(pages2, pages2.homePageId);
|
|
3748
3741
|
if (homePage === void 0) {
|
|
3749
|
-
throw new Error(`Home page "${
|
|
3742
|
+
throw new Error(`Home page "${pages2.homePageId}" was not found.`);
|
|
3750
3743
|
}
|
|
3751
3744
|
return homePage;
|
|
3752
3745
|
};
|
|
3753
|
-
function findPageByIdOrPath(idOrPath,
|
|
3746
|
+
function findPageByIdOrPath(idOrPath, pages2, options = {}) {
|
|
3754
3747
|
var _a;
|
|
3755
|
-
if (idOrPath === "" || idOrPath === "/" || idOrPath ===
|
|
3756
|
-
return getHomePage(
|
|
3748
|
+
if (idOrPath === "" || idOrPath === "/" || idOrPath === pages2.homePageId) {
|
|
3749
|
+
return getHomePage(pages2);
|
|
3757
3750
|
}
|
|
3758
|
-
const found = getAllPages(
|
|
3759
|
-
(
|
|
3751
|
+
const found = getAllPages(pages2).find(
|
|
3752
|
+
(page2) => page2.id === idOrPath || getPagePath(page2.id, pages2) === idOrPath
|
|
3760
3753
|
);
|
|
3761
3754
|
if (found) {
|
|
3762
3755
|
return found;
|
|
3763
3756
|
}
|
|
3764
3757
|
if (options.includeTemplates) {
|
|
3765
|
-
return (_a =
|
|
3758
|
+
return (_a = pages2.pageTemplates) == null ? void 0 : _a.get(idOrPath);
|
|
3766
3759
|
}
|
|
3767
3760
|
}
|
|
3768
|
-
const getPagePath = (id,
|
|
3761
|
+
const getPagePath = (id, pages2) => {
|
|
3769
3762
|
const foldersMap = /* @__PURE__ */ new Map();
|
|
3770
3763
|
const childParentMap = /* @__PURE__ */ new Map();
|
|
3771
|
-
for (const
|
|
3772
|
-
foldersMap.set(
|
|
3773
|
-
for (const childId of
|
|
3774
|
-
childParentMap.set(childId,
|
|
3764
|
+
for (const folder2 of getAllFolders(pages2)) {
|
|
3765
|
+
foldersMap.set(folder2.id, folder2);
|
|
3766
|
+
for (const childId of folder2.children) {
|
|
3767
|
+
childParentMap.set(childId, folder2.id);
|
|
3775
3768
|
}
|
|
3776
3769
|
}
|
|
3777
3770
|
const paths = [];
|
|
3778
3771
|
let currentId = id;
|
|
3779
|
-
const allPages = getAllPages(
|
|
3780
|
-
for (const
|
|
3781
|
-
if (
|
|
3782
|
-
paths.push(
|
|
3783
|
-
currentId = childParentMap.get(
|
|
3772
|
+
const allPages = getAllPages(pages2);
|
|
3773
|
+
for (const page2 of allPages) {
|
|
3774
|
+
if (page2.id === id) {
|
|
3775
|
+
paths.push(page2.path);
|
|
3776
|
+
currentId = childParentMap.get(page2.id);
|
|
3784
3777
|
break;
|
|
3785
3778
|
}
|
|
3786
3779
|
}
|
|
3787
3780
|
while (currentId) {
|
|
3788
|
-
const
|
|
3789
|
-
if (
|
|
3781
|
+
const folder2 = foldersMap.get(currentId);
|
|
3782
|
+
if (folder2 === void 0) {
|
|
3790
3783
|
break;
|
|
3791
3784
|
}
|
|
3792
|
-
paths.push(
|
|
3785
|
+
paths.push(folder2.slug);
|
|
3793
3786
|
currentId = childParentMap.get(currentId);
|
|
3794
3787
|
}
|
|
3795
3788
|
return paths.reverse().join("/").replace(/\/+/g, "/");
|
|
3796
3789
|
};
|
|
3797
|
-
const getStaticSiteMapXml = (
|
|
3798
|
-
const allPages = getAllPages(
|
|
3799
|
-
return allPages.filter((
|
|
3800
|
-
(
|
|
3801
|
-
).filter((
|
|
3802
|
-
path: getPagePath(
|
|
3790
|
+
const getStaticSiteMapXml = (pages2, updatedAt) => {
|
|
3791
|
+
const allPages = getAllPages(pages2);
|
|
3792
|
+
return allPages.filter((page2) => (page2.meta.documentType ?? "html") === "html").filter(
|
|
3793
|
+
(page2) => executeExpression(page2.meta.excludePageFromSearch) !== true
|
|
3794
|
+
).filter((page2) => false === isPathnamePattern(page2.path)).map((page2) => ({
|
|
3795
|
+
path: getPagePath(page2.id, pages2),
|
|
3803
3796
|
lastModified: updatedAt.split("T")[0]
|
|
3804
3797
|
}));
|
|
3805
3798
|
};
|
|
@@ -3846,22 +3839,22 @@ const createScope = (occupiedIdentifiers = [], normalizeName = normalizeJsName,
|
|
|
3846
3839
|
};
|
|
3847
3840
|
const generateResources = ({
|
|
3848
3841
|
scope,
|
|
3849
|
-
page,
|
|
3842
|
+
page: page2,
|
|
3850
3843
|
dataSources,
|
|
3851
3844
|
props,
|
|
3852
3845
|
resources
|
|
3853
3846
|
}) => {
|
|
3854
3847
|
const usedDataSources = /* @__PURE__ */ new Map();
|
|
3855
3848
|
let generatedRequests = "";
|
|
3856
|
-
for (const
|
|
3849
|
+
for (const resource2 of resources.values()) {
|
|
3857
3850
|
let generatedRequest = "";
|
|
3858
|
-
const resourceName = scope.getName(
|
|
3851
|
+
const resourceName = scope.getName(resource2.id, resource2.name);
|
|
3859
3852
|
generatedRequest += ` const ${resourceName}: ResourceRequest = {
|
|
3860
3853
|
`;
|
|
3861
|
-
generatedRequest += ` name: ${JSON.stringify(
|
|
3854
|
+
generatedRequest += ` name: ${JSON.stringify(resource2.name)},
|
|
3862
3855
|
`;
|
|
3863
3856
|
const url = generateExpression({
|
|
3864
|
-
expression:
|
|
3857
|
+
expression: resource2.url,
|
|
3865
3858
|
dataSources,
|
|
3866
3859
|
usedDataSources,
|
|
3867
3860
|
scope
|
|
@@ -3870,7 +3863,7 @@ const generateResources = ({
|
|
|
3870
3863
|
`;
|
|
3871
3864
|
generatedRequest += ` searchParams: [
|
|
3872
3865
|
`;
|
|
3873
|
-
for (const searchParam of
|
|
3866
|
+
for (const searchParam of resource2.searchParams ?? []) {
|
|
3874
3867
|
const value = generateExpression({
|
|
3875
3868
|
expression: searchParam.value,
|
|
3876
3869
|
dataSources,
|
|
@@ -3882,11 +3875,11 @@ const generateResources = ({
|
|
|
3882
3875
|
}
|
|
3883
3876
|
generatedRequest += ` ],
|
|
3884
3877
|
`;
|
|
3885
|
-
generatedRequest += ` method: "${
|
|
3878
|
+
generatedRequest += ` method: "${resource2.method}",
|
|
3886
3879
|
`;
|
|
3887
3880
|
generatedRequest += ` headers: [
|
|
3888
3881
|
`;
|
|
3889
|
-
for (const header2 of
|
|
3882
|
+
for (const header2 of resource2.headers) {
|
|
3890
3883
|
const value = generateExpression({
|
|
3891
3884
|
expression: header2.value,
|
|
3892
3885
|
dataSources,
|
|
@@ -3898,9 +3891,9 @@ const generateResources = ({
|
|
|
3898
3891
|
}
|
|
3899
3892
|
generatedRequest += ` ],
|
|
3900
3893
|
`;
|
|
3901
|
-
if (
|
|
3894
|
+
if (resource2.body !== void 0 && resource2.body.length > 0) {
|
|
3902
3895
|
const body2 = generateExpression({
|
|
3903
|
-
expression:
|
|
3896
|
+
expression: resource2.body,
|
|
3904
3897
|
dataSources,
|
|
3905
3898
|
usedDataSources,
|
|
3906
3899
|
scope
|
|
@@ -3913,16 +3906,16 @@ const generateResources = ({
|
|
|
3913
3906
|
generatedRequests += generatedRequest;
|
|
3914
3907
|
}
|
|
3915
3908
|
let generatedVariables = "";
|
|
3916
|
-
for (const
|
|
3917
|
-
if (
|
|
3918
|
-
const name2 = scope.getName(
|
|
3919
|
-
const value = JSON.stringify(
|
|
3909
|
+
for (const dataSource2 of usedDataSources.values()) {
|
|
3910
|
+
if (dataSource2.type === "variable") {
|
|
3911
|
+
const name2 = scope.getName(dataSource2.id, dataSource2.name);
|
|
3912
|
+
const value = JSON.stringify(dataSource2.value.value);
|
|
3920
3913
|
generatedVariables += ` let ${name2} = ${value}
|
|
3921
3914
|
`;
|
|
3922
3915
|
}
|
|
3923
|
-
if (
|
|
3924
|
-
if (
|
|
3925
|
-
const name2 = scope.getName(
|
|
3916
|
+
if (dataSource2.type === "parameter") {
|
|
3917
|
+
if (dataSource2.id === page2.systemDataSourceId || dataSource2.id === SYSTEM_VARIABLE_ID) {
|
|
3918
|
+
const name2 = scope.getName(dataSource2.id, dataSource2.name);
|
|
3926
3919
|
generatedVariables += ` const ${name2} = _props.system
|
|
3927
3920
|
`;
|
|
3928
3921
|
}
|
|
@@ -3937,9 +3930,9 @@ const generateResources = ({
|
|
|
3937
3930
|
generated += generatedRequests;
|
|
3938
3931
|
generated += ` const _data = new Map<string, ResourceRequest>([
|
|
3939
3932
|
`;
|
|
3940
|
-
for (const
|
|
3941
|
-
if (
|
|
3942
|
-
const name2 = scope.getName(
|
|
3933
|
+
for (const dataSource2 of dataSources.values()) {
|
|
3934
|
+
if (dataSource2.type === "resource") {
|
|
3935
|
+
const name2 = scope.getName(dataSource2.resourceId, dataSource2.name);
|
|
3943
3936
|
generated += ` ["${name2}", ${name2}],
|
|
3944
3937
|
`;
|
|
3945
3938
|
}
|
|
@@ -3948,9 +3941,9 @@ const generateResources = ({
|
|
|
3948
3941
|
`;
|
|
3949
3942
|
generated += ` const _action = new Map<string, ResourceRequest>([
|
|
3950
3943
|
`;
|
|
3951
|
-
for (const
|
|
3952
|
-
if (
|
|
3953
|
-
const name2 = scope.getName(
|
|
3944
|
+
for (const prop2 of props.values()) {
|
|
3945
|
+
if (prop2.type === "resource") {
|
|
3946
|
+
const name2 = scope.getName(prop2.value, prop2.name);
|
|
3954
3947
|
generated += ` ["${name2}", ${name2}],
|
|
3955
3948
|
`;
|
|
3956
3949
|
}
|
|
@@ -3982,38 +3975,38 @@ const replaceFormActionsWithResources = ({
|
|
|
3982
3975
|
}) => {
|
|
3983
3976
|
var _a, _b;
|
|
3984
3977
|
const formProps = /* @__PURE__ */ new Map();
|
|
3985
|
-
for (const
|
|
3986
|
-
if (
|
|
3987
|
-
let data = formProps.get(
|
|
3978
|
+
for (const prop2 of props.values()) {
|
|
3979
|
+
if (prop2.name === "method" && prop2.type === "string" && ((_a = instances.get(prop2.instanceId)) == null ? void 0 : _a.component) === "Form") {
|
|
3980
|
+
let data = formProps.get(prop2.instanceId);
|
|
3988
3981
|
if (data === void 0) {
|
|
3989
3982
|
data = {};
|
|
3990
|
-
formProps.set(
|
|
3983
|
+
formProps.set(prop2.instanceId, data);
|
|
3991
3984
|
}
|
|
3992
|
-
data.method =
|
|
3993
|
-
props.delete(
|
|
3985
|
+
data.method = prop2.value;
|
|
3986
|
+
props.delete(prop2.id);
|
|
3994
3987
|
}
|
|
3995
|
-
if (
|
|
3996
|
-
let data = formProps.get(
|
|
3988
|
+
if (prop2.name === "action" && prop2.type === "string" && prop2.value && ((_b = instances.get(prop2.instanceId)) == null ? void 0 : _b.component) === "Form") {
|
|
3989
|
+
let data = formProps.get(prop2.instanceId);
|
|
3997
3990
|
if (data === void 0) {
|
|
3998
3991
|
data = {};
|
|
3999
|
-
formProps.set(
|
|
3992
|
+
formProps.set(prop2.instanceId, data);
|
|
4000
3993
|
}
|
|
4001
|
-
data.action =
|
|
4002
|
-
props.set(
|
|
4003
|
-
id:
|
|
4004
|
-
instanceId:
|
|
4005
|
-
name:
|
|
3994
|
+
data.action = prop2.value;
|
|
3995
|
+
props.set(prop2.id, {
|
|
3996
|
+
id: prop2.id,
|
|
3997
|
+
instanceId: prop2.instanceId,
|
|
3998
|
+
name: prop2.name,
|
|
4006
3999
|
type: "resource",
|
|
4007
|
-
value:
|
|
4000
|
+
value: prop2.instanceId
|
|
4008
4001
|
});
|
|
4009
4002
|
}
|
|
4010
4003
|
}
|
|
4011
|
-
for (const [
|
|
4004
|
+
for (const [instanceId2, { action, method: method2 }] of formProps) {
|
|
4012
4005
|
if (action) {
|
|
4013
|
-
resources.set(
|
|
4014
|
-
id:
|
|
4006
|
+
resources.set(instanceId2, {
|
|
4007
|
+
id: instanceId2,
|
|
4015
4008
|
name: "action",
|
|
4016
|
-
method: getMethod(
|
|
4009
|
+
method: getMethod(method2),
|
|
4017
4010
|
url: JSON.stringify(action),
|
|
4018
4011
|
headers: [
|
|
4019
4012
|
{ name: "Content-Type", value: JSON.stringify("application/json") }
|
|
@@ -4024,7 +4017,7 @@ const replaceFormActionsWithResources = ({
|
|
|
4024
4017
|
};
|
|
4025
4018
|
const generatePageMeta = ({
|
|
4026
4019
|
globalScope,
|
|
4027
|
-
page,
|
|
4020
|
+
page: page2,
|
|
4028
4021
|
dataSources,
|
|
4029
4022
|
assets
|
|
4030
4023
|
}) => {
|
|
@@ -4032,52 +4025,52 @@ const generatePageMeta = ({
|
|
|
4032
4025
|
const localScope = createScope(["system", "resources"]);
|
|
4033
4026
|
const usedDataSources = /* @__PURE__ */ new Map();
|
|
4034
4027
|
const titleExpression = generateExpression({
|
|
4035
|
-
expression:
|
|
4028
|
+
expression: page2.title,
|
|
4036
4029
|
dataSources,
|
|
4037
4030
|
usedDataSources,
|
|
4038
4031
|
scope: localScope
|
|
4039
4032
|
});
|
|
4040
4033
|
const descriptionExpression = generateExpression({
|
|
4041
|
-
expression:
|
|
4034
|
+
expression: page2.meta.description ?? "undefined",
|
|
4042
4035
|
dataSources,
|
|
4043
4036
|
usedDataSources,
|
|
4044
4037
|
scope: localScope
|
|
4045
4038
|
});
|
|
4046
4039
|
const excludePageFromSearchExpression = generateExpression({
|
|
4047
|
-
expression:
|
|
4040
|
+
expression: page2.meta.excludePageFromSearch ?? "undefined",
|
|
4048
4041
|
dataSources,
|
|
4049
4042
|
usedDataSources,
|
|
4050
4043
|
scope: localScope
|
|
4051
4044
|
});
|
|
4052
4045
|
const languageExpression = generateExpression({
|
|
4053
|
-
expression:
|
|
4046
|
+
expression: page2.meta.language ?? "undefined",
|
|
4054
4047
|
dataSources,
|
|
4055
4048
|
usedDataSources,
|
|
4056
4049
|
scope: localScope
|
|
4057
4050
|
});
|
|
4058
4051
|
const socialImageAssetNameExpression = JSON.stringify(
|
|
4059
|
-
|
|
4052
|
+
page2.meta.socialImageAssetId ? (_a = assets.get(page2.meta.socialImageAssetId)) == null ? void 0 : _a.name : void 0
|
|
4060
4053
|
);
|
|
4061
4054
|
const socialImageUrlExpression = generateExpression({
|
|
4062
|
-
expression:
|
|
4055
|
+
expression: page2.meta.socialImageUrl ?? "undefined",
|
|
4063
4056
|
dataSources,
|
|
4064
4057
|
usedDataSources,
|
|
4065
4058
|
scope: localScope
|
|
4066
4059
|
});
|
|
4067
4060
|
const statusExpression = generateExpression({
|
|
4068
|
-
expression:
|
|
4061
|
+
expression: page2.meta.status ?? "undefined",
|
|
4069
4062
|
dataSources,
|
|
4070
4063
|
usedDataSources,
|
|
4071
4064
|
scope: localScope
|
|
4072
4065
|
});
|
|
4073
4066
|
const redirectExpression = generateExpression({
|
|
4074
|
-
expression:
|
|
4067
|
+
expression: page2.meta.redirect ?? "undefined",
|
|
4075
4068
|
dataSources,
|
|
4076
4069
|
usedDataSources,
|
|
4077
4070
|
scope: localScope
|
|
4078
4071
|
});
|
|
4079
4072
|
const contentExpression = generateExpression({
|
|
4080
|
-
expression:
|
|
4073
|
+
expression: page2.meta.content ?? "undefined",
|
|
4081
4074
|
dataSources,
|
|
4082
4075
|
usedDataSources,
|
|
4083
4076
|
scope: localScope
|
|
@@ -4085,7 +4078,7 @@ const generatePageMeta = ({
|
|
|
4085
4078
|
let customExpression = "";
|
|
4086
4079
|
customExpression += `[
|
|
4087
4080
|
`;
|
|
4088
|
-
for (const customMeta of
|
|
4081
|
+
for (const customMeta of page2.meta.custom ?? []) {
|
|
4089
4082
|
if (customMeta.property.trim().length === 0) {
|
|
4090
4083
|
continue;
|
|
4091
4084
|
}
|
|
@@ -4121,27 +4114,27 @@ const generatePageMeta = ({
|
|
|
4121
4114
|
`;
|
|
4122
4115
|
generated += `}): PageMeta => {
|
|
4123
4116
|
`;
|
|
4124
|
-
for (const
|
|
4125
|
-
if (
|
|
4126
|
-
const valueName = localScope.getName(
|
|
4127
|
-
const initialValueString = JSON.stringify(
|
|
4117
|
+
for (const dataSource2 of usedDataSources.values()) {
|
|
4118
|
+
if (dataSource2.type === "variable") {
|
|
4119
|
+
const valueName = localScope.getName(dataSource2.id, dataSource2.name);
|
|
4120
|
+
const initialValueString = JSON.stringify(dataSource2.value.value);
|
|
4128
4121
|
generated += ` let ${valueName} = ${initialValueString}
|
|
4129
4122
|
`;
|
|
4130
4123
|
continue;
|
|
4131
4124
|
}
|
|
4132
|
-
if (
|
|
4133
|
-
if (
|
|
4134
|
-
const valueName = localScope.getName(
|
|
4125
|
+
if (dataSource2.type === "parameter") {
|
|
4126
|
+
if (dataSource2.id === page2.systemDataSourceId || dataSource2.id === SYSTEM_VARIABLE_ID) {
|
|
4127
|
+
const valueName = localScope.getName(dataSource2.id, dataSource2.name);
|
|
4135
4128
|
generated += ` let ${valueName} = system
|
|
4136
4129
|
`;
|
|
4137
4130
|
}
|
|
4138
4131
|
continue;
|
|
4139
4132
|
}
|
|
4140
|
-
if (
|
|
4141
|
-
const valueName = localScope.getName(
|
|
4133
|
+
if (dataSource2.type === "resource") {
|
|
4134
|
+
const valueName = localScope.getName(dataSource2.id, dataSource2.name);
|
|
4142
4135
|
const resourceName = globalScope.getName(
|
|
4143
|
-
|
|
4144
|
-
|
|
4136
|
+
dataSource2.resourceId,
|
|
4137
|
+
dataSource2.name
|
|
4145
4138
|
);
|
|
4146
4139
|
generated += ` let ${valueName} = resources.${resourceName}
|
|
4147
4140
|
`;
|
|
@@ -4182,9 +4175,9 @@ const addFontRules = ({
|
|
|
4182
4175
|
assetBaseUrl
|
|
4183
4176
|
}) => {
|
|
4184
4177
|
const fontAssets = [];
|
|
4185
|
-
for (const
|
|
4186
|
-
if (
|
|
4187
|
-
fontAssets.push(
|
|
4178
|
+
for (const asset2 of assets.values()) {
|
|
4179
|
+
if (asset2.type === "font") {
|
|
4180
|
+
fontAssets.push(asset2);
|
|
4188
4181
|
}
|
|
4189
4182
|
}
|
|
4190
4183
|
const fontFaces = getFontFaces(fontAssets, { assetBaseUrl });
|
|
@@ -4192,20 +4185,20 @@ const addFontRules = ({
|
|
|
4192
4185
|
sheet.addFontFaceRule(fontFace);
|
|
4193
4186
|
}
|
|
4194
4187
|
};
|
|
4195
|
-
const createImageValueTransformer = (assets, { assetBaseUrl }) => (
|
|
4196
|
-
if (
|
|
4197
|
-
const
|
|
4198
|
-
if (
|
|
4188
|
+
const createImageValueTransformer = (assets, { assetBaseUrl }) => (styleValue2) => {
|
|
4189
|
+
if (styleValue2.type === "image" && styleValue2.value.type === "asset") {
|
|
4190
|
+
const asset2 = assets.get(styleValue2.value.value);
|
|
4191
|
+
if (asset2 === void 0) {
|
|
4199
4192
|
return { type: "keyword", value: "none" };
|
|
4200
4193
|
}
|
|
4201
|
-
const url = `${assetBaseUrl}${
|
|
4194
|
+
const url = `${assetBaseUrl}${asset2.name}`;
|
|
4202
4195
|
return {
|
|
4203
4196
|
type: "image",
|
|
4204
4197
|
value: {
|
|
4205
4198
|
type: "url",
|
|
4206
4199
|
url
|
|
4207
4200
|
},
|
|
4208
|
-
hidden:
|
|
4201
|
+
hidden: styleValue2.hidden
|
|
4209
4202
|
};
|
|
4210
4203
|
}
|
|
4211
4204
|
};
|
|
@@ -4231,14 +4224,14 @@ const generateCss = ({
|
|
|
4231
4224
|
const tagsByComponent = /* @__PURE__ */ new Map();
|
|
4232
4225
|
tagsByComponent.set(rootComponent, /* @__PURE__ */ new Set(["html"]));
|
|
4233
4226
|
const htmlTagsByInstanceId = getHtmlTagsFromProps(props);
|
|
4234
|
-
for (const
|
|
4235
|
-
let componentTags = tagsByComponent.get(
|
|
4227
|
+
for (const instance2 of instances.values()) {
|
|
4228
|
+
let componentTags = tagsByComponent.get(instance2.component);
|
|
4236
4229
|
if (componentTags === void 0) {
|
|
4237
4230
|
componentTags = /* @__PURE__ */ new Set();
|
|
4238
|
-
tagsByComponent.set(
|
|
4231
|
+
tagsByComponent.set(instance2.component, componentTags);
|
|
4239
4232
|
}
|
|
4240
4233
|
const tag = getHtmlTagFromInstance({
|
|
4241
|
-
instance,
|
|
4234
|
+
instance: instance2,
|
|
4242
4235
|
metas: componentMetas,
|
|
4243
4236
|
props,
|
|
4244
4237
|
htmlTagsByInstanceId
|
|
@@ -4271,78 +4264,78 @@ const generateCss = ({
|
|
|
4271
4264
|
}
|
|
4272
4265
|
}
|
|
4273
4266
|
}
|
|
4274
|
-
for (const
|
|
4275
|
-
userSheet.addMediaRule(
|
|
4267
|
+
for (const breakpoint2 of breakpoints.values()) {
|
|
4268
|
+
userSheet.addMediaRule(breakpoint2.id, breakpoint2);
|
|
4276
4269
|
}
|
|
4277
4270
|
const imageValueTransformer = createImageValueTransformer(assets, {
|
|
4278
4271
|
assetBaseUrl
|
|
4279
4272
|
});
|
|
4280
4273
|
userSheet.setTransformer(imageValueTransformer);
|
|
4281
|
-
for (const
|
|
4282
|
-
const rule = userSheet.addMixinRule(
|
|
4274
|
+
for (const styleDecl2 of styles.values()) {
|
|
4275
|
+
const rule = userSheet.addMixinRule(styleDecl2.styleSourceId);
|
|
4283
4276
|
rule.setDeclaration({
|
|
4284
|
-
breakpoint:
|
|
4285
|
-
selector:
|
|
4286
|
-
property:
|
|
4287
|
-
value:
|
|
4277
|
+
breakpoint: styleDecl2.breakpointId,
|
|
4278
|
+
selector: styleDecl2.state ?? "",
|
|
4279
|
+
property: styleDecl2.property,
|
|
4280
|
+
value: styleDecl2.value
|
|
4288
4281
|
});
|
|
4289
4282
|
}
|
|
4290
4283
|
const classes = /* @__PURE__ */ new Map();
|
|
4291
4284
|
const parentIdByInstanceId = /* @__PURE__ */ new Map();
|
|
4292
|
-
for (const
|
|
4293
|
-
const presetClass = presetClasses.get(
|
|
4285
|
+
for (const instance2 of instances.values()) {
|
|
4286
|
+
const presetClass = presetClasses.get(instance2.component);
|
|
4294
4287
|
if (presetClass) {
|
|
4295
|
-
classes.set(
|
|
4288
|
+
classes.set(instance2.id, [presetClass]);
|
|
4296
4289
|
}
|
|
4297
|
-
for (const child of
|
|
4290
|
+
for (const child of instance2.children) {
|
|
4298
4291
|
if (child.type === "id") {
|
|
4299
|
-
parentIdByInstanceId.set(child.value,
|
|
4292
|
+
parentIdByInstanceId.set(child.value, instance2.id);
|
|
4300
4293
|
}
|
|
4301
4294
|
}
|
|
4302
4295
|
}
|
|
4303
4296
|
const descendantSelectorByInstanceId = /* @__PURE__ */ new Map();
|
|
4304
|
-
for (const
|
|
4305
|
-
if (
|
|
4306
|
-
descendantSelectorByInstanceId.set(
|
|
4297
|
+
for (const prop2 of props.values()) {
|
|
4298
|
+
if (prop2.name === "selector" && prop2.type === "string") {
|
|
4299
|
+
descendantSelectorByInstanceId.set(prop2.instanceId, prop2.value);
|
|
4307
4300
|
}
|
|
4308
4301
|
}
|
|
4309
4302
|
const instanceByRule = /* @__PURE__ */ new Map();
|
|
4310
4303
|
for (const selection of styleSourceSelections.values()) {
|
|
4311
|
-
let { instanceId } = selection;
|
|
4304
|
+
let { instanceId: instanceId2 } = selection;
|
|
4312
4305
|
const { values } = selection;
|
|
4313
|
-
if (
|
|
4306
|
+
if (instanceId2 === ROOT_INSTANCE_ID) {
|
|
4314
4307
|
const rule2 = userSheet.addNestingRule(`:root`);
|
|
4315
4308
|
rule2.applyMixins(values);
|
|
4316
4309
|
continue;
|
|
4317
4310
|
}
|
|
4318
4311
|
let descendantSuffix = "";
|
|
4319
|
-
const
|
|
4320
|
-
if (
|
|
4312
|
+
const instance2 = instances.get(instanceId2);
|
|
4313
|
+
if (instance2 === void 0) {
|
|
4321
4314
|
continue;
|
|
4322
4315
|
}
|
|
4323
|
-
if (
|
|
4324
|
-
const parentId = parentIdByInstanceId.get(
|
|
4325
|
-
const descendantSelector = descendantSelectorByInstanceId.get(
|
|
4316
|
+
if (instance2.component === descendantComponent) {
|
|
4317
|
+
const parentId = parentIdByInstanceId.get(instanceId2);
|
|
4318
|
+
const descendantSelector = descendantSelectorByInstanceId.get(instanceId2);
|
|
4326
4319
|
if (parentId && descendantSelector) {
|
|
4327
4320
|
descendantSuffix = descendantSelector;
|
|
4328
|
-
|
|
4321
|
+
instanceId2 = parentId;
|
|
4329
4322
|
}
|
|
4330
4323
|
}
|
|
4331
|
-
const meta = componentMetas.get(
|
|
4332
|
-
const [_namespace, shortName] = parseComponentName(
|
|
4333
|
-
const baseName =
|
|
4334
|
-
const className = `w-${scope.getName(
|
|
4324
|
+
const meta = componentMetas.get(instance2.component);
|
|
4325
|
+
const [_namespace, shortName] = parseComponentName(instance2.component);
|
|
4326
|
+
const baseName = instance2.label ?? (meta == null ? void 0 : meta.label) ?? shortName;
|
|
4327
|
+
const className = `w-${scope.getName(instanceId2, baseName)}`;
|
|
4335
4328
|
if (atomic === false) {
|
|
4336
|
-
let classList = classes.get(
|
|
4329
|
+
let classList = classes.get(instanceId2);
|
|
4337
4330
|
if (classList === void 0) {
|
|
4338
4331
|
classList = [];
|
|
4339
|
-
classes.set(
|
|
4332
|
+
classes.set(instanceId2, classList);
|
|
4340
4333
|
}
|
|
4341
4334
|
classList.push(className);
|
|
4342
4335
|
}
|
|
4343
4336
|
const rule = userSheet.addNestingRule(`.${className}`, descendantSuffix);
|
|
4344
4337
|
rule.applyMixins(values);
|
|
4345
|
-
instanceByRule.set(rule,
|
|
4338
|
+
instanceByRule.set(rule, instanceId2);
|
|
4346
4339
|
}
|
|
4347
4340
|
const fontCss = fontSheet.cssText;
|
|
4348
4341
|
const presetCss = presetSheet.cssText.replaceAll(
|
|
@@ -4367,15 +4360,15 @@ ${userSheet.cssText}`,
|
|
|
4367
4360
|
classes
|
|
4368
4361
|
};
|
|
4369
4362
|
};
|
|
4370
|
-
const
|
|
4371
|
-
meta:
|
|
4372
|
-
compiler:
|
|
4373
|
-
redirects: z.array(
|
|
4363
|
+
const serializedPages = z.object({
|
|
4364
|
+
meta: projectMeta.optional(),
|
|
4365
|
+
compiler: compilerSettings.optional(),
|
|
4366
|
+
redirects: z.array(pageRedirect).optional(),
|
|
4374
4367
|
homePageId: z.string(),
|
|
4375
4368
|
rootFolderId: z.string(),
|
|
4376
|
-
pages: z.array(
|
|
4377
|
-
pageTemplates: z.union([z.array(
|
|
4378
|
-
folders: z.array(
|
|
4369
|
+
pages: z.array(page),
|
|
4370
|
+
pageTemplates: z.union([z.array(pageTemplate), z.record(pageTemplate)]).optional(),
|
|
4371
|
+
folders: z.array(folder)
|
|
4379
4372
|
});
|
|
4380
4373
|
const toMap = (items, normalizeItem = (item) => item) => {
|
|
4381
4374
|
if (items instanceof Map) {
|
|
@@ -4386,40 +4379,40 @@ const toMap = (items, normalizeItem = (item) => item) => {
|
|
|
4386
4379
|
const list = Array.isArray(items) ? items : Object.values(items);
|
|
4387
4380
|
return new Map(list.map((item) => [item.id, normalizeItem(item)]));
|
|
4388
4381
|
};
|
|
4389
|
-
const normalizePage = (
|
|
4390
|
-
...
|
|
4391
|
-
meta:
|
|
4382
|
+
const normalizePage = (page2) => ({
|
|
4383
|
+
...page2,
|
|
4384
|
+
meta: page2.meta ?? {}
|
|
4392
4385
|
});
|
|
4393
|
-
const isLegacyPages = (
|
|
4394
|
-
if (typeof
|
|
4386
|
+
const isLegacyPages = (pages2) => {
|
|
4387
|
+
if (typeof pages2 !== "object" || pages2 === null) {
|
|
4395
4388
|
return false;
|
|
4396
4389
|
}
|
|
4397
|
-
return "homePage" in
|
|
4390
|
+
return "homePage" in pages2 && Array.isArray(pages2.pages);
|
|
4398
4391
|
};
|
|
4399
|
-
const isSerializedPages = (
|
|
4400
|
-
if (typeof
|
|
4392
|
+
const isSerializedPages = (pages2) => {
|
|
4393
|
+
if (typeof pages2 !== "object" || pages2 === null) {
|
|
4401
4394
|
return false;
|
|
4402
4395
|
}
|
|
4403
|
-
const candidate =
|
|
4396
|
+
const candidate = pages2;
|
|
4404
4397
|
return typeof candidate.homePageId === "string" && typeof candidate.rootFolderId === "string" && candidate.pages !== void 0 && candidate.folders !== void 0;
|
|
4405
4398
|
};
|
|
4406
|
-
const removeOrphanFolderChildren = (
|
|
4399
|
+
const removeOrphanFolderChildren = (pages2, folders) => {
|
|
4407
4400
|
const nextFolders = /* @__PURE__ */ new Map();
|
|
4408
|
-
for (const [
|
|
4409
|
-
nextFolders.set(
|
|
4410
|
-
...
|
|
4411
|
-
children:
|
|
4412
|
-
(childId) =>
|
|
4401
|
+
for (const [folderId2, folder2] of folders) {
|
|
4402
|
+
nextFolders.set(folderId2, {
|
|
4403
|
+
...folder2,
|
|
4404
|
+
children: folder2.children.filter(
|
|
4405
|
+
(childId) => pages2.has(childId) || folders.has(childId)
|
|
4413
4406
|
)
|
|
4414
4407
|
});
|
|
4415
4408
|
}
|
|
4416
4409
|
return nextFolders;
|
|
4417
4410
|
};
|
|
4418
|
-
const migratePages = (
|
|
4411
|
+
const migratePages = (pagesData) => {
|
|
4419
4412
|
var _a;
|
|
4420
|
-
if (isSerializedPages(
|
|
4421
|
-
const currentPages =
|
|
4422
|
-
const result =
|
|
4413
|
+
if (isSerializedPages(pagesData) && pagesData.pages instanceof Map && pagesData.folders instanceof Map) {
|
|
4414
|
+
const currentPages = pagesData;
|
|
4415
|
+
const result = pages.safeParse(currentPages);
|
|
4423
4416
|
if (result.success && currentPages.pageTemplates !== void 0) {
|
|
4424
4417
|
return currentPages;
|
|
4425
4418
|
}
|
|
@@ -4432,39 +4425,39 @@ const migratePages = (pages) => {
|
|
|
4432
4425
|
)
|
|
4433
4426
|
};
|
|
4434
4427
|
}
|
|
4435
|
-
if (isSerializedPages(
|
|
4436
|
-
const nextPages2 = toMap(
|
|
4437
|
-
const nextFolders2 = toMap(
|
|
4428
|
+
if (isSerializedPages(pagesData)) {
|
|
4429
|
+
const nextPages2 = toMap(pagesData.pages, normalizePage);
|
|
4430
|
+
const nextFolders2 = toMap(pagesData.folders);
|
|
4438
4431
|
return {
|
|
4439
|
-
meta:
|
|
4440
|
-
compiler:
|
|
4441
|
-
redirects:
|
|
4442
|
-
homePageId:
|
|
4443
|
-
rootFolderId:
|
|
4432
|
+
meta: pagesData.meta,
|
|
4433
|
+
compiler: pagesData.compiler,
|
|
4434
|
+
redirects: pagesData.redirects,
|
|
4435
|
+
homePageId: pagesData.homePageId,
|
|
4436
|
+
rootFolderId: pagesData.rootFolderId,
|
|
4444
4437
|
pages: nextPages2,
|
|
4445
|
-
pageTemplates:
|
|
4438
|
+
pageTemplates: pagesData.pageTemplates === void 0 ? /* @__PURE__ */ new Map() : toMap(pagesData.pageTemplates),
|
|
4446
4439
|
folders: removeOrphanFolderChildren(nextPages2, nextFolders2)
|
|
4447
4440
|
};
|
|
4448
4441
|
}
|
|
4449
|
-
if (isLegacyPages(
|
|
4442
|
+
if (isLegacyPages(pagesData) === false) {
|
|
4450
4443
|
throw new Error("Pages data has unsupported shape.");
|
|
4451
4444
|
}
|
|
4452
4445
|
const homePage = {
|
|
4453
|
-
...normalizePage(
|
|
4446
|
+
...normalizePage(pagesData.homePage),
|
|
4454
4447
|
path: ""
|
|
4455
4448
|
};
|
|
4456
4449
|
const nextPages = /* @__PURE__ */ new Map([[homePage.id, homePage]]);
|
|
4457
|
-
for (const
|
|
4458
|
-
if (
|
|
4450
|
+
for (const page2 of pagesData.pages) {
|
|
4451
|
+
if (page2.id === homePage.id) {
|
|
4459
4452
|
continue;
|
|
4460
4453
|
}
|
|
4461
|
-
nextPages.set(
|
|
4454
|
+
nextPages.set(page2.id, normalizePage(page2));
|
|
4462
4455
|
}
|
|
4463
4456
|
const nextFolders = /* @__PURE__ */ new Map();
|
|
4464
|
-
for (const
|
|
4465
|
-
nextFolders.set(
|
|
4457
|
+
for (const folder2 of pagesData.folders ?? []) {
|
|
4458
|
+
nextFolders.set(folder2.id, { ...folder2, children: [...folder2.children] });
|
|
4466
4459
|
}
|
|
4467
|
-
const rootFolder = Array.from(nextFolders.values()).find(isRootFolder) ?? ((_a =
|
|
4460
|
+
const rootFolder = Array.from(nextFolders.values()).find(isRootFolder) ?? ((_a = pagesData.folders) == null ? void 0 : _a[0]) ?? {
|
|
4468
4461
|
id: ROOT_FOLDER_ID,
|
|
4469
4462
|
name: "Root",
|
|
4470
4463
|
slug: "",
|
|
@@ -4477,25 +4470,25 @@ const migratePages = (pages) => {
|
|
|
4477
4470
|
if (nextRootFolder === void 0) {
|
|
4478
4471
|
throw new Error("Pages must include a root folder.");
|
|
4479
4472
|
}
|
|
4480
|
-
for (const
|
|
4481
|
-
|
|
4473
|
+
for (const folder2 of nextFolders.values()) {
|
|
4474
|
+
folder2.children = folder2.children.filter(
|
|
4482
4475
|
(childId) => childId !== homePage.id && (nextPages.has(childId) || nextFolders.has(childId))
|
|
4483
4476
|
);
|
|
4484
4477
|
}
|
|
4485
4478
|
nextRootFolder.children.unshift(homePage.id);
|
|
4486
4479
|
const referencedIds = new Set(
|
|
4487
|
-
Array.from(nextFolders.values()).flatMap((
|
|
4480
|
+
Array.from(nextFolders.values()).flatMap((folder2) => folder2.children)
|
|
4488
4481
|
);
|
|
4489
|
-
for (const
|
|
4490
|
-
if (
|
|
4491
|
-
nextRootFolder.children.push(
|
|
4492
|
-
referencedIds.add(
|
|
4482
|
+
for (const page2 of pagesData.pages) {
|
|
4483
|
+
if (page2.id !== homePage.id && referencedIds.has(page2.id) === false) {
|
|
4484
|
+
nextRootFolder.children.push(page2.id);
|
|
4485
|
+
referencedIds.add(page2.id);
|
|
4493
4486
|
}
|
|
4494
4487
|
}
|
|
4495
4488
|
return {
|
|
4496
|
-
meta:
|
|
4497
|
-
compiler:
|
|
4498
|
-
redirects:
|
|
4489
|
+
meta: pagesData.meta,
|
|
4490
|
+
compiler: pagesData.compiler,
|
|
4491
|
+
redirects: pagesData.redirects,
|
|
4499
4492
|
homePageId: homePage.id,
|
|
4500
4493
|
rootFolderId: rootFolder.id,
|
|
4501
4494
|
pages: nextPages,
|
|
@@ -4503,26 +4496,26 @@ const migratePages = (pages) => {
|
|
|
4503
4496
|
folders: nextFolders
|
|
4504
4497
|
};
|
|
4505
4498
|
};
|
|
4506
|
-
const
|
|
4499
|
+
const entry = (value) => z.tuple([z.string(), value]);
|
|
4507
4500
|
const serializedBuildShape = {
|
|
4508
4501
|
id: z.string(),
|
|
4509
4502
|
projectId: z.string(),
|
|
4510
4503
|
version: z.number(),
|
|
4511
4504
|
createdAt: z.string(),
|
|
4512
4505
|
updatedAt: z.string(),
|
|
4513
|
-
pages:
|
|
4514
|
-
breakpoints: z.array(
|
|
4515
|
-
styles: z.array(
|
|
4516
|
-
styleSources: z.array(
|
|
4517
|
-
styleSourceSelections: z.array(
|
|
4518
|
-
props: z.array(
|
|
4519
|
-
instances: z.array(
|
|
4520
|
-
dataSources: z.array(
|
|
4521
|
-
resources: z.array(
|
|
4522
|
-
deployment:
|
|
4523
|
-
};
|
|
4524
|
-
const
|
|
4525
|
-
const
|
|
4506
|
+
pages: serializedPages,
|
|
4507
|
+
breakpoints: z.array(entry(breakpoint)),
|
|
4508
|
+
styles: z.array(entry(styleDecl)),
|
|
4509
|
+
styleSources: z.array(entry(styleSource)),
|
|
4510
|
+
styleSourceSelections: z.array(entry(styleSourceSelection)),
|
|
4511
|
+
props: z.array(entry(prop)),
|
|
4512
|
+
instances: z.array(entry(instance)),
|
|
4513
|
+
dataSources: z.array(entry(dataSource)),
|
|
4514
|
+
resources: z.array(entry(resource)),
|
|
4515
|
+
deployment: deployment.optional()
|
|
4516
|
+
};
|
|
4517
|
+
const serializedBuild = z.object(serializedBuildShape);
|
|
4518
|
+
const basicAuthInput = z.union([
|
|
4526
4519
|
z.object({
|
|
4527
4520
|
method: z.literal("basic"),
|
|
4528
4521
|
login: z.string(),
|
|
@@ -4534,11 +4527,10 @@ const basicAuthInputSchema = z.union([
|
|
|
4534
4527
|
password: z.string()
|
|
4535
4528
|
})
|
|
4536
4529
|
]);
|
|
4537
|
-
const
|
|
4530
|
+
const wsAuthConfig = z.object({
|
|
4538
4531
|
version: z.literal(1),
|
|
4539
|
-
routes: z.record(
|
|
4532
|
+
routes: z.record(basicAuthInput)
|
|
4540
4533
|
});
|
|
4541
|
-
const version$1 = "0.272.0";
|
|
4542
4534
|
const getFunctionContract = (value) => {
|
|
4543
4535
|
if (typeof value !== "function") {
|
|
4544
4536
|
return;
|
|
@@ -4712,8 +4704,7 @@ const stableStringify = (value) => {
|
|
|
4712
4704
|
}
|
|
4713
4705
|
return JSON.stringify(value);
|
|
4714
4706
|
};
|
|
4715
|
-
const createContractVersion = (schema,
|
|
4716
|
-
const bundlePackageVersion = version2.replace(/-webstudio-version$/, "");
|
|
4707
|
+
const createContractVersion = (schema, additionalSchemas = []) => {
|
|
4717
4708
|
let hash2 = 2166136261;
|
|
4718
4709
|
for (const char of stableStringify({
|
|
4719
4710
|
additionalSchemas: additionalSchemas.map(
|
|
@@ -4724,74 +4715,64 @@ const createContractVersion = (schema, version2, additionalSchemas = []) => {
|
|
|
4724
4715
|
hash2 ^= char.charCodeAt(0);
|
|
4725
4716
|
hash2 = Math.imul(hash2, 16777619);
|
|
4726
4717
|
}
|
|
4727
|
-
return `bundle-${
|
|
4728
|
-
};
|
|
4729
|
-
const
|
|
4730
|
-
const
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4718
|
+
return `bundle-${(hash2 >>> 0).toString(16).padStart(8, "0")}`;
|
|
4719
|
+
};
|
|
4720
|
+
const maxProjectBundleSize = 20 * 1024 * 1024;
|
|
4721
|
+
const stagedUploadPath = "/rest/staged-upload";
|
|
4722
|
+
const stagedUploadProjectIdHeader = "x-webstudio-project-id";
|
|
4723
|
+
const assetFileName = z.string().min(1).regex(/^(?!\.{1,2}$)[^/\\]+$/);
|
|
4724
|
+
const isAssetFileName = (value) => assetFileName.safeParse(value).success;
|
|
4725
|
+
const missingImportedAssetFilesPrefix = "Imported asset files are missing: ";
|
|
4726
|
+
const parseMissingImportedAssetFilesMessage = (error) => {
|
|
4727
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4728
|
+
const start = message.indexOf(missingImportedAssetFilesPrefix);
|
|
4729
|
+
if (start === -1) {
|
|
4730
|
+
return;
|
|
4736
4731
|
}
|
|
4737
|
-
const
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
if (isAssetFileDataString(value)) {
|
|
4743
|
-
return;
|
|
4744
|
-
}
|
|
4745
|
-
context.addIssue({
|
|
4746
|
-
code: z.ZodIssueCode.custom,
|
|
4747
|
-
message: "Invalid asset file data"
|
|
4748
|
-
});
|
|
4749
|
-
},
|
|
4750
|
-
{
|
|
4751
|
-
contract: {
|
|
4752
|
-
encoding: "base64",
|
|
4753
|
-
length: "multiple-of-4",
|
|
4754
|
-
padding: "only-last-two-characters",
|
|
4755
|
-
pattern: assetFileDataPattern
|
|
4732
|
+
const data = message.slice(start + missingImportedAssetFilesPrefix.length);
|
|
4733
|
+
try {
|
|
4734
|
+
const names = JSON.parse(data);
|
|
4735
|
+
if (Array.isArray(names) && names.every((name2) => typeof name2 === "string")) {
|
|
4736
|
+
return names;
|
|
4756
4737
|
}
|
|
4738
|
+
} catch {
|
|
4757
4739
|
}
|
|
4758
|
-
);
|
|
4759
|
-
|
|
4760
|
-
const
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
const projectBundleSchema = z.object({
|
|
4766
|
-
page: Page,
|
|
4767
|
-
pages: z.array(Page),
|
|
4768
|
-
build: SerializedBuildSchema,
|
|
4769
|
-
assets: z.array(Asset),
|
|
4740
|
+
return data.split(",").map((name2) => name2.trim()).filter((name2) => name2 !== "");
|
|
4741
|
+
};
|
|
4742
|
+
const projectBundle = z.object({
|
|
4743
|
+
page,
|
|
4744
|
+
pages: z.array(page),
|
|
4745
|
+
build: serializedBuild,
|
|
4746
|
+
assets: z.array(asset),
|
|
4770
4747
|
origin: z.string().optional()
|
|
4771
4748
|
});
|
|
4772
|
-
const
|
|
4749
|
+
const publishedProjectBundle = projectBundle.extend({
|
|
4773
4750
|
bundleVersion: z.union([z.string(), z.number()]).optional(),
|
|
4774
4751
|
user: z.object({ email: z.string().nullable() }).optional(),
|
|
4775
4752
|
projectDomain: z.string(),
|
|
4776
4753
|
projectTitle: z.string()
|
|
4777
4754
|
});
|
|
4778
4755
|
z.object({
|
|
4779
|
-
projectId: z.string(),
|
|
4780
|
-
data:
|
|
4781
|
-
|
|
4756
|
+
projectId: z.string().min(1),
|
|
4757
|
+
data: publishedProjectBundle.optional(),
|
|
4758
|
+
uploadId: z.string().min(1).optional(),
|
|
4782
4759
|
ignoreVersionCheck: z.boolean().optional()
|
|
4783
|
-
})
|
|
4784
|
-
|
|
4760
|
+
}).refine(
|
|
4761
|
+
({ data, uploadId }) => data === void 0 !== (uploadId === void 0),
|
|
4762
|
+
{
|
|
4763
|
+
message: "Provide either project bundle data or an upload id",
|
|
4764
|
+
path: ["data"]
|
|
4765
|
+
}
|
|
4766
|
+
);
|
|
4767
|
+
const importProjectBundleResult = z.object({
|
|
4785
4768
|
version: z.number()
|
|
4786
4769
|
});
|
|
4787
4770
|
z.object({
|
|
4788
|
-
projectId: z.string()
|
|
4771
|
+
projectId: z.string().min(1)
|
|
4789
4772
|
});
|
|
4790
|
-
const bundleVersion = createContractVersion(
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
[wsAuthConfigSchema]
|
|
4794
|
-
);
|
|
4773
|
+
const bundleVersion = createContractVersion(publishedProjectBundle, [
|
|
4774
|
+
wsAuthConfig
|
|
4775
|
+
]);
|
|
4795
4776
|
const getBundleVersion = (data) => {
|
|
4796
4777
|
if (typeof data !== "object" || data === null) {
|
|
4797
4778
|
return;
|
|
@@ -4803,6 +4784,48 @@ const getBundleVersionMismatchMessage = ({
|
|
|
4803
4784
|
ignoreVersionCheckHint,
|
|
4804
4785
|
receivedVersion
|
|
4805
4786
|
}) => `Project bundle format is incompatible. Expected version ${bundleVersion}, received ${receivedVersion ?? "missing"}. Sync with a compatible API/CLI version and retry, or ${ignoreVersionCheckHint}.`;
|
|
4787
|
+
const maxResponsePreviewLength = 500;
|
|
4788
|
+
const getResponsePreview = async (response) => {
|
|
4789
|
+
try {
|
|
4790
|
+
const text2 = await response.clone().text();
|
|
4791
|
+
return text2.replace(/\s+/g, " ").trim().slice(0, maxResponsePreviewLength);
|
|
4792
|
+
} catch {
|
|
4793
|
+
return "";
|
|
4794
|
+
}
|
|
4795
|
+
};
|
|
4796
|
+
const createApiResponseErrorMessage = async (request, response) => {
|
|
4797
|
+
const contentType = response.headers.get("content-type") ?? "unknown";
|
|
4798
|
+
const status = `${response.status} ${response.statusText}`.trim();
|
|
4799
|
+
const url = typeof request === "string" || request instanceof URL ? request.toString() : request.url;
|
|
4800
|
+
const preview = await getResponsePreview(response);
|
|
4801
|
+
const hint = response.status === 413 ? "The request may be too large for the API." : void 0;
|
|
4802
|
+
return [
|
|
4803
|
+
`API returned ${contentType} instead of JSON from ${url}.`,
|
|
4804
|
+
`HTTP status: ${status}.`,
|
|
4805
|
+
preview === "" ? void 0 : `Response preview: ${preview}`,
|
|
4806
|
+
hint
|
|
4807
|
+
].filter(Boolean).join("\n");
|
|
4808
|
+
};
|
|
4809
|
+
const fetchJsonResponse = async (request, init) => {
|
|
4810
|
+
const response = await fetch(request, init);
|
|
4811
|
+
const contentType = response.headers.get("content-type");
|
|
4812
|
+
if ((contentType == null ? void 0 : contentType.includes("json")) !== true) {
|
|
4813
|
+
throw new Error(await createApiResponseErrorMessage(request, response));
|
|
4814
|
+
}
|
|
4815
|
+
return response;
|
|
4816
|
+
};
|
|
4817
|
+
const createHeaders = (headers) => {
|
|
4818
|
+
return new Headers(createHeadersObject(headers));
|
|
4819
|
+
};
|
|
4820
|
+
const createHeadersObject = (headers) => {
|
|
4821
|
+
const result = {};
|
|
4822
|
+
for (const [name2, value] of Object.entries(headers)) {
|
|
4823
|
+
if (value !== void 0) {
|
|
4824
|
+
result[name2] = value;
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4827
|
+
return result;
|
|
4828
|
+
};
|
|
4806
4829
|
const createTrpcClient = (origin, headers) => {
|
|
4807
4830
|
const { sourceOrigin } = parseBuilderUrl(origin);
|
|
4808
4831
|
const url = new URL("/trpc", sourceOrigin);
|
|
@@ -4810,7 +4833,8 @@ const createTrpcClient = (origin, headers) => {
|
|
|
4810
4833
|
links: [
|
|
4811
4834
|
httpBatchLink({
|
|
4812
4835
|
url: url.href,
|
|
4813
|
-
headers
|
|
4836
|
+
headers,
|
|
4837
|
+
fetch: fetchJsonResponse
|
|
4814
4838
|
})
|
|
4815
4839
|
]
|
|
4816
4840
|
});
|
|
@@ -4819,6 +4843,50 @@ const createAuthTrpcClient = (params) => createTrpcClient(params.origin, {
|
|
|
4819
4843
|
...params.headers,
|
|
4820
4844
|
"x-auth-token": params.authToken
|
|
4821
4845
|
});
|
|
4846
|
+
const stagedUploadChunkSize = 3 * 1024 * 1024;
|
|
4847
|
+
const formatMebibytes = (bytes) => `${Math.round(bytes / 1024 / 1024)} MiB`;
|
|
4848
|
+
const getAssetUploadUrl = ({
|
|
4849
|
+
asset: asset2,
|
|
4850
|
+
origin,
|
|
4851
|
+
projectId
|
|
4852
|
+
}) => {
|
|
4853
|
+
const { sourceOrigin } = parseBuilderUrl(origin);
|
|
4854
|
+
const url = new URL(
|
|
4855
|
+
`/rest/assets/${encodeURIComponent(asset2.name)}`,
|
|
4856
|
+
sourceOrigin
|
|
4857
|
+
);
|
|
4858
|
+
url.searchParams.set("projectId", projectId);
|
|
4859
|
+
url.searchParams.set("type", asset2.type);
|
|
4860
|
+
if (asset2.type === "image") {
|
|
4861
|
+
url.searchParams.set("width", String(asset2.meta.width));
|
|
4862
|
+
url.searchParams.set("height", String(asset2.meta.height));
|
|
4863
|
+
url.searchParams.set("format", asset2.format);
|
|
4864
|
+
}
|
|
4865
|
+
return url;
|
|
4866
|
+
};
|
|
4867
|
+
const uploadAsset = async (params) => {
|
|
4868
|
+
const { authToken, headers, origin, projectId, upload } = params;
|
|
4869
|
+
const response = await fetchJsonResponse(
|
|
4870
|
+
getAssetUploadUrl({
|
|
4871
|
+
asset: upload.asset,
|
|
4872
|
+
origin,
|
|
4873
|
+
projectId
|
|
4874
|
+
}),
|
|
4875
|
+
{
|
|
4876
|
+
method: "POST",
|
|
4877
|
+
body: upload.data,
|
|
4878
|
+
headers: createHeaders({
|
|
4879
|
+
...headers,
|
|
4880
|
+
"x-auth-token": authToken,
|
|
4881
|
+
"content-type": "application/octet-stream"
|
|
4882
|
+
})
|
|
4883
|
+
}
|
|
4884
|
+
);
|
|
4885
|
+
const result = await response.json();
|
|
4886
|
+
if (typeof result === "object" && result !== null && "errors" in result && typeof result.errors === "string") {
|
|
4887
|
+
throw new Error(result.errors);
|
|
4888
|
+
}
|
|
4889
|
+
};
|
|
4822
4890
|
const loadProjectBundleByBuildId = async (params) => {
|
|
4823
4891
|
const headers = "serviceToken" in params ? { Authorization: params.serviceToken } : { "x-auth-token": params.authToken };
|
|
4824
4892
|
const data = await createTrpcClient(params.origin, {
|
|
@@ -4827,7 +4895,7 @@ const loadProjectBundleByBuildId = async (params) => {
|
|
|
4827
4895
|
}).query("build.loadProjectBundleByBuildId", {
|
|
4828
4896
|
buildId: params.buildId
|
|
4829
4897
|
});
|
|
4830
|
-
return
|
|
4898
|
+
return publishedProjectBundle.parse(data);
|
|
4831
4899
|
};
|
|
4832
4900
|
const loadProjectBundleByProjectId = async (params) => {
|
|
4833
4901
|
const data = await createAuthTrpcClient(params).query(
|
|
@@ -4836,7 +4904,7 @@ const loadProjectBundleByProjectId = async (params) => {
|
|
|
4836
4904
|
projectId: params.projectId
|
|
4837
4905
|
}
|
|
4838
4906
|
);
|
|
4839
|
-
return
|
|
4907
|
+
return publishedProjectBundle.parse(data);
|
|
4840
4908
|
};
|
|
4841
4909
|
const checkProjectBuildPermission = async (params) => {
|
|
4842
4910
|
await createAuthTrpcClient(params).query(
|
|
@@ -4846,17 +4914,59 @@ const checkProjectBuildPermission = async (params) => {
|
|
|
4846
4914
|
}
|
|
4847
4915
|
);
|
|
4848
4916
|
};
|
|
4917
|
+
const getUploadIdFromUrl = (uploadUrl) => {
|
|
4918
|
+
if (uploadUrl === null) {
|
|
4919
|
+
throw new Error("Project bundle upload did not return an upload URL.");
|
|
4920
|
+
}
|
|
4921
|
+
const { pathname } = new URL(uploadUrl);
|
|
4922
|
+
const uploadId = pathname.split("/").filter(Boolean).at(-1);
|
|
4923
|
+
if (uploadId === void 0) {
|
|
4924
|
+
throw new Error("Project bundle upload did not return an upload id.");
|
|
4925
|
+
}
|
|
4926
|
+
return decodeURIComponent(uploadId);
|
|
4927
|
+
};
|
|
4928
|
+
const uploadProjectBundleData = async (params) => {
|
|
4929
|
+
const { sourceOrigin } = parseBuilderUrl(params.origin);
|
|
4930
|
+
const endpoint = new URL(stagedUploadPath, sourceOrigin);
|
|
4931
|
+
const data = JSON.stringify(params.data);
|
|
4932
|
+
if (new TextEncoder().encode(data).byteLength > maxProjectBundleSize) {
|
|
4933
|
+
throw new Error(
|
|
4934
|
+
`Project bundle is too large to import. Maximum size is ${formatMebibytes(maxProjectBundleSize)}.`
|
|
4935
|
+
);
|
|
4936
|
+
}
|
|
4937
|
+
const file = typeof Buffer === "undefined" ? new Blob([data], { type: "application/json" }) : Buffer.from(data);
|
|
4938
|
+
return await new Promise((resolve2, reject) => {
|
|
4939
|
+
const upload = new Upload(file, {
|
|
4940
|
+
endpoint: endpoint.href,
|
|
4941
|
+
chunkSize: stagedUploadChunkSize,
|
|
4942
|
+
retryDelays: [0, 1e3],
|
|
4943
|
+
removeFingerprintOnSuccess: true,
|
|
4944
|
+
storeFingerprintForResuming: false,
|
|
4945
|
+
headers: createHeadersObject({
|
|
4946
|
+
...params.headers,
|
|
4947
|
+
"x-auth-token": params.authToken,
|
|
4948
|
+
[stagedUploadProjectIdHeader]: params.projectId
|
|
4949
|
+
}),
|
|
4950
|
+
metadata: {
|
|
4951
|
+
projectId: params.projectId
|
|
4952
|
+
},
|
|
4953
|
+
onError: reject,
|
|
4954
|
+
onSuccess: () => resolve2(getUploadIdFromUrl(upload.url))
|
|
4955
|
+
});
|
|
4956
|
+
upload.start();
|
|
4957
|
+
});
|
|
4958
|
+
};
|
|
4849
4959
|
const importProjectBundle = async (params) => {
|
|
4960
|
+
const uploadId = await uploadProjectBundleData(params);
|
|
4850
4961
|
const result = await createAuthTrpcClient(params).mutation(
|
|
4851
4962
|
"build.importProjectBundle",
|
|
4852
4963
|
{
|
|
4853
4964
|
projectId: params.projectId,
|
|
4854
|
-
|
|
4855
|
-
assetFiles: params.assetFiles,
|
|
4965
|
+
uploadId,
|
|
4856
4966
|
ignoreVersionCheck: params.ignoreVersionCheck
|
|
4857
4967
|
}
|
|
4858
4968
|
);
|
|
4859
|
-
return
|
|
4969
|
+
return importProjectBundleResult.parse(result);
|
|
4860
4970
|
};
|
|
4861
4971
|
const buildProjectDomainPrefix = "p-";
|
|
4862
4972
|
const parseBuilderUrl = (urlStr) => {
|
|
@@ -5005,9 +5115,9 @@ const isHandledCliError = (error) => error instanceof HandledCliError;
|
|
|
5005
5115
|
const apiCompatibilityErrorType = "webstudioApiCompatibilityError";
|
|
5006
5116
|
const apiClientHeader = "x-webstudio-client";
|
|
5007
5117
|
const apiClientVersionHeader = "x-webstudio-client-version";
|
|
5008
|
-
const
|
|
5118
|
+
const apiCompatibilityTarget = z.enum(["browser", "cli"]);
|
|
5009
5119
|
z.enum(["browser", "cli", "service"]);
|
|
5010
|
-
const
|
|
5120
|
+
const apiCompatibilityAction = z.discriminatedUnion("type", [
|
|
5011
5121
|
z.object({
|
|
5012
5122
|
type: z.literal("reloadBrowser")
|
|
5013
5123
|
}),
|
|
@@ -5015,17 +5125,17 @@ const ApiCompatibilityAction = z.discriminatedUnion("type", [
|
|
|
5015
5125
|
type: z.literal("updateCli")
|
|
5016
5126
|
})
|
|
5017
5127
|
]);
|
|
5018
|
-
const
|
|
5128
|
+
const apiCompatibilityPayload = z.object({
|
|
5019
5129
|
type: z.literal(apiCompatibilityErrorType),
|
|
5020
5130
|
reason: z.enum(["apiRouteNotFound", "apiProcedureNotFound"]),
|
|
5021
|
-
target:
|
|
5131
|
+
target: apiCompatibilityTarget,
|
|
5022
5132
|
message: z.string(),
|
|
5023
|
-
action:
|
|
5133
|
+
action: apiCompatibilityAction
|
|
5024
5134
|
});
|
|
5025
5135
|
const isObject = (value) => typeof value === "object" && value !== null;
|
|
5026
5136
|
const getApiCompatibilityPayload = (value) => {
|
|
5027
5137
|
const findPayload = (value2, seen) => {
|
|
5028
|
-
const parsed =
|
|
5138
|
+
const parsed = apiCompatibilityPayload.safeParse(value2);
|
|
5029
5139
|
if (parsed.success) {
|
|
5030
5140
|
return parsed.data;
|
|
5031
5141
|
}
|
|
@@ -5064,7 +5174,7 @@ const getApiCompatibilityPayload = (value) => {
|
|
|
5064
5174
|
return findPayload(value, /* @__PURE__ */ new WeakSet());
|
|
5065
5175
|
};
|
|
5066
5176
|
const name = "webstudio";
|
|
5067
|
-
const version = "0.
|
|
5177
|
+
const version = "0.273.0";
|
|
5068
5178
|
const description = "Webstudio CLI";
|
|
5069
5179
|
const author = "Webstudio <github@webstudio.is>";
|
|
5070
5180
|
const homepage = "https://webstudio.is";
|
|
@@ -5075,7 +5185,7 @@ const files = ["lib/*", "templates/*", "bin.js", "!*.{test,stories}.*"];
|
|
|
5075
5185
|
const scripts = { "typecheck": "tsgo --noEmit", "build": "rm -rf lib && vite build", "test": "vitest run" };
|
|
5076
5186
|
const license = "AGPL-3.0-or-later";
|
|
5077
5187
|
const engines = { "node": ">=22" };
|
|
5078
|
-
const dependencies = { "@clack/prompts": "^0.10.0", "@emotion/hash": "^0.9.2", "@trpc/client": "^10.45.2", "@webstudio-is/project-migrations": "workspace:*", "@webstudio-is/trpc-interface": "workspace:*", "acorn": "^8.14.1", "acorn-walk": "^8.3.4", "change-case": "^5.4.4", "deepmerge": "^4.3.1", "env-paths": "^3.0.0", "nanoid": "^5.1.5", "p-limit": "^6.2.0", "parse5": "7.3.0", "picocolors": "^1.1.1", "reserved-identifiers": "^1.0.0", "tinyexec": "^0.3.2", "warn-once": "^0.1.1", "yargs": "^17.7.2", "zod": "^3.24.2" };
|
|
5188
|
+
const dependencies = { "@clack/prompts": "^0.10.0", "@emotion/hash": "^0.9.2", "@trpc/client": "^10.45.2", "@webstudio-is/project-migrations": "workspace:*", "@webstudio-is/trpc-interface": "workspace:*", "acorn": "^8.14.1", "acorn-walk": "^8.3.4", "change-case": "^5.4.4", "deepmerge": "^4.3.1", "env-paths": "^3.0.0", "nanoid": "^5.1.5", "p-limit": "^6.2.0", "parse5": "7.3.0", "picocolors": "^1.1.1", "reserved-identifiers": "^1.0.0", "tinyexec": "^0.3.2", "tus-js-client": "^4.3.1", "warn-once": "^0.1.1", "yargs": "^17.7.2", "zod": "^3.24.2" };
|
|
5079
5189
|
const devDependencies = { "@cloudflare/vite-plugin": "^1.1.0", "@netlify/vite-plugin-react-router": "^1.0.1", "@react-router/dev": "^7.5.3", "@react-router/fs-routes": "^7.5.3", "@remix-run/cloudflare": "^2.16.5", "@remix-run/cloudflare-pages": "^2.16.5", "@remix-run/dev": "^2.16.5", "@remix-run/node": "^2.16.5", "@remix-run/react": "^2.16.5", "@remix-run/server-runtime": "^2.16.5", "@types/react": "^18.2.70", "@types/react-dom": "^18.2.25", "@types/yargs": "^17.0.33", "@vercel/react-router": "^1.1.0", "@vitejs/plugin-react": "^4.4.1", "@webstudio-is/css-engine": "workspace:*", "@webstudio-is/http-client": "workspace:*", "@webstudio-is/image": "workspace:*", "@webstudio-is/protocol": "workspace:*", "@webstudio-is/react-sdk": "workspace:*", "@webstudio-is/sdk": "workspace:*", "@webstudio-is/sdk-components-animation": "workspace:*", "@webstudio-is/sdk-components-react": "workspace:*", "@webstudio-is/sdk-components-react-radix": "workspace:*", "@webstudio-is/sdk-components-react-remix": "workspace:*", "@webstudio-is/sdk-components-react-router": "workspace:*", "@webstudio-is/tsconfig": "workspace:*", "@webstudio-is/wsauth": "workspace:*", "h3": "^1.15.1", "ipx": "^3.0.3", "isbot": "^5.1.25", "prettier": "3.5.3", "react": "18.3.0-canary-14898b6a9-20240318", "react-dom": "18.3.0-canary-14898b6a9-20240318", "react-router": "^7.5.3", "ts-expect": "^1.3.0", "vike": "^0.4.229", "vite": "^6.3.4", "vitest": "^3.1.2", "wrangler": "^3.63.2" };
|
|
5080
5190
|
const packageJson = {
|
|
5081
5191
|
name,
|
|
@@ -5127,12 +5237,12 @@ const runAssetTasks = async ({
|
|
|
5127
5237
|
}) => {
|
|
5128
5238
|
await Promise.all(
|
|
5129
5239
|
assets.map(
|
|
5130
|
-
(
|
|
5240
|
+
(asset2) => limit(async () => {
|
|
5131
5241
|
try {
|
|
5132
|
-
await task(
|
|
5242
|
+
await task(asset2);
|
|
5133
5243
|
} catch (error) {
|
|
5134
5244
|
if (continueOnError) {
|
|
5135
|
-
console.error(`Error ${operation} file ${
|
|
5245
|
+
console.error(`Error ${operation} file ${asset2.name}
|
|
5136
5246
|
${error}`);
|
|
5137
5247
|
return;
|
|
5138
5248
|
}
|
|
@@ -5142,6 +5252,14 @@ const runAssetTasks = async ({
|
|
|
5142
5252
|
)
|
|
5143
5253
|
);
|
|
5144
5254
|
};
|
|
5255
|
+
const formatError = (error) => error instanceof Error ? error.message : String(error);
|
|
5256
|
+
const retryOnce = async (task) => {
|
|
5257
|
+
try {
|
|
5258
|
+
await task();
|
|
5259
|
+
} catch {
|
|
5260
|
+
await task();
|
|
5261
|
+
}
|
|
5262
|
+
};
|
|
5145
5263
|
const getLocalAssetPath = (assetName, assetsDirectory = LOCAL_ASSETS_DIR) => {
|
|
5146
5264
|
if (isAssetFileName(assetName) === false) {
|
|
5147
5265
|
throw new Error(`Asset path escapes ${assetsDirectory}: ${assetName}`);
|
|
@@ -5179,13 +5297,13 @@ const downloadUrlToFile = async (url, filePath) => {
|
|
|
5179
5297
|
}
|
|
5180
5298
|
};
|
|
5181
5299
|
const downloadAssetFile = async ({
|
|
5182
|
-
asset,
|
|
5300
|
+
asset: asset2,
|
|
5183
5301
|
assetsDirectory = LOCAL_ASSETS_DIR,
|
|
5184
5302
|
origin
|
|
5185
5303
|
}) => {
|
|
5186
5304
|
await downloadUrlToFile(
|
|
5187
|
-
getAssetUrl(
|
|
5188
|
-
getLocalAssetPath(
|
|
5305
|
+
getAssetUrl(asset2, origin).href,
|
|
5306
|
+
getLocalAssetPath(asset2.name, assetsDirectory)
|
|
5189
5307
|
);
|
|
5190
5308
|
};
|
|
5191
5309
|
const downloadAssetFiles = async ({
|
|
@@ -5198,21 +5316,21 @@ const downloadAssetFiles = async ({
|
|
|
5198
5316
|
assets,
|
|
5199
5317
|
continueOnError,
|
|
5200
5318
|
operation: "downloading",
|
|
5201
|
-
task: (
|
|
5319
|
+
task: (asset2) => downloadAssetFile({ asset: asset2, assetsDirectory, origin })
|
|
5202
5320
|
});
|
|
5203
5321
|
};
|
|
5204
5322
|
const materializeAssetFile = async ({
|
|
5205
|
-
asset,
|
|
5323
|
+
asset: asset2,
|
|
5206
5324
|
origin,
|
|
5207
5325
|
sourceAssetsDirectory = LOCAL_ASSETS_DIR,
|
|
5208
5326
|
targetAssetsDirectory
|
|
5209
5327
|
}) => {
|
|
5210
|
-
const targetPath = getLocalAssetPath(
|
|
5328
|
+
const targetPath = getLocalAssetPath(asset2.name, targetAssetsDirectory);
|
|
5211
5329
|
if (await isFileExists(targetPath)) {
|
|
5212
5330
|
return;
|
|
5213
5331
|
}
|
|
5214
5332
|
await createFolderIfNotExists(dirname(targetPath));
|
|
5215
|
-
const sourcePath = getLocalAssetPath(
|
|
5333
|
+
const sourcePath = getLocalAssetPath(asset2.name, sourceAssetsDirectory);
|
|
5216
5334
|
if (await isFileExists(sourcePath)) {
|
|
5217
5335
|
try {
|
|
5218
5336
|
await copyFile(sourcePath, targetPath, constants$1.COPYFILE_FICLONE);
|
|
@@ -5222,7 +5340,7 @@ const materializeAssetFile = async ({
|
|
|
5222
5340
|
return;
|
|
5223
5341
|
}
|
|
5224
5342
|
await downloadAssetFile({
|
|
5225
|
-
asset,
|
|
5343
|
+
asset: asset2,
|
|
5226
5344
|
assetsDirectory: targetAssetsDirectory,
|
|
5227
5345
|
origin
|
|
5228
5346
|
});
|
|
@@ -5238,27 +5356,54 @@ const materializeAssetFiles = async ({
|
|
|
5238
5356
|
assets,
|
|
5239
5357
|
continueOnError,
|
|
5240
5358
|
operation: "materializing",
|
|
5241
|
-
task: (
|
|
5242
|
-
asset,
|
|
5359
|
+
task: (asset2) => materializeAssetFile({
|
|
5360
|
+
asset: asset2,
|
|
5243
5361
|
origin,
|
|
5244
5362
|
sourceAssetsDirectory,
|
|
5245
5363
|
targetAssetsDirectory
|
|
5246
5364
|
})
|
|
5247
5365
|
});
|
|
5248
5366
|
};
|
|
5249
|
-
const
|
|
5367
|
+
const uploadAssetFiles = async ({
|
|
5250
5368
|
assets,
|
|
5251
|
-
assetsDirectory = LOCAL_ASSETS_DIR
|
|
5369
|
+
assetsDirectory = LOCAL_ASSETS_DIR,
|
|
5370
|
+
authToken,
|
|
5371
|
+
headers,
|
|
5372
|
+
origin,
|
|
5373
|
+
projectId
|
|
5252
5374
|
}) => {
|
|
5253
|
-
const
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5375
|
+
const failedUploads = [];
|
|
5376
|
+
await runAssetTasks({
|
|
5377
|
+
assets,
|
|
5378
|
+
operation: "uploading",
|
|
5379
|
+
task: async (asset2) => {
|
|
5380
|
+
try {
|
|
5381
|
+
const file = await readFile(
|
|
5382
|
+
getLocalAssetPath(asset2.name, assetsDirectory)
|
|
5383
|
+
);
|
|
5384
|
+
const upload = async () => {
|
|
5385
|
+
await uploadAsset({
|
|
5386
|
+
authToken,
|
|
5387
|
+
headers,
|
|
5388
|
+
origin,
|
|
5389
|
+
projectId,
|
|
5390
|
+
upload: {
|
|
5391
|
+
asset: asset2,
|
|
5392
|
+
data: new Blob([new Uint8Array(file)])
|
|
5393
|
+
}
|
|
5394
|
+
});
|
|
5395
|
+
};
|
|
5396
|
+
await retryOnce(upload);
|
|
5397
|
+
} catch (error) {
|
|
5398
|
+
failedUploads.push({ asset: asset2, error });
|
|
5399
|
+
}
|
|
5400
|
+
}
|
|
5401
|
+
});
|
|
5402
|
+
if (failedUploads.length > 0) {
|
|
5403
|
+
throw new Error(
|
|
5404
|
+
`Failed to upload assets: ${failedUploads.map(({ asset: asset2, error }) => `${asset2.name}: ${formatError(error)}`).join("; ")}`
|
|
5258
5405
|
);
|
|
5259
|
-
files2.push({ name: asset.name, data });
|
|
5260
5406
|
}
|
|
5261
|
-
return files2;
|
|
5262
5407
|
};
|
|
5263
5408
|
const defaultDependencies$1 = {
|
|
5264
5409
|
createFileIfNotExists,
|
|
@@ -5271,14 +5416,14 @@ const defaultDependencies$1 = {
|
|
|
5271
5416
|
writeFile
|
|
5272
5417
|
};
|
|
5273
5418
|
const toLocalProjectBundle = (project) => {
|
|
5274
|
-
const normalizedProject =
|
|
5419
|
+
const normalizedProject = publishedProjectBundle.parse(project);
|
|
5275
5420
|
const {
|
|
5276
5421
|
assets,
|
|
5277
5422
|
build: build2,
|
|
5278
5423
|
bundleVersion: synchronizedBundleVersion,
|
|
5279
5424
|
origin,
|
|
5280
|
-
page,
|
|
5281
|
-
pages,
|
|
5425
|
+
page: page2,
|
|
5426
|
+
pages: pages2,
|
|
5282
5427
|
projectDomain,
|
|
5283
5428
|
projectTitle,
|
|
5284
5429
|
user
|
|
@@ -5286,8 +5431,8 @@ const toLocalProjectBundle = (project) => {
|
|
|
5286
5431
|
return {
|
|
5287
5432
|
bundleVersion: synchronizedBundleVersion ?? bundleVersion,
|
|
5288
5433
|
build: build2,
|
|
5289
|
-
page,
|
|
5290
|
-
pages,
|
|
5434
|
+
page: page2,
|
|
5435
|
+
pages: pages2,
|
|
5291
5436
|
assets,
|
|
5292
5437
|
user,
|
|
5293
5438
|
projectDomain,
|
|
@@ -5416,13 +5561,13 @@ const sync = async (options, dependencies2 = defaultDependencies$1) => {
|
|
|
5416
5561
|
syncing.stop("Project bundle synchronized successfully");
|
|
5417
5562
|
};
|
|
5418
5563
|
const LOCAL_AUTH_FILE = ".webstudio/auth.json";
|
|
5419
|
-
const createAuthConfigResources = (
|
|
5564
|
+
const createAuthConfigResources = (pages2) => {
|
|
5420
5565
|
var _a;
|
|
5421
5566
|
return createWsAuthResources({
|
|
5422
|
-
projectContent: (_a =
|
|
5423
|
-
pages: getAllPages(
|
|
5424
|
-
route: getPagePath(
|
|
5425
|
-
auth:
|
|
5567
|
+
projectContent: (_a = pages2.meta) == null ? void 0 : _a.auth,
|
|
5568
|
+
pages: getAllPages(pages2).filter((page2) => page2.meta.auth !== void 0).map((page2) => ({
|
|
5569
|
+
route: getPagePath(page2.id, pages2),
|
|
5570
|
+
auth: page2.meta.auth
|
|
5426
5571
|
}))
|
|
5427
5572
|
});
|
|
5428
5573
|
};
|
|
@@ -5466,7 +5611,7 @@ const isInteractiveTerminal = () => stdin.isTTY === true && stdout.isTTY === tru
|
|
|
5466
5611
|
const defaultDependencies = {
|
|
5467
5612
|
checkProjectBuildPermission,
|
|
5468
5613
|
importProjectBundle,
|
|
5469
|
-
|
|
5614
|
+
uploadAssetFiles,
|
|
5470
5615
|
loadJSONFile,
|
|
5471
5616
|
text,
|
|
5472
5617
|
isInteractive: isInteractiveTerminal(),
|
|
@@ -5478,12 +5623,16 @@ const missingProjectBundleMessage = "Project bundle is missing. Please run webst
|
|
|
5478
5623
|
const invalidProjectBundleMessage = "Project bundle is invalid. Please run webstudio sync before importing.";
|
|
5479
5624
|
const invalidAuthConfigMessage = "Project bundle auth config is invalid. Please run webstudio prebuild before importing.";
|
|
5480
5625
|
const invalidDestinationMessage = "Destination share link is invalid.";
|
|
5626
|
+
const maxMissingAssetImportRetries = 5;
|
|
5481
5627
|
const importOptions = (yargs) => yargs.option("to", {
|
|
5482
5628
|
type: "string",
|
|
5483
5629
|
describe: "Share link with build permissions to import synced data into"
|
|
5484
5630
|
}).option("ignore-version-check", {
|
|
5485
5631
|
type: "boolean",
|
|
5486
5632
|
describe: "Import data without a compatible data version; import may fail if source and target API data formats differ"
|
|
5633
|
+
}).option("skip-assets", {
|
|
5634
|
+
type: "boolean",
|
|
5635
|
+
describe: "Import project data without uploading or importing asset files; referenced assets may be missing in the target project"
|
|
5487
5636
|
}).check((options) => {
|
|
5488
5637
|
if (options.to === void 0 && isInteractiveTerminal() === false) {
|
|
5489
5638
|
return missingDestinationMessage;
|
|
@@ -5522,7 +5671,7 @@ const importProject = async (options, dependencies2 = defaultDependencies) => {
|
|
|
5522
5671
|
);
|
|
5523
5672
|
throw new HandledCliError();
|
|
5524
5673
|
}
|
|
5525
|
-
const parsedData =
|
|
5674
|
+
const parsedData = publishedProjectBundle.safeParse(data);
|
|
5526
5675
|
if (parsedData.success === false) {
|
|
5527
5676
|
importing.stop(
|
|
5528
5677
|
`${invalidProjectBundleMessage} Invalid fields: ${formatZodIssues(
|
|
@@ -5594,30 +5743,25 @@ const importProject = async (options, dependencies2 = defaultDependencies) => {
|
|
|
5594
5743
|
);
|
|
5595
5744
|
throw new HandledCliError();
|
|
5596
5745
|
}
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5746
|
+
if (options.skipAssets === true) {
|
|
5747
|
+
dependencies2.log.info("Skipped asset upload and asset rows");
|
|
5748
|
+
} else {
|
|
5749
|
+
importing.message(`Uploading ${importData.assets.length} assets`);
|
|
5750
|
+
try {
|
|
5751
|
+
await dependencies2.uploadAssetFiles({
|
|
5752
|
+
assets: importData.assets,
|
|
5753
|
+
...destinationRequest
|
|
5754
|
+
});
|
|
5755
|
+
} catch (error) {
|
|
5756
|
+
importing.stop(
|
|
5757
|
+
error instanceof Error ? `Unable to upload assets: ${error.message}` : "Unable to upload assets",
|
|
5758
|
+
2
|
|
5759
|
+
);
|
|
5760
|
+
throw new HandledCliError();
|
|
5761
|
+
}
|
|
5609
5762
|
}
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
);
|
|
5613
|
-
try {
|
|
5614
|
-
await dependencies2.importProjectBundle({
|
|
5615
|
-
...destinationRequest,
|
|
5616
|
-
data: importData,
|
|
5617
|
-
assetFiles,
|
|
5618
|
-
ignoreVersionCheck: options.ignoreVersionCheck
|
|
5619
|
-
});
|
|
5620
|
-
} catch (error) {
|
|
5763
|
+
const dataToImport = options.skipAssets === true ? { ...importData, assets: [] } : importData;
|
|
5764
|
+
const stopImportWithError = (error) => {
|
|
5621
5765
|
stopSpinnerWithError(
|
|
5622
5766
|
importing,
|
|
5623
5767
|
error,
|
|
@@ -5625,8 +5769,46 @@ const importProject = async (options, dependencies2 = defaultDependencies) => {
|
|
|
5625
5769
|
"import"
|
|
5626
5770
|
);
|
|
5627
5771
|
throw new HandledCliError();
|
|
5772
|
+
};
|
|
5773
|
+
for (let attempt = 0; attempt <= maxMissingAssetImportRetries; attempt += 1) {
|
|
5774
|
+
importing.message(
|
|
5775
|
+
`Waiting for API response while importing into ${destination.projectId}`
|
|
5776
|
+
);
|
|
5777
|
+
try {
|
|
5778
|
+
await dependencies2.importProjectBundle({
|
|
5779
|
+
...destinationRequest,
|
|
5780
|
+
data: dataToImport,
|
|
5781
|
+
ignoreVersionCheck: options.ignoreVersionCheck
|
|
5782
|
+
});
|
|
5783
|
+
importing.stop("Project imported successfully");
|
|
5784
|
+
return;
|
|
5785
|
+
} catch (error) {
|
|
5786
|
+
const missingAssetNames = options.skipAssets === true ? void 0 : parseMissingImportedAssetFilesMessage(error);
|
|
5787
|
+
const assetNames = missingAssetNames ?? [];
|
|
5788
|
+
if (assetNames.length === 0 || attempt === maxMissingAssetImportRetries) {
|
|
5789
|
+
stopImportWithError(error);
|
|
5790
|
+
}
|
|
5791
|
+
const missingAssets = importData.assets.filter(
|
|
5792
|
+
(asset2) => assetNames.includes(asset2.name)
|
|
5793
|
+
);
|
|
5794
|
+
if (missingAssets.length !== assetNames.length) {
|
|
5795
|
+
stopImportWithError(error);
|
|
5796
|
+
}
|
|
5797
|
+
importing.message(`Re-uploading ${missingAssets.length} missing assets`);
|
|
5798
|
+
try {
|
|
5799
|
+
await dependencies2.uploadAssetFiles({
|
|
5800
|
+
assets: missingAssets,
|
|
5801
|
+
...destinationRequest
|
|
5802
|
+
});
|
|
5803
|
+
} catch (uploadError) {
|
|
5804
|
+
importing.stop(
|
|
5805
|
+
uploadError instanceof Error ? `Unable to upload missing assets: ${uploadError.message}` : "Unable to upload missing assets",
|
|
5806
|
+
2
|
|
5807
|
+
);
|
|
5808
|
+
throw new HandledCliError();
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5628
5811
|
}
|
|
5629
|
-
importing.stop("Project bundle imported successfully");
|
|
5630
5812
|
};
|
|
5631
5813
|
const getRemixSegment = (segment) => {
|
|
5632
5814
|
var _a, _b;
|
|
@@ -5689,68 +5871,68 @@ const normalizeProps = ({
|
|
|
5689
5871
|
assetBaseUrl,
|
|
5690
5872
|
assets,
|
|
5691
5873
|
uploadingImageAssets,
|
|
5692
|
-
pages,
|
|
5874
|
+
pages: pages2,
|
|
5693
5875
|
source
|
|
5694
5876
|
}) => {
|
|
5695
5877
|
const newProps = [];
|
|
5696
|
-
for (const
|
|
5697
|
-
if (
|
|
5698
|
-
const
|
|
5699
|
-
const
|
|
5700
|
-
if (
|
|
5878
|
+
for (const prop2 of props) {
|
|
5879
|
+
if (prop2.type === "asset") {
|
|
5880
|
+
const assetId2 = prop2.value;
|
|
5881
|
+
const asset2 = assets.get(assetId2) ?? uploadingImageAssets.find((asset22) => asset22.id === assetId2);
|
|
5882
|
+
if (asset2 === void 0) {
|
|
5701
5883
|
continue;
|
|
5702
5884
|
}
|
|
5703
5885
|
const propBase = {
|
|
5704
|
-
id:
|
|
5705
|
-
name:
|
|
5706
|
-
required:
|
|
5707
|
-
instanceId:
|
|
5886
|
+
id: prop2.id,
|
|
5887
|
+
name: prop2.name,
|
|
5888
|
+
required: prop2.required,
|
|
5889
|
+
instanceId: prop2.instanceId
|
|
5708
5890
|
};
|
|
5709
|
-
if (
|
|
5891
|
+
if (prop2.name === "width" && asset2.type === "image") {
|
|
5710
5892
|
newProps.push({
|
|
5711
5893
|
...propBase,
|
|
5712
5894
|
type: "number",
|
|
5713
|
-
value:
|
|
5895
|
+
value: asset2.meta.width
|
|
5714
5896
|
});
|
|
5715
5897
|
continue;
|
|
5716
5898
|
}
|
|
5717
|
-
if (
|
|
5899
|
+
if (prop2.name === "height" && asset2.type === "image") {
|
|
5718
5900
|
newProps.push({
|
|
5719
5901
|
...propBase,
|
|
5720
5902
|
type: "number",
|
|
5721
|
-
value:
|
|
5903
|
+
value: asset2.meta.height
|
|
5722
5904
|
});
|
|
5723
5905
|
continue;
|
|
5724
5906
|
}
|
|
5725
|
-
if (
|
|
5907
|
+
if (prop2.name === "alt" && asset2.type === "image") {
|
|
5726
5908
|
newProps.push({
|
|
5727
5909
|
...propBase,
|
|
5728
5910
|
type: "string",
|
|
5729
|
-
value:
|
|
5911
|
+
value: asset2.description ?? ""
|
|
5730
5912
|
});
|
|
5731
5913
|
continue;
|
|
5732
5914
|
}
|
|
5733
5915
|
newProps.push({
|
|
5734
5916
|
...propBase,
|
|
5735
5917
|
type: "string",
|
|
5736
|
-
value: `${assetBaseUrl}${
|
|
5918
|
+
value: `${assetBaseUrl}${asset2.name}`
|
|
5737
5919
|
});
|
|
5738
5920
|
continue;
|
|
5739
5921
|
}
|
|
5740
|
-
if (
|
|
5922
|
+
if (prop2.type === "page") {
|
|
5741
5923
|
let idProp;
|
|
5742
|
-
const
|
|
5743
|
-
const
|
|
5744
|
-
if (
|
|
5924
|
+
const pageId2 = typeof prop2.value === "string" ? prop2.value : prop2.value.pageId;
|
|
5925
|
+
const page2 = findPageByIdOrPath(pageId2, pages2);
|
|
5926
|
+
if (page2 === void 0) {
|
|
5745
5927
|
continue;
|
|
5746
5928
|
}
|
|
5747
|
-
if (typeof
|
|
5748
|
-
const { instanceId } =
|
|
5929
|
+
if (typeof prop2.value !== "string") {
|
|
5930
|
+
const { instanceId: instanceId2 } = prop2.value;
|
|
5749
5931
|
idProp = props.find(
|
|
5750
|
-
(
|
|
5932
|
+
(prop22) => prop22.instanceId === instanceId2 && prop22.name === "id"
|
|
5751
5933
|
);
|
|
5752
5934
|
}
|
|
5753
|
-
const path = getPagePath(
|
|
5935
|
+
const path = getPagePath(page2.id, pages2);
|
|
5754
5936
|
const url = new URL(path, "https://any-valid.url");
|
|
5755
5937
|
let value = url.pathname;
|
|
5756
5938
|
if ((idProp == null ? void 0 : idProp.type) === "string") {
|
|
@@ -5759,16 +5941,16 @@ const normalizeProps = ({
|
|
|
5759
5941
|
value = `${url.pathname}${url.hash}`;
|
|
5760
5942
|
}
|
|
5761
5943
|
newProps.push({
|
|
5762
|
-
id:
|
|
5763
|
-
name:
|
|
5764
|
-
required:
|
|
5765
|
-
instanceId:
|
|
5944
|
+
id: prop2.id,
|
|
5945
|
+
name: prop2.name,
|
|
5946
|
+
required: prop2.required,
|
|
5947
|
+
instanceId: prop2.instanceId,
|
|
5766
5948
|
type: "string",
|
|
5767
5949
|
value
|
|
5768
5950
|
});
|
|
5769
5951
|
continue;
|
|
5770
5952
|
}
|
|
5771
|
-
newProps.push(
|
|
5953
|
+
newProps.push(prop2);
|
|
5772
5954
|
}
|
|
5773
5955
|
return newProps;
|
|
5774
5956
|
};
|
|
@@ -5917,14 +6099,14 @@ const standardAttributesToReactProps = {
|
|
|
5917
6099
|
};
|
|
5918
6100
|
const generateAction = ({
|
|
5919
6101
|
scope,
|
|
5920
|
-
prop,
|
|
6102
|
+
prop: prop2,
|
|
5921
6103
|
dataSources,
|
|
5922
6104
|
usedDataSources
|
|
5923
6105
|
}) => {
|
|
5924
6106
|
const setters = /* @__PURE__ */ new Set();
|
|
5925
6107
|
let args = [];
|
|
5926
6108
|
let assignersCode = "";
|
|
5927
|
-
for (const value of
|
|
6109
|
+
for (const value of prop2.value) {
|
|
5928
6110
|
args = value.args;
|
|
5929
6111
|
assignersCode += transpileExpression({
|
|
5930
6112
|
expression: value.code,
|
|
@@ -5950,11 +6132,11 @@ const generateAction = ({
|
|
|
5950
6132
|
`;
|
|
5951
6133
|
}
|
|
5952
6134
|
let settersCode = "";
|
|
5953
|
-
for (const
|
|
5954
|
-
const valueName = scope.getName(
|
|
6135
|
+
for (const dataSource2 of setters) {
|
|
6136
|
+
const valueName = scope.getName(dataSource2.id, dataSource2.name);
|
|
5955
6137
|
const setterName = scope.getName(
|
|
5956
|
-
`set$${
|
|
5957
|
-
`set$${
|
|
6138
|
+
`set$${dataSource2.id}`,
|
|
6139
|
+
`set$${dataSource2.name}`
|
|
5958
6140
|
);
|
|
5959
6141
|
settersCode += `${setterName}(${valueName})
|
|
5960
6142
|
`;
|
|
@@ -5970,37 +6152,37 @@ const generateAction = ({
|
|
|
5970
6152
|
};
|
|
5971
6153
|
const generatePropValue = ({
|
|
5972
6154
|
scope,
|
|
5973
|
-
prop,
|
|
6155
|
+
prop: prop2,
|
|
5974
6156
|
dataSources,
|
|
5975
6157
|
usedDataSources
|
|
5976
6158
|
}) => {
|
|
5977
|
-
if (
|
|
6159
|
+
if (prop2.type === "asset" || prop2.type === "page") {
|
|
5978
6160
|
return;
|
|
5979
6161
|
}
|
|
5980
|
-
if (
|
|
5981
|
-
return JSON.stringify(
|
|
6162
|
+
if (prop2.type === "string" || prop2.type === "number" || prop2.type === "boolean" || prop2.type === "string[]" || prop2.type === "json" || prop2.type === "animationAction") {
|
|
6163
|
+
return JSON.stringify(prop2.value);
|
|
5982
6164
|
}
|
|
5983
|
-
if (
|
|
5984
|
-
const
|
|
5985
|
-
if (
|
|
6165
|
+
if (prop2.type === "parameter") {
|
|
6166
|
+
const dataSource2 = dataSources.get(prop2.value);
|
|
6167
|
+
if (dataSource2 === void 0) {
|
|
5986
6168
|
return;
|
|
5987
6169
|
}
|
|
5988
|
-
usedDataSources.set(
|
|
5989
|
-
return scope.getName(
|
|
6170
|
+
usedDataSources.set(dataSource2.id, dataSource2);
|
|
6171
|
+
return scope.getName(dataSource2.id, dataSource2.name);
|
|
5990
6172
|
}
|
|
5991
|
-
if (
|
|
6173
|
+
if (prop2.type === "expression") {
|
|
5992
6174
|
return generateExpression({
|
|
5993
|
-
expression:
|
|
6175
|
+
expression: prop2.value,
|
|
5994
6176
|
dataSources,
|
|
5995
6177
|
usedDataSources,
|
|
5996
6178
|
scope
|
|
5997
6179
|
});
|
|
5998
6180
|
}
|
|
5999
|
-
if (
|
|
6000
|
-
return generateAction({ scope, prop, dataSources, usedDataSources });
|
|
6181
|
+
if (prop2.type === "action") {
|
|
6182
|
+
return generateAction({ scope, prop: prop2, dataSources, usedDataSources });
|
|
6001
6183
|
}
|
|
6002
|
-
if (
|
|
6003
|
-
return JSON.stringify(scope.getName(
|
|
6184
|
+
if (prop2.type === "resource") {
|
|
6185
|
+
return JSON.stringify(scope.getName(prop2.value, prop2.name));
|
|
6004
6186
|
}
|
|
6005
6187
|
};
|
|
6006
6188
|
const generateJsxElement = ({
|
|
@@ -6008,7 +6190,7 @@ const generateJsxElement = ({
|
|
|
6008
6190
|
scope,
|
|
6009
6191
|
metas,
|
|
6010
6192
|
tagsOverrides,
|
|
6011
|
-
instance,
|
|
6193
|
+
instance: instance2,
|
|
6012
6194
|
props,
|
|
6013
6195
|
dataSources,
|
|
6014
6196
|
usedDataSources,
|
|
@@ -6017,44 +6199,44 @@ const generateJsxElement = ({
|
|
|
6017
6199
|
classesMap
|
|
6018
6200
|
}) => {
|
|
6019
6201
|
var _a;
|
|
6020
|
-
if (
|
|
6202
|
+
if (instance2.component === descendantComponent) {
|
|
6021
6203
|
return "";
|
|
6022
6204
|
}
|
|
6023
|
-
const meta = metas.get(
|
|
6205
|
+
const meta = metas.get(instance2.component);
|
|
6024
6206
|
const hasTags = Object.keys((meta == null ? void 0 : meta.presetStyle) ?? {}).length > 0;
|
|
6025
6207
|
let generatedProps = "";
|
|
6026
|
-
const index = indexesWithinAncestors.get(
|
|
6208
|
+
const index = indexesWithinAncestors.get(instance2.id);
|
|
6027
6209
|
if (index !== void 0) {
|
|
6028
6210
|
generatedProps += `
|
|
6029
6211
|
${indexProperty}="${index}"`;
|
|
6030
6212
|
}
|
|
6031
|
-
if (
|
|
6213
|
+
if (instance2.tag !== void 0 && instance2.component !== elementComponent) {
|
|
6032
6214
|
generatedProps += `
|
|
6033
|
-
${tagProperty}=${JSON.stringify(
|
|
6215
|
+
${tagProperty}=${JSON.stringify(instance2.tag)}`;
|
|
6034
6216
|
}
|
|
6035
6217
|
let conditionValue;
|
|
6036
6218
|
let collectionDataValue;
|
|
6037
6219
|
let collectionItemValue;
|
|
6038
6220
|
let collectionItemKeyValue;
|
|
6039
6221
|
let classNameValue;
|
|
6040
|
-
for (const
|
|
6041
|
-
if (
|
|
6222
|
+
for (const prop2 of props.values()) {
|
|
6223
|
+
if (prop2.instanceId !== instance2.id) {
|
|
6042
6224
|
continue;
|
|
6043
6225
|
}
|
|
6044
6226
|
const propValue = generatePropValue({
|
|
6045
6227
|
scope,
|
|
6046
|
-
prop,
|
|
6228
|
+
prop: prop2,
|
|
6047
6229
|
dataSources,
|
|
6048
6230
|
usedDataSources
|
|
6049
6231
|
});
|
|
6050
|
-
if (isAttributeNameSafe(
|
|
6232
|
+
if (isAttributeNameSafe(prop2.name) === false) {
|
|
6051
6233
|
continue;
|
|
6052
6234
|
}
|
|
6053
|
-
let name2 =
|
|
6054
|
-
if (hasTags && !((_a = meta == null ? void 0 : meta.props) == null ? void 0 : _a[
|
|
6055
|
-
name2 = standardAttributesToReactProps[
|
|
6235
|
+
let name2 = prop2.name;
|
|
6236
|
+
if (hasTags && !((_a = meta == null ? void 0 : meta.props) == null ? void 0 : _a[prop2.name])) {
|
|
6237
|
+
name2 = standardAttributesToReactProps[prop2.name] ?? prop2.name;
|
|
6056
6238
|
}
|
|
6057
|
-
if (
|
|
6239
|
+
if (prop2.name === showAttribute) {
|
|
6058
6240
|
if (propValue === "true") {
|
|
6059
6241
|
continue;
|
|
6060
6242
|
}
|
|
@@ -6064,14 +6246,14 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
|
|
|
6064
6246
|
conditionValue = propValue;
|
|
6065
6247
|
continue;
|
|
6066
6248
|
}
|
|
6067
|
-
if (
|
|
6068
|
-
if (
|
|
6249
|
+
if (instance2.component === collectionComponent) {
|
|
6250
|
+
if (prop2.name === "data") {
|
|
6069
6251
|
collectionDataValue = propValue;
|
|
6070
6252
|
}
|
|
6071
|
-
if (
|
|
6253
|
+
if (prop2.name === "item") {
|
|
6072
6254
|
collectionItemValue = propValue;
|
|
6073
6255
|
}
|
|
6074
|
-
if (
|
|
6256
|
+
if (prop2.name === "itemKey") {
|
|
6075
6257
|
collectionItemKeyValue = propValue;
|
|
6076
6258
|
}
|
|
6077
6259
|
continue;
|
|
@@ -6085,7 +6267,7 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
|
|
|
6085
6267
|
${name2}={${propValue}}`;
|
|
6086
6268
|
}
|
|
6087
6269
|
}
|
|
6088
|
-
const classMapArray = classesMap == null ? void 0 : classesMap.get(
|
|
6270
|
+
const classMapArray = classesMap == null ? void 0 : classesMap.get(instance2.id);
|
|
6089
6271
|
if (classMapArray || classNameValue) {
|
|
6090
6272
|
let classNameTemplate = classMapArray ? classMapArray.join(" ") : "";
|
|
6091
6273
|
if (classNameValue) {
|
|
@@ -6097,14 +6279,14 @@ ${name2}={${propValue}}`;
|
|
|
6097
6279
|
generatedProps += "\nclassName={`" + classNameTemplate + "`}";
|
|
6098
6280
|
}
|
|
6099
6281
|
let generatedElement = "";
|
|
6100
|
-
if (
|
|
6282
|
+
if (instance2.component === blockTemplateComponent) {
|
|
6101
6283
|
return "";
|
|
6102
6284
|
}
|
|
6103
|
-
if (
|
|
6285
|
+
if (instance2.component === collectionComponent) {
|
|
6104
6286
|
if (collectionDataValue === void 0 || collectionItemValue === void 0) {
|
|
6105
6287
|
return "";
|
|
6106
6288
|
}
|
|
6107
|
-
const indexVariable = scope.getName(`${
|
|
6289
|
+
const indexVariable = scope.getName(`${instance2.id}-index`, "index");
|
|
6108
6290
|
const keyVariable = collectionItemKeyValue ?? indexVariable;
|
|
6109
6291
|
generatedElement += `{${generateCollectionIterationCode({
|
|
6110
6292
|
dataExpression: collectionDataValue,
|
|
@@ -6123,22 +6305,22 @@ ${name2}={${propValue}}`;
|
|
|
6123
6305
|
`;
|
|
6124
6306
|
generatedElement += `}
|
|
6125
6307
|
`;
|
|
6126
|
-
} else if (
|
|
6308
|
+
} else if (instance2.component === blockComponent) {
|
|
6127
6309
|
generatedElement += children;
|
|
6128
6310
|
} else {
|
|
6129
6311
|
let componentVariable;
|
|
6130
|
-
if (
|
|
6131
|
-
componentVariable =
|
|
6312
|
+
if (instance2.component === elementComponent) {
|
|
6313
|
+
componentVariable = instance2.tag ?? "div";
|
|
6132
6314
|
const componentDescriptor = tagsOverrides == null ? void 0 : tagsOverrides[componentVariable];
|
|
6133
6315
|
if (componentDescriptor !== void 0) {
|
|
6134
6316
|
const [_importSource, importSpecifier] = componentDescriptor.split(":");
|
|
6135
6317
|
componentVariable = scope.getName(componentDescriptor, importSpecifier);
|
|
6136
6318
|
}
|
|
6137
6319
|
} else {
|
|
6138
|
-
const [_namespace, shortName] = parseComponentName(
|
|
6139
|
-
componentVariable = scope.getName(
|
|
6320
|
+
const [_namespace, shortName] = parseComponentName(instance2.component);
|
|
6321
|
+
componentVariable = scope.getName(instance2.component, shortName);
|
|
6140
6322
|
}
|
|
6141
|
-
if (
|
|
6323
|
+
if (instance2.children.length === 0) {
|
|
6142
6324
|
generatedElement += `<${componentVariable}${generatedProps} />
|
|
6143
6325
|
`;
|
|
6144
6326
|
} else {
|
|
@@ -6159,7 +6341,7 @@ ${name2}={${propValue}}`;
|
|
|
6159
6341
|
}
|
|
6160
6342
|
conditionalElement += `${before}(${conditionValue}) &&
|
|
6161
6343
|
`;
|
|
6162
|
-
if (
|
|
6344
|
+
if (instance2.component === collectionComponent) {
|
|
6163
6345
|
conditionalElement += "<>\n";
|
|
6164
6346
|
conditionalElement += generatedElement;
|
|
6165
6347
|
conditionalElement += "</>\n";
|
|
@@ -6208,9 +6390,9 @@ const generateJsxChildren = ({
|
|
|
6208
6390
|
continue;
|
|
6209
6391
|
}
|
|
6210
6392
|
if (child.type === "id") {
|
|
6211
|
-
const
|
|
6212
|
-
const
|
|
6213
|
-
if (
|
|
6393
|
+
const instanceId2 = child.value;
|
|
6394
|
+
const instance2 = instances.get(instanceId2);
|
|
6395
|
+
if (instance2 === void 0) {
|
|
6214
6396
|
continue;
|
|
6215
6397
|
}
|
|
6216
6398
|
generatedChildren += generateJsxElement({
|
|
@@ -6218,7 +6400,7 @@ const generateJsxChildren = ({
|
|
|
6218
6400
|
scope,
|
|
6219
6401
|
metas,
|
|
6220
6402
|
tagsOverrides,
|
|
6221
|
-
instance,
|
|
6403
|
+
instance: instance2,
|
|
6222
6404
|
props,
|
|
6223
6405
|
dataSources,
|
|
6224
6406
|
usedDataSources,
|
|
@@ -6229,7 +6411,7 @@ const generateJsxChildren = ({
|
|
|
6229
6411
|
scope,
|
|
6230
6412
|
metas,
|
|
6231
6413
|
tagsOverrides,
|
|
6232
|
-
children:
|
|
6414
|
+
children: instance2.children,
|
|
6233
6415
|
instances,
|
|
6234
6416
|
props,
|
|
6235
6417
|
dataSources,
|
|
@@ -6255,19 +6437,19 @@ const generateWebstudioComponent = ({
|
|
|
6255
6437
|
tagsOverrides,
|
|
6256
6438
|
classesMap
|
|
6257
6439
|
}) => {
|
|
6258
|
-
const
|
|
6440
|
+
const instance2 = instances.get(rootInstanceId);
|
|
6259
6441
|
const indexesWithinAncestors = getIndexesWithinAncestors(metas, instances, [
|
|
6260
6442
|
rootInstanceId
|
|
6261
6443
|
]);
|
|
6262
6444
|
const usedDataSources = /* @__PURE__ */ new Map();
|
|
6263
6445
|
let generatedJsx = "<></>\n";
|
|
6264
|
-
if (
|
|
6446
|
+
if (instance2) {
|
|
6265
6447
|
generatedJsx = generateJsxElement({
|
|
6266
6448
|
context: "expression",
|
|
6267
6449
|
scope,
|
|
6268
6450
|
metas,
|
|
6269
6451
|
tagsOverrides,
|
|
6270
|
-
instance,
|
|
6452
|
+
instance: instance2,
|
|
6271
6453
|
props,
|
|
6272
6454
|
dataSources,
|
|
6273
6455
|
usedDataSources,
|
|
@@ -6277,7 +6459,7 @@ const generateWebstudioComponent = ({
|
|
|
6277
6459
|
scope,
|
|
6278
6460
|
metas,
|
|
6279
6461
|
tagsOverrides,
|
|
6280
|
-
children:
|
|
6462
|
+
children: instance2.children,
|
|
6281
6463
|
instances,
|
|
6282
6464
|
props,
|
|
6283
6465
|
dataSources,
|
|
@@ -6299,32 +6481,32 @@ const generateWebstudioComponent = ({
|
|
|
6299
6481
|
}
|
|
6300
6482
|
generatedProps = `_props: { ${generatedPropsType}}`;
|
|
6301
6483
|
for (const parameter of parameters) {
|
|
6302
|
-
const
|
|
6303
|
-
if (
|
|
6304
|
-
const valueName = scope.getName(
|
|
6484
|
+
const dataSource2 = usedDataSources.get(parameter.value);
|
|
6485
|
+
if (dataSource2) {
|
|
6486
|
+
const valueName = scope.getName(dataSource2.id, dataSource2.name);
|
|
6305
6487
|
generatedParameters += `const ${valueName} = _props.${parameter.name};
|
|
6306
6488
|
`;
|
|
6307
6489
|
}
|
|
6308
6490
|
}
|
|
6309
6491
|
}
|
|
6310
6492
|
let generatedDataSources = "";
|
|
6311
|
-
for (const
|
|
6312
|
-
if (
|
|
6313
|
-
const valueName = scope.getName(
|
|
6493
|
+
for (const dataSource2 of usedDataSources.values()) {
|
|
6494
|
+
if (dataSource2.type === "variable") {
|
|
6495
|
+
const valueName = scope.getName(dataSource2.id, dataSource2.name);
|
|
6314
6496
|
const setterName = scope.getName(
|
|
6315
|
-
`set$${
|
|
6316
|
-
`set$${
|
|
6497
|
+
`set$${dataSource2.id}`,
|
|
6498
|
+
`set$${dataSource2.name}`
|
|
6317
6499
|
);
|
|
6318
|
-
const initialValue =
|
|
6500
|
+
const initialValue = dataSource2.value.value;
|
|
6319
6501
|
const initialValueString = JSON.stringify(initialValue);
|
|
6320
6502
|
generatedDataSources += `let [${valueName}, ${setterName}] = useVariableState<any>(${initialValueString})
|
|
6321
6503
|
`;
|
|
6322
6504
|
}
|
|
6323
|
-
if (
|
|
6324
|
-
const valueName = scope.getName(
|
|
6505
|
+
if (dataSource2.type === "resource") {
|
|
6506
|
+
const valueName = scope.getName(dataSource2.id, dataSource2.name);
|
|
6325
6507
|
const resourceName = scope.getName(
|
|
6326
|
-
|
|
6327
|
-
|
|
6508
|
+
dataSource2.resourceId,
|
|
6509
|
+
dataSource2.name
|
|
6328
6510
|
);
|
|
6329
6511
|
const resourceNameString = JSON.stringify(resourceName);
|
|
6330
6512
|
generatedDataSources += `let ${valueName} = useResource(${resourceNameString})
|
|
@@ -6452,9 +6634,9 @@ const htmlToJsx = (html2) => {
|
|
|
6452
6634
|
}
|
|
6453
6635
|
return result;
|
|
6454
6636
|
};
|
|
6455
|
-
const createRemixFramework = async () => (await import("./framework-remix-
|
|
6456
|
-
const createReactRouterFramework = async () => (await import("./framework-react-router-
|
|
6457
|
-
const createVikeSsgFramework = async () => (await import("./framework-vike-ssg-
|
|
6637
|
+
const createRemixFramework = async () => (await import("./framework-remix-DWec4bEd.js")).createFramework();
|
|
6638
|
+
const createReactRouterFramework = async () => (await import("./framework-react-router-UzYgymrh.js")).createFramework();
|
|
6639
|
+
const createVikeSsgFramework = async () => (await import("./framework-vike-ssg-yIhvBUQn.js")).createFramework();
|
|
6458
6640
|
const mergeJsonInto = async (sourcePath, destinationPath) => {
|
|
6459
6641
|
const sourceJson = await readFile(sourcePath, "utf8");
|
|
6460
6642
|
const destinationJson = await readFile(destinationPath, "utf8").catch(
|
|
@@ -6474,8 +6656,8 @@ const mergeJsonInto = async (sourcePath, destinationPath) => {
|
|
|
6474
6656
|
);
|
|
6475
6657
|
await writeFile(destinationPath, content, "utf8");
|
|
6476
6658
|
};
|
|
6477
|
-
const writeWsAuthResources = async (generatedDir,
|
|
6478
|
-
const { content, module } = createAuthConfigResources(
|
|
6659
|
+
const writeWsAuthResources = async (generatedDir, pages2) => {
|
|
6660
|
+
const { content, module } = createAuthConfigResources(pages2);
|
|
6479
6661
|
await createFolderIfNotExists(dirname(LOCAL_AUTH_FILE));
|
|
6480
6662
|
await writeFile(LOCAL_AUTH_FILE, content);
|
|
6481
6663
|
await createFileIfNotExists(
|
|
@@ -6588,7 +6770,7 @@ Please check webstudio --help for more details`
|
|
|
6588
6770
|
`Project bundle is missing, please make sure the project is synced.`
|
|
6589
6771
|
);
|
|
6590
6772
|
}
|
|
6591
|
-
const parsedSiteData =
|
|
6773
|
+
const parsedSiteData = publishedProjectBundle.safeParse(loadedSiteData);
|
|
6592
6774
|
if (parsedSiteData.success === false) {
|
|
6593
6775
|
throw new Error(
|
|
6594
6776
|
`Project bundle is invalid, please make sure the project is synced. Invalid fields: ${formatZodIssues(parsedSiteData.error.issues)}`
|
|
@@ -6598,63 +6780,63 @@ Please check webstudio --help for more details`
|
|
|
6598
6780
|
const usedMetas = new Map(
|
|
6599
6781
|
Object.entries(coreMetas)
|
|
6600
6782
|
);
|
|
6601
|
-
const
|
|
6602
|
-
const allPages = getAllPages(
|
|
6603
|
-
await writeWsAuthResources(generatedDir,
|
|
6783
|
+
const pages2 = migratePages(siteData.build.pages);
|
|
6784
|
+
const allPages = getAllPages(pages2);
|
|
6785
|
+
await writeWsAuthResources(generatedDir, pages2);
|
|
6604
6786
|
const siteDataByPage = {};
|
|
6605
6787
|
const fontAssetsByPage = {};
|
|
6606
6788
|
const backgroundImageAssetsByPage = {};
|
|
6607
6789
|
const normalizedProps = normalizeProps({
|
|
6608
|
-
props: siteData.build.props.map(([_id,
|
|
6790
|
+
props: siteData.build.props.map(([_id, prop2]) => prop2),
|
|
6609
6791
|
assetBaseUrl,
|
|
6610
|
-
assets: new Map(siteData.assets.map((
|
|
6792
|
+
assets: new Map(siteData.assets.map((asset2) => [asset2.id, asset2])),
|
|
6611
6793
|
uploadingImageAssets: [],
|
|
6612
|
-
pages,
|
|
6794
|
+
pages: pages2,
|
|
6613
6795
|
source: "prebuild"
|
|
6614
6796
|
});
|
|
6615
|
-
for (const
|
|
6797
|
+
for (const page2 of allPages) {
|
|
6616
6798
|
const instanceMap = new Map(siteData.build.instances);
|
|
6617
6799
|
const pageInstanceSet = findTreeInstanceIds(
|
|
6618
6800
|
instanceMap,
|
|
6619
|
-
|
|
6801
|
+
page2.rootInstanceId
|
|
6620
6802
|
);
|
|
6621
6803
|
pageInstanceSet.add(ROOT_INSTANCE_ID);
|
|
6622
6804
|
const instances = [];
|
|
6623
|
-
for (const [_instanceId,
|
|
6624
|
-
if (pageInstanceSet.has(
|
|
6625
|
-
instances.push([
|
|
6626
|
-
const meta = framework.metas[
|
|
6805
|
+
for (const [_instanceId, instance2] of siteData.build.instances) {
|
|
6806
|
+
if (pageInstanceSet.has(instance2.id)) {
|
|
6807
|
+
instances.push([instance2.id, instance2]);
|
|
6808
|
+
const meta = framework.metas[instance2.component];
|
|
6627
6809
|
if (meta) {
|
|
6628
|
-
usedMetas.set(
|
|
6810
|
+
usedMetas.set(instance2.component, meta);
|
|
6629
6811
|
}
|
|
6630
6812
|
}
|
|
6631
6813
|
}
|
|
6632
6814
|
const resourceIds = /* @__PURE__ */ new Set();
|
|
6633
6815
|
const props = [];
|
|
6634
|
-
for (const
|
|
6635
|
-
if (pageInstanceSet.has(
|
|
6636
|
-
props.push([
|
|
6637
|
-
if (
|
|
6638
|
-
resourceIds.add(
|
|
6816
|
+
for (const prop2 of normalizedProps) {
|
|
6817
|
+
if (pageInstanceSet.has(prop2.instanceId)) {
|
|
6818
|
+
props.push([prop2.id, prop2]);
|
|
6819
|
+
if (prop2.type === "resource") {
|
|
6820
|
+
resourceIds.add(prop2.value);
|
|
6639
6821
|
}
|
|
6640
6822
|
}
|
|
6641
6823
|
}
|
|
6642
6824
|
const dataSources = [];
|
|
6643
|
-
for (const [
|
|
6644
|
-
if (pageInstanceSet.has(
|
|
6645
|
-
dataSources.push([
|
|
6646
|
-
if (
|
|
6647
|
-
resourceIds.add(
|
|
6825
|
+
for (const [dataSourceId2, dataSource2] of siteData.build.dataSources) {
|
|
6826
|
+
if (pageInstanceSet.has(dataSource2.scopeInstanceId ?? "")) {
|
|
6827
|
+
dataSources.push([dataSourceId2, dataSource2]);
|
|
6828
|
+
if (dataSource2.type === "resource") {
|
|
6829
|
+
resourceIds.add(dataSource2.resourceId);
|
|
6648
6830
|
}
|
|
6649
6831
|
}
|
|
6650
6832
|
}
|
|
6651
6833
|
const resources = [];
|
|
6652
|
-
for (const [
|
|
6653
|
-
if (resourceIds.has(
|
|
6654
|
-
resources.push([
|
|
6834
|
+
for (const [resourceId2, resource2] of siteData.build.resources ?? []) {
|
|
6835
|
+
if (resourceIds.has(resourceId2)) {
|
|
6836
|
+
resources.push([resourceId2, resource2]);
|
|
6655
6837
|
}
|
|
6656
6838
|
}
|
|
6657
|
-
siteDataByPage[
|
|
6839
|
+
siteDataByPage[page2.id] = {
|
|
6658
6840
|
build: {
|
|
6659
6841
|
props,
|
|
6660
6842
|
instances,
|
|
@@ -6662,23 +6844,23 @@ Please check webstudio --help for more details`
|
|
|
6662
6844
|
resources
|
|
6663
6845
|
},
|
|
6664
6846
|
pages: allPages,
|
|
6665
|
-
page,
|
|
6847
|
+
page: page2,
|
|
6666
6848
|
assets: siteData.assets
|
|
6667
6849
|
};
|
|
6668
6850
|
const styleSourceSelections = ((_a = siteData.build) == null ? void 0 : _a.styleSourceSelections) ?? [];
|
|
6669
6851
|
const pageStyleSourceIds = new Set(
|
|
6670
|
-
styleSourceSelections.filter(([, { instanceId }]) => pageInstanceSet.has(
|
|
6852
|
+
styleSourceSelections.filter(([, { instanceId: instanceId2 }]) => pageInstanceSet.has(instanceId2)).map(([, { values }]) => values).flat()
|
|
6671
6853
|
);
|
|
6672
6854
|
const pageStyles = (_c = (_b = siteData.build) == null ? void 0 : _b.styles) == null ? void 0 : _c.filter(
|
|
6673
|
-
([, { styleSourceId }]) => pageStyleSourceIds.has(
|
|
6855
|
+
([, { styleSourceId: styleSourceId2 }]) => pageStyleSourceIds.has(styleSourceId2)
|
|
6674
6856
|
);
|
|
6675
6857
|
const pageFontFamilySet = new Set(
|
|
6676
6858
|
pageStyles.filter(([, { property }]) => property === "fontFamily").map(
|
|
6677
6859
|
([, { value }]) => value.type === "fontFamily" ? value.value : void 0
|
|
6678
6860
|
).flat().filter((value) => value !== void 0)
|
|
6679
6861
|
);
|
|
6680
|
-
const pageFontAssets = siteData.assets.filter((
|
|
6681
|
-
fontAssetsByPage[
|
|
6862
|
+
const pageFontAssets = siteData.assets.filter((asset2) => asset2.type === "font").filter((fontAsset2) => pageFontFamilySet.has(fontAsset2.meta.family)).map((asset2) => asset2.name);
|
|
6863
|
+
fontAssetsByPage[page2.id] = pageFontAssets;
|
|
6682
6864
|
const backgroundImageAssetIdSet = new Set(
|
|
6683
6865
|
pageStyles.filter(([, { property }]) => property === "backgroundImage").map(
|
|
6684
6866
|
([, { value }]) => value.type === "layers" ? value.value.map(
|
|
@@ -6686,8 +6868,8 @@ Please check webstudio --help for more details`
|
|
|
6686
6868
|
) : void 0
|
|
6687
6869
|
).flat().filter((value) => value !== void 0)
|
|
6688
6870
|
);
|
|
6689
|
-
const backgroundImageAssets = siteData.assets.filter((
|
|
6690
|
-
backgroundImageAssetsByPage[
|
|
6871
|
+
const backgroundImageAssets = siteData.assets.filter((asset2) => asset2.type === "image").filter((imageAsset2) => backgroundImageAssetIdSet.has(imageAsset2.id)).map((asset2) => asset2.name);
|
|
6872
|
+
backgroundImageAssetsByPage[page2.id] = backgroundImageAssets;
|
|
6691
6873
|
}
|
|
6692
6874
|
if (options.assets === true) {
|
|
6693
6875
|
const assetOrigin = siteData.origin;
|
|
@@ -6695,7 +6877,7 @@ Please check webstudio --help for more details`
|
|
|
6695
6877
|
console.warn("Warning: Asset origin is not defined in project bundle.");
|
|
6696
6878
|
}
|
|
6697
6879
|
}
|
|
6698
|
-
const assets = new Map(siteData.assets.map((
|
|
6880
|
+
const assets = new Map(siteData.assets.map((asset2) => [asset2.id, asset2]));
|
|
6699
6881
|
const { cssText, classes } = generateCss({
|
|
6700
6882
|
instances: new Map(siteData.build.instances),
|
|
6701
6883
|
props: new Map(siteData.build.props),
|
|
@@ -6706,10 +6888,10 @@ Please check webstudio --help for more details`
|
|
|
6706
6888
|
// pass only used metas to not generate unused preset styles
|
|
6707
6889
|
componentMetas: usedMetas,
|
|
6708
6890
|
assetBaseUrl,
|
|
6709
|
-
atomic: ((_g =
|
|
6891
|
+
atomic: ((_g = pages2.compiler) == null ? void 0 : _g.atomicStyles) ?? true
|
|
6710
6892
|
});
|
|
6711
6893
|
await createFileIfNotExists(join(generatedDir, "index.css"), cssText);
|
|
6712
|
-
for (const
|
|
6894
|
+
for (const page2 of allPages) {
|
|
6713
6895
|
const scope = createScope([
|
|
6714
6896
|
// manually maintained list of occupied identifiers
|
|
6715
6897
|
"useState",
|
|
@@ -6719,32 +6901,32 @@ Please check webstudio --help for more details`
|
|
|
6719
6901
|
"Page",
|
|
6720
6902
|
"_props"
|
|
6721
6903
|
]);
|
|
6722
|
-
const pageData = siteDataByPage[
|
|
6904
|
+
const pageData = siteDataByPage[page2.id];
|
|
6723
6905
|
const instances = new Map(pageData.build.instances);
|
|
6724
|
-
const documentType =
|
|
6725
|
-
let rootInstanceId =
|
|
6906
|
+
const documentType = page2.meta.documentType ?? "html";
|
|
6907
|
+
let rootInstanceId = page2.rootInstanceId;
|
|
6726
6908
|
if (documentType === "xml") {
|
|
6727
6909
|
const bodyInstance = instances.get(rootInstanceId);
|
|
6728
6910
|
const firstChild = bodyInstance == null ? void 0 : bodyInstance.children.at(0);
|
|
6729
6911
|
if ((firstChild == null ? void 0 : firstChild.type) === "id") {
|
|
6730
6912
|
rootInstanceId = firstChild.value;
|
|
6731
6913
|
}
|
|
6732
|
-
for (const
|
|
6733
|
-
if (isCoreComponent(
|
|
6914
|
+
for (const instance2 of instances.values()) {
|
|
6915
|
+
if (isCoreComponent(instance2.component)) {
|
|
6734
6916
|
continue;
|
|
6735
6917
|
}
|
|
6736
|
-
if (((_h = usedMetas.get(
|
|
6918
|
+
if (((_h = usedMetas.get(instance2.component)) == null ? void 0 : _h.category) === "xml") {
|
|
6737
6919
|
continue;
|
|
6738
6920
|
}
|
|
6739
|
-
instances.delete(
|
|
6921
|
+
instances.delete(instance2.id);
|
|
6740
6922
|
}
|
|
6741
6923
|
}
|
|
6742
6924
|
const imports2 = /* @__PURE__ */ new Map();
|
|
6743
|
-
for (const
|
|
6744
|
-
let descriptor = framework.components[
|
|
6745
|
-
let id =
|
|
6746
|
-
if (
|
|
6747
|
-
descriptor = framework.tags[
|
|
6925
|
+
for (const instance2 of instances.values()) {
|
|
6926
|
+
let descriptor = framework.components[instance2.component];
|
|
6927
|
+
let id = instance2.component;
|
|
6928
|
+
if (instance2.component === elementComponent && instance2.tag) {
|
|
6929
|
+
descriptor = framework.tags[instance2.tag];
|
|
6748
6930
|
id = descriptor;
|
|
6749
6931
|
}
|
|
6750
6932
|
if (descriptor === void 0) {
|
|
@@ -6766,8 +6948,8 @@ Please check webstudio --help for more details`
|
|
|
6766
6948
|
importsString += `import { ${specifiersString} } from "${importSource}";
|
|
6767
6949
|
`;
|
|
6768
6950
|
}
|
|
6769
|
-
const pageFontAssets = fontAssetsByPage[
|
|
6770
|
-
const pageBackgroundImageAssets = backgroundImageAssetsByPage[
|
|
6951
|
+
const pageFontAssets = fontAssetsByPage[page2.id];
|
|
6952
|
+
const pageBackgroundImageAssets = backgroundImageAssetsByPage[page2.id];
|
|
6771
6953
|
const props = new Map(pageData.build.props);
|
|
6772
6954
|
const dataSources = new Map(pageData.build.dataSources);
|
|
6773
6955
|
const resources = new Map(pageData.build.resources);
|
|
@@ -6786,7 +6968,7 @@ Please check webstudio --help for more details`
|
|
|
6786
6968
|
instanceId: "",
|
|
6787
6969
|
name: "system",
|
|
6788
6970
|
type: "parameter",
|
|
6789
|
-
value:
|
|
6971
|
+
value: page2.systemDataSourceId ?? ""
|
|
6790
6972
|
},
|
|
6791
6973
|
{
|
|
6792
6974
|
id: "global-system",
|
|
@@ -6803,13 +6985,13 @@ Please check webstudio --help for more details`
|
|
|
6803
6985
|
metas: usedMetas,
|
|
6804
6986
|
tagsOverrides: framework.tags
|
|
6805
6987
|
});
|
|
6806
|
-
const
|
|
6988
|
+
const projectMeta2 = pages2.meta;
|
|
6807
6989
|
const contactEmail = (
|
|
6808
6990
|
// fallback to user email when contact email is empty string
|
|
6809
|
-
(
|
|
6991
|
+
(projectMeta2 == null ? void 0 : projectMeta2.contactEmail) || ((_i = siteData.user) == null ? void 0 : _i.email) || void 0
|
|
6810
6992
|
);
|
|
6811
|
-
const favIconAsset = (_j = assets.get((
|
|
6812
|
-
const
|
|
6993
|
+
const favIconAsset = (_j = assets.get((projectMeta2 == null ? void 0 : projectMeta2.faviconAssetId) ?? "")) == null ? void 0 : _j.name;
|
|
6994
|
+
const pagePath2 = getPagePath(page2.id, pages2);
|
|
6813
6995
|
const breakpoints = siteData.build.breakpoints.map(([_, value]) => ({
|
|
6814
6996
|
id: value.id,
|
|
6815
6997
|
minWidth: value.minWidth,
|
|
@@ -6829,7 +7011,7 @@ Please check webstudio --help for more details`
|
|
|
6829
7011
|
|
|
6830
7012
|
export const lastPublished = "${new Date(siteData.build.createdAt).toISOString()}";
|
|
6831
7013
|
|
|
6832
|
-
export const siteName = ${JSON.stringify(
|
|
7014
|
+
export const siteName = ${JSON.stringify(projectMeta2 == null ? void 0 : projectMeta2.siteName)};
|
|
6833
7015
|
|
|
6834
7016
|
export const breakpoints = ${JSON.stringify(breakpoints)};
|
|
6835
7017
|
|
|
@@ -6843,8 +7025,8 @@ Please check webstudio --help for more details`
|
|
|
6843
7025
|
export const pageBackgroundImageAssets: string[] =
|
|
6844
7026
|
${JSON.stringify(pageBackgroundImageAssets)}
|
|
6845
7027
|
|
|
6846
|
-
${
|
|
6847
|
-
${(
|
|
7028
|
+
${pagePath2 === "/" ? `
|
|
7029
|
+
${(projectMeta2 == null ? void 0 : projectMeta2.code) ? `
|
|
6848
7030
|
const Script = ({children, ...props}: Record<string, string | boolean>) => {
|
|
6849
7031
|
if (children == null) {
|
|
6850
7032
|
return <script {...props} />;
|
|
@@ -6862,7 +7044,7 @@ Please check webstudio --help for more details`
|
|
|
6862
7044
|
` : ""}
|
|
6863
7045
|
|
|
6864
7046
|
export const CustomCode = () => {
|
|
6865
|
-
return (<>${(
|
|
7047
|
+
return (<>${(projectMeta2 == null ? void 0 : projectMeta2.code) ? htmlToJsx(projectMeta2.code) : ""}</>);
|
|
6866
7048
|
}
|
|
6867
7049
|
` : ""}
|
|
6868
7050
|
|
|
@@ -6877,7 +7059,7 @@ Please check webstudio --help for more details`
|
|
|
6877
7059
|
import type { PageMeta } from "@webstudio-is/sdk";
|
|
6878
7060
|
${generateResources({
|
|
6879
7061
|
scope,
|
|
6880
|
-
page,
|
|
7062
|
+
page: page2,
|
|
6881
7063
|
dataSources,
|
|
6882
7064
|
props,
|
|
6883
7065
|
resources
|
|
@@ -6885,22 +7067,22 @@ Please check webstudio --help for more details`
|
|
|
6885
7067
|
|
|
6886
7068
|
${generatePageMeta({
|
|
6887
7069
|
globalScope: scope,
|
|
6888
|
-
page,
|
|
7070
|
+
page: page2,
|
|
6889
7071
|
dataSources,
|
|
6890
7072
|
assets
|
|
6891
7073
|
})}
|
|
6892
7074
|
|
|
6893
|
-
${generateRemixParams(
|
|
7075
|
+
${generateRemixParams(page2.path)}
|
|
6894
7076
|
|
|
6895
7077
|
export const contactEmail = ${JSON.stringify(contactEmail)};
|
|
6896
7078
|
`;
|
|
6897
|
-
const generatedBasename = generateRemixRoute(
|
|
7079
|
+
const generatedBasename = generateRemixRoute(pagePath2);
|
|
6898
7080
|
const clientFile = join(generatedDir, `${generatedBasename}.tsx`);
|
|
6899
7081
|
await createFileIfNotExists(clientFile, pageExports);
|
|
6900
7082
|
const serverFile = join(generatedDir, `${generatedBasename}.server.tsx`);
|
|
6901
7083
|
await createFileIfNotExists(serverFile, serverExports);
|
|
6902
7084
|
const getTemplates = framework[documentType];
|
|
6903
|
-
for (const { file, template } of getTemplates({ pagePath })) {
|
|
7085
|
+
for (const { file, template } of getTemplates({ pagePath: pagePath2 })) {
|
|
6904
7086
|
const content = template.replaceAll("__CONSTANTS__", importFrom("./app/constants.mjs", file)).replaceAll(
|
|
6905
7087
|
"__SITEMAP__",
|
|
6906
7088
|
importFrom(`./app/__generated__/$resources.sitemap.xml`, file)
|
|
@@ -6934,16 +7116,16 @@ Please check webstudio --help for more details`
|
|
|
6934
7116
|
join(generatedDir, "$resources.sitemap.xml.ts"),
|
|
6935
7117
|
`
|
|
6936
7118
|
export const sitemap = ${JSON.stringify(
|
|
6937
|
-
getStaticSiteMapXml(
|
|
7119
|
+
getStaticSiteMapXml(pages2, siteData.build.updatedAt),
|
|
6938
7120
|
null,
|
|
6939
7121
|
2
|
|
6940
7122
|
)};
|
|
6941
7123
|
`
|
|
6942
7124
|
);
|
|
6943
7125
|
const assetsById = Object.fromEntries(
|
|
6944
|
-
siteData.assets.map((
|
|
6945
|
-
|
|
6946
|
-
toRuntimeAsset(
|
|
7126
|
+
siteData.assets.map((asset2) => [
|
|
7127
|
+
asset2.id,
|
|
7128
|
+
toRuntimeAsset(asset2, "https://placeholder.local")
|
|
6947
7129
|
])
|
|
6948
7130
|
);
|
|
6949
7131
|
await createFileIfNotExists(
|
|
@@ -6954,7 +7136,7 @@ Please check webstudio --help for more details`
|
|
|
6954
7136
|
);
|
|
6955
7137
|
await createFileIfNotExists(
|
|
6956
7138
|
join(generatedDir, "$resources.redirects.ts"),
|
|
6957
|
-
generateRedirectsModule(
|
|
7139
|
+
generateRedirectsModule(pages2.redirects)
|
|
6958
7140
|
);
|
|
6959
7141
|
if (options.assets === true && siteData.assets.length > 0) {
|
|
6960
7142
|
const downloading = spinner();
|
|
@@ -6970,20 +7152,20 @@ Please check webstudio --help for more details`
|
|
|
6970
7152
|
log.step("Build finished");
|
|
6971
7153
|
};
|
|
6972
7154
|
const mapToTemplatesFromOptions = (values) => {
|
|
6973
|
-
const
|
|
7155
|
+
const templates2 = [];
|
|
6974
7156
|
for (const value of values) {
|
|
6975
7157
|
const template = PROJECT_TEMPLATES.find((item) => item.value === value) ?? INTERNAL_TEMPLATES.find((item) => item.value === value);
|
|
6976
7158
|
if (template == null) {
|
|
6977
|
-
|
|
7159
|
+
templates2.push(value);
|
|
6978
7160
|
continue;
|
|
6979
7161
|
}
|
|
6980
7162
|
if ("expand" in template && template.expand != null) {
|
|
6981
|
-
|
|
7163
|
+
templates2.push(...template.expand);
|
|
6982
7164
|
continue;
|
|
6983
7165
|
}
|
|
6984
|
-
|
|
7166
|
+
templates2.push(value);
|
|
6985
7167
|
}
|
|
6986
|
-
return
|
|
7168
|
+
return templates2;
|
|
6987
7169
|
};
|
|
6988
7170
|
const buildOptions = (yargs) => yargs.option("assets", {
|
|
6989
7171
|
type: "boolean",
|
|
@@ -7022,7 +7204,7 @@ const exitIfCancelled = (value) => {
|
|
|
7022
7204
|
const initFlow = async (options) => {
|
|
7023
7205
|
const isProjectConfigured = await isFileExists(".webstudio/config.json");
|
|
7024
7206
|
let shouldInstallDeps = false;
|
|
7025
|
-
let
|
|
7207
|
+
let folderName2;
|
|
7026
7208
|
let projectTemplate;
|
|
7027
7209
|
if (isProjectConfigured === false) {
|
|
7028
7210
|
const shouldCreateFolder = exitIfCancelled(
|
|
@@ -7032,7 +7214,7 @@ const initFlow = async (options) => {
|
|
|
7032
7214
|
})
|
|
7033
7215
|
);
|
|
7034
7216
|
if (shouldCreateFolder === true) {
|
|
7035
|
-
|
|
7217
|
+
folderName2 = exitIfCancelled(
|
|
7036
7218
|
await text({
|
|
7037
7219
|
message: "Please enter a project name",
|
|
7038
7220
|
validate(value) {
|
|
@@ -7042,8 +7224,8 @@ const initFlow = async (options) => {
|
|
|
7042
7224
|
}
|
|
7043
7225
|
})
|
|
7044
7226
|
);
|
|
7045
|
-
await createFolderIfNotExists(join(cwd(),
|
|
7046
|
-
chdir(join(cwd(),
|
|
7227
|
+
await createFolderIfNotExists(join(cwd(), folderName2));
|
|
7228
|
+
chdir(join(cwd(), folderName2));
|
|
7047
7229
|
}
|
|
7048
7230
|
const shareLink = exitIfCancelled(
|
|
7049
7231
|
await text({
|
|
@@ -7091,7 +7273,7 @@ const initFlow = async (options) => {
|
|
|
7091
7273
|
log.message(
|
|
7092
7274
|
[
|
|
7093
7275
|
"Now you can:",
|
|
7094
|
-
|
|
7276
|
+
folderName2 && `Go to your project: ${pc.dim(`cd ${folderName2}`)}`,
|
|
7095
7277
|
`Run ${pc.dim("npm run dev")} to preview your project on a local server.`,
|
|
7096
7278
|
projectTemplate && getDeploymentInstructions(projectTemplate)
|
|
7097
7279
|
].filter(Boolean).join("\n")
|