@rectify-dev/core 2.0.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -190,6 +190,48 @@ var listenToNativeEvent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((domEventName
190
190
  // ../rectify-dom-binding/src/clients/RectifyDomProperties.ts
191
191
  var isEvent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((k) => k.startsWith("on"), "isEvent");
192
192
  var isProperty = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((k) => k !== "children" && k !== "ref" && !isEvent(k), "isProperty");
193
+ var SVG_NS = "http://www.w3.org/2000/svg";
194
+ var SVG_CAMEL_ATTRS = /* @__PURE__ */ new Set([
195
+ "viewBox",
196
+ "preserveAspectRatio",
197
+ "gradientTransform",
198
+ "gradientUnits",
199
+ "patternTransform",
200
+ "patternUnits",
201
+ "patternContentUnits",
202
+ "clipPathUnits",
203
+ "markerUnits",
204
+ "markerWidth",
205
+ "markerHeight",
206
+ "refX",
207
+ "refY",
208
+ "textLength",
209
+ "startOffset",
210
+ "baseFrequency",
211
+ "numOctaves",
212
+ "stdDeviation",
213
+ "filterUnits",
214
+ "primitiveUnits",
215
+ "tableValues",
216
+ "kernelMatrix",
217
+ "kernelUnitLength",
218
+ "targetX",
219
+ "targetY",
220
+ "xChannelSelector",
221
+ "yChannelSelector",
222
+ "diffuseConstant",
223
+ "surfaceScale",
224
+ "specularConstant",
225
+ "specularExponent",
226
+ "limitingConeAngle",
227
+ "pointsAtX",
228
+ "pointsAtY",
229
+ "pointsAtZ",
230
+ "repeatX",
231
+ "repeatY"
232
+ ]);
233
+ var camelToKebab = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((s) => s.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()), "camelToKebab");
234
+ var svgAttrName = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((k) => SVG_CAMEL_ATTRS.has(k) ? k : camelToKebab(k), "svgAttrName");
193
235
  var unitlessProperties = /* @__PURE__ */ new Set([
194
236
  "zIndex",
195
237
  "opacity",
@@ -212,14 +254,16 @@ function convertStyleObjectToString(styleObj) {
212
254
  chunkAJJIEZ7G_cjs.__name(convertStyleObjectToString, "convertStyleObjectToString");
213
255
  var applyPropsToDom = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((node, prevProps = {}, nextProps = {}) => {
214
256
  const element = node;
257
+ const isSvg = element.namespaceURI === SVG_NS;
215
258
  const eventNode = getEventHandlerListeners(element) || /* @__PURE__ */ new Map();
216
259
  for (const k in prevProps) {
217
260
  if (isEvent(k) && !(k in nextProps)) {
218
261
  eventNode.delete(k);
219
262
  }
220
263
  if (isProperty(k) && !(k in nextProps)) {
264
+ const attrName = isSvg ? svgAttrName(k) : k;
221
265
  element[k] = "";
222
- element.removeAttribute(k);
266
+ element.removeAttribute(attrName);
223
267
  }
224
268
  }
225
269
  for (const k in nextProps) {
@@ -229,13 +273,22 @@ var applyPropsToDom = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((node, prevProps
229
273
  eventNode.set(k, nextProps[k]);
230
274
  }
231
275
  } else if (k === "style") {
232
- element.setAttribute("style", convertStyleObjectToString(nextProps[k]));
276
+ if (typeof nextProps[k] === "string") {
277
+ element.setAttribute("style", nextProps[k]);
278
+ } else {
279
+ element.setAttribute("style", convertStyleObjectToString(nextProps[k]));
280
+ }
233
281
  } else {
234
282
  const v = nextProps[k];
235
- if (k === "className") element.setAttribute("class", v ?? "");
236
- else if (v === false || v === null || v === void 0)
237
- element.removeAttribute(k);
238
- else element.setAttribute(k, String(v));
283
+ if (k === "className") {
284
+ element.setAttribute("class", v ?? "");
285
+ } else if (v === false || v === null || v === void 0) {
286
+ const attrName = isSvg ? svgAttrName(k) : k;
287
+ element.removeAttribute(attrName);
288
+ } else {
289
+ const attrName = isSvg ? svgAttrName(k) : k;
290
+ element.setAttribute(attrName, String(v));
291
+ }
239
292
  }
240
293
  }
241
294
  setEventHandlerListeners(element, eventNode);
@@ -247,6 +300,7 @@ var PlacementFlag = 1 << 0;
247
300
  var UpdateFlag = 1 << 1;
248
301
  var DeletionFlag = 1 << 2;
249
302
  var MoveFlag = 1 << 3;
303
+ var RefFlag = 1 << 4;
250
304
 
251
305
  // ../rectify-reconciler/src/RectifyFiberLanes.ts
252
306
  var NoLanes = 0;
@@ -258,12 +312,15 @@ var IdleLane = 16;
258
312
 
259
313
  // ../rectify-reconciler/src/RectifyFiberWorkTags.ts
260
314
  var FunctionComponent = /* @__PURE__ */ Symbol.for("rectify.function_component");
315
+ var ClassComponent = /* @__PURE__ */ Symbol.for("rectify.class_component");
261
316
  var HostComponent = /* @__PURE__ */ Symbol.for("rectify.host_component");
262
317
  var HostText = /* @__PURE__ */ Symbol.for("rectify.host_text");
263
318
  var HostRoot = /* @__PURE__ */ Symbol.for("rectify.host_root");
264
319
  var FragmentComponent = /* @__PURE__ */ Symbol.for("rectify.fragment_component");
265
320
  var ContextProvider = /* @__PURE__ */ Symbol.for("rectify.context_provider");
266
321
  var MemoComponent = /* @__PURE__ */ Symbol.for("rectify.memo_component");
322
+ var LazyComponent = /* @__PURE__ */ Symbol.for("rectify.lazy_component");
323
+ var SuspenseComponent = /* @__PURE__ */ Symbol.for("rectify.suspense_component");
267
324
  var addFlagToFiber = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber, flag) => {
268
325
  if (hasFlagOnFiber(fiber, flag)) return;
269
326
  fiber.flags |= flag;
@@ -285,6 +342,15 @@ var getFiberTagFromElement = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((element)
285
342
  if (shared.isFunction(element.type) && element.type?._isMemo === true) {
286
343
  return MemoComponent;
287
344
  }
345
+ if (element.type?._isSuspense === true) {
346
+ return SuspenseComponent;
347
+ }
348
+ if (element.type?._isLazy === true) {
349
+ return LazyComponent;
350
+ }
351
+ if (element.type?._isClassComponent === true) {
352
+ return ClassComponent;
353
+ }
288
354
  return shared.isFunction(element.type) ? FunctionComponent : HostComponent;
289
355
  case shared.RECTIFY_TEXT_TYPE:
290
356
  return HostText;
@@ -294,12 +360,53 @@ var getFiberTagFromElement = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((element)
294
360
  return null;
295
361
  }
296
362
  }, "getFiberTagFromElement");
363
+ var SVG_TAGS = /* @__PURE__ */ new Set([
364
+ "svg",
365
+ "circle",
366
+ "ellipse",
367
+ "line",
368
+ "path",
369
+ "polygon",
370
+ "polyline",
371
+ "rect",
372
+ "g",
373
+ "defs",
374
+ "use",
375
+ "symbol",
376
+ "clipPath",
377
+ "mask",
378
+ "pattern",
379
+ "linearGradient",
380
+ "radialGradient",
381
+ "stop",
382
+ "marker",
383
+ "image",
384
+ "text",
385
+ "tspan",
386
+ "textPath",
387
+ "foreignObject",
388
+ "animate",
389
+ "animateMotion",
390
+ "animateTransform",
391
+ "feBlend",
392
+ "feColorMatrix",
393
+ "feComposite",
394
+ "feGaussianBlur",
395
+ "feOffset",
396
+ "feMerge",
397
+ "feMergeNode",
398
+ "feTurbulence",
399
+ "feFlood"
400
+ ]);
401
+ var SVG_NS2 = "http://www.w3.org/2000/svg";
297
402
  var createDomElementFromFiber = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
298
403
  switch (fiber.workTag) {
299
404
  case HostText:
300
405
  return document.createTextNode(fiber.pendingProps);
301
- default:
302
- return document.createElement(fiber.type);
406
+ default: {
407
+ const tag = fiber.type;
408
+ return SVG_TAGS.has(tag) ? document.createElementNS(SVG_NS2, tag) : document.createElement(tag);
409
+ }
303
410
  }
304
411
  }, "createDomElementFromFiber");
305
412
  var getParentDom = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
@@ -329,8 +436,10 @@ chunkAJJIEZ7G_cjs.__name(findFirstHostNode, "findFirstHostNode");
329
436
  function getHostSibling(fiber) {
330
437
  let sibling = fiber.sibling;
331
438
  while (sibling) {
332
- const node = findFirstHostNode(sibling);
333
- if (node) return node;
439
+ if (!(sibling.flags & PlacementFlag)) {
440
+ const node = findFirstHostNode(sibling);
441
+ if (node) return node;
442
+ }
334
443
  sibling = sibling.sibling;
335
444
  }
336
445
  return null;
@@ -361,13 +470,15 @@ var createFiber = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((workTag, pendingProp
361
470
  sibling: null,
362
471
  return: null,
363
472
  stateNode: null,
473
+ classInstance: null,
364
474
  deletions: null,
365
475
  alternate: null,
366
476
  lanes: NoLanes,
367
477
  childLanes: NoLanes,
368
478
  subtreeFlags: NoFlags,
369
479
  flags: NoFlags,
370
- memoizedState: null
480
+ memoizedState: null,
481
+ refCleanup: null
371
482
  };
372
483
  }, "createFiber");
373
484
  var createHostRootFiber = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((containerDom) => {
@@ -394,6 +505,8 @@ var createWorkInProgress = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((current, pe
394
505
  }
395
506
  wip.memoizedProps = current.memoizedProps;
396
507
  wip.memoizedState = current.memoizedState;
508
+ wip.classInstance = current.classInstance;
509
+ wip.refCleanup = current.refCleanup;
397
510
  wip.return = current.return;
398
511
  wip.child = current.child;
399
512
  wip.sibling = current.sibling;
@@ -419,6 +532,88 @@ var getScheduledFiberRoot = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
419
532
  return instance.fiberRoot;
420
533
  }, "getScheduledFiberRoot");
421
534
 
535
+ // ../rectify-reconciler/src/RectifyFiberScheduler.ts
536
+ var FRAME_BUDGET_MS = 5;
537
+ var frameStart = 0;
538
+ var shouldYield = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => performance.now() - frameStart > FRAME_BUDGET_MS, "shouldYield");
539
+ var doWork = null;
540
+ var setWorkCallback = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((cb) => {
541
+ doWork = cb;
542
+ }, "setWorkCallback");
543
+ var resumeCursor = null;
544
+ var setResumeCursor = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
545
+ resumeCursor = fiber;
546
+ }, "setResumeCursor");
547
+ var getResumeCursor = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => resumeCursor, "getResumeCursor");
548
+ var clearResumeCursor = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
549
+ resumeCursor = null;
550
+ }, "clearResumeCursor");
551
+ var pendingLanes = NoLanes;
552
+ var scheduleRenderLane = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((lane) => {
553
+ pendingLanes |= lane;
554
+ if (lane & (SyncLane | InputLane)) {
555
+ scheduleMicrotask();
556
+ } else if (lane & DefaultLane) {
557
+ scheduleMessageTask();
558
+ } else if (lane & TransitionLane) {
559
+ scheduleTimeout();
560
+ } else if (lane & IdleLane) {
561
+ scheduleIdle();
562
+ }
563
+ }, "scheduleRenderLane");
564
+ var flush = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((mask) => {
565
+ const lanes = pendingLanes & mask;
566
+ if (!lanes) return;
567
+ pendingLanes &= ~lanes;
568
+ frameStart = performance.now();
569
+ doWork?.(lanes);
570
+ }, "flush");
571
+ var MICROTASK_MASK = SyncLane | InputLane;
572
+ var microtaskScheduled = false;
573
+ var scheduleMicrotask = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
574
+ if (microtaskScheduled) return;
575
+ microtaskScheduled = true;
576
+ queueMicrotask(() => {
577
+ microtaskScheduled = false;
578
+ flush(MICROTASK_MASK);
579
+ });
580
+ }, "scheduleMicrotask");
581
+ var DEFAULT_MASK = DefaultLane;
582
+ var mc = new MessageChannel();
583
+ var mcScheduled = false;
584
+ mc.port1.onmessage = () => {
585
+ mcScheduled = false;
586
+ flush(DEFAULT_MASK);
587
+ };
588
+ var scheduleMessageTask = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
589
+ if (mcScheduled) return;
590
+ mcScheduled = true;
591
+ mc.port2.postMessage(null);
592
+ }, "scheduleMessageTask");
593
+ var TRANSITION_MASK = TransitionLane;
594
+ var timeoutHandle = null;
595
+ var scheduleTimeout = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
596
+ if (timeoutHandle !== null) return;
597
+ timeoutHandle = setTimeout(() => {
598
+ timeoutHandle = null;
599
+ flush(TRANSITION_MASK);
600
+ }, 0);
601
+ }, "scheduleTimeout");
602
+ var IDLE_MASK = IdleLane;
603
+ var idleHandle = null;
604
+ var scheduleIdle = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
605
+ if (idleHandle !== null) return;
606
+ const run = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
607
+ idleHandle = null;
608
+ flush(IDLE_MASK);
609
+ }, "run");
610
+ if (typeof requestIdleCallback !== "undefined") {
611
+ idleHandle = requestIdleCallback(run, { timeout: 300 });
612
+ } else {
613
+ idleHandle = setTimeout(run, 300);
614
+ }
615
+ }, "scheduleIdle");
616
+
422
617
  // ../rectify-hook/src/RectifyHookRenderingFiber.ts
