@aippy/vite-plugins 0.2.8 → 0.3.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/aippy-preload/index.js +2 -147
- package/dist/aippy-preload-8BoWu90-.js +153 -0
- package/dist/aippy-tagger/index.js +2 -381
- package/dist/aippy-tagger-By5socAS.js +99 -0
- package/dist/asset-constants/index.js +2 -301
- package/dist/asset-constants-BvKclVVI.js +252 -0
- package/dist/file-scanner-DT-LbrCa.js +85 -0
- package/dist/index/index.js +5 -15
- package/dist/utils/index.js +93 -90
- package/package.json +6 -6
- package/dist/file-scanner-DSr-Ek-8.js +0 -54
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { promises as e } from "fs";
|
|
2
|
+
import t from "path";
|
|
3
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/typeof.js
|
|
4
|
+
function n(e) {
|
|
5
|
+
"@babel/helpers - typeof";
|
|
6
|
+
return n = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
7
|
+
return typeof e;
|
|
8
|
+
} : function(e) {
|
|
9
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
10
|
+
}, n(e);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPrimitive.js
|
|
14
|
+
function r(e, t) {
|
|
15
|
+
if (n(e) != "object" || !e) return e;
|
|
16
|
+
var r = e[Symbol.toPrimitive];
|
|
17
|
+
if (r !== void 0) {
|
|
18
|
+
var i = r.call(e, t || "default");
|
|
19
|
+
if (n(i) != "object") return i;
|
|
20
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
21
|
+
}
|
|
22
|
+
return (t === "string" ? String : Number)(e);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPropertyKey.js
|
|
26
|
+
function i(e) {
|
|
27
|
+
var t = r(e, "string");
|
|
28
|
+
return n(t) == "symbol" ? t : t + "";
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/defineProperty.js
|
|
32
|
+
function a(e, t, n) {
|
|
33
|
+
return (t = i(t)) in e ? Object.defineProperty(e, t, {
|
|
34
|
+
value: n,
|
|
35
|
+
enumerable: !0,
|
|
36
|
+
configurable: !0,
|
|
37
|
+
writable: !0
|
|
38
|
+
}) : e[t] = n, e;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/utils/file-scanner.ts
|
|
42
|
+
async function o(n, r) {
|
|
43
|
+
let i = [];
|
|
44
|
+
try {
|
|
45
|
+
let a = await e.readdir(n, { withFileTypes: !0 });
|
|
46
|
+
for (let e of a) {
|
|
47
|
+
let a = t.join(n, e.name);
|
|
48
|
+
if (e.isDirectory()) {
|
|
49
|
+
let e = await o(a, r);
|
|
50
|
+
i.push(...e);
|
|
51
|
+
} else if (e.isFile()) {
|
|
52
|
+
let n = t.extname(e.name);
|
|
53
|
+
r.includes(n) && i.push(a);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.warn(`Warning: Failed to read directory ${n}:`, e);
|
|
58
|
+
}
|
|
59
|
+
return i;
|
|
60
|
+
}
|
|
61
|
+
function s(e, n) {
|
|
62
|
+
let r = t.relative(t.dirname(e), n).replace(/\.(ts|tsx|js|jsx|json)$/, "");
|
|
63
|
+
return r.startsWith(".") ? r : `./${r}`;
|
|
64
|
+
}
|
|
65
|
+
function c(e, n) {
|
|
66
|
+
return `@/${t.relative(n, e).replace(/\.(ts|tsx|js|jsx|json)$/, "")}`;
|
|
67
|
+
}
|
|
68
|
+
var l = class {
|
|
69
|
+
constructor() {
|
|
70
|
+
a(this, "cache", /* @__PURE__ */ new Map());
|
|
71
|
+
}
|
|
72
|
+
async read(t) {
|
|
73
|
+
if (this.cache.has(t)) return this.cache.get(t);
|
|
74
|
+
let n = await e.readFile(t, "utf-8");
|
|
75
|
+
return this.cache.set(t, n), n;
|
|
76
|
+
}
|
|
77
|
+
invalidate(e) {
|
|
78
|
+
this.cache.delete(e);
|
|
79
|
+
}
|
|
80
|
+
clear() {
|
|
81
|
+
this.cache.clear();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
export { a, s as i, c as n, o as r, l as t };
|
package/dist/index/index.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
6
|
-
r as aippyPreloadPlugin,
|
|
7
|
-
i as aippyTaggerPlugin,
|
|
8
|
-
s as assetConstantsPlugin,
|
|
9
|
-
o as default,
|
|
10
|
-
g as extractAssetsFromContent,
|
|
11
|
-
l as findProjectRoot,
|
|
12
|
-
f as generateConstantName,
|
|
13
|
-
m as isValidAsset,
|
|
14
|
-
P as processAssetURL
|
|
15
|
-
};
|
|
1
|
+
import { extractAssetsFromContent as e, findProjectRoot as t, generateConstantName as n, isValidAsset as r, processAssetURL as i } from "../utils/index.js";
|
|
2
|
+
import { t as a } from "../asset-constants-BvKclVVI.js";
|
|
3
|
+
import { t as o } from "../aippy-preload-8BoWu90-.js";
|
|
4
|
+
import { t as s } from "../aippy-tagger-By5socAS.js";
|
|
5
|
+
export { o as aippyPreloadPlugin, s as aippyTaggerPlugin, a as assetConstantsPlugin, a as default, e as extractAssetsFromContent, t as findProjectRoot, n as generateConstantName, r as isValidAsset, i as processAssetURL };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,97 +1,100 @@
|
|
|
1
|
-
import { existsSync as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { existsSync as e } from "fs";
|
|
2
|
+
import t from "path";
|
|
3
|
+
//#region src/utils/index.ts
|
|
4
|
+
var n = [
|
|
5
|
+
".png",
|
|
6
|
+
".jpg",
|
|
7
|
+
".jpeg",
|
|
8
|
+
".gif",
|
|
9
|
+
".svg",
|
|
10
|
+
".webp"
|
|
11
|
+
], r = [
|
|
12
|
+
".mp4",
|
|
13
|
+
".webm",
|
|
14
|
+
".mov",
|
|
15
|
+
".avi"
|
|
16
|
+
], i = [
|
|
17
|
+
".mp3",
|
|
18
|
+
".wav",
|
|
19
|
+
".ogg",
|
|
20
|
+
".m4a"
|
|
21
|
+
];
|
|
22
|
+
function a(e) {
|
|
23
|
+
return e = e.trim(), e.match(/^https?:\/\//) || e.match(/^data:/) || e.match(/^blob:/), e;
|
|
6
24
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const s = e.split(".");
|
|
21
|
-
return !(s.length < 2 || s[0].length === 0 || s[s.length - 1].toLowerCase() === "json");
|
|
25
|
+
function o(e) {
|
|
26
|
+
if (!e || e.length < 4 || e.includes("node_modules") || e.startsWith("./") && e.length < 10) return !1;
|
|
27
|
+
let t;
|
|
28
|
+
if (e.match(/^https?:\/\//)) {
|
|
29
|
+
let n = e.split("?")[0].split("#")[0].split("/");
|
|
30
|
+
t = n[n.length - 1];
|
|
31
|
+
} else {
|
|
32
|
+
let n = e.split("/");
|
|
33
|
+
t = n[n.length - 1], t = t.split("?")[0].split("#")[0];
|
|
34
|
+
}
|
|
35
|
+
if (!t || t.startsWith(".")) return !1;
|
|
36
|
+
let n = t.split(".");
|
|
37
|
+
return !(n.length < 2 || n[0].length === 0 || n[n.length - 1].toLowerCase() === "json");
|
|
22
38
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
n = `${s}_${r}`;
|
|
34
|
-
} while (e.has(n));
|
|
35
|
-
return n;
|
|
39
|
+
function s(e, t = /* @__PURE__ */ new Set()) {
|
|
40
|
+
let a = "ASSET", o = e.split("?")[0].split("#")[0];
|
|
41
|
+
n.some((e) => o.endsWith(e)) ? a = "IMAGE" : r.some((e) => o.endsWith(e)) ? a = "VIDEO" : i.some((e) => o.endsWith(e)) && (a = "AUDIO");
|
|
42
|
+
let s;
|
|
43
|
+
do {
|
|
44
|
+
let e = "";
|
|
45
|
+
for (let t = 0; t < 4; t++) e += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(Math.random() * 26)];
|
|
46
|
+
s = `${a}_${e}`;
|
|
47
|
+
} while (t.has(s));
|
|
48
|
+
return s;
|
|
36
49
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
/(["'])(?:(?=(\\?))\2.)*?\1|\/\*[\s\S]*?\*\/|\/\/.*/g,
|
|
40
|
-
(s) => s.startsWith('"') || s.startsWith("'") ? s : ""
|
|
41
|
-
);
|
|
50
|
+
function c(e) {
|
|
51
|
+
return e.replace(/(["'])(?:(?=(\\?))\2.)*?\1|\/\*[\s\S]*?\*\/|\/\/.*/g, (e) => e.startsWith("\"") || e.startsWith("'") ? e : "");
|
|
42
52
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
53
|
+
function l(e) {
|
|
54
|
+
return e.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
45
55
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return Array.from(i);
|
|
56
|
+
function u(e, t, n = [
|
|
57
|
+
".js",
|
|
58
|
+
".css",
|
|
59
|
+
".png",
|
|
60
|
+
".jpg",
|
|
61
|
+
".jpeg",
|
|
62
|
+
".gif",
|
|
63
|
+
".svg",
|
|
64
|
+
".woff",
|
|
65
|
+
".woff2",
|
|
66
|
+
".ttf",
|
|
67
|
+
".eot"
|
|
68
|
+
]) {
|
|
69
|
+
let r = /* @__PURE__ */ new Set(), i = e;
|
|
70
|
+
t === "js" ? i = c(e) : t === "css" && (i = l(e));
|
|
71
|
+
let s = n.map((e) => e.replace(/^\./, "")).join("|");
|
|
72
|
+
if (t === "html") [RegExp(`(?:src|href)=["']([^"']*\\.(?:${s})(?:[?#][^"']*)?)["']`, "g"), RegExp(`url\\(["']?([^"']*\\.(?:${s})(?:[?#][^"']*)?)["']?\\)`, "g")].forEach((e) => {
|
|
73
|
+
let t;
|
|
74
|
+
for (; (t = e.exec(i)) !== null;) t[1] && o(t[1]) && r.add(a(t[1]));
|
|
75
|
+
}), (i.match(/<script[^>]*>[\s\S]*?<\/script>/g) || []).forEach((e) => {
|
|
76
|
+
u(e.replace(/<script[^>]*>/, "").replace(/<\/script>/, ""), "js", n).forEach((e) => r.add(e));
|
|
77
|
+
});
|
|
78
|
+
else if (t === "js") {
|
|
79
|
+
let e = RegExp(`["']([^"']*\\.(?:${s})(?:[?#][^"']*)?)["']`, "g"), t;
|
|
80
|
+
for (; (t = e.exec(i)) !== null;) t[1] && o(t[1]) && r.add(a(t[1]));
|
|
81
|
+
} else if (t === "css") {
|
|
82
|
+
let e = RegExp(`url\\(["']?([^"']*\\.(?:${s})(?:[?#][^"']*)?)["']?\\)`, "g"), t;
|
|
83
|
+
for (; (t = e.exec(i)) !== null;) t[1] && o(t[1]) && r.add(a(t[1]));
|
|
84
|
+
}
|
|
85
|
+
return Array.from(r);
|
|
77
86
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
87
|
+
function d(n = process.cwd()) {
|
|
88
|
+
try {
|
|
89
|
+
let r = n, i = 0;
|
|
90
|
+
for (; r !== t.parse(r).root && i < 20;) {
|
|
91
|
+
if (e(t.join(r, "package.json"))) return r;
|
|
92
|
+
r = t.dirname(r), i++;
|
|
93
|
+
}
|
|
94
|
+
return process.cwd();
|
|
95
|
+
} catch (e) {
|
|
96
|
+
return console.error("Error finding project root:", e), process.cwd();
|
|
97
|
+
}
|
|
90
98
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
C as findProjectRoot,
|
|
94
|
-
I as generateConstantName,
|
|
95
|
-
h as isValidAsset,
|
|
96
|
-
p as processAssetURL
|
|
97
|
-
};
|
|
99
|
+
//#endregion
|
|
100
|
+
export { u as extractAssetsFromContent, d as findProjectRoot, s as generateConstantName, o as isValidAsset, a as processAssetURL };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aippy/vite-plugins",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Vite plugins for Aippy projects - Asset management and component tagging",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -71,14 +71,14 @@
|
|
|
71
71
|
"eslint": "^9.36.0",
|
|
72
72
|
"prettier": "^3.6.2",
|
|
73
73
|
"typescript": "^5.9.2",
|
|
74
|
-
"vite": "^
|
|
74
|
+
"vite": "^8.0.0",
|
|
75
75
|
"vite-plugin-dts": "^4.5.4"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"vite": "^
|
|
78
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
|
-
"node": "
|
|
81
|
+
"node": "^20.19.0 || >=22.12.0",
|
|
82
82
|
"pnpm": ">=10.0.0"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"audit:fix": "pnpm audit --fix",
|
|
102
102
|
"security:check": "pnpm audit && pnpm outdated",
|
|
103
103
|
"prerelease": "pnpm run audit && pnpm run type-check && pnpm run lint && pnpm run build",
|
|
104
|
-
"release:dry": "
|
|
105
|
-
"test:build": "node -e \"
|
|
104
|
+
"release:dry": "pnpm publish --dry-run",
|
|
105
|
+
"test:build": "node -e \"import('./dist/index/index.js')\""
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
};
|