@vielzeug/ripple 1.2.3 → 2.0.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.
Files changed (157) hide show
  1. package/README.md +33 -71
  2. package/dist/_async.cjs +2 -0
  3. package/dist/_async.cjs.map +1 -0
  4. package/dist/_async.d.ts +40 -0
  5. package/dist/_async.d.ts.map +1 -0
  6. package/dist/_async.js +75 -0
  7. package/dist/_async.js.map +1 -0
  8. package/dist/_store.cjs +2 -0
  9. package/dist/_store.cjs.map +1 -0
  10. package/dist/_store.d.ts +20 -0
  11. package/dist/_store.d.ts.map +1 -0
  12. package/dist/_store.js +24 -0
  13. package/dist/_store.js.map +1 -0
  14. package/dist/_watch.cjs +2 -0
  15. package/dist/_watch.cjs.map +1 -0
  16. package/dist/_watch.d.ts +15 -0
  17. package/dist/_watch.d.ts.map +1 -0
  18. package/dist/_watch.js +18 -0
  19. package/dist/_watch.js.map +1 -0
  20. package/dist/async.cjs +1 -0
  21. package/dist/async.d.ts +3 -0
  22. package/dist/async.d.ts.map +1 -0
  23. package/dist/async.js +2 -0
  24. package/dist/errors.cjs +1 -1
  25. package/dist/errors.cjs.map +1 -1
  26. package/dist/errors.d.ts +2 -15
  27. package/dist/errors.d.ts.map +1 -1
  28. package/dist/errors.js +2 -2
  29. package/dist/errors.js.map +1 -1
  30. package/dist/index.cjs +2 -1
  31. package/dist/index.cjs.map +1 -0
  32. package/dist/index.d.ts +34 -11
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +25 -12
  35. package/dist/index.js.map +1 -0
  36. package/dist/ripple.cjs +1 -1
  37. package/dist/ripple.cjs.map +1 -1
  38. package/dist/ripple.iife.js +1 -1
  39. package/dist/ripple.iife.js.map +1 -1
  40. package/dist/ripple.js +1 -1
  41. package/dist/ripple.js.map +1 -1
  42. package/dist/runtime.cjs +2 -0
  43. package/dist/runtime.cjs.map +1 -0
  44. package/dist/runtime.d.ts +98 -0
  45. package/dist/runtime.d.ts.map +1 -0
  46. package/dist/runtime.js +340 -0
  47. package/dist/runtime.js.map +1 -0
  48. package/dist/store.cjs +1 -2
  49. package/dist/store.d.ts +2 -44
  50. package/dist/store.d.ts.map +1 -1
  51. package/dist/store.js +2 -205
  52. package/dist/types.d.ts +37 -292
  53. package/dist/types.d.ts.map +1 -1
  54. package/dist/watch.cjs +1 -0
  55. package/dist/watch.d.ts +3 -0
  56. package/dist/watch.d.ts.map +1 -0
  57. package/dist/watch.js +2 -0
  58. package/package.json +23 -16
  59. package/dist/_dev.cjs +0 -2
  60. package/dist/_dev.cjs.map +0 -1
  61. package/dist/_dev.d.ts +0 -2
  62. package/dist/_dev.d.ts.map +0 -1
  63. package/dist/_dev.js +0 -9
  64. package/dist/_dev.js.map +0 -1
  65. package/dist/_error-utils.cjs +0 -2
  66. package/dist/_error-utils.cjs.map +0 -1
  67. package/dist/_error-utils.d.ts +0 -24
  68. package/dist/_error-utils.d.ts.map +0 -1
  69. package/dist/_error-utils.js +0 -20
  70. package/dist/_error-utils.js.map +0 -1
  71. package/dist/_virtual/_rolldown/runtime.js +0 -7
  72. package/dist/async-computed.cjs +0 -2
  73. package/dist/async-computed.cjs.map +0 -1
  74. package/dist/async-computed.d.ts +0 -36
  75. package/dist/async-computed.d.ts.map +0 -1
  76. package/dist/async-computed.js +0 -58
  77. package/dist/async-computed.js.map +0 -1
  78. package/dist/computed.cjs +0 -2
  79. package/dist/computed.cjs.map +0 -1
  80. package/dist/computed.d.ts +0 -26
  81. package/dist/computed.d.ts.map +0 -1
  82. package/dist/computed.js +0 -113
  83. package/dist/computed.js.map +0 -1
  84. package/dist/devtools-hook.cjs +0 -2
  85. package/dist/devtools-hook.cjs.map +0 -1
  86. package/dist/devtools-hook.d.ts +0 -4
  87. package/dist/devtools-hook.d.ts.map +0 -1
  88. package/dist/devtools-hook.js +0 -8
  89. package/dist/devtools-hook.js.map +0 -1
  90. package/dist/devtools.d.ts +0 -50
  91. package/dist/devtools.d.ts.map +0 -1
  92. package/dist/effect.cjs +0 -2
  93. package/dist/effect.cjs.map +0 -1
  94. package/dist/effect.d.ts +0 -104
  95. package/dist/effect.d.ts.map +0 -1
  96. package/dist/effect.js +0 -173
  97. package/dist/effect.js.map +0 -1
  98. package/dist/reactive-base.cjs +0 -2
  99. package/dist/reactive-base.cjs.map +0 -1
  100. package/dist/reactive-base.d.ts +0 -60
  101. package/dist/reactive-base.d.ts.map +0 -1
  102. package/dist/reactive-base.js +0 -56
  103. package/dist/reactive-base.js.map +0 -1
  104. package/dist/scheduling.cjs +0 -2
  105. package/dist/scheduling.cjs.map +0 -1
  106. package/dist/scheduling.d.ts +0 -5
  107. package/dist/scheduling.d.ts.map +0 -1
  108. package/dist/scheduling.js +0 -57
  109. package/dist/scheduling.js.map +0 -1
  110. package/dist/signal.cjs +0 -2
  111. package/dist/signal.cjs.map +0 -1
  112. package/dist/signal.d.ts +0 -24
  113. package/dist/signal.d.ts.map +0 -1
  114. package/dist/signal.js +0 -54
  115. package/dist/signal.js.map +0 -1
  116. package/dist/src/devtools.cjs +0 -2
  117. package/dist/src/devtools.cjs.map +0 -1
  118. package/dist/src/devtools.js +0 -36
  119. package/dist/src/devtools.js.map +0 -1
  120. package/dist/src/ssr/index.cjs +0 -2
  121. package/dist/src/ssr/index.cjs.map +0 -1
  122. package/dist/src/ssr/index.js +0 -38
  123. package/dist/src/ssr/index.js.map +0 -1
  124. package/dist/ssr/index.d.ts +0 -56
  125. package/dist/ssr/index.d.ts.map +0 -1
  126. package/dist/store-history.cjs +0 -2
  127. package/dist/store-history.cjs.map +0 -1
  128. package/dist/store-history.d.ts +0 -42
  129. package/dist/store-history.d.ts.map +0 -1
  130. package/dist/store-history.js +0 -60
  131. package/dist/store-history.js.map +0 -1
  132. package/dist/store.cjs.map +0 -1
  133. package/dist/store.js.map +0 -1
  134. package/dist/subscription.cjs +0 -2
  135. package/dist/subscription.cjs.map +0 -1
  136. package/dist/subscription.d.ts +0 -22
  137. package/dist/subscription.d.ts.map +0 -1
  138. package/dist/subscription.js +0 -47
  139. package/dist/subscription.js.map +0 -1
  140. package/dist/symbols.cjs +0 -2
  141. package/dist/symbols.cjs.map +0 -1
  142. package/dist/symbols.d.ts +0 -6
  143. package/dist/symbols.d.ts.map +0 -1
  144. package/dist/symbols.js +0 -6
  145. package/dist/symbols.js.map +0 -1
  146. package/dist/tracking.cjs +0 -2
  147. package/dist/tracking.cjs.map +0 -1
  148. package/dist/tracking.d.ts +0 -82
  149. package/dist/tracking.d.ts.map +0 -1
  150. package/dist/tracking.js +0 -76
  151. package/dist/tracking.js.map +0 -1
  152. package/dist/utilities.cjs +0 -2
  153. package/dist/utilities.cjs.map +0 -1
  154. package/dist/utilities.d.ts +0 -56
  155. package/dist/utilities.d.ts.map +0 -1
  156. package/dist/utilities.js +0 -25
  157. package/dist/utilities.js.map +0 -1
