@ssgoi/react 7.0.3 → 7.1.0-beta.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/lib/nextjs/selected-segments-to-path.cjs +1 -0
- package/dist/lib/nextjs/selected-segments-to-path.d.ts +6 -0
- package/dist/lib/nextjs/selected-segments-to-path.js +8 -0
- package/dist/lib/nextjs/ssgoi-route-boundary.cjs +2 -0
- package/dist/lib/nextjs/ssgoi-route-boundary.d.ts +15 -0
- package/dist/lib/nextjs/ssgoi-route-boundary.js +24 -0
- package/dist/lib/nextjs.d.ts +4 -0
- package/dist/lib/react-router/ssgoi-route-boundary.cjs +2 -0
- package/dist/lib/react-router/ssgoi-route-boundary.d.ts +5 -0
- package/dist/lib/react-router/ssgoi-route-boundary.js +14 -0
- package/dist/lib/react-router.d.ts +3 -0
- package/dist/lib/route-boundary.cjs +2 -0
- package/dist/lib/route-boundary.d.ts +22 -0
- package/dist/lib/route-boundary.js +22 -0
- package/dist/lib/tanstack-router/ssgoi-route-boundary.cjs +2 -0
- package/dist/lib/tanstack-router/ssgoi-route-boundary.d.ts +4 -0
- package/dist/lib/tanstack-router/ssgoi-route-boundary.js +16 -0
- package/dist/lib/tanstack-router.d.ts +3 -0
- package/dist/nextjs.cjs +2 -0
- package/dist/nextjs.d.ts +2 -0
- package/dist/nextjs.js +7 -0
- package/dist/react-router.cjs +2 -0
- package/dist/react-router.d.ts +2 -0
- package/dist/react-router.js +5 -0
- package/dist/tanstack-router.cjs +2 -0
- package/dist/tanstack-router.d.ts +2 -0
- package/dist/tanstack-router.js +5 -0
- package/package.json +48 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=/^(?:\(\.\.\.\)|\(\.\.\)|\(\.\))+/;function l(t,o="/"){const r=t.filter(e=>!(e.startsWith("(")&&e.endsWith(")"))).map(e=>e.replace(a,"")).filter(Boolean).join("/");return`${o.replace(/\/$/,"")}/${r}`.replace(/\/$/,"")||"/"}exports.selectedSegmentsToPath=l;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn a layout's selected slot into a route id. Pass the owning layout's
|
|
3
|
+
* absolute base path for nested layouts. Interception markers are stripped;
|
|
4
|
+
* this does not reconstruct an intercepted destination's relative ancestry.
|
|
5
|
+
*/
|
|
6
|
+
export declare function selectedSegmentsToPath(segments: readonly string[], basePath?: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const n = /^(?:\(\.\.\.\)|\(\.\.\)|\(\.\))+/;
|
|
2
|
+
function o(t, r = "/") {
|
|
3
|
+
const a = t.filter((e) => !(e.startsWith("(") && e.endsWith(")"))).map((e) => e.replace(n, "")).filter(Boolean).join("/");
|
|
4
|
+
return `${r.replace(/\/$/, "")}/${a}`.replace(/\/$/, "") || "/";
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
o as selectedSegmentsToPath
|
|
8
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),u=require("next/navigation"),l=require("../route-boundary.cjs");function d(e){return t.jsx(i.Suspense,{fallback:e.fallback??null,children:t.jsx(y,{...e})})}function y({resolve:e,parallelRoutesKey:o="children",fallback:r,...s}){const n=u.usePathname(),a=u.useSelectedLayoutSegments(o)??[];if(n==null)return r??null;const c=e?.({pathname:n,selectedSegments:a})??{id:n};return t.jsx(l.RouteBoundary,{...s,boundary:c})}exports.SsgoiRouteBoundary=d;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ElementType, ReactNode } from 'react';
|
|
2
|
+
import { RouteBoundaryProps } from '../route-boundary';
|
|
3
|
+
export interface NextjsRouteLocation {
|
|
4
|
+
pathname: string;
|
|
5
|
+
/** Segments below the layout that renders this boundary, including groups. */
|
|
6
|
+
selectedSegments: string[];
|
|
7
|
+
}
|
|
8
|
+
export type SsgoiRouteBoundaryProps<T extends ElementType = "div"> = RouteBoundaryProps<NextjsRouteLocation, T> & {
|
|
9
|
+
/** The parallel slot to read, without @. Defaults to children. */
|
|
10
|
+
parallelRoutesKey?: string;
|
|
11
|
+
/** Shown while Next.js resolves URL data (including Cache Components). */
|
|
12
|
+
fallback?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
/** App Router boundary. Import only from @ssgoi/react/nextjs. */
|
|
15
|
+
export declare function SsgoiRouteBoundary<T extends ElementType = "div">(props: SsgoiRouteBoundaryProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { Suspense as m } from "react";
|
|
4
|
+
import { usePathname as s, useSelectedLayoutSegments as c } from "next/navigation";
|
|
5
|
+
import { RouteBoundary as i } from "../route-boundary.js";
|
|
6
|
+
function h(e) {
|
|
7
|
+
return /* @__PURE__ */ o(m, { fallback: e.fallback ?? null, children: /* @__PURE__ */ o(d, { ...e }) });
|
|
8
|
+
}
|
|
9
|
+
function d({
|
|
10
|
+
resolve: e,
|
|
11
|
+
parallelRoutesKey: t = "children",
|
|
12
|
+
fallback: r,
|
|
13
|
+
...u
|
|
14
|
+
}) {
|
|
15
|
+
const n = s(), l = c(t) ?? [];
|
|
16
|
+
if (n == null) return r ?? null;
|
|
17
|
+
const a = e?.({ pathname: n, selectedSegments: l }) ?? {
|
|
18
|
+
id: n
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ o(i, { ...u, boundary: a });
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
h as SsgoiRouteBoundary
|
|
24
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { SsgoiRouteBoundary } from './nextjs/ssgoi-route-boundary';
|
|
2
|
+
export type { SsgoiRouteBoundaryProps, NextjsRouteLocation, } from './nextjs/ssgoi-route-boundary';
|
|
3
|
+
export type { RouteBoundaryState } from './route-boundary';
|
|
4
|
+
export { selectedSegmentsToPath } from './nextjs/selected-segments-to-path';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),n=require("react-router"),i=require("../route-boundary.cjs");function a({resolve:e,...t}){const o=n.useLocation(),r=e?.(o)??{id:o.pathname};return u.jsx(i.RouteBoundary,{...t,boundary:r})}exports.SsgoiRouteBoundary=a;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
2
|
+
import { Location } from 'react-router';
|
|
3
|
+
import { RouteBoundaryProps } from '../route-boundary';
|
|
4
|
+
export type SsgoiRouteBoundaryProps<T extends ElementType = "div"> = RouteBoundaryProps<Location, T>;
|
|
5
|
+
export declare function SsgoiRouteBoundary<T extends ElementType = "div">({ resolve, ...props }: SsgoiRouteBoundaryProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { useLocation as u } from "react-router";
|
|
4
|
+
import { RouteBoundary as a } from "../route-boundary.js";
|
|
5
|
+
function p({
|
|
6
|
+
resolve: t,
|
|
7
|
+
...r
|
|
8
|
+
}) {
|
|
9
|
+
const o = u(), n = t?.(o) ?? { id: o.pathname };
|
|
10
|
+
return /* @__PURE__ */ i(a, { ...r, boundary: n });
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
p as SsgoiRouteBoundary
|
|
14
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react");function a({boundary:e,routeKey:t,as:o,children:n,...i}){const r=o??"div";return u.createElement(r,{...i,key:t??e.key??e.id,"data-ssgoi-transition":e.id},n)}exports.RouteBoundary=a;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface RouteBoundaryState {
|
|
3
|
+
id: string;
|
|
4
|
+
/** Defaults to id. Keep this stable while a nested layout owns navigation. */
|
|
5
|
+
key?: string | number;
|
|
6
|
+
}
|
|
7
|
+
export interface RouteLocation {
|
|
8
|
+
pathname: string;
|
|
9
|
+
}
|
|
10
|
+
export type RouteBoundaryProps<Location extends RouteLocation = RouteLocation, T extends ElementType = "div"> = {
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
as?: T;
|
|
13
|
+
/** A stable lifetime for a boundary inside a persistent route layout. */
|
|
14
|
+
routeKey?: string | number;
|
|
15
|
+
/** Resolve the logical route and its lifetime together during render. */
|
|
16
|
+
resolve?: (location: Location) => RouteBoundaryState;
|
|
17
|
+
} & Omit<ComponentPropsWithoutRef<T>, "as" | "children" | "resolve" | "routeKey">;
|
|
18
|
+
export declare function RouteBoundary({ boundary, routeKey, as, children, ...rest }: HTMLAttributes<HTMLElement> & {
|
|
19
|
+
as?: ElementType;
|
|
20
|
+
routeKey?: string | number;
|
|
21
|
+
boundary: RouteBoundaryState;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createElement as r } from "react";
|
|
3
|
+
function s({
|
|
4
|
+
boundary: t,
|
|
5
|
+
routeKey: e,
|
|
6
|
+
as: o,
|
|
7
|
+
children: n,
|
|
8
|
+
...i
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ r(
|
|
11
|
+
o ?? "div",
|
|
12
|
+
{
|
|
13
|
+
...i,
|
|
14
|
+
key: e ?? t.key ?? t.id,
|
|
15
|
+
"data-ssgoi-transition": t.id
|
|
16
|
+
},
|
|
17
|
+
n
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
s as RouteBoundary
|
|
22
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),a=require("@tanstack/react-router"),s=require("../route-boundary.cjs");function c({resolve:e,...o}){const t={pathname:a.useRouterState({select:r=>r.location.pathname})},n=e?.(t)??{id:t.pathname};return u.jsx(s.RouteBoundary,{...o,boundary:n})}exports.SsgoiRouteBoundary=c;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
2
|
+
import { RouteBoundaryProps, RouteLocation } from '../route-boundary';
|
|
3
|
+
export type SsgoiRouteBoundaryProps<T extends ElementType = "div"> = RouteBoundaryProps<RouteLocation, T>;
|
|
4
|
+
export declare function SsgoiRouteBoundary<T extends ElementType = "div">({ resolve, ...props }: SsgoiRouteBoundaryProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useRouterState as m } from "@tanstack/react-router";
|
|
4
|
+
import { RouteBoundary as u } from "../route-boundary.js";
|
|
5
|
+
function d({
|
|
6
|
+
resolve: t,
|
|
7
|
+
...n
|
|
8
|
+
}) {
|
|
9
|
+
const o = { pathname: m({
|
|
10
|
+
select: (e) => e.location.pathname
|
|
11
|
+
}) }, a = t?.(o) ?? { id: o.pathname };
|
|
12
|
+
return /* @__PURE__ */ r(u, { ...n, boundary: a });
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
d as SsgoiRouteBoundary
|
|
16
|
+
};
|
package/dist/nextjs.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./lib/nextjs/ssgoi-route-boundary.cjs"),t=require("./lib/nextjs/selected-segments-to-path.cjs");exports.SsgoiRouteBoundary=e.SsgoiRouteBoundary;exports.selectedSegmentsToPath=t.selectedSegmentsToPath;
|
package/dist/nextjs.d.ts
ADDED
package/dist/nextjs.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssgoi/react",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-beta.0",
|
|
4
4
|
"description": "React bindings for SSGOI - Native app-like page transitions for React applications",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -61,14 +61,34 @@
|
|
|
61
61
|
"import": "./dist/unplugin/esbuild.js",
|
|
62
62
|
"require": "./dist/unplugin/esbuild.cjs",
|
|
63
63
|
"default": "./dist/unplugin/esbuild.js"
|
|
64
|
+
},
|
|
65
|
+
"./nextjs": {
|
|
66
|
+
"types": "./dist/nextjs.d.ts",
|
|
67
|
+
"import": "./dist/nextjs.js",
|
|
68
|
+
"require": "./dist/nextjs.cjs",
|
|
69
|
+
"default": "./dist/nextjs.js"
|
|
70
|
+
},
|
|
71
|
+
"./react-router": {
|
|
72
|
+
"types": "./dist/react-router.d.ts",
|
|
73
|
+
"import": "./dist/react-router.js",
|
|
74
|
+
"require": "./dist/react-router.cjs",
|
|
75
|
+
"default": "./dist/react-router.js"
|
|
76
|
+
},
|
|
77
|
+
"./tanstack-router": {
|
|
78
|
+
"types": "./dist/tanstack-router.d.ts",
|
|
79
|
+
"import": "./dist/tanstack-router.js",
|
|
80
|
+
"require": "./dist/tanstack-router.cjs",
|
|
81
|
+
"default": "./dist/tanstack-router.js"
|
|
64
82
|
}
|
|
65
83
|
},
|
|
66
84
|
"dependencies": {
|
|
67
85
|
"unplugin": "^2.3.2",
|
|
68
86
|
"@babel/core": "^7.26.10",
|
|
69
|
-
"@ssgoi/core": "^7.0.
|
|
87
|
+
"@ssgoi/core": "^7.1.0-beta.0"
|
|
70
88
|
},
|
|
71
89
|
"devDependencies": {
|
|
90
|
+
"@babel/traverse": "7.28.5",
|
|
91
|
+
"@babel/types": "7.28.5",
|
|
72
92
|
"@types/babel__core": "^7.20.5",
|
|
73
93
|
"@eslint/js": "^9.30.1",
|
|
74
94
|
"@types/react": "^19.1.8",
|
|
@@ -83,7 +103,14 @@
|
|
|
83
103
|
"typescript": "~5.8.3",
|
|
84
104
|
"typescript-eslint": "^8.35.1",
|
|
85
105
|
"vite": "^7.0.4",
|
|
86
|
-
"vite-plugin-dts": "^4.5.4"
|
|
106
|
+
"vite-plugin-dts": "^4.5.4",
|
|
107
|
+
"next": "16.1.0",
|
|
108
|
+
"react-router": "7.10.1",
|
|
109
|
+
"@tanstack/react-router": "^1.93.0",
|
|
110
|
+
"react": "^19.2.3",
|
|
111
|
+
"react-dom": "^19.2.3",
|
|
112
|
+
"vitest": "^3.2.4",
|
|
113
|
+
"jsdom": "^26.1.0"
|
|
87
114
|
},
|
|
88
115
|
"keywords": [
|
|
89
116
|
"react",
|
|
@@ -120,12 +147,29 @@
|
|
|
120
147
|
"engines": {
|
|
121
148
|
"node": ">=18.0.0"
|
|
122
149
|
},
|
|
150
|
+
"peerDependencies": {
|
|
151
|
+
"next": "*",
|
|
152
|
+
"react-router": "*",
|
|
153
|
+
"@tanstack/react-router": "*"
|
|
154
|
+
},
|
|
155
|
+
"peerDependenciesMeta": {
|
|
156
|
+
"next": {
|
|
157
|
+
"optional": true
|
|
158
|
+
},
|
|
159
|
+
"react-router": {
|
|
160
|
+
"optional": true
|
|
161
|
+
},
|
|
162
|
+
"@tanstack/react-router": {
|
|
163
|
+
"optional": true
|
|
164
|
+
}
|
|
165
|
+
},
|
|
123
166
|
"scripts": {
|
|
124
167
|
"dev": "vite build --watch",
|
|
125
168
|
"build": "tsc -b && vite build",
|
|
126
169
|
"watch": "vite build --watch",
|
|
127
170
|
"lint": "eslint .",
|
|
128
171
|
"preview": "vite preview",
|
|
129
|
-
"package": "vite build"
|
|
172
|
+
"package": "vite build",
|
|
173
|
+
"test:run": "vitest run"
|
|
130
174
|
}
|
|
131
175
|
}
|