phecda-server 7.0.0-alpha.0 → 7.0.0-alpha.10
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/assets/ps.json +24 -24
- package/assets/schema.json +55 -55
- package/bin/cli.mjs +31 -18
- package/dist/chunk-4LLLQOMF.js +152 -0
- package/dist/{chunk-BGXSMOLX.js → chunk-6OQ2SB5W.js} +138 -70
- package/dist/{chunk-SW5IKE5H.js → chunk-G7JFKM2M.js} +136 -89
- package/dist/{chunk-MBCHNDAY.js → chunk-KCPBITYZ.js} +24 -24
- package/dist/{chunk-HMVLXNV3.mjs → chunk-MUI6MTUO.mjs} +1 -1
- package/dist/chunk-NQ55PA2X.mjs +152 -0
- package/dist/{chunk-5622RBNB.mjs → chunk-YCES6ABN.mjs} +125 -57
- package/dist/{chunk-P75VKZJY.mjs → chunk-Z7NAAE4M.mjs} +94 -47
- package/dist/{core-BIcUwV18.d.mts → core-CUTbX_IS.d.ts} +5 -3
- package/dist/{core-CYwEPfN4.d.ts → core-DIfgUKIU.d.mts} +5 -3
- package/dist/helper.d.mts +8 -6
- package/dist/helper.d.ts +8 -6
- package/dist/helper.js +8 -3
- package/dist/helper.mjs +10 -5
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +43 -44
- package/dist/http/elysia/index.mjs +9 -10
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +40 -41
- package/dist/http/express/index.mjs +9 -10
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +41 -42
- package/dist/http/fastify/index.mjs +9 -10
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +41 -42
- package/dist/http/h3/index.mjs +9 -10
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +37 -39
- package/dist/http/hono/index.mjs +5 -7
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +38 -39
- package/dist/http/hyper-express/index.mjs +8 -9
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +40 -41
- package/dist/http/koa/index.mjs +9 -10
- package/dist/index.d.mts +46 -40
- package/dist/index.d.ts +46 -40
- package/dist/index.js +48 -42
- package/dist/index.mjs +21 -15
- package/dist/{meta-BXKLFTgG.d.mts → meta-CR-D39hQ.d.mts} +7 -5
- package/dist/{meta-BXKLFTgG.d.ts → meta-CR-D39hQ.d.ts} +7 -5
- package/dist/rpc/bullmq/index.d.mts +5 -5
- package/dist/rpc/bullmq/index.d.ts +5 -5
- package/dist/rpc/bullmq/index.js +15 -14
- package/dist/rpc/bullmq/index.mjs +4 -3
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +15 -14
- package/dist/rpc/kafka/index.mjs +3 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +14 -13
- package/dist/rpc/nats/index.mjs +4 -3
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +16 -15
- package/dist/rpc/rabbitmq/index.mjs +4 -3
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +14 -13
- package/dist/rpc/redis/index.mjs +4 -3
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-h40T3cRG.d.mts → types-BF1TDbFV.d.ts} +4 -3
- package/dist/{types-BtbL49Zs.d.mts → types-DYRu0vic.d.ts} +4 -3
- package/dist/{types-VFzEM7LL.d.ts → types-DYviSl5B.d.mts} +4 -3
- package/dist/{types-m3IEDKjP.d.ts → types-DqH1qA-q.d.mts} +4 -3
- package/package.json +8 -5
- package/register/export.mjs +30 -0
- package/register/index.mjs +50 -40
- package/register/loader.mjs +384 -367
- package/register/utils.mjs +60 -56
- package/dist/chunk-J5CFUN4V.js +0 -73
- package/dist/chunk-WHJ5FALK.mjs +0 -73
package/assets/ps.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://unpkg.com/phecda-server/assets/schema.json",
|
|
3
|
-
"resolve": [
|
|
4
|
-
{
|
|
5
|
-
"source": "controller",
|
|
6
|
-
"importer": "http",
|
|
7
|
-
"path": ".ps/http.js"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"source": "rpc",
|
|
11
|
-
"importer": "client",
|
|
12
|
-
"path": ".ps/rpc.js"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"unimport": {
|
|
16
|
-
"dirs": ["."],
|
|
17
|
-
"dirsScanOptions": {
|
|
18
|
-
"filePatterns": ["*.{service,controller,module,rpc,
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"virtualFile": {},
|
|
22
|
-
"moduleFile": []
|
|
23
|
-
|
|
24
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/phecda-server/assets/schema.json",
|
|
3
|
+
"resolve": [
|
|
4
|
+
{
|
|
5
|
+
"source": "controller",
|
|
6
|
+
"importer": "http",
|
|
7
|
+
"path": ".ps/http.js"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"source": "rpc",
|
|
11
|
+
"importer": "client",
|
|
12
|
+
"path": ".ps/rpc.js"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"unimport": {
|
|
16
|
+
"dirs": ["."],
|
|
17
|
+
"dirsScanOptions": {
|
|
18
|
+
"filePatterns": ["*.{service,controller,module,rpc,solo,guard,extension,pipe,filter,addon}.ts"]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"virtualFile": {},
|
|
22
|
+
"moduleFile": []
|
|
23
|
+
|
|
24
|
+
}
|
package/assets/schema.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"type": "object",
|
|
4
|
-
"properties": {
|
|
5
|
-
"resolve": {
|
|
6
|
-
"type": "array",
|
|
7
|
-
"items": {
|
|
8
|
-
"type": "object",
|
|
9
|
-
"properties": {
|
|
10
|
-
"source": {
|
|
11
|
-
"type": "string",
|
|
12
|
-
"description": "The middle name of the imported file."
|
|
13
|
-
},
|
|
14
|
-
"importer": {
|
|
15
|
-
"type": "string",
|
|
16
|
-
"description": "The middle name of the importer file."
|
|
17
|
-
},
|
|
18
|
-
"path": {
|
|
19
|
-
"type": "string",
|
|
20
|
-
|
|
21
|
-
"description": "Redirect path"
|
|
22
|
-
},
|
|
23
|
-
"filename": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"optional": true,
|
|
26
|
-
|
|
27
|
-
"description": "generate split chunk,only work in vite"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"required": ["source", "path", "importer"]
|
|
31
|
-
},
|
|
32
|
-
"description": "Resolve and redirect modules path"
|
|
33
|
-
},
|
|
34
|
-
"moduleFile": {
|
|
35
|
-
"type": "array",
|
|
36
|
-
"items": {
|
|
37
|
-
"type": "string"
|
|
38
|
-
},
|
|
39
|
-
"description": "Including the module's file middle name, such as controller mapping to xx.controller.ts"
|
|
40
|
-
},
|
|
41
|
-
"virtualFile": {
|
|
42
|
-
"type": "object",
|
|
43
|
-
"additionalProperties": {
|
|
44
|
-
"type": "string"
|
|
45
|
-
},
|
|
46
|
-
"description": "Virtual module, just like in Vite."
|
|
47
|
-
},
|
|
48
|
-
"unimport": {
|
|
49
|
-
"type": "object",
|
|
50
|
-
"description": "Includes the arguments passed to unimport
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
"required": ["resolve"]
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"resolve": {
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"source": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "The middle name of the imported file."
|
|
13
|
+
},
|
|
14
|
+
"importer": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The middle name of the importer file."
|
|
17
|
+
},
|
|
18
|
+
"path": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
|
|
21
|
+
"description": "Redirect path"
|
|
22
|
+
},
|
|
23
|
+
"filename": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"optional": true,
|
|
26
|
+
|
|
27
|
+
"description": "generate split chunk,only work in vite"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": ["source", "path", "importer"]
|
|
31
|
+
},
|
|
32
|
+
"description": "Resolve and redirect modules path"
|
|
33
|
+
},
|
|
34
|
+
"moduleFile": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"description": "Including the module's file middle name, such as controller mapping to xx.controller.ts"
|
|
40
|
+
},
|
|
41
|
+
"virtualFile": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"additionalProperties": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"description": "Virtual module, just like in Vite."
|
|
47
|
+
},
|
|
48
|
+
"unimport": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"description": "Includes the arguments passed to unimport"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
"required": ["resolve"]
|
|
55
|
+
}
|
package/bin/cli.mjs
CHANGED
|
@@ -3,11 +3,18 @@ import { fork } from 'child_process'
|
|
|
3
3
|
import { createRequire } from 'module'
|
|
4
4
|
import { fileURLToPath } from 'url'
|
|
5
5
|
|
|
6
|
-
import { dirname,
|
|
6
|
+
import { dirname, resolve } from 'path'
|
|
7
7
|
import pc from 'picocolors'
|
|
8
8
|
import cac from 'cac'
|
|
9
9
|
import fse from 'fs-extra'
|
|
10
|
-
import { log } from '../dist/index.mjs'
|
|
10
|
+
import { log as psLog } from '../dist/index.mjs'
|
|
11
|
+
|
|
12
|
+
const log = (...args) => {
|
|
13
|
+
if (process.env.PS_BAN_CLI_LOG)
|
|
14
|
+
return
|
|
15
|
+
|
|
16
|
+
psLog(...args)
|
|
17
|
+
}
|
|
11
18
|
|
|
12
19
|
const cli = cac('phecda').option('-c,--config <config>', 'config file', {
|
|
13
20
|
default: 'ps.json',
|
|
@@ -30,7 +37,7 @@ if (nodeVersion < 18.19) {
|
|
|
30
37
|
|
|
31
38
|
function startChild(file, args) {
|
|
32
39
|
child = fork(file, {
|
|
33
|
-
env: {
|
|
40
|
+
env: { ...process.env },
|
|
34
41
|
stdio: 'inherit',
|
|
35
42
|
execArgv: [
|
|
36
43
|
nodeVersion < 18.19
|
|
@@ -42,15 +49,12 @@ function startChild(file, args) {
|
|
|
42
49
|
|
|
43
50
|
closePromise = new Promise((resolve) => {
|
|
44
51
|
child.once('exit', (code) => {
|
|
45
|
-
if (code ===
|
|
46
|
-
log('only generate code')
|
|
47
|
-
process.exit(0)
|
|
48
|
-
}
|
|
49
|
-
if (code >= 2) {
|
|
50
|
-
// for relaunch
|
|
51
|
-
log('relaunch...')
|
|
52
|
+
if (code === 4171)
|
|
52
53
|
startChild(file, args)
|
|
53
|
-
|
|
54
|
+
|
|
55
|
+
if (code === 4172)
|
|
56
|
+
return process.exit()
|
|
57
|
+
|
|
54
58
|
child = undefined
|
|
55
59
|
|
|
56
60
|
resolve()
|
|
@@ -80,11 +84,11 @@ cli
|
|
|
80
84
|
default: 'tsconfig.json',
|
|
81
85
|
})
|
|
82
86
|
.action(async (root, options) => {
|
|
83
|
-
if (
|
|
84
|
-
root
|
|
87
|
+
if (root)
|
|
88
|
+
process.chdir(root)
|
|
85
89
|
|
|
86
|
-
const tsconfigPath =
|
|
87
|
-
const psconfigPath =
|
|
90
|
+
const tsconfigPath = options.tsconfig
|
|
91
|
+
const psconfigPath = options.config
|
|
88
92
|
|
|
89
93
|
if (!fse.existsSync(tsconfigPath)) {
|
|
90
94
|
log(`create ${tsconfigPath}`)
|
|
@@ -108,10 +112,18 @@ cli
|
|
|
108
112
|
.command('<file> [root]', 'run file')
|
|
109
113
|
.alias('run')
|
|
110
114
|
.allowUnknownOptions()
|
|
111
|
-
.
|
|
115
|
+
.option('-p,--prod [prod]', 'prod mode', {
|
|
116
|
+
default: false,
|
|
117
|
+
})
|
|
112
118
|
.action((file, root, options) => {
|
|
113
119
|
if (root)
|
|
114
|
-
process.
|
|
120
|
+
process.chdir(root)
|
|
121
|
+
|
|
122
|
+
if (options.prod)
|
|
123
|
+
process.env.NODE_ENV = 'production'
|
|
124
|
+
else
|
|
125
|
+
process.env.NODE_ENV = 'development'
|
|
126
|
+
|
|
115
127
|
process.env.PS_CONFIG_FILE = options.config
|
|
116
128
|
|
|
117
129
|
log('process start!')
|
|
@@ -119,6 +131,7 @@ cli
|
|
|
119
131
|
startChild(file, options['--'])
|
|
120
132
|
console.log(`${pc.green('->')} press ${pc.green('e')} to exit`)
|
|
121
133
|
console.log(`${pc.green('->')} press ${pc.green('r')} to relaunch`)
|
|
134
|
+
console.log(`${pc.green('->')} press ${pc.green('c')} to clear terminal`)
|
|
122
135
|
|
|
123
136
|
process.stdin.on('data', async (data) => {
|
|
124
137
|
const input = data.toString().trim().toLocaleLowerCase()
|
|
@@ -149,7 +162,7 @@ cli
|
|
|
149
162
|
.allowUnknownOptions()
|
|
150
163
|
.action((file, root, options) => {
|
|
151
164
|
if (root)
|
|
152
|
-
process.
|
|
165
|
+
process.chdir(root)
|
|
153
166
|
process.env.PS_GENERATE = 'true'
|
|
154
167
|
process.env.PS_CONFIG_FILE = options.config
|
|
155
168
|
startChild(file, options['--'])
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _class;var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/common.ts
|
|
5
|
+
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
+
var IS_DEV = process.env.NODE_ENV === "development";
|
|
7
|
+
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
|
+
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
|
+
var IS_PURE = !!process.env.PS_PURE;
|
|
10
|
+
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
11
|
+
var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
12
|
+
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 4171] = "RELAUNCH";
|
|
13
|
+
PS_EXIT_CODE2[PS_EXIT_CODE2["EXIT"] = 4172] = "EXIT";
|
|
14
|
+
return PS_EXIT_CODE2;
|
|
15
|
+
}({});
|
|
16
|
+
|
|
17
|
+
// src/utils.ts
|
|
18
|
+
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
19
|
+
var _tsmixer = require('ts-mixer');
|
|
20
|
+
var isObject = /* @__PURE__ */ __name((fn) => fn !== null && typeof fn === "object", "isObject");
|
|
21
|
+
var isPlainObject = /* @__PURE__ */ __name((fn) => {
|
|
22
|
+
if (!isObject(fn)) return false;
|
|
23
|
+
const proto = Object.getPrototypeOf(fn);
|
|
24
|
+
if (proto === null) return true;
|
|
25
|
+
const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
26
|
+
return typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
|
|
27
|
+
}, "isPlainObject");
|
|
28
|
+
var InternalLogger = (_class = class InternalLogger2 {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
|
|
29
|
+
static {
|
|
30
|
+
__name(this, "InternalLogger");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
__init() {this.color = {
|
|
34
|
+
debug: "bgMagenta",
|
|
35
|
+
error: "red",
|
|
36
|
+
info: "gray",
|
|
37
|
+
warn: "yellow",
|
|
38
|
+
log: "green"
|
|
39
|
+
}}
|
|
40
|
+
__init2() {this.dateFormatter = new Intl.DateTimeFormat(void 0, {
|
|
41
|
+
year: "numeric",
|
|
42
|
+
hour: "numeric",
|
|
43
|
+
minute: "numeric",
|
|
44
|
+
second: "numeric",
|
|
45
|
+
day: "2-digit",
|
|
46
|
+
month: "2-digit"
|
|
47
|
+
})}
|
|
48
|
+
diffTimestamp() {
|
|
49
|
+
const now = Date.now();
|
|
50
|
+
if (!this.time) return "";
|
|
51
|
+
const diff = now - this.time;
|
|
52
|
+
this.time = now;
|
|
53
|
+
return diff ? _picocolors2.default.yellow(` +${diff}`) : "";
|
|
54
|
+
}
|
|
55
|
+
colorize(message, logLevel) {
|
|
56
|
+
return _picocolors2.default[this.color[logLevel]](message);
|
|
57
|
+
}
|
|
58
|
+
isAllowLog(level) {
|
|
59
|
+
const logLevel = {
|
|
60
|
+
debug: -1,
|
|
61
|
+
info: 0,
|
|
62
|
+
log: 1,
|
|
63
|
+
warn: 2,
|
|
64
|
+
error: 3
|
|
65
|
+
}[level];
|
|
66
|
+
if (logLevel < LOG_LEVEL) return false;
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
stringifyMessage(message, logLevel) {
|
|
70
|
+
if (typeof message === "function") {
|
|
71
|
+
const messageAsStr = Function.prototype.toString.call(message);
|
|
72
|
+
const isClass = messageAsStr.startsWith("class ");
|
|
73
|
+
if (isClass) {
|
|
74
|
+
return this.stringifyMessage(message.name, logLevel);
|
|
75
|
+
}
|
|
76
|
+
return this.stringifyMessage(message(), logLevel);
|
|
77
|
+
}
|
|
78
|
+
return isPlainObject(message) || Array.isArray(message) ? `${this.colorize("Object:", logLevel)}
|
|
79
|
+
${JSON.stringify(message, (key, value) => typeof value === "bigint" ? value.toString() : value, 2)}
|
|
80
|
+
` : this.colorize(message, logLevel);
|
|
81
|
+
}
|
|
82
|
+
log(msg, level, ctx) {
|
|
83
|
+
if (!this.isAllowLog(level)) return;
|
|
84
|
+
msg = this.stringifyMessage(msg, level);
|
|
85
|
+
const pidMsg = this.colorize(`[${process.env.PS_APP_NAME || "phecda-server"}] ${process.pid}`, level);
|
|
86
|
+
const ctxMsg = ctx ? this.colorize(_picocolors2.default.bold(`[${ctx}] `), level) : "";
|
|
87
|
+
const timeDiff = this.diffTimestamp();
|
|
88
|
+
const levelMsg = this.colorize(level.toUpperCase().padStart(7, " "), level);
|
|
89
|
+
process.stdout.write(`${pidMsg} ${this.dateFormatter.format(Date.now())} ${levelMsg} ${ctxMsg}${msg}${timeDiff}
|
|
90
|
+
`);
|
|
91
|
+
}
|
|
92
|
+
}, _class);
|
|
93
|
+
var _logger = new InternalLogger();
|
|
94
|
+
function setLogger(logger) {
|
|
95
|
+
_logger = logger;
|
|
96
|
+
}
|
|
97
|
+
__name(setLogger, "setLogger");
|
|
98
|
+
function getLogger() {
|
|
99
|
+
return _logger;
|
|
100
|
+
}
|
|
101
|
+
__name(getLogger, "getLogger");
|
|
102
|
+
function log(msg, level = "log", ctx) {
|
|
103
|
+
_logger.log(msg, level, ctx);
|
|
104
|
+
}
|
|
105
|
+
__name(log, "log");
|
|
106
|
+
function runMiddleware(ctx, middleware) {
|
|
107
|
+
return new Promise((resolve) => {
|
|
108
|
+
middleware(ctx.getRequest(), ctx.getResponse(), resolve);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
__name(runMiddleware, "runMiddleware");
|
|
112
|
+
|
|
113
|
+
// src/hmr.ts
|
|
114
|
+
function HMR(cb) {
|
|
115
|
+
if (IS_DEV) {
|
|
116
|
+
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
117
|
+
globalThis.__PS_HMR__.push(cb);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
__name(HMR, "HMR");
|
|
121
|
+
async function RELOAD(oldModels, newModels) {
|
|
122
|
+
log("reload module...");
|
|
123
|
+
for (const cb of globalThis.__PS_HMR__) await cb(oldModels, newModels);
|
|
124
|
+
log("reload done");
|
|
125
|
+
}
|
|
126
|
+
__name(RELOAD, "RELOAD");
|
|
127
|
+
function RELAUNCH() {
|
|
128
|
+
if (IS_DEV) {
|
|
129
|
+
log("relaunch...");
|
|
130
|
+
process.exit(PS_EXIT_CODE.RELAUNCH);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
__name(RELAUNCH, "RELAUNCH");
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_DEV = IS_DEV; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; exports.IS_PURE = IS_PURE; exports.LOG_LEVEL = LOG_LEVEL; exports.PS_EXIT_CODE = PS_EXIT_CODE; exports.setLogger = setLogger; exports.getLogger = getLogger; exports.log = log; exports.runMiddleware = runMiddleware; exports.Mixin = _tsmixer.Mixin; exports.HMR = HMR; exports.RELOAD = RELOAD; exports.RELAUNCH = RELAUNCH;
|