verstak 0.23.120 → 0.23.122

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.
@@ -17,8 +17,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  });
18
18
  };
19
19
  import { reactive, unobs, Transaction, options, Reentrance, Rx, MergeList, ObservableObject, raw } from "reactronic";
20
- import { BlockKind, Priority, Mode, Align } from "./Interfaces.js";
21
- import { emitLetters, equalBlockCoords, parseBlockCoords, getCallerInfo } from "./Utils.js";
20
+ import { ElKind, Priority, Mode, Align } from "./Interfaces.js";
21
+ import { emitLetters, equalElCoords, parseElCoords, getCallerInfo } from "./Utils.js";
22
22
  export class Verstak {
23
23
  static claim(driver, builder, base) {
24
24
  var _a;
@@ -37,55 +37,55 @@ export class Verstak {
37
37
  if (((_a = last === null || last === void 0 ? void 0 : last.instance) === null || _a === void 0 ? void 0 : _a.node.driver) === driver)
38
38
  ex = last;
39
39
  }
40
- ex !== null && ex !== void 0 ? ex : (ex = children.claim(key = key || generateKey(owner), undefined, "nested blocks can be declared inside rebuild function only"));
40
+ ex !== null && ex !== void 0 ? ex : (ex = children.claim(key = key || generateKey(owner), undefined, "nested elements can be declared inside update function only"));
41
41
  if (ex) {
42
42
  result = ex.instance;
43
43
  const node = result.node;
44
44
  if (node.driver !== driver && driver !== undefined)
45
- throw new Error(`changing block driver is not yet supported: "${result.node.driver.name}" -> "${driver === null || driver === void 0 ? void 0 : driver.name}"`);
45
+ throw new Error(`changing element driver is not yet supported: "${result.node.driver.name}" -> "${driver === null || driver === void 0 ? void 0 : driver.name}"`);
46
46
  const exTriggers = node.builder.triggers;
47
47
  if (triggersAreEqual(builder.triggers, exTriggers))
48
48
  builder.triggers = exTriggers;
49
49
  node.builder = builder;
50
50
  }
51
51
  else {
52
- result = new BlockImpl(key || generateKey(owner), driver, owner, builder);
52
+ result = new ElImpl(key || generateKey(owner), driver, owner, builder);
53
53
  result.node.ties = children.add(result);
54
54
  }
55
55
  }
56
56
  else {
57
- result = new BlockImpl(key || "", driver, owner, builder);
57
+ result = new ElImpl(key || "", driver, owner, builder);
58
58
  result.node.ties = MergeList.createItem(result);
59
- triggerRebuild(result.node.ties);
59
+ triggerUpdate(result.node.ties);
60
60
  }
61
61
  return result;
62
62
  }
