march-hare 0.13.10 → 0.13.11
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/dist/types/index.d.ts
CHANGED
|
@@ -175,9 +175,10 @@ export declare class Brand {
|
|
|
175
175
|
static readonly Name: unique symbol;
|
|
176
176
|
/**
|
|
177
177
|
* Phantom brand identifying lifecycle actions returned by
|
|
178
|
-
* `Lifecycle.Mount()`, `Lifecycle.
|
|
179
|
-
* `Lifecycle.Update()`. Carries the lifecycle's
|
|
180
|
-
* `useAction` can pick distinct overloads — in
|
|
178
|
+
* `Lifecycle.Mount()`, `Lifecycle.Paint()`, `Lifecycle.Unmount()`,
|
|
179
|
+
* `Lifecycle.Error()`, and `Lifecycle.Update()`. Carries the lifecycle's
|
|
180
|
+
* literal kind so that `useAction` can pick distinct overloads — in
|
|
181
|
+
* particular,
|
|
181
182
|
* `Lifecycle.Update` resolves its payload to `Partial<DeepReadonly<D>>`
|
|
182
183
|
* against the surrounding `useActions` data generic instead of the
|
|
183
184
|
* factory-level `Record<string, unknown>` placeholder. Without this
|
|
@@ -213,6 +214,7 @@ export declare const EnvSymbol: unique symbol;
|
|
|
213
214
|
* ```ts
|
|
214
215
|
* export class Actions {
|
|
215
216
|
* static Mount = Lifecycle.Mount();
|
|
217
|
+
* static Paint = Lifecycle.Paint();
|
|
216
218
|
* static Unmount = Lifecycle.Unmount();
|
|
217
219
|
* static Error = Lifecycle.Error();
|
|
218
220
|
* static Update = Lifecycle.Update();
|
|
@@ -229,6 +231,14 @@ export declare const EnvSymbol: unique symbol;
|
|
|
229
231
|
export declare class Lifecycle {
|
|
230
232
|
/** Creates a Mount lifecycle action. Triggered once on component mount (`useLayoutEffect`). */
|
|
231
233
|
static Mount(): LifecyclePayload<never, never, "Mount">;
|
|
234
|
+
/**
|
|
235
|
+
* Creates a Paint lifecycle action. Triggered once after the browser has
|
|
236
|
+
* committed the first frame (`useEffect`). Pairs with {@link Lifecycle.Mount}
|
|
237
|
+
* (pre-paint) — use Paint for work that should not delay the first
|
|
238
|
+
* paint: analytics “viewed” events, focus management, scroll-into-view,
|
|
239
|
+
* non-blocking prefetch, etc.
|
|
240
|
+
*/
|
|
241
|
+
static Paint(): LifecyclePayload<never, never, "Paint">;
|
|
232
242
|
/** Creates an Unmount lifecycle action. Triggered when the component unmounts. */
|
|
233
243
|
static Unmount(): LifecyclePayload<never, never, "Unmount">;
|
|
234
244
|
/** Creates an Error lifecycle action. Triggered when an action throws. Receives `Fault` as payload. */
|
|
@@ -407,20 +417,21 @@ export type HandlerPayload<P = unknown, C extends Filter = never, Name extends s
|
|
|
407
417
|
(channel: C): ChanneledAction<P, C, Name>;
|
|
408
418
|
});
|
|
409
419
|
/**
|
|
410
|
-
* Branded type returned by `Lifecycle.Mount`, `Lifecycle.
|
|
411
|
-
* `Lifecycle.Error`, and `Lifecycle.Update`.
|
|
412
|
-
* `HandlerPayload` but carries a phantom
|
|
413
|
-
* is the lifecycle's literal kind. The
|
|
414
|
-
* `Handlers` resolve `Lifecycle.Update`'s
|
|
415
|
-
* (against the surrounding `useActions`
|
|
416
|
-
* factory-level `Record<string, unknown>`
|
|
417
|
-
* `Action<P>("Update")` would have
|
|
418
|
-
* so it falls into the generic
|
|
420
|
+
* Branded type returned by `Lifecycle.Mount`, `Lifecycle.Paint`,
|
|
421
|
+
* `Lifecycle.Unmount`, `Lifecycle.Error`, and `Lifecycle.Update`.
|
|
422
|
+
* Structurally identical to a `HandlerPayload` but carries a phantom
|
|
423
|
+
* `Brand.Lifecycle` brand whose value is the lifecycle's literal kind. The
|
|
424
|
+
* brand is what lets `useAction` and `Handlers` resolve `Lifecycle.Update`'s
|
|
425
|
+
* payload to `Partial<DeepReadonly<D>>` (against the surrounding `useActions`
|
|
426
|
+
* data generic) instead of the factory-level `Record<string, unknown>`
|
|
427
|
+
* placeholder — a user-defined `Action<P>("Update")` would have
|
|
428
|
+
* `Name = "Update"` but no `Brand.Lifecycle`, so it falls into the generic
|
|
429
|
+
* payload overload as expected.
|
|
419
430
|
*
|
|
420
431
|
* @template P Payload type for the lifecycle.
|
|
421
432
|
* @template C Channel filter (always `never` for lifecycles — they are
|
|
422
433
|
* not channeled).
|
|
423
|
-
* @template Name Literal name (`"Mount"`, `"Unmount"`, `"Error"`, `"Update"`).
|
|
434
|
+
* @template Name Literal name (`"Mount"`, `"Paint"`, `"Unmount"`, `"Error"`, `"Update"`).
|
|
424
435
|
*/
|
|
425
436
|
export type LifecyclePayload<P = unknown, C extends Filter = never, Name extends string = string> = HandlerPayload<P, C, Name> & {
|
|
426
437
|
readonly [Brand.Lifecycle]: Name;
|