@hitch42/applet 0.1.1-beta.14 → 0.1.1-beta.16

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 (61) hide show
  1. package/dist/_internal/server.d.ts +10 -1
  2. package/dist/_internal/server.js +16 -2
  3. package/dist/applet.js +12 -12
  4. package/dist/auth-D3CrCtZq.js +21 -0
  5. package/dist/{build-CwOM9C0W.js → build-XHoa_sJL.js} +1 -1
  6. package/dist/build-ueR7XjZT.js +2 -0
  7. package/dist/{ci-BKw14X2h.js → ci-B5-mH-YW.js} +1 -1
  8. package/dist/client.d.ts +3 -3
  9. package/dist/contract-BbOj5EB7.js +23 -0
  10. package/dist/{contract-CZdT22tB.d.ts → contract-D9wEvxGI.d.ts} +1 -1
  11. package/dist/{deploy-CaGPhe2h.js → deploy-C5JDIn2Y.js} +4 -3
  12. package/dist/device-BgIfytaR.js +135 -0
  13. package/dist/email-protocol-B9u_dh2p.d.ts +202 -0
  14. package/dist/{generate-CORu1X2X.js → generate-BV_emZgy.js} +39 -13
  15. package/dist/generate-C9bWqdaB.js +2 -0
  16. package/dist/hitch-file-url-BPKj9zVG.js +25 -0
  17. package/dist/index.d.ts +15 -25
  18. package/dist/index.js +80 -192
  19. package/dist/{init-CD-xOYWV.js → init-BGQ_bP44.js} +5 -5
  20. package/dist/{manifest-CuY3ICpN.js → load-config-Dkr2VxZN.js} +37 -2
  21. package/dist/{login-CUx3TmFQ.js → login-CceGvlMi.js} +3 -1
  22. package/dist/{logs-BySh9fnH.js → logs-DOkT5ots.js} +3 -3
  23. package/dist/{manifest-ARAy2HP7.d.ts → manifest-BSUtHbu-.d.ts} +1 -4
  24. package/dist/markdown-CwlqzBtP.js +88 -0
  25. package/dist/markdown-DSHOQIOb.d.ts +14 -0
  26. package/dist/markdown-editor-BmEaBzd7.d.ts +27 -0
  27. package/dist/markdown-editor-C5mLHGqu.js +428 -0
  28. package/dist/{project-z7x0omdw.js → project-CCVqCCgU.js} +5 -4
  29. package/dist/react/markdown-editor.d.ts +2 -0
  30. package/dist/react/markdown-editor.js +2 -0
  31. package/dist/react/markdown.d.ts +2 -0
  32. package/dist/react/markdown.js +2 -0
  33. package/dist/react.d.ts +2 -37
  34. package/dist/react.js +2 -534
  35. package/dist/{schedules-B_p9U-vM.js → schedules-D6-3v-Az.js} +1 -1
  36. package/dist/server.d.ts +3 -3
  37. package/dist/store-B8N_8JIN.js +196 -0
  38. package/dist/{upload-DKZzz5kW.d.ts → upload-D_kkmne_.d.ts} +5 -9
  39. package/dist/{variables-D9nEFyOK.js → variables-BSFZnLxY.js} +2 -2
  40. package/dist/vite.d.ts +1 -1
  41. package/dist/vite.js +165 -35
  42. package/dist/workspace-8yqXsvce.js +31 -0
  43. package/fonts/inter/LICENSE.txt +92 -0
  44. package/fonts/inter/inter-cyrillic-ext.woff2 +0 -0
  45. package/fonts/inter/inter-cyrillic.woff2 +0 -0
  46. package/fonts/inter/inter-greek-ext.woff2 +0 -0
  47. package/fonts/inter/inter-greek.woff2 +0 -0
  48. package/fonts/inter/inter-latin-ext.woff2 +0 -0
  49. package/fonts/inter/inter-latin.woff2 +0 -0
  50. package/fonts/inter/inter-vietnamese.woff2 +0 -0
  51. package/fonts/inter.css +81 -0
  52. package/package.json +15 -1
  53. package/scaffold/.agents/skills/hitch-applets/references/markdown.md +20 -2
  54. package/scaffold/applet/src/client/styles/globals.css +6 -1
  55. package/dist/build-CeRZYhM9.js +0 -2
  56. package/dist/email-WA4jnzZ0.js +0 -211
  57. package/dist/email-protocol-DqJ6YCiC.d.ts +0 -230
  58. package/dist/generate-CtbF9Zxd.js +0 -2
  59. package/dist/load-config-BeQZ2yOa.js +0 -27
  60. package/dist/me-BW7Paary.js +0 -32
  61. package/dist/workspace-D0dnnlxL.js +0 -385
