phecda-server 7.0.0-alpha.9 → 7.0.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 (154) hide show
  1. package/README.md +10 -10
  2. package/assets/schema.json +12 -9
  3. package/bin/cli.mjs +96 -37
  4. package/dist/chunk-5SUY5UVC.js +258 -0
  5. package/dist/chunk-5SUY5UVC.js.map +1 -0
  6. package/dist/{chunk-7ZGYJ5OW.mjs → chunk-6JAHCTOT.mjs} +7 -2
  7. package/dist/chunk-6JAHCTOT.mjs.map +1 -0
  8. package/dist/{chunk-V5EYXVJT.js → chunk-EDAWJVJ4.js} +42 -25
  9. package/dist/chunk-EDAWJVJ4.js.map +1 -0
  10. package/dist/{chunk-FX3LDQII.js → chunk-H7OCHDZT.js} +61 -70
  11. package/dist/chunk-H7OCHDZT.js.map +1 -0
  12. package/dist/chunk-KRUOHWFR.js +306 -0
  13. package/dist/chunk-KRUOHWFR.js.map +1 -0
  14. package/dist/{chunk-KJUD2BKE.js → chunk-KUGU3UGO.js} +23 -18
  15. package/dist/chunk-KUGU3UGO.js.map +1 -0
  16. package/dist/{chunk-CVPZWDXU.mjs → chunk-LBH4RXQQ.mjs} +11 -20
  17. package/dist/chunk-LBH4RXQQ.mjs.map +1 -0
  18. package/dist/{chunk-FXTJ3BJ6.mjs → chunk-MDPW6WGF.mjs} +10 -4
  19. package/dist/chunk-MDPW6WGF.mjs.map +1 -0
  20. package/dist/{chunk-5RBTN33A.js → chunk-RLFCI3RG.js} +11 -5
  21. package/dist/chunk-RLFCI3RG.js.map +1 -0
  22. package/dist/{chunk-ODVWOXVB.mjs → chunk-TTHYUNOT.mjs} +18 -1
  23. package/dist/chunk-TTHYUNOT.mjs.map +1 -0
  24. package/dist/chunk-VDOICQ2U.mjs +258 -0
  25. package/dist/chunk-VDOICQ2U.mjs.map +1 -0
  26. package/dist/chunk-WTJKTICN.mjs +306 -0
  27. package/dist/chunk-WTJKTICN.mjs.map +1 -0
  28. package/dist/{core-D_cz0tKa.d.ts → core-BOo3uGFX.d.ts} +2 -2
  29. package/dist/{core-BDkhrEyf.d.mts → core-CF45G79J.d.mts} +2 -2
  30. package/dist/core-DbqWh47p.d.mts +50 -0
  31. package/dist/core-Rq7BhPHE.d.ts +50 -0
  32. package/dist/helper.d.mts +3 -5
  33. package/dist/helper.d.ts +3 -5
  34. package/dist/helper.js +4 -5
  35. package/dist/helper.js.map +1 -0
  36. package/dist/helper.mjs +3 -4
  37. package/dist/helper.mjs.map +1 -0
  38. package/dist/http/elysia/index.d.mts +4 -4
  39. package/dist/http/elysia/index.d.ts +4 -4
  40. package/dist/http/elysia/index.js +42 -40
  41. package/dist/http/elysia/index.js.map +1 -0
  42. package/dist/http/elysia/index.mjs +5 -3
  43. package/dist/http/elysia/index.mjs.map +1 -0
  44. package/dist/http/express/index.d.mts +3 -3
  45. package/dist/http/express/index.d.ts +3 -3
  46. package/dist/http/express/index.js +39 -37
  47. package/dist/http/express/index.js.map +1 -0
  48. package/dist/http/express/index.mjs +4 -2
  49. package/dist/http/express/index.mjs.map +1 -0
  50. package/dist/http/fastify/index.d.mts +3 -3
  51. package/dist/http/fastify/index.d.ts +3 -3
  52. package/dist/http/fastify/index.js +40 -38
  53. package/dist/http/fastify/index.js.map +1 -0
  54. package/dist/http/fastify/index.mjs +5 -3
  55. package/dist/http/fastify/index.mjs.map +1 -0
  56. package/dist/http/h3/index.d.mts +3 -3
  57. package/dist/http/h3/index.d.ts +3 -3
  58. package/dist/http/h3/index.js +40 -38
  59. package/dist/http/h3/index.js.map +1 -0
  60. package/dist/http/h3/index.mjs +4 -2
  61. package/dist/http/h3/index.mjs.map +1 -0
  62. package/dist/http/hono/index.d.mts +3 -3
  63. package/dist/http/hono/index.d.ts +3 -3
  64. package/dist/http/hono/index.js +36 -34
  65. package/dist/http/hono/index.js.map +1 -0
  66. package/dist/http/hono/index.mjs +4 -2
  67. package/dist/http/hono/index.mjs.map +1 -0
  68. package/dist/http/hyper-express/index.d.mts +3 -3
  69. package/dist/http/hyper-express/index.d.ts +3 -3
  70. package/dist/http/hyper-express/index.js +37 -35
  71. package/dist/http/hyper-express/index.js.map +1 -0
  72. package/dist/http/hyper-express/index.mjs +4 -2
  73. package/dist/http/hyper-express/index.mjs.map +1 -0
  74. package/dist/http/koa/index.d.mts +3 -3
  75. package/dist/http/koa/index.d.ts +3 -3
  76. package/dist/http/koa/index.js +39 -37
  77. package/dist/http/koa/index.js.map +1 -0
  78. package/dist/http/koa/index.mjs +4 -2
  79. package/dist/http/koa/index.mjs.map +1 -0
  80. package/dist/index.d.mts +76 -12
  81. package/dist/index.d.ts +76 -12
  82. package/dist/index.js +105 -49
  83. package/dist/index.js.map +1 -0
  84. package/dist/index.mjs +68 -12
  85. package/dist/index.mjs.map +1 -0
  86. package/dist/{meta-BX5jhe4Z.d.mts → meta-BoS1E-Nz.d.mts} +6 -23
  87. package/dist/{meta-BX5jhe4Z.d.ts → meta-BoS1E-Nz.d.ts} +6 -23
  88. package/dist/rpc/bullmq/index.d.mts +4 -6
  89. package/dist/rpc/bullmq/index.d.ts +4 -6
  90. package/dist/rpc/bullmq/index.js +13 -80
  91. package/dist/rpc/bullmq/index.js.map +1 -0
  92. package/dist/rpc/bullmq/index.mjs +5 -72
  93. package/dist/rpc/bullmq/index.mjs.map +1 -0
  94. package/dist/rpc/electron/index.d.mts +13 -0
  95. package/dist/rpc/electron/index.d.ts +13 -0
  96. package/dist/rpc/electron/index.js +73 -0
  97. package/dist/rpc/electron/index.js.map +1 -0
  98. package/dist/rpc/electron/index.mjs +73 -0
  99. package/dist/rpc/electron/index.mjs.map +1 -0
  100. package/dist/rpc/kafka/index.d.mts +4 -9
  101. package/dist/rpc/kafka/index.d.ts +4 -9
  102. package/dist/rpc/kafka/index.js +12 -90
  103. package/dist/rpc/kafka/index.js.map +1 -0
  104. package/dist/rpc/kafka/index.mjs +5 -83
  105. package/dist/rpc/kafka/index.mjs.map +1 -0
  106. package/dist/rpc/nats/index.d.mts +4 -6
  107. package/dist/rpc/nats/index.d.ts +4 -6
  108. package/dist/rpc/nats/index.js +13 -72
  109. package/dist/rpc/nats/index.js.map +1 -0
  110. package/dist/rpc/nats/index.mjs +4 -63
  111. package/dist/rpc/nats/index.mjs.map +1 -0
  112. package/dist/rpc/rabbitmq/index.d.mts +4 -6
  113. package/dist/rpc/rabbitmq/index.d.ts +4 -6
  114. package/dist/rpc/rabbitmq/index.js +14 -79
  115. package/dist/rpc/rabbitmq/index.js.map +1 -0
  116. package/dist/rpc/rabbitmq/index.mjs +5 -70
  117. package/dist/rpc/rabbitmq/index.mjs.map +1 -0
  118. package/dist/rpc/redis/index.d.mts +4 -9
  119. package/dist/rpc/redis/index.d.ts +4 -9
  120. package/dist/rpc/redis/index.js +12 -78
  121. package/dist/rpc/redis/index.js.map +1 -0
  122. package/dist/rpc/redis/index.mjs +5 -71
  123. package/dist/rpc/redis/index.mjs.map +1 -0
  124. package/dist/rpc/web-ext/index.d.mts +2 -0
  125. package/dist/rpc/web-ext/index.d.ts +2 -0
  126. package/dist/rpc/web-ext/index.js +1 -0
  127. package/dist/rpc/web-ext/index.js.map +1 -0
  128. package/dist/rpc/web-ext/index.mjs +1 -0
  129. package/dist/rpc/web-ext/index.mjs.map +1 -0
  130. package/dist/rpc/ws/index.d.mts +14 -0
  131. package/dist/rpc/ws/index.d.ts +14 -0
  132. package/dist/rpc/ws/index.js +74 -0
  133. package/dist/rpc/ws/index.js.map +1 -0
  134. package/dist/rpc/ws/index.mjs +74 -0
  135. package/dist/rpc/ws/index.mjs.map +1 -0
  136. package/dist/test.d.mts +7 -3
  137. package/dist/test.d.ts +7 -3
  138. package/dist/test.js +7 -6
  139. package/dist/test.js.map +1 -0
  140. package/dist/test.mjs +3 -2
  141. package/dist/test.mjs.map +1 -0
  142. package/dist/types-CInz3bD0.d.ts +14 -0
  143. package/dist/types-E-rqlg3-.d.mts +14 -0
  144. package/dist/{types-DKVhyZk_.d.mts → types-SCJZFCYt.d.mts} +1 -1
  145. package/dist/{types-CMeuFoyd.d.ts → types-xruyYmyu.d.ts} +1 -1
  146. package/package.json +24 -8
  147. package/register/export.mjs +30 -0
  148. package/register/index.mjs +2 -3
  149. package/register/loader.mjs +83 -90
  150. package/register/utils.mjs +36 -6
  151. package/assets/ps.json +0 -24
  152. package/assets/tsconfig.json +0 -21
  153. package/dist/types-B-rUM9Fm.d.mts +0 -19
  154. package/dist/types-MxxtkZXw.d.ts +0 -19
