@solidjs/signals 2.0.0-beta.32 → 2.0.0-beta.34

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.
@@ -111,6 +111,28 @@ export interface EffectOptions extends BaseEffectOptions {
111
111
  * stored as-is and never awaited.
112
112
  */
113
113
  sync?: boolean;
114
+ /**
115
+ * Advanced (integration tier). When true, the effect is invisible to the
116
+ * hydration id scheme: it inherits its parent's id instead of consuming a
117
+ * child slot, and during hydration its compute runs live instead of
118
+ * adopting the serialized server value (its first run is not frozen to
119
+ * the server's decision).
120
+ *
121
+ * For **client-only effects created while hydrating** — effects with no
122
+ * server-rendered counterpart (a router wiring link state, scroll
123
+ * restoration, etc.). An id-consuming node the server never created would
124
+ * shift every later sibling's hydration id, making serialized lookups and
125
+ * template claims after it miss. `transparent` is also the supported
126
+ * alternative to branching on hydration state
127
+ * (`if (hydrating) createEffect(...)`), which freezes whatever the first
128
+ * run decided: create the effect unconditionally and let it observe live
129
+ * state instead.
130
+ *
131
+ * SSR ignores this option (a server-side effect always allocates its id
132
+ * slot), so only mark effects the server does not create. Outside
133
+ * hydration it is a no-op.
134
+ */
135
+ transparent?: boolean;
114
136
  }
115
137
  /** Options for plain signals created with `createSignal(value)` or `createOptimistic(value)`. */
116
138
  export interface SignalOptions<T> {
@@ -138,7 +160,14 @@ export interface MemoOptions<T> {
138
160
  id?: string;
139
161
  /** Debug name (dev mode only) */
140
162
  name?: string;
141
- /** When true, the owner is invisible to the ID scheme -- inherits parent ID and doesn't consume a childCount slot */
163
+ /**
164
+ * Advanced (integration tier). When true, the memo is invisible to the
165
+ * hydration id scheme: it inherits its parent's id instead of consuming a
166
+ * child slot, and during hydration it computes live instead of adopting
167
+ * the serialized server value. For client-only memos with no
168
+ * server-rendered counterpart — see {@link EffectOptions.transparent} for
169
+ * the full semantics. No-op outside hydration.
170
+ */
142
171
  transparent?: boolean;
143
172
  /**
144
173
  * Custom equality function, or `false` to always notify subscribers.
@@ -168,6 +197,30 @@ export interface MemoOptions<T> {
168
197
  * stored as-is and never awaited.
169
198
  */
170
199
  sync?: boolean;
200
+ /**
201
+ * Commit #0: a committed value the memo is born with, shown until the
202
+ * compute's first real answer lands. While that first answer is in flight
203
+ * the memo reads as a settled value everywhere — nothing suspends to a
204
+ * `<Loading>` boundary, no transition is held (first-flight work is
205
+ * loading-class, like a boundary fallback), and `isPending(memo)` stays
206
+ * **false**: commit #0 answers the question by declaration, so first-load
207
+ * affordances are driven from the value itself (a `null` placeholder, a
208
+ * `skeleton: true` field, etc.). Once the first answer lands, the loading
209
+ * value leaves the lineage forever: refetches use normal pending semantics
210
+ * (stale value shown, `isPending` true, boundaries/transitions coordinate)
211
+ * — the canonical guard is `data.skeleton || isPending(data)`, whose two
212
+ * terms cover the two disjoint states.
213
+ *
214
+ * Typed strictly as `T`: to use `null`/`undefined` as the placeholder,
215
+ * declare it in the memo's type (e.g. `createMemo<User | null>(...)`), so
216
+ * every consumer sees the nullable window honestly. If the placeholder is
217
+ * shaped data standing in for real data, encode its provenance in the data
218
+ * (e.g. a `skeleton: true` field) rather than letting it impersonate truth.
219
+ *
220
+ * The loading value is also the compute's first `prev`, so `prev`-based
221
+ * memos fold from it.
222
+ */
223
+ loadingValue?: T;
171
224
  }
172
225
  export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
173
226
  /**
@@ -216,7 +269,7 @@ export declare function createSignal<T>(fn: ComputeFunction<T>, options?: Signal
216
269
  * const value = createMemo<T>(compute, options?: MemoOptions<T>);
217
270
  * ```
218
271
  * @param compute a function that receives its previous value and returns a new value used to react on a computation
219
- * @param options `MemoOptions` -- id, name, equals, unobserved, lazy
272
+ * @param options `MemoOptions` -- id, name, equals, unobserved, lazy, transparent
220
273
  *
221
274
  * @example
222
275
  * ```ts
@@ -239,6 +292,9 @@ export declare function createSignal<T>(fn: ComputeFunction<T>, options?: Signal
239
292
  *
240
293
  * @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
241
294
  */
295
+ export declare function createMemo<T>(compute: ComputeFunction<NoInfer<T>, T>, options: MemoOptions<T> & {
296
+ loadingValue: T;
297
+ }): SourceAccessor<T>;
242
298
  export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: MemoOptions<T>): SourceAccessor<T>;
243
299
  /**
244
300
  * Creates a reactive effect with **separate compute and effect phases**.
@@ -280,7 +336,7 @@ export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInf
280
336
  * ```
281
337
  * @param compute a function that receives its previous value and returns a new value used to react on a computation
282
338
  * @param effectFn a function that receives the new value and is used to perform side effects (return a cleanup function), or an `EffectBundle` with `effect` and `error` handlers
283
- * @param options `EffectOptions` -- name, defer, schedule
339
+ * @param options `EffectOptions` -- name, defer, schedule, transparent
284
340
  *
285
341
  * @example
286
342
  * ```ts
@@ -334,7 +390,7 @@ export declare function createEffect<T>(compute: ComputeFunction<undefined | NoI
334
390
  * ```
335
391
  * @param compute a function that receives its previous value and returns a new value used to react on a computation
336
392
  * @param effectFn a function that receives the new value and is used to perform side effects
337
- * @param options `EffectOptions` -- name, defer, schedule
393
+ * @param options `EffectOptions` -- name, defer, schedule, transparent
338
394
  *
339
395
  * @example
340
396
  * ```ts
@@ -33,6 +33,20 @@ export interface ProjectionOptions extends StoreOptions {
33
33
  key?: string | ((item: NonNullable<any>) => any) | null;
34
34
  /** Single-layer store: root keys reactive, values raw records replaced by reference */
35
35
  shallow?: boolean;
36
+ /**
37
+ * Treat the seed as commit #0: the store is born committed with the seed's
38
+ * contents, shown until the derive's first real answer lands. While that
39
+ * first answer is in flight, reads serve the seed everywhere — nothing
40
+ * suspends to a `<Loading>` boundary, no transition is held, and
41
+ * `isPending` stays false (the seed answers by declaration; first-load
42
+ * affordances belong to the data, e.g. a `skeleton: true` field in the
43
+ * seed). Once the first answer lands (reconciled into the seed), refetches
44
+ * use normal pending semantics with `isPending` true.
45
+ *
46
+ * The store equivalent of `MemoOptions.loadingValue`; the seed already
47
+ * carries the placeholder shape, so this is just the opt-in.
48
+ */
49
+ seedLoadingValue?: boolean;
36
50
  }
37
51
  export type NoFn<T> = T extends Function ? never : T;
38
52
  type DataNode = Signal<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "2.0.0-beta.32",
3
+ "version": "2.0.0-beta.34",
4
4
  "description": "Solid's reactive primitives: signals, memos, effects, stores, and async-aware computations.",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",