@abraca/nuxt 2.73.0 → 2.75.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 (32) hide show
  1. package/dist/module.d.mts +1 -0
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/ADocSubPageList.d.vue.ts +12 -0
  4. package/dist/runtime/components/ADocSubPageList.vue +7 -1
  5. package/dist/runtime/components/ADocSubPageList.vue.d.ts +12 -0
  6. package/dist/runtime/components/APresence.d.vue.ts +4 -0
  7. package/dist/runtime/components/APresence.vue.d.ts +4 -0
  8. package/dist/runtime/composables/useAwarenessPeers.d.ts +10 -2
  9. package/dist/runtime/composables/useChat.d.ts +28 -0
  10. package/dist/runtime/composables/useChat.js +20 -2
  11. package/dist/runtime/composables/useChildTree.d.ts +2 -1
  12. package/dist/runtime/composables/useChildTree.js +18 -7
  13. package/dist/runtime/composables/useFileBlobStore.d.ts +13 -0
  14. package/dist/runtime/composables/useFileBlobStore.js +17 -2
  15. package/dist/runtime/composables/useNotifications.d.ts +41 -0
  16. package/dist/runtime/composables/useNotifications.js +50 -12
  17. package/dist/runtime/composables/useRendererBase.d.ts +18 -1
  18. package/dist/runtime/composables/useYDoc.d.ts +34 -9
  19. package/dist/runtime/plugin-abracadabra.client.js +3 -1
  20. package/dist/runtime/server/api/_abracadabra/render/[docId].get.d.ts +3 -3
  21. package/dist/runtime/server/api/_abracadabra/render/[docId].get.js +4 -3
  22. package/dist/runtime/server/api/_abracadabra/resolve/[...slug].get.d.ts +3 -3
  23. package/dist/runtime/server/api/_abracadabra/resolve/[...slug].get.js +5 -4
  24. package/dist/runtime/server/utils/docCache.d.ts +44 -0
  25. package/dist/runtime/server/utils/docCache.js +26 -4
  26. package/dist/runtime/types.d.ts +7 -0
  27. package/dist/runtime/utils/docTypes.d.ts +2 -0
  28. package/dist/runtime/utils/docTypes.js +10 -4
  29. package/dist/runtime/utils/titleSync.d.ts +6 -1
  30. package/dist/runtime/utils/titleSync.js +1 -1
  31. package/dist/types.d.mts +2 -0
  32. package/package.json +1 -1
package/dist/module.d.mts CHANGED
@@ -5,6 +5,7 @@ import { AbracadabraLocale } from '../dist/runtime/locale.js';
5
5
  export { AbracadabraLocale } from '../dist/runtime/locale.js';
6
6
  export { DocTreeReturn } from '../dist/runtime/composables/useDocTree.js';
7
7
  export { DocSeoOptions } from '../dist/runtime/composables/useDocSeo.js';
8
+ export { AppNotification, NotificationType } from '../dist/runtime/composables/useNotifications.js';
8
9
  export { DocDragState } from '../dist/runtime/composables/useDocDragBus.js';
9
10
  export { ParsedMessage, TextSegment, parseMessageContent, previewMessageContent, renderMessageSegments } from '../dist/runtime/utils/chatContent.js';
10
11
  export { DupEntry, duplicateDocContent, duplicateDocTree } from '../dist/runtime/utils/duplicateDocContent.js';
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "2.73.0",
7
+ "version": "2.75.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -30,6 +30,17 @@ type __VLS_Props = {
30
30
  expanded?: boolean;
31
31
  /** Whether create / rename / reorder / delete are available. Default: true. */
32
32
  editable?: boolean;
33
+ /**
34
+ * List children carrying `meta.hidden`. Default: false.
35
+ *
36
+ * `meta.hidden` is the platform-wide "routable but not advertised" flag —
37
+ * it already removes a doc from navigation and from the graph. The sub-page
38
+ * list used to ignore it, which is how app-internal pages (a site-config
39
+ * document, a settings page, staging drafts) leaked onto the parent page
40
+ * for every reader. Owner/admin surfaces that deliberately want the full
41
+ * set pass `:show-hidden="true"`.
42
+ */
43
+ showHidden?: boolean;
33
44
  /** Per-string label overrides. */
34
45
  labels?: Partial<SubPageListLabels>;
35
46
  };
@@ -41,6 +52,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
41
52
  editable: boolean;
42
53
  labels: Partial<SubPageListLabels>;
43
54
  expanded: boolean;
55
+ showHidden: boolean;
44
56
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
45
57
  declare const _default: typeof __VLS_export;
46
58
  export default _default;
@@ -25,6 +25,7 @@ const props = defineProps({
25
25
  docId: { type: String, required: true },
26
26
  expanded: { type: Boolean, required: false, default: true },
27
27
  editable: { type: Boolean, required: false, default: true },
28
+ showHidden: { type: Boolean, required: false, default: false },
28
29
  labels: { type: Object, required: false, default: () => ({}) }
29
30
  });
30
31
  const emit = defineEmits(["open"]);
@@ -99,9 +100,14 @@ function pageColor(id, entry) {
99
100
  lookup: (lid) => treeMap.data[lid]
100
101
  });
101
102
  }
103
+ function visibleChildrenOf(parentId) {
104
+ const children = docTree.childrenOf(parentId);
105
+ if (props.showHidden) return children;
106
+ return children.filter((c) => !c.meta?.hidden);
107
+ }
102
108
  const { expandedIds, toggle: toggleExpand, flatItems } = useTreeExpansion({
103
109
  storageKey: `subdoc:expand:${props.docId}`,
104
- childrenOf: (parentId) => docTree.childrenOf(parentId)
110
+ childrenOf: visibleChildrenOf
105
111
  });
