@aevantec/litevue 0.5.5 → 0.5.6

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 (46) hide show
  1. package/README.md +3 -2
  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.iife.js +1 -1
  6. package/dist/litevue-plugins.mjs +1 -1
  7. package/dist/litevue-plugins.umd.js +1 -1
  8. package/dist/litevue.iife.js +1 -1
  9. package/dist/litevue.mjs +1 -1
  10. package/dist/litevue.umd.js +1 -1
  11. package/dist/plugins/morph.iife.js +1 -1
  12. package/dist/plugins/morph.mjs +1 -1
  13. package/dist/plugins/morph.umd.js +1 -1
  14. package/dist/types/app.d.mts +8 -18
  15. package/dist/types/app.d.ts +8 -18
  16. package/dist/types/block.d.mts +1 -2
  17. package/dist/types/block.d.ts +1 -2
  18. package/dist/types/context.d.mts +5 -8
  19. package/dist/types/context.d.ts +5 -8
  20. package/dist/types/devtools.d.mts +7 -0
  21. package/dist/types/devtools.d.ts +7 -0
  22. package/dist/types/effect.d.mts +6 -10
  23. package/dist/types/effect.d.ts +6 -10
  24. package/dist/types/magics.d.mts +5 -6
  25. package/dist/types/magics.d.ts +5 -6
  26. package/dist/types/ownership.d.mts +9 -16
  27. package/dist/types/ownership.d.ts +9 -16
  28. package/dist/types/plugins/focus/index.d.mts +6 -8
  29. package/dist/types/plugins/focus/index.d.ts +6 -8
  30. package/dist/types/plugins/media/index.d.mts +6 -7
  31. package/dist/types/plugins/media/index.d.ts +6 -7
  32. package/dist/types/plugins/morph/index.d.mts +21 -10
  33. package/dist/types/plugins/morph/index.d.ts +21 -10
  34. package/dist/types/plugins/persist/index.d.mts +12 -19
  35. package/dist/types/plugins/persist/index.d.ts +12 -19
  36. package/dist/types/plugins/resize/index.d.mts +5 -7
  37. package/dist/types/plugins/resize/index.d.ts +5 -7
  38. package/dist/types/plugins/transition/index.d.mts +7 -12
  39. package/dist/types/plugins/transition/index.d.ts +7 -12
  40. package/dist/types/store.d.mts +3 -6
  41. package/dist/types/store.d.ts +3 -6
  42. package/dist/types/utils.d.mts +3 -3
  43. package/dist/types/utils.d.ts +3 -3
  44. package/dist/types/warn.d.mts +6 -8
  45. package/dist/types/warn.d.ts +6 -8
  46. package/package.json +2 -1
@@ -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);
@@ -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,15 +2,10 @@ 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
  /**
@@ -21,6 +16,22 @@ export interface MorphOptions {
21
16
  key?: (el: Element) => string | null | undefined;
22
17
  /** Return true to leave a subtree completely untouched. */
23
18
  skip?: (from: Element, to: Element) => boolean;
19
+ /**
20
+ * Return true to keep an element the incoming HTML no longer contains.
21
+ * `skip` cannot express this — it is only consulted for a matched pair, so
22
+ * it never sees one the server stopped sending, which is exactly the case a
23
+ * client-only widget hits. `data-morph-preserve` does the same declaratively.
24
+ */
25
+ preserve?: (el: Element) => boolean;
26
+ /**
27
+ * Called before a node is inserted. Return `false` to leave it out.
28
+ */
29
+ beforeNodeAdded?: (node: Node) => boolean | void;
30
+ /**
31
+ * Called after a node has been removed, once its effects and listeners are
32
+ * released — so what arrives here is inert, not a live subtree.
33
+ */
34
+ afterNodeRemoved?: (node: Node) => void;
24
35
  }
25
36
  /**
26
37
  * morph(from, to) — patch `from` in place so it matches `to`, which may be an
@@ -28,7 +39,7 @@ export interface MorphOptions {
28
39
  */
29
40
  export declare const morph: (from: Element, to: Element | string, opts?: MorphOptions) => Element;
30
41
  /**
31
- * Registers `$morph` so templates can update a region from a fetch response
42
+ * Registers `$morph`, so a template can update a region from a fetch response
32
43
  * without dropping into JavaScript.
33
44
  */
34
45
  export declare const morphPlugin: Plugin;
@@ -2,15 +2,10 @@ 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
  /**
@@ -21,6 +16,22 @@ export interface MorphOptions {
21
16
  key?: (el: Element) => string | null | undefined;
22
17
  /** Return true to leave a subtree completely untouched. */
