phecda-server 5.2.5 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/{chunk-JJJ7AUEF.mjs → chunk-5E2AVYP2.mjs} +2 -2
  2. package/dist/{chunk-6QLTBEXP.js → chunk-AUAAKHWS.js} +38 -38
  3. package/dist/{chunk-2O6X54P5.mjs → chunk-BZKJ5NBU.mjs} +1 -1
  4. package/dist/{chunk-MGADYFW4.mjs → chunk-LHLQIQPH.mjs} +27 -25
  5. package/dist/{chunk-2NTXVYQC.mjs → chunk-MESZCLSS.mjs} +0 -2
  6. package/dist/{chunk-MKZOLLJS.js → chunk-N4ULJDEQ.js} +43 -41
  7. package/dist/{chunk-6T4UZ4LV.js → chunk-QYX5Q7KO.js} +60 -60
  8. package/dist/{chunk-H2FWLKXN.js → chunk-RVWBJ6LV.js} +1 -3
  9. package/dist/{core-C3cON4Um.d.ts → core-Bc2ENEHX.d.mts} +7 -5
  10. package/dist/{core-BIm7dkko.d.mts → core-dx9E5x2N.d.ts} +7 -5
  11. package/dist/helper.d.mts +1 -1
  12. package/dist/helper.d.ts +1 -1
  13. package/dist/helper.js +3 -3
  14. package/dist/helper.mjs +2 -2
  15. package/dist/index.d.mts +24 -19
  16. package/dist/index.d.ts +24 -19
  17. package/dist/index.js +72 -65
  18. package/dist/index.mjs +40 -33
  19. package/dist/rpc/bullmq/index.d.mts +3 -3
  20. package/dist/rpc/bullmq/index.d.ts +3 -3
  21. package/dist/rpc/bullmq/index.js +12 -12
  22. package/dist/rpc/bullmq/index.mjs +2 -2
  23. package/dist/rpc/kafka/index.d.mts +3 -3
  24. package/dist/rpc/kafka/index.d.ts +3 -3
  25. package/dist/rpc/kafka/index.js +12 -12
  26. package/dist/rpc/kafka/index.mjs +2 -2
  27. package/dist/rpc/nats/index.d.mts +3 -3
  28. package/dist/rpc/nats/index.d.ts +3 -3
  29. package/dist/rpc/nats/index.js +11 -11
  30. package/dist/rpc/nats/index.mjs +2 -2
  31. package/dist/rpc/rabbitmq/index.d.mts +3 -3
  32. package/dist/rpc/rabbitmq/index.d.ts +3 -3
  33. package/dist/rpc/rabbitmq/index.js +13 -13
  34. package/dist/rpc/rabbitmq/index.mjs +2 -2
  35. package/dist/rpc/redis/index.d.mts +3 -3
  36. package/dist/rpc/redis/index.d.ts +3 -3
  37. package/dist/rpc/redis/index.js +11 -11
  38. package/dist/rpc/redis/index.mjs +2 -2
  39. package/dist/server/elysia/index.d.mts +3 -3
  40. package/dist/server/elysia/index.d.ts +3 -3
  41. package/dist/server/elysia/index.js +39 -21
  42. package/dist/server/elysia/index.mjs +23 -5
  43. package/dist/server/express/index.d.mts +3 -3
  44. package/dist/server/express/index.d.ts +3 -3
  45. package/dist/server/express/index.js +36 -22
  46. package/dist/server/express/index.mjs +21 -7
  47. package/dist/server/fastify/index.d.mts +3 -3
  48. package/dist/server/fastify/index.d.ts +3 -3
  49. package/dist/server/fastify/index.js +41 -23
  50. package/dist/server/fastify/index.mjs +26 -8
  51. package/dist/server/h3/index.d.mts +3 -3
  52. package/dist/server/h3/index.d.ts +3 -3
  53. package/dist/server/h3/index.js +31 -19
  54. package/dist/server/h3/index.mjs +17 -5
  55. package/dist/server/hono/index.d.mts +3 -3
  56. package/dist/server/hono/index.d.ts +3 -3
  57. package/dist/server/hono/index.js +35 -18
  58. package/dist/server/hono/index.mjs +21 -4
  59. package/dist/server/hyper-express/index.d.mts +3 -3
  60. package/dist/server/hyper-express/index.d.ts +3 -3
  61. package/dist/server/hyper-express/index.js +31 -19
  62. package/dist/server/hyper-express/index.mjs +16 -4
  63. package/dist/server/koa/index.d.mts +3 -3
  64. package/dist/server/koa/index.d.ts +3 -3
  65. package/dist/server/koa/index.js +37 -23
  66. package/dist/server/koa/index.mjs +21 -7
  67. package/dist/test.d.mts +3 -3
  68. package/dist/test.d.ts +3 -3
  69. package/dist/test.js +14 -14
  70. package/dist/test.mjs +11 -11
  71. package/dist/{types-B-y2TwhC.d.mts → types-AgVwUXPC.d.mts} +2 -2
  72. package/dist/{types-CIZbw8S2.d.ts → types-B-ZFZajI.d.ts} +2 -2
  73. package/dist/types-BCJhmpQh.d.ts +45 -0
  74. package/dist/{types-CdQey96H.d.ts → types-BlIBlnVT.d.mts} +1 -2
  75. package/dist/{types-CdQey96H.d.mts → types-BlIBlnVT.d.ts} +1 -2
  76. package/dist/types-Dgxirc9f.d.mts +45 -0
  77. package/package.json +2 -2
  78. package/dist/types-ByP1fKMe.d.mts +0 -27
  79. package/dist/types-C5sdDiDQ.d.ts +0 -27
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  mergeObject,
3
3
  shallowClone
