@constela/core 0.17.4 → 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 +2 -2
- package/dist/index.js +19 -3
- package/package.json +1 -1
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,7 +989,7 @@ 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
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"];
|
|
@@ -1217,6 +1218,7 @@ function validateExpression(expr, path) {
|
|
|
1217
1218
|
}
|
|
1218
1219
|
break;
|
|
1219
1220
|
case "state":
|
|
1221
|
+
case "local":
|
|
1220
1222
|
case "var":
|
|
1221
1223
|
if (typeof expr["name"] !== "string") {
|
|
1222
1224
|
return { path: path + "/name", message: "name is required" };
|
|
@@ -1323,8 +1325,10 @@ function validateExpression(expr, path) {
|
|
|
1323
1325
|
return { path: path + "/method", message: "method is required" };
|
|
1324
1326
|
}
|
|
1325
1327
|
{
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
+
if (expr["target"] !== null) {
|
|
1329
|
+
const targetError = validateExpression(expr["target"], path + "/target");
|
|
1330
|
+
if (targetError) return targetError;
|
|
1331
|
+
}
|
|
1328
1332
|
if ("args" in expr && expr["args"] !== void 0) {
|
|
1329
1333
|
if (!Array.isArray(expr["args"])) {
|
|
1330
1334
|
return { path: path + "/args", message: "args must be an array" };
|
|
@@ -1375,6 +1379,18 @@ function validateExpression(expr, path) {
|
|
|
1375
1379
|
if (itemError) return itemError;
|
|
1376
1380
|
}
|
|
1377
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;
|
|
1378
1394
|
}
|
|
1379
1395
|
return null;
|
|
1380
1396
|
}
|