@cssxjs/runtime 0.2.10 → 0.2.12

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 CHANGED
@@ -1,3 +1,15 @@
1
+ # v0.2.11 (Fri Nov 07 2025)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - fix: make pug reconstruct bindings; add extra options to babel preset; implement reactive update of @media for web and RN ([@cray0000](https://github.com/cray0000))
6
+
7
+ #### Authors: 1
8
+
9
+ - Pavel Zhukov ([@cray0000](https://github.com/cray0000))
10
+
11
+ ---
12
+
1
13
  # v0.2.10 (Wed Nov 05 2025)
2
14
 
3
15
  #### 🐛 Bug Fix
package/dimensions.js CHANGED
@@ -1,5 +1,15 @@
1
1
  import { observable } from '@nx-js/observer-util'
2
2
 
3
+ let dimensionsInitialized = false
4
+
5
+ export function setDimensionsInitialized (value) {
6
+ dimensionsInitialized = value
7
+ }
8
+
9
+ export function getDimensionsInitialized () {
10
+ return dimensionsInitialized
11
+ }
12
+
3
13
  export default observable({
4
14
  width: 0
5
15
  })
@@ -3,5 +3,6 @@ import { setPlatformHelpers } from '../platformHelpers/index.js'
3
3
  import { process } from '../processCached.js'
4
4
 
5
5
  setPlatformHelpers(platformHelpers)
6
+ platformHelpers.initDimensionsUpdater()
6
7
 
7
8
  export default process
@@ -3,5 +3,6 @@ import { setPlatformHelpers } from '../platformHelpers/index.js'
3
3
  import { process } from '../process.js'
4
4
 
5
5
  setPlatformHelpers(platformHelpers)
6
+ platformHelpers.initDimensionsUpdater()
6
7
 
7
8
  export default process
@@ -3,5 +3,6 @@ import * as platformHelpers from '../platformHelpers/web.js'
3
3
  import { process } from '../processCached.js'
4
4
 
5
5
  setPlatformHelpers(platformHelpers)
6
+ platformHelpers.initDimensionsUpdater()
6
7
 
7
8
  export default process
@@ -3,5 +3,6 @@ import * as platformHelpers from '../platformHelpers/web.js'
3
3
  import { process } from '../process.js'
4
4
 
5
5
  setPlatformHelpers(platformHelpers)
6
+ platformHelpers.initDimensionsUpdater()
6
7
 
7
8
  export default process
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cssxjs/runtime",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -54,5 +54,5 @@
54
54
  "optional": true
55
55
  }
56
56
  },
57
- "gitHead": "df668d1f0c63ad78e0668d63613f304e5cca3584"
57
+ "gitHead": "353563eb72be74e2911d1343adcda32eceba43e5"
58
58
  }
@@ -39,3 +39,12 @@ export function isPureReact (...args) {
39
39
  throw err
40
40
  }
41
41
  }
42
+
43
+ export function initDimensionsUpdater (...args) {
44
+ try {
45
+ return platformHelpers.initDimensionsUpdater(...args)
46
+ } catch (err) {
47
+ console.error('[cssxjs] platform helpers \'initDimensionsUpdater\' is not specified. Babel is probably misconfigured')
48
+ throw err
49
+ }
50
+ }
@@ -1,4 +1,5 @@
1
1
  import { Dimensions, Platform } from 'react-native'
2
+ import dimensions, { getDimensionsInitialized, setDimensionsInitialized } from '../dimensions.js'
2
3
 
3
4
  export function getDimensions () {
4
5
  return Dimensions.get('window')
@@ -11,3 +12,24 @@ export function getPlatform () {
11
12
  export function isPureReact () {
12
13
  return false
13
14
  }
15
+
16
+ // this is needed to trigger components rerendering to update @media queries
17
+ export function initDimensionsUpdater () {
18
+ if (getDimensionsInitialized()) return
19
+ setDimensionsInitialized(true)
20
+ dimensions.width = Dimensions.get('window').width
21
+ console.log('> Init dimensions updater for React Native. Initial width:', dimensions.width)
22
+
23
+ // debounce by 200ms to avoid too many updates in a short time
24
+ let timeoutId
25
+ Dimensions.addEventListener('change', ({ window }) => {
26
+ if (timeoutId) clearTimeout(timeoutId)
27
+ timeoutId = setTimeout(() => {
28
+ if (dimensions.width !== window.width) {
29
+ console.log('> update window width:', window.width)
30
+ dimensions.width = window.width
31
+ }
32
+ timeoutId = undefined
33
+ }, 200)
34
+ })
35
+ }
@@ -1,3 +1,5 @@
1
+ import dimensions, { getDimensionsInitialized, setDimensionsInitialized } from '../dimensions.js'
2
+
1
3
  export function getDimensions () {
2
4
  if (typeof window === 'undefined' || !window.innerWidth || !window.innerHeight) {
3
5
  console.warn('[cssx] No "window" global variable. Falling back to constant window width and height of 1024x768')
@@ -16,3 +18,29 @@ export function getPlatform () {
16
18
  export function isPureReact () {
17
19
  return true
18
20
  }
21
+
22
+ // this is needed to trigger components rerendering to update @media queries
23
+ export function initDimensionsUpdater () {
24
+ if (getDimensionsInitialized()) return
25
+ setDimensionsInitialized(true)
26
+ if (typeof window === 'undefined' || !window.innerWidth || !window.addEventListener) {
27
+ console.warn('[cssx] No "window" global variable. Setting default window width to 1024 and skipping updater.')
28
+ dimensions.width = 1024
29
+ return
30
+ }
31
+ dimensions.width = window.innerWidth
32
+ console.log('> Init dimensions updater for Web. Initial width:', dimensions.width)
33
+
34
+ // debounce by 200ms to avoid too many updates in a short time
35
+ let timeoutId
36
+ window.addEventListener('resize', () => {
37
+ if (timeoutId) clearTimeout(timeoutId)
38
+ timeoutId = setTimeout(() => {
39
+ if (dimensions.width !== window.innerWidth) {
40
+ console.log('> update window width:', window.innerWidth)
41
+ dimensions.width = window.innerWidth
42
+ }
43
+ timeoutId = undefined
44
+ }, 200)
45
+ })
46
+ }