hadars 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/{chunk-TV37IMRB.js → chunk-2TMQUXFL.js} +10 -10
  2. package/dist/{chunk-2J2L2H3H.js → chunk-NYLXE7T7.js} +6 -6
  3. package/dist/{chunk-OS3V4CPN.js → chunk-OZUZS2PD.js} +4 -4
  4. package/dist/cli.js +462 -496
  5. package/dist/cloudflare.cjs +11 -11
  6. package/dist/cloudflare.js +3 -3
  7. package/dist/index.d.cts +8 -4
  8. package/dist/index.d.ts +8 -4
  9. package/dist/lambda.cjs +11 -11
  10. package/dist/lambda.js +7 -7
  11. package/dist/loader.cjs +90 -54
  12. package/dist/slim-react/index.cjs +13 -13
  13. package/dist/slim-react/index.js +2 -2
  14. package/dist/slim-react/jsx-runtime.cjs +2 -4
  15. package/dist/slim-react/jsx-runtime.js +1 -1
  16. package/dist/ssr-render-worker.js +174 -161
  17. package/dist/ssr-watch.js +40 -74
  18. package/package.json +8 -10
  19. package/cli-lib.ts +0 -676
  20. package/cli.ts +0 -36
  21. package/index.ts +0 -17
  22. package/src/build.ts +0 -805
  23. package/src/cloudflare.ts +0 -140
  24. package/src/index.tsx +0 -41
  25. package/src/lambda.ts +0 -287
  26. package/src/slim-react/context.ts +0 -55
  27. package/src/slim-react/dispatcher.ts +0 -87
  28. package/src/slim-react/hooks.ts +0 -137
  29. package/src/slim-react/index.ts +0 -232
  30. package/src/slim-react/jsx-runtime.ts +0 -7
  31. package/src/slim-react/jsx.ts +0 -53
  32. package/src/slim-react/render.ts +0 -1101
  33. package/src/slim-react/renderContext.ts +0 -294
  34. package/src/slim-react/types.ts +0 -33
  35. package/src/source/context.ts +0 -113
  36. package/src/source/graphiql.ts +0 -101
  37. package/src/source/inference.ts +0 -260
  38. package/src/source/runner.ts +0 -138
  39. package/src/source/store.ts +0 -50
  40. package/src/ssr-render-worker.ts +0 -116
  41. package/src/ssr-watch.ts +0 -62
  42. package/src/static.ts +0 -109
  43. package/src/types/global.d.ts +0 -5
  44. package/src/types/hadars.ts +0 -350
  45. package/src/utils/Head.tsx +0 -462
  46. package/src/utils/clientScript.tsx +0 -71
  47. package/src/utils/cookies.ts +0 -16
  48. package/src/utils/loader.ts +0 -335
  49. package/src/utils/proxyHandler.tsx +0 -104
  50. package/src/utils/request.tsx +0 -9
  51. package/src/utils/response.tsx +0 -141
  52. package/src/utils/rspack.ts +0 -467
  53. package/src/utils/runtime.ts +0 -19
  54. package/src/utils/serve.ts +0 -155
  55. package/src/utils/ssrHandler.ts +0 -239
  56. package/src/utils/staticFile.ts +0 -43
  57. package/src/utils/template.html +0 -11
  58. package/src/utils/upgradeRequest.tsx +0 -19
@@ -3,11 +3,10 @@ import { workerData, parentPort } from "node:worker_threads";
3
3
  import { pathToFileURL } from "node:url";
4
4
 
5
5
  // src/slim-react/types.ts
6
- var SLIM_ELEMENT = /* @__PURE__ */ Symbol.for("react.element");
7
- var REACT19_ELEMENT = /* @__PURE__ */ Symbol.for("react.transitional.element");
8
- var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
9
- var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
10
-
6
+ var SLIM_ELEMENT = Symbol.for("react.element");
7
+ var REACT19_ELEMENT = Symbol.for("react.transitional.element");
8
+ var FRAGMENT_TYPE = Symbol.for("react.fragment");
9
+ var SUSPENSE_TYPE = Symbol.for("react.suspense");
11
10
  // src/slim-react/jsx.ts