4
- } from "./chunk-2O6X54P5.mjs";
4
+ } from "./chunk-BZKJ5NBU.mjs";
5
5
  import {
6
6
  __name
7
- } from "./chunk-2NTXVYQC.mjs";
7
+ } from "./chunk-MESZCLSS.mjs";
8
8
 
9
9
  // src/decorators/param.ts
10
10
  import { getState, setPropertyState } from "phecda-core";
@@ -1,10 +1,10 @@
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
3
 
4
- var _chunk6T4UZ4LVjs = require('./chunk-6T4UZ4LV.js');
4
+ var _chunkQYX5Q7KOjs = require('./chunk-QYX5Q7KO.js');
5
5
 
6
6
 
7
- var _chunkH2FWLKXNjs = require('./chunk-H2FWLKXN.js');
7
+ var _chunkRVWBJ6LVjs = require('./chunk-RVWBJ6LV.js');
8
8
 
9
9
  // src/decorators/param.ts
10
10
  var _phecdacore = require('phecda-core');
@@ -14,7 +14,7 @@ function BaseParam(data) {
14
14
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
15
15
  if (!state.params) state.params = [
16
16
  ..._optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _ => _.params]) || []
17
- ].map(_chunk6T4UZ4LVjs.shallowClone);
17
+ ].map(_chunkQYX5Q7KOjs.shallowClone);
18
18
  const existItem = state.params.find((item) => item.index === index);
19
19
  if (existItem) Object.assign(existItem, data);
20
20
  else state.params.push({
@@ -24,42 +24,42 @@ function BaseParam(data) {
24
24
  });
25
25
  };
26
26
  }
27
- _chunkH2FWLKXNjs.__name.call(void 0, BaseParam, "BaseParam");
27
+ _chunkRVWBJ6LVjs.__name.call(void 0, BaseParam, "BaseParam");
28
28
  function Body(key = "") {
29
29
  return BaseParam({
30
30
  type: "body",
31
31
  key
32
32
  });
33
33
  }
34
- _chunkH2FWLKXNjs.__name.call(void 0, Body, "Body");
34
+ _chunkRVWBJ6LVjs.__name.call(void 0, Body, "Body");
35
35
  function Head(key) {
36
36
  return BaseParam({
37
37
  type: "headers",
38
38
  key: key.toLowerCase()
39
39
  });
40
40
  }
41
- _chunkH2FWLKXNjs.__name.call(void 0, Head, "Head");
41
+ _chunkRVWBJ6LVjs.__name.call(void 0, Head, "Head");
42
42
  function Query(key = "") {
43
43
  return BaseParam({
44
44
  type: "query",
45
45
  key
46
46
  });
47
47
  }
48
- _chunkH2FWLKXNjs.__name.call(void 0, Query, "Query");
48
+ _chunkRVWBJ6LVjs.__name.call(void 0, Query, "Query");
49
49
  function Param(key) {
50
50
  return BaseParam({
51
51
  type: "params",
52
52
  key
53
53
  });
54
54
  }
55
- _chunkH2FWLKXNjs.__name.call(void 0, Param, "Param");
55
+ _chunkRVWBJ6LVjs.__name.call(void 0, Param, "Param");
56
56
  function Arg(target, k, index) {
57
57
  BaseParam({
58
58
  type: "args",
59
59
  key: `${index}`
60
60
  })(target, k, index);
61
61
  }
62
- _chunkH2FWLKXNjs.__name.call(void 0, Arg, "Arg");
62
+ _chunkRVWBJ6LVjs.__name.call(void 0, Arg, "Arg");
63
63
 
64
64
  // src/decorators/aop.ts
65
65
 
