@shuvi/platform-web 1.0.45 → 1.0.46

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.
@@ -13,9 +13,23 @@ export declare type RequestContext = {
13
13
  res: ServerResponse;
14
14
  };
15
15
  export declare type ISendHtml = (html: string, requestContext: RequestContext) => Promise<void>;
16
+ declare type AppConfigCtx = {
17
+ req: ShuviRequest;
18
+ };
19
+ export declare const getAppConfig: import("@shuvi/hook").SyncBailHook<void, AppConfigCtx, {
20
+ router: {
21
+ basename: string;
22
+ };
23
+ }>;
16
24
  export declare const extendedHooks: {
17
25
  getPageData: import("@shuvi/hook").AsyncParallelHook<void, IAppContext, Record<string, unknown>>;
26
+ getAppConfig: import("@shuvi/hook").SyncBailHook<void, AppConfigCtx, {
27
+ router: {
28
+ basename: string;
29
+ };
30
+ }>;
18
31
  handlePageRequest: import("@shuvi/hook").AsyncSeriesWaterfallHook<IHandlePageRequest, void>;
19
32
  modifyHtml: import("@shuvi/hook").AsyncSeriesHook<IHtmlDocument, ModifyHtmlContext, void>;
20
33
  sendHtml: import("@shuvi/hook").AsyncSeriesWaterfallHook<ISendHtml, void>;
21
34
  };
35
+ export {};
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extendedHooks = void 0;
3
+ exports.extendedHooks = exports.getAppConfig = void 0;
4
4
  const hook_1 = require("@shuvi/hook");
5
5
  const getPageData = (0, hook_1.createAsyncParallelHook)();
6
6
  const handlePageRequest = (0, hook_1.createAsyncSeriesWaterfallHook)();
7
7
  const modifyHtml = (0, hook_1.createAsyncSeriesHook)();
8
8
  const sendHtml = (0, hook_1.createAsyncSeriesWaterfallHook)();
9
+ exports.getAppConfig = (0, hook_1.createSyncBailHook)();
9
10
  exports.extendedHooks = {
10
11
  getPageData,
12
+ getAppConfig: exports.getAppConfig,
11
13
  handlePageRequest,
12
14
  modifyHtml,
13
15
  sendHtml
@@ -13,10 +13,12 @@ exports.getMiddlewaresBeforeDevMiddlewares = exports.getMiddlewares = void 0;
13
13
  const on_demand_compile_page_1 = require("./on-demand-compile-page");
14
14
  const filesystem_routes_1 = require("./filesystem-routes");
15
15
  const html_render_1 = require("./html-render");
16
+ const setup_app_config_1 = require("./setup-app-config");
16
17
  const getMiddlewares = (context) => __awaiter(void 0, void 0, void 0, function* () {
17
18
  return [
18
19
  (0, filesystem_routes_1.getMiddlewareMiddleware)(context),
19
20
  (0, filesystem_routes_1.getApiMiddleware)(context),
21
+ (0, setup_app_config_1.getSetupAppConfigMiddleware)(context),
20
22
  yield (0, html_render_1.getPageMiddleware)(context)
21
23
  ].filter(Boolean);
22
24
  });
@@ -0,0 +1,2 @@
1
+ import { IServerPluginContext, ShuviRequestHandler } from '@shuvi/service';
2
+ export declare const getSetupAppConfigMiddleware: (context: IServerPluginContext) => ShuviRequestHandler;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSetupAppConfigMiddleware = void 0;
4
+ const getSetupAppConfigMiddleware = (context) => {
5
+ return (req, _res, next) => {
6
+ const appConfig = context.serverPluginRunner.getAppConfig({ req });
7
+ if (appConfig) {
8
+ if (typeof appConfig.router.basename !== 'string') {
9
+ throw new Error('[ServerPlugin Hook getAppConfig] appConfig.router.basename must be a string');
10
+ }
11
+ context.appConfig = appConfig;
12
+ }
13
+ next();
14
+ };
15
+ };
16
+ exports.getSetupAppConfigMiddleware = getSetupAppConfigMiddleware;
@@ -6,6 +6,7 @@ declare global {
6
6
  namespace ShuviService {
7
7
  interface CustomServerPluginHooks {
8
8
  getPageData: typeof extendedHooks.getPageData;
9
+ getAppConfig: typeof extendedHooks.getAppConfig;
9
10
  handlePageRequest: typeof extendedHooks.handlePageRequest;
10
11
  modifyHtml: typeof extendedHooks.modifyHtml;
11
12
  sendHtml: typeof extendedHooks.sendHtml;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/platform-web",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -72,15 +72,15 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@next/react-refresh-utils": "12.1.6",
75
- "@shuvi/error-overlay": "1.0.45",
76
- "@shuvi/hook": "1.0.45",
77
- "@shuvi/platform-shared": "1.0.45",
78
- "@shuvi/router": "1.0.45",
79
- "@shuvi/router-react": "1.0.45",
80
- "@shuvi/runtime": "1.0.45",
81
- "@shuvi/shared": "1.0.45",
82
- "@shuvi/toolpack": "1.0.45",
83
- "@shuvi/utils": "1.0.45",
75
+ "@shuvi/error-overlay": "1.0.46",
76
+ "@shuvi/hook": "1.0.46",
77
+ "@shuvi/platform-shared": "1.0.46",
78
+ "@shuvi/router": "1.0.46",
79
+ "@shuvi/router-react": "1.0.46",
80
+ "@shuvi/runtime": "1.0.46",
81
+ "@shuvi/shared": "1.0.46",
82
+ "@shuvi/toolpack": "1.0.46",
83
+ "@shuvi/utils": "1.0.46",
84
84
  "content-type": "1.0.4",
85
85
  "core-js": "3.6.5",
86
86
  "doura": "0.0.13",
@@ -98,7 +98,7 @@
98
98
  "whatwg-fetch": "3.0.0"
99
99
  },
100
100
  "peerDependencies": {
101
- "@shuvi/service": "1.0.45"
101
+ "@shuvi/service": "1.0.46"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@shuvi/service": "workspace:*",