wurzel 0.0.12 → 0.0.13
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/lib/index.d.ts +5 -3
- package/dist/lib/index.js +10 -7
- package/package.json +2 -2
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { defaultCodeAnalyzer } from "es6-debug-server";
|
|
2
|
+
import type { TCodeAnalyzeFunc, TResolveImportPathFunc } from "es6-debug-server";
|
|
2
3
|
import type Express from "express";
|
|
3
4
|
type TFileType = "script" | "script-resource" | "other";
|
|
4
5
|
declare const defaultResolveImportPath: TResolveImportPathFunc;
|
|
5
6
|
declare const defaultDetermineFileTypeByPath: ({ filePath }: {
|
|
6
7
|
filePath: string;
|
|
7
8
|
}) => TFileType;
|
|
8
|
-
declare const expressRouter: ({ express, baseFolder, maxAnalyzeCacheSize, maxTranspileCacheSize, determineFileTypeByPath, resolveImportPath }: {
|
|
9
|
+
declare const expressRouter: ({ express, baseFolder, maxAnalyzeCacheSize, maxTranspileCacheSize, analyzeCode: providedAnalyzeCode, determineFileTypeByPath, resolveImportPath }: {
|
|
9
10
|
express: typeof Express;
|
|
10
11
|
baseFolder: string;
|
|
11
12
|
maxAnalyzeCacheSize?: number;
|
|
12
13
|
maxTranspileCacheSize?: number;
|
|
14
|
+
analyzeCode?: TCodeAnalyzeFunc;
|
|
13
15
|
determineFileTypeByPath?: (args: {
|
|
14
16
|
filePath: string;
|
|
15
17
|
}) => TFileType;
|
|
16
18
|
resolveImportPath?: TResolveImportPathFunc;
|
|
17
19
|
}) => any;
|
|
18
|
-
export { expressRouter, defaultResolveImportPath, defaultDetermineFileTypeByPath, };
|
|
20
|
+
export { expressRouter, defaultResolveImportPath, defaultDetermineFileTypeByPath, defaultCodeAnalyzer, };
|
|
19
21
|
export type { TResolveImportPathFunc, TFileType };
|
package/dist/lib/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createReadError,
|
|
3
|
-
|
|
4
|
-
ETryReadErrorCode,
|
|
3
|
+
createEs6DebugServer,
|
|
5
4
|
defaultCodeAnalyzer
|
|
6
5
|
} from "es6-debug-server";
|
|
7
6
|
/*import type {
|
|
8
7
|
ICodeAnalyzeResult,
|
|
8
|
+
TCodeAnalyzeFunc,
|
|
9
9
|
TResolveImportPathFunc,
|
|
10
10
|
} from "es6-debug-server";*/
|
|
11
11
|
import { readFile } from "node:fs/promises";
|
|
@@ -88,6 +88,7 @@ const expressRouter = ({
|
|
|
88
88
|
maxAnalyzeCacheSize = 1 * 1024 * 1024,
|
|
89
89
|
maxTranspileCacheSize = 64 * 1024 * 1024,
|
|
90
90
|
|
|
91
|
+
analyzeCode: providedAnalyzeCode = defaultCodeAnalyzer,
|
|
91
92
|
determineFileTypeByPath = defaultDetermineFileTypeByPath,
|
|
92
93
|
resolveImportPath = defaultResolveImportPath
|
|
93
94
|
}/*: {
|
|
@@ -97,6 +98,7 @@ const expressRouter = ({
|
|
|
97
98
|
maxAnalyzeCacheSize?: number,
|
|
98
99
|
maxTranspileCacheSize?: number,
|
|
99
100
|
|
|
101
|
+
analyzeCode?: TCodeAnalyzeFunc,
|
|
100
102
|
// eslint-disable-next-line no-unused-vars
|
|
101
103
|
determineFileTypeByPath?: (args: { filePath: string }) => TFileType,
|
|
102
104
|
resolveImportPath?: TResolveImportPathFunc
|
|
@@ -162,7 +164,7 @@ const expressRouter = ({
|
|
|
162
164
|
};
|
|
163
165
|
};
|
|
164
166
|
|
|
165
|
-
const server =
|
|
167
|
+
const server = createEs6DebugServer({
|
|
166
168
|
|
|
167
169
|
scriptRootFolder: baseFolder,
|
|
168
170
|
|
|
@@ -179,7 +181,7 @@ const expressRouter = ({
|
|
|
179
181
|
|
|
180
182
|
return {
|
|
181
183
|
error: createReadError({
|
|
182
|
-
code:
|
|
184
|
+
code: "FILE_NOT_FOUND",
|
|
183
185
|
message: readError.message,
|
|
184
186
|
cause: readError
|
|
185
187
|
})
|
|
@@ -188,7 +190,7 @@ const expressRouter = ({
|
|
|
188
190
|
|
|
189
191
|
return {
|
|
190
192
|
error: createReadError({
|
|
191
|
-
code:
|
|
193
|
+
code: "IO_ERROR",
|
|
192
194
|
message: readError.message,
|
|
193
195
|
cause: readError
|
|
194
196
|
})
|
|
@@ -203,7 +205,7 @@ const expressRouter = ({
|
|
|
203
205
|
if (transpileError !== undefined) {
|
|
204
206
|
return {
|
|
205
207
|
error: createReadError({
|
|
206
|
-
code:
|
|
208
|
+
code: "IO_ERROR",
|
|
207
209
|
message: `failed to transpile code of "${filePath}"`,
|
|
208
210
|
cause: transpileError
|
|
209
211
|
})
|
|
@@ -228,7 +230,7 @@ const expressRouter = ({
|
|
|
228
230
|
};
|
|
229
231
|
}
|
|
230
232
|
|
|
231
|
-
const analyzeResult =
|
|
233
|
+
const analyzeResult = providedAnalyzeCode({ code });
|
|
232
234
|
if (analyzeResult.error !== undefined) {
|
|
233
235
|
return {
|
|
234
236
|
error: analyzeResult.error
|
|
@@ -297,6 +299,7 @@ export {
|
|
|
297
299
|
|
|
298
300
|
defaultResolveImportPath,
|
|
299
301
|
defaultDetermineFileTypeByPath,
|
|
302
|
+
defaultCodeAnalyzer,
|
|
300
303
|
};
|
|
301
304
|
|
|
302
305
|
/*export type {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.13",
|
|
3
3
|
"name": "wurzel",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A tool to serve script files from different directories",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"main": "dist/lib/index.js",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"commentscript": "^0.0.10",
|
|
12
|
-
"es6-debug-server": "^0.0.
|
|
12
|
+
"es6-debug-server": "^0.0.11",
|
|
13
13
|
"esm-resource": "^0.0.3",
|
|
14
14
|
"import-meta-resolve": "^4.0.0",
|
|
15
15
|
"lru-cache": "^10.2.1"
|