@blogmcp/sdk 0.9.3 → 0.10.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/dist/community/channels.d.ts +7 -6
- package/dist/community/channels.js +4 -4
- package/dist/community/client.d.ts +74 -4
- package/dist/community/client.js +143 -91
- package/dist/community/index.d.ts +11 -6
- package/dist/community/index.js +111 -80
- package/dist/community/links.d.ts +61 -1
- package/dist/community/links.js +94 -40
- package/dist/community/manifest/index.d.ts +54 -0
- package/dist/community/manifest/index.js +46 -0
- package/dist/community/mentions.d.ts +38 -0
- package/dist/community/mentions.js +25 -0
- package/dist/community/messages.cs.d.ts +73 -3
- package/dist/community/messages.cs.js +82 -3
- package/dist/community/messages.d.ts +11 -0
- package/dist/community/messages.en.d.ts +69 -1
- package/dist/community/messages.en.js +71 -1
- package/dist/community/messages.js +26 -16
- package/dist/community/outcome.d.ts +8 -3
- package/dist/community/outcome.js +72 -28
- package/dist/community/realtime/index.d.ts +118 -0
- package/dist/community/realtime/index.js +215 -0
- package/dist/community/routes.d.ts +12 -0
- package/dist/community/routes.js +41 -25
- package/dist/community/server/bff.js +25 -25
- package/dist/community/server/host-routes.js +12 -0
- package/dist/community/server/index.d.ts +1 -1
- package/dist/community/server/index.js +15 -14
- package/dist/community/server/route-decision.d.ts +8 -0
- package/dist/community/server/route-decision.js +28 -22
- package/dist/community/shapes.d.ts +214 -2
- package/dist/community/shapes.js +65 -25
- package/dist/community/store.d.ts +18 -1
- package/dist/community/store.js +316 -261
- package/dist/community/sw/index.d.ts +45 -0
- package/dist/community/sw/index.js +59 -0
- package/dist/community/ua.d.ts +12 -0
- package/dist/community/ua.js +9 -0
- package/dist/packages/mdx-render-vue/dist/node_modules/dompurify/dist/purify.es.js +1342 -484
- package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
- package/package.json +21 -3
- package/src/community/channels.ts +8 -7
- package/src/community/client.ts +116 -5
- package/src/community/index.ts +59 -1
- package/src/community/links.ts +119 -2
- package/src/community/manifest/index.ts +107 -0
- package/src/community/mentions.ts +59 -0
- package/src/community/messages.cs.ts +88 -3
- package/src/community/messages.en.ts +77 -1
- package/src/community/messages.ts +19 -0
- package/src/community/outcome.ts +50 -1
- package/src/community/realtime/index.ts +522 -0
- package/src/community/routes.ts +16 -0
- package/src/community/server/bff.ts +2 -4
- package/src/community/server/host-routes.ts +12 -0
- package/src/community/server/index.ts +1 -0
- package/src/community/server/route-decision.ts +15 -0
- package/src/community/shapes.ts +256 -3
- package/src/community/store.ts +114 -0
- package/src/community/sw/index.ts +112 -0
- package/src/community/ua.ts +17 -0
package/dist/community/index.js
CHANGED
|
@@ -1,93 +1,124 @@
|
|
|
1
|
-
import { createCommunityClient as
|
|
2
|
-
import { COMMUNITY_APPEAL_MAX as
|
|
3
|
-
import { COMMUNITY_API_CODES as y, COMMUNITY_HOST_CODES as
|
|
4
|
-
import { assertCommunityBase as h, communityOpUrl as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { createCommunityClient as o } from "./client.js";
|
|
2
|
+
import { COMMUNITY_APPEAL_MAX as t, COMMUNITY_BIO_MAX as T, COMMUNITY_CLIENT_MSG_ID_RE as s, COMMUNITY_DISPLAY_NAME_MAX as O, COMMUNITY_DISPLAY_NAME_MIN as n, COMMUNITY_GOOD_FAITH as E, COMMUNITY_HANDLE_CHANGE_DAYS as i, COMMUNITY_HANDLE_RE as r, COMMUNITY_HEAD_ARTICLES_MAX as I, COMMUNITY_MESSAGE_LINKS_MAX as N, COMMUNITY_MESSAGE_MAX as C, COMMUNITY_NOTICE_DESCRIPTION_MAX as S, COMMUNITY_NOTICE_TURNSTILE_ACTION as m, COMMUNITY_NOTIFIER_NAME_MAX as A, COMMUNITY_OPS as a, COMMUNITY_PAGE_SIZE as U, COMMUNITY_REPLIES_MAX as R, COMMUNITY_REPORT_NOTE_MAX as u, communityOpPath as L, newClientMsgId as Y } from "./routes.js";
|
|
3
|
+
import { COMMUNITY_API_CODES as y, COMMUNITY_HOST_CODES as f, COMMUNITY_OUTCOME_OF_HOST as D, COMMUNITY_OUTCOME_OF_KB as g, COMMUNITY_UI_CODES as p, CommunityTransportError as K, communityFailureOf as P, communityOutcomeOf as H, isCommunityTransportError as l, isCommunityUiCode as F, isLoggedCommunityOutcome as d } from "./outcome.js";
|
|
4
|
+
import { assertCommunityBase as h, communityOpUrl as X, fetchTransport as w, isRelativeCommunityBase as x } from "./transport.js";
|
|
5
|
+
import { IN_APP_BROWSER_RE as k, isInAppBrowser as b } from "./ua.js";
|
|
6
|
+
import { AGE_BANDS as V, ART9_CONSENT_LAYOUTS as W, ART9_CONTROLLERS_MAX as q, ART9_REFUSALS as Z, AUTHOR_KINDS as j, CASE_CATEGORIES as z, CATEGORY_WITHOUT_NOTIFIER as J, LEGAL_TEXT_KINDS as Q, MESSAGE_STATES as $, MODULE_STATES as ee, MUTE_TARGET_KINDS as Me, NEEDS as oe, NOTIFICATION_CODES as _e, PUSH_USER_AGENT_CLASSES as te, REALTIME_EVENT_KINDS as Te, RESTRICTION_KINDS as se, TRUST_LABELS as Oe, art9ConsentLayoutOf as ne, art9ControllersOf as Ee, art9RefusalOf as ie, communityLegalSectionsOf as re, communityRulesOf as Ie, isCaseCategory as Ne, isKnownAuthor as Ce, isKnownAuthorKind as Se, isKnownModuleState as me, isKnownNeed as Ae, isKnownNotificationCode as ae, isKnownRestrictionKind as Ue, isKnownState as Re, isKnownTrustLabel as ue } from "./shapes.js";
|
|
7
|
+
import { createDiscussionStore as Ye, findMessage as ce, isOwnMessage as ye, loadMoreDiscussion as fe, reactionAfter as De, reactionsFor as ge, refreshDiscussion as pe, viewerNeeds as Ke } from "./store.js";
|
|
8
|
+
import { POLL_INTERVAL_MS as He, POLL_MAX_BACKOFF_MS as le, pollDiscussionHead as Fe } from "./poll.js";
|
|
9
|
+
import { COMMUNITY_CHANNELS as Ge } from "./channels.js";
|
|
10
|
+
import { COMMUNITY_DIGEST_TOKEN_RE as Xe, COMMUNITY_MESSAGE_ANCHOR_PREFIX as we, COMMUNITY_RECEIPT_RE as xe, COMMUNITY_ROUTES as Be, communityMessageAnchor as ke, communityMessageLink as be, communityMessageSeqFromHash as ve, digestTokenFromHash as Ve, forgetDigestToken as We, myCommunityPath as qe, noticeStatusLink as Ze, profilePath as je, readDigestTokenFromHash as ze, readReceiptFromHash as Je, receiptFromHash as Qe, signInLink as $e, statementPath as eM } from "./links.js";
|
|
11
|
+
import { COMMUNITY_MENTION_RE as oM, communityMentionHandles as _M, communityMentionSpans as tM } from "./mentions.js";
|
|
12
|
+
import { COMMUNITY_MESSAGES as sM, communityMessage as OM, communityMessageLanguage as nM, confirmMessageKey as EM, hasCommunityMessage as iM, noteMessageKey as rM, notificationMessageKey as IM, trustLabelMessageKey as NM, warningMessageKey as CM } from "./messages.js";
|
|
11
13
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
V as AGE_BANDS,
|
|
15
|
+
W as ART9_CONSENT_LAYOUTS,
|
|
16
|
+
q as ART9_CONTROLLERS_MAX,
|
|
17
|
+
Z as ART9_REFUSALS,
|
|
18
|
+
j as AUTHOR_KINDS,
|
|
19
|
+
z as CASE_CATEGORIES,
|
|
20
|
+
J as CATEGORY_WITHOUT_NOTIFIER,
|
|
16
21
|
y as COMMUNITY_API_CODES,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
t as COMMUNITY_APPEAL_MAX,
|
|
23
|
+
T as COMMUNITY_BIO_MAX,
|
|
24
|
+
Ge as COMMUNITY_CHANNELS,
|
|
25
|
+
s as COMMUNITY_CLIENT_MSG_ID_RE,
|
|
26
|
+
Xe as COMMUNITY_DIGEST_TOKEN_RE,
|
|
27
|
+
O as COMMUNITY_DISPLAY_NAME_MAX,
|
|
28
|
+
n as COMMUNITY_DISPLAY_NAME_MIN,
|
|
29
|
+
E as COMMUNITY_GOOD_FAITH,
|
|
30
|
+
i as COMMUNITY_HANDLE_CHANGE_DAYS,
|
|
31
|
+
r as COMMUNITY_HANDLE_RE,
|
|
32
|
+
I as COMMUNITY_HEAD_ARTICLES_MAX,
|
|
33
|
+
f as COMMUNITY_HOST_CODES,
|
|
34
|
+
oM as COMMUNITY_MENTION_RE,
|
|
35
|
+
sM as COMMUNITY_MESSAGES,
|
|
36
|
+
we as COMMUNITY_MESSAGE_ANCHOR_PREFIX,
|
|
37
|
+
N as COMMUNITY_MESSAGE_LINKS_MAX,
|
|
38
|
+
C as COMMUNITY_MESSAGE_MAX,
|
|
39
|
+
S as COMMUNITY_NOTICE_DESCRIPTION_MAX,
|
|
40
|
+
m as COMMUNITY_NOTICE_TURNSTILE_ACTION,
|
|
41
|
+
A as COMMUNITY_NOTIFIER_NAME_MAX,
|
|
34
42
|
a as COMMUNITY_OPS,
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
D as COMMUNITY_OUTCOME_OF_HOST,
|
|
44
|
+
g as COMMUNITY_OUTCOME_OF_KB,
|
|
37
45
|
U as COMMUNITY_PAGE_SIZE,
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
xe as COMMUNITY_RECEIPT_RE,
|
|
47
|
+
R as COMMUNITY_REPLIES_MAX,
|
|
40
48
|
u as COMMUNITY_REPORT_NOTE_MAX,
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
Be as COMMUNITY_ROUTES,
|
|
50
|
+
p as COMMUNITY_UI_CODES,
|
|
43
51
|
K as CommunityTransportError,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
k as IN_APP_BROWSER_RE,
|
|
53
|
+
Q as LEGAL_TEXT_KINDS,
|
|
54
|
+
$ as MESSAGE_STATES,
|
|
55
|
+
ee as MODULE_STATES,
|
|
56
|
+
Me as MUTE_TARGET_KINDS,
|
|
57
|
+
oe as NEEDS,
|
|
58
|
+
_e as NOTIFICATION_CODES,
|
|
59
|
+
He as POLL_INTERVAL_MS,
|
|
60
|
+
le as POLL_MAX_BACKOFF_MS,
|
|
61
|
+
te as PUSH_USER_AGENT_CLASSES,
|
|
62
|
+
Te as REALTIME_EVENT_KINDS,
|
|
63
|
+
se as RESTRICTION_KINDS,
|
|
64
|
+
Oe as TRUST_LABELS,
|
|
65
|
+
ne as art9ConsentLayoutOf,
|
|
66
|
+
Ee as art9ControllersOf,
|
|
67
|
+
ie as art9RefusalOf,
|
|
51
68
|
h as assertCommunityBase,
|
|
52
69
|
P as communityFailureOf,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
re as communityLegalSectionsOf,
|
|
71
|
+
_M as communityMentionHandles,
|
|
72
|
+
tM as communityMentionSpans,
|
|
73
|
+
OM as communityMessage,
|
|
74
|
+
ke as communityMessageAnchor,
|
|
75
|
+
nM as communityMessageLanguage,
|
|
76
|
+
be as communityMessageLink,
|
|
77
|
+
ve as communityMessageSeqFromHash,
|
|
78
|
+
L as communityOpPath,
|
|
79
|
+
X as communityOpUrl,
|
|
58
80
|
H as communityOutcomeOf,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
Ie as communityRulesOf,
|
|
82
|
+
EM as confirmMessageKey,
|
|
83
|
+
o as createCommunityClient,
|
|
84
|
+
Ye as createDiscussionStore,
|
|
85
|
+
Ve as digestTokenFromHash,
|
|
63
86
|
w as fetchTransport,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
87
|
+
ce as findMessage,
|
|
88
|
+
We as forgetDigestToken,
|
|
89
|
+
iM as hasCommunityMessage,
|
|
90
|
+
Ne as isCaseCategory,
|
|
91
|
+
l as isCommunityTransportError,
|
|
68
92
|
F as isCommunityUiCode,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
93
|
+
b as isInAppBrowser,
|
|
94
|
+
Ce as isKnownAuthor,
|
|
95
|
+
Se as isKnownAuthorKind,
|
|
96
|
+
me as isKnownModuleState,
|
|
97
|
+
Ae as isKnownNeed,
|
|
98
|
+
ae as isKnownNotificationCode,
|
|
99
|
+
Ue as isKnownRestrictionKind,
|
|
100
|
+
Re as isKnownState,
|
|
101
|
+
ue as isKnownTrustLabel,
|
|
102
|
+
d as isLoggedCommunityOutcome,
|
|
103
|
+
ye as isOwnMessage,
|
|
77
104
|
x as isRelativeCommunityBase,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
105
|
+
fe as loadMoreDiscussion,
|
|
106
|
+
qe as myCommunityPath,
|
|
107
|
+
Y as newClientMsgId,
|
|
108
|
+
rM as noteMessageKey,
|
|
109
|
+
Ze as noticeStatusLink,
|
|
110
|
+
IM as notificationMessageKey,
|
|
111
|
+
Fe as pollDiscussionHead,
|
|
112
|
+
je as profilePath,
|
|
113
|
+
De as reactionAfter,
|
|
114
|
+
ge as reactionsFor,
|
|
115
|
+
ze as readDigestTokenFromHash,
|
|
116
|
+
Je as readReceiptFromHash,
|
|
117
|
+
Qe as receiptFromHash,
|
|
118
|
+
pe as refreshDiscussion,
|
|
119
|
+
$e as signInLink,
|
|
120
|
+
eM as statementPath,
|
|
121
|
+
NM as trustLabelMessageKey,
|
|
122
|
+
Ke as viewerNeeds,
|
|
123
|
+
CM as warningMessageKey
|
|
93
124
|
};
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
* takes them as attributes. Without them the managed blog's pages apply, COMMUNITY_ROUTES — the paths kb-api's
|
|
10
10
|
* deliveries fall back to (a drift spec pins them to kb-api's).
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* M2 T8: the module's pages (profile, settings, welcome, notifications, discussions) and the digest's unsubscribe
|
|
13
|
+
* token, which travels in the fragment of the settings page's link (`#u=<kbun_…>`) by the receipt's rule.
|
|
14
|
+
*
|
|
15
|
+
* Browser-safe; readReceiptFromHash and readDigestTokenFromHash are the functions that touch `window` (on call,
|
|
16
|
+
* never on import).
|
|
13
17
|
*/
|
|
14
18
|
/**
|
|
15
19
|
* The managed blog's community pages (router-relative; the blog prepends its own base). The three legal pages —
|
|
@@ -31,6 +35,16 @@ export declare const COMMUNITY_ROUTES: Readonly<{
|
|
|
31
35
|
readonly terms: "/community/terms";
|
|
32
36
|
/** The discussion privacy notice, rendered the same way. */
|
|
33
37
|
readonly privacy: "/community/privacy";
|
|
38
|
+
/** The discussions overview (the articles with a discussion). */
|
|
39
|
+
readonly discussions: "/community/discussions";
|
|
40
|
+
/** A member's public profile; `{handle}` is the member's handle (profilePath). */
|
|
41
|
+
readonly profile: "/community/u/{handle}";
|
|
42
|
+
/** The member's notification settings — also where the digest's unsubscribe link lands (`#u=<token>`). */
|
|
43
|
+
readonly settings: "/community/settings";
|
|
44
|
+
/** The welcome page after joining: the rules' summary and three links. */
|
|
45
|
+
readonly welcome: "/community/welcome";
|
|
46
|
+
/** The notification centre (kb-api's fallback for `notifications_link_path`). */
|
|
47
|
+
readonly notifications: "/community/notifications";
|
|
34
48
|
}>;
|
|
35
49
|
/** A notifier's receipt: kb-api's `kbnt_` capability token (≤ 512 characters, base64url). */
|
|
36
50
|
export declare const COMMUNITY_RECEIPT_RE: RegExp;
|
|
@@ -40,6 +54,29 @@ export declare const COMMUNITY_RECEIPT_RE: RegExp;
|
|
|
40
54
|
* a template that is no site path, lacks `{id}` or holds another brace — no link is built from arbitrary text.
|
|
41
55
|
*/
|
|
42
56
|
export declare function statementPath(template: string | null | undefined, decisionId: string): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* A member's profile page: `{handle}` of the template filled with the handle (lower-cased; a leading `@` is dropped).
|
|
59
|
+
* The template is the host's (its `profilePath` attribute); absent, the managed blog's. Null for a handle that is no
|
|
60
|
+
* handle, or a template that is no site path, lacks `{handle}` or holds another brace — no link from arbitrary text.
|
|
61
|
+
*/
|
|
62
|
+
export declare function profilePath(template: string | null | undefined, handle: string): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* M2 T10: the id `<blogmcp-discussion>` gives a message's row — `bcm-msg-<seq>` (the seq is the message's number in
|
|
65
|
+
* its conversation, the same for every reader) — and the fragment a link to that message carries. The element
|
|
66
|
+
* renders in a shadow root, so it scrolls to the row itself once its first page is in (the browser cannot).
|
|
67
|
+
*/
|
|
68
|
+
export declare const COMMUNITY_MESSAGE_ANCHOR_PREFIX = "bcm-msg-";
|
|
69
|
+
/** A message's anchor id (`bcm-msg-12`), or null for anything that is not a message's seq (a pending row's 0). */
|
|
70
|
+
export declare function communityMessageAnchor(seq: number): string | null;
|
|
71
|
+
/** The seq of a message anchor in a URL fragment (`#bcm-msg-12`), or null — nothing else of the fragment is read. */
|
|
72
|
+
export declare function communityMessageSeqFromHash(hash: string): number | null;
|
|
73
|
+
/**
|
|
74
|
+
* M2 T10: a message on its article's page — the host's article template (`articlePath`, one `{slug}`: the managed
|
|
75
|
+
* blogs `/blog/articles/{slug}`, the storefront `/blog/{slug}`) filled with the article's slug (URL-encoded), and the
|
|
76
|
+
* message's anchor in the fragment. No default: null without a template, for a template that is no site path, holds
|
|
77
|
+
* a fragment, lacks `{slug}` or holds another brace, and for a slug or seq that is none — no link from arbitrary text.
|
|
78
|
+
*/
|
|
79
|
+
export declare function communityMessageLink(articlePath: string | null | undefined, articleSlug: string | null | undefined, seq: number | null | undefined): string | null;
|
|
43
80
|
/** The „Moje komunita" page: the host's path when it is a site path, else the managed blog's. */
|
|
44
81
|
export declare function myCommunityPath(path?: string | null): string;
|
|
45
82
|
/**
|
|
@@ -71,3 +108,26 @@ export declare function receiptFromHash(hash: string): string | null;
|
|
|
71
108
|
* ⚠️ In a vue-router app follow it with `router.replace({ hash: '' })`, so the router forgets the fragment too.
|
|
72
109
|
*/
|
|
73
110
|
export declare function readReceiptFromHash(win?: Window): string | null;
|
|
111
|
+
/** The digest's unsubscribe token: kb-api's `kbun_` capability (DIGEST_TOKEN_RE: 64 base64url characters). */
|
|
112
|
+
export declare const COMMUNITY_DIGEST_TOKEN_RE: RegExp;
|
|
113
|
+
/**
|
|
114
|
+
* The unsubscribe token in a URL fragment (`#u=<token>`, the digest e-mail's link to the settings page), or null.
|
|
115
|
+
* Only kb-api's exact token shape is accepted, as receiptFromHash does for a receipt.
|
|
116
|
+
*/
|
|
117
|
+
export declare function digestTokenFromHash(hash: string): string | null;
|
|
118
|
+
/**
|
|
119
|
+
* The digest's unsubscribe token from the address bar, which is then cleared of it (the URL and the router's copy in
|
|
120
|
+
* `history.state`), as readReceiptFromHash does for a receipt — the token switches the member's digest off, so it
|
|
121
|
+
* stays out of the history, a bookmark and a shared link. Remembered per window (a second mount still gets it)
|
|
122
|
+
* until forgetDigestToken — call it once the token was used, so a later mount does not offer the unsubscribe again.
|
|
123
|
+
*
|
|
124
|
+
* Reading it never sends it: the page POSTs `me.settings.unsubscribeDigest({ token })` only on the member's click
|
|
125
|
+
* (a mail scanner that opens the link must not unsubscribe anyone). ⚠️ In a vue-router app follow it with
|
|
126
|
+
* `router.replace({ hash: '' })`.
|
|
127
|
+
*/
|
|
128
|
+
export declare function readDigestTokenFromHash(win?: Window): string | null;
|
|
129
|
+
/**
|
|
130
|
+
* Forgets the window's remembered unsubscribe token (after `me.settings.unsubscribeDigest` answered, either way: the
|
|
131
|
+
* token is single-purpose). The next readDigestTokenFromHash reads the address bar afresh — which it cleared.
|
|
132
|
+
*/
|
|
133
|
+
export declare function forgetDigestToken(win?: Window): void;
|
package/dist/community/links.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { COMMUNITY_HANDLE_RE as E } from "./routes.js";
|
|
1
2
|
const f = Object.freeze({
|
|
2
3
|
/** The „Moje komunita" panel. */
|
|
3
4
|
myCommunity: "/community",
|
|
@@ -12,74 +13,127 @@ const f = Object.freeze({
|
|
|
12
13
|
/** The discussion terms (DSA art. 14), rendered on the server without JavaScript, as the rules. */
|
|
13
14
|
terms: "/community/terms",
|
|
14
15
|
/** The discussion privacy notice, rendered the same way. */
|
|
15
|
-
privacy: "/community/privacy"
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
privacy: "/community/privacy",
|
|
17
|
+
// M2 T8 (m2-contracts.md §3.10, §3.3): the module's pages. The storefront names its own (`/komunita/…`).
|
|
18
|
+
/** The discussions overview (the articles with a discussion). */
|
|
19
|
+
discussions: "/community/discussions",
|
|
20
|
+
/** A member's public profile; `{handle}` is the member's handle (profilePath). */
|
|
21
|
+
profile: "/community/u/{handle}",
|
|
22
|
+
/** The member's notification settings — also where the digest's unsubscribe link lands (`#u=<token>`). */
|
|
23
|
+
settings: "/community/settings",
|
|
24
|
+
/** The welcome page after joining: the rules' summary and three links. */
|
|
25
|
+
welcome: "/community/welcome",
|
|
26
|
+
/** The notification centre (kb-api's fallback for `notifications_link_path`). */
|
|
27
|
+
notifications: "/community/notifications"
|
|
28
|
+
}), _ = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, y = /^kbnt_[A-Za-z0-9_-]{1,507}$/, d = "t";
|
|
29
|
+
function i(t) {
|
|
18
30
|
return typeof t == "string" && /^\/(?![/\\])/.test(t) && !/[\s\\\u0000-\u001f\u007f]/.test(t);
|
|
19
31
|
}
|
|
20
|
-
function
|
|
32
|
+
function N(t, n) {
|
|
21
33
|
const e = t == null || t === "" ? f.statement : t;
|
|
22
|
-
return !
|
|
34
|
+
return !i(e) || !e.includes("{id}") || /[{}]/.test(e.split("{id}").join("")) || typeof n != "string" || !_.test(n) ? null : e.split("{id}").join(n.toLowerCase());
|
|
23
35
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
36
|
+
function j(t, n) {
|
|
37
|
+
const e = t == null || t === "" ? f.profile : t;
|
|
38
|
+
if (!i(e) || !e.includes("{handle}") || /[{}]/.test(e.split("{handle}").join(""))) return null;
|
|
39
|
+
const o = typeof n == "string" ? n.replace(/^@/, "").toLowerCase() : "";
|
|
40
|
+
return E.test(o) ? e.split("{handle}").join(o) : null;
|
|
26
41
|
}
|
|
27
|
-
|
|
42
|
+
const h = "bcm-msg-", p = (t) => typeof t == "number" && Number.isSafeInteger(t) && t > 0;
|
|
43
|
+
function O(t) {
|
|
44
|
+
return p(t) ? `${h}${t}` : null;
|
|
45
|
+
}
|
|
46
|
+
function I(t) {
|
|
47
|
+
const n = new RegExp(`^#${h}([1-9][0-9]{0,14})$`).exec(typeof t == "string" ? t : ""), e = n ? Number(n[1]) : NaN;
|
|
48
|
+
return p(e) ? e : null;
|
|
49
|
+
}
|
|
50
|
+
function x(t, n, e) {
|
|
51
|
+
const o = t;
|
|
52
|
+
if (!i(o) || o.includes("#") || !o.includes("{slug}") || /[{}]/.test(o.split("{slug}").join("")) || typeof n != "string" || n === "" || n.length > 512 || n === "." || n === ".." || /[\u0000-\u001f\u007f]/.test(n)) return null;
|
|
53
|
+
const s = O(e);
|
|
54
|
+
return s === null ? null : `${o.split("{slug}").join(encodeURIComponent(n))}#${s}`;
|
|
55
|
+
}
|
|
56
|
+
function F(t) {
|
|
57
|
+
return i(t) ? t : f.myCommunity;
|
|
58
|
+
}
|
|
59
|
+
function U(t, n) {
|
|
28
60
|
const e = t == null || t === "" ? f.notices : t;
|
|
29
|
-
return !
|
|
61
|
+
return !i(e) || e.includes("#") || typeof n != "string" || !y.test(n) ? null : `${e}#${d}=${n}`;
|
|
30
62
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
63
|
+
function A(t, n) {
|
|
64
|
+
return i(t) ? t.includes("#") || !i(n) || n.includes("#") ? t : `${t}#${n}` : null;
|
|
33
65
|
}
|
|
34
|
-
function
|
|
66
|
+
function b(t) {
|
|
35
67
|
const e = /^#t=([^&]*)/.exec(typeof t == "string" ? t : "")?.[1] ?? "";
|
|
36
|
-
return
|
|
68
|
+
return y.test(e) ? e : null;
|
|
37
69
|
}
|
|
38
|
-
const
|
|
39
|
-
function
|
|
70
|
+
const l = /* @__PURE__ */ new WeakMap();
|
|
71
|
+
function m() {
|
|
40
72
|
if (typeof window > "u")
|
|
41
73
|
throw new Error(
|
|
42
|
-
"[blogmcp-sdk] readReceiptFromHash
|
|
74
|
+
"[blogmcp-sdk] readReceiptFromHash and readDigestTokenFromHash read the address bar — call them in the browser (onMounted / useEffect), never while rendering on the server"
|
|
43
75
|
);
|
|
44
76
|
return window;
|
|
45
77
|
}
|
|
46
|
-
function
|
|
78
|
+
function M(t) {
|
|
47
79
|
if (typeof t != "object" || t === null || Array.isArray(t)) return !1;
|
|
48
80
|
const n = Object.getPrototypeOf(t);
|
|
49
81
|
return n === Object.prototype || n === null;
|
|
50
82
|
}
|
|
51
|
-
function
|
|
83
|
+
function T(t, n, e) {
|
|
52
84
|
let o = t;
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
85
|
+
const s = n ? o.indexOf(n) : -1;
|
|
86
|
+
if (s >= 0 && (o = o.slice(0, s)), e !== null)
|
|
55
87
|
for (let r = o.indexOf(e); r >= 0; r = o.indexOf(e)) {
|
|
56
|
-
const
|
|
57
|
-
o =
|
|
88
|
+
const u = o.lastIndexOf("#", r);
|
|
89
|
+
o = u >= 0 ? o.slice(0, u) : o.slice(0, r) + o.slice(r + e.length);
|
|
58
90
|
}
|
|
59
91
|
return o;
|
|
60
92
|
}
|
|
61
|
-
function
|
|
62
|
-
if (!
|
|
93
|
+
function g(t, n, e) {
|
|
94
|
+
if (!M(t)) return t;
|
|
63
95
|
let o = !1;
|
|
64
|
-
const
|
|
65
|
-
for (const [r,
|
|
66
|
-
if (typeof
|
|
67
|
-
const
|
|
68
|
-
|
|
96
|
+
const s = { ...t };
|
|
97
|
+
for (const [r, u] of Object.entries(s)) {
|
|
98
|
+
if (typeof u != "string") continue;
|
|
99
|
+
const a = T(u, n, e);
|
|
100
|
+
a !== u && (s[r] = a, o = !0);
|
|
69
101
|
}
|
|
70
|
-
return o ?
|
|
102
|
+
return o ? s : t;
|
|
103
|
+
}
|
|
104
|
+
function D(t = m()) {
|
|
105
|
+
const n = t.location.hash, e = b(n), o = !l.has(t);
|
|
106
|
+
return n.startsWith(`#${d}=`) && t.history.replaceState(g(t.history.state, n, e), "", t.location.pathname + t.location.search), (o || e !== null) && l.set(t, e), l.get(t) ?? null;
|
|
107
|
+
}
|
|
108
|
+
const $ = /^kbun_[A-Za-z0-9_-]{64}$/, k = "u";
|
|
109
|
+
function C(t) {
|
|
110
|
+
const e = /^#u=([^&]*)/.exec(typeof t == "string" ? t : "")?.[1] ?? "";
|
|
111
|
+
return $.test(e) ? e : null;
|
|
112
|
+
}
|
|
113
|
+
const c = /* @__PURE__ */ new WeakMap();
|
|
114
|
+
function P(t = m()) {
|
|
115
|
+
const n = t.location.hash, e = C(n), o = !c.has(t);
|
|
116
|
+
return n.startsWith(`#${k}=`) && t.history.replaceState(g(t.history.state, n, e), "", t.location.pathname + t.location.search), (o || e !== null) && c.set(t, e), c.get(t) ?? null;
|
|
71
117
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
return n.startsWith(`#${m}=`) && t.history.replaceState(O(t.history.state, n, e), "", t.location.pathname + t.location.search), (o || e !== null) && u.set(t, e), u.get(t) ?? null;
|
|
118
|
+
function S(t = m()) {
|
|
119
|
+
c.delete(t);
|
|
75
120
|
}
|
|
76
121
|
export {
|
|
77
|
-
|
|
122
|
+
$ as COMMUNITY_DIGEST_TOKEN_RE,
|
|
123
|
+
h as COMMUNITY_MESSAGE_ANCHOR_PREFIX,
|
|
124
|
+
y as COMMUNITY_RECEIPT_RE,
|
|
78
125
|
f as COMMUNITY_ROUTES,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
126
|
+
O as communityMessageAnchor,
|
|
127
|
+
x as communityMessageLink,
|
|
128
|
+
I as communityMessageSeqFromHash,
|
|
129
|
+
C as digestTokenFromHash,
|
|
130
|
+
S as forgetDigestToken,
|
|
131
|
+
F as myCommunityPath,
|
|
132
|
+
U as noticeStatusLink,
|
|
133
|
+
j as profilePath,
|
|
134
|
+
P as readDigestTokenFromHash,
|
|
135
|
+
D as readReceiptFromHash,
|
|
136
|
+
b as receiptFromHash,
|
|
137
|
+
A as signInLink,
|
|
138
|
+
N as statementPath
|
|
85
139
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@blogmcp/sdk/community/manifest` — the web app manifest that lets a member install the site (community M2,
|
|
3
|
+
* slice T4; docs/internal/m2-contracts.md §3.4; community.md §7.5: iOS shows web push only to a website added to
|
|
4
|
+
* the home screen).
|
|
5
|
+
*
|
|
6
|
+
* A host serves `JSON.stringify(communityManifest(…))` from `<base>/manifest.webmanifest` as
|
|
7
|
+
* COMMUNITY_MANIFEST_CONTENT_TYPE and links it from its pages (`<link rel="manifest">`). `display: standalone`, the
|
|
8
|
+
* start URL is the notification centre, the scope is the site's base (the managed blogs' `/blog/`, the
|
|
9
|
+
* storefront's `/`), so an installed app opens where a notification would.
|
|
10
|
+
*
|
|
11
|
+
* Pure: no DOM, no globals, no import.
|
|
12
|
+
*/
|
|
13
|
+
/** The Content-Type a host serves the manifest with. */
|
|
14
|
+
export declare const COMMUNITY_MANIFEST_CONTENT_TYPE = "application/manifest+json; charset=utf-8";
|
|
15
|
+
export interface CommunityManifestIcon {
|
|
16
|
+
/** A path on this site. */
|
|
17
|
+
readonly src: string;
|
|
18
|
+
/** `192x192`, `512x512`, … */
|
|
19
|
+
readonly sizes: string;
|
|
20
|
+
readonly type?: string;
|
|
21
|
+
readonly purpose?: 'any' | 'maskable' | 'monochrome' | 'any maskable';
|
|
22
|
+
}
|
|
23
|
+
export interface CommunityManifestOptions {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly shortName?: string;
|
|
26
|
+
/** The notification centre: where the installed app opens (a path inside `scope`). */
|
|
27
|
+
readonly startUrl: string;
|
|
28
|
+
/** The site's base (default `/`): what the installed app covers. */
|
|
29
|
+
readonly scope?: string;
|
|
30
|
+
readonly icons: readonly CommunityManifestIcon[];
|
|
31
|
+
readonly themeColor?: string;
|
|
32
|
+
readonly backgroundColor?: string;
|
|
33
|
+
/** The manifest's language (`cs`, `en`). */
|
|
34
|
+
readonly lang?: string;
|
|
35
|
+
}
|
|
36
|
+
/** The manifest (W3C Web App Manifest) a host serves. */
|
|
37
|
+
export interface CommunityWebManifest {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly short_name: string;
|
|
40
|
+
readonly start_url: string;
|
|
41
|
+
readonly scope: string;
|
|
42
|
+
readonly display: 'standalone';
|
|
43
|
+
readonly icons: ReadonlyArray<{
|
|
44
|
+
src: string;
|
|
45
|
+
sizes: string;
|
|
46
|
+
type?: string;
|
|
47
|
+
purpose?: string;
|
|
48
|
+
}>;
|
|
49
|
+
readonly theme_color?: string;
|
|
50
|
+
readonly background_color?: string;
|
|
51
|
+
readonly lang?: string;
|
|
52
|
+
}
|
|
53
|
+
/** The manifest (see the module comment). Throws a TypeError for a path outside the site or a start URL outside the scope. */
|
|
54
|
+
export declare function communityManifest(options: CommunityManifestOptions): CommunityWebManifest;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const M = "application/manifest+json; charset=utf-8";
|
|
2
|
+
const p = /^(#[0-9a-fA-F]{3,8}|[a-zA-Z]{3,30}|(rgb|hsl)a?\([0-9.,%\s/]{1,60}\))$/, g = /^(any|\d{1,4}x\d{1,4}( \d{1,4}x\d{1,4})*)$/;
|
|
3
|
+
function c(t, s) {
|
|
4
|
+
if (typeof t != "string" || !/^\/(?!\/)[^\s\\]*$/.test(t) || t.length > 512)
|
|
5
|
+
throw new TypeError(`communityManifest: ${s} must be a path on this site (starting with a single /)`);
|
|
6
|
+
return t;
|
|
7
|
+
}
|
|
8
|
+
function h(t, s, n) {
|
|
9
|
+
if (typeof t != "string" || t.trim() === "") throw new TypeError(`communityManifest: ${n} is required`);
|
|
10
|
+
return t.replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, s);
|
|
11
|
+
}
|
|
12
|
+
function d(t) {
|
|
13
|
+
const s = h(t?.name, 80, "name"), n = t.shortName === void 0 ? s.slice(0, 30) : h(t.shortName, 30, "shortName"), o = c(t.scope ?? "/", "scope"), i = o.endsWith("/") ? o : `${o}/`, a = c(t.startUrl, "startUrl");
|
|
14
|
+
if (!a.startsWith(i) && `${a}/` !== i) throw new TypeError("communityManifest: startUrl must lie inside scope");
|
|
15
|
+
if (!Array.isArray(t.icons) || t.icons.length === 0) throw new TypeError("communityManifest: at least one icon is required");
|
|
16
|
+
const u = t.icons.map((r, e) => {
|
|
17
|
+
const l = c(r?.src, `icons[${e}].src`);
|
|
18
|
+
if (typeof r.sizes != "string" || !g.test(r.sizes)) throw new TypeError(`communityManifest: icons[${e}].sizes is not a sizes list`);
|
|
19
|
+
return {
|
|
20
|
+
src: l,
|
|
21
|
+
sizes: r.sizes,
|
|
22
|
+
...typeof r.type == "string" && /^image\/[a-z0-9.+-]{1,40}$/.test(r.type) ? { type: r.type } : {},
|
|
23
|
+
...r.purpose ? { purpose: r.purpose } : {}
|
|
24
|
+
};
|
|
25
|
+
}), m = (r, e) => {
|
|
26
|
+
if (r !== void 0) {
|
|
27
|
+
if (typeof r != "string" || !p.test(r)) throw new TypeError(`communityManifest: ${e} is not a colour`);
|
|
28
|
+
return r;
|
|
29
|
+
}
|
|
30
|
+
}, f = m(t.themeColor, "themeColor"), y = m(t.backgroundColor, "backgroundColor");
|
|
31
|
+
return {
|
|
32
|
+
name: s,
|
|
33
|
+
short_name: n,
|
|
34
|
+
start_url: a,
|
|
35
|
+
scope: i,
|
|
36
|
+
display: "standalone",
|
|
37
|
+
icons: u,
|
|
38
|
+
...f ? { theme_color: f } : {},
|
|
39
|
+
...y ? { background_color: y } : {},
|
|
40
|
+
...typeof t.lang == "string" && /^[a-z]{2}(-[A-Za-z0-9]{2,8})?$/.test(t.lang) ? { lang: t.lang } : {}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
M as COMMUNITY_MANIFEST_CONTENT_TYPE,
|
|
45
|
+
d as communityManifest
|
|
46
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@handle` mentions in a message body (community M2, slice T8; docs/internal/m2-contracts.md §3.3 "Mentions"): the
|
|
3
|
+
* same token rule kb-api's `services/community/mentions.ts` applies when it notifies the mentioned member, so a page
|
|
4
|
+
* links exactly the handles kb-api counted (test/community/mentions.spec.ts pins the pattern to kb-api's source).
|
|
5
|
+
*
|
|
6
|
+
* A mention is TEXT with a link to the member's profile page (profilePath): the body is split into spans, never
|
|
7
|
+
* parsed as HTML — a page renders each span as a text node (a mention inside an `<a>` whose href profilePath built).
|
|
8
|
+
* Whether a handle names anyone is kb-api's to know; the page links every well-formed one (the profile page answers
|
|
9
|
+
* `notFound` for a handle nobody holds, the same answer as for one hidden from the viewer).
|
|
10
|
+
*
|
|
11
|
+
* Pure: no I/O, no globals.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* One `@handle` token: `@` at the start or after a character that is not a letter, a digit, `_`, `@`, `.` or `/`
|
|
15
|
+
* (so `jana@example.com` and a URL's `/@x` are no mentions), then a handle in any case, not followed by a handle
|
|
16
|
+
* character. Group 1 is the character before the `@`, group 2 the handle as typed. kb-api's MENTION_TOKEN_RE.
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ The regex is global (`/g`, as kb-api's), so `.test()` and `.exec()` on it carry `lastIndex` from one call to the
|
|
19
|
+
* next. Use `communityMentionSpans`, `communityMentionHandles` or `text.matchAll(COMMUNITY_MENTION_RE)` — never
|
|
20
|
+
* `.test`/`.exec` on the shared object.
|
|
21
|
+
*/
|
|
22
|
+
export declare const COMMUNITY_MENTION_RE: RegExp;
|
|
23
|
+
/** A piece of a message body: plain text, or a mention (`text` as typed, `@` included; `handle` lower-cased). */
|
|
24
|
+
export type CommunityTextSpan = {
|
|
25
|
+
readonly kind: 'text';
|
|
26
|
+
readonly text: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: 'mention';
|
|
29
|
+
readonly text: string;
|
|
30
|
+
readonly handle: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The body as spans, in order: the text between mentions and each mention. Joining every span's `text` gives the
|
|
34
|
+
* body back unchanged. A body without a mention is one text span; an empty or absent body, none.
|
|
35
|
+
*/
|
|
36
|
+
export declare function communityMentionSpans(text: string | null | undefined): CommunityTextSpan[];
|
|
37
|
+
/** The distinct handles a body mentions, lower-cased, in the order they first appear (kb-api's mentionHandles). */
|
|
38
|
+
export declare function communityMentionHandles(text: string | null | undefined): string[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { COMMUNITY_HANDLE_RE as u } from "./routes.js";
|
|
2
|
+
const r = /(^|[^A-Za-z0-9_@./])@([A-Za-z0-9][A-Za-z0-9_]{2,29})(?![A-Za-z0-9_])/g;
|
|
3
|
+
function a(n) {
|
|
4
|
+
if (typeof n != "string" || n === "") return [];
|
|
5
|
+
if (!n.includes("@")) return [{ kind: "text", text: n }];
|
|
6
|
+
const e = [];
|
|
7
|
+
let t = 0;
|
|
8
|
+
for (const o of n.matchAll(new RegExp(r.source, "g"))) {
|
|
9
|
+
const i = o[2], c = i.toLowerCase();
|
|
10
|
+
if (!u.test(c)) continue;
|
|
11
|
+
const s = (o.index ?? 0) + o[1].length;
|
|
12
|
+
s > t && e.push({ kind: "text", text: n.slice(t, s) }), e.push({ kind: "mention", text: `@${i}`, handle: c }), t = s + 1 + i.length;
|
|
13
|
+
}
|
|
14
|
+
return t < n.length && e.push({ kind: "text", text: n.slice(t) }), e;
|
|
15
|
+
}
|
|
16
|
+
function l(n) {
|
|
17
|
+
const e = [];
|
|
18
|
+
for (const t of a(n)) t.kind === "mention" && !e.includes(t.handle) && e.push(t.handle);
|
|
19
|
+
return e;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
r as COMMUNITY_MENTION_RE,
|
|
23
|
+
l as communityMentionHandles,
|
|
24
|
+
a as communityMentionSpans
|
|
25
|
+
};
|