423
618
  var instance2 = {
424
619
  fiberRendering: null,
@@ -464,10 +659,10 @@ var prepareToUseHooks = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
464
659
  var finishUsingHooks = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
465
660
  setFiberRendering(null);
466
661
  }, "finishUsingHooks");
467
- var withHooks = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip, Component) => {
662
+ var withHooks = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip, Component2) => {
468
663
  const NewComponent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((props) => {
469
664
  prepareToUseHooks(wip);
470
- const result = Component(props);
665
+ const result = Component2(props);
471
666
  finishUsingHooks();
472
667
  return result;
473
668
  }, "NewComponent");
@@ -482,23 +677,14 @@ function useState(initialState) {
482
677
  }
483
678
  const hookIndex = getHookIndex();
484
679
  nextHookIndex();
485
- let state = fiber.memoizedState;
486
- let prevHook = null;
487
- for (let i = 0; i < hookIndex; i++) {
488
- prevHook = state;
489
- state = state?.next ?? null;
490
- }
680
+ let { hook: state, prevHook } = getHookSlot(fiber, hookIndex);
491
681
  if (!state) {
492
682
  state = {
493
683
  memoizedState: getInitialState(initialState),
494
684
  queue: null,
495
685
  next: null
496
686
  };
497
- if (prevHook) {
498
- prevHook.next = state;
499
- } else {
500
- fiber.memoizedState = state;
501
- }
687
+ attachHook(fiber, state, prevHook);
502
688
  }
503
689
  let update = state.queue;
504
690
  while (update) {
@@ -523,6 +709,42 @@ function useState(initialState) {
523
709
  }
524
710
  chunkAJJIEZ7G_cjs.__name(useState, "useState");
525
711
  var RectifyHookUseState_default = useState;
712
+ function useReducer(reducer, initialArg, init) {
713
+ const fiber = getFiberRendering();
714
+ if (!fiber) {
715
+ throw new Error("useReducer must be used within a function component.");
716
+ }
717
+ const hookIndex = getHookIndex();
718
+ nextHookIndex();
719
+ let { hook, prevHook } = getHookSlot(fiber, hookIndex);
720
+ if (!hook) {
721
+ const initialState = shared.isFunction(init) ? init(initialArg) : initialArg;
722
+ hook = { memoizedState: initialState, queue: null, next: null };
723
+ attachHook(fiber, hook, prevHook);
724
+ }
725
+ let update = hook.queue;
726
+ while (update) {
727
+ hook.memoizedState = reducer(hook.memoizedState, update.action);
728
+ update = update.next;
729
+ }
730
+ hook.queue = null;
731
+ const dispatch = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((action) => {
732
+ const update2 = { action, next: null };
733
+ if (!hook.queue) {
734
+ hook.queue = update2;
735
+ } else {
736
+ let last = hook.queue;
737
+ while (last.next) {
738
+ last = last.next;
739
+ }
740
+ last.next = update2;
741
+ }
742
+ scheduleRerender(fiber);
743
+ }, "dispatch");
744
+ return [hook.memoizedState, dispatch];
745
+ }
746
+ chunkAJJIEZ7G_cjs.__name(useReducer, "useReducer");
747
+ var RectifyHookUseReducer_default = useReducer;
526
748
 
527
749
  // ../rectify-hook/src/RectifyHookDeps.ts
528
750
  var depsChanged = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((prev, next) => {
@@ -633,20 +855,11 @@ function useRef(initialValue) {
633
855
  }
634
856
  const hookIndex = getHookIndex();
635
857
  nextHookIndex();
636
- let hook = fiber.memoizedState;
637
- let prevHook = null;
638
- for (let i = 0; i < hookIndex; i++) {
639
- prevHook = hook;
640
- hook = hook?.next ?? null;
641
- }
858
+ const { hook, prevHook } = getHookSlot(fiber, hookIndex);
642
859
  if (!hook) {
643
860
  const ref = { current: initialValue };
644
861
  const newHook = { memoizedState: ref, queue: null, next: null };
645
- if (prevHook) {
646
- prevHook.next = newHook;
647
- } else {
648
- fiber.memoizedState = newHook;
649
- }
862
+ attachHook(fiber, newHook, prevHook);
650
863
  return ref;
651
864
  }
652
865
  return hook.memoizedState;
@@ -662,20 +875,10 @@ function useMemo(factory, deps) {
662
875
  }
663
876
  const hookIndex = getHookIndex();
664
877
  nextHookIndex();
665
- let hook = fiber.memoizedState;
666
- let prevHook = null;
667
- for (let i = 0; i < hookIndex; i++) {
668
- prevHook = hook;
669
- hook = hook?.next ?? null;
670
- }
878
+ const { hook, prevHook } = getHookSlot(fiber, hookIndex);
671
879
  if (!hook) {
672
880
  const state = { value: factory(), deps };
673
- const newHook = { memoizedState: state, queue: null, next: null };
674
- if (prevHook) {
675
- prevHook.next = newHook;
676
- } else {
677
- fiber.memoizedState = newHook;
678
- }
881
+ attachHook(fiber, { memoizedState: state, queue: null, next: null }, prevHook);
679
882
  return state.value;
680
883
  }
681
884
  const prev = hook.memoizedState;
@@ -762,6 +965,30 @@ function clearContextSubscriptions(fiber) {
762
965
  }
763
966
  chunkAJJIEZ7G_cjs.__name(clearContextSubscriptions, "clearContextSubscriptions");
764
967
 
968
+ // ../rectify-hook/src/RectifyHookUseId.ts
969
+ var _idCounter = 0;
970
+ var generateId = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => `_r${(_idCounter++).toString(36)}_`, "generateId");
971
+ var useId = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
972
+ const fiber = getFiberRendering();
973
+ if (!fiber) {
974
+ throw new Error("useId must be used within a function component.");
975
+ }
976
+ const hookIndex = getHookIndex();
977
+ nextHookIndex();
978
+ const { hook, prevHook } = getHookSlot(fiber, hookIndex);
979
+ if (!hook) {
980
+ const newHook = {
981
+ memoizedState: generateId(),
982
+ queue: null,
983
+ next: null
984
+ };
985
+ attachHook(fiber, newHook, prevHook);
986
+ return newHook.memoizedState;
987
+ }
988
+ return hook.memoizedState;
989
+ }, "useId");
990
+ var RectifyHookUseId_default = useId;
991
+
765
992
  // ../rectify-reconciler/src/RectifyFiberRenderPriority.ts
766
993
  var currentEventPriority = DefaultLane;
767
994
  var setCurrentEventPriority = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((lane) => {
@@ -776,156 +1003,228 @@ var setCurrentRenderingLanes = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((lanes)
776
1003
  currentRenderingLanes = lanes;
777
1004
  }, "setCurrentRenderingLanes");
778
1005
  var getCurrentLanePriority = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => currentRenderingLanes, "getCurrentLanePriority");
779
-
780
- // ../rectify-reconciler/src/RectifyFiberScheduler.ts
781
- var FRAME_BUDGET_MS = 5;
782
- var frameStart = 0;
783
- var shouldYield = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => performance.now() - frameStart > FRAME_BUDGET_MS, "shouldYield");
784
- var doWork = null;
785
- var setWorkCallback = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((cb) => {
786
- doWork = cb;
787
- }, "setWorkCallback");
788
- var resumeCursor = null;
789
- var setResumeCursor = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
790
- resumeCursor = fiber;
791
- }, "setResumeCursor");
792
- var getResumeCursor = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => resumeCursor, "getResumeCursor");
793
- var clearResumeCursor = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
794
- resumeCursor = null;
795
- }, "clearResumeCursor");
796
- var pendingLanes = NoLanes;
797
- var scheduleRenderLane = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((lane) => {
798
- pendingLanes |= lane;
799
- if (lane & (SyncLane | InputLane)) {
800
- scheduleMicrotask();
801
- } else if (lane & DefaultLane) {
802
- scheduleMessageTask();
803
- } else if (lane & TransitionLane) {
804
- scheduleTimeout();
805
- } else if (lane & IdleLane) {
806
- scheduleIdle();
807
- }
808
- }, "scheduleRenderLane");
809
- var flush = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((mask) => {
810
- const lanes = pendingLanes & mask;
811
- if (!lanes) return;
812
- pendingLanes &= ~lanes;
813
- frameStart = performance.now();
814
- doWork?.(lanes);
815
- }, "flush");
816
- var MICROTASK_MASK = SyncLane | InputLane;
817
- var microtaskScheduled = false;
818
- var scheduleMicrotask = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
819
- if (microtaskScheduled) return;
820
- microtaskScheduled = true;
821
- queueMicrotask(() => {
822
- microtaskScheduled = false;
823
- flush(MICROTASK_MASK);
824
- });
825
- }, "scheduleMicrotask");
826
- var DEFAULT_MASK = DefaultLane;
827
- var mc = new MessageChannel();
828
- var mcScheduled = false;
829
- mc.port1.onmessage = () => {
830
- mcScheduled = false;
831
- flush(DEFAULT_MASK);
832
- };
833
- var scheduleMessageTask = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
834
- if (mcScheduled) return;
835
- mcScheduled = true;
836
- mc.port2.postMessage(null);
837
- }, "scheduleMessageTask");
838
- var TRANSITION_MASK = TransitionLane;
839
- var timeoutHandle = null;
840
- var scheduleTimeout = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
841
- if (timeoutHandle !== null) return;
842
- timeoutHandle = setTimeout(() => {
843
- timeoutHandle = null;
844
- flush(TRANSITION_MASK);
845
- }, 0);
846
- }, "scheduleTimeout");
847
- var IDLE_MASK = IdleLane;
848
- var idleHandle = null;
849
- var scheduleIdle = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
850
- if (idleHandle !== null) return;
851
- const run = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
852
- idleHandle = null;
853
- flush(IDLE_MASK);
854
- }, "run");
855
- if (typeof requestIdleCallback !== "undefined") {
856
- idleHandle = requestIdleCallback(run, { timeout: 300 });
857
- } else {
858
- idleHandle = setTimeout(run, 300);
859
- }
860
- }, "scheduleIdle");
861
-
862
- // ../rectify-reconciler/src/RectifyFiberWorkLoop.ts
863
- var swapCurrentForWip = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((current, wip) => {
864
- const parent = wip.return;
865
- if (!parent) return;
866
- if (parent.child === current) {
867
- parent.child = wip;
868
- return;
869
- }
870
- let prevSibling = parent.child;
871
- while (prevSibling && prevSibling.sibling !== current) {
872
- prevSibling = prevSibling.sibling;
1006
+ var reuseOrCreate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((oldFiber, element, wip) => {
1007
+ const newFiber = createWorkInProgress(oldFiber, element.props);
1008
+ if (hasPropsChanged(oldFiber.memoizedProps, element.props)) {
1009
+ addFlagToFiber(newFiber, UpdateFlag);
873
1010
  }
874
- if (prevSibling) prevSibling.sibling = wip;
875
- }, "swapCurrentForWip");
876
- var workLoop = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wipRoot) => {
877
- let workInProgress = wipRoot;
878
- while (workInProgress) {
879
- const next = beginWork(workInProgress);
880
- if (next) {
881
- workInProgress = next;
882
- } else {
883
- workInProgress = completeUnitOfWork(workInProgress, wipRoot);
884
- }
1011
+ if ((oldFiber.memoizedProps?.ref ?? null) !== (element.props?.ref ?? null)) {
1012
+ addFlagToFiber(newFiber, RefFlag);
885
1013
  }
886
- }, "workLoop");
887
- var workLoopConcurrent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wipRoot) => {
888
- let workInProgress = getResumeCursor() ?? wipRoot;
889
- clearResumeCursor();
890
- while (workInProgress && !shouldYield()) {
891
- const next = beginWork(workInProgress);
892
- if (next) {
893
- workInProgress = next;
1014
+ newFiber.return = wip;
1015
+ return newFiber;
1016
+ }, "reuseOrCreate");
1017
+ var createAndPlace = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((element, wip) => {
1018
+ const newFiber = createFiberFromRectifyElement(element);
1019
+ newFiber.type = element.type;
1020
+ addFlagToFiber(newFiber, PlacementFlag);
1021
+ newFiber.return = wip;
1022
+ return newFiber;
1023
+ }, "createAndPlace");
1024
+ var appendFiber = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber, prev, index, wip) => {
1025
+ fiber.index = index;
1026
+ if (!prev) wip.child = fiber;
1027
+ else prev.sibling = fiber;
1028
+ return fiber;
1029
+ }, "appendFiber");
1030
+ var buildOldFiberStructures = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((firstRemaining) => {
1031
+ const keyedMap = /* @__PURE__ */ new Map();
1032
+ const unkeyedByType = /* @__PURE__ */ new Map();
1033
+ let fiber = firstRemaining;
1034
+ while (fiber) {
1035
+ if (fiber.key !== null && fiber.key !== void 0) {
1036
+ keyedMap.set(fiber.key, fiber);
894
1037
  } else {
895
- workInProgress = completeUnitOfWork(workInProgress, wipRoot);
1038
+ const pool = unkeyedByType.get(fiber.type);
1039
+ if (pool) pool.push(fiber);
1040
+ else unkeyedByType.set(fiber.type, [fiber]);
896
1041
  }
1042
+ fiber = fiber.sibling;
897
1043
  }
898
- if (workInProgress !== null) {
899
- setResumeCursor(workInProgress);
900
- return false;
1044
+ return { keyedMap, unkeyedByType };
1045
+ }, "buildOldFiberStructures");
1046
+ var reconcileSequential = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((state, firstOldFiber) => {
1047
+ let oldFiber = firstOldFiber;
1048
+ for (let i = 0; i < state.newElements.length; i++) {
1049
+ const element = state.newElements[i];
1050
+ const { key: elementKey = null, type: elementType } = element;
1051
+ if (!oldFiber) return { stoppedAt: i, oldFiber: null };
1052
+ if (oldFiber.key !== elementKey) return { stoppedAt: i, oldFiber };
1053
+ if (oldFiber.type === elementType) {
1054
+ state.prev = appendFiber(
1055
+ reuseOrCreate(oldFiber, element, state.wip),
1056
+ state.prev,
1057
+ state.index++,
1058
+ state.wip
1059
+ );
1060
+ } else if (elementKey !== null) {
1061
+ addFlagToFiber(oldFiber, DeletionFlag);
1062
+ state.deletions.push(oldFiber);
1063
+ state.prev = appendFiber(
1064
+ createAndPlace(element, state.wip),
1065
+ state.prev,
1066
+ state.index++,
1067
+ state.wip
1068
+ );
1069
+ } else {
1070
+ return { stoppedAt: i, oldFiber };
1071
+ }
1072
+ oldFiber = oldFiber.sibling;
901
1073
  }
902
- return true;
903
- }, "workLoopConcurrent");
904
- var workLoopOnFiberLanes = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wipRoot, renderLanes) => {
905
- if (wipRoot.lanes & renderLanes) {
906
- const wip = createWorkInProgress(wipRoot, wipRoot.pendingProps);
907
- swapCurrentForWip(wipRoot, wip);
908
- const isSync = !!(renderLanes & (SyncLane | InputLane));
909
- let completed;
910
- if (isSync) {
911
- workLoop(wip);
912
- completed = true;
1074
+ return { stoppedAt: state.newElements.length, oldFiber };
1075
+ }, "reconcileSequential");
1076
+ var reconcileKeyed = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((state, startAt, remainingOldFiber) => {
1077
+ const { keyedMap, unkeyedByType } = buildOldFiberStructures(remainingOldFiber);
1078
+ let lastPlacedIndex = 0;
1079
+ for (let i = startAt; i < state.newElements.length; i++) {
1080
+ const element = state.newElements[i];
1081
+ const { key: elementKey = null, type: elementType } = element;
1082
+ let matched = null;
1083
+ if (elementKey !== null) {
1084
+ const candidate = keyedMap.get(elementKey) ?? null;
1085
+ if (candidate && candidate.type === elementType) {
1086
+ keyedMap.delete(elementKey);
1087
+ matched = candidate;
1088
+ }
913
1089
  } else {
914
- completed = workLoopConcurrent(wip);
1090
+ const pool = unkeyedByType.get(elementType);
1091
+ if (pool?.length) matched = pool.shift();
1092
+ }
1093
+ if (matched) {
1094
+ const newFiber = reuseOrCreate(matched, element, state.wip);
1095
+ if (matched.index < lastPlacedIndex) {
1096
+ addFlagToFiber(newFiber, MoveFlag);
1097
+ } else {
1098
+ lastPlacedIndex = matched.index;
1099
+ }
1100
+ state.prev = appendFiber(newFiber, state.prev, state.index++, state.wip);
1101
+ } else {
1102
+ state.prev = appendFiber(
1103
+ createAndPlace(element, state.wip),
1104
+ state.prev,
1105
+ state.index++,
1106
+ state.wip
1107
+ );
915
1108
  }
916
- if (completed) bubbleFlagsToRoot(wip);
917
- return completed;
918
1109
  }
919
- if (wipRoot.childLanes & renderLanes) {
920
- let child = wipRoot.child;
921
- while (child) {
922
- const done = workLoopOnFiberLanes(child, renderLanes);
923
- if (!done) return false;
924
- child = child.sibling;
1110
+ for (const orphan of keyedMap.values()) {
1111
+ addFlagToFiber(orphan, DeletionFlag);
1112
+ state.deletions.push(orphan);
1113
+ }
1114
+ for (const pool of unkeyedByType.values()) {
1115
+ for (const orphan of pool) {
1116
+ addFlagToFiber(orphan, DeletionFlag);
1117
+ state.deletions.push(orphan);
925
1118
  }
926
1119
  }
927
- return true;
928
- }, "workLoopOnFiberLanes");
1120
+ }, "reconcileKeyed");
1121
+ var toChildArray = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((children) => {
1122
+ if (children == null || typeof children === "boolean") return [];
1123
+ if (shared.isArray(children)) return children;
1124
+ return [children];
1125
+ }, "toChildArray");
1126
+ var reconcileChildren = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip, children) => {
1127
+ const newElements = toChildArray(children).map(shared.createElementFromRectifyNode).filter(shared.isValidRectifyElement);
1128
+ const state = {
1129
+ wip,
1130
+ newElements,
1131
+ deletions: [],
1132
+ prev: null,
1133
+ index: 0
1134
+ };
1135
+ const firstOldFiber = wip.alternate?.child ?? null;
1136
+ const { stoppedAt, oldFiber } = reconcileSequential(state, firstOldFiber);
1137
+ if (stoppedAt < newElements.length) {
1138
+ reconcileKeyed(state, stoppedAt, oldFiber);
1139
+ } else {
1140
+ let leftover = oldFiber;
1141
+ while (leftover) {
1142
+ addFlagToFiber(leftover, DeletionFlag);
1143
+ state.deletions.push(leftover);
1144
+ leftover = leftover.sibling;
1145
+ }
1146
+ }
1147
+ if (state.prev) state.prev.sibling = null;
1148
+ if (state.deletions.length) wip.deletions = state.deletions;
1149
+ }, "reconcileChildren");
1150
+
1151
+ // ../rectify-reconciler/src/RectifyFiberConcurrentUpdate.ts
1152
+ var instance3 = {
1153
+ head: null,
1154
+ tail: null
1155
+ };
1156
+ var enqueueUpdate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((update) => {
1157
+ update.next = null;
1158
+ if (instance3.tail === null) {
1159
+ instance3.head = update;
1160
+ instance3.tail = update;
1161
+ return;
1162
+ }
1163
+ instance3.tail.next = update;
1164
+ instance3.tail = update;
1165
+ }, "enqueueUpdate");
1166
+ var dequeueUpdate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
1167
+ const first = instance3.head;
1168
+ if (first === null) {
1169
+ return null;
1170
+ }
1171
+ instance3.head = first.next;
1172
+ if (instance3.head === null) {
1173
+ instance3.tail = null;
1174
+ }
1175
+ first.next = null;
1176
+ return first;
1177
+ }, "dequeueUpdate");
1178
+ var hasUpdate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => instance3.head !== null, "hasUpdate");
1179
+
1180
+ // ../rectify-reconciler/src/RectifyFiberSuspense.ts
1181
+ var suspendedBoundaries = /* @__PURE__ */ new WeakSet();
1182
+ var stableFiber = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => fiber.alternate ?? fiber, "stableFiber");
1183
+ var isSuspendedBoundary = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => suspendedBoundaries.has(stableFiber(fiber)), "isSuspendedBoundary");
1184
+ var findNearestSuspenseBoundary = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
1185
+ let current = fiber.return;
1186
+ while (current) {
1187
+ if (current.workTag === SuspenseComponent) return current;
1188
+ current = current.return;
1189
+ }
1190
+ return null;
1191
+ }, "findNearestSuspenseBoundary");
1192
+ var handleSuspendedWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((boundary, thenable) => {
1193
+ const stable = stableFiber(boundary);
1194
+ if (suspendedBoundaries.has(stable)) return;
1195
+ suspendedBoundaries.add(stable);
1196
+ boundary.child = null;
1197
+ boundary.deletions = null;
1198
+ thenable.then(
1199
+ () => {
1200
+ suspendedBoundaries.delete(stable);
1201
+ enqueueUpdate({ lanes: DefaultLane, fiber: stable, next: null });
1202
+ scheduleRenderLane(DefaultLane);
1203
+ },
1204
+ () => {
1205
+ suspendedBoundaries.delete(stable);
1206
+ }
1207
+ );
1208
+ }, "handleSuspendedWork");
1209
+ var isThenable = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((value) => value !== null && typeof value === "object" && typeof value.then === "function", "isThenable");
1210
+
1211
+ // ../rectify-reconciler/src/RectifyFiberBeginWork.ts
1212
+ var hasNoPendingWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => !(wip.lanes & getCurrentLanePriority()), "hasNoPendingWork");
1213
+ var isUpdate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => wip.alternate !== null, "isUpdate");
1214
+ var flushStateQueue = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((currentState, props, queue) => {
1215
+ let state = currentState;
1216
+ for (const update of queue) {
1217
+ const partial = typeof update === "function" ? update(state, props) : update;
1218
+ state = { ...state, ...partial };
1219
+ }
1220
+ return state;
1221
+ }, "flushStateQueue");
1222
+ var renderFunctionComponent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip, Component2) => {
1223
+ const ComponentWithHooks = withHooks(wip, Component2);
1224
+ const children = ComponentWithHooks(wip.pendingProps);
1225
+ reconcileChildren(wip, children);
1226
+ }, "renderFunctionComponent");
1227
+ var getProviderContext = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => wip.type._context, "getProviderContext");
929
1228
  var cloneChildFibers = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
