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
package/dist/test.js CHANGED
@@ -1,14 +1,14 @@
1
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; } }
2
2
 
3
- var _chunkXSMUJ77Ajs = require('./chunk-XSMUJ77A.js');
3
+ var _chunkKJUD2BKEjs = require('./chunk-KJUD2BKE.js');
4
4
 
5
5
 
6
- var _chunkM5HGFUCVjs = require('./chunk-M5HGFUCV.js');
6
+ var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.js');
7
7
 
8
8
  // src/test.ts
9
9
  var _phecdacore = require('phecda-core');
10
10
  async function TestFactory(...Modules) {
11
- const { moduleMap, modelMap } = await _chunkXSMUJ77Ajs.Factory.call(void 0, Modules);
11
+ const { moduleMap, modelMap } = await _chunkKJUD2BKEjs.Factory.call(void 0, Modules);
12
12
  return {
13
13
  get(Model) {
14
14
  const tag = _phecdacore.getTag.call(void 0, Model);
@@ -19,7 +19,7 @@ async function TestFactory(...Modules) {
19
19
  }
20
20
  };
21
21
  }
22
- _chunkM5HGFUCVjs.__name.call(void 0, TestFactory, "TestFactory");
22
+ _chunk5RBTN33Ajs.__name.call(void 0, TestFactory, "TestFactory");
23
23
  async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
24
24
  const { default: request, agent } = await Promise.resolve().then(() => _interopRequireWildcard(require("supertest")));
25
25
  const Agent = agent(app);
@@ -59,11 +59,11 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
59
59
  }
60
60
  });
61
61
  }
62
- _chunkM5HGFUCVjs.__name.call(void 0, module, "module");
62
+ _chunk5RBTN33Ajs.__name.call(void 0, module, "module");
63
63
  Agent.module = module;
64
64
  return Agent;
65
65
  }
66
- _chunkM5HGFUCVjs.__name.call(void 0, TestHttp, "TestHttp");
66
+ _chunk5RBTN33Ajs.__name.call(void 0, TestHttp, "TestHttp");
67
67
 
68
68
 
69
69
 
package/dist/test.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Factory
3
- } from "./chunk-RGSKKTHD.mjs";
3
+ } from "./chunk-7ZGYJ5OW.mjs";
4
4
  import {
5
5
  __name
6
- } from "./chunk-C5BVKEGW.mjs";
6
+ } from "./chunk-FXTJ3BJ6.mjs";
7
7
 
8
8
  // src/test.ts
9
9
  import { getTag } from "phecda-core";
@@ -1,4 +1,4 @@
1
- import { D as DefaultOptions, B as BaseContext } from './meta-BTnLXuCa.js';
1
+ import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.mjs';
2
2
 
