svelte-ag 1.0.36 → 1.0.38
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/lib/vite/vite-plugin-component-source-collector.d.ts +1 -1
- package/dist/lib/vite/vite-plugin-component-source-collector.d.ts.map +1 -1
- package/dist/lib/vite/vite-plugin-component-source-collector.js +9 -2
- package/package.json +7 -7
- package/src/lib/vite/vite-plugin-component-source-collector.ts +11 -2
|
@@ -15,6 +15,6 @@ interface Options {
|
|
|
15
15
|
*/
|
|
16
16
|
safePackages: string[];
|
|
17
17
|
}
|
|
18
|
-
export default function componentSourceCollector(opts?: Options): Plugin
|
|
18
|
+
export default function componentSourceCollector(opts?: Options): Promise<Plugin>;
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=vite-plugin-component-source-collector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-component-source-collector.d.ts","sourceRoot":"","sources":["../../../src/lib/vite/vite-plugin-component-source-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"vite-plugin-component-source-collector.d.ts","sourceRoot":"","sources":["../../../src/lib/vite/vite-plugin-component-source-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAMnD,UAAU,OAAO;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAKD,wBAA8B,wBAAwB,CAAC,IAAI,GAAE,OAA8B,GAAG,OAAO,CAAC,MAAM,CAAC,CAoK5G"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { exists, writeIfDifferent } from 'ts-ag';
|
|
2
2
|
import { readFile } from 'fs/promises';
|
|
3
3
|
import { resolve, join, relative, dirname } from 'path';
|
|
4
|
+
import { open } from 'fs/promises';
|
|
4
5
|
/** All unique component directories */
|
|
5
6
|
const componentFiles = new Set();
|
|
6
|
-
export default function componentSourceCollector(opts = { safePackages: [] }) {
|
|
7
|
+
export default async function componentSourceCollector(opts = { safePackages: [] }) {
|
|
7
8
|
// constants
|
|
8
9
|
const outFileName = opts.outputFile ?? 'component-sources.css';
|
|
9
10
|
const classRegex = /class(?:=|:)/;
|
|
@@ -15,6 +16,7 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
|
|
|
15
16
|
let firstRound = true;
|
|
16
17
|
let initialTransformDone = false;
|
|
17
18
|
let initialTransformTimer = null;
|
|
19
|
+
// init
|
|
18
20
|
function shouldAdd(code) {
|
|
19
21
|
return classRegex.test(code);
|
|
20
22
|
}
|
|
@@ -26,7 +28,7 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
|
|
|
26
28
|
(!/\.pnpm|.vite/.test(file) || opts.safePackages.some((p) => file.includes(`node_modules/${p}`)))) {
|
|
27
29
|
const cleanedFileName = file.replace(/\?v=.*$/, '');
|
|
28
30
|
const relativeFilePath = relative(dirname(outputFilePath), cleanedFileName);
|
|
29
|
-
if (relativeFilePath !==
|
|
31
|
+
if (relativeFilePath !== outFileName) {
|
|
30
32
|
// Dont add itself
|
|
31
33
|
componentFiles.add(relativeFilePath);
|
|
32
34
|
}
|
|
@@ -42,6 +44,10 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
|
|
|
42
44
|
}
|
|
43
45
|
}, 1000); // adjust delay as needed
|
|
44
46
|
}
|
|
47
|
+
async function touch(path) {
|
|
48
|
+
const handle = await open(path, 'a');
|
|
49
|
+
await handle.close();
|
|
50
|
+
}
|
|
45
51
|
const writeOutFile = async () => {
|
|
46
52
|
const lines = Array.from(componentFiles)
|
|
47
53
|
.map((d) => `@source '${d}';`)
|
|
@@ -63,6 +69,7 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
|
|
|
63
69
|
config = resolved;
|
|
64
70
|
root = config.root;
|
|
65
71
|
outputFilePath = resolve(root, outFileName);
|
|
72
|
+
await touch(outputFilePath);
|
|
66
73
|
if (config.command === 'build' && firstRound) {
|
|
67
74
|
componentFiles.clear();
|
|
68
75
|
firstRound = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-ag",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"description": "Useful svelte components",
|
|
5
5
|
"bugs": "https://github.com/ageorgeh/svelte-ag/issues",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@dnd-kit-svelte/svelte": "^0.1.6",
|
|
49
|
-
"@floating-ui/dom": "^1.7.
|
|
49
|
+
"@floating-ui/dom": "^1.7.6",
|
|
50
50
|
"bits-ui": "^2.16.2",
|
|
51
51
|
"bottleneck": "^2.19.5",
|
|
52
52
|
"clsx": "^2.1.1",
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@actions/languageserver": "^0.3.46",
|
|
68
68
|
"@eslint/js": "^10.0.1",
|
|
69
|
-
"@iconify/json": "^2.2.
|
|
69
|
+
"@iconify/json": "^2.2.445",
|
|
70
70
|
"@iconify/tailwind4": "^1.2.1",
|
|
71
71
|
"@iconify/types": "^2.0.0",
|
|
72
72
|
"@internationalized/date": "^3.11.0",
|
|
73
|
-
"@lucide/svelte": "^0.
|
|
73
|
+
"@lucide/svelte": "^0.576.0",
|
|
74
74
|
"@playwright/test": "1.57.0",
|
|
75
75
|
"@sveltejs/kit": "^2.53.4",
|
|
76
76
|
"@sveltejs/package": "^2.5.7",
|
|
@@ -78,13 +78,13 @@
|
|
|
78
78
|
"@tailwindcss/typography": "^0.5.19",
|
|
79
79
|
"@tailwindcss/vite": "^4.2.1",
|
|
80
80
|
"@types/node": "^24.11.0",
|
|
81
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
81
|
+
"@typescript/native-preview": "7.0.0-dev.20260303.1",
|
|
82
82
|
"eslint": "^10.0.2",
|
|
83
83
|
"eslint-plugin-better-tailwindcss": "^4.3.1",
|
|
84
84
|
"eslint-plugin-svelte": "^3.15.0",
|
|
85
|
-
"globals": "^17.
|
|
85
|
+
"globals": "^17.4.0",
|
|
86
86
|
"husky": "^9.1.7",
|
|
87
|
-
"lint-staged": "^16.3.
|
|
87
|
+
"lint-staged": "^16.3.1",
|
|
88
88
|
"prettier": "^3.8.1",
|
|
89
89
|
"prettier-plugin-packagejson": "^3.0.0",
|
|
90
90
|
"prettier-plugin-svelte": "^3.5.0",
|
|
@@ -2,6 +2,7 @@ import type { Plugin, ResolvedConfig } from 'vite';
|
|
|
2
2
|
import { exists, writeIfDifferent } from 'ts-ag';
|
|
3
3
|
import { readFile } from 'fs/promises';
|
|
4
4
|
import { resolve, join, relative, dirname } from 'path';
|
|
5
|
+
import { open } from 'fs/promises';
|
|
5
6
|
|
|
6
7
|
interface Options {
|
|
7
8
|
/**
|
|
@@ -23,7 +24,7 @@ interface Options {
|
|
|
23
24
|
/** All unique component directories */
|
|
24
25
|
const componentFiles = new Set<string>();
|
|
25
26
|
|
|
26
|
-
export default function componentSourceCollector(opts: Options = { safePackages: [] }): Plugin {
|
|
27
|
+
export default async function componentSourceCollector(opts: Options = { safePackages: [] }): Promise<Plugin> {
|
|
27
28
|
// constants
|
|
28
29
|
const outFileName = opts.outputFile ?? 'component-sources.css';
|
|
29
30
|
const classRegex = /class(?:=|:)/;
|
|
@@ -38,6 +39,7 @@ export default function componentSourceCollector(opts: Options = { safePackages:
|
|
|
38
39
|
let initialTransformDone = false;
|
|
39
40
|
let initialTransformTimer: NodeJS.Timeout | null = null;
|
|
40
41
|
|
|
42
|
+
// init
|
|
41
43
|
function shouldAdd(code: string) {
|
|
42
44
|
return classRegex.test(code);
|
|
43
45
|
}
|
|
@@ -53,7 +55,7 @@ export default function componentSourceCollector(opts: Options = { safePackages:
|
|
|
53
55
|
const cleanedFileName = file.replace(/\?v=.*$/, '');
|
|
54
56
|
const relativeFilePath = relative(dirname(outputFilePath), cleanedFileName);
|
|
55
57
|
|
|
56
|
-
if (relativeFilePath !==
|
|
58
|
+
if (relativeFilePath !== outFileName) {
|
|
57
59
|
// Dont add itself
|
|
58
60
|
componentFiles.add(relativeFilePath);
|
|
59
61
|
}
|
|
@@ -70,6 +72,11 @@ export default function componentSourceCollector(opts: Options = { safePackages:
|
|
|
70
72
|
}, 1000); // adjust delay as needed
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
async function touch(path: string) {
|
|
76
|
+
const handle = await open(path, 'a');
|
|
77
|
+
await handle.close();
|
|
78
|
+
}
|
|
79
|
+
|
|
73
80
|
const writeOutFile = async () => {
|
|
74
81
|
const lines = Array.from(componentFiles)
|
|
75
82
|
.map((d) => `@source '${d}';`)
|
|
@@ -95,6 +102,8 @@ export default function componentSourceCollector(opts: Options = { safePackages:
|
|
|
95
102
|
root = config.root;
|
|
96
103
|
outputFilePath = resolve(root, outFileName);
|
|
97
104
|
|
|
105
|
+
await touch(outputFilePath);
|
|
106
|
+
|
|
98
107
|
if (config.command === 'build' && firstRound) {
|
|
99
108
|
componentFiles.clear();
|
|
100
109
|
firstRound = false;
|