@lls/vitescripts 2.0.19 → 2.0.21
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 +1 -1
- package/src/esbuildCssModulePlugin.mjs +2 -3
- package/src/index.mjs +1 -1
- package/src/llsAssetsPlugin.mjs +11 -9
- package/src/llsCssModuleMacroPlugin.mjs +41 -39
- package/src/llsCssSsrCollectPlugin.mjs +2 -2
- package/src/llsLadlePlugin.mjs +2 -2
- package/src/llsLinariaImportsPlugin.mjs +1 -1
- package/src/llsLinariaSsrCollectPlugin.mjs +3 -3
- package/src/llsSideRefreshMetaPlugin.mjs +56 -19
- package/src/llsVitestMockPlugin.mjs +2 -2
- package/src/postBuildAutoprefixerPlugin.mjs +5 -4
package/package.json
CHANGED
|
@@ -13,8 +13,7 @@ export default ({ prefix = '', llsCssModuleMacroPluginArg }) => {
|
|
|
13
13
|
return [
|
|
14
14
|
{
|
|
15
15
|
name: 'lls-cssmodule',
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
async setup (build) {
|
|
18
17
|
await fs.promises.mkdir(tmpDir, { recursive: true })
|
|
19
18
|
const llsCssModuleMacroPluginInstance = await llsCssModuleMacroPlugin(llsCssModuleMacroPluginArg)
|
|
20
19
|
|
|
@@ -41,4 +40,4 @@ export default ({ prefix = '', llsCssModuleMacroPluginArg }) => {
|
|
|
41
40
|
},
|
|
42
41
|
esbuildCssModule
|
|
43
42
|
]
|
|
44
|
-
}
|
|
43
|
+
}
|
package/src/index.mjs
CHANGED
|
@@ -7,4 +7,4 @@ export { default as llsVitestMockPlugin } from './llsVitestMockPlugin.mjs'
|
|
|
7
7
|
export { default as llsLadlePlugin } from './llsLadlePlugin.mjs'
|
|
8
8
|
export { default as llsCssModuleMacroPlugin } from './llsCssModuleMacroPlugin.mjs'
|
|
9
9
|
export { default as postBuildAutoprefixerPlugin } from './postBuildAutoprefixerPlugin.mjs'
|
|
10
|
-
export { default as esbuildCssModulePlugin } from './esbuildCssModulePlugin.mjs'
|
|
10
|
+
export { default as esbuildCssModulePlugin } from './esbuildCssModulePlugin.mjs'
|
package/src/llsAssetsPlugin.mjs
CHANGED
|
@@ -19,7 +19,7 @@ const llsAssetsPlugin = (llsRepos, publicDir = 'ladleassets', { stripRoot = true
|
|
|
19
19
|
const storyRoot = process.cwd() + '/stories'
|
|
20
20
|
return {
|
|
21
21
|
name: 'lls:copyassets',
|
|
22
|
-
async config() {
|
|
22
|
+
async config () {
|
|
23
23
|
await execP(`mkdir -p ${publicAssetDir}`)
|
|
24
24
|
const repoArgs = await Promise.all(llsRepos.map(async repo => {
|
|
25
25
|
if (!repo.startsWith('@')) return repo
|
|
@@ -34,21 +34,23 @@ const llsAssetsPlugin = (llsRepos, publicDir = 'ladleassets', { stripRoot = true
|
|
|
34
34
|
await execP(`cp -rf ${repo} ${publicAssetDir}`)
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
...(stripRoot && {
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
...(stripRoot && {
|
|
38
|
+
transform (src, id) {
|
|
39
|
+
if (
|
|
40
|
+
llsRepos.some(repo => id.includes(repo)) ||
|
|
40
41
|
id.startsWith(srcRoot) ||
|
|
41
42
|
id.startsWith(storyRoot)
|
|
42
|
-
|
|
43
|
+
) {
|
|
43
44
|
// workaround because we don't use /assets (maybe we should ?)
|
|
44
45
|
// specs orders than relative path in css is current container
|
|
45
46
|
// so use relative path instead of / being the "fqdn"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
return {
|
|
48
|
+
code: src.replace(/(= |url\(|Worker\()(['"])\/assets/g, '$1$2assets'),
|
|
49
|
+
map: null
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
}
|
|
53
|
+
})
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { transform as lightTransform } from 'lightningcss'
|
|
2
|
+
import { makeSideRefreshThemeInterceptor } from './llsSideRefreshMetaPlugin.mjs'
|
|
2
3
|
|
|
3
|
-
const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, themeIsNotDarkMode }) => {
|
|
4
|
+
const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, themeIsNotDarkMode, sideRefreshActiveModules = [] }) => {
|
|
4
5
|
const keepProperties = [
|
|
5
6
|
'Supporting',
|
|
6
7
|
'Button1',
|
|
@@ -29,12 +30,19 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
29
30
|
light: themeIsNotDarkMode
|
|
30
31
|
}
|
|
31
32
|
const replaceKitBag = (__, cap) => kitBag[cap]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
|
|
34
|
+
const interceptSideRefreshTheme = await makeSideRefreshThemeInterceptor(sideRefreshActiveModules)
|
|
35
|
+
// replaces dark from @llsTheme(dark) with proper css macro
|
|
36
|
+
const replaceTheme = (cap, id) => {
|
|
37
|
+
// try to resolve proper macro from siderefreshed directory
|
|
38
|
+
// otherwise defaults to standard resolving
|
|
39
|
+
return interceptSideRefreshTheme(cap, id, (cap) => {
|
|
40
|
+
const back = cssMacroTheme[cap]
|
|
41
|
+
if (!back) {
|
|
42
|
+
throw new Error('llsCssModuleMacroPlugin::missing definition for ' + cap)
|
|
43
|
+
}
|
|
44
|
+
return back
|
|
45
|
+
})
|
|
38
46
|
}
|
|
39
47
|
const replaceGetFluidSize = (__, cap) => {
|
|
40
48
|
const args = {
|
|
@@ -46,13 +54,7 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
46
54
|
for (const a of cap.matchAll(/(?<prop>maxSize|minSize|minViewport|maxViewport)\s*:\s*(?<value>.+?)(?=[,]|\s|$)/g)) {
|
|
47
55
|
args[a.groups.prop] = a.groups.value
|
|
48
56
|
}
|
|
49
|
-
const { maxSize, minSize, minViewport, maxViewport} = args
|
|
50
|
-
return `min(${maxSize}px, max(${minSize}px, calc(${minSize}px + (${maxSize} - ${minSize}) * ((100vw - ${minViewport}px) / (${maxViewport} - ${minViewport})))))`
|
|
51
|
-
}
|
|
52
|
-
const replaceGetFluidSizeV2 = (__, cap) => {
|
|
53
|
-
const [minSize, maxSize, aMinviewport, aMaxviewport] = cap.split(',')
|
|
54
|
-
const minViewport = (typeof(aMinviewport) === 'undefined' || /^\s*$/.test(aMinviewport)) ? 320 : aMinviewport
|
|
55
|
-
const maxViewport = (typeof(aMaxviewport) === 'undefined' || /^\s*$/.test(aMaxviewport)) ? 1280 : aMaxviewport
|
|
57
|
+
const { maxSize, minSize, minViewport, maxViewport } = args
|
|
56
58
|
return `min(${maxSize}px, max(${minSize}px, calc(${minSize}px + (${maxSize} - ${minSize}) * ((100vw - ${minViewport}px) / (${maxViewport} - ${minViewport})))))`
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -63,15 +65,15 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
63
65
|
const func = (name, args) => ({ type: 'function', value: { name, arguments: args } })
|
|
64
66
|
return {
|
|
65
67
|
enforce: 'pre',
|
|
66
|
-
transform(src, id) {
|
|
68
|
+
transform (src, id) {
|
|
67
69
|
if (!/module\.css(\?.*)?$/.test(id)) {
|
|
68
70
|
return undefined
|
|
69
71
|
}
|
|
70
72
|
const back = src
|
|
71
73
|
.replace(/@cx\((Body[123]|Heading[1234]|Button[12]|Supporting|RippleEffect|FontFamily)\)/g, replaceKitBag)
|
|
72
74
|
.replace(/\${(Body[123]|Heading[1234]|Button[12]|Supporting|RippleEffect|FontFamily)}/g, replaceKitBag)
|
|
73
|
-
.replace(/\${(themeIsFreeMode|themeIsDarkMode|themeIsNotDarkMode)}/g, replaceTheme)
|
|
74
|
-
.replace(/@llsTheme\((dark|light|free)\)/g, replaceTheme)
|
|
75
|
+
.replace(/\${(themeIsFreeMode|themeIsDarkMode|themeIsNotDarkMode)}/g, (__, cap) => replaceTheme(cap, id))
|
|
76
|
+
.replace(/@llsTheme\((dark|light|free)\)/g, (__, cap) => replaceTheme(cap, id))
|
|
75
77
|
|
|
76
78
|
.replace(/\${getFluidSize\({(.*?)}\)}/gs, replaceGetFluidSize)
|
|
77
79
|
.replace(/\${getTruePx\((.*?)\)}?/g, 'calc(var(--size-index, 1) * $1 * 1px)')
|
|
@@ -80,27 +82,27 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
80
82
|
code: Buffer.from(back),
|
|
81
83
|
visitor: {
|
|
82
84
|
Function: {
|
|
83
|
-
getTruePx({ arguments: [value] }) {
|
|
85
|
+
getTruePx ({ arguments: [value] }) {
|
|
84
86
|
return {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
type: 'function',
|
|
88
|
+
value: {
|
|
89
|
+
name: 'calc',
|
|
88
90
|
arguments: [
|
|
89
91
|
value.type !== 'token' && token('parenthesis-block'),
|
|
90
92
|
value,
|
|
91
93
|
value.type !== 'token' && token('close-parenthesis'),
|
|
92
94
|
delim('*'),
|
|
93
|
-
{
|
|
95
|
+
{ type: 'var', value: { name: { ident: '--size-index', from: null }, fallback: [{ type: 'token', value: { type: 'number', value: 1 } }] } },
|
|
94
96
|
delim('*'),
|
|
95
97
|
length(1, 'px')
|
|
96
98
|
].filter(Boolean)
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
},
|
|
100
|
-
getFluidSize({arguments: [minSize, comma1, maxSize, comma2, iMinViewport, comma3, iMaxViewport]}){
|
|
101
|
-
const minViewport = (typeof(iMinviewport) === 'undefined' || iMinViewport.value?.type === 'comma') ? length(320, 'px') : iMinViewport
|
|
102
|
+
getFluidSize ({ arguments: [minSize, comma1, maxSize, comma2, iMinViewport, comma3, iMaxViewport] }) {
|
|
103
|
+
const minViewport = (typeof (iMinviewport) === 'undefined' || iMinViewport.value?.type === 'comma') ? length(320, 'px') : iMinViewport
|
|
102
104
|
const max = iMinViewport?.value?.type === 'comma' ? comma3 : iMaxViewport
|
|
103
|
-
const maxViewport = typeof(max) === 'undefined' ? length(1280, 'px') : max
|
|
105
|
+
const maxViewport = typeof (max) === 'undefined' ? length(1280, 'px') : max
|
|
104
106
|
return func('min', [
|
|
105
107
|
maxSize,
|
|
106
108
|
token('comma'),
|
|
@@ -111,24 +113,24 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
111
113
|
minSize,
|
|
112
114
|
delim('+'),
|
|
113
115
|
token('parenthesis-block'),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
maxSize,
|
|
117
|
+
delim('-'),
|
|
118
|
+
minSize,
|
|
117
119
|
token('close-parenthesis'),
|
|
118
120
|
delim('*'),
|
|
119
121
|
token('parenthesis-block'),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
token('close-parenthesis'),
|
|
122
|
+
token('parenthesis-block'),
|
|
123
|
+
length(100, 'vw'),
|
|
124
|
+
delim('-'),
|
|
125
|
+
minViewport,
|
|
126
|
+
token('close-parenthesis'),
|
|
127
|
+
delim('/'),
|
|
128
|
+
token('parenthesis-block'),
|
|
129
|
+
maxViewport,
|
|
130
|
+
delim('-'),
|
|
131
|
+
minViewport,
|
|
131
132
|
token('close-parenthesis'),
|
|
133
|
+
token('close-parenthesis')
|
|
132
134
|
])
|
|
133
135
|
])
|
|
134
136
|
])
|
|
@@ -6,12 +6,12 @@ const llsCssSsrCollectPlugin = () => {
|
|
|
6
6
|
const cssIds = new Map()
|
|
7
7
|
return {
|
|
8
8
|
name: 'lls:llsCssSsrCollectPlugin',
|
|
9
|
-
transform(src, id) {
|
|
9
|
+
transform (src, id) {
|
|
10
10
|
if (/module\.css$/.test(id)) {
|
|
11
11
|
cssIds.set(id, src)
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
flushStyles() {
|
|
14
|
+
flushStyles () {
|
|
15
15
|
const css = [...cssIds.values()].join('\n')
|
|
16
16
|
|
|
17
17
|
// when hmr, id changes but not css-selector so we get two rules with the same css-selector
|
package/src/llsLadlePlugin.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const llsLadlePlugin = (sbFolder) => ({
|
|
2
2
|
name: 'lls:llsLadlePlugin',
|
|
3
|
-
config(config, { command }) {
|
|
3
|
+
config (config, { command }) {
|
|
4
4
|
const ladleCiEnv = /prod|tag|master|v\d/.test(process.env.LADLE_DEST) ? 'prod' : 'dev'
|
|
5
5
|
return {
|
|
6
6
|
base: command === 'serve' ? '/' : `https://build.lelivrescolaire.fr/storybook/${sbFolder}-${ladleCiEnv}/`,
|
|
7
|
-
//base: command === 'serve' ? '/' : 'http://localhost:5000/ladledist/',
|
|
7
|
+
// base: command === 'serve' ? '/' : 'http://localhost:5000/ladledist/',
|
|
8
8
|
|
|
9
9
|
build: {
|
|
10
10
|
minify: false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const llsLinariaImports = ({ client } = {}) => {
|
|
2
2
|
return {
|
|
3
3
|
name: 'lls:linaria-imports',
|
|
4
|
-
load(id) {
|
|
4
|
+
load (id) {
|
|
5
5
|
console.log('llsLinariaImports plugin is deprecated, remove usage. Already handled by llsSideRefreshMetaPlugin')
|
|
6
6
|
if (client) return
|
|
7
7
|
if (id.endsWith('@lls/viewer/lib/assets/viewer.css')) { return '' }
|
|
@@ -12,13 +12,13 @@ const llsLinariaSsrCollectPlugin = () => {
|
|
|
12
12
|
name: 'lls:llsLinariaSsrCollect',
|
|
13
13
|
/* we enforce pre because if vite-plugin-linaria resolves id, vite4 won't call us. Since we do not resolve, we can be put before */
|
|
14
14
|
enforce: 'pre',
|
|
15
|
-
config(config) {
|
|
15
|
+
config (config) {
|
|
16
16
|
linariaPlugin = config.plugins.find(plugin => plugin.name === 'linaria')
|
|
17
17
|
},
|
|
18
|
-
async resolveId(id, from) {
|
|
18
|
+
async resolveId (id, from) {
|
|
19
19
|
if (id.includes('@linaria-cache')) { cssIds.add(id) }
|
|
20
20
|
},
|
|
21
|
-
flushStyles() {
|
|
21
|
+
flushStyles () {
|
|
22
22
|
const css = [...cssIds].map(linariaPlugin.load).join('\n')
|
|
23
23
|
|
|
24
24
|
// when hmr, id changes but not css-selector so we get two rules with the same css-selector
|
|
@@ -1,25 +1,60 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import path from 'path'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
// sideRefreshActiveModules is of the form ['viewer', 'superkit', ...] with 'viewer' if repo launched
|
|
5
|
+
// WITH_VIEWER=1 npm start
|
|
6
|
+
export const makeSideRefreshThemeInterceptor = async (sideRefreshActiveModules) => {
|
|
7
|
+
const parentDir = path.basename(path.dirname(process.cwd()))
|
|
8
|
+
const sideRefreshThemes = {}
|
|
9
|
+
if (sideRefreshActiveModules.length) {
|
|
10
|
+
const cssThemeMap = {
|
|
11
|
+
viewer: '@lls/viewer/lib/css-bare.mjs',
|
|
12
|
+
// kit: no themes for kit
|
|
13
|
+
superkit: '@lls/superkit/lib/css-bare.mjs',
|
|
14
|
+
core: '@lls/core/lib/css-bare.mjs',
|
|
15
|
+
audio: '@lls/lls-audio/lib/css-bare.mjs',
|
|
16
|
+
code: '@lls/lls-code/lib/css-bare.mjs'
|
|
17
|
+
}
|
|
18
|
+
await Promise.all(sideRefreshActiveModules.map(sideRefreshName => {
|
|
19
|
+
if (!cssThemeMap[sideRefreshName]) {
|
|
20
|
+
throw new Error('invalid side refresh name' + sideRefreshName)
|
|
21
|
+
}
|
|
22
|
+
return import(cssThemeMap[sideRefreshName]).then(m => {
|
|
23
|
+
const mod = m.default || m
|
|
24
|
+
sideRefreshThemes[`${sideRefreshName}_dark`] = mod.themeIsDarkMode
|
|
25
|
+
sideRefreshThemes[`${sideRefreshName}_free`] = mod.themeIsFreeMode
|
|
26
|
+
sideRefreshThemes[`${sideRefreshName}_light`] = mod.themeIsNotDarkMode
|
|
27
|
+
})
|
|
28
|
+
}))
|
|
29
|
+
}
|
|
30
|
+
const folderRegex = new RegExp(Object.keys(sideRefreshThemes).map(capName => parentDir + '/' + capName.split('_')[0]).join('|'))
|
|
31
|
+
return (cap, id, next) => {
|
|
32
|
+
const match = id.match(folderRegex)?.[0]
|
|
33
|
+
cap = match ? `${match.split('/')[1]}_${cap}` : cap
|
|
34
|
+
return match && sideRefreshThemes[cap] ? sideRefreshThemes[cap] : next(cap)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
4
37
|
|
|
5
38
|
/**
|
|
6
39
|
* Side refresh plugin for LLS clients
|
|
7
40
|
* @param {*} param specifies which dependency is beign sideRefreshed
|
|
8
41
|
* @returns a plugin to pass to vite and aliases for sideRefreshed packages
|
|
9
42
|
*/
|
|
10
|
-
const llsSideRefreshMetaPlugin = ({ viewer: iViewer, superkit: iSuperkit, kit: iKit, utils: iUtils, core: iCore, code: iCode }, { client, publicDir='ladleassets' } = {}) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
console.log('sideResfresh: ', [
|
|
43
|
+
const llsSideRefreshMetaPlugin = ({ audio: iAudio, viewer: iViewer, superkit: iSuperkit, kit: iKit, utils: iUtils, core: iCore, code: iCode }, { client, publicDir = 'ladleassets' } = {}) => {
|
|
44
|
+
const pwd = process.cwd()
|
|
45
|
+
let activeModules = []
|
|
46
|
+
if ([iViewer, iSuperkit, iKit, iUtils, iCore, iCode, iAudio].some(x => x)) {
|
|
47
|
+
activeModules = [
|
|
16
48
|
iViewer && 'viewer',
|
|
17
49
|
iSuperkit && 'superkit',
|
|
18
50
|
iKit && 'kit',
|
|
19
51
|
iUtils && 'utils',
|
|
20
52
|
iCore && 'core',
|
|
21
|
-
iCode && 'code'
|
|
22
|
-
|
|
53
|
+
iCode && 'code',
|
|
54
|
+
iAudio && 'audio'
|
|
55
|
+
].filter(Boolean)
|
|
56
|
+
// eslint-disable-next-line no-console
|
|
57
|
+
console.log('sideResfresh: ', activeModules)
|
|
23
58
|
}
|
|
24
59
|
|
|
25
60
|
const makeResolver = (dirname, aliasImport) => {
|
|
@@ -27,7 +62,7 @@ const llsSideRefreshMetaPlugin = ({ viewer: iViewer, superkit: iSuperkit, kit: i
|
|
|
27
62
|
const projectDir = path.join(projectPath, 'src/')
|
|
28
63
|
const projectDirs = fs.readdirSync(projectDir).map(x => x.replace(/\.[jt]sx?$/, ''))
|
|
29
64
|
return {
|
|
30
|
-
async resolve(id, from) {
|
|
65
|
+
async resolve (id, from) {
|
|
31
66
|
if (projectDirs.some(dir => id.startsWith(dir))) {
|
|
32
67
|
try {
|
|
33
68
|
const resolution = await this.resolve(projectDir + id, from, { skipSelf: true })
|
|
@@ -48,7 +83,7 @@ const llsSideRefreshMetaPlugin = ({ viewer: iViewer, superkit: iSuperkit, kit: i
|
|
|
48
83
|
['@' + dirname]: path.join(projectPath, 'src'),
|
|
49
84
|
[aliasImport || '@' + dirname]: path.join(projectPath, 'src')
|
|
50
85
|
},
|
|
51
|
-
shouldResolve(from) {
|
|
86
|
+
shouldResolve (from) {
|
|
52
87
|
return from.includes(dirname)
|
|
53
88
|
}
|
|
54
89
|
}
|
|
@@ -62,11 +97,12 @@ const llsSideRefreshMetaPlugin = ({ viewer: iViewer, superkit: iSuperkit, kit: i
|
|
|
62
97
|
const kit = (iKit && makeResolver('lls-kit', '@kit')) || makeNoopResolver()
|
|
63
98
|
const utils = (iUtils && makeResolver('utils', 'commons')) || makeNoopResolver()
|
|
64
99
|
const core = (iCore && makeResolver('core', '@core')) || makeNoopResolver()
|
|
65
|
-
const code = (iCode && makeResolver('code', '@code')) || makeNoopResolver()
|
|
100
|
+
const code = (iCode && makeResolver('lls-code', '@code')) || makeNoopResolver()
|
|
101
|
+
const audio = (iAudio && makeResolver('lls-audio', '@audio')) || makeNoopResolver()
|
|
66
102
|
|
|
67
103
|
const VIRTUAL_ID = 'sideRefresh/node_modules' // specify node_modules to bypass linaria plugin parsing css file... (cant tweak exclude regex)
|
|
68
104
|
const key = basename => path.join(pwd, publicDir, 'assets', basename)
|
|
69
|
-
const loads = new Map(['core.css', 'viewer.css', 'superkit.css', 'lls-kit.css', 'lls-kit-fonts.css', 'lls-audio.css', 'lls-code.css'].map(basename => {
|
|
105
|
+
const loads = new Map(['core.css', 'viewer.css', 'superkit.css', 'lls-kit.css', 'lls-kit-fonts.css', 'lls-audio.css', 'lls-code.css', 'lls-audio.css'].map(basename => {
|
|
70
106
|
let promise = ''
|
|
71
107
|
const getPromise = () => {
|
|
72
108
|
if (client && !pwd.includes(basename.replace('.css', ''))) {
|
|
@@ -78,21 +114,21 @@ const llsSideRefreshMetaPlugin = ({ viewer: iViewer, superkit: iSuperkit, kit: i
|
|
|
78
114
|
}))
|
|
79
115
|
const plugin = () => ({
|
|
80
116
|
name: 'lls:sideRefresh',
|
|
81
|
-
async resolveId(id, from) {
|
|
117
|
+
async resolveId (id, from) {
|
|
82
118
|
const basename = path.basename(id)
|
|
83
|
-
if (['core.css', 'viewer.css', 'superkit.css', 'lls-kit.css', 'lls-kit-fonts.css', 'lls-audio.css', 'lls-code.css'].includes(basename)) {
|
|
119
|
+
if (['core.css', 'viewer.css', 'superkit.css', 'lls-kit.css', 'lls-kit-fonts.css', 'lls-audio.css', 'lls-code.css', 'lls-audio.css'].includes(basename)) {
|
|
84
120
|
return VIRTUAL_ID + key(basename)
|
|
85
121
|
}
|
|
86
|
-
if (id.includes('@linaria-cache')) { return }
|
|
87
122
|
if (viewer.shouldResolve(from)) { return viewer.resolve.call(this, id, from) }
|
|
88
123
|
if (superkit.shouldResolve(from)) { return superkit.resolve.call(this, id, from) }
|
|
89
124
|
if (kit.shouldResolve(from)) { return kit.resolve.call(this, id, from) }
|
|
90
125
|
if (utils.shouldResolve(from)) { return utils.resolve.call(this, id, from) }
|
|
91
126
|
if (core.shouldResolve(from)) { return core.resolve.call(this, id, from) }
|
|
92
127
|
if (code.shouldResolve(from)) { return code.resolve.call(this, id, from) }
|
|
128
|
+
if (audio.shouldResolve(from)) { return audio.resolve.call(this, id, from) }
|
|
93
129
|
},
|
|
94
130
|
|
|
95
|
-
async load(id) {
|
|
131
|
+
async load (id) {
|
|
96
132
|
if (loads.has(id)) {
|
|
97
133
|
return loads.get(id)()
|
|
98
134
|
}
|
|
@@ -104,9 +140,10 @@ const llsSideRefreshMetaPlugin = ({ viewer: iViewer, superkit: iSuperkit, kit: i
|
|
|
104
140
|
...kit.alias,
|
|
105
141
|
...utils.alias,
|
|
106
142
|
...core.alias,
|
|
107
|
-
...code.alias
|
|
143
|
+
...code.alias,
|
|
144
|
+
...audio.alias
|
|
108
145
|
}
|
|
109
|
-
return { plugin, alias,
|
|
146
|
+
return { plugin, alias, activeModules }
|
|
110
147
|
}
|
|
111
148
|
|
|
112
149
|
export default llsSideRefreshMetaPlugin
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const llsVitestMock = () => ({
|
|
2
2
|
name: 'lls:vitestmock',
|
|
3
|
-
transform(code, id) {
|
|
3
|
+
transform (code, id) {
|
|
4
4
|
if (id.endsWith('@lls/viewer/lib/index.js')) {
|
|
5
5
|
return code
|
|
6
6
|
.replace(/require\("(@lls\/lls-audio|@lls\/lls-code|@yorab\/react-paint)"\)/g, (__, cap) => {
|
|
@@ -11,4 +11,4 @@ const llsVitestMock = () => ({
|
|
|
11
11
|
}
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
export default llsVitestMock
|
|
14
|
+
export default llsVitestMock
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
|
|
3
|
-
const esbuildAutoprefixerPlugin = async ({ from, to }) => {
|
|
3
|
+
const esbuildAutoprefixerPlugin = async ({ from, to, lightningcssOptions: { minify = false } = {} }) => {
|
|
4
4
|
const [{ transform, browserslistToTargets }, browserslist] = await Promise.all([import('lightningcss'), import('browserslist').then(m => m.default)])
|
|
5
5
|
const contents = await fs.promises.readFile(from).then(async buf => {
|
|
6
|
-
const {code} = transform({
|
|
6
|
+
const { code } = transform({
|
|
7
7
|
code: buf,
|
|
8
|
-
targets: browserslistToTargets(browserslist('cover 99.5%'))
|
|
8
|
+
targets: browserslistToTargets(browserslist('cover 99.5%')),
|
|
9
|
+
minify
|
|
9
10
|
})
|
|
10
11
|
return code.toString()
|
|
11
12
|
})
|
|
12
13
|
return fs.promises.writeFile(to, contents)
|
|
13
14
|
}
|
|
14
|
-
export default esbuildAutoprefixerPlugin
|
|
15
|
+
export default esbuildAutoprefixerPlugin
|