@shuvi/platform-web 1.0.0-rc.2 → 1.0.0-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/esm/shared/appTypes.d.ts +12 -6
  2. package/esm/shared/configTypes.d.ts +1 -3
  3. package/esm/shared/constants.d.ts +8 -0
  4. package/esm/shared/constants.js +8 -0
  5. package/esm/shared/htmlRenderer.d.ts +33 -0
  6. package/esm/shared/{serverTypes.js → htmlRenderer.js} +0 -0
  7. package/esm/shared/index.d.ts +2 -1
  8. package/esm/shared/index.js +2 -1
  9. package/esm/shared/renderTypes.d.ts +8 -7
  10. package/esm/shared/routeTypes.d.ts +4 -9
  11. package/esm/shuvi-app/app/client.d.ts +2 -1
  12. package/esm/shuvi-app/app/client.js +13 -17
  13. package/esm/shuvi-app/app/server.js +13 -9
  14. package/esm/shuvi-app/dev/eventsource.d.ts +1 -0
  15. package/esm/shuvi-app/dev/eventsource.js +60 -0
  16. package/esm/shuvi-app/dev/hotDevClient.d.ts +32 -0
  17. package/esm/shuvi-app/dev/hotDevClient.js +327 -0
  18. package/esm/shuvi-app/dev/index.d.ts +3 -0
  19. package/esm/shuvi-app/dev/index.js +27 -0
  20. package/esm/shuvi-app/dev/websocket.d.ts +16 -0
  21. package/esm/shuvi-app/dev/websocket.js +61 -0
  22. package/esm/shuvi-app/entry/client/app.d.ts +2 -1
  23. package/esm/shuvi-app/entry/client/app.js +13 -6
  24. package/esm/shuvi-app/entry/client/index.js +1 -1
  25. package/esm/shuvi-app/entry/client/run.dev.js +15 -16
  26. package/esm/shuvi-app/entry/server/index.d.ts +5 -4
  27. package/esm/shuvi-app/entry/server/index.js +5 -4
  28. package/esm/shuvi-app/helper/serializeServerError.d.ts +2 -0
  29. package/esm/shuvi-app/helper/serializeServerError.js +21 -0
  30. package/esm/shuvi-app/react/AppContainer.d.ts +4 -5
  31. package/esm/shuvi-app/react/AppContainer.jsx +4 -5
  32. package/esm/shuvi-app/react/ApplicationContext.d.ts +7 -0
  33. package/esm/shuvi-app/react/{applicationContext.jsx → ApplicationContext.jsx} +0 -0
  34. package/esm/shuvi-app/react/Error.jsx +4 -1
  35. package/esm/shuvi-app/react/Link.d.ts +2 -1
  36. package/esm/shuvi-app/react/Link.jsx +1 -1
  37. package/esm/shuvi-app/react/getRoutes.d.ts +2 -2
  38. package/esm/shuvi-app/react/getRoutes.js +9 -8
  39. package/esm/shuvi-app/react/{redox-react → model}/RedoxWrapper.d.ts +3 -3
  40. package/esm/shuvi-app/react/{redox-react → model}/RedoxWrapper.jsx +3 -3
  41. package/esm/shuvi-app/react/model/runtime.d.ts +8 -0
  42. package/esm/shuvi-app/react/{redox-react → model}/runtime.js +8 -3
  43. package/esm/shuvi-app/react/store.d.ts +5 -0
  44. package/esm/shuvi-app/react/store.js +3 -0
  45. package/esm/shuvi-app/react/types.d.ts +0 -7
  46. package/esm/shuvi-app/react/useLoaderData.js +9 -20
  47. package/esm/shuvi-app/react/view/ReactView.client.jsx +34 -23
  48. package/esm/shuvi-app/react/view/ReactView.server.jsx +29 -14
  49. package/esm/shuvi-app/react/view/render.d.ts +8 -0
  50. package/esm/shuvi-app/react/view/{render-action.js → render.js} +6 -6
  51. package/lib/node/features/custom-server/index.d.ts +1 -1
  52. package/lib/node/features/custom-server/server.d.ts +1 -1
  53. package/lib/node/features/custom-server/server.js +20 -11
  54. package/lib/node/features/filesystem-routes/api/apiRouteHandler.d.ts +7 -7
  55. package/lib/node/features/filesystem-routes/api/apiRouteHandler.js +5 -5
  56. package/lib/node/features/filesystem-routes/api/middleware.d.ts +2 -2
  57. package/lib/node/features/filesystem-routes/api/middleware.js +5 -2
  58. package/lib/node/features/filesystem-routes/hooks.d.ts +2 -1
  59. package/lib/node/features/filesystem-routes/hooks.js +2 -1
  60. package/lib/node/features/filesystem-routes/index.d.ts +1 -13
  61. package/lib/node/features/filesystem-routes/index.js +55 -84
  62. package/lib/node/features/filesystem-routes/middleware/middleware.d.ts +2 -2
  63. package/lib/node/features/filesystem-routes/middleware/middleware.js +5 -2
  64. package/lib/node/features/filesystem-routes/page/routes.d.ts +3 -3
  65. package/lib/node/features/filesystem-routes/page/routes.js +25 -12
  66. package/lib/node/features/html-render/index.d.ts +4 -18
  67. package/lib/node/features/html-render/index.js +129 -16
  68. package/lib/node/features/{main → html-render/lib}/buildHtml.d.ts +0 -0
  69. package/lib/node/features/{main → html-render/lib}/buildHtml.js +2 -1
  70. package/lib/node/features/html-render/lib/generateFilesByRoutId.d.ts +3 -3
  71. package/lib/node/features/html-render/lib/generateFilesByRoutId.js +3 -3
  72. package/lib/node/features/{main → html-render/lib}/generateResource.d.ts +0 -0
  73. package/lib/node/features/{main → html-render/lib}/generateResource.js +12 -8
  74. package/lib/node/features/html-render/lib/getPageMiddleware.d.ts +2 -2
  75. package/lib/node/features/html-render/lib/getPageMiddleware.js +18 -13
  76. package/lib/node/features/html-render/lib/index.d.ts +0 -2
  77. package/lib/node/features/html-render/lib/index.js +1 -4
  78. package/lib/node/features/html-render/lib/renderToHTML.d.ts +2 -2
  79. package/lib/node/features/html-render/lib/renderToHTML.js +9 -49
  80. package/lib/node/features/html-render/lib/renderer/base.d.ts +7 -8
  81. package/lib/node/features/html-render/lib/renderer/base.js +19 -11
  82. package/lib/node/features/html-render/lib/renderer/index.d.ts +5 -4
  83. package/lib/node/features/html-render/lib/renderer/index.js +77 -8
  84. package/lib/node/features/html-render/lib/renderer/spa.d.ts +2 -2
  85. package/lib/node/features/html-render/lib/renderer/spa.js +4 -6
  86. package/lib/node/features/html-render/lib/renderer/ssr.d.ts +2 -2
  87. package/lib/node/features/html-render/lib/renderer/ssr.js +9 -11
  88. package/lib/node/features/html-render/lib/renderer/types.d.ts +10 -8
  89. package/lib/node/features/html-render/lib/webpack/build-manifest-plugin.d.ts +27 -0
  90. package/lib/node/features/html-render/lib/webpack/build-manifest-plugin.js +223 -0
  91. package/lib/node/features/html-render/server.d.ts +1 -1
  92. package/lib/node/features/html-render/serverHooks.d.ts +6 -1
  93. package/lib/node/features/html-render/serverHooks.js +1 -2
  94. package/lib/node/features/index.d.ts +3 -31
  95. package/lib/node/features/index.js +6 -7
  96. package/lib/node/features/middlewares.d.ts +1 -1
  97. package/lib/node/features/middlewares.js +12 -3
  98. package/lib/node/features/model/index.d.ts +1 -13
  99. package/lib/node/features/model/runtime.d.ts +3 -8
  100. package/lib/node/features/model/runtime.js +13 -18
  101. package/lib/node/features/model/server.js +2 -3
  102. package/lib/node/features/model/shuvi-app.d.ts +2 -2
  103. package/lib/node/features/on-demand-compile-page/index.d.ts +3 -13
  104. package/lib/node/features/on-demand-compile-page/index.js +4 -1
  105. package/lib/node/features/on-demand-compile-page/onDemandRouteManager.d.ts +3 -3
  106. package/lib/node/features/on-demand-compile-page/onDemandRouteManager.js +4 -6
  107. package/lib/node/index.d.ts +1 -0
  108. package/lib/node/index.js +17 -5
  109. package/lib/node/paths.js +0 -2
  110. package/lib/node/shuvi-runtime-server.d.ts +26 -0
  111. package/lib/{shared/serverTypes.js → node/shuvi-runtime-server.js} +0 -0
  112. package/lib/node/shuvi-type-extensions-node.d.ts +20 -23
  113. package/lib/node/targets/react/bundler/index.d.ts +1 -13
  114. package/lib/node/targets/react/bundler/index.js +19 -13
  115. package/lib/node/targets/react/index.d.ts +2 -27
  116. package/lib/node/targets/react/index.js +3 -7
  117. package/lib/node/targets/react/model/index.d.ts +6 -0
  118. package/lib/node/targets/react/{redox-react → model}/index.js +7 -6
  119. package/lib/node/version.d.ts +1 -0
  120. package/lib/node/version.js +13 -0
  121. package/lib/shared/appTypes.d.ts +12 -6
  122. package/lib/shared/configTypes.d.ts +1 -3
  123. package/lib/shared/constants.d.ts +8 -0
  124. package/lib/shared/constants.js +15 -0
  125. package/lib/shared/htmlRenderer.d.ts +33 -0
  126. package/lib/shared/htmlRenderer.js +2 -0
  127. package/lib/shared/index.d.ts +2 -1
  128. package/lib/shared/index.js +2 -1
  129. package/lib/shared/renderTypes.d.ts +8 -7
  130. package/lib/shared/routeTypes.d.ts +4 -9
  131. package/package.json +40 -26
  132. package/polyfills/polyfills.js +1 -0
  133. package/shuvi-env.d.ts +10 -0
  134. package/shuvi-image.d.ts +54 -0
  135. package/shuvi-type-extensions-node.js +1 -0
  136. package/shuvi-type-extensions-runtime.d.ts +2 -2
  137. package/esm/shared/serverTypes.d.ts +0 -6
  138. package/esm/shuvi-app/dev/webpackHotDevClient.d.ts +0 -5
  139. package/esm/shuvi-app/dev/webpackHotDevClient.js +0 -34
  140. package/esm/shuvi-app/react/applicationContext.d.ts +0 -7
  141. package/esm/shuvi-app/react/redox-react/runtime.d.ts +0 -2
  142. package/esm/shuvi-app/react/view/render-action.d.ts +0 -10
  143. package/esm/shuvi-app/shuvi-runtime-index.d.ts +0 -4
  144. package/esm/shuvi-app/shuvi-runtime-index.js +0 -2
  145. package/esm/shuvi-app/shuvi-runtime-server.d.ts +0 -6
  146. package/esm/shuvi-app/shuvi-runtime-server.js +0 -1
  147. package/lib/node/features/html-render/lib/pageLoader.d.ts +0 -1
  148. package/lib/node/features/html-render/lib/pageLoader.js +0 -42
  149. package/lib/node/features/main/index.d.ts +0 -3
  150. package/lib/node/features/main/index.js +0 -82
  151. package/lib/node/targets/react/redox-react/index.d.ts +0 -18
  152. package/lib/shared/serverTypes.d.ts +0 -6
