@seed-hypermedia/client 0.0.84 → 0.0.85

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 (32) hide show
  1. package/dist/auto-link.mjs +3 -3
  2. package/dist/blocks-to-markdown.mjs +2 -2
  3. package/dist/capability.mjs +2 -2
  4. package/dist/{chunk-7UTCJZPQ.mjs → chunk-7DJW6A2P.mjs} +3 -3
  5. package/dist/{chunk-IQONPGLX.mjs → chunk-7QKG43UV.mjs} +2 -2
  6. package/dist/{chunk-TSUQYYH6.mjs → chunk-DVJ3XGXS.mjs} +1 -1
  7. package/dist/{chunk-PEG3UOMI.mjs → chunk-E2UOAVXB.mjs} +2 -2
  8. package/dist/{chunk-Q7YPP3WO.mjs → chunk-GIO2JLKT.mjs} +35 -0
  9. package/dist/{chunk-Q2NA774U.mjs → chunk-GN76IN3M.mjs} +8 -3
  10. package/dist/{chunk-X4VXKKMT.mjs → chunk-GVFAXUKA.mjs} +10 -8
  11. package/dist/{chunk-LQMTE724.mjs → chunk-I273FRIR.mjs} +1 -1
  12. package/dist/{chunk-MTGPGNGT.mjs → chunk-IW5GLPEG.mjs} +5 -4
  13. package/dist/{chunk-N3P7S5YZ.mjs → chunk-JKKS35IS.mjs} +1 -1
  14. package/dist/{chunk-NGLLI4HI.mjs → chunk-NR2TW5BW.mjs} +1 -1
  15. package/dist/{chunk-LMWLJHSM.mjs → chunk-QRWRLUTY.mjs} +1 -1
  16. package/dist/{chunk-73JZJ5YC.mjs → chunk-STKAE4YB.mjs} +1 -1
  17. package/dist/{chunk-5OEUIK3L.mjs → chunk-ZVJGJE2L.mjs} +1 -1
  18. package/dist/client.mjs +2 -2
  19. package/dist/comment.mjs +3 -3
  20. package/dist/document-state.mjs +2 -2
  21. package/dist/editor-types.d.ts +2 -0
  22. package/dist/editorblock-to-hmblock.mjs +3 -3
  23. package/dist/hm-resolver.mjs +2 -2
  24. package/dist/hm-types.d.ts +2519 -754
  25. package/dist/hm-types.mjs +5 -1
  26. package/dist/hmblock-to-editorblock.mjs +2 -2
  27. package/dist/index.mjs +14 -14
  28. package/dist/pdf-to-blocks.mjs +3 -3
  29. package/dist/resource-read.mjs +4 -4
  30. package/dist/tei-to-blocks.mjs +2 -2
  31. package/dist/unicode.mjs +2 -2
  32. package/package.json +1 -1
@@ -4,13 +4,13 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-PEG3UOMI.mjs";
7
+ } from "./chunk-E2UOAVXB.mjs";
8
8
  import "./chunk-W7H2UYQL.mjs";
9
9
  import "./chunk-PJ2RFT5A.mjs";
10
- import "./chunk-73JZJ5YC.mjs";
10
+ import "./chunk-STKAE4YB.mjs";
11
11
  import "./chunk-LVAHHQIK.mjs";
12
12
  import "./chunk-DR3HJ6BV.mjs";
13
- import "./chunk-Q7YPP3WO.mjs";
13
+ import "./chunk-GIO2JLKT.mjs";
14
14
  import "./chunk-7P6ASYW6.mjs";
15
15
  export {
16
16
  autoLinkChildToParent,
@@ -7,8 +7,8 @@ import {
7
7
  emitFrontmatter,
8
8
  parseDraftFilename,
9
9
  slugify
10
- } from "./chunk-X4VXKKMT.mjs";
11
- import "./chunk-Q7YPP3WO.mjs";
10
+ } from "./chunk-GVFAXUKA.mjs";
11
+ import "./chunk-GIO2JLKT.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
14
14
  blocksToMarkdown,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createCapability,
3
3
  resolveCapability
4
- } from "./chunk-LQMTE724.mjs";
4
+ } from "./chunk-I273FRIR.mjs";
5
5
  import "./chunk-LVAHHQIK.mjs";
6
6
  import "./chunk-NBCHK76Q.mjs";