package/dist/react.js CHANGED
@@ -1,535 +1,3 @@
1
- import { useEffect, useMemo, useRef, useState } from "react";
2
- import { BetweenHorizontalEnd, BetweenVerticalEnd, Bold, Code, Heading, Italic, Link, List, ListMinus, ListOrdered, ListTodo, Quote, Strikethrough, Table, Trash2, X } from "lucide-react";
3
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- import { Streamdown, defaultRehypePlugins, defaultUrlTransform } from "streamdown";
5
- import { GapCursor } from "@tiptap/pm/gapcursor";
6
- import { NodeSelection } from "@tiptap/pm/state";
7
- import { EditorContent, NodeViewWrapper, ReactNodeViewRenderer, useEditor, useEditorState } from "@tiptap/react";
8
- import { Button, Toolbar } from "react-aria-components";
9
- import { twMerge } from "cn";
10
- import { generateHTML } from "@tiptap/core";
11
- import Image from "@tiptap/extension-image";
12
- import { TaskItem, TaskList } from "@tiptap/extension-list";
13
- import { Table as Table$1, TableCell, TableHeader, TableRow, renderTableToMarkdown } from "@tiptap/extension-table";
14
- import { Placeholder } from "@tiptap/extensions";
15
- import { Markdown as Markdown$1 } from "@tiptap/markdown";
16
- import StarterKit from "@tiptap/starter-kit";
17
- //#region src/react/hitch-file-url.ts
18
- const HITCH_FILE_PREFIX = "hitch-file://";
19
- const DOWNLOAD_URL_TTL_MS = 3e6;
20
- const downloadUrlCache = /* @__PURE__ */ new Map();
21
- function cachedDownloadUrl(files, id) {
22
- const cached = downloadUrlCache.get(id);
23
- if (cached !== void 0 && cached.expiresAt > Date.now()) return cached.request;
24
- const request = files.download(id).then((file) => file.downloadUrl);
25
- downloadUrlCache.set(id, {
26
- request,
27
- expiresAt: Date.now() + DOWNLOAD_URL_TTL_MS
28
- });
29
- return request;
30
- }
31
- function seedDownloadUrl(id, url) {
32
- downloadUrlCache.set(id, {
33
- request: Promise.resolve(url),
34
- expiresAt: Date.now() + DOWNLOAD_URL_TTL_MS
35
- });
36
- }
37
- function invalidateDownloadUrl(id) {
38
- downloadUrlCache.delete(id);
39
- }
40
- //#endregion
41
- //#region src/react/markdown.tsx
42
- function withHitchFileProtocol() {
43
- const sanitize = defaultRehypePlugins.sanitize;
44
- if (!Array.isArray(sanitize)) throw new Error("streamdown's default sanitize plugin is no longer [plugin, schema].");
45
- const [plugin, schema] = sanitize;
46
- if (!Array.isArray(schema.protocols?.src)) throw new Error("streamdown's sanitize schema no longer lists src protocols.");
47
- return Object.values({
48
- ...defaultRehypePlugins,
49
- sanitize: [plugin, {
50
- ...schema,
51
- protocols: {
52
- ...schema.protocols,
53
- src: [...schema.protocols.src, "hitch-file"]
54
- }
55
- }]
56
- });
57
- }
58
- const rehypePlugins = withHitchFileProtocol();
59
- function HitchImage({ src, alt, files, node: _node, ...props }) {
60
- const id = typeof src === "string" && src.startsWith("hitch-file://") ? src.slice(13) : void 0;
61
- const [state, setState] = useState({ id });
62
- useEffect(() => {
63
- if (id === void 0 || files === void 0) return;
64
- let active = true;
65
- cachedDownloadUrl(files, id).then((url) => {
66
- if (active) setState({
67
- id,
68
- url
69
- });
70
- }, (error) => {
71
- invalidateDownloadUrl(id);
72
- console.error(`Failed to download Hitch file "${id}".`, error);
73
- if (active) setState({
74
- id,
75
- error
76
- });
77
- });
78
- return () => {
79
- active = false;
80
- };
81
- }, [files, id]);
82
- if (id === void 0) return /* @__PURE__ */ jsx("img", {
83
- src,
84
- alt,
85
- ...props
86
- });
87
- if (files === void 0 || state.error !== void 0) return /* @__PURE__ */ jsx("span", {
88
- className: "text-muted-foreground text-sm",
89
- children: alt ?? "Image unavailable"
90
- });
91
- if (state.id !== id || state.url === void 0) return /* @__PURE__ */ jsx("span", {
92
- className: "inline-block min-h-16 min-w-32 animate-pulse rounded-md bg-muted p-3 text-muted-foreground text-sm",
93
- role: "img",
94
- "aria-label": alt ?? "Loading image",
95
- children: alt ?? "Loading image"
96
- });
97
- return /* @__PURE__ */ jsx("img", {
98
- src: state.url,
99
- alt,
100
- ...props,
101
- onError: () => {
102
- invalidateDownloadUrl(id);
103
- setState({
104
- id,
105
- error: /* @__PURE__ */ new Error("image failed to load")
106
- });
107
- }
108
- });
109
- }
110
- function Markdown({ children, files, className }) {
111
- const components = useMemo(() => ({ img: (props) => /* @__PURE__ */ jsx(HitchImage, {
112
- ...props,
113
- files
114
- }) }), [files]);
115
- return /* @__PURE__ */ jsx(Streamdown, {
116
- className,
117
- components,
118
- rehypePlugins,
119
- urlTransform: (url, key, node) => url.startsWith("hitch-file://") ? url : defaultUrlTransform(url, key, node),
120
- children
121
- });
122
- }
123
- //#endregion
124
- //#region src/react/markdown-editor-extensions.tsx
125
- function sanitizeAltText(text) {
126
- return text.replaceAll(/[[\]()\\]/g, "").replaceAll(/\s+/g, " ");
127
- }
128
- function editorMarkdown(editor) {
129
- return editor.getMarkdown().trimEnd();
130
- }
131
- function tableHasBlockCells(node) {
132
- return (node.content ?? []).some((row) => (row.content ?? []).some((cell) => cell.content?.length !== 1 || cell.content[0]?.type !== "paragraph"));
133
- }
134
- function hitchImageNode(files) {
135
- return function HitchImageNode({ node, selected, editor, deleteNode }) {
136
- const src = String(node.attrs.src);
137
- const alt = typeof node.attrs.alt === "string" ? node.attrs.alt : void 0;
138
- const id = src.startsWith("hitch-file://") ? src.slice(13) : void 0;
139
- const [state, setState] = useState({ id });
140
- useEffect(() => {
141
- if (id === void 0 || files === void 0) return;
142
- let active = true;
143
- cachedDownloadUrl(files, id).then((url) => {
144
- if (active) setState({
145
- id,
146
- url
147
- });
148
- }, (error) => {
149
- invalidateDownloadUrl(id);
150
- console.error(`Failed to download Hitch file "${id}".`, error);
151
- if (active) setState({
152
- id,
153
- error
154
- });
155
- });
156
- return () => {
157
- active = false;
158
- };
159
- }, [files, id]);
160
- const content = id === void 0 ? /* @__PURE__ */ jsx("img", {
161
- src,
162
- alt,
163
- className: "max-w-full rounded-lg",
164
- "data-drag-handle": true
165
- }) : files === void 0 || state.error !== void 0 ? /* @__PURE__ */ jsx("span", {
166
- className: "text-muted-foreground text-sm",
167
- children: alt ?? "Image unavailable"
168
- }) : state.id !== id || state.url === void 0 ? /* @__PURE__ */ jsx("span", {
169
- className: "inline-block min-h-16 min-w-32 animate-pulse rounded-md bg-muted p-3 text-muted-foreground text-sm",
170
- role: "img",
171
- "aria-label": alt ?? "Loading image",
172
- children: alt ?? "Loading image"
173
- }) : /* @__PURE__ */ jsx("img", {
174
- src: state.url,
175
- alt,
176
- className: "max-w-full rounded-lg",
177
- "data-drag-handle": true,
178
- onError: () => {
179
- invalidateDownloadUrl(id);
180
- setState({
181
- id,
182
- error: /* @__PURE__ */ new Error("image failed to load")
183
- });
184
- }
185
- });
186
- return /* @__PURE__ */ jsxs(NodeViewWrapper, {
187
- as: "span",
188
- className: twMerge("relative inline-block max-w-full rounded-lg", selected && "in-[.ProseMirror[contenteditable=true]:focus-within]:ring-2 in-[.ProseMirror[contenteditable=true]:focus-within]:ring-ring"),
189
- children: [content, selected && /* @__PURE__ */ jsx("button", {
190
- type: "button",
191
- contentEditable: false,
192
- "aria-label": "Remove image",
193
- className: "absolute top-1.5 right-1.5 hidden size-6 in-[.ProseMirror[contenteditable=true]:focus-within]:inline-flex items-center justify-center rounded-full bg-background/90 text-foreground shadow-sm outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/30 [&_svg]:size-3.5",
194
- onClick: () => {
195
- deleteNode();
196
- editor.commands.focus();
197
- },
198
- children: /* @__PURE__ */ jsx(X, {})
199
- })]
200
- });
201
- };
202
- }
203
- function markdownEditorExtensions(files, placeholder = "") {
204
- const extensions = [];
205
- extensions.push(StarterKit.configure({ link: { openOnClick: false } }), Table$1.extend({ renderMarkdown(node, helpers) {
206
- if (!tableHasBlockCells(node)) return renderTableToMarkdown(node, helpers);
207
- return `\n${generateHTML({
208
- type: "doc",
209
- content: [node]
210
- }, extensions)}\n`;
211
- } }), TableRow, TableHeader, TableCell, TaskList, TaskItem.configure({ nested: true }), Image.extend({ addNodeView() {
212
- return ReactNodeViewRenderer(hitchImageNode(files));
213
- } }), Markdown$1, Placeholder.configure({
214
- placeholder,
215
- showOnlyWhenEditable: false
216
- }));
217
- return extensions;
218
- }
219
- //#endregion
220
- //#region src/react/markdown-editor.tsx
221
- const buttonClassName = "inline-flex size-7 shrink-0 items-center justify-center rounded-2xl border border-transparent text-muted-foreground outline-none transition-all select-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
222
- const editorClassName = "min-h-32 w-full px-2.5 py-2 text-base md:text-sm outline-none whitespace-pre-wrap space-y-4 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_h1]:mt-6 [&_h1]:mb-2 [&_h1]:font-semibold [&_h1]:text-3xl [&_h2]:mt-6 [&_h2]:mb-2 [&_h2]:font-semibold [&_h2]:text-2xl [&_h3]:mt-6 [&_h3]:mb-2 [&_h3]:font-semibold [&_h3]:text-xl [&_h4]:mt-6 [&_h4]:mb-2 [&_h4]:font-semibold [&_h4]:text-lg [&_h5]:mt-6 [&_h5]:mb-2 [&_h5]:font-semibold [&_h5]:text-base [&_h6]:mt-6 [&_h6]:mb-2 [&_h6]:font-semibold [&_h6]:text-sm [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_blockquote]:my-4 [&_blockquote]:border-l-4 [&_blockquote]:border-muted-foreground/30 [&_blockquote]:pl-4 [&_blockquote]:text-muted-foreground [&_blockquote]:italic [&_code]:rounded [&_code]:bg-muted [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-sm [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:border [&_pre]:border-border [&_pre]:bg-background [&_pre]:p-4 [&_pre]:text-sm [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_a]:font-medium [&_a]:text-primary [&_a]:underline [&_a]:wrap-anywhere [&_hr]:my-4 [&_hr]:border-border [&_table]:my-4 [&_table]:w-full [&_table]:border-collapse [&_th]:border [&_th]:border-border [&_th]:px-4 [&_th]:py-2 [&_th]:text-left [&_th]:font-semibold [&_th]:text-sm [&_td]:border [&_td]:border-border [&_td]:px-4 [&_td]:py-2 [&_td]:text-sm [&_ul[data-type=taskList]]:list-none [&_ul[data-type=taskList]]:pl-0 [&_li[data-type=taskItem]]:flex [&_li[data-type=taskItem]]:items-start [&_li[data-type=taskItem]]:gap-2 [&_li[data-type=taskItem]>div]:flex-1 [&_p.is-editor-empty:first-child]:before:content-[attr(data-placeholder)] [&_p.is-editor-empty:first-child]:before:float-left [&_p.is-editor-empty:first-child]:before:h-0 [&_p.is-editor-empty:first-child]:before:pointer-events-none [&_p.is-editor-empty:first-child]:before:text-muted-foreground";
223
- function findImage(view, src) {
224
- let found;
225
- view.state.doc.descendants((node, pos) => {
226
- if (found !== void 0) return false;
227
- if (node.type.name === "image" && node.attrs.src === src) found = {
228
- pos,
229
- size: node.nodeSize
230
- };
231
- return found === void 0;
232
- });
233
- return found;
234
- }
235
- function MarkdownEditor({ value, onChange, files, id, placeholder, required, minLength, maxLength, disabled, autoFocus, className, onUploadError }) {
236
- const validationRef = useRef(null);
237
- const lastEmittedRef = useRef(value);
238
- const filesRef = useRef(files);
239
- const uploadErrorRef = useRef(onUploadError);
240
- const pendingUploads = useRef(0);
241
- useEffect(() => {
242
- filesRef.current = files;
243
- uploadErrorRef.current = onUploadError;
244
- });
245
- const hasFiles = files !== void 0;
246
- const stableFiles = useMemo(() => {
247
- if (!hasFiles) return void 0;
248
- const current = () => {
249
- const filesNow = filesRef.current;
250
- if (filesNow === void 0) throw new Error("files was removed while the editor used it.");
251
- return filesNow;
252
- };
253
- return {
254
- upload: (file) => current().upload(file),
255
- download: (fileId) => current().download(fileId)
256
- };
257
- }, [hasFiles]);
258
- const extensions = useMemo(() => markdownEditorExtensions(stableFiles, placeholder), [stableFiles, placeholder]);
259
- const applyValidity = () => {
260
- validationRef.current?.setCustomValidity(pendingUploads.current > 0 ? "Wait for the image upload to finish." : minLength !== void 0 && value.length > 0 && value.length < minLength ? `Use at least ${minLength} characters.` : maxLength !== void 0 && value.length > maxLength ? `Use no more than ${maxLength} characters.` : "");
261
- };
262
- useEffect(applyValidity);
263
- const markUploadPending = (delta) => {
264
- pendingUploads.current += delta;
265
- applyValidity();
266
- };
267
- const editor = useEditor({
268
- extensions,
269
- content: value,
270
- contentType: "markdown",
271
- editable: !disabled,
272
- autofocus: autoFocus ? "end" : false,
273
- editorProps: {
274
- attributes: { class: editorClassName },
275
- handlePaste: (view, event) => {
276
- const imageFiles = Array.from(event.clipboardData?.files ?? []).filter((file) => file.type.startsWith("image/"));
277
- if (filesRef.current === void 0 || imageFiles.length === 0) return false;
278
- uploadImages(view, imageFiles, view.state.selection.from);
279
- return true;
280
- },
281
- handleDrop: (view, event) => {
282
- const imageFiles = Array.from(event.dataTransfer?.files ?? []).filter((file) => file.type.startsWith("image/"));
283
- if (filesRef.current === void 0 || imageFiles.length === 0) return false;
284
- const position = view.posAtCoords({
285
- left: event.clientX,
286
- top: event.clientY
287
- })?.pos;
288
- if (position === void 0) return false;
289
- uploadImages(view, imageFiles, position);
290
- return true;
291
- }
292
- },
293
- onCreate: ({ editor: createdEditor }) => {
294
- if (autoFocus) createdEditor.commands.focus("end");
295
- else if (createdEditor.state.selection instanceof NodeSelection) {
296
- const { state, view } = createdEditor;
297
- view.dispatch(state.tr.setSelection(new GapCursor(state.doc.resolve(0))));
298
- }
299
- },
300
- onUpdate: ({ editor: updatedEditor, transaction }) => {
301
- if (!transaction.docChanged) return;
302
- const markdown = editorMarkdown(updatedEditor);
303
- if (markdown === lastEmittedRef.current) return;
304
- lastEmittedRef.current = markdown;
305
- onChange(markdown);
306
- }
307
- }, [extensions]);
308
- async function uploadImages(view, imageFiles, position) {
309
- const uploadFiles = filesRef.current;
310
- if (uploadFiles === void 0) return;
311
- markUploadPending(1);
312
- try {
313
- const pending = imageFiles.map((file) => ({
314
- file,
315
- url: URL.createObjectURL(file)
316
- }));
317
- const transaction = view.state.tr;
318
- let insertPosition = position;
319
- for (const { file, url } of pending) {
320
- const node = view.state.schema.nodes.image.create({
321
- src: url,
322
- alt: sanitizeAltText(file.name)
323
- });
324
- transaction.insert(insertPosition, node);
325
- insertPosition += node.nodeSize;
326
- }
327
- view.dispatch(transaction);
328
- for (const { file, url } of pending) try {
329
- const uploaded = await uploadFiles.upload(file);
330
- seedDownloadUrl(uploaded.id, uploaded.downloadUrl);
331
- const image = findImage(view, url);
332
- if (image !== void 0) view.dispatch(view.state.tr.setNodeMarkup(image.pos, void 0, {
333
- ...view.state.doc.nodeAt(image.pos)?.attrs,
334
- src: `${HITCH_FILE_PREFIX}${uploaded.id}`
335
- }));
336
- } catch (error) {
337
- const image = findImage(view, url);
338
- if (image !== void 0) view.dispatch(view.state.tr.delete(image.pos, image.pos + image.size));
339
- if (uploadErrorRef.current !== void 0) uploadErrorRef.current(error, file);
340
- else console.error(`Upload of "${file.name}" failed.`, error);
341
- } finally {
342
- URL.revokeObjectURL(url);
343
- }
344
- } finally {
345
- markUploadPending(-1);
346
- }
347
- }
348
- useEffect(() => {
349
- if (value !== lastEmittedRef.current && value !== editorMarkdown(editor)) editor.commands.setContent(value, {
350
- contentType: "markdown",
351
- emitUpdate: false
352
- });
353
- lastEmittedRef.current = value;
354
- }, [editor, value]);
355
- useEffect(() => editor.setEditable(!disabled, false), [disabled, editor]);
356
- const active = useEditorState({
357
- editor,
358
- selector: ({ editor: current }) => ({
359
- heading: current.isActive("heading"),
360
- bold: current.isActive("bold"),
361
- italic: current.isActive("italic"),
362
- strike: current.isActive("strike"),
363
- code: current.isActive("code"),
364
- link: current.isActive("link"),
365
- bulletList: current.isActive("bulletList"),
366
- orderedList: current.isActive("orderedList"),
367
- taskList: current.isActive("taskList"),
368
- blockquote: current.isActive("blockquote"),
369
- table: current.isActive("table")
370
- })
371
- });
372
- const cycleHeading = () => {
373
- const level = [
374
- 1,
375
- 2,
376
- 3
377
- ].find((item) => editor.isActive("heading", { level: item }));
378
- if (level === void 0) editor.chain().focus().toggleHeading({ level: 1 }).run();
379
- else if (level < 3) editor.chain().focus().toggleHeading({ level: level + 1 }).run();
380
- else editor.chain().focus().setParagraph().run();
381
- };
382
- const toggleLink = () => {
383
- if (editor.isActive("link")) return void editor.chain().focus().unsetLink().run();
384
- const url = window.prompt("Link URL");
385
- if (!url) return;
386
- if (editor.state.selection.empty) editor.chain().focus().insertContent({
387
- type: "text",
388
- text: url,
389
- marks: [{
390
- type: "link",
391
- attrs: { href: url }
392
- }]
393
- }).run();
394
- else editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
395
- };
396
- const items = [
397
- {
398
- title: "Heading",
399
- active: active.heading,
400
- icon: Heading,
401
- command: cycleHeading
402
- },
403
- {
404
- title: "Bold",
405
- active: active.bold,
406
- icon: Bold,
407
- command: () => editor.chain().focus().toggleBold().run()
408
- },
409
- {
410
- title: "Italic",
411
- active: active.italic,
412
- icon: Italic,
413
- command: () => editor.chain().focus().toggleItalic().run()
414
- },
415
- {
416
- title: "Strikethrough",
417
- active: active.strike,
418
- icon: Strikethrough,
419
- command: () => editor.chain().focus().toggleStrike().run()
420
- },
421
- {
422
- title: "Inline code",
423
- active: active.code,
424
- icon: Code,
425
- command: () => editor.chain().focus().toggleCode().run()
426
- },
427
- {
428
- title: "Link",
429
- active: active.link,
430
- icon: Link,
431
- command: toggleLink
432
- },
433
- {
434
- title: "Bulleted list",
435
- active: active.bulletList,
436
- icon: List,
437
- command: () => editor.chain().focus().toggleBulletList().run()
438
- },
439
- {
440
- title: "Numbered list",
441
- active: active.orderedList,
442
- icon: ListOrdered,
443
- command: () => editor.chain().focus().toggleOrderedList().run()
444
- },
445
- {
446
- title: "Task list",
447
- active: active.taskList,
448
- icon: ListTodo,
449
- command: () => editor.chain().focus().toggleTaskList().run()
450
- },
451
- {
452
- title: "Quote",
453
- active: active.blockquote,
454
- icon: Quote,
455
- command: () => editor.chain().focus().toggleBlockquote().run()
456
- },
457
- {
458
- title: "Table",
459
- active: active.table,
460
- icon: Table,
461
- command: () => editor.chain().focus().insertTable({
462
- rows: 3,
463
- cols: 3,
464
- withHeaderRow: true
465
- }).run()
466
- }
467
- ];
468
- const tableItems = [
469
- {
470
- title: "Add row below",
471
- icon: BetweenHorizontalEnd,
472
- command: () => editor.chain().focus().addRowAfter().run()
473
- },
474
- {
475
- title: "Add column right",
476
- icon: BetweenVerticalEnd,
477
- command: () => editor.chain().focus().addColumnAfter().run()
478
- },
479
- {
480
- title: "Delete row",
481
- icon: ListMinus,
482
- command: () => editor.chain().focus().deleteRow().run()
483
- },
484
- {
485
- title: "Delete column",
486
- icon: ListMinus,
487
- iconClassName: "rotate-90",
488
- command: () => editor.chain().focus().deleteColumn().run()
489
- },
490
- {
491
- title: "Delete table",
492
- icon: Trash2,
493
- command: () => editor.chain().focus().deleteTable().run()
494
- }
495
- ];
496
- return /* @__PURE__ */ jsxs("div", {
497
- className: twMerge("flex flex-col overflow-hidden rounded-2xl border border-input bg-background", className),
498
- children: [
499
- /* @__PURE__ */ jsx(EditorContent, { editor }),
500
- /* @__PURE__ */ jsxs(Toolbar, {
501
- className: "order-first flex flex-wrap gap-1 border-b border-input p-1",
502
- "aria-label": "Markdown formatting",
503
- children: [items.map(({ title, active: isActive, icon: Icon, command }) => /* @__PURE__ */ jsx(Button, {
504
- className: twMerge(buttonClassName, isActive && "bg-muted text-foreground"),
505
- "aria-label": title,
506
- isDisabled: disabled,
507
- onPress: command,
508
- children: /* @__PURE__ */ jsx(Icon, {})
509
- }, title)), active.table && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
510
- "aria-hidden": true,
511
- className: "mx-1 w-px self-stretch bg-border"
512
- }), tableItems.map(({ title, icon: Icon, iconClassName, command }) => /* @__PURE__ */ jsx(Button, {
513
- className: buttonClassName,
514
- "aria-label": title,
515
- isDisabled: disabled,
516
- onPress: command,
517
- children: /* @__PURE__ */ jsx(Icon, { className: iconClassName })
518
- }, title))] })]
519
- }),
520
- /* @__PURE__ */ jsx("textarea", {
521
- ref: validationRef,
522
- id,
523
- className: "sr-only",
524
- tabIndex: -1,
525
- value,
526
- required,
527
- disabled,
528
- onChange: () => void 0,
529
- onFocus: () => editor.commands.focus()
530
- })
531
- ]
532
- });
533
- }
534
- //#endregion
1
+ import { t as Markdown } from "./markdown-CwlqzBtP.js";
2
+ import { t as MarkdownEditor } from "./markdown-editor-C5mLHGqu.js";
535
3
  export { Markdown, MarkdownEditor };
