phecda-server 5.0.0-alpha.12 → 5.0.0-alpha.13

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.
@@ -291,31 +291,31 @@ __publicField(Context, "interceptorRecord", {});
291
291
  __publicField(Context, "addonRecord", {});
292
292
  function addAddon(key, handler) {
293
293
  if (Context.addonRecord[key] && Context.addonRecord[key] !== handler)
294
- log(`overwrite Addon "${key}"`, "warn");
294
+ log(`overwrite Addon "${String(key)}"`, "warn");
295
295
  Context.addonRecord[key] = handler;
296
296
  }
297
297
  __name(addAddon, "addAddon");
298
298
  function addPipe(key, handler) {
299
299
  if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler)
300
- log(`overwrite Pipe "${key}"`, "warn");
300
+ log(`overwrite Pipe "${String(key)}"`, "warn");
301
301
  Context.pipeRecord[key] = handler;
302
302
  }
303
303
  __name(addPipe, "addPipe");
304
304
  function addFilter(key, handler) {
305
305
  if (Context.filterRecord[key] && Context.filterRecord[key] !== handler)
306
- log(`overwrite Filter "${key}"`, "warn");
306
+ log(`overwrite Filter "${String(key)}"`, "warn");
307
307
  Context.filterRecord[key] = handler;
308
308
  }
309
309
  __name(addFilter, "addFilter");
310
310
  function addGuard(key, handler) {
311
311
  if (Context.guardRecord[key] && Context.guardRecord[key] !== handler)
312
- log(`overwrite Guard "${key}"`, "warn");
312
+ log(`overwrite Guard "${String(key)}"`, "warn");
313
313
  Context.guardRecord[key] = handler;
314
314
  }
315
315
  __name(addGuard, "addGuard");
316
316
  function addInterceptor(key, handler) {
317
317
  if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler)
318
- log(`overwrite Interceptor "${key}"`, "warn");
318
+ log(`overwrite Interceptor "${String(key)}"`, "warn");
319
319
  Context.interceptorRecord[key] = handler;
320
320
  }
321
321
  __name(addInterceptor, "addInterceptor");
@@ -2,7 +2,6 @@
2
2
 
3
3
 
4
4
 
5
-
6
5
  var _chunkGWLM5DEJjs = require('./chunk-GWLM5DEJ.js');
7
6
 
8
7
  // src/meta.ts
