@abraca/nuxt 2.72.0 → 2.74.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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "2.72.0",
7
+ "version": "2.74.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -30,6 +30,17 @@ type __VLS_Props = {
30
30
  expanded?: boolean;
31
31
  /** Whether create / rename / reorder / delete are available. Default: true. */
32
32
  editable?: boolean;
33
+ /**
34
+ * List children carrying `meta.hidden`. Default: false.
35
+ *
36
+ * `meta.hidden` is the platform-wide "routable but not advertised" flag —
37
+ * it already removes a doc from navigation and from the graph. The sub-page
38
+ * list used to ignore it, which is how app-internal pages (a site-config
39
+ * document, a settings page, staging drafts) leaked onto the parent page
40
+ * for every reader. Owner/admin surfaces that deliberately want the full
41
+ * set pass `:show-hidden="true"`.
42
+ */
43
+ showHidden?: boolean;
33
44
  /** Per-string label overrides. */
34
45
  labels?: Partial<SubPageListLabels>;
35
46
  };
@@ -41,6 +52,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
41
52
  editable: boolean;
42
53
  labels: Partial<SubPageListLabels>;
43
54
  expanded: boolean;
55
+ showHidden: boolean;
44
56
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
45
57
  declare const _default: typeof __VLS_export;
46
58
  export default _default;
@@ -25,6 +25,7 @@ const props = defineProps({
25
25
  docId: { type: String, required: true },
26
26
  expanded: { type: Boolean, required: false, default: true },
27
27
  editable: { type: Boolean, required: false, default: true },
28
+ showHidden: { type: Boolean, required: false, default: false },
28
29
  labels: { type: Object, required: false, default: () => ({}) }
29
30
  });
30
31
  const emit = defineEmits(["open"]);
@@ -99,9 +100,14 @@ function pageColor(id, entry) {
99
100
  lookup: (lid) => treeMap.data[lid]
100
101
  });
101
102
  }
103
+ function visibleChildrenOf(parentId) {
104
+ const children = docTree.childrenOf(parentId);
105
+ if (props.showHidden) return children;
106
+ return children.filter((c) => !c.meta?.hidden);
107
+ }
102
108
  const { expandedIds, toggle: toggleExpand, flatItems } = useTreeExpansion({
103
109
  storageKey: `subdoc:expand:${props.docId}`,
104
- childrenOf: (parentId) => docTree.childrenOf(parentId)
110
+ childrenOf: visibleChildrenOf
105
111
  });
