phecda-server 7.0.0-alpha.7 → 7.0.0-alpha.9

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 (80) hide show
  1. package/bin/cli.mjs +10 -1
  2. package/dist/{chunk-M5HGFUCV.js → chunk-5RBTN33A.js} +23 -3
  3. package/dist/{chunk-RGSKKTHD.mjs → chunk-7ZGYJ5OW.mjs} +88 -54
  4. package/dist/{chunk-IRXNF6ZE.mjs → chunk-CVPZWDXU.mjs} +39 -30
  5. package/dist/{chunk-MENRZSGW.js → chunk-FX3LDQII.js} +88 -79
  6. package/dist/{chunk-C5BVKEGW.mjs → chunk-FXTJ3BJ6.mjs} +25 -5
  7. package/dist/{chunk-XSMUJ77A.js → chunk-KJUD2BKE.js} +103 -69
  8. package/dist/{chunk-JPSXNDXP.mjs → chunk-ODVWOXVB.mjs} +1 -1
  9. package/dist/{chunk-VYMSCWXC.js → chunk-V5EYXVJT.js} +24 -24
  10. package/dist/{core-DU7gQKSk.d.mts → core-BDkhrEyf.d.mts} +4 -3
  11. package/dist/{core-CzElxZoF.d.ts → core-D_cz0tKa.d.ts} +4 -3
  12. package/dist/helper.d.mts +7 -5
  13. package/dist/helper.d.ts +7 -5
  14. package/dist/helper.js +8 -3
  15. package/dist/helper.mjs +10 -5
  16. package/dist/http/elysia/index.d.mts +4 -4
  17. package/dist/http/elysia/index.d.ts +4 -4
  18. package/dist/http/elysia/index.js +41 -44
  19. package/dist/http/elysia/index.mjs +7 -10
  20. package/dist/http/express/index.d.mts +4 -4
  21. package/dist/http/express/index.d.ts +4 -4
  22. package/dist/http/express/index.js +38 -41
  23. package/dist/http/express/index.mjs +7 -10
  24. package/dist/http/fastify/index.d.mts +4 -4
  25. package/dist/http/fastify/index.d.ts +4 -4
  26. package/dist/http/fastify/index.js +39 -42
  27. package/dist/http/fastify/index.mjs +7 -10
  28. package/dist/http/h3/index.d.mts +4 -4
  29. package/dist/http/h3/index.d.ts +4 -4
  30. package/dist/http/h3/index.js +39 -42
  31. package/dist/http/h3/index.mjs +7 -10
  32. package/dist/http/hono/index.d.mts +4 -4
  33. package/dist/http/hono/index.d.ts +4 -4
  34. package/dist/http/hono/index.js +35 -39
  35. package/dist/http/hono/index.mjs +3 -7
  36. package/dist/http/hyper-express/index.d.mts +4 -4
  37. package/dist/http/hyper-express/index.d.ts +4 -4
  38. package/dist/http/hyper-express/index.js +36 -39
  39. package/dist/http/hyper-express/index.mjs +6 -9
  40. package/dist/http/koa/index.d.mts +4 -4
  41. package/dist/http/koa/index.d.ts +4 -4
  42. package/dist/http/koa/index.js +38 -41
  43. package/dist/http/koa/index.mjs +7 -10
  44. package/dist/index.d.mts +35 -33
  45. package/dist/index.d.ts +35 -33
  46. package/dist/index.js +42 -43
  47. package/dist/index.mjs +15 -16
  48. package/dist/{meta-BTnLXuCa.d.ts → meta-BX5jhe4Z.d.mts} +3 -4
  49. package/dist/{meta-BTnLXuCa.d.mts → meta-BX5jhe4Z.d.ts} +3 -4
  50. package/dist/rpc/bullmq/index.d.mts +4 -4
  51. package/dist/rpc/bullmq/index.d.ts +4 -4
  52. package/dist/rpc/bullmq/index.js +14 -14
  53. package/dist/rpc/bullmq/index.mjs +3 -3
  54. package/dist/rpc/kafka/index.d.mts +4 -4
  55. package/dist/rpc/kafka/index.d.ts +4 -4
  56. package/dist/rpc/kafka/index.js +14 -14
  57. package/dist/rpc/kafka/index.mjs +2 -2
  58. package/dist/rpc/nats/index.d.mts +4 -4
  59. package/dist/rpc/nats/index.d.ts +4 -4
  60. package/dist/rpc/nats/index.js +13 -13
  61. package/dist/rpc/nats/index.mjs +3 -3
  62. package/dist/rpc/rabbitmq/index.d.mts +4 -4
  63. package/dist/rpc/rabbitmq/index.d.ts +4 -4
  64. package/dist/rpc/rabbitmq/index.js +15 -15
  65. package/dist/rpc/rabbitmq/index.mjs +3 -3
  66. package/dist/rpc/redis/index.d.mts +4 -4
  67. package/dist/rpc/redis/index.d.ts +4 -4
  68. package/dist/rpc/redis/index.js +13 -13
  69. package/dist/rpc/redis/index.mjs +3 -3
  70. package/dist/test.d.mts +3 -3
  71. package/dist/test.d.ts +3 -3
  72. package/dist/test.js +6 -6
  73. package/dist/test.mjs +2 -2
  74. package/dist/{types-CbfaGkPA.d.ts → types-B-rUM9Fm.d.mts} +3 -3
  75. package/dist/{types--E-OCZhC.d.ts → types-CMeuFoyd.d.ts} +3 -3
  76. package/dist/{types-BxlzVoRv.d.mts → types-DKVhyZk_.d.mts} +3 -3
  77. package/dist/{types-BYqBeqrs.d.mts → types-MxxtkZXw.d.ts} +3 -3
  78. package/package.json +3 -2
  79. package/register/index.mjs +20 -11
  80. package/register/loader.mjs +13 -28
