@ssgoi/svelte 5.2.0 → 6.1.0

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
@@ -16,7 +16,7 @@ SSGOI brings native app-like page transitions to the web. Transform your static
16
16
  - **🚀 SSR Ready** - Perfect compatibility with SvelteKit. No hydration issues, SEO-friendly
17
17
  - **🎯 Use Your Router** - Keep your existing routing. SvelteKit's built-in router works seamlessly
18
18
  - **💾 State Persistence** - Remembers animation state during navigation, even with browser back/forward
19
- - **🧩 Svelte Native** - Built specifically for Svelte with actions and stores
19
+ - **🧩 Svelte Native** - Built specifically for Svelte components
20
20
 
21
21
  ## Installation
22
22
 
@@ -37,9 +37,13 @@ pnpm add @ssgoi/svelte
37
37
  <script>
38
38
  import { Ssgoi } from "@ssgoi/svelte";
39
39
  import { fade } from "@ssgoi/svelte/view-transitions";
40
+
41
+ const config = {
42
+ transitions: [fade({ paths: ["/", "/about"] })],
43
+ };
40
44
  </script>
41
45
 
42
- <Ssgoi config={{ defaultTransition: fade() }}>
46
+ <Ssgoi {config}>
43
47
  <!-- ⚠️ Important: position: relative is required! -->
44
48
  <div style="position: relative; min-height: 100vh;">
45
49
  <slot />
@@ -62,7 +66,7 @@ pnpm add @ssgoi/svelte
62
66
  </SsgoiTransition>
63
67
  ```
64
68
 
65
- **That's it!** Your pages now transition smoothly with a fade effect.
69
+ **That's it!** Your pages now transition smoothly with the configured effect.
66
70
 
67
71
  ## Advanced Transitions
68
72
 
@@ -73,34 +77,19 @@ Define different transitions for different routes:
73
77
  ```svelte
74
78
  <script>
75
79
  import { Ssgoi } from "@ssgoi/svelte";
76
- import {
77
- scroll,
78
- fade,
79
- drill,
80
- pinterest,
81
- } from "@ssgoi/svelte/view-transitions";
80
+ import { scroll, drill, zoom } from "@ssgoi/svelte/view-transitions";
82
81
 
83
82
  const config = {
84
83
  transitions: [
85
84
  // Scroll between tabs
86
- { from: "/home", to: "/about", transition: scroll({ direction: "up" }) },
87
- {
88
- from: "/about",
89
- to: "/home",
90
- transition: scroll({ direction: "down" }),
91
- },
85
+ scroll({ paths: ["/home", "/about"] }),
92
86
 
93
87
  // Drill in when entering details
94
- {
95
- from: "/products",
96
- to: "/products/*",
97
- transition: drill({ direction: "enter" }),
98
- },
99
-
100
- // Pinterest-style image transitions
101
- { from: "/gallery", to: "/photo/*", transition: pinterest() },
88
+ drill({ enter: "/products/*", exit: "/products" }),
89
+
90
+ // Shared element image transitions
91
+ zoom({ paths: ["/gallery", "/photo/*"], type: "expand" }),
102
92
  ],
103
- defaultTransition: fade(),
104
93
  };
105
94
  </script>
106
95
 
@@ -109,39 +98,7 @@ Define different transitions for different routes:
109
98
  </Ssgoi>
110
99
  ```
111
100
 
112
- ### Symmetric Transitions
113
-
114
- Automatically create bidirectional transitions:
115
-
116
- ```svelte
117
- {
118
- from: '/home',
119
- to: '/about',
120
- transition: scroll({ direction: 'up' }),
121
- symmetric: true // Automatically creates reverse transition
122
- }
123
- ```
124
-
125
- ### Individual Element Animations
126
-
127
- Animate specific elements during mount/unmount:
128
-
129
- ```svelte
130
- <script>
131
- import { transition } from "@ssgoi/svelte";
132
- import { fade, slide } from "@ssgoi/svelte/transitions";
133
- </script>
134
-
135
- <div
136
- use:transition={{
137
- key: "card",
138
- in: fade(),
139
- out: slide({ direction: 'up' }),
140
- }}
141
- >
142
- <h2>Animated Card</h2>
143
- </div>
144
- ```
101
+ The route helpers return path transition groups, so nested arrays are accepted in `config.transitions`.
145
102
 
146
103
  ## SvelteKit App Example
147
104
 
@@ -150,11 +107,13 @@ Animate specific elements during mount/unmount:
150
107
  <script>
151
108
  import { Ssgoi } from '@ssgoi/svelte';
152
109
  import { scroll } from '@ssgoi/svelte/view-transitions';
110
+
111
+ const config = {
112
+ transitions: [scroll({ paths: ['/', '/about', '/products'] })]
113
+ };
153
114
  </script>
154
115
 
155
- <Ssgoi config={{
156
- defaultTransition: scroll({ direction: 'up' })
157
- }}>
116
+ <Ssgoi {config}>
158
117
  <div style="position: relative; min-height: 100vh;">
159
118
  <nav>
160
119
  <a href="/">Home</a>
@@ -190,6 +149,11 @@ The provider component that manages transition context.
190
149
  </Ssgoi>
191
150
  ```
