@ssgoi/react 4.2.1 → 5.0.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function m(e){return("tick"in e||"css"in e)&&!("items"in e)}function a(e){return"items"in e}function f(e){return"css"in e&&typeof e.css=="function"}function p(e){return"tick"in e&&typeof e.tick=="function"}async function d(e){const t=await e;return a(t)?{prepare:t.prepare,wait:t.wait,onStart:t.onStart,onEnd:t.onEnd,items:t.items,schedule:t.schedule}:{prepare:t.prepare,wait:t.wait,onStart:t.onStart,onEnd:t.onEnd,items:[{physics:t.physics,tick:t.tick,css:t.css}],schedule:"parallel"}}function h(e,t){const c=e.schedule??"parallel",o=e.items.map(s=>{let n;switch(c){case"parallel":n=0;break;case"sequential":n=1;break;case"stagger":n=Math.max(0,Math.min(1,s.offset??0));break;default:n=0}const{css:i,offset:k,...l}=s,u=i?typeof i=="function"?t?{element:t,style:i}:void 0:{element:i.element,style:i.style}:void 0;return{...l,css:u,normalizedOffset:n}}),{schedule:y,...r}=e;return{...r,items:o}}exports.isCssAnimation=f;exports.isMultiAnimation=a;exports.isSingleAnimation=m;exports.isTickAnimation=p;exports.normalizeSchedule=h;exports.normalizeToMultiAnimation=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function m(n){return("tick"in n||"css"in n)&&!("items"in n)}function a(n){return"items"in n}function d(n){return"css"in n&&typeof n.css=="function"}function f(n){return"tick"in n&&typeof n.tick=="function"}async function p(n){const e=await n;return a(e)?{prepare:e.prepare,wait:e.wait,onReady:e.onReady,onStart:e.onStart,onEnd:e.onEnd,items:e.items,schedule:e.schedule}:{prepare:e.prepare,wait:e.wait,onReady:e.onReady,onStart:e.onStart,onEnd:e.onEnd,items:[{physics:e.physics,tick:e.tick,css:e.css}],schedule:"parallel"}}function y(n,e){const o=n.schedule??"parallel",c=n.items.map(s=>{let t;switch(o){case"parallel":t=0;break;case"sequential":t=1;break;case"stagger":t=Math.max(0,Math.min(1,s.offset??0));break;default:t=0}const{css:i,offset:k,...l}=s,u=i?typeof i=="function"?e?{element:e,style:i}:void 0:{element:i.element,style:i.style}:void 0;return{...l,css:u,normalizedOffset:t}}),{schedule:h,...r}=n;return{...r,items:c}}exports.isCssAnimation=d;exports.isMultiAnimation=a;exports.isSingleAnimation=m;exports.isTickAnimation=f;exports.normalizeSchedule=y;exports.normalizeToMultiAnimation=p;
@@ -1,41 +1,43 @@
1
- function p(e) {
2
- return ("tick" in e || "css" in e) && !("items" in e);
1
+ function d(n) {
2
+ return ("tick" in n || "css" in n) && !("items" in n);
3
3
  }
4
- function u(e) {
5
- return "items" in e;
4
+ function u(n) {
5
+ return "items" in n;
6
6
  }
7
- function d(e) {
8
- return "css" in e && typeof e.css == "function";
7
+ function p(n) {
8
+ return "css" in n && typeof n.css == "function";
9
9
  }
10
- function h(e) {
11
- return "tick" in e && typeof e.tick == "function";
10
+ function y(n) {
11
+ return "tick" in n && typeof n.tick == "function";
12
12
  }
13
- async function k(e) {
14
- const n = await e;
15
- return u(n) ? {
16
- prepare: n.prepare,
17
- wait: n.wait,
18
- onStart: n.onStart,
19
- onEnd: n.onEnd,
20
- items: n.items,
21
- schedule: n.schedule
13
+ async function h(n) {
14
+ const e = await n;
15
+ return u(e) ? {
16
+ prepare: e.prepare,
17
+ wait: e.wait,
18
+ onReady: e.onReady,
19
+ onStart: e.onStart,
20
+ onEnd: e.onEnd,
21
+ items: e.items,
22
+ schedule: e.schedule
22
23
  } : {
23
- prepare: n.prepare,
24
- wait: n.wait,
25
- onStart: n.onStart,
26
- onEnd: n.onEnd,
24
+ prepare: e.prepare,
25
+ wait: e.wait,
26
+ onReady: e.onReady,
27
+ onStart: e.onStart,
28
+ onEnd: e.onEnd,
27
29
  items: [
28
30
  {
29
- physics: n.physics,
30
- tick: n.tick,
31
- css: n.css
31
+ physics: e.physics,
32
+ tick: e.tick,
33
+ css: e.css
32
34
  }
33
35
  ],
34
36
  schedule: "parallel"
35
37
  };
36
38
  }
37
- function y(e, n) {
38
- const a = e.schedule ?? "parallel", c = e.items.map(
39
+ function k(n, e) {
40
+ const a = n.schedule ?? "parallel", o = n.items.map(
39
41
  (s) => {
40
42
  let t;
41
43
  switch (a) {
@@ -51,20 +53,20 @@ function y(e, n) {
51
53
  default:
52
54
  t = 0;
53
55
  }
54
- const { css: i, offset: f, ...r } = s, l = i ? typeof i == "function" ? n ? { element: n, style: i } : void 0 : { element: i.element, style: i.style } : void 0;
56
+ const { css: i, offset: f, ...r } = s, l = i ? typeof i == "function" ? e ? { element: e, style: i } : void 0 : { element: i.element, style: i.style } : void 0;
55
57
  return { ...r, css: l, normalizedOffset: t };
56
58
  }
57
- ), { schedule: m, ...o } = e;
59
+ ), { schedule: m, ...c } = n;
58
60
  return {
59
- ...o,
60
- items: c
61
+ ...c,
62
+ items: o
61
63
  };
62
64
  }
63
65
  export {
64
- d as isCssAnimation,
66
+ p as isCssAnimation,
65
67
  u as isMultiAnimation,
66
- p as isSingleAnimation,
67
- h as isTickAnimation,
68
- y as normalizeSchedule,
69
- k as normalizeToMultiAnimation
68
+ d as isSingleAnimation,
69
+ y as isTickAnimation,
70
+ k as normalizeSchedule,
71
+ h as normalizeToMultiAnimation
70
72
  };
@@ -3,13 +3,6 @@ import { SsgoiConfig } from './types';
3
3
  interface SsgoiProps {
4
4
  config: SsgoiConfig;
5
5
  children: ReactNode;
6
- /**
7
- * Hook to get current pathname (e.g., Next.js usePathname)
8
- * @example
9
- * import { usePathname } from 'next/navigation';
10
- * <Ssgoi config={config} usePathname={usePathname}>
11
- */
12
- usePathname?: () => string;
13
6
  }
14
7
  export declare const Ssgoi: React.FC<SsgoiProps>;
15
8
  export {};
@@ -1,23 +1,5 @@
1
- import { CSSProperties } from 'react';
2
1
  import { SsgoiContext } from '@ssgoi/core/types';
3
2
  export * from '@ssgoi/core/types';
4
- /**
5
- * Navigation info containing from/to paths
6
- */
7
- export type NavigationInfo = {
8
- from: string | null;
9
- to: string;
10
- };
11
- /**
12
- * React-specific context type with style control
13
- */
14
3
  export type ReactSsgoiContext = {
15
- /** Get transition config for a path */
16
4
  getTransition: SsgoiContext;
17
- /**
18
- * Get initial style for an element
19
- * Returns { visibility: "hidden" } on first call if transition is configured, {} otherwise
20
- * Subsequent calls always return {} to prevent re-hiding on rerender
21
- */
22
- getInitialStyle: () => CSSProperties;
23
5
  };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),e=require("react"),T=require("./transition.cjs"),j=require("./context.cjs"),f=require("./utils.cjs"),x=({children:a,id:s,as:R,className:m,...g})=>{const{getTransition:S,getInitialStyle:y}=j.useSsgoi(),b=R||"div",n=e.useRef(null),i=e.useRef(!0),t=e.useRef(null);t.current===null&&(t.current=y());let r;i.current?r=t.current:n.current&&t.current&&(r=f.forkStyleFromElement(n.current,t.current));const o=e.useCallback(l=>{n.current=l,l&&(i.current=!1)},[]),c=S(s),u=e.useMemo(()=>T.transition(c),[c]),d=e.useMemo(()=>f.combineRefs(o,u),[o,u]);return q.jsx(b,{ref:d,"data-ssgoi-transition":s,className:m,style:r,...g,children:a})};exports.SsgoiTransition=x;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),g=require("react"),S=require("./transition.cjs"),f=require("./context.cjs"),m=({children:o,id:t,as:i,className:s,...e})=>{const{getTransition:r}=f.useSsgoi(),a=i||"div",n=r(t),c=g.useMemo(()=>S.transition(n),[n]);return u.jsx(a,{ref:c,"data-ssgoi-transition":t,className:s,...e,children:o})};exports.SsgoiTransition=m;
@@ -1,44 +1,30 @@
1
1
  "use client";
2
- import { jsx as d } from "react/jsx-runtime";
3
- import { useRef as r, useCallback as C, useMemo as u } from "react";
4
- import { transition as k } from "./transition.js";
5
- import { useSsgoi as x } from "./context.js";
6
- import { forkStyleFromElement as E, combineRefs as F } from "./utils.js";
7
- const h = ({
8
- children: m,
2
+ import { jsx as f } from "react/jsx-runtime";
3
+ import { useMemo as p } from "react";
4
+ import { transition as c } from "./transition.js";
5
+ import { useSsgoi as g } from "./context.js";
6
+ const T = ({
7
+ children: n,
9
8
  id: o,
10
- as: a,
11
- className: R,
12
- ...p
9
+ as: i,
10
+ className: r,
11
+ ...s
13
12
  }) => {
14
- const { getTransition: g, getInitialStyle: S } = x(), y = a || "div", e = r(null), i = r(!0), t = r(null);
15
- t.current === null && (t.current = S());
16
- let n;
17
- i.current ? n = t.current : e.current && t.current && (n = E(
18
- e.current,
19
- t.current
20
- ));
21
- const s = C((l) => {
22
- e.current = l, l && (i.current = !1);
23
- }, []), c = g(o), f = u(
24
- () => k(c),
25
- [c]
26
- ), b = u(
27
- () => F(s, f),
28
- [s, f]
13
+ const { getTransition: m } = g(), e = i || "div", t = m(o), a = p(
14
+ () => c(t),
15
+ [t]
29
16
  );
30
- return /* @__PURE__ */ d(
31
- y,
17
+ return /* @__PURE__ */ f(
18
+ e,
32
19
  {
33
- ref: b,
20
+ ref: a,
34
21
  "data-ssgoi-transition": o,
35
- className: R,
36
- style: n,
37
- ...p,
38
- children: m
22
+ className: r,
23
+ ...s,
24
+ children: n
39
25
  }
40
26
  );
41
27
  };
42
28
  export {
43
- h as SsgoiTransition
29
+ T as SsgoiTransition
44
30
  };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),o=require("react"),v=require("./context.cjs"),s=require("@ssgoi/core");function R(t){const n=o.useRef(null),e=o.useRef(null);t!==null&&n.current!==t&&(e.current=n.current,n.current=t);const r=o.useRef({from:null,to:""});return t!==null&&(r.current={from:e.current,to:t}),o.useCallback(()=>r.current,[])}function S(t){return{trigger(){},get(n){const{from:e,to:r}=t();return!e||!r||e===r?Promise.resolve(null):Promise.resolve({from:e,to:r})}}}const y=o.memo(({config:t,children:n,usePathname:e})=>{const r=e?.()??null,i=R(r),l=o.useMemo(()=>{const{getTransition:g,hasMatchingTransition:f}=s.createSggoiTransitionContext(t,{createNavigationDetector:e?()=>S(i):s.createAnyOrderDetector});return{getTransition:g,getInitialStyle:()=>{if(!e)return{};const{from:u,to:c}=i();return!u||u===c?{}:f(u,c)?{visibility:"hidden"}:{}}}},[t,e,i]);return a.jsx(v.SsgoiProvider,{value:l,children:n})});exports.Ssgoi=y;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("react"),i=require("./context.cjs"),n=require("@ssgoi/core"),u=t.memo(({config:e,children:o})=>{const r=t.useMemo(()=>({getTransition:n.createSggoiTransitionContext(e,{outFirst:!1})}),[e]);return s.jsx(i.SsgoiProvider,{value:r,children:o})});exports.Ssgoi=u;
@@ -1,43 +1,21 @@
1
1
  "use client";
2
- import { jsx as g } from "react/jsx-runtime";
3
- import a, { useMemo as m, useRef as c, useCallback as v } from "react";
4
- import { SsgoiProvider as y } from "./context.js";
5
- import { createSggoiTransitionContext as R, createAnyOrderDetector as S } from "@ssgoi/core";
6
- function d(t) {
7
- const n = c(null), r = c(null);
8
- t !== null && n.current !== t && (r.current = n.current, n.current = t);
9
- const e = c({ from: null, to: "" });
10
- return t !== null && (e.current = { from: r.current, to: t }), v(() => e.current, []);
11
- }
12
- function p(t) {
13
- return {
14
- trigger() {
15
- },
16
- get(n) {
17
- const { from: r, to: e } = t();
18
- return !r || !e || r === e ? Promise.resolve(null) : Promise.resolve({ from: r, to: e });
19
- }
20
- };
21
- }
22
- const C = a.memo(
23
- ({ config: t, children: n, usePathname: r }) => {
24
- const e = r?.() ?? null, o = d(e), l = m(() => {
25
- const { getTransition: s, hasMatchingTransition: f } = R(t, {
26
- createNavigationDetector: r ? () => p(o) : S
27
- });
28
- return {
29
- getTransition: s,
30
- getInitialStyle: () => {
31
- if (!r)
32
- return {};
33
- const { from: i, to: u } = o();
34
- return !i || i === u ? {} : f(i, u) ? { visibility: "hidden" } : {};
35
- }
36
- };
37
- }, [t, r, o]);
38
- return /* @__PURE__ */ g(y, { value: l, children: n });
2
+ import { jsx as e } from "react/jsx-runtime";
3
+ import i, { useMemo as m } from "react";
4
+ import { SsgoiProvider as s } from "./context.js";
5
+ import { createSggoiTransitionContext as n } from "@ssgoi/core";
6
+ const f = i.memo(
7
+ ({ config: o, children: t }) => {
8
+ const r = m(
9
+ () => ({
10
+ getTransition: n(o, {
11
+ outFirst: !1
12
+ })
13
+ }),
14
+ [o]
15
+ );
16
+ return /* @__PURE__ */ e(s, { value: r, children: t });
39
17
  }
40
18
  );
41
19
  export {
42
- C as Ssgoi
20
+ f as Ssgoi
43
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/react",
3
- "version": "4.2.1",
3
+ "version": "5.0.0",
4
4
  "description": "React bindings for SSGOI - Native app-like page transitions for React applications",
5
5
  "private": false,
6
6
  "type": "module",
@@ -78,7 +78,7 @@
78
78
  "dependencies": {
79
79
  "unplugin": "^2.3.2",
80
80
  "@babel/core": "^7.26.10",
81
- "@ssgoi/core": "^4.2.0"
81
+ "@ssgoi/core": "^5.0.0"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@types/babel__core": "^7.20.5",
@@ -100,9 +100,20 @@
100
100
  "keywords": [
101
101
  "react",
102
102
  "page-transition",
103
+ "page-transitions",
104
+ "view-transitions",
105
+ "view-transition-api-alternative",
103
106
  "animation",
104
107
  "ssgoi",
105
- "spring-physics"
108
+ "spring-physics",
109
+ "nextjs",
110
+ "next-js",
111
+ "cross-browser",
112
+ "navigation-animation",
113
+ "hero-transition",
114
+ "shared-element-transition",
115
+ "route-transition",
116
+ "drill-transition"
106
117
  ],
107
118
  "author": "MeurSyphus <tmdeoans@snu.ac.kr>",
108
119
  "license": "MIT",
@@ -1,10 +0,0 @@
1
- import { CSSProperties } from 'react';
2
- /**
3
- * Combines multiple ref callbacks into one
4
- */
5
- export declare function combineRefs<T>(...refs: Array<((el: T | null) => void) | null | undefined>): (el: T | null) => void;
6
- /**
7
- * Forks style from element.style based on initialStyle keys
8
- * Returns the current DOM style values for keys that were in initialStyle
9
- */
10
- export declare function forkStyleFromElement(element: HTMLElement, initialStyle: CSSProperties): CSSProperties;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function f(...t){return o=>{t.forEach(e=>e?.(o))}}function c(t,o){const e={};for(const n of Object.keys(o)){const r=t.style[n];r&&(e[n]=r)}return e}exports.combineRefs=f;exports.forkStyleFromElement=c;
@@ -1,17 +0,0 @@
1
- function f(...o) {
2
- return (t) => {
3
- o.forEach((e) => e?.(t));
4
- };
5
- }
6
- function c(o, t) {
7
- const e = {};
8
- for (const n of Object.keys(t)) {
9
- const r = o.style[n];
10
- r && (e[n] = r);
11
- }
12
- return e;
13
- }
14
- export {
15
- f as combineRefs,
16
- c as forkStyleFromElement
17
- };