@webstudio-is/sdk 0.181.0 → 0.185.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.
@@ -43,28 +43,16 @@ var ol = div;
43
43
  var p = div;
44
44
  var span = div;
45
45
  var html = [
46
+ { property: "display", value: { type: "keyword", value: "grid" } },
47
+ { property: "minHeight", value: { type: "unit", unit: "%", value: 100 } },
46
48
  {
47
- property: "lineHeight",
48
- value: { type: "unit", unit: "number", value: 1.15 }
49
- },
50
- {
51
- property: "textSizeAdjust",
52
- value: { type: "unit", unit: "%", value: 100 }
53
- },
54
- { property: "tabSize", value: { type: "unit", unit: "number", value: 4 } },
55
- { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
56
- { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
57
- {
58
- property: "borderRightWidth",
59
- value: { type: "unit", unit: "px", value: 1 }
60
- },
61
- {
62
- property: "borderBottomWidth",
63
- value: { type: "unit", unit: "px", value: 1 }
49
+ property: "fontFamily",
50
+ value: { type: "fontFamily", value: ["Arial", "Roboto", "sans-serif"] }
64
51
  },
52
+ { property: "fontSize", value: { type: "unit", unit: "px", value: 16 } },
65
53
  {
66
- property: "borderLeftWidth",
67
- value: { type: "unit", unit: "px", value: 1 }
54
+ property: "lineHeight",
55
+ value: { type: "unit", unit: "number", value: 1.2 }
68
56
  }
69
57
  ];
70
58
  var body = [
@@ -78,15 +66,6 @@ var body = [
78
66
  value: { type: "unit", unit: "number", value: 0 }
79
67
  },
80
68
  { property: "marginLeft", value: { type: "unit", unit: "number", value: 0 } },
81
- {
82
- property: "fontFamily",
83
- value: { type: "fontFamily", value: ["Arial", "Roboto", "sans-serif"] }
84
- },
85
- { property: "fontSize", value: { type: "unit", unit: "px", value: 16 } },
86
- {
87
- property: "lineHeight",
88
- value: { type: "unit", unit: "number", value: 1.2 }
89
- },
90
69
  { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
91
70
  { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
92
71
  {
package/lib/index.js CHANGED
@@ -436,7 +436,12 @@ var Deployment = z11.union([
436
436
  z11.object({
437
437
  destination: z11.literal("saas").optional(),
438
438
  domains: z11.array(z11.string()),
439
- projectDomain: z11.string()
439
+ assetsDomain: z11.string().optional(),
440
+ /**
441
+ * @deprecated This field is deprecated, use `domains` instead.
442
+ */
443
+ projectDomain: z11.string().optional(),
444
+ excludeWstdDomainFromSearch: z11.boolean().optional()
440
445
  })
441
446
  ]);
442
447
 
@@ -456,6 +461,7 @@ var WebstudioFragment = z12.object({
456
461
  });
457
462
 
458
463
  // src/instances-utils.ts
464
+ var ROOT_INSTANCE_ID = ":root";
459
465
  var traverseInstances = (instances, instanceId, callback) => {
460
466
  const instance = instances.get(instanceId);
461
467
  if (instance === void 0) {
@@ -472,14 +478,14 @@ var traverseInstances = (instances, instanceId, callback) => {
472
478
  }
473
479
  };
474
480
  var findTreeInstanceIds = (instances, rootInstanceId) => {
475
- const ids = /* @__PURE__ */ new Set();
481
+ const ids = /* @__PURE__ */ new Set([rootInstanceId]);
476
482
  traverseInstances(instances, rootInstanceId, (instance) => {
477
483
  ids.add(instance.id);
478
484
  });
479
485
  return ids;
480
486
  };
481
487
  var findTreeInstanceIdsExcludingSlotDescendants = (instances, rootInstanceId) => {
482
- const ids = /* @__PURE__ */ new Set();
488
+ const ids = /* @__PURE__ */ new Set([rootInstanceId]);
483
489
  traverseInstances(instances, rootInstanceId, (instance) => {
484
490
  ids.add(instance.id);
485
491
  if (instance.component === "Slot") {
@@ -538,7 +544,7 @@ var lintExpression = ({
538
544
  simple(root, {
539
545
  Identifier(node) {
540
546
  if (availableVariables.has(node.name) === false) {
541
- addError(`"${node.name}" is not available in the scope`)(node);
547
+ addError(`"${node.name}" is not defined in the scope`)(node);
542
548
  }
543
549
  },
544
550
  Literal() {
@@ -571,7 +577,7 @@ var lintExpression = ({
571
577
  simple(node.left, {
572
578
  Identifier(node2) {
573
579
  if (availableVariables.has(node2.name) === false) {
574
- addError(`"${node2.name}" is not available in the scope`)(node2);
580
+ addError(`"${node2.name}" is not defined in the scope`)(node2);
575
581
  }
576
582
  }
577
583
  });
@@ -640,20 +646,20 @@ var isLiteralExpression = (expression) => {
640
646
  }
641
647
  };
642
648
  var getExpressionIdentifiers = (expression) => {
643
- const identifiers = /* @__PURE__ */ new Set();
649
+ const identifiers2 = /* @__PURE__ */ new Set();
644
650
  try {
645
651
  const root = parseExpressionAt(expression, 0, { ecmaVersion: "latest" });
646
652
  simple(root, {
647
- Identifier: (node) => identifiers.add(node.name),
653
+ Identifier: (node) => identifiers2.add(node.name),
648
654
  AssignmentExpression(node) {
649
655
  simple(node.left, {
650
- Identifier: (node2) => identifiers.add(node2.name)
656
+ Identifier: (node2) => identifiers2.add(node2.name)
651
657
  });
652
658
  }
653
659
  });
654
660
  } catch {
655
661
  }
656
- return identifiers;
662
+ return identifiers2;
657
663
  };
658
664
  var transpileExpression = ({
659
665
  expression,
@@ -852,6 +858,9 @@ var getStaticSiteMapXml = (pages, updatedAt) => {
852
858
  };
853
859
 
854
860
  // src/scope.ts
861
+ import reservedIdentifiers from "reserved-identifiers";
862
+ var identifiers = reservedIdentifiers({ includeGlobalProperties: true });
863
+ var isReserved = (identifier) => identifiers.has(identifier);
855
864
  var normalizeJsName = (name) => {
856
865
  name = name.replaceAll(/[^\w$]/g, "");
857
866
  if (name.length === 0) {
@@ -860,6 +869,9 @@ var normalizeJsName = (name) => {
860
869
  if (/[A-Za-z_$]/.test(name[0]) === false) {
861
870
  name = `_${name}`;
862
871
  }
872
+ if (isReserved(name)) {
873
+ return `${name}_`;
874
+ }
863
875
  return name;
864
876
  };
865
877
  var createScope = (occupiedIdentifiers = [], normalizeName = normalizeJsName, separator = "_") => {
@@ -909,12 +921,15 @@ var loadResource = async (customFetch, resourceRequest) => {
909
921
  }
910
922
  try {
911
923
  const response = await customFetch(url.trim(), requestInit);
912
- let data;
913
- if (response.ok && // accept json by default and when specified explicitly
914
- (response.headers.has("content-type") === false || response.headers.get("content-type")?.includes("application/json"))) {
915
- data = await response.json();
916
- } else {
917
- data = await response.text();
924
+ let data = await response.text();
925
+ try {
926
+ data = JSON.parse(data);
927
+ } catch {
928
+ }
929
+ if (!response.ok) {
930
+ console.error(
931
+ `Failed to load resource: ${url} - ${response.status}: ${JSON.stringify(data).slice(0, 300)}`
932
+ );
918
933
  }
919
934
  return {
920
935
  ok: response.ok,
@@ -923,6 +938,7 @@ var loadResource = async (customFetch, resourceRequest) => {
923
938
  statusText: response.statusText
924
939
  };
925
940
  } catch (error) {
941
+ console.error(error);
926
942
  const message = error.message;
927
943
  return {
928
944
  ok: false,
@@ -1310,6 +1326,7 @@ export {
1310
1326
  Prop,
1311
1327
  Props,
1312
1328
  ROOT_FOLDER_ID,
1329
+ ROOT_INSTANCE_ID,
1313
1330
  Resource,
1314
1331
  ResourceRequest,
1315
1332
  Resources,
@@ -1,4 +1,5 @@
1
1
  import type { Instance, Instances } from "./schema/instances";
2
+ export declare const ROOT_INSTANCE_ID = ":root";
2
3
  export declare const findTreeInstanceIds: (instances: Instances, rootInstanceId: Instance["id"]) => Set<string>;
3
4
  export declare const findTreeInstanceIdsExcludingSlotDescendants: (instances: Instances, rootInstanceId: Instance["id"]) => Set<string>;
4
5
  export declare const parseComponentName: (componentName: string) => readonly [string | undefined, string];
@@ -1,14 +1,24 @@
1
1
  import type { ResourceRequest } from "./schema/resources";
2
2
  export declare const loadResource: (customFetch: typeof fetch, resourceRequest: ResourceRequest) => Promise<{
3
3
  ok: boolean;
4
- data: any;
4
+ data: string;
5
+ status: number;
6
+ statusText: string;
7
+ } | {
8
+ ok: boolean;
9
+ data: undefined;
5
10
  status: number;
6
11
  statusText: string;
7
12
  }>;
8
13
  export declare const loadResources: (customFetch: typeof fetch, requests: Map<string, ResourceRequest>) => Promise<{
9
14
  [k: string]: {
10
15
  ok: boolean;
11
- data: any;
16
+ data: string;
17
+ status: number;
18
+ statusText: string;
19
+ } | {
20
+ ok: boolean;
21
+ data: undefined;
12
22
  status: number;
13
23
  statusText: string;
14
24
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -19,14 +19,23 @@ export declare const Deployment: z.ZodUnion<[z.ZodObject<{
19
19
  }>, z.ZodObject<{
20
20
  destination: z.ZodOptional<z.ZodLiteral<"saas">>;
21
21
  domains: z.ZodArray<z.ZodString, "many">;
22
- projectDomain: z.ZodString;
22
+ assetsDomain: z.ZodOptional<z.ZodString>;
23
+ /**
24
+ * @deprecated This field is deprecated, use `domains` instead.
25
+ */
26
+ projectDomain: z.ZodOptional<z.ZodString>;
27
+ excludeWstdDomainFromSearch: z.ZodOptional<z.ZodBoolean>;
23
28
  }, "strip", z.ZodTypeAny, {
24
29
  domains: string[];
25
- projectDomain: string;
26
30
  destination?: "saas" | undefined;
31
+ assetsDomain?: string | undefined;
32
+ projectDomain?: string | undefined;
33
+ excludeWstdDomainFromSearch?: boolean | undefined;
27
34
  }, {
28
35
  domains: string[];
29
- projectDomain: string;
30
36
  destination?: "saas" | undefined;
37
+ assetsDomain?: string | undefined;
38
+ projectDomain?: string | undefined;
39
+ excludeWstdDomainFromSearch?: boolean | undefined;
31
40
  }>]>;
32
41
  export type Deployment = z.infer<typeof Deployment>;