@abraca/nuxt 2.87.0 → 2.90.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.87.0",
7
+ "version": "2.90.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -295,6 +295,11 @@ const module$1 = defineNuxtModule({
295
295
  "@tiptap/extension-superscript",
296
296
  "@tiptap/extension-subscript",
297
297
  "@tiptap/extension-code-block-lowlight",
298
+ // Pre-bundled for DEV, and it stays. What changed in the weight round is
299
+ // WHERE it is imported: `runtime/utils/lowlightCommon.ts` imports it
300
+ // statically and is the only file that may, because a dynamic
301
+ // `import('lowlight')` retains the namespace and with it all 156
302
+ // grammars. Read that file's header before touching either.
298
303
  "lowlight",
299
304
  // `lowlight` does a `default` import from the CommonJS `highlight.js/lib/core`.
300
305
  // It MUST be pre-bundled (CJS→ESM) or the browser can't read its 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;
@@ -14,13 +14,13 @@ type __VLS_Props = {
14
14
  extraItems?: DropdownMenuItem[][];
15
15
  };
16
16
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
- logout: () => any;
18
17
  "open-settings": () => any;
19
18
  "open-account": () => any;
19
+ logout: () => any;
20
20
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
21
- onLogout?: (() => any) | undefined;
22
21
  "onOpen-settings"?: (() => any) | undefined;
23
22
  "onOpen-account"?: (() => any) | undefined;
