@constela/core 0.17.3 → 0.18.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/dist/index.d.ts CHANGED
@@ -50,7 +50,7 @@ declare function isThemeConfig(value: unknown): value is ThemeConfig;
50
50
  * for representing Constela UI applications.
51
51
  */
52
52
 
53
- declare const BINARY_OPERATORS: readonly ["+", "-", "*", "/", "==", "!=", "<", "<=", ">", ">=", "&&", "||"];
53
+ declare const BINARY_OPERATORS: readonly ["+", "-", "*", "/", "%", "==", "!=", "<", "<=", ">", ">=", "&&", "||"];
54
54
  type BinaryOperator = (typeof BINARY_OPERATORS)[number];
55
55
  declare const UPDATE_OPERATIONS: readonly ["increment", "decrement", "push", "pop", "remove", "toggle", "merge", "replaceAt", "insertAt", "splice"];
56
56
  type UpdateOperation = (typeof UPDATE_OPERATIONS)[number];
@@ -216,7 +216,7 @@ interface ValidityExpr {
216
216
  */
217
217
  interface CallExpr {
218
218
  expr: 'call';
219
- target: Expression;
219
+ target: Expression | null;
220
220
  method: string;
221
221
  args?: Expression[];
222
222
  }
package/dist/index.js CHANGED
@@ -50,6 +50,7 @@ var BINARY_OPERATORS = [
50
50
  "-",
51
51
  "*",
52
52
  "/",
53
+ "%",
53
54
  "==",
54
55
  "!=",
55
56
  "<",
@@ -988,9 +989,9 @@ function isObject3(value) {
988
989
  return typeof value === "object" && value !== null && !Array.isArray(value);
989
990
  }
990
991
  var VALID_VIEW_KINDS = ["element", "text", "if", "each", "component", "slot", "markdown", "code", "portal", "island"];
991
- var VALID_EXPR_TYPES = ["lit", "state", "var", "bin", "not", "param", "cond", "get", "style", "validity", "index", "call", "lambda", "array", "concat"];
992
+ var VALID_EXPR_TYPES = ["lit", "state", "local", "var", "bin", "not", "param", "cond", "get", "style", "validity", "index", "call", "lambda", "array", "concat", "obj"];
992
993
  var VALID_PARAM_TYPES = ["string", "number", "boolean", "json"];
993
- var VALID_ACTION_TYPES = ["set", "update", "setPath", "fetch", "delay", "interval", "clearTimer", "focus", "if", "storage", "dom"];
994
+ var VALID_ACTION_TYPES = ["set", "update", "setPath", "fetch", "delay", "interval", "clearTimer", "focus", "if", "storage", "dom", "sseConnect", "sseClose", "optimistic", "confirm", "reject"];
994
995
  var VALID_STATE_TYPES = ["number", "string", "list", "boolean", "object"];
995
996
  var VALID_BIN_OPS = BINARY_OPERATORS;
996
997
  var VALID_UPDATE_OPS = UPDATE_OPERATIONS;
@@ -1073,8 +1074,11 @@ function validateViewNode(node, path) {
1073
1074
  }
1074
1075
  if (node["props"] !== void 0 && isObject3(node["props"])) {
1075
1076
  for (const [propName, propValue] of Object.entries(node["props"])) {
1076
- const error = validateExpression(propValue, path + "/props/" + propName);
1077
- if (error) return error;
1077
+ if (isObject3(propValue) && "event" in propValue) {
1078
+ } else {
1079
+ const error = validateExpression(propValue, path + "/props/" + propName);
1080
+ if (error) return error;
1081
+ }
1078
1082
  }
1079
1083
  }
1080
1084
  if (Array.isArray(node["children"])) {
@@ -1214,6 +1218,7 @@ function validateExpression(expr, path) {
1214
1218
  }
1215
1219
  break;
1216
1220
  case "state":
1221
+ case "local":
1217
1222
  case "var":
1218
1223
  if (typeof expr["name"] !== "string") {
1219
1224
  return { path: path + "/name", message: "name is required" };
@@ -1320,8 +1325,10 @@ function validateExpression(expr, path) {
1320
1325
  return { path: path + "/method", message: "method is required" };
1321
1326
  }
1322
1327
  {
1323
- const targetError = validateExpression(expr["target"], path + "/target");
1324
- if (targetError) return targetError;
1328
+ if (expr["target"] !== null) {
1329
+ const targetError = validateExpression(expr["target"], path + "/target");
1330
+ if (targetError) return targetError;
1331
+ }
1325
1332
  if ("args" in expr && expr["args"] !== void 0) {
1326
1333
  if (!Array.isArray(expr["args"])) {
1327
1334
  return { path: path + "/args", message: "args must be an array" };
@@ -1372,6 +1379,18 @@ function validateExpression(expr, path) {
1372
1379
  if (itemError) return itemError;
1373
1380
  }
1374
1381
  break;
1382
+ case "obj":
1383
+ if (!("props" in expr)) {
1384
+ return { path: path + "/props", message: "props is required" };
1385
+ }
1386
+ if (!isObject3(expr["props"])) {
1387
+ return { path: path + "/props", message: "props must be an object" };
1388
+ }
1389
+ for (const [propKey, propValue] of Object.entries(expr["props"])) {
1390
+ const propError = validateExpression(propValue, path + "/props/" + propKey);
1391
+ if (propError) return propError;
1392
+ }
1393
+ break;
1375
1394
  }
1376
1395
  return null;
1377
1396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/core",
3
- "version": "0.17.3",
3
+ "version": "0.18.0",
4
4
  "description": "Core types, schema, and validator for Constela UI framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",