@@ -1,4 +1,4 @@
1
- import { t as loadAppletConfig } from "./load-config-BeQZ2yOa.js";
1
+ import { t as loadAppletConfig } from "./load-config-Dkr2VxZN.js";
2
2
  import { t as question } from "./prompt-ChS-grYO.js";
3
3
  import { RPCLink } from "@orpc/client/fetch";
4
4
  import { readFile } from "node:fs/promises";
package/dist/server.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { a as createWorkflow, i as WorkflowStep, n as WorkflowDefinition, r as WorkflowDuration } from "./workflow-DurM6Fwx.js";
2
- import { _ as RegisteredWorkflows, f as RegisteredContract, g as RegisteredVariables, p as RegisteredManifest } from "./manifest-ARAy2HP7.js";
3
- import { t as NarrowContract } from "./contract-CZdT22tB.js";
2
+ import { l as RegisteredContract, m as RegisteredWorkflows, p as RegisteredVariables, u as RegisteredManifest } from "./manifest-BSUtHbu-.js";
3
+ import { t as NarrowContract } from "./contract-D9wEvxGI.js";
4
4
  import { t as WithBatchRecorder } from "./batch-Qa4B4-Yp.js";
5
- import { o as WithFilesUpload } from "./upload-DKZzz5kW.js";
5
+ import { o as WithFilesUpload } from "./upload-D_kkmne_.js";
6
6
  import { ContractRouterClient } from "@orpc/contract";
7
7
  //#region src/server/workflows-client.d.ts
8
8
  type WorkflowRunStatus<Result> = {