phecda-server 7.0.0-alpha.2 → 7.0.0-alpha.4
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 +1 -0
- package/dist/{chunk-NQIFUZL4.js → chunk-6EBEME3I.js} +51 -51
- package/dist/{chunk-XYVMNY2X.mjs → chunk-A53KNKY4.mjs} +1 -1
- package/dist/{chunk-HMVLXNV3.mjs → chunk-KUGFI6SC.mjs} +1 -1
- package/dist/{chunk-3FHZB3Z5.mjs → chunk-MMG73S64.mjs} +1 -1
- package/dist/{chunk-7YQ57BQS.js → chunk-PKSWGQLW.js} +18 -18
- package/dist/{chunk-MBCHNDAY.js → chunk-QCOBXM7F.js} +24 -24
- package/dist/{chunk-WHJ5FALK.mjs → chunk-QD3QR3NW.mjs} +3 -3
- package/dist/{chunk-J5CFUN4V.js → chunk-RQSQRZL4.js} +3 -3
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/http/elysia/index.js +40 -40
- package/dist/http/elysia/index.mjs +3 -3
- package/dist/http/express/index.js +37 -37
- package/dist/http/express/index.mjs +2 -2
- package/dist/http/fastify/index.js +38 -38
- package/dist/http/fastify/index.mjs +3 -3
- package/dist/http/h3/index.js +37 -37
- package/dist/http/h3/index.mjs +2 -2
- package/dist/http/hono/index.js +35 -35
- package/dist/http/hono/index.mjs +2 -2
- package/dist/http/hyper-express/index.js +35 -35
- package/dist/http/hyper-express/index.mjs +2 -2
- package/dist/http/koa/index.js +37 -37
- package/dist/http/koa/index.mjs +2 -2
- package/dist/index.js +38 -38
- package/dist/index.mjs +4 -4
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/test.d.mts +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/package.json +2 -2
- package/register/index.mjs +41 -40
- package/register/loader.mjs +36 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.4",
|
|
4
4
|
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
|
|
5
5
|
"author": "fgsreally",
|
|
6
6
|
"license": "MIT",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"picocolors": "^1.0.0",
|
|
148
148
|
"reflect-metadata": "^0.1.13",
|
|
149
149
|
"ts-mixer": "^6.0.4",
|
|
150
|
-
"phecda-core": "4.0.
|
|
150
|
+
"phecda-core": "4.1.0-alpha.0"
|
|
151
151
|
},
|
|
152
152
|
"devDependencies": {
|
|
153
153
|
"@koa/router": "^12.0.1",
|
package/register/index.mjs
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
import { register } from 'node:module'
|
|
2
|
-
import { MessageChannel } from 'node:worker_threads'
|
|
3
|
-
import { log } from '../dist/index.mjs'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
1
|
+
import { register } from 'node:module'
|
|
2
|
+
import { MessageChannel } from 'node:worker_threads'
|
|
3
|
+
import { log } from '../dist/index.mjs'
|
|
4
|
+
|
|
5
|
+
const { port1, port2 } = new MessageChannel()
|
|
6
|
+
|
|
7
|
+
register('./loader.mjs', {
|
|
8
|
+
parentURL: import.meta.url,
|
|
9
|
+
data: { port: port2 },
|
|
10
|
+
transferList: [port2],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
let isRunning = true
|
|
14
|
+
|
|
15
|
+
port1.on('message', async (data) => {
|
|
16
|
+
const { type, files } = JSON.parse(data)
|
|
17
|
+
|
|
18
|
+
if (!isRunning || !globalThis.__PS_HMR__ || type === 'relaunch')
|
|
19
|
+
return process.exit(2)// file change -> relaunch
|
|
20
|
+
|
|
21
|
+
if (type === 'change') {
|
|
22
|
+
log('reload module...')
|
|
23
|
+
|
|
24
|
+
for (const cb of globalThis.__PS_HMR__) await cb(files)
|
|
25
|
+
|
|
26
|
+
log('reload done')
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
process.on('uncaughtException', (err) => {
|
|
31
|
+
log('Uncaught Exception:', 'error')
|
|
32
|
+
isRunning = false
|
|
33
|
+
console.error(err)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
process.on('unhandledRejection', (err) => {
|
|
37
|
+
log('Unhandled Promise Rejection:', 'error')
|
|
38
|
+
isRunning = false
|
|
39
|
+
|
|
40
|
+
console.error(err)
|
|
41
|
+
})
|
package/register/loader.mjs
CHANGED
|
@@ -2,26 +2,42 @@ import { fileURLToPath, pathToFileURL } from 'url'
|
|
|
2
2
|
import { writeFile } from 'fs/promises'
|
|
3
3
|
import {
|
|
4
4
|
basename,
|
|
5
|
+
dirname,
|
|
5
6
|
extname,
|
|
6
7
|
isAbsolute,
|
|
7
8
|
relative,
|
|
8
9
|
resolve as resolvePath,
|
|
9
10
|
} from 'path'
|
|
10
11
|
import { createRequire } from 'module'
|
|
12
|
+
import { existsSync } from 'fs'
|
|
11
13
|
import ts from 'typescript'
|
|
12
14
|
import chokidar from 'chokidar'
|
|
13
15
|
import { log } from '../dist/index.mjs'
|
|
14
16
|
import { compile, genUnImportRet, handleClassTypes, slash } from './utils.mjs'
|
|
15
17
|
|
|
16
18
|
let port
|
|
19
|
+
let tsconfig = {
|
|
20
|
+
module: ts.ModuleKind.ESNext,
|
|
21
|
+
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
22
|
+
}
|
|
17
23
|
|
|
18
24
|
const isLowVersion = parseFloat(process.version.slice(1)) < 18.19
|
|
19
25
|
// this part is important or not?
|
|
20
26
|
const EXTENSIONS = [ts.Extension.Ts, ts.Extension.Tsx, ts.Extension.Mts]
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
|
|
28
|
+
const tsconfigPath = resolvePath(process.cwd(), 'tsconfig.json')
|
|
29
|
+
const tsRet = ts.readConfigFile(tsconfigPath, ts.sys.readFile)
|
|
30
|
+
|
|
31
|
+
if (!tsRet.error) {
|
|
32
|
+
const { error, options } = ts.parseJsonConfigFileContent(
|
|
33
|
+
tsRet.config,
|
|
34
|
+
ts.sys,
|
|
35
|
+
dirname(tsconfigPath),
|
|
36
|
+
)
|
|
37
|
+
if (!error)
|
|
38
|
+
tsconfig = options
|
|
24
39
|
}
|
|
40
|
+
|
|
25
41
|
const moduleResolutionCache = ts.createModuleResolutionCache(
|
|
26
42
|
ts.sys.getCurrentDirectory(),
|
|
27
43
|
x => x,
|
|
@@ -56,6 +72,8 @@ export async function initialize(data) {
|
|
|
56
72
|
config = require(configPath)
|
|
57
73
|
if (!config.virtualFile)
|
|
58
74
|
config.virtualFile = {}
|
|
75
|
+
if (!config.paths)
|
|
76
|
+
config.paths = {}
|
|
59
77
|
|
|
60
78
|
if (!process.env.PS_HMR_BAN) {
|
|
61
79
|
chokidar.watch(configPath, { persistent: true }).on('change', () => {
|
|
@@ -127,13 +145,20 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
127
145
|
}
|
|
128
146
|
// entrypoint
|
|
129
147
|
if (!context.parentURL) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
:
|
|
135
|
-
|
|
136
|
-
|
|
148
|
+
if (/^file:\/\/\//.test(specifier) && existsSync(fileURLToPath(specifier))) {
|
|
149
|
+
entryUrl = specifier
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
format: EXTENSIONS.some(ext => specifier.endsWith(ext))
|
|
153
|
+
? 'ts'
|
|
154
|
+
: undefined,
|
|
155
|
+
url: specifier,
|
|
156
|
+
shortCircuit: true,
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// won't resolve virtual file as entry in vite
|
|
161
|
+
return nextResolve(specifier)
|
|
137
162
|
}
|
|
138
163
|
}
|
|
139
164
|
// url import
|
|
@@ -357,7 +382,7 @@ export function isModuleFileUrl(url) {
|
|
|
357
382
|
'addon',
|
|
358
383
|
'filter',
|
|
359
384
|
'pipe',
|
|
360
|
-
'
|
|
385
|
+
'solo',
|
|
361
386
|
].includes(midName)
|
|
362
387
|
)
|
|
363
388
|
return true
|