23
18
  skip?: (from: Element, to: Element) => boolean;
19
+ /**
20
+ * Return true to keep an element the incoming HTML no longer contains.
21
+ * `skip` cannot express this — it is only consulted for a matched pair, so
22
+ * it never sees one the server stopped sending, which is exactly the case a
23
+ * client-only widget hits. `data-morph-preserve` does the same declaratively.
24
+ */
25
+ preserve?: (el: Element) => boolean;
26
+ /**
27
+ * Called before a node is inserted. Return `false` to leave it out.
28
+ */
29
+ beforeNodeAdded?: (node: Node) => boolean | void;
30
+ /**
31
+ * Called after a node has been removed, once its effects and listeners are
32
+ * released — so what arrives here is inert, not a live subtree.
33
+ */
34
+ afterNodeRemoved?: (node: Node) => void;
24
35
  }
25
36
  /**
26
37
  * morph(from, to) — patch `from` in place so it matches `to`, which may be an
@@ -28,7 +39,7 @@ export interface MorphOptions {
28
39
  */
29
40
  export declare const morph: (from: Element, to: Element | string, opts?: MorphOptions) => Element;
30
41
  /**
31
- * Registers `$morph` so templates can update a region from a fetch response
42
+ * Registers `$morph`, so a template can update a region from a fetch response
32
43
  * without dropping into JavaScript.
33
44
  */
34
45
  export declare const morphPlugin: Plugin;
@@ -5,15 +5,12 @@ export interface PersistStorage {
5
5
  setItem(key: string, value: string): void;
6
6
  }
7
7
  /**
8
- * Register a custom storage under a name, so it can be selected by name from
9
- * anywhere — including as a directive modifier:
8
+ * Register a custom storage under a name, selectable anywhere — including as a
9
+ * directive modifier. Any object with getItem/setItem works.
10
10
  *
11
11
  * registerStorage('memory', myMemoryStorage);
12
12
  * persistStore('scratch', { storage: 'memory' });
13
13
  * <div v-persist.memory="scratch">…</div>
14
- *
15
- * Any object with getItem/setItem works — sessionStorage, an IndexedDB
16
- * shim, an in-memory map, a server-backed store.
17
14
  */
18
15
  export declare const registerStorage: (name: string, storage: PersistStorage) => void;
19
16
  /**
@@ -24,27 +21,23 @@ export declare const registerStorage: (name: string, storage: PersistStorage) =>
24
21
  */
25
22
  export declare const setDefaultStorage: (storage: PersistStorage | string) => void;
26
23
  /**
27
- * v-persist="storage-key" — syncs the element's scope to storage. Saved
28
- * values are restored on mount, and every change (including nested objects
29
- * and arrays) is written back automatically.
24
+ * v-persist="storage-key" — syncs the element's scope to storage: restored on
25
+ * mount, written back on every change, nested values included.
30
26
  *
31
- * The attribute value is used verbatim as the storage key (it is not
32
- * evaluated as an expression); it falls back to the element id.
27
+ * The attribute value is the storage key verbatim, not an expression, and
28
+ * falls back to the element id. An argument narrows which properties are
29
+ * stored; a modifier picks the storage (`local` default, `session`, or any
30
+ * name given to registerStorage()).
33
31
  *
34
- * An argument narrows what is stored to specific properties:
35
32
  * v-persist:draft="composer" — only `draft`
36
33
  * v-persist:draft,recipient="composer" — only those two
37
- *
38
- * A modifier picks the storage — `local` (default), `session`, or any name
39
- * passed to registerStorage():
40
- * v-persist.session="wizard"
41
- * v-persist:draft.session="composer"
34
+ * v-persist:draft.session="composer" — and into sessionStorage
42
35
  */
43
36
  export declare const persist: Plugin;
44
37
  /**
45
- * persistStore('cart') — the JS-side counterpart for global stores, which
46
- * have no element to hang a directive on. Restores immediately and saves on
47
- * every change; returns a function that stops persisting.
38
+ * persistStore('cart') — the JS-side counterpart for global stores, which have
39
+ * no element to hang a directive on. Restores immediately, saves on change,
40
+ * and returns a stop function.
48
41
  *
49
42
  * persistStore('cart') // the whole store
50
43
  * persistStore('cart', { keys: ['items'] }) // only these properties
@@ -5,15 +5,12 @@ export interface PersistStorage {
5
5
  setItem(key: string, value: string): void;
6
6
  }
7
7
  /**
8
- * Register a custom storage under a name, so it can be selected by name from
9
- * anywhere — including as a directive modifier:
8
+ * Register a custom storage under a name, selectable anywhere — including as a
9
+ * directive modifier. Any object with getItem/setItem works.
10
10
  *
11
11
  * registerStorage('memory', myMemoryStorage);
12
12
  * persistStore('scratch', { storage: 'memory' });
13
13
  * <div v-persist.memory="scratch">…</div>
14
- *
15
- * Any object with getItem/setItem works — sessionStorage, an IndexedDB
16
- * shim, an in-memory map, a server-backed store.
17
14
  */
