@abraca/nuxt 2.95.0 → 2.97.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 (54) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/ADocSubPageList.vue +8 -0
  3. package/dist/runtime/components/ANodePanel.vue +11 -1
  4. package/dist/runtime/components/ANodePanelStack.d.vue.ts +19 -0
  5. package/dist/runtime/components/ANodePanelStack.vue +35 -0
  6. package/dist/runtime/components/ANodePanelStack.vue.d.ts +19 -0
  7. package/dist/runtime/components/APresence.d.vue.ts +1 -13
  8. package/dist/runtime/components/APresence.vue.d.ts +1 -13
  9. package/dist/runtime/components/ATagsPopover.d.vue.ts +34 -0
  10. package/dist/runtime/components/ATagsPopover.vue +114 -0
  11. package/dist/runtime/components/ATagsPopover.vue.d.ts +34 -0
  12. package/dist/runtime/components/chat/AChatMessages.d.vue.ts +14 -0
  13. package/dist/runtime/components/chat/AChatMessages.vue +94 -14
  14. package/dist/runtime/components/chat/AChatMessages.vue.d.ts +14 -0
  15. package/dist/runtime/components/chat/AChatPanel.d.vue.ts +10 -0
  16. package/dist/runtime/components/chat/AChatPanel.vue +5 -1
  17. package/dist/runtime/components/chat/AChatPanel.vue.d.ts +10 -0
  18. package/dist/runtime/components/chat/ANodeChatPanel.d.vue.ts +10 -3
  19. package/dist/runtime/components/chat/ANodeChatPanel.vue +6 -2
  20. package/dist/runtime/components/chat/ANodeChatPanel.vue.d.ts +10 -3
  21. package/dist/runtime/components/docs/ADocsSearch.d.vue.ts +2 -2
  22. package/dist/runtime/components/docs/ADocsSearch.vue.d.ts +2 -2
  23. package/dist/runtime/components/docs/ADocsSearchButton.d.vue.ts +1 -1
  24. package/dist/runtime/components/docs/ADocsSearchButton.vue.d.ts +1 -1
  25. package/dist/runtime/components/editor/AMetaChip.vue +18 -16
  26. package/dist/runtime/components/settings/ASettingsAboutPanel.d.vue.ts +3 -0
  27. package/dist/runtime/components/settings/ASettingsAboutPanel.vue +143 -0
  28. package/dist/runtime/components/settings/ASettingsAboutPanel.vue.d.ts +3 -0
  29. package/dist/runtime/components/settings/ASettingsConnectionPanel.vue +65 -100
  30. package/dist/runtime/components/settings/ASettingsModal.vue +7 -2
  31. package/dist/runtime/components/settings/sections.d.ts +28 -2
  32. package/dist/runtime/components/settings/sections.js +23 -0
  33. package/dist/runtime/components/shell/AUserMenu.d.vue.ts +2 -2
  34. package/dist/runtime/components/shell/AUserMenu.vue.d.ts +2 -2
  35. package/dist/runtime/composables/awarenessView.d.ts +46 -0
  36. package/dist/runtime/composables/awarenessView.js +65 -0
  37. package/dist/runtime/composables/useAwareness.js +19 -28
  38. package/dist/runtime/composables/useAwarenessPeers.d.ts +1 -25
  39. package/dist/runtime/composables/useChat.d.ts +21 -0
  40. package/dist/runtime/composables/useChat.js +77 -3
  41. package/dist/runtime/composables/useDocOpen.d.ts +69 -0
  42. package/dist/runtime/composables/useDocOpen.js +158 -0
  43. package/dist/runtime/composables/useRendererBase.d.ts +1 -25
  44. package/dist/runtime/composables/useSettingsModal.d.ts +1 -1
  45. package/dist/runtime/composables/useSpaceConnections.js +1 -60
  46. package/dist/runtime/composables/useYDoc.d.ts +3 -75
  47. package/dist/runtime/composables/useYDoc.js +28 -33
  48. package/dist/runtime/extensions/views/DocLinkView.vue +15 -5
  49. package/dist/runtime/extensions/views/MetaFieldView.vue +61 -49
  50. package/dist/runtime/locale.d.ts +2 -0
  51. package/dist/runtime/locale.js +1 -0
  52. package/dist/runtime/utils/observeYMap.d.ts +44 -0
  53. package/dist/runtime/utils/observeYMap.js +86 -0
  54. package/package.json +5 -5
