@abraca/nuxt 2.56.0 → 2.57.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/aware/AMedia.d.vue.ts +1 -1
- package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
- package/dist/runtime/composables/useDocSlugs.js +3 -1
- package/dist/runtime/composables/useDocTree.js +4 -2
- package/dist/runtime/extensions/views/DocEmbedView.vue +3 -1
- package/dist/runtime/server/plugins/abracadabra-service.js +1 -0
- package/dist/runtime/server/runners/doc-tree-cache.js +4 -3
- package/dist/runtime/server/utils/slugMap.d.ts +4 -2
- package/dist/runtime/server/utils/slugMap.js +4 -4
- package/dist/runtime/types.d.ts +8 -0
- package/dist/runtime/utils/slugify.d.ts +7 -1
- package/dist/runtime/utils/slugify.js +4 -3
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
12
|
awareness: boolean;
|
|
13
13
|
tag: "video" | "audio";
|
|
14
14
|
live: boolean;
|
|
15
|
-
controls: boolean;
|
|
16
15
|
total: boolean;
|
|
16
|
+
controls: boolean;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
19
19
|
export default _default;
|
|
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
12
|
awareness: boolean;
|
|
13
13
|
tag: "video" | "audio";
|
|
14
14
|
live: boolean;
|
|
15
|
-
controls: boolean;
|
|
16
15
|
total: boolean;
|
|
16
|
+
controls: boolean;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
19
19
|
export default _default;
|
|
@@ -11,7 +11,9 @@ export function useDocSlugs() {
|
|
|
11
11
|
const entries = computed(
|
|
12
12
|
() => Object.entries(treeMap.data).map(([id, entry]) => ({ id, ...entry }))
|
|
13
13
|
);
|
|
14
|
-
const slugMap = computed(
|
|
14
|
+
const slugMap = computed(
|
|
15
|
+
() => buildSlugMap(entries.value, abra.spaceDocId?.value ?? null)
|
|
16
|
+
);
|
|
15
17
|
const getSlug = (docId) => slugMap.value.idToSlug[docId] ?? docId;
|
|
16
18
|
const getDocId = (slug) => slugMap.value.slugToId[slug] ?? null;
|
|
17
19
|
const getDocUrl = (docId) => {
|
|
@@ -34,14 +34,16 @@ export function useDocTree(docId) {
|
|
|
34
34
|
() => Object.entries(treeMap.data).filter(([id]) => id !== spaceDocId.value).map(([id, entry]) => ({ id, ...entry }))
|
|
35
35
|
);
|
|
36
36
|
const topLevelDocs = computed(
|
|
37
|
-
() => entries.value.filter(
|
|
37
|
+
() => entries.value.filter(
|
|
38
|
+
(e) => (!e.parentId || e.parentId === spaceDocId.value) && !e.trashed && e.id !== spaceDocId.value
|
|
39
|
+
).sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
|
|
38
40
|
);
|
|
39
41
|
const firstDocId = computed(() => topLevelDocs.value[0]?.id ?? null);
|
|
40
42
|
const getEntry = (id) => {
|
|
41
43
|
const raw = treeMap.data[id];
|
|
42
44
|
return raw ? { id, ...raw } : void 0;
|
|
43
45
|
};
|
|
44
|
-
const slugMap = computed(() => buildSlugMap(entries.value));
|
|
46
|
+
const slugMap = computed(() => buildSlugMap(entries.value, spaceDocId.value ?? null));
|
|
45
47
|
const navigationItems = computed(
|
|
46
48
|
() => topLevelDocs.value.filter((e) => e.meta?.hidden !== true).map((e) => {
|
|
47
49
|
const slug = slugMap.value.idToSlug[e.id];
|
|
@@ -6,6 +6,7 @@ import { navigateTo } from "#imports";
|
|
|
6
6
|
import { useAbracadabra } from "../../composables/useAbracadabra";
|
|
7
7
|
import { useSyncedMap } from "../../composables/useYDoc";
|
|
8
8
|
import { useDocSlugs } from "../../composables/useDocSlugs";
|
|
9
|
+
import { usePluginRegistry } from "../../composables/usePluginRegistry";
|
|
9
10
|
import { resolveDocType } from "../../utils/docTypes";
|
|
10
11
|
const props = defineProps({
|
|
11
12
|
decorations: { type: Array, required: true },
|
|
@@ -30,7 +31,8 @@ const treeMap = useSyncedMap(
|
|
|
30
31
|
const docId = computed(() => props.node.attrs.docId);
|
|
31
32
|
const treeEntry = computed(() => treeMap.data[docId.value]);
|
|
32
33
|
const exists = computed(() => !!treeEntry.value);
|
|
33
|
-
const
|
|
34
|
+
const registry = usePluginRegistry();
|
|
35
|
+
const docType = computed(() => resolveDocType(treeEntry.value?.type, registry));
|
|
34
36
|
const label = computed(() => treeEntry.value?.label || "Untitled");
|
|
35
37
|
const childProvider = shallowRef(null);
|
|
36
38
|
const isLoading = ref(false);
|
|
@@ -4,7 +4,7 @@ import { initSlugMap, rebuildSlugMapSync, rebuildSlugMap } from "../utils/slugMa
|
|
|
4
4
|
export const docTreeCacheRunner = {
|
|
5
5
|
name: "abracadabra:doc-tree-cache",
|
|
6
6
|
async start(ctx) {
|
|
7
|
-
const { rootDoc, rootProvider, storage } = ctx;
|
|
7
|
+
const { rootDoc, rootDocId, rootProvider, storage } = ctx;
|
|
8
8
|
const treeMap = rootDoc.getMap("doc-tree");
|
|
9
9
|
const loadedDocs = /* @__PURE__ */ new Map();
|
|
10
10
|
const pendingDocs = /* @__PURE__ */ new Set();
|
|
@@ -12,6 +12,7 @@ export const docTreeCacheRunner = {
|
|
|
12
12
|
initDocCache(storage, serverExts);
|
|
13
13
|
initSlugMap(storage);
|
|
14
14
|
async function trackDoc(docId) {
|
|
15
|
+
if (docId === rootDocId) return;
|
|
15
16
|
if (loadedDocs.has(docId) || pendingDocs.has(docId)) return;
|
|
16
17
|
pendingDocs.add(docId);
|
|
17
18
|
try {
|
|
@@ -44,7 +45,7 @@ export const docTreeCacheRunner = {
|
|
|
44
45
|
treeMap.forEach((_val, docId) => {
|
|
45
46
|
trackDoc(docId);
|
|
46
47
|
});
|
|
47
|
-
rebuildSlugMapSync(treeMap);
|
|
48
|
+
rebuildSlugMapSync(treeMap, rootDocId);
|
|
48
49
|
const observer = (event) => {
|
|
49
50
|
event.keysChanged.forEach((docId) => {
|
|
50
51
|
if (treeMap.has(docId)) {
|
|
@@ -55,7 +56,7 @@ export const docTreeCacheRunner = {
|
|
|
55
56
|
console.log(`[abracadabra:doc-tree-cache] Untracked: ${docId}`);
|
|
56
57
|
}
|
|
57
58
|
});
|
|
58
|
-
rebuildSlugMap(treeMap);
|
|
59
|
+
rebuildSlugMap(treeMap, rootDocId);
|
|
59
60
|
};
|
|
60
61
|
treeMap.observe(observer);
|
|
61
62
|
return () => {
|
|
@@ -18,12 +18,14 @@ export declare function loadPersistedSlugMap(): Promise<void>;
|
|
|
18
18
|
/**
|
|
19
19
|
* Rebuild the slug map from a Y.Map tree (debounced).
|
|
20
20
|
* Called by the doc-tree-cache runner when the tree changes.
|
|
21
|
+
* `rootId` = the space/root doc id — entries parented directly to it are
|
|
22
|
+
* top-level, and its self-descriptor entry gets no slug (mirrors the client).
|
|
21
23
|
*/
|
|
22
|
-
export declare function rebuildSlugMap(treeMap: any): void;
|
|
24
|
+
export declare function rebuildSlugMap(treeMap: any, rootId?: string | null): void;
|
|
23
25
|
/**
|
|
24
26
|
* Rebuild immediately (used for initial load).
|
|
25
27
|
*/
|
|
26
|
-
export declare function rebuildSlugMapSync(treeMap: any): void;
|
|
28
|
+
export declare function rebuildSlugMapSync(treeMap: any, rootId?: string | null): void;
|
|
27
29
|
/** Resolve a slug path to a docId. Returns null if not found. */
|
|
28
30
|
export declare function getDocIdFromSlug(slug: string): string | null;
|
|
29
31
|
/** Get the slug for a docId. Returns null if not found. */
|
|
@@ -19,14 +19,14 @@ export async function loadPersistedSlugMap() {
|
|
|
19
19
|
console.warn("[abracadabra:slug-map] Failed to load persisted slug map:", e);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
export function rebuildSlugMap(treeMap) {
|
|
22
|
+
export function rebuildSlugMap(treeMap, rootId) {
|
|
23
23
|
if (_rebuildTimer) clearTimeout(_rebuildTimer);
|
|
24
24
|
_rebuildTimer = setTimeout(() => {
|
|
25
25
|
_rebuildTimer = null;
|
|
26
|
-
rebuildSlugMapSync(treeMap);
|
|
26
|
+
rebuildSlugMapSync(treeMap, rootId);
|
|
27
27
|
}, REBUILD_DEBOUNCE_MS);
|
|
28
28
|
}
|
|
29
|
-
export function rebuildSlugMapSync(treeMap) {
|
|
29
|
+
export function rebuildSlugMapSync(treeMap, rootId) {
|
|
30
30
|
try {
|
|
31
31
|
const raw = treeMap.toJSON();
|
|
32
32
|
const entries = Object.entries(raw).map(([id, entry]) => ({
|
|
@@ -36,7 +36,7 @@ export function rebuildSlugMapSync(treeMap) {
|
|
|
36
36
|
order: entry.order ?? 0,
|
|
37
37
|
trashed: entry.trashed ?? false
|
|
38
38
|
}));
|
|
39
|
-
_slugMap = buildSlugMap(entries);
|
|
39
|
+
_slugMap = buildSlugMap(entries, rootId);
|
|
40
40
|
if (_storage) {
|
|
41
41
|
_storage.setItem(SLUG_STORAGE_KEY, _slugMap).catch((e) => {
|
|
42
42
|
console.warn("[abracadabra:slug-map] Failed to persist:", e);
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -629,6 +629,14 @@ export interface ServerRunnerContext {
|
|
|
629
629
|
wsp: AbracadabraWS;
|
|
630
630
|
/** Root Y.Doc (the world document) */
|
|
631
631
|
rootDoc: Y.Doc;
|
|
632
|
+
/**
|
|
633
|
+
* The root/space document ID the service synced (`service.rootDocId`
|
|
634
|
+
* override or the backend's `/info root_doc_id`). NOTE: `rootDoc.guid` is
|
|
635
|
+
* NOT this id — the root Y.Doc is created guid-less; the id lives on the
|
|
636
|
+
* provider. Use this for tree semantics (self-descriptor, space-rooted
|
|
637
|
+
* parentIds, slug maps).
|
|
638
|
+
*/
|
|
639
|
+
rootDocId: string;
|
|
632
640
|
/** Root AbracadabraProvider — call .loadChild(docId) to open sub-documents */
|
|
633
641
|
rootProvider: AbracadabraProvider;
|
|
634
642
|
/** Nitro useStorage() handle — use for persistent cache across requests */
|
|
@@ -35,6 +35,12 @@ export interface SlugMap {
|
|
|
35
35
|
* Duplicate slugs at the same level get `-1`, `-2` suffixes (first occurrence
|
|
36
36
|
* keeps the base slug).
|
|
37
37
|
*
|
|
38
|
+
* `rootId` (optional): the space/root doc id. Entries parented DIRECTLY to the
|
|
39
|
+
* root doc (`parentId === rootId`) are top-level — same as `parentId: null` —
|
|
40
|
+
* so trees that model nav pages as true children of the space doc still get
|
|
41
|
+
* root-level slugs. The root doc's own self-descriptor entry (`id === rootId`,
|
|
42
|
+
* the cou-sh space pattern) is skipped: the root is served at `/`, never a slug.
|
|
43
|
+
*
|
|
38
44
|
* The output is deterministic: entries are sorted by order, then by id.
|
|
39
45
|
*/
|
|
40
|
-
export declare function buildSlugMap(entries: SlugMapEntry[]): SlugMap;
|
|
46
|
+
export declare function buildSlugMap(entries: SlugMapEntry[], rootId?: string | null): SlugMap;
|
|
@@ -3,13 +3,14 @@ export function slugify(label) {
|
|
|
3
3
|
return slug || "untitled";
|
|
4
4
|
}
|
|
5
5
|
export const isUUID = (s) => /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s);
|
|
6
|
-
export function buildSlugMap(entries) {
|
|
6
|
+
export function buildSlugMap(entries, rootId) {
|
|
7
7
|
const slugToId = {};
|
|
8
8
|
const idToSlug = {};
|
|
9
|
-
const active = entries.filter((e) => !e.trashed);
|
|
9
|
+
const active = entries.filter((e) => !e.trashed && (!rootId || e.id !== rootId));
|
|
10
10
|
const byParent = /* @__PURE__ */ new Map();
|
|
11
11
|
for (const entry of active) {
|
|
12
|
-
const
|
|
12
|
+
const pid = entry.parentId ?? null;
|
|
13
|
+
const key = rootId && pid === rootId ? null : pid;
|
|
13
14
|
if (!byParent.has(key)) byParent.set(key, []);
|
|
14
15
|
byParent.get(key).push(entry);
|
|
15
16
|
}
|