192
151
 
152
+ Props:
153
+
154
+ - `config` - Transition configuration object
155
+ - `host` - Optional external playback host for debug tooling
156
+
193
157
  #### `<SsgoiTransition>`
194
158
 
195
159
  Wrapper component for pages that should transition.
@@ -200,40 +164,6 @@ Wrapper component for pages that should transition.
200
164
  </SsgoiTransition>
201
165
  ```
202
166
 
203
- ### Actions
204
-
205
- #### `use:transition`
206
-
207
- Apply transitions to individual elements.
208
-
209
- ```svelte
210
- <div
211
- use:transition={{
212
- key: "unique-key",
213
- in: fade(),
214
- out: fade(),
215
- }}
216
- >
217
- Content
218
- </div>
219
- ```
220
-
221
- ### Stores
222
-
223
- #### `transitioning`
224
-
225
- Access transition state.
226
-
227
- ```svelte
228
- <script>
229
- import { transitioning } from "@ssgoi/svelte";
230
- </script>
231
-
232
- {#if $transitioning}
233
- <p>Transitioning...</p>
234
- {/if}
235
- ```
236
-
237
167
  ## Built-in Transitions
238
168
 
239
169
  ### Page Transitions (`@ssgoi/svelte/view-transitions`)
@@ -242,28 +172,16 @@ Access transition state.
242
172
  - `scroll()` - Vertical scrolling (up/down)
243
173
  - `drill()` - Drill in/out effect (enter/exit)
244
174
  - `hero()` - Shared element transitions
245
- - `pinterest()` - Pinterest-style expand effect
246
-
247
- ### Element Transitions (`@ssgoi/svelte/transitions`)
248
-
249
- - `fade()`
250
- - `slide({ direction: 'up' | 'down' | 'left' | 'right' })`
251
- - `scale()`
252
- - `bounce()`
253
- - `blur()`
254
- - `rotate()`
175
+ - `slide()` - Ordered horizontal page transitions
176
+ - `zoom()` - Shared element zoom transitions
255
177
 
256
- ## Spring Physics Configuration
178
+ ## Typed Preset Configuration
257
179
 
258
- All transitions use spring physics for natural motion:
180
+ Transition presets are fully typed and use the core animation engine internally:
259
181
 
260
182
  ```javascript
261
183
  slide({
262
- direction: "left",
263
- spring: {
264
- stiffness: 300, // 1-1000, higher = faster
265
- damping: 30, // 0-100, higher = less oscillation
266
- },
184
+ paths: ["/products/all", "/products/fashion"],
267
185
  });
268
186
  ```
269
187
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- export { transition } from "./transition.js";
2
1
  export { default as Ssgoi } from "./ssgoi.svelte";
3
2
  export { default as SsgoiTransition } from "./ssgoi-transition.svelte";
4
- export { default as TransitionScope } from "./transition-scope.svelte";
5
3
  export * from "./types.js";
4
+ export * from "@ssgoi/core";
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
- export { transition } from "./transition.js";
2
1
  export { default as Ssgoi } from "./ssgoi.svelte";
3
2
  export { default as SsgoiTransition } from "./ssgoi-transition.svelte";
4
- export { default as TransitionScope } from "./transition-scope.svelte";
5
3
  export * from "./types.js";
4
+ export * from "@ssgoi/core";
@@ -1,24 +1,30 @@
1
1
  <script lang="ts">
2
- import { transition } from "./transition";
2
+ import type { Snippet } from "svelte";
3
3
  import { getSsgoiContext } from "./context";
4
4
 
5
5
  interface Props {
6
6
  id: string;
7
- children: () => any;
7
+ children: Snippet;
8
8
  as?: keyof HTMLElementTagNameMap;
9
9
  class?: string;
10
+ [key: string]: unknown;
10
11
  }
11
12
 
12
- let { id, children, as = "div", class: className }: Props = $props();
13
+ let { id, children, as = "div", class: className, ...rest }: Props = $props();
13
14
 
14
- const getTransition = getSsgoiContext();
15
+ const ssgoi = getSsgoiContext();
16
+
17
+ function ssgoiRef(node: HTMLElement) {
18
+ ssgoi.refFor(id)(node);
19
+ }
15
20
  </script>
16
21
 
17
22
  <svelte:element
18
23
  this={as}
19
- use:transition={getTransition(id)}
24
+ use:ssgoiRef
20
25
  data-ssgoi-transition={id}
21
26
  class={className}
27
+ {...rest}
22
28
  >
23
29
  {@render children()}
24
30
  </svelte:element>
@@ -1,8 +1,10 @@
1
+ import type { Snippet } from "svelte";
1
2
  interface Props {
2
3
  id: string;
3
- children: () => any;
4
+ children: Snippet;
4
5
  as?: keyof HTMLElementTagNameMap;
5
6
  class?: string;
7
+ [key: string]: unknown;
6
8
  }
7
9
  declare const SsgoiTransition: import("svelte").Component<Props, {}, "">;
8
10
  type SsgoiTransition = ReturnType<typeof SsgoiTransition>;
package/dist/ssgoi.svelte CHANGED
@@ -1,16 +1,19 @@
1
1
  <script lang="ts">
2
+ import type { Snippet } from "svelte";
2
3
  import type { SsgoiConfig } from "@ssgoi/core/types";
4
+ import type { HostAnimation } from "@ssgoi/core/internal";
3
5
  import { setSsgoiContext } from "./context";
4
- import { createSggoiTransitionContext } from "@ssgoi/core";
6
+ import { createSggoiTransitionContext } from "@ssgoi/core/internal";
5
7
 
6
8
  interface Props {
7
9
  config: SsgoiConfig;
8
- children: () => any;
10
+ host?: HostAnimation;
11
+ children: Snippet;
9
12
  }
10
13
 
11
- let { config, children }: Props = $props();
14
+ let { config, host, children }: Props = $props();
12
15
 
13
- const contextValue = createSggoiTransitionContext(config);
16
+ const contextValue = createSggoiTransitionContext(config, { host });
14
17
  setSsgoiContext(contextValue);
15
18
  </script>
16
19
 
@@ -1,7 +1,10 @@
1
+ import type { Snippet } from "svelte";
1
2
  import type { SsgoiConfig } from "@ssgoi/core/types";
3
+ import type { HostAnimation } from "@ssgoi/core/internal";
2
4
  interface Props {
3
5
  config: SsgoiConfig;
4
- children: () => any;
6
+ host?: HostAnimation;
7
+ children: Snippet;
5
8
  }
6
9
  declare const Ssgoi: import("svelte").Component<Props, {}, "">;
7
10
  type Ssgoi = ReturnType<typeof Ssgoi>;
@@ -0,0 +1 @@
1
+ export * from "@ssgoi/core";
@@ -0,0 +1 @@
1
+ export * from "@ssgoi/core";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/svelte",
3
- "version": "5.2.0",
3
+ "version": "6.1.0",
4
4
  "description": "Svelte bindings for SSGOI - Native app-like page transitions for Svelte and SvelteKit applications",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
@@ -14,7 +14,7 @@
14
14
  "types": "./dist/index.d.ts",
15
15
  "type": "module",
16
16
  "dependencies": {
17
- "@ssgoi/core": "^5.2.0"
17
+ "@ssgoi/core": "^6.1.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "svelte": "^5.0.0"
@@ -77,25 +77,15 @@
77
77
  "svelte": "./dist/index.js",
78
78
  "import": "./dist/index.js"
79
79
  },
80
- "./transitions": {
81
- "types": "./dist/transitions/index.d.ts",
82
- "svelte": "./dist/transitions/index.js",
83
- "import": "./dist/transitions/index.js"
84
- },
85
- "./view-transitions": {
86
- "types": "./dist/view-transitions/index.d.ts",
87
- "svelte": "./dist/view-transitions/index.js",
88
- "import": "./dist/view-transitions/index.js"
89
- },
90
80
  "./types": {
91
81
  "types": "./dist/types.d.ts",
92
82
  "svelte": "./dist/types.js",
93
83
  "import": "./dist/types.js"
94
84
  },
95
- "./presets": {
96
- "types": "./dist/presets/index.d.ts",
97
- "svelte": "./dist/presets/index.js",
98
- "import": "./dist/presets/index.js"
85
+ "./view-transitions": {
86
+ "types": "./dist/view-transitions.d.ts",
87
+ "svelte": "./dist/view-transitions.js",
88
+ "import": "./dist/view-transitions.js"
99
89
  }
100
90
  },
101
91
  "scripts": {
@@ -1 +0,0 @@
1
- export * from "@ssgoi/core/presets";
@@ -1 +0,0 @@
1
- export * from "@ssgoi/core/presets";
@@ -1,30 +0,0 @@
1
- <script lang="ts">
2
- import { createTransitionScope } from "@ssgoi/core";
3
-
4
- interface Props {
5
- children: () => any;
6
- }
7
-
8
- let { children }: Props = $props();
9
- </script>
10
-
11
- <!--
12
- TransitionScope creates a boundary for local-scoped transitions.
13
-
14
- Child elements with `scope: 'local'` will:
15
- - Skip IN animation when mounted simultaneously with the scope
16
- - Skip OUT animation when unmounted simultaneously with the scope
17
-
18
- @example
19
- ```svelte
20
- <TransitionScope>
21
- <div use:transition={[fadeIn(), { scope: 'local' }]}>
22
- This will only animate when added/removed independently,
23
- not when the entire scope mounts/unmounts.
24
- </div>
25
- </TransitionScope>
26
- ```
27
- -->
28
- <div use:createTransitionScope style="display: contents;">
29
- {@render children()}
30
- </div>
@@ -1,6 +0,0 @@
1
- interface Props {
2
- children: () => any;
3
- }
4
- declare const TransitionScope: import("svelte").Component<Props, {}, "">;
5
- type TransitionScope = ReturnType<typeof TransitionScope>;
6
- export default TransitionScope;
@@ -1,17 +0,0 @@
1
- import { type Transition, type TransitionKey, type TransitionScope } from "@ssgoi/core";
2
- type TransitionParams = Transition<undefined> & {
3
- key: TransitionKey;
4
- scope?: TransitionScope;
5
- };
6
- /**
7
- * Svelte action for element transitions
8
- *
9
- * Uses Svelte's destroy callback for OUT transition detection.
10
- * This ensures the correct transition config is used even when
11
- * params are updated (e.g., during SvelteKit page navigation).
12
- */
13
- export declare const transition: (node: HTMLElement, params: TransitionParams) => {
14
- update(newParams: TransitionParams): void;
15
- destroy(): void;
16
- };
17
- export {};
@@ -1,33 +0,0 @@
1
- import { transition as _transition, } from "@ssgoi/core";
2
- /**
3
- * Svelte action for element transitions
4
- *
5
- * Uses Svelte's destroy callback for OUT transition detection.
6
- * This ensures the correct transition config is used even when
7
- * params are updated (e.g., during SvelteKit page navigation).
8
- */
9
- export var transition = function (node, params) {
10
- var callback = _transition({
11
- key: params.key,
12
- in: params.in,
13
- out: params.out,
14
- scope: params.scope,
15
- });
16
- var cleanup = callback(node);
17
- return {
18
- update: function (newParams) {
19
- callback = _transition({
20
- key: newParams.key,
21
- in: newParams.in,
22
- out: newParams.out,
23
- scope: newParams.scope,
24
- });
25
- cleanup = callback(node);
26
- },
27
- destroy: function () {
28
- // Call cleanup to trigger OUT transition with the correct config
29
- // The cleanup function captures the transition config at registration time
30
- cleanup === null || cleanup === void 0 ? void 0 : cleanup();
31
- },
32
- };
33
- };
@@ -1 +0,0 @@
1
- export * from "@ssgoi/core/transitions";
@@ -1 +0,0 @@
1
- export * from "@ssgoi/core/transitions";
@@ -1 +0,0 @@
1
- export * from "@ssgoi/core/view-transitions";
@@ -1 +0,0 @@
1
- export * from "@ssgoi/core/view-transitions";