@seed-hypermedia/client 0.0.41 → 0.0.43
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/{chunk-2E3HWHST.mjs → chunk-XHVG24AF.mjs} +13 -1
- package/dist/client.d.ts +5 -1
- package/dist/comment.d.ts +15 -0
- package/dist/hm-types.d.ts +63 -16
- package/dist/hm-types.mjs +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +85 -11
- package/package.json +1 -1
- package/src/index.ts +7 -1
|
@@ -28,7 +28,12 @@ var unpackedHmIdSchema = z.object({
|
|
|
28
28
|
targetDocPath: z.array(z.string()).nullable().optional()
|
|
29
29
|
});
|
|
30
30
|
var HMBlockChildrenTypeSchema = z.union([z.literal("Group"), z.literal("Ordered"), z.literal("Unordered"), z.literal("Blockquote"), z.literal("Grid")]).nullable();
|
|
31
|
-
var HMEmbedViewSchema = z.union([
|
|
31
|
+
var HMEmbedViewSchema = z.union([
|
|
32
|
+
z.literal("Content"),
|
|
33
|
+
z.literal("Card"),
|
|
34
|
+
z.literal("Comments"),
|
|
35
|
+
z.literal("Link")
|
|
36
|
+
]);
|
|
32
37
|
var HMQueryStyleSchema = z.union([z.literal("Card"), z.literal("List")]);
|
|
33
38
|
var baseAnnotationProperties = {
|
|
34
39
|
starts: z.array(z.number()),
|
|
@@ -538,11 +543,16 @@ var HMAccountContactsRequestSchema = z.object({
|
|
|
538
543
|
// account UID
|
|
539
544
|
output: z.array(HMContactRecordSchema)
|
|
540
545
|
});
|
|
546
|
+
var QuotingRangeSchema = z.object({
|
|
547
|
+
start: z.number(),
|
|
548
|
+
end: z.number()
|
|
549
|
+
});
|
|
541
550
|
var HMCommentDraftSchema = z.object({
|
|
542
551
|
blocks: z.array(HMBlockNodeSchema),
|
|
543
552
|
targetDocId: z.string().optional(),
|
|
544
553
|
replyCommentId: z.string().optional(),
|
|
545
554
|
quotingBlockId: z.string().optional(),
|
|
555
|
+
quotingRange: QuotingRangeSchema.optional(),
|
|
546
556
|
context: z.enum(["accessory", "feed", "document-content"]).optional(),
|
|
547
557
|
lastUpdateTime: z.number().optional()
|
|
548
558
|
});
|
|
@@ -551,6 +561,7 @@ var HMListedCommentDraftSchema = z.object({
|
|
|
551
561
|
targetDocId: z.string(),
|
|
552
562
|
replyCommentId: z.string().optional(),
|
|
553
563
|
quotingBlockId: z.string().optional(),
|
|
564
|
+
quotingRange: QuotingRangeSchema.optional(),
|
|
554
565
|
context: z.enum(["accessory", "feed", "document-content"]).optional(),
|
|
555
566
|
lastUpdateTime: z.number()
|
|
556
567
|
});
|
|
@@ -1348,6 +1359,7 @@ export {
|
|
|
1348
1359
|
HMContactSubscribeSchema,
|
|
1349
1360
|
HMContactRecordSchema,
|
|
1350
1361
|
HMAccountContactsRequestSchema,
|
|
1362
|
+
QuotingRangeSchema,
|
|
1351
1363
|
HMCommentDraftSchema,
|
|
1352
1364
|
HMListedCommentDraftSchema,
|
|
1353
1365
|
HMHostConfigSchema,
|
package/dist/client.d.ts
CHANGED
|
@@ -19,13 +19,17 @@ export type SeedClientOptions = {
|
|
|
19
19
|
fetch?: typeof globalThis.fetch;
|
|
20
20
|
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
21
21
|
};
|
|
22
|
+
/** Options that control an individual Seed API request. */
|
|
23
|
+
export type SeedClientRequestOptions = {
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
};
|
|
22
26
|
type PublishBlobsRequest = Extract<HMRequest, {
|
|
23
27
|
key: 'PublishBlobs';
|
|
24
28
|
}>;
|
|
25
29
|
export type SeedClient = {
|
|
26
30
|
request<K extends HMRequest['key']>(key: K, input: Extract<HMRequest, {
|
|
27
31
|
key: K;
|
|
28
|
-
}>['input']): Promise<Extract<HMRequest, {
|
|
32
|
+
}>['input'], options?: SeedClientRequestOptions): Promise<Extract<HMRequest, {
|
|
29
33
|
key: K;
|
|
30
34
|
}>['output']>;
|
|
31
35
|
publish(input: PublishBlobsRequest['input']): Promise<PublishBlobsRequest['output']>;
|
package/dist/comment.d.ts
CHANGED
|
@@ -13,11 +13,26 @@ type PrepareAttachments = (binaries: Uint8Array[]) => Promise<{
|
|
|
13
13
|
blobs: CommentAttachmentBlob[];
|
|
14
14
|
resultCIDs: string[];
|
|
15
15
|
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Target of a quoted block fragment in a comment. The optional `range`
|
|
18
|
+
* holds zero-based Unicode codepoint offsets within the block's text.
|
|
19
|
+
* When `range` is omitted, the comment quotes the whole block.
|
|
20
|
+
*/
|
|
21
|
+
export type QuotingTarget = {
|
|
22
|
+
blockId: string;
|
|
23
|
+
range?: {
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
16
28
|
type CreateCommentBaseInput = {
|
|
17
29
|
docId: UnpackedHypermediaId;
|
|
18
30
|
docVersion: string;
|
|
19
31
|
replyCommentVersion?: string | null;
|
|
20
32
|
rootReplyCommentVersion?: string | null;
|
|
33
|
+
/** Structured quote target (preferred). */
|
|
34
|
+
quoting?: QuotingTarget;
|
|
35
|
+
/** Deprecated: pass `quoting: {blockId}` instead. Still honored for back-compat. */
|
|
21
36
|
quotingBlockId?: string;
|
|
22
37
|
visibility?: 'Private' | '';
|
|
23
38
|
};
|
package/dist/hm-types.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export declare const unpackedHmIdSchema: z.ZodObject<{
|
|
|
77
77
|
export type UnpackedHypermediaId = z.infer<typeof unpackedHmIdSchema>;
|
|
78
78
|
export declare const HMBlockChildrenTypeSchema: z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>;
|
|
79
79
|
export type HMBlockChildrenType = z.infer<typeof HMBlockChildrenTypeSchema>;
|
|
80
|
-
export declare const HMEmbedViewSchema: z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">]>;
|
|
80
|
+
export declare const HMEmbedViewSchema: z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">, z.ZodLiteral<"Link">]>;
|
|
81
81
|
export type HMEmbedView = z.infer<typeof HMEmbedViewSchema>;
|
|
82
82
|
export declare const HMQueryStyleSchema: z.ZodUnion<[z.ZodLiteral<"Card">, z.ZodLiteral<"List">]>;
|
|
83
83
|
export type HMQueryStyle = z.infer<typeof HMQueryStyleSchema>;
|
|
@@ -2510,17 +2510,17 @@ export declare const HMBlockButtonSchema: z.ZodObject<{
|
|
|
2510
2510
|
export declare const HMBlockEmbedSchema: z.ZodObject<{
|
|
2511
2511
|
link: z.ZodString;
|
|
2512
2512
|
attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
2513
|
-
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">]>>;
|
|
2513
|
+
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">, z.ZodLiteral<"Link">]>>;
|
|
2514
2514
|
childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
|
|
2515
2515
|
columnCount: z.ZodOptional<z.ZodNumber>;
|
|
2516
2516
|
}, "strip", z.ZodTypeAny, {
|
|
2517
2517
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
2518
2518
|
columnCount?: number | undefined;
|
|
2519
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
2519
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
2520
2520
|
}, {
|
|
2521
2521
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
2522
2522
|
columnCount?: number | undefined;
|
|
2523
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
2523
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
2524
2524
|
}>>>;
|
|
2525
2525
|
id: z.ZodString;
|
|
2526
2526
|
revision: z.ZodOptional<z.ZodString>;
|
|
@@ -2534,7 +2534,7 @@ export declare const HMBlockEmbedSchema: z.ZodObject<{
|
|
|
2534
2534
|
attributes: {
|
|
2535
2535
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
2536
2536
|
columnCount?: number | undefined;
|
|
2537
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
2537
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
2538
2538
|
};
|
|
2539
2539
|
text?: "" | undefined;
|
|
2540
2540
|
annotations?: never[] | undefined;
|
|
@@ -2546,7 +2546,7 @@ export declare const HMBlockEmbedSchema: z.ZodObject<{
|
|
|
2546
2546
|
attributes?: {
|
|
2547
2547
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
2548
2548
|
columnCount?: number | undefined;
|
|
2549
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
2549
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
2550
2550
|
} | undefined;
|
|
2551
2551
|
text?: "" | undefined;
|
|
2552
2552
|
annotations?: never[] | undefined;
|
|
@@ -7403,17 +7403,17 @@ export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
7403
7403
|
}>, z.ZodObject<{
|
|
7404
7404
|
link: z.ZodString;
|
|
7405
7405
|
attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
7406
|
-
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">]>>;
|
|
7406
|
+
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">, z.ZodLiteral<"Link">]>>;
|
|
7407
7407
|
childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
|
|
7408
7408
|
columnCount: z.ZodOptional<z.ZodNumber>;
|
|
7409
7409
|
}, "strip", z.ZodTypeAny, {
|
|
7410
7410
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
7411
7411
|
columnCount?: number | undefined;
|
|
7412
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
7412
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
7413
7413
|
}, {
|
|
7414
7414
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
7415
7415
|
columnCount?: number | undefined;
|
|
7416
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
7416
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
7417
7417
|
}>>>;
|
|
7418
7418
|
id: z.ZodString;
|
|
7419
7419
|
revision: z.ZodOptional<z.ZodString>;
|
|
@@ -7427,7 +7427,7 @@ export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
7427
7427
|
attributes: {
|
|
7428
7428
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
7429
7429
|
columnCount?: number | undefined;
|
|
7430
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
7430
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
7431
7431
|
};
|
|
7432
7432
|
text?: "" | undefined;
|
|
7433
7433
|
annotations?: never[] | undefined;
|
|
@@ -7439,7 +7439,7 @@ export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
7439
7439
|
attributes?: {
|
|
7440
7440
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
7441
7441
|
columnCount?: number | undefined;
|
|
7442
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
7442
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
7443
7443
|
} | undefined;
|
|
7444
7444
|
text?: "" | undefined;
|
|
7445
7445
|
annotations?: never[] | undefined;
|
|
@@ -9310,17 +9310,17 @@ export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type",
|
|
|
9310
9310
|
}>, z.ZodObject<{
|
|
9311
9311
|
link: z.ZodString;
|
|
9312
9312
|
attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
9313
|
-
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">]>>;
|
|
9313
|
+
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">, z.ZodLiteral<"Link">]>>;
|
|
9314
9314
|
childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
|
|
9315
9315
|
columnCount: z.ZodOptional<z.ZodNumber>;
|
|
9316
9316
|
}, "strip", z.ZodTypeAny, {
|
|
9317
9317
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
9318
9318
|
columnCount?: number | undefined;
|
|
9319
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
9319
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
9320
9320
|
}, {
|
|
9321
9321
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
9322
9322
|
columnCount?: number | undefined;
|
|
9323
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
9323
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
9324
9324
|
}>>>;
|
|
9325
9325
|
id: z.ZodString;
|
|
9326
9326
|
revision: z.ZodOptional<z.ZodString>;
|
|
@@ -9334,7 +9334,7 @@ export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type",
|
|
|
9334
9334
|
attributes: {
|
|
9335
9335
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
9336
9336
|
columnCount?: number | undefined;
|
|
9337
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
9337
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
9338
9338
|
};
|
|
9339
9339
|
text?: "" | undefined;
|
|
9340
9340
|
annotations?: never[] | undefined;
|
|
@@ -9346,7 +9346,7 @@ export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type",
|
|
|
9346
9346
|
attributes?: {
|
|
9347
9347
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
9348
9348
|
columnCount?: number | undefined;
|
|
9349
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
9349
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
9350
9350
|
} | undefined;
|
|
9351
9351
|
text?: "" | undefined;
|
|
9352
9352
|
annotations?: never[] | undefined;
|
|
@@ -12868,11 +12868,32 @@ export type HMExistingDraft = {
|
|
|
12868
12868
|
id: string;
|
|
12869
12869
|
metadata?: HMMetadata;
|
|
12870
12870
|
};
|
|
12871
|
+
/** Codepoint offsets within a quoted block. */
|
|
12872
|
+
export declare const QuotingRangeSchema: z.ZodObject<{
|
|
12873
|
+
start: z.ZodNumber;
|
|
12874
|
+
end: z.ZodNumber;
|
|
12875
|
+
}, "strip", z.ZodTypeAny, {
|
|
12876
|
+
start: number;
|
|
12877
|
+
end: number;
|
|
12878
|
+
}, {
|
|
12879
|
+
start: number;
|
|
12880
|
+
end: number;
|
|
12881
|
+
}>;
|
|
12871
12882
|
export declare const HMCommentDraftSchema: z.ZodObject<{
|
|
12872
12883
|
blocks: z.ZodArray<z.ZodType<HMBlockNode, z.ZodTypeDef, HMBlockNode>, "many">;
|
|
12873
12884
|
targetDocId: z.ZodOptional<z.ZodString>;
|
|
12874
12885
|
replyCommentId: z.ZodOptional<z.ZodString>;
|
|
12875
12886
|
quotingBlockId: z.ZodOptional<z.ZodString>;
|
|
12887
|
+
quotingRange: z.ZodOptional<z.ZodObject<{
|
|
12888
|
+
start: z.ZodNumber;
|
|
12889
|
+
end: z.ZodNumber;
|
|
12890
|
+
}, "strip", z.ZodTypeAny, {
|
|
12891
|
+
start: number;
|
|
12892
|
+
end: number;
|
|
12893
|
+
}, {
|
|
12894
|
+
start: number;
|
|
12895
|
+
end: number;
|
|
12896
|
+
}>>;
|
|
12876
12897
|
context: z.ZodOptional<z.ZodEnum<["accessory", "feed", "document-content"]>>;
|
|
12877
12898
|
lastUpdateTime: z.ZodOptional<z.ZodNumber>;
|
|
12878
12899
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -12880,6 +12901,10 @@ export declare const HMCommentDraftSchema: z.ZodObject<{
|
|
|
12880
12901
|
targetDocId?: string | undefined;
|
|
12881
12902
|
replyCommentId?: string | undefined;
|
|
12882
12903
|
quotingBlockId?: string | undefined;
|
|
12904
|
+
quotingRange?: {
|
|
12905
|
+
start: number;
|
|
12906
|
+
end: number;
|
|
12907
|
+
} | undefined;
|
|
12883
12908
|
context?: "accessory" | "feed" | "document-content" | undefined;
|
|
12884
12909
|
lastUpdateTime?: number | undefined;
|
|
12885
12910
|
}, {
|
|
@@ -12887,6 +12912,10 @@ export declare const HMCommentDraftSchema: z.ZodObject<{
|
|
|
12887
12912
|
targetDocId?: string | undefined;
|
|
12888
12913
|
replyCommentId?: string | undefined;
|
|
12889
12914
|
quotingBlockId?: string | undefined;
|
|
12915
|
+
quotingRange?: {
|
|
12916
|
+
start: number;
|
|
12917
|
+
end: number;
|
|
12918
|
+
} | undefined;
|
|
12890
12919
|
context?: "accessory" | "feed" | "document-content" | undefined;
|
|
12891
12920
|
lastUpdateTime?: number | undefined;
|
|
12892
12921
|
}>;
|
|
@@ -12896,6 +12925,16 @@ export declare const HMListedCommentDraftSchema: z.ZodObject<{
|
|
|
12896
12925
|
targetDocId: z.ZodString;
|
|
12897
12926
|
replyCommentId: z.ZodOptional<z.ZodString>;
|
|
12898
12927
|
quotingBlockId: z.ZodOptional<z.ZodString>;
|
|
12928
|
+
quotingRange: z.ZodOptional<z.ZodObject<{
|
|
12929
|
+
start: z.ZodNumber;
|
|
12930
|
+
end: z.ZodNumber;
|
|
12931
|
+
}, "strip", z.ZodTypeAny, {
|
|
12932
|
+
start: number;
|
|
12933
|
+
end: number;
|
|
12934
|
+
}, {
|
|
12935
|
+
start: number;
|
|
12936
|
+
end: number;
|
|
12937
|
+
}>>;
|
|
12899
12938
|
context: z.ZodOptional<z.ZodEnum<["accessory", "feed", "document-content"]>>;
|
|
12900
12939
|
lastUpdateTime: z.ZodNumber;
|
|
12901
12940
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -12904,6 +12943,10 @@ export declare const HMListedCommentDraftSchema: z.ZodObject<{
|
|
|
12904
12943
|
lastUpdateTime: number;
|
|
12905
12944
|
replyCommentId?: string | undefined;
|
|
12906
12945
|
quotingBlockId?: string | undefined;
|
|
12946
|
+
quotingRange?: {
|
|
12947
|
+
start: number;
|
|
12948
|
+
end: number;
|
|
12949
|
+
} | undefined;
|
|
12907
12950
|
context?: "accessory" | "feed" | "document-content" | undefined;
|
|
12908
12951
|
}, {
|
|
12909
12952
|
id: string;
|
|
@@ -12911,6 +12954,10 @@ export declare const HMListedCommentDraftSchema: z.ZodObject<{
|
|
|
12911
12954
|
lastUpdateTime: number;
|
|
12912
12955
|
replyCommentId?: string | undefined;
|
|
12913
12956
|
quotingBlockId?: string | undefined;
|
|
12957
|
+
quotingRange?: {
|
|
12958
|
+
start: number;
|
|
12959
|
+
end: number;
|
|
12960
|
+
} | undefined;
|
|
12914
12961
|
context?: "accessory" | "feed" | "document-content" | undefined;
|
|
12915
12962
|
}>;
|
|
12916
12963
|
export type HMListedCommentDraft = z.infer<typeof HMListedCommentDraftSchema>;
|
package/dist/hm-types.mjs
CHANGED
|
@@ -154,6 +154,7 @@ import {
|
|
|
154
154
|
ItalicAnnotationSchema,
|
|
155
155
|
LinkAnnotationSchema,
|
|
156
156
|
ParsedFragmentSchema,
|
|
157
|
+
QuotingRangeSchema,
|
|
157
158
|
StrikeAnnotationSchema,
|
|
158
159
|
TextColorAnnotationSchema,
|
|
159
160
|
TextFamilyAnnotationSchema,
|
|
@@ -176,7 +177,7 @@ import {
|
|
|
176
177
|
toNumber,
|
|
177
178
|
unpackHmId,
|
|
178
179
|
unpackedHmIdSchema
|
|
179
|
-
} from "./chunk-
|
|
180
|
+
} from "./chunk-XHVG24AF.mjs";
|
|
180
181
|
export {
|
|
181
182
|
BackgroundColorAnnotationSchema,
|
|
182
183
|
BlockRangeSchema,
|
|
@@ -333,6 +334,7 @@ export {
|
|
|
333
334
|
ItalicAnnotationSchema,
|
|
334
335
|
LinkAnnotationSchema,
|
|
335
336
|
ParsedFragmentSchema,
|
|
337
|
+
QuotingRangeSchema,
|
|
336
338
|
StrikeAnnotationSchema,
|
|
337
339
|
TextColorAnnotationSchema,
|
|
338
340
|
TextFamilyAnnotationSchema,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type { CreateChangeOpsInput, CreateDocumentChangeFromOpsInput, CreateDocu
|
|
|
5
5
|
export { createSeedClient } from './client';
|
|
6
6
|
export type { PublishDocumentInput, SeedClient, SeedClientOptions } from './client';
|
|
7
7
|
export { commentRecordIdFromBlob, createComment, deleteComment, updateComment } from './comment';
|
|
8
|
-
export type { CommentAttachmentBlob, CreateCommentInput, DeleteCommentInput, UpdateCommentInput } from './comment';
|
|
8
|
+
export type { CommentAttachmentBlob, CreateCommentInput, DeleteCommentInput, QuotingTarget, UpdateCommentInput, } from './comment';
|
|
9
9
|
export { contactRecordIdFromBlob, createContact, deleteContact, updateContact } from './contact';
|
|
10
10
|
export type { CreateContactInput, CreateContactResult, DeleteContactInput, UpdateContactInput } from './contact';
|
|
11
11
|
export { SeedClientError, SeedNetworkError, SeedValidationError } from './errors';
|
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
serializeBlockRange,
|
|
18
18
|
toNumber,
|
|
19
19
|
unpackHmId
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-XHVG24AF.mjs";
|
|
21
21
|
|
|
22
22
|
// src/capability.ts
|
|
23
23
|
import { encode as cborEncode2 } from "@ipld/dag-cbor";
|
|
@@ -373,7 +373,7 @@ function createSeedClient(baseUrl, options) {
|
|
|
373
373
|
const normalizedBaseUrl = baseUrl.replace(/\/+$/, "");
|
|
374
374
|
const fetchFn = (options == null ? void 0 : options.fetch) ?? globalThis.fetch;
|
|
375
375
|
const getDefaultHeaders = async () => typeof (options == null ? void 0 : options.headers) === "function" ? await options.headers() : (options == null ? void 0 : options.headers) ?? {};
|
|
376
|
-
async function request(key, input) {
|
|
376
|
+
async function request(key, input, options2) {
|
|
377
377
|
const requestSchema = HMRequestSchema.options.find((schema) => schema.shape.key.value === key);
|
|
378
378
|
if (!requestSchema) {
|
|
379
379
|
throw new SeedValidationError(`Unknown request key: ${key}`);
|
|
@@ -397,9 +397,11 @@ function createSeedClient(baseUrl, options) {
|
|
|
397
397
|
"Content-Type": "application/cbor",
|
|
398
398
|
...defaultHeaders
|
|
399
399
|
},
|
|
400
|
-
body: new Uint8Array(cborEncode5(stripUndefined(validatedInput)))
|
|
400
|
+
body: new Uint8Array(cborEncode5(stripUndefined(validatedInput))),
|
|
401
|
+
signal: options2 == null ? void 0 : options2.signal
|
|
401
402
|
});
|
|
402
403
|
} catch (err) {
|
|
404
|
+
if (isAbortError(err)) throw err;
|
|
403
405
|
throw new SeedNetworkError(
|
|
404
406
|
`Network error fetching ${key}: ${err instanceof Error ? err.message : String(err)}`,
|
|
405
407
|
{ cause: err }
|
|
@@ -424,9 +426,11 @@ function createSeedClient(baseUrl, options) {
|
|
|
424
426
|
headers: {
|
|
425
427
|
Accept: "application/json",
|
|
426
428
|
...defaultHeaders
|
|
427
|
-
}
|
|
429
|
+
},
|
|
430
|
+
signal: options2 == null ? void 0 : options2.signal
|
|
428
431
|
});
|
|
429
432
|
} catch (err) {
|
|
433
|
+
if (isAbortError(err)) throw err;
|
|
430
434
|
throw new SeedNetworkError(
|
|
431
435
|
`Network error fetching ${key}: ${err instanceof Error ? err.message : String(err)}`,
|
|
432
436
|
{ cause: err }
|
|
@@ -515,6 +519,9 @@ function createSeedClient(baseUrl, options) {
|
|
|
515
519
|
publishDocument
|
|
516
520
|
};
|
|
517
521
|
}
|
|
522
|
+
function isAbortError(err) {
|
|
523
|
+
return typeof DOMException !== "undefined" && err instanceof DOMException && err.name === "AbortError";
|
|
524
|
+
}
|
|
518
525
|
function stripUndefined(obj) {
|
|
519
526
|
if (obj === null || obj === void 0 || typeof obj !== "object") return obj;
|
|
520
527
|
if (ArrayBuffer.isView(obj) || obj instanceof ArrayBuffer) return obj;
|
|
@@ -659,6 +666,16 @@ function isEmptyBlockNode(node) {
|
|
|
659
666
|
if (block.type !== "Paragraph" && block.type !== "Heading") return false;
|
|
660
667
|
return !block.text || block.text.trim() === "";
|
|
661
668
|
}
|
|
669
|
+
function resolveQuotingTarget(input) {
|
|
670
|
+
if (input.quoting) {
|
|
671
|
+
if (input.quoting.range && input.quoting.range.start === input.quoting.range.end) {
|
|
672
|
+
return { blockId: input.quoting.blockId };
|
|
673
|
+
}
|
|
674
|
+
return input.quoting;
|
|
675
|
+
}
|
|
676
|
+
if (input.quotingBlockId) return { blockId: input.quotingBlockId };
|
|
677
|
+
return void 0;
|
|
678
|
+
}
|
|
662
679
|
function annotationsToPublishable(annotations) {
|
|
663
680
|
validateExclusiveAnnotations(annotations);
|
|
664
681
|
return annotations.map((annotation) => {
|
|
@@ -892,7 +909,15 @@ function generateBlockId(length = 8) {
|
|
|
892
909
|
return result;
|
|
893
910
|
}
|
|
894
911
|
function wrapQuotedContent(content, input) {
|
|
895
|
-
|
|
912
|
+
const quoting = resolveQuotingTarget(input);
|
|
913
|
+
if (!quoting) return content;
|
|
914
|
+
const link = packHmId({
|
|
915
|
+
...input.docId,
|
|
916
|
+
blockRef: quoting.blockId,
|
|
917
|
+
blockRange: quoting.range ?? null,
|
|
918
|
+
version: input.docVersion,
|
|
919
|
+
latest: false
|
|
920
|
+
});
|
|
896
921
|
return [
|
|
897
922
|
{
|
|
898
923
|
block: {
|
|
@@ -904,11 +929,7 @@ function wrapQuotedContent(content, input) {
|
|
|
904
929
|
view: "Content"
|
|
905
930
|
},
|
|
906
931
|
annotations: [],
|
|
907
|
-
link
|
|
908
|
-
...input.docId,
|
|
909
|
-
blockRef: input.quotingBlockId,
|
|
910
|
-
version: input.docVersion
|
|
911
|
-
})
|
|
932
|
+
link
|
|
912
933
|
},
|
|
913
934
|
children: content
|
|
914
935
|
}
|
|
@@ -3607,7 +3628,7 @@ function editorBlockToHMBlock(editorBlock) {
|
|
|
3607
3628
|
const blockType = toHMBlockType(editorBlock.type);
|
|
3608
3629
|
if (!blockType) throw new Error("Unsupported block type " + editorBlock.type);
|
|
3609
3630
|
let block = {
|
|
3610
|
-
id: editorBlock.id,
|
|
3631
|
+
id: normalizeEditorBlockId(editorBlock.id),
|
|
3611
3632
|
type: blockType,
|
|
3612
3633
|
attributes: {},
|
|
3613
3634
|
text: "",
|
|
@@ -3822,6 +3843,17 @@ function flattenLeaves(content) {
|
|
|
3822
3843
|
}
|
|
3823
3844
|
return result;
|
|
3824
3845
|
}
|
|
3846
|
+
function normalizeEditorBlockId(id) {
|
|
3847
|
+
return id && id !== "empty" ? id : generateBlockId6();
|
|
3848
|
+
}
|
|
3849
|
+
function generateBlockId6(length = 8) {
|
|
3850
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
3851
|
+
let result = "";
|
|
3852
|
+
for (let i = 0; i < length; i++) {
|
|
3853
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
3854
|
+
}
|
|
3855
|
+
return result;
|
|
3856
|
+
}
|
|
3825
3857
|
|
|
3826
3858
|
// src/hmblock-to-editorblock.ts
|
|
3827
3859
|
function toEditorBlockType(hmBlockType) {
|
|
@@ -3943,6 +3975,27 @@ function hmBlockToEditorBlock(block) {
|
|
|
3943
3975
|
return out;
|
|
3944
3976
|
}
|
|
3945
3977
|
while (i < blockText.length) {
|
|
3978
|
+
const inlineEmbed = findInlineEmbedStartingAt(pos);
|
|
3979
|
+
if (inlineEmbed) {
|
|
3980
|
+
if (leaf) {
|
|
3981
|
+
finishLeaf(textStart, i);
|
|
3982
|
+
leaf = null;
|
|
3983
|
+
}
|
|
3984
|
+
if (inlineBlockContent) {
|
|
3985
|
+
leaves.push(inlineBlockContent);
|
|
3986
|
+
inlineBlockContent = null;
|
|
3987
|
+
}
|
|
3988
|
+
leaves.push({
|
|
3989
|
+
type: "inline-embed",
|
|
3990
|
+
styles: {},
|
|
3991
|
+
link: inlineEmbed.link
|
|
3992
|
+
});
|
|
3993
|
+
skipToCodepoint(inlineEmbed.end);
|
|
3994
|
+
textStart = i;
|
|
3995
|
+
leafAnnotations.clear();
|
|
3996
|
+
if (i >= blockText.length) return out;
|
|
3997
|
+
continue;
|
|
3998
|
+
}
|
|
3946
3999
|
let ul = 1;
|
|
3947
4000
|
let annotationsChanged = trackPosAnnotations(pos);
|
|
3948
4001
|
let surrogate = isSurrogate(blockText, i);
|
|
@@ -4161,6 +4214,27 @@ function hmBlockToEditorBlock(block) {
|
|
|
4161
4214
|
});
|
|
4162
4215
|
return annotationsChanged;
|
|
4163
4216
|
}
|
|
4217
|
+
function findInlineEmbedStartingAt(pos2) {
|
|
4218
|
+
var _a2, _b2;
|
|
4219
|
+
const blockAnnotations = block.annotations;
|
|
4220
|
+
if (!blockAnnotations) return null;
|
|
4221
|
+
for (const annotation of blockAnnotations) {
|
|
4222
|
+
const annotationData = annotation;
|
|
4223
|
+
if (annotationData.type !== "Embed") continue;
|
|
4224
|
+
const spanIndex = ((_a2 = annotationData.starts) == null ? void 0 : _a2.findIndex((start) => start === pos2)) ?? -1;
|
|
4225
|
+
if (spanIndex === -1) continue;
|
|
4226
|
+
const end = (_b2 = annotationData.ends) == null ? void 0 : _b2[spanIndex];
|
|
4227
|
+
if (typeof end !== "number" || end <= pos2) continue;
|
|
4228
|
+
return { link: annotationData.link || "", end };
|
|
4229
|
+
}
|
|
4230
|
+
return null;
|
|
4231
|
+
}
|
|
4232
|
+
function skipToCodepoint(end) {
|
|
4233
|
+
while (pos < end && i < blockText.length) {
|
|
4234
|
+
i += isSurrogate(blockText, i) ? 2 : 1;
|
|
4235
|
+
pos++;
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4164
4238
|
}
|
|
4165
4239
|
function annotationContains(annotation, pos) {
|
|
4166
4240
|
let low = 0;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -19,7 +19,13 @@ export type {
|
|
|
19
19
|
export {createSeedClient} from './client'
|
|
20
20
|
export type {PublishDocumentInput, SeedClient, SeedClientOptions} from './client'
|
|
21
21
|
export {commentRecordIdFromBlob, createComment, deleteComment, updateComment} from './comment'
|
|
22
|
-
export type {
|
|
22
|
+
export type {
|
|
23
|
+
CommentAttachmentBlob,
|
|
24
|
+
CreateCommentInput,
|
|
25
|
+
DeleteCommentInput,
|
|
26
|
+
QuotingTarget,
|
|
27
|
+
UpdateCommentInput,
|
|
28
|
+
} from './comment'
|
|
23
29
|
export {contactRecordIdFromBlob, createContact, deleteContact, updateContact} from './contact'
|
|
24
30
|
export type {CreateContactInput, CreateContactResult, DeleteContactInput, UpdateContactInput} from './contact'
|
|
25
31
|
export {SeedClientError, SeedNetworkError, SeedValidationError} from './errors'
|