106
112
  const viewersByPage = computed(() => {
107
113
  const m = /* @__PURE__ */ new Map();
@@ -30,6 +30,17 @@ type __VLS_Props = {
30
30
  expanded?: boolean;
31
31
  /** Whether create / rename / reorder / delete are available. Default: true. */
32
32
  editable?: boolean;
33
+ /**
34
+ * List children carrying `meta.hidden`. Default: false.
35
+ *
36
+ * `meta.hidden` is the platform-wide "routable but not advertised" flag —
37
+ * it already removes a doc from navigation and from the graph. The sub-page
38
+ * list used to ignore it, which is how app-internal pages (a site-config
39
+ * document, a settings page, staging drafts) leaked onto the parent page
40
+ * for every reader. Owner/admin surfaces that deliberately want the full
41
+ * set pass `:show-hidden="true"`.
42
+ */
43
+ showHidden?: boolean;
33
44
  /** Per-string label overrides. */
34
45
  labels?: Partial<SubPageListLabels>;
35
46
  };
@@ -41,6 +52,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
41
52
  editable: boolean;
42
53
  labels: Partial<SubPageListLabels>;
43
54
  expanded: boolean;
55
+ showHidden: boolean;
44
56
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
45
57
  declare const _default: typeof __VLS_export;
46
58
  export default _default;
@@ -18,7 +18,11 @@ declare var __VLS_1: {
18
18
  name?: string | undefined;
19
19
  color?: string | undefined;
20
20
  avatar?: string | undefined;
21
+ statusIcon?: string | undefined;
22
+ statusText?: string | undefined;
23
+ publicKey?: string | undefined;
21
24
  } | undefined;
25
+ docId?: string | undefined;
22
26
  } | null;
23
27
  avatarStyle: typeof userAvatarStyle;
24
28
  }, __VLS_3: {
@@ -18,7 +18,11 @@ declare var __VLS_1: {
18
18
  name?: string | undefined;
19
19
  color?: string | undefined;
20
20
  avatar?: string | undefined;
21
+ statusIcon?: string | undefined;
22
+ statusText?: string | undefined;
23
+ publicKey?: string | undefined;
21
24
  } | undefined;
25
+ docId?: string | undefined;
22
26
  } | null;
23
27
  avatarStyle: typeof userAvatarStyle;
