phecda-server 7.0.0-alpha.4 → 7.0.0-alpha.6
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/dist/{chunk-MMG73S64.mjs → chunk-3C7Z3IJN.mjs} +1 -1
- package/dist/chunk-62FBZWGW.js +106 -0
- package/dist/{chunk-A53KNKY4.mjs → chunk-HTY3H33L.mjs} +33 -3
- package/dist/{chunk-KUGFI6SC.mjs → chunk-ICI5KUDX.mjs} +1 -1
- package/dist/{chunk-6EBEME3I.js → chunk-JF4YU32E.js} +51 -51
- package/dist/chunk-KSDE5G57.mjs +106 -0
- package/dist/{chunk-QCOBXM7F.js → chunk-UKRQVTEY.js} +24 -24
- package/dist/{chunk-PKSWGQLW.js → chunk-WYI2F7LD.js} +50 -20
- package/dist/{core-C1kHRqU9.d.ts → core-CzElxZoF.d.ts} +2 -1
- package/dist/{core-CSiaRU7r.d.mts → core-DU7gQKSk.d.mts} +2 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +40 -40
- package/dist/http/elysia/index.mjs +3 -3
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +37 -37
- package/dist/http/express/index.mjs +2 -2
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +38 -38
- package/dist/http/fastify/index.mjs +3 -3
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +37 -37
- package/dist/http/h3/index.mjs +2 -2
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +35 -35
- package/dist/http/hono/index.mjs +2 -2
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +35 -35
- package/dist/http/hyper-express/index.mjs +2 -2
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +37 -37
- package/dist/http/koa/index.mjs +2 -2
- package/dist/index.d.mts +19 -15
- package/dist/index.d.ts +19 -15
- package/dist/index.js +43 -38
- package/dist/index.mjs +9 -4
- package/dist/{meta-D1M85Hef.d.ts → meta-BTnLXuCa.d.mts} +2 -1
- package/dist/{meta-D1M85Hef.d.mts → meta-BTnLXuCa.d.ts} +2 -1
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +2 -2
- 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-ee1FBodH.d.ts → types--E-OCZhC.d.ts} +1 -1
- package/dist/{types-JMhFVp-Z.d.mts → types-BYqBeqrs.d.mts} +1 -1
- package/dist/{types-wbHHC93P.d.mts → types-BxlzVoRv.d.mts} +1 -1
- package/dist/{types-C9Remkup.d.ts → types-CbfaGkPA.d.ts} +1 -1
- package/package.json +1 -1
- package/register/loader.mjs +2 -1
- package/register/utils.mjs +56 -56
- package/dist/chunk-QD3QR3NW.mjs +0 -73
- package/dist/chunk-RQSQRZL4.js +0 -73
package/dist/rpc/redis/index.js
CHANGED
|
@@ -4,29 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk62FBZWGWjs = require('../../chunk-62FBZWGW.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/redis/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
14
|
var debug = _debug2.default.call(void 0, "phecda-server/redis");
|
|
15
15
|
function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
16
16
|
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkJF4YU32Ejs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
18
18
|
const { controller, rpc, func, tag } = meta2.data;
|
|
19
19
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
20
20
|
debug(`register method "${func}" in module "${tag}"`);
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
_chunkJF4YU32Ejs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
28
|
const existQueue = /* @__PURE__ */ new Set();
|
|
29
|
-
|
|
29
|
+
_chunkJF4YU32Ejs.Context.applyAddons(globalAddons, {
|
|
30
30
|
pub,
|
|
31
31
|
sub
|
|
32
32
|
}, "redis");
|
|
@@ -45,7 +45,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
_chunk62FBZWGWjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
49
49
|
sub.on("message", async (channel, msg) => {
|
|
50
50
|
if (!existQueue.has(channel)) return;
|
|
51
51
|
if (msg) {
|
|
@@ -55,12 +55,12 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
55
55
|
if (_ps !== 1) return;
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
57
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
58
|
-
const aop =
|
|
58
|
+
const aop = _chunkJF4YU32Ejs.Context.getAop(meta2, {
|
|
59
59
|
globalFilter,
|
|
60
60
|
globalGuards,
|
|
61
61
|
globalPipe
|
|
62
62
|
});
|
|
63
|
-
const context = new (0,
|
|
63
|
+
const context = new (0, _chunkJF4YU32Ejs.Context)({
|
|
64
64
|
type: "redis",
|
|
65
65
|
category: "rpc",
|
|
66
66
|
moduleMap,
|
|
@@ -92,12 +92,12 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
subscribeQueues();
|
|
95
|
-
|
|
95
|
+
_chunkJF4YU32Ejs.HMR.call(void 0, async () => {
|
|
96
96
|
for (const queue of existQueue) await sub.unsubscribe(queue);
|
|
97
97
|
subscribeQueues();
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
_chunk62FBZWGWjs.__name.call(void 0, bind, "bind");
|
|
101
101
|
|
|
102
102
|
// src/rpc/redis/client.ts
|
|
103
103
|
var _events = require('events'); var _events2 = _interopRequireDefault(_events);
|
|
@@ -106,7 +106,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
106
106
|
let eventId = 1;
|
|
107
107
|
let eventCount = 0;
|
|
108
108
|
const emitter = new (0, _events2.default)();
|
|
109
|
-
const clientQueue =
|
|
109
|
+
const clientQueue = _chunkJF4YU32Ejs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
110
110
|
await sub.subscribe(clientQueue);
|
|
111
111
|
for (const i in controllers) {
|
|
112
112
|
ret[i] = new Proxy(new controllers[i](), {
|
|
@@ -146,7 +146,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
146
146
|
if (error) reject(data);
|
|
147
147
|
else resolve(data);
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
_chunk62FBZWGWjs.__name.call(void 0, listener, "listener");
|
|
150
150
|
eventCount++;
|
|
151
151
|
emitter.once(id, listener);
|
|
152
152
|
});
|
|
@@ -162,7 +162,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
162
162
|
});
|
|
163
163
|
return ret;
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
_chunk62FBZWGWjs.__name.call(void 0, createClient, "createClient");
|
|
166
166
|
|
|
167
167
|
|
|
168
168
|
|
package/dist/rpc/redis/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-3C7Z3IJN.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-KSDE5G57.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/redis/bind.ts
|
|
13
13
|
import Debug from "debug";
|
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-DU7gQKSk.mjs';
|
|
6
|
+
import { P as PickFunc } from './meta-BTnLXuCa.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-CzElxZoF.js';
|
|
6
|
+
import { P as PickFunc } from './meta-BTnLXuCa.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 _chunkWYI2F7LDjs = require('./chunk-WYI2F7LD.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk62FBZWGWjs = require('./chunk-62FBZWGW.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 _chunkWYI2F7LDjs.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
|
+
_chunk62FBZWGWjs.__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
|
+
_chunk62FBZWGWjs.__name.call(void 0, module, "module");
|
|
63
63
|
Agent.module = module;
|
|
64
64
|
return Agent;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
_chunk62FBZWGWjs.__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 BaseContext } from './meta-
|
|
2
|
+
import { D as DefaultOptions, B as BaseContext } from './meta-BTnLXuCa.js';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { D as DefaultOptions, B as BaseContext } from './meta-
|
|
2
|
+
import { D as DefaultOptions, B as BaseContext } from './meta-BTnLXuCa.mjs';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
package/package.json
CHANGED
package/register/loader.mjs
CHANGED
|
@@ -314,7 +314,8 @@ export const load = async (url, context, nextLoad) => {
|
|
|
314
314
|
|
|
315
315
|
const code
|
|
316
316
|
= typeof source === 'string' ? source : Buffer.from(source).toString()
|
|
317
|
-
const compiled = await compile(code, url)
|
|
317
|
+
const compiled = (await compile(code, url)).replace(/_ts_metadata\(\"design:paramtypes\"\,/g, '_ts_metadata("design:paramtypes",()=>')// handle cycle
|
|
318
|
+
|
|
318
319
|
if (unimportRet) {
|
|
319
320
|
const { injectImports } = unimportRet
|
|
320
321
|
return {
|
package/register/utils.mjs
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { basename } from 'path'
|
|
2
|
-
import { transform } from '@swc-node/core'
|
|
3
|
-
const injectInlineSourceMap = ({ code, map }) => {
|
|
4
|
-
if (map) {
|
|
5
|
-
const base64Map = Buffer.from(map, 'utf8').toString('base64')
|
|
6
|
-
const sourceMapContent = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`
|
|
7
|
-
return `${code}\n${sourceMapContent}`
|
|
8
|
-
}
|
|
9
|
-
return code
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function compile(sourcecode, filename) {
|
|
13
|
-
if (filename.endsWith('.d.ts'))
|
|
14
|
-
return ''
|
|
15
|
-
|
|
16
|
-
const { code, map } = await transform(sourcecode, filename, {
|
|
17
|
-
sourcemap: true,
|
|
18
|
-
module: 'es6',
|
|
19
|
-
emitDecoratorMetadata: true,
|
|
20
|
-
experimentalDecorators: true,
|
|
21
|
-
esModuleInterop: false,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
return injectInlineSourceMap({ code, map })
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function genUnImportRet(opts) {
|
|
28
|
-
try {
|
|
29
|
-
const psExports = Object.keys(await import('../dist/index.mjs'))
|
|
30
|
-
const { createUnimport } = await import('unimport')
|
|
31
|
-
return createUnimport({
|
|
32
|
-
...opts,
|
|
33
|
-
imports: psExports
|
|
34
|
-
.map((k) => {
|
|
35
|
-
return { name: k, from: 'phecda-server' }
|
|
36
|
-
})
|
|
37
|
-
.concat(opts.imports || []),
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
return false
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function handleClassTypes(input) {
|
|
46
|
-
return input.replace(/const\s+(\w+)\s*:\s*typeof\s+import\(['"](.+)['"]\)\['(\w+)'\]/g, (_, n, p, e) => {
|
|
47
|
-
// TestController in test.controller
|
|
48
|
-
if (p.startsWith('./') && (basename(p).replace('.', '').toLowerCase() === e.toLowerCase()))
|
|
49
|
-
return `${_}\n type ${n} = InstanceType<typeof import('${p}')['${e}']>`
|
|
50
|
-
|
|
51
|
-
return _
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
export function slash(str) {
|
|
55
|
-
return str.replace(/\\/g, '/')
|
|
56
|
-
}
|
|
1
|
+
import { basename } from 'path'
|
|
2
|
+
import { transform } from '@swc-node/core'
|
|
3
|
+
const injectInlineSourceMap = ({ code, map }) => {
|
|
4
|
+
if (map) {
|
|
5
|
+
const base64Map = Buffer.from(map, 'utf8').toString('base64')
|
|
6
|
+
const sourceMapContent = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`
|
|
7
|
+
return `${code}\n${sourceMapContent}`
|
|
8
|
+
}
|
|
9
|
+
return code
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function compile(sourcecode, filename) {
|
|
13
|
+
if (filename.endsWith('.d.ts'))
|
|
14
|
+
return ''
|
|
15
|
+
|
|
16
|
+
const { code, map } = await transform(sourcecode, filename, {
|
|
17
|
+
sourcemap: true,
|
|
18
|
+
module: 'es6',
|
|
19
|
+
emitDecoratorMetadata: true,
|
|
20
|
+
experimentalDecorators: true,
|
|
21
|
+
esModuleInterop: false,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
return injectInlineSourceMap({ code, map })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function genUnImportRet(opts) {
|
|
28
|
+
try {
|
|
29
|
+
const psExports = Object.keys(await import('../dist/index.mjs'))
|
|
30
|
+
const { createUnimport } = await import('unimport')
|
|
31
|
+
return createUnimport({
|
|
32
|
+
...opts,
|
|
33
|
+
imports: psExports
|
|
34
|
+
.map((k) => {
|
|
35
|
+
return { name: k, from: 'phecda-server' }
|
|
36
|
+
})
|
|
37
|
+
.concat(opts.imports || []),
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
return false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function handleClassTypes(input) {
|
|
46
|
+
return input.replace(/const\s+(\w+)\s*:\s*typeof\s+import\(['"](.+)['"]\)\['(\w+)'\]/g, (_, n, p, e) => {
|
|
47
|
+
// TestController in test.controller
|
|
48
|
+
if (p.startsWith('./') && (basename(p).replace('.', '').toLowerCase() === e.toLowerCase()))
|
|
49
|
+
return `${_}\n type ${n} = InstanceType<typeof import('${p}')['${e}']>`
|
|
50
|
+
|
|
51
|
+
return _
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
export function slash(str) {
|
|
55
|
+
return str.replace(/\\/g, '/')
|
|
56
|
+
}
|
package/dist/chunk-QD3QR3NW.mjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/common.ts
|
|
5
|
-
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
-
var IS_HMR = process.env.NODE_ENV === "development";
|
|
7
|
-
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
|
-
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
|
-
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
-
var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
11
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
|
|
12
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
|
|
13
|
-
return PS_EXIT_CODE2;
|
|
14
|
-
}({});
|
|
15
|
-
|
|
16
|
-
// src/utils.ts
|
|
17
|
-
import pc from "picocolors";
|
|
18
|
-
import { Mixin } from "ts-mixer";
|
|
19
|
-
var time;
|
|
20
|
-
var internalLogger;
|
|
21
|
-
function setLogger(logger) {
|
|
22
|
-
internalLogger = logger;
|
|
23
|
-
}
|
|
24
|
-
__name(setLogger, "setLogger");
|
|
25
|
-
function getLogger() {
|
|
26
|
-
return internalLogger;
|
|
27
|
-
}
|
|
28
|
-
__name(getLogger, "getLogger");
|
|
29
|
-
function log(msg, level = "log") {
|
|
30
|
-
if (internalLogger) internalLogger[level](msg);
|
|
31
|
-
const logLevel = {
|
|
32
|
-
debug: -1,
|
|
33
|
-
info: 0,
|
|
34
|
-
log: 1,
|
|
35
|
-
warn: 2,
|
|
36
|
-
error: 3
|
|
37
|
-
}[level];
|
|
38
|
-
if (logLevel < LOG_LEVEL) return;
|
|
39
|
-
const color = {
|
|
40
|
-
debug: "bgMagenta",
|
|
41
|
-
error: "red",
|
|
42
|
-
info: "gray",
|
|
43
|
-
warn: "yellow",
|
|
44
|
-
log: "green"
|
|
45
|
-
}[level];
|
|
46
|
-
const date = /* @__PURE__ */ new Date();
|
|
47
|
-
const current = Date.now();
|
|
48
|
-
const interval = time && current - time ? `+${current - time}` : "";
|
|
49
|
-
time = current;
|
|
50
|
-
console[level](`${pc.magenta("[phecda-server]")} ${pc.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${pc[color](msg)} ${pc.gray(interval)}`);
|
|
51
|
-
}
|
|
52
|
-
__name(log, "log");
|
|
53
|
-
function runMiddleware(ctx, middleware) {
|
|
54
|
-
return new Promise((resolve) => {
|
|
55
|
-
middleware(ctx.getRequest(), ctx.getResponse(), resolve);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
__name(runMiddleware, "runMiddleware");
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
__name,
|
|
62
|
-
ERROR_SYMBOL,
|
|
63
|
-
IS_HMR,
|
|
64
|
-
IS_ONLY_GENERATE,
|
|
65
|
-
IS_STRICT,
|
|
66
|
-
LOG_LEVEL,
|
|
67
|
-
PS_EXIT_CODE,
|
|
68
|
-
setLogger,
|
|
69
|
-
getLogger,
|
|
70
|
-
log,
|
|
71
|
-
runMiddleware,
|
|
72
|
-
Mixin
|
|
73
|
-
};
|
package/dist/chunk-RQSQRZL4.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/common.ts
|
|
5
|
-
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
-
var IS_HMR = process.env.NODE_ENV === "development";
|
|
7
|
-
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
|
-
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
|
-
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
-
var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
11
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
|
|
12
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
|
|
13
|
-
return PS_EXIT_CODE2;
|
|
14
|
-
}({});
|
|
15
|
-
|
|
16
|
-
// src/utils.ts
|
|
17
|
-
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
18
|
-
var _tsmixer = require('ts-mixer');
|
|
19
|
-
var time;
|
|
20
|
-
var internalLogger;
|
|
21
|
-
function setLogger(logger) {
|
|
22
|
-
internalLogger = logger;
|
|
23
|
-
}
|
|
24
|
-
__name(setLogger, "setLogger");
|
|
25
|
-
function getLogger() {
|
|
26
|
-
return internalLogger;
|
|
27
|
-
}
|
|
28
|
-
__name(getLogger, "getLogger");
|
|
29
|
-
function log(msg, level = "log") {
|
|
30
|
-
if (internalLogger) internalLogger[level](msg);
|
|
31
|
-
const logLevel = {
|
|
32
|
-
debug: -1,
|
|
33
|
-
info: 0,
|
|
34
|
-
log: 1,
|
|
35
|
-
warn: 2,
|
|
36
|
-
error: 3
|
|
37
|
-
}[level];
|
|
38
|
-
if (logLevel < LOG_LEVEL) return;
|
|
39
|
-
const color = {
|
|
40
|
-
debug: "bgMagenta",
|
|
41
|
-
error: "red",
|
|
42
|
-
info: "gray",
|
|
43
|
-
warn: "yellow",
|
|
44
|
-
log: "green"
|
|
45
|
-
}[level];
|
|
46
|
-
const date = /* @__PURE__ */ new Date();
|
|
47
|
-
const current = Date.now();
|
|
48
|
-
const interval = time && current - time ? `+${current - time}` : "";
|
|
49
|
-
time = current;
|
|
50
|
-
console[level](`${_picocolors2.default.magenta("[phecda-server]")} ${_picocolors2.default.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${_picocolors2.default[color](msg)} ${_picocolors2.default.gray(interval)}`);
|
|
51
|
-
}
|
|
52
|
-
__name(log, "log");
|
|
53
|
-
function runMiddleware(ctx, middleware) {
|
|
54
|
-
return new Promise((resolve) => {
|
|
55
|
-
middleware(ctx.getRequest(), ctx.getResponse(), resolve);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
__name(runMiddleware, "runMiddleware");
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_HMR = IS_HMR; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; exports.LOG_LEVEL = LOG_LEVEL; exports.PS_EXIT_CODE = PS_EXIT_CODE; exports.setLogger = setLogger; exports.getLogger = getLogger; exports.log = log; exports.runMiddleware = runMiddleware; exports.Mixin = _tsmixer.Mixin;
|