930
1229
  const currentChild = wip.alternate?.child ?? null;
931
1230
  if (!currentChild) {
@@ -948,14 +1247,6 @@ var cloneChildFibers = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
948
1247
  if (prevNewChild) prevNewChild.sibling = null;
949
1248
  return wip.child;
950
1249
  }, "cloneChildFibers");
951
- var hasNoPendingWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => !(wip.lanes & getCurrentLanePriority()), "hasNoPendingWork");
952
- var isUpdate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => wip.alternate !== null, "isUpdate");
953
- var renderFunctionComponent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip, Component) => {
954
- const ComponentWithHooks = withHooks(wip, Component);
955
- const children = ComponentWithHooks(wip.pendingProps);
956
- reconcileChildren(wip, children);
957
- }, "renderFunctionComponent");
958
- var getProviderContext = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => wip.type._context, "getProviderContext");
959
1250
  var beginWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
960
1251
  switch (wip.workTag) {
961
1252
  case MemoComponent: {
@@ -970,12 +1261,12 @@ var beginWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
970
1261
  break;
971
1262
  }
972
1263
  case FunctionComponent: {
973
- const Component = wip.type;
974
- if (!shared.isFunction(Component)) break;
1264
+ const Component2 = wip.type;
1265
+ if (!shared.isFunction(Component2)) break;
975
1266
  if (isUpdate(wip) && hasNoPendingWork(wip) && shared.shallowEqual(wip.memoizedProps, wip.pendingProps)) {
976
1267
  return cloneChildFibers(wip);
977
1268
  }
978
- renderFunctionComponent(wip, Component);
1269
+ renderFunctionComponent(wip, Component2);
979
1270
  break;
980
1271
  }
981
1272
  case FragmentComponent:
@@ -998,33 +1289,80 @@ var beginWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
998
1289
  }