@@ -0,0 +1,26 @@
1
+ import { ShuviRequestHandler, ServerPluginConstructor as _ServerPluginConstructor } from '@shuvi/service';
2
+ import { IApiRequestHandler } from '../shared';
3
+ import { extendedHooks } from './features/html-render/serverHooks';
4
+ declare global {
5
+ namespace ShuviService {
6
+ interface CustomServerPluginHooks {
7
+ getPageData: typeof extendedHooks.getPageData;
8
+ handlePageRequest: typeof extendedHooks.handlePageRequest;
9
+ modifyHtml: typeof extendedHooks.modifyHtml;
10
+ }
11
+ }
12
+ }
13
+ declare type ServerPluginConstructor = Required<_ServerPluginConstructor>;
14
+ declare type Head<T extends any[]> = T extends [...infer Head, any] ? Head : never;
15
+ declare type RemoveLast<T extends (...args: any) => any> = (...args: Head<Parameters<T>>) => ReturnType<T>;
16
+ export declare type ShuviMiddlewareHandler = ShuviRequestHandler;
17
+ export declare type ShuviApiHandler = IApiRequestHandler;
18
+ export declare type GetPageDataFunction = RemoveLast<ServerPluginConstructor['getPageData']>;
19
+ export declare type HandlePageRequestFunction = RemoveLast<ServerPluginConstructor['handlePageRequest']>;
20
+ export declare type ModifyHtmlFunction = RemoveLast<ServerPluginConstructor['modifyHtml']>;
21
+ export interface IServerModule {
22
+ getPageData?: GetPageDataFunction;
23
+ handlePageRequest?: HandlePageRequestFunction;
24
+ modifyHtml?: ModifyHtmlFunction;
25
+ }
26
+ export {};
@@ -1,23 +1,26 @@
1
1
  import '@shuvi/platform-shared/shuvi-type-extensions-node';