@@ -6,7 +6,7 @@ import AColorPalettePopover from "../../components/editor/AColorPalettePopover.v
6
6
  import AIconPickerPopover from "../../components/editor/AIconPickerPopover.vue";
7
7
  import ALocationPickerPopover from "../../components/editor/ALocationPickerPopover.vue";
8
8
  import AMetaNumberStepper from "../../components/editor/AMetaNumberStepper.vue";
9
- import ATagsEditor from "../../components/ATagsEditor.vue";
9
+ import ATagsPopover from "../../components/ATagsPopover.vue";
10
10
  import { useAbraLocale } from "../../composables/useAbraLocale";
11
11
  import {
12
12
  DateFormatter,
@@ -562,7 +562,7 @@ function removeOption(opt) {
562
562
  color="neutral"
563
563
  variant="ghost"
564
564
  icon="i-lucide-calendar"
565
- class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
565
+ class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
566
566
  >
567
567
  {{ formatDateRange(startKey, endKey) }}
568
568
  </UButton>
@@ -606,11 +606,15 @@ function removeOption(opt) {
606
606
  </template>
607
607
  </UPopover>
608
608
 
609
+ <!-- The chip's own surface when it is OFF, so it matches the date chip
610
+ beside it instead of being two words lying on the page. When it is
611
+ on, `variant="soft"` paints its own. -->
609
612
  <UButton
610
613
  size="sm"
611
614
  :color="getBool(allDayKey, true) ? 'primary' : 'neutral'"
612
615
  :variant="getBool(allDayKey, true) ? 'soft' : 'ghost'"
613
- class="h-7 px-2.5 py-1 text-sm"
616
+ class="h-7 px-2.5 py-1 text-sm rounded-md"
617
+ :class="getBool(allDayKey, true) ? '' : 'border border-(--ui-border) bg-(--ui-bg) hover:bg-(--ui-bg-elevated)'"
614
618
  @click="toggleAllDay"
615
619
  >
616
620
  {{ t.allDay }}
@@ -629,7 +633,7 @@ function removeOption(opt) {
629
633
  color="neutral"
630
634
  variant="ghost"
631
635
  icon="i-lucide-calendar-range"
632
- class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
636
+ class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
633
637
  >
634
638
  {{ formatDateRange(startKey, endKey) }}
635
639
  </UButton>
@@ -648,7 +652,7 @@ function removeOption(opt) {
648
652
  <template v-else-if="fieldType === 'slider'">
649
653
  <!-- mousedown.stop prevents TipTap drag-handle from hijacking slider drags -->
650
654
  <div
651
- class="flex items-center gap-2 h-7 px-2.5 border border-(--ui-border) rounded-md text-sm"
655
+ class="flex items-center gap-2 h-7 px-2.5 border border-(--ui-border) rounded-md bg-(--ui-bg) text-sm"
652
656
  @mousedown.stop
653
657
  @touchstart.stop
654
658
  @wheel.prevent="onSliderWheel"
@@ -696,7 +700,7 @@ function removeOption(opt) {
696
700
  size="sm"
697
701
  color="neutral"
698
702
  variant="ghost"
699
- class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
703
+ class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
700
704
  >
701
705
  <span
702
706
  class="size-3 rounded-full shrink-0 ring-1 ring-(--ui-border)"
@@ -726,7 +730,7 @@ function removeOption(opt) {
726
730
  color="neutral"
727
731
  variant="ghost"
728
732
  :icon="getOptNum(latKey) !== void 0 ? 'i-lucide-map-pin' : 'i-lucide-map-pin-off'"
729
- class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
733
+ class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
730
734
  >
731
735
  <span
732
736
  v-if="fieldLabel && getOptNum(latKey) === void 0"
@@ -755,7 +759,7 @@ function removeOption(opt) {
755
759
  size="sm"
756
760
  color="neutral"
757
761
  variant="ghost"
758
- class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) gap-1.5"
762
+ class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) gap-1.5"
759
763
  :icon="getStr(metaKey) ? `i-lucide-${getStr(metaKey)}` : 'i-lucide-smile'"
760
764
  >
761
765
  <span
@@ -777,7 +781,7 @@ function removeOption(opt) {
777
781
  color="neutral"
778
782
  variant="ghost"
779
783
  icon="i-lucide-text"
780
- class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
784
+ class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
781
785
  >
782
786
  <span
783
787
  v-if="fieldLabel"
@@ -861,7 +865,7 @@ function removeOption(opt) {
861
865
 
862
866
  <!-- ── toggle ─────────────────────────────────────────────────────────── -->
863
867
  <template v-else-if="fieldType === 'toggle'">
864
- <div class="flex items-center gap-2 h-7 px-2.5 border border-(--ui-border) rounded-md text-sm">
868
+ <div class="flex items-center gap-2 h-7 px-2.5 border border-(--ui-border) rounded-md bg-(--ui-bg) text-sm">
865
869
  <template v-if="fieldLabel">
866
870
  <input
867
871
  v-if="editingLabel"
@@ -899,7 +903,7 @@ function removeOption(opt) {
899
903
  variant="ghost"
900
904
  icon="i-lucide-chevron-down"
901
905
  trailing
902
- class="h-7 px-2.5 border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated) min-w-28"
906
+ class="h-7 px-2.5 border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated) min-w-28"
903
907
  >
904
908
  <span :class="selectChipLabel ? '' : 'text-(--ui-text-dimmed)'">
905
909
  {{ selectChipLabel || fieldLabel || t.select }}
@@ -975,7 +979,7 @@ function removeOption(opt) {
975
979
  variant="ghost"
976
980
  icon="i-lucide-chevron-down"
977
981
  trailing
978
- class="h-7 px-2.5 border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated) min-w-28"
982
+ class="h-7 px-2.5 border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated) min-w-28"
979
983
  >
980
984
  <span :class="multiSelectChipValues.length ? '' : 'text-(--ui-text-dimmed)'">
981
985
  {{ multiSelectChipValues.length ? multiSelectChipLabel : fieldLabel || t.select }}
@@ -1041,7 +1045,7 @@ function removeOption(opt) {
1041
1045
  <!-- ── url ────────────────────────────────────────────────────────────── -->
1042
1046
  <template v-else-if="fieldType === 'url'">
1043
1047
  <div
1044
- class="flex items-center gap-1 h-7 px-2.5 border border-(--ui-border) rounded-md text-sm"
1048
+ class="flex items-center gap-1 h-7 px-2.5 border border-(--ui-border) rounded-md bg-(--ui-bg) text-sm"
1045
1049
  @mousedown.stop
1046
1050
  >
1047
1051
  <UIcon
@@ -1062,7 +1066,7 @@ function removeOption(opt) {
1062
1066
 
1063
1067
  <!-- ── rating ─────────────────────────────────────────────────────────── -->
1064
1068
  <template v-else-if="fieldType === 'rating'">
1065
- <div class="inline-flex items-center gap-1.5 h-7 px-2">
1069
+ <div class="inline-flex items-center gap-1.5 h-7 px-2.5 border border-(--ui-border) rounded-md bg-(--ui-bg)">
1066
1070
  <template v-if="fieldLabel">
1067
1071
  <input
1068
1072
  v-if="editingLabel"
@@ -1103,38 +1107,46 @@ function removeOption(opt) {
1103
1107
 
1104
1108
  <!-- ── tags ───────────────────────────────────────────────────────────── -->
1105
1109
  <template v-else-if="fieldType === 'tags'">
1106
- <!-- A CHIP, like every other field in this header, not a bare
1107
- `<UInputTags>`. The input was the one control here that was a form
1108
- field rather than a chip: it took a fixed width whether or not the
1109
- document had tags, sat a head taller than its neighbours, and read
1110
- as a second, unrelated meta editor next to the renderer's own
1111
- `<AMetaChip>` row. Same recipe as the chip now — button plus the
1112
- shared `<ATagsEditor>` MODAL, which is also why this is not a
1113
- popover: an `<UInputTags>` inside one loses its focus to the
1114
- popover's focus trap on the first Enter. -->
1115
- <UButton
1116
- size="sm"
1117
- color="neutral"
1118
- variant="ghost"
1119
- icon="i-lucide-tags"
1120
- class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
1121
- @click="isEditable && (tagsModalOpen = true)"
1122
- >
1123
- <span
1124
- v-if="fieldLabel"
1125
- class="text-(--ui-text-muted) text-xs"
1126
- >{{ fieldLabel }}</span>
1127
- <span
1128
- class="max-w-44 truncate"
1129
- :class="tagList.length ? '' : 'text-(--ui-text-muted)'"
1130
- >{{ tagList.length ? tagList.join(", ") : t.addTag }}</span>
1131
- </UButton>
1132
- <ATagsEditor
1110
+ <!-- A CHIP with a POPOVER, like every other field in this header.
1111
+ Two corrections, in order.
1112
+
1113
+ First it was a bare `<UInputTags>` — the one control here that was a
1114
+ form field rather than a chip: a fixed width whether or not the
1115
+ document had tags, a head taller than its neighbours, reading as a
1116
+ second unrelated meta editor beside the renderer's own `<AMetaChip>`
1117
+ row. Then it was a chip that opened the shared `<ATagsEditor>`
1118
+ MODAL, because an `<UInputTags>` inside a popover loses its focus to
1119
+ the popover's focus scope on the first Enter.
1120
+
1121
+ That reason was real and is now answered rather than worked around:
1122
+ `<ATagsPopover>` does not use `<UInputTags>` at all. Its chips and
1123
+ its input are its own markup, nothing inside it moves focus, and it
1124
+ commits on every add and remove — so tags open, behave and close
1125
+ exactly like the date, the colour and the select beside them. -->
1126
+ <ATagsPopover
1133
1127
  v-model:open="tagsModalOpen"
1134
1128
  :tags="tagList"
1135
- :title="fieldLabel ? `Edit ${fieldLabel.toLowerCase()}` : 'Edit tags'"
1129
+ :title="fieldLabel || t.tags"
1130
+ :disabled="!isEditable"
1136
1131
  @save="onTagsSave"
1137
- />
1132
+ >
1133
+ <UButton
1134
+ size="sm"
1135
+ color="neutral"
1136
+ variant="ghost"
1137
+ icon="i-lucide-tags"
1138
+ class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
1139
+ >
1140
+ <span
1141
+ v-if="fieldLabel"
1142
+ class="text-(--ui-text-muted) text-xs"
1143
+ >{{ fieldLabel }}</span>
1144
+ <span
1145
+ class="max-w-44 truncate"
1146
+ :class="tagList.length ? '' : 'text-(--ui-text-muted)'"
1147
+ >{{ tagList.length ? tagList.join(", ") : t.addTag }}</span>
1148
+ </UButton>
1149
+ </ATagsPopover>
1138
1150
  </template>
1139
1151
 
1140
1152
  <!-- ── colorPicker ────────────────────────────────────────────────────── -->
@@ -1144,7 +1156,7 @@ function removeOption(opt) {
1144
1156
  size="sm"
1145
1157
  color="neutral"
1146
1158
  variant="ghost"
1147
- class="h-7 px-2.5 border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
1159
+ class="h-7 px-2.5 border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)"
1148
1160
  >
1149
1161
  <span
1150
1162
  class="size-3 rounded-full shrink-0 ring-1 ring-(--ui-border)"
@@ -1177,7 +1189,7 @@ function removeOption(opt) {
1177
1189
  color="neutral"
1178
1190
  variant="ghost"
1179
1191
  icon="i-lucide-calendar-clock"
1180
- class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
1192
+ class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
1181
1193
  @wheel.prevent="(e) => onDateWheel(e, metaKey)"
1182
1194
  >
1183
1195
  {{ getStr(metaKey) ? df.format(new Date(getStr(metaKey))) : fieldLabel || t.pickDatetime }}
@@ -1212,7 +1224,7 @@ function removeOption(opt) {
1212
1224
  color="neutral"
1213
1225
  variant="ghost"
1214
1226
  icon="i-lucide-calendar"
1215
- class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
1227
+ class="h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
1216
1228
  @wheel.prevent="(e) => onDateWheel(e, metaKey)"
1217
1229
  >
1218
1230
  {{ getStr(metaKey) ? df.format(isoToCalendarDate(getStr(metaKey)).toDate(getLocalTimeZone())) : fieldLabel || t.pickDate }}
@@ -1238,7 +1250,7 @@ function removeOption(opt) {
1238
1250
  color="neutral"
1239
1251
  variant="ghost"
1240
1252
  icon="i-lucide-clock"
1241
- class="h-7 px-2.5 border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
1253
+ class="h-7 px-2.5 border border-(--ui-border) rounded-md bg-(--ui-bg) hover:bg-(--ui-bg-elevated) data-[state=open]:bg-(--ui-bg-elevated)"
1242
1254
  @wheel.prevent="(e) => onTimeWheel(e, metaKey)"
1243
1255
  >
1244
1256
  {{ getStr(metaKey) || fieldLabel || t.pickTime }}
@@ -1258,7 +1270,7 @@ function removeOption(opt) {
1258
1270
  <!-- ── timerange ──────────────────────────────────────────────────────── -->
1259
1271
  <template v-else-if="fieldType === 'timerange'">
1260
1272
  <div
1261
- class="flex items-center gap-2 h-7 px-2"
1273
+ class="flex items-center gap-2 h-7 px-2.5 border border-(--ui-border) rounded-md bg-(--ui-bg)"
1262
1274
  @mousedown.stop
1263
1275
  @touchstart.stop
1264
1276
  >
@@ -1303,7 +1315,7 @@ function removeOption(opt) {
1303
1315
  :content="{ align: 'start' }"
1304
1316
  >
1305
1317
  <div
1306
- class="flex items-center gap-1 min-h-7 px-1.5 border border-(--ui-border) rounded-md cursor-pointer hover:bg-(--ui-bg-elevated)"
1318
+ class="flex items-center gap-1 min-h-7 px-1.5 border border-(--ui-border) rounded-md bg-(--ui-bg) cursor-pointer hover:bg-(--ui-bg-elevated)"
1307
1319
  @mousedown.stop
1308
1320
  >
1309
1321
  <template v-if="getObjArr(metaKey).length">
@@ -44,6 +44,8 @@ export interface AbracadabraLocale {
44
44
  searchMembers: string;
45
45
  noMembersFound: string;
46
46
  addTag: string;
47
+ /** Heading of the tags popover, when the field declares no label of its own. */
48
+ tags: string;
47
49
  dragToReorder: string;
48
50
  deleteField: string;
49
51
  copied: string;
@@ -30,6 +30,7 @@ export const DEFAULT_LOCALE = {
30
30
  searchMembers: "Search members\u2026",
31
31
  noMembersFound: "No members found",
32
32
  addTag: "Add tag\u2026",
33
+ tags: "Tags",
33
34
  dragToReorder: "Drag to reorder",
34
35
  deleteField: "Delete field",
35
36
  copied: "Copied"
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Incremental Y.Map → Vue ref mirror.
3
+ *
4
+ * Lives in `utils/` rather than `composables/` on purpose: the composables
5
+ * directory is auto-imported wholesale, and this is an internal primitive, not
6
+ * an app-facing composable. Keeping it here also makes it unit-testable without
7
+ * standing up a provider.
8
+ */
9
+ import { type Ref } from 'vue';
10
+ import * as Y from 'yjs';
11
+ /**
12
+ * Observe a top-level Y.Map and mirror it into a Vue ref. Uses `observeDeep`
13
+ * (not a shallow `observe`) so per-key writes INSIDE a nested entry Y.Map — the
14
+ * shape of every doc-tree entry — are caught; a shallow observe goes stale on
15
+ * remote edits to existing entries. Local writes flush synchronously (DnD,
16
+ * typing); remote writes batch per animation frame.
17
+ *
18
+ * ## Why this is incremental
19
+ *
20
+ * It used to re-serialise the WHOLE map on every change: `forEach` + `toJSON()`
21
+ * per entry, building a brand-new object for every key. In a space with a few
22
+ * thousand documents, a single `updatedAt` write rebuilt every one of them —
23
+ * and `TreeTimestamps` writes `updatedAt` to the root every 5 s while anyone is
24
+ * typing, so one person typing paid that cost on every peer, once per connected
25
+ * space. Local transactions bypassed the rAF batch entirely, so the O(n) walk
26
+ * ran synchronously on the main thread mid-keystroke.
27
+ *
28
+ * Now only the entries an event actually touched are re-serialised. Two effects,
29
+ * both wanted:
30
+ *
31
+ * 1. The work is O(changed), not O(tree). A timestamp write costs one entry.
32
+ * 2. **Untouched entries keep their object identity.** Every consumer that
33
+ * renders `treeData` in a `v-for`, or derives from it, previously saw every
34
+ * entry as a brand-new object on every change and re-rendered the lot.
35
+ *
36
+ * `observeDeep` reports a write inside an entry with `path[0]` set to that
37
+ * entry's key, and a write to the map itself with an empty path plus
38
+ * `changes.keys` — so the dirty set is exact, and a deletion is simply a key
39
+ * that no longer resolves.
40
+ */
41
+ export declare function observeYMap<T>(doc: Y.Doc, mapName: string): {
42
+ data: Ref<Record<string, T>>;
43
+ cleanup: () => void;
44
+ };
@@ -0,0 +1,86 @@
1
+ import { ref } from "vue";
2
+ import * as Y from "yjs";
3
+ export function observeYMap(doc, mapName) {
4
+ const ymap = doc.getMap(mapName);
5
+ const data = ref({});
6
+ const serialize = (val) => val instanceof Y.Map ? val.toJSON() : val;
7
+ const snapshot = () => {
8
+ const obj = {};
9
+ ymap.forEach((val, key) => {
10
+ obj[key] = serialize(val);
11
+ });
12
+ return obj;
13
+ };
14
+ data.value = snapshot();
15
+ const dirty = /* @__PURE__ */ new Set();
16
+ const collect = (events) => {
17
+ for (const event of events) {
18
+ if (event.path.length === 0) {
19
+ for (const key of event.changes.keys.keys()) dirty.add(key);
20
+ } else {
21
+ dirty.add(String(event.path[0]));
22
+ }
23
+ }
24
+ };
25
+ const applyDirty = () => {
26
+ if (dirty.size === 0) return;
27
+ const next = { ...data.value };
28
+ for (const key of dirty) {
29
+ const val = ymap.get(key);
30
+ if (val === void 0) Reflect.deleteProperty(next, key);
31
+ else next[key] = serialize(val);
32
+ }
33
+ dirty.clear();
34
+ data.value = next;
35
+ };
36
+ let rafId = null;
37
+ const flush = () => {
38
+ rafId = null;
39
+ applyDirty();
40
+ };
41
+ const observer = (events, transaction) => {
42
+ collect(events);
43
+ if (transaction.local) {
44
+ if (rafId !== null) {
45
+ cancelAnimationFrame(rafId);
46
+ rafId = null;
47
+ }
48
+ applyDirty();
49
+ } else if (typeof requestAnimationFrame !== "undefined") {
50
+ if (rafId === null) rafId = requestAnimationFrame(flush);
51
+ } else {
52
+ applyDirty();
53
+ }
54
+ };
55
+ ymap.observeDeep(observer);
56
+ const onVisibilityChange = () => {
57
+ if (typeof document !== "undefined" && !document.hidden) {
58
+ if (rafId !== null) {
59
+ cancelAnimationFrame(rafId);
60
+ rafId = null;
61
+ }
62
+ applyDirty();
63
+ }
64
+ };
65
+ if (typeof document !== "undefined") {
66
+ document.addEventListener("visibilitychange", onVisibilityChange);
67
+ }
68
+ queueMicrotask(() => {
69
+ data.value = snapshot();
70
+ });
71
+ const cleanup = () => {
72
+ try {
73
+ ymap.unobserveDeep(observer);
74
+ } catch {
75
+ }
76
+ if (rafId !== null) {
77
+ cancelAnimationFrame(rafId);
78
+ rafId = null;
79
+ }
80
+ dirty.clear();
81
+ if (typeof document !== "undefined") {
82
+ document.removeEventListener("visibilitychange", onVisibilityChange);
83
+ }
84
+ };
85
+ return { data, cleanup };
86
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/nuxt",
3
- "version": "2.95.0",
3
+ "version": "2.97.0",
4
4
  "description": "First-class Nuxt module for the Abracadabra CRDT collaboration platform",
5
5
  "repository": "abracadabra/abracadabra-nuxt",
6
6
  "license": "MIT",
@@ -173,10 +173,10 @@
173
173
  }
174
174
  },
175
175
  "devDependencies": {
176
- "@abraca/convert": "^2.93.0",
177
- "@abraca/dabra": "^2.93.0",
178
- "@abraca/plugin": "^2.93.0",
179
- "@abraca/schema": "^2.93.0",
176
+ "@abraca/convert": "^2.96.0",
177
+ "@abraca/dabra": "^2.96.0",
178
+ "@abraca/plugin": "^2.96.0",
179
+ "@abraca/schema": "^2.96.0",
180
180
  "@codemirror/autocomplete": "^6.18.0",
181
181
  "@codemirror/commands": "^6.7.0",
182
182
  "@codemirror/lang-css": "^6.3.1",