@@ -76,7 +76,7 @@ function Guard(...guards) {
76
76
  });
77
77
  };
78
78
  }
79
- _chunkH2FWLKXNjs.__name.call(void 0, Guard, "Guard");
79
+ _chunkRVWBJ6LVjs.__name.call(void 0, Guard, "Guard");
80
80
  function Plugin(...plugins) {
81
81
  return (target, k) => {
82
82
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
@@ -90,7 +90,7 @@ function Plugin(...plugins) {
90
90
  });
91
91
  };
92
92
  }
93
- _chunkH2FWLKXNjs.__name.call(void 0, Plugin, "Plugin");
93
+ _chunkRVWBJ6LVjs.__name.call(void 0, Plugin, "Plugin");
94
94
  function Interceptor(...interceptors) {
95
95
  return (target, k) => {
96
96
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
@@ -104,13 +104,13 @@ function Interceptor(...interceptors) {
104
104
  });
105
105
  };
106
106
  }
107
- _chunkH2FWLKXNjs.__name.call(void 0, Interceptor, "Interceptor");
107
+ _chunkRVWBJ6LVjs.__name.call(void 0, Interceptor, "Interceptor");
108
108
  function Filter(filter) {
109
109
  return (target, k) => {
110
110
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => state.filter = filter);
111
111
  };
112
112
  }
113
- _chunkH2FWLKXNjs.__name.call(void 0, Filter, "Filter");
113
+ _chunkRVWBJ6LVjs.__name.call(void 0, Filter, "Filter");
114
114
  function Pipe(pipe) {
115
115
  return (target, k, index) => {
116
116
  if (typeof index === "number") {
@@ -122,86 +122,86 @@ function Pipe(pipe) {
122
122
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => state.pipe = pipe);
123
123
  };
124
124
  }
125
- _chunkH2FWLKXNjs.__name.call(void 0, Pipe, "Pipe");
125
+ _chunkRVWBJ6LVjs.__name.call(void 0, Pipe, "Pipe");
126
126
 
127
127
  // src/decorators/http.ts
128
128
 
129
129
  function Route(route, type) {
130
130
  return (target, k) => {
131
131
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
132
- state.http = _chunk6T4UZ4LVjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _5 => _5.http]), {
132
+ state.http = _chunkQYX5Q7KOjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _5 => _5.http]), {
133
133
  route,
134
134
  type
135
135
  });
136
136
  });
137
137
  };
138
138
  }
139
- _chunkH2FWLKXNjs.__name.call(void 0, Route, "Route");
139
+ _chunkRVWBJ6LVjs.__name.call(void 0, Route, "Route");
140
140
  function Header(headers) {
141
141
  return (target, k) => {
142
142
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
143
- if (!state.http) state.http = _chunk6T4UZ4LVjs.mergeObject.call(void 0, _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _6 => _6.http]));
144
- state.http = _chunk6T4UZ4LVjs.mergeObject.call(void 0, state.http, {
145
- headers: _chunk6T4UZ4LVjs.mergeObject.call(void 0, _optionalChain([state, 'access', _7 => _7.http, 'optionalAccess', _8 => _8.headers]), headers)
143
+ if (!state.http) state.http = _chunkQYX5Q7KOjs.mergeObject.call(void 0, _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _6 => _6.http]));
144
+ state.http = _chunkQYX5Q7KOjs.mergeObject.call(void 0, state.http, {
145
+ headers: _chunkQYX5Q7KOjs.mergeObject.call(void 0, _optionalChain([state, 'access', _7 => _7.http, 'optionalAccess', _8 => _8.headers]), headers)
146
146
  });
147
147
  });
148
148
  };
149
149
  }
150
- _chunkH2FWLKXNjs.__name.call(void 0, Header, "Header");
150
+ _chunkRVWBJ6LVjs.__name.call(void 0, Header, "Header");
151
151
  function Get(route = "") {
152
152
  return Route(route, "get");
153
153
  }
154
- _chunkH2FWLKXNjs.__name.call(void 0, Get, "Get");
154
+ _chunkRVWBJ6LVjs.__name.call(void 0, Get, "Get");
155
155
  function Post(route = "") {
156
156
  return Route(route, "post");
157
157
  }
158
- _chunkH2FWLKXNjs.__name.call(void 0, Post, "Post");
158
+ _chunkRVWBJ6LVjs.__name.call(void 0, Post, "Post");
159
159
  function Put(route = "") {
160
160
  return Route(route, "put");
161
161
  }
162
- _chunkH2FWLKXNjs.__name.call(void 0, Put, "Put");
162
+ _chunkRVWBJ6LVjs.__name.call(void 0, Put, "Put");
163
163
  function Patch(route = "") {
164
164
  return Route(route, "patch");
165
165
  }
