@seed-hypermedia/client 0.0.77 → 0.0.79

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 (36) 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-I6T7E6NR.mjs → chunk-3UP4S7XZ.mjs} +1 -1
  5. package/dist/{chunk-NXWZWZWS.mjs → chunk-473ELALL.mjs} +3 -3
  6. package/dist/{chunk-EGDF5YHG.mjs → chunk-4HJWSEWS.mjs} +5 -1
  7. package/dist/{chunk-E2S3ZLBH.mjs → chunk-5HHKGULK.mjs} +2 -2
  8. package/dist/{chunk-5ARN5GTL.mjs → chunk-AC3EMQZG.mjs} +1 -1
  9. package/dist/{chunk-YMF2Y7UO.mjs → chunk-AOCNYES4.mjs} +1 -1
  10. package/dist/{chunk-HYCHOIRR.mjs → chunk-CCVGF25A.mjs} +1 -1
  11. package/dist/{chunk-6ZDWVCC2.mjs → chunk-CVUWZ27W.mjs} +1 -1
  12. package/dist/{chunk-DBHL3BYB.mjs → chunk-EZ5UFUMQ.mjs} +78 -1
  13. package/dist/{chunk-FT4OR5WY.mjs → chunk-LJI66S7C.mjs} +1 -1
  14. package/dist/{chunk-YYQPNBQK.mjs → chunk-M7ZYWWI3.mjs} +1 -1
  15. package/dist/{chunk-LLRVL4BP.mjs → chunk-R5FOS4BW.mjs} +1 -1
  16. package/dist/{chunk-7UUGEBS3.mjs → chunk-UX7OUR3C.mjs} +1 -1
  17. package/dist/{chunk-3NKBUTZO.mjs → chunk-ZFQ6SZ5C.mjs} +1 -1
  18. package/dist/client.mjs +2 -2
  19. package/dist/comment.mjs +2 -2
  20. package/dist/document-state.mjs +2 -2
  21. package/dist/editorblock-to-hmblock.mjs +2 -2
  22. package/dist/hm-resolver.mjs +2 -2
  23. package/dist/hm-types.d.ts +81 -0
  24. package/dist/hm-types.mjs +1 -1
  25. package/dist/hmblock-to-editorblock.mjs +2 -2
  26. package/dist/index.mjs +13 -13
  27. package/dist/pdf-to-blocks.mjs +3 -3
  28. package/dist/resource-read.mjs +4 -4
  29. package/dist/tei-to-blocks.mjs +2 -2
  30. package/dist/unicode.mjs +1 -1
  31. package/dist/vault-local.mjs +1 -1
  32. package/dist/vault-merge.d.ts +67 -0
  33. package/dist/vault-merge.mjs +332 -0
  34. package/dist/vault.d.ts +23 -0
  35. package/dist/vault.mjs +9 -1
  36. package/package.json +1 -1
@@ -4,13 +4,13 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-E2S3ZLBH.mjs";
7
+ } from "./chunk-5HHKGULK.mjs";
8
8
  import "./chunk-JT57MV7Y.mjs";
9
9
  import "./chunk-PJ2RFT5A.mjs";
10
- import "./chunk-YYQPNBQK.mjs";
10
+ import "./chunk-M7ZYWWI3.mjs";
11
11
  import "./chunk-LVAHHQIK.mjs";
12
12
  import "./chunk-DR3HJ6BV.mjs";
13
- import "./chunk-EGDF5YHG.mjs";
13
+ import "./chunk-4HJWSEWS.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-7UUGEBS3.mjs";
11
- import "./chunk-EGDF5YHG.mjs";
10
+ } from "./chunk-UX7OUR3C.mjs";
11
+ import "./chunk-4HJWSEWS.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-3NKBUTZO.mjs";
4
+ } from "./chunk-ZFQ6SZ5C.mjs";
5
5
  import "./chunk-LVAHHQIK.mjs";
6
6
  import "./chunk-IT5LLTMP.mjs";
7
7
  import "./chunk-DR3HJ6BV.mjs";
8
- import "./chunk-EGDF5YHG.mjs";
8
+ import "./chunk-4HJWSEWS.mjs";
9
9
  import "./chunk-3TPCJCVO.mjs";