7
7
  import "./chunk-DR3HJ6BV.mjs";
8
- import "./chunk-Q7YPP3WO.mjs";
8
+ import "./chunk-GIO2JLKT.mjs";
9
9
  import "./chunk-3TPCJCVO.mjs";
10
10
  import "./chunk-7P6ASYW6.mjs";
11
11
  export {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  resolveId
3
- } from "./chunk-TSUQYYH6.mjs";
3
+ } from "./chunk-DVJ3XGXS.mjs";
4
4
  import {
5
5
  createSeedClient
6
- } from "./chunk-NGLLI4HI.mjs";
6
+ } from "./chunk-NR2TW5BW.mjs";
7
7
  import {
8
8
  unpackHmId
9
- } from "./chunk-Q7YPP3WO.mjs";
9
+ } from "./chunk-GIO2JLKT.mjs";
10
10
 
11
11
  // src/resource-read.ts
12
12
  async function resolveIdWithClient(rawId, options = {}) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  validateExclusiveAnnotations
3
- } from "./chunk-N3P7S5YZ.mjs";
3
+ } from "./chunk-JKKS35IS.mjs";
4
4
  import {
5
5
  signObject,
6
6
  signerPublicKey,
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  hmIdPathToEntityQueryPath,
11
11
  packHmId
12
- } from "./chunk-Q7YPP3WO.mjs";
12
+ } from "./chunk-GIO2JLKT.mjs";
13
13
 
14
14
  // src/comment.ts
15
15
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -2,7 +2,7 @@ import {
2
2
  entityQueryPathToHmIdPath,
3
3
  parseFragment,
4
4
  unpackHmId
5
- } from "./chunk-Q7YPP3WO.mjs";
5
+ } from "./chunk-GIO2JLKT.mjs";
6
6
 
7
7
  // src/hm-resolver.ts
8
8
  async function resolveHypermediaUrl(url, opts) {
@@ -7,12 +7,12 @@ import {
7
7
  } from "./chunk-PJ2RFT5A.mjs";
8
8
  import {
9
9
  resolveDocumentState
10
- } from "./chunk-73JZJ5YC.mjs";
10
+ } from "./chunk-STKAE4YB.mjs";
11
11
  import {
12
12
  entityQueryPathToHmIdPath,
13
13
  packHmId,
14
14
  unpackHmId
15
- } from "./chunk-Q7YPP3WO.mjs";
15
+ } from "./chunk-GIO2JLKT.mjs";
16
16
 
17
17
  // src/auto-link.ts
18
18
  import { CID } from "multiformats/cid";