package/dist/types.d.ts CHANGED
@@ -1,315 +1,60 @@
1
- export type CleanupFn = () => void;
2
- export type EffectCallback = () => CleanupFn | void;
3
- export type AsyncEffectCallback = (signal: AbortSignal, owner: Scope) => Promise<CleanupFn | void>;
4
- export type EqualityFn<T> = (a: T, b: T) => boolean;
5
- /**
6
- * Controls when an effect re-runs after a dependency changes.
7
- * - `'sync'` (default): runs immediately in the same flush.
8
- * - `'microtask'`: deferred to the next microtask.
9
- */
10
- export type EffectScheduler = 'microtask' | 'sync';
11
- /** Options accepted by `computed()`. */
12
- export type ComputedOptions<T> = {
13
- equals?: EqualityFn<T>;
14
- name?: string;
15
- };
16
- /** Options accepted by `signal()`. */
1
+ export type Cleanup = () => void;
2
+ export type Equality<T> = (previous: T, next: T) => boolean;
3
+ export type Unsubscribe = () => void;
17
4
  export type SignalOptions<T> = {
18
- equals?: EqualityFn<T>;
19
- name?: string;
20
- };
21
- export type EffectOptions = {
5
+ equals?: Equality<T>;
22
6
  name?: string;
23
- scheduler?: EffectScheduler;
24
7
  };
