@zubyjs/react 1.0.78 → 1.0.80
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/components/Text.d.ts +1 -1
- package/components/lazyWithPreload.d.ts +1 -1
- package/components/lazyWithPreload.js +1 -1
- package/hooks/useTranslations.js +2 -2
- package/image.d.ts +2 -2
- package/image.js +2 -2
- package/index.d.ts +1 -1
- package/package.json +45 -45
- package/render.d.ts +1 -1
- package/router.d.ts +2 -2
- package/router.js +9 -3
- package/templates/app.d.ts +1 -1
- package/templates/error.d.ts +1 -1
- package/templates/innerLayout.d.ts +2 -2
- package/templates/innerLayout.js +1 -1
- package/templates/layout.d.ts +2 -2
package/components/Text.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export function lazyWithPreload(factory) {
|
|
|
15
15
|
const LazyWithPreload = Component;
|
|
16
16
|
LazyWithPreload.preload = () => {
|
|
17
17
|
if (!factoryPromise) {
|
|
18
|
-
factoryPromise = factory().then(module => {
|
|
18
|
+
factoryPromise = factory().then((module) => {
|
|
19
19
|
PreloadedComponent = module.default;
|
|
20
20
|
return PreloadedComponent;
|
|
21
21
|
});
|
package/hooks/useTranslations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { usePageContext } from './usePageContext.js';
|
|
2
|
-
|
|
2
|
+
const translationsCache = new Map();
|
|
3
3
|
/**
|
|
4
4
|
* Returns the translations object for the given namespace and locale
|
|
5
5
|
* @param namespace
|
|
@@ -12,7 +12,7 @@ export function useTranslations(namespace, locale) {
|
|
|
12
12
|
const translations = translationsCache.get(namespaceWithLocale) || getTranslations(namespace, locale);
|
|
13
13
|
if (translations instanceof Promise) {
|
|
14
14
|
translationsCache.set(namespaceWithLocale, translations);
|
|
15
|
-
translations.then(result => translationsCache.set(namespaceWithLocale, result));
|
|
15
|
+
translations.then((result) => translationsCache.set(namespaceWithLocale, result));
|
|
16
16
|
throw translations;
|
|
17
17
|
}
|
|
18
18
|
return translations;
|
package/image.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImageFormat } from 'zuby/types.js';
|
|
1
|
+
import type { ImageFormat } from 'zuby/types.js';
|
|
2
2
|
export interface ImageProps {
|
|
3
3
|
src: string;
|
|
4
4
|
alt?: string;
|
|
@@ -8,4 +8,4 @@ export interface ImageProps {
|
|
|
8
8
|
quality?: number;
|
|
9
9
|
lazy?: boolean;
|
|
10
10
|
}
|
|
11
|
-
export default function Image({ src: originalSrc, alt, width, height, format, quality, lazy
|
|
11
|
+
export default function Image({ src: originalSrc, alt, width, height, format, quality, lazy }: ImageProps): import("react/jsx-runtime").JSX.Element;
|
package/image.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useGlobalContext } from 'zuby/hooks/index.js';
|
|
3
3
|
import getNearestSize from 'zuby/image/getNearestSize.js';
|
|
4
|
-
export default function Image({ src: originalSrc, alt, width, height, format, quality, lazy = true
|
|
4
|
+
export default function Image({ src: originalSrc, alt, width, height, format, quality, lazy = true }) {
|
|
5
5
|
const context = useGlobalContext();
|
|
6
6
|
format = format || context?.image?.defaultFormat;
|
|
7
7
|
quality = quality || context?.image?.defaultQuality;
|
|
@@ -17,5 +17,5 @@ export default function Image({ src: originalSrc, alt, width, height, format, qu
|
|
|
17
17
|
isAbsolute,
|
|
18
18
|
context,
|
|
19
19
|
});
|
|
20
|
-
return
|
|
20
|
+
return _jsx("img", { src: src, alt: alt, width: width, height: height, loading: lazy ? 'lazy' : 'eager' });
|
|
21
21
|
}
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
2
|
+
"name": "@zubyjs/react",
|
|
3
|
+
"version": "1.0.80",
|
|
4
|
+
"description": "Zuby.js JsxProvider for react",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"release": "cd ./dist && npm publish --access public && cd ..",
|
|
9
|
+
"bump-version": "npm version patch",
|
|
10
|
+
"build": "rm -rf dist/ stage/ && mkdir dist && tsc && cp -rf package.json README.md stage/react/src/* dist/ && rm -rf stage/",
|
|
11
|
+
"push-build": "npm run build && cd dist && yalc push --force && cd ..",
|
|
12
|
+
"test": "exit 0"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"directory": "dist",
|
|
16
|
+
"linkDirectory": true
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@vitejs/plugin-react": "4.2.1",
|
|
20
|
+
"wouter": "2.12.1",
|
|
21
|
+
"react": "18.3.1",
|
|
22
|
+
"react-dom": "18.3.1",
|
|
23
|
+
"@types/react": "18.3.1",
|
|
24
|
+
"@types/react-dom": "18.3.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"zuby": "^1.0.0"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://gitlab.com/futrou/zuby.js/-/issues",
|
|
31
|
+
"email": "zuby@futrou.com"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://gitlab.com/futrou/zuby.js.git"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://zubyjs.com",
|
|
39
|
+
"keywords": [
|
|
40
|
+
"zuby-jsx-provider",
|
|
41
|
+
"zuby",
|
|
42
|
+
"react"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
}
|
|
47
47
|
}
|
package/render.d.ts
CHANGED
package/router.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { useRoute, useRouter, useParams, useLocation, Redirect, RedirectProps } from 'wouter';
|
|
2
|
-
import { LazyTemplate } from 'zuby/templates/types.js';
|
|
3
|
-
import { PageContext } from 'zuby/contexts/index.js';
|
|
2
|
+
import type { LazyTemplate } from 'zuby/templates/types.js';
|
|
3
|
+
import type { PageContext } from 'zuby/contexts/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Zuby's Router component provides support for file-system based routing.
|
|
6
6
|
*/
|
package/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Router as WouterRouter, Route as WouterRoute, Switch as WouterSwitch, Link as WouterLink, useRoute
|
|
2
|
+
import { Router as WouterRouter, Route as WouterRoute, Switch as WouterSwitch, Link as WouterLink, useRoute } from 'wouter';
|
|
3
3
|
export { useRoute, useRouter, useParams, useLocation, Redirect } from 'wouter';
|
|
4
4
|
import { useParams } from 'wouter';
|
|
5
5
|
import { createElement, Suspense } from 'react';
|
|
@@ -95,11 +95,17 @@ export function Link(props) {
|
|
|
95
95
|
try {
|
|
96
96
|
matchTemplate(pages || [], href)?.component?.preload();
|
|
97
97
|
}
|
|
98
|
-
catch (
|
|
98
|
+
catch (_error) {
|
|
99
|
+
// Silently ignore preload errors - preloading is a performance optimization
|
|
100
|
+
// and should not break functionality if it fails
|
|
101
|
+
}
|
|
99
102
|
try {
|
|
100
103
|
useProps(href, 'low');
|
|
101
104
|
}
|
|
102
|
-
catch (
|
|
105
|
+
catch (_error) {
|
|
106
|
+
// Silently ignore props preload errors - this is a performance optimization
|
|
107
|
+
// and the props will be loaded on-demand if preload fails
|
|
108
|
+
}
|
|
103
109
|
});
|
|
104
110
|
}
|
|
105
111
|
return (_jsx(WouterLink, { ...props, className: className, children: props.children }));
|
package/templates/app.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
2
|
export default function App({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
package/templates/error.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PageContext } from 'zuby/contexts/index.js';
|
|
2
|
-
export default function InnerLayout({ innerHtml, context
|
|
1
|
+
import type { PageContext } from 'zuby/contexts/index.js';
|
|
2
|
+
export default function InnerLayout({ innerHtml, context }: {
|
|
3
3
|
innerHtml: string;
|
|
4
4
|
context: PageContext;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
package/templates/innerLayout.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
export default function InnerLayout({ innerHtml, context
|
|
2
|
+
export default function InnerLayout({ innerHtml, context }) {
|
|
3
3
|
return (_jsxs(_Fragment, { children: [_jsx("div", { id: "app", dangerouslySetInnerHTML: { __html: innerHtml } }), _jsx("script", { type: "text/javascript", dangerouslySetInnerHTML: {
|
|
4
4
|
__html: `globalThis.initialPageContext=${JSON.stringify({
|
|
5
5
|
props: context.props,
|
package/templates/layout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { PageContext } from 'zuby/contexts/index.js';
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import type { PageContext } from 'zuby/contexts/index.js';
|
|
3
3
|
export default function Layout({ children, context, }: PropsWithChildren<{
|
|
4
4
|
context: PageContext;
|
|
5
5
|
}>): import("react/jsx-runtime").JSX.Element;
|