phecda-server 7.1.3 → 8.0.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/assets/schema.json +5 -0
- package/dist/{chunk-MKRHYZCL.mjs → chunk-FI5756JX.mjs} +2 -2
- package/dist/{chunk-JTSD2LIG.js → chunk-OLNN4U3O.js} +13 -11
- package/dist/{chunk-TQSHE4PZ.mjs → chunk-PFPOEZHH.mjs} +13 -11
- package/dist/{chunk-DPPDWBYO.js → chunk-UYZSUBX4.js} +2 -2
- package/dist/{chunk-P3CS65OP.mjs → chunk-VAHCYYCB.mjs} +32 -17
- package/dist/{chunk-OV3UJLGP.js → chunk-YJ3QHGTC.js} +32 -17
- package/dist/{core-B5yKYkMJ.d.mts → core-BTSHIAyB.d.ts} +2 -1
- package/dist/{core-BRuvL6hY.d.ts → core-D1YYphEn.d.mts} +2 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +2 -2
- package/dist/helper.mjs +1 -1
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +30 -30
- package/dist/http/elysia/index.mjs +15 -15
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +27 -27
- package/dist/http/express/index.mjs +14 -14
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +29 -29
- package/dist/http/fastify/index.mjs +15 -15
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +28 -28
- package/dist/http/h3/index.mjs +14 -14
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +26 -26
- package/dist/http/hono/index.mjs +14 -14
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +26 -26
- package/dist/http/hyper-express/index.mjs +14 -14
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +27 -27
- package/dist/http/koa/index.mjs +14 -14
- package/dist/index.d.mts +20 -13
- package/dist/index.d.ts +20 -13
- package/dist/index.js +112 -71
- package/dist/index.mjs +69 -28
- package/dist/{meta-C_eDyXnK.d.ts → meta-DNF6Fl27.d.mts} +11 -9
- package/dist/{meta-C_eDyXnK.d.mts → meta-DNF6Fl27.d.ts} +11 -9
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +16 -16
- package/dist/rpc/bullmq/index.mjs +11 -11
- package/dist/rpc/electron/index.d.mts +3 -3
- package/dist/rpc/electron/index.d.ts +3 -3
- package/dist/rpc/electron/index.js +11 -11
- package/dist/rpc/electron/index.mjs +7 -7
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +9 -9
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +14 -14
- package/dist/rpc/nats/index.mjs +9 -9
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +14 -14
- package/dist/rpc/rabbitmq/index.mjs +9 -9
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +14 -14
- package/dist/rpc/redis/index.mjs +9 -9
- package/dist/rpc/ws/index.d.mts +3 -3
- package/dist/rpc/ws/index.d.ts +3 -3
- package/dist/rpc/ws/index.js +10 -10
- package/dist/rpc/ws/index.mjs +6 -6
- package/dist/test.d.mts +2 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +5 -5
- package/dist/test.mjs +4 -4
- package/dist/{types-7-m2wEkP.d.mts → types-BOZ8yE2L.d.mts} +1 -1
- package/dist/{types-BuvMT1ta.d.ts → types-Cosv4nol.d.ts} +1 -1
- package/dist/{types-BKHBmSQN.d.mts → types-DtiHAXQB.d.mts} +1 -1
- package/dist/{types-B6aU8oT-.d.ts → types-YJ55P7A_.d.ts} +1 -1
- package/package.json +3 -4
- package/register/export.mjs +5 -1
- package/register/loader.mjs +293 -292
- package/register/utils.mjs +43 -70
package/register/utils.mjs
CHANGED
|
@@ -2,85 +2,58 @@ import { basename } from 'path'
|
|
|
2
2
|
import { transform } from '@swc-node/core'
|
|
3
3
|
import psExports from './export.mjs'
|
|
4
4
|
const injectInlineSourceMap = ({ code, map }) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
11
|
}
|
|
12
12
|
|
|
13
|
-
export async function compile(sourcecode, filename) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
})
|
|
13
|
+
export async function compile(sourcecode, filename, config = {}) {
|
|
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
|
+
...config
|
|
24
|
+
})
|
|
50
25
|
|
|
51
|
-
|
|
26
|
+
return injectInlineSourceMap({ code, map })
|
|
52
27
|
}
|
|
53
28
|
|
|
54
29
|
export async function genUnImportRet(opts) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return false
|
|
72
|
-
}
|
|
30
|
+
try {
|
|
31
|
+
const { createUnimport } = await
|
|
32
|
+
import ('unimport')
|
|
33
|
+
return createUnimport({
|
|
34
|
+
...opts,
|
|
35
|
+
|
|
36
|
+
presets: [{
|
|
37
|
+
from: 'phecda-server',
|
|
38
|
+
imports: psExports,
|
|
39
|
+
}, ]
|
|
40
|
+
.concat(opts.presets || []),
|
|
41
|
+
})
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error(e)
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
73
46
|
}
|
|
74
47
|
|
|
75
48
|
export function handleClassTypes(input) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
49
|
+
return input.replace(/const\s+(\w+)\s*:\s*typeof\s+import\(['"](.+)['"]\)\['(\w+)'\]/g, (_, n, p, e) => {
|
|
50
|
+
// TestController in test.controller
|
|
51
|
+
if (p.startsWith('./') && (basename(p).replace('.', '').toLowerCase() === e.toLowerCase()))
|
|
52
|
+
return `${_}\n type ${n} = InstanceType<typeof import('${p}')['${e}']>`
|
|
80
53
|
|
|
81
|
-
|
|
82
|
-
|
|
54
|
+
return _
|
|
55
|
+
})
|
|
83
56
|
}
|
|
84
57
|
export function slash(str) {
|
|
85
|
-
|
|
86
|
-
}
|
|
58
|
+
return str.replace(/\\/g, '/')
|
|
59
|
+
}
|