12
11
  function createElement(type, props, ...children) {
13
12
  const normalizedProps = { ...props || {} };
@@ -29,7 +28,8 @@ function createElement(type, props, ...children) {
29
28
  // src/slim-react/renderContext.ts
30
29
  var MAP_KEY = "__slimReactContextMap";
31
30
  var _g = globalThis;
32
- if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
31
+ if (!("__slimReactContextMap" in _g))
32
+ _g[MAP_KEY] = null;
33
33
  function swapContextMap(map) {
34
34
  const prev = _g[MAP_KEY];
35
35
  _g[MAP_KEY] = map;
@@ -47,18 +47,19 @@ function restoreUnsuspend(u) {
47
47
  }
48
48
  function getContextValue(context) {
49
49
  const map = _g[MAP_KEY];
50
- if (map && map.has(context)) return map.get(context);
50
+ if (map && map.has(context))
51
+ return map.get(context);
51
52
  const c = context;
52
53
  return "_defaultValue" in c ? c._defaultValue : c._currentValue;
53
54
  }
54
55
  function pushContextValue(context, value) {
55
56
  let map = _g[MAP_KEY];
56
57
  if (map === null) {
57
- map = /* @__PURE__ */ new Map();
58
+ map = new Map;
58
59
  _g[MAP_KEY] = map;
59
60
  }
60
61
  const c = context;
61
- const prev = map.has(context) ? map.get(context) : "_defaultValue" in c ? c._defaultValue : c._currentValue;
62
+ const prev = map.has(context) ? map.get(context) : ("_defaultValue" in c) ? c._defaultValue : c._currentValue;
62
63
  map.set(context, value);
63
64
  return prev;
64
65
  }
@@ -69,7 +70,8 @@ var GLOBAL_KEY = "__slimReactRenderState";
69
70
  var EMPTY = { id: 1, overflow: "" };
70
71
  var _stateCache = null;
71
72
  function s() {
72
- if (_stateCache !== null) return _stateCache;
73
+ if (_stateCache !== null)
74
+ return _stateCache;
73
75
  if (!_g[GLOBAL_KEY]) {
74
76
  _g[GLOBAL_KEY] = { currentTreeContext: { ...EMPTY }, localIdCounter: 0, idPrefix: "" };
75
77
  }
@@ -139,8 +141,6 @@ function snapshotContext() {
139
141
  tree: { id: ctx.id, overflow: ctx.overflow },
140
142
  localId: st.localIdCounter,
141
143
  treeDepth: depth,
142
- // Snapshot the live stack so that popTreeContext reads correct saved values
143
- // even if another concurrent render's resetRenderState stomped the arrays.
144
144
  idStack: _treeIdStack.slice(0, depth),
145
145
  ovStack: _treeOvStack.slice(0, depth)
146
146
  };
@@ -152,14 +152,15 @@ function restoreContext(snap) {
152
152
  ctx.overflow = snap.tree.overflow;
153
153
  st.localIdCounter = snap.localId;
154
154
  _treeDepth = snap.treeDepth;
155
- for (let i = 0; i < snap.treeDepth; i++) {
155
+ for (let i = 0;i < snap.treeDepth; i++) {
156
156
  _treeIdStack[i] = snap.idStack[i];
157
157
  _treeOvStack[i] = snap.ovStack[i];
158
158
  }
159
159
  }
160
160
  function getTreeId() {
161
161
  const { id, overflow } = s().currentTreeContext;
162
- if (id === 1) return overflow;
162
+ if (id === 1)
163
+ return overflow;
163
164
  const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
164
165
  return stripped + overflow;
165
166
  }
@@ -168,26 +169,22 @@ function makeId() {
168
169
  const treeId = getTreeId();
169
170
  const n = st.localIdCounter++;
170
171
  let id = "_R_" + st.idPrefix + treeId;
171
- if (n > 0) id += "H" + n.toString(32);
172
+ if (n > 0)
173
+ id += "H" + n.toString(32);
172
174
  return id + "_";
173
175
  }
174
176
 
175
177
  // src/slim-react/hooks.ts
176
178
  function useState(initialState) {
177
179
  const value = typeof initialState === "function" ? initialState() : initialState;
178
- return [value, () => {
179
- }];
180
+ return [value, () => {}];
180
181
  }
181
182
  function useReducer(_reducer, initialState) {
182
- return [initialState, () => {
183
- }];
184
- }
185
- function useEffect(_effect, _deps) {
186
- }
187
- function useLayoutEffect(_effect, _deps) {
188
- }
189
- function useInsertionEffect(_effect, _deps) {
183
+ return [initialState, () => {}];
190
184
  }
185
+ function useEffect(_effect, _deps) {}
186
+ function useLayoutEffect(_effect, _deps) {}
187
+ function useInsertionEffect(_effect, _deps) {}
191
188
  function useRef(initialValue) {
192
189
  return { current: initialValue };
193
190
  }
@@ -197,10 +194,8 @@ function useMemo(factory, _deps) {
197
194
  function useCallback(callback, _deps) {
198
195
  return callback;
199
196
  }
200
- function useDebugValue(_value, _format) {
201
- }
202
- function useImperativeHandle(_ref, _createHandle, _deps) {
203
- }
197
+ function useDebugValue(_value, _format) {}
198
+ function useImperativeHandle(_ref, _createHandle, _deps) {}
204
199
  function useSyncExternalStore(_subscribe, getSnapshot, getServerSnapshot) {
205
200
  return (getServerSnapshot || getSnapshot)();
206
201
  }
@@ -211,23 +206,22 @@ function useDeferredValue(value) {
211
206
  return value;
212
207
  }
213
208
  function useOptimistic(passthrough) {
214
- return [passthrough, () => {
215
- }];
209
+ return [passthrough, () => {}];
216
210
  }
217
211
  function useActionState(_action, initialState, _permalink) {
218
- return [initialState, () => {
219
- }, false];
212
+ return [initialState, () => {}, false];
220
213
  }
221
214
  function use(usable) {
222
- if (typeof usable === "object" && usable !== null && ("_currentValue" in usable || "_defaultValue" in usable)) {
215
+ if (typeof usable === "object" && usable !== null && (("_currentValue" in usable) || ("_defaultValue" in usable))) {
223
216
  return getContextValue(usable);
224
217
  }
225
218
  const promise = usable;
226
- if (promise.status === "fulfilled") return promise.value;
227
- if (promise.status === "rejected") throw promise.reason;
219
+ if (promise.status === "fulfilled")
220
+ return promise.value;
221
+ if (promise.status === "rejected")
222
+ throw promise.reason;
228
223
  throw promise;
229
224
  }
230
-
231
225
  // src/slim-react/dispatcher.ts
232
226
  import * as ReactNS from "react";
233
227
  var _reactInternalsKey = "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
@@ -252,20 +246,20 @@ var slimDispatcher = {
252
246
  useOptimistic,
253
247
  useActionState,
254
248
  use,
255
- // React internals that compiled output may call
256
- useMemoCache: (size) => new Array(size).fill(void 0),
257
- useCacheRefresh: () => () => {
258
- },
249
+ useMemoCache: (size) => new Array(size).fill(undefined),
250
+ useCacheRefresh: () => () => {},
259
251
  useHostTransitionStatus: () => false
260
252
  };
261
253
  function installDispatcher() {
262
- if (!_internals) return null;
254
+ if (!_internals)
255
+ return null;
263
256
  const prev = _internals.H;
264
257
  _internals.H = slimDispatcher;
265
258
  return prev;
266
259
  }
267
260
  function restoreDispatcher(prev) {
268
- if (_internals) _internals.H = prev;
261
+ if (_internals)
262
+ _internals.H = prev;
269
263
  }
270
264
 
271
265
  // src/slim-react/render.ts
@@ -277,7 +271,7 @@ function restoreRenderCtx(ctx) {
277
271
  restoreUnsuspend(ctx.u);
278
272
  restoreContext(ctx.t);
279
273
  }
280
- var VOID_ELEMENTS = /* @__PURE__ */ new Set([
274
+ var VOID_ELEMENTS = new Set([
281
275
  "area",
282
276
  "base",
283
277
  "br",
@@ -296,16 +290,18 @@ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
296
290
  var HTML_ESC = { "&": "&amp;", "<": "&lt;", ">": "&gt;", "'": "&#x27;" };
297
291
  var HTML_ESC_RE = /[&<>']/;
298
292
  function escapeHtml(str) {
299
- if (!HTML_ESC_RE.test(str)) return str;
293
+ if (!HTML_ESC_RE.test(str))
294
+ return str;
300
295
  return str.replace(/[&<>']/g, (c) => HTML_ESC[c]);
301
296
  }
302
297
  var ATTR_ESC = { "&": "&amp;", '"': "&quot;", "<": "&lt;", ">": "&gt;" };
303
298
  var ATTR_ESC_RE = /[&"<>]/;
304
299
  function escapeAttr(str) {
305
- if (!ATTR_ESC_RE.test(str)) return str;
300
+ if (!ATTR_ESC_RE.test(str))
301
+ return str;
306
302
  return str.replace(/[&"<>]/g, (c) => ATTR_ESC[c]);
307
303
  }
308
- var UNITLESS_CSS = /* @__PURE__ */ new Set([
304
+ var UNITLESS_CSS = new Set([
309
305
  "animationIterationCount",
310
306
  "aspectRatio",
311
307
  "borderImageOutset",
@@ -351,15 +347,17 @@ var UNITLESS_CSS = /* @__PURE__ */ new Set([
351
347
  "strokeOpacity",
352
348
  "strokeWidth"
353
349
  ]);
354
- var _cssKeyCache = /* @__PURE__ */ new Map();
350
+ var _cssKeyCache = new Map;
355
351
  function styleObjectToString(style) {
356
352
  let result = "";
357
353
  for (const key in style) {
358
354
  const value = style[key];
359
- if (value == null || typeof value === "boolean") continue;
360
- if (result) result += ";";
355
+ if (value == null || typeof value === "boolean")
356
+ continue;
357
+ if (result)
358
+ result += ";";
361
359
  let cssKey = _cssKeyCache.get(key);
362
- if (cssKey === void 0) {
360
+ if (cssKey === undefined) {
363
361
  cssKey = key.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
364
362
  _cssKeyCache.set(key, cssKey);
365
363
  }
@@ -372,7 +370,6 @@ function styleObjectToString(style) {
372
370
  return result;
373
371
  }
374
372
  var SVG_ATTR_MAP = {
375
- // Presentation / geometry
376
373
  accentHeight: "accent-height",
377
374
  alignmentBaseline: "alignment-baseline",
378
375
  arabicForm: "arabic-form",
@@ -443,7 +440,6 @@ var SVG_ATTR_MAP = {
443
440
  wordSpacing: "word-spacing",
444
441
  writingMode: "writing-mode",
445
442
  xHeight: "x-height",
446
- // Namespace-prefixed
447
443
  xlinkActuate: "xlink:actuate",
448
444
  xlinkArcrole: "xlink:arcrole",
449
445
  xlinkHref: "xlink:href",
@@ -456,7 +452,6 @@ var SVG_ATTR_MAP = {
456
452
  xmlSpace: "xml:space",
457
453
  xmlns: "xmlns",
458
454
  xmlnsXlink: "xmlns:xlink",
459
- // Filter / lighting
460
455
  baseFrequency: "baseFrequency",
461
456
  colorInterpolation_filters: "color-interpolation-filters",
462
457
  diffuseConstant: "diffuseConstant",
@@ -502,9 +497,9 @@ var SVG_ATTR_MAP = {
502
497
  xChannelSelector: "xChannelSelector",
503
498
  yChannelSelector: "yChannelSelector"
504
499
  };
505
- var TEXTAREA_SKIP_PROPS = /* @__PURE__ */ new Set(["value", "defaultValue", "children"]);
506
- var SELECT_SKIP_PROPS = /* @__PURE__ */ new Set(["value", "defaultValue"]);
507
- var INTERNAL_PROPS = /* @__PURE__ */ new Set([
500
+ var TEXTAREA_SKIP_PROPS = new Set(["value", "defaultValue", "children"]);
501
+ var SELECT_SKIP_PROPS = new Set(["value", "defaultValue"]);
502
+ var INTERNAL_PROPS = new Set([
508
503
  "children",
509
504
  "key",
510
505
  "ref",
@@ -514,10 +509,13 @@ var INTERNAL_PROPS = /* @__PURE__ */ new Set([
514
509
  ]);
515
510
  function writeAttributes(writer, props, isSvg, skip) {
516
511
  for (const key in props) {
517
- if (skip !== void 0 && skip.has(key)) continue;
512
+ if (skip !== undefined && skip.has(key))
513
+ continue;
518
514
  const value = props[key];
519
- if (INTERNAL_PROPS.has(key)) continue;
520
- if (key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key.charCodeAt(2) >= 65 && key.charCodeAt(2) <= 90) continue;
515
+ if (INTERNAL_PROPS.has(key))
516
+ continue;
517
+ if (key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key.charCodeAt(2) >= 65 && key.charCodeAt(2) <= 90)
518
+ continue;
521
519
  let attrName;
522
520
  if (isSvg && key in SVG_ATTR_MAP) {
523
521
  attrName = SVG_ATTR_MAP[key];
@@ -540,13 +538,15 @@ function writeAttributes(writer, props, isSvg, skip) {
540
538
  }
541
539
  if (key === "style" && typeof value === "object") {
542
540
  const styleStr = styleObjectToString(value);
543
- if (styleStr) writer.write(` style="${escapeAttr(styleStr)}"`);
541
+ if (styleStr)
542
+ writer.write(` style="${escapeAttr(styleStr)}"`);
544
543
  continue;
545
544
  }
546
545
  writer.write(` ${attrName}="${escapeAttr(typeof value === "string" ? value : String(value))}"`);
547
546
  }
548
547
  }
549
- var BufferWriter = class _BufferWriter {
548
+
549
+ class BufferWriter {
550
550
  data = "";
551
551
  lastWasText = false;
552
552
  write(chunk) {
@@ -557,19 +557,20 @@ var BufferWriter = class _BufferWriter {
557
557
  this.data += s2;
558
558
  this.lastWasText = true;
559
559
  }
560
- /** Flush accumulated output into a parent writer and reset. */
561
560
  flushTo(target) {
562
- if (!this.data) return;
563
- if (target instanceof _BufferWriter) {
561
+ if (!this.data)
562
+ return;
563
+ if (target instanceof BufferWriter) {
564
564
  target.data += this.data;
565
565
  } else {
566
566
  target.write(this.data);
567
567
  }
568
568
  target.lastWasText = this.lastWasText;
569
569
  }
570
- };
570
+ }
571
571
  function renderNode(node, writer, isSvg = false) {
572
- if (node == null || typeof node === "boolean") return;
572
+ if (node == null || typeof node === "boolean")
573
+ return;
573
574
  if (typeof node === "string") {
574
575
  writer.text(escapeHtml(node));
575
576
  return;
@@ -587,7 +588,8 @@ function renderNode(node, writer, isSvg = false) {
587
588
  }
588
589
  if ("$$typeof" in obj) {
589
590
  const elType = obj["$$typeof"];
590
- if (elType !== SLIM_ELEMENT && elType !== REACT19_ELEMENT) return;
591
+ if (elType !== SLIM_ELEMENT && elType !== REACT19_ELEMENT)
592
+ return;
591
593
  const element = node;
592
594
  const { type, props } = element;
593
595
  if (type === FRAGMENT_TYPE) {
@@ -608,19 +610,22 @@ function renderNode(node, writer, isSvg = false) {
608
610
  }
609
611
  }
610
612
  function markSelectedOptionsMulti(children, selectedValues) {
611
- if (children == null || typeof children === "boolean") return children;
612
- if (typeof children === "string" || typeof children === "number") return children;
613
+ if (children == null || typeof children === "boolean")
614
+ return children;
615
+ if (typeof children === "string" || typeof children === "number")
616
+ return children;
613
617
  if (Array.isArray(children)) {
614
618
  return children.map((c) => markSelectedOptionsMulti(c, selectedValues));
615
619
  }
616
620
  if (typeof children === "object" && "$$typeof" in children) {
617
621
  const elType = children["$$typeof"];
618
- if (elType !== SLIM_ELEMENT && elType !== REACT19_ELEMENT) return children;
622
+ if (elType !== SLIM_ELEMENT && elType !== REACT19_ELEMENT)
623
+ return children;
619
624
  const el = children;
620
625
  if (el.type === "option") {
621
- const optValue = el.props.value !== void 0 ? el.props.value : el.props.children;
626
+ const optValue = el.props.value !== undefined ? el.props.value : el.props.children;
622
627
  const isSelected = selectedValues.has(String(optValue));
623
- return { ...el, props: { ...el.props, selected: isSelected || void 0 } };
628
+ return { ...el, props: { ...el.props, selected: isSelected || undefined } };
624
629
  }
625
630
  if (el.type === "optgroup" || el.type === FRAGMENT_TYPE) {
626
631
  const newChildren = markSelectedOptionsMulti(el.props.children, selectedValues);
@@ -645,7 +650,7 @@ function renderHostElement(tag, props, writer, isSvg) {
645
650
  writer.write("<select");
646
651
  writeAttributes(writer, props, false, SELECT_SKIP_PROPS);
647
652
  writer.write(">");
648
- const selectedSet = selectedValue == null ? null : Array.isArray(selectedValue) ? new Set(selectedValue.map(String)) : /* @__PURE__ */ new Set([String(selectedValue)]);
653
+ const selectedSet = selectedValue == null ? null : Array.isArray(selectedValue) ? new Set(selectedValue.map(String)) : new Set([String(selectedValue)]);
649
654
  const patchedChildren = selectedSet != null ? markSelectedOptionsMulti(props.children, selectedSet) : props.children;
650
655
  const inner2 = renderChildren(patchedChildren, writer, false);
651
656
  if (inner2 && typeof inner2.then === "function") {
@@ -664,7 +669,7 @@ function renderHostElement(tag, props, writer, isSvg) {
664
669
  }
665
670
  writer.write(">");
666
671
  const childContext = tag === "foreignObject" ? false : childSvg;
667
- let inner = void 0;
672
+ let inner = undefined;
668
673
  if (props.dangerouslySetInnerHTML) {
669
674
  writer.write(props.dangerouslySetInnerHTML.__html);
670
675
  } else {
@@ -677,37 +682,31 @@ function renderHostElement(tag, props, writer, isSvg) {
677
682
  }
678
683
  writer.write(`</${tag}>`);
679
684
  }
680
- var REACT_MEMO = /* @__PURE__ */ Symbol.for("react.memo");
681
- var REACT_FORWARD_REF = /* @__PURE__ */ Symbol.for("react.forward_ref");
682
- var REACT_PROVIDER = /* @__PURE__ */ Symbol.for("react.provider");
683
- var REACT_CONTEXT = /* @__PURE__ */ Symbol.for("react.context");
684
- var REACT_CONSUMER = /* @__PURE__ */ Symbol.for("react.consumer");
685
- var REACT_LAZY = /* @__PURE__ */ Symbol.for("react.lazy");
686
- var SUSPENSE_RETRY_LIMIT = /* @__PURE__ */ Symbol("SuspenseRetryLimit");
685
+ var REACT_MEMO = Symbol.for("react.memo");
686
+ var REACT_FORWARD_REF = Symbol.for("react.forward_ref");
687
+ var REACT_PROVIDER = Symbol.for("react.provider");
688
+ var REACT_CONTEXT = Symbol.for("react.context");
689
+ var REACT_CONSUMER = Symbol.for("react.consumer");
690
+ var REACT_LAZY = Symbol.for("react.lazy");
691
+ var SUSPENSE_RETRY_LIMIT = Symbol("SuspenseRetryLimit");
687
692
  var MAX_COMPONENT_SUSPENSE_RETRIES = 25;
688
693
  function patchPromiseStatus(p) {
689
694
  const w = p;
690
- if (w.status) return;
695
+ if (w.status)
696
+ return;
691
697
  w.status = "pending";
692
- w.then(
693
- (v) => {
694
- w.status = "fulfilled";
695
- w.value = v;
696
- },
697
- (r) => {
698
- w.status = "rejected";
699
- w.reason = r;
700
- }
701
- );
698
+ w.then((v) => {
699
+ w.status = "fulfilled";
700
+ w.value = v;
701
+ }, (r) => {
702
+ w.status = "rejected";
703
+ w.reason = r;
704
+ });
702
705
  }
703
706
  function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
704
707
  const typeOf = type.$$typeof;
705
708
  if (typeOf === REACT_MEMO) {
706
- return renderNode(
707
- { $$typeof: SLIM_ELEMENT, type: type.type, props, key: null },
708
- writer,
709
- isSvg
710
- );
709
+ return renderNode({ $$typeof: SLIM_ELEMENT, type: type.type, props, key: null }, writer, isSvg);
711
710
  }
712
711
  if (typeOf === REACT_FORWARD_REF) {
713
712
  return renderComponent(type.render, props, writer, isSvg);
@@ -718,7 +717,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
718
717
  resolved = type._init(type._payload);
719
718
  } catch (e) {
720
719
  if (e && typeof e.then === "function") {
721
- if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES) throw SUSPENSE_RETRY_LIMIT;
720
+ if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES)
721
+ throw SUSPENSE_RETRY_LIMIT;
722
722
  patchPromiseStatus(e);
723
723
  const rctx = captureRenderCtx();
724
724
  return e.then(() => {
@@ -733,7 +733,7 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
733
733
  }
734
734
  if (typeOf === REACT_CONSUMER) {
735
735
  const ctx2 = type._context;
736
- const value = ctx2 ? getContextValue(ctx2) : void 0;
736
+ const value = ctx2 ? getContextValue(ctx2) : undefined;
737
737
  const result2 = typeof props.children === "function" ? props.children(value) : null;
738
738
  const savedScope2 = pushComponentScope();
739
739
  const finish = () => popComponentScope(savedScope2);
@@ -760,17 +760,14 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
760
760
  const r2 = renderChildren(props.children, writer, isSvg);
761
761
  if (r2 && typeof r2.then === "function") {
762
762
  const rctx = captureRenderCtx();
763
- return r2.then(
764
- () => {
765
- restoreRenderCtx(rctx);
766
- finish();
767
- },
768
- (e) => {
769
- restoreRenderCtx(rctx);
770
- finish();
771
- throw e;
772
- }
773
- );
763
+ return r2.then(() => {
764
+ restoreRenderCtx(rctx);
765
+ finish();
766
+ }, (e) => {
767
+ restoreRenderCtx(rctx);
768
+ finish();
769
+ throw e;
770
+ });
774
771
  }
775
772
  finish();
776
773
  return;
@@ -782,7 +779,8 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
782
779
  const instance = new type(props);
783
780
  if (typeof type.getDerivedStateFromProps === "function") {
784
781
  const derived = type.getDerivedStateFromProps(props, instance.state ?? {});
785
- if (derived != null) instance.state = { ...instance.state ?? {}, ...derived };
782
+ if (derived != null)
783
+ instance.state = { ...instance.state ?? {}, ...derived };
786
784
  }
787
785
  result = instance.render();
788
786
  } else {
@@ -791,9 +789,11 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
791
789
  } catch (e) {
792
790
  restoreDispatcher(prevDispatcher);
793
791
  popComponentScope(savedScope);
794
- if (isProvider) popContextValue(ctx, prevCtxValue);
792
+ if (isProvider)
793
+ popContextValue(ctx, prevCtxValue);
795
794
  if (e && typeof e.then === "function") {
796
- if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES) throw SUSPENSE_RETRY_LIMIT;
795
+ if (_suspenseRetries + 1 >= MAX_COMPONENT_SUSPENSE_RETRIES)
796
+ throw SUSPENSE_RETRY_LIMIT;
797
797
  patchPromiseStatus(e);
798
798
  const rctx = captureRenderCtx();
799
799
  return e.then(() => {
@@ -819,61 +819,68 @@ function renderComponent(type, props, writer, isSvg, _suspenseRetries = 0) {
819
819
  const r2 = renderNode(resolved, writer, isSvg);
820
820
  if (r2 && typeof r2.then === "function") {
821
821
  const rctx2 = captureRenderCtx();
822
- return r2.then(
823
- () => {
824
- restoreRenderCtx(rctx2);
825
- if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
826
- popComponentScope(savedScope);
827
- if (isProvider) popContextValue(ctx, prevCtxValue);
828
- },
829
- (e) => {
830
- restoreRenderCtx(rctx2);
831
- if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
832
- popComponentScope(savedScope);
833
- if (isProvider) popContextValue(ctx, prevCtxValue);
834
- throw e;
835
- }
836
- );
822
+ return r2.then(() => {
823
+ restoreRenderCtx(rctx2);
824
+ if (asyncSavedIdTree !== undefined)
825
+ popTreeContext(asyncSavedIdTree);
826
+ popComponentScope(savedScope);
827
+ if (isProvider)
828
+ popContextValue(ctx, prevCtxValue);
829
+ }, (e) => {
830
+ restoreRenderCtx(rctx2);
831
+ if (asyncSavedIdTree !== undefined)
832
+ popTreeContext(asyncSavedIdTree);
833
+ popComponentScope(savedScope);
834
+ if (isProvider)
835
+ popContextValue(ctx, prevCtxValue);
836
+ throw e;
837
+ });
837
838
  }
838
- if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
839
+ if (asyncSavedIdTree !== undefined)
840
+ popTreeContext(asyncSavedIdTree);
839
841
  popComponentScope(savedScope);
840
- if (isProvider) popContextValue(ctx, prevCtxValue);
842
+ if (isProvider)
843
+ popContextValue(ctx, prevCtxValue);
841
844
  }, (e) => {
842
845
  restoreRenderCtx(rctx);
843
846
  popComponentScope(savedScope);
844
- if (isProvider) popContextValue(ctx, prevCtxValue);
847
+ if (isProvider)
848
+ popContextValue(ctx, prevCtxValue);
845
849
  throw e;
846
850
  });
847
851
  }
848
852
  const r = renderNode(result, writer, isSvg);
849
853
  if (r && typeof r.then === "function") {
850
854
  const rctx = captureRenderCtx();
851
- return r.then(
852
- () => {
853
- restoreRenderCtx(rctx);
854
- if (savedIdTree !== void 0) popTreeContext(savedIdTree);
855
- popComponentScope(savedScope);
856
- if (isProvider) popContextValue(ctx, prevCtxValue);
857
- },
858
- (e) => {
859
- restoreRenderCtx(rctx);
860
- if (savedIdTree !== void 0) popTreeContext(savedIdTree);
861
- popComponentScope(savedScope);
862
- if (isProvider) popContextValue(ctx, prevCtxValue);
863
- throw e;
864
- }
865
- );
855
+ return r.then(() => {
856
+ restoreRenderCtx(rctx);
857
+ if (savedIdTree !== undefined)
858
+ popTreeContext(savedIdTree);
859
+ popComponentScope(savedScope);
860
+ if (isProvider)
861
+ popContextValue(ctx, prevCtxValue);
862
+ }, (e) => {
863
+ restoreRenderCtx(rctx);
864
+ if (savedIdTree !== undefined)
865
+ popTreeContext(savedIdTree);
866
+ popComponentScope(savedScope);
867
+ if (isProvider)
868
+ popContextValue(ctx, prevCtxValue);
869
+ throw e;
870
+ });
866
871
  }
867
- if (savedIdTree !== void 0) popTreeContext(savedIdTree);
872
+ if (savedIdTree !== undefined)
873
+ popTreeContext(savedIdTree);
868
874
  popComponentScope(savedScope);
869
- if (isProvider) popContextValue(ctx, prevCtxValue);
875
+ if (isProvider)
876
+ popContextValue(ctx, prevCtxValue);
870
877
  }
871
878
  function renderChildArray(children, writer, isSvg) {
872
879
  return renderChildArrayFrom(children, 0, writer, isSvg);
873
880
  }
874
881
  function renderChildArrayFrom(children, startIndex, writer, isSvg) {
875
882
  const totalChildren = children.length;
876
- for (let i = startIndex; i < totalChildren; i++) {
883
+ for (let i = startIndex;i < totalChildren; i++) {
877
884
  const child = children[i];
878
885
  if ((typeof child === "string" || typeof child === "number") && writer.lastWasText) {
879
886
  writer.write("<!-- -->");
@@ -892,7 +899,8 @@ function renderChildArrayFrom(children, startIndex, writer, isSvg) {
892
899
  }
893
900
  }
894
901
  function renderChildren(children, writer, isSvg = false) {
895
- if (children == null) return;
902
+ if (children == null)
903
+ return;
896
904
  if (Array.isArray(children)) {
897
905
  return renderChildArray(children, writer, isSvg);
898
906
  }
@@ -903,7 +911,7 @@ async function renderSuspense(props, writer, isSvg = false) {
903
911
  const snap = snapshotContext();
904
912
  const savedMap = captureMap();
905
913
  const savedMapClone = savedMap ? new Map(savedMap) : null;
906
- const buffer = new BufferWriter();
914
+ const buffer = new BufferWriter;
907
915
  try {
908
916
  const r = renderNode(children, buffer, isSvg);
909
917
  if (r && typeof r.then === "function") {
@@ -934,7 +942,7 @@ async function renderSuspense(props, writer, isSvg = false) {
934
942
  }
935
943
  }
936
944
  }
937
- var _streamEncoder = new TextEncoder();
945
+ var _streamEncoder = new TextEncoder;
938
946
  async function renderToString(element, options) {
939
947
  const idPrefix = options?.identifierPrefix ?? "";
940
948
  const prev = swapContextMap(null);
@@ -963,7 +971,6 @@ async function renderToString(element, options) {
963
971
  swapContextMap(prev);
964
972
  }
965
973
  }
966
-
967
974
  // src/utils/response.tsx
968
975
  var ESC = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" };
969
976
  var escAttr = (s2) => s2.replace(/[&<>"]/g, (c) => ESC[c] ?? c);
@@ -983,14 +990,17 @@ function renderHeadTag(tag, id, opts, selfClose = false) {
983
990
  let attrs = ` id="${escAttr(id)}"`;
984
991
  let inner = "";
985
992
  for (const [k, v] of Object.entries(opts)) {
986
- if (k === "key" || k === "children") continue;
993
+ if (k === "key" || k === "children")
994
+ continue;
987
995
  if (k === "dangerouslySetInnerHTML") {
988
996
  inner = v.__html ?? "";
989
997
  continue;
990
998
  }
991
999
  const attr = ATTR[k] ?? k;
992
- if (v === true) attrs += ` ${attr}`;
993
- else if (v !== false && v != null) attrs += ` ${attr}="${escAttr(String(v))}"`;
1000
+ if (v === true)
1001
+ attrs += ` ${attr}`;
1002
+ else if (v !== false && v != null)
1003
+ attrs += ` ${attr}="${escAttr(String(v))}"`;
994
1004
  }
995
1005
  return selfClose ? `<${tag}${attrs}>` : `<${tag}${attrs}>${inner}</${tag}>`;
996
1006
  }
@@ -1011,12 +1021,14 @@ function buildHeadHtml(seoData) {
1011
1021
  var { ssrBundlePath } = workerData;
1012
1022
  var _ssrMod = null;
1013
1023
  async function init() {
1014
- if (_ssrMod) return;
1024
+ if (_ssrMod)
1025
+ return;
1015
1026
  _ssrMod = await import(pathToFileURL(ssrBundlePath).href);
1016
1027
  }
1017
1028
  function deserializeRequest(s2) {
1018
1029
  const init2 = { method: s2.method, headers: new Headers(s2.headers) };
1019
- if (s2.body) init2.body = s2.body.buffer;
1030
+ if (s2.body)
1031
+ init2.body = s2.body.buffer;
1020
1032
  const req = new Request(s2.url, init2);
1021
1033
  Object.assign(req, { pathname: s2.pathname, search: s2.search, location: s2.location, cookies: s2.cookies });
1022
1034
  return req;
@@ -1032,7 +1044,7 @@ async function runFullLifecycle(serialReq) {
1032
1044
  ...getInitProps ? await getInitProps(parsedReq) : {},
1033
1045
  location: serialReq.location
1034
1046
  };
1035
- const unsuspend = { cache: /* @__PURE__ */ new Map() };
1047
+ const unsuspend = { cache: new Map };
1036
1048
  globalThis.__hadarsUnsuspend = unsuspend;
1037
1049
  globalThis.__hadarsContext = context;
1038
1050
  let appHtml;
@@ -1066,7 +1078,8 @@ parentPort.on("message", async (msg) => {
1066
1078
  const { id, type, request } = msg;
1067
1079
  try {
1068
1080
  await init();
1069
- if (type !== "renderFull") return;
1081
+ if (type !== "renderFull")
1082
+ return;
1070
1083
  const { html, headHtml, status } = await runFullLifecycle(request);
1071
1084
  parentPort.postMessage({ id, html, headHtml, status });
1072
1085
  } catch (err) {