phecda-server 7.0.0-alpha.0 → 7.0.0-alpha.10
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.
- package/assets/ps.json +24 -24
- package/assets/schema.json +55 -55
- package/bin/cli.mjs +31 -18
- package/dist/chunk-4LLLQOMF.js +152 -0
- package/dist/{chunk-BGXSMOLX.js → chunk-6OQ2SB5W.js} +138 -70
- package/dist/{chunk-SW5IKE5H.js → chunk-G7JFKM2M.js} +136 -89
- package/dist/{chunk-MBCHNDAY.js → chunk-KCPBITYZ.js} +24 -24
- package/dist/{chunk-HMVLXNV3.mjs → chunk-MUI6MTUO.mjs} +1 -1
- package/dist/chunk-NQ55PA2X.mjs +152 -0
- package/dist/{chunk-5622RBNB.mjs → chunk-YCES6ABN.mjs} +125 -57
- package/dist/{chunk-P75VKZJY.mjs → chunk-Z7NAAE4M.mjs} +94 -47
- package/dist/{core-BIcUwV18.d.mts → core-CUTbX_IS.d.ts} +5 -3
- package/dist/{core-CYwEPfN4.d.ts → core-DIfgUKIU.d.mts} +5 -3
- package/dist/helper.d.mts +8 -6
- package/dist/helper.d.ts +8 -6
- package/dist/helper.js +8 -3
- package/dist/helper.mjs +10 -5
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +43 -44
- package/dist/http/elysia/index.mjs +9 -10
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +40 -41
- package/dist/http/express/index.mjs +9 -10
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +41 -42
- package/dist/http/fastify/index.mjs +9 -10
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +41 -42
- package/dist/http/h3/index.mjs +9 -10
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +37 -39
- package/dist/http/hono/index.mjs +5 -7
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +38 -39
- package/dist/http/hyper-express/index.mjs +8 -9
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +40 -41
- package/dist/http/koa/index.mjs +9 -10
- package/dist/index.d.mts +46 -40
- package/dist/index.d.ts +46 -40
- package/dist/index.js +48 -42
- package/dist/index.mjs +21 -15
- package/dist/{meta-BXKLFTgG.d.mts → meta-CR-D39hQ.d.mts} +7 -5
- package/dist/{meta-BXKLFTgG.d.ts → meta-CR-D39hQ.d.ts} +7 -5
- package/dist/rpc/bullmq/index.d.mts +5 -5
- package/dist/rpc/bullmq/index.d.ts +5 -5
- package/dist/rpc/bullmq/index.js +15 -14
- package/dist/rpc/bullmq/index.mjs +4 -3
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +15 -14
- package/dist/rpc/kafka/index.mjs +3 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +14 -13
- package/dist/rpc/nats/index.mjs +4 -3
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +16 -15
- package/dist/rpc/rabbitmq/index.mjs +4 -3
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +14 -13
- package/dist/rpc/redis/index.mjs +4 -3
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-h40T3cRG.d.mts → types-BF1TDbFV.d.ts} +4 -3
- package/dist/{types-BtbL49Zs.d.mts → types-DYRu0vic.d.ts} +4 -3
- package/dist/{types-VFzEM7LL.d.ts → types-DYviSl5B.d.mts} +4 -3
- package/dist/{types-m3IEDKjP.d.ts → types-DqH1qA-q.d.mts} +4 -3
- package/package.json +8 -5
- package/register/export.mjs +30 -0
- package/register/index.mjs +50 -40
- package/register/loader.mjs +384 -367
- package/register/utils.mjs +60 -56
- package/dist/chunk-J5CFUN4V.js +0 -73
- package/dist/chunk-WHJ5FALK.mjs +0 -73
package/dist/test.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory } from './core-
|
|
6
|
-
import { P as PickFunc } from './meta-
|
|
5
|
+
import { F as Factory } from './core-DIfgUKIU.mjs';
|
|
6
|
+
import { P as PickFunc } from './meta-CR-D39hQ.mjs';
|
|
7
7
|
|
|
8
8
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
9
9
|
get<C extends T[number]>(Model: C): InstanceType<C>;
|
|
@@ -11,7 +11,7 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
|
11
11
|
type SuperTestRequest<T> = {
|
|
12
12
|
[K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
|
|
13
13
|
};
|
|
14
|
-
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "
|
|
14
|
+
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "use" | "on" | "set" | "query" | "type" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "key" | "pfx" | "cert"> & {
|
|
15
15
|
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
16
16
|
}>;
|
|
17
17
|
|
package/dist/test.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory } from './core-
|
|
6
|
-
import { P as PickFunc } from './meta-
|
|
5
|
+
import { F as Factory } from './core-CUTbX_IS.js';
|
|
6
|
+
import { P as PickFunc } from './meta-CR-D39hQ.js';
|
|
7
7
|
|
|
8
8
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
9
9
|
get<C extends T[number]>(Model: C): InstanceType<C>;
|
|
@@ -11,7 +11,7 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
|
11
11
|
type SuperTestRequest<T> = {
|
|
12
12
|
[K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
|
|
13
13
|
};
|
|
14
|
-
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "
|
|
14
|
+
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "use" | "on" | "set" | "query" | "type" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "key" | "pfx" | "cert"> & {
|
|
15
15
|
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
16
16
|
}>;
|
|
17
17
|
|
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
|
|
3
|
+
var _chunk6OQ2SB5Wjs = require('./chunk-6OQ2SB5W.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.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
|
|
11
|
+
const { moduleMap, modelMap } = await _chunk6OQ2SB5Wjs.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
|
-
|
|
22
|
+
_chunk4LLLQOMFjs.__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
|
-
|
|
62
|
+
_chunk4LLLQOMFjs.__name.call(void 0, module, "module");
|
|
63
63
|
Agent.module = module;
|
|
64
64
|
return Agent;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
_chunk4LLLQOMFjs.__name.call(void 0, TestHttp, "TestHttp");
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
package/dist/test.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { D as DefaultOptions, B as
|
|
2
|
+
import { D as DefaultOptions, B as BaseCtx } from './meta-CR-D39hQ.js';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -15,13 +15,14 @@ interface HttpOptions extends DefaultOptions {
|
|
|
15
15
|
*/
|
|
16
16
|
dynamic?: boolean;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface HttpCtx extends BaseCtx {
|
|
19
19
|
parallel?: true;
|
|
20
20
|
index?: number;
|
|
21
21
|
query: Record<string, any>;
|
|
22
22
|
params: Record<string, string>;
|
|
23
23
|
body: Record<string, any>;
|
|
24
24
|
headers: IncomingHttpHeaders;
|
|
25
|
+
category: 'http';
|
|
25
26
|
redirect: (url: string, status?: number) => void;
|
|
26
27
|
getCookie(key: string): string | undefined;
|
|
27
28
|
setCookie(key: string, value: string, opts?: CookieSerializeOptions): void;
|
|
@@ -44,4 +45,4 @@ interface CookieSerializeOptions {
|
|
|
44
45
|
partitioned?: boolean;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
export type { CookieSerializeOptions as C,
|
|
48
|
+
export type { CookieSerializeOptions as C, HttpCtx as H, HttpOptions as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DefaultOptions, B as
|
|
1
|
+
import { D as DefaultOptions, B as BaseCtx } from './meta-CR-D39hQ.js';
|
|
2
2
|
|
|
3
3
|
interface RpcServerOptions extends DefaultOptions {
|
|
4
4
|
defaultQueue?: string;
|
|
@@ -8,11 +8,12 @@ interface RpcClientOptions {
|
|
|
8
8
|
timeout?: number;
|
|
9
9
|
max?: number;
|
|
10
10
|
}
|
|
11
|
-
interface
|
|
11
|
+
interface RpcCtx extends BaseCtx {
|
|
12
12
|
args: any[];
|
|
13
13
|
id: string;
|
|
14
14
|
queue: string;
|
|
15
15
|
isEvent?: boolean;
|
|
16
|
+
category: 'rpc';
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export type {
|
|
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
|
|
2
|
+
import { D as DefaultOptions, B as BaseCtx } from './meta-CR-D39hQ.mjs';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -15,13 +15,14 @@ interface HttpOptions extends DefaultOptions {
|
|
|
15
15
|
*/
|
|
16
16
|
dynamic?: boolean;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface HttpCtx extends BaseCtx {
|
|
19
19
|
parallel?: true;
|
|
20
20
|
index?: number;
|
|
21
21
|
query: Record<string, any>;
|
|
22
22
|
params: Record<string, string>;
|
|
23
23
|
body: Record<string, any>;
|
|
24
24
|
headers: IncomingHttpHeaders;
|
|
25
|
+
category: 'http';
|
|
25
26
|
redirect: (url: string, status?: number) => void;
|
|
26
27
|
getCookie(key: string): string | undefined;
|
|
27
28
|
setCookie(key: string, value: string, opts?: CookieSerializeOptions): void;
|
|
@@ -44,4 +45,4 @@ interface CookieSerializeOptions {
|
|
|
44
45
|
partitioned?: boolean;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
export type { CookieSerializeOptions as C,
|
|
48
|
+
export type { CookieSerializeOptions as C, HttpCtx as H, HttpOptions as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DefaultOptions, B as
|
|
1
|
+
import { D as DefaultOptions, B as BaseCtx } from './meta-CR-D39hQ.mjs';
|
|
2
2
|
|
|
3
3
|
interface RpcServerOptions extends DefaultOptions {
|
|
4
4
|
defaultQueue?: string;
|
|
@@ -8,11 +8,12 @@ interface RpcClientOptions {
|
|
|
8
8
|
timeout?: number;
|
|
9
9
|
max?: number;
|
|
10
10
|
}
|
|
11
|
-
interface
|
|
11
|
+
interface RpcCtx extends BaseCtx {
|
|
12
12
|
args: any[];
|
|
13
13
|
id: string;
|
|
14
14
|
queue: string;
|
|
15
15
|
isEvent?: boolean;
|
|
16
|
+
category: 'rpc';
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export type {
|
|
19
|
+
export type { RpcCtx as R, RpcServerOptions as a, RpcClientOptions as b };
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.10",
|
|
4
4
|
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
|
|
5
5
|
"author": "fgsreally",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "https://github.com/fgsreally/phecda/tree/main/packages/server",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"server",
|
|
10
|
+
"http",
|
|
10
11
|
"IOC",
|
|
11
12
|
"rpc",
|
|
12
|
-
"types-
|
|
13
|
+
"types-safe"
|
|
13
14
|
],
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
@@ -129,7 +130,8 @@
|
|
|
129
130
|
}
|
|
130
131
|
},
|
|
131
132
|
"bin": {
|
|
132
|
-
"phecda": "bin/cli.mjs"
|
|
133
|
+
"phecda": "bin/cli.mjs",
|
|
134
|
+
"phecda-server": "bin/cli.mjs"
|
|
133
135
|
},
|
|
134
136
|
"files": [
|
|
135
137
|
"dist",
|
|
@@ -143,11 +145,11 @@
|
|
|
143
145
|
"chokidar": "^3.5.3",
|
|
144
146
|
"debug": "^4.3.4",
|
|
145
147
|
"fs-extra": "^11.2.0",
|
|
146
|
-
"h3": "^1.12.0",
|
|
147
148
|
"picocolors": "^1.0.0",
|
|
148
149
|
"reflect-metadata": "^0.1.13",
|
|
149
150
|
"ts-mixer": "^6.0.4",
|
|
150
|
-
"
|
|
151
|
+
"unconfig": "^0.6.0",
|
|
152
|
+
"phecda-core": "4.1.0-alpha.0"
|
|
151
153
|
},
|
|
152
154
|
"devDependencies": {
|
|
153
155
|
"@koa/router": "^12.0.1",
|
|
@@ -164,6 +166,7 @@
|
|
|
164
166
|
"elysia": "^1.0.17",
|
|
165
167
|
"express": "^4.18.2",
|
|
166
168
|
"fastify": "^4.25.1",
|
|
169
|
+
"h3": "^1.12.0",
|
|
167
170
|
"hono": "^4.3.4",
|
|
168
171
|
"hyper-express": "^6.15.2",
|
|
169
172
|
"ioredis": "^5.3.2",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default ['Addon', 'Arg', 'Assign', 'BadGatewayException', 'BadRequestException',
|
|
2
|
+
'Base', 'Body', 'Clear',
|
|
3
|
+
'ConflictException', 'Controller',
|
|
4
|
+
'Ctx', 'CustomResponse',
|
|
5
|
+
'Delete',
|
|
6
|
+
'Define',
|
|
7
|
+
'ERROR_SYMBOL',
|
|
8
|
+
'Effect', 'Empty', 'Err', 'Exception', 'Expose', 'Factory', 'Filter', 'ForbiddenException',
|
|
9
|
+
'FrameworkException',
|
|
10
|
+
'Generator', 'Get', 'Global', 'Guard', 'HTTPGenerator', 'Head', 'Header', 'HttpBase',
|
|
11
|
+
'If', 'Init', 'Inject', 'Injectable',
|
|
12
|
+
'InvalidInputException', 'Isolate',
|
|
13
|
+
'Mixin',
|
|
14
|
+
'NotFoundException', 'PAddon', 'PExtension', 'PFilter', 'PGuard',
|
|
15
|
+
'PPipe', 'Param', 'Patch', 'PayloadLargeException', 'Pipe', 'Pipeline', 'Post',
|
|
16
|
+
'Provide', 'Put', 'Query', 'Queue', 'RPCGenerator', 'Route',
|
|
17
|
+
'Rpc', 'RpcBase', 'Search', 'ServerBase', 'ServerPhecda', 'ServiceUnavailableException', 'Storage',
|
|
18
|
+
'Tag', 'TimeoutException', 'TimerException', 'UnauthorizedException', 'UndefinedException',
|
|
19
|
+
'Unique', 'Unmount', 'UnsupportedMediaTypeException', 'ValidateException',
|
|
20
|
+
'Watcher', 'WorkerException',
|
|
21
|
+
'addAddon', 'addDecoToClass',
|
|
22
|
+
'addFilter', 'addGuard', 'addPipe', 'emitter',
|
|
23
|
+
'getMergedMeta',
|
|
24
|
+
'getMeta', 'getMetaKey', 'getMetaParams', 'getOwnMeta', 'getOwnMetaKey', 'getOwnMetaParams',
|
|
25
|
+
'getTag',
|
|
26
|
+
'isPhecda', 'log', 'phecdaNamespace', 'runMiddleware',
|
|
27
|
+
'setInject',
|
|
28
|
+
'setLogger',
|
|
29
|
+
'setMeta',
|
|
30
|
+
'useS', 'wait']
|
package/register/index.mjs
CHANGED
|
@@ -1,40 +1,50 @@
|
|
|
1
|
-
import { register } from 'node:module'
|
|
2
|
-
import { MessageChannel } from 'node:worker_threads'
|
|
3
|
-
import { log } from '../dist/index.mjs'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (type === '
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import { register } from 'node:module'
|
|
2
|
+
import { MessageChannel } from 'node:worker_threads'
|
|
3
|
+
import { isPhecda, log } from '../dist/index.mjs'
|
|
4
|
+
import { RELAUNCH, RELOAD } from '../dist/helper.mjs'
|
|
5
|
+
const { port1, port2 } = new MessageChannel()
|
|
6
|
+
|
|
7
|
+
register('./loader.mjs', {
|
|
8
|
+
parentURL: import.meta.url,
|
|
9
|
+
data: { port: port2 },
|
|
10
|
+
transferList: [port2],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
let isRunning = true
|
|
14
|
+
|
|
15
|
+
const fileModelMap = new Map()
|
|
16
|
+
|
|
17
|
+
port1.on('message', async (data) => {
|
|
18
|
+
const { type, files } = JSON.parse(data)
|
|
19
|
+
|
|
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)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
process.on('uncaughtException', (err) => {
|
|
40
|
+
log('Uncaught Exception:', 'error')
|
|
41
|
+
isRunning = false
|
|
42
|
+
console.error(err)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
process.on('unhandledRejection', (err) => {
|
|
46
|
+
log('Unhandled Promise Rejection:', 'error')
|
|
47
|
+
isRunning = false
|
|
48
|
+
|
|
49
|
+
console.error(err)
|
|
50
|
+
})
|