@@ -1,14 +1,14 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; } var _class;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; } var _class;
2
2
 
3
3
 
4
4
 
5
5
 
6
- var _chunkM5HGFUCVjs = require('./chunk-M5HGFUCV.js');
6
+ var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.js');
7
7
 
8
8
  // src/meta.ts
9
9
  var Meta = class {
10
10
  static {
11
- _chunkM5HGFUCVjs.__name.call(void 0, this, "Meta");
11
+ _chunk5RBTN33Ajs.__name.call(void 0, this, "Meta");
12
12
  }
13
13
 
14
14
 
@@ -37,11 +37,11 @@ function defaultServerInject() {
37
37
  });
38
38
  }
39
39
  }
40
- _chunkM5HGFUCVjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
40
+ _chunk5RBTN33Ajs.__name.call(void 0, defaultServerInject, "defaultServerInject");
41
41
  var phecdaNamespace = /* @__PURE__ */ new Map();
42
42
  var ServerPhecda = (_class = class {
43
43
  static {
44
- _chunkM5HGFUCVjs.__name.call(void 0, this, "ServerPhecda");
44
+ _chunk5RBTN33Ajs.__name.call(void 0, this, "ServerPhecda");
45
45
  }
46
46
  __init() {this.moduleMap = /* @__PURE__ */ new Map()}
47
47
  __init2() {this.meta = []}
@@ -51,9 +51,9 @@ var ServerPhecda = (_class = class {
51
51
 
52
52
 
53
53
 
54
- constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);
54
+ constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);
55
55
  defaultServerInject();
56
- const { namespace = "default", parseModule = /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
56
+ const { namespace = "default", parseModule = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
57
57
  phecdaNamespace.set(namespace, this);
58
58
  this.parseMeta = parseMeta;
59
59
  this.parseModule = parseModule;
@@ -61,63 +61,58 @@ var ServerPhecda = (_class = class {
61
61
  }
62
62
  async start(models) {
63
63
  for (const model of models) await this.buildDepModule(model);
64
- const generateCode = /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, async () => {
65
- if (_chunkM5HGFUCVjs.IS_HMR) {
66
- return Promise.all(this.generators.map((generator) => {
67
- debug(`generate "${generator.name}" code to ${generator.path}`);
68
- return generator.output(this.meta);
69
- }));
70
- }
71
- }, "generateCode");
72
- generateCode().then(() => {
73
- if (_chunkM5HGFUCVjs.IS_ONLY_GENERATE) process.exit(4);
64
+ this.hmr();
65
+ this.generateCode().then(() => {
66
+ if (_chunk5RBTN33Ajs.IS_ONLY_GENERATE) process.exit(4);
74
67
  });
75
- if (_chunkM5HGFUCVjs.IS_HMR) {
76
- if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
77
- _optionalChain([globalThis, 'access', _2 => _2.__PS_HMR__, 'optionalAccess', _3 => _3.push, 'call', _4 => _4(async (files) => {
78
- debug("reload files ");
79
- for (const file of files) {
80
- const models2 = await Promise.resolve().then(() => _interopRequireWildcard(require(file)));
81
- for (const i in models2) {
82
- if (_phecdacore.isPhecda.call(void 0, models2[i])) await this.add(models2[i]);
83
- }
84
- }
85
- generateCode();
86
- })]);
87
- }
88
- }
89
- async add(Model) {
90
- const tag = _phecdacore.getTag.call(void 0, Model);
91
- const oldInstance = await this.del(tag);
92
- const { module: newModule } = await this.buildDepModule(Model);
93
- if (oldInstance && this.dependenceGraph.has(tag)) {
94
- debug(`replace module "${String(tag)}"`);
95
- [
96
- ...this.dependenceGraph.get(tag)
97
- ].forEach((tag2) => {
98
- const module = this.moduleMap.get(tag2);
99
- for (const key in module) {
100
- if (module[key] === oldInstance) module[key] = newModule;
101
- }
102
- });
103
- }
104
68
  }
105
- async del(tag) {
106
- if (!this.moduleMap.has(tag)) return;
107
- const module = this.moduleMap.get(tag);
108
- debug(`unmount module "${String(tag)}"`);
109
- await _phecdacore.invokeUnmount.call(void 0, module);
110
- debug(`del module "${String(tag)}"`);
111
- this.moduleMap.delete(tag);
112
- this.modelMap.delete(module);
113
- for (let i = this.meta.length - 1; i >= 0; i--) {
114
- if (this.meta[i].data.tag === tag) this.meta.splice(i, 1);
115
- }
116
- return module;
69
+ __init6() {this.generateCode = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, async () => {
70
+ return Promise.all(this.generators.map((generator) => {
71
+ debug(`generate "${generator.name}" code to ${generator.path}`);
72
+ return generator.output(this.meta);
73
+ }));
74
+ }, "generateCode")}
75
+ hmr() {
76
+ _chunk5RBTN33Ajs.HMR.call(void 0, async (oldModels, newModels) => {
77
+ debug("reload models ");
78
+ await this.replace(oldModels, newModels);
79
+ this.generateCode();
80
+ });
117
81
  }
82
+ // async add(Model: Construct) {
83
+ // const tag = getTag(Model)
84
+ // const oldInstance = await this.del(tag)
85
+ // const { module: newModule } = await this.buildDepModule(Model)
86
+ // if (oldInstance && this.dependenceGraph.has(tag)) {
87
+ // debug(`replace module "${String(tag)}"`);
88
+ // [...this.dependenceGraph.get(tag)!].forEach((tag) => {
89
+ // const module = this.moduleMap.get(tag)
90
+ // for (const key in module) {
91
+ // if (module[key] === oldInstance)
92
+ // module[key] = newModule
93
+ // }
94
+ // })
95
+ // }
96
+ // }
97
+ // async del(modelOrTag: Construct | PropertyKey) {
98
+ // const tag = typeof modelOrTag === 'function' ? getTag(modelOrTag) : modelOrTag
99
+ // if (!this.moduleMap.has(tag))
100
+ // return
101
+ // const module = this.moduleMap.get(tag)
102
+ // debug(`unmount module "${String(tag)}"`)
103
+ // await invokeUnmount(module)
104
+ // debug(`del module "${String(tag)}"`)
105
+ // this.moduleMap.delete(tag)
106
+ // this.modelMap.delete(module)
107
+ // for (let i = this.meta.length - 1; i >= 0; i--) {
108
+ // if (this.meta[i].data.tag === tag)
109
+ // this.meta.splice(i, 1)
110
+ // }
111
+ // return module
112
+ // }
118
113
  async destroy() {
119
114
  debug("destroy all");
120
- for (const [tag] of this.moduleMap) await this.del(tag);
115
+ this.replace(Object.values(this.modelMap), []);
121
116
  }
122
117
  createProxyModule(tag) {
123
118
  const that = this;
@@ -133,6 +128,9 @@ var ServerPhecda = (_class = class {
133
128
  has(_target, prop) {
134
129
  return Reflect.has(that.moduleMap.get(tag), prop);
135
130
  },
131
+ ownKeys() {
132
+ return Reflect.ownKeys(that.moduleMap.get(tag));
133
+ },
136
134
  getPrototypeOf() {
137
135
  return Reflect.getPrototypeOf(that.moduleMap.get(tag));
138
136
  },
@@ -148,7 +146,7 @@ var ServerPhecda = (_class = class {
148
146
  if (this.moduleMap.has(tag)) {
149
147
  module = this.moduleMap.get(tag);
150
148
  if (!module) {
151
- _chunkM5HGFUCVjs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
149
+ _chunk5RBTN33Ajs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
152
150
  return {
153
151
  module: this.createProxyModule(tag),
154
152
  tag
@@ -156,8 +154,8 @@ var ServerPhecda = (_class = class {
156
154
  }
157
155
  if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
158
156
  this.modelSet.add(Model);
159
- if (module instanceof Model) _chunkM5HGFUCVjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
160
- else _chunkM5HGFUCVjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
157
+ if (module instanceof Model) _chunk5RBTN33Ajs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
158
+ else _chunk5RBTN33Ajs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
161
159
  }
162
160
  return {
163
161
  module,
@@ -180,7 +178,7 @@ var ServerPhecda = (_class = class {
180
178
  }
181
179
  this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter((item) => !!item));
182
180
  debug(`init module "${String(tag)}"`);
183
- if (!_chunkM5HGFUCVjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
181
+ if (!_chunk5RBTN33Ajs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
184
182
  debug(`add module "${String(tag)}"`);
185
183
  this.moduleMap.set(tag, module);
186
184
  this.modelMap.set(module, Model);
@@ -189,6 +187,42 @@ var ServerPhecda = (_class = class {
189
187
  tag
190
188
  };
191
189
  }
190
+ async replace(oldModels, newModels) {
191
+ const oldModules = (await Promise.all(oldModels.map(async (model) => {
192
+ const tag = _phecdacore.getTag.call(void 0, model);
193
+ if (!this.has(tag)) return;
194
+ const module = this.moduleMap.get(tag);
195
+ debug(`unmount module "${String(tag)}"`);
196
+ await _phecdacore.invokeUnmount.call(void 0, module);
197
+ debug(`del module "${String(tag)}"`);
198
+ this.moduleMap.delete(tag);
199
+ this.modelMap.delete(module);
200
+ for (let i = this.meta.length - 1; i >= 0; i--) {
201
+ if (this.meta[i].data.tag === tag) this.meta.splice(i, 1);
202
+ }
203
+ return module;
204
+ }))).filter((item) => item);
205
+ for (const model of newModels) {
206
+ debug(`mount module: ${model.name}`);
207
+ await this.buildDepModule(model);
208
+ }
209
+ debug("replace old modules");
210
+ for (const module of oldModules) {
211
+ const tag = _phecdacore.getTag.call(void 0, module);
212
+ if (this.dependenceGraph.has(tag)) {
213
+ [
214
+ ...this.dependenceGraph.get(tag)
215
+ ].forEach((depTag) => {
216
+ const depModule = this.moduleMap.get(depTag);
217
+ if (depModule) {
218
+ for (const key in depModule) {
219
+ if (depModule[key] === module) depModule[key] = this.moduleMap.get(tag);
220
+ }
221
+ }
222
+ });
223
+ }
224
+ }
225
+ }
192
226
  has(modelOrTag) {
193
227
  return this.moduleMap.has(typeof modelOrTag === "function" ? _phecdacore.getTag.call(void 0, modelOrTag) : modelOrTag);
194
228
  }
@@ -203,7 +237,7 @@ async function Factory(models, opts = {}) {
203
237
  await phecda.start(models);
204
238
  return phecda;
205
239
  }
206
- _chunkM5HGFUCVjs.__name.call(void 0, Factory, "Factory");
240
+ _chunk5RBTN33Ajs.__name.call(void 0, Factory, "Factory");
207
241
  function useS(nsOrModel, namespace) {
208
242
  if (!nsOrModel) {
209
243
  namespace = "default";
@@ -216,7 +250,7 @@ function useS(nsOrModel, namespace) {
216
250
  if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
217
251
  else return serverPhecda;
218
252
  }
219
- _chunkM5HGFUCVjs.__name.call(void 0, useS, "useS");
253
+ _chunk5RBTN33Ajs.__name.call(void 0, useS, "useS");
220
254
  function getMetaFromInstance(instance, tag, name) {
221
255
  const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
222
256
  const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
@@ -230,7 +264,7 @@ function getMetaFromInstance(instance, tag, name) {
230
264
  func: i
231
265
  };
232
266
  if (baseMeta.controller) {
233
- if (typeof tag !== "string") _chunkM5HGFUCVjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
267
+ if (typeof tag !== "string") _chunk5RBTN33Ajs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
234
268
  metaData.controller = baseMeta.controller;
235
269
  metaData[baseMeta.controller] = {
236
270
  ...baseMeta[baseMeta.controller],
@@ -268,7 +302,7 @@ function getMetaFromInstance(instance, tag, name) {
268
302
  return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
269
303
  });
270
304
  }
271
- _chunkM5HGFUCVjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
305
+ _chunk5RBTN33Ajs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
272
306
  function deepFreeze(object) {
273
307
  Object.freeze(object);
274
308
  Object.getOwnPropertyNames(object).forEach((prop) => {
@@ -276,13 +310,13 @@ function deepFreeze(object) {
276
310
  });
277
311
  return object;
278
312
  }
279
- _chunkM5HGFUCVjs.__name.call(void 0, deepFreeze, "deepFreeze");
313
+ _chunk5RBTN33Ajs.__name.call(void 0, deepFreeze, "deepFreeze");
280
314
  function getParamTypes(Model, key) {
281
315
  const paramTypes = Reflect.getMetadata("design:paramtypes", Model, key);
282
316
  if (typeof paramTypes === "function") return paramTypes();
283
317
  else return paramTypes;
284
318
  }
285
- _chunkM5HGFUCVjs.__name.call(void 0, getParamTypes, "getParamTypes");
319
+ _chunk5RBTN33Ajs.__name.call(void 0, getParamTypes, "getParamTypes");
286
320
 
287
321
 
288
322
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-C5BVKEGW.mjs";
3
+ } from "./chunk-FXTJ3BJ6.mjs";
4
4
 
5
5
  // src/decorators/param.ts
6
6
  import { setMeta } from "phecda-core";
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkM5HGFUCVjs = require('./chunk-M5HGFUCV.js');
3
+ var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.js');
4
4
 
5
5
  // src/decorators/param.ts
6
6
  var _phecdacore = require('phecda-core');
@@ -10,42 +10,42 @@ function BaseParam(data) {
10
10
  _phecdacore.setMeta.call(void 0, target, property, index, data);
11
11
  };
12
12
  }
13
- _chunkM5HGFUCVjs.__name.call(void 0, BaseParam, "BaseParam");
13
+ _chunk5RBTN33Ajs.__name.call(void 0, BaseParam, "BaseParam");
14
14
  function Body(key = "") {
15
15
  return BaseParam({
16
16
  type: "body",
17
17
  key
18
18
  });
19
19
  }
20
- _chunkM5HGFUCVjs.__name.call(void 0, Body, "Body");
20
+ _chunk5RBTN33Ajs.__name.call(void 0, Body, "Body");
21
21
  function Head(key) {
22
22
  return BaseParam({
23
23
  type: "headers",
24
24
  key: key.toLowerCase()
25
25
  });
26
26
  }
27
- _chunkM5HGFUCVjs.__name.call(void 0, Head, "Head");
27
+ _chunk5RBTN33Ajs.__name.call(void 0, Head, "Head");
28
28
  function Query(key = "") {
29
29
  return BaseParam({
30
30
  type: "query",
31
31
  key
32
32
  });
33
33
  }
34
- _chunkM5HGFUCVjs.__name.call(void 0, Query, "Query");
34
+ _chunk5RBTN33Ajs.__name.call(void 0, Query, "Query");
35
35
  function Param(key) {
36
36
  return BaseParam({
37
37
  type: "params",
38
38
  key
39
39
  });
40
40
  }
41
- _chunkM5HGFUCVjs.__name.call(void 0, Param, "Param");
41
+ _chunk5RBTN33Ajs.__name.call(void 0, Param, "Param");
42
42
  function Arg(target, k, index) {
43
43
  BaseParam({
44
44
  type: "args",
45
45
  key: `${index}`
46
46
  })(target, k, index);
47
47
  }
48
- _chunkM5HGFUCVjs.__name.call(void 0, Arg, "Arg");
48
+ _chunk5RBTN33Ajs.__name.call(void 0, Arg, "Arg");
49
49
 
50
50
  // src/decorators/aop.ts
51
51
 
@@ -56,7 +56,7 @@ function Guard(...guards) {
56
56
  });
57
57
  };
58
58
  }
59
- _chunkM5HGFUCVjs.__name.call(void 0, Guard, "Guard");
59
+ _chunk5RBTN33Ajs.__name.call(void 0, Guard, "Guard");
60
60
  function Addon(...addons) {
61
61
  return (target, property) => {
62
62
  _phecdacore.setMeta.call(void 0, target, property, void 0, {
@@ -64,7 +64,7 @@ function Addon(...addons) {
64
64
  });
65
65
  };
66
66
  }
67
- _chunkM5HGFUCVjs.__name.call(void 0, Addon, "Addon");
67
+ _chunk5RBTN33Ajs.__name.call(void 0, Addon, "Addon");
68
68
  function Filter(filter) {
69
69
  return (target, property) => {
70
70
  _phecdacore.setMeta.call(void 0, target, property, void 0, {
@@ -72,7 +72,7 @@ function Filter(filter) {
72
72
  });
73
73
  };
74
74
  }
75
- _chunkM5HGFUCVjs.__name.call(void 0, Filter, "Filter");
75
+ _chunk5RBTN33Ajs.__name.call(void 0, Filter, "Filter");
76
76
  function Pipe(pipe) {
77
77
  return (target, property, index) => {
78
78
  if (typeof index === "number") {
@@ -86,7 +86,7 @@ function Pipe(pipe) {
86
86
  });
87
87
  };
88
88
  }
89
- _chunkM5HGFUCVjs.__name.call(void 0, Pipe, "Pipe");
89
+ _chunk5RBTN33Ajs.__name.call(void 0, Pipe, "Pipe");
90
90
 
91
91
  // src/decorators/http.ts
92
92
 
@@ -100,7 +100,7 @@ function Route(route, type) {
100
100
  });
101
101
  };
102
102
  }
103
- _chunkM5HGFUCVjs.__name.call(void 0, Route, "Route");
103
+ _chunk5RBTN33Ajs.__name.call(void 0, Route, "Route");
104
104
  function Header(headers) {
105
105
  return (target, property) => {
106
106
  _phecdacore.setMeta.call(void 0, target, property, void 0, {
@@ -110,31 +110,31 @@ function Header(headers) {
110
110
  });
111
111
  };
112
112
  }
113
- _chunkM5HGFUCVjs.__name.call(void 0, Header, "Header");
113
+ _chunk5RBTN33Ajs.__name.call(void 0, Header, "Header");
114
114
  function Get(route = "") {
115
115
  return Route(route, "get");
116
116
  }
117
- _chunkM5HGFUCVjs.__name.call(void 0, Get, "Get");
117
+ _chunk5RBTN33Ajs.__name.call(void 0, Get, "Get");
118
118
  function Post(route = "") {
119
119
  return Route(route, "post");
120
120
  }
121
- _chunkM5HGFUCVjs.__name.call(void 0, Post, "Post");
121
+ _chunk5RBTN33Ajs.__name.call(void 0, Post, "Post");
122
122
  function Put(route = "") {
123
123
  return Route(route, "put");
124
124
  }
125
- _chunkM5HGFUCVjs.__name.call(void 0, Put, "Put");
125
+ _chunk5RBTN33Ajs.__name.call(void 0, Put, "Put");
126
126
  function Search(route = "") {
127
127
  return Route(route, "search");
128
128
  }
129
- _chunkM5HGFUCVjs.__name.call(void 0, Search, "Search");
129
+ _chunk5RBTN33Ajs.__name.call(void 0, Search, "Search");
130
130
  function Patch(route = "") {
131
131
  return Route(route, "patch");
132
132
  }
133
- _chunkM5HGFUCVjs.__name.call(void 0, Patch, "Patch");
133
+ _chunk5RBTN33Ajs.__name.call(void 0, Patch, "Patch");
134
134
  function Delete(route = "") {
135
135
  return Route(route, "delete");
136
136
  }
137
- _chunkM5HGFUCVjs.__name.call(void 0, Delete, "Delete");
137
+ _chunk5RBTN33Ajs.__name.call(void 0, Delete, "Delete");
138
138
  function Controller(prefix = "") {
139
139
  return (target) => {
140
140
  _phecdacore.setMeta.call(void 0, target, void 0, void 0, {
@@ -145,7 +145,7 @@ function Controller(prefix = "") {
145
145
  });
146
146
  };
147
147
  }
148
- _chunkM5HGFUCVjs.__name.call(void 0, Controller, "Controller");
148
+ _chunk5RBTN33Ajs.__name.call(void 0, Controller, "Controller");
149
149
 
150
150
  // src/decorators/rpc.ts
151
151
 
@@ -159,7 +159,7 @@ function Queue(queue = "", isEvent) {
159
159
  });
160
160
  };
161
161
  }
162
- _chunkM5HGFUCVjs.__name.call(void 0, Queue, "Queue");
162
+ _chunk5RBTN33Ajs.__name.call(void 0, Queue, "Queue");
163
163
  function Rpc() {
164
164
  return (target) => {
165
165
  _phecdacore.setMeta.call(void 0, target, void 0, void 0, {
@@ -167,11 +167,11 @@ function Rpc() {
167
167
  });
168
168
  };
169
169
  }
170
- _chunkM5HGFUCVjs.__name.call(void 0, Rpc, "Rpc");
170
+ _chunk5RBTN33Ajs.__name.call(void 0, Rpc, "Rpc");
171
171
 
172
172
  // src/decorators/ctx.ts
173
173
 
174
- var Ctx = /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (target, property) => {
174
+ var Ctx = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (target, property) => {
175
175
  _phecdacore.setMeta.call(void 0, target, _phecdacore.SHARE_KEY, void 0, {
176
176
  ctxs: [
177
177
  property
@@ -200,7 +200,7 @@ function Define(key, value) {
200
200
  }
201
201
  };
202
202
  }
203
- _chunkM5HGFUCVjs.__name.call(void 0, Define, "Define");
203
+ _chunk5RBTN33Ajs.__name.call(void 0, Define, "Define");
204
204
 
205
205
 
206
206
 
@@ -1,5 +1,5 @@
1
1
  import { Construct } from 'phecda-core';
2
- import { b as MetaData, M as Meta, E as Emitter } from './meta-BTnLXuCa.mjs';
2
+ import { b as MetaData, M as Meta, E as Emitter } from './meta-BX5jhe4Z.mjs';
3
3
 
4
4
  declare abstract class Generator {
5
5
  private _path;
@@ -30,14 +30,15 @@ declare class ServerPhecda {
30
30
  generators: Generator[];
31
31
  constructor(options: Options);
32
32
  start(models: Construct[]): Promise<void>;
33
- add(Model: Construct): Promise<void>;
34
- del(tag: PropertyKey): Promise<any>;
33
+ generateCode: () => Promise<void[]>;
34
+ hmr(): void;
35
35
  destroy(): Promise<void>;
36
36
  createProxyModule(tag: PropertyKey): {};
37
37
  protected buildDepModule(Model: Construct): Promise<{
38
38
  module: any;
39
39
  tag: PropertyKey;
40
40
  }>;
41
+ replace(oldModels: Construct[], newModels: Construct[]): Promise<void>;
41
42
  has(modelOrTag: Construct | PropertyKey): boolean;
42
43
  get<Model extends Construct>(modelOrTag: Model | PropertyKey): InstanceType<Model>;
43
44
  }
@@ -1,5 +1,5 @@
1
1
  import { Construct } from 'phecda-core';
2
- import { b as MetaData, M as Meta, E as Emitter } from './meta-BTnLXuCa.js';
2
+ import { b as MetaData, M as Meta, E as Emitter } from './meta-BX5jhe4Z.js';
3
3
 
4
4
  declare abstract class Generator {
5
5
  private _path;
@@ -30,14 +30,15 @@ declare class ServerPhecda {
30
30
  generators: Generator[];
31
31
  constructor(options: Options);
32
32
  start(models: Construct[]): Promise<void>;
33
- add(Model: Construct): Promise<void>;
34
- del(tag: PropertyKey): Promise<any>;
33
+ generateCode: () => Promise<void[]>;
34
+ hmr(): void;
35
35
  destroy(): Promise<void>;
36
36
  createProxyModule(tag: PropertyKey): {};
37
37
  protected buildDepModule(Model: Construct): Promise<{
38
38
  module: any;
39
39
  tag: PropertyKey;
40
40
  }>;
41
+ replace(oldModels: Construct[], newModels: Construct[]): Promise<void>;
41
42
  has(modelOrTag: Construct | PropertyKey): boolean;
42
43
  get<Model extends Construct>(modelOrTag: Model | PropertyKey): InstanceType<Model>;
43
44
  }
package/dist/helper.d.mts CHANGED
@@ -1,10 +1,11 @@
1
- import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-BTnLXuCa.mjs';
2
- import 'phecda-core';
1
+ import { M as Meta, C as ControllerMeta } from './meta-BX5jhe4Z.mjs';
2
+ import { Construct } from 'phecda-core';
3
3
 
4
- declare function HMR(cb: (...args: any) => any): void;
4
+ declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
5
+ declare function RELOAD(oldModels: Construct[], newModels: Construct[]): Promise<void>;
6
+ declare function RELAUNCH(): void;
5
7
 
6
8
  declare function resolveDep(ret: any, key: string): any;
7
- declare function argToReq(params: ControllerMetaData['params'], args: any[], headers: Record<string, any>): any;
8
9
 
9
10
  declare function genClientQueue(key?: string): string;
10
11
 
@@ -21,5 +22,6 @@ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
21
22
  pipeSet: Set<string>;
22
23
  filterSet: Set<string>;
23
24
  };
25
+ declare function joinUrl(base: string, ...paths: string[]): string;
24
26
 
25
- export { HMR, argToReq, createControllerMetaMap, detectAopDep, genClientQueue, mergeObject, resolveDep, shallowClone };
27
+ export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep, genClientQueue, joinUrl, mergeObject, resolveDep, shallowClone };
package/dist/helper.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-BTnLXuCa.js';
2
- import 'phecda-core';
1
+ import { M as Meta, C as ControllerMeta } from './meta-BX5jhe4Z.js';
2
+ import { Construct } from 'phecda-core';
3
3
 
4
- declare function HMR(cb: (...args: any) => any): void;
4
+ declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
5
+ declare function RELOAD(oldModels: Construct[], newModels: Construct[]): Promise<void>;
6
+ declare function RELAUNCH(): void;
5
7
 
6
8
  declare function resolveDep(ret: any, key: string): any;
7
- declare function argToReq(params: ControllerMetaData['params'], args: any[], headers: Record<string, any>): any;
8
9
 
9
10
  declare function genClientQueue(key?: string): string;
10
11
 
@@ -21,5 +22,6 @@ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
21
22
  pipeSet: Set<string>;
22
23
  filterSet: Set<string>;
23
24
  };
25
+ declare function joinUrl(base: string, ...paths: string[]): string;
24
26
 
25
- export { HMR, argToReq, createControllerMetaMap, detectAopDep, genClientQueue, mergeObject, resolveDep, shallowClone };
27
+ export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep, genClientQueue, joinUrl, mergeObject, resolveDep, shallowClone };
package/dist/helper.js CHANGED
@@ -6,16 +6,21 @@
6
6
 
7
7
 
8
8
 
9
+ var _chunkFX3LDQIIjs = require('./chunk-FX3LDQII.js');
9
10
 
10
- var _chunkMENRZSGWjs = require('./chunk-MENRZSGW.js');
11
- require('./chunk-M5HGFUCV.js');
12
11
 
13
12
 
14
13
 
14
+ var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.js');
15
15
 
16
16
 
17
17
 
18
18
 
19
19
 
20
20
 
21
- exports.HMR = _chunkMENRZSGWjs.HMR; exports.argToReq = _chunkMENRZSGWjs.argToReq; exports.createControllerMetaMap = _chunkMENRZSGWjs.createControllerMetaMap; exports.detectAopDep = _chunkMENRZSGWjs.detectAopDep; exports.genClientQueue = _chunkMENRZSGWjs.genClientQueue; exports.mergeObject = _chunkMENRZSGWjs.mergeObject; exports.resolveDep = _chunkMENRZSGWjs.resolveDep; exports.shallowClone = _chunkMENRZSGWjs.shallowClone;
21
+
22
+
23
+
24
+
25
+
26
+ exports.HMR = _chunk5RBTN33Ajs.HMR; exports.RELAUNCH = _chunk5RBTN33Ajs.RELAUNCH; exports.RELOAD = _chunk5RBTN33Ajs.RELOAD; exports.createControllerMetaMap = _chunkFX3LDQIIjs.createControllerMetaMap; exports.detectAopDep = _chunkFX3LDQIIjs.detectAopDep; exports.genClientQueue = _chunkFX3LDQIIjs.genClientQueue; exports.joinUrl = _chunkFX3LDQIIjs.joinUrl; exports.mergeObject = _chunkFX3LDQIIjs.mergeObject; exports.resolveDep = _chunkFX3LDQIIjs.resolveDep; exports.shallowClone = _chunkFX3LDQIIjs.shallowClone;
package/dist/helper.mjs CHANGED
@@ -1,20 +1,25 @@
1
1
  import {
2
- HMR,
3
- argToReq,
4
2
  createControllerMetaMap,
5
3
  detectAopDep,
6
4
  genClientQueue,
5
+ joinUrl,
7
6
  mergeObject,
8
7
  resolveDep,
9
8
  shallowClone
10
- } from "./chunk-IRXNF6ZE.mjs";
11
- import "./chunk-C5BVKEGW.mjs";
9
+ } from "./chunk-CVPZWDXU.mjs";
10
+ import {
11
+ HMR,
12
+ RELAUNCH,
13
+ RELOAD
14
+ } from "./chunk-FXTJ3BJ6.mjs";
12
15
  export {
13
16
  HMR,
14
- argToReq,
17
+ RELAUNCH,
18
+ RELOAD,
15
19
  createControllerMetaMap,
16
20
  detectAopDep,
17
21
  genClientQueue,
22
+ joinUrl,
18
23
  mergeObject,
19
24
  resolveDep,
20
25
  shallowClone
@@ -1,12 +1,12 @@
1
1
  import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
2
2
  import { BaseMacro } from 'elysia/dist/types';
3
- import { H as HttpContext, a as HttpOptions } from '../../types-BxlzVoRv.mjs';
4
- import { F as Factory } from '../../core-DU7gQKSk.mjs';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-DKVhyZk_.mjs';
4
+ import { F as Factory } from '../../core-BDkhrEyf.mjs';
5
5
  import 'node:http';
6
- import '../../meta-BTnLXuCa.mjs';
6
+ import '../../meta-BX5jhe4Z.mjs';
7
7
  import 'phecda-core';
8
8
 
9
- interface ElysiaCtx extends HttpContext {
9
+ interface ElysiaCtx extends HttpCtx {
10
10
  type: 'elysia';
11
11
  app: Elysia$1;
12
12
  context: Context;
@@ -1,12 +1,12 @@
1
1
  import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
2
2
  import { BaseMacro } from 'elysia/dist/types';
3
- import { H as HttpContext, a as HttpOptions } from '../../types--E-OCZhC.js';
4
- import { F as Factory } from '../../core-CzElxZoF.js';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-CMeuFoyd.js';
4
+ import { F as Factory } from '../../core-D_cz0tKa.js';
5
5
  import 'node:http';
6
- import '../../meta-BTnLXuCa.js';
6
+ import '../../meta-BX5jhe4Z.js';
7
7
  import 'phecda-core';
8
8
 
9
- interface ElysiaCtx extends HttpContext {
9
+ interface ElysiaCtx extends HttpCtx {
10
10
  type: 'elysia';
11
11
  app: Elysia$1;
12
12
  context: Context;