106
112
  const viewersByPage = computed(() => {
107
113
  const m = /* @__PURE__ */ new Map();
@@ -30,6 +30,17 @@ type __VLS_Props = {
30
30
  expanded?: boolean;
31
31
  /** Whether create / rename / reorder / delete are available. Default: true. */
32
32
  editable?: boolean;
33
+ /**
34
+ * List children carrying `meta.hidden`. Default: false.
35
+ *
36
+ * `meta.hidden` is the platform-wide "routable but not advertised" flag —
37
+ * it already removes a doc from navigation and from the graph. The sub-page
38
+ * list used to ignore it, which is how app-internal pages (a site-config
39
+ * document, a settings page, staging drafts) leaked onto the parent page
40
+ * for every reader. Owner/admin surfaces that deliberately want the full
41
+ * set pass `:show-hidden="true"`.
42
+ */
43
+ showHidden?: boolean;
33
44
  /** Per-string label overrides. */
34
45
  labels?: Partial<SubPageListLabels>;
35
46
  };
@@ -41,6 +52,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
41
52
  editable: boolean;
42
53
  labels: Partial<SubPageListLabels>;
43
54
  expanded: boolean;
55
+ showHidden: boolean;
44
56
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
45
57
  declare const _default: typeof __VLS_export;
46
58
  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;
@@ -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;
@@ -2,7 +2,15 @@ type __VLS_Props = {
2
2
  uploadId: string;
3
3
  docId: string;
4
4
  mimeType?: string;
5
+ /** Max-edge px for image covers (retina ~2× CSS); falls back to full blob. */
6
+ size?: number;
7
+ /** Skip the thumbnail and load the full-resolution original — for the
8
+ * lightbox / zoom view where a downscaled thumbnail would look soft. */
9
+ full?: boolean;
5
10
  };
6
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
12
+ size: number;
13
+ full: boolean;
14
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
15
  declare const _default: typeof __VLS_export;
8
16
  export default _default;
@@ -4,9 +4,11 @@ import { useFileBlobStore } from "../../composables/useFileBlobStore";
4
4
  const props = defineProps({
5
5
  uploadId: { type: String, required: true },
6
6
  docId: { type: String, required: true },
7
- mimeType: { type: String, required: false }
7
+ mimeType: { type: String, required: false },
8
+ size: { type: Number, required: false, default: 512 },
9
+ full: { type: Boolean, required: false, default: false }
8
10
  });
9
- const { getBlobUrl } = useFileBlobStore();
11
+ const { getBlobUrl, getThumbUrl } = useFileBlobStore();
10
12
  const blobUrl = ref("");
11
13
  const loading = ref(true);
12
14
  const errored = ref(false);
@@ -15,7 +17,14 @@ watchEffect(async () => {
15
17
  loading.value = true;
16
18
  errored.value = false;
17
19
  try {
18
- const url = await getBlobUrl(props.docId, props.uploadId);
20
+ const tryThumb = !props.full && (!props.mimeType || props.mimeType.startsWith("image/"));
21
+ let url = null;
22
+ if (tryThumb) {
23
+ url = await getThumbUrl(props.docId, props.uploadId, { w: props.size });
24
+ }
25
+ if (!url) {
26
+ url = await getBlobUrl(props.docId, props.uploadId);
27
+ }
19
28
  if (url) {
20
29
  blobUrl.value = url;
21
30
  } else {
@@ -2,7 +2,15 @@ type __VLS_Props = {
2
2
  uploadId: string;
3
3
  docId: string;
4
4
  mimeType?: string;
5
+ /** Max-edge px for image covers (retina ~2× CSS); falls back to full blob. */
6
+ size?: number;
7
+ /** Skip the thumbnail and load the full-resolution original — for the
8
+ * lightbox / zoom view where a downscaled thumbnail would look soft. */
9
+ full?: boolean;
5
10
  };
6
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
12
+ size: number;
13
+ full: boolean;
14
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
15
  declare const _default: typeof __VLS_export;
8
16
  export default _default;
@@ -371,6 +371,7 @@ defineExpose({ connectedUsers });
371
371
  :upload-id="lightboxItem.uploadId"
372
372
  :doc-id="lightboxItem.id"
373
373
  :mime-type="lightboxItem.mimeType"
374
+ full
374
375
  class="max-w-full max-h-[70vh] object-contain rounded"
375
376
  />
376
377
  </div>
@@ -9,7 +9,36 @@
9
9
  export declare function _initFileBlobStore(store: any): void;
10
10
  export declare function _getFileBlobStore(): any;
11
11
  export declare function _destroyFileBlobStore(): void;
12
+ /**
13
+ * Thumbnail request options — the box (`w`/`h`), `fit`, `format`, JPEG
14
+ * quality. Declared locally (not imported from @abraca/dabra) so this
15
+ * composable type-checks regardless of the installed SDK version; the store
16
+ * is `any`, and the `?.()` call below degrades gracefully when the SDK
17
+ * predates `getThumbUrl`.
18
+ */
19
+ export interface ThumbOptions {
20
+ w?: number;
21
+ h?: number;
22
+ fit?: 'cover' | 'contain' | 'inside';
23
+ format?: 'auto' | 'jpeg' | 'png';
24
+ q?: number;
25
+ }
26
+ /**
27
+ * The server's default `[uploads.thumbnails].allowed_sizes` ladder.
28
+ *
29
+ * The thumbnail endpoint deliberately serves ONLY these max-edge sizes — the
30
+ * allowlist is what bounds cache cardinality and closes a resize-amplification
31
+ * DoS — and answers anything else with **422**, not with a nearest match. A
32
+ * caller that asks for the size its layout actually needs (`w: 800` for an
33
+ * 800px card) therefore gets no thumbnail at all, silently falls back to the
34
+ * multi-megabyte original, and leaves a 422 in the console for every image on
35
+ * the page. Sizes are snapped here instead, so callers can keep expressing
36
+ * intent in real pixels.
37
+ */
38
+ export declare const THUMB_SIZES: readonly [64, 128, 256, 512, 1024];
12
39
  export declare function useFileBlobStore(): {
13
40
  getBlobUrl: (docId: string, uploadId: string) => Promise<string | null>;
41
+ getThumbUrl: (docId: string, uploadId: string, opts?: ThumbOptions) => Promise<string | null>;
42
+ invalidateThumbUrl: (docId: string, uploadId: string, opts?: ThumbOptions) => void;
14
43
  putBlob: (docId: string, id: string, file: File, filename: string) => Promise<void>;
15
44
  };
@@ -9,14 +9,36 @@ export function _destroyFileBlobStore() {
9
9
  _store?.destroy();
10
10
  _store = null;
11
11
  }
12
+ export const THUMB_SIZES = [64, 128, 256, 512, 1024];
13
+ function snapSize(px) {
14
+ if (!px || px <= 0) return void 0;
15
+ return THUMB_SIZES.find((s) => s >= px) ?? THUMB_SIZES[THUMB_SIZES.length - 1];
16
+ }
17
+ function snapOpts(opts) {
18
+ const w = snapSize(opts.w);
19
+ const h = snapSize(opts.h);
20
+ if (w === opts.w && h === opts.h) return opts;
21
+ return { ...opts, ...w !== void 0 ? { w } : {}, ...h !== void 0 ? { h } : {} };
22
+ }
12
23
  export function useFileBlobStore() {
13
24
  async function getBlobUrl(docId, uploadId) {
14
25
  if (!_store) return null;
15
26
  return _store.getBlobUrl(docId, uploadId);
16
27
  }
28
+ async function getThumbUrl(docId, uploadId, opts = {}) {
29
+ if (!_store) return null;
30
+ try {
31
+ return await _store.getThumbUrl?.(docId, uploadId, snapOpts(opts)) ?? null;
32
+ } catch {
33
+ return null;
34
+ }
35
+ }
36
+ function invalidateThumbUrl(docId, uploadId, opts = {}) {
37
+ _store?.invalidateThumbUrl?.(docId, uploadId, snapOpts(opts));
38
+ }
17
39
  async function putBlob(docId, id, file, filename) {
18
40
  if (!_store) return;
19
41
  return _store.putBlob(docId, id, file, filename);
20
42
  }
21
- return { getBlobUrl, putBlob };
43
+ return { getBlobUrl, getThumbUrl, invalidateThumbUrl, putBlob };
22
44
  }
@@ -20,7 +20,7 @@ const props = defineProps({
20
20
  extension: { type: Object, required: true },
21
21
  HTMLAttributes: { type: Object, required: true }
22
22
  });
23
- const { getBlobUrl } = useFileBlobStore();
23
+ const { getBlobUrl, getThumbUrl } = useFileBlobStore();
24
24
  const { client } = useAbracadabra();
25
25
  const uploadId = computed(() => props.node.attrs.uploadId);
26
26
  const docId = computed(() => props.node.attrs.docId);
@@ -55,7 +55,13 @@ async function loadBlob() {
55
55
  loading.value = true;
56
56
  error.value = null;
57
57
  try {
58
- const url = await getBlobUrl(docId.value, uploadId.value);
58
+ let url = null;
59
+ if (fileCategory.value === "image") {
60
+ url = await getThumbUrl(docId.value, uploadId.value, { w: 1024 });
61
+ }
62
+ if (!url) {
63
+ url = await getBlobUrl(docId.value, uploadId.value);
64
+ }
59
65
  if (url) {
60
66
  blobUrl.value = url;
61
67
  } else {
@@ -2,6 +2,7 @@ import { shallowRef, ref, computed, watch } from "vue";
2
2
  import { defineNuxtPlugin, useRuntimeConfig, useAppConfig, navigateTo } from "#imports";
3
3
  import * as Y from "yjs";
4
4
  import { PluginRegistry } from "./plugin-registry.js";
5
+ import { setAmbientDocTypeRegistry } from "./utils/docTypes.js";
5
6
  import { corePlugin } from "./plugins/core.plugin.js";
6
7
  import {
7
8
  UI_COLORS,
@@ -228,6 +229,7 @@ export default defineNuxtPlugin({
228
229
  const pinServer = abraConfig.pinServer ?? false;
229
230
  const deferConnect = abraConfig.deferConnect ?? false;
230
231
  const registry = new PluginRegistry();
232
+ setAmbientDocTypeRegistry(registry);
231
233
  const storedDisabledBuiltins = JSON.parse(
232
234
  localStorage.getItem(STORAGE_KEY_DISABLED_BUILTINS) ?? "[]"
233
235
  );
@@ -187,6 +187,8 @@ export interface DocTypeDefinition {
187
187
  export declare const GEO_TYPE_META_SCHEMAS: Record<string, MetaField[]>;
188
188
  export declare const DOC_TYPES: Record<string, DocTypeDefinition>;
189
189
  export declare const DEFAULT_DOC_TYPE: DocTypeDefinition;
190
+ /** Publish the app's plugin registry as the fallback for registry-less calls. */
191
+ export declare function setAmbientDocTypeRegistry(registry: PluginRegistry | null): void;
190
192
  /** Resolve a type key to a DocTypeDefinition. Falls back to plugin types, then to 'doc'. */
191
193
  export declare function resolveDocType(typeKey: string | undefined, registry?: PluginRegistry): DocTypeDefinition;
192
194
  /** All available doc types, including plugin contributions. */
@@ -319,11 +319,16 @@ export const DOC_TYPES = {
319
319
  }
320
320
  };
321
321
  export const DEFAULT_DOC_TYPE = DOC_TYPES.doc;
322
+ let ambientRegistry = null;
323
+ export function setAmbientDocTypeRegistry(registry) {
324
+ ambientRegistry = registry;
325
+ }
322
326
  export function resolveDocType(typeKey, registry) {
323
327
  if (!typeKey) return DEFAULT_DOC_TYPE;
324
328
  if (DOC_TYPES[typeKey]) return DOC_TYPES[typeKey];
325
- if (registry) {
326
- const pluginTypes = registry.getAllPageTypes();
329
+ const reg = registry ?? ambientRegistry;
330
+ if (reg) {
331
+ const pluginTypes = reg.getAllPageTypes();
327
332
  if (pluginTypes[typeKey]) {
328
333
  const pt = pluginTypes[typeKey];
329
334
  return {
@@ -342,8 +347,9 @@ export function resolveDocType(typeKey, registry) {
342
347
  }
343
348
  export function getAvailableDocTypes(registry) {
344
349
  const all = { ...DOC_TYPES };
345
- if (registry) {
346
- for (const [key, pt] of Object.entries(registry.getAllPageTypes())) {
350
+ const reg = registry ?? ambientRegistry;
351
+ if (reg) {
352
+ for (const [key, pt] of Object.entries(reg.getAllPageTypes())) {
347
353
  all[key] = {
348
354
  key,
349
355
  label: pt.label,
@@ -91,7 +91,12 @@ export interface TitleSyncInput {
91
91
  * │ │ │ local + post-initial → tree-from- │
92
92
  * │ │ │ header('Untitled') (user emptied │
93
93
  * │ │ │ the title, so canonicalise) │
94
- * │ different │ different │ initial OR local → tree-from-header │
94
+ * │ different │ different │ initial → header-from-tree (the tree │
95
+ * │ │ │ label is canonical; a stale header │
96
+ * │ │ │ must not revert a rename made while │
97
+ * │ │ │ no editor was mounted) │
98
+ * │ │ │ local + post-initial → tree-from- │
99
+ * │ │ │ header (the user is typing the H1) │
95
100
  * │ │ │ remote + post-initial → noop (the │
96
101
  * │ │ │ label watcher reconciles header │
97
102
  * │ │ │ from tree if needed) │
@@ -24,7 +24,7 @@ export function decideTitleSync(input) {
24
24
  return { kind: "noop" };
25
25
  }
26
26
  if (!initialSyncDone) {
27
- return { kind: "tree-from-header", label: headerText };
27
+ return { kind: "header-from-tree", text: treeLabel };
28
28
  }
29
29
  if (!isRemoteUpdate) {
30
30
  return { kind: "tree-from-header", label: headerText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/nuxt",
3
- "version": "2.72.0",
3
+ "version": "2.74.0",
4
4
  "description": "First-class Nuxt module for the Abracadabra CRDT collaboration platform",
5
5
  "repository": "abracadabra/abracadabra-nuxt",
6
6
  "license": "MIT",