hadars 0.4.2 → 0.4.3-rc.0
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 +53 -14
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-2TMQUXFL.js → chunk-BNBZ3XYX.js} +78 -18
- package/dist/{chunk-NYLXE7T7.js → chunk-YCCTGINV.js} +1 -1
- package/dist/cli.js +330 -226
- package/dist/cloudflare.cjs +83 -34
- package/dist/cloudflare.js +3 -2
- package/dist/index.js +2 -0
- package/dist/lambda.cjs +83 -34
- package/dist/lambda.js +3 -2
- package/dist/slim-react/index.cjs +103 -45
- package/dist/slim-react/index.d.cts +24 -2
- package/dist/slim-react/index.d.ts +24 -2
- package/dist/slim-react/index.js +4 -1
- package/dist/slim-react/jsx-runtime.js +1 -0
- package/dist/ssr-render-worker.js +86 -37
- package/package.json +3 -3
|
@@ -156,7 +156,18 @@ declare class Component<P = {}, S = {}> {
|
|
|
156
156
|
}
|
|
157
157
|
declare class PureComponent<P = {}, S = {}> extends Component<P, S> {
|
|
158
158
|
}
|
|
159
|
-
declare const version
|
|
159
|
+
declare const version: string;
|
|
160
|
+
declare const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
|
|
161
|
+
ReactCurrentDispatcher: {
|
|
162
|
+
current: unknown;
|
|
163
|
+
};
|
|
164
|
+
ReactCurrentBatchConfig: {
|
|
165
|
+
transition: unknown;
|
|
166
|
+
};
|
|
167
|
+
ReactCurrentOwner: {
|
|
168
|
+
current: unknown;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
160
171
|
declare const React: {
|
|
161
172
|
useState: typeof useState;
|
|
162
173
|
useReducer: typeof useReducer;
|
|
@@ -201,6 +212,17 @@ declare const React: {
|
|
|
201
212
|
renderToReadableStream: typeof renderToStream;
|
|
202
213
|
renderPreflight: typeof renderPreflight;
|
|
203
214
|
version: string;
|
|
215
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
|
|
216
|
+
ReactCurrentDispatcher: {
|
|
217
|
+
current: unknown;
|
|
218
|
+
};
|
|
219
|
+
ReactCurrentBatchConfig: {
|
|
220
|
+
transition: unknown;
|
|
221
|
+
};
|
|
222
|
+
ReactCurrentOwner: {
|
|
223
|
+
current: unknown;
|
|
224
|
+
};
|
|
225
|
+
};
|
|
204
226
|
};
|
|
205
227
|
|
|
206
|
-
export { Children, Component, type Context, PureComponent, type RenderOptions, SlimElement, SlimNode, Suspense, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderPreflight, 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, version };
|
|
228
|
+
export { Children, Component, type Context, PureComponent, type RenderOptions, SlimElement, SlimNode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderPreflight, 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, version };
|
package/dist/slim-react/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
Component,
|
|
4
4
|
PureComponent,
|
|
5
5
|
Suspense,
|
|
6
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
6
7
|
cloneElement,
|
|
7
8
|
createContext,
|
|
8
9
|
forwardRef,
|
|
@@ -34,7 +35,7 @@ import {
|
|
|
34
35
|
useSyncExternalStore,
|
|
35
36
|
useTransition,
|
|
36
37
|
version
|
|
37
|
-
} from "../chunk-
|
|
38
|
+
} from "../chunk-BNBZ3XYX.js";
|
|
38
39
|
import {
|
|
39
40
|
FRAGMENT_TYPE,
|
|
40
41
|
Fragment,
|
|
@@ -43,6 +44,7 @@ import {
|
|
|
43
44
|
createElement,
|
|
44
45
|
jsx
|
|
45
46
|
} from "../chunk-OZUZS2PD.js";
|
|
47
|
+
import "../chunk-3RG5ZIWI.js";
|
|
46
48
|
export {
|
|
47
49
|
Children,
|
|
48
50
|
Component,
|
|
@@ -52,6 +54,7 @@ export {
|
|
|
52
54
|
SLIM_ELEMENT,
|
|
53
55
|
SUSPENSE_TYPE,
|
|
54
56
|
Suspense,
|
|
57
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
55
58
|
cloneElement,
|
|
56
59
|
createContext,
|
|
57
60
|
createElement,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
1
4
|
// src/ssr-render-worker.ts
|
|
2
5
|
import { workerData, parentPort } from "node:worker_threads";
|
|
3
6
|
import { pathToFileURL } from "node:url";
|
|
@@ -7,25 +10,8 @@ var SLIM_ELEMENT = Symbol.for("react.element");
|
|
|
7
10
|
var REACT19_ELEMENT = Symbol.for("react.transitional.element");
|
|
8
11
|
var FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
9
12
|
var SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
10
|
-
// src/slim-react/jsx.ts
|
|
11
|
-
function createElement(type, props, ...children) {
|
|
12
|
-
const normalizedProps = { ...props || {} };
|
|
13
|
-
if (children.length === 1) {
|
|
14
|
-
normalizedProps.children = children[0];
|
|
15
|
-
} else if (children.length > 1) {
|
|
16
|
-
normalizedProps.children = children;
|
|
17
|
-
}
|
|
18
|
-
const key = normalizedProps.key ?? null;
|
|
19
|
-
delete normalizedProps.key;
|
|
20
|
-
return {
|
|
21
|
-
$$typeof: SLIM_ELEMENT,
|
|
22
|
-
type,
|
|
23
|
-
props: normalizedProps,
|
|
24
|
-
key
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
13
|
// src/slim-react/renderContext.ts
|
|
14
|
+
import { createRequire as _nodeCreateRequire } from "node:module";
|
|
29
15
|
var MAP_KEY = "__slimReactContextMap";
|
|
30
16
|
var _g = globalThis;
|
|
31
17
|
if (!("__slimReactContextMap" in _g))
|
|
@@ -49,8 +35,7 @@ function getContextValue(context) {
|
|
|
49
35
|
const map = _g[MAP_KEY];
|
|
50
36
|
if (map && map.has(context))
|
|
51
37
|
return map.get(context);
|
|
52
|
-
|
|
53
|
-
return "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
38
|
+
return context._currentValue;
|
|
54
39
|
}
|
|
55
40
|
function pushContextValue(context, value) {
|
|
56
41
|
let map = _g[MAP_KEY];
|
|
@@ -58,8 +43,7 @@ function pushContextValue(context, value) {
|
|
|
58
43
|
map = new Map;
|
|
59
44
|
_g[MAP_KEY] = map;
|
|
60
45
|
}
|
|
61
|
-
const
|
|
62
|
-
const prev = map.has(context) ? map.get(context) : ("_defaultValue" in c) ? c._defaultValue : c._currentValue;
|
|
46
|
+
const prev = map.has(context) ? map.get(context) : context._currentValue;
|
|
63
47
|
map.set(context, value);
|
|
64
48
|
return prev;
|
|
65
49
|
}
|
|
@@ -164,14 +148,54 @@ function getTreeId() {
|
|
|
164
148
|
const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
|
|
165
149
|
return stripped + overflow;
|
|
166
150
|
}
|
|
151
|
+
var _detectReact = () => {
|
|
152
|
+
if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
|
|
153
|
+
const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
|
|
154
|
+
return {
|
|
155
|
+
major,
|
|
156
|
+
version: major < 19 ? "18.3.1" : "19.1.1"
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
|
|
160
|
+
try {
|
|
161
|
+
return parse(__require("react").version);
|
|
162
|
+
} catch {}
|
|
163
|
+
try {
|
|
164
|
+
const req = _nodeCreateRequire(process.cwd() + "/__hadars__.js");
|
|
165
|
+
return parse(req("react").version);
|
|
166
|
+
} catch {}
|
|
167
|
+
return { major: 19, version: "19.1.1" };
|
|
168
|
+
};
|
|
169
|
+
var _react = _detectReact();
|
|
170
|
+
var REACT_MAJOR = _react.major;
|
|
171
|
+
var REACT_VERSION = _react.version;
|
|
167
172
|
function makeId() {
|
|
168
173
|
const st = s();
|
|
169
174
|
const treeId = getTreeId();
|
|
170
175
|
const n = st.localIdCounter++;
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
const suffix = n > 0 ? "H" + n.toString(32) : "";
|
|
177
|
+
if (REACT_MAJOR < 19) {
|
|
178
|
+
return ":" + st.idPrefix + "R" + treeId + suffix + ":";
|
|
179
|
+
}
|
|
180
|
+
return "_R_" + st.idPrefix + treeId + suffix + "_";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// src/slim-react/jsx.ts
|
|
184
|
+
function createElement(type, props, ...children) {
|
|
185
|
+
const normalizedProps = { ...props || {} };
|
|
186
|
+
if (children.length === 1) {
|
|
187
|
+
normalizedProps.children = children[0];
|
|
188
|
+
} else if (children.length > 1) {
|
|
189
|
+
normalizedProps.children = children;
|
|
190
|
+
}
|
|
191
|
+
const key = normalizedProps.key ?? null;
|
|
192
|
+
delete normalizedProps.key;
|
|
193
|
+
return {
|
|
194
|
+
$$typeof: SLIM_ELEMENT,
|
|
195
|
+
type,
|
|
196
|
+
props: normalizedProps,
|
|
197
|
+
key
|
|
198
|
+
};
|
|
175
199
|
}
|
|
176
200
|
|
|
177
201
|
// src/slim-react/hooks.ts
|
|
@@ -224,8 +248,22 @@ function use(usable) {
|
|
|
224
248
|
}
|
|
225
249
|
// src/slim-react/dispatcher.ts
|
|
226
250
|
import * as ReactNS from "react";
|
|
227
|
-
var
|
|
228
|
-
var
|
|
251
|
+
var _r19;
|
|
252
|
+
var _r18;
|
|
253
|
+
var _detected = false;
|
|
254
|
+
function _detect() {
|
|
255
|
+
if (_detected)
|
|
256
|
+
return;
|
|
257
|
+
_detected = true;
|
|
258
|
+
const r19 = ReactNS.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
259
|
+
if (r19) {
|
|
260
|
+
_r19 = r19;
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const raw = ReactNS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
264
|
+
if (raw?.ReactCurrentDispatcher)
|
|
265
|
+
_r18 = raw;
|
|
266
|
+
}
|
|
229
267
|
var slimDispatcher = {
|
|
230
268
|
useId: makeId,
|
|
231
269
|
readContext: (ctx) => getContextValue(ctx),
|
|
@@ -251,15 +289,25 @@ var slimDispatcher = {
|
|
|
251
289
|
useHostTransitionStatus: () => false
|
|
252
290
|
};
|
|
253
291
|
function installDispatcher() {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
292
|
+
_detect();
|
|
293
|
+
if (_r19) {
|
|
294
|
+
const prev = _r19.H;
|
|
295
|
+
_r19.H = slimDispatcher;
|
|
296
|
+
return prev;
|
|
297
|
+
}
|
|
298
|
+
if (_r18) {
|
|
299
|
+
const prev = _r18.ReactCurrentDispatcher.current;
|
|
300
|
+
_r18.ReactCurrentDispatcher.current = slimDispatcher;
|
|
301
|
+
return prev;
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
259
304
|
}
|
|
260
305
|
function restoreDispatcher(prev) {
|
|
261
|
-
|
|
262
|
-
|
|
306
|
+
_detect();
|
|
307
|
+
if (_r19)
|
|
308
|
+
_r19.H = prev;
|
|
309
|
+
else if (_r18)
|
|
310
|
+
_r18.ReactCurrentDispatcher.current = prev;
|
|
263
311
|
}
|
|
264
312
|
|
|
265
313
|
// src/slim-react/render.ts
|
|
@@ -520,7 +568,7 @@ function writeAttributes(writer, props, isSvg, skip) {
|
|
|
520
568
|
if (isSvg && key in SVG_ATTR_MAP) {
|
|
521
569
|
attrName = SVG_ATTR_MAP[key];
|
|
522
570
|
} else {
|
|
523
|
-
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
|
|
571
|
+
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
|
|
524
572
|
}
|
|
525
573
|
if (value === false || value == null) {
|
|
526
574
|
if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
|
|
@@ -731,7 +779,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
731
779
|
const LazyComp = resolved?.default ?? resolved;
|
|
732
780
|
return renderComponent(LazyComp, props, writer, isSvg);
|
|
733
781
|
}
|
|
734
|
-
|
|
782
|
+
const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
|
|
783
|
+
if (isConsumer) {
|
|
735
784
|
const ctx2 = type._context;
|
|
736
785
|
const value = ctx2 ? getContextValue(ctx2) : undefined;
|
|
737
786
|
const result2 = typeof props.children === "function" ? props.children(value) : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hadars",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3-rc.0",
|
|
4
4
|
"description": "Minimal SSR framework for React — rspack, HMR, TypeScript, Bun/Node/Deno",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"node": ">=18.0.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"react": "^19.
|
|
62
|
-
"react-dom": "^19.
|
|
61
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
62
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
63
63
|
"typescript": "^5"
|
|
64
64
|
},
|
|
65
65
|
"peerDependenciesMeta": {
|