vite-react-ssg 0.7.2 → 0.8.0-beta.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 +10 -4
- package/dist/chunks/jsdomGlobal.cjs +10 -65
- package/dist/chunks/jsdomGlobal.mjs +10 -65
- package/dist/client/single-page.cjs +8 -6
- package/dist/client/single-page.d.cts +3 -4
- package/dist/client/single-page.d.mts +3 -4
- package/dist/client/single-page.d.ts +3 -4
- package/dist/client/single-page.mjs +9 -7
- package/dist/index.cjs +19 -12
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +17 -10
- package/dist/node/cli.cjs +9 -8
- package/dist/node/cli.mjs +7 -6
- package/dist/node.cjs +22 -1722
- package/dist/node.d.cts +1 -2
- package/dist/node.d.mts +1 -2
- package/dist/node.d.ts +1 -2
- package/dist/node.mjs +17 -1716
- package/dist/shared/vite-react-ssg.4y2OEiyV.mjs +31 -0
- package/dist/shared/{vite-react-ssg.a292c181.mjs → vite-react-ssg.B6SGTWpD.mjs} +5 -4
- package/dist/shared/{vite-react-ssg.c1d49976.cjs → vite-react-ssg.BuZVBVT6.cjs} +5 -8
- package/dist/shared/{vite-react-ssg.054e813a.mjs → vite-react-ssg.C0y5wbxl.mjs} +1 -30
- package/dist/shared/{vite-react-ssg.0408f7e1.cjs → vite-react-ssg.C2GpVZF1.cjs} +0 -34
- package/dist/shared/vite-react-ssg.CFQGqC60.cjs +36 -0
- package/dist/shared/vite-react-ssg.CZ2uxKni.mjs +1029 -0
- package/dist/shared/vite-react-ssg.CjIppNIS.mjs +30 -0
- package/dist/shared/vite-react-ssg.D0EGioth.cjs +35 -0
- package/dist/shared/{vite-react-ssg.4d155759.d.ts → vite-react-ssg.Txy2EJkI.d.cts} +26 -7
- package/dist/shared/{vite-react-ssg.4d155759.d.cts → vite-react-ssg.Txy2EJkI.d.mts} +26 -7
- package/dist/shared/{vite-react-ssg.4d155759.d.mts → vite-react-ssg.Txy2EJkI.d.ts} +26 -7
- package/dist/shared/vite-react-ssg.sc14Rk9F.cjs +1038 -0
- package/dist/tanstack.cjs +150 -0
- package/dist/tanstack.d.cts +29 -0
- package/dist/tanstack.d.mts +29 -0
- package/dist/tanstack.d.ts +29 -0
- package/dist/tanstack.mjs +143 -0
- package/package.json +33 -22
- /package/dist/shared/{vite-react-ssg.579feabb.mjs → vite-react-ssg.C6pK7rvr.mjs} +0 -0
- /package/dist/shared/{vite-react-ssg.bee8a5a9.cjs → vite-react-ssg.CjsEygxB.cjs} +0 -0
- /package/dist/shared/{vite-react-ssg.faf3855a.d.cts → vite-react-ssg.Cm9gBlfg.d.cts} +0 -0
- /package/dist/shared/{vite-react-ssg.faf3855a.d.mts → vite-react-ssg.Cm9gBlfg.d.mts} +0 -0
- /package/dist/shared/{vite-react-ssg.faf3855a.d.ts → vite-react-ssg.Cm9gBlfg.d.ts} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const ViteReactSSGTanstackRouterStaticPathsContext = {};
|
|
2
|
+
function registerPaths(id, getStaticPaths) {
|
|
3
|
+
ViteReactSSGTanstackRouterStaticPathsContext[id] = getStaticPaths;
|
|
4
|
+
}
|
|
5
|
+
async function convertRouteTreeToRouteOption(routeTree, client, visitNode) {
|
|
6
|
+
const routes = [];
|
|
7
|
+
async function traverseRouteTree(node) {
|
|
8
|
+
if (!client && node.path.includes("$") && node.lazyFn) {
|
|
9
|
+
await node.lazyFn();
|
|
10
|
+
}
|
|
11
|
+
visitNode?.(node);
|
|
12
|
+
const routeRecord = {
|
|
13
|
+
path: node.path,
|
|
14
|
+
getStaticPaths: ViteReactSSGTanstackRouterStaticPathsContext[node.id]
|
|
15
|
+
};
|
|
16
|
+
routeRecord.path = routeRecord.path?.replaceAll("$", ":");
|
|
17
|
+
const children = node.children;
|
|
18
|
+
if (children) {
|
|
19
|
+
routeRecord.children = [];
|
|
20
|
+
for (const child of Object.values(children)) {
|
|
21
|
+
routeRecord.children.push(await traverseRouteTree(child));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return routeRecord;
|
|
25
|
+
}
|
|
26
|
+
routes.push(await traverseRouteTree(routeTree));
|
|
27
|
+
return routes;
|
|
28
|
+
}
|
|
29
|
+
const META_CONTAINER_ID = "__SSG_TANSTACK_META_CONTAINER__";
|
|
30
|
+
|
|
31
|
+
export { META_CONTAINER_ID as M, convertRouteTreeToRouteOption as c, registerPaths as r };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Helmet } from 'react-helmet-async';
|
|
3
|
+
import { useState, useEffect, isValidElement } from 'react';
|
|
3
4
|
|
|
4
5
|
function documentReady(_passThrough) {
|
|
5
6
|
if (document.readyState === "loading") {
|
|
@@ -11,7 +12,7 @@ function documentReady(_passThrough) {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
function Head(props) {
|
|
14
|
-
return /* @__PURE__ */
|
|
15
|
+
return /* @__PURE__ */ jsx(Helmet, { ...props });
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
function useIsClient() {
|
|
@@ -28,13 +29,13 @@ function ClientOnly({
|
|
|
28
29
|
}) {
|
|
29
30
|
const isBrowser = useIsClient();
|
|
30
31
|
if (isBrowser) {
|
|
31
|
-
if (typeof children !== "function" &&
|
|
32
|
+
if (typeof children !== "function" && import.meta.env.DEV) {
|
|
32
33
|
throw new Error(
|
|
33
34
|
`vite-react-ssg error: The children of <ClientOnly> must be a "render function", e.g. <ClientOnly>{() => <span>{window.location.href}</span>}</ClientOnly>.
|
|
34
35
|
Current type: ${isValidElement(children) ? "React element" : typeof children}`
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children?.() });
|
|
38
39
|
}
|
|
39
40
|
return fallback ?? null;
|
|
40
41
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
const reactHelmetAsync = require('react-helmet-async');
|
|
5
|
-
|
|
6
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
7
|
-
|
|
8
|
-
const React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
5
|
+
const React = require('react');
|
|
9
6
|
|
|
10
7
|
function documentReady(_passThrough) {
|
|
11
8
|
if (document.readyState === "loading") {
|
|
@@ -17,7 +14,7 @@ function documentReady(_passThrough) {
|
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
function Head(props) {
|
|
20
|
-
return /* @__PURE__ */
|
|
17
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactHelmetAsync.Helmet, { ...props });
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
function useIsClient() {
|
|
@@ -34,13 +31,13 @@ function ClientOnly({
|
|
|
34
31
|
}) {
|
|
35
32
|
const isBrowser = useIsClient();
|
|
36
33
|
if (isBrowser) {
|
|
37
|
-
if (typeof children !== "function" &&
|
|
34
|
+
if (typeof children !== "function" && undefined.DEV) {
|
|
38
35
|
throw new Error(
|
|
39
36
|
`vite-react-ssg error: The children of <ClientOnly> must be a "render function", e.g. <ClientOnly>{() => <span>{window.location.href}</span>}</ClientOnly>.
|
|
40
37
|
Current type: ${React.isValidElement(children) ? "React element" : typeof children}`
|
|
41
38
|
);
|
|
42
39
|
}
|
|
43
|
-
return /* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children?.() });
|
|
44
41
|
}
|
|
45
42
|
return fallback ?? null;
|
|
46
43
|
}
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
function joinUrlSegments(a, b) {
|
|
2
|
-
if (!a || !b)
|
|
3
|
-
return a || b || "";
|
|
4
|
-
if (a[a.length - 1] === "/")
|
|
5
|
-
a = a.substring(0, a.length - 1);
|
|
6
|
-
if (b[0] !== "/")
|
|
7
|
-
b = `/${b}`;
|
|
8
|
-
return a + b;
|
|
9
|
-
}
|
|
10
|
-
function removeLeadingSlash(str) {
|
|
11
|
-
return str[0] === "/" ? str.slice(1) : str;
|
|
12
|
-
}
|
|
13
|
-
function stripBase(path, base) {
|
|
14
|
-
if (path === base)
|
|
15
|
-
return "/";
|
|
16
|
-
const devBase = withTrailingSlash(base);
|
|
17
|
-
return path.startsWith(devBase) ? path.slice(devBase.length - 1) : path;
|
|
18
|
-
}
|
|
19
|
-
function withTrailingSlash(path) {
|
|
20
|
-
if (path[path.length - 1] !== "/")
|
|
21
|
-
return `${path}/`;
|
|
22
|
-
return path;
|
|
23
|
-
}
|
|
24
|
-
function withLeadingSlash(path) {
|
|
25
|
-
if (path[0] !== "/")
|
|
26
|
-
return `/${path}`;
|
|
27
|
-
return path;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
1
|
function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = []) {
|
|
31
2
|
return routes.map((route, index) => {
|
|
32
3
|
const treePath = [...parentPath, String(index)];
|
|
@@ -62,4 +33,4 @@ function isIndexRoute(route) {
|
|
|
62
33
|
return route.index === true;
|
|
63
34
|
}
|
|
64
35
|
|
|
65
|
-
export {
|
|
36
|
+
export { convertRoutesToDataRoutes as c };
|
|
@@ -1,34 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function joinUrlSegments(a, b) {
|
|
4
|
-
if (!a || !b)
|
|
5
|
-
return a || b || "";
|
|
6
|
-
if (a[a.length - 1] === "/")
|
|
7
|
-
a = a.substring(0, a.length - 1);
|
|
8
|
-
if (b[0] !== "/")
|
|
9
|
-
b = `/${b}`;
|
|
10
|
-
return a + b;
|
|
11
|
-
}
|
|
12
|
-
function removeLeadingSlash(str) {
|
|
13
|
-
return str[0] === "/" ? str.slice(1) : str;
|
|
14
|
-
}
|
|
15
|
-
function stripBase(path, base) {
|
|
16
|
-
if (path === base)
|
|
17
|
-
return "/";
|
|
18
|
-
const devBase = withTrailingSlash(base);
|
|
19
|
-
return path.startsWith(devBase) ? path.slice(devBase.length - 1) : path;
|
|
20
|
-
}
|
|
21
|
-
function withTrailingSlash(path) {
|
|
22
|
-
if (path[path.length - 1] !== "/")
|
|
23
|
-
return `${path}/`;
|
|
24
|
-
return path;
|
|
25
|
-
}
|
|
26
|
-
function withLeadingSlash(path) {
|
|
27
|
-
if (path[0] !== "/")
|
|
28
|
-
return `/${path}`;
|
|
29
|
-
return path;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
3
|
function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = []) {
|
|
33
4
|
return routes.map((route, index) => {
|
|
34
5
|
const treePath = [...parentPath, String(index)];
|
|
@@ -65,8 +36,3 @@ function isIndexRoute(route) {
|
|
|
65
36
|
}
|
|
66
37
|
|
|
67
38
|
exports.convertRoutesToDataRoutes = convertRoutesToDataRoutes;
|
|
68
|
-
exports.joinUrlSegments = joinUrlSegments;
|
|
69
|
-
exports.removeLeadingSlash = removeLeadingSlash;
|
|
70
|
-
exports.stripBase = stripBase;
|
|
71
|
-
exports.withLeadingSlash = withLeadingSlash;
|
|
72
|
-
exports.withTrailingSlash = withTrailingSlash;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function joinUrlSegments(a, b) {
|
|
4
|
+
if (!a || !b)
|
|
5
|
+
return a || b || "";
|
|
6
|
+
if (a[a.length - 1] === "/")
|
|
7
|
+
a = a.substring(0, a.length - 1);
|
|
8
|
+
if (b[0] !== "/")
|
|
9
|
+
b = `/${b}`;
|
|
10
|
+
return a + b;
|
|
11
|
+
}
|
|
12
|
+
function removeLeadingSlash(str) {
|
|
13
|
+
return str[0] === "/" ? str.slice(1) : str;
|
|
14
|
+
}
|
|
15
|
+
function stripBase(path, base) {
|
|
16
|
+
if (path === base)
|
|
17
|
+
return "/";
|
|
18
|
+
const devBase = withTrailingSlash(base);
|
|
19
|
+
return path.startsWith(devBase) ? path.slice(devBase.length - 1) : path;
|
|
20
|
+
}
|
|
21
|
+
function withTrailingSlash(path) {
|
|
22
|
+
if (path[path.length - 1] !== "/")
|
|
23
|
+
return `${path}/`;
|
|
24
|
+
return path;
|
|
25
|
+
}
|
|
26
|
+
function withLeadingSlash(path) {
|
|
27
|
+
if (path[0] !== "/")
|
|
28
|
+
return `/${path}`;
|
|
29
|
+
return path;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.joinUrlSegments = joinUrlSegments;
|
|
33
|
+
exports.removeLeadingSlash = removeLeadingSlash;
|
|
34
|
+
exports.stripBase = stripBase;
|
|
35
|
+
exports.withLeadingSlash = withLeadingSlash;
|
|
36
|
+
exports.withTrailingSlash = withTrailingSlash;
|