63
- static get block() {
63
+ static get element() {
64
64
  if (gCurrent === undefined)
65
- throw new Error("current block is undefined");
65
+ throw new Error("current element is undefined");
66
66
  return gCurrent.instance;
67
67
  }
68
- static triggerRebuild(block, triggers) {
69
- const b = block;
70
- const builder = b.node.builder;
68
+ static triggerUpdate(element, triggers) {
69
+ const el = element;
70
+ const builder = el.node.builder;
71
71
  if (!triggersAreEqual(triggers, builder.triggers)) {
72
72
  builder.triggers = triggers;
73
- triggerRebuild(b.node.ties);
73
+ triggerUpdate(el.node.ties);
74
74
  }
75
75
  }
76
- static rebuildNestedTreesThenDo(action) {
77
- runRebuildNestedTreesThenDo(undefined, action);
76
+ static updateNestedTreesThenDo(action) {
77
+ runUpdateNestedTreesThenDo(undefined, action);
78
78
  }
79
79
  static getDefaultLoggingOptions() {
80
- return BlockImpl.logging;
80
+ return ElImpl.logging;
81
81
  }
82
82
  static setDefaultLoggingOptions(logging) {
83
- BlockImpl.logging = logging;
83
+ ElImpl.logging = logging;
84
84
  }
85
85
  }
86
86
  Verstak.shortFrameDuration = 16;
87
87
  Verstak.longFrameDuration = 300;
88
- Verstak.currentRebuildPriority = Priority.Realtime;
88
+ Verstak.currentUpdatePriority = Priority.Realtime;
89
89
  Verstak.frameDuration = Verstak.longFrameDuration;
90
90
  export class BaseDriver {
91
91
  constructor(name, isRow, preset) {
@@ -93,44 +93,44 @@ export class BaseDriver {
93
93
  this.isRow = isRow;
94
94
  this.preset = preset;
95
95
  }
96
- claim(block) {
97
- const b = block;
98
- chainedClaim(b, b.node.builder);
96
+ claim(element) {
97
+ const el = element;
98
+ chainedClaim(el, el.node.builder);
99
99
  }
100
- create(block, b) {
101
- chainedCreate(block, block.node.builder);
100
+ create(element, result) {
101
+ chainedCreate(element, element.node.builder);
102
102
  }
103
- initialize(block) {
103
+ initialize(element) {
104
104
  var _a;
105
- const b = block;
106
- (_a = this.preset) === null || _a === void 0 ? void 0 : _a.call(this, b);
107
- chainedInitialize(b, b.node.builder);
105
+ const el = element;
106
+ (_a = this.preset) === null || _a === void 0 ? void 0 : _a.call(this, el);
107
+ chainedInitialize(el, el.node.builder);
108
108
  }
109
- mount(block) {
109
+ mount(element, nativeHost) {
110
110
  }
111
- rebuild(block) {
112
- chainedRebuild(block, block.node.builder);
111
+ update(element) {
112
+ chainedUpdated(element, element.node.builder);
113
113
  }
114
- finalize(block, isLeader) {
115
- const b = block;
116
- chainedFinalize(b, b.node.builder);
114
+ finalize(element, isLeader) {
115
+ const el = element;
116
+ chainedFinalize(el, el.node.builder);
117
117
  return isLeader;
118
118
  }
119
- applyKind(block, value) { }
120
- applyCoords(block, value) { }
121
- applyWidthGrowth(block, value) { }
122
- applyMinWidth(block, value) { }
123
- applyMaxWidth(block, value) { }
124
- applyHeightGrowth(block, value) { }
125
- applyMinHeight(block, value) { }
126
- applyMaxHeight(block, value) { }
127
- applyContentAlignment(block, value) { }
128
- applyBlockAlignment(block, value) { }
129
- applyContentWrapping(block, value) { }
130
- applyOverlayVisible(block, value) { }
131
- applyStyle(block, secondary, styleName, enabled) { }
132
- }
133
- BaseDriver.fragment = new BaseDriver("fragment", false, b => b.kind = BlockKind.Group);
119
+ applyKind(element, value) { }
120
+ applyCoords(element, value) { }
121
+ applyWidthGrowth(element, value) { }
122
+ applyMinWidth(element, value) { }
123
+ applyMaxWidth(element, value) { }
124
+ applyHeightGrowth(element, value) { }
125
+ applyMinHeight(element, value) { }
126
+ applyMaxHeight(element, value) { }
127
+ applyContentAlignment(element, value) { }
128
+ applyElementAlignment(element, value) { }
129
+ applyContentWrapping(element, value) { }
130
+ applyOverlayVisible(element, value) { }
131
+ applyStyle(element, secondary, styleName, enabled) { }
132
+ }
133
+ BaseDriver.fragment = new BaseDriver("fragment", false, el => el.kind = ElKind.Group);
134
134
  function generateKey(owner) {
135
135
  const n = owner.node.numerator++;
136
136
  const lettered = emitLetters(n);
@@ -145,64 +145,64 @@ function chainedMode(bb) {
145
145
  var _a;
146
146
  return (_a = bb === null || bb === void 0 ? void 0 : bb.mode) !== null && _a !== void 0 ? _a : ((bb === null || bb === void 0 ? void 0 : bb.base) ? chainedMode(bb === null || bb === void 0 ? void 0 : bb.base) : Mode.Default);
147
147
  }
148
- function chainedClaim(block, bb) {
149
- const claim = bb.claim;
150
- const base = bb.base;
148
+ function chainedClaim(element, elb) {
149
+ const claim = elb.claim;
150
+ const base = elb.base;
151
151
  if (claim)
152
- claim(block, base ? () => chainedClaim(block, base) : NOP);
152
+ claim(element, base ? () => chainedClaim(element, base) : NOP);
153
153
  else if (base)
154
- chainedClaim(block, base);
154
+ chainedClaim(element, base);
155
155
  }
156
- function chainedCreate(block, bb) {
157
- const create = bb.create;
158
- const base = bb.base;
156
+ function chainedCreate(element, elb) {
157
+ const create = elb.create;
158
+ const base = elb.base;
159
159
  if (create)
160
- create(block, base ? () => chainedCreate(block, base) : NOP);
160
+ create(element, base ? () => chainedCreate(element, base) : NOP);
161
161
  else if (base)
162
- chainedCreate(block, base);
162
+ chainedCreate(element, base);
163
163
  }
164
- function chainedInitialize(block, bb) {
165
- const initialize = bb.initialize;
166
- const base = bb.base;
164
+ function chainedInitialize(element, elb) {
165
+ const initialize = elb.initialize;
166
+ const base = elb.base;
167
167
  if (initialize)
168
- initialize(block, base ? () => chainedInitialize(block, base) : NOP);
168
+ initialize(element, base ? () => chainedInitialize(element, base) : NOP);
169
169
  else if (base)
170
- chainedInitialize(block, base);
170
+ chainedInitialize(element, base);
171
171
  }
172
- function chainedRebuild(block, bb) {
173
- const rebuild = bb.rebuild;
174
- const base = bb.base;
175
- if (rebuild)
176
- rebuild(block, base ? () => chainedRebuild(block, base) : NOP);
172
+ function chainedUpdated(element, elb) {
173
+ const update = elb.update;
174
+ const base = elb.base;
175
+ if (update)
176
+ update(element, base ? () => chainedUpdated(element, base) : NOP);
177
177
  else if (base)
178
- chainedRebuild(block, base);
178
+ chainedUpdated(element, base);
179
179
  }
180
- function chainedFinalize(block, bb) {
181
- const finalize = bb.finalize;
182
- const base = bb.base;
180
+ function chainedFinalize(element, elb) {
181
+ const finalize = elb.finalize;
182
+ const base = elb.base;
183
183
  if (finalize)
184
- finalize(block, base ? () => chainedFinalize(block, base) : NOP);
184
+ finalize(element, base ? () => chainedFinalize(element, base) : NOP);
185
185
  else if (base)
186
- chainedFinalize(block, base);
186
+ chainedFinalize(element, base);
187
187
  }
188
188
  export class StaticDriver extends BaseDriver {
189
- constructor(element, name, isRow, preset) {
189
+ constructor(native, name, isRow, preset) {
190
190
  super(name, isRow, preset);
191
- this.element = element;
191
+ this.native = native;
192
192
  }
193
- create(block, b) {
194
- b.native = this.element;
193
+ create(element, result) {
194
+ result.native = this.native;
195
195
  }
196
196
  }
197
197
  export class CursorCommand {
198
198
  }
199
199
  export class CursorCommandDriver extends BaseDriver {
200
200
  constructor() {
201
- super("cursor", false, b => b.kind = BlockKind.Cursor);
201
+ super("cursor", false, el => el.kind = ElKind.Cursor);
202
202
  }
203
- create(block, b) {
204
- b.native = new CursorCommand();
205
- super.create(block, b);
203
+ create(element, result) {
204
+ result.native = new CursorCommand();
205
+ super.create(element, result);
206
206
  }
207
207
  }
208
208
  export class SubTreeVariable {
@@ -210,13 +210,13 @@ export class SubTreeVariable {
210
210
  this.defaultValue = defaultValue;
211
211
  }
212
212
  set value(value) {
213
- BlockImpl.setSubTreeVariableValue(this, value);
213
+ ElImpl.setSubTreeVariableValue(this, value);
214
214
  }
215
215
  get value() {
216
- return BlockImpl.useSubTreeVariableValue(this);
216
+ return ElImpl.useSubTreeVariableValue(this);
217
217
  }
218
218
  get valueOrUndefined() {
219
- return BlockImpl.tryUseSubTreeVariable(this);
219
+ return ElImpl.tryUseSubTreeVariable(this);
220
220
  }
221
221
  }
222
222
  class CursorPosition {
@@ -235,9 +235,9 @@ var CursorFlags;
235
235
  CursorFlags[CursorFlags["UsesRunningColumnCount"] = 2] = "UsesRunningColumnCount";
236
236
  CursorFlags[CursorFlags["UsesRunningRowCount"] = 4] = "UsesRunningRowCount";
237
237
  })(CursorFlags || (CursorFlags = {}));
238
- const UndefinedBlockCoords = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
238
+ const UndefinedElCoords = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
239
239
  const InitialCursorPosition = Object.freeze(new CursorPosition({ x: 1, y: 1, runningMaxX: 0, runningMaxY: 0, flags: CursorFlags.None }));
240
- class BlockCtxImpl extends ObservableObject {
240
+ class ElCtxImpl extends ObservableObject {
241
241
  constructor(variable, value) {
242
242
  super();
243
243
  this.next = undefined;
@@ -248,12 +248,12 @@ class BlockCtxImpl extends ObservableObject {
248
248
  __decorate([
249
249
  raw,
250
250
  __metadata("design:type", Object)
251
- ], BlockCtxImpl.prototype, "next", void 0);
251
+ ], ElCtxImpl.prototype, "next", void 0);
252
252
  __decorate([
253
253
  raw,
254
254
  __metadata("design:type", SubTreeVariable)
255
- ], BlockCtxImpl.prototype, "variable", void 0);
256
- class BlockNodeImpl {
255
+ ], ElCtxImpl.prototype, "variable", void 0);
256
+ class ElNodeImpl {
257
257
  constructor(key, driver, builder, self, owner) {
258
258
  this.maxColumnCount = 0;
259
259
  this.maxRowCount = 0;
@@ -272,9 +272,9 @@ class BlockNodeImpl {
272
272
  this.outer = self;
273
273
  }
274
274
  this.host = self;
275
- this.children = new MergeList(getBlockKey, true);
275
+ this.children = new MergeList(getElNodeKey, true);
276
276
  this.ties = undefined;
277
- this.stamp = 0;
277
+ this.stamp = Number.MAX_SAFE_INTEGER;
278
278
  this.context = undefined;
279
279
  this.numerator = 0;
280
280
  this.maxColumnCount = 0;
@@ -282,15 +282,15 @@ class BlockNodeImpl {
282
282
  this.cursorPosition = undefined;
283
283
  }
284
284
  }
285
- class BlockImpl {
285
+ class ElImpl {
286
286
  constructor(key, driver, owner, builder) {
287
- this.node = new BlockNodeImpl(key, driver, builder, this, owner);
287
+ this.node = new ElNodeImpl(key, driver, builder, this, owner);
288
288
  this.native = undefined;
289
289
  this.model = undefined;
290
290
  this.controller = undefined;
291
- this._kind = BlockKind.Row;
291
+ this._kind = ElKind.Row;
292
292
  this._area = undefined;
293
- this._coords = UndefinedBlockCoords;
293
+ this._coords = UndefinedElCoords;
294
294
  this._widthGrowth = 0;
295
295
  this._minWidth = "";
296
296
  this._maxWidth = "";
@@ -298,37 +298,36 @@ class BlockImpl {
298
298
  this._minHeight = "";
299
299
  this._maxHeight = "";
300
300
  this._contentAlignment = Align.Default;
301
- this._blockAlignment = Align.Default;
301
+ this._elementAlignment = Align.Default;
302
302
  this._contentWrapping = true;
303
303
  this._overlayVisible = undefined;
304
304
  this._hasStyles = false;
305
- this.rebuildPriority = Priority.Realtime;
305
+ this.updatePriority = Priority.Realtime;
306
306
  this.childrenShuffling = false;
307
- BlockImpl.grandBlockCount++;
308
- if (this.isOn(Mode.PinpointRebuild))
309
- BlockImpl.disposableBlockCount++;
307
+ ElImpl.grandElementCount++;
308
+ if (this.hasMode(Mode.PinpointUpdate))
309
+ ElImpl.disposableElementCount++;
310
310
  }
311
- rebuild(_triggers) {
312
- rebuildNow(this.node.ties);
311
+ update(_triggers) {
312
+ updateNow(this.node.ties);
313
313
  }
314
- prepareForRebuild() {
314
+ prepareForUpdate() {
315
315
  this._area = undefined;
316
316
  this._hasStyles = false;
317
317
  }
318
- isOn(mode) {
318
+ hasMode(mode) {
319
319
  return (chainedMode(this.node.builder) & mode) === mode;
320
320
  }
321
- get isInitialRebuild() { return this.node.stamp === 2; }
322
- get isAuxiliary() { return this.kind > BlockKind.Note; }
323
- get isSection() { return this.kind === BlockKind.Section; }
324
- get isTable() { return this.kind === BlockKind.Table; }
325
- get isAutoMountEnabled() { return !this.isOn(Mode.ManualMount) && this.node.host !== this; }
321
+ get isInitialUpdate() { return this.node.stamp === 1; }
322
+ get isAuxiliary() { return this.kind > ElKind.Note; }
323
+ get isSection() { return this.kind === ElKind.Section; }
324
+ get isTable() { return this.kind === ElKind.Table; }
326
325
  get isMoved() { return this.node.owner.node.children.isMoved(this.node.ties); }
327
326
  get strictOrder() { return this.node.children.isStrict; }
328
327
  set strictOrder(value) { this.node.children.isStrict = value; }
329
328
  get kind() { return this._kind; }
330
329
  set kind(value) {
331
- if (value !== this._kind || this.node.stamp < 2) {
330
+ if (value !== this._kind || this.node.stamp >= Number.MAX_SAFE_INTEGER - 1) {
332
331
  this.node.driver.applyKind(this, value);
333
332
  this._kind = value;
334
333
  }
@@ -342,9 +341,9 @@ class BlockImpl {
342
341
  const owner = node.owner.node;
343
342
  const cursorPosition = (_b = (_a = node.ties.prev) === null || _a === void 0 ? void 0 : _a.instance.node.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
344
343
  const newCursorPosition = node.cursorPosition = owner.children.isStrict ? new CursorPosition(cursorPosition) : undefined;
345
- const isCursorBlock = driver instanceof CursorCommandDriver;
346
- const coords = getEffectiveBlockCoords(!isCursorBlock, value, owner.maxColumnCount, owner.maxRowCount, cursorPosition, newCursorPosition);
347
- if (!equalBlockCoords(coords, this._coords)) {
344
+ const isCursorElement = driver instanceof CursorCommandDriver;
345
+ const coords = getEffectiveElCoords(!isCursorElement, value, owner.maxColumnCount, owner.maxRowCount, cursorPosition, newCursorPosition);
346
+ if (!equalElCoords(coords, this._coords)) {
348
347
  driver.applyCoords(this, coords);
349
348
  this._coords = coords;
350
349
  }
@@ -402,11 +401,11 @@ class BlockImpl {
402
401
  this._contentAlignment = value;
403
402
  }
404
403
  }
405
- get blockAlignment() { return this._blockAlignment; }
406
- set blockAlignment(value) {
407
- if (value !== this._blockAlignment) {
408
- this.node.driver.applyBlockAlignment(this, value);
409
- this._blockAlignment = value;
404
+ get elementAlignment() { return this._elementAlignment; }
405
+ set elementAlignment(value) {
406
+ if (value !== this._elementAlignment) {
407
+ this.node.driver.applyElementAlignment(this, value);
408
+ this._elementAlignment = value;
410
409
  }
411
410
  }
412
411
  get contentWrapping() { return this._contentWrapping; }
@@ -428,32 +427,32 @@ class BlockImpl {
428
427
  this._hasStyles = true;
429
428
  }
430
429
  configureReactronic(options) {
431
- if (this.node.stamp !== 1 || !this.isOn(Mode.PinpointRebuild))
432
- throw new Error("reactronic can be configured only for blocks with separate reaction mode and only inside initialize");
433
- return Rx.getReaction(this.rebuild).configure(options);
430
+ if (this.node.stamp < Number.MAX_SAFE_INTEGER - 1 || !this.hasMode(Mode.PinpointUpdate))
431
+ throw new Error("reactronic can be configured only for elements with pinpoint update mode and only inside initialize");
432
+ return Rx.getReaction(this.update).configure(options);
434
433
  }
435
434
  static get curr() {
436
435
  if (!gCurrent)
437
- throw new Error("current block is undefined");
436
+ throw new Error("current element is undefined");
438
437
  return gCurrent;
439
438
  }
440
439
  static tryUseSubTreeVariable(variable) {
441
440
  var _a, _b;
442
- let b = BlockImpl.curr.instance;
443
- while (((_a = b.node.context) === null || _a === void 0 ? void 0 : _a.variable) !== variable && b.node.owner !== b)
444
- b = b.node.outer;
445
- return (_b = b.node.context) === null || _b === void 0 ? void 0 : _b.value;
441
+ let el = ElImpl.curr.instance;
442
+ while (((_a = el.node.context) === null || _a === void 0 ? void 0 : _a.variable) !== variable && el.node.owner !== el)
443
+ el = el.node.outer;
444
+ return (_b = el.node.context) === null || _b === void 0 ? void 0 : _b.value;
446
445
  }
447
446
  static useSubTreeVariableValue(variable) {
448
447
  var _a;
449
- const result = (_a = BlockImpl.tryUseSubTreeVariable(variable)) !== null && _a !== void 0 ? _a : variable.defaultValue;
448
+ const result = (_a = ElImpl.tryUseSubTreeVariable(variable)) !== null && _a !== void 0 ? _a : variable.defaultValue;
450
449
  if (!result)
451
450
  throw new Error("context doesn't exist");
452
451
  return result;
453
452
  }
454
453
  static setSubTreeVariableValue(variable, value) {
455
- const b = BlockImpl.curr.instance;
456
- const node = b.node;
454
+ const el = ElImpl.curr.instance;
455
+ const node = el.node;
457
456
  const owner = node.owner;
458
457
  const hostCtx = unobs(() => { var _a; return (_a = owner.node.context) === null || _a === void 0 ? void 0 : _a.value; });
459
458
  if (value && value !== hostCtx) {
@@ -468,7 +467,7 @@ class BlockImpl {
468
467
  ctx.value = value;
469
468
  }
470
469
  else
471
- node.context = new BlockCtxImpl(variable, value);
470
+ node.context = new ElCtxImpl(variable, value);
472
471
  });
473
472
  }
474
473
  else if (hostCtx)
@@ -485,9 +484,9 @@ class BlockImpl {
485
484
  newCursorPosition.y = newCursorPosition.runningMaxY + 1;
486
485
  }
487
486
  }
488
- BlockImpl.grandBlockCount = 0;
489
- BlockImpl.disposableBlockCount = 0;
490
- BlockImpl.logging = undefined;
487
+ ElImpl.grandElementCount = 0;
488
+ ElImpl.disposableElementCount = 0;
489
+ ElImpl.logging = undefined;
491
490
  __decorate([
492
491
  reactive,
493
492
  options({
@@ -498,19 +497,19 @@ __decorate([
498
497
  __metadata("design:type", Function),
499
498
  __metadata("design:paramtypes", [Object]),
500
499
  __metadata("design:returntype", void 0)
501
- ], BlockImpl.prototype, "rebuild", null);
502
- function getBlockKey(block) {
503
- const node = block.node;
500
+ ], ElImpl.prototype, "update", null);
501
+ function getElNodeKey(element) {
502
+ const node = element.node;
504
503
  return node.stamp >= 0 ? node.key : undefined;
505
504
  }
506
- function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPosition, newCursorPosition) {
505
+ function getEffectiveElCoords(isRegularElement, area, maxX, maxY, cursorPosition, newCursorPosition) {
507
506
  var _a, _b;
508
507
  let result;
509
508
  if (typeof (area) === "string") {
510
- result = parseBlockCoords(area, { x1: 0, y1: 0, x2: 0, y2: 0 });
511
- absolutizeBlockCoords(result, cursorPosition.x, cursorPosition.y, maxX || Infinity, maxY || Infinity, result);
509
+ result = parseElCoords(area, { x1: 0, y1: 0, x2: 0, y2: 0 });
510
+ absolutizeElCoords(result, cursorPosition.x, cursorPosition.y, maxX || Infinity, maxY || Infinity, result);
512
511
  if (newCursorPosition) {
513
- newCursorPosition.x = isRegularBlock ? result.x2 + 1 : result.x1;
512
+ newCursorPosition.x = isRegularElement ? result.x2 + 1 : result.x1;
514
513
  newCursorPosition.y = result.y1;
515
514
  newCursorPosition.flags = CursorFlags.OwnCursorPosition;
516
515
  }
@@ -527,12 +526,12 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
527
526
  const runningX = maxX !== 0 ? maxX : cursorPosition.runningMaxX;
528
527
  const runningY = maxY !== 0 ? maxY : cursorPosition.runningMaxY;
529
528
  result = { x1: 0, y1: 0, x2: 0, y2: 0 };
530
- if (dx === 0 && isRegularBlock) {
529
+ if (dx === 0 && isRegularElement) {
531
530
  dx = runningX || 1;
532
531
  newCursorPosition.flags = CursorFlags.UsesRunningColumnCount;
533
532
  }
534
533
  if (dx >= 0) {
535
- if (isRegularBlock) {
534
+ if (isRegularElement) {
536
535
  result.x1 = cursorPosition.x;
537
536
  result.x2 = absolutizePosition(result.x1 + dx - 1, 0, maxX || Infinity);
538
537
  newCursorPosition.x = result.x2 + 1;
@@ -543,7 +542,7 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
543
542
  }
544
543
  }
545
544
  else {
546
- if (isRegularBlock) {
545
+ if (isRegularElement) {
547
546
  result.x1 = Math.max(cursorPosition.x + dx, 1);
548
547
  result.x2 = cursorPosition.x;
549
548
  newCursorPosition.x = result.x2 + 1;
@@ -553,12 +552,12 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
553
552
  newCursorPosition.x = result.x2;
554
553
  }
555
554
  }
556
- if (dy === 0 && isRegularBlock) {
555
+ if (dy === 0 && isRegularElement) {
557
556
  dy = runningY || 1;
558
557
  newCursorPosition.flags |= CursorFlags.UsesRunningRowCount;
559
558
  }
560
559
  if (dy >= 0) {
561
- if (isRegularBlock) {
560
+ if (isRegularElement) {
562
561
  result.y1 = cursorPosition.y;
563
562
  result.y2 = absolutizePosition(result.y1 + dy - 1, 0, maxY || Infinity);
564
563
  if (result.y2 > newCursorPosition.runningMaxY)
@@ -568,7 +567,7 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
568
567
  result.y1 = result.y2 = cursorPosition.y + dy;
569
568
  }
570
569
  else {
571
- if (isRegularBlock) {
570
+ if (isRegularElement) {
572
571
  result.y1 = Math.max(cursorPosition.y + dy, 1);
573
572
  result.y2 = cursorPosition.y;
574
573
  }
@@ -580,9 +579,9 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
580
579
  throw new Error("relative layout requires sequential children");
581
580
  return result;
582
581
  }
583
- function runRebuildNestedTreesThenDo(error, action) {
582
+ function runUpdateNestedTreesThenDo(error, action) {
584
583
  var _a;
585
- const curr = BlockImpl.curr;
584
+ const curr = ElImpl.curr;
586
585
  const owner = curr.instance;
587
586
  const children = owner.node.children;
588
587
  if (children.isMergeInProgress) {
@@ -601,22 +600,22 @@ function runRebuildNestedTreesThenDo(error, action) {
601
600
  for (const item of children.items()) {
602
601
  if (Transaction.isCanceled)
603
602
  break;
604
- const block = item.instance;
605
- const isRow = block.node.driver.isRow;
603
+ const el = item.instance;
604
+ const isRow = el.node.driver.isRow;
606
605
  const host = isRow ? owner : hostingRow;
607
- const p = (_a = block.rebuildPriority) !== null && _a !== void 0 ? _a : Priority.Realtime;
606
+ const p = (_a = el.updatePriority) !== null && _a !== void 0 ? _a : Priority.Realtime;
608
607
  mounting = markToMountIfNecessary(mounting, host, item, children, sequential);
609
608
  if (p === Priority.Realtime)
610
- triggerRebuild(item);
609
+ triggerUpdate(item);
611
610
  else if (p === Priority.Normal)
612
611
  p1 = push(item, p1);
613
612
  else
614
613
  p2 = push(item, p2);
615
614
  if (ownerIsSection && isRow)
616
- hostingRow = block;
615
+ hostingRow = el;
617
616
  }
618
617
  if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
619
- promised = startIncrementalRebuild(curr, children, p1, p2).then(() => action(error), e => action(e));
618
+ promised = startIncrementalUpdate(curr, children, p1, p2).then(() => action(error), e => action(e));
620
619
  }
621
620
  }
622
621
  finally {
@@ -626,9 +625,9 @@ function runRebuildNestedTreesThenDo(error, action) {
626
625
  }
627
626
  }
628
627
  function markToMountIfNecessary(mounting, host, ties, children, sequential) {
629
- const b = ties.instance;
630
- const node = b.node;
631
- if (b.native && !b.isOn(Mode.ManualMount)) {
628
+ const el = ties.instance;
629
+ const node = el.node;
630
+ if (el.native && !el.hasMode(Mode.ManualMount)) {
632
631
  if (mounting || node.host !== host) {
633
632
  children.markAsMoved(ties);
634
633
  mounting = false;
@@ -639,34 +638,34 @@ function markToMountIfNecessary(mounting, host, ties, children, sequential) {
639
638
  node.host = host;
640
639
  return mounting;
641
640
  }
642
- function startIncrementalRebuild(owner, allChildren, priority1, priority2) {
641
+ function startIncrementalUpdate(owner, allChildren, priority1, priority2) {
643
642
  return __awaiter(this, void 0, void 0, function* () {
644
643
  const stamp = owner.instance.node.stamp;
645
644
  if (priority1)
646
- yield rebuildIncrementally(owner, stamp, allChildren, priority1, Priority.Normal);
645
+ yield updateIncrementally(owner, stamp, allChildren, priority1, Priority.Normal);
647
646
  if (priority2)
648
- yield rebuildIncrementally(owner, stamp, allChildren, priority2, Priority.Background);
647
+ yield updateIncrementally(owner, stamp, allChildren, priority2, Priority.Background);
649
648
  });
650
649
  }
651
- function rebuildIncrementally(owner, stamp, allChildren, items, priority) {
650
+ function updateIncrementally(owner, stamp, allChildren, items, priority) {
652
651
  return __awaiter(this, void 0, void 0, function* () {
653
652
  yield Transaction.requestNextFrame();
654
- const block = owner.instance;
653
+ const el = owner.instance;
655
654
  if (!Transaction.isCanceled || !Transaction.isFrameOver(1, Verstak.shortFrameDuration / 3)) {
656
- let outerPriority = Verstak.currentRebuildPriority;
657
- Verstak.currentRebuildPriority = priority;
655
+ let outerPriority = Verstak.currentUpdatePriority;
656
+ Verstak.currentUpdatePriority = priority;
658
657
  try {
659
- if (block.childrenShuffling)
658
+ if (el.childrenShuffling)
660
659
  shuffle(items);
661
660
  const frameDurationLimit = priority === Priority.Background ? Verstak.shortFrameDuration : Infinity;
662
661
  let frameDuration = Math.min(frameDurationLimit, Math.max(Verstak.frameDuration / 4, Verstak.shortFrameDuration));
663
662
  for (const child of items) {
664
- triggerRebuild(child);
663
+ triggerUpdate(child);
665
664
  if (Transaction.isFrameOver(1, frameDuration)) {
666
- Verstak.currentRebuildPriority = outerPriority;
665
+ Verstak.currentUpdatePriority = outerPriority;
667
666
  yield Transaction.requestNextFrame(0);
668
- outerPriority = Verstak.currentRebuildPriority;
669
- Verstak.currentRebuildPriority = priority;
667
+ outerPriority = Verstak.currentUpdatePriority;
668
+ Verstak.currentUpdatePriority = priority;
670
669
  frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, Verstak.frameDuration));
671
670
  }
672
671
  if (Transaction.isCanceled && Transaction.isFrameOver(1, Verstak.shortFrameDuration / 3))
@@ -674,87 +673,92 @@ function rebuildIncrementally(owner, stamp, allChildren, items, priority) {
674
673
  }
675
674
  }
676
675
  finally {
677
- Verstak.currentRebuildPriority = outerPriority;
676
+ Verstak.currentUpdatePriority = outerPriority;
678
677
  }
679
678
  }
680
679
  });
681
680
  }
682
- function triggerRebuild(ties) {
683
- const b = ties.instance;
684
- const node = b.node;
681
+ function triggerUpdate(ties) {
682
+ const el = ties.instance;
683
+ const node = el.node;
685
684
  if (node.stamp >= 0) {
686
- if (b.isOn(Mode.PinpointRebuild)) {
687
- if (node.stamp === 0) {
685
+ if (el.hasMode(Mode.PinpointUpdate)) {
686
+ if (node.stamp === Number.MAX_SAFE_INTEGER) {
688
687
  Transaction.outside(() => {
689
688
  if (Rx.isLogging)
690
- Rx.setLoggingHint(b, node.key);
691
- Rx.getReaction(b.rebuild).configure({
689
+ Rx.setLoggingHint(el, node.key);
690
+ Rx.getReaction(el.update).configure({
692
691
  order: node.level,
693
692
  });
694
693
  });
695
694
  }
696
- unobs(b.rebuild, node.builder.triggers);
695
+ unobs(el.update, node.builder.triggers);
697
696
  }
698
697
  else
699
- rebuildNow(ties);
698
+ updateNow(ties);
700
699
  }
701
700
  }
702
- function mountIfNecessary(block) {
703
- const node = block.node;
701
+ function mountOrRemountIfNecessary(element) {
702
+ const node = element.node;
704
703
  const driver = node.driver;
705
- if (node.stamp === 0) {
706
- node.stamp = 1;
704
+ if (node.stamp === Number.MAX_SAFE_INTEGER) {
705
+ node.stamp = Number.MAX_SAFE_INTEGER - 1;
707
706
  unobs(() => {
708
- driver.create(block, block);
709
- driver.initialize(block);
710
- if (block.isAutoMountEnabled)
711
- driver.mount(block);
707
+ driver.create(element, element);
708
+ driver.initialize(element);
709
+ if (!element.hasMode(Mode.ManualMount)) {
710
+ node.stamp = 0;
711
+ if (element.node.host !== element)
712
+ driver.mount(element);
713
+ }
712
714
  });
713
715
  }
714
- else if (block.isMoved && block.isAutoMountEnabled)
715
- unobs(() => driver.mount(block));
716
+ else if (element.isMoved && !element.hasMode(Mode.ManualMount) && element.node.host !== element)
717
+ unobs(() => driver.mount(element));
716
718
  }
717
- function rebuildNow(ties) {
718
- const b = ties.instance;
719
- const node = b.node;
719
+ function updateNow(ties) {
720
+ const el = ties.instance;
721
+ const node = el.node;
720
722
  if (node.stamp >= 0) {
721
723
  let result = undefined;
722
724
  runInside(ties, () => {
723
- try {
724
- mountIfNecessary(b);
725
- node.stamp++;
726
- node.numerator = 0;
727
- b.prepareForRebuild();
728
- node.children.beginMerge();
729
- const driver = node.driver;
730
- result = driver.rebuild(b);
731
- if (b.area === undefined && node.owner.isTable)
732
- b.area = undefined;
733
- if (result instanceof Promise)
734
- result.then(v => { runRebuildNestedTreesThenDo(undefined, NOP); return v; }, e => { console.log(e); runRebuildNestedTreesThenDo(e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
735
- else
736
- runRebuildNestedTreesThenDo(undefined, NOP);
737
- }
738
- catch (e) {
739
- runRebuildNestedTreesThenDo(e, NOP);
740
- console.log(`Rebuild failed: ${node.key}`);
741
- console.log(`${e}`);
725
+ mountOrRemountIfNecessary(el);
726
+ if (node.stamp < Number.MAX_SAFE_INTEGER - 1) {
727
+ try {
728
+ node.stamp++;
729
+ node.numerator = 0;
730
+ el.prepareForUpdate();
731
+ node.children.beginMerge();
732
+ const driver = node.driver;
733
+ result = driver.update(el);
734
+ if (el.area === undefined && node.owner.isTable)
735
+ el.area = undefined;
736
+ if (result instanceof Promise)
737
+ result.then(v => { runUpdateNestedTreesThenDo(undefined, NOP); return v; }, e => { console.log(e); runUpdateNestedTreesThenDo(e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
738
+ else
739
+ runUpdateNestedTreesThenDo(undefined, NOP);
740
+ }
741
+ catch (e) {
742
+ runUpdateNestedTreesThenDo(e, NOP);
743
+ console.log(`Update failed: ${node.key}`);
744
+ console.log(`${e}`);
745
+ }
742
746
  }
743
747
  });
744
748
  }
745
749
  }
746
750
  function triggerFinalization(ties, isLeader, individual) {
747
- const b = ties.instance;
748
- const node = b.node;
751
+ const el = ties.instance;
752
+ const node = el.node;
749
753
  if (node.stamp >= 0) {
750
754
  const driver = node.driver;
751
755
  if (individual && node.key !== node.builder.key && !driver.isRow)
752
- console.log(`WARNING: it is recommended to assign explicit key for conditional block in order to avoid unexpected side effects: ${node.key}`);
756
+ console.log(`WARNING: it is recommended to assign explicit key for conditional element in order to avoid unexpected side effects: ${node.key}`);
753
757
  node.stamp = ~node.stamp;
754
- const childrenAreLeaders = unobs(() => driver.finalize(b, isLeader));
755
- b.native = null;
756
- b.controller = null;
757
- if (b.isOn(Mode.PinpointRebuild)) {
758
+ const childrenAreLeaders = unobs(() => driver.finalize(el, isLeader));
759
+ el.native = null;
760
+ el.controller = null;
761
+ if (el.hasMode(Mode.PinpointUpdate)) {
758
762
  ties.aux = undefined;
759
763
  const last = gLastToDispose;
760
764
  if (last)
@@ -768,7 +772,7 @@ function triggerFinalization(ties, isLeader, individual) {
768
772
  }
769
773
  for (const item of node.children.items())
770
774
  triggerFinalization(item, childrenAreLeaders, false);
771
- BlockImpl.grandBlockCount--;
775
+ ElImpl.grandElementCount--;
772
776
  }
773
777
  }
774
778
  function runDisposalLoop() {
@@ -780,7 +784,7 @@ function runDisposalLoop() {
780
784
  yield Transaction.requestNextFrame();
781
785
  Rx.dispose(item.instance);
782
786
  item = item.aux;
783
- BlockImpl.disposableBlockCount--;
787
+ ElImpl.disposableElementCount--;
784
788
  }
785
789
  gFirstToDispose = gLastToDispose = undefined;
786
790
  });
@@ -824,7 +828,7 @@ function triggersAreEqual(a1, a2) {
824
828
  }
825
829
  return result;
826
830
  }
827
- function absolutizeBlockCoords(area, cursorX, cursorY, maxWidth, maxHeight, result) {
831
+ function absolutizeElCoords(area, cursorX, cursorY, maxWidth, maxHeight, result) {
828
832
  const x1 = absolutizePosition(area.x1, cursorX, maxWidth);
829
833
  const x2 = absolutizePosition(area.x2, x1, maxWidth);
830
834
  if (x1 <= x2)