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.
Files changed (86) hide show
  1. package/assets/ps.json +24 -24
  2. package/assets/schema.json +55 -55
  3. package/bin/cli.mjs +31 -18
  4. package/dist/chunk-4LLLQOMF.js +152 -0
  5. package/dist/{chunk-BGXSMOLX.js → chunk-6OQ2SB5W.js} +138 -70
  6. package/dist/{chunk-SW5IKE5H.js → chunk-G7JFKM2M.js} +136 -89
  7. package/dist/{chunk-MBCHNDAY.js → chunk-KCPBITYZ.js} +24 -24
  8. package/dist/{chunk-HMVLXNV3.mjs → chunk-MUI6MTUO.mjs} +1 -1
  9. package/dist/chunk-NQ55PA2X.mjs +152 -0
  10. package/dist/{chunk-5622RBNB.mjs → chunk-YCES6ABN.mjs} +125 -57
  11. package/dist/{chunk-P75VKZJY.mjs → chunk-Z7NAAE4M.mjs} +94 -47
  12. package/dist/{core-BIcUwV18.d.mts → core-CUTbX_IS.d.ts} +5 -3
  13. package/dist/{core-CYwEPfN4.d.ts → core-DIfgUKIU.d.mts} +5 -3
  14. package/dist/helper.d.mts +8 -6
  15. package/dist/helper.d.ts +8 -6
  16. package/dist/helper.js +8 -3
  17. package/dist/helper.mjs +10 -5
  18. package/dist/http/elysia/index.d.mts +4 -4
  19. package/dist/http/elysia/index.d.ts +4 -4
  20. package/dist/http/elysia/index.js +43 -44
  21. package/dist/http/elysia/index.mjs +9 -10
  22. package/dist/http/express/index.d.mts +4 -4
  23. package/dist/http/express/index.d.ts +4 -4
  24. package/dist/http/express/index.js +40 -41
  25. package/dist/http/express/index.mjs +9 -10
  26. package/dist/http/fastify/index.d.mts +4 -4
  27. package/dist/http/fastify/index.d.ts +4 -4
  28. package/dist/http/fastify/index.js +41 -42
  29. package/dist/http/fastify/index.mjs +9 -10
  30. package/dist/http/h3/index.d.mts +4 -4
  31. package/dist/http/h3/index.d.ts +4 -4
  32. package/dist/http/h3/index.js +41 -42
  33. package/dist/http/h3/index.mjs +9 -10
  34. package/dist/http/hono/index.d.mts +4 -4
  35. package/dist/http/hono/index.d.ts +4 -4
  36. package/dist/http/hono/index.js +37 -39
  37. package/dist/http/hono/index.mjs +5 -7
  38. package/dist/http/hyper-express/index.d.mts +4 -4
  39. package/dist/http/hyper-express/index.d.ts +4 -4
  40. package/dist/http/hyper-express/index.js +38 -39
  41. package/dist/http/hyper-express/index.mjs +8 -9
  42. package/dist/http/koa/index.d.mts +4 -4
  43. package/dist/http/koa/index.d.ts +4 -4
  44. package/dist/http/koa/index.js +40 -41
  45. package/dist/http/koa/index.mjs +9 -10
  46. package/dist/index.d.mts +46 -40
  47. package/dist/index.d.ts +46 -40
  48. package/dist/index.js +48 -42
  49. package/dist/index.mjs +21 -15
  50. package/dist/{meta-BXKLFTgG.d.mts → meta-CR-D39hQ.d.mts} +7 -5
  51. package/dist/{meta-BXKLFTgG.d.ts → meta-CR-D39hQ.d.ts} +7 -5
  52. package/dist/rpc/bullmq/index.d.mts +5 -5
  53. package/dist/rpc/bullmq/index.d.ts +5 -5
  54. package/dist/rpc/bullmq/index.js +15 -14
  55. package/dist/rpc/bullmq/index.mjs +4 -3
  56. package/dist/rpc/kafka/index.d.mts +4 -4
  57. package/dist/rpc/kafka/index.d.ts +4 -4
  58. package/dist/rpc/kafka/index.js +15 -14
  59. package/dist/rpc/kafka/index.mjs +3 -2
  60. package/dist/rpc/nats/index.d.mts +4 -4
  61. package/dist/rpc/nats/index.d.ts +4 -4
  62. package/dist/rpc/nats/index.js +14 -13
  63. package/dist/rpc/nats/index.mjs +4 -3
  64. package/dist/rpc/rabbitmq/index.d.mts +4 -4
  65. package/dist/rpc/rabbitmq/index.d.ts +4 -4
  66. package/dist/rpc/rabbitmq/index.js +16 -15
  67. package/dist/rpc/rabbitmq/index.mjs +4 -3
  68. package/dist/rpc/redis/index.d.mts +4 -4
  69. package/dist/rpc/redis/index.d.ts +4 -4
  70. package/dist/rpc/redis/index.js +14 -13
  71. package/dist/rpc/redis/index.mjs +4 -3
  72. package/dist/test.d.mts +3 -3
  73. package/dist/test.d.ts +3 -3
  74. package/dist/test.js +6 -6
  75. package/dist/test.mjs +2 -2
  76. package/dist/{types-h40T3cRG.d.mts → types-BF1TDbFV.d.ts} +4 -3
  77. package/dist/{types-BtbL49Zs.d.mts → types-DYRu0vic.d.ts} +4 -3
  78. package/dist/{types-VFzEM7LL.d.ts → types-DYviSl5B.d.mts} +4 -3
  79. package/dist/{types-m3IEDKjP.d.ts → types-DqH1qA-q.d.mts} +4 -3
  80. package/package.json +8 -5
  81. package/register/export.mjs +30 -0
  82. package/register/index.mjs +50 -40
  83. package/register/loader.mjs +384 -367
  84. package/register/utils.mjs +60 -56
  85. package/dist/chunk-J5CFUN4V.js +0 -73
  86. package/dist/chunk-WHJ5FALK.mjs +0 -73
