vite-react-ssg 0.8.3 → 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.
Files changed (43) hide show
  1. package/README.md +37 -8
  2. package/dist/client/single-page.d.mts +4 -4
  3. package/dist/client/single-page.d.ts +4 -4
  4. package/dist/client/single-page.mjs +7 -6
  5. package/dist/index.d.mts +11 -4
  6. package/dist/index.d.ts +11 -4
  7. package/dist/index.mjs +11 -9
  8. package/dist/node/cli.mjs +9 -9
  9. package/dist/node.d.mts +2 -2
  10. package/dist/node.d.ts +2 -2
  11. package/dist/node.mjs +7 -7
  12. package/dist/shared/{vite-react-ssg.Cm9gBlfg.d.ts → vite-react-ssg.-NlgsPvg.d.mts} +8 -8
  13. package/dist/shared/{vite-react-ssg.Cm9gBlfg.d.mts → vite-react-ssg.-NlgsPvg.d.ts} +8 -8
  14. package/dist/shared/{vite-react-ssg.BgawrvuJ.mjs → vite-react-ssg.2P3UhU88.mjs} +216 -212
  15. package/dist/shared/{vite-react-ssg.C0y5wbxl.mjs → vite-react-ssg.C_MPXL9p.mjs} +1 -1
  16. package/dist/shared/{vite-react-ssg.CfJcpdWF.mjs → vite-react-ssg.Dx4ca9OM.mjs} +18 -4
  17. package/dist/tanstack.d.mts +5 -4
  18. package/dist/tanstack.d.ts +5 -4
  19. package/dist/tanstack.mjs +9 -7
  20. package/package.json +32 -33
  21. package/dist/chunks/jsdomGlobal.cjs +0 -36
  22. package/dist/client/single-page.cjs +0 -75
  23. package/dist/client/single-page.d.cts +0 -11
  24. package/dist/index.cjs +0 -196
  25. package/dist/index.d.cts +0 -20
  26. package/dist/node/cli.cjs +0 -89
  27. package/dist/node/cli.d.cts +0 -2
  28. package/dist/node.cjs +0 -24
  29. package/dist/node.d.cts +0 -11
  30. package/dist/shared/vite-react-ssg.B4jDfvXh.cjs +0 -106
  31. package/dist/shared/vite-react-ssg.C2GpVZF1.cjs +0 -38
  32. package/dist/shared/vite-react-ssg.CFQGqC60.cjs +0 -36
  33. package/dist/shared/vite-react-ssg.CjsEygxB.cjs +0 -37
  34. package/dist/shared/vite-react-ssg.Cm9gBlfg.d.cts +0 -15
  35. package/dist/shared/vite-react-ssg.D5xBH08M.cjs +0 -1079
  36. package/dist/shared/vite-react-ssg.DWHmkjdM.cjs +0 -35
  37. package/dist/shared/vite-react-ssg.Di0pROyF.d.ts +0 -214
  38. package/dist/style-collectors/styled-components.cjs +0 -20
  39. package/dist/style-collectors/styled-components.d.cts +0 -9
  40. package/dist/tanstack.cjs +0 -144
  41. package/dist/tanstack.d.cts +0 -30
  42. package/dist/shared/{vite-react-ssg.Di0pROyF.d.cts → vite-react-ssg.BrImbdZU.d.mts} +1 -1
  43. 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 };