@abraca/nuxt 0.1.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 (299) hide show
  1. package/README.md +84 -0
  2. package/dist/module.d.mts +201 -0
  3. package/dist/module.json +12 -0
  4. package/dist/module.mjs +170 -0
  5. package/dist/runtime/components/ACollaborationUsers.d.vue.ts +11 -0
  6. package/dist/runtime/components/ACollaborationUsers.vue +48 -0
  7. package/dist/runtime/components/ACollaborationUsers.vue.d.ts +11 -0
  8. package/dist/runtime/components/AColorPicker.d.vue.ts +13 -0
  9. package/dist/runtime/components/AColorPicker.vue +71 -0
  10. package/dist/runtime/components/AColorPicker.vue.d.ts +13 -0
  11. package/dist/runtime/components/ACommandPalette.d.vue.ts +13 -0
  12. package/dist/runtime/components/ACommandPalette.vue +31 -0
  13. package/dist/runtime/components/ACommandPalette.vue.d.ts +13 -0
  14. package/dist/runtime/components/AConnectionStatus.d.vue.ts +13 -0
  15. package/dist/runtime/components/AConnectionStatus.vue +50 -0
  16. package/dist/runtime/components/AConnectionStatus.vue.d.ts +13 -0
  17. package/dist/runtime/components/ADocTypeSelect.d.vue.ts +10 -0
  18. package/dist/runtime/components/ADocTypeSelect.vue +34 -0
  19. package/dist/runtime/components/ADocTypeSelect.vue.d.ts +10 -0
  20. package/dist/runtime/components/ADocumentTree.d.vue.ts +53 -0
  21. package/dist/runtime/components/ADocumentTree.vue +350 -0
  22. package/dist/runtime/components/ADocumentTree.vue.d.ts +53 -0
  23. package/dist/runtime/components/AEditor.d.vue.ts +60 -0
  24. package/dist/runtime/components/AEditor.vue +174 -0
  25. package/dist/runtime/components/AEditor.vue.d.ts +60 -0
  26. package/dist/runtime/components/AFloatingWindow.d.vue.ts +24 -0
  27. package/dist/runtime/components/AFloatingWindow.vue +232 -0
  28. package/dist/runtime/components/AFloatingWindow.vue.d.ts +24 -0
  29. package/dist/runtime/components/AIconPicker.d.vue.ts +13 -0
  30. package/dist/runtime/components/AIconPicker.vue +257 -0
  31. package/dist/runtime/components/AIconPicker.vue.d.ts +13 -0
  32. package/dist/runtime/components/ANodePanel.d.vue.ts +15 -0
  33. package/dist/runtime/components/ANodePanel.vue +541 -0
  34. package/dist/runtime/components/ANodePanel.vue.d.ts +15 -0
  35. package/dist/runtime/components/ANotifications.d.vue.ts +7 -0
  36. package/dist/runtime/components/ANotifications.vue +75 -0
  37. package/dist/runtime/components/ANotifications.vue.d.ts +7 -0
  38. package/dist/runtime/components/APermissionGuard.d.vue.ts +21 -0
  39. package/dist/runtime/components/APermissionGuard.vue +22 -0
  40. package/dist/runtime/components/APermissionGuard.vue.d.ts +21 -0
  41. package/dist/runtime/components/APresence.d.vue.ts +43 -0
  42. package/dist/runtime/components/APresence.vue +36 -0
  43. package/dist/runtime/components/APresence.vue.d.ts +43 -0
  44. package/dist/runtime/components/AProvider.d.vue.ts +27 -0
  45. package/dist/runtime/components/AProvider.vue +42 -0
  46. package/dist/runtime/components/AProvider.vue.d.ts +27 -0
  47. package/dist/runtime/components/ARoleBadge.d.vue.ts +11 -0
  48. package/dist/runtime/components/ARoleBadge.vue +29 -0
  49. package/dist/runtime/components/ARoleBadge.vue.d.ts +11 -0
  50. package/dist/runtime/components/AVoiceBar.d.vue.ts +13 -0
  51. package/dist/runtime/components/AVoiceBar.vue +379 -0
  52. package/dist/runtime/components/AVoiceBar.vue.d.ts +13 -0
  53. package/dist/runtime/components/AVoiceTile.d.vue.ts +10 -0
  54. package/dist/runtime/components/AVoiceTile.vue +48 -0
  55. package/dist/runtime/components/AVoiceTile.vue.d.ts +10 -0
  56. package/dist/runtime/components/AWindowLayer.d.vue.ts +3 -0
  57. package/dist/runtime/components/AWindowLayer.vue +17 -0
  58. package/dist/runtime/components/AWindowLayer.vue.d.ts +3 -0
  59. package/dist/runtime/components/aware/AArea.d.vue.ts +42 -0
  60. package/dist/runtime/components/aware/AArea.vue +45 -0
  61. package/dist/runtime/components/aware/AArea.vue.d.ts +42 -0
  62. package/dist/runtime/components/aware/AAvatar.d.vue.ts +25 -0
  63. package/dist/runtime/components/aware/AAvatar.vue +86 -0
  64. package/dist/runtime/components/aware/AAvatar.vue.d.ts +25 -0
  65. package/dist/runtime/components/aware/AButton.d.vue.ts +7 -0
  66. package/dist/runtime/components/aware/AButton.vue +39 -0
  67. package/dist/runtime/components/aware/AButton.vue.d.ts +7 -0
  68. package/dist/runtime/components/aware/ACursorLabel.d.vue.ts +12 -0
  69. package/dist/runtime/components/aware/ACursorLabel.vue +44 -0
  70. package/dist/runtime/components/aware/ACursorLabel.vue.d.ts +12 -0
  71. package/dist/runtime/components/aware/ADocBadge.d.vue.ts +11 -0
  72. package/dist/runtime/components/aware/ADocBadge.vue +27 -0
  73. package/dist/runtime/components/aware/ADocBadge.vue.d.ts +11 -0
  74. package/dist/runtime/components/aware/AFacepile.d.vue.ts +20 -0
  75. package/dist/runtime/components/aware/AFacepile.vue +92 -0
  76. package/dist/runtime/components/aware/AFacepile.vue.d.ts +20 -0
  77. package/dist/runtime/components/aware/AInput.d.vue.ts +7 -0
  78. package/dist/runtime/components/aware/AInput.vue +44 -0
  79. package/dist/runtime/components/aware/AInput.vue.d.ts +7 -0
  80. package/dist/runtime/components/aware/ASelect.d.vue.ts +7 -0
  81. package/dist/runtime/components/aware/ASelect.vue +51 -0
  82. package/dist/runtime/components/aware/ASelect.vue.d.ts +7 -0
  83. package/dist/runtime/components/aware/ATextarea.d.vue.ts +7 -0
  84. package/dist/runtime/components/aware/ATextarea.vue +44 -0
  85. package/dist/runtime/components/aware/ATextarea.vue.d.ts +7 -0
  86. package/dist/runtime/components/aware/AUserList.d.vue.ts +17 -0
  87. package/dist/runtime/components/aware/AUserList.vue +72 -0
  88. package/dist/runtime/components/aware/AUserList.vue.d.ts +17 -0
  89. package/dist/runtime/components/renderers/ACalendarRenderer.d.vue.ts +8 -0
  90. package/dist/runtime/components/renderers/ACalendarRenderer.vue +154 -0
  91. package/dist/runtime/components/renderers/ACalendarRenderer.vue.d.ts +8 -0
  92. package/dist/runtime/components/renderers/AGalleryRenderer.d.vue.ts +8 -0
  93. package/dist/runtime/components/renderers/AGalleryRenderer.vue +88 -0
  94. package/dist/runtime/components/renderers/AGalleryRenderer.vue.d.ts +8 -0
  95. package/dist/runtime/components/renderers/AKanbanRenderer.d.vue.ts +8 -0
  96. package/dist/runtime/components/renderers/AKanbanRenderer.vue +179 -0
  97. package/dist/runtime/components/renderers/AKanbanRenderer.vue.d.ts +8 -0
  98. package/dist/runtime/components/renderers/AOutlineRenderer.d.vue.ts +8 -0
  99. package/dist/runtime/components/renderers/AOutlineRenderer.vue +180 -0
  100. package/dist/runtime/components/renderers/AOutlineRenderer.vue.d.ts +8 -0
  101. package/dist/runtime/components/renderers/ATableRenderer.d.vue.ts +8 -0
  102. package/dist/runtime/components/renderers/ATableRenderer.vue +191 -0
  103. package/dist/runtime/components/renderers/ATableRenderer.vue.d.ts +8 -0
  104. package/dist/runtime/composables/useAAField.d.ts +42 -0
  105. package/dist/runtime/composables/useAAField.js +62 -0
  106. package/dist/runtime/composables/useAbraLocale.d.ts +14 -0
  107. package/dist/runtime/composables/useAbraLocale.js +11 -0
  108. package/dist/runtime/composables/useAbracadabra.d.ts +11 -0
  109. package/dist/runtime/composables/useAbracadabra.js +3 -0
  110. package/dist/runtime/composables/useAbracadabraAuth.d.ts +23 -0
  111. package/dist/runtime/composables/useAbracadabraAuth.js +22 -0
  112. package/dist/runtime/composables/useAwareness.d.ts +22 -0
  113. package/dist/runtime/composables/useAwareness.js +48 -0
  114. package/dist/runtime/composables/useAwarenessPeers.d.ts +34 -0
  115. package/dist/runtime/composables/useAwarenessPeers.js +33 -0
  116. package/dist/runtime/composables/useBackgroundSync.d.ts +37 -0
  117. package/dist/runtime/composables/useBackgroundSync.js +73 -0
  118. package/dist/runtime/composables/useChat.d.ts +65 -0
  119. package/dist/runtime/composables/useChat.js +210 -0
  120. package/dist/runtime/composables/useChatUsers.d.ts +21 -0
  121. package/dist/runtime/composables/useChatUsers.js +39 -0
  122. package/dist/runtime/composables/useChildTree.d.ts +119 -0
  123. package/dist/runtime/composables/useChildTree.js +100 -0
  124. package/dist/runtime/composables/useCommandPalette.d.ts +58 -0
  125. package/dist/runtime/composables/useCommandPalette.js +94 -0
  126. package/dist/runtime/composables/useConnectionStatus.d.ts +17 -0
  127. package/dist/runtime/composables/useConnectionStatus.js +37 -0
  128. package/dist/runtime/composables/useDashboard.d.ts +3 -0
  129. package/dist/runtime/composables/useDashboard.js +23 -0
  130. package/dist/runtime/composables/useDocExport.d.ts +5 -0
  131. package/dist/runtime/composables/useDocExport.js +256 -0
  132. package/dist/runtime/composables/useDocImport.d.ts +10 -0
  133. package/dist/runtime/composables/useDocImport.js +227 -0
  134. package/dist/runtime/composables/useDocJump.d.ts +29 -0
  135. package/dist/runtime/composables/useDocJump.js +17 -0
  136. package/dist/runtime/composables/useDocumentPermissions.d.ts +20 -0
  137. package/dist/runtime/composables/useDocumentPermissions.js +33 -0
  138. package/dist/runtime/composables/useEditor.d.ts +45 -0
  139. package/dist/runtime/composables/useEditor.js +121 -0
  140. package/dist/runtime/composables/useEditorDragHandle.d.ts +26 -0
  141. package/dist/runtime/composables/useEditorDragHandle.js +219 -0
  142. package/dist/runtime/composables/useEditorMentions.d.ts +28 -0
  143. package/dist/runtime/composables/useEditorMentions.js +40 -0
  144. package/dist/runtime/composables/useEditorSuggestions.d.ts +18 -0
  145. package/dist/runtime/composables/useEditorSuggestions.js +45 -0
  146. package/dist/runtime/composables/useEditorToolbar.d.ts +22 -0
  147. package/dist/runtime/composables/useEditorToolbar.js +60 -0
  148. package/dist/runtime/composables/useFileBlobStore.d.ts +15 -0
  149. package/dist/runtime/composables/useFileBlobStore.js +22 -0
  150. package/dist/runtime/composables/useFileIndex.d.ts +20 -0
  151. package/dist/runtime/composables/useFileIndex.js +69 -0
  152. package/dist/runtime/composables/useFollowUser.d.ts +5 -0
  153. package/dist/runtime/composables/useFollowUser.js +40 -0
  154. package/dist/runtime/composables/useNotifications.d.ts +82 -0
  155. package/dist/runtime/composables/useNotifications.js +171 -0
  156. package/dist/runtime/composables/useOfflineUploadQueue.d.ts +90 -0
  157. package/dist/runtime/composables/useOfflineUploadQueue.js +33 -0
  158. package/dist/runtime/composables/usePasskeyAccounts.d.ts +32 -0
  159. package/dist/runtime/composables/usePasskeyAccounts.js +46 -0
  160. package/dist/runtime/composables/usePluginRegistry.d.ts +6 -0
  161. package/dist/runtime/composables/usePluginRegistry.js +3 -0
  162. package/dist/runtime/composables/useRendererBase.d.ts +186 -0
  163. package/dist/runtime/composables/useRendererBase.js +46 -0
  164. package/dist/runtime/composables/useSearchIndex.d.ts +20 -0
  165. package/dist/runtime/composables/useSearchIndex.js +104 -0
  166. package/dist/runtime/composables/useTrash.d.ts +50 -0
  167. package/dist/runtime/composables/useTrash.js +127 -0
  168. package/dist/runtime/composables/useVoice.d.ts +51 -0
  169. package/dist/runtime/composables/useVoice.js +220 -0
  170. package/dist/runtime/composables/useWindowManager.d.ts +122 -0
  171. package/dist/runtime/composables/useWindowManager.js +141 -0
  172. package/dist/runtime/composables/useYDoc.d.ts +142 -0
  173. package/dist/runtime/composables/useYDoc.js +172 -0
  174. package/dist/runtime/extensions/accordion.d.ts +3 -0
  175. package/dist/runtime/extensions/accordion.js +49 -0
  176. package/dist/runtime/extensions/badge.d.ts +2 -0
  177. package/dist/runtime/extensions/badge.js +39 -0
  178. package/dist/runtime/extensions/callout.d.ts +2 -0
  179. package/dist/runtime/extensions/callout.js +28 -0
  180. package/dist/runtime/extensions/card.d.ts +3 -0
  181. package/dist/runtime/extensions/card.js +53 -0
  182. package/dist/runtime/extensions/code-collapse.d.ts +2 -0
  183. package/dist/runtime/extensions/code-collapse.js +32 -0
  184. package/dist/runtime/extensions/code-group.d.ts +2 -0
  185. package/dist/runtime/extensions/code-group.js +17 -0
  186. package/dist/runtime/extensions/collapsible.d.ts +2 -0
  187. package/dist/runtime/extensions/collapsible.js +35 -0
  188. package/dist/runtime/extensions/document-header.d.ts +11 -0
  189. package/dist/runtime/extensions/document-header.js +82 -0
  190. package/dist/runtime/extensions/document-meta.d.ts +20 -0
  191. package/dist/runtime/extensions/document-meta.js +121 -0
  192. package/dist/runtime/extensions/document.d.ts +6 -0
  193. package/dist/runtime/extensions/document.js +6 -0
  194. package/dist/runtime/extensions/file-block.d.ts +15 -0
  195. package/dist/runtime/extensions/file-block.js +34 -0
  196. package/dist/runtime/extensions/file-drop.d.ts +6 -0
  197. package/dist/runtime/extensions/file-drop.js +65 -0
  198. package/dist/runtime/extensions/kbd.d.ts +2 -0
  199. package/dist/runtime/extensions/kbd.js +33 -0
  200. package/dist/runtime/extensions/prose-icon.d.ts +2 -0
  201. package/dist/runtime/extensions/prose-icon.js +33 -0
  202. package/dist/runtime/extensions/search-highlight.d.ts +10 -0
  203. package/dist/runtime/extensions/search-highlight.js +129 -0
  204. package/dist/runtime/extensions/steps.d.ts +2 -0
  205. package/dist/runtime/extensions/steps.js +32 -0
  206. package/dist/runtime/extensions/tabs.d.ts +3 -0
  207. package/dist/runtime/extensions/tabs.js +49 -0
  208. package/dist/runtime/extensions/views/AccordionItemView.d.vue.ts +4 -0
  209. package/dist/runtime/extensions/views/AccordionItemView.vue +41 -0
  210. package/dist/runtime/extensions/views/AccordionItemView.vue.d.ts +4 -0
  211. package/dist/runtime/extensions/views/AccordionView.d.vue.ts +4 -0
  212. package/dist/runtime/extensions/views/AccordionView.vue +22 -0
  213. package/dist/runtime/extensions/views/AccordionView.vue.d.ts +4 -0
  214. package/dist/runtime/extensions/views/BadgeView.d.vue.ts +4 -0
  215. package/dist/runtime/extensions/views/BadgeView.vue +23 -0
  216. package/dist/runtime/extensions/views/BadgeView.vue.d.ts +4 -0
  217. package/dist/runtime/extensions/views/CalloutView.d.vue.ts +4 -0
  218. package/dist/runtime/extensions/views/CalloutView.vue +43 -0
  219. package/dist/runtime/extensions/views/CalloutView.vue.d.ts +4 -0
  220. package/dist/runtime/extensions/views/CardGroupView.d.vue.ts +4 -0
  221. package/dist/runtime/extensions/views/CardGroupView.vue +22 -0
  222. package/dist/runtime/extensions/views/CardGroupView.vue.d.ts +4 -0
  223. package/dist/runtime/extensions/views/CardView.d.vue.ts +4 -0
  224. package/dist/runtime/extensions/views/CardView.vue +28 -0
  225. package/dist/runtime/extensions/views/CardView.vue.d.ts +4 -0
  226. package/dist/runtime/extensions/views/CodeCollapseView.d.vue.ts +4 -0
  227. package/dist/runtime/extensions/views/CodeCollapseView.vue +45 -0
  228. package/dist/runtime/extensions/views/CodeCollapseView.vue.d.ts +4 -0
  229. package/dist/runtime/extensions/views/CodeGroupView.d.vue.ts +4 -0
  230. package/dist/runtime/extensions/views/CodeGroupView.vue +53 -0
  231. package/dist/runtime/extensions/views/CodeGroupView.vue.d.ts +4 -0
  232. package/dist/runtime/extensions/views/CollapsibleView.d.vue.ts +4 -0
  233. package/dist/runtime/extensions/views/CollapsibleView.vue +42 -0
  234. package/dist/runtime/extensions/views/CollapsibleView.vue.d.ts +4 -0
  235. package/dist/runtime/extensions/views/FileNodeView.d.vue.ts +4 -0
  236. package/dist/runtime/extensions/views/FileNodeView.vue +140 -0
  237. package/dist/runtime/extensions/views/FileNodeView.vue.d.ts +4 -0
  238. package/dist/runtime/extensions/views/KbdView.d.vue.ts +4 -0
  239. package/dist/runtime/extensions/views/KbdView.vue +23 -0
  240. package/dist/runtime/extensions/views/KbdView.vue.d.ts +4 -0
  241. package/dist/runtime/extensions/views/ProseIconView.d.vue.ts +4 -0
  242. package/dist/runtime/extensions/views/ProseIconView.vue +23 -0
  243. package/dist/runtime/extensions/views/ProseIconView.vue.d.ts +4 -0
  244. package/dist/runtime/extensions/views/StepsView.d.vue.ts +4 -0
  245. package/dist/runtime/extensions/views/StepsView.vue +32 -0
  246. package/dist/runtime/extensions/views/StepsView.vue.d.ts +4 -0
  247. package/dist/runtime/extensions/views/TabsItemView.d.vue.ts +4 -0
  248. package/dist/runtime/extensions/views/TabsItemView.vue +22 -0
  249. package/dist/runtime/extensions/views/TabsItemView.vue.d.ts +4 -0
  250. package/dist/runtime/extensions/views/TabsView.d.vue.ts +4 -0
  251. package/dist/runtime/extensions/views/TabsView.vue +56 -0
  252. package/dist/runtime/extensions/views/TabsView.vue.d.ts +4 -0
  253. package/dist/runtime/locale.d.ts +134 -0
  254. package/dist/runtime/locale.js +119 -0
  255. package/dist/runtime/middleware/abracadabra-auth.d.ts +11 -0
  256. package/dist/runtime/middleware/abracadabra-auth.js +9 -0
  257. package/dist/runtime/plugin-abracadabra.client.d.ts +7 -0
  258. package/dist/runtime/plugin-abracadabra.client.js +898 -0
  259. package/dist/runtime/plugin-abracadabra.server.d.ts +2 -0
  260. package/dist/runtime/plugin-abracadabra.server.js +71 -0
  261. package/dist/runtime/plugin-registry.d.ts +34 -0
  262. package/dist/runtime/plugin-registry.js +83 -0
  263. package/dist/runtime/plugin-shared-globals.client.d.ts +2 -0
  264. package/dist/runtime/plugin-shared-globals.client.js +20 -0
  265. package/dist/runtime/plugins/core.plugin.d.ts +12 -0
  266. package/dist/runtime/plugins/core.plugin.js +179 -0
  267. package/dist/runtime/server/api/_abracadabra/render/[docId].get.d.ts +18 -0
  268. package/dist/runtime/server/api/_abracadabra/render/[docId].get.js +51 -0
  269. package/dist/runtime/server/api/_abracadabra/spaces.get.d.ts +11 -0
  270. package/dist/runtime/server/api/_abracadabra/spaces.get.js +16 -0
  271. package/dist/runtime/server/plugins/abracadabra-service.d.ts +2 -0
  272. package/dist/runtime/server/plugins/abracadabra-service.js +116 -0
  273. package/dist/runtime/server/runners/doc-tree-cache.d.ts +11 -0
  274. package/dist/runtime/server/runners/doc-tree-cache.js +65 -0
  275. package/dist/runtime/server/tsconfig.json +3 -0
  276. package/dist/runtime/server/utils/docCache.d.ts +25 -0
  277. package/dist/runtime/server/utils/docCache.js +131 -0
  278. package/dist/runtime/server/utils/serverRunner.d.ts +28 -0
  279. package/dist/runtime/server/utils/serverRunner.js +58 -0
  280. package/dist/runtime/types.d.ts +444 -0
  281. package/dist/runtime/types.js +93 -0
  282. package/dist/runtime/utils/VoiceClient.d.ts +94 -0
  283. package/dist/runtime/utils/VoiceClient.js +599 -0
  284. package/dist/runtime/utils/avatarStyle.d.ts +15 -0
  285. package/dist/runtime/utils/avatarStyle.js +20 -0
  286. package/dist/runtime/utils/colorPalettes.d.ts +13 -0
  287. package/dist/runtime/utils/colorPalettes.js +49 -0
  288. package/dist/runtime/utils/docTypes.d.ts +129 -0
  289. package/dist/runtime/utils/docTypes.js +116 -0
  290. package/dist/runtime/utils/markdownToYjs.d.ts +23 -0
  291. package/dist/runtime/utils/markdownToYjs.js +440 -0
  292. package/dist/runtime/utils/metaFieldDefinitions.d.ts +7 -0
  293. package/dist/runtime/utils/metaFieldDefinitions.js +182 -0
  294. package/dist/runtime/utils/voiceErrors.d.ts +33 -0
  295. package/dist/runtime/utils/voiceErrors.js +54 -0
  296. package/dist/runtime/utils/yjsConvert.d.ts +14 -0
  297. package/dist/runtime/utils/yjsConvert.js +331 -0
  298. package/dist/types.d.mts +13 -0
  299. package/package.json +100 -0