24
28
  }, __VLS_3: {
@@ -1,5 +1,5 @@
1
1
  import type { MaybeRef } from 'vue';
2
- import type { AwarenessPeer } from '../types.js';
2
+ import type { AwarenessPeer, AwarenessUser } from '../types.js';
3
3
  /**
4
4
  * Reactive awareness peer list with idle detection and doc-scoped filtering.
5
5
  *
@@ -19,15 +19,23 @@ export declare function useAwarenessPeers(): {
19
19
  name?: string | undefined;
20
20
  color?: string | undefined;
21
21
  avatar?: string | undefined;
22
+ statusIcon?: string | undefined;
23
+ statusText?: string | undefined;
24
+ publicKey?: string | undefined;
22
25
  } | undefined;
23
- } | null, import("./useYDoc.js").AwarenessUser | {
26
+ docId?: string | undefined;
27
+ } | null, AwarenessUser | {
24
28
  [x: string]: any;
25
29
  clientId: number;
26
30
  user?: {
27
31
  name?: string | undefined;
28
32
  color?: string | undefined;
29
33
  avatar?: string | undefined;
34
+ statusIcon?: string | undefined;
35
+ statusText?: string | undefined;
36
+ publicKey?: string | undefined;
30
37
  } | undefined;
38
+ docId?: string | undefined;
31
39
  } | null>;
32
40
  isIdle: (clientId: number, thresholdMs?: number) => boolean;
33
41
  peersInDoc: (docId: MaybeRef<string>) => import("vue").ComputedRef<AwarenessPeer[]>;
@@ -26,7 +26,34 @@ export interface ChatChannel {
26
26
  lastMessage?: ChatMessage;
27
27
  unreadCount: number;
28
28
  }
29
+ /**
30
+ * Deterministic doc id of the DM between two pubkeys — a real `kind = "dm"`
31
+ * document at the server root, derived from the sorted pair so both sides
32
+ * compute the same target without coordinating.
33
+ *
34
+ * ⚠️ This REPLACES the old synthetic `dm:<a>:<b>` key. That key was never a
35
+ * doc, and since the server unified chat + notifications onto the document
36
+ * tree it rejects it outright:
37
+ *
38
+ * WARN abracadabra::messages: Messages: handler error for messages:send:
39
+ * not found: document dm:<a>:<b> not found
40
+ *
41
+ * The symptom is nasty because the send is fire-and-forget: the message
42
+ * appears locally via the optimistic echo and is simply never persisted or
43
+ * delivered. (Found in abracadabra-atrium — every DM silently vanished.)
44
+ *
45
+ * The doc must EXIST before the first send. Call `ensureDmChannel()` once when
46
+ * opening a conversation; this function is the cheap synchronous derivation
47
+ * for keying reactive state.
48
+ */
29
49
  export declare function buildDmChannelId(a: string, b: string): string;
50
+ /**
51
+ * Find-or-create the backing DM doc (`kind = "dm"`, `public_access = "none"`,
52
+ * explicit Editor rows for both participants) and return its id. Idempotent
53
+ * and race-tolerant — both sides derive the same id, so a concurrent create
54
+ * resolves to the same doc. Await this before the conversation's first send.
55
+ */
56
+ export declare function ensureDmChannel(otherPubkey: string): Promise<string | null>;
30
57
  declare function setMuted(id: string, on: boolean): void;
31
58
  declare function setPinned(id: string, on: boolean): void;
32
59
  declare function setHidden(id: string, on: boolean): void;
@@ -71,6 +98,7 @@ export declare function useChat(): {
71
98
  sendTyping: typeof sendTyping;
72
99
  setActiveChannel: typeof setActiveChannel;
73
100
  buildDmChannelId: typeof buildDmChannelId;
101
+ ensureDmChannel: typeof ensureDmChannel;
74
102
  mutedChannels: import("vue").Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
75
103
  pinnedChannels: import("vue").Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
76
104
  hiddenChannels: import("vue").Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
@@ -5,6 +5,7 @@ import {
5
5
  ChannelKeyResolver,
6
6
  DocKeyManager,
7
7
  decryptChatContent,
8
+ deriveDmDocId,
8
9
  foldRecords,
9
10
  isEncryptedContent,
10
11
  recordFromYAny
@@ -22,7 +23,18 @@ function _resolveChannelKey(client) {
22
23
  return resolver;
23
24
  }
24
25
  export function buildDmChannelId(a, b) {
25
- return `dm:${[a, b].sort().join(":")}`;
26
+ return deriveDmDocId(a, b);
27
+ }
28
+ export async function ensureDmChannel(otherPubkey) {
29
+ const { client } = useAbracadabra();
30
+ const c = client.value;
31
+ if (!c?.findOrCreateDmDoc) return null;
32
+ try {
33
+ return await c.findOrCreateDmDoc(otherPubkey);
34
+ } catch (e) {
35
+ console.error("[abracadabra] ensureDmChannel failed:", e);
36
+ return null;
37
+ }
26
38
  }
27
39
  function normalizeChannel(channelId) {
28
40
  if (typeof channelId !== "string" || !channelId) return "";
@@ -199,7 +211,12 @@ export function _handleStatelessChat(payload) {
199
211
  // human-readable name from awareness so peers don't all show as
200
212
  // the placeholder "User" — that visual collapse was being read
201
213
  // as "chat is broken / messages aren't syncing".
202
- senderName: rec.sender_name ?? resolveSenderName(senderId),
214
+ //
215
+ // Falsy test, NOT `??`: the server round-trips `sender_name` as an
216
+ // EMPTY STRING rather than null, which `??` happily passes through —
217
+ // so every received message rendered with a blank byline (observed on
218
+ // abracadabra-atrium's DMs) while the resolver sat right there unused.
219
+ senderName: rec.sender_name || resolveSenderName(senderId),
203
220
  content: rec.content ?? "",
204
221
  createdAt: tsMs,
205
222
  ...rec.reply_to ? { replyTo: rec.reply_to } : {}
@@ -435,6 +452,7 @@ export function useChat() {
435
452
  sendTyping,
436
453
  setActiveChannel,
437
454
  buildDmChannelId,
455
+ ensureDmChannel,
438
456
  // Channel preferences
439
457
  mutedChannels,
440
458
  pinnedChannels,
@@ -20,10 +20,11 @@ export declare function useChildTree(rootDoc: ShallowRef<Y.Doc | null>, parentDo
20
20
  childrenOf: (parentId: string | null) => TreeEntry[];
21
21
  descendantsOf: (id: string) => TreeEntry[];
22
22
  createChild: (parentId: string | null, label: string, type?: string) => string;
23
+ createChildRegistered: (parentId: string | null, label: string, type?: string) => Promise<string>;
23
24
  registerDoc: (id: string, parentId: string, opts?: {
24
25
  label?: string;
25
26
  type?: string;
26
- }) => void;
27
+ }) => Promise<void>;
27
28
  moveEntry: (id: string, newParentId: string | null, newOrder: number) => void;
28
29
  deleteEntry: (id: string) => void;
29
30
  renameEntry: (id: string, label: string) => void;
@@ -62,18 +62,16 @@ export function useChildTree(rootDoc, parentDocId, options) {
62
62
  }
63
63
  function registerDoc(id, parentId, opts) {
64
64
  const client = abraState?.client?.value;
65
- if (import.meta.server || !client?.createChild) return;
66
- client.createChild(parentId, {
65
+ if (import.meta.server || !client?.createChild) return Promise.resolve();
66
+ return client.createChild(parentId, {
67
67
  child_id: id,
68
68
  label: opts?.label,
69
69
  doc_type: opts?.type
70
- }).catch(() => {
70
+ }).then(() => void 0).catch(() => {
71
71
  });
72
72
  }
73
- function createChild(parentId, label, type) {
74
- const id = crypto.randomUUID();
73
+ function writeTreeEntry(id, resolvedParent, label, type) {
75
74
  const now = Date.now();
76
- const resolvedParent = parentId === null ? parentDocId : parentId;
77
75
  treeMap.set(id, {
78
76
  label,
79
77
  parentId: resolvedParent,
@@ -82,7 +80,19 @@ export function useChildTree(rootDoc, parentDocId, options) {
82
80
  createdAt: now,
83
81
  updatedAt: now
84
82
  });
85
- registerDoc(id, resolvedParent, { label, type });
83
+ }
84
+ function createChild(parentId, label, type) {
85
+ const id = crypto.randomUUID();
86
+ const resolvedParent = parentId === null ? parentDocId : parentId;
87
+ void registerDoc(id, resolvedParent, { label, type });
88
+ writeTreeEntry(id, resolvedParent, label, type);
89
+ return id;
90
+ }
91
+ async function createChildRegistered(parentId, label, type) {
92
+ const id = crypto.randomUUID();
93
+ const resolvedParent = parentId === null ? parentDocId : parentId;
94
+ await registerDoc(id, resolvedParent, { label, type });
95
+ writeTreeEntry(id, resolvedParent, label, type);
86
96
  return id;
87
97
  }
88
98
  function moveEntry(id, newParentId, newOrder) {
@@ -133,6 +143,7 @@ export function useChildTree(rootDoc, parentDocId, options) {
133
143
  childrenOf,
134
144
  descendantsOf,
135
145
  createChild,
146
+ createChildRegistered,
136
147
  registerDoc,
137
148
  moveEntry,
138
149
  deleteEntry,
@@ -23,6 +23,19 @@ export interface ThumbOptions {
23
23
  format?: 'auto' | 'jpeg' | 'png';
24
24
  q?: number;
25
25
  }
26
+ /**
27
+ * The server's default `[uploads.thumbnails].allowed_sizes` ladder.
28
+ *
29
+ * The thumbnail endpoint deliberately serves ONLY these max-edge sizes — the
30
+ * allowlist is what bounds cache cardinality and closes a resize-amplification
31
+ * DoS — and answers anything else with **422**, not with a nearest match. A
32
+ * caller that asks for the size its layout actually needs (`w: 800` for an
33
+ * 800px card) therefore gets no thumbnail at all, silently falls back to the
34
+ * multi-megabyte original, and leaves a 422 in the console for every image on
35
+ * the page. Sizes are snapped here instead, so callers can keep expressing
36
+ * intent in real pixels.
37
+ */
38
+ export declare const THUMB_SIZES: readonly [64, 128, 256, 512, 1024];
26
39
  export declare function useFileBlobStore(): {
27
40
  getBlobUrl: (docId: string, uploadId: string) => Promise<string | null>;
28
41
  getThumbUrl: (docId: string, uploadId: string, opts?: ThumbOptions) => Promise<string | null>;
@@ -9,6 +9,17 @@ export function _destroyFileBlobStore() {
9
9
  _store?.destroy();
10
10
  _store = null;
11
11
  }
12
+ export const THUMB_SIZES = [64, 128, 256, 512, 1024];
13
+ function snapSize(px) {
14
+ if (!px || px <= 0) return void 0;
15
+ return THUMB_SIZES.find((s) => s >= px) ?? THUMB_SIZES[THUMB_SIZES.length - 1];
16
+ }
17
+ function snapOpts(opts) {
18
+ const w = snapSize(opts.w);
19
+ const h = snapSize(opts.h);
20
+ if (w === opts.w && h === opts.h) return opts;
21
+ return { ...opts, ...w !== void 0 ? { w } : {}, ...h !== void 0 ? { h } : {} };
22
+ }
12
23
  export function useFileBlobStore() {
13
24
  async function getBlobUrl(docId, uploadId) {
14
25
  if (!_store) return null;
@@ -16,10 +27,14 @@ export function useFileBlobStore() {
16
27
  }
17
28
  async function getThumbUrl(docId, uploadId, opts = {}) {
18
29
  if (!_store) return null;
19
- return await _store.getThumbUrl?.(docId, uploadId, opts) ?? null;
30
+ try {
31
+ return await _store.getThumbUrl?.(docId, uploadId, snapOpts(opts)) ?? null;
32
+ } catch {
33
+ return null;
34
+ }
20
35
  }
21
36
  function invalidateThumbUrl(docId, uploadId, opts = {}) {
22
- _store?.invalidateThumbUrl?.(docId, uploadId, opts);
37
+ _store?.invalidateThumbUrl?.(docId, uploadId, snapOpts(opts));
23
38
  }
24
39
  async function putBlob(docId, id, file, filename) {
25
40
  if (!_store) return;
@@ -7,6 +7,30 @@
7
7
  *
8
8
  * Usage:
9
9
  * const { notifications, unreadCount, fetchNotifications, markRead } = useNotifications()
10
+ *
11
+ * ## Wire protocol — `messages:inbox_*` (NOT the old `notify:*`)
12
+ *
13
+ * abracadabra-rs collapsed the `chat:*` and `notify:*` stateless dialects into
14
+ * one unified `messages:*` subsystem (`crates/abracadabra/src/messages.rs`:
15
+ * "Replaces the old chat:* and notify:* dispatchers"). Nothing in the server
16
+ * answers `notify:fetch` / `notify:mark_read` / `notify:create` any more, and
17
+ * `sendStateless` is fire-and-forget — so this composable sat there sending
18
+ * into the void and reporting "all caught up" forever. Found while auditing
19
+ * abracadabra-atrium, whose inbox was permanently empty.
20
+ *
21
+ * A notification is now an `InboxEntry` on the caller's own `kind = "inbox"`
22
+ * doc, which the server writes as a side effect of `messages:send` fan-out
23
+ * (mentions + DM participants, consent-gated on read access). Requests:
24
+ *
25
+ * → `messages:inbox_fetch` { before?, limit?, unread_only? }
26
+ * ← `messages:inbox_history` { inbox_doc_id, entries: InboxEntry[] }
27
+ * → `messages:inbox_mark_read` { id | ids | source_id | all }
28
+ * ← `messages:ok` { source: "messages:inbox_mark_read" }
29
+ *
30
+ * There is no longer any "create a notification for an arbitrary user" call —
31
+ * `createNotification()` below emits a `messages:send` carrying the recipient
32
+ * in `mentions`, which is the supported path (service-role senders skip the
33
+ * channel role check, so a Nitro runner can fan out on a forum's behalf).
10
34
  */
11
35
  export type NotificationType = 'chat' | 'agent' | 'mention' | 'system';
12
36
  export interface AppNotification {
@@ -31,8 +55,25 @@ declare function fetchNotifications(opts?: {
31
55
  }): void;
32
56
  declare function markRead(id: string): void;
33
57
  declare function markAllRead(): void;
58
+ /**
59
+ * Deliver a notification to `recipientId`.
60
+ *
61
+ * There is no "write an arbitrary notification" server API any more. Inbox
62
+ * entries are produced by `messages:send` fan-out, so this posts a message on
63
+ * `channelDocId` naming the recipient in `mentions` — the server then resolves
64
+ * the recipient's read access to that channel (consent gate) and writes the
65
+ * inbox entry itself.
66
+ *
67
+ * `channelDocId` is REQUIRED: without a channel there is nothing to fan out
68
+ * from. Pass the doc the notification is *about* (a forum, a thread, a space) —
69
+ * any doc the caller can write becomes a chat container server-side.
70
+ *
71
+ * `title` is not carried on the wire (the inbox stores who/where/when +
72
+ * preview and the UI synthesises a title), so it's folded into the body.
73
+ */
34
74
  declare function createNotification(opts: {
35
75
  recipientId: string;
76
+ channelDocId: string;
36
77
  type?: NotificationType;
37
78
  title: string;
38
79
  body: string;
@@ -33,14 +33,49 @@ function parseNotification(data) {
33
33
  createdAt: data.created_at ? new Date(data.created_at).getTime() : Date.now()
34
34
  };
35
35
  }
36
+ const INBOX_KIND_TO_TYPE = {
37
+ mention: "mention",
38
+ reply: "mention",
39
+ dm: "chat",
40
+ system: "system"
41
+ };
42
+ function inboxEntryToNotification(e) {
43
+ const who = typeof e.sender_name === "string" && e.sender_name ? e.sender_name : null;
44
+ const title = e.kind === "dm" ? who ? `Message from ${who}` : "New message" : e.kind === "mention" ? who ? `${who} mentioned you` : "You were mentioned" : e.kind === "reply" ? who ? `${who} replied` : "New reply" : "Notification";
45
+ return {
46
+ id: String(e.id),
47
+ type: INBOX_KIND_TO_TYPE[e.kind] ?? "system",
48
+ title,
49
+ body: e.preview ?? "",
50
+ icon: e.kind === "dm" ? "i-lucide-mail" : void 0,
51
+ // The channel doc the entry came from — enough for a consumer to route to
52
+ // it. Consumers wanting richer links resolve `channel_doc_id` themselves.
53
+ link: void 0,
54
+ sourceId: e.channel_doc_id ?? void 0,
55
+ read: e.read === true,
56
+ createdAt: typeof e.ts === "number" ? e.ts : Date.now()
57
+ };
58
+ }
36
59
  function isForMe(recipientId) {
37
60
  if (!recipientId) return true;
38
61
  return recipientId === _publicKeyB64.value;
39
62
  }
40
63
  export function _handleStatelessNotification(payload) {
41
- if (!payload.includes('"notify:')) return;
64
+ const isInbox = payload.includes('"messages:inbox_history"');
65
+ if (!isInbox && !payload.includes('"notify:')) return;
42
66
  try {
43
67
  const data = JSON.parse(payload);
68
+ if (data.type === "messages:inbox_history") {
69
+ lastError.value = null;
70
+ const incoming = (data.entries || []).map(inboxEntryToNotification);
71
+ const existingIds = new Set(notifications.value.map((n) => n.id));
72
+ const fresh = incoming.filter((n) => !existingIds.has(n.id));
73
+ notifications.value = [...notifications.value, ...fresh].sort((a, b) => b.createdAt - a.createdAt);
74
+ if (existingIds.size > 0) {
75
+ for (const n of fresh) if (!n.read) _scheduleToast(n);
76
+ }
77
+ return;
78
+ }
44
79
  if (!data.type?.startsWith("notify:")) return;
45
80
  lastError.value = null;
46
81
  switch (data.type) {
@@ -130,7 +165,7 @@ function fetchNotifications(opts) {
130
165
  const { provider } = useAbracadabra();
131
166
  if (!provider.value) return;
132
167
  provider.value.sendStateless(JSON.stringify({
133
- type: "notify:fetch",
168
+ type: "messages:inbox_fetch",
134
169
  before: opts?.before,
135
170
  limit: opts?.limit ?? 50,
136
171
  unread_only: opts?.unreadOnly ?? false
@@ -139,29 +174,32 @@ function fetchNotifications(opts) {
139
174
  function markRead(id) {
140
175
  const { provider } = useAbracadabra();
141
176
  if (provider.value) {
142
- provider.value.sendStateless(JSON.stringify({ type: "notify:mark_read", id }));
177
+ provider.value.sendStateless(JSON.stringify({ type: "messages:inbox_mark_read", id }));
143
178
  }
144
179
  notifications.value = notifications.value.map((n) => n.id === id ? { ...n, read: true } : n);
145
180
  }
146
181
  function markAllRead() {
147
182
  const { provider } = useAbracadabra();
148
183
  if (provider.value) {
149
- provider.value.sendStateless(JSON.stringify({ type: "notify:mark_all_read" }));
184
+ provider.value.sendStateless(JSON.stringify({ type: "messages:inbox_mark_read", all: true }));
150
185
  }
151
186
  notifications.value = notifications.value.map((n) => ({ ...n, read: true }));
152
187
  }
153
188
  function createNotification(opts) {
154
189
  const { provider } = useAbracadabra();
155
190
  if (!provider.value) return;
191
+ if (!opts.channelDocId) {
192
+ console.warn("[abracadabra] createNotification: channelDocId is required \u2014 inbox entries are produced by messages:send fan-out");
193
+ return;
194
+ }
195
+ const content = opts.title && opts.body ? `${opts.title} \u2014 ${opts.body}` : opts.body || opts.title;
156
196
  provider.value.sendStateless(JSON.stringify({
157
- type: "notify:create",
158
- recipient_id: opts.recipientId,
159
- notification_type: opts.type ?? "system",
160
- title: opts.title,
161
- body: opts.body,
162
- icon: opts.icon,
163
- link: opts.link,
164
- source_id: opts.sourceId
197
+ type: "messages:send",
198
+ id: crypto.randomUUID(),
199
+ channel_doc_id: opts.channelDocId,
200
+ content,
201
+ mentions: [opts.recipientId],
202
+ ts: Date.now()
165
203
  }));
166
204
  }
167
205
  export function useNotifications() {
@@ -33,7 +33,11 @@ export declare function useRendererBase(props: RendererBaseProps): {
33
33
  name?: string | undefined;
34
34
  color?: string | undefined;
35
35
  avatar?: string | undefined;
36
+ statusIcon?: string | undefined;
37
+ statusText?: string | undefined;
38
+ publicKey?: string | undefined;
36
39
  } | undefined;
40
+ docId?: string | undefined;
37
41
  };
38
42
  }[], {
39
43
  clientId: number;
@@ -51,7 +55,11 @@ export declare function useRendererBase(props: RendererBaseProps): {
51
55
  name?: string | undefined;
52
56
  color?: string | undefined;
53
57
  avatar?: string | undefined;
58
+ statusIcon?: string | undefined;
59
+ statusText?: string | undefined;
60
+ publicKey?: string | undefined;
54
61
  } | undefined;
62
+ docId?: string | undefined;
55
63
  };
56
64
  }[]>;
57
65
  states: import("vue").Ref<{
@@ -61,7 +69,11 @@ export declare function useRendererBase(props: RendererBaseProps): {
61
69
  name?: string | undefined;
62
70
  color?: string | undefined;
63
71
  avatar?: string | undefined;
72
+ statusIcon?: string | undefined;
73
+ statusText?: string | undefined;
74
+ publicKey?: string | undefined;
64
75
  } | undefined;
76
+ docId?: string | undefined;
65
77
  }[], import("./useYDoc.js").AwarenessUser[] | {
66
78
  [x: string]: any;
67
79
  clientId: number;
@@ -69,7 +81,11 @@ export declare function useRendererBase(props: RendererBaseProps): {
69
81
  name?: string | undefined;
70
82
  color?: string | undefined;
71
83
  avatar?: string | undefined;
84
+ statusIcon?: string | undefined;
85
+ statusText?: string | undefined;
86
+ publicKey?: string | undefined;
72
87
  } | undefined;
88
+ docId?: string | undefined;
73
89
  }[]>;
74
90
  setLocalState: (state: any) => void;
75
91
  tree: {
@@ -77,10 +93,11 @@ export declare function useRendererBase(props: RendererBaseProps): {
77
93
  childrenOf: (parentId: string | null) => import("./useChildTree.js").TreeEntry[];
78
94
  descendantsOf: (id: string) => import("./useChildTree.js").TreeEntry[];
79
95
  createChild: (parentId: string | null, label: string, type?: string) => string;
96
+ createChildRegistered: (parentId: string | null, label: string, type?: string) => Promise<string>;
80
97
  registerDoc: (id: string, parentId: string, opts?: {
81
98
  label?: string;
82
99
  type?: string;
83
- }) => void;
100
+ }) => Promise<void>;
84
101
  moveEntry: (id: string, newParentId: string | null, newOrder: number) => void;
85
102
  deleteEntry: (id: string) => void;
86
103
  renameEntry: (id: string, label: string) => void;
@@ -10,15 +10,8 @@
10
10
  */
11
11
  import { type Ref, type ShallowRef } from 'vue';
12
12
  import type * as Y from 'yjs';
13
- export interface AwarenessUser {
14
- clientId: number;
15
- user?: {
16
- name?: string;
17
- color?: string;
18
- avatar?: string;
19
- };
20
- [key: string]: any;
21
- }
13
+ import type { AwarenessUser } from '../types.js';
14
+ export type { AwarenessUser } from '../types.js';
22
15
  export declare function useSyncedMap<T = any>(doc: ShallowRef<Y.Doc | null>, mapName: string): {
23
16
  data: Record<string, T>;
24
17
  lastUpdateLocal: ShallowRef<boolean, boolean>;
@@ -57,7 +50,11 @@ export declare function useAwarenessOf(provider: ShallowRef<{
57
50
  name?: string | undefined;
58
51
  color?: string | undefined;
59
52
  avatar?: string | undefined;
53
+ statusIcon?: string | undefined;
54
+ statusText?: string | undefined;
55
+ publicKey?: string | undefined;
60
56
  } | undefined;
57
+ docId?: string | undefined;
61
58
  }[], AwarenessUser[] | {
62
59
  [x: string]: any;
63
60
  clientId: number;
@@ -65,7 +62,11 @@ export declare function useAwarenessOf(provider: ShallowRef<{
65
62
  name?: string | undefined;
66
63
  color?: string | undefined;
67
64
  avatar?: string | undefined;
65
+ statusIcon?: string | undefined;
66
+ statusText?: string | undefined;
67
+ publicKey?: string | undefined;
68
68
  } | undefined;
69
+ docId?: string | undefined;
69
70
  }[]>;
70
71
  currentUser: Ref<{
71
72
  [x: string]: any;
@@ -74,7 +75,11 @@ export declare function useAwarenessOf(provider: ShallowRef<{
74
75
  name?: string | undefined;
75
76
  color?: string | undefined;
76
77
  avatar?: string | undefined;
78
+ statusIcon?: string | undefined;
79
+ statusText?: string | undefined;
80
+ publicKey?: string | undefined;
77
81
  } | undefined;
82
+ docId?: string | undefined;
78
83
  } | null, AwarenessUser | {
79
84
  [x: string]: any;
80
85
  clientId: number;
@@ -82,7 +87,11 @@ export declare function useAwarenessOf(provider: ShallowRef<{
82
87
  name?: string | undefined;
83
88
  color?: string | undefined;
84
89
  avatar?: string | undefined;
90
+ statusIcon?: string | undefined;
91
+ statusText?: string | undefined;
92
+ publicKey?: string | undefined;
85
93
  } | undefined;
94
+ docId?: string | undefined;
86
95
  } | null>;
87
96
  setLocalState: (state: any) => void;
88
97
  };
@@ -100,7 +109,11 @@ export declare function useSmoothedCursors(provider: ShallowRef<{
100
109
  name?: string | undefined;
101
110
  color?: string | undefined;
102
111
  avatar?: string | undefined;
112
+ statusIcon?: string | undefined;
113
+ statusText?: string | undefined;
114
+ publicKey?: string | undefined;
103
115
  } | undefined;
116
+ docId?: string | undefined;
104
117
  };
105
118
  }[], {
106
119
  clientId: number;
@@ -118,7 +131,11 @@ export declare function useSmoothedCursors(provider: ShallowRef<{
118
131
  name?: string | undefined;
119
132
  color?: string | undefined;
120
133
  avatar?: string | undefined;
134
+ statusIcon?: string | undefined;
135
+ statusText?: string | undefined;
136
+ publicKey?: string | undefined;
121
137
  } | undefined;
138
+ docId?: string | undefined;
122
139
  };
123
140
  }[]>;
124
141
  states: Ref<{
@@ -128,7 +145,11 @@ export declare function useSmoothedCursors(provider: ShallowRef<{
128
145
  name?: string | undefined;
129
146
  color?: string | undefined;
130
147
  avatar?: string | undefined;
148
+ statusIcon?: string | undefined;
149
+ statusText?: string | undefined;
150
+ publicKey?: string | undefined;
131
151
  } | undefined;
152
+ docId?: string | undefined;
132
153
  }[], AwarenessUser[] | {
133
154
  [x: string]: any;
134
155
  clientId: number;
@@ -136,7 +157,11 @@ export declare function useSmoothedCursors(provider: ShallowRef<{
136
157
  name?: string | undefined;
137
158
  color?: string | undefined;
138
159
  avatar?: string | undefined;
160
+ statusIcon?: string | undefined;
161
+ statusText?: string | undefined;
162
+ publicKey?: string | undefined;
139
163
  } | undefined;
164
+ docId?: string | undefined;
140
165
  }[]>;
141
166
  setLocalState: (state: any) => void;
142
167
  };
@@ -2,6 +2,7 @@ import { shallowRef, ref, computed, watch } from "vue";
2
2
  import { defineNuxtPlugin, useRuntimeConfig, useAppConfig, navigateTo } from "#imports";
3
3
  import * as Y from "yjs";
4
4
  import { PluginRegistry } from "./plugin-registry.js";
5
+ import { setAmbientDocTypeRegistry } from "./utils/docTypes.js";
5
6
  import { corePlugin } from "./plugins/core.plugin.js";
6
7
  import {
7
8
  UI_COLORS,
@@ -228,6 +229,7 @@ export default defineNuxtPlugin({
228
229
  const pinServer = abraConfig.pinServer ?? false;
229
230
  const deferConnect = abraConfig.deferConnect ?? false;
230
231
  const registry = new PluginRegistry();
232
+ setAmbientDocTypeRegistry(registry);
231
233
  const storedDisabledBuiltins = JSON.parse(
232
234
  localStorage.getItem(STORAGE_KEY_DISABLED_BUILTINS) ?? "[]"
233
235
  );
@@ -1443,7 +1445,7 @@ export default defineNuxtPlugin({
1443
1445
  }
1444
1446
  }
1445
1447
  try {
1446
- _provider.sendStateless?.(JSON.stringify({ type: "notify:fetch", limit: 20 }));
1448
+ _provider.sendStateless?.(JSON.stringify({ type: "messages:inbox_fetch", limit: 20 }));
1447
1449
  } catch {
1448
1450
  }
1449
1451
  try {
@@ -1,9 +1,9 @@
1
1
  declare const _default: import("h3").EventHandler<Omit<import("h3").EventHandlerRequest, "body">, Promise<{
2
2
  docId: string;
3
3
  html: string;
4
- title: any;
5
- type: any;
6
- meta: any;
4
+ title: string;
5
+ type: string;
6
+ meta: Record<string, any>;
7
7
  description: any;
8
8
  ogImage: any;
9
9
  source: "crdt-cache";
@@ -2,6 +2,7 @@ import { createError, getRouterParam, getHeader } from "h3";
2
2
  import { defineCachedEventHandler } from "nitropack/runtime";
3
3
  import { useRuntimeConfig } from "nitropack/runtime/config";
4
4
  import { useStorage } from "nitropack/runtime/storage";
5
+ import { getCachedTreeEntry, resolveRootDocIdFromConfig } from "../../../utils/docCache.js";
5
6
  function extractFirstParagraph(html) {
6
7
  if (!html) return "";
7
8
  const pMatch = html.match(/<p[^>]*>(.*?)<\/p>/is);
@@ -31,12 +32,12 @@ export default defineCachedEventHandler(async (event) => {
31
32
  throw createError({ statusCode: 400, message: "docId is required" });
32
33
  }
33
34
  const storage = useStorage();
34
- const [cachedHtml, cachedJson] = await Promise.all([
35
+ const rootDocId = resolveRootDocIdFromConfig(config);
36
+ const [cachedHtml, treeEntry] = await Promise.all([
35
37
  storage.getItem(`doc-cache:html:${docId}`),
36
- storage.getItem(`doc-cache:json:${docId}`)
38
+ getCachedTreeEntry(docId, rootDocId)
37
39
  ]);
38
40
  if (cachedHtml !== null) {
39
- const treeEntry = cachedJson?.["doc-tree"]?.[docId] ?? {};
40
41
  const html2 = cachedHtml ?? "";
41
42
  return {
42
43
  docId,
@@ -2,9 +2,9 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
2
2
  docId: string;
3
3
  slug: string;
4
4
  html: string;
5
- title: any;
6
- type: any;
7
- meta: any;
5
+ title: string;
6
+ type: string;
7
+ meta: Record<string, any>;
8
8
  description: any;
9
9
  ogImage: any;
10
10
  source: "none" | "crdt-cache";
@@ -1,6 +1,7 @@
1
1
  import { defineEventHandler, getRouterParam, createError } from "h3";
2
2
  import { getDocIdFromSlug } from "../../../utils/slugMap.js";
3
- import { getCachedHTML, getCachedJSON } from "../../../utils/docCache.js";
3
+ import { useRuntimeConfig } from "nitropack/runtime/config";
4
+ import { getCachedHTML, getCachedTreeEntry, resolveRootDocIdFromConfig } from "../../../utils/docCache.js";
4
5
  function extractFirstParagraph(html) {
5
6
  if (!html) return "";
6
7
  const pMatch = html.match(/<p[^>]*>(.*?)<\/p>/is);
@@ -24,12 +25,12 @@ export default defineEventHandler(async (event) => {
24
25
  if (!docId) {
25
26
  throw createError({ statusCode: 404, message: `Document not found for slug: ${slug}` });
26
27
  }
27
- const [cachedHtml, cachedJson] = await Promise.all([
28
+ const rootDocId = resolveRootDocIdFromConfig(useRuntimeConfig());
29
+ const [cachedHtml, treeEntry] = await Promise.all([
28
30
  getCachedHTML(docId),
29
- getCachedJSON(docId)
31
+ getCachedTreeEntry(docId, rootDocId)
30
32
  ]);
31
33
  const html = cachedHtml ?? "";
32
- const treeEntry = cachedJson?.["doc-tree"]?.[docId] ?? {};
33
34
  return {
34
35
  docId,
35
36
  slug,
@@ -17,6 +17,50 @@ export declare function initDocCache(storage: NitroStorage, extraExtensions?: An
17
17
  export declare function renderDocToHTML(ydoc: Y.Doc): Promise<string | null>;
18
18
  export declare function getCachedHTML(docId: string): Promise<string | null>;
19
19
  export declare function getCachedJSON(docId: string): Promise<Record<string, unknown> | null>;
20
+ /** A doc's `doc-tree` entry: label, page type and meta. */
21
+ export interface CachedTreeEntry {
22
+ label?: string;
23
+ type?: string;
24
+ parentId?: string | null;
25
+ meta?: Record<string, any>;
26
+ }
27
+ /**
28
+ * The `doc-tree` entry for `docId`, read out of the ROOT doc's cache.
29
+ *
30
+ * ⚠️ The tree lives ONLY on the root/space doc. A child doc's own Y.Doc has no
31
+ * `doc-tree` map, so `getCachedJSON(childId)['doc-tree']` is always `undefined` —
32
+ * which is what the render + resolve endpoints used to do, making them return
33
+ * `title: ""`, `type: "doc"`, `meta: {}` for EVERY child document no matter how
34
+ * warm the cache was. (Symptom in abracadabra-atrium: every route SSR'd a
35
+ * placeholder `<h1>Thread</h1>` / `<title>Forum · Atrium</title>` and the client
36
+ * replaced it on hydration, producing a mismatch warning on every navigation.)
37
+ *
38
+ * Falls back to the doc's own json so this still works when `docId` IS the root.
39
+ */
40
+ export declare function getCachedTreeEntry(docId: string, rootDocId?: string | null): Promise<CachedTreeEntry>;
41
+ /**
42
+ * The root/space doc id as seen from a Nitro request handler.
43
+ *
44
+ * `ServerRunnerContext.rootDocId` isn't reachable here, so resolve it the same
45
+ * way the service plugin does: the explicit `service.rootDocId` override wins,
46
+ * then the module's `entryDocId`.
47
+ */
48
+ export declare function resolveRootDocIdFromConfig(config: {
49
+ abracadabra?: {
50
+ entryDocId?: string;
51
+ service?: {
52
+ rootDocId?: string;
53
+ };
54
+ };
55
+ public?: {
56
+ abracadabra?: {
57
+ entryDocId?: string;
58
+ service?: {
59
+ rootDocId?: string;
60
+ };
61
+ };
62
+ };
63
+ }): string | null;
20
64
  export declare function invalidateDoc(docId: string, ydoc?: Y.Doc): Promise<void>;
21
65
  /**
22
66
  * Start observing a Y.Doc for changes with debounced re-rendering.
@@ -70,13 +70,35 @@ function htmlKey(docId) {
70
70
  function jsonKey(docId) {
71
71
  return `doc-cache:json:${docId}`;
72
72
  }
73
+ async function readStorage() {
74
+ if (_storage) return _storage;
75
+ try {
76
+ const { useStorage } = await import("nitropack/runtime/storage");
77
+ return useStorage();
78
+ } catch {
79
+ return null;
80
+ }
81
+ }
73
82
  export async function getCachedHTML(docId) {
74
- if (!_storage) return null;
75
- return await _storage.getItem(htmlKey(docId)) ?? null;
83
+ const storage = await readStorage();
84
+ if (!storage) return null;
85
+ return await storage.getItem(htmlKey(docId)) ?? null;
76
86
  }
77
87
  export async function getCachedJSON(docId) {
78
- if (!_storage) return null;
79
- return await _storage.getItem(jsonKey(docId)) ?? null;
88
+ const storage = await readStorage();
89
+ if (!storage) return null;
90
+ return await storage.getItem(jsonKey(docId)) ?? null;
91
+ }
92
+ export async function getCachedTreeEntry(docId, rootDocId) {
93
+ const fromRoot = rootDocId ? (await getCachedJSON(rootDocId))?.["doc-tree"] : void 0;
94
+ if (fromRoot?.[docId]) return fromRoot[docId];
95
+ const own = (await getCachedJSON(docId))?.["doc-tree"];
96
+ return own?.[docId] ?? {};
97
+ }
98
+ export function resolveRootDocIdFromConfig(config) {
99
+ const pub = config.public?.abracadabra;
100
+ const priv = config.abracadabra;
101
+ return priv?.service?.rootDocId ?? pub?.service?.rootDocId ?? priv?.entryDocId ?? pub?.entryDocId ?? null;
80
102
  }
81
103
  export async function invalidateDoc(docId, ydoc) {
82
104
  if (!_storage) return;
@@ -145,6 +145,13 @@ export interface DocTreeHelper {
145
145
  childrenOf: (parentId: string | null) => TreeEntry[];
146
146
  descendantsOf: (id: string) => TreeEntry[];
147
147
  createChild: (parentId: string | null, label: string, type?: string) => string;
148
+ /**
149
+ * Like `createChild`, but awaits the doc's REST registration before writing
150
+ * the tree entry — so the `documents` row carries the correct `parent_id` and
151
+ * the permission cascade gets a real ancestor chain. Prefer it for content
152
+ * docs; see the implementation notes in useChildTree.ts.
153
+ */
154
+ createChildRegistered: (parentId: string | null, label: string, type?: string) => Promise<string>;
148
155
  moveEntry: (id: string, newParentId: string | null, newOrder: number) => void;
149
156
  deleteEntry: (id: string) => void;
150
157
  renameEntry: (id: string, label: string) => void;
@@ -187,6 +187,8 @@ export interface DocTypeDefinition {
187
187
  export declare const GEO_TYPE_META_SCHEMAS: Record<string, MetaField[]>;
188
188
  export declare const DOC_TYPES: Record<string, DocTypeDefinition>;
189
189
  export declare const DEFAULT_DOC_TYPE: DocTypeDefinition;
190
+ /** Publish the app's plugin registry as the fallback for registry-less calls. */
191
+ export declare function setAmbientDocTypeRegistry(registry: PluginRegistry | null): void;
190
192
  /** Resolve a type key to a DocTypeDefinition. Falls back to plugin types, then to 'doc'. */
191
193
  export declare function resolveDocType(typeKey: string | undefined, registry?: PluginRegistry): DocTypeDefinition;
192
194
  /** All available doc types, including plugin contributions. */
@@ -319,11 +319,16 @@ export const DOC_TYPES = {
319
319
  }
320
320
  };
321
321
  export const DEFAULT_DOC_TYPE = DOC_TYPES.doc;
322
+ let ambientRegistry = null;
323
+ export function setAmbientDocTypeRegistry(registry) {
324
+ ambientRegistry = registry;
325
+ }
322
326
  export function resolveDocType(typeKey, registry) {
323
327
  if (!typeKey) return DEFAULT_DOC_TYPE;
324
328
  if (DOC_TYPES[typeKey]) return DOC_TYPES[typeKey];
325
- if (registry) {
326
- const pluginTypes = registry.getAllPageTypes();
329
+ const reg = registry ?? ambientRegistry;
330
+ if (reg) {
331
+ const pluginTypes = reg.getAllPageTypes();
327
332
  if (pluginTypes[typeKey]) {
328
333
  const pt = pluginTypes[typeKey];
329
334
  return {
@@ -342,8 +347,9 @@ export function resolveDocType(typeKey, registry) {
342
347
  }
343
348
  export function getAvailableDocTypes(registry) {
344
349
  const all = { ...DOC_TYPES };
345
- if (registry) {
346
- for (const [key, pt] of Object.entries(registry.getAllPageTypes())) {
350
+ const reg = registry ?? ambientRegistry;
351
+ if (reg) {
352
+ for (const [key, pt] of Object.entries(reg.getAllPageTypes())) {
347
353
  all[key] = {
348
354
  key,
349
355
  label: pt.label,
@@ -91,7 +91,12 @@ export interface TitleSyncInput {
91
91
  * │ │ │ local + post-initial → tree-from- │
92
92
  * │ │ │ header('Untitled') (user emptied │
93
93
  * │ │ │ the title, so canonicalise) │
94
- * │ different │ different │ initial OR local → tree-from-header │
94
+ * │ different │ different │ initial → header-from-tree (the tree │
95
+ * │ │ │ label is canonical; a stale header │
96
+ * │ │ │ must not revert a rename made while │
97
+ * │ │ │ no editor was mounted) │
98
+ * │ │ │ local + post-initial → tree-from- │
99
+ * │ │ │ header (the user is typing the H1) │
95
100
  * │ │ │ remote + post-initial → noop (the │
96
101
  * │ │ │ label watcher reconciles header │
97
102
  * │ │ │ from tree if needed) │
@@ -24,7 +24,7 @@ export function decideTitleSync(input) {
24
24
  return { kind: "noop" };
25
25
  }
26
26
  if (!initialSyncDone) {
27
- return { kind: "tree-from-header", label: headerText };
27
+ return { kind: "header-from-tree", text: treeLabel };
28
28
  }
29
29
  if (!isRemoteUpdate) {
30
30
  return { kind: "tree-from-header", label: headerText };
package/dist/types.d.mts CHANGED
@@ -6,6 +6,8 @@ export { type DocTreeReturn } from '../dist/runtime/composables/useDocTree.js'
6
6
 
7
7
  export { type DocSeoOptions } from '../dist/runtime/composables/useDocSeo.js'
8
8
 
9
+ export { type AppNotification, type NotificationType } from '../dist/runtime/composables/useNotifications.js'
10
+
9
11
  export { type DocDragState } from '../dist/runtime/composables/useDocDragBus.js'
10
12
 
11
13
  export { type ParsedMessage, type TextSegment, type parseMessageContent, type previewMessageContent, type renderMessageSegments } from '../dist/runtime/utils/chatContent.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/nuxt",
3
- "version": "2.73.0",
3
+ "version": "2.75.0",
4
4
  "description": "First-class Nuxt module for the Abracadabra CRDT collaboration platform",
5
5
  "repository": "abracadabra/abracadabra-nuxt",
6
6
  "license": "MIT",