diff --git a/.changeset/config.json b/.changeset/config.json index fcc8804f..3c34b3cb 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -8,6 +8,8 @@ "baseBranch": "main", "updateInternalDependencies": "patch", "ignore": [ - "next-example" + "next-example", + "vite-example", + "vite-lib-example" ] } diff --git a/.changeset/curly-mice-promise.md b/.changeset/curly-mice-promise.md new file mode 100644 index 00000000..7b670ae0 --- /dev/null +++ b/.changeset/curly-mice-promise.md @@ -0,0 +1,5 @@ +--- +"@devup-ui/wasm": patch +--- + +Support transpiled code diff --git a/.changeset/cyan-tigers-know.md b/.changeset/cyan-tigers-know.md new file mode 100644 index 00000000..56d91602 --- /dev/null +++ b/.changeset/cyan-tigers-know.md @@ -0,0 +1,5 @@ +--- +"@devup-ui/vite-plugin": minor +--- + +Implement vite plugin diff --git a/.changeset/mean-socks-drum.md b/.changeset/mean-socks-drum.md new file mode 100644 index 00000000..9419bda3 --- /dev/null +++ b/.changeset/mean-socks-drum.md @@ -0,0 +1,5 @@ +--- +"@devup-ui/webpack-plugin": patch +--- + +Fix watch mode issue diff --git a/.gitignore b/.gitignore index 869d44c5..c0926696 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ node_modules target *.*.timestamp-* coverage +.df +build_rs_cov.profraw +tsconfig.tsbuildinfo \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 4ff69722..40d551ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,6 +116,7 @@ name = "css" version = "0.1.0" dependencies = [ "once_cell", + "serial_test", ] [[package]] @@ -161,6 +162,7 @@ dependencies = [ "oxc_parser", "oxc_span", "oxc_syntax", + "serial_test", ] [[package]] @@ -175,6 +177,83 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "hashbrown" version = "0.15.2" @@ -245,6 +324,16 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.22" @@ -590,6 +679,29 @@ dependencies = [ "unicode-id-start", ] +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + [[package]] name = "petgraph" version = "0.7.1" @@ -642,6 +754,18 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "proc-macro2" version = "1.0.92" @@ -675,6 +799,15 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +[[package]] +name = "redox_syscall" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +dependencies = [ + "bitflags", +] + [[package]] name = "ropey" version = "1.6.1" @@ -718,6 +851,27 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scc" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28e1c91382686d21b5ac7959341fcb9780fa7c03773646995a87c950fa7be640" +dependencies = [ + "sdd", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sdd" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9" + [[package]] name = "self_cell" version = "1.1.0" @@ -762,6 +916,31 @@ dependencies = [ "serde", ] +[[package]] +name = "serial_test" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" +dependencies = [ + "futures", + "log", + "once_cell", + "parking_lot", + "scc", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sheet" version = "0.1.0" @@ -793,6 +972,15 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.13.2" diff --git a/apps/vite-lib/devup.json b/apps/vite-lib/devup.json new file mode 100644 index 00000000..bdad1809 --- /dev/null +++ b/apps/vite-lib/devup.json @@ -0,0 +1,40 @@ +{ + "theme": { + "colors": { + "default": { + "text": "purple" + }, + "dark": { + "text": "#fff" + } + }, + "typography": { + "bold": { + "fontFamily": "Freesentation", + "fontSize": "14px", + "fontWeight": "800", + "lineHeight": "120%", + "letterSpacing": "-0.28px" + }, + "header": [ + { + "fontFamily": "Freesentation", + "fontSize": "12px", + "fontWeight": "600", + "lineHeight": "120%", + "letterSpacing": "-0.24px" + }, + null, + null, + null, + { + "fontFamily": "Freesentation", + "fontSize": "16px", + "fontWeight": "600", + "lineHeight": "120%", + "letterSpacing": "-0.32px" + } + ] + } + } +} diff --git a/apps/vite-lib/package.json b/apps/vite-lib/package.json new file mode 100644 index 00000000..63a4861a --- /dev/null +++ b/apps/vite-lib/package.json @@ -0,0 +1,23 @@ +{ + "name": "vite-lib-example", + "version": "0.1.0", + "type": "module", + "private": true, + "scripts": { + "build": "vite build", + "lint": "tsc && eslint" + }, + "dependencies": { + "react": "^19.0.0", + "@devup-ui/react": "workspace:*", + "vite": "^6.0.7" + }, + "devDependencies": { + "vite-plugin-dts": "^4.5.0", + "@devup-ui/vite-plugin": "workspace:*", + "@vitejs/plugin-react": "^4.3.4", + "typescript": "^5", + "@types/node": "^20", + "@types/react": "^19" + } +} diff --git a/apps/vite-lib/src/index.tsx b/apps/vite-lib/src/index.tsx new file mode 100644 index 00000000..684a259e --- /dev/null +++ b/apps/vite-lib/src/index.tsx @@ -0,0 +1,21 @@ +import { Box, Flex, Text } from '@devup-ui/react' + +export function Lib() { + return ( +
+ + hello + + typo + + section + +
+ ) +} diff --git a/apps/vite-lib/tsconfig.json b/apps/vite-lib/tsconfig.json new file mode 100644 index 00000000..09085d3e --- /dev/null +++ b/apps/vite-lib/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "target": "ES2017", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "paths": { + "@/*": [ + "./src/*" + ] + } + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ".df/*.d.ts" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/apps/vite-lib/vite.config.ts b/apps/vite-lib/vite.config.ts new file mode 100644 index 00000000..2357486e --- /dev/null +++ b/apps/vite-lib/vite.config.ts @@ -0,0 +1,61 @@ +import { DevupUI } from '@devup-ui/vite-plugin' +import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' +import dts from 'vite-plugin-dts' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [ + react(), + DevupUI({ + extractCss: false, + }), + dts({ + entryRoot: 'src', + staticImport: true, + pathsToAliases: false, + exclude: [ + '**/__tests__/**/*', + '**/*.test.(tsx|ts|js|jsx)', + '**/*.test-d.(tsx|ts|js|jsx)', + 'vite.config.ts', + ], + include: ['**/src/**/*.(ts|tsx)', '.df/*.d.ts'], + copyDtsFiles: true, + compilerOptions: { + isolatedModules: false, + declaration: true, + }, + }) as any, + ], + build: { + rollupOptions: { + onwarn: (warning) => { + if (warning.code === 'MODULE_LEVEL_DIRECTIVE') { + return + } + }, + external: (source) => { + return !(source.includes('src') || source.startsWith('.')) + }, + + output: { + dir: 'dist', + preserveModules: true, + preserveModulesRoot: 'src', + + exports: 'named', + assetFileNames({ name }) { + return name?.replace(/^src\//g, '') ?? '' + }, + }, + }, + lib: { + formats: ['es', 'cjs'], + entry: { + index: 'src/index.tsx', + }, + }, + outDir: 'dist', + }, +}) diff --git a/apps/vite/devup.json b/apps/vite/devup.json new file mode 100644 index 00000000..bdad1809 --- /dev/null +++ b/apps/vite/devup.json @@ -0,0 +1,40 @@ +{ + "theme": { + "colors": { + "default": { + "text": "purple" + }, + "dark": { + "text": "#fff" + } + }, + "typography": { + "bold": { + "fontFamily": "Freesentation", + "fontSize": "14px", + "fontWeight": "800", + "lineHeight": "120%", + "letterSpacing": "-0.28px" + }, + "header": [ + { + "fontFamily": "Freesentation", + "fontSize": "12px", + "fontWeight": "600", + "lineHeight": "120%", + "letterSpacing": "-0.24px" + }, + null, + null, + null, + { + "fontFamily": "Freesentation", + "fontSize": "16px", + "fontWeight": "600", + "lineHeight": "120%", + "letterSpacing": "-0.32px" + } + ] + } + } +} diff --git a/apps/vite/index.html b/apps/vite/index.html new file mode 100644 index 00000000..f69a4c46 --- /dev/null +++ b/apps/vite/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/apps/vite/package.json b/apps/vite/package.json new file mode 100644 index 00000000..9db0d56e --- /dev/null +++ b/apps/vite/package.json @@ -0,0 +1,26 @@ +{ + "name": "vite-example", + "version": "0.1.0", + "type": "module", + "private": true, + "scripts": { + "dev": "vite dev", + "build": "vite build", + "start": "vite start", + "lint": "tsc && eslint" + }, + "dependencies": { + "react": "^19.0.0", + "react-dom": "^19.0.0", + "@devup-ui/react": "workspace:*" + }, + "devDependencies": { + "@devup-ui/vite-plugin": "workspace:*", + "vite": "^6.0.7", + "@vitejs/plugin-react": "^4.3.4", + "typescript": "^5", + "@types/node": "^20", + "@types/react": "^19", + "@types/react-dom": "^19" + } +} diff --git a/apps/vite/src/App.tsx b/apps/vite/src/App.tsx new file mode 100644 index 00000000..c7b01e9d --- /dev/null +++ b/apps/vite/src/App.tsx @@ -0,0 +1,18 @@ +import { Box, Text } from '@devup-ui/react' + +export default function App() { + return ( +
+ + hello + + typo +
+ ) +} diff --git a/apps/vite/src/main.tsx b/apps/vite/src/main.tsx new file mode 100644 index 00000000..7d74c216 --- /dev/null +++ b/apps/vite/src/main.tsx @@ -0,0 +1,10 @@ +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' + +import App from './App' + +createRoot(document.getElementById('root')!).render( + + + , +) diff --git a/apps/vite/tsconfig.json b/apps/vite/tsconfig.json new file mode 100644 index 00000000..09085d3e --- /dev/null +++ b/apps/vite/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "target": "ES2017", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "paths": { + "@/*": [ + "./src/*" + ] + } + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ".df/*.d.ts" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/apps/vite/vite.config.ts b/apps/vite/vite.config.ts new file mode 100644 index 00000000..a2fa73c8 --- /dev/null +++ b/apps/vite/vite.config.ts @@ -0,0 +1,8 @@ +import { DevupUI } from '@devup-ui/vite-plugin' +import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react(), DevupUI()], +}) diff --git a/codecov b/codecov deleted file mode 100755 index 1b2574ba..00000000 Binary files a/codecov and /dev/null differ diff --git a/codecov.SHA256SUM b/codecov.SHA256SUM deleted file mode 100644 index 69ab8535..00000000 --- a/codecov.SHA256SUM +++ /dev/null @@ -1 +0,0 @@ -bb3c8dcaf649c47ce0321ce153ebc781b88421c97c584b1956fb62c3399db755 codecov \ No newline at end of file diff --git a/codecov.SHA256SUM.sig b/codecov.SHA256SUM.sig deleted file mode 100644 index 0b25ee1f..00000000 --- a/codecov.SHA256SUM.sig +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQIzBAABCgAdFiEEJwNOf9uFDgu8LGL/gGuyiu13mGkFAmdUctkACgkQgGuyiu13 -mGnWiQ/9ETvUH5DK+XGjPLDr2O7abSvy1mmD2jZwDGCzYShKtR4m/H7nQ/3/KOtC -QBlrM23nIswRmQSWah4vajZHdLgRqJp5nuod1gA6Hlnsx/3ydO/AzYC7Niruk2PK -xzp1VANXBNRhTy/a4Fwt5/FjwaPT1KW8bp9EIZruqnnJohOb+D3ji8aC6F8H6Nfs -PGB9WPeb9PoviYJstmzVhaxgMT/5Kxktqzdpy9fe7l4Lq05oB+Pg1D2zsyN9KNMM -nVQHvuKAlIhe9Sml0FV2c2V7+7sTF15U1kjh6S0tYhrIrMTMiD4TWjIfgddxmhva -yjdFzeh4BAvNvjDAGpfqxN7r3e3ZXC9TTBlrPcG7VJMBX8bxHkbaCxoqYgw33wOi -78dZhH4o2dGqsUUJKiOJI3C9gHAIcf+bTbJtFGuoOj34FRFNrUbX3j4QVHffO85b -d16HbwGxO5PQ7jd5dBFFhgQxqNVF5DTozDhNzweMDqvaiC8p5vwNPWWhZkX28Uk4 -XBkOp/uS3ke/GzmPYtGSCbu4RbQZACKDJ2RIwhEt83OWssXfA999E4TwtwL7MfeR -5zEy7tiKlzwZ5D7JegNr5ZOgn6YqoPZ7xl/YhtIf67juhCKksmkLvPcKtawHtj4X -mWD8ejvqRhfotTD+FjROnjNh32bb/3md4yiXM/diooVm6J93DxQ= -=+iTB ------END PGP SIGNATURE----- diff --git a/libs/css/Cargo.toml b/libs/css/Cargo.toml index 0c743d19..c6008976 100644 --- a/libs/css/Cargo.toml +++ b/libs/css/Cargo.toml @@ -5,3 +5,4 @@ edition = "2021" [dependencies] once_cell = "1.20.2" +serial_test = "3.2.0" diff --git a/libs/css/src/lib.rs b/libs/css/src/lib.rs index aa94562e..d127017d 100644 --- a/libs/css/src/lib.rs +++ b/libs/css/src/lib.rs @@ -1,6 +1,5 @@ use once_cell::sync::Lazy; use std::collections::HashMap; -use std::hash::{DefaultHasher, Hasher}; use std::sync::Mutex; #[derive(Clone, Debug, PartialEq)] @@ -66,6 +65,16 @@ static GLOBAL_STYLE_PROPERTY: Lazy>> = Lazy::n map }) }); + +static GLOBAL_CLASS_MAP: Lazy>> = + Lazy::new(|| Mutex::new(HashMap::new())); + +/// for test +pub fn reset_class_map() { + let mut map = GLOBAL_CLASS_MAP.lock().unwrap(); + map.clear(); +} + pub fn to_kebab_case(value: &str) -> String { value .chars() @@ -99,52 +108,67 @@ pub fn sheet_to_classname( value: Option<&str>, selector: Option<&str>, ) -> String { - let mut hasher = DefaultHasher::new(); - hasher.write( - format!( - "{}-{}-{}-{}", - property, - level, - value.unwrap_or(""), - selector.unwrap_or("") - ) - .as_bytes(), + let key = format!( + "{}-{}-{}-{}", + property, + level, + value.unwrap_or(""), + selector.unwrap_or("") ); - format!("d{}", hasher.finish()) + let mut map = GLOBAL_CLASS_MAP.lock().unwrap(); + map.get(&key).map(|v| format!("d{}", v)).unwrap_or_else(|| { + let len = map.len(); + map.insert(key, len as i32); + format!("d{}", map.len() - 1) + }) } pub fn sheet_to_variable_name(property: &str, level: u8, selector: Option<&str>) -> String { - let mut hasher = DefaultHasher::new(); - hasher.write(format!("{}-{}-{}", property, level, selector.unwrap_or("")).as_bytes()); - format!("--d{}", hasher.finish()) + let key = format!("{}-{}-{}", property, level, selector.unwrap_or("")); + let mut map = GLOBAL_CLASS_MAP.lock().unwrap(); + map.get(&key) + .map(|v| format!("--d{}", v)) + .unwrap_or_else(|| { + let len = map.len(); + map.insert(key, len as i32); + format!("--d{}", map.len() - 1) + }) } #[cfg(test)] mod tests { use super::*; + use serial_test::serial; #[test] + #[serial] fn test_sheet_to_variable_name() { - let mut hasher = DefaultHasher::new(); - hasher.write(format!("{}-{}-{}", "color", 0, "").as_bytes()); + reset_class_map(); + assert_eq!(sheet_to_variable_name("background", 0, None), "--d0"); + assert_eq!( + sheet_to_variable_name("background", 0, Some("hover")), + "--d1" + ); + assert_eq!(sheet_to_variable_name("background", 1, None), "--d2"); assert_eq!( - sheet_to_variable_name("color", 0, None), - format!("--d{}", hasher.finish()) + sheet_to_variable_name("background", 1, Some("hover")), + "--d3" ); } #[test] + #[serial] fn test_sheet_to_classname() { - let mut hasher = DefaultHasher::new(); - hasher.write(format!("{}-{}-{}-{}", "color", 0, "red", "").as_bytes()); + reset_class_map(); + assert_eq!(sheet_to_classname("background", 0, None, None), "d0"); assert_eq!( - sheet_to_classname("color", 0, Some("red"), None), - format!("d{}", hasher.finish()) + sheet_to_classname("background", 0, Some("hover"), None), + "d1" ); - - assert_ne!( - sheet_to_classname("color", 0, Some("red"), None), - sheet_to_classname("color", 0, Some("red"), Some(":hover")), + assert_eq!(sheet_to_classname("background", 1, None, None), "d2"); + assert_eq!( + sheet_to_classname("background", 1, Some("hover"), None), + "d3" ); } diff --git a/libs/extractor/Cargo.toml b/libs/extractor/Cargo.toml index 2a5290ac..4686f228 100644 --- a/libs/extractor/Cargo.toml +++ b/libs/extractor/Cargo.toml @@ -13,4 +13,5 @@ oxc_codegen = "0.46.0" css = { path = "../css" } [dev-dependencies] -insta = "1.42.0" \ No newline at end of file +insta = "1.42.0" +serial_test = "3.2.0" \ No newline at end of file diff --git a/libs/extractor/src/component.rs b/libs/extractor/src/component.rs index b705349a..ccdbeeab 100644 --- a/libs/extractor/src/component.rs +++ b/libs/extractor/src/component.rs @@ -2,7 +2,7 @@ use crate::ExtractStyleValue::Static; use crate::{ExtractStaticStyle, ExtractStyleValue}; /// devup-ui export variable kind -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] pub enum ExportVariableKind { Box, Text, @@ -12,7 +12,6 @@ pub enum ExportVariableKind { VStack, Center, Image, - Css, } impl ExportVariableKind { @@ -27,7 +26,6 @@ impl ExportVariableKind { ExportVariableKind::Image => Ok("img"), ExportVariableKind::Button => Ok("button"), ExportVariableKind::Input => Ok("input"), - ExportVariableKind::Css => Err("Css does not have a tag"), } } } @@ -37,7 +35,6 @@ impl ExportVariableKind { match self { ExportVariableKind::Input | ExportVariableKind::Button - | ExportVariableKind::Css | ExportVariableKind::Text | ExportVariableKind::Image | ExportVariableKind::Box => vec![], @@ -102,7 +99,6 @@ impl TryFrom for ExportVariableKind { "Flex" => Ok(ExportVariableKind::Flex), "VStack" => Ok(ExportVariableKind::VStack), "Center" => Ok(ExportVariableKind::Center), - "css" => Ok(ExportVariableKind::Css), _ => Err(()), } } @@ -146,10 +142,7 @@ mod tests { ExportVariableKind::try_from("Center".to_string()), Ok(ExportVariableKind::Center) ); - assert_eq!( - ExportVariableKind::try_from("css".to_string()), - Ok(ExportVariableKind::Css) - ); + assert!(ExportVariableKind::try_from("css".to_string()).is_err()); assert!(ExportVariableKind::try_from("foo".to_string()).is_err()); } @@ -163,7 +156,6 @@ mod tests { assert_eq!(ExportVariableKind::Flex.to_tag(), Ok("div")); assert_eq!(ExportVariableKind::VStack.to_tag(), Ok("div")); assert_eq!(ExportVariableKind::Center.to_tag(), Ok("div")); - assert!(ExportVariableKind::Css.to_tag().is_err()); } #[test] @@ -222,6 +214,5 @@ mod tests { }) ] ); - assert_eq!(ExportVariableKind::Css.extract(), vec![]); } } diff --git a/libs/extractor/src/lib.rs b/libs/extractor/src/lib.rs index d927e71a..7256ffc1 100644 --- a/libs/extractor/src/lib.rs +++ b/libs/extractor/src/lib.rs @@ -1,7 +1,7 @@ mod component; mod gen_class_name; mod gen_style; -mod media_prop_extract_utils; +mod object_prop_extract_utils; mod prop_extract_utils; mod prop_modify_utils; mod utils; @@ -231,11 +231,15 @@ pub fn extract( #[cfg(test)] mod tests { use super::*; + use css::reset_class_map; use insta::assert_debug_snapshot; + use serial_test::serial; use std::hash::{DefaultHasher, Hasher}; #[test] + #[serial] fn extract_just_tsx() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", "const a = 1;", @@ -246,6 +250,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", "", @@ -257,7 +262,9 @@ mod tests { .unwrap()); } #[test] + #[serial] fn ignore_special_props() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r"import {Box} from '@devup-ui/core' @@ -271,7 +278,9 @@ mod tests { .unwrap()); } #[test] + #[serial] fn extract_style_props() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r"import {Box} from '@devup-ui/core' @@ -283,6 +292,7 @@ mod tests { } ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r"import {Box as C} from '@devup-ui/core' @@ -294,6 +304,7 @@ mod tests { } ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r"import {Input} from '@devup-ui/core' @@ -306,6 +317,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r"import {Button} from '@devup-ui/core' @@ -318,6 +330,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r"import {Flex} from '@devup-ui/core' @@ -332,7 +345,9 @@ mod tests { } #[test] + #[serial] fn extract_style_props_with_class_name() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import {Box as C} from '@devup-ui/core' @@ -345,6 +360,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import {Box as C} from '@devup-ui/core' @@ -357,6 +373,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import {Box as C} from '@devup-ui/core' @@ -369,6 +386,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import {Box as C} from '@devup-ui/core' @@ -380,6 +398,7 @@ mod tests { } ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import {Box as C} from '@devup-ui/core' @@ -394,7 +413,9 @@ mod tests { } #[test] + #[serial] fn extract_class_name_from_component() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import {VStack as C} from '@devup-ui/core' @@ -408,7 +429,9 @@ mod tests { .unwrap(),); } #[test] + #[serial] fn extract_responsive_style_props() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -423,7 +446,9 @@ mod tests { } #[test] + #[serial] fn extract_dynamic_style_props() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -438,7 +463,9 @@ mod tests { } #[test] + #[serial] fn extract_dynamic_responsive_style_props() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -453,7 +480,9 @@ mod tests { } #[test] + #[serial] fn extract_compound_responsive_style_props() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -468,7 +497,9 @@ mod tests { } #[test] + #[serial] fn extract_wrong_responsive_style_props() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -483,7 +514,9 @@ mod tests { } #[test] + #[serial] fn extract_variable_style_props_with_style() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -496,6 +529,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -510,7 +544,9 @@ mod tests { } #[test] + #[serial] fn extract_conditional_style_props() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -523,6 +559,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -535,6 +572,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -549,7 +587,9 @@ mod tests { } #[test] + #[serial] fn extract_responsive_conditional_style_props() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -562,6 +602,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -574,6 +615,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -586,6 +628,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -598,6 +641,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -610,6 +654,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -621,6 +666,7 @@ mod tests { } ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -633,6 +679,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -647,7 +694,9 @@ mod tests { } #[test] + #[serial] fn extract_logical_case() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -660,6 +709,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -672,6 +722,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -685,7 +736,9 @@ mod tests { .unwrap()); } #[test] + #[serial] fn extract_responsive_conditional_style_props_with_class_name() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -698,6 +751,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { Box } from "@devup-ui/core"; @@ -712,7 +766,9 @@ mod tests { } #[test] + #[serial] fn extract_selector() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r"import {Box} from '@devup-ui/core' @@ -729,7 +785,9 @@ mod tests { } #[test] + #[serial] fn extract_selector_with_responsive() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r"import {Box} from '@devup-ui/core' @@ -744,6 +802,7 @@ mod tests { ) .unwrap()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r"import {Box} from '@devup-ui/core' @@ -762,9 +821,11 @@ mod tests { } #[test] + #[serial] fn extract_static_css_class_name_props() { let mut hasher = DefaultHasher::new(); hasher.write("background-color: red;".as_bytes()); + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import { css } from "@devup-ui/core"; @@ -781,7 +842,9 @@ mod tests { } #[test] + #[serial] fn extract_static_css_with_theme() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import {Box} from '@devup-ui/core' @@ -796,7 +859,9 @@ mod tests { } #[test] + #[serial] fn apply_typography() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import {Text} from '@devup-ui/core' @@ -811,7 +876,9 @@ mod tests { } #[test] + #[serial] fn raise_error() { + reset_class_map(); assert!(extract( "test.wrong", "const a = 1;", @@ -824,6 +891,7 @@ mod tests { .to_string() .starts_with("Unknown file extension")); + reset_class_map(); assert_eq!( extract( "test.tsx", @@ -840,7 +908,9 @@ mod tests { } #[test] + #[serial] fn import_wrong_component() { + reset_class_map(); assert_debug_snapshot!(extract( "test.tsx", r#"import {W} from '@devup-ui/core' @@ -852,4 +922,109 @@ mod tests { ) .unwrap()); } + + #[test] + #[serial] + fn support_transpile_mjs() { + reset_class_map(); + assert_debug_snapshot!(extract( + "test.mjs", + r#"import { jsxs as r, jsx as e } from "react/jsx-runtime"; +import { Box as o, Text as t, Flex as i } from "@devup-ui/react"; +function c() { + return /* @__PURE__ */ r("div", { children: [ + /* @__PURE__ */ e( + o, + { + _hover: { + bg: "blue" + }, + bg: "$text", + color: "red", + children: "hello" + } + ), + /* @__PURE__ */ e(t, { typography: "header", children: "typo" }), + /* @__PURE__ */ e(i, { as: "section", mt: 2, children: "section" }) + ] }); +} +export { + c as Lib +};"#, + ExtractOption { + package: "@devup-ui/react".to_string(), + css_file: None + } + ) + .unwrap()); + + reset_class_map(); + assert_debug_snapshot!(extract( + "test.js", + r#"import { jsxs as r, jsx as e } from "react/jsx-runtime"; +import { Box as o, Text as t, Flex as i } from "@devup-ui/react"; +function c() { + return /* @__PURE__ */ r("div", { children: [ + /* @__PURE__ */ e( + o, + { + _hover: { + bg: "blue" + }, + bg: "$text", + color: "red", + children: "hello" + } + ), + /* @__PURE__ */ e(t, { typography: "header", children: "typo" }), + /* @__PURE__ */ e(i, { as: "section", mt: 2, children: "section" }) + ] }); +} +export { + c as Lib +};"#, + ExtractOption { + package: "@devup-ui/react".to_string(), + css_file: None + } + ) + .unwrap()); + } + + #[test] + #[serial] + fn support_transpile_cjs() { + reset_class_map(); + assert_debug_snapshot!(extract( + "test.cjs", + r#""use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("@devup-ui/react");function t(){return e.jsxs("div",{children:[e.jsx(r.Box,{_hover:{bg:"blue"},bg:"$text",color:"red",children:"hello"}),e.jsx(r.Text,{typography:"header",children:"typo"}),e.jsx(r.Flex,{as:"section",mt:2,children:"section"})]})}exports.Lib=t;"#, + ExtractOption { + package: "@devup-ui/react".to_string(), + css_file: None + } + ) + .unwrap()); + + reset_class_map(); + assert_debug_snapshot!(extract( + "test.cjs", + r#""use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const {jsx:e1, jsxs:e2}=require("react/jsx-runtime"),r=require("@devup-ui/react");function t(){return e2("div",{children:[e1(r.Box,{_hover:{bg:"blue"},bg:"$text",color:"red",children:"hello"}),e1(r.Text,{typography:"header",children:"typo"}),e1(r.Flex,{as:"section",mt:2,children:"section"})]})}exports.Lib=t;"#, + ExtractOption { + package: "@devup-ui/react".to_string(), + css_file: None + } + ) + .unwrap()); + + reset_class_map(); + assert_debug_snapshot!(extract( + "test.js", + r#""use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("@devup-ui/react");function t(){return e.jsxs("div",{children:[e.jsx(r.Box,{_hover:{bg:"blue"},bg:"$text",color:"red",children:"hello"}),e.jsx(r.Text,{typography:"header",children:"typo"}),e.jsx(r.Flex,{as:"section",mt:2,children:"section"})]})}exports.Lib=t;"#, + ExtractOption { + package: "@devup-ui/react".to_string(), + css_file: None + } + ) + .unwrap()); + } } diff --git a/libs/extractor/src/media_prop_extract_utils.rs b/libs/extractor/src/object_prop_extract_utils.rs similarity index 53% rename from libs/extractor/src/media_prop_extract_utils.rs rename to libs/extractor/src/object_prop_extract_utils.rs index c0cc7240..ec05ed50 100644 --- a/libs/extractor/src/media_prop_extract_utils.rs +++ b/libs/extractor/src/object_prop_extract_utils.rs @@ -1,14 +1,16 @@ use crate::prop_extract_utils::extract_style_prop_from_express; +use crate::utils::is_special_property; use crate::ExtractStyleProp; use oxc_ast::ast::{ - ArrayExpressionElement, JSXAttributeValue, JSXExpression, ObjectExpression, ObjectPropertyKind, + ArrayExpressionElement, Expression, JSXAttributeValue, JSXExpression, ObjectExpression, + ObjectPropertyKind, }; use oxc_ast::AstBuilder; -pub fn extract_media_prop<'a>( +pub fn extract_object_from_jsx_attr<'a>( ast_builder: &AstBuilder<'a>, value: &JSXAttributeValue<'a>, - media: &str, + media: Option<&str>, ) -> Option>> { match value { JSXAttributeValue::ExpressionContainer(expression) => match &expression.expression { @@ -42,22 +44,56 @@ pub fn extract_media_prop<'a>( } } +pub fn extract_from_style_value<'a>( + ast_builder: &AstBuilder<'a>, + value: &Expression<'a>, + media: Option<&str>, +) -> Option>> { + match value { + Expression::ObjectExpression(obj) => { + let mut props = vec![]; + props.append(&mut extract_props_from_object_expression( + ast_builder, + obj, + 0, + media, + )); + Some(props) + } + Expression::ArrayExpression(arr) => { + let mut props = vec![]; + for (idx, e) in arr.elements.iter().enumerate() { + if let ArrayExpressionElement::ObjectExpression(oo) = e { + props.append(&mut extract_props_from_object_expression( + ast_builder, + oo, + idx as u8, + media, + )); + } + } + Some(props) + } + _ => None, + } +} + fn extract_props_from_object_expression<'a>( ast_builder: &AstBuilder<'a>, obj: &ObjectExpression<'a>, level: u8, - media: &str, + media: Option<&str>, ) -> Vec> { let mut props = vec![]; for p in obj.properties.iter() { if let ObjectPropertyKind::ObjectProperty(o) = p { - if let Some(ret) = extract_style_prop_from_express( - ast_builder, - o.key.name().unwrap().to_string().as_str(), - &o.value, - level, - Some(media), - ) { + let name = o.key.name().unwrap(); + if is_special_property(&name) { + continue; + } + if let Some(ret) = + extract_style_prop_from_express(ast_builder, &name, &o.value, level, media) + { props.push(ret); } }; diff --git a/libs/extractor/src/prop_modify_utils.rs b/libs/extractor/src/prop_modify_utils.rs index 4a18d658..41a72691 100644 --- a/libs/extractor/src/prop_modify_utils.rs +++ b/libs/extractor/src/prop_modify_utils.rs @@ -1,12 +1,120 @@ -use crate::gen_class_name::{apply_class_name_attribute, gen_class_names}; +use crate::gen_class_name::{ + apply_class_name_attribute, gen_class_names, merge_expression_for_class_name, +}; use crate::gen_style::{apply_style_attribute, gen_styles}; use crate::ExtractStyleProp; -use oxc_ast::ast::JSXAttributeItem; +use oxc_allocator::CloneIn; use oxc_ast::ast::JSXAttributeItem::Attribute; use oxc_ast::ast::JSXAttributeName::Identifier; +use oxc_ast::ast::{Expression, JSXAttributeItem, ObjectPropertyKind, PropertyKey, PropertyKind}; use oxc_ast::AstBuilder; use oxc_span::SPAN; +/// modify object props +pub fn modify_prop_object<'a>( + ast_builder: &AstBuilder<'a>, + props: &mut oxc_allocator::Vec>, + styles: Vec>, +) { + let mut class_name_prop = None; + let mut style_prop = None; + + for idx in 0..props.len() { + if let ObjectPropertyKind::ObjectProperty(attr) = &props[idx] { + if let PropertyKey::StaticIdentifier(ident) = &attr.key { + if ident.name == "className" { + if let ObjectPropertyKind::ObjectProperty(attr) = props.remove(idx) { + class_name_prop = Some(attr); + } + } else if ident.name == "style" { + if let ObjectPropertyKind::ObjectProperty(attr) = props.remove(idx) { + style_prop = Some(attr); + } + } + } + } + } + + // should modify class name prop + if let Some(ex) = gen_class_names(ast_builder, &styles) { + if let Some(pr) = if let Some(class_name_prop) = class_name_prop { + let res = merge_expression_for_class_name( + ast_builder, + vec![class_name_prop.value.clone_in(ast_builder.allocator), ex], + ); + res.map(|res| { + ast_builder.alloc_object_property( + SPAN, + PropertyKind::Init, + PropertyKey::StaticIdentifier( + ast_builder.alloc_identifier_name(SPAN, "className"), + ), + res, + false, + false, + false, + ) + }) + } else { + Some(ast_builder.alloc_object_property( + SPAN, + PropertyKind::Init, + PropertyKey::StaticIdentifier(ast_builder.alloc_identifier_name(SPAN, "className")), + ex, + false, + false, + false, + )) + } { + props.push(ObjectPropertyKind::ObjectProperty(pr)); + } + } else if let Some(class_name_prop) = class_name_prop { + // re add class name prop if not modified + props.push(ObjectPropertyKind::ObjectProperty(class_name_prop)) + } + + // should modify style prop + if let Some(mut ex) = gen_styles(ast_builder, &styles) { + if let Some(style_prop) = style_prop { + props.push(ObjectPropertyKind::ObjectProperty( + ast_builder.alloc_object_property( + SPAN, + PropertyKind::Init, + PropertyKey::StaticIdentifier(ast_builder.alloc_identifier_name(SPAN, "style")), + if ex.properties.is_empty() { + Expression::ObjectExpression(ast_builder.alloc(ex)) + } else { + ex.properties.push(ObjectPropertyKind::SpreadProperty( + ast_builder.alloc_spread_element( + SPAN, + style_prop.value.clone_in(ast_builder.allocator), + ), + )); + Expression::ObjectExpression(ast_builder.alloc(ex)) + }, + false, + false, + false, + ), + )); + } else { + props.push(ObjectPropertyKind::ObjectProperty( + ast_builder.alloc_object_property( + SPAN, + PropertyKind::Init, + PropertyKey::StaticIdentifier(ast_builder.alloc_identifier_name(SPAN, "style")), + Expression::ObjectExpression(ast_builder.alloc(ex)), + false, + false, + false, + ), + )); + }; + } else if let Some(style_prop) = style_prop { + // re add class name prop if not modified + props.push(ObjectPropertyKind::ObjectProperty(style_prop)) + } +} /// modify JSX props pub fn modify_props<'a>( ast_builder: &AstBuilder<'a>, diff --git a/libs/extractor/src/snapshots/extractor__tests__apply_typography.snap b/libs/extractor/src/snapshots/extractor__tests__apply_typography.snap index 819ae7b9..aae74d9d 100644 --- a/libs/extractor/src/snapshots/extractor__tests__apply_typography.snap +++ b/libs/extractor/src/snapshots/extractor__tests__apply_typography.snap @@ -8,5 +8,5 @@ ExtractOutput { "bold", ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Text } from \"@devup-ui/core\";\n;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_class_name_from_component.snap b/libs/extractor/src/snapshots/extractor__tests__extract_class_name_from_component.snap index a0f53212..e443d0a2 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_class_name_from_component.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_class_name_from_component.snap @@ -37,5 +37,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { VStack as C } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_compound_responsive_style_props.snap b/libs/extractor/src/snapshots/extractor__tests__extract_compound_responsive_style_props.snap index 9973ba7f..f839704c 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_compound_responsive_style_props.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_compound_responsive_style_props.snap @@ -37,5 +37,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props-2.snap b/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props-2.snap index 0c4893c0..cc9fe18c 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props-2.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props-2.snap @@ -21,5 +21,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props-3.snap b/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props-3.snap index 335cc73d..7666592d 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props-3.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props-3.snap @@ -21,5 +21,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props.snap b/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props.snap index 6614b51a..1895de9b 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_conditional_style_props.snap @@ -21,5 +21,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_dynamic_responsive_style_props.snap b/libs/extractor/src/snapshots/extractor__tests__extract_dynamic_responsive_style_props.snap index 34daa2b4..cd4f07b7 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_dynamic_responsive_style_props.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_dynamic_responsive_style_props.snap @@ -29,5 +29,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_dynamic_style_props.snap b/libs/extractor/src/snapshots/extractor__tests__extract_dynamic_style_props.snap index 9eb51a16..6f325c7a 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_dynamic_style_props.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_dynamic_style_props.snap @@ -21,5 +21,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_logical_case-2.snap b/libs/extractor/src/snapshots/extractor__tests__extract_logical_case-2.snap index 8822c1cd..6772ebad 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_logical_case-2.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_logical_case-2.snap @@ -13,5 +13,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_logical_case-3.snap b/libs/extractor/src/snapshots/extractor__tests__extract_logical_case-3.snap index 6c358291..41428a9a 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_logical_case-3.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_logical_case-3.snap @@ -13,5 +13,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_logical_case.snap b/libs/extractor/src/snapshots/extractor__tests__extract_logical_case.snap index 50c19026..56eac602 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_logical_case.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_logical_case.snap @@ -13,5 +13,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-2.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-2.snap index 8913f137..83935fb1 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-2.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-2.snap @@ -29,5 +29,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-3.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-3.snap index 90bdef00..781d6807 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-3.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-3.snap @@ -45,5 +45,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-4.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-4.snap index cbbaffb8..85b57c3a 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-4.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-4.snap @@ -53,5 +53,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-5.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-5.snap index 5563648f..3f3f1b84 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-5.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-5.snap @@ -53,5 +53,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-6.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-6.snap index 61750872..5b148599 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-6.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-6.snap @@ -69,5 +69,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-7.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-7.snap index dfc9ed46..1de9cca6 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-7.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-7.snap @@ -13,5 +13,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-8.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-8.snap index 4c11277f..49bfc1f9 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-8.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props-8.snap @@ -21,5 +21,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props.snap index 765a0f48..aa48960f 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props.snap @@ -21,5 +21,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props_with_class_name-2.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props_with_class_name-2.snap index 8e2177a7..d870f3d7 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props_with_class_name-2.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props_with_class_name-2.snap @@ -13,5 +13,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props_with_class_name.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props_with_class_name.snap index 4b84b4d5..612d6e3c 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props_with_class_name.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_conditional_style_props_with_class_name.snap @@ -29,5 +29,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
w ? \"d16099640469738164034\" : \"d5377394017476416093\" : \"d2237786094991016968\"}`} />;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
w ? \"d0\" : \"d1\" : \"d2\"}`} />;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_style_props.snap b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_style_props.snap index 751723c3..3cca84bc 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_responsive_style_props.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_responsive_style_props.snap @@ -29,5 +29,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_selector.snap b/libs/extractor/src/snapshots/extractor__tests__extract_selector.snap index ba1c9156..1638d1ed 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_selector.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_selector.snap @@ -15,5 +15,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_selector_with_responsive-2.snap b/libs/extractor/src/snapshots/extractor__tests__extract_selector_with_responsive-2.snap index c7c54183..fd825f48 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_selector_with_responsive-2.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_selector_with_responsive-2.snap @@ -25,5 +25,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_selector_with_responsive.snap b/libs/extractor/src/snapshots/extractor__tests__extract_selector_with_responsive.snap index f422f9c8..4bd429ac 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_selector_with_responsive.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_selector_with_responsive.snap @@ -25,5 +25,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_static_css_with_theme.snap b/libs/extractor/src/snapshots/extractor__tests__extract_static_css_with_theme.snap index 833fbfd0..d9ea984a 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_static_css_with_theme.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_static_css_with_theme.snap @@ -13,5 +13,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_style_props-2.snap b/libs/extractor/src/snapshots/extractor__tests__extract_style_props-2.snap index 615e4205..d4d9d0f0 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_style_props-2.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_style_props-2.snap @@ -21,5 +21,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Box as C } from \"@devup-ui/core\";\n
;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n
;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_style_props-3.snap b/libs/extractor/src/snapshots/extractor__tests__extract_style_props-3.snap index 677e53af..a5e8c1fe 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_style_props-3.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_style_props-3.snap @@ -21,5 +21,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Input } from \"@devup-ui/core\";\n;\n", + code: "import \"@devup-ui/core/devup-ui.css\";\n;\n", } diff --git a/libs/extractor/src/snapshots/extractor__tests__extract_style_props-4.snap b/libs/extractor/src/snapshots/extractor__tests__extract_style_props-4.snap index d4fce6f9..de636714 100644 --- a/libs/extractor/src/snapshots/extractor__tests__extract_style_props-4.snap +++ b/libs/extractor/src/snapshots/extractor__tests__extract_style_props-4.snap @@ -21,5 +21,5 @@ ExtractOutput { }, ), ], - code: "import \"@devup-ui/core/devup-ui.css\";\nimport { Button } from \"@devup-ui/core\";\n