@modern-js/types 1.1.5 → 1.2.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,5 +1,17 @@
1
1
  # @modern-js/types
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cfe11628: Make Modern.js self bootstraping
8
+
9
+ ### Patch Changes
10
+
11
+ - e2464fe5: add more server types
12
+ - Updated dependencies [cfe11628]
13
+ - @modern-js/plugin@1.2.0
14
+
3
15
  ## 1.1.5
4
16
 
5
17
  ### Patch Changes
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",
15
- "main": "",
14
+ "version": "1.2.0",
16
15
  "types": "./index.d.ts",
17
16
  "dependencies": {
18
- "@modern-js/plugin": "^1.1.2",
17
+ "@modern-js/plugin": "^1.2.0",
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;
@@ -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
  }