@ssgoi/react 6.2.0 → 6.4.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
@@ -45,17 +45,15 @@ export default function App() {
45
45
  }
46
46
  ```
47
47
 
48
- ### 2. Wrap your pages
48
+ ### 2. Mark your pages
49
49
 
50
50
  ```tsx
51
- import { SsgoiTransition } from "@ssgoi/react";
52
-
53
51
  export default function HomePage() {
54
52
  return (
55
- <SsgoiTransition id="/">
53
+ <main data-ssgoi-transition="/">
56
54
  <h1>Welcome</h1>
57
55
  {/* Page content */}
58
- </SsgoiTransition>
56
+ </main>
59
57
  );
60
58
  }
61
59
  ```
@@ -246,11 +244,8 @@ export default function RootLayout({ children }) {
246
244
  );
247
245
  }
248
246
 
249
- // app/page.tsx
250
- import { SsgoiTransition } from "@ssgoi/react";
251
-
252
247
  export default function Page() {
253
- return <SsgoiTransition id="/">{/* Your page content */}</SsgoiTransition>;
248
+ return <main data-ssgoi-transition="/">{/* Your page content */}</main>;
254
249
  }
255
250
  ```
256
251
 
@@ -266,12 +261,13 @@ The provider component that manages transition context.
266
261
  <Ssgoi config={ssgoiConfig}>{children}</Ssgoi>
267
262
  ```
268
263
 
269
- #### `<SsgoiTransition>`
264
+ #### `data-ssgoi-transition`
270
265
 
271
- Wrapper component for pages that should transition.
266
+ Attribute for pages that should transition. Set it on the page boundary element
267
+ inside `<Ssgoi>`.
272
268
 
273
269
  ```tsx
