@mmstack/primitives 19.5.1 → 19.5.2

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/lib/stored.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { type CreateSignalOptions, type Signal, type WritableSignal } from '@angular/core';
1
+ import { Injector, type CreateSignalOptions, type Signal, type WritableSignal } from '@angular/core';
2
+ import { type PauseOption } from './concurrent/pausable';
2
3
  /**
3
4
  * Interface for storage mechanisms compatible with the `stored` signal.
4
5
  * Matches the essential parts of the `Storage` interface (`localStorage`, `sessionStorage`).
@@ -65,6 +66,18 @@ export type CreateStoredOptions<T> = CreateSignalOptions<T> & {
65
66
  * Optional validator, which is called on load of value. Store will be set to fallback if value is false
66
67
  */
67
68
  validate?: (value: T) => boolean;
69
+ /**
70
+ * Opt-in pause: gate the persistence effect on an ambient Activity boundary (`true`), a custom
71
+ * predicate, or `false` (default — no pausing). While paused the value stays live; persistence is
72
+ * skipped and flushes the latest value on resume. The inbound `storage` listener stays live.
73
+ * See {@link PauseOption}.
74
+ */
75
+ pause?: PauseOption;
76
+ /**
77
+ * Injector used when `stored` is created outside an injection context, and to resolve the ambient
78
+ * pause boundary when `pause` is `true`.
79
+ */
80
+ injector?: Injector;
68
81
  };
69
82
  /**
70
83
  * A specialized `WritableSignal` returned by the `stored()` function.
@@ -136,5 +149,5 @@ export type StoredSignal<T> = WritableSignal<T> & {
136
149
  * }
137
150
  * ```
138
151
  */
139
- export declare function stored<T>(fallback: T, { key, store: providedStore, serialize, deserialize, syncTabs, equal, onKeyChange, cleanupOldKey, validate, ...rest }: CreateStoredOptions<T>): StoredSignal<T>;
152
+ export declare function stored<T>(fallback: T, { key, store: providedStore, serialize, deserialize, syncTabs, equal, onKeyChange, cleanupOldKey, validate, pause, injector: providedInjector, ...rest }: CreateStoredOptions<T>): StoredSignal<T>;
140
153
  export {};
package/lib/tab-sync.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type OnDestroy, type WritableSignal } from '@angular/core';
1
+ import { Injector, type OnDestroy, type WritableSignal } from '@angular/core';
2
2
  import * as i0 from "@angular/core";
3
3
  export declare class MessageBus implements OnDestroy {
4
4
  private readonly channel;
@@ -22,6 +22,14 @@ type LegacySyncSignalOptions = {
22
22
  };
23
23
  export type SyncSignalOptions = {
24
24
  id: string;
25
+ /**
26
+ * Injector used when `tabSync` is called outside an injection context.
27
+ *
28
+ * NOTE: `tabSync` is intentionally NOT pausable. Pausing the outbound broadcast would let its
29
+ * mount-time echo guard swallow a value changed while hidden, so other tabs would silently miss
30
+ * it — a cross-tab consistency gap not worth the negligible saving. The channel stays live.
31
+ */
32
+ injector?: Injector;
25
33
  };
26
34
  /**
27
35
  * @example tabSync(signal('dark'), { id: 'theme' })
@@ -37,12 +37,16 @@ export type CreateThrottledOptions<T> = CreateSignalOptions<T> & {
37
37
  /**
38
38
  * A specialized `WritableSignal` whose publicly readable value updates are throttled.
39
39
  *
40
- * It provides access to the underlying, non-throttled signal via the `original` property.
40
+ * Provides access to the underlying, non-throttled signal via `original`, and a
41
+ * `flush()` that emits the current value immediately (clearing any open window) —
42
+ * useful for terminal transitions that shouldn't wait for the trailing edge.
41
43
  *
42
44
  * @template T The type of value held by the signal.
43
- * @see {DebouncedSignal} as the output type has the same structure.
44
45
  */
45
- export type ThrottledSignal<T> = DebouncedSignal<T>;
46
+ export type ThrottledSignal<T> = DebouncedSignal<T> & {
47
+ /** Emit the latest value now, bypassing the remaining throttle window. */
48
+ flush: () => void;
49
+ };
46
50
  /**
47
51
  * A convenience function that creates and throttles a new `WritableSignal` in one step.
48
52
  *
@@ -63,7 +67,7 @@ export type ThrottledSignal<T> = DebouncedSignal<T>;
63
67
  * // With a trailing-edge throttle, the final value 'c' would be set
64
68
  * // after the 500ms cooldown.
65
69
  */
66
- export declare function throttled<T>(initial: T, opt?: CreateThrottledOptions<T>): DebouncedSignal<T>;
70
+ export declare function throttled<T>(initial: T, opt?: CreateThrottledOptions<T>): ThrottledSignal<T>;
67
71
  /**
68
72
  * Wraps an existing `WritableSignal` to create a new one whose readable value is throttled.
69
73
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmstack/primitives",
3
- "version": "19.5.1",
3
+ "version": "19.5.2",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "signals",