10
10
  import "./chunk-7P6ASYW6.mjs";
11
11
  export {
@@ -2,7 +2,7 @@ import {
2
2
  entityQueryPathToHmIdPath,
3
3
  parseFragment,
4
4
  unpackHmId
5
- } from "./chunk-EGDF5YHG.mjs";
5
+ } from "./chunk-4HJWSEWS.mjs";
6
6
 
7
7
  // src/hm-resolver.ts
8
8
  async function resolveHypermediaUrl(url, opts) {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  resolveId
3
- } from "./chunk-I6T7E6NR.mjs";
3
+ } from "./chunk-3UP4S7XZ.mjs";
4
4
  import {
5
5
  createSeedClient
6
- } from "./chunk-6ZDWVCC2.mjs";
6
+ } from "./chunk-CVUWZ27W.mjs";
7
7
  import {
8
8
  unpackHmId
9
- } from "./chunk-EGDF5YHG.mjs";
9
+ } from "./chunk-4HJWSEWS.mjs";
10
10
 
11
11
  // src/resource-read.ts
12
12
  async function resolveIdWithClient(rawId, options = {}) {
@@ -431,6 +431,8 @@ var HMDocumentInfoSchema = z.object({
431
431
  generationInfo: HMGenerationInfoSchema,
432
432
  redirectInfo: HMRedirectInfoSchema.optional(),
433
433
  metadata: HMDocumentMetadataSchema,
434
+ /** Folder status derived by the published-document indexer. */
435
+ isFolder: z.boolean().optional(),
434
436
  // Indexer-derived first image block of the document's content (reading
435
437
  // order), used as a fallback cover on directory cards without fetching the
436
438
  // full document. Undefined = not derived (yet); empty string = derived, the
@@ -767,7 +769,9 @@ var HMDraftMetaBaseSchema = z.object({
767
769
  // deps and navigation live in the index entry for .md drafts
768
770
  // (for .json drafts they come from the content file for backwards compat)
769
771
  deps: z.array(z.string().min(1)).default([]),
770
- navigation: z.array(HMNavigationItemSchema).optional()
772
+ navigation: z.array(HMNavigationItemSchema).optional(),
773
+ /** Folder status derived from the locally persisted draft content. */
774
+ isFolder: z.boolean().default(false)
771
775
  });
772
776
  var draftLocationRefinement = (data) => data.editUid || data.locationUid;
773
777
  var HMDraftMetaSchema = HMDraftMetaBaseSchema.refine(draftLocationRefinement, {
@@ -7,12 +7,12 @@ import {
7
7
  } from "./chunk-PJ2RFT5A.mjs";
8
8
  import {
9
9
  resolveDocumentState
10
- } from "./chunk-YYQPNBQK.mjs";
10
+ } from "./chunk-M7ZYWWI3.mjs";
11
11
  import {
12
12
  entityQueryPathToHmIdPath,
13
13
  packHmId,
14
14
  unpackHmId
15
- } from "./chunk-EGDF5YHG.mjs";
15
+ } from "./chunk-4HJWSEWS.mjs";
16
16
 
17
17
  // src/auto-link.ts
18
18
  import { CID } from "multiformats/cid";
@@ -6,7 +6,7 @@ import {
6
6
  HMBlockSchema,
7
7
  codePointLength,
8
8
  toNumber
9
- } from "./chunk-EGDF5YHG.mjs";
9
+ } from "./chunk-4HJWSEWS.mjs";
10
10
 
11
11
  // src/editorblock-to-hmblock.ts
12
12
  function toHMBlockType(editorBlockType) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSurrogate
3
- } from "./chunk-EGDF5YHG.mjs";
3
+ } from "./chunk-4HJWSEWS.mjs";
4
4
 
5
5
  // src/hmblock-to-editorblock.ts
6
6
  function toEditorBlockType(hmBlockType) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  codePointLength
3
- } from "./chunk-EGDF5YHG.mjs";
3
+ } from "./chunk-4HJWSEWS.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
@@ -15,7 +15,7 @@ import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-EGDF5YHG.mjs";
18
+ } from "./chunk-4HJWSEWS.mjs";
19
19
 