274
- <SsgoiTransition id="/page-id">{children}</SsgoiTransition>
270
+ <main data-ssgoi-transition="/page-id">{children}</main>
275
271
  ```
276
272
 
277
273
  ### Hooks
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),u=require("./context.cjs"),a=({children:o,id:t,as:e,className:n,...s})=>{const{refFor:i}=u.useSsgoi(),r=e||"div";return c.jsx(r,{ref:i(t),"data-ssgoi-transition":t,className:n,...s,children:o})};exports.SsgoiTransition=a;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),a=({children:t,id:i,as:n,className:o,...s})=>{const e=n||"div";return r.jsx(e,{"data-ssgoi-transition":i,className:o,...s,children:t})};exports.SsgoiTransition=a;
@@ -8,11 +8,8 @@ type SsgoiTransitionProps<T extends ElementType = "div"> = {
8
8
  /**
9
9
  * Marks a subtree as a Ssgoi page boundary.
10
10
  *
11
- * The ssgoi context hands out a stable, path-bound ref callback via
12
- * `refFor(id)` — the same function reference across renders for the same
13
- * id, so React doesn't see a fresh ref each commit and won't churn the
14
- * attach/detach cycle. Unmount is detected internally via the shared
15
- * MutationObserver in the dispatcher; nothing extra to wire up here.
11
+ * @deprecated Set `data-ssgoi-transition` directly on the page boundary
12
+ * element inside `<Ssgoi>` instead.
16
13
  */
17
14
  export declare const SsgoiTransition: <T extends ElementType = "div">({ children, id, as, className, ...rest }: SsgoiTransitionProps<T>) => import("react/jsx-runtime").JSX.Element;
18
15
  export {};
@@ -1,25 +1,12 @@
1
1
  "use client";
2
- import { jsx as e } from "react/jsx-runtime";
3
- import { useSsgoi as m } from "./context.js";
4
- const c = ({
5
- children: t,
6
- id: o,
7
- as: n,
8
- className: r,
2
+ import { jsx as r } from "react/jsx-runtime";
3
+ const m = ({
4
+ children: o,
5
+ id: n,
6
+ as: t,
7
+ className: i,
9
8
  ...s
10
- }) => {
11
- const { refFor: i } = m();
12
- return /* @__PURE__ */ e(
13
- n || "div",
14
- {
15
- ref: i(o),
16
- "data-ssgoi-transition": o,
17
- className: r,
18
- ...s,
19
- children: t
20
- }
21
- );
22
- };
9
+ }) => /* @__PURE__ */ r(t || "div", { "data-ssgoi-transition": n, className: i, ...s, children: o });
23
10
  export {
24
- c as SsgoiTransition
11
+ m as SsgoiTransition
25
12
  };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("react"),n=require("./context.cjs"),u=require("@ssgoi/core/internal"),c=o.memo(({config:e,host:t,children:r})=>{const i=o.useMemo(()=>u.createSggoiTransitionContext(e,{host:t}),[e,t]);return s.jsx(n.SsgoiProvider,{value:i,children:r})});exports.Ssgoi=c;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),e=require("react"),i=require("@ssgoi/core/internal"),a={display:"contents"},l=e.memo(({config:t,host:o,children:u})=>{const r=e.useRef(null),s=e.useMemo(()=>i.createSggoiTransitionContext(t,{host:o}),[t,o]);return e.useEffect(()=>{const n=r.current;if(n)return i.observeSsgoiTransitions(n,s)},[s]),c.jsx("div",{ref:r,"data-ssgoi-root":"",style:a,children:u})});exports.Ssgoi=l;
package/dist/lib/ssgoi.js CHANGED
@@ -1,17 +1,20 @@
1
1
  "use client";
2
- import { jsx as m } from "react/jsx-runtime";
3
- import i, { useMemo as s } from "react";
4
- import { SsgoiProvider as n } from "./context.js";
5
- import { createSggoiTransitionContext as p } from "@ssgoi/core/internal";
6
- const u = i.memo(
7
- ({ config: o, host: r, children: t }) => {
8
- const e = s(
9
- () => p(o, { host: r }),
10
- [o, r]
2
+ import { jsx as i } from "react/jsx-runtime";
3
+ import c, { useRef as m, useMemo as f, useEffect as u } from "react";
4
+ import { createSggoiTransitionContext as a, observeSsgoiTransitions as g } from "@ssgoi/core/internal";
5
+ const l = { display: "contents" }, x = c.memo(
6
+ ({ config: o, host: t, children: n }) => {
7
+ const r = m(null), e = f(
8
+ () => a(o, { host: t }),
9
+ [o, t]
11
10
  );
12
- return /* @__PURE__ */ m(n, { value: e, children: t });
11
+ return u(() => {
12
+ const s = r.current;
13
+ if (s)
14
+ return g(s, e);
15
+ }, [e]), /* @__PURE__ */ i("div", { ref: r, "data-ssgoi-root": "", style: l, children: n });
13
16
  }
14
17
  );
15
18
  export {
16
- u as Ssgoi
19
+ x as Ssgoi
17
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/react",
3
- "version": "6.2.0",
3
+ "version": "6.4.0",
4
4
  "description": "React bindings for SSGOI - Native app-like page transitions for React applications",
5
5
  "private": false,
6
6
  "type": "module",
@@ -66,7 +66,7 @@
66
66
  "dependencies": {
67
67
  "unplugin": "^2.3.2",
68
68
  "@babel/core": "^7.26.10",
69
- "@ssgoi/core": "^6.2.0"
69
+ "@ssgoi/core": "^6.4.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/babel__core": "^7.20.5",
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),t=o.createContext(null),r=t.Provider,s=()=>{const e=o.useContext(t);if(!e)throw new Error("useSsgoi must be used within Ssgoi provider");return e};exports.SsgoiProvider=r;exports.useSsgoi=s;
@@ -1,3 +0,0 @@
1
- import { SsgoiContext } from '@ssgoi/core/types';
2
- export declare const SsgoiProvider: import('react').Provider<SsgoiContext | null>;
3
- export declare const useSsgoi: () => SsgoiContext;
@@ -1,11 +0,0 @@
1
- "use client";
2
- import { createContext as e, useContext as r } from "react";
3
- const t = e(null), n = t.Provider, i = () => {
4
- const o = r(t);
5
- if (!o) throw new Error("useSsgoi must be used within Ssgoi provider");
6
- return o;
7
- };
8
- export {
9
- n as SsgoiProvider,
10
- i as useSsgoi
11
- };