@commentkit/comment-kit 1.0.0 → 1.5.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 (77) hide show
  1. package/CHANGELOG.md +133 -1
  2. package/README.md +12 -5
  3. package/SECURITY.md +3 -1
  4. package/dist/npm/THIRD_PARTY_NOTICES.txt +22 -23
  5. package/dist/npm/chunks/AgentSend-DyWxNQ0p.js +64 -0
  6. package/dist/npm/chunks/Checklist-VYkSl6Q9.js +259 -0
  7. package/dist/npm/chunks/Composer-CnsGQirF.js +679 -0
  8. package/dist/npm/chunks/Guest-DkIvY5zt.js +170 -0
  9. package/dist/npm/chunks/MarkupEditor-DxTI9nJH.js +334 -0
  10. package/dist/npm/chunks/Panel-riaMYxt-.js +863 -0
  11. package/dist/npm/chunks/Settings-CB4zxQAL.js +206 -0
  12. package/dist/npm/chunks/{Shortcuts-BSOKdMHt.js → Shortcuts-D1cbajg_.js} +21 -17
  13. package/dist/npm/chunks/StyleEditor-BtTv3I8_.js +44 -0
  14. package/dist/npm/chunks/StylePanel-BI-n5Me1.js +199 -0
  15. package/dist/npm/chunks/TaskFields-HwrD0FrH.js +272 -0
  16. package/dist/npm/chunks/ThreadCard-CjaC8BTa.js +1026 -0
  17. package/dist/npm/chunks/Viewer-BnWshSXb.js +110 -0
  18. package/dist/npm/chunks/agent-Cr6NB6We.js +146 -0
  19. package/dist/npm/chunks/anchor-OCQnjp_6.js +294 -0
  20. package/dist/npm/chunks/{ar-O7EPv0mI.js → ar-BQ9K9Oqf.js} +189 -8
  21. package/dist/npm/chunks/card-bits-CxteYiZ9.js +126 -0
  22. package/dist/npm/chunks/client-CJ1tpI62.js +754 -0
  23. package/dist/npm/chunks/colors-0Ied7PE2.js +101 -0
  24. package/dist/npm/chunks/confetti-DKeKR7-6.js +41 -0
  25. package/dist/npm/chunks/{de-PGyZVNHX.js → de-CcPi8xdC.js} +160 -8
  26. package/dist/npm/chunks/drafts-CpQdHhcK.js +51 -0
  27. package/dist/npm/chunks/{es-Bq1idl8M.js → es-DXgkjDCG.js} +160 -8
  28. package/dist/npm/chunks/extension-BIGfr4Gh.js +50 -0
  29. package/dist/npm/chunks/{extension-B7SelsS0.js → extension-DkDSW4qw.js} +2 -2
  30. package/dist/npm/chunks/{fr-BVB9GGco.js → fr-IjJaUbWh.js} +160 -8
  31. package/dist/npm/chunks/{hi-DyBvrjzQ.js → hi-BhKQK2MU.js} +160 -8
  32. package/dist/npm/chunks/html2canvas-pro.esm-lgs6tb4C.js +8378 -0
  33. package/dist/npm/chunks/i18n-DAJGndZ2.js +904 -0
  34. package/dist/npm/chunks/{it-BlMMMwZh.js → it-DKiSCkiD.js} +160 -8
  35. package/dist/npm/chunks/{ja-lAioBCJv.js → ja-BI1WagDg.js} +160 -8
  36. package/dist/npm/chunks/{live-YFyP1GnP.js → live-B-mo27Qq.js} +1 -1
  37. package/dist/npm/chunks/lock-C82sC17d.js +30 -0
  38. package/dist/npm/chunks/{nl-DR8mLHnn.js → nl-CJw3VUQ5.js} +160 -8
  39. package/dist/npm/chunks/pick-CYPkLLFJ.js +120 -0
  40. package/dist/npm/chunks/{pt-BR-D7j6aDPx.js → pt-BR-CjBolC5g.js} +160 -8
  41. package/dist/npm/chunks/{pusher-BSsQoE1K.js → realtime-D22tI_AS.js} +58 -4
  42. package/dist/npm/chunks/source-CTQmAh0Y.js +146 -0
  43. package/dist/npm/chunks/src-CgBEoWl0.js +150 -0
  44. package/dist/npm/chunks/start-DW9_DKmf.js +1783 -0
  45. package/dist/npm/chunks/upload-BmrpZE5G.js +42 -0
  46. package/dist/npm/chunks/uploads-CipONvCy.js +541 -0
  47. package/dist/npm/chunks/{zh-CN-tzYg9NPH.js → zh-CN-BrZGx2S0.js} +160 -8
  48. package/dist/npm/element.js +4 -5
  49. package/dist/npm/headless.js +3 -3
  50. package/dist/npm/index.js +2 -2
  51. package/dist/npm/react.js +1 -1
  52. package/dist/npm/svelte.js +1 -1
  53. package/dist/npm/types/adapters/vue.d.ts +14 -0
  54. package/dist/npm/types/anchor/index.d.ts +22 -1
  55. package/dist/npm/types/core/api.d.ts +3 -0
  56. package/dist/npm/types/core/auth.d.ts +11 -0
  57. package/dist/npm/types/core/client.d.ts +128 -6
  58. package/dist/npm/types/core/types.d.ts +78 -4
  59. package/dist/npm/types/headless.d.ts +1 -1
  60. package/dist/npm/types/index.d.ts +6 -1
  61. package/dist/npm/vue.js +5 -1
  62. package/package.json +7 -5
  63. package/dist/npm/chunks/Guest-VNoofLxw.js +0 -157
  64. package/dist/npm/chunks/MarkupEditor-DTXrS3DD.js +0 -199
  65. package/dist/npm/chunks/Panel-B88JYH52.js +0 -438
  66. package/dist/npm/chunks/ThreadCard-izybwXIC.js +0 -817
  67. package/dist/npm/chunks/anchor-DT-Ynhh1.js +0 -270
  68. package/dist/npm/chunks/art-DK1JwPIo.js +0 -155
  69. package/dist/npm/chunks/client-Iegfv6ZC.js +0 -620
  70. package/dist/npm/chunks/colors-CX-IPjvb.js +0 -86
  71. package/dist/npm/chunks/extension-DSA8S8Qz.js +0 -26
  72. package/dist/npm/chunks/format-B5tJGtPC.js +0 -524
  73. package/dist/npm/chunks/html2canvas-DfGb8yka.js +0 -4024
  74. package/dist/npm/chunks/mount-Dx_8NhX3.js +0 -1484
  75. package/dist/npm/chunks/privacy-DLhezjyi.js +0 -30
  76. package/dist/npm/chunks/realtime-CBRW9BB3.js +0 -34
  77. package/dist/npm/chunks/src-C1Qp94nr.js +0 -549
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Public types of the CommentKit v1 browser SDK. They mirror the /api/v1
3
- * contract (openapi/v1.yaml in the API repo).
3
+ * contract: openapi/v1.yaml in the API repo, copied here as contract/openapi-v1.yaml.
4
4
  */
