@my-react/react-reconciler-compact 0.0.12 → 0.0.13

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.
@@ -348,8 +348,10 @@ function requireIndex_production () {
348
348
  return ListTreeNode;
349
349
  }());
350
350
  var ListTree = /** @class */ (function () {
351
- function ListTree() {
351
+ function ListTree(max) {
352
352
  this.length = 0;
353
+ this.maxLength = Infinity;
354
+ this.maxLength = max || Infinity;
353
355
  var _stickyHead = null;
354
356
  Object.defineProperty(this, "stickyHead", {
355
357
  get: function () {
@@ -388,6 +390,9 @@ function requireIndex_production () {
388
390
  });
389
391
  }
390
392
  ListTree.prototype.push = function (node) {
393
+ while (this.length >= this.maxLength) {
394
+ this.pop();
395
+ }
391
396
  var listNode = new ListTreeNode(node);
392
397
  this.length++;
393
398
  if (!this.foot) {
@@ -405,6 +410,7 @@ function requireIndex_production () {
405
410
  var node_1 = this.stickyFoot;
406
411
  this.push(node_1.value);
407
412
  this.stickyFoot = null;
413
+ this.length--;
408
414
  }
409
415
  else {
410
416
  this.length++;
@@ -417,6 +423,7 @@ function requireIndex_production () {
417
423
  var node_2 = this.stickyHead;
418
424
  this.unshift(node_2.value);
419
425
  this.stickyHead = null;
426
+ this.length--;
420
427
  }
421
428
  else {
422
429
  this.length++;
@@ -435,6 +442,9 @@ function requireIndex_production () {
435
442
  }
436
443
  };
437
444
  ListTree.prototype.unshift = function (node) {
445
+ while (this.length >= this.maxLength) {
446
+ this.shift();
447
+ }
438
448
  var listNode = new ListTreeNode(node);
439
449
  this.length++;
440
450
  if (!this.head) {
@@ -452,6 +462,7 @@ function requireIndex_production () {
452
462
  var node_3 = this.stickyHead;
453
463
  this.unshift(node_3.value);
454
464
  this.stickyHead = null;
465
+ this.length--;
455
466
  }
456
467
  else {
457
468
  this.length++;
@@ -464,6 +475,7 @@ function requireIndex_production () {
464
475
  var node_4 = this.stickyFoot;
465
476
  this.push(node_4.value);
466
477
  this.stickyFoot = null;
478
+ this.length--;
467
479
  }
468
480
  else {
469
481
  this.length++;
@@ -615,7 +627,7 @@ function requireIndex_production () {
615
627
  return newList;
616
628
  };
617
629
  ListTree.prototype.clone = function () {
618
- var newList = new ListTree();
630
+ var newList = new ListTree(this.maxLength);
619
631
  this.listToFoot(function (v) { return newList.push(v); });
620
632
  return newList;
621
633
  };
@@ -2201,12 +2213,52 @@ function requireIndex_production () {
2201
2213
  }
2202
2214
  // TODO update flow
2203
2215
  if (enableSuspenseRoot$2.current) {
2204
- var suspenseField = getInstanceFieldByInstance(renderDispatch);
2205
- var list = suspenseField.asyncLoadList.getAll();
2216
+ var suspenseField_1 = getInstanceFieldByInstance(renderDispatch);
2217
+ var list = suspenseField_1.asyncLoadList.getAll();
2206
2218
  if (list.length === 0)
2207
2219
  return;
2208
2220
  if (renderDispatch.enableAsyncLoad) {
2209
- throw new Error("[@my-react/reconciler] not implemented yet");
2221
+ var allPendingLoadArray = list.filter(function (item) {
2222
+ if (isPromise(item)) {
2223
+ return typeof item.status !== "string";
2224
+ }
2225
+ else {
2226
+ return !item._loading && !item._loaded && !item._error;
2227
+ }
2228
+ });
2229
+ if (allPendingLoadArray.length) {
2230
+ Promise.all(allPendingLoadArray.map(function (item) { return __awaiter(void 0, void 0, void 0, function () {
2231
+ var allNode;
2232
+ var _a;
2233
+ return __generator(this, function (_b) {
2234
+ switch (_b.label) {
2235
+ case 0:
2236
+ if (!isPromise(item)) return [3 /*break*/, 2];
2237
+ return [4 /*yield*/, renderDispatch.processPromise(item)];
2238
+ case 1:
2239
+ _b.sent();
2240
+ return [3 /*break*/, 4];
2241
+ case 2: return [4 /*yield*/, renderDispatch.processLazy(item)];
2242
+ case 3:
2243
+ _b.sent();
2244
+ _b.label = 4;
2245
+ case 4:
2246
+ allNode = Array.from(item._list);
2247
+ (_a = item._list) === null || _a === void 0 ? void 0 : _a.clear();
2248
+ allNode.forEach(function (node) {
2249
+ node.state = STATE_TYPE.__reschedule__;
2250
+ });
2251
+ suspenseField_1.asyncLoadList.uniDelete(item);
2252
+ return [2 /*return*/];
2253
+ }
2254
+ });
2255
+ }); }));
2256
+ var root = renderDispatch.rootFiber;
2257
+ root.state = remove(root.state, STATE_TYPE.__stable__);
2258
+ root.state = merge(root.state, STATE_TYPE.__retrigger__);
2259
+ // TODO use hide tree to improve
2260
+ mountLoopAll(renderDispatch, root);
2261
+ }
2210
2262
  }
2211
2263
  else {
2212
2264
  throw new Error("[@my-react/reconciler] should not process async load list on sync mount without enableAsyncLoad, you may use a wrong renderDispatch instance");
@@ -3261,12 +3313,11 @@ function requireIndex_production () {
3261
3313
  cb === null || cb === void 0 ? void 0 : cb();
3262
3314
  };
3263
3315
  var clearContainer = function (renderDispatch) {
3264
- var _a, _b, _c, _d;
3316
+ var _a, _b, _c;
3265
3317
  renderDispatch.pendingCommitFiberPatch = PATCH_TYPE.__initial__;
3266
3318
  (_a = renderDispatch.pendingUpdateFiberArray) === null || _a === void 0 ? void 0 : _a.clear();
3267
3319
  (_b = renderDispatch.pendingSuspenseFiberArray) === null || _b === void 0 ? void 0 : _b.clear();
3268
3320
  (_c = renderDispatch.pendingCommitFiberList) === null || _c === void 0 ? void 0 : _c.clear();
3269
- (_d = renderDispatch.pendingChangedFiberList) === null || _d === void 0 ? void 0 : _d.clear();
3270
3321
  renderDispatch.resetUpdateFlowRuntimeFiber();
3271
3322
  renderDispatch.isAppMounted = false;
3272
3323
  renderDispatch.isAppUnmounted = true;
@@ -3486,14 +3537,12 @@ function requireIndex_production () {
3486
3537
  react.__my_react_shared__.enableScopeTreeLog;
3487
3538
  function finishUpdateSyncFromRoot(renderDispatch) {
3488
3539
  var commitList = renderDispatch.pendingCommitFiberList;
3489
- var changedList = renderDispatch.pendingChangedFiberList;
3490
3540
  renderDispatch.resetUpdateFlowRuntimeFiber();
3491
3541
  renderDispatch.pendingCommitFiberList = null;
3492
- renderDispatch.pendingChangedFiberList = null;
3493
3542
  (commitList === null || commitList === void 0 ? void 0 : commitList.length) && renderDispatch.reconcileUpdate(commitList, true);
3494
- (changedList === null || changedList === void 0 ? void 0 : changedList.length) &&
3543
+ (commitList === null || commitList === void 0 ? void 0 : commitList.length) &&
3495
3544
  safeCall(function safeCallFiberHasChangeListener() {
3496
- renderDispatch.callOnFiberChange(changedList);
3545
+ renderDispatch.callOnFiberChange(commitList);
3497
3546
  });
3498
3547
  }
3499
3548
  var updateSyncFromRoot = function (renderDispatch) {
@@ -3509,14 +3558,12 @@ function requireIndex_production () {
3509
3558
  };
3510
3559
  function finishUpdateConcurrentFromRoot(renderDispatch) {
3511
3560
  var commitList = renderDispatch.pendingCommitFiberList;
3512
- var changedList = renderDispatch.pendingChangedFiberList;
3513
3561
  renderDispatch.resetUpdateFlowRuntimeFiber();
3514
3562
  renderDispatch.pendingCommitFiberList = null;
3515
- renderDispatch.pendingChangedFiberList = null;
3516
3563
  (commitList === null || commitList === void 0 ? void 0 : commitList.length) && renderDispatch.reconcileUpdate(commitList);
3517
- (changedList === null || changedList === void 0 ? void 0 : changedList.length) &&
3564
+ (commitList === null || commitList === void 0 ? void 0 : commitList.length) &&
3518
3565
  safeCall(function safeCallFiberHasChangeListener() {
3519
- renderDispatch.callOnFiberChange(changedList);
3566
+ renderDispatch.callOnFiberChange(commitList);
3520
3567
  });
3521
3568
  }
3522
3569
  function checkNextFiberIsSync(renderDispatch) {
@@ -4446,7 +4493,6 @@ function requireIndex_production () {
4446
4493
  renderDispatch.runtimeMap.effectMap.delete(fiber);
4447
4494
  renderDispatch.runtimeMap.layoutEffectMap.delete(fiber);
4448
4495
  renderDispatch.runtimeMap.unmountMap.delete(fiber);
4449
- renderDispatch.runtimeMap.eventMap.delete(fiber);
4450
4496
  renderDispatch.runtimeMap.triggerCallbackMap.delete(fiber);
4451
4497
  if (Boolean(false) === false) {
4452
4498
  // fiber.child = null;
@@ -4504,7 +4550,6 @@ function requireIndex_production () {
4504
4550
  renderDispatch.pendingUnmount(parentFiber, f);
4505
4551
  });
4506
4552
  });
4507
- renderDispatch.generateChangedList(parentFiber, true);
4508
4553
  }
4509
4554
  };
4510
4555
  var getNewFiberWithUpdate = function (renderDispatch, newChild, parentFiber, existingChildren, prevFiberChild, index) {
@@ -4518,11 +4563,9 @@ function requireIndex_production () {
4518
4563
  // same type
4519
4564
  if (include(draftFiber_1 === null || draftFiber_1 === void 0 ? void 0 : draftFiber_1.type, exports.NODE_TYPE.__fragment__)) {
4520
4565
  var newElement = react.createElement(Fragment, dynamicFragmentProps, newChild);
4521
- draftFiber_1 !== prevFiberChild && renderDispatch.generateChangedList(parentFiber);
4522
4566
  return updateFiberNode(renderDispatch, { fiber: draftFiber_1, parent: parentFiber, prevFiber: prevFiberChild }, newElement);
4523
4567
  }
4524
4568
  else {
4525
- draftFiber_1 && renderDispatch.generateChangedList(parentFiber);
4526
4569
  draftFiber_1 && renderDispatch.pendingUnmount(parentFiber, draftFiber_1);
4527
4570
  return createFragmentWithUpdate(renderDispatch, newChild, parentFiber);
4528
4571
  }
@@ -4535,12 +4578,10 @@ function requireIndex_production () {
4535
4578
  }
4536
4579
  var isSameType = getIsSameTypeNode(newChild, draftFiber);
4537
4580
  if (isSameType) {
4538
- draftFiber !== prevFiberChild && renderDispatch.generateChangedList(parentFiber);
4539
4581
  return updateFiberNode(renderDispatch, { fiber: draftFiber, parent: parentFiber, prevFiber: prevFiberChild }, newChild);
4540
4582
  }
4541
4583
  else {
4542
4584
  draftFiber && renderDispatch.pendingUnmount(parentFiber, draftFiber);
4543
- draftFiber && renderDispatch.generateChangedList(parentFiber);
4544
4585
  return createFiberNode(renderDispatch, { parent: parentFiber, type: "position" }, newChild);
4545
4586
  }
4546
4587
  };
@@ -4583,7 +4624,6 @@ function requireIndex_production () {
4583
4624
  deleteIfNeed(renderDispatch, parentFiber, existingChildrenMap);
4584
4625
  }
4585
4626
  else {
4586
- renderDispatch.generateChangedList(parentFiber);
4587
4627
  var existingChildrenMap = getExistingChildren(parentFiber).existingChildrenMap;
4588
4628
  deleteIfNeed(renderDispatch, parentFiber, existingChildrenMap);
4589
4629
  parentFiber.child = null;
@@ -5544,7 +5584,6 @@ function requireIndex_production () {
5544
5584
  layoutEffectMap: new MyWeakMap(),
5545
5585
  insertionEffectMap: new MyWeakMap(),
5546
5586
  unmountMap: new MyWeakMap(),
5547
- eventMap: new MyWeakMap(),
5548
5587
  triggerCallbackMap: new MyWeakMap(),
5549
5588
  }); };
5550
5589
  var getInitialFiber = function () { return ({
@@ -6300,13 +6339,12 @@ function requireIndex_production () {
6300
6339
  _this.isAppMounted = false;
6301
6340
  _this.isAppCrashed = false;
6302
6341
  _this.isAppUnmounted = false;
6303
- _this.version = "0.3.21";
6342
+ _this.version = "0.3.22";
6304
6343
  _this.id = Math.random().toString(16).slice(2);
6305
6344
  _this.mode = "production";
6306
6345
  _this.renderMode = "render";
6307
6346
  _this.pendingCommitFiberList = null;
6308
6347
  _this.pendingCommitFiberPatch = PATCH_TYPE.__initial__;
6309
- _this.pendingChangedFiberList = null;
6310
6348
  _this.pendingUpdateFiberArray = new UniqueArray();
6311
6349
  _this.pendingSuspenseFiberArray = new UniqueArray();
6312
6350
  _this.uniqueIdCount = 0;
@@ -6324,17 +6362,6 @@ function requireIndex_production () {
6324
6362
  this.pendingCommitFiberList.push(_fiber);
6325
6363
  }
6326
6364
  };
6327
- CustomRenderDispatch.prototype.generateChangedList = function (_fiber, withCheck) {
6328
- if (!_fiber)
6329
- return;
6330
- if (!this.isAppMounted)
6331
- return;
6332
- this.pendingChangedFiberList = this.pendingChangedFiberList || new ListTree();
6333
- if (withCheck && this.pendingChangedFiberList.hasValue(_fiber)) {
6334
- return;
6335
- }
6336
- this.pendingChangedFiberList.push(_fiber);
6337
- };
6338
6365
  CustomRenderDispatch.prototype.pendingCreate = function (_fiber) {
6339
6366
  if (include(_fiber.type, this.runtimeRef.typeForCreate)) {
6340
6367
  _fiber.patch = merge(_fiber.patch, PATCH_TYPE.__create__);
@@ -6519,17 +6546,8 @@ function requireIndex_production () {
6519
6546
  react.__my_react_shared__.enableScopeTreeLog;
6520
6547
  function finishMountSync(renderDispatch, fiber) {
6521
6548
  renderDispatch.reconcileCommit(fiber);
6522
- var changedList = renderDispatch.pendingChangedFiberList;
6523
6549
  renderDispatch.resetUpdateFlowRuntimeFiber();
6524
6550
  renderDispatch.pendingCommitFiberList = null;
6525
- renderDispatch.pendingChangedFiberList = null;
6526
- (changedList === null || changedList === void 0 ? void 0 : changedList.length) &&
6527
- safeCallWithCurrentFiber({
6528
- fiber: fiber,
6529
- action: function safeCallFiberHasChangeListener() {
6530
- renderDispatch.callOnFiberChange(changedList);
6531
- },
6532
- });
6533
6551
  }
6534
6552
  var mountSync = function (renderDispatch, fiber) {
6535
6553
  globalLoop.current = true;
@@ -6540,17 +6558,8 @@ function requireIndex_production () {
6540
6558
  };
6541
6559
  function finishMountAsync(renderDispatch, fiber) {
6542
6560
  renderDispatch.reconcileCommit(fiber);
6543
- var changedList = renderDispatch.pendingChangedFiberList;
6544
6561
  renderDispatch.resetUpdateFlowRuntimeFiber();
6545
6562
  renderDispatch.pendingCommitFiberList = null;
6546
- renderDispatch.pendingChangedFiberList = null;
6547
- (changedList === null || changedList === void 0 ? void 0 : changedList.length) &&
6548
- safeCallWithCurrentFiber({
6549
- fiber: fiber,
6550
- action: function safeCallFiberHasChangeListener() {
6551
- renderDispatch.callOnFiberChange(changedList);
6552
- },
6553
- });
6554
6563
  }
6555
6564
  var mountAsync = function (renderDispatch, fiber) { return __awaiter(void 0, void 0, void 0, function () {
6556
6565
  return __generator(this, function (_a) {
@@ -6568,7 +6577,7 @@ function requireIndex_production () {
6568
6577
  });
6569
6578
  }); };
6570
6579
 
6571
- var version = "0.3.21";
6580
+ var version = "0.3.22";
6572
6581
 
6573
6582
  exports.CustomRenderDispatch = CustomRenderDispatch;
6574
6583
  exports.MyReactFiberNode = MyReactFiberNode;
@@ -6866,6 +6875,8 @@ var Effect_TYPE;
6866
6875
  Effect_TYPE[Effect_TYPE["__unmount__"] = 2] = "__unmount__";
6867
6876
  })(Effect_TYPE || (Effect_TYPE = {}));
6868
6877
 
6878
+ var enableKnownConfigLog = require$$0.createRef(false);
6879
+
6869
6880
  var DISPATCH_FIELD = "__@my-react/dispatch__";
6870
6881
  var DEV_TOOL_FIELD = "__@my-react/react-devtool-inject__";
6871
6882
  var addGlobalDispatch = function (dispatch) {
@@ -8098,6 +8109,7 @@ var Reconciler = function (_config) {
8098
8109
  _container.__flag__ = 1;
8099
8110
  }
8100
8111
  enableDebugFiled.current = false;
8112
+ myreactReconcilerExports.enableDebugUpdateQueue.current = false;
8101
8113
  enableScopeTreeLog.current = false;
8102
8114
  myreactReconcilerExports.enableFiberForLog.current = false;
8103
8115
  return _container;
@@ -8192,14 +8204,16 @@ var Reconciler = function (_config) {
8192
8204
  getPublicRootInstance: getPublicRootInstance,
8193
8205
  injectIntoDevToolsWithSocketIO: injectIntoDevToolsWithSocketIO,
8194
8206
  flushSync: myreactReconcilerExports.safeCallWithSync,
8207
+ flushSyncWork: myreactReconcilerExports.safeCallWithSync,
8195
8208
  batchedUpdates: myreactReconcilerExports.safeCallWithSync,
8196
8209
  };
8197
8210
  };
8198
8211
 
8199
8212
  /* eslint-disable import/export */
8200
- var version = "0.0.12";
8213
+ var version = "0.0.13";
8201
8214
  var createReconciler = Reconciler;
8202
8215
 
8203
8216
  exports.createReconciler = createReconciler;
8204
8217
  exports.default = createReconciler;
8218
+ exports.enableKnownConfigLog = enableKnownConfigLog;
8205
8219
  exports.version = version;