999
1290
  break;
1000
1291
  }
1001
- }
1002
- return wip.child;
1003
- }, "beginWork");
1004
- var completeUnitOfWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((unit, stopAt) => {
1005
- let completed = unit;
1006
- while (completed) {
1007
- bubbleProperties(completed);
1008
- if (completed === stopAt) {
1009
- return null;
1292
+ case SuspenseComponent: {
1293
+ const children = isSuspendedBoundary(wip) ? wip.pendingProps?.fallback : wip.pendingProps?.children;
1294
+ reconcileChildren(wip, children);
1295
+ break;
1010
1296
  }
1011
- if (completed.sibling) {
1012
- return completed.sibling;
1297
+ case ClassComponent: {
1298
+ const Ctor = wip.type;
1299
+ const isMount = !wip.classInstance;
1300
+ if (isMount) {
1301
+ const instance4 = new Ctor(wip.pendingProps);
1302
+ instance4._fiber = wip;
1303
+ wip.classInstance = instance4;
1304
+ if (instance4._pendingStateQueue?.length) {
1305
+ instance4.state = flushStateQueue(
1306
+ instance4.state,
1307
+ instance4.props,
1308
+ instance4._pendingStateQueue
1309
+ );
1310
+ instance4._pendingStateQueue = [];
1311
+ }
1312
+ } else {
1313
+ const instance4 = wip.classInstance;
1314
+ if (hasNoPendingWork(wip) && !instance4._pendingStateQueue?.length && shared.shallowEqual(instance4.props, wip.pendingProps)) {
1315
+ return cloneChildFibers(wip);
1316
+ }
1317
+ instance4._prevProps = instance4.props;
1318
+ instance4._prevState = { ...instance4.state };
1319
+ if (instance4._pendingStateQueue?.length) {
1320
+ instance4.state = flushStateQueue(
1321
+ instance4.state,
1322
+ wip.pendingProps,
1323
+ instance4._pendingStateQueue
1324
+ );
1325
+ instance4._pendingStateQueue = [];
1326
+ }
1327
+ instance4.props = wip.pendingProps;
1328
+ instance4._fiber = wip;
1329
+ if (isUpdate(wip) && typeof instance4.shouldComponentUpdate === "function" && !instance4.shouldComponentUpdate(wip.pendingProps, instance4.state)) {
1330
+ return cloneChildFibers(wip);
1331
+ }
1332
+ }
1333
+ const children = wip.classInstance.render();
1334
+ reconcileChildren(wip, children);
1335
+ break;
1336
+ }
1337
+ case LazyComponent: {
1338
+ const lazy2 = wip.type;
1339
+ if (lazy2._status === "resolved") {
1340
+ renderFunctionComponent(wip, lazy2._result);
1341
+ break;
1342
+ }
1343
+ if (lazy2._status === "rejected") {
1344
+ throw lazy2._result;
1345
+ }
1346
+ if (lazy2._status === "uninitialized") {
1347
+ lazy2._status = "pending";
1348
+ lazy2._promise = lazy2._factory().then(
1349
+ (module) => {
1350
+ lazy2._status = "resolved";
1351
+ lazy2._result = module?.default ?? module;
1352
+ },
1353
+ (error) => {
1354
+ lazy2._status = "rejected";
1355
+ lazy2._result = error;
1356
+ }
1357
+ );
1358
+ }
1359
+ throw lazy2._promise;
1013
1360
  }
1014
- completed = completed.return;
1015
- }
1016
- return null;
1017
- }, "completeUnitOfWork");
1018
- var bubbleFlagsToRoot = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
1019
- let current = wip;
1020
- let parent = current.return;
1021
- while (parent) {
1022
- parent.subtreeFlags |= current.flags | current.subtreeFlags;
1023
- parent.childLanes |= current.lanes | current.childLanes;
1024
- current = parent;
1025
- parent = parent.return;
1026
1361
  }
1027
- }, "bubbleFlagsToRoot");
1362
+ return wip.child;
1363
+ }, "beginWork");
1364
+
1365
+ // ../rectify-reconciler/src/RectifyFiberCompleteWork.ts
1028
1366
  var bubbleProperties = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