@@ -76,6 +76,7 @@ var LinkAnnotationSchema = z.object({
76
76
  var InlineEmbedAnnotationSchema = z.object({
77
77
  type: z.literal("Embed"),
78
78
  ...baseAnnotationProperties,
79
+ attributes: z.object({ mentionKind: z.enum(["account", "document"]).optional() }).optional(),
79
80
  link: z.string()
80
81
  }).strict();
81
82
  var HighlightAnnotationSchema = z.object({
@@ -880,6 +881,36 @@ var HMSearchRequestSchema = z.object({
880
881
  input: HMSearchInputSchema,
881
882
  output: HMSearchPayloadSchema
882
883
  });
884
+ var HMMentionCandidateSchema = z.object({
885
+ id: unpackedHmIdSchema,
886
+ type: z.enum(["account", "document"]),
887
+ title: z.string(),
888
+ icon: z.string(),
889
+ parentNames: z.array(z.string()),
890
+ searchQuery: z.string(),
891
+ /** Requested account identity before the daemon resolves an account alias. */
892
+ sourceAccountUid: z.string().optional(),
893
+ publicName: z.string().optional(),
894
+ petname: z.string().optional(),
895
+ activityTime: z.number().optional(),
896
+ activityType: z.enum(["publication", "comment"]).optional(),
897
+ accountRole: z.enum(["site-owner", "site-editor", "document-editor", "site-follower"]).optional(),
898
+ sameSite: z.boolean(),
899
+ issuedContact: z.boolean(),
900
+ hint: z.string().optional()
901
+ });
902
+ var HMMentionCandidatesRequestSchema = z.object({
903
+ key: z.literal("MentionCandidates"),
904
+ input: z.object({
905
+ mode: z.enum(["account", "document"]),
906
+ query: z.string().trim(),
907
+ perspectiveAccountUid: z.string().optional(),
908
+ siteUid: z.string().optional(),
909
+ documentId: unpackedHmIdSchema.optional(),
910
+ seedIds: z.array(unpackedHmIdSchema).max(20).optional()
911
+ }),
912
+ output: z.array(HMMentionCandidateSchema).max(100)
913
+ });
883
914
  var HMQueryRequestSchema = z.object({
884
915
  key: z.literal("Query"),
885
916
  input: HMQuerySchema,
@@ -1248,6 +1279,7 @@ var HMGetRequestSchema = z.discriminatedUnion("key", [
1248
1279
  HMAccountRequestSchema,
1249
1280
  HMCommentRequestSchema,
1250
1281
  HMSearchRequestSchema,
1282
+ HMMentionCandidatesRequestSchema,
1251
1283
  HMQueryRequestSchema,
1252
1284
  HMQueryBlockRequestSchema,
1253
1285
  HMAccountContactsRequestSchema,
@@ -1280,6 +1312,7 @@ var HMRequestSchema = z.discriminatedUnion("key", [
1280
1312
  HMAccountRequestSchema,
1281
1313
  HMCommentRequestSchema,
1282
1314
  HMSearchRequestSchema,
1315
+ HMMentionCandidatesRequestSchema,
1283
1316
  HMQueryRequestSchema,
1284
1317
  HMQueryBlockRequestSchema,
1285
1318
  HMAccountContactsRequestSchema,
@@ -1570,6 +1603,8 @@ export {
1570
1603
  HMSearchResultItemSchema,
1571
1604
  HMSearchPayloadSchema,
1572
1605
  HMSearchRequestSchema,
1606
+ HMMentionCandidateSchema,
1607
+ HMMentionCandidatesRequestSchema,
1573
1608
  HMQueryRequestSchema,
1574
1609
  HMQueryBlockInputSchema,
1575
1610
  HMListCommentsInputSchema,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  AnnotationSet
3
- } from "./chunk-N3P7S5YZ.mjs";
3
+ } from "./chunk-JKKS35IS.mjs";
4
4
  import {
5
5
  HMBlockButtonAlignmentSchema,
6
6
  HMBlockSchema,
7
7
  codePointLength,
8
8
  toNumber
9
- } from "./chunk-Q7YPP3WO.mjs";
9
+ } from "./chunk-GIO2JLKT.mjs";
10
10
 
11
11
  // src/editorblock-to-hmblock.ts
12
12
  function toHMBlockType(editorBlockType) {
@@ -108,7 +108,12 @@ function editorBlockToHMBlock(editorBlock) {
108
108
  annotations.addSpan("Math", null, start, end);
109
109
  }
110
110
  if (leaf.type == "inline-embed") {
111
- annotations.addSpan("Embed", { link: leaf.link }, start, end);
111
+ annotations.addSpan(
112
+ "Embed",
113
+ { link: leaf.link, ...leaf.mentionKind ? { mentionKind: leaf.mentionKind } : {} },
114
+ start,
115
+ end
116
+ );
112
117
  }
113
118
  if (leaf.type == "link") {
114
119
  annotations.addSpan("Link", { link: leaf.href }, start, end);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  normalizeQuerySort,
3
3
  unpackHmId
4
- } from "./chunk-Q7YPP3WO.mjs";
4
+ } from "./chunk-GIO2JLKT.mjs";
5
5
 
6
6
  // src/blocks-to-markdown.ts
7
7
  import { stringify as stringifyYaml } from "yaml";
@@ -691,12 +691,13 @@ async function getResolvedAnnotationMarker(ann, type, ctx) {
691
691
  }
692
692
  }
693
693
  async function resolveInlineEmbed(ann, type, ctx) {
694
+ var _a;
694
695
  const link = "link" in ann ? ann.link || "" : "";
695
696
  if (type === "close") return `](${link})`;
696
697
  if (!link) return "[\u2197 embed";
697
698
  try {
698
- const resolved = await resolveReference(link, ctx);
699
- const prefix = resolved.type === "account" ? "@" : "";
699
+ const resolved = await resolveReference(link, ctx, ann.type === "Embed" ? (_a = ann.attributes) == null ? void 0 : _a.mentionKind : void 0);
700
+ const prefix = resolved.type === "account" && !resolved.label.startsWith("@") ? "@" : "";
700
701
  return `[${prefix}${resolved.label}`;
701
702
  } catch {
702
703
  return `[\u2197 ${fallbackLabel(link)}`;
@@ -740,20 +741,21 @@ async function resolveEmbeddedResource(link, ctx) {
740
741
  ctx.cache.set(cacheKey, resolved);
741
742
  return resolved;
742
743
  }
743
- async function resolveReference(link, ctx) {
744
+ async function resolveReference(link, ctx, mentionKind) {
744
745
  var _a, _b, _c, _d, _e;
745
- const cached = ctx.cache.get(link);
746
+ const cacheKey = `${mentionKind || "legacy"}:${link}`;
747
+ const cached = ctx.cache.get(cacheKey);
746
748
  if (cached) return cached;
747
749
  const id = unpackHmId(link);
748
750
  if (!id) throw new Error("Invalid HM link");
749
751
  let resolved;
750
752
  const profileAccountUid = ((_a = id.path) == null ? void 0 : _a[0]) === ":profile" ? id.path[1] || id.uid : !((_b = id.path) == null ? void 0 : _b.length) ? id.uid : null;
751
- if (profileAccountUid) {
753
+ if (profileAccountUid && mentionKind !== "document") {
752
754
  try {
753
755
  const account = await ctx.client.request("Account", profileAccountUid);
754
756
  if (account.type === "account") {
755
757
  resolved = { label: ((_c = account.metadata) == null ? void 0 : _c.name) || fallbackUid(profileAccountUid), type: "account" };
756
- ctx.cache.set(link, resolved);
758
+ ctx.cache.set(cacheKey, resolved);
757
759
  return resolved;
758
760
  }
759
761
  } catch {
@@ -786,7 +788,7 @@ async function resolveReference(link, ctx) {
786
788
  } else {
787
789
  resolved = { label: fallbackLabel(link), type: "unknown" };
788
790
  }
789
- ctx.cache.set(link, resolved);
791
+ ctx.cache.set(cacheKey, resolved);
790
792
  return resolved;
791
793
  }
792
794
  function findBlockById(content, blockId) {
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packBaseId
10
- } from "./chunk-Q7YPP3WO.mjs";
10
+ } from "./chunk-GIO2JLKT.mjs";
11
11
 
12
12
  // src/capability.ts
13
13
  import { base58btc } from "multiformats/bases/base58";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSurrogate
3
- } from "./chunk-Q7YPP3WO.mjs";
3
+ } from "./chunk-GIO2JLKT.mjs";
4
4
 
5
5
  // src/hmblock-to-editorblock.ts
6
6
  function toEditorBlockType(hmBlockType) {
@@ -193,7 +193,8 @@ function hmBlockToEditorBlock(block) {
193
193
  leaves.push({
194
194
  type: "inline-embed",
195
195
  styles: {},
196
- link: inlineEmbed.link
196
+ link: inlineEmbed.link,
197
+ ...inlineEmbed.mentionKind ? { mentionKind: inlineEmbed.mentionKind } : {}
197
198
  });
198
199
  skipToCodepoint(inlineEmbed.end);
199
200
  textStart = i;
@@ -420,7 +421,7 @@ function hmBlockToEditorBlock(block) {
420
421
  return annotationsChanged;
421
422
  }
422
423
  function findInlineEmbedStartingAt(pos2) {
423
- var _a2, _b2;
424
+ var _a2, _b2, _c2;
424
425
  const blockAnnotations = block.annotations;
425
426
  if (!blockAnnotations) return null;
426
427
  for (const annotation of blockAnnotations) {
@@ -430,7 +431,7 @@ function hmBlockToEditorBlock(block) {
430
431
  if (spanIndex === -1) continue;
431
432
  const end = (_b2 = annotationData.ends) == null ? void 0 : _b2[spanIndex];
432
433
  if (typeof end !== "number" || end <= pos2) continue;
433
- return { link: annotationData.link || "", end };
434
+ return { link: annotationData.link || "", end, mentionKind: (_c2 = annotationData.attributes) == null ? void 0 : _c2.mentionKind };
434
435
  }
435
436
  return null;
436
437
  }
@@ -28,7 +28,7 @@ var AnnotationSet = class {
28
28
  _annotationId(type, attributes) {
29
29
  if (attributes) {
30
30
  if (attributes.link) {
31
- return `${type}-${attributes.link}`;
31
+ return JSON.stringify([type, attributes.link, attributes.mentionKind || null]);
32
32
  }
33
33
  if (attributes.href) {
34
34
  return `${type}-${attributes.href}`;
@@ -15,7 +15,7 @@ import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-Q7YPP3WO.mjs";
18
+ } from "./chunk-GIO2JLKT.mjs";
19
19
 
20
20
  // src/client.ts
21
21
  import { encode as cborEncode } from "@ipld/dag-cbor";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-5OEUIK3L.mjs";
3
+ } from "./chunk-ZVJGJE2L.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-52P3E6H6.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  packHmId,
3
3
  unpackHmId
4
- } from "./chunk-Q7YPP3WO.mjs";
4
+ } from "./chunk-GIO2JLKT.mjs";
5
5
 
6
6
  // src/document-state.ts
7
7
  async function resolveDocumentState(client, targetId) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  codePointLength
3
- } from "./chunk-Q7YPP3WO.mjs";
3
+ } from "./chunk-GIO2JLKT.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
package/dist/client.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createSeedClient,
3
3
  deserializeQueryString
4
- } from "./chunk-NGLLI4HI.mjs";
4
+ } from "./chunk-NR2TW5BW.mjs";
5
5
  import "./chunk-CBELM7KX.mjs";
6
6
  import "./chunk-W7H2UYQL.mjs";
7
7
  import "./chunk-PJ2RFT5A.mjs";
8
8
  import "./chunk-LVAHHQIK.mjs";
9
9
  import "./chunk-DR3HJ6BV.mjs";
10
- import "./chunk-Q7YPP3WO.mjs";
10
+ import "./chunk-GIO2JLKT.mjs";
11
11
  import "./chunk-7P6ASYW6.mjs";
12
12
  export {
13
13
  createSeedClient,
package/dist/comment.mjs CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  deleteComment,
5
5
  trimTrailingEmptyBlocks,
6
6
  updateComment
7
- } from "./chunk-IQONPGLX.mjs";
8
- import "./chunk-N3P7S5YZ.mjs";
7
+ } from "./chunk-7QKG43UV.mjs";
8
+ import "./chunk-JKKS35IS.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
11
- import "./chunk-Q7YPP3WO.mjs";
11
+ import "./chunk-GIO2JLKT.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
14
14
  commentRecordIdFromBlob,
@@ -4,8 +4,8 @@ import {
4
4
  followToDocument,
5
5
  resolveDocumentState,
6
6
  resolveEditableDocument
7
- } from "./chunk-73JZJ5YC.mjs";
8
- import "./chunk-Q7YPP3WO.mjs";
7
+ } from "./chunk-STKAE4YB.mjs";
8
+ import "./chunk-GIO2JLKT.mjs";
9
9
  import "./chunk-7P6ASYW6.mjs";
10
10
  export {
11
11
  describeRedirect,
@@ -158,6 +158,8 @@ export interface EditorLink {
158
158
  content: Array<HMInlineContent>;
159
159
  }
160
160
  export interface EditorInlineEmbed {
161
+ /** Explicit identity for new mentions; absent on legacy references. */
162
+ mentionKind?: 'account' | 'document';
161
163
  type: 'inline-embed';
162
164
  link: string;
163
165
  styles: EditorInlineStyles | {};
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  editorBlockToHMBlock,
3
3
  editorBlocksToHMBlockNodes
4
- } from "./chunk-Q2NA774U.mjs";
5
- import "./chunk-N3P7S5YZ.mjs";
6
- import "./chunk-Q7YPP3WO.mjs";
4
+ } from "./chunk-GN76IN3M.mjs";
5
+ import "./chunk-JKKS35IS.mjs";
6
+ import "./chunk-GIO2JLKT.mjs";
7
7
  import "./chunk-7P6ASYW6.mjs";
8
8
  export {
9
9
  editorBlockToHMBlock,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  resolveHypermediaUrl,
3
3
  resolveId
4
- } from "./chunk-TSUQYYH6.mjs";
5
- import "./chunk-Q7YPP3WO.mjs";
4
+ } from "./chunk-DVJ3XGXS.mjs";
5
+ import "./chunk-GIO2JLKT.mjs";
6
6
  import "./chunk-7P6ASYW6.mjs";
7
7
  export {
8
8
  resolveHypermediaUrl,