startupjs 0.60.0-canary.0 → 0.60.0-canary.1
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "startupjs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.60.0-canary.
|
|
4
|
+
"version": "0.60.0-canary.1",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">= 14"
|
|
7
7
|
},
|
|
@@ -22,13 +22,12 @@
|
|
|
22
22
|
"./metro-babel-transformer": "./metro-babel-transformer.cjs",
|
|
23
23
|
"./babel": "./babel.cjs",
|
|
24
24
|
"./startupjs.config": "./startupjs.config.cjs",
|
|
25
|
-
"./package.json": "./package.json"
|
|
26
|
-
"./plugins/cssMediaUpdater.plugin": "./plugins/cssMediaUpdater.plugin.js"
|
|
25
|
+
"./package.json": "./package.json"
|
|
27
26
|
},
|
|
28
27
|
"bin": "./cli.js",
|
|
29
28
|
"license": "MIT",
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"@startupjs/bundler": "^0.60.0-canary.
|
|
30
|
+
"@startupjs/bundler": "^0.60.0-canary.1",
|
|
32
31
|
"@startupjs/cli": "^0.60.0-canary.0",
|
|
33
32
|
"@startupjs/hooks": "^0.60.0-canary.0",
|
|
34
33
|
"@startupjs/isomorphic-helpers": "^0.60.0-canary.0",
|
|
@@ -36,7 +35,7 @@
|
|
|
36
35
|
"@startupjs/server": "^0.60.0-canary.0",
|
|
37
36
|
"@startupjs/utils": "^0.60.0-canary.0",
|
|
38
37
|
"babel-preset-startupjs": "^0.60.0-canary.0",
|
|
39
|
-
"cssxjs": "^0.2.
|
|
38
|
+
"cssxjs": "^0.2.11",
|
|
40
39
|
"lodash": "^4.17.20",
|
|
41
40
|
"teamplay": "^0.3.26"
|
|
42
41
|
},
|
|
@@ -53,5 +52,5 @@
|
|
|
53
52
|
"optional": true
|
|
54
53
|
}
|
|
55
54
|
},
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "302e7e8004b435ddf4310611d3b59247e4e3b89e"
|
|
57
56
|
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { memo, Fragment, createElement as el, useCallback, useRef } from 'react'
|
|
2
|
-
import { useWindowDimensions } from 'react-native'
|
|
3
|
-
import { createPlugin } from '@startupjs/registry'
|
|
4
|
-
import { dimensions } from 'cssxjs'
|
|
5
|
-
import debounce from 'lodash/debounce'
|
|
6
|
-
|
|
7
|
-
const DEFAULT_UPDATE_DELAY = 200
|
|
8
|
-
|
|
9
|
-
export default createPlugin({
|
|
10
|
-
name: 'cssMediaUpdater',
|
|
11
|
-
enabled: true,
|
|
12
|
-
order: 'system root',
|
|
13
|
-
client: ({ updateDelay }) => ({
|
|
14
|
-
renderRoot ({ children }) {
|
|
15
|
-
return (
|
|
16
|
-
el(Fragment, null,
|
|
17
|
-
el(MediaUpdater, { updateDelay }),
|
|
18
|
-
children
|
|
19
|
-
)
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
// eslint-disable-next-line react/display-name
|
|
26
|
-
const MediaUpdater = memo(({ updateDelay = DEFAULT_UPDATE_DELAY }) => {
|
|
27
|
-
const widthRef = useRef()
|
|
28
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
-
const updateWidth = useCallback(
|
|
30
|
-
debounce(width => {
|
|
31
|
-
if (dimensions.width !== width) {
|
|
32
|
-
console.log('> update window width:', width)
|
|
33
|
-
dimensions.width = width
|
|
34
|
-
}
|
|
35
|
-
}, updateDelay, { leading: false, trailing: true }),
|
|
36
|
-
[]
|
|
37
|
-
)
|
|
38
|
-
const { width } = useWindowDimensions()
|
|
39
|
-
if (widthRef.current == null) {
|
|
40
|
-
widthRef.current = width
|
|
41
|
-
dimensions.width = width
|
|
42
|
-
} else if (widthRef.current !== width) {
|
|
43
|
-
widthRef.current = width
|
|
44
|
-
updateWidth(width)
|
|
45
|
-
}
|
|
46
|
-
return null
|
|
47
|
-
})
|