hadars 1.0.0 → 1.0.1
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-3RG5ZIWI.js +10 -0
- package/dist/{chunk-2TMQUXFL.js → chunk-HIKMDNRB.js} +65 -18
- package/dist/{chunk-NYLXE7T7.js → chunk-U2JQR4HV.js} +1 -1
- package/dist/cli.js +87 -39
- package/dist/cloudflare.cjs +70 -34
- package/dist/cloudflare.js +3 -2
- package/dist/index.js +2 -0
- package/dist/lambda.cjs +70 -34
- package/dist/lambda.js +3 -2
- package/dist/slim-react/index.cjs +90 -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 +71 -37
- package/package.json +3 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
|
@@ -6,8 +6,12 @@ import {
|
|
|
6
6
|
SUSPENSE_TYPE,
|
|
7
7
|
createElement
|
|
8
8
|
} from "./chunk-OZUZS2PD.js";
|
|
9
|
+
import {
|
|
10
|
+
__require
|
|
11
|
+
} from "./chunk-3RG5ZIWI.js";
|
|
9
12
|
|
|
10
13
|
// src/slim-react/renderContext.ts
|
|
14
|
+
import { createRequire as _nodeCreateRequire } from "module";
|
|
11
15
|
var MAP_KEY = "__slimReactContextMap";
|
|
12
16
|
var _g = globalThis;
|
|
13
17
|
if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
|
|
@@ -29,8 +33,7 @@ function restoreUnsuspend(u) {
|
|
|
29
33
|
function getContextValue(context) {
|
|
30
34
|
const map = _g[MAP_KEY];
|
|
31
35
|
if (map && map.has(context)) return map.get(context);
|
|
32
|
-
|
|
33
|
-
return "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
36
|
+
return context._currentValue;
|
|
34
37
|
}
|
|
35
38
|
function pushContextValue(context, value) {
|
|
36
39
|
let map = _g[MAP_KEY];
|
|
@@ -38,8 +41,7 @@ function pushContextValue(context, value) {
|
|
|
38
41
|
map = /* @__PURE__ */ new Map();
|
|
39
42
|
_g[MAP_KEY] = map;
|
|
40
43
|
}
|
|
41
|
-
const
|
|
42
|
-
const prev = map.has(context) ? map.get(context) : "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
44
|
+
const prev = map.has(context) ? map.get(context) : context._currentValue;
|
|
43
45
|
map.set(context, value);
|
|
44
46
|
return prev;
|
|
45
47
|
}
|
|
@@ -144,13 +146,40 @@ function getTreeId() {
|
|
|
144
146
|
const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
|
|
145
147
|
return stripped + overflow;
|
|
146
148
|
}
|
|
149
|
+
var _detectReact = () => {
|
|
150
|
+
if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
|
|
151
|
+
const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
|
|
152
|
+
return {
|
|
153
|
+
major,
|
|
154
|
+
// Exact patch version is unknown from the define alone; use a
|
|
155
|
+
// representative fallback. Most libraries only check the 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
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
const req = _nodeCreateRequire(process.cwd() + "/__hadars__.js");
|
|
166
|
+
return parse(req("react").version);
|
|
167
|
+
} catch {
|
|
168
|
+
}
|
|
169
|
+
return { major: 19, version: "19.1.1" };
|
|
170
|
+
};
|
|
171
|
+
var _react = _detectReact();
|
|
172
|
+
var REACT_MAJOR = _react.major;
|
|
173
|
+
var REACT_VERSION = _react.version;
|
|
147
174
|
function makeId() {
|
|
148
175
|
const st = s();
|
|
149
176
|
const treeId = getTreeId();
|
|
150
177
|
const n = st.localIdCounter++;
|
|
151
|
-
|
|
152
|
-
if (
|
|
153
|
-
|
|
178
|
+
const suffix = n > 0 ? "H" + n.toString(32) : "";
|
|
179
|
+
if (REACT_MAJOR < 19) {
|
|
180
|
+
return ":" + st.idPrefix + "R" + treeId + suffix + ":";
|
|
181
|
+
}
|
|
182
|
+
return "_R_" + st.idPrefix + treeId + suffix + "_";
|
|
154
183
|
}
|
|
155
184
|
|
|
156
185
|
// src/slim-react/hooks.ts
|
|
@@ -243,8 +272,9 @@ function createContext(defaultValue) {
|
|
|
243
272
|
|
|
244
273
|
// src/slim-react/dispatcher.ts
|
|
245
274
|
import * as ReactNS from "react";
|
|
246
|
-
var
|
|
247
|
-
var
|
|
275
|
+
var _r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
|
|
276
|
+
var _r18Raw = !_r19 ? ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"] : void 0;
|
|
277
|
+
var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : void 0;
|
|
248
278
|
var slimDispatcher = {
|
|
249
279
|
useId: makeId,
|
|
250
280
|
readContext: (ctx) => getContextValue(ctx),
|
|
@@ -272,13 +302,21 @@ var slimDispatcher = {
|
|
|
272
302
|
useHostTransitionStatus: () => false
|
|
273
303
|
};
|
|
274
304
|
function installDispatcher() {
|
|
275
|
-
if (
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
305
|
+
if (_r19) {
|
|
306
|
+
const prev = _r19.H;
|
|
307
|
+
_r19.H = slimDispatcher;
|
|
308
|
+
return prev;
|
|
309
|
+
}
|
|
310
|
+
if (_r18) {
|
|
311
|
+
const prev = _r18.ReactCurrentDispatcher.current;
|
|
312
|
+
_r18.ReactCurrentDispatcher.current = slimDispatcher;
|
|
313
|
+
return prev;
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
279
316
|
}
|
|
280
317
|
function restoreDispatcher(prev) {
|
|
281
|
-
if (
|
|
318
|
+
if (_r19) _r19.H = prev;
|
|
319
|
+
else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
|
|
282
320
|
}
|
|
283
321
|
|
|
284
322
|
// src/slim-react/render.ts
|
|
@@ -535,7 +573,7 @@ function writeAttributes(writer, props, isSvg, skip) {
|
|
|
535
573
|
if (isSvg && key in SVG_ATTR_MAP) {
|
|
536
574
|
attrName = SVG_ATTR_MAP[key];
|
|
537
575
|
} else {
|
|
538
|
-
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
|
|
576
|
+
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
|
|
539
577
|
}
|
|
540
578
|
if (value === false || value == null) {
|
|
541
579
|
if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
|
|
@@ -744,7 +782,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
744
782
|
const LazyComp = resolved?.default ?? resolved;
|
|
745
783
|
return renderComponent(LazyComp, props, writer, isSvg);
|
|
746
784
|
}
|
|
747
|
-
|
|
785
|
+
const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
|
|
786
|
+
if (isConsumer) {
|
|
748
787
|
const ctx2 = type._context;
|
|
749
788
|
const value = ctx2 ? getContextValue(ctx2) : void 0;
|
|
750
789
|
const result2 = typeof props.children === "function" ? props.children(value) : null;
|
|
@@ -1130,7 +1169,12 @@ var Component = class {
|
|
|
1130
1169
|
};
|
|
1131
1170
|
var PureComponent = class extends Component {
|
|
1132
1171
|
};
|
|
1133
|
-
var version =
|
|
1172
|
+
var version = REACT_VERSION;
|
|
1173
|
+
var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2 = {
|
|
1174
|
+
ReactCurrentDispatcher: { current: null },
|
|
1175
|
+
ReactCurrentBatchConfig: { transition: null },
|
|
1176
|
+
ReactCurrentOwner: { current: null }
|
|
1177
|
+
};
|
|
1134
1178
|
var React = {
|
|
1135
1179
|
// Hooks
|
|
1136
1180
|
useState,
|
|
@@ -1174,7 +1218,9 @@ var React = {
|
|
|
1174
1218
|
renderToReadableStream: renderToStream,
|
|
1175
1219
|
renderPreflight,
|
|
1176
1220
|
// Version
|
|
1177
|
-
version
|
|
1221
|
+
version,
|
|
1222
|
+
// React 18 internals
|
|
1223
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2
|
|
1178
1224
|
};
|
|
1179
1225
|
var slim_react_default = React;
|
|
1180
1226
|
|
|
@@ -1213,5 +1259,6 @@ export {
|
|
|
1213
1259
|
Component,
|
|
1214
1260
|
PureComponent,
|
|
1215
1261
|
version,
|
|
1262
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2 as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
1216
1263
|
slim_react_default
|
|
1217
1264
|
};
|
package/dist/cli.js
CHANGED
|
@@ -147,25 +147,8 @@ var SLIM_ELEMENT = Symbol.for("react.element");
|
|
|
147
147
|
var REACT19_ELEMENT = Symbol.for("react.transitional.element");
|
|
148
148
|
var FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
149
149
|
var SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
150
|
-
// src/slim-react/jsx.ts
|
|
151
|
-
function createElement(type, props, ...children) {
|
|
152
|
-
const normalizedProps = { ...props || {} };
|
|
153
|
-
if (children.length === 1) {
|
|
154
|
-
normalizedProps.children = children[0];
|
|
155
|
-
} else if (children.length > 1) {
|
|
156
|
-
normalizedProps.children = children;
|
|
157
|
-
}
|
|
158
|
-
const key = normalizedProps.key ?? null;
|
|
159
|
-
delete normalizedProps.key;
|
|
160
|
-
return {
|
|
161
|
-
$$typeof: SLIM_ELEMENT,
|
|
162
|
-
type,
|
|
163
|
-
props: normalizedProps,
|
|
164
|
-
key
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
|
|
168
150
|
// src/slim-react/renderContext.ts
|
|
151
|
+
import { createRequire as _nodeCreateRequire } from "node:module";
|
|
169
152
|
var MAP_KEY = "__slimReactContextMap";
|
|
170
153
|
var _g = globalThis;
|
|
171
154
|
if (!("__slimReactContextMap" in _g))
|
|
@@ -189,8 +172,7 @@ function getContextValue(context) {
|
|
|
189
172
|
const map = _g[MAP_KEY];
|
|
190
173
|
if (map && map.has(context))
|
|
191
174
|
return map.get(context);
|
|
192
|
-
|
|
193
|
-
return "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
175
|
+
return context._currentValue;
|
|
194
176
|
}
|
|
195
177
|
function pushContextValue(context, value) {
|
|
196
178
|
let map = _g[MAP_KEY];
|
|
@@ -198,8 +180,7 @@ function pushContextValue(context, value) {
|
|
|
198
180
|
map = new Map;
|
|
199
181
|
_g[MAP_KEY] = map;
|
|
200
182
|
}
|
|
201
|
-
const
|
|
202
|
-
const prev = map.has(context) ? map.get(context) : ("_defaultValue" in c) ? c._defaultValue : c._currentValue;
|
|
183
|
+
const prev = map.has(context) ? map.get(context) : context._currentValue;
|
|
203
184
|
map.set(context, value);
|
|
204
185
|
return prev;
|
|
205
186
|
}
|
|
@@ -304,14 +285,54 @@ function getTreeId() {
|
|
|
304
285
|
const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
|
|
305
286
|
return stripped + overflow;
|
|
306
287
|
}
|
|
288
|
+
var _detectReact = () => {
|
|
289
|
+
if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
|
|
290
|
+
const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
|
|
291
|
+
return {
|
|
292
|
+
major,
|
|
293
|
+
version: major < 19 ? "18.3.1" : "19.1.1"
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
|
|
297
|
+
try {
|
|
298
|
+
return parse(__require("react").version);
|
|
299
|
+
} catch {}
|
|
300
|
+
try {
|
|
301
|
+
const req = _nodeCreateRequire(process.cwd() + "/__hadars__.js");
|
|
302
|
+
return parse(req("react").version);
|
|
303
|
+
} catch {}
|
|
304
|
+
return { major: 19, version: "19.1.1" };
|
|
305
|
+
};
|
|
306
|
+
var _react = _detectReact();
|
|
307
|
+
var REACT_MAJOR = _react.major;
|
|
308
|
+
var REACT_VERSION = _react.version;
|
|
307
309
|
function makeId() {
|
|
308
310
|
const st = s();
|
|
309
311
|
const treeId = getTreeId();
|
|
310
312
|
const n = st.localIdCounter++;
|
|
311
|
-
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
const suffix = n > 0 ? "H" + n.toString(32) : "";
|
|
314
|
+
if (REACT_MAJOR < 19) {
|
|
315
|
+
return ":" + st.idPrefix + "R" + treeId + suffix + ":";
|
|
316
|
+
}
|
|
317
|
+
return "_R_" + st.idPrefix + treeId + suffix + "_";
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/slim-react/jsx.ts
|
|
321
|
+
function createElement(type, props, ...children) {
|
|
322
|
+
const normalizedProps = { ...props || {} };
|
|
323
|
+
if (children.length === 1) {
|
|
324
|
+
normalizedProps.children = children[0];
|
|
325
|
+
} else if (children.length > 1) {
|
|
326
|
+
normalizedProps.children = children;
|
|
327
|
+
}
|
|
328
|
+
const key = normalizedProps.key ?? null;
|
|
329
|
+
delete normalizedProps.key;
|
|
330
|
+
return {
|
|
331
|
+
$$typeof: SLIM_ELEMENT,
|
|
332
|
+
type,
|
|
333
|
+
props: normalizedProps,
|
|
334
|
+
key
|
|
335
|
+
};
|
|
315
336
|
}
|
|
316
337
|
|
|
317
338
|
// src/slim-react/hooks.ts
|
|
@@ -364,8 +385,9 @@ function use(usable) {
|
|
|
364
385
|
}
|
|
365
386
|
// src/slim-react/dispatcher.ts
|
|
366
387
|
import * as ReactNS from "react";
|
|
367
|
-
var
|
|
368
|
-
var
|
|
388
|
+
var _r19 = ReactNS.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
389
|
+
var _r18Raw = !_r19 ? ReactNS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED : undefined;
|
|
390
|
+
var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : undefined;
|
|
369
391
|
var slimDispatcher = {
|
|
370
392
|
useId: makeId,
|
|
371
393
|
readContext: (ctx) => getContextValue(ctx),
|
|
@@ -391,15 +413,23 @@ var slimDispatcher = {
|
|
|
391
413
|
useHostTransitionStatus: () => false
|
|
392
414
|
};
|
|
393
415
|
function installDispatcher() {
|
|
394
|
-
if (
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
416
|
+
if (_r19) {
|
|
417
|
+
const prev = _r19.H;
|
|
418
|
+
_r19.H = slimDispatcher;
|
|
419
|
+
return prev;
|
|
420
|
+
}
|
|
421
|
+
if (_r18) {
|
|
422
|
+
const prev = _r18.ReactCurrentDispatcher.current;
|
|
423
|
+
_r18.ReactCurrentDispatcher.current = slimDispatcher;
|
|
424
|
+
return prev;
|
|
425
|
+
}
|
|
426
|
+
return null;
|
|
399
427
|
}
|
|
400
428
|
function restoreDispatcher(prev) {
|
|
401
|
-
if (
|
|
402
|
-
|
|
429
|
+
if (_r19)
|
|
430
|
+
_r19.H = prev;
|
|
431
|
+
else if (_r18)
|
|
432
|
+
_r18.ReactCurrentDispatcher.current = prev;
|
|
403
433
|
}
|
|
404
434
|
|
|
405
435
|
// src/slim-react/render.ts
|
|
@@ -660,7 +690,7 @@ function writeAttributes(writer, props, isSvg, skip) {
|
|
|
660
690
|
if (isSvg && key in SVG_ATTR_MAP) {
|
|
661
691
|
attrName = SVG_ATTR_MAP[key];
|
|
662
692
|
} else {
|
|
663
|
-
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
|
|
693
|
+
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
|
|
664
694
|
}
|
|
665
695
|
if (value === false || value == null) {
|
|
666
696
|
if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
|
|
@@ -871,7 +901,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
871
901
|
const LazyComp = resolved?.default ?? resolved;
|
|
872
902
|
return renderComponent(LazyComp, props, writer, isSvg);
|
|
873
903
|
}
|
|
874
|
-
|
|
904
|
+
const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
|
|
905
|
+
if (isConsumer) {
|
|
875
906
|
const ctx2 = type._context;
|
|
876
907
|
const value = ctx2 ? getContextValue(ctx2) : undefined;
|
|
877
908
|
const result2 = typeof props.children === "function" ? props.children(value) : null;
|
|
@@ -2448,6 +2479,20 @@ var HadarsFolder = "./.hadars";
|
|
|
2448
2479
|
var StaticPath = `${HadarsFolder}/static`;
|
|
2449
2480
|
var HADARS_TMP_DIR = pathMod2.join(os.tmpdir(), "hadars");
|
|
2450
2481
|
var ensureHadarsTmpDir = () => fs.mkdir(HADARS_TMP_DIR, { recursive: true });
|
|
2482
|
+
var readReactMajor = async () => {
|
|
2483
|
+
let dir = process.cwd();
|
|
2484
|
+
while (true) {
|
|
2485
|
+
try {
|
|
2486
|
+
const pkgPath = pathMod2.join(dir, "node_modules", "react", "package.json");
|
|
2487
|
+
const pkg = JSON.parse(await fs.readFile(pkgPath, "utf-8"));
|
|
2488
|
+
return parseInt(pkg.version.split(".")[0], 10);
|
|
2489
|
+
} catch {}
|
|
2490
|
+
const parent = pathMod2.dirname(dir);
|
|
2491
|
+
if (parent === dir)
|
|
2492
|
+
return 19;
|
|
2493
|
+
dir = parent;
|
|
2494
|
+
}
|
|
2495
|
+
};
|
|
2451
2496
|
var validateOptions = (options) => {
|
|
2452
2497
|
if (!options.entry) {
|
|
2453
2498
|
throw new Error("Entry file is required");
|
|
@@ -2567,6 +2612,8 @@ var dev = async (options) => {
|
|
|
2567
2612
|
});
|
|
2568
2613
|
const workerCmd = resolveWorkerCmd(packageDir2);
|
|
2569
2614
|
console.log("Spawning SSR worker:", workerCmd.join(" "), "entry:", entry);
|
|
2615
|
+
const reactMajor = await readReactMajor();
|
|
2616
|
+
const ssrDefine = { __HADARS_REACT_MAJOR__: String(reactMajor), ...options.define };
|
|
2570
2617
|
const child = spawn(workerCmd[0], [
|
|
2571
2618
|
...workerCmd.slice(1),
|
|
2572
2619
|
`--entry=${entry}`,
|
|
@@ -2574,7 +2621,7 @@ var dev = async (options) => {
|
|
|
2574
2621
|
`--outFile=${SSR_FILENAME}`,
|
|
2575
2622
|
`--base=${baseURL}`,
|
|
2576
2623
|
...options.swcPlugins ? [`--swcPlugins=${JSON.stringify(options.swcPlugins)}`] : [],
|
|
2577
|
-
|
|
2624
|
+
`--define=${JSON.stringify(ssrDefine)}`,
|
|
2578
2625
|
...options.moduleRules ? [`--moduleRules=${JSON.stringify(options.moduleRules, (_k, v) => v instanceof RegExp ? { __re: v.source, __flags: v.flags } : v)}`] : []
|
|
2579
2626
|
], { stdio: "pipe" });
|
|
2580
2627
|
child.stdin?.end();
|
|
@@ -2748,6 +2795,7 @@ var build = async (options) => {
|
|
|
2748
2795
|
const tmpFilePath = pathMod2.join(HADARS_TMP_DIR, `client-${Date.now()}.tsx`);
|
|
2749
2796
|
await fs.writeFile(tmpFilePath, clientScript);
|
|
2750
2797
|
const resolvedHtmlTemplate = options.htmlTemplate ? await processHtmlTemplate(pathMod2.resolve(__dirname3, options.htmlTemplate)) : undefined;
|
|
2798
|
+
const reactMajor = await readReactMajor();
|
|
2751
2799
|
console.log("Building client and server bundles in parallel...");
|
|
2752
2800
|
await Promise.all([
|
|
2753
2801
|
compileEntry(tmpFilePath, {
|
|
@@ -2779,7 +2827,7 @@ var build = async (options) => {
|
|
|
2779
2827
|
target: "node",
|
|
2780
2828
|
mode: "production",
|
|
2781
2829
|
swcPlugins: options.swcPlugins,
|
|
2782
|
-
define: options.define,
|
|
2830
|
+
define: { __HADARS_REACT_MAJOR__: String(reactMajor), ...options.define },
|
|
2783
2831
|
moduleRules: options.moduleRules,
|
|
2784
2832
|
plugins: options.plugins,
|
|
2785
2833
|
postcssPlugins: options.postcssPlugins
|
package/dist/cloudflare.cjs
CHANGED
|
@@ -157,25 +157,8 @@ var REACT19_ELEMENT = /* @__PURE__ */ Symbol.for("react.transitional.element");
|
|
|
157
157
|
var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
158
158
|
var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
|
|
159
159
|
|
|
160
|
-
// src/slim-react/jsx.ts
|
|
161
|
-
function createElement(type, props, ...children) {
|
|
162
|
-
const normalizedProps = { ...props || {} };
|
|
163
|
-
if (children.length === 1) {
|
|
164
|
-
normalizedProps.children = children[0];
|
|
165
|
-
} else if (children.length > 1) {
|
|
166
|
-
normalizedProps.children = children;
|
|
167
|
-
}
|
|
168
|
-
const key = normalizedProps.key ?? null;
|
|
169
|
-
delete normalizedProps.key;
|
|
170
|
-
return {
|
|
171
|
-
$$typeof: SLIM_ELEMENT,
|
|
172
|
-
type,
|
|
173
|
-
props: normalizedProps,
|
|
174
|
-
key
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
160
|
// src/slim-react/renderContext.ts
|
|
161
|
+
var import_node_module = require("module");
|
|
179
162
|
var MAP_KEY = "__slimReactContextMap";
|
|
180
163
|
var _g = globalThis;
|
|
181
164
|
if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
|
|
@@ -197,8 +180,7 @@ function restoreUnsuspend(u) {
|
|
|
197
180
|
function getContextValue(context) {
|
|
198
181
|
const map = _g[MAP_KEY];
|
|
199
182
|
if (map && map.has(context)) return map.get(context);
|
|
200
|
-
|
|
201
|
-
return "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
183
|
+
return context._currentValue;
|
|
202
184
|
}
|
|
203
185
|
function pushContextValue(context, value) {
|
|
204
186
|
let map = _g[MAP_KEY];
|
|
@@ -206,8 +188,7 @@ function pushContextValue(context, value) {
|
|
|
206
188
|
map = /* @__PURE__ */ new Map();
|
|
207
189
|
_g[MAP_KEY] = map;
|
|
208
190
|
}
|
|
209
|
-
const
|
|
210
|
-
const prev = map.has(context) ? map.get(context) : "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
191
|
+
const prev = map.has(context) ? map.get(context) : context._currentValue;
|
|
211
192
|
map.set(context, value);
|
|
212
193
|
return prev;
|
|
213
194
|
}
|
|
@@ -312,13 +293,58 @@ function getTreeId() {
|
|
|
312
293
|
const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
|
|
313
294
|
return stripped + overflow;
|
|
314
295
|
}
|
|
296
|
+
var _detectReact = () => {
|
|
297
|
+
if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
|
|
298
|
+
const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
|
|
299
|
+
return {
|
|
300
|
+
major,
|
|
301
|
+
// Exact patch version is unknown from the define alone; use a
|
|
302
|
+
// representative fallback. Most libraries only check the major.
|
|
303
|
+
version: major < 19 ? "18.3.1" : "19.1.1"
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
|
|
307
|
+
try {
|
|
308
|
+
return parse(require("react").version);
|
|
309
|
+
} catch {
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
const req = (0, import_node_module.createRequire)(process.cwd() + "/__hadars__.js");
|
|
313
|
+
return parse(req("react").version);
|
|
314
|
+
} catch {
|
|
315
|
+
}
|
|
316
|
+
return { major: 19, version: "19.1.1" };
|
|
317
|
+
};
|
|
318
|
+
var _react = _detectReact();
|
|
319
|
+
var REACT_MAJOR = _react.major;
|
|
320
|
+
var REACT_VERSION = _react.version;
|
|
315
321
|
function makeId() {
|
|
316
322
|
const st = s();
|
|
317
323
|
const treeId = getTreeId();
|
|
318
324
|
const n = st.localIdCounter++;
|
|
319
|
-
|
|
320
|
-
if (
|
|
321
|
-
|
|
325
|
+
const suffix = n > 0 ? "H" + n.toString(32) : "";
|
|
326
|
+
if (REACT_MAJOR < 19) {
|
|
327
|
+
return ":" + st.idPrefix + "R" + treeId + suffix + ":";
|
|
328
|
+
}
|
|
329
|
+
return "_R_" + st.idPrefix + treeId + suffix + "_";
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// src/slim-react/jsx.ts
|
|
333
|
+
function createElement(type, props, ...children) {
|
|
334
|
+
const normalizedProps = { ...props || {} };
|
|
335
|
+
if (children.length === 1) {
|
|
336
|
+
normalizedProps.children = children[0];
|
|
337
|
+
} else if (children.length > 1) {
|
|
338
|
+
normalizedProps.children = children;
|
|
339
|
+
}
|
|
340
|
+
const key = normalizedProps.key ?? null;
|
|
341
|
+
delete normalizedProps.key;
|
|
342
|
+
return {
|
|
343
|
+
$$typeof: SLIM_ELEMENT,
|
|
344
|
+
type,
|
|
345
|
+
props: normalizedProps,
|
|
346
|
+
key
|
|
347
|
+
};
|
|
322
348
|
}
|
|
323
349
|
|
|
324
350
|
// src/slim-react/hooks.ts
|
|
@@ -379,8 +405,9 @@ function use(usable) {
|
|
|
379
405
|
|
|
380
406
|
// src/slim-react/dispatcher.ts
|
|
381
407
|
var ReactNS = __toESM(require("react"), 1);
|
|
382
|
-
var
|
|
383
|
-
var
|
|
408
|
+
var _r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
|
|
409
|
+
var _r18Raw = !_r19 ? ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"] : void 0;
|
|
410
|
+
var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : void 0;
|
|
384
411
|
var slimDispatcher = {
|
|
385
412
|
useId: makeId,
|
|
386
413
|
readContext: (ctx) => getContextValue(ctx),
|
|
@@ -408,13 +435,21 @@ var slimDispatcher = {
|
|
|
408
435
|
useHostTransitionStatus: () => false
|
|
409
436
|
};
|
|
410
437
|
function installDispatcher() {
|
|
411
|
-
if (
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
438
|
+
if (_r19) {
|
|
439
|
+
const prev = _r19.H;
|
|
440
|
+
_r19.H = slimDispatcher;
|
|
441
|
+
return prev;
|
|
442
|
+
}
|
|
443
|
+
if (_r18) {
|
|
444
|
+
const prev = _r18.ReactCurrentDispatcher.current;
|
|
445
|
+
_r18.ReactCurrentDispatcher.current = slimDispatcher;
|
|
446
|
+
return prev;
|
|
447
|
+
}
|
|
448
|
+
return null;
|
|
415
449
|
}
|
|
416
450
|
function restoreDispatcher(prev) {
|
|
417
|
-
if (
|
|
451
|
+
if (_r19) _r19.H = prev;
|
|
452
|
+
else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
|
|
418
453
|
}
|
|
419
454
|
|
|
420
455
|
// src/slim-react/render.ts
|
|
@@ -671,7 +706,7 @@ function writeAttributes(writer, props, isSvg, skip) {
|
|
|
671
706
|
if (isSvg && key in SVG_ATTR_MAP) {
|
|
672
707
|
attrName = SVG_ATTR_MAP[key];
|
|
673
708
|
} else {
|
|
674
|
-
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
|
|
709
|
+
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
|
|
675
710
|
}
|
|
676
711
|
if (value === false || value == null) {
|
|
677
712
|
if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
|
|
@@ -880,7 +915,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
880
915
|
const LazyComp = resolved?.default ?? resolved;
|
|
881
916
|
return renderComponent(LazyComp, props, writer, isSvg);
|
|
882
917
|
}
|
|
883
|
-
|
|
918
|
+
const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
|
|
919
|
+
if (isConsumer) {
|
|
884
920
|
const ctx2 = type._context;
|
|
885
921
|
const value = ctx2 ? getContextValue(ctx2) : void 0;
|
|
886
922
|
const result2 = typeof props.children === "function" ? props.children(value) : null;
|
package/dist/cloudflare.js
CHANGED
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
getReactResponse,
|
|
7
7
|
makePrecontentHtmlGetter,
|
|
8
8
|
parseRequest
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-U2JQR4HV.js";
|
|
10
|
+
import "./chunk-HIKMDNRB.js";
|
|
11
11
|
import "./chunk-OZUZS2PD.js";
|
|
12
|
+
import "./chunk-3RG5ZIWI.js";
|
|
12
13
|
|
|
13
14
|
// src/cloudflare.ts
|
|
14
15
|
import "react";
|
package/dist/index.js
CHANGED
package/dist/lambda.cjs
CHANGED
|
@@ -197,25 +197,8 @@ var REACT19_ELEMENT = /* @__PURE__ */ Symbol.for("react.transitional.element");
|
|
|
197
197
|
var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
198
198
|
var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
|
|
199
199
|
|
|
200
|
-
// src/slim-react/jsx.ts
|
|
201
|
-
function createElement(type, props, ...children) {
|
|
202
|
-
const normalizedProps = { ...props || {} };
|
|
203
|
-
if (children.length === 1) {
|
|
204
|
-
normalizedProps.children = children[0];
|
|
205
|
-
} else if (children.length > 1) {
|
|
206
|
-
normalizedProps.children = children;
|
|
207
|
-
}
|
|
208
|
-
const key = normalizedProps.key ?? null;
|
|
209
|
-
delete normalizedProps.key;
|
|
210
|
-
return {
|
|
211
|
-
$$typeof: SLIM_ELEMENT,
|
|
212
|
-
type,
|
|
213
|
-
props: normalizedProps,
|
|
214
|
-
key
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
200
|
// src/slim-react/renderContext.ts
|
|
201
|
+
var import_node_module = require("module");
|
|
219
202
|
var MAP_KEY = "__slimReactContextMap";
|
|
220
203
|
var _g = globalThis;
|
|
221
204
|
if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
|
|
@@ -237,8 +220,7 @@ function restoreUnsuspend(u) {
|
|
|
237
220
|
function getContextValue(context) {
|
|
238
221
|
const map = _g[MAP_KEY];
|
|
239
222
|
if (map && map.has(context)) return map.get(context);
|
|
240
|
-
|
|
241
|
-
return "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
223
|
+
return context._currentValue;
|
|
242
224
|
}
|
|
243
225
|
function pushContextValue(context, value) {
|
|
244
226
|
let map = _g[MAP_KEY];
|
|
@@ -246,8 +228,7 @@ function pushContextValue(context, value) {
|
|
|
246
228
|
map = /* @__PURE__ */ new Map();
|
|
247
229
|
_g[MAP_KEY] = map;
|
|
248
230
|
}
|
|
249
|
-
const
|
|
250
|
-
const prev = map.has(context) ? map.get(context) : "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
231
|
+
const prev = map.has(context) ? map.get(context) : context._currentValue;
|
|
251
232
|
map.set(context, value);
|
|
252
233
|
return prev;
|
|
253
234
|
}
|
|
@@ -352,13 +333,58 @@ function getTreeId() {
|
|
|
352
333
|
const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
|
|
353
334
|
return stripped + overflow;
|
|
354
335
|
}
|
|
336
|
+
var _detectReact = () => {
|
|
337
|
+
if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
|
|
338
|
+
const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
|
|
339
|
+
return {
|
|
340
|
+
major,
|
|
341
|
+
// Exact patch version is unknown from the define alone; use a
|
|
342
|
+
// representative fallback. Most libraries only check the major.
|
|
343
|
+
version: major < 19 ? "18.3.1" : "19.1.1"
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
|
|
347
|
+
try {
|
|
348
|
+
return parse(require("react").version);
|
|
349
|
+
} catch {
|
|
350
|
+
}
|
|
351
|
+
try {
|
|
352
|
+
const req = (0, import_node_module.createRequire)(process.cwd() + "/__hadars__.js");
|
|
353
|
+
return parse(req("react").version);
|
|
354
|
+
} catch {
|
|
355
|
+
}
|
|
356
|
+
return { major: 19, version: "19.1.1" };
|
|
357
|
+
};
|
|
358
|
+
var _react = _detectReact();
|
|
359
|
+
var REACT_MAJOR = _react.major;
|
|
360
|
+
var REACT_VERSION = _react.version;
|
|
355
361
|
function makeId() {
|
|
356
362
|
const st = s();
|
|
357
363
|
const treeId = getTreeId();
|
|
358
364
|
const n = st.localIdCounter++;
|
|
359
|
-
|
|
360
|
-
if (
|
|
361
|
-
|
|
365
|
+
const suffix = n > 0 ? "H" + n.toString(32) : "";
|
|
366
|
+
if (REACT_MAJOR < 19) {
|
|
367
|
+
return ":" + st.idPrefix + "R" + treeId + suffix + ":";
|
|
368
|
+
}
|
|
369
|
+
return "_R_" + st.idPrefix + treeId + suffix + "_";
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// src/slim-react/jsx.ts
|
|
373
|
+
function createElement(type, props, ...children) {
|
|
374
|
+
const normalizedProps = { ...props || {} };
|
|
375
|
+
if (children.length === 1) {
|
|
376
|
+
normalizedProps.children = children[0];
|
|
377
|
+
} else if (children.length > 1) {
|
|
378
|
+
normalizedProps.children = children;
|
|
379
|
+
}
|
|
380
|
+
const key = normalizedProps.key ?? null;
|
|
381
|
+
delete normalizedProps.key;
|
|
382
|
+
return {
|
|
383
|
+
$$typeof: SLIM_ELEMENT,
|
|
384
|
+
type,
|
|
385
|
+
props: normalizedProps,
|
|
386
|
+
key
|
|
387
|
+
};
|
|
362
388
|
}
|
|
363
389
|
|
|
364
390
|
// src/slim-react/hooks.ts
|
|
@@ -419,8 +445,9 @@ function use(usable) {
|
|
|
419
445
|
|
|
420
446
|
// src/slim-react/dispatcher.ts
|
|
421
447
|
var ReactNS = __toESM(require("react"), 1);
|
|
422
|
-
var
|
|
423
|
-
var
|
|
448
|
+
var _r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
|
|
449
|
+
var _r18Raw = !_r19 ? ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"] : void 0;
|
|
450
|
+
var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : void 0;
|
|
424
451
|
var slimDispatcher = {
|
|
425
452
|
useId: makeId,
|
|
426
453
|
readContext: (ctx) => getContextValue(ctx),
|
|
@@ -448,13 +475,21 @@ var slimDispatcher = {
|
|
|
448
475
|
useHostTransitionStatus: () => false
|
|
449
476
|
};
|
|
450
477
|
function installDispatcher() {
|
|
451
|
-
if (
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
478
|
+
if (_r19) {
|
|
479
|
+
const prev = _r19.H;
|
|
480
|
+
_r19.H = slimDispatcher;
|
|
481
|
+
return prev;
|
|
482
|
+
}
|
|
483
|
+
if (_r18) {
|
|
484
|
+
const prev = _r18.ReactCurrentDispatcher.current;
|
|
485
|
+
_r18.ReactCurrentDispatcher.current = slimDispatcher;
|
|
486
|
+
return prev;
|
|
487
|
+
}
|
|
488
|
+
return null;
|
|
455
489
|
}
|
|
456
490
|
function restoreDispatcher(prev) {
|
|
457
|
-
if (
|
|
491
|
+
if (_r19) _r19.H = prev;
|
|
492
|
+
else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
|
|
458
493
|
}
|
|
459
494
|
|
|
460
495
|
// src/slim-react/render.ts
|
|
@@ -711,7 +746,7 @@ function writeAttributes(writer, props, isSvg, skip) {
|
|
|
711
746
|
if (isSvg && key in SVG_ATTR_MAP) {
|
|
712
747
|
attrName = SVG_ATTR_MAP[key];
|
|
713
748
|
} else {
|
|
714
|
-
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
|
|
749
|
+
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
|
|
715
750
|
}
|
|
716
751
|
if (value === false || value == null) {
|
|
717
752
|
if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
|
|
@@ -920,7 +955,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
920
955
|
const LazyComp = resolved?.default ?? resolved;
|
|
921
956
|
return renderComponent(LazyComp, props, writer, isSvg);
|
|
922
957
|
}
|
|
923
|
-
|
|
958
|
+
const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
|
|
959
|
+
if (isConsumer) {
|
|
924
960
|
const ctx2 = type._context;
|
|
925
961
|
const value = ctx2 ? getContextValue(ctx2) : void 0;
|
|
926
962
|
const result2 = typeof props.children === "function" ? props.children(value) : null;
|
package/dist/lambda.js
CHANGED
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
getReactResponse,
|
|
7
7
|
makePrecontentHtmlGetter,
|
|
8
8
|
parseRequest
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-U2JQR4HV.js";
|
|
10
|
+
import "./chunk-HIKMDNRB.js";
|
|
11
11
|
import "./chunk-OZUZS2PD.js";
|
|
12
|
+
import "./chunk-3RG5ZIWI.js";
|
|
12
13
|
|
|
13
14
|
// src/lambda.ts
|
|
14
15
|
import "react";
|
|
@@ -38,6 +38,7 @@ __export(slim_react_exports, {
|
|
|
38
38
|
SLIM_ELEMENT: () => SLIM_ELEMENT,
|
|
39
39
|
SUSPENSE_TYPE: () => SUSPENSE_TYPE,
|
|
40
40
|
Suspense: () => Suspense,
|
|
41
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: () => __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2,
|
|
41
42
|
cloneElement: () => cloneElement,
|
|
42
43
|
createContext: () => createContext,
|
|
43
44
|
createElement: () => createElement,
|
|
@@ -83,34 +84,8 @@ var REACT19_ELEMENT = /* @__PURE__ */ Symbol.for("react.transitional.element");
|
|
|
83
84
|
var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
84
85
|
var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
|
|
85
86
|
|
|
86
|
-
// src/slim-react/jsx.ts
|
|
87
|
-
var Fragment = FRAGMENT_TYPE;
|
|
88
|
-
function jsx(type, props, key) {
|
|
89
|
-
return {
|
|
90
|
-
$$typeof: SLIM_ELEMENT,
|
|
91
|
-
type,
|
|
92
|
-
props: props || {},
|
|
93
|
-
key: key ?? (props?.key ?? null)
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function createElement(type, props, ...children) {
|
|
97
|
-
const normalizedProps = { ...props || {} };
|
|
98
|
-
if (children.length === 1) {
|
|
99
|
-
normalizedProps.children = children[0];
|
|
100
|
-
} else if (children.length > 1) {
|
|
101
|
-
normalizedProps.children = children;
|
|
102
|
-
}
|
|
103
|
-
const key = normalizedProps.key ?? null;
|
|
104
|
-
delete normalizedProps.key;
|
|
105
|
-
return {
|
|
106
|
-
$$typeof: SLIM_ELEMENT,
|
|
107
|
-
type,
|
|
108
|
-
props: normalizedProps,
|
|
109
|
-
key
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
87
|
// src/slim-react/renderContext.ts
|
|
88
|
+
var import_node_module = require("module");
|
|
114
89
|
var MAP_KEY = "__slimReactContextMap";
|
|
115
90
|
var _g = globalThis;
|
|
116
91
|
if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
|
|
@@ -132,8 +107,7 @@ function restoreUnsuspend(u) {
|
|
|
132
107
|
function getContextValue(context) {
|
|
133
108
|
const map = _g[MAP_KEY];
|
|
134
109
|
if (map && map.has(context)) return map.get(context);
|
|
135
|
-
|
|
136
|
-
return "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
110
|
+
return context._currentValue;
|
|
137
111
|
}
|
|
138
112
|
function pushContextValue(context, value) {
|
|
139
113
|
let map = _g[MAP_KEY];
|
|
@@ -141,8 +115,7 @@ function pushContextValue(context, value) {
|
|
|
141
115
|
map = /* @__PURE__ */ new Map();
|
|
142
116
|
_g[MAP_KEY] = map;
|
|
143
117
|
}
|
|
144
|
-
const
|
|
145
|
-
const prev = map.has(context) ? map.get(context) : "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
118
|
+
const prev = map.has(context) ? map.get(context) : context._currentValue;
|
|
146
119
|
map.set(context, value);
|
|
147
120
|
return prev;
|
|
148
121
|
}
|
|
@@ -247,13 +220,67 @@ function getTreeId() {
|
|
|
247
220
|
const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
|
|
248
221
|
return stripped + overflow;
|
|
249
222
|
}
|
|
223
|
+
var _detectReact = () => {
|
|
224
|
+
if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
|
|
225
|
+
const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
|
|
226
|
+
return {
|
|
227
|
+
major,
|
|
228
|
+
// Exact patch version is unknown from the define alone; use a
|
|
229
|
+
// representative fallback. Most libraries only check the major.
|
|
230
|
+
version: major < 19 ? "18.3.1" : "19.1.1"
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
|
|
234
|
+
try {
|
|
235
|
+
return parse(require("react").version);
|
|
236
|
+
} catch {
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
const req = (0, import_node_module.createRequire)(process.cwd() + "/__hadars__.js");
|
|
240
|
+
return parse(req("react").version);
|
|
241
|
+
} catch {
|
|
242
|
+
}
|
|
243
|
+
return { major: 19, version: "19.1.1" };
|
|
244
|
+
};
|
|
245
|
+
var _react = _detectReact();
|
|
246
|
+
var REACT_MAJOR = _react.major;
|
|
247
|
+
var REACT_VERSION = _react.version;
|
|
250
248
|
function makeId() {
|
|
251
249
|
const st = s();
|
|
252
250
|
const treeId = getTreeId();
|
|
253
251
|
const n = st.localIdCounter++;
|
|
254
|
-
|
|
255
|
-
if (
|
|
256
|
-
|
|
252
|
+
const suffix = n > 0 ? "H" + n.toString(32) : "";
|
|
253
|
+
if (REACT_MAJOR < 19) {
|
|
254
|
+
return ":" + st.idPrefix + "R" + treeId + suffix + ":";
|
|
255
|
+
}
|
|
256
|
+
return "_R_" + st.idPrefix + treeId + suffix + "_";
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// src/slim-react/jsx.ts
|
|
260
|
+
var Fragment = FRAGMENT_TYPE;
|
|
261
|
+
function jsx(type, props, key) {
|
|
262
|
+
return {
|
|
263
|
+
$$typeof: SLIM_ELEMENT,
|
|
264
|
+
type,
|
|
265
|
+
props: props || {},
|
|
266
|
+
key: key ?? (props?.key ?? null)
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function createElement(type, props, ...children) {
|
|
270
|
+
const normalizedProps = { ...props || {} };
|
|
271
|
+
if (children.length === 1) {
|
|
272
|
+
normalizedProps.children = children[0];
|
|
273
|
+
} else if (children.length > 1) {
|
|
274
|
+
normalizedProps.children = children;
|
|
275
|
+
}
|
|
276
|
+
const key = normalizedProps.key ?? null;
|
|
277
|
+
delete normalizedProps.key;
|
|
278
|
+
return {
|
|
279
|
+
$$typeof: SLIM_ELEMENT,
|
|
280
|
+
type,
|
|
281
|
+
props: normalizedProps,
|
|
282
|
+
key
|
|
283
|
+
};
|
|
257
284
|
}
|
|
258
285
|
|
|
259
286
|
// src/slim-react/hooks.ts
|
|
@@ -346,8 +373,9 @@ function createContext(defaultValue) {
|
|
|
346
373
|
|
|
347
374
|
// src/slim-react/dispatcher.ts
|
|
348
375
|
var ReactNS = __toESM(require("react"), 1);
|
|
349
|
-
var
|
|
350
|
-
var
|
|
376
|
+
var _r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
|
|
377
|
+
var _r18Raw = !_r19 ? ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"] : void 0;
|
|
378
|
+
var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : void 0;
|
|
351
379
|
var slimDispatcher = {
|
|
352
380
|
useId: makeId,
|
|
353
381
|
readContext: (ctx) => getContextValue(ctx),
|
|
@@ -375,13 +403,21 @@ var slimDispatcher = {
|
|
|
375
403
|
useHostTransitionStatus: () => false
|
|
376
404
|
};
|
|
377
405
|
function installDispatcher() {
|
|
378
|
-
if (
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
406
|
+
if (_r19) {
|
|
407
|
+
const prev = _r19.H;
|
|
408
|
+
_r19.H = slimDispatcher;
|
|
409
|
+
return prev;
|
|
410
|
+
}
|
|
411
|
+
if (_r18) {
|
|
412
|
+
const prev = _r18.ReactCurrentDispatcher.current;
|
|
413
|
+
_r18.ReactCurrentDispatcher.current = slimDispatcher;
|
|
414
|
+
return prev;
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
382
417
|
}
|
|
383
418
|
function restoreDispatcher(prev) {
|
|
384
|
-
if (
|
|
419
|
+
if (_r19) _r19.H = prev;
|
|
420
|
+
else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
|
|
385
421
|
}
|
|
386
422
|
|
|
387
423
|
// src/slim-react/render.ts
|
|
@@ -638,7 +674,7 @@ function writeAttributes(writer, props, isSvg, skip) {
|
|
|
638
674
|
if (isSvg && key in SVG_ATTR_MAP) {
|
|
639
675
|
attrName = SVG_ATTR_MAP[key];
|
|
640
676
|
} else {
|
|
641
|
-
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
|
|
677
|
+
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
|
|
642
678
|
}
|
|
643
679
|
if (value === false || value == null) {
|
|
644
680
|
if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
|
|
@@ -847,7 +883,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
847
883
|
const LazyComp = resolved?.default ?? resolved;
|
|
848
884
|
return renderComponent(LazyComp, props, writer, isSvg);
|
|
849
885
|
}
|
|
850
|
-
|
|
886
|
+
const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
|
|
887
|
+
if (isConsumer) {
|
|
851
888
|
const ctx2 = type._context;
|
|
852
889
|
const value = ctx2 ? getContextValue(ctx2) : void 0;
|
|
853
890
|
const result2 = typeof props.children === "function" ? props.children(value) : null;
|
|
@@ -1233,7 +1270,12 @@ var Component = class {
|
|
|
1233
1270
|
};
|
|
1234
1271
|
var PureComponent = class extends Component {
|
|
1235
1272
|
};
|
|
1236
|
-
var version =
|
|
1273
|
+
var version = REACT_VERSION;
|
|
1274
|
+
var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2 = {
|
|
1275
|
+
ReactCurrentDispatcher: { current: null },
|
|
1276
|
+
ReactCurrentBatchConfig: { transition: null },
|
|
1277
|
+
ReactCurrentOwner: { current: null }
|
|
1278
|
+
};
|
|
1237
1279
|
var React = {
|
|
1238
1280
|
// Hooks
|
|
1239
1281
|
useState,
|
|
@@ -1277,7 +1319,9 @@ var React = {
|
|
|
1277
1319
|
renderToReadableStream: renderToStream,
|
|
1278
1320
|
renderPreflight,
|
|
1279
1321
|
// Version
|
|
1280
|
-
version
|
|
1322
|
+
version,
|
|
1323
|
+
// React 18 internals
|
|
1324
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2
|
|
1281
1325
|
};
|
|
1282
1326
|
var slim_react_default = React;
|
|
1283
1327
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1290,6 +1334,7 @@ var slim_react_default = React;
|
|
|
1290
1334
|
SLIM_ELEMENT,
|
|
1291
1335
|
SUSPENSE_TYPE,
|
|
1292
1336
|
Suspense,
|
|
1337
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
1293
1338
|
cloneElement,
|
|
1294
1339
|
createContext,
|
|
1295
1340
|
createElement,
|
|
@@ -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 };
|
|
@@ -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-HIKMDNRB.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,9 @@ 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 = ReactNS.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
252
|
+
var _r18Raw = !_r19 ? ReactNS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED : undefined;
|
|
253
|
+
var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : undefined;
|
|
229
254
|
var slimDispatcher = {
|
|
230
255
|
useId: makeId,
|
|
231
256
|
readContext: (ctx) => getContextValue(ctx),
|
|
@@ -251,15 +276,23 @@ var slimDispatcher = {
|
|
|
251
276
|
useHostTransitionStatus: () => false
|
|
252
277
|
};
|
|
253
278
|
function installDispatcher() {
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
279
|
+
if (_r19) {
|
|
280
|
+
const prev = _r19.H;
|
|
281
|
+
_r19.H = slimDispatcher;
|
|
282
|
+
return prev;
|
|
283
|
+
}
|
|
284
|
+
if (_r18) {
|
|
285
|
+
const prev = _r18.ReactCurrentDispatcher.current;
|
|
286
|
+
_r18.ReactCurrentDispatcher.current = slimDispatcher;
|
|
287
|
+
return prev;
|
|
288
|
+
}
|
|
289
|
+
return null;
|
|
259
290
|
}
|
|
260
291
|
function restoreDispatcher(prev) {
|
|
261
|
-
if (
|
|
262
|
-
|
|
292
|
+
if (_r19)
|
|
293
|
+
_r19.H = prev;
|
|
294
|
+
else if (_r18)
|
|
295
|
+
_r18.ReactCurrentDispatcher.current = prev;
|
|
263
296
|
}
|
|
264
297
|
|
|
265
298
|
// src/slim-react/render.ts
|
|
@@ -520,7 +553,7 @@ function writeAttributes(writer, props, isSvg, skip) {
|
|
|
520
553
|
if (isSvg && key in SVG_ATTR_MAP) {
|
|
521
554
|
attrName = SVG_ATTR_MAP[key];
|
|
522
555
|
} else {
|
|
523
|
-
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
|
|
556
|
+
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
|
|
524
557
|
}
|
|
525
558
|
if (value === false || value == null) {
|
|
526
559
|
if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
|
|
@@ -731,7 +764,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
|
|
|
731
764
|
const LazyComp = resolved?.default ?? resolved;
|
|
732
765
|
return renderComponent(LazyComp, props, writer, isSvg);
|
|
733
766
|
}
|
|
734
|
-
|
|
767
|
+
const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
|
|
768
|
+
if (isConsumer) {
|
|
735
769
|
const ctx2 = type._context;
|
|
736
770
|
const value = ctx2 ? getContextValue(ctx2) : undefined;
|
|
737
771
|
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": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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": {
|