@shuvi/platform-web 1.0.4 → 1.0.6
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/esm/shuvi-app/react/AppContainer.jsx +5 -4
- package/esm/shuvi-app/react/model/Wrapper.d.ts +8 -0
- package/esm/shuvi-app/react/model/Wrapper.jsx +11 -0
- package/esm/shuvi-app/react/model/runtime.d.ts +2 -2
- package/esm/shuvi-app/react/model/runtime.js +2 -2
- package/esm/shuvi-app/react/store.d.ts +2 -2
- package/esm/shuvi-app/react/store.js +1 -1
- package/esm/shuvi-app/react/useLoaderData.js +4 -4
- package/lib/node/features/model/index.js +3 -3
- package/lib/node/features/model/runtime.d.ts +3 -3
- package/lib/node/features/model/runtime.js +3 -3
- package/lib/node/features/model/shuvi-app.d.ts +2 -2
- package/lib/node/targets/react/model/index.js +3 -3
- package/package.json +13 -13
- package/esm/shuvi-app/react/model/RedoxWrapper.d.ts +0 -8
- package/esm/shuvi-app/react/model/RedoxWrapper.jsx +0 -11
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { errorModel } from '@shuvi/platform-shared/shared';
|
|
2
|
+
import { errorModel, errorModelName } from '@shuvi/platform-shared/shared';
|
|
3
3
|
import { AppProvider } from './ApplicationContext';
|
|
4
4
|
import ErrorPage from './ErrorPage';
|
|
5
5
|
import { ErrorBoundary } from './ErrorBoundary';
|
|
6
6
|
import { Provider, useSharedModel } from './store';
|
|
7
7
|
function ErrorGuard({ children = null }) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const errorState = useSharedModel(errorModelName, errorModel);
|
|
10
|
+
if (errorState.hasError) {
|
|
11
|
+
return (<ErrorPage code={(_a = errorState.error) === null || _a === void 0 ? void 0 : _a.code} message={(_b = errorState.error) === null || _b === void 0 ? void 0 : _b.message}/>);
|
|
11
12
|
}
|
|
12
13
|
return <>{children}</>;
|
|
13
14
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DouraRoot } from 'react-doura';
|
|
3
|
+
export const DouraWrapper = (App, appContext) => {
|
|
4
|
+
function DouraAppWrapper() {
|
|
5
|
+
return (<DouraRoot store={appContext.store}>
|
|
6
|
+
<App />
|
|
7
|
+
</DouraRoot>);
|
|
8
|
+
}
|
|
9
|
+
DouraAppWrapper.displayName = 'DouraAppWrapper';
|
|
10
|
+
return DouraAppWrapper;
|
|
11
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Doura } from 'doura';
|
|
2
2
|
declare module '@shuvi/runtime' {
|
|
3
3
|
interface CustomAppContext {
|
|
4
|
-
store:
|
|
4
|
+
store: Doura;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
declare const _default: import("@shuvi/platform-shared/shared").IPluginInstance<import("@shuvi/platform-shared/shared").RuntimePluginHooks, void>;
|
|
@@ -8,11 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { createRuntimePluginAfter } from '@shuvi/platform-shared/shared';
|
|
11
|
-
import {
|
|
11
|
+
import { DouraWrapper } from './Wrapper';
|
|
12
12
|
// this needs to be run last
|
|
13
13
|
export default createRuntimePluginAfter({
|
|
14
14
|
appComponent: (App, appContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
return
|
|
15
|
+
return DouraWrapper(App, {
|
|
16
16
|
store: appContext.store
|
|
17
17
|
});
|
|
18
18
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare const Provider: (props: import("react").PropsWithChildren<{
|
|
3
|
-
store?: import("
|
|
4
|
-
}>) => JSX.Element, useSharedModel: import("
|
|
3
|
+
store?: import("doura").Doura | undefined;
|
|
4
|
+
}>) => JSX.Element, useSharedModel: import("react-doura").UseNamedModel, useStaticModel: import("react-doura").UseNamedStaticModel;
|
|
5
5
|
export { Provider, useSharedModel, useStaticModel };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMatchedRoute } from '@shuvi/router-react';
|
|
2
|
-
import { loaderModel } from '@shuvi/platform-shared/shared';
|
|
2
|
+
import { loaderModel, loaderModelName } from '@shuvi/platform-shared/shared';
|
|
3
3
|
import { useStaticModel } from './store';
|
|
4
4
|
export const noLoaderMessage = 'Warning: no loader found. Please make sure the page component where `useLoaderData` is called has a `loader` export.';
|
|
5
5
|
const hasOwn = Object.prototype.hasOwnProperty;
|
|
@@ -8,9 +8,9 @@ export const useLoaderData = () => {
|
|
|
8
8
|
const id = currentMatch.route.id;
|
|
9
9
|
// we don't need to watch the model change, cause it always change with
|
|
10
10
|
// matched route
|
|
11
|
-
const
|
|
12
|
-
if (!hasOwn.call(
|
|
11
|
+
const loaderData = useStaticModel(loaderModelName, loaderModel);
|
|
12
|
+
if (!hasOwn.call(loaderData.dataByRouteId, id)) {
|
|
13
13
|
throw Error(noLoaderMessage);
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return loaderData.dataByRouteId[id];
|
|
16
16
|
};
|
|
@@ -6,17 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const service_1 = require("@shuvi/service");
|
|
7
7
|
const paths_1 = require("../../paths");
|
|
8
8
|
const server_1 = __importDefault(require("./server"));
|
|
9
|
-
const
|
|
9
|
+
const douraSource = (0, paths_1.resolveLib)('doura');
|
|
10
10
|
const core = (0, service_1.createPlugin)({
|
|
11
11
|
addRuntimeService: () => [
|
|
12
12
|
{
|
|
13
|
-
source:
|
|
13
|
+
source: douraSource,
|
|
14
14
|
exported: '*',
|
|
15
15
|
filepath: 'model.ts'
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
configWebpack: config => {
|
|
19
|
-
config.resolve.alias.set('
|
|
19
|
+
config.resolve.alias.set('doura', douraSource);
|
|
20
20
|
return config;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Doura } from 'doura';
|
|
2
2
|
import { IAppContext } from '@shuvi/platform-shared/shared';
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type InitDoura = (params: {
|
|
4
4
|
initialState: any;
|
|
5
5
|
ctx: IAppContext;
|
|
6
|
-
}) =>
|
|
6
|
+
}) => Doura;
|
|
7
7
|
declare const _default: import("@shuvi/platform-shared/shared").IPluginInstance<import("@shuvi/platform-shared/shared").RuntimePluginHooks, void>;
|
|
8
8
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const doura_1 = require("doura");
|
|
4
4
|
const shared_1 = require("@shuvi/platform-shared/shared");
|
|
5
5
|
let currentStore;
|
|
6
6
|
const isServer = typeof window === 'undefined';
|
|
@@ -8,11 +8,11 @@ const isServer = typeof window === 'undefined';
|
|
|
8
8
|
// for server, return new store
|
|
9
9
|
const initStore = ({ initialState, ctx }) => {
|
|
10
10
|
const createStoreInstance = () => {
|
|
11
|
-
// return
|
|
11
|
+
// return createDoura(initialState, {
|
|
12
12
|
// ...ctx,
|
|
13
13
|
// isServer
|
|
14
14
|
// });
|
|
15
|
-
return (0,
|
|
15
|
+
return (0, doura_1.doura)({
|
|
16
16
|
initialState
|
|
17
17
|
});
|
|
18
18
|
};
|
|
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ModelReactPlugin = void 0;
|
|
4
4
|
const service_1 = require("@shuvi/service");
|
|
5
5
|
const paths_1 = require("../../../paths");
|
|
6
|
-
const
|
|
6
|
+
const reactDouraSource = (0, paths_1.resolveLib)('react-doura');
|
|
7
7
|
const core = (0, service_1.createPluginAfter)({
|
|
8
8
|
addRuntimeService: () => [
|
|
9
9
|
{
|
|
10
|
-
source:
|
|
10
|
+
source: reactDouraSource,
|
|
11
11
|
exported: '*',
|
|
12
12
|
filepath: 'model.ts'
|
|
13
13
|
}
|
|
14
14
|
],
|
|
15
15
|
configWebpack: config => {
|
|
16
|
-
config.resolve.alias.set('
|
|
16
|
+
config.resolve.alias.set('react-doura', reactDouraSource);
|
|
17
17
|
return config;
|
|
18
18
|
}
|
|
19
19
|
}, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -72,17 +72,17 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@next/react-refresh-utils": "12.1.6",
|
|
75
|
-
"@shuvi/error-overlay": "1.0.
|
|
76
|
-
"@shuvi/hook": "1.0.
|
|
77
|
-
"@shuvi/platform-shared": "1.0.
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"@shuvi/router": "1.0.
|
|
81
|
-
"@shuvi/router-react": "1.0.
|
|
82
|
-
"@shuvi/runtime": "1.0.
|
|
83
|
-
"@shuvi/shared": "1.0.
|
|
84
|
-
"@shuvi/toolpack": "1.0.
|
|
85
|
-
"@shuvi/utils": "1.0.
|
|
75
|
+
"@shuvi/error-overlay": "1.0.6",
|
|
76
|
+
"@shuvi/hook": "1.0.6",
|
|
77
|
+
"@shuvi/platform-shared": "1.0.6",
|
|
78
|
+
"doura": "0.0.3",
|
|
79
|
+
"react-doura": "0.0.3",
|
|
80
|
+
"@shuvi/router": "1.0.6",
|
|
81
|
+
"@shuvi/router-react": "1.0.6",
|
|
82
|
+
"@shuvi/runtime": "1.0.6",
|
|
83
|
+
"@shuvi/shared": "1.0.6",
|
|
84
|
+
"@shuvi/toolpack": "1.0.6",
|
|
85
|
+
"@shuvi/utils": "1.0.6",
|
|
86
86
|
"content-type": "1.0.4",
|
|
87
87
|
"core-js": "3.6.5",
|
|
88
88
|
"ejs": "3.1.5",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"whatwg-fetch": "3.0.0"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@shuvi/service": "1.0.
|
|
101
|
+
"@shuvi/service": "1.0.6"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@shuvi/service": "workspace:*",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { RedoxRoot } from '@shuvi/redox-react';
|
|
3
|
-
export const RedoxWrapper = (App, appContext) => {
|
|
4
|
-
function RedoxAppWrapper() {
|
|
5
|
-
return (<RedoxRoot store={appContext.store}>
|
|
6
|
-
<App />
|
|
7
|
-
</RedoxRoot>);
|
|
8
|
-
}
|
|
9
|
-
RedoxAppWrapper.displayName = 'RedoxAppWrapper';
|
|
10
|
-
return RedoxAppWrapper;
|
|
11
|
-
};
|