@constela/core 0.17.1 → 0.17.3
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.js +56 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -988,9 +988,9 @@ function isObject3(value) {
|
|
|
988
988
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
989
989
|
}
|
|
990
990
|
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"];
|
|
991
|
+
var VALID_EXPR_TYPES = ["lit", "state", "var", "bin", "not", "param", "cond", "get", "style", "validity", "index", "call", "lambda", "array", "concat"];
|
|
992
992
|
var VALID_PARAM_TYPES = ["string", "number", "boolean", "json"];
|
|
993
|
-
var VALID_ACTION_TYPES = ["set", "update", "setPath", "fetch", "delay", "interval", "clearTimer", "focus", "if"];
|
|
993
|
+
var VALID_ACTION_TYPES = ["set", "update", "setPath", "fetch", "delay", "interval", "clearTimer", "focus", "if", "storage", "dom"];
|
|
994
994
|
var VALID_STATE_TYPES = ["number", "string", "list", "boolean", "object"];
|
|
995
995
|
var VALID_BIN_OPS = BINARY_OPERATORS;
|
|
996
996
|
var VALID_UPDATE_OPS = UPDATE_OPERATIONS;
|
|
@@ -1360,6 +1360,18 @@ function validateExpression(expr, path) {
|
|
|
1360
1360
|
if (elemError) return elemError;
|
|
1361
1361
|
}
|
|
1362
1362
|
break;
|
|
1363
|
+
case "concat":
|
|
1364
|
+
if (!("items" in expr)) {
|
|
1365
|
+
return { path: path + "/items", message: "items is required" };
|
|
1366
|
+
}
|
|
1367
|
+
if (!Array.isArray(expr["items"])) {
|
|
1368
|
+
return { path: path + "/items", message: "items must be an array" };
|
|
1369
|
+
}
|
|
1370
|
+
for (let i = 0; i < expr["items"].length; i++) {
|
|
1371
|
+
const itemError = validateExpression(expr["items"][i], path + "/items/" + i);
|
|
1372
|
+
if (itemError) return itemError;
|
|
1373
|
+
}
|
|
1374
|
+
break;
|
|
1363
1375
|
}
|
|
1364
1376
|
return null;
|
|
1365
1377
|
}
|
|
@@ -1502,6 +1514,48 @@ function validateActionStep(step, path) {
|
|
|
1502
1514
|
}
|
|
1503
1515
|
}
|
|
1504
1516
|
break;
|
|
1517
|
+
case "storage":
|
|
1518
|
+
if (!("operation" in step)) {
|
|
1519
|
+
return { path: path + "/operation", message: "operation is required" };
|
|
1520
|
+
}
|
|
1521
|
+
if (!["get", "set", "remove"].includes(step["operation"])) {
|
|
1522
|
+
return { path: path + "/operation", message: "must be one of: get, set, remove" };
|
|
1523
|
+
}
|
|
1524
|
+
if (!("key" in step)) {
|
|
1525
|
+
return { path: path + "/key", message: "key is required" };
|
|
1526
|
+
}
|
|
1527
|
+
{
|
|
1528
|
+
const keyError = validateExpression(step["key"], path + "/key");
|
|
1529
|
+
if (keyError) return keyError;
|
|
1530
|
+
if (step["operation"] === "set" && "value" in step) {
|
|
1531
|
+
const valueError = validateExpression(step["value"], path + "/value");
|
|
1532
|
+
if (valueError) return valueError;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
break;
|
|
1536
|
+
case "dom":
|
|
1537
|
+
if (!("operation" in step)) {
|
|
1538
|
+
return { path: path + "/operation", message: "operation is required" };
|
|
1539
|
+
}
|
|
1540
|
+
if (!["addClass", "removeClass", "toggleClass", "setAttribute", "removeAttribute"].includes(step["operation"])) {
|
|
1541
|
+
return { path: path + "/operation", message: "must be one of: addClass, removeClass, toggleClass, setAttribute, removeAttribute" };
|
|
1542
|
+
}
|
|
1543
|
+
if (!("selector" in step)) {
|
|
1544
|
+
return { path: path + "/selector", message: "selector is required" };
|
|
1545
|
+
}
|
|
1546
|
+
{
|
|
1547
|
+
const selectorError = validateExpression(step["selector"], path + "/selector");
|
|
1548
|
+
if (selectorError) return selectorError;
|
|
1549
|
+
if ("value" in step) {
|
|
1550
|
+
const valueError = validateExpression(step["value"], path + "/value");
|
|
1551
|
+
if (valueError) return valueError;
|
|
1552
|
+
}
|
|
1553
|
+
if ("attribute" in step) {
|
|
1554
|
+
const attrError = validateExpression(step["attribute"], path + "/attribute");
|
|
1555
|
+
if (attrError) return attrError;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
break;
|
|
1505
1559
|
}
|
|
1506
1560
|
return null;
|
|
1507
1561
|
}
|