@zubyjs/preact 1.0.79 → 1.0.81
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 +43 -43
- package/render.d.ts +1 -1
- package/render.js +1 -0
- package/router.d.ts +2 -2
- package/router.js +9 -3
- package/templates/app.d.ts +1 -1
- package/templates/error.d.ts +2 -2
- package/templates/error.js +1 -1
- package/templates/innerLayout.d.ts +2 -2
- package/templates/innerLayout.js +1 -1
- package/templates/layout.d.ts +3 -3
- package/templates/layout.js +1 -1
package/components/Text.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function lazyWithPreload(factory) {
|
|
|
17
17
|
const LazyWithPreload = Component;
|
|
18
18
|
LazyWithPreload.preload = () => {
|
|
19
19
|
if (!factoryPromise) {
|
|
20
|
-
factoryPromise = factory().then(module => {
|
|
20
|
+
factoryPromise = factory().then((module) => {
|
|
21
21
|
PreloadedComponent = module.default;
|
|
22
22
|
return PreloadedComponent;
|
|
23
23
|
});
|
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("preact").JSX.Element;
|
package/image.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "preact/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,45 +1,45 @@
|
|
|
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
|
-
|
|
2
|
+
"name": "@zubyjs/preact",
|
|
3
|
+
"version": "1.0.81",
|
|
4
|
+
"description": "Zuby.js JsxProvider for Preact",
|
|
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/preact/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
|
+
"@preact/preset-vite": "2.8.2",
|
|
20
|
+
"wouter-preact": "2.12.2",
|
|
21
|
+
"preact-render-to-string": "6.4.2",
|
|
22
|
+
"preact": "10.21.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"zuby": "^1.0.0"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://gitlab.com/futrou/zuby.js/-/issues",
|
|
29
|
+
"email": "zuby@futrou.com"
|
|
30
|
+
},
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://gitlab.com/futrou/zuby.js.git"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://zubyjs.com",
|
|
37
|
+
"keywords": [
|
|
38
|
+
"zuby-jsx-provider",
|
|
39
|
+
"zuby",
|
|
40
|
+
"preact"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
}
|
|
45
45
|
}
|
package/render.d.ts
CHANGED
package/render.js
CHANGED
|
@@ -28,6 +28,7 @@ export const renderToString = async (vnode, options) => {
|
|
|
28
28
|
}
|
|
29
29
|
const renderNode = async () => {
|
|
30
30
|
if (++tries > maxDepth) {
|
|
31
|
+
// Using console.warn as render functions don't have logger context
|
|
31
32
|
console.warn(`WARNING: Maximum depth of ${maxDepth} of lazy components exceeded while prerendering page.`);
|
|
32
33
|
console.warn(`This may indicate a circular dependency in your code.`);
|
|
33
34
|
return '';
|
package/router.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { useRoute, useRouter, useParams, useLocation, Redirect, RedirectProps, } from 'wouter-preact';
|
|
2
|
-
import { LazyTemplate } from 'zuby/templates/types.js';
|
|
2
|
+
import type { LazyTemplate } from 'zuby/templates/types.js';
|
|
3
3
|
import { createElement } from 'preact';
|
|
4
|
-
import { PageContext } from 'zuby/contexts/index.js';
|
|
4
|
+
import type { PageContext } from 'zuby/contexts/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Zuby's Router component provides support for file-system based routing.
|
|
7
7
|
*/
|
package/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "preact/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-preact';
|
|
3
3
|
export { useRoute, useRouter, useParams, useLocation, Redirect, } from 'wouter-preact';
|
|
4
4
|
import { useParams } from 'wouter-preact';
|
|
5
5
|
import { Suspense } from 'preact/compat';
|
|
@@ -96,11 +96,17 @@ export function Link(props) {
|
|
|
96
96
|
try {
|
|
97
97
|
matchTemplate(pages || [], href)?.component?.preload();
|
|
98
98
|
}
|
|
99
|
-
catch (
|
|
99
|
+
catch (_error) {
|
|
100
|
+
// Silently ignore preload errors - preloading is a performance optimization
|
|
101
|
+
// and should not break functionality if it fails
|
|
102
|
+
}
|
|
100
103
|
try {
|
|
101
104
|
useProps(href, 'low');
|
|
102
105
|
}
|
|
103
|
-
catch (
|
|
106
|
+
catch (_error) {
|
|
107
|
+
// Silently ignore props preload errors - this is a performance optimization
|
|
108
|
+
// and the props will be loaded on-demand if preload fails
|
|
109
|
+
}
|
|
104
110
|
});
|
|
105
111
|
}
|
|
106
112
|
return (_jsx(WouterLink, { ...props, className: className, children: props.children }));
|
package/templates/app.d.ts
CHANGED
package/templates/error.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentChildren } from 'preact';
|
|
2
|
-
export default function Error({ statusCode, message
|
|
1
|
+
import type { ComponentChildren } from 'preact';
|
|
2
|
+
export default function Error({ statusCode, message }: {
|
|
3
3
|
children: ComponentChildren;
|
|
4
4
|
statusCode: number;
|
|
5
5
|
message: string;
|
package/templates/error.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
export default function Error({ statusCode, message
|
|
2
|
+
export default function Error({ statusCode, message }) {
|
|
3
3
|
return (_jsxs("div", { children: [_jsx("h1", { children: statusCode }), _jsx("p", { children: message })] }));
|
|
4
4
|
}
|
|
@@ -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("preact").JSX.Element;
|
package/templates/innerLayout.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/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,6 +1,6 @@
|
|
|
1
|
-
import { ComponentChildren } from 'preact';
|
|
2
|
-
import { PageContext } from 'zuby/contexts/index.js';
|
|
3
|
-
export default function Layout({ children, context
|
|
1
|
+
import type { ComponentChildren } from 'preact';
|
|
2
|
+
import type { PageContext } from 'zuby/contexts/index.js';
|
|
3
|
+
export default function Layout({ children, context }: {
|
|
4
4
|
children: ComponentChildren;
|
|
5
5
|
context: PageContext;
|
|
6
6
|
}): import("preact").JSX.Element;
|
package/templates/layout.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
export default function Layout({ children, context
|
|
2
|
+
export default function Layout({ children, context }) {
|
|
3
3
|
return (_jsxs("html", { children: [_jsxs("head", { children: [_jsx("meta", { charset: "UTF-8" }), _jsx("title", { children: context.title })] }), _jsx("body", { children: children })] }));
|
|
4
4
|
}
|