@lls/vitescripts 2.0.1 → 2.0.3
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/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lls/vitescripts",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "lls vite plugins",
|
|
5
5
|
"main": "src/index.mjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"src/"
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "
|
|
10
|
+
"test": "CONF_ENV=test npx vitest run",
|
|
11
|
+
"prepare": "husky install || true"
|
|
11
12
|
},
|
|
12
13
|
"dependencies": {
|
|
13
14
|
"lightningcss": "1.21.5"
|
|
@@ -16,6 +17,12 @@
|
|
|
16
17
|
"author": "",
|
|
17
18
|
"license": "ISC",
|
|
18
19
|
"devDependencies": {
|
|
19
|
-
"@lls/eslint-config-lls": "1.1.12"
|
|
20
|
+
"@lls/eslint-config-lls": "1.1.12",
|
|
21
|
+
"@lls/lls-kit": "20.1.0",
|
|
22
|
+
"husky": "8.0.3",
|
|
23
|
+
"vitest": "0.34.6"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@lls/lls-kit": "*"
|
|
20
27
|
}
|
|
21
28
|
}
|
package/src/llsAssetsPlugin.mjs
CHANGED
|
@@ -12,7 +12,7 @@ const execP = promisify(exec)
|
|
|
12
12
|
* @returns config() method that copies assets
|
|
13
13
|
* transform() method that replaces assets path to be resolved
|
|
14
14
|
*/
|
|
15
|
-
const llsAssetsPlugin = (llsRepos, publicDir = 'ladleassets') => {
|
|
15
|
+
const llsAssetsPlugin = (llsRepos, publicDir = 'ladleassets', { stripRoot = true } = {}) => {
|
|
16
16
|
const publicAssetDir = path.join(publicDir, 'assets')
|
|
17
17
|
const fileExists = (s) => new Promise(resolve => fs.access(s, e => resolve(!e)))
|
|
18
18
|
const srcRoot = process.cwd() + '/src'
|
|
@@ -34,7 +34,7 @@ const llsAssetsPlugin = (llsRepos, publicDir = 'ladleassets') => {
|
|
|
34
34
|
await execP(`cp -rf ${repo} ${publicAssetDir}`)
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
transform(src, id) {
|
|
37
|
+
...(stripRoot && {transform(src, id) {
|
|
38
38
|
if (
|
|
39
39
|
llsRepos.some(repo => id.includes(repo)) ||
|
|
40
40
|
id.startsWith(srcRoot) ||
|
|
@@ -48,7 +48,7 @@ const llsAssetsPlugin = (llsRepos, publicDir = 'ladleassets') => {
|
|
|
48
48
|
map: null
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}})
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, themeIsNotDarkMode }) => {
|
|
2
|
+
const keepProperties = [
|
|
3
|
+
'Supporting',
|
|
4
|
+
'Button1',
|
|
5
|
+
'Button2',
|
|
6
|
+
'Body1',
|
|
7
|
+
'Body2',
|
|
8
|
+
'Body3',
|
|
9
|
+
'RippleEffect',
|
|
10
|
+
'Heading1',
|
|
11
|
+
'Heading2',
|
|
12
|
+
'Heading3',
|
|
13
|
+
'Heading4'
|
|
14
|
+
]
|
|
15
|
+
const kitBag = await import('@lls/lls-kit')
|
|
16
|
+
.then(m => m.default || m)
|
|
17
|
+
.then(obj => Object.fromEntries(keepProperties.map(property => [property, obj[property]])))
|
|
18
|
+
|
|
2
19
|
const cssMacroTheme = {
|
|
3
20
|
themeIsFreeMode,
|
|
4
21
|
themeIsDarkMode,
|
|
@@ -11,6 +28,20 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
11
28
|
return undefined
|
|
12
29
|
}
|
|
13
30
|
return src
|
|
31
|
+
.replace(/\${(Body[123]|Heading[123])}/g, (__, cap) => kitBag[cap])
|
|
32
|
+
.replace(/\${getFluidSize\({(.*?)}\)}/, (__, cap) => {
|
|
33
|
+
const args = {
|
|
34
|
+
minViewport: 320, // BREAKPOINT_XXS
|
|
35
|
+
maxViewport: 1280, // BREAKPOINT_MD
|
|
36
|
+
minSize: undefined,
|
|
37
|
+
maxSize: undefined
|
|
38
|
+
}
|
|
39
|
+
for (const a of cap.matchAll(/(?<prop>maxSize|minSize|minViewport|maxViewport)\s*:\s*(?<value>.+?)(?=[, ]|$)/g)) {
|
|
40
|
+
args[a.groups.prop] = a.groups.value
|
|
41
|
+
}
|
|
42
|
+
const { maxSize, minSize, minViewport, maxViewport} = args
|
|
43
|
+
return `min(${maxSize}px, max(${minSize}px, calc(${minSize}px + (${maxSize} - ${minSize}) * ((100vw - ${minViewport}px) / (${maxViewport} - ${minViewport})))))`
|
|
44
|
+
})
|
|
14
45
|
.replace(/\${getTruePx\((.*?)\)}/g, 'calc(var(--size-index, 1) * $1 * 1px)')
|
|
15
46
|
.replace(/\${(themeIsFreeMode|themeIsDarkMode|themeIsNotDarkMode)}/g, (__, cap) => {
|
|
16
47
|
const back = cssMacroTheme[cap]
|