@commentkit/comment-kit 2.0.0 → 2.1.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +123 -19
  3. package/SECURITY.md +2 -2
  4. package/dist/node/cli/api.js +61 -15
  5. package/dist/node/cli/credentials.js +8 -0
  6. package/dist/node/cli/doctor.js +152 -25
  7. package/dist/node/cli/init.js +349 -35
  8. package/dist/node/cli/main.js +310 -69
  9. package/dist/node/cli/mcp.js +187 -6
  10. package/dist/node/cli/website.js +140 -0
  11. package/dist/node/shared/dashboard-places.js +33 -0
  12. package/dist/node/types/next.d.ts +4 -4
  13. package/dist/npm/THIRD_PARTY_NOTICES.txt +47 -0
  14. package/dist/npm/chunks/{AgentSend-DxRJIYiz.js → AgentSend-pA7Ufvye.js} +16 -16
  15. package/dist/npm/chunks/Checklist-Cn9skOYK.js +269 -0
  16. package/dist/npm/chunks/Composer-D7H-pzGa.js +734 -0
  17. package/dist/npm/chunks/DatePicker-Nta5a1xD.js +161 -0
  18. package/dist/npm/chunks/{Guest-vvNPz8h-.js → Guest-Bi7hlzhs.js} +63 -59
  19. package/dist/npm/chunks/{MarkupEditor-VCOXh9d2.js → MarkupEditor-WU3USeTk.js} +46 -39
  20. package/dist/npm/chunks/Panel-DhAzbUbC.js +1210 -0
  21. package/dist/npm/chunks/{Settings-BGoZS2iV.js → Settings-BmKqPX40.js} +91 -90
  22. package/dist/npm/chunks/{Shortcuts-B2OMvczr.js → Shortcuts-Bl-c0Sez.js} +25 -23
  23. package/dist/npm/chunks/SignInFirst-CmGvSYkQ.js +35 -0
  24. package/dist/npm/chunks/{StyleEditor-CJ_d8Huf.js → StyleEditor-D6fUnlwq.js} +10 -10
  25. package/dist/npm/chunks/{StylePanel-yQzHHlY7.js → StylePanel-C-Gikxt1.js} +61 -61
  26. package/dist/npm/chunks/TaskFields-CaKi523b.js +617 -0
  27. package/dist/npm/chunks/ThreadCard-d_3pUB5V.js +1142 -0
  28. package/dist/npm/chunks/Viewer-BULQsi9-.js +115 -0
  29. package/dist/npm/chunks/{agent-C1OQzBAm.js → agent-DHdhIJ3s.js} +1 -1
  30. package/dist/npm/chunks/{ar-CAJ3XT8e.js → ar-B5UszrQp.js} +53 -12
  31. package/dist/npm/chunks/card-bits-cV8GdFWX.js +55 -0
  32. package/dist/npm/chunks/{client-kNAo2TTG.js → client-Cv8ddtuM.js} +13 -11
  33. package/dist/npm/chunks/{confetti-CkBdSu19.js → confetti-B9zlyILU.js} +1 -1
  34. package/dist/npm/chunks/{context-B8UAzve0.js → context-CsHnabaA.js} +1 -1
  35. package/dist/npm/chunks/{de-Dl18G48t.js → de-BE0Aaq8u.js} +53 -12
  36. package/dist/npm/chunks/{dialog-GO04oC3D.js → dialog-DvdIkCW0.js} +1 -1
  37. package/dist/npm/chunks/{dpop-U48QIQd7.js → dpop-CwW9ifkq.js} +1 -1
  38. package/dist/npm/chunks/entrance-Bn_5M9uO.js +90 -0
  39. package/dist/npm/chunks/{es-Dxk79lS9.js → es-BQviao4d.js} +53 -12
  40. package/dist/npm/chunks/{extension-E81hWyiT.js → extension-CnQTDC1j.js} +2 -2
  41. package/dist/npm/chunks/{extension-CKFpPWmi.js → extension-DXhz81XD.js} +1 -1
  42. package/dist/npm/chunks/{files-DyD5BZgp.js → files-DLEr_wmh.js} +2 -2
  43. package/dist/npm/chunks/{fr-8BebGKYD.js → fr-C5gu6A06.js} +53 -12
  44. package/dist/npm/chunks/{hi-BIN6Yy_p.js → hi-DXfQ5EvY.js} +53 -12
  45. package/dist/npm/chunks/{i18n-DOBt8e9U.js → i18n-Mgs9VOuk.js} +63 -58
  46. package/dist/npm/chunks/icons-_C6ZWmBY.js +141 -0
  47. package/dist/npm/chunks/{identify-CN-3xzqL.js → identify-BnQGJOa0.js} +4 -4
  48. package/dist/npm/chunks/{it-Cr6EwpPQ.js → it-BPHt13FV.js} +53 -12
  49. package/dist/npm/chunks/{ja-Iy3s5aur.js → ja-BkCqyKR0.js} +52 -11
  50. package/dist/npm/chunks/late-words-D4Oo_yhJ.js +57 -0
  51. package/dist/npm/chunks/{live-CelVeZfP.js → live-DXcxj_Af.js} +28 -22
  52. package/dist/npm/chunks/{nl-B84WHqqe.js → nl-DZxdLLMU.js} +53 -12
  53. package/dist/npm/chunks/{page-key-DepmJzC1.js → page-key-UqAozdZi.js} +1 -1
  54. package/dist/npm/chunks/{pick-yTyqtxN0.js → pick-C20RVUas.js} +1 -1
  55. package/dist/npm/chunks/{pkce-ChKGSW_4.js → pkce-BPvWoBrr.js} +1 -1
  56. package/dist/npm/chunks/{pt-BR-DOkdlfoe.js → pt-BR-lA9mJ05F.js} +53 -12
  57. package/dist/npm/chunks/{report-CrIqQZDI.js → report-BjUgUNnT.js} +1 -1
  58. package/dist/npm/chunks/show-BinoJyED.js +97 -0
  59. package/dist/npm/chunks/signin-C2jjsxz9.js +101 -0
  60. package/dist/npm/chunks/{source-pXVve2Cx.js → source-NuflODx3.js} +1 -1
  61. package/dist/npm/chunks/src-9o2Ocq8d.js +221 -0
  62. package/dist/npm/chunks/start-Cbx6rMrr.js +1904 -0
  63. package/dist/npm/chunks/states-DLMCvwes.js +3 -0
  64. package/dist/npm/chunks/{upload-MgPYqPyE.js → upload-C4NpM-jE.js} +1 -1
  65. package/dist/npm/chunks/uploads-CY4bDbaI.js +1236 -0
  66. package/dist/npm/chunks/{wrap-Bl0gbnFa.js → wrap-D-xTKIzj.js} +20 -20
  67. package/dist/npm/chunks/{zh-CN-Z5fQCb7G.js → zh-CN-yqaDHwBx.js} +53 -12
  68. package/dist/npm/element.js +7 -1
  69. package/dist/npm/headless.js +2 -2
  70. package/dist/npm/index.js +2 -2
  71. package/dist/npm/react.js +1 -1
  72. package/dist/npm/svelte.js +1 -1
  73. package/dist/npm/types/adapters/vue.d.ts +12 -0
  74. package/dist/npm/types/core/auth.d.ts +1 -0
  75. package/dist/npm/types/core/client.d.ts +5 -1
  76. package/dist/npm/types/core/types.d.ts +19 -4
  77. package/dist/npm/vue.js +5 -1
  78. package/package.json +4 -1
  79. package/dist/npm/chunks/Checklist-CnlfeSbc.js +0 -282
  80. package/dist/npm/chunks/Composer-B1bBVszY.js +0 -725
  81. package/dist/npm/chunks/Panel-F37vIL1K.js +0 -1206
  82. package/dist/npm/chunks/TaskFields-fmy6_HtK.js +0 -289
  83. package/dist/npm/chunks/ThreadCard-D51slKST.js +0 -1113
  84. package/dist/npm/chunks/Viewer-BOBadqmC.js +0 -111
  85. package/dist/npm/chunks/card-bits-CAnzrqx3.js +0 -53
  86. package/dist/npm/chunks/late-words-B2bmZceJ.js +0 -12
  87. package/dist/npm/chunks/show-BgVC8gWY.js +0 -97
  88. package/dist/npm/chunks/signin-Dd1rb2BP.js +0 -75
  89. package/dist/npm/chunks/src-BTMy4Gyc.js +0 -208
  90. package/dist/npm/chunks/start-DtVlpt7p.js +0 -1878
  91. package/dist/npm/chunks/states-sfTbjZz8.js +0 -3
  92. package/dist/npm/chunks/uploads-D49mywwz.js +0 -1146