1029
1367
  wip.lanes &= ~getCurrentLanePriority();
1030
1368
  let subtreeFlags = NoFlags;
@@ -1039,164 +1377,151 @@ var bubbleProperties = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
1039
1377
  wip.subtreeFlags = subtreeFlags;
1040
1378
  wip.childLanes = childLanes;
1041
1379
  }, "bubbleProperties");
1042
- var reuseOrCreate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((oldFiber, element, wip) => {
1043
- const newFiber = createWorkInProgress(oldFiber, element.props);
1044
- if (hasPropsChanged(oldFiber.memoizedProps, element.props)) {
1045
- addFlagToFiber(newFiber, UpdateFlag);
1380
+ var bubbleFlagsToRoot = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
1381
+ let current = wip;
1382
+ let parent = current.return;
1383
+ while (parent) {
1384
+ parent.subtreeFlags |= current.flags | current.subtreeFlags;
1385
+ parent.childLanes |= current.lanes | current.childLanes;
1386
+ current = parent;
1387
+ parent = parent.return;
1046
1388
  }
1047
- newFiber.return = wip;
1048
- return newFiber;
1049
- }, "reuseOrCreate");
1050
- var createAndPlace = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((element, wip) => {
1051
- const newFiber = createFiberFromRectifyElement(element);
1052
- newFiber.type = element.type;
1053
- addFlagToFiber(newFiber, PlacementFlag);
1054
- newFiber.return = wip;
1055
- return newFiber;
1056
- }, "createAndPlace");
1057
- var appendFiber = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber, prev, index, wip) => {
1058
- fiber.index = index;
1059
- if (!prev) wip.child = fiber;
1060
- else prev.sibling = fiber;
1061
- return fiber;
1062
- }, "appendFiber");
1063
- var buildOldFiberMap = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((firstRemaining, startIndex) => {
1064
- const map = /* @__PURE__ */ new Map();
1065
- let fiber = firstRemaining;
1066
- let i = startIndex;
1067
- while (fiber) {
1068
- map.set(fiber.key ?? i, fiber);
1069
- fiber = fiber.sibling;
1070
- i++;
1389
+ }, "bubbleFlagsToRoot");
1390
+ var completeUnitOfWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((unit, stopAt) => {
1391
+ let completed = unit;
1392
+ while (completed) {
1393
+ bubbleProperties(completed);
1394
+ if (completed === stopAt) return null;
1395
+ if (completed.sibling) return completed.sibling;
1396
+ completed = completed.return;
1071
1397
  }
1072
- return map;
1073
- }, "buildOldFiberMap");
1074
- var reconcileSequential = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((state, firstOldFiber) => {
1075
- let oldFiber = firstOldFiber;
1076
- let i = 0;
1077
- for (; i < state.newElements.length; i++) {
1078
- const element = state.newElements[i];
1079
- const { key: elementKey = null, type: elementType } = element;
1080
- if (!oldFiber) break;
1081
- if (oldFiber.key !== elementKey) break;
1082
- if (oldFiber.type === elementType) {
1083
- state.prev = appendFiber(reuseOrCreate(oldFiber, element, state.wip), state.prev, state.index++, state.wip);
1084
- } else {
1085
- addFlagToFiber(oldFiber, DeletionFlag);
1086
- state.deletions.push(oldFiber);
1087
- state.prev = appendFiber(createAndPlace(element, state.wip), state.prev, state.index++, state.wip);
1088
- }
1089
- oldFiber = oldFiber.sibling;
1398
+ return null;
1399
+ }, "completeUnitOfWork");
1400
+
1401
+ // ../rectify-reconciler/src/RectifyFiberWorkLoop.ts
1402
+ var swapCurrentForWip = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((current, wip) => {
1403
+ const parent = wip.return;
1404
+ if (!parent) return;
1405
+ if (parent.child === current) {
1406
+ parent.child = wip;
1407
+ return;
1090
1408
  }
1091
- return { stoppedAt: i, oldFiber };
1092
- }, "reconcileSequential");
1093
- var reconcileKeyed = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((state, startAt, remainingOldFiber) => {
1094
- const oldFiberMap = buildOldFiberMap(remainingOldFiber, startAt);
1095
- let lastPlacedIndex = 0;
1096
- for (let i = startAt; i < state.newElements.length; i++) {
1097
- const element = state.newElements[i];
1098
- const { key: elementKey = null, type: elementType } = element;
1099
- const mapKey = elementKey ?? i;
1100
- const matched = oldFiberMap.get(mapKey) ?? null;
1101
- if (matched && matched.type === elementType) {
1102
- oldFiberMap.delete(mapKey);
1103
- const newFiber = reuseOrCreate(matched, element, state.wip);
1104
- if (matched.index < lastPlacedIndex) {
1105
- addFlagToFiber(newFiber, MoveFlag);
1106
- } else {
1107
- lastPlacedIndex = matched.index;
1108
- }
1109
- state.prev = appendFiber(newFiber, state.prev, state.index++, state.wip);
1110
- } else {
1111
- state.prev = appendFiber(createAndPlace(element, state.wip), state.prev, state.index++, state.wip);
1112
- }
1409
+ let prevSibling = parent.child;
1410
+ while (prevSibling && prevSibling.sibling !== current) {
1411
+ prevSibling = prevSibling.sibling;
1113
1412
  }
1114
- for (const orphan of oldFiberMap.values()) {
1115
- addFlagToFiber(orphan, DeletionFlag);
1116
- state.deletions.push(orphan);
1413
+ if (prevSibling) prevSibling.sibling = wip;
1414
+ }, "swapCurrentForWip");
1415
+ var workLoop = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wipRoot) => {
1416
+ let workInProgress = wipRoot;
1417
+ while (workInProgress) {
1418
+ try {
1419
+ const next = beginWork(workInProgress);
1420
+ workInProgress = next ?? completeUnitOfWork(workInProgress, wipRoot);
1421
+ } catch (thrown) {
1422
+ if (isThenable(thrown) && workInProgress) {
1423
+ const boundary = findNearestSuspenseBoundary(workInProgress);
1424
+ if (boundary) {
1425
+ handleSuspendedWork(boundary, thrown);
1426
+ workInProgress = boundary;
1427
+ continue;
1428
+ }
1429
+ }
1430
+ throw thrown;
1431
+ }
1117
1432
  }
1118
- }, "reconcileKeyed");
1119
- var toChildArray = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((children) => {
1120
- if (children == null || typeof children === "boolean") return [];
1121
- if (shared.isArray(children)) return children;
1122
- return [children];
1123
- }, "toChildArray");
1124
- var reconcileChildren = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip, children) => {
1125
- const newElements = toChildArray(children).map(shared.createElementFromRectifyNode).filter(shared.isValidRectifyElement);
1126
- const state = { wip, newElements, deletions: [], prev: null, index: 0 };
1127
- const firstOldFiber = wip.alternate?.child ?? null;
1128
- const { stoppedAt, oldFiber } = reconcileSequential(state, firstOldFiber);
1129
- if (stoppedAt < newElements.length) {
1130
- reconcileKeyed(state, stoppedAt, oldFiber);
1131
- } else {
1132
- let leftover = oldFiber;
1133
- while (leftover) {
1134
- addFlagToFiber(leftover, DeletionFlag);
1135
- state.deletions.push(leftover);
1136
- leftover = leftover.sibling;
1433
+ }, "workLoop");
1434
+ var workLoopConcurrent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wipRoot) => {
1435
+ let workInProgress = getResumeCursor() ?? wipRoot;
1436
+ clearResumeCursor();
1437
+ while (workInProgress && !shouldYield()) {
1438
+ try {
1439
+ const next = beginWork(workInProgress);
1440
+ workInProgress = next ?? completeUnitOfWork(workInProgress, wipRoot);
1441
+ } catch (thrown) {
1442
+ if (isThenable(thrown) && workInProgress) {
1443
+ const boundary = findNearestSuspenseBoundary(workInProgress);
1444
+ if (boundary) {
1445
+ handleSuspendedWork(boundary, thrown);
1446
+ workInProgress = boundary;
1447
+ continue;
1448
+ }
1449
+ }
1450
+ throw thrown;
1137
1451
  }
1138
1452
  }
1139
- if (state.prev) state.prev.sibling = null;
1140
- if (state.deletions.length) wip.deletions = state.deletions;
1141
- }, "reconcileChildren");
1142
-
1143
- // ../rectify-reconciler/src/RectifyFiberCommitWork.ts
1144
- var MutationMask = PlacementFlag | UpdateFlag | MoveFlag;
1145
- var commitWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((finishedWork) => {
1146
- if (finishedWork.deletions?.length) {
1147
- finishedWork.deletions.forEach(removeHostTree);
1148
- finishedWork.deletions = null;
1453
+ if (workInProgress !== null) {
1454
+ setResumeCursor(workInProgress);
1455
+ return false;
1149
1456
  }
1150
- if (finishedWork.flags & MutationMask) {
1151
- commitMutation(finishedWork);
1152
- syncMemoizedProps(finishedWork);
1457
+ return true;
1458
+ }, "workLoopConcurrent");
1459
+ var workLoopOnFiberLanes = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wipRoot, renderLanes) => {
1460
+ if (wipRoot.lanes & renderLanes) {
1461
+ const wip = createWorkInProgress(wipRoot, wipRoot.pendingProps);
1462
+ swapCurrentForWip(wipRoot, wip);
1463
+ const isSync = !!(renderLanes & (SyncLane | InputLane));
1464
+ const completed = isSync ? (workLoop(wip), true) : workLoopConcurrent(wip);
1465
+ if (completed) bubbleFlagsToRoot(wip);
1466
+ return completed;
1153
1467
  }
1154
- if (finishedWork.subtreeFlags & MutationMask) {
1155
- let child = finishedWork.child;
1468
+ if (wipRoot.childLanes & renderLanes) {
1469
+ let child = wipRoot.child;
1156
1470
  while (child) {
1157
- commitWork(child);
1471
+ if (!workLoopOnFiberLanes(child, renderLanes)) return false;
1158
1472
  child = child.sibling;
1159
1473
  }
1160
1474
  }
1161
- finishedWork.flags = NoFlags;
1162
- finishedWork.subtreeFlags = NoFlags;
1163
- }, "commitWork");
1164
- var syncMemoizedProps = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
1165
- wip.memoizedProps = wip.pendingProps;
1166
- }, "syncMemoizedProps");
1475
+ return true;
1476
+ }, "workLoopOnFiberLanes");
1167
1477
  var attachRef = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
