@tdacorp/hyle-sdk 0.17.0 → 0.22.2

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 (92) hide show
  1. package/README.md +261 -42
  2. package/dist/check-routes-bin.js +190 -53
  3. package/dist/{chunk-6VOHFFA5.js → chunk-7T5EEJHK.js} +2 -2
  4. package/dist/chunk-DUPT6XLB.js +57 -0
  5. package/dist/chunk-IW3TUD4G.js +841 -0
  6. package/dist/{chunk-MGSUQBDW.js → chunk-KU7LWK4E.js} +249 -24
  7. package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
  8. package/dist/chunk-SFFBZFEN.js +178 -0
  9. package/dist/chunk-U74B7AUG.js +398 -0
  10. package/dist/chunk-ZIW6FDU2.js +1126 -0
  11. package/dist/client-BGjmEWhN.d.cts +207 -0
  12. package/dist/client-D0LTpr3Y.d.ts +207 -0
  13. package/dist/code-copy.cjs +74 -0
  14. package/dist/code-copy.d.cts +18 -0
  15. package/dist/code-copy.d.ts +18 -0
  16. package/dist/code-copy.js +50 -0
  17. package/dist/comments.cjs +738 -280
  18. package/dist/comments.d.cts +66 -3
  19. package/dist/comments.d.ts +66 -3
  20. package/dist/comments.js +419 -331
  21. package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
  22. package/dist/docs-enhance.cjs +7 -4
  23. package/dist/docs-enhance.d.cts +5 -3
  24. package/dist/docs-enhance.d.ts +5 -3
  25. package/dist/docs-enhance.js +8 -5
  26. package/dist/{embed-DNTZ2UXv.d.ts → embed-CbtsbZs3.d.cts} +5 -3
  27. package/dist/{embed-BmdwA2G9.d.cts → embed-Cf_2ZR5x.d.ts} +5 -3
  28. package/dist/fragment-alias.cjs +51 -0
  29. package/dist/fragment-alias.d.cts +7 -0
  30. package/dist/fragment-alias.d.ts +7 -0
  31. package/dist/fragment-alias.js +27 -0
  32. package/dist/html.cjs +886 -0
  33. package/dist/html.d.cts +20 -0
  34. package/dist/html.d.ts +20 -0
  35. package/dist/html.js +45 -0
  36. package/dist/index.cjs +244 -24
  37. package/dist/index.d.cts +22 -68
  38. package/dist/index.d.ts +22 -68
  39. package/dist/index.js +12 -2
  40. package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.cts} +9 -0
  41. package/dist/{labels-nmukKYgL.d.ts → labels-CrA-iqTN.d.ts} +9 -0
  42. package/dist/mermaid-diagram.cjs +441 -125
  43. package/dist/mermaid-diagram.d.cts +23 -7
  44. package/dist/mermaid-diagram.d.ts +23 -7
  45. package/dist/mermaid-diagram.js +213 -51
  46. package/dist/mermaid-image.cjs +137 -60
  47. package/dist/mermaid-image.d.cts +4 -3
  48. package/dist/mermaid-image.d.ts +4 -3
  49. package/dist/mermaid-image.js +27 -28
  50. package/dist/next.cjs +836 -304
  51. package/dist/next.d.cts +45 -20
  52. package/dist/next.d.ts +45 -20
  53. package/dist/next.js +151 -40
  54. package/dist/print-coordinator.cjs +157 -0
  55. package/dist/print-coordinator.d.cts +27 -0
  56. package/dist/print-coordinator.d.ts +27 -0
  57. package/dist/print-coordinator.js +83 -0
  58. package/dist/react.cjs +603 -240
  59. package/dist/react.d.cts +148 -30
  60. package/dist/react.d.ts +148 -30
  61. package/dist/react.js +26 -4
  62. package/dist/reactions.cjs +653 -0
  63. package/dist/reactions.d.cts +27 -0
  64. package/dist/reactions.d.ts +27 -0
  65. package/dist/reactions.js +364 -0
  66. package/dist/{resolve-euZ4-aC9.d.cts → resolve-BnIv7aB7.d.cts} +2 -2
  67. package/dist/{resolve-Ae7UFjsQ.d.ts → resolve-BysHtZ_i.d.ts} +2 -2
  68. package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
  69. package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
  70. package/dist/sanitize-BpY_AdZh.d.cts +23 -0
  71. package/dist/sanitize-BpY_AdZh.d.ts +23 -0
  72. package/dist/styles.css +100 -29
  73. package/dist/toc-spy.cjs +60 -0
  74. package/dist/toc-spy.d.cts +15 -0
  75. package/dist/toc-spy.d.ts +15 -0
  76. package/dist/toc-spy.js +36 -0
  77. package/dist/{types-Czt887Iv.d.cts → types-D09Z072G.d.cts} +57 -2
  78. package/dist/{types-Czt887Iv.d.ts → types-D09Z072G.d.ts} +57 -2
  79. package/dist/use-cache.cjs +89 -13
  80. package/dist/use-cache.d.cts +12 -5
  81. package/dist/use-cache.d.ts +12 -5
  82. package/dist/use-cache.js +8 -8
  83. package/dist/youtube-facade.cjs +50 -0
  84. package/dist/youtube-facade.d.cts +17 -0
  85. package/dist/youtube-facade.d.ts +17 -0
  86. package/dist/youtube-facade.js +26 -0
  87. package/package.json +16 -3
  88. package/dist/chunk-67IOIAVW.js +0 -35
  89. package/dist/chunk-DMK4XQLU.js +0 -1556
  90. package/dist/chunk-PJMJMP66.js +0 -63
  91. package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
  92. package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
