@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.
- package/README.md +84 -0
- package/dist/module.d.mts +201 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +170 -0
- package/dist/runtime/components/ACollaborationUsers.d.vue.ts +11 -0
- package/dist/runtime/components/ACollaborationUsers.vue +48 -0
- package/dist/runtime/components/ACollaborationUsers.vue.d.ts +11 -0
- package/dist/runtime/components/AColorPicker.d.vue.ts +13 -0
- package/dist/runtime/components/AColorPicker.vue +71 -0
- package/dist/runtime/components/AColorPicker.vue.d.ts +13 -0
- package/dist/runtime/components/ACommandPalette.d.vue.ts +13 -0
- package/dist/runtime/components/ACommandPalette.vue +31 -0
- package/dist/runtime/components/ACommandPalette.vue.d.ts +13 -0
- package/dist/runtime/components/AConnectionStatus.d.vue.ts +13 -0
- package/dist/runtime/components/AConnectionStatus.vue +50 -0
- package/dist/runtime/components/AConnectionStatus.vue.d.ts +13 -0
- package/dist/runtime/components/ADocTypeSelect.d.vue.ts +10 -0
- package/dist/runtime/components/ADocTypeSelect.vue +34 -0
- package/dist/runtime/components/ADocTypeSelect.vue.d.ts +10 -0
- package/dist/runtime/components/ADocumentTree.d.vue.ts +53 -0
- package/dist/runtime/components/ADocumentTree.vue +350 -0
- package/dist/runtime/components/ADocumentTree.vue.d.ts +53 -0
- package/dist/runtime/components/AEditor.d.vue.ts +60 -0
- package/dist/runtime/components/AEditor.vue +174 -0
- package/dist/runtime/components/AEditor.vue.d.ts +60 -0
- package/dist/runtime/components/AFloatingWindow.d.vue.ts +24 -0
- package/dist/runtime/components/AFloatingWindow.vue +232 -0
- package/dist/runtime/components/AFloatingWindow.vue.d.ts +24 -0
- package/dist/runtime/components/AIconPicker.d.vue.ts +13 -0
- package/dist/runtime/components/AIconPicker.vue +257 -0
- package/dist/runtime/components/AIconPicker.vue.d.ts +13 -0
- package/dist/runtime/components/ANodePanel.d.vue.ts +15 -0
- package/dist/runtime/components/ANodePanel.vue +541 -0
- package/dist/runtime/components/ANodePanel.vue.d.ts +15 -0
- package/dist/runtime/components/ANotifications.d.vue.ts +7 -0
- package/dist/runtime/components/ANotifications.vue +75 -0
- package/dist/runtime/components/ANotifications.vue.d.ts +7 -0
- package/dist/runtime/components/APermissionGuard.d.vue.ts +21 -0
- package/dist/runtime/components/APermissionGuard.vue +22 -0
- package/dist/runtime/components/APermissionGuard.vue.d.ts +21 -0
- package/dist/runtime/components/APresence.d.vue.ts +43 -0
- package/dist/runtime/components/APresence.vue +36 -0
- package/dist/runtime/components/APresence.vue.d.ts +43 -0
- package/dist/runtime/components/AProvider.d.vue.ts +27 -0
- package/dist/runtime/components/AProvider.vue +42 -0
- package/dist/runtime/components/AProvider.vue.d.ts +27 -0
- package/dist/runtime/components/ARoleBadge.d.vue.ts +11 -0
- package/dist/runtime/components/ARoleBadge.vue +29 -0
- package/dist/runtime/components/ARoleBadge.vue.d.ts +11 -0
- package/dist/runtime/components/AVoiceBar.d.vue.ts +13 -0
- package/dist/runtime/components/AVoiceBar.vue +379 -0
- package/dist/runtime/components/AVoiceBar.vue.d.ts +13 -0
- package/dist/runtime/components/AVoiceTile.d.vue.ts +10 -0
- package/dist/runtime/components/AVoiceTile.vue +48 -0
- package/dist/runtime/components/AVoiceTile.vue.d.ts +10 -0
- package/dist/runtime/components/AWindowLayer.d.vue.ts +3 -0
- package/dist/runtime/components/AWindowLayer.vue +17 -0
- package/dist/runtime/components/AWindowLayer.vue.d.ts +3 -0
- package/dist/runtime/components/aware/AArea.d.vue.ts +42 -0
- package/dist/runtime/components/aware/AArea.vue +45 -0
- package/dist/runtime/components/aware/AArea.vue.d.ts +42 -0
- package/dist/runtime/components/aware/AAvatar.d.vue.ts +25 -0
- package/dist/runtime/components/aware/AAvatar.vue +86 -0
- package/dist/runtime/components/aware/AAvatar.vue.d.ts +25 -0
- package/dist/runtime/components/aware/AButton.d.vue.ts +7 -0
- package/dist/runtime/components/aware/AButton.vue +39 -0
- package/dist/runtime/components/aware/AButton.vue.d.ts +7 -0
- package/dist/runtime/components/aware/ACursorLabel.d.vue.ts +12 -0
- package/dist/runtime/components/aware/ACursorLabel.vue +44 -0
- package/dist/runtime/components/aware/ACursorLabel.vue.d.ts +12 -0
- package/dist/runtime/components/aware/ADocBadge.d.vue.ts +11 -0
- package/dist/runtime/components/aware/ADocBadge.vue +27 -0
- package/dist/runtime/components/aware/ADocBadge.vue.d.ts +11 -0
- package/dist/runtime/components/aware/AFacepile.d.vue.ts +20 -0
- package/dist/runtime/components/aware/AFacepile.vue +92 -0
- package/dist/runtime/components/aware/AFacepile.vue.d.ts +20 -0
- package/dist/runtime/components/aware/AInput.d.vue.ts +7 -0
- package/dist/runtime/components/aware/AInput.vue +44 -0
- package/dist/runtime/components/aware/AInput.vue.d.ts +7 -0
- package/dist/runtime/components/aware/ASelect.d.vue.ts +7 -0
- package/dist/runtime/components/aware/ASelect.vue +51 -0
- package/dist/runtime/components/aware/ASelect.vue.d.ts +7 -0
- package/dist/runtime/components/aware/ATextarea.d.vue.ts +7 -0
- package/dist/runtime/components/aware/ATextarea.vue +44 -0
- package/dist/runtime/components/aware/ATextarea.vue.d.ts +7 -0
- package/dist/runtime/components/aware/AUserList.d.vue.ts +17 -0
- package/dist/runtime/components/aware/AUserList.vue +72 -0
- package/dist/runtime/components/aware/AUserList.vue.d.ts +17 -0
- package/dist/runtime/components/renderers/ACalendarRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/ACalendarRenderer.vue +154 -0
- package/dist/runtime/components/renderers/ACalendarRenderer.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/AGalleryRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/AGalleryRenderer.vue +88 -0
- package/dist/runtime/components/renderers/AGalleryRenderer.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/AKanbanRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/AKanbanRenderer.vue +179 -0
- package/dist/runtime/components/renderers/AKanbanRenderer.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/AOutlineRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/AOutlineRenderer.vue +180 -0
- package/dist/runtime/components/renderers/AOutlineRenderer.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/ATableRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/ATableRenderer.vue +191 -0
- package/dist/runtime/components/renderers/ATableRenderer.vue.d.ts +8 -0
- package/dist/runtime/composables/useAAField.d.ts +42 -0
- package/dist/runtime/composables/useAAField.js +62 -0
- package/dist/runtime/composables/useAbraLocale.d.ts +14 -0
- package/dist/runtime/composables/useAbraLocale.js +11 -0
- package/dist/runtime/composables/useAbracadabra.d.ts +11 -0
- package/dist/runtime/composables/useAbracadabra.js +3 -0
- package/dist/runtime/composables/useAbracadabraAuth.d.ts +23 -0
- package/dist/runtime/composables/useAbracadabraAuth.js +22 -0
- package/dist/runtime/composables/useAwareness.d.ts +22 -0
- package/dist/runtime/composables/useAwareness.js +48 -0
- package/dist/runtime/composables/useAwarenessPeers.d.ts +34 -0
- package/dist/runtime/composables/useAwarenessPeers.js +33 -0
- package/dist/runtime/composables/useBackgroundSync.d.ts +37 -0
- package/dist/runtime/composables/useBackgroundSync.js +73 -0
- package/dist/runtime/composables/useChat.d.ts +65 -0
- package/dist/runtime/composables/useChat.js +210 -0
- package/dist/runtime/composables/useChatUsers.d.ts +21 -0
- package/dist/runtime/composables/useChatUsers.js +39 -0
- package/dist/runtime/composables/useChildTree.d.ts +119 -0
- package/dist/runtime/composables/useChildTree.js +100 -0
- package/dist/runtime/composables/useCommandPalette.d.ts +58 -0
- package/dist/runtime/composables/useCommandPalette.js +94 -0
- package/dist/runtime/composables/useConnectionStatus.d.ts +17 -0
- package/dist/runtime/composables/useConnectionStatus.js +37 -0
- package/dist/runtime/composables/useDashboard.d.ts +3 -0
- package/dist/runtime/composables/useDashboard.js +23 -0
- package/dist/runtime/composables/useDocExport.d.ts +5 -0
- package/dist/runtime/composables/useDocExport.js +256 -0
- package/dist/runtime/composables/useDocImport.d.ts +10 -0
- package/dist/runtime/composables/useDocImport.js +227 -0
- package/dist/runtime/composables/useDocJump.d.ts +29 -0
- package/dist/runtime/composables/useDocJump.js +17 -0
- package/dist/runtime/composables/useDocumentPermissions.d.ts +20 -0
- package/dist/runtime/composables/useDocumentPermissions.js +33 -0
- package/dist/runtime/composables/useEditor.d.ts +45 -0
- package/dist/runtime/composables/useEditor.js +121 -0
- package/dist/runtime/composables/useEditorDragHandle.d.ts +26 -0
- package/dist/runtime/composables/useEditorDragHandle.js +219 -0
- package/dist/runtime/composables/useEditorMentions.d.ts +28 -0
- package/dist/runtime/composables/useEditorMentions.js +40 -0
- package/dist/runtime/composables/useEditorSuggestions.d.ts +18 -0
- package/dist/runtime/composables/useEditorSuggestions.js +45 -0
- package/dist/runtime/composables/useEditorToolbar.d.ts +22 -0
- package/dist/runtime/composables/useEditorToolbar.js +60 -0
- package/dist/runtime/composables/useFileBlobStore.d.ts +15 -0
- package/dist/runtime/composables/useFileBlobStore.js +22 -0
- package/dist/runtime/composables/useFileIndex.d.ts +20 -0
- package/dist/runtime/composables/useFileIndex.js +69 -0
- package/dist/runtime/composables/useFollowUser.d.ts +5 -0
- package/dist/runtime/composables/useFollowUser.js +40 -0
- package/dist/runtime/composables/useNotifications.d.ts +82 -0
- package/dist/runtime/composables/useNotifications.js +171 -0
- package/dist/runtime/composables/useOfflineUploadQueue.d.ts +90 -0
- package/dist/runtime/composables/useOfflineUploadQueue.js +33 -0
- package/dist/runtime/composables/usePasskeyAccounts.d.ts +32 -0
- package/dist/runtime/composables/usePasskeyAccounts.js +46 -0
- package/dist/runtime/composables/usePluginRegistry.d.ts +6 -0
- package/dist/runtime/composables/usePluginRegistry.js +3 -0
- package/dist/runtime/composables/useRendererBase.d.ts +186 -0
- package/dist/runtime/composables/useRendererBase.js +46 -0
- package/dist/runtime/composables/useSearchIndex.d.ts +20 -0
- package/dist/runtime/composables/useSearchIndex.js +104 -0
- package/dist/runtime/composables/useTrash.d.ts +50 -0
- package/dist/runtime/composables/useTrash.js +127 -0
- package/dist/runtime/composables/useVoice.d.ts +51 -0
- package/dist/runtime/composables/useVoice.js +220 -0
- package/dist/runtime/composables/useWindowManager.d.ts +122 -0
- package/dist/runtime/composables/useWindowManager.js +141 -0
- package/dist/runtime/composables/useYDoc.d.ts +142 -0
- package/dist/runtime/composables/useYDoc.js +172 -0
- package/dist/runtime/extensions/accordion.d.ts +3 -0
- package/dist/runtime/extensions/accordion.js +49 -0
- package/dist/runtime/extensions/badge.d.ts +2 -0
- package/dist/runtime/extensions/badge.js +39 -0
- package/dist/runtime/extensions/callout.d.ts +2 -0
- package/dist/runtime/extensions/callout.js +28 -0
- package/dist/runtime/extensions/card.d.ts +3 -0
- package/dist/runtime/extensions/card.js +53 -0
- package/dist/runtime/extensions/code-collapse.d.ts +2 -0
- package/dist/runtime/extensions/code-collapse.js +32 -0
- package/dist/runtime/extensions/code-group.d.ts +2 -0
- package/dist/runtime/extensions/code-group.js +17 -0
- package/dist/runtime/extensions/collapsible.d.ts +2 -0
- package/dist/runtime/extensions/collapsible.js +35 -0
- package/dist/runtime/extensions/document-header.d.ts +11 -0
- package/dist/runtime/extensions/document-header.js +82 -0
- package/dist/runtime/extensions/document-meta.d.ts +20 -0
- package/dist/runtime/extensions/document-meta.js +121 -0
- package/dist/runtime/extensions/document.d.ts +6 -0
- package/dist/runtime/extensions/document.js +6 -0
- package/dist/runtime/extensions/file-block.d.ts +15 -0
- package/dist/runtime/extensions/file-block.js +34 -0
- package/dist/runtime/extensions/file-drop.d.ts +6 -0
- package/dist/runtime/extensions/file-drop.js +65 -0
- package/dist/runtime/extensions/kbd.d.ts +2 -0
- package/dist/runtime/extensions/kbd.js +33 -0
- package/dist/runtime/extensions/prose-icon.d.ts +2 -0
- package/dist/runtime/extensions/prose-icon.js +33 -0
- package/dist/runtime/extensions/search-highlight.d.ts +10 -0
- package/dist/runtime/extensions/search-highlight.js +129 -0
- package/dist/runtime/extensions/steps.d.ts +2 -0
- package/dist/runtime/extensions/steps.js +32 -0
- package/dist/runtime/extensions/tabs.d.ts +3 -0
- package/dist/runtime/extensions/tabs.js +49 -0
- package/dist/runtime/extensions/views/AccordionItemView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/AccordionItemView.vue +41 -0
- package/dist/runtime/extensions/views/AccordionItemView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/AccordionView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/AccordionView.vue +22 -0
- package/dist/runtime/extensions/views/AccordionView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/BadgeView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/BadgeView.vue +23 -0
- package/dist/runtime/extensions/views/BadgeView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CalloutView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CalloutView.vue +43 -0
- package/dist/runtime/extensions/views/CalloutView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CardGroupView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CardGroupView.vue +22 -0
- package/dist/runtime/extensions/views/CardGroupView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CardView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CardView.vue +28 -0
- package/dist/runtime/extensions/views/CardView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CodeCollapseView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CodeCollapseView.vue +45 -0
- package/dist/runtime/extensions/views/CodeCollapseView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CodeGroupView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CodeGroupView.vue +53 -0
- package/dist/runtime/extensions/views/CodeGroupView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CollapsibleView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CollapsibleView.vue +42 -0
- package/dist/runtime/extensions/views/CollapsibleView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/FileNodeView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/FileNodeView.vue +140 -0
- package/dist/runtime/extensions/views/FileNodeView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/KbdView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/KbdView.vue +23 -0
- package/dist/runtime/extensions/views/KbdView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/ProseIconView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/ProseIconView.vue +23 -0
- package/dist/runtime/extensions/views/ProseIconView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/StepsView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/StepsView.vue +32 -0
- package/dist/runtime/extensions/views/StepsView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/TabsItemView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/TabsItemView.vue +22 -0
- package/dist/runtime/extensions/views/TabsItemView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/TabsView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/TabsView.vue +56 -0
- package/dist/runtime/extensions/views/TabsView.vue.d.ts +4 -0
- package/dist/runtime/locale.d.ts +134 -0
- package/dist/runtime/locale.js +119 -0
- package/dist/runtime/middleware/abracadabra-auth.d.ts +11 -0
- package/dist/runtime/middleware/abracadabra-auth.js +9 -0
- package/dist/runtime/plugin-abracadabra.client.d.ts +7 -0
- package/dist/runtime/plugin-abracadabra.client.js +898 -0
- package/dist/runtime/plugin-abracadabra.server.d.ts +2 -0
- package/dist/runtime/plugin-abracadabra.server.js +71 -0
- package/dist/runtime/plugin-registry.d.ts +34 -0
- package/dist/runtime/plugin-registry.js +83 -0
- package/dist/runtime/plugin-shared-globals.client.d.ts +2 -0
- package/dist/runtime/plugin-shared-globals.client.js +20 -0
- package/dist/runtime/plugins/core.plugin.d.ts +12 -0
- package/dist/runtime/plugins/core.plugin.js +179 -0
- package/dist/runtime/server/api/_abracadabra/render/[docId].get.d.ts +18 -0
- package/dist/runtime/server/api/_abracadabra/render/[docId].get.js +51 -0
- package/dist/runtime/server/api/_abracadabra/spaces.get.d.ts +11 -0
- package/dist/runtime/server/api/_abracadabra/spaces.get.js +16 -0
- package/dist/runtime/server/plugins/abracadabra-service.d.ts +2 -0
- package/dist/runtime/server/plugins/abracadabra-service.js +116 -0
- package/dist/runtime/server/runners/doc-tree-cache.d.ts +11 -0
- package/dist/runtime/server/runners/doc-tree-cache.js +65 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/docCache.d.ts +25 -0
- package/dist/runtime/server/utils/docCache.js +131 -0
- package/dist/runtime/server/utils/serverRunner.d.ts +28 -0
- package/dist/runtime/server/utils/serverRunner.js +58 -0
- package/dist/runtime/types.d.ts +444 -0
- package/dist/runtime/types.js +93 -0
- package/dist/runtime/utils/VoiceClient.d.ts +94 -0
- package/dist/runtime/utils/VoiceClient.js +599 -0
- package/dist/runtime/utils/avatarStyle.d.ts +15 -0
- package/dist/runtime/utils/avatarStyle.js +20 -0
- package/dist/runtime/utils/colorPalettes.d.ts +13 -0
- package/dist/runtime/utils/colorPalettes.js +49 -0
- package/dist/runtime/utils/docTypes.d.ts +129 -0
- package/dist/runtime/utils/docTypes.js +116 -0
- package/dist/runtime/utils/markdownToYjs.d.ts +23 -0
- package/dist/runtime/utils/markdownToYjs.js +440 -0
- package/dist/runtime/utils/metaFieldDefinitions.d.ts +7 -0
- package/dist/runtime/utils/metaFieldDefinitions.js +182 -0
- package/dist/runtime/utils/voiceErrors.d.ts +33 -0
- package/dist/runtime/utils/voiceErrors.js +54 -0
- package/dist/runtime/utils/yjsConvert.d.ts +14 -0
- package/dist/runtime/utils/yjsConvert.js +331 -0
- package/dist/types.d.mts +13 -0
- package/package.json +100 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { shallowRef, ref, computed } from "vue";
|
|
2
|
+
import { PluginRegistry } from "./plugin-registry.js";
|
|
3
|
+
export default defineNuxtPlugin({
|
|
4
|
+
name: "abracadabra:server-stub",
|
|
5
|
+
enforce: "post",
|
|
6
|
+
setup(nuxtApp) {
|
|
7
|
+
const registry = new PluginRegistry();
|
|
8
|
+
registry.freeze();
|
|
9
|
+
const noop = () => {
|
|
10
|
+
};
|
|
11
|
+
const noopAsync = async () => {
|
|
12
|
+
};
|
|
13
|
+
nuxtApp.provide("abracadabra", {
|
|
14
|
+
// CRDT objects — null on server
|
|
15
|
+
doc: shallowRef(null),
|
|
16
|
+
provider: shallowRef(null),
|
|
17
|
+
client: shallowRef(null),
|
|
18
|
+
keystore: shallowRef(null),
|
|
19
|
+
// Connection state
|
|
20
|
+
status: ref("disconnected"),
|
|
21
|
+
synced: ref(false),
|
|
22
|
+
isReady: ref(false),
|
|
23
|
+
connectionError: ref(null),
|
|
24
|
+
isConnectionBlocked: ref(false),
|
|
25
|
+
// User identity
|
|
26
|
+
userName: ref(""),
|
|
27
|
+
userColor: ref("#6366f1"),
|
|
28
|
+
userColorName: ref("indigo"),
|
|
29
|
+
userNeutralColorName: ref("zinc"),
|
|
30
|
+
userCount: ref(0),
|
|
31
|
+
publicKeyB64: ref(""),
|
|
32
|
+
isClaimed: ref(false),
|
|
33
|
+
identityLost: ref(false),
|
|
34
|
+
needsReauth: ref(false),
|
|
35
|
+
requirePasskeyOnLogin: ref(false),
|
|
36
|
+
// Servers / spaces
|
|
37
|
+
currentServerUrl: ref(""),
|
|
38
|
+
savedServers: ref([]),
|
|
39
|
+
currentServerSpaces: computed(() => []),
|
|
40
|
+
currentServerSpacesEnabled: computed(() => false),
|
|
41
|
+
// Misc
|
|
42
|
+
pendingInviteCode: ref(null),
|
|
43
|
+
logs: ref([]),
|
|
44
|
+
// Plugin registry (empty, frozen)
|
|
45
|
+
registry,
|
|
46
|
+
// Methods — all no-ops on server
|
|
47
|
+
addLog: noop,
|
|
48
|
+
setUserName: noop,
|
|
49
|
+
setUserColor: noop,
|
|
50
|
+
setNeutralColor: noop,
|
|
51
|
+
setRequirePasskey: noop,
|
|
52
|
+
reconnect: noop,
|
|
53
|
+
removeServer: noop,
|
|
54
|
+
claimAccount: noopAsync,
|
|
55
|
+
loginWithHardware: noopAsync,
|
|
56
|
+
logout: noopAsync,
|
|
57
|
+
addServer: noopAsync,
|
|
58
|
+
switchServer: noopAsync,
|
|
59
|
+
switchSpace: noopAsync,
|
|
60
|
+
refreshSpaces: noopAsync,
|
|
61
|
+
createSpace: noopAsync,
|
|
62
|
+
updateSpace: noopAsync,
|
|
63
|
+
deleteSpace: noopAsync,
|
|
64
|
+
redeemInvite: noopAsync,
|
|
65
|
+
createInvite: async () => ({}),
|
|
66
|
+
listInvites: async () => [],
|
|
67
|
+
revokeInvite: noopAsync,
|
|
68
|
+
init: noopAsync
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Extension } from '@tiptap/core';
|
|
2
|
+
import type { AbracadabraPlugin, AbracadabraPageType, AbracadabraToolbarItem, AbracadabraSuggestionItem, AbracadabraDragHandleItem, AbracadabraMentionProvider, AbracadabraAwarenessContribution, AbracadabraCommandItem, AbracadabraNodePanelSlot, AbracadabraSettingsPanel, AbracadabraKeyboardShortcut, EditorPluginCtx, DragHandlePluginCtx, CommandPaletteCtx } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* PluginRegistry — manages the lifecycle of AbracadabraPlugin instances.
|
|
5
|
+
*
|
|
6
|
+
* Instantiated once per Nuxt app inside the main client plugin.
|
|
7
|
+
* After freezePluginRegistry() is called, no new plugins can be registered.
|
|
8
|
+
* All aggregator methods are safe to call after freezing.
|
|
9
|
+
*/
|
|
10
|
+
export declare class PluginRegistry {
|
|
11
|
+
private _plugins;
|
|
12
|
+
private _frozen;
|
|
13
|
+
register(plugin: AbracadabraPlugin): void;
|
|
14
|
+
/** Lock the registry. Called after all plugins (built-in + external) are loaded. */
|
|
15
|
+
freeze(): void;
|
|
16
|
+
isFrozen(): boolean;
|
|
17
|
+
getPlugins(): readonly AbracadabraPlugin[];
|
|
18
|
+
getAllExtensions(): Extension[];
|
|
19
|
+
/** Waits until all plugins with async extension bundles have finished loading. */
|
|
20
|
+
waitForExtensions(): Promise<void>;
|
|
21
|
+
getServerExtensions(): Extension[];
|
|
22
|
+
getAllPageTypes(): Record<string, AbracadabraPageType>;
|
|
23
|
+
getAllCustomHandlers(): Record<string, (...args: any[]) => any>;
|
|
24
|
+
getAllToolbarItems(ctx: EditorPluginCtx): AbracadabraToolbarItem[][];
|
|
25
|
+
getAllBubbleMenuItems(ctx: EditorPluginCtx): AbracadabraToolbarItem[][];
|
|
26
|
+
getAllSuggestionItems(ctx: EditorPluginCtx): AbracadabraSuggestionItem[][];
|
|
27
|
+
getAllDragHandleItems(ctx: DragHandlePluginCtx): AbracadabraDragHandleItem[][];
|
|
28
|
+
getAllMentionProviders(): AbracadabraMentionProvider[];
|
|
29
|
+
getAllAwarenessContributions(): AbracadabraAwarenessContribution[];
|
|
30
|
+
getAllCommandPaletteItems(ctx: CommandPaletteCtx): Promise<AbracadabraCommandItem[]>;
|
|
31
|
+
getAllNodePanelSlots(): AbracadabraNodePanelSlot[];
|
|
32
|
+
getSettingsPanels(): AbracadabraSettingsPanel[];
|
|
33
|
+
getAllKeyboardShortcuts(): AbracadabraKeyboardShortcut[];
|
|
34
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export class PluginRegistry {
|
|
2
|
+
_plugins = [];
|
|
3
|
+
_frozen = false;
|
|
4
|
+
register(plugin) {
|
|
5
|
+
if (this._frozen) {
|
|
6
|
+
console.warn(`[abracadabra] Plugin registry frozen \u2014 cannot register "${plugin.name}"`);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (this._plugins.some((p) => p.name === plugin.name)) {
|
|
10
|
+
console.warn(`[abracadabra] Plugin "${plugin.name}" already registered`);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
this._plugins.push(plugin);
|
|
14
|
+
}
|
|
15
|
+
/** Lock the registry. Called after all plugins (built-in + external) are loaded. */
|
|
16
|
+
freeze() {
|
|
17
|
+
this._frozen = true;
|
|
18
|
+
}
|
|
19
|
+
isFrozen() {
|
|
20
|
+
return this._frozen;
|
|
21
|
+
}
|
|
22
|
+
getPlugins() {
|
|
23
|
+
return this._plugins;
|
|
24
|
+
}
|
|
25
|
+
// ── Aggregated getters ───────────────────────────────────────────────────────
|
|
26
|
+
getAllExtensions() {
|
|
27
|
+
return this._plugins.flatMap((p) => p.extensions?.() ?? []);
|
|
28
|
+
}
|
|
29
|
+
/** Waits until all plugins with async extension bundles have finished loading. */
|
|
30
|
+
async waitForExtensions() {
|
|
31
|
+
await Promise.all(this._plugins.map((p) => p.extensionsReady ?? Promise.resolve()));
|
|
32
|
+
}
|
|
33
|
+
getServerExtensions() {
|
|
34
|
+
return this._plugins.flatMap((p) => p.serverExtensions?.() ?? []);
|
|
35
|
+
}
|
|
36
|
+
getAllPageTypes() {
|
|
37
|
+
const merged = {};
|
|
38
|
+
for (const p of this._plugins) {
|
|
39
|
+
if (p.pageTypes) Object.assign(merged, p.pageTypes);
|
|
40
|
+
}
|
|
41
|
+
return merged;
|
|
42
|
+
}
|
|
43
|
+
getAllCustomHandlers() {
|
|
44
|
+
const merged = {};
|
|
45
|
+
for (const p of this._plugins) {
|
|
46
|
+
if (p.customHandlers) Object.assign(merged, p.customHandlers());
|
|
47
|
+
}
|
|
48
|
+
return merged;
|
|
49
|
+
}
|
|
50
|
+
getAllToolbarItems(ctx) {
|
|
51
|
+
return this._plugins.flatMap((p) => p.toolbarItems?.(ctx) ?? []);
|
|
52
|
+
}
|
|
53
|
+
getAllBubbleMenuItems(ctx) {
|
|
54
|
+
return this._plugins.flatMap((p) => p.bubbleMenuItems?.(ctx) ?? []);
|
|
55
|
+
}
|
|
56
|
+
getAllSuggestionItems(ctx) {
|
|
57
|
+
return this._plugins.flatMap((p) => p.suggestionItems?.(ctx) ?? []);
|
|
58
|
+
}
|
|
59
|
+
getAllDragHandleItems(ctx) {
|
|
60
|
+
return this._plugins.flatMap((p) => p.dragHandleItems?.(ctx) ?? []);
|
|
61
|
+
}
|
|
62
|
+
getAllMentionProviders() {
|
|
63
|
+
return this._plugins.flatMap((p) => p.mentionProviders ?? []);
|
|
64
|
+
}
|
|
65
|
+
getAllAwarenessContributions() {
|
|
66
|
+
return this._plugins.flatMap((p) => p.awarenessContributions ?? []);
|
|
67
|
+
}
|
|
68
|
+
async getAllCommandPaletteItems(ctx) {
|
|
69
|
+
const results = await Promise.all(
|
|
70
|
+
this._plugins.filter((p) => p.commandPaletteItems).map((p) => Promise.resolve(p.commandPaletteItems(ctx)))
|
|
71
|
+
);
|
|
72
|
+
return results.flat().filter((item) => !item.when || item.when(ctx));
|
|
73
|
+
}
|
|
74
|
+
getAllNodePanelSlots() {
|
|
75
|
+
return this._plugins.flatMap((p) => p.nodePanelSlots ?? []);
|
|
76
|
+
}
|
|
77
|
+
getSettingsPanels() {
|
|
78
|
+
return this._plugins.flatMap((p) => p.settingsPanel ? [p.settingsPanel] : []);
|
|
79
|
+
}
|
|
80
|
+
getAllKeyboardShortcuts() {
|
|
81
|
+
return this._plugins.flatMap((p) => p.keyboardShortcuts ?? []);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as Vue from "vue";
|
|
2
|
+
import * as Yjs from "yjs";
|
|
3
|
+
export default defineNuxtPlugin({
|
|
4
|
+
name: "abracadabra:shared-globals",
|
|
5
|
+
enforce: "pre",
|
|
6
|
+
setup() {
|
|
7
|
+
Promise.all([
|
|
8
|
+
import("@tiptap/core").catch(() => null),
|
|
9
|
+
import("@tiptap/vue-3").catch(() => null)
|
|
10
|
+
]).then(([core, vue3]) => {
|
|
11
|
+
;
|
|
12
|
+
globalThis.__ABRACA_SHARED__ = {
|
|
13
|
+
vue: Vue,
|
|
14
|
+
yjs: Yjs,
|
|
15
|
+
...core ? { "@tiptap/core": core } : {},
|
|
16
|
+
...vue3 ? { "@tiptap/vue-3": vue3 } : {}
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core built-in plugin for nuxt-abracadabra.
|
|
3
|
+
*
|
|
4
|
+
* Provides structural TipTap extensions that most collaborative documents need.
|
|
5
|
+
* Extensions are split into two loaders:
|
|
6
|
+
* - loadClientExtensions(): full set including Vue NodeViews (client only)
|
|
7
|
+
* - loadServerExtensions(): pure ProseMirror extensions safe for SSR rendering
|
|
8
|
+
*
|
|
9
|
+
* Registered automatically by the module.
|
|
10
|
+
*/
|
|
11
|
+
import type { AbracadabraPlugin } from '../types.js';
|
|
12
|
+
export declare const corePlugin: AbracadabraPlugin;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { DOC_TYPES } from "../utils/docTypes.js";
|
|
2
|
+
async function loadClientExtensions() {
|
|
3
|
+
const [
|
|
4
|
+
{ default: TaskList },
|
|
5
|
+
{ default: TaskItem },
|
|
6
|
+
{ Table },
|
|
7
|
+
{ default: TableRow },
|
|
8
|
+
{ default: TableHeader },
|
|
9
|
+
{ default: TableCell },
|
|
10
|
+
{ default: CharacterCount },
|
|
11
|
+
{ default: TextAlign },
|
|
12
|
+
{ default: Highlight },
|
|
13
|
+
{ default: Color },
|
|
14
|
+
{ TextStyle },
|
|
15
|
+
{ default: Superscript },
|
|
16
|
+
{ default: Subscript },
|
|
17
|
+
{ default: CodeBlockLowlight },
|
|
18
|
+
{ createLowlight, common },
|
|
19
|
+
{ Document },
|
|
20
|
+
{ DocumentHeader },
|
|
21
|
+
{ DocumentMeta },
|
|
22
|
+
{ FileDrop },
|
|
23
|
+
{ SearchHighlight },
|
|
24
|
+
{ Callout },
|
|
25
|
+
{ Collapsible },
|
|
26
|
+
{ Accordion, AccordionItem },
|
|
27
|
+
{ Tabs, TabsItem },
|
|
28
|
+
{ Card, CardGroup },
|
|
29
|
+
{ Steps },
|
|
30
|
+
{ CodeCollapse },
|
|
31
|
+
{ CodeGroup },
|
|
32
|
+
{ Badge },
|
|
33
|
+
{ Kbd },
|
|
34
|
+
{ ProseIcon },
|
|
35
|
+
{ FileBlock }
|
|
36
|
+
] = await Promise.all([
|
|
37
|
+
import("@tiptap/extension-task-list"),
|
|
38
|
+
import("@tiptap/extension-task-item"),
|
|
39
|
+
import("@tiptap/extension-table"),
|
|
40
|
+
import("@tiptap/extension-table-row"),
|
|
41
|
+
import("@tiptap/extension-table-header"),
|
|
42
|
+
import("@tiptap/extension-table-cell"),
|
|
43
|
+
import("@tiptap/extension-character-count"),
|
|
44
|
+
import("@tiptap/extension-text-align"),
|
|
45
|
+
import("@tiptap/extension-highlight"),
|
|
46
|
+
import("@tiptap/extension-color"),
|
|
47
|
+
import("@tiptap/extension-text-style"),
|
|
48
|
+
import("@tiptap/extension-superscript"),
|
|
49
|
+
import("@tiptap/extension-subscript"),
|
|
50
|
+
import("@tiptap/extension-code-block-lowlight"),
|
|
51
|
+
import("lowlight"),
|
|
52
|
+
import("../extensions/document.js"),
|
|
53
|
+
import("../extensions/document-header.js"),
|
|
54
|
+
import("../extensions/document-meta.js"),
|
|
55
|
+
import("../extensions/file-drop.js"),
|
|
56
|
+
import("../extensions/search-highlight.js"),
|
|
57
|
+
import("../extensions/callout.js"),
|
|
58
|
+
import("../extensions/collapsible.js"),
|
|
59
|
+
import("../extensions/accordion.js"),
|
|
60
|
+
import("../extensions/tabs.js"),
|
|
61
|
+
import("../extensions/card.js"),
|
|
62
|
+
import("../extensions/steps.js"),
|
|
63
|
+
import("../extensions/code-collapse.js"),
|
|
64
|
+
import("../extensions/code-group.js"),
|
|
65
|
+
import("../extensions/badge.js"),
|
|
66
|
+
import("../extensions/kbd.js"),
|
|
67
|
+
import("../extensions/prose-icon.js"),
|
|
68
|
+
import("../extensions/file-block.js")
|
|
69
|
+
]);
|
|
70
|
+
const lowlight = createLowlight(common);
|
|
71
|
+
return [
|
|
72
|
+
TaskList,
|
|
73
|
+
TaskItem.configure({ nested: true }),
|
|
74
|
+
Table.configure({ resizable: true }),
|
|
75
|
+
TableRow,
|
|
76
|
+
TableHeader,
|
|
77
|
+
TableCell,
|
|
78
|
+
CharacterCount,
|
|
79
|
+
TextAlign.configure({ types: ["heading", "paragraph"] }),
|
|
80
|
+
Highlight.configure({ multicolor: true }),
|
|
81
|
+
Color,
|
|
82
|
+
TextStyle,
|
|
83
|
+
Superscript,
|
|
84
|
+
Subscript,
|
|
85
|
+
CodeBlockLowlight.configure({ lowlight }),
|
|
86
|
+
// Document structure
|
|
87
|
+
Document,
|
|
88
|
+
DocumentHeader,
|
|
89
|
+
DocumentMeta,
|
|
90
|
+
// File handling
|
|
91
|
+
FileDrop,
|
|
92
|
+
// Search
|
|
93
|
+
SearchHighlight,
|
|
94
|
+
// Content blocks
|
|
95
|
+
Callout,
|
|
96
|
+
Collapsible,
|
|
97
|
+
Accordion,
|
|
98
|
+
AccordionItem,
|
|
99
|
+
Tabs,
|
|
100
|
+
TabsItem,
|
|
101
|
+
Card,
|
|
102
|
+
CardGroup,
|
|
103
|
+
Steps,
|
|
104
|
+
CodeCollapse,
|
|
105
|
+
CodeGroup,
|
|
106
|
+
// Inline nodes
|
|
107
|
+
Badge,
|
|
108
|
+
Kbd,
|
|
109
|
+
ProseIcon,
|
|
110
|
+
// File block
|
|
111
|
+
FileBlock
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
async function loadServerExtensions() {
|
|
115
|
+
const [
|
|
116
|
+
{ default: StarterKit },
|
|
117
|
+
{ default: CodeBlockLowlight },
|
|
118
|
+
{ createLowlight, common },
|
|
119
|
+
{ Document },
|
|
120
|
+
{ DocumentHeader },
|
|
121
|
+
{ DocumentMeta },
|
|
122
|
+
{ FileDrop }
|
|
123
|
+
] = await Promise.all([
|
|
124
|
+
import("@tiptap/starter-kit"),
|
|
125
|
+
import("@tiptap/extension-code-block-lowlight"),
|
|
126
|
+
import("lowlight"),
|
|
127
|
+
import("../extensions/document.js"),
|
|
128
|
+
import("../extensions/document-header.js"),
|
|
129
|
+
import("../extensions/document-meta.js"),
|
|
130
|
+
import("../extensions/file-drop.js")
|
|
131
|
+
]);
|
|
132
|
+
const lowlight = createLowlight(common);
|
|
133
|
+
return [
|
|
134
|
+
StarterKit.configure({
|
|
135
|
+
history: false,
|
|
136
|
+
codeBlock: false,
|
|
137
|
+
document: false
|
|
138
|
+
}),
|
|
139
|
+
CodeBlockLowlight.configure({ lowlight }),
|
|
140
|
+
Document,
|
|
141
|
+
DocumentHeader,
|
|
142
|
+
DocumentMeta,
|
|
143
|
+
FileDrop
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
let _cachedClient = null;
|
|
147
|
+
let _cachedServer = null;
|
|
148
|
+
const _clientReady = loadClientExtensions().then((exts) => {
|
|
149
|
+
_cachedClient = exts;
|
|
150
|
+
}).catch((e) => console.warn("[abracadabra:core] Failed to preload client extensions:", e));
|
|
151
|
+
export const corePlugin = {
|
|
152
|
+
name: "core",
|
|
153
|
+
label: "Core",
|
|
154
|
+
version: "0.1.0",
|
|
155
|
+
description: "Core TipTap extensions: rich text, tables, tasks, code blocks, document structure, and more.",
|
|
156
|
+
// Expose the loading promise so PluginRegistry.waitForExtensions() can await it.
|
|
157
|
+
extensionsReady: _clientReady,
|
|
158
|
+
pageTypes: Object.fromEntries(
|
|
159
|
+
Object.entries(DOC_TYPES).map(([key, def]) => [
|
|
160
|
+
key,
|
|
161
|
+
{
|
|
162
|
+
label: def.label,
|
|
163
|
+
icon: def.icon,
|
|
164
|
+
component: def.component,
|
|
165
|
+
hasEditor: def.hasEditor
|
|
166
|
+
}
|
|
167
|
+
])
|
|
168
|
+
),
|
|
169
|
+
extensions() {
|
|
170
|
+
return _cachedClient ?? [];
|
|
171
|
+
},
|
|
172
|
+
serverExtensions() {
|
|
173
|
+
if (_cachedServer) return _cachedServer;
|
|
174
|
+
loadServerExtensions().then((exts) => {
|
|
175
|
+
_cachedServer = exts;
|
|
176
|
+
}).catch((e) => console.warn("[abracadabra:core] Failed to load server extensions:", e));
|
|
177
|
+
return _cachedServer ?? [];
|
|
178
|
+
}
|
|
179
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GET /api/_abracadabra/render/:docId
|
|
3
|
+
*
|
|
4
|
+
* SSR-friendly endpoint that returns document HTML + metadata.
|
|
5
|
+
*
|
|
6
|
+
* Strategy (fastest first):
|
|
7
|
+
* 1. CRDT cache — if the service provider is running, documents are kept
|
|
8
|
+
* pre-rendered in Nitro storage with 2s debounce on each update.
|
|
9
|
+
* This path is effectively instant and always fresh.
|
|
10
|
+
* 2. REST fallback — fetches HTML + metadata from the Abracadabra REST API.
|
|
11
|
+
* Used when the service provider is not configured or for uncached docs.
|
|
12
|
+
*
|
|
13
|
+
* Usage in a Nuxt page:
|
|
14
|
+
* const { data } = await useFetch(`/api/_abracadabra/render/${docId}`)
|
|
15
|
+
* // data.value: { html, title, type, meta, docId, source }
|
|
16
|
+
*/
|
|
17
|
+
declare const _default: any;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export default defineCachedEventHandler(async (event) => {
|
|
2
|
+
const config = useRuntimeConfig();
|
|
3
|
+
const baseUrl = config.public?.abracadabra?.url;
|
|
4
|
+
if (!baseUrl) {
|
|
5
|
+
throw createError({ statusCode: 500, message: "[abracadabra] module url not configured" });
|
|
6
|
+
}
|
|
7
|
+
const docId = getRouterParam(event, "docId");
|
|
8
|
+
if (!docId) {
|
|
9
|
+
throw createError({ statusCode: 400, message: "docId is required" });
|
|
10
|
+
}
|
|
11
|
+
const storage = useStorage();
|
|
12
|
+
const [cachedHtml, cachedJson] = await Promise.all([
|
|
13
|
+
storage.getItem(`doc-cache:html:${docId}`),
|
|
14
|
+
storage.getItem(`doc-cache:json:${docId}`)
|
|
15
|
+
]);
|
|
16
|
+
if (cachedHtml !== null) {
|
|
17
|
+
const treeEntry = cachedJson?.["doc-tree"]?.[docId] ?? {};
|
|
18
|
+
return {
|
|
19
|
+
docId,
|
|
20
|
+
html: cachedHtml ?? "",
|
|
21
|
+
title: treeEntry.label ?? "",
|
|
22
|
+
type: treeEntry.type ?? "doc",
|
|
23
|
+
meta: treeEntry.meta ?? {},
|
|
24
|
+
source: "crdt-cache"
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const token = getHeader(event, "x-abra-token") ?? getHeader(event, "authorization") ?? "";
|
|
28
|
+
const authHeader = token.startsWith("Bearer ") ? token : token ? `Bearer ${token}` : void 0;
|
|
29
|
+
const headers = {};
|
|
30
|
+
if (authHeader) headers["Authorization"] = authHeader;
|
|
31
|
+
const [exportRes, metaRes] = await Promise.all([
|
|
32
|
+
$fetch(`${baseUrl}/api/docs/${docId}/export?format=html`, {
|
|
33
|
+
headers
|
|
34
|
+
}).catch(() => null),
|
|
35
|
+
$fetch(
|
|
36
|
+
`${baseUrl}/api/docs/${docId}`,
|
|
37
|
+
{ headers }
|
|
38
|
+
).catch(() => null)
|
|
39
|
+
]);
|
|
40
|
+
return {
|
|
41
|
+
docId,
|
|
42
|
+
html: exportRes?.html ?? "",
|
|
43
|
+
title: metaRes?.label ?? "",
|
|
44
|
+
type: metaRes?.type ?? "doc",
|
|
45
|
+
meta: metaRes?.meta ?? {},
|
|
46
|
+
source: "rest"
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
maxAge: 60,
|
|
50
|
+
getKey: (event) => `abra:render:${getRouterParam(event, "docId")}`
|
|
51
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GET /api/_abracadabra/spaces
|
|
3
|
+
*
|
|
4
|
+
* Proxies the Abracadabra REST space list endpoint.
|
|
5
|
+
* Enables app devs to server-side render space navigation.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const { data } = await useFetch('/api/_abracadabra/spaces')
|
|
9
|
+
*/
|
|
10
|
+
declare const _default: any;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default defineCachedEventHandler(async (event) => {
|
|
2
|
+
const config = useRuntimeConfig();
|
|
3
|
+
const baseUrl = config.public?.abracadabra?.url;
|
|
4
|
+
if (!baseUrl) {
|
|
5
|
+
throw createError({ statusCode: 500, message: "[abracadabra] module url not configured" });
|
|
6
|
+
}
|
|
7
|
+
const token = getHeader(event, "x-abra-token") ?? getHeader(event, "authorization") ?? "";
|
|
8
|
+
const authHeader = token.startsWith("Bearer ") ? token : token ? `Bearer ${token}` : void 0;
|
|
9
|
+
const headers = {};
|
|
10
|
+
if (authHeader) headers["Authorization"] = authHeader;
|
|
11
|
+
const spaces = await $fetch(`${baseUrl}/api/spaces`, { headers }).catch(() => []);
|
|
12
|
+
return spaces;
|
|
13
|
+
}, {
|
|
14
|
+
maxAge: 30,
|
|
15
|
+
getKey: () => "abra:spaces"
|
|
16
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { registerServerPlugin, bootRunners, shutdownAllRunners } from "../utils/serverRunner.js";
|
|
2
|
+
import { createDocCacheAPI } from "../utils/docCache.js";
|
|
3
|
+
import { docTreeCacheRunner } from "../runners/doc-tree-cache.js";
|
|
4
|
+
function fromBase64Url(str) {
|
|
5
|
+
const b = atob(str.replace(/-/g, "+").replace(/_/g, "/").padEnd(str.length + (4 - str.length % 4) % 4, "="));
|
|
6
|
+
const a = new Uint8Array(b.length);
|
|
7
|
+
for (let i = 0; i < b.length; i++) a[i] = b.charCodeAt(i);
|
|
8
|
+
return a;
|
|
9
|
+
}
|
|
10
|
+
function toBase64Url(bytes) {
|
|
11
|
+
let b = "";
|
|
12
|
+
for (const byte of bytes) b += String.fromCharCode(byte);
|
|
13
|
+
return btoa(b).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
14
|
+
}
|
|
15
|
+
export default defineNitroPlugin(async (nitroApp) => {
|
|
16
|
+
const config = useRuntimeConfig();
|
|
17
|
+
const abraConfig = config.abracadabra;
|
|
18
|
+
const pubKeyB64 = abraConfig?.servicePublicKey ?? "";
|
|
19
|
+
const privKeyB64 = abraConfig?.servicePrivateKey ?? "";
|
|
20
|
+
const rootDocIdOverride = abraConfig?.serviceRootDocId ?? "";
|
|
21
|
+
const disabled = abraConfig?.serviceDisabled ?? false;
|
|
22
|
+
if (disabled || !pubKeyB64 || !privKeyB64) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let wsp = null;
|
|
26
|
+
try {
|
|
27
|
+
const [
|
|
28
|
+
{ AbracadabraClient, AbracadabraProvider, HocuspocusProviderWebsocket },
|
|
29
|
+
ed,
|
|
30
|
+
{ sha512 },
|
|
31
|
+
Y
|
|
32
|
+
] = await Promise.all([
|
|
33
|
+
import("@abraca/dabra"),
|
|
34
|
+
import("@noble/ed25519"),
|
|
35
|
+
import("@noble/hashes/sha2.js"),
|
|
36
|
+
import("yjs")
|
|
37
|
+
]);
|
|
38
|
+
ed.etc = ed.etc ?? {};
|
|
39
|
+
ed.etc.sha512Sync = (m) => sha512(m);
|
|
40
|
+
const privKey = fromBase64Url(privKeyB64);
|
|
41
|
+
const client = new AbracadabraClient({
|
|
42
|
+
url: config.public?.abracadabra?.url,
|
|
43
|
+
persistAuth: false
|
|
44
|
+
});
|
|
45
|
+
await client.loginWithKey(pubKeyB64, async (challenge) => {
|
|
46
|
+
const sig = await ed.sign(fromBase64Url(challenge), privKey);
|
|
47
|
+
return toBase64Url(sig);
|
|
48
|
+
});
|
|
49
|
+
console.log("[abracadabra-service] Authenticated as service role");
|
|
50
|
+
const wsUrl = client.wsUrl;
|
|
51
|
+
wsp = new HocuspocusProviderWebsocket({
|
|
52
|
+
url: wsUrl,
|
|
53
|
+
delay: 1e3,
|
|
54
|
+
minDelay: 1e3,
|
|
55
|
+
maxDelay: 3e4,
|
|
56
|
+
factor: 2,
|
|
57
|
+
jitter: true,
|
|
58
|
+
maxAttempts: 0
|
|
59
|
+
});
|
|
60
|
+
let rootDocId = rootDocIdOverride;
|
|
61
|
+
if (!rootDocId) {
|
|
62
|
+
try {
|
|
63
|
+
const info = await $fetch(`${config.public?.abracadabra?.url}/info`);
|
|
64
|
+
rootDocId = info?.index_doc_id ?? "";
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!rootDocId) {
|
|
69
|
+
console.warn("[abracadabra-service] Could not determine root doc ID. Set service.rootDocId in module options.");
|
|
70
|
+
wsp.destroy?.();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const rootDoc = new Y.Doc();
|
|
74
|
+
const rootProvider = new AbracadabraProvider({
|
|
75
|
+
client,
|
|
76
|
+
document: rootDoc,
|
|
77
|
+
name: rootDocId,
|
|
78
|
+
websocketProvider: wsp,
|
|
79
|
+
disableOfflineStore: true
|
|
80
|
+
});
|
|
81
|
+
rootProvider.attach?.();
|
|
82
|
+
await Promise.race([
|
|
83
|
+
new Promise((resolve) => rootProvider.on("synced", resolve)),
|
|
84
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("sync timeout")), 3e4))
|
|
85
|
+
]);
|
|
86
|
+
console.log("[abracadabra-service] Root doc synced");
|
|
87
|
+
const storage = useStorage();
|
|
88
|
+
const ctx = {
|
|
89
|
+
client,
|
|
90
|
+
wsp,
|
|
91
|
+
rootDoc,
|
|
92
|
+
rootProvider,
|
|
93
|
+
storage,
|
|
94
|
+
docCache: createDocCacheAPI(rootDoc)
|
|
95
|
+
};
|
|
96
|
+
const publicConfig = config.public?.abracadabra;
|
|
97
|
+
if (publicConfig?.features?.serverCache !== false) {
|
|
98
|
+
const coreServerPlugin = {
|
|
99
|
+
name: "abracadabra:core-server",
|
|
100
|
+
serverRunners: [docTreeCacheRunner]
|
|
101
|
+
};
|
|
102
|
+
registerServerPlugin(coreServerPlugin);
|
|
103
|
+
}
|
|
104
|
+
await nitroApp.hooks.callHook("abracadabra:before-runners", ctx);
|
|
105
|
+
await bootRunners(ctx);
|
|
106
|
+
console.log("[abracadabra-service] All runners started");
|
|
107
|
+
nitroApp.hooks.hook("close", async () => {
|
|
108
|
+
await shutdownAllRunners();
|
|
109
|
+
wsp?.destroy?.();
|
|
110
|
+
console.log("[abracadabra-service] Shutdown complete");
|
|
111
|
+
});
|
|
112
|
+
} catch (err) {
|
|
113
|
+
console.error("[abracadabra-service] Failed to initialize:", err?.message ?? err);
|
|
114
|
+
wsp?.destroy?.();
|
|
115
|
+
}
|
|
116
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in doc-tree-cache server runner.
|
|
3
|
+
*
|
|
4
|
+
* Watches the root doc-tree Y.Map, loads each child document via the
|
|
5
|
+
* service provider, and keeps an HTML+JSON render of every document in
|
|
6
|
+
* Nitro storage. The SSR render route reads from this cache first.
|
|
7
|
+
*
|
|
8
|
+
* Registered automatically on the core plugin when features.serverCache !== false.
|
|
9
|
+
*/
|
|
10
|
+
import type { ServerRunnerDefinition } from '../../types.js';
|
|
11
|
+
export declare const docTreeCacheRunner: ServerRunnerDefinition;
|