@paged-media/plugin-sdk 0.2.45-canary.0 → 0.2.46-canary.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.js +15 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7637,9 +7637,10 @@ function normalizeCoreType(t) {
|
|
|
7637
7637
|
case "point":
|
|
7638
7638
|
return { kind: t.kind };
|
|
7639
7639
|
case "number": {
|
|
7640
|
-
|
|
7640
|
+
const keywords = t.members?.length ? { keywords: [...t.members] } : {};
|
|
7641
|
+
if (t.unit === "count") return { kind: "number", integer: true, ...keywords };
|
|
7641
7642
|
const unit = t.unit ? UNIT[t.unit] : void 0;
|
|
7642
|
-
return unit ? { kind: "number", unit } : { kind: "number" };
|
|
7643
|
+
return unit ? { kind: "number", unit, ...keywords } : { kind: "number", ...keywords };
|
|
7643
7644
|
}
|
|
7644
7645
|
case "enum":
|
|
7645
7646
|
return { kind: "enum", members: [...t.members ?? []] };
|
|
@@ -8397,6 +8398,13 @@ function checkValueType(t, at = "type") {
|
|
|
8397
8398
|
return `${at}: an enum needs a non-empty members[]`;
|
|
8398
8399
|
}
|
|
8399
8400
|
return null;
|
|
8401
|
+
case "number": {
|
|
8402
|
+
const kw = v["keywords"];
|
|
8403
|
+
if (kw !== void 0 && (!Array.isArray(kw) || !kw.every((m) => typeof m === "string"))) {
|
|
8404
|
+
return `${at}: a number's keywords must be strings`;
|
|
8405
|
+
}
|
|
8406
|
+
return null;
|
|
8407
|
+
}
|
|
8400
8408
|
case "ref":
|
|
8401
8409
|
return typeof v["to"] === "string" && v["to"].length > 0 ? null : `${at}: a ref needs "to"`;
|
|
8402
8410
|
case "list":
|
|
@@ -8457,7 +8465,10 @@ function validateValue(type, value, row, at = "value") {
|
|
|
8457
8465
|
case "bool":
|
|
8458
8466
|
return typeof value === "boolean" ? null : `${at} must be a boolean`;
|
|
8459
8467
|
case "number":
|
|
8460
|
-
if (
|
|
8468
|
+
if (typeof value === "string" && type.keywords?.includes(value)) return null;
|
|
8469
|
+
if (!isNum(value)) {
|
|
8470
|
+
return type.keywords?.length ? `${at} must be a number or one of ${type.keywords.join(" | ")}` : `${at} must be a number`;
|
|
8471
|
+
}
|
|
8461
8472
|
if (type.integer && !Number.isInteger(value)) return `${at} must be an integer`;
|
|
8462
8473
|
return range(value);
|
|
8463
8474
|
case "length":
|
|
@@ -8601,6 +8612,7 @@ function coerceValue(type, input) {
|
|
|
8601
8612
|
if (/^(false|no|0|off)$/i.test(text2)) return ok(false);
|
|
8602
8613
|
return { ok: false, reason: `"${input}" is not a boolean` };
|
|
8603
8614
|
case "number": {
|
|
8615
|
+
if (type.keywords?.includes(text2)) return ok(text2);
|
|
8604
8616
|
const n = Number(text2.replace(/%$/, ""));
|
|
8605
8617
|
return text2 !== "" && Number.isFinite(n) ? ok(n) : { ok: false, reason: `"${input}" is not a number` };
|
|
8606
8618
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paged-media/plugin-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.46-canary.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@paged-media/plugin-api": "0.2.
|
|
14
|
+
"@paged-media/plugin-api": "0.2.46-canary.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": "^18.3.0"
|