@shuvi/platform-web 1.0.55 → 1.0.56

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 (65) hide show
  1. package/esm/shared/appTypes.d.ts +2 -2
  2. package/esm/shared/htmlRenderer.d.ts +1 -1
  3. package/esm/shared/renderTypes.d.ts +3 -3
  4. package/esm/shared/routeTypes.d.ts +7 -7
  5. package/esm/shuvi-app/dev/hotDevClient.d.ts +1 -1
  6. package/esm/shuvi-app/dev/websocket.d.ts +1 -1
  7. package/esm/shuvi-app/entry/client/run.dev.d.ts +0 -1
  8. package/esm/shuvi-app/entry/client/run.prod.d.ts +0 -1
  9. package/esm/shuvi-app/react/Error.d.ts +0 -1
  10. package/esm/shuvi-app/react/ErrorBoundary.d.ts +2 -2
  11. package/esm/shuvi-app/react/ErrorPage.d.ts +0 -1
  12. package/esm/shuvi-app/react/Link.d.ts +0 -1
  13. package/esm/shuvi-app/react/dynamic.d.ts +7 -7
  14. package/esm/shuvi-app/react/head/side-effect.d.ts +2 -2
  15. package/esm/shuvi-app/react/head/types.d.ts +3 -4
  16. package/esm/shuvi-app/react/loadRouteComponent.d.ts +0 -1
  17. package/esm/shuvi-app/react/loadable/loadable-context.d.ts +1 -1
  18. package/esm/shuvi-app/react/loadable/loadable.d.ts +2 -2
  19. package/esm/shuvi-app/react/model/Wrapper.d.ts +0 -1
  20. package/esm/shuvi-app/react/store.d.ts +1 -2
  21. package/esm/shuvi-app/react/types.d.ts +3 -3
  22. package/esm/shuvi-app/react/utils/requestIdleCallback.d.ts +1 -1
  23. package/esm/shuvi-app/react/utils/useIntersection.d.ts +1 -2
  24. package/esm/shuvi-app/react/view/ReactView.client.jsx +1 -1
  25. package/esm/shuvi-app/react/view/ReactView.server.jsx +1 -1
  26. package/esm/shuvi-app/react/view/render.d.ts +1 -1
  27. package/lib/node/features/custom-server/index.d.ts +1 -1
  28. package/lib/node/features/custom-server/server.d.ts +1 -1
  29. package/lib/node/features/custom-server/server.js +2 -2
  30. package/lib/node/features/filesystem-routes/api/apiRouteHandler.js +7 -7
  31. package/lib/node/features/filesystem-routes/api/apiRoutes.js +3 -3
  32. package/lib/node/features/filesystem-routes/api/middleware.js +1 -2
  33. package/lib/node/features/filesystem-routes/index.d.ts +1 -1
  34. package/lib/node/features/filesystem-routes/index.js +1 -1
  35. package/lib/node/features/filesystem-routes/middleware/middleware.js +3 -4
  36. package/lib/node/features/filesystem-routes/middleware/routes.js +3 -4
  37. package/lib/node/features/filesystem-routes/page/EmptyPageComponent.js +1 -1
  38. package/lib/node/features/filesystem-routes/page/routes.js +3 -3
  39. package/lib/node/features/html-render/lib/buildHtml.d.ts +1 -1
  40. package/lib/node/features/html-render/lib/buildHtml.js +1 -1
  41. package/lib/node/features/html-render/lib/generateFilesByRoutId.js +1 -1
  42. package/lib/node/features/html-render/lib/getPageMiddleware.js +2 -3
  43. package/lib/node/features/html-render/lib/renderToHTML.js +3 -4
  44. package/lib/node/features/html-render/lib/renderer/base.d.ts +1 -1
  45. package/lib/node/features/html-render/lib/renderer/htmlTag.js +3 -4
  46. package/lib/node/features/html-render/lib/renderer/index.js +1 -1
  47. package/lib/node/features/html-render/lib/renderer/ssr.js +2 -2
  48. package/lib/node/features/html-render/lib/renderer/types.d.ts +2 -2
  49. package/lib/node/features/html-render/lib/viewTemplate.js +2 -3
  50. package/lib/node/features/html-render/server.d.ts +1 -1
  51. package/lib/node/features/html-render/serverHooks.d.ts +4 -5
  52. package/lib/node/features/middlewares.js +1 -1
  53. package/lib/node/features/model/index.d.ts +1 -1
  54. package/lib/node/features/on-demand-compile-page/emptyComponent.js +1 -1
  55. package/lib/node/features/on-demand-compile-page/index.d.ts +1 -1
  56. package/lib/node/shuvi-runtime-server.d.ts +9 -9
  57. package/lib/node/targets/react/bundler/index.d.ts +1 -1
  58. package/lib/node/targets/react/index.d.ts +2 -2
  59. package/lib/node/targets/react/model/index.d.ts +1 -1
  60. package/lib/node/version.js +1 -2
  61. package/lib/shared/appTypes.d.ts +2 -2
  62. package/lib/shared/htmlRenderer.d.ts +1 -1
  63. package/lib/shared/renderTypes.d.ts +3 -3
  64. package/lib/shared/routeTypes.d.ts +7 -7
  65. package/package.json +11 -11
@@ -4,8 +4,8 @@ import type { ShuviRequest } from '@shuvi/service';
4
4
  export interface AppConfig {
5
5
  ssr: boolean;
6
6
  }
