@shuvi/platform-shared 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 (68) hide show
  1. package/esm/shared/application.d.ts +13 -66
  2. package/esm/shared/application.js +41 -12
  3. package/esm/shared/applicationTypes.d.ts +15 -18
  4. package/esm/shared/helper/getAppData.d.ts +1 -4
  5. package/esm/shared/helper/getAppData.js +0 -1
  6. package/esm/shared/index.d.ts +2 -1
  7. package/esm/shared/index.js +2 -3
  8. package/esm/shared/loader/index.d.ts +0 -1
  9. package/esm/shared/loader/index.js +0 -1
  10. package/esm/shared/loader/loader.d.ts +1 -1
  11. package/esm/shared/loader/loader.js +2 -2
  12. package/esm/shared/loader/types.d.ts +4 -8
  13. package/esm/shared/models/error.d.ts +4 -4
  14. package/esm/shared/models/error.js +2 -2
  15. package/esm/shared/models/loader.d.ts +13 -0
  16. package/esm/shared/models/loader.js +24 -0
  17. package/esm/shared/routerTypes.d.ts +4 -13
  18. package/esm/shared/{lifecycle.d.ts → runtimPlugin.d.ts} +2 -4
  19. package/esm/shared/{lifecycle.js → runtimPlugin.js} +2 -1
  20. package/esm/shuvi-app/shuvi-runtime-app.d.ts +1 -1
  21. package/esm/shuvi-app/shuvi-runtime-index.d.ts +1 -1
  22. package/esm/shuvi-app/shuvi-runtime-index.js +1 -1
  23. package/lib/node/platform/index.d.ts +1 -14
  24. package/lib/node/platform/plugins/main/index.d.ts +1 -14
  25. package/lib/node/platform/plugins/main/index.js +1 -2
  26. package/lib/node/platform/runtimeFiles.d.ts +1 -1
  27. package/lib/node/project/file-presets/files/app/core/entry.js.d.ts +1 -1
  28. package/lib/node/project/file-presets/files/app/core/error.js.d.ts +1 -1
  29. package/lib/node/project/file-presets/files/app/core/platform.js.d.ts +1 -1
  30. package/lib/node/project/file-presets/files/app/core/polyfill.js.d.ts +1 -1
  31. package/lib/node/project/file-presets/files/app/core/runtimeConfig.js.d.ts +1 -1
  32. package/lib/node/project/file-presets/files/app/core/setPublicRuntimeConfig.js.d.ts +1 -1
  33. package/lib/node/project/file-presets/files/app/core/setRuntimeConfig.js.d.ts +1 -1
  34. package/lib/node/project/file-presets/files/app/user/app.js.d.ts +1 -1
  35. package/lib/node/project/file-presets/files/app/user/error.js.d.ts +1 -1
  36. package/lib/node/project/file-presets/files/app/user/server.js.d.ts +1 -1
  37. package/lib/node/project/file-presets/index.d.ts +3 -3
  38. package/lib/node/route/helpers.js +6 -27
  39. package/lib/node/route/index.d.ts +1 -1
  40. package/lib/node/route/index.js +2 -1
  41. package/lib/node/route/route.d.ts +3 -3
  42. package/lib/node/route/route.js +26 -5
  43. package/lib/shared/application.d.ts +13 -66
  44. package/lib/shared/application.js +43 -14
  45. package/lib/shared/applicationTypes.d.ts +15 -18
  46. package/lib/shared/helper/getAppData.d.ts +1 -4
  47. package/lib/shared/helper/getAppData.js +0 -1
  48. package/lib/shared/index.d.ts +2 -1
  49. package/lib/shared/index.js +7 -4
  50. package/lib/shared/loader/index.d.ts +0 -1
  51. package/lib/shared/loader/index.js +0 -1
  52. package/lib/shared/loader/loader.d.ts +1 -1
  53. package/lib/shared/loader/loader.js +2 -2
  54. package/lib/shared/loader/types.d.ts +4 -8
  55. package/lib/shared/models/error.d.ts +4 -4
  56. package/lib/shared/models/error.js +2 -2
  57. package/lib/shared/models/loader.d.ts +13 -0
  58. package/lib/shared/models/loader.js +27 -0
  59. package/lib/shared/routerTypes.d.ts +4 -13
  60. package/lib/shared/{lifecycle.d.ts → runtimPlugin.d.ts} +2 -4
  61. package/lib/shared/{lifecycle.js → runtimPlugin.js} +4 -2
  62. package/package.json +12 -11
  63. package/shuvi-type-extensions-node.js +1 -0
  64. package/shuvi-type-extensions-runtime.d.ts +2 -6
  65. package/esm/shared/loader/loaderManager.d.ts +0 -16
  66. package/esm/shared/loader/loaderManager.js +0 -49
  67. package/lib/shared/loader/loaderManager.d.ts +0 -16
  68. package/lib/shared/loader/loaderManager.js +0 -53
