@ssgoi/solid 7.4.0 → 7.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @ssgoi/solid
2
2
 
3
- Solid and SolidStart bindings for SSGOI.
3
+ Native app-like page transitions for Solid and SolidStart. Make a web app, PWA or WebView app (Capacitor, Tauri, Ionic) feel like a native app without replacing your router.
4
4
 
5
5
  [![SSGOI live showcase](https://ssgoi.dev/readme.png)](https://ssgoi.dev)
6
6
 
package/dist/context.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("solid-js"),t=o.createContext(null),s=t.Provider,r=()=>{const e=o.useContext(t);if(!e)throw new Error("useSsgoi must be used within SsgoiProvider");return e};exports.SsgoiProvider=s;exports.useSsgoi=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("solid-js"),s=e.createContext(null),r=s.Provider,u=()=>{const t=e.useContext(s);if(!t)throw new Error("useSsgoi must be used within SsgoiProvider");return t},c=()=>{const t=e.useContext(s);if(!t)throw new Error("useSsgoiTransition must be used within <Ssgoi>");const[o,i]=e.createSignal(t.getTransitionState());return e.onCleanup(t.subscribe(n=>i(()=>n))),o};exports.SsgoiProvider=r;exports.useSsgoi=u;exports.useSsgoiTransition=c;
package/dist/context.d.ts CHANGED
@@ -1,3 +1,14 @@
1
- import { SsgoiContext } from './types';
1
+ import { Accessor } from 'solid-js';
2
+ import { SsgoiContext, SsgoiTransitionState } from './types';
2
3
  export declare const SsgoiProvider: import('solid-js').ContextProviderComponent<SsgoiContext | null>;
3
4
  export declare const useSsgoi: () => SsgoiContext;
5
+ /**
6
+ * Signal of the provider's transition lifecycle: whether a page transition is
7
+ * preparing or playing, and which routes it joins.
8
+ *
9
+ * Use it to defer work that would fight the animation, such as a programmatic
10
+ * scroll on the arriving page, until the status returns to `"idle"`.
11
+ *
12
+ * Must be called under `<Ssgoi>`.
13
+ */
14
+ export declare const useSsgoiTransition: () => Accessor<SsgoiTransitionState>;
package/dist/context.js CHANGED
@@ -1,11 +1,18 @@
1
- import { createContext as e, useContext as r } from "solid-js";
2
- const t = e(null), n = t.Provider, i = () => {
3
- const o = r(t);
4
- if (!o)
1
+ import { createContext as i, useContext as o, createSignal as u, onCleanup as c } from "solid-js";
2
+ const e = i(null), S = e.Provider, g = () => {
3
+ const t = o(e);
4
+ if (!t)
5
5
  throw new Error("useSsgoi must be used within SsgoiProvider");
6
- return o;
6
+ return t;
7
+ }, w = () => {
8
+ const t = o(e);
9
+ if (!t)
10
+ throw new Error("useSsgoiTransition must be used within <Ssgoi>");
11
+ const [s, n] = u(t.getTransitionState());
12
+ return c(t.subscribe((r) => n(() => r))), s;
7
13
  };
8
14
  export {
9
- n as SsgoiProvider,
10
- i as useSsgoi
15
+ S as SsgoiProvider,
16
+ g as useSsgoi,
17
+ w as useSsgoiTransition
11
18
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ssgoi/core/types"),o=require("./ssgoi.cjs"),i=require("./ssgoi-transition.cjs"),r=require("@ssgoi/core");exports.Ssgoi=o.Ssgoi;exports.SsgoiTransition=i.SsgoiTransition;Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});Object.keys(r).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ssgoi/core/types"),o=require("./ssgoi.cjs"),i=require("./context.cjs"),s=require("./ssgoi-transition.cjs"),r=require("@ssgoi/core");exports.Ssgoi=o.Ssgoi;exports.useSsgoiTransition=i.useSsgoiTransition;exports.SsgoiTransition=s.SsgoiTransition;Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});Object.keys(r).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './types';
2
2
  export { Ssgoi } from './ssgoi';
3
+ export { useSsgoiTransition } from './context';
3
4
  /** @deprecated Set `data-ssgoi-transition` directly on an element inside `<Ssgoi>` instead. */
4
5
  export { SsgoiTransition } from './ssgoi-transition';
5
6
  export * from '@ssgoi/core';
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export * from "@ssgoi/core/types";
2
- import { Ssgoi as e } from "./ssgoi.js";
3
- import { SsgoiTransition as i } from "./ssgoi-transition.js";
2
+ import { Ssgoi as t } from "./ssgoi.js";
3
+ import { useSsgoiTransition as s } from "./context.js";
4
+ import { SsgoiTransition as m } from "./ssgoi-transition.js";
4
5
  export * from "@ssgoi/core";
5
6
  export {
6
- e as Ssgoi,
7
- i as SsgoiTransition
7
+ t as Ssgoi,
8
+ m as SsgoiTransition,
9
+ s as useSsgoiTransition
8
10
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ssgoi/solid",
3
- "version": "7.4.0",
4
- "description": "Solid.js bindings for SSGOI - Native app-like page transitions for Solid applications",
3
+ "version": "7.4.1",
4
+ "description": "Native app-like page transitions for Solid and SolidStart. Make a web app, PWA or WebView app feel native.",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "files": [
@@ -53,7 +53,7 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@ssgoi/core": "^7.4.0"
56
+ "@ssgoi/core": "^7.4.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@eslint/js": "^9.30.1",
@@ -76,10 +76,28 @@
76
76
  "keywords": [
77
77
  "solid",
78
78
  "solidjs",
79
+ "solid-router",
80
+ "solidstart",
79
81
  "page-transition",
82
+ "page-transitions",
83
+ "route-transition",
84
+ "navigation-animation",
85
+ "native-app",
86
+ "app-like",
87
+ "mobile-web",
88
+ "webview",
89
+ "pwa",
90
+ "capacitor",
91
+ "react-native-webview",
92
+ "hybrid-app",
93
+ "view-transitions",
94
+ "view-transition-api-alternative",
95
+ "shared-element-transition",
96
+ "hero-transition",
97
+ "spring-physics",
98
+ "web-animations",
80
99
  "animation",
81
- "ssgoi",
82
- "spring-physics"
100
+ "ssgoi"
83
101
  ],
84
102
  "author": "MeurSyphus <tmdeoans@snu.ac.kr>",
85
103
  "license": "MIT",
@@ -1,5 +1,11 @@
1
- import { createContext, useContext } from "solid-js";
2
- import type { SsgoiContext } from "./types";
1
+ import {
2
+ createContext,
3
+ createSignal,
4
+ onCleanup,
5
+ useContext,
6
+ type Accessor,
7
+ } from "solid-js";
8
+ import type { SsgoiContext, SsgoiTransitionState } from "./types";
3
9
 
4
10
  const SsgoiContextInstance = createContext<SsgoiContext | null>(null);
5
11
 
@@ -12,3 +18,24 @@ export const useSsgoi = () => {
12
18
  }
13
19
  return context;
14
20
  };
21
+
22
+ /**
23
+ * Signal of the provider's transition lifecycle: whether a page transition is
24
+ * preparing or playing, and which routes it joins.
25
+ *
26
+ * Use it to defer work that would fight the animation, such as a programmatic
27
+ * scroll on the arriving page, until the status returns to `"idle"`.
28
+ *
29
+ * Must be called under `<Ssgoi>`.
30
+ */
31
+ export const useSsgoiTransition = (): Accessor<SsgoiTransitionState> => {
32
+ const context = useContext(SsgoiContextInstance);
33
+ if (!context) {
34
+ throw new Error("useSsgoiTransition must be used within <Ssgoi>");
35
+ }
36
+ const [state, setState] = createSignal<SsgoiTransitionState>(
37
+ context.getTransitionState(),
38
+ );
39
+ onCleanup(context.subscribe((next) => setState(() => next)));
40
+ return state;
41
+ };
package/src/lib/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./types";
2
2
  export { Ssgoi } from "./ssgoi";
3
+ export { useSsgoiTransition } from "./context";
3
4
  /** @deprecated Set `data-ssgoi-transition` directly on an element inside `<Ssgoi>` instead. */
4
5
  export { SsgoiTransition } from "./ssgoi-transition";
5
6
  export * from "@ssgoi/core";