2
- import { IManifest } from '@shuvi/toolpack/lib/webpack/types';
3
- import { IMiddlewareRoutes, CreateAppServer, IApiRoutes, IServerModule, PlatformWebCustomConfig } from '../shared/index';
4
- import { IViewServer } from './features/html-render/index';
5
- import { addRoutes, addMiddlewareRoutes } from './features/filesystem-routes/hooks';
6
- import { extendedHooks } from './features/html-render/serverHooks';
2
+ import { IPageRouteRecord } from '@shuvi/platform-shared/shared';
3
+ import { IManifest, IMiddlewareRoutes, CreateAppServer, IApiRoutes, PlatformWebCustomConfig } from '../shared';
4
+ import { IViewServer } from './features/html-render';
5
+ import { IServerModule } from './shuvi-runtime-server';
6
+ import { addRoutes, addMiddlewareRoutes, addApiRoutes } from './features/filesystem-routes/hooks';
7
7
  export {};
8
8
  declare module '@shuvi/service/lib/resources' {
9
- const server: {
10
- server: IServerModule;
11
- apiRoutes: IApiRoutes;
12
- middlewareRoutes: IMiddlewareRoutes;
13
- application: {
14
- createApp: CreateAppServer;
9
+ interface IResources {
10
+ server: {
11
+ server: IServerModule;
12
+ pageRoutes: IPageRouteRecord[];
13
+ apiRoutes: IApiRoutes;
14
+ middlewareRoutes: IMiddlewareRoutes;
15
+ application: {
16
+ createApp: CreateAppServer;
17
+ };
18
+ view: IViewServer;
15
19
  };
16
- view: IViewServer;
17
- };
18
- const documentPath: string;
19
- const clientManifest: IManifest;
20
- const serverManifest: IManifest;
20
+ documentPath: string;
21
+ clientManifest: IManifest;
22
+ serverManifest: IManifest;
23
+ }
21
24
  }
22
25
  declare global {
23
26
  namespace ShuviService {
@@ -25,18 +28,12 @@ declare global {
25
28
  ssr: PlatformWebCustomConfig['ssr'];
26
29
  router: PlatformWebCustomConfig['router'];
27
30
  routes?: PlatformWebCustomConfig['routes'];
28
- middlewareRoutes?: PlatformWebCustomConfig['middlewareRoutes'];
29
- apiRoutes?: PlatformWebCustomConfig['apiRoutes'];
30
31
  conventionRoutes: PlatformWebCustomConfig['conventionRoutes'];
31
32
  }
32
33
  interface CustomCorePluginHooks {
33
34
  addRoutes: typeof addRoutes;
34
35
  addMiddlewareRoutes: typeof addMiddlewareRoutes;
35
- }
36
- interface CustomServerPluginHooks {
37
- getPageData: typeof extendedHooks.getPageData;
38
- handlePageRequest: typeof extendedHooks.handlePageRequest;
39
- modifyHtml: typeof extendedHooks.modifyHtml;
36
+ addApiRoutes: typeof addApiRoutes;
40
37
  }
41
38
  }
42
39
  }
@@ -1,16 +1,4 @@
1
1
  declare const _default: {
2
- core: import("@shuvi/hook").IPluginInstance<{
3
- extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
4
- afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
5
- afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
6
- afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
7
- afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
8
- afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
9
- configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
10
- addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
11
- addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
12
- addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
13
- addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
14
- } & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
2
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
15
3
  };
16
4
  export default _default;
@@ -29,8 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const path = __importStar(require("path"));
30
30
  const service_1 = require("@shuvi/service");
31
31
  const ReactRefreshWebpackPlugin_1 = __importDefault(require("@next/react-refresh-utils/ReactRefreshWebpackPlugin"));
32
- const constants_1 = require("@shuvi/shared/lib/constants");
33
- const webpack_1 = require("webpack");
32
+ const shared_1 = require("../../../../shared");
34
33
  const configWebpack = (config, { name, webpack }, context) => {
35
34
  const resolveLocal = (m, sub) => {
36
35
  const pck = path.dirname(require.resolve(`${m}/package.json`));
@@ -64,25 +63,32 @@ const configWebpack = (config, { name, webpack }, context) => {
64
63
  resolveLocal('react', 'jsx-runtime')
65
64
  ]);
66
65
  // @ts-ignore
66
+ config.resolve.alias.set('react/jsx-dev-runtime$', [
67
+ resolveUser('react/jsx-dev-runtime'),
68
+ resolveLocal('react', 'jsx-dev-runtime')
69
+ ]);
70
+ // @ts-ignore
67
71
  config.resolve.alias.set('react-dom$', [
68
72
  resolveUser('react-dom'),
69
73
  resolveLocal('react-dom')
70
74
  ]);
71
- if (name === constants_1.BUNDLER_DEFAULT_TARGET && context.mode === 'development') {
72
- config.module
73
- .rule('main')
74
- .oneOf('js')
75
- .use('react-refresh-loader')
76
- .loader(require.resolve('@next/react-refresh-utils/loader'))
77
- .before('shuvi-swc-loader');
78
- config
79
- .plugin('react-refresh-plugin')
80
- .use(ReactRefreshWebpackPlugin_1.default, [webpack]);
81
- config.plugin('version-env-plugin').use(webpack_1.DefinePlugin, [
75
+ if (name === shared_1.BUNDLER_TARGET_CLIENT) {
76
+ config.plugin('version-env-plugin').use(webpack.DefinePlugin, [
82
77
  {
83
78
  'process.env.__SHUVI__AFTER__REACT__18__': JSON.stringify(isReactVersionAfter18())
84
79
  }
85
80
  ]);
81
+ if (context.mode === 'development') {
82
+ config.module
83
+ .rule('main')
84
+ .oneOf('js')
85
+ .use('react-refresh-loader')
86
+ .loader(require.resolve('@next/react-refresh-utils/loader'))
87
+ .before('shuvi-swc-loader');
88
+ config
89
+ .plugin('react-refresh-plugin')
90
+ .use(ReactRefreshWebpackPlugin_1.default, [webpack]);
91
+ }
86
92
  }
87
93
  return config;
88
94
  };
@@ -1,32 +1,7 @@
1
1
  declare const platformWebReact: () => {
2
- plugins: (import("@shuvi/hook").IPluginInstance<{
3
- extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
4
- afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
5
- afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
6
- afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
7
- afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
8
- afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
9
- configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
10
- addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
11
- addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
12
- addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
13
- addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
14
- } & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext> | {
15
- core: import("@shuvi/hook").IPluginInstance<{
16
- extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
17
- afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
18
- afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
19
- afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
20
- afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
21
- afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
22
- configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
23
- addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
24
- addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
25
- addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
26
- addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
27
- } & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
2
+ plugins: (import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext> | {
3
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
28
4
  })[];
29
5
  platformModule: string;
30
- polyfills: string[];
31
6
  };
32
7
  export default platformWebReact;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const service_1 = require("@shuvi/service");
7
7
  const bundler_1 = __importDefault(require("./bundler"));
8
- const redox_react_1 = require("./redox-react");
8
+ const model_1 = require("./model");
9
9
  const paths_1 = require("../../paths");
10
10
  const webReactMainPlugin = (0, service_1.createPlugin)({
11
11
  addRuntimeService: () => [
@@ -17,12 +17,8 @@ const webReactMainPlugin = (0, service_1.createPlugin)({
17
17
  });
18
18
  const platformWebReact = () => {
19
19
  return {
20
- plugins: [webReactMainPlugin, bundler_1.default, redox_react_1.RedoxReactPlugin],
21
- platformModule: (0, paths_1.resolvePkgFile)('esm/shuvi-app/react/index'),
22
- polyfills: [
23
- (0, paths_1.resolveDep)('react-app-polyfill/ie11'),
24
- (0, paths_1.resolveDep)('react-app-polyfill/stable')
25
- ]
20
+ plugins: [webReactMainPlugin, bundler_1.default, model_1.ModelReactPlugin],
21
+ platformModule: (0, paths_1.resolvePkgFile)('esm/shuvi-app/react/index')
26
22
  };
27
23
  };
28
24
  exports.default = platformWebReact;
@@ -0,0 +1,6 @@
1
+ export declare const ModelReactPlugin: {
2
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
3
+ runtime: {
4
+ plugin: string;
5
+ };
6
+ };
@@ -23,13 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.RedoxReactPlugin = void 0;
26
+ exports.ModelReactPlugin = void 0;
27
27
  const path = __importStar(require("path"));
28
28
  const service_1 = require("@shuvi/service");
29
29
  const paths_1 = require("../../../paths");
30
- // todo: optimize this
31
- const runtimePath = require.resolve(path.join(__dirname, '../../../../../esm/shuvi-app/react/redox-react/runtime'));
32
- const core = (0, service_1.createPlugin)({
30
+ const core = (0, service_1.createPluginAfter)({
33
31
  addRuntimeService: () => [
34
32
  {
35
33
  source: path.dirname(require.resolve('@shuvi/redox-react/package.json')),
@@ -41,10 +39,13 @@ const core = (0, service_1.createPlugin)({
41
39
  config.resolve.alias.set('@shuvi/redox', (0, paths_1.resolveLib)('@shuvi/redox'));
42
40
  return config;
43
41
  }
42
+ }, {
43
+ name: 'model-react'
44
44
  });
45
- exports.RedoxReactPlugin = {
45
+ exports.ModelReactPlugin = {
46
46
  core,
47
47
  runtime: {
48
- plugin: runtimePath
48
+ // this need
49
+ plugin: (0, paths_1.resolvePkgFile)('esm/shuvi-app/react/model/runtime')
49
50
  }
50
51
  };
@@ -0,0 +1 @@
1
+ export declare function getVersion(): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVersion = void 0;
4
+ const paths_1 = require("./paths");
5
+ let version;
6
+ function getVersion() {
7
+ if (!version) {
8
+ const pkg = require((0, paths_1.resolvePkgFile)('package.json'));
9
+ version = pkg.version;
10
+ }
11
+ return version;
12
+ }
13
+ exports.getVersion = getVersion;
@@ -1,15 +1,21 @@
1
- import { IRequest, IRawPageRouteRecord, IAppData, IAppState } from '@shuvi/platform-shared/shared';
2
- import { Application } from '@shuvi/platform-shared/shuvi-app/application';
1
+ import { IPageRouteRecord, IAppData, IAppState, Application as _Application } from '@shuvi/platform-shared/shared';
2
+ import { ApplicationImpl as _ApplicationImpl } from '@shuvi/platform-shared/shuvi-app/application';
3
+ import type { ShuviRequest } from '@shuvi/service';
4
+ export interface AppConfig {
5
+ ssr: boolean;
6
+ }
7
+ export declare type InternalApplication = _ApplicationImpl<AppConfig>;
8
+ export declare type Application = _Application<AppConfig>;
3
9
  export interface CreateAppServer {
4
10
  (options: {
5
- req: IRequest;
11
+ req: ShuviRequest;
6
12
  ssr: boolean;
7
- }): Application;
13
+ }): InternalApplication;
8
14
  }
9
15
  export interface CreateAppClient {
10
16
  (options: {
11
- routes: IRawPageRouteRecord[];
17
+ routes: IPageRouteRecord[];
12
18
  appComponent: any;
13
19
  appData: IAppData<any, IAppState>;
14
- }): Application;
20
+ }): InternalApplication;
15
21
  }
@@ -1,4 +1,4 @@
1
- import { IRouterHistoryMode, IPageRouteConfig, IMiddlewareRouteConfig, IApiRouteConfig } from '@shuvi/platform-shared/shared';
1
+ import { IRouterHistoryMode, IPageRouteConfig } from '@shuvi/platform-shared/shared';
2
2
  export interface IRouterConfig {
3
3
  history: IRouterHistoryMode | 'auto';
4
4
  }
@@ -6,8 +6,6 @@ export interface PlatformWebCustomConfig {
6
6
  ssr: boolean;
7
7
  router: IRouterConfig;
8
8
  routes?: IPageRouteConfig[];
9
- middlewareRoutes?: IMiddlewareRouteConfig[];
10
- apiRoutes?: IApiRouteConfig[];
11
9
  conventionRoutes: {
12
10
  exclude?: string[];
13
11
  };
@@ -0,0 +1,8 @@
1
+ export { BUNDLER_TARGET_CLIENT, BUNDLER_TARGET_SERVER, CLIENT_OUTPUT_DIR, SERVER_OUTPUT_DIR } from '@shuvi/shared/lib/constants';
2
+ export declare const CLIENT_BUILD_MANIFEST_PATH = "../build-manifest.client.json";
3
+ export declare const SERVER_BUILD_MANIFEST_PATH = "../build-manifest.server.json";
4
+ export declare const BUILD_CLIENT_RUNTIME_POLYFILLS = "static/polyfills";
5
+ export declare const BUILD_CLIENT_RUNTIME_POLYFILLS_SYMBOL: unique symbol;
6
+ export declare const BUILD_CLIENT_RUNTIME_WEBPACK = "static/webpack-runtime";
7
+ export declare const BUILD_CLIENT_RUNTIME_MAIN = "static/main";
8
+ export declare const BUILD_SERVER_FILE_SERVER = "server";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BUILD_SERVER_FILE_SERVER = exports.BUILD_CLIENT_RUNTIME_MAIN = exports.BUILD_CLIENT_RUNTIME_WEBPACK = exports.BUILD_CLIENT_RUNTIME_POLYFILLS_SYMBOL = exports.BUILD_CLIENT_RUNTIME_POLYFILLS = exports.SERVER_BUILD_MANIFEST_PATH = exports.CLIENT_BUILD_MANIFEST_PATH = exports.SERVER_OUTPUT_DIR = exports.CLIENT_OUTPUT_DIR = exports.BUNDLER_TARGET_SERVER = exports.BUNDLER_TARGET_CLIENT = void 0;
4
+ var constants_1 = require("@shuvi/shared/lib/constants");
5
+ Object.defineProperty(exports, "BUNDLER_TARGET_CLIENT", { enumerable: true, get: function () { return constants_1.BUNDLER_TARGET_CLIENT; } });
6
+ Object.defineProperty(exports, "BUNDLER_TARGET_SERVER", { enumerable: true, get: function () { return constants_1.BUNDLER_TARGET_SERVER; } });
7
+ Object.defineProperty(exports, "CLIENT_OUTPUT_DIR", { enumerable: true, get: function () { return constants_1.CLIENT_OUTPUT_DIR; } });
8
+ Object.defineProperty(exports, "SERVER_OUTPUT_DIR", { enumerable: true, get: function () { return constants_1.SERVER_OUTPUT_DIR; } });
9
+ exports.CLIENT_BUILD_MANIFEST_PATH = '../build-manifest.client.json';
10
+ exports.SERVER_BUILD_MANIFEST_PATH = '../build-manifest.server.json';
11
+ exports.BUILD_CLIENT_RUNTIME_POLYFILLS = `static/polyfills`;
12
+ exports.BUILD_CLIENT_RUNTIME_POLYFILLS_SYMBOL = Symbol(`polyfills`);
13
+ exports.BUILD_CLIENT_RUNTIME_WEBPACK = `static/webpack-runtime`;
14
+ exports.BUILD_CLIENT_RUNTIME_MAIN = `static/main`;
15
+ exports.BUILD_SERVER_FILE_SERVER = `server`;
@@ -0,0 +1,33 @@
1
+ export interface IModuleItem {
2
+ id: string;
3
+ name: string;
4
+ }
5
+ export interface IModule {
6
+ files: string[];
7
+ children: IModuleItem[];
8
+ }
9
+ export declare type IAssetMap = {
10
+ js: string[];
11
+ css?: string[];
12
+ } & {
13
+ [ext: string]: string[];
14
+ };
15
+ export interface IChunk {
16
+ file: string;
17
+ request: string;
18
+ }
19
+ export interface IManifest {
20
+ polyfillFiles?: string[];
21
+ entries: {
22
+ [s: string]: IAssetMap;
23
+ };
24
+ bundles: {
25
+ [name: string]: string;
26
+ };
27
+ chunkRequest: {
28
+ [file: string]: string;
29
+ };
30
+ loadble: {
31
+ [s: string]: IModule;
32
+ };
33
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,6 @@
1
1
  export * from './appTypes';
2
2
  export * from './configTypes';
3
+ export * from './constants';
4
+ export * from './htmlRenderer';
3
5
  export * from './renderTypes';
4
6
  export * from './routeTypes';
5
- export * from './serverTypes';
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./appTypes"), exports);
18
18
  __exportStar(require("./configTypes"), exports);
19
+ __exportStar(require("./constants"), exports);
20
+ __exportStar(require("./htmlRenderer"), exports);
19
21
  __exportStar(require("./renderTypes"), exports);
20
22
  __exportStar(require("./routeTypes"), exports);
21
- __exportStar(require("./serverTypes"), exports);
@@ -1,10 +1,11 @@
1
- import { IManifest } from '@shuvi/toolpack/lib/webpack/types';
2
- import { Response, IApplication, IRequest, IAppData } from '@shuvi/platform-shared/shared';
3
- export declare type IRenderDocumentOptions = {
4
- app: IApplication;
5
- req?: IRequest;
1
+ import type { ShuviRequest } from '@shuvi/service';
2
+ import { Response, IAppData } from '@shuvi/platform-shared/shared';
3
+ import { IManifest } from '../shared';
4
+ import { Application } from './appTypes';
5
+ export declare type IRenderViewOptions = {
6
+ app: Application;
6
7
  };
7
- export interface IRenderOptions extends IRenderDocumentOptions {
8
+ export interface IRenderOptions extends IRenderViewOptions {
8
9
  }
9
10
  export interface IView<RenderOption extends IRenderOptions = any, RenderResult = void> {
10
11
  renderApp(options: RenderOption): RenderResult;
@@ -35,8 +36,8 @@ export interface IClientRendererOptions<ExtraAppData = {}> extends IRenderOption
35
36
  appData: IAppData<ExtraAppData>;
36
37
  }
37
38
  export interface IServerRendererOptions extends IRenderOptions {
39
+ req: ShuviRequest;
38
40
  manifest: IManifest;
39
- getAssetPublicUrl(path: string): string;
40
41
  }
41
42
  export interface IViewClient<ExtraAppData = {}> extends IView<IClientRendererOptions<ExtraAppData>> {
42
43
  }
@@ -1,10 +1,5 @@
1
- import { IURLParams, IURLQuery } from '@shuvi/platform-shared/shared';
2
- import { IRequestHandlerWithNext } from '@shuvi/service';
3
- import { IResponse, IRequest } from '@shuvi/service';
1
+ import { ShuviRequest, ShuviResponse, ShuviRequestHandler } from '@shuvi/service';
4
2
  export interface IApiReq {
5
- pathname: string;
6
- query: IURLQuery;
7
- params: IURLParams;
8
3
  cookies: {
9
4
  [key: string]: string;
10
5
  };
@@ -12,7 +7,7 @@ export interface IApiReq {
12
7
  [key: string]: any;
13
8
  };
14
9
  }
15
- export declare type IApiRequest = IRequest & IApiReq;
10
+ export declare type IApiRequest = ShuviRequest & IApiReq;
16
11
  export declare type Send<T> = (body: T) => void;
17
12
  export declare type IApiRes<T = any> = {
18
13
  send: Send<T>;
@@ -21,7 +16,7 @@ export declare type IApiRes<T = any> = {
21
16
  redirect(url: string): IApiRes<T>;
22
17
  redirect(status: number, url: string): IApiRes<T>;
23
18
  };
24
- export declare type IApiResponse<T = any> = IResponse & IApiRes<T>;
19
+ export declare type IApiResponse<T = any> = ShuviResponse & IApiRes<T>;
25
20
  export declare type IApiRequestHandler<T = any> = (req: IApiRequest, res: IApiResponse<T>) => void | Promise<void>;
26
21
  export interface IApiConfig {
27
22
  api?: {
@@ -35,7 +30,7 @@ export interface IApiHandler {
35
30
  config?: IApiConfig;
36
31
  }
37
32
  export interface IMiddlewareConfig {
38
- default: IRequestHandlerWithNext;
33
+ default: ShuviRequestHandler;
39
34
  }
40
35
  export declare type IApiRoutes = {
41
36
  path: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/platform-web",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.20",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -12,9 +12,13 @@
12
12
  "**/shuvi-app/entry/client/**"
13
13
  ],
14
14
  "files": [
15
- "lib",
16
15
  "esm",
16
+ "lib",
17
+ "polyfills",
18
+ "shuvi-env.d.ts",
19
+ "shuvi-image.d.ts",
17
20
  "shuvi-type-extensions-node.d.ts",
21
+ "shuvi-type-extensions-node.js",
18
22
  "shuvi-type-extensions-runtime.d.ts"
19
23
  ],
20
24
  "exports": {
@@ -28,10 +32,14 @@
28
32
  "default": "./lib/node/*.js"
29
33
  },
30
34
  "./shared": {
31
- "default": "./esm/shared/index.js"
35
+ "require": "./lib/shared/index.js",
36
+ "import": "./esm/shared/index.js",
37
+ "default": "./lib/shared/index.js"
32
38
  },
33
39
  "./shared/*": {
34
- "default": "./esm/shared/*.js"
40
+ "require": "./lib/shared/index.js",
41
+ "import": "./esm/shared/index.js",
42
+ "default": "./lib/shared/*.js"
35
43
  },
36
44
  "./shuvi-app": {
37
45
  "default": "./esm/shuvi-app/index.js"
@@ -46,58 +54,64 @@
46
54
  "types": "./shuvi-type-extensions-node.d.js",
47
55
  "default": "./shuvi-type-extensions-node.js"
48
56
  },
49
- "./shuvi-type-extensions-runtime": "./shuvi-type-extensions-runtime.d.ts"
57
+ "./shuvi-type-extensions-runtime": "./shuvi-type-extensions-runtime.d.ts",
58
+ "./package.json": "./package.json"
50
59
  },
51
60
  "scripts": {
52
61
  "dev": "run-p watch:*",
53
62
  "watch:esm": "tsc -p tsconfig.build.browser.json -w",
54
63
  "watch:cjs": "tsc -p tsconfig.build.node.json -w",
55
- "prebuild": "rimraf lib esm types",
64
+ "prebuild": "rimraf lib esm polyfills",
56
65
  "build": "run-p build:*",
57
66
  "build:esm": "tsc -p tsconfig.build.browser.json",
58
- "build:cjs": "tsc -p tsconfig.build.node.json"
67
+ "build:cjs": "tsc -p tsconfig.build.node.json",
68
+ "build:polyfills": "microbundle -i src/polyfills/index.js -o polyfills/polyfills.js -f iife --no-sourcemap --external none --no-pkg-main"
59
69
  },
60
70
  "engines": {
61
71
  "node": ">= 12.0.0"
62
72
  },
63
73
  "dependencies": {
64
74
  "@next/react-refresh-utils": "12.1.6",
65
- "@shuvi/hook": "1.0.0-rc.2",
66
- "@shuvi/platform-shared": "1.0.0-rc.2",
67
- "@shuvi/redox": "0.0.3",
68
- "@shuvi/redox-react": "0.0.3",
69
- "@shuvi/router": "1.0.0-rc.2",
70
- "@shuvi/router-react": "1.0.0-rc.2",
71
- "@shuvi/runtime": "1.0.0-rc.2",
72
- "@shuvi/service": "1.0.0-rc.2",
73
- "@shuvi/shared": "1.0.0-rc.2",
74
- "@shuvi/toolpack": "1.0.0-rc.2",
75
- "@shuvi/utils": "1.0.0-rc.2",
75
+ "@shuvi/error-overlay": "1.0.0-rc.20",
76
+ "@shuvi/hook": "1.0.0-rc.20",
77
+ "@shuvi/platform-shared": "1.0.0-rc.20",
78
+ "@shuvi/redox": "0.0.7",
79
+ "@shuvi/redox-react": "0.0.7",
80
+ "@shuvi/router": "1.0.0-rc.20",
81
+ "@shuvi/router-react": "1.0.0-rc.20",
82
+ "@shuvi/runtime": "1.0.0-rc.20",
83
+ "@shuvi/service": "1.0.0-rc.20",
84
+ "@shuvi/shared": "1.0.0-rc.20",
85
+ "@shuvi/toolpack": "1.0.0-rc.20",
86
+ "@shuvi/utils": "1.0.0-rc.20",
76
87
  "content-type": "1.0.4",
77
88
  "cookie": "0.4.1",
89
+ "core-js": "3.6.5",
78
90
  "ejs": "3.1.5",
79
91
  "fs-extra": "9.0.1",
80
92
  "node-mocks-http": "1.11.0",
93
+ "object-assign": "4.1.1",
81
94
  "raw-body": "2.4.1",
82
95
  "react": "18.1.0",
83
- "react-app-polyfill": "2.0.0",
84
96
  "react-dom": "18.1.0",
85
97
  "react-refresh": "0.12.0",
86
- "use-sync-external-store": "1.1.0"
98
+ "strip-ansi": "6.0.0",
99
+ "use-sync-external-store": "1.1.0",
100
+ "whatwg-fetch": "3.0.0"
87
101
  },
88
102
  "peerDependencies": {
89
- "@shuvi/service": "1.0.0-rc.2"
103
+ "@shuvi/service": "1.0.0-rc.20"
90
104
  },
91
105
  "devDependencies": {
92
- "@types/react": "18.0.9",
93
- "@types/react-dom": "18.0.6",
94
- "@types/react-test-renderer": "18.0.0",
95
- "@shuvi/redox": "0.0.3",
96
106
  "@testing-library/react": "^13.2.0",
97
107
  "@types/content-type": "^1.1.5",
98
108
  "@types/cookie": "^0.4.1",
99
109
  "@types/ejs": "^3.1.0",
100
110
  "@types/raw-body": "^2.3.0",
101
- "webpack": "5.73.0"
111
+ "@types/react": "18.0.9",
112
+ "@types/react-dom": "18.0.6",
113
+ "@types/react-test-renderer": "18.0.0",
114
+ "memfs": "3.1.2",
115
+ "microbundle": "0.15.1"
102
116
  }
103
117
  }