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.
Files changed (87) hide show
  1. package/assets/schema.json +5 -0
  2. package/dist/{chunk-MKRHYZCL.mjs → chunk-FI5756JX.mjs} +2 -2
  3. package/dist/{chunk-JTSD2LIG.js → chunk-OLNN4U3O.js} +13 -11
  4. package/dist/{chunk-TQSHE4PZ.mjs → chunk-PFPOEZHH.mjs} +13 -11
  5. package/dist/{chunk-DPPDWBYO.js → chunk-UYZSUBX4.js} +2 -2
  6. package/dist/{chunk-P3CS65OP.mjs → chunk-VAHCYYCB.mjs} +32 -17
  7. package/dist/{chunk-OV3UJLGP.js → chunk-YJ3QHGTC.js} +32 -17
  8. package/dist/{core-B5yKYkMJ.d.mts → core-BTSHIAyB.d.ts} +2 -1
  9. package/dist/{core-BRuvL6hY.d.ts → core-D1YYphEn.d.mts} +2 -1
  10. package/dist/helper.d.mts +1 -1
  11. package/dist/helper.d.ts +1 -1
  12. package/dist/helper.js +2 -2
  13. package/dist/helper.mjs +1 -1
  14. package/dist/http/elysia/index.d.mts +3 -3
  15. package/dist/http/elysia/index.d.ts +3 -3
  16. package/dist/http/elysia/index.js +30 -30
  17. package/dist/http/elysia/index.mjs +15 -15
  18. package/dist/http/express/index.d.mts +3 -3
  19. package/dist/http/express/index.d.ts +3 -3
  20. package/dist/http/express/index.js +27 -27
  21. package/dist/http/express/index.mjs +14 -14
  22. package/dist/http/fastify/index.d.mts +3 -3
  23. package/dist/http/fastify/index.d.ts +3 -3
  24. package/dist/http/fastify/index.js +29 -29
  25. package/dist/http/fastify/index.mjs +15 -15
  26. package/dist/http/h3/index.d.mts +3 -3
  27. package/dist/http/h3/index.d.ts +3 -3
  28. package/dist/http/h3/index.js +28 -28
  29. package/dist/http/h3/index.mjs +14 -14
  30. package/dist/http/hono/index.d.mts +3 -3
  31. package/dist/http/hono/index.d.ts +3 -3
  32. package/dist/http/hono/index.js +26 -26
  33. package/dist/http/hono/index.mjs +14 -14
  34. package/dist/http/hyper-express/index.d.mts +3 -3
  35. package/dist/http/hyper-express/index.d.ts +3 -3
  36. package/dist/http/hyper-express/index.js +26 -26
  37. package/dist/http/hyper-express/index.mjs +14 -14
  38. package/dist/http/koa/index.d.mts +3 -3
  39. package/dist/http/koa/index.d.ts +3 -3
  40. package/dist/http/koa/index.js +27 -27
  41. package/dist/http/koa/index.mjs +14 -14
  42. package/dist/index.d.mts +20 -13
  43. package/dist/index.d.ts +20 -13
  44. package/dist/index.js +112 -71
  45. package/dist/index.mjs +69 -28
  46. package/dist/{meta-C_eDyXnK.d.ts → meta-DNF6Fl27.d.mts} +11 -9
  47. package/dist/{meta-C_eDyXnK.d.mts → meta-DNF6Fl27.d.ts} +11 -9
  48. package/dist/rpc/bullmq/index.d.mts +3 -3
  49. package/dist/rpc/bullmq/index.d.ts +3 -3
  50. package/dist/rpc/bullmq/index.js +16 -16
  51. package/dist/rpc/bullmq/index.mjs +11 -11
  52. package/dist/rpc/electron/index.d.mts +3 -3
  53. package/dist/rpc/electron/index.d.ts +3 -3
  54. package/dist/rpc/electron/index.js +11 -11
  55. package/dist/rpc/electron/index.mjs +7 -7
  56. package/dist/rpc/kafka/index.d.mts +3 -3
  57. package/dist/rpc/kafka/index.d.ts +3 -3
  58. package/dist/rpc/kafka/index.js +14 -14
  59. package/dist/rpc/kafka/index.mjs +9 -9
  60. package/dist/rpc/nats/index.d.mts +3 -3
  61. package/dist/rpc/nats/index.d.ts +3 -3
  62. package/dist/rpc/nats/index.js +14 -14
  63. package/dist/rpc/nats/index.mjs +9 -9
  64. package/dist/rpc/rabbitmq/index.d.mts +3 -3
  65. package/dist/rpc/rabbitmq/index.d.ts +3 -3
  66. package/dist/rpc/rabbitmq/index.js +14 -14
  67. package/dist/rpc/rabbitmq/index.mjs +9 -9
  68. package/dist/rpc/redis/index.d.mts +3 -3
  69. package/dist/rpc/redis/index.d.ts +3 -3
  70. package/dist/rpc/redis/index.js +14 -14
  71. package/dist/rpc/redis/index.mjs +9 -9
  72. package/dist/rpc/ws/index.d.mts +3 -3
  73. package/dist/rpc/ws/index.d.ts +3 -3
  74. package/dist/rpc/ws/index.js +10 -10
  75. package/dist/rpc/ws/index.mjs +6 -6
  76. package/dist/test.d.mts +2 -2
  77. package/dist/test.d.ts +2 -2
  78. package/dist/test.js +5 -5
  79. package/dist/test.mjs +4 -4
  80. package/dist/{types-7-m2wEkP.d.mts → types-BOZ8yE2L.d.mts} +1 -1
  81. package/dist/{types-BuvMT1ta.d.ts → types-Cosv4nol.d.ts} +1 -1
  82. package/dist/{types-BKHBmSQN.d.mts → types-DtiHAXQB.d.mts} +1 -1
  83. package/dist/{types-B6aU8oT-.d.ts → types-YJ55P7A_.d.ts} +1 -1
  84. package/package.json +3 -4
  85. package/register/export.mjs +5 -1
  86. package/register/loader.mjs +293 -292
  87. package/register/utils.mjs +43 -70
@@ -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
- 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
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
- 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
- })
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
- return injectInlineSourceMap({ code, map })
26
+ return injectInlineSourceMap({ code, map })
52
27
  }
53
28
 
54
29
  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
- }
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
- 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}']>`
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
- return _
82
- })
54
+ return _
55
+ })
83
56
  }
84
57
  export function slash(str) {
85
- return str.replace(/\\/g, '/')
86
- }
58
+ return str.replace(/\\/g, '/')
59
+ }