kenspeckle 0.1.3 → 0.1.4
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/kit/types.d.ts +2 -0
- package/dist/kit/view-transition.js +32 -23
- package/package.json +2 -2
package/dist/kit/types.d.ts
CHANGED
|
@@ -25,30 +25,39 @@ export function isRetreat(navigation) {
|
|
|
25
25
|
}
|
|
26
26
|
/** @internal — the handler `viewTransition()` registers, exported so it is testable without a component. */
|
|
27
27
|
export function navigationTransition({ onStart, onSettle, ...rest } = {}) {
|
|
28
|
-
return (navigation) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
return (navigation) => {
|
|
29
|
+
// SvelteKit 3 fires onNavigate for a shallow navigation; Kit 2 never did. The route is
|
|
30
|
+
// unchanged, so there is no arrival to cross-fade to, and holding the navigation suspends
|
|
31
|
+
// rendering — a call site that strips a query param and then calls window.print()
|
|
32
|
+
// synchronously would print a suspended page. A consumer who does want a shallow change
|
|
33
|
+
// animated has `viewTransition(update)`, which says so at the call site.
|
|
34
|
+
if (navigation.shallow)
|
|
35
|
+
return Promise.resolve();
|
|
36
|
+
return new Promise((resolve) => {
|
|
37
|
+
let transitioning = false;
|
|
38
|
+
runViewTransition(async () => {
|
|
39
|
+
// resolve() BEFORE awaiting breaks a mutual wait: Kit holds the navigation until this
|
|
40
|
+
// promise settles, the browser holds the snapshot until the callback settles.
|
|
41
|
+
resolve();
|
|
42
|
+
await navigation.complete;
|
|
43
|
+
if (transitioning)
|
|
44
|
+
beginPhase(navigation, 'arrival');
|
|
45
|
+
}, {
|
|
46
|
+
...rest,
|
|
47
|
+
state: isRetreat(navigation) ? 'retreat' : 'forward',
|
|
48
|
+
onStart: () => {
|
|
49
|
+
transitioning = true;
|
|
50
|
+
beginPhase(navigation, 'capture');
|
|
51
|
+
onStart?.(navigation);
|
|
52
|
+
},
|
|
53
|
+
onSettle: () => {
|
|
54
|
+
transitioning = false;
|
|
55
|
+
endTransition();
|
|
56
|
+
onSettle?.();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
50
59
|
});
|
|
51
|
-
}
|
|
60
|
+
};
|
|
52
61
|
}
|
|
53
62
|
export function viewTransition(first, second) {
|
|
54
63
|
if (typeof first === 'function')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kenspeckle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Svelte 5 utilities under one naming convention: attachments first-class, view transitions, and a state machine with context.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Brandon Pittman <brandon@brandonpittman.com>",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"svelte": "^5.40.0",
|
|
54
|
-
"@sveltejs/kit": "^2.0.0"
|
|
54
|
+
"@sveltejs/kit": "^2.0.0 || ^3.0.0-next.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"@sveltejs/kit": {
|