hadars 0.1.16 → 0.1.18
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/chunk-TGSIYGY2.js +40 -0
- package/dist/cli.js +695 -165
- package/dist/index.cjs +61 -6
- package/dist/index.d.ts +40 -1
- package/dist/index.js +58 -6
- package/dist/jsx-runtime-97ca74a5.d.ts +18 -0
- package/dist/slim-react/index.cjs +874 -0
- package/dist/slim-react/index.d.ts +180 -0
- package/dist/slim-react/index.js +784 -0
- package/dist/slim-react/jsx-runtime.cjs +51 -0
- package/dist/slim-react/jsx-runtime.d.ts +1 -0
- package/dist/slim-react/jsx-runtime.js +10 -0
- package/dist/ssr-render-worker.js +619 -108
- package/dist/ssr-watch.js +37 -13
- package/dist/utils/Head.tsx +3 -6
- package/index.ts +1 -1
- package/package.json +2 -2
- package/src/build.ts +55 -49
- package/src/components/CacheSegment.tsx +67 -0
- package/src/index.tsx +2 -0
- package/src/slim-react/context.ts +52 -0
- package/src/slim-react/hooks.ts +137 -0
- package/src/slim-react/index.ts +225 -0
- package/src/slim-react/jsx-runtime.ts +7 -0
- package/src/slim-react/jsx.ts +53 -0
- package/src/slim-react/render.ts +686 -0
- package/src/slim-react/renderContext.ts +105 -0
- package/src/slim-react/types.ts +27 -0
- package/src/ssr-render-worker.ts +83 -118
- package/src/utils/Head.tsx +3 -6
- package/src/utils/response.tsx +42 -105
- package/src/utils/rspack.ts +45 -15
- package/src/utils/segmentCache.ts +87 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { S as SlimNode, a as SlimElement, c as createElement } from '../jsx-runtime-97ca74a5.js';
|
|
2
|
+
export { C as ComponentFunction, d as FRAGMENT_TYPE, F as Fragment, b as SLIM_ELEMENT, e as SUSPENSE_TYPE, j as jsx, j as jsxDEV, j as jsxs } from '../jsx-runtime-97ca74a5.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SSR hook implementations.
|
|
6
|
+
*
|
|
7
|
+
* On the server every hook is either a no-op or returns the initial /
|
|
8
|
+
* snapshot value. This is enough for the vast majority of React-
|
|
9
|
+
* compatible libraries to work during server-side rendering.
|
|
10
|
+
*/
|
|
11
|
+
declare function useState<T>(initialState: T | (() => T)): [T, (value: T | ((prev: T) => T)) => void];
|
|
12
|
+
declare function useReducer<S, A>(_reducer: (state: S, action: A) => S, initialState: S): [S, (action: A) => void];
|
|
13
|
+
declare function useEffect(_effect: () => void | (() => void), _deps?: any[]): void;
|
|
14
|
+
declare function useLayoutEffect(_effect: () => void | (() => void), _deps?: any[]): void;
|
|
15
|
+
declare function useInsertionEffect(_effect: () => void | (() => void), _deps?: any[]): void;
|
|
16
|
+
declare function useRef<T>(initialValue: T): {
|
|
17
|
+
current: T;
|
|
18
|
+
};
|
|
19
|
+
declare function useMemo<T>(factory: () => T, _deps?: any[]): T;
|
|
20
|
+
declare function useCallback<T extends Function>(callback: T, _deps?: any[]): T;
|
|
21
|
+
declare function useId(): string;
|
|
22
|
+
declare function useDebugValue(_value: any, _format?: (v: any) => any): void;
|
|
23
|
+
declare function useImperativeHandle(_ref: any, _createHandle: () => any, _deps?: any[]): void;
|
|
24
|
+
declare function useSyncExternalStore<T>(_subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T): T;
|
|
25
|
+
declare function useTransition(): [boolean, (callback: () => void) => void];
|
|
26
|
+
declare function useDeferredValue<T>(value: T): T;
|
|
27
|
+
declare function useOptimistic<T>(passthrough: T): [T, () => void];
|
|
28
|
+
declare function useFormStatus(): {
|
|
29
|
+
pending: boolean;
|
|
30
|
+
data: null;
|
|
31
|
+
method: null;
|
|
32
|
+
action: null;
|
|
33
|
+
};
|
|
34
|
+
declare function useActionState<S>(_action: (state: S, payload: any) => S | Promise<S>, initialState: S, _permalink?: string): [S, (payload: any) => void, boolean];
|
|
35
|
+
declare function use<T>(usable: (Promise<T> & {
|
|
36
|
+
status?: string;
|
|
37
|
+
value?: T;
|
|
38
|
+
reason?: any;
|
|
39
|
+
}) | {
|
|
40
|
+
_currentValue: T;
|
|
41
|
+
}): T;
|
|
42
|
+
declare function startTransition(callback: () => void): void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Minimal Context implementation for SSR.
|
|
46
|
+
*
|
|
47
|
+
* Because SSR is single-pass and synchronous within each component,
|
|
48
|
+
* we just track the "current" value on the context object and
|
|
49
|
+
* save / restore around Provider renders (handled by the renderer).
|
|
50
|
+
*/
|
|
51
|
+
interface Context<T> {
|
|
52
|
+
_currentValue: T;
|
|
53
|
+
Provider: ContextProvider<T>;
|
|
54
|
+
Consumer: (props: {
|
|
55
|
+
children: (value: T) => SlimNode;
|
|
56
|
+
}) => SlimNode;
|
|
57
|
+
}
|
|
58
|
+
type ContextProvider<T> = ((props: {
|
|
59
|
+
value: T;
|
|
60
|
+
children?: SlimNode;
|
|
61
|
+
}) => SlimNode) & {
|
|
62
|
+
_context: Context<T>;
|
|
63
|
+
};
|
|
64
|
+
declare function createContext<T>(defaultValue: T): Context<T>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Streaming SSR renderer with Suspense support.
|
|
68
|
+
*
|
|
69
|
+
* `renderToStream` walks the virtual-node tree produced by jsx() /
|
|
70
|
+
* createElement() and writes HTML chunks into a ReadableStream.
|
|
71
|
+
*
|
|
72
|
+
* When it meets a <Suspense> boundary it:
|
|
73
|
+
* 1. Tries to render the children into a temporary buffer.
|
|
74
|
+
* 2. If a child throws a Promise (React Suspense protocol) it
|
|
75
|
+
* awaits the promise, then retries from step 1.
|
|
76
|
+
* 3. Once successful, the buffer is flushed to the real stream.
|
|
77
|
+
*
|
|
78
|
+
* The net effect is that the stream **pauses** at Suspense boundaries
|
|
79
|
+
* until the async data is ready, then continues – exactly as requested.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Render a component tree to a `ReadableStream<Uint8Array>`.
|
|
84
|
+
*
|
|
85
|
+
* The stream pauses at `<Suspense>` boundaries until the suspended
|
|
86
|
+
* promise resolves, then continues writing HTML.
|
|
87
|
+
*/
|
|
88
|
+
declare function renderToStream(element: SlimNode): ReadableStream<Uint8Array>;
|
|
89
|
+
/**
|
|
90
|
+
* Convenience: render to a complete HTML string.
|
|
91
|
+
* Retries the full tree when a component throws a Promise (Suspense protocol),
|
|
92
|
+
* so useServerData and similar hooks work without requiring explicit <Suspense>.
|
|
93
|
+
*/
|
|
94
|
+
declare function renderToString(element: SlimNode): Promise<string>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* slim-react – a lightweight, SSR-only React-compatible runtime.
|
|
98
|
+
*
|
|
99
|
+
* Provides just enough of the React API surface to server-render
|
|
100
|
+
* components that use hooks, Context and Suspense.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
declare function useContext<T>(context: Context<T>): T;
|
|
104
|
+
|
|
105
|
+
declare const Suspense: symbol;
|
|
106
|
+
|
|
107
|
+
declare function isValidElement(obj: unknown): obj is SlimElement;
|
|
108
|
+
declare function cloneElement(element: SlimElement, overrideProps?: Record<string, any>, ...children: SlimNode[]): SlimElement;
|
|
109
|
+
declare function forwardRef<P = any>(render: (props: P, ref: any) => SlimNode): (props: P & {
|
|
110
|
+
ref?: any;
|
|
111
|
+
}) => SlimNode;
|
|
112
|
+
declare function memo<P = any>(component: (props: P) => SlimNode): (props: P) => SlimNode;
|
|
113
|
+
declare function lazy<P = any>(factory: () => Promise<{
|
|
114
|
+
default: (props: P) => SlimNode;
|
|
115
|
+
}>): (props: P) => SlimNode;
|
|
116
|
+
declare function toFlatArray(children: SlimNode): SlimNode[];
|
|
117
|
+
declare const Children: {
|
|
118
|
+
map(children: SlimNode, fn: (child: SlimNode, index: number) => SlimNode): SlimNode[];
|
|
119
|
+
forEach(children: SlimNode, fn: (child: SlimNode, index: number) => void): void;
|
|
120
|
+
count(children: SlimNode): number;
|
|
121
|
+
only(children: SlimNode): SlimElement;
|
|
122
|
+
toArray: typeof toFlatArray;
|
|
123
|
+
};
|
|
124
|
+
declare class Component<P = {}, S = {}> {
|
|
125
|
+
props: P;
|
|
126
|
+
state: S;
|
|
127
|
+
context: any;
|
|
128
|
+
constructor(props: P);
|
|
129
|
+
setState(_partial: Partial<S> | ((prev: S) => Partial<S>)): void;
|
|
130
|
+
forceUpdate(): void;
|
|
131
|
+
render(): SlimNode;
|
|
132
|
+
}
|
|
133
|
+
declare class PureComponent<P = {}, S = {}> extends Component<P, S> {
|
|
134
|
+
}
|
|
135
|
+
declare const React: {
|
|
136
|
+
useState: typeof useState;
|
|
137
|
+
useReducer: typeof useReducer;
|
|
138
|
+
useEffect: typeof useEffect;
|
|
139
|
+
useLayoutEffect: typeof useLayoutEffect;
|
|
140
|
+
useInsertionEffect: typeof useInsertionEffect;
|
|
141
|
+
useRef: typeof useRef;
|
|
142
|
+
useMemo: typeof useMemo;
|
|
143
|
+
useCallback: typeof useCallback;
|
|
144
|
+
useId: typeof useId;
|
|
145
|
+
useDebugValue: typeof useDebugValue;
|
|
146
|
+
useImperativeHandle: typeof useImperativeHandle;
|
|
147
|
+
useSyncExternalStore: typeof useSyncExternalStore;
|
|
148
|
+
useTransition: typeof useTransition;
|
|
149
|
+
useDeferredValue: typeof useDeferredValue;
|
|
150
|
+
useOptimistic: typeof useOptimistic;
|
|
151
|
+
useFormStatus: typeof useFormStatus;
|
|
152
|
+
useActionState: typeof useActionState;
|
|
153
|
+
use: typeof use;
|
|
154
|
+
startTransition: typeof startTransition;
|
|
155
|
+
createContext: typeof createContext;
|
|
156
|
+
useContext: typeof useContext;
|
|
157
|
+
createElement: typeof createElement;
|
|
158
|
+
cloneElement: typeof cloneElement;
|
|
159
|
+
isValidElement: typeof isValidElement;
|
|
160
|
+
forwardRef: typeof forwardRef;
|
|
161
|
+
memo: typeof memo;
|
|
162
|
+
lazy: typeof lazy;
|
|
163
|
+
Fragment: symbol;
|
|
164
|
+
Suspense: symbol;
|
|
165
|
+
Children: {
|
|
166
|
+
map(children: SlimNode, fn: (child: SlimNode, index: number) => SlimNode): SlimNode[];
|
|
167
|
+
forEach(children: SlimNode, fn: (child: SlimNode, index: number) => void): void;
|
|
168
|
+
count(children: SlimNode): number;
|
|
169
|
+
only(children: SlimNode): SlimElement;
|
|
170
|
+
toArray: typeof toFlatArray;
|
|
171
|
+
};
|
|
172
|
+
Component: typeof Component;
|
|
173
|
+
PureComponent: typeof PureComponent;
|
|
174
|
+
renderToStream: typeof renderToStream;
|
|
175
|
+
renderToString: typeof renderToString;
|
|
176
|
+
renderToReadableStream: typeof renderToStream;
|
|
177
|
+
version: string;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export { Children, Component, Context, PureComponent, SlimElement, SlimNode, Suspense, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderToStream as renderToReadableStream, renderToStream, renderToString, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useFormStatus, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition };
|