@abraca/nuxt 2.36.0 → 2.38.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.d.mts +6 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/ADocPickModal.vue +1 -1
- package/dist/runtime/components/ADocSubPageList.d.vue.ts +46 -0
- package/dist/runtime/components/ADocSubPageList.vue +1006 -0
- package/dist/runtime/components/ADocSubPageList.vue.d.ts +46 -0
- package/dist/runtime/components/ADocumentTree.vue +3 -2
- package/dist/runtime/components/AEditor.d.vue.ts +9 -0
- package/dist/runtime/components/AEditor.vue +14 -2
- package/dist/runtime/components/AEditor.vue.d.ts +9 -0
- package/dist/runtime/components/AIconPicker.vue +27 -180
- package/dist/runtime/components/ANodePanel.d.vue.ts +8 -5
- package/dist/runtime/components/ANodePanel.vue +1 -1
- package/dist/runtime/components/ANodePanel.vue.d.ts +8 -5
- package/dist/runtime/components/AWindowLayer.vue +4 -2
- 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/editor/ADocSuggestMenu.vue +1 -1
- package/dist/runtime/components/editor/ALocationPickerPopover.vue +31 -16
- package/dist/runtime/components/renderers/ACalendarRenderer.d.vue.ts +1 -0
- package/dist/runtime/components/renderers/ACalendarRenderer.vue +309 -68
- package/dist/runtime/components/renderers/ACalendarRenderer.vue.d.ts +1 -0
- package/dist/runtime/components/renderers/AChecklistRenderer.vue +259 -40
- package/dist/runtime/components/renderers/ADashboardRenderer.vue +493 -89
- package/dist/runtime/components/renderers/AGraphRenderer.d.vue.ts +2 -0
- package/dist/runtime/components/renderers/AGraphRenderer.vue +2113 -576
- package/dist/runtime/components/renderers/AGraphRenderer.vue.d.ts +2 -0
- package/dist/runtime/components/renderers/AKanbanRenderer.vue +460 -86
- package/dist/runtime/components/renderers/AMapRenderer.d.vue.ts +7 -1
- package/dist/runtime/components/renderers/AMapRenderer.vue +999 -166
- package/dist/runtime/components/renderers/AMapRenderer.vue.d.ts +7 -1
- package/dist/runtime/components/renderers/AOutlineRenderer.d.vue.ts +2 -0
- package/dist/runtime/components/renderers/AOutlineRenderer.vue +285 -81
- package/dist/runtime/components/renderers/AOutlineRenderer.vue.d.ts +2 -0
- package/dist/runtime/components/renderers/AOverviewRenderer.vue +3 -2
- package/dist/runtime/components/renderers/ASheetsRenderer.client.vue +255 -87
- package/dist/runtime/components/renderers/ATimelineRenderer.d.vue.ts +1 -0
- package/dist/runtime/components/renderers/ATimelineRenderer.vue +224 -31
- package/dist/runtime/components/renderers/ATimelineRenderer.vue.d.ts +1 -0
- package/dist/runtime/components/renderers/calendar/ACalendarDayCell.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/calendar/ACalendarDayCell.vue +12 -1
- package/dist/runtime/components/renderers/calendar/ACalendarDayCell.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/calendar/ACalendarEventChip.d.vue.ts +10 -0
- package/dist/runtime/components/renderers/calendar/ACalendarEventChip.vue +15 -3
- package/dist/runtime/components/renderers/calendar/ACalendarEventChip.vue.d.ts +10 -0
- package/dist/runtime/components/renderers/calendar/ACalendarMonthView.d.vue.ts +14 -0
- package/dist/runtime/components/renderers/calendar/ACalendarMonthView.vue +6 -1
- package/dist/runtime/components/renderers/calendar/ACalendarMonthView.vue.d.ts +14 -0
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.d.vue.ts +6 -6
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue +25 -7
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue.d.ts +6 -6
- package/dist/runtime/components/renderers/sheets/ASheetsMobileActionBar.d.vue.ts +2 -2
- package/dist/runtime/components/renderers/sheets/ASheetsMobileActionBar.vue.d.ts +2 -2
- package/dist/runtime/components/renderers/sheets/ASheetsToolbar.d.vue.ts +6 -0
- package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue +130 -23
- package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue.d.ts +6 -0
- package/dist/runtime/components/renderers/timeline/ATimelineAxis.vue +5 -3
- package/dist/runtime/components/renderers/timeline/ATimelineBar.vue +1 -1
- package/dist/runtime/components/renderers/timeline/ATimelineBarArea.d.vue.ts +0 -2
- package/dist/runtime/components/renderers/timeline/ATimelineBarArea.vue +16 -14
- package/dist/runtime/components/renderers/timeline/ATimelineBarArea.vue.d.ts +0 -2
- package/dist/runtime/components/renderers/timeline/ATimelineLabelPanel.vue +4 -2
- package/dist/runtime/composables/useAbracadabraAuth.d.ts +1 -0
- package/dist/runtime/composables/useAbracadabraAuth.js +1 -0
- package/dist/runtime/composables/useCalendarView.js +34 -11
- package/dist/runtime/composables/useConnectionStatus.d.ts +1 -1
- package/dist/runtime/composables/useGraphReferenceEdges.d.ts +26 -0
- package/dist/runtime/composables/useGraphReferenceEdges.js +138 -0
- package/dist/runtime/composables/useGraphSim.d.ts +79 -0
- package/dist/runtime/composables/useGraphSim.js +231 -0
- package/dist/runtime/composables/useSheetsDependencyGraph.d.ts +26 -0
- package/dist/runtime/composables/useSheetsDependencyGraph.js +76 -0
- package/dist/runtime/composables/useSheetsFormulas.d.ts +4 -3
- package/dist/runtime/composables/useSheetsFormulas.js +575 -26
- package/dist/runtime/composables/useTimelineView.d.ts +4 -0
- package/dist/runtime/composables/useTimelineView.js +45 -11
- package/dist/runtime/composables/useWindowManager.d.ts +4 -0
- package/dist/runtime/composables/useWindowManager.js +11 -0
- package/dist/runtime/composables/useWorkspace.d.ts +57 -0
- package/dist/runtime/composables/useWorkspace.js +58 -0
- package/dist/runtime/middleware/abracadabra-auth.js +11 -1
- package/dist/runtime/plugin-abracadabra.client.js +121 -12
- package/dist/runtime/utils/dateField.d.ts +17 -0
- package/dist/runtime/utils/dateField.js +19 -0
- package/dist/runtime/utils/itemLabel.d.ts +27 -0
- package/dist/runtime/utils/itemLabel.js +8 -0
- package/dist/runtime/utils/localDate.d.ts +15 -0
- package/dist/runtime/utils/localDate.js +16 -0
- package/dist/runtime/utils/lucideIcons.d.ts +16 -10
- package/dist/runtime/utils/lucideIcons.js +1391 -69
- package/dist/runtime/utils/resolveDocColor.d.ts +7 -0
- package/dist/runtime/utils/resolveDocColor.js +32 -0
- package/dist/runtime/utils/resolveDocIcon.d.ts +10 -0
- package/dist/runtime/utils/resolveDocIcon.js +44 -0
- package/dist/runtime/utils/rowEdges.d.ts +22 -0
- package/dist/runtime/utils/rowEdges.js +29 -0
- package/dist/runtime/utils/softKeystore.d.ts +55 -0
- package/dist/runtime/utils/softKeystore.js +160 -0
- package/package.json +1 -1
|
@@ -3,6 +3,10 @@ export interface AxisLabel {
|
|
|
3
3
|
label: string;
|
|
4
4
|
offset: number;
|
|
5
5
|
tier: 'coarse' | 'fine';
|
|
6
|
+
/** Coarse context label pinned to the viewport's left edge. */
|
|
7
|
+
sticky?: boolean;
|
|
8
|
+
/** Where to render the text (defaults to `offset`); used to pin sticky labels. */
|
|
9
|
+
labelOffset?: number;
|
|
6
10
|
}
|
|
7
11
|
export interface UseTimelineViewOptions {
|
|
8
12
|
containerRef: Ref<HTMLElement | null>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
|
|
2
|
+
import { tlStart, tlEnd } from "../utils/dateField.js";
|
|
2
3
|
const TIER_MILLENNIA = 5e-3;
|
|
3
4
|
const TIER_CENTURIES = 0.05;
|
|
4
5
|
const TIER_DECADES = 0.5;
|
|
@@ -9,6 +10,7 @@ const ZOOM_MIN = 5e-4;
|
|
|
9
10
|
const ZOOM_MAX = 120;
|
|
10
11
|
const ZOOM_WHEEL_FACTOR = 1.08;
|
|
11
12
|
const PAN_KEYBOARD_PX = 100;
|
|
13
|
+
const STICKY_PAD = 6;
|
|
12
14
|
const MS_PER_DAY = 24 * 60 * 60 * 1e3;
|
|
13
15
|
function toDateStr(d) {
|
|
14
16
|
const y = d.getFullYear();
|
|
@@ -47,8 +49,8 @@ export function useTimelineView(options) {
|
|
|
47
49
|
let maxDate = -Infinity;
|
|
48
50
|
let hasAnyDate = false;
|
|
49
51
|
for (const item of items) {
|
|
50
|
-
const start = item.meta
|
|
51
|
-
const end = item.meta
|
|
52
|
+
const start = tlStart(item.meta);
|
|
53
|
+
const end = tlEnd(item.meta);
|
|
52
54
|
if (start) {
|
|
53
55
|
const t = new Date(start).getTime();
|
|
54
56
|
if (!Number.isNaN(t)) {
|
|
@@ -286,31 +288,62 @@ export function useTimelineView(options) {
|
|
|
286
288
|
addYearTierLabels(labels, start, end, 1e3, "fine");
|
|
287
289
|
} else if (ppd < TIER_CENTURIES) {
|
|
288
290
|
addYearTierLabels(labels, start, end, 100, "fine");
|
|
289
|
-
|
|
291
|
+
addCoarseTier(labels, start, "year", 1e3);
|
|
290
292
|
} else if (ppd < TIER_DECADES) {
|
|
291
293
|
addYearTierLabels(labels, start, end, 10, "fine");
|
|
292
|
-
|
|
294
|
+
addCoarseTier(labels, start, "year", 100);
|
|
293
295
|
} else if (ppd < TIER_YEARS) {
|
|
294
296
|
addYearTierLabels(labels, start, end, 1, "fine");
|
|
295
|
-
|
|
297
|
+
addCoarseTier(labels, start, "year", 10);
|
|
296
298
|
} else if (ppd < TIER_MONTHS) {
|
|
297
299
|
addMonthLabels(labels, start, end, "fine");
|
|
298
|
-
|
|
300
|
+
addCoarseTier(labels, start, "year", 1);
|
|
299
301
|
} else if (ppd < TIER_WEEKS) {
|
|
300
302
|
addWeekLabels(labels, start, end, "fine");
|
|
301
|
-
|
|
303
|
+
addCoarseTier(labels, start, "month");
|
|
302
304
|
} else {
|
|
303
305
|
addDayLabels(labels, start, end, "fine");
|
|
304
|
-
|
|
306
|
+
addCoarseTier(labels, start, "month");
|
|
305
307
|
}
|
|
306
308
|
return labels;
|
|
307
309
|
});
|
|
310
|
+
function addCoarseTier(labels, start, kind, step = 1) {
|
|
311
|
+
const locale = typeof navigator !== "undefined" ? navigator.language : "en-US";
|
|
312
|
+
const limit = containerWidth.value + 200;
|
|
313
|
+
let cur = kind === "year" ? yearStartDate(Math.floor(start.getFullYear() / step) * step) : new Date(start.getFullYear(), start.getMonth(), 1);
|
|
314
|
+
let first = true;
|
|
315
|
+
for (let guard = 0; guard < 2e3; guard++) {
|
|
316
|
+
const offset = dateToX(toDateStr(cur));
|
|
317
|
+
if (offset > limit) break;
|
|
318
|
+
const label = kind === "year" ? String(cur.getFullYear()) : cur.toLocaleDateString(locale, { month: "long", year: "numeric" });
|
|
319
|
+
const next = kind === "year" ? yearStartDate(cur.getFullYear() + step) : new Date(cur.getFullYear(), cur.getMonth() + 1, 1);
|
|
320
|
+
if (first) {
|
|
321
|
+
const nextOffset = dateToX(toDateStr(next));
|
|
322
|
+
const estWidth = label.length * 6.5 + 14;
|
|
323
|
+
labels.push({
|
|
324
|
+
label,
|
|
325
|
+
offset,
|
|
326
|
+
tier: "coarse",
|
|
327
|
+
sticky: true,
|
|
328
|
+
labelOffset: Math.min(STICKY_PAD, nextOffset - estWidth)
|
|
329
|
+
});
|
|
330
|
+
first = false;
|
|
331
|
+
} else {
|
|
332
|
+
labels.push({ label, offset, tier: "coarse" });
|
|
333
|
+
}
|
|
334
|
+
cur = next;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function yearStartDate(year) {
|
|
338
|
+
const d = new Date(0, 0, 1);
|
|
339
|
+
d.setFullYear(year, 0, 1);
|
|
340
|
+
return d;
|
|
341
|
+
}
|
|
308
342
|
function addYearTierLabels(labels, start, end, step, tier) {
|
|
309
343
|
const startYear = Math.floor(start.getFullYear() / step) * step;
|
|
310
344
|
const endYear = end.getFullYear();
|
|
311
345
|
for (let y = startYear; y <= endYear + step; y += step) {
|
|
312
|
-
const d =
|
|
313
|
-
d.setFullYear(y, 0, 1);
|
|
346
|
+
const d = yearStartDate(y);
|
|
314
347
|
const offset = dateToX(toDateStr(d));
|
|
315
348
|
if (offset >= -200 && offset <= containerWidth.value + 200) {
|
|
316
349
|
labels.push({ label: String(y), offset, tier });
|
|
@@ -369,7 +402,8 @@ export function useTimelineView(options) {
|
|
|
369
402
|
return end >= visibleStartDate.value && start <= visibleEndDate.value;
|
|
370
403
|
}
|
|
371
404
|
function isMilestone(entry) {
|
|
372
|
-
|
|
405
|
+
const end = tlEnd(entry.meta);
|
|
406
|
+
return !end || end === tlStart(entry.meta);
|
|
373
407
|
}
|
|
374
408
|
function onKeydown(e) {
|
|
375
409
|
if (e.target?.tagName === "INPUT" || e.target?.tagName === "TEXTAREA") return;
|
|
@@ -35,6 +35,8 @@ export interface FloatingWindowState {
|
|
|
35
35
|
initialTab?: 'editor' | 'chat';
|
|
36
36
|
meta?: Record<string, any>;
|
|
37
37
|
}
|
|
38
|
+
export declare function registerWindowLayer(): void;
|
|
39
|
+
export declare function unregisterWindowLayer(): void;
|
|
38
40
|
export declare function useWindowManager(): {
|
|
39
41
|
windows: import("vue").Reactive<Map<string, FloatingWindowState>>;
|
|
40
42
|
activeWindows: import("vue").ComputedRef<{
|
|
@@ -91,6 +93,8 @@ export declare function useWindowManager(): {
|
|
|
91
93
|
initialTab?: "editor" | "chat" | undefined;
|
|
92
94
|
meta?: Record<string, any> | undefined;
|
|
93
95
|
}[]>;
|
|
96
|
+
windowLayerMounted: import("vue").ComputedRef<boolean>;
|
|
97
|
+
floatWindowsAvailable: import("vue").ComputedRef<boolean>;
|
|
94
98
|
openWindow: (opts: {
|
|
95
99
|
id: string;
|
|
96
100
|
title: string;
|
|
@@ -4,6 +4,13 @@ const windows = reactive(/* @__PURE__ */ new Map());
|
|
|
4
4
|
const topZIndex = ref(30);
|
|
5
5
|
let cascadeOffset = 0;
|
|
6
6
|
let _saveDebounce = null;
|
|
7
|
+
const windowLayerCount = ref(0);
|
|
8
|
+
export function registerWindowLayer() {
|
|
9
|
+
windowLayerCount.value++;
|
|
10
|
+
}
|
|
11
|
+
export function unregisterWindowLayer() {
|
|
12
|
+
windowLayerCount.value = Math.max(0, windowLayerCount.value - 1);
|
|
13
|
+
}
|
|
7
14
|
export function useWindowManager() {
|
|
8
15
|
function bringToFront(id) {
|
|
9
16
|
const win = windows.get(id);
|
|
@@ -131,6 +138,8 @@ export function useWindowManager() {
|
|
|
131
138
|
const minimizedWindows = computed(
|
|
132
139
|
() => [...windows.values()].filter((w) => w.isMinimized)
|
|
133
140
|
);
|
|
141
|
+
const windowLayerMounted = computed(() => windowLayerCount.value > 0);
|
|
142
|
+
const floatWindowsAvailable = windowLayerMounted;
|
|
134
143
|
function _saveLayout() {
|
|
135
144
|
if (_saveDebounce) clearTimeout(_saveDebounce);
|
|
136
145
|
_saveDebounce = setTimeout(() => {
|
|
@@ -188,6 +197,8 @@ export function useWindowManager() {
|
|
|
188
197
|
windows,
|
|
189
198
|
activeWindows,
|
|
190
199
|
minimizedWindows,
|
|
200
|
+
windowLayerMounted,
|
|
201
|
+
floatWindowsAvailable,
|
|
191
202
|
openWindow,
|
|
192
203
|
closeWindow,
|
|
193
204
|
closeAll,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useWorkspace — low-level glue for navigating ONE doc-tree as an app workspace.
|
|
3
|
+
*
|
|
4
|
+
* Every Abracadabra app reimplements the same handful of doc-tree operations:
|
|
5
|
+
* scope the visible tree to a container, walk a breadcrumb up to it, flip a
|
|
6
|
+
* container's page type in place (the polymorphic-tree lens), and create a new
|
|
7
|
+
* child doc. This composable is that shared core — apps compose domain helpers
|
|
8
|
+
* beside it instead of copy-pasting the plumbing.
|
|
9
|
+
*
|
|
10
|
+
* Three ideas, all over the root doc's "doc-tree" Y.Map:
|
|
11
|
+
* 1. ROOT SCOPING — pass the container id your app lives under; breadcrumb +
|
|
12
|
+
* newDocument scope to it. Omit it (or pass null/'') to operate on the
|
|
13
|
+
* whole space tree.
|
|
14
|
+
* 2. THE LENS FLIP — setType() rewrites a container's `type`; <ADocRenderer>
|
|
15
|
+
* re-renders the SAME children under the new page type, zero data movement.
|
|
16
|
+
* 3. PLUMBING — entry/docType/childCount/isContainer/breadcrumb that every
|
|
17
|
+
* route, navbar, and command palette needs.
|
|
18
|
+
*
|
|
19
|
+
* Rendering, node panels, and awareness are handled by <ADocRenderer> + the
|
|
20
|
+
* renderers; this is purely the tree-navigation layer.
|
|
21
|
+
*
|
|
22
|
+
* @param root - The workspace container id (string, ref, or getter). Empty/null
|
|
23
|
+
* → the whole tree (no scoping).
|
|
24
|
+
*/
|
|
25
|
+
import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
|
|
26
|
+
export interface WorkspaceEntry {
|
|
27
|
+
label?: string;
|
|
28
|
+
parentId?: string | null;
|
|
29
|
+
order?: number;
|
|
30
|
+
type?: string;
|
|
31
|
+
meta?: Record<string, any>;
|
|
32
|
+
[k: string]: any;
|
|
33
|
+
}
|
|
34
|
+
export interface WorkspaceCrumb {
|
|
35
|
+
id: string;
|
|
36
|
+
label: string;
|
|
37
|
+
icon?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface UseWorkspace {
|
|
40
|
+
/** The scoped container id (empty string = unscoped / whole tree). */
|
|
41
|
+
rootDocId: ComputedRef<string>;
|
|
42
|
+
/** Raw doc-tree entry for an id. */
|
|
43
|
+
entry: (id: string) => WorkspaceEntry | undefined;
|
|
44
|
+
/** A doc's page type (defaults to "doc"). */
|
|
45
|
+
docType: (id: string) => string;
|
|
46
|
+
/** Number of direct children of a doc. */
|
|
47
|
+
childCount: (id: string) => number;
|
|
48
|
+
/** True when the doc owns children (a container — shows the lens switcher). */
|
|
49
|
+
isContainer: (id: string) => boolean;
|
|
50
|
+
/** Trail from just-below the root down to docId, EXCLUDING the root itself. */
|
|
51
|
+
breadcrumb: (docId: string) => WorkspaceCrumb[];
|
|
52
|
+
/** Flip a container's page type in place (the lens flip). */
|
|
53
|
+
setType: (id: string, type: string) => void;
|
|
54
|
+
/** Create a new child under the root (or top-level when unscoped). */
|
|
55
|
+
newDocument: (label?: string, type?: string, meta?: Record<string, any>) => string | null;
|
|
56
|
+
}
|
|
57
|
+
export declare function useWorkspace(root?: MaybeRefOrGetter<string | null | undefined>): UseWorkspace;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { computed, unref } from "vue";
|
|
2
|
+
import { useAbracadabra } from "./useAbracadabra.js";
|
|
3
|
+
import { useSyncedMap } from "./useYDoc.js";
|
|
4
|
+
export function useWorkspace(root) {
|
|
5
|
+
const abra = useAbracadabra();
|
|
6
|
+
const treeMap = useSyncedMap(abra.doc, "doc-tree");
|
|
7
|
+
const rootDocId = computed(() => {
|
|
8
|
+
const r = typeof root === "function" ? root() : unref(root);
|
|
9
|
+
return r || "";
|
|
10
|
+
});
|
|
11
|
+
function entry(id) {
|
|
12
|
+
return id ? treeMap.data[id] : void 0;
|
|
13
|
+
}
|
|
14
|
+
function docType(id) {
|
|
15
|
+
return entry(id)?.type ?? "doc";
|
|
16
|
+
}
|
|
17
|
+
function childCount(id) {
|
|
18
|
+
const data = treeMap.data;
|
|
19
|
+
let n = 0;
|
|
20
|
+
for (const k in data) if (data[k]?.parentId === id) n++;
|
|
21
|
+
return n;
|
|
22
|
+
}
|
|
23
|
+
function isContainer(id) {
|
|
24
|
+
return childCount(id) > 0;
|
|
25
|
+
}
|
|
26
|
+
function breadcrumb(docId) {
|
|
27
|
+
const out = [];
|
|
28
|
+
let id = docId;
|
|
29
|
+
let guard = 0;
|
|
30
|
+
while (id && id !== rootDocId.value && guard++ < 100) {
|
|
31
|
+
const e = entry(id);
|
|
32
|
+
if (!e) break;
|
|
33
|
+
out.unshift({ id, label: e.label || "Untitled", icon: e.meta?.icon });
|
|
34
|
+
id = e.parentId ?? "";
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
function setType(id, type) {
|
|
39
|
+
const e = entry(id);
|
|
40
|
+
if (!e || e.type === type) return;
|
|
41
|
+
treeMap.set(id, { ...e, type });
|
|
42
|
+
}
|
|
43
|
+
function newDocument(label = "Untitled", type = "doc", meta) {
|
|
44
|
+
const doc = abra.doc.value;
|
|
45
|
+
if (!doc || abra.isReady && !abra.isReady.value) return null;
|
|
46
|
+
const id = crypto.randomUUID();
|
|
47
|
+
const e = {
|
|
48
|
+
label,
|
|
49
|
+
parentId: rootDocId.value || null,
|
|
50
|
+
order: Date.now(),
|
|
51
|
+
type
|
|
52
|
+
};
|
|
53
|
+
if (meta) e.meta = meta;
|
|
54
|
+
doc.getMap("doc-tree").set(id, e);
|
|
55
|
+
return id;
|
|
56
|
+
}
|
|
57
|
+
return { rootDocId, entry, docType, childCount, isContainer, breadcrumb, setType, newDocument };
|
|
58
|
+
}
|
|
@@ -4,8 +4,18 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
|
|
4
4
|
if (import.meta.server) return;
|
|
5
5
|
const abra = useAbracadabra();
|
|
6
6
|
const config = useRuntimeConfig();
|
|
7
|
-
const
|
|
7
|
+
const authCfg = config.public?.abracadabra?.auth ?? {};
|
|
8
|
+
const loginPath = authCfg.loginPath ?? "/login";
|
|
9
|
+
const requireClaimed = authCfg.requireClaimed === true;
|
|
10
|
+
if (to.path === loginPath) return;
|
|
8
11
|
await abra.whenReady?.();
|
|
12
|
+
if (requireClaimed) {
|
|
13
|
+
const state = abra.identityState?.value;
|
|
14
|
+
if (state !== "claimed" && state !== "account") {
|
|
15
|
+
return navigateTo({ path: loginPath, query: { redirect: to.fullPath } });
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
9
19
|
if (!abra.publicKeyB64?.value) {
|
|
10
20
|
return navigateTo({ path: loginPath, query: { redirect: to.fullPath } });
|
|
11
21
|
}
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
_initServerInfo,
|
|
49
49
|
_destroyServerInfo
|
|
50
50
|
} from "./composables/useServerInfo.js";
|
|
51
|
-
import { setSdkModule } from "./utils/sdkRef.js";
|
|
51
|
+
import { setSdkModule, getSdkModule } from "./utils/sdkRef.js";
|
|
52
52
|
const NUXT_UI_PRIMARY_COLORS = /* @__PURE__ */ new Set([
|
|
53
53
|
"red",
|
|
54
54
|
"orange",
|
|
@@ -375,6 +375,16 @@ export default defineNuxtPlugin({
|
|
|
375
375
|
let _wsp = null;
|
|
376
376
|
let _tokenManager = null;
|
|
377
377
|
let _signChallenge = null;
|
|
378
|
+
let _ephemeralSeed = null;
|
|
379
|
+
function _wipeEphemeralSeed() {
|
|
380
|
+
if (_ephemeralSeed) {
|
|
381
|
+
_ephemeralSeed.fill(0);
|
|
382
|
+
_ephemeralSeed = null;
|
|
383
|
+
}
|
|
384
|
+
if (typeof window !== "undefined") {
|
|
385
|
+
window.removeEventListener("beforeunload", _wipeEphemeralSeed);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
378
388
|
let authFailureCount = 0;
|
|
379
389
|
const AUTH_FAILURE_LIMIT = 3;
|
|
380
390
|
let lastClientIds = /* @__PURE__ */ new Set();
|
|
@@ -747,6 +757,12 @@ export default defineNuxtPlugin({
|
|
|
747
757
|
_tokenManager?.clearSession();
|
|
748
758
|
if (client.value) client.value.logout();
|
|
749
759
|
if (keystore.value) await keystore.value.clear();
|
|
760
|
+
_wipeEphemeralSeed();
|
|
761
|
+
try {
|
|
762
|
+
const { clearSoftKey } = await import("./utils/softKeystore.js");
|
|
763
|
+
await clearSoftKey();
|
|
764
|
+
} catch {
|
|
765
|
+
}
|
|
750
766
|
localStorage.removeItem("abracadabra_privkey");
|
|
751
767
|
localStorage.removeItem("abracadabra_usercolor");
|
|
752
768
|
localStorage.removeItem("abracadabra_neutralcolor");
|
|
@@ -824,6 +840,50 @@ export default defineNuxtPlugin({
|
|
|
824
840
|
setTimeout(() => _wsp?.connect(), 300);
|
|
825
841
|
}
|
|
826
842
|
}
|
|
843
|
+
async function loginWithMnemonic(opts) {
|
|
844
|
+
const sdk = getSdkModule();
|
|
845
|
+
if (!sdk) throw new Error("SDK not initialized");
|
|
846
|
+
const { mnemonicToKeyPair, validateMnemonic } = sdk;
|
|
847
|
+
if (!validateMnemonic(opts.mnemonic)) throw new Error("Invalid recovery phrase");
|
|
848
|
+
const kp = await mnemonicToKeyPair(opts.mnemonic, opts.passphrase);
|
|
849
|
+
const pubKey = kp.publicKeyB64;
|
|
850
|
+
if (opts.ephemeral) {
|
|
851
|
+
_wipeEphemeralSeed();
|
|
852
|
+
_ephemeralSeed = kp.seed;
|
|
853
|
+
localStorage.removeItem("abracadabra_privkey");
|
|
854
|
+
if (typeof window !== "undefined") {
|
|
855
|
+
window.addEventListener("beforeunload", _wipeEphemeralSeed);
|
|
856
|
+
}
|
|
857
|
+
publicKeyB64.value = pubKey;
|
|
858
|
+
identityState.value = "claimed";
|
|
859
|
+
addLog("Ephemeral recovery-phrase session", "auth");
|
|
860
|
+
} else {
|
|
861
|
+
_wipeEphemeralSeed();
|
|
862
|
+
try {
|
|
863
|
+
const { softKeystoreAvailable, importSoftKeyFromSeed } = await import("./utils/softKeystore.js");
|
|
864
|
+
if (softKeystoreAvailable()) {
|
|
865
|
+
await importSoftKeyFromSeed(kp.seed);
|
|
866
|
+
} else {
|
|
867
|
+
localStorage.setItem("abracadabra_privkey", toBase64Url(kp.seed));
|
|
868
|
+
}
|
|
869
|
+
} finally {
|
|
870
|
+
kp.seed.fill(0);
|
|
871
|
+
}
|
|
872
|
+
localStorage.setItem(CLAIMED_FLAG_KEY, "1");
|
|
873
|
+
localStorage.setItem(PUBKEY_KEY, pubKey);
|
|
874
|
+
localStorage.removeItem(REQUIRE_PASSKEY_KEY);
|
|
875
|
+
publicKeyB64.value = pubKey;
|
|
876
|
+
identityState.value = "claimed";
|
|
877
|
+
addLog("Authenticated via recovery phrase", "auth");
|
|
878
|
+
}
|
|
879
|
+
const serverUrl = currentServerUrl.value;
|
|
880
|
+
if (client.value || serverUrl) {
|
|
881
|
+
_teardown();
|
|
882
|
+
_initPromise = null;
|
|
883
|
+
_initPromise = init(serverUrl);
|
|
884
|
+
await _initPromise;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
827
887
|
async function confirmPasswordReset(opts) {
|
|
828
888
|
if (!client.value) throw new Error("Not connected");
|
|
829
889
|
await client.value.confirmPasswordReset(opts);
|
|
@@ -947,28 +1007,64 @@ export default defineNuxtPlugin({
|
|
|
947
1007
|
const wasPreviouslyClaimed = localStorage.getItem(CLAIMED_FLAG_KEY) === "1";
|
|
948
1008
|
const storedPubKey = localStorage.getItem(PUBKEY_KEY);
|
|
949
1009
|
requirePasskeyOnLogin.value = localStorage.getItem(REQUIRE_PASSKEY_KEY) === "1";
|
|
950
|
-
|
|
1010
|
+
const { softKeystoreAvailable, getOrCreateSoftKey, getSoftKeyPublicKey, importSoftKeyFromSeed, signWithSoftKey } = await import("./utils/softKeystore.js");
|
|
1011
|
+
if (_ephemeralSeed) {
|
|
1012
|
+
pubKey = toBase64Url(ed.getPublicKey(_ephemeralSeed));
|
|
1013
|
+
identityState.value = "claimed";
|
|
1014
|
+
addLog("Ephemeral recovery-phrase identity", "auth");
|
|
1015
|
+
} else if (wasPreviouslyClaimed && storedPubKey) {
|
|
951
1016
|
pubKey = storedPubKey;
|
|
952
1017
|
identityState.value = "claimed";
|
|
953
|
-
|
|
1018
|
+
if (softKeystoreAvailable()) {
|
|
1019
|
+
const legacySeed = localStorage.getItem("abracadabra_privkey");
|
|
1020
|
+
if (legacySeed) {
|
|
1021
|
+
try {
|
|
1022
|
+
const seedBytes = fromBase64Url(legacySeed);
|
|
1023
|
+
await importSoftKeyFromSeed(seedBytes);
|
|
1024
|
+
seedBytes.fill(0);
|
|
1025
|
+
localStorage.removeItem("abracadabra_privkey");
|
|
1026
|
+
addLog("Migrated recovered key identity to encrypted soft keystore", "auth");
|
|
1027
|
+
} catch {
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
if (await getSoftKeyPublicKey() === pubKey) {
|
|
1031
|
+
addLog("Restored recovered key identity (soft seed)", "auth");
|
|
1032
|
+
} else {
|
|
1033
|
+
addLog("Restored claimed identity from cache", "auth");
|
|
1034
|
+
}
|
|
1035
|
+
} else {
|
|
1036
|
+
const recoveredSeed = localStorage.getItem("abracadabra_privkey");
|
|
1037
|
+
if (recoveredSeed) {
|
|
1038
|
+
privKey = fromBase64Url(recoveredSeed);
|
|
1039
|
+
addLog("Restored recovered key identity (soft seed)", "auth");
|
|
1040
|
+
} else {
|
|
1041
|
+
addLog("Restored claimed identity from cache", "auth");
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
954
1044
|
} else if (wasPreviouslyClaimed && !storedPubKey) {
|
|
955
1045
|
identityState.value = "identityLost";
|
|
956
1046
|
addLog("Previously claimed account \u2014 cached key missing, waiting for recovery", "auth");
|
|
957
1047
|
publicKeyB64.value = "";
|
|
958
1048
|
return;
|
|
959
1049
|
} else {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1050
|
+
if (softKeystoreAvailable()) {
|
|
1051
|
+
const softKey = await getOrCreateSoftKey();
|
|
1052
|
+
pubKey = softKey.publicKey;
|
|
1053
|
+
softKey.privateKey.fill(0);
|
|
1054
|
+
addLog("Using guest identity (soft key, IDB)", "auth");
|
|
964
1055
|
} else {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1056
|
+
const storedPrivKey = localStorage.getItem("abracadabra_privkey");
|
|
1057
|
+
if (storedPrivKey) {
|
|
1058
|
+
privKey = fromBase64Url(storedPrivKey);
|
|
1059
|
+
addLog("Using guest identity (soft key)", "auth");
|
|
1060
|
+
} else {
|
|
1061
|
+
privKey = ed.utils.randomSecretKey();
|
|
1062
|
+
localStorage.setItem("abracadabra_privkey", toBase64Url(privKey));
|
|
1063
|
+
addLog("Created new guest identity (soft key)", "auth");
|
|
1064
|
+
}
|
|
1065
|
+
pubKey = toBase64Url(ed.getPublicKey(privKey));
|
|
968
1066
|
}
|
|
969
1067
|
identityState.value = "guest";
|
|
970
|
-
const pubKeyBytes = ed.getPublicKey(privKey);
|
|
971
|
-
pubKey = toBase64Url(pubKeyBytes);
|
|
972
1068
|
}
|
|
973
1069
|
publicKeyB64.value = pubKey;
|
|
974
1070
|
const storedColor = localStorage.getItem("abracadabra_usercolor");
|
|
@@ -1011,7 +1107,19 @@ export default defineNuxtPlugin({
|
|
|
1011
1107
|
}
|
|
1012
1108
|
addLog(`Public key: ${pubKey.slice(0, 16)}...`, "auth");
|
|
1013
1109
|
const signChallengeFn = async (challenge) => {
|
|
1110
|
+
if (_ephemeralSeed) {
|
|
1111
|
+
return await CryptoIdentityKeystore.signWithSeed(challenge, _ephemeralSeed);
|
|
1112
|
+
}
|
|
1113
|
+
if (softKeystoreAvailable()) {
|
|
1114
|
+
try {
|
|
1115
|
+
if (await getSoftKeyPublicKey() === pubKey) {
|
|
1116
|
+
return await signWithSoftKey(challenge);
|
|
1117
|
+
}
|
|
1118
|
+
} catch {
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1014
1121
|
if (isClaimed.value) return await ks.sign(challenge);
|
|
1122
|
+
if (softKeystoreAvailable()) return await signWithSoftKey(challenge);
|
|
1015
1123
|
if (privKey) {
|
|
1016
1124
|
const sig = await ed.sign(fromBase64Url(challenge), privKey);
|
|
1017
1125
|
return toBase64Url(sig);
|
|
@@ -1412,6 +1520,7 @@ export default defineNuxtPlugin({
|
|
|
1412
1520
|
loginWithHardware,
|
|
1413
1521
|
loginWithPassword,
|
|
1414
1522
|
registerWithPassword,
|
|
1523
|
+
loginWithMnemonic,
|
|
1415
1524
|
logout,
|
|
1416
1525
|
reconnect,
|
|
1417
1526
|
logoutServer,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** A bare `YYYY-MM-DD` (no time component). */
|
|
2
|
+
export declare function isDateOnly(s: unknown): s is string;
|
|
3
|
+
/**
|
|
4
|
+
* The calendar "day" (`YYYY-MM-DD`) a value belongs to: an all-day / date-only
|
|
5
|
+
* value floats on its literal stored date (slice, no timezone math); a timed
|
|
6
|
+
* instant resolves to its LOCAL day. Used by the type-switch normalization to
|
|
7
|
+
* convert a Calendar `datetimeStart` into a Timeline `dateStart`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function calendarDayOf(value: string, allDay: boolean): string;
|
|
10
|
+
/** The opposite date-family key. `daterange` (Timeline) ⇄ `datetimerange` (Calendar). */
|
|
11
|
+
export declare const DATE_SIBLING_KEY: Record<string, string>;
|
|
12
|
+
type AnyMeta = Record<string, unknown> | null | undefined;
|
|
13
|
+
/** Tolerant start read — daterange (Timeline-native) first, datetimerange fallback. */
|
|
14
|
+
export declare function tlStart(meta: AnyMeta): string | undefined;
|
|
15
|
+
/** Tolerant end read — daterange (Timeline-native) first, datetimerange fallback. */
|
|
16
|
+
export declare function tlEnd(meta: AnyMeta): string | undefined;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { toLocalDateStr } from "./localDate.js";
|
|
2
|
+
export function isDateOnly(s) {
|
|
3
|
+
return typeof s === "string" && /^\d{4}-\d{2}-\d{2}$/.test(s);
|
|
4
|
+
}
|
|
5
|
+
export function calendarDayOf(value, allDay) {
|
|
6
|
+
return allDay || isDateOnly(value) ? value.slice(0, 10) : toLocalDateStr(new Date(value));
|
|
7
|
+
}
|
|
8
|
+
export const DATE_SIBLING_KEY = {
|
|
9
|
+
dateStart: "datetimeStart",
|
|
10
|
+
dateEnd: "datetimeEnd",
|
|
11
|
+
datetimeStart: "dateStart",
|
|
12
|
+
datetimeEnd: "dateEnd"
|
|
13
|
+
};
|
|
14
|
+
export function tlStart(meta) {
|
|
15
|
+
return meta?.dateStart ?? meta?.datetimeStart;
|
|
16
|
+
}
|
|
17
|
+
export function tlEnd(meta) {
|
|
18
|
+
return meta?.dateEnd ?? meta?.datetimeEnd;
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for item-label display across the doc renderers.
|
|
3
|
+
*
|
|
4
|
+
* Brand-new collection items (checklist tasks, table rows, sheet cells, kanban
|
|
5
|
+
* cards, gallery items) are created with an EMPTY label and renamed inline. The
|
|
6
|
+
* doc-tree stores that empty string verbatim, so renderers must distinguish
|
|
7
|
+
* "awaiting a name" (show a muted ghost placeholder) from a doc a user genuinely
|
|
8
|
+
* titled "Untitled". An empty label must never be persisted or rendered as the
|
|
9
|
+
* literal word "Untitled" — that is a display concern, decided per renderer.
|
|
10
|
+
*
|
|
11
|
+
* Ported verbatim from cou-sh/app/utils/itemLabel.ts.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* True when a label carries no real title: empty, whitespace-only, or the legacy
|
|
15
|
+
* "Untitled"/"untitled" sentinel (case-insensitive — the lowercase form is what
|
|
16
|
+
* a lost label round-trips back to through `untitled.md`).
|
|
17
|
+
*/
|
|
18
|
+
export declare function isPlaceholderLabel(label: unknown): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Display fallback for contexts that need a non-empty string for a possibly
|
|
21
|
+
* unnamed entity (breadcrumbs, calendar/map/graph/timeline chips). Returns
|
|
22
|
+
* `fallback` for placeholder labels, otherwise the label unchanged.
|
|
23
|
+
*
|
|
24
|
+
* Editable list items should NOT use this — they show a muted ghost placeholder
|
|
25
|
+
* via their own label so empty reads as "type here", not as a fake title.
|
|
26
|
+
*/
|
|
27
|
+
export declare function displayLabel(label: unknown, fallback?: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function isPlaceholderLabel(label) {
|
|
2
|
+
if (typeof label !== "string") return label == null;
|
|
3
|
+
const t = label.trim();
|
|
4
|
+
return t === "" || t.toLowerCase() === "untitled";
|
|
5
|
+
}
|
|
6
|
+
export function displayLabel(label, fallback = "Untitled") {
|
|
7
|
+
return isPlaceholderLabel(label) ? fallback : label;
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local-time date helpers shared by the date-bearing renderers (calendar,
|
|
3
|
+
* timeline, checklist). Ported verbatim from cou-sh/app/utils/localDate.ts.
|
|
4
|
+
*
|
|
5
|
+
* `new Date('YYYY-MM-DD')` parses as UTC midnight, which lands on the previous
|
|
6
|
+
* calendar day in negative-offset timezones; `Date#toISOString().slice(0,10)`
|
|
7
|
+
* emits the UTC date, a different wall-clock day in any non-zero offset. These
|
|
8
|
+
* helpers use LOCAL calendar components so events never render a day early/late.
|
|
9
|
+
*/
|
|
10
|
+
/** Parse a date string in LOCAL time. */
|
|
11
|
+
export declare function parseLocalDate(dateStr: string): Date;
|
|
12
|
+
/** Whole calendar days between today and the date (negative = past). */
|
|
13
|
+
export declare function daysFromToday(dateStr: string): number;
|
|
14
|
+
/** Format a Date as `YYYY-MM-DD` using LOCAL calendar components. */
|
|
15
|
+
export declare function toLocalDateStr(d: Date): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function parseLocalDate(dateStr) {
|
|
2
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateStr);
|
|
3
|
+
if (m) return new Date(+m[1], +m[2] - 1, +m[3]);
|
|
4
|
+
return new Date(dateStr);
|
|
5
|
+
}
|
|
6
|
+
export function daysFromToday(dateStr) {
|
|
7
|
+
const due = parseLocalDate(dateStr);
|
|
8
|
+
const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
9
|
+
return Math.round((startOfDay(due) - startOfDay(/* @__PURE__ */ new Date())) / 864e5);
|
|
10
|
+
}
|
|
11
|
+
export function toLocalDateStr(d) {
|
|
12
|
+
const y = d.getFullYear();
|
|
13
|
+
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
14
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
15
|
+
return `${y}-${m}-${day}`;
|
|
16
|
+
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LUCIDE_ICON_NAMES —
|
|
2
|
+
* LUCIDE_ICON_NAMES — the full Lucide icon set (names only).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* `@iconify-json/lucide
|
|
6
|
-
* bundle that dependency to keep its install footprint small, so we ship a
|
|
7
|
-
* static curated subset (~250 of the most useful Lucide icons) instead.
|
|
4
|
+
* GENERATED FILE — do not edit by hand. Regenerate after bumping the
|
|
5
|
+
* `@iconify-json/lucide` devDependency with:
|
|
8
6
|
*
|
|
9
|
-
*
|
|
10
|
-
* dep is added, replace this file with a single `Object.keys(...).sort()` call
|
|
11
|
-
* so that consumers get the full icon set.
|
|
7
|
+
* node scripts/gen-lucide-icons.mjs
|
|
12
8
|
*
|
|
13
|
-
*
|
|
14
|
-
* the
|
|
9
|
+
* Mirrors cou-sh's `Object.keys(lucideData.icons).sort()` so the module's
|
|
10
|
+
* IconPicker exposes the SAME 1771-icon set as the reference app —
|
|
11
|
+
* NOT a curated subset. We ship only the kebab-case NAMES (no SVG path
|
|
12
|
+
* bodies), so this adds ~30KB of strings to the bundle instead of the
|
|
13
|
+
* multi-hundred-KB `icons.json`. Nuxt Icon resolves the actual glyphs at
|
|
14
|
+
* render time (from a consumer-installed `@iconify-json/lucide` or the
|
|
15
|
+
* Iconify API), exactly as in cou-sh.
|
|
16
|
+
*
|
|
17
|
+
* Names are kebab-case, without the `i-lucide-` prefix. The IconPicker
|
|
18
|
+
* prepends the prefix when rendering.
|
|
19
|
+
*
|
|
20
|
+
* Count: 1771 icons (lucide `icons` keys; aliases excluded, matching cou-sh).
|
|
15
21
|
*/
|
|
16
22
|
export declare const LUCIDE_ICON_NAMES: string[];
|