@@ -0,0 +1,180 @@
1
+ <script setup>
2
+ import { ref, computed, nextTick } from "vue";
3
+ import { useRendererBase } from "../../composables/useRendererBase";
4
+ import { DEFAULT_LOCALE } from "../../locale";
5
+ const props = defineProps({
6
+ docId: { type: String, required: true },
7
+ childProvider: { type: null, required: true },
8
+ docLabel: { type: String, required: true },
9
+ pageTypes: { type: Array, required: false },
10
+ labels: { type: Object, required: false }
11
+ });
12
+ const config = useRuntimeConfig();
13
+ const locale = computed(() => ({
14
+ ...DEFAULT_LOCALE.renderers.outline,
15
+ ...config.public?.abracadabra?.locale?.renderers?.outline ?? {},
16
+ ...props.labels ?? {}
17
+ }));
18
+ const { tree } = useRendererBase(props);
19
+ const editingId = ref(null);
20
+ const editValues = ref({});
21
+ const expandedIds = ref(/* @__PURE__ */ new Set());
22
+ function childrenOf(parentId) {
23
+ return tree.entries.value.filter((e) => e.parentId === (parentId === null ? props.docId : parentId)).sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
24
+ }
25
+ function buildFlat(parentId, depth) {
26
+ const result = [];
27
+ for (const entry of childrenOf(parentId)) {
28
+ const expanded = expandedIds.value.has(entry.id);
29
+ const hc = tree.entries.value.some((e) => e.parentId === entry.id);
30
+ result.push({
31
+ id: entry.id,
32
+ label: entry.label,
33
+ depth,
34
+ parentId: entry.parentId,
35
+ order: entry.order,
36
+ hasChildren: hc,
37
+ isExpanded: expanded
38
+ });
39
+ if (expanded || !hc) {
40
+ result.push(...buildFlat(entry.id, depth + 1));
41
+ }
42
+ }
43
+ return result;
44
+ }
45
+ const flatItems = computed(() => buildFlat(null, 0));
46
+ function startEdit(id, label) {
47
+ editingId.value = id;
48
+ editValues.value[id] = label;
49
+ nextTick(() => {
50
+ const el = document.getElementById(`outline-${id}`);
51
+ el?.focus();
52
+ el?.select();
53
+ });
54
+ }
55
+ function commitEdit(id) {
56
+ const val = (editValues.value[id] ?? "").trim();
57
+ if (val) {
58
+ const entry = tree.treeMap.get(id);
59
+ if (entry) tree.treeMap.set(id, { ...entry, label: val, updatedAt: Date.now() });
60
+ }
61
+ editingId.value = null;
62
+ }
63
+ function onKeydown(e, item, idx) {
64
+ if (e.key === "Enter") {
65
+ e.preventDefault();
66
+ commitEdit(item.id);
67
+ const newId = tree.createChild(item.parentId === props.docId ? null : item.parentId, "");
68
+ nextTick(() => startEdit(newId, ""));
69
+ } else if (e.key === "Tab") {
70
+ e.preventDefault();
71
+ const val = (editValues.value[item.id] ?? "").trim();
72
+ if (val) {
73
+ const entry = tree.treeMap.get(item.id);
74
+ if (entry) tree.treeMap.set(item.id, { ...entry, label: val, updatedAt: Date.now() });
75
+ }
76
+ if (!e.shiftKey) {
77
+ const prev = flatItems.value[idx - 1];
78
+ if (prev && prev.depth <= item.depth) {
79
+ const entry = tree.treeMap.get(item.id);
80
+ if (entry) tree.treeMap.set(item.id, { ...entry, parentId: prev.id, order: Date.now(), updatedAt: Date.now() });
81
+ expandedIds.value.add(prev.id);
82
+ expandedIds.value = new Set(expandedIds.value);
83
+ }
84
+ } else {
85
+ if (item.depth > 0) {
86
+ const parentEntry = tree.treeMap.get(item.parentId);
87
+ const grandParentId = parentEntry?.parentId ?? props.docId;
88
+ const entry = tree.treeMap.get(item.id);
89
+ if (entry) tree.treeMap.set(item.id, { ...entry, parentId: grandParentId, order: Date.now(), updatedAt: Date.now() });
90
+ }
91
+ }
92
+ } else if (e.key === "Backspace" && !(editValues.value[item.id] ?? "").length) {
93
+ e.preventDefault();
94
+ tree.treeMap.remove(item.id);
95
+ editingId.value = null;
96
+ const prev = flatItems.value[idx - 1];
97
+ if (prev) nextTick(() => startEdit(prev.id, prev.label));
98
+ } else if (e.key === "ArrowUp") {
99
+ e.preventDefault();
100
+ commitEdit(item.id);
101
+ const prev = flatItems.value[idx - 1];
102
+ if (prev) nextTick(() => startEdit(prev.id, prev.label));
103
+ } else if (e.key === "ArrowDown") {
104
+ e.preventDefault();
105
+ commitEdit(item.id);
106
+ const next = flatItems.value[idx + 1];
107
+ if (next) nextTick(() => startEdit(next.id, next.label));
108
+ }
109
+ }
110
+ function addRoot() {
111
+ const newId = tree.createChild(null, locale.value.addItem);
112
+ nextTick(() => startEdit(newId, locale.value.addItem));
113
+ }
114
+ </script>
115
+
116
+ <template>
117
+ <div class="p-4 max-w-2xl">
118
+ <div class="space-y-0.5">
119
+ <div
120
+ v-for="(item, idx) in flatItems"
121
+ :key="item.id"
122
+ :style="{ paddingLeft: `${item.depth * 24}px` }"
123
+ class="flex items-center gap-2 group py-0.5"
124
+ >
125
+ <!-- Expand toggle -->
126
+ <UButton
127
+ :icon="item.isExpanded ? 'i-lucide-chevron-down' : 'i-lucide-chevron-right'"
128
+ variant="ghost"
129
+ color="neutral"
130
+ size="xs"
131
+ :class="item.hasChildren ? 'opacity-100' : 'opacity-0 pointer-events-none'"
132
+ @click="() => {
133
+ const s = new Set(expandedIds);
134
+ s.has(item.id) ? s.delete(item.id) : s.add(item.id);
135
+ expandedIds = s;
136
+ }"
137
+ />
138
+
139
+ <UIcon name="i-lucide-circle-dot" class="size-3 text-muted flex-shrink-0" />
140
+
141
+ <template v-if="editingId === item.id">
142
+ <input
143
+ :id="`outline-${item.id}`"
144
+ v-model="editValues[item.id]"
145
+ class="flex-1 bg-transparent border-none outline-none text-sm"
146
+ @blur="commitEdit(item.id)"
147
+ @keydown="onKeydown($event, item, idx)"
148
+ >
149
+ </template>
150
+ <span
151
+ v-else
152
+ class="flex-1 text-sm cursor-text"
153
+ :class="!item.label ? 'text-muted italic' : ''"
154
+ @click="startEdit(item.id, item.label)"
155
+ >{{ item.label || locale.empty }}</span>
156
+
157
+ <UButton
158
+ icon="i-lucide-trash"
159
+ variant="ghost"
160
+ color="error"
161
+ size="xs"
162
+ class="opacity-0 group-hover:opacity-100"
163
+ @click="tree.treeMap.remove(item.id)"
164
+ />
165
+ </div>
166
+ </div>
167
+
168
+ <!-- Add root item -->
169
+ <div class="mt-2">
170
+ <UButton
171
+ icon="i-lucide-plus"
172
+ variant="ghost"
173
+ color="neutral"
174
+ size="sm"
175
+ :label="locale.addItem"
176
+ @click="addRoot"
177
+ />
178
+ </div>
179
+ </div>
180
+ </template>
@@ -0,0 +1,8 @@
1
+ import { type RendererBaseProps } from '../../composables/useRendererBase.js';
2
+ import type { AbracadabraLocale } from '../../locale.js';
3
+ type __VLS_Props = RendererBaseProps & {
4
+ labels?: Partial<AbracadabraLocale['renderers']['outline']>;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { type RendererBaseProps } from '../../composables/useRendererBase.js';
2
+ import type { AbracadabraLocale } from '../../locale.js';
3
+ type __VLS_Props = RendererBaseProps & {
4
+ labels?: Partial<AbracadabraLocale['renderers']['table']>;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,191 @@
1
+ <script setup>
2
+ import { ref, computed } from "vue";
3
+ import { useRendererBase } from "../../composables/useRendererBase";
4
+ import { DEFAULT_LOCALE } from "../../locale";
5
+ const props = defineProps({
6
+ docId: { type: String, required: true },
7
+ childProvider: { type: null, required: true },
8
+ docLabel: { type: String, required: true },
9
+ pageTypes: { type: Array, required: false },
10
+ labels: { type: Object, required: false }
11
+ });
12
+ const config = useRuntimeConfig();
13
+ const locale = computed(() => ({
14
+ ...DEFAULT_LOCALE.renderers.table,
15
+ ...config.public?.abracadabra?.locale?.renderers?.table ?? {},
16
+ ...props.labels ?? {}
17
+ }));
18
+ const { tree } = useRendererBase(props);
19
+ const rows = computed(() => tree.childrenOf(null).sort((a, b) => (a.order ?? 0) - (b.order ?? 0)));
20
+ const detectedColumns = computed(() => {
21
+ const keys = /* @__PURE__ */ new Set(["label"]);
22
+ for (const row of rows.value) {
23
+ if (row.meta) {
24
+ for (const key of Object.keys(row.meta)) {
25
+ if (!["_metaFields", "_metaInitialized", "coverUploadId", "coverDocId", "coverMimeType"].includes(key)) {
26
+ keys.add(key);
27
+ }
28
+ }
29
+ }
30
+ }
31
+ return [...keys];
32
+ });
33
+ const editingCell = ref(null);
34
+ const editValue = ref("");
35
+ function getCellValue(row, col) {
36
+ if (col === "label") return row.label;
37
+ const v = row.meta?.[col];
38
+ if (v === void 0 || v === null) return "";
39
+ if (Array.isArray(v)) return v.join(", ");
40
+ return String(v);
41
+ }
42
+ function startEdit(rowId, col, value) {
43
+ editingCell.value = { rowId, col };
44
+ editValue.value = value;
45
+ }
46
+ function commitEdit() {
47
+ if (!editingCell.value) return;
48
+ const { rowId, col } = editingCell.value;
49
+ const entry = tree.treeMap.get(rowId);
50
+ if (!entry) {
51
+ editingCell.value = null;
52
+ return;
53
+ }
54
+ if (col === "label") {
55
+ tree.treeMap.set(rowId, { ...entry, label: editValue.value, updatedAt: Date.now() });
56
+ } else {
57
+ tree.treeMap.set(rowId, {
58
+ ...entry,
59
+ meta: { ...entry.meta ?? {}, [col]: editValue.value },
60
+ updatedAt: Date.now()
61
+ });
62
+ }
63
+ editingCell.value = null;
64
+ }
65
+ function addRow() {
66
+ tree.createChild(null, locale.value.untitled);
67
+ }
68
+ function deleteRow(id) {
69
+ tree.treeMap.remove(id);
70
+ }
71
+ const newColName = ref("");
72
+ const showAddCol = ref(false);
73
+ function addColumn() {
74
+ const name = newColName.value.trim();
75
+ if (!name) return;
76
+ for (const row of rows.value) {
77
+ const entry = tree.treeMap.get(row.id);
78
+ if (entry && !entry.meta?.[name]) {
79
+ tree.treeMap.set(row.id, {
80
+ ...entry,
81
+ meta: { ...entry.meta ?? {}, [name]: "" },
82
+ updatedAt: Date.now()
83
+ });
84
+ }
85
+ }
86
+ newColName.value = "";
87
+ showAddCol.value = false;
88
+ }
89
+ </script>
90
+
91
+ <template>
92
+ <div class="p-4 overflow-auto">
93
+ <div class="border border-muted rounded-lg overflow-hidden">
94
+ <table class="w-full text-sm border-collapse">
95
+ <!-- Header -->
96
+ <thead>
97
+ <tr class="bg-muted/50">
98
+ <th
99
+ v-for="col in detectedColumns"
100
+ :key="col"
101
+ class="px-3 py-2 text-left font-medium text-muted capitalize border-b border-muted"
102
+ >
103
+ {{ col }}
104
+ </th>
105
+ <th class="px-2 py-2 border-b border-muted w-8">
106
+ <UButton
107
+ icon="i-lucide-plus"
108
+ variant="ghost"
109
+ color="neutral"
110
+ size="xs"
111
+ @click="showAddCol = !showAddCol"
112
+ />
113
+ </th>
114
+ </tr>
115
+ <tr v-if="showAddCol">
116
+ <td
117
+ :colspan="detectedColumns.length + 1"
118
+ class="px-3 py-1 border-b border-muted"
119
+ >
120
+ <div class="flex gap-2">
121
+ <UInput
122
+ v-model="newColName"
123
+ placeholder="Column name"
124
+ size="xs"
125
+ class="flex-1"
126
+ @keydown.enter="addColumn"
127
+ @keydown.escape="showAddCol = false"
128
+ />
129
+ <UButton
130
+ size="xs"
131
+ label="Add"
132
+ @click="addColumn"
133
+ />
134
+ </div>
135
+ </td>
136
+ </tr>
137
+ </thead>
138
+ <!-- Rows -->
139
+ <tbody>
140
+ <tr
141
+ v-for="row in rows"
142
+ :key="row.id"
143
+ class="group hover:bg-muted/30 border-b border-muted last:border-b-0"
144
+ >
145
+ <td
146
+ v-for="col in detectedColumns"
147
+ :key="col"
148
+ class="px-3 py-1.5"
149
+ @dblclick="startEdit(row.id, col, getCellValue(row, col))"
150
+ >
151
+ <template v-if="editingCell?.rowId === row.id && editingCell?.col === col">
152
+ <input
153
+ v-model="editValue"
154
+ class="w-full bg-transparent border-none outline-none text-sm"
155
+ @blur="commitEdit"
156
+ @keydown.enter="commitEdit"
157
+ @keydown.escape="editingCell = null"
158
+ >
159
+ </template>
160
+ <span
161
+ v-else
162
+ class="truncate block"
163
+ >{{ getCellValue(row, col) }}</span>
164
+ </td>
165
+ <td class="px-2 py-1">
166
+ <UButton
167
+ icon="i-lucide-trash"
168
+ variant="ghost"
169
+ color="error"
170
+ size="xs"
171
+ class="opacity-0 group-hover:opacity-100"
172
+ @click="deleteRow(row.id)"
173
+ />
174
+ </td>
175
+ </tr>
176
+ </tbody>
177
+ </table>
178
+ </div>
179
+
180
+ <div class="mt-2">
181
+ <UButton
182
+ icon="i-lucide-plus"
183
+ variant="ghost"
184
+ color="neutral"
185
+ size="sm"
186
+ :label="locale.addRow"
187
+ @click="addRow"
188
+ />
189
+ </div>
190
+ </div>
191
+ </template>
@@ -0,0 +1,8 @@
1
+ import { type RendererBaseProps } from '../../composables/useRendererBase.js';
2
+ import type { AbracadabraLocale } from '../../locale.js';
3
+ type __VLS_Props = RendererBaseProps & {
4
+ labels?: Partial<AbracadabraLocale['renderers']['table']>;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,42 @@
1
+ import type { MaybeRef } from 'vue';
2
+ import type { AwarenessPeer } from '../types.js';
3
+ /**
4
+ * Per-element interaction awareness.
5
+ *
6
+ * Associates a UI element with a unique fieldKey so remote users' hover,
7
+ * press, and focus states are visible on that element. Each user broadcasts
8
+ * at most ONE hover, press, and focus key at any moment.
9
+ *
10
+ * Usage:
11
+ * const { hoverers, pressers, focusers, handlers } = useAAField('toolbar:bold')
12
+ * <UButton v-on="handlers" />
13
+ *
14
+ * Or per-event:
15
+ * <div @mouseenter="onMouseenter" @mouseleave="onMouseleave" />
16
+ *
17
+ * Field convention: "{scope}:{element-id}", e.g. "doc:toolbar:bold", "settings:save-btn"
18
+ */
19
+ export declare function useAAField(key: MaybeRef<string>): {
20
+ hoverers: import("vue").ComputedRef<AwarenessPeer[]>;
21
+ pressers: import("vue").ComputedRef<AwarenessPeer[]>;
22
+ focusers: import("vue").ComputedRef<AwarenessPeer[]>;
23
+ hasRemoteActivity: import("vue").ComputedRef<boolean>;
24
+ handlers: {
25
+ mouseenter: () => void;
26
+ mouseleave: () => void;
27
+ mousedown: () => void;
28
+ mouseup: () => void;
29
+ focus: () => void;
30
+ blur: () => void;
31
+ };
32
+ hoverHandlers: {
33
+ mouseenter: () => void;
34
+ mouseleave: () => void;
35
+ };
36
+ onMouseenter: () => void;
37
+ onMouseleave: () => void;
38
+ onMousedown: () => void;
39
+ onMouseup: () => void;
40
+ onFocus: () => void;
41
+ onBlur: () => void;
42
+ };
@@ -0,0 +1,62 @@
1
+ import { computed, isRef } from "vue";
2
+ export function useAAField(key) {
3
+ const { setField } = useAwareness();
4
+ const { peers } = useAwarenessPeers();
5
+ const fieldKey = computed(() => isRef(key) ? key.value : key);
6
+ const hoverers = computed(
7
+ () => peers.value.filter((p) => p.hover === fieldKey.value)
8
+ );
9
+ const pressers = computed(
10
+ () => peers.value.filter((p) => p.press === fieldKey.value)
11
+ );
12
+ const focusers = computed(
13
+ () => peers.value.filter((p) => p.focus === fieldKey.value)
14
+ );
15
+ const hasRemoteActivity = computed(
16
+ () => hoverers.value.length > 0 || pressers.value.length > 0 || focusers.value.length > 0
17
+ );
18
+ function onMouseenter() {
19
+ setField("hover", fieldKey.value);
20
+ }
21
+ function onMouseleave() {
22
+ setField("hover", null);
23
+ }
24
+ function onMousedown() {
25
+ setField("press", fieldKey.value);
26
+ }
27
+ function onMouseup() {
28
+ setField("press", null);
29
+ }
30
+ function onFocus() {
31
+ setField("focus", fieldKey.value);
32
+ }
33
+ function onBlur() {
34
+ setField("focus", null);
35
+ }
36
+ const handlers = {
37
+ mouseenter: onMouseenter,
38
+ mouseleave: onMouseleave,
39
+ mousedown: onMousedown,
40
+ mouseup: onMouseup,
41
+ focus: onFocus,
42
+ blur: onBlur
43
+ };
44
+ const hoverHandlers = {
45
+ mouseenter: onMouseenter,
46
+ mouseleave: onMouseleave
47
+ };
48
+ return {
49
+ hoverers,
50
+ pressers,
51
+ focusers,
52
+ hasRemoteActivity,
53
+ handlers,
54
+ hoverHandlers,
55
+ onMouseenter,
56
+ onMouseleave,
57
+ onMousedown,
58
+ onMouseup,
59
+ onFocus,
60
+ onBlur
61
+ };
62
+ }
@@ -0,0 +1,14 @@
1
+ import { type AbracadabraLocale } from '../locale.js';
2
+ /**
3
+ * Resolve locale strings for a specific component section.
4
+ *
5
+ * Priority (highest wins):
6
+ * 1. per-component `overrides` prop
7
+ * 2. module-level `locale` option (runtimeConfig.public.abracadabra.locale)
8
+ * 3. DEFAULT_LOCALE (built-in English)
9
+ *
10
+ * Usage in a component:
11
+ * const locale = useAbraLocale('documentTree', props.labels)
12
+ * // template: {{ locale.newDocument }}
13
+ */
14
+ export declare function useAbraLocale<K extends keyof AbracadabraLocale>(section: K, overrides?: Partial<AbracadabraLocale[K]> | null): AbracadabraLocale[K];
@@ -0,0 +1,11 @@
1
+ import { DEFAULT_LOCALE } from "../locale.js";
2
+ export function useAbraLocale(section, overrides) {
3
+ const config = useRuntimeConfig();
4
+ const moduleLocale = config.public?.abracadabra?.locale;
5
+ const base = {
6
+ ...DEFAULT_LOCALE[section],
7
+ ...moduleLocale?.[section] ?? {}
8
+ };
9
+ if (!overrides) return base;
10
+ return { ...base, ...overrides };
11
+ }
@@ -0,0 +1,11 @@
1
+ import type { AbracadabraState } from '../types.js';
2
+ /**
3
+ * Core Abracadabra composable.
4
+ *
5
+ * Returns the full state object injected by the main client plugin.
6
+ * All CRDT objects (provider, doc, client) are shallowRef — do NOT deep-watch them.
7
+ *
8
+ * On first call inside a Vue component, auto-imports are resolved.
9
+ * The actual SDK init happens in the plugin — this is a zero-logic accessor.
10
+ */
11
+ export declare function useAbracadabra(): AbracadabraState;
@@ -0,0 +1,3 @@
1
+ export function useAbracadabra() {
2
+ return useNuxtApp().$abracadabra;
3
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Focused auth composable — a subset of useAbracadabra() for components
3
+ * that only need identity/auth state without importing the entire surface.
4
+ */
5
+ export declare function useAbracadabraAuth(): {
6
+ isClaimed: any;
7
+ identityLost: any;
8
+ needsReauth: any;
9
+ isConnectionBlocked: any;
10
+ requirePasskeyOnLogin: any;
11
+ publicKeyB64: any;
12
+ userName: any;
13
+ userColor: any;
14
+ userColorName: any;
15
+ userNeutralColorName: any;
16
+ claimAccount: any;
17
+ loginWithHardware: any;
18
+ logout: any;
19
+ setUserName: any;
20
+ setUserColor: any;
21
+ setNeutralColor: any;
22
+ setRequirePasskey: any;
23
+ };
@@ -0,0 +1,22 @@
1
+ export function useAbracadabraAuth() {
2
+ const abra = useNuxtApp().$abracadabra;
3
+ return {
4
+ isClaimed: abra.isClaimed,
5
+ identityLost: abra.identityLost,
6
+ needsReauth: abra.needsReauth,
7
+ isConnectionBlocked: abra.isConnectionBlocked,
8
+ requirePasskeyOnLogin: abra.requirePasskeyOnLogin,
9
+ publicKeyB64: abra.publicKeyB64,
10
+ userName: abra.userName,
11
+ userColor: abra.userColor,
12
+ userColorName: abra.userColorName,
13
+ userNeutralColorName: abra.userNeutralColorName,
14
+ claimAccount: abra.claimAccount,
15
+ loginWithHardware: abra.loginWithHardware,
16
+ logout: abra.logout,
17
+ setUserName: abra.setUserName,
18
+ setUserColor: abra.setUserColor,
19
+ setNeutralColor: abra.setNeutralColor,
20
+ setRequirePasskey: abra.setRequirePasskey
21
+ };
22
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Reactive wrapper around the Abracadabra provider's Y.js awareness object.
3
+ *
4
+ * Exposes all connected users' awareness states as a reactive Map, and provides
5
+ * helpers to read/write the local user's state fields — without needing to
6
+ * access Y.js awareness directly.
7
+ *
8
+ * Usage:
9
+ * const { states, localState, setField } = useAwareness()
10
+ * setField('cursor', { docId, x, y })
11
+ * // states.value is a Map<clientId, { user, cursor, ... }>
12
+ */
13
+ export declare function useAwareness(): {
14
+ states: import("vue").ShallowRef<Map<number, Record<string, unknown>>, Map<number, Record<string, unknown>>>;
15
+ localState: import("vue").ComputedRef<Record<string, unknown>>;
16
+ setField: (key: string, value: unknown) => void;
17
+ onChange: (cb: (changed: {
18
+ added: number[];
19
+ updated: number[];
20
+ removed: number[];
21
+ }) => void) => () => void;
22
+ };
@@ -0,0 +1,48 @@
1
+ import { shallowRef, computed, watch } from "vue";
2
+ export function useAwareness() {
3
+ const { provider } = useAbracadabra();
4
+ const states = shallowRef(/* @__PURE__ */ new Map());
5
+ function _syncStates() {
6
+ const awareness = provider.value?.awareness;
7
+ if (!awareness) {
8
+ states.value = /* @__PURE__ */ new Map();
9
+ return;
10
+ }
11
+ states.value = new Map(awareness.getStates());
12
+ }
13
+ let _unsub = null;
14
+ function _subscribe() {
15
+ _unsub?.();
16
+ _unsub = null;
17
+ const awareness = provider.value?.awareness;
18
+ if (!awareness) return;
19
+ _syncStates();
20
+ const handler = () => _syncStates();
21
+ awareness.on("change", handler);
22
+ _unsub = () => awareness.off("change", handler);
23
+ }
24
+ watch(provider, () => _subscribe(), { immediate: true });
25
+ const localState = computed(() => {
26
+ const awareness = provider.value?.awareness;
27
+ if (!awareness) return {};
28
+ return awareness.getLocalState() ?? {};
29
+ });
30
+ function setField(key, value) {
31
+ const awareness = provider.value?.awareness;
32
+ if (!awareness) return;
33
+ awareness.setLocalStateField(key, value);
34
+ }
35
+ function onChange(cb) {
36
+ const awareness = provider.value?.awareness;
37
+ if (!awareness) return () => {
38
+ };
39
+ awareness.on("change", cb);
40
+ return () => awareness.off("change", cb);
41
+ }
42
+ return {
43
+ states,
44
+ localState,
45
+ setField,
46
+ onChange
47
+ };
48
+ }