phecda-server 4.0.5 → 4.0.7

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 (65) hide show
  1. package/dist/{chunk-JQPX546Z.mjs → chunk-43ZXHSVH.mjs} +2 -2
  2. package/dist/{chunk-Q6T7HNEO.mjs → chunk-ATMZNJSE.mjs} +43 -31
  3. package/dist/chunk-ATMZNJSE.mjs.map +1 -0
  4. package/dist/{chunk-AJ2HYENF.mjs → chunk-DQUH5BP6.mjs} +28 -4
  5. package/dist/chunk-DQUH5BP6.mjs.map +1 -0
  6. package/dist/{chunk-NFAA3WFR.mjs → chunk-F5PQVQTY.mjs} +18 -11
  7. package/dist/chunk-F5PQVQTY.mjs.map +1 -0
  8. package/dist/{chunk-FAHHXHL5.js → chunk-FCLWCFQS.js} +3 -3
  9. package/dist/{chunk-YU7ROHTO.js → chunk-JZGLQ4FQ.js} +78 -66
  10. package/dist/chunk-JZGLQ4FQ.js.map +1 -0
  11. package/dist/{chunk-R3N4HR7U.js → chunk-WWYSLFOI.js} +39 -32
  12. package/dist/chunk-WWYSLFOI.js.map +1 -0
  13. package/dist/{chunk-LZAU5FUS.js → chunk-ZZ2QKZ46.js} +27 -3
  14. package/dist/chunk-ZZ2QKZ46.js.map +1 -0
  15. package/dist/{types-ead02c5d.d.ts → core-72951cf9.d.ts} +42 -19
  16. package/dist/index.d.ts +45 -26
  17. package/dist/index.js +123 -54
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +101 -32
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/rpc/rabbitmq/index.d.ts +2 -3
  22. package/dist/rpc/rabbitmq/index.js +19 -13
  23. package/dist/rpc/rabbitmq/index.js.map +1 -1
  24. package/dist/rpc/rabbitmq/index.mjs +13 -7
  25. package/dist/rpc/rabbitmq/index.mjs.map +1 -1
  26. package/dist/rpc/redis/index.d.ts +2 -3
  27. package/dist/rpc/redis/index.js +19 -13
  28. package/dist/rpc/redis/index.js.map +1 -1
  29. package/dist/rpc/redis/index.mjs +13 -7
  30. package/dist/rpc/redis/index.mjs.map +1 -1
  31. package/dist/server/express/index.d.ts +3 -3
  32. package/dist/server/express/index.js +37 -29
  33. package/dist/server/express/index.js.map +1 -1
  34. package/dist/server/express/index.mjs +19 -11
  35. package/dist/server/express/index.mjs.map +1 -1
  36. package/dist/server/fastify/index.d.ts +4 -4
  37. package/dist/server/fastify/index.js +38 -26
  38. package/dist/server/fastify/index.js.map +1 -1
  39. package/dist/server/fastify/index.mjs +23 -11
  40. package/dist/server/fastify/index.mjs.map +1 -1
  41. package/dist/server/h3/index.d.ts +5 -5
  42. package/dist/server/h3/index.js +34 -28
  43. package/dist/server/h3/index.js.map +1 -1
  44. package/dist/server/h3/index.mjs +16 -10
  45. package/dist/server/h3/index.mjs.map +1 -1
  46. package/dist/server/koa/index.d.ts +2 -2
  47. package/dist/server/koa/index.js +36 -28
  48. package/dist/server/koa/index.js.map +1 -1
  49. package/dist/server/koa/index.mjs +18 -10
  50. package/dist/server/koa/index.mjs.map +1 -1
  51. package/dist/test.d.ts +9 -5
  52. package/dist/test.js +10 -21
  53. package/dist/test.js.map +1 -1
  54. package/dist/test.mjs +7 -18
  55. package/dist/test.mjs.map +1 -1
  56. package/package.json +2 -2
  57. package/dist/chunk-AJ2HYENF.mjs.map +0 -1
  58. package/dist/chunk-LZAU5FUS.js.map +0 -1
  59. package/dist/chunk-NFAA3WFR.mjs.map +0 -1
  60. package/dist/chunk-Q6T7HNEO.mjs.map +0 -1
  61. package/dist/chunk-R3N4HR7U.js.map +0 -1
  62. package/dist/chunk-YU7ROHTO.js.map +0 -1
  63. package/dist/core-ba036c2b.d.ts +0 -23
  64. /package/dist/{chunk-JQPX546Z.mjs.map → chunk-43ZXHSVH.mjs.map} +0 -0
  65. /package/dist/{chunk-FAHHXHL5.js.map → chunk-FCLWCFQS.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-AJ2HYENF.mjs";
3
+ } from "./chunk-DQUH5BP6.mjs";
4
4
 
5
5
  // src/helper.ts
6
6
  function resolveDep(ret, key) {
@@ -13,4 +13,4 @@ __name(resolveDep, "resolveDep");
13
13
  export {
14
14
  resolveDep
15
15
  };
16
- //# sourceMappingURL=chunk-JQPX546Z.mjs.map
16
+ //# sourceMappingURL=chunk-43ZXHSVH.mjs.map
@@ -1,10 +1,11 @@
1
1
  import {
2
+ ERROR_SYMBOL,
2
3
  IS_DEV,
3
4
  IS_STRICT,
4
5
  __name,
5
6
  __publicField,
6
7
  log
7
- } from "./chunk-AJ2HYENF.mjs";
8
+ } from "./chunk-DQUH5BP6.mjs";
8
9
 
9
10
  // src/exception/base.ts
10
11
  var Exception = class extends Error {
@@ -22,7 +23,7 @@ var Exception = class extends Error {
22
23
  message: this.message,
23
24
  description: this.description,
24
25
  status: this.status,
25
- error: true
26
+ [ERROR_SYMBOL]: true
26
27
  };
27
28
  }
28
29
  };
@@ -219,8 +220,14 @@ var _Context = class {
219
220
  return _Context.pipeRecord[item.pipe || "default"](item, this.tag, this.data);
220
221
  }));
221
222
  }