20
20
  // src/client.ts
21
21
  import { encode as cborEncode } from "@ipld/dag-cbor";
@@ -45,6 +45,76 @@ async function deserialize(compressed) {
45
45
  }
46
46
  return decodeState(decoded);
47
47
  }
48
+ async function serializeState(data) {
49
+ const encodedCb = cborg.encode(encodeStateGoParity(data), cborEncodeOpts);
50
+ return compress(new Uint8Array(encodedCb));
51
+ }
52
+ async function deserializeState(compressed) {
53
+ const decodedCb = await decompress(compressed);
54
+ const decoded = dagCBOR.decode(decodedCb);
55
+ if (decoded.version !== VAULT_VERSION) {
56
+ throw new Error(
57
+ `Vault schema version mismatch: stored version is ${decoded.version}, but this client expects version ${VAULT_VERSION}. The vault data is incompatible with this version of the application.`
58
+ );
59
+ }
60
+ return decodeStateGoParity(decoded);
61
+ }
62
+ function decodeStateGoParity(decoded) {
63
+ const accounts = Array.isArray(decoded.accounts) ? decoded.accounts.map((account) => fillEmptyAccountName(decodeAccountRaw(account))) : [];
64
+ const restored = {
65
+ version: VAULT_VERSION,
66
+ accounts
67
+ };
68
+ if (typeof decoded.notificationServerUrl === "string") {
69
+ restored.notificationServerUrl = decoded.notificationServerUrl;
70
+ }
71
+ if (isDeletedAccounts(decoded.deletedAccounts)) {
72
+ restored.deletedAccounts = { ...decoded.deletedAccounts };
73
+ }
74
+ restored[stateExtraKey] = omitKnown(decoded, ["version", "notificationServerUrl", "deletedAccounts", "accounts"]);
75
+ return restored;
76
+ }
77
+ function encodeStateGoParity(data) {
78
+ const encoded = {
79
+ ...data[stateExtraKey],
80
+ version: VAULT_VERSION,
81
+ accounts: data.accounts.map((account) => encodeAccountGoParity(account))
82
+ };
83
+ if (data.notificationServerUrl) {
84
+ encoded.notificationServerUrl = data.notificationServerUrl;
85
+ }
86
+ if (data.deletedAccounts && Object.keys(data.deletedAccounts).length > 0) {
87
+ encoded.deletedAccounts = data.deletedAccounts;
88
+ }
89
+ return encoded;
90
+ }
91
+ function encodeAccountGoParity(account) {
92
+ const filled = fillEmptyAccountName(account);
93
+ return {
94
+ ...filled[accountExtraKey],
95
+ seed: filled.seed,
96
+ createTime: filled.createTime,
97
+ delegations: (filled.delegations ?? []).map((delegation) => encodeDelegation(delegation)),
98
+ name: filled.name
99
+ };
100
+ }
101
+ function fillEmptyAccountName(account) {
102
+ if (typeof account.name === "string" && account.name.trim() !== "") return account;
103
+ return { ...account, name: accountIdFromSeed(account.seed) };
104
+ }
105
+ function getUnknownFields(target) {
106
+ return target[unknownFieldsKeyFor(target)] ?? {};
107
+ }
108
+ function setUnknownFields(target, extras) {
109
+ ;
110
+ target[unknownFieldsKeyFor(target)] = { ...extras };
111
+ }
112
+ function unknownFieldsKeyFor(target) {
113
+ if ("accounts" in target) return stateExtraKey;
114
+ if ("seed" in target) return accountExtraKey;
115
+ if ("capability" in target) return delegationExtraKey;
116
+ return capabilityExtraKey;
117
+ }
48
118
  function getAccountName(account) {
49
119
  const normalized = typeof account.name === "string" ? account.name.trim() : "";
50
120
  if (normalized && accountNamePattern.test(normalized)) {
@@ -99,6 +169,9 @@ function decodeState(decoded) {
99
169
  return restored;
100
170
  }
101
171
  function decodeAccount(decoded) {
172
+ return normalizeAccount(decodeAccountRaw(decoded));
173
+ }
174
+ function decodeAccountRaw(decoded) {
102
175
  const account = {
103
176
  name: typeof decoded.name === "string" ? decoded.name : void 0,
104
177
  seed: new Uint8Array(decoded.seed),
@@ -106,7 +179,7 @@ function decodeAccount(decoded) {
106
179
  delegations: Array.isArray(decoded.delegations) ? decoded.delegations.map((delegation) => decodeDelegation(delegation)) : []
107
180
  };
108
181
  account[accountExtraKey] = omitKnown(decoded, ["name", "seed", "createTime", "delegations"]);
109
- return normalizeAccount(account);
182
+ return account;
110
183
  }
111
184
  function decodeDelegation(decoded) {
112
185
  const delegation = {
@@ -314,6 +387,10 @@ export {
314
387
  createEmpty,
315
388
  serialize,
316
389
  deserialize,
390
+ serializeState,
391
+ deserializeState,
392
+ getUnknownFields,
393
+ setUnknownFields,
317
394
  getAccountName,
318
395
  deriveHKDFKey,
319
396
  deriveEncryptionKey,
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  hmIdPathToEntityQueryPath,
11
11
  packHmId
12
- } from "./chunk-EGDF5YHG.mjs";
12
+ } from "./chunk-4HJWSEWS.mjs";
13
13
 
14
14
  // src/comment.ts
15
15
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  packHmId,
3
3
  unpackHmId
4
- } from "./chunk-EGDF5YHG.mjs";
4
+ } from "./chunk-4HJWSEWS.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
  teiToBlocks
3
- } from "./chunk-HYCHOIRR.mjs";
3
+ } from "./chunk-CCVGF25A.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-52P3E6H6.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpackHmId
3
- } from "./chunk-EGDF5YHG.mjs";
3
+ } from "./chunk-4HJWSEWS.mjs";
4
4
 