@@ -121,27 +120,22 @@ async function Factory(Modules, opts = {}) {
121
120
  if (!_phecdacore.getProperty.call(void 0, "watcher")) {
122
121
  _phecdacore.injectProperty.call(void 0, "watcher", ({ eventName, instance, key, options }) => {
123
122
  const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
124
- if (!instance[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL])
125
- instance[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL] = [];
126
- instance[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL].push(() => {
127
- emitter.off(eventName, fn);
128
- });
129
123
  if (_optionalChain([options, 'optionalAccess', _2 => _2.once]))
130
124
  emitter.once(eventName, fn);
131
125
  else
132
126
  emitter.on(eventName, fn);
127
+ return () => {
128
+ emitter.off(eventName, fn);
129
+ };
133
130
  });
134
131
  }
135
132
  async function del(tag) {
136
133
  if (!moduleMap.has(tag))
137
134
  return;
138
135
  const instance = moduleMap.get(tag);
139
- debug(`unmount module "${tag}"`);
140
- if (_optionalChain([instance, 'optionalAccess', _3 => _3[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL]])) {
141
- for (const cb of instance[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL])
142
- await cb();
143
- }
144
- debug(`del module "${tag}"`);
136
+ debug(`unmount module "${String(tag)}"`);
137
+ _phecdacore.unmountParallel.call(void 0, instance);
138
+ debug(`del module "${String(tag)}"`);
145
139
  moduleMap.delete(tag);
146
140
  constructorMap.delete(tag);
147
141
  for (let i = meta.length - 1; i >= 0; i--) {
@@ -158,7 +152,7 @@ async function Factory(Modules, opts = {}) {
158
152
  }
159
153
  _chunkGWLM5DEJjs.__name.call(void 0, destroy, "destroy");
160
154
  async function add(Module) {
161
- const tag = _optionalChain([Module, 'access', _4 => _4.prototype, 'optionalAccess', _5 => _5.__TAG__]) || Module.name;
155
+ const tag = _optionalChain([Module, 'access', _3 => _3.prototype, 'optionalAccess', _4 => _4.__TAG__]) || Module.name;
162
156
  const oldInstance = await del(tag);
163
157
  const { instance: newModule } = await buildNestModule(Module);
164
158
  if (oldInstance && moduleGraph.has(tag)) {
@@ -182,10 +176,10 @@ async function Factory(Modules, opts = {}) {
182
176
  if (moduleMap.has(tag)) {
183
177
  instance = moduleMap.get(tag);
184
178
  if (!instance)
185
- throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`);
179
+ throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Module}`);
186
180
  if (constructorMap.get(tag) !== Module && !constructorSet.has(Module)) {
187
181
  constructorSet.add(Module);
188
- _chunkGWLM5DEJjs.log.call(void 0, `Synonym module: Module taged "${tag}" has been loaded before, so phecda-server won't load Module "${Module.name}"`, "warn");
182
+ _chunkGWLM5DEJjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Module.name}"`, "warn");
189
183
  }
190
184
  return {
191
185
  instance,
@@ -193,7 +187,7 @@ async function Factory(Modules, opts = {}) {
193
187
  };
194
188
  }
195
189
  moduleMap.set(tag, void 0);
196
- debug(`instantiate module "${tag}"`);
190
+ debug(`instantiate module "${String(tag)}"`);
197
191
  if (paramtypes) {
198
192
  const paramtypesInstances = [];
199
193
  for (const i in paramtypes) {
@@ -208,9 +202,9 @@ async function Factory(Modules, opts = {}) {
208
202
  instance = new Module();
209
203
  }
210
204
  meta.push(...getMetaFromInstance(instance, tag, Module.name));
211
- debug(`init module "${tag}"`);
205
+ debug(`init module "${String(tag)}"`);
212
206
  await _phecdacore.registerSerial.call(void 0, instance);
213
- debug(`add module "${tag}"`);
207
+ debug(`add module "${String(tag)}"`);
214
208
  moduleMap.set(tag, instance);
215
209
  constructorMap.set(tag, Module);
216
210
  return {
@@ -236,7 +230,7 @@ async function Factory(Modules, opts = {}) {
236
230
  if (_chunkGWLM5DEJjs.IS_DEV) {
237
231
  if (!globalThis.__PS_HMR__)
238
232
  globalThis.__PS_HMR__ = [];
239
- _optionalChain([globalThis, 'access', _6 => _6.__PS_HMR__, 'optionalAccess', _7 => _7.push, 'call', _8 => _8(async (files) => {
233
+ _optionalChain([globalThis, 'access', _5 => _5.__PS_HMR__, 'optionalAccess', _6 => _6.push, 'call', _7 => _7(async (files) => {
240
234
  debug("reload files ");
241
235
  for (const file of files) {
242
236
  const module = await Promise.resolve().then(() => require(file));
@@ -268,7 +262,7 @@ function getMetaFromInstance(instance, tag, name) {
268
262
  initState(state);
269
263
  if (state.http) {
270
264
  meta.http = {
271
- route: (_optionalChain([baseState, 'access', _9 => _9.http, 'optionalAccess', _10 => _10.route]) || "") + state.http.route,
265
+ route: (_optionalChain([baseState, 'access', _8 => _8.http, 'optionalAccess', _9 => _9.route]) || "") + state.http.route,
272
266
  type: state.http.type
273
267
  };
274
268
  }
@@ -280,6 +274,8 @@ function getMetaFromInstance(instance, tag, name) {
280
274
  ...state.rpc
281
275
  };
282
276
  }
277
+ if (typeof tag !== "string" && (meta.rpc || meta.http))
278
+ _chunkGWLM5DEJjs.log.call(void 0, `can't use Tag with ${typeof tag} on http/rpc controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
283
279
  meta.name = name;
284
280
  meta.tag = tag;
285
281
  meta.method = i;
@@ -291,31 +291,31 @@ _chunkGWLM5DEJjs.__publicField.call(void 0, Context, "interceptorRecord", {});
291
291
  _chunkGWLM5DEJjs.__publicField.call(void 0, Context, "addonRecord", {});
292
292
  function addAddon(key, handler) {
293
293
  if (Context.addonRecord[key] && Context.addonRecord[key] !== handler)
294
- _chunkGWLM5DEJjs.log.call(void 0, `overwrite Addon "${key}"`, "warn");
294
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Addon "${String(key)}"`, "warn");
295
295
  Context.addonRecord[key] = handler;
296
296
  }
297
297
  _chunkGWLM5DEJjs.__name.call(void 0, addAddon, "addAddon");
298
298
  function addPipe(key, handler) {
299
299
  if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler)
300
- _chunkGWLM5DEJjs.log.call(void 0, `overwrite Pipe "${key}"`, "warn");
300
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Pipe "${String(key)}"`, "warn");
301
301
  Context.pipeRecord[key] = handler;
302
302
  }
303
303
  _chunkGWLM5DEJjs.__name.call(void 0, addPipe, "addPipe");
304
304
  function addFilter(key, handler) {
305
305
  if (Context.filterRecord[key] && Context.filterRecord[key] !== handler)
306
- _chunkGWLM5DEJjs.log.call(void 0, `overwrite Filter "${key}"`, "warn");
306
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Filter "${String(key)}"`, "warn");
307
307
  Context.filterRecord[key] = handler;
308
308
  }
309
309
  _chunkGWLM5DEJjs.__name.call(void 0, addFilter, "addFilter");
310
310
  function addGuard(key, handler) {
311
311
  if (Context.guardRecord[key] && Context.guardRecord[key] !== handler)
312
- _chunkGWLM5DEJjs.log.call(void 0, `overwrite Guard "${key}"`, "warn");
312
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Guard "${String(key)}"`, "warn");
313
313
  Context.guardRecord[key] = handler;
314
314
  }
315
315
  _chunkGWLM5DEJjs.__name.call(void 0, addGuard, "addGuard");
316
316
  function addInterceptor(key, handler) {
317
317
  if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler)
318
- _chunkGWLM5DEJjs.log.call(void 0, `overwrite Interceptor "${key}"`, "warn");
318
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Interceptor "${String(key)}"`, "warn");
319
319
  Context.interceptorRecord[key] = handler;
320
320
  }
321
321
  _chunkGWLM5DEJjs.__name.call(void 0, addInterceptor, "addInterceptor");
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  IS_DEV,
3
- UNMOUNT_SYMBOL,
4
3
  __name,
5
4
  log
6
5
  } from "./chunk-DJO45NRZ.mjs";
@@ -103,7 +102,7 @@ __name(generateHTTPCode, "generateHTTPCode");
103
102
  import "reflect-metadata";
104
103
  import fs from "fs";
105
104
  import EventEmitter from "node:events";
106
- import { Empty, SHARE_KEY, getExposeKey, getHandler, getProperty, getState, getTag, injectProperty, isPhecda, registerSerial } from "phecda-core";
105
+ import { Empty, SHARE_KEY, getExposeKey, getHandler, getProperty, getState, getTag, injectProperty, isPhecda, registerSerial, unmountParallel } from "phecda-core";
107
106
  import Debug from "debug";
108
107
  function Injectable() {
109
108
  return (target) => Empty(target);
@@ -121,27 +120,22 @@ async function Factory(Modules, opts = {}) {
121
120
  if (!getProperty("watcher")) {
122
121
  injectProperty("watcher", ({ eventName, instance, key, options }) => {
123
122
  const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
124
- if (!instance[UNMOUNT_SYMBOL])
125
- instance[UNMOUNT_SYMBOL] = [];
126
- instance[UNMOUNT_SYMBOL].push(() => {
127
- emitter.off(eventName, fn);
128
- });
129
123
  if (options?.once)
130
124
  emitter.once(eventName, fn);
131
125
  else
132
126
  emitter.on(eventName, fn);
127
+ return () => {
128
+ emitter.off(eventName, fn);
129
+ };
133
130
  });
134
131
  }
135
132
  async function del(tag) {
136
133
  if (!moduleMap.has(tag))
137
134
  return;
138
135
  const instance = moduleMap.get(tag);
139
- debug(`unmount module "${tag}"`);
140
- if (instance?.[UNMOUNT_SYMBOL]) {
141
- for (const cb of instance[UNMOUNT_SYMBOL])
142
- await cb();
143
- }
144
- debug(`del module "${tag}"`);
136
+ debug(`unmount module "${String(tag)}"`);
137
+ unmountParallel(instance);
138
+ debug(`del module "${String(tag)}"`);
145
139
  moduleMap.delete(tag);
146
140
  constructorMap.delete(tag);
147
141
  for (let i = meta.length - 1; i >= 0; i--) {
@@ -182,10 +176,10 @@ async function Factory(Modules, opts = {}) {
182
176
  if (moduleMap.has(tag)) {
183
177
  instance = moduleMap.get(tag);
184
178
  if (!instance)
185
- throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`);
179
+ throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Module}`);
186
180
  if (constructorMap.get(tag) !== Module && !constructorSet.has(Module)) {
187
181
  constructorSet.add(Module);
188
- log(`Synonym module: Module taged "${tag}" has been loaded before, so phecda-server won't load Module "${Module.name}"`, "warn");
182
+ log(`Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Module.name}"`, "warn");
189
183
  }
190
184
  return {
191
185
  instance,
@@ -193,7 +187,7 @@ async function Factory(Modules, opts = {}) {
193
187
  };
194
188
  }
195
189
  moduleMap.set(tag, void 0);
196
- debug(`instantiate module "${tag}"`);
190
+ debug(`instantiate module "${String(tag)}"`);
197
191
  if (paramtypes) {
198
192
  const paramtypesInstances = [];
199
193
  for (const i in paramtypes) {
@@ -208,9 +202,9 @@ async function Factory(Modules, opts = {}) {
208
202
  instance = new Module();
209
203
  }
210
204
  meta.push(...getMetaFromInstance(instance, tag, Module.name));
211
- debug(`init module "${tag}"`);
205
+ debug(`init module "${String(tag)}"`);
212
206
  await registerSerial(instance);
213
- debug(`add module "${tag}"`);
207
+ debug(`add module "${String(tag)}"`);
214
208
  moduleMap.set(tag, instance);
215
209
  constructorMap.set(tag, Module);
216
210
  return {
@@ -280,6 +274,8 @@ function getMetaFromInstance(instance, tag, name) {
280
274
  ...state.rpc
281
275
  };
282
276
  }
277
+ if (typeof tag !== "string" && (meta.rpc || meta.http))
278
+ log(`can't use Tag with ${typeof tag} on http/rpc controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
283
279
  meta.name = name;
284
280
  meta.tag = tag;
285
281
  meta.method = i;
@@ -65,7 +65,9 @@ declare namespace P {
65
65
  type ResOrErr<R> = {
66
66
  [K in keyof R]: Awaited<R[K]> | Error;
67
67
  };
68
- type Res<T> = T;
68
+ type Res<T> = T extends {
69
+ toJSON(): infer R;
70
+ } ? R : T;
69
71
  type Guard<C extends BaseContext = any> = ((ctx: C) => Promise<boolean> | boolean);
70
72
  type Interceptor<C extends BaseContext = any> = (ctx: C) => (any | ((ret: any) => any));
71
73
  type Pipe<C extends BaseContext = any> = (arg: {
@@ -104,7 +106,7 @@ declare namespace P {
104
106
  plugins: string[];
105
107
  method: string;
106
108
  name: string;
107
- tag: string;
109
+ tag: PropertyKey;
108
110
  }
109
111
  }
110
112
 
@@ -114,11 +116,11 @@ declare function Factory(Modules: (new (...args: any) => any)[], opts?: {
114
116
  http?: string;
115
117
  rpc?: string;
116
118
  }): Promise<{
117
- moduleMap: Map<string, any>;
119
+ moduleMap: Map<PropertyKey, any>;
118
120
  meta: Meta[];
119
121
  constructorMap: Map<any, any>;
120
122
  add: (Module: Construct) => Promise<void>;
121
- del: (tag: string) => Promise<any>;
123
+ del: (tag: PropertyKey) => Promise<any>;
122
124
  destroy: () => Promise<void>;
123
125
  }>;
124
126
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Exception, P, M as Meta, U as UNMOUNT_SYMBOL } from './core-295348b7.js';
2
- export { A as APP_SYMBOL, k as ERROR_SYMBOL, a as Emitter, F as Factory, h as IS_DEV, j as IS_LOG_BAN, i as IS_STRICT, I as Injectable, d as MERGE_SYMBOL, g as META_SYMBOL, f as MODULE_SYMBOL, l as PS_FILE_RE, m as PS_IMPORT_RE, c as PickFunc, b as PickKeysByValue, R as RequestType, T as ToControllerMap, e as emitter } from './core-295348b7.js';
1
+ import { E as Exception, P, M as Meta, U as UNMOUNT_SYMBOL } from './core-11dd822c.js';
2
+ export { A as APP_SYMBOL, k as ERROR_SYMBOL, a as Emitter, F as Factory, h as IS_DEV, j as IS_LOG_BAN, i as IS_STRICT, I as Injectable, d as MERGE_SYMBOL, g as META_SYMBOL, f as MODULE_SYMBOL, l as PS_FILE_RE, m as PS_IMPORT_RE, c as PickFunc, b as PickKeysByValue, R as RequestType, T as ToControllerMap, e as emitter } from './core-11dd822c.js';
3
3
  import { Construct } from 'phecda-core';
4
4
  export * from 'phecda-core';
5
5
 
@@ -71,11 +71,11 @@ declare class Context<Data extends P.BaseContext> {
71
71
  method: string;
72
72
  params: string[];
73
73
  history: Histroy;
74
- static filterRecord: Record<string, P.Filter>;
75
- static pipeRecord: Record<string, P.Pipe>;
76
- static guardRecord: Record<string, P.Guard>;
77
- static interceptorRecord: Record<string, P.Interceptor>;
78
- static addonRecord: Record<string, any>;
74
+ static filterRecord: Record<PropertyKey, P.Filter>;
75
+ static pipeRecord: Record<PropertyKey, P.Pipe>;
76
+ static guardRecord: Record<PropertyKey, P.Guard>;
77
+ static interceptorRecord: Record<PropertyKey, P.Interceptor>;
78
+ static addonRecord: Record<PropertyKey, any>;
79
79
  postInterceptors: Function[];
80
80
  constructor(data: Data);
81
81
  usePipe(args: {
@@ -93,11 +93,11 @@ declare class Context<Data extends P.BaseContext> {
93
93
  useInterceptor(interceptors: string[]): Promise<any>;
94
94
  static usePlugin(plugins: string[]): any[];
95
95
  }
96
- declare function addAddon<T>(key: string, handler: T): void;
97
- declare function addPipe<C extends P.BaseContext>(key: string, handler: P.Pipe<C>): void;
98
- declare function addFilter<C extends P.BaseContext>(key: string, handler: P.Filter<C>): void;
99
- declare function addGuard<C extends P.BaseContext>(key: string, handler: P.Guard<C>): void;
100
- declare function addInterceptor<C extends P.BaseContext>(key: string, handler: P.Interceptor<C>): void;
96
+ declare function addAddon<T>(key: PropertyKey, handler: T): void;
97
+ declare function addPipe<C extends P.BaseContext>(key: PropertyKey, handler: P.Pipe<C>): void;
98
+ declare function addFilter<C extends P.BaseContext>(key: PropertyKey, handler: P.Filter<C>): void;
99
+ declare function addGuard<C extends P.BaseContext>(key: PropertyKey, handler: P.Guard<C>): void;
100
+ declare function addInterceptor<C extends P.BaseContext>(key: PropertyKey, handler: P.Interceptor<C>): void;
101
101
  declare function isAopDepInject(meta: Meta[], { guards, interceptors, plugins }?: {
102
102
  guards?: string[];
103
103
  interceptors?: string[];
@@ -137,28 +137,29 @@ declare function resolveDep(ret: any, key: string): any;
137
137
  declare class Dev {
138
138
  private readonly [UNMOUNT_SYMBOL];
139
139
  onUnmount(cb: () => void): void;
140
+ private unmount;
140
141
  }
141
142
 
142
143
  declare abstract class PFilter<C extends P.BaseContext = any, E extends Exception = Exception> extends Dev {
143
- readonly key: string;
144
+ readonly key: PropertyKey;
144
145
  constructor(tag?: string);
145
146
  abstract use(error: Error | E, ctx?: C): P.Error;
146
147
  }
147
148
 
148
149
  declare abstract class PGuard<C extends P.BaseContext = any> extends Dev {
149
150
  abstract use(ctx: C): Promise<boolean> | boolean;
150
- readonly key: string;
151
+ readonly key: PropertyKey;
151
152
  constructor(tag?: string);
152
153
  }
153
154
 
154
155
  declare abstract class PInterceptor<C extends P.BaseContext = any> extends Dev {
155
156
  abstract use(ctx: C): Function | Promise<Function> | any;
156
- readonly key: string;
157
+ readonly key: PropertyKey;
157
158
  constructor(tag?: string);
158
159
  }
159
160
 
160
161
  declare abstract class PPipe<C extends P.BaseContext = any> extends Dev {
161
- readonly key: string;
162
+ readonly key: PropertyKey;
162
163
  constructor(tag?: string);
163
164
  abstract use(param: {
164
165
  arg: any;
@@ -171,7 +172,7 @@ declare abstract class PPipe<C extends P.BaseContext = any> extends Dev {
171
172
  }
172
173
 
173
174
  declare abstract class PAddon<Params extends any[] = any[]> extends Dev {
174
- readonly key: string;
175
+ readonly key: PropertyKey;
175
176
  constructor(tag?: string);
176
177
  abstract use(...args: Params): void;
177
178
  }
@@ -191,7 +192,7 @@ interface PExtension<C extends P.BaseContext = any, E extends Exception = Except
191
192
  addon(...args: any): void;
192
193
  }
193
194
  declare class PExtension extends Dev {
194
- readonly key: string;
195
+ readonly key: PropertyKey;
195
196
  constructor(tag?: string);
196
197
  }
197
198
 
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunk27WMBKFHjs = require('./chunk-27WMBKFH.js');
8
+ var _chunkINPMEA67js = require('./chunk-INPMEA67.js');
9
9
 
10
10
 
11
11
  var _chunkSSZS3GSQjs = require('./chunk-SSZS3GSQ.js');
@@ -34,7 +34,7 @@ var _chunkSSZS3GSQjs = require('./chunk-SSZS3GSQ.js');
34
34
 
35
35
 
36
36
 
37
- var _chunkKOWUK5OVjs = require('./chunk-KOWUK5OV.js');
37
+ var _chunkMFCPWVO5js = require('./chunk-MFCPWVO5.js');
38
38
 
39
39
 
40
40
 
@@ -294,12 +294,25 @@ var __decorate = function(decorators, target, key, desc) {
294
294
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
295
295
  return c > 3 && r && Object.defineProperty(target, key, r), r;
296
296
  };
297
+ var __metadata = function(k, v) {
298
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
299
+ return Reflect.metadata(k, v);
300
+ };
297
301
  var Dev = /* @__PURE__ */ _chunkGWLM5DEJjs.__name.call(void 0, (_class =class Dev2 {constructor() { _class.prototype.__init.call(this); }
298
302
  __init() {this[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL] = []}
299
303
  onUnmount(cb) {
300
304
  this[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL].push(cb);
301
305
  }
306
+ async unmount() {
307
+ for (const cb of this[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL])
308
+ await cb();
309
+ }
302
310
  }, _class), "Dev");
311
+ __decorate([
312
+ _phecdacore.Unmount,
313
+ __metadata("design:type", Function),
314
+ __metadata("design:paramtypes", [])
315
+ ], Dev.prototype, "unmount", null);
303
316
  Dev = exports.Dev = __decorate([
304
317
  _phecdacore.Empty
305
318
  ], Dev);
@@ -311,9 +324,9 @@ var PFilter = class extends Dev {
311
324
  constructor(tag) {
312
325
  super();
313
326
  this.key = tag || _phecdacore.getTag.call(void 0, this);
314
- _chunkKOWUK5OVjs.addFilter.call(void 0, this.key, this.use.bind(this));
327
+ _chunkMFCPWVO5js.addFilter.call(void 0, this.key, this.use.bind(this));
315
328
  this.onUnmount(() => {
316
- delete _chunkKOWUK5OVjs.Context.filterRecord[this.key];
329
+ delete _chunkMFCPWVO5js.Context.filterRecord[this.key];
317
330
  });
318
331
  }
319
332
  };
@@ -326,9 +339,9 @@ var PGuard = class extends Dev {
326
339
  constructor(tag) {
327
340
  super();
328
341
  this.key = tag || _phecdacore.getTag.call(void 0, this);
329
- _chunkKOWUK5OVjs.addGuard.call(void 0, this.key, this.use.bind(this));
342
+ _chunkMFCPWVO5js.addGuard.call(void 0, this.key, this.use.bind(this));
330
343
  this.onUnmount(() => {
331
- delete _chunkKOWUK5OVjs.Context.guardRecord[this.key];
344
+ delete _chunkMFCPWVO5js.Context.guardRecord[this.key];
332
345
  });
333
346
  }
334
347
  };
@@ -342,9 +355,9 @@ var PInterceptor = class extends Dev {
342
355
  super();
343
356
  this.key = tag || _phecdacore.getTag.call(void 0, this);
344
357
  this.onUnmount(() => {
345
- delete _chunkKOWUK5OVjs.Context.interceptorRecord[this.key];
358
+ delete _chunkMFCPWVO5js.Context.interceptorRecord[this.key];
346
359
  });
347
- _chunkKOWUK5OVjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
360
+ _chunkMFCPWVO5js.addInterceptor.call(void 0, this.key, this.use.bind(this));
348
361
  }
349
362
  };
350
363
  _chunkGWLM5DEJjs.__name.call(void 0, PInterceptor, "PInterceptor");
@@ -356,9 +369,9 @@ var PPipe = class extends Dev {
356
369
  constructor(tag) {
357
370
  super();
358
371
  this.key = tag || _phecdacore.getTag.call(void 0, this);
359
- _chunkKOWUK5OVjs.addPipe.call(void 0, this.key, this.use.bind(this));
372
+ _chunkMFCPWVO5js.addPipe.call(void 0, this.key, this.use.bind(this));
360
373
  this.onUnmount(() => {
361
- delete _chunkKOWUK5OVjs.Context.pipeRecord[this.key];
374
+ delete _chunkMFCPWVO5js.Context.pipeRecord[this.key];
362
375
  });
363
376
  }
364
377
  };
@@ -371,9 +384,9 @@ var PAddon = class extends Dev {
371
384
  constructor(tag) {
372
385
  super();
373
386
  this.key = tag || _phecdacore.getTag.call(void 0, this);
374
- _chunkKOWUK5OVjs.addAddon.call(void 0, this.key, this.use.bind(this));
387
+ _chunkMFCPWVO5js.addAddon.call(void 0, this.key, this.use.bind(this));
375
388
  this.onUnmount(() => {
376
- delete _chunkKOWUK5OVjs.Context.addonRecord[this.key];
389
+ delete _chunkMFCPWVO5js.Context.addonRecord[this.key];
377
390
  });
378
391
  }
379
392
  };
@@ -387,33 +400,33 @@ var PExtension = class extends Dev {
387
400
  super();
388
401
  const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
389
402
  if (this.pipe) {
390
- _chunkKOWUK5OVjs.addPipe.call(void 0, key, this.pipe.bind(this));
403
+ _chunkMFCPWVO5js.addPipe.call(void 0, key, this.pipe.bind(this));
391
404
  this.onUnmount(() => {
392
- delete _chunkKOWUK5OVjs.Context.pipeRecord[key];
405
+ delete _chunkMFCPWVO5js.Context.pipeRecord[key];
393
406
  });
394
407
  }
395
408
  if (this.addon) {
396
- _chunkKOWUK5OVjs.addAddon.call(void 0, key, this.addon.bind(this));
409
+ _chunkMFCPWVO5js.addAddon.call(void 0, key, this.addon.bind(this));
397
410
  this.onUnmount(() => {
398
- delete _chunkKOWUK5OVjs.Context.addonRecord[key];
411
+ delete _chunkMFCPWVO5js.Context.addonRecord[key];
399
412
  });
400
413
  }
401
414
  if (this.intercept) {
402
- _chunkKOWUK5OVjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
415
+ _chunkMFCPWVO5js.addInterceptor.call(void 0, key, this.intercept.bind(this));
403
416
  this.onUnmount(() => {
404
- delete _chunkKOWUK5OVjs.Context.interceptorRecord[key];
417
+ delete _chunkMFCPWVO5js.Context.interceptorRecord[key];
405
418
  });
406
419
  }
407
420
  if (this.guard) {
408
- _chunkKOWUK5OVjs.addGuard.call(void 0, key, this.guard.bind(this));
421
+ _chunkMFCPWVO5js.addGuard.call(void 0, key, this.guard.bind(this));
409
422
  this.onUnmount(() => {
410
- delete _chunkKOWUK5OVjs.Context.guardRecord[key];
423
+ delete _chunkMFCPWVO5js.Context.guardRecord[key];
411
424
  });
412
425
  }
413
426
  if (this.filter) {
414
- _chunkKOWUK5OVjs.addFilter.call(void 0, key, this.filter.bind(this));
427
+ _chunkMFCPWVO5js.addFilter.call(void 0, key, this.filter.bind(this));
415
428
  this.onUnmount(() => {
416
- delete _chunkKOWUK5OVjs.Context.filterRecord[key];
429
+ delete _chunkMFCPWVO5js.Context.filterRecord[key];
417
430
  });
418
431
  }
419
432
  }
@@ -495,4 +508,4 @@ _chunkGWLM5DEJjs.__name.call(void 0, PExtension, "PExtension");
495
508
 
496
509
 
497
510
 
498
- exports.APP_SYMBOL = _chunkGWLM5DEJjs.APP_SYMBOL; exports.Arg = Arg; exports.BadGatewayException = _chunkKOWUK5OVjs.BadGatewayException; exports.BadRequestException = _chunkKOWUK5OVjs.BadRequestException; exports.BaseParam = BaseParam; exports.Body = Body; exports.ConflictException = _chunkKOWUK5OVjs.ConflictException; exports.Context = _chunkKOWUK5OVjs.Context; exports.Controller = Controller; exports.Define = Define; exports.Delete = Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkGWLM5DEJjs.ERROR_SYMBOL; exports.Event = Event; exports.Exception = _chunkKOWUK5OVjs.Exception; exports.Factory = _chunk27WMBKFHjs.Factory; exports.Filter = Filter; exports.ForbiddenException = _chunkKOWUK5OVjs.ForbiddenException; exports.FrameworkException = _chunkKOWUK5OVjs.FrameworkException; exports.Get = Get; exports.Guard = Guard; exports.Head = Head; exports.Header = Header; exports.IS_DEV = _chunkGWLM5DEJjs.IS_DEV; exports.IS_LOG_BAN = _chunkGWLM5DEJjs.IS_LOG_BAN; exports.IS_STRICT = _chunkGWLM5DEJjs.IS_STRICT; exports.Injectable = _chunk27WMBKFHjs.Injectable; exports.Interceptor = Interceptor; exports.InvalidInputException = _chunkKOWUK5OVjs.InvalidInputException; exports.MERGE_SYMBOL = _chunkGWLM5DEJjs.MERGE_SYMBOL; exports.META_SYMBOL = _chunkGWLM5DEJjs.META_SYMBOL; exports.MODULE_SYMBOL = _chunkGWLM5DEJjs.MODULE_SYMBOL; exports.Meta = _chunk27WMBKFHjs.Meta; exports.Mix = _chunkGWLM5DEJjs.Mix; exports.NotFoundException = _chunkKOWUK5OVjs.NotFoundException; exports.PAddon = PAddon; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PS_FILE_RE = _chunkGWLM5DEJjs.PS_FILE_RE; exports.PS_IMPORT_RE = _chunkGWLM5DEJjs.PS_IMPORT_RE; exports.Param = Param; exports.Patch = Patch; exports.PayloadLargeException = _chunkKOWUK5OVjs.PayloadLargeException; exports.Pipe = Pipe; exports.Plugin = Plugin; exports.Post = Post; exports.Put = Put; exports.Query = Query; exports.Route = Route; exports.Rpc = Rpc; exports.ServiceUnavailableException = _chunkKOWUK5OVjs.ServiceUnavailableException; exports.TimeoutException = _chunkKOWUK5OVjs.TimeoutException; exports.UNMOUNT_SYMBOL = _chunkGWLM5DEJjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunkKOWUK5OVjs.UnauthorizedException; exports.UndefinedException = _chunkKOWUK5OVjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkKOWUK5OVjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkKOWUK5OVjs.ValidateException; exports.addAddon = _chunkKOWUK5OVjs.addAddon; exports.addFilter = _chunkKOWUK5OVjs.addFilter; exports.addGuard = _chunkKOWUK5OVjs.addGuard; exports.addInterceptor = _chunkKOWUK5OVjs.addInterceptor; exports.addPipe = _chunkKOWUK5OVjs.addPipe; exports.defaultPipe = _chunkKOWUK5OVjs.defaultPipe; exports.emitter = _chunk27WMBKFHjs.emitter; exports.generateHTTPCode = _chunk27WMBKFHjs.generateHTTPCode; exports.generateRPCCode = _chunk27WMBKFHjs.generateRPCCode; exports.getConfig = _chunkGWLM5DEJjs.getConfig; exports.guardRecord = _chunkKOWUK5OVjs.guardRecord; exports.isAopDepInject = _chunkKOWUK5OVjs.isAopDepInject; exports.log = _chunkGWLM5DEJjs.log; exports.resolveDep = _chunkSSZS3GSQjs.resolveDep; exports.setConfig = _chunkGWLM5DEJjs.setConfig;
511
+ exports.APP_SYMBOL = _chunkGWLM5DEJjs.APP_SYMBOL; exports.Arg = Arg; exports.BadGatewayException = _chunkMFCPWVO5js.BadGatewayException; exports.BadRequestException = _chunkMFCPWVO5js.BadRequestException; exports.BaseParam = BaseParam; exports.Body = Body; exports.ConflictException = _chunkMFCPWVO5js.ConflictException; exports.Context = _chunkMFCPWVO5js.Context; exports.Controller = Controller; exports.Define = Define; exports.Delete = Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkGWLM5DEJjs.ERROR_SYMBOL; exports.Event = Event; exports.Exception = _chunkMFCPWVO5js.Exception; exports.Factory = _chunkINPMEA67js.Factory; exports.Filter = Filter; exports.ForbiddenException = _chunkMFCPWVO5js.ForbiddenException; exports.FrameworkException = _chunkMFCPWVO5js.FrameworkException; exports.Get = Get; exports.Guard = Guard; exports.Head = Head; exports.Header = Header; exports.IS_DEV = _chunkGWLM5DEJjs.IS_DEV; exports.IS_LOG_BAN = _chunkGWLM5DEJjs.IS_LOG_BAN; exports.IS_STRICT = _chunkGWLM5DEJjs.IS_STRICT; exports.Injectable = _chunkINPMEA67js.Injectable; exports.Interceptor = Interceptor; exports.InvalidInputException = _chunkMFCPWVO5js.InvalidInputException; exports.MERGE_SYMBOL = _chunkGWLM5DEJjs.MERGE_SYMBOL; exports.META_SYMBOL = _chunkGWLM5DEJjs.META_SYMBOL; exports.MODULE_SYMBOL = _chunkGWLM5DEJjs.MODULE_SYMBOL; exports.Meta = _chunkINPMEA67js.Meta; exports.Mix = _chunkGWLM5DEJjs.Mix; exports.NotFoundException = _chunkMFCPWVO5js.NotFoundException; exports.PAddon = PAddon; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PS_FILE_RE = _chunkGWLM5DEJjs.PS_FILE_RE; exports.PS_IMPORT_RE = _chunkGWLM5DEJjs.PS_IMPORT_RE; exports.Param = Param; exports.Patch = Patch; exports.PayloadLargeException = _chunkMFCPWVO5js.PayloadLargeException; exports.Pipe = Pipe; exports.Plugin = Plugin; exports.Post = Post; exports.Put = Put; exports.Query = Query; exports.Route = Route; exports.Rpc = Rpc; exports.ServiceUnavailableException = _chunkMFCPWVO5js.ServiceUnavailableException; exports.TimeoutException = _chunkMFCPWVO5js.TimeoutException; exports.UNMOUNT_SYMBOL = _chunkGWLM5DEJjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunkMFCPWVO5js.UnauthorizedException; exports.UndefinedException = _chunkMFCPWVO5js.UndefinedException; exports.UnsupportedMediaTypeException = _chunkMFCPWVO5js.UnsupportedMediaTypeException; exports.ValidateException = _chunkMFCPWVO5js.ValidateException; exports.addAddon = _chunkMFCPWVO5js.addAddon; exports.addFilter = _chunkMFCPWVO5js.addFilter; exports.addGuard = _chunkMFCPWVO5js.addGuard; exports.addInterceptor = _chunkMFCPWVO5js.addInterceptor; exports.addPipe = _chunkMFCPWVO5js.addPipe; exports.defaultPipe = _chunkMFCPWVO5js.defaultPipe; exports.emitter = _chunkINPMEA67js.emitter; exports.generateHTTPCode = _chunkINPMEA67js.generateHTTPCode; exports.generateRPCCode = _chunkINPMEA67js.generateRPCCode; exports.getConfig = _chunkGWLM5DEJjs.getConfig; exports.guardRecord = _chunkMFCPWVO5js.guardRecord; exports.isAopDepInject = _chunkMFCPWVO5js.isAopDepInject; exports.log = _chunkGWLM5DEJjs.log; exports.resolveDep = _chunkSSZS3GSQjs.resolveDep; exports.setConfig = _chunkGWLM5DEJjs.setConfig;
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  emitter,
6
6
  generateHTTPCode,
7
7
  generateRPCCode
8
- } from "./chunk-UXPHQ7OT.mjs";
8
+ } from "./chunk-Y7AOZMC2.mjs";
9
9
  import {
10
10
  resolveDep
11
11
  } from "./chunk-HQ5RLYMA.mjs";
@@ -34,7 +34,7 @@ import {
34
34
  defaultPipe,
35
35
  guardRecord,
36
36
  isAopDepInject
37
- } from "./chunk-L5SFPHG6.mjs";
37
+ } from "./chunk-BADPI5WG.mjs";
38
38
  import {
39
39
  APP_SYMBOL,
40
40
  ERROR_SYMBOL,
@@ -283,7 +283,7 @@ __name(Define, "Define");
283
283
  export * from "phecda-core";
284
284
 
285
285
  // src/modules/dev.ts
286
- import { Empty } from "phecda-core";
286
+ import { Empty, Unmount } from "phecda-core";
287
287
  var __decorate = function(decorators, target, key, desc) {
288
288
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
289
289
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -294,12 +294,25 @@ var __decorate = function(decorators, target, key, desc) {
294
294
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
295
295
  return c > 3 && r && Object.defineProperty(target, key, r), r;
296
296
  };
297
+ var __metadata = function(k, v) {
298
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
299
+ return Reflect.metadata(k, v);
300
+ };
297
301
  var Dev = /* @__PURE__ */ __name(class Dev2 {
298
302
  [UNMOUNT_SYMBOL] = [];
299
303
  onUnmount(cb) {
300
304
  this[UNMOUNT_SYMBOL].push(cb);
301
305
  }
306
+ async unmount() {
307
+ for (const cb of this[UNMOUNT_SYMBOL])
308
+ await cb();
309
+ }
302
310
  }, "Dev");
311
+ __decorate([
312
+ Unmount,
313
+ __metadata("design:type", Function),
314
+ __metadata("design:paramtypes", [])
315
+ ], Dev.prototype, "unmount", null);
303
316
  Dev = __decorate([
304
317
  Empty
305
318
  ], Dev);
@@ -1,5 +1,5 @@
1
1
  import { Kafka } from 'kafkajs';
2
- import { P, F as Factory, T as ToControllerMap } from '../../core-295348b7.js';
2
+ import { P, F as Factory, T as ToControllerMap } from '../../core-11dd822c.js';
3
3
  import 'phecda-core';
4
4
 
5
5
  interface Options {