vite-react-ssg 0.8.4 → 0.8.5-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 +5 -8
- package/dist/client/single-page.d.mts +4 -4
- package/dist/client/single-page.d.ts +4 -4
- package/dist/client/single-page.mjs +7 -6
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.mjs +10 -8
- package/dist/node/cli.mjs +9 -9
- package/dist/node.d.mts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.mjs +7 -7
- package/dist/shared/{vite-react-ssg.Cm9gBlfg.d.ts → vite-react-ssg.-NlgsPvg.d.mts} +8 -8
- package/dist/shared/{vite-react-ssg.Cm9gBlfg.d.mts → vite-react-ssg.-NlgsPvg.d.ts} +8 -8
- package/dist/shared/{vite-react-ssg.CKcl-j8g.mjs → vite-react-ssg.2P3UhU88.mjs} +212 -211
- package/dist/shared/{vite-react-ssg.C0y5wbxl.mjs → vite-react-ssg.C_MPXL9p.mjs} +1 -1
- package/dist/shared/{vite-react-ssg.CfJcpdWF.mjs → vite-react-ssg.Dx4ca9OM.mjs} +18 -4
- package/dist/tanstack.d.mts +5 -4
- package/dist/tanstack.d.ts +5 -4
- package/dist/tanstack.mjs +9 -7
- package/package.json +32 -33
- package/dist/chunks/jsdomGlobal.cjs +0 -36
- package/dist/client/single-page.cjs +0 -75
- package/dist/client/single-page.d.cts +0 -11
- package/dist/index.cjs +0 -196
- package/dist/index.d.cts +0 -26
- package/dist/node/cli.cjs +0 -89
- package/dist/node/cli.d.cts +0 -2
- package/dist/node.cjs +0 -24
- package/dist/node.d.cts +0 -11
- package/dist/shared/vite-react-ssg.B4jDfvXh.cjs +0 -106
- package/dist/shared/vite-react-ssg.C2GpVZF1.cjs +0 -38
- package/dist/shared/vite-react-ssg.CFQGqC60.cjs +0 -36
- package/dist/shared/vite-react-ssg.CjsEygxB.cjs +0 -37
- package/dist/shared/vite-react-ssg.Cm9gBlfg.d.cts +0 -15
- package/dist/shared/vite-react-ssg.DWHmkjdM.cjs +0 -35
- package/dist/shared/vite-react-ssg.Di0pROyF.d.ts +0 -214
- package/dist/shared/vite-react-ssg.Dus0yLsZ.cjs +0 -1082
- package/dist/style-collectors/styled-components.cjs +0 -20
- package/dist/style-collectors/styled-components.d.cts +0 -9
- package/dist/tanstack.cjs +0 -144
- package/dist/tanstack.d.cts +0 -30
- package/dist/shared/{vite-react-ssg.Di0pROyF.d.cts → vite-react-ssg.BrImbdZU.d.mts} +1 -1
- package/dist/shared/{vite-react-ssg.Di0pROyF.d.mts → vite-react-ssg.BrImbdZU.d.ts} +1 -1
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const React = require('react');
|
|
4
|
-
const ReactDOM = require('react-dom');
|
|
5
|
-
const jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
const reactHelmetAsync = require('react-helmet-async');
|
|
7
|
-
|
|
8
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
9
|
-
|
|
10
|
-
function _interopNamespaceCompat(e) {
|
|
11
|
-
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
12
|
-
const n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
for (const k in e) {
|
|
15
|
-
n[k] = e[k];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return n;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
23
|
-
const ReactDOM__namespace = /*#__PURE__*/_interopNamespaceCompat(ReactDOM);
|
|
24
|
-
|
|
25
|
-
const CopyReactDOM = {
|
|
26
|
-
...ReactDOM__namespace
|
|
27
|
-
};
|
|
28
|
-
const { version, render: reactRender, hydrate: reactHydrate } = CopyReactDOM;
|
|
29
|
-
const isReact18 = Number((version || "").split(".")[0]) > 17;
|
|
30
|
-
function render(app, container, renderOptions = {}) {
|
|
31
|
-
const { useLegacyRender } = renderOptions;
|
|
32
|
-
if (useLegacyRender || !isReact18) {
|
|
33
|
-
reactRender(app, container);
|
|
34
|
-
} else {
|
|
35
|
-
CopyReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = true;
|
|
36
|
-
const { createRoot } = CopyReactDOM;
|
|
37
|
-
if (!createRoot) {
|
|
38
|
-
throw new Error("createRoot not found");
|
|
39
|
-
}
|
|
40
|
-
const root = createRoot(container);
|
|
41
|
-
CopyReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = false;
|
|
42
|
-
React__default.startTransition(() => {
|
|
43
|
-
root.render(app);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function hydrate(app, container, renderOptions = {}) {
|
|
48
|
-
const { useLegacyRender } = renderOptions;
|
|
49
|
-
if (useLegacyRender || !isReact18) {
|
|
50
|
-
reactHydrate(app, container);
|
|
51
|
-
} else {
|
|
52
|
-
CopyReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = true;
|
|
53
|
-
const { hydrateRoot } = CopyReactDOM;
|
|
54
|
-
if (!hydrateRoot) {
|
|
55
|
-
throw new Error("hydrateRoot not found");
|
|
56
|
-
}
|
|
57
|
-
React__default.startTransition(() => {
|
|
58
|
-
hydrateRoot(container, app);
|
|
59
|
-
CopyReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = false;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function documentReady(_passThrough) {
|
|
65
|
-
if (document.readyState === "loading") {
|
|
66
|
-
return new Promise((resolve) => {
|
|
67
|
-
document.addEventListener("DOMContentLoaded", () => resolve(_passThrough));
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return Promise.resolve(_passThrough);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function Head(props) {
|
|
74
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactHelmetAsync.Helmet, { ...props });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function useIsClient() {
|
|
78
|
-
const [isBrowser, setIsBrowser] = React.useState(false);
|
|
79
|
-
React.useEffect(() => {
|
|
80
|
-
setIsBrowser(true);
|
|
81
|
-
}, []);
|
|
82
|
-
return isBrowser;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function ClientOnly({
|
|
86
|
-
children,
|
|
87
|
-
fallback
|
|
88
|
-
}) {
|
|
89
|
-
const isBrowser = useIsClient();
|
|
90
|
-
if (isBrowser) {
|
|
91
|
-
if (typeof children !== "function" && process.env.NODE_ENV === "development") {
|
|
92
|
-
throw new Error(
|
|
93
|
-
`vite-react-ssg error: The children of <ClientOnly> must be a "render function", e.g. <ClientOnly>{() => <span>{window.location.href}</span>}</ClientOnly>.
|
|
94
|
-
Current type: ${React.isValidElement(children) ? "React element" : typeof children}`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children?.() });
|
|
98
|
-
}
|
|
99
|
-
return fallback ?? null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
exports.ClientOnly = ClientOnly;
|
|
103
|
-
exports.Head = Head;
|
|
104
|
-
exports.documentReady = documentReady;
|
|
105
|
-
exports.hydrate = hydrate;
|
|
106
|
-
exports.render = render;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = []) {
|
|
4
|
-
return routes.map((route, index) => {
|
|
5
|
-
const treePath = [...parentPath, String(index)];
|
|
6
|
-
const id = typeof route.id === "string" ? route.id : treePath.join("-");
|
|
7
|
-
route.id = id;
|
|
8
|
-
if (isIndexRoute(route)) {
|
|
9
|
-
const indexRoute = {
|
|
10
|
-
...route,
|
|
11
|
-
...mapRouteProperties(route),
|
|
12
|
-
id
|
|
13
|
-
};
|
|
14
|
-
return indexRoute;
|
|
15
|
-
} else {
|
|
16
|
-
const pathOrLayoutRoute = {
|
|
17
|
-
...route,
|
|
18
|
-
...mapRouteProperties(route),
|
|
19
|
-
id,
|
|
20
|
-
children: void 0
|
|
21
|
-
};
|
|
22
|
-
if (route.children) {
|
|
23
|
-
pathOrLayoutRoute.children = convertRoutesToDataRoutes(
|
|
24
|
-
route.children,
|
|
25
|
-
mapRouteProperties,
|
|
26
|
-
treePath
|
|
27
|
-
// manifest,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
return pathOrLayoutRoute;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function isIndexRoute(route) {
|
|
35
|
-
return route.index === true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
exports.convertRoutesToDataRoutes = convertRoutesToDataRoutes;
|
|
@@ -1,36 +0,0 @@
|
|
|
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;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const UNSAFE_CHARS_REGEXP = /[<>/\u2028\u2029]/g;
|
|
4
|
-
const ESCAPED_CHARS = {
|
|
5
|
-
"<": "\\u003C",
|
|
6
|
-
">": "\\u003E",
|
|
7
|
-
"/": "\\u002F",
|
|
8
|
-
"\u2028": "\\u2028",
|
|
9
|
-
"\u2029": "\\u2029"
|
|
10
|
-
};
|
|
11
|
-
function escapeUnsafeChars(unsafeChar) {
|
|
12
|
-
return ESCAPED_CHARS[unsafeChar];
|
|
13
|
-
}
|
|
14
|
-
function serializeState(state) {
|
|
15
|
-
if (state == null || Object.keys(state).length === 0)
|
|
16
|
-
return null;
|
|
17
|
-
try {
|
|
18
|
-
return JSON.stringify(JSON.stringify(state || {})).replace(
|
|
19
|
-
UNSAFE_CHARS_REGEXP,
|
|
20
|
-
escapeUnsafeChars
|
|
21
|
-
);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.error("[SSG] On state serialization -", error, state);
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function deserializeState(state) {
|
|
28
|
-
try {
|
|
29
|
-
return JSON.parse(state || "{}");
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error("[SSG] On state deserialization -", error, state);
|
|
32
|
-
return {};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports.deserializeState = deserializeState;
|
|
37
|
-
exports.serializeState = serializeState;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { HelmetProps } from 'react-helmet-async';
|
|
3
|
-
|
|
4
|
-
type Props = HelmetProps & {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
};
|
|
7
|
-
declare function Head(props: Props): JSX.Element;
|
|
8
|
-
|
|
9
|
-
interface ClientOnlyProps {
|
|
10
|
-
children?: () => JSX.Element;
|
|
11
|
-
fallback?: JSX.Element;
|
|
12
|
-
}
|
|
13
|
-
declare function ClientOnly({ children, fallback, }: ClientOnlyProps): JSX.Element | null;
|
|
14
|
-
|
|
15
|
-
export { ClientOnly as C, Head as H };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ViteReactSSGTanstackRouterStaticPathsContext = {};
|
|
4
|
-
function registerPaths(id, getStaticPaths) {
|
|
5
|
-
ViteReactSSGTanstackRouterStaticPathsContext[id] = getStaticPaths;
|
|
6
|
-
}
|
|
7
|
-
async function convertRouteTreeToRouteOption(routeTree, client, visitNode) {
|
|
8
|
-
const routes = [];
|
|
9
|
-
async function traverseRouteTree(node) {
|
|
10
|
-
if (!client && node.path?.includes("$") && node.lazyFn) {
|
|
11
|
-
await node.lazyFn();
|
|
12
|
-
}
|
|
13
|
-
visitNode?.(node);
|
|
14
|
-
const routeRecord = {
|
|
15
|
-
path: node.path,
|
|
16
|
-
getStaticPaths: ViteReactSSGTanstackRouterStaticPathsContext[node.id]
|
|
17
|
-
};
|
|
18
|
-
routeRecord.path = routeRecord.path?.replaceAll("$", ":");
|
|
19
|
-
const children = node.children;
|
|
20
|
-
if (children) {
|
|
21
|
-
routeRecord.children = [];
|
|
22
|
-
for (const child of Object.values(children)) {
|
|
23
|
-
routeRecord.children.push(await traverseRouteTree(child));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return routeRecord;
|
|
27
|
-
}
|
|
28
|
-
routes.push(await traverseRouteTree(routeTree));
|
|
29
|
-
return routes;
|
|
30
|
-
}
|
|
31
|
-
const META_CONTAINER_ID = "__SSG_TANSTACK_META_CONTAINER__";
|
|
32
|
-
|
|
33
|
-
exports.META_CONTAINER_ID = META_CONTAINER_ID;
|
|
34
|
-
exports.convertRouteTreeToRouteOption = convertRouteTreeToRouteOption;
|
|
35
|
-
exports.registerPaths = registerPaths;
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { NonIndexRouteObject, IndexRouteObject, FutureConfig, createBrowserRouter } from 'react-router-dom';
|
|
3
|
-
import { Options } from 'beasties';
|
|
4
|
-
|
|
5
|
-
type Router = ReturnType<typeof createBrowserRouter>;
|
|
6
|
-
interface CrittersOptions {
|
|
7
|
-
path?: string;
|
|
8
|
-
publicPath?: string;
|
|
9
|
-
external?: boolean;
|
|
10
|
-
inlineThreshold?: number;
|
|
11
|
-
minimumExternalSize?: number;
|
|
12
|
-
pruneSource?: boolean;
|
|
13
|
-
mergeStylesheets?: boolean;
|
|
14
|
-
additionalStylesheets?: string[];
|
|
15
|
-
preload?: 'body' | 'media' | 'swap' | 'js' | 'js-lazy';
|
|
16
|
-
noscriptFallback?: boolean;
|
|
17
|
-
inlineFonts?: boolean;
|
|
18
|
-
preloadFonts?: boolean;
|
|
19
|
-
fonts?: boolean;
|
|
20
|
-
keyframes?: string;
|
|
21
|
-
compress?: boolean;
|
|
22
|
-
logLevel?: 'info' | 'warn' | 'error' | 'trace' | 'debug' | 'silent';
|
|
23
|
-
reduceInlineStyles?: boolean;
|
|
24
|
-
}
|
|
25
|
-
interface ViteReactSSGOptions<Context = ViteReactSSGContext> {
|
|
26
|
-
/**
|
|
27
|
-
* Set the scripts' loading mode. Only works for `type="module"`.
|
|
28
|
-
*
|
|
29
|
-
* @default 'sync'
|
|
30
|
-
*/
|
|
31
|
-
script?: 'sync' | 'async' | 'defer' | 'async defer';
|
|
32
|
-
/**
|
|
33
|
-
* Build format.
|
|
34
|
-
*
|
|
35
|
-
* @default 'esm'
|
|
36
|
-
*/
|
|
37
|
-
format?: 'esm' | 'cjs';
|
|
38
|
-
/**
|
|
39
|
-
* The path of the main entry file (relative to the project root).
|
|
40
|
-
*
|
|
41
|
-
* @default 'src/main.ts'
|
|
42
|
-
*/
|
|
43
|
-
entry?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Mock browser global variables (window, document, etc...) from SSG.
|
|
46
|
-
*
|
|
47
|
-
* @default false
|
|
48
|
-
*/
|
|
49
|
-
mock?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Apply formatter to the generated index file.
|
|
52
|
-
*
|
|
53
|
-
* **It will cause Hydration Failed.**
|
|
54
|
-
*
|
|
55
|
-
* @default 'none'
|
|
56
|
-
*/
|
|
57
|
-
formatting?: 'prettify' | 'none';
|
|
58
|
-
/**
|
|
59
|
-
* Vite environmeng mode.
|
|
60
|
-
*/
|
|
61
|
-
mode?: string;
|
|
62
|
-
/**
|
|
63
|
-
* Directory style of the output directory.
|
|
64
|
-
*
|
|
65
|
-
* flat: `/foo` -> `/foo.html`
|
|
66
|
-
* nested: `/foo` -> `/foo/index.html`
|
|
67
|
-
*
|
|
68
|
-
* @default 'flat'
|
|
69
|
-
*/
|
|
70
|
-
dirStyle?: 'flat' | 'nested';
|
|
71
|
-
/**
|
|
72
|
-
* Generate for all routes, including dynamic routes.
|
|
73
|
-
* If enabled, you will need to configGure your serve
|
|
74
|
-
* manually to handle dynamic routes properly.
|
|
75
|
-
*
|
|
76
|
-
* @default false
|
|
77
|
-
*/
|
|
78
|
-
includeAllRoutes?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Options for the critters packages.
|
|
81
|
-
*
|
|
82
|
-
* @deprecated Use `beastiesOptions` instead.
|
|
83
|
-
* @see https://github.com/GoogleChromeLabs/critters
|
|
84
|
-
*/
|
|
85
|
-
crittersOptions?: CrittersOptions | false;
|
|
86
|
-
/**
|
|
87
|
-
* Options for the beasties package.
|
|
88
|
-
*
|
|
89
|
-
* @see https://github.com/danielroe/beasties
|
|
90
|
-
*/
|
|
91
|
-
beastiesOptions?: Options | false;
|
|
92
|
-
/**
|
|
93
|
-
* Custom function to modify the routes to do the SSG.
|
|
94
|
-
*
|
|
95
|
-
* Works only when `includeAllRoutes` is set to false.
|
|
96
|
-
*
|
|
97
|
-
* Defaults to a handler that filters out all the dynamic routes.
|
|
98
|
-
* When passing your custom handler, you should also take care of the dynamic routes yourself.
|
|
99
|
-
*/
|
|
100
|
-
includedRoutes?: (paths: string[], routes: Readonly<RouteRecord[]>) => Promise<string[]> | string[];
|
|
101
|
-
/**
|
|
102
|
-
* Callback to be called before every page render.
|
|
103
|
-
*
|
|
104
|
-
* It can be used to transform the project's `index.html` file before passing it to the renderer.
|
|
105
|
-
*
|
|
106
|
-
* To do so, you can change the 'index.html' file contents (passed in through the `indexHTML` parameter), and return it.
|
|
107
|
-
* The returned value will then be passed to renderer.
|
|
108
|
-
*/
|
|
109
|
-
onBeforePageRender?: (route: string, indexHTML: string, appCtx: Context) => Promise<string | null | undefined> | string | null | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* Callback to be called on every rendered page.
|
|
112
|
-
*
|
|
113
|
-
* It can be used to transform the current route's rendered HTML.
|
|
114
|
-
*
|
|
115
|
-
* To do so, you can transform the route's rendered HTML (passed in through the `renderedHTML` parameter), and return it.
|
|
116
|
-
* The returned value will be used as the HTML of the route.
|
|
117
|
-
*/
|
|
118
|
-
onPageRendered?: (route: string, renderedHTML: string, appCtx: Context) => Promise<string | null | undefined> | string | null | undefined;
|
|
119
|
-
onFinished?: () => Promise<void> | void;
|
|
120
|
-
/**
|
|
121
|
-
* The application's root container `id`.
|
|
122
|
-
*
|
|
123
|
-
* @default `root`
|
|
124
|
-
*/
|
|
125
|
-
rootContainerId?: string;
|
|
126
|
-
/**
|
|
127
|
-
* The size of the SSG processing queue.
|
|
128
|
-
*
|
|
129
|
-
* @default 20
|
|
130
|
-
*/
|
|
131
|
-
concurrency?: number;
|
|
132
|
-
}
|
|
133
|
-
interface ViteReactSSGContext<HasRouter extends boolean = true> {
|
|
134
|
-
router?: HasRouter extends true ? Router : undefined;
|
|
135
|
-
routes: HasRouter extends true ? Readonly<RouteRecord[]> : undefined;
|
|
136
|
-
routerOptions: HasRouter extends true ? RouterOptions : undefined;
|
|
137
|
-
initialState: Record<string, any>;
|
|
138
|
-
isClient: boolean;
|
|
139
|
-
onSSRAppRendered: (cb: Function) => void;
|
|
140
|
-
triggerOnSSRAppRendered: (route: string, appHTML: string, appCtx: ViteReactSSGContext) => Promise<unknown[]>;
|
|
141
|
-
transformState?: (state: any) => any;
|
|
142
|
-
/**
|
|
143
|
-
* Current router path on SSG, `undefined` on client side.
|
|
144
|
-
*/
|
|
145
|
-
routePath?: string;
|
|
146
|
-
base: string;
|
|
147
|
-
getStyleCollector: (() => StyleCollector | Promise<StyleCollector>) | null;
|
|
148
|
-
app?: HasRouter extends true ? never : ReactNode;
|
|
149
|
-
routerType: 'remix' | 'single-page';
|
|
150
|
-
}
|
|
151
|
-
interface ViteReactSSGClientOptions {
|
|
152
|
-
transformState?: (state: any) => any;
|
|
153
|
-
registerComponents?: boolean;
|
|
154
|
-
/**
|
|
155
|
-
* The application's root container query selector.
|
|
156
|
-
*
|
|
157
|
-
* @default `#root`
|
|
158
|
-
*/
|
|
159
|
-
rootContainer?: string | Element;
|
|
160
|
-
/**
|
|
161
|
-
* @deprecated This option is no longer needed
|
|
162
|
-
*/
|
|
163
|
-
ssrWhenDev?: boolean;
|
|
164
|
-
getStyleCollector?: (() => StyleCollector | Promise<StyleCollector>) | null;
|
|
165
|
-
useLegacyRender?: boolean;
|
|
166
|
-
}
|
|
167
|
-
interface CommonRouteOptions {
|
|
168
|
-
/**
|
|
169
|
-
* Used to obtain static resources through manifest
|
|
170
|
-
*
|
|
171
|
-
* **You are not required to use this field. It is only necessary when "prehydration style loss" occurs.**
|
|
172
|
-
*
|
|
173
|
-
* @example `src/pages/home.tsx`
|
|
174
|
-
*/
|
|
175
|
-
entry?: string;
|
|
176
|
-
/**
|
|
177
|
-
* The getStaticPaths() function should return an array of path
|
|
178
|
-
* to determine which paths will be pre-rendered by vite-react-ssg.
|
|
179
|
-
*
|
|
180
|
-
* This function is only valid for dynamic route.
|
|
181
|
-
*
|
|
182
|
-
* @example () => ['path1', 'path2']
|
|
183
|
-
*/
|
|
184
|
-
getStaticPaths?: () => string[] | Promise<string[]>;
|
|
185
|
-
}
|
|
186
|
-
type NonIndexRouteRecord = Omit<NonIndexRouteObject, 'children'> & {
|
|
187
|
-
children?: RouteRecord[];
|
|
188
|
-
} & CommonRouteOptions;
|
|
189
|
-
type IndexRouteRecord = IndexRouteObject & CommonRouteOptions;
|
|
190
|
-
type RouteRecord = NonIndexRouteRecord | IndexRouteRecord;
|
|
191
|
-
interface RouterFutureConfig {
|
|
192
|
-
v7_fetcherPersist?: boolean;
|
|
193
|
-
v7_normalizeFormMethod?: boolean;
|
|
194
|
-
v7_partialHydration?: boolean;
|
|
195
|
-
v7_relativeSplatPath?: boolean;
|
|
196
|
-
v7_skipActionErrorRevalidation?: boolean;
|
|
197
|
-
}
|
|
198
|
-
interface RouterOptions {
|
|
199
|
-
routes: RouteRecord[];
|
|
200
|
-
basename?: string;
|
|
201
|
-
future?: Partial<RouterFutureConfig & FutureConfig>;
|
|
202
|
-
}
|
|
203
|
-
interface StyleCollector {
|
|
204
|
-
collect: (app: ReactElement) => ReactElement;
|
|
205
|
-
toString: (html: string) => string;
|
|
206
|
-
cleanup?: () => void;
|
|
207
|
-
}
|
|
208
|
-
declare module 'vite' {
|
|
209
|
-
interface UserConfig {
|
|
210
|
-
ssgOptions?: ViteReactSSGOptions;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export type { CrittersOptions as C, IndexRouteRecord as I, NonIndexRouteRecord as N, RouteRecord as R, StyleCollector as S, ViteReactSSGContext as V, ViteReactSSGClientOptions as a, ViteReactSSGOptions as b, RouterFutureConfig as c, RouterOptions as d };
|