hadars 0.4.1 → 0.4.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.
Files changed (58) hide show
  1. package/dist/{chunk-TV37IMRB.js → chunk-2TMQUXFL.js} +10 -10
  2. package/dist/{chunk-2J2L2H3H.js → chunk-NYLXE7T7.js} +6 -6
  3. package/dist/{chunk-OS3V4CPN.js → chunk-OZUZS2PD.js} +4 -4
  4. package/dist/cli.js +462 -496
  5. package/dist/cloudflare.cjs +11 -11
  6. package/dist/cloudflare.js +3 -3
  7. package/dist/index.d.cts +8 -4
  8. package/dist/index.d.ts +8 -4
  9. package/dist/lambda.cjs +11 -11
  10. package/dist/lambda.js +7 -7
  11. package/dist/loader.cjs +90 -54
  12. package/dist/slim-react/index.cjs +13 -13
  13. package/dist/slim-react/index.js +2 -2
  14. package/dist/slim-react/jsx-runtime.cjs +2 -4
  15. package/dist/slim-react/jsx-runtime.js +1 -1
  16. package/dist/ssr-render-worker.js +174 -161
  17. package/dist/ssr-watch.js +40 -74
  18. package/package.json +8 -10
  19. package/cli-lib.ts +0 -676
  20. package/cli.ts +0 -36
  21. package/index.ts +0 -17
  22. package/src/build.ts +0 -805
  23. package/src/cloudflare.ts +0 -140
  24. package/src/index.tsx +0 -41
  25. package/src/lambda.ts +0 -287
  26. package/src/slim-react/context.ts +0 -55
  27. package/src/slim-react/dispatcher.ts +0 -87
  28. package/src/slim-react/hooks.ts +0 -137
  29. package/src/slim-react/index.ts +0 -232
  30. package/src/slim-react/jsx-runtime.ts +0 -7
  31. package/src/slim-react/jsx.ts +0 -53
  32. package/src/slim-react/render.ts +0 -1101
  33. package/src/slim-react/renderContext.ts +0 -294
  34. package/src/slim-react/types.ts +0 -33
  35. package/src/source/context.ts +0 -113
  36. package/src/source/graphiql.ts +0 -101
  37. package/src/source/inference.ts +0 -260
  38. package/src/source/runner.ts +0 -138
  39. package/src/source/store.ts +0 -50
  40. package/src/ssr-render-worker.ts +0 -116
  41. package/src/ssr-watch.ts +0 -62
  42. package/src/static.ts +0 -109
  43. package/src/types/global.d.ts +0 -5
  44. package/src/types/hadars.ts +0 -350
  45. package/src/utils/Head.tsx +0 -462
  46. package/src/utils/clientScript.tsx +0 -71
  47. package/src/utils/cookies.ts +0 -16
  48. package/src/utils/loader.ts +0 -335
  49. package/src/utils/proxyHandler.tsx +0 -104
  50. package/src/utils/request.tsx +0 -9
  51. package/src/utils/response.tsx +0 -141
  52. package/src/utils/rspack.ts +0 -467
  53. package/src/utils/runtime.ts +0 -19
  54. package/src/utils/serve.ts +0 -155
  55. package/src/utils/ssrHandler.ts +0 -239
  56. package/src/utils/staticFile.ts +0 -43
  57. package/src/utils/template.html +0 -11
  58. package/src/utils/upgradeRequest.tsx +0 -19
