@shuvi/platform-web 1.0.0-rc.3 → 1.0.0-rc.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.
Files changed (108) hide show
  1. package/esm/shared/appTypes.d.ts +5 -3
  2. package/esm/shared/renderTypes.d.ts +6 -5
  3. package/esm/shared/routeTypes.d.ts +4 -9
  4. package/esm/shuvi-app/app/client.d.ts +2 -0
  5. package/esm/shuvi-app/app/client.js +13 -17
  6. package/esm/shuvi-app/app/server.js +10 -9
  7. package/esm/shuvi-app/dev/eventsource.d.ts +1 -0
  8. package/esm/shuvi-app/dev/eventsource.js +60 -0
  9. package/esm/shuvi-app/dev/hotDevClient.d.ts +32 -0
  10. package/esm/shuvi-app/dev/hotDevClient.js +327 -0
  11. package/esm/shuvi-app/dev/index.d.ts +3 -0
  12. package/esm/shuvi-app/dev/index.js +27 -0
  13. package/esm/shuvi-app/dev/websocket.d.ts +16 -0
  14. package/esm/shuvi-app/dev/websocket.js +61 -0
  15. package/esm/shuvi-app/entry/client/app.d.ts +2 -1
  16. package/esm/shuvi-app/entry/client/app.js +2 -2
  17. package/esm/shuvi-app/entry/client/run.dev.js +4 -4
  18. package/esm/shuvi-app/entry/server/index.d.ts +5 -4
  19. package/esm/shuvi-app/entry/server/index.js +5 -4
  20. package/esm/shuvi-app/helper/serializeServerError.d.ts +2 -0
  21. package/esm/shuvi-app/helper/serializeServerError.js +21 -0
  22. package/esm/shuvi-app/react/AppContainer.d.ts +2 -3
  23. package/esm/shuvi-app/react/AppContainer.jsx +3 -4
  24. package/esm/shuvi-app/react/getRoutes.d.ts +2 -2
  25. package/esm/shuvi-app/react/getRoutes.js +9 -8
  26. package/esm/shuvi-app/react/{redox-react → model}/RedoxWrapper.d.ts +3 -3
  27. package/esm/shuvi-app/react/{redox-react → model}/RedoxWrapper.jsx +3 -3
  28. package/esm/shuvi-app/react/model/runtime.d.ts +8 -0
  29. package/esm/shuvi-app/react/{redox-react → model}/runtime.js +8 -3
  30. package/esm/shuvi-app/react/store.d.ts +5 -0
  31. package/esm/shuvi-app/react/store.js +3 -0
  32. package/esm/shuvi-app/react/types.d.ts +0 -7
  33. package/esm/shuvi-app/react/useLoaderData.js +9 -20
  34. package/esm/shuvi-app/react/view/ReactView.client.jsx +25 -4
  35. package/esm/shuvi-app/react/view/ReactView.server.jsx +17 -14
  36. package/esm/shuvi-app/shuvi-runtime-index.d.ts +3 -3
  37. package/esm/shuvi-app/shuvi-runtime-index.js +1 -1
  38. package/lib/node/features/custom-server/index.d.ts +1 -1
  39. package/lib/node/features/custom-server/server.d.ts +1 -1
  40. package/lib/node/features/filesystem-routes/api/apiRouteHandler.d.ts +7 -7
  41. package/lib/node/features/filesystem-routes/api/apiRouteHandler.js +0 -4
  42. package/lib/node/features/filesystem-routes/api/middleware.d.ts +2 -2
  43. package/lib/node/features/filesystem-routes/index.d.ts +1 -13
  44. package/lib/node/features/filesystem-routes/index.js +20 -48
  45. package/lib/node/features/filesystem-routes/middleware/middleware.d.ts +2 -2
  46. package/lib/node/features/filesystem-routes/page/routes.d.ts +2 -2
  47. package/lib/node/features/filesystem-routes/page/routes.js +29 -11
  48. package/lib/node/features/html-render/index.d.ts +3 -18
  49. package/lib/node/features/html-render/index.js +87 -16
  50. package/lib/node/features/{main → html-render/lib}/buildHtml.d.ts +0 -0
  51. package/lib/node/features/{main → html-render/lib}/buildHtml.js +0 -0
  52. package/lib/node/features/html-render/lib/generateFilesByRoutId.d.ts +2 -2
  53. package/lib/node/features/html-render/lib/generateFilesByRoutId.js +3 -3
  54. package/lib/node/features/{main → html-render/lib}/generateResource.d.ts +0 -0
  55. package/lib/node/features/{main → html-render/lib}/generateResource.js +0 -0
  56. package/lib/node/features/html-render/lib/getPageMiddleware.d.ts +2 -2
  57. package/lib/node/features/html-render/lib/index.d.ts +0 -1
  58. package/lib/node/features/html-render/lib/index.js +1 -3
  59. package/lib/node/features/html-render/lib/renderToHTML.d.ts +2 -2
  60. package/lib/node/features/html-render/lib/renderToHTML.js +7 -48
  61. package/lib/node/features/html-render/lib/renderer/base.d.ts +6 -6
  62. package/lib/node/features/html-render/lib/renderer/base.js +5 -5
  63. package/lib/node/features/html-render/lib/renderer/index.d.ts +5 -4
  64. package/lib/node/features/html-render/lib/renderer/index.js +69 -6
  65. package/lib/node/features/html-render/lib/renderer/spa.d.ts +2 -2
  66. package/lib/node/features/html-render/lib/renderer/spa.js +4 -6
  67. package/lib/node/features/html-render/lib/renderer/ssr.d.ts +2 -2
  68. package/lib/node/features/html-render/lib/renderer/ssr.js +5 -6
  69. package/lib/node/features/html-render/lib/renderer/types.d.ts +8 -5
  70. package/lib/node/features/html-render/server.d.ts +1 -1
  71. package/lib/node/features/index.d.ts +3 -31
  72. package/lib/node/features/index.js +6 -7
  73. package/lib/node/features/model/index.d.ts +1 -13
  74. package/lib/node/features/model/runtime.d.ts +3 -8
  75. package/lib/node/features/model/runtime.js +13 -17
  76. package/lib/node/features/model/server.js +2 -3
  77. package/lib/node/features/model/shuvi-app.d.ts +2 -2
  78. package/lib/node/features/on-demand-compile-page/index.d.ts +3 -13
  79. package/lib/node/features/on-demand-compile-page/index.js +4 -1
  80. package/lib/node/features/on-demand-compile-page/onDemandRouteManager.d.ts +3 -3
  81. package/lib/node/features/on-demand-compile-page/onDemandRouteManager.js +2 -4
  82. package/lib/node/index.js +1 -3
  83. package/lib/node/paths.js +0 -2
  84. package/lib/node/shuvi-runtime-server.d.ts +18 -0
  85. package/lib/node/shuvi-runtime-server.js +2 -0
  86. package/lib/node/shuvi-type-extensions-node.d.ts +2 -6
  87. package/lib/node/targets/react/bundler/index.d.ts +1 -13
  88. package/lib/node/targets/react/bundler/index.js +5 -0
  89. package/lib/node/targets/react/index.d.ts +2 -26
  90. package/lib/node/targets/react/index.js +2 -2
  91. package/lib/node/targets/react/model/index.d.ts +6 -0
  92. package/lib/node/targets/react/{redox-react → model}/index.js +7 -6
  93. package/lib/shared/appTypes.d.ts +5 -3
  94. package/lib/shared/renderTypes.d.ts +6 -5
  95. package/lib/shared/routeTypes.d.ts +4 -9
  96. package/package.json +20 -15
  97. package/shuvi-env.d.ts +10 -0
  98. package/shuvi-image.d.ts +54 -0
  99. package/shuvi-type-extensions-node.js +1 -0
  100. package/shuvi-type-extensions-runtime.d.ts +2 -2
  101. package/esm/shuvi-app/dev/webpackHotDevClient.d.ts +0 -5
  102. package/esm/shuvi-app/dev/webpackHotDevClient.js +0 -34
  103. package/esm/shuvi-app/react/redox-react/runtime.d.ts +0 -2
  104. package/esm/shuvi-app/shuvi-runtime-server.d.ts +0 -6
  105. package/esm/shuvi-app/shuvi-runtime-server.js +0 -1
  106. package/lib/node/features/main/index.d.ts +0 -3
  107. package/lib/node/features/main/index.js +0 -82
  108. package/lib/node/targets/react/redox-react/index.d.ts +0 -18
