@aevantec/litevue 0.5.5 → 0.5.7

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.
Files changed (65) hide show
  1. package/README.md +10 -7
  2. package/dist/litevue-devtools.iife.js +1 -1
  3. package/dist/litevue-devtools.mjs +1 -1
  4. package/dist/litevue-devtools.umd.js +1 -1
  5. package/dist/litevue-plugins.dev.iife.js +898 -0
  6. package/dist/litevue-plugins.dev.mjs +880 -0
  7. package/dist/litevue-plugins.iife.js +1 -1
  8. package/dist/litevue-plugins.mjs +1 -1
  9. package/dist/litevue-plugins.umd.js +1 -1
  10. package/dist/litevue.dev.iife.js +2103 -0
  11. package/dist/litevue.dev.mjs +2092 -0
  12. package/dist/litevue.iife.js +1 -1
  13. package/dist/litevue.mjs +1 -1
  14. package/dist/litevue.umd.js +1 -1
  15. package/dist/plugins/collapse.iife.js +1 -1
  16. package/dist/plugins/collapse.mjs +1 -1
  17. package/dist/plugins/collapse.umd.js +1 -1
  18. package/dist/plugins/media.dev.iife.js +249 -0
  19. package/dist/plugins/media.dev.mjs +243 -0
  20. package/dist/plugins/morph.dev.iife.js +217 -0
  21. package/dist/plugins/morph.dev.mjs +212 -0
  22. package/dist/plugins/morph.iife.js +1 -1
  23. package/dist/plugins/morph.mjs +1 -1
  24. package/dist/plugins/morph.umd.js +1 -1
  25. package/dist/plugins/persist.dev.iife.js +126 -0
  26. package/dist/plugins/persist.dev.mjs +120 -0
  27. package/dist/types/app.d.mts +15 -18
  28. package/dist/types/app.d.ts +15 -18
  29. package/dist/types/block.d.mts +1 -2
  30. package/dist/types/block.d.ts +1 -2
  31. package/dist/types/context.d.mts +5 -8
  32. package/dist/types/context.d.ts +5 -8
  33. package/dist/types/devtools.d.mts +7 -0
  34. package/dist/types/devtools.d.ts +7 -0
  35. package/dist/types/effect.d.mts +6 -10
  36. package/dist/types/effect.d.ts +6 -10
  37. package/dist/types/errors.d.mts +36 -0
  38. package/dist/types/errors.d.ts +36 -0
  39. package/dist/types/eval.d.mts +8 -2
  40. package/dist/types/eval.d.ts +8 -2
  41. package/dist/types/index.d.mts +1 -0
  42. package/dist/types/index.d.ts +1 -0
  43. package/dist/types/magics.d.mts +5 -6
  44. package/dist/types/magics.d.ts +5 -6
  45. package/dist/types/ownership.d.mts +9 -16
  46. package/dist/types/ownership.d.ts +9 -16
  47. package/dist/types/plugins/focus/index.d.mts +6 -8
  48. package/dist/types/plugins/focus/index.d.ts +6 -8
  49. package/dist/types/plugins/media/index.d.mts +6 -7
  50. package/dist/types/plugins/media/index.d.ts +6 -7
  51. package/dist/types/plugins/morph/index.d.mts +23 -11
  52. package/dist/types/plugins/morph/index.d.ts +23 -11
  53. package/dist/types/plugins/persist/index.d.mts +12 -19
  54. package/dist/types/plugins/persist/index.d.ts +12 -19
  55. package/dist/types/plugins/resize/index.d.mts +5 -7
  56. package/dist/types/plugins/resize/index.d.ts +5 -7
  57. package/dist/types/plugins/transition/index.d.mts +7 -12
  58. package/dist/types/plugins/transition/index.d.ts +7 -12
  59. package/dist/types/store.d.mts +3 -6
  60. package/dist/types/store.d.ts +3 -6
  61. package/dist/types/utils.d.mts +3 -3
  62. package/dist/types/utils.d.ts +3 -3
  63. package/dist/types/warn.d.mts +6 -8
  64. package/dist/types/warn.d.ts +6 -8
  65. package/package.json +11 -2
