@cssxjs/loaders 0.2.27 → 0.2.31
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/CHANGELOG.md +22 -0
- package/cssToReactNativeLoader.js +33 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.2.31](https://github.com/startupjs/cssx/compare/v0.2.30...v0.2.31) (2026-01-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **runtime:** improve performance of substituting var() in css ([282cb46](https://github.com/startupjs/cssx/commit/282cb461369cdb951cc873973a2d0da97a682b9b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.2.30](https://github.com/startupjs/cssx/compare/v0.2.29...v0.2.30) (2026-01-18)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* support animation and transition (the way it's expected by Reanimated v4) ([44a1f77](https://github.com/startupjs/cssx/commit/44a1f778074f1f65a8ccd76994a6bf1a3eb5e4a7))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [0.2.27](https://github.com/startupjs/cssx/compare/v0.2.26...v0.2.27) (2025-12-16)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @cssxjs/loaders
|
|
@@ -2,15 +2,28 @@
|
|
|
2
2
|
const css2rn = require('@startupjs/css-to-react-native-transform').default
|
|
3
3
|
|
|
4
4
|
const EXPORT_REGEX = /:export\s*\{/
|
|
5
|
+
const VAR_NAMES_REGEX = /"var\(\s*--[A-Za-z0-9_-]+/g
|
|
5
6
|
|
|
6
7
|
module.exports = function cssToReactNative (source) {
|
|
7
8
|
source = escapeExport(source)
|
|
8
|
-
const cssObject = css2rn(source, {
|
|
9
|
+
const cssObject = css2rn(source, {
|
|
10
|
+
parseMediaQueries: true,
|
|
11
|
+
parsePartSelectors: true,
|
|
12
|
+
parseKeyframes: true
|
|
13
|
+
})
|
|
9
14
|
for (const key in cssObject.__exportProps || {}) {
|
|
10
15
|
cssObject[key] = parseStylValue(cssObject.__exportProps[key])
|
|
11
16
|
}
|
|
17
|
+
const stringifiedCss = JSON.stringify(cssObject)
|
|
12
18
|
// save hash to use with the caching system of @startupjs/cache
|
|
13
|
-
cssObject.__hash__ = simpleNumericHash(
|
|
19
|
+
cssObject.__hash__ = simpleNumericHash(stringifiedCss)
|
|
20
|
+
// OPTIMIZATION: save vars used in the styles for later replacement in runtime
|
|
21
|
+
// and also to determine whether we need to listen for variable changes
|
|
22
|
+
const vars = getVariableNames(stringifiedCss)
|
|
23
|
+
if (vars) cssObject.__vars = vars
|
|
24
|
+
// OPTIMIZATION: indicate whether @media queries are used.
|
|
25
|
+
// This is later used in runtime to determine whether we need to listen for dimension changes
|
|
26
|
+
if (hasMedia(cssObject)) cssObject.__hasMedia = true
|
|
14
27
|
return 'module.exports = ' + JSON.stringify(cssObject)
|
|
15
28
|
}
|
|
16
29
|
|
|
@@ -81,6 +94,23 @@ function escapeExport (source) {
|
|
|
81
94
|
|
|
82
95
|
// ref: https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0?permalink_comment_id=2694461#gistcomment-2694461
|
|
83
96
|
function simpleNumericHash (s) {
|
|
84
|
-
|
|
97
|
+
let i, h
|
|
98
|
+
for (i = 0, h = 0; i < s.length; i++) h = Math.imul(31, h) + s.charCodeAt(i) | 0
|
|
85
99
|
return h
|
|
86
100
|
}
|
|
101
|
+
|
|
102
|
+
function getVariableNames (cssString) {
|
|
103
|
+
let res = cssString.match(VAR_NAMES_REGEX)
|
|
104
|
+
if (!res) return
|
|
105
|
+
res = res.map(i => i.replace(/"var\(\s*/, ''))
|
|
106
|
+
res = [...new Set(res)].sort() // remove duplicates and sort
|
|
107
|
+
return res
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function hasMedia (styles = {}) {
|
|
111
|
+
for (const selector in styles) {
|
|
112
|
+
if (/^@media/.test(selector)) {
|
|
113
|
+
return true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cssxjs/loaders",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.31",
|
|
4
4
|
"description": "Webpack-compatible loaders for CSSX styles in React Native and Web bundlers",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./callLoader": "./callLoader.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@startupjs/css-to-react-native-transform": "
|
|
23
|
+
"@startupjs/css-to-react-native-transform": "2.1.0-2",
|
|
24
24
|
"stylus": "0.64.0"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "989ab68dbc3ed81262ccc51946ddaa01b90416a5"
|
|
27
27
|
}
|