@teamvelix/velix 5.1.7 → 5.2.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/dist/build/index.js +3 -2
- package/dist/chunk-4S5YQJHB.js +11 -0
- package/dist/chunk-4S5YQJHB.js.map +1 -0
- package/dist/{chunk-CFDPNOWM.js → chunk-DTF3KTLR.js} +82 -31
- package/dist/chunk-DTF3KTLR.js.map +1 -0
- package/dist/{chunk-OIZNYND3.js → chunk-JI2HJFUT.js} +2 -2
- package/dist/chunk-JI2HJFUT.js.map +1 -0
- package/dist/{chunk-X2EZAAQS.js → chunk-QIPVMOXL.js} +4 -4
- package/dist/chunk-QIPVMOXL.js.map +1 -0
- package/dist/{chunk-INOZP2VD.js → chunk-QLFG6PW3.js} +3 -2
- package/dist/chunk-QLFG6PW3.js.map +1 -0
- package/dist/{chunk-SB5DCDTH.js → chunk-XXPHGRLC.js} +3 -3
- package/dist/{chunk-SB5DCDTH.js.map → chunk-XXPHGRLC.js.map} +1 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +2 -1
- package/dist/config.js +1 -0
- package/dist/{image-optimizer-I6TWWH6W.js → image-optimizer-KPRXE5VI.js} +3 -3
- package/dist/image-optimizer-KPRXE5VI.js.map +1 -0
- package/dist/index-8CqitL9K.d.ts +300 -0
- package/dist/{index-C4udNtpZ.d.ts → index-ChyKLf1W.d.ts} +18 -3
- package/dist/index.d.ts +53 -176
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/islands/index.d.ts +22 -10
- package/dist/islands/index.js +2 -1
- package/dist/runtime/start-build.js +2 -2
- package/dist/runtime/start-build.js.map +1 -1
- package/dist/runtime/start-dev.js +81 -22
- package/dist/runtime/start-dev.js.map +1 -1
- package/dist/runtime/start-prod.js +81 -22
- package/dist/runtime/start-prod.js.map +1 -1
- package/dist/server/index.d.ts +3 -1
- package/dist/server/index.js +4 -3
- package/package.json +60 -58
- package/dist/chunk-CFDPNOWM.js.map +0 -1
- package/dist/chunk-INOZP2VD.js.map +0 -1
- package/dist/chunk-OIZNYND3.js.map +0 -1
- package/dist/chunk-X2EZAAQS.js.map +0 -1
- package/dist/image-optimizer-I6TWWH6W.js.map +0 -1
- package/dist/index-DYgxL3mE.d.ts +0 -107
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export { VelixConfig, VelixConfigSchema, defaultConfig, defineConfig, loadConfig, resolvePaths } from './config.js';
|
|
2
|
+
import { R as Route, a as RouteTreeNode, b as RouteType } from './index-8CqitL9K.js';
|
|
3
|
+
export { m as ActionState, A as ApiHandler, B as BuildOptions, o as BuildResult, h as ErrorComponent, E as ErrorProps, I as IslandConfig, k as IslandManifest, g as LayoutComponent, L as LayoutProps, i as LoadingComponent, e as LoadingProps, n as Metadata, M as Middleware, l as NextFunction, j as NotFoundComponent, N as NotFoundProps, f as PageComponent, P as PageProps, x as PluginHooks, w as PluginManager, d as RouteMatch, c as RouteTree, S as ServerAction, p as StaticPath, q as StaticProps, T as TypedActionResult, V as VelixPlugin, s as VelixServer, r as createServer, t as definePlugin, v as loadPlugins, u as pluginManager, y as tailwindPlugin } from './index-8CqitL9K.js';
|
|
4
|
+
export { InferActionInput, InferActionOutput, InferLoaderData } from '@teamvelix/velix-core';
|
|
2
5
|
import * as http from 'http';
|
|
3
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
4
|
-
import React, { ReactNode, ComponentType, ImgHTMLAttributes } from 'react';
|
|
5
|
-
export { use, useActionState, useOptimistic } from 'react';
|
|
6
|
-
export { a as PluginHooks, P as PluginManager, V as VelixServer, c as createServer, d as definePlugin, l as loadPlugins, p as pluginManager, t as tailwindPlugin } from './index-DYgxL3mE.js';
|
|
7
6
|
export { Island, LoadStrategy, createIsland, createLazyIsland, generateAdvancedHydrationScript, generateHydrationScript, getRegisteredIslands } from './islands/index.js';
|
|
8
|
-
export { L as LayoutContext, f as Link, R as RequestContext, d as RouteContext, e as createRequestContext, h as hydrate, r as router, u as useParams, b as usePathname, a as useQuery, c as useRequest, g as useRouter } from './index-
|
|
7
|
+
export { L as LayoutContext, f as Link, R as RequestContext, d as RouteContext, e as createRequestContext, h as hydrate, r as router, u as useParams, b as usePathname, a as useQuery, c as useRequest, g as useRouter } from './index-ChyKLf1W.js';
|
|
8
|
+
import React, { ImgHTMLAttributes } from 'react';
|
|
9
|
+
export { use, useActionState, useOptimistic } from 'react';
|
|
9
10
|
export { build } from './build/index.js';
|
|
10
11
|
export { useFormStatus } from 'react-dom';
|
|
11
12
|
import 'zod';
|
|
13
|
+
import '@teamvelix/velix-react';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Velix v5 Middleware System
|
|
@@ -21,13 +23,13 @@ interface MiddlewareRequest {
|
|
|
21
23
|
cookies: Record<string, string>;
|
|
22
24
|
params: Record<string, string>;
|
|
23
25
|
query: Record<string, string>;
|
|
24
|
-
body?:
|
|
26
|
+
body?: unknown;
|
|
25
27
|
raw: http.IncomingMessage;
|
|
26
28
|
}
|
|
27
29
|
interface MiddlewareResponse {
|
|
28
30
|
status: (code: number) => MiddlewareResponse;
|
|
29
31
|
header: (name: string, value: string) => MiddlewareResponse;
|
|
30
|
-
json: (data:
|
|
32
|
+
json: (data: unknown) => void;
|
|
31
33
|
redirect: (url: string, status?: number) => void;
|
|
32
34
|
rewrite: (url: string) => void;
|
|
33
35
|
next: () => Promise<void>;
|
|
@@ -70,155 +72,6 @@ declare function runMiddleware(req: http.IncomingMessage, res: http.ServerRespon
|
|
|
70
72
|
*/
|
|
71
73
|
declare function composeMiddleware(...fns: MiddlewareFunction[]): MiddlewareFunction;
|
|
72
74
|
|
|
73
|
-
/**
|
|
74
|
-
* Velix v5 Core Types
|
|
75
|
-
* Comprehensive type definitions for the framework
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
type RouteType = 'page' | 'api' | 'layout' | 'loading' | 'error' | 'not-found';
|
|
79
|
-
interface Route {
|
|
80
|
-
type: RouteType;
|
|
81
|
-
path: string;
|
|
82
|
-
filePath: string;
|
|
83
|
-
pattern: RegExp;
|
|
84
|
-
segments: string[];
|
|
85
|
-
layout?: string | null;
|
|
86
|
-
loading?: string | null;
|
|
87
|
-
error?: string | null;
|
|
88
|
-
notFound?: string | null;
|
|
89
|
-
template?: string | null;
|
|
90
|
-
middleware?: string | null;
|
|
91
|
-
isServerComponent?: boolean;
|
|
92
|
-
isClientComponent?: boolean;
|
|
93
|
-
isIsland?: boolean;
|
|
94
|
-
params?: Record<string, string>;
|
|
95
|
-
}
|
|
96
|
-
interface RouteTree {
|
|
97
|
-
pages: Route[];
|
|
98
|
-
api: Route[];
|
|
99
|
-
layouts: Map<string, string>;
|
|
100
|
-
tree: Record<string, unknown>;
|
|
101
|
-
appRoutes: Route[];
|
|
102
|
-
rootLayout?: string;
|
|
103
|
-
}
|
|
104
|
-
interface RouteMatch {
|
|
105
|
-
route: Route;
|
|
106
|
-
params: Record<string, string>;
|
|
107
|
-
}
|
|
108
|
-
type Request$1 = IncomingMessage & {
|
|
109
|
-
params?: Record<string, string>;
|
|
110
|
-
query?: Record<string, string>;
|
|
111
|
-
body?: unknown;
|
|
112
|
-
json?: () => Promise<unknown>;
|
|
113
|
-
};
|
|
114
|
-
type Response$1 = ServerResponse & {
|
|
115
|
-
json?: (data: unknown) => void;
|
|
116
|
-
send?: (data: string) => void;
|
|
117
|
-
status?: (code: number) => Response$1;
|
|
118
|
-
};
|
|
119
|
-
type NextFunction = () => void | Promise<void>;
|
|
120
|
-
type Middleware = (req: Request$1, res: Response$1, next: NextFunction) => void | Promise<void>;
|
|
121
|
-
type ApiHandler = (req: Request$1, res: Response$1) => void | Promise<void>;
|
|
122
|
-
|
|
123
|
-
type ActionState<T> = T | Promise<T>;
|
|
124
|
-
type ServerAction<State, Payload = FormData> = (prevState: Awaited<State>, payload: Payload) => State | Promise<State>;
|
|
125
|
-
interface TypedActionResult<T> {
|
|
126
|
-
success: boolean;
|
|
127
|
-
data?: T;
|
|
128
|
-
error?: string;
|
|
129
|
-
errors?: Record<string, string[]>;
|
|
130
|
-
redirect?: string;
|
|
131
|
-
}
|
|
132
|
-
interface PageProps {
|
|
133
|
-
params?: Record<string, string>;
|
|
134
|
-
searchParams?: Record<string, string>;
|
|
135
|
-
}
|
|
136
|
-
interface LayoutProps {
|
|
137
|
-
children: ReactNode;
|
|
138
|
-
params?: Record<string, string>;
|
|
139
|
-
}
|
|
140
|
-
interface ErrorProps {
|
|
141
|
-
error: Error;
|
|
142
|
-
reset: () => void;
|
|
143
|
-
}
|
|
144
|
-
interface LoadingProps {
|
|
145
|
-
}
|
|
146
|
-
interface NotFoundProps {
|
|
147
|
-
}
|
|
148
|
-
type PageComponent = ComponentType<PageProps>;
|
|
149
|
-
type LayoutComponent = ComponentType<LayoutProps>;
|
|
150
|
-
type ErrorComponent = ComponentType<ErrorProps>;
|
|
151
|
-
type LoadingComponent = ComponentType<LoadingProps>;
|
|
152
|
-
type NotFoundComponent = ComponentType<NotFoundProps>;
|
|
153
|
-
interface IslandConfig {
|
|
154
|
-
name: string;
|
|
155
|
-
component: ComponentType<unknown>;
|
|
156
|
-
props?: Record<string, unknown>;
|
|
157
|
-
hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'interaction';
|
|
158
|
-
media?: string;
|
|
159
|
-
}
|
|
160
|
-
interface IslandManifest {
|
|
161
|
-
islands: Map<string, IslandConfig>;
|
|
162
|
-
}
|
|
163
|
-
interface BuildOptions {
|
|
164
|
-
outDir?: string;
|
|
165
|
-
minify?: boolean;
|
|
166
|
-
sourcemap?: boolean;
|
|
167
|
-
target?: string;
|
|
168
|
-
}
|
|
169
|
-
interface BuildResult {
|
|
170
|
-
success: boolean;
|
|
171
|
-
errors?: string[];
|
|
172
|
-
warnings?: string[];
|
|
173
|
-
duration?: number;
|
|
174
|
-
}
|
|
175
|
-
interface StaticPath {
|
|
176
|
-
params: Record<string, string>;
|
|
177
|
-
}
|
|
178
|
-
interface StaticProps {
|
|
179
|
-
props: Record<string, unknown>;
|
|
180
|
-
revalidate?: number | false;
|
|
181
|
-
notFound?: boolean;
|
|
182
|
-
redirect?: {
|
|
183
|
-
destination: string;
|
|
184
|
-
permanent?: boolean;
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
interface VelixPlugin {
|
|
188
|
-
name: string;
|
|
189
|
-
setup?: (config: any) => void | Promise<void>;
|
|
190
|
-
transform?: (code: string, id: string) => string | null | Promise<string | null>;
|
|
191
|
-
buildStart?: () => void | Promise<void>;
|
|
192
|
-
buildEnd?: () => void | Promise<void>;
|
|
193
|
-
}
|
|
194
|
-
interface Metadata$1 {
|
|
195
|
-
title?: string;
|
|
196
|
-
description?: string;
|
|
197
|
-
keywords?: string[];
|
|
198
|
-
author?: string;
|
|
199
|
-
canonical?: string;
|
|
200
|
-
openGraph?: {
|
|
201
|
-
title?: string;
|
|
202
|
-
description?: string;
|
|
203
|
-
image?: string;
|
|
204
|
-
url?: string;
|
|
205
|
-
type?: string;
|
|
206
|
-
siteName?: string;
|
|
207
|
-
};
|
|
208
|
-
twitter?: {
|
|
209
|
-
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
210
|
-
title?: string;
|
|
211
|
-
description?: string;
|
|
212
|
-
image?: string;
|
|
213
|
-
site?: string;
|
|
214
|
-
creator?: string;
|
|
215
|
-
};
|
|
216
|
-
robots?: {
|
|
217
|
-
index?: boolean;
|
|
218
|
-
follow?: boolean;
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
75
|
/**
|
|
223
76
|
* Velix v5 Server Helpers
|
|
224
77
|
* Utility functions for server-side operations
|
|
@@ -330,21 +183,37 @@ declare function isMethod(request: Request, method: string | string[]): boolean;
|
|
|
330
183
|
* Builds the complete route tree from the app/ directory
|
|
331
184
|
*/
|
|
332
185
|
declare function buildRouteTree(appDir: string): {
|
|
333
|
-
pages:
|
|
334
|
-
api:
|
|
186
|
+
pages: Route[];
|
|
187
|
+
api: Route[];
|
|
335
188
|
layouts: Map<string, string>;
|
|
336
|
-
tree:
|
|
337
|
-
appRoutes:
|
|
189
|
+
tree: RouteTreeNode;
|
|
190
|
+
appRoutes: Route[];
|
|
338
191
|
rootLayout?: string;
|
|
339
192
|
};
|
|
340
193
|
/**
|
|
341
194
|
* Matches URL path against routes
|
|
342
195
|
*/
|
|
343
|
-
declare function matchRoute(urlPath: string, routes:
|
|
196
|
+
declare function matchRoute(urlPath: string, routes: Route[]): {
|
|
197
|
+
params: Record<string, string>;
|
|
198
|
+
type: RouteType;
|
|
199
|
+
path: string;
|
|
200
|
+
filePath: string;
|
|
201
|
+
pattern: RegExp;
|
|
202
|
+
segments: string[];
|
|
203
|
+
layout?: string | null;
|
|
204
|
+
loading?: string | null;
|
|
205
|
+
error?: string | null;
|
|
206
|
+
notFound?: string | null;
|
|
207
|
+
template?: string | null;
|
|
208
|
+
middleware?: string | null;
|
|
209
|
+
isServerComponent?: boolean;
|
|
210
|
+
isClientComponent?: boolean;
|
|
211
|
+
isIsland?: boolean;
|
|
212
|
+
} | null;
|
|
344
213
|
/**
|
|
345
214
|
* Finds all layouts that apply to a route
|
|
346
215
|
*/
|
|
347
|
-
declare function findRouteLayouts(route:
|
|
216
|
+
declare function findRouteLayouts(route: Route, layoutsMap: Map<string, string>): Array<{
|
|
348
217
|
name: string;
|
|
349
218
|
filePath: string | undefined;
|
|
350
219
|
}>;
|
|
@@ -491,7 +360,7 @@ interface FormatDetection {
|
|
|
491
360
|
}
|
|
492
361
|
declare function generateMetadataTags(metadata: Metadata, baseUrl?: string): string;
|
|
493
362
|
declare function mergeMetadata(parent: Metadata, child: Metadata): Metadata;
|
|
494
|
-
declare function generateJsonLd(data: Record<string,
|
|
363
|
+
declare function generateJsonLd(data: Record<string, unknown>): string;
|
|
495
364
|
declare const jsonLd: {
|
|
496
365
|
website: (c: {
|
|
497
366
|
name: string;
|
|
@@ -565,7 +434,10 @@ declare const jsonLd: {
|
|
|
565
434
|
/**
|
|
566
435
|
* Generate sitemap.xml content from routes
|
|
567
436
|
*/
|
|
568
|
-
declare function generateSitemap(routes:
|
|
437
|
+
declare function generateSitemap(routes: Array<{
|
|
438
|
+
type: string;
|
|
439
|
+
path: string;
|
|
440
|
+
}>, baseUrl: string): string;
|
|
569
441
|
/**
|
|
570
442
|
* Generate robots.txt content
|
|
571
443
|
*/
|
|
@@ -591,8 +463,8 @@ interface ActionContext {
|
|
|
591
463
|
redirect: typeof redirect;
|
|
592
464
|
notFound: typeof notFound;
|
|
593
465
|
}
|
|
594
|
-
type ServerActionFunction = (...args:
|
|
595
|
-
interface ActionResult<T =
|
|
466
|
+
type ServerActionFunction<TArgs extends unknown[] = unknown[], TReturn = unknown> = (...args: TArgs) => Promise<TReturn>;
|
|
467
|
+
interface ActionResult<T = unknown> {
|
|
596
468
|
success: boolean;
|
|
597
469
|
data?: T;
|
|
598
470
|
error?: string;
|
|
@@ -601,22 +473,22 @@ interface ActionResult<T = any> {
|
|
|
601
473
|
/**
|
|
602
474
|
* Decorator to mark a function as a server action
|
|
603
475
|
*/
|
|
604
|
-
declare function serverAction<
|
|
476
|
+
declare function serverAction<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>, actionId?: string): (...args: TArgs) => Promise<ActionResult<TReturn>>;
|
|
605
477
|
declare function registerAction(id: string, fn: ServerActionFunction): void;
|
|
606
478
|
declare function getAction(id: string): ServerActionFunction | undefined;
|
|
607
479
|
/**
|
|
608
480
|
* Execute a server action on the server
|
|
609
481
|
*/
|
|
610
|
-
declare function executeAction(actionId: string, args:
|
|
482
|
+
declare function executeAction(actionId: string, args: unknown[], context?: Partial<ActionContext>): Promise<ActionResult>;
|
|
611
483
|
/**
|
|
612
484
|
* Call a server action from the client
|
|
613
485
|
*/
|
|
614
|
-
declare function callServerAction(actionId: string, args:
|
|
615
|
-
declare function deserializeArgs(args:
|
|
486
|
+
declare function callServerAction(actionId: string, args: unknown[]): Promise<ActionResult>;
|
|
487
|
+
declare function deserializeArgs(args: unknown[]): unknown[];
|
|
616
488
|
declare function useActionContext(): ActionContext | null;
|
|
617
489
|
declare function formAction<T>(action: (formData: FormData) => Promise<T>): (formData: FormData) => Promise<ActionResult<T>>;
|
|
618
490
|
declare function useVelixAction<State, Payload>(action: (state: Awaited<State>, payload: Payload) => State | Promise<State>, initialState: Awaited<State>, permalink?: string): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
|
|
619
|
-
declare function bindArgs<
|
|
491
|
+
declare function bindArgs<TArgs extends unknown[], TBound extends unknown[], TReturn>(action: (...args: [...TBound, ...TArgs]) => Promise<ActionResult<TReturn>>, ...boundArgs: TBound): (...args: TArgs) => Promise<ActionResult<TReturn>>;
|
|
620
492
|
|
|
621
493
|
/**
|
|
622
494
|
* Velix v5 Revalidation & Cache Management
|
|
@@ -626,8 +498,8 @@ type RevalidationType = 'path' | 'tag' | 'layout';
|
|
|
626
498
|
declare class CacheManager {
|
|
627
499
|
private cache;
|
|
628
500
|
private tagIndex;
|
|
629
|
-
set(path: string, data:
|
|
630
|
-
get(path: string):
|
|
501
|
+
set(path: string, data: unknown, tags?: string[]): void;
|
|
502
|
+
get(path: string): unknown | null;
|
|
631
503
|
revalidatePath(path: string): void;
|
|
632
504
|
revalidateTag(tag: string): void;
|
|
633
505
|
clear(): void;
|
|
@@ -738,7 +610,7 @@ declare function copyDir(src: string, dest: string): void;
|
|
|
738
610
|
/**
|
|
739
611
|
* Debounce function for file watching
|
|
740
612
|
*/
|
|
741
|
-
declare function debounce<T extends (...args:
|
|
613
|
+
declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
742
614
|
/**
|
|
743
615
|
* Formats bytes to human-readable string
|
|
744
616
|
*/
|
|
@@ -770,7 +642,12 @@ declare function isIsland(filePath: string): boolean;
|
|
|
770
642
|
*/
|
|
771
643
|
declare const logger: {
|
|
772
644
|
logo(): void;
|
|
773
|
-
serverStart(config:
|
|
645
|
+
serverStart(config: {
|
|
646
|
+
port: number | string;
|
|
647
|
+
host: string;
|
|
648
|
+
mode: string;
|
|
649
|
+
pagesDir?: string;
|
|
650
|
+
}, startTime?: number): void;
|
|
774
651
|
request(method: string, path: string, status: number, time: number, extra?: {
|
|
775
652
|
type?: string;
|
|
776
653
|
}): void;
|
|
@@ -790,4 +667,4 @@ declare const logger: {
|
|
|
790
667
|
}): void;
|
|
791
668
|
};
|
|
792
669
|
|
|
793
|
-
export { type
|
|
670
|
+
export { type CookieOptions, Image, type ImageProps, NotFoundError, RedirectError, Route, RouteType, bindArgs, buildRouteTree, cacheManager, callServerAction, cleanDir, composeMiddleware, cookies, copyDir, debounce, deserializeArgs, ensureDir, escapeHtml, executeAction, findFiles, findRouteLayouts, formAction, formatBytes, formatTime, generateHash, generateJsonLd, generateMetadataTags, generateRobotsTxt, generateSitemap, getAction, getMethod, getPathname, headers, html, isClientComponent, isIsland as isIslandComponent, isMethod, isServerComponent, json, jsonLd, loadMiddleware, logger, matchRoute, mergeMetadata, middlewares, notFound, parseFormData, parseJson, parseSearchParams, preloadResource, redirect, registerAction, revalidatePath, revalidateTag, runMiddleware, serverAction, sleep, text, unstable_cache, useActionContext, useAsyncData, useOptimisticMutation, useVelixAction };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { NotFoundError, PluginHooks, PluginManager, RedirectError, bindArgs, callServerAction, composeMiddleware, cookies, createServer, definePlugin, deserializeArgs, executeAction, formAction, generateJsonLd, generateMetadataTags, generateRobotsTxt, generateSitemap, getAction, getMethod, getPathname, headers, html, isMethod, json, jsonLd, loadMiddleware, loadPlugins, mergeMetadata, middlewares, notFound, parseFormData, parseJson, parseSearchParams, pluginManager, redirect, registerAction, runMiddleware, serverAction, tailwindPlugin, text, useActionContext, useActionState, useFormStatus, useOptimistic, useVelixAction } from './chunk-
|
|
4
|
-
export { buildRouteTree, cleanDir, copyDir, debounce, ensureDir, escapeHtml, findFiles, findRouteLayouts, formatBytes, formatTime, generateHash, isClientComponent, isIsland as isIslandComponent, isServerComponent, logger, matchRoute, sleep } from './chunk-
|
|
1
|
+
export { build } from './chunk-XXPHGRLC.js';
|
|
2
|
+
export { LayoutContext, Link, RequestContext, RouteContext, createRequestContext, hydrate, router, useParams, usePathname, useQuery, useRequest, useRouter } from './chunk-QLFG6PW3.js';
|
|
3
|
+
export { NotFoundError, PluginHooks, PluginManager, RedirectError, bindArgs, callServerAction, composeMiddleware, cookies, createServer, definePlugin, deserializeArgs, executeAction, formAction, generateJsonLd, generateMetadataTags, generateRobotsTxt, generateSitemap, getAction, getMethod, getPathname, headers, html, isMethod, json, jsonLd, loadMiddleware, loadPlugins, mergeMetadata, middlewares, notFound, parseFormData, parseJson, parseSearchParams, pluginManager, redirect, registerAction, runMiddleware, serverAction, tailwindPlugin, text, useActionContext, useActionState, useFormStatus, useOptimistic, useVelixAction } from './chunk-DTF3KTLR.js';
|
|
4
|
+
export { buildRouteTree, cleanDir, copyDir, debounce, ensureDir, escapeHtml, findFiles, findRouteLayouts, formatBytes, formatTime, generateHash, isClientComponent, isIsland as isIslandComponent, isServerComponent, logger, matchRoute, sleep } from './chunk-QIPVMOXL.js';
|
|
5
5
|
export { VelixConfigSchema, defaultConfig, defineConfig, loadConfig, resolvePaths } from './chunk-F24Q2MX3.js';
|
|
6
|
-
export { Island, LoadStrategy, createIsland, createLazyIsland, generateAdvancedHydrationScript, generateHydrationScript, getRegisteredIslands } from './chunk-
|
|
7
|
-
import
|
|
6
|
+
export { Island, LoadStrategy, createIsland, createLazyIsland, generateAdvancedHydrationScript, generateHydrationScript, getRegisteredIslands } from './chunk-JI2HJFUT.js';
|
|
7
|
+
import './chunk-4S5YQJHB.js';
|
|
8
|
+
import React, { forwardRef, useState, use, useOptimistic } from 'react';
|
|
8
9
|
export { use } from 'react';
|
|
9
10
|
import 'react-dom';
|
|
10
11
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -86,6 +87,11 @@ function unstable_cache(fn, keys, options) {
|
|
|
86
87
|
return result;
|
|
87
88
|
};
|
|
88
89
|
}
|
|
90
|
+
React.createContext(null);
|
|
91
|
+
React.createContext(null);
|
|
92
|
+
React.createContext(null);
|
|
93
|
+
|
|
94
|
+
// ../velix-react/src/hooks/index.ts
|
|
89
95
|
function useAsyncData(promise) {
|
|
90
96
|
return use(promise);
|
|
91
97
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../actions/revalidation.ts","../hooks/index.ts","../components/Image.tsx"],"names":["use","useOptimisticReact"],"mappings":";;;;;;;;;;;;AAcA,IAAM,eAAN,MAAmB;AAAA,EACT,KAAA,uBAAY,GAAA,EAAwB;AAAA,EACpC,QAAA,uBAAe,GAAA,EAAyB;AAAA,EAEhD,GAAA,CAAI,IAAA,EAAc,IAAA,EAAW,IAAA,GAAiB,EAAC,EAAS;AACtD,IAAA,MAAM,KAAA,GAAoB;AAAA,MACxB,IAAA;AAAA,MACA,IAAA,EAAM,IAAI,GAAA,CAAI,IAAI,CAAA;AAAA,MAClB,SAAA,EAAW,KAAK,GAAA,EAAI;AAAA,MACpB;AAAA,KACF;AAEA,IAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,IAAA,EAAM,KAAK,CAAA;AAG1B,IAAA,IAAA,CAAK,QAAQ,CAAA,GAAA,KAAO;AAClB,MAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAG,CAAA,EAAG;AAC3B,QAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAA,kBAAK,IAAI,KAAK,CAAA;AAAA,MAClC;AACA,MAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAG,CAAA,CAAG,IAAI,IAAI,CAAA;AAAA,IAClC,CAAC,CAAA;AAAA,EACH;AAAA,EAEA,IAAI,IAAA,EAA0B;AAC5B,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,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ACA,OAAA,EAAS,WAAW,OAAA,GAAU,MAAA;AAAA,MAC9B,QAAA,EAAU,WAAW,MAAA,GAAS,OAAA;AAAA,MAC9B,SAAA;AAAA,MACA,KAAA,EAAO;AAAA,QACL,KAAA,EAAO,aAAA;AAAA,QACP,GAAG;AAAA,OACL;AAAA,MACA,MAAA,EAAQ,CAAC,CAAA,KAAM;AACb,QAAA,WAAA,CAAY,IAAI,CAAA;AAChB,QAAA,IAAI,IAAA,CAAK,MAAA,EAAQ,IAAA,CAAK,MAAA,CAAO,CAAC,CAAA;AAAA,MAChC,CAAA;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ,CAAC;AAED,KAAA,CAAM,WAAA,GAAc,OAAA","file":"index.js","sourcesContent":["/**\n * Velix v5 Revalidation & Cache Management\n * Inspired by Next.js revalidatePath and revalidateTag\n */\n\nexport type RevalidationType = 'path' | 'tag' | 'layout';\n\ninterface CacheEntry {\n path: string;\n tags: Set<string>;\n timestamp: number;\n data: any;\n}\n\nclass CacheManager {\n private cache = new Map<string, CacheEntry>();\n private tagIndex = new Map<string, Set<string>>();\n\n set(path: string, data: any, tags: string[] = []): void {\n const entry: CacheEntry = {\n path,\n tags: new Set(tags),\n timestamp: Date.now(),\n data,\n };\n\n this.cache.set(path, entry);\n\n // Index by tags\n tags.forEach(tag => {\n if (!this.tagIndex.has(tag)) {\n this.tagIndex.set(tag, new Set());\n }\n this.tagIndex.get(tag)!.add(path);\n });\n }\n\n get(path: string): any | null {\n const entry = this.cache.get(path);\n return entry ? entry.data : null;\n }\n\n revalidatePath(path: string): void {\n this.cache.delete(path);\n }\n\n revalidateTag(tag: string): void {\n const paths = this.tagIndex.get(tag);\n if (paths) {\n paths.forEach(path => this.cache.delete(path));\n this.tagIndex.delete(tag);\n }\n }\n\n clear(): void {\n this.cache.clear();\n this.tagIndex.clear();\n }\n\n has(path: string): boolean {\n return this.cache.has(path);\n }\n}\n\nexport const cacheManager = new CacheManager();\n\n/**\n * Revalidate a specific path\n * @example\n * ```ts\n * import { revalidatePath } from 'velix/actions';\n * \n * await revalidatePath('/blog');\n * await revalidatePath('/blog/[slug]', 'layout');\n * ```\n */\nexport function revalidatePath(path: string, type: RevalidationType = 'path'): void {\n cacheManager.revalidatePath(path);\n \n // Notify connected clients via HMR\n if (typeof global !== 'undefined' && (global as any).__VELIX_HMR_SERVER__) {\n (global as any).__VELIX_HMR_SERVER__.broadcast(JSON.stringify({\n type: 'revalidate',\n path,\n revalidationType: type,\n }));\n }\n}\n\n/**\n * Revalidate all paths with a specific cache tag\n * @example\n * ```ts\n * import { revalidateTag } from 'velix/actions';\n * \n * await revalidateTag('blog-posts');\n * ```\n */\nexport function revalidateTag(tag: string): void {\n cacheManager.revalidateTag(tag);\n\n // Notify connected clients\n if (typeof global !== 'undefined' && (global as any).__VELIX_HMR_SERVER__) {\n (global as any).__VELIX_HMR_SERVER__.broadcast(JSON.stringify({\n type: 'revalidate',\n tag,\n }));\n }\n}\n\n/**\n * Unstable cache wrapper (experimental)\n */\nexport function unstable_cache<T>(\n fn: () => Promise<T>,\n keys: string[],\n options?: { tags?: string[]; revalidate?: number }\n): () => Promise<T> {\n return async () => {\n const cacheKey = keys.join(':');\n \n if (cacheManager.has(cacheKey)) {\n return cacheManager.get(cacheKey);\n }\n\n const result = await fn();\n cacheManager.set(cacheKey, result, options?.tags || []);\n\n if (options?.revalidate) {\n setTimeout(() => {\n cacheManager.revalidatePath(cacheKey);\n }, options.revalidate * 1000);\n }\n\n return result;\n };\n}\n","/**\n * Velix v5 Hooks\n * React 19 hooks re-exports and Velix-specific hook utilities\n */\n\n// React 19 Core Hooks\nexport { useActionState, useOptimistic, use } from 'react';\nexport { useFormStatus } from 'react-dom';\n\n// Velix Context Hooks\nexport { useParams, useQuery, usePathname, useRequest } from '../context.js';\n\n// ============================================================================\n// Velix Enhanced Hooks\n// ============================================================================\n\nimport { use, useOptimistic as useOptimisticReact } from 'react';\n\n/**\n * Async data fetching hook using React 19's use()\n *\n * @example\n * ```tsx\n * function UserProfile({ userId }: { userId: string }) {\n * const user = useAsyncData(fetchUser(userId));\n * return <div>{user.name}</div>;\n * }\n * ```\n */\nexport function useAsyncData<T>(promise: Promise<T>): T {\n return use(promise);\n}\n\n/**\n * Optimistic mutation helper with typed update function\n *\n * @example\n * ```tsx\n * const [optimisticTodos, addOptimistic] = useOptimisticMutation(\n * todos,\n * (state, newTodo: Todo) => [...state, { ...newTodo, pending: true }]\n * );\n * ```\n */\nexport function useOptimisticMutation<T, M>(\n currentState: T,\n updateFn: (state: T, mutation: M) => T\n): [T, (mutation: M) => void] {\n return useOptimisticReact(currentState, updateFn);\n}\n\n/**\n * Resource preloading for Suspense optimization\n */\nexport function preloadResource<T>(fetcher: () => Promise<T>): Promise<T> {\n return fetcher();\n}\n\nexport default { useAsyncData, useOptimisticMutation, preloadResource };\n","import React, { ImgHTMLAttributes, forwardRef, useState, useEffect } from 'react';\n\nexport interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'src' | 'srcSet'> {\n src: string;\n alt: string;\n width?: number | string;\n height?: number | string;\n quality?: number;\n priority?: boolean;\n unoptimized?: boolean;\n}\n\nconst defaultWidths = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];\nconst defaultQuality = 75;\n\nexport const Image = forwardRef<HTMLImageElement, ImageProps>(({\n src,\n alt,\n width,\n height,\n quality = defaultQuality,\n priority = false,\n unoptimized = false,\n className,\n style,\n ...rest\n}, ref) => {\n const [isLoaded, setIsLoaded] = useState(false);\n\n // If it's an external URL (http) or unoptimized is set, we skip the optimization router\n const isExternal = src.startsWith('http');\n const skipOptimization = unoptimized || (isExternal && !src.includes('our-domain'));\n\n const generateSrcSet = () => {\n if (skipOptimization) return undefined;\n return defaultWidths\n .map(w => `/__velix/image?url=${encodeURIComponent(src)}&w=${w}&q=${quality} ${w}w`)\n .join(', ');\n };\n\n const optimizedSrc = skipOptimization\n ? src\n : `/__velix/image?url=${encodeURIComponent(src)}&w=${width || 1080}&q=${quality}`;\n\n return (\n <img\n ref={ref}\n src={optimizedSrc}\n srcSet={generateSrcSet()}\n alt={alt}\n width={width}\n height={height}\n loading={priority ? 'eager' : 'lazy'}\n decoding={priority ? 'sync' : 'async'}\n className={className}\n style={{\n color: 'transparent',\n ...style\n }}\n onLoad={(e) => {\n setIsLoaded(true);\n if (rest.onLoad) rest.onLoad(e);\n }}\n {...rest}\n />\n );\n});\n\nImage.displayName = 'Image';\n"]}
|
|
1
|
+
{"version":3,"sources":["../actions/revalidation.ts","../../velix-react/src/context.ts","../../velix-react/src/hooks/index.ts","../../velix-react/src/components/Image.tsx"],"names":["use","useOptimisticReact","useState"],"mappings":";;;;;;;;;;;;;AAcA,IAAM,eAAN,MAAmB;AAAA,EACT,KAAA,uBAAY,GAAA,EAAwB;AAAA,EACpC,QAAA,uBAAe,GAAA,EAAyB;AAAA,EAEhD,GAAA,CAAI,IAAA,EAAc,IAAA,EAAe,IAAA,GAAiB,EAAC,EAAS;AAC1D,IAAA,MAAM,KAAA,GAAoB;AAAA,MACxB,IAAA;AAAA,MACA,IAAA,EAAM,IAAI,GAAA,CAAI,IAAI,CAAA;AAAA,MAClB,SAAA,EAAW,KAAK,GAAA,EAAI;AAAA,MACpB;AAAA,KACF;AAEA,IAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,IAAA,EAAM,KAAK,CAAA;AAG1B,IAAA,IAAA,CAAK,QAAQ,CAAA,GAAA,KAAO;AAClB,MAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAG,CAAA,EAAG;AAC3B,QAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAA,kBAAK,IAAI,KAAK,CAAA;AAAA,MAClC;AACA,MAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAG,CAAA,CAAG,IAAI,IAAI,CAAA;AAAA,IAClC,CAAC,CAAA;AAAA,EACH;AAAA,EAEA,IAAI,IAAA,EAA8B;AAChC,IAAA,MAAM,KAAA,GAA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KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,GAAA,EAAK,YAAA;AAAA,MACL,QAAQ,cAAA,EAAe;AAAA,MACvB,GAAA;AAAA,MACA,KAAA;AAAA,MACA,MAAA;AAAA,MACA,OAAA,EAAS,WAAW,OAAA,GAAU,MAAA;AAAA,MAC9B,QAAA,EAAU,WAAW,MAAA,GAAS,OAAA;AAAA,MAC9B,SAAA;AAAA,MACA,KAAA,EAAO;AAAA,QACL,KAAA,EAAO,aAAA;AAAA,QACP,GAAG;AAAA,OACL;AAAA,MACA,MAAA,EAAQ,CAAC,CAAA,KAAM;AACb,QAAA,WAAA,CAAY,IAAI,CAAA;AAChB,QAAA,IAAI,IAAA,CAAK,MAAA,EAAQ,IAAA,CAAK,MAAA,CAAO,CAAC,CAAA;AAAA,MAChC,CAAA;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ,CAAC;AAED,KAAA,CAAM,WAAA,GAAc,OAAA","file":"index.js","sourcesContent":["/**\n * Velix v5 Revalidation & Cache Management\n * Inspired by Next.js revalidatePath and revalidateTag\n */\n\nexport type RevalidationType = 'path' | 'tag' | 'layout';\n\ninterface CacheEntry {\n path: string;\n tags: Set<string>;\n timestamp: number;\n data: unknown;\n}\n\nclass CacheManager {\n private cache = new Map<string, CacheEntry>();\n private tagIndex = new Map<string, Set<string>>();\n\n set(path: string, data: unknown, tags: string[] = []): void {\n const entry: CacheEntry = {\n path,\n tags: new Set(tags),\n timestamp: Date.now(),\n data,\n };\n\n this.cache.set(path, entry);\n\n // Index by tags\n tags.forEach(tag => {\n if (!this.tagIndex.has(tag)) {\n this.tagIndex.set(tag, new Set());\n }\n this.tagIndex.get(tag)!.add(path);\n });\n }\n\n get(path: string): unknown | null {\n const entry = this.cache.get(path);\n return entry ? entry.data : null;\n }\n\n revalidatePath(path: string): void {\n this.cache.delete(path);\n }\n\n revalidateTag(tag: string): void {\n const paths = this.tagIndex.get(tag);\n if (paths) {\n paths.forEach(path => this.cache.delete(path));\n this.tagIndex.delete(tag);\n }\n }\n\n clear(): void {\n this.cache.clear();\n this.tagIndex.clear();\n }\n\n has(path: string): boolean {\n return this.cache.has(path);\n }\n}\n\nexport const cacheManager = new CacheManager();\n\n/**\n * Revalidate a specific path\n * @example\n * ```ts\n * import { revalidatePath } from 'velix/actions';\n * \n * await revalidatePath('/blog');\n * await revalidatePath('/blog/[slug]', 'layout');\n * ```\n */\nexport function revalidatePath(path: string, type: RevalidationType = 'path'): void {\n cacheManager.revalidatePath(path);\n \n // Notify connected clients via HMR\n if (typeof global !== 'undefined' && (global as unknown as { __VELIX_HMR_SERVER__?: { broadcast: (msg: string) => void } }).__VELIX_HMR_SERVER__) {\n (global as unknown as { __VELIX_HMR_SERVER__: { broadcast: (msg: string) => void } }).__VELIX_HMR_SERVER__.broadcast(JSON.stringify({\n type: 'revalidate',\n path,\n revalidationType: type,\n }));\n }\n}\n\n/**\n * Revalidate all paths with a specific cache tag\n * @example\n * ```ts\n * import { revalidateTag } from 'velix/actions';\n * \n * await revalidateTag('blog-posts');\n * ```\n */\nexport function revalidateTag(tag: string): void {\n cacheManager.revalidateTag(tag);\n\n // Notify connected clients\n if (typeof global !== 'undefined' && (global as unknown as { __VELIX_HMR_SERVER__?: { broadcast: (msg: string) => void } }).__VELIX_HMR_SERVER__) {\n (global as unknown as { __VELIX_HMR_SERVER__: { broadcast: (msg: string) => void } }).__VELIX_HMR_SERVER__.broadcast(JSON.stringify({\n type: 'revalidate',\n tag,\n }));\n }\n}\n\n/**\n * Unstable cache wrapper (experimental)\n */\nexport function unstable_cache<T>(\n fn: () => Promise<T>,\n keys: string[],\n options?: { tags?: string[]; revalidate?: number }\n): () => Promise<T> {\n return async () => {\n const cacheKey = keys.join(':');\n \n if (cacheManager.has(cacheKey)) {\n return cacheManager.get(cacheKey) as T;\n }\n\n const result = await fn();\n cacheManager.set(cacheKey, result, options?.tags || []);\n\n if (options?.revalidate) {\n setTimeout(() => {\n cacheManager.revalidatePath(cacheKey);\n }, options.revalidate * 1000);\n }\n\n return result;\n };\n}\n","/**\n * Velix v5 Context System\n * Provides request context and shared state for SSR\n */\n\nimport React from 'react';\n\n// Route context type\ninterface RouteContextType {\n params: Record<string, string>;\n query: Record<string, string>;\n pathname: string;\n}\n\n// Server-side request context\ninterface RequestContextType {\n req: import('http').IncomingMessage;\n res: import('http').ServerResponse;\n params: Record<string, string>;\n query: Record<string, string>;\n url: string | undefined;\n method: string | undefined;\n headers: import('http').IncomingHttpHeaders;\n cookies: Record<string, string>;\n}\nexport const RequestContext = React.createContext<RequestContextType | null>(null);\n\n// Route context for nested routes\nexport const RouteContext = React.createContext<RouteContextType | null>(null);\n\n// Layout context\ninterface LayoutContextType {\n children: React.ReactNode;\n params?: Record<string, string>;\n}\nexport const LayoutContext = React.createContext<LayoutContextType | null>(null);\n\n/**\n * Creates a request context value\n */\nexport function createRequestContext(\n req: import('http').IncomingMessage,\n res: import('http').ServerResponse,\n params: Record<string, string> = {},\n query: Record<string, string> = {}\n) {\n return {\n req,\n res,\n params,\n query,\n url: req.url,\n method: req.method,\n headers: req.headers,\n cookies: parseCookies(req.headers.cookie || '')\n };\n}\n\n/**\n * Parse cookies from header string\n */\nfunction parseCookies(cookieHeader: string): Record<string, string> {\n const cookies: Record<string, string> = {};\n if (!cookieHeader) return cookies;\n cookieHeader.split(';').forEach((cookie: string) => {\n const [name, ...rest] = cookie.split('=');\n if (name) cookies[name.trim()] = rest.join('=').trim();\n });\n return cookies;\n}\n\n/**\n * Hook to access request context (server-side only)\n */\nexport function useRequest() {\n const context = React.useContext(RequestContext);\n if (!context) throw new Error('useRequest must be used within a RequestContext provider');\n return context;\n}\n\n/**\n * Hook to access route params\n */\nexport function useParams() {\n const context = React.useContext(RouteContext);\n return context?.params || {};\n}\n\n/**\n * Hook to access query parameters\n */\nexport function useQuery() {\n const context = React.useContext(RouteContext);\n return context?.query || {};\n}\n\n/**\n * Hook to access current pathname\n */\nexport function usePathname() {\n const context = React.useContext(RouteContext);\n return context?.pathname || '/';\n}\n","/**\n * Velix v5 Hooks\n * React 19 hooks re-exports and Velix-specific hook utilities\n */\n\n// React 19 Core Hooks\nexport { useActionState, useOptimistic, use } from 'react';\nexport { useFormStatus } from 'react-dom';\n\n// Velix Context Hooks\nexport { useParams, useQuery, usePathname, useRequest } from '../context.js';\n\n// ============================================================================\n// Velix Enhanced Hooks\n// ============================================================================\n\nimport { use, useOptimistic as useOptimisticReact } from 'react';\n\n/**\n * Async data fetching hook using React 19's use()\n *\n * @example\n * ```tsx\n * function UserProfile({ userId }: { userId: string }) {\n * const user = useAsyncData(fetchUser(userId));\n * return <div>{user.name}</div>;\n * }\n * ```\n */\nexport function useAsyncData<T>(promise: Promise<T>): T {\n return use(promise);\n}\n\n/**\n * Optimistic mutation helper with typed update function\n *\n * @example\n * ```tsx\n * const [optimisticTodos, addOptimistic] = useOptimisticMutation(\n * todos,\n * (state, newTodo: Todo) => [...state, { ...newTodo, pending: true }]\n * );\n * ```\n */\nexport function useOptimisticMutation<T, M>(\n currentState: T,\n updateFn: (state: T, mutation: M) => T\n): [T, (mutation: M) => void] {\n return useOptimisticReact(currentState, updateFn);\n}\n\n/**\n * Resource preloading for Suspense optimization\n */\nexport function preloadResource<T>(fetcher: () => Promise<T>): Promise<T> {\n return fetcher();\n}\n\nexport * from './use-action.js';\n\nexport default { useAsyncData, useOptimisticMutation, preloadResource };\n","import React, { ImgHTMLAttributes, forwardRef, useState, useEffect } from 'react';\n\nexport interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'src' | 'srcSet'> {\n src: string;\n alt: string;\n width?: number | string;\n height?: number | string;\n quality?: number;\n priority?: boolean;\n unoptimized?: boolean;\n}\n\nconst defaultWidths = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];\nconst defaultQuality = 75;\n\nexport const Image = forwardRef<HTMLImageElement, ImageProps>(({\n src,\n alt,\n width,\n height,\n quality = defaultQuality,\n priority = false,\n unoptimized = false,\n className,\n style,\n ...rest\n}, ref) => {\n const [isLoaded, setIsLoaded] = useState(false);\n\n // If it's an external URL (http) or unoptimized is set, we skip the optimization router\n const isExternal = src.startsWith('http');\n const skipOptimization = unoptimized || (isExternal && !src.includes('our-domain'));\n\n const generateSrcSet = () => {\n if (skipOptimization) return undefined;\n return defaultWidths\n .map(w => `/__velix/image?url=${encodeURIComponent(src)}&w=${w}&q=${quality} ${w}w`)\n .join(', ');\n };\n\n const optimizedSrc = skipOptimization\n ? src\n : `/__velix/image?url=${encodeURIComponent(src)}&w=${width || 1080}&q=${quality}`;\n\n return (\n <img\n ref={ref}\n src={optimizedSrc}\n srcSet={generateSrcSet()}\n alt={alt}\n width={width}\n height={height}\n loading={priority ? 'eager' : 'lazy'}\n decoding={priority ? 'sync' : 'async'}\n className={className}\n style={{\n color: 'transparent',\n ...style\n }}\n onLoad={(e) => {\n setIsLoaded(true);\n if (rest.onLoad) rest.onLoad(e);\n }}\n {...rest}\n />\n );\n});\n\nImage.displayName = 'Image';\n"]}
|
package/dist/islands/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ import React from 'react';
|
|
|
13
13
|
* Island wrapper component for server-side rendering
|
|
14
14
|
*/
|
|
15
15
|
declare function Island({ component: Component, props, name, clientPath }: {
|
|
16
|
-
component: React.ComponentType<
|
|
17
|
-
props?:
|
|
16
|
+
component: React.ComponentType<Record<string, unknown>>;
|
|
17
|
+
props?: Record<string, unknown>;
|
|
18
18
|
name: string;
|
|
19
19
|
clientPath: string;
|
|
20
20
|
}): React.ReactElement<{
|
|
@@ -29,18 +29,18 @@ declare function getRegisteredIslands(): any[];
|
|
|
29
29
|
/**
|
|
30
30
|
* Creates an island component wrapper
|
|
31
31
|
*/
|
|
32
|
-
declare function createIsland(Component: React.ComponentType<
|
|
32
|
+
declare function createIsland(Component: React.ComponentType<Record<string, unknown>>, options?: {
|
|
33
33
|
name?: string;
|
|
34
34
|
clientPath?: string;
|
|
35
35
|
}): {
|
|
36
|
-
(props:
|
|
36
|
+
(props: Record<string, unknown>): React.ReactElement<{
|
|
37
37
|
'data-island': string;
|
|
38
38
|
'data-island-name': string;
|
|
39
39
|
'data-island-props': string;
|
|
40
40
|
}, string | React.JSXElementConstructor<any>>;
|
|
41
41
|
displayName: string;
|
|
42
42
|
isIsland: boolean;
|
|
43
|
-
originalComponent: React.ComponentType<
|
|
43
|
+
originalComponent: React.ComponentType<Record<string, unknown>>;
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
46
|
* Island loading strategies
|
|
@@ -54,15 +54,15 @@ declare const LoadStrategy: {
|
|
|
54
54
|
/**
|
|
55
55
|
* Creates a lazy island that hydrates based on strategy
|
|
56
56
|
*/
|
|
57
|
-
declare function createLazyIsland(Component: React.ComponentType<
|
|
57
|
+
declare function createLazyIsland(Component: React.ComponentType<Record<string, unknown>>, options?: {
|
|
58
58
|
name?: string;
|
|
59
59
|
clientPath?: string;
|
|
60
60
|
strategy?: string;
|
|
61
61
|
media?: string | null;
|
|
62
62
|
}): {
|
|
63
|
-
(props:
|
|
63
|
+
(props: Record<string, unknown>): React.ReactElement<{
|
|
64
64
|
'data-island': string;
|
|
65
|
-
'data-island-name':
|
|
65
|
+
'data-island-name': string;
|
|
66
66
|
'data-island-strategy': string;
|
|
67
67
|
'data-island-media': string | null;
|
|
68
68
|
'data-island-props': string;
|
|
@@ -74,11 +74,23 @@ declare function createLazyIsland(Component: React.ComponentType<any>, options?:
|
|
|
74
74
|
/**
|
|
75
75
|
* Generates the client-side hydration script for islands
|
|
76
76
|
*/
|
|
77
|
-
declare function generateHydrationScript(islands:
|
|
77
|
+
declare function generateHydrationScript(islands: Array<{
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
clientPath: string;
|
|
81
|
+
props: Record<string, unknown>;
|
|
82
|
+
}>): string;
|
|
78
83
|
/**
|
|
79
84
|
* Generates advanced hydration script with loading strategies
|
|
80
85
|
*/
|
|
81
|
-
declare function generateAdvancedHydrationScript(islands:
|
|
86
|
+
declare function generateAdvancedHydrationScript(islands: Array<{
|
|
87
|
+
id: string;
|
|
88
|
+
name: string;
|
|
89
|
+
clientPath: string;
|
|
90
|
+
props: Record<string, unknown>;
|
|
91
|
+
strategy?: string;
|
|
92
|
+
media?: string | null;
|
|
93
|
+
}>): string;
|
|
82
94
|
declare const _default: {
|
|
83
95
|
Island: typeof Island;
|
|
84
96
|
createIsland: typeof createIsland;
|
package/dist/islands/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { Island, LoadStrategy, createIsland, createLazyIsland, islands_default as default, generateAdvancedHydrationScript, generateHydrationScript, getRegisteredIslands } from '../chunk-
|
|
1
|
+
export { Island, LoadStrategy, createIsland, createLazyIsland, islands_default as default, generateAdvancedHydrationScript, generateHydrationScript, getRegisteredIslands } from '../chunk-JI2HJFUT.js';
|
|
2
|
+
import '../chunk-4S5YQJHB.js';
|
|
2
3
|
//# sourceMappingURL=index.js.map
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -196,7 +196,7 @@ function buildRouteTree(appDir) {
|
|
|
196
196
|
pages: [],
|
|
197
197
|
api: [],
|
|
198
198
|
layouts: /* @__PURE__ */ new Map(),
|
|
199
|
-
tree: {},
|
|
199
|
+
tree: { children: {}, routes: [] },
|
|
200
200
|
appRoutes: []
|
|
201
201
|
};
|
|
202
202
|
if (fs3.existsSync(appDir)) {
|
|
@@ -348,7 +348,7 @@ function buildTree(routes) {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
// version.ts
|
|
351
|
-
var VERSION = "5.1.
|
|
351
|
+
var VERSION = "5.1.7";
|
|
352
352
|
|
|
353
353
|
// logger.ts
|
|
354
354
|
var colors = {
|