1168
1478
  const ref = wip.pendingProps?.ref;
1169
- if (ref && typeof ref === "object" && "current" in ref) {
1479
+ if (!ref) return;
1480
+ if (shared.isFunction(ref)) {
1481
+ const cleanup = ref(wip.stateNode);
1482
+ wip.refCleanup = shared.isFunction(cleanup) ? cleanup : null;
1483
+ } else if (typeof ref === "object" && "current" in ref) {
1170
1484
  ref.current = wip.stateNode;
1171
1485
  }
1172
1486
  }, "attachRef");
1173
1487
  var detachRef = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
1488
+ if (fiber.refCleanup) {
1489
+ fiber.refCleanup();
1490
+ fiber.refCleanup = null;
1491
+ return;
1492
+ }
1174
1493
  const ref = fiber.memoizedProps?.ref;
1175
- if (ref && typeof ref === "object" && "current" in ref) {
1494
+ if (!ref) return;
1495
+ if (typeof ref === "function") {
1496
+ ref(null);
1497
+ } else if (typeof ref === "object" && "current" in ref) {
1176
1498
  ref.current = null;
1177
1499
  }
1178
1500
  }, "detachRef");
1501
+
1502
+ // ../rectify-reconciler/src/RectifyFiberCommitPlacement.ts
1179
1503
  var insertIntoParent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip, node) => {
1180
1504
  const parentDom = getParentDom(wip);
1181
- const before = getHostSibling(wip) ?? (wip.return ? getHostSibling(wip.return) : null);
1182
- if (before) parentDom.insertBefore(node, before);
1183
- else parentDom.appendChild(node);
1505
+ let cursor = wip;
1506
+ while (cursor) {
1507
+ const before = getHostSibling(cursor);
1508
+ if (before) {
1509
+ parentDom.insertBefore(node, before);
1510
+ return;
1511
+ }
1512
+ const parent = cursor.return;
1513
+ if (!parent || parent.workTag === HostComponent || parent.workTag === HostRoot) break;
1514
+ cursor = parent;
1515
+ }
1516
+ parentDom.appendChild(node);
1184
1517
  }, "insertIntoParent");
