nextia 7.0.4 → 7.0.6

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": "nextia",
3
3
  "description": "Create fast web applications",
4
- "version": "7.0.4",
4
+ "version": "7.0.6",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "engines": {
@@ -27,7 +27,7 @@
27
27
  ".": "./src/lib/index.js"
28
28
  },
29
29
  "scripts": {
30
- "clean": "rm -fr my-app node_modules package-lock.json .coverage out",
30
+ "clean": "rm -fr node_modules .coverage out package-lock.json",
31
31
  "format": "biome format",
32
32
  "lint": "biome lint src",
33
33
  "check": "biome check --reporter=summary src",
@@ -37,13 +37,13 @@
37
37
  "test:coverage": "vitest run --silent --coverage"
38
38
  },
39
39
  "peerDependencies": {
40
- "react": "^19.2.3",
41
- "react-dom": "^19.2.3"
40
+ "react": "^19.0.0",
41
+ "react-dom": "^19.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@vitejs/plugin-react": "^6.0.1",
45
- "@vitest/coverage-v8": "^4.1.2",
46
- "jsdom": "^29.0.1",
47
- "vitest": "^4.1.2"
44
+ "@vitejs/plugin-react": "6.0.1",
45
+ "@vitest/coverage-v8": "4.1.2",
46
+ "jsdom": "29.0.2",
47
+ "vitest": "4.1.2"
48
48
  }
49
49
  }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright (c) 2025 Sinuhe Maceda https://sinuhe.dev
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * https://github.com/sinuhedev/nextia
8
+ */
9
+
10
+ import { useCallback, useEffect, useState } from 'react'
11
+
12
+ function useQueryString() {
13
+ const getQueryString = useCallback(
14
+ () => ({
15
+ hash: window.location.hash.split('?')[0],
16
+ queryString: Object.fromEntries(
17
+ new URLSearchParams(window.location.hash.split('?')[1])
18
+ )
19
+ }),
20
+ []
21
+ )
22
+
23
+ const [queryString, setQueryString] = useState(getQueryString)
24
+
25
+ useEffect(() => {
26
+ const handlePopState = () => setQueryString(getQueryString())
27
+
28
+ window.addEventListener('popstate', handlePopState)
29
+ return () => {
30
+ window.removeEventListener('popstate', handlePopState)
31
+ }
32
+ }, [getQueryString])
33
+
34
+ return queryString
35
+ }
36
+
37
+ function useResize({ md = 768, lg = 1024, xl = 1280 }) {
38
+ const getResize = useCallback(
39
+ () => ({
40
+ width: window.innerWidth,
41
+ height: window.innerHeight,
42
+ sm: window.innerWidth < md,
43
+ md: window.innerWidth >= md && window.innerWidth < lg,
44
+ lg: window.innerWidth >= lg && window.innerWidth < xl,
45
+ xl: window.innerWidth >= xl
46
+ }),
47
+ [md, lg, xl]
48
+ )
49
+
50
+ const [resize, setResize] = useState(getResize)
51
+
52
+ useEffect(() => {
53
+ const handleResize = () => setResize(getResize())
54
+
55
+ window.addEventListener('resize', handleResize)
56
+ return () => {
57
+ window.removeEventListener('resize', handleResize)
58
+ }
59
+ }, [getResize])
60
+
61
+ return resize
62
+ }
63
+
64
+ export { useQueryString, useResize }
package/src/lib/index.js CHANGED
@@ -8,14 +8,9 @@
8
8
  */
9
9
 
10
10
  import { PagesFx, useFx } from './fx.js'
11
+ import { useQueryString, useResize } from './hooks.js'
11
12
  import { I18n, Icon, Link, Svg } from './ui.js'
12
- import {
13
- css,
14
- env,
15
- startViewTransition,
16
- useQueryString,
17
- useResize
18
- } from './utils.js'
13
+ import { css, env, startViewTransition } from './utils.js'
19
14
 
20
15
  export {
21
16
  css,
package/src/lib/utils.js CHANGED
@@ -7,7 +7,6 @@
7
7
  * https://github.com/sinuhedev/nextia
8
8
  */
9
9
 
10
- import { useCallback, useEffect, useState } from 'react'
11
10
  import { flushSync } from 'react-dom'
12
11
 
13
12
  /**
@@ -30,59 +29,7 @@ async function startViewTransition(fun = () => {}, ref, animation = 'fade') {
30
29
  }
31
30
 
32
31
  /**
33
- * hooks
34
- */
35
-
36
- function useQueryString() {
37
- const getQueryString = useCallback(
38
- () => ({
39
- hash: window.location.hash.split('?')[0],
40
- queryString: Object.fromEntries(
41
- new URLSearchParams(window.location.hash.split('?')[1])
42
- )
43
- }),
44
- []
45
- )
46
-
47
- const [queryString, setQueryString] = useState(getQueryString)
48
-
49
- useEffect(() => {
50
- const handlePopState = () => setQueryString(getQueryString())
51
-
52
- window.addEventListener('popstate', handlePopState)
53
- return () => {
54
- window.removeEventListener('popstate', handlePopState)
55
- }
56
- }, [getQueryString])
57
-
58
- return queryString
59
- }
60
-
61
- function useResize() {
62
- const getResize = useCallback(
63
- () => ({
64
- width: window.innerWidth,
65
- height: window.innerHeight
66
- }),
67
- []
68
- )
69
-
70
- const [resize, setResize] = useState(getResize)
71
-
72
- useEffect(() => {
73
- const handleResize = () => setResize(getResize())
74
-
75
- window.addEventListener('resize', handleResize)
76
- return () => {
77
- window.removeEventListener('resize', handleResize)
78
- }
79
- }, [getResize])
80
-
81
- return resize
82
- }
83
-
84
- /**
85
- * util
32
+ * css
86
33
  */
87
34
 
88
35
  function css(...classNames) {
@@ -104,4 +51,4 @@ function css(...classNames) {
104
51
  .join(' ')
105
52
  }
106
53
 
107
- export { css, env, startViewTransition, useQueryString, useResize }
54
+ export { css, env, startViewTransition }