@aippy/vite-plugins 0.2.8 → 0.2.9-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.
@@ -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 };
@@ -1,15 +1,5 @@
1
- import { assetConstantsPlugin as s, assetConstantsPlugin as o } from "../asset-constants/index.js";
2
- import { aippyPreloadPlugin as r } from "../aippy-preload/index.js";
3
- import { aippyTaggerPlugin as i } from "../aippy-tagger/index.js";
4
- import { extractAssetsFromContent as g, findProjectRoot as l, generateConstantName as f, isValidAsset as m, processAssetURL as P } from "../utils/index.js";
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 };
@@ -1,97 +1,100 @@
1
- import { existsSync as m } from "fs";
2
- import f from "path";
3
- const g = [".png", ".jpg", ".jpeg", ".gif", ".svg", ".webp"], d = [".mp4", ".webm", ".mov", ".avi"], w = [".mp3", ".wav", ".ogg", ".m4a"];
4
- function p(t) {
5
- return t = t.trim(), t.match(/^https?:\/\//) || t.match(/^data:/) || t.match(/^blob:/), t;
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 h(t) {
8
- if (!t || t.length < 4 || t.includes("node_modules") || t.startsWith("./") && t.length < 10)
9
- return !1;
10
- let e;
11
- if (t.match(/^https?:\/\//)) {
12
- const c = t.split("?")[0].split("#")[0].split("/");
13
- e = c[c.length - 1];
14
- } else {
15
- const n = t.split("/");
16
- e = n[n.length - 1], e = e.split("?")[0].split("#")[0];
17
- }
18
- if (!e || e.startsWith("."))
19
- return !1;
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 I(t, e = /* @__PURE__ */ new Set()) {
24
- let s = "ASSET";
25
- const i = t.split("?")[0].split("#")[0];
26
- g.some((r) => i.endsWith(r)) ? s = "IMAGE" : d.some((r) => i.endsWith(r)) ? s = "VIDEO" : w.some((r) => i.endsWith(r)) && (s = "AUDIO");
27
- let n;
28
- const c = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
29
- do {
30
- let r = "";
31
- for (let o = 0; o < 4; o++)
32
- r += c[Math.floor(Math.random() * c.length)];
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 E(t) {
38
- return t.replace(
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 S(t) {
44
- return t.replace(/\/\*[\s\S]*?\*\//g, "");
53
+ function l(e) {
54
+ return e.replace(/\/\*[\s\S]*?\*\//g, "");
45
55
  }
46
- function j(t, e, s = [".js", ".css", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".woff", ".woff2", ".ttf", ".eot"]) {
47
- const i = /* @__PURE__ */ new Set();
48
- let n = t;
49
- e === "js" ? n = E(t) : e === "css" && (n = S(t));
50
- const c = s.map((r) => r.replace(/^\./, "")).join("|");
51
- if (e === "html")
52
- [
53
- // src/href attributes for img, script, link, video, audio tags
54
- new RegExp(`(?:src|href)=["']([^"']*\\.(?:${c})(?:[?#][^"']*)?)["']`, "g"),
55
- // url() in CSS
56
- new RegExp(`url\\(["']?([^"']*\\.(?:${c})(?:[?#][^"']*)?)["']?\\)`, "g")
57
- ].forEach((a) => {
58
- let l;
59
- for (; (l = a.exec(n)) !== null; )
60
- l[1] && h(l[1]) && i.add(p(l[1]));
61
- }), (n.match(/<script[^>]*>[\s\S]*?<\/script>/g) || []).forEach((a) => {
62
- const l = a.replace(/<script[^>]*>/, "").replace(/<\/script>/, "");
63
- j(l, "js", s).forEach((u) => i.add(u));
64
- });
65
- else if (e === "js") {
66
- const r = new RegExp(`["']([^"']*\\.(?:${c})(?:[?#][^"']*)?)["']`, "g");
67
- let o;
68
- for (; (o = r.exec(n)) !== null; )
69
- o[1] && h(o[1]) && i.add(p(o[1]));
70
- } else if (e === "css") {
71
- const r = new RegExp(`url\\(["']?([^"']*\\.(?:${c})(?:[?#][^"']*)?)["']?\\)`, "g");
72
- let o;
73
- for (; (o = r.exec(n)) !== null; )
74
- o[1] && h(o[1]) && i.add(p(o[1]));
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 C(t = process.cwd()) {
79
- try {
80
- let e = t, s = 0;
81
- for (; e !== f.parse(e).root && s < 20; ) {
82
- if (m(f.join(e, "package.json")))
83
- return e;
84
- e = f.dirname(e), s++;
85
- }
86
- return process.cwd();
87
- } catch (e) {
88
- return console.error("Error finding project root:", e), process.cwd();
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
- export {
92
- j as extractAssetsFromContent,
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.2.8",
3
+ "version": "0.2.9-dev.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": "^7.1.7",
74
+ "vite": "^8.0.0",
75
75
  "vite-plugin-dts": "^4.5.4"
76
76
  },
77
77
  "peerDependencies": {
78
- "vite": "^7.0.0 || ^6.0.0 || ^5.0.0"
78
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
79
79
  },
80
80
  "engines": {
81
- "node": ">=20.0.0",
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": "npm publish --dry-run",
105
- "test:build": "node -e \"require('./dist/index.js')\""
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
- };