ssr-plugin-react 6.2.72 → 6.2.74
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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +18 -0
- package/cjs/entry/client-entry.d.ts.map +1 -1
- package/cjs/entry/client-entry.js +7 -11
- package/cjs/entry/client-entry.js.map +1 -1
- package/cjs/entry/context.d.ts +1 -2
- package/cjs/entry/context.d.ts.map +1 -1
- package/cjs/entry/context.js +5 -5
- package/cjs/entry/context.js.map +1 -1
- package/cjs/entry/create.d.ts +7 -0
- package/cjs/entry/create.d.ts.map +1 -0
- package/cjs/entry/create.js +37 -0
- package/cjs/entry/create.js.map +1 -0
- package/cjs/entry/server-entry.d.ts +1 -1
- package/cjs/entry/server-entry.d.ts.map +1 -1
- package/cjs/entry/server-entry.js +16 -16
- package/cjs/entry/server-entry.js.map +1 -1
- package/esm/entry/client-entry.d.ts.map +1 -1
- package/esm/entry/client-entry.js +7 -11
- package/esm/entry/client-entry.js.map +1 -1
- package/esm/entry/context.d.ts +1 -2
- package/esm/entry/context.d.ts.map +1 -1
- package/esm/entry/context.js +3 -3
- package/esm/entry/context.js.map +1 -1
- package/esm/entry/create.d.ts +7 -0
- package/esm/entry/create.d.ts.map +1 -0
- package/esm/entry/create.js +32 -0
- package/esm/entry/create.js.map +1 -0
- package/esm/entry/server-entry.d.ts +1 -1
- package/esm/entry/server-entry.d.ts.map +1 -1
- package/esm/entry/server-entry.js +15 -15
- package/esm/entry/server-entry.js.map +1 -1
- package/package.json +2 -1
- package/src/entry/client-entry.tsx +6 -10
- package/src/entry/context.tsx +9 -9
- package/src/entry/create.ts +37 -0
- package/src/entry/server-entry.tsx +15 -15
- package/cjs/entry/create-context.d.ts +0 -5
- package/cjs/entry/create-context.d.ts.map +0 -1
- package/cjs/entry/create-context.js +0 -19
- package/cjs/entry/create-context.js.map +0 -1
- package/cjs/entry/create-router.d.ts +0 -4
- package/cjs/entry/create-router.d.ts.map +0 -1
- package/cjs/entry/create-router.js +0 -9
- package/cjs/entry/create-router.js.map +0 -1
- package/esm/entry/create-context.d.ts +0 -5
- package/esm/entry/create-context.d.ts.map +0 -1
- package/esm/entry/create-context.js +0 -16
- package/esm/entry/create-context.js.map +0 -1
- package/esm/entry/create-router.d.ts +0 -4
- package/esm/entry/create-router.d.ts.map +0 -1
- package/esm/entry/create-router.js +0 -6
- package/esm/entry/create-router.js.map +0 -1
- package/src/entry/create-context.ts +0 -19
- package/src/entry/create-router.ts +0 -10
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
ssr-plugin-react:build: cache hit, replaying output
|
|
1
|
+
ssr-plugin-react:build: cache hit, replaying output ec0cb59fe934d2c7
|
|
2
2
|
ssr-plugin-react:build:
|
|
3
|
-
ssr-plugin-react:build: > ssr-plugin-react@6.2.
|
|
3
|
+
ssr-plugin-react:build: > ssr-plugin-react@6.2.74 build /home/runner/work/ssr/ssr/packages/plugin-react
|
|
4
4
|
ssr-plugin-react:build: > concurrently "tsc -p ./tsconfig.cjs.json " " tsc -p ./tsconfig.esm.json"
|
|
5
5
|
ssr-plugin-react:build:
|
|
6
6
|
ssr-plugin-react:build: [0] tsc -p ./tsconfig.cjs.json exited with code 0
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## [6.2.74](https://github.com/zhangyuang/ssr/compare/plugin-react@6.2.73...plugin-react@6.2.74) (2024-03-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* optimize react scene use context code ([1d3e885](https://github.com/zhangyuang/ssr/commit/1d3e885d4fd5a8fade6f48438592ae2df16374e1))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [6.2.73](https://github.com/zhangyuang/ssr/compare/plugin-react@6.2.72...plugin-react@6.2.73) (2024-03-25)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* valtio single instance error ([0474b30](https://github.com/zhangyuang/ssr/commit/0474b302110adc755285fdcefe9d58757e1b200f))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
1
19
|
## [6.2.72](https://github.com/zhangyuang/ssr/compare/plugin-react@6.2.70...plugin-react@6.2.72) (2024-03-19)
|
|
2
20
|
|
|
3
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-entry.d.ts","sourceRoot":"","sources":["../../src/entry/client-entry.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client-entry.d.ts","sourceRoot":"","sources":["../../src/entry/client-entry.tsx"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAA;AAUrB,QAAA,MAAM,YAAY,QAAa,QAAQ,IAAI,CAkC1C,CAAA;AAID,OAAO,EACL,YAAY,EACb,CAAA"}
|
|
@@ -3,24 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.clientRender = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const ReactDOM = require("react-dom");
|
|
6
|
-
const valtio_1 = require("valtio");
|
|
7
6
|
require("react-router"); // for vite prebundle list
|
|
8
7
|
const react_router_dom_1 = require("react-router-dom");
|
|
9
8
|
const ssr_common_utils_1 = require("ssr-common-utils");
|
|
10
9
|
const ssr_hoc_react_1 = require("ssr-hoc-react");
|
|
11
|
-
const
|
|
12
|
-
const create_router_1 = require("./create-router");
|
|
10
|
+
const create_1 = require("./create");
|
|
13
11
|
const context_1 = require("./context");
|
|
14
|
-
const { FeRoutes, layoutFetch, App
|
|
12
|
+
const { FeRoutes, layoutFetch, App } = create_1.Routes;
|
|
15
13
|
const clientRender = async () => {
|
|
16
|
-
var _a, _b, _c
|
|
14
|
+
var _a, _b, _c;
|
|
17
15
|
const IApp = App !== null && App !== void 0 ? App : function (props) {
|
|
18
16
|
return props.children;
|
|
19
17
|
};
|
|
20
|
-
(0, ssr_common_utils_1.setStoreContext)(
|
|
21
|
-
|
|
22
|
-
store[key] = (0, valtio_1.proxy)((_a = window.__VALTIO_DATA__) === null || _a === void 0 ? void 0 : _a[key]);
|
|
23
|
-
}
|
|
18
|
+
(0, ssr_common_utils_1.setStoreContext)((0, create_1.ssrCreateContext)());
|
|
19
|
+
const store = (0, create_1.createStore)(window.__VALTIO_DATA__);
|
|
24
20
|
(0, ssr_common_utils_1.setStore)(store !== null && store !== void 0 ? store : {});
|
|
25
21
|
const baseName = (0, ssr_common_utils_1.isMicro)() ? window.clientPrefix : window.prefix;
|
|
26
22
|
const routes = await (0, ssr_common_utils_1.preloadComponent)(FeRoutes, baseName);
|
|
@@ -41,9 +37,9 @@ const clientRender = async () => {
|
|
|
41
37
|
})
|
|
42
38
|
});
|
|
43
39
|
}))))
|
|
44
|
-
})), document.querySelector((
|
|
40
|
+
})), document.querySelector((_a = window.ssrDevInfo.rootId) !== null && _a !== void 0 ? _a : '#app'));
|
|
45
41
|
if (!window.__USE_VITE__) {
|
|
46
|
-
(
|
|
42
|
+
(_c = (_b = module === null || module === void 0 ? void 0 : module.hot) === null || _b === void 0 ? void 0 : _b.accept) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
47
43
|
}
|
|
48
44
|
};
|
|
49
45
|
exports.clientRender = clientRender;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-entry.js","sourceRoot":"","sources":["../../src/entry/client-entry.tsx"],"names":[],"mappings":";;;AAAA,iCAAqC;AACrC,sCAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"client-entry.js","sourceRoot":"","sources":["../../src/entry/client-entry.tsx"],"names":[],"mappings":";;;AAAA,iCAAqC;AACrC,sCAAqC;AACrC,wBAAqB,CAAC,0BAA0B;AAChD,uDAA+D;AAC/D,uDAAuF;AACvF,iDAA6C;AAE7C,qCAAgE;AAChE,uCAAsC;AAEtC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,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AC,CAAA;YACjD,OAAO,IAAA,qBAAa,EAAC,wBAAK,EAAE;gBAC1B,KAAK,EAAE,IAAI;gBACX,GAAG,EAAE,IAAI;gBACT,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,qBAAa,EAAC,gBAAgB,EAAE;oBAC5C,GAAG,EAAE,QAAQ,CAAC,QAAQ;iBACvB,CAAC;aACH,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC,CAAC,CAAC;KACV,CAAC,CAAC,EACD,QAAQ,CAAC,aAAa,CAAC,MAAA,MAAM,CAAC,UAAU,CAAC,MAAM,mCAAI,MAAM,CAAC,CAAC,CAAA;IAC/D,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;QACxB,MAAA,MAAC,MAAc,aAAd,MAAM,uBAAN,MAAM,CAAU,GAAG,0CAAE,MAAM,kDAAI,CAAA;KACjC;AACH,CAAC,CAAA;AAKC,oCAAY;AAHd,YAAY,EAAE,CAAA"}
|
package/cjs/entry/context.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="context" />
|
|
2
1
|
/// <reference types="react" />
|
|
3
2
|
import { IProps } from 'ssr-types';
|
|
4
|
-
export declare function AppContext(props: IProps): import("react").FunctionComponentElement<import("react").ProviderProps<import("
|
|
3
|
+
export declare function AppContext(props: IProps): import("react").FunctionComponentElement<import("react").ProviderProps<import("ssr-types").IContext<any>>>;
|
|
5
4
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAoC,MAAM,WAAW,CAAA;AA4BpE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,8GAUvC"}
|
package/cjs/entry/context.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppContext = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const { reducer, state } = create_router_1.Routes;
|
|
5
|
+
const create_1 = require("./create");
|
|
6
|
+
const { reducer, state } = create_1.Routes;
|
|
8
7
|
const userState = state !== null && state !== void 0 ? state : {};
|
|
9
8
|
const userReducer = reducer !== null && reducer !== void 0 ? reducer : function () { };
|
|
10
9
|
const isDev = process.env.NODE_ENV !== 'production';
|
|
@@ -18,13 +17,14 @@ function defaultReducer(state, action) {
|
|
|
18
17
|
return { ...state, ...action.payload };
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
const initialState = Object.assign({}, userState !== null && userState !== void 0 ? userState : {}, window.__INITIAL_DATA__);
|
|
22
20
|
function combineReducer(state, action) {
|
|
23
21
|
return defaultReducer(state, action) || userReducer(state, action);
|
|
24
22
|
}
|
|
25
23
|
function AppContext(props) {
|
|
24
|
+
const initialState = Object.assign({}, userState !== null && userState !== void 0 ? userState : {}, __isBrowser__ ? window === null || window === void 0 ? void 0 : window.__INITIAL_DATA__ : props.initialState);
|
|
25
|
+
const Context = (0, create_1.ssrCreateContext)();
|
|
26
26
|
const [state, dispatch] = (0, react_1.useReducer)(combineReducer, initialState);
|
|
27
|
-
return (0, react_1.createElement)(
|
|
27
|
+
return (0, react_1.createElement)(Context.Provider, {
|
|
28
28
|
value: {
|
|
29
29
|
state,
|
|
30
30
|
dispatch
|
package/cjs/entry/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":";;;AAAA,iCAAiD;AAEjD,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":";;;AAAA,iCAAiD;AAEjD,qC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AAK,EAAE;YACL,KAAK;YACL,QAAQ;SACT;KACF,EAAE,KAAK,CAAC,QAAe,CAAC,CAAA;AAC3B,CAAC;AAVD,gCAUC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from 'react';
|
|
2
|
+
import type { IContext } from 'ssr-types';
|
|
3
|
+
import { ReactRoutesType } from 'ssr-types';
|
|
4
|
+
export declare const Routes: ReactRoutesType;
|
|
5
|
+
export declare const ssrCreateContext: () => Context<IContext<any>>;
|
|
6
|
+
export declare function createStore(initialData?: any): any;
|
|
7
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/entry/create.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAMzC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,eAAO,MAAM,MAAM,iBAAgE,CAAA;AAEnF,eAAO,MAAM,gBAAgB,8BAe5B,CAAA;AAED,wBAAgB,WAAW,CAAE,WAAW,CAAC,EAAE,GAAG,OAO7C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStore = exports.ssrCreateContext = exports.Routes = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const valtio_1 = require("valtio");
|
|
6
|
+
const ssr_deepclone_1 = require("ssr-deepclone");
|
|
7
|
+
const ssr_common_utils_1 = require("ssr-common-utils");
|
|
8
|
+
const declareRoutes = require("_build/ssr-declare-routes");
|
|
9
|
+
const ManualRoutes = require("_build/ssr-manual-routes");
|
|
10
|
+
exports.Routes = (0, ssr_common_utils_1.combineRoutes)(declareRoutes, ManualRoutes);
|
|
11
|
+
const ssrCreateContext = () => {
|
|
12
|
+
let STORE_CONTEXT;
|
|
13
|
+
if (__isBrowser__) {
|
|
14
|
+
STORE_CONTEXT = window.STORE_CONTEXT || (0, react_1.createContext)({
|
|
15
|
+
state: {}
|
|
16
|
+
});
|
|
17
|
+
window.STORE_CONTEXT = STORE_CONTEXT;
|
|
18
|
+
return STORE_CONTEXT;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
STORE_CONTEXT = (0, react_1.createContext)({
|
|
22
|
+
state: {}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return STORE_CONTEXT;
|
|
26
|
+
};
|
|
27
|
+
exports.ssrCreateContext = ssrCreateContext;
|
|
28
|
+
function createStore(initialData) {
|
|
29
|
+
const { store } = exports.Routes;
|
|
30
|
+
const storeInstance = initialData ? store : (0, ssr_deepclone_1.deepClone)(store);
|
|
31
|
+
for (const key in storeInstance) {
|
|
32
|
+
storeInstance[key] = initialData ? (0, valtio_1.proxy)(initialData[key]) : (0, valtio_1.proxy)(storeInstance[key]);
|
|
33
|
+
}
|
|
34
|
+
return storeInstance;
|
|
35
|
+
}
|
|
36
|
+
exports.createStore = createStore;
|
|
37
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/entry/create.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAGrC,mCAA8B;AAC9B,iDAAyC;AACzC,uDAAgD;AAChD,2DAA0D;AAC1D,yDAAwD;AAG3C,QAAA,MAAM,GAAG,IAAA,gCAAa,EAAC,aAAa,EAAE,YAAY,CAAoB,CAAA;AAE5E,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,IAAI,aAAgC,CAAA;IAEpC,IAAI,aAAa,EAAE;QACjB,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,IAAA,qBAAa,EAAW;YAC9D,KAAK,EAAE,EAAE;SACV,CAAC,CAAA;QACF,MAAM,CAAC,aAAa,GAAG,aAAa,CAAA;QACpC,OAAO,aAAa,CAAA;KACrB;SAAM;QACL,aAAa,GAAG,IAAA,qBAAa,EAAW;YACtC,KAAK,EAAE,EAAE;SACV,CAAC,CAAA;KACH;IACD,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA;AAfY,QAAA,gBAAgB,oBAe5B;AAED,SAAgB,WAAW,CAAE,WAAiB;IAC5C,MAAM,EAAE,KAAK,EAAE,GAAG,cAAM,CAAA;IACxB,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,yBAAS,EAAC,KAAK,CAAC,CAAA;IAC5D,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;QAC/B,aAAa,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;KACvF;IACD,OAAO,aAAa,CAAA;AACtB,CAAC;AAPD,kCAOC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ISSRContext, IConfig } from 'ssr-types';
|
|
3
|
-
import { Routes } from './create
|
|
3
|
+
import { Routes } from './create';
|
|
4
4
|
declare const serverRender: (ctx: ISSRContext, config: IConfig) => Promise<string | import("stream").Readable | NodeJS.ReadableStream | import("ssr-types").PipeableStream | {
|
|
5
5
|
html: string;
|
|
6
6
|
teleportsContext: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-entry.d.ts","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAmD,MAAM,WAAW,CAAA;AAGjG,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"server-entry.d.ts","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAmD,MAAM,WAAW,CAAA;AAGjG,OAAO,EAAE,MAAM,EAAiC,MAAM,UAAU,CAAA;AAIhE,QAAA,MAAM,YAAY,QAAe,WAAW,UAAU,OAAO;;;EAuF5D,CAAA;AAED,OAAO,EACL,YAAY,EACZ,MAAM,EACP,CAAA"}
|
|
@@ -8,12 +8,13 @@ const react_router_dom_1 = require("react-router-dom");
|
|
|
8
8
|
const server_1 = require("react-dom/server");
|
|
9
9
|
const ssr_common_utils_1 = require("ssr-common-utils");
|
|
10
10
|
const ssr_serialize_javascript_1 = require("ssr-serialize-javascript");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
Object.defineProperty(exports, "Routes", { enumerable: true, get: function () { return
|
|
14
|
-
const { FeRoutes, layoutFetch, state, Layout
|
|
11
|
+
const context_1 = require("./context");
|
|
12
|
+
const create_1 = require("./create");
|
|
13
|
+
Object.defineProperty(exports, "Routes", { enumerable: true, get: function () { return create_1.Routes; } });
|
|
14
|
+
const { FeRoutes, layoutFetch, state, Layout } = create_1.Routes;
|
|
15
15
|
const serverRender = async (ctx, config) => {
|
|
16
16
|
var _a;
|
|
17
|
+
const context = (0, create_1.ssrCreateContext)();
|
|
17
18
|
const { mode, parallelFetch, prefix, isVite, isDev, clientPrefix, stream, rootId, hashRouter } = config;
|
|
18
19
|
const rawPath = (_a = ctx.request.path) !== null && _a !== void 0 ? _a : ctx.request.url;
|
|
19
20
|
const path = (0, ssr_common_utils_1.normalizePath)(rawPath, prefix);
|
|
@@ -72,23 +73,22 @@ const serverRender = async (ctx, config) => {
|
|
|
72
73
|
const ele = (0, react_1.createElement)(react_router_dom_1.StaticRouter, {
|
|
73
74
|
location: ctx.request.url,
|
|
74
75
|
basename: prefix === '/' ? undefined : prefix
|
|
75
|
-
}, (0, react_1.createElement)(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, (0, react_1.createElement)(Component, null))));
|
|
76
|
+
}, (0, react_1.createElement)(context_1.AppContext, {
|
|
77
|
+
initialState: combineData,
|
|
78
|
+
children: (0, react_1.createElement)(Layout, {
|
|
79
|
+
ctx: ctx,
|
|
80
|
+
config: config,
|
|
81
|
+
staticList: staticList,
|
|
82
|
+
injectState: injectState
|
|
83
|
+
}, (0, react_1.createElement)(Component, null))
|
|
84
|
+
}));
|
|
85
85
|
// for ctx.body will loose asynclocalstorage context, consume stream in advance like vue2/3
|
|
86
86
|
return stream ? (0, server_1.renderToNodeStream)(ele).pipe(new stream_1.PassThrough()) : (0, server_1.renderToString)(ele);
|
|
87
87
|
};
|
|
88
88
|
return await ssr_common_utils_1.localStorageWrapper.run({
|
|
89
|
-
context:
|
|
89
|
+
context: context,
|
|
90
90
|
ctx,
|
|
91
|
-
store
|
|
91
|
+
store: (0, create_1.createStore)()
|
|
92
92
|
}, fn);
|
|
93
93
|
};
|
|
94
94
|
exports.serverRender = serverRender;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-entry.js","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,+BAA8B;AAC9B,iCAAqC;AACrC,uDAA+C;AAC/C,6CAAqE;AACrE,uDAAqM;AAErM,uEAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"server-entry.js","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,+BAA8B;AAC9B,iCAAqC;AACrC,uDAA+C;AAC/C,6CAAqE;AACrE,uDAAqM;AAErM,uEAAoD;AACpD,uCAAsC;AACtC,qCAAgE;AA+F9D,uFA/FO,eAAM,OA+FP;AA7FR,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,eAAM,CAAA;AAEvD,MAAM,YAAY,GAAG,KAAK,EAAE,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AE;YACtC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG;YACzB,QAAQ,EAAE,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;SAC9C,EAAE,IAAA,qBAAa,EAAC,oBAAU,EAAE;YAC3B,YAAY,EAAE,WAAW;YACzB,QAAQ,EAAE,IAAA,qBAAa,EAAC,MAAM,EAAE;gBAC9B,GAAG,EAAE,GAAG;gBACR,MAAM,EAAE,MAAM;gBACd,UAAU,EAAE,UAAU;gBACtB,WAAW,EAAE,WAAW;aACzB,EAAE,IAAA,qBAAa,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;SACnC,CAAC,CAAC,CAAA;QACH,2FAA2F;QAC3F,OAAO,MAAM,CAAC,CAAC,CAAC,IAAA,2BAAkB,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,oBAAW,EAAE,CAAC,CAAC,CAAC,CAAC,IAAA,uBAAc,EAAC,GAAG,CAAC,CAAA;IACvF,CAAC,CAAA;IAED,OAAO,MAAM,sCAAmB,CAAC,GAAG,CAAC;QACnC,OAAO,EAAE,OAAc;QACvB,GAAG;QACH,KAAK,EAAE,IAAA,oBAAW,GAAE;KACrB,EAAE,EAAE,CAAC,CAAA;AACR,CAAC,CAAA;AAGC,oCAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-entry.d.ts","sourceRoot":"","sources":["../../src/entry/client-entry.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client-entry.d.ts","sourceRoot":"","sources":["../../src/entry/client-entry.tsx"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAA;AAUrB,QAAA,MAAM,YAAY,QAAa,QAAQ,IAAI,CAkC1C,CAAA;AAID,OAAO,EACL,YAAY,EACb,CAAA"}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import * as ReactDOM from 'react-dom';
|
|
3
|
-
import { proxy } from 'valtio';
|
|
4
3
|
import 'react-router'; // for vite prebundle list
|
|
5
4
|
import { BrowserRouter, Route, Switch } from 'react-router-dom';
|
|
6
5
|
import { preloadComponent, isMicro, setStoreContext, setStore } from 'ssr-common-utils';
|
|
7
6
|
import { wrapComponent } from 'ssr-hoc-react';
|
|
8
|
-
import {
|
|
9
|
-
import { Routes } from './create-router';
|
|
7
|
+
import { ssrCreateContext, Routes, createStore } from './create';
|
|
10
8
|
import { AppContext } from './context';
|
|
11
|
-
const { FeRoutes, layoutFetch, App
|
|
9
|
+
const { FeRoutes, layoutFetch, App } = Routes;
|
|
12
10
|
const clientRender = async () => {
|
|
13
|
-
var _a, _b, _c
|
|
11
|
+
var _a, _b, _c;
|
|
14
12
|
const IApp = App !== null && App !== void 0 ? App : function (props) {
|
|
15
13
|
return props.children;
|
|
16
14
|
};
|
|
17
|
-
setStoreContext(
|
|
18
|
-
|
|
19
|
-
store[key] = proxy((_a = window.__VALTIO_DATA__) === null || _a === void 0 ? void 0 : _a[key]);
|
|
20
|
-
}
|
|
15
|
+
setStoreContext(ssrCreateContext());
|
|
16
|
+
const store = createStore(window.__VALTIO_DATA__);
|
|
21
17
|
setStore(store !== null && store !== void 0 ? store : {});
|
|
22
18
|
const baseName = isMicro() ? window.clientPrefix : window.prefix;
|
|
23
19
|
const routes = await preloadComponent(FeRoutes, baseName);
|
|
@@ -38,9 +34,9 @@ const clientRender = async () => {
|
|
|
38
34
|
})
|
|
39
35
|
});
|
|
40
36
|
}))))
|
|
41
|
-
})), document.querySelector((
|
|
37
|
+
})), document.querySelector((_a = window.ssrDevInfo.rootId) !== null && _a !== void 0 ? _a : '#app'));
|
|
42
38
|
if (!window.__USE_VITE__) {
|
|
43
|
-
(
|
|
39
|
+
(_c = (_b = module === null || module === void 0 ? void 0 : module.hot) === null || _b === void 0 ? void 0 : _b.accept) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
44
40
|
}
|
|
45
41
|
};
|
|
46
42
|
clientRender();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-entry.js","sourceRoot":"","sources":["../../src/entry/client-entry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAA;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"client-entry.js","sourceRoot":"","sources":["../../src/entry/client-entry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAA;AACrC,OAAO,cAAc,CAAA,CAAC,0BAA0B;AAChD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,MAAM,CAAA;AAE7C,MAAM,YAAY,GAAG,KAAK,IAAmB,EAAE;;IAC7C,MAAM,IAAI,GAAG,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,UAAS,KAAkB;QAC7C,OAAO,KAAK,CAAC,QAAS,CAAA;IACxB,CAAC,CAAA;IACD,eAAe,CAAC,gBAAgB,EAAS,CAAC,CAAA;IAC1C,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC,CAAA;IACjD,QAAQ,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAA;IACrB,MAAM,QAAQ,GAAG,OAAO,EAAE,C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AAM,kDAAI,CAAA;KACjC;AACH,CAAC,CAAA;AAED,YAAY,EAAE,CAAA;AAEd,OAAO,EACL,YAAY,EACb,CAAA"}
|
package/esm/entry/context.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="context" />
|
|
2
1
|
/// <reference types="react" />
|
|
3
2
|
import { IProps } from 'ssr-types';
|
|
4
|
-
export declare function AppContext(props: IProps): import("react").FunctionComponentElement<import("react").ProviderProps<import("
|
|
3
|
+
export declare function AppContext(props: IProps): import("react").FunctionComponentElement<import("react").ProviderProps<import("ssr-types").IContext<any>>>;
|
|
5
4
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAoC,MAAM,WAAW,CAAA;AA4BpE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,8GAUvC"}
|
package/esm/entry/context.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useReducer, createElement } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { Routes } from './create-router';
|
|
2
|
+
import { ssrCreateContext, Routes } from './create';
|
|
4
3
|
const { reducer, state } = Routes;
|
|
5
4
|
const userState = state !== null && state !== void 0 ? state : {};
|
|
6
5
|
const userReducer = reducer !== null && reducer !== void 0 ? reducer : function () { };
|
|
@@ -15,11 +14,12 @@ function defaultReducer(state, action) {
|
|
|
15
14
|
return { ...state, ...action.payload };
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
|
-
const initialState = Object.assign({}, userState !== null && userState !== void 0 ? userState : {}, window.__INITIAL_DATA__);
|
|
19
17
|
function combineReducer(state, action) {
|
|
20
18
|
return defaultReducer(state, action) || userReducer(state, action);
|
|
21
19
|
}
|
|
22
20
|
export function AppContext(props) {
|
|
21
|
+
const initialState = Object.assign({}, userState !== null && userState !== void 0 ? userState : {}, __isBrowser__ ? window === null || window === void 0 ? void 0 : window.__INITIAL_DATA__ : props.initialState);
|
|
22
|
+
const Context = ssrCreateContext();
|
|
23
23
|
const [state, dispatch] = useReducer(combineReducer, initialState);
|
|
24
24
|
return createElement(Context.Provider, {
|
|
25
25
|
value: {
|
package/esm/entry/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAEjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEnD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAyB,CAAA;AAEpD,MAAM,SAAS,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAA;AAC7B,MAAM,WAAW,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,cAAa,CAAC,CAAA;AAE7C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA;AAInD,SAAS,cAAc,CAAC,KAAU,EAAE,MAAc;IAChD,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,eAAe;YAClB,IAAI,KAAK,EAAE;gBACT,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAA;gBACtE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;aACpB;YACD,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;KACzC;AACH,CAAC;AAGD,SAAS,cAAc,CAAC,KAAU,EAAE,MAAW;IAC7C,OAAO,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AACpE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IACtH,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAA;IAClC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;IAClE,OAAO,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE;QACrC,KAAK,EAAE;YACL,KAAK;YACL,QAAQ;SACT;KACF,EAAE,KAAK,CAAC,QAAe,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from 'react';
|
|
2
|
+
import type { IContext } from 'ssr-types';
|
|
3
|
+
import { ReactRoutesType } from 'ssr-types';
|
|
4
|
+
export declare const Routes: ReactRoutesType;
|
|
5
|
+
export declare const ssrCreateContext: () => Context<IContext<any>>;
|
|
6
|
+
export declare function createStore(initialData?: any): any;
|
|
7
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/entry/create.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAMzC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,eAAO,MAAM,MAAM,iBAAgE,CAAA;AAEnF,eAAO,MAAM,gBAAgB,8BAe5B,CAAA;AAED,wBAAgB,WAAW,CAAE,WAAW,CAAC,EAAE,GAAG,OAO7C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import { proxy } from 'valtio';
|
|
3
|
+
import { deepClone } from 'ssr-deepclone';
|
|
4
|
+
import { combineRoutes } from 'ssr-common-utils';
|
|
5
|
+
import * as declareRoutes from '_build/ssr-declare-routes';
|
|
6
|
+
import * as ManualRoutes from '_build/ssr-manual-routes';
|
|
7
|
+
export const Routes = combineRoutes(declareRoutes, ManualRoutes);
|
|
8
|
+
export const ssrCreateContext = () => {
|
|
9
|
+
let STORE_CONTEXT;
|
|
10
|
+
if (__isBrowser__) {
|
|
11
|
+
STORE_CONTEXT = window.STORE_CONTEXT || createContext({
|
|
12
|
+
state: {}
|
|
13
|
+
});
|
|
14
|
+
window.STORE_CONTEXT = STORE_CONTEXT;
|
|
15
|
+
return STORE_CONTEXT;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
STORE_CONTEXT = createContext({
|
|
19
|
+
state: {}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return STORE_CONTEXT;
|
|
23
|
+
};
|
|
24
|
+
export function createStore(initialData) {
|
|
25
|
+
const { store } = Routes;
|
|
26
|
+
const storeInstance = initialData ? store : deepClone(store);
|
|
27
|
+
for (const key in storeInstance) {
|
|
28
|
+
storeInstance[key] = initialData ? proxy(initialData[key]) : proxy(storeInstance[key]);
|
|
29
|
+
}
|
|
30
|
+
return storeInstance;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/entry/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,M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2
|
import { ISSRContext, IConfig } from 'ssr-types';
|
|
3
|
-
import { Routes } from './create
|
|
3
|
+
import { Routes } from './create';
|
|
4
4
|
declare const serverRender: (ctx: ISSRContext, config: IConfig) => Promise<string | import("stream").Readable | NodeJS.ReadableStream | import("ssr-types").PipeableStream | {
|
|
5
5
|
html: string;
|
|
6
6
|
teleportsContext: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-entry.d.ts","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAmD,MAAM,WAAW,CAAA;AAGjG,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"server-entry.d.ts","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAmD,MAAM,WAAW,CAAA;AAGjG,OAAO,EAAE,MAAM,EAAiC,MAAM,UAAU,CAAA;AAIhE,QAAA,MAAM,YAAY,QAAe,WAAW,UAAU,OAAO;;;EAuF5D,CAAA;AAED,OAAO,EACL,YAAY,EACZ,MAAM,EACP,CAAA"}
|
|
@@ -5,11 +5,12 @@ import { StaticRouter } from 'react-router-dom';
|
|
|
5
5
|
import { renderToString, renderToNodeStream } from 'react-dom/server';
|
|
6
6
|
import { findRoute, getManifest, logGreen, normalizePath, getAsyncCssChunk, getAsyncJsChunk, splitPageInfo, reactRefreshFragment, localStorageWrapper, checkRoute, useStore } from 'ssr-common-utils';
|
|
7
7
|
import { serialize } from 'ssr-serialize-javascript';
|
|
8
|
-
import {
|
|
9
|
-
import { Routes } from './create
|
|
10
|
-
const { FeRoutes, layoutFetch, state, Layout
|
|
8
|
+
import { AppContext } from './context';
|
|
9
|
+
import { Routes, ssrCreateContext, createStore } from './create';
|
|
10
|
+
const { FeRoutes, layoutFetch, state, Layout } = Routes;
|
|
11
11
|
const serverRender = async (ctx, config) => {
|
|
12
12
|
var _a;
|
|
13
|
+
const context = ssrCreateContext();
|
|
13
14
|
const { mode, parallelFetch, prefix, isVite, isDev, clientPrefix, stream, rootId, hashRouter } = config;
|
|
14
15
|
const rawPath = (_a = ctx.request.path) !== null && _a !== void 0 ? _a : ctx.request.url;
|
|
15
16
|
const path = normalizePath(rawPath, prefix);
|
|
@@ -68,23 +69,22 @@ const serverRender = async (ctx, config) => {
|
|
|
68
69
|
const ele = createElement(StaticRouter, {
|
|
69
70
|
location: ctx.request.url,
|
|
70
71
|
basename: prefix === '/' ? undefined : prefix
|
|
71
|
-
}, createElement(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, createElement(Component, null))));
|
|
72
|
+
}, createElement(AppContext, {
|
|
73
|
+
initialState: combineData,
|
|
74
|
+
children: createElement(Layout, {
|
|
75
|
+
ctx: ctx,
|
|
76
|
+
config: config,
|
|
77
|
+
staticList: staticList,
|
|
78
|
+
injectState: injectState
|
|
79
|
+
}, createElement(Component, null))
|
|
80
|
+
}));
|
|
81
81
|
// for ctx.body will loose asynclocalstorage context, consume stream in advance like vue2/3
|
|
82
82
|
return stream ? renderToNodeStream(ele).pipe(new PassThrough()) : renderToString(ele);
|
|
83
83
|
};
|
|
84
84
|
return await localStorageWrapper.run({
|
|
85
|
-
context:
|
|
85
|
+
context: context,
|
|
86
86
|
ctx,
|
|
87
|
-
store
|
|
87
|
+
store: createStore()
|
|
88
88
|
}, fn);
|
|
89
89
|
};
|
|
90
90
|
export { serverRender, Routes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-entry.js","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA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AC9C,EAAE,aAAa,CAAC,UAAU,EAAE;YAC3B,YAAY,EAAE,WAAW;YACzB,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE;gBAC9B,GAAG,EAAE,GAAG;gBACR,MAAM,EAAE,MAAM;gBACd,UAAU,EAAE,UAAU;gBACtB,WAAW,EAAE,WAAW;aACzB,EAAE,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;SACnC,CAAC,CAAC,CAAA;QACH,2FAA2F;QAC3F,OAAO,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;IACvF,CAAC,CAAA;IAED,OAAO,MAAM,mBAAmB,CAAC,GAAG,CAAC;QACnC,OAAO,EAAE,OAAc;QACvB,GAAG;QACH,KAAK,EAAE,WAAW,EAAE;KACrB,EAAE,EAAE,CAAC,CAAA;AACR,CAAC,CAAA;AAED,OAAO,EACL,YAAY,EACZ,MAAM,EACP,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssr-plugin-react",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.74",
|
|
4
4
|
"description": "plugin-react for ssr",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"react-router-dom": "^5.1.2",
|
|
66
66
|
"semver": "^7.3.8",
|
|
67
67
|
"ssr-common-utils": "^6.0.0",
|
|
68
|
+
"ssr-deepclone": "^1.0.0",
|
|
68
69
|
"ssr-hoc-react": "^6.2.7",
|
|
69
70
|
"ssr-mini-css-extract-plugin": "^1.0.0",
|
|
70
71
|
"ssr-serialize-javascript": "^6.0.0",
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
import { createElement } from 'react'
|
|
2
2
|
import * as ReactDOM from 'react-dom'
|
|
3
|
-
import { proxy } from 'valtio'
|
|
4
3
|
import 'react-router' // for vite prebundle list
|
|
5
4
|
import { BrowserRouter, Route, Switch } from 'react-router-dom'
|
|
6
5
|
import { preloadComponent, isMicro, setStoreContext, setStore } from 'ssr-common-utils'
|
|
7
6
|
import { wrapComponent } from 'ssr-hoc-react'
|
|
8
7
|
import { LayoutProps } from 'ssr-types'
|
|
9
|
-
import {
|
|
10
|
-
import { Routes } from './create-router'
|
|
8
|
+
import { ssrCreateContext, Routes, createStore } from './create'
|
|
11
9
|
import { AppContext } from './context'
|
|
12
10
|
|
|
13
|
-
const { FeRoutes, layoutFetch, App
|
|
11
|
+
const { FeRoutes, layoutFetch, App } = Routes
|
|
14
12
|
|
|
15
13
|
const clientRender = async (): Promise<void> => {
|
|
16
|
-
const IApp = App ?? function
|
|
14
|
+
const IApp = App ?? function(props: LayoutProps) {
|
|
17
15
|
return props.children!
|
|
18
16
|
}
|
|
19
|
-
setStoreContext(
|
|
20
|
-
|
|
21
|
-
store[key] = proxy(window.__VALTIO_DATA__?.[key])
|
|
22
|
-
}
|
|
17
|
+
setStoreContext(ssrCreateContext() as any)
|
|
18
|
+
const store = createStore(window.__VALTIO_DATA__)
|
|
23
19
|
setStore(store ?? {})
|
|
24
20
|
const baseName = isMicro() ? window.clientPrefix : window.prefix
|
|
25
21
|
const routes = await preloadComponent(FeRoutes, baseName)
|
|
26
22
|
ReactDOM[window.__USE_SSR__ ? 'hydrate' : 'render'](
|
|
27
23
|
createElement(BrowserRouter, {
|
|
28
24
|
basename: baseName
|
|
29
|
-
}, createElement(AppContext
|
|
25
|
+
}, createElement(AppContext, {
|
|
30
26
|
children: createElement(Switch, null,
|
|
31
27
|
createElement(IApp as any, null, createElement(Switch, null,
|
|
32
28
|
routes.map(item => {
|
package/src/entry/context.tsx
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { useReducer, createElement } from 'react'
|
|
2
2
|
import { IProps, Action, IWindow, ReactRoutesType } from 'ssr-types'
|
|
3
|
-
import {
|
|
4
|
-
import { Routes } from './create-router'
|
|
3
|
+
import { ssrCreateContext, Routes } from './create'
|
|
5
4
|
|
|
6
5
|
const { reducer, state } = Routes as ReactRoutesType
|
|
7
6
|
|
|
8
7
|
const userState = state ?? {}
|
|
9
|
-
const userReducer = reducer ?? function
|
|
8
|
+
const userReducer = reducer ?? function() { }
|
|
10
9
|
|
|
11
10
|
const isDev = process.env.NODE_ENV !== 'production'
|
|
12
11
|
|
|
13
|
-
// 客户端的 context 只需要创建一次,在页面整个生命周期内共享
|
|
14
12
|
declare const window: IWindow
|
|
15
13
|
|
|
16
|
-
function defaultReducer
|
|
14
|
+
function defaultReducer(state: any, action: Action) {
|
|
17
15
|
switch (action.type) {
|
|
18
16
|
case 'updateContext':
|
|
19
17
|
if (isDev) {
|
|
@@ -24,17 +22,19 @@ function defaultReducer (state: any, action: Action) {
|
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
const initialState = Object.assign({}, userState ?? {}, window.__INITIAL_DATA__)
|
|
28
25
|
|
|
29
|
-
function combineReducer
|
|
26
|
+
function combineReducer(state: any, action: any) {
|
|
30
27
|
return defaultReducer(state, action) || userReducer(state, action)
|
|
31
28
|
}
|
|
32
|
-
|
|
29
|
+
|
|
30
|
+
export function AppContext(props: IProps) {
|
|
31
|
+
const initialState = Object.assign({}, userState ?? {}, __isBrowser__ ? window?.__INITIAL_DATA__ : props.initialState)
|
|
32
|
+
const Context = ssrCreateContext()
|
|
33
33
|
const [state, dispatch] = useReducer(combineReducer, initialState)
|
|
34
34
|
return createElement(Context.Provider, {
|
|
35
35
|
value: {
|
|
36
36
|
state,
|
|
37
37
|
dispatch
|
|
38
38
|
}
|
|
39
|
-
}, props.children)
|
|
39
|
+
}, props.children as any)
|
|
40
40
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
import type { Context } from 'react'
|
|
3
|
+
import type { IContext } from 'ssr-types'
|
|
4
|
+
import { proxy } from 'valtio'
|
|
5
|
+
import { deepClone } from 'ssr-deepclone'
|
|
6
|
+
import { combineRoutes } from 'ssr-common-utils'
|
|
7
|
+
import * as declareRoutes from '_build/ssr-declare-routes'
|
|
8
|
+
import * as ManualRoutes from '_build/ssr-manual-routes'
|
|
9
|
+
import { ReactRoutesType } from 'ssr-types'
|
|
10
|
+
|
|
11
|
+
export const Routes = combineRoutes(declareRoutes, ManualRoutes) as ReactRoutesType
|
|
12
|
+
|
|
13
|
+
export const ssrCreateContext = () => {
|
|
14
|
+
let STORE_CONTEXT: Context<IContext>
|
|
15
|
+
|
|
16
|
+
if (__isBrowser__) {
|
|
17
|
+
STORE_CONTEXT = window.STORE_CONTEXT || createContext<IContext>({
|
|
18
|
+
state: {}
|
|
19
|
+
})
|
|
20
|
+
window.STORE_CONTEXT = STORE_CONTEXT
|
|
21
|
+
return STORE_CONTEXT
|
|
22
|
+
} else {
|
|
23
|
+
STORE_CONTEXT = createContext<IContext>({
|
|
24
|
+
state: {}
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
return STORE_CONTEXT
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createStore (initialData?: any) {
|
|
31
|
+
const { store } = Routes
|
|
32
|
+
const storeInstance = initialData ? store : deepClone(store)
|
|
33
|
+
for (const key in storeInstance) {
|
|
34
|
+
storeInstance[key] = initialData ? proxy(initialData[key]) : proxy(storeInstance[key])
|
|
35
|
+
}
|
|
36
|
+
return storeInstance
|
|
37
|
+
}
|
|
@@ -6,12 +6,13 @@ import { renderToString, renderToNodeStream } from 'react-dom/server'
|
|
|
6
6
|
import { findRoute, getManifest, logGreen, normalizePath, getAsyncCssChunk, getAsyncJsChunk, splitPageInfo, reactRefreshFragment, localStorageWrapper, checkRoute, useStore } from 'ssr-common-utils'
|
|
7
7
|
import { ISSRContext, IConfig, ReactESMPreloadFeRouteItem, DynamicFC, StaticFC } from 'ssr-types'
|
|
8
8
|
import { serialize } from 'ssr-serialize-javascript'
|
|
9
|
-
import {
|
|
10
|
-
import { Routes } from './create
|
|
9
|
+
import { AppContext } from './context'
|
|
10
|
+
import { Routes, ssrCreateContext, createStore } from './create'
|
|
11
11
|
|
|
12
|
-
const { FeRoutes, layoutFetch, state, Layout
|
|
12
|
+
const { FeRoutes, layoutFetch, state, Layout } = Routes
|
|
13
13
|
|
|
14
14
|
const serverRender = async (ctx: ISSRContext, config: IConfig) => {
|
|
15
|
+
const context = ssrCreateContext()
|
|
15
16
|
const { mode, parallelFetch, prefix, isVite, isDev, clientPrefix, stream, rootId, hashRouter } = config
|
|
16
17
|
const rawPath = ctx.request.path ?? ctx.request.url
|
|
17
18
|
const path = normalizePath(rawPath, prefix)
|
|
@@ -79,24 +80,23 @@ const serverRender = async (ctx: ISSRContext, config: IConfig) => {
|
|
|
79
80
|
const ele = createElement(StaticRouter, {
|
|
80
81
|
location: ctx.request.url,
|
|
81
82
|
basename: prefix === '/' ? undefined : prefix
|
|
82
|
-
}, createElement(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, createElement(Component, null))))
|
|
83
|
+
}, createElement(AppContext, {
|
|
84
|
+
initialState: combineData,
|
|
85
|
+
children: createElement(Layout, {
|
|
86
|
+
ctx: ctx,
|
|
87
|
+
config: config,
|
|
88
|
+
staticList: staticList,
|
|
89
|
+
injectState: injectState
|
|
90
|
+
}, createElement(Component, null))
|
|
91
|
+
}))
|
|
92
92
|
// for ctx.body will loose asynclocalstorage context, consume stream in advance like vue2/3
|
|
93
93
|
return stream ? renderToNodeStream(ele).pipe(new PassThrough()) : renderToString(ele)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
return await localStorageWrapper.run({
|
|
97
|
-
context:
|
|
97
|
+
context: context as any,
|
|
98
98
|
ctx,
|
|
99
|
-
store
|
|
99
|
+
store: createStore()
|
|
100
100
|
}, fn)
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.d.ts","sourceRoot":"","sources":["../../src/entry/create-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAiB,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,QAAA,IAAI,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;AAYpC,OAAO,EACL,aAAa,EACd,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// The file is provisional,don't modify it
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.STORE_CONTEXT = void 0;
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
let STORE_CONTEXT;
|
|
7
|
-
exports.STORE_CONTEXT = STORE_CONTEXT;
|
|
8
|
-
if (__isBrowser__) {
|
|
9
|
-
exports.STORE_CONTEXT = STORE_CONTEXT = window.STORE_CONTEXT || (0, react_1.createContext)({
|
|
10
|
-
state: {}
|
|
11
|
-
});
|
|
12
|
-
window.STORE_CONTEXT = STORE_CONTEXT;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
exports.STORE_CONTEXT = STORE_CONTEXT = (0, react_1.createContext)({
|
|
16
|
-
state: {}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=create-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.js","sourceRoot":"","sources":["../../src/entry/create-context.ts"],"names":[],"mappings":";AAAA,0CAA0C;;;AAE1C,iCAA8C;AAE9C,IAAI,aAAgC,CAAA;AAalC,sCAAa;AAZf,IAAI,aAAa,EAAE;IACjB,wBAAA,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,IAAA,qBAAa,EAAW;QAC9D,KAAK,EAAE,EAAE;KACV,CAAC,CAAA;IACF,MAAM,CAAC,aAAa,GAAG,aAAa,CAAA;CACrC;KAAM;IACL,wBAAA,aAAa,GAAG,IAAA,qBAAa,EAAW;QACtC,KAAK,EAAE,EAAE;KACV,CAAC,CAAA;CACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-router.d.ts","sourceRoot":"","sources":["../../src/entry/create-router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,QAAA,MAAM,MAAM,iBAAgE,CAAA;AAE5E,OAAO,EACL,MAAM,EACP,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Routes = void 0;
|
|
4
|
-
const ssr_common_utils_1 = require("ssr-common-utils");
|
|
5
|
-
const declareRoutes = require("_build/ssr-declare-routes");
|
|
6
|
-
const ManualRoutes = require("_build/ssr-manual-routes");
|
|
7
|
-
const Routes = (0, ssr_common_utils_1.combineRoutes)(declareRoutes, ManualRoutes);
|
|
8
|
-
exports.Routes = Routes;
|
|
9
|
-
//# sourceMappingURL=create-router.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-router.js","sourceRoot":"","sources":["../../src/entry/create-router.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAChD,2DAA0D;AAC1D,yDAAwD;AAGxD,MAAM,MAAM,GAAG,IAAA,gCAAa,EAAC,aAAa,EAAE,YAAY,CAAoB,CAAA;AAG1E,wBAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.d.ts","sourceRoot":"","sources":["../../src/entry/create-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAiB,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,QAAA,IAAI,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;AAYpC,OAAO,EACL,aAAa,EACd,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// The file is provisional,don't modify it
|
|
2
|
-
import { createContext } from 'react';
|
|
3
|
-
let STORE_CONTEXT;
|
|
4
|
-
if (__isBrowser__) {
|
|
5
|
-
STORE_CONTEXT = window.STORE_CONTEXT || createContext({
|
|
6
|
-
state: {}
|
|
7
|
-
});
|
|
8
|
-
window.STORE_CONTEXT = STORE_CONTEXT;
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
STORE_CONTEXT = createContext({
|
|
12
|
-
state: {}
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export { STORE_CONTEXT };
|
|
16
|
-
//# sourceMappingURL=create-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.js","sourceRoot":"","sources":["../../src/entry/create-context.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,EAAW,aAAa,EAAE,MAAM,OAAO,CAAA;AAE9C,IAAI,aAAgC,CAAA;AACpC,IAAI,aAAa,EAAE;IACjB,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,aAAa,CAAW;QAC9D,KAAK,EAAE,EAAE;KACV,CAAC,CAAA;IACF,MAAM,CAAC,aAAa,GAAG,aAAa,CAAA;CACrC;KAAM;IACL,aAAa,GAAG,aAAa,CAAW;QACtC,KAAK,EAAE,EAAE;KACV,CAAC,CAAA;CACH;AAED,OAAO,EACL,aAAa,EACd,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-router.d.ts","sourceRoot":"","sources":["../../src/entry/create-router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,QAAA,MAAM,MAAM,iBAAgE,CAAA;AAE5E,OAAO,EACL,MAAM,EACP,CAAA"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { combineRoutes } from 'ssr-common-utils';
|
|
2
|
-
import * as declareRoutes from '_build/ssr-declare-routes';
|
|
3
|
-
import * as ManualRoutes from '_build/ssr-manual-routes';
|
|
4
|
-
const Routes = combineRoutes(declareRoutes, ManualRoutes);
|
|
5
|
-
export { Routes };
|
|
6
|
-
//# sourceMappingURL=create-router.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-router.js","sourceRoot":"","sources":["../../src/entry/create-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,YAAY,MAAM,0BAA0B,CAAA;AAGxD,MAAM,MAAM,GAAG,aAAa,CAAC,aAAa,EAAE,YAAY,CAAoB,CAAA;AAE5E,OAAO,EACL,MAAM,EACP,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// The file is provisional,don't modify it
|
|
2
|
-
|
|
3
|
-
import { Context, createContext } from 'react'
|
|
4
|
-
import { IContext } from 'ssr-types'
|
|
5
|
-
let STORE_CONTEXT: Context<IContext>
|
|
6
|
-
if (__isBrowser__) {
|
|
7
|
-
STORE_CONTEXT = window.STORE_CONTEXT || createContext<IContext>({
|
|
8
|
-
state: {}
|
|
9
|
-
})
|
|
10
|
-
window.STORE_CONTEXT = STORE_CONTEXT
|
|
11
|
-
} else {
|
|
12
|
-
STORE_CONTEXT = createContext<IContext>({
|
|
13
|
-
state: {}
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
STORE_CONTEXT
|
|
19
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { combineRoutes } from 'ssr-common-utils'
|
|
2
|
-
import * as declareRoutes from '_build/ssr-declare-routes'
|
|
3
|
-
import * as ManualRoutes from '_build/ssr-manual-routes'
|
|
4
|
-
import { ReactRoutesType } from 'ssr-types'
|
|
5
|
-
|
|
6
|
-
const Routes = combineRoutes(declareRoutes, ManualRoutes) as ReactRoutesType
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
Routes
|
|
10
|
-
}
|