@meursyphus/flitter 0.0.4 → 0.0.5

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/index.cjs CHANGED
@@ -62,6 +62,10 @@ var data_default = Data;
62
62
 
63
63
  // src/type/_types/_calculable.ts
64
64
  var Calculable = class extends data_default {
65
+ constructor() {
66
+ super(...arguments);
67
+ __publicField(this, "isCalculable", true);
68
+ }
65
69
  plus(_other) {
66
70
  throw Error("plus is not implemented");
67
71
  }
@@ -443,7 +447,7 @@ var _Utils = class _Utils {
443
447
  if (typeof a === "number") {
444
448
  return lerp_default(a, b, t);
445
449
  }
446
- assert(b instanceof calculable_default);
450
+ assert(b == null ? void 0 : b.isCalculable, "b is not a Calculable");
447
451
  return a.plus(b.minus(a).multiply(t));
448
452
  }
449
453
  };
@@ -1341,6 +1345,7 @@ var matrix3_default = Matrix3;
1341
1345
  // src/type/_types/_vector4.ts
1342
1346
  var Vector4 = class _Vector4 {
1343
1347
  constructor(arg0, arg1, arg2, arg3) {
1348
+ __publicField(this, "type", "v4");
1344
1349
  __publicField(this, "_v4storage");
1345
1350
  this._v4storage = [arg0, arg1, arg2, arg3];
1346
1351
  }
@@ -6720,6 +6725,7 @@ var vector4_default = Vector4;
6720
6725
  // src/type/_types/_vector2.ts
6721
6726
  var Vector2 = class _Vector2 {
6722
6727
  constructor(arg0, arg1) {
6728
+ __publicField(this, "type", "v2");
6723
6729
  __publicField(this, "_v2storage");
6724
6730
  this._v2storage = [arg0, arg1];
6725
6731
  }
@@ -6776,63 +6782,63 @@ var Vector2 = class _Vector2 {
6776
6782
  return new _Vector2(this._v2storage[1], this._v2storage[1]);
6777
6783
  }
6778
6784
  get xxx() {
6779
- return new vector3_default(
6785
+ return new Vector3(
6780
6786
  this._v2storage[0],
6781
6787
  this._v2storage[0],
6782
6788
  this._v2storage[0]
6783
6789
  );
6784
6790
  }
6785
6791
  get xxy() {
6786
- return new vector3_default(
6792
+ return new Vector3(
6787
6793
  this._v2storage[0],
6788
6794
  this._v2storage[0],
6789
6795
  this._v2storage[1]
6790
6796
  );
6791
6797
  }
6792
6798
  get xyx() {
6793
- return new vector3_default(
6799
+ return new Vector3(
6794
6800
  this._v2storage[0],
6795
6801
  this._v2storage[1],
6796
6802
  this._v2storage[0]
6797
6803
  );
6798
6804
  }
6799
6805
  get xyy() {
6800
- return new vector3_default(
6806
+ return new Vector3(
6801
6807
  this._v2storage[0],
6802
6808
  this._v2storage[1],
6803
6809
  this._v2storage[1]
6804
6810
  );
6805
6811
  }
6806
6812
  get yxx() {
6807
- return new vector3_default(
6813
+ return new Vector3(
6808
6814
  this._v2storage[1],
6809
6815
  this._v2storage[0],
6810
6816
  this._v2storage[0]
6811
6817
  );
6812
6818
  }
6813
6819
  get yxy() {
6814
- return new vector3_default(
6820
+ return new Vector3(
6815
6821
  this._v2storage[1],
6816
6822
  this._v2storage[0],
6817
6823
  this._v2storage[1]
6818
6824
  );
6819
6825
  }
6820
6826
  get yyx() {
6821
- return new vector3_default(
6827
+ return new Vector3(
6822
6828
  this._v2storage[1],
6823
6829
  this._v2storage[1],
6824
6830
  this._v2storage[0]
6825
6831
  );
6826
6832
  }
6827
6833
  get yyy() {
6828
- return new vector3_default(
6834
+ return new Vector3(
6829
6835
  this._v2storage[1],
6830
6836
  this._v2storage[1],
6831
6837
  this._v2storage[1]
6832
6838
  );
6833
6839
  }
6834
6840
  get xxxx() {
6835
- return new vector4_default(
6841
+ return new Vector4(
6836
6842
  this._v2storage[0],
6837
6843
  this._v2storage[0],
6838
6844
  this._v2storage[0],
@@ -6840,7 +6846,7 @@ var Vector2 = class _Vector2 {
6840
6846
  );
6841
6847
  }
6842
6848
  get xxxy() {
6843
- return new vector4_default(
6849
+ return new Vector4(
6844
6850
  this._v2storage[0],
6845
6851
  this._v2storage[0],
6846
6852
  this._v2storage[0],
@@ -6848,7 +6854,7 @@ var Vector2 = class _Vector2 {
6848
6854
  );
6849
6855
  }
6850
6856
  get xxyx() {
6851
- return new vector4_default(
6857
+ return new Vector4(
6852
6858
  this._v2storage[0],
6853
6859
  this._v2storage[0],
6854
6860
  this._v2storage[1],
@@ -6856,7 +6862,7 @@ var Vector2 = class _Vector2 {
6856
6862
  );
6857
6863
  }
6858
6864
  get xxyy() {
6859
- return new vector4_default(
6865
+ return new Vector4(
6860
6866
  this._v2storage[0],
6861
6867
  this._v2storage[0],
6862
6868
  this._v2storage[1],
@@ -6864,7 +6870,7 @@ var Vector2 = class _Vector2 {
6864
6870
  );
6865
6871
  }
6866
6872
  get xyxx() {
6867
- return new vector4_default(
6873
+ return new Vector4(
6868
6874
  this._v2storage[0],
6869
6875
  this._v2storage[1],
6870
6876
  this._v2storage[0],
@@ -6872,7 +6878,7 @@ var Vector2 = class _Vector2 {
6872
6878
  );
6873
6879
  }
6874
6880
  get xyxy() {
6875
- return new vector4_default(
6881
+ return new Vector4(
6876
6882
  this._v2storage[0],
6877
6883
  this._v2storage[1],
6878
6884
  this._v2storage[0],
@@ -6880,7 +6886,7 @@ var Vector2 = class _Vector2 {
6880
6886
  );
6881
6887
  }
6882
6888
  get xyyx() {
6883
- return new vector4_default(
6889
+ return new Vector4(
6884
6890
  this._v2storage[0],
6885
6891
  this._v2storage[1],
6886
6892
  this._v2storage[1],
@@ -6888,7 +6894,7 @@ var Vector2 = class _Vector2 {
6888
6894
  );
6889
6895
  }
6890
6896
  get xyyy() {
6891
- return new vector4_default(
6897
+ return new Vector4(
6892
6898
  this._v2storage[0],
6893
6899
  this._v2storage[1],
6894
6900
  this._v2storage[1],
@@ -6896,7 +6902,7 @@ var Vector2 = class _Vector2 {
6896
6902
  );
6897
6903
  }
6898
6904
  get yxxx() {
6899
- return new vector4_default(
6905
+ return new Vector4(
6900
6906
  this._v2storage[1],
6901
6907
  this._v2storage[0],
6902
6908
  this._v2storage[0],
@@ -6904,7 +6910,7 @@ var Vector2 = class _Vector2 {
6904
6910
  );
6905
6911
  }
6906
6912
  get yxxy() {
6907
- return new vector4_default(
6913
+ return new Vector4(
6908
6914
  this._v2storage[1],
6909
6915
  this._v2storage[0],
6910
6916
  this._v2storage[0],
@@ -6912,7 +6918,7 @@ var Vector2 = class _Vector2 {
6912
6918
  );
6913
6919
  }
6914
6920
  get yxyx() {
6915
- return new vector4_default(
6921
+ return new Vector4(
6916
6922
  this._v2storage[1],
6917
6923
  this._v2storage[0],
6918
6924
  this._v2storage[1],
@@ -6920,7 +6926,7 @@ var Vector2 = class _Vector2 {
6920
6926
  );
6921
6927
  }
6922
6928
  get yxyy() {
6923
- return new vector4_default(
6929
+ return new Vector4(
6924
6930
  this._v2storage[1],
6925
6931
  this._v2storage[0],
6926
6932
  this._v2storage[1],
@@ -6928,7 +6934,7 @@ var Vector2 = class _Vector2 {
6928
6934
  );
6929
6935
  }
6930
6936
  get yyxx() {
6931
- return new vector4_default(
6937
+ return new Vector4(
6932
6938
  this._v2storage[1],
6933
6939
  this._v2storage[1],
6934
6940
  this._v2storage[0],
@@ -6936,7 +6942,7 @@ var Vector2 = class _Vector2 {
6936
6942
  );
6937
6943
  }
6938
6944
  get yyxy() {
6939
- return new vector4_default(
6945
+ return new Vector4(
6940
6946
  this._v2storage[1],
6941
6947
  this._v2storage[1],
6942
6948
  this._v2storage[0],
@@ -6944,7 +6950,7 @@ var Vector2 = class _Vector2 {
6944
6950
  );
6945
6951
  }
6946
6952
  get yyyx() {
6947
- return new vector4_default(
6953
+ return new Vector4(
6948
6954
  this._v2storage[1],
6949
6955
  this._v2storage[1],
6950
6956
  this._v2storage[1],
@@ -6952,7 +6958,7 @@ var Vector2 = class _Vector2 {
6952
6958
  );
6953
6959
  }
6954
6960
  get yyyy() {
6955
- return new vector4_default(
6961
+ return new Vector4(
6956
6962
  this._v2storage[1],
6957
6963
  this._v2storage[1],
6958
6964
  this._v2storage[1],
@@ -7151,6 +7157,7 @@ var vector2_default = Vector2;
7151
7157
  // src/type/_types/_vector3.ts
7152
7158
  var Vector3 = class _Vector3 {
7153
7159
  constructor(arg0, arg1, arg2) {
7160
+ __publicField(this, "type", "v3");
7154
7161
  __publicField(this, "_v3storage");
7155
7162
  this._v3storage = [arg0, arg1, arg2];
7156
7163
  }
@@ -9828,12 +9835,12 @@ var Matrix4 = class _Matrix4 extends calculable_default {
9828
9835
  */
9829
9836
  translate(x, y, z) {
9830
9837
  let tx, ty, tz;
9831
- const tw = x instanceof vector4_default ? x.w : 1;
9832
- if (x instanceof vector3_default) {
9838
+ const tw = (x == null ? void 0 : x.type) === "v4" ? x.w : 1;
9839
+ if ((x == null ? void 0 : x.type) === "v3") {
9833
9840
  tx = x.x;
9834
9841
  ty = x.y;
9835
9842
  tz = x.z;
9836
- } else if (x instanceof vector4_default) {
9843
+ } else if ((x == null ? void 0 : x.type) === "v4") {
9837
9844
  tx = x.x;
9838
9845
  ty = x.y;
9839
9846
  tz = x.z;
@@ -9863,21 +9870,21 @@ var Matrix4 = class _Matrix4 extends calculable_default {
9863
9870
  */
9864
9871
  leftTranslate(x, y = 0, z = 0) {
9865
9872
  let tx, ty, tz;
9866
- const tw = x instanceof vector4_default ? x.w : 1;
9867
- if (x instanceof vector3_default) {
9873
+ const tw = (x == null ? void 0 : x.type) === "v4" ? x.w : 1;
9874
+ if ((x == null ? void 0 : x.type) === "v3") {
9868
9875
  tx = x.x;
9869
9876
  ty = x.y;
9870
9877
  tz = x.z;
9871
- } else if (x instanceof vector4_default) {
9878
+ } else if ((x == null ? void 0 : x.type) === "v4") {
9872
9879
  tx = x.x;
9873
9880
  ty = x.y;
9874
9881
  tz = x.z;
9875
9882
  } else if (typeof x === "number") {
9876
9883
  tx = x;
9877
- ty = y;
9878
- tz = z;
9884
+ ty = y || 0;
9885
+ tz = z || 0;
9879
9886
  } else {
9880
- throw new Error("Invalid argument type");
9887
+ throw new Error("Unsupported argument type.");
9881
9888
  }
9882
9889
  this._m4storage[0] += tx * this._m4storage[3];
9883
9890
  this._m4storage[1] += ty * this._m4storage[3];
@@ -10022,12 +10029,12 @@ var Matrix4 = class _Matrix4 extends calculable_default {
10022
10029
  let sx;
10023
10030
  let sy;
10024
10031
  let sz;
10025
- const sw = x instanceof vector4_default ? x.w : 1;
10026
- if (x instanceof vector3_default) {
10032
+ const sw = (x == null ? void 0 : x.type) === "v4" ? x.w : 1;
10033
+ if (x.type === "v3") {
10027
10034
  sx = x.x;
10028
10035
  sy = x.y;
10029
10036
  sz = x.z;
10030
- } else if (x instanceof vector4_default) {
10037
+ } else if (x.type === "v4") {
10031
10038
  sx = x.x;
10032
10039
  sy = x.y;
10033
10040
  sz = x.z;
@@ -11196,8 +11203,6 @@ var Border = class _Border extends _BoxBorder {
11196
11203
  equals(other) {
11197
11204
  if (this === other)
11198
11205
  return true;
11199
- if (!(other instanceof _Border))
11200
- return false;
11201
11206
  return this.top.equals(other.top) && this.right.equals(other.right) && this.bottom.equals(other.bottom) && this.left.equals(other.left);
11202
11207
  }
11203
11208
  /**
@@ -11590,8 +11595,6 @@ var BoxDecoration = class _BoxDecoration extends data_default {
11590
11595
  equals(other) {
11591
11596
  if (this === other)
11592
11597
  return true;
11593
- if (!(other instanceof _BoxDecoration))
11594
- return false;
11595
11598
  if (!(this.color == null && other.color == null) && (!(this.color != null && other.color != null) || !this.color.equals(other.color))) {
11596
11599
  return false;
11597
11600
  }
@@ -11961,6 +11964,7 @@ var ToolTipPosition = /* @__PURE__ */ ((ToolTipPosition2) => {
11961
11964
  var _domNode, _domOrder, _domOrderChanged;
11962
11965
  var RenderObject = class {
11963
11966
  constructor({ isPainter }) {
11967
+ __publicField(this, "runtimeType", this.constructor.name);
11964
11968
  __publicField(this, "isPainter");
11965
11969
  __publicField(this, "ownerElement");
11966
11970
  __publicField(this, "renderOwner");
@@ -12256,485 +12260,489 @@ var Widget = class {
12256
12260
  };
12257
12261
  var Widget_default = Widget;
12258
12262
 
12259
- // src/scheduler/BuildOwner.ts
12260
- var BuildOwner = class {
12261
- constructor({ onNeedVisualUpdate }) {
12262
- __publicField(this, "onNeedVisualUpdate");
12263
- __publicField(this, "dirtyElements", []);
12264
- __publicField(this, "globalKeyRegistry", /* @__PURE__ */ new WeakMap());
12265
- this.onNeedVisualUpdate = () => onNeedVisualUpdate();
12266
- }
12267
- scheduleFor(elememt) {
12268
- this.dirtyElements.push(elememt);
12269
- this.requestVisualUpdate();
12263
+ // src/element/Element.ts
12264
+ var Element = class {
12265
+ constructor(widget) {
12266
+ __publicField(this, "scheduler");
12267
+ __publicField(this, "renderContext");
12268
+ __publicField(this, "buildOwner");
12269
+ __publicField(this, "widget");
12270
+ __publicField(this, "parent");
12271
+ __publicField(this, "dirty", true);
12272
+ __publicField(this, "depth", 0);
12273
+ __publicField(this, "type", "none");
12274
+ this.widget = widget;
12270
12275
  }
12271
- requestVisualUpdate() {
12272
- this.onNeedVisualUpdate();
12276
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12277
+ visitChildren(visitor) {
12278
+ throw { message: "not implemented" };
12273
12279
  }
12274
- flushBuild() {
12275
- const dirtyElements = this.dirtyElements;
12276
- this.dirtyElements = [];
12277
- dirtyElements.sort((a, b) => a.depth - b.depth).forEach((elememt) => {
12278
- if (!elememt.dirty)
12279
- return;
12280
- elememt.rebuild();
12280
+ get renderObject() {
12281
+ let result = null;
12282
+ this.visitChildren((child) => {
12283
+ result = child.renderObject;
12281
12284
  });
12285
+ if (result == null)
12286
+ throw { message: "can not find render object" };
12287
+ return result;
12282
12288
  }
12283
- registerGlobalKey(key, elememt) {
12284
- key.buildOwner = this;
12285
- this.globalKeyRegistry.set(key, elememt);
12289
+ //There are 5 case
12290
+ // 1. child is not null, but widget is null
12291
+ // in this case, child must be unmounted
12292
+ // 2. child is null, widget is null
12293
+ // nothing happend
12294
+ // 3. child is null, widget is not null
12295
+ // newWidget would be inflated,
12296
+ // 4. child is not null, widget is not null, and widget can be update
12297
+ // in this case, just update widget configruation
12298
+ // 5. it is similar to 4 but widget can not be update,
12299
+ // in this case, child must be unmounted and newWidget would be inflated
12300
+ updateChild(child, newWidget) {
12301
+ if (child != null && newWidget == null) {
12302
+ child.unmount();
12303
+ return null;
12304
+ } else if (child == null && newWidget == null) {
12305
+ } else if (child == null && newWidget != null) {
12306
+ return this.inflateWidget(newWidget);
12307
+ } else if (child != null && newWidget != null && Widget_default.canUpdate(child.widget, newWidget)) {
12308
+ child.update(newWidget);
12309
+ return child;
12310
+ } else {
12311
+ child.unmount();
12312
+ return this.inflateWidget(newWidget);
12313
+ }
12286
12314
  }
12287
- findByGlobalKey(key) {
12288
- const result = this.globalKeyRegistry.get(key);
12289
- return result;
12315
+ unmount() {
12316
+ this.parent = void 0;
12290
12317
  }
12291
- };
12292
- var BuildOwner_default = BuildOwner;
12293
-
12294
- // src/scheduler/RenderOwner.ts
12295
- var RenderOwner = class {
12296
- constructor({
12297
- onNeedVisualUpdate,
12298
- paintContext
12299
- }) {
12300
- __publicField(this, "paintContext");
12301
- __publicField(this, "onNeedVisualUpdate");
12302
- __publicField(this, "needsPaintRenderObjects", []);
12303
- __publicField(this, "needsLayoutRenderObjects", []);
12304
- /*
12305
- this will be set by RenderView
12306
- */
12307
- __publicField(this, "renderView");
12308
- __publicField(this, "domOrderChanged", true);
12309
- this.onNeedVisualUpdate = onNeedVisualUpdate;
12310
- this.paintContext = paintContext;
12318
+ mount(newParent) {
12319
+ var _a;
12320
+ if (newParent) {
12321
+ this.renderContext = newParent.renderContext;
12322
+ this.buildOwner = newParent.buildOwner;
12323
+ this.depth = newParent.depth + 1;
12324
+ this.scheduler = newParent.scheduler;
12325
+ }
12326
+ this.parent = newParent;
12327
+ if ((_a = this.widget.key) == null ? void 0 : _a.isGlobalKey) {
12328
+ this.buildOwner.registerGlobalKey(this.widget.key, this);
12329
+ }
12311
12330
  }
12312
- requestVisualUpdate() {
12313
- this.onNeedVisualUpdate();
12331
+ update(newWidget) {
12332
+ this.widget = newWidget;
12314
12333
  }
12315
- drawFrame() {
12316
- this.flushLayout();
12317
- this.rearrangeDomOrder();
12318
- this.flushPaint();
12334
+ inflateWidget(childWidget) {
12335
+ const newChild = childWidget.createElement();
12336
+ newChild.mount(this);
12337
+ return newChild;
12319
12338
  }
12320
- rearrangeDomOrder() {
12321
- if (!this.domOrderChanged)
12339
+ rebuild({ force = false } = {}) {
12340
+ if (!this.dirty && !force)
12322
12341
  return;
12323
- this.domOrderChanged = false;
12324
- const domOrderVisitor = new DomOrderVisitor();
12325
- this.renderView.accept(domOrderVisitor);
12326
- const painterRenderObjects = domOrderVisitor.getRenderObjectsByDomOrder();
12327
- for (let i = painterRenderObjects.length - 1; i >= 0; i--) {
12328
- const renderObject = painterRenderObjects[i];
12329
- renderObject.domOrder = i;
12330
- renderObject.rearrangeDomOrder();
12331
- }
12332
- }
12333
- didDomOrderChange() {
12334
- this.domOrderChanged = true;
12342
+ this.dirty = false;
12343
+ this.performRebuild();
12335
12344
  }
12336
- flushLayout() {
12337
- const dirties = this.needsLayoutRenderObjects;
12338
- this.needsLayoutRenderObjects = [];
12339
- dirties.sort((a, b) => a.depth - b.depth).forEach((renderObject) => {
12340
- if (!renderObject.needsLayout)
12341
- return;
12342
- renderObject.layoutWithoutResize();
12343
- });
12345
+ performRebuild() {
12346
+ throw new Error("not implemented performRebuild");
12344
12347
  }
12345
- flushPaint() {
12346
- const dirties = this.needsPaintRenderObjects;
12347
- this.needsPaintRenderObjects = [];
12348
- dirties.sort((a, b) => a.depth - b.depth).forEach((renderObject) => {
12349
- if (!renderObject.needsPaint)
12350
- return;
12351
- renderObject.paintWithoutLayout(this.paintContext);
12352
- });
12348
+ markNeedsBuild() {
12349
+ this.dirty = true;
12350
+ this.buildOwner.scheduleFor(this);
12353
12351
  }
12354
12352
  };
12355
- var DomOrderVisitor = class {
12356
- constructor() {
12357
- __publicField(this, "collectedRenderObjects", []);
12358
- __publicField(this, "currentVisitedOrder", 0);
12359
- __publicField(this, "currentStackingContext", []);
12353
+ var Element_default = Element;
12354
+
12355
+ // src/element/RenderObjectElement.ts
12356
+ var RenderObjectElement = class extends Element_default {
12357
+ constructor(widget) {
12358
+ super(widget);
12359
+ __publicField(this, "children");
12360
+ __publicField(this, "_renderObject");
12361
+ __publicField(this, "type", "render");
12362
+ __publicField(this, "ancestorRenderObjectElement");
12360
12363
  }
12361
- visit(renderObject, { willCollect }) {
12362
- if (willCollect) {
12363
- this.collectedRenderObjects.push({
12364
- renderObject,
12365
- contexts: this.currentStackingContext,
12366
- visitedOrder: this.currentVisitedOrder++
12367
- });
12368
- }
12369
- renderObject.visitChildren((child) => {
12370
- child.accept(this);
12371
- });
12364
+ createRenderObject() {
12365
+ const renderObject = this.widget.createRenderObject();
12366
+ return renderObject;
12372
12367
  }
12373
- visitGeneral(renderObject) {
12374
- this.visit(renderObject, { willCollect: renderObject.isPainter });
12368
+ get renderObject() {
12369
+ return this._renderObject;
12375
12370
  }
12376
- visitZIndex(renderObject) {
12377
- this.currentStackingContext = [...this.currentStackingContext];
12378
- this.currentStackingContext.push({
12379
- visitedOrder: this.currentVisitedOrder,
12380
- zIndex: renderObject.zIndex
12371
+ unmount() {
12372
+ super.unmount();
12373
+ this.renderObject.dispose(this.renderContext.paintContext);
12374
+ this.children.forEach((child) => {
12375
+ child.unmount();
12381
12376
  });
12382
- this.visit(renderObject, { willCollect: false });
12383
- this.currentStackingContext = [...this.currentStackingContext];
12384
- this.currentStackingContext.pop();
12377
+ this._renderObject.markNeedsParentLayout();
12385
12378
  }
12386
- getRenderObjectsByDomOrder() {
12387
- const sorted = this.collectedRenderObjects.sort((a, b) => {
12388
- var _a, _b;
12389
- const limit = Math.min(a.contexts.length, b.contexts.length);
12390
- for (let i = 0; i < limit; i++) {
12391
- const aContext = a.contexts[i];
12392
- const bContext = b.contexts[i];
12393
- if (aContext.zIndex !== bContext.zIndex) {
12394
- return aContext.zIndex - bContext.zIndex;
12395
- } else if (aContext.visitedOrder !== bContext.visitedOrder) {
12396
- return aContext.visitedOrder - bContext.visitedOrder;
12397
- }
12398
- }
12399
- if (limit > 0) {
12400
- const lastContext = a.contexts[limit - 1];
12401
- if (lastContext.visitedOrder === a.visitedOrder || lastContext.visitedOrder === b.visitedOrder) {
12402
- return a.visitedOrder - b.visitedOrder;
12403
- }
12404
- }
12405
- if (a.contexts.length !== b.contexts.length) {
12406
- const aContext = (_a = a.contexts[limit]) != null ? _a : {
12407
- visitedOrder: a.visitedOrder,
12408
- zIndex: 0
12409
- };
12410
- const bContext = (_b = b.contexts[limit]) != null ? _b : {
12411
- visitedOrder: b.visitedOrder,
12412
- zIndex: 0
12413
- };
12414
- if (aContext.zIndex !== bContext.zIndex) {
12415
- return aContext.zIndex - bContext.zIndex;
12416
- } else if (aContext.visitedOrder !== bContext.visitedOrder) {
12417
- return aContext.visitedOrder - bContext.visitedOrder;
12418
- }
12419
- }
12420
- return a.visitedOrder - b.visitedOrder;
12421
- });
12422
- return sorted.map(({ renderObject }) => renderObject);
12423
- }
12424
- };
12425
- var RenderOwner_default = RenderOwner;
12426
-
12427
- // src/scheduler/Scheduler.ts
12428
- var Scheduler = class {
12429
- constructor() {
12430
- __publicField(this, "phase");
12431
- __publicField(this, "persistenceCallbacks");
12432
- __publicField(this, "postFrameCallbacks");
12433
- this.phase = 0 /* idle */;
12434
- this.persistenceCallbacks = [];
12435
- this.postFrameCallbacks = [];
12436
- }
12437
- schedule() {
12438
- switch (this.phase) {
12439
- case 0 /* idle */:
12440
- case 2 /* postFrameCallbacks */:
12441
- this.performSchedule();
12442
- break;
12443
- case 1 /* persistenceCallbacks */:
12444
- break;
12379
+ mount(newParent) {
12380
+ var _a;
12381
+ super.mount(newParent);
12382
+ this._renderObject = this.createRenderObject();
12383
+ this.ancestorRenderObjectElement = this.findAncestorRenderObjectElement();
12384
+ const ancestorRenderObject = (_a = this.ancestorRenderObjectElement) == null ? void 0 : _a.renderObject;
12385
+ if (ancestorRenderObject) {
12386
+ this.renderObject.parent = ancestorRenderObject;
12387
+ this.renderObject.renderOwner = ancestorRenderObject.renderOwner;
12445
12388
  }
12389
+ this.children = this.widget.children.map(
12390
+ (childWidget) => this.inflateWidget(childWidget)
12391
+ );
12392
+ this._renderObject.attach(this);
12393
+ this._renderObject.markNeedsParentLayout();
12446
12394
  }
12447
- performSchedule() {
12448
- this.phase = 1 /* persistenceCallbacks */;
12449
- this.persistenceCallbacks.forEach((callback) => {
12450
- callback();
12395
+ update(newWidget) {
12396
+ super.update(newWidget);
12397
+ this.rebuild({ force: true });
12398
+ }
12399
+ updateChildren(newWidgets) {
12400
+ const updatedChildIndexes = [];
12401
+ const oldChildren = this.children;
12402
+ const newChildren = newWidgets.map((newWidget) => {
12403
+ const matchedChildIndex = oldChildren.findIndex(
12404
+ (oldChild, oldChildIndex) => !updatedChildIndexes.includes(oldChildIndex) && Widget_default.canUpdate(newWidget, oldChild.widget)
12405
+ );
12406
+ let matchedChild;
12407
+ if (matchedChildIndex === -1) {
12408
+ matchedChild = null;
12409
+ } else {
12410
+ matchedChild = oldChildren[matchedChildIndex];
12411
+ updatedChildIndexes.push(matchedChildIndex);
12412
+ }
12413
+ return this.updateChild(matchedChild, newWidget);
12451
12414
  });
12452
- this.phase = 2 /* postFrameCallbacks */;
12453
- this.postFrameCallbacks.forEach((callback) => {
12454
- callback();
12415
+ oldChildren.forEach((oldChild, i) => {
12416
+ if (updatedChildIndexes.includes(i))
12417
+ return;
12418
+ this.updateChild(oldChild, null);
12455
12419
  });
12456
- this.postFrameCallbacks = [];
12457
- this.phase = 0 /* idle */;
12420
+ this.children = newChildren;
12458
12421
  }
12459
- addPersistenceCallbacks(callback) {
12460
- this.persistenceCallbacks.push(() => callback());
12422
+ performRebuild() {
12423
+ this.widget.updateRenderObject(this._renderObject);
12424
+ const newChildWidgets = this.widget.children;
12425
+ this.updateChildren(newChildWidgets);
12461
12426
  }
12462
- addPostFrameCallbacks(callback) {
12463
- this.postFrameCallbacks.push(() => callback());
12427
+ visitChildren(visitor) {
12428
+ this.children.forEach((child) => visitor(child));
12429
+ }
12430
+ findAncestorRenderObjectElement() {
12431
+ let ancestor = this.parent;
12432
+ while (ancestor != null && !(ancestor.type === "render")) {
12433
+ ancestor = ancestor.parent;
12434
+ }
12435
+ return ancestor;
12464
12436
  }
12465
12437
  };
12466
- var Scheduler_default = Scheduler;
12438
+ var RenderObjectElement_default = RenderObjectElement;
12467
12439
 
12468
- // src/scheduler/RenderFrameDispatcher.ts
12469
- var RenderFrameDispatcher = class {
12470
- constructor({ onFrame } = {}) {
12471
- __publicField(this, "onFrame");
12472
- this.onFrame = onFrame;
12440
+ // src/widget/RenderObjectWidget.ts
12441
+ var RenderObjectWidget = class extends Widget_default {
12442
+ constructor({ children = [], key }) {
12443
+ super(key);
12444
+ __publicField(this, "children");
12445
+ this.children = children;
12473
12446
  }
12474
- setOnFrame(callback) {
12475
- this.onFrame = () => callback();
12447
+ createElement() {
12448
+ return new RenderObjectElement_default(this);
12476
12449
  }
12477
- // Actually we dont need to invoke browser to render because browser automatically render its own state periodically
12478
- // so Here we just call onFrame callback.
12479
- dispatch() {
12480
- if (typeof window === "undefined") {
12481
- setTimeout(() => {
12482
- var _a;
12483
- (_a = this.onFrame) == null ? void 0 : _a.call(this);
12484
- }, 0);
12485
- } else {
12486
- window.requestAnimationFrame(() => {
12487
- var _a;
12488
- (_a = this.onFrame) == null ? void 0 : _a.call(this);
12489
- });
12490
- }
12450
+ createRenderObject() {
12451
+ throw { message: "not implemented createRenderObject" };
12452
+ }
12453
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12454
+ updateRenderObject(renderObject) {
12455
+ throw { message: "not implemented updatedRenderObject" };
12491
12456
  }
12492
12457
  };
12493
- var RenderFrameDispatcher_default = RenderFrameDispatcher;
12458
+ var RenderObjectWidget_default = RenderObjectWidget;
12494
12459
 
12495
- // src/scheduler/Globalkey.ts
12496
- var GlobalKey = class {
12497
- constructor() {
12460
+ // src/widget/RenderObjectToWidgetAdapter.ts
12461
+ var RenderObjectToWidgetAdapter = class extends RenderObjectWidget_default {
12462
+ constructor({
12463
+ app,
12464
+ renderOwner,
12465
+ buildOwner,
12466
+ renderContext,
12467
+ scheduler
12468
+ }) {
12469
+ super({ children: [app] });
12470
+ __publicField(this, "renderOwner");
12498
12471
  __publicField(this, "buildOwner");
12472
+ __publicField(this, "renderContext");
12473
+ __publicField(this, "scheduler");
12474
+ this.renderOwner = renderOwner;
12475
+ this.buildOwner = buildOwner;
12476
+ this.renderContext = renderContext;
12477
+ this.scheduler = scheduler;
12499
12478
  }
12500
- get currentContext() {
12501
- assert(
12502
- this.buildOwner != null,
12503
- "buildOwner is null, currentContext must be called after initState"
12504
- );
12505
- return this.buildOwner.findByGlobalKey(this);
12479
+ createElement() {
12480
+ const el = super.createElement();
12481
+ el.renderContext = this.renderContext;
12482
+ el.buildOwner = this.buildOwner;
12483
+ el.scheduler = this.scheduler;
12484
+ return el;
12485
+ }
12486
+ createRenderObject() {
12487
+ return new RenderView_default({ renderOwner: this.renderOwner });
12488
+ }
12489
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12490
+ updateRenderObject(renderObject) {
12506
12491
  }
12507
12492
  };
12508
- var Globalkey_default = GlobalKey;
12493
+ var RenderObjectToWidgetAdapter_default = RenderObjectToWidgetAdapter;
12509
12494
 
12510
- // src/element/Element.ts
12511
- var Element = class {
12512
- constructor(widget) {
12513
- __publicField(this, "scheduler");
12514
- __publicField(this, "renderContext");
12515
- __publicField(this, "buildOwner");
12516
- __publicField(this, "widget");
12517
- __publicField(this, "parent");
12518
- __publicField(this, "dirty", true);
12519
- __publicField(this, "depth", 0);
12520
- this.widget = widget;
12495
+ // src/scheduler/BuildOwner.ts
12496
+ var BuildOwner = class {
12497
+ constructor({ onNeedVisualUpdate }) {
12498
+ __publicField(this, "onNeedVisualUpdate");
12499
+ __publicField(this, "dirtyElements", []);
12500
+ __publicField(this, "globalKeyRegistry", /* @__PURE__ */ new WeakMap());
12501
+ this.onNeedVisualUpdate = () => onNeedVisualUpdate();
12521
12502
  }
12522
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
12523
- visitChildren(visitor) {
12524
- throw { message: "not implemented" };
12503
+ scheduleFor(elememt) {
12504
+ this.dirtyElements.push(elememt);
12505
+ this.requestVisualUpdate();
12525
12506
  }
12526
- get renderObject() {
12527
- let result = null;
12528
- this.visitChildren((child) => {
12529
- result = child.renderObject;
12507
+ requestVisualUpdate() {
12508
+ this.onNeedVisualUpdate();
12509
+ }
12510
+ flushBuild() {
12511
+ const dirtyElements = this.dirtyElements;
12512
+ this.dirtyElements = [];
12513
+ dirtyElements.sort((a, b) => a.depth - b.depth).forEach((elememt) => {
12514
+ if (!elememt.dirty)
12515
+ return;
12516
+ elememt.rebuild();
12530
12517
  });
12531
- if (result == null)
12532
- throw { message: "can not find render object" };
12518
+ }
12519
+ registerGlobalKey(key, elememt) {
12520
+ key.buildOwner = this;
12521
+ this.globalKeyRegistry.set(key, elememt);
12522
+ }
12523
+ findByGlobalKey(key) {
12524
+ const result = this.globalKeyRegistry.get(key);
12533
12525
  return result;
12534
12526
  }
12535
- //There are 5 case
12536
- // 1. child is not null, but widget is null
12537
- // in this case, child must be unmounted
12538
- // 2. child is null, widget is null
12539
- // nothing happend
12540
- // 3. child is null, widget is not null
12541
- // newWidget would be inflated,
12542
- // 4. child is not null, widget is not null, and widget can be update
12543
- // in this case, just update widget configruation
12544
- // 5. it is similar to 4 but widget can not be update,
12545
- // in this case, child must be unmounted and newWidget would be inflated
12546
- updateChild(child, newWidget) {
12547
- if (child != null && newWidget == null) {
12548
- child.unmount();
12549
- return null;
12550
- } else if (child == null && newWidget == null) {
12551
- } else if (child == null && newWidget != null) {
12552
- return this.inflateWidget(newWidget);
12553
- } else if (child != null && newWidget != null && Widget_default.canUpdate(child.widget, newWidget)) {
12554
- child.update(newWidget);
12555
- return child;
12556
- } else {
12557
- child.unmount();
12558
- return this.inflateWidget(newWidget);
12559
- }
12527
+ };
12528
+ var BuildOwner_default = BuildOwner;
12529
+
12530
+ // src/scheduler/RenderOwner.ts
12531
+ var RenderOwner = class {
12532
+ constructor({
12533
+ onNeedVisualUpdate,
12534
+ paintContext
12535
+ }) {
12536
+ __publicField(this, "paintContext");
12537
+ __publicField(this, "onNeedVisualUpdate");
12538
+ __publicField(this, "needsPaintRenderObjects", []);
12539
+ __publicField(this, "needsLayoutRenderObjects", []);
12540
+ /*
12541
+ this will be set by RenderView
12542
+ */
12543
+ __publicField(this, "renderView");
12544
+ __publicField(this, "domOrderChanged", true);
12545
+ this.onNeedVisualUpdate = onNeedVisualUpdate;
12546
+ this.paintContext = paintContext;
12560
12547
  }
12561
- unmount() {
12562
- this.parent = void 0;
12548
+ requestVisualUpdate() {
12549
+ this.onNeedVisualUpdate();
12563
12550
  }
12564
- mount(newParent) {
12565
- if (newParent) {
12566
- this.renderContext = newParent.renderContext;
12567
- this.buildOwner = newParent.buildOwner;
12568
- this.depth = newParent.depth + 1;
12569
- this.scheduler = newParent.scheduler;
12570
- }
12571
- this.parent = newParent;
12572
- if (this.widget.key instanceof Globalkey_default) {
12573
- this.buildOwner.registerGlobalKey(this.widget.key, this);
12551
+ drawFrame() {
12552
+ this.flushLayout();
12553
+ this.rearrangeDomOrder();
12554
+ this.flushPaint();
12555
+ }
12556
+ rearrangeDomOrder() {
12557
+ if (!this.domOrderChanged)
12558
+ return;
12559
+ this.domOrderChanged = false;
12560
+ const domOrderVisitor = new DomOrderVisitor();
12561
+ this.renderView.accept(domOrderVisitor);
12562
+ const painterRenderObjects = domOrderVisitor.getRenderObjectsByDomOrder();
12563
+ for (let i = painterRenderObjects.length - 1; i >= 0; i--) {
12564
+ const renderObject = painterRenderObjects[i];
12565
+ renderObject.domOrder = i;
12566
+ renderObject.rearrangeDomOrder();
12574
12567
  }
12575
12568
  }
12576
- update(newWidget) {
12577
- this.widget = newWidget;
12569
+ didDomOrderChange() {
12570
+ this.domOrderChanged = true;
12578
12571
  }
12579
- inflateWidget(childWidget) {
12580
- const newChild = childWidget.createElement();
12581
- newChild.mount(this);
12582
- return newChild;
12572
+ flushLayout() {
12573
+ const dirties = this.needsLayoutRenderObjects;
12574
+ this.needsLayoutRenderObjects = [];
12575
+ dirties.sort((a, b) => a.depth - b.depth).forEach((renderObject) => {
12576
+ if (!renderObject.needsLayout)
12577
+ return;
12578
+ renderObject.layoutWithoutResize();
12579
+ });
12583
12580
  }
12584
- rebuild({ force = false } = {}) {
12585
- if (!this.dirty && !force)
12586
- return;
12587
- this.dirty = false;
12588
- this.performRebuild();
12581
+ flushPaint() {
12582
+ const dirties = this.needsPaintRenderObjects;
12583
+ this.needsPaintRenderObjects = [];
12584
+ dirties.sort((a, b) => a.depth - b.depth).forEach((renderObject) => {
12585
+ if (!renderObject.needsPaint)
12586
+ return;
12587
+ renderObject.paintWithoutLayout(this.paintContext);
12588
+ });
12589
12589
  }
12590
- performRebuild() {
12591
- throw new Error("not implemented performRebuild");
12590
+ };
12591
+ var DomOrderVisitor = class {
12592
+ constructor() {
12593
+ __publicField(this, "collectedRenderObjects", []);
12594
+ __publicField(this, "currentVisitedOrder", 0);
12595
+ __publicField(this, "currentStackingContext", []);
12592
12596
  }
12593
- markNeedsBuild() {
12594
- this.dirty = true;
12595
- this.buildOwner.scheduleFor(this);
12597
+ visit(renderObject, { willCollect }) {
12598
+ if (willCollect) {
12599
+ this.collectedRenderObjects.push({
12600
+ renderObject,
12601
+ contexts: this.currentStackingContext,
12602
+ visitedOrder: this.currentVisitedOrder++
12603
+ });
12604
+ }
12605
+ renderObject.visitChildren((child) => {
12606
+ child.accept(this);
12607
+ });
12608
+ }
12609
+ visitGeneral(renderObject) {
12610
+ this.visit(renderObject, { willCollect: renderObject.isPainter });
12611
+ }
12612
+ visitZIndex(renderObject) {
12613
+ this.currentStackingContext = [...this.currentStackingContext];
12614
+ this.currentStackingContext.push({
12615
+ visitedOrder: this.currentVisitedOrder,
12616
+ zIndex: renderObject.zIndex
12617
+ });
12618
+ this.visit(renderObject, { willCollect: false });
12619
+ this.currentStackingContext = [...this.currentStackingContext];
12620
+ this.currentStackingContext.pop();
12621
+ }
12622
+ getRenderObjectsByDomOrder() {
12623
+ const sorted = this.collectedRenderObjects.sort((a, b) => {
12624
+ var _a, _b;
12625
+ const limit = Math.min(a.contexts.length, b.contexts.length);
12626
+ for (let i = 0; i < limit; i++) {
12627
+ const aContext = a.contexts[i];
12628
+ const bContext = b.contexts[i];
12629
+ if (aContext.zIndex !== bContext.zIndex) {
12630
+ return aContext.zIndex - bContext.zIndex;
12631
+ } else if (aContext.visitedOrder !== bContext.visitedOrder) {
12632
+ return aContext.visitedOrder - bContext.visitedOrder;
12633
+ }
12634
+ }
12635
+ if (limit > 0) {
12636
+ const lastContext = a.contexts[limit - 1];
12637
+ if (lastContext.visitedOrder === a.visitedOrder || lastContext.visitedOrder === b.visitedOrder) {
12638
+ return a.visitedOrder - b.visitedOrder;
12639
+ }
12640
+ }
12641
+ if (a.contexts.length !== b.contexts.length) {
12642
+ const aContext = (_a = a.contexts[limit]) != null ? _a : {
12643
+ visitedOrder: a.visitedOrder,
12644
+ zIndex: 0
12645
+ };
12646
+ const bContext = (_b = b.contexts[limit]) != null ? _b : {
12647
+ visitedOrder: b.visitedOrder,
12648
+ zIndex: 0
12649
+ };
12650
+ if (aContext.zIndex !== bContext.zIndex) {
12651
+ return aContext.zIndex - bContext.zIndex;
12652
+ } else if (aContext.visitedOrder !== bContext.visitedOrder) {
12653
+ return aContext.visitedOrder - bContext.visitedOrder;
12654
+ }
12655
+ }
12656
+ return a.visitedOrder - b.visitedOrder;
12657
+ });
12658
+ return sorted.map(({ renderObject }) => renderObject);
12596
12659
  }
12597
12660
  };
12598
- var Element_default = Element;
12661
+ var RenderOwner_default = RenderOwner;
12599
12662
 
12600
- // src/element/RenderObjectElement.ts
12601
- var RenderObjectElement = class _RenderObjectElement extends Element_default {
12602
- constructor(widget) {
12603
- super(widget);
12604
- __publicField(this, "children");
12605
- __publicField(this, "_renderObject");
12606
- __publicField(this, "ancestorRenderObjectElement");
12607
- }
12608
- createRenderObject() {
12609
- const renderObject = this.widget.createRenderObject();
12610
- return renderObject;
12611
- }
12612
- get renderObject() {
12613
- return this._renderObject;
12614
- }
12615
- unmount() {
12616
- super.unmount();
12617
- this.renderObject.dispose(this.renderContext.paintContext);
12618
- this.children.forEach((child) => {
12619
- child.unmount();
12620
- });
12621
- this._renderObject.markNeedsParentLayout();
12663
+ // src/scheduler/Scheduler.ts
12664
+ var Scheduler = class {
12665
+ constructor() {
12666
+ __publicField(this, "phase");
12667
+ __publicField(this, "persistenceCallbacks");
12668
+ __publicField(this, "postFrameCallbacks");
12669
+ this.phase = 0 /* idle */;
12670
+ this.persistenceCallbacks = [];
12671
+ this.postFrameCallbacks = [];
12622
12672
  }
12623
- mount(newParent) {
12624
- var _a;
12625
- super.mount(newParent);
12626
- this._renderObject = this.createRenderObject();
12627
- this.ancestorRenderObjectElement = this.findAncestorRenderObjectElement();
12628
- const ancestorRenderObject = (_a = this.ancestorRenderObjectElement) == null ? void 0 : _a.renderObject;
12629
- if (ancestorRenderObject) {
12630
- this.renderObject.parent = ancestorRenderObject;
12631
- this.renderObject.renderOwner = ancestorRenderObject.renderOwner;
12673
+ schedule() {
12674
+ switch (this.phase) {
12675
+ case 0 /* idle */:
12676
+ case 2 /* postFrameCallbacks */:
12677
+ this.performSchedule();
12678
+ break;
12679
+ case 1 /* persistenceCallbacks */:
12680
+ break;
12632
12681
  }
12633
- this.children = this.widget.children.map(
12634
- (childWidget) => this.inflateWidget(childWidget)
12635
- );
12636
- this._renderObject.attach(this);
12637
- this._renderObject.markNeedsParentLayout();
12638
- }
12639
- update(newWidget) {
12640
- super.update(newWidget);
12641
- this.rebuild({ force: true });
12642
12682
  }
12643
- updateChildren(newWidgets) {
12644
- const updatedChildIndexes = [];
12645
- const oldChildren = this.children;
12646
- const newChildren = newWidgets.map((newWidget) => {
12647
- const matchedChildIndex = oldChildren.findIndex(
12648
- (oldChild, oldChildIndex) => !updatedChildIndexes.includes(oldChildIndex) && Widget_default.canUpdate(newWidget, oldChild.widget)
12649
- );
12650
- let matchedChild;
12651
- if (matchedChildIndex === -1) {
12652
- matchedChild = null;
12653
- } else {
12654
- matchedChild = oldChildren[matchedChildIndex];
12655
- updatedChildIndexes.push(matchedChildIndex);
12656
- }
12657
- return this.updateChild(matchedChild, newWidget);
12683
+ performSchedule() {
12684
+ this.phase = 1 /* persistenceCallbacks */;
12685
+ this.persistenceCallbacks.forEach((callback) => {
12686
+ callback();
12658
12687
  });
12659
- oldChildren.forEach((oldChild, i) => {
12660
- if (updatedChildIndexes.includes(i))
12661
- return;
12662
- this.updateChild(oldChild, null);
12688
+ this.phase = 2 /* postFrameCallbacks */;
12689
+ this.postFrameCallbacks.forEach((callback) => {
12690
+ callback();
12663
12691
  });
12664
- this.children = newChildren;
12665
- }
12666
- performRebuild() {
12667
- this.widget.updateRenderObject(this._renderObject);
12668
- const newChildWidgets = this.widget.children;
12669
- this.updateChildren(newChildWidgets);
12692
+ this.postFrameCallbacks = [];
12693
+ this.phase = 0 /* idle */;
12670
12694
  }
12671
- visitChildren(visitor) {
12672
- this.children.forEach((child) => visitor(child));
12695
+ addPersistenceCallbacks(callback) {
12696
+ this.persistenceCallbacks.push(() => callback());
12673
12697
  }
12674
- findAncestorRenderObjectElement() {
12675
- let ancestor = this.parent;
12676
- while (ancestor != null && !(ancestor instanceof _RenderObjectElement)) {
12677
- ancestor = ancestor.parent;
12678
- }
12679
- return ancestor;
12698
+ addPostFrameCallbacks(callback) {
12699
+ this.postFrameCallbacks.push(() => callback());
12680
12700
  }
12681
12701
  };
12682
- var RenderObjectElement_default = RenderObjectElement;
12702
+ var Scheduler_default = Scheduler;
12683
12703
 
12684
- // src/widget/RenderObjectWidget.ts
12685
- var RenderObjectWidget = class extends Widget_default {
12686
- constructor({ children = [], key }) {
12687
- super(key);
12688
- __publicField(this, "children");
12689
- this.children = children;
12690
- }
12691
- createElement() {
12692
- return new RenderObjectElement_default(this);
12704
+ // src/scheduler/RenderFrameDispatcher.ts
12705
+ var RenderFrameDispatcher = class {
12706
+ constructor({ onFrame } = {}) {
12707
+ __publicField(this, "onFrame");
12708
+ this.onFrame = onFrame;
12693
12709
  }
12694
- createRenderObject() {
12695
- throw { message: "not implemented createRenderObject" };
12710
+ setOnFrame(callback) {
12711
+ this.onFrame = () => callback();
12696
12712
  }
12697
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
12698
- updateRenderObject(renderObject) {
12699
- throw { message: "not implemented updatedRenderObject" };
12713
+ // Actually we dont need to invoke browser to render because browser automatically render its own state periodically
12714
+ // so Here we just call onFrame callback.
12715
+ dispatch() {
12716
+ if (typeof window === "undefined") {
12717
+ setTimeout(() => {
12718
+ var _a;
12719
+ (_a = this.onFrame) == null ? void 0 : _a.call(this);
12720
+ }, 0);
12721
+ } else {
12722
+ window.requestAnimationFrame(() => {
12723
+ var _a;
12724
+ (_a = this.onFrame) == null ? void 0 : _a.call(this);
12725
+ });
12726
+ }
12700
12727
  }
12701
12728
  };
12702
- var RenderObjectWidget_default = RenderObjectWidget;
12729
+ var RenderFrameDispatcher_default = RenderFrameDispatcher;
12703
12730
 
12704
- // src/widget/RenderObjectToWidgetAdapter.ts
12705
- var RenderObjectToWidgetAdapter = class extends RenderObjectWidget_default {
12706
- constructor({
12707
- app,
12708
- renderOwner,
12709
- buildOwner,
12710
- renderContext,
12711
- scheduler
12712
- }) {
12713
- super({ children: [app] });
12714
- __publicField(this, "renderOwner");
12731
+ // src/scheduler/Globalkey.ts
12732
+ var GlobalKey = class {
12733
+ constructor() {
12734
+ __publicField(this, "isGlobalKey", true);
12715
12735
  __publicField(this, "buildOwner");
12716
- __publicField(this, "renderContext");
12717
- __publicField(this, "scheduler");
12718
- this.renderOwner = renderOwner;
12719
- this.buildOwner = buildOwner;
12720
- this.renderContext = renderContext;
12721
- this.scheduler = scheduler;
12722
- }
12723
- createElement() {
12724
- const el = super.createElement();
12725
- el.renderContext = this.renderContext;
12726
- el.buildOwner = this.buildOwner;
12727
- el.scheduler = this.scheduler;
12728
- return el;
12729
- }
12730
- createRenderObject() {
12731
- return new RenderView_default({ renderOwner: this.renderOwner });
12732
12736
  }
12733
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
12734
- updateRenderObject(renderObject) {
12737
+ get currentContext() {
12738
+ assert(
12739
+ this.buildOwner != null,
12740
+ "buildOwner is null, currentContext must be called after initState"
12741
+ );
12742
+ return this.buildOwner.findByGlobalKey(this);
12735
12743
  }
12736
12744
  };
12737
- var RenderObjectToWidgetAdapter_default = RenderObjectToWidgetAdapter;
12745
+ var Globalkey_default = GlobalKey;
12738
12746
 
12739
12747
  // src/runApp.ts
12740
12748
  var AppRunner = class {
@@ -13016,7 +13024,7 @@ var Provider = class extends Widget_default {
13016
13024
  while (parent != null) {
13017
13025
  const current = parent;
13018
13026
  parent = current.parent;
13019
- if (!(current instanceof ProviderElement))
13027
+ if (!(current.type === "provider"))
13020
13028
  continue;
13021
13029
  if (current.providerKey !== key)
13022
13030
  continue;
@@ -13028,10 +13036,11 @@ var Provider = class extends Widget_default {
13028
13036
  return new ProviderElement(this);
13029
13037
  }
13030
13038
  };
13031
- var ProviderElement = class extends Element_default {
13039
+ var _ProviderElement = class _ProviderElement extends Element_default {
13032
13040
  constructor(widget) {
13033
13041
  super(widget);
13034
13042
  __publicField(this, "child");
13043
+ __publicField(this, "type", _ProviderElement.type);
13035
13044
  this.widget = widget;
13036
13045
  }
13037
13046
  get providerKey() {
@@ -13055,6 +13064,8 @@ var ProviderElement = class extends Element_default {
13055
13064
  this.child = this.updateChild(this.child, this.child.widget);
13056
13065
  }
13057
13066
  };
13067
+ __publicField(_ProviderElement, "type", "provider");
13068
+ var ProviderElement = _ProviderElement;
13058
13069
  function ProviderFn(props) {
13059
13070
  return new Provider(props);
13060
13071
  }
@@ -13818,75 +13829,22 @@ var ClipPath = class extends StatelessWidget_default {
13818
13829
  return new BaseClipPath_default({ child: this.child, clipper: this.clipper });
13819
13830
  }
13820
13831
  };
13821
- var ClipPath_default = classToFunction_default(ClipPath);
13822
-
13823
- // src/component/ClipRect.ts
13824
- function ClipRect({
13825
- child,
13826
- clipper,
13827
- clipped = true,
13828
- key
13829
- }) {
13830
- return ClipPath_default({
13831
- child,
13832
- clipped,
13833
- key,
13834
- clipper: (size) => new path_default().addRect(clipper(size))
13835
- });
13836
- }
13837
-
13838
- // src/component/base/BaseFlexible.ts
13839
- var Flexible = class extends SingleChildRenderObjectWidget_default {
13840
- constructor({
13841
- flex = 1,
13842
- child,
13843
- fit = "loose",
13844
- key
13845
- } = {}) {
13846
- super({ child, key });
13847
- __publicField(this, "flex");
13848
- __publicField(this, "fit");
13849
- if (flex < 0)
13850
- throw { message: "flex must not be under zero" };
13851
- this.flex = flex;
13852
- this.fit = fit;
13853
- }
13854
- createRenderObject() {
13855
- return new RenderFlexible({ flex: this.flex, fit: this.fit });
13856
- }
13857
- updateRenderObject(renderObject) {
13858
- renderObject.flex = this.flex;
13859
- renderObject.fit = this.fit;
13860
- }
13861
- };
13862
- var RenderFlexible = class extends SingleChildRenderObject_default {
13863
- constructor({ flex, fit }) {
13864
- super({ isPainter: false });
13865
- __publicField(this, "_flex");
13866
- __publicField(this, "_fit");
13867
- this._flex = flex;
13868
- this._fit = fit;
13869
- }
13870
- get flex() {
13871
- return this._flex;
13872
- }
13873
- set flex(newFlex) {
13874
- if (this._flex === newFlex)
13875
- return;
13876
- this._flex = newFlex;
13877
- this.markNeedsLayout();
13878
- }
13879
- get fit() {
13880
- return this._fit;
13881
- }
13882
- set fit(newFit) {
13883
- if (this._fit === newFit)
13884
- return;
13885
- this._fit = newFit;
13886
- this.markNeedsLayout();
13887
- }
13888
- };
13889
- var BaseFlexible_default = Flexible;
13832
+ var ClipPath_default = classToFunction_default(ClipPath);
13833
+
13834
+ // src/component/ClipRect.ts
13835
+ function ClipRect({
13836
+ child,
13837
+ clipper,
13838
+ clipped = true,
13839
+ key
13840
+ }) {
13841
+ return ClipPath_default({
13842
+ child,
13843
+ clipped,
13844
+ key,
13845
+ clipper: (size) => new path_default().addRect(clipper(size))
13846
+ });
13847
+ }
13890
13848
 
13891
13849
  // src/component/base/BaseFlex.ts
13892
13850
  var Flex = class extends MultiChildRenderObjectWidget_default {
@@ -14016,7 +13974,7 @@ var RenderFlex = class extends MultiChildRenderObject_default {
14016
13974
  const sortedChildren = this.verticalDirection === "down" ? this.children : [...this.children].reverse();
14017
13975
  sortedChildren.forEach((child) => {
14018
13976
  child.layout(this.constraints.loosen());
14019
- const flex = child instanceof RenderFlexible ? child.flex : 0;
13977
+ const flex = (child == null ? void 0 : child.isRenderFlexible) ? child.flex : 0;
14020
13978
  totalFlex += flex;
14021
13979
  if (flex === 0) {
14022
13980
  childIntrinsicMainAxisValue += child.size[this.mainAxisSizeName];
@@ -14026,14 +13984,15 @@ var RenderFlex = class extends MultiChildRenderObject_default {
14026
13984
  const flexUnitSize = (this.constraints.getMax(this.mainAxisSizeName) - childIntrinsicMainAxisValue) / totalFlex;
14027
13985
  sortedChildren.forEach((child) => {
14028
13986
  let childConstraint;
14029
- if (!(child instanceof RenderFlexible)) {
13987
+ if (!child.isRenderFlexible) {
14030
13988
  childConstraint = this.getNonFlexItemConstraint(crossAxisValue);
14031
13989
  } else {
14032
- const flex = child.flex;
13990
+ const flexible = child;
13991
+ const flex = flexible.flex;
14033
13992
  const childMainAxisValue = flex * flexUnitSize;
14034
13993
  childConstraint = this.getFlexItemConstraint(
14035
13994
  childMainAxisValue,
14036
- child.fit
13995
+ flexible.fit
14037
13996
  );
14038
13997
  }
14039
13998
  child.layout(childConstraint.enforce(this.constraints.loosen()));
@@ -14894,6 +14853,61 @@ var _Text = class extends StatelessWidget_default {
14894
14853
  }
14895
14854
  };
14896
14855
 
14856
+ // src/component/base/BaseFlexible.ts
14857
+ var Flexible = class extends SingleChildRenderObjectWidget_default {
14858
+ constructor({
14859
+ flex = 1,
14860
+ child,
14861
+ fit = "loose",
14862
+ key
14863
+ } = {}) {
14864
+ super({ child, key });
14865
+ __publicField(this, "isFlexible", true);
14866
+ __publicField(this, "flex");
14867
+ __publicField(this, "fit");
14868
+ if (flex < 0)
14869
+ throw { message: "flex must not be under zero" };
14870
+ this.flex = flex;
14871
+ this.fit = fit;
14872
+ }
14873
+ createRenderObject() {
14874
+ return new RenderFlexible({ flex: this.flex, fit: this.fit });
14875
+ }
14876
+ updateRenderObject(renderObject) {
14877
+ renderObject.flex = this.flex;
14878
+ renderObject.fit = this.fit;
14879
+ }
14880
+ };
14881
+ var RenderFlexible = class extends SingleChildRenderObject_default {
14882
+ constructor({ flex, fit }) {
14883
+ super({ isPainter: false });
14884
+ __publicField(this, "isRenderFlexible", true);
14885
+ __publicField(this, "_flex");
14886
+ __publicField(this, "_fit");
14887
+ this._flex = flex;
14888
+ this._fit = fit;
14889
+ }
14890
+ get flex() {
14891
+ return this._flex;
14892
+ }
14893
+ set flex(newFlex) {
14894
+ if (this._flex === newFlex)
14895
+ return;
14896
+ this._flex = newFlex;
14897
+ this.markNeedsLayout();
14898
+ }
14899
+ get fit() {
14900
+ return this._fit;
14901
+ }
14902
+ set fit(newFit) {
14903
+ if (this._fit === newFit)
14904
+ return;
14905
+ this._fit = newFit;
14906
+ this.markNeedsLayout();
14907
+ }
14908
+ };
14909
+ var BaseFlexible_default = Flexible;
14910
+
14897
14911
  // src/component/Flexible.ts
14898
14912
  var Flexible_default = classToFunction_default(BaseFlexible_default);
14899
14913
 
@@ -15290,6 +15304,8 @@ var Padding = class extends SingleChildRenderObjectWidget_default {
15290
15304
  }) {
15291
15305
  super({ child, key });
15292
15306
  __publicField(this, "padding");
15307
+ if ((child == null ? void 0 : child.isFlexible) && child.fit === "tight")
15308
+ throw { message: "Padding must not have a Expanded Widget" };
15293
15309
  this.padding = padding;
15294
15310
  }
15295
15311
  createRenderObject() {
@@ -15345,8 +15361,6 @@ function Padding2({
15345
15361
  child,
15346
15362
  key
15347
15363
  }) {
15348
- if (child instanceof Expanded_default)
15349
- throw { message: "Padding must not have a Expanded Widget" };
15350
15364
  return new Padding({ padding, child, key });
15351
15365
  }
15352
15366
 
@@ -15934,239 +15948,103 @@ var RenderBaseGrid = class extends MultiChildRenderObject_default {
15934
15948
  let result = 0;
15935
15949
  if (type === "fr") {
15936
15950
  result = value * frUnitOnWidth;
15937
- } else {
15938
- result = fixedColumnWidths[i];
15939
- }
15940
- return result;
15941
- });
15942
- const totalFrOnHeight = this.rows.filter(({ type }) => type === "fr").map(({ value }) => value).reduce(sum, 0);
15943
- const totalFixedHeight = fixedRowHeights.reduce(sum, 0);
15944
- const frUnitOnHeight = (this.size.height - totalFixedHeight) / totalFrOnHeight;
15945
- const heights = this.rows.map(({ type, value }, i) => {
15946
- let result = 0;
15947
- if (type === "fr") {
15948
- result = value * frUnitOnHeight;
15949
- } else {
15950
- result = fixedRowHeights[i];
15951
- }
15952
- return result;
15953
- });
15954
- this.childrenByRow.forEach((columnChildren, rowIndex) => {
15955
- columnChildren.forEach((child, columnIndex) => {
15956
- const childConstraint = new constraints_default(__spreadProps(__spreadValues({}, this.constraints), {
15957
- maxHeight: heights[rowIndex],
15958
- maxWidth: widths[columnIndex]
15959
- }));
15960
- child.layout(childConstraint);
15961
- child.offset = new offset_default({
15962
- x: widths.slice(0, columnIndex).reduce(sum, 0),
15963
- y: heights.slice(0, rowIndex).reduce(sum, 0)
15964
- });
15965
- });
15966
- });
15967
- }
15968
- getIntrinsicWidth(height) {
15969
- return this.childrenByRow.map(
15970
- (row) => row.map((child) => child.getIntrinsicWidth(height)).reduce(Utils.sumReducer)
15971
- ).reduce(Utils.maxReducer);
15972
- }
15973
- getIntrinsicHeight(width) {
15974
- return this.childrenByRow.map(
15975
- (row) => row.map((child) => child.getIntrinsicHeight(width)).reduce(Utils.maxReducer)
15976
- ).reduce(Utils.sumReducer);
15977
- }
15978
- };
15979
- var GridTemplate = class _GridTemplate {
15980
- constructor({
15981
- type,
15982
- value
15983
- }) {
15984
- __publicField(this, "type");
15985
- __publicField(this, "value");
15986
- this.type = type;
15987
- this.value = value;
15988
- }
15989
- static equals(target, other) {
15990
- if (target.length !== other.length)
15991
- return false;
15992
- return target.every((value, i) => value.equals(other[i]));
15993
- }
15994
- equals(other) {
15995
- if (this === other)
15996
- return true;
15997
- return this.type === other.type && this.value === other.value;
15998
- }
15999
- static Fr(value) {
16000
- return new _GridTemplate({ value, type: "fr" });
16001
- }
16002
- static Px(value) {
16003
- return new _GridTemplate({ value, type: "px" });
16004
- }
16005
- static ContentFit() {
16006
- return new _GridTemplate({ value: 0, type: "content-fit" });
16007
- }
16008
- // 0 ~ 100
16009
- static Percent(value) {
16010
- return new _GridTemplate({ value, type: "percent" });
16011
- }
16012
- repeat(count) {
16013
- return Array.from({ length: count }, () => this);
16014
- }
16015
- };
16016
- var BaseGrid_default = BaseGrid;
16017
-
16018
- // src/component/Grid.ts
16019
- function Grid(_a) {
16020
- var _b = _a, {
16021
- childrenByRow,
16022
- key
16023
- } = _b, props = __objRest(_b, [
16024
- "childrenByRow",
16025
- "key"
16026
- ]);
16027
- return new BaseGrid_default(__spreadValues({ childrenByRow, key }, props));
16028
- }
16029
- Grid.Fr = GridTemplate.Fr;
16030
- Grid.ContentFit = GridTemplate.ContentFit;
16031
- Grid.Percent = GridTemplate.Percent;
16032
- Grid.Px = GridTemplate.Px;
16033
- var Grid_default = Grid;
16034
-
16035
- // src/component/base/BasePositioned.ts
16036
- var BasePositioned = class extends SingleChildRenderObjectWidget_default {
16037
- constructor({
16038
- top,
16039
- bottom,
16040
- left,
16041
- right,
16042
- width,
16043
- height,
16044
- child,
16045
- key
16046
- }) {
16047
- super({ child, key });
16048
- __publicField(this, "top");
16049
- __publicField(this, "bottom");
16050
- __publicField(this, "right");
16051
- __publicField(this, "left");
16052
- __publicField(this, "width");
16053
- __publicField(this, "height");
16054
- this.top = top;
16055
- this.bottom = bottom;
16056
- this.left = left;
16057
- this.right = right;
16058
- this.width = width;
16059
- this.height = height;
16060
- }
16061
- createRenderObject() {
16062
- return new RenderPositioned({
16063
- top: this.top,
16064
- left: this.left,
16065
- right: this.right,
16066
- bottom: this.bottom,
16067
- width: this.width,
16068
- height: this.height
16069
- });
16070
- }
16071
- updateRenderObject(renderObject) {
16072
- renderObject.top = this.top;
16073
- renderObject.left = this.left;
16074
- renderObject.bottom = this.bottom;
16075
- renderObject.right = this.right;
16076
- renderObject.width = this.width;
16077
- renderObject.height = this.height;
16078
- }
16079
- };
16080
- var RenderPositioned = class extends SingleChildRenderObject_default {
16081
- constructor({
16082
- top,
16083
- bottom,
16084
- left,
16085
- right,
16086
- width,
16087
- height
16088
- }) {
16089
- super({ isPainter: false });
16090
- __publicField(this, "_top");
16091
- __publicField(this, "_bottom");
16092
- __publicField(this, "_right");
16093
- __publicField(this, "_left");
16094
- __publicField(this, "_width");
16095
- __publicField(this, "_height");
16096
- this._top = top;
16097
- this._bottom = bottom;
16098
- this._left = left;
16099
- this._right = right;
16100
- this._width = width;
16101
- this._height = height;
16102
- }
16103
- get top() {
16104
- return this._top;
16105
- }
16106
- set top(newTop) {
16107
- if (this._top === newTop)
16108
- return;
16109
- this._top = newTop;
16110
- this.markNeedsLayout();
16111
- }
16112
- get bottom() {
16113
- return this._bottom;
16114
- }
16115
- set bottom(newBottom) {
16116
- if (this._bottom === newBottom)
16117
- return;
16118
- this._bottom = newBottom;
16119
- this.markNeedsLayout();
16120
- }
16121
- get right() {
16122
- return this._right;
15951
+ } else {
15952
+ result = fixedColumnWidths[i];
15953
+ }
15954
+ return result;
15955
+ });
15956
+ const totalFrOnHeight = this.rows.filter(({ type }) => type === "fr").map(({ value }) => value).reduce(sum, 0);
15957
+ const totalFixedHeight = fixedRowHeights.reduce(sum, 0);
15958
+ const frUnitOnHeight = (this.size.height - totalFixedHeight) / totalFrOnHeight;
15959
+ const heights = this.rows.map(({ type, value }, i) => {
15960
+ let result = 0;
15961
+ if (type === "fr") {
15962
+ result = value * frUnitOnHeight;
15963
+ } else {
15964
+ result = fixedRowHeights[i];
15965
+ }
15966
+ return result;
15967
+ });
15968
+ this.childrenByRow.forEach((columnChildren, rowIndex) => {
15969
+ columnChildren.forEach((child, columnIndex) => {
15970
+ const childConstraint = new constraints_default(__spreadProps(__spreadValues({}, this.constraints), {
15971
+ maxHeight: heights[rowIndex],
15972
+ maxWidth: widths[columnIndex]
15973
+ }));
15974
+ child.layout(childConstraint);
15975
+ child.offset = new offset_default({
15976
+ x: widths.slice(0, columnIndex).reduce(sum, 0),
15977
+ y: heights.slice(0, rowIndex).reduce(sum, 0)
15978
+ });
15979
+ });
15980
+ });
16123
15981
  }
16124
- set right(newRight) {
16125
- if (this._right === newRight)
16126
- return;
16127
- this._right = newRight;
16128
- this.markNeedsLayout();
15982
+ getIntrinsicWidth(height) {
15983
+ return this.childrenByRow.map(
15984
+ (row) => row.map((child) => child.getIntrinsicWidth(height)).reduce(Utils.sumReducer)
15985
+ ).reduce(Utils.maxReducer);
16129
15986
  }
16130
- get left() {
16131
- return this._left;
15987
+ getIntrinsicHeight(width) {
15988
+ return this.childrenByRow.map(
15989
+ (row) => row.map((child) => child.getIntrinsicHeight(width)).reduce(Utils.maxReducer)
15990
+ ).reduce(Utils.sumReducer);
16132
15991
  }
16133
- set left(newLeft) {
16134
- if (this._left === newLeft)
16135
- return;
16136
- this._left = newLeft;
16137
- this.markNeedsLayout();
15992
+ };
15993
+ var GridTemplate = class _GridTemplate {
15994
+ constructor({
15995
+ type,
15996
+ value
15997
+ }) {
15998
+ __publicField(this, "type");
15999
+ __publicField(this, "value");
16000
+ this.type = type;
16001
+ this.value = value;
16138
16002
  }
16139
- get width() {
16140
- return this._width;
16003
+ static equals(target, other) {
16004
+ if (target.length !== other.length)
16005
+ return false;
16006
+ return target.every((value, i) => value.equals(other[i]));
16141
16007
  }
16142
- set width(newWidth) {
16143
- if (this._width === newWidth)
16144
- return;
16145
- this._width = newWidth;
16146
- this.markNeedsLayout();
16008
+ equals(other) {
16009
+ if (this === other)
16010
+ return true;
16011
+ return this.type === other.type && this.value === other.value;
16147
16012
  }
16148
- get height() {
16149
- return this._height;
16013
+ static Fr(value) {
16014
+ return new _GridTemplate({ value, type: "fr" });
16150
16015
  }
16151
- set height(newHeight) {
16152
- if (this._height === newHeight)
16153
- return;
16154
- this._height = newHeight;
16155
- this.markNeedsLayout();
16016
+ static Px(value) {
16017
+ return new _GridTemplate({ value, type: "px" });
16156
16018
  }
16157
- get isPositioned() {
16158
- return this.top != null || this.bottom != null || this.left != null || this.right != null || this.width != null || this.height != null;
16019
+ static ContentFit() {
16020
+ return new _GridTemplate({ value: 0, type: "content-fit" });
16159
16021
  }
16160
- getIntrinsicWidth(height) {
16161
- var _a;
16162
- return ((_a = this.child) == null ? void 0 : _a.getIntrinsicWidth(height)) || 0;
16022
+ // 0 ~ 100
16023
+ static Percent(value) {
16024
+ return new _GridTemplate({ value, type: "percent" });
16163
16025
  }
16164
- getIntrinsicHeight(width) {
16165
- var _a;
16166
- return ((_a = this.child) == null ? void 0 : _a.getIntrinsicHeight(width)) || 0;
16026
+ repeat(count) {
16027
+ return Array.from({ length: count }, () => this);
16167
16028
  }
16168
16029
  };
16169
- var BasePositioned_default = BasePositioned;
16030
+ var BaseGrid_default = BaseGrid;
16031
+
16032
+ // src/component/Grid.ts
16033
+ function Grid(_a) {
16034
+ var _b = _a, {
16035
+ childrenByRow,
16036
+ key
16037
+ } = _b, props = __objRest(_b, [
16038
+ "childrenByRow",
16039
+ "key"
16040
+ ]);
16041
+ return new BaseGrid_default(__spreadValues({ childrenByRow, key }, props));
16042
+ }
16043
+ Grid.Fr = GridTemplate.Fr;
16044
+ Grid.ContentFit = GridTemplate.ContentFit;
16045
+ Grid.Percent = GridTemplate.Percent;
16046
+ Grid.Px = GridTemplate.Px;
16047
+ var Grid_default = Grid;
16170
16048
 
16171
16049
  // src/component/base/BaseStack.ts
16172
16050
  var BaseStack = class extends MultiChildRenderObjectWidget_default {
@@ -16256,7 +16134,7 @@ var RenderStack = class _RenderStack extends MultiChildRenderObject_default {
16256
16134
  break;
16257
16135
  }
16258
16136
  this.children.forEach((child) => {
16259
- if (child instanceof RenderPositioned && child.isPositioned)
16137
+ if (child.isRenderPositioned && child.isPositioned)
16260
16138
  return;
16261
16139
  hasNonPositionedChildren = true;
16262
16140
  child.layout(nonPositionedConstraints);
@@ -16322,7 +16200,7 @@ var RenderStack = class _RenderStack extends MultiChildRenderObject_default {
16322
16200
  constraints: this.constraints
16323
16201
  });
16324
16202
  this.children.forEach((child) => {
16325
- if (!(child instanceof RenderPositioned && child.isPositioned)) {
16203
+ if (!(child.isRenderPositioned && child.isPositioned)) {
16326
16204
  child.offset = this.resolvedAlignment.alongOffset(
16327
16205
  this.size.minus(child.size)
16328
16206
  );
@@ -16364,6 +16242,143 @@ function Stack({
16364
16242
  });
16365
16243
  }
16366
16244
 
16245
+ // src/component/base/BasePositioned.ts
16246
+ var BasePositioned = class extends SingleChildRenderObjectWidget_default {
16247
+ constructor({
16248
+ top,
16249
+ bottom,
16250
+ left,
16251
+ right,
16252
+ width,
16253
+ height,
16254
+ child,
16255
+ key
16256
+ }) {
16257
+ super({ child, key });
16258
+ __publicField(this, "top");
16259
+ __publicField(this, "bottom");
16260
+ __publicField(this, "right");
16261
+ __publicField(this, "left");
16262
+ __publicField(this, "width");
16263
+ __publicField(this, "height");
16264
+ this.top = top;
16265
+ this.bottom = bottom;
16266
+ this.left = left;
16267
+ this.right = right;
16268
+ this.width = width;
16269
+ this.height = height;
16270
+ }
16271
+ createRenderObject() {
16272
+ return new RenderPositioned({
16273
+ top: this.top,
16274
+ left: this.left,
16275
+ right: this.right,
16276
+ bottom: this.bottom,
16277
+ width: this.width,
16278
+ height: this.height
16279
+ });
16280
+ }
16281
+ updateRenderObject(renderObject) {
16282
+ renderObject.top = this.top;
16283
+ renderObject.left = this.left;
16284
+ renderObject.bottom = this.bottom;
16285
+ renderObject.right = this.right;
16286
+ renderObject.width = this.width;
16287
+ renderObject.height = this.height;
16288
+ }
16289
+ };
16290
+ var RenderPositioned = class extends SingleChildRenderObject_default {
16291
+ constructor({
16292
+ top,
16293
+ bottom,
16294
+ left,
16295
+ right,
16296
+ width,
16297
+ height
16298
+ }) {
16299
+ super({ isPainter: false });
16300
+ __publicField(this, "isRenderPositioned", true);
16301
+ __publicField(this, "_top");
16302
+ __publicField(this, "_bottom");
16303
+ __publicField(this, "_right");
16304
+ __publicField(this, "_left");
16305
+ __publicField(this, "_width");
16306
+ __publicField(this, "_height");
16307
+ this._top = top;
16308
+ this._bottom = bottom;
16309
+ this._left = left;
16310
+ this._right = right;
16311
+ this._width = width;
16312
+ this._height = height;
16313
+ }
16314
+ get top() {
16315
+ return this._top;
16316
+ }
16317
+ set top(newTop) {
16318
+ if (this._top === newTop)
16319
+ return;
16320
+ this._top = newTop;
16321
+ this.markNeedsLayout();
16322
+ }
16323
+ get bottom() {
16324
+ return this._bottom;
16325
+ }
16326
+ set bottom(newBottom) {
16327
+ if (this._bottom === newBottom)
16328
+ return;
16329
+ this._bottom = newBottom;
16330
+ this.markNeedsLayout();
16331
+ }
16332
+ get right() {
16333
+ return this._right;
16334
+ }
16335
+ set right(newRight) {
16336
+ if (this._right === newRight)
16337
+ return;
16338
+ this._right = newRight;
16339
+ this.markNeedsLayout();
16340
+ }
16341
+ get left() {
16342
+ return this._left;
16343
+ }
16344
+ set left(newLeft) {
16345
+ if (this._left === newLeft)
16346
+ return;
16347
+ this._left = newLeft;
16348
+ this.markNeedsLayout();
16349
+ }
16350
+ get width() {
16351
+ return this._width;
16352
+ }
16353
+ set width(newWidth) {
16354
+ if (this._width === newWidth)
16355
+ return;
16356
+ this._width = newWidth;
16357
+ this.markNeedsLayout();
16358
+ }
16359
+ get height() {
16360
+ return this._height;
16361
+ }
16362
+ set height(newHeight) {
16363
+ if (this._height === newHeight)
16364
+ return;
16365
+ this._height = newHeight;
16366
+ this.markNeedsLayout();
16367
+ }
16368
+ get isPositioned() {
16369
+ return this.top != null || this.bottom != null || this.left != null || this.right != null || this.width != null || this.height != null;
16370
+ }
16371
+ getIntrinsicWidth(height) {
16372
+ var _a;
16373
+ return ((_a = this.child) == null ? void 0 : _a.getIntrinsicWidth(height)) || 0;
16374
+ }
16375
+ getIntrinsicHeight(width) {
16376
+ var _a;
16377
+ return ((_a = this.child) == null ? void 0 : _a.getIntrinsicHeight(width)) || 0;
16378
+ }
16379
+ };
16380
+ var BasePositioned_default = BasePositioned;
16381
+
16367
16382
  // src/component/Positioned.ts
16368
16383
  var Positioned = classToFunction_default(
16369
16384
  BasePositioned_default
@@ -17315,7 +17330,7 @@ var BaseGestureDetector = class extends SingleChildRenderObjectWidget_default {
17315
17330
  renderObject.onWheel = this.onWheel;
17316
17331
  }
17317
17332
  };
17318
- var RenderGestureDetector = class _RenderGestureDetector extends SingleChildRenderObject_default {
17333
+ var RenderGestureDetector = class extends SingleChildRenderObject_default {
17319
17334
  constructor({
17320
17335
  onClick,
17321
17336
  onMouseDown,
@@ -17332,6 +17347,7 @@ var RenderGestureDetector = class _RenderGestureDetector extends SingleChildRend
17332
17347
  onWheel
17333
17348
  }) {
17334
17349
  super({ isPainter: true });
17350
+ __publicField(this, "isRenderGestureDetector", true);
17335
17351
  __publicField(this, "id", createUniqueId());
17336
17352
  __publicField(this, "_bubble");
17337
17353
  __publicField(this, "_cursor");
@@ -17546,7 +17562,7 @@ var RenderGestureDetector = class _RenderGestureDetector extends SingleChildRend
17546
17562
  dispatchParent(e) {
17547
17563
  let parent = this.parent;
17548
17564
  while (parent != null) {
17549
- if (parent instanceof _RenderGestureDetector) {
17565
+ if (parent == null ? void 0 : parent.isRenderGestureDetector) {
17550
17566
  parent.dispatch(e);
17551
17567
  break;
17552
17568
  }