kerria 0.3.1 → 0.3.3
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/index.d.ts +0 -3
- package/dist/index.js +7 -9
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ declare function useLoad(name: string, options: UseLoadOptions): LoadInfo;
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/types.d.ts
|
|
17
17
|
type MaybePromise<T> = T | Promise<T>;
|
|
18
|
-
|
|
19
18
|
//#endregion
|
|
20
19
|
//#region src/core/useSource.d.ts
|
|
21
20
|
interface SourceInfo extends Omit<UseSourceOptions, "folders"> {
|
|
@@ -37,7 +36,6 @@ interface UseSourceOptions<T = any> {
|
|
|
37
36
|
onCacheHit?: (cache: T) => void;
|
|
38
37
|
}
|
|
39
38
|
declare function useSource<C extends object>(kind: number, options: UseSourceOptions<C>): SourceInfo;
|
|
40
|
-
|
|
41
39
|
//#endregion
|
|
42
40
|
//#region src/core/processor.d.ts
|
|
43
41
|
interface KerriaContext {
|
|
@@ -50,6 +48,5 @@ declare function createKerria(sign: string, setup: (ctx: KerriaContext) => void)
|
|
|
50
48
|
build: () => Promise<void>;
|
|
51
49
|
watch: () => Promise<void>;
|
|
52
50
|
};
|
|
53
|
-
|
|
54
51
|
//#endregion
|
|
55
52
|
export { LoadInfo, SourceInfo, UseLoadOptions, createKerria, useCurrentContext, useLoad, useSource };
|
package/dist/index.js
CHANGED
|
@@ -55,10 +55,7 @@ function createKerria(sign, setup) {
|
|
|
55
55
|
const caches = existsSync(cachePath) && readJsonSync(cachePath) || {};
|
|
56
56
|
async function build() {
|
|
57
57
|
for (const info of ctx.sourceInfos) {
|
|
58
|
-
const paths = await glob(info.patterns, {
|
|
59
|
-
deep: info.deep ? Infinity : 2,
|
|
60
|
-
absolute: true
|
|
61
|
-
});
|
|
58
|
+
const paths = await glob(info.patterns, { absolute: true });
|
|
62
59
|
await Promise.all(paths.map((path) => path.replaceAll("\\", "/")).filter(info.filter).sort((a, b) => a.localeCompare(b)).map((path) => parse(path, info)));
|
|
63
60
|
}
|
|
64
61
|
outputLoads();
|
|
@@ -135,9 +132,9 @@ function createKerria(sign, setup) {
|
|
|
135
132
|
//#region src/core/useLoad.ts
|
|
136
133
|
function useLoad(name, options) {
|
|
137
134
|
const ctx = useCurrentContext();
|
|
135
|
+
const { defaultValue = {}, onUpdate, beforeOutput } = options;
|
|
138
136
|
const src = options.src ? resolve(options.src) : void 0;
|
|
139
137
|
const out = resolve(options.out);
|
|
140
|
-
const { defaultValue = {}, onUpdate, beforeOutput } = options;
|
|
141
138
|
const info = {
|
|
142
139
|
name,
|
|
143
140
|
src,
|
|
@@ -158,10 +155,11 @@ function useLoad(name, options) {
|
|
|
158
155
|
//#region src/core/useSource.ts
|
|
159
156
|
function useSource(kind, options) {
|
|
160
157
|
const ctx = useCurrentContext();
|
|
158
|
+
const { deep = true, skip = 0 } = options;
|
|
161
159
|
const base = resolve(options.base);
|
|
162
160
|
const dist = options.dist ? resolve(options.dist) : void 0;
|
|
163
161
|
const folders = options.folders?.map((folder) => resolve(base, folder)) ?? [base];
|
|
164
|
-
const patterns = folders.map((path) => resolve(path,
|
|
162
|
+
const patterns = folders.map((path) => resolve(path, (deep ? "**/*" : "*") + options.ext));
|
|
165
163
|
const info = {
|
|
166
164
|
...options,
|
|
167
165
|
kind,
|
|
@@ -169,11 +167,11 @@ function useSource(kind, options) {
|
|
|
169
167
|
dist,
|
|
170
168
|
folders,
|
|
171
169
|
patterns,
|
|
172
|
-
deep
|
|
173
|
-
skip
|
|
170
|
+
deep,
|
|
171
|
+
skip,
|
|
174
172
|
filter(path) {
|
|
175
173
|
const depth = path.split("/").length - folders[0].split("/").length;
|
|
176
|
-
return
|
|
174
|
+
return skip < depth;
|
|
177
175
|
},
|
|
178
176
|
async output(path, data) {
|
|
179
177
|
const outPath = path.replace(base, dist).replace(info.ext, ".json");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kerria",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.3",
|
|
5
5
|
"description": "Composable source processor",
|
|
6
6
|
"author": "KazariEX",
|
|
7
7
|
"license": "MIT",
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
"consola": "^3.4.2",
|
|
22
22
|
"empathic": "^1.1.0",
|
|
23
23
|
"pathe": "^2.0.3",
|
|
24
|
-
"tinyglobby": "^0.2.
|
|
24
|
+
"tinyglobby": "^0.2.14"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@antfu/eslint-config": "^4.13.
|
|
28
|
-
"@types/node": "^22.15.
|
|
27
|
+
"@antfu/eslint-config": "^4.13.2",
|
|
28
|
+
"@types/node": "^22.15.29",
|
|
29
29
|
"@zinkawaii/eslint-config": "^0.3.0",
|
|
30
30
|
"@zinkawaii/tsconfig": "^0.0.2",
|
|
31
|
-
"bumpp": "^10.1.
|
|
32
|
-
"eslint": "^9.
|
|
33
|
-
"tsdown": "^0.
|
|
31
|
+
"bumpp": "^10.1.1",
|
|
32
|
+
"eslint": "^9.28.0",
|
|
33
|
+
"tsdown": "^0.12.5"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsdown",
|