verstak 0.23.121 → 0.23.123

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,70 +17,70 @@ 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
- static claim(driver, builder, base) {
23
+ static specify(driver, spec, base) {
24
24
  var _a;
25
25
  let result;
26
- if (builder)
27
- builder.base = base;
26
+ if (spec)
27
+ spec.base = base;
28
28
  else
29
- builder = base !== null && base !== void 0 ? base : {};
30
- let key = builder.key;
29
+ spec = base !== null && base !== void 0 ? base : {};
30
+ let key = spec.key;
31
31
  const owner = gCurrent === null || gCurrent === void 0 ? void 0 : gCurrent.instance;
32
32
  if (owner) {
33
33
  let ex = undefined;
34
34
  const children = owner.node.children;
35
- if (driver.isRow) {
36
- const last = children.lastClaimedItem();
35
+ if (driver.isSeparator) {
36
+ const last = children.lastSpecifiedItem();
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 update function only"));
40
+ ex !== null && ex !== void 0 ? ex : (ex = children.specify(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}"`);
46
- const exTriggers = node.builder.triggers;
47
- if (triggersAreEqual(builder.triggers, exTriggers))
48
- builder.triggers = exTriggers;
49
- node.builder = builder;
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
+ const exTriggers = node.spec.triggers;
47
+ if (triggersAreEqual(spec.triggers, exTriggers))
48
+ spec.triggers = exTriggers;
49
+ node.spec = spec;
50
50
  }
51
51
  else {
52
- result = new BlockImpl(key || generateKey(owner), driver, owner, builder);
53
- result.node.ties = children.add(result);
52
+ result = new ElImpl(key || generateKey(owner), driver, owner, spec);
53
+ result.node.slot = children.add(result);
54
54
  }
55
55
  }
56
56
  else {
57
- result = new BlockImpl(key || "", driver, owner, builder);
58
- result.node.ties = MergeList.createItem(result);
59
- triggerUpdate(result.node.ties);
57
+ result = new ElImpl(key || "", driver, owner, spec);
58
+ result.node.slot = MergeList.createItem(result);
59
+ triggerUpdate(result.node.slot);
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 triggerUpdate(block, triggers) {
69
- const b = block;
70
- const builder = b.node.builder;
71
- if (!triggersAreEqual(triggers, builder.triggers)) {
72
- builder.triggers = triggers;
73
- triggerUpdate(b.node.ties);
68
+ static triggerUpdate(element, triggers) {
69
+ const el = element;
70
+ const spec = el.node.spec;
71
+ if (!triggersAreEqual(triggers, spec.triggers)) {
72
+ spec.triggers = triggers;
73
+ triggerUpdate(el.node.slot);
74
74
  }
75
75
  }
76
76
  static updateNestedTreesThenDo(action) {
77
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;
@@ -88,49 +88,46 @@ Verstak.longFrameDuration = 300;
88
88
  Verstak.currentUpdatePriority = Priority.Realtime;
89
89
  Verstak.frameDuration = Verstak.longFrameDuration;
90
90
  export class BaseDriver {
91
- constructor(name, isRow, preset) {
91
+ constructor(name, isSeparator, preset) {
92
92
  this.name = name;
93
- this.isRow = isRow;
93
+ this.isSeparator = isSeparator;
94
94
  this.preset = preset;
95
95
  }
96
- claim(block) {
97
- const b = block;
98
- chainedClaim(b, b.node.builder);
96
+ specify(element) {
97
+ chainedSpecify(element, element.node.spec);
99
98
  }
100
- create(block, b) {
101
- chainedCreate(block, block.node.builder);
99
+ create(element) {
100
+ chainedCreate(element, element.node.spec);
102
101
  }
103
- initialize(block) {
102
+ initialize(element) {
104
103
  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);
104
+ (_a = this.preset) === null || _a === void 0 ? void 0 : _a.call(this, element);
105
+ chainedInitialize(element, element.node.spec);
108
106
  }
109
- mount(block) {
107
+ mount(element) {
110
108
  }
111
- update(block) {
112
- chainedUpdated(block, block.node.builder);
109
+ update(element) {
110
+ chainedUpdated(element, element.node.spec);
113
111
  }
114
- finalize(block, isLeader) {
115
- const b = block;
116
- chainedFinalize(b, b.node.builder);
112
+ finalize(element, isLeader) {
113
+ chainedFinalize(element, element.node.spec);
117
114
  return isLeader;
118
115
  }
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);
116
+ applyKind(element, value) { }
117
+ applyCoords(element, value) { }
118
+ applyWidthGrowth(element, value) { }
119
+ applyMinWidth(element, value) { }
120
+ applyMaxWidth(element, value) { }
121
+ applyHeightGrowth(element, value) { }
122
+ applyMinHeight(element, value) { }
123
+ applyMaxHeight(element, value) { }
124
+ applyContentAlignment(element, value) { }
125
+ applyElementAlignment(element, value) { }
126
+ applyContentWrapping(element, value) { }
127
+ applyOverlayVisible(element, value) { }
128
+ applyStyle(element, secondary, styleName, enabled) { }
129
+ }
130
+ BaseDriver.fragment = new BaseDriver("fragment", false, el => el.kind = ElKind.Group);
134
131
  function generateKey(owner) {
135
132
  const n = owner.node.numerator++;
136
133
  const lettered = emitLetters(n);
@@ -145,64 +142,64 @@ function chainedMode(bb) {
145
142
  var _a;
146
143
  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
144
  }
148
- function chainedClaim(block, bb) {
149
- const claim = bb.claim;
150
- const base = bb.base;
151
- if (claim)
152
- claim(block, base ? () => chainedClaim(block, base) : NOP);
145
+ function chainedSpecify(element, elb) {
146
+ const specify = elb.specify;
147
+ const base = elb.base;
148
+ if (specify)
149
+ specify(element, base ? () => chainedSpecify(element, base) : NOP);
153
150
  else if (base)
154
- chainedClaim(block, base);
151
+ chainedSpecify(element, base);
155
152
  }
156
- function chainedCreate(block, bb) {
157
- const create = bb.create;
158
- const base = bb.base;
153
+ function chainedCreate(element, elb) {
154
+ const create = elb.create;
155
+ const base = elb.base;
159
156
  if (create)
160
- create(block, base ? () => chainedCreate(block, base) : NOP);
157
+ create(element, base ? () => chainedCreate(element, base) : NOP);
161
158
  else if (base)
162
- chainedCreate(block, base);
159
+ chainedCreate(element, base);
163
160
  }
164
- function chainedInitialize(block, bb) {
165
- const initialize = bb.initialize;
166
- const base = bb.base;
161
+ function chainedInitialize(element, elb) {
162
+ const initialize = elb.initialize;
163
+ const base = elb.base;
167
164
  if (initialize)
168
- initialize(block, base ? () => chainedInitialize(block, base) : NOP);
165
+ initialize(element, base ? () => chainedInitialize(element, base) : NOP);
169
166
  else if (base)
170
- chainedInitialize(block, base);
167
+ chainedInitialize(element, base);
171
168
  }
172
- function chainedUpdated(block, bb) {
173
- const update = bb.update;
174
- const base = bb.base;
169
+ function chainedUpdated(element, elb) {
170
+ const update = elb.update;
171
+ const base = elb.base;
175
172
  if (update)
176
- update(block, base ? () => chainedUpdated(block, base) : NOP);
173
+ update(element, base ? () => chainedUpdated(element, base) : NOP);
177
174
  else if (base)
178
- chainedUpdated(block, base);
175
+ chainedUpdated(element, base);
179
176
  }
180
- function chainedFinalize(block, bb) {
181
- const finalize = bb.finalize;
182
- const base = bb.base;
177
+ function chainedFinalize(element, elb) {
178
+ const finalize = elb.finalize;
179
+ const base = elb.base;
183
180
  if (finalize)
184
- finalize(block, base ? () => chainedFinalize(block, base) : NOP);
181
+ finalize(element, base ? () => chainedFinalize(element, base) : NOP);
185
182
  else if (base)
186
- chainedFinalize(block, base);
183
+ chainedFinalize(element, base);
187
184
  }
188
185
  export class StaticDriver extends BaseDriver {
189
- constructor(element, name, isRow, preset) {
186
+ constructor(native, name, isRow, preset) {
190
187
  super(name, isRow, preset);
191
- this.element = element;
188
+ this.native = native;
192
189
  }
193
- create(block, b) {
194
- b.native = this.element;
190
+ create(element) {
191
+ element.native = this.native;
195
192
  }
196
193
  }
197
194
  export class CursorCommand {
198
195
  }
199
196
  export class CursorCommandDriver extends BaseDriver {
200
197
  constructor() {
201
- super("cursor", false, b => b.kind = BlockKind.Cursor);
198
+ super("cursor", false, el => el.kind = ElKind.Cursor);
202
199
  }
203
- create(block, b) {
204
- b.native = new CursorCommand();
205
- super.create(block, b);
200
+ create(element) {
201
+ element.native = new CursorCommand();
202
+ super.create(element);
206
203
  }
207
204
  }
208
205
  export class SubTreeVariable {
@@ -210,13 +207,13 @@ export class SubTreeVariable {
210
207
  this.defaultValue = defaultValue;
211
208
  }
212
209
  set value(value) {
213
- BlockImpl.setSubTreeVariableValue(this, value);
210
+ ElImpl.setSubTreeVariableValue(this, value);
214
211
  }
215
212
  get value() {
216
- return BlockImpl.useSubTreeVariableValue(this);
213
+ return ElImpl.useSubTreeVariableValue(this);
217
214
  }
218
215
  get valueOrUndefined() {
219
- return BlockImpl.tryUseSubTreeVariable(this);
216
+ return ElImpl.tryUseSubTreeVariable(this);
220
217
  }
221
218
  }
222
219
  class CursorPosition {
@@ -235,9 +232,9 @@ var CursorFlags;
235
232
  CursorFlags[CursorFlags["UsesRunningColumnCount"] = 2] = "UsesRunningColumnCount";
236
233
  CursorFlags[CursorFlags["UsesRunningRowCount"] = 4] = "UsesRunningRowCount";
237
234
  })(CursorFlags || (CursorFlags = {}));
238
- const UndefinedBlockCoords = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
235
+ const UndefinedElCoords = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
239
236
  const InitialCursorPosition = Object.freeze(new CursorPosition({ x: 1, y: 1, runningMaxX: 0, runningMaxY: 0, flags: CursorFlags.None }));
240
- class BlockCtxImpl extends ObservableObject {
237
+ class RxNodeCtxImpl extends ObservableObject {
241
238
  constructor(variable, value) {
242
239
  super();
243
240
  this.next = undefined;
@@ -248,49 +245,75 @@ class BlockCtxImpl extends ObservableObject {
248
245
  __decorate([
249
246
  raw,
250
247
  __metadata("design:type", Object)
251
- ], BlockCtxImpl.prototype, "next", void 0);
248
+ ], RxNodeCtxImpl.prototype, "next", void 0);
252
249
  __decorate([
253
250
  raw,
254
251
  __metadata("design:type", SubTreeVariable)
255
- ], BlockCtxImpl.prototype, "variable", void 0);
256
- class BlockNodeImpl {
257
- constructor(key, driver, builder, self, owner) {
258
- this.maxColumnCount = 0;
259
- this.maxRowCount = 0;
252
+ ], RxNodeCtxImpl.prototype, "variable", void 0);
253
+ class RxNodeImpl {
254
+ constructor(key, driver, spec, element, owner) {
260
255
  this.key = key;
261
256
  this.driver = driver;
262
- this.builder = builder;
257
+ this.spec = spec;
263
258
  if (owner) {
264
- const node = owner.node;
259
+ const node = owner;
265
260
  this.level = node.level + 1;
266
261
  this.owner = owner;
267
262
  this.outer = node.context ? owner : node.outer;
268
263
  }
269
264
  else {
270
265
  this.level = 1;
271
- this.owner = owner = self;
272
- this.outer = self;
266
+ this.owner = owner = this;
267
+ this.outer = this;
273
268
  }
274
- this.host = self;
275
- this.children = new MergeList(getBlockKey, true);
276
- this.ties = undefined;
277
- this.stamp = 0;
269
+ this.host = this;
270
+ this.children = new MergeList(getNodeKey, true);
271
+ this.slot = undefined;
272
+ this.stamp = Number.MAX_SAFE_INTEGER;
278
273
  this.context = undefined;
279
274
  this.numerator = 0;
275
+ this.priority = Priority.Realtime;
276
+ this.childrenShuffling = false;
277
+ RxNodeImpl.grandNodeCount++;
278
+ if (this.has(Mode.PinpointUpdate))
279
+ RxNodeImpl.disposableNodeCount++;
280
+ }
281
+ get isInitialUpdate() { return this.stamp === 1; }
282
+ get strictOrder() { return this.children.isStrict; }
283
+ set strictOrder(value) { this.children.isStrict = value; }
284
+ get isMoved() { return this.owner.children.isMoved(this.slot); }
285
+ has(mode) {
286
+ return (chainedMode(this.spec) & mode) === mode;
287
+ }
288
+ update(_triggers) {
289
+ updateNow(this.slot);
290
+ }
291
+ }
292
+ RxNodeImpl.grandNodeCount = 0;
293
+ RxNodeImpl.disposableNodeCount = 0;
294
+ __decorate([
295
+ reactive,
296
+ options({
297
+ reentrance: Reentrance.CancelPrevious,
298
+ triggeringArgs: true,
299
+ noSideEffects: false,
300
+ }),
301
+ __metadata("design:type", Function),
302
+ __metadata("design:paramtypes", [Object]),
303
+ __metadata("design:returntype", void 0)
304
+ ], RxNodeImpl.prototype, "update", null);
305
+ class ElImpl {
306
+ constructor(key, driver, owner, spec) {
307
+ this.node = new RxNodeImpl(key, driver, spec, this, owner === null || owner === void 0 ? void 0 : owner.node);
280
308
  this.maxColumnCount = 0;
281
309
  this.maxRowCount = 0;
282
310
  this.cursorPosition = undefined;
283
- }
284
- }
285
- class BlockImpl {
286
- constructor(key, driver, owner, builder) {
287
- this.node = new BlockNodeImpl(key, driver, builder, this, owner);
288
311
  this.native = undefined;
289
312
  this.model = undefined;
290
313
  this.controller = undefined;
291
- this._kind = BlockKind.Row;
314
+ this._kind = ElKind.Row;
292
315
  this._area = undefined;
293
- this._coords = UndefinedBlockCoords;
316
+ this._coords = UndefinedElCoords;
294
317
  this._widthGrowth = 0;
295
318
  this._minWidth = "";
296
319
  this._maxWidth = "";
@@ -298,37 +321,21 @@ class BlockImpl {
298
321
  this._minHeight = "";
299
322
  this._maxHeight = "";
300
323
  this._contentAlignment = Align.Default;
301
- this._blockAlignment = Align.Default;
324
+ this._elementAlignment = Align.Default;
302
325
  this._contentWrapping = true;
303
326
  this._overlayVisible = undefined;
304
327
  this._hasStyles = false;
305
- this.updatePriority = Priority.Realtime;
306
- this.childrenShuffling = false;
307
- BlockImpl.grandBlockCount++;
308
- if (this.isOn(Mode.PinpointUpdate))
309
- BlockImpl.disposableBlockCount++;
310
- }
311
- update(_triggers) {
312
- updateNow(this.node.ties);
313
328
  }
314
329
  prepareForUpdate() {
315
330
  this._area = undefined;
316
331
  this._hasStyles = false;
317
332
  }
318
- isOn(mode) {
319
- return (chainedMode(this.node.builder) & mode) === mode;
320
- }
321
- get isInitialUpdate() { 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; }
326
- get isMoved() { return this.node.owner.node.children.isMoved(this.node.ties); }
327
- get strictOrder() { return this.node.children.isStrict; }
328
- set strictOrder(value) { this.node.children.isStrict = value; }
333
+ get isAuxiliary() { return this.kind > ElKind.Note; }
334
+ get isSection() { return this.kind === ElKind.Section; }
335
+ get isTable() { return this.kind === ElKind.Table; }
329
336
  get kind() { return this._kind; }
330
337
  set kind(value) {
331
- if (value !== this._kind || this.node.stamp < 2) {
338
+ if (value !== this._kind || this.node.stamp >= Number.MAX_SAFE_INTEGER - 1) {
332
339
  this.node.driver.applyKind(this, value);
333
340
  this._kind = value;
334
341
  }
@@ -338,13 +345,14 @@ class BlockImpl {
338
345
  var _a, _b;
339
346
  const node = this.node;
340
347
  const driver = node.driver;
341
- if (!driver.isRow) {
342
- const owner = node.owner.node;
343
- const cursorPosition = (_b = (_a = node.ties.prev) === null || _a === void 0 ? void 0 : _a.instance.node.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
344
- 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)) {
348
+ if (!driver.isSeparator) {
349
+ const owner = node.owner;
350
+ const ownerEl = owner.slot.instance;
351
+ const cursorPosition = (_b = (_a = node.slot.prev) === null || _a === void 0 ? void 0 : _a.instance.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
352
+ const newCursorPosition = this.cursorPosition = owner.children.isStrict ? new CursorPosition(cursorPosition) : undefined;
353
+ const isCursorElement = driver instanceof CursorCommandDriver;
354
+ const coords = getEffectiveElCoords(!isCursorElement, value, ownerEl.maxColumnCount, ownerEl.maxRowCount, cursorPosition, newCursorPosition);
355
+ if (!equalElCoords(coords, this._coords)) {
348
356
  driver.applyCoords(this, coords);
349
357
  this._coords = coords;
350
358
  }
@@ -402,11 +410,11 @@ class BlockImpl {
402
410
  this._contentAlignment = value;
403
411
  }
404
412
  }
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;
413
+ get elementAlignment() { return this._elementAlignment; }
414
+ set elementAlignment(value) {
415
+ if (value !== this._elementAlignment) {
416
+ this.node.driver.applyElementAlignment(this, value);
417
+ this._elementAlignment = value;
410
418
  }
411
419
  }
412
420
  get contentWrapping() { return this._contentWrapping; }
@@ -428,39 +436,40 @@ class BlockImpl {
428
436
  this._hasStyles = true;
429
437
  }
430
438
  configureReactronic(options) {
431
- if (this.node.stamp !== 1 || !this.isOn(Mode.PinpointUpdate))
432
- throw new Error("reactronic can be configured only for blocks with separate reaction mode and only inside initialize");
433
- return Rx.getReaction(this.update).configure(options);
439
+ const node = this.node;
440
+ if (node.stamp < Number.MAX_SAFE_INTEGER - 1 || !node.has(Mode.PinpointUpdate))
441
+ throw new Error("reactronic can be configured only for elements with pinpoint update mode and only inside initialize");
442
+ return Rx.getReaction(node.update).configure(options);
434
443
  }
435
444
  static get curr() {
436
445
  if (!gCurrent)
437
- throw new Error("current block is undefined");
446
+ throw new Error("current element is undefined");
438
447
  return gCurrent;
439
448
  }
440
449
  static tryUseSubTreeVariable(variable) {
441
450
  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;
451
+ let el = ElImpl.curr.instance;
452
+ while (((_a = el.node.context) === null || _a === void 0 ? void 0 : _a.variable) !== variable && el.node.owner !== el.node)
453
+ el = el.node.outer.slot.instance;
454
+ return (_b = el.node.context) === null || _b === void 0 ? void 0 : _b.value;
446
455
  }
447
456
  static useSubTreeVariableValue(variable) {
448
457
  var _a;
449
- const result = (_a = BlockImpl.tryUseSubTreeVariable(variable)) !== null && _a !== void 0 ? _a : variable.defaultValue;
458
+ const result = (_a = ElImpl.tryUseSubTreeVariable(variable)) !== null && _a !== void 0 ? _a : variable.defaultValue;
450
459
  if (!result)
451
460
  throw new Error("context doesn't exist");
452
461
  return result;
453
462
  }
454
463
  static setSubTreeVariableValue(variable, value) {
455
- const b = BlockImpl.curr.instance;
456
- const node = b.node;
464
+ const el = ElImpl.curr.instance;
465
+ const node = el.node;
457
466
  const owner = node.owner;
458
- const hostCtx = unobs(() => { var _a; return (_a = owner.node.context) === null || _a === void 0 ? void 0 : _a.value; });
467
+ const hostCtx = unobs(() => { var _a; return (_a = owner.context) === null || _a === void 0 ? void 0 : _a.value; });
459
468
  if (value && value !== hostCtx) {
460
469
  if (hostCtx)
461
470
  node.outer = owner;
462
471
  else
463
- node.outer = owner.node.outer;
472
+ node.outer = owner.outer;
464
473
  Transaction.run({ separation: true }, () => {
465
474
  const ctx = node.context;
466
475
  if (ctx) {
@@ -468,49 +477,36 @@ class BlockImpl {
468
477
  ctx.value = value;
469
478
  }
470
479
  else
471
- node.context = new BlockCtxImpl(variable, value);
480
+ node.context = new RxNodeCtxImpl(variable, value);
472
481
  });
473
482
  }
474
483
  else if (hostCtx)
475
484
  node.outer = owner;
476
485
  else
477
- node.outer = owner.node.outer;
486
+ node.outer = owner.outer;
478
487
  }
479
488
  rowBreak() {
480
489
  var _a, _b;
481
490
  const node = this.node;
482
- const cursorPosition = (_b = (_a = node.ties.prev) === null || _a === void 0 ? void 0 : _a.instance.node.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
483
- const newCursorPosition = this.node.cursorPosition = new CursorPosition(cursorPosition);
491
+ const cursorPosition = (_b = (_a = node.slot.prev) === null || _a === void 0 ? void 0 : _a.instance.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
492
+ const newCursorPosition = this.cursorPosition = new CursorPosition(cursorPosition);
484
493
  newCursorPosition.x = 1;
485
494
  newCursorPosition.y = newCursorPosition.runningMaxY + 1;
486
495
  }
487
496
  }
488
- BlockImpl.grandBlockCount = 0;
489
- BlockImpl.disposableBlockCount = 0;
490
- BlockImpl.logging = undefined;
491
- __decorate([
492
- reactive,
493
- options({
494
- reentrance: Reentrance.CancelPrevious,
495
- triggeringArgs: true,
496
- noSideEffects: false,
497
- }),
498
- __metadata("design:type", Function),
499
- __metadata("design:paramtypes", [Object]),
500
- __metadata("design:returntype", void 0)
501
- ], BlockImpl.prototype, "update", null);
502
- function getBlockKey(block) {
503
- const node = block.node;
497
+ ElImpl.logging = undefined;
498
+ function getNodeKey(element) {
499
+ const node = element.node;
504
500
  return node.stamp >= 0 ? node.key : undefined;
505
501
  }
506
- function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPosition, newCursorPosition) {
502
+ function getEffectiveElCoords(isRegularElement, area, maxX, maxY, cursorPosition, newCursorPosition) {
507
503
  var _a, _b;
508
504
  let result;
509
505
  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);
506
+ result = parseElCoords(area, { x1: 0, y1: 0, x2: 0, y2: 0 });
507
+ absolutizeElCoords(result, cursorPosition.x, cursorPosition.y, maxX || Infinity, maxY || Infinity, result);
512
508
  if (newCursorPosition) {
513
- newCursorPosition.x = isRegularBlock ? result.x2 + 1 : result.x1;
509
+ newCursorPosition.x = isRegularElement ? result.x2 + 1 : result.x1;
514
510
  newCursorPosition.y = result.y1;
515
511
  newCursorPosition.flags = CursorFlags.OwnCursorPosition;
516
512
  }
@@ -527,12 +523,12 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
527
523
  const runningX = maxX !== 0 ? maxX : cursorPosition.runningMaxX;
528
524
  const runningY = maxY !== 0 ? maxY : cursorPosition.runningMaxY;
529
525
  result = { x1: 0, y1: 0, x2: 0, y2: 0 };
530
- if (dx === 0 && isRegularBlock) {
526
+ if (dx === 0 && isRegularElement) {
531
527
  dx = runningX || 1;
532
528
  newCursorPosition.flags = CursorFlags.UsesRunningColumnCount;
533
529
  }
534
530
  if (dx >= 0) {
535
- if (isRegularBlock) {
531
+ if (isRegularElement) {
536
532
  result.x1 = cursorPosition.x;
537
533
  result.x2 = absolutizePosition(result.x1 + dx - 1, 0, maxX || Infinity);
538
534
  newCursorPosition.x = result.x2 + 1;
@@ -543,7 +539,7 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
543
539
  }
544
540
  }
545
541
  else {
546
- if (isRegularBlock) {
542
+ if (isRegularElement) {
547
543
  result.x1 = Math.max(cursorPosition.x + dx, 1);
548
544
  result.x2 = cursorPosition.x;
549
545
  newCursorPosition.x = result.x2 + 1;
@@ -553,12 +549,12 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
553
549
  newCursorPosition.x = result.x2;
554
550
  }
555
551
  }
556
- if (dy === 0 && isRegularBlock) {
552
+ if (dy === 0 && isRegularElement) {
557
553
  dy = runningY || 1;
558
554
  newCursorPosition.flags |= CursorFlags.UsesRunningRowCount;
559
555
  }
560
556
  if (dy >= 0) {
561
- if (isRegularBlock) {
557
+ if (isRegularElement) {
562
558
  result.y1 = cursorPosition.y;
563
559
  result.y2 = absolutizePosition(result.y1 + dy - 1, 0, maxY || Infinity);
564
560
  if (result.y2 > newCursorPosition.runningMaxY)
@@ -568,7 +564,7 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
568
564
  result.y1 = result.y2 = cursorPosition.y + dy;
569
565
  }
570
566
  else {
571
- if (isRegularBlock) {
567
+ if (isRegularElement) {
572
568
  result.y1 = Math.max(cursorPosition.y + dy, 1);
573
569
  result.y2 = cursorPosition.y;
574
570
  }
@@ -582,15 +578,15 @@ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPositio
582
578
  }
583
579
  function runUpdateNestedTreesThenDo(error, action) {
584
580
  var _a;
585
- const curr = BlockImpl.curr;
581
+ const curr = ElImpl.curr;
586
582
  const owner = curr.instance;
587
583
  const children = owner.node.children;
588
584
  if (children.isMergeInProgress) {
589
585
  let promised = undefined;
590
586
  try {
591
587
  children.endMerge(error);
592
- for (const item of children.removedItems(true))
593
- triggerFinalization(item, true, true);
588
+ for (const slot of children.removedItems(true))
589
+ triggerFinalization(slot, true, true);
594
590
  if (!error) {
595
591
  const ownerIsSection = owner.isSection;
596
592
  const sequential = children.isStrict;
@@ -598,22 +594,22 @@ function runUpdateNestedTreesThenDo(error, action) {
598
594
  let p2 = undefined;
599
595
  let mounting = false;
600
596
  let hostingRow = owner;
601
- for (const item of children.items()) {
597
+ for (const slot of children.items()) {
602
598
  if (Transaction.isCanceled)
603
599
  break;
604
- const block = item.instance;
605
- const isRow = block.node.driver.isRow;
606
- const host = isRow ? owner : hostingRow;
607
- const p = (_a = block.updatePriority) !== null && _a !== void 0 ? _a : Priority.Realtime;
608
- mounting = markToMountIfNecessary(mounting, host, item, children, sequential);
600
+ const el = slot.instance;
601
+ const isSeparator = el.node.driver.isSeparator;
602
+ const host = isSeparator ? owner : hostingRow;
603
+ const p = (_a = el.node.priority) !== null && _a !== void 0 ? _a : Priority.Realtime;
604
+ mounting = markToMountIfNecessary(mounting, host, slot, children, sequential);
609
605
  if (p === Priority.Realtime)
610
- triggerUpdate(item);
606
+ triggerUpdate(slot);
611
607
  else if (p === Priority.Normal)
612
- p1 = push(item, p1);
608
+ p1 = push(slot, p1);
613
609
  else
614
- p2 = push(item, p2);
615
- if (ownerIsSection && isRow)
616
- hostingRow = block;
610
+ p2 = push(slot, p2);
611
+ if (ownerIsSection && isSeparator)
612
+ hostingRow = el;
617
613
  }
618
614
  if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
619
615
  promised = startIncrementalUpdate(curr, children, p1, p2).then(() => action(error), e => action(e));
@@ -625,18 +621,18 @@ function runUpdateNestedTreesThenDo(error, action) {
625
621
  }
626
622
  }
627
623
  }
628
- 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)) {
632
- if (mounting || node.host !== host) {
633
- children.markAsMoved(ties);
624
+ function markToMountIfNecessary(mounting, host, slot, children, sequential) {
625
+ const el = slot.instance;
626
+ const node = el.node;
627
+ if (el.native && !node.has(Mode.ManualMount)) {
628
+ if (mounting || node.host !== host.node) {
629
+ children.markAsMoved(slot);
634
630
  mounting = false;
635
631
  }
636
632
  }
637
- else if (sequential && children.isMoved(ties))
633
+ else if (sequential && children.isMoved(slot))
638
634
  mounting = true;
639
- node.host = host;
635
+ node.host = host.node;
640
636
  return mounting;
641
637
  }
642
638
  function startIncrementalUpdate(owner, allChildren, priority1, priority2) {
@@ -651,12 +647,12 @@ function startIncrementalUpdate(owner, allChildren, priority1, priority2) {
651
647
  function updateIncrementally(owner, stamp, allChildren, items, priority) {
652
648
  return __awaiter(this, void 0, void 0, function* () {
653
649
  yield Transaction.requestNextFrame();
654
- const block = owner.instance;
650
+ const el = owner.instance;
655
651
  if (!Transaction.isCanceled || !Transaction.isFrameOver(1, Verstak.shortFrameDuration / 3)) {
656
652
  let outerPriority = Verstak.currentUpdatePriority;
657
653
  Verstak.currentUpdatePriority = priority;
658
654
  try {
659
- if (block.childrenShuffling)
655
+ if (el.node.childrenShuffling)
660
656
  shuffle(items);
661
657
  const frameDurationLimit = priority === Priority.Background ? Verstak.shortFrameDuration : Infinity;
662
658
  let frameDuration = Math.min(frameDurationLimit, Math.max(Verstak.frameDuration / 4, Verstak.shortFrameDuration));
@@ -679,108 +675,114 @@ function updateIncrementally(owner, stamp, allChildren, items, priority) {
679
675
  }
680
676
  });
681
677
  }
682
- function triggerUpdate(ties) {
683
- const b = ties.instance;
684
- const node = b.node;
678
+ function triggerUpdate(slot) {
679
+ const el = slot.instance;
680
+ const node = el.node;
685
681
  if (node.stamp >= 0) {
686
- if (b.isOn(Mode.PinpointUpdate)) {
687
- if (node.stamp === 0) {
682
+ if (node.has(Mode.PinpointUpdate)) {
683
+ if (node.stamp === Number.MAX_SAFE_INTEGER) {
688
684
  Transaction.outside(() => {
689
685
  if (Rx.isLogging)
690
- Rx.setLoggingHint(b, node.key);
691
- Rx.getReaction(b.update).configure({
686
+ Rx.setLoggingHint(el, node.key);
687
+ Rx.getReaction(node.update).configure({
692
688
  order: node.level,
693
689
  });
694
690
  });
695
691
  }
696
- unobs(b.update, node.builder.triggers);
692
+ unobs(node.update, node.spec.triggers);
697
693
  }
698
694
  else
699
- updateNow(ties);
695
+ updateNow(slot);
700
696
  }
701
697
  }
702
- function mountIfNecessary(block) {
703
- const node = block.node;
698
+ function mountOrRemountIfNecessary(element) {
699
+ const node = element.node;
704
700
  const driver = node.driver;
705
- if (node.stamp === 0) {
706
- node.stamp = 1;
701
+ if (node.stamp === Number.MAX_SAFE_INTEGER) {
702
+ node.stamp = Number.MAX_SAFE_INTEGER - 1;
707
703
  unobs(() => {
708
- driver.create(block, block);
709
- driver.initialize(block);
710
- if (block.isAutoMountEnabled)
711
- driver.mount(block);
704
+ driver.create(element);
705
+ driver.initialize(element);
706
+ if (!node.has(Mode.ManualMount)) {
707
+ node.stamp = 0;
708
+ if (element.node.host !== element.node)
709
+ driver.mount(element);
710
+ }
711
+ node.stamp = 0;
712
712
  });
713
713
  }
714
- else if (block.isMoved && block.isAutoMountEnabled)
715
- unobs(() => driver.mount(block));
714
+ else if (node.isMoved && !node.has(Mode.ManualMount) && element.node.host !== element.node)
715
+ unobs(() => driver.mount(element));
716
716
  }
717
- function updateNow(ties) {
718
- const b = ties.instance;
719
- const node = b.node;
717
+ function updateNow(slot) {
718
+ const el = slot.instance;
719
+ const node = el.node;
720
720
  if (node.stamp >= 0) {
721
721
  let result = undefined;
722
- runInside(ties, () => {
723
- try {
724
- mountIfNecessary(b);
725
- node.stamp++;
726
- node.numerator = 0;
727
- b.prepareForUpdate();
728
- node.children.beginMerge();
729
- const driver = node.driver;
730
- result = driver.update(b);
731
- if (b.area === undefined && node.owner.isTable)
732
- b.area = undefined;
733
- if (result instanceof Promise)
734
- result.then(v => { runUpdateNestedTreesThenDo(undefined, NOP); return v; }, e => { console.log(e); runUpdateNestedTreesThenDo(e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
735
- else
736
- runUpdateNestedTreesThenDo(undefined, NOP);
737
- }
738
- catch (e) {
739
- runUpdateNestedTreesThenDo(e, NOP);
740
- console.log(`Update failed: ${node.key}`);
741
- console.log(`${e}`);
722
+ runInside(slot, () => {
723
+ mountOrRemountIfNecessary(el);
724
+ if (node.stamp < Number.MAX_SAFE_INTEGER - 1) {
725
+ try {
726
+ node.stamp++;
727
+ node.numerator = 0;
728
+ el.prepareForUpdate();
729
+ node.children.beginMerge();
730
+ const driver = node.driver;
731
+ result = driver.update(el);
732
+ if (el.area === undefined && node.owner.slot.instance.isTable)
733
+ el.area = undefined;
734
+ if (result instanceof Promise)
735
+ result.then(v => { runUpdateNestedTreesThenDo(undefined, NOP); return v; }, e => { console.log(e); runUpdateNestedTreesThenDo(e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
736
+ else
737
+ runUpdateNestedTreesThenDo(undefined, NOP);
738
+ }
739
+ catch (e) {
740
+ runUpdateNestedTreesThenDo(e, NOP);
741
+ console.log(`Update failed: ${node.key}`);
742
+ console.log(`${e}`);
743
+ }
742
744
  }
743
745
  });
744
746
  }
745
747
  }
746
- function triggerFinalization(ties, isLeader, individual) {
747
- const b = ties.instance;
748
- const node = b.node;
748
+ function triggerFinalization(slot, isLeader, individual) {
749
+ const el = slot.instance;
750
+ const node = el.node;
749
751
  if (node.stamp >= 0) {
750
752
  const driver = node.driver;
751
- 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}`);
753
+ if (individual && node.key !== node.spec.key && !driver.isSeparator)
754
+ console.log(`WARNING: it is recommended to assign explicit key for conditional element in order to avoid unexpected side effects: ${node.key}`);
753
755
  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.PinpointUpdate)) {
758
- ties.aux = undefined;
756
+ const childrenAreLeaders = unobs(() => driver.finalize(el, isLeader));
757
+ el.native = null;
758
+ el.controller = null;
759
+ if (node.has(Mode.PinpointUpdate)) {
760
+ slot.aux = undefined;
759
761
  const last = gLastToDispose;
760
762
  if (last)
761
- gLastToDispose = last.aux = ties;
763
+ gLastToDispose = last.aux = slot;
762
764
  else
763
- gFirstToDispose = gLastToDispose = ties;
764
- if (gFirstToDispose === ties)
765
- Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${ties.instance.node.key})` }, () => {
765
+ gFirstToDispose = gLastToDispose = slot;
766
+ if (gFirstToDispose === slot)
767
+ Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${slot.instance.node.key})` }, () => {
766
768
  void runDisposalLoop().then(NOP, error => console.log(error));
767
769
  });
768
770
  }
769
- for (const item of node.children.items())
770
- triggerFinalization(item, childrenAreLeaders, false);
771
- BlockImpl.grandBlockCount--;
771
+ for (const slot of node.children.items())
772
+ triggerFinalization(slot, childrenAreLeaders, false);
773
+ RxNodeImpl.grandNodeCount--;
772
774
  }
773
775
  }
774
776
  function runDisposalLoop() {
775
777
  return __awaiter(this, void 0, void 0, function* () {
776
778
  yield Transaction.requestNextFrame();
777
- let item = gFirstToDispose;
778
- while (item !== undefined) {
779
+ let slot = gFirstToDispose;
780
+ while (slot !== undefined) {
779
781
  if (Transaction.isFrameOver(500, 5))
780
782
  yield Transaction.requestNextFrame();
781
- Rx.dispose(item.instance);
782
- item = item.aux;
783
- BlockImpl.disposableBlockCount--;
783
+ Rx.dispose(slot.instance);
784
+ slot = slot.aux;
785
+ RxNodeImpl.disposableNodeCount--;
784
786
  }
785
787
  gFirstToDispose = gLastToDispose = undefined;
786
788
  });
@@ -796,10 +798,10 @@ function wrapToRunInside(func) {
796
798
  wrappedToRunInside = func;
797
799
  return wrappedToRunInside;
798
800
  }
799
- function runInside(ties, func, ...args) {
801
+ function runInside(slot, func, ...args) {
800
802
  const outer = gCurrent;
801
803
  try {
802
- gCurrent = ties;
804
+ gCurrent = slot;
803
805
  return func(...args);
804
806
  }
805
807
  finally {
@@ -824,7 +826,7 @@ function triggersAreEqual(a1, a2) {
824
826
  }
825
827
  return result;
826
828
  }
827
- function absolutizeBlockCoords(area, cursorX, cursorY, maxWidth, maxHeight, result) {
829
+ function absolutizeElCoords(area, cursorX, cursorY, maxWidth, maxHeight, result) {
828
830
  const x1 = absolutizePosition(area.x1, cursorX, maxWidth);
829
831
  const x2 = absolutizePosition(area.x2, x1, maxWidth);
830
832
  if (x1 <= x2)