ocean-brain 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -0
- package/dist/mcp.js +230 -291
- package/package.json +5 -5
- package/server/client/dist/assets/ArrowRight.es-g2YZTklZ.js +1 -0
- package/server/client/dist/assets/Calendar-BP6HTuSn.js +25 -0
- package/server/client/dist/assets/Callout-B_IPSF_5.js +1 -0
- package/server/client/dist/assets/Copy.es-CNxe4ujr.js +1 -0
- package/server/client/dist/assets/Graph-D9GeO71k.js +1 -0
- package/server/client/dist/assets/Graph-Xha3fwhp.js +46 -0
- package/server/client/dist/assets/Image-BLEjLUqd.js +1 -0
- package/server/client/dist/assets/Image.es-DnON8cv2.js +1 -0
- package/server/client/dist/assets/Note-DjrCYtat.js +24 -0
- package/server/client/dist/assets/NotePropertiesPanel-2DgXEM4B.js +2 -0
- package/server/client/dist/assets/Plus.es-CQ8wn2is.js +1 -0
- package/server/client/dist/assets/Reminders-B4l3KdlK.js +1 -0
- package/server/client/dist/assets/Search-BN5sf7bE.js +1 -0
- package/server/client/dist/assets/SurfaceCard-BZm73nyS.js +1 -0
- package/server/client/dist/assets/Tag-oSnmViVp.js +1 -0
- package/server/client/dist/assets/TagNotes-BDTCcJcL.js +1 -0
- package/server/client/dist/assets/Trash.es-0aPpA-3S.js +1 -0
- package/server/client/dist/assets/ViewNotes-CiZtGJNE.js +1 -0
- package/server/client/dist/assets/{ViewSectionDialog-brTrsF6G.js → ViewSectionDialog-Ctl_694Y.js} +17 -17
- package/server/client/dist/assets/Views-D-zlatYD.js +1 -0
- package/server/client/dist/assets/app-DmqIOMWF.css +1 -0
- package/server/client/dist/assets/app-cTRcKMGc.js +26 -0
- package/server/client/dist/assets/floating-ui.react-dom-wWLZ1CdM.js +1 -0
- package/server/client/dist/assets/{image.api-CYsjXiMr.js → image.api-CVuuvTBk.js} +1 -1
- package/server/client/dist/assets/index-DKJChPr4.js +1 -0
- package/server/client/dist/assets/manage-image-BZjaxp-f.js +1 -0
- package/server/client/dist/assets/manage-image-detail-DPv0FQ2m.js +1 -0
- package/server/client/dist/assets/{mcp-Dd98N9Hq.js → mcp-CT_9IV2c.js} +2 -2
- package/server/client/dist/assets/mcp-admin-adapter-xAuyZc_M.js +1 -0
- package/server/client/dist/assets/note-core-Buwzyxi7.js +13 -0
- package/server/client/dist/assets/note-runtime-CPDVOFEo.js +168 -0
- package/server/client/dist/assets/note-ui-CHI-tzj-.js +2 -0
- package/server/client/dist/assets/{index-DPI6YoDt.css → note-ui-DL8owV-U.css} +1 -1
- package/server/client/dist/assets/note.api-D_00ZzJC.js +356 -0
- package/server/client/dist/assets/placeholder-DbdGiYGL.js +34 -0
- package/server/client/dist/assets/preload-helper-BXl3LOEh.js +1 -0
- package/server/client/dist/assets/properties-D447wsWk.js +1 -0
- package/server/client/dist/assets/route-preload.js +2 -0
- package/server/client/dist/assets/{tag.api-CwmC8crB.js → tag.api-CX0SE06J.js} +1 -1
- package/server/client/dist/assets/time-B3pt8vt4.js +9 -0
- package/server/client/dist/assets/trash-8sH7EZgc.js +1 -0
- package/server/client/dist/assets/url-BSnWpmJx.js +1 -0
- package/server/client/dist/assets/{useReminderMutate-DuVKxpBh.js → useReminderMutate-CLK1tHvT.js} +4 -4
- package/server/client/dist/index.html +10 -5
- package/server/dist/app.js +1 -1
- package/server/dist/modules/blocknote.js +262 -75
- package/server/dist/modules/error-handler.js +8 -0
- package/server/client/dist/assets/ArrowRight.es-CbA8ey6a.js +0 -1
- package/server/client/dist/assets/Calendar-CgWgr1BV.js +0 -25
- package/server/client/dist/assets/Callout-DKruIT0f.js +0 -1
- package/server/client/dist/assets/Copy.es-DFbgpaNJ.js +0 -1
- package/server/client/dist/assets/Graph-kCltGRlY.js +0 -1
- package/server/client/dist/assets/Image-7W0DZwMo.js +0 -1
- package/server/client/dist/assets/Image.es-5pXLx9TU.js +0 -1
- package/server/client/dist/assets/Note-BW6Np_5g.js +0 -20
- package/server/client/dist/assets/Plus.es-B0sg64VJ.js +0 -1
- package/server/client/dist/assets/Reminders-C10fHQcl.js +0 -1
- package/server/client/dist/assets/Search-tf2nV4v0.js +0 -1
- package/server/client/dist/assets/SurfaceCard-pydtvHfu.js +0 -1
- package/server/client/dist/assets/Tag-uCoYbISy.js +0 -1
- package/server/client/dist/assets/TagNotes-CqOcQiRw.js +0 -1
- package/server/client/dist/assets/Trash.es-w32Goxfa.js +0 -1
- package/server/client/dist/assets/ViewNotes-slPXXoOY.js +0 -1
- package/server/client/dist/assets/Views-B_wsb-XJ.js +0 -1
- package/server/client/dist/assets/graph-vendor-BAF95C0g.js +0 -46
- package/server/client/dist/assets/index-BR05aSXr.js +0 -342
- package/server/client/dist/assets/index-D83QbOcw.js +0 -1
- package/server/client/dist/assets/manage-image-BYIhWu56.js +0 -1
- package/server/client/dist/assets/manage-image-detail-6KgmQvbN.js +0 -1
- package/server/client/dist/assets/mcp-admin-adapter-DOgBsYpl.js +0 -1
- package/server/client/dist/assets/note-core-CMGUaW1v.js +0 -176
- package/server/client/dist/assets/note-vendor-Hoz9Q4-4.js +0 -54
- package/server/client/dist/assets/placeholder-siHGg9aK.js +0 -34
- package/server/client/dist/assets/properties-CyVRKgcT.js +0 -1
- package/server/client/dist/assets/trash-wojQBK9Z.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as E}from"./floating-ui.react-dom-wWLZ1CdM.js";import{u as Q,e as k,m as F,q as L,i as M,d as _}from"./time-B3pt8vt4.js";import{aa as I,ai as K,U as O,a9 as B,b1 as H,T as i,b2 as U,b3 as W,aj as w,al as Y,Z as d,au as b,ak as $,ac as l,a8 as z,aA as G,b4 as V,at as y}from"./note.api-D_00ZzJC.js";import{S as C}from"./SurfaceCard-BZm73nyS.js";import{e as Z,N as J}from"./url-BSnWpmJx.js";import"./NotePropertiesPanel-2DgXEM4B.js";import"./Plus.es-CQ8wn2is.js";const m=25,v=K(Z),S=30,R=`Deleted notes stay here for ${S} days before permanent removal`,g={title:"Permanently delete note?",description:"This note is referenced by the notes below. If you permanently delete it, those links will stay broken. Other notes will not be edited automatically.",confirmLabel:"Delete now",confirmVariant:"danger"},P=a=>M(a).format("YYYY-MM-DD HH:mm"),X=({note:a,onClose:o})=>{const s=a?.id??"",c=a?.title||"Untitled note",r=_({queryKey:i.notes.trashDetail(s),enabled:!!a,queryFn:async()=>{const h=await V(s);if(h.type==="error")throw h;if(!h.trashedNote)throw new Error("Trashed note not found");return h.trashedNote}}),f=r.data?.contentAsMarkdown.trim()??"";return e.jsxs(y,{isOpen:!!a,onClose:o,variant:"inspect",children:[e.jsx(y.Header,{title:c,onClose:o}),e.jsx(y.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[a&&e.jsxs(d,{as:"p",variant:"meta",tone:"secondary",children:["Deleted ",P(a.deletedAt)]}),r.isLoading&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",children:"Loading deleted note content..."}),r.isError&&e.jsx(d,{as:"p",variant:"meta",tone:"error",children:"Failed to load deleted note content."}),!r.isLoading&&!r.isError&&f&&e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:f}),!r.isLoading&&!r.isError&&!f&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this deleted note."})]})}),e.jsx(y.Footer,{children:e.jsx(b,{variant:"ghost",size:"sm",onClick:o,children:"Close"})})]})},ee=()=>e.jsx(w,{title:"Trash",variant:"default",heading:e.jsx(l,{width:118,height:24,className:"rounded-full"}),description:e.jsx(l,{width:352,height:16,className:"rounded-full"}),children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:3},(a,o)=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx(l,{width:"40%",height:18,className:"rounded-full"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:168,height:14,className:"rounded-full"}),e.jsx(l,{width:176,height:14,className:"rounded-full"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:56,height:24,className:"rounded-full"}),e.jsx(l,{width:72,height:24,className:"rounded-full"})]})]}),e.jsx(l,{width:92,height:32,className:"rounded-[12px]"})]})},o))})}),te=()=>{const{page:a}=v.useSearch(),o=v.useNavigate(),s=O(),c=z(),r=Q(),[f,h]=E.useState(null),[x,j]=E.useState(null),{data:u}=B({queryKey:i.notes.trash({limit:m,offset:(a-1)*m}),queryFn:async()=>{const t=await H({limit:m,offset:(a-1)*m});if(t.type==="error")throw t;return t.trashedNotes}}),N=k({mutationFn:U,onSuccess:async t=>{if(t.type==="error")throw t;await Promise.all([s.invalidateQueries({queryKey:i.notes.all(),exact:!1}),s.invalidateQueries({queryKey:i.tags.all(),exact:!1}),s.invalidateQueries({queryKey:i.reminders.all(),exact:!1}),s.invalidateQueries({queryKey:i.images.all(),exact:!1}),s.invalidateQueries({queryKey:i.calendar.all(),exact:!1})]),c("The note has been restored."),o({to:J,params:{id:t.restoreTrashedNote.id}})},onError:()=>{c("Failed to restore the note.")}}),p=k({mutationFn:W,onSuccess:async t=>{if(t.type==="error")throw t;await s.invalidateQueries({queryKey:i.notes.trashAll(),exact:!1}),c("The note has been permanently deleted.")},onError:()=>{c("Failed to permanently delete the note.")}}),D=()=>{if(!x)return;const{id:t}=x;j(null),p.mutate(t)},A=async t=>{const n=await G(t);if(n.type==="error"){c("Failed to check linked notes before permanently deleting this note.");return}if(s.setQueryData(i.notes.backReferences(t),n.backReferences),n.backReferences.length>0){j({id:t,backReferences:n.backReferences});return}await r("Permanently delete this note? This cannot be undone.")&&p.mutate(t)},T=u.totalCount>0?`Trash (${u.totalCount})`:void 0,q=u.notes.find(t=>t.id===f)??null;return u.notes.length===0?e.jsx(w,{title:"Trash",variant:"default",heading:T,description:R,children:e.jsx(Y,{title:"Trash is empty",description:`Delete a note and you can restore it here for ${S} days before permanent removal`})}):e.jsxs(w,{title:"Trash",variant:"default",heading:T,description:R,children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid gap-3",children:u.notes.map(t=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[e.jsx(d,{as:"h2",variant:"body",weight:"medium",className:"min-w-0 flex-1 break-words leading-[1.25]",children:t.title||"Untitled note"}),t.pinned&&e.jsx("span",{title:"Pinned",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center text-fg-tertiary",children:e.jsx(F,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsxs(d,{as:"div",variant:"meta",weight:"medium",tone:"secondary",children:["Deleted ",P(t.deletedAt)]})}),t.tagNames.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.tagNames.map(n=>e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"rounded-full border border-border-subtle bg-hover-subtle px-2 py-0.5",children:n},`${t.id}-${n}`))}),t.contentPreview&&e.jsx("div",{className:"mt-3 rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-3 whitespace-pre-wrap break-words",children:t.contentPreview})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(b,{variant:"subtle",size:"sm",onClick:()=>h(t.id),children:"View content"}),e.jsx(b,{variant:"subtle",size:"sm",isLoading:N.isPending&&N.variables===t.id,onClick:()=>N.mutate(t.id),children:"Restore"}),e.jsx(b,{variant:"soft-danger",size:"sm",isLoading:p.isPending&&p.variables===t.id,onClick:()=>A(t.id),children:"Delete now"})]})]})},t.id))}),u.totalCount>m&&e.jsx($,{page:a,last:Math.ceil(u.totalCount/m),onChange:t=>{o({search:n=>({...n,page:t})})}})]}),e.jsx(X,{note:q,onClose:()=>h(null)}),e.jsx(L,{isOpen:!!x,title:g.title,description:g.description,references:x?.backReferences??[],confirmLabel:g.confirmLabel,confirmVariant:g.confirmVariant,onClose:()=>j(null),onConfirm:D})]})},de=()=>{const{page:a}=v.useSearch();return e.jsx(I,{fallback:e.jsx(ee,{}),errorTitle:"Failed to load trash",errorDescription:"Retry loading deleted notes",resetKeys:[a],children:e.jsx(te,{})})};export{de as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const E={HOME_ROUTE:"/",VIEWS_ROUTE:"/views",VIEW_NOTES_ROUTE:"/views/notes",CALENDAR_ROUTE:"/calendar",REMINDERS_ROUTE:"/reminders",GRAPH_ROUTE:"/graph",SEARCH_ROUTE:"/search",TAG_ROUTE:"/tag",NOTE_ROUTE:"/$id",TAG_NOTES_ROUTE:"/tag/$id",SETTINGS_ROUTE:"/setting",SETTINGS_MCP_ROUTE:"/setting/mcp",SETTINGS_TRASH_ROUTE:"/setting/trash",SETTINGS_MANAGE_IMAGE_ROUTE:"/setting/manage-image",SETTINGS_MANAGE_IMAGE_DETAIL_ROUTE:"/setting/manage-image/$id",SETTINGS_PLACEHOLDER_ROUTE:"/setting/placeholder",SETTINGS_PROPERTIES_ROUTE:"/setting/properties"},{HOME_ROUTE:T,VIEWS_ROUTE:_,VIEW_NOTES_ROUTE:R,CALENDAR_ROUTE:O,REMINDERS_ROUTE:S,GRAPH_ROUTE:U,SEARCH_ROUTE:s,TAG_ROUTE:a,NOTE_ROUTE:A,TAG_NOTES_ROUTE:G,SETTINGS_ROUTE:N,SETTINGS_MCP_ROUTE:I,SETTINGS_TRASH_ROUTE:e,SETTINGS_MANAGE_IMAGE_ROUTE:t,SETTINGS_MANAGE_IMAGE_DETAIL_ROUTE:i,SETTINGS_PLACEHOLDER_ROUTE:g,SETTINGS_PROPERTIES_ROUTE:n}=E;export{E as A,O as C,U as G,T as H,A as N,S as R,s as S,a as T,_ as V,N as a,G as b,R as c,I as d,e,t as f,i as g,g as h,n as i};
|
package/server/client/dist/assets/{useReminderMutate-DuVKxpBh.js → useReminderMutate-CLK1tHvT.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as y}from"./
|
|
1
|
+
import{j as y,r as l}from"./floating-ui.react-dom-wWLZ1CdM.js";import{a6 as u,a9 as f,T as n,U as R,a8 as $}from"./note.api-D_00ZzJC.js";const g=(e={})=>({limit:e.limit??10,offset:e.offset??0}),D=async(e,t)=>u(`
|
|
2
2
|
query FetchNoteReminders($noteId: ID!, $pagination: PaginationInput) {
|
|
3
3
|
noteReminders(noteId: $noteId, pagination: $pagination) {
|
|
4
4
|
totalCount
|
|
@@ -34,7 +34,7 @@ import{j as y}from"./note-vendor-Hoz9Q4-4.js";import{h as u,a5 as f,q as n,k as
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
`,{pagination:g(e)}),
|
|
37
|
+
`,{pagination:g(e)}),I=async e=>{const{noteId:t,reminderDate:a,priority:o="medium",content:i}=e;return u(`
|
|
38
38
|
mutation CreateReminder($noteId: ID!, $reminderDate: String!, $priority: ReminderPriority, $content: String) {
|
|
39
39
|
createReminder(
|
|
40
40
|
noteId: $noteId,
|
|
@@ -51,7 +51,7 @@ import{j as y}from"./note-vendor-Hoz9Q4-4.js";import{h as u,a5 as f,q as n,k as
|
|
|
51
51
|
updatedAt
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
`,{noteId:t,reminderDate:a.toISOString(),priority:o,content:i})},
|
|
54
|
+
`,{noteId:t,reminderDate:a.toISOString(),priority:o,content:i})},q=async({id:e,reminderDate:t,completed:a,priority:o,content:i})=>{const r={id:e};return t&&(r.reminderDate=t.toISOString()),a!==void 0&&(r.completed=a),o&&(r.priority=o),i!==void 0&&(r.content=i),u(`
|
|
55
55
|
mutation UpdateReminder(
|
|
56
56
|
$id: ID!,
|
|
57
57
|
$reminderDate: String,
|
|
@@ -79,4 +79,4 @@ import{j as y}from"./note-vendor-Hoz9Q4-4.js";import{h as u,a5 as f,q as n,k as
|
|
|
79
79
|
mutation DeleteReminder($id: ID!) {
|
|
80
80
|
deleteReminder(id: $id)
|
|
81
81
|
}
|
|
82
|
-
`,{id:e});function
|
|
82
|
+
`,{id:e});function K({noteId:e,searchParams:t,render:a}){const{data:o}=f({queryKey:e?n.reminders.note(e,t):n.reminders.upcoming(t),queryFn:async()=>{if(e){const r=await D(e,t);if(r.type==="error")throw r;return r.noteReminders}const i=await A(t);if(i.type==="error")throw i;return i.upcomingReminders}});return y.jsx(y.Fragment,{children:a(o)})}function P(){const e=$(),t=R(),a=l.useCallback(async(r,m,d="medium",s,c)=>{const p=await I({noteId:r,reminderDate:m,priority:d,content:c});if(p.type==="error"){e(p.errors[0].message);return}await Promise.all([t.invalidateQueries({queryKey:n.reminders.noteAllPages(r),exact:!1}),t.invalidateQueries({queryKey:n.reminders.upcomingAllPages(),exact:!1}),t.invalidateQueries({queryKey:n.reminders.inDateRangeAll(),exact:!1})]),s&&s()},[t,e]),o=l.useCallback(async(r,m,d,s)=>{const c=await q({id:r,...d});if(c.type==="error"){e(c.errors[0].message);return}await Promise.all([t.invalidateQueries({queryKey:n.reminders.noteAllPages(m),exact:!1}),t.invalidateQueries({queryKey:n.reminders.upcomingAllPages(),exact:!1}),t.invalidateQueries({queryKey:n.reminders.inDateRangeAll(),exact:!1})]),s&&s()},[t,e]),i=l.useCallback(async(r,m,d)=>{const s=await x(r);if(s.type==="error"){e(s.errors[0].message);return}await Promise.all([t.invalidateQueries({queryKey:n.reminders.noteAllPages(m),exact:!1}),t.invalidateQueries({queryKey:n.reminders.upcomingAllPages(),exact:!1}),t.invalidateQueries({queryKey:n.reminders.inDateRangeAll(),exact:!1})]),d&&d()},[t,e]);return{onCreate:a,onUpdate:o,onDelete:i}}export{K as R,P as u};
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
|
|
4
4
|
<head>
|
|
5
|
+
<script type="module" src="/assets/route-preload.js"></script>
|
|
6
|
+
|
|
5
7
|
<meta charset="UTF-8" />
|
|
6
8
|
<link rel="icon" type="image/png" href="/icon.png" />
|
|
7
9
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
10
|
<title>Ocean Brain</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/note-
|
|
13
|
-
<link rel="
|
|
11
|
+
<script type="module" crossorigin src="/assets/app-cTRcKMGc.js"></script>
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/floating-ui.react-dom-wWLZ1CdM.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/url-BSnWpmJx.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/note.api-D_00ZzJC.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/time-B3pt8vt4.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/preload-helper-BXl3LOEh.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/Graph-D9GeO71k.js">
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/app-DmqIOMWF.css">
|
|
14
19
|
</head>
|
|
15
20
|
|
|
16
21
|
<body>
|
package/server/dist/app.js
CHANGED
|
@@ -18,7 +18,7 @@ const createAppWithMcpAuth = (authConfig, mcpAdminService) => {
|
|
|
18
18
|
process.stderr.write(`[recovery] Startup cleanup failed: ${message}
|
|
19
19
|
`);
|
|
20
20
|
});
|
|
21
|
-
app.use(logger).use(createSessionMiddleware(authConfig)).use(express.urlencoded({ extended: false })).use(express.json({ limit: "50mb" })).use("/api", createApiRouter(authConfig, mcpAdminService)).use(createAuthPagesRouter(authConfig)).use("/graphql", createGraphqlRouter(authConfig, mcpAdminService)).use(createClientRouter(authConfig)).use(createErrorHandler());
|
|
21
|
+
app.use(logger).use(createSessionMiddleware(authConfig)).use(express.urlencoded({ extended: false, inflate: false })).use(express.json({ limit: "50mb", inflate: false })).use("/api", createApiRouter(authConfig, mcpAdminService)).use(createAuthPagesRouter(authConfig)).use("/graphql", createGraphqlRouter(authConfig, mcpAdminService)).use(createClientRouter(authConfig)).use(createErrorHandler());
|
|
22
22
|
return app;
|
|
23
23
|
};
|
|
24
24
|
var app_default = createApp;
|
|
@@ -242,7 +242,10 @@ function replaceExplicitReferenceTokens(text, placeholderToReference) {
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
const MARKDOWN_ANGLE_BRACKET_TOKEN_PATTERN = /<([^<>\n]+)>/g;
|
|
245
|
-
const
|
|
245
|
+
const TILDE_RUN_PATTERN = /~+/g;
|
|
246
|
+
const NUMERIC_ENDPOINT_TOKEN_CHARACTER_PATTERN = /[\p{L}\p{M}\p{N}\p{Sc}%‰.,+\-/:°℃℉µμ·²³^]/u;
|
|
247
|
+
const NUMERIC_ENDPOINT_START_PATTERN = /^(?:[+-]?\p{Sc}?|\p{Sc}[+-]?)\p{N}/u;
|
|
248
|
+
const NUMERIC_CHARACTER_REFERENCE_PATTERN = /&#(?:x[0-9a-f]+|\d+);/giu;
|
|
246
249
|
const MARKDOWN_FENCED_CODE_PATTERN = /^ {0,3}(`{3,}|~{3,})/;
|
|
247
250
|
const ANGLE_BRACKET_PLACEHOLDER_PREFIX = "\uE000OBANGLE";
|
|
248
251
|
const ANGLE_BRACKET_PLACEHOLDER_SUFFIX = "\uE001";
|
|
@@ -285,19 +288,39 @@ function hasLiteralAngleBracketTextTokenLoss(sourceMarkdown, renderedMarkdown) {
|
|
|
285
288
|
}
|
|
286
289
|
return false;
|
|
287
290
|
}
|
|
288
|
-
function
|
|
289
|
-
|
|
291
|
+
function getNumericTildeRangeRunSignatures(markdown) {
|
|
292
|
+
const normalizedMarkdown = markdown.replace(/\\(?=~)/g, "");
|
|
293
|
+
return getNumericTildeRangeRuns(normalizedMarkdown).map((run) => {
|
|
294
|
+
const leftEndpoint = getNumericEndpointBefore(normalizedMarkdown, run.start);
|
|
295
|
+
const rightEndpoint = getNumericEndpointAfter(normalizedMarkdown, run.start + run.length);
|
|
296
|
+
return JSON.stringify([leftEndpoint, run.length, rightEndpoint]);
|
|
297
|
+
});
|
|
290
298
|
}
|
|
291
299
|
function hasNumericTildeRangeMarkers(markdown) {
|
|
292
|
-
return
|
|
300
|
+
return getNumericTildeRangeRunSignatures(markdown).length > 0;
|
|
293
301
|
}
|
|
294
302
|
function hasNumericTildeRangeMarkerLoss(sourceMarkdown, renderedMarkdown) {
|
|
295
|
-
const
|
|
296
|
-
|
|
303
|
+
const sourceRunSignatures = getNumericTildeRangeRunSignatures(sourceMarkdown);
|
|
304
|
+
if (sourceRunSignatures.length === 0) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
const renderedRunSignatures = getNumericTildeRangeRunSignatures(renderedMarkdown);
|
|
308
|
+
let renderedIndex = 0;
|
|
309
|
+
for (const sourceRunSignature of sourceRunSignatures) {
|
|
310
|
+
while (renderedIndex < renderedRunSignatures.length && renderedRunSignatures[renderedIndex] !== sourceRunSignature) {
|
|
311
|
+
renderedIndex += 1;
|
|
312
|
+
}
|
|
313
|
+
if (renderedIndex === renderedRunSignatures.length) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
renderedIndex += 1;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
297
319
|
}
|
|
298
320
|
function protectMarkdownNumericTildeRanges(markdown) {
|
|
299
321
|
const protectedLines = [];
|
|
300
322
|
const placeholderToToken = /* @__PURE__ */ new Map();
|
|
323
|
+
const createPlaceholder = createNumericTildeRangePlaceholderFactory(markdown);
|
|
301
324
|
let activeFence = null;
|
|
302
325
|
for (const line of markdown.split(/(?<=\n)/)) {
|
|
303
326
|
const { body: lineBody, lineEnding } = splitMarkdownLineEnding(line);
|
|
@@ -322,7 +345,9 @@ function protectMarkdownNumericTildeRanges(markdown) {
|
|
|
322
345
|
protectedLines.push(line);
|
|
323
346
|
continue;
|
|
324
347
|
}
|
|
325
|
-
protectedLines.push(
|
|
348
|
+
protectedLines.push(
|
|
349
|
+
`${protectMarkdownLineNumericTildeRanges(lineBody, placeholderToToken, createPlaceholder)}${lineEnding}`
|
|
350
|
+
);
|
|
326
351
|
}
|
|
327
352
|
return {
|
|
328
353
|
markdown: protectedLines.join(""),
|
|
@@ -332,6 +357,11 @@ function protectMarkdownNumericTildeRanges(markdown) {
|
|
|
332
357
|
function protectMarkdownLineEndHardBreakMarkers(markdown) {
|
|
333
358
|
const protectedLines = [];
|
|
334
359
|
const placeholderToToken = /* @__PURE__ */ new Map();
|
|
360
|
+
const createPlaceholder = createProtectedTextPlaceholderFactory(
|
|
361
|
+
markdown,
|
|
362
|
+
HARD_BREAK_PLACEHOLDER_PREFIX,
|
|
363
|
+
HARD_BREAK_PLACEHOLDER_SUFFIX
|
|
364
|
+
);
|
|
335
365
|
let activeFence = null;
|
|
336
366
|
const lines = markdown.split(/(?<=\n)/);
|
|
337
367
|
for (const [index, line] of lines.entries()) {
|
|
@@ -363,7 +393,8 @@ function protectMarkdownLineEndHardBreakMarkers(markdown) {
|
|
|
363
393
|
lineBody,
|
|
364
394
|
lineEnding,
|
|
365
395
|
isMarkdownHardBreakContinuationLine(nextLineBody),
|
|
366
|
-
placeholderToToken
|
|
396
|
+
placeholderToToken,
|
|
397
|
+
createPlaceholder
|
|
367
398
|
)}${lineEnding}`
|
|
368
399
|
);
|
|
369
400
|
}
|
|
@@ -375,6 +406,11 @@ function protectMarkdownLineEndHardBreakMarkers(markdown) {
|
|
|
375
406
|
function protectMarkdownTextAngleBrackets(markdown) {
|
|
376
407
|
const protectedLines = [];
|
|
377
408
|
const placeholderToToken = /* @__PURE__ */ new Map();
|
|
409
|
+
const createPlaceholder = createProtectedTextPlaceholderFactory(
|
|
410
|
+
markdown,
|
|
411
|
+
ANGLE_BRACKET_PLACEHOLDER_PREFIX,
|
|
412
|
+
ANGLE_BRACKET_PLACEHOLDER_SUFFIX
|
|
413
|
+
);
|
|
378
414
|
let activeFence = null;
|
|
379
415
|
for (const line of markdown.split(/(?<=\n)/)) {
|
|
380
416
|
const { body: lineBody, lineEnding } = splitMarkdownLineEnding(line);
|
|
@@ -399,7 +435,9 @@ function protectMarkdownTextAngleBrackets(markdown) {
|
|
|
399
435
|
protectedLines.push(line);
|
|
400
436
|
continue;
|
|
401
437
|
}
|
|
402
|
-
protectedLines.push(
|
|
438
|
+
protectedLines.push(
|
|
439
|
+
`${protectMarkdownLineTextAngleBrackets(lineBody, placeholderToToken, createPlaceholder)}${lineEnding}`
|
|
440
|
+
);
|
|
403
441
|
}
|
|
404
442
|
return {
|
|
405
443
|
markdown: protectedLines.join(""),
|
|
@@ -428,68 +466,69 @@ function isClosingFenceLine(line, fence) {
|
|
|
428
466
|
const escapedMarker = fence.marker === "`" ? "`" : "~";
|
|
429
467
|
return new RegExp(`^ {0,3}${escapedMarker}{${fence.length},} *$`).test(line);
|
|
430
468
|
}
|
|
431
|
-
function protectMarkdownLineTextAngleBrackets(line, placeholderToToken) {
|
|
469
|
+
function protectMarkdownLineTextAngleBrackets(line, placeholderToToken, createPlaceholder) {
|
|
432
470
|
let result = "";
|
|
433
471
|
let cursor = 0;
|
|
434
472
|
while (cursor < line.length) {
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
437
|
-
result += replaceLiteralAngleBracketTextTokens(line.slice(cursor), placeholderToToken);
|
|
438
|
-
break;
|
|
439
|
-
}
|
|
440
|
-
result += replaceLiteralAngleBracketTextTokens(line.slice(cursor, codeStart), placeholderToToken);
|
|
441
|
-
const delimiterLength = countRepeatedCharacter(line, codeStart, "`");
|
|
442
|
-
const codeEnd = line.indexOf("`".repeat(delimiterLength), codeStart + delimiterLength);
|
|
443
|
-
if (codeEnd === -1) {
|
|
444
|
-
result += replaceLiteralAngleBracketTextTokens(line.slice(codeStart), placeholderToToken);
|
|
473
|
+
const codeSpan = findNextInlineCodeSpan(line, cursor);
|
|
474
|
+
if (!codeSpan) {
|
|
475
|
+
result += replaceLiteralAngleBracketTextTokens(line.slice(cursor), placeholderToToken, createPlaceholder);
|
|
445
476
|
break;
|
|
446
477
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
478
|
+
result += replaceLiteralAngleBracketTextTokens(
|
|
479
|
+
line.slice(cursor, codeSpan.start),
|
|
480
|
+
placeholderToToken,
|
|
481
|
+
createPlaceholder
|
|
482
|
+
);
|
|
483
|
+
result += line.slice(codeSpan.start, codeSpan.end);
|
|
484
|
+
cursor = codeSpan.end;
|
|
450
485
|
}
|
|
451
486
|
return result;
|
|
452
487
|
}
|
|
453
|
-
function protectMarkdownLineNumericTildeRanges(line, placeholderToToken) {
|
|
488
|
+
function protectMarkdownLineNumericTildeRanges(line, placeholderToToken, createPlaceholder) {
|
|
454
489
|
let result = "";
|
|
455
490
|
let cursor = 0;
|
|
456
491
|
while (cursor < line.length) {
|
|
457
492
|
const protectedSpan = findNextMarkdownProtectedSpan(line, cursor);
|
|
458
493
|
if (!protectedSpan) {
|
|
459
|
-
result += replaceNumericTildeRangeMarkers(line.slice(cursor), placeholderToToken);
|
|
494
|
+
result += replaceNumericTildeRangeMarkers(line.slice(cursor), placeholderToToken, createPlaceholder);
|
|
460
495
|
break;
|
|
461
496
|
}
|
|
462
|
-
result += replaceNumericTildeRangeMarkers(
|
|
497
|
+
result += replaceNumericTildeRangeMarkers(
|
|
498
|
+
line.slice(cursor, protectedSpan.start),
|
|
499
|
+
placeholderToToken,
|
|
500
|
+
createPlaceholder
|
|
501
|
+
);
|
|
463
502
|
result += line.slice(protectedSpan.start, protectedSpan.end);
|
|
464
503
|
cursor = protectedSpan.end;
|
|
465
504
|
}
|
|
466
505
|
return result;
|
|
467
506
|
}
|
|
468
507
|
function findNextMarkdownProtectedSpan(line, cursor) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
508
|
+
return [
|
|
509
|
+
findNextInlineCodeSpan(line, cursor),
|
|
510
|
+
findNextMarkdownLinkDestinationSpan(line, cursor),
|
|
511
|
+
findNextMarkdownAngleBracketSpan(line, cursor)
|
|
512
|
+
].reduce((nextSpan, span) => {
|
|
513
|
+
if (!span || nextSpan && nextSpan.start <= span.start) {
|
|
514
|
+
return nextSpan;
|
|
515
|
+
}
|
|
516
|
+
return span;
|
|
517
|
+
}, null);
|
|
478
518
|
}
|
|
479
519
|
function findNextInlineCodeSpan(line, cursor) {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
520
|
+
let codeStart = line.indexOf("`", cursor);
|
|
521
|
+
while (codeStart !== -1) {
|
|
522
|
+
const delimiterLength = countRepeatedCharacter(line, codeStart, "`");
|
|
523
|
+
if (!isEscapedMarkdownCharacter(line, codeStart)) {
|
|
524
|
+
const end = findMatchingBacktickRunEnd(line, codeStart, delimiterLength);
|
|
525
|
+
if (end !== null) {
|
|
526
|
+
return { start: codeStart, end };
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
codeStart = line.indexOf("`", codeStart + delimiterLength);
|
|
488
530
|
}
|
|
489
|
-
return
|
|
490
|
-
start: codeStart,
|
|
491
|
-
end: codeEnd + delimiterLength
|
|
492
|
-
};
|
|
531
|
+
return null;
|
|
493
532
|
}
|
|
494
533
|
function findNextMarkdownLinkDestinationSpan(line, cursor) {
|
|
495
534
|
const linkDestinationPrefix = line.indexOf("](", cursor);
|
|
@@ -497,37 +536,144 @@ function findNextMarkdownLinkDestinationSpan(line, cursor) {
|
|
|
497
536
|
return null;
|
|
498
537
|
}
|
|
499
538
|
const destinationStart = linkDestinationPrefix + 2;
|
|
500
|
-
|
|
501
|
-
|
|
539
|
+
let parenthesisDepth = 0;
|
|
540
|
+
for (let destinationEnd = destinationStart; destinationEnd < line.length; destinationEnd += 1) {
|
|
541
|
+
const character = line[destinationEnd];
|
|
542
|
+
if (character === "\\") {
|
|
543
|
+
destinationEnd += 1;
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
if (character === "(") {
|
|
547
|
+
parenthesisDepth += 1;
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
if (character !== ")") {
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
if (parenthesisDepth > 0) {
|
|
554
|
+
parenthesisDepth -= 1;
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
return {
|
|
558
|
+
start: destinationStart,
|
|
559
|
+
end: destinationEnd
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
return null;
|
|
563
|
+
}
|
|
564
|
+
function findNextMarkdownAngleBracketSpan(line, cursor) {
|
|
565
|
+
const start = line.indexOf("<", cursor);
|
|
566
|
+
if (start === -1) {
|
|
502
567
|
return null;
|
|
503
568
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
569
|
+
const end = line.indexOf(">", start + 1);
|
|
570
|
+
if (end === -1) {
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
return { start, end: end + 1 };
|
|
508
574
|
}
|
|
509
|
-
function replaceLiteralAngleBracketTextTokens(text, placeholderToToken) {
|
|
575
|
+
function replaceLiteralAngleBracketTextTokens(text, placeholderToToken, createPlaceholder) {
|
|
510
576
|
return text.replace(MARKDOWN_ANGLE_BRACKET_TOKEN_PATTERN, (match, innerText) => {
|
|
511
577
|
if (isMarkdownAutolinkAngleBracketText(innerText)) {
|
|
512
578
|
return match;
|
|
513
579
|
}
|
|
514
|
-
const placeholder =
|
|
580
|
+
const placeholder = createPlaceholder();
|
|
515
581
|
placeholderToToken.set(placeholder, match);
|
|
516
582
|
return placeholder;
|
|
517
583
|
});
|
|
518
584
|
}
|
|
519
|
-
function
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
585
|
+
function isPotentialNumericTildeRangeRun(value, start, end) {
|
|
586
|
+
if (end - start > 2) {
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
return getNumericEndpointBefore(value, start) !== null && getNumericEndpointAfter(value, end) !== null;
|
|
590
|
+
}
|
|
591
|
+
function findEndpointTokenBefore(value, end) {
|
|
592
|
+
let start = end;
|
|
593
|
+
while (start > 0 && NUMERIC_ENDPOINT_TOKEN_CHARACTER_PATTERN.test(value[start - 1] ?? "")) {
|
|
594
|
+
start -= 1;
|
|
595
|
+
}
|
|
596
|
+
return {
|
|
597
|
+
start,
|
|
598
|
+
token: value.slice(start, end)
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
function findEndpointTokenAfter(value, start) {
|
|
602
|
+
let end = start;
|
|
603
|
+
while (end < value.length && NUMERIC_ENDPOINT_TOKEN_CHARACTER_PATTERN.test(value[end] ?? "")) {
|
|
604
|
+
end += 1;
|
|
605
|
+
}
|
|
606
|
+
return value.slice(start, end);
|
|
607
|
+
}
|
|
608
|
+
function getNumericEndpointBefore(value, end) {
|
|
609
|
+
const endpoint = findEndpointTokenBefore(value, end);
|
|
610
|
+
if (NUMERIC_ENDPOINT_START_PATTERN.test(endpoint.token)) {
|
|
611
|
+
return endpoint.token;
|
|
612
|
+
}
|
|
613
|
+
if (!endpoint.token) {
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
let previousEnd = endpoint.start;
|
|
617
|
+
while (previousEnd > 0 && (value[previousEnd - 1] === " " || value[previousEnd - 1] === " ")) {
|
|
618
|
+
previousEnd -= 1;
|
|
619
|
+
}
|
|
620
|
+
if (previousEnd === endpoint.start) {
|
|
621
|
+
return null;
|
|
622
|
+
}
|
|
623
|
+
const previousEndpoint = findEndpointTokenBefore(value, previousEnd);
|
|
624
|
+
return NUMERIC_ENDPOINT_START_PATTERN.test(previousEndpoint.token) ? value.slice(previousEndpoint.start, end) : null;
|
|
625
|
+
}
|
|
626
|
+
function getNumericEndpointAfter(value, start) {
|
|
627
|
+
const endpoint = findEndpointTokenAfter(value, start);
|
|
628
|
+
return NUMERIC_ENDPOINT_START_PATTERN.test(endpoint) ? endpoint : null;
|
|
629
|
+
}
|
|
630
|
+
function getNumericTildeRangeRuns(value) {
|
|
631
|
+
const numericRuns = [];
|
|
632
|
+
const pendingNumericBoundaryStrikeOpeners = /* @__PURE__ */ new Set();
|
|
633
|
+
for (const match of value.matchAll(TILDE_RUN_PATTERN)) {
|
|
634
|
+
const start = match.index;
|
|
635
|
+
const length = match[0].length;
|
|
636
|
+
const end = start + length;
|
|
637
|
+
if (length > 2) {
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
const canOpen = end < value.length && !/\s/u.test(value[end] ?? "");
|
|
641
|
+
const canClose = start > 0 && !/\s/u.test(value[start - 1] ?? "");
|
|
642
|
+
const isNumericRange = isPotentialNumericTildeRangeRun(value, start, end);
|
|
643
|
+
if (isNumericRange) {
|
|
644
|
+
if (canClose && pendingNumericBoundaryStrikeOpeners.delete(length)) {
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
numericRuns.push({ length, start });
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
if (canClose && pendingNumericBoundaryStrikeOpeners.delete(length)) {
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
if (canOpen && getNumericEndpointBefore(value, start) !== null) {
|
|
654
|
+
pendingNumericBoundaryStrikeOpeners.add(length);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return numericRuns;
|
|
658
|
+
}
|
|
659
|
+
function replaceNumericTildeRangeMarkers(text, placeholderToToken, createPlaceholder) {
|
|
660
|
+
const numericRunStarts = new Set(getNumericTildeRangeRuns(text).map((run) => run.start));
|
|
661
|
+
return text.replace(TILDE_RUN_PATTERN, (tildeRun, offset) => {
|
|
662
|
+
if (!numericRunStarts.has(offset)) {
|
|
663
|
+
return tildeRun;
|
|
664
|
+
}
|
|
665
|
+
return [...tildeRun].map(() => {
|
|
666
|
+
const placeholder = createPlaceholder();
|
|
667
|
+
placeholderToToken.set(placeholder, "~");
|
|
668
|
+
return placeholder;
|
|
669
|
+
}).join("");
|
|
524
670
|
});
|
|
525
671
|
}
|
|
526
|
-
function protectMarkdownLineEndHardBreakMarker(line, lineEnding, hasContinuationLine, placeholderToToken) {
|
|
672
|
+
function protectMarkdownLineEndHardBreakMarker(line, lineEnding, hasContinuationLine, placeholderToToken, createPlaceholder) {
|
|
527
673
|
if (!lineEnding || !line.endsWith("\\")) {
|
|
528
674
|
return line;
|
|
529
675
|
}
|
|
530
|
-
const placeholder =
|
|
676
|
+
const placeholder = createPlaceholder();
|
|
531
677
|
const shouldPreserveAsHardBreak = hasContinuationLine && !hasUnclosedInlineCodeSpanAtLineEnd(line);
|
|
532
678
|
placeholderToToken.set(placeholder, shouldPreserveAsHardBreak ? "\n" : "\\");
|
|
533
679
|
return `${line.slice(0, -1)}${placeholder}`;
|
|
@@ -569,14 +715,35 @@ function hasUnclosedInlineCodeSpanAtLineEnd(line) {
|
|
|
569
715
|
}
|
|
570
716
|
return openDelimiter !== null;
|
|
571
717
|
}
|
|
572
|
-
function
|
|
573
|
-
|
|
718
|
+
function decodeNumericCharacterReference(reference) {
|
|
719
|
+
const value = reference.slice(2, -1);
|
|
720
|
+
const isHexadecimal = value[0]?.toLowerCase() === "x";
|
|
721
|
+
const codePoint = Number.parseInt(isHexadecimal ? value.slice(1) : value, isHexadecimal ? 16 : 10);
|
|
722
|
+
if (!Number.isSafeInteger(codePoint) || codePoint < 0 || codePoint > 1114111) {
|
|
723
|
+
return reference;
|
|
724
|
+
}
|
|
725
|
+
return String.fromCodePoint(codePoint);
|
|
574
726
|
}
|
|
575
|
-
function
|
|
576
|
-
return
|
|
727
|
+
function createNumericTildeRangePlaceholderFactory(markdown) {
|
|
728
|
+
return createProtectedTextPlaceholderFactory(
|
|
729
|
+
markdown,
|
|
730
|
+
NUMERIC_TILDE_RANGE_PLACEHOLDER_PREFIX,
|
|
731
|
+
NUMERIC_TILDE_RANGE_PLACEHOLDER_SUFFIX
|
|
732
|
+
);
|
|
577
733
|
}
|
|
578
|
-
function
|
|
579
|
-
|
|
734
|
+
function createProtectedTextPlaceholderFactory(markdown, prefix, suffix) {
|
|
735
|
+
const decodedMarkdown = markdown.replace(NUMERIC_CHARACTER_REFERENCE_PATTERN, decodeNumericCharacterReference);
|
|
736
|
+
const lowercaseMarkdown = markdown.toLowerCase();
|
|
737
|
+
let index = 0;
|
|
738
|
+
return () => {
|
|
739
|
+
let placeholder = `${prefix}${index}${suffix}`;
|
|
740
|
+
while (markdown.includes(placeholder) || lowercaseMarkdown.includes(encodeURIComponent(placeholder).toLowerCase()) || decodedMarkdown.includes(placeholder)) {
|
|
741
|
+
index += 1;
|
|
742
|
+
placeholder = `${prefix}${index}${suffix}`;
|
|
743
|
+
}
|
|
744
|
+
index += 1;
|
|
745
|
+
return placeholder;
|
|
746
|
+
};
|
|
580
747
|
}
|
|
581
748
|
function countRepeatedCharacter(value, start, character) {
|
|
582
749
|
let cursor = start;
|
|
@@ -585,6 +752,28 @@ function countRepeatedCharacter(value, start, character) {
|
|
|
585
752
|
}
|
|
586
753
|
return cursor - start;
|
|
587
754
|
}
|
|
755
|
+
function isEscapedMarkdownCharacter(value, index) {
|
|
756
|
+
let precedingBackslashes = 0;
|
|
757
|
+
for (let cursor = index - 1; cursor >= 0 && value[cursor] === "\\"; cursor -= 1) {
|
|
758
|
+
precedingBackslashes += 1;
|
|
759
|
+
}
|
|
760
|
+
return precedingBackslashes % 2 === 1;
|
|
761
|
+
}
|
|
762
|
+
function findMatchingBacktickRunEnd(line, start, delimiterLength) {
|
|
763
|
+
let cursor = start + delimiterLength;
|
|
764
|
+
while (cursor < line.length) {
|
|
765
|
+
const candidate = line.indexOf("`", cursor);
|
|
766
|
+
if (candidate === -1) {
|
|
767
|
+
return null;
|
|
768
|
+
}
|
|
769
|
+
const candidateLength = countRepeatedCharacter(line, candidate, "`");
|
|
770
|
+
if (candidateLength === delimiterLength) {
|
|
771
|
+
return candidate + candidateLength;
|
|
772
|
+
}
|
|
773
|
+
cursor = candidate + candidateLength;
|
|
774
|
+
}
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
588
777
|
function findTagPlaceholderAtCursor(text, cursor, placeholderToTag) {
|
|
589
778
|
for (const [placeholder, tagToken] of placeholderToTag.entries()) {
|
|
590
779
|
if (text.startsWith(placeholder, cursor)) {
|
|
@@ -629,13 +818,7 @@ function restoreProtectedTextPlaceholders(blocks, placeholderToToken) {
|
|
|
629
818
|
if (placeholderToToken.size === 0) {
|
|
630
819
|
return blocks;
|
|
631
820
|
}
|
|
632
|
-
return
|
|
633
|
-
blocks,
|
|
634
|
-
(content) => mapBlockContent(
|
|
635
|
-
content,
|
|
636
|
-
(inline) => restoreProtectedTextInValue(inline, placeholderToToken)
|
|
637
|
-
)
|
|
638
|
-
);
|
|
821
|
+
return restoreProtectedTextInValue(blocks, placeholderToToken);
|
|
639
822
|
}
|
|
640
823
|
function restoreProtectedTextInValue(value, placeholderToToken) {
|
|
641
824
|
if (typeof value === "string") {
|
|
@@ -661,6 +844,10 @@ function restoreProtectedText(text, placeholderToToken) {
|
|
|
661
844
|
`).join(`${placeholder}\r
|
|
662
845
|
`);
|
|
663
846
|
}
|
|
847
|
+
restoredText = restoredText.replace(
|
|
848
|
+
new RegExp(encodeURIComponent(placeholder), "gi"),
|
|
849
|
+
encodeURIComponent(token)
|
|
850
|
+
);
|
|
664
851
|
restoredText = restoredText.split(placeholder).join(token);
|
|
665
852
|
}
|
|
666
853
|
return restoredText;
|
|
@@ -13,6 +13,7 @@ class AppError extends Error {
|
|
|
13
13
|
const createAppError = (status, code, message, details) => {
|
|
14
14
|
return new AppError(status, code, message, details);
|
|
15
15
|
};
|
|
16
|
+
const hasErrorType = (error, type) => error instanceof Error && "type" in error && error.type === type;
|
|
16
17
|
const createErrorHandler = () => {
|
|
17
18
|
return (error, _req, res, next) => {
|
|
18
19
|
if (res.headersSent) {
|
|
@@ -27,6 +28,13 @@ const createErrorHandler = () => {
|
|
|
27
28
|
}).end();
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
31
|
+
if (hasErrorType(error, "encoding.unsupported")) {
|
|
32
|
+
res.status(415).json({
|
|
33
|
+
code: "UNSUPPORTED_CONTENT_ENCODING",
|
|
34
|
+
message: "Compressed request bodies are not supported."
|
|
35
|
+
}).end();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
30
38
|
if (error instanceof Error && error.message.startsWith("CSRF token ")) {
|
|
31
39
|
res.status(403).json({
|
|
32
40
|
code: "CSRF_TOKEN_INVALID",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./graph-vendor-BAF95C0g.js";import{a7 as r}from"./index-BR05aSXr.js";const n=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,128l-72,72V56Z",opacity:"0.2"}),e.createElement("path",{d:"M221.66,122.34l-72-72A8,8,0,0,0,136,56v64H40a8,8,0,0,0,0,16h96v64a8,8,0,0,0,13.66,5.66l72-72A8,8,0,0,0,221.66,122.34ZM152,180.69V75.31L204.69,128Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M221.66,133.66l-72,72A8,8,0,0,1,136,200V136H40a8,8,0,0,1,0-16h96V56a8,8,0,0,1,13.66-5.66l72,72A8,8,0,0,1,221.66,133.66Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M220.24,132.24l-72,72a6,6,0,0,1-8.48-8.48L201.51,134H40a6,6,0,0,1,0-12H201.51L139.76,60.24a6,6,0,0,1,8.48-8.48l72,72A6,6,0,0,1,220.24,132.24Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M218.83,130.83l-72,72a4,4,0,0,1-5.66-5.66L206.34,132H40a4,4,0,0,1,0-8H206.34L141.17,58.83a4,4,0,0,1,5.66-5.66l72,72A4,4,0,0,1,218.83,130.83Z"}))]]),a=e.forwardRef((t,l)=>e.createElement(r,{ref:l,...t,weights:n}));a.displayName="ArrowRightIcon";const o=a;export{o as s};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-Hoz9Q4-4.js";import{T as b,L as te,N as se,c as q,d as f,s as ae,a as re,M as S,b as ne,S as oe,e as F,B as O,f as ie,g as le,u as H,q as z,h as K,P as ce,i as de,j as ue,C as me}from"./index-BR05aSXr.js";import{a as d}from"./graph-vendor-BAF95C0g.js";import{C as he}from"./Callout-DKruIT0f.js";import"./note-core-CMGUaW1v.js";const ge=({day:a,cellClassName:t,dayNumberClassName:s,isCurrentMonth:i,items:o,overflowCount:l,onOpenOverflow:m})=>e.jsxs("div",{className:`min-h-[196px] rounded-[16px] border p-2.5 ${t}`.trim(),children:[e.jsx("div",{className:"mb-2.5 flex justify-end",children:e.jsx(b,{as:"span",variant:"label",className:`flex h-7 w-7 items-center justify-center rounded-[10px] ${s}`.trim(),children:a})}),i&&o.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[o,l>0?e.jsxs("button",{type:"button",onClick:m,className:"focus-ring-soft w-full rounded-[10px] border border-dashed border-border-subtle/70 bg-subtle/70 py-1 text-center text-micro font-semibold text-fg-tertiary outline-none transition-colors hover:border-border-secondary/70 hover:bg-hover-subtle hover:text-fg-secondary",children:["+",l," more"]}):null]}):null]}),V=({params:a,toneClassName:t="",header:s,title:i,meta:o,titleClassName:l=""})=>e.jsx(te,{to:se,params:a,className:"focus-ring-soft group block rounded-[8px] outline-none",children:e.jsxs("div",{className:q("flex items-start gap-1.5 rounded-[8px] px-1.5 py-1 transition-colors group-hover:bg-hover-subtle",t),children:[s?e.jsx("span",{className:"mt-[2px] flex h-4 w-4 shrink-0 items-center justify-center text-fg-tertiary",children:s}):e.jsx("span",{"aria-hidden":"true",className:"mt-[6px] h-1.5 w-1.5 shrink-0 rounded-full bg-fg-placeholder"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(b,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:q("line-clamp-1",l),children:i}),o?e.jsx(b,{as:"div",variant:"micro",weight:"medium",tone:"tertiary",className:"mt-0.5",children:o}):null]})]})}),xe=({note:a,type:t})=>e.jsx(V,{params:{id:a.id},header:e.jsx(ae,{size:12}),title:a.title,meta:f(Number(t==="create"?a.createdAt:a.updatedAt)).format("HH:mm")}),pe=({reminder:a})=>e.jsx(V,{params:{id:String(a.note?.id??a.noteId)},header:e.jsx(re,{size:12}),title:a.content||a.note?.title||"No title",titleClassName:a.completed?"line-through":"",meta:f(Number(a.reminderDate)).format("HH:mm")}),L=3,Q=(a,t)=>a.map(s=>s.type==="note"?e.jsx(xe,{note:s.item,type:t},`note-${s.item.id}`):e.jsx(pe,{reminder:s.item},`reminder-${s.item.id}`)),ye=({year:a,month:t,day:s,isCurrentMonth:i,isSunday:o,isToday:l,isPast:m,notes:h,reminders:g,type:N})=>{const[M,v]=d.useState(!1),p=d.useMemo(()=>{const r=h.map(u=>({type:"note",item:u})),c=g.map(u=>({type:"reminder",item:u}));return m?[...r,...c]:[...c,...r]},[m,h,g]),D=p.length>L,w=d.useMemo(()=>Q(p.slice(0,L),N),[p,N]),$=d.useMemo(()=>Q(p,N),[p,N]),k=d.useCallback(()=>v(!0),[]),C=d.useCallback(()=>v(!1),[]),E=()=>i?l?"border-border-secondary/70 bg-[color:color-mix(in_srgb,var(--surface)_88%,var(--accent-soft-primary)_12%)]":"bg-surface border-border-subtle":"bg-muted/18 border-border-subtle/70",I=()=>l?"bg-cta text-fg-on-filled font-semibold":i?o?"text-fg-weekend font-bold":"text-fg-secondary font-bold":"text-fg-disabled opacity-55";return e.jsxs(e.Fragment,{children:[e.jsx(ge,{day:s,cellClassName:E(),dayNumberClassName:I(),isCurrentMonth:i,items:w,overflowCount:D?p.length-L:0,onOpenOverflow:k}),D&&e.jsxs(S,{isOpen:M,onClose:C,variant:"inspect",children:[e.jsx(S.Header,{title:`${a}/${String(t).padStart(2,"0")}/${String(s).padStart(2,"0")}`,onClose:C}),e.jsxs(S.Body,{children:[e.jsxs(S.Description,{className:"sr-only",children:["View all notes and reminders scheduled for day ",s,"."]}),e.jsx("div",{className:"flex max-h-[60vh] flex-col gap-2 overflow-y-auto",children:$})]})]})]})},fe=d.memo(ye),be=["January","February","March","April","May","June","July","August","September","October","November","December"],je=({month:a,year:t,type:s,onPrevMonth:i,onNextMonth:o,onToday:l,onTypeChange:m})=>e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-x-2.5 gap-y-1",children:[e.jsx(b,{as:"h1",variant:"display",weight:"bold",tracking:"tighter",className:"text-2xl leading-none sm:text-[2.15rem]",children:be[a-1]}),e.jsx(b,{as:"span",variant:"subheading",weight:"medium",tone:"secondary",tracking:"tight",className:"pb-0.5",children:t})]}),e.jsx(b,{as:"p",variant:"meta",weight:"medium",tone:"secondary",children:"Track note activity and reminders across the month"})]}),e.jsx("div",{className:"flex lg:justify-end",children:e.jsxs("div",{className:"surface-base inline-flex flex-wrap items-center gap-3 rounded-[16px] px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(b,{id:"calendar-note-date-label",as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Note date"}),e.jsxs(oe,{value:s,"aria-labelledby":"calendar-note-date-label",onValueChange:g=>m(g),variant:"ghost",size:"sm",children:[e.jsx(F,{value:"create",children:"Created"}),e.jsx(F,{value:"update",children:"Updated"})]})]}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(O,{variant:"ghost",size:"sm",onClick:l,children:"Today"}),e.jsx(O,{variant:"ghost",size:"icon-sm","aria-label":"Previous month",onClick:i,children:e.jsx(ie,{width:18,height:18})}),e.jsx(O,{variant:"ghost",size:"icon-sm","aria-label":"Next month",onClick:o,children:e.jsx(le,{width:18,height:18})})]})]})})]}),Ne=`
|
|
2
|
-
query NotesInDateRange($dateRange: DateRangeInput) {
|
|
3
|
-
notesInDateRange(dateRange: $dateRange) {
|
|
4
|
-
id
|
|
5
|
-
title
|
|
6
|
-
createdAt
|
|
7
|
-
updatedAt
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
`,ve=`
|
|
11
|
-
query RemindersInDateRange($dateRange: DateRangeInput) {
|
|
12
|
-
remindersInDateRange(dateRange: $dateRange) {
|
|
13
|
-
id
|
|
14
|
-
noteId
|
|
15
|
-
reminderDate
|
|
16
|
-
completed
|
|
17
|
-
priority
|
|
18
|
-
content
|
|
19
|
-
note {
|
|
20
|
-
id
|
|
21
|
-
title
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
`,Me=async a=>{const t=await K(Ne,{dateRange:a});if(t.type==="error")throw t;return t.notesInDateRange},De=async a=>{const t=await K(ve,{dateRange:a});if(t.type==="error")throw t;return t.remindersInDateRange},Ce=({year:a,month:t})=>{const s=`${a}-${String(t).padStart(2,"0")}-01`,i=t===12?1:t+1,l=`${t===12?a+1:a}-${String(i).padStart(2,"0")}-01`,m={start:s,end:l},h=H({queryKey:z.calendar.notesInDateRange(a,t),queryFn:()=>Me(m)}),g=H({queryKey:z.reminders.inDateRange(a,t),queryFn:()=>De(m)});return{notes:h.data??[],reminders:g.data??[],isLoading:h.isLoading||g.isLoading,isError:h.isError||g.isError}},Re=["SUN","MON","TUE","WED","THU","FRI","SAT"],Se=[],we=[],B=ue(me);function Oe(){const a=B.useNavigate(),{year:t,month:s,type:i}=B.useSearch(),o=d.useRef(null),l=d.useRef(!1),m=d.useRef(0),h=d.useRef(0),g=d.useCallback(r=>{l.current=!0,m.current=r.pageX-(o.current?.offsetLeft??0),h.current=o.current?.scrollLeft??0,o.current&&(o.current.style.cursor="grabbing",o.current.style.userSelect="none")},[]),N=d.useCallback(r=>{if(!l.current||!o.current)return;r.preventDefault();const u=(r.pageX-o.current.offsetLeft-m.current)*1.2;o.current.scrollLeft=h.current-u},[]),M=d.useCallback(()=>{l.current=!1,o.current&&(o.current.style.cursor="grab",o.current.style.userSelect="")},[]),{notes:v,reminders:p,isLoading:D,isError:w}=Ce({year:t,month:s}),$=d.useMemo(()=>{const r=f(),c=`${r.year()}-${r.month()+1}-${r.date()}`,u=new Map;for(const n of v){const y=i==="create"?f(Number(n.createdAt)):f(Number(n.updatedAt)),x=`${y.year()}-${y.month()+1}-${y.date()}`,j=u.get(x)||[];j.push(n),u.set(x,j)}const T=new Map;for(const n of p){const y=f(Number(n.reminderDate)),x=`${y.year()}-${y.month()+1}-${y.date()}`,j=T.get(x)||[];j.push(n),T.set(x,j)}const W=new Date(t,s-1,1),X=new Date(t,s,0),A=W.getDay(),_=X.getDate(),R=[],Y=s===1?12:s-1,P=s===1?t-1:t,J=new Date(P,Y,0).getDate();for(let n=A-1;n>=0;n--)R.push({day:J-n,isCurrentMonth:!1,year:P,month:Y});for(let n=1;n<=_;n++)R.push({day:n,isCurrentMonth:!0,year:t,month:s});const U=(A+_)%7,G=U===0?0:7-U,Z=s===12?1:s+1,ee=s===12?t+1:t;for(let n=1;n<=G;n++)R.push({day:n,isCurrentMonth:!1,year:ee,month:Z});return R.map((n,y)=>{const x=`${n.year}-${n.month}-${n.day}`,j=f(`${n.year}-${String(n.month).padStart(2,"0")}-${String(n.day).padStart(2,"0")}`);return{key:x,year:n.year,month:n.month,day:n.day,isCurrentMonth:n.isCurrentMonth,isSunday:y%7===0,isToday:x===c,isPast:j.isBefore(r,"day"),notes:u.get(x)||Se,reminders:T.get(x)||we}})},[t,s,v,p,i]),k=()=>{const r=s===1?12:s-1,c=s===1?t-1:t;a({search:u=>({...u,month:r,year:c})})},C=()=>{const r=s===12?1:s+1,c=s===12?t+1:t;a({search:u=>({...u,month:r,year:c})})},E=()=>{a({search:r=>({...r,month:f().month()+1,year:f().year()})})},I=r=>{r&&a({search:c=>({...c,type:r})})};return e.jsx(ce,{title:"Calendar",variant:"none",children:w?e.jsx(he,{children:"Failed to load calendar data. Please try again later."}):e.jsxs("div",{className:"surface-base",children:[e.jsx("div",{className:"border-b border-border-subtle/80 px-4 py-4 sm:px-5",children:e.jsx(je,{month:s,year:t,type:i,onPrevMonth:k,onNextMonth:C,onToday:E,onTypeChange:I})}),e.jsx("div",{ref:o,className:"cursor-grab overflow-x-auto px-4 pb-4 pt-3 sm:px-5",onMouseDown:g,onMouseMove:N,onMouseUp:M,onMouseLeave:M,children:e.jsxs("div",{className:"min-w-[1260px]",children:[e.jsx("div",{className:"mb-2.5 grid grid-cols-7 gap-1.5",children:Re.map((r,c)=>e.jsx(b,{as:"div",variant:"label",weight:"semibold",tracking:"wider",transform:"uppercase",className:`py-2 text-center ${c===0?"text-fg-weekend":"text-fg-tertiary"}`,children:r},r))}),D?e.jsx("div",{className:"grid grid-cols-7 gap-1.5",children:Array.from({length:35}).map((r,c)=>e.jsx(de,{height:180},c))}):e.jsx("div",{className:"grid grid-cols-7 gap-1.5",children:$.map(r=>e.jsx(fe,{year:r.year,month:r.month,day:r.day,isCurrentMonth:r.isCurrentMonth,isSunday:r.isSunday,isToday:r.isToday,isPast:r.isPast,notes:r.notes,reminders:r.reminders,type:i},r.key))})]})})]})})}export{Oe as default};
|