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.
@@ -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
- const c = context;
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 c = context;
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
- let id = "_R_" + st.idPrefix + treeId;
320
- if (n > 0) id += "H" + n.toString(32);
321
- return id + "_";
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,20 @@ function use(usable) {
379
405
 
380
406
  // src/slim-react/dispatcher.ts
381
407
  var ReactNS = __toESM(require("react"), 1);
382
- var _reactInternalsKey = "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
383
- var _internals = ReactNS[_reactInternalsKey];
408
+ var _r19;
409
+ var _r18;
410
+ var _detected = false;
411
+ function _detect() {
412
+ if (_detected) return;
413
+ _detected = true;
414
+ const r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
415
+ if (r19) {
416
+ _r19 = r19;
417
+ return;
418
+ }
419
+ const raw = ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"];
420
+ if (raw?.ReactCurrentDispatcher) _r18 = raw;
421
+ }
384
422
  var slimDispatcher = {
385
423
  useId: makeId,
386
424
  readContext: (ctx) => getContextValue(ctx),
@@ -408,13 +446,23 @@ var slimDispatcher = {
408
446
  useHostTransitionStatus: () => false
409
447
  };
410
448
  function installDispatcher() {
411
- if (!_internals) return null;
412
- const prev = _internals.H;
413
- _internals.H = slimDispatcher;
414
- return prev;
449
+ _detect();
450
+ if (_r19) {
451
+ const prev = _r19.H;
452
+ _r19.H = slimDispatcher;
453
+ return prev;
454
+ }
455
+ if (_r18) {
456
+ const prev = _r18.ReactCurrentDispatcher.current;
457
+ _r18.ReactCurrentDispatcher.current = slimDispatcher;
458
+ return prev;
459
+ }
460
+ return null;
415
461
  }
416
462
  function restoreDispatcher(prev) {
417
- if (_internals) _internals.H = prev;
463
+ _detect();
464
+ if (_r19) _r19.H = prev;
465
+ else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
418
466
  }
419
467
 
420
468
  // src/slim-react/render.ts
@@ -671,7 +719,7 @@ function writeAttributes(writer, props, isSvg, skip) {
671
719
  if (isSvg && key in SVG_ATTR_MAP) {
672
720
  attrName = SVG_ATTR_MAP[key];
673
721
  } else {
674
- attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
722
+ attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
675
723
  }
676
724
  if (value === false || value == null) {
677
725
  if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
@@ -880,7 +928,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
880
928
  const LazyComp = resolved?.default ?? resolved;
881
929
  return renderComponent(LazyComp, props, writer, isSvg);
882
930
  }
883
- if (typeOf === REACT_CONSUMER) {
931
+ const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
932
+ if (isConsumer) {
884
933
  const ctx2 = type._context;
885
934
  const value = ctx2 ? getContextValue(ctx2) : void 0;
886
935
  const result2 = typeof props.children === "function" ? props.children(value) : null;
@@ -6,9 +6,10 @@ import {
6
6
  getReactResponse,
7
7
  makePrecontentHtmlGetter,
8
8
  parseRequest
9
- } from "./chunk-NYLXE7T7.js";
10
- import "./chunk-2TMQUXFL.js";
9
+ } from "./chunk-YCCTGINV.js";
10
+ import "./chunk-BNBZ3XYX.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
@@ -1,3 +1,5 @@
1
+ import "./chunk-3RG5ZIWI.js";
2
+
1
3
  // src/utils/Head.tsx
2
4
  import React from "react";
3
5
  function deriveKey(tag, props) {
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
- const c = context;
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 c = context;
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
- let id = "_R_" + st.idPrefix + treeId;
360
- if (n > 0) id += "H" + n.toString(32);
361
- return id + "_";
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,20 @@ function use(usable) {
419
445
 
420
446
  // src/slim-react/dispatcher.ts
421
447
  var ReactNS = __toESM(require("react"), 1);
422
- var _reactInternalsKey = "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
423
- var _internals = ReactNS[_reactInternalsKey];
448
+ var _r19;
449
+ var _r18;
450
+ var _detected = false;
451
+ function _detect() {
452
+ if (_detected) return;
453
+ _detected = true;
454
+ const r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
455
+ if (r19) {
456
+ _r19 = r19;
457
+ return;
458
+ }
459
+ const raw = ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"];
460
+ if (raw?.ReactCurrentDispatcher) _r18 = raw;
461
+ }
424
462
  var slimDispatcher = {
425
463
  useId: makeId,
426
464
  readContext: (ctx) => getContextValue(ctx),
@@ -448,13 +486,23 @@ var slimDispatcher = {
448
486
  useHostTransitionStatus: () => false
449
487
  };
450
488
  function installDispatcher() {
451
- if (!_internals) return null;
452
- const prev = _internals.H;
453
- _internals.H = slimDispatcher;
454
- return prev;
489
+ _detect();
490
+ if (_r19) {
491
+ const prev = _r19.H;
492
+ _r19.H = slimDispatcher;
493
+ return prev;
494
+ }
495
+ if (_r18) {
496
+ const prev = _r18.ReactCurrentDispatcher.current;
497
+ _r18.ReactCurrentDispatcher.current = slimDispatcher;
498
+ return prev;
499
+ }
500
+ return null;
455
501
  }
456
502
  function restoreDispatcher(prev) {
457
- if (_internals) _internals.H = prev;
503
+ _detect();
504
+ if (_r19) _r19.H = prev;
505
+ else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
458
506
  }
459
507
 
460
508
  // src/slim-react/render.ts
@@ -711,7 +759,7 @@ function writeAttributes(writer, props, isSvg, skip) {
711
759
  if (isSvg && key in SVG_ATTR_MAP) {
712
760
  attrName = SVG_ATTR_MAP[key];
713
761
  } else {
714
- attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
762
+ attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
715
763
  }
716
764
  if (value === false || value == null) {
717
765
  if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
@@ -920,7 +968,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
920
968
  const LazyComp = resolved?.default ?? resolved;
921
969
  return renderComponent(LazyComp, props, writer, isSvg);
922
970
  }
923
- if (typeOf === REACT_CONSUMER) {
971
+ const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
972
+ if (isConsumer) {
924
973
  const ctx2 = type._context;
925
974
  const value = ctx2 ? getContextValue(ctx2) : void 0;
926
975
  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-NYLXE7T7.js";
10
- import "./chunk-2TMQUXFL.js";
9
+ } from "./chunk-YCCTGINV.js";
10
+ import "./chunk-BNBZ3XYX.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
- const c = context;
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 c = context;
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
- let id = "_R_" + st.idPrefix + treeId;
255
- if (n > 0) id += "H" + n.toString(32);
256
- return id + "_";
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,20 @@ function createContext(defaultValue) {
346
373
 
347
374
  // src/slim-react/dispatcher.ts
348
375
  var ReactNS = __toESM(require("react"), 1);
349
- var _reactInternalsKey = "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
350
- var _internals = ReactNS[_reactInternalsKey];
376
+ var _r19;
377
+ var _r18;
378
+ var _detected = false;
379
+ function _detect() {
380
+ if (_detected) return;
381
+ _detected = true;
382
+ const r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
383
+ if (r19) {
384
+ _r19 = r19;
385
+ return;
386
+ }
387
+ const raw = ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"];
388
+ if (raw?.ReactCurrentDispatcher) _r18 = raw;
389
+ }
351
390
  var slimDispatcher = {
352
391
  useId: makeId,
353
392
  readContext: (ctx) => getContextValue(ctx),
@@ -375,13 +414,23 @@ var slimDispatcher = {
375
414
  useHostTransitionStatus: () => false
376
415
  };
377
416
  function installDispatcher() {
378
- if (!_internals) return null;
379
- const prev = _internals.H;
380
- _internals.H = slimDispatcher;
381
- return prev;
417
+ _detect();
418
+ if (_r19) {
419
+ const prev = _r19.H;
420
+ _r19.H = slimDispatcher;
421
+ return prev;
422
+ }
423
+ if (_r18) {
424
+ const prev = _r18.ReactCurrentDispatcher.current;
425
+ _r18.ReactCurrentDispatcher.current = slimDispatcher;
426
+ return prev;
427
+ }
428
+ return null;
382
429
  }
383
430
  function restoreDispatcher(prev) {
384
- if (_internals) _internals.H = prev;
431
+ _detect();
432
+ if (_r19) _r19.H = prev;
433
+ else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
385
434
  }
386
435
 
387
436
  // src/slim-react/render.ts
@@ -638,7 +687,7 @@ function writeAttributes(writer, props, isSvg, skip) {
638
687
  if (isSvg && key in SVG_ATTR_MAP) {
639
688
  attrName = SVG_ATTR_MAP[key];
640
689
  } else {
641
- attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key;
690
+ attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key === "defaultValue" ? "value" : key === "defaultChecked" ? "checked" : key === "contentEditable" && REACT_MAJOR < 19 ? "contenteditable" : key;
642
691
  }
643
692
  if (value === false || value == null) {
644
693
  if (value === false && (attrName.charCodeAt(0) === 97 && attrName.startsWith("aria-") || attrName.charCodeAt(0) === 100 && attrName.startsWith("data-"))) {
@@ -847,7 +896,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
847
896
  const LazyComp = resolved?.default ?? resolved;
848
897
  return renderComponent(LazyComp, props, writer, isSvg);
849
898
  }
850
- if (typeOf === REACT_CONSUMER) {
899
+ const isConsumer = typeOf === REACT_CONSUMER || typeOf === REACT_CONTEXT && "_context" in type && !("value" in props);
900
+ if (isConsumer) {
851
901
  const ctx2 = type._context;
852
902
  const value = ctx2 ? getContextValue(ctx2) : void 0;
853
903
  const result2 = typeof props.children === "function" ? props.children(value) : null;
@@ -1233,7 +1283,12 @@ var Component = class {
1233
1283
  };
1234
1284
  var PureComponent = class extends Component {
1235
1285
  };
1236
- var version = "19.1.1";
1286
+ var version = REACT_VERSION;
1287
+ var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2 = {
1288
+ ReactCurrentDispatcher: { current: null },
1289
+ ReactCurrentBatchConfig: { transition: null },
1290
+ ReactCurrentOwner: { current: null }
1291
+ };
1237
1292
  var React = {
1238
1293
  // Hooks
1239
1294
  useState,
@@ -1277,7 +1332,9 @@ var React = {
1277
1332
  renderToReadableStream: renderToStream,
1278
1333
  renderPreflight,
1279
1334
  // Version
1280
- version
1335
+ version,
1336
+ // React 18 internals
1337
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2
1281
1338
  };
1282
1339
  var slim_react_default = React;
1283
1340
  // Annotate the CommonJS export names for ESM import in node:
@@ -1290,6 +1347,7 @@ var slim_react_default = React;
1290
1347
  SLIM_ELEMENT,
1291
1348
  SUSPENSE_TYPE,
1292
1349
  Suspense,
1350
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1293
1351
  cloneElement,
1294
1352
  createContext,
1295
1353
  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 = "19.1.1";
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 };