23
+ onLogout?: (() => any) | undefined;
24
24
  }>, {
25
25
  color: string;
26
26
  collapsed: boolean;
@@ -14,13 +14,13 @@ type __VLS_Props = {
14
14
  extraItems?: DropdownMenuItem[][];
15
15
  };
16
16
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
- logout: () => any;
18
17
  "open-settings": () => any;
19
18
  "open-account": () => any;
19
+ logout: () => any;
20
20
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
21
- onLogout?: (() => any) | undefined;
22
21
  "onOpen-settings"?: (() => any) | undefined;
23
22
  "onOpen-account"?: (() => any) | undefined;
23
+ onLogout?: (() => any) | undefined;
24
24
  }>, {
25
25
  color: string;
26
26
  collapsed: boolean;
@@ -0,0 +1,58 @@
1
+ import { type MaybeRefOrGetter } from 'vue';
2
+ export interface EdgeSwipeOptions {
3
+ /** A swipe that began at the left edge and travelled inward. */
4
+ onFromLeft?: () => void;
5
+ /** A swipe that began at the right edge and travelled inward. */
6
+ onFromRight?: () => void;
7
+ /** Turn the whole thing off without unmounting the caller. */
8
+ disabled?: MaybeRefOrGetter<boolean>;
9
+ /**
10
+ * How far from an edge a touch counts as an edge touch.
11
+ *
12
+ * 50px by default, which is deliberately WIDER than iOS's own back-swipe
13
+ * zone (~30–40px): a gesture that competes with the browser's has to be
14
+ * recognised before the browser recognises its own.
15
+ */
16
+ edge?: number;
17
+ /**
18
+ * The narrower band where an edge swipe wins even inside something that
19
+ * scrolls horizontally.
20
+ *
21
+ * A renderer that owns its horizontal axis — a kanban, a map, a timeline —
22
+ * would otherwise trap the reader: every swipe belongs to the renderer and
23
+ * nothing can be opened from inside it. 20px is enough to reach and small
24
+ * enough not to steal the renderer's own gestures.
25
+ */
26
+ forceEdge?: number;
27
+ /** Minimum inward travel before it counts. */
28
+ threshold?: number;
29
+ /**
30
+ * Also stop the BROWSER acting on the gesture.
31
+ *
32
+ * This is the whole reason edge handling is separate from an ordinary swipe:
33
+ * without `preventDefault` on an edge touch, iOS runs its own back-navigation
34
+ * and the app's gesture and the browser's fight over the same finger. Costs a
35
+ * non-passive `touchmove`, which is why it is a choice.
36
+ */
37
+ preventBrowserGesture?: boolean;
38
+ }
39
+ /**
40
+ * A swipe that starts at the screen's edge — the gesture that opens things.
41
+ *
42
+ * Distinct from `useSwipeGesture`, which watches an ELEMENT and tells you which
43
+ * way a finger travelled across it. This watches the WINDOW, cares where the
44
+ * finger started, and exists mostly to win an argument with the browser.
45
+ *
46
+ * Two zones and a scroll check, all three earned in cou-sh:
47
+ *
48
+ * - anything inside `data-swipe-ignore`, or inside a container that actually
49
+ * scrolls horizontally, keeps its own gesture — unless the touch began in
50
+ * the narrow `forceEdge` band;
51
+ * - a touch that starts on a control (a button, a link, an input) is not a
52
+ * swipe, so the control still works at the edge of the screen;
53
+ * - a gesture that travels mostly VERTICALLY is a scroll, not an edge swipe.
54
+ *
55
+ * Client-only by construction: it binds in `onMounted`-free fashion via a guard
56
+ * on `window`, and disposes with the calling scope.
57
+ */
58
+ export declare function useEdgeSwipe(options?: EdgeSwipeOptions): void;
@@ -0,0 +1,82 @@
1
+ import { onScopeDispose, toValue } from "vue";
2
+ export function useEdgeSwipe(options = {}) {
3
+ if (typeof window === "undefined") return;
4
+ const EDGE = options.edge ?? 50;
5
+ const FORCE_EDGE = options.forceEdge ?? 20;
6
+ const THRESHOLD = options.threshold ?? 60;
7
+ const VERTICAL_SLOP = 40;
8
+ let startX = 0;
9
+ let startY = 0;
10
+ let fromLeft = false;
11
+ let fromRight = false;
12
+ let tracking = false;
13
+ let fired = false;
14
+ function scrollsHorizontally(target) {
15
+ let el = target;
16
+ let depth = 0;
17
+ while (el && el !== document.documentElement && depth < 15) {
18
+ if (el.hasAttribute("data-swipe-ignore")) return true;
19
+ const style = getComputedStyle(el);
20
+ if (style.overflowX === "auto" || style.overflowX === "scroll") {
21
+ const box = el;
22
+ if (box.scrollWidth > box.clientWidth) return true;
23
+ }
24
+ el = el.parentElement;
25
+ depth++;
26
+ }
27
+ return false;
28
+ }
29
+ function onTouchStart(e) {
30
+ tracking = false;
31
+ fired = false;
32
+ if (toValue(options.disabled)) return;
33
+ if (e.touches.length !== 1) return;
34
+ const touch = e.touches[0];
35
+ startX = touch.clientX;
36
+ startY = touch.clientY;
37
+ const atLeft = startX < EDGE;
38
+ const atRight = window.innerWidth - startX < EDGE;
39
+ if (!atLeft && !atRight) return;
40
+ const target = e.target;
41
+ if (target?.closest?.('button, a, input, textarea, select, label, [role="button"]')) return;
42
+ const forced = startX < FORCE_EDGE || window.innerWidth - startX < FORCE_EDGE;
43
+ if (scrollsHorizontally(target) && !forced) return;
44
+ fromLeft = atLeft;
45
+ fromRight = atRight && !atLeft;
46
+ tracking = true;
47
+ }
48
+ function onTouchMove(e) {
49
+ if (!tracking || fired) return;
50
+ const touch = e.touches[0];
51
+ if (!touch) return;
52
+ const dx = touch.clientX - startX;
53
+ const dy = touch.clientY - startY;
54
+ if (Math.abs(dy) > VERTICAL_SLOP && Math.abs(dy) > Math.abs(dx)) {
55
+ tracking = false;
56
+ return;
57
+ }
58
+ if (options.preventBrowserGesture && e.cancelable) e.preventDefault();
59
+ if (fromLeft && dx > THRESHOLD) {
60
+ fired = true;
61
+ options.onFromLeft?.();
62
+ } else if (fromRight && dx < -THRESHOLD) {
63
+ fired = true;
64
+ options.onFromRight?.();
65
+ }
66
+ }
67
+ function onTouchEnd() {
68
+ tracking = false;
69
+ fired = false;
70
+ }
71
+ const moveOptions = { passive: !options.preventBrowserGesture };
72
+ window.addEventListener("touchstart", onTouchStart, { passive: true });
73
+ window.addEventListener("touchmove", onTouchMove, moveOptions);
74
+ window.addEventListener("touchend", onTouchEnd, { passive: true });
75
+ window.addEventListener("touchcancel", onTouchEnd, { passive: true });
76
+ onScopeDispose(() => {
77
+ window.removeEventListener("touchstart", onTouchStart);
78
+ window.removeEventListener("touchmove", onTouchMove);
79
+ window.removeEventListener("touchend", onTouchEnd);
80
+ window.removeEventListener("touchcancel", onTouchEnd);
81
+ });
82
+ }
@@ -22,6 +22,28 @@ export interface SwipeGestureOptions {
22
22
  disabled?: MaybeRefOrGetter<boolean>;
23
23
  /** Restrict to a single axis. Gestures on the other axis pass through. */
24
24
  axis?: 'x' | 'y';
25
+ /**
26
+ * Which input may fire this gesture.
27
+ *
28
+ * `any` (the default) keeps the trackpad: a deck, a slideover and a window
29
+ * manager are PAGERS, and paging them with a two-finger flick is the whole
30
+ * point of the wheel half.
31
+ *
32
+ * `touch` is for surfaces where a horizontal wheel is not a gesture but an
33
+ * accident. A reading page is the example: on a Mac, brushing sideways past a
34
+ * wide code block emits exactly the deltas this composable counts, and the
35
+ * reader is navigated away from the page they were reading. Measured, not
36
+ * theorised — eight `deltaX: 25` events took a documentation page to its
37
+ * neighbour.
38
+ */
39
+ pointer?: 'any' | 'touch';
40
+ /**
41
+ * Damping multiplier for a valid direction. `0` follows the finger with no
42
+ * visible offset at all — which is what a caller passes for a reader who has
43
+ * asked their system for less motion: the gesture still fires, the rubber
44
+ * band is simply not drawn.
45
+ */
46
+ damp?: MaybeRefOrGetter<number>;
25
47
  }
26
48
  /**
27
49
  * Swipe gesture detection for both touch (mobile) and trackpad/wheel (desktop).
@@ -31,7 +53,16 @@ export interface SwipeGestureOptions {
31
53
  *
32
54
  * A child with `data-swipe-ignore` lets its own touch-scroll pass through.
33
55
  *
34
- * Ported 1:1 from cou-sh/app/composables/useSwipeGesture.ts.
56
+ * Shared with cou-sh, which is where this shape was proven. Two things beyond
57
+ * that port, both of which a SITE needs and a dashboard did not:
58
+ *
59
+ * - `disabled` is re-checked on move and on end. It can flip true AFTER
60
+ * `touchstart` — a drag taking over the pointer mid-gesture is the usual
61
+ * way — and an in-flight swipe must then abort and snap back rather than
62
+ * finish and navigate.
63
+ * - `damp` is a caller's, so `prefers-reduced-motion` can be honoured by the
64
+ * thing that knows about it. `damp: 0` still fires the gesture and simply
65
+ * does not draw the rubber band.
35
66
  */
36
67
  export declare function useSwipeGesture(options: SwipeGestureOptions): {
37
68
  swipeOffset: Ref<{
@@ -10,6 +10,8 @@ export function useSwipeGesture(options) {
10
10
  const SWIPE_TRIGGER = 24;
11
11
  const DAMP_VALID = 0.4;
12
12
  const DAMP_INVALID = 0.1;
13
+ const dampValid = () => toValue(options.damp) ?? DAMP_VALID;
14
+ const dampInvalid = () => toValue(options.damp) == null ? DAMP_INVALID : dampValid() * 0.25;
13
15
  function isInsideSwipeIgnore(target, boundary) {
14
16
  let el = target;
15
17
  while (el && el !== boundary) {
@@ -35,8 +37,17 @@ export function useSwipeGesture(options) {
35
37
  isSwiping.value = false;
36
38
  swipeOffset.value = { x: 0, y: 0 };
37
39
  }
40
+ function resetSwipe() {
41
+ swipeOffset.value = { x: 0, y: 0 };
42
+ isSwiping.value = false;
43
+ touchLockedAxis = null;
44
+ }
38
45
  function onTouchMove(e) {
39
46
  if (touchIgnored) return;
47
+ if (toValue(options.disabled)) {
48
+ resetSwipe();
49
+ return;
50
+ }
40
51
  const touch = e.touches[0];
41
52
  const dx = touch.clientX - touchStartX;
42
53
  const dy = touch.clientY - touchStartY;
@@ -51,17 +62,21 @@ export function useSwipeGesture(options) {
51
62
  const canL = toValue(options.canSwipeLeft) ?? !!options.onSwipeLeft;
52
63
  const canR = toValue(options.canSwipeRight) ?? !!options.onSwipeRight;
53
64
  const valid = dx < 0 && canL || dx > 0 && canR;
54
- swipeOffset.value = { x: dx * (valid ? DAMP_VALID : DAMP_INVALID), y: 0 };
65
+ swipeOffset.value = { x: dx * (valid ? dampValid() : dampInvalid()), y: 0 };
55
66
  } else {
56
67
  const canU = toValue(options.canSwipeUp) ?? !!options.onSwipeUp;
57
68
  const canD = toValue(options.canSwipeDown) ?? !!options.onSwipeDown;
58
69
  const valid = dy < 0 && canU || dy > 0 && canD;
59
- swipeOffset.value = { x: 0, y: dy * (valid ? DAMP_VALID : DAMP_INVALID) };
70
+ swipeOffset.value = { x: 0, y: dy * (valid ? dampValid() : dampInvalid()) };
60
71
  }
61
72
  e.preventDefault();
62
73
  }
63
74
  function onTouchEnd() {
64
75
  if (touchIgnored) return;
76
+ if (toValue(options.disabled)) {
77
+ resetSwipe();
78
+ return;
79
+ }
65
80
  if (touchLockedAxis === "x" && Math.abs(swipeOffset.value.x) > SWIPE_TRIGGER) {
66
81
  if (swipeOffset.value.x < 0) options.onSwipeLeft?.();
67
82
  else options.onSwipeRight?.();
@@ -85,6 +100,7 @@ export function useSwipeGesture(options) {
85
100
  wheelTimer = null;
86
101
  }
87
102
  function onWheel(e) {
103
+ if (options.pointer === "touch") return;
88
104
  if (toValue(options.disabled)) return;
89
105
  if (e.ctrlKey) return;
90
106
  wheelAccumX += e.deltaX;
@@ -45,7 +45,7 @@ async function loadClientExtensions() {
45
45
  { default: Superscript },
46
46
  { default: Subscript },
47
47
  { default: CodeBlockLowlight },
48
- { createLowlight, common },
48
+ { createCommonLowlight },
49
49
  { Document },
50
50
  { DocumentHeader },
51
51
  { DocumentMeta },
@@ -101,7 +101,9 @@ async function loadClientExtensions() {
101
101
  import("@tiptap/extension-superscript"),
102
102
  import("@tiptap/extension-subscript"),
103
103
  import("@tiptap/extension-code-block-lowlight"),
104
- import("lowlight"),
104
+ // NOT `import('lowlight')` — see the wrapper's header. A dynamic import
105
+ // of that namespace cannot be tree-shaken and drags in all 156 grammars.
106
+ import("../utils/lowlightCommon.js"),
105
107
  tolerant(() => import("../extensions/document"), "document"),
106
108
  tolerant(() => import("../extensions/document-header"), "document-header"),
107
109
  tolerant(() => import("../extensions/document-meta"), "document-meta"),
@@ -145,7 +147,7 @@ async function loadClientExtensions() {
145
147
  tolerant(() => import("../extensions/svg-embed"), "svg-embed"),
146
148
  tolerant(() => import("../extensions/timeline"), "timeline")
147
149
  ]);
148
- const lowlight = createLowlight(common);
150
+ const lowlight = createCommonLowlight();
149
151
  const extensions = [
150
152
  TaskList,
151
153
  TaskItem.configure({ nested: true }),
@@ -236,7 +238,7 @@ async function loadServerExtensions() {
236
238
  const [
237
239
  { default: StarterKit },
238
240
  { default: CodeBlockLowlight },
239
- { createLowlight, common },
241
+ { createCommonLowlight },
240
242
  { Document },
241
243
  { DocumentHeader },
242
244
  { DocumentMeta },
@@ -244,13 +246,15 @@ async function loadServerExtensions() {
244
246
  ] = await Promise.all([
245
247
  import("@tiptap/starter-kit"),
246
248
  import("@tiptap/extension-code-block-lowlight"),
247
- import("lowlight"),
249
+ // NOT `import('lowlight')` — see the wrapper's header. A dynamic import
250
+ // of that namespace cannot be tree-shaken and drags in all 156 grammars.
251
+ import("../utils/lowlightCommon.js"),
248
252
  import("../extensions/document.js"),
249
253
  import("../extensions/document-header.js"),
250
254
  import("../extensions/document-meta.js"),
251
255
  import("../extensions/file-drop.js")
252
256
  ]);
253
- const lowlight = createLowlight(common);
257
+ const lowlight = createCommonLowlight();
254
258
  return [
255
259
  StarterKit.configure({
256
260
  // @ts-expect-error StarterKit accepts history option at runtime
@@ -0,0 +1,22 @@
1
+ /** The `common` grammar names, for tests and for anything reporting the set. */
2
+ export declare const LOWLIGHT_COMMON_LANGUAGES: string[];
3
+ /**
4
+ * A registry carrying the common languages.
5
+ *
6
+ * Called once per editor schema build — twice per process in practice, since
7
+ * the client and server extension lists are built separately.
8
+ */
9
+ export declare function createCommonLowlight(): {
10
+ highlight: (language: string, value: string, options?: Readonly<import("lowlight").Options> | null | undefined) => import("hast").Root;
11
+ highlightAuto: (value: string, options?: Readonly<import("lowlight").AutoOptions> | null | undefined) => import("hast").Root;
12
+ listLanguages: () => Array<string>;
13
+ register: {
14
+ (grammars: Readonly<Record<string, import("highlight.js").LanguageFn>>): undefined;
15
+ (name: string, grammar: import("highlight.js").LanguageFn): undefined;
16
+ };
17
+ registerAlias: {
18
+ (aliases: Readonly<Record<string, ReadonlyArray<string> | string>>): undefined;
19
+ (language: string, alias: ReadonlyArray<string> | string): undefined;
20
+ };
21
+ registered: (aliasOrName: string) => boolean;
22
+ };
@@ -0,0 +1,5 @@
1
+ import { createLowlight, common } from "lowlight";
2
+ export const LOWLIGHT_COMMON_LANGUAGES = Object.keys(common);
3
+ export function createCommonLowlight() {
4
+ return createLowlight(common);
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/nuxt",
3
- "version": "2.87.0",
3
+ "version": "2.90.0",
4
4
  "description": "First-class Nuxt module for the Abracadabra CRDT collaboration platform",
5
5
  "repository": "abracadabra/abracadabra-nuxt",
6
6
  "license": "MIT",
@@ -173,9 +173,9 @@
173
173
  }
174
174
  },
175
175
  "devDependencies": {
176
- "@abraca/convert": "^2.86.0",
177
- "@abraca/dabra": "^2.86.0",
178
- "@abraca/plugin": "^2.86.0",
176
+ "@abraca/convert": "^2.88.0",
177
+ "@abraca/dabra": "^2.88.0",
178
+ "@abraca/plugin": "^2.88.0",
179
179
  "@codemirror/autocomplete": "^6.18.0",
180
180
  "@codemirror/commands": "^6.7.0",
181
181
  "@codemirror/lang-css": "^6.3.1",