@paged-media/plugin-sdk 0.2.45-canary.0 → 0.2.47-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.
Files changed (2) hide show
  1. package/dist/index.js +19 -4
  2. 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
- if (t.unit === "count") return { kind: "number", integer: true };
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 (!isNum(value)) return `${at} must be a number`;
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
  }
@@ -8721,6 +8733,9 @@ function formatSelector(steps) {
8721
8733
  }
8722
8734
  return { text: text2, family };
8723
8735
  }
8736
+ function keywordOf(type, value) {
8737
+ return type.kind === "number" && typeof value === "string" && (type.keywords ?? []).includes(value);
8738
+ }
8724
8739
  function createCoreObjectsV71(getEditor, v70) {
8725
8740
  const client = () => getEditor().client;
8726
8741
  async function send(kind, payload) {
@@ -8830,7 +8845,7 @@ function createCoreObjectsV71(getEditor, v70) {
8830
8845
  }
8831
8846
  let wire;
8832
8847
  if (isRawWire2(value)) wire = value;
8833
- else if (row) wire = { type: row.wire, value };
8848
+ else if (row) wire = { type: keywordOf(row.schema.type, value) ? "enum" : row.wire, value };
8834
8849
  else if (CORE_OPERATION_PATHS.has(path)) return no2("invalidValue", `${path} is a geometry operation: pass its raw wire value { type, value }`);
8835
8850
  else return no2("unknownPath", `${kind || formatAddress(a)} has no path "${path}"`);
8836
8851
  const address = a.kind === "handle" ? formatAddress(a) : await target(a, row);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paged-media/plugin-sdk",
3
- "version": "0.2.45-canary.0",
3
+ "version": "0.2.47-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.45-canary.0"
14
+ "@paged-media/plugin-api": "0.2.47-canary.0"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "react": "^18.3.0"