@@ -1,111 +0,0 @@
1
- import { c as e, f as t, g as n, p as r, u as i, y as a } from "./i18n-DOBt8e9U.js";
2
- import { C as o, s } from "./start-DtVlpt7p.js";
3
- // src/ui/Viewer.tsx
4
- s(".ck-viewer{z-index:calc(var(--ck-z) + 3);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);color:#f2f1ec;animation:ck-fade var(--ck-dur) ease-out;background:#0a0a0cd1;grid-template-rows:auto 1fr;place-items:center;padding:12px 56px 24px;display:grid;position:fixed;top:0;bottom:0;left:0;right:0}.ck-viewer-bar{justify-self:stretch;align-items:center;gap:4px;min-height:40px;display:flex}.ck-viewer-name{white-space:nowrap;min-width:0;font-size:var(--ck-fs-md);flex:1;align-items:baseline;gap:8px;font-weight:600;display:flex}.ck-viewer-name>bdi{text-overflow:ellipsis;min-width:0;overflow:hidden}.ck-viewer-count{color:#f2f1eca6;font-variant-numeric:tabular-nums;flex:none;font-weight:500}.ck-viewer-btn,.ck-viewer-nav{border-radius:var(--ck-radius-pill);width:36px;height:36px;color:inherit;transition:background-color var(--ck-fast), scale var(--ck-fast) ease-out;background:#ffffff1a;border:0;flex:none;place-items:center;padding:0;text-decoration:none;display:grid}.ck-viewer-btn:active,.ck-viewer-nav:active{scale:.96}.ck-viewer-img{object-fit:contain;border-radius:var(--ck-radius-md);max-width:100%;max-height:calc(100dvh - 96px);box-shadow:var(--ck-shadow);outline:1px solid var(--ck-img-outline);outline-offset:-1px;animation:ck-pop var(--ck-dur) var(--ck-ease);background:#fff}.ck-viewer-nav{width:40px;height:40px;position:absolute;top:50%;translate:0 -50%}.ck-viewer-nav[data-dir=prev]:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:8px}.ck-viewer-nav[data-dir=prev]:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:8px}.ck-viewer-nav[data-dir=prev]:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){right:8px}.ck-viewer-nav[data-dir=prev]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){right:8px}.ck-viewer-nav[data-dir=next]:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){right:8px}.ck-viewer-nav[data-dir=next]:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){right:8px}.ck-viewer-nav[data-dir=next]:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){left:8px}.ck-viewer-nav[data-dir=next]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){left:8px}.ck-viewer-nav[data-dir=prev] svg{scale:-1 1}.ck-root[dir=rtl] .ck-viewer-nav[data-dir=prev] svg{scale:1}.ck-root[dir=rtl] .ck-viewer-nav[data-dir=next] svg{scale:-1 1}.ck-viewer :focus-visible{outline-color:#fff}@media (hover:hover){.ck-viewer-btn:hover,.ck-viewer-nav:hover{background:#fff3}}@media (max-width:520px){.ck-viewer{padding:8px 8px 16px}.ck-viewer-img{max-height:calc(100dvh - 140px)}.ck-viewer-nav{top:auto;bottom:16px;translate:none}}@media (pointer:coarse){.ck-viewer-btn,.ck-viewer-nav{width:44px;height:44px}}");
5
- var c = (e) => getComputedStyle(e).direction === "rtl";
6
- function l({ images: s, start: l = 0, onClose: u }) {
7
- let [d, f] = n(Math.min(Math.max(0, l), s.length - 1)), p = r(null), m = s[d], h = s.length > 1, g = (e) => f((t) => (t + e + s.length) % s.length);
8
- if (t(() => {
9
- let e = p.current?.getRootNode()?.activeElement ?? document.activeElement;
10
- return p.current?.focus({ preventScroll: !0 }), () => {
11
- e instanceof HTMLElement && e.isConnected && e.focus({ preventScroll: !0 });
12
- };
13
- }, []), !m) return null;
14
- let _ = m.href ?? m.src;
15
- return /* @__PURE__ */ i("div", {
16
- class: "ck-viewer",
17
- role: "dialog",
18
- "aria-modal": "true",
19
- "aria-label": e("imageViewer"),
20
- "data-commentkit-ui": !0,
21
- onClick: (e) => e.target === e.currentTarget && u(),
22
- onKeyDown: (e) => {
23
- if (e.stopPropagation(), e.key === "Escape") u();
24
- else if (h && (e.key === "ArrowRight" || e.key === "ArrowLeft")) g(e.key === "ArrowRight" === c(e.currentTarget) ? -1 : 1);
25
- else if (e.key === "Tab") {
26
- let t = [...e.currentTarget.querySelectorAll("button, a[href]")], n = t.indexOf(e.currentTarget.getRootNode().activeElement);
27
- e.preventDefault(), t[(n + (e.shiftKey ? -1 : 1) + t.length) % t.length]?.focus();
28
- }
29
- },
30
- children: [
31
- /* @__PURE__ */ i("div", {
32
- class: "ck-viewer-bar",
33
- children: [
34
- /* @__PURE__ */ i("span", {
35
- class: "ck-viewer-name",
36
- children: [/* @__PURE__ */ i("bdi", {
37
- title: m.name,
38
- children: m.name
39
- }), h ? /* @__PURE__ */ i("span", {
40
- class: "ck-viewer-count",
41
- children: e("countOf", {
42
- n: d + 1,
43
- total: s.length
44
- })
45
- }) : null]
46
- }),
47
- /* @__PURE__ */ i("a", {
48
- class: "ck-viewer-btn",
49
- href: _,
50
- target: "_blank",
51
- rel: "noopener noreferrer",
52
- download: m.name,
53
- "aria-label": e("download"),
54
- title: e("download"),
55
- children: /* @__PURE__ */ i(o, {
56
- name: "down",
57
- size: 16
58
- })
59
- }),
60
- /* @__PURE__ */ i("a", {
61
- class: "ck-viewer-btn",
62
- href: _,
63
- target: "_blank",
64
- rel: "noopener noreferrer",
65
- "aria-label": e("openInTab"),
66
- title: e("openInTab"),
67
- children: /* @__PURE__ */ i(o, {
68
- name: "link",
69
- size: 16
70
- })
71
- }),
72
- /* @__PURE__ */ i("button", {
73
- class: "ck-viewer-btn",
74
- ref: p,
75
- "aria-label": e("close"),
76
- onClick: u,
77
- children: /* @__PURE__ */ i(o, {
78
- name: "close",
79
- size: 16
80
- })
81
- })
82
- ]
83
- }),
84
- /* @__PURE__ */ i("img", {
85
- class: "ck-viewer-img",
86
- src: m.src,
87
- alt: m.name
88
- }),
89
- h ? /* @__PURE__ */ i(a, { children: [/* @__PURE__ */ i("button", {
90
- class: "ck-viewer-nav",
91
- "data-dir": "prev",
92
- "aria-label": e("previousImage"),
93
- onClick: () => g(-1),
94
- children: /* @__PURE__ */ i(o, {
95
- name: "chevron",
96
- size: 18
97
- })
98
- }), /* @__PURE__ */ i("button", {
99
- class: "ck-viewer-nav",
100
- "data-dir": "next",
101
- "aria-label": e("nextImage"),
102
- onClick: () => g(1),
103
- children: /* @__PURE__ */ i(o, {
104
- name: "chevron",
105
- size: 18
106
- })
107
- })] }) : null
108
- ]
109
- });
110
- }
111
- export { l as Viewer };
@@ -1,53 +0,0 @@
1
- import { v as e } from "./client-kNAo2TTG.js";
2
- import { c as t, l as n, u as r, y as i } from "./i18n-DOBt8e9U.js";
3
- import { t as a } from "./files-DyD5BZgp.js";
4
- import { C as o, d as s, f as c } from "./start-DtVlpt7p.js";
5
- // src/ui/card-bits.tsx
6
- s.http_413 = "tooBig";
7
- function l(n, r, i, a) {
8
- return n.updateThread(r.id, { status: r.status }).catch((n) => (n instanceof e && n.status === 403 ? i({
9
- text: t("undoTooLate", { ref: r.reference }),
10
- tone: "error"
11
- }) : a(n), null));
12
- }
13
- function u(t) {
14
- return t instanceof e && (t.code === "widget_disabled" || t.code === "plan_required" || t.code === "guest_codes_paused" || t.status >= 400 && t.status < 500 && t.status !== 408 && t.status !== 429) ? c(t) : null;
15
- }
16
- function d({ input: e, onFiles: n, types: s }) {
17
- let c = a(s);
18
- return c ? /* @__PURE__ */ r(i, { children: [/* @__PURE__ */ r("input", {
19
- ref: e,
20
- type: "file",
21
- multiple: !0,
22
- hidden: !0,
23
- accept: c,
24
- onChange: (e) => {
25
- let t = e.target;
26
- n(Array.from(t.files ?? [])), t.value = "";
27
- }
28
- }), /* @__PURE__ */ r("button", {
29
- class: "ck-ghost",
30
- onClick: () => e.current?.click(),
31
- "aria-label": t("attach"),
32
- title: t("attach"),
33
- children: /* @__PURE__ */ r(o, { name: "paperclip" })
34
- })] }) : null;
35
- }
36
- function f(e, t = {
37
- top: e.y,
38
- bottom: e.y
39
- }) {
40
- let r = Math.min(380, innerWidth - 24), i = e.x + 16, a = e.x - 16 - r, o = i + r <= innerWidth - 12, s = n() === "rtl" ? a >= 12 || !o : !o && a >= 12, c = Math.min(Math.max(12, s ? a : i), innerWidth - r - 12), l = innerHeight - (t.bottom + 16) - 12, u = t.top - 16 - 12, d = (e) => `min(560px, ${Math.max(240, Math.round(e))}px)`, f = s ? "right" : "left";
41
- return l >= 360 || l >= u ? {
42
- left: `${c}px`,
43
- top: `${Math.min(t.bottom + 16, innerHeight - 252)}px`,
44
- maxHeight: d(l),
45
- transformOrigin: `${f} top`
46
- } : {
47
- left: `${c}px`,
48
- bottom: `${Math.max(12, innerHeight - t.top + 16)}px`,
49
- maxHeight: d(u),
50
- transformOrigin: `${f} bottom`
51
- };
52
- }
53
- export { l as i, u as n, f as r, d as t };
@@ -1,12 +0,0 @@
1
- import { n as e } from "./rolldown-runtime-QGRDbDUS.js";
2
- // src/ui/late-words.ts
3
- var t = /* @__PURE__ */ e({ LATE: () => n }), n = {
4
- notLive: "Choose a plan to use comments on your live website.",
5
- fileImagesOnly: "This website accepts images only.",
6
- tooBig: "That’s too big to send. Try a shorter comment or a smaller file.",
7
- finishTitle: "Send your comment?",
8
- finishBody: "You opened the link from your code email. Press the button to publish the comment you wrote on this website.",
9
- finishSend: "Send my comment",
10
- finishExpired: "This link no longer works. Links in the code email work once, for 10 minutes. If your comment is still waiting, enter the code on the page where you wrote it."
11
- };
12
- export { t as n, n as t };
@@ -1,97 +0,0 @@
1
- import { a as e, i as t, n, r } from "./src-BTMy4Gyc.js";
2
- import { i, l as a, v as o } from "./client-kNAo2TTG.js";
3
- import { n as s } from "./page-key-DepmJzC1.js";
4
- // src/core/show.ts
5
- var c;
6
- function l() {
7
- if (/[?&]ck(_thread)?(=|&|$)/.test(location.search)) return !0;
8
- try {
9
- return !!sessionStorage.getItem("commentkit:share");
10
- } catch {
11
- return !1;
12
- }
13
- }
14
- a(s);
15
- var u = (e) => e.disabled_reason === "version_blocked", d = (e) => e.disabled_reason === "not_live", f = (e) => {
16
- let t = e.state.get().session;
17
- return !!t && t.role !== "guest";
18
- };
19
- async function p(n, i, a, o, p, _, v = () => void 0) {
20
- let y = (c ?? (c = l())) || a;
21
- if (u(i)) return v(), null;
22
- let b = d(i);
23
- if (b && !n.auth.hasSession() && !t()) return v(), null;
24
- if (!i.enabled && !y && !b) return null;
25
- s.ignore(i.pages?.ignored_query_params);
26
- let x = import("./start-DtVlpt7p.js").then((e) => e.t), S = x.then((e) => e.setLocale(n.options.locale));
27
- if (x.catch(() => void 0), S.catch(() => void 0), await n.auth.completeRedirect().catch(() => !1), t() && await import("./extension-E81hWyiT.js").then((e) => e.extensionHandoff(n.auth)).catch(() => !1), _ && i.enabled && await import("./identify-CN-3xzqL.js").then((e) => e.identify(n, _, null, !0)).catch(() => !1), await n.loadSession().catch(() => null), n.state.get().session || m(n.options.project), b && !f(n)) return v(), null;
28
- let C = await x, { installDiagnostics: w, mountWidget: T } = C;
29
- if (b && Object.assign(C.en, (await import("./late-words-B2bmZceJ.js").then((e) => e.n)).LATE), await S, o()) return null;
30
- let E = w({
31
- console: i.features.console_capture,
32
- network: i.features.network_capture,
33
- endpoint: n.endpoint
34
- }), D = () => {
35
- p(), e(!1);
36
- }, O;
37
- try {
38
- O = T(n, () => (h([r() + 1, Date.now()]), D()), D);
39
- } catch (e) {
40
- throw E(), e;
41
- }
42
- let k = setTimeout(h, 3e4, null), A = g(n, y, p, v), j = n.state.get().config, M = n.state.subscribe((e) => {
43
- e.config && e.config !== j && s.ignore((j = e.config).pages?.ignored_query_params);
44
- });
45
- return n.emit("ready", { session: n.state.get().session }), Object.assign(() => {
46
- clearTimeout(k), A(), M();
47
- for (let e of [O, E]) try {
48
- e();
49
- } catch (e) {
50
- console.warn("[CommentKit] hide() failed.", e);
51
- }
52
- }, { attach: () => O.attach?.() });
53
- }
54
- function m(e) {
55
- let t = `commentkit:draft:v2:${e}:`;
56
- try {
57
- for (let e = localStorage.length - 1; e >= 0; e--) {
58
- let n = localStorage.key(e);
59
- n?.startsWith(t) && n.includes("~", t.length) && localStorage.removeItem(n);
60
- }
61
- } catch {}
62
- }
63
- function h(e) {
64
- try {
65
- e ? localStorage.setItem(n, JSON.stringify(e)) : localStorage.removeItem(n);
66
- } catch {}
67
- }
68
- function g(e, t, n, r) {
69
- let i = Date.now(), a = () => {
70
- document.visibilityState === "hidden" || Date.now() - i < 15e3 || (i = Date.now(), e.loadConfig().then((i) => {
71
- u(i) || d(i) && !f(e) ? (n(), r()) : i.enabled || t || d(i) || n();
72
- }, () => void 0));
73
- }, o = setInterval(a, 6e4);
74
- return document.addEventListener("visibilitychange", a), () => {
75
- clearInterval(o), document.removeEventListener("visibilitychange", a);
76
- };
77
- }
78
- function _(e, t) {
79
- let n = e.state.get().config;
80
- if (n && (u(n) || d(n))) return;
81
- let r = t instanceof o;
82
- console.warn(r ? `[CommentKit] The widget could not start: ${t.message} (${t.code}). See https://commentkit.dev/docs/errors#${t.code}` : "[CommentKit] The widget could not start; your page is not affected. See https://commentkit.dev/docs/troubleshooting", t), r && e.emit("error", { error: t }), (!r || t.status >= 500) && e.reportCrash(t, "start");
83
- }
84
- function v(e, t) {
85
- import("./report-CrIqQZDI.js").then((n) => n.reportStart(e, t)).catch(() => void 0);
86
- }
87
- var y = "See https://commentkit.dev/docs/";
88
- function b(e, ...t) {
89
- let [n, r] = t, a = {
90
- key: `init() needs your publishable project key, which starts with pk_live_ or pk_test_ (${n ? "the one given is not one" : "none was given"}), so the widget stays off. Copy it from Setup in your CommentKit project and pass it as init({ project: "pk_live_…" }) or data-project="pk_live_…". ${y}quickstart`,
91
- copy: `CommentKit was added twice: version ${String(n)} is already running on this page, so this copy (${i}) stays off. Add it once, with either the npm package or the script tag, not both. ${y}troubleshooting`,
92
- project: `init() was called again with another project (${String(n)}) while ${String(r)} is running; the first one stays. Call destroy() on every handle of the first one before starting another project. ${y}troubleshooting`,
93
- cooling: `The widget is hidden for a few hours on this browser after 3 crashes in a row. Cmd/Ctrl+Shift+K or show() brings it back now. ${y}troubleshooting`
94
- };
95
- console.warn(`[CommentKit] ${a[e]}`);
96
- }
97
- export { b as explain, _ as failed, m as forgetSignedIn, p as mount, v as reportStart };
@@ -1,75 +0,0 @@
1
- import { b as e } from "./client-kNAo2TTG.js";
2
- import { r as t } from "./page-key-DepmJzC1.js";
3
- import { t as n } from "./pkce-ChKGSW_4.js";
4
- import { t as r } from "./locale-D8Q4Q2Nt.js";
5
- // src/core/signin.ts
6
- function i(e = navigator.userAgent) {
7
- return /FBAN|FBAV|Instagram|Line\/|WhatsApp|Snapchat|LinkedInApp|Slack|Twitter|MicroMessenger|; wv\)|GSA\//i.test(e);
8
- }
9
- var a = "popup=yes,width=460,height=680,left=120,top=80", o = 500, s = 6e5, c = (e) => `commentkit:pkce:${e.projectKey}`;
10
- function l() {
11
- return (document.querySelector("[data-commentkit-host]")?.shadowRoot?.querySelector(".ck-root"))?.getAttribute("lang") || r();
12
- }
13
- async function u(t, r) {
14
- let o = e(48), s = e(24), c = await n(o), u = r.mode ?? "auto", d = u === "redirect" || u === "auto" && i(), h = t.signInLink, g = l(), _ = f(t, c, s, r.share ?? null, d ? location.href : null, h, g);
15
- if (d) return t.signInLink = null, p(t, _, o, s);
16
- let v = window.open(_.toString(), "commentkit-signin", a);
17
- if (!v) return u === "auto" ? (t.signInLink = null, p(t, f(t, c, s, r.share ?? null, location.href, h, g), o, s)) : "popup_blocked";
18
- t.signInLink = null;
19
- let y = await m(t, v, s);
20
- return y ? await t.exchange(y, o) ? "signed_in" : "failed" : "cancelled";
21
- }
22
- async function d(e) {
23
- let n = new URL(location.href), r = n.searchParams.get("ck_code"), i = n.searchParams.get("ck_state");
24
- if (!r || !i) return !1;
25
- history.replaceState(history.state, "", t(location.href, /^ck_(code|state)$/));
26
- let a = null;
27
- try {
28
- a = JSON.parse(sessionStorage.getItem(c(e)) ?? "null"), sessionStorage.removeItem(c(e));
29
- } catch {
30
- return !1;
31
- }
32
- return !a?.verifier || a.state !== i ? !1 : e.exchange(r, a.verifier);
33
- }
34
- function f(e, t, n, r, i, a = null, o = l()) {
35
- let s = new URL(e.authorize ?? "/widget/connect", e.endpoint), c = a ? new URL("guest", s) : s;
36
- return c.search = new URLSearchParams({
37
- key: e.projectKey,
38
- origin: e.origin,
39
- code_challenge: t,
40
- code_challenge_method: "S256",
41
- state: n,
42
- locale: o,
43
- ...r ? { share: r } : {},
44
- ...i ? { return_to: i } : {}
45
- }).toString(), a && (c.hash = `signin=${encodeURIComponent(a)}`), c;
46
- }
47
- function p(e, t, n, r) {
48
- try {
49
- sessionStorage.setItem(c(e), JSON.stringify({
50
- verifier: n,
51
- state: r
52
- }));
53
- } catch {
54
- return "failed";
55
- }
56
- return location.assign(t.toString()), "redirecting";
57
- }
58
- function m(e, t, n) {
59
- let r = [new URL(e.endpoint).origin, new URL(e.authorize ?? e.endpoint).origin];
60
- return new Promise((e) => {
61
- let i = !1, a = Date.now(), c = (t) => {
62
- i || (i = !0, window.removeEventListener("message", l), clearInterval(d), e(t));
63
- }, l = (e) => {
64
- if (e.source !== t || !r.includes(e.origin)) return;
65
- let i = e.data;
66
- i?.type === "commentkit:auth" && i.state === n && typeof i.code == "string" && c(i.code);
67
- };
68
- window.addEventListener("message", l);
69
- let u = null, d = setInterval(() => {
70
- if (Date.now() - a > s) return c(null);
71
- t.closed && (u ?? (u = Date.now())), u !== null && Date.now() - u > 1e3 && c(null);
72
- }, o);
73
- });
74
- }
75
- export { f as authorizeUrl, d as completeRedirect, u as signIn, l as widgetLocale };
@@ -1,208 +0,0 @@
1
- import { a as e, d as t, i as n, p as r, s as i, t as a } from "./client-kNAo2TTG.js";
2
- // src/activation.ts
3
- var o = "commentkit:active", s = "data-commentkit-extension";
4
- function c() {
5
- return document.documentElement.hasAttribute(s);
6
- }
7
- function l() {
8
- return /^(127\.0\.0\.1|\[::1\])$|(^|\.)localhost$|\.test$/.test(location.hostname);
9
- }
10
- function u(e, t = !0) {
11
- if (!t || l() || c() || /[?&]ck(_thread|_code)?(=|&|$)/.test(location.href)) return !0;
12
- try {
13
- let t = `commentkit:v1:${e}`;
14
- return !!localStorage.getItem(t) || !!sessionStorage.getItem(t) || localStorage.getItem(o) === "1";
15
- } catch {
16
- return !1;
17
- }
18
- }
19
- function d(e) {
20
- try {
21
- e ? localStorage.setItem(o, "1") : localStorage.removeItem(o);
22
- } catch {}
23
- }
24
- function f(e, t) {
25
- let n;
26
- try {
27
- let r = t ? location.hash : location.href, i = r.replace(RegExp(`([?#&])ck_${e}=([^&#]*)(&?)`), (e, t, r, i) => (n = r, i && t));
28
- i != r && history.replaceState(history.state, "", location.href.replace(r, () => i));
29
- } catch {}
30
- return n;
31
- }
32
- function p(e) {
33
- let t = (t) => {
34
- (t.metaKey || t.ctrlKey) && t.shiftKey && /^k$/i.test(t.key) && e() && (t.preventDefault(), t.stopImmediatePropagation());
35
- };
36
- return addEventListener("keydown", t, !0), () => removeEventListener("keydown", t, !0);
37
- }
38
- var m = "commentkit:crashes";
39
- function h() {
40
- try {
41
- let [e, t] = JSON.parse(localStorage.getItem(m));
42
- return Date.now() - t < 216e5 ? e : 0;
43
- } catch {
44
- return 0;
45
- }
46
- }
47
- // src/index.ts
48
- var g = null, _ = null, v = null, y = {}, b = Symbol.for("commentkit.instance");
49
- function x(e, t, ...n) {
50
- y[e] || (y[e] = 1, console.warn(`[CommentKit] ${t}`, ...n));
51
- }
52
- function S(e, ...t) {
53
- y[e] || (y[e] = 1, import("./show-BgVC8gWY.js").then((n) => n.explain(e, ...t)).catch(T));
54
- }
55
- function C() {
56
- let e = (e) => typeof e == "string" && e.trim() ? e.trim().slice(0, 255) : null;
57
- try {
58
- let t = typeof __COMMENTKIT_BUILD__ < "u" ? __COMMENTKIT_BUILD__ : globalThis.__COMMENTKIT_BUILD__;
59
- typeof t == "string" && (t = JSON.parse(t));
60
- let n = t ?? {};
61
- return {
62
- branch: e(n.branch),
63
- commit: e(n.commit)
64
- };
65
- } catch {
66
- return {
67
- branch: null,
68
- commit: null
69
- };
70
- }
71
- }
72
- function w(e) {
73
- let t = f("signin"), n = f("code", 1);
74
- if (typeof window > "u") return j(e);
75
- try {
76
- let r = t ?? e?._signin;
77
- if (r != null && (_ = r), v = n ?? e?._finish ?? v, g) return e?.project !== g.project && S("project", e?.project, g.project), g.client.auth.takeSignInLink(_), _ = null, O(g);
78
- let i = k(e);
79
- return typeof i == "string" ? j(e, i) : (g = i, O(i));
80
- } catch (t) {
81
- return console.warn("[CommentKit] The widget could not start because of an error inside CommentKit; your page is not affected. See https://commentkit.dev/docs/troubleshooting", t), import("./show-BgVC8gWY.js").then((n) => n.reportStart(e, t)).catch(T), j(e);
82
- }
83
- }
84
- var T = () => void 0, E = (e) => (t) => x(e, `${e}() failed.`, t), D = (e, t) => (...n) => t(...n).then(T, E(e));
85
- function O(e) {
86
- e.refs++;
87
- let t = !0, n = /* @__PURE__ */ new Set();
88
- return {
89
- ...e.api,
90
- client: e.client,
91
- on: ((r, i) => {
92
- if (!t) return T;
93
- let a = e.client.on(r, i);
94
- return n.add(a), a;
95
- }),
96
- destroy() {
97
- t && (t = !1, n.forEach((e) => e()), --e.refs < 1 && e.destroy());
98
- },
99
- _m: e.started
100
- };
101
- }
102
- function k(e) {
103
- if (!e?.project || !t.test(e.project)) return S("key", !!e?.project), "bad project key";
104
- let o = document;
105
- if (o[b]) return S("copy", o[b]), "second copy";
106
- let s = C(), { _key: l, _signin: f, _finish: m, identity: y, ...x } = e, w = {
107
- ...x,
108
- ...r(e.branch || s.branch, e.commit || s.commit)
109
- }, O = new a(w), k = null, A = null, j = !1, M = !1, N = !!l, P = O.auth.takeSignInLink(_) || !!(O.auth.finishLink = v);
110
- _ = v = null;
111
- let F = 0, I, L = (e) => (e === !0 && (M = !0), M && k?.attach?.(), j || k ? Promise.resolve() : (A ?? (A = (async (e) => {
112
- let t = () => e !== F, n = import("./show-BgVC8gWY.js");
113
- n.catch(T);
114
- try {
115
- let e = await O.loadConfig();
116
- if (t()) return;
117
- k = await (await n).mount(O, e, P, t, R, y, () => I = setTimeout(L, 6e4)), M && k?.attach?.(), k && N && d(!0);
118
- } catch (e) {
119
- await n.then((t) => t.failed(O, e), E("show"));
120
- } finally {
121
- t() || (A = null);
122
- }
123
- })(F)), A)), R = () => {
124
- clearTimeout(I), F++, M = !1, A = null, k?.(), k = null;
125
- }, z = w.toggleShortcut === !1 ? T : p(() => {
126
- try {
127
- if (k) return O.state.set({ request: {
128
- kind: "inbox",
129
- at: Date.now()
130
- } }), !0;
131
- N = !0, L(!0);
132
- } catch (e) {
133
- E("shortcut")(e);
134
- }
135
- });
136
- c() && import("./extension-E81hWyiT.js").then((e) => e.extensionHello()).catch(() => void 0);
137
- let B = P || N || u(w.project, w.hideOnProduction ?? !0) || !!y;
138
- B && !P && !N && h() >= 3 && (B = !1, S("cooling")), B && !O.auth.hasSession() && O.prefetchSignIn();
139
- let V = B ? L().then(() => !!k) : Promise.resolve(!1), H = {
140
- show: () => L(!0),
141
- hide: R,
142
- open: D("open", async (e) => {
143
- O.state.set({ opening: String(e).slice(0, 64) }), await L(!0);
144
- }),
145
- comment: D("comment", async (e = !0) => {
146
- e && (N = !0), await L(e), e && k && d(!0), O.state.set({ request: {
147
- kind: e ? "comment" : "stop",
148
- at: Date.now()
149
- } });
150
- }),
151
- signIn: async () => await O.signIn() === "signed_in",
152
- identify: (e) => import("./identify-CN-3xzqL.js").then((t) => t.identify(O, e, L)).catch(() => !1),
153
- signOut: D("signOut", () => O.signOut()),
154
- session: () => i(O.state.get().session)
155
- };
156
- Object.defineProperty(o, b, {
157
- value: n,
158
- configurable: !0
159
- });
160
- let U = {
161
- project: w.project,
162
- client: O,
163
- refs: 0,
164
- started: V,
165
- api: H,
166
- destroy() {
167
- j = !0, R(), z(), _ = O.auth.signInLink, v = O.auth.finishLink, delete o[b], g === U && (g = null);
168
- try {
169
- O.destroy();
170
- } catch (e) {
171
- E("destroy")(e);
172
- }
173
- }
174
- };
175
- return U;
176
- }
177
- var A = () => new Proxy(() => Promise.resolve(), { get: (e, t) => t === "then" ? void 0 : t === Symbol.toPrimitive ? () => "" : A() });
178
- function j(t, n) {
179
- let r = async () => void 0, i = async () => !1, a = () => T, o = e(), s = t ?? {}, c = {
180
- options: s,
181
- state: {
182
- get: () => o,
183
- subscribe: a,
184
- set: T
185
- },
186
- on: a,
187
- emit: T,
188
- endpoint: String(s.endpoint ?? "https://commentkit.dev").replace(/\/+$/, "")
189
- };
190
- return {
191
- client: new Proxy(c, { get: (e, t) => t in e ? e[t] : t === "then" ? void 0 : A() }),
192
- show: r,
193
- hide: T,
194
- open: r,
195
- comment: r,
196
- signIn: i,
197
- identify: i,
198
- signOut: r,
199
- session: () => null,
200
- on: a,
201
- destroy: T,
202
- ...n ? { _r() {
203
- let e = n && /* @__PURE__ */ Error(`init() stayed off: ${n}`);
204
- n = void 0, e && import("./show-BgVC8gWY.js").then((n) => n.reportStart(t, e)).catch(T);
205
- } } : {}
206
- };
207
- }
208
- export { d as a, c as i, m as n, h as r, w as t };