3
3
  interface RpcServerOptions extends DefaultOptions {
4
4
  defaultQueue?: string;
@@ -8,7 +8,7 @@ interface RpcClientOptions {
8
8
  timeout?: number;
9
9
  max?: number;
10
10
  }
11
- interface RpcContext extends BaseContext {
11
+ interface RpcCtx extends BaseCtx {
12
12
  args: any[];
13
13
  id: string;
14
14
  queue: string;
@@ -16,4 +16,4 @@ interface RpcContext extends BaseContext {
16
16
  category: 'rpc';
17
17
  }
18
18
 
19
- export type { RpcContext as R, RpcServerOptions as a, RpcClientOptions as b };
19
+ export type { RpcCtx as R, RpcServerOptions as a, RpcClientOptions as b };
@@ -1,5 +1,5 @@
1
1
  import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
2
- import { D as DefaultOptions, B as BaseContext } from './meta-BTnLXuCa.js';
2
+ import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.js';
3
3
 
4
4
  interface HttpOptions extends DefaultOptions {
5
5
  /**
@@ -15,7 +15,7 @@ interface HttpOptions extends DefaultOptions {
15
15
  */
16
16
  dynamic?: boolean;
17
17
  }
18
- interface HttpContext extends BaseContext {
18
+ interface HttpCtx extends BaseCtx {
19
19
  parallel?: true;
20
20
  index?: number;
21
21
  query: Record<string, any>;
@@ -45,4 +45,4 @@ interface CookieSerializeOptions {
45
45
  partitioned?: boolean;
46
46
  }
47
47
 
48
- export type { CookieSerializeOptions as C, HttpContext as H, HttpOptions as a };
48
+ export type { CookieSerializeOptions as C, HttpCtx as H, HttpOptions as a };
@@ -1,5 +1,5 @@
1
1
  import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
2
- import { D as DefaultOptions, B as BaseContext } from './meta-BTnLXuCa.mjs';
2
+ import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.mjs';
3
3
 
4
4
  interface HttpOptions extends DefaultOptions {
5
5
  /**
@@ -15,7 +15,7 @@ interface HttpOptions extends DefaultOptions {
15
15
  */
16
16
  dynamic?: boolean;
17
17
  }
18
- interface HttpContext extends BaseContext {
18
+ interface HttpCtx extends BaseCtx {
19
19
  parallel?: true;
20
20
  index?: number;
21
21
  query: Record<string, any>;
@@ -45,4 +45,4 @@ interface CookieSerializeOptions {
45
45
  partitioned?: boolean;
46
46
  }
47
47
 
48
- export type { CookieSerializeOptions as C, HttpContext as H, HttpOptions as a };
48
+ export type { CookieSerializeOptions as C, HttpCtx as H, HttpOptions as a };
@@ -1,4 +1,4 @@
1
- import { D as DefaultOptions, B as BaseContext } from './meta-BTnLXuCa.mjs';
1
+ import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.js';
2
2
 
3
3
  interface RpcServerOptions extends DefaultOptions {
4
4
  defaultQueue?: string;
@@ -8,7 +8,7 @@ interface RpcClientOptions {
8
8
  timeout?: number;
9
9
  max?: number;
10
10
  }
11
- interface RpcContext extends BaseContext {
11
+ interface RpcCtx extends BaseCtx {
12
12
  args: any[];
13
13
  id: string;
14
14
  queue: string;
@@ -16,4 +16,4 @@ interface RpcContext extends BaseContext {
16
16
  category: 'rpc';
17
17
  }
18
18
 
19
- export type { RpcContext as R, RpcServerOptions as a, RpcClientOptions as b };
19
+ export type { RpcCtx as R, RpcServerOptions as a, RpcClientOptions as b };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-server",
3
- "version": "7.0.0-alpha.7",
3
+ "version": "7.0.0-alpha.9",
4
4
  "description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
5
5
  "author": "fgsreally",
6
6
  "license": "MIT",
@@ -129,7 +129,8 @@
129
129
  }
130
130
  },
131
131
  "bin": {
132
- "phecda": "bin/cli.mjs"
132
+ "phecda": "bin/cli.mjs",
133
+ "phecda-server": "bin/cli.mjs"
133
134
  },
134
135
  "files": [
135
136
  "dist",
@@ -1,7 +1,7 @@
1
1
  import { register } from 'node:module'
2
2
  import { MessageChannel } from 'node:worker_threads'
3
- import { log } from '../dist/index.mjs'
4
-
3
+ import { isPhecda, log } from '../dist/index.mjs'
4
+ import { RELAUNCH, RELOAD } from '../dist/helper.mjs'
5
5
  const { port1, port2 } = new MessageChannel()
6
6
 
7
7
  register('./loader.mjs', {
@@ -12,18 +12,27 @@ register('./loader.mjs', {
12
12
 
13
13
  let isRunning = true
14
14
 
15
+ const fileModelMap = new Map()
16
+
15
17
  port1.on('message', async (data) => {
16
18
  const { type, files } = JSON.parse(data)
17
19
 
18
- if (!isRunning || !globalThis.__PS_HMR__ || type === 'relaunch')
19
- return process.exit(2)// file change -> relaunch
20
-
21
- if (type === 'change') {
22
- log('reload module...')
23
-
24
- for (const cb of globalThis.__PS_HMR__) await cb(files)
25
-
26
- log('reload done')
20
+ if (!isRunning || type === 'relaunch')
21
+ return RELAUNCH()// file change -> relaunch
22
+
23
+ if (type === 'change' || type === 'init') {
24
+ if (!files.length)
25
+ return
26
+ const oldModels = []
27
+ const newModels = []
28
+ for (const file of files) {
29
+ oldModels.push(...fileModelMap.get(file) || [])
30
+ const models = Object.values(await import(file)).filter(isPhecda)
31
+ fileModelMap.set(file, models)
32
+ newModels.push(...models)
33
+ }
34
+ if (type === 'change')
35
+ return RELOAD(oldModels, newModels)
27
36
  }
28
37
  })
29
38
 
@@ -12,7 +12,7 @@ import { createRequire } from 'module'
12
12
  import { existsSync } from 'fs'
13
13
  import ts from 'typescript'
14
14
  import chokidar from 'chokidar'
15
- import { log } from '../dist/index.mjs'
15
+ import { IS_DEV, log } from '../dist/index.mjs'
16
16
  import { compile, genUnImportRet, handleClassTypes, slash } from './utils.mjs'
17
17
 
18
18
  let port
@@ -75,7 +75,7 @@ export async function initialize(data) {
75
75
  if (!config.paths)
76
76
  config.paths = {}
77
77
 
78
- if (!process.env.PS_HMR_BAN) {
78
+ if (IS_DEV) {
79
79
  chokidar.watch(configPath, { persistent: true }).on('change', () => {
80
80
  port.postMessage(
81
81
  JSON.stringify({
@@ -254,32 +254,17 @@ export const load = async (url, context, nextLoad) => {
254
254
  && !isLowVersion
255
255
  ) {
256
256
  watchFiles.add(url)
257
- // watch(
258
- // fileURLToPath(url),
259
- // debounce((type) => {
260
- // if (type === 'change') {
261
- // try {
262
- // const files = [...findTopScope(url, Date.now())].reverse()
263
-
264
- // port.postMessage(
265
- // JSON.stringify({
266
- // type: 'change',
267
- // files,
268
- // }),
269
- // )
270
- // }
271
- // catch (e) {
272
- // port.postMessage(
273
- // JSON.stringify({
274
- // type: 'relaunch',
275
- // }),
276
- // )
277
- // }
278
- // }
279
- // }),
280
- // )
281
-
282
- if (!process.env.PS_HMR_BAN) {
257
+
258
+ if (IS_DEV) {
259
+ if (isModuleFileUrl(url)) {
260
+ port.postMessage(
261
+ JSON.stringify({
262
+ type: 'init',
263
+ files: [fileURLToPath(url)],
264
+ }),
265
+ )
266
+ }
267
+
283
268
  chokidar.watch(fileURLToPath(url), { persistent: true }).on(
284
269
  'change',
285
270
  debounce(() => {