@modern-js/runtime 2.35.1 → 2.36.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/cjs/cli/index.js +48 -30
- package/dist/cjs/common.js +27 -18
- package/dist/cjs/config.js +15 -3
- package/dist/cjs/core/appConfig.js +25 -15
- package/dist/cjs/core/compatible.js +60 -43
- package/dist/cjs/core/index.js +47 -40
- package/dist/cjs/core/loader/index.js +35 -9
- package/dist/cjs/core/loader/loaderManager.js +37 -18
- package/dist/cjs/core/loader/useLoader.js +45 -23
- package/dist/cjs/core/plugin.js +39 -31
- package/dist/cjs/core/types.js +15 -3
- package/dist/cjs/document/Body.js +35 -19
- package/dist/cjs/document/Comment.js +29 -14
- package/dist/cjs/document/DocumentContext.js +36 -10
- package/dist/cjs/document/DocumentStructureContext.js +36 -10
- package/dist/cjs/document/Head.js +40 -31
- package/dist/cjs/document/Html.js +34 -19
- package/dist/cjs/document/Links.js +28 -13
- package/dist/cjs/document/Root.js +37 -28
- package/dist/cjs/document/Script.js +29 -14
- package/dist/cjs/document/Scripts.js +28 -13
- package/dist/cjs/document/Style.js +29 -14
- package/dist/cjs/document/cli/index.js +68 -51
- package/dist/cjs/document/constants.js +64 -72
- package/dist/cjs/document/index.js +42 -15
- package/dist/cjs/exports/head.js +38 -11
- package/dist/cjs/exports/loadable.js +38 -11
- package/dist/cjs/exports/server.js +24 -7
- package/dist/cjs/exports/styled.js +38 -11
- package/dist/cjs/index.js +41 -38
- package/dist/cjs/router/cli/index.js +31 -22
- package/dist/cjs/router/index.js +39 -18
- package/dist/cjs/router/runtime/DefaultNotFound.js +26 -11
- package/dist/cjs/router/runtime/DeferredDataScripts.js +21 -8
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +47 -34
- package/dist/cjs/router/runtime/PrefetchLink.js +60 -42
- package/dist/cjs/router/runtime/fetch.js +24 -7
- package/dist/cjs/router/runtime/fetch.node.js +25 -8
- package/dist/cjs/router/runtime/fetch.worker.js +24 -7
- package/dist/cjs/router/runtime/hooks.js +26 -9
- package/dist/cjs/router/runtime/index.js +155 -208
- package/dist/cjs/router/runtime/plugin.js +62 -46
- package/dist/cjs/router/runtime/plugin.node.js +65 -48
- package/dist/cjs/router/runtime/server.js +20 -4
- package/dist/cjs/router/runtime/types.js +15 -3
- package/dist/cjs/router/runtime/utils.js +61 -48
- package/dist/cjs/router/runtime/withRouter.js +30 -15
- package/dist/cjs/runtimeContext.js +28 -18
- package/dist/cjs/ssr/cli/babel-plugin-ssr-loader-id.js +40 -23
- package/dist/cjs/ssr/cli/index.js +48 -30
- package/dist/cjs/ssr/cli/loadable-bundler-plugin.js +31 -13
- package/dist/cjs/ssr/index.js +71 -52
- package/dist/cjs/ssr/index.node.js +44 -25
- package/dist/cjs/ssr/prefetch.js +29 -16
- package/dist/cjs/ssr/react/index.js +27 -17
- package/dist/cjs/ssr/react/nossr/index.js +38 -12
- package/dist/cjs/ssr/react/prerender/index.js +52 -27
- package/dist/cjs/ssr/react/prerender/type.js +15 -3
- package/dist/cjs/ssr/react/prerender/util.js +31 -24
- package/dist/cjs/ssr/react/withCallback/index.js +27 -11
- package/dist/cjs/ssr/serverRender/helmet.js +23 -15
- package/dist/cjs/ssr/serverRender/index.js +24 -11
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +30 -13
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.share.js +25 -15
- package/dist/cjs/ssr/serverRender/renderToStream/bulidTemplate.before.js +46 -20
- package/dist/cjs/ssr/serverRender/renderToStream/index.js +49 -23
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.js +30 -17
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.worker.js +30 -17
- package/dist/cjs/ssr/serverRender/renderToStream/template.js +28 -11
- package/dist/cjs/ssr/serverRender/renderToString/buildHtml.js +31 -24
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +81 -59
- package/dist/cjs/ssr/serverRender/renderToString/index.js +44 -18
- package/dist/cjs/ssr/serverRender/renderToString/loadable.js +33 -16
- package/dist/cjs/ssr/serverRender/renderToString/render.js +39 -13
- package/dist/cjs/ssr/serverRender/renderToString/styledComponent.js +28 -11
- package/dist/cjs/ssr/serverRender/renderToString/type.js +24 -7
- package/dist/cjs/ssr/serverRender/tracker.js +27 -18
- package/dist/cjs/ssr/serverRender/types.js +25 -8
- package/dist/cjs/ssr/serverRender/utils.js +31 -24
- package/dist/cjs/ssr/utils.js +42 -25
- package/dist/cjs/state/cli/index.js +28 -19
- package/dist/cjs/state/index.js +39 -18
- package/dist/cjs/state/plugins.js +46 -29
- package/dist/cjs/state/runtime/index.js +39 -11
- package/dist/cjs/state/runtime/plugin.js +55 -28
- package/dist/esm/cli/index.js +6 -2
- package/dist/esm/common.js +8 -3
- package/dist/esm/config.js +0 -1
- package/dist/esm/core/appConfig.js +6 -2
- package/dist/esm/core/compatible.js +20 -15
- package/dist/esm/core/index.js +13 -3
- package/dist/esm/core/loader/index.js +4 -1
- package/dist/esm/core/loader/loaderManager.js +13 -9
- package/dist/esm/core/loader/useLoader.js +5 -2
- package/dist/esm/core/plugin.js +15 -10
- package/dist/esm/core/types.js +0 -1
- package/dist/esm/document/Body.js +4 -1
- package/dist/esm/document/Comment.js +4 -1
- package/dist/esm/document/DocumentContext.js +4 -1
- package/dist/esm/document/DocumentStructureContext.js +4 -1
- package/dist/esm/document/Head.js +6 -2
- package/dist/esm/document/Html.js +9 -6
- package/dist/esm/document/Links.js +4 -1
- package/dist/esm/document/Root.js +6 -2
- package/dist/esm/document/Script.js +4 -1
- package/dist/esm/document/Scripts.js +4 -1
- package/dist/esm/document/Style.js +4 -1
- package/dist/esm/document/cli/index.js +14 -9
- package/dist/esm/document/constants.js +42 -20
- package/dist/esm/exports/head.js +4 -1
- package/dist/esm/exports/loadable.js +4 -1
- package/dist/esm/exports/server.js +4 -1
- package/dist/esm/exports/styled.js +4 -1
- package/dist/esm/index.js +13 -2
- package/dist/esm/router/cli/index.js +11 -7
- package/dist/esm/router/index.js +6 -2
- package/dist/esm/router/runtime/DefaultNotFound.js +4 -1
- package/dist/esm/router/runtime/DeferredDataScripts.js +4 -1
- package/dist/esm/router/runtime/DeferredDataScripts.node.js +10 -7
- package/dist/esm/router/runtime/PrefetchLink.js +12 -8
- package/dist/esm/router/runtime/fetch.js +3 -1
- package/dist/esm/router/runtime/fetch.node.js +3 -1
- package/dist/esm/router/runtime/fetch.worker.js +3 -1
- package/dist/esm/router/runtime/hooks.js +3 -1
- package/dist/esm/router/runtime/index.js +70 -6
- package/dist/esm/router/runtime/plugin.js +22 -16
- package/dist/esm/router/runtime/plugin.node.js +20 -15
- package/dist/esm/router/runtime/types.js +0 -1
- package/dist/esm/router/runtime/utils.js +23 -14
- package/dist/esm/router/runtime/withRouter.js +7 -4
- package/dist/esm/runtimeContext.js +6 -2
- package/dist/esm/ssr/cli/babel-plugin-ssr-loader-id.js +107 -98
- package/dist/esm/ssr/cli/index.js +17 -13
- package/dist/esm/ssr/cli/loadable-bundler-plugin.js +105 -96
- package/dist/esm/ssr/index.js +18 -14
- package/dist/esm/ssr/index.node.js +14 -10
- package/dist/esm/ssr/prefetch.js +7 -4
- package/dist/esm/ssr/react/index.js +6 -2
- package/dist/esm/ssr/react/nossr/index.js +4 -1
- package/dist/esm/ssr/react/prerender/index.js +4 -1
- package/dist/esm/ssr/react/prerender/type.js +0 -1
- package/dist/esm/ssr/react/prerender/util.js +12 -5
- package/dist/esm/ssr/react/withCallback/index.js +4 -1
- package/dist/esm/ssr/serverRender/helmet.js +4 -1
- package/dist/esm/ssr/serverRender/index.js +4 -1
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.after.js +7 -4
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.share.js +6 -2
- package/dist/esm/ssr/serverRender/renderToStream/bulidTemplate.before.js +4 -1
- package/dist/esm/ssr/serverRender/renderToStream/index.js +4 -1
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.js +4 -1
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.worker.js +4 -1
- package/dist/esm/ssr/serverRender/renderToStream/template.js +6 -3
- package/dist/esm/ssr/serverRender/renderToString/buildHtml.js +12 -5
- package/dist/esm/ssr/serverRender/renderToString/entry.js +5 -3
- package/dist/esm/ssr/serverRender/renderToString/index.js +6 -3
- package/dist/esm/ssr/serverRender/renderToString/loadable.js +5 -2
- package/dist/esm/ssr/serverRender/renderToString/render.js +4 -1
- package/dist/esm/ssr/serverRender/renderToString/styledComponent.js +4 -1
- package/dist/esm/ssr/serverRender/renderToString/type.js +4 -1
- package/dist/esm/ssr/serverRender/tracker.js +8 -3
- package/dist/esm/ssr/serverRender/types.js +3 -1
- package/dist/esm/ssr/serverRender/utils.js +12 -5
- package/dist/esm/ssr/utils.js +13 -7
- package/dist/esm/state/cli/index.js +10 -6
- package/dist/esm/state/index.js +6 -2
- package/dist/esm/state/plugins.js +10 -4
- package/dist/esm/state/runtime/index.js +4 -1
- package/dist/esm/state/runtime/plugin.js +10 -7
- package/dist/esm-node/cli/index.js +6 -2
- package/dist/esm-node/common.js +8 -3
- package/dist/esm-node/config.js +0 -1
- package/dist/esm-node/core/appConfig.js +6 -2
- package/dist/esm-node/core/compatible.js +8 -3
- package/dist/esm-node/core/index.js +13 -3
- package/dist/esm-node/core/loader/index.js +4 -1
- package/dist/esm-node/core/loader/loaderManager.js +6 -2
- package/dist/esm-node/core/loader/useLoader.js +4 -1
- package/dist/esm-node/core/plugin.js +9 -4
- package/dist/esm-node/core/types.js +0 -1
- package/dist/esm-node/document/Body.js +4 -1
- package/dist/esm-node/document/Comment.js +4 -1
- package/dist/esm-node/document/DocumentContext.js +4 -1
- package/dist/esm-node/document/DocumentStructureContext.js +4 -1
- package/dist/esm-node/document/Head.js +6 -2
- package/dist/esm-node/document/Html.js +4 -1
- package/dist/esm-node/document/Links.js +4 -1
- package/dist/esm-node/document/Root.js +6 -2
- package/dist/esm-node/document/Script.js +4 -1
- package/dist/esm-node/document/Scripts.js +4 -1
- package/dist/esm-node/document/Style.js +4 -1
- package/dist/esm-node/document/cli/index.js +8 -3
- package/dist/esm-node/document/constants.js +42 -20
- package/dist/esm-node/exports/head.js +4 -1
- package/dist/esm-node/exports/loadable.js +4 -1
- package/dist/esm-node/exports/server.js +4 -1
- package/dist/esm-node/exports/styled.js +4 -1
- package/dist/esm-node/index.js +13 -2
- package/dist/esm-node/router/cli/index.js +6 -2
- package/dist/esm-node/router/index.js +6 -2
- package/dist/esm-node/router/runtime/DefaultNotFound.js +4 -1
- package/dist/esm-node/router/runtime/DeferredDataScripts.js +4 -1
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.js +4 -1
- package/dist/esm-node/router/runtime/PrefetchLink.js +6 -2
- package/dist/esm-node/router/runtime/fetch.js +3 -1
- package/dist/esm-node/router/runtime/fetch.node.js +3 -1
- package/dist/esm-node/router/runtime/fetch.worker.js +3 -1
- package/dist/esm-node/router/runtime/hooks.js +3 -1
- package/dist/esm-node/router/runtime/index.js +70 -6
- package/dist/esm-node/router/runtime/plugin.js +10 -4
- package/dist/esm-node/router/runtime/plugin.node.js +8 -3
- package/dist/esm-node/router/runtime/types.js +0 -1
- package/dist/esm-node/router/runtime/utils.js +16 -7
- package/dist/esm-node/router/runtime/withRouter.js +4 -1
- package/dist/esm-node/runtimeContext.js +6 -2
- package/dist/esm-node/ssr/cli/babel-plugin-ssr-loader-id.js +108 -99
- package/dist/esm-node/ssr/cli/index.js +6 -2
- package/dist/esm-node/ssr/cli/loadable-bundler-plugin.js +92 -83
- package/dist/esm-node/ssr/index.js +6 -2
- package/dist/esm-node/ssr/index.node.js +6 -2
- package/dist/esm-node/ssr/prefetch.js +4 -1
- package/dist/esm-node/ssr/react/index.js +6 -2
- package/dist/esm-node/ssr/react/nossr/index.js +4 -1
- package/dist/esm-node/ssr/react/prerender/index.js +4 -1
- package/dist/esm-node/ssr/react/prerender/type.js +0 -1
- package/dist/esm-node/ssr/react/prerender/util.js +12 -5
- package/dist/esm-node/ssr/react/withCallback/index.js +4 -1
- package/dist/esm-node/ssr/serverRender/helmet.js +4 -1
- package/dist/esm-node/ssr/serverRender/index.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToStream/buildTemplate.after.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToStream/buildTemplate.share.js +6 -2
- package/dist/esm-node/ssr/serverRender/renderToStream/bulidTemplate.before.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToStream/index.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToStream/renderToPipe.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToStream/renderToPipe.worker.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToStream/template.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToString/buildHtml.js +12 -5
- package/dist/esm-node/ssr/serverRender/renderToString/entry.js +3 -1
- package/dist/esm-node/ssr/serverRender/renderToString/index.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToString/loadable.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToString/render.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToString/styledComponent.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToString/type.js +4 -1
- package/dist/esm-node/ssr/serverRender/tracker.js +8 -3
- package/dist/esm-node/ssr/serverRender/types.js +3 -1
- package/dist/esm-node/ssr/serverRender/utils.js +12 -5
- package/dist/esm-node/ssr/utils.js +10 -4
- package/dist/esm-node/state/cli/index.js +6 -2
- package/dist/esm-node/state/index.js +6 -2
- package/dist/esm-node/state/plugins.js +10 -4
- package/dist/esm-node/state/runtime/index.js +4 -1
- package/dist/esm-node/state/runtime/plugin.js +4 -1
- package/package.json +10 -12
- package/dist/cjs/state/types.js +0 -4
- package/dist/esm/state/types.js +0 -1
- package/dist/esm-node/state/types.js +0 -1
- package/dist/types/state/types.d.ts +0 -16
|
@@ -4,7 +4,7 @@ import { ErrorResponse } from "@modern-js/runtime-utils/remix-router";
|
|
|
4
4
|
import { renderNestedRoute } from "@modern-js/runtime-utils/browser";
|
|
5
5
|
import { DefaultNotFound } from "./DefaultNotFound";
|
|
6
6
|
import DeferredDataScripts from "./DeferredDataScripts";
|
|
7
|
-
|
|
7
|
+
function getRouteComponents(routes, { globalApp, ssrMode, props, reporter }) {
|
|
8
8
|
const Layout = ({ Component, ...props2 }) => {
|
|
9
9
|
const GlobalLayout = globalApp;
|
|
10
10
|
if (!GlobalLayout) {
|
|
@@ -42,7 +42,7 @@ export function getRouteComponents(routes, { globalApp, ssrMode, props, reporter
|
|
|
42
42
|
}, "*"));
|
|
43
43
|
return routeElements;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
function renderRoutes({ routesConfig, props, ssrMode, reporter }) {
|
|
46
46
|
if (!routesConfig) {
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
@@ -58,7 +58,7 @@ export function renderRoutes({ routesConfig, props, ssrMode, reporter }) {
|
|
|
58
58
|
});
|
|
59
59
|
return routeElements;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
function getLocation(serverContext) {
|
|
62
62
|
var _url_replace;
|
|
63
63
|
const { pathname, url } = (serverContext === null || serverContext === void 0 ? void 0 : serverContext.request) || {};
|
|
64
64
|
const cleanUrl = url === null || url === void 0 ? void 0 : (_url_replace = url.replace("http://", "")) === null || _url_replace === void 0 ? void 0 : _url_replace.replace("https://", "");
|
|
@@ -68,12 +68,12 @@ export function getLocation(serverContext) {
|
|
|
68
68
|
}
|
|
69
69
|
return cleanUrl.substring(index);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
const urlJoin = (...parts) => {
|
|
72
72
|
const separator = "/";
|
|
73
73
|
const replace = new RegExp(`${separator}{1,}`, "g");
|
|
74
74
|
return standardSlash(parts.join(separator).replace(replace, separator));
|
|
75
75
|
};
|
|
76
|
-
|
|
76
|
+
function standardSlash(str) {
|
|
77
77
|
let addr = str;
|
|
78
78
|
if (!addr || typeof addr !== "string") {
|
|
79
79
|
return addr;
|
|
@@ -89,7 +89,7 @@ export function standardSlash(str) {
|
|
|
89
89
|
}
|
|
90
90
|
return addr;
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
function serializeErrors(errors) {
|
|
93
93
|
if (!errors) {
|
|
94
94
|
return null;
|
|
95
95
|
}
|
|
@@ -113,7 +113,7 @@ export function serializeErrors(errors) {
|
|
|
113
113
|
}
|
|
114
114
|
return serialized;
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
function deserializeErrors(errors) {
|
|
117
117
|
if (!errors) {
|
|
118
118
|
return null;
|
|
119
119
|
}
|
|
@@ -132,3 +132,12 @@ export function deserializeErrors(errors) {
|
|
|
132
132
|
}
|
|
133
133
|
return serialized;
|
|
134
134
|
}
|
|
135
|
+
export {
|
|
136
|
+
deserializeErrors,
|
|
137
|
+
getLocation,
|
|
138
|
+
getRouteComponents,
|
|
139
|
+
renderRoutes,
|
|
140
|
+
serializeErrors,
|
|
141
|
+
standardSlash,
|
|
142
|
+
urlJoin
|
|
143
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLocation, useNavigate, useParams } from "@modern-js/runtime-utils/router";
|
|
3
|
-
|
|
3
|
+
const withRouter = (Component) => {
|
|
4
4
|
return (props) => {
|
|
5
5
|
const location = useLocation();
|
|
6
6
|
const params = useParams();
|
|
@@ -13,3 +13,6 @@ export const withRouter = (Component) => {
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
export {
|
|
17
|
+
withRouter
|
|
18
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const RuntimeReactContext = createContext({});
|
|
3
|
+
const ServerRouterContext = createContext({});
|
|
4
|
+
export {
|
|
5
|
+
RuntimeReactContext,
|
|
6
|
+
ServerRouterContext
|
|
7
|
+
};
|
|
@@ -1,110 +1,119 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
1
5
|
import crypto from "crypto";
|
|
2
|
-
import { Buffer } from "buffer";
|
|
6
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
3
7
|
import * as t from "@babel/types";
|
|
4
8
|
import { get } from "@modern-js/utils/lodash";
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const fsHash = crypto.createHash("md5");
|
|
18
|
-
const md5 = fsHash.update(fileBuf).digest("hex");
|
|
19
|
-
return md5;
|
|
20
|
-
}
|
|
21
|
-
function getUseLoaderPath(path, calleeName) {
|
|
22
|
-
const { node } = path;
|
|
23
|
-
if (!calleeName || node.callee.name !== calleeName) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const arg1 = get(node, "arguments.0");
|
|
27
|
-
if (t.isFunction(arg1) || t.isFunctionExpression(arg1) || t.isArrowFunctionExpression(arg1) || t.isIdentifier(arg1) || t.isCallExpression(arg1) || t.isMemberExpression(arg1)) {
|
|
28
|
-
const loaderPath = path.get("arguments.0");
|
|
29
|
-
if (isDuplicateInnerLoader(loaderPath)) {
|
|
30
|
-
return false;
|
|
31
|
-
} else {
|
|
32
|
-
return loaderPath;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
console.warn("useLoader 中 loaderId 生成失败,请检查 useLoader");
|
|
36
|
-
throw path.buildCodeFrameError(`
|
|
37
|
-
please check the usage of ${path.node.name}
|
|
38
|
-
`);
|
|
39
|
-
}
|
|
40
|
-
function isDuplicateInnerLoader(path) {
|
|
41
|
-
const { node } = path;
|
|
42
|
-
if (t.isFunctionExpression(node.callee)) {
|
|
43
|
-
if (t.isBlockStatement(node.callee.body)) {
|
|
44
|
-
if (get(node.callee.body, "body.0.declarations.0.id.name") === "innerLoader" && get(node.callee.body, "body.2.argument.name") === "innerLoader") {
|
|
45
|
-
return true;
|
|
9
|
+
var require_babel_plugin_ssr_loader_id = __commonJS({
|
|
10
|
+
"src/ssr/cli/babel-plugin-ssr-loader-id.ts"(exports, module) {
|
|
11
|
+
const RUNTIME_PACKAGE_NAMES = [
|
|
12
|
+
"@modern-js/runtime"
|
|
13
|
+
];
|
|
14
|
+
const FUNCTION_USE_LOADER_NAME = "useLoader";
|
|
15
|
+
function getHash(filepath) {
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
const point = filepath.indexOf(cwd);
|
|
18
|
+
let relativePath = filepath;
|
|
19
|
+
if (point !== -1) {
|
|
20
|
+
relativePath = filepath.substring(point + cwd.length);
|
|
46
21
|
}
|
|
22
|
+
const fileBuf = Buffer2.from(relativePath);
|
|
23
|
+
const fsHash = crypto.createHash("md5");
|
|
24
|
+
const md5 = fsHash.update(fileBuf).digest("hex");
|
|
25
|
+
return md5;
|
|
47
26
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
t.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
t.returnStatement(t.identifier("innerLoader"))
|
|
58
|
-
])), []);
|
|
59
|
-
}
|
|
60
|
-
module.exports = function() {
|
|
61
|
-
let useLoader = null;
|
|
62
|
-
let hash = "";
|
|
63
|
-
let index = 0;
|
|
64
|
-
function genId() {
|
|
65
|
-
return `${hash}_${index++}`;
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
name: "babel-plugin-ssr-loader-id",
|
|
69
|
-
pre() {
|
|
70
|
-
index = 0;
|
|
71
|
-
useLoader = null;
|
|
72
|
-
hash = "";
|
|
73
|
-
},
|
|
74
|
-
visitor: {
|
|
75
|
-
ImportDeclaration(path, state) {
|
|
76
|
-
if (useLoader) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
if (!RUNTIME_PACKAGE_NAMES.includes(get(path, "node.source.value"))) {
|
|
27
|
+
function getUseLoaderPath(path, calleeName) {
|
|
28
|
+
const { node } = path;
|
|
29
|
+
if (!calleeName || node.callee.name !== calleeName) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const arg1 = get(node, "arguments.0");
|
|
33
|
+
if (t.isFunction(arg1) || t.isFunctionExpression(arg1) || t.isArrowFunctionExpression(arg1) || t.isIdentifier(arg1) || t.isCallExpression(arg1) || t.isMemberExpression(arg1)) {
|
|
34
|
+
const loaderPath = path.get("arguments.0");
|
|
35
|
+
if (isDuplicateInnerLoader(loaderPath)) {
|
|
80
36
|
return false;
|
|
37
|
+
} else {
|
|
38
|
+
return loaderPath;
|
|
81
39
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let loaderPath = getUseLoaderPath(path, useLoader);
|
|
95
|
-
if (loaderPath) {
|
|
96
|
-
if (!Array.isArray(loaderPath)) {
|
|
97
|
-
loaderPath = [
|
|
98
|
-
loaderPath
|
|
99
|
-
];
|
|
40
|
+
}
|
|
41
|
+
console.warn("useLoader 中 loaderId 生成失败,请检查 useLoader");
|
|
42
|
+
throw path.buildCodeFrameError(`
|
|
43
|
+
please check the usage of ${path.node.name}
|
|
44
|
+
`);
|
|
45
|
+
}
|
|
46
|
+
function isDuplicateInnerLoader(path) {
|
|
47
|
+
const { node } = path;
|
|
48
|
+
if (t.isFunctionExpression(node.callee)) {
|
|
49
|
+
if (t.isBlockStatement(node.callee.body)) {
|
|
50
|
+
if (get(node.callee.body, "body.0.declarations.0.id.name") === "innerLoader" && get(node.callee.body, "body.2.argument.name") === "innerLoader") {
|
|
51
|
+
return true;
|
|
100
52
|
}
|
|
101
|
-
loaderPath.forEach((p) => {
|
|
102
|
-
p.replaceWith(getSelfRunLoaderExpression(p.node, genId()));
|
|
103
|
-
});
|
|
104
|
-
return false;
|
|
105
53
|
}
|
|
106
|
-
return false;
|
|
107
54
|
}
|
|
55
|
+
return false;
|
|
108
56
|
}
|
|
109
|
-
|
|
110
|
-
|
|
57
|
+
function getSelfRunLoaderExpression(loaderExpression, id) {
|
|
58
|
+
return t.callExpression(t.functionExpression(null, [], t.blockStatement([
|
|
59
|
+
t.variableDeclaration("var", [
|
|
60
|
+
t.variableDeclarator(t.identifier("innerLoader"), loaderExpression)
|
|
61
|
+
]),
|
|
62
|
+
t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("innerLoader"), t.identifier("id")), t.stringLiteral(id))),
|
|
63
|
+
t.returnStatement(t.identifier("innerLoader"))
|
|
64
|
+
])), []);
|
|
65
|
+
}
|
|
66
|
+
module.exports = function() {
|
|
67
|
+
let useLoader = null;
|
|
68
|
+
let hash = "";
|
|
69
|
+
let index = 0;
|
|
70
|
+
function genId() {
|
|
71
|
+
return `${hash}_${index++}`;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
name: "babel-plugin-ssr-loader-id",
|
|
75
|
+
pre() {
|
|
76
|
+
index = 0;
|
|
77
|
+
useLoader = null;
|
|
78
|
+
hash = "";
|
|
79
|
+
},
|
|
80
|
+
visitor: {
|
|
81
|
+
ImportDeclaration(path, state) {
|
|
82
|
+
if (useLoader) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (!RUNTIME_PACKAGE_NAMES.includes(get(path, "node.source.value"))) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
hash = getHash(state.file.opts.filename);
|
|
89
|
+
get(path, "node.specifiers", []).forEach(({ imported, local }) => {
|
|
90
|
+
if (!imported) {
|
|
91
|
+
throw path.buildCodeFrameError(`please \`import { useLoader } from ${RUNTIME_PACKAGE_NAMES[0]}\``);
|
|
92
|
+
}
|
|
93
|
+
if (!useLoader && imported.name === FUNCTION_USE_LOADER_NAME) {
|
|
94
|
+
useLoader = local.name;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return false;
|
|
98
|
+
},
|
|
99
|
+
CallExpression(path) {
|
|
100
|
+
let loaderPath = getUseLoaderPath(path, useLoader);
|
|
101
|
+
if (loaderPath) {
|
|
102
|
+
if (!Array.isArray(loaderPath)) {
|
|
103
|
+
loaderPath = [
|
|
104
|
+
loaderPath
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
loaderPath.forEach((p) => {
|
|
108
|
+
p.replaceWith(getSelfRunLoaderExpression(p.node, genId()));
|
|
109
|
+
});
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
export default require_babel_plugin_ssr_loader_id();
|
|
@@ -20,7 +20,7 @@ const checkUseStringSSR = (config) => {
|
|
|
20
20
|
const { output } = config;
|
|
21
21
|
return Boolean(output === null || output === void 0 ? void 0 : output.ssg) || hasStringSSREntry(config);
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
const ssrPlugin = () => ({
|
|
24
24
|
name: "@modern-js/plugin-ssr",
|
|
25
25
|
required: [
|
|
26
26
|
"@modern-js/runtime"
|
|
@@ -161,4 +161,8 @@ export const ssrPlugin = () => ({
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
|
-
|
|
164
|
+
var cli_default = ssrPlugin;
|
|
165
|
+
export {
|
|
166
|
+
cli_default as default,
|
|
167
|
+
ssrPlugin
|
|
168
|
+
};
|
|
@@ -1,91 +1,100 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
1
5
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
6
|
import path from "path";
|
|
3
7
|
import { fs } from "@modern-js/utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
var require_loadable_bundler_plugin = __commonJS({
|
|
9
|
+
"src/ssr/cli/loadable-bundler-plugin.ts"(exports, module) {
|
|
10
|
+
class LoadablePlugin {
|
|
11
|
+
apply(compiler) {
|
|
12
|
+
this.compiler = compiler;
|
|
13
|
+
compiler.options.output.chunkLoadingGlobal = this.opts.chunkLoadingGlobal;
|
|
14
|
+
if (this.opts.outputAsset || this.opts.writeToDisk) {
|
|
15
|
+
compiler.hooks.make.tap(LoadablePlugin.name, (compilation) => {
|
|
16
|
+
compilation.hooks.processAssets.tap({
|
|
17
|
+
name: LoadablePlugin.name,
|
|
18
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
19
|
+
}, () => {
|
|
20
|
+
const asset = this.handleEmit(compilation);
|
|
21
|
+
if (asset) {
|
|
22
|
+
compilation.emitAsset(this.opts.filename, asset);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
handleEmit(compilation) {
|
|
29
|
+
const stats = compilation.getStats().toJson({
|
|
30
|
+
all: false,
|
|
31
|
+
assets: true,
|
|
32
|
+
// rspack not support cachedAssets,
|
|
33
|
+
cachedAssets: true,
|
|
34
|
+
chunks: true,
|
|
35
|
+
chunkGroups: true,
|
|
36
|
+
entrypoints: true,
|
|
37
|
+
// rspack not support chunkGroupChildren.
|
|
38
|
+
chunkGroupChildren: true,
|
|
39
|
+
hash: true,
|
|
40
|
+
ids: true,
|
|
41
|
+
outputPath: true,
|
|
42
|
+
publicPath: true
|
|
18
43
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
chunkGroupChildren: true,
|
|
33
|
-
hash: true,
|
|
34
|
-
ids: true,
|
|
35
|
-
outputPath: true,
|
|
36
|
-
publicPath: true
|
|
37
|
-
});
|
|
38
|
-
const output = {
|
|
39
|
-
...stats,
|
|
40
|
-
generator: "loadable-components",
|
|
41
|
-
chunks: [
|
|
42
|
-
...stats.chunks || []
|
|
43
|
-
].map((chunk) => {
|
|
44
|
-
return {
|
|
45
|
-
id: chunk.id,
|
|
46
|
-
files: [
|
|
47
|
-
...chunk.files || []
|
|
48
|
-
]
|
|
44
|
+
const output = {
|
|
45
|
+
...stats,
|
|
46
|
+
generator: "loadable-components",
|
|
47
|
+
chunks: [
|
|
48
|
+
...stats.chunks || []
|
|
49
|
+
].map((chunk) => {
|
|
50
|
+
return {
|
|
51
|
+
id: chunk.id,
|
|
52
|
+
files: [
|
|
53
|
+
...chunk.files || []
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
})
|
|
49
57
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (this.opts.writeToDisk) {
|
|
54
|
-
this.writeAssetsFile(result);
|
|
55
|
-
}
|
|
56
|
-
if (this.opts.outputAsset) {
|
|
57
|
-
return {
|
|
58
|
-
source() {
|
|
59
|
-
return result;
|
|
60
|
-
},
|
|
61
|
-
size() {
|
|
62
|
-
return result.length;
|
|
58
|
+
const result = JSON.stringify(output, null, 2);
|
|
59
|
+
if (this.opts.writeToDisk) {
|
|
60
|
+
this.writeAssetsFile(result);
|
|
63
61
|
}
|
|
64
|
-
|
|
62
|
+
if (this.opts.outputAsset) {
|
|
63
|
+
return {
|
|
64
|
+
source() {
|
|
65
|
+
return result;
|
|
66
|
+
},
|
|
67
|
+
size() {
|
|
68
|
+
return result.length;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
writeAssetsFile(manifest) {
|
|
75
|
+
var _this_compiler;
|
|
76
|
+
const outputFolder = (_this_compiler = this.compiler) === null || _this_compiler === void 0 ? void 0 : _this_compiler.options.output.path;
|
|
77
|
+
const outputFile = path.resolve(outputFolder || "", this.opts.filename);
|
|
78
|
+
fs.outputFileSync(outputFile, manifest);
|
|
79
|
+
}
|
|
80
|
+
constructor({ filename = "loadable-stats.json", path: path2, writeToDisk, outputAsset = true, chunkLoadingGlobal = "__LOADABLE_LOADED_CHUNKS__" } = {
|
|
81
|
+
filename: "loadable-stats.json",
|
|
82
|
+
outputAsset: true,
|
|
83
|
+
chunkLoadingGlobal: "__LOADABLE_LOADED_CHUNKS__"
|
|
84
|
+
}) {
|
|
85
|
+
_define_property(this, "opts", void 0);
|
|
86
|
+
_define_property(this, "compiler", void 0);
|
|
87
|
+
this.opts = {
|
|
88
|
+
filename,
|
|
89
|
+
path: path2,
|
|
90
|
+
writeToDisk,
|
|
91
|
+
outputAsset,
|
|
92
|
+
chunkLoadingGlobal
|
|
93
|
+
};
|
|
94
|
+
this.compiler = null;
|
|
95
|
+
}
|
|
65
96
|
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
writeAssetsFile(manifest) {
|
|
69
|
-
var _this_compiler;
|
|
70
|
-
const outputFolder = (_this_compiler = this.compiler) === null || _this_compiler === void 0 ? void 0 : _this_compiler.options.output.path;
|
|
71
|
-
const outputFile = path.resolve(outputFolder || "", this.opts.filename);
|
|
72
|
-
fs.outputFileSync(outputFile, manifest);
|
|
73
|
-
}
|
|
74
|
-
constructor({ filename = "loadable-stats.json", path: path2, writeToDisk, outputAsset = true, chunkLoadingGlobal = "__LOADABLE_LOADED_CHUNKS__" } = {
|
|
75
|
-
filename: "loadable-stats.json",
|
|
76
|
-
outputAsset: true,
|
|
77
|
-
chunkLoadingGlobal: "__LOADABLE_LOADED_CHUNKS__"
|
|
78
|
-
}) {
|
|
79
|
-
_define_property(this, "opts", void 0);
|
|
80
|
-
_define_property(this, "compiler", void 0);
|
|
81
|
-
this.opts = {
|
|
82
|
-
filename,
|
|
83
|
-
path: path2,
|
|
84
|
-
writeToDisk,
|
|
85
|
-
outputAsset,
|
|
86
|
-
chunkLoadingGlobal
|
|
87
|
-
};
|
|
88
|
-
this.compiler = null;
|
|
97
|
+
module.exports = LoadablePlugin;
|
|
89
98
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
99
|
+
});
|
|
100
|
+
export default require_loadable_bundler_plugin();
|
|
@@ -6,7 +6,7 @@ import { RenderLevel } from "./serverRender/types";
|
|
|
6
6
|
import { WithCallback } from "./react/withCallback";
|
|
7
7
|
import { formatClient, mockResponse, isReact18 } from "./utils";
|
|
8
8
|
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "./serverRender/utils";
|
|
9
|
-
|
|
9
|
+
const ssr = (config) => ({
|
|
10
10
|
name: "@modern-js/plugin-ssr",
|
|
11
11
|
setup: () => {
|
|
12
12
|
const mockResp = mockResponse();
|
|
@@ -128,5 +128,9 @@ export const ssr = (config) => ({
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
|
-
|
|
131
|
+
var ssr_default = ssr;
|
|
132
132
|
export * from "./react";
|
|
133
|
+
export {
|
|
134
|
+
ssr_default as default,
|
|
135
|
+
ssr
|
|
136
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formatServer } from "./utils";
|
|
2
2
|
import render from "./serverRender";
|
|
3
3
|
import { createSSRTracker } from "./serverRender/tracker";
|
|
4
|
-
|
|
4
|
+
const ssr = (config = {}) => ({
|
|
5
5
|
name: "@modern-js/plugin-ssr",
|
|
6
6
|
setup: () => {
|
|
7
7
|
return {
|
|
@@ -41,5 +41,9 @@ export const ssr = (config = {}) => ({
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
var index_node_default = ssr;
|
|
45
45
|
export * from "./react";
|
|
46
|
+
export {
|
|
47
|
+
index_node_default as default,
|
|
48
|
+
ssr
|
|
49
|
+
};
|
|
@@ -46,4 +46,7 @@ const prefetch = async (App, context, config) => run(context.ssrContext.request.
|
|
|
46
46
|
storeState: context === null || context === void 0 ? void 0 : (_context_store = context.store) === null || _context_store === void 0 ? void 0 : _context_store.getState()
|
|
47
47
|
};
|
|
48
48
|
});
|
|
49
|
-
|
|
49
|
+
var prefetch_default = prefetch;
|
|
50
|
+
export {
|
|
51
|
+
prefetch_default as default
|
|
52
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
let csr = false;
|
|
3
|
-
|
|
3
|
+
const NoSSR = (props) => {
|
|
4
4
|
const [isMounted, setMounted] = useState(csr);
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
csr = true;
|
|
@@ -9,3 +9,6 @@ export const NoSSR = (props) => {
|
|
|
9
9
|
const { children, fallback = null } = props;
|
|
10
10
|
return React.createElement(React.Fragment, null, isMounted ? children : fallback);
|
|
11
11
|
};
|
|
12
|
+
export {
|
|
13
|
+
NoSSR
|
|
14
|
+
};
|
|
@@ -83,4 +83,7 @@ function factory(Component) {
|
|
|
83
83
|
}
|
|
84
84
|
const NullComponent = () => null;
|
|
85
85
|
const SprSideEffects = withSideEffect(reducePropsToState, handleClientStateChange, mapStateOnServer)(NullComponent);
|
|
86
|
-
|
|
86
|
+
const PreRender = factory(SprSideEffects);
|
|
87
|
+
export {
|
|
88
|
+
PreRender
|
|
89
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -2,7 +2,7 @@ const REQUEST_META = [
|
|
|
2
2
|
"header",
|
|
3
3
|
"query"
|
|
4
4
|
];
|
|
5
|
-
|
|
5
|
+
const getInnermostProperty = function getInnermostProperty2(propsList, propName) {
|
|
6
6
|
for (let i = propsList.length - 1; i >= 0; i--) {
|
|
7
7
|
const props = propsList[i];
|
|
8
8
|
if (props.hasOwnProperty(propName)) {
|
|
@@ -11,7 +11,7 @@ export const getInnermostProperty = function getInnermostProperty2(propsList, pr
|
|
|
11
11
|
}
|
|
12
12
|
return null;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
const getOutermostProperty = function getOutermostProperty2(propsList, propName) {
|
|
15
15
|
for (const props of propsList) {
|
|
16
16
|
if (props.hasOwnProperty(propName)) {
|
|
17
17
|
return props[propName];
|
|
@@ -19,7 +19,7 @@ export const getOutermostProperty = function getOutermostProperty2(propsList, pr
|
|
|
19
19
|
}
|
|
20
20
|
return null;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
const aggKeysFromPropsList = function aggKeysFromPropsList2(propsList, propName) {
|
|
23
23
|
const initResult = REQUEST_META.reduce((result, next) => {
|
|
24
24
|
const key = next;
|
|
25
25
|
result[key] = [];
|
|
@@ -43,7 +43,7 @@ export const aggKeysFromPropsList = function aggKeysFromPropsList2(propsList, pr
|
|
|
43
43
|
return result;
|
|
44
44
|
}, res);
|
|
45
45
|
};
|
|
46
|
-
|
|
46
|
+
const aggMatchesFromPropsList = function aggMatchesFromPropsList2(propsList, propName) {
|
|
47
47
|
const initResult = REQUEST_META.reduce((result, next) => {
|
|
48
48
|
const key = next;
|
|
49
49
|
result[key] = {};
|
|
@@ -81,6 +81,13 @@ function usefulArray(target) {
|
|
|
81
81
|
}
|
|
82
82
|
return Array.isArray(target) && target.length > 0;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
function exist(target) {
|
|
85
85
|
return target != null;
|
|
86
86
|
}
|
|
87
|
+
export {
|
|
88
|
+
aggKeysFromPropsList,
|
|
89
|
+
aggMatchesFromPropsList,
|
|
90
|
+
exist,
|
|
91
|
+
getInnermostProperty,
|
|
92
|
+
getOutermostProperty
|
|
93
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRef, useLayoutEffect } from "react";
|
|
2
|
-
|
|
2
|
+
const WithCallback = ({ callback, children }) => {
|
|
3
3
|
const once = useRef(false);
|
|
4
4
|
useLayoutEffect(() => {
|
|
5
5
|
if (once.current) {
|
|
@@ -12,3 +12,6 @@ export const WithCallback = ({ callback, children }) => {
|
|
|
12
12
|
]);
|
|
13
13
|
return children;
|
|
14
14
|
};
|
|
15
|
+
export {
|
|
16
|
+
WithCallback
|
|
17
|
+
};
|