@0x-jerry/x 2.9.3 → 2.10.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/dist/{chunk-PM26AGY7.js → chunk-VDPUNX7B.js} +1 -1
- package/dist/hooks/index.js +63 -84
- package/dist/x.js +1 -2
- package/dist/xn.js +1 -2
- package/dist/xr.js +1 -2
- package/package.json +1 -1
- package/dist/chunk-MLKGABMK.js +0 -9
package/dist/hooks/index.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__export
|
|
3
|
-
} from "../chunk-MLKGABMK.js";
|
|
4
|
-
|
|
5
1
|
// src/hooks/index.ts
|
|
6
2
|
import * as tsx from "tsx/esm";
|
|
7
3
|
|
|
8
4
|
// src/hooks/jsonc.ts
|
|
9
|
-
var jsonc_exports = {};
|
|
10
|
-
__export(jsonc_exports, {
|
|
11
|
-
load: () => load,
|
|
12
|
-
resolve: () => resolve
|
|
13
|
-
});
|
|
14
|
-
import path from "path";
|
|
15
5
|
import stripJsonComment from "strip-json-comments";
|
|
16
6
|
|
|
17
7
|
// src/hooks/utils.ts
|
|
@@ -37,90 +27,79 @@ function chainHooks(fns) {
|
|
|
37
27
|
return wrapperFn;
|
|
38
28
|
}
|
|
39
29
|
|
|
40
|
-
// src/hooks/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
// src/hooks/helper.ts
|
|
31
|
+
function createModuleHook({
|
|
32
|
+
type,
|
|
33
|
+
loader
|
|
34
|
+
}) {
|
|
35
|
+
const resolve2 = async (specifier, ctx, nextResolve) => {
|
|
36
|
+
const nextResult = await nextResolve(specifier, ctx);
|
|
37
|
+
if (ctx.importAttributes.type !== type) {
|
|
38
|
+
return nextResult;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...nextResult,
|
|
42
|
+
format: type,
|
|
43
|
+
shortCircuit: true
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const load2 = async (url, ctx, nextLoad) => {
|
|
47
|
+
const nextResult = await nextLoad(url, ctx);
|
|
48
|
+
if (ctx.format !== type) return nextResult;
|
|
49
|
+
const source = await loader(sourceToStr(nextResult.source));
|
|
50
|
+
return {
|
|
51
|
+
shortCircuit: true,
|
|
52
|
+
...source
|
|
53
|
+
};
|
|
50
54
|
};
|
|
51
|
-
};
|
|
52
|
-
var load = async (url, ctx, nextLoad) => {
|
|
53
|
-
const nextResult = await nextLoad(url, ctx);
|
|
54
|
-
if (ctx.format !== FORMAT_TYPE) return nextResult;
|
|
55
|
-
const source = stripJsonComment(sourceToStr(nextResult.source));
|
|
56
55
|
return {
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
resolve: resolve2,
|
|
57
|
+
load: load2
|
|
59
58
|
};
|
|
60
|
-
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/hooks/jsonc.ts
|
|
62
|
+
var jsonc_default = createModuleHook({
|
|
63
|
+
type: "jsonc",
|
|
64
|
+
loader(rawSource) {
|
|
65
|
+
const source = stripJsonComment(rawSource);
|
|
66
|
+
return {
|
|
67
|
+
format: "json",
|
|
68
|
+
source
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
61
72
|
|
|
62
73
|
// src/hooks/text.ts
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
var text_default = createModuleHook({
|
|
75
|
+
type: "text",
|
|
76
|
+
loader(rawSource) {
|
|
77
|
+
const source = `export default ${JSON.stringify(rawSource)};`;
|
|
78
|
+
return {
|
|
79
|
+
format: "module",
|
|
80
|
+
source
|
|
81
|
+
};
|
|
82
|
+
}
|
|
67
83
|
});
|
|
68
|
-
import path2 from "path";
|
|
69
|
-
var supportedExtensions2 = [".txt", ".sql", ".md"];
|
|
70
|
-
var FORMAT_TYPE2 = "text";
|
|
71
|
-
var resolve2 = async (specifier, ctx, nextResolve) => {
|
|
72
|
-
const nextResult = await nextResolve(specifier, ctx);
|
|
73
|
-
const ext = path2.extname(specifier);
|
|
74
|
-
if (!supportedExtensions2.includes(ext)) return nextResult;
|
|
75
|
-
return {
|
|
76
|
-
...nextResult,
|
|
77
|
-
format: FORMAT_TYPE2
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
var load2 = async (url, ctx, nextLoad) => {
|
|
81
|
-
const nextResult = await nextLoad(url, ctx);
|
|
82
|
-
if (ctx.format !== FORMAT_TYPE2) return nextResult;
|
|
83
|
-
const source = `export default ${JSON.stringify(sourceToStr(nextResult.source))};`;
|
|
84
|
-
return {
|
|
85
|
-
format: "module",
|
|
86
|
-
source
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
84
|
|
|
90
85
|
// src/hooks/yaml.ts
|
|
91
|
-
var yaml_exports = {};
|
|
92
|
-
__export(yaml_exports, {
|
|
93
|
-
load: () => load3,
|
|
94
|
-
resolve: () => resolve3
|
|
95
|
-
});
|
|
96
|
-
import path3 from "path";
|
|
97
86
|
import yaml from "yaml";
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
};
|
|
109
|
-
var load3 = async (url, ctx, nextLoad) => {
|
|
110
|
-
if (ctx.format !== FORMAT_TYPE3) return nextLoad(url, ctx);
|
|
111
|
-
const nextResult = await nextLoad(url, ctx);
|
|
112
|
-
const source = yaml.parse(sourceToStr(nextResult.source));
|
|
113
|
-
return {
|
|
114
|
-
format: "json",
|
|
115
|
-
source: JSON.stringify(source)
|
|
116
|
-
};
|
|
117
|
-
};
|
|
87
|
+
var yaml_default = createModuleHook({
|
|
88
|
+
type: "yaml",
|
|
89
|
+
loader(rawSource) {
|
|
90
|
+
const source = yaml.parse(rawSource);
|
|
91
|
+
return {
|
|
92
|
+
format: "json",
|
|
93
|
+
source: JSON.stringify(source)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
});
|
|
118
97
|
|
|
119
98
|
// src/hooks/index.ts
|
|
120
|
-
var hooks = [
|
|
121
|
-
var
|
|
122
|
-
var
|
|
99
|
+
var hooks = [jsonc_default, text_default, yaml_default, tsx];
|
|
100
|
+
var resolve = chainHooks(hooks.map((n) => n.resolve));
|
|
101
|
+
var load = chainHooks(hooks.map((n) => n.load));
|
|
123
102
|
export {
|
|
124
|
-
|
|
125
|
-
|
|
103
|
+
load,
|
|
104
|
+
resolve
|
|
126
105
|
};
|
package/dist/x.js
CHANGED
package/dist/xn.js
CHANGED
package/dist/xr.js
CHANGED
package/package.json
CHANGED