25
- export type EffectAsyncOptions = {
26
- /** Name used to identify this async effect in DevTools. */
27
- name?: string;
28
- onError?: (error: unknown) => void;
29
- };
30
- export interface Subscription {
31
- dispose(): void;
32
- /** `true` after `dispose()` has been called. */
33
- readonly disposed: boolean;
34
- [Symbol.dispose](): void;
35
- }
36
- /**
37
- * A snapshot of one reactive dependency recorded by an effect.
38
- * Returned by `EffectHandle.getDependencies()`.
39
- */
40
- export type DepInfo = {
41
- readonly kind: 'computed' | 'signal';
42
- readonly name?: string;
43
- };
44
- /**
45
- * Extended handle returned by `effect()`.
46
- * Extends `Subscription` with `getDependencies()` for reactive graph introspection.
47
- *
48
- * @example
49
- * ```ts
50
- * const handle = effect(() => { console.log(count.value); });
51
- * console.log(handle.getDependencies()); // [{ name: 'count' }]
52
- * handle.dispose();
53
- * ```
54
- */
55
- export interface EffectHandle extends Subscription {
56
- /**
57
- * Returns the reactive sources the effect is currently subscribed to.
58
- * Reflects the deps collected during the last completed run.
59
- * Returns an empty array after `dispose()`.
60
- */
61
- getDependencies(): ReadonlyArray<DepInfo>;
62
- }
63
- /**
64
- * Extended async subscription returned by `effectAsync()`.
65
- * Adds `run()` for structured concurrency — await the current async run before proceeding.
66
- */
67
- export interface AsyncSubscription extends Subscription {
68
- /** Awaits the current async run without disposing the effect. Resolves immediately if idle. */
69
- run(): Promise<void>;
70
- /** ES2024 `await using` compatible async disposal. Stops the effect and awaits full teardown. */
71
- [Symbol.asyncDispose](): Promise<void>;
72
- }
73
- export type WatchOptions<T> = {
74
- equals?: EqualityFn<T>;
75
- immediate?: boolean;
8
+ export type ComputedOptions<T> = {
9
+ equals?: Equality<T>;
76
10
  name?: string;
77
- /** Auto-dispose the watch after the first callback invocation. */
78
- once?: boolean;
79
11
  };
80
- export type ResourceOptions<T> = {
81
- /** Value exposed via `data` while the first run is loading. */
82
- initialValue?: T;
83
- /** Debug name for the internal effect and state signal. */
12
+ export type EffectOptions = {
84
13
  name?: string;
14
+ scheduler?: 'microtask' | 'sync';
85
15
  };
86
- /**
87
- * Discriminated-union state emitted by a `resource()` signal.
88
- *
89
- * - `'loading'` — async factory is in-flight. `data` carries the last fulfilled value (if any).
90
- * - `'ready'` — factory resolved. `data` is the fulfilled value.
91
- * - `'error'` — factory rejected. `error` holds the thrown value. `data` carries the last fulfilled value (if any).
92
- *
93
- * @example
94
- * ```ts
95
- * const user = resource(async () => fetchUser(id.value));
96
- *
97
- * effect(() => {
98
- * const s = user.value;
99
- * if (s.status === 'loading') return showSpinner();
100
- * if (s.status === 'error') return showError(s.error);
101
- * renderUser(s.data);
102
- * });
103
- * ```
104
- */
105
- export type ResourceState<T> = {
106
- readonly data?: T;
107
- readonly status: 'loading';
108
- } | {
109
- readonly data: T;
110
- readonly status: 'ready';
111
- } | {
112
- readonly data?: T;
113
- readonly error: unknown;
114
- readonly status: 'error';
115
- };
116
- /**
117
- * Disposable handle returned by `resource()`. Extends `Computed<ResourceState<T>>`
118
- * with `refresh()` for manually forcing a re-fetch.
119
- */
120
- export interface Resource<T> extends Computed<ResourceState<T>> {
121
- /**
122
- * Forces the factory to re-run immediately, aborting any in-flight run —
123
- * even if no tracked dependency changed. No-op after `dispose()`.
124
- */
125
- refresh(): void;
126
- }
127
- /**
128
- * A single snapshot entry in `StoreWithHistory`.
129
- * Carries the frozen state and an optional label for annotated checkpoints.
130
- */
131
- export type HistoryEntry<T> = {
132
- readonly label?: string;
133
- readonly state: Readonly<T>;
134
- };
135
- /**
136
- * The minimal read-only contract for consuming any reactive value.
137
- * Effects and computed functions read `.value` (tracked) or `peek()` (untracked).
138
- * Use `subscribe()` for external imperative listeners.
139
- */
140
16
  export interface Readable<T> {
141
- /** `true` after the underlying node has been disposed. */
142
- readonly disposed: boolean;
143
- /** The debug name assigned at creation time, or `undefined` if unnamed. */
144
17
  readonly name?: string;
145
18
  peek(): T;
146
- /**
147
- * Subscribes a listener to value change notifications.
148
- * Implementations MUST NOT invoke `listener` synchronously during registration.
149
- */
150
- subscribe(listener: () => void): Subscription;
19
+ subscribe(listener: () => void): Unsubscribe;
151
20
  readonly value: T;
152
21
  }
153
- /**
154
- * A disposable derived value. The holder is responsible for calling `dispose()`.
155
- * Returned by `computed()`, `readonly()`, and `resource()`.
156
- */
157
- export interface Computed<T> extends Readable<T> {
158
- dispose(): void;
159
- [Symbol.dispose](): void;
160
- }
161
- /**
162
- * A writable owned signal. The holder can both read and write `.value`,
163
- * and is responsible for calling `dispose()` when done.
164
- */
165
- export interface Signal<T> extends Computed<T> {
22
+ export interface Signal<T> extends Readable<T> {
166
23
  value: T;
167
24
  }
168
- /**
169
- * Extracts the value type at a dot-separated path `P` within object type `T`.
170
- *
171
- * @example
172
- * type City = PathValue<{ user: { address: { city: string } } }, 'user.address.city'>
173
- * // → string
174
- */
175
- export type PathValue<T, P extends string> = P extends keyof T ? T[P] : P extends `${infer K}.${infer Rest}` ? K extends keyof T ? PathValue<T[K], Rest> : never : never;
176
- /**
177
- * A fine-grained reactive store for objects.
178
- * Extends `Computed<Readonly<T>>` — `store.value` provides a tracked whole-store read.
179
- *
180
- * `lens()` is the primary reactive read/write API — it returns a `Signal` for
181
- * a specific property or nested path and registers fine-grained dependencies.
182
- * `peek()` returns a non-reactive snapshot (useful for serialization).
183
- * `subscribe()` fires on any mutation (useful for adapters like `storeWithHistory`).
184
- */
185
- export interface Store<T extends object> extends Computed<Readonly<T>> {
186
- /**
187
- * Returns a writable `Signal` scoped to a single property or nested path.
188
- * Reads register a fine-grained dependency on that property's signal —
189
- * unrelated patches do NOT re-run effects watching this lens.
190
- * Lenses are cached — `store.lens('x') === store.lens('x')`.
191
- */
192
- lens<P extends string>(path: P): Signal<PathValue<T, P>>;
193
- /** Atomic partial update — only changed keys notify their subscribers. */
194
- patch(partial: Partial<T>): void;
195
- /**
196
- * Returns a non-reactive snapshot of the current state.
197
- * Use for serialization or one-off reads outside reactive contexts.
198
- */
199
- peek(): Readonly<T>;
200
- /**
201
- * Replaces the entire store state by passing the current state to `fn` and
202
- * applying the returned value. Only changed properties trigger downstream effects.
203
- */
204
- replace(fn: (state: Readonly<T>) => T): void;
205
- /** Resets the store to its initial state. */
206
- reset(): void;
207
- /**
208
- * Subscribes to any store mutation (patch / replace / reset / lens write).
209
- * Used by external adapters — prefer `store.lens()` for reactive reads.
210
- */
211
- subscribe(listener: () => void): Subscription;
212
- }
213
- /**
214
- * A lifecycle scope that collects cleanup functions and runs them on dispose.
215
- * Effects and computeds created inside `scope.run()` auto-register their disposal.
216
- */
217
- export interface Scope {
218
- /**
219
- * Registers `fn` to run when this scope is disposed.
220
- * Throws `RippleDisposedScopeError` if called on an already-disposed scope.
221
- * Use this from within an effect body to explicitly direct a cleanup into the scope
222
- * rather than the effect's own cleanup queue.
223
- */
224
- add(fn: CleanupFn): void;
225
- /** `AbortSignal` that is aborted when `dispose()` is called. Use to tie external lifetimes to this scope. */
226
- readonly disposalSignal: AbortSignal;
25
+ export interface Disposable {
227
26
  dispose(): void;
228
- /** `true` after `dispose()` has been called. */
229
27
  readonly disposed: boolean;
230
- /**
231
- * Runs `fn` inside this scope's cleanup context.
232
- * `onCleanup()` calls and resource auto-disposals inside `fn` are registered
233
- * to this scope when there is no enclosing effect or computed context.
234
- * Reactive reads inside `fn` are tracked normally against any enclosing effect.
235
- * Throws `RippleDisposedScopeError` if the scope has already been disposed.
236
- */
237
- run<T>(fn: () => T): T;
28
+ readonly disposalSignal: AbortSignal;
238
29
  [Symbol.dispose](): void;
239
30
  }
240
- /**
241
- * An undo/redo adapter wrapping a `Store<T>`.
242
- * Extends `Store<T>` directly — all store mutations (`patch`, `replace`, `reset`, `lens`)
243
- * work on the history adapter without `.store` indirection.
244
- *
245
- * History is **explicit** — call `push()` or `pushNamed()` after any mutation you want undoable.
246
- *
247
- * @example
248
- * ```ts
249
- * const h = storeWithHistory({ count: 0 });
250
- *
251
- * h.patch({ count: 1 });
252
- * h.push(); // save a checkpoint
253
- * h.undo(); // restore to { count: 0 }
254
- * h.redo(); // restore to { count: 1 }
255
- * ```
256
- */
257
- export interface StoreWithHistory<T extends object> extends Store<T> {
258
- /** `true` when there is at least one snapshot ahead to redo. Reactive — reads inside effects re-run on change. */
259
- readonly canRedo: boolean;
260
- /** `true` when there is at least one snapshot to undo to. Reactive — reads inside effects re-run on change. */
261
- readonly canUndo: boolean;
262
- /** Returns the history entry at the given index (0 = oldest). */
263
- historyAt(index: number): HistoryEntry<T> | undefined;
264
- /** Number of snapshots currently in history. */
265
- readonly historyLength: number;
266
- /** Saves the current store state as an explicit undo checkpoint. */
267
- push(): void;
268
- /**
269
- * Saves the current store state as an annotated checkpoint.
270
- * Use to mark significant transitions (e.g. `'import'`, `'reset'`) so time-travel
271
- * debuggers can distinguish user-initiated from programmatic mutations.
272
- */
273
- pushNamed(label: string): void;
274
- /** Move forward one snapshot. No-op when at the most recent checkpoint. */
275
- redo(): void;
276
- /** The underlying store — kept as an escape hatch for adapters that need direct store access. */
277
- readonly store: Store<T>;
278
- /** Move back one snapshot. No-op when at the oldest checkpoint. */
279
- undo(): void;
31
+ export type EffectHandle = Disposable;
32
+ export interface Scope extends Disposable {
33
+ run<T>(fn: () => T): T;
280
34
  }
281
- export type Subscriber = () => void;
282
- /** Event emitted when a signal's value changes. */
283
- export type WriteEvent = {
284
- name: string | undefined;
285
- newValue: unknown;
286
- oldValue: unknown;
287
- };
288
- /** Event emitted when a computed recomputes, or when an effect runs. */
289
- export type NamedEvent = {
290
- name: string | undefined;
291
- };
292
- /** Event emitted when a signal, computed, effect, or store is disposed. */
293
- export type DisposeEvent = {
294
- kind: 'computed' | 'effect' | 'signal' | 'store';
295
- name: string | undefined;
35
+ export type ReactiveEvent = {
36
+ readonly kind: 'compute';
37
+ readonly name?: string;
38
+ } | {
39
+ readonly kind: 'effect';
40
+ readonly name?: string;
41
+ } | {
42
+ readonly kind: 'write';
43
+ readonly name?: string;
44
+ readonly next: unknown;
45
+ readonly previous: unknown;
46
+ } | {
47
+ readonly kind: 'dispose';
48
+ readonly name?: string;
49
+ readonly node: 'effect' | 'scope';
296
50
  };
297
- /** Event emitted when a store-level mutation occurs. `path` is populated for `kind: 'lens'`. */
298
- export type MutateEvent = {
299
- kind: 'patch' | 'replace' | 'reset' | 'lens';
300
- name: string | undefined;
301
- path?: string;
51
+ export type ReactiveObserver = (event: ReactiveEvent) => void;
52
+ export type ReactiveErrorContext = {
53
+ readonly kind: 'cleanup' | 'effect' | 'listener' | 'observer';
54
+ readonly name?: string;
302
55
  };
303
- export type RippleDevToolsHook = {
304
- /** Called when a computed signal recomputes. */
305
- compute?(event: NamedEvent): void;
306
- /** Called when a signal, computed, or effect is disposed. */
307
- dispose?(event: DisposeEvent): void;
308
- /** Called when a store-level mutation (patch/replace/reset/lens) occurs. */
309
- mutate?(event: MutateEvent): void;
310
- /** Called when an effect starts running. */
311
- run?(event: NamedEvent): void;
312
- /** Called when a signal's value changes. */
313
- write?(event: WriteEvent): void;
56
+ export type RippleOptions = {
57
+ observer?: ReactiveObserver;
58
+ onError?: (error: unknown, context: ReactiveErrorContext) => void;
314
59
  };
315
60
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC;AACnC,MAAM,MAAM,cAAc,GAAG,MAAM,SAAS,GAAG,IAAI,CAAC;AACpD,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;AACnG,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;AAEpD;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,MAAM,CAAC;AAEnD,wCAAwC;AACxC,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC/B,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,C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Options } from './_watch';
2
+ export { watch } from './index';
3
+ //# sourceMappingURL=watch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
package/dist/watch.js ADDED
@@ -0,0 +1,2 @@
1
+ import { watch as e } from "./index.js";
2
+ export { e as watch };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@vielzeug/ripple",
3
- "version": "1.2.3",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
- "description": "Fine-grained reactive state — signals, computed values, effects, stores, and reactive scopes",
8
+ "description": "Fine-grained reactive runtime — signals, derived values, effects, scopes, and optional state tools",
9
9
  "main": "./dist/index.cjs",
10
10
  "module": "./dist/index.js",
11
11
  "types": "dist/index.d.ts",
@@ -16,17 +16,23 @@
16
16
  "import": "./dist/index.js",
17
17
  "require": "./dist/index.cjs"
18
18
  },
19
- "./devtools": {
20
- "source": "./src/devtools.ts",
21
- "types": "./dist/devtools.d.ts",
22
- "import": "./dist/devtools.js",
23
- "require": "./dist/devtools.cjs"
19
+ "./async": {
20
+ "source": "./src/async.ts",
21
+ "types": "./dist/async.d.ts",
22
+ "import": "./dist/async.js",
23
+ "require": "./dist/async.cjs"
24
24
  },
25
- "./ssr": {
26
- "source": "./src/ssr/index.ts",
27
- "types": "./dist/ssr/index.d.ts",
28
- "import": "./dist/ssr/index.js",
29
- "require": "./dist/ssr/index.cjs"
25
+ "./store": {
26
+ "source": "./src/store.ts",
27
+ "types": "./dist/store.d.ts",
28
+ "import": "./dist/store.js",
29
+ "require": "./dist/store.cjs"
30
+ },
31
+ "./watch": {
32
+ "source": "./src/watch.ts",
33
+ "types": "./dist/watch.d.ts",
34
+ "import": "./dist/watch.js",
35
+ "require": "./dist/watch.cjs"
30
36
  }
31
37
  },
32
38
  "scripts": {
@@ -34,10 +40,11 @@
34
40
  "build:types": "tsc -p tsconfig.declarations.json",
35
41
  "fix": "eslint --fix src",
36
42
  "lint": "eslint src",
37
- "prepublishOnly": "pnpm run build",
43
+ "prepublishOnly": "pnpm run build && pnpm run verify:exports",
38
44
  "preview": "vite preview",
39
45
  "test": "vitest",
40
- "build:bundle": "vite build --config vite.bundle.config.ts"
46
+ "build:bundle": "vite build --config vite.bundle.config.ts",
47
+ "verify:exports": "node ./scripts/verify-exports.mjs"
41
48
  },
42
49
  "publishConfig": {
43
50
  "access": "public",
@@ -47,9 +54,9 @@
47
54
  "node": ">=22"
48
55
  },
49
56
  "devDependencies": {
50
- "@types/node": "^26.1.0",
57
+ "@types/node": "^26.1.2",
51
58
  "typescript": "^6.0.3",
52
- "vite": "^8.1.3",
59
+ "vite": "^8.2.0",
53
60
  "vitest": "^4.1.10"
54
61
  }
55
62
  }
package/dist/_dev.cjs DELETED
@@ -1,2 +0,0 @@
1
- var e=!globalThis.__RIPPLE_PROD__;function t(t){e&&console.warn(`[@vielzeug/ripple] ${t}`)}exports.warn=t;
2
- //# sourceMappingURL=_dev.cjs.map
package/dist/_dev.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["const isDev = !(globalThis as { __RIPPLE_PROD__?: boolean }).__RIPPLE_PROD__;\n\n/** @internal @security Messages may include user-supplied data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/ripple] ${msg}`);\n}\n"],"mappings":"AAAA,IAAM,EAAQ,CAAE,WAA6C,gBAG7D,SAAgB,EAAK,EAAmB,CAClC,GAAO,QAAQ,KAAK,sBAAsB,GAAK,CACrD"}
package/dist/_dev.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=_dev.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_dev.d.ts","sourceRoot":"","sources":["../src/_dev.ts"],"names":[],"mappings":""}
package/dist/_dev.js DELETED
@@ -1,9 +0,0 @@
1
- //#region src/_dev.ts
2
- var e = !globalThis.__RIPPLE_PROD__;
3
- function t(t) {
4
- e && console.warn(`[@vielzeug/ripple] ${t}`);
5
- }
6
- //#endregion
7
- export { t as warn };
8
-
9
- //# sourceMappingURL=_dev.js.map
package/dist/_dev.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["const isDev = !(globalThis as { __RIPPLE_PROD__?: boolean }).__RIPPLE_PROD__;\n\n/** @internal @security Messages may include user-supplied data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/ripple] ${msg}`);\n}\n"],"mappings":";AAAA,IAAM,IAAQ,CAAE,WAA6C;AAG7D,SAAgB,EAAK,GAAmB;CACtC,AAAI,KAAO,QAAQ,KAAK,sBAAsB,GAAK;AACrD"}
@@ -1,2 +0,0 @@
1
- var e=e=>e instanceof Error?e:Error(`Non-Error thrown: ${String(e)}`),t=t=>{let n=[];for(let r of t)try{r()}catch(t){n.push(e(t))}return n},n=(e,n)=>{let r=t(e);if(r.length===1)throw r[0];if(r.length>0)throw AggregateError(r,n)},r=(t,n,r)=>{throw n.length===0?t:AggregateError([e(t),...n],r,{cause:e(t)})};exports.collectErrors=t,exports.ensureError=e,exports.rethrowWith=r,exports.runAll=n;
2
- //# sourceMappingURL=_error-utils.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_error-utils.cjs","names":[],"sources":["../src/_error-utils.ts"],"sourcesContent":["import type { CleanupFn } from './types';\n\n/**\n * Coerces any thrown value to an `Error`.\n * Non-Error throws (strings, numbers, etc.) are wrapped in a plain `Error`\n * with a descriptive message — they are NOT mis-branded as `RippleError`.\n */\nexport const ensureError = (error: unknown): Error =>\n error instanceof Error ? error : new Error(`Non-Error thrown: ${String(error)}`);\n\n/**\n * Runs each fn in `fns`, collecting any thrown errors. Does NOT re-throw.\n */\nexport const collectErrors = (fns: Iterable<CleanupFn>): Error[] => {\n const errors: Error[] = [];\n\n for (const fn of fns) {\n try {\n fn();\n } catch (e) {\n errors.push(ensureError(e));\n }\n }\n\n return errors;\n};\n\n/**\n * Runs all `fns`, collecting errors.\n * - Single error: re-throws the original error directly (preserves type + stack).\n * - Multiple errors: wraps in AggregateError with the given context label.\n */\nexport const runAll = (fns: Iterable<CleanupFn>, context: string): void => {\n const errors = collectErrors(fns);\n\n if (errors.length === 1) throw errors[0]!;\n\n if (errors.length > 0) {\n throw new AggregateError(errors, context);\n }\n};\n\n/**\n * Re-throws `primary`, augmented with any extra errors as an AggregateError.\n * If `extras` is empty, throws `primary` directly (preserves original type + stack).\n * Otherwise, `primary` is set as the `.cause` so callers can identify the root failure.\n */\nexport const rethrowWith = (primary: unknown, extras: Error[], context: string): never => {\n if (extras.length === 0) throw primary;\n\n throw new AggregateError([ensureError(primary), ...extras], context, {\n cause: ensureError(primary),\n });\n};\n"],"mappings":"AAOA,IAAa,EAAe,GAC1B,aAAiB,MAAQ,EAAY,MAAM,qBAAqB,OAAO,CAAK,GAAG,EAKpE,EAAiB,GAAsC,CAClE,IAAM,EAAkB,CAAC,EAEzB,IAAK,IAAM,KAAM,EACf,GAAI,CACF,EAAG,CACL,OAAS,EAAG,CACV,EAAO,KAAK,EAAY,CAAC,CAAC,CAC5B,CAGF,OAAO,CACT,EAOa,GAAU,EAA0B,IAA0B,CACzE,IAAM,EAAS,EAAc,CAAG,EAEhC,GAAI,EAAO,SAAW,EAAG,MAAM,EAAO,GAEtC,GAAI,EAAO,OAAS,EAClB,MAAU,eAAe,EAAQ,CAAO,CAE5C,EAOa,GAAe,EAAkB,EAAiB,IAA2B,CAGxF,MAFI,EAAO,SAAW,EAAS,EAErB,eAAe,CAAC,EAAY,CAAO,EAAG,GAAG,CAAM,EAAG,EAAS,CACnE,MAAO,EAAY,CAAO,CAC5B,CAAC,CACH"}
@@ -1,24 +0,0 @@
1
- import type { CleanupFn } from './types';
2
- /**
3
- * Coerces any thrown value to an `Error`.
4
- * Non-Error throws (strings, numbers, etc.) are wrapped in a plain `Error`
5
- * with a descriptive message — they are NOT mis-branded as `RippleError`.
6
- */
7
- export declare const ensureError: (error: unknown) => Error;
8
- /**
9
- * Runs each fn in `fns`, collecting any thrown errors. Does NOT re-throw.
10
- */
11
- export declare const collectErrors: (fns: Iterable<CleanupFn>) => Error[];
12
- /**
13
- * Runs all `fns`, collecting errors.
14
- * - Single error: re-throws the original error directly (preserves type + stack).
15
- * - Multiple errors: wraps in AggregateError with the given context label.
16
- */
17
- export declare const runAll: (fns: Iterable<CleanupFn>, context: string) => void;
18
- /**
19
- * Re-throws `primary`, augmented with any extra errors as an AggregateError.
20
- * If `extras` is empty, throws `primary` directly (preserves original type + stack).
21
- * Otherwise, `primary` is set as the `.cause` so callers can identify the root failure.
22
- */
23
- export declare const rethrowWith: (primary: unknown, extras: Error[], context: string) => never;
24
- //# sourceMappingURL=_error-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_error-utils.d.ts","sourceRoot":"","sources":["../src/_error-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,KACqC,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,QAAQ,CAAC,SAAS,CAAC,KAAG,KAAK,EAY7D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,KAAG,IAQlE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,OAAO,EAAE,QAAQ,KAAK,EAAE,EAAE,SAAS,MAAM,KAAG,KAMhF,CAAC"}
@@ -1,20 +0,0 @@
1
- //#region src/_error-utils.ts
2
- var e = (e) => e instanceof Error ? e : /* @__PURE__ */ Error(`Non-Error thrown: ${String(e)}`), t = (t) => {
3
- let n = [];
4
- for (let r of t) try {
5
- r();
6
- } catch (t) {
7
- n.push(e(t));
8
- }
9
- return n;
10
- }, n = (e, n) => {
11
- let r = t(e);
12
- if (r.length === 1) throw r[0];
13
- if (r.length > 0) throw AggregateError(r, n);
14
- }, r = (t, n, r) => {
15
- throw n.length === 0 ? t : AggregateError([e(t), ...n], r, { cause: e(t) });
16
- };
17
- //#endregion
18
- export { t as collectErrors, e as ensureError, r as rethrowWith, n as runAll };
19
-
20
- //# sourceMappingURL=_error-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_error-utils.js","names":[],"sources":["../src/_error-utils.ts"],"sourcesContent":["import type { CleanupFn } from './types';\n\n/**\n * Coerces any thrown value to an `Error`.\n * Non-Error throws (strings, numbers, etc.) are wrapped in a plain `Error`\n * with a descriptive message — they are NOT mis-branded as `RippleError`.\n */\nexport const ensureError = (error: unknown): Error =>\n error instanceof Error ? error : new Error(`Non-Error thrown: ${String(error)}`);\n\n/**\n * Runs each fn in `fns`, collecting any thrown errors. Does NOT re-throw.\n */\nexport const collectErrors = (fns: Iterable<CleanupFn>): Error[] => {\n const errors: Error[] = [];\n\n for (const fn of fns) {\n try {\n fn();\n } catch (e) {\n errors.push(ensureError(e));\n }\n }\n\n return errors;\n};\n\n/**\n * Runs all `fns`, collecting errors.\n * - Single error: re-throws the original error directly (preserves type + stack).\n * - Multiple errors: wraps in AggregateError with the given context label.\n */\nexport const runAll = (fns: Iterable<CleanupFn>, context: string): void => {\n const errors = collectErrors(fns);\n\n if (errors.length === 1) throw errors[0]!;\n\n if (errors.length > 0) {\n throw new AggregateError(errors, context);\n }\n};\n\n/**\n * Re-throws `primary`, augmented with any extra errors as an AggregateError.\n * If `extras` is empty, throws `primary` directly (preserves original type + stack).\n * Otherwise, `primary` is set as the `.cause` so callers can identify the root failure.\n */\nexport const rethrowWith = (primary: unknown, extras: Error[], context: string): never => {\n if (extras.length === 0) throw primary;\n\n throw new AggregateError([ensureError(primary), ...extras], context, {\n cause: ensureError(primary),\n });\n};\n"],"mappings":";AAOA,IAAa,KAAe,MAC1B,aAAiB,QAAQ,IAAQ,gBAAI,MAAM,qBAAqB,OAAO,CAAK,GAAG,GAKpE,KAAiB,MAAsC;CAClE,IAAM,IAAkB,CAAC;CAEzB,KAAK,IAAM,KAAM,GACf,IAAI;EACF,EAAG;CACL,SAAS,GAAG;EACV,EAAO,KAAK,EAAY,CAAC,CAAC;CAC5B;CAGF,OAAO;AACT,GAOa,KAAU,GAA0B,MAA0B;CACzE,IAAM,IAAS,EAAc,CAAG;CAEhC,IAAI,EAAO,WAAW,GAAG,MAAM,EAAO;CAEtC,IAAI,EAAO,SAAS,GAClB,MAAU,eAAe,GAAQ,CAAO;AAE5C,GAOa,KAAe,GAAkB,GAAiB,MAA2B;CAGxF,MAFI,EAAO,WAAW,IAAS,IAErB,eAAe,CAAC,EAAY,CAAO,GAAG,GAAG,CAAM,GAAG,GAAS,EACnE,OAAO,EAAY,CAAO,EAC5B,CAAC;AACH"}
@@ -1,7 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var e = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
3
- if (typeof require < "u") return require.apply(this, arguments);
4
- throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
5
- });
6
- //#endregion
7
- export { e as __require };
@@ -1,2 +0,0 @@
1
- const e=require("./tracking.cjs"),t=require("./symbols.cjs"),n=require("./effect.cjs"),r=require("./signal.cjs");var i=(i,a)=>{let o=a?.name,s=r.signal({data:a?.initialValue,status:`loading`},o?{name:o}:void 0),c=r.signal(0),l=null,u=!1,d=n.effect(()=>{c.value,l?.abort(),l=new AbortController;let{signal:e}=l,t=s.peek(),n=`data`in t?t.data:void 0;s.value={data:n,status:`loading`},(async()=>{try{let t=await i(e);!e.aborted&&!u&&(s.value={data:t,status:`ready`})}catch(t){!e.aborted&&!u&&(s.value={data:n,error:t,status:`error`})}})()},o?{name:o}:void 0),f=()=>{u||(c.value=c.peek()+1)},p=()=>{u||(u=!0,l?.abort(),d.dispose(),s.dispose(),c.dispose())};return e.autoRegisterDisposal(p),{dispose:p,get disposed(){return u},[t.IS_COMPUTED]:!0,[t.IS_SIGNAL]:!0,get name(){return s.name},peek:()=>s.peek(),refresh:f,subscribe:e=>s.subscribe(e),[Symbol.dispose]:p,get value(){return s.value}}};exports.resource=i;
2
- //# sourceMappingURL=async-computed.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-computed.cjs","names":[],"sources":["../src/async-computed.ts"],"sourcesContent":["import type { Resource, ResourceOptions, ResourceState } from './types';\n\nimport { effect } from './effect';\nimport { signal } from './signal';\nimport { IS_COMPUTED, IS_SIGNAL } from './symbols';\nimport { autoRegisterDisposal } from './tracking';\n\n/**\n * Creates a reactive async resource that emits a `ResourceState<T>` discriminated union.\n *\n * Dependencies are tracked synchronously in the factory (before the first `await`).\n * The factory receives an `AbortSignal` that fires when dependencies change or\n * the resource is disposed, cancelling any in-flight work.\n *\n * If `resource()` is created inside an active `effect()` or `scope.run()` context,\n * it is automatically registered for cleanup and disposed with that context —\n * matching `computed()`'s auto-disposal behavior.\n *\n * Call `refresh()` to force the factory to re-run immediately, even if no tracked\n * dependency changed — useful for manual \"retry\"/\"refetch\" actions.\n *\n * @example\n * ```ts\n * const userId = signal('u1');\n * const user = resource(async (signal) => {\n * const id = userId.value; // tracked dep — re-runs when userId changes\n * return fetchUser(id, { signal });\n * });\n *\n * effect(() => {\n * const s = user.value;\n * if (s.status === 'loading') return showSpinner();\n * if (s.status === 'error') return showError(s.error);\n * renderUser(s.data);\n * });\n *\n * user.refresh(); // force a re-fetch without changing userId\n * user.dispose();\n * ```\n */\nexport const resource = <T>(\n factory: (abortSignal: AbortSignal) => Promise<T>,\n options?: ResourceOptions<T>,\n): Resource<T> => {\n const name = options?.name;\n const state = signal<ResourceState<T>>(\n { data: options?.initialValue, status: 'loading' },\n name ? { name } : undefined,\n );\n // Internal-only trigger — never exposed. Read (but never written to a meaningful\n // value) inside the effect purely so it becomes a tracked dep; refresh() bumps it\n // to force a re-run without requiring a real dependency to change.\n const epoch = signal(0);\n\n let controller: AbortController | null = null;\n let disposed = false;\n\n const stop = effect(\n () => {\n void epoch.value;\n\n controller?.abort();\n controller = new AbortController();\n\n const { signal: abortSignal } = controller;\n\n const current = state.peek();\n const prevData = 'data' in current ? current.data : undefined;\n\n state.value = { data: prevData, status: 'loading' };\n\n void (async () => {\n try {\n const result = await factory(abortSignal);\n\n if (!abortSignal.aborted && !disposed) {\n state.value = { data: result, status: 'ready' };\n }\n } catch (err) {\n if (!abortSignal.aborted && !disposed) {\n state.value = { data: prevData, error: err, status: 'error' };\n }\n }\n })();\n },\n name ? { name } : undefined,\n );\n\n const refresh = (): void => {\n if (disposed) return;\n\n epoch.value = epoch.peek() + 1;\n };\n\n const dispose = (): void => {\n if (disposed) return;\n\n disposed = true;\n controller?.abort();\n stop.dispose();\n state.dispose();\n epoch.dispose();\n };\n\n autoRegisterDisposal(dispose);\n\n return {\n dispose,\n get disposed() {\n return disposed;\n },\n [IS_COMPUTED]: true as const,\n [IS_SIGNAL]: true as const,\n get name() {\n return state.name;\n },\n peek: () => state.peek(),\n refresh,\n subscribe: (listener: () => void) => state.subscribe(listener),\n [Symbol.dispose]: dispose,\n get value() {\n return state.value;\n },\n } as Resource<T>;\n};\n"],"mappings":"iHAwCA,IAAa,GACX,EACA,IACgB,CAChB,IAAM,EAAO,GAAS,KAChB,EAAQ,EAAA,OACZ,CAAE,KAAM,GAAS,aAAc,OAAQ,SAAU,EACjD,EAAO,CAAE,MAAK,EAAI,IAAA,EACpB,EAIM,EAAQ,EAAA,OAAO,CAAC,EAElB,EAAqC,KACrC,EAAW,GAET,EAAO,EAAA,WACL,CACJ,EAAW,MAEX,GAAY,MAAM,EAClB,EAAa,IAAI,gBAEjB,GAAM,CAAE,OAAQ,GAAgB,EAE1B,EAAU,EAAM,KAAK,EACrB,EAAW,SAAU,EAAU,EAAQ,KAAO,IAAA,GAEpD,EAAM,MAAQ,CAAE,KAAM,EAAU,OAAQ,SAAU,GAE5C,SAAY,CAChB,GAAI,CACF,IAAM,EAAS,MAAM,EAAQ,CAAW,EAEpC,CAAC,EAAY,SAAW,CAAC,IAC3B,EAAM,MAAQ,CAAE,KAAM,EAAQ,OAAQ,OAAQ,EAElD,OAAS,EAAK,CACR,CAAC,EAAY,SAAW,CAAC,IAC3B,EAAM,MAAQ,CAAE,KAAM,EAAU,MAAO,EAAK,OAAQ,OAAQ,EAEhE,CACF,EAAA,CAAG,CACL,EACA,EAAO,CAAE,MAAK,EAAI,IAAA,EACpB,EAEM,MAAsB,CACtB,IAEJ,EAAM,MAAQ,EAAM,KAAK,EAAI,EAC/B,EAEM,MAAsB,CACtB,IAEJ,EAAW,GACX,GAAY,MAAM,EAClB,EAAK,QAAQ,EACb,EAAM,QAAQ,EACd,EAAM,QAAQ,EAChB,EAIA,OAFA,EAAA,qBAAqB,CAAO,EAErB,CACL,UACA,IAAI,UAAW,CACb,OAAO,CACT,GACC,EAAA,aAAc,IACd,EAAA,WAAY,GACb,IAAI,MAAO,CACT,OAAO,EAAM,IACf,EACA,SAAY,EAAM,KAAK,EACvB,UACA,UAAY,GAAyB,EAAM,UAAU,CAAQ,GAC5D,OAAO,SAAU,EAClB,IAAI,OAAQ,CACV,OAAO,EAAM,KACf,CACF,CACF"}
@@ -1,36 +0,0 @@
1
- import type { Resource, ResourceOptions } from './types';
2
- /**
3
- * Creates a reactive async resource that emits a `ResourceState<T>` discriminated union.
4
- *
5
- * Dependencies are tracked synchronously in the factory (before the first `await`).
6
- * The factory receives an `AbortSignal` that fires when dependencies change or
7
- * the resource is disposed, cancelling any in-flight work.
8
- *
9
- * If `resource()` is created inside an active `effect()` or `scope.run()` context,
10
- * it is automatically registered for cleanup and disposed with that context —
11
- * matching `computed()`'s auto-disposal behavior.
12
- *
13
- * Call `refresh()` to force the factory to re-run immediately, even if no tracked
14
- * dependency changed — useful for manual "retry"/"refetch" actions.
15
- *
16
- * @example
17
- * ```ts
18
- * const userId = signal('u1');
19
- * const user = resource(async (signal) => {
20
- * const id = userId.value; // tracked dep — re-runs when userId changes
21
- * return fetchUser(id, { signal });
22
- * });
23
- *
24
- * effect(() => {
25
- * const s = user.value;
26
- * if (s.status === 'loading') return showSpinner();
27
- * if (s.status === 'error') return showError(s.error);
28
- * renderUser(s.data);
29
- * });
30
- *
31
- * user.refresh(); // force a re-fetch without changing userId
32
- * user.dispose();
33
- * ```
34
- */
35
- export declare const resource: <T>(factory: (abortSignal: AbortSignal) => Promise<T>, options?: ResourceOptions<T>) => Resource<T>;
36
- //# sourceMappingURL=async-computed.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-computed.d.ts","sourceRoot":"","sources":["../src/async-computed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAOxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EACxB,SAAS,CAAC,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACjD,UAAU,eAAe,CAAC,CAAC,CAAC,KAC3B,QAAQ,CAAC,CAAC,CAiFZ,CAAC"}