@aippy/vite-plugins 0.2.7-dev.1 → 0.2.8-dev.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { promises as c } from "fs";
|
|
2
2
|
import u from "path";
|
|
3
3
|
import { extractAssetsFromContent as a } from "../utils/index.js";
|
|
4
|
-
import { g as l } from "../file-scanner-
|
|
4
|
+
import { g as l } from "../file-scanner-DSr-Ek-8.js";
|
|
5
5
|
async function p(t) {
|
|
6
6
|
const s = [], n = [u.join(process.cwd(), "index.html")];
|
|
7
7
|
for (const e of n)
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
var
|
|
2
|
-
var I = (i, s, t) => s in i ?
|
|
3
|
-
var
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var I = (i, s, t) => s in i ? E(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t;
|
|
3
|
+
var w = (i, s, t) => I(i, typeof s != "symbol" ? s + "" : s, t);
|
|
4
4
|
import { promises as g } from "fs";
|
|
5
5
|
import h from "path";
|
|
6
|
-
import { parse as
|
|
7
|
-
import
|
|
6
|
+
import { parse as $ } from "@babel/parser";
|
|
7
|
+
import F from "@babel/traverse";
|
|
8
8
|
import * as p from "@babel/types";
|
|
9
|
-
import
|
|
10
|
-
import { generateConstantName as
|
|
11
|
-
import { F as
|
|
12
|
-
function
|
|
9
|
+
import A from "@babel/generator";
|
|
10
|
+
import { generateConstantName as W, extractAssetsFromContent as S, processAssetURL as T } from "../utils/index.js";
|
|
11
|
+
import { F as b, g as x, a as N, b as y } from "../file-scanner-DSr-Ek-8.js";
|
|
12
|
+
function R(i, s) {
|
|
13
13
|
const t = {};
|
|
14
|
-
for (const [
|
|
15
|
-
t[
|
|
16
|
-
return Array.from(i.values()).forEach((
|
|
17
|
-
t[
|
|
14
|
+
for (const [a, o] of s.entries())
|
|
15
|
+
t[o] = a;
|
|
16
|
+
return Array.from(i.values()).forEach((a) => {
|
|
17
|
+
t[a.constantName] = a.originalUri;
|
|
18
18
|
}), JSON.stringify(t, null, 2) + `
|
|
19
19
|
`;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function O(i) {
|
|
22
22
|
const s = /* @__PURE__ */ new Map();
|
|
23
23
|
try {
|
|
24
24
|
if (!i.trim())
|
|
25
25
|
return s;
|
|
26
26
|
const t = JSON.parse(i);
|
|
27
|
-
for (const [e,
|
|
28
|
-
typeof
|
|
27
|
+
for (const [e, a] of Object.entries(t))
|
|
28
|
+
typeof a == "string" && s.set(a, e);
|
|
29
29
|
s.size > 0 && console.log(`📋 Found ${s.size} existing constants in assets.json`);
|
|
30
30
|
} catch (t) {
|
|
31
31
|
console.warn("Warning: Failed to parse existing assets.json:", t);
|
|
32
32
|
}
|
|
33
33
|
return s;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
const
|
|
37
|
-
(
|
|
38
|
-
).length,
|
|
39
|
-
|
|
35
|
+
function J(i, s, t, e) {
|
|
36
|
+
const a = Array.from(t.values()).filter(
|
|
37
|
+
(n) => s.has(n.originalUri)
|
|
38
|
+
).length, o = i - a;
|
|
39
|
+
o > 0 ? console.log(`✅ Generated ${i} asset constants (${o} new, ${a} reused) in ${e}`) : i > 0 ? console.log(`✅ Generated ${i} asset constants (all reused from existing) in ${e}`) : console.log("✅ No asset constants found");
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
class
|
|
41
|
+
const C = typeof F == "function" ? F : F.default, U = typeof A == "function" ? A : A.default;
|
|
42
|
+
class P {
|
|
43
43
|
constructor(s = {}) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
w(this, "options");
|
|
45
|
+
w(this, "assets", /* @__PURE__ */ new Map());
|
|
46
|
+
w(this, "existingAssets", /* @__PURE__ */ new Map());
|
|
47
|
+
w(this, "fileCache", new b());
|
|
48
48
|
this.options = {
|
|
49
49
|
extensions: [".png", ".jpg", ".jpeg", ".gif", ".svg", ".mp4", ".mp3", ".wav", ".ogg", ".webm"],
|
|
50
50
|
srcDir: "src",
|
|
@@ -61,16 +61,16 @@ class O {
|
|
|
61
61
|
...Array.from(this.assets.values()).map((e) => e.constantName),
|
|
62
62
|
...Array.from(this.existingAssets.values())
|
|
63
63
|
]);
|
|
64
|
-
return
|
|
64
|
+
return W(s, t);
|
|
65
65
|
}
|
|
66
66
|
async scanTsFile(s) {
|
|
67
67
|
try {
|
|
68
|
-
const t = await this.fileCache.read(s), e = [],
|
|
68
|
+
const t = await this.fileCache.read(s), e = [], a = S(t, "js", this.options.extensions), o = t.split(`
|
|
69
69
|
`);
|
|
70
|
-
return
|
|
71
|
-
const r = this.generateConstantName(
|
|
70
|
+
return a.forEach((n) => {
|
|
71
|
+
const r = this.generateConstantName(n), c = o.findIndex((u) => u.includes(n)) + 1;
|
|
72
72
|
e.push({
|
|
73
|
-
originalUri:
|
|
73
|
+
originalUri: n,
|
|
74
74
|
constantName: r,
|
|
75
75
|
filePath: s,
|
|
76
76
|
line: c,
|
|
@@ -84,14 +84,14 @@ class O {
|
|
|
84
84
|
async scanAllTsFiles() {
|
|
85
85
|
const s = this.options.srcDir;
|
|
86
86
|
try {
|
|
87
|
-
const t = await
|
|
87
|
+
const t = await x(s, [".ts", ".tsx"]);
|
|
88
88
|
for (const e of t) {
|
|
89
89
|
if (e.endsWith("assets.json") || e.endsWith("assets.ts"))
|
|
90
90
|
continue;
|
|
91
|
-
(await this.scanTsFile(e)).forEach((
|
|
92
|
-
this.existingAssets.has(
|
|
93
|
-
const
|
|
94
|
-
this.assets.has(
|
|
91
|
+
(await this.scanTsFile(e)).forEach((o) => {
|
|
92
|
+
this.existingAssets.has(o.originalUri) && (o.constantName = this.existingAssets.get(o.originalUri));
|
|
93
|
+
const n = o.originalUri;
|
|
94
|
+
this.assets.has(n) || this.assets.set(n, o);
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
} catch (t) {
|
|
@@ -107,12 +107,12 @@ class O {
|
|
|
107
107
|
}
|
|
108
108
|
async parseExistingAssets() {
|
|
109
109
|
const s = await this.readExistingAssetsFile();
|
|
110
|
-
this.existingAssets =
|
|
110
|
+
this.existingAssets = O(s);
|
|
111
111
|
}
|
|
112
112
|
async generateAssetsFile() {
|
|
113
113
|
await this.parseExistingAssets(), await this.scanAllTsFiles();
|
|
114
|
-
const s =
|
|
115
|
-
await g.mkdir(t, { recursive: !0 }), await g.writeFile(this.options.outputFile, s, "utf-8"), await this.generateAssetsWrapper(),
|
|
114
|
+
const s = R(this.assets, this.existingAssets), t = h.dirname(this.options.outputFile);
|
|
115
|
+
await g.mkdir(t, { recursive: !0 }), await g.writeFile(this.options.outputFile, s, "utf-8"), await this.generateAssetsWrapper(), J(this.assets.size, this.existingAssets, this.assets, this.options.outputFile);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* 生成 assets.ts 包装文件
|
|
@@ -136,46 +136,46 @@ export default assetsData;
|
|
|
136
136
|
}
|
|
137
137
|
async replaceUrisInFile(s, t) {
|
|
138
138
|
try {
|
|
139
|
-
const e = await this.fileCache.read(s),
|
|
139
|
+
const e = await this.fileCache.read(s), a = $(e, {
|
|
140
140
|
sourceType: "module",
|
|
141
141
|
plugins: ["typescript", "jsx", "decorators-legacy"]
|
|
142
142
|
});
|
|
143
|
-
let
|
|
144
|
-
if (
|
|
143
|
+
let o = !1;
|
|
144
|
+
if (C(a, {
|
|
145
145
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
146
|
StringLiteral: (l) => {
|
|
147
|
-
const m = l.node.value,
|
|
148
|
-
if (t.has(
|
|
149
|
-
const
|
|
147
|
+
const m = l.node.value, v = T(m);
|
|
148
|
+
if (t.has(v)) {
|
|
149
|
+
const D = t.get(v), j = p.memberExpression(
|
|
150
150
|
p.identifier("assetsData"),
|
|
151
|
-
p.identifier(
|
|
151
|
+
p.identifier(D)
|
|
152
152
|
);
|
|
153
|
-
l.parent && p.isJSXAttribute(l.parent) ? l.replaceWith(p.jsxExpressionContainer(j)) : l.replaceWith(j),
|
|
153
|
+
l.parent && p.isJSXAttribute(l.parent) ? l.replaceWith(p.jsxExpressionContainer(j)) : l.replaceWith(j), o = !0;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
}), !
|
|
156
|
+
}), !o)
|
|
157
157
|
return;
|
|
158
|
-
const
|
|
159
|
-
let
|
|
160
|
-
if (
|
|
158
|
+
const n = this.options.outputFile.replace(/\.json$/, ".ts"), r = N(n, this.options.srcDir), c = y(s, n), d = y(s, this.options.outputFile) + ".json";
|
|
159
|
+
let u = !1;
|
|
160
|
+
if (C(a, {
|
|
161
161
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
162
|
ImportDeclaration: (l) => {
|
|
163
163
|
const m = l.node.source.value;
|
|
164
|
-
(m === r || m === c) && (
|
|
164
|
+
(m === r || m === c || m === d) && (u = !0, l.stop());
|
|
165
165
|
}
|
|
166
|
-
}), !
|
|
166
|
+
}), !u) {
|
|
167
167
|
const l = p.importDeclaration(
|
|
168
168
|
[p.importDefaultSpecifier(p.identifier("assetsData"))],
|
|
169
169
|
p.stringLiteral(r)
|
|
170
170
|
);
|
|
171
|
-
|
|
171
|
+
a.program.body.unshift(l);
|
|
172
172
|
}
|
|
173
|
-
const
|
|
173
|
+
const f = U(a, {
|
|
174
174
|
retainLines: !1,
|
|
175
175
|
comments: !0,
|
|
176
176
|
compact: !1
|
|
177
177
|
}, e);
|
|
178
|
-
await g.writeFile(s,
|
|
178
|
+
await g.writeFile(s, f.code, "utf-8"), this.fileCache.invalidate(s), console.log(` ✓ Replaced URIs in ${h.relative(process.cwd(), s)}`);
|
|
179
179
|
} catch (e) {
|
|
180
180
|
console.warn(`Warning: Failed to replace URIs in ${s}:`, e);
|
|
181
181
|
}
|
|
@@ -194,38 +194,38 @@ export default assetsData;
|
|
|
194
194
|
return;
|
|
195
195
|
const t = /* @__PURE__ */ new Map();
|
|
196
196
|
try {
|
|
197
|
-
const
|
|
198
|
-
for (const [r, c] of Object.entries(
|
|
197
|
+
const n = JSON.parse(s);
|
|
198
|
+
for (const [r, c] of Object.entries(n))
|
|
199
199
|
typeof c == "string" && t.set(r, c);
|
|
200
|
-
} catch (
|
|
201
|
-
console.warn("Warning: Failed to parse assets.json:",
|
|
200
|
+
} catch (n) {
|
|
201
|
+
console.warn("Warning: Failed to parse assets.json:", n);
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
if (t.size === 0)
|
|
205
205
|
return;
|
|
206
|
-
const e = /* @__PURE__ */ new Set(),
|
|
207
|
-
for (const
|
|
208
|
-
if (!(
|
|
206
|
+
const e = /* @__PURE__ */ new Set(), a = await x(this.options.srcDir, [".ts", ".tsx"]);
|
|
207
|
+
for (const n of a)
|
|
208
|
+
if (!(n.endsWith("assets.json") || n.endsWith("assets.ts")))
|
|
209
209
|
try {
|
|
210
|
-
const r = await this.fileCache.read(
|
|
210
|
+
const r = await this.fileCache.read(n);
|
|
211
211
|
for (const c of t.keys())
|
|
212
212
|
r.includes(c) && e.add(c);
|
|
213
213
|
} catch (r) {
|
|
214
|
-
console.warn(`Warning: Failed to read ${
|
|
214
|
+
console.warn(`Warning: Failed to read ${n}:`, r);
|
|
215
215
|
}
|
|
216
|
-
const
|
|
217
|
-
for (const
|
|
218
|
-
e.has(
|
|
219
|
-
if (
|
|
220
|
-
console.log(`🧹 Removing ${
|
|
216
|
+
const o = [];
|
|
217
|
+
for (const n of t.keys())
|
|
218
|
+
e.has(n) || o.push(n);
|
|
219
|
+
if (o.length > 0) {
|
|
220
|
+
console.log(`🧹 Removing ${o.length} unused constant(s):`), o.forEach((r) => {
|
|
221
221
|
console.log(` - ${r}`);
|
|
222
222
|
});
|
|
223
|
-
const
|
|
224
|
-
for (const r of
|
|
223
|
+
const n = [];
|
|
224
|
+
for (const r of o) {
|
|
225
225
|
const c = t.get(r);
|
|
226
|
-
c &&
|
|
226
|
+
c && n.push(c);
|
|
227
227
|
}
|
|
228
|
-
for (const r of
|
|
228
|
+
for (const r of n)
|
|
229
229
|
this.assets.delete(r);
|
|
230
230
|
} else
|
|
231
231
|
console.log("✅ All constants are in use");
|
|
@@ -234,43 +234,43 @@ export default assetsData;
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
237
|
-
* 🍎
|
|
238
|
-
* 解决旧项目中已经使用 assets.json 的情况
|
|
237
|
+
* 🍎 升级现有的相对路径或 .json 导入为 @/ 别名的 .ts 包装文件导入
|
|
239
238
|
*/
|
|
240
239
|
async upgradeJsonImportsToTs() {
|
|
241
|
-
const s = this.options.outputFile.replace(/\.json$/, ".ts"), t = await
|
|
242
|
-
let
|
|
243
|
-
for (const
|
|
244
|
-
if (!(
|
|
240
|
+
const s = this.options.outputFile.replace(/\.json$/, ".ts"), t = N(s, this.options.srcDir), e = await x(this.options.srcDir, [".ts", ".tsx"]);
|
|
241
|
+
let a = 0;
|
|
242
|
+
for (const o of e)
|
|
243
|
+
if (!(o.endsWith("assets.ts") || o.endsWith("assets.json")))
|
|
245
244
|
try {
|
|
246
|
-
const
|
|
247
|
-
if (!
|
|
245
|
+
const n = await this.fileCache.read(o), r = y(o, this.options.outputFile) + ".json", c = y(o, s);
|
|
246
|
+
if (!n.includes(r) && !n.includes(c))
|
|
248
247
|
continue;
|
|
249
|
-
const
|
|
248
|
+
const d = $(n, {
|
|
250
249
|
sourceType: "module",
|
|
251
250
|
plugins: ["typescript", "jsx", "decorators-legacy"]
|
|
252
251
|
});
|
|
253
|
-
let
|
|
254
|
-
if (
|
|
252
|
+
let u = !1;
|
|
253
|
+
if (C(d, {
|
|
255
254
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
256
|
-
ImportDeclaration: (
|
|
257
|
-
|
|
255
|
+
ImportDeclaration: (f) => {
|
|
256
|
+
const l = f.node.source.value;
|
|
257
|
+
(l === r || l === c) && (f.node.source.value = t, u = !0);
|
|
258
258
|
}
|
|
259
|
-
}),
|
|
260
|
-
const
|
|
259
|
+
}), u) {
|
|
260
|
+
const f = U(d, {
|
|
261
261
|
retainLines: !1,
|
|
262
262
|
comments: !0,
|
|
263
263
|
compact: !1
|
|
264
|
-
},
|
|
265
|
-
await g.writeFile(
|
|
264
|
+
}, n);
|
|
265
|
+
await g.writeFile(o, f.code, "utf-8"), this.fileCache.invalidate(o), console.log(` ✓ Upgraded import in ${h.relative(process.cwd(), o)} → ${t}`), a++;
|
|
266
266
|
}
|
|
267
|
-
} catch (
|
|
268
|
-
console.warn(`Warning: Failed to upgrade imports in ${
|
|
267
|
+
} catch (n) {
|
|
268
|
+
console.warn(`Warning: Failed to upgrade imports in ${o}:`, n);
|
|
269
269
|
}
|
|
270
|
-
|
|
270
|
+
a > 0 && console.log(`✅ Upgraded ${a} file(s) to use ${t}`);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
function
|
|
273
|
+
function X(i = {}) {
|
|
274
274
|
return {
|
|
275
275
|
name: "vite-plugin-asset-constants",
|
|
276
276
|
apply: "build",
|
|
@@ -279,7 +279,7 @@ function q(i = {}) {
|
|
|
279
279
|
async buildStart() {
|
|
280
280
|
if (i.devMode)
|
|
281
281
|
try {
|
|
282
|
-
const s = new
|
|
282
|
+
const s = new P(i);
|
|
283
283
|
await s.generateAssetsFile();
|
|
284
284
|
const t = s.getAssets();
|
|
285
285
|
t.length > 0 && (console.log(`📦 Found ${t.length} asset references:`), t.forEach((e) => {
|
|
@@ -296,6 +296,6 @@ function q(i = {}) {
|
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
298
|
export {
|
|
299
|
-
|
|
300
|
-
|
|
299
|
+
X as assetConstantsPlugin,
|
|
300
|
+
X as default
|
|
301
301
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var u = (e, t, s) => t in e ? h(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var o = (e, t, s) => u(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
import { promises as l } from "fs";
|
|
5
|
+
import r from "path";
|
|
6
|
+
async function p(e, t) {
|
|
7
|
+
const s = [];
|
|
8
|
+
try {
|
|
9
|
+
const a = await l.readdir(e, { withFileTypes: !0 });
|
|
10
|
+
for (const i of a) {
|
|
11
|
+
const c = r.join(e, i.name);
|
|
12
|
+
if (i.isDirectory()) {
|
|
13
|
+
const n = await p(c, t);
|
|
14
|
+
s.push(...n);
|
|
15
|
+
} else if (i.isFile()) {
|
|
16
|
+
const n = r.extname(i.name);
|
|
17
|
+
t.includes(n) && s.push(c);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
} catch (a) {
|
|
21
|
+
console.warn(`Warning: Failed to read directory ${e}:`, a);
|
|
22
|
+
}
|
|
23
|
+
return s;
|
|
24
|
+
}
|
|
25
|
+
function d(e, t) {
|
|
26
|
+
const a = r.relative(r.dirname(e), t).replace(/\.(ts|tsx|js|jsx|json)$/, "");
|
|
27
|
+
return a.startsWith(".") ? a : `./${a}`;
|
|
28
|
+
}
|
|
29
|
+
function w(e, t) {
|
|
30
|
+
return `@/${r.relative(t, e).replace(/\.(ts|tsx|js|jsx|json)$/, "")}`;
|
|
31
|
+
}
|
|
32
|
+
class y {
|
|
33
|
+
constructor() {
|
|
34
|
+
o(this, "cache", /* @__PURE__ */ new Map());
|
|
35
|
+
}
|
|
36
|
+
async read(t) {
|
|
37
|
+
if (this.cache.has(t))
|
|
38
|
+
return this.cache.get(t);
|
|
39
|
+
const s = await l.readFile(t, "utf-8");
|
|
40
|
+
return this.cache.set(t, s), s;
|
|
41
|
+
}
|
|
42
|
+
invalidate(t) {
|
|
43
|
+
this.cache.delete(t);
|
|
44
|
+
}
|
|
45
|
+
clear() {
|
|
46
|
+
this.cache.clear();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
y as F,
|
|
51
|
+
w as a,
|
|
52
|
+
d as b,
|
|
53
|
+
p as g
|
|
54
|
+
};
|
|
@@ -15,6 +15,11 @@ export declare function getFilesByExtension(dir: string, extensions: string[]):
|
|
|
15
15
|
* @returns Relative import path (without extension)
|
|
16
16
|
*/
|
|
17
17
|
export declare function getRelativeImportPath(fromFile: string, toFile: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Convert a file path under srcDir to a `@/`-prefixed alias import path.
|
|
20
|
+
* E.g. `src/config/assets.ts` with srcDir=`src` → `@/config/assets`
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAliasImportPath(filePath: string, srcDir: string): string;
|
|
18
23
|
/**
|
|
19
24
|
* Read file with caching support
|
|
20
25
|
*/
|
package/package.json
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
var l = Object.defineProperty;
|
|
2
|
-
var u = (e, t, a) => t in e ? l(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
|
|
3
|
-
var o = (e, t, a) => u(e, typeof t != "symbol" ? t + "" : t, a);
|
|
4
|
-
import { promises as h } from "fs";
|
|
5
|
-
import i from "path";
|
|
6
|
-
async function f(e, t) {
|
|
7
|
-
const a = [];
|
|
8
|
-
try {
|
|
9
|
-
const s = await h.readdir(e, { withFileTypes: !0 });
|
|
10
|
-
for (const r of s) {
|
|
11
|
-
const c = i.join(e, r.name);
|
|
12
|
-
if (r.isDirectory()) {
|
|
13
|
-
const n = await f(c, t);
|
|
14
|
-
a.push(...n);
|
|
15
|
-
} else if (r.isFile()) {
|
|
16
|
-
const n = i.extname(r.name);
|
|
17
|
-
t.includes(n) && a.push(c);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
} catch (s) {
|
|
21
|
-
console.warn(`Warning: Failed to read directory ${e}:`, s);
|
|
22
|
-
}
|
|
23
|
-
return a;
|
|
24
|
-
}
|
|
25
|
-
function y(e, t) {
|
|
26
|
-
const s = i.relative(i.dirname(e), t).replace(/\.(ts|tsx|js|jsx|json)$/, "");
|
|
27
|
-
return s.startsWith(".") ? s : `./${s}`;
|
|
28
|
-
}
|
|
29
|
-
class F {
|
|
30
|
-
constructor() {
|
|
31
|
-
o(this, "cache", /* @__PURE__ */ new Map());
|
|
32
|
-
}
|
|
33
|
-
async read(t) {
|
|
34
|
-
if (this.cache.has(t))
|
|
35
|
-
return this.cache.get(t);
|
|
36
|
-
const a = await h.readFile(t, "utf-8");
|
|
37
|
-
return this.cache.set(t, a), a;
|
|
38
|
-
}
|
|
39
|
-
invalidate(t) {
|
|
40
|
-
this.cache.delete(t);
|
|
41
|
-
}
|
|
42
|
-
clear() {
|
|
43
|
-
this.cache.clear();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
F,
|
|
48
|
-
y as a,
|
|
49
|
-
f as g
|
|
50
|
-
};
|