kerria 0.2.4 → 0.3.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/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -40,16 +40,16 @@ declare function useSource<C extends object>(kind: number, options: UseSourceOpt
|
|
|
40
40
|
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/core/processor.d.ts
|
|
43
|
-
interface
|
|
43
|
+
interface KerriaContext {
|
|
44
44
|
sign: string;
|
|
45
45
|
loadInfos: LoadInfo[];
|
|
46
46
|
sourceInfos: SourceInfo[];
|
|
47
47
|
}
|
|
48
|
-
declare function useCurrentContext():
|
|
49
|
-
declare function
|
|
48
|
+
declare function useCurrentContext(): KerriaContext;
|
|
49
|
+
declare function createKerria(sign: string, setup: (ctx: KerriaContext) => void): {
|
|
50
50
|
build: () => Promise<void>;
|
|
51
51
|
watch: () => Promise<void>;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
//#endregion
|
|
55
|
-
export { LoadInfo, SourceInfo, UseLoadOptions,
|
|
55
|
+
export { LoadInfo, SourceInfo, UseLoadOptions, createKerria, useCurrentContext, useLoad, useSource };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync,
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
4
4
|
import chokidar from "chokidar";
|
|
5
5
|
import consola from "consola";
|
|
@@ -38,7 +38,7 @@ let currentContext = null;
|
|
|
38
38
|
function useCurrentContext() {
|
|
39
39
|
return currentContext;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function createKerria(sign, setup) {
|
|
42
42
|
const ctx = {
|
|
43
43
|
sign,
|
|
44
44
|
loadInfos: [],
|
|
@@ -122,7 +122,7 @@ function createProcessor(sign, setup) {
|
|
|
122
122
|
}
|
|
123
123
|
function outputLoads() {
|
|
124
124
|
if (isDev) writeJsonSync(cachePath, caches);
|
|
125
|
-
else
|
|
125
|
+
else rmSync(cachePath, { force: true });
|
|
126
126
|
for (const info of ctx.loadInfos) info.output();
|
|
127
127
|
}
|
|
128
128
|
return {
|
|
@@ -185,4 +185,4 @@ function useSource(kind, options) {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
//#endregion
|
|
188
|
-
export {
|
|
188
|
+
export { createKerria, useCurrentContext, useLoad, useSource };
|