@tdacorp/hyle-sdk 0.8.1 → 0.11.0
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/README.md +82 -4
- package/bin/hyle-sdk-engage-keygen.mjs +3 -0
- package/dist/check-routes-bin.js +6 -1
- package/dist/{chunk-EBNIKRQH.js → chunk-N7ZQUAGM.js} +46 -2
- package/dist/chunk-R5EMI4HQ.js +61 -0
- package/dist/{chunk-LGW2KP4X.js → chunk-S3LT6G4M.js} +601 -77
- package/dist/{chunk-N4QYPO7S.js → chunk-S7PCCEHP.js} +3 -2
- package/dist/comments.cjs +1048 -0
- package/dist/comments.d.cts +152 -0
- package/dist/comments.d.ts +152 -0
- package/dist/comments.js +1025 -0
- package/dist/docs-enhance.cjs +97 -0
- package/dist/docs-enhance.d.cts +16 -0
- package/dist/docs-enhance.d.ts +16 -0
- package/dist/docs-enhance.js +73 -0
- package/dist/{types-DnPzhrFx.d.cts → embed-BC8Tlc6A.d.cts} +44 -3
- package/dist/{types-BoyBWF2F.d.ts → embed-CwSzvBUO.d.ts} +44 -3
- package/dist/engage-keygen-bin.js +67 -0
- package/dist/index.cjs +27 -1
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +5 -1
- package/dist/mermaid-diagram.js +9 -54
- package/dist/next.cjs +988 -66
- package/dist/next.d.cts +149 -6
- package/dist/next.d.ts +149 -6
- package/dist/next.js +391 -12
- package/dist/react.cjs +403 -75
- package/dist/react.d.cts +141 -33
- package/dist/react.d.ts +141 -33
- package/dist/react.js +7 -1
- package/dist/{resolve-36-Ng1H0.d.cts → resolve-BYL8jMg0.d.ts} +2 -2
- package/dist/{resolve-1rQntRBh.d.ts → resolve-Ra8-y2U-.d.cts} +2 -2
- package/dist/styles.css +149 -21
- package/dist/{types-CwBCPh6K.d.cts → types-C72FwzOd.d.cts} +71 -1
- package/dist/{types-CwBCPh6K.d.ts → types-C72FwzOd.d.ts} +71 -1
- package/dist/use-cache.cjs +9 -4
- package/dist/use-cache.d.cts +2 -2
- package/dist/use-cache.d.ts +2 -2
- package/dist/use-cache.js +5 -5
- package/package.json +4 -3
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
/** One comment of `GET /cp1/engage/comments` (docs/cp1-spec.md section 3.11), in thread order. */
|
|
4
|
+
interface EngageComment {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly parent_id: string | null;
|
|
7
|
+
/** 1 to 4. */
|
|
8
|
+
readonly depth: number;
|
|
9
|
+
/** An immutable author-name string, read if a hyle sends it; the contract on main is `author: { name }`, which is read the same way. */
|
|
10
|
+
readonly author_name?: string | null;
|
|
11
|
+
readonly author?: {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
} | null;
|
|
14
|
+
readonly created_at: string;
|
|
15
|
+
readonly edited_at: string | null;
|
|
16
|
+
readonly like_count: number;
|
|
17
|
+
/** A hidden or deleted comment kept only because a visible reply hangs from it: no body, no author. */
|
|
18
|
+
readonly removed: boolean;
|
|
19
|
+
/** On a tombstone only: who removed it. Absent on a live comment. */
|
|
20
|
+
readonly removed_by?: "moderator" | "author";
|
|
21
|
+
readonly body: {
|
|
22
|
+
readonly format: "hast";
|
|
23
|
+
readonly tree: unknown;
|
|
24
|
+
} | null;
|
|
25
|
+
/** Viewer members: present on a live comment only when the listing was fetched for a known reader. */
|
|
26
|
+
readonly mine?: boolean;
|
|
27
|
+
readonly liked_by_me?: boolean;
|
|
28
|
+
/** ISO instant until which the reader may edit, or null. */
|
|
29
|
+
readonly can_edit_until?: string | null;
|
|
30
|
+
}
|
|
31
|
+
/** One of the reader's own held comments (`mine_held`): never part of `comments`, never counted. */
|
|
32
|
+
interface EngageHeldComment {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly parent_id: string | null;
|
|
35
|
+
readonly depth: number;
|
|
36
|
+
readonly author_name: string | null;
|
|
37
|
+
readonly created_at: string;
|
|
38
|
+
readonly edited_at: string | null;
|
|
39
|
+
readonly can_edit_until: string | null;
|
|
40
|
+
readonly body: {
|
|
41
|
+
readonly format: "hast";
|
|
42
|
+
readonly tree: unknown;
|
|
43
|
+
} | null;
|
|
44
|
+
}
|
|
45
|
+
/** `data` of `GET /cp1/engage/comments`. */
|
|
46
|
+
interface EngageListing {
|
|
47
|
+
readonly cp: 1;
|
|
48
|
+
readonly kind: "comments";
|
|
49
|
+
readonly publication_id: string;
|
|
50
|
+
readonly comment_count: number;
|
|
51
|
+
readonly like_count: number;
|
|
52
|
+
/** More than the 500 listed comments exist. */
|
|
53
|
+
readonly truncated: boolean;
|
|
54
|
+
readonly comments: readonly EngageComment[];
|
|
55
|
+
/** Viewer members: absent from the public listing (anonymous, banned or unknown reader, or a rate-limited viewer read). */
|
|
56
|
+
readonly liked_by_me?: boolean;
|
|
57
|
+
readonly mine_held?: readonly EngageHeldComment[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Chrome strings of the Comments component (en, fr, es). The fr and es copy is a draft and has not been reviewed by a native
|
|
62
|
+
* speaker. Placeholders in braces are filled by the component. Plain data: the client component receives only the active set.
|
|
63
|
+
*/
|
|
64
|
+
interface CommentStrings {
|
|
65
|
+
readonly heading: string;
|
|
66
|
+
readonly countLabel: string;
|
|
67
|
+
readonly likeArticle: string;
|
|
68
|
+
readonly likedArticle: string;
|
|
69
|
+
readonly likeArticleSignIn: string;
|
|
70
|
+
readonly likeComment: string;
|
|
71
|
+
readonly likeCommentSignIn: string;
|
|
72
|
+
readonly signInTitle: string;
|
|
73
|
+
readonly signInBody: string;
|
|
74
|
+
readonly signIn: string;
|
|
75
|
+
readonly commentingAs: string;
|
|
76
|
+
readonly write: string;
|
|
77
|
+
readonly placeholder: string;
|
|
78
|
+
readonly help: string;
|
|
79
|
+
readonly chars: string;
|
|
80
|
+
readonly post: string;
|
|
81
|
+
readonly posting: string;
|
|
82
|
+
readonly reply: string;
|
|
83
|
+
readonly replyTo: string;
|
|
84
|
+
readonly replyPlaceholder: string;
|
|
85
|
+
readonly cancel: string;
|
|
86
|
+
readonly edit: string;
|
|
87
|
+
readonly editLeft: string;
|
|
88
|
+
readonly save: string;
|
|
89
|
+
readonly delete: string;
|
|
90
|
+
readonly deleteConfirm: string;
|
|
91
|
+
readonly keep: string;
|
|
92
|
+
readonly you: string;
|
|
93
|
+
readonly edited: string;
|
|
94
|
+
readonly removed: string;
|
|
95
|
+
readonly removedByModerator: string;
|
|
96
|
+
readonly removedByAuthor: string;
|
|
97
|
+
readonly depthEnd: string;
|
|
98
|
+
readonly held: string;
|
|
99
|
+
readonly heldBanner: string;
|
|
100
|
+
readonly heldBannerBody: string;
|
|
101
|
+
readonly heldNote: string;
|
|
102
|
+
readonly heldLive: string;
|
|
103
|
+
readonly postedLive: string;
|
|
104
|
+
readonly deletedLive: string;
|
|
105
|
+
readonly savedLive: string;
|
|
106
|
+
readonly empty: string;
|
|
107
|
+
readonly emptyBody: string;
|
|
108
|
+
readonly loading: string;
|
|
109
|
+
readonly loadError: string;
|
|
110
|
+
readonly loadErrorBody: string;
|
|
111
|
+
readonly retry: string;
|
|
112
|
+
readonly postError: string;
|
|
113
|
+
readonly tooLong: string;
|
|
114
|
+
readonly editClosed: string;
|
|
115
|
+
readonly actionError: string;
|
|
116
|
+
readonly rateTitle: string;
|
|
117
|
+
readonly rateBody: string;
|
|
118
|
+
readonly rateWait: string;
|
|
119
|
+
readonly bannedTitle: string;
|
|
120
|
+
readonly bannedBody: string;
|
|
121
|
+
readonly expired: string;
|
|
122
|
+
readonly more: string;
|
|
123
|
+
readonly truncated: string;
|
|
124
|
+
readonly justNow: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The comments and likes section of an article (ADR 0017). It is fetched in the browser, uncached, after the cached article
|
|
129
|
+
* has rendered, so a like never purges a page. It talks only to the host's own `createEngagementRoute` (same origin): no
|
|
130
|
+
* credential, no hyle URL and no markup built from text ever reaches this file. Comment bodies are server-rendered hast, turned
|
|
131
|
+
* into React elements by `CommentBody`; the reader's own unapproved comment is shown as plain text.
|
|
132
|
+
*/
|
|
133
|
+
interface CommentsProps {
|
|
134
|
+
/** The article's canonical site path (`publication.canonical_path`). */
|
|
135
|
+
readonly path: string;
|
|
136
|
+
/** The host route that answers the calls, for example "/api/hyle/engage". No trailing slash. */
|
|
137
|
+
readonly endpoint: string;
|
|
138
|
+
/** Where the sign-in button goes. Without it a signed-out visitor sees the prompt but no button. */
|
|
139
|
+
readonly signInHref?: string | undefined;
|
|
140
|
+
readonly locale: string;
|
|
141
|
+
readonly labels: CommentStrings;
|
|
142
|
+
/**
|
|
143
|
+
* The public listing, fetched on the server (`HyleComments` with `interactive`): the section renders from it at once, with no
|
|
144
|
+
* skeleton, and still refetches silently on mount. Keep it referentially stable between renders. Public data only.
|
|
145
|
+
*/
|
|
146
|
+
readonly initial?: EngageListing | undefined;
|
|
147
|
+
/** Epoch milliseconds `initial` was fetched at: the first render's clock, so relative times hydrate identically. The real clock takes over on mount. */
|
|
148
|
+
readonly initialAt?: number | undefined;
|
|
149
|
+
}
|
|
150
|
+
declare function Comments({ path, endpoint, signInHref, locale, labels: s, initial, initialAt }: CommentsProps): ReactElement | null;
|
|
151
|
+
|
|
152
|
+
export { Comments, type CommentsProps };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
/** One comment of `GET /cp1/engage/comments` (docs/cp1-spec.md section 3.11), in thread order. */
|
|
4
|
+
interface EngageComment {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly parent_id: string | null;
|
|
7
|
+
/** 1 to 4. */
|
|
8
|
+
readonly depth: number;
|
|
9
|
+
/** An immutable author-name string, read if a hyle sends it; the contract on main is `author: { name }`, which is read the same way. */
|
|
10
|
+
readonly author_name?: string | null;
|
|
11
|
+
readonly author?: {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
} | null;
|
|
14
|
+
readonly created_at: string;
|
|
15
|
+
readonly edited_at: string | null;
|
|
16
|
+
readonly like_count: number;
|
|
17
|
+
/** A hidden or deleted comment kept only because a visible reply hangs from it: no body, no author. */
|
|
18
|
+
readonly removed: boolean;
|
|
19
|
+
/** On a tombstone only: who removed it. Absent on a live comment. */
|
|
20
|
+
readonly removed_by?: "moderator" | "author";
|
|
21
|
+
readonly body: {
|
|
22
|
+
readonly format: "hast";
|
|
23
|
+
readonly tree: unknown;
|
|
24
|
+
} | null;
|
|
25
|
+
/** Viewer members: present on a live comment only when the listing was fetched for a known reader. */
|
|
26
|
+
readonly mine?: boolean;
|
|
27
|
+
readonly liked_by_me?: boolean;
|
|
28
|
+
/** ISO instant until which the reader may edit, or null. */
|
|
29
|
+
readonly can_edit_until?: string | null;
|
|
30
|
+
}
|
|
31
|
+
/** One of the reader's own held comments (`mine_held`): never part of `comments`, never counted. */
|
|
32
|
+
interface EngageHeldComment {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly parent_id: string | null;
|
|
35
|
+
readonly depth: number;
|
|
36
|
+
readonly author_name: string | null;
|
|
37
|
+
readonly created_at: string;
|
|
38
|
+
readonly edited_at: string | null;
|
|
39
|
+
readonly can_edit_until: string | null;
|
|
40
|
+
readonly body: {
|
|
41
|
+
readonly format: "hast";
|
|
42
|
+
readonly tree: unknown;
|
|
43
|
+
} | null;
|
|
44
|
+
}
|
|
45
|
+
/** `data` of `GET /cp1/engage/comments`. */
|
|
46
|
+
interface EngageListing {
|
|
47
|
+
readonly cp: 1;
|
|
48
|
+
readonly kind: "comments";
|
|
49
|
+
readonly publication_id: string;
|
|
50
|
+
readonly comment_count: number;
|
|
51
|
+
readonly like_count: number;
|
|
52
|
+
/** More than the 500 listed comments exist. */
|
|
53
|
+
readonly truncated: boolean;
|
|
54
|
+
readonly comments: readonly EngageComment[];
|
|
55
|
+
/** Viewer members: absent from the public listing (anonymous, banned or unknown reader, or a rate-limited viewer read). */
|
|
56
|
+
readonly liked_by_me?: boolean;
|
|
57
|
+
readonly mine_held?: readonly EngageHeldComment[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Chrome strings of the Comments component (en, fr, es). The fr and es copy is a draft and has not been reviewed by a native
|
|
62
|
+
* speaker. Placeholders in braces are filled by the component. Plain data: the client component receives only the active set.
|
|
63
|
+
*/
|
|
64
|
+
interface CommentStrings {
|
|
65
|
+
readonly heading: string;
|
|
66
|
+
readonly countLabel: string;
|
|
67
|
+
readonly likeArticle: string;
|
|
68
|
+
readonly likedArticle: string;
|
|
69
|
+
readonly likeArticleSignIn: string;
|
|
70
|
+
readonly likeComment: string;
|
|
71
|
+
readonly likeCommentSignIn: string;
|
|
72
|
+
readonly signInTitle: string;
|
|
73
|
+
readonly signInBody: string;
|
|
74
|
+
readonly signIn: string;
|
|
75
|
+
readonly commentingAs: string;
|
|
76
|
+
readonly write: string;
|
|
77
|
+
readonly placeholder: string;
|
|
78
|
+
readonly help: string;
|
|
79
|
+
readonly chars: string;
|
|
80
|
+
readonly post: string;
|
|
81
|
+
readonly posting: string;
|
|
82
|
+
readonly reply: string;
|
|
83
|
+
readonly replyTo: string;
|
|
84
|
+
readonly replyPlaceholder: string;
|
|
85
|
+
readonly cancel: string;
|
|
86
|
+
readonly edit: string;
|
|
87
|
+
readonly editLeft: string;
|
|
88
|
+
readonly save: string;
|
|
89
|
+
readonly delete: string;
|
|
90
|
+
readonly deleteConfirm: string;
|
|
91
|
+
readonly keep: string;
|
|
92
|
+
readonly you: string;
|
|
93
|
+
readonly edited: string;
|
|
94
|
+
readonly removed: string;
|
|
95
|
+
readonly removedByModerator: string;
|
|
96
|
+
readonly removedByAuthor: string;
|
|
97
|
+
readonly depthEnd: string;
|
|
98
|
+
readonly held: string;
|
|
99
|
+
readonly heldBanner: string;
|
|
100
|
+
readonly heldBannerBody: string;
|
|
101
|
+
readonly heldNote: string;
|
|
102
|
+
readonly heldLive: string;
|
|
103
|
+
readonly postedLive: string;
|
|
104
|
+
readonly deletedLive: string;
|
|
105
|
+
readonly savedLive: string;
|
|
106
|
+
readonly empty: string;
|
|
107
|
+
readonly emptyBody: string;
|
|
108
|
+
readonly loading: string;
|
|
109
|
+
readonly loadError: string;
|
|
110
|
+
readonly loadErrorBody: string;
|
|
111
|
+
readonly retry: string;
|
|
112
|
+
readonly postError: string;
|
|
113
|
+
readonly tooLong: string;
|
|
114
|
+
readonly editClosed: string;
|
|
115
|
+
readonly actionError: string;
|
|
116
|
+
readonly rateTitle: string;
|
|
117
|
+
readonly rateBody: string;
|
|
118
|
+
readonly rateWait: string;
|
|
119
|
+
readonly bannedTitle: string;
|
|
120
|
+
readonly bannedBody: string;
|
|
121
|
+
readonly expired: string;
|
|
122
|
+
readonly more: string;
|
|
123
|
+
readonly truncated: string;
|
|
124
|
+
readonly justNow: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The comments and likes section of an article (ADR 0017). It is fetched in the browser, uncached, after the cached article
|
|
129
|
+
* has rendered, so a like never purges a page. It talks only to the host's own `createEngagementRoute` (same origin): no
|
|
130
|
+
* credential, no hyle URL and no markup built from text ever reaches this file. Comment bodies are server-rendered hast, turned
|
|
131
|
+
* into React elements by `CommentBody`; the reader's own unapproved comment is shown as plain text.
|
|
132
|
+
*/
|
|
133
|
+
interface CommentsProps {
|
|
134
|
+
/** The article's canonical site path (`publication.canonical_path`). */
|
|
135
|
+
readonly path: string;
|
|
136
|
+
/** The host route that answers the calls, for example "/api/hyle/engage". No trailing slash. */
|
|
137
|
+
readonly endpoint: string;
|
|
138
|
+
/** Where the sign-in button goes. Without it a signed-out visitor sees the prompt but no button. */
|
|
139
|
+
readonly signInHref?: string | undefined;
|
|
140
|
+
readonly locale: string;
|
|
141
|
+
readonly labels: CommentStrings;
|
|
142
|
+
/**
|
|
143
|
+
* The public listing, fetched on the server (`HyleComments` with `interactive`): the section renders from it at once, with no
|
|
144
|
+
* skeleton, and still refetches silently on mount. Keep it referentially stable between renders. Public data only.
|
|
145
|
+
*/
|
|
146
|
+
readonly initial?: EngageListing | undefined;
|
|
147
|
+
/** Epoch milliseconds `initial` was fetched at: the first render's clock, so relative times hydrate identically. The real clock takes over on mount. */
|
|
148
|
+
readonly initialAt?: number | undefined;
|
|
149
|
+
}
|
|
150
|
+
declare function Comments({ path, endpoint, signInHref, locale, labels: s, initial, initialAt }: CommentsProps): ReactElement | null;
|
|
151
|
+
|
|
152
|
+
export { Comments, type CommentsProps };
|