@cancia/astro 0.9.0 → 0.10.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.
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-2NVZWZPE.js";
4
4
  import {
5
5
  isDraft
6
- } from "./chunk-WVHTCFE6.js";
6
+ } from "./chunk-YGJ3JHXF.js";
7
7
 
8
8
  // src/loader/index.ts
9
9
  import { join } from "path";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-VL6FO446.js";
4
4
  import {
5
5
  describeList
6
- } from "./chunk-WVHTCFE6.js";
6
+ } from "./chunk-YGJ3JHXF.js";
7
7
 
8
8
  // src/routes/schemas.ts
9
9
  function json(body, status = 200) {
@@ -93,7 +93,14 @@ var defineField = {
93
93
  */
94
94
  link: (o) => z.object({
95
95
  label: z.string(),
96
- href: z.string().refine(isSafeHref, "unsafe or unsupported URL scheme")
96
+ // An EMPTY href is allowed: it means "this link has no destination
97
+ // yet", which is a state the editor must be able to save — otherwise a
98
+ // client cannot clear a URL at all, and the form rejects a field they
99
+ // deliberately emptied. `isSafeHref("")` is false (correct for
100
+ // rendering, where an empty href must not become an anchor), so the
101
+ // empty case is permitted here explicitly rather than by loosening the
102
+ // guard. Anything non-empty still has to pass it.
103
+ href: z.string().refine((h) => h === "" || isSafeHref(h), "unsafe or unsupported URL scheme")
97
104
  }).meta({ widget: "link", ...o }),
98
105
  /**
99
106
  * A constrained rich-text body. Stored as a Portable-Text SUBSET array (D4):
package/dist/content.js CHANGED
@@ -20,17 +20,17 @@ function isSafeHref(href) {
20
20
  return true;
21
21
  }
22
22
  function parseLink(raw, fallback) {
23
- if (!raw) return fallback;
23
+ if (raw === void 0) return fallback;
24
+ if (raw === "") return { label: "", href: "" };
24
25
  const trimmed = raw.trim();
25
26
  if (trimmed.startsWith("{")) {
26
27
  try {
27
28
  const p = JSON.parse(trimmed);
28
29
  if (p && typeof p === "object") {
29
- const href = String(p.href ?? "");
30
- return {
31
- label: String(p.label ?? "") || fallback.label,
32
- href: href && isSafeHref(href) ? href : fallback.href
33
- };
30
+ const label = p.label === void 0 ? fallback.label : String(p.label);
31
+ const rawHref = p.href === void 0 ? void 0 : String(p.href);
32
+ const href = rawHref === void 0 ? fallback.href : rawHref === "" ? "" : isSafeHref(rawHref) ? rawHref : fallback.href;
33
+ return { label, href };
34
34
  }
35
35
  } catch {
36
36
  }
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  makeSchemasRoute
3
- } from "../chunk-HQIGNRIU.js";
3
+ } from "../chunk-ONKCUTPU.js";
4
4
  import "../chunk-VL6FO446.js";
5
- import "../chunk-WVHTCFE6.js";
5
+ import "../chunk-YGJ3JHXF.js";
6
6
  import "../chunk-KHCFVVYV.js";
7
7
 
8
8
  // src/endpoints/schemas.ts
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  makeSchemasRoute
3
- } from "./chunk-HQIGNRIU.js";
3
+ } from "./chunk-ONKCUTPU.js";
4
4
  import {
5
5
  runPublish
6
6
  } from "./chunk-5RCLBWRH.js";
@@ -30,7 +30,7 @@ import "./chunk-U7V53JX7.js";
30
30
  import "./chunk-VL6FO446.js";
31
31
  import {
32
32
  canciaLoader
33
- } from "./chunk-GBTFXQEA.js";
33
+ } from "./chunk-NVXNJ4YC.js";
34
34
  import {
35
35
  createJsonFileAdapter,
36
36
  createJsonFileAdapterV2
@@ -43,7 +43,7 @@ import {
43
43
  defineList,
44
44
  describeList,
45
45
  z
46
- } from "./chunk-WVHTCFE6.js";
46
+ } from "./chunk-YGJ3JHXF.js";
47
47
  import "./chunk-KHCFVVYV.js";
48
48
 
49
49
  // src/integration.ts
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  canciaLoader
3
- } from "../chunk-GBTFXQEA.js";
3
+ } from "../chunk-NVXNJ4YC.js";
4
4
  import "../chunk-2NVZWZPE.js";
5
5
  import "../chunk-7IA5B5CF.js";
6
- import "../chunk-WVHTCFE6.js";
6
+ import "../chunk-YGJ3JHXF.js";
7
7
  import "../chunk-KHCFVVYV.js";
8
8
  export {
9
9
  canciaLoader
@@ -8,7 +8,7 @@ import {
8
8
  serializeLinkValue,
9
9
  slugify,
10
10
  z
11
- } from "../chunk-WVHTCFE6.js";
11
+ } from "../chunk-YGJ3JHXF.js";
12
12
  import {
13
13
  PT_DECORATORS,
14
14
  PT_LIST_ITEMS,
@@ -44,11 +44,10 @@ function __canciaLink(cms, key, labelFallback, hrefFallback) {
44
44
  if (trimmed.startsWith("{")) {
45
45
  try {
46
46
  const parsed = JSON.parse(trimmed);
47
- const href = String(parsed.href ?? "");
48
- return {
49
- label: String(parsed.label ?? "") || labelFallback,
50
- href: href && isSafeHref(href) ? href : hrefFallback
51
- };
47
+ const label = parsed.label === void 0 ? labelFallback : String(parsed.label);
48
+ const rawHref = parsed.href === void 0 ? void 0 : String(parsed.href);
49
+ const href = rawHref === void 0 ? hrefFallback : rawHref === "" ? "" : isSafeHref(rawHref) ? rawHref : hrefFallback;
50
+ return { label, href };
52
51
  } catch {
53
52
  return fallback;
54
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cancia/astro",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Astro integration for Cancia CMS — inline editing with zero separate server",
5
5
  "license": "MIT",
6
6
  "repository": {