@ijo-elaja/rev.js 0.6.2 → 0.6.3
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/global.d.ts +0 -11
- package/index.ts +33 -1
- package/package.json +1 -1
- package/index.d.ts +0 -58
package/global.d.ts
CHANGED
|
@@ -14,17 +14,6 @@ declare global {
|
|
|
14
14
|
[elem: string]: any;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
type PageContext = {
|
|
19
|
-
params: Record<string, string>;
|
|
20
|
-
query: Record<string, string>;
|
|
21
|
-
request?: Request;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type PageProps<T extends Record<string, string> = {}> = {
|
|
25
|
-
context?: PageContext & { params: T };
|
|
26
|
-
children?: VNode;
|
|
27
|
-
};
|
|
28
17
|
}
|
|
29
18
|
|
|
30
19
|
export {};
|
package/index.ts
CHANGED
|
@@ -40,9 +40,41 @@ export const error = (...args: any[]) => _errorf("revjs.log", ...args);
|
|
|
40
40
|
/** @jsx h */
|
|
41
41
|
/** @jsxFrag Fragment */
|
|
42
42
|
|
|
43
|
+
//#region Global type declarations
|
|
44
|
+
|
|
45
|
+
import { type VNode } from "preact";
|
|
46
|
+
|
|
47
|
+
declare global {
|
|
48
|
+
namespace JSX {
|
|
49
|
+
interface Element extends VNode {}
|
|
50
|
+
interface ElementClass {
|
|
51
|
+
render(): any;
|
|
52
|
+
}
|
|
53
|
+
interface ElementAttributesProperty {
|
|
54
|
+
props: any;
|
|
55
|
+
}
|
|
56
|
+
interface IntrinsicElements {
|
|
57
|
+
[elem: string]: any;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type PageContext = {
|
|
62
|
+
params: Record<string, string>;
|
|
63
|
+
query: Record<string, string>;
|
|
64
|
+
request?: Request;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type PageProps<T extends Record<string, string> = {}> = {
|
|
68
|
+
context?: PageContext & { params: T };
|
|
69
|
+
children?: VNode;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
|
|
43
75
|
//#region JSX SSR
|
|
44
76
|
|
|
45
|
-
import { h, Fragment
|
|
77
|
+
import { h, Fragment } from "preact";
|
|
46
78
|
import { render } from "preact-render-to-string";
|
|
47
79
|
import prettier from "prettier";
|
|
48
80
|
import path from "node:path";
|
package/package.json
CHANGED
package/index.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import Elysia from "elysia";
|
|
2
|
-
import { VNode, Fragment } from "preact";
|
|
3
|
-
|
|
4
|
-
declare const log: (...args: any[]) => void;
|
|
5
|
-
declare const debug: (...args: any[]) => void;
|
|
6
|
-
declare const warn: (...args: any[]) => void;
|
|
7
|
-
declare const error: (...args: any[]) => void;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Context object passed to page and layout components
|
|
11
|
-
*/
|
|
12
|
-
declare interface PageContext {
|
|
13
|
-
/** Dynamic route parameters (e.g., [slug] becomes params.slug) */
|
|
14
|
-
params: Record<string, string>;
|
|
15
|
-
/** Query string parameters */
|
|
16
|
-
query: Record<string, string>;
|
|
17
|
-
/** The incoming HTTP request (contains headers, cookies, etc.) */
|
|
18
|
-
request?: Request;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Props passed to page and layout components
|
|
23
|
-
*/
|
|
24
|
-
declare interface PageProps<T extends Record<string, string> = {}> {
|
|
25
|
-
/** Context object with params, query, and request */
|
|
26
|
-
context?: PageContext & { params: T };
|
|
27
|
-
/** Child VNodes (for layouts) */
|
|
28
|
-
children?: VNode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
declare interface RevConfig {
|
|
32
|
-
port?: number;
|
|
33
|
-
showDebug?: boolean;
|
|
34
|
-
rootDir: string;
|
|
35
|
-
elysia?: (app: Elysia) => Elysia;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Rev - A JSX/TSX-based SSR framework
|
|
40
|
-
*
|
|
41
|
-
* File structure:
|
|
42
|
-
* - pages/_layout.tsx - Root layout (receives children and context)
|
|
43
|
-
* - pages/_page.tsx - Home page
|
|
44
|
-
* - pages/about/_page.tsx - About page with its own layout (optional)
|
|
45
|
-
* - pages/blog/[slug]/_page.tsx - Dynamic route
|
|
46
|
-
* - components/Header.tsx - Reusable component
|
|
47
|
-
*
|
|
48
|
-
* Component signature:
|
|
49
|
-
* export default function Page({ context, children }: { context?: PageContext; children?: VNode }) {
|
|
50
|
-
* return <div>{children}</div>;
|
|
51
|
-
* }
|
|
52
|
-
*/
|
|
53
|
-
declare class Rev {
|
|
54
|
-
constructor(config: RevConfig);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export { Rev as default, Fragment };
|
|
58
|
-
export type { RevConfig, PageContext, PageProps };
|