@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.
@@ -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
- const [errorState] = useSharedModel(errorModel);
9
- if (errorState.error !== undefined) {
10
- return (<ErrorPage code={errorState.error.code} message={errorState.error.message}/>);
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,8 @@
1
+ /// <reference types="react" />
2
+ import type { Doura } from 'doura';
3
+ export declare const DouraWrapper: (App: any, appContext: {
4
+ store: Doura;
5
+ }) => {
6
+ (): JSX.Element;
7
+ displayName: string;
8
+ };
@@ -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 { RedoxStore } from '@shuvi/redox';
1
+ import { Doura } from 'doura';
2
2
  declare module '@shuvi/runtime' {
3
3
  interface CustomAppContext {
4
- store: RedoxStore;
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 { RedoxWrapper } from './RedoxWrapper';
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 RedoxWrapper(App, {
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("@shuvi/redox").RedoxStore | undefined;
4
- }>) => JSX.Element, useSharedModel: import("@shuvi/redox-react/esm/types").IUseModel, useStaticModel: import("@shuvi/redox-react/esm/types").IUseStaticModel;
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,3 +1,3 @@
1
- import { createContainer } from '@shuvi/redox-react';
1
+ import { createContainer } from 'react-doura';
2
2
  const { Provider, useSharedModel, useStaticModel } = createContainer();
3
3
  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 [state] = useStaticModel(loaderModel);
12
- if (!hasOwn.call(state.current.dataByRouteId, id)) {
11
+ const loaderData = useStaticModel(loaderModelName, loaderModel);
12
+ if (!hasOwn.call(loaderData.dataByRouteId, id)) {
13
13
  throw Error(noLoaderMessage);
14
14
  }
15
- return state.current.dataByRouteId[id];
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 redoxSource = (0, paths_1.resolveLib)('@shuvi/redox');
9
+ const douraSource = (0, paths_1.resolveLib)('doura');
10
10
  const core = (0, service_1.createPlugin)({
11
11
  addRuntimeService: () => [
12
12
  {
13
- source: redoxSource,
13
+ source: douraSource,
14
14
  exported: '*',
15
15
  filepath: 'model.ts'
16
16
  }
17
17
  ],
18
18
  configWebpack: config => {
19
- config.resolve.alias.set('@shuvi/redox', redoxSource);
19
+ config.resolve.alias.set('doura', douraSource);
20
20
  return config;
21
21
  }
22
22
  });
@@ -1,8 +1,8 @@
1
- import { RedoxStore } from '@shuvi/redox';
1
+ import { Doura } from 'doura';
2
2
  import { IAppContext } from '@shuvi/platform-shared/shared';
3
- export declare type InitRedox = (params: {
3
+ export declare type InitDoura = (params: {
4
4
  initialState: any;
5
5
  ctx: IAppContext;
6
- }) => RedoxStore;
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 redox_1 = require("@shuvi/redox");
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 createRedox(initialState, {
11
+ // return createDoura(initialState, {
12
12
  // ...ctx,
13
13
  // isServer
14
14
  // });
15
- return (0, redox_1.redox)({
15
+ return (0, doura_1.doura)({
16
16
  initialState
17
17
  });
18
18
  };
@@ -1,6 +1,6 @@
1
- import type { RedoxStore } from '@shuvi/redox';
1
+ import type { Doura } from 'doura';
2
2
  declare module '@shuvi/runtime' {
3
3
  interface CustomAppContext {
4
- store: RedoxStore;
4
+ store: Doura;
5
5
  }
6
6
  }
@@ -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 redoxReactSource = (0, paths_1.resolveLib)('@shuvi/redox-react');
6
+ const reactDouraSource = (0, paths_1.resolveLib)('react-doura');
7
7
  const core = (0, service_1.createPluginAfter)({
8
8
  addRuntimeService: () => [
9
9
  {
10
- source: redoxReactSource,
10
+ source: reactDouraSource,
11
11
  exported: '*',
12
12
  filepath: 'model.ts'
13
13
  }
14
14
  ],
15
15
  configWebpack: config => {
16
- config.resolve.alias.set('@shuvi/redox-react', redoxReactSource);
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.4",
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.4",
76
- "@shuvi/hook": "1.0.4",
77
- "@shuvi/platform-shared": "1.0.4",
78
- "@shuvi/redox": "0.0.7",
79
- "@shuvi/redox-react": "0.0.7",
80
- "@shuvi/router": "1.0.4",
81
- "@shuvi/router-react": "1.0.4",
82
- "@shuvi/runtime": "1.0.4",
83
- "@shuvi/shared": "1.0.4",
84
- "@shuvi/toolpack": "1.0.4",
85
- "@shuvi/utils": "1.0.4",
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.4"
101
+ "@shuvi/service": "1.0.6"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@shuvi/service": "workspace:*",
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import type { RedoxStore } from '@shuvi/redox';
3
- export declare const RedoxWrapper: (App: any, appContext: {
4
- store: RedoxStore;
5
- }) => {
6
- (): JSX.Element;
7
- displayName: string;
8
- };
@@ -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
- };