phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.11
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 +1 -1
- package/assets/schema.json +55 -55
- package/bin/cli.mjs +33 -25
- package/dist/chunk-4LLLQOMF.js +152 -0
- package/dist/{chunk-7YQ57BQS.js → chunk-6OQ2SB5W.js} +137 -69
- package/dist/{chunk-GSPBHZBH.js → chunk-G7JFKM2M.js} +96 -80
- 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-XYVMNY2X.mjs → chunk-YCES6ABN.mjs} +124 -56
- package/dist/{chunk-V7EI76QQ.mjs → chunk-Z7NAAE4M.mjs} +48 -32
- 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 +44 -38
- package/dist/index.d.ts +44 -38
- 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 -6
- package/register/export.mjs +30 -0
- package/register/index.mjs +50 -40
- package/register/loader.mjs +110 -74
- package/register/utils.mjs +86 -56
- package/dist/chunk-J5CFUN4V.js +0 -73
- package/dist/chunk-WHJ5FALK.mjs +0 -73
package/register/loader.mjs
CHANGED
|
@@ -2,26 +2,57 @@ import { fileURLToPath, pathToFileURL } from 'url'
|
|
|
2
2
|
import { writeFile } from 'fs/promises'
|
|
3
3
|
import {
|
|
4
4
|
basename,
|
|
5
|
-
|
|
5
|
+
dirname,
|
|
6
6
|
isAbsolute,
|
|
7
7
|
relative,
|
|
8
8
|
resolve as resolvePath,
|
|
9
9
|
} from 'path'
|
|
10
|
+
import { existsSync } from 'fs'
|
|
10
11
|
import { createRequire } from 'module'
|
|
11
12
|
import ts from 'typescript'
|
|
12
13
|
import chokidar from 'chokidar'
|
|
13
|
-
import
|
|
14
|
+
import Debug from 'debug'
|
|
14
15
|
import { compile, genUnImportRet, handleClassTypes, slash } from './utils.mjs'
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
const require = createRequire(import.meta.url)
|
|
18
|
+
const debug = Debug('phecda-server/loader')
|
|
17
19
|
|
|
18
20
|
const isLowVersion = parseFloat(process.version.slice(1)) < 18.19
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const IS_DEV = process.env.NODE_ENV === 'development'
|
|
22
|
+
let port
|
|
23
|
+
let config
|
|
24
|
+
const workdir = process.cwd()
|
|
25
|
+
const configPath = resolvePath(
|
|
26
|
+
workdir,
|
|
27
|
+
process.env.PS_CONFIG_FILE || 'ps.json',
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
// unimport
|
|
31
|
+
let unimportRet
|
|
32
|
+
const dtsPath = process.env.PS_DTS_PATH || 'ps.d.ts'
|
|
33
|
+
|
|
34
|
+
// graph
|
|
35
|
+
let entryUrl
|
|
36
|
+
const watchFiles = new Set()
|
|
37
|
+
const filesRecord = new Map()
|
|
38
|
+
const moduleGraph = {}
|
|
39
|
+
// ts
|
|
40
|
+
let tsconfig = {
|
|
22
41
|
module: ts.ModuleKind.ESNext,
|
|
23
42
|
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
24
43
|
}
|
|
44
|
+
const EXTENSIONS = [ts.Extension.Ts, ts.Extension.Tsx, ts.Extension.Mts]
|
|
45
|
+
const tsconfigPath = resolvePath(process.cwd(), 'tsconfig.json')
|
|
46
|
+
const tsRet = ts.readConfigFile(tsconfigPath, ts.sys.readFile)
|
|
47
|
+
if (!tsRet.error) {
|
|
48
|
+
const { error, options } = ts.parseJsonConfigFileContent(
|
|
49
|
+
tsRet.config,
|
|
50
|
+
ts.sys,
|
|
51
|
+
dirname(tsconfigPath),
|
|
52
|
+
)
|
|
53
|
+
if (!error)
|
|
54
|
+
tsconfig = options
|
|
55
|
+
}
|
|
25
56
|
const moduleResolutionCache = ts.createModuleResolutionCache(
|
|
26
57
|
ts.sys.getCurrentDirectory(),
|
|
27
58
|
x => x,
|
|
@@ -32,32 +63,32 @@ const host = {
|
|
|
32
63
|
readFile: ts.sys.readFile,
|
|
33
64
|
}
|
|
34
65
|
|
|
35
|
-
let unimportRet
|
|
36
|
-
const dtsPath = 'ps.d.ts'
|
|
37
|
-
|
|
38
66
|
if (isLowVersion)
|
|
39
67
|
await initialize()
|
|
40
68
|
|
|
41
|
-
let config
|
|
42
|
-
|
|
43
|
-
const workdir = process.env.PS_WORKDIR || process.cwd()
|
|
44
|
-
|
|
45
|
-
const configPath = resolvePath(
|
|
46
|
-
workdir,
|
|
47
|
-
process.env.PS_CONFIG_FILE || 'ps.json',
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
const require = createRequire(import.meta.url)
|
|
51
69
|
export async function initialize(data) {
|
|
52
70
|
if (data)
|
|
53
71
|
port = data.port
|
|
54
|
-
|
|
72
|
+
|
|
73
|
+
debug('read config...')
|
|
55
74
|
|
|
56
75
|
config = require(configPath)
|
|
76
|
+
// const unconfigRet = await loadConfig({
|
|
77
|
+
// sources: [
|
|
78
|
+
// {
|
|
79
|
+
// files: configPath,
|
|
80
|
+
// extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json', ''],
|
|
81
|
+
// },
|
|
82
|
+
// ],
|
|
83
|
+
// merge: false,
|
|
84
|
+
// })
|
|
85
|
+
// config = unconfigRet.config
|
|
57
86
|
if (!config.virtualFile)
|
|
58
87
|
config.virtualFile = {}
|
|
88
|
+
if (!config.paths)
|
|
89
|
+
config.paths = {}
|
|
59
90
|
|
|
60
|
-
if (
|
|
91
|
+
if (IS_DEV) {
|
|
61
92
|
chokidar.watch(configPath, { persistent: true }).on('change', () => {
|
|
62
93
|
port.postMessage(
|
|
63
94
|
JSON.stringify({
|
|
@@ -71,17 +102,18 @@ export async function initialize(data) {
|
|
|
71
102
|
return
|
|
72
103
|
unimportRet = await genUnImportRet(config.unimport)
|
|
73
104
|
if (unimportRet) {
|
|
74
|
-
|
|
105
|
+
debug('auto import...')
|
|
75
106
|
await unimportRet.init()
|
|
76
107
|
|
|
108
|
+
const unimportDtsPath = resolvePath(workdir, dtsPath)
|
|
77
109
|
writeFile(
|
|
78
|
-
|
|
110
|
+
unimportDtsPath,
|
|
79
111
|
handleClassTypes(
|
|
80
112
|
await unimportRet.generateTypeDeclarations({
|
|
81
113
|
resolvePath: (i) => {
|
|
82
114
|
if (i.from.startsWith('.') || isAbsolute(i.from)) {
|
|
83
115
|
const related = slash(
|
|
84
|
-
relative(
|
|
116
|
+
relative(dirname(unimportDtsPath), i.from).replace(/\.ts(x)?$/, ''),
|
|
85
117
|
)
|
|
86
118
|
|
|
87
119
|
return !related.startsWith('.') ? `./${related}` : related
|
|
@@ -94,12 +126,6 @@ export async function initialize(data) {
|
|
|
94
126
|
}
|
|
95
127
|
}
|
|
96
128
|
|
|
97
|
-
const watchFiles = new Set()
|
|
98
|
-
const filesRecord = new Map()
|
|
99
|
-
const moduleGraph = {}
|
|
100
|
-
|
|
101
|
-
let entryUrl
|
|
102
|
-
|
|
103
129
|
function addUrlToGraph(url, parent) {
|
|
104
130
|
if (!(url in moduleGraph))
|
|
105
131
|
moduleGraph[url] = new Set()
|
|
@@ -127,25 +153,33 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
127
153
|
}
|
|
128
154
|
// entrypoint
|
|
129
155
|
if (!context.parentURL) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
:
|
|
135
|
-
|
|
136
|
-
|
|
156
|
+
if (/^file:\/\/\//.test(specifier) && existsSync(fileURLToPath(specifier))) {
|
|
157
|
+
entryUrl = specifier
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
format: EXTENSIONS.some(ext => specifier.endsWith(ext))
|
|
161
|
+
? 'ts'
|
|
162
|
+
: undefined,
|
|
163
|
+
url: specifier,
|
|
164
|
+
shortCircuit: true,
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
// won't resolve virtual file as entry in vite
|
|
169
|
+
return nextResolve(specifier)
|
|
137
170
|
}
|
|
138
171
|
}
|
|
139
172
|
// url import
|
|
140
173
|
// it seems useless
|
|
141
|
-
if (/^file:\/\/\//.test(specifier) && extname(specifier) === '.ts') {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
174
|
+
// if (/^file:\/\/\//.test(specifier) && extname(specifier) === '.ts') {
|
|
175
|
+
// const url = addUrlToGraph(specifier, context.parentURL.split('?')[0])
|
|
176
|
+
// return {
|
|
177
|
+
// format: 'ts',
|
|
178
|
+
// url,
|
|
179
|
+
// shortCircuit: true,
|
|
180
|
+
// }
|
|
181
|
+
// }
|
|
182
|
+
|
|
149
183
|
|
|
150
184
|
// hmr import
|
|
151
185
|
if (
|
|
@@ -169,7 +203,7 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
169
203
|
moduleResolutionCache,
|
|
170
204
|
)
|
|
171
205
|
|
|
172
|
-
// import
|
|
206
|
+
// import among files in local project
|
|
173
207
|
if (
|
|
174
208
|
resolvedModule
|
|
175
209
|
&& !resolvedModule.resolvedFileName.includes('/node_modules/')
|
|
@@ -202,6 +236,7 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
202
236
|
}
|
|
203
237
|
}
|
|
204
238
|
|
|
239
|
+
|
|
205
240
|
const resolveRet = await nextResolve(specifier)
|
|
206
241
|
|
|
207
242
|
// ts resolve fail in some cases
|
|
@@ -213,6 +248,9 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
213
248
|
// @todo the first params may be url or path, need to distinguish
|
|
214
249
|
|
|
215
250
|
export const load = async (url, context, nextLoad) => {
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
216
254
|
if (config.virtualFile[url]) {
|
|
217
255
|
return {
|
|
218
256
|
format: 'module',
|
|
@@ -221,6 +259,14 @@ export const load = async (url, context, nextLoad) => {
|
|
|
221
259
|
}
|
|
222
260
|
}
|
|
223
261
|
|
|
262
|
+
let mode
|
|
263
|
+
if (context.importAttributes.ps) {
|
|
264
|
+
mode = context.importAttributes.ps
|
|
265
|
+
delete context.importAttributes.ps
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
224
270
|
url = url.split('?')[0]
|
|
225
271
|
if (
|
|
226
272
|
!url.includes('/node_modules/')
|
|
@@ -229,32 +275,17 @@ export const load = async (url, context, nextLoad) => {
|
|
|
229
275
|
&& !isLowVersion
|
|
230
276
|
) {
|
|
231
277
|
watchFiles.add(url)
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
// }),
|
|
244
|
-
// )
|
|
245
|
-
// }
|
|
246
|
-
// catch (e) {
|
|
247
|
-
// port.postMessage(
|
|
248
|
-
// JSON.stringify({
|
|
249
|
-
// type: 'relaunch',
|
|
250
|
-
// }),
|
|
251
|
-
// )
|
|
252
|
-
// }
|
|
253
|
-
// }
|
|
254
|
-
// }),
|
|
255
|
-
// )
|
|
256
|
-
|
|
257
|
-
if (!process.env.PS_HMR_BAN) {
|
|
278
|
+
|
|
279
|
+
if (IS_DEV && mode !== 'not-hmr') {
|
|
280
|
+
if (isModuleFileUrl(url)) {
|
|
281
|
+
port.postMessage(
|
|
282
|
+
JSON.stringify({
|
|
283
|
+
type: 'init',
|
|
284
|
+
files: [fileURLToPath(url)],
|
|
285
|
+
}),
|
|
286
|
+
)
|
|
287
|
+
}
|
|
288
|
+
|
|
258
289
|
chokidar.watch(fileURLToPath(url), { persistent: true }).on(
|
|
259
290
|
'change',
|
|
260
291
|
debounce(() => {
|
|
@@ -289,9 +320,14 @@ export const load = async (url, context, nextLoad) => {
|
|
|
289
320
|
|
|
290
321
|
const code
|
|
291
322
|
= typeof source === 'string' ? source : Buffer.from(source).toString()
|
|
292
|
-
|
|
323
|
+
|
|
324
|
+
const compiled = (await compile(code, url)).replace(/_ts_metadata\(\"design:paramtypes\"\,/g, '_ts_metadata("design:paramtypes",()=>')// handle cycle
|
|
325
|
+
|
|
293
326
|
if (unimportRet) {
|
|
327
|
+
|
|
328
|
+
|
|
294
329
|
const { injectImports } = unimportRet
|
|
330
|
+
|
|
295
331
|
return {
|
|
296
332
|
format: 'module',
|
|
297
333
|
source: (
|
|
@@ -357,7 +393,7 @@ export function isModuleFileUrl(url) {
|
|
|
357
393
|
'addon',
|
|
358
394
|
'filter',
|
|
359
395
|
'pipe',
|
|
360
|
-
'
|
|
396
|
+
'solo',
|
|
361
397
|
].includes(midName)
|
|
362
398
|
)
|
|
363
399
|
return true
|
package/register/utils.mjs
CHANGED
|
@@ -1,56 +1,86 @@
|
|
|
1
|
-
import { basename } from 'path'
|
|
2
|
-
import { transform } from '@swc-node/core'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
export function
|
|
55
|
-
|
|
56
|
-
}
|
|
1
|
+
import { basename } from 'path'
|
|
2
|
+
import { transform } from '@swc-node/core'
|
|
3
|
+
import psExports from './export.mjs'
|
|
4
|
+
const injectInlineSourceMap = ({ code, map }) => {
|
|
5
|
+
if (map) {
|
|
6
|
+
const base64Map = Buffer.from(map, 'utf8').toString('base64')
|
|
7
|
+
const sourceMapContent = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`
|
|
8
|
+
return `${code}\n${sourceMapContent}`
|
|
9
|
+
}
|
|
10
|
+
return code
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function compile(sourcecode, filename) {
|
|
14
|
+
if (filename.endsWith('.d.ts'))
|
|
15
|
+
return ''
|
|
16
|
+
|
|
17
|
+
const { code, map } = await transform(sourcecode, filename, {
|
|
18
|
+
sourcemap: true,
|
|
19
|
+
module: 'es6',
|
|
20
|
+
emitDecoratorMetadata: true,
|
|
21
|
+
experimentalDecorators: true,
|
|
22
|
+
esModuleInterop: false,
|
|
23
|
+
swc: {
|
|
24
|
+
|
|
25
|
+
jsc: {
|
|
26
|
+
parser: {
|
|
27
|
+
syntax: "typescript",
|
|
28
|
+
importAttributes: true,
|
|
29
|
+
decorators: true,
|
|
30
|
+
tsx: false,
|
|
31
|
+
dynamicImport: true,
|
|
32
|
+
strictPropertyInitialization: false
|
|
33
|
+
},
|
|
34
|
+
experimental: {
|
|
35
|
+
keepImportAssertions: true
|
|
36
|
+
},
|
|
37
|
+
transform: {
|
|
38
|
+
legacyDecorator: true,
|
|
39
|
+
decoratorMetadata: true
|
|
40
|
+
}
|
|
41
|
+
// parser: {
|
|
42
|
+
// importAttributes: true
|
|
43
|
+
// },
|
|
44
|
+
// experimental: {
|
|
45
|
+
// keepImportAssertions: true
|
|
46
|
+
// }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return injectInlineSourceMap({ code, map })
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function genUnImportRet(opts) {
|
|
55
|
+
try {
|
|
56
|
+
const { createUnimport } = await import('unimport')
|
|
57
|
+
return createUnimport({
|
|
58
|
+
...opts,
|
|
59
|
+
|
|
60
|
+
presets: [
|
|
61
|
+
{
|
|
62
|
+
from: 'phecda-server',
|
|
63
|
+
imports: psExports,
|
|
64
|
+
},
|
|
65
|
+
]
|
|
66
|
+
.concat(opts.presets || []),
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
console.error(e)
|
|
71
|
+
return false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function handleClassTypes(input) {
|
|
76
|
+
return input.replace(/const\s+(\w+)\s*:\s*typeof\s+import\(['"](.+)['"]\)\['(\w+)'\]/g, (_, n, p, e) => {
|
|
77
|
+
// TestController in test.controller
|
|
78
|
+
if (p.startsWith('./') && (basename(p).replace('.', '').toLowerCase() === e.toLowerCase()))
|
|
79
|
+
return `${_}\n type ${n} = InstanceType<typeof import('${p}')['${e}']>`
|
|
80
|
+
|
|
81
|
+
return _
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
export function slash(str) {
|
|
85
|
+
return str.replace(/\\/g, '/')
|
|
86
|
+
}
|
package/dist/chunk-J5CFUN4V.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }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_HMR = process.env.NODE_ENV === "development";
|
|
7
|
-
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
|
-
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
|
-
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
-
var PS_EXIT_CODE;
|
|
11
|
-
(function(PS_EXIT_CODE2) {
|
|
12
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
|
|
13
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
|
|
14
|
-
})(PS_EXIT_CODE || (PS_EXIT_CODE = exports.PS_EXIT_CODE = {}));
|
|
15
|
-
|
|
16
|
-
// src/utils.ts
|
|
17
|
-
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
18
|
-
var _tsmixer = require('ts-mixer');
|
|
19
|
-
var time;
|
|
20
|
-
var internalLogger;
|
|
21
|
-
function setLogger(logger) {
|
|
22
|
-
internalLogger = logger;
|
|
23
|
-
}
|
|
24
|
-
__name(setLogger, "setLogger");
|
|
25
|
-
function getLogger() {
|
|
26
|
-
return internalLogger;
|
|
27
|
-
}
|
|
28
|
-
__name(getLogger, "getLogger");
|
|
29
|
-
function log(msg, level = "log") {
|
|
30
|
-
if (internalLogger) internalLogger[level](msg);
|
|
31
|
-
const logLevel = {
|
|
32
|
-
debug: -1,
|
|
33
|
-
info: 0,
|
|
34
|
-
log: 1,
|
|
35
|
-
warn: 2,
|
|
36
|
-
error: 3
|
|
37
|
-
}[level];
|
|
38
|
-
if (logLevel < LOG_LEVEL) return;
|
|
39
|
-
const color = {
|
|
40
|
-
debug: "bgMagenta",
|
|
41
|
-
error: "red",
|
|
42
|
-
info: "gray",
|
|
43
|
-
warn: "yellow",
|
|
44
|
-
log: "green"
|
|
45
|
-
}[level];
|
|
46
|
-
const date = /* @__PURE__ */ new Date();
|
|
47
|
-
const current = Date.now();
|
|
48
|
-
const interval = time && current - time ? `+${current - time}` : "";
|
|
49
|
-
time = current;
|
|
50
|
-
console[level](`${_picocolors2.default.magenta("[phecda-server]")} ${_picocolors2.default.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${_picocolors2.default[color](msg)} ${_picocolors2.default.gray(interval)}`);
|
|
51
|
-
}
|
|
52
|
-
__name(log, "log");
|
|
53
|
-
function runMiddleware(ctx, middleware) {
|
|
54
|
-
return new Promise((resolve) => {
|
|
55
|
-
middleware(ctx.getRequest(), ctx.getResponse(), resolve);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
__name(runMiddleware, "runMiddleware");
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_HMR = IS_HMR; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; 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;
|
package/dist/chunk-WHJ5FALK.mjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
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_HMR = process.env.NODE_ENV === "development";
|
|
7
|
-
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
|
-
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
|
-
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
-
var PS_EXIT_CODE;
|
|
11
|
-
(function(PS_EXIT_CODE2) {
|
|
12
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
|
|
13
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
|
|
14
|
-
})(PS_EXIT_CODE || (PS_EXIT_CODE = {}));
|
|
15
|
-
|
|
16
|
-
// src/utils.ts
|
|
17
|
-
import pc from "picocolors";
|
|
18
|
-
import { Mixin } from "ts-mixer";
|
|
19
|
-
var time;
|
|
20
|
-
var internalLogger;
|
|
21
|
-
function setLogger(logger) {
|
|
22
|
-
internalLogger = logger;
|
|
23
|
-
}
|
|
24
|
-
__name(setLogger, "setLogger");
|
|
25
|
-
function getLogger() {
|
|
26
|
-
return internalLogger;
|
|
27
|
-
}
|
|
28
|
-
__name(getLogger, "getLogger");
|
|
29
|
-
function log(msg, level = "log") {
|
|
30
|
-
if (internalLogger) internalLogger[level](msg);
|
|
31
|
-
const logLevel = {
|
|
32
|
-
debug: -1,
|
|
33
|
-
info: 0,
|
|
34
|
-
log: 1,
|
|
35
|
-
warn: 2,
|
|
36
|
-
error: 3
|
|
37
|
-
}[level];
|
|
38
|
-
if (logLevel < LOG_LEVEL) return;
|
|
39
|
-
const color = {
|
|
40
|
-
debug: "bgMagenta",
|
|
41
|
-
error: "red",
|
|
42
|
-
info: "gray",
|
|
43
|
-
warn: "yellow",
|
|
44
|
-
log: "green"
|
|
45
|
-
}[level];
|
|
46
|
-
const date = /* @__PURE__ */ new Date();
|
|
47
|
-
const current = Date.now();
|
|
48
|
-
const interval = time && current - time ? `+${current - time}` : "";
|
|
49
|
-
time = current;
|
|
50
|
-
console[level](`${pc.magenta("[phecda-server]")} ${pc.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${pc[color](msg)} ${pc.gray(interval)}`);
|
|
51
|
-
}
|
|
52
|
-
__name(log, "log");
|
|
53
|
-
function runMiddleware(ctx, middleware) {
|
|
54
|
-
return new Promise((resolve) => {
|
|
55
|
-
middleware(ctx.getRequest(), ctx.getResponse(), resolve);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
__name(runMiddleware, "runMiddleware");
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
__name,
|
|
62
|
-
ERROR_SYMBOL,
|
|
63
|
-
IS_HMR,
|
|
64
|
-
IS_ONLY_GENERATE,
|
|
65
|
-
IS_STRICT,
|
|
66
|
-
LOG_LEVEL,
|
|
67
|
-
PS_EXIT_CODE,
|
|
68
|
-
setLogger,
|
|
69
|
-
getLogger,
|
|
70
|
-
log,
|
|
71
|
-
runMiddleware,
|
|
72
|
-
Mixin
|
|
73
|
-
};
|