@@ -0,0 +1,306 @@
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
+
3
+
4
+
5
+
6
+
7
+ var _chunkRLFCI3RGjs = require('./chunk-RLFCI3RG.js');
8
+
9
+ // src/meta.ts
10
+ var Meta = class {
11
+ static {
12
+ _chunkRLFCI3RGjs.__name.call(void 0, this, "Meta");
13
+ }
14
+
15
+
16
+ constructor(data, paramsType) {
17
+ this.data = data;
18
+ this.paramsType = paramsType;
19
+ }
20
+ };
21
+
22
+ // src/core.ts
23
+ require('reflect-metadata');
24
+ var _events = require('events'); var _events2 = _interopRequireDefault(_events);
25
+ var _phecdacore = require('phecda-core');
26
+ var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
27
+ var debug = _debug2.default.call(void 0, "phecda-server(Factory)");
28
+ var emitter = new (0, _events2.default)();
29
+ function defaultServerInject() {
30
+ if (!_phecdacore.getInject.call(void 0, "watcher")) {
31
+ _phecdacore.setInject.call(void 0, "watcher", ({ eventName, instance, property, options }) => {
32
+ const fn = typeof instance[property] === "function" ? instance[property].bind(instance) : (v) => instance[property] = v;
33
+ if (_optionalChain([options, 'optionalAccess', _ => _.once])) emitter.once(eventName, fn);
34
+ else emitter.on(eventName, fn);
35
+ return () => {
36
+ emitter.off(eventName, fn);
37
+ };
38
+ });
39
+ }
40
+ }
41
+ _chunkRLFCI3RGjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
42
+ var phecdaNamespace = /* @__PURE__ */ new Map();
43
+ var ServerPhecda = (_class = class {
44
+ static {
45
+ _chunkRLFCI3RGjs.__name.call(void 0, this, "ServerPhecda");
46
+ }
47
+ __init() {this.moduleMap = /* @__PURE__ */ new Map()}
48
+ __init2() {this.meta = []}
49
+ __init3() {this.modelMap = /* @__PURE__ */ new WeakMap()}
50
+ __init4() {this.modelSet = /* @__PURE__ */ new WeakSet()}
51
+ __init5() {this.dependenceGraph = /* @__PURE__ */ new Map()}
52
+
53
+
54
+
55
+ 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);
56
+ defaultServerInject();
57
+ const { namespace = "default", parseModule = /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
58
+ phecdaNamespace.set(namespace, this);
59
+ this.parseMeta = parseMeta;
60
+ this.parseModule = parseModule;
61
+ this.generators = generators;
62
+ }
63
+ async start(models) {
64
+ for (const model of models) await this.buildDepModule(model);
65
+ this.hmr();
66
+ this.generateCode().then(() => {
67
+ if (_chunkRLFCI3RGjs.IS_ONLY_GENERATE) {
68
+ _chunkRLFCI3RGjs.log.call(void 0, "Only generate code");
69
+ process.exit(_chunkRLFCI3RGjs.PS_EXIT_CODE.EXIT);
70
+ }
71
+ });
72
+ }
73
+ __init6() {this.generateCode = /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, async () => {
74
+ return Promise.all(this.generators.map((generator) => {
75
+ debug(`generate "${generator.name}" code to ${generator.path}`);
76
+ return generator.output(this.meta);
77
+ }));
78
+ }, "generateCode")}
79
+ hmr() {
80
+ _chunkRLFCI3RGjs.HMR.call(void 0, async (oldModels, newModels) => {
81
+ debug("reload models ");
82
+ await this.replace(oldModels, newModels);
83
+ this.generateCode();
84
+ });
85
+ }
86
+ async destroy() {
87
+ debug("destroy all");
88
+ this.replace(Object.values(this.modelMap), []);
89
+ }
90
+ createProxyModule(tag) {
91
+ const that = this;
92
+ return new Proxy({}, {
93
+ get(_target, prop) {
94
+ const module = that.moduleMap.get(tag);
95
+ return Reflect.get(module, prop, module);
96
+ },
97
+ set(_target, prop, newValue) {
98
+ const module = that.moduleMap.get(tag);
99
+ return Reflect.set(module, prop, newValue, module);
100
+ },
101
+ has(_target, prop) {
102
+ return Reflect.has(that.moduleMap.get(tag), prop);
103
+ },
104
+ ownKeys() {
105
+ return Reflect.ownKeys(that.moduleMap.get(tag));
106
+ },
107
+ getPrototypeOf() {
108
+ return Reflect.getPrototypeOf(that.moduleMap.get(tag));
109
+ },
110
+ getOwnPropertyDescriptor(_target, prop) {
111
+ return Reflect.getOwnPropertyDescriptor(that.moduleMap.get(tag), prop);
112
+ }
113
+ });
114
+ }
115
+ async buildDepModule(Model) {
116
+ const paramtypes = getParamTypes(Model);
117
+ let module;
118
+ const tag = _phecdacore.getTag.call(void 0, Model);
119
+ if (this.moduleMap.has(tag)) {
120
+ module = this.moduleMap.get(tag);
121
+ if (!module) {
122
+ _chunkRLFCI3RGjs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
123
+ return {
124
+ module: this.createProxyModule(tag),
125
+ tag
126
+ };
127
+ }
128
+ if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
129
+ this.modelSet.add(Model);
130
+ if (module instanceof Model) _chunkRLFCI3RGjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
131
+ else _chunkRLFCI3RGjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
132
+ }
133
+ return {
134
+ module,
135
+ tag
136
+ };
137
+ }
138
+ this.moduleMap.set(tag, void 0);
139
+ debug(`instantiate module "${String(tag)}"`);
140
+ if (paramtypes) {
141
+ const paramtypesInstances = [];
142
+ for (const i in paramtypes) {
143
+ const { module: sub, tag: subTag } = await this.buildDepModule(paramtypes[i]);
144
+ paramtypesInstances[i] = sub;
145
+ if (!this.dependenceGraph.has(subTag)) this.dependenceGraph.set(subTag, /* @__PURE__ */ new Set());
146
+ this.dependenceGraph.get(subTag).add(tag);
147
+ }
148
+ module = this.parseModule(new Model(...paramtypesInstances));
149
+ } else {
150
+ module = this.parseModule(new Model());
151
+ }
152
+ this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter((item) => !!item));
153
+ debug(`init module "${String(tag)}"`);
154
+ if (!_chunkRLFCI3RGjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
155
+ debug(`add module "${String(tag)}"`);
156
+ this.moduleMap.set(tag, module);
157
+ this.modelMap.set(module, Model);
158
+ return {
159
+ module,
160
+ tag
161
+ };
162
+ }
163
+ async replace(oldModels, newModels) {
164
+ const oldModules = (await Promise.all(oldModels.map(async (model) => {
165
+ const tag = _phecdacore.getTag.call(void 0, model);
166
+ if (!this.has(tag)) return;
167
+ const module = this.moduleMap.get(tag);
168
+ debug(`unmount module "${String(tag)}"`);
169
+ await _phecdacore.invokeUnmount.call(void 0, module);
170
+ debug(`del module "${String(tag)}"`);
171
+ this.moduleMap.delete(tag);
172
+ this.modelMap.delete(module);
173
+ for (let i = this.meta.length - 1; i >= 0; i--) {
174
+ if (this.meta[i].data.tag === tag) this.meta.splice(i, 1);
175
+ }
176
+ return module;
177
+ }))).filter((item) => item);
178
+ for (const model of newModels) {
179
+ debug(`mount module: ${model.name}`);
180
+ await this.buildDepModule(model);
181
+ }
182
+ debug("replace old modules");
183
+ for (const module of oldModules) {
184
+ const tag = _phecdacore.getTag.call(void 0, module);
185
+ if (this.dependenceGraph.has(tag)) {
186
+ [
187
+ ...this.dependenceGraph.get(tag)
188
+ ].forEach((depTag) => {
189
+ const depModule = this.moduleMap.get(depTag);
190
+ if (depModule) {
191
+ for (const key in depModule) {
192
+ if (depModule[key] === module) depModule[key] = this.moduleMap.get(tag);
193
+ }
194
+ }
195
+ });
196
+ }
197
+ }
198
+ }
199
+ has(modelOrTag) {
200
+ return this.moduleMap.has(typeof modelOrTag === "function" ? _phecdacore.getTag.call(void 0, modelOrTag) : modelOrTag);
201
+ }
202
+ get(modelOrTag) {
203
+ const tag = typeof modelOrTag === "function" ? _phecdacore.getTag.call(void 0, modelOrTag) : modelOrTag;
204
+ if (!this.has(tag)) throw new Error(`module "${tag.toString()}" doesn't exist`);
205
+ return this.moduleMap.get(tag);
206
+ }
207
+ getModel(tag) {
208
+ return this.modelMap.get(this.get(tag));
209
+ }
210
+ }, _class);
211
+ async function Factory(models, opts = {}) {
212
+ const phecda = new ServerPhecda(opts);
213
+ await phecda.start(models);
214
+ return phecda;
215
+ }
216
+ _chunkRLFCI3RGjs.__name.call(void 0, Factory, "Factory");
217
+ function useS(nsOrModel, namespace) {
218
+ if (!nsOrModel) {
219
+ namespace = "default";
220
+ } else {
221
+ if (typeof nsOrModel === "string") namespace = nsOrModel;
222
+ else if (!namespace) namespace = "default";
223
+ }
224
+ if (!phecdaNamespace.has(namespace)) throw new Error(`namespace "${namespace}" doesn't exist`);
225
+ const serverPhecda = phecdaNamespace.get(namespace);
226
+ if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
227
+ else return serverPhecda;
228
+ }
229
+ _chunkRLFCI3RGjs.__name.call(void 0, useS, "useS");
230
+ function getMetaFromInstance(instance, tag, name) {
231
+ const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
232
+ const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
233
+ const ctxs = baseMeta.ctxs;
234
+ return propertyKeys.filter((i) => typeof instance[i] === "function").map((i) => {
235
+ const meta = _phecdacore.getMergedMeta.call(void 0, instance, i);
236
+ const metaData = {
237
+ ...meta,
238
+ name,
239
+ tag,
240
+ func: i
241
+ };
242
+ if (baseMeta.controller) {
243
+ if (typeof tag !== "string") _chunkRLFCI3RGjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
244
+ metaData.controller = baseMeta.controller;
245
+ metaData[baseMeta.controller] = {
246
+ ...baseMeta[baseMeta.controller],
247
+ ...meta[baseMeta.controller]
248
+ };
249
+ const params = _phecdacore.getMetaParams.call(void 0, instance, i).map((item) => _phecdacore.getMergedMeta.call(void 0, instance, i, item));
250
+ params.forEach((item, index) => {
251
+ if (!item.pipe) item.pipe = meta.pipe || baseMeta.pipe;
252
+ if (!item.define) item.define = {};
253
+ item.index = index;
254
+ });
255
+ metaData.ctxs = ctxs;
256
+ metaData.params = params;
257
+ metaData.filter = meta.filter || baseMeta.filter;
258
+ metaData.define = {
259
+ ...baseMeta.define,
260
+ ...meta.define
261
+ };
262
+ for (const item of [
263
+ "addons",
264
+ "guards"
265
+ ]) {
266
+ const set = new Set(baseMeta[item]);
267
+ if (meta[item]) {
268
+ meta[item].forEach((part) => {
269
+ set.delete(part);
270
+ set.add(part);
271
+ });
272
+ }
273
+ metaData[item] = [
274
+ ...set
275
+ ];
276
+ }
277
+ }
278
+ return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
279
+ });
280
+ }
281
+ _chunkRLFCI3RGjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
282
+ function deepFreeze(object) {
283
+ Object.freeze(object);
284
+ Object.getOwnPropertyNames(object).forEach((prop) => {
285
+ if (object[prop] !== null && (typeof object[prop] === "object" || typeof object[prop] === "function") && !Object.isFrozen(object[prop])) deepFreeze(object[prop]);
286
+ });
287
+ return object;
288
+ }
289
+ _chunkRLFCI3RGjs.__name.call(void 0, deepFreeze, "deepFreeze");
290
+ function getParamTypes(Model, key) {
291
+ const paramTypes = Reflect.getMetadata("design:paramtypes", Model, key);
292
+ if (typeof paramTypes === "function") return paramTypes();
293
+ else return paramTypes;
294
+ }
295
+ _chunkRLFCI3RGjs.__name.call(void 0, getParamTypes, "getParamTypes");
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+ exports.Meta = Meta; exports.emitter = emitter; exports.defaultServerInject = defaultServerInject; exports.phecdaNamespace = phecdaNamespace; exports.ServerPhecda = ServerPhecda; exports.Factory = Factory; exports.useS = useS;
306
+ //# sourceMappingURL=chunk-KRUOHWFR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["d:\\myproject\\phecda\\packages\\server\\dist\\chunk-KRUOHWFR.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACA;AACA,IAAI,KAAK,EAAE,MAAM;AACjB,EAAE,OAAO;AACT,IAAI,qCAAM,IAAK,EAAE,MAAM,CAAC;AACxB,EAAE;AACF,EAAE;AACF,EAAE;AACF,EAAE,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE;AAChC,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI;AACpB,IAAI,IAAI,CAAC,WAAW,EAAE,UAAU;AAChC,EAAE;AACF,CAAC;AACD;AACA;AACA,4BAAyB;AACzB,gFAAiC;AACjC,yCAA+H;AAC/H,4EAAyB;AACzB,IAAI,MAAM,EAAE,6BAAK,wBAAyB,CAAC;AAC3C,IAAI,QAAQ,EAAE,IAAI,qBAAY,CAAC,CAAC;AAChC,SAAS,mBAAmB,CAAC,EAAE;AAC/B,EAAE,GAAG,CAAC,CAAC,mCAAS,SAAU,CAAC,EAAE;AAC7B,IAAI,mCAAS,SAAU,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EA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,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,UAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,UAAA;AACA,QAAA;AACA,UAAA;AACA,UAAA;AACA,YAAA;AACA,cAAA;AACA,YAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,UAAA;AACA,YAAA;AACA,YAAA;AACA,UAAA;AACA,QAAA;AACA,QAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"D:\\myproject\\phecda\\packages\\server\\dist\\chunk-KRUOHWFR.js","sourcesContent":[null]}
@@ -3,12 +3,13 @@
3
3
 