@@ -1,30 +1,6 @@
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
6
  polyfills: string[];
@@ -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,7 +17,7 @@ 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],
20
+ plugins: [webReactMainPlugin, bundler_1.default, model_1.ModelReactPlugin],
21
21
  platformModule: (0, paths_1.resolvePkgFile)('esm/shuvi-app/react/index'),
22
22
  polyfills: [
23
23
  (0, paths_1.resolveDep)('react-app-polyfill/ie11'),
@@ -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
  };
@@ -1,14 +1,16 @@
1
- import { IRequest, IRawPageRouteRecord, IAppData, IAppState } from '@shuvi/platform-shared/shared';
1
+ import { IPageRouteRecord, IAppData, IAppState } from '@shuvi/platform-shared/shared';
2
2
  import { Application } from '@shuvi/platform-shared/shuvi-app/application';
3
+ import type { ShuviRequest } from '@shuvi/service';
3
4
  export interface CreateAppServer {
4
5
  (options: {
5
- req: IRequest;
6
+ req: ShuviRequest;
6
7
  ssr: boolean;
8
+ isDev: boolean;
7
9
  }): Application;
8
10
  }
9
11
  export interface CreateAppClient {
10
12
  (options: {
11
- routes: IRawPageRouteRecord[];
13
+ routes: IPageRouteRecord[];
12
14
  appComponent: any;
13
15
  appData: IAppData<any, IAppState>;
14
16
  }): Application;
@@ -1,10 +1,10 @@
1
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 = {
2
+ import type { ShuviRequest } from '@shuvi/service';
3
+ import { Response, IApplication, IAppData } from '@shuvi/platform-shared/shared';
4
+ export declare type IRenderViewOptions = {
4
5
  app: IApplication;
5
- req?: IRequest;
6
6
  };
7
- export interface IRenderOptions extends IRenderDocumentOptions {
7
+ export interface IRenderOptions extends IRenderViewOptions {
8
8
  }
9
9
  export interface IView<RenderOption extends IRenderOptions = any, RenderResult = void> {
10
10
  renderApp(options: RenderOption): RenderResult;
@@ -35,8 +35,9 @@ export interface IClientRendererOptions<ExtraAppData = {}> extends IRenderOption
35
35
  appData: IAppData<ExtraAppData>;
36
36
  }
37
37
  export interface IServerRendererOptions extends IRenderOptions {
38
+ req: ShuviRequest;
38
39
  manifest: IManifest;
39
- getAssetPublicUrl(path: string): string;
40
+ isDev?: boolean;
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.3",
3
+ "version": "1.0.0-rc.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -12,9 +12,12 @@
12
12
  "**/shuvi-app/entry/client/**"
13
13
  ],
14
14
  "files": [
15
- "lib",
16
15
  "esm",
16
+ "lib",
17
+ "shuvi-env.d.ts",
18
+ "shuvi-image.d.ts",
17
19
  "shuvi-type-extensions-node.d.ts",
20
+ "shuvi-type-extensions-node.js",
18
21
  "shuvi-type-extensions-runtime.d.ts"
19
22
  ],
20
23
  "exports": {
@@ -62,17 +65,18 @@
62
65
  },
63
66
  "dependencies": {
64
67
  "@next/react-refresh-utils": "12.1.6",
65
- "@shuvi/hook": "1.0.0-rc.3",
66
- "@shuvi/platform-shared": "1.0.0-rc.3",
67
- "@shuvi/redox": "0.0.3",
68
- "@shuvi/redox-react": "0.0.3",
69
- "@shuvi/router": "1.0.0-rc.3",
70
- "@shuvi/router-react": "1.0.0-rc.3",
71
- "@shuvi/runtime": "1.0.0-rc.3",
72
- "@shuvi/service": "1.0.0-rc.3",
73
- "@shuvi/shared": "1.0.0-rc.3",
74
- "@shuvi/toolpack": "1.0.0-rc.3",
75
- "@shuvi/utils": "1.0.0-rc.3",
68
+ "@shuvi/hook": "1.0.0-rc.6",
69
+ "@shuvi/platform-shared": "1.0.0-rc.6",
70
+ "@shuvi/redox": "0.0.6",
71
+ "@shuvi/redox-react": "0.0.6",
72
+ "@shuvi/router": "1.0.0-rc.6",
73
+ "@shuvi/router-react": "1.0.0-rc.6",
74
+ "@shuvi/runtime": "1.0.0-rc.6",
75
+ "@shuvi/service": "1.0.0-rc.6",
76
+ "@shuvi/shared": "1.0.0-rc.6",
77
+ "@shuvi/toolpack": "1.0.0-rc.6",
78
+ "@shuvi/utils": "1.0.0-rc.6",
79
+ "@shuvi/error-overlay": "1.0.0-rc.6",
76
80
  "content-type": "1.0.4",
77
81
  "cookie": "0.4.1",
78
82
  "ejs": "3.1.5",
@@ -82,17 +86,18 @@
82
86
  "react": "18.1.0",
83
87
  "react-app-polyfill": "2.0.0",
84
88
  "react-dom": "18.1.0",
89
+ "react-error-overlay": "6.0.8",
85
90
  "react-refresh": "0.12.0",
91
+ "strip-ansi": "6.0.0",
86
92
  "use-sync-external-store": "1.1.0"
87
93
  },
88
94
  "peerDependencies": {
89
- "@shuvi/service": "1.0.0-rc.3"
95
+ "@shuvi/service": "1.0.0-rc.6"
90
96
  },
91
97
  "devDependencies": {
92
98
  "@types/react": "18.0.9",
93
99
  "@types/react-dom": "18.0.6",
94
100
  "@types/react-test-renderer": "18.0.0",
95
- "@shuvi/redox": "0.0.3",
96
101
  "@testing-library/react": "^13.2.0",
97
102
  "@types/content-type": "^1.1.5",
98
103
  "@types/cookie": "^0.4.1",
package/shuvi-env.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="react" />
3
+ /// <reference types="react-dom" />
4
+
5
+ // Extend the NodeJS namespace with Next.js-defined properties
6
+ declare namespace NodeJS {
7
+ interface ProcessEnv {
8
+ readonly NODE_ENV: 'development' | 'production' | 'test';
9
+ }
10
+ }
@@ -0,0 +1,54 @@
1
+ declare module '*.bmp' {
2
+ const src: string;
3
+ export default src;
4
+ }
5
+
6
+ declare module '*.gif' {
7
+ const src: string;
8
+ export default src;
9
+ }
10
+
11
+ declare module '*.jpg' {
12
+ const src: string;
13
+ export default src;
14
+ }
15
+
16
+ declare module '*.jpeg' {
17
+ const src: string;
18
+ export default src;
19
+ }
20
+
21
+ declare module '*.png' {
22
+ const src: string;
23
+ export default src;
24
+ }
25
+
26
+ declare module '*.webp' {
27
+ const src: string;
28
+ export default src;
29
+ }
30
+
31
+ declare module '*.svg' {
32
+ /**
33
+ * Use `any` to avoid conflicts with
34
+ * `@svgr/webpack` plugin or
35
+ * `babel-plugin-inline-react-svg` plugin.
36
+ */
37
+ const content: any;
38
+ export default content;
39
+ }
40
+
41
+ declare module '*.css' {
42
+ const classes: { readonly [key: string]: string };
43
+ export default classes;
44
+ }
45
+
46
+ declare module '*.sass' {
47
+ const classes: { readonly [key: string]: string };
48
+ export default classes;
49
+ }
50
+
51
+ declare module '*.scss' {
52
+ const classes: { readonly [key: string]: string };
53
+ export default classes;
54
+ }
@@ -0,0 +1 @@
1
+ module.exports = {};
@@ -1,8 +1,8 @@
1
1
  /// <reference types="@shuvi/platform-shared/shuvi-type-extensions-runtime" />
2
2
 
3
3
  declare module '@shuvi/app/files/routes' {
4
- import { IRawPageRouteRecord } from '@shuvi/platform-shared/shared';
5
- declare const routes: IRawPageRouteRecord[];
4
+ import { IPageRouteRecord } from '@shuvi/platform-shared/shared';
5
+ declare const routes: IPageRouteRecord[];
6
6
  export default routes;
7
7
  }
8
8
 
@@ -1,5 +0,0 @@
1
- declare const _default: (options?: {}) => {
2
- subscribeToHmrEvent(handler: any): void;
3
- reportRuntimeError(err: any): void;
4
- };
5
- export default _default;
@@ -1,34 +0,0 @@
1
- import connect from '@shuvi/toolpack/lib/utils/hotDevClient';
2
- import { DEV_HOT_MIDDLEWARE_PATH, DEV_HOT_LAUNCH_EDITOR_ENDPOINT } from '@shuvi/shared/lib/constants';
3
- let devClient;
4
- export default (options = {}) => {
5
- if (devClient) {
6
- return devClient;
7
- }
8
- devClient = connect(Object.assign(Object.assign({}, options), { launchEditorEndpoint: DEV_HOT_LAUNCH_EDITOR_ENDPOINT, path: DEV_HOT_MIDDLEWARE_PATH, location,
9
- WebSocket }));
10
- devClient.subscribeToHmrEvent((event) => {
11
- // if (obj.action === "reloadPage") {
12
- // return window.location.reload();
13
- // }
14
- // if (obj.action === "removedPage") {
15
- // const [page] = obj.data;
16
- // if (page === window.next.router.pathname) {
17
- // return window.location.reload();
18
- // }
19
- // return;
20
- // }
21
- // if (obj.action === "addedPage") {
22
- // const [page] = obj.data;
23
- // if (
24
- // page === window.next.router.pathname &&
25
- // typeof window.next.router.components[page] === "undefined"
26
- // ) {
27
- // return window.location.reload();
28
- // }
29
- // return;
30
- // }
31
- // throw new Error("Unexpected action " + obj.action);
32
- });
33
- return devClient;
34
- };
@@ -1,2 +0,0 @@
1
- declare const _default: import("@shuvi/platform-shared/shared").IPluginInstance<import("@shuvi/platform-shared/shared").BuiltInRuntimePluginHooks & import("@shuvi/platform-shared/shared").CustomRuntimePluginHooks, void>;
2
- export default _default;
@@ -1,6 +0,0 @@
1
- import { IServerModule as _IServerModule } from '../shared';
2
- declare type ServerModule = Required<_IServerModule>;
3
- export declare type GetPageDataFunction = ServerModule['getPageData'];
4
- export declare type HandlePageRequestFunction = ServerModule['handlePageRequest'];
5
- export declare type ModifyHtmlFunction = ServerModule['modifyHtml'];
6
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { IPlatformContext, ResolvedPlugin } from '@shuvi/service/lib/core';
2
- /** This main plugin uses `platformContext` so that it is set to a plugin getter */
3
- export declare const getPlugin: (platformContext: IPlatformContext) => ResolvedPlugin;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getPlugin = void 0;
16
- const service_1 = require("@shuvi/service");
17
- const constants_1 = require("@shuvi/shared/lib/constants");
18
- const config_1 = require("@shuvi/toolpack/lib/webpack/config");
19
- const generateResource_1 = __importDefault(require("./generateResource"));
20
- const paths_1 = require("../../paths");
21
- const buildHtml_1 = require("./buildHtml");
22
- const middlewares_1 = require("../middlewares");
23
- function getServerEntry() {
24
- return {
25
- [service_1.BUILD_SERVER_FILE_SERVER]: [(0, paths_1.resolvePkgFile)('esm/shuvi-app/entry/server')]
26
- };
27
- }
28
- /** This main plugin uses `platformContext` so that it is set to a plugin getter */
29
- const getPlugin = (platformContext) => {
30
- const core = (0, service_1.createPlugin)({
31
- addExtraTarget: ({ createConfig }, context) => {
32
- const serverWebpackHelpers = (0, config_1.webpackHelpers)();
33
- const serverChain = createConfig({
34
- name: constants_1.BUNDLER_TARGET_SERVER,
35
- node: true,
36
- entry: getServerEntry(),
37
- outputDir: service_1.BUILD_SERVER_DIR,
38
- webpackHelpers: serverWebpackHelpers
39
- });
40
- return {
41
- name: constants_1.BUNDLER_TARGET_SERVER,
42
- chain: serverChain
43
- };
44
- },
45
- configWebpack: chain => {
46
- chain.merge({
47
- entry: {
48
- [service_1.BUILD_CLIENT_RUNTIME_POLYFILL]: ['@shuvi/app/core/polyfill'],
49
- [service_1.BUILD_CLIENT_RUNTIME_MAIN]: [
50
- (0, paths_1.resolvePkgFile)('esm/shuvi-app/entry/client')
51
- ]
52
- }
53
- });
54
- return chain;
55
- },
56
- addRuntimeService: () => [
57
- {
58
- source: (0, paths_1.resolvePkgFile)('esm/shuvi-app/shuvi-runtime-index'),
59
- exported: '*'
60
- },
61
- {
62
- source: (0, paths_1.resolvePkgFile)('esm/shuvi-app/shuvi-runtime-server'),
63
- filepath: 'server.ts',
64
- exported: '*'
65
- }
66
- ],
67
- addResource: context => (0, generateResource_1.default)(context),
68
- afterBuild: (context) => __awaiter(void 0, void 0, void 0, function* () {
69
- yield (0, buildHtml_1.buildHtml)({
70
- context,
71
- serverPlugins: platformContext.serverPlugins,
72
- getMiddlewares: middlewares_1.getMiddlewares,
73
- pathname: '/',
74
- filename: 'index.html'
75
- });
76
- })
77
- });
78
- return {
79
- core
80
- };
81
- };
82
- exports.getPlugin = getPlugin;
@@ -1,18 +0,0 @@
1
- export declare const RedoxReactPlugin: {
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>;
15
- runtime: {
16
- plugin: string;
17
- };
18
- };