@modern-js/types 1.1.5-rc.0 → 1.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,44 @@
1
1
  # @modern-js/types
2
2
 
3
- ## 1.1.5-rc.0
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ec4dbffb: feat: support as a pure api service
8
+
9
+ ### Patch Changes
10
+
11
+ - 816fd721: support more server context
12
+ - bfbea9a7: support multi base url and dynamic base url
13
+ - 24f616ca: feat: support custom meta info
14
+ - 272cab15: refactor server plugin manager
15
+
16
+ ## 1.2.1
17
+
18
+ ### Patch Changes
19
+
20
+ - 83166714: change .npmignore
21
+ - b7c48198: feat: add beforeGenerateRoutes hook
22
+ - Updated dependencies [83166714]
23
+ - @modern-js/plugin@1.2.1
24
+
25
+ ## 1.2.0
26
+
27
+ ### Minor Changes
28
+
29
+ - cfe11628: Make Modern.js self bootstraping
30
+
31
+ ### Patch Changes
32
+
33
+ - e2464fe5: add more server types
34
+ - Updated dependencies [cfe11628]
35
+ - @modern-js/plugin@1.2.0
36
+
37
+ ## 1.1.5
4
38
 
5
39
  ### Patch Changes
6
40
 
7
41
  - e51b1db3: feat: support custom sdk, interceptor, headers for bff request
8
- - @modern-js/plugin@1.1.2
9
42
 
10
43
  ## 1.1.4
11
44
 
package/cli/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export interface HtmlTemplates {
44
44
  }
45
45
 
46
46
  export interface IAppContext {
47
+ metaName: string; // name for generating conventional constants, such as .modern-js
47
48
  appDirectory: string;
48
49
  configFile: string | false;
49
50
  ip?: string;
@@ -63,6 +64,9 @@ export interface IAppContext {
63
64
  entrypoints: Entrypoint[];
64
65
  serverRoutes: ServerRoute[];
65
66
  htmlTemplates: HtmlTemplates;
67
+ existSrc: boolean;
68
+ internalDirAlias: string;
69
+ internalSrcAlias: string;
66
70
  }
67
71
 
68
72
  export interface Hooks {
@@ -121,4 +125,8 @@ export interface Hooks {
121
125
  partials: HtmlPartials;
122
126
  }>;
123
127
  addRuntimeExports: AsyncWaterfall<void>;
128
+ beforeGenerateRoutes: AsyncWaterfall<{
129
+ entrypoint: Entrypoint;
130
+ code: string;
131
+ }>;
124
132
  }
package/jest.config.js ADDED
@@ -0,0 +1,8 @@
1
+ const sharedConfig = require('@scripts/jest-config');
2
+
3
+ /** @type {import('@jest/types').Config.InitialOptions} */
4
+ module.exports = {
5
+ // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
+ ...sharedConfig,
7
+ rootDir: __dirname,
8
+ };
package/package.json CHANGED
@@ -11,29 +11,38 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.5-rc.0",
15
- "main": "",
14
+ "version": "1.3.0",
16
15
  "types": "./index.d.ts",
17
16
  "dependencies": {
18
- "@modern-js/plugin": "^1.1.2",
17
+ "@modern-js/plugin": "^1.2.1",
19
18
  "webpack": "^5.54.0"
20
19
  },
21
20
  "exports": {
22
21
  ".": "./index.d.ts",
23
- "./server": "./server/index.d.ts"
22
+ "./server": {
23
+ "jsnext:source": "./server/index.d.ts",
24
+ "default": "./server/index.d.ts"
25
+ }
24
26
  },
25
27
  "devDependencies": {
26
28
  "@types/jest": "^26",
27
29
  "@types/node": "^14",
28
30
  "@types/react": "^17",
29
31
  "@types/react-dom": "^17",
30
- "@modern-js/plugin-testing": "^1.2.2",
31
- "@modern-js/module-tools": "^1.1.4"
32
+ "@scripts/build": "0.0.0",
33
+ "jest": "^27",
34
+ "@scripts/jest-config": "0.0.0"
32
35
  },
33
36
  "sideEffects": false,
34
37
  "publishConfig": {
35
38
  "registry": "https://registry.npmjs.org/",
36
- "access": "public"
39
+ "access": "public",
40
+ "main": "",
41
+ "types": "./index.d.ts"
42
+ },
43
+ "scripts": {
44
+ "test": "jest --passWithNoTests"
37
45
  },
46
+ "main": "",
38
47
  "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
39
48
  }
@@ -1,7 +1,7 @@
1
1
  import { IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
2
2
  import { URL } from 'url';
3
3
  import qs from 'querystring';
4
- import { Metrics, Logger } from './util';
4
+ import { Metrics, Logger } from './utils';
5
5
 
6
6
  export interface ModernServerContext {
7
7
  req: IncomingMessage;
@@ -51,7 +51,9 @@ export type BaseSSRServerContext = {
51
51
  pathname: string;
52
52
  query: Record<string, string>;
53
53
  headers: IncomingHttpHeaders;
54
+ host: string;
54
55
  cookie?: string;
56
+ [propsName: string]: any;
55
57
  };
56
58
  redirection: { url?: string; status?: number };
57
59
  distDir: string;
@@ -60,4 +62,5 @@ export type BaseSSRServerContext = {
60
62
  logger: Logger;
61
63
  metrics?: Metrics;
62
64
  loadableManifest?: string;
65
+ cacheConfig?: any;
63
66
  };
@@ -0,0 +1,35 @@
1
+ import { IncomingMessage, ServerResponse } from 'http';
2
+ import { ServerRoute as Route } from './route';
3
+ import { NextFunction } from './utils';
4
+ import { ModernServerContext } from './context';
5
+
6
+ type Middleware = (
7
+ req: IncomingMessage,
8
+ res: ServerResponse,
9
+ next: NextFunction,
10
+ ) => Promise<void>;
11
+
12
+ export type TemplateAPI = {
13
+ get: () => Promise<string>;
14
+ set: (html: string) => void;
15
+ prependBody: (frag: string) => TemplateAPI;
16
+ prependHead: (frag: string) => TemplateAPI;
17
+ appendBody: (frag: string) => TemplateAPI;
18
+ appendHead: (frag: string) => TemplateAPI;
19
+ replace: (tag: string, frag: string) => TemplateAPI;
20
+ };
21
+
22
+ export type RouteAPI = {
23
+ cur: () => Route;
24
+ get: (entryName: string) => Route | undefined;
25
+ use: (entryName: string) => boolean;
26
+ };
27
+
28
+ type HookHandler<Context> = (ctx: Context, next: NextFunction) => Promise<void>;
29
+ type Hook<Context> = (fn: HookHandler<Context>) => void;
30
+ export type ModernServerHook = {
31
+ beforeMatch: Hook<ModernServerContext>;
32
+ afterMatch: Hook<ModernServerContext & { router: RouteAPI }>;
33
+ beforeRender: Hook<ModernServerContext>;
34
+ afterRender: Hook<ModernServerContext & { template: TemplateAPI }>;
35
+ };
package/server/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './context';
2
- export * from './util';
2
+ export * from './hook';
3
+ export * from './utils';
3
4
  export * from './route';
File without changes
package/tsconfig.json CHANGED
@@ -4,9 +4,7 @@
4
4
  "declaration": false,
5
5
  "jsx": "preserve",
6
6
  "baseUrl": "./",
7
- "paths": {
8
- "@/*": ["./src/*"]
9
- }
7
+ "paths": {}
10
8
  },
11
9
  "include": ["src"]
12
10
  }