@@ -14,8 +14,7 @@ export declare class Block {
14
14
  remove(): void;
15
15
  /**
16
16
  * The bookkeeping half of `remove()`, for a block whose nodes are already
17
- * gone. `remove()` cannot be reused there: its `removeChild` calls would
18
- * throw on nodes that no longer have this parent.
17
+ * gone — `remove()`'s `removeChild` calls would throw on them.
19
18
  */
20
19
  discard(): void;
21
20
  teardown(): void;
@@ -14,8 +14,7 @@ export declare class Block {
14
14
  remove(): void;
15
15
  /**
16
16
  * The bookkeeping half of `remove()`, for a block whose nodes are already
17
- * gone. `remove()` cannot be reused there: its `removeChild` calls would
18
- * throw on nodes that no longer have this parent.
17
+ * gone — `remove()`'s `removeChild` calls would throw on them.
19
18
  */
20
19
  discard(): void;
21
20
  teardown(): void;
@@ -12,17 +12,14 @@ export interface Context {
12
12
  delimiters: [string, string];
13
13
  delimitersRE: RegExp;
14
14
  /**
15
- * The framework walker, published on the root context by `mount()` and
16
- * inherited by every child context through the spreads below. Plugins that
17
- * insert markup into a live tree (morph) need it to bind that markup, and
18
- * reading it here keeps them from importing — and re-bundling — the core.
15
+ * The framework walker, published by `mount()` and inherited by every child
16
+ * context. Plugins that insert markup into a live tree (morph) bind it with
17
+ * this instead of importing — and re-bundling — the core.
19
18
  */
20
19
  walk?: (node: Node, ctx: Context) => ChildNode | null | void;
21
20
  /**
22
- * Disposes a node and its subtree. Published on the root context alongside
23
- * `walk` and inherited by the spreads above, so a plugin that removes nodes
24
- * — morph does, directly — can release what they owned without importing
25
- * and re-bundling the core.
21
+ * Disposes a node and its subtree. Published alongside `walk`, so a plugin
22
+ * that removes nodes directly can release what they owned.
26
23
  */
27
24
  dispose?: (node: Node) => void;
28
25
  }
@@ -12,17 +12,14 @@ export interface Context {
12
12
  delimiters: [string, string];
13
13
  delimitersRE: RegExp;
14
14
  /**
15
- * The framework walker, published on the root context by `mount()` and
16
- * inherited by every child context through the spreads below. Plugins that
17
- * insert markup into a live tree (morph) need it to bind that markup, and
18
- * reading it here keeps them from importing — and re-bundling — the core.
15
+ * The framework walker, published by `mount()` and inherited by every child
16
+ * context. Plugins that insert markup into a live tree (morph) bind it with
17
+ * this instead of importing — and re-bundling — the core.
19
18
  */
20
19
  walk?: (node: Node, ctx: Context) => ChildNode | null | void;
21
20
  /**
22
- * Disposes a node and its subtree. Published on the root context alongside
23
- * `walk` and inherited by the spreads above, so a plugin that removes nodes
24
- * — morph does, directly — can release what they owned without importing
25
- * and re-bundling the core.
21
+ * Disposes a node and its subtree. Published alongside `walk`, so a plugin
22
+ * that removes nodes directly can release what they owned.
26
23
  */
27
24
  dispose?: (node: Node) => void;
28
25
  }
@@ -21,6 +21,12 @@ export interface LiteVueDevtools {
21
21
  * reactive — writing to one updates every app using it.
22
22
  */
23
23
  stores: Map<string, Record<string, any>>;
24
+ /**
25
+ * Names registered with app.component(). Inspection UIs use this to label a
26
+ * scope by the component that produced it — `v-scope="Cart()"` reads as
27
+ * `<Cart>` rather than by tag or id.
28
+ */
29
+ components: Set<string>;
24
30
  /**
25
31
  * Find the scope governing a node by walking up the DOM to the nearest
26
32
  * registered scope root. Usable from the console: __LITE_VUE__.getScope($0)
@@ -44,6 +50,7 @@ export interface LiteVueDevtools {
44
50
  }
45
51
  export declare const registerScope: (el: Element, scope: Record<string, any>, exp?: string, name?: string) => (() => void);
46
52
  export declare const registerStore: (name: string, store: Record<string, any>) => void;
53
+ export declare const registerComponent: (name: string) => void;
47
54
  export declare const emitFlush: () => void;
48
55
  export declare const devtools: LiteVueDevtools;
49
56
  /**
@@ -21,6 +21,12 @@ export interface LiteVueDevtools {
21
21
  * reactive — writing to one updates every app using it.
22
22
  */
23
23
  stores: Map<string, Record<string, any>>;
24
+ /**
25
+ * Names registered with app.component(). Inspection UIs use this to label a
26
+ * scope by the component that produced it — `v-scope="Cart()"` reads as
27
+ * `<Cart>` rather than by tag or id.
28
+ */
29
+ components: Set<string>;
24
30
  /**
25
31
  * Find the scope governing a node by walking up the DOM to the nearest
26
32
  * registered scope root. Usable from the console: __LITE_VUE__.getScope($0)
@@ -44,6 +50,7 @@ export interface LiteVueDevtools {
44
50
  }
45
51
  export declare const registerScope: (el: Element, scope: Record<string, any>, exp?: string, name?: string) => (() => void);
46
52
  export declare const registerStore: (name: string, store: Record<string, any>) => void;
53
+ export declare const registerComponent: (name: string) => void;
47
54
  export declare const emitFlush: () => void;
48
55
  export declare const devtools: LiteVueDevtools;
49
56
  /**
@@ -1,15 +1,11 @@
1
1
  /**
2
- * watchEffect(fn) — run `fn` now, then again whenever any reactive state it
3
- * read changes. The JS-side counterpart to `v-effect`, for work that isn't
4
- * tied to an element: syncing state to storage or the URL, updating
5
- * document.title, driving a non-LiteVue widget.
2
+ * Runs `fn` now, then again when the reactive state it read changes. The
3
+ * JS-side counterpart to `v-effect`, for work not tied to an element.
6
4
  *
7
- * Re-runs go through the framework scheduler, so a burst of mutations in one
8
- * tick triggers a single run and the DOM is already up to date by then —
9
- * unlike @vue/reactivity's raw `effect`, which fires synchronously on every
10
- * mutation.
5
+ * Re-runs are scheduled, so a burst of mutations in one tick triggers one run
6
+ * with the DOM already updated — unlike raw `effect`, which fires
7
+ * synchronously per mutation.
11
8
  *
12
- * Returns a function that stops watching. Nothing stops it automatically, so
13
- * hold onto it for anything shorter-lived than the page.
9
+ * Returns a stop function. Nothing stops it automatically.
14
10
  */
15
11
  export declare const watchEffect: (fn: () => void) => (() => void);
@@ -1,15 +1,11 @@
1
1
  /**
2
- * watchEffect(fn) — run `fn` now, then again whenever any reactive state it
3
- * read changes. The JS-side counterpart to `v-effect`, for work that isn't
4
- * tied to an element: syncing state to storage or the URL, updating
5
- * document.title, driving a non-LiteVue widget.
2
+ * Runs `fn` now, then again when the reactive state it read changes. The
3
+ * JS-side counterpart to `v-effect`, for work not tied to an element.
6
4
  *
7
- * Re-runs go through the framework scheduler, so a burst of mutations in one
8
- * tick triggers a single run and the DOM is already up to date by then —
9
- * unlike @vue/reactivity's raw `effect`, which fires synchronously on every
10
- * mutation.
5
+ * Re-runs are scheduled, so a burst of mutations in one tick triggers one run
6
+ * with the DOM already updated — unlike raw `effect`, which fires
7
+ * synchronously per mutation.
11
8
  *
12
- * Returns a function that stops watching. Nothing stops it automatically, so
13
- * hold onto it for anything shorter-lived than the page.
9
+ * Returns a stop function. Nothing stops it automatically.
14
10
  */
15
11
  export declare const watchEffect: (fn: () => void) => (() => void);
@@ -0,0 +1,36 @@
1
+ /**
2
+ * One route for every runtime error. The diagnostic prose is DEV-only; the
3
+ * routing and `onError` handlers ship, since that is where monitoring hooks in.
4
+ */
5
+ export type ErrorPhase =
6
+ /** evaluating a directive's expression, or a text interpolation */
7
+ 'expression'
8
+ /** inside a v-on handler, after the event fired */
9
+ | 'handler'
10
+ /** a directive's own setup threw */
11
+ | 'directive'
12
+ /** the expression could not be compiled into a function at all */
13
+ | 'compile'
14
+ /** re-running after a change: a `$watch` callback, `watchEffect`, a plugin effect */
15
+ | 'effect'
16
+ /** a plugin's teardown, during a full `app.unmount()` */
17
+ | 'teardown';
18
+ export interface ErrorInfo {
19
+ phase: ErrorPhase;
20
+ /** the expression text, as written in the attribute */
21
+ expression?: string;
22
+ /** the attribute or construct it came from, e.g. `v-on:click` or `{{ }}` */
23
+ source?: string;
24
+ /** the element the directive sits on */
25
+ el?: Node;
26
+ /** the scope the expression was evaluated against */
27
+ scope?: Record<string, any>;
28
+ }
29
+ export type ErrorHandler = (err: unknown, info: ErrorInfo) => void;
30
+ /** A short, recognisable rendering of the element — not its whole subtree. */
31
+ export declare const describeEl: (el?: Node) => string | undefined;
32
+ /** Registered by `app.onError()`. Shared across apps, like the store registry. */
33
+ export declare const addErrorHandler: (fn: ErrorHandler) => () => void;
34
+ /** Test seam — drops every registered handler. */
35
+ export declare const clearErrorHandlers: () => undefined;
36
+ export declare const handleError: (err: unknown, info: ErrorInfo) => void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * One route for every runtime error. The diagnostic prose is DEV-only; the
3
+ * routing and `onError` handlers ship, since that is where monitoring hooks in.
4
+ */
5
+ export type ErrorPhase =
6
+ /** evaluating a directive's expression, or a text interpolation */
7
+ 'expression'
8
+ /** inside a v-on handler, after the event fired */
9
+ | 'handler'
10
+ /** a directive's own setup threw */
11
+ | 'directive'
12
+ /** the expression could not be compiled into a function at all */
13
+ | 'compile'
14
+ /** re-running after a change: a `$watch` callback, `watchEffect`, a plugin effect */
15
+ | 'effect'
16
+ /** a plugin's teardown, during a full `app.unmount()` */
17
+ | 'teardown';
18
+ export interface ErrorInfo {
19
+ phase: ErrorPhase;
20
+ /** the expression text, as written in the attribute */
21
+ expression?: string;
22
+ /** the attribute or construct it came from, e.g. `v-on:click` or `{{ }}` */
23
+ source?: string;
24
+ /** the element the directive sits on */
25
+ el?: Node;
26
+ /** the scope the expression was evaluated against */
27
+ scope?: Record<string, any>;
28
+ }
29
+ export type ErrorHandler = (err: unknown, info: ErrorInfo) => void;
30
+ /** A short, recognisable rendering of the element — not its whole subtree. */
31
+ export declare const describeEl: (el?: Node) => string | undefined;
32
+ /** Registered by `app.onError()`. Shared across apps, like the store registry. */
33
+ export declare const addErrorHandler: (fn: ErrorHandler) => () => void;
34
+ /** Test seam — drops every registered handler. */
35
+ export declare const clearErrorHandlers: () => undefined;
36
+ export declare const handleError: (err: unknown, info: ErrorInfo) => void;
@@ -1,2 +1,8 @@
1
- export declare const evaluate: (scope: any, exp: string, el?: Node) => any;
2
- export declare const execute: (scope: any, exp: string, el?: Node) => any;
1
+ import { type ErrorInfo } from './errors.mjs';
2
+ /** Where the expression came from, so a failure can name its directive and element. */
3
+ export type EvalMeta = Pick<ErrorInfo, 'source' | 'el'> & {
4
+ /** Shown instead of the compiled text: `{{ total }}`, not `$s( total )`. */
5
+ expression?: string;
6
+ };
7
+ export declare const evaluate: (scope: any, exp: string, el?: Node, meta?: EvalMeta) => any;
8
+ export declare const execute: (scope: any, exp: string, el?: Node, meta?: EvalMeta) => any;
@@ -1,2 +1,8 @@
1
- export declare const evaluate: (scope: any, exp: string, el?: Node) => any;
2
- export declare const execute: (scope: any, exp: string, el?: Node) => any;
1
+ import { type ErrorInfo } from './errors';
2
+ /** Where the expression came from, so a failure can name its directive and element. */
3
+ export type EvalMeta = Pick<ErrorInfo, 'source' | 'el'> & {
4
+ /** Shown instead of the compiled text: `{{ total }}`, not `$s( total )`. */
5
+ expression?: string;
6
+ };
7
+ export declare const evaluate: (scope: any, exp: string, el?: Node, meta?: EvalMeta) => any;
8
+ export declare const execute: (scope: any, exp: string, el?: Node, meta?: EvalMeta) => any;
@@ -5,5 +5,6 @@ export { nextTick } from './scheduler.mjs';
5
5
  export { watchEffect } from './effect.mjs';
6
6
  export { computed, reactive } from '@vue/reactivity';
7
7
  export type { ComputedRef, WritableComputedRef } from '@vue/reactivity';
8
+ export type { ErrorHandler, ErrorInfo, ErrorPhase } from './errors.mjs';
8
9
  export { devtools, disableDevtools } from './devtools.mjs';
9
10
  export type { LiteVueDevtools, DevtoolsEvent } from './devtools.mjs';
@@ -5,5 +5,6 @@ export { nextTick } from './scheduler';
5
5
  export { watchEffect } from './effect';
6
6
  export { computed, reactive } from '@vue/reactivity';
7
7
  export type { ComputedRef, WritableComputedRef } from '@vue/reactivity';
8
+ export type { ErrorHandler, ErrorInfo, ErrorPhase } from './errors';
8
9
  export { devtools, disableDevtools } from './devtools';
9
10
  export type { LiteVueDevtools, DevtoolsEvent } from './devtools';
@@ -1,13 +1,12 @@
1
1
  import type { Context } from './context.mjs';
2
2
  /**
3
- * $id('name') — unique ids for accessibility attributes. Stable within a
4
- * scope (repeated calls with the same name return the same id, so
5
- * label/input pairs match), unique across scopes.
3
+ * $id('name') — unique ids for accessibility attributes. Stable within a scope
4
+ * so label/input pairs match, unique across scopes.
6
5
  */
7
6
  export declare const createId: () => (name?: string) => string;
8
7
  /**
9
- * $watch(source, callback) — watches a dot-path string or getter function
10
- * and calls back with (value, oldValue) on change. Tied to the owning
11
- * scope's effect list, so it stops when the scope unmounts.
8
+ * $watch(source, callback) — watches a dot-path string or getter and calls
9
+ * back with (value, oldValue). Tied to the owning scope's effects, so it stops
10
+ * when the scope unmounts.
12
11
  */
13
12
  export declare const createWatch: (ctx: Context) => (source: string | (() => any), cb: (value: any, oldValue: any) => void) => void;
@@ -1,13 +1,12 @@
1
1
  import type { Context } from './context';
2
2
  /**
3
- * $id('name') — unique ids for accessibility attributes. Stable within a
4
- * scope (repeated calls with the same name return the same id, so
5
- * label/input pairs match), unique across scopes.
3
+ * $id('name') — unique ids for accessibility attributes. Stable within a scope
4
+ * so label/input pairs match, unique across scopes.
6
5
  */
7
6
  export declare const createId: () => (name?: string) => string;
8
7
  /**
9
- * $watch(source, callback) — watches a dot-path string or getter function
10
- * and calls back with (value, oldValue) on change. Tied to the owning
11
- * scope's effect list, so it stops when the scope unmounts.
8
+ * $watch(source, callback) — watches a dot-path string or getter and calls
9
+ * back with (value, oldValue). Tied to the owning scope's effects, so it stops
10
+ * when the scope unmounts.
12
11
  */
13
12
  export declare const createWatch: (ctx: Context) => (source: string | (() => any), cb: (value: any, oldValue: any) => void) => void;
@@ -1,30 +1,23 @@
1
1
  /**
2
2
  * Per-node disposal.
3
3
  *
4
- * Effects and cleanups are owned by a Context, and a Context spans everything
5
- * between one `v-scope` and the next. That is the right boundary for
6
- * `app.unmount(el)`, which tears down whole regions, but it is the wrong one
7
- * for a node removed on its own: morph detaches nodes directly, so a node
8
- * leaves the DOM while its effects stay in an array that is still alive and
9
- * still reacting.
10
- *
11
- * This records what each node acquired while it was walked, so a removed
12
- * subtree can be disposed precisely without giving every node a Context.
4
+ * A Context spans one `v-scope` to the next — the right boundary for
5
+ * `app.unmount(el)`, too coarse for a node removed on its own. Morph detaches
6
+ * nodes directly, leaving their effects live. Tracking what each node acquired
7
+ * lets a detached subtree be disposed without a Context per node.
13
8
  */
14
9
  type Disposer = () => void;
15
10
  export declare const setOwner: (node: Node | undefined) => Node | undefined;
16
11
  /**
17
12
  * Registers a disposer against `node`, defaulting to the node being walked.
18
- *
19
- * The explicit form exists because a directive may outlive the element it was
20
- * written on: `v-if` and `v-for` both detach that element and render from an
21
- * anchor, so their own effects have to be owned by a node that stays in the
22
- * tree, not by the template they removed.
13
+ * Pass `node` explicitly for a directive that outlives its element: `v-if` and
14
+ * `v-for` detach the template and render from an anchor, so they must own to
15
+ * the anchor.
23
16
  */
24
17
  export declare const own: (dispose: Disposer, node?: Node | undefined) => void;
25
18
  /**
26
- * Disposes `node` and everything under it. Safe to call on a node that never
27
- * acquired anything, and safe to call twice — the record is dropped as it runs.
19
+ * Disposes `node` and its subtree. Safe on an unowned node, and idempotent —
20
+ * the record is dropped as it runs.
28
21
  */
29
22
  export declare const disposeSubtree: (node: Node) => void;
30
23
  export {};
@@ -1,30 +1,23 @@
1
1
  /**
2
2
  * Per-node disposal.
3
3
  *
4
- * Effects and cleanups are owned by a Context, and a Context spans everything
5
- * between one `v-scope` and the next. That is the right boundary for
6
- * `app.unmount(el)`, which tears down whole regions, but it is the wrong one
7
- * for a node removed on its own: morph detaches nodes directly, so a node
8
- * leaves the DOM while its effects stay in an array that is still alive and
9
- * still reacting.
10
- *
11
- * This records what each node acquired while it was walked, so a removed
12
- * subtree can be disposed precisely without giving every node a Context.
4
+ * A Context spans one `v-scope` to the next — the right boundary for
5
+ * `app.unmount(el)`, too coarse for a node removed on its own. Morph detaches
6
+ * nodes directly, leaving their effects live. Tracking what each node acquired
7
+ * lets a detached subtree be disposed without a Context per node.
13
8
  */
14
9
  type Disposer = () => void;
15
10
  export declare const setOwner: (node: Node | undefined) => Node | undefined;
16
11
  /**
17
12
  * Registers a disposer against `node`, defaulting to the node being walked.
18
- *
19
- * The explicit form exists because a directive may outlive the element it was
20
- * written on: `v-if` and `v-for` both detach that element and render from an
21
- * anchor, so their own effects have to be owned by a node that stays in the
22
- * tree, not by the template they removed.
13
+ * Pass `node` explicitly for a directive that outlives its element: `v-if` and
14
+ * `v-for` detach the template and render from an anchor, so they must own to
15
+ * the anchor.
23
16
  */
24
17
  export declare const own: (dispose: Disposer, node?: Node | undefined) => void;
25
18
  /**
26
- * Disposes `node` and everything under it. Safe to call on a node that never
27
- * acquired anything, and safe to call twice — the record is dropped as it runs.
19
+ * Disposes `node` and its subtree. Safe on an unowned node, and idempotent —
20
+ * the record is dropped as it runs.
28
21
  */
29
22
  export declare const disposeSubtree: (node: Node) => void;
30
23
  export {};
@@ -2,14 +2,12 @@ import type { Plugin } from '../../app.mjs';
2
2
  /**
3
3
  * Focus utilities.
4
4
  *
5
- * v-focus="expression" — focuses the element whenever the expression
6
- * becomes truthy (including on mount, making it an autofocus).
7
- * Modifiers:
8
- * - .select also select the element's text (inputs/textareas)
5
+ * v-focus="expression" — focuses the element while the expression is truthy,
6
+ * on mount included, making it an autofocus.
7
+ * - .select also select the text (inputs/textareas)
9
8
  *
10
- * v-trap="expression" — while the expression is truthy, contains Tab /
11
- * Shift+Tab focus cycling within the element (for accessible modals).
12
- * Focus moves to the first focusable child on activation and returns to
13
- * the previously focused element on release or unmount.
9
+ * v-trap="expression" — cycles Tab / Shift+Tab within the element while truthy,
10
+ * for accessible modals. Focus enters the first focusable child and returns to
11
+ * the previous element on release or unmount.
14
12
  */
15
13
  export declare const focus: Plugin;
@@ -2,14 +2,12 @@ import type { Plugin } from '../../app';
2
2
  /**
3
3
  * Focus utilities.
4
4
  *
5
- * v-focus="expression" — focuses the element whenever the expression
6
- * becomes truthy (including on mount, making it an autofocus).
7
- * Modifiers:
8
- * - .select also select the element's text (inputs/textareas)
5
+ * v-focus="expression" — focuses the element while the expression is truthy,
6
+ * on mount included, making it an autofocus.
7
+ * - .select also select the text (inputs/textareas)
9
8
  *
10
- * v-trap="expression" — while the expression is truthy, contains Tab /
11
- * Shift+Tab focus cycling within the element (for accessible modals).
12
- * Focus moves to the first focusable child on activation and returns to
13
- * the previously focused element on release or unmount.
9
+ * v-trap="expression" — cycles Tab / Shift+Tab within the element while truthy,
10
+ * for accessible modals. Focus enters the first focusable child and returns to
11
+ * the previous element on release or unmount.
14
12
  */
15
13
  export declare const focus: Plugin;
@@ -1,9 +1,8 @@
1
1
  import type { Plugin } from '../../app.mjs';
2
2
  /**
3
- * Viewport-driven behaviour — the cases CSS genuinely cannot serve: values
4
- * handed to JavaScript, structural branches, skipping expensive init on small
5
- * screens. Appearance still belongs in a stylesheet, which applies before
6
- * first paint; this runs after it.
3
+ * Viewport-driven behaviour for the cases CSS cannot serve: values handed to
4
+ * JavaScript, structural branches, skipping expensive init on small screens.
5
+ * Appearance still belongs in a stylesheet, which applies before first paint.
7
6
  */
8
7
  export type Breakpoints = Record<string, number>;
9
8
  export interface MediaOptions {
@@ -14,9 +13,9 @@ export interface MediaOptions {
14
13
  export type ResponsiveMap<T = any> = Record<string | number, T>;
15
14
  export type Device = 'mobile' | 'tablet' | 'desktop';
16
15
  /**
17
- * The scale in use until something calls `configure()`. Exported because
18
- * `configure()` replaces rather than merges: adjusting one breakpoint, or
19
- * adding one, means spreading this rather than retyping all five.
16
+ * The scale in use until `configure()` runs. Exported because `configure()`
17
+ * replaces rather than merges, so adjusting one breakpoint means spreading
18
+ * this rather than retyping all five.
20
19
  */
21
20
  export declare const defaultBreakpoints: Readonly<Breakpoints>;
22
21
  export interface Mq {
@@ -1,9 +1,8 @@
1
1
  import type { Plugin } from '../../app';
2
2
  /**
3
- * Viewport-driven behaviour — the cases CSS genuinely cannot serve: values
4
- * handed to JavaScript, structural branches, skipping expensive init on small
5
- * screens. Appearance still belongs in a stylesheet, which applies before
6
- * first paint; this runs after it.
3
+ * Viewport-driven behaviour for the cases CSS cannot serve: values handed to
4
+ * JavaScript, structural branches, skipping expensive init on small screens.
5
+ * Appearance still belongs in a stylesheet, which applies before first paint.
7
6
  */
8
7
  export type Breakpoints = Record<string, number>;
9
8
  export interface MediaOptions {
@@ -14,9 +13,9 @@ export interface MediaOptions {
14
13
  export type ResponsiveMap<T = any> = Record<string | number, T>;
15
14
  export type Device = 'mobile' | 'tablet' | 'desktop';
16
15
  /**
17
- * The scale in use until something calls `configure()`. Exported because
18
- * `configure()` replaces rather than merges: adjusting one breakpoint, or
19
- * adding one, means spreading this rather than retyping all five.
16
+ * The scale in use until `configure()` runs. Exported because `configure()`
17
+ * replaces rather than merges, so adjusting one breakpoint means spreading
18
+ * this rather than retyping all five.
20
19
  */
21
20
  export declare const defaultBreakpoints: Readonly<Breakpoints>;
22
21
  export interface Mq {
@@ -2,25 +2,37 @@ import type { Plugin } from '../../app.mjs';
2
2
  /**
3
3
  * Update a live region in place from new HTML, instead of replacing it.
4
4
  *
5
- * Replacing markup (`el.innerHTML = html`, then re-mounting) destroys every
6
- * element in the region, which means every scope, its state, and the browser
7
- * state riding on those nodes — focus, cursor position, text selection, scroll
8
- * offsets, media playback, `<details open>`. LiteVue also has no per-region
9
- * teardown, so the discarded subtree's effects stay subscribed and keep writing
10
- * to detached nodes.
11
- *
12
- * Morphing patches the differences onto the existing tree, so unchanged
13
- * elements are never touched and none of that is lost.
5
+ * Replacing markup destroys every element in the region — and with it every
6
+ * scope, its state, and the browser state riding on those nodes: focus, caret,
7
+ * selection, scroll, media playback, `<details open>`. Morphing patches only
8
+ * the differences, so unchanged elements are never touched.
14
9
  */
15
10
  export interface MorphOptions {
16
11
  /**
17
- * Identity used to match children across the update. Defaults to `id`.
12
+ * Identity used to match children across the update. Defaults to `id`,
13
+ * then `data-key`, then `data-id`.
18
14
  * Elements that match keep their DOM node (and therefore their scope);
19
15
  * unkeyed children fall back to matching by position.
20
16
  */
21
17
  key?: (el: Element) => string | null | undefined;
22
18
  /** Return true to leave a subtree completely untouched. */
23
19
  skip?: (from: Element, to: Element) => boolean;
20
+ /**
21
+ * Return true to keep an element the incoming HTML no longer contains.
22
+ * `skip` cannot express this — it is only consulted for a matched pair, so
23
+ * it never sees one the server stopped sending, which is exactly the case a
24
+ * client-only widget hits. `data-morph-preserve` does the same declaratively.
25
+ */
26
+ preserve?: (el: Element) => boolean;
27
+ /**
28
+ * Called before a node is inserted. Return `false` to leave it out.
29
+ */
30
+ beforeNodeAdded?: (node: Node) => boolean | void;
31
+ /**
32
+ * Called after a node has been removed, once its effects and listeners are
33
+ * released — so what arrives here is inert, not a live subtree.
34
+ */
35
+ afterNodeRemoved?: (node: Node) => void;
24
36
  }
25
37
  /**
26
38
  * morph(from, to) — patch `from` in place so it matches `to`, which may be an
@@ -28,7 +40,7 @@ export interface MorphOptions {
28
40
  */
29
41
  export declare const morph: (from: Element, to: Element | string, opts?: MorphOptions) => Element;
30
42
  /**
31
- * Registers `$morph` so templates can update a region from a fetch response
43
+ * Registers `$morph`, so a template can update a region from a fetch response
32
44
  * without dropping into JavaScript.
33
45
  */
34
46
  export declare const morphPlugin: Plugin;
@@ -2,25 +2,37 @@ import type { Plugin } from '../../app';
2
2
  /**
3
3
  * Update a live region in place from new HTML, instead of replacing it.
4
4
  *
5
- * Replacing markup (`el.innerHTML = html`, then re-mounting) destroys every
6
- * element in the region, which means every scope, its state, and the browser
7
- * state riding on those nodes — focus, cursor position, text selection, scroll
8
- * offsets, media playback, `<details open>`. LiteVue also has no per-region
9
- * teardown, so the discarded subtree's effects stay subscribed and keep writing
10
- * to detached nodes.
11
- *
12
- * Morphing patches the differences onto the existing tree, so unchanged
13
- * elements are never touched and none of that is lost.
5
+ * Replacing markup destroys every element in the region — and with it every
6
+ * scope, its state, and the browser state riding on those nodes: focus, caret,
7
+ * selection, scroll, media playback, `<details open>`. Morphing patches only
8
+ * the differences, so unchanged elements are never touched.
14
9
  */
15
10
  export interface MorphOptions {
16
11
  /**
17
- * Identity used to match children across the update. Defaults to `id`.
12
+ * Identity used to match children across the update. Defaults to `id`,
13
+ * then `data-key`, then `data-id`.
18
14
  * Elements that match keep their DOM node (and therefore their scope);
19
15
  * unkeyed children fall back to matching by position.
20
16
  */
21
17
  key?: (el: Element) => string | null | undefined;
22
18
  /** Return true to leave a subtree completely untouched. */
23
19
  skip?: (from: Element, to: Element) => boolean;
20
+ /**
21
+ * Return true to keep an element the incoming HTML no longer contains.
22
+ * `skip` cannot express this — it is only consulted for a matched pair, so
23
+ * it never sees one the server stopped sending, which is exactly the case a
24
+ * client-only widget hits. `data-morph-preserve` does the same declaratively.
25
+ */
26
+ preserve?: (el: Element) => boolean;
27
+ /**
28
+ * Called before a node is inserted. Return `false` to leave it out.
29
+ */
30
+ beforeNodeAdded?: (node: Node) => boolean | void;
31
+ /**
32
+ * Called after a node has been removed, once its effects and listeners are
33
+ * released — so what arrives here is inert, not a live subtree.
34
+ */
35
+ afterNodeRemoved?: (node: Node) => void;
24
36
  }
25
37
  /**
26
38
  * morph(from, to) — patch `from` in place so it matches `to`, which may be an
@@ -28,7 +40,7 @@ export interface MorphOptions {
28
40
  */
29
41
  export declare const morph: (from: Element, to: Element | string, opts?: MorphOptions) => Element;
30
42
  /**
31
- * Registers `$morph` so templates can update a region from a fetch response
43
+ * Registers `$morph`, so a template can update a region from a fetch response
32
44
  * without dropping into JavaScript.
33
45
  */
34
46
  export declare const morphPlugin: Plugin;