@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.
@@ -1,147 +1,2 @@
1
- import { promises as c } from "fs";
2
- import u from "path";
3
- import { extractAssetsFromContent as a } from "../utils/index.js";
4
- import { g as l } from "../file-scanner-DSr-Ek-8.js";
5
- async function p(t) {
6
- const s = [], n = [u.join(process.cwd(), "index.html")];
7
- for (const e of n)
8
- try {
9
- const o = await c.readFile(e, "utf-8"), r = a(o, "html", t);
10
- s.push(...r);
11
- } catch {
12
- console.warn("⚠️ No index.html found in project root");
13
- }
14
- return s;
15
- }
16
- async function g(t, s) {
17
- const n = [], e = await l(t, [".ts", ".tsx", ".js", ".jsx"]);
18
- for (const o of e)
19
- try {
20
- const r = await c.readFile(o, "utf-8"), i = a(r, "js", s);
21
- n.push(...i);
22
- } catch (r) {
23
- console.warn(`⚠️ Failed to read JS file: ${o}`, r);
24
- }
25
- return n;
26
- }
27
- async function m(t, s) {
28
- const n = [], e = await l(t, [".css", ".scss", ".sass", ".less"]);
29
- for (const o of e)
30
- try {
31
- const r = await c.readFile(o, "utf-8"), i = a(r, "css", s);
32
- n.push(...i);
33
- } catch (r) {
34
- console.warn(`⚠️ Failed to read CSS file: ${o}`, r);
35
- }
36
- return n;
37
- }
38
- async function h(t, s) {
39
- const n = [], e = await l(t, [".json"]);
40
- for (const o of e)
41
- try {
42
- const r = await c.readFile(o, "utf-8"), i = a(r, "js", s);
43
- n.push(...i);
44
- } catch (r) {
45
- console.warn(`⚠️ Failed to read JSON file: ${o}`, r);
46
- }
47
- return n;
48
- }
49
- async function w(t, s, n) {
50
- console.log("🔍 Scanning source files for static assets...");
51
- const e = [];
52
- if (n) {
53
- console.log("🔍 Deep scanning source file contents...");
54
- const [o, r, i, d] = await Promise.all([
55
- p(s),
56
- g(t, s),
57
- m(t, s),
58
- h(t, s)
59
- ]);
60
- e.push(...o, ...r, ...i, ...d);
61
- }
62
- return [...new Set(e)];
63
- }
64
- const f = "<head>", j = f.length;
65
- function F(t) {
66
- return t.map((s) => ` <meta content="${s}" name="aippy:preload">`).join(`
67
- `);
68
- }
69
- function y(t, s) {
70
- const n = t.indexOf(f);
71
- if (n === -1)
72
- throw new Error("Could not find <head> tag in HTML");
73
- const e = n + j;
74
- return t.slice(0, e) + `
75
- ` + s + `
76
- ` + t.slice(e);
77
- }
78
- function A(t) {
79
- const s = t.length;
80
- if (console.log(`📁 Found ${s} static ${s === 1 ? "asset" : "assets"} in source files`), s === 0) {
81
- console.log("⚠️ No static assets found in source files.");
82
- return;
83
- }
84
- console.log(`📋 ${s === 1 ? "Asset" : "Assets"} found:`), t.forEach((n) => console.log(` - ${n}`));
85
- }
86
- function E(t) {
87
- console.log(`✅ Injected ${t} preload meta ${t === 1 ? "tag" : "tags"} into index.html`);
88
- }
89
- const $ = 3, S = 1e3;
90
- function x(t) {
91
- return new Promise((s) => setTimeout(s, t));
92
- }
93
- async function T(t, s = $, n = S) {
94
- for (let e = 1; e <= s; e++)
95
- try {
96
- return await c.readFile(t, "utf-8");
97
- } catch (o) {
98
- if (o.code === "ENOENT") {
99
- if (e < s) {
100
- console.log(`⏳ index.html not found, waiting ${n}ms before retry (attempt ${e}/${s})...`), await x(n);
101
- continue;
102
- }
103
- return console.log(`⚠️ index.html not found after ${s} attempts, skipping preload injection.`), null;
104
- } else
105
- return console.error("❌ Error reading index.html:", o), null;
106
- }
107
- return null;
108
- }
109
- function P(t = {}) {
110
- const s = {
111
- extensions: [".png", ".jpg", ".jpeg", ".gif", ".svg", ".mp4", ".mp3", ".wav", ".ogg", ".webm"],
112
- srcDir: "src",
113
- outDir: "dist",
114
- deepScan: !0,
115
- ...t
116
- };
117
- return {
118
- name: "vite-plugin-aippy-preload",
119
- apply: "build",
120
- // Ensure this plugin runs after other plugins (like viteSingleFile)
121
- enforce: "post",
122
- // Use writeBundle instead of closeBundle for more reliable execution order
123
- // writeBundle is called sequentially after files are written, respecting plugin order
124
- async writeBundle() {
125
- try {
126
- const n = await w(
127
- s.srcDir,
128
- s.extensions,
129
- s.deepScan
130
- );
131
- if (A(n), n.length === 0)
132
- return;
133
- const e = u.join(s.outDir, "index.html"), o = await T(e);
134
- if (o === null)
135
- return;
136
- const r = F(n), i = y(o, r);
137
- await c.writeFile(e, i, "utf-8"), E(n.length);
138
- } catch (n) {
139
- console.error("❌ Error in aippy preload plugin:", n);
140
- }
141
- }
142
- };
143
- }
144
- export {
145
- P as aippyPreloadPlugin,
146
- P as default
147
- };
1
+ import { t as e } from "../aippy-preload-8BoWu90-.js";
2
+ export { e as aippyPreloadPlugin, e as default };
@@ -0,0 +1,153 @@
1
+ import { extractAssetsFromContent as e } from "./utils/index.js";
2
+ import { r as t } from "./file-scanner-DT-LbrCa.js";
3
+ import { promises as n } from "fs";
4
+ import r from "path";
5
+ //#region src/aippy-preload/scanner-utils.ts
6
+ async function i(t) {
7
+ let i = [], a = [r.join(process.cwd(), "index.html")];
8
+ for (let r of a) try {
9
+ let a = await n.readFile(r, "utf-8"), o = e(a, "html", t);
10
+ i.push(...o);
11
+ } catch {
12
+ console.warn("⚠️ No index.html found in project root");
13
+ }
14
+ return i;
15
+ }
16
+ async function a(r, i) {
17
+ let a = [], o = await t(r, [
18
+ ".ts",
19
+ ".tsx",
20
+ ".js",
21
+ ".jsx"
22
+ ]);
23
+ for (let t of o) try {
24
+ let r = await n.readFile(t, "utf-8"), o = e(r, "js", i);
25
+ a.push(...o);
26
+ } catch (e) {
27
+ console.warn(`⚠️ Failed to read JS file: ${t}`, e);
28
+ }
29
+ return a;
30
+ }
31
+ async function o(r, i) {
32
+ let a = [], o = await t(r, [
33
+ ".css",
34
+ ".scss",
35
+ ".sass",
36
+ ".less"
37
+ ]);
38
+ for (let t of o) try {
39
+ let r = await n.readFile(t, "utf-8"), o = e(r, "css", i);
40
+ a.push(...o);
41
+ } catch (e) {
42
+ console.warn(`⚠️ Failed to read CSS file: ${t}`, e);
43
+ }
44
+ return a;
45
+ }
46
+ async function s(r, i) {
47
+ let a = [], o = await t(r, [".json"]);
48
+ for (let t of o) try {
49
+ let r = await n.readFile(t, "utf-8"), o = e(r, "js", i);
50
+ a.push(...o);
51
+ } catch (e) {
52
+ console.warn(`⚠️ Failed to read JSON file: ${t}`, e);
53
+ }
54
+ return a;
55
+ }
56
+ async function c(e, t, n) {
57
+ console.log("🔍 Scanning source files for static assets...");
58
+ let r = [];
59
+ if (n) {
60
+ console.log("🔍 Deep scanning source file contents...");
61
+ let [n, c, l, u] = await Promise.all([
62
+ i(t),
63
+ a(e, t),
64
+ o(e, t),
65
+ s(e, t)
66
+ ]);
67
+ r.push(...n, ...c, ...l, ...u);
68
+ }
69
+ return [...new Set(r)];
70
+ }
71
+ //#endregion
72
+ //#region src/aippy-preload/html-utils.ts
73
+ var l = "<head>", u = 6;
74
+ function d(e) {
75
+ return e.map((e) => ` <meta content="${e}" name="aippy:preload">`).join("\n");
76
+ }
77
+ function f(e, t) {
78
+ let n = e.indexOf(l);
79
+ if (n === -1) throw Error("Could not find <head> tag in HTML");
80
+ let r = n + u;
81
+ return e.slice(0, r) + "\n" + t + "\n" + e.slice(r);
82
+ }
83
+ function p(e) {
84
+ let t = e.length;
85
+ if (console.log(`📁 Found ${t} static ${t === 1 ? "asset" : "assets"} in source files`), t === 0) {
86
+ console.log("⚠️ No static assets found in source files.");
87
+ return;
88
+ }
89
+ console.log(`📋 ${t === 1 ? "Asset" : "Assets"} found:`), e.forEach((e) => console.log(` - ${e}`));
90
+ }
91
+ function m(e) {
92
+ console.log(`✅ Injected ${e} preload meta ${e === 1 ? "tag" : "tags"} into index.html`);
93
+ }
94
+ //#endregion
95
+ //#region src/aippy-preload/index.ts
96
+ var h = 3, g = 1e3;
97
+ function _(e) {
98
+ return new Promise((t) => setTimeout(t, e));
99
+ }
100
+ async function v(e, t = h, r = g) {
101
+ for (let i = 1; i <= t; i++) try {
102
+ return await n.readFile(e, "utf-8");
103
+ } catch (e) {
104
+ if (e.code === "ENOENT") {
105
+ if (i < t) {
106
+ console.log(`⏳ index.html not found, waiting ${r}ms before retry (attempt ${i}/${t})...`), await _(r);
107
+ continue;
108
+ }
109
+ return console.log(`⚠️ index.html not found after ${t} attempts, skipping preload injection.`), null;
110
+ }
111
+ return console.error("❌ Error reading index.html:", e), null;
112
+ }
113
+ return null;
114
+ }
115
+ function y(e = {}) {
116
+ let t = {
117
+ extensions: [
118
+ ".png",
119
+ ".jpg",
120
+ ".jpeg",
121
+ ".gif",
122
+ ".svg",
123
+ ".mp4",
124
+ ".mp3",
125
+ ".wav",
126
+ ".ogg",
127
+ ".webm"
128
+ ],
129
+ srcDir: "src",
130
+ outDir: "dist",
131
+ deepScan: !0,
132
+ ...e
133
+ };
134
+ return {
135
+ name: "vite-plugin-aippy-preload",
136
+ apply: "build",
137
+ enforce: "post",
138
+ async writeBundle() {
139
+ try {
140
+ let e = await c(t.srcDir, t.extensions, t.deepScan);
141
+ if (p(e), e.length === 0) return;
142
+ let i = r.join(t.outDir, "index.html"), a = await v(i);
143
+ if (a === null) return;
144
+ let o = f(a, d(e));
145
+ await n.writeFile(i, o, "utf-8"), m(e.length);
146
+ } catch (e) {
147
+ console.error("❌ Error in aippy preload plugin:", e);
148
+ }
149
+ }
150
+ };
151
+ }
152
+ //#endregion
153
+ export { y as t };
@@ -1,381 +1,2 @@
1
- import { parse as E } from "@babel/parser";
2
- import * as A from "esbuild";
3
- import G from "fs/promises";
4
- import P from "magic-string";
5
- import i from "path";
6
- import { findProjectRoot as F } from "../utils/index.js";
7
- const H = [
8
- "object3D",
9
- "audioListener",
10
- "positionalAudio",
11
- "mesh",
12
- "batchedMesh",
13
- "instancedMesh",
14
- "scene",
15
- "sprite",
16
- "lOD",
17
- "skinnedMesh",
18
- "skeleton",
19
- "bone",
20
- "lineSegments",
21
- "lineLoop",
22
- "points",
23
- "group",
24
- "camera",
25
- "perspectiveCamera",
26
- "orthographicCamera",
27
- "cubeCamera",
28
- "arrayCamera",
29
- "instancedBufferGeometry",
30
- "bufferGeometry",
31
- "boxBufferGeometry",
32
- "circleBufferGeometry",
33
- "coneBufferGeometry",
34
- "cylinderBufferGeometry",
35
- "dodecahedronBufferGeometry",
36
- "extrudeBufferGeometry",
37
- "icosahedronBufferGeometry",
38
- "latheBufferGeometry",
39
- "octahedronBufferGeometry",
40
- "planeBufferGeometry",
41
- "polyhedronBufferGeometry",
42
- "ringBufferGeometry",
43
- "shapeBufferGeometry",
44
- "sphereBufferGeometry",
45
- "tetrahedronBufferGeometry",
46
- "torusBufferGeometry",
47
- "torusKnotBufferGeometry",
48
- "tubeBufferGeometry",
49
- "wireframeGeometry",
50
- "tetrahedronGeometry",
51
- "octahedronGeometry",
52
- "icosahedronGeometry",
53
- "dodecahedronGeometry",
54
- "polyhedronGeometry",
55
- "tubeGeometry",
56
- "torusKnotGeometry",
57
- "torusGeometry",
58
- "sphereGeometry",
59
- "ringGeometry",
60
- "planeGeometry",
61
- "latheGeometry",
62
- "shapeGeometry",
63
- "extrudeGeometry",
64
- "edgesGeometry",
65
- "coneGeometry",
66
- "cylinderGeometry",
67
- "circleGeometry",
68
- "boxGeometry",
69
- "capsuleGeometry",
70
- "material",
71
- "shadowMaterial",
72
- "spriteMaterial",
73
- "rawShaderMaterial",
74
- "shaderMaterial",
75
- "pointsMaterial",
76
- "meshPhysicalMaterial",
77
- "meshStandardMaterial",
78
- "meshPhongMaterial",
79
- "meshToonMaterial",
80
- "meshNormalMaterial",
81
- "meshLambertMaterial",
82
- "meshDepthMaterial",
83
- "meshDistanceMaterial",
84
- "meshBasicMaterial",
85
- "meshMatcapMaterial",
86
- "lineDashedMaterial",
87
- "lineBasicMaterial",
88
- "primitive",
89
- "light",
90
- "spotLightShadow",
91
- "spotLight",
92
- "pointLight",
93
- "rectAreaLight",
94
- "hemisphereLight",
95
- "directionalLightShadow",
96
- "directionalLight",
97
- "ambientLight",
98
- "lightShadow",
99
- "ambientLightProbe",
100
- "hemisphereLightProbe",
101
- "lightProbe",
102
- "spotLightHelper",
103
- "skeletonHelper",
104
- "pointLightHelper",
105
- "hemisphereLightHelper",
106
- "gridHelper",
107
- "polarGridHelper",
108
- "directionalLightHelper",
109
- "cameraHelper",
110
- "boxHelper",
111
- "box3Helper",
112
- "planeHelper",
113
- "arrowHelper",
114
- "axesHelper",
115
- "texture",
116
- "videoTexture",
117
- "dataTexture",
118
- "dataTexture3D",
119
- "compressedTexture",
120
- "cubeTexture",
121
- "canvasTexture",
122
- "depthTexture",
123
- "raycaster",
124
- "vector2",
125
- "vector3",
126
- "vector4",
127
- "euler",
128
- "matrix3",
129
- "matrix4",
130
- "quaternion",
131
- "bufferAttribute",
132
- "float16BufferAttribute",
133
- "float32BufferAttribute",
134
- "float64BufferAttribute",
135
- "int8BufferAttribute",
136
- "int16BufferAttribute",
137
- "int32BufferAttribute",
138
- "uint8BufferAttribute",
139
- "uint16BufferAttribute",
140
- "uint32BufferAttribute",
141
- "instancedBufferAttribute",
142
- "color",
143
- "fog",
144
- "fogExp2",
145
- "shape",
146
- "colorShiftMaterial"
147
- ], R = [
148
- "AsciiRenderer",
149
- "Billboard",
150
- "Clone",
151
- "ComputedAttribute",
152
- "Decal",
153
- "Edges",
154
- "Effects",
155
- "GradientTexture",
156
- "Image",
157
- "MarchingCubes",
158
- "Outlines",
159
- "PositionalAudio",
160
- "Sampler",
161
- "ScreenSizer",
162
- "ScreenSpace",
163
- "Splat",
164
- "Svg",
165
- "Text",
166
- "Text3D",
167
- "Trail",
168
- "CubeCamera",
169
- "OrthographicCamera",
170
- "PerspectiveCamera",
171
- "CameraControls",
172
- "FaceControls",
173
- "KeyboardControls",
174
- "MotionPathControls",
175
- "PresentationControls",
176
- "ScrollControls",
177
- "DragControls",
178
- "GizmoHelper",
179
- "Grid",
180
- "Helper",
181
- "PivotControls",
182
- "TransformControls",
183
- "CubeTexture",
184
- "Fbx",
185
- "Gltf",
186
- "Ktx2",
187
- "Loader",
188
- "Progress",
189
- "ScreenVideoTexture",
190
- "Texture",
191
- "TrailTexture",
192
- "VideoTexture",
193
- "WebcamVideoTexture",
194
- "CycleRaycast",
195
- "DetectGPU",
196
- "Example",
197
- "FaceLandmarker",
198
- "Fbo",
199
- "Html",
200
- "Select",
201
- "SpriteAnimator",
202
- "StatsGl",
203
- "Stats",
204
- "Trail",
205
- "Wireframe",
206
- "CurveModifier",
207
- "AdaptiveDpr",
208
- "AdaptiveEvents",
209
- "BakeShadows",
210
- "Bvh",
211
- "Detailed",
212
- "Instances",
213
- "Merged",
214
- "meshBounds",
215
- "PerformanceMonitor",
216
- "Points",
217
- "Preload",
218
- "Segments",
219
- "Fisheye",
220
- "Hud",
221
- "Mask",
222
- "MeshPortalMaterial",
223
- "RenderCubeTexture",
224
- "RenderTexture",
225
- "View",
226
- "MeshDiscardMaterial",
227
- "MeshDistortMaterial",
228
- "MeshReflectorMaterial",
229
- "MeshRefractionMaterial",
230
- "MeshTransmissionMaterial",
231
- "MeshWobbleMaterial",
232
- "PointMaterial",
233
- "shaderMaterial",
234
- "SoftShadows",
235
- "CatmullRomLine",
236
- "CubicBezierLine",
237
- "Facemesh",
238
- "Line",
239
- "Mesh",
240
- "QuadraticBezierLine",
241
- "RoundedBox",
242
- "ScreenQuad",
243
- "AccumulativeShadows",
244
- "Backdrop",
245
- "BBAnchor",
246
- "Bounds",
247
- "CameraShake",
248
- "Caustics",
249
- "Center",
250
- "Cloud",
251
- "ContactShadows",
252
- "Environment",
253
- "Float",
254
- "Lightformer",
255
- "MatcapTexture",
256
- "NormalTexture",
257
- "RandomizedLight",
258
- "Resize",
259
- "ShadowAlpha",
260
- "Shadow",
261
- "Sky",
262
- "Sparkles",
263
- "SpotLightShadow",
264
- "SpotLight",
265
- "Stage",
266
- "Stars",
267
- "OrbitControls"
268
- ];
269
- function D(e) {
270
- return !H.includes(e) && !R.includes(e);
271
- }
272
- const $ = /* @__PURE__ */ new Set([".jsx", ".tsx"]), b = F(), g = i.resolve(b, "./tailwind.config.ts"), j = i.resolve(b, "./src/tailwind.config.aippy.json"), y = i.resolve(b, "./.aippy.tailwind.config.js");
273
- function X() {
274
- const e = process.cwd(), l = {
275
- totalFiles: 0,
276
- processedFiles: 0,
277
- totalElements: 0
278
- };
279
- return {
280
- name: "vite-plugin-aippy-tagger",
281
- enforce: "pre",
282
- async transform(n, r) {
283
- if (!$.has(i.extname(r)) || r.includes("node_modules"))
284
- return null;
285
- l.totalFiles++;
286
- const d = i.relative(e, r);
287
- try {
288
- const B = E(n, {
289
- sourceType: "module",
290
- plugins: ["jsx", "typescript"]
291
- }), f = new P(n);
292
- let x = 0, c = null;
293
- const { walk: C } = await import("estree-walker");
294
- return C(B, {
295
- enter(m) {
296
- if (m.type === "JSXElement" && (c = m), m.type === "JSXOpeningElement") {
297
- const a = m;
298
- let s;
299
- if (a.name.type === "JSXIdentifier")
300
- s = a.name.name;
301
- else if (a.name.type === "JSXMemberExpression") {
302
- const t = a.name;
303
- s = `${t.object.name}.${t.property.name}`;
304
- } else
305
- return;
306
- if (s === "Fragment" || s === "React.Fragment")
307
- return;
308
- const u = a.attributes.reduce((t, o) => (o.type === "JSXAttribute" && (o.value?.type === "StringLiteral" ? t[o.name.name] = o.value.value : o.value?.type === "JSXExpressionContainer" && o.value.expression.type === "StringLiteral" && (t[o.name.name] = o.value.expression.value)), t), {});
309
- let h = "";
310
- c && c.children && (h = c.children.map((t) => t.type === "JSXText" ? t.value.trim() : t.type === "JSXExpressionContainer" && t.expression.type === "StringLiteral" ? t.expression.value : "").filter(Boolean).join(" ").trim());
311
- const p = {};
312
- h && (p.text = h), u.placeholder && (p.placeholder = u.placeholder), u.className && (p.className = u.className);
313
- const M = a.loc?.start?.line ?? 0, v = a.loc?.start?.column ?? 0, T = `${d}:${M}:${v}`, L = i.basename(r);
314
- if (D(s)) {
315
- const t = ` data-component-path="${d}" data-component-line="${M}" data-component-file="${L}" data-component-name="${s}" data-component-content="${encodeURIComponent(
316
- JSON.stringify(p)
317
- )}"`;
318
- f.appendLeft(
319
- a.name.end ?? 0,
320
- ` data-aippy-id="${T}" data-aippy-name="${s}" ${t}`
321
- ), x++;
322
- }
323
- }
324
- }
325
- }), l.processedFiles++, l.totalElements += x, {
326
- code: f.toString(),
327
- map: f.generateMap({ hires: !0 })
328
- };
329
- } catch (S) {
330
- return console.error(`Error processing file ${d}:`, S), l.processedFiles++, null;
331
- }
332
- },
333
- async buildStart() {
334
- try {
335
- await w();
336
- } catch (n) {
337
- console.error("Error generating tailwind.config.aippy.json:", n);
338
- }
339
- },
340
- configureServer(n) {
341
- try {
342
- n.watcher.add(g), n.watcher.on("change", async (r) => {
343
- i.normalize(r) === i.normalize(g) && await w();
344
- });
345
- } catch (r) {
346
- console.error("Error adding watcher:", r);
347
- }
348
- }
349
- };
350
- }
351
- async function w() {
352
- try {
353
- await A.build({
354
- entryPoints: [g],
355
- outfile: y,
356
- bundle: !0,
357
- format: "esm",
358
- banner: {
359
- js: 'import { createRequire } from "module"; const require = createRequire(import.meta.url);'
360
- }
361
- });
362
- try {
363
- const e = await import(
364
- y + "?update=" + Date.now()
365
- // cache buster
366
- );
367
- if (!e || !e.default)
368
- throw console.error("Invalid Tailwind config structure:", e), new Error("Invalid Tailwind config structure");
369
- await G.writeFile(j, JSON.stringify(e.default, null, 2)), await G.unlink(y).catch(() => {
370
- });
371
- } catch (e) {
372
- throw console.error("Error processing config:", e), e;
373
- }
374
- } catch (e) {
375
- throw console.error("Error in generateConfig:", e), e;
376
- }
377
- }
378
- export {
379
- X as aippyTaggerPlugin,
380
- X as default
381
- };
1
+ import { t as e } from "../aippy-tagger-By5socAS.js";
2
+ export { e as aippyTaggerPlugin, e as default };