166
- _chunkH2FWLKXNjs.__name.call(void 0, Patch, "Patch");
166
+ _chunkRVWBJ6LVjs.__name.call(void 0, Patch, "Patch");
167
167
  function Delete(route = "") {
168
168
  return Route(route, "delete");
169
169
  }
170
- _chunkH2FWLKXNjs.__name.call(void 0, Delete, "Delete");
170
+ _chunkRVWBJ6LVjs.__name.call(void 0, Delete, "Delete");
171
171
  function Controller(prefix = "") {
172
172
  return (target) => {
173
173
  _phecdacore.setPropertyState.call(void 0, target, void 0, (state) => {
174
174
  state.controller = "http";
175
- state.http = _chunk6T4UZ4LVjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target), 'optionalAccess', _9 => _9.http]), {
175
+ state.http = _chunkQYX5Q7KOjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target), 'optionalAccess', _9 => _9.http]), {
176
176
  prefix
177
177
  });
178
178
  });
179
179
  };
180
180
  }
181
- _chunkH2FWLKXNjs.__name.call(void 0, Controller, "Controller");
181
+ _chunkRVWBJ6LVjs.__name.call(void 0, Controller, "Controller");
182
182
 
183
183
  // src/decorators/rpc.ts
184
184
 
185
185
  function Event(isEvent = true) {
186
186
  return (target, k) => {
187
187
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
188
- state.rpc = _chunk6T4UZ4LVjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _10 => _10.rpc]), {
188
+ state.rpc = _chunkQYX5Q7KOjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _10 => _10.rpc]), {
189
189
  isEvent
190
190
  });
191
191
  });
192
192
  };
193
193
  }
194
- _chunkH2FWLKXNjs.__name.call(void 0, Event, "Event");
194
+ _chunkRVWBJ6LVjs.__name.call(void 0, Event, "Event");
195
195
  function Queue(queue = "") {
196
196
  return (target, k) => {
197
197
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
198
- state.rpc = _chunk6T4UZ4LVjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _11 => _11.rpc]), {
198
+ state.rpc = _chunkQYX5Q7KOjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _11 => _11.rpc]), {
199
199
  queue
200
200
  });
201
201
  });
202
202
  };
203
203
  }