@@ -1,137 +0,0 @@
1
- /**
2
- * SSR hook implementations.
3
- *
4
- * On the server every hook is either a no-op or returns the initial /
5
- * snapshot value. This is enough for the vast majority of React-
6
- * compatible libraries to work during server-side rendering.
7
- */
8
-
9
- import { makeId, getContextValue } from "./renderContext";
10
-
11
- // ---- useState ----
12
- export function useState<T>(
13
- initialState: T | (() => T),
14
- ): [T, (value: T | ((prev: T) => T)) => void] {
15
- const value =
16
- typeof initialState === "function"
17
- ? (initialState as () => T)()
18
- : initialState;
19
- return [value, () => {}];
20
- }
21
-
22
- // ---- useReducer ----
23
- export function useReducer<S, A>(
24
- _reducer: (state: S, action: A) => S,
25
- initialState: S,
26
- ): [S, (action: A) => void] {
27
- return [initialState, () => {}];
28
- }
29
-
30
- // ---- useEffect / useLayoutEffect / useInsertionEffect ----
31
- export function useEffect(
32
- _effect: () => void | (() => void),
33
- _deps?: any[],
34
- ) {}
35
- export function useLayoutEffect(
36
- _effect: () => void | (() => void),
37
- _deps?: any[],
38
- ) {}
39
- export function useInsertionEffect(
40
- _effect: () => void | (() => void),
41
- _deps?: any[],
42
- ) {}
43
-
44
- // ---- useRef ----
45
- export function useRef<T>(initialValue: T): { current: T } {
46
- return { current: initialValue };
47
- }
48
-
49
- // ---- useMemo / useCallback ----
50
- export function useMemo<T>(factory: () => T, _deps?: any[]): T {
51
- return factory();
52
- }
53
- export function useCallback<T extends Function>(callback: T, _deps?: any[]): T {
54
- return callback;
55
- }
56
-
57
- // ---- useId ----
58
- export function useId(): string {
59
- return makeId();
60
- }
61
-
62
- // ---- useDebugValue ----
63
- export function useDebugValue(_value: any, _format?: (v: any) => any) {}
64
-
65
- // ---- useImperativeHandle ----
66
- export function useImperativeHandle(
67
- _ref: any,
68
- _createHandle: () => any,
69
- _deps?: any[],
70
- ) {}
71
-
72
- // ---- useSyncExternalStore ----
73
- export function useSyncExternalStore<T>(
74
- _subscribe: (onStoreChange: () => void) => () => void,
75
- getSnapshot: () => T,
76
- getServerSnapshot?: () => T,
77
- ): T {
78
- return (getServerSnapshot || getSnapshot)();
79
- }
80
-
81
- // ---- useTransition ----
82
- export function useTransition(): [boolean, (callback: () => void) => void] {
83
- return [false, (cb) => cb()];
84
- }
85
-
86
- // ---- useDeferredValue ----
87
- export function useDeferredValue<T>(value: T): T {
88
- return value;
89
- }
90
-
91
- // ---- useOptimistic (React 19) ----
92
- export function useOptimistic<T>(passthrough: T): [T, () => void] {
93
- return [passthrough, () => {}];
94
- }
95
-
96
- // ---- useFormStatus (React 19) ----
97
- export function useFormStatus() {
98
- return { pending: false, data: null, method: null, action: null };
99
- }
100
-
101
- // ---- useActionState (React 19) ----
102
- export function useActionState<S>(
103
- _action: (state: S, payload: any) => S | Promise<S>,
104
- initialState: S,
105
- _permalink?: string,
106
- ): [S, (payload: any) => void, boolean] {
107
- return [initialState, () => {}, false];
108
- }
109
-
110
- // ---- use (React 19 – Suspense integration) ----
111
- export function use<T>(
112
- usable: (Promise<T> & { status?: string; value?: T; reason?: any }) | { _currentValue: T },
113
- ): T {
114
- // Context object
115
- if (
116
- typeof usable === "object" &&
117
- usable !== null &&
118
- ("_currentValue" in usable || "_defaultValue" in usable)
119
- ) {
120
- return getContextValue<T>(usable as object);
121
- }
122
-
123
- // Promise – Suspense protocol
124
- const promise = usable as Promise<T> & {
125
- status?: string;
126
- value?: T;
127
- reason?: any;
128
- };
129
- if (promise.status === "fulfilled") return promise.value!;
130
- if (promise.status === "rejected") throw promise.reason;
131
- throw promise; // caught by the nearest Suspense boundary
132
- }
133
-
134
- // ---- startTransition ----
135
- export function startTransition(callback: () => void) {
136
- callback();
137
- }
@@ -1,232 +0,0 @@
1
- /**
2
- * slim-react – a lightweight, SSR-only React-compatible runtime.
3
- *
4
- * Provides just enough of the React API surface to server-render
5
- * components that use hooks, Context and Suspense.
6
- */
7
-
8
- // ---- Symbols & types ----
9
- export {
10
- SLIM_ELEMENT,
11
- FRAGMENT_TYPE,
12
- SUSPENSE_TYPE,
13
- type SlimElement,
14
- type SlimNode,
15
- type ComponentFunction,
16
- } from "./types";
17
-
18
- // ---- JSX runtime ----
19
- import { jsx, jsxs, jsxDEV, createElement, Fragment } from "./jsx";
20
- export { jsx, jsxs, jsxDEV, createElement, Fragment };
21
-
22
- // ---- Hooks (SSR stubs) ----
23
- import {
24
- useState,
25
- useReducer,
26
- useEffect,
27
- useLayoutEffect,
28
- useInsertionEffect,
29
- useRef,
30
- useMemo,
31
- useCallback,
32
- useId,
33
- useDebugValue,
34
- useImperativeHandle,
35
- useSyncExternalStore,
36
- useTransition,
37
- useDeferredValue,
38
- useOptimistic,
39
- useFormStatus,
40
- useActionState,
41
- use,
42
- startTransition,
43
- } from "./hooks";
44
- export {
45
- useState,
46
- useReducer,
47
- useEffect,
48
- useLayoutEffect,
49
- useInsertionEffect,
50
- useRef,
51
- useMemo,
52
- useCallback,
53
- useId,
54
- useDebugValue,
55
- useImperativeHandle,
56
- useSyncExternalStore,
57
- useTransition,
58
- useDeferredValue,
59
- useOptimistic,
60
- useFormStatus,
61
- useActionState,
62
- use,
63
- startTransition,
64
- };
65
-
66
- // ---- Context ----
67
- import { createContext } from "./context";
68
- export { createContext, type Context } from "./context";
69
-
70
- import { getContextValue } from "./renderContext";
71
- import type { Context } from "./context";
72
- export function useContext<T>(context: Context<T>): T {
73
- return getContextValue<T>(context);
74
- }
75
-
76
- // ---- Rendering ----
77
- import { renderToStream, renderToString, renderToReadableStream, renderPreflight } from "./render";
78
- export { renderToStream, renderToString, renderToReadableStream, renderPreflight, type RenderOptions } from "./render";
79
-
80
- // ---- Suspense (as a JSX tag) ----
81
- import { SUSPENSE_TYPE } from "./types";
82
- export const Suspense = SUSPENSE_TYPE;
83
-
84
- // ---- Compat utilities ----
85
- import { SLIM_ELEMENT, REACT19_ELEMENT, type SlimElement, type SlimNode } from "./types";
86
-
87
- export function isValidElement(obj: unknown): obj is SlimElement {
88
- if (typeof obj !== "object" || obj === null) return false;
89
- const t = (obj as any).$$typeof;
90
- return t === SLIM_ELEMENT || t === REACT19_ELEMENT;
91
- }
92
-
93
- export function cloneElement(
94
- element: SlimElement,
95
- overrideProps?: Record<string, any>,
96
- ...children: SlimNode[]
97
- ): SlimElement {
98
- return {
99
- $$typeof: (element as any).$$typeof || SLIM_ELEMENT,
100
- type: element.type,
101
- props: {
102
- ...element.props,
103
- ...overrideProps,
104
- ...(children.length === 1
105
- ? { children: children[0] }
106
- : children.length > 1
107
- ? { children }
108
- : {}),
109
- },
110
- key: overrideProps?.key ?? element.key,
111
- };
112
- }
113
-
114
- export function forwardRef<P = any>(
115
- render: (props: P, ref: any) => SlimNode,
116
- ): any {
117
- return {
118
- $$typeof: Symbol.for("react.forward_ref"),
119
- render,
120
- displayName: (render as any).displayName || (render as any).name || "ForwardRef",
121
- };
122
- }
123
-
124
- export function memo<P = any>(
125
- component: (props: P) => SlimNode,
126
- compare?: (prevProps: P, nextProps: P) => boolean,
127
- ): any {
128
- return {
129
- $$typeof: Symbol.for("react.memo"),
130
- type: component,
131
- compare: compare ?? null,
132
- };
133
- }
134
-
135
- export function lazy<P = any>(
136
- factory: () => Promise<{ default: (props: P) => SlimNode }>,
137
- ): (props: P) => SlimNode {
138
- let resolved: ((props: P) => SlimNode) | null = null;
139
- let promise: Promise<void> | null = null;
140
-
141
- return function LazyComponent(props: P): SlimNode {
142
- if (resolved) return resolved(props);
143
- if (!promise) {
144
- promise = factory().then((mod) => {
145
- resolved = mod.default;
146
- });
147
- }
148
- throw promise; // Suspense protocol
149
- };
150
- }
151
-
152
- // ---- Children helpers ----
153
- function toFlatArray(children: SlimNode): SlimNode[] {
154
- if (children == null || typeof children === "boolean") return [];
155
- if (Array.isArray(children)) return children.flatMap(toFlatArray);
156
- return [children];
157
- }
158
-
159
- export const Children = {
160
- map(
161
- children: SlimNode,
162
- fn: (child: SlimNode, index: number) => SlimNode,
163
- ): SlimNode[] {
164
- return toFlatArray(children).map((child, i) => fn(child, i));
165
- },
166
- forEach(
167
- children: SlimNode,
168
- fn: (child: SlimNode, index: number) => void,
169
- ): void {
170
- toFlatArray(children).forEach((child, i) => fn(child, i));
171
- },
172
- count(children: SlimNode): number {
173
- return toFlatArray(children).length;
174
- },
175
- only(children: SlimNode): SlimElement {
176
- const arr = toFlatArray(children);
177
- if (arr.length !== 1) throw new Error("Children.only expected one child");
178
- return arr[0] as SlimElement;
179
- },
180
- toArray: toFlatArray,
181
- };
182
-
183
- // ---- React.Component (basic class component support) ----
184
- export class Component<P = {}, S = {}> {
185
- props: P;
186
- state: S;
187
- context: any;
188
-
189
- constructor(props: P) {
190
- this.props = props;
191
- this.state = {} as S;
192
- }
193
-
194
- setState(_partial: Partial<S> | ((prev: S) => Partial<S>)) {}
195
- forceUpdate() {}
196
- render(): SlimNode {
197
- return null;
198
- }
199
- }
200
-
201
- export class PureComponent<P = {}, S = {}> extends Component<P, S> {}
202
-
203
- // ---- Version ----
204
- // Exported as a named export so that namespace imports (`import * as React`)
205
- // — as used by react-redux and other libraries that check React.version —
206
- // find it on the module namespace rather than only on the default export.
207
- export const version = "19.1.1";
208
-
209
- // ---- Default export ----
210
- // Mirrors `import React from 'react'` so code that uses React.useState,
211
- // React.createContext, React.Suspense, etc. works without changes.
212
- // All names here are already imported/defined above — no re-imports needed.
213
- const React = {
214
- // Hooks
215
- useState, useReducer, useEffect, useLayoutEffect, useInsertionEffect,
216
- useRef, useMemo, useCallback, useId, useDebugValue, useImperativeHandle,
217
- useSyncExternalStore, useTransition, useDeferredValue,
218
- useOptimistic, useFormStatus, useActionState, use, startTransition,
219
- // Context
220
- createContext, useContext,
221
- // Elements
222
- createElement, cloneElement, isValidElement, forwardRef, memo, lazy,
223
- Fragment, Suspense,
224
- // Compat
225
- Children, Component, PureComponent,
226
- // Rendering
227
- renderToStream, renderToString, renderToReadableStream, renderPreflight,
228
- // Version
229
- version,
230
- };
231
-
232
- export default React;
@@ -1,7 +0,0 @@
1
- /**
2
- * JSX automatic-transform runtime for slim-react.
3
- *
4
- * Aliased from `react/jsx-runtime` in SSR rspack builds so that the
5
- * automatic JSX transform produces slim-react elements instead of React ones.
6
- */
7
- export { jsx, jsxs, jsxDEV, Fragment } from "./jsx";
@@ -1,53 +0,0 @@
1
- import {
2
- SLIM_ELEMENT,
3
- FRAGMENT_TYPE,
4
- type SlimElement,
5
- type SlimNode,
6
- type ComponentFunction,
7
- } from "./types";
8
-
9
- // ---- Fragment ----
10
- export const Fragment = FRAGMENT_TYPE;
11
-
12
- // ---- jsx / jsxs (automatic transform) ----
13
- // The automatic JSX transform calls jsx(type, props, key?)
14
- // where props already contains `children`.
15
- export function jsx(
16
- type: string | ComponentFunction | symbol,
17
- props: Record<string, any>,
18
- key?: string | number | null,
19
- ): SlimElement {
20
- return {
21
- $$typeof: SLIM_ELEMENT,
22
- type,
23
- props: props || {},
24
- key: key ?? (props?.key ?? null),
25
- };
26
- }
27
-
28
- export { jsx as jsxs, jsx as jsxDEV };
29
-
30
- // ---- createElement (classic transform) ----
31
- export function createElement(
32
- type: string | ComponentFunction | symbol,
33
- props?: Record<string, any> | null,
34
- ...children: SlimNode[]
35
- ): SlimElement {
36
- const normalizedProps: Record<string, any> = { ...(props || {}) };
37
-
38
- if (children.length === 1) {
39
- normalizedProps.children = children[0];
40
- } else if (children.length > 1) {
41
- normalizedProps.children = children;
42
- }
43
-
44
- const key = normalizedProps.key ?? null;
45
- delete normalizedProps.key;
46
-
47
- return {
48
- $$typeof: SLIM_ELEMENT,
49
- type,
50
- props: normalizedProps,
51
- key,
52
- };
53
- }