@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.
- package/README.md +261 -42
- package/dist/check-routes-bin.js +190 -53
- package/dist/{chunk-6VOHFFA5.js → chunk-7T5EEJHK.js} +2 -2
- package/dist/chunk-DUPT6XLB.js +57 -0
- package/dist/chunk-IW3TUD4G.js +841 -0
- package/dist/{chunk-MGSUQBDW.js → chunk-KU7LWK4E.js} +249 -24
- package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
- package/dist/chunk-SFFBZFEN.js +178 -0
- package/dist/chunk-U74B7AUG.js +398 -0
- package/dist/chunk-ZIW6FDU2.js +1126 -0
- package/dist/client-BGjmEWhN.d.cts +207 -0
- package/dist/client-D0LTpr3Y.d.ts +207 -0
- package/dist/code-copy.cjs +74 -0
- package/dist/code-copy.d.cts +18 -0
- package/dist/code-copy.d.ts +18 -0
- package/dist/code-copy.js +50 -0
- package/dist/comments.cjs +738 -280
- package/dist/comments.d.cts +66 -3
- package/dist/comments.d.ts +66 -3
- package/dist/comments.js +419 -331
- package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
- package/dist/docs-enhance.cjs +7 -4
- package/dist/docs-enhance.d.cts +5 -3
- package/dist/docs-enhance.d.ts +5 -3
- package/dist/docs-enhance.js +8 -5
- package/dist/{embed-DNTZ2UXv.d.ts → embed-CbtsbZs3.d.cts} +5 -3
- package/dist/{embed-BmdwA2G9.d.cts → embed-Cf_2ZR5x.d.ts} +5 -3
- package/dist/fragment-alias.cjs +51 -0
- package/dist/fragment-alias.d.cts +7 -0
- package/dist/fragment-alias.d.ts +7 -0
- package/dist/fragment-alias.js +27 -0
- package/dist/html.cjs +886 -0
- package/dist/html.d.cts +20 -0
- package/dist/html.d.ts +20 -0
- package/dist/html.js +45 -0
- package/dist/index.cjs +244 -24
- package/dist/index.d.cts +22 -68
- package/dist/index.d.ts +22 -68
- package/dist/index.js +12 -2
- package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.cts} +9 -0
- package/dist/{labels-nmukKYgL.d.ts → labels-CrA-iqTN.d.ts} +9 -0
- package/dist/mermaid-diagram.cjs +441 -125
- package/dist/mermaid-diagram.d.cts +23 -7
- package/dist/mermaid-diagram.d.ts +23 -7
- package/dist/mermaid-diagram.js +213 -51
- package/dist/mermaid-image.cjs +137 -60
- package/dist/mermaid-image.d.cts +4 -3
- package/dist/mermaid-image.d.ts +4 -3
- package/dist/mermaid-image.js +27 -28
- package/dist/next.cjs +836 -304
- package/dist/next.d.cts +45 -20
- package/dist/next.d.ts +45 -20
- package/dist/next.js +151 -40
- package/dist/print-coordinator.cjs +157 -0
- package/dist/print-coordinator.d.cts +27 -0
- package/dist/print-coordinator.d.ts +27 -0
- package/dist/print-coordinator.js +83 -0
- package/dist/react.cjs +603 -240
- package/dist/react.d.cts +148 -30
- package/dist/react.d.ts +148 -30
- package/dist/react.js +26 -4
- package/dist/reactions.cjs +653 -0
- package/dist/reactions.d.cts +27 -0
- package/dist/reactions.d.ts +27 -0
- package/dist/reactions.js +364 -0
- package/dist/{resolve-euZ4-aC9.d.cts → resolve-BnIv7aB7.d.cts} +2 -2
- package/dist/{resolve-Ae7UFjsQ.d.ts → resolve-BysHtZ_i.d.ts} +2 -2
- package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
- package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
- package/dist/sanitize-BpY_AdZh.d.cts +23 -0
- package/dist/sanitize-BpY_AdZh.d.ts +23 -0
- package/dist/styles.css +100 -29
- package/dist/toc-spy.cjs +60 -0
- package/dist/toc-spy.d.cts +15 -0
- package/dist/toc-spy.d.ts +15 -0
- package/dist/toc-spy.js +36 -0
- package/dist/{types-Czt887Iv.d.cts → types-D09Z072G.d.cts} +57 -2
- package/dist/{types-Czt887Iv.d.ts → types-D09Z072G.d.ts} +57 -2
- package/dist/use-cache.cjs +89 -13
- package/dist/use-cache.d.cts +12 -5
- package/dist/use-cache.d.ts +12 -5
- package/dist/use-cache.js +8 -8
- package/dist/youtube-facade.cjs +50 -0
- package/dist/youtube-facade.d.cts +17 -0
- package/dist/youtube-facade.d.ts +17 -0
- package/dist/youtube-facade.js +26 -0
- package/package.json +16 -3
- package/dist/chunk-67IOIAVW.js +0 -35
- package/dist/chunk-DMK4XQLU.js +0 -1556
- package/dist/chunk-PJMJMP66.js +0 -63
- package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
- package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
/** Reader comments and likes under an article (ADR 0017). Pass it only when the workspace has engagement on and the host mounted `createEngagementRoute`. */
|
|
4
|
+
interface EngagementConfig {
|
|
5
|
+
/** The host route that answers the calls. Default "/api/hyle/engage". */
|
|
6
|
+
endpoint?: string | undefined;
|
|
7
|
+
/** Where the "Sign in" button goes (the host's own sign-in). Without it a signed-out visitor sees the prompt but no button. */
|
|
8
|
+
signInHref?: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface HyleReactionsProps {
|
|
12
|
+
/** The article's canonical site path (`publication.canonical_path`). */
|
|
13
|
+
readonly path: string;
|
|
14
|
+
/** The same object `ArticlePage` takes: `endpoint` (default "/api/hyle/engage") and `signInHref`. */
|
|
15
|
+
readonly engagement: EngagementConfig;
|
|
16
|
+
/** BCP 47. English, French and Spanish strings ship; anything else is English. Default "en". */
|
|
17
|
+
readonly locale?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The article's reactions, on their own (for example under the title). Fetched in the browser through the host's
|
|
21
|
+
* `createEngagementRoute`, like `Comments`; renders nothing when engagement is off or the article is unknown.
|
|
22
|
+
* hyle has no counts-only endpoint, so it reads the first page `Comments` reads (the two share the request when they load
|
|
23
|
+
* together) and uses its article fields. It reads on mount even beside a `lazy` `Comments`.
|
|
24
|
+
*/
|
|
25
|
+
declare function HyleReactions(props: HyleReactionsProps): ReactElement;
|
|
26
|
+
|
|
27
|
+
export { HyleReactions, type HyleReactionsProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
/** Reader comments and likes under an article (ADR 0017). Pass it only when the workspace has engagement on and the host mounted `createEngagementRoute`. */
|
|
4
|
+
interface EngagementConfig {
|
|
5
|
+
/** The host route that answers the calls. Default "/api/hyle/engage". */
|
|
6
|
+
endpoint?: string | undefined;
|
|
7
|
+
/** Where the "Sign in" button goes (the host's own sign-in). Without it a signed-out visitor sees the prompt but no button. */
|
|
8
|
+
signInHref?: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface HyleReactionsProps {
|
|
12
|
+
/** The article's canonical site path (`publication.canonical_path`). */
|
|
13
|
+
readonly path: string;
|
|
14
|
+
/** The same object `ArticlePage` takes: `endpoint` (default "/api/hyle/engage") and `signInHref`. */
|
|
15
|
+
readonly engagement: EngagementConfig;
|
|
16
|
+
/** BCP 47. English, French and Spanish strings ship; anything else is English. Default "en". */
|
|
17
|
+
readonly locale?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The article's reactions, on their own (for example under the title). Fetched in the browser through the host's
|
|
21
|
+
* `createEngagementRoute`, like `Comments`; renders nothing when engagement is off or the article is unknown.
|
|
22
|
+
* hyle has no counts-only endpoint, so it reads the first page `Comments` reads (the two share the request when they load
|
|
23
|
+
* together) and uses its article fields. It reads on mount even beside a `lazy` `Comments`.
|
|
24
|
+
*/
|
|
25
|
+
declare function HyleReactions(props: HyleReactionsProps): ReactElement;
|
|
26
|
+
|
|
27
|
+
export { HyleReactions, type HyleReactionsProps };
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Icon,
|
|
4
|
+
ReactionBar,
|
|
5
|
+
call,
|
|
6
|
+
fetchPages,
|
|
7
|
+
isObject,
|
|
8
|
+
kindName,
|
|
9
|
+
useReactions
|
|
10
|
+
} from "./chunk-U74B7AUG.js";
|
|
11
|
+
|
|
12
|
+
// src/react/reactions.tsx
|
|
13
|
+
import { useEffect, useState } from "react";
|
|
14
|
+
|
|
15
|
+
// src/react/comments-labels.ts
|
|
16
|
+
var COMMENT_LABELS_EN = {
|
|
17
|
+
heading: "Comments",
|
|
18
|
+
countLabel: "{n} comments",
|
|
19
|
+
likeArticle: "Like this article",
|
|
20
|
+
likedArticle: "Liked",
|
|
21
|
+
likeArticleSignIn: "(sign in), ",
|
|
22
|
+
likeComment: "Like this comment, ",
|
|
23
|
+
likeCommentSignIn: "Sign in to like this comment, ",
|
|
24
|
+
signInTitle: "Sign in to join the discussion",
|
|
25
|
+
signInBody: "Anyone can read. To comment or like, sign in.",
|
|
26
|
+
signIn: "Sign in",
|
|
27
|
+
commentingAs: "Commenting as {name}",
|
|
28
|
+
write: "Write a comment",
|
|
29
|
+
placeholder: "Add to the discussion",
|
|
30
|
+
help: "Markdown: links, emphasis, code and quotes.",
|
|
31
|
+
chars: "{n} / {max}",
|
|
32
|
+
post: "Post comment",
|
|
33
|
+
posting: "Posting",
|
|
34
|
+
reply: "Reply",
|
|
35
|
+
replyTo: "Reply to {name}",
|
|
36
|
+
replyPlaceholder: "Write a reply",
|
|
37
|
+
cancel: "Cancel",
|
|
38
|
+
edit: "Edit",
|
|
39
|
+
editLeft: "({n} min left)",
|
|
40
|
+
save: "Save",
|
|
41
|
+
delete: "Delete",
|
|
42
|
+
deleteConfirm: "Delete this comment?",
|
|
43
|
+
keep: "Keep",
|
|
44
|
+
you: "You",
|
|
45
|
+
edited: "edited",
|
|
46
|
+
removed: "This comment was removed.",
|
|
47
|
+
removedByModerator: "This comment was removed by a moderator.",
|
|
48
|
+
removedByAuthor: "This comment was deleted by its author.",
|
|
49
|
+
unrenderable: "This comment cannot be displayed.",
|
|
50
|
+
depthEnd: "Replies end at this depth",
|
|
51
|
+
held: "Awaiting approval.",
|
|
52
|
+
heldBanner: "Thanks, your comment is awaiting approval",
|
|
53
|
+
heldBannerBody: "New commenters may be reviewed first. You will see it here, marked as pending, until a moderator approves it. Nobody else can see it yet.",
|
|
54
|
+
heldNote: "Only you can see this until a moderator approves it.",
|
|
55
|
+
heldLive: "Comment awaiting approval",
|
|
56
|
+
postedLive: "Comment posted",
|
|
57
|
+
deletedLive: "Comment deleted",
|
|
58
|
+
savedLive: "Comment saved",
|
|
59
|
+
empty: "No comments yet",
|
|
60
|
+
emptyBody: "Start the discussion. Comments may be reviewed before they appear.",
|
|
61
|
+
loading: "Loading comments",
|
|
62
|
+
loadError: "Comments could not be loaded",
|
|
63
|
+
loadErrorBody: "The article is fine. The comments service did not answer.",
|
|
64
|
+
retry: "Try again",
|
|
65
|
+
postError: "Your comment was not posted. We kept your text, so nothing is lost. Check your connection and try again.",
|
|
66
|
+
tooLong: "That comment is too long or empty. Comments are 1 to 4000 characters.",
|
|
67
|
+
editClosed: "Comments can be edited for ten minutes after posting. That time has passed.",
|
|
68
|
+
actionError: "That did not go through. Please try again.",
|
|
69
|
+
rateTitle: "You are commenting too quickly",
|
|
70
|
+
rateBody: "Please wait before posting again. Your draft is kept in the box below.",
|
|
71
|
+
rateWait: "You can post again in {n} seconds.",
|
|
72
|
+
bannedTitle: "You cannot comment right now",
|
|
73
|
+
bannedBody: "Commenting is not available for your account on this site. You can still read every comment. If you think this is a mistake, contact the site team.",
|
|
74
|
+
expired: "Your session ended. Sign in again to post. Your text is kept.",
|
|
75
|
+
more: "Load more comments",
|
|
76
|
+
truncated: "Only the first part of this discussion is shown.",
|
|
77
|
+
justNow: "just now",
|
|
78
|
+
react: "React",
|
|
79
|
+
reactions: "Reactions",
|
|
80
|
+
reactionLike: "Like",
|
|
81
|
+
reactionLove: "Love",
|
|
82
|
+
reactionInsightful: "Insightful",
|
|
83
|
+
reactionCelebrate: "Celebrate",
|
|
84
|
+
reactionSignIn: "Sign in to react, ",
|
|
85
|
+
reactionAddedLive: "{kind} reaction added",
|
|
86
|
+
reactionRemovedLive: "{kind} reaction removed",
|
|
87
|
+
reactionsLoading: "Loading reactions",
|
|
88
|
+
reactionsError: "Reactions could not be loaded",
|
|
89
|
+
votesOn: "Votes on the comment by {name}",
|
|
90
|
+
score: "Score {n}",
|
|
91
|
+
upvote: "Upvote",
|
|
92
|
+
downvote: "Downvote",
|
|
93
|
+
upvoteSignIn: "Sign in to upvote",
|
|
94
|
+
downvoteSignIn: "Sign in to downvote",
|
|
95
|
+
upvotedLive: "Upvoted. Score {n}",
|
|
96
|
+
downvotedLive: "Downvoted. Score {n}",
|
|
97
|
+
voteRemovedLive: "Vote removed. Score {n}",
|
|
98
|
+
voteRefused: "That vote was not accepted. You cannot vote on your own comment.",
|
|
99
|
+
slowDown: "Too many actions in a short time. Wait a moment and try again.",
|
|
100
|
+
sort: "Sort comments",
|
|
101
|
+
sortNewest: "Newest",
|
|
102
|
+
sortTop: "Top",
|
|
103
|
+
sortedNewestLive: "Showing newest comments first",
|
|
104
|
+
sortedTopLive: "Showing top comments first",
|
|
105
|
+
sortError: "The comments could not be sorted. Please try again.",
|
|
106
|
+
newerLater: "Newer comments appear after you load more.",
|
|
107
|
+
moreError: "More comments could not be loaded. Please try again.",
|
|
108
|
+
loadedLive: "{n} comments loaded"
|
|
109
|
+
};
|
|
110
|
+
var COMMENT_LABELS_FR = {
|
|
111
|
+
heading: "Commentaires",
|
|
112
|
+
countLabel: "{n} commentaires",
|
|
113
|
+
likeArticle: "Aimer cet article",
|
|
114
|
+
likedArticle: "Aim\xE9",
|
|
115
|
+
likeArticleSignIn: "(connexion requise), ",
|
|
116
|
+
likeComment: "Aimer ce commentaire, ",
|
|
117
|
+
likeCommentSignIn: "Connectez-vous pour aimer ce commentaire, ",
|
|
118
|
+
signInTitle: "Connectez-vous pour participer \xE0 la discussion",
|
|
119
|
+
signInBody: "Tout le monde peut lire. Pour commenter ou aimer, connectez-vous.",
|
|
120
|
+
signIn: "Se connecter",
|
|
121
|
+
commentingAs: "Vous commentez en tant que {name}",
|
|
122
|
+
write: "\xC9crire un commentaire",
|
|
123
|
+
placeholder: "Participez \xE0 la discussion",
|
|
124
|
+
help: "Markdown : liens, emphase, code et citations.",
|
|
125
|
+
chars: "{n} / {max}",
|
|
126
|
+
post: "Publier le commentaire",
|
|
127
|
+
posting: "Publication",
|
|
128
|
+
reply: "R\xE9pondre",
|
|
129
|
+
replyTo: "R\xE9pondre \xE0 {name}",
|
|
130
|
+
replyPlaceholder: "\xC9crire une r\xE9ponse",
|
|
131
|
+
cancel: "Annuler",
|
|
132
|
+
edit: "Modifier",
|
|
133
|
+
editLeft: "({n} min restantes)",
|
|
134
|
+
save: "Enregistrer",
|
|
135
|
+
delete: "Supprimer",
|
|
136
|
+
deleteConfirm: "Supprimer ce commentaire ?",
|
|
137
|
+
keep: "Conserver",
|
|
138
|
+
you: "Vous",
|
|
139
|
+
edited: "modifi\xE9",
|
|
140
|
+
removed: "Ce commentaire a \xE9t\xE9 retir\xE9.",
|
|
141
|
+
removedByModerator: "Ce commentaire a \xE9t\xE9 retir\xE9 par un mod\xE9rateur.",
|
|
142
|
+
removedByAuthor: "Ce commentaire a \xE9t\xE9 supprim\xE9 par son auteur.",
|
|
143
|
+
unrenderable: "Ce commentaire ne peut pas \xEAtre affich\xE9.",
|
|
144
|
+
depthEnd: "Les r\xE9ponses s'arr\xEAtent \xE0 ce niveau",
|
|
145
|
+
held: "En attente d'approbation.",
|
|
146
|
+
heldBanner: "Merci, votre commentaire est en attente d'approbation",
|
|
147
|
+
heldBannerBody: "Les nouveaux commentaires peuvent \xEAtre relus d'abord. Vous le voyez ici, marqu\xE9 en attente, jusqu'\xE0 son approbation par un mod\xE9rateur. Personne d'autre ne peut le voir.",
|
|
148
|
+
heldNote: "Vous seul le voyez tant qu'un mod\xE9rateur ne l'a pas approuv\xE9.",
|
|
149
|
+
heldLive: "Commentaire en attente d'approbation",
|
|
150
|
+
postedLive: "Commentaire publi\xE9",
|
|
151
|
+
deletedLive: "Commentaire supprim\xE9",
|
|
152
|
+
savedLive: "Commentaire enregistr\xE9",
|
|
153
|
+
empty: "Aucun commentaire pour l'instant",
|
|
154
|
+
emptyBody: "Lancez la discussion. Les commentaires peuvent \xEAtre relus avant d'appara\xEEtre.",
|
|
155
|
+
loading: "Chargement des commentaires",
|
|
156
|
+
loadError: "Les commentaires n'ont pas pu \xEAtre charg\xE9s",
|
|
157
|
+
loadErrorBody: "L'article est intact. Le service de commentaires n'a pas r\xE9pondu.",
|
|
158
|
+
retry: "R\xE9essayer",
|
|
159
|
+
postError: "Votre commentaire n'a pas \xE9t\xE9 publi\xE9. Votre texte est conserv\xE9. V\xE9rifiez votre connexion et r\xE9essayez.",
|
|
160
|
+
tooLong: "Ce commentaire est trop long ou vide. Un commentaire compte de 1 \xE0 4000 caract\xE8res.",
|
|
161
|
+
editClosed: "Un commentaire peut \xEAtre modifi\xE9 pendant dix minutes apr\xE8s sa publication. Ce d\xE9lai est \xE9coul\xE9.",
|
|
162
|
+
actionError: "L'action a \xE9chou\xE9. R\xE9essayez.",
|
|
163
|
+
rateTitle: "Vous commentez trop vite",
|
|
164
|
+
rateBody: "Patientez avant de publier \xE0 nouveau. Votre brouillon est conserv\xE9 dans la zone ci-dessous.",
|
|
165
|
+
rateWait: "Vous pourrez publier \xE0 nouveau dans {n} secondes.",
|
|
166
|
+
bannedTitle: "Vous ne pouvez pas commenter pour le moment",
|
|
167
|
+
bannedBody: "Les commentaires ne sont pas disponibles pour votre compte sur ce site. Vous pouvez toujours tout lire. Si vous pensez \xE0 une erreur, contactez l'\xE9quipe du site.",
|
|
168
|
+
expired: "Votre session a expir\xE9. Reconnectez-vous pour publier. Votre texte est conserv\xE9.",
|
|
169
|
+
more: "Charger plus de commentaires",
|
|
170
|
+
truncated: "Seul le d\xE9but de cette discussion est affich\xE9.",
|
|
171
|
+
justNow: "\xE0 l'instant",
|
|
172
|
+
react: "R\xE9agir",
|
|
173
|
+
reactions: "R\xE9actions",
|
|
174
|
+
reactionLike: "J'aime",
|
|
175
|
+
reactionLove: "J'adore",
|
|
176
|
+
reactionInsightful: "Instructif",
|
|
177
|
+
reactionCelebrate: "Bravo",
|
|
178
|
+
reactionSignIn: "Connectez-vous pour r\xE9agir, ",
|
|
179
|
+
reactionAddedLive: "R\xE9action {kind} ajout\xE9e",
|
|
180
|
+
reactionRemovedLive: "R\xE9action {kind} retir\xE9e",
|
|
181
|
+
reactionsLoading: "Chargement des r\xE9actions",
|
|
182
|
+
reactionsError: "Les r\xE9actions n'ont pas pu \xEAtre charg\xE9es",
|
|
183
|
+
votesOn: "Votes sur le commentaire de {name}",
|
|
184
|
+
score: "Score {n}",
|
|
185
|
+
upvote: "Voter pour",
|
|
186
|
+
downvote: "Voter contre",
|
|
187
|
+
upvoteSignIn: "Connectez-vous pour voter pour",
|
|
188
|
+
downvoteSignIn: "Connectez-vous pour voter contre",
|
|
189
|
+
upvotedLive: "Vote pour enregistr\xE9. Score {n}",
|
|
190
|
+
downvotedLive: "Vote contre enregistr\xE9. Score {n}",
|
|
191
|
+
voteRemovedLive: "Vote retir\xE9. Score {n}",
|
|
192
|
+
voteRefused: "Ce vote a \xE9t\xE9 refus\xE9. Vous ne pouvez pas voter pour votre propre commentaire.",
|
|
193
|
+
slowDown: "Trop d'actions en peu de temps. Patientez un instant et r\xE9essayez.",
|
|
194
|
+
sort: "Trier les commentaires",
|
|
195
|
+
sortNewest: "R\xE9cents",
|
|
196
|
+
sortTop: "Meilleurs",
|
|
197
|
+
sortedNewestLive: "Commentaires les plus r\xE9cents en premier",
|
|
198
|
+
sortedTopLive: "Meilleurs commentaires en premier",
|
|
199
|
+
sortError: "Les commentaires n'ont pas pu \xEAtre tri\xE9s. R\xE9essayez.",
|
|
200
|
+
newerLater: "Les commentaires plus r\xE9cents apparaissent apr\xE8s le chargement de la suite.",
|
|
201
|
+
moreError: "La suite des commentaires n'a pas pu \xEAtre charg\xE9e. R\xE9essayez.",
|
|
202
|
+
loadedLive: "{n} commentaires charg\xE9s"
|
|
203
|
+
};
|
|
204
|
+
var COMMENT_LABELS_ES = {
|
|
205
|
+
heading: "Comentarios",
|
|
206
|
+
countLabel: "{n} comentarios",
|
|
207
|
+
likeArticle: "Me gusta este art\xEDculo",
|
|
208
|
+
likedArticle: "Te gusta",
|
|
209
|
+
likeArticleSignIn: "(inicia sesi\xF3n), ",
|
|
210
|
+
likeComment: "Me gusta este comentario, ",
|
|
211
|
+
likeCommentSignIn: "Inicia sesi\xF3n para dar me gusta a este comentario, ",
|
|
212
|
+
signInTitle: "Inicia sesi\xF3n para unirte a la conversaci\xF3n",
|
|
213
|
+
signInBody: "Todos pueden leer. Para comentar o dar me gusta, inicia sesi\xF3n.",
|
|
214
|
+
signIn: "Iniciar sesi\xF3n",
|
|
215
|
+
commentingAs: "Comentando como {name}",
|
|
216
|
+
write: "Escribe un comentario",
|
|
217
|
+
placeholder: "A\xF1ade a la conversaci\xF3n",
|
|
218
|
+
help: "Markdown: enlaces, \xE9nfasis, c\xF3digo y citas.",
|
|
219
|
+
chars: "{n} / {max}",
|
|
220
|
+
post: "Publicar comentario",
|
|
221
|
+
posting: "Publicando",
|
|
222
|
+
reply: "Responder",
|
|
223
|
+
replyTo: "Responder a {name}",
|
|
224
|
+
replyPlaceholder: "Escribe una respuesta",
|
|
225
|
+
cancel: "Cancelar",
|
|
226
|
+
edit: "Editar",
|
|
227
|
+
editLeft: "(quedan {n} min)",
|
|
228
|
+
save: "Guardar",
|
|
229
|
+
delete: "Eliminar",
|
|
230
|
+
deleteConfirm: "\xBFEliminar este comentario?",
|
|
231
|
+
keep: "Conservar",
|
|
232
|
+
you: "T\xFA",
|
|
233
|
+
edited: "editado",
|
|
234
|
+
removed: "Este comentario fue eliminado.",
|
|
235
|
+
removedByModerator: "Un moderador elimin\xF3 este comentario.",
|
|
236
|
+
removedByAuthor: "Su autor elimin\xF3 este comentario.",
|
|
237
|
+
unrenderable: "Este comentario no se puede mostrar.",
|
|
238
|
+
depthEnd: "Las respuestas terminan en este nivel",
|
|
239
|
+
held: "Pendiente de aprobaci\xF3n.",
|
|
240
|
+
heldBanner: "Gracias, tu comentario est\xE1 pendiente de aprobaci\xF3n",
|
|
241
|
+
heldBannerBody: "Los comentarios nuevos pueden revisarse primero. Lo ves aqu\xED, marcado como pendiente, hasta que un moderador lo apruebe. Nadie m\xE1s puede verlo todav\xEDa.",
|
|
242
|
+
heldNote: "Solo t\xFA lo ves hasta que un moderador lo apruebe.",
|
|
243
|
+
heldLive: "Comentario pendiente de aprobaci\xF3n",
|
|
244
|
+
postedLive: "Comentario publicado",
|
|
245
|
+
deletedLive: "Comentario eliminado",
|
|
246
|
+
savedLive: "Comentario guardado",
|
|
247
|
+
empty: "A\xFAn no hay comentarios",
|
|
248
|
+
emptyBody: "Empieza la conversaci\xF3n. Los comentarios pueden revisarse antes de aparecer.",
|
|
249
|
+
loading: "Cargando comentarios",
|
|
250
|
+
loadError: "No se pudieron cargar los comentarios",
|
|
251
|
+
loadErrorBody: "El art\xEDculo est\xE1 bien. El servicio de comentarios no respondi\xF3.",
|
|
252
|
+
retry: "Reintentar",
|
|
253
|
+
postError: "Tu comentario no se public\xF3. Hemos conservado tu texto. Revisa tu conexi\xF3n e int\xE9ntalo de nuevo.",
|
|
254
|
+
tooLong: "Ese comentario es demasiado largo o est\xE1 vac\xEDo. Los comentarios tienen de 1 a 4000 caracteres.",
|
|
255
|
+
editClosed: "Un comentario puede editarse durante diez minutos tras publicarlo. Ese tiempo ya pas\xF3.",
|
|
256
|
+
actionError: "No se pudo completar. Int\xE9ntalo de nuevo.",
|
|
257
|
+
rateTitle: "Est\xE1s comentando demasiado r\xE1pido",
|
|
258
|
+
rateBody: "Espera antes de publicar de nuevo. Tu borrador se conserva en el cuadro de abajo.",
|
|
259
|
+
rateWait: "Podr\xE1s publicar de nuevo en {n} segundos.",
|
|
260
|
+
bannedTitle: "No puedes comentar por ahora",
|
|
261
|
+
bannedBody: "Los comentarios no est\xE1n disponibles para tu cuenta en este sitio. A\xFAn puedes leerlos todos. Si crees que es un error, contacta con el equipo del sitio.",
|
|
262
|
+
expired: "Tu sesi\xF3n termin\xF3. Inicia sesi\xF3n de nuevo para publicar. Tu texto se conserva.",
|
|
263
|
+
more: "Cargar m\xE1s comentarios",
|
|
264
|
+
truncated: "Solo se muestra la primera parte de esta conversaci\xF3n.",
|
|
265
|
+
justNow: "ahora mismo",
|
|
266
|
+
react: "Reaccionar",
|
|
267
|
+
reactions: "Reacciones",
|
|
268
|
+
reactionLike: "Me gusta",
|
|
269
|
+
reactionLove: "Me encanta",
|
|
270
|
+
reactionInsightful: "Interesante",
|
|
271
|
+
reactionCelebrate: "Celebrar",
|
|
272
|
+
reactionSignIn: "Inicia sesi\xF3n para reaccionar, ",
|
|
273
|
+
reactionAddedLive: "Reacci\xF3n {kind} a\xF1adida",
|
|
274
|
+
reactionRemovedLive: "Reacci\xF3n {kind} eliminada",
|
|
275
|
+
reactionsLoading: "Cargando reacciones",
|
|
276
|
+
reactionsError: "No se pudieron cargar las reacciones",
|
|
277
|
+
votesOn: "Votos del comentario de {name}",
|
|
278
|
+
score: "Puntuaci\xF3n {n}",
|
|
279
|
+
upvote: "Votar a favor",
|
|
280
|
+
downvote: "Votar en contra",
|
|
281
|
+
upvoteSignIn: "Inicia sesi\xF3n para votar a favor",
|
|
282
|
+
downvoteSignIn: "Inicia sesi\xF3n para votar en contra",
|
|
283
|
+
upvotedLive: "Voto a favor registrado. Puntuaci\xF3n {n}",
|
|
284
|
+
downvotedLive: "Voto en contra registrado. Puntuaci\xF3n {n}",
|
|
285
|
+
voteRemovedLive: "Voto retirado. Puntuaci\xF3n {n}",
|
|
286
|
+
voteRefused: "No se acept\xF3 el voto. No puedes votar tu propio comentario.",
|
|
287
|
+
slowDown: "Demasiadas acciones en poco tiempo. Espera un momento e int\xE9ntalo de nuevo.",
|
|
288
|
+
sort: "Ordenar comentarios",
|
|
289
|
+
sortNewest: "Recientes",
|
|
290
|
+
sortTop: "Destacados",
|
|
291
|
+
sortedNewestLive: "Comentarios m\xE1s recientes primero",
|
|
292
|
+
sortedTopLive: "Comentarios destacados primero",
|
|
293
|
+
sortError: "No se pudieron ordenar los comentarios. Int\xE9ntalo de nuevo.",
|
|
294
|
+
newerLater: "Los comentarios m\xE1s recientes aparecen al cargar m\xE1s.",
|
|
295
|
+
moreError: "No se pudieron cargar m\xE1s comentarios. Int\xE9ntalo de nuevo.",
|
|
296
|
+
loadedLive: "{n} comentarios cargados"
|
|
297
|
+
};
|
|
298
|
+
function commentLabelsFor(locale) {
|
|
299
|
+
const language = locale.slice(0, 2).toLowerCase();
|
|
300
|
+
return language === "fr" ? COMMENT_LABELS_FR : language === "es" ? COMMENT_LABELS_ES : COMMENT_LABELS_EN;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/react/reactions.tsx
|
|
304
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
305
|
+
function HyleReactions(props) {
|
|
306
|
+
return /* @__PURE__ */ jsx(ArticleReactions, { ...props }, `${props.engagement.endpoint ?? ""}
|
|
307
|
+
${props.path}`);
|
|
308
|
+
}
|
|
309
|
+
function ArticleReactions({ path, engagement, locale = "en" }) {
|
|
310
|
+
const endpoint = engagement.endpoint ?? "/api/hyle/engage";
|
|
311
|
+
const s = commentLabelsFor(locale);
|
|
312
|
+
const [session, setSession] = useState("loading");
|
|
313
|
+
const [listing, setListing] = useState("loading");
|
|
314
|
+
const [live, setLive] = useState("");
|
|
315
|
+
const [error, setError] = useState(null);
|
|
316
|
+
const [attempt, setAttempt] = useState(0);
|
|
317
|
+
const reactions = useReactions(endpoint, path);
|
|
318
|
+
useEffect(() => {
|
|
319
|
+
let current = true;
|
|
320
|
+
setListing("loading");
|
|
321
|
+
setError(null);
|
|
322
|
+
reactions.reset();
|
|
323
|
+
void fetchPages(endpoint, path, "newest", 1).then((r) => current && setListing(r.status === 404 ? "off" : r.listing ?? "error"));
|
|
324
|
+
void call(endpoint, "GET", "/session").then((r) => {
|
|
325
|
+
if (!current) return;
|
|
326
|
+
const signedIn = r.status === 200 && isObject(r.data) && isObject(r.data.reader) && typeof r.data.reader.name === "string";
|
|
327
|
+
setSession(r.status === 404 ? "off" : signedIn ? "in" : "out");
|
|
328
|
+
});
|
|
329
|
+
return () => void (current = false);
|
|
330
|
+
}, [endpoint, path, attempt]);
|
|
331
|
+
async function react(kind, count, on) {
|
|
332
|
+
setError(null);
|
|
333
|
+
const r = await reactions.toggle("article", kind, count, on);
|
|
334
|
+
if (!r) return;
|
|
335
|
+
if (r.ok) return setLive((r.on ? s.reactionAddedLive : s.reactionRemovedLive).replace("{kind}", kindName(s, kind)));
|
|
336
|
+
if (r.status === 401) setSession("out");
|
|
337
|
+
setError(r.status === 401 ? s.expired : r.status === 429 ? s.slowDown : s.actionError);
|
|
338
|
+
}
|
|
339
|
+
if (session === "off" || listing === "off") return null;
|
|
340
|
+
const access = session === "loading" ? "pending" : session;
|
|
341
|
+
return /* @__PURE__ */ jsxs("div", { className: "hyle hyle-reactions", "data-slot-component": "HyleReactions", children: [
|
|
342
|
+
/* @__PURE__ */ jsx("p", { className: "hyle-sr", role: "status", "aria-live": "polite", children: live }),
|
|
343
|
+
listing === "loading" ? /* @__PURE__ */ jsxs("div", { className: "hyle-react", "aria-busy": "true", children: [
|
|
344
|
+
/* @__PURE__ */ jsx("span", { className: "hyle-sr", children: s.reactionsLoading }),
|
|
345
|
+
/* @__PURE__ */ jsx("span", { className: "hyle-sk", "aria-hidden": "true" })
|
|
346
|
+
] }) : listing === "error" ? /* @__PURE__ */ jsxs("div", { className: "hyle-react", children: [
|
|
347
|
+
/* @__PURE__ */ jsxs("p", { className: "hyle-cm-err", role: "alert", children: [
|
|
348
|
+
/* @__PURE__ */ jsx(Icon, { name: "alert" }),
|
|
349
|
+
/* @__PURE__ */ jsx("span", { children: s.reactionsError })
|
|
350
|
+
] }),
|
|
351
|
+
/* @__PURE__ */ jsxs("button", { className: "hyle-btn sm", type: "button", onClick: () => setAttempt((n) => n + 1), children: [
|
|
352
|
+
/* @__PURE__ */ jsx(Icon, { name: "refresh" }),
|
|
353
|
+
s.retry
|
|
354
|
+
] })
|
|
355
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "hyle-react", children: /* @__PURE__ */ jsx(ReactionBar, { s, scope: "article", subject: "article", likes: listing.like_count, counts: listing.reaction_counts, likedByMe: listing.liked_by_me === true, mine: listing.my_reactions, overlay: reactions.overlay, access, signInHref: engagement.signInHref, onToggle: (kind, count, on) => void react(kind, count, on) }) }),
|
|
356
|
+
error ? /* @__PURE__ */ jsxs("p", { className: "hyle-cm-err", role: "alert", children: [
|
|
357
|
+
/* @__PURE__ */ jsx(Icon, { name: "alert" }),
|
|
358
|
+
/* @__PURE__ */ jsx("span", { children: error })
|
|
359
|
+
] }) : null
|
|
360
|
+
] });
|
|
361
|
+
}
|
|
362
|
+
export {
|
|
363
|
+
HyleReactions
|
|
364
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Resolved } from './types-D09Z072G.cjs';
|
|
2
2
|
|
|
3
3
|
/** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
|
|
4
4
|
type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string, nav?: "tree", format?: "md") => Promise<Resolved>;
|
|
@@ -7,7 +7,7 @@ interface FetchResolverOptions {
|
|
|
7
7
|
readonly token: string;
|
|
8
8
|
/** The workspace id (HYLE_WORKSPACE_ID): the fetch is tagged before the response exists, so tags are built from it. */
|
|
9
9
|
readonly workspaceId: string;
|
|
10
|
-
/**
|
|
10
|
+
/** Safety-net seconds before a cached page is revalidated in the background. Tag webhooks purge pages when content changes, so this only bounds a missed webhook. Default 86400. */
|
|
11
11
|
readonly revalidate?: number;
|
|
12
12
|
/** Section slugs this mount shows (its own section slug first): each gets a cache tag. Used only for tagging. */
|
|
13
13
|
readonly sections?: readonly string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Resolved } from './types-D09Z072G.js';
|
|
2
2
|
|
|
3
3
|
/** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
|
|
4
4
|
type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string, nav?: "tree", format?: "md") => Promise<Resolved>;
|
|
@@ -7,7 +7,7 @@ interface FetchResolverOptions {
|
|
|
7
7
|
readonly token: string;
|
|
8
8
|
/** The workspace id (HYLE_WORKSPACE_ID): the fetch is tagged before the response exists, so tags are built from it. */
|
|
9
9
|
readonly workspaceId: string;
|
|
10
|
-
/**
|
|
10
|
+
/** Safety-net seconds before a cached page is revalidated in the background. Tag webhooks purge pages when content changes, so this only bounds a missed webhook. Default 86400. */
|
|
11
11
|
readonly revalidate?: number;
|
|
12
12
|
/** Section slugs this mount shows (its own section slug first): each gets a cache tag. Used only for tagging. */
|
|
13
13
|
readonly sections?: readonly string[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
declare const COMMENT_EVENT_TYPES: readonly ["comment.held", "comment.reply", "comment.approved", "comment.hidden"];
|
|
2
|
+
type CommentEventType = (typeof COMMENT_EVENT_TYPES)[number];
|
|
3
|
+
/** A comment notification (docs/cp1-spec.md section 5.3.1). No comment text: fetch it from the engagement surface. */
|
|
4
|
+
interface CommentEvent {
|
|
5
|
+
readonly cp: 1;
|
|
6
|
+
/** The delivery id: identical on every retry of the same delivery, so dedupe on it. */
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly type: CommentEventType;
|
|
9
|
+
readonly created_at: string;
|
|
10
|
+
readonly workspace_id: string;
|
|
11
|
+
readonly event_id: string;
|
|
12
|
+
readonly data: {
|
|
13
|
+
readonly comment_id: string;
|
|
14
|
+
readonly parent_comment_id: string | null;
|
|
15
|
+
readonly publication_path: string;
|
|
16
|
+
/** Your own reader subject, or null once that reader's data is erased. */
|
|
17
|
+
readonly reader_sub: string | null;
|
|
18
|
+
readonly parent_reader_sub: string | null;
|
|
19
|
+
readonly status: "held" | "visible" | "hidden";
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The comment event in a parsed webhook payload, or undefined when it is not one (any other `type` or protocol version, or a
|
|
24
|
+
* malformed shape). It checks the shape only: call it on a body whose signature you have verified. Extra fields are dropped.
|
|
25
|
+
*/
|
|
26
|
+
declare function parseCommentEvent(payload: unknown): CommentEvent | undefined;
|
|
27
|
+
interface RevalidationPayload {
|
|
28
|
+
readonly cp: number;
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly type: string;
|
|
31
|
+
readonly created_at: string;
|
|
32
|
+
readonly workspace_id: string;
|
|
33
|
+
readonly event_id: string;
|
|
34
|
+
readonly reason: string;
|
|
35
|
+
readonly epoch: number;
|
|
36
|
+
readonly tags: readonly string[];
|
|
37
|
+
readonly paths?: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
interface RevalidationCallbackOptions {
|
|
40
|
+
/** This deployment's own configured workspace -- a mismatched payload is ignored (step 5), never rejected. */
|
|
41
|
+
readonly workspaceId: string;
|
|
42
|
+
/** Current secret first, previous secret(s) after, for rotation with a grace window (section 5.2). */
|
|
43
|
+
readonly secrets: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* Wired by the caller to next/cache's own revalidateTag -- this package
|
|
46
|
+
* never imports next/cache directly, so it stays usable outside a Next.js
|
|
47
|
+
* runtime too (docs/cp1-spec.md section 7.7's own framework-boundary
|
|
48
|
+
* spirit, applied here even though the SDK itself is outside that
|
|
49
|
+
* table).
|
|
50
|
+
*/
|
|
51
|
+
readonly revalidateTag: (tag: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Called for a verified comment event of this workspace (the endpoint must have comment notifications switched on in hyle).
|
|
54
|
+
* At most once per delivery id per instance, and NOT retried: a throw, or no answer within 3 s, is logged and the delivery is
|
|
55
|
+
* still answered 200, because failed deliveries trip hyle's circuit breaker, which would also stop content revalidation.
|
|
56
|
+
* Put work that must not be lost on your own queue here.
|
|
57
|
+
*/
|
|
58
|
+
readonly onCommentEvent?: ((event: CommentEvent) => void | Promise<void>) | undefined;
|
|
59
|
+
readonly toleranceSeconds?: number;
|
|
60
|
+
readonly dedupeCapacity?: number;
|
|
61
|
+
/** Injectable for tests; defaults to the real wall clock. */
|
|
62
|
+
readonly now?: () => number;
|
|
63
|
+
}
|
|
64
|
+
interface RevalidationCallbackRoute {
|
|
65
|
+
readonly POST: (req: Request) => Promise<Response>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* docs/cp1-spec.md section 5.6, all nine steps, in order. Never throws for
|
|
69
|
+
* an expected condition (a mismatched workspace, an unknown cp version) --
|
|
70
|
+
* those are 200-and-ignore, specifically so they never trip the sender's
|
|
71
|
+
* circuit breaker (section 5.7) for an endpoint that is otherwise healthy.
|
|
72
|
+
*/
|
|
73
|
+
declare function createRevalidationCallbackRoute(options: RevalidationCallbackOptions): RevalidationCallbackRoute;
|
|
74
|
+
|
|
75
|
+
export { type CommentEvent as C, type RevalidationCallbackOptions as R, type CommentEventType as a, type RevalidationCallbackRoute as b, type RevalidationPayload as c, createRevalidationCallbackRoute as d, parseCommentEvent as p };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
declare const COMMENT_EVENT_TYPES: readonly ["comment.held", "comment.reply", "comment.approved", "comment.hidden"];
|
|
2
|
+
type CommentEventType = (typeof COMMENT_EVENT_TYPES)[number];
|
|
3
|
+
/** A comment notification (docs/cp1-spec.md section 5.3.1). No comment text: fetch it from the engagement surface. */
|
|
4
|
+
interface CommentEvent {
|
|
5
|
+
readonly cp: 1;
|
|
6
|
+
/** The delivery id: identical on every retry of the same delivery, so dedupe on it. */
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly type: CommentEventType;
|
|
9
|
+
readonly created_at: string;
|
|
10
|
+
readonly workspace_id: string;
|
|
11
|
+
readonly event_id: string;
|
|
12
|
+
readonly data: {
|
|
13
|
+
readonly comment_id: string;
|
|
14
|
+
readonly parent_comment_id: string | null;
|
|
15
|
+
readonly publication_path: string;
|
|
16
|
+
/** Your own reader subject, or null once that reader's data is erased. */
|
|
17
|
+
readonly reader_sub: string | null;
|
|
18
|
+
readonly parent_reader_sub: string | null;
|
|
19
|
+
readonly status: "held" | "visible" | "hidden";
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The comment event in a parsed webhook payload, or undefined when it is not one (any other `type` or protocol version, or a
|
|
24
|
+
* malformed shape). It checks the shape only: call it on a body whose signature you have verified. Extra fields are dropped.
|
|
25
|
+
*/
|
|
26
|
+
declare function parseCommentEvent(payload: unknown): CommentEvent | undefined;
|
|
27
|
+
interface RevalidationPayload {
|
|
28
|
+
readonly cp: number;
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly type: string;
|
|
31
|
+
readonly created_at: string;
|
|
32
|
+
readonly workspace_id: string;
|
|
33
|
+
readonly event_id: string;
|
|
34
|
+
readonly reason: string;
|
|
35
|
+
readonly epoch: number;
|
|
36
|
+
readonly tags: readonly string[];
|
|
37
|
+
readonly paths?: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
interface RevalidationCallbackOptions {
|
|
40
|
+
/** This deployment's own configured workspace -- a mismatched payload is ignored (step 5), never rejected. */
|
|
41
|
+
readonly workspaceId: string;
|
|
42
|
+
/** Current secret first, previous secret(s) after, for rotation with a grace window (section 5.2). */
|
|
43
|
+
readonly secrets: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* Wired by the caller to next/cache's own revalidateTag -- this package
|
|
46
|
+
* never imports next/cache directly, so it stays usable outside a Next.js
|
|
47
|
+
* runtime too (docs/cp1-spec.md section 7.7's own framework-boundary
|
|
48
|
+
* spirit, applied here even though the SDK itself is outside that
|
|
49
|
+
* table).
|
|
50
|
+
*/
|
|
51
|
+
readonly revalidateTag: (tag: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Called for a verified comment event of this workspace (the endpoint must have comment notifications switched on in hyle).
|
|
54
|
+
* At most once per delivery id per instance, and NOT retried: a throw, or no answer within 3 s, is logged and the delivery is
|
|
55
|
+
* still answered 200, because failed deliveries trip hyle's circuit breaker, which would also stop content revalidation.
|
|
56
|
+
* Put work that must not be lost on your own queue here.
|
|
57
|
+
*/
|
|
58
|
+
readonly onCommentEvent?: ((event: CommentEvent) => void | Promise<void>) | undefined;
|
|
59
|
+
readonly toleranceSeconds?: number;
|
|
60
|
+
readonly dedupeCapacity?: number;
|
|
61
|
+
/** Injectable for tests; defaults to the real wall clock. */
|
|
62
|
+
readonly now?: () => number;
|
|
63
|
+
}
|
|
64
|
+
interface RevalidationCallbackRoute {
|
|
65
|
+
readonly POST: (req: Request) => Promise<Response>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* docs/cp1-spec.md section 5.6, all nine steps, in order. Never throws for
|
|
69
|
+
* an expected condition (a mismatched workspace, an unknown cp version) --
|
|
70
|
+
* those are 200-and-ignore, specifically so they never trip the sender's
|
|
71
|
+
* circuit breaker (section 5.7) for an endpoint that is otherwise healthy.
|
|
72
|
+
*/
|
|
73
|
+
declare function createRevalidationCallbackRoute(options: RevalidationCallbackOptions): RevalidationCallbackRoute;
|
|
74
|
+
|
|
75
|
+
export { type CommentEvent as C, type RevalidationCallbackOptions as R, type CommentEventType as a, type RevalidationCallbackRoute as b, type RevalidationPayload as c, createRevalidationCallbackRoute as d, parseCommentEvent as p };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Root } from 'hast';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Defense in depth. hyle sanitizes server-side (packages/renderer/src/render.ts); this guard repeats the same allowlist
|
|
5
|
+
* so a compromised or buggy response still cannot put script, event handlers or `javascript:` URLs on the page. It
|
|
6
|
+
* rebuilds the tree from scratch: only listed tags, only listed properties with an accepted value shape, and nothing
|
|
7
|
+
* else is copied. Unknown tags are unwrapped (children kept); script and style are dropped with their text.
|
|
8
|
+
*/
|
|
9
|
+
/** Thrown when a tree exceeds the node or size caps; `HastContent` renders a safe notice instead of the content. */
|
|
10
|
+
declare class HastLimitError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
declare const scopeId: (id: string) => string;
|
|
14
|
+
/** Accepts a site-relative path, a fragment (href only), or an absolute http(s) URL (mailto for href only). */
|
|
15
|
+
declare function isSafeUrl(value: unknown, kind: "href" | "src"): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @param title when the body opens with an h1 that repeats the page title, that h1 is dropped (the page renders the title itself).
|
|
18
|
+
* @param description when the first paragraph after that h1 is exactly it, the paragraph is dropped (the page renders the description itself; hyle derives it from that paragraph). A paragraph that says more, as under a description hyle cut at 300 characters, is kept whole. A paragraph with an embed link is never dropped: the description can be a bare video URL.
|
|
19
|
+
* @throws HastLimitError when the tree has more than 20,000 nodes or 512 KiB of text (hyle's own renderer caps).
|
|
20
|
+
*/
|
|
21
|
+
declare function sanitizeHast(tree: unknown, title?: string, description?: string | null): Root;
|
|
22
|
+
|
|
23
|
+
export { HastLimitError as H, scopeId as a, isSafeUrl as i, sanitizeHast as s };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Root } from 'hast';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Defense in depth. hyle sanitizes server-side (packages/renderer/src/render.ts); this guard repeats the same allowlist
|
|
5
|
+
* so a compromised or buggy response still cannot put script, event handlers or `javascript:` URLs on the page. It
|
|
6
|
+
* rebuilds the tree from scratch: only listed tags, only listed properties with an accepted value shape, and nothing
|
|
7
|
+
* else is copied. Unknown tags are unwrapped (children kept); script and style are dropped with their text.
|
|
8
|
+
*/
|
|
9
|
+
/** Thrown when a tree exceeds the node or size caps; `HastContent` renders a safe notice instead of the content. */
|
|
10
|
+
declare class HastLimitError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
declare const scopeId: (id: string) => string;
|
|
14
|
+
/** Accepts a site-relative path, a fragment (href only), or an absolute http(s) URL (mailto for href only). */
|
|
15
|
+
declare function isSafeUrl(value: unknown, kind: "href" | "src"): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @param title when the body opens with an h1 that repeats the page title, that h1 is dropped (the page renders the title itself).
|
|
18
|
+
* @param description when the first paragraph after that h1 is exactly it, the paragraph is dropped (the page renders the description itself; hyle derives it from that paragraph). A paragraph that says more, as under a description hyle cut at 300 characters, is kept whole. A paragraph with an embed link is never dropped: the description can be a bare video URL.
|
|
19
|
+
* @throws HastLimitError when the tree has more than 20,000 nodes or 512 KiB of text (hyle's own renderer caps).
|
|
20
|
+
*/
|
|
21
|
+
declare function sanitizeHast(tree: unknown, title?: string, description?: string | null): Root;
|
|
22
|
+
|
|
23
|
+
export { HastLimitError as H, scopeId as a, isSafeUrl as i, sanitizeHast as s };
|