@pyreon/zero 0.21.0 → 0.23.0
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 +211 -57
- package/lib/_chunks/app-BbPT0Y5M.js +36 -0
- package/lib/{fs-router-Bacdhsq-.js → _chunks/fs-router-DvBlRzmP.js} +21 -5
- package/lib/_chunks/use-intersection-observer-C6opeplh.js +29 -0
- package/lib/actions.js +24 -3
- package/lib/ai.js +1 -102
- package/lib/client.js +3 -33
- package/lib/csp.js +12 -9
- package/lib/favicon.js +1 -1
- package/lib/font.js +1 -1
- package/lib/image-plugin.js +1 -1
- package/lib/image.js +3 -27
- package/lib/index.js +8 -1085
- package/lib/link.js +3 -27
- package/lib/meta.js +1 -25
- package/lib/script.js +2 -26
- package/lib/seo.js +4 -4
- package/lib/server.js +275 -2129
- package/lib/testing.js +1 -69
- package/lib/theme.js +52 -22
- package/lib/types/config.d.ts +115 -0
- package/lib/types/csp.d.ts +9 -1
- package/lib/types/index.d.ts +120 -1
- package/lib/types/server.d.ts +192 -17
- package/lib/types/theme.d.ts +11 -2
- package/package.json +10 -10
- package/src/actions.ts +43 -5
- package/src/adapters/bun.ts +35 -7
- package/src/adapters/cloudflare.ts +17 -12
- package/src/adapters/netlify.ts +7 -1
- package/src/adapters/node.ts +33 -6
- package/src/adapters/vercel.ts +25 -4
- package/src/csp.ts +10 -7
- package/src/fs-router.ts +2 -1
- package/src/isr.ts +256 -51
- package/src/manifest.ts +23 -10
- package/src/server.ts +2 -1
- package/src/ssg-plugin.ts +27 -7
- package/src/theme.tsx +94 -38
- package/src/types.ts +76 -0
- package/lib/api-routes-CMsLztoj.js +0 -148
- package/lib/fs-router-3xzp-4Wj.js +0 -32
- package/lib/rolldown-runtime-CjeV3_4I.js +0 -18
package/lib/link.js
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as useIntersectionObserver } from "./_chunks/use-intersection-observer-C6opeplh.js";
|
|
2
|
+
import { createRef } from "@pyreon/core";
|
|
3
3
|
import { jsx } from "@pyreon/core/jsx-runtime";
|
|
4
|
+
import { useRouter } from "@pyreon/router";
|
|
4
5
|
|
|
5
|
-
//#region src/utils/use-intersection-observer.ts
|
|
6
|
-
/**
|
|
7
|
-
* Observes an element and calls `onIntersect` once it enters the viewport.
|
|
8
|
-
* Automatically disconnects after the first intersection.
|
|
9
|
-
*
|
|
10
|
-
* @param getElement - Getter for the target element (may be undefined before mount).
|
|
11
|
-
* @param onIntersect - Callback fired when the element becomes visible.
|
|
12
|
-
* @param rootMargin - IntersectionObserver rootMargin. Default: "200px".
|
|
13
|
-
*/
|
|
14
|
-
function useIntersectionObserver(getElement, onIntersect, rootMargin = "200px") {
|
|
15
|
-
onMount(() => {
|
|
16
|
-
const el = getElement();
|
|
17
|
-
if (!el) return void 0;
|
|
18
|
-
const observer = new IntersectionObserver((entries) => {
|
|
19
|
-
for (const entry of entries) if (entry.isIntersecting) {
|
|
20
|
-
onIntersect();
|
|
21
|
-
observer.disconnect();
|
|
22
|
-
}
|
|
23
|
-
}, { rootMargin });
|
|
24
|
-
observer.observe(el);
|
|
25
|
-
onUnmount(() => observer.disconnect());
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
6
|
//#region src/link.tsx
|
|
31
7
|
const MAX_PREFETCH_CACHE = 200;
|
|
32
8
|
const prefetched = /* @__PURE__ */ new Map();
|
package/lib/meta.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
+
import { extractLocaleFromPath } from "./i18n-routing.js";
|
|
1
2
|
import { useHead } from "@pyreon/head";
|
|
2
|
-
import { createContext } from "@pyreon/core";
|
|
3
|
-
import { signal } from "@pyreon/reactivity";
|
|
4
3
|
|
|
5
|
-
//#region src/i18n-routing.ts
|
|
6
|
-
/**
|
|
7
|
-
* Extract locale from a URL path.
|
|
8
|
-
* Returns { locale, pathWithoutLocale }.
|
|
9
|
-
*/
|
|
10
|
-
function extractLocaleFromPath(path, locales, defaultLocale) {
|
|
11
|
-
const segments = path.split("/").filter(Boolean);
|
|
12
|
-
const firstSegment = segments[0]?.toLowerCase();
|
|
13
|
-
if (firstSegment && locales.includes(firstSegment)) return {
|
|
14
|
-
locale: firstSegment,
|
|
15
|
-
pathWithoutLocale: "/" + segments.slice(1).join("/") || "/"
|
|
16
|
-
};
|
|
17
|
-
return {
|
|
18
|
-
locale: defaultLocale,
|
|
19
|
-
pathWithoutLocale: path
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/** @internal Context for the current locale. */
|
|
23
|
-
const LocaleCtx = createContext("en");
|
|
24
|
-
/** Current locale signal — set by the server middleware or client-side detection. */
|
|
25
|
-
const localeSignal = signal("en");
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
4
|
//#region src/meta.tsx
|
|
29
5
|
function faviconLinks(locale, config) {
|
|
30
6
|
const hasLocaleOverride = locale && config.locales?.[locale];
|
package/lib/script.js
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
1
|
+
import { t as useIntersectionObserver } from "./_chunks/use-intersection-observer-C6opeplh.js";
|
|
1
2
|
import { createRef, onMount, onUnmount } from "@pyreon/core";
|
|
2
|
-
import { signal } from "@pyreon/reactivity";
|
|
3
3
|
import { jsx } from "@pyreon/core/jsx-runtime";
|
|
4
|
+
import { signal } from "@pyreon/reactivity";
|
|
4
5
|
|
|
5
|
-
//#region src/utils/use-intersection-observer.ts
|
|
6
|
-
/**
|
|
7
|
-
* Observes an element and calls `onIntersect` once it enters the viewport.
|
|
8
|
-
* Automatically disconnects after the first intersection.
|
|
9
|
-
*
|
|
10
|
-
* @param getElement - Getter for the target element (may be undefined before mount).
|
|
11
|
-
* @param onIntersect - Callback fired when the element becomes visible.
|
|
12
|
-
* @param rootMargin - IntersectionObserver rootMargin. Default: "200px".
|
|
13
|
-
*/
|
|
14
|
-
function useIntersectionObserver(getElement, onIntersect, rootMargin = "200px") {
|
|
15
|
-
onMount(() => {
|
|
16
|
-
const el = getElement();
|
|
17
|
-
if (!el) return void 0;
|
|
18
|
-
const observer = new IntersectionObserver((entries) => {
|
|
19
|
-
for (const entry of entries) if (entry.isIntersecting) {
|
|
20
|
-
onIntersect();
|
|
21
|
-
observer.disconnect();
|
|
22
|
-
}
|
|
23
|
-
}, { rootMargin });
|
|
24
|
-
observer.observe(el);
|
|
25
|
-
onUnmount(() => observer.disconnect());
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
6
|
//#region src/script.tsx
|
|
31
7
|
/**
|
|
32
8
|
* Composable that provides all script loading behavior — strategy state
|
package/lib/seo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
3
2
|
import { join, resolve } from "node:path";
|
|
3
|
+
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
|
|
5
5
|
//#region src/seo.ts
|
|
6
6
|
/**
|
|
@@ -238,7 +238,7 @@ function seoPlugin(config = {}) {
|
|
|
238
238
|
},
|
|
239
239
|
async generateBundle(_, _bundle) {
|
|
240
240
|
if (config.sitemap && !useSsgPaths) {
|
|
241
|
-
const { scanRouteFiles } = await import("./fs-router-
|
|
241
|
+
const { scanRouteFiles } = await import("./_chunks/fs-router-DvBlRzmP.js").then((n) => n.n);
|
|
242
242
|
const routesDir = `${process.cwd()}/src/routes`;
|
|
243
243
|
try {
|
|
244
244
|
const files = await scanRouteFiles(routesDir);
|
|
@@ -262,7 +262,7 @@ function seoPlugin(config = {}) {
|
|
|
262
262
|
},
|
|
263
263
|
async closeBundle() {
|
|
264
264
|
if (!config.sitemap || !useSsgPaths) return;
|
|
265
|
-
const { scanRouteFiles } = await import("./fs-router-
|
|
265
|
+
const { scanRouteFiles } = await import("./_chunks/fs-router-DvBlRzmP.js").then((n) => n.n);
|
|
266
266
|
const routesDir = `${process.cwd()}/src/routes`;
|
|
267
267
|
const manifestPath = join(distDir, "_pyreon-ssg-paths.json");
|
|
268
268
|
try {
|
|
@@ -300,7 +300,7 @@ function seoMiddleware(config = {}) {
|
|
|
300
300
|
return async (ctx) => {
|
|
301
301
|
if (ctx.url.pathname === "/robots.txt" && config.robots) return new Response(generateRobots(config.robots), { headers: { "Content-Type": "text/plain" } });
|
|
302
302
|
if (ctx.url.pathname === "/sitemap.xml" && config.sitemap) try {
|
|
303
|
-
const { scanRouteFiles } = await import("./fs-router-
|
|
303
|
+
const { scanRouteFiles } = await import("./_chunks/fs-router-DvBlRzmP.js").then((n) => n.n);
|
|
304
304
|
const sitemap = generateSitemap(await scanRouteFiles(`${process.cwd()}/src/routes`), config.sitemap);
|
|
305
305
|
return new Response(sitemap, { headers: { "Content-Type": "application/xml" } });
|
|
306
306
|
} catch {}
|