1185
1518
  var placeNode = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip, node) => {
1186
1519
  insertIntoParent(wip, node);
1187
1520
  precacheFiberNode(wip, node);
1188
1521
  attachRef(wip);
1189
1522
  }, "placeNode");
1190
- var commitMutation = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((childFiber) => {
1191
- switch (childFiber.workTag) {
1192
- case HostComponent:
1193
- commitMutationHostComponent(childFiber);
1194
- break;
1195
- case HostText:
1196
- commitMutationHostText(childFiber);
1197
- break;
1198
- }
1199
- }, "commitMutation");
1523
+
1524
+ // ../rectify-reconciler/src/RectifyFiberCommitMutation.ts
1200
1525
  var commitMutationHostComponent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
1201
1526
  if (!wip.stateNode) {
1202
1527
  const node = createDomElementFromFiber(wip);
@@ -1216,9 +1541,13 @@ var commitMutationHostComponent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip)
1216
1541
  if (hasFlagOnFiber(wip, UpdateFlag)) {
1217
1542
  applyPropsToDom(wip.stateNode, wip.memoizedProps, wip.pendingProps);
1218
1543
  precacheFiberNode(wip, wip.stateNode);
1219
- attachRef(wip);
1220
1544
  removeFlagFromFiber(wip, UpdateFlag);
1221
1545
  }
1546
+ if (hasFlagOnFiber(wip, RefFlag)) {
1547
+ detachRef(wip);
1548
+ attachRef(wip);
1549
+ removeFlagFromFiber(wip, RefFlag);
1550
+ }
1222
1551
  }, "commitMutationHostComponent");
1223
1552
  var commitMutationHostText = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
1224
1553
  if (!wip.stateNode) {
@@ -1243,7 +1572,22 @@ var commitMutationHostText = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
1243
1572
  removeFlagFromFiber(wip, UpdateFlag);
1244
1573
  }
1245
1574
  }, "commitMutationHostText");
1575
+ var commitMutation = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
1576
+ switch (fiber.workTag) {
1577
+ case HostComponent:
1578
+ commitMutationHostComponent(fiber);
1579
+ break;
1580
+ case HostText:
1581
+ commitMutationHostText(fiber);
1582
+ break;
1583
+ }
1584
+ }, "commitMutation");
1585
+
1586
+ // ../rectify-reconciler/src/RectifyFiberCommitRemoval.ts
1246
1587
  var removeHostTree = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
1588
+ if (fiber.workTag === ClassComponent) {
1589
+ fiber.classInstance?.componentWillUnmount?.();
1590
+ }
1247
1591
  if (fiber.memoizedState) {
1248
1592
  runEffectCleanups(fiber);
1249
1593
  }
@@ -1259,96 +1603,48 @@ var removeHostTree = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
1259
1603
  }
1260
1604
  }, "removeHostTree");
1261
1605
 
1262
- // ../rectify-reconciler/src/RectifyFiberConcurrentUpdate.ts
1263
- var instance3 = {
1264
- head: null,
1265
- tail: null
1266
- };
1267
- var enqueueUpdate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((update) => {
1268
- update.next = null;
1269
- if (instance3.tail === null) {
1270
- instance3.head = update;
1271
- instance3.tail = update;
1272
- return;
1273
- }
1274
- instance3.tail.next = update;
1275
- instance3.tail = update;
1276
- }, "enqueueUpdate");
1277
- var dequeueUpdate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
1278
- const first = instance3.head;
1279
- if (first === null) {
1280
- return null;
1281
- }
1282
- instance3.head = first.next;
1283
- if (instance3.head === null) {
1284
- instance3.tail = null;
1606
+ // ../rectify-reconciler/src/RectifyFiberCommitWork.ts
1607
+ var MutationMask = PlacementFlag | UpdateFlag | MoveFlag | RefFlag;
1608
+ var commitWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((finishedWork) => {
1609
+ if (finishedWork.deletions?.length) {
1610
+ finishedWork.deletions.forEach(removeHostTree);
1611
+ finishedWork.deletions = null;
1285
1612
  }
1286
- first.next = null;
1287
- return first;
1288
- }, "dequeueUpdate");
1289
- var hasUpdate = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => instance3.head !== null, "hasUpdate");
1290
-
1291
- // ../rectify-reconciler/src/RectifyFiberReconciler.ts
1292
- injectEventPriorityCallbacks(
1293
- setCurrentEventPriority,
1294
- resetCurrentEventPriority
1295
- );
1296
- var isFlushingLayoutEffects = false;
1297
- var performWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((lanes) => {
1298
- const fiberRoot = getScheduledFiberRoot();
1299
- if (!fiberRoot) return;
1300
- if (!getResumeCursor()) flushPendingUpdates();
1301
- setCurrentRenderingLanes(lanes);
1302
- const completed = workLoopOnFiberLanes(fiberRoot.root, lanes);
1303
- if (!completed) {
1304
- scheduleRenderLane(lanes);
1305
- return;
1613
+ if (finishedWork.flags & MutationMask) {
1614
+ commitMutation(finishedWork);
1615
+ finishedWork.memoizedProps = finishedWork.pendingProps;
1306
1616
  }
1307
- clearResumeCursor();
1308
- commitWork(fiberRoot.root);
1309
- markContainerAsRoot(fiberRoot.root, fiberRoot.containerDom);
1310
- flushLayoutPhase(fiberRoot);
1311
- schedulePassiveEffects();
1312
- }, "performWork");
1313
- setWorkCallback(performWork);
1314
- var onScheduleRerender = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
1315
- const lane = isFlushingLayoutEffects ? SyncLane : requestUpdateLane();
1316
- enqueueUpdate({ lanes: lane, fiber, next: null });
1317
- if (!isFlushingLayoutEffects) {
1318
- scheduleRenderLane(lane);
1617
+ if (finishedWork.subtreeFlags & MutationMask) {
1618
+ let child = finishedWork.child;
1619
+ while (child) {
1620
+ commitWork(child);
1621
+ child = child.sibling;
1622
+ }
1319
1623
  }
1320
- }, "onScheduleRerender");
1321
- var onMarkFiberDirty = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
1322
- const lane = getCurrentLanePriority();
1323
- fiber.lanes |= lane;
1324
- const wip = fiber.alternate;
1325
- if (!wip) return;
1326
- wip.lanes |= lane;
1327
- let parent = wip.return;
1328
- while (parent) {
1329
- if ((parent.childLanes & lane) === lane) break;
1330
- parent.childLanes |= lane;
1331
- parent = parent.return;
1624
+ if (finishedWork.workTag === ClassComponent && finishedWork.classInstance) {
1625
+ const instance4 = finishedWork.classInstance;
1626
+ const isMount = finishedWork.alternate === null;
1627
+ if (isMount) {
1628
+ instance4.componentDidMount?.();
1629
+ } else if (instance4._prevState !== void 0) {
1630
+ instance4.componentDidUpdate?.(
1631
+ instance4._prevProps,
1632
+ instance4._prevState
1633
+ );
1634
+ instance4._prevProps = void 0;
1635
+ instance4._prevState = void 0;
1636
+ }
1332
1637
  }
1333
- }, "onMarkFiberDirty");
1334
- setScheduleRerender(onScheduleRerender);
1335
- setMarkFiberDirty(onMarkFiberDirty);
1336
- var createContainer = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((container) => {
1337
- return createHostRootFiber(container);
1338
- }, "createContainer");
1339
- var updateContainer = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((children, fiberRoot) => {
1340
- fiberRoot.children = children;
1341
- setScheduledFiberRoot(fiberRoot);
1342
- const wipRoot = createWorkInProgress(fiberRoot.root, { children });
1343
- setCurrentRenderingLanes(SyncLane);
1344
- workLoop(wipRoot);
1345
- commitWork(wipRoot);
1346
- fiberRoot.root = wipRoot;
1347
- markContainerAsRoot(wipRoot, fiberRoot.containerDom);
1348
- setScheduledFiberRoot(fiberRoot);
1349
- flushLayoutPhase(fiberRoot);
1350
- schedulePassiveEffects();
1351
- }, "updateContainer");
1638
+ finishedWork.flags = NoFlags;
1639
+ finishedWork.subtreeFlags = NoFlags;
1640
+ }, "commitWork");
1641
+
1642
+ // ../rectify-reconciler/src/RectifyFiberFlushPhase.ts
1643
+ var _isFlushingLayoutEffects = false;
1644
+ var getIsFlushingLayoutEffects = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => _isFlushingLayoutEffects, "getIsFlushingLayoutEffects");
1645
+ var setIsFlushingLayoutEffects = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((value) => {
1646
+ _isFlushingLayoutEffects = value;
1647
+ }, "setIsFlushingLayoutEffects");
1352
1648
  var passiveChannel = new MessageChannel();
