weifuwu 0.33.0 → 0.33.2
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 +303 -145
- package/dist/client/app.d.ts +21 -0
- package/dist/client/index.d.ts +21 -0
- package/dist/client/index.js +320 -0
- package/dist/client/jsx-runtime.d.ts +60 -0
- package/dist/client/jsx-runtime.js +320 -0
- package/dist/client/router.d.ts +51 -0
- package/dist/client/signal.d.ts +19 -0
- package/dist/client/types.d.ts +45 -0
- package/dist/index.d.ts +0 -7
- package/dist/index.js +13 -925
- package/dist/types.d.ts +0 -1
- package/package.json +9 -42
- package/dist/middleware/esbuild-dev.d.ts +0 -69
- package/dist/middleware/esbuild-dev.js +0 -335
- package/dist/middleware/tailwind-dev.d.ts +0 -43
- package/dist/middleware/tailwind-dev.js +0 -199
- package/dist/react/client.d.ts +0 -76
- package/dist/react/client.js +0 -182
- package/dist/react/compile.d.ts +0 -17
- package/dist/react/context.d.ts +0 -2
- package/dist/react/error-boundary.d.ts +0 -30
- package/dist/react/hooks.d.ts +0 -6
- package/dist/react/index.d.ts +0 -92
- package/dist/react/index.js +0 -910
- package/dist/react/types.d.ts +0 -146
package/dist/react/types.d.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../types.ts';
|
|
2
|
-
declare module '../types.ts' {
|
|
3
|
-
interface Context {
|
|
4
|
-
/**
|
|
5
|
-
* Compile and render a .tsx file to HTML.
|
|
6
|
-
* The component should render a full page.
|
|
7
|
-
*/
|
|
8
|
-
render(path: string, opts?: RenderOptions): Promise<Response>;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/** Options for the react() middleware. */
|
|
12
|
-
export interface ReactOptions {
|
|
13
|
-
/**
|
|
14
|
-
* Path to a shared layout component (relative to cwd or absolute).
|
|
15
|
-
* The layout wraps every rendered page as its `children`.
|
|
16
|
-
* Layout + page are wrapped in HtmlShell for <html>/<head>/<body> structure.
|
|
17
|
-
*
|
|
18
|
-
* The layout component receives `{ children: ReactNode }`.
|
|
19
|
-
* Both layout and page can use `useServerData()`.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* // layouts/Root.tsx
|
|
24
|
-
* export default function Root({ children }: { children: ReactNode }) {
|
|
25
|
-
* const { user } = useServerData()
|
|
26
|
-
* return <><Nav user={user} /><main>{children}</main><Footer /></>
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
layout?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Directory for compiled .tsx module cache.
|
|
33
|
-
* Default: node_modules/.weifuwu/react
|
|
34
|
-
* Persisted across restarts — source changes trigger recompilation.
|
|
35
|
-
*/
|
|
36
|
-
cacheDir?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface BootstrapScriptDescriptor {
|
|
39
|
-
src: string;
|
|
40
|
-
crossOrigin?: string;
|
|
41
|
-
integrity?: string;
|
|
42
|
-
}
|
|
43
|
-
export interface RenderOptions {
|
|
44
|
-
/** Props passed directly to the page component. */
|
|
45
|
-
props?: Record<string, unknown>;
|
|
46
|
-
/** Data passed to useServerData() in the component tree. */
|
|
47
|
-
data?: Record<string, unknown>;
|
|
48
|
-
/**
|
|
49
|
-
* Async loader that runs before render.
|
|
50
|
-
* Receives ctx (with params, query) and returns data merged into useServerData().
|
|
51
|
-
* Throw HttpError for non-200 status codes.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts
|
|
55
|
-
* app.get('/users/:id', (_req, ctx) => ctx.render('./UserPage.tsx', {
|
|
56
|
-
* loader: async (ctx) => {
|
|
57
|
-
* const user = await db.findUser(ctx.params.id)
|
|
58
|
-
* if (!user) throw new HttpError('Not found', 404)
|
|
59
|
-
* return { user }
|
|
60
|
-
* },
|
|
61
|
-
* }))
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
loader?: (ctx: Context) => Promise<Record<string, unknown>>;
|
|
65
|
-
/** HTTP status code (default 200). */
|
|
66
|
-
status?: number;
|
|
67
|
-
/** Extra response headers. */
|
|
68
|
-
headers?: Record<string, string>;
|
|
69
|
-
/** Classic scripts injected by React. */
|
|
70
|
-
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
|
|
71
|
-
/** ES module scripts injected by React. */
|
|
72
|
-
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
73
|
-
/**
|
|
74
|
-
* Import map for ES module resolution.
|
|
75
|
-
* Rendered as <script type="importmap"> in <head>.
|
|
76
|
-
*/
|
|
77
|
-
importMap?: {
|
|
78
|
-
imports?: Record<string, string>;
|
|
79
|
-
};
|
|
80
|
-
/** Stylesheet URLs injected as <link rel="stylesheet"> in <head>. */
|
|
81
|
-
stylesheets?: string[];
|
|
82
|
-
/**
|
|
83
|
-
* Enable streaming SSR (default: true).
|
|
84
|
-
* When true, the response starts sending immediately and Suspense
|
|
85
|
-
* boundaries are streamed as they resolve.
|
|
86
|
-
* When false, waits for all Suspense boundaries before sending.
|
|
87
|
-
*/
|
|
88
|
-
stream?: boolean;
|
|
89
|
-
}
|
|
90
|
-
/** Options for the reactRouter() helper. */
|
|
91
|
-
export interface ReactRouterOptions extends Omit<RenderOptions, 'component' | 'loader'> {
|
|
92
|
-
/**
|
|
93
|
-
* Shared layout component path (relative to cwd).
|
|
94
|
-
* Same as react()'s layout option.
|
|
95
|
-
*/
|
|
96
|
-
layout?: string;
|
|
97
|
-
/**
|
|
98
|
-
* Per-route loaders. Keys must match paths in the routes config.
|
|
99
|
-
* Each loader receives ctx and returns data merged into useServerData().
|
|
100
|
-
* Throw HttpError for non-200 status codes.
|
|
101
|
-
*/
|
|
102
|
-
loaders?: Record<string, (ctx: Context) => Promise<Record<string, unknown>>>;
|
|
103
|
-
}
|
|
104
|
-
/** Options for createReactApp — one call to set up SSR routing + client bundle. */
|
|
105
|
-
export interface ReactAppOptions {
|
|
106
|
-
/** Page route → component path mapping for both server and client. */
|
|
107
|
-
pages: Record<string, string>;
|
|
108
|
-
/** Per-route data loaders. Keys match page route paths. */
|
|
109
|
-
loaders?: Record<string, (ctx: Context) => Promise<Record<string, unknown>>>;
|
|
110
|
-
/** Shared layout component path (relative to cwd). */
|
|
111
|
-
layout: string;
|
|
112
|
-
/** 404 fallback component path (relative to cwd). */
|
|
113
|
-
notFound?: string;
|
|
114
|
-
/** Stylesheet URLs injected in <head>. */
|
|
115
|
-
stylesheets?: string[];
|
|
116
|
-
/** ES module bootstrap scripts. */
|
|
117
|
-
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
118
|
-
/**
|
|
119
|
-
* Client bundle config.
|
|
120
|
-
* - `false` to disable client-side JS (static SSR only)
|
|
121
|
-
* - `true` or omitted for defaults
|
|
122
|
-
* - `{ ... }` to customize
|
|
123
|
-
*/
|
|
124
|
-
client?: boolean | {
|
|
125
|
-
/** URL path for the client bundle (default: '/assets/client.js'). */
|
|
126
|
-
path?: string;
|
|
127
|
-
/** Minify output (default: false). */
|
|
128
|
-
minify?: boolean;
|
|
129
|
-
/** Code splitting (default: true). */
|
|
130
|
-
splitting?: boolean;
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* Tailwind CSS config. When provided, tailwindDev middleware is set up
|
|
134
|
-
* and the output path is automatically added to stylesheets.
|
|
135
|
-
*/
|
|
136
|
-
tailwind?: {
|
|
137
|
-
/** URL path for the compiled CSS (default: '/assets/tailwind.css'). */
|
|
138
|
-
path?: string;
|
|
139
|
-
/** Source CSS entry point (default: './styles/input.css'). */
|
|
140
|
-
entry?: string;
|
|
141
|
-
};
|
|
142
|
-
/** Compilation cache directory. */
|
|
143
|
-
cacheDir?: string;
|
|
144
|
-
/** Enable streaming SSR (default: true). */
|
|
145
|
-
stream?: boolean;
|
|
146
|
-
}
|