@lls/vitescripts 2.0.20 → 2.0.22
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 +36 -41
- 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 +2 -2
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
|
|
|
@@ -61,17 +63,18 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
61
63
|
const delim = (operator) => ({ type: 'token', value: { type: 'delim', value: operator } })
|
|
62
64
|
const length = (value, unit) => ({ type: 'length', value: { value, unit } })
|
|
63
65
|
const func = (name, args) => ({ type: 'function', value: { name, arguments: args } })
|
|
66
|
+
const num = value => ({ type: 'token', value: { type: 'number', value } })
|
|
64
67
|
return {
|
|
65
68
|
enforce: 'pre',
|
|
66
|
-
transform(src, id) {
|
|
69
|
+
transform (src, id) {
|
|
67
70
|
if (!/module\.css(\?.*)?$/.test(id)) {
|
|
68
71
|
return undefined
|
|
69
72
|
}
|
|
70
73
|
const back = src
|
|
71
74
|
.replace(/@cx\((Body[123]|Heading[1234]|Button[12]|Supporting|RippleEffect|FontFamily)\)/g, replaceKitBag)
|
|
72
75
|
.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)
|
|
76
|
+
.replace(/\${(themeIsFreeMode|themeIsDarkMode|themeIsNotDarkMode)}/g, (__, cap) => replaceTheme(cap, id))
|
|
77
|
+
.replace(/@llsTheme\((dark|light|free)\)/g, (__, cap) => replaceTheme(cap, id))
|
|
75
78
|
|
|
76
79
|
.replace(/\${getFluidSize\({(.*?)}\)}/gs, replaceGetFluidSize)
|
|
77
80
|
.replace(/\${getTruePx\((.*?)\)}?/g, 'calc(var(--size-index, 1) * $1 * 1px)')
|
|
@@ -80,27 +83,27 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
80
83
|
code: Buffer.from(back),
|
|
81
84
|
visitor: {
|
|
82
85
|
Function: {
|
|
83
|
-
getTruePx({ arguments: [value] }) {
|
|
86
|
+
getTruePx ({ arguments: [value] }) {
|
|
84
87
|
return {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
type: 'function',
|
|
89
|
+
value: {
|
|
90
|
+
name: 'calc',
|
|
88
91
|
arguments: [
|
|
89
92
|
value.type !== 'token' && token('parenthesis-block'),
|
|
90
93
|
value,
|
|
91
94
|
value.type !== 'token' && token('close-parenthesis'),
|
|
92
95
|
delim('*'),
|
|
93
|
-
{
|
|
96
|
+
{ type: 'var', value: { name: { ident: '--size-index', from: null }, fallback: [{ type: 'token', value: { type: 'number', value: 1 } }] } },
|
|
94
97
|
delim('*'),
|
|
95
98
|
length(1, 'px')
|
|
96
99
|
].filter(Boolean)
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
},
|
|
100
|
-
getFluidSize({arguments: [minSize, comma1, maxSize, comma2, iMinViewport, comma3, iMaxViewport]}){
|
|
101
|
-
const minViewport = (typeof(
|
|
103
|
+
getFluidSize ({ arguments: [minSize, comma1, maxSize, comma2, iMinViewport, comma3, iMaxViewport] }) {
|
|
104
|
+
const minViewport = (typeof (iMinViewport) === 'undefined' || iMinViewport.value?.type === 'comma') ? length(320, 'px') : iMinViewport
|
|
102
105
|
const max = iMinViewport?.value?.type === 'comma' ? comma3 : iMaxViewport
|
|
103
|
-
const maxViewport = typeof(max) === 'undefined' ? length(1280, 'px') : max
|
|
106
|
+
const maxViewport = typeof (max) === 'undefined' ? length(1280, 'px') : max
|
|
104
107
|
return func('min', [
|
|
105
108
|
maxSize,
|
|
106
109
|
token('comma'),
|
|
@@ -110,25 +113,17 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
110
113
|
func('calc', [
|
|
111
114
|
minSize,
|
|
112
115
|
delim('+'),
|
|
113
|
-
|
|
114
|
-
maxSize,
|
|
115
|
-
delim('-'),
|
|
116
|
-
minSize,
|
|
117
|
-
token('close-parenthesis'),
|
|
116
|
+
num(maxSize?.value?.value - minSize?.value?.value),
|
|
118
117
|
delim('*'),
|
|
119
118
|
token('parenthesis-block'),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
token('close-parenthesis'),
|
|
125
|
-
delim('/'),
|
|
126
|
-
token('parenthesis-block'),
|
|
127
|
-
maxViewport,
|
|
128
|
-
delim('-'),
|
|
129
|
-
minViewport,
|
|
130
|
-
token('close-parenthesis'),
|
|
119
|
+
token('parenthesis-block'),
|
|
120
|
+
length(100, 'vw'),
|
|
121
|
+
delim('-'),
|
|
122
|
+
minViewport,
|
|
131
123
|
token('close-parenthesis'),
|
|
124
|
+
delim('/'),
|
|
125
|
+
num(maxViewport?.value?.value - minViewport?.value.value),
|
|
126
|
+
token('close-parenthesis')
|
|
132
127
|
])
|
|
133
128
|
])
|
|
134
129
|
])
|
|
@@ -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
|
|
@@ -3,7 +3,7 @@ import fs from 'fs'
|
|
|
3
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
8
|
targets: browserslistToTargets(browserslist('cover 99.5%')),
|
|
9
9
|
minify
|
|
@@ -12,4 +12,4 @@ const esbuildAutoprefixerPlugin = async ({ from, to, lightningcssOptions: { mini
|
|
|
12
12
|
})
|
|
13
13
|
return fs.promises.writeFile(to, contents)
|
|
14
14
|
}
|
|
15
|
-
export default esbuildAutoprefixerPlugin
|
|
15
|
+
export default esbuildAutoprefixerPlugin
|