204
- _chunkH2FWLKXNjs.__name.call(void 0, Queue, "Queue");
204
+ _chunkRVWBJ6LVjs.__name.call(void 0, Queue, "Queue");
205
205
  function Rpc() {
206
206
  return (target) => {
207
207
  _phecdacore.setPropertyState.call(void 0, target, void 0, (state) => {
@@ -209,15 +209,15 @@ function Rpc() {
209
209
  });
210
210
  };
211
211
  }
212
- _chunkH2FWLKXNjs.__name.call(void 0, Rpc, "Rpc");
212
+ _chunkRVWBJ6LVjs.__name.call(void 0, Rpc, "Rpc");
213
213
 
214
214
  // src/decorators/ctx.ts
215
215
 
216
216
  function Injectable() {
217
217
  return (target) => _phecdacore.Empty.call(void 0, target);
218
218
  }
219
- _chunkH2FWLKXNjs.__name.call(void 0, Injectable, "Injectable");
220
- var Ctx = /* @__PURE__ */ _chunkH2FWLKXNjs.__name.call(void 0, (target, key) => {
219
+ _chunkRVWBJ6LVjs.__name.call(void 0, Injectable, "Injectable");
220
+ var Ctx = /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (target, key) => {
221
221
  _phecdacore.setPropertyState.call(void 0, target, _phecdacore.SHARE_KEY, (state) => {
222
222
  if (!state.ctxs) state.ctxs = /* @__PURE__ */ new Set([
223
223
  ..._optionalChain([_phecdacore.getState.call(void 0, target), 'optionalAccess', _12 => _12.ctxs]) || []
@@ -232,9 +232,9 @@ function Define(key, value) {
232
232
  const parentState = _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _13 => _13.params]) || [];
233
233
  if (!state.params) state.params = [
234
234
  ...parentState
235
- ].map(_chunk6T4UZ4LVjs.shallowClone);
235
+ ].map(_chunkQYX5Q7KOjs.shallowClone);
236
236
  const existItem = state.params.find((item) => item.index === index);
237
- if (existItem) existItem.define = _chunk6T4UZ4LVjs.mergeObject.call(void 0, existItem.define, {
237
+ if (existItem) existItem.define = _chunkQYX5Q7KOjs.mergeObject.call(void 0, existItem.define, {
238
238
  [key]: value
239
239
  });
240
240
  else state.params.push({
@@ -248,12 +248,12 @@ function Define(key, value) {
248
248
  }
249
249
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
250
250
  const parentState = _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _14 => _14.define]);
251
- if (!state.define) state.define = _chunk6T4UZ4LVjs.mergeObject.call(void 0, parentState);
251
+ if (!state.define) state.define = _chunkQYX5Q7KOjs.mergeObject.call(void 0, parentState);
252
252
  state.define[key] = value;
253
253
  });
254
254
  };
255
255
  }
256
- _chunkH2FWLKXNjs.__name.call(void 0, Define, "Define");
256
+ _chunkRVWBJ6LVjs.__name.call(void 0, Define, "Define");
257
257
 
258
258
 
259
259
 
@@ -5,7 +5,7 @@ import {
5
5
  LOG_LEVEL,
6
6
  __name,
7
7
  log
8
- } from "./chunk-2NTXVYQC.mjs";
8
+ } from "./chunk-MESZCLSS.mjs";
9
9
 
10
10
  // src/helper.ts
11
11
  import pc from "picocolors";
@@ -3,7 +3,7 @@ import {
3
3
  IS_ONLY_GENERATE,
4
4
  __name,
5
5
  log
6
- } from "./chunk-2NTXVYQC.mjs";
6
+ } from "./chunk-MESZCLSS.mjs";
7
7
 
8
8
  // src/meta.ts
9
9
  var Meta = class {
@@ -28,8 +28,8 @@ var emitter = new EventEmitter();
28
28
  async function Factory(models, opts = {}) {
29
29
  const moduleMap = /* @__PURE__ */ new Map();
30
30
  const meta = [];
31
- const constructorMap = /* @__PURE__ */ new Map();
32
- const constructorSet = /* @__PURE__ */ new WeakSet();
31
+ const modelMap = /* @__PURE__ */ new WeakMap();
32
+ const modelSet = /* @__PURE__ */ new WeakSet();
33
33
  const dependenceGraph = /* @__PURE__ */ new Map();
34
34
  const { parseModule = /* @__PURE__ */ __name((module) => module, "parseModule"), parseMeta = /* @__PURE__ */ __name((meta2) => meta2, "parseMeta"), generators } = opts;
35
35
  if (!getInject("watcher")) {
@@ -44,16 +44,16 @@ async function Factory(models, opts = {}) {
44
44
  }
45
45
  async function del(tag) {
46
46
  if (!moduleMap.has(tag)) return;
47
- const instance = moduleMap.get(tag);
47
+ const module = moduleMap.get(tag);
48
48
  debug(`unmount module "${String(tag)}"`);
49
- await invokeHandler("unmount", instance);
49
+ await invokeHandler("unmount", module);
50
50
  debug(`del module "${String(tag)}"`);
51
51
  moduleMap.delete(tag);
52
- constructorMap.delete(tag);
52
+ modelMap.delete(module);
53
53
  for (let i = meta.length - 1; i >= 0; i--) {
54
54
  if (meta[i].data.tag === tag) meta.splice(i, 1);
55
55
  }
56
- return instance;
56
+ return module;
57
57
  }
58
58
  __name(del, "del");
59
59
  async function destroy() {
@@ -64,7 +64,7 @@ async function Factory(models, opts = {}) {
64
64
  async function add(Model) {
65
65
  const tag = getTag(Model);
66
66
  const oldInstance = await del(tag);
67
- const { instance: newModule } = await buildDepModule(Model);
67
+ const { module: newModule } = await buildDepModule(Model);
68
68
  if (oldInstance && dependenceGraph.has(tag)) {
69
69
  debug(`replace module "${String(tag)}"`);
70
70
  [
@@ -80,18 +80,18 @@ async function Factory(models, opts = {}) {
80
80
  __name(add, "add");
81
81
  async function buildDepModule(Model) {
82
82
  const paramtypes = getParamTypes(Model);
83
- let instance;
83
+ let module;
84
84
  const tag = getTag(Model);
85
85
  if (moduleMap.has(tag)) {
86
- instance = moduleMap.get(tag);
87
- if (!instance) throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Model}`);
88
- if (constructorMap.get(tag) !== Model && !constructorSet.has(Model)) {
89
- constructorSet.add(Model);
90
- if (instance instanceof Model) log(`Module taged ${String(tag)} has been overridden`);
86
+ module = moduleMap.get(tag);
87
+ if (!module) throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Model}`);
88
+ if (modelMap.get(module) !== Model && !modelSet.has(Model)) {
89
+ modelSet.add(Model);
90
+ if (module instanceof Model) log(`Module taged ${String(tag)} has been overridden`);
91
91
  else log(`Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
92
92
  }
93
93
  return {
94
- instance,
94
+ module,
95
95
  tag
96
96
  };
97
97
  }
@@ -100,23 +100,23 @@ async function Factory(models, opts = {}) {
100
100
  if (paramtypes) {
101
101
  const paramtypesInstances = [];
102
102
  for (const i in paramtypes) {
103
- const { instance: sub, tag: subTag } = await buildDepModule(paramtypes[i]);
103
+ const { module: sub, tag: subTag } = await buildDepModule(paramtypes[i]);
104
104
  paramtypesInstances[i] = sub;
105
105
  if (!dependenceGraph.has(subTag)) dependenceGraph.set(subTag, /* @__PURE__ */ new Set());
106
106
  dependenceGraph.get(subTag).add(tag);
107
107
  }
108
- instance = parseModule(new Model(...paramtypesInstances));
108
+ module = parseModule(new Model(...paramtypesInstances));
109
109
  } else {
110
- instance = parseModule(new Model());
110
+ module = parseModule(new Model());
111
111
  }
112
- meta.push(...getMetaFromInstance(instance, tag, Model.name).map(parseMeta).filter((item) => !!item));
112
+ meta.push(...getMetaFromInstance(module, tag, Model.name).map(parseMeta).filter((item) => !!item));
113
113
  debug(`init module "${String(tag)}"`);
114
- if (!IS_ONLY_GENERATE) await invokeHandler("init", instance);
114
+ if (!IS_ONLY_GENERATE) await invokeHandler("init", module);
115
115
  debug(`add module "${String(tag)}"`);
116
- moduleMap.set(tag, instance);
117
- constructorMap.set(tag, Model);
116
+ moduleMap.set(tag, module);
117
+ modelMap.set(module, Model);
118
118
  return {
119
- instance,
119
+ module,
120
120
  tag
121
121
  };
122
122
  }
@@ -149,7 +149,7 @@ async function Factory(models, opts = {}) {
149
149
  }
150
150
  return {
151
151
  moduleMap,
152
- constructorMap,
152
+ modelMap,
153
153
  meta,
154
154
  add,
155
155
  del,
@@ -226,9 +226,11 @@ function initState(state) {
226
226
  if (!state.interceptors) state.interceptors = /* @__PURE__ */ new Set();
227
227
  }
228
228
  __name(initState, "initState");
229
+ var createPhecda = Factory;
229
230
 
230
231
  export {
231
232
  Meta,
232
233
  emitter,
233
- Factory
234
+ Factory,
235
+ createPhecda
234
236
  };
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/common.ts
5
- var UNMOUNT_SYMBOL = "__PS_UNMOUNT__";
6
5
  var ERROR_SYMBOL = "__PS_ERROR__";
7
6
  var IS_HMR = process.env.NODE_ENV === "development";
8
7
  var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
@@ -55,7 +54,6 @@ __name(Mix, "Mix");
55
54
 
56
55
  export {
57
56
  __name,
58
- UNMOUNT_SYMBOL,
59
57
  ERROR_SYMBOL,
60
58
  IS_HMR,
61
59
  IS_ONLY_GENERATE,
@@ -3,12 +3,12 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkH2FWLKXNjs = require('./chunk-H2FWLKXN.js');
6
+ var _chunkRVWBJ6LVjs = require('./chunk-RVWBJ6LV.js');
7
7
 
8
8
  // src/meta.ts
9
9
  var Meta = class {
10
10
  static {
11
- _chunkH2FWLKXNjs.__name.call(void 0, this, "Meta");
11
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "Meta");
12
12
  }
13
13
 
14
14
 
@@ -28,10 +28,10 @@ var emitter = new (0, _events2.default)();
28
28
  async function Factory(models, opts = {}) {
29
29
  const moduleMap = /* @__PURE__ */ new Map();
30
30
  const meta = [];
31
- const constructorMap = /* @__PURE__ */ new Map();
32
- const constructorSet = /* @__PURE__ */ new WeakSet();
31
+ const modelMap = /* @__PURE__ */ new WeakMap();
32
+ const modelSet = /* @__PURE__ */ new WeakSet();
33
33
  const dependenceGraph = /* @__PURE__ */ new Map();
34
- const { parseModule = /* @__PURE__ */ _chunkH2FWLKXNjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkH2FWLKXNjs.__name.call(void 0, (meta2) => meta2, "parseMeta"), generators } = opts;
34
+ const { parseModule = /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (meta2) => meta2, "parseMeta"), generators } = opts;
35
35
  if (!_phecdacore.getInject.call(void 0, "watcher")) {
36
36
  _phecdacore.setInject.call(void 0, "watcher", ({ eventName, instance, key, options }) => {
37
37
  const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
@@ -44,27 +44,27 @@ async function Factory(models, opts = {}) {
44
44
  }
45
45
  async function del(tag) {
46
46
  if (!moduleMap.has(tag)) return;
47
- const instance = moduleMap.get(tag);
47
+ const module = moduleMap.get(tag);
48
48
  debug(`unmount module "${String(tag)}"`);
49
- await _phecdacore.invokeHandler.call(void 0, "unmount", instance);
49
+ await _phecdacore.invokeHandler.call(void 0, "unmount", module);
50
50
  debug(`del module "${String(tag)}"`);
51
51
  moduleMap.delete(tag);
52
- constructorMap.delete(tag);
52
+ modelMap.delete(module);
53
53
  for (let i = meta.length - 1; i >= 0; i--) {
54
54
  if (meta[i].data.tag === tag) meta.splice(i, 1);
55
55
  }
56
- return instance;
56
+ return module;
57
57
  }
58
- _chunkH2FWLKXNjs.__name.call(void 0, del, "del");
58
+ _chunkRVWBJ6LVjs.__name.call(void 0, del, "del");
59
59
  async function destroy() {
60
60
  debug("destroy all");
61
61
  for (const [tag] of moduleMap) await del(tag);
62
62
  }
63
- _chunkH2FWLKXNjs.__name.call(void 0, destroy, "destroy");
63
+ _chunkRVWBJ6LVjs.__name.call(void 0, destroy, "destroy");
64
64
  async function add(Model) {
65
65
  const tag = _phecdacore.getTag.call(void 0, Model);
66
66
  const oldInstance = await del(tag);
67
- const { instance: newModule } = await buildDepModule(Model);
67
+ const { module: newModule } = await buildDepModule(Model);
68
68
  if (oldInstance && dependenceGraph.has(tag)) {
69
69
  debug(`replace module "${String(tag)}"`);
70
70
  [
@@ -77,21 +77,21 @@ async function Factory(models, opts = {}) {
77
77
  });
78
78
  }
79
79
  }
80
- _chunkH2FWLKXNjs.__name.call(void 0, add, "add");
80
+ _chunkRVWBJ6LVjs.__name.call(void 0, add, "add");
81
81
  async function buildDepModule(Model) {
82
82
  const paramtypes = getParamTypes(Model);
83
- let instance;
83
+ let module;
84
84
  const tag = _phecdacore.getTag.call(void 0, Model);
85
85
  if (moduleMap.has(tag)) {
86
- instance = moduleMap.get(tag);
87
- if (!instance) throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Model}`);
88
- if (constructorMap.get(tag) !== Model && !constructorSet.has(Model)) {
89
- constructorSet.add(Model);
90
- if (instance instanceof Model) _chunkH2FWLKXNjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
91
- else _chunkH2FWLKXNjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
86
+ module = moduleMap.get(tag);
87
+ if (!module) throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Model}`);
88
+ if (modelMap.get(module) !== Model && !modelSet.has(Model)) {
89
+ modelSet.add(Model);
90
+ if (module instanceof Model) _chunkRVWBJ6LVjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
91
+ else _chunkRVWBJ6LVjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
92
92
  }
93
93
  return {
94
- instance,
94
+ module,
95
95
  tag
96
96
  };
97
97
  }
@@ -100,41 +100,41 @@ async function Factory(models, opts = {}) {
100
100
  if (paramtypes) {
101
101
  const paramtypesInstances = [];
102
102
  for (const i in paramtypes) {
103
- const { instance: sub, tag: subTag } = await buildDepModule(paramtypes[i]);
103
+ const { module: sub, tag: subTag } = await buildDepModule(paramtypes[i]);
104
104
  paramtypesInstances[i] = sub;
105
105
  if (!dependenceGraph.has(subTag)) dependenceGraph.set(subTag, /* @__PURE__ */ new Set());
106
106
  dependenceGraph.get(subTag).add(tag);
107
107
  }
108
- instance = parseModule(new Model(...paramtypesInstances));
108
+ module = parseModule(new Model(...paramtypesInstances));
109
109
  } else {
110
- instance = parseModule(new Model());
110
+ module = parseModule(new Model());
111
111
  }
112
- meta.push(...getMetaFromInstance(instance, tag, Model.name).map(parseMeta).filter((item) => !!item));
112
+ meta.push(...getMetaFromInstance(module, tag, Model.name).map(parseMeta).filter((item) => !!item));
113
113
  debug(`init module "${String(tag)}"`);
114
- if (!_chunkH2FWLKXNjs.IS_ONLY_GENERATE) await _phecdacore.invokeHandler.call(void 0, "init", instance);
114
+ if (!_chunkRVWBJ6LVjs.IS_ONLY_GENERATE) await _phecdacore.invokeHandler.call(void 0, "init", module);
115
115
  debug(`add module "${String(tag)}"`);
116
- moduleMap.set(tag, instance);
117
- constructorMap.set(tag, Model);
116
+ moduleMap.set(tag, module);
117
+ modelMap.set(module, Model);
118
118
  return {
119
- instance,
119
+ module,
120
120
  tag
121
121
  };
122
122
  }
123
- _chunkH2FWLKXNjs.__name.call(void 0, buildDepModule, "buildDepModule");
123
+ _chunkRVWBJ6LVjs.__name.call(void 0, buildDepModule, "buildDepModule");
124
124
  for (const model of models) await buildDepModule(model);
125
125
  async function generateCode() {
126
- if (generators && _chunkH2FWLKXNjs.IS_HMR) {
126
+ if (generators && _chunkRVWBJ6LVjs.IS_HMR) {
127
127
  return Promise.all(generators.map((generator) => {
128
128
  debug(`generate "${generator.name}" code to ${generator.path}`);
129
129
  return generator.output(meta);
130
130
  }));
131
131
  }
132
132
  }
133
- _chunkH2FWLKXNjs.__name.call(void 0, generateCode, "generateCode");
133
+ _chunkRVWBJ6LVjs.__name.call(void 0, generateCode, "generateCode");
134
134
  generateCode().then(() => {
135
- if (_chunkH2FWLKXNjs.IS_ONLY_GENERATE) process.exit(4);
135
+ if (_chunkRVWBJ6LVjs.IS_ONLY_GENERATE) process.exit(4);
136
136
  });
137
- if (_chunkH2FWLKXNjs.IS_HMR) {
137
+ if (_chunkRVWBJ6LVjs.IS_HMR) {
138
138
  if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
139
139
  _optionalChain([globalThis, 'access', _2 => _2.__PS_HMR__, 'optionalAccess', _3 => _3.push, 'call', _4 => _4(async (files) => {
140
140
  debug("reload files ");
@@ -149,14 +149,14 @@ async function Factory(models, opts = {}) {
149
149
  }
150
150
  return {
151
151
  moduleMap,
152
- constructorMap,
152
+ modelMap,
153
153
  meta,
154
154
  add,
155
155
  del,
156
156
  destroy
157
157
  };
158
158
  }
159
- _chunkH2FWLKXNjs.__name.call(void 0, Factory, "Factory");
159
+ _chunkRVWBJ6LVjs.__name.call(void 0, Factory, "Factory");
160
160
  function getMetaFromInstance(instance, tag, name) {
161
161
  const vars = _phecdacore.getExposeKey.call(void 0, instance).filter((item) => typeof item === "string");
162
162
  const baseState = _phecdacore.getState.call(void 0, instance);
@@ -171,7 +171,7 @@ function getMetaFromInstance(instance, tag, name) {
171
171
  func: i
172
172
  };
173
173
  if (baseState.controller) {
174
- if (typeof tag !== "string") _chunkH2FWLKXNjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
174
+ if (typeof tag !== "string") _chunkRVWBJ6LVjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
175
175
  initState(state);
176
176
  meta.controller = baseState.controller;
177
177
  meta[baseState.controller] = {
@@ -214,21 +214,23 @@ function getMetaFromInstance(instance, tag, name) {
214
214
  return new Meta(meta, getParamTypes(instance, i) || []);
215
215
  });
216
216
  }
217
- _chunkH2FWLKXNjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
217
+ _chunkRVWBJ6LVjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
218
218
  function getParamTypes(Model, key) {
219
219
  return Reflect.getMetadata("design:paramtypes", Model, key);
220
220
  }
221
- _chunkH2FWLKXNjs.__name.call(void 0, getParamTypes, "getParamTypes");
221
+ _chunkRVWBJ6LVjs.__name.call(void 0, getParamTypes, "getParamTypes");
222
222
  function initState(state) {
223
223
  if (!state.define) state.define = {};
224
224
  if (!state.plugins) state.plugins = /* @__PURE__ */ new Set();
225
225
  if (!state.guards) state.guards = /* @__PURE__ */ new Set();
226
226
  if (!state.interceptors) state.interceptors = /* @__PURE__ */ new Set();
227
227
  }
228
- _chunkH2FWLKXNjs.__name.call(void 0, initState, "initState");
228
+ _chunkRVWBJ6LVjs.__name.call(void 0, initState, "initState");
229
+ var createPhecda = Factory;
229
230
 
230
231
 
231
232
 
232
233
 
233
234
 
234
- exports.Meta = Meta; exports.emitter = emitter; exports.Factory = Factory;
235
+
236
+ exports.Meta = Meta; exports.emitter = emitter; exports.Factory = Factory; exports.createPhecda = createPhecda;