@@ -1,78 +1,25 @@
1
- import { IRouter } from './routerTypes';
2
- import { IStoreManager, IApplication, IAppContext, IApplicationOptions, IRerenderConfig } from './applicationTypes';
1
+ import { IRouter, IPageRouteRecord } from './routerTypes';
2
+ import { RedoxStore, IApplication, IAppContext, IApplicationOptions, IRerenderConfig, IError } from './applicationTypes';
3
3
  export declare class Application {
4
- private _error;
5
4
  private _router;
6
5
  private _appComponent;
7
6
  private _pluginManager;
8
7
  private _context;
9
- private _storeManager;
8
+ private _store;
9
+ private _error;
10
+ private _loader;
10
11
  constructor(options: IApplicationOptions);
11
- get router(): IRouter<any>;
12
+ get router(): IRouter<IPageRouteRecord>;
12
13
  get context(): IAppContext;
13
- get pluginManager(): import("@shuvi/hook").HookManager<import("./lifecycle").BuiltInRuntimePluginHooks, void, import("@shuvi/runtime").CustomRuntimePluginHooks>;
14
+ get pluginManager(): import("@shuvi/hook").HookManager<import("./runtimPlugin").RuntimePluginHooks, void>;
14
15
  get appComponent(): any;
15
- get error(): {
16
- $state: import("./applicationTypes").IErrorState;
17
- $set: (state: import("@shuvi/redox").State) => void;
18
- $modify: (modifier: (state: import("./applicationTypes").IErrorState) => void) => void;
19
- $patch: (partState: import("@shuvi/redox").ObjectState) => void;
20
- $actions: {
21
- setError: (payload?: import("./applicationTypes").IError | undefined) => import("@shuvi/redox").Action<import("./applicationTypes").IError | undefined>;
22
- } & {
23
- error: (payload?: import("./applicationTypes").IError | undefined) => void;
24
- clear: () => void;
25
- } & {
26
- [X: string]: never;
27
- [X: number]: never;
28
- [X: symbol]: never;
29
- };
30
- $views: import("@shuvi/redox").RedoxViews<({
31
- getError(): import("./applicationTypes").IError | undefined;
32
- hasError(): boolean;
33
- } & ThisType<import("./applicationTypes").IErrorState & {
34
- $state: import("./applicationTypes").IErrorState;
35
- } & import("@shuvi/redox").RedoxViews<{
36
- getError(): import("./applicationTypes").IError | undefined;
37
- hasError(): boolean;
38
- }> & {
39
- $dep: {} & {} & {};
40
- }>) | undefined>;
41
- $createSelector: <TReturn>(selector: import("@shuvi/redox").ISelector<import("@shuvi/redox").Model<"error", import("./applicationTypes").IErrorState, {}, {
42
- setError(_state: import("./applicationTypes").IErrorState, error?: import("./applicationTypes").IError | undefined): {
43
- error: import("./applicationTypes").IError | undefined;
44
- };
45
- }, {
46
- error(payload?: import("./applicationTypes").IError | undefined): void;
47
- clear(): void;
48
- }, {
49
- getError(): import("./applicationTypes").IError | undefined;
50
- hasError(): boolean;
51
- }>, TReturn>) => (() => TReturn) & {
52
- clearCache: () => void;
53
- };
54
- } & import("@shuvi/redox").RedoxViews<{
55
- getError(): import("./applicationTypes").IError | undefined;
56
- hasError(): boolean;
57
- } & ThisType<import("./applicationTypes").IErrorState & {
58
- $state: import("./applicationTypes").IErrorState;
59
- } & import("@shuvi/redox").RedoxViews<{
60
- getError(): import("./applicationTypes").IError | undefined;
61
- hasError(): boolean;
62
- }> & {
63
- $dep: {} & {} & {};
64
- }>> & {
65
- setError: (payload?: import("./applicationTypes").IError | undefined) => import("@shuvi/redox").Action<import("./applicationTypes").IError | undefined>;
66
- } & {
67
- error: (payload?: import("./applicationTypes").IError | undefined) => void;
68
- clear: () => void;
69
- } & {
70
- [X: string]: never;
71
- [X: number]: never;
72
- [X: symbol]: never;
73
- };
16
+ get error(): IError | undefined;
17
+ setError(err: IError): void;
18
+ clearError(): void;
19
+ getLoadersData(): Record<string, any>;
20
+ setLoadersData(datas: Record<string, any>): void;
74
21
  init(): Promise<void>;
75
- get storeManager(): IStoreManager;
22
+ get store(): RedoxStore;
76
23
  updateComponents({ AppComponent }?: IRerenderConfig): Promise<void>;
77
24
  dispose(): Promise<void>;
78
25
  private _initPlugin;
@@ -7,16 +7,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { getManager } from './lifecycle';
11
- import { initPlugins } from './lifecycle';
10
+ import { getManager } from './runtimPlugin';
11
+ import { initPlugins } from './runtimPlugin';
12
12
  import { redox } from '@shuvi/redox';
13
13
  import { errorModel } from './models/error';
14
+ import { loaderModel } from './models/loader';
14
15
  export class Application {
15
16
  constructor(options) {
16
17
  this._router = options.router;
17
18
  this._context = {};
18
- this._storeManager = redox({ initialState: options.initialState });
19
- this._error = this._storeManager.get(errorModel);
19
+ this._store = redox({ initialState: options.initialState });
20
+ this._error = this._store.getModel(errorModel);
21
+ this._loader = this._store.getModel(loaderModel);
20
22
  this._appComponent = options.AppComponent;
21
23
  this._pluginManager = getManager();
22
24
  initPlugins(this._pluginManager, options.plugins || []);
@@ -34,7 +36,19 @@ export class Application {
34
36
  return this._appComponent;
35
37
  }
36
38
  get error() {
37
- return this._error;
39
+ return this._error.errorObject;
40
+ }
41
+ setError(err) {
42
+ this._error.set(err);
43
+ }
44
+ clearError() {
45
+ this._error.clear();
46
+ }
47
+ getLoadersData() {
48
+ return this._loader.getAllData;
49
+ }
50
+ setLoadersData(datas) {
51
+ this._loader.setDatas(datas);
38
52
  }
39
53
  init() {
40
54
  return __awaiter(this, void 0, void 0, function* () {
@@ -44,8 +58,8 @@ export class Application {
44
58
  this._router.init();
45
59
  });
46
60
  }
47
- get storeManager() {
48
- return this._storeManager;
61
+ get store() {
62
+ return this._store;
49
63
  }
50
64
  updateComponents({ AppComponent } = {}) {
51
65
  return __awaiter(this, void 0, void 0, function* () {
@@ -76,12 +90,27 @@ export class Application {
76
90
  });
77
91
  }
78
92
  getPublicAPI() {
93
+ const self = this;
79
94
  return {
80
- context: this._context,
81
- router: this._router,
82
- appComponent: this._appComponent,
83
- storeManager: this._storeManager,
84
- error: this._error
95
+ context: self._context,
96
+ router: self._router,
97
+ appComponent: self._appComponent,
98
+ store: self._store,
99
+ get error() {
100
+ return self.error;
101
+ },
102
+ setError(err) {
103
+ self.setError(err);
104
+ },
105
+ clearError() {
106
+ self.clearError();
107
+ },
108
+ getLoadersData() {
109
+ return self.getLoadersData();
110
+ },
111
+ setLoadersData(datas) {
112
+ self.setLoadersData(datas);
113
+ }
85
114
  };
86
115
  }
87
116
  }
@@ -1,22 +1,21 @@
1
- /// <reference types="node" />
2
- import type { IncomingMessage } from 'http';
3
- import { IStoreManager } from '@shuvi/redox';
1
+ import { RedoxStore } from '@shuvi/redox';
4
2
  import { CustomAppContext } from '@shuvi/runtime';
5
- import { IRouter } from './routerTypes';
6
- import { IPluginList } from './lifecycle';
7
- export declare type IRequest = IncomingMessage & {
8
- [x: string]: any;
9
- };
3
+ import { IRouter, IPageRouteRecord } from './routerTypes';
4
+ import { IPluginList } from './runtimPlugin';
10
5
  export interface IAppContext extends CustomAppContext {
11
6
  [x: string]: unknown;
12
7
  }
13
8
  export declare type IRerenderConfig = {
14
9
  AppComponent?: any;
15
10
  };
16
- export type { IStoreManager };
11
+ export type { RedoxStore };
12
+ export declare type ErrorSource = 'server';
17
13
  export interface IError {
18
14
  code?: number;
19
15
  message?: string;
16
+ stack?: string;
17
+ name?: string;
18
+ source?: ErrorSource;
20
19
  }
21
20
  export interface IErrorState {
22
21
  error?: IError;
@@ -24,18 +23,16 @@ export interface IErrorState {
24
23
  export declare type IAppState = {
25
24
  error?: IErrorState;
26
25
  };
27
- export interface IErrorManager {
28
- getError: IError | undefined;
29
- error: (err: IError) => void;
30
- clear: () => void;
31
- hasError: boolean;
32
- }
33
26
  export interface IApplication {
34
27
  readonly context: IAppContext;
35
- readonly router: IRouter;
28
+ readonly router: IRouter<IPageRouteRecord>;
36
29
  readonly appComponent: any;
37
- readonly error: IErrorManager;
38
- readonly storeManager: IStoreManager;
30
+ readonly store: RedoxStore;
31
+ readonly error: IError | undefined;
32
+ setError(err: IError): void;
33
+ clearError(): void;
34
+ getLoadersData(): Record<string, any>;
35
+ setLoadersData(datas: Record<string, any>): void;
39
36
  }
40
37
  export interface IApplicationOptions {
41
38
  router: IRouter;
@@ -5,13 +5,10 @@ export declare type IData = {
5
5
  export declare type IAppData<Data = {}, appState = any> = {
6
6
  ssr: boolean;
7
7
  runtimeConfig?: Record<string, string>;
8
+ appState?: appState;
8
9
  pageData?: {
9
10
  [key: string]: any;
10
11
  };
11
- loadersData?: {
12
- [x: string]: any;
13
- };
14
- appState?: appState;
15
12
  filesByRoutId: Record<string, string[]>;
16
13
  publicPath: string;
17
14
  } & {
@@ -17,7 +17,6 @@ export function getAppData() {
17
17
  return {
18
18
  ssr: false,
19
19
  pageData: {},
20
- loadersData: {},
21
20
  filesByRoutId: {},
22
21
  publicPath: ''
23
22
  };
@@ -4,7 +4,8 @@ export * from './router';
4
4
  export * from './response';
5
5
  export * from './loader';
6
6
  export { errorModel } from './models/error';
7
+ export { loaderModel } from './models/loader';
7
8
  export * from './applicationTypes';
8
9
  export type { Application } from './application';
9
10
  export type { IRuntimeConfig } from './runtimeConfigTypes';
10
- export { IAppModule, IPluginInstance, BuiltInRuntimePluginHooks, CustomRuntimePluginHooks, RuntimePluginHooks, createRuntimePlugin, RuntimePluginInstance } from './lifecycle';
11
+ export { IAppModule, IPluginInstance, BuiltInRuntimePluginHooks, CustomRuntimePluginHooks, RuntimePluginHooks, createRuntimePlugin, createRuntimePluginBefore, createRuntimePluginAfter, RuntimePluginInstance } from './runtimPlugin';
@@ -4,7 +4,6 @@ export * from './router';
4
4
  export * from './response';
5
5
  export * from './loader';
6
6
  export { errorModel } from './models/error';
7
+ export { loaderModel } from './models/loader';
7
8
  export * from './applicationTypes';
8
- export {
9
- // fix createRuntimePlugin is not portable end
10
- createRuntimePlugin } from './lifecycle';
9
+ export { createRuntimePlugin, createRuntimePluginBefore, createRuntimePluginAfter } from './runtimPlugin';
@@ -1,3 +1,2 @@
1
1
  export * from './loader';
2
- export * from './loaderManager';
3
2
  export * from './types';
@@ -1,3 +1,2 @@
1
1
  export * from './loader';
2
- export * from './loaderManager';
3
2
  export * from './types';
@@ -5,5 +5,5 @@ interface Result<T> {
5
5
  result?: T;
6
6
  }
7
7
  export declare function runInParallerAndBail<T>(fns: Array<() => Promise<T> | T>): Promise<Result<T>[]>;
8
- export declare function runLoaders(matches: IRouteMatch<IPageRouteRecord>[], loadersByRouteId: Record<string, Loader>, { isServer, query, req, getAppContext }: LoaderContextOptions): Promise<LoaderDataRecord>;
8
+ export declare function runLoaders(matches: IRouteMatch<IPageRouteRecord>[], loadersByRouteId: Record<string, Loader>, { query, req, getAppContext }: LoaderContextOptions): Promise<LoaderDataRecord>;
9
9
  export {};
@@ -68,7 +68,7 @@ function errorHelper(msg, statusCode = 500) {
68
68
  invariant(statusCode >= 400 && statusCode < 600, 'status code should be 4xx and 5xx');
69
69
  throw response(msg, { status: statusCode });
70
70
  }
71
- export function runLoaders(matches, loadersByRouteId, { isServer, query, req, getAppContext }) {
71
+ export function runLoaders(matches, loadersByRouteId, { query, req, getAppContext }) {
72
72
  return __awaiter(this, void 0, void 0, function* () {
73
73
  if (!matches.length) {
74
74
  return [];
@@ -78,7 +78,7 @@ export function runLoaders(matches, loadersByRouteId, { isServer, query, req, ge
78
78
  const loaderFn = loadersByRouteId[match.route.id];
79
79
  let res;
80
80
  try {
81
- const value = yield loaderFn(Object.assign({ isServer, pathname: match.pathname, params: match.params, query: query, redirect: redirectHelper, error: errorHelper, appContext }, (req ? { req } : {})));
81
+ const value = yield loaderFn(Object.assign({ pathname: match.pathname, params: match.params, query: query, redirect: redirectHelper, error: errorHelper, appContext }, (req ? { req } : {})));
82
82
  if (value) {
83
83
  res = createJson(value);
84
84
  }
@@ -1,9 +1,9 @@
1
+ import type { ShuviRequest } from '@shuvi/service';
1
2
  import { IURLQuery, IURLParams } from '../routerTypes';
2
- import { IAppContext, IRequest } from '../applicationTypes';
3
+ import { IAppContext } from '../applicationTypes';
3
4
  import { Response } from '../response';
4
5
  export interface LoaderContextOptions {
5
- isServer: boolean;
6
- req?: IRequest;
6
+ req?: ShuviRequest;
7
7
  query: IURLQuery;
8
8
  getAppContext: () => IAppContext;
9
9
  }
@@ -17,10 +17,6 @@ export interface ErrorFunction {
17
17
  * route component getInitialProps params `context`
18
18
  */
19
19
  export interface IRouteLoaderContext {
20
- /**
21
- * is running on server, if server is true, client will be false
22
- */
23
- isServer: boolean;
24
20
  /**
25
21
  * current url path
26
22
  */
@@ -62,7 +58,7 @@ export interface IRouteLoaderContext {
62
58
  /**
63
59
  * server only
64
60
  */
65
- req?: IRequest;
61
+ req?: ShuviRequest;
66
62
  /**
67
63
  * Application context object, which is accessiable during the entire lifecycle of application
68
64
  */
@@ -1,13 +1,13 @@
1
1
  import { IErrorState, IError } from '../applicationTypes';
2
- export declare const errorModel: import("@shuvi/redox").Model<"error", IErrorState, {}, {
2
+ export declare const errorModel: import("@shuvi/redox/esm/core/defineModel").DefineModel<"error", IErrorState, {
3
3
  setError(_state: IErrorState, error?: IError): {
4
4
  error: IError | undefined;
5
5
  };
6
6
  }, {
7
- error(payload?: IError): void;
7
+ set(payload?: IError): void;
8
8
  clear(): void;
9
9
  }, {
10
- getError(): IError | undefined;
10
+ errorObject(): IError | undefined;
11
11
  hasError(): boolean;
12
- }>;
12
+ }, {}>;
13
13
  export declare type ErrorModel = typeof errorModel;
@@ -12,7 +12,7 @@ export const errorModel = defineModel({
12
12
  }
13
13
  },
14
14
  actions: {
15
- error(payload) {
15
+ set(payload) {
16
16
  this.setError(payload || SHUVI_ERROR.APP_ERROR);
17
17
  },
18
18
  clear() {
@@ -22,7 +22,7 @@ export const errorModel = defineModel({
22
22
  }
23
23
  },
24
24
  views: {
25
- getError() {
25
+ errorObject() {
26
26
  return this.error;
27
27
  },
28
28
  hasError() {
@@ -0,0 +1,13 @@
1
+ export interface LoaderState {
2
+ dataByRouteId: Record<string, any>;
3
+ }
4
+ export declare const loaderModel: import("@shuvi/redox/esm/core/defineModel").DefineModel<"loader", LoaderState, {
5
+ setDatas(state: LoaderState, newData: Record<string, any>): {
6
+ dataByRouteId: {
7
+ [x: string]: any;
8
+ };
9
+ };
10
+ }, import("@shuvi/redox/esm/core/defineModel").ActionOptions, {
11
+ getAllData(): Record<string, any>;
12
+ }, {}>;
13
+ export declare type LoaderModel = typeof loaderModel;
@@ -0,0 +1,24 @@
1
+ import { defineModel } from '@shuvi/redox';
2
+ const initState = {
3
+ dataByRouteId: {}
4
+ };
5
+ export const loaderModel = defineModel({
6
+ name: 'loader',
7
+ state: initState,
8
+ reducers: {
9
+ setDatas(state, newData) {
10
+ return Object.assign(Object.assign({}, state), { dataByRouteId: Object.assign(Object.assign({}, state.dataByRouteId), newData) });
11
+ }
12
+ // clearDatas(state) {
13
+ // return {
14
+ // ...state,
15
+ // dataByRouteId: {}
16
+ // };
17
+ // }
18
+ },
19
+ views: {
20
+ getAllData() {
21
+ return this.dataByRouteId;
22
+ }
23
+ }
24
+ });
@@ -7,18 +7,10 @@ export interface IPageRouteRecord extends IRouteRecord {
7
7
  path: string;
8
8
  component?: any;
9
9
  children?: IPageRouteRecord[];
10
- [x: string]: any;
11
- }
12
- export interface IRawPageRouteRecord extends IRouteRecord {
13
- id: string;
14
- path: string;
15
- component?: any;
16
- children?: IRawPageRouteRecord[];
17
- fullPath: string;
18
- __componentSource__: string;
19
- __componentSourceWithAffix__: string;
20
- __import__: () => Promise<any>;
21
- __resolveWeak__: () => any;
10
+ __import__?: () => Promise<any>;
11
+ __resolveWeak__?: () => string[];
12
+ __componentSource__?: string;
13
+ __componentRawRequest__?: string;
22
14
  [x: string]: any;
23
15
  }
24
16
  export interface IPlatformConfig {
@@ -34,7 +26,6 @@ export interface IPageRouteConfig {
34
26
  component?: string;
35
27
  redirect?: string;
36
28
  path: string;
37
- fullPath?: string;
38
29
  }
39
30
  export interface IPageRouteConfigWithId extends IPageRouteConfig {
40
31
  id: string;
@@ -14,10 +14,8 @@ export interface BuiltInRuntimePluginHooks extends HookMap {
14
14
  }
15
15
  export interface RuntimePluginHooks extends BuiltInRuntimePluginHooks, CustomRuntimePluginHooks {
16
16
  }
17
- export declare const getManager: () => import("@shuvi/hook").HookManager<BuiltInRuntimePluginHooks, void, CustomRuntimePluginHooks>;
18
- export declare const createRuntimePlugin: (pluginHandlers: Partial<import("@shuvi/hook").IPluginHandlersFullMap<BuiltInRuntimePluginHooks & CustomRuntimePluginHooks, void>> & {
19
- setup?: import("@shuvi/hook").Setup<CustomRuntimePluginHooks> | undefined;
20
- }, options?: import("@shuvi/hook").PluginOptions | undefined) => IPluginInstance<BuiltInRuntimePluginHooks & CustomRuntimePluginHooks, void>;
17
+ export declare const getManager: () => import("@shuvi/hook").HookManager<RuntimePluginHooks, void>;
18
+ export declare const createRuntimePluginBefore: import("@shuvi/shared/lib/plugins").PluginFunc<RuntimePluginHooks, void>, createRuntimePlugin: import("@shuvi/shared/lib/plugins").PluginFunc<RuntimePluginHooks, void>, createRuntimePluginAfter: import("@shuvi/shared/lib/plugins").PluginFunc<RuntimePluginHooks, void>;
21
19
  export type { IPluginInstance, CustomRuntimePluginHooks };
22
20
  export declare type PluginManager = ReturnType<typeof getManager>;
23
21
  export declare type RuntimePluginInstance = IPluginInstance<RuntimePluginHooks, void>;
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { createAsyncParallelHook, createAsyncSeriesWaterfallHook, createHookManager, isPluginInstance } from '@shuvi/hook';
11
+ import { createPluginCreator } from '@shuvi/shared/lib/plugins';
11
12
  const init = createAsyncParallelHook();
12
13
  const appContext = createAsyncSeriesWaterfallHook();
13
14
  const appComponent = createAsyncSeriesWaterfallHook();
@@ -19,7 +20,7 @@ const builtinRuntimePluginHooks = {
19
20
  dispose
20
21
  };
21
22
  export const getManager = () => createHookManager(builtinRuntimePluginHooks, false);
22
- export const { createPlugin: createRuntimePlugin } = getManager();
23
+ export const { createPluginBefore: createRuntimePluginBefore, createPlugin: createRuntimePlugin, createPluginAfter: createRuntimePluginAfter } = createPluginCreator(getManager());
23
24
  export const initPlugins = (pluginManager, plugins) => __awaiter(void 0, void 0, void 0, function* () {
24
25
  // clear plugin at development mode every time
25
26
  if (process.env.NODE_ENV === 'development') {
@@ -5,7 +5,7 @@
5
5
  * import {} from '@shuvi/runtime/app'
6
6
  *
7
7
  */
8
- import { IAppModule as _IAppModule } from '../shared/lifecycle';
8
+ import { IAppModule as _IAppModule } from '../shared/runtimPlugin';
9
9
  declare type AppModule = Required<_IAppModule>;
10
10
  export declare type InitFunction = AppModule['init'];
11
11
  export declare type AppComponentFunction = AppModule['appComponent'];
@@ -5,6 +5,6 @@
5
5
  * import {} from '@shuvi/runtime'
6
6
  *
7
7
  */
8
- export { createRuntimePlugin } from '../shared/lifecycle';
8
+ export { createRuntimePlugin } from '../shared/runtimPlugin';
9
9
  export { getPageData } from '../shared/helper/getPageData';
10
10
  export type { Loader } from '../shared/loader';
@@ -5,5 +5,5 @@
5
5
  * import {} from '@shuvi/runtime'
6
6
  *
7
7
  */
8
- export { createRuntimePlugin } from '../shared/lifecycle';
8
+ export { createRuntimePlugin } from '../shared/runtimPlugin';
9
9
  export { getPageData } from '../shared/helper/getPageData';
@@ -1,17 +1,4 @@
1
1
  export * from './runtimeFiles';
2
2
  export declare const SharedPlugins: {
3
- core: import("@shuvi/hook").IPluginInstance<{
4
- extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
5
- afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
6
- afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
7
- afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
8
- afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
9
- afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
10
- configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
11
- addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
12
- addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
13
- 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>[]>;
14
- addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
15
- } & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
16
- types: string;
3
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
17
4
  }[];
@@ -1,17 +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>;
15
- types: string;
2
+ core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
16
3
  };
17
4
  export default _default;
@@ -27,6 +27,5 @@ const core = (0, service_1.createPlugin)({
27
27
  ]
28
28
  });
29
29
  exports.default = {
30
- core,
31
- types: (0, paths_1.resolvePkgFile)('lib/node/platform/plugins/main/shuvi-app.d.ts')
30
+ core
32
31
  };
@@ -4,4 +4,4 @@ import { IPluginContext } from '@shuvi/service';
4
4
  * `core/error`, `core/platform`, `core/plugins`, `core/polyfill`, `core/runtimeConfig`, `core/setRuntimeConfig`,
5
5
  * `user/error`, `user/runtime` and `entry`
6
6
  */
7
- export declare const getPresetRuntimeFilesCreator: (platformModule: string, polyfills: string[]) => (pluginContext: IPluginContext) => Promise<import("@shuvi/service/lib/project").FileOptions<any, any>[]>;
7
+ export declare const getPresetRuntimeFilesCreator: (platformModule: string, polyfills: string[]) => (pluginContext: IPluginContext) => Promise<import("@shuvi/service/lib/project").FileOption<any, any>[]>;
@@ -1,3 +1,3 @@
1
1
  import { ProjectContext } from '../../../../projectContext';
2
- declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").DefineFileOption, "name">;
2
+ declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").FileOptionWithoutId<string, any>, "name">;
3
3
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: () => Omit<import("@shuvi/service/lib/project/index").DefineFileOption, "name">;
1
+ declare const _default: () => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import { ProjectContext } from '../../../../projectContext';
2
- declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").DefineFileOption, "name">;
2
+ declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").FileOptionWithoutId<string, any>, "name">;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import { ProjectContext } from '../../../../projectContext';
2
- declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project/index").DefineFileOption, "name">;
2
+ declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import { ProjectContext } from '../../../../projectContext';
2
- declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project/index").DefineFileOption, "name">;
2
+ declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
3
3
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: () => Omit<import("@shuvi/service/lib/project/index").DefineFileOption, "name">;
1
+ declare const _default: () => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: () => Omit<import("@shuvi/service/lib/project/index").DefineFileOption, "name">;
1
+ declare const _default: () => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import { ProjectContext } from '../../../../projectContext';
2
- declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").DefineFileOption, "name">;
2
+ declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").FileOptionWithoutId<string, any>, "name">;
3
3
  export default _default;