@modern-js/types 1.1.5 → 1.3.1

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,46 @@
1
1
  # @modern-js/types
2
2
 
3
+ ## 1.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 78279953: compiler entry bug fix and dev build console
8
+ - 4d72edea: support dev compiler by entry
9
+
10
+ ## 1.3.0
11
+
12
+ ### Minor Changes
13
+
14
+ - ec4dbffb: feat: support as a pure api service
15
+
16
+ ### Patch Changes
17
+
18
+ - 816fd721: support more server context
19
+ - bfbea9a7: support multi base url and dynamic base url
20
+ - 24f616ca: feat: support custom meta info
21
+ - 272cab15: refactor server plugin manager
22
+
23
+ ## 1.2.1
24
+
25
+ ### Patch Changes
26
+
27
+ - 83166714: change .npmignore
28
+ - b7c48198: feat: add beforeGenerateRoutes hook
29
+ - Updated dependencies [83166714]
30
+ - @modern-js/plugin@1.2.1
31
+
32
+ ## 1.2.0
33
+
34
+ ### Minor Changes
35
+
36
+ - cfe11628: Make Modern.js self bootstraping
37
+
38
+ ### Patch Changes
39
+
40
+ - e2464fe5: add more server types
41
+ - Updated dependencies [cfe11628]
42
+ - @modern-js/plugin@1.2.0
43
+
3
44
  ## 1.1.5
4
45
 
5
46
  ### Patch Changes
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;
@@ -61,8 +62,12 @@ export interface IAppContext {
61
62
  serverPath?: any;
62
63
  }[];
63
64
  entrypoints: Entrypoint[];
65
+ checkedEntries: string[];
64
66
  serverRoutes: ServerRoute[];
65
67
  htmlTemplates: HtmlTemplates;
68
+ existSrc: boolean;
69
+ internalDirAlias: string;
70
+ internalSrcAlias: string;
66
71
  }
67
72
 
68
73
  export interface Hooks {
@@ -121,4 +126,8 @@ export interface Hooks {
121
126
  partials: HtmlPartials;
122
127
  }>;
123
128
  addRuntimeExports: AsyncWaterfall<void>;
129
+ beforeGenerateRoutes: AsyncWaterfall<{
130
+ entrypoint: Entrypoint;
131
+ code: string;
132
+ }>;
124
133
  }
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,36 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.5",
15
- "main": "",
14
+ "version": "1.3.1",
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
39
  "access": "public"
37
40
  },
41
+ "scripts": {
42
+ "test": "jest --passWithNoTests"
43
+ },
44
+ "main": "",
38
45
  "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
46
  }
@@ -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
  }