@@ -1,5 +1,11 @@
1
1
  import { ReactElement } from 'react';
2
2
 
3
+ /** The reaction kinds hyle accepts. A reader holds at most one of each kind on a subject. */
4
+ type ReactionKind = "like" | "love" | "insightful" | "celebrate";
5
+ /** Reactions on a subject by kind; a kind nobody used is absent. */
6
+ type ReactionCounts = Readonly<Partial<Record<ReactionKind, number>>>;
7
+ /** A comment vote: up or down. */
8
+ type VoteValue = 1 | -1;
3
9
  /** One comment of `GET /cp1/engage/comments` (docs/cp1-spec.md section 3.11), in thread order. */
4
10
  interface EngageComment {
5
11
  readonly id: string;
@@ -14,10 +20,16 @@ interface EngageComment {
14
20
  readonly created_at: string;
15
21
  readonly edited_at: string | null;
16
22
  readonly like_count: number;
23
+ /** Sum of votes (may be negative; 0 on a tombstone). Absent from a hyle without votes. */
24
+ readonly score?: number;
25
+ /** Absent from a hyle without reaction kinds. */
26
+ readonly reaction_counts?: ReactionCounts;
17
27
  /** A hidden or deleted comment kept only because a visible reply hangs from it: no body, no author. */
18
28
  readonly removed: boolean;
19
29
  /** On a tombstone only: who removed it. Absent on a live comment. */
20
30
  readonly removed_by?: "moderator" | "author";
31
+ /** A live comment hyle can no longer render: `body` is an empty tree. Absent otherwise, and from an older hyle. */
32
+ readonly unrenderable?: true;
21
33
  readonly body: {
22
34
  readonly format: "hast";
23
35
  readonly tree: unknown;
@@ -25,8 +37,12 @@ interface EngageComment {
25
37
  /** Viewer members: present on a live comment only when the listing was fetched for a known reader. */
26
38
  readonly mine?: boolean;
27
39
  readonly liked_by_me?: boolean;
40
+ /** The reader's own reactions, every kind. Absent from a hyle that only says `liked_by_me`. */
41
+ readonly my_reactions?: readonly ReactionKind[];
28
42
  /** ISO instant until which the reader may edit, or null. */
29
43
  readonly can_edit_until?: string | null;
44
+ /** The reader's own vote, or null. Absent from a hyle without votes. */
45
+ readonly my_vote?: VoteValue | null;
30
46
  }
31
47
  /** One of the reader's own held comments (`mine_held`): never part of `comments`, never counted. */
32
48
  interface EngageHeldComment {
@@ -37,6 +53,8 @@ interface EngageHeldComment {
37
53
  readonly created_at: string;
38
54
  readonly edited_at: string | null;
39
55
  readonly can_edit_until: string | null;
56
+ /** As on `EngageComment`. */
57
+ readonly unrenderable?: true;
40
58
  readonly body: {
41
59
  readonly format: "hast";
42
60
  readonly tree: unknown;
@@ -49,11 +67,17 @@ interface EngageListing {
49
67
  readonly publication_id: string;
50
68
  readonly comment_count: number;
51
69
  readonly like_count: number;
52
- /** More than the 500 listed comments exist. */
70
+ /** Reactions on the article by kind. Absent from a hyle without reaction kinds. */
71
+ readonly reaction_counts?: ReactionCounts;
72
+ /** More comments exist than this page lists. A hyle that pages every comment sets it exactly when `next_cursor` is set. */
53
73
  readonly truncated: boolean;
74
+ /** Opaque cursor of the next page, valid with the same sort only. Null or absent when there is none. */
75
+ readonly next_cursor?: string | null;
54
76
  readonly comments: readonly EngageComment[];
55
77
  /** Viewer members: absent from the public listing (anonymous, banned or unknown reader, or a rate-limited viewer read). */
56
78
  readonly liked_by_me?: boolean;
79
+ /** The reader's own reactions on the article. Absent from a hyle that only says `liked_by_me`. */
80
+ readonly my_reactions?: readonly ReactionKind[];
57
81
  readonly mine_held?: readonly EngageHeldComment[];
58
82
  }
59
83
 
@@ -94,6 +118,7 @@ interface CommentStrings {
94
118
  readonly removed: string;
95
119
  readonly removedByModerator: string;
96
120
  readonly removedByAuthor: string;
121
+ readonly unrenderable: string;
97
122
  readonly depthEnd: string;
98
123
  readonly held: string;
99
124
  readonly heldBanner: string;
@@ -122,10 +147,41 @@ interface CommentStrings {
122
147
  readonly more: string;
123
148
  readonly truncated: string;
124
149
  readonly justNow: string;
150
+ readonly react: string;
151
+ readonly reactions: string;
152
+ readonly reactionLike: string;
153
+ readonly reactionLove: string;
154
+ readonly reactionInsightful: string;
155
+ readonly reactionCelebrate: string;
156
+ readonly reactionSignIn: string;
157
+ readonly reactionAddedLive: string;
158
+ readonly reactionRemovedLive: string;
159
+ readonly reactionsLoading: string;
160
+ readonly reactionsError: string;
161
+ readonly votesOn: string;
162
+ readonly score: string;
163
+ readonly upvote: string;
164
+ readonly downvote: string;
165
+ readonly upvoteSignIn: string;
166
+ readonly downvoteSignIn: string;
167
+ readonly upvotedLive: string;
168
+ readonly downvotedLive: string;
169
+ readonly voteRemovedLive: string;
170
+ readonly voteRefused: string;
171
+ readonly slowDown: string;
172
+ readonly sort: string;
173
+ readonly sortNewest: string;
174
+ readonly sortTop: string;
175
+ readonly sortedNewestLive: string;
176
+ readonly sortedTopLive: string;
177
+ readonly sortError: string;
178
+ readonly newerLater: string;
179
+ readonly moreError: string;
180
+ readonly loadedLive: string;
125
181
  }
126
182
 
127
183
  /**
128
- * The comments and likes section of an article (ADR 0017). It is fetched in the browser, uncached, after the cached article
184
+ * The comments, votes and reactions section of an article (ADR 0017, 0021). It is fetched in the browser, uncached, after the cached article
129
185
  * has rendered, so a like never purges a page. It talks only to the host's own `createEngagementRoute` (same origin): no
130
186
  * credential, no hyle URL and no markup built from text ever reaches this file. Comment bodies are server-rendered hast, turned
131
187
  * into React elements by `CommentBody`; the reader's own unapproved comment is shown as plain text.
@@ -146,7 +202,14 @@ interface CommentsProps {
146
202
  readonly initial?: EngageListing | undefined;
147
203
  /** Epoch milliseconds `initial` was fetched at: the first render's clock, so relative times hydrate identically. The real clock takes over on mount. */
148
204
  readonly initialAt?: number | undefined;
205
+ /**
206
+ * Fetch nothing until the section is about to scroll into view (within 600px), so a statically cached page costs no request for
207
+ * readers who never get there. Without IntersectionObserver it loads at once. Default false.
208
+ */
209
+ readonly lazy?: boolean | undefined;
210
+ /** The article's own reactions above the thread. Set false when the page already has `HyleReactions`. Default true. */
211
+ readonly articleReactions?: boolean | undefined;
149
212
  }
150
- declare function Comments({ path, endpoint, signInHref, locale, labels: s, initial, initialAt }: CommentsProps): ReactElement | null;
213
+ declare function Comments(props: CommentsProps): ReactElement;
151
214
 
152
215
  export { Comments, type CommentsProps };
@@ -1,5 +1,11 @@
1
1
  import { ReactElement } from 'react';
2
2
 
3
+ /** The reaction kinds hyle accepts. A reader holds at most one of each kind on a subject. */
4
+ type ReactionKind = "like" | "love" | "insightful" | "celebrate";
5
+ /** Reactions on a subject by kind; a kind nobody used is absent. */
6
+ type ReactionCounts = Readonly<Partial<Record<ReactionKind, number>>>;
7
+ /** A comment vote: up or down. */
8
+ type VoteValue = 1 | -1;
3
9
  /** One comment of `GET /cp1/engage/comments` (docs/cp1-spec.md section 3.11), in thread order. */
4
10
  interface EngageComment {
5
11
  readonly id: string;
@@ -14,10 +20,16 @@ interface EngageComment {
14
20
  readonly created_at: string;
15
21
  readonly edited_at: string | null;
16
22
  readonly like_count: number;
23
+ /** Sum of votes (may be negative; 0 on a tombstone). Absent from a hyle without votes. */
24
+ readonly score?: number;
25
+ /** Absent from a hyle without reaction kinds. */
26
+ readonly reaction_counts?: ReactionCounts;
17
27
  /** A hidden or deleted comment kept only because a visible reply hangs from it: no body, no author. */
18
28
  readonly removed: boolean;
19
29
  /** On a tombstone only: who removed it. Absent on a live comment. */
20
30
  readonly removed_by?: "moderator" | "author";
31
+ /** A live comment hyle can no longer render: `body` is an empty tree. Absent otherwise, and from an older hyle. */
32
+ readonly unrenderable?: true;
21
33
  readonly body: {
22
34
  readonly format: "hast";
23
35
  readonly tree: unknown;
@@ -25,8 +37,12 @@ interface EngageComment {
25
37
  /** Viewer members: present on a live comment only when the listing was fetched for a known reader. */
26
38
  readonly mine?: boolean;
27
39
  readonly liked_by_me?: boolean;
40
+ /** The reader's own reactions, every kind. Absent from a hyle that only says `liked_by_me`. */
41
+ readonly my_reactions?: readonly ReactionKind[];
28
42
  /** ISO instant until which the reader may edit, or null. */
29
43
  readonly can_edit_until?: string | null;
44
+ /** The reader's own vote, or null. Absent from a hyle without votes. */
45
+ readonly my_vote?: VoteValue | null;
30
46
  }
31
47
  /** One of the reader's own held comments (`mine_held`): never part of `comments`, never counted. */
32
48
  interface EngageHeldComment {
@@ -37,6 +53,8 @@ interface EngageHeldComment {
37
53
  readonly created_at: string;
38
54
  readonly edited_at: string | null;
39
55
  readonly can_edit_until: string | null;
56
+ /** As on `EngageComment`. */
57
+ readonly unrenderable?: true;
40
58
  readonly body: {
41
59
  readonly format: "hast";
42
60
  readonly tree: unknown;
@@ -49,11 +67,17 @@ interface EngageListing {
49
67
  readonly publication_id: string;
50
68
  readonly comment_count: number;
51
69
  readonly like_count: number;
52
- /** More than the 500 listed comments exist. */
70
+ /** Reactions on the article by kind. Absent from a hyle without reaction kinds. */
71
+ readonly reaction_counts?: ReactionCounts;
72
+ /** More comments exist than this page lists. A hyle that pages every comment sets it exactly when `next_cursor` is set. */
53
73
  readonly truncated: boolean;
74
+ /** Opaque cursor of the next page, valid with the same sort only. Null or absent when there is none. */
75
+ readonly next_cursor?: string | null;
54
76
  readonly comments: readonly EngageComment[];
55
77
  /** Viewer members: absent from the public listing (anonymous, banned or unknown reader, or a rate-limited viewer read). */
56
78
  readonly liked_by_me?: boolean;
79
+ /** The reader's own reactions on the article. Absent from a hyle that only says `liked_by_me`. */
80
+ readonly my_reactions?: readonly ReactionKind[];
57
81
  readonly mine_held?: readonly EngageHeldComment[];
58
82
  }
59
83
 
@@ -94,6 +118,7 @@ interface CommentStrings {
94
118
  readonly removed: string;
95
119
  readonly removedByModerator: string;
96
120
  readonly removedByAuthor: string;
121
+ readonly unrenderable: string;
97
122
  readonly depthEnd: string;
98
123
  readonly held: string;
99
124
  readonly heldBanner: string;
@@ -122,10 +147,41 @@ interface CommentStrings {
122
147
  readonly more: string;
123
148
  readonly truncated: string;
124
149
  readonly justNow: string;
150
+ readonly react: string;
151
+ readonly reactions: string;
152
+ readonly reactionLike: string;
153
+ readonly reactionLove: string;
154
+ readonly reactionInsightful: string;
155
+ readonly reactionCelebrate: string;
156
+ readonly reactionSignIn: string;
157
+ readonly reactionAddedLive: string;
158
+ readonly reactionRemovedLive: string;
159
+ readonly reactionsLoading: string;
160
+ readonly reactionsError: string;
161
+ readonly votesOn: string;
162
+ readonly score: string;
163
+ readonly upvote: string;
164
+ readonly downvote: string;
165
+ readonly upvoteSignIn: string;
166
+ readonly downvoteSignIn: string;
167
+ readonly upvotedLive: string;
168
+ readonly downvotedLive: string;
169
+ readonly voteRemovedLive: string;
170
+ readonly voteRefused: string;
171
+ readonly slowDown: string;
172
+ readonly sort: string;
173
+ readonly sortNewest: string;
174
+ readonly sortTop: string;
175
+ readonly sortedNewestLive: string;
176
+ readonly sortedTopLive: string;
177
+ readonly sortError: string;
178
+ readonly newerLater: string;
179
+ readonly moreError: string;
180
+ readonly loadedLive: string;
125
181
  }
126
182
 
127
183
  /**
128
- * The comments and likes section of an article (ADR 0017). It is fetched in the browser, uncached, after the cached article
184
+ * The comments, votes and reactions section of an article (ADR 0017, 0021). It is fetched in the browser, uncached, after the cached article
129
185
  * has rendered, so a like never purges a page. It talks only to the host's own `createEngagementRoute` (same origin): no
130
186
  * credential, no hyle URL and no markup built from text ever reaches this file. Comment bodies are server-rendered hast, turned
131
187
  * into React elements by `CommentBody`; the reader's own unapproved comment is shown as plain text.
@@ -146,7 +202,14 @@ interface CommentsProps {
146
202
  readonly initial?: EngageListing | undefined;
147
203
  /** Epoch milliseconds `initial` was fetched at: the first render's clock, so relative times hydrate identically. The real clock takes over on mount. */
148
204
  readonly initialAt?: number | undefined;
205
+ /**
206
+ * Fetch nothing until the section is about to scroll into view (within 600px), so a statically cached page costs no request for
207
+ * readers who never get there. Without IntersectionObserver it loads at once. Default false.
208
+ */
209
+ readonly lazy?: boolean | undefined;
210
+ /** The article's own reactions above the thread. Set false when the page already has `HyleReactions`. Default true. */
211
+ readonly articleReactions?: boolean | undefined;
149
212
  }
150
- declare function Comments({ path, endpoint, signInHref, locale, labels: s, initial, initialAt }: CommentsProps): ReactElement | null;
213
+ declare function Comments(props: CommentsProps): ReactElement;
151
214
 
152
215
  export { Comments, type CommentsProps };