@hyperspan/framework 0.1.2 → 0.1.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/dist/index.d.ts DELETED
@@ -1,132 +0,0 @@
1
- // Generated by dts-bundle-generator v9.5.1
2
-
3
- import { Context, Handler, Hono } from 'hono';
4
-
5
- declare class TmplHtml {
6
- _kind: string;
7
- content: string;
8
- asyncContent: Array<{
9
- id: string;
10
- promise: Promise<{
11
- id: string;
12
- value: unknown;
13
- }>;
14
- }>;
15
- constructor(props: Pick<TmplHtml, "content" | "asyncContent">);
16
- }
17
- export declare const IS_PROD: boolean;
18
- /**
19
- * Route
20
- * Define a route that can handle a direct HTTP request
21
- * Route handlers should return a Response or TmplHtml object
22
- */
23
- export declare function createRoute(handler: Handler): HSRoute;
24
- /**
25
- * Component
26
- * Define a component or partial with an optional loading placeholder
27
- * These can be rendered anywhere inside other templates - even if async.
28
- */
29
- export declare function createComponent(render: () => THSComponentReturn | Promise<THSComponentReturn>): HSComponent;
30
- /**
31
- * Form + route handler
32
- * Automatically handles and parses form data
33
- *
34
- * INITIAL IDEA OF HOW THIS WILL WORK:
35
- * ---
36
- * 1. Renders component as initial form markup for GET request
37
- * 2. Bind form onSubmit function to custom client JS handling
38
- * 3. Submits form with JavaScript fetch()
39
- * 4. Replaces form content with content from server
40
- * 5. All validation and save logic is on the server
41
- * 6. Handles any Exception thrown on server as error displayed in client
42
- */
43
- export declare function createForm(renderForm: (data?: any) => THSResponseTypes, schema?: z.ZodSchema | null): HSFormRoute;
44
- /**
45
- * Types
46
- */
47
- export type THSComponentReturn = TmplHtml | string | number | null;
48
- export type THSResponseTypes = TmplHtml | Response | string | null;
49
- export declare const HS_DEFAULT_LOADING: () => TmplHtml;
50
- /**
51
- * Route handler helper
52
- */
53
- export declare class HSComponent {
54
- _kind: string;
55
- _handlers: Record<string, Handler>;
56
- _loading?: () => TmplHtml;
57
- render: () => THSComponentReturn | Promise<THSComponentReturn>;
58
- constructor(render: () => THSComponentReturn | Promise<THSComponentReturn>);
59
- loading(fn: () => TmplHtml): this;
60
- }
61
- /**
62
- * Route handler helper
63
- */
64
- export declare class HSRoute {
65
- _kind: string;
66
- _handlers: Record<string, Handler>;
67
- _methods: null | string[];
68
- constructor(handler: Handler);
69
- }
70
- /**
71
- * Form route handler helper
72
- */
73
- export type THSFormRenderer = (data?: any) => THSResponseTypes;
74
- export declare class HSFormRoute {
75
- _kind: string;
76
- _handlers: Record<string, Handler>;
77
- _form: THSFormRenderer;
78
- _methods: null | string[];
79
- _schema: null | z.ZodSchema;
80
- constructor(renderForm: THSFormRenderer, schema?: z.ZodSchema | null);
81
- getDefaultData(): unknown;
82
- /**
83
- * Get form renderer method
84
- */
85
- renderForm(data?: any): THSResponseTypes;
86
- get(handler: Handler): this;
87
- patch(handler: Handler): this;
88
- post(handler: Handler): this;
89
- put(handler: Handler): this;
90
- delete(handler: Handler): this;
91
- }
92
- /**
93
- * Run route from file
94
- */
95
- export declare function runFileRoute(RouteModule: any, context: Context): Promise<Response | false>;
96
- export type THSServerConfig = {
97
- appDir: string;
98
- staticFileRoot: string;
99
- rewrites?: Array<{
100
- source: string;
101
- destination: string;
102
- }>;
103
- beforeRoutesAdded?: (app: Hono) => void;
104
- afterRoutesAdded?: (app: Hono) => void;
105
- };
106
- export type THSRouteMap = {
107
- file: string;
108
- route: string;
109
- params: string[];
110
- };
111
- export declare function buildRoutes(config: THSServerConfig): Promise<THSRouteMap[]>;
112
- /**
113
- * Create and start Bun HTTP server
114
- */
115
- export declare function createServer(config: THSServerConfig): Promise<Hono>;
116
- /**
117
- * Streaming HTML Response
118
- */
119
- export declare class StreamResponse extends Response {
120
- constructor(iterator: AsyncIterator<unknown>, options?: {});
121
- }
122
- /**
123
- * Does what it says on the tin...
124
- */
125
- export declare function createReadableStreamFromAsyncGenerator(output: AsyncGenerator): ReadableStream<any>;
126
- /**
127
- * Normalize URL path
128
- * Removes trailing slash and lowercases path
129
- */
130
- export declare function normalizePath(urlPath: string): string;
131
-
132
- export {};