@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.
- package/dist/module.json +1 -1
- package/dist/runtime/components/ADocSubPageList.vue +8 -0
- package/dist/runtime/components/ANodePanel.vue +11 -1
- package/dist/runtime/components/ANodePanelStack.d.vue.ts +19 -0
- package/dist/runtime/components/ANodePanelStack.vue +35 -0
- package/dist/runtime/components/ANodePanelStack.vue.d.ts +19 -0
- package/dist/runtime/components/APresence.d.vue.ts +1 -13
- package/dist/runtime/components/APresence.vue.d.ts +1 -13
- package/dist/runtime/components/ATagsPopover.d.vue.ts +34 -0
- package/dist/runtime/components/ATagsPopover.vue +114 -0
- package/dist/runtime/components/ATagsPopover.vue.d.ts +34 -0
- package/dist/runtime/components/chat/AChatMessages.d.vue.ts +14 -0
- package/dist/runtime/components/chat/AChatMessages.vue +94 -14
- package/dist/runtime/components/chat/AChatMessages.vue.d.ts +14 -0
- package/dist/runtime/components/chat/AChatPanel.d.vue.ts +10 -0
- package/dist/runtime/components/chat/AChatPanel.vue +5 -1
- package/dist/runtime/components/chat/AChatPanel.vue.d.ts +10 -0
- package/dist/runtime/components/chat/ANodeChatPanel.d.vue.ts +10 -3
- package/dist/runtime/components/chat/ANodeChatPanel.vue +6 -2
- package/dist/runtime/components/chat/ANodeChatPanel.vue.d.ts +10 -3
- package/dist/runtime/components/docs/ADocsSearch.d.vue.ts +2 -2
- package/dist/runtime/components/docs/ADocsSearch.vue.d.ts +2 -2
- package/dist/runtime/components/docs/ADocsSearchButton.d.vue.ts +1 -1
- package/dist/runtime/components/docs/ADocsSearchButton.vue.d.ts +1 -1
- package/dist/runtime/components/editor/AMetaChip.vue +18 -16
- package/dist/runtime/components/settings/ASettingsAboutPanel.d.vue.ts +3 -0
- package/dist/runtime/components/settings/ASettingsAboutPanel.vue +143 -0
- package/dist/runtime/components/settings/ASettingsAboutPanel.vue.d.ts +3 -0
- package/dist/runtime/components/settings/ASettingsConnectionPanel.vue +65 -100
- package/dist/runtime/components/settings/ASettingsModal.vue +7 -2
- package/dist/runtime/components/settings/sections.d.ts +28 -2
- package/dist/runtime/components/settings/sections.js +23 -0
- package/dist/runtime/components/shell/AUserMenu.d.vue.ts +2 -2
- package/dist/runtime/components/shell/AUserMenu.vue.d.ts +2 -2
- package/dist/runtime/composables/awarenessView.d.ts +46 -0
- package/dist/runtime/composables/awarenessView.js +65 -0
- package/dist/runtime/composables/useAwareness.js +19 -28
- package/dist/runtime/composables/useAwarenessPeers.d.ts +1 -25
- package/dist/runtime/composables/useChat.d.ts +21 -0
- package/dist/runtime/composables/useChat.js +77 -3
- package/dist/runtime/composables/useDocOpen.d.ts +69 -0
- package/dist/runtime/composables/useDocOpen.js +158 -0
- package/dist/runtime/composables/useRendererBase.d.ts +1 -25
- package/dist/runtime/composables/useSettingsModal.d.ts +1 -1
- package/dist/runtime/composables/useSpaceConnections.js +1 -60
- package/dist/runtime/composables/useYDoc.d.ts +3 -75
- package/dist/runtime/composables/useYDoc.js +28 -33
- package/dist/runtime/extensions/views/DocLinkView.vue +15 -5
- package/dist/runtime/extensions/views/MetaFieldView.vue +61 -49
- package/dist/runtime/locale.d.ts +2 -0
- package/dist/runtime/locale.js +1 -0
- package/dist/runtime/utils/observeYMap.d.ts +44 -0
- package/dist/runtime/utils/observeYMap.js +86 -0
- package/package.json +5 -5
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
BUILTIN_SETTINGS_SECTIONS,
|
|
7
7
|
GROUP_LABELS,
|
|
8
8
|
GROUP_MODE,
|
|
9
|
+
pluginSections,
|
|
9
10
|
searchSections,
|
|
10
11
|
visibleSections
|
|
11
12
|
} from "./sections";
|
|
@@ -22,8 +23,12 @@ const headerTabs = [
|
|
|
22
23
|
{ value: "user", label: "User Settings", icon: "i-lucide-user" },
|
|
23
24
|
{ value: "admin", label: "Administration", icon: "i-lucide-shield" }
|
|
24
25
|
];
|
|
26
|
+
const allSections = computed(() => [
|
|
27
|
+
...BUILTIN_SETTINGS_SECTIONS,
|
|
28
|
+
...pluginSections(abra.registry)
|
|
29
|
+
]);
|
|
25
30
|
const modeSections = computed(
|
|
26
|
-
() => visibleSections(
|
|
31
|
+
() => visibleSections(allSections.value, isAdmin.value).filter((s) => GROUP_MODE[s.group] === settingsMode.value)
|
|
27
32
|
);
|
|
28
33
|
const filteredSections = computed(() => searchSections(search.value, modeSections.value));
|
|
29
34
|
const groupedSections = computed(() => {
|
|
@@ -57,7 +62,7 @@ watch(isOpen, (val) => {
|
|
|
57
62
|
if (val) {
|
|
58
63
|
showMobileNav.value = true;
|
|
59
64
|
search.value = "";
|
|
60
|
-
const target =
|
|
65
|
+
const target = allSections.value.find((s) => s.key === activeTab.value);
|
|
61
66
|
if (target) settingsMode.value = GROUP_MODE[target.group];
|
|
62
67
|
}
|
|
63
68
|
});
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { type Component } from 'vue';
|
|
16
16
|
import type { SettingsTab } from '../../composables/useSettingsModal.js';
|
|
17
|
-
export type SettingsGroup = 'user' | 'workspace' | 'admin';
|
|
17
|
+
export type SettingsGroup = 'user' | 'plugin' | 'workspace' | 'admin';
|
|
18
|
+
/** A plugin-contributed section's key. Namespaced so it can never collide with a built-in. */
|
|
19
|
+
export type PluginSectionKey = `plugin:${string}`;
|
|
18
20
|
export interface SettingsSectionDef {
|
|
19
|
-
key: SettingsTab;
|
|
21
|
+
key: SettingsTab | PluginSectionKey;
|
|
20
22
|
label: string;
|
|
21
23
|
icon: string;
|
|
22
24
|
group: SettingsGroup;
|
|
@@ -31,6 +33,30 @@ export interface SettingsSectionDef {
|
|
|
31
33
|
export declare const GROUP_MODE: Record<SettingsGroup, 'user' | 'admin'>;
|
|
32
34
|
export declare const GROUP_LABELS: Record<SettingsGroup, string>;
|
|
33
35
|
export declare const BUILTIN_SETTINGS_SECTIONS: SettingsSectionDef[];
|
|
36
|
+
/**
|
|
37
|
+
* Sections contributed by installed plugins.
|
|
38
|
+
*
|
|
39
|
+
* `AbracadabraPlugin.settingsPanel` has been part of the contract — and
|
|
40
|
+
* `PluginRegistry.getSettingsPanels()` part of the base registry — since the
|
|
41
|
+
* plugin system shipped, but nothing rendered them, so a plugin could declare a
|
|
42
|
+
* settings panel and watch it never appear. They are ordinary sections from
|
|
43
|
+
* here on: searchable, grouped, and selected the same way.
|
|
44
|
+
*
|
|
45
|
+
* Keys are namespaced `plugin:<plugin name>` so they can never collide with a
|
|
46
|
+
* built-in tab, and the name (not the label) is what a deep-link targets.
|
|
47
|
+
*/
|
|
48
|
+
export declare function pluginSections(registry: PluginSectionSource | null | undefined): SettingsSectionDef[];
|
|
49
|
+
/** The slice of the plugin registry `pluginSections` needs. */
|
|
50
|
+
export interface PluginSectionSource {
|
|
51
|
+
getPlugins?: () => readonly {
|
|
52
|
+
name: string;
|
|
53
|
+
settingsPanel?: {
|
|
54
|
+
label?: string;
|
|
55
|
+
icon?: string;
|
|
56
|
+
component?: unknown;
|
|
57
|
+
};
|
|
58
|
+
}[];
|
|
59
|
+
}
|
|
34
60
|
/** Filter to the sections visible for the current role. */
|
|
35
61
|
export declare function visibleSections(sections: SettingsSectionDef[], isAdmin: boolean): SettingsSectionDef[];
|
|
36
62
|
/** Case-insensitive search over label + keywords. */
|
|
@@ -10,13 +10,18 @@ import ASettingsTrashPanel from "./ASettingsTrashPanel.vue";
|
|
|
10
10
|
import ASettingsPluginsPanel from "./ASettingsPluginsPanel.vue";
|
|
11
11
|
import ASettingsInvitesPanel from "./ASettingsInvitesPanel.vue";
|
|
12
12
|
import ASettingsAdminPanel from "./ASettingsAdminPanel.vue";
|
|
13
|
+
import ASettingsAboutPanel from "./ASettingsAboutPanel.vue";
|
|
13
14
|
export const GROUP_MODE = {
|
|
14
15
|
user: "user",
|
|
16
|
+
// A plugin's own settings are the user's preferences for that plugin, not
|
|
17
|
+
// workspace administration — they belong beside Appearance, not beside Members.
|
|
18
|
+
plugin: "user",
|
|
15
19
|
workspace: "admin",
|
|
16
20
|
admin: "admin"
|
|
17
21
|
};
|
|
18
22
|
export const GROUP_LABELS = {
|
|
19
23
|
user: "Account",
|
|
24
|
+
plugin: "Plugins",
|
|
20
25
|
workspace: "Workspace",
|
|
21
26
|
admin: "Administration"
|
|
22
27
|
};
|
|
@@ -25,6 +30,7 @@ export const BUILTIN_SETTINGS_SECTIONS = [
|
|
|
25
30
|
{ key: "appearance", label: "Appearance", icon: "i-lucide-palette", group: "user", keywords: ["theme", "dark", "light", "motion", "font"], component: markRaw(ASettingsAppearancePanel) },
|
|
26
31
|
{ key: "security", label: "Security", icon: "i-lucide-shield", group: "user", keywords: ["passkey", "password", "account", "logout", "wipe"], component: markRaw(ASettingsSecurityPanel) },
|
|
27
32
|
{ key: "offline", label: "Offline", icon: "i-lucide-database", group: "user", keywords: ["sync", "storage", "cache"], component: markRaw(ASettingsOfflinePanel) },
|
|
33
|
+
{ key: "about", label: "About", icon: "i-lucide-info", group: "user", keywords: ["version", "server", "diagnostics", "health", "support"], component: markRaw(ASettingsAboutPanel) },
|
|
28
34
|
{ key: "spaces", label: "Spaces", icon: "i-lucide-layers", group: "workspace", keywords: ["workspace", "create", "switch"], component: markRaw(ASettingsSpacesPanel) },
|
|
29
35
|
{ key: "members", label: "Members", icon: "i-lucide-users", group: "workspace", keywords: ["people", "roles", "online"], component: markRaw(ASettingsMembersPanel) },
|
|
30
36
|
{ key: "connection", label: "Connection", icon: "i-lucide-wifi", group: "workspace", keywords: ["server", "p2p", "webrtc", "reconnect"], component: markRaw(ASettingsConnectionPanel) },
|
|
@@ -33,6 +39,23 @@ export const BUILTIN_SETTINGS_SECTIONS = [
|
|
|
33
39
|
{ key: "invites", label: "Invites", icon: "i-lucide-ticket", group: "admin", adminOnly: true, keywords: ["invite", "code", "join"], component: markRaw(ASettingsInvitesPanel) },
|
|
34
40
|
{ key: "admin", label: "Admin", icon: "i-lucide-shield-alert", group: "admin", adminOnly: true, keywords: ["users", "server", "manage"], component: markRaw(ASettingsAdminPanel) }
|
|
35
41
|
];
|
|
42
|
+
export function pluginSections(registry) {
|
|
43
|
+
const plugins = registry?.getPlugins?.() ?? [];
|
|
44
|
+
const sections = [];
|
|
45
|
+
for (const plugin of plugins) {
|
|
46
|
+
const panel = plugin?.settingsPanel;
|
|
47
|
+
if (!panel?.component) continue;
|
|
48
|
+
sections.push({
|
|
49
|
+
key: `plugin:${plugin.name}`,
|
|
50
|
+
label: panel.label || plugin.name,
|
|
51
|
+
icon: panel.icon || "i-lucide-plug",
|
|
52
|
+
group: "plugin",
|
|
53
|
+
keywords: [plugin.name],
|
|
54
|
+
component: markRaw(panel.component)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return sections;
|
|
58
|
+
}
|
|
36
59
|
export function visibleSections(sections, isAdmin) {
|
|
37
60
|
return sections.filter((s) => !s.adminOnly || isAdmin);
|
|
38
61
|
}
|
|
@@ -14,13 +14,13 @@ type __VLS_Props = {
|
|
|
14
14
|
extraItems?: DropdownMenuItem[][];
|
|
15
15
|
};
|
|
16
16
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
logout: () => any;
|
|
17
18
|
"open-settings": () => any;
|
|
18
19
|
"open-account": () => any;
|
|
19
|
-
logout: () => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
+
onLogout?: (() => any) | undefined;
|
|
21
22
|
"onOpen-settings"?: (() => any) | undefined;
|
|
22
23
|
"onOpen-account"?: (() => any) | undefined;
|
|
23
|
-
onLogout?: (() => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
color: string;
|
|
26
26
|
collapsed: boolean;
|
|
@@ -14,13 +14,13 @@ type __VLS_Props = {
|
|
|
14
14
|
extraItems?: DropdownMenuItem[][];
|
|
15
15
|
};
|
|
16
16
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
logout: () => any;
|
|
17
18
|
"open-settings": () => any;
|
|
18
19
|
"open-account": () => any;
|
|
19
|
-
logout: () => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
+
onLogout?: (() => any) | undefined;
|
|
21
22
|
"onOpen-settings"?: (() => any) | undefined;
|
|
22
23
|
"onOpen-account"?: (() => any) | undefined;
|
|
23
|
-
onLogout?: (() => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
color: string;
|
|
26
26
|
collapsed: boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One shared, rAF-throttled mirror of an Awareness instance.
|
|
3
|
+
*
|
|
4
|
+
* `useAwareness()` and `useAwarenessOf()` are plain functions, not singletons —
|
|
5
|
+
* every call site installed its **own** `change` listener, its **own**
|
|
6
|
+
* `requestAnimationFrame`, and rebuilt its **own** full copy of every peer's
|
|
7
|
+
* state. Across the module that is 11 + 12 call sites, so a single cursor move
|
|
8
|
+
* from a single peer woke 23 listeners, scheduled 23 frames, and produced 23
|
|
9
|
+
* identical clones of the same data — every one of them thrown away on the next
|
|
10
|
+
* pointer move. On a busy document that is the module's largest idle cost after
|
|
11
|
+
* the provider's own heartbeats.
|
|
12
|
+
*
|
|
13
|
+
* This module keeps exactly one mirror per Awareness instance, refcounted, so
|
|
14
|
+
* the work is done once and every consumer reads the same refs. Consumers that
|
|
15
|
+
* want a `Map` rather than an array get it from a `computed`, which is lazy and
|
|
16
|
+
* cached — so that shape is also built once per change, not once per consumer.
|
|
17
|
+
*
|
|
18
|
+
* Keyed on the **Awareness instance**, not the provider: a provider can swap
|
|
19
|
+
* its awareness (reconnect, server switch), and a child provider materialises
|
|
20
|
+
* its own lazily. A `WeakMap` means a discarded awareness takes its mirror with
|
|
21
|
+
* it even if a consumer leaks its handle.
|
|
22
|
+
*/
|
|
23
|
+
import { type ShallowRef, type ComputedRef } from 'vue';
|
|
24
|
+
/** A peer's awareness state, flattened with its client id. */
|
|
25
|
+
export interface AwarenessUser {
|
|
26
|
+
clientId: number;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
export interface SharedAwarenessView {
|
|
30
|
+
/** Every peer's state, including the local client. Replaced wholesale per frame. */
|
|
31
|
+
states: ShallowRef<AwarenessUser[]>;
|
|
32
|
+
/** The same data keyed by client id, derived once however many consumers read it. */
|
|
33
|
+
statesMap: ComputedRef<Map<number, Record<string, unknown>>>;
|
|
34
|
+
/** The local client's own state, or the last one seen. */
|
|
35
|
+
currentUser: ShallowRef<AwarenessUser | null>;
|
|
36
|
+
/** Rebuild now, bypassing the frame throttle (used on first attach). */
|
|
37
|
+
flush: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Take a reference on the shared mirror for `awareness`, creating it on first
|
|
41
|
+
* use. **Every acquire must be paired with a `releaseAwarenessView`**, or the
|
|
42
|
+
* listener outlives its consumers.
|
|
43
|
+
*/
|
|
44
|
+
export declare function acquireAwarenessView(awareness: any): SharedAwarenessView;
|
|
45
|
+
/** Drop a reference; the last one out detaches the listener and the frame. */
|
|
46
|
+
export declare function releaseAwarenessView(awareness: any): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { shallowRef, computed } from "vue";
|
|
2
|
+
const views = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function createEntry(awareness) {
|
|
4
|
+
const states = shallowRef([]);
|
|
5
|
+
const currentUser = shallowRef(null);
|
|
6
|
+
const statesMap = computed(() => {
|
|
7
|
+
const map = /* @__PURE__ */ new Map();
|
|
8
|
+
for (const entry of states.value) {
|
|
9
|
+
const { clientId, ...rest } = entry;
|
|
10
|
+
map.set(clientId, rest);
|
|
11
|
+
}
|
|
12
|
+
return map;
|
|
13
|
+
});
|
|
14
|
+
let rafId = null;
|
|
15
|
+
const flush = () => {
|
|
16
|
+
rafId = null;
|
|
17
|
+
const next = [];
|
|
18
|
+
for (const [id, state] of awareness.getStates()) {
|
|
19
|
+
next.push({ clientId: id, ...state });
|
|
20
|
+
}
|
|
21
|
+
states.value = next;
|
|
22
|
+
const local = awareness.getLocalState();
|
|
23
|
+
if (local) currentUser.value = { clientId: awareness.clientID, ...local };
|
|
24
|
+
};
|
|
25
|
+
const schedule = () => {
|
|
26
|
+
if (typeof requestAnimationFrame === "undefined") {
|
|
27
|
+
flush();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (rafId === null) rafId = requestAnimationFrame(flush);
|
|
31
|
+
};
|
|
32
|
+
awareness.on("change", schedule);
|
|
33
|
+
flush();
|
|
34
|
+
return {
|
|
35
|
+
refs: 0,
|
|
36
|
+
states,
|
|
37
|
+
statesMap,
|
|
38
|
+
currentUser,
|
|
39
|
+
flush,
|
|
40
|
+
teardown() {
|
|
41
|
+
awareness.off("change", schedule);
|
|
42
|
+
if (rafId !== null) {
|
|
43
|
+
cancelAnimationFrame(rafId);
|
|
44
|
+
rafId = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function acquireAwarenessView(awareness) {
|
|
50
|
+
let entry = views.get(awareness);
|
|
51
|
+
if (!entry) {
|
|
52
|
+
entry = createEntry(awareness);
|
|
53
|
+
views.set(awareness, entry);
|
|
54
|
+
}
|
|
55
|
+
entry.refs++;
|
|
56
|
+
return entry;
|
|
57
|
+
}
|
|
58
|
+
export function releaseAwarenessView(awareness) {
|
|
59
|
+
const entry = views.get(awareness);
|
|
60
|
+
if (!entry) return;
|
|
61
|
+
entry.refs--;
|
|
62
|
+
if (entry.refs > 0) return;
|
|
63
|
+
entry.teardown();
|
|
64
|
+
views.delete(awareness);
|
|
65
|
+
}
|
|
@@ -1,44 +1,35 @@
|
|
|
1
1
|
import { shallowRef, computed, watch } from "vue";
|
|
2
2
|
import { tryOnScopeDispose } from "@vueuse/core";
|
|
3
3
|
import { useAbracadabra } from "./useAbracadabra.js";
|
|
4
|
+
import { acquireAwarenessView, releaseAwarenessView } from "./awarenessView.js";
|
|
4
5
|
export function useAwareness() {
|
|
5
6
|
const { provider } = useAbracadabra();
|
|
6
7
|
const states = shallowRef(/* @__PURE__ */ new Map());
|
|
7
|
-
|
|
8
|
+
let _attached = null;
|
|
9
|
+
let _stopMirror = null;
|
|
10
|
+
function _detach() {
|
|
11
|
+
_stopMirror?.();
|
|
12
|
+
_stopMirror = null;
|
|
13
|
+
if (_attached) {
|
|
14
|
+
releaseAwarenessView(_attached);
|
|
15
|
+
_attached = null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function _subscribe() {
|
|
19
|
+
_detach();
|
|
8
20
|
const awareness = provider.value?.awareness;
|
|
9
21
|
if (!awareness) {
|
|
10
22
|
states.value = /* @__PURE__ */ new Map();
|
|
11
23
|
return;
|
|
12
24
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const _throttledSync = () => {
|
|
19
|
-
if (_rafPending) return;
|
|
20
|
-
_rafPending = true;
|
|
21
|
-
_rafId = requestAnimationFrame(() => {
|
|
22
|
-
_rafPending = false;
|
|
23
|
-
_rafId = null;
|
|
24
|
-
_syncStates();
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
function _subscribe() {
|
|
28
|
-
_unsub?.();
|
|
29
|
-
_unsub = null;
|
|
30
|
-
const awareness = provider.value?.awareness;
|
|
31
|
-
if (!awareness) return;
|
|
32
|
-
_syncStates();
|
|
33
|
-
awareness.on("change", _throttledSync);
|
|
34
|
-
_unsub = () => awareness.off("change", _throttledSync);
|
|
25
|
+
const view = acquireAwarenessView(awareness);
|
|
26
|
+
_attached = awareness;
|
|
27
|
+
_stopMirror = watch(view.statesMap, (m) => {
|
|
28
|
+
states.value = m;
|
|
29
|
+
}, { immediate: true });
|
|
35
30
|
}
|
|
36
31
|
watch(provider, () => _subscribe(), { immediate: true });
|
|
37
|
-
tryOnScopeDispose(
|
|
38
|
-
_unsub?.();
|
|
39
|
-
_unsub = null;
|
|
40
|
-
if (_rafId !== null) cancelAnimationFrame(_rafId);
|
|
41
|
-
});
|
|
32
|
+
tryOnScopeDispose(_detach);
|
|
42
33
|
const localState = computed(() => {
|
|
43
34
|
const awareness = provider.value?.awareness;
|
|
44
35
|
if (!awareness) return {};
|
|
@@ -12,31 +12,7 @@ import type { AwarenessPeer, AwarenessUser } from '../types.js';
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function useAwarenessPeers(): {
|
|
14
14
|
peers: import("vue").ComputedRef<AwarenessPeer[]>;
|
|
15
|
-
currentUser: import("vue").
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
clientId: number;
|
|
18
|
-
user?: {
|
|
19
|
-
name?: string | undefined;
|
|
20
|
-
color?: string | undefined;
|
|
21
|
-
avatar?: string | undefined;
|
|
22
|
-
statusIcon?: string | undefined;
|
|
23
|
-
statusText?: string | undefined;
|
|
24
|
-
publicKey?: string | undefined;
|
|
25
|
-
} | undefined;
|
|
26
|
-
docId?: string | undefined;
|
|
27
|
-
} | null, AwarenessUser | {
|
|
28
|
-
[x: string]: any;
|
|
29
|
-
clientId: number;
|
|
30
|
-
user?: {
|
|
31
|
-
name?: string | undefined;
|
|
32
|
-
color?: string | undefined;
|
|
33
|
-
avatar?: string | undefined;
|
|
34
|
-
statusIcon?: string | undefined;
|
|
35
|
-
statusText?: string | undefined;
|
|
36
|
-
publicKey?: string | undefined;
|
|
37
|
-
} | undefined;
|
|
38
|
-
docId?: string | undefined;
|
|
39
|
-
} | null>;
|
|
15
|
+
currentUser: import("vue").ShallowRef<AwarenessUser | null, AwarenessUser | null>;
|
|
40
16
|
isIdle: (clientId: number, thresholdMs?: number) => boolean;
|
|
41
17
|
peersInDoc: (docId: MaybeRef<string>) => import("vue").ComputedRef<AwarenessPeer[]>;
|
|
42
18
|
};
|
|
@@ -18,6 +18,8 @@ export interface ChatMessage {
|
|
|
18
18
|
createdAt: number;
|
|
19
19
|
/** Id of the message this one replies to, if any (threaded reply). */
|
|
20
20
|
replyTo?: string;
|
|
21
|
+
/** When the message was last edited, if ever. Renders the "(edited)" marker. */
|
|
22
|
+
editedAt?: number;
|
|
21
23
|
}
|
|
22
24
|
export interface ChatChannel {
|
|
23
25
|
id: string;
|
|
@@ -69,6 +71,21 @@ declare function sendMessage(channelId: string, content: string, opts?: {
|
|
|
69
71
|
mentions?: string[];
|
|
70
72
|
replyTo?: string;
|
|
71
73
|
}): void;
|
|
74
|
+
/**
|
|
75
|
+
* Edit a previously-sent message.
|
|
76
|
+
*
|
|
77
|
+
* The server records an append-only `edit` entry against the original and
|
|
78
|
+
* clients fold it on read (`foldRecords`), so there is no separate broadcast
|
|
79
|
+
* to handle: the period doc's `messages` Y.Array changes, `pumpAll` re-folds,
|
|
80
|
+
* and `reconcileFolded` applies the new content. Only the sender (or an admin)
|
|
81
|
+
* is permitted server-side; a rejection comes back as a `serverError`.
|
|
82
|
+
*/
|
|
83
|
+
declare function editMessage(channelId: string, messageId: string, content: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* Delete a message. Append-only server-side — a `tombstone` record, which
|
|
86
|
+
* `foldRecords` drops on the next fold. Same permission rule as edit.
|
|
87
|
+
*/
|
|
88
|
+
declare function deleteMessage(channelId: string, messageId: string): void;
|
|
72
89
|
/**
|
|
73
90
|
* Open the wrapper provider for the given channel, observe its
|
|
74
91
|
* `periods` Y.Array, and attach the active period subdoc so its
|
|
@@ -94,6 +111,8 @@ export declare function useChat(): {
|
|
|
94
111
|
typingByChannel: import("vue").Ref<Record<string, Map<string, string>>, Record<string, Map<string, string>>>;
|
|
95
112
|
totalUnreadCount: import("vue").ComputedRef<number>;
|
|
96
113
|
sendMessage: typeof sendMessage;
|
|
114
|
+
editMessage: typeof editMessage;
|
|
115
|
+
deleteMessage: typeof deleteMessage;
|
|
97
116
|
fetchHistory: typeof fetchHistory;
|
|
98
117
|
sendTyping: typeof sendTyping;
|
|
99
118
|
setActiveChannel: typeof setActiveChannel;
|
|
@@ -118,6 +137,8 @@ export declare function useChatChannel(channelId: string): {
|
|
|
118
137
|
mentions?: string[];
|
|
119
138
|
replyTo?: string;
|
|
120
139
|
}) => void;
|
|
140
|
+
edit: (messageId: string, content: string) => void;
|
|
141
|
+
remove: (messageId: string) => void;
|
|
121
142
|
loadHistory: (opts?: {
|
|
122
143
|
before?: number;
|
|
123
144
|
limit?: number;
|
|
@@ -160,6 +160,29 @@ function ensureChannel(channelId, label) {
|
|
|
160
160
|
channels.value = { ...channels.value, [channelId]: { ...channels.value[channelId], label: resolvedLabel } };
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
+
function reconcileFolded(channel, folded) {
|
|
164
|
+
const previous = messagesByChannel.value[channel] ?? [];
|
|
165
|
+
const priorById = new Map(previous.map((m) => [m.id, m]));
|
|
166
|
+
const optimistic = previous.filter((m) => m.id.startsWith("local-"));
|
|
167
|
+
const next = folded.map((m) => {
|
|
168
|
+
const prior = priorById.get(m.id);
|
|
169
|
+
return prior?.senderName ? { ...m, senderName: prior.senderName } : m;
|
|
170
|
+
});
|
|
171
|
+
const foldedIds = new Set(folded.map((m) => m.id));
|
|
172
|
+
for (const local of optimistic) {
|
|
173
|
+
const echoed = folded.some(
|
|
174
|
+
(m) => m.senderId === local.senderId && m.content === local.content && Math.abs(m.createdAt - local.createdAt) < 3e4
|
|
175
|
+
);
|
|
176
|
+
if (!echoed && !foldedIds.has(local.id)) next.push(local);
|
|
177
|
+
}
|
|
178
|
+
next.sort((a, b) => a.createdAt - b.createdAt);
|
|
179
|
+
messagesByChannel.value = { ...messagesByChannel.value, [channel]: next };
|
|
180
|
+
const chan = channels.value[channel];
|
|
181
|
+
const last = next[next.length - 1];
|
|
182
|
+
if (chan && last && chan.lastMessage?.id !== last.id) {
|
|
183
|
+
channels.value = { ...channels.value, [channel]: { ...chan, lastMessage: last } };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
163
186
|
function addMessage(msg) {
|
|
164
187
|
const list = messagesByChannel.value[msg.channel] ?? [];
|
|
165
188
|
if (list.some((m) => m.id === msg.id)) return;
|
|
@@ -316,6 +339,46 @@ function sendMessage(channelId, content, opts) {
|
|
|
316
339
|
...opts?.replyTo ? { reply_to: opts.replyTo } : {}
|
|
317
340
|
}));
|
|
318
341
|
}
|
|
342
|
+
function editMessage(channelId, messageId, content) {
|
|
343
|
+
const { provider } = useAbracadabra();
|
|
344
|
+
if (!provider.value || !content.trim() || !messageId) return;
|
|
345
|
+
if (messageId.startsWith("local-")) return;
|
|
346
|
+
const channelDocId = normalizeChannel(channelId);
|
|
347
|
+
const trimmed = content.trim();
|
|
348
|
+
const list = messagesByChannel.value[channelDocId];
|
|
349
|
+
if (list) {
|
|
350
|
+
messagesByChannel.value = {
|
|
351
|
+
...messagesByChannel.value,
|
|
352
|
+
[channelDocId]: list.map(
|
|
353
|
+
(m) => m.id === messageId ? { ...m, content: trimmed, editedAt: Date.now() } : m
|
|
354
|
+
)
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
provider.value.sendStateless(JSON.stringify({
|
|
358
|
+
type: "messages:edit",
|
|
359
|
+
channel_doc_id: channelDocId,
|
|
360
|
+
message_id: messageId,
|
|
361
|
+
content: trimmed
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
364
|
+
function deleteMessage(channelId, messageId) {
|
|
365
|
+
const { provider } = useAbracadabra();
|
|
366
|
+
if (!provider.value || !messageId) return;
|
|
367
|
+
const channelDocId = normalizeChannel(channelId);
|
|
368
|
+
const list = messagesByChannel.value[channelDocId];
|
|
369
|
+
if (list) {
|
|
370
|
+
messagesByChannel.value = {
|
|
371
|
+
...messagesByChannel.value,
|
|
372
|
+
[channelDocId]: list.filter((m) => m.id !== messageId)
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
if (messageId.startsWith("local-")) return;
|
|
376
|
+
provider.value.sendStateless(JSON.stringify({
|
|
377
|
+
type: "messages:delete",
|
|
378
|
+
channel_doc_id: channelDocId,
|
|
379
|
+
message_id: messageId
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
319
382
|
const _channelHandles = /* @__PURE__ */ new Map();
|
|
320
383
|
async function _attachPeriodProvider(channel, rootProv, periodId) {
|
|
321
384
|
const handle = _channelHandles.get(channel);
|
|
@@ -340,6 +403,7 @@ async function _attachPeriodProvider(channel, rootProv, periodId) {
|
|
|
340
403
|
const pumpAll = async () => {
|
|
341
404
|
const records = arr.toArray().map((v) => recordFromYAny(v)).filter((r) => r !== null);
|
|
342
405
|
const folded = foldRecords(records);
|
|
406
|
+
const resolved = [];
|
|
343
407
|
for (const f of folded) {
|
|
344
408
|
let content = f.content;
|
|
345
409
|
if (isEncryptedContent(content)) {
|
|
@@ -350,7 +414,7 @@ async function _attachPeriodProvider(channel, rootProv, periodId) {
|
|
|
350
414
|
content = docKeyError ? "[encrypted \u2014 no key available for this channel]" : "[encrypted]";
|
|
351
415
|
}
|
|
352
416
|
}
|
|
353
|
-
|
|
417
|
+
resolved.push({
|
|
354
418
|
id: f.id,
|
|
355
419
|
channel,
|
|
356
420
|
senderId: f.senderId,
|
|
@@ -358,9 +422,11 @@ async function _attachPeriodProvider(channel, rootProv, periodId) {
|
|
|
358
422
|
content,
|
|
359
423
|
createdAt: f.createdAt,
|
|
360
424
|
// Best-effort: the SDK's folded record may carry reply linkage.
|
|
361
|
-
...f.reply_to || f.replyTo ? { replyTo: f.reply_to ?? f.replyTo } : {}
|
|
425
|
+
...f.reply_to || f.replyTo ? { replyTo: f.reply_to ?? f.replyTo } : {},
|
|
426
|
+
...f.editedAt ? { editedAt: f.editedAt } : {}
|
|
362
427
|
});
|
|
363
428
|
}
|
|
429
|
+
reconcileFolded(channel, resolved);
|
|
364
430
|
};
|
|
365
431
|
const onChange = () => {
|
|
366
432
|
void pumpAll();
|
|
@@ -448,6 +514,8 @@ export function useChat() {
|
|
|
448
514
|
typingByChannel,
|
|
449
515
|
totalUnreadCount,
|
|
450
516
|
sendMessage,
|
|
517
|
+
editMessage,
|
|
518
|
+
deleteMessage,
|
|
451
519
|
fetchHistory,
|
|
452
520
|
sendTyping,
|
|
453
521
|
setActiveChannel,
|
|
@@ -484,6 +552,12 @@ export function useChatChannel(channelId) {
|
|
|
484
552
|
function send(content, opts) {
|
|
485
553
|
sendMessage(key, content, opts);
|
|
486
554
|
}
|
|
555
|
+
function edit(messageId, content) {
|
|
556
|
+
editMessage(key, messageId, content);
|
|
557
|
+
}
|
|
558
|
+
function remove(messageId) {
|
|
559
|
+
deleteMessage(key, messageId);
|
|
560
|
+
}
|
|
487
561
|
function loadHistory(opts) {
|
|
488
562
|
fetchHistory(key, opts);
|
|
489
563
|
}
|
|
@@ -496,5 +570,5 @@ export function useChatChannel(channelId) {
|
|
|
496
570
|
function blur() {
|
|
497
571
|
if (activeChannel.value === key) setActiveChannel(null);
|
|
498
572
|
}
|
|
499
|
-
return { messages, channel, typingUsers, unreadCount, send, loadHistory, typing, focus, blur };
|
|
573
|
+
return { messages, channel, typingUsers, unreadCount, send, edit, remove, loadHistory, typing, focus, blur };
|
|
500
574
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** One open slideover. `provider` is `null` until the child finishes loading. */
|
|
2
|
+
export interface DocOpenEntry {
|
|
3
|
+
/** Stable identity for `v-for` — ids can repeat across a drill-in path. */
|
|
4
|
+
key: number;
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
provider: any;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Host overrides. Every field is optional; unset falls back to the default. */
|
|
11
|
+
export interface DocOpenConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Navigate the main view to a document. Defaults to `navigateTo` against
|
|
14
|
+
* `useDocSlugs().getDocUrl(id)` (slug-aware, honours `docBasePath`).
|
|
15
|
+
* Return a promise to have `openInMain` await it.
|
|
16
|
+
*/
|
|
17
|
+
navigateToDoc?: (id: string, entry?: {
|
|
18
|
+
label?: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
}) => unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Open a document in a floating window. Defaults to `useWindowManager()`.
|
|
23
|
+
* Set to `null` to disable floats entirely (Alt-click then falls back to a
|
|
24
|
+
* slideover, exactly as it does on mobile).
|
|
25
|
+
*/
|
|
26
|
+
openWindow?: ((args: {
|
|
27
|
+
id: string;
|
|
28
|
+
label: string;
|
|
29
|
+
entry?: {
|
|
30
|
+
label?: string;
|
|
31
|
+
type?: string;
|
|
32
|
+
};
|
|
33
|
+
spaceId?: string;
|
|
34
|
+
provider: any;
|
|
35
|
+
}) => unknown) | null;
|
|
36
|
+
/** Whether Alt-click may use a floating window. Defaults to the window layer's own signal. */
|
|
37
|
+
floatWindowsAvailable?: () => boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function registerNodePanelStack(): void;
|
|
40
|
+
export declare function unregisterNodePanelStack(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Install host overrides. Call once during app setup (a plugin, or the shell's
|
|
43
|
+
* `setup`). Merges into whatever is already configured, so separate concerns
|
|
44
|
+
* can register separately.
|
|
45
|
+
*/
|
|
46
|
+
export declare function configureDocOpen(config: DocOpenConfig): void;
|
|
47
|
+
/** The current overrides — mostly useful for tests and for host introspection. */
|
|
48
|
+
export declare function getDocOpenConfig(): Readonly<DocOpenConfig>;
|
|
49
|
+
export declare function useDocOpen(): {
|
|
50
|
+
/** The shared slideover stack — render it with `<ANodePanelStack>`. */
|
|
51
|
+
overlayStack: import("vue").Reactive<DocOpenEntry[]>;
|
|
52
|
+
/**
|
|
53
|
+
* True when an `<ANodePanelStack>` host is mounted. Surfaces with their own
|
|
54
|
+
* fallback panel check this before routing a Cmd-click through the stack.
|
|
55
|
+
*/
|
|
56
|
+
panelStackMounted: import("vue").ComputedRef<boolean>;
|
|
57
|
+
openInMain: (id: string) => unknown;
|
|
58
|
+
openInSlideover: (id: string, label?: string) => Promise<void>;
|
|
59
|
+
openInWindow: (id: string, label?: string) => Promise<unknown>;
|
|
60
|
+
closeSlideover: () => void;
|
|
61
|
+
closeSlideoverAt: (index: number) => void;
|
|
62
|
+
closeAllSlideovers: () => void;
|
|
63
|
+
onDocActivate: (e: MouseEvent, id: string, opts?: {
|
|
64
|
+
label?: string;
|
|
65
|
+
onPlain?: () => void;
|
|
66
|
+
}) => boolean;
|
|
67
|
+
/** Handy for callers that need a doc's label/type without opening it. */
|
|
68
|
+
resolveEntry: (docId: string) => import("#imports").SpaceTreeEntry | undefined;
|
|
69
|
+
};
|