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.
- package/README.md +10 -10
- package/assets/schema.json +12 -9
- package/bin/cli.mjs +96 -37
- package/dist/chunk-5SUY5UVC.js +258 -0
- package/dist/chunk-5SUY5UVC.js.map +1 -0
- package/dist/{chunk-7ZGYJ5OW.mjs → chunk-6JAHCTOT.mjs} +7 -2
- package/dist/chunk-6JAHCTOT.mjs.map +1 -0
- package/dist/{chunk-V5EYXVJT.js → chunk-EDAWJVJ4.js} +42 -25
- package/dist/chunk-EDAWJVJ4.js.map +1 -0
- package/dist/{chunk-FX3LDQII.js → chunk-H7OCHDZT.js} +61 -70
- package/dist/chunk-H7OCHDZT.js.map +1 -0
- package/dist/chunk-KRUOHWFR.js +306 -0
- package/dist/chunk-KRUOHWFR.js.map +1 -0
- package/dist/{chunk-KJUD2BKE.js → chunk-KUGU3UGO.js} +23 -18
- package/dist/chunk-KUGU3UGO.js.map +1 -0
- package/dist/{chunk-CVPZWDXU.mjs → chunk-LBH4RXQQ.mjs} +11 -20
- package/dist/chunk-LBH4RXQQ.mjs.map +1 -0
- package/dist/{chunk-FXTJ3BJ6.mjs → chunk-MDPW6WGF.mjs} +10 -4
- package/dist/chunk-MDPW6WGF.mjs.map +1 -0
- package/dist/{chunk-5RBTN33A.js → chunk-RLFCI3RG.js} +11 -5
- package/dist/chunk-RLFCI3RG.js.map +1 -0
- package/dist/{chunk-ODVWOXVB.mjs → chunk-TTHYUNOT.mjs} +18 -1
- package/dist/chunk-TTHYUNOT.mjs.map +1 -0
- package/dist/chunk-VDOICQ2U.mjs +258 -0
- package/dist/chunk-VDOICQ2U.mjs.map +1 -0
- package/dist/chunk-WTJKTICN.mjs +306 -0
- package/dist/chunk-WTJKTICN.mjs.map +1 -0
- package/dist/{core-D_cz0tKa.d.ts → core-BOo3uGFX.d.ts} +2 -2
- package/dist/{core-BDkhrEyf.d.mts → core-CF45G79J.d.mts} +2 -2
- package/dist/core-DbqWh47p.d.mts +50 -0
- package/dist/core-Rq7BhPHE.d.ts +50 -0
- package/dist/helper.d.mts +3 -5
- package/dist/helper.d.ts +3 -5
- package/dist/helper.js +4 -5
- package/dist/helper.js.map +1 -0
- package/dist/helper.mjs +3 -4
- package/dist/helper.mjs.map +1 -0
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +42 -40
- package/dist/http/elysia/index.js.map +1 -0
- package/dist/http/elysia/index.mjs +5 -3
- package/dist/http/elysia/index.mjs.map +1 -0
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +39 -37
- package/dist/http/express/index.js.map +1 -0
- package/dist/http/express/index.mjs +4 -2
- package/dist/http/express/index.mjs.map +1 -0
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +40 -38
- package/dist/http/fastify/index.js.map +1 -0
- package/dist/http/fastify/index.mjs +5 -3
- package/dist/http/fastify/index.mjs.map +1 -0
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +40 -38
- package/dist/http/h3/index.js.map +1 -0
- package/dist/http/h3/index.mjs +4 -2
- package/dist/http/h3/index.mjs.map +1 -0
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +36 -34
- package/dist/http/hono/index.js.map +1 -0
- package/dist/http/hono/index.mjs +4 -2
- package/dist/http/hono/index.mjs.map +1 -0
- 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 +37 -35
- package/dist/http/hyper-express/index.js.map +1 -0
- package/dist/http/hyper-express/index.mjs +4 -2
- package/dist/http/hyper-express/index.mjs.map +1 -0
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +39 -37
- package/dist/http/koa/index.js.map +1 -0
- package/dist/http/koa/index.mjs +4 -2
- package/dist/http/koa/index.mjs.map +1 -0
- package/dist/index.d.mts +76 -12
- package/dist/index.d.ts +76 -12
- package/dist/index.js +105 -49
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +68 -12
- package/dist/index.mjs.map +1 -0
- package/dist/{meta-BX5jhe4Z.d.mts → meta-BoS1E-Nz.d.mts} +6 -23
- package/dist/{meta-BX5jhe4Z.d.ts → meta-BoS1E-Nz.d.ts} +6 -23
- package/dist/rpc/bullmq/index.d.mts +4 -6
- package/dist/rpc/bullmq/index.d.ts +4 -6
- package/dist/rpc/bullmq/index.js +13 -80
- package/dist/rpc/bullmq/index.js.map +1 -0
- package/dist/rpc/bullmq/index.mjs +5 -72
- package/dist/rpc/bullmq/index.mjs.map +1 -0
- package/dist/rpc/electron/index.d.mts +13 -0
- package/dist/rpc/electron/index.d.ts +13 -0
- package/dist/rpc/electron/index.js +73 -0
- package/dist/rpc/electron/index.js.map +1 -0
- package/dist/rpc/electron/index.mjs +73 -0
- package/dist/rpc/electron/index.mjs.map +1 -0
- package/dist/rpc/kafka/index.d.mts +4 -9
- package/dist/rpc/kafka/index.d.ts +4 -9
- package/dist/rpc/kafka/index.js +12 -90
- package/dist/rpc/kafka/index.js.map +1 -0
- package/dist/rpc/kafka/index.mjs +5 -83
- package/dist/rpc/kafka/index.mjs.map +1 -0
- package/dist/rpc/nats/index.d.mts +4 -6
- package/dist/rpc/nats/index.d.ts +4 -6
- package/dist/rpc/nats/index.js +13 -72
- package/dist/rpc/nats/index.js.map +1 -0
- package/dist/rpc/nats/index.mjs +4 -63
- package/dist/rpc/nats/index.mjs.map +1 -0
- package/dist/rpc/rabbitmq/index.d.mts +4 -6
- package/dist/rpc/rabbitmq/index.d.ts +4 -6
- package/dist/rpc/rabbitmq/index.js +14 -79
- package/dist/rpc/rabbitmq/index.js.map +1 -0
- package/dist/rpc/rabbitmq/index.mjs +5 -70
- package/dist/rpc/rabbitmq/index.mjs.map +1 -0
- package/dist/rpc/redis/index.d.mts +4 -9
- package/dist/rpc/redis/index.d.ts +4 -9
- package/dist/rpc/redis/index.js +12 -78
- package/dist/rpc/redis/index.js.map +1 -0
- package/dist/rpc/redis/index.mjs +5 -71
- package/dist/rpc/redis/index.mjs.map +1 -0
- package/dist/rpc/web-ext/index.d.mts +2 -0
- package/dist/rpc/web-ext/index.d.ts +2 -0
- package/dist/rpc/web-ext/index.js +1 -0
- package/dist/rpc/web-ext/index.js.map +1 -0
- package/dist/rpc/web-ext/index.mjs +1 -0
- package/dist/rpc/web-ext/index.mjs.map +1 -0
- package/dist/rpc/ws/index.d.mts +14 -0
- package/dist/rpc/ws/index.d.ts +14 -0
- package/dist/rpc/ws/index.js +74 -0
- package/dist/rpc/ws/index.js.map +1 -0
- package/dist/rpc/ws/index.mjs +74 -0
- package/dist/rpc/ws/index.mjs.map +1 -0
- package/dist/test.d.mts +7 -3
- package/dist/test.d.ts +7 -3
- package/dist/test.js +7 -6
- package/dist/test.js.map +1 -0
- package/dist/test.mjs +3 -2
- package/dist/test.mjs.map +1 -0
- package/dist/types-CInz3bD0.d.ts +14 -0
- package/dist/types-E-rqlg3-.d.mts +14 -0
- package/dist/{types-DKVhyZk_.d.mts → types-SCJZFCYt.d.mts} +1 -1
- package/dist/{types-CMeuFoyd.d.ts → types-xruyYmyu.d.ts} +1 -1
- package/package.json +24 -8
- package/register/export.mjs +30 -0
- package/register/index.mjs +2 -3
- package/register/loader.mjs +83 -90
- package/register/utils.mjs +36 -6
- package/assets/ps.json +0 -24
- package/assets/tsconfig.json +0 -21
- package/dist/types-B-rUM9Fm.d.mts +0 -19
- package/dist/types-MxxtkZXw.d.ts +0 -19
package/register/loader.mjs
CHANGED
|
@@ -3,31 +3,45 @@ import { writeFile } from 'fs/promises'
|
|
|
3
3
|
import {
|
|
4
4
|
basename,
|
|
5
5
|
dirname,
|
|
6
|
-
extname,
|
|
7
6
|
isAbsolute,
|
|
8
7
|
relative,
|
|
9
8
|
resolve as resolvePath,
|
|
10
9
|
} from 'path'
|
|
11
10
|
import { createRequire } from 'module'
|
|
12
|
-
import { existsSync } from 'fs'
|
|
13
11
|
import ts from 'typescript'
|
|
14
12
|
import chokidar from 'chokidar'
|
|
15
|
-
import
|
|
13
|
+
import Debug from 'debug'
|
|
16
14
|
import { compile, genUnImportRet, handleClassTypes, slash } from './utils.mjs'
|
|
17
15
|
|
|
16
|
+
const require = createRequire(import.meta.url)
|
|
17
|
+
const debug = Debug('phecda-server/loader')
|
|
18
|
+
|
|
19
|
+
const isLowVersion = parseFloat(process.version.slice(1)) < 18.19
|
|
20
|
+
const IS_DEV = process.env.NODE_ENV === 'development'
|
|
18
21
|
let port
|
|
22
|
+
let config
|
|
23
|
+
const workdir = process.cwd()
|
|
24
|
+
const configPath = resolvePath(
|
|
25
|
+
workdir,
|
|
26
|
+
process.env.PS_CONFIG_FILE || 'ps.json',
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
// unimport
|
|
30
|
+
let unimportRet, customLoad, customResolve
|
|
31
|
+
const dtsPath = process.env.PS_DTS_PATH || 'ps.d.ts'
|
|
32
|
+
|
|
33
|
+
// graph
|
|
34
|
+
const watchFiles = new Set()
|
|
35
|
+
const filesRecord = new Map()
|
|
36
|
+
const moduleGraph = {}
|
|
37
|
+
// ts
|
|
19
38
|
let tsconfig = {
|
|
20
39
|
module: ts.ModuleKind.ESNext,
|
|
21
40
|
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
22
41
|
}
|
|
23
|
-
|
|
24
|
-
const isLowVersion = parseFloat(process.version.slice(1)) < 18.19
|
|
25
|
-
// this part is important or not?
|
|
26
42
|
const EXTENSIONS = [ts.Extension.Ts, ts.Extension.Tsx, ts.Extension.Mts]
|
|
27
|
-
|
|
28
43
|
const tsconfigPath = resolvePath(process.cwd(), 'tsconfig.json')
|
|
29
44
|
const tsRet = ts.readConfigFile(tsconfigPath, ts.sys.readFile)
|
|
30
|
-
|
|
31
45
|
if (!tsRet.error) {
|
|
32
46
|
const { error, options } = ts.parseJsonConfigFileContent(
|
|
33
47
|
tsRet.config,
|
|
@@ -48,33 +62,31 @@ const host = {
|
|
|
48
62
|
readFile: ts.sys.readFile,
|
|
49
63
|
}
|
|
50
64
|
|
|
51
|
-
let unimportRet
|
|
52
|
-
const dtsPath = 'ps.d.ts'
|
|
53
|
-
|
|
54
65
|
if (isLowVersion)
|
|
55
66
|
await initialize()
|
|
56
67
|
|
|
57
|
-
let config
|
|
58
|
-
|
|
59
|
-
const workdir = process.cwd()
|
|
60
|
-
|
|
61
|
-
const configPath = resolvePath(
|
|
62
|
-
workdir,
|
|
63
|
-
process.env.PS_CONFIG_FILE || 'ps.json',
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
const require = createRequire(import.meta.url)
|
|
67
68
|
export async function initialize(data) {
|
|
68
69
|
if (data)
|
|
69
70
|
port = data.port
|
|
70
|
-
|
|
71
|
+
|
|
72
|
+
debug('read config...')
|
|
71
73
|
|
|
72
74
|
config = require(configPath)
|
|
73
|
-
|
|
74
|
-
config.virtualFile = {}
|
|
75
|
+
|
|
75
76
|
if (!config.paths)
|
|
76
77
|
config.paths = {}
|
|
77
78
|
|
|
79
|
+
const loaderPath = process.env.PS_LOADER_PATH
|
|
80
|
+
|
|
81
|
+
if (loaderPath) {
|
|
82
|
+
const loader = await import(loaderPath.startsWith('.') ? resolvePath(workdir, loaderPath) : loaderPath)
|
|
83
|
+
|
|
84
|
+
if (typeof loader.load === 'function')
|
|
85
|
+
customLoad = loader.load
|
|
86
|
+
|
|
87
|
+
if (typeof loader.resolve === 'function')
|
|
88
|
+
customResolve = loader.resolve
|
|
89
|
+
}
|
|
78
90
|
if (IS_DEV) {
|
|
79
91
|
chokidar.watch(configPath, { persistent: true }).on('change', () => {
|
|
80
92
|
port.postMessage(
|
|
@@ -87,19 +99,21 @@ export async function initialize(data) {
|
|
|
87
99
|
|
|
88
100
|
if (!config.unimport)
|
|
89
101
|
return
|
|
102
|
+
|
|
90
103
|
unimportRet = await genUnImportRet(config.unimport)
|
|
91
104
|
if (unimportRet) {
|
|
92
|
-
|
|
105
|
+
debug('auto import...')
|
|
93
106
|
await unimportRet.init()
|
|
94
107
|
|
|
108
|
+
const unimportDtsPath = resolvePath(workdir, dtsPath)
|
|
95
109
|
writeFile(
|
|
96
|
-
|
|
110
|
+
unimportDtsPath,
|
|
97
111
|
handleClassTypes(
|
|
98
112
|
await unimportRet.generateTypeDeclarations({
|
|
99
113
|
resolvePath: (i) => {
|
|
100
114
|
if (i.from.startsWith('.') || isAbsolute(i.from)) {
|
|
101
115
|
const related = slash(
|
|
102
|
-
relative(
|
|
116
|
+
relative(dirname(unimportDtsPath), i.from).replace(/\.ts(x)?$/, ''),
|
|
103
117
|
)
|
|
104
118
|
|
|
105
119
|
return !related.startsWith('.') ? `./${related}` : related
|
|
@@ -112,12 +126,6 @@ export async function initialize(data) {
|
|
|
112
126
|
}
|
|
113
127
|
}
|
|
114
128
|
|
|
115
|
-
const watchFiles = new Set()
|
|
116
|
-
const filesRecord = new Map()
|
|
117
|
-
const moduleGraph = {}
|
|
118
|
-
|
|
119
|
-
let entryUrl
|
|
120
|
-
|
|
121
129
|
function addUrlToGraph(url, parent) {
|
|
122
130
|
if (!(url in moduleGraph))
|
|
123
131
|
moduleGraph[url] = new Set()
|
|
@@ -129,63 +137,34 @@ function addUrlToGraph(url, parent) {
|
|
|
129
137
|
function getFileMid(file) {
|
|
130
138
|
const filename = basename(file)
|
|
131
139
|
const ret = filename.split('.')
|
|
132
|
-
if (ret.
|
|
133
|
-
return
|
|
134
|
-
|
|
140
|
+
if (!['js', 'mjs', 'cjs', 'ts', 'tsx', 'mts', 'cts'].includes(ret.pop()))
|
|
141
|
+
return ''
|
|
142
|
+
if (!ret[0])// .dockerfile
|
|
143
|
+
return ''
|
|
144
|
+
|
|
145
|
+
return ret[1]
|
|
135
146
|
}
|
|
136
147
|
|
|
137
148
|
export const resolve = async (specifier, context, nextResolve) => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
format: 'ts',
|
|
142
|
-
url: specifier,
|
|
143
|
-
shortCircuit: true,
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
// entrypoint
|
|
147
|
-
if (!context.parentURL) {
|
|
148
|
-
if (/^file:\/\/\//.test(specifier) && existsSync(fileURLToPath(specifier))) {
|
|
149
|
-
entryUrl = specifier
|
|
150
|
-
|
|
149
|
+
if (customResolve) {
|
|
150
|
+
const url = await customResolve(specifier, context)
|
|
151
|
+
if (url) {
|
|
151
152
|
return {
|
|
152
|
-
format:
|
|
153
|
-
|
|
154
|
-
: undefined,
|
|
155
|
-
url: specifier,
|
|
153
|
+
format: 'ts',
|
|
154
|
+
url,
|
|
156
155
|
shortCircuit: true,
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
|
-
else {
|
|
160
|
-
// won't resolve virtual file as entry in vite
|
|
161
|
-
return nextResolve(specifier)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
// url import
|
|
165
|
-
// it seems useless
|
|
166
|
-
if (/^file:\/\/\//.test(specifier) && extname(specifier) === '.ts') {
|
|
167
|
-
const url = addUrlToGraph(specifier, context.parentURL.split('?')[0])
|
|
168
|
-
return {
|
|
169
|
-
format: 'ts',
|
|
170
|
-
url,
|
|
171
|
-
shortCircuit: true,
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// hmr import
|
|
176
|
-
if (
|
|
177
|
-
context.parentURL.includes('/node_modules/phecda-server')
|
|
178
|
-
&& isAbsolute(specifier)
|
|
179
|
-
) {
|
|
180
|
-
specifier = relative(fileURLToPath(entryUrl), specifier)
|
|
181
|
-
.replace(/\.ts$/, '')
|
|
182
|
-
.slice(1)
|
|
183
|
-
context.parentURL = entryUrl
|
|
184
158
|
}
|
|
185
159
|
|
|
186
|
-
//
|
|
187
|
-
if (context.parentURL
|
|
160
|
+
// entrypoint
|
|
161
|
+
if (!context.parentURL)
|
|
188
162
|
return nextResolve(specifier)
|
|
163
|
+
|
|
164
|
+
// @todo skip resolve to improve performance
|
|
165
|
+
// if (context.parentURL.includes('/node_modules/') && specifier.includes('/node_modules/'))
|
|
166
|
+
// return nextResolve(specifier)
|
|
167
|
+
|
|
189
168
|
const { resolvedModule } = ts.resolveModuleName(
|
|
190
169
|
specifier,
|
|
191
170
|
fileURLToPath(context.parentURL),
|
|
@@ -194,7 +173,7 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
194
173
|
moduleResolutionCache,
|
|
195
174
|
)
|
|
196
175
|
|
|
197
|
-
// import
|
|
176
|
+
// import among files in local project
|
|
198
177
|
if (
|
|
199
178
|
resolvedModule
|
|
200
179
|
&& !resolvedModule.resolvedFileName.includes('/node_modules/')
|
|
@@ -230,23 +209,24 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
230
209
|
const resolveRet = await nextResolve(specifier)
|
|
231
210
|
|
|
232
211
|
// ts resolve fail in some cases
|
|
233
|
-
if (resolveRet.url && isAbsolute(resolveRet.url))
|
|
234
|
-
|
|
212
|
+
if (resolveRet.url && isAbsolute(resolveRet.url)) {
|
|
213
|
+
const [path, query] = resolveRet.url.split('?')
|
|
214
|
+
resolveRet.url = pathToFileURL(path).href + (query ? `?${query}` : '')
|
|
215
|
+
}
|
|
235
216
|
|
|
236
217
|
return resolveRet
|
|
237
218
|
}
|
|
238
219
|
// @todo the first params may be url or path, need to distinguish
|
|
239
220
|
|
|
240
221
|
export const load = async (url, context, nextLoad) => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
shortCircuit: true,
|
|
246
|
-
}
|
|
222
|
+
let mode
|
|
223
|
+
if (context.importAttributes.ps) {
|
|
224
|
+
mode = context.importAttributes.ps
|
|
225
|
+
delete context.importAttributes.ps
|
|
247
226
|
}
|
|
248
227
|
|
|
249
228
|
url = url.split('?')[0]
|
|
229
|
+
|
|
250
230
|
if (
|
|
251
231
|
!url.includes('/node_modules/')
|
|
252
232
|
&& url.startsWith('file://')
|
|
@@ -255,7 +235,7 @@ export const load = async (url, context, nextLoad) => {
|
|
|
255
235
|
) {
|
|
256
236
|
watchFiles.add(url)
|
|
257
237
|
|
|
258
|
-
if (IS_DEV) {
|
|
238
|
+
if (IS_DEV && mode !== 'not-hmr') {
|
|
259
239
|
if (isModuleFileUrl(url)) {
|
|
260
240
|
port.postMessage(
|
|
261
241
|
JSON.stringify({
|
|
@@ -289,6 +269,17 @@ export const load = async (url, context, nextLoad) => {
|
|
|
289
269
|
)
|
|
290
270
|
}
|
|
291
271
|
}
|
|
272
|
+
// after hmr
|
|
273
|
+
if (customLoad) {
|
|
274
|
+
const source = await customLoad(url, context)
|
|
275
|
+
if (source) {
|
|
276
|
+
return {
|
|
277
|
+
format: 'module',
|
|
278
|
+
source,
|
|
279
|
+
shortCircuit: true,
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
292
283
|
// resolveModuleName failed
|
|
293
284
|
// I don't know why it failed
|
|
294
285
|
if (!context.format && url.endsWith('.ts'))
|
|
@@ -299,10 +290,12 @@ export const load = async (url, context, nextLoad) => {
|
|
|
299
290
|
|
|
300
291
|
const code
|
|
301
292
|
= typeof source === 'string' ? source : Buffer.from(source).toString()
|
|
293
|
+
|
|
302
294
|
const compiled = (await compile(code, url)).replace(/_ts_metadata\(\"design:paramtypes\"\,/g, '_ts_metadata("design:paramtypes",()=>')// handle cycle
|
|
303
295
|
|
|
304
296
|
if (unimportRet) {
|
|
305
297
|
const { injectImports } = unimportRet
|
|
298
|
+
|
|
306
299
|
return {
|
|
307
300
|
format: 'module',
|
|
308
301
|
source: (
|
package/register/utils.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { basename } from 'path'
|
|
2
2
|
import { transform } from '@swc-node/core'
|
|
3
|
+
import psExports from './export.mjs'
|
|
3
4
|
const injectInlineSourceMap = ({ code, map }) => {
|
|
4
5
|
if (map) {
|
|
5
6
|
const base64Map = Buffer.from(map, 'utf8').toString('base64')
|
|
@@ -19,6 +20,32 @@ export async function compile(sourcecode, filename) {
|
|
|
19
20
|
emitDecoratorMetadata: true,
|
|
20
21
|
experimentalDecorators: true,
|
|
21
22
|
esModuleInterop: false,
|
|
23
|
+
swc: {
|
|
24
|
+
|
|
25
|
+
jsc: {
|
|
26
|
+
parser: {
|
|
27
|
+
syntax: 'typescript',
|
|
28
|
+
importAttributes: true,
|
|
29
|
+
decorators: true,
|
|
30
|
+
tsx: false,
|
|
31
|
+
dynamicImport: true,
|
|
32
|
+
strictPropertyInitialization: false,
|
|
33
|
+
},
|
|
34
|
+
experimental: {
|
|
35
|
+
keepImportAssertions: true,
|
|
36
|
+
},
|
|
37
|
+
transform: {
|
|
38
|
+
legacyDecorator: true,
|
|
39
|
+
decoratorMetadata: true,
|
|
40
|
+
},
|
|
41
|
+
// parser: {
|
|
42
|
+
// importAttributes: true
|
|
43
|
+
// },
|
|
44
|
+
// experimental: {
|
|
45
|
+
// keepImportAssertions: true
|
|
46
|
+
// }
|
|
47
|
+
},
|
|
48
|
+
},
|
|
22
49
|
})
|
|
23
50
|
|
|
24
51
|
return injectInlineSourceMap({ code, map })
|
|
@@ -26,18 +53,21 @@ export async function compile(sourcecode, filename) {
|
|
|
26
53
|
|
|
27
54
|
export async function genUnImportRet(opts) {
|
|
28
55
|
try {
|
|
29
|
-
const psExports = Object.keys(await import('../dist/index.mjs'))
|
|
30
56
|
const { createUnimport } = await import('unimport')
|
|
31
57
|
return createUnimport({
|
|
32
58
|
...opts,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
|
|
60
|
+
presets: [
|
|
61
|
+
{
|
|
62
|
+
from: 'phecda-server',
|
|
63
|
+
imports: psExports,
|
|
64
|
+
},
|
|
65
|
+
]
|
|
66
|
+
.concat(opts.presets || []),
|
|
38
67
|
})
|
|
39
68
|
}
|
|
40
69
|
catch (e) {
|
|
70
|
+
console.error(e)
|
|
41
71
|
return false
|
|
42
72
|
}
|
|
43
73
|
}
|
package/assets/ps.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://unpkg.com/phecda-server/assets/schema.json",
|
|
3
|
-
"resolve": [
|
|
4
|
-
{
|
|
5
|
-
"source": "controller",
|
|
6
|
-
"importer": "http",
|
|
7
|
-
"path": ".ps/http.js"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"source": "rpc",
|
|
11
|
-
"importer": "client",
|
|
12
|
-
"path": ".ps/rpc.js"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"unimport": {
|
|
16
|
-
"dirs": ["."],
|
|
17
|
-
"dirsScanOptions": {
|
|
18
|
-
"filePatterns": ["*.{service,controller,module,rpc,solo,guard,extension,pipe,filter,addon}.ts"]
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"virtualFile": {},
|
|
22
|
-
"moduleFile": []
|
|
23
|
-
|
|
24
|
-
}
|
package/assets/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"useDefineForClassFields": false,
|
|
5
|
-
"experimentalDecorators": true,
|
|
6
|
-
"emitDecoratorMetadata": true,
|
|
7
|
-
"module": "esnext",
|
|
8
|
-
"lib": ["esnext", "DOM"],
|
|
9
|
-
"strictPropertyInitialization": false,
|
|
10
|
-
"moduleResolution": "Node",
|
|
11
|
-
"strict": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"noUnusedLocals": true,
|
|
16
|
-
"noUnusedParameters": true,
|
|
17
|
-
"noImplicitReturns": true,
|
|
18
|
-
"skipLibCheck": true
|
|
19
|
-
},
|
|
20
|
-
"include": [".","./ps.d.ts"]
|
|
21
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.mjs';
|
|
2
|
-
|
|
3
|
-
interface RpcServerOptions extends DefaultOptions {
|
|
4
|
-
defaultQueue?: string;
|
|
5
|
-
}
|
|
6
|
-
interface RpcClientOptions {
|
|
7
|
-
key?: string;
|
|
8
|
-
timeout?: number;
|
|
9
|
-
max?: number;
|
|
10
|
-
}
|
|
11
|
-
interface RpcCtx extends BaseCtx {
|
|
12
|
-
args: any[];
|
|
13
|
-
id: string;
|
|
14
|
-
queue: string;
|
|
15
|
-
isEvent?: boolean;
|
|
16
|
-
category: 'rpc';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type { RpcCtx as R, RpcServerOptions as a, RpcClientOptions as b };
|
package/dist/types-MxxtkZXw.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.js';
|
|
2
|
-
|
|
3
|
-
interface RpcServerOptions extends DefaultOptions {
|
|
4
|
-
defaultQueue?: string;
|
|
5
|
-
}
|
|
6
|
-
interface RpcClientOptions {
|
|
7
|
-
key?: string;
|
|
8
|
-
timeout?: number;
|
|
9
|
-
max?: number;
|
|
10
|
-
}
|
|
11
|
-
interface RpcCtx extends BaseCtx {
|
|
12
|
-
args: any[];
|
|
13
|
-
id: string;
|
|
14
|
-
queue: string;
|
|
15
|
-
isEvent?: boolean;
|
|
16
|
-
category: 'rpc';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type { RpcCtx as R, RpcServerOptions as a, RpcClientOptions as b };
|