kenspeckle 0.1.2 → 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/README.md CHANGED
@@ -206,6 +206,18 @@ const dispose = viewTransitionName(element, 'back-button');
206
206
  `viewTransition(update)` on a same-route step names nothing. Morph a stepping element with static
207
207
  `view-transition-name` in CSS instead.
208
208
 
209
+ ## Claude Code plugin
210
+
211
+ This repo doubles as a Claude Code plugin. `skills/view-transitions/` is the
212
+ agent-facing guide to the view-transition tier — the `data-view-transition`
213
+ contract, `viewTransitionName` claims and their phases, the duplicate-name
214
+ abort, and the list of things the library already handles so an agent stops
215
+ reimplementing them. Point a marketplace entry at this repo
216
+ (`.claude-plugin/plugin.json` is at the root) and it installs as `kenspeckle`,
217
+ invoked as `/kenspeckle:view-transitions`.
218
+
219
+ The skill and the code ship in the same change, same rule as the docs pages.
220
+
209
221
  ## Provenance
210
222
 
211
223
  kenspeckle is a curation, not a fork. [runed](https://runed.dev) has genuinely useful utilities under three naming regimes at once — PascalCase classes, bare functions, and React-style `use` hooks, with pairs like `Debounced` / `useDebounce` coexisting. [svelte-put](https://svelte-put.vnphanquang.com) has good actions from the Svelte 4 era, before attachments existed. kenspeckle reshapes both pools under one convention and adds what neither ships: attachments as a first-class layer.
@@ -2,6 +2,8 @@
2
2
  export interface Navigation {
3
3
  complete: Promise<void>;
4
4
  type?: string;
5
+ /** Optional because SvelteKit 2 has no such field; only Kit 3 reports it. */
6
+ shallow?: boolean;
5
7
  delta?: number | null;
6
8
  from?: {
7
9
  url: URL;
@@ -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) => new Promise((resolve) => {
29
- let transitioning = false;
30
- runViewTransition(async () => {
31
- // resolve() BEFORE awaiting breaks a mutual wait: Kit holds the navigation until this
32
- // promise settles, the browser holds the snapshot until the callback settles.
33
- resolve();
34
- await navigation.complete;
35
- if (transitioning)
36
- beginPhase(navigation, 'arrival');
37
- }, {
38
- ...rest,
39
- state: isRetreat(navigation) ? 'retreat' : 'forward',
40
- onStart: () => {
41
- transitioning = true;
42
- beginPhase(navigation, 'capture');
43
- onStart?.(navigation);
44
- },
45
- onSettle: () => {
46
- transitioning = false;
47
- endTransition();
48
- onSettle?.();
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.2",
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": {