5
5
  // src/blocks-to-markdown.ts
6
6
  var FM_STRING_KEYS = [
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packBaseId
10
- } from "./chunk-EGDF5YHG.mjs";
10
+ } from "./chunk-4HJWSEWS.mjs";
11
11
 
12
12
  // src/capability.ts
13
13
  import { base58btc } from "multiformats/bases/base58";
package/dist/client.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createSeedClient,
3
3
  deserializeQueryString
4
- } from "./chunk-6ZDWVCC2.mjs";
4
+ } from "./chunk-CVUWZ27W.mjs";
5
5
  import "./chunk-CBELM7KX.mjs";
6
6
  import "./chunk-JT57MV7Y.mjs";
7
7
  import "./chunk-PJ2RFT5A.mjs";
8
8
  import "./chunk-LVAHHQIK.mjs";
9
9
  import "./chunk-DR3HJ6BV.mjs";
10
- import "./chunk-EGDF5YHG.mjs";
10
+ import "./chunk-4HJWSEWS.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-FT4OR5WY.mjs";
7
+ } from "./chunk-LJI66S7C.mjs";
8
8
  import "./chunk-N3P7S5YZ.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
11
- import "./chunk-EGDF5YHG.mjs";
11
+ import "./chunk-4HJWSEWS.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-YYQPNBQK.mjs";
8
- import "./chunk-EGDF5YHG.mjs";
7
+ } from "./chunk-M7ZYWWI3.mjs";
8
+ import "./chunk-4HJWSEWS.mjs";
9
9
  import "./chunk-7P6ASYW6.mjs";
10
10
  export {
11
11
  describeRedirect,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  editorBlockToHMBlock,
3
3
  editorBlocksToHMBlockNodes
4
- } from "./chunk-5ARN5GTL.mjs";
4
+ } from "./chunk-AC3EMQZG.mjs";
5
5
  import "./chunk-N3P7S5YZ.mjs";
6
- import "./chunk-EGDF5YHG.mjs";
6
+ import "./chunk-4HJWSEWS.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-I6T7E6NR.mjs";
5
- import "./chunk-EGDF5YHG.mjs";
4
+ } from "./chunk-3UP4S7XZ.mjs";
5
+ import "./chunk-4HJWSEWS.mjs";
6
6
  import "./chunk-7P6ASYW6.mjs";
7
7
  export {
8
8
  resolveHypermediaUrl,