@seed-hypermedia/client 0.0.132 → 0.0.134
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.
- package/dist/apps.mjs +10 -7
- package/dist/auto-link.mjs +3 -3
- package/dist/block-diff.d.ts +37 -0
- package/dist/block-diff.mjs +10 -1
- package/dist/block-edits.d.ts +33 -0
- package/dist/block-edits.mjs +9 -0
- package/dist/blocks-to-markdown.d.ts +21 -6
- package/dist/blocks-to-markdown.mjs +1 -1
- package/dist/{chunk-T7SWLR32.mjs → chunk-37QDFTT6.mjs} +3 -3
- package/dist/{chunk-SUVJSSHG.mjs → chunk-4ELQ4LJL.mjs} +68 -9
- package/dist/chunk-53PY4AWT.mjs +163 -0
- package/dist/{chunk-3KLY2B27.mjs → chunk-7FPJWOXB.mjs} +148 -1
- package/dist/{chunk-NEUDKUBC.mjs → chunk-BRNXLHBP.mjs} +108 -2
- package/dist/{chunk-JQKYF5NB.mjs → chunk-ITUEKIQD.mjs} +19 -5
- package/dist/{chunk-325UCLMT.mjs → chunk-O36UBGLF.mjs} +1 -1
- package/dist/{chunk-Y4PWAEJ5.mjs → chunk-QFIEZZYJ.mjs} +213 -328
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +53 -39
- package/dist/markdown-to-blocks.d.ts +25 -5
- package/dist/markdown-to-blocks.mjs +7 -3
- package/dist/prepare-change.mjs +2 -2
- package/dist/resource-read.mjs +1 -1
- package/dist/schema-engine.d.ts +46 -2
- package/dist/schema-engine.mjs +18 -4
- package/dist/schema-registry.generated.mjs +1 -1
- package/dist/schema-resolve.d.ts +10 -1
- package/dist/schema-resolve.mjs +5 -3
- package/dist/schema-subtypes.mjs +3 -3
- package/dist/schema-types.generated.d.ts +34 -2
- package/dist/signed-blob.mjs +2 -2
- package/package.json +1 -1
- package/dist/{chunk-6QBB3P3Q.mjs → chunk-KAZNQFXV.mjs} +3 -3
package/dist/apps.mjs
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
documentUpdateBlobs
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-CBELM7KX.mjs";
|
|
5
|
-
import "./chunk-KM2NR4YA.mjs";
|
|
6
|
-
import "./chunk-PJ2RFT5A.mjs";
|
|
3
|
+
} from "./chunk-KAZNQFXV.mjs";
|
|
7
4
|
import {
|
|
8
5
|
resolveEditableDocument
|
|
9
6
|
} from "./chunk-QS6PIRUE.mjs";
|
|
7
|
+
import "./chunk-CBELM7KX.mjs";
|
|
8
|
+
import "./chunk-KM2NR4YA.mjs";
|
|
9
|
+
import "./chunk-PJ2RFT5A.mjs";
|
|
10
|
+
import "./chunk-LVAHHQIK.mjs";
|
|
11
|
+
import "./chunk-DR3HJ6BV.mjs";
|
|
10
12
|
import {
|
|
11
13
|
computeReplaceOps,
|
|
12
14
|
createBlocksMap,
|
|
13
15
|
hmBlockNodeToBlockNode,
|
|
14
16
|
toAPIBlockNode
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-7FPJWOXB.mjs";
|
|
18
|
+
import "./chunk-4ELQ4LJL.mjs";
|
|
19
|
+
import "./chunk-QFIEZZYJ.mjs";
|
|
20
|
+
import "./chunk-Q7CWMEBZ.mjs";
|
|
18
21
|
import {
|
|
19
22
|
hmIdPathToEntityQueryPath,
|
|
20
23
|
packHmId,
|
package/dist/auto-link.mjs
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
documentContainsLinkToChild,
|
|
5
5
|
documentHasSelfQuery,
|
|
6
6
|
shouldAutoLinkParent
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-O36UBGLF.mjs";
|
|
8
|
+
import "./chunk-KAZNQFXV.mjs";
|
|
9
|
+
import "./chunk-QS6PIRUE.mjs";
|
|
9
10
|
import "./chunk-CBELM7KX.mjs";
|
|
10
11
|
import "./chunk-KM2NR4YA.mjs";
|
|
11
12
|
import "./chunk-PJ2RFT5A.mjs";
|
|
12
|
-
import "./chunk-QS6PIRUE.mjs";
|
|
13
13
|
import "./chunk-LVAHHQIK.mjs";
|
|
14
14
|
import "./chunk-DR3HJ6BV.mjs";
|
|
15
15
|
import "./chunk-DGNAMVGH.mjs";
|
package/dist/block-diff.d.ts
CHANGED
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
* re-derived from (row id, column id) against the old document, and
|
|
17
17
|
* attributes markdown cannot express (column width, header column) are
|
|
18
18
|
* carried over from the old blocks.
|
|
19
|
+
*
|
|
20
|
+
* A body written as markdown gets one more pass first (markdownUpdateTree):
|
|
21
|
+
* a block whose markdown is what the stored block reads as is the stored
|
|
22
|
+
* block, so nothing the dialect spells differently is stored again, and a
|
|
23
|
+
* block that lost its id comment gets its id back.
|
|
19
24
|
*/
|
|
20
25
|
import type { DocumentOperation } from './change';
|
|
21
26
|
import type { HMBlockNode } from './hm-types';
|
|
@@ -105,4 +110,36 @@ export declare function toAPIBlockNode(node: HMBlockNode): APIBlockNode;
|
|
|
105
110
|
* (columnId, isHeader, width, …) are preserved in `block.attributes`.
|
|
106
111
|
*/
|
|
107
112
|
export declare function hmBlockNodeToBlockNode(node: HMBlockNode): BlockNode;
|
|
113
|
+
/**
|
|
114
|
+
* The tree to diff against a stored document when its new body was written as markdown.
|
|
115
|
+
*
|
|
116
|
+
* Markdown spells some things in one way only: an annotation over several ranges comes back as one
|
|
117
|
+
* per range, a block with children gets an explicit `Group`, a mention gets its kind. A diff of
|
|
118
|
+
* the parsed blocks against the stored ones would store every such block again although its author
|
|
119
|
+
* changed nothing. So the stored document is written to markdown and parsed here, which says what
|
|
120
|
+
* each stored block reads as, and then:
|
|
121
|
+
*
|
|
122
|
+
* - a written block that reads the same as the stored block with its id is that block, as stored;
|
|
123
|
+
* - a written block with no stored id that reads the same as a stored block the body does not
|
|
124
|
+
* otherwise hold is that block: it gets the id back (the earliest such block in the document,
|
|
125
|
+
* when several read alike). Only blocks with text or a link are matched this way, and how
|
|
126
|
+
* their children are arranged does not count: markdown without id comments nests a list under
|
|
127
|
+
* the paragraph before it.
|
|
128
|
+
*
|
|
129
|
+
* Tables are rebound first (rebindTableIdentities). The result goes to computeReplaceOps. A body
|
|
130
|
+
* that is the document's own markdown, with or without its id comments, yields no operations.
|
|
131
|
+
*/
|
|
132
|
+
export declare function markdownUpdateTree(oldContent: HMBlockNode[], written: BlockNode[]): BlockNode[];
|
|
133
|
+
/** What a content update does to a document, counted in blocks. */
|
|
134
|
+
export type ContentChange = {
|
|
135
|
+
/** Blocks the document holds now. */
|
|
136
|
+
blocks: number;
|
|
137
|
+
added: number;
|
|
138
|
+
rewritten: number;
|
|
139
|
+
/** Blocks that keep their id and end up under another parent or in another order. */
|
|
140
|
+
moved: number;
|
|
141
|
+
deleted: number;
|
|
142
|
+
};
|
|
143
|
+
/** Counts what `ops` (from computeReplaceOps over `newTree`) change in the stored document. */
|
|
144
|
+
export declare function describeContentChange(oldNodes: APIBlockNode[], newTree: BlockNode[], ops: DocumentOperation[]): ContentChange;
|
|
108
145
|
export {};
|
package/dist/block-diff.mjs
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
computeReplaceOps,
|
|
3
3
|
createBlocksMap,
|
|
4
|
+
describeContentChange,
|
|
4
5
|
hmBlockNodeToBlockNode,
|
|
6
|
+
markdownUpdateTree,
|
|
5
7
|
matchBlockIds,
|
|
6
8
|
rebindTableIdentities,
|
|
7
9
|
toAPIBlockNode
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7FPJWOXB.mjs";
|
|
11
|
+
import "./chunk-4ELQ4LJL.mjs";
|
|
12
|
+
import "./chunk-QFIEZZYJ.mjs";
|
|
13
|
+
import "./chunk-Q7CWMEBZ.mjs";
|
|
14
|
+
import "./chunk-DGNAMVGH.mjs";
|
|
15
|
+
import "./chunk-AHQWDCHV.mjs";
|
|
9
16
|
import "./chunk-7P6ASYW6.mjs";
|
|
10
17
|
export {
|
|
11
18
|
computeReplaceOps,
|
|
12
19
|
createBlocksMap,
|
|
20
|
+
describeContentChange,
|
|
13
21
|
hmBlockNodeToBlockNode,
|
|
22
|
+
markdownUpdateTree,
|
|
14
23
|
matchBlockIds,
|
|
15
24
|
rebindTableIdentities,
|
|
16
25
|
toAPIBlockNode
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edits that name the blocks they change.
|
|
3
|
+
*
|
|
4
|
+
* Replacing a document's whole body to change one sentence costs the whole document, and every
|
|
5
|
+
* block left out of the new body is deleted. An edit list changes blocks by id instead and leaves
|
|
6
|
+
* the rest of the tree as it is stored:
|
|
7
|
+
*
|
|
8
|
+
* {replace: ID, content} one block's own content; its children stay
|
|
9
|
+
* {after | before | into: ID, content} new blocks beside a block, or as its last children
|
|
10
|
+
* {move: ID, after | before | into: ID} a block with its children, somewhere else
|
|
11
|
+
* {delete: ID | [ID, …]} a block with its children
|
|
12
|
+
*
|
|
13
|
+
* `content` is markdown in the dialect of `markdown-to-blocks.ts`. Edits apply in order, each to
|
|
14
|
+
* the result of the one before, and all or none: the first edit that cannot apply throws
|
|
15
|
+
* {@link BlockEditError} and the input tree is untouched.
|
|
16
|
+
*/
|
|
17
|
+
import type { BlockNode } from './markdown-to-blocks';
|
|
18
|
+
/** An edit that cannot apply. `index` is its position in the list. */
|
|
19
|
+
export declare class BlockEditError extends Error {
|
|
20
|
+
index: number;
|
|
21
|
+
constructor(index: number, message: string);
|
|
22
|
+
}
|
|
23
|
+
export type BlockEditResult = {
|
|
24
|
+
/** The edited tree. Blocks no edit named are the same objects as in the input. */
|
|
25
|
+
tree: BlockNode[];
|
|
26
|
+
/** Every block an edit wrote: the replacements and the new blocks, with their children. */
|
|
27
|
+
written: BlockNode[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Applies `edits` to `tree`. `parse` turns an edit's markdown into blocks (the caller decides what
|
|
31
|
+
* else that involves, such as resolving links).
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyBlockEdits(tree: BlockNode[], edits: unknown, parse: (markdown: string) => BlockNode[]): BlockEditResult;
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
* - nesting by indentation, heading level by heading depth
|
|
9
9
|
* - annotations as markdown markers, split at boundaries so they nest
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* `blocksToMarkdown` is synchronous and does not touch the network. The
|
|
12
|
+
* `documentToResolvedMarkdown` family below is the same writer with what the
|
|
13
|
+
* blocks point at added for the reader: the name behind a mention, and the
|
|
14
|
+
* content of an embed or the results of a query between
|
|
15
|
+
* `<!-- resolved: … -->` and `<!-- /resolved -->`, which the parser skips.
|
|
16
|
+
* Both outputs parse back to the document they were written from.
|
|
15
17
|
*
|
|
16
18
|
* Round-trip: `parseMarkdown(blocksToMarkdown(doc))` reproduces `doc`, and
|
|
17
19
|
* exporting that parse reproduces the same markdown. Use
|
|
@@ -22,6 +24,12 @@ import type { HMBlockNode, HMComment, HMDocument, HMMetadata } from './hm-types'
|
|
|
22
24
|
export type BlocksToMarkdownOptions = {
|
|
23
25
|
/** Format ipfs:// URLs as https gateway URLs. Default: true. */
|
|
24
26
|
ipfsGateway?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The name to print for an inline mention of `link`. When set, a mention is written
|
|
29
|
+
* `[@Name](hm://…)` instead of `<hm://…>`; the parser reads only the link, so any name
|
|
30
|
+
* (the empty string included) parses to the same mention.
|
|
31
|
+
*/
|
|
32
|
+
mentionLabel?: (link: string, kind?: string) => string;
|
|
25
33
|
};
|
|
26
34
|
/**
|
|
27
35
|
* Emit YAML frontmatter from HMMetadata. Every defined key is emitted,
|
|
@@ -64,12 +72,19 @@ export declare function parseDraftFilename(filename: string): {
|
|
|
64
72
|
id: string;
|
|
65
73
|
ext: string;
|
|
66
74
|
};
|
|
67
|
-
/** Options for Seed-client-backed markdown rendering that resolves embeds and mentions. */
|
|
75
|
+
/** Options for Seed-client-backed markdown rendering that resolves embeds, queries and mentions. */
|
|
68
76
|
export type ResolvedMarkdownOptions = {
|
|
69
77
|
client: Pick<SeedClient, 'request'>;
|
|
70
78
|
maxDepth?: number;
|
|
79
|
+
/** Format ipfs:// URLs as https gateway URLs. Default: true. */
|
|
80
|
+
ipfsGateway?: boolean;
|
|
71
81
|
};
|
|
72
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Convert a document to markdown with what its blocks point at shown beside them: mentions carry
|
|
84
|
+
* the name of their target, and each embed or query is followed by its content between
|
|
85
|
+
* `<!-- resolved: … -->` and `<!-- /resolved -->`. The blocks themselves are written exactly as
|
|
86
|
+
* `blocksToMarkdown` writes them, so the output parses back to the document.
|
|
87
|
+
*/
|
|
73
88
|
export declare function documentToResolvedMarkdown(doc: HMDocument, options: ResolvedMarkdownOptions): Promise<string>;
|
|
74
89
|
/** Convert comment content to markdown, resolving inline mentions and block embeds through a Seed client. */
|
|
75
90
|
export declare function commentToResolvedMarkdown(comment: HMComment, options: ResolvedMarkdownOptions): Promise<string>;
|