nextia 8.0.1 → 8.0.3

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/README.md CHANGED
@@ -5,7 +5,6 @@ Create fast web applications
5
5
  ### To start
6
6
 
7
7
  ```sh
8
- gcl git@github.com:sinuhedev/nextia.git
9
8
  npm install
10
9
  cd templates/web
11
10
  npm install
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nextia",
3
3
  "description": "Create fast web applications",
4
- "version": "8.0.1",
4
+ "version": "8.0.3",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "engines": {
@@ -42,8 +42,8 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@vitejs/plugin-react": "6.0.1",
45
- "@vitest/coverage-v8": "4.1.5",
46
- "jsdom": "29.1.0",
47
- "vitest": "4.1.5"
45
+ "@vitest/coverage-v8": "4.1.6",
46
+ "jsdom": "29.1.1",
47
+ "vitest": "4.1.6"
48
48
  }
49
49
  }
package/src/lib/fx.js CHANGED
@@ -8,10 +8,8 @@
8
8
  */
9
9
 
10
10
  import { createContext, use, useEffect, useReducer, useState } from 'react'
11
- import { env } from './utils.js'
12
11
 
13
- const LOGGER = env.DEV && env.PUBLIC_LOGGER !== 'false'
14
- const Pages = createContext()
12
+ const Pagex = createContext()
15
13
 
16
14
  /**
17
15
  * util
@@ -159,10 +157,12 @@ const reducerLogger = (state, action) => {
159
157
  */
160
158
 
161
159
  function useCx() {
162
- const pages = use(Pages)
160
+ const pages = use(Pagex)
163
161
  const [icons, setIcons] = useState()
164
162
 
165
163
  useEffect(() => {
164
+ if (!pages?.icons) return
165
+
166
166
  fetch(pages?.icons)
167
167
  .then((r) => r.text())
168
168
  .then((text) => {
@@ -175,7 +175,8 @@ function useCx() {
175
175
  return {
176
176
  context: pages?.context,
177
177
  i18n: pages?.i18n,
178
- icons
178
+ icons,
179
+ logger: pages?.logger ?? false
179
180
  }
180
181
  }
181
182
 
@@ -183,7 +184,7 @@ function useFx(functions = { initialState: {} }) {
183
184
  const cx = useCx()
184
185
  const { initialState } = functions
185
186
  const [state, dispatch] = useReducer(
186
- LOGGER ? reducerLogger : reducer,
187
+ cx.logger ? reducerLogger : reducer,
187
188
  initialState
188
189
  )
189
190
 
@@ -234,4 +235,4 @@ function useFx(functions = { initialState: {} }) {
234
235
  return Object.freeze(props)
235
236
  }
236
237
 
237
- export { Pages, useCx, useFx }
238
+ export { Pagex, useCx, useFx }
package/src/lib/index.js CHANGED
@@ -7,18 +7,17 @@
7
7
  * https://github.com/sinuhedev/nextia
8
8
  */
9
9
 
10
- import { Pages, useCx, useFx } from './fx.js'
10
+ import { Pagex, useCx, useFx } from './fx.js'
11
11
  import { useQueryString, useResize } from './hooks.js'
12
12
  import { I18n, Icon, Link, Svg } from './ui.js'
13
- import { css, env, startViewTransition } from './utils.js'
13
+ import { css, startViewTransition } from './utils.js'
14
14
 
15
15
  export {
16
16
  css,
17
- env,
18
17
  I18n,
19
18
  Icon,
20
19
  Link,
21
- Pages,
20
+ Pagex,
22
21
  Svg,
23
22
  startViewTransition,
24
23
  useCx,
package/src/lib/ui.js CHANGED
@@ -22,25 +22,24 @@ function Link({ children, href, value = {}, ...props }) {
22
22
  function I18n({ value, args = [] }) {
23
23
  const { context, i18n } = useCx()
24
24
 
25
- if (i18n) {
26
- try {
27
- let text = value.split('.').reduce((ac, el) => ac[el], i18n)
28
-
29
- text =
30
- text[i18n.locales.indexOf(context.state?.i18n || i18n.defaultLocale)]
31
-
32
- if (args) {
33
- text = text.replace(
34
- /([{}])\\1|[{](.*?)(?:!(.+?))?[}]/g,
35
- (match, _literal, number) => args[number] || match
36
- )
37
- }
38
-
39
- return text
40
- } catch {
41
- console.error(`Error in [il8n] => ${value}`)
42
- return value
25
+ if (!i18n) return null
26
+
27
+ try {
28
+ let text = value.split('.').reduce((ac, el) => ac[el], i18n)
29
+
30
+ text = text[i18n.locales.indexOf(context.state?.i18n || i18n.defaultLocale)]
31
+
32
+ if (args) {
33
+ text = text.replace(
34
+ /([{}])\\1|[{](.*?)(?:!(.+?))?[}]/g,
35
+ (match, _literal, number) => args[number] || match
36
+ )
43
37
  }
38
+
39
+ return text
40
+ } catch {
41
+ console.error(`Error in [il8n] => ${value}`)
42
+ return value
44
43
  }
45
44
  }
46
45
 
@@ -64,9 +63,8 @@ function Icon({
64
63
  const ref = useRef()
65
64
 
66
65
  useEffect(() => {
67
- if (icons) {
68
- ref.current.innerHTML = icons.getElementById(id).innerHTML
69
- }
66
+ const el = icons?.getElementById(id)
67
+ if (ref.current && el) ref.current.innerHTML = el.innerHTML
70
68
  }, [id, icons])
71
69
 
72
70
  return createElement('svg', {
package/src/lib/utils.js CHANGED
@@ -9,32 +9,12 @@
9
9
 
10
10
  import { flushSync } from 'react-dom'
11
11
 
12
- /**
13
- * env
14
- */
15
-
16
- const env = import.meta.env
17
-
18
- const VERSION = Object.fromEntries(
19
- document
20
- .querySelector('meta[name="version"]')
21
- ?.getAttribute('content')
22
- .split(', ')
23
- .map((item) => {
24
- const [key, value] = item.split('=')
25
- return [key, value]
26
- }) ?? ''
27
- )
28
-
29
- env.VERSION = VERSION
30
-
31
12
  /**
32
13
  * View Transition
33
14
  */
34
15
 
35
16
  async function startViewTransition(fun = () => {}, ref, animation = 'fade') {
36
- if (!document.startViewTransition || env.PUBLIC_VIEW_TRANSITION === 'false')
37
- return fun()
17
+ if (!document.startViewTransition) return fun()
38
18
 
39
19
  ref.style.viewTransitionName = animation
40
20
  await document.startViewTransition(() => flushSync(fun)).finished
@@ -64,4 +44,4 @@ function css(...classNames) {
64
44
  .join(' ')
65
45
  }
66
46
 
67
- export { css, env, startViewTransition }
47
+ export { css, startViewTransition }