7
- export declare type InternalApplication = _ApplicationImpl<AppConfig>;
8
- export declare type Application = _Application<AppConfig>;
7
+ export type InternalApplication = _ApplicationImpl<AppConfig>;
8
+ export type Application = _Application<AppConfig>;
9
9
  export interface CreateAppServer {
10
10
  (options: {
11
11
  req: ShuviRequest;
@@ -6,7 +6,7 @@ export interface IModule {
6
6
  files: string[];
7
7
  children: IModuleItem[];
8
8
  }
9
- export declare type IAssetMap = {
9
+ export type IAssetMap = {
10
10
  js: string[];
11
11
  css?: string[];
12
12
  } & {
@@ -2,7 +2,7 @@ import type { ShuviRequest } from '@shuvi/service';
2
2
  import { Response, IAppData } from '@shuvi/platform-shared/shared';
3
3
  import { IManifest } from '../shared';
4
4
  import { Application } from './appTypes';
5
- export declare type IRenderViewOptions = {
5
+ export type IRenderViewOptions = {
6
6
  app: Application;
7
7
  };
8
8
  export interface IRenderOptions extends IRenderViewOptions {
@@ -10,7 +10,7 @@ export interface IRenderOptions extends IRenderViewOptions {
10
10
  export interface IView<RenderOption extends IRenderOptions = any, RenderResult = void> {
11
11
  renderApp(options: RenderOption): RenderResult;
12
12
  }
13
- export declare type IHtmlAttrs = {
13
+ export type IHtmlAttrs = {
14
14
  textContent?: string;
15
15
  } & {
16
16
  [x: string]: string | number | undefined | boolean;
@@ -20,7 +20,7 @@ export interface IHtmlTag<TagNames = string> {
20
20
  attrs: IHtmlAttrs;
21
21
  innerHTML?: string;
22
22
  }
23
- export declare type IRenderAppServerResult<ExtraAppData = {}> = {
23
+ export type IRenderAppServerResult<ExtraAppData = {}> = {
24
24
  htmlAttrs?: IHtmlAttrs;
25
25
  headBeginTags?: IHtmlTag[];
26
26
  headEndTags?: IHtmlTag[];
@@ -4,17 +4,17 @@ export interface IApiReq {
4
4
  [key: string]: any;
5
5
  };
6
6
  }
7
- export declare type IApiRequest = ShuviRequest & IApiReq;
8
- export declare type Send<T> = (body: T) => void;
9
- export declare type IApiRes<T = any> = {
7
+ export type IApiRequest = ShuviRequest & IApiReq;
8
+ export type Send<T> = (body: T) => void;
9
+ export type IApiRes<T = any> = {
10
10
  send: Send<T>;
11
11
  json: Send<T>;
12
12
  status: (statusCode: number) => IApiRes<T>;
13
13
  redirect(url: string): IApiRes<T>;
14
14
  redirect(status: number, url: string): IApiRes<T>;
15
15
  };
16
- export declare type IApiResponse<T = any> = ShuviResponse & IApiRes<T>;
17
- export declare type IApiRequestHandler<T = any> = (req: IApiRequest, res: IApiResponse<T>) => void | Promise<void>;
16
+ export type IApiResponse<T = any> = ShuviResponse & IApiRes<T>;
17
+ export type IApiRequestHandler<T = any> = (req: IApiRequest, res: IApiResponse<T>) => void | Promise<void>;
18
18
  export interface IApiConfig {
19
19
  api?: {
20
20
  bodyParser?: {
@@ -29,11 +29,11 @@ export interface IApiHandler {
29
29
  export interface IMiddlewareConfig {
30
30
  default: ShuviRequestHandler;
31
31
  }
32
- export declare type IApiRoutes = {
32
+ export type IApiRoutes = {
33
33
  path: string;
34
34
  api: IApiHandler;
35
35
  }[];
36
- export declare type IMiddlewareRoutes = {
36
+ export type IMiddlewareRoutes = {
37
37
  path: string;
38
38
  middleware: IMiddlewareConfig;
39
39
  }[];
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  SOFTWARE.
23
23
  */
24
- export declare type HotDevClient = {
24
+ export type HotDevClient = {
25
25
  sendMessage: (data: any) => void;
26
26
  subscribeToHmrEvent: (handler: any) => void;
27
27
  };
@@ -1,6 +1,6 @@
1
1
  export declare function addMessageListener(cb: (event: any) => void): void;
2
2
  export declare function sendMessage(data: any): any;
3
- export declare type HotDevClient = {
3
+ export type HotDevClient = {
4
4
  sendMessage: (data: any) => void;
5
5
  subscribeToHmrEvent?: (handler: any) => void;
6
6
  };
@@ -1,2 +1 @@
1
- /// <reference lib="dom" />
2
1
  export {};
@@ -1,2 +1 @@
1
- /// <reference lib="dom" />
2
1
  export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export default function Error({ errorCode, errorDesc }: {
3
2
  errorCode?: number;
4
3
  errorDesc?: string;
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
- declare type ErrorBoundaryState = {
3
+ type ErrorBoundaryState = {
4
4
  error: Error | null;
5
5
  };
6
- declare type ErrorInfo = {
6
+ type ErrorInfo = {
7
7
  componentStack?: string | null;
8
8
  };
9
9
  declare class ErrorBoundary extends React.PureComponent<PropsWithChildren<{}>, ErrorBoundaryState> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export default function ErrorPage({ code, message, error }: {
3
2
  code?: number;
4
3
  message?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { LinkProps } from '@shuvi/router-react';
3
2
  export declare const Link: ({ to, ref, prefetch, onMouseEnter, ...rest }: LinkWrapperProps) => JSX.Element;
4
3
  interface LinkWrapperProps extends LinkProps {
@@ -1,13 +1,13 @@
1
1
  import * as React from 'react';
2
- export declare type LoaderComponent<P = {}> = Promise<React.ComponentType<P> | {
2
+ export type LoaderComponent<P = {}> = Promise<React.ComponentType<P> | {
3
3
  default: React.ComponentType<P>;
4
4
  }>;
5
- export declare type Loader<P = {}> = () => LoaderComponent<P>;
6
- export declare type LoadableGeneratedOptions = {
5
+ export type Loader<P = {}> = () => LoaderComponent<P>;
6
+ export type LoadableGeneratedOptions = {
7
7
  webpack?(): string[];
8
8
  modules?: string[];
9
9
  };
10
- export declare type LoadableBaseOptions<P = {}> = LoadableGeneratedOptions & {
10
+ export type LoadableBaseOptions<P = {}> = LoadableGeneratedOptions & {
11
11
  loading?: ({ error, isLoading, pastDelay }: {
12
12
  error?: Error | null;
13
13
  isLoading?: boolean;
@@ -17,9 +17,9 @@ export declare type LoadableBaseOptions<P = {}> = LoadableGeneratedOptions & {
17
17
  loader?: Loader<P>;
18
18
  ssr?: boolean;
19
19
  };
20
- export declare type DynamicOptions<P = {}> = LoadableBaseOptions<P>;
21
- export declare type LoaderFn<P = {}> = (opts: DynamicOptions<P>) => React.ComponentType<P>;
22
- export declare type LoadableComponent<P = {}> = React.ComponentType<P>;
20
+ export type DynamicOptions<P = {}> = LoadableBaseOptions<P>;
21
+ export type LoaderFn<P = {}> = (opts: DynamicOptions<P>) => React.ComponentType<P>;
22
+ export type LoadableComponent<P = {}> = React.ComponentType<P>;
23
23
  export declare function noSSR<P = {}>(LoadableInitializer: LoaderFn<P>, dynamicOptions: DynamicOptions<P>): React.ComponentType<P> | (() => JSX.Element);
24
24
  /**
25
25
  * ES2020 [dynamic import()](https://github.com/tc39/proposal-dynamic-import) for JavaScript
@@ -7,7 +7,7 @@ declare const _default: () => {
7
7
  componentWillUnmount(): void;
8
8
  render(): React.ReactNode;
9
9
  context: unknown;
10
- setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<React.PropsWithChildren<SideEffectProps>>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
10
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<React.PropsWithChildren<SideEffectProps>>) => (Pick<{}, K> | {} | null)) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
11
11
  forceUpdate(callback?: (() => void) | undefined): void;
12
12
  readonly props: Readonly<React.PropsWithChildren<SideEffectProps>>;
13
13
  state: Readonly<{}>;
@@ -16,7 +16,7 @@ declare const _default: () => {
16
16
  };
17
17
  shouldComponentUpdate?(nextProps: Readonly<React.PropsWithChildren<SideEffectProps>>, nextState: Readonly<{}>, nextContext: any): boolean;
18
18
  componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
19
- getSnapshotBeforeUpdate?(prevProps: Readonly<React.PropsWithChildren<SideEffectProps>>, prevState: Readonly<{}>): any;
19
+ getSnapshotBeforeUpdate?(prevProps: Readonly<React.PropsWithChildren<SideEffectProps>>, prevState: Readonly<{}>): any | null;
20
20
  componentWillMount?(): void;
21
21
  UNSAFE_componentWillMount?(): void;
22
22
  componentWillReceiveProps?(nextProps: Readonly<React.PropsWithChildren<SideEffectProps>>, nextContext: any): void;
@@ -1,6 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { IHtmlTag } from '../types';
3
- export declare type SideEffectProps = {
2
+ export type SideEffectProps = {
4
3
  reduceComponentsToState: <T>(components: Array<React.ReactElement<any>>, props: T) => HeadState;
5
4
  handleStateChange?: (state: HeadState) => void;
6
5
  };
@@ -11,5 +10,5 @@ export interface HeadElement {
11
10
  children?: string | string[];
12
11
  };
13
12
  }
14
- export declare type HeadState = IHtmlTag[];
15
- export declare type HeadItem = IHtmlTag;
13
+ export type HeadState = IHtmlTag[];
14
+ export type HeadItem = IHtmlTag;
@@ -1,4 +1,3 @@
1
- /// <reference lib="dom" />
2
1
  import * as React from 'react';
3
2
  import { DynamicOptions } from './dynamic';
4
3
  export declare function loadRouteComponent(loader: () => Promise<any>, options?: DynamicOptions<any>): React.ComponentType;
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
- declare type CaptureFn = (moduleName: string) => void;
2
+ type CaptureFn = (moduleName: string) => void;
3
3
  export declare const LoadableContext: React.Context<CaptureFn | null>;
4
4
  export {};
@@ -19,10 +19,10 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
19
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
20
20
  */
21
21
  import * as React from 'react';
22
- declare type Options = any;
22
+ type Options = any;
23
23
  declare function Loadable<P>(opts: Options): React.ComponentType<P>;
24
24
  declare namespace Loadable {
25
25
  var preloadAll: () => Promise<void>;
26
- var preloadReady: (ids?: (string | number)[]) => Promise<void>;
26
+ var preloadReady: (ids?: Array<string | number>) => Promise<void>;
27
27
  }
28
28
  export default Loadable;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Doura } from 'doura';
3
2
  export declare const DouraWrapper: (App: any, appContext: {
4
3
  store: Doura;
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
1
  declare const Provider: (props: import("react").PropsWithChildren<{
3
- store?: import("doura").Doura | undefined;
2
+ store?: import("doura").Doura;
4
3
  }>) => JSX.Element, useSharedModel: import("react-doura").UseNamedModel, useStaticModel: import("react-doura").UseStaticModel;
5
4
  export { Provider, useSharedModel, useStaticModel };
@@ -1,7 +1,7 @@
1
1
  import { IHtmlTag, IViewClient, IViewServer } from '../../shared';
2
2
  export { IHtmlTag };
3
- export declare type IReactAppData = {
3
+ export type IReactAppData = {
4
4
  dynamicIds?: Array<string | number>;
5
5
  };
6
- export declare type IReactServerView = IViewServer<IReactAppData>;
7
- export declare type IReactClientView = IViewClient<IReactAppData>;
6
+ export type IReactServerView = IViewServer<IReactAppData>;
7
+ export type IReactClientView = IViewClient<IReactAppData>;
@@ -1,2 +1,2 @@
1
- export declare const requestIdleCallback: ((callback: IdleRequestCallback, options?: IdleRequestOptions | undefined) => number) & typeof globalThis.requestIdleCallback;
1
+ export declare const requestIdleCallback: ((callback: IdleRequestCallback, options?: IdleRequestOptions) => number) & typeof globalThis.requestIdleCallback;
2
2
  export declare const cancelIdleCallback: ((handle: number) => void) & typeof globalThis.cancelIdleCallback;
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
- declare type UseIntersection = {
1
+ type UseIntersection = {
3
2
  rootRef?: React.RefObject<HTMLElement>;
4
3
  rootMargin?: string;
5
4
  disabled?: boolean;
@@ -20,7 +20,7 @@ const headManager = new HeadManager();
20
20
  export class ReactClientView {
21
21
  constructor() {
22
22
  this._isInitialRender = true;
23
- this.renderApp = ({ appContainer, app, appData }) => __awaiter(this, void 0, void 0, function* () {
23
+ this.renderApp = (_a) => __awaiter(this, [_a], void 0, function* ({ appContainer, app, appData }) {
24
24
  const { _isInitialRender: isInitialRender } = this;
25
25
  const { router, appComponent: AppComponent, setError: setAppError, error: appError } = app;
26
26
  let { ssr, dynamicIds } = appData;
@@ -22,7 +22,7 @@ import isThirdSite from '../../helper/isThirdSite';
22
22
  const { SHUVI_SERVER_RENDER_TO_STRING } = SERVER_REQUEST.events;
23
23
  export class ReactServerView {
24
24
  constructor() {
25
- this.renderApp = ({ req, app, manifest }) => __awaiter(this, void 0, void 0, function* () {
25
+ this.renderApp = (_a) => __awaiter(this, [_a], void 0, function* ({ req, app, manifest }) {
26
26
  yield Loadable.preloadAll();
27
27
  const { router, appComponent: AppComponent, setError: setAppError } = app;
28
28
  yield router.ready;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- declare type RenderActionParam = {
2
+ type RenderActionParam = {
3
3
  appContainer: Element | Document;
4
4
  root?: ReactNode;
5
5
  shouldHydrate?: boolean;
@@ -1,4 +1,4 @@
1
1
  declare const _default: {
2
- server: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/server/plugin").ServerPluginHooks, import("@shuvi/service").IServerPluginContext>;
2
+ server: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/server").ServerPluginHooks, import("@shuvi/service").IServerPluginContext>;
3
3
  };
4
4
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/server/plugin").ServerPluginHooks, import("@shuvi/service").IServerPluginContext>;
1
+ declare const _default: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/server").ServerPluginHooks, import("@shuvi/service").IServerPluginContext>;
2
2
  export default _default;
@@ -35,8 +35,8 @@ exports.default = (0, service_1.createServerPlugin)({
35
35
  yield ((_c = (_b = (_a = resources_1.default.server) === null || _a === void 0 ? void 0 : _a.server) === null || _b === void 0 ? void 0 : _b.modifyHtml) === null || _c === void 0 ? void 0 : _c.call(_b, document, context));
36
36
  }),
37
37
  sendHtml: (originalSendHtml) => __awaiter(void 0, void 0, void 0, function* () {
38
- var _d, _e;
39
- return (((_e = (_d = resources_1.default.server.server) === null || _d === void 0 ? void 0 : _d.sendHtml) === null || _e === void 0 ? void 0 : _e.call(_d, originalSendHtml)) ||
38
+ var _a, _b;
39
+ return (((_b = (_a = resources_1.default.server.server) === null || _a === void 0 ? void 0 : _a.sendHtml) === null || _b === void 0 ? void 0 : _b.call(_a, originalSendHtml)) ||
40
40
  originalSendHtml);
41
41
  })
42
42
  }, {
@@ -35,7 +35,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.ApiError = exports.sendJson = exports.sendData = exports.redirect = exports.sendStatusCode = exports.parseBody = exports.apiRouteHandler = void 0;
38
+ exports.ApiError = void 0;
39
+ exports.apiRouteHandler = apiRouteHandler;
40
+ exports.parseBody = parseBody;
41
+ exports.sendStatusCode = sendStatusCode;
42
+ exports.redirect = redirect;
43
+ exports.sendData = sendData;
44
+ exports.sendJson = sendJson;
39
45
  const stream_1 = require("stream");
40
46
  const querystring = __importStar(require("querystring"));
41
47
  const raw_body_1 = __importDefault(require("raw-body"));
@@ -74,7 +80,6 @@ function apiRouteHandler(req, res, resolver, apiRoutesConfig) {
74
80
  }
75
81
  });
76
82
  }
77
- exports.apiRouteHandler = apiRouteHandler;
78
83
  /**
79
84
  * Parse incoming message like `json` or `urlencoded`
80
85
  * @param req request object
@@ -114,7 +119,6 @@ function parseBody(req, limit) {
114
119
  }
115
120
  });
116
121
  }
117
- exports.parseBody = parseBody;
118
122
  /**
119
123
  * Parse `JSON` and handles invalid `JSON` strings
120
124
  * @param str `JSON` string
@@ -140,7 +144,6 @@ function sendStatusCode(res, statusCode) {
140
144
  res.statusCode = statusCode;
141
145
  return res;
142
146
  }
143
- exports.sendStatusCode = sendStatusCode;
144
147
  /**
145
148
  *
146
149
  * @param res response object
@@ -160,7 +163,6 @@ function redirect(res, statusOrUrl, url) {
160
163
  res.end();
161
164
  return res;
162
165
  }
163
- exports.redirect = redirect;
164
166
  /**
165
167
  * Send `any` body to response
166
168
  * @param req request object
@@ -196,7 +198,6 @@ function sendData(req, res, body) {
196
198
  res.setHeader('Content-Length', Buffer.byteLength(stringifiedBody));
197
199
  res.end(stringifiedBody);
198
200
  }
199
- exports.sendData = sendData;
200
201
  /**
201
202
  * Send `JSON` object
202
203
  * @param res response object
@@ -208,7 +209,6 @@ function sendJson(req, res, jsonBody) {
208
209
  // Use send to handle request
209
210
  return sendData(req, res, jsonBody);
210
211
  }
211
- exports.sendJson = sendJson;
212
212
  /**
213
213
  * Custom error class
214
214
  */
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateRoutesContent = exports.normalizeApiRoutes = exports.serializeApiRoutes = void 0;
3
+ exports.generateRoutesContent = void 0;
4
+ exports.serializeApiRoutes = serializeApiRoutes;
5
+ exports.normalizeApiRoutes = normalizeApiRoutes;
4
6
  const file_1 = require("@shuvi/utils/file");
5
7
  function serializeApiRoutes(apiRoutes) {
6
8
  let res = '';
@@ -14,7 +16,6 @@ function serializeApiRoutes(apiRoutes) {
14
16
  }
15
17
  return `[${res}]`;
16
18
  }
17
- exports.serializeApiRoutes = serializeApiRoutes;
18
19
  function normalizeApiRoutes(apiRoutes, option) {
19
20
  const res = [];
20
21
  for (let index = 0; index < apiRoutes.length; index++) {
@@ -26,7 +27,6 @@ function normalizeApiRoutes(apiRoutes, option) {
26
27
  }
27
28
  return res;
28
29
  }
29
- exports.normalizeApiRoutes = normalizeApiRoutes;
30
30
  const generateRoutesContent = (apiRoutes, apisDir) => {
31
31
  const normalizedRoutes = normalizeApiRoutes(apiRoutes, { apisDir });
32
32
  const serialized = serializeApiRoutes(normalizedRoutes);
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.middleware = void 0;
15
+ exports.middleware = middleware;
16
16
  const router_1 = require("@shuvi/router");
17
17
  const resources_1 = __importDefault(require("@shuvi/service/lib/resources"));
18
18
  const trace_1 = require("@shuvi/shared/constants/trace");
@@ -60,4 +60,3 @@ function middleware(_ctx) {
60
60
  });
61
61
  };
62
62
  }
63
- exports.middleware = middleware;
@@ -3,6 +3,6 @@ import { middleware as getMiddlewareMiddleware } from './middleware';
3
3
  import { IApiRequestHandler, middleware as getApiMiddleware } from './api';
4
4
  export { IApiRequestHandler, getRoutes, getMiddlewareMiddleware, getApiMiddleware };
5
5
  declare const _default: {
6
- core: import("@shuvi/platform-shared/shared").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
6
+ core: import("@shuvi/platform-shared/shared").IPluginInstance<import("@shuvi/service/lib/core").PluginHooks, import("@shuvi/service").IPluginContext>;
7
7
  };
8
8
  export default _default;
@@ -30,7 +30,7 @@ const plugin = (0, service_1.createPlugin)({
30
30
  setup: ({ addHooks }) => {
31
31
  addHooks({ addRoutes: hooks_1.addRoutes, addApiRoutes: hooks_1.addApiRoutes, addMiddlewareRoutes: hooks_1.addMiddlewareRoutes });
32
32
  },
33
- addRuntimeFile: ({ defineFile, getContent }, context) => __awaiter(void 0, void 0, void 0, function* () {
33
+ addRuntimeFile: (_a, context_1) => __awaiter(void 0, [_a, context_1], void 0, function* ({ defineFile, getContent }, context) {
34
34
  const { config: { routes: pageRoutes, conventionRoutes }, paths, pluginRunner, phase, mode } = context;
35
35
  const isBuildPhase = phase === 'PHASE_PRODUCTION_BUILD';
36
36
  const rawRoutes = defineFile({
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.middleware = void 0;
15
+ exports.middleware = middleware;
16
16
  const router_1 = require("@shuvi/router");
17
17
  const resources_1 = __importDefault(require("@shuvi/service/lib/resources"));
18
18
  const trace_1 = require("@shuvi/service/lib/trace");
@@ -58,7 +58,7 @@ function middleware(_api) {
58
58
  /** Catch error from single middleware */
59
59
  middlewareRoutesTrace.setAttributes({
60
60
  [SHUVI_SERVER_RUN_MIDDLEWARE_ROUTES.attrs.error.name]: true,
61
- [SHUVI_SERVER_RUN_MIDDLEWARE_ROUTES.attrs.statusCode.name]: 500,
61
+ [SHUVI_SERVER_RUN_MIDDLEWARE_ROUTES.attrs.statusCode.name]: 500, // status code should be 500
62
62
  [SHUVI_SERVER_RUN_MIDDLEWARE_ROUTES.attrs.headersSent.name]: res.headersSent
63
63
  });
64
64
  middlewareRoutesTrace.stop();
@@ -81,7 +81,7 @@ function middleware(_api) {
81
81
  /** Catch error from the whole function */
82
82
  middlewareRoutesTrace.setAttributes({
83
83
  [SHUVI_SERVER_RUN_MIDDLEWARE_ROUTES.attrs.error.name]: true,
84
- [SHUVI_SERVER_RUN_MIDDLEWARE_ROUTES.attrs.statusCode.name]: 500,
84
+ [SHUVI_SERVER_RUN_MIDDLEWARE_ROUTES.attrs.statusCode.name]: 500, // status code should be 500
85
85
  [SHUVI_SERVER_RUN_MIDDLEWARE_ROUTES.attrs.headersSent.name]: res.headersSent
86
86
  });
87
87
  middlewareRoutesTrace.stop();
@@ -90,4 +90,3 @@ function middleware(_api) {
90
90
  });
91
91
  };
92
92
  }
93
- exports.middleware = middleware;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateRoutesContent = exports.serializeMiddlewareRoutes = exports.normalizeMiddlewareRoutes = void 0;
3
+ exports.normalizeMiddlewareRoutes = normalizeMiddlewareRoutes;
4
+ exports.serializeMiddlewareRoutes = serializeMiddlewareRoutes;
5
+ exports.generateRoutesContent = generateRoutesContent;
4
6
  const file_1 = require("@shuvi/utils/file");
5
7
  function normalizeMiddlewareRoutes(middlewareRoutes, option) {
6
8
  const res = [];
@@ -13,7 +15,6 @@ function normalizeMiddlewareRoutes(middlewareRoutes, option) {
13
15
  }
14
16
  return res;
15
17
  }
16
- exports.normalizeMiddlewareRoutes = normalizeMiddlewareRoutes;
17
18
  function serializeMiddlewareRoutes(middlewareRoutes) {
18
19
  let res = '';
19
20
  for (let index = 0; index < middlewareRoutes.length; index++) {
@@ -26,9 +27,7 @@ function serializeMiddlewareRoutes(middlewareRoutes) {
26
27
  }
27
28
  return `[${res}]`;
28
29
  }
29
- exports.serializeMiddlewareRoutes = serializeMiddlewareRoutes;
30
30
  function generateRoutesContent(rawRoutes, { baseDir }) {
31
31
  const serialized = serializeMiddlewareRoutes(normalizeMiddlewareRoutes(rawRoutes, { baseDir }));
32
32
  return `export default ${serialized}`;
33
33
  }
34
- exports.generateRoutesContent = generateRoutesContent;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = Page;
3
4
  function Page() {
4
5
  return null;
5
6
  }
6
- exports.default = Page;
@@ -14,7 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.generateRoutesContent = exports.normalizeRoutes = exports.serializeRoutes = void 0;
17
+ exports.generateRoutesContent = void 0;
18
+ exports.serializeRoutes = serializeRoutes;
19
+ exports.normalizeRoutes = normalizeRoutes;
18
20
  const crypto_1 = require("crypto");
19
21
  const path_1 = __importDefault(require("path"));
20
22
  const constants_1 = require("@shuvi/shared/constants");
@@ -71,7 +73,6 @@ __resolveWeak__: () => [require.resolveWeak("${componentRequest}")]`.trim();
71
73
  }
72
74
  return `[${res}]`;
73
75
  }
74
- exports.serializeRoutes = serializeRoutes;
75
76
  function normalizeRoutes(routes, componentDir, parentPath = '') {
76
77
  const res = [];
77
78
  for (let index = 0; index < routes.length; index++) {
@@ -90,7 +91,6 @@ function normalizeRoutes(routes, componentDir, parentPath = '') {
90
91
  }
91
92
  return res;
92
93
  }
93
- exports.normalizeRoutes = normalizeRoutes;
94
94
  const generateRoutesContent = (routes, { dev, ssr }) => {
95
95
  const serverRoutes = serializeRoutes(routes, {
96
96
  includeMeta: true,
@@ -2,7 +2,7 @@ import { IPlatformContent, IPluginContext, ServerPluginInstance } from '@shuvi/s
2
2
  export declare const buildHtml: ({ context, serverPlugins, getMiddlewares, pathname, filename }: {
3
3
  context: IPluginContext;
4
4
  serverPlugins: ServerPluginInstance[];
5
- getMiddlewares: IPlatformContent['getMiddlewares'];
5
+ getMiddlewares: IPlatformContent["getMiddlewares"];
6
6
  pathname: string;
7
7
  filename: string;
8
8
  }) => Promise<void>;
@@ -39,7 +39,7 @@ const node_mocks_http_1 = require("node-mocks-http");
39
39
  const path = __importStar(require("path"));
40
40
  const service_1 = require("@shuvi/service");
41
41
  const shared_1 = require("../../../../shared");
42
- const buildHtml = ({ context, serverPlugins, getMiddlewares, pathname, filename }) => __awaiter(void 0, void 0, void 0, function* () {
42
+ const buildHtml = (_a) => __awaiter(void 0, [_a], void 0, function* ({ context, serverPlugins, getMiddlewares, pathname, filename }) {
43
43
  return new Promise(resolve => {
44
44
  const request = (0, node_mocks_http_1.createRequest)({
45
45
  url: pathname
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = generateFilesByRoutId;
3
4
  function generateFilesByRoutId(assetMap, routes) {
4
5
  let filesByRoutId = {};
5
6
  const processRoute = (route) => {
@@ -16,4 +17,3 @@ function generateFilesByRoutId(assetMap, routes) {
16
17
  routes.forEach(processRoute);
17
18
  return filesByRoutId;
18
19
  }
19
- exports.default = generateFilesByRoutId;
@@ -9,14 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getPageMiddleware = void 0;
12
+ exports.getPageMiddleware = getPageMiddleware;
13
13
  const utils_1 = require("@shuvi/service/lib/server/utils");
14
14
  const shared_1 = require("@shuvi/platform-shared/shared");
15
15
  const trace_1 = require("@shuvi/shared/constants/trace");
16
16
  const renderToHTML_1 = require("./renderToHTML");
17
17
  const { SHUVI_SERVER_SEND_HTML_ORIGINAL, SHUVI_SERVER_SEND_HTML_HOOK, SHUVI_SERVER_RENDER_TO_HTML, SHUVI_SERVER_RUN_PAGE_MIDDLEWARE } = trace_1.SERVER_REQUEST.events;
18
18
  function createPageHandler(serverPluginContext) {
19
- const wrappedSendHtml = (html, { req, res }) => __awaiter(this, void 0, void 0, function* () {
19
+ const wrappedSendHtml = (html_1, _a) => __awaiter(this, [html_1, _a], void 0, function* (html, { req, res }) {
20
20
  const { serverRequestTrace } = req._traces;
21
21
  const sendHtmlOriginalTrace = serverRequestTrace.traceChild(SHUVI_SERVER_SEND_HTML_ORIGINAL.name, { [SHUVI_SERVER_SEND_HTML_ORIGINAL.attrs.requestId.name]: req._requestId });
22
22
  (0, utils_1.sendHTML)(req, res, html);
@@ -108,4 +108,3 @@ function getPageMiddleware(api) {
108
108
  };
109
109
  });
110
110
  }
111
- exports.getPageMiddleware = getPageMiddleware;
@@ -12,12 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.renderToHTML = void 0;
15
+ exports.renderToHTML = renderToHTML;
16
16
  const resources_1 = __importDefault(require("@shuvi/service/lib/resources"));
17
17
  const trace_1 = require("@shuvi/shared/constants/trace");
18
18
  const renderer_1 = require("./renderer");
19
- function renderToHTML({ req, serverPluginContext }) {
20
- return __awaiter(this, void 0, void 0, function* () {
19
+ function renderToHTML(_a) {
20
+ return __awaiter(this, arguments, void 0, function* ({ req, serverPluginContext }) {
21
21
  let result;
22
22
  const renderer = new renderer_1.Renderer({ serverPluginContext });
23
23
  const { config: { ssr }, appConfig: { router: { basename } } } = serverPluginContext;
@@ -50,4 +50,3 @@ function renderToHTML({ req, serverPluginContext }) {
50
50
  return result;
51
51
  });
52
52
  }
53
- exports.renderToHTML = renderToHTML;
@@ -1,7 +1,7 @@
1
1
  import { IAppData } from '@shuvi/platform-shared/shared';
2
2
  import { ShuviRequest, IServerPluginContext } from '@shuvi/service';
3
3
  import { IHtmlTag, Application, IRendererConstructorOptions, IRenderViewOptions, IRenderDocumentResult } from './types';
4
- export declare type AppData = Omit<IAppData, 'filesByRoutId' | 'publicPath'>;
4
+ export type AppData = Omit<IAppData, 'filesByRoutId' | 'publicPath'>;
5
5
  export declare abstract class BaseRenderer {
6
6
  protected _serverPluginContext: IServerPluginContext;
7
7
  protected _app?: Application;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tag = exports.stringifyTag = exports.stringifyAttrs = void 0;
3
+ exports.stringifyAttrs = stringifyAttrs;
4
+ exports.stringifyTag = stringifyTag;
5
+ exports.tag = tag;
4
6
  const htmlescape_1 = require("@shuvi/utils/htmlescape");
5
7
  /**
6
8
  * All html tag elements which must not contain innerHTML
@@ -44,7 +46,6 @@ function stringifyAttrs(attrs) {
44
46
  }
45
47
  return res.join(' ');
46
48
  }
47
- exports.stringifyAttrs = stringifyAttrs;
48
49
  function stringifyTag(tag) {
49
50
  const attr = stringifyAttrs(tag.attrs);
50
51
  const voidTag = voidTags.indexOf(tag.tagName) !== -1;
@@ -59,7 +60,6 @@ function stringifyTag(tag) {
59
60
  res += '</' + tag.tagName + '>';
60
61
  return res;
61
62
  }
62
- exports.stringifyTag = stringifyTag;
63
63
  function tag(tagName, attrs, innerHTML) {
64
64
  return {
65
65
  tagName: tagName,
@@ -67,4 +67,3 @@ function tag(tagName, attrs, innerHTML) {
67
67
  innerHTML
68
68
  };
69
69
  }
70
- exports.tag = tag;
@@ -72,8 +72,8 @@ class Renderer {
72
72
  this._spaRenderer = new spa_1.SpaRenderer(options);
73
73
  }
74
74
  renderView(options) {
75
- var _a, _b;
76
75
  return __awaiter(this, void 0, void 0, function* () {
76
+ var _a, _b;
77
77
  let result;
78
78
  const { app, req } = options;
79
79
  const doc = yield this._renderDocument(options);
@@ -18,8 +18,8 @@ const shuvi_singleton_runtimeConfig_1 = require("@shuvi/platform-shared/shared/s
18
18
  const resources_1 = __importDefault(require("@shuvi/service/lib/resources"));
19
19
  const base_1 = require("./base");
20
20
  class SsrRenderer extends base_1.BaseRenderer {
21
- renderDocument({ app, req }) {
22
- return __awaiter(this, void 0, void 0, function* () {
21
+ renderDocument(_a) {
22
+ return __awaiter(this, arguments, void 0, function* ({ app, req }) {
23
23
  const { store, router, context } = app;
24
24
  const serverPluginContext = this._serverPluginContext;
25
25
  const { view } = resources_1.default.server;
@@ -5,12 +5,12 @@ export { IHtmlAttrs, IHtmlTag, Application };
5
5
  export interface IRendererConstructorOptions {
6
6
  serverPluginContext: IServerPluginContext;
7
7
  }
8
- export declare type IRenderViewOptions = {
8
+ export type IRenderViewOptions = {
9
9
  app: Application;
10
10
  req: ShuviRequest;
11
11
  ssr: boolean;
12
12
  };
13
- export declare type IRenderDocumentResult = Promise<IHtmlDocument | Response> | IHtmlDocument | Response;
13
+ export type IRenderDocumentResult = Promise<IHtmlDocument | Response> | IHtmlDocument | Response;
14
14
  export interface IHtmlDocument {
15
15
  htmlAttrs: IHtmlAttrs;
16
16
  headTags: IHtmlTag<'meta' | 'link' | 'style' | 'script' | 'noscript' | 'title'>[];
@@ -23,15 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.renderTemplate = exports.parseTemplateFile = void 0;
26
+ exports.parseTemplateFile = parseTemplateFile;
27
+ exports.renderTemplate = renderTemplate;
27
28
  const ejs = __importStar(require("ejs"));
28
29
  const fs = __importStar(require("fs"));
29
30
  function parseTemplateFile(templateFile) {
30
31
  const content = fs.readFileSync(templateFile, 'utf8');
31
32
  return ejs.compile(content);
32
33
  }
33
- exports.parseTemplateFile = parseTemplateFile;
34
34
  function renderTemplate(templateFn, data) {
35
35
  return templateFn(data);
36
36
  }
37
- exports.renderTemplate = renderTemplate;
@@ -1,2 +1,2 @@
1
- declare const _default: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/server/plugin").ServerPluginHooks, import("@shuvi/service").IServerPluginContext>;
1
+ declare const _default: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/server").ServerPluginHooks, import("@shuvi/service").IServerPluginContext>;
2
2
  export default _default;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { ServerResponse } from 'http';
3
2
  import { ShuviRequest } from '@shuvi/service';
4
3
  import { IAppContext } from '@shuvi/platform-shared/shared';
@@ -7,13 +6,13 @@ export interface ModifyHtmlContext {
7
6
  req: ShuviRequest;
8
7
  appContext: IAppContext;
9
8
  }
10
- export declare type IHandlePageRequest = (req: ShuviRequest, res: ServerResponse) => Promise<void>;
11
- export declare type RequestContext = {
9
+ export type IHandlePageRequest = (req: ShuviRequest, res: ServerResponse) => Promise<void>;
10
+ export type RequestContext = {
12
11
  req: ShuviRequest;
13
12
  res: ServerResponse;
14
13
  };
15
- export declare type ISendHtml = (html: string, requestContext: RequestContext) => Promise<void>;
16
- declare type AppConfigCtx = {
14
+ export type ISendHtml = (html: string, requestContext: RequestContext) => Promise<void>;
15
+ type AppConfigCtx = {
17
16
  req: ShuviRequest;
18
17
  };
19
18
  export declare const getAppConfig: import("@shuvi/hook").SyncBailHook<void, AppConfigCtx, {
@@ -27,7 +27,7 @@ const getMiddlewaresBeforeDevMiddlewares = (devMiddleware, context) => {
27
27
  const onDemandRouteManager = new on_demand_compile_page_1.OnDemandRouteManager(context);
28
28
  onDemandRouteManager.devMiddleware = devMiddleware;
29
29
  return [
30
- onDemandRouteManager.getServerMiddleware(),
30
+ onDemandRouteManager.getServerMiddleware(), // check page-*.js
31
31
  onDemandRouteManager.ensureRoutesMiddleware() // check page request
32
32
  ];
33
33
  };
@@ -1,5 +1,5 @@
1
1
  declare const _default: {
2
- core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
2
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core").PluginHooks, import("@shuvi/service").IPluginContext>;
3
3
  runtime: {
4
4
  plugin: string;
5
5
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
3
4
  function default_1() {
4
5
  console.warn('You should compile the module before using it.');
5
6
  return null;
6
7
  }
7
- exports.default = default_1;
@@ -1,5 +1,5 @@
1
1
  declare const _default: {
2
- core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
2
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core").PluginHooks, import("@shuvi/service").IPluginContext>;
3
3
  };
4
4
  export default _default;
5
5
  export { default as OnDemandRouteManager } from './onDemandRouteManager';
@@ -13,17 +13,17 @@ declare global {
13
13
  }
14
14
  }
15
15
  }
16
- declare type ServerPluginConstructor = Required<_ServerPluginConstructor>;
17
- declare type Head<T extends any[]> = T extends [...infer Head, any] ? Head : never;
18
- declare type RemoveLast<T extends (...args: any) => any> = (...args: Head<Parameters<T>>) => ReturnType<T>;
19
- export declare type ShuviMiddlewareHandler = ShuviRequestHandler;
20
- export declare type ShuviApiHandler = IApiRequestHandler;
21
- export declare type GetPageDataFunction = RemoveLast<ServerPluginConstructor['getPageData']>;
22
- export declare type HandlePageRequestFunction = RemoveLast<ServerPluginConstructor['handlePageRequest']>;
23
- export declare type ModifyHtmlFunction = RemoveLast<ServerPluginConstructor['modifyHtml']>;
16
+ type ServerPluginConstructor = Required<_ServerPluginConstructor>;
17
+ type Head<T extends any[]> = T extends [...infer Head, any] ? Head : never;
18
+ type RemoveLast<T extends (...args: any) => any> = (...args: Head<Parameters<T>>) => ReturnType<T>;
19
+ export type ShuviMiddlewareHandler = ShuviRequestHandler;
20
+ export type ShuviApiHandler = IApiRequestHandler;
21
+ export type GetPageDataFunction = RemoveLast<ServerPluginConstructor['getPageData']>;
22
+ export type HandlePageRequestFunction = RemoveLast<ServerPluginConstructor['handlePageRequest']>;
23
+ export type ModifyHtmlFunction = RemoveLast<ServerPluginConstructor['modifyHtml']>;
24
24
  /** indirect type of ModifyHtmlFunction */
25
25
  export type { IHtmlDocument };
26
- export declare type SendHtmlFunction = RemoveLast<ServerPluginConstructor['sendHtml']>;
26
+ export type SendHtmlFunction = RemoveLast<ServerPluginConstructor['sendHtml']>;
27
27
  export interface IServerModule {
28
28
  getPageData?: GetPageDataFunction;
29
29
  handlePageRequest?: HandlePageRequestFunction;
@@ -1,4 +1,4 @@
1
1
  declare const _default: {
2
- core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
2
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core").PluginHooks, import("@shuvi/service").IPluginContext>;
3
3
  };
4
4
  export default _default;
@@ -1,6 +1,6 @@
1
1
  declare const platformWebReact: () => {
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>;
2
+ plugins: (import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core").PluginHooks, import("@shuvi/service").IPluginContext> | {
3
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core").PluginHooks, import("@shuvi/service").IPluginContext>;
4
4
  })[];
5
5
  platformModule: string;
6
6
  };
@@ -1,5 +1,5 @@
1
1
  export declare const ModelReactPlugin: {
2
- core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
2
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core").PluginHooks, import("@shuvi/service").IPluginContext>;
3
3
  runtime: {
4
4
  plugin: string;
5
5
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVersion = void 0;
3
+ exports.getVersion = getVersion;
4
4
  const paths_1 = require("./paths");
5
5
  let version;
6
6
  function getVersion() {
@@ -10,4 +10,3 @@ function getVersion() {
10
10
  }
11
11
  return version;
12
12
  }
13
- exports.getVersion = getVersion;
@@ -4,8 +4,8 @@ import type { ShuviRequest } from '@shuvi/service';
4
4
  export interface AppConfig {
5
5
  ssr: boolean;
6
6
  }
7
- export declare type InternalApplication = _ApplicationImpl<AppConfig>;
8
- export declare type Application = _Application<AppConfig>;
7
+ export type InternalApplication = _ApplicationImpl<AppConfig>;
8
+ export type Application = _Application<AppConfig>;
9
9
  export interface CreateAppServer {
10
10
  (options: {
11
11
  req: ShuviRequest;
@@ -6,7 +6,7 @@ export interface IModule {
6
6
  files: string[];
7
7
  children: IModuleItem[];
8
8
  }
9
- export declare type IAssetMap = {
9
+ export type IAssetMap = {
10
10
  js: string[];
11
11
  css?: string[];
12
12
  } & {
@@ -2,7 +2,7 @@ import type { ShuviRequest } from '@shuvi/service';
2
2
  import { Response, IAppData } from '@shuvi/platform-shared/shared';
3
3
  import { IManifest } from '../shared';
4
4
  import { Application } from './appTypes';
5
- export declare type IRenderViewOptions = {
5
+ export type IRenderViewOptions = {
6
6
  app: Application;
7
7
  };
8
8
  export interface IRenderOptions extends IRenderViewOptions {
@@ -10,7 +10,7 @@ export interface IRenderOptions extends IRenderViewOptions {
10
10
  export interface IView<RenderOption extends IRenderOptions = any, RenderResult = void> {
11
11
  renderApp(options: RenderOption): RenderResult;
12
12
  }
13
- export declare type IHtmlAttrs = {
13
+ export type IHtmlAttrs = {
14
14
  textContent?: string;
15
15
  } & {
16
16
  [x: string]: string | number | undefined | boolean;
@@ -20,7 +20,7 @@ export interface IHtmlTag<TagNames = string> {
20
20
  attrs: IHtmlAttrs;
21
21
  innerHTML?: string;
22
22
  }
23
- export declare type IRenderAppServerResult<ExtraAppData = {}> = {
23
+ export type IRenderAppServerResult<ExtraAppData = {}> = {
24
24
  htmlAttrs?: IHtmlAttrs;
25
25
  headBeginTags?: IHtmlTag[];
26
26
  headEndTags?: IHtmlTag[];
@@ -4,17 +4,17 @@ export interface IApiReq {
4
4
  [key: string]: any;
5
5
  };
6
6
  }
7
- export declare type IApiRequest = ShuviRequest & IApiReq;
8
- export declare type Send<T> = (body: T) => void;
9
- export declare type IApiRes<T = any> = {
7
+ export type IApiRequest = ShuviRequest & IApiReq;
8
+ export type Send<T> = (body: T) => void;
9
+ export type IApiRes<T = any> = {
10
10
  send: Send<T>;
11
11
  json: Send<T>;
12
12
  status: (statusCode: number) => IApiRes<T>;
13
13
  redirect(url: string): IApiRes<T>;
14
14
  redirect(status: number, url: string): IApiRes<T>;
15
15
  };
16
- export declare type IApiResponse<T = any> = ShuviResponse & IApiRes<T>;
17
- export declare type IApiRequestHandler<T = any> = (req: IApiRequest, res: IApiResponse<T>) => void | Promise<void>;
16
+ export type IApiResponse<T = any> = ShuviResponse & IApiRes<T>;
17
+ export type IApiRequestHandler<T = any> = (req: IApiRequest, res: IApiResponse<T>) => void | Promise<void>;
18
18
  export interface IApiConfig {
19
19
  api?: {
20
20
  bodyParser?: {
@@ -29,11 +29,11 @@ export interface IApiHandler {
29
29
  export interface IMiddlewareConfig {
30
30
  default: ShuviRequestHandler;
31
31
  }
32
- export declare type IApiRoutes = {
32
+ export type IApiRoutes = {
33
33
  path: string;
34
34
  api: IApiHandler;
35
35
  }[];
36
- export declare type IMiddlewareRoutes = {
36
+ export type IMiddlewareRoutes = {
37
37
  path: string;
38
38
  middleware: IMiddlewareConfig;
39
39
  }[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/platform-web",
3
- "version": "1.0.55",
3
+ "version": "1.0.56",
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.55",
76
- "@shuvi/hook": "1.0.55",
77
- "@shuvi/platform-shared": "1.0.55",
78
- "@shuvi/router": "1.0.55",
79
- "@shuvi/router-react": "1.0.55",
80
- "@shuvi/runtime": "1.0.55",
81
- "@shuvi/shared": "1.0.55",
82
- "@shuvi/toolpack": "1.0.55",
83
- "@shuvi/utils": "1.0.55",
75
+ "@shuvi/error-overlay": "1.0.56",
76
+ "@shuvi/hook": "1.0.56",
77
+ "@shuvi/platform-shared": "1.0.56",
78
+ "@shuvi/router": "1.0.56",
79
+ "@shuvi/router-react": "1.0.56",
80
+ "@shuvi/runtime": "1.0.56",
81
+ "@shuvi/shared": "1.0.56",
82
+ "@shuvi/toolpack": "1.0.56",
83
+ "@shuvi/utils": "1.0.56",
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.55"
101
+ "@shuvi/service": "1.0.56"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@shuvi/service": "workspace:*",