@seed-hypermedia/client 0.0.86 → 0.0.88

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.
@@ -4,8 +4,8 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-E2UOAVXB.mjs";
8
- import "./chunk-W7H2UYQL.mjs";
7
+ } from "./chunk-J45O2Y7E.mjs";
8
+ import "./chunk-O5MHN2EO.mjs";
9
9
  import "./chunk-PJ2RFT5A.mjs";
10
10
  import "./chunk-STKAE4YB.mjs";
11
11
  import "./chunk-LVAHHQIK.mjs";
package/dist/change.d.ts CHANGED
@@ -72,6 +72,30 @@ export declare const signPreparedChange: (unsignedBytes: Uint8Array, signer: Any
72
72
  * Create a signed genesis Change blob (empty, ts=0).
73
73
  * This deterministic sentinel is only intended for home documents.
74
74
  */
75
+ /**
76
+ * The genesis Change of an account's HOME document (path ''), and of nothing else.
77
+ *
78
+ * It is deterministic on purpose: signer key plus a zero timestamp, and Ed25519 signatures
79
+ * are deterministic, so every device of an account derives the same home genesis and the
80
+ * daemon (`ensureProfileGenesis`) agrees with it. A document's identity is its genesis, so
81
+ * any OTHER document created on this genesis becomes the home document as far as the daemon
82
+ * is concerned: comments, activity and moves all merge. That is what happened to sixty
83
+ * papers created through document.create on 2026-09-15.
84
+ *
85
+ * A non-home document needs no genesis blob of its own: its first content Change IS its
86
+ * genesis. Build it with {@link createChangeOps} without `genesisCid`, and point the Version
87
+ * Ref's `genesis` and `version` at that Change's CID (what the CLI's `document create` does).
88
+ */
89
+ export declare function createHomeGenesisChange(signer: AnySigner): Promise<{
90
+ bytes: Uint8Array;
91
+ cid: CID;
92
+ }>;
93
+ /**
94
+ * @deprecated This is the HOME document's deterministic genesis; call
95
+ * {@link createHomeGenesisChange} when you mean that. For any other document do not create a
96
+ * genesis at all: its first content Change is its genesis (see createHomeGenesisChange).
97
+ * Using this for an ordinary document merges it with the home document.
98
+ */
75
99
  export declare function createGenesisChange(signer: AnySigner): Promise<{
76
100
  bytes: Uint8Array;
77
101
  cid: CID;
package/dist/change.mjs CHANGED
@@ -4,10 +4,11 @@ import {
4
4
  createDocumentChange,
5
5
  createDocumentChangeFromOps,
6
6
  createGenesisChange,
7
+ createHomeGenesisChange,
7
8
  signDocumentChange,
8
9
  signPreparedChange,
9
10
  visibilityToCbor
10
- } from "./chunk-W7H2UYQL.mjs";
11
+ } from "./chunk-O5MHN2EO.mjs";
11
12
  import "./chunk-PJ2RFT5A.mjs";
12
13
  import "./chunk-LVAHHQIK.mjs";
13
14
  import "./chunk-DR3HJ6BV.mjs";
@@ -18,6 +19,7 @@ export {
18
19
  createDocumentChange,
19
20
  createDocumentChangeFromOps,
20
21
  createGenesisChange,
22
+ createHomeGenesisChange,
21
23
  signDocumentChange,
22
24
  signPreparedChange,
23
25
  visibilityToCbor
@@ -352,8 +352,12 @@ async function extractTitle(doc) {
352
352
  }
353
353
  async function embeddedPdfToBlocks(pdfData) {
354
354
  let pdfjsLib;
355
+ const pdfjsSpecifier = "pdfjs-dist";
355
356
  try {
356
- pdfjsLib = await import("pdfjs-dist");
357
+ pdfjsLib = await import(
358
+ /* @vite-ignore */
359
+ pdfjsSpecifier
360
+ );
357
361
  } catch {
358
362
  throw new Error(
359
363
  "pdfjs-dist is not installed. Install it for embedded PDF extraction:\n pnpm add pdfjs-dist\nOr provide a GROBID server URL for higher-fidelity extraction."
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-ZVJGJE2L.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
- } from "./chunk-52P3E6H6.mjs";
6
+ } from "./chunk-2FJBS3V7.mjs";
7
7
  import {
8
8
  isGrobidAvailable,
9
9
  processFulltextDocument
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-DVJ3XGXS.mjs";
4
4
  import {
5
5
  createSeedClient
6
- } from "./chunk-NR2TW5BW.mjs";
6
+ } from "./chunk-W3MTG26Q.mjs";
7
7
  import {
8
8
  unpackHmId
9
9
  } from "./chunk-GIO2JLKT.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createChange,
3
3
  createChangeOps
4
- } from "./chunk-W7H2UYQL.mjs";
4
+ } from "./chunk-O5MHN2EO.mjs";
5
5
  import {
6
6
  createVersionRef
7
7
  } from "./chunk-PJ2RFT5A.mjs";
@@ -45,7 +45,7 @@ var signPreparedChange = async (unsignedBytes, signer) => {
45
45
  const result = await createChange(unsignedBytes, signer);
46
46
  return { signedBytes: result.bytes, cid: result.cid, genesis: result.genesis };
47
47
  };
48
- async function createGenesisChange(signer) {
48
+ async function createHomeGenesisChange(signer) {
49
49
  const pubKey = await signerPublicKey(signer);
50
50
  const unsigned = {
51
51
  type: "Change",
@@ -57,6 +57,9 @@ async function createGenesisChange(signer) {
57
57
  const block = await Block.encode({ value: unsigned, codec: cborCodec, hasher: sha256 });
58
58
  return { bytes: block.bytes, cid: block.cid };
59
59
  }
60
+ function createGenesisChange(signer) {
61
+ return createHomeGenesisChange(signer);
62
+ }
60
63
  async function createDocumentChangeFromOps(input, signer) {
61
64
  const { unsignedBytes, ts } = createChangeOps(input);
62
65
  const { bytes, cid } = await createChange(unsignedBytes, signer);
@@ -130,6 +133,7 @@ export {
130
133
  createChangeOps,
131
134
  createChange,
132
135
  signPreparedChange,
136
+ createHomeGenesisChange,
133
137
  createGenesisChange,
134
138
  createDocumentChangeFromOps,
135
139
  createDocumentChange,
@@ -5,9 +5,9 @@ import {
5
5
  } from "./chunk-CBELM7KX.mjs";
6
6
  import {
7
7
  createDocumentChange,
8
- createGenesisChange,
8
+ createHomeGenesisChange,
9
9
  signDocumentChange
10
- } from "./chunk-W7H2UYQL.mjs";
10
+ } from "./chunk-O5MHN2EO.mjs";
11
11
  import {
12
12
  createVersionRef
13
13
  } from "./chunk-PJ2RFT5A.mjs";
@@ -177,7 +177,7 @@ function createSeedClient(baseUrl, options) {
177
177
  }
178
178
  async function publishDocument(input, signer) {
179
179
  if (!input.genesis && !input.baseVersion && !input.path) {
180
- const genesisChange = await createGenesisChange(signer);
180
+ const genesisChange = await createHomeGenesisChange(signer);
181
181
  const generation2 = input.generation != null ? Number(input.generation) : 1;
182
182
  if (input.changes.every((change) => {
183
183
  var _a;
@@ -0,0 +1,79 @@
1
+ import {
2
+ createChange,
3
+ createChangeOps,
4
+ createHomeGenesisChange
5
+ } from "./chunk-O5MHN2EO.mjs";
6
+ import {
7
+ createVersionRef
8
+ } from "./chunk-PJ2RFT5A.mjs";
9
+ import {
10
+ signerPublicKey
11
+ } from "./chunk-LVAHHQIK.mjs";
12
+
13
+ // src/create-document.ts
14
+ import { base58btc } from "multiformats/bases/base58";
15
+ async function createDocumentBlobs(signer, input) {
16
+ const isHome = input.path === "";
17
+ const toBlob = (block) => ({
18
+ data: block.bytes,
19
+ cid: block.cid.toString()
20
+ });
21
+ if (isHome) {
22
+ const signerAccount = base58btc.encode(new Uint8Array(await signerPublicKey(signer)));
23
+ if (signerAccount !== input.space) {
24
+ throw new Error(
25
+ `A home document can only be created by its own account: signer ${signerAccount} cannot create the home of ${input.space}`
26
+ );
27
+ }
28
+ const genesis = await createHomeGenesisChange(signer);
29
+ const { unsignedBytes: unsignedBytes2, ts: ts2 } = createChangeOps({
30
+ ops: input.ops,
31
+ genesisCid: genesis.cid,
32
+ deps: [genesis.cid],
33
+ depth: 1
34
+ });
35
+ const change2 = await createChange(unsignedBytes2, signer);
36
+ const ref2 = await createVersionRef(
37
+ {
38
+ space: input.space,
39
+ path: "",
40
+ genesis: genesis.cid.toString(),
41
+ version: change2.cid.toString(),
42
+ generation: input.generation ?? Number(ts2),
43
+ capability: input.capability,
44
+ visibility: input.visibility
45
+ },
46
+ signer
47
+ );
48
+ return {
49
+ blobs: [toBlob(genesis), toBlob(change2), ...ref2.blobs],
50
+ genesis: genesis.cid.toString(),
51
+ version: change2.cid.toString(),
52
+ ts: ts2
53
+ };
54
+ }
55
+ const { unsignedBytes, ts } = createChangeOps({ ops: input.ops });
56
+ const change = await createChange(unsignedBytes, signer);
57
+ const ref = await createVersionRef(
58
+ {
59
+ space: input.space,
60
+ path: input.path,
61
+ genesis: change.cid.toString(),
62
+ version: change.cid.toString(),
63
+ generation: input.generation ?? Number(ts),
64
+ capability: input.capability,
65
+ visibility: input.visibility
66
+ },
67
+ signer
68
+ );
69
+ return {
70
+ blobs: [toBlob(change), ...ref.blobs],
71
+ genesis: change.cid.toString(),
72
+ version: change.cid.toString(),
73
+ ts
74
+ };
75
+ }
76
+
77
+ export {
78
+ createDocumentBlobs
79
+ };
package/dist/client.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createSeedClient,
3
3
  deserializeQueryString
4
- } from "./chunk-NR2TW5BW.mjs";
4
+ } from "./chunk-W3MTG26Q.mjs";
5
5
  import "./chunk-CBELM7KX.mjs";
6
- import "./chunk-W7H2UYQL.mjs";
6
+ import "./chunk-O5MHN2EO.mjs";
7
7
  import "./chunk-PJ2RFT5A.mjs";
8
8
  import "./chunk-LVAHHQIK.mjs";
9
9
  import "./chunk-DR3HJ6BV.mjs";
@@ -0,0 +1,41 @@
1
+ import { type DocumentOperation } from './change';
2
+ import type { HMPublishBlobsInput } from './hm-types';
3
+ import type { AnySigner } from './signer';
4
+ export type CreateDocumentBlobsInput = {
5
+ /** Account UID the document lives in. */
6
+ space: string;
7
+ /** Entity path ('' for the account's home document, '/a/b' otherwise). */
8
+ path: string;
9
+ /** The first content change. */
10
+ ops: DocumentOperation[];
11
+ /** Capability CID, when the signer writes into someone else's space. */
12
+ capability?: string;
13
+ /** Generation of the Ref; defaults to the first change's timestamp, as the daemon does. */
14
+ generation?: number;
15
+ visibility?: string;
16
+ };
17
+ export type CreateDocumentBlobs = {
18
+ /** Blobs to publish, in dependency order. */
19
+ blobs: HMPublishBlobsInput['blobs'];
20
+ genesis: string;
21
+ version: string;
22
+ ts: bigint;
23
+ };
24
+ /**
25
+ * The blobs that bring a brand-new document into existence, built the way the daemon builds
26
+ * them:
27
+ *
28
+ * - A non-home document has no genesis blob of its own. Its first content Change is its
29
+ * genesis: no `genesis`/`deps` on the Change, and the Ref's genesis and head are both that
30
+ * Change (the daemon's docmodel.Ref does the same for its first Ref).
31
+ * - The account's HOME document (path '') gets the deterministic genesis
32
+ * ({@link createHomeGenesisChange}), then the content Change on top of it, then the Ref.
33
+ * The daemon's ensureProfileGenesis mints that same genesis, and only when the path is
34
+ * empty AND the space is the signer's own account: a home can only be created by its
35
+ * owner, so any other signer asking for path '' is refused here as well.
36
+ *
37
+ * Every document one account created through the deterministic genesis used to share one
38
+ * identity (sixty papers, one comment thread, 2026-09-15); keep this the single place that
39
+ * decides which genesis a new document gets.
40
+ */
41
+ export declare function createDocumentBlobs(signer: AnySigner, input: CreateDocumentBlobsInput): Promise<CreateDocumentBlobs>;
@@ -0,0 +1,11 @@
1
+ import {
2
+ createDocumentBlobs
3
+ } from "./chunk-WD332LPF.mjs";
4
+ import "./chunk-O5MHN2EO.mjs";
5
+ import "./chunk-PJ2RFT5A.mjs";
6
+ import "./chunk-LVAHHQIK.mjs";
7
+ import "./chunk-DR3HJ6BV.mjs";
8
+ import "./chunk-7P6ASYW6.mjs";
9
+ export {
10
+ createDocumentBlobs
11
+ };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createCapability, resolveCapability } from './capability';
2
2
  export type { CapabilityRole, CreateCapabilityInput } from './capability';
3
- export { createChange, createChangeOps, createDocumentChange, createDocumentChangeFromOps, createGenesisChange, signDocumentChange, signPreparedChange, } from './change';
3
+ export { createChange, createChangeOps, createDocumentChange, createDocumentChangeFromOps, createGenesisChange, createHomeGenesisChange, signDocumentChange, signPreparedChange, } from './change';
4
4
  export type { CreateChangeOpsInput, CreateDocumentChangeFromOpsInput, CreateDocumentChangeInput, DocumentOperation, SignDocumentChangeInput, } from './change';
5
5
  export { createSeedClient } from './client';
6
6
  export type { PublishDocumentResult, PublishDocumentInput, SeedClient, SeedClientOptions } from './client';
@@ -10,6 +10,7 @@ export { contactRecordIdFromBlob, createContact, deleteContact, updateContact }
10
10
  export type { CreateContactInput, CreateContactResult, DeleteContactInput, UpdateContactInput } from './contact';
11
11
  export { SeedClientError, SeedNetworkError, SeedValidationError } from './errors';
12
12
  export { createRedirectRef, createTombstoneRef, createVersionRef } from './ref';
13
+ export { createDocumentBlobs, type CreateDocumentBlobs, type CreateDocumentBlobsInput } from './create-document';
13
14
  export type { CreateRedirectRefInput, CreateTombstoneRefInput, CreateVersionRefInput } from './ref';
14
15
  export { teiToBlocks } from './tei-to-blocks';
15
16
  export type { TeiToBlocksOptions, TeiToBlocksResult, TeiFigure, FigureCoords } from './tei-to-blocks';
package/dist/index.mjs CHANGED
@@ -10,16 +10,19 @@ import {
10
10
  } from "./chunk-XB6E7EVC.mjs";
11
11
  import {
12
12
  pdfToBlocks
13
- } from "./chunk-QRWRLUTY.mjs";
13
+ } from "./chunk-7OWFPOHI.mjs";
14
14
  import {
15
15
  teiToBlocks
16
16
  } from "./chunk-ZVJGJE2L.mjs";
17
17
  import {
18
18
  embeddedPdfToBlocks
19
- } from "./chunk-52P3E6H6.mjs";
19
+ } from "./chunk-2FJBS3V7.mjs";
20
20
  import {
21
21
  resolveIdWithClient
22
- } from "./chunk-7DJW6A2P.mjs";
22
+ } from "./chunk-BMPK76B2.mjs";
23
+ import {
24
+ encryption_exports
25
+ } from "./chunk-UOL3F6XQ.mjs";
23
26
  import {
24
27
  fileToIpfsBlobs,
25
28
  filesToIpfsBlobs,
@@ -42,7 +45,7 @@ import {
42
45
  } from "./chunk-IW5GLPEG.mjs";
43
46
  import {
44
47
  createSeedClient
45
- } from "./chunk-NR2TW5BW.mjs";
48
+ } from "./chunk-W3MTG26Q.mjs";
46
49
  import {
47
50
  SeedClientError,
48
51
  SeedNetworkError,
@@ -61,6 +64,9 @@ import {
61
64
  deleteContact,
62
65
  updateContact
63
66
  } from "./chunk-37WRGUK4.mjs";
67
+ import {
68
+ createDocumentBlobs
69
+ } from "./chunk-WD332LPF.mjs";
64
70
  import {
65
71
  editorBlockToHMBlock,
66
72
  editorBlocksToHMBlockNodes
@@ -70,25 +76,23 @@ import {
70
76
  addSpanToAnnotation,
71
77
  pushSpanToAnnotation
72
78
  } from "./chunk-JKKS35IS.mjs";
73
- import {
74
- encryption_exports
75
- } from "./chunk-UOL3F6XQ.mjs";
76
79
  import {
77
80
  autoLinkChildToParent,
78
81
  createAutoLinkOps,
79
82
  documentContainsLinkToChild,
80
83
  documentHasSelfQuery,
81
84
  shouldAutoLinkParent
82
- } from "./chunk-E2UOAVXB.mjs";
85
+ } from "./chunk-J45O2Y7E.mjs";
83
86
  import {
84
87
  createChange,
85
88
  createChangeOps,
86
89
  createDocumentChange,
87
90
  createDocumentChangeFromOps,
88
91
  createGenesisChange,
92
+ createHomeGenesisChange,
89
93
  signDocumentChange,
90
94
  signPreparedChange
91
- } from "./chunk-W7H2UYQL.mjs";
95
+ } from "./chunk-O5MHN2EO.mjs";
92
96
  import {
93
97
  createRedirectRef,
94
98
  createTombstoneRef,
@@ -170,9 +174,11 @@ export {
170
174
  createChangeOps,
171
175
  createComment,
172
176
  createContact,
177
+ createDocumentBlobs,
173
178
  createDocumentChange,
174
179
  createDocumentChangeFromOps,
175
180
  createGenesisChange,
181
+ createHomeGenesisChange,
176
182
  createRedirectRef,
177
183
  createSeedClient,
178
184
  createTombstoneRef,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  embeddedPdfToBlocks
3
- } from "./chunk-52P3E6H6.mjs";
3
+ } from "./chunk-2FJBS3V7.mjs";
4
4
  import "./chunk-7P6ASYW6.mjs";
5
5
  export {
6
6
  embeddedPdfToBlocks
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  pdfToBlocks
3
- } from "./chunk-QRWRLUTY.mjs";
3
+ } from "./chunk-7OWFPOHI.mjs";
4
4
  import "./chunk-ZVJGJE2L.mjs";
5
- import "./chunk-52P3E6H6.mjs";
5
+ import "./chunk-2FJBS3V7.mjs";
6
6
  import "./chunk-PPAY4WZX.mjs";
7
7
  import "./chunk-GIO2JLKT.mjs";
8
8
  import "./chunk-7P6ASYW6.mjs";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  resolveIdWithClient
3
- } from "./chunk-7DJW6A2P.mjs";
3
+ } from "./chunk-BMPK76B2.mjs";
4
4
  import "./chunk-DVJ3XGXS.mjs";
5
- import "./chunk-NR2TW5BW.mjs";
5
+ import "./chunk-W3MTG26Q.mjs";
6
6
  import "./chunk-CBELM7KX.mjs";
7
- import "./chunk-W7H2UYQL.mjs";
7
+ import "./chunk-O5MHN2EO.mjs";
8
8
  import "./chunk-PJ2RFT5A.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-hypermedia/client",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/seed-hypermedia/seed",