1353
1649
  var schedulePassiveEffects = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
1354
1650
  passiveChannel.port1.onmessage = () => {
@@ -1359,10 +1655,10 @@ var schedulePassiveEffects = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(() => {
1359
1655
  }, "schedulePassiveEffects");
1360
1656
  var flushLayoutPhase = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiberRoot) => {
1361
1657
  while (true) {
1362
- isFlushingLayoutEffects = true;
1658
+ setIsFlushingLayoutEffects(true);
1363
1659
  flushLayoutEffectCleanups();
1364
1660
  flushLayoutEffects();
1365
- isFlushingLayoutEffects = false;
1661
+ setIsFlushingLayoutEffects(false);
1366
1662
  if (!hasUpdate()) break;
1367
1663
  flushPendingUpdates();
1368
1664
  setCurrentRenderingLanes(SyncLane);
@@ -1393,6 +1689,71 @@ var propagateLaneToAncestors = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((updateQ
1393
1689
  }
1394
1690
  }, "propagateLaneToAncestors");
1395
1691
 
1692
+ // ../rectify-reconciler/src/RectifyFiberHookBridge.ts
1693
+ var onScheduleRerender = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
1694
+ const lane = getIsFlushingLayoutEffects() ? SyncLane : requestUpdateLane();
1695
+ enqueueUpdate({ lanes: lane, fiber, next: null });
1696
+ if (!getIsFlushingLayoutEffects()) {
1697
+ scheduleRenderLane(lane);
1698
+ }
1699
+ }, "onScheduleRerender");
1700
+ var onMarkFiberDirty = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
1701
+ const lane = getCurrentLanePriority();
1702
+ fiber.lanes |= lane;
1703
+ const wip = fiber.alternate;
1704
+ if (!wip) return;
1705
+ wip.lanes |= lane;
1706
+ let parent = wip.return;
1707
+ while (parent) {
1708
+ if ((parent.childLanes & lane) === lane) break;
1709
+ parent.childLanes |= lane;
1710
+ parent = parent.return;
1711
+ }
1712
+ }, "onMarkFiberDirty");
1713
+ setScheduleRerender(onScheduleRerender);
1714
+ setMarkFiberDirty(onMarkFiberDirty);
1715
+
1716
+ // ../rectify-reconciler/src/RectifyFiberBootstrap.ts
1717
+ injectEventPriorityCallbacks(
1718
+ setCurrentEventPriority,
1719
+ resetCurrentEventPriority
1720
+ );
1721
+ var performWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((lanes) => {
1722
+ const fiberRoot = getScheduledFiberRoot();
1723
+ if (!fiberRoot) return;
1724
+ if (!getResumeCursor()) flushPendingUpdates();
1725
+ setCurrentRenderingLanes(lanes);
1726
+ const completed = workLoopOnFiberLanes(fiberRoot.root, lanes);
1727
+ if (!completed) {
1728
+ scheduleRenderLane(lanes);
1729
+ return;
1730
+ }
1731
+ clearResumeCursor();
1732
+ commitWork(fiberRoot.root);
1733
+ markContainerAsRoot(fiberRoot.root, fiberRoot.containerDom);
1734
+ flushLayoutPhase(fiberRoot);
1735
+ schedulePassiveEffects();
1736
+ }, "performWork");
1737
+ setWorkCallback(performWork);
1738
+
1739
+ // ../rectify-reconciler/src/RectifyFiberReconciler.ts
1740
+ var createContainer = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((container) => {
1741
+ return createHostRootFiber(container);
1742
+ }, "createContainer");
1743
+ var updateContainer = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((children, fiberRoot) => {
1744
+ fiberRoot.children = children;
1745
+ setScheduledFiberRoot(fiberRoot);
1746
+ const wipRoot = createWorkInProgress(fiberRoot.root, { children });
1747
+ setCurrentRenderingLanes(SyncLane);
1748
+ workLoop(wipRoot);
1749
+ commitWork(wipRoot);
1750
+ fiberRoot.root = wipRoot;
1751
+ markContainerAsRoot(wipRoot, fiberRoot.containerDom);
1752
+ setScheduledFiberRoot(fiberRoot);
1753
+ flushLayoutPhase(fiberRoot);
1754
+ schedulePassiveEffects();
1755
+ }, "updateContainer");
1756
+
1396
1757
  // ../rectify-dom/src/RectifyDomRoot.ts
1397
1758
  var createRoot = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((container) => {
1398
1759
  const hostRoot = createContainer(container);
@@ -1409,15 +1770,80 @@ var createRoot = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((container) => {
1409
1770
  }, "createRoot");
1410
1771
 
1411
1772
  // src/RectifyMemo.ts
1412
- function memo(Component, compare) {
1773
+ function memo(Component2, compare) {
1413
1774
  const wrapper = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name(((_props) => null), "wrapper");
1414
1775
  wrapper._isMemo = true;
1415
- wrapper._render = Component;
1776
+ wrapper._render = Component2;
1416
1777
  wrapper._compare = compare ?? null;
1417
1778
  return wrapper;
1418
1779
  }
1419
1780
  chunkAJJIEZ7G_cjs.__name(memo, "memo");
1420
1781
 
1782
+ // src/RectifyLazy.ts
1783
+ var lazy = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((factory) => {
1784
+ const stub = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((() => null), "stub");
1785
+ return Object.assign(stub, {
1786
+ _isLazy: true,
1787
+ _status: "uninitialized",
1788
+ _result: null,
1789
+ _promise: null,
1790
+ _factory: factory
1791
+ });
1792
+ }, "lazy");
1793
+
1794
+ // src/RectifySuspense.ts
1795
+ var Suspense = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((_props) => null, "Suspense");
1796
+ Suspense._isSuspense = true;
1797
+
1798
+ // src/RectifyComponent.ts
1799
+ var _Component = class _Component {
1800
+ constructor(props) {
1801
+ this.state = {};
1802
+ /**
1803
+ * @internal Set by the reconciler when the instance is created so
1804
+ * `setState` can enqueue a re-render on the correct fiber.
1805
+ */
1806
+ this._fiber = null;
1807
+ /**
1808
+ * @internal Snapshots taken by the reconciler in beginWork before each
1809
+ * update render so that `componentDidUpdate` receives the correct prev values.
1810
+ * Cleared after `componentDidUpdate` is called.
1811
+ */
1812
+ this._prevProps = void 0;
1813
+ this._prevState = void 0;
1814
+ /**
1815
+ * @internal Queue of pending setState updates, flushed by the reconciler
1816
+ * during beginWork so that prevState snapshots can be taken first.
1817
+ */
1818
+ this._pendingStateQueue = [];
1819
+ this.props = props;
1820
+ }
1821
+ // ---------------------------------------------------------------------------
1822
+ // Core API
1823
+ // ---------------------------------------------------------------------------
1824
+ /**
1825
+ * Merges `partialState` into the current state and schedules a re-render.
1826
+ * Accepts either a plain partial state object or an updater function.
1827
+ */
1828
+ setState(partialState) {
1829
+ this._pendingStateQueue.push(partialState);
1830
+ if (this._fiber) {
1831
+ scheduleRerender(this._fiber);
1832
+ }
1833
+ }
1834
+ /**
1835
+ * Must be implemented by every class component.
1836
+ * Returns the subtree to render.
1837
+ */
1838
+ render() {
1839
+ return null;
1840
+ }
1841
+ };
1842
+ chunkAJJIEZ7G_cjs.__name(_Component, "Component");
1843
+ /** Marks this as a class component for the reconciler. */
1844
+ _Component._isClassComponent = true;
1845
+ var Component = _Component;
1846
+
1421
1847
  Object.defineProperty(exports, "Fragment", {
1422
1848
  enumerable: true,
1423
1849
  get: function () { return chunkAJJIEZ7G_cjs.Fragment; }
@@ -1426,15 +1852,20 @@ Object.defineProperty(exports, "jsx", {
1426
1852
  enumerable: true,
1427
1853
  get: function () { return chunkAJJIEZ7G_cjs.jsx; }
1428
1854
  });
1855
+ exports.Component = Component;
1856
+ exports.Suspense = Suspense;
1429
1857
  exports.SyntheticEvent = SyntheticEvent_default;
1430
1858
  exports.createContext = createContext;
1431
1859
  exports.createRoot = createRoot;
1860
+ exports.lazy = lazy;
1432
1861
  exports.memo = memo;
1433
1862
  exports.useCallback = RectifyHookUseCallback_default;
1434
1863
  exports.useContext = useContext;
1435
1864
  exports.useEffect = RectifyHookUseEffect_default;
1865
+ exports.useId = RectifyHookUseId_default;
1436
1866
  exports.useLayoutEffect = RectifyHookUseLayoutEffect_default;
1437
1867
  exports.useMemo = RectifyHookUseMemo_default;
1868
+ exports.useReducer = RectifyHookUseReducer_default;
1438
1869
  exports.useRef = RectifyHookUseRef_default;
1439
1870
  exports.useState = RectifyHookUseState_default;
1440
1871
  //# sourceMappingURL=index.cjs.map