4
4
 
5
5
 
6
- var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.js');
6
+
7
+ var _chunkRLFCI3RGjs = require('./chunk-RLFCI3RG.js');
7
8
 
8
9
  // src/meta.ts
9
10
  var Meta = class {
10
11
  static {
11
- _chunk5RBTN33Ajs.__name.call(void 0, this, "Meta");
12
+ _chunkRLFCI3RGjs.__name.call(void 0, this, "Meta");
12
13
  }
13
14
 
14
15
 
@@ -37,11 +38,11 @@ function defaultServerInject() {
37
38
  });
38
39
  }
39
40
  }
40
- _chunk5RBTN33Ajs.__name.call(void 0, defaultServerInject, "defaultServerInject");
41
+ _chunkRLFCI3RGjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
41
42
  var phecdaNamespace = /* @__PURE__ */ new Map();
42
43
  var ServerPhecda = (_class = class {
43
44
  static {
44
- _chunk5RBTN33Ajs.__name.call(void 0, this, "ServerPhecda");
45
+ _chunkRLFCI3RGjs.__name.call(void 0, this, "ServerPhecda");
45
46
  }
46
47
  __init() {this.moduleMap = /* @__PURE__ */ new Map()}
47
48
  __init2() {this.meta = []}
@@ -53,7 +54,7 @@ var ServerPhecda = (_class = class {
53
54
 
54
55
  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
56
  defaultServerInject();
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
+ const { namespace = "default", parseModule = /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
57
58
  phecdaNamespace.set(namespace, this);
58
59
  this.parseMeta = parseMeta;
59
60
  this.parseModule = parseModule;
@@ -63,17 +64,20 @@ var ServerPhecda = (_class = class {
63
64
  for (const model of models) await this.buildDepModule(model);
64
65
  this.hmr();
65
66
  this.generateCode().then(() => {
66
- if (_chunk5RBTN33Ajs.IS_ONLY_GENERATE) process.exit(4);
67
+ if (_chunkRLFCI3RGjs.IS_ONLY_GENERATE) {
68
+ _chunkRLFCI3RGjs.log.call(void 0, "Only generate code");
69
+ process.exit(_chunkRLFCI3RGjs.PS_EXIT_CODE.EXIT);
70
+ }
67
71
  });
68
72
  }
69
- __init6() {this.generateCode = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, async () => {
73
+ __init6() {this.generateCode = /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, async () => {
70
74
  return Promise.all(this.generators.map((generator) => {
71
75
  debug(`generate "${generator.name}" code to ${generator.path}`);
72
76
  return generator.output(this.meta);
73
77
  }));
74
78
  }, "generateCode")}
75
79
  hmr() {
76
- _chunk5RBTN33Ajs.HMR.call(void 0, async (oldModels, newModels) => {
80
+ _chunkRLFCI3RGjs.HMR.call(void 0, async (oldModels, newModels) => {
77
81
  debug("reload models ");
78
82
  await this.replace(oldModels, newModels);
79
83
  this.generateCode();
@@ -146,7 +150,7 @@ var ServerPhecda = (_class = class {
146
150
  if (this.moduleMap.has(tag)) {
147
151
  module = this.moduleMap.get(tag);
148
152
  if (!module) {
149
- _chunk5RBTN33Ajs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
153
+ _chunkRLFCI3RGjs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
150
154
  return {
151
155
  module: this.createProxyModule(tag),
152
156
  tag
@@ -154,8 +158,8 @@ var ServerPhecda = (_class = class {
154
158
  }
155
159
  if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
156
160
  this.modelSet.add(Model);
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
+ if (module instanceof Model) _chunkRLFCI3RGjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
162
+ else _chunkRLFCI3RGjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
159
163
  }
160
164
  return {
161
165
  module,
@@ -178,7 +182,7 @@ var ServerPhecda = (_class = class {
178
182
  }
179
183
  this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter((item) => !!item));
180
184
  debug(`init module "${String(tag)}"`);
181
- if (!_chunk5RBTN33Ajs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
185
+ if (!_chunkRLFCI3RGjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
182
186
  debug(`add module "${String(tag)}"`);
183
187
  this.moduleMap.set(tag, module);
184
188
  this.modelMap.set(module, Model);
@@ -237,7 +241,7 @@ async function Factory(models, opts = {}) {
237
241
  await phecda.start(models);
238
242
  return phecda;
239
243
  }
240
- _chunk5RBTN33Ajs.__name.call(void 0, Factory, "Factory");
244
+ _chunkRLFCI3RGjs.__name.call(void 0, Factory, "Factory");
241
245
  function useS(nsOrModel, namespace) {
242
246
  if (!nsOrModel) {
243
247
  namespace = "default";
@@ -250,7 +254,7 @@ function useS(nsOrModel, namespace) {
250
254
  if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
251
255
  else return serverPhecda;
252
256
  }
253
- _chunk5RBTN33Ajs.__name.call(void 0, useS, "useS");
257
+ _chunkRLFCI3RGjs.__name.call(void 0, useS, "useS");
254
258
  function getMetaFromInstance(instance, tag, name) {
255
259
  const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
256
260
  const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
@@ -264,7 +268,7 @@ function getMetaFromInstance(instance, tag, name) {
264
268
  func: i
265
269
  };
266
270
  if (baseMeta.controller) {
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");
271
+ if (typeof tag !== "string") _chunkRLFCI3RGjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
268
272
  metaData.controller = baseMeta.controller;
269
273
  metaData[baseMeta.controller] = {
270
274
  ...baseMeta[baseMeta.controller],
@@ -302,7 +306,7 @@ function getMetaFromInstance(instance, tag, name) {
302
306
  return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
303
307
  });
304
308
  }
305
- _chunk5RBTN33Ajs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
309
+ _chunkRLFCI3RGjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
306
310
  function deepFreeze(object) {
307
311
  Object.freeze(object);
308
312
  Object.getOwnPropertyNames(object).forEach((prop) => {
@@ -310,13 +314,13 @@ function deepFreeze(object) {
310
314
  });
311
315
  return object;
312
316
  }
313
- _chunk5RBTN33Ajs.__name.call(void 0, deepFreeze, "deepFreeze");
317
+ _chunkRLFCI3RGjs.__name.call(void 0, deepFreeze, "deepFreeze");
314
318
  function getParamTypes(Model, key) {
315
319
  const paramTypes = Reflect.getMetadata("design:paramtypes", Model, key);
316
320
  if (typeof paramTypes === "function") return paramTypes();
317
321
  else return paramTypes;
318
322
  }
319
- _chunk5RBTN33Ajs.__name.call(void 0, getParamTypes, "getParamTypes");
323
+ _chunkRLFCI3RGjs.__name.call(void 0, getParamTypes, "getParamTypes");
320
324
 
321
325
 
322
326
 
@@ -327,3 +331,4 @@ _chunk5RBTN33Ajs.__name.call(void 0, getParamTypes, "getParamTypes");
327
331
 
328
332
 
329
333
  exports.Meta = Meta; exports.emitter = emitter; exports.defaultServerInject = defaultServerInject; exports.phecdaNamespace = phecdaNamespace; exports.ServerPhecda = ServerPhecda; exports.Factory = Factory; exports.useS = useS;
334
+ //# sourceMappingURL=chunk-KUGU3UGO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["d:\\myproject\\phecda\\packages\\server\\dist\\chunk-KUGU3UGO.js"],"names":[],"mappings":"A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A,QAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,UAAA;AACA,QAAA;AACA,UAAA;AACA,UAAA;AACA,YAAA;AACA,cAAA;AACA,YAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,UAAA;AACA,YAAA;AACA,YAAA;AACA,UAAA;AACA,QAAA;AACA,QAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"D:\\myproject\\phecda\\packages\\server\\dist\\chunk-KUGU3UGO.js","sourcesContent":[null]}
@@ -2,11 +2,12 @@ import {
2
2
  ERROR_SYMBOL,
3
3
  HMR,
4
4
  IS_DEV,
5
+ IS_PURE,
5
6
  IS_STRICT,
6
7
  LOG_LEVEL,
7
8
  __name,
8
9
  log
9
- } from "./chunk-FXTJ3BJ6.mjs";
10
+ } from "./chunk-MDPW6WGF.mjs";
10
11
 
11
12
  // src/helper.ts
12
13
  import pc2 from "picocolors";
@@ -232,16 +233,13 @@ var Context = class _Context {
232
233
  static guardRecord = {};
233
234
  static addonRecord = {};
234
235
  ctx;
235
- canGetCtx;
236
+ // protected canGetCtx = true
236
237
  constructor(data) {
237
238
  this.data = data;
238
- this.canGetCtx = true;
239
239
  if (IS_DEV)
240
240
  data._context = this;
241
- const that = this;
242
241
  this.ctx = new Proxy(data, {
243
242
  get(target, p) {
244
- if (IS_DEV && !that.canGetCtx) throw new FrameworkException("ctx must be obtained within the same request cycle in controller");
245
243
  if (!(p in target)) log(`attribute "${p}" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, "warn", data.tag);
246
244
  return target[p];
247
245
  },
@@ -292,13 +290,7 @@ ${pc.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
292
290
  reflect: paramsType[item.index],
293
291
  ...item
294
292
  }, this.ctx)));
295
- if (IS_DEV) {
296
- Promise.resolve().then(() => {
297
- this.canGetCtx = false;
298
- });
299
- }
300
293
  res = await instance[func](...args);
301
- this.canGetCtx = true;
302
294
  } else {
303
295
  let nextPromise;
304
296
  async function next() {
@@ -385,13 +377,6 @@ function resolveDep(ret, key) {
385
377
  }
386
378
  __name(resolveDep, "resolveDep");
387
379
 
388
- // src/rpc/helper.ts
389
- import { hostname } from "os";
390
- function genClientQueue(key) {
391
- return `PS-${key ? `${key}-` : ""}${hostname()}-${process.pid}`;
392
- }
393
- __name(genClientQueue, "genClientQueue");
394
-
395
380
  // src/decorators/helper.ts
396
381
  function shallowClone(obj) {
397
382
  return {
@@ -425,6 +410,7 @@ function createControllerMetaMap(meta, filter) {
425
410
  }
426
411
  __name(createControllerMetaMap, "createControllerMetaMap");
427
412
  function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
413
+ if (IS_PURE) return;
428
414
  const addonSet = /* @__PURE__ */ new Set();
429
415
  const guardSet = /* @__PURE__ */ new Set();
430
416
  const pipeSet = /* @__PURE__ */ new Set();
@@ -443,6 +429,8 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
443
429
  guardSet.add(item);
444
430
  });
445
431
  meta.forEach(({ data }) => {
432
+ if (!data.controller) return;
433
+ if (typeof data.tag !== "string") warningSet.add(`Tag of controller "${data.name}" should be a string`);
446
434
  if (data.controller !== controller) {
447
435
  if (data[controller]) warningSet.add(`Should use ${controller} controller to decorate class "${data.name}"`);
448
436
  return;
@@ -467,7 +455,10 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
467
455
  ...filterSet
468
456
  ].filter((i) => !Context.filterRecord[i]);
469
457
  function exit() {
470
- if (IS_STRICT) process.exit(5);
458
+ if (IS_STRICT) {
459
+ log("Does not meet strict mode requirements", "error");
460
+ process.exit(1);
461
+ }
471
462
  }
472
463
  __name(exit, "exit");
473
464
  if (missAddons.length) {
@@ -534,10 +525,10 @@ export {
534
525
  addGuard,
535
526
  addAddon,
536
527
  resolveDep,
537
- genClientQueue,
538
528
  shallowClone,
539
529
  mergeObject,
540
530
  createControllerMetaMap,
541
531
  detectAopDep,
542
532
  joinUrl
543
533
  };
534
+ //# sourceMappingURL=chunk-LBH4RXQQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helper.ts","../src/context.ts","../src/pipe.ts","../src/exception/base.ts","../src/exception/undefine.ts","../src/exception/validate.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/exception/timer.ts","../src/exception/worker.ts","../src/filter.ts","../src/http/helper.ts","../src/decorators/helper.ts"],"sourcesContent":["// help you build custom framework or decorator\r\n\r\nimport pc from 'picocolors'\r\nimport { log } from './utils'\r\nimport { Context } from './context'\r\nimport { HMR } from './hmr'\r\nimport { ControllerMeta, Meta } from './meta'\r\nimport { IS_PURE, IS_STRICT } from './common'\r\n\r\nexport * from './hmr'\r\nexport * from './http/helper'\r\nexport * from './decorators/helper'\r\n\r\nexport function createControllerMetaMap(meta: Meta[], filter: (meta: Meta) => boolean | void) {\r\n const metaMap = new Map<string, Record<string, ControllerMeta>>()\r\n\r\n function handleMeta() {\r\n metaMap.clear()\r\n for (const item of meta) {\r\n const { tag, func } = item.data\r\n if (!filter(item))\r\n continue\r\n\r\n if (metaMap.has(tag))\r\n metaMap.get(tag)![func] = item as ControllerMeta\r\n\r\n else\r\n metaMap.set(tag, { [func]: item as ControllerMeta })\r\n }\r\n }\r\n\r\n handleMeta()\r\n HMR(handleMeta)\r\n\r\n return metaMap\r\n}\r\n\r\n// detect whether addon/filter/pipe/guard/intercept is injected\r\nexport function detectAopDep(meta: Meta[], { guards, addons }: {\r\n guards?: string[]\r\n addons?: string[]\r\n\r\n} = {}, controller = 'http') {\r\n if (IS_PURE)\r\n return\r\n\r\n const addonSet = new Set<string>()\r\n const guardSet = new Set<string>()\r\n const pipeSet = new Set<string>()\r\n const filterSet = new Set<string>()\r\n const warningSet = new Set<string>()\r\n function handleMeta() {\r\n addonSet.clear()\r\n guardSet.clear()\r\n pipeSet.clear()\r\n filterSet.clear()\r\n warningSet.clear()\r\n\r\n addons?.forEach((item) => {\r\n addonSet.add(item)\r\n })\r\n guards?.forEach((item) => {\r\n guardSet.add(item)\r\n });\r\n\r\n (meta as ControllerMeta[]).forEach(({ data }) => {\r\n if (!data.controller)\r\n return\r\n\r\n if (typeof data.tag !== 'string')\r\n warningSet.add(`Tag of controller \"${data.name}\" should be a string`)\r\n\r\n // @todo func of meta on controller should be string\r\n\r\n if (data.controller !== controller) {\r\n if (data[controller])\r\n warningSet.add(`Should use ${controller} controller to decorate class \"${data.name}\"`)\r\n\r\n return\r\n }\r\n if (data.filter)\r\n filterSet.add(data.filter)\r\n\r\n data.guards.forEach(i => guardSet.add(i))\r\n data.addons.forEach(i => addonSet.add(i))\r\n data.params.forEach((i) => {\r\n if (i.pipe)\r\n pipeSet.add(i.pipe)\r\n })\r\n })\r\n const missAddons = [...addonSet].filter(i => !Context.addonRecord[i])\r\n const missGuards = [...guardSet].filter(i => !Context.guardRecord[i])\r\n const missPipes = [...pipeSet].filter(i => !Context.pipeRecord[i])\r\n const missFilters = [...filterSet].filter(i => !Context.filterRecord[i])\r\n\r\n function exit() {\r\n if (IS_STRICT) {\r\n log('Does not meet strict mode requirements', 'error')\r\n process.exit(1)\r\n }\r\n }\r\n\r\n if (missAddons.length) {\r\n log(`${pc.white(`Addon [${missAddons.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n if (missGuards.length) {\r\n log(`${pc.magenta(`Guard [${missGuards.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n if (missPipes.length) {\r\n log(`${pc.blue(`Pipe [${missPipes.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n if (missFilters.length) {\r\n log(`${pc.red(`Filter [${missFilters.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n\r\n warningSet.forEach(warn => log(warn, 'warn'))\r\n if (warningSet.size)\r\n exit()\r\n }\r\n\r\n handleMeta()\r\n HMR(handleMeta)\r\n return {\r\n addonSet,\r\n guardSet,\r\n pipeSet,\r\n filterSet,\r\n }\r\n}\r\n\r\nexport function joinUrl(base: string, ...paths: string[]) {\r\n const joinedPath = [base, ...paths].filter(p => p).map(path => path.replace(/(^\\/)/g, '')).join('/')\r\n return `/${joinedPath}`\r\n}\r\n","import Debug from 'debug'\r\nimport pc from 'picocolors'\r\nimport { defaultPipe } from './pipe'\r\nimport { defaultFilter } from './filter'\r\nimport type { BaseCtx, DefaultOptions } from './types'\r\nimport { IS_DEV } from './common'\r\nimport { type Exception } from './exception'\r\nimport { resolveDep } from './helper'\r\nimport { ControllerMeta } from './meta'\r\nimport { log } from './utils'\r\n\r\nconst debug = Debug('phecda-server(Context)')\r\n\r\nexport interface AOP {\r\n guards: GuardType[]\r\n pipe: PipeType[]\r\n filter: FilterType\r\n}\r\n\r\nexport interface PipeArg { arg: any; pipe?: string; key: string; type: string; index: number; reflect: any; define: Record<string, any> }\r\nexport type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any\r\nexport type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>\r\nexport type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any\r\n\r\nexport class Context<Ctx extends BaseCtx> {\r\n method: string\r\n params: string[]\r\n\r\n static filterRecord: Record<PropertyKey, FilterType> = {\r\n default: defaultFilter,\r\n }\r\n\r\n static pipeRecord: Record<PropertyKey, PipeType> = {\r\n default: defaultPipe,\r\n }\r\n\r\n static guardRecord: Record<PropertyKey, {\r\n value: GuardType\r\n priority: number\r\n }> = {}\r\n\r\n static addonRecord: Record<PropertyKey, {\r\n value: (router: any, framework: string) => any\r\n priority: number\r\n\r\n }> = {}\r\n\r\n ctx: Ctx\r\n\r\n // protected canGetCtx = true\r\n\r\n constructor(public data: Ctx) {\r\n if (IS_DEV)\r\n // @ts-expect-error work for debug\r\n data._context = this\r\n\r\n // const that = this\r\n\r\n this.ctx = new Proxy(data, {\r\n get(target, p) {\r\n // if (IS_DEV && !that.canGetCtx)// only detect in dev\r\n // throw new FrameworkException('ctx must be obtained within the same request cycle in controller')\r\n\r\n if (!(p in target))\r\n log(`attribute \"${p as string}\" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, 'warn', data.tag)\r\n\r\n return target[p as any]\r\n },\r\n set(target: any, p, newValue) {\r\n target[p] = newValue\r\n return true\r\n },\r\n })\r\n }\r\n\r\n static getAop(meta: ControllerMeta, opts: DefaultOptions) {\r\n const { globalGuards = [], globalFilter = 'default', globalPipe = 'default' } = opts\r\n const {\r\n data: {\r\n guards, filter,\r\n params, tag, func,\r\n },\r\n } = meta\r\n\r\n const resolved = {\r\n guards: [...globalGuards, ...guards],\r\n pipe: params.map(item => item.pipe || globalPipe),\r\n filter: filter || globalFilter,\r\n\r\n }\r\n\r\n if (process.env.DEBUG) {\r\n const { guards, pipe, filter } = resolved\r\n debug(`func \"${tag}-${func}\" aop: \\n${pc.magenta(`Guard ${guards.join('->')}[${guards.filter(g => g in this.guardRecord).join('->')}]`)}\\n${pc.blue(`Pipe ${pipe.join('-')}[${pipe.map(p => p in this.pipeRecord ? p : 'default').join('-')}]`)}\\n${pc.red(`Filter ${filter}[${filter || 'default'}]`)}`)\r\n }\r\n return {\r\n guards: this.getGuards(resolved.guards),\r\n pipe: this.getPipe(resolved.pipe),\r\n filter: this.getFilter(resolved.filter),\r\n }\r\n }\r\n\r\n public async run<ResponseData = any, ReturnErr = any>({\r\n guards, filter, pipe,\r\n }: {\r\n guards: GuardType[]\r\n filter: FilterType\r\n pipe: PipeType[]\r\n }, successCb: (data: any) => ResponseData, failCb: (err: any) => ReturnErr) {\r\n const { meta, moduleMap } = this.data\r\n const {\r\n paramsType,\r\n data: {\r\n ctxs,\r\n tag,\r\n params,\r\n func,\r\n },\r\n } = meta\r\n\r\n try {\r\n // let current = 0\r\n let res: any\r\n const nextHandler = (index: number) => {\r\n return async () => {\r\n if (index === guards.length) {\r\n const instance = moduleMap.get(tag)!\r\n if (ctxs) {\r\n ctxs.forEach(ctx => instance[ctx] = this.ctx,\r\n )\r\n }\r\n const args = await Promise.all(\r\n params.map((item, i) =>\r\n pipe[i]({ arg: resolveDep(this.data[item.type], item.key), reflect: paramsType[item.index], ...item }, this.ctx),\r\n ),\r\n )\r\n\r\n // if (IS_DEV) {\r\n // Promise.resolve().then(() => {\r\n // this.canGetCtx = false\r\n // })\r\n // }\r\n res = await instance[func](...args)\r\n // this.canGetCtx = true\r\n }\r\n else {\r\n let nextPromise: Promise<any> | undefined\r\n async function next() {\r\n return nextPromise = nextHandler(index + 1)().then((ret) => {\r\n if (ret !== undefined) {\r\n debug(`The ${index + 1}th guard on \"${tag}-${func}\" rewrite the response value.`)\r\n res = ret\r\n }\r\n\r\n return res\r\n })\r\n }\r\n\r\n const ret = await guards[index](this.ctx, next)\r\n\r\n if (ret !== undefined) {\r\n res = ret\r\n }\r\n else {\r\n if (!nextPromise)\r\n await next()\r\n\r\n else\r\n await nextPromise\r\n }\r\n }\r\n }\r\n }\r\n await nextHandler(0)()\r\n\r\n return successCb(res)\r\n }\r\n catch (e) {\r\n const err = await filter(e, this.ctx)\r\n return failCb(err)\r\n }\r\n }\r\n\r\n static getPipe(pipe: string[]) {\r\n return pipe.map((pipe) => {\r\n return Context.pipeRecord[pipe] || Context.pipeRecord.default\r\n })\r\n }\r\n\r\n static getFilter(filter = 'default') {\r\n return Context.filterRecord[filter] || Context.filterRecord.default\r\n }\r\n\r\n static getGuards(guards: string[]) {\r\n const ret: { value: GuardType; priority: number }[] = []\r\n for (const guard of new Set(guards)) {\r\n if (guard in Context.guardRecord)\r\n ret.push(Context.guardRecord[guard])\r\n }\r\n\r\n return ret.sort((a, b) => b.priority - a.priority).map(item => item.value)\r\n }\r\n\r\n static applyAddons(addons: string[], router: any, framework: string) {\r\n const ret: {\r\n value: (router: any, framework: string) => any\r\n priority: number\r\n }[] = []\r\n for (const a of new Set(addons)) {\r\n if (a in Context.addonRecord)\r\n ret.push(Context.addonRecord[a])\r\n }\r\n\r\n ret.sort((a, b) => b.priority - a.priority).forEach(item => item.value(router, framework))\r\n\r\n // await Context.addonRecord[a](router, framework)\r\n }\r\n}\r\n\r\nexport function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>) {\r\n if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe)\r\n debug(`overwrite Pipe \"${String(key)}\"`, 'warn')\r\n Context.pipeRecord[key] = pipe\r\n}\r\n\r\nexport function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>) {\r\n if (Context.filterRecord[key] && Context.filterRecord[key] !== filter)\r\n debug(`overwrite Filter \"${String(key)}\"`, 'warn')\r\n Context.filterRecord[key] = filter\r\n}\r\n\r\nexport function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority = 0) {\r\n if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard)\r\n debug(`overwrite Guard \"${String(key)}\"`, 'warn')\r\n\r\n Context.guardRecord[key] = {\r\n value: guard,\r\n priority,\r\n }\r\n}\r\nexport function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority = 0) {\r\n if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon)\r\n debug(`overwrite Addon \"${String(key)}\"`, 'warn')\r\n Context.addonRecord[key] = {\r\n value: addon,\r\n priority,\r\n }\r\n}\r\n","// import { isPhecda, } from 'phecda-core'\r\n// import { ValidateException } from './exception/validate'\r\n\r\nimport type { PipeType } from './context'\r\n\r\nexport const defaultPipe: PipeType = ({ arg }) => {\n // if (['query', 'params'].includes(type) && reflect !== String) {\r\n // if ([Object, Array].includes(reflect)) {\r\n // return JSON.parse(arg)\r\n // }\r\n // if ([Number, Boolean].includes(reflect)) {\r\n // return reflect(arg)\r\n // }\r\n // }\r\n return arg\r\n}\r\n","import { ERROR_SYMBOL } from '../common'\r\n\r\nexport class Exception extends Error {\r\n constructor(public message: string, public status = 0, public description = 'Exception') {\r\n super(message)\r\n }\r\n\r\n get data() {\r\n return { message: this.message, description: this.description, status: this.status, [ERROR_SYMBOL]: true }\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class UndefinedException extends Exception {\r\n constructor(message: string) {\r\n super(message, 500, 'Undefined error')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ValidateException extends Exception {\r\n constructor(message: string) {\r\n super(message, 400, 'Validate exception')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ForbiddenException extends Exception {\r\n constructor(message: string) {\r\n super(message, 403, 'Forbidden resource')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class BadRequestException extends Exception {\r\n constructor(message: string) {\r\n super(message, 400, 'Bad Request')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class NotFoundException extends Exception {\r\n constructor(message: string) {\r\n super(message, 404, 'Not Found')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ConflictException extends Exception {\r\n constructor(message: string) {\r\n super(message, 409, 'Conflict')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class BadGatewayException extends Exception {\r\n constructor(message: string) {\r\n super(message, 502, 'Bad Gatrway')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class InvalidInputException extends Exception {\r\n constructor(message: string) {\r\n super(message, 502, 'Invalid Input')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class UnsupportedMediaTypeException extends Exception {\r\n constructor(message: string) {\r\n super(message, 415, 'Unsupported Media Type')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class PayloadLargeException extends Exception {\r\n constructor(message: string) {\r\n super(message, 413, 'Payload Too Large')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class TimeoutException extends Exception {\r\n constructor(message: string) {\r\n super(message, 408, 'Request Timeout',\r\n )\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class UnauthorizedException extends Exception {\r\n constructor(message: string) {\r\n super(message, 401, 'Unauthorized')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ServiceUnavailableException extends Exception {\r\n constructor(message: string) {\r\n super(message, 503, 'Service Unavailable')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class FrameworkException extends Exception {\r\n constructor(message: string) {\r\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\r\n }\r\n}\r\n","import { Exception } from './base'\r\nexport class TimerException extends Exception {\r\n constructor(message: string) {\r\n super(message, 0, 'Timer Error')\r\n }\r\n}\r\n","import { Exception } from './base'\r\nexport class WorkerException extends Exception {\r\n constructor(message: string) {\r\n super(message, 0, 'Worker Error')\r\n }\r\n}\r\n","import { LOG_LEVEL } from './common'\r\nimport { Exception, UndefinedException } from './exception'\r\nimport { log } from './utils'\r\nimport type { FilterType } from './context'\r\n\r\nexport const defaultFilter: FilterType = (e) => {\r\n if (!(e instanceof Exception)) {\r\n log(e.message, 'error')\r\n if (LOG_LEVEL <= 0)\r\n console.error(e.stack)\r\n\r\n e = new UndefinedException(e.message || e)\r\n }\r\n else {\r\n log(`[${e.constructor.name}] ${e.message}`, 'error')\r\n if (LOG_LEVEL <= 0)\r\n console.error(e.stack)\r\n }\r\n\r\n return e.data\r\n}\r\n","export function resolveDep(ret: any, key: string) {\r\n if (key)\r\n return ret?.[key]\r\n return ret\r\n}\r\n\r\n// export function argToReq(params: ControllerMetaData['params'], args: any[], headers: Record<string, any>) {\r\n// const req = {\r\n// body: {},\r\n// query: {},\r\n// params: {},\r\n// headers,\r\n// } as any\r\n\r\n// params.forEach((param) => {\r\n// if (param.key)\r\n// req[param.type][param.key] = args[param.index]\r\n\r\n// else\r\n// req[param.type] = args[param.index]\r\n// })\r\n\r\n// return req\r\n// }\r\n","export function shallowClone(obj: any) {\r\n return { ...obj }\r\n}\r\nexport function mergeObject(...args: any[]) {\r\n return Object.assign({}, ...args)\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAEA,OAAOA,SAAQ;;;ACFf,OAAOC,WAAW;AAClB,OAAOC,QAAQ;;;ACIR,IAAMC,cAAwB,wBAAC,EAAEC,IAAG,MAAE;AAS3C,SAAOA;AACT,GAVqC;;;ACH9B,IAAMC,YAAN,cAAwBC,MAAAA;EAF/B,OAE+BA;;;;;;EAC7BC,YAAmBC,SAAwBC,SAAS,GAAUC,cAAc,aAAa;AACvF,UAAMF,OAAAA,GAAAA,KADWA,UAAAA,SAAAA,KAAwBC,SAAAA,QAAAA,KAAmBC,cAAAA;EAE9D;EAEA,IAAIC,OAAO;AACT,WAAO;MAAEH,SAAS,KAAKA;MAASE,aAAa,KAAKA;MAAaD,QAAQ,KAAKA;MAAQ,CAACG,YAAAA,GAAe;IAAK;EAC3G;AACF;;;ACRO,IAAMC,qBAAN,cAAiCC,UAAAA;EAFxC,OAEwCA;;;EACtCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,iBAAA;EACtB;AACF;;;ACJO,IAAMC,oBAAN,cAAgCC,UAAAA;EAFvC,OAEuCA;;;EACrCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;;;ACJO,IAAMC,qBAAN,cAAiCC,UAAAA;EAFxC,OAEwCA;;;EACtCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;;;ACJO,IAAMC,sBAAN,cAAkCC,UAAAA;EAFzC,OAEyCA;;;EACvCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,aAAA;EACtB;AACF;;;ACJO,IAAMC,oBAAN,cAAgC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ACrC,QAAI3B,WAAW4B,KACbZ,MAAAA;EACJ;AAvESpC;AAyETA,aAAAA;AACAS,MAAIT,UAAAA;AACJ,SAAO;IACLe;IACAE;IACAC;IACAC;EACF;AACF;AA9FgBT;AAgGT,SAASuC,QAAQC,SAAiBC,OAAe;AACtD,QAAMC,aAAa;IAACF;OAASC;IAAOtD,OAAOwD,CAAAA,MAAKA,CAAAA,EAAGC,IAAIC,CAAAA,SAAQA,KAAKC,QAAQ,UAAU,EAAA,CAAA,EAAKb,KAAK,GAAA;AAChG,SAAO,IAAIS,UAAAA;AACb;AAHgBH;","names":["pc","Debug","pc","defaultPipe","arg","Exception","Error","constructor","message","status","description","data","ERROR_SYMBOL","UndefinedException","Exception","constructor","message","ValidateException","Exception","constructor","message","ForbiddenException","Exception","constructor","message","BadRequestException","Exception","constructor","message","NotFoundException","Exception","constructor","message","ConflictException","Exception","constructor","message","BadGatewayException","Exception","constructor","message","InvalidInputException","Exception","constructor","message","UnsupportedMediaTypeException","Exception","constructor","message","PayloadLargeException","Exception","constructor","message","TimeoutException","Exception","constructor","message","UnauthorizedException","Exception","constructor","message","ServiceUnavailableException","Exception","constructor","message","FrameworkException","Exception","constructor","message","TimerException","Exception","constructor","message","WorkerException","Exception","constructor","message","defaultFilter","e","Exception","log","message","LOG_LEVEL","console","error","stack","UndefinedException","constructor","name","data","debug","Debug","Context","method","params","filterRecord","default","defaultFilter","pipeRecord","defaultPipe","guardRecord","addonRecord","ctx","constructor","data","IS_DEV","_context","Proxy","get","target","p","log","tag","set","newValue","getAop","meta","opts","globalGuards","globalFilter","globalPipe","guards","filter","func","resolved","pipe","map","item","process","env","DEBUG","pc","magenta","join","g","blue","red","getGuards","getPipe","getFilter","run","successCb","failCb","moduleMap","paramsType","ctxs","res","nextHandler","index","length","instance","forEach","args","Promise","all","i","arg","resolveDep","type","key","reflect","nextPromise","next","then","ret","undefined","e","err","guard","Set","push","sort","a","b","priority","value","applyAddons","addons","router","framework","addPipe","String","addFilter","addGuard","addAddon","addon","resolveDep","ret","key","shallowClone","obj","mergeObject","args","Object","assign","createControllerMetaMap","meta","filter","metaMap","Map","handleMeta","clear","item","tag","func","data","has","get","set","HMR","detectAopDep","guards","addons","controller","IS_PURE","addonSet","Set","guardSet","pipeSet","filterSet","warningSet","forEach","add","name","i","params","pipe","missAddons","Context","addonRecord","missGuards","guardRecord","missPipes","pipeRecord","missFilters","filterRecord","exit","IS_STRICT","log","process","length","pc","white","join","magenta","blue","red","warn","size","joinUrl","base","paths","joinedPath","p","map","path","replace"]}