@abraca/nuxt 2.96.0 → 2.99.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/aware/AMedia.d.vue.ts +1 -1
- package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
- 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/ALocationPickerPopover.vue +6 -2
- package/dist/runtime/components/editor/AMetaChip.vue +18 -16
- package/dist/runtime/components/renderers/AMapRenderer.vue +3 -2
- 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/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/mapboxToken.d.ts +7 -0
- package/dist/runtime/utils/mapboxToken.js +7 -0
- package/dist/runtime/utils/observeYMap.d.ts +44 -0
- package/dist/runtime/utils/observeYMap.js +86 -0
- package/package.json +5 -5
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { reactive, markRaw, ref, computed } from "vue";
|
|
2
|
+
import { navigateTo } from "#imports";
|
|
3
|
+
import { useSpaceConnections } from "./useSpaceConnections.js";
|
|
4
|
+
import { useDocSlugs } from "./useDocSlugs.js";
|
|
5
|
+
import { useWindowManager } from "./useWindowManager.js";
|
|
6
|
+
const overlayStack = reactive([]);
|
|
7
|
+
let _overlayKey = 0;
|
|
8
|
+
let _config = {};
|
|
9
|
+
const _stackHosts = ref(0);
|
|
10
|
+
export function registerNodePanelStack() {
|
|
11
|
+
_stackHosts.value++;
|
|
12
|
+
}
|
|
13
|
+
export function unregisterNodePanelStack() {
|
|
14
|
+
_stackHosts.value = Math.max(0, _stackHosts.value - 1);
|
|
15
|
+
}
|
|
16
|
+
export function configureDocOpen(config) {
|
|
17
|
+
_config = { ..._config, ...config };
|
|
18
|
+
}
|
|
19
|
+
export function getDocOpenConfig() {
|
|
20
|
+
return _config;
|
|
21
|
+
}
|
|
22
|
+
export function useDocOpen() {
|
|
23
|
+
const { getProviderForDoc, findDocSpaceId, resolveEntry } = useSpaceConnections();
|
|
24
|
+
async function loadChildProvider(id) {
|
|
25
|
+
const docProvider = getProviderForDoc(id);
|
|
26
|
+
if (!docProvider) return null;
|
|
27
|
+
const childProv = await docProvider.loadChild(id);
|
|
28
|
+
if (childProv?.ready) await childProv.ready;
|
|
29
|
+
return childProv ?? null;
|
|
30
|
+
}
|
|
31
|
+
function openInMain(id) {
|
|
32
|
+
if (!id) return;
|
|
33
|
+
const entry = resolveEntry(id);
|
|
34
|
+
if (_config.navigateToDoc) return _config.navigateToDoc(id, entry);
|
|
35
|
+
const { getDocUrl } = useDocSlugs();
|
|
36
|
+
return navigateTo(getDocUrl(id));
|
|
37
|
+
}
|
|
38
|
+
async function openInSlideover(id, label) {
|
|
39
|
+
if (!id) return;
|
|
40
|
+
if (!getProviderForDoc(id)) return;
|
|
41
|
+
const top = overlayStack[overlayStack.length - 1];
|
|
42
|
+
if (top && top.id === id) return;
|
|
43
|
+
const entry = reactive({
|
|
44
|
+
key: ++_overlayKey,
|
|
45
|
+
id,
|
|
46
|
+
label: label || resolveEntry(id)?.label || "",
|
|
47
|
+
provider: null,
|
|
48
|
+
loading: true
|
|
49
|
+
});
|
|
50
|
+
overlayStack.push(entry);
|
|
51
|
+
try {
|
|
52
|
+
const prov = await loadChildProvider(id);
|
|
53
|
+
if (!overlayStack.includes(entry)) {
|
|
54
|
+
try {
|
|
55
|
+
prov?.detach?.();
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
entry.provider = prov ? markRaw(prov) : null;
|
|
61
|
+
} finally {
|
|
62
|
+
entry.loading = false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function closeSlideover() {
|
|
66
|
+
const entry = overlayStack.pop();
|
|
67
|
+
detachEntry(entry);
|
|
68
|
+
}
|
|
69
|
+
function closeSlideoverAt(index) {
|
|
70
|
+
if (index < 0 || index >= overlayStack.length) return;
|
|
71
|
+
for (const entry of overlayStack.splice(index)) detachEntry(entry);
|
|
72
|
+
}
|
|
73
|
+
function closeAllSlideovers() {
|
|
74
|
+
for (const entry of overlayStack.splice(0)) detachEntry(entry);
|
|
75
|
+
}
|
|
76
|
+
function detachEntry(entry) {
|
|
77
|
+
if (!entry?.provider) return;
|
|
78
|
+
try {
|
|
79
|
+
entry.provider.detach?.();
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async function openInWindow(id, label) {
|
|
84
|
+
if (!id) return;
|
|
85
|
+
if (!getProviderForDoc(id)) return;
|
|
86
|
+
const entry = resolveEntry(id);
|
|
87
|
+
const resolvedLabel = label || entry?.label || "";
|
|
88
|
+
if (_config.openWindow === null) return openInSlideover(id, label);
|
|
89
|
+
if (!_config.openWindow) {
|
|
90
|
+
const wm = useWindowManager();
|
|
91
|
+
if (wm.windows.has(id)) {
|
|
92
|
+
wm.focusWindow(id);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const childProv2 = await loadChildProvider(id);
|
|
96
|
+
if (!childProv2) return;
|
|
97
|
+
return wm.openWindow({
|
|
98
|
+
id,
|
|
99
|
+
title: resolvedLabel,
|
|
100
|
+
docId: id,
|
|
101
|
+
docType: entry?.type,
|
|
102
|
+
provider: childProv2
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const childProv = await loadChildProvider(id);
|
|
106
|
+
if (!childProv) return;
|
|
107
|
+
return _config.openWindow({
|
|
108
|
+
id,
|
|
109
|
+
label: resolvedLabel,
|
|
110
|
+
entry,
|
|
111
|
+
spaceId: findDocSpaceId(id),
|
|
112
|
+
provider: childProv
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function floatsAvailable() {
|
|
116
|
+
if (_config.openWindow === null) return false;
|
|
117
|
+
if (_config.floatWindowsAvailable) return _config.floatWindowsAvailable();
|
|
118
|
+
if (_config.openWindow) return true;
|
|
119
|
+
return !!useWindowManager().floatWindowsAvailable.value;
|
|
120
|
+
}
|
|
121
|
+
function onDocActivate(e, id, opts) {
|
|
122
|
+
if (!id) return false;
|
|
123
|
+
if (!e.shiftKey && (e.metaKey || e.ctrlKey)) {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
void openInSlideover(id, opts?.label);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
if (!e.shiftKey && e.altKey) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
if (floatsAvailable()) void openInWindow(id, opts?.label);
|
|
133
|
+
else void openInSlideover(id, opts?.label);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
if (opts?.onPlain) opts.onPlain();
|
|
137
|
+
else void openInMain(id);
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
/** The shared slideover stack — render it with `<ANodePanelStack>`. */
|
|
142
|
+
overlayStack,
|
|
143
|
+
/**
|
|
144
|
+
* True when an `<ANodePanelStack>` host is mounted. Surfaces with their own
|
|
145
|
+
* fallback panel check this before routing a Cmd-click through the stack.
|
|
146
|
+
*/
|
|
147
|
+
panelStackMounted: computed(() => _stackHosts.value > 0),
|
|
148
|
+
openInMain,
|
|
149
|
+
openInSlideover,
|
|
150
|
+
openInWindow,
|
|
151
|
+
closeSlideover,
|
|
152
|
+
closeSlideoverAt,
|
|
153
|
+
closeAllSlideovers,
|
|
154
|
+
onDocActivate,
|
|
155
|
+
/** Handy for callers that need a doc's label/type without opening it. */
|
|
156
|
+
resolveEntry
|
|
157
|
+
};
|
|
158
|
+
}
|
|
@@ -62,31 +62,7 @@ export declare function useRendererBase(props: RendererBaseProps): {
|
|
|
62
62
|
docId?: string | undefined;
|
|
63
63
|
};
|
|
64
64
|
}[]>;
|
|
65
|
-
states: import("
|
|
66
|
-
[x: string]: any;
|
|
67
|
-
clientId: number;
|
|
68
|
-
user?: {
|
|
69
|
-
name?: string | undefined;
|
|
70
|
-
color?: string | undefined;
|
|
71
|
-
avatar?: string | undefined;
|
|
72
|
-
statusIcon?: string | undefined;
|
|
73
|
-
statusText?: string | undefined;
|
|
74
|
-
publicKey?: string | undefined;
|
|
75
|
-
} | undefined;
|
|
76
|
-
docId?: string | undefined;
|
|
77
|
-
}[], import("./useYDoc.js").AwarenessUser[] | {
|
|
78
|
-
[x: string]: any;
|
|
79
|
-
clientId: number;
|
|
80
|
-
user?: {
|
|
81
|
-
name?: string | undefined;
|
|
82
|
-
color?: string | undefined;
|
|
83
|
-
avatar?: string | undefined;
|
|
84
|
-
statusIcon?: string | undefined;
|
|
85
|
-
statusText?: string | undefined;
|
|
86
|
-
publicKey?: string | undefined;
|
|
87
|
-
} | undefined;
|
|
88
|
-
docId?: string | undefined;
|
|
89
|
-
}[]>;
|
|
65
|
+
states: ShallowRef<import("./useYDoc.js").AwarenessUser[], import("./useYDoc.js").AwarenessUser[]>;
|
|
90
66
|
setLocalState: (state: any) => void;
|
|
91
67
|
tree: {
|
|
92
68
|
entries: import("vue").ComputedRef<import("./useChildTree.js").TreeEntry[]>;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Usage:
|
|
10
10
|
* const { isOpen, activeTab, openSettings, closeSettings } = useSettingsModal()
|
|
11
11
|
*/
|
|
12
|
-
export type SettingsTab = 'profile' | 'appearance' | 'connection' | 'spaces' | 'security' | 'invites' | 'members' | 'trash' | 'offline' | 'plugins' | 'admin';
|
|
12
|
+
export type SettingsTab = 'profile' | 'appearance' | 'connection' | 'spaces' | 'security' | 'invites' | 'members' | 'trash' | 'offline' | 'about' | 'plugins' | 'admin';
|
|
13
13
|
export declare function useSettingsModal(): {
|
|
14
14
|
isOpen: import("vue").WritableComputedRef<boolean, boolean>;
|
|
15
15
|
activeTab: import("vue").WritableComputedRef<SettingsTab, SettingsTab>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ref, shallowReactive, watch } from "vue";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
|
+
import { observeYMap } from "../utils/observeYMap.js";
|
|
3
4
|
import { useAbracadabra } from "./useAbracadabra.js";
|
|
4
5
|
let _ctx = null;
|
|
5
6
|
export function _initSpaceConnections(ctx) {
|
|
@@ -15,66 +16,6 @@ export function _resetSpaceConnections() {
|
|
|
15
16
|
}
|
|
16
17
|
const connections = shallowReactive(/* @__PURE__ */ new Map());
|
|
17
18
|
const _connectPromises = /* @__PURE__ */ new Map();
|
|
18
|
-
function observeYMap(doc, mapName) {
|
|
19
|
-
const ymap = doc.getMap(mapName);
|
|
20
|
-
const data = ref({});
|
|
21
|
-
const snapshot = () => {
|
|
22
|
-
const obj = {};
|
|
23
|
-
ymap.forEach((val, key) => {
|
|
24
|
-
obj[key] = val instanceof Y.Map ? val.toJSON() : val;
|
|
25
|
-
});
|
|
26
|
-
return obj;
|
|
27
|
-
};
|
|
28
|
-
data.value = snapshot();
|
|
29
|
-
let rafId = null;
|
|
30
|
-
const flush = () => {
|
|
31
|
-
rafId = null;
|
|
32
|
-
data.value = snapshot();
|
|
33
|
-
};
|
|
34
|
-
const observer = (_events, transaction) => {
|
|
35
|
-
if (transaction.local) {
|
|
36
|
-
if (rafId !== null) {
|
|
37
|
-
cancelAnimationFrame(rafId);
|
|
38
|
-
rafId = null;
|
|
39
|
-
}
|
|
40
|
-
data.value = snapshot();
|
|
41
|
-
} else if (typeof requestAnimationFrame !== "undefined") {
|
|
42
|
-
if (rafId === null) rafId = requestAnimationFrame(flush);
|
|
43
|
-
} else {
|
|
44
|
-
data.value = snapshot();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
ymap.observeDeep(observer);
|
|
48
|
-
const onVisibilityChange = () => {
|
|
49
|
-
if (typeof document !== "undefined" && !document.hidden) {
|
|
50
|
-
if (rafId !== null) {
|
|
51
|
-
cancelAnimationFrame(rafId);
|
|
52
|
-
rafId = null;
|
|
53
|
-
}
|
|
54
|
-
data.value = snapshot();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
if (typeof document !== "undefined") {
|
|
58
|
-
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
59
|
-
}
|
|
60
|
-
queueMicrotask(() => {
|
|
61
|
-
data.value = snapshot();
|
|
62
|
-
});
|
|
63
|
-
const cleanup = () => {
|
|
64
|
-
try {
|
|
65
|
-
ymap.unobserveDeep(observer);
|
|
66
|
-
} catch {
|
|
67
|
-
}
|
|
68
|
-
if (rafId !== null) {
|
|
69
|
-
cancelAnimationFrame(rafId);
|
|
70
|
-
rafId = null;
|
|
71
|
-
}
|
|
72
|
-
if (typeof document !== "undefined") {
|
|
73
|
-
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return { data, cleanup };
|
|
77
|
-
}
|
|
78
19
|
let _activeBound = false;
|
|
79
20
|
let _activeSpaceId = null;
|
|
80
21
|
function _ensureActiveBinding() {
|
|
@@ -43,56 +43,8 @@ export declare function useSyncedXml(doc: ShallowRef<Y.Doc | null>, xmlName: str
|
|
|
43
43
|
export declare function useAwarenessOf(provider: ShallowRef<{
|
|
44
44
|
awareness: any;
|
|
45
45
|
} | null>): {
|
|
46
|
-
states:
|
|
47
|
-
|
|
48
|
-
clientId: number;
|
|
49
|
-
user?: {
|
|
50
|
-
name?: string | undefined;
|
|
51
|
-
color?: string | undefined;
|
|
52
|
-
avatar?: string | undefined;
|
|
53
|
-
statusIcon?: string | undefined;
|
|
54
|
-
statusText?: string | undefined;
|
|
55
|
-
publicKey?: string | undefined;
|
|
56
|
-
} | undefined;
|
|
57
|
-
docId?: string | undefined;
|
|
58
|
-
}[], AwarenessUser[] | {
|
|
59
|
-
[x: string]: any;
|
|
60
|
-
clientId: number;
|
|
61
|
-
user?: {
|
|
62
|
-
name?: string | undefined;
|
|
63
|
-
color?: string | undefined;
|
|
64
|
-
avatar?: string | undefined;
|
|
65
|
-
statusIcon?: string | undefined;
|
|
66
|
-
statusText?: string | undefined;
|
|
67
|
-
publicKey?: string | undefined;
|
|
68
|
-
} | undefined;
|
|
69
|
-
docId?: string | undefined;
|
|
70
|
-
}[]>;
|
|
71
|
-
currentUser: Ref<{
|
|
72
|
-
[x: string]: any;
|
|
73
|
-
clientId: number;
|
|
74
|
-
user?: {
|
|
75
|
-
name?: string | undefined;
|
|
76
|
-
color?: string | undefined;
|
|
77
|
-
avatar?: string | undefined;
|
|
78
|
-
statusIcon?: string | undefined;
|
|
79
|
-
statusText?: string | undefined;
|
|
80
|
-
publicKey?: string | undefined;
|
|
81
|
-
} | undefined;
|
|
82
|
-
docId?: string | undefined;
|
|
83
|
-
} | null, AwarenessUser | {
|
|
84
|
-
[x: string]: any;
|
|
85
|
-
clientId: number;
|
|
86
|
-
user?: {
|
|
87
|
-
name?: string | undefined;
|
|
88
|
-
color?: string | undefined;
|
|
89
|
-
avatar?: string | undefined;
|
|
90
|
-
statusIcon?: string | undefined;
|
|
91
|
-
statusText?: string | undefined;
|
|
92
|
-
publicKey?: string | undefined;
|
|
93
|
-
} | undefined;
|
|
94
|
-
docId?: string | undefined;
|
|
95
|
-
} | null>;
|
|
46
|
+
states: ShallowRef<AwarenessUser[], AwarenessUser[]>;
|
|
47
|
+
currentUser: ShallowRef<AwarenessUser | null, AwarenessUser | null>;
|
|
96
48
|
setLocalState: (state: any) => void;
|
|
97
49
|
};
|
|
98
50
|
export declare function useSmoothedCursors(provider: ShallowRef<{
|
|
@@ -138,30 +90,6 @@ export declare function useSmoothedCursors(provider: ShallowRef<{
|
|
|
138
90
|
docId?: string | undefined;
|
|
139
91
|
};
|
|
140
92
|
}[]>;
|
|
141
|
-
states:
|
|
142
|
-
[x: string]: any;
|
|
143
|
-
clientId: number;
|
|
144
|
-
user?: {
|
|
145
|
-
name?: string | undefined;
|
|
146
|
-
color?: string | undefined;
|
|
147
|
-
avatar?: string | undefined;
|
|
148
|
-
statusIcon?: string | undefined;
|
|
149
|
-
statusText?: string | undefined;
|
|
150
|
-
publicKey?: string | undefined;
|
|
151
|
-
} | undefined;
|
|
152
|
-
docId?: string | undefined;
|
|
153
|
-
}[], AwarenessUser[] | {
|
|
154
|
-
[x: string]: any;
|
|
155
|
-
clientId: number;
|
|
156
|
-
user?: {
|
|
157
|
-
name?: string | undefined;
|
|
158
|
-
color?: string | undefined;
|
|
159
|
-
avatar?: string | undefined;
|
|
160
|
-
statusIcon?: string | undefined;
|
|
161
|
-
statusText?: string | undefined;
|
|
162
|
-
publicKey?: string | undefined;
|
|
163
|
-
} | undefined;
|
|
164
|
-
docId?: string | undefined;
|
|
165
|
-
}[]>;
|
|
93
|
+
states: ShallowRef<AwarenessUser[], AwarenessUser[]>;
|
|
166
94
|
setLocalState: (state: any) => void;
|
|
167
95
|
};
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
onMounted,
|
|
9
9
|
onBeforeUnmount
|
|
10
10
|
} from "vue";
|
|
11
|
+
import { acquireAwarenessView, releaseAwarenessView } from "./awarenessView.js";
|
|
11
12
|
export function useSyncedMap(doc, mapName) {
|
|
12
13
|
const state = reactive({});
|
|
13
14
|
const ymap = shallowRef(null);
|
|
@@ -142,44 +143,38 @@ export function useSyncedXml(doc, xmlName) {
|
|
|
142
143
|
return { yXml };
|
|
143
144
|
}
|
|
144
145
|
export function useAwarenessOf(provider) {
|
|
145
|
-
const states =
|
|
146
|
-
const currentUser =
|
|
147
|
-
let _rafId = null;
|
|
148
|
-
const flush = () => {
|
|
149
|
-
_rafId = null;
|
|
150
|
-
if (!provider.value?.awareness) return;
|
|
151
|
-
const awareness = provider.value.awareness;
|
|
152
|
-
states.value = Array.from(awareness.getStates().entries()).map(([id, state]) => ({ clientId: id, ...state }));
|
|
153
|
-
const local = awareness.getLocalState();
|
|
154
|
-
if (local) currentUser.value = { clientId: awareness.clientID, ...local };
|
|
155
|
-
};
|
|
156
|
-
const update = () => {
|
|
157
|
-
if (_rafId === null) _rafId = requestAnimationFrame(flush);
|
|
158
|
-
};
|
|
146
|
+
const states = shallowRef([]);
|
|
147
|
+
const currentUser = shallowRef(null);
|
|
159
148
|
let _attachedAwareness = null;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (p?.awareness) {
|
|
167
|
-
p.awareness.on("change", update);
|
|
168
|
-
_attachedAwareness = p.awareness;
|
|
169
|
-
flush();
|
|
170
|
-
} else {
|
|
149
|
+
let _stopMirror = null;
|
|
150
|
+
const detach = () => {
|
|
151
|
+
_stopMirror?.();
|
|
152
|
+
_stopMirror = null;
|
|
153
|
+
if (_attachedAwareness) {
|
|
154
|
+
releaseAwarenessView(_attachedAwareness);
|
|
171
155
|
_attachedAwareness = null;
|
|
172
156
|
}
|
|
157
|
+
};
|
|
158
|
+
const attach = (awareness) => {
|
|
159
|
+
const view = acquireAwarenessView(awareness);
|
|
160
|
+
_attachedAwareness = awareness;
|
|
161
|
+
const stopStates = watch(view.states, (v) => {
|
|
162
|
+
states.value = v;
|
|
163
|
+
}, { immediate: true });
|
|
164
|
+
const stopUser = watch(view.currentUser, (v) => {
|
|
165
|
+
currentUser.value = v;
|
|
166
|
+
}, { immediate: true });
|
|
167
|
+
_stopMirror = () => {
|
|
168
|
+
stopStates();
|
|
169
|
+
stopUser();
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
watch(provider, (p) => {
|
|
173
|
+
detach();
|
|
174
|
+
if (p?.awareness) attach(p.awareness);
|
|
173
175
|
}, { immediate: true });
|
|
174
176
|
onBeforeUnmount(() => {
|
|
175
|
-
|
|
176
|
-
_attachedAwareness.off("change", update);
|
|
177
|
-
_attachedAwareness = null;
|
|
178
|
-
}
|
|
179
|
-
if (_rafId !== null) {
|
|
180
|
-
cancelAnimationFrame(_rafId);
|
|
181
|
-
_rafId = null;
|
|
182
|
-
}
|
|
177
|
+
detach();
|
|
183
178
|
});
|
|
184
179
|
const setLocalState = (state) => {
|
|
185
180
|
if (!provider.value) return;
|