18
15
  export declare const registerStorage: (name: string, storage: PersistStorage) => void;
19
16
  /**
@@ -24,27 +21,23 @@ export declare const registerStorage: (name: string, storage: PersistStorage) =>
24
21
  */
25
22
  export declare const setDefaultStorage: (storage: PersistStorage | string) => void;
26
23
  /**
27
- * v-persist="storage-key" — syncs the element's scope to storage. Saved
28
- * values are restored on mount, and every change (including nested objects
29
- * and arrays) is written back automatically.
24
+ * v-persist="storage-key" — syncs the element's scope to storage: restored on
25
+ * mount, written back on every change, nested values included.
30
26
  *
31
- * The attribute value is used verbatim as the storage key (it is not
32
- * evaluated as an expression); it falls back to the element id.
27
+ * The attribute value is the storage key verbatim, not an expression, and
28
+ * falls back to the element id. An argument narrows which properties are
29
+ * stored; a modifier picks the storage (`local` default, `session`, or any
30
+ * name given to registerStorage()).
33
31
  *
34
- * An argument narrows what is stored to specific properties:
35
32
  * v-persist:draft="composer" — only `draft`
36
33
  * v-persist:draft,recipient="composer" — only those two
37
- *
38
- * A modifier picks the storage — `local` (default), `session`, or any name
39
- * passed to registerStorage():
40
- * v-persist.session="wizard"
41
- * v-persist:draft.session="composer"
34
+ * v-persist:draft.session="composer" — and into sessionStorage
42
35
  */
43
36
  export declare const persist: Plugin;
44
37
  /**
45
- * persistStore('cart') — the JS-side counterpart for global stores, which
46
- * have no element to hang a directive on. Restores immediately and saves on
47
- * every change; returns a function that stops persisting.
38
+ * persistStore('cart') — the JS-side counterpart for global stores, which have
39
+ * no element to hang a directive on. Restores immediately, saves on change,
40
+ * and returns a stop function.
48
41
  *
49
42
  * persistStore('cart') // the whole store
50
43
  * persistStore('cart', { keys: ['items'] }) // only these properties
@@ -1,12 +1,10 @@
1
1
  import type { Plugin } from '../../app.mjs';
2
2
  /**
3
- * `v-resize="expr"` — element size, which no media query can report and which
4
- * CSS container queries cannot hand to JavaScript. The expression runs with
5
- * `$width` and `$height` in scope.
3
+ * `v-resize="expr"` — element size, which no media query reports and container
4
+ * queries cannot hand to JavaScript. The expression runs with `$width` and
5
+ * `$height` in scope.
6
6
  *
7
- * Separate from the media plugin on purpose: that one is viewport state,
8
- * readable from a script with no element involved, while this is bound to the
9
- * element it sits on. They share no code, and the shape here — one directive
10
- * wrapping one observer — is the same as `intersect`.
7
+ * Separate from the media plugin: that is viewport state, readable with no
8
+ * element involved, while this is bound to the element it sits on.
11
9
  */
12
10
  export declare const resize: Plugin;
@@ -1,12 +1,10 @@
1
1
  import type { Plugin } from '../../app';
2
2
  /**
3
- * `v-resize="expr"` — element size, which no media query can report and which
4
- * CSS container queries cannot hand to JavaScript. The expression runs with
5
- * `$width` and `$height` in scope.
3
+ * `v-resize="expr"` — element size, which no media query reports and container
4
+ * queries cannot hand to JavaScript. The expression runs with `$width` and
5
+ * `$height` in scope.
6
6
  *
7
- * Separate from the media plugin on purpose: that one is viewport state,
8
- * readable from a script with no element involved, while this is bound to the
9
- * element it sits on. They share no code, and the shape here — one directive
10
- * wrapping one observer — is the same as `intersect`.
7
+ * Separate from the media plugin: that is viewport state, readable with no
8
+ * element involved, while this is bound to the element it sits on.
11
9
  */
12
10
  export declare const resize: Plugin;