@seed-hypermedia/client 0.0.124 → 0.0.126

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.
@@ -788,7 +788,15 @@ function parseMarkdown(markdown, options = {}) {
788
788
  }
789
789
  }
790
790
  const finalize = (nodes) => {
791
+ var _a2;
791
792
  for (const n of nodes) {
793
+ const explicit = (_a2 = n.block.attributes) == null ? void 0 : _a2.childrenType;
794
+ if (typeof explicit === "string") {
795
+ const { childrenType: _childrenType, ...rest } = n.block.attributes;
796
+ n.block.childrenType = explicit;
797
+ if (Object.keys(rest).length) n.block.attributes = rest;
798
+ else delete n.block.attributes;
799
+ }
792
800
  if (n.children.length && !n.block.childrenType && n.block.type !== "Table" && n.block.type !== "TableRow") {
793
801
  n.block.childrenType = "Group";
794
802
  }
@@ -130,7 +130,10 @@ function parseScalar(value) {
130
130
  return value;
131
131
  }
132
132
  function quoteExploreValue(value) {
133
- return /[\s()"=<>~^]/.test(value) ? `"${value.replace(/"/g, '\\"')}"` : value;
133
+ return value === "" || /[\s()"=<>~^]/.test(value) || typeof parseScalar(value) !== "string" ? `"${value.replace(/"/g, '\\"')}"` : value;
134
+ }
135
+ function quoteExploreKey(key) {
136
+ return /[\s()"=<>~^:!]/.test(key) ? `"${key.replace(/"/g, '\\"')}"` : key;
134
137
  }
135
138
  function flatten(kind, children) {
136
139
  const flattened = children.flatMap((child) => child.kind === kind ? child.children : [child]);
@@ -206,7 +209,7 @@ var ExploreParser = class {
206
209
  return this.parsePrimary();
207
210
  }
208
211
  parsePrimary() {
209
- var _a;
212
+ var _a, _b;
210
213
  const token = this.current();
211
214
  if (!token) return null;
212
215
  if (token.kind === "lparen") {
@@ -222,7 +225,8 @@ var ExploreParser = class {
222
225
  return null;
223
226
  }
224
227
  this.index++;
225
- if (token.kind === "quoted") return { kind: "text", value: token.value, phrase: true };
228
+ if (token.kind === "quoted" && ((_b = this.current()) == null ? void 0 : _b.kind) !== "operator")
229
+ return { kind: "text", value: token.value, phrase: true };
226
230
  const operator = this.current();
227
231
  if ((operator == null ? void 0 : operator.kind) !== "operator") return { kind: "text", value: token.value, phrase: false };
228
232
  this.index++;
@@ -271,7 +275,19 @@ var ExploreParser = class {
271
275
  );
272
276
  return { kind: "text", value: `${token.value}${operator.value}${value}`, phrase: false };
273
277
  }
274
- if ((token.value === "has" || token.value === "missing") && operator.value === ":") {
278
+ if (token.kind === "word" && token.value === "empty" && operator.value === ":") {
279
+ return {
280
+ kind: "or",
281
+ children: [
282
+ { kind: "predicate", predicate: { kind: "attribute", key: value, operator: "missing" } },
283
+ {
284
+ kind: "predicate",
285
+ predicate: { kind: "attribute", key: value, operator: "comparison", comparison: "=", value: "" }
286
+ }
287
+ ]
288
+ };
289
+ }
290
+ if (token.kind === "word" && (token.value === "has" || token.value === "missing") && operator.value === ":") {
275
291
  return {
276
292
  kind: "predicate",
277
293
  predicate: { kind: "attribute", key: value, operator: token.value === "has" ? "exists" : "missing" }
@@ -296,7 +312,8 @@ var ExploreParser = class {
296
312
  key: token.value,
297
313
  operator: "comparison",
298
314
  comparison: operator.value,
299
- value: parseScalar(value)
315
+ // A quoted value is a string even when it looks like a number: `version="3"`.
316
+ value: valueToken.kind === "quoted" ? value : parseScalar(value)
300
317
  }
301
318
  };
302
319
  }
@@ -324,11 +341,12 @@ function serializePredicate(predicate) {
324
341
  return `path:${pathPredicate.value}${pathPredicate.prefix ? "/*" : ""}`;
325
342
  }
326
343
  if (predicate.operator === "exists" || predicate.operator === "missing")
327
- return `${predicate.operator === "exists" ? "has" : "missing"}:${predicate.key}`;
328
- if (predicate.operator === "contains") return `${predicate.key}:${quoteExploreValue(predicate.value)}`;
329
- if (predicate.operator === "prefix") return `${predicate.key}^${quoteExploreValue(predicate.value)}`;
344
+ return `${predicate.operator === "exists" ? "has" : "missing"}:${quoteExploreKey(predicate.key)}`;
345
+ if (predicate.operator === "contains")
346
+ return `${quoteExploreKey(predicate.key)}:${quoteExploreValue(predicate.value)}`;
347
+ if (predicate.operator === "prefix") return `${quoteExploreKey(predicate.key)}^${quoteExploreValue(predicate.value)}`;
330
348
  const comparison = predicate;
331
- return `${comparison.key}${comparison.comparison}${typeof comparison.value === "string" ? quoteExploreValue(comparison.value) : String(comparison.value)}`;
349
+ return `${quoteExploreKey(comparison.key)}${comparison.comparison}${typeof comparison.value === "string" ? quoteExploreValue(comparison.value) : String(comparison.value)}`;
332
350
  }
333
351
  function serializeNode(node, parentPrecedence = 0) {
334
352
  let value;
package/dist/index.mjs CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  parseFrontmatter,
27
27
  parseInlineFormatting,
28
28
  parseMarkdown
29
- } from "./chunk-4WRPNPEJ.mjs";
29
+ } from "./chunk-SUVJSSHG.mjs";
30
30
  import {
31
31
  InvalidMermaidError,
32
32
  assertValidMermaid,
@@ -8,7 +8,7 @@ import {
8
8
  parseFrontmatter,
9
9
  parseInlineFormatting,
10
10
  parseMarkdown
11
- } from "./chunk-4WRPNPEJ.mjs";
11
+ } from "./chunk-SUVJSSHG.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
14
14
  MarkdownFrontmatterError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-hypermedia/client",
3
- "version": "0.0.124",
3
+ "version": "0.0.126",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/seed-hypermedia/seed",