@pyreon/zero 0.13.1 → 0.15.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/lib/api-routes-DANluJic.js +146 -0
- package/lib/client.js +3 -1
- package/lib/csp.js +19 -9
- package/lib/{fs-router-CQ7Zxeca.js → fs-router-ZebyutPa.js} +43 -6
- package/lib/image-plugin.js +4 -0
- package/lib/image.js +1 -50
- package/lib/index.js +1 -50
- package/lib/link.js +1 -49
- package/lib/script.js +1 -49
- package/lib/server.js +6 -688
- package/lib/theme.js +1 -50
- package/lib/types/i18n-routing.d.ts +4 -4
- package/lib/types/index.d.ts +23 -13
- package/lib/types/link.d.ts +3 -3
- package/lib/types/server.d.ts +28 -5
- package/lib/types/theme.d.ts +2 -2
- package/lib/vite-plugin-E4BHYvYW.js +855 -0
- package/package.json +15 -13
- package/src/app.ts +21 -1
- package/src/csp.ts +28 -12
- package/src/fs-router.ts +53 -3
- package/src/ssg-plugin.ts +366 -0
- package/src/types.ts +28 -9
- package/src/vite-plugin.ts +220 -40
- package/lib/actions.js.map +0 -1
- package/lib/ai.js.map +0 -1
- package/lib/api-routes.js.map +0 -1
- package/lib/cache.js.map +0 -1
- package/lib/client.js.map +0 -1
- package/lib/compression.js.map +0 -1
- package/lib/config.js.map +0 -1
- package/lib/cors.js.map +0 -1
- package/lib/csp.js.map +0 -1
- package/lib/env.js.map +0 -1
- package/lib/favicon.js.map +0 -1
- package/lib/font.js.map +0 -1
- package/lib/fs-router-3xzp-4Wj.js.map +0 -1
- package/lib/fs-router-CQ7Zxeca.js.map +0 -1
- package/lib/i18n-routing.js.map +0 -1
- package/lib/image-plugin.js.map +0 -1
- package/lib/image.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/link.js.map +0 -1
- package/lib/logger.js.map +0 -1
- package/lib/meta.js.map +0 -1
- package/lib/middleware.js.map +0 -1
- package/lib/og-image.js.map +0 -1
- package/lib/rate-limit.js.map +0 -1
- package/lib/script.js.map +0 -1
- package/lib/seo.js.map +0 -1
- package/lib/server.js.map +0 -1
- package/lib/testing.js.map +0 -1
- package/lib/theme.js.map +0 -1
- package/lib/types/actions.d.ts.map +0 -1
- package/lib/types/ai.d.ts.map +0 -1
- package/lib/types/api-routes.d.ts.map +0 -1
- package/lib/types/cache.d.ts.map +0 -1
- package/lib/types/client.d.ts.map +0 -1
- package/lib/types/compression.d.ts.map +0 -1
- package/lib/types/config.d.ts.map +0 -1
- package/lib/types/cors.d.ts.map +0 -1
- package/lib/types/csp.d.ts.map +0 -1
- package/lib/types/env.d.ts.map +0 -1
- package/lib/types/favicon.d.ts.map +0 -1
- package/lib/types/font.d.ts.map +0 -1
- package/lib/types/i18n-routing.d.ts.map +0 -1
- package/lib/types/image-plugin.d.ts.map +0 -1
- package/lib/types/image.d.ts.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/link.d.ts.map +0 -1
- package/lib/types/logger.d.ts.map +0 -1
- package/lib/types/meta.d.ts.map +0 -1
- package/lib/types/middleware.d.ts.map +0 -1
- package/lib/types/og-image.d.ts.map +0 -1
- package/lib/types/rate-limit.d.ts.map +0 -1
- package/lib/types/script.d.ts.map +0 -1
- package/lib/types/seo.d.ts.map +0 -1
- package/lib/types/server.d.ts.map +0 -1
- package/lib/types/testing.d.ts.map +0 -1
- package/lib/types/theme.d.ts.map +0 -1
package/lib/theme.js
CHANGED
|
@@ -1,56 +1,7 @@
|
|
|
1
1
|
import { onMount } from "@pyreon/core";
|
|
2
2
|
import { effect, signal } from "@pyreon/reactivity";
|
|
3
|
+
import { jsx, jsxs } from "@pyreon/core/jsx-runtime";
|
|
3
4
|
|
|
4
|
-
//#region ../../core/core/lib/jsx-runtime.js
|
|
5
|
-
/**
|
|
6
|
-
* Hyperscript function — the compiled output of JSX.
|
|
7
|
-
* `<div class="x">hello</div>` → `h("div", { class: "x" }, "hello")`
|
|
8
|
-
*
|
|
9
|
-
* Generic on P so TypeScript validates props match the component's signature
|
|
10
|
-
* at the call site, then stores the result in the loosely-typed VNode.
|
|
11
|
-
*/
|
|
12
|
-
/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */
|
|
13
|
-
const EMPTY_PROPS = {};
|
|
14
|
-
function h(type, props, ...children) {
|
|
15
|
-
return {
|
|
16
|
-
type,
|
|
17
|
-
props: props ?? EMPTY_PROPS,
|
|
18
|
-
children: normalizeChildren(children),
|
|
19
|
-
key: props?.key ?? null
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function normalizeChildren(children) {
|
|
23
|
-
for (let i = 0; i < children.length; i++) if (Array.isArray(children[i])) return flattenChildren(children);
|
|
24
|
-
return children;
|
|
25
|
-
}
|
|
26
|
-
function flattenChildren(children) {
|
|
27
|
-
const result = [];
|
|
28
|
-
for (const child of children) if (Array.isArray(child)) result.push(...flattenChildren(child));
|
|
29
|
-
else result.push(child);
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* JSX automatic runtime.
|
|
34
|
-
*
|
|
35
|
-
* When tsconfig has `"jsxImportSource": "@pyreon/core"`, the TS/bundler compiler
|
|
36
|
-
* rewrites JSX to imports from this file automatically:
|
|
37
|
-
* <div class="x" /> → jsx("div", { class: "x" })
|
|
38
|
-
*/
|
|
39
|
-
function jsx(type, props, key) {
|
|
40
|
-
const { children, ...rest } = props;
|
|
41
|
-
const propsWithKey = key != null ? {
|
|
42
|
-
...rest,
|
|
43
|
-
key
|
|
44
|
-
} : rest;
|
|
45
|
-
if (typeof type === "function") return h(type, children !== void 0 ? {
|
|
46
|
-
...propsWithKey,
|
|
47
|
-
children
|
|
48
|
-
} : propsWithKey);
|
|
49
|
-
return h(type, propsWithKey, ...children === void 0 ? [] : Array.isArray(children) ? children : [children]);
|
|
50
|
-
}
|
|
51
|
-
const jsxs = jsx;
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
5
|
//#region src/theme.tsx
|
|
55
6
|
const STORAGE_KEY = "zero-theme";
|
|
56
7
|
/** Reactive theme signal. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as _pyreon_core0 from "@pyreon/core";
|
|
2
|
-
import * as _pyreon_reactivity0 from "@pyreon/reactivity";
|
|
1
|
+
import * as _$_pyreon_core0 from "@pyreon/core";
|
|
2
|
+
import * as _$_pyreon_reactivity0 from "@pyreon/reactivity";
|
|
3
3
|
import { Plugin } from "vite";
|
|
4
4
|
|
|
5
5
|
//#region src/i18n-routing.d.ts
|
|
@@ -74,9 +74,9 @@ declare function createLocaleContext(locale: string, path: string, config: I18nR
|
|
|
74
74
|
*/
|
|
75
75
|
declare function i18nRouting(config: I18nRoutingConfig): Plugin;
|
|
76
76
|
/** @internal Context for the current locale. */
|
|
77
|
-
declare const LocaleCtx: _pyreon_core0.Context<string>;
|
|
77
|
+
declare const LocaleCtx: _$_pyreon_core0.Context<string>;
|
|
78
78
|
/** Current locale signal — set by the server middleware or client-side detection. */
|
|
79
|
-
declare const localeSignal: _pyreon_reactivity0.Signal<string>;
|
|
79
|
+
declare const localeSignal: _$_pyreon_reactivity0.Signal<string>;
|
|
80
80
|
/**
|
|
81
81
|
* Read the current locale reactively.
|
|
82
82
|
*
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as _pyreon_core0 from "@pyreon/core";
|
|
1
|
+
import * as _$_pyreon_core0 from "@pyreon/core";
|
|
2
2
|
import { ComponentFn, VNodeChild } from "@pyreon/core";
|
|
3
|
-
import * as _pyreon_reactivity0 from "@pyreon/reactivity";
|
|
4
|
-
import { NavigationGuard } from "@pyreon/router";
|
|
3
|
+
import * as _$_pyreon_reactivity0 from "@pyreon/reactivity";
|
|
4
|
+
import { LoaderContext, NavigationGuard } from "@pyreon/router";
|
|
5
5
|
import { Middleware } from "@pyreon/server";
|
|
6
6
|
|
|
7
7
|
//#region src/image-plugin.d.ts
|
|
@@ -95,7 +95,7 @@ interface LinkProps {
|
|
|
95
95
|
/** Props passed to a custom component via createLink. */
|
|
96
96
|
interface LinkRenderProps {
|
|
97
97
|
href: string;
|
|
98
|
-
ref: _pyreon_core0.Ref<HTMLAnchorElement>;
|
|
98
|
+
ref: _$_pyreon_core0.Ref<HTMLAnchorElement>;
|
|
99
99
|
onClick: (e: MouseEvent) => void;
|
|
100
100
|
onMouseEnter: () => void;
|
|
101
101
|
onTouchStart: () => void;
|
|
@@ -112,7 +112,7 @@ interface LinkRenderProps {
|
|
|
112
112
|
/** Return type of useLink. */
|
|
113
113
|
interface UseLinkReturn {
|
|
114
114
|
/** Ref object — attach to the root element for viewport-based prefetch. */
|
|
115
|
-
ref: _pyreon_core0.Ref<HTMLAnchorElement>;
|
|
115
|
+
ref: _$_pyreon_core0.Ref<HTMLAnchorElement>;
|
|
116
116
|
/** Click handler — performs client-side navigation. */
|
|
117
117
|
handleClick: (e: MouseEvent) => void;
|
|
118
118
|
/** Mouse enter handler — triggers hover prefetch. */
|
|
@@ -448,7 +448,7 @@ declare function buildMetaTags(props: Omit<MetaProps, 'title' | 'description' |
|
|
|
448
448
|
//#region src/theme.d.ts
|
|
449
449
|
type Theme = 'light' | 'dark' | 'system';
|
|
450
450
|
/** Reactive theme signal. */
|
|
451
|
-
declare const theme: _pyreon_reactivity0.Signal<Theme>;
|
|
451
|
+
declare const theme: _$_pyreon_reactivity0.Signal<Theme>;
|
|
452
452
|
/**
|
|
453
453
|
* Set the default theme for SSR (when `matchMedia` is unavailable).
|
|
454
454
|
* Call once at server startup before rendering.
|
|
@@ -516,13 +516,6 @@ interface RouteModule {
|
|
|
516
516
|
/** Rendering mode override for this route. */
|
|
517
517
|
renderMode?: RenderMode;
|
|
518
518
|
}
|
|
519
|
-
/** Context passed to route loaders. */
|
|
520
|
-
interface LoaderContext {
|
|
521
|
-
params: Record<string, string>;
|
|
522
|
-
query: Record<string, string>;
|
|
523
|
-
signal: AbortSignal;
|
|
524
|
-
request: Request;
|
|
525
|
-
}
|
|
526
519
|
/** Per-route metadata. */
|
|
527
520
|
interface RouteMeta {
|
|
528
521
|
title?: string;
|
|
@@ -585,6 +578,23 @@ interface RouteFileExports {
|
|
|
585
578
|
hasError: boolean;
|
|
586
579
|
/** Has `export const middleware` */
|
|
587
580
|
hasMiddleware: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Has `export const loaderKey` or `export function loaderKey`. When present,
|
|
583
|
+
* the route generator wires it as the `loaderKey` field on the route record,
|
|
584
|
+
* which controls cache identity for `_loaderCache`. Useful for auth-gate
|
|
585
|
+
* loaders that should invalidate when the session cookie changes — read
|
|
586
|
+
* `document.cookie` (CSR) or `ctx.request.headers.get('cookie')` (SSR) and
|
|
587
|
+
* derive a key from session identity. Default cache key is `path + params`,
|
|
588
|
+
* which doesn't see cookie changes.
|
|
589
|
+
*/
|
|
590
|
+
hasLoaderKey: boolean;
|
|
591
|
+
/**
|
|
592
|
+
* Has `export const gcTime` (number, in ms). When present, the route generator
|
|
593
|
+
* inlines it on the route record. `gcTime: 0` disables caching entirely —
|
|
594
|
+
* the loader runs on every navigation. Useful for auth-gate loaders that
|
|
595
|
+
* must validate session on every navigation rather than serve stale data.
|
|
596
|
+
*/
|
|
597
|
+
hasGcTime: boolean;
|
|
588
598
|
/**
|
|
589
599
|
* Raw text of the `export const meta = …` initializer, captured as a
|
|
590
600
|
* literal expression. When present, the route generator inlines this
|
package/lib/types/link.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as _pyreon_core0 from "@pyreon/core";
|
|
1
|
+
import * as _$_pyreon_core0 from "@pyreon/core";
|
|
2
2
|
|
|
3
3
|
//#region src/link.d.ts
|
|
4
4
|
interface LinkProps {
|
|
@@ -26,7 +26,7 @@ interface LinkProps {
|
|
|
26
26
|
/** Props passed to a custom component via createLink. */
|
|
27
27
|
interface LinkRenderProps {
|
|
28
28
|
href: string;
|
|
29
|
-
ref: _pyreon_core0.Ref<HTMLAnchorElement>;
|
|
29
|
+
ref: _$_pyreon_core0.Ref<HTMLAnchorElement>;
|
|
30
30
|
onClick: (e: MouseEvent) => void;
|
|
31
31
|
onMouseEnter: () => void;
|
|
32
32
|
onTouchStart: () => void;
|
|
@@ -43,7 +43,7 @@ interface LinkRenderProps {
|
|
|
43
43
|
/** Return type of useLink. */
|
|
44
44
|
interface UseLinkReturn {
|
|
45
45
|
/** Ref object — attach to the root element for viewport-based prefetch. */
|
|
46
|
-
ref: _pyreon_core0.Ref<HTMLAnchorElement>;
|
|
46
|
+
ref: _$_pyreon_core0.Ref<HTMLAnchorElement>;
|
|
47
47
|
/** Click handler — performs client-side navigation. */
|
|
48
48
|
handleClick: (e: MouseEvent) => void;
|
|
49
49
|
/** Mouse enter handler — triggers hover prefetch. */
|
package/lib/types/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as _pyreon_core0 from "@pyreon/core";
|
|
1
|
+
import * as _$_pyreon_core0 from "@pyreon/core";
|
|
2
2
|
import { ComponentFn } from "@pyreon/core";
|
|
3
|
-
import * as _pyreon_router0 from "@pyreon/router";
|
|
3
|
+
import * as _$_pyreon_router0 from "@pyreon/router";
|
|
4
4
|
import { RouteRecord } from "@pyreon/router";
|
|
5
5
|
import { Middleware, MiddlewareContext } from "@pyreon/server";
|
|
6
6
|
import { Plugin } from "vite";
|
|
@@ -23,8 +23,8 @@ interface CreateAppOptions {
|
|
|
23
23
|
* Used internally by entry-server and entry-client.
|
|
24
24
|
*/
|
|
25
25
|
declare function createApp(options: CreateAppOptions): {
|
|
26
|
-
App: () => _pyreon_core0.VNode;
|
|
27
|
-
router: _pyreon_router0.Router<string>;
|
|
26
|
+
App: () => _$_pyreon_core0.VNode;
|
|
27
|
+
router: _$_pyreon_router0.Router<string>;
|
|
28
28
|
};
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/api-routes.d.ts
|
|
@@ -118,6 +118,23 @@ interface RouteFileExports {
|
|
|
118
118
|
hasError: boolean;
|
|
119
119
|
/** Has `export const middleware` */
|
|
120
120
|
hasMiddleware: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Has `export const loaderKey` or `export function loaderKey`. When present,
|
|
123
|
+
* the route generator wires it as the `loaderKey` field on the route record,
|
|
124
|
+
* which controls cache identity for `_loaderCache`. Useful for auth-gate
|
|
125
|
+
* loaders that should invalidate when the session cookie changes — read
|
|
126
|
+
* `document.cookie` (CSR) or `ctx.request.headers.get('cookie')` (SSR) and
|
|
127
|
+
* derive a key from session identity. Default cache key is `path + params`,
|
|
128
|
+
* which doesn't see cookie changes.
|
|
129
|
+
*/
|
|
130
|
+
hasLoaderKey: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Has `export const gcTime` (number, in ms). When present, the route generator
|
|
133
|
+
* inlines it on the route record. `gcTime: 0` disables caching entirely —
|
|
134
|
+
* the loader runs on every navigation. Useful for auth-gate loaders that
|
|
135
|
+
* must validate session on every navigation rather than serve stale data.
|
|
136
|
+
*/
|
|
137
|
+
hasGcTime: boolean;
|
|
121
138
|
/**
|
|
122
139
|
* Raw text of the `export const meta = …` initializer, captured as a
|
|
123
140
|
* literal expression. When present, the route generator inlines this
|
|
@@ -281,6 +298,12 @@ declare function generateRouteModule(files: string[], routesDir: string, options
|
|
|
281
298
|
/**
|
|
282
299
|
* Generate a virtual module that maps URL patterns to their middleware exports.
|
|
283
300
|
* Used by the server entry to dispatch per-route middleware.
|
|
301
|
+
*
|
|
302
|
+
* Detects whether each route file actually exports `middleware` (via
|
|
303
|
+
* `detectRouteExports` source scanning) and only emits an import for files
|
|
304
|
+
* that do. The `lazy()` import path tolerates missing exports, but the SSG
|
|
305
|
+
* static-import path fails Rolldown's missing-export check at build time —
|
|
306
|
+
* skipping no-middleware files keeps both paths working.
|
|
284
307
|
*/
|
|
285
308
|
declare function generateMiddlewareModule(files: string[], routesDir: string): string;
|
|
286
309
|
/**
|
|
@@ -455,7 +478,7 @@ declare function getContext(ctx: MiddlewareContext): Record<string, unknown>;
|
|
|
455
478
|
* plugins: [pyreon(), zero()],
|
|
456
479
|
* }
|
|
457
480
|
*/
|
|
458
|
-
declare function zeroPlugin(userConfig?: ZeroConfig): Plugin;
|
|
481
|
+
declare function zeroPlugin(userConfig?: ZeroConfig): Plugin[];
|
|
459
482
|
//#endregion
|
|
460
483
|
//#region src/favicon.d.ts
|
|
461
484
|
interface FaviconLocaleConfig {
|
package/lib/types/theme.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as _pyreon_reactivity0 from "@pyreon/reactivity";
|
|
1
|
+
import * as _$_pyreon_reactivity0 from "@pyreon/reactivity";
|
|
2
2
|
import { VNodeChild } from "@pyreon/core";
|
|
3
3
|
|
|
4
4
|
//#region src/theme.d.ts
|
|
5
5
|
type Theme = 'light' | 'dark' | 'system';
|
|
6
6
|
/** Reactive theme signal. */
|
|
7
|
-
declare const theme: _pyreon_reactivity0.Signal<Theme>;
|
|
7
|
+
declare const theme: _$_pyreon_reactivity0.Signal<Theme>;
|
|
8
8
|
/**
|
|
9
9
|
* Set the default theme for SSR (when `matchMedia` is unavailable).
|
|
10
10
|
* Call once at server startup before rendering.
|