@ssgoi/react 4.0.0 → 4.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/dist/core/dist/types.cjs +1 -1
- package/dist/core/dist/types.js +40 -47
- package/dist/index.cjs +1 -1
- package/dist/index.js +12 -14
- package/dist/lib/context.d.ts +3 -3
- package/dist/lib/create-pathname-detector.d.ts +6 -0
- package/dist/lib/ssgoi-transition.d.ts +3 -2
- package/dist/lib/ssgoi.d.ts +6 -0
- package/dist/lib/types.d.ts +14 -0
- package/dist/react/src/lib/create-pathname-detector.cjs +1 -0
- package/dist/react/src/lib/create-pathname-detector.js +24 -0
- package/dist/react/src/lib/ssgoi-transition.cjs +1 -1
- package/dist/react/src/lib/ssgoi-transition.js +16 -14
- package/dist/react/src/lib/ssgoi.cjs +1 -1
- package/dist/react/src/lib/ssgoi.js +33 -16
- package/dist/types.cjs +1 -1
- package/dist/types.js +7 -9
- package/package.json +2 -2
package/dist/core/dist/types.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
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;
|
package/dist/core/dist/types.js
CHANGED
|
@@ -1,49 +1,44 @@
|
|
|
1
|
-
function
|
|
2
|
-
return ("tick" in
|
|
1
|
+
function p(e) {
|
|
2
|
+
return ("tick" in e || "css" in e) && !("items" in e);
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return "
|
|
4
|
+
function u(e) {
|
|
5
|
+
return "items" in e;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return "css" in
|
|
7
|
+
function d(e) {
|
|
8
|
+
return "css" in e && typeof e.css == "function";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return "tick" in
|
|
10
|
+
function h(e) {
|
|
11
|
+
return "tick" in e && typeof e.tick == "function";
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
prepare: e.prepare,
|
|
29
|
-
wait: e.wait,
|
|
30
|
-
onStart: e.onStart,
|
|
31
|
-
onEnd: e.onEnd,
|
|
32
|
-
springs: [
|
|
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
|
|
22
|
+
} : {
|
|
23
|
+
prepare: n.prepare,
|
|
24
|
+
wait: n.wait,
|
|
25
|
+
onStart: n.onStart,
|
|
26
|
+
onEnd: n.onEnd,
|
|
27
|
+
items: [
|
|
33
28
|
{
|
|
34
|
-
physics:
|
|
35
|
-
tick:
|
|
36
|
-
css:
|
|
29
|
+
physics: n.physics,
|
|
30
|
+
tick: n.tick,
|
|
31
|
+
css: n.css
|
|
37
32
|
}
|
|
38
33
|
],
|
|
39
34
|
schedule: "parallel"
|
|
40
|
-
}
|
|
35
|
+
};
|
|
41
36
|
}
|
|
42
|
-
function y(
|
|
43
|
-
const
|
|
37
|
+
function y(e, n) {
|
|
38
|
+
const a = e.schedule ?? "parallel", c = e.items.map(
|
|
44
39
|
(s) => {
|
|
45
40
|
let t;
|
|
46
|
-
switch (
|
|
41
|
+
switch (a) {
|
|
47
42
|
case "parallel":
|
|
48
43
|
t = 0;
|
|
49
44
|
break;
|
|
@@ -56,22 +51,20 @@ function y(n, e) {
|
|
|
56
51
|
default:
|
|
57
52
|
t = 0;
|
|
58
53
|
}
|
|
59
|
-
const { css: i, offset:
|
|
60
|
-
return { ...
|
|
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;
|
|
55
|
+
return { ...r, css: l, normalizedOffset: t };
|
|
61
56
|
}
|
|
62
|
-
), { schedule:
|
|
57
|
+
), { schedule: m, ...o } = e;
|
|
63
58
|
return {
|
|
64
59
|
...o,
|
|
65
|
-
|
|
60
|
+
items: c
|
|
66
61
|
};
|
|
67
62
|
}
|
|
68
63
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
y as
|
|
74
|
-
|
|
75
|
-
h as validateAnimationMode,
|
|
76
|
-
d as validateSpringItem
|
|
64
|
+
d as isCssAnimation,
|
|
65
|
+
u as isMultiAnimation,
|
|
66
|
+
p as isSingleAnimation,
|
|
67
|
+
h as isTickAnimation,
|
|
68
|
+
y as normalizeSchedule,
|
|
69
|
+
k as normalizeToMultiAnimation
|
|
77
70
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./react/src/lib/transition.cjs"),i=require("./core/dist/types.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./react/src/lib/transition.cjs"),i=require("./core/dist/types.cjs"),o=require("./react/src/lib/ssgoi.cjs"),t=require("./react/src/lib/ssgoi-transition.cjs"),s=require("./react/src/lib/transition-scope.cjs");exports.transition=n.transition;exports.isCssAnimation=i.isCssAnimation;exports.isMultiAnimation=i.isMultiAnimation;exports.isSingleAnimation=i.isSingleAnimation;exports.isTickAnimation=i.isTickAnimation;exports.normalizeSchedule=i.normalizeSchedule;exports.normalizeToMultiAnimation=i.normalizeToMultiAnimation;exports.Ssgoi=o.Ssgoi;exports.SsgoiTransition=t.SsgoiTransition;exports.TransitionScope=s.TransitionScope;
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { transition as n } from "./react/src/lib/transition.js";
|
|
2
|
-
import { isCssAnimation as
|
|
2
|
+
import { isCssAnimation as r, isMultiAnimation as m, isSingleAnimation as e, isTickAnimation as s, normalizeSchedule as a, normalizeToMultiAnimation as l } from "./core/dist/types.js";
|
|
3
3
|
import { Ssgoi as f } from "./react/src/lib/ssgoi.js";
|
|
4
|
-
import { SsgoiTransition as
|
|
5
|
-
import { TransitionScope as
|
|
4
|
+
import { SsgoiTransition as A } from "./react/src/lib/ssgoi-transition.js";
|
|
5
|
+
import { TransitionScope as T } from "./react/src/lib/transition-scope.js";
|
|
6
6
|
export {
|
|
7
7
|
f as Ssgoi,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
n as transition
|
|
17
|
-
S as validateAnimationMode,
|
|
18
|
-
l as validateSpringItem
|
|
8
|
+
A as SsgoiTransition,
|
|
9
|
+
T as TransitionScope,
|
|
10
|
+
r as isCssAnimation,
|
|
11
|
+
m as isMultiAnimation,
|
|
12
|
+
e as isSingleAnimation,
|
|
13
|
+
s as isTickAnimation,
|
|
14
|
+
a as normalizeSchedule,
|
|
15
|
+
l as normalizeToMultiAnimation,
|
|
16
|
+
n as transition
|
|
19
17
|
};
|
package/dist/lib/context.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const SsgoiProvider: import('react').Provider<
|
|
3
|
-
export declare const useSsgoi: () =>
|
|
1
|
+
import { ReactSsgoiContext } from './types';
|
|
2
|
+
export declare const SsgoiProvider: import('react').Provider<ReactSsgoiContext | null>;
|
|
3
|
+
export declare const useSsgoi: () => ReactSsgoiContext;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NavigationDetector } from '@ssgoi/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a NavigationDetector based on pathname changes
|
|
4
|
+
* Uses getPathname() to detect navigation without relying on IN/OUT callbacks
|
|
5
|
+
*/
|
|
6
|
+
export declare function createPathnameDetector(getPathname: () => string): NavigationDetector;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ReactNode, ElementType } from 'react';
|
|
1
|
+
import { ReactNode, ElementType, CSSProperties } from 'react';
|
|
2
2
|
type SsgoiTransitionProps<T extends ElementType = "div"> = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
id: string;
|
|
5
5
|
as?: T;
|
|
6
6
|
className?: string;
|
|
7
|
+
style?: CSSProperties;
|
|
7
8
|
};
|
|
8
|
-
export declare const SsgoiTransition: <T extends ElementType = "div">({ children, id, as, className, ...rest }: SsgoiTransitionProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const SsgoiTransition: <T extends ElementType = "div">({ children, id, as, className, style, ...rest }: SsgoiTransitionProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export {};
|
package/dist/lib/ssgoi.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import { SsgoiConfig } from './types';
|
|
|
3
3
|
interface SsgoiProps {
|
|
4
4
|
config: SsgoiConfig;
|
|
5
5
|
children: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Function to get current pathname
|
|
8
|
+
* Used to determine initial style and navigation detection
|
|
9
|
+
* @example Next.js: () => usePathname()
|
|
10
|
+
*/
|
|
11
|
+
getPathname?: () => string;
|
|
6
12
|
}
|
|
7
13
|
export declare const Ssgoi: React.FC<SsgoiProps>;
|
|
8
14
|
export {};
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { SsgoiContext } from '@ssgoi/core/types';
|
|
1
3
|
export * from '@ssgoi/core/types';
|
|
4
|
+
/**
|
|
5
|
+
* React-specific context type with style control
|
|
6
|
+
*/
|
|
7
|
+
export type ReactSsgoiContext = {
|
|
8
|
+
/** Get transition config for a path */
|
|
9
|
+
getTransition: SsgoiContext;
|
|
10
|
+
/**
|
|
11
|
+
* Get initial style for an element
|
|
12
|
+
* Returns { visibility: "hidden" } if transition is configured, {} otherwise
|
|
13
|
+
*/
|
|
14
|
+
getInitialStyle: (path: string) => CSSProperties;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(o){let e=null,t=null,r=!1,l=!1;return{trigger(){},get(u){const n=o();if(!t||r&&l){if(!e||e===n)return e=n,Promise.resolve(null);t={from:e,to:n},r=!1,l=!1}u==="out"?r=!0:l=!0;const a=t;return r&&l&&(e=n,t=null),Promise.resolve(a)}}}exports.createPathnameDetector=s;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function s(u) {
|
|
2
|
+
let e = null, t = null, r = !1, l = !1;
|
|
3
|
+
return {
|
|
4
|
+
trigger() {
|
|
5
|
+
},
|
|
6
|
+
get(o) {
|
|
7
|
+
const n = u();
|
|
8
|
+
if (!t || r && l) {
|
|
9
|
+
if (!e || e === n)
|
|
10
|
+
return e = n, Promise.resolve(null);
|
|
11
|
+
t = {
|
|
12
|
+
from: e,
|
|
13
|
+
to: n
|
|
14
|
+
}, r = !1, l = !1;
|
|
15
|
+
}
|
|
16
|
+
o === "out" ? r = !0 : l = !0;
|
|
17
|
+
const a = t;
|
|
18
|
+
return r && l && (e = n, t = null), Promise.resolve(a);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
s as createPathnameDetector
|
|
24
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),l=require("./transition.cjs"),S=require("./context.cjs"),y=({children:n,id:t,as:i,className:e,style:o,...s})=>{const{getTransition:r,getInitialStyle:a}=S.useSsgoi(),c=i||"div",u=a(t);return g.jsx(c,{ref:l.transition(r(t)),"data-ssgoi-transition":t,className:e,style:{...o,...u},...s,children:n})};exports.SsgoiTransition=y;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { transition as
|
|
4
|
-
import { useSsgoi as
|
|
2
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
3
|
+
import { transition as p } from "./transition.js";
|
|
4
|
+
import { useSsgoi as c } from "./context.js";
|
|
5
5
|
const u = ({
|
|
6
|
-
children:
|
|
7
|
-
id:
|
|
8
|
-
as:
|
|
9
|
-
className:
|
|
6
|
+
children: o,
|
|
7
|
+
id: t,
|
|
8
|
+
as: i,
|
|
9
|
+
className: n,
|
|
10
|
+
style: s,
|
|
10
11
|
...r
|
|
11
12
|
}) => {
|
|
12
|
-
const
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
|
|
13
|
+
const { getTransition: e, getInitialStyle: a } = c(), m = i || "div", g = a(t);
|
|
14
|
+
return /* @__PURE__ */ l(
|
|
15
|
+
m,
|
|
15
16
|
{
|
|
16
|
-
ref: e(
|
|
17
|
-
"data-ssgoi-transition":
|
|
18
|
-
className:
|
|
17
|
+
ref: p(e(t)),
|
|
18
|
+
"data-ssgoi-transition": t,
|
|
19
|
+
className: n,
|
|
20
|
+
style: { ...s, ...g },
|
|
19
21
|
...r,
|
|
20
|
-
children:
|
|
22
|
+
children: o
|
|
21
23
|
}
|
|
22
24
|
);
|
|
23
25
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),n=require("react"),g=require("./context.cjs"),i=require("@ssgoi/core"),d=require("./create-pathname-detector.cjs"),m=n.memo(({config:o,children:c,getPathname:e})=>{const t=n.useRef(null),s=n.useMemo(()=>{const{getTransition:u,hasMatchingTransition:a}=i.createSggoiTransitionContext(o,{outFirst:!1,createNavigationDetector:e?()=>d.createPathnameDetector(e):i.createAnyOrderDetector});return{getTransition:u,getInitialStyle:l=>{if(!e)return{};const r=e();if(!t.current||t.current===r)return t.current=r,{};const S=t.current;return t.current=r,a(S,l)?{visibility:"hidden"}:{}}}},[o,e]);return f.jsx(g.SsgoiProvider,{value:s,children:c})});exports.Ssgoi=m;
|
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { SsgoiProvider as
|
|
5
|
-
import { createSggoiTransitionContext as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import f, { useRef as l, useMemo as p } from "react";
|
|
4
|
+
import { SsgoiProvider as v } from "./context.js";
|
|
5
|
+
import { createSggoiTransitionContext as S, createAnyOrderDetector as d } from "@ssgoi/core";
|
|
6
|
+
import { createPathnameDetector as g } from "./create-pathname-detector.js";
|
|
7
|
+
const I = f.memo(
|
|
8
|
+
({ config: o, children: n, getPathname: r }) => {
|
|
9
|
+
const t = l(null), i = p(() => {
|
|
10
|
+
const { getTransition: c, hasMatchingTransition: s } = S(o, {
|
|
11
|
+
// React uses MutationObserver for unmount detection,
|
|
12
|
+
// so OUT and IN can arrive in any order
|
|
13
|
+
outFirst: !1,
|
|
14
|
+
// Use pathname-based detector when getPathname is provided,
|
|
15
|
+
// otherwise use default any-order detector for React
|
|
16
|
+
createNavigationDetector: r ? () => g(r) : d
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
getTransition: c,
|
|
20
|
+
getInitialStyle: (u) => {
|
|
21
|
+
if (!r)
|
|
22
|
+
return {};
|
|
23
|
+
const e = r();
|
|
24
|
+
if (!t.current || t.current === e)
|
|
25
|
+
return t.current = e, {};
|
|
26
|
+
const a = t.current;
|
|
27
|
+
return t.current = e, s(a, u) ? { visibility: "hidden" } : {};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}, [o, r]);
|
|
31
|
+
return /* @__PURE__ */ m(v, { value: i, children: n });
|
|
32
|
+
}
|
|
33
|
+
);
|
|
17
34
|
export {
|
|
18
|
-
|
|
35
|
+
I as Ssgoi
|
|
19
36
|
};
|
package/dist/types.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./core/dist/types.cjs");exports.isCssAnimation=i.isCssAnimation;exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./core/dist/types.cjs");exports.isCssAnimation=i.isCssAnimation;exports.isMultiAnimation=i.isMultiAnimation;exports.isSingleAnimation=i.isSingleAnimation;exports.isTickAnimation=i.isTickAnimation;exports.normalizeSchedule=i.normalizeSchedule;exports.normalizeToMultiAnimation=i.normalizeToMultiAnimation;
|
package/dist/types.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { isCssAnimation as
|
|
1
|
+
import { isCssAnimation as o, isMultiAnimation as m, isSingleAnimation as t, isTickAnimation as a, normalizeSchedule as e, normalizeToMultiAnimation as l } from "./core/dist/types.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
m as validateAnimationMode,
|
|
10
|
-
S as validateSpringItem
|
|
3
|
+
o as isCssAnimation,
|
|
4
|
+
m as isMultiAnimation,
|
|
5
|
+
t as isSingleAnimation,
|
|
6
|
+
a as isTickAnimation,
|
|
7
|
+
e as normalizeSchedule,
|
|
8
|
+
l as normalizeToMultiAnimation
|
|
11
9
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssgoi/react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.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.
|
|
81
|
+
"@ssgoi/core": "^4.2.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@types/babel__core": "^7.20.5",
|