@mmstack/primitives 19.6.0 → 19.7.1
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/README.md +38 -1
- package/fesm2022/mmstack-primitives.mjs +264 -44
- package/fesm2022/mmstack-primitives.mjs.map +1 -1
- package/lib/concurrent/index.d.ts +1 -0
- package/lib/concurrent/start-transition.d.ts +3 -2
- package/lib/concurrent/suspense-boundary.d.ts +1 -2
- package/lib/concurrent/transaction.d.ts +2 -1
- package/lib/concurrent/transition-scope.d.ts +9 -0
- package/lib/concurrent/transition.d.ts +62 -0
- package/lib/sensors/pointer-drag.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Signal } from '@angular/core';
|
|
2
2
|
/**
|
|
3
|
-
* Handle for an in-progress transition: a `pending` signal (true while the transition's
|
|
4
|
-
* resources are in flight
|
|
3
|
+
* Handle for an in-progress transition: a `pending` signal (true while the transition's OWN
|
|
4
|
+
* resources are in flight — loads already in flight when it started are not attributed) and a
|
|
5
|
+
* `done` promise that resolves once they all settle.
|
|
5
6
|
*/
|
|
6
7
|
export type TransitionRef = {
|
|
7
8
|
readonly pending: Signal<boolean>;
|
|
@@ -41,8 +41,7 @@ export declare class SuspenseBoundary extends SuspenseBoundaryBase {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Unscoped suspense boundary — **reads the ambient scope** instead of providing one. For cases where
|
|
44
|
-
* the resources to coordinate are registered *above* the boundary
|
|
45
|
-
* manifests/connectors register at a higher injector), so the boundary observes that outer scope
|
|
44
|
+
* the resources to coordinate are registered *above* the boundary so the boundary observes that outer scope
|
|
46
45
|
* rather than opening a fresh one. Pair with a `provideTransitionScope()` (or another boundary) in an
|
|
47
46
|
* ancestor.
|
|
48
47
|
*/
|
|
@@ -15,7 +15,8 @@ export type Transaction = {
|
|
|
15
15
|
export declare function createTransaction(): Transaction;
|
|
16
16
|
/** The transaction in effect right now, or `null`. Stateful actions consult this to record undo. */
|
|
17
17
|
export declare function activeTransaction(): Transaction | null;
|
|
18
|
-
/** Handle for an in-progress transaction (Tier 3): the
|
|
18
|
+
/** Handle for an in-progress transaction (Tier 3): the transaction's own `pending`/`done`
|
|
19
|
+
* (loads already in flight at start are not attributed to it), plus `abort`. */
|
|
19
20
|
export type TransactionRef = {
|
|
20
21
|
readonly pending: Signal<boolean>;
|
|
21
22
|
readonly done: Promise<void>;
|
|
@@ -78,6 +78,15 @@ export declare function createForwardingScope(): ForwardingTransitionScope;
|
|
|
78
78
|
export declare function provideForwardingTransitionScope(): Provider;
|
|
79
79
|
/** Read the transition scope reachable from `injector`, or null if none is provided there. */
|
|
80
80
|
export declare function getTransitionScope(injector: Injector): TransitionScope | null;
|
|
81
|
+
/**
|
|
82
|
+
* @internal Transaction-attributed pending for `startTransition`/`startTransaction`: like
|
|
83
|
+
* `scope.pending`, but loads already in flight when the tracker is created are NOT attributed —
|
|
84
|
+
* a pre-existing background load can neither settle the transaction early nor block its settle
|
|
85
|
+
* forever. A pre-existing flight is excluded only until it first settles; a later re-trigger of
|
|
86
|
+
* the same resource (e.g. the transaction's write changed its request) counts as the
|
|
87
|
+
* transaction's own work.
|
|
88
|
+
*/
|
|
89
|
+
export declare function createAttributedPending(scope: TransitionScope): Signal<boolean>;
|
|
81
90
|
/**
|
|
82
91
|
* Returns a register function bound to the nearest transition scope: it adds a resource
|
|
83
92
|
* to the scope and removes it when the caller's injection context is destroyed. Pass any
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export type MmTransitionContext<T> = {
|
|
4
|
+
readonly $implicit: T;
|
|
5
|
+
readonly mmTransition: T;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Generic hold-and-swap: the non-router `TransitionRouterOutlet`. When the bound value changes,
|
|
9
|
+
* the OLD view stays mounted and visible (it keeps its old context value — that's the hold) while
|
|
10
|
+
* the NEW view mounts hidden with its **own transition scope**; resources created in the incoming
|
|
11
|
+
* subtree register into that scope just by existing, and once they've gone in flight and settled
|
|
12
|
+
* the views swap in one frame. Tabs, wizard steps, master-detail — any branch change that would
|
|
13
|
+
* otherwise flash a loading state.
|
|
14
|
+
*
|
|
15
|
+
* ```html
|
|
16
|
+
* <div *mmTransition="selectedTab(); let tab">
|
|
17
|
+
* @switch (tab) { ... }
|
|
18
|
+
* </div>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Distinct from `<mm-suspense>` (the readiness gate): suspense decides placeholder-vs-content
|
|
22
|
+
* *within* one branch, but can't stop an `@switch` from unmounting the old branch the instant the
|
|
23
|
+
* value flips. This directive is the swap itself — the old branch survives until the new one is
|
|
24
|
+
* ready. Compose them freely: suspense inside a transitioned branch handles its first load.
|
|
25
|
+
*
|
|
26
|
+
* Semantics mirror the outlet: the first render is immediate (nothing to hold); an interrupting
|
|
27
|
+
* value change mid-hold destroys the half-ready hidden view and re-targets; a branch that loads
|
|
28
|
+
* nothing swaps right after its first render. Per-view scopes mean the outgoing branch's
|
|
29
|
+
* background work can never delay the swap. Set `mmTransitionImmediate` to skip holding, and
|
|
30
|
+
* `mmTransitionViewTransition` to wrap the swap in `document.startViewTransition` (feature
|
|
31
|
+
* detected). On the server every change swaps immediately.
|
|
32
|
+
*/
|
|
33
|
+
export declare class MmTransition<T> {
|
|
34
|
+
private readonly tpl;
|
|
35
|
+
private readonly vcr;
|
|
36
|
+
private readonly parent;
|
|
37
|
+
private readonly onServer;
|
|
38
|
+
/** The value whose changes are transitioned. Each view keeps the value it was created with. */
|
|
39
|
+
readonly value: import("@angular/core").InputSignal<T>;
|
|
40
|
+
/** Skip holding entirely — every change swaps at once (the plain re-render behavior). */
|
|
41
|
+
readonly immediate: import("@angular/core").InputSignal<boolean>;
|
|
42
|
+
/** Wrap the swap in the View Transitions API for an animated cross-fade (feature detected). */
|
|
43
|
+
readonly viewTransition: import("@angular/core").InputSignal<boolean>;
|
|
44
|
+
private current;
|
|
45
|
+
private incoming;
|
|
46
|
+
/** Bumped on every re-target/teardown so a superseded (possibly deferred) swap can't commit. */
|
|
47
|
+
private swapEpoch;
|
|
48
|
+
private readonly holding;
|
|
49
|
+
/** True while an incoming view is mounted hidden, waiting to settle. */
|
|
50
|
+
readonly pending: Signal<boolean>;
|
|
51
|
+
static ngTemplateContextGuard<T>(dir: MmTransition<T>, ctx: unknown): ctx is MmTransitionContext<T>;
|
|
52
|
+
constructor();
|
|
53
|
+
private onValue;
|
|
54
|
+
private commitSwap;
|
|
55
|
+
/** The actual swap: destroy the old view, reveal the new one. Always instant. */
|
|
56
|
+
private finishSwap;
|
|
57
|
+
private dropIncoming;
|
|
58
|
+
private createView;
|
|
59
|
+
private setHidden;
|
|
60
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MmTransition<any>, never>;
|
|
61
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<MmTransition<any>, "[mmTransition]", ["mmTransition"], { "value": { "alias": "mmTransition"; "required": true; "isSignal": true; }; "immediate": { "alias": "mmTransitionImmediate"; "required": false; "isSignal": true; }; "viewTransition": { "alias": "mmTransitionViewTransition"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
62
|
+
}
|
|
@@ -33,6 +33,13 @@ export type PointerDragState = {
|
|
|
33
33
|
* otherwise the listener's element. `null` when idle.
|
|
34
34
|
*/
|
|
35
35
|
origin: HTMLElement | null;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the LAST gesture ended by being aborted (`pointercancel` /
|
|
38
|
+
* `lostpointercapture` / Escape / `cancel()`) rather than a normal `pointerup`.
|
|
39
|
+
* Only meaningful on the idle transition — consumers ending a drag branch on it
|
|
40
|
+
* to distinguish "drop here" from "abort". Sticky until the next `pointerdown`.
|
|
41
|
+
*/
|
|
42
|
+
cancelled: boolean;
|
|
36
43
|
};
|
|
37
44
|
export type PointerDragOptions = SensorRunOptions & {
|
|
38
45
|
/**
|