222
- useFilter(arg) {
223
- return _Context.filter(arg, this.tag, this.data);
223
+ useFilter(arg, filter = "default") {
224
+ if (!_Context.filterRecord[filter]) {
225
+ if (IS_STRICT)
226
+ throw new FrameworkException(`can't find filter named '${filter}'`);
227
+ else
228
+ return _Context.filterRecord.default(arg, this.tag, this.data);
229
+ }
230
+ return _Context.filterRecord[filter](arg, this.tag, this.data);
224
231
  }
225
232
  async useGuard(guards) {
226
233
  for (const guard of guards) {
@@ -275,7 +282,9 @@ var _Context = class {
275
282
  };
276
283
  var Context = _Context;
277
284
  __name(Context, "Context");
278
- __publicField(Context, "filter", defaultFilter);
285
+ __publicField(Context, "filterRecord", {
286
+ default: defaultFilter
287
+ });
279
288
  __publicField(Context, "pipeRecord", {
280
289
  default: defaultPipe
281
290
  });
@@ -290,10 +299,10 @@ function addPipe(key, pipe) {
290
299
  Context.pipeRecord[key] = pipe;
291
300
  }
292
301
  __name(addPipe, "addPipe");
293
- function setFilter(filter) {
294
- Context.filter = filter;
302
+ function addFilter(key, handler) {
303
+ Context.filterRecord[key] = handler;
295
304
  }
296
- __name(setFilter, "setFilter");
305
+ __name(addFilter, "addFilter");
297
306
  function addGuard(key, handler) {
298
307
  Context.guardRecord[key] = handler;
299
308
  }
@@ -307,7 +316,10 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
307
316
  const guardSet = new Set(guards);
308
317
  const interceptorSet = new Set(interceptors);
309
318
  const pipeSet = /* @__PURE__ */ new Set();
319
+ const filterSet = /* @__PURE__ */ new Set();
310
320
  meta.forEach(({ data }) => {
321
+ if (data.filter)
322
+ filterSet.add(data.filter);
311
323
  data.interceptors.forEach((i) => interceptorSet.add(i));
312
324
  data.guards.forEach((i) => guardSet.add(i));
313
325
  data.plugins.forEach((i) => pluginSet.add(i));
@@ -316,30 +328,31 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
316
328
  pipeSet.add(i.pipe);
317
329
  });
318
330
  });
319
- [
331
+ const missPlugins = [
320
332
  ...pluginSet
321
- ].forEach((i) => {
322
- if (!Context.pluginRecord[i])
323
- log(`${pc.white(`Plugin [${i}]`)} doesn't exist`, "warn");
324
- });
325
- [
333
+ ].filter((i) => !Context.pluginRecord[i]);
334
+ const missGuards = [
326
335
  ...guardSet
327
- ].forEach((i) => {
328
- if (!Context.guardRecord[i])
329
- log(`${pc.red(`Guard [${i}]`)} doesn't exist`, "warn");
330
- });
331
- [
336
+ ].filter((i) => !Context.guardRecord[i]);
337
+ const missInterceptors = [
332
338
  ...interceptorSet
333
- ].forEach((i) => {
334
- if (!Context.interceptorRecord[i])
335
- log(`${pc.cyan(`Interceptor [${i}]`)} doesn't exist`, "warn");
336
- });
337
- [
339
+ ].filter((i) => !Context.interceptorRecord[i]);
340
+ const missPipes = [
338
341
  ...pipeSet
339
- ].forEach((i) => {
340
- if (!Context.pipeRecord[i])
341
- log(`${pc.blue(`Pipe [${i}]`)} doesn't exist`, "warn");
342
- });
342
+ ].filter((i) => !Context.pipeRecord[i]);
343
+ const missFilters = [
344
+ ...filterSet
345
+ ].filter((i) => !Context.filterRecord[i]);
346
+ if (missPlugins.length)
347
+ log(`${pc.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
348
+ if (missGuards.length)
349
+ log(`${pc.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
350
+ if (missInterceptors.length)
351
+ log(`${pc.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
352
+ if (missPipes.length)
353
+ log(`${pc.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
354
+ if (missFilters.length)
355
+ log(`${pc.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
343
356
  }
344
357
  __name(isAopDepInject, "isAopDepInject");
345
358
 
@@ -360,14 +373,13 @@ export {
360
373
  UnauthorizedException,
361
374
  ServiceUnavailableException,
362
375
  FrameworkException,
363
- defaultFilter,
364
376
  guardRecord,
365
377
  Context,
366
378
  addPlugin,
367
379
  addPipe,
368
- setFilter,
380
+ addFilter,
369
381
  addGuard,
370
382
  addInterceptor,
371
383
  isAopDepInject
372
384
  };
373
- //# sourceMappingURL=chunk-Q6T7HNEO.mjs.map
385
+ //# sourceMappingURL=chunk-ATMZNJSE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/exception/base.ts","../src/exception/validate.ts","../src/pipe.ts","../src/exception/undefine.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/context.ts","../src/filter.ts","../src/history.ts"],"sourcesContent":["import { ERROR_SYMBOL } from '../common'\n\nexport class Exception extends Error {\n constructor(public message: string, public status: number, public description = 'Http exception') {\n super(message)\n }\n\n get data() {\n return { message: this.message, description: this.description, status: this.status, [ERROR_SYMBOL]: true }\n }\n}\n","import { Exception } from './base'\n\nexport class ValidateException extends Exception {\n constructor(message: string) {\n super(message, 400, 'Validate exception')\n }\n}\n","import { isPhecda, plainToClass, transformClass } from 'phecda-core'\nimport { ValidateException } from './exception/validate'\n\nimport type { P } from './types'\n\nexport const defaultPipe: P.Pipe = async ({ arg, reflect, index }: any) => {\n if (isPhecda(reflect)) {\n const instance = plainToClass(reflect, arg)\n const err = await transformClass(instance)\n if (err.length > 0)\n throw new ValidateException(err[0])\n\n arg = instance\n }\n else {\n if ([Number, Boolean].includes(reflect)) {\n arg = reflect(arg)\n\n if (reflect === Number && Object.is(arg, NaN))\n throw new ValidateException(`parameter ${Number(index) + 1} should be a number`)\n }\n }\n return arg\n}\n","import { Exception } from './base'\n\nexport class UndefinedException extends Exception {\n constructor(message: string) {\n super(message, 500, 'Undefined error')\n }\n}\n","import { Exception } from './base'\n\nexport class ForbiddenException extends Exception {\n constructor(message: string) {\n super(message, 403, 'Forbidden resource')\n }\n}\n","import { Exception } from './base'\n\nexport class BadRequestException extends Exception {\n constructor(message: string) {\n super(message, 400, 'Bad Request')\n }\n}\n","import { Exception } from './base'\n\nexport class NotFoundException extends Exception {\n constructor(message: string) {\n super(message, 404, 'Not Found')\n }\n}\n","import { Exception } from './base'\n\nexport class ConflictException extends Exception {\n constructor(message: string) {\n super(message, 409, 'Conflict')\n }\n}\n","import { Exception } from './base'\n\nexport class BadGatewayException extends Exception {\n constructor(message: string) {\n super(message, 502, 'Bad Gatrway')\n }\n}\n","import { Exception } from './base'\n\nexport class InvalidInputException extends Exception {\n constructor(message: string) {\n super(message, 502, 'Invalid Input')\n }\n}\n","import { Exception } from './base'\n\nexport class UnsupportedMediaTypeException extends Exception {\n constructor(message: string) {\n super(message, 415, 'Unsupported Media Type')\n }\n}\n","import { Exception } from './base'\n\nexport class PayloadLargeException extends Exception {\n constructor(message: string) {\n super(message, 413, 'Payload Too Large')\n }\n}\n","import { Exception } from './base'\n\nexport class TimeoutException extends Exception {\n constructor(message: string) {\n super(message, 408, 'Request Timeout',\n )\n }\n}\n","import { Exception } from './base'\n\nexport class UnauthorizedException extends Exception {\n constructor(message: string) {\n super(message, 401, 'Unauthorized')\n }\n}\n","import { Exception } from './base'\n\nexport class ServiceUnavailableException extends Exception {\n constructor(message: string) {\n super(message, 503, 'Service Unavailable')\n }\n}\n","import { Exception } from './base'\n\nexport class FrameworkException extends Exception {\n constructor(message: string) {\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\n }\n}\n","import pc from 'picocolors'\nimport { defaultPipe } from './pipe'\nimport { ForbiddenException, FrameworkException } from './exception'\nimport { defaultFilter } from './filter'\nimport { Histroy } from './history'\nimport type { P } from './types'\nimport { IS_DEV, IS_STRICT } from './common'\nimport type { Meta } from './meta'\nimport { log } from './utils'\nexport const guardRecord = {} as Record<string, P.Guard>\n\nexport class Context<Data = any> {\n method: string\n params: string[]\n history = new Histroy()\n\n static filterRecord: Record<string, P.Filter> = {\n default: defaultFilter,\n }\n\n static pipeRecord: Record<string, P.Pipe> = {\n default: defaultPipe,\n }\n\n static guardRecord: Record<string, P.Guard> = {}\n static interceptorRecord: Record<string, P.Interceptor> = {}\n\n static pluginRecord: Record<string, any> = {}\n postInterceptors: Function[]\n\n constructor(public tag: string, public data: Data) {\n if (IS_DEV)\n // @ts-expect-error work for debug\n data._context = this\n }\n\n usePipe(args: { arg: any; pipe?: string; pipeOpts?: any; type: string; key: string; index: number; reflect: any }[]) {\n return Promise.all(args.map((item) => {\n if (item.pipe && !Context.pipeRecord[item.pipe]) {\n if (IS_STRICT)\n throw new FrameworkException(`can't find pipe named '${item.pipe}'`)\n\n else\n return Context.pipeRecord.default(item, this.tag, this.data)\n }\n\n return Context.pipeRecord[item.pipe || 'default'](item, this.tag, this.data)\n }))\n }\n\n useFilter(arg: any, filter = 'default') {\n if (!Context.filterRecord[filter]) {\n if (IS_STRICT)\n throw new FrameworkException(`can't find filter named '${filter}'`)\n else\n return Context.filterRecord.default(arg, this.tag, this.data)\n }\n\n return Context.filterRecord[filter](arg, this.tag, this.data)\n }\n\n async useGuard(guards: string[]) {\n for (const guard of guards) {\n if (this.history.record(guard, 'guard')) {\n if (!(guard in Context.guardRecord)) {\n if (IS_STRICT)\n throw new FrameworkException(`can't find guard named '${guard}'`)\n continue\n }\n if (!await Context.guardRecord[guard](this.tag, this.data))\n throw new ForbiddenException(`Guard exception--${guard}`)\n }\n }\n }\n\n async usePostInterceptor(ret: any) {\n for (const cb of this.postInterceptors)\n ret = await cb(ret) || ret\n\n return ret\n }\n\n async useInterceptor(interceptors: string[]) {\n const ret = []\n for (const interceptor of interceptors) {\n if (this.history.record(interceptor, 'interceptor')) {\n if (!(interceptor in Context.interceptorRecord)) {\n if (IS_STRICT)\n throw new FrameworkException(`can't find interceptor named '${interceptor}'`)\n\n continue\n }\n const postInterceptor = await Context.interceptorRecord[interceptor](this.tag, this.data)\n if (postInterceptor !== undefined) {\n if (typeof postInterceptor === 'function')\n ret.push(postInterceptor)\n\n else\n return postInterceptor\n }\n }\n }\n this.postInterceptors = ret\n }\n\n static usePlugin(plugins: string[]) {\n const ret = []\n for (const m of plugins) {\n if (!(m in Context.pluginRecord)) {\n if (IS_STRICT)\n throw new FrameworkException(`can't find middleware named '${m}'`)\n\n continue\n }\n ret.push(Context.pluginRecord[m])\n }\n return ret as any[]\n }\n}\nexport function addPlugin<C>(key: string, handler: C) {\n Context.pluginRecord[key] = handler\n}\n\nexport function addPipe(key: string, pipe: P.Pipe) {\n Context.pipeRecord[key] = pipe\n}\n\nexport function addFilter(key: string, handler: P.Filter) {\n Context.filterRecord[key] = handler\n}\n\nexport function addGuard(key: string, handler: P.Guard) {\n Context.guardRecord[key] = handler\n}\n\nexport function addInterceptor(key: string, handler: P.Interceptor) {\n Context.interceptorRecord[key] = handler\n}\n\n// detect whether plugin/filter/pipe/guard/intercept is injected\nexport function isAopDepInject(meta: Meta[], { guards, interceptors, plugins }: {\n guards?: string[]\n interceptors?: string[]\n plugins?: string[]\n} = {}) {\n const pluginSet = new Set<string>(plugins)\n\n const guardSet = new Set<string>(guards)\n const interceptorSet = new Set<string>(interceptors)\n const pipeSet = new Set<string>()\n\n const filterSet = new Set<string>()\n meta.forEach(({ data }) => {\n if (data.filter)\n filterSet.add(data.filter)\n\n data.interceptors.forEach(i => interceptorSet.add(i))\n data.guards.forEach(i => guardSet.add(i))\n data.plugins.forEach(i => pluginSet.add(i))\n data.params.forEach((i) => {\n if (i.pipe)\n pipeSet.add(i.pipe)\n })\n })\n\n const missPlugins = [...pluginSet].filter(i => !Context.pluginRecord[i])\n const missGuards = [...guardSet].filter(i => !Context.guardRecord[i])\n const missInterceptors = [...interceptorSet].filter(i => !Context.interceptorRecord[i])\n const missPipes = [...pipeSet].filter(i => !Context.pipeRecord[i])\n const missFilters = [...filterSet].filter(i => !Context.filterRecord[i])\n\n if (missPlugins.length)\n log(`${pc.white(`Plugin [${missPlugins.join(',')}]`)} doesn't exist`, 'warn')\n if (missGuards.length)\n log(`${pc.magenta(`Guard [${missGuards.join(',')}]`)} doesn't exist`, 'warn')\n\n if (missInterceptors.length)\n log(`${pc.cyan(`Interceptor [${missInterceptors.join(',')}]`)} doesn't exist`, 'warn')\n\n if (missPipes.length)\n log(`${pc.blue(`Pipe [${missPipes.join(',')}]`)} doesn't exist`, 'warn')\n\n if (missFilters.length)\n log(`${pc.red(`Filter [${missFilters.join(',')}]`)} doesn't exist`, 'warn')\n}\n","import { Exception, UndefinedException } from './exception'\nimport type { P } from './types'\nimport { log } from './utils'\n\nexport const defaultFilter: P.Filter = (e) => {\n if (!(e instanceof Exception)) {\n log(e.message, 'error')\n console.error(e.stack)\n e = new UndefinedException(e.message || e)\n }\n else {\n log(`[${e.constructor.name}] ${e.message}`, 'error')\n console.error(e.stack)\n }\n\n return e.data\n}\n","export class Histroy {\n guard: string[] = []\n interceptor: string[] = []\n record(name: string, type: 'guard' | 'interceptor') {\n if (!this[type].includes(name)) {\n this[type].push(name)\n return true\n }\n return false\n }\n}\n"],"mappings":";;;;;;;;;;AAEO,IAAMA,YAAN,cAAwBC,MAAAA;EACVC;EAAwBC;EAAuBC;EAAlEC,YAAmBH,SAAwBC,QAAuBC,cAAc,kBAAkB;AAChG,UAAMF,OAAAA;mBADWA;kBAAwBC;uBAAuBC;EAElE;EAEA,IAAIE,OAAO;AACT,WAAO;MAAEJ,SAAS,KAAKA;MAASE,aAAa,KAAKA;MAAaD,QAAQ,KAAKA;MAAQ,CAACI,eAAe;IAAK;EAC3G;AACF;AARaP;;;ACAN,IAAMQ,oBAAN,cAAgCC,UAAAA;EACrCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;AAJaH;;;ACFb,SAASI,UAAUC,cAAcC,sBAAsB;AAKhD,IAAMC,cAAsB,8BAAO,EAAEC,KAAKC,SAASC,MAAK,MAAY;AACzE,MAAIC,SAASF,OAAAA,GAAU;AACrB,UAAMG,WAAWC,aAAaJ,SAASD,GAAAA;AACvC,UAAMM,MAAM,MAAMC,eAAeH,QAAAA;AACjC,QAAIE,IAAIE,SAAS;AACf,YAAM,IAAIC,kBAAkBH,IAAI,EAAE;AAEpCN,UAAMI;EACR,OACK;AACH,QAAI;MAACM;MAAQC;MAASC,SAASX,OAAAA,GAAU;AACvCD,YAAMC,QAAQD,GAAAA;AAEd,UAAIC,YAAYS,UAAUG,OAAOC,GAAGd,KAAKe,GAAAA;AACvC,cAAM,IAAIN,kBAAkB,aAAaC,OAAOR,KAAAA,IAAS,sBAAsB;IACnF;EACF;AACA,SAAOF;AACT,GAlBmC;;;ACH5B,IAAMgB,qBAAN,cAAiCC,UAAAA;EACtCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,iBAAA;EACtB;AACF;AAJaH;;;ACAN,IAAMI,qBAAN,cAAiCC,UAAAA;EACtCC,YAAYC,SAAiB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AUE;AACZC,QAAI,GAAGC,GAAGK,KAAK,SAAST,UAAUM,KAAK,GAAA,IAAO,mBAAmB,MAAA;AAEnE,MAAIL,YAAYC;AACdC,QAAI,GAAGC,GAAGM,IAAI,WAAWT,YAAYK,KAAK,GAAA,IAAO,mBAAmB,MAAA;AACxE;AA5CgBpB;","names":["Exception","Error","message","status","description","constructor","data","ERROR_SYMBOL","ValidateException","Exception","constructor","message","isPhecda","plainToClass","transformClass","defaultPipe","arg","reflect","index","isPhecda","instance","plainToClass","err","transformClass","length","ValidateException","Number","Boolean","includes","Object","is","NaN","UndefinedException","Exception","constructor","message","ForbiddenException","Exception","constructor","message","BadRequestException","Exception","constructor","message","NotFoundException","Exception","constructor","message","ConflictException","Exception","constructor","message","BadGatewayException","Exception","constructor","message","InvalidInputException","Exception","constructor","message","UnsupportedMediaTypeException","Exception","constructor","message","PayloadLargeException","Exception","constructor","message","TimeoutException","Exception","constructor","message","UnauthorizedException","Exception","constructor","message","ServiceUnavailableException","Exception","constructor","message","FrameworkException","Exception","constructor","message","pc","defaultFilter","e","Exception","log","message","console","error","stack","UndefinedException","constructor","name","data","Histroy","guard","interceptor","record","name","type","includes","push","guardRecord","Context","tag","data","method","params","history","postInterceptors","constructor","Histroy","IS_DEV","_context","usePipe","args","Promise","all","map","item","pipe","pipeRecord","IS_STRICT","FrameworkException","default","useFilter","arg","filter","filterRecord","useGuard","guards","guard","record","ForbiddenException","usePostInterceptor","ret","cb","useInterceptor","interceptors","interceptor","interceptorRecord","postInterceptor","undefined","push","usePlugin","plugins","m","pluginRecord","defaultFilter","defaultPipe","addPlugin","key","handler","addPipe","addFilter","addGuard","addInterceptor","isAopDepInject","meta","pluginSet","Set","guardSet","interceptorSet","pipeSet","filterSet","forEach","add","i","missPlugins","missGuards","missInterceptors","missPipes","missFilters","length","log","pc","white","join","magenta","cyan","blue","red"]}
@@ -14,9 +14,12 @@ var META_SYMBOL = "__PS_META__";
14
14
  var APP_SYMBOL = "__PS__";
15
15
  var IS_DEV = process.env.NODE_ENV === "development";
16
16
  var IS_STRICT = !!process.env.PS_STRICT;
17
+ var ERROR_SYMBOL = "__PS_ERROR__";
17
18
 
18
19
  // src/utils.ts
19
20
  import pc from "picocolors";
21
+ import { DataMap } from "phecda-core";
22
+ var time;
20
23
  function log(msg, level = "info") {
21
24
  const color = {
22
25
  error: "red",
@@ -24,20 +27,41 @@ function log(msg, level = "info") {
24
27
  warn: "yellow"
25
28
  }[level];
26
29
  const date = new Date();
27
- console.log(`${pc.magenta("[phecda-server]")} ${pc.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${pc[color](msg)}`);
30
+ const current = Date.now();
31
+ const interval = time && current - time ? `+${current - time}` : "";
32
+ time = current;
33
+ console.log(`${pc.magenta("[phecda-server]")} ${pc.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${pc[color](msg)} ${pc.gray(interval)}`);
28
34
  }
29
35
  __name(log, "log");
36
+ function getConfig(key, defaultConf) {
37
+ if (!DataMap[key]) {
38
+ if (defaultConf)
39
+ return defaultConf;
40
+ throw new Error(`config "${key}" is not existed`);
41
+ }
42
+ return DataMap[key];
43
+ }
44
+ __name(getConfig, "getConfig");
45
+ function setConfig(key, conf, force = true) {
46
+ if (DataMap[key] && !force)
47
+ return;
48
+ DataMap[key] = conf;
49
+ }
50
+ __name(setConfig, "setConfig");
30
51
 
31
52
  export {
32
53
  __name,
33
54
  __publicField,
34
- log,
35
55
  MERGE_SYMBOL,
36
56
  UNMOUNT_SYMBOL,
37
57
  MODULE_SYMBOL,
38
58
  META_SYMBOL,
39
59
  APP_SYMBOL,
40
60
  IS_DEV,
41
- IS_STRICT
61
+ IS_STRICT,
62
+ ERROR_SYMBOL,
63
+ log,
64
+ getConfig,
65
+ setConfig
42
66
  };
43
- //# sourceMappingURL=chunk-AJ2HYENF.mjs.map
67
+ //# sourceMappingURL=chunk-DQUH5BP6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/common.ts","../src/utils.ts"],"sourcesContent":["export const MERGE_SYMBOL = '__PS_MERGE__'\nexport const UNMOUNT_SYMBOL = '__PS_UNMOUNT__'\nexport const MODULE_SYMBOL = '__PS_MODULE__'\nexport const META_SYMBOL = '__PS_META__'\nexport const APP_SYMBOL = '__PS__'\nexport const IS_DEV = process.env.NODE_ENV === 'development'\nexport const IS_STRICT = !!process.env.PS_STRICT\nexport const ERROR_SYMBOL = '__PS_ERROR__'\n","import pc from 'picocolors'\nimport { DataMap } from 'phecda-core'\n\nlet time: number\n\nexport function log(msg: string, level: 'error' | 'info' | 'warn' = 'info') {\n const color = ({ error: 'red', info: 'green', warn: 'yellow' } as const)[level]\n const date = new Date()\n const current = Date.now()\n const interval = (time && current - time) ? `+${current - time}` : ''\n time = current\n // eslint-disable-next-line no-console\n console.log(`${pc.magenta('[phecda-server]')} ${pc.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${pc[color](msg)} ${pc.gray(interval)}`)\n}\n\nexport function getConfig<C = any>(key: string, defaultConf?: C): C {\n if (!DataMap[key]) {\n if (defaultConf)\n return defaultConf\n throw new Error(`config \"${key}\" is not existed`)\n }\n\n return DataMap[key]\n}\n\nexport function setConfig<C = any>(key: string, conf: C, force = true) {\n if (DataMap[key] && !force)\n return\n\n DataMap[key] = conf\n}\n"],"mappings":";;;;;;;;;AAAO,IAAMA,eAAe;AACrB,IAAMC,iBAAiB;AACvB,IAAMC,gBAAgB;AACtB,IAAMC,cAAc;AACpB,IAAMC,aAAa;AACnB,IAAMC,SAASC,QAAQC,IAAIC,aAAa;AACxC,IAAMC,YAAY,CAAC,CAACH,QAAQC,IAAIG;AAChC,IAAMC,eAAe;;;ACP5B,OAAOC,QAAQ;AACf,SAASC,eAAe;AAExB,IAAIC;AAEG,SAASC,IAAIC,KAAaC,QAAmC,QAAQ;AAC1E,QAAMC,QAAS;IAAEC,OAAO;IAAOC,MAAM;IAASC,MAAM;EAAS,EAAYJ;AACzE,QAAMK,OAAO,IAAIC,KAAAA;AACjB,QAAMC,UAAUD,KAAKE,IAAG;AACxB,QAAMC,WAAYZ,QAAQU,UAAUV,OAAQ,IAAIU,UAAUV,SAAS;AACnEA,SAAOU;AAEPG,UAAQZ,IAAI,GAAGa,GAAGC,QAAQ,iBAAA,KAAsBD,GAAGE,KAAK,GAAGR,KAAKS,SAAQ,KAAMT,KAAKU,WAAU,KAAMV,KAAKW,WAAU,GAAI,KAAKL,GAAGV,OAAOF,GAAAA,KAAQY,GAAGE,KAAKJ,QAAAA,GAAW;AAClK;AARgBX;AAUT,SAASmB,UAAmBC,KAAaC,aAAoB;AAClE,MAAI,CAACC,QAAQF,MAAM;AACjB,QAAIC;AACF,aAAOA;AACT,UAAM,IAAIE,MAAM,WAAWH,qBAAqB;EAClD;AAEA,SAAOE,QAAQF;AACjB;AARgBD;AAUT,SAASK,UAAmBJ,KAAaK,MAASC,QAAQ,MAAM;AACrE,MAAIJ,QAAQF,QAAQ,CAACM;AACnB;AAEFJ,UAAQF,OAAOK;AACjB;AALgBD;","names":["MERGE_SYMBOL","UNMOUNT_SYMBOL","MODULE_SYMBOL","META_SYMBOL","APP_SYMBOL","IS_DEV","process","env","NODE_ENV","IS_STRICT","PS_STRICT","ERROR_SYMBOL","pc","DataMap","time","log","msg","level","color","error","info","warn","date","Date","current","now","interval","console","pc","magenta","gray","getHours","getMinutes","getSeconds","getConfig","key","defaultConf","DataMap","Error","setConfig","conf","force"]}
@@ -3,7 +3,7 @@ import {
3
3
  UNMOUNT_SYMBOL,
4
4
  __name,
5
5
  log
6
- } from "./chunk-AJ2HYENF.mjs";
6
+ } from "./chunk-DQUH5BP6.mjs";
7
7
 
8
8
  // src/meta.ts
9
9
  var Meta = class {
@@ -105,7 +105,6 @@ import fs from "fs";
105
105
  import EventEmitter from "node:events";
106
106
  import { Empty, getExposeKey, getHandler, getState, injectProperty, isPhecda, registerAsync } from "phecda-core";
107
107
  import Debug from "debug";
108
- import pc from "picocolors";
109
108
  function Injectable() {
110
109
  return (target) => Empty(target);
111
110
  }
@@ -135,12 +134,12 @@ async function Factory(Modules, opts = {}) {
135
134
  if (!moduleMap.has(tag))
136
135
  return;
137
136
  const instance = moduleMap.get(tag);
137
+ debug(`unmount module "${tag}"`);
138
138
  if (instance?.[UNMOUNT_SYMBOL]) {
139
139
  for (const cb of instance[UNMOUNT_SYMBOL])
140
140
  await cb();
141
141
  }
142
142
  debug(`del module "${tag}"`);
143
- log(`Module ${pc.yellow(`[${tag}]`)} unmount`);
144
143
  moduleMap.delete(tag);
145
144
  constructorMap.delete(tag);
146
145
  for (let i = meta.length - 1; i >= 0; i--) {
@@ -154,8 +153,8 @@ async function Factory(Modules, opts = {}) {
154
153
  const tag = Module.prototype?.__TAG__ || Module.name;
155
154
  const oldInstance = await del(tag);
156
155
  const { instance: newModule } = await buildNestModule(Module);
157
- debug(`add module "${tag}"`);
158
156
  if (oldInstance && moduleGraph.has(tag)) {
157
+ debug(`replace module "${tag}"`);
159
158
  [
160
159
  ...moduleGraph.get(tag)
161
160
  ].forEach((tag2) => {
@@ -166,7 +165,6 @@ async function Factory(Modules, opts = {}) {
166
165
  }
167
166
  });
168
167
  }
169
- moduleMap.set(tag, newModule);
170
168
  }
171
169
  __name(add, "add");
172
170
  async function buildNestModule(Module) {
@@ -196,14 +194,17 @@ async function Factory(Modules, opts = {}) {
196
194
  moduleGraph.set(subTag, /* @__PURE__ */ new Set());
197
195
  moduleGraph.get(subTag).add(tag);
198
196
  }
197
+ debug(`instantiate module "${tag}"`);
199
198
  instance = new Module(...paramtypesInstances);
200
199
  } else {
200
+ debug(`instantiate module "${tag}"`);
201
201
  instance = new Module();
202
202
  }
203
203
  meta.push(...getMetaFromInstance(instance, tag, Module.name));
204
+ debug(`init module "${tag}"`);
204
205
  await registerAsync(instance);
206
+ debug(`add module "${tag}"`);
205
207
  moduleMap.set(tag, instance);
206
- log(`Module ${pc.yellow(`[${tag}]`)} mount"`);
207
208
  constructorMap.set(tag, Module);
208
209
  return {
209
210
  instance,
@@ -214,9 +215,14 @@ async function Factory(Modules, opts = {}) {
214
215
  for (const Module of Modules)
215
216
  await buildNestModule(Module);
216
217
  function writeCode() {
217
- debug("write code");
218
- http && fs.promises.writeFile(http, generateHTTPCode(meta.map((item) => item.data)));
219
- rpc && fs.promises.writeFile(rpc, generateRPCCode(meta.map((item) => item.data)));
218
+ if (http) {
219
+ debug(`write http code to ${http}`);
220
+ fs.promises.writeFile(http, generateHTTPCode(meta.map((item) => item.data)));
221
+ }
222
+ if (rpc) {
223
+ debug(`write rpc code to ${rpc}`);
224
+ fs.promises.writeFile(rpc, generateRPCCode(meta.map((item) => item.data)));
225
+ }
220
226
  }
221
227
  __name(writeCode, "writeCode");
222
228
  writeCode();
@@ -224,8 +230,8 @@ async function Factory(Modules, opts = {}) {
224
230
  if (!globalThis.__PS_HMR__)
225
231
  globalThis.__PS_HMR__ = [];
226
232
  globalThis.__PS_HMR__?.push(async (files) => {
233
+ debug("reload files ");
227
234
  for (const file of files) {
228
- debug(`reload file ${file}`);
229
235
  const module = await import(file);
230
236
  for (const i in module) {
231
237
  if (isPhecda(module[i]))
@@ -276,6 +282,7 @@ function getMetaFromInstance(instance, tag, name) {
276
282
  break;
277
283
  }
278
284
  meta.params = params;
285
+ meta.filter = state.filter || baseState.filter;
279
286
  meta.define = {
280
287
  ...baseState.define,
281
288
  ...state.define
@@ -332,4 +339,4 @@ export {
332
339
  emitter,
333
340
  Factory
334
341
  };
335
- //# sourceMappingURL=chunk-NFAA3WFR.mjs.map
342
+ //# sourceMappingURL=chunk-F5PQVQTY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/meta.ts","../src/compiler/rpc.ts","../src/compiler/http.ts","../src/core.ts"],"sourcesContent":["import type { P } from './types'\n\nexport class Meta {\n constructor(public data: P.Meta, public handlers: P.Handler[], public paramsType: any[]) {\n\n }\n}\n","import type { P } from '../types'\n\nclass Compiler {\n classMap: Record<string, { [key: string]: string }> = {}\n constructor() { }\n\n getContent() {\n let content = ''\n\n for (const name in this.classMap) {\n content += `\n export class ${name}{\n ${Object.values(this.classMap[name]).reduce((p, c) => p + c)}\n }`\n }\n return content\n }\n\n addMethod(args: P.Meta) {\n const {\n rpc, name, method, tag,\n } = args\n if (!rpc || !rpc.type)\n return\n if (!this.classMap[name])\n this.classMap[name] = {}\n this.classMap[name][method] = `\n ${method}(){\n return {tag:'${tag}-${method}',isEvent:${!!rpc.isEvent},rpc:[${rpc.type.reduce((p, c) => {\n return `${p}\"${c}\",`\n }, '')}]}\n\n }\n `\n }\n}\n\nexport function generateRPCCode(meta: P.Meta[]) {\n const compiler = new Compiler()\n\n for (const i of meta)\n compiler.addMethod(i)\n return compiler.getContent()\n}\n","import type { P } from '../types'\n\nclass Compiler {\n classMap: Record<string, { [key: string]: string }> = {}\n constructor() { }\n\n getContent() {\n let content = ''\n\n for (const name in this.classMap) {\n content += `\n export class ${name}{\n ${Object.values(this.classMap[name]).reduce((p, c) => p + c)}\n }`\n }\n return content\n }\n\n // createRequest() {\n // let content = 'import {useC} from \\'phecda-server\\'\\n'\n // for (const name in this.classMap)\n // content += `export const {${Object.keys(this.classMap[name]).join(',')}}=useC(${name})\\n`\n // return content\n // }\n\n addMethod(args: P.Meta) {\n const {\n http, name, method, params, tag,\n } = args\n if (!http)\n return\n const url = http.route.replace(/\\/\\:([^\\/]*)/g, (_, js) => `/{{${js}}}`)\n if (!this.classMap[name])\n this.classMap[name] = {}\n this.classMap[name][method] = `\n ${method}(...args){\nconst ret={tag:\"${tag}-${method}\",body:{},headers:{},query:{},params:{},method:\"${http.type}\",url:\"${url}\",args}\n\n${params.reduce((p, c, i) => `${p}ret.${c.type}${c.key ? `['${c.key}']` : ''}=args[${i}]\\n${c.type === 'params' ? `ret.url=ret.url.replace('{{${c.key}}}',args[${i}])` : ''}\\n`, '')}\nreturn ret\n }\n `\n }\n}\n\nexport function generateHTTPCode(meta: P.Meta[]) {\n const compiler = new Compiler()\n\n for (const i of meta)\n compiler.addMethod(i)\n return compiler.getContent()\n}\n","import 'reflect-metadata'\nimport fs from 'fs'\nimport EventEmitter from 'node:events'\nimport type { Phecda } from 'phecda-core'\nimport { Empty, getExposeKey, getHandler, getState, injectProperty, isPhecda, registerAsync } from 'phecda-core'\nimport Debug from 'debug'\nimport type { Construct, Emitter, P } from './types'\nimport { Meta } from './meta'\nimport { log } from './utils'\nimport { IS_DEV, UNMOUNT_SYMBOL } from './common'\nimport { generateHTTPCode, generateRPCCode } from './compiler'\nexport function Injectable() {\n return (target: any) => Empty(target)\n}\nconst debug = Debug('phecda-server')\n// TODO: support both emitter types and origin emitter type in future\nexport const emitter: Emitter = new EventEmitter() as any\n\nexport async function Factory(Modules: (new (...args: any) => any)[], opts: {\n\n // HTTP generate code path\n http?: string\n // rpc generate code path\n rpc?: string\n} = {}) {\n const moduleMap = new Map<string, InstanceType<Construct>>()\n const meta: Meta[] = []\n const constructorMap = new Map()\n\n // only work for warn\n const constructorSet = new WeakSet()\n const moduleGraph = new Map<string, Set<string>>()\n const { http, rpc } = opts\n injectProperty('watcher', ({ eventName, instance, key, options }: { eventName: string; instance: any; key: string; options?: { once: boolean } }) => {\n const fn = typeof instance[key] === 'function' ? instance[key].bind(instance) : (v: any) => instance[key] = v\n\n // work for hmr\n if (!instance[UNMOUNT_SYMBOL])\n instance[UNMOUNT_SYMBOL] = []\n\n instance[UNMOUNT_SYMBOL].push(() => {\n (emitter as any).off(eventName, fn)\n })\n\n if (options?.once)\n (emitter as any).once(eventName, fn)\n\n else\n (emitter as any).on(eventName, fn)\n })\n\n // only remove module in moduleMap(won't remove indiect module)\n async function del(tag: string) {\n if (!moduleMap.has(tag))\n return\n\n const instance = moduleMap.get(tag)\n\n debug(`unmount module \"${tag}\"`)\n\n if (instance?.[UNMOUNT_SYMBOL]) {\n for (const cb of instance[UNMOUNT_SYMBOL])\n await cb()\n }\n\n debug(`del module \"${tag}\"`)\n\n moduleMap.delete(tag)\n constructorMap.delete(tag)\n for (let i = meta.length - 1; i >= 0; i--) {\n if (meta[i].data.tag === tag)\n meta.splice(i, 1)\n }\n\n return instance\n }\n\n async function add(Module: Construct) {\n const tag = Module.prototype?.__TAG__ || Module.name\n const oldInstance = await del(tag)\n\n const { instance: newModule } = await buildNestModule(Module)\n\n if (oldInstance && moduleGraph.has(tag)) {\n debug(`replace module \"${tag}\"`);\n\n [...moduleGraph.get(tag)!].forEach((tag) => {\n const module = moduleMap.get(tag)\n for (const key in module) {\n if (module[key] === oldInstance)\n module[key] = newModule\n }\n })\n }\n }\n async function buildNestModule(Module: Construct) {\n const paramtypes = getParamTypes(Module) as Construct[]\n let instance: InstanceType<Construct>\n const tag = Module.prototype?.__TAG__ || Module.name\n if (moduleMap.has(tag)) {\n instance = moduleMap.get(tag)\n if (!instance)\n throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`)\n\n if (constructorMap.get(tag) !== Module && !constructorSet.has(Module)) {\n constructorSet.add(Module)// a module will only warn once\n log(`Synonym module: Module taged \"${tag}\" has been loaded before, so phecda-server won't load Module \"${Module.name}\"`, 'warn')\n }\n return { instance, tag }\n }\n moduleMap.set(tag, undefined)\n if (paramtypes) {\n const paramtypesInstances = [] as any[]\n for (const i in paramtypes) {\n const { instance: sub, tag: subTag } = await buildNestModule(paramtypes[i])\n paramtypesInstances[i] = sub\n if (!moduleGraph.has(subTag))\n moduleGraph.set(subTag, new Set())\n moduleGraph.get(subTag)!.add(tag)\n }\n debug(`instantiate module \"${tag}\"`)\n\n instance = new Module(...paramtypesInstances)\n }\n else {\n debug(`instantiate module \"${tag}\"`)\n\n instance = new Module()\n }\n meta.push(...getMetaFromInstance(instance, tag, Module.name))\n\n debug(`init module \"${tag}\"`)\n\n await registerAsync(instance)\n\n debug(`add module \"${tag}\"`)\n\n moduleMap.set(tag, instance)\n constructorMap.set(tag, Module)\n return { instance, tag }\n }\n\n for (const Module of Modules)\n await buildNestModule(Module)\n\n function writeCode() {\n if (http) {\n debug(`write http code to ${http}`)\n fs.promises.writeFile(http, generateHTTPCode(meta.map(item => item.data)))\n }\n if (rpc) {\n debug(`write rpc code to ${rpc}`)\n\n fs.promises.writeFile(rpc, generateRPCCode(meta.map(item => item.data)))\n }\n }\n\n writeCode()\n if (IS_DEV) {\n if (!globalThis.__PS_HMR__)\n globalThis.__PS_HMR__ = []\n\n globalThis.__PS_HMR__?.push(async (files: string[]) => {\n debug('reload files ')\n\n for (const file of files) {\n const module = await import(file)\n for (const i in module) {\n if (isPhecda(module[i]))\n await add(module[i])\n }\n }\n writeCode()\n })\n }\n\n return {\n moduleMap,\n meta,\n constructorMap,\n add,\n del,\n }\n}\n\nfunction getMetaFromInstance(instance: Phecda, tag: string, name: string) {\n const vars = getExposeKey(instance).filter(item => item !== '__CLASS')\n const baseState = (getState(instance, '__CLASS') || {}) as P.Meta\n initState(baseState)\n\n return vars.map((i) => {\n const meta = {} as P.Meta\n const state = (getState(instance, i) || {}) as P.Meta\n initState(state)\n if (state.http) {\n meta.http = {\n route: (baseState.http?.route || '') + (state.http.route),\n type: state.http.type,\n }\n }\n if (baseState.rpc)\n meta.rpc = baseState.rpc\n if (state.rpc) {\n meta.rpc = {\n ...meta.rpc,\n ...state.rpc,\n }\n }\n\n meta.name = name\n meta.tag = tag\n meta.method = i as string\n const params = [] as any[]\n for (const i of state.params || []) {\n params.unshift(i)\n if (i.index === 0)\n break\n }\n\n meta.params = params\n meta.filter = state.filter || baseState.filter\n meta.define = { ...baseState.define, ...state.define }\n meta.header = { ...baseState.header, ...state.header }\n meta.plugins = [...new Set([...baseState.plugins, ...state.plugins])]\n meta.guards = [...new Set([...baseState.guards, ...state.guards])]\n meta.interceptors = [...new Set([...baseState.interceptors, ...state.interceptors])]\n\n return new Meta(meta as unknown as P.Meta, getHandler(instance, i), getParamTypes(instance, i as string) || [])\n })\n}\n\nfunction getParamTypes(Module: any, key?: string | symbol) {\n return Reflect.getMetadata('design:paramtypes', Module, key!)\n}\n\nfunction initState(state: any) {\n if (!state.define)\n state.define = {}\n if (!state.header)\n state.header = {}\n if (!state.plugins)\n state.plugins = []\n if (!state.guards)\n state.guards = []\n if (!state.interceptors)\n state.interceptors = []\n}\n"],"mappings":";;;;;;;;AAEO,IAAMA,OAAN,MAAMA;EACQC;EAAqBC;EAA8BC;EAAtEC,YAAmBH,MAAqBC,UAA8BC,YAAmB;gBAAtEF;oBAAqBC;sBAA8BC;EAEtE;AACF;AAJaH;;;ACAb,IAAMK,WAAN,6BAAMA,UAAAA;EACJC,WAAsD,CAAC;EACvDC,cAAc;EAAE;EAEhBC,aAAa;AACX,QAAIC,UAAU;AAEd,eAAWC,QAAQ,KAAKJ,UAAU;AAChCG,iBAAW;uBACMC;cACTC,OAAOC,OAAO,KAAKN,SAASI,KAAK,EAAEG,OAAO,CAACC,GAAGC,MAAMD,IAAIC,CAAAA;;IAElE;AACA,WAAON;EACT;EAEAO,UAAUC,MAAc;AACtB,UAAM,EACJC,KAAKR,MAAMS,QAAQC,IAAG,IACpBH;AACJ,QAAI,CAACC,OAAO,CAACA,IAAIG;AACf;AACF,QAAI,CAAC,KAAKf,SAASI;AACjB,WAAKJ,SAASI,QAAQ,CAAC;AACzB,SAAKJ,SAASI,MAAMS,UAAU;MAC5BA;qBACeC,OAAOD,mBAAmB,CAAC,CAACD,IAAII,gBAAgBJ,IAAIG,KAAKR,OAAO,CAACC,GAAGC,MAAM;AACvF,aAAO,GAAGD,KAAKC;IACjB,GAAG,EAAA;;;;EAIP;AACF,GAjCA;AAmCO,SAASQ,gBAAgBC,MAAgB;AAC9C,QAAMC,WAAW,IAAIpB,SAAAA;AAErB,aAAWqB,KAAKF;AACdC,aAAST,UAAUU,CAAAA;AACrB,SAAOD,SAASjB,WAAU;AAC5B;AANgBe;;;ACnChB,IAAMI,YAAN,6BAAMA,UAAAA;EACJC,WAAsD,CAAC;EACvDC,cAAc;EAAE;EAEhBC,aAAa;AACX,QAAIC,UAAU;AAEd,eAAWC,QAAQ,KAAKJ,UAAU;AAChCG,iBAAW;uBAC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AAS;SAAI,oBAAIjC,IAAI;WAAIoB,UAAUa;WAAWV,MAAMU;OAAO;;AAChElF,SAAKmF,eAAe;SAAI,oBAAIlC,IAAI;WAAIoB,UAAUc;WAAiBX,MAAMW;OAAa;;AAElF,WAAO,IAAIC,KAAKpF,MAA2BqF,WAAW5E,UAAUiB,CAAAA,GAAIe,cAAchC,UAAUiB,CAAAA,KAAgB,CAAA,CAAE;EAChH,CAAA;AACF;AA5CSwB;AA8CT,SAAST,cAAcV,QAAarB,KAAuB;AACzD,SAAO4E,QAAQC,YAAY,qBAAqBxD,QAAQrB,GAAAA;AAC1D;AAFS+B;AAIT,SAAS8B,UAAUC,OAAY;AAC7B,MAAI,CAACA,MAAMO;AACTP,UAAMO,SAAS,CAAC;AAClB,MAAI,CAACP,MAAMQ;AACTR,UAAMQ,SAAS,CAAC;AAClB,MAAI,CAACR,MAAMS;AACTT,UAAMS,UAAU,CAAA;AAClB,MAAI,CAACT,MAAMU;AACTV,UAAMU,SAAS,CAAA;AACjB,MAAI,CAACV,MAAMW;AACTX,UAAMW,eAAe,CAAA;AACzB;AAXSZ;","names":["Meta","data","handlers","paramsType","constructor","Compiler","classMap","constructor","getContent","content","name","Object","values","reduce","p","c","addMethod","args","rpc","method","tag","type","isEvent","generateRPCCode","meta","compiler","i","Compiler","classMap","constructor","getContent","content","name","Object","values","reduce","p","c","addMethod","args","http","method","params","tag","url","route","replace","_","js","type","i","key","generateHTTPCode","meta","compiler","fs","EventEmitter","Empty","getExposeKey","getHandler","getState","injectProperty","isPhecda","registerAsync","Debug","Injectable","target","Empty","debug","Debug","emitter","EventEmitter","Factory","Modules","opts","moduleMap","Map","meta","constructorMap","constructorSet","WeakSet","moduleGraph","http","rpc","injectProperty","eventName","instance","key","options","fn","bind","v","UNMOUNT_SYMBOL","push","off","once","on","del","tag","has","get","cb","delete","i","length","data","splice","add","Module","prototype","__TAG__","name","oldInstance","newModule","buildNestModule","forEach","module","paramtypes","getParamTypes","Error","log","set","undefined","paramtypesInstances","sub","subTag","Set","getMetaFromInstance","registerAsync","writeCode","fs","promises","writeFile","generateHTTPCode","map","item","generateRPCCode","IS_DEV","globalThis","__PS_HMR__","files","file","isPhecda","vars","getExposeKey","filter","baseState","getState","initState","state","route","type","method","params","unshift","index","define","header","plugins","guards","interceptors","Meta","getHandler","Reflect","getMetadata"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkLZAU5FUSjs = require('./chunk-LZAU5FUS.js');
3
+ var _chunkZZ2QKZ46js = require('./chunk-ZZ2QKZ46.js');
4
4
 
5
5
  // src/helper.ts
6
6
  function resolveDep(ret, key) {
@@ -8,9 +8,9 @@ function resolveDep(ret, key) {
8
8
  return _optionalChain([ret, 'optionalAccess', _ => _[key]]);
9
9
  return ret;
10
10
  }
11
- _chunkLZAU5FUSjs.__name.call(void 0, resolveDep, "resolveDep");
11
+ _chunkZZ2QKZ46js.__name.call(void 0, resolveDep, "resolveDep");
12
12
 
13
13
 
14
14
 
15
15
  exports.resolveDep = resolveDep;
16
- //# sourceMappingURL=chunk-FAHHXHL5.js.map
16
+ //# sourceMappingURL=chunk-FCLWCFQS.js.map