@0x-jerry/x 2.10.0 → 2.10.1
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-VDPUNX7B.js → chunk-635NMR3B.js} +1 -1
- package/dist/hooks/index.js +18 -26
- package/dist/x.js +1 -1
- package/dist/xn.js +1 -1
- package/dist/xr.js +1 -1
- package/package.json +1 -1
package/dist/hooks/index.js
CHANGED
|
@@ -4,30 +4,9 @@ import * as tsx from "tsx/esm";
|
|
|
4
4
|
// src/hooks/jsonc.ts
|
|
5
5
|
import stripJsonComment from "strip-json-comments";
|
|
6
6
|
|
|
7
|
-
// src/hooks/utils.ts
|
|
8
|
-
function sourceToStr(source) {
|
|
9
|
-
if (!source) return "";
|
|
10
|
-
if (source instanceof ArrayBuffer) {
|
|
11
|
-
return Buffer.from(source).toString("utf-8");
|
|
12
|
-
}
|
|
13
|
-
if (typeof source === "string") {
|
|
14
|
-
return source;
|
|
15
|
-
}
|
|
16
|
-
return Buffer.from(source.buffer).toString("utf-8");
|
|
17
|
-
}
|
|
18
|
-
function chainHooks(fns) {
|
|
19
|
-
const wrapperFn = (a, b, defaultHook) => {
|
|
20
|
-
const fn = fns.reduceRight((prev, hook) => {
|
|
21
|
-
return (a2, b2) => {
|
|
22
|
-
return hook(a2, b2, prev);
|
|
23
|
-
};
|
|
24
|
-
}, defaultHook);
|
|
25
|
-
return fn(a, b);
|
|
26
|
-
};
|
|
27
|
-
return wrapperFn;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
7
|
// src/hooks/helper.ts
|
|
8
|
+
import { readFile } from "fs/promises";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
31
10
|
function createModuleHook({
|
|
32
11
|
type,
|
|
33
12
|
loader
|
|
@@ -44,9 +23,9 @@ function createModuleHook({
|
|
|
44
23
|
};
|
|
45
24
|
};
|
|
46
25
|
const load2 = async (url, ctx, nextLoad) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const source = await loader(
|
|
26
|
+
if (ctx.format !== type) return nextLoad(url, ctx);
|
|
27
|
+
const raw = await readFile(fileURLToPath(url), "utf-8");
|
|
28
|
+
const source = await loader(raw);
|
|
50
29
|
return {
|
|
51
30
|
shortCircuit: true,
|
|
52
31
|
...source
|
|
@@ -82,6 +61,19 @@ var text_default = createModuleHook({
|
|
|
82
61
|
}
|
|
83
62
|
});
|
|
84
63
|
|
|
64
|
+
// src/hooks/utils.ts
|
|
65
|
+
function chainHooks(fns) {
|
|
66
|
+
const wrapperFn = (a, b, defaultHook) => {
|
|
67
|
+
const fn = fns.reduceRight((prev, hook) => {
|
|
68
|
+
return (a2, b2) => {
|
|
69
|
+
return hook(a2, b2, prev);
|
|
70
|
+
};
|
|
71
|
+
}, defaultHook);
|
|
72
|
+
return fn(a, b);
|
|
73
|
+
};
|
|
74
|
+
return wrapperFn;
|
|
75
|
+
}
|
|
76
|
+
|
|
85
77
|
// src/hooks/yaml.ts
|
|
86
78
|
import yaml from "yaml";
|
|
87
79
|
var yaml_default = createModuleHook({
|
package/dist/x.js
CHANGED
package/dist/xn.js
CHANGED
package/dist/xr.js
CHANGED