5
5
  export type ThreadStatus = "open" | "in_progress" | "in_review" | "resolved" | "closed";
6
6
  export type ThreadPriority = "none" | "low" | "medium" | "high" | "urgent";
@@ -14,8 +14,25 @@ export interface Person {
14
14
  /** Where feedback points. Several strategies are stored so it can be found again after the page changes. */
15
15
  export interface Anchor {
16
16
  type: "element" | "region" | "text" | "page";
17
- /** Build-time source location (data-ck-src), e.g. "src/Hero.tsx:12:4". */
17
+ /**
18
+ * Source location, e.g. "src/Hero.tsx:12:4": from data-ck-src (build plugin), or in development
19
+ * builds without it, read from the framework's dev data (React, Vue, Svelte, Preact).
20
+ */
18
21
  source?: string | null;
22
+ /** Component that rendered the element, in development builds (e.g. "PricingCard"). At most 120 characters. */
23
+ component?: string | null;
24
+ /** Open shadow roots the element is inside: each host's selector, outermost first. */
25
+ shadow_path?: string[] | null;
26
+ /** Selector of the same-origin iframe the element is inside (in the top page). */
27
+ frame?: string | null;
28
+ /**
29
+ * The way through nested same-origin iframes (depth 2 to 4), or through an iframe that sits in a
30
+ * shadow root: one hop per iframe, outermost first. A hop is the iframe's selector in its document,
31
+ * after the selectors of any open shadow hosts around it, joined by " >>> " (e.g.
32
+ * "#app >>> iframe#editor"). `shadow_path` is then the shadow hosts inside the innermost iframe.
33
+ * When set, `frame` repeats the first hop if that is a plain selector, for readers of the one-level field.
34
+ */
35
+ frames?: string[] | null;
19
36
  /** Developer-provided stable id (data-ck-id). */
20
37
  ck_id?: string | null;
21
38
  selector?: string | null;
@@ -72,12 +89,33 @@ export interface Message {
72
89
  } | null;
73
90
  attachments?: Attachment[];
74
91
  reactions?: Reaction[];
92
+ /** Version of this message: sent back as If-Match when editing it (older servers leave it out). */
93
+ etag?: string;
75
94
  edited_at: string | null;
76
95
  created_at: string;
77
96
  }
97
+ /** Fields team members (capabilities.triage) can set while writing; the server ignores them for anyone else. */
98
+ export interface TaskInput {
99
+ priority?: ThreadPriority;
100
+ assignee_id?: number | null;
101
+ /** Several people; the first is the primary. */
102
+ assignee_ids?: number[];
103
+ label_ids?: number[];
104
+ }
105
+ /** A CSS property a reviewer may suggest a new value for (the composer's "Adjust style" panel). */
106
+ export type StyleProperty = "font-size" | "font-weight" | "line-height" | "letter-spacing" | "text-align" | "color" | "background-color" | "border-color" | "border-width" | "border-style" | "border-radius" | "opacity" | "margin" | "padding" | "width" | "height" | "gap" | "display";
107
+ /** One suggested style change on the commented element. `to: null` means "remove this value". */
108
+ export interface StyleChange {
109
+ property: StyleProperty;
110
+ /** The value on the page when it was suggested. */
111
+ from?: string | null;
112
+ to: string | null;
113
+ }
78
114
  export interface MarkupShape {
79
- tool: "arrow" | "rect" | "pen" | "blur" | "text";
115
+ tool: "arrow" | "rect" | "pen" | "blur" | "text" | "line" | "ellipse";
80
116
  color?: string | null;
117
+ /** Stroke width in screenshot pixels. */
118
+ width?: number | null;
81
119
  points?: number[] | null;
82
120
  text?: string | null;
83
121
  }
@@ -119,6 +157,13 @@ export interface Thread {
119
157
  status: ThreadStatus;
120
158
  priority: ThreadPriority;
121
159
  assignee: Person | null;
160
+ /** Everyone assigned, the primary (`assignee`) first. Older servers send only `assignee`. */
161
+ assignees?: Person[];
162
+ /** Extra detail under the comment. */
163
+ description?: string | null;
164
+ checklist?: ChecklistItem[];
165
+ /** Style changes the reviewer suggested for the commented element. Older servers leave it out. */
166
+ style_changes?: StyleChange[];
122
167
  due_at: string | null;
123
168
  labels?: Label[];
124
169
  page: {
@@ -184,6 +229,12 @@ export interface Session {
184
229
  capabilities: Capabilities;
185
230
  /** Opaque key that live-update pings carry in `by` when this person made the change. */
186
231
  realtime_key?: string;
232
+ /** This project in the CommentKit dashboard, for members (absent for guests and older servers). */
233
+ dashboard_url?: string | null;
234
+ /** The linked GitHub repository (owner/name), team members only: agents open in its clone. */
235
+ repository?: string | null;
236
+ /** The signed-in person's email, shown in Settings (absent on older servers). */
237
+ email?: string | null;
187
238
  }
188
239
  export interface WidgetConfig {
189
240
  project: {
@@ -235,15 +286,24 @@ export interface WidgetConfig {
235
286
  auth_endpoint: string;
236
287
  } | null;
237
288
  }
289
+ export interface ChecklistItem {
290
+ id: string;
291
+ body: string;
292
+ done: boolean;
293
+ }
238
294
  export interface Label {
239
295
  id: number;
240
296
  name: string;
241
297
  color: string;
242
298
  }
243
299
  export type Position = "bottom-right" | "bottom-left" | "top-right" | "top-left";
300
+ /** Where the reader dragged the toolbar on this device: a corner, or the middle of the top or bottom edge. */
301
+ export type DockPosition = Position | "bottom-center" | "top-center";
302
+ /** What a notification is about (the API's inbox `kind`). */
303
+ export type InboxKind = "mention" | "assigned" | "ready_for_review" | "reopened" | "reply" | "resolved" | "closed" | "new_feedback" | "due_soon" | "overdue" | "agent_request";
244
304
  export interface InboxItem {
245
305
  id: string;
246
- kind: string;
306
+ kind: InboxKind;
247
307
  actor: Person;
248
308
  thread_id: string;
249
309
  reference: string | null;
@@ -293,6 +353,16 @@ export interface CommentKitOptions {
293
353
  * (WCAG 2.1.4). Esc and Cmd/Ctrl+Shift+K keep working.
294
354
  */
295
355
  shortcuts?: boolean;
356
+ /**
357
+ * Turn parts of the comment tools off on this site. Each one defaults to on (screenshots also
358
+ * follow the dashboard setting). `text: false` stops selected text from becoming a quoted comment.
359
+ */
360
+ tools?: {
361
+ screenshots?: boolean;
362
+ markup?: boolean;
363
+ text?: boolean;
364
+ attachments?: boolean;
365
+ };
296
366
  }
297
367
  export interface CommentKitEvents {
298
368
  ready: {
@@ -310,6 +380,10 @@ export interface CommentKitEvents {
310
380
  "message:created": {
311
381
  message: Message;
312
382
  };
383
+ /** Comment mode started or stopped (from the Comment button, the C key or `comment()`). */
384
+ mode: {
385
+ commenting: boolean;
386
+ };
313
387
  error: {
314
388
  error: CommentKitError;
315
389
  };
@@ -1,5 +1,5 @@
1
1
  /** Headless client for custom UIs, extensions and tests. No UI, no globals. */
2
- export { CommentKitClient, currentPageUrl, SDK_VERSION } from "./core/client.js";
2
+ export { CommentKitClient, currentPageUrl, EDIT_CONFLICT, SDK_VERSION } from "./core/client.js";
3
3
  export { ApiClient } from "./core/api.js";
4
4
  export { AuthManager } from "./core/auth.js";
5
5
  export { createAnchor, resolveAnchor, stableSelector } from "./anchor/index.js";
@@ -1,6 +1,6 @@
1
1
  import { CommentKitClient, SDK_VERSION } from "./core/client.js";
2
2
  import { type CommentKitEvents, type CommentKitOptions, type Session } from "./core/types.js";
3
- export type { Anchor, Attachment, Capabilities, CaptureInput, CommentKitEvents, CommentKitOptions, Environment, InboxItem, MarkupShape, Message, Page, Person, Position, Reaction, Session, Thread, ThreadPriority, ThreadStatus, WidgetConfig, } from "./core/types.js";
3
+ export type { Anchor, Attachment, Capabilities, CaptureInput, ChecklistItem, CommentKitEvents, CommentKitOptions, Environment, InboxItem, MarkupShape, Message, Page, Person, Position, Reaction, Session, StyleChange, StyleProperty, Thread, TaskInput, ThreadPriority, ThreadStatus, WidgetConfig, } from "./core/types.js";
4
4
  export { CommentKitError } from "./core/types.js";
5
5
  export { SDK_VERSION };
6
6
  export interface CommentKit {
@@ -10,6 +10,11 @@ export interface CommentKit {
10
10
  hide(): void;
11
11
  /** Show the widget and open one conversation, by id or reference ("CK-12"). */
12
12
  open(thread: string): Promise<void>;
13
+ /**
14
+ * Start comment mode, as if the Comment button was pressed: for your own "Leave feedback" button.
15
+ * `comment(false)` stops it. Listen to the `mode` event to follow it.
16
+ */
17
+ comment(on?: boolean): Promise<void>;
13
18
  /** Open the sign-in window. Call from a click handler. */
14
19
  signIn(): Promise<boolean>;
15
20
  signOut(): Promise<void>;
package/dist/npm/vue.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as e } from "./chunks/src-C1Qp94nr.js";
1
+ import { t as e } from "./chunks/src-CgBEoWl0.js";
2
2
  import { defineComponent as t, onBeforeUnmount as n, onMounted as r } from "vue";
3
3
  //#region src/adapters/vue.ts
4
4
  function i(e) {
@@ -58,6 +58,10 @@ var a = t({
58
58
  shortcuts: {
59
59
  type: Boolean,
60
60
  default: void 0
61
+ },
62
+ tools: {
63
+ type: Object,
64
+ default: void 0
61
65
  }
62
66
  },
63
67
  setup(t) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commentkit/comment-kit",
3
- "version": "1.0.0",
3
+ "version": "1.5.0",
4
4
  "description": "Figma-style comments for any website. Clients pin feedback with an automatic screenshot; developers see it on localhost and hand it to their AI agent.",
5
5
  "keywords": [
6
6
  "comments",
@@ -63,8 +63,7 @@
63
63
  ],
64
64
  "publishConfig": {
65
65
  "access": "public",
66
- "registry": "https://registry.npmjs.org/",
67
- "tag": "beta"
66
+ "registry": "https://registry.npmjs.org/"
68
67
  },
69
68
  "scripts": {
70
69
  "build": "npm run build:npm && npm run build:cdn && npm run build:types && node scripts/check-dist.mjs",
@@ -77,6 +76,8 @@
77
76
  "test:e2e": "playwright test",
78
77
  "test:visual": "playwright test e2e/specs/visual.spec.ts --project=chromium",
79
78
  "test:host-matrix": "node scripts/host-matrix.mjs",
79
+ "test:wordpress": "node scripts/wordpress-check.mjs",
80
+ "test:wordpress:real": "node e2e/wordpress-real/run.mjs",
80
81
  "typecheck": "tsc -p tsconfig.json",
81
82
  "check": "npm run typecheck && npm run test && npm run build",
82
83
  "prepublishOnly": "npm run check && node scripts/check-pack.mjs",
@@ -92,7 +93,7 @@
92
93
  "@playwright/test": "1.64.1",
93
94
  "@types/react": "19.3.0",
94
95
  "@vitest/coverage-v8": "5.0.5",
95
- "html2canvas": "1.4.1",
96
+ "html2canvas-pro": "2.5.2",
96
97
  "jsdom": "30.1.3",
97
98
  "preact": "11.0.1",
98
99
  "pusher-js": "8.6.0",
@@ -103,7 +104,8 @@
103
104
  "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
104
105
  "vite-plus": "1.3.0",
105
106
  "vitest": "5.0.5",
106
- "vue": "3.5.44"
107
+ "vue": "3.5.44",
108
+ "yaml": "2.9.1"
107
109
  },
108
110
  "peerDependencies": {
109
111
  "react": ">=18",
@@ -1,157 +0,0 @@
1
- import { o as e } from "./src-C1Qp94nr.js";
2
- import { c as t } from "./client-Iegfv6ZC.js";
3
- import { d as n, f as r, h as i, n as a, p as o } from "./format-B5tJGtPC.js";
4
- import { o as s, p as c } from "./mount-Dx_8NhX3.js";
5
- //#region src/ui/Guest.tsx
6
- async function l(n, r) {
7
- try {
8
- let e = await n.api.request("/guest/start", {
9
- method: "POST",
10
- anonymous: !0,
11
- body: {
12
- client_id: n.options.project,
13
- share: r.share,
14
- name: r.name.trim(),
15
- email: r.email.trim()
16
- }
17
- }), t = Date.parse(e.pending_session.expires_at);
18
- return n.auth.setPending({
19
- token: e.access_token,
20
- email: e.pending_session.email,
21
- expiresAt: Number.isFinite(t) ? t : Date.now() + e.expires_in * 1e3
22
- }), "started";
23
- } catch (n) {
24
- if (n instanceof t && n.code === "origin_not_allowed") return "popup";
25
- throw n instanceof t && (n.code === "share_expired" || n.status === 410 || n.errors?.share) ? new t(410, "share_expired", e("shareExpired")) : n;
26
- }
27
- }
28
- function u({ client: l, email: u, onDone: f, onDifferentEmail: p, onClose: m }) {
29
- let [h, g] = i(""), [_, v] = i(!1), [y, b] = i(null), [x, S] = i(null), C = o(null);
30
- r(() => C.current?.focus({ preventScroll: !0 }), []);
31
- let w = async () => {
32
- if (/^\d{6}$/.test(h) && !_) {
33
- v(!0), b(null);
34
- try {
35
- let e = await l.api.request("/guest/verify", {
36
- method: "POST",
37
- body: { code: h }
38
- });
39
- l.auth.adopt(e), await l.loadSession().catch(() => null), f(e.published_thread_ids ?? []);
40
- } catch (n) {
41
- if ((n instanceof t ? n.status : 0) === 422) return b({
42
- text: e("verifyWrong"),
43
- tone: "warning"
44
- });
45
- let r = d(n);
46
- r && (l.auth.setPending(null), S(r === "expired" ? "again" : "stop")), b({
47
- text: r ? e(r === "link" ? "verifyLinkExpired" : r === "removed" ? "verifyRemoved" : "verifyExpired") : c(n),
48
- tone: "warning"
49
- });
50
- } finally {
51
- v(!1);
52
- }
53
- }
54
- }, T = async () => {
55
- try {
56
- await l.api.request("/guest/resend", { method: "POST" }), b({ text: e("verifyResent") });
57
- } catch (n) {
58
- b({
59
- text: n instanceof t && n.status === 429 ? e("verifyWait") : e("errorGeneric"),
60
- tone: "warning"
61
- });
62
- }
63
- };
64
- return /* @__PURE__ */ n("div", {
65
- class: "ck-card",
66
- style: s({
67
- x: innerWidth / 2 - 190,
68
- y: 80
69
- }),
70
- role: "dialog",
71
- "aria-labelledby": "ck-verify-title",
72
- "data-commentkit-ui": !0,
73
- onKeyDown: (e) => e.key === "Escape" && m(),
74
- children: [
75
- /* @__PURE__ */ n("div", {
76
- class: "ck-card-head",
77
- children: [/* @__PURE__ */ n("h2", {
78
- class: "ck-card-title",
79
- id: "ck-verify-title",
80
- children: e("verifyTitle")
81
- }), /* @__PURE__ */ n("button", {
82
- class: "ck-ghost",
83
- "aria-label": e("close"),
84
- onClick: m,
85
- children: /* @__PURE__ */ n(a, { name: "close" })
86
- })]
87
- }),
88
- /* @__PURE__ */ n("div", {
89
- class: "ck-card-body",
90
- children: [
91
- /* @__PURE__ */ n("p", {
92
- class: "ck-verify-text",
93
- children: e("verifyBody", { email: u })
94
- }),
95
- /* @__PURE__ */ n("label", {
96
- class: "ck-field",
97
- children: [/* @__PURE__ */ n("span", { children: e("verifyCode") }), /* @__PURE__ */ n("input", {
98
- ref: C,
99
- class: "ck-input ck-code",
100
- inputMode: "numeric",
101
- autoComplete: "one-time-code",
102
- pattern: "[0-9]*",
103
- maxLength: 6,
104
- value: h,
105
- onInput: (e) => g(e.target.value.replace(/\D/g, "").slice(0, 6)),
106
- onKeyDown: (e) => {
107
- e.stopPropagation(), e.key === "Enter" && w(), e.key === "Escape" && m();
108
- }
109
- })]
110
- }),
111
- y ? /* @__PURE__ */ n("div", {
112
- class: "ck-note",
113
- role: y.tone ? "alert" : "status",
114
- "data-tone": y.tone,
115
- children: y.text
116
- }) : null,
117
- x ? null : /* @__PURE__ */ n("div", {
118
- class: "ck-actions",
119
- children: [/* @__PURE__ */ n("button", {
120
- class: "ck-chip",
121
- onClick: () => void T(),
122
- children: e("verifyResend")
123
- }), /* @__PURE__ */ n("button", {
124
- class: "ck-chip",
125
- onClick: () => {
126
- l.auth.setPending(null), p();
127
- },
128
- children: e("verifyDifferent")
129
- })]
130
- })
131
- ]
132
- }),
133
- /* @__PURE__ */ n("div", {
134
- class: "ck-card-foot",
135
- children: [/* @__PURE__ */ n("span", { class: "ck-spacer" }), x === "again" ? /* @__PURE__ */ n("button", {
136
- class: "ck-btn ck-primary",
137
- onClick: p,
138
- children: e("writeAgain")
139
- }) : x === "stop" ? /* @__PURE__ */ n("button", {
140
- class: "ck-btn",
141
- onClick: m,
142
- children: e("close")
143
- }) : /* @__PURE__ */ n("button", {
144
- class: "ck-btn ck-primary",
145
- disabled: _ || h.length !== 6,
146
- onClick: () => void w(),
147
- children: e(_ ? "sending" : "verifyPublish")
148
- })]
149
- })
150
- ]
151
- });
152
- }
153
- function d(e) {
154
- return e instanceof t ? e.code === "share_expired" || e.status === 410 ? "link" : e.code === "guest_removed" ? "removed" : e.status === 403 ? /\blink\b/i.test(e.message) ? "link" : "removed" : e.status === 409 || e.status === 401 ? "expired" : null : null;
155
- }
156
- //#endregion
157
- export { u as GuestVerify, l as startGuest };
@@ -1,199 +0,0 @@
1
- import { o as e } from "./src-C1Qp94nr.js";
2
- import { a as t, d as n, f as r, h as i, p as a } from "./format-B5tJGtPC.js";
3
- //#region src/ui/MarkupEditor.tsx
4
- var o = [
5
- "#ff3b30",
6
- "#ff9500",
7
- "#34c759",
8
- "#007aff",
9
- "#121316"
10
- ], s = [
11
- "color_red",
12
- "color_orange",
13
- "color_green",
14
- "color_blue",
15
- "color_black"
16
- ];
17
- function c({ image: c, onDone: u, onCancel: d }) {
18
- let f = a(null), [p, m] = i(null), [h, g] = i("arrow"), [_, v] = i(o[0]), [y, b] = i([]), x = a(null), [S, C] = i(null), w = a(null), T = a(null);
19
- r(() => (w.current ?? T.current)?.focus({ preventScroll: !0 }), [!!S]);
20
- let E = () => {
21
- let e = S?.text.trim().slice(0, 500);
22
- S && e && b([...y, {
23
- tool: "text",
24
- color: _,
25
- points: [S.x, S.y],
26
- text: e
27
- }]), T.current?.focus({ preventScroll: !0 }), C(null);
28
- };
29
- r(() => {
30
- createImageBitmap(c).then(m);
31
- }, [c]), r(() => D(), [p, y]);
32
- let D = (e) => {
33
- let t = f.current;
34
- if (!t || !p) return;
35
- t.width = p.width, t.height = p.height;
36
- let n = t.getContext("2d");
37
- n.drawImage(p, 0, 0);
38
- for (let t of e ? [...y, e] : y) l(n, t, p);
39
- }, O = (e) => {
40
- let t = f.current, n = t.getBoundingClientRect();
41
- return [Math.round((e.clientX - n.left) / n.width * t.width), Math.round((e.clientY - n.top) / n.height * t.height)];
42
- };
43
- return /* @__PURE__ */ n("div", {
44
- class: "ck-markup",
45
- ref: T,
46
- tabIndex: -1,
47
- role: "dialog",
48
- "aria-label": e("markup"),
49
- "data-commentkit-ui": !0,
50
- onKeyDown: (e) => {
51
- e.key === "Escape" && (e.stopPropagation(), S ? (T.current?.focus({ preventScroll: !0 }), C(null)) : d());
52
- },
53
- children: [
54
- /* @__PURE__ */ n("div", {
55
- class: "ck-markup-tools",
56
- children: [
57
- [
58
- "arrow",
59
- "rect",
60
- "pen",
61
- "blur",
62
- "text"
63
- ].map((t) => /* @__PURE__ */ n("button", {
64
- class: "ck-chip",
65
- "aria-pressed": h === t,
66
- onClick: () => g(t),
67
- children: e(`tool_${t}`)
68
- })),
69
- o.map((t, r) => /* @__PURE__ */ n("button", {
70
- class: "ck-chip",
71
- "aria-pressed": _ === t,
72
- "aria-label": e(s[r]),
73
- style: {
74
- width: "28px",
75
- padding: 0,
76
- background: t
77
- },
78
- onClick: () => v(t)
79
- })),
80
- /* @__PURE__ */ n("button", {
81
- class: "ck-chip",
82
- disabled: !y.length,
83
- onClick: () => b(y.slice(0, -1)),
84
- children: e("undo")
85
- }),
86
- /* @__PURE__ */ n("button", {
87
- class: "ck-chip",
88
- onClick: d,
89
- children: e("cancel")
90
- }),
91
- /* @__PURE__ */ n("button", {
92
- class: "ck-chip ck-primary",
93
- onClick: () => {
94
- let e = S?.text.trim().slice(0, 500), t = S && e ? {
95
- tool: "text",
96
- color: _,
97
- points: [S.x, S.y],
98
- text: e
99
- } : null;
100
- t && D(t), f.current?.toBlob((e) => e && u(e, t ? [...y, t] : y), "image/webp", .88);
101
- },
102
- children: e("markupDone")
103
- })
104
- ]
105
- }),
106
- /* @__PURE__ */ n("canvas", {
107
- ref: f,
108
- onPointerDown: (e) => {
109
- let [t, n] = O(e);
110
- h === "text" ? (e.preventDefault(), E(), C({
111
- x: t,
112
- y: n,
113
- left: Math.min(e.clientX, innerWidth - 240),
114
- top: Math.max(8, e.clientY - 18),
115
- text: ""
116
- })) : (x.current = {
117
- tool: h,
118
- color: _,
119
- points: [
120
- t,
121
- n,
122
- t,
123
- n
124
- ]
125
- }, f.current?.setPointerCapture(e.pointerId));
126
- },
127
- onPointerMove: (e) => {
128
- let t = x.current;
129
- if (!t?.points) return;
130
- let [n, r] = O(e);
131
- t.tool === "pen" ? t.points.length < 4e3 && t.points.push(n, r) : (t.points[2] = n, t.points[3] = r), D(t);
132
- },
133
- onPointerUp: () => {
134
- x.current && b([...y, x.current]), x.current = null;
135
- }
136
- }),
137
- S ? /* @__PURE__ */ n("div", {
138
- class: "ck-label-box",
139
- style: t(S.left, S.top),
140
- children: [/* @__PURE__ */ n("input", {
141
- ref: w,
142
- class: "ck-input",
143
- maxLength: 500,
144
- value: S.text,
145
- placeholder: e("markupTextPrompt"),
146
- "aria-label": e("markupTextPrompt"),
147
- style: { color: _ },
148
- onInput: (e) => C({
149
- ...S,
150
- text: e.target.value
151
- }),
152
- onKeyDown: (e) => {
153
- e.key === "Enter" && (e.preventDefault(), E());
154
- }
155
- }), /* @__PURE__ */ n("button", {
156
- class: "ck-chip ck-primary",
157
- onMouseDown: (e) => e.preventDefault(),
158
- onClick: E,
159
- children: e("markupTextAdd")
160
- })]
161
- }) : null
162
- ]
163
- });
164
- }
165
- function l(e, t, n) {
166
- let r = t.points ?? [], i = Math.max(3, Math.round(n.width / 300));
167
- e.save(), e.strokeStyle = e.fillStyle = t.color ?? "#ff3b30", e.lineWidth = i, e.lineCap = e.lineJoin = "round";
168
- let [a = 0, o = 0, s = 0, c = 0] = r;
169
- switch (t.tool) {
170
- case "rect":
171
- e.strokeRect(Math.min(a, s), Math.min(o, c), Math.abs(s - a), Math.abs(c - o));
172
- break;
173
- case "arrow": {
174
- let t = Math.atan2(c - o, s - a), n = i * 5;
175
- e.beginPath(), e.moveTo(a, o), e.lineTo(s, c), e.stroke(), e.beginPath(), e.moveTo(s, c), e.lineTo(s - n * Math.cos(t - .45), c - n * Math.sin(t - .45)), e.lineTo(s - n * Math.cos(t + .45), c - n * Math.sin(t + .45)), e.closePath(), e.fill();
176
- break;
177
- }
178
- case "pen":
179
- e.beginPath();
180
- for (let t = 0; t < r.length; t += 2) (t ? e.lineTo : e.moveTo).call(e, r[t], r[t + 1]);
181
- e.stroke();
182
- break;
183
- case "blur": {
184
- let t = Math.min(a, s), n = Math.min(o, c), r = Math.abs(s - a), i = Math.abs(c - o);
185
- if (r > 2 && i > 2) {
186
- let a = Math.max(8, Math.round(Math.min(r, i) / 6)), o = e.getImageData(t, n, r, i);
187
- for (let s = 0; s < i; s += a) for (let i = 0; i < r; i += a) {
188
- let c = (s * r + i) * 4;
189
- e.fillStyle = `rgb(${o.data[c]},${o.data[c + 1]},${o.data[c + 2]})`, e.fillRect(t + i, n + s, a, a);
190
- }
191
- }
192
- break;
193
- }
194
- case "text": e.font = `bold ${i * 6}px system-ui, sans-serif`, e.lineWidth = i * 1.5, e.strokeStyle = "#ffffff", e.strokeText(t.text ?? "", a, o), e.fillText(t.text ?? "", a, o);
195
- }
196
- e.restore();
197
- }
198
- //#endregion
199
- export { c as MarkupEditor };