@@ -1,56 +1,60 @@
1
- import { basename } from 'path'
2
- import { transform } from '@swc-node/core'
3
- const injectInlineSourceMap = ({ code, map }) => {
4
- if (map) {
5
- const base64Map = Buffer.from(map, 'utf8').toString('base64')
6
- const sourceMapContent = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`
7
- return `${code}\n${sourceMapContent}`
8
- }
9
- return code
10
- }
11
-
12
- export async function compile(sourcecode, filename) {
13
- if (filename.endsWith('.d.ts'))
14
- return ''
15
-
16
- const { code, map } = await transform(sourcecode, filename, {
17
- sourcemap: true,
18
- module: 'es6',
19
- emitDecoratorMetadata: true,
20
- experimentalDecorators: true,
21
- esModuleInterop: false,
22
- })
23
-
24
- return injectInlineSourceMap({ code, map })
25
- }
26
-
27
- export async function genUnImportRet(opts) {
28
- try {
29
- const psExports = Object.keys(await import('../dist/index.mjs'))
30
- const { createUnimport } = await import('unimport')
31
- return createUnimport({
32
- ...opts,
33
- imports: psExports
34
- .map((k) => {
35
- return { name: k, from: 'phecda-server' }
36
- })
37
- .concat(opts.imports || []),
38
- })
39
- }
40
- catch (e) {
41
- return false
42
- }
43
- }
44
-
45
- export function handleClassTypes(input) {
46
- return input.replace(/const\s+(\w+)\s*:\s*typeof\s+import\(['"](.+)['"]\)\['(\w+)'\]/g, (_, n, p, e) => {
47
- // TestController in test.controller
48
- if (p.startsWith('./') && (basename(p).replace('.', '').toLowerCase() === e.toLowerCase()))
49
- return `${_}\n type ${n} = InstanceType<typeof import('${p}')['${e}']>`
50
-
51
- return _
52
- })
53
- }
54
- export function slash(str) {
55
- return str.replace(/\\/g, '/')
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
+ })
24
+
25
+ return injectInlineSourceMap({ code, map })
26
+ }
27
+
28
+ export async function genUnImportRet(opts) {
29
+ try {
30
+ const { createUnimport } = await import('unimport')
31
+ return createUnimport({
32
+ ...opts,
33
+
34
+ presets: [
35
+ {
36
+ from: 'phecda-server',
37
+ imports: psExports,
38
+ },
39
+ ]
40
+ .concat(opts.presets || []),
41
+ })
42
+ }
43
+ catch (e) {
44
+ console.error(e)
45
+ return false
46
+ }
47
+ }
48
+
49
+ export function handleClassTypes(input) {
50
+ return input.replace(/const\s+(\w+)\s*:\s*typeof\s+import\(['"](.+)['"]\)\['(\w+)'\]/g, (_, n, p, e) => {
51
+ // TestController in test.controller
52
+ if (p.startsWith('./') && (basename(p).replace('.', '').toLowerCase() === e.toLowerCase()))
53
+ return `${_}\n type ${n} = InstanceType<typeof import('${p}')['${e}']>`
54
+
55
+ return _
56
+ })
57
+ }
58
+ export function slash(str) {
59
+ return str.replace(/\\/g, '/')
60
+ }
@@ -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;
@@ -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
- };