@webstudio-is/sdk 0.0.0-4f7bf18 → 0.0.0-5558cd0

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/index.js CHANGED
@@ -428,7 +428,10 @@ var Styles = z10.map(z10.string(), StyleDecl);
428
428
  import { z as z11 } from "zod";
429
429
  var Templates = z11.enum([
430
430
  "vanilla",
431
+ "docker",
431
432
  "vercel",
433
+ "vercel-legacy",
434
+ "netlify",
432
435
  "netlify-functions",
433
436
  "netlify-edge-functions",
434
437
  "ssg",
@@ -966,7 +969,10 @@ var parseComponentName = (componentName) => {
966
969
  };
967
970
 
968
971
  // src/expression.ts
969
- import { parseExpressionAt } from "acorn";
972
+ import {
973
+ parse,
974
+ parseExpressionAt
975
+ } from "acorn";
970
976
  import { simple } from "acorn-walk";
971
977
  var lintExpression = ({
972
978
  expression,
@@ -974,13 +980,13 @@ var lintExpression = ({
974
980
  allowAssignment = false
975
981
  }) => {
976
982
  const diagnostics = [];
977
- const addError = (message) => {
983
+ const addMessage = (message, severity = "error") => {
978
984
  return (node) => {
979
985
  diagnostics.push({
980
986
  // tune error position after wrapping expression with parentheses
981
987
  from: node.start - 1,
982
988
  to: node.end - 1,
983
- severity: "error",
989
+ severity,
984
990
  message
985
991
  });
986
992
  };
@@ -995,7 +1001,7 @@ var lintExpression = ({
995
1001
  return diagnostics;
996
1002
  }
997
1003
  try {
998
- const root = parseExpressionAt(`(${expression})`, 0, {
1004
+ const root = parse(`(${expression})`, {
999
1005
  ecmaVersion: "latest",
1000
1006
  // support parsing import to forbid explicitly
1001
1007
  sourceType: "module"
@@ -1003,7 +1009,10 @@ var lintExpression = ({
1003
1009
  simple(root, {
1004
1010
  Identifier(node) {
1005
1011
  if (availableVariables.has(node.name) === false) {
1006
- addError(`"${node.name}" is not defined in the scope`)(node);
1012
+ addMessage(
1013
+ `"${node.name}" is not defined in the scope`,
1014
+ "warning"
1015
+ )(node);
1007
1016
  }
1008
1017
  },
1009
1018
  Literal() {
@@ -1030,13 +1039,16 @@ var lintExpression = ({
1030
1039
  },
1031
1040
  AssignmentExpression(node) {
1032
1041
  if (allowAssignment === false) {
1033
- addError("Assignment is supported only inside actions")(node);
1042
+ addMessage("Assignment is supported only inside actions")(node);
1034
1043
  return;
1035
1044
  }
1036
1045
  simple(node.left, {
1037
1046
  Identifier(node2) {
1038
1047
  if (availableVariables.has(node2.name) === false) {
1039
- addError(`"${node2.name}" is not defined in the scope`)(node2);
1048
+ addMessage(
1049
+ `"${node2.name}" is not defined in the scope`,
1050
+ "warning"
1051
+ )(node2);
1040
1052
  }
1041
1053
  }
1042
1054
  });
@@ -1044,18 +1056,18 @@ var lintExpression = ({
1044
1056
  // parser forbids to yield inside module
1045
1057
  YieldExpression() {
1046
1058
  },
1047
- ThisExpression: addError(`"this" keyword is not supported`),
1048
- FunctionExpression: addError("Functions are not supported"),
1049
- UpdateExpression: addError("Increment and decrement are not supported"),
1050
- CallExpression: addError("Functions are not supported"),
1051
- NewExpression: addError("Classes are not supported"),
1052
- SequenceExpression: addError(`Only single expression is supported`),
1053
- ArrowFunctionExpression: addError("Functions are not supported"),
1054
- TaggedTemplateExpression: addError("Tagged template is not supported"),
1055
- ClassExpression: addError("Classes are not supported"),
1056
- MetaProperty: addError("Imports are not supported"),
1057
- AwaitExpression: addError(`"await" keyword is not supported`),
1058
- ImportExpression: addError("Imports are not supported")
1059
+ ThisExpression: addMessage(`"this" keyword is not supported`),
1060
+ FunctionExpression: addMessage("Functions are not supported"),
1061
+ UpdateExpression: addMessage("Increment and decrement are not supported"),
1062
+ CallExpression: addMessage("Functions are not supported"),
1063
+ NewExpression: addMessage("Classes are not supported"),
1064
+ SequenceExpression: addMessage(`Only single expression is supported`),
1065
+ ArrowFunctionExpression: addMessage("Functions are not supported"),
1066
+ TaggedTemplateExpression: addMessage("Tagged template is not supported"),
1067
+ ClassExpression: addMessage("Classes are not supported"),
1068
+ MetaProperty: addMessage("Imports are not supported"),
1069
+ AwaitExpression: addMessage(`"await" keyword is not supported`),
1070
+ ImportExpression: addMessage("Imports are not supported")
1059
1071
  });
1060
1072
  } catch (error) {
1061
1073
  const castedError = error;
@@ -1240,6 +1252,7 @@ var generateExpression = ({
1240
1252
  usedDataSources?.set(dep.id, dep);
1241
1253
  return scope.getName(dep.id, dep.name);
1242
1254
  }
1255
+ return "undefined";
1243
1256
  }
1244
1257
  });
1245
1258
  };
@@ -1736,10 +1749,12 @@ export {
1736
1749
  corePropsMetas,
1737
1750
  createScope,
1738
1751
  decodeDataSourceVariable,
1752
+ decodeDataSourceVariable as decodeDataVariableId,
1739
1753
  defaultStates,
1740
1754
  descendantComponent,
1741
1755
  documentTypes,
1742
1756
  encodeDataSourceVariable,
1757
+ encodeDataSourceVariable as encodeDataVariableId,
1743
1758
  executeExpression,
1744
1759
  findPageByIdOrPath,
1745
1760
  findParentFolderByChildId,
@@ -43,11 +43,16 @@ export declare const parseObjectExpression: (expression: string) => Map<string,
43
43
  */
44
44
  export declare const generateObjectExpression: (map: Map<string, string>) => string;
45
45
  export declare const encodeDataSourceVariable: (id: string) => string;
46
+ export { encodeDataSourceVariable as encodeDataVariableId };
46
47
  export declare const decodeDataSourceVariable: (name: string) => string | undefined;
48
+ export { decodeDataSourceVariable as decodeDataVariableId };
47
49
  export declare const generateExpression: ({ expression, dataSources, usedDataSources, scope, }: {
48
50
  expression: string;
49
51
  dataSources: DataSources;
50
52
  usedDataSources: DataSources;
51
53
  scope: Scope;
52
54
  }) => string;
55
+ /**
56
+ * edge case utility for "statoc" expression without variables
57
+ */
53
58
  export declare const executeExpression: (expression: undefined | string) => any;
@@ -1,21 +1,21 @@
1
1
  import { z } from "zod";
2
- export declare const Templates: z.ZodEnum<["vanilla", "vercel", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>;
2
+ export declare const Templates: z.ZodEnum<["vanilla", "docker", "vercel", "vercel-legacy", "netlify", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>;
3
3
  export type Templates = z.infer<typeof Templates>;
4
4
  export declare const Deployment: z.ZodUnion<[z.ZodObject<{
5
5
  destination: z.ZodLiteral<"static">;
6
6
  name: z.ZodString;
7
7
  assetsDomain: z.ZodString;
8
- templates: z.ZodArray<z.ZodEnum<["vanilla", "vercel", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>, "many">;
8
+ templates: z.ZodArray<z.ZodEnum<["vanilla", "docker", "vercel", "vercel-legacy", "netlify", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>, "many">;
9
9
  }, "strip", z.ZodTypeAny, {
10
10
  name: string;
11
11
  destination: "static";
12
12
  assetsDomain: string;
13
- templates: ("vanilla" | "vercel" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
13
+ templates: ("vanilla" | "docker" | "vercel" | "vercel-legacy" | "netlify" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
14
14
  }, {
15
15
  name: string;
16
16
  destination: "static";
17
17
  assetsDomain: string;
18
- templates: ("vanilla" | "vercel" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
18
+ templates: ("vanilla" | "docker" | "vercel" | "vercel-legacy" | "netlify" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
19
19
  }>, z.ZodObject<{
20
20
  destination: z.ZodOptional<z.ZodLiteral<"saas">>;
21
21
  domains: z.ZodArray<z.ZodString, "many">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk",
3
- "version": "0.0.0-4f7bf18",
3
+ "version": "0.0.0-5558cd0",
4
4
  "description": "Webstudio project data schema",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -39,15 +39,15 @@
39
39
  "reserved-identifiers": "^1.0.0",
40
40
  "type-fest": "^4.32.0",
41
41
  "zod": "^3.22.4",
42
- "@webstudio-is/css-engine": "0.0.0-4f7bf18",
43
- "@webstudio-is/icons": "0.0.0-4f7bf18",
44
- "@webstudio-is/fonts": "0.0.0-4f7bf18"
42
+ "@webstudio-is/css-engine": "0.0.0-5558cd0",
43
+ "@webstudio-is/icons": "0.0.0-5558cd0",
44
+ "@webstudio-is/fonts": "0.0.0-5558cd0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "html-tags": "^4.0.0",
48
- "vitest": "^3.0.2",
48
+ "vitest": "^3.0.4",
49
49
  "@webstudio-is/css-data": "0.0.0",
50
- "@webstudio-is/template": "0.0.0-4f7bf18",
50
+ "@webstudio-is/template": "0.0.0-5558cd0",
51
51
  "@webstudio-is/tsconfig": "1.0.7"
52
52
  },
53
53
  "scripts": {