verstak 0.23.108 → 0.23.110

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.
@@ -20,43 +20,43 @@ import { reactive, nonreactive, Transaction, options, Reentrance, Rx, Collection
20
20
  import { BlockKind, Priority, Mode, Align } from "./Interfaces";
21
21
  import { emitLetters, equalBlockCoords, parseBlockCoords, getCallerInfo } from "./Utils";
22
22
  export class Verstak {
23
- static claim(driver, builder, original) {
23
+ static claim(driver, builder, base) {
24
24
  var _a;
25
25
  let result;
26
26
  if (builder)
27
- builder.original = original;
27
+ builder.base = base;
28
28
  else
29
- builder = original !== null && original !== void 0 ? original : {};
29
+ builder = base !== null && base !== void 0 ? base : {};
30
30
  let key = builder.key;
31
31
  const owner = gCurrent === null || gCurrent === void 0 ? void 0 : gCurrent.instance;
32
32
  if (owner) {
33
33
  let ex = undefined;
34
- const children = owner.descriptor.children;
34
+ const children = owner.node.children;
35
35
  if (driver.isRow) {
36
36
  const last = children.lastClaimedItem();
37
- if (((_a = last === null || last === void 0 ? void 0 : last.instance) === null || _a === void 0 ? void 0 : _a.descriptor.driver) === driver)
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
40
  ex !== null && ex !== void 0 ? ex : (ex = children.claim(key = key || generateKey(owner), undefined, "nested blocks can be declared inside render function only"));
41
41
  if (ex) {
42
42
  result = ex.instance;
43
- const d = result.descriptor;
44
- if (d.driver !== driver && driver !== undefined)
45
- throw new Error(`changing block driver is not yet supported: "${result.descriptor.driver.name}" -> "${driver === null || driver === void 0 ? void 0 : driver.name}"`);
46
- const exTriggers = d.builder.triggers;
43
+ const node = result.node;
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
47
  if (triggersAreEqual(builder.triggers, exTriggers))
48
48
  builder.triggers = exTriggers;
49
- d.builder = builder;
49
+ node.builder = builder;
50
50
  }
51
51
  else {
52
- result = new XBlock(key || generateKey(owner), driver, owner, builder);
53
- result.descriptor.item = children.add(result);
52
+ result = new BlockImpl(key || generateKey(owner), driver, owner, builder);
53
+ result.node.ties = children.add(result);
54
54
  }
55
55
  }
56
56
  else {
57
- result = new XBlock(key || "", driver, owner, builder);
58
- result.descriptor.item = Collection.createItem(result);
59
- triggerRendering(result.descriptor.item);
57
+ result = new BlockImpl(key || "", driver, owner, builder);
58
+ result.node.ties = Collection.createItem(result);
59
+ triggerRendering(result.node.ties);
60
60
  }
61
61
  return result;
62
62
  }
@@ -65,14 +65,22 @@ export class Verstak {
65
65
  throw new Error("current block is undefined");
66
66
  return gCurrent.instance;
67
67
  }
68
+ static triggerRendering(block, triggers) {
69
+ const b = block;
70
+ const builder = b.node.builder;
71
+ if (!triggersAreEqual(triggers, builder.triggers)) {
72
+ builder.triggers = triggers;
73
+ triggerRendering(b.node.ties);
74
+ }
75
+ }
68
76
  static renderNestedTreesThenDo(action) {
69
77
  runRenderNestedTreesThenDo(undefined, action);
70
78
  }
71
79
  static getDefaultLoggingOptions() {
72
- return XBlock.logging;
80
+ return BlockImpl.logging;
73
81
  }
74
82
  static setDefaultLoggingOptions(logging) {
75
- XBlock.logging = logging;
83
+ BlockImpl.logging = logging;
76
84
  }
77
85
  }
78
86
  Verstak.shortFrameDuration = 16;
@@ -87,57 +95,44 @@ export class BaseDriver {
87
95
  }
88
96
  claim(block) {
89
97
  const b = block;
90
- chainedClaim(b, b.descriptor.builder);
98
+ chainedClaim(b, b.node.builder);
91
99
  }
92
100
  create(block, b) {
93
- chainedCreate(block, block.descriptor.builder);
101
+ chainedCreate(block, block.node.builder);
94
102
  }
95
103
  initialize(block) {
96
104
  var _a;
97
105
  const b = block;
98
106
  (_a = this.preset) === null || _a === void 0 ? void 0 : _a.call(this, b);
99
- chainedInitialize(b, b.descriptor.builder);
107
+ chainedInitialize(b, b.node.builder);
100
108
  }
101
109
  mount(block) {
102
110
  }
103
111
  render(block) {
104
- chainedRender(block, block.descriptor.builder);
112
+ chainedRender(block, block.node.builder);
105
113
  }
106
114
  finalize(block, isLeader) {
107
115
  const b = block;
108
- chainedFinalize(b, b.descriptor.builder);
116
+ chainedFinalize(b, b.node.builder);
109
117
  return isLeader;
110
118
  }
111
- applyKind(block, value) {
112
- }
113
- applyCoords(block, value) {
114
- }
115
- applyWidthGrowth(block, value) {
116
- }
117
- applyMinWidth(block, value) {
118
- }
119
- applyMaxWidth(block, value) {
120
- }
121
- applyHeightGrowth(block, value) {
122
- }
123
- applyMinHeight(block, value) {
124
- }
125
- applyMaxHeight(block, value) {
126
- }
127
- applyContentAlignment(block, value) {
128
- }
129
- applyBlockAlignment(block, value) {
130
- }
131
- applyContentWrapping(block, value) {
132
- }
133
- applyOverlayVisible(block, value) {
134
- }
135
- applyStyle(block, secondary, styleName, enabled) {
136
- }
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) { }
137
132
  }
138
133
  BaseDriver.fragment = new BaseDriver("fragment", false, b => b.kind = BlockKind.Group);
139
134
  function generateKey(owner) {
140
- const n = owner.descriptor.numerator++;
135
+ const n = owner.node.numerator++;
141
136
  const lettered = emitLetters(n);
142
137
  let result;
143
138
  if (Rx.isLogging)
@@ -146,49 +141,49 @@ function generateKey(owner) {
146
141
  result = `·${lettered}`;
147
142
  return result;
148
143
  }
149
- function chainedMode(builder) {
144
+ function chainedMode(bb) {
150
145
  var _a;
151
- return (_a = builder === null || builder === void 0 ? void 0 : builder.modes) !== null && _a !== void 0 ? _a : ((builder === null || builder === void 0 ? void 0 : builder.original) ? chainedMode(builder === null || builder === void 0 ? void 0 : builder.original) : Mode.Default);
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);
152
147
  }
153
- function chainedClaim(block, builder) {
154
- const claim = builder.claim;
155
- const original = builder.original;
148
+ function chainedClaim(block, bb) {
149
+ const claim = bb.claim;
150
+ const base = bb.base;
156
151
  if (claim)
157
- claim(block, original ? () => chainedClaim(block, original) : NOP);
158
- else if (original)
159
- chainedClaim(block, original);
152
+ claim(block, base ? () => chainedClaim(block, base) : NOP);
153
+ else if (base)
154
+ chainedClaim(block, base);
160
155
  }
161
- function chainedCreate(block, builder) {
162
- const create = builder.create;
163
- const original = builder.original;
156
+ function chainedCreate(block, bb) {
157
+ const create = bb.create;
158
+ const base = bb.base;
164
159
  if (create)
165
- create(block, original ? () => chainedCreate(block, original) : NOP);
166
- else if (original)
167
- chainedCreate(block, original);
160
+ create(block, base ? () => chainedCreate(block, base) : NOP);
161
+ else if (base)
162
+ chainedCreate(block, base);
168
163
  }
169
- function chainedInitialize(block, builder) {
170
- const initialize = builder.initialize;
171
- const original = builder.original;
164
+ function chainedInitialize(block, bb) {
165
+ const initialize = bb.initialize;
166
+ const base = bb.base;
172
167
  if (initialize)
173
- initialize(block, original ? () => chainedInitialize(block, original) : NOP);
174
- else if (original)
175
- chainedInitialize(block, original);
168
+ initialize(block, base ? () => chainedInitialize(block, base) : NOP);
169
+ else if (base)
170
+ chainedInitialize(block, base);
176
171
  }
177
- function chainedRender(block, builder) {
178
- const render = builder.render;
179
- const original = builder.original;
172
+ function chainedRender(block, bb) {
173
+ const render = bb.render;
174
+ const base = bb.base;
180
175
  if (render)
181
- render(block, original ? () => chainedRender(block, original) : NOP);
182
- else if (original)
183
- chainedRender(block, original);
176
+ render(block, base ? () => chainedRender(block, base) : NOP);
177
+ else if (base)
178
+ chainedRender(block, base);
184
179
  }
185
- function chainedFinalize(block, builder) {
186
- const finalize = builder.finalize;
187
- const original = builder.original;
180
+ function chainedFinalize(block, bb) {
181
+ const finalize = bb.finalize;
182
+ const base = bb.base;
188
183
  if (finalize)
189
- finalize(block, original ? () => chainedFinalize(block, original) : NOP);
190
- else if (original)
191
- chainedFinalize(block, original);
184
+ finalize(block, base ? () => chainedFinalize(block, base) : NOP);
185
+ else if (base)
186
+ chainedFinalize(block, base);
192
187
  }
193
188
  export class StaticDriver extends BaseDriver {
194
189
  constructor(element, name, isRow, preset) {
@@ -210,18 +205,18 @@ export class CursorCommandDriver extends BaseDriver {
210
205
  super.create(block, b);
211
206
  }
212
207
  }
213
- export class ContextVariable {
208
+ export class SubTreeVariable {
214
209
  constructor(defaultValue) {
215
210
  this.defaultValue = defaultValue;
216
211
  }
217
212
  set value(value) {
218
- XBlock.setContextVariableValue(this, value);
213
+ BlockImpl.setSubTreeVariableValue(this, value);
219
214
  }
220
215
  get value() {
221
- return XBlock.useContextVariableValue(this);
216
+ return BlockImpl.useSubTreeVariableValue(this);
222
217
  }
223
218
  get valueOrUndefined() {
224
- return XBlock.tryUseContextVariable(this);
219
+ return BlockImpl.tryUseSubTreeVariable(this);
225
220
  }
226
221
  }
227
222
  class CursorPosition {
@@ -242,7 +237,7 @@ var CursorFlags;
242
237
  })(CursorFlags || (CursorFlags = {}));
243
238
  const UndefinedBlockCoords = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
244
239
  const InitialCursorPosition = Object.freeze(new CursorPosition({ x: 1, y: 1, runningMaxX: 0, runningMaxY: 0, flags: CursorFlags.None }));
245
- class XBlockCtx extends ObservableObject {
240
+ class BlockCtxImpl extends ObservableObject {
246
241
  constructor(variable, value) {
247
242
  super();
248
243
  this.next = undefined;
@@ -253,12 +248,12 @@ class XBlockCtx extends ObservableObject {
253
248
  __decorate([
254
249
  raw,
255
250
  __metadata("design:type", Object)
256
- ], XBlockCtx.prototype, "next", void 0);
251
+ ], BlockCtxImpl.prototype, "next", void 0);
257
252
  __decorate([
258
253
  raw,
259
- __metadata("design:type", ContextVariable)
260
- ], XBlockCtx.prototype, "variable", void 0);
261
- class XBlockDescriptor {
254
+ __metadata("design:type", SubTreeVariable)
255
+ ], BlockCtxImpl.prototype, "variable", void 0);
256
+ class BlockNodeImpl {
262
257
  constructor(key, driver, builder, self, owner) {
263
258
  this.maxColumnCount = 0;
264
259
  this.maxRowCount = 0;
@@ -266,10 +261,10 @@ class XBlockDescriptor {
266
261
  this.driver = driver;
267
262
  this.builder = builder;
268
263
  if (owner) {
269
- const d = owner.descriptor;
270
- this.level = d.level + 1;
264
+ const node = owner.node;
265
+ this.level = node.level + 1;
271
266
  this.owner = owner;
272
- this.outer = d.context ? owner : d.outer;
267
+ this.outer = node.context ? owner : node.outer;
273
268
  }
274
269
  else {
275
270
  this.level = 1;
@@ -278,7 +273,7 @@ class XBlockDescriptor {
278
273
  }
279
274
  this.host = self;
280
275
  this.children = new Collection(getBlockKey, true);
281
- this.item = undefined;
276
+ this.ties = undefined;
282
277
  this.stamp = 0;
283
278
  this.context = undefined;
284
279
  this.numerator = 0;
@@ -287,9 +282,9 @@ class XBlockDescriptor {
287
282
  this.cursorPosition = undefined;
288
283
  }
289
284
  }
290
- class XBlock {
285
+ class BlockImpl {
291
286
  constructor(key, driver, owner, builder) {
292
- this.descriptor = new XBlockDescriptor(key, driver, builder, this, owner);
287
+ this.node = new BlockNodeImpl(key, driver, builder, this, owner);
293
288
  this.native = undefined;
294
289
  this.model = undefined;
295
290
  this.controller = undefined;
@@ -304,45 +299,51 @@ class XBlock {
304
299
  this._maxHeight = "";
305
300
  this._contentAlignment = Align.Default;
306
301
  this._blockAlignment = Align.Default;
307
- this._contentWrapping = false;
302
+ this._contentWrapping = true;
308
303
  this._overlayVisible = undefined;
309
- this.hasStyles = false;
310
- this.childrenShuffling = false;
304
+ this._hasStyles = false;
311
305
  this.renderingPriority = Priority.Realtime;
312
- XBlock.grandCount++;
313
- if (this.has(Mode.SeparateReaction))
314
- XBlock.disposableCount++;
306
+ this.childrenShuffling = false;
307
+ BlockImpl.grandBlockCount++;
308
+ if (this.isOn(Mode.PinpointRefresh))
309
+ BlockImpl.disposableBlockCount++;
315
310
  }
316
311
  render(_triggers) {
317
- renderNow(this.descriptor.item);
312
+ renderNow(this.node.ties);
313
+ }
314
+ prepareForRender() {
315
+ this._area = undefined;
316
+ this._hasStyles = false;
317
+ }
318
+ isOn(mode) {
319
+ return (chainedMode(this.node.builder) & mode) === mode;
318
320
  }
319
- has(mode) { return (chainedMode(this.descriptor.builder) & mode) === mode; }
320
- get isInitialRendering() { return this.descriptor.stamp === 2; }
321
- get isSequential() { return this.descriptor.children.isStrict; }
322
- set isSequential(value) { this.descriptor.children.isStrict = value; }
321
+ get isInitialRendering() { return this.node.stamp === 2; }
323
322
  get isAuxiliary() { return this.kind > BlockKind.Note; }
324
323
  get isBand() { return this.kind === BlockKind.Band; }
325
324
  get isTable() { return this.kind === BlockKind.Table; }
326
- get isAutoMountEnabled() { return !this.has(Mode.ManualMount) && this.descriptor.host !== this; }
327
- get isMoved() { return this.descriptor.owner.descriptor.children.isMoved(this.descriptor.item); }
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; }
328
329
  get kind() { return this._kind; }
329
330
  set kind(value) {
330
- if (value !== this._kind || this.descriptor.stamp < 2) {
331
- this.descriptor.driver.applyKind(this, value);
331
+ if (value !== this._kind || this.node.stamp < 2) {
332
+ this.node.driver.applyKind(this, value);
332
333
  this._kind = value;
333
334
  }
334
335
  }
335
336
  get area() { return this._area; }
336
337
  set area(value) {
337
338
  var _a, _b;
338
- const d = this.descriptor;
339
- const driver = d.driver;
339
+ const node = this.node;
340
+ const driver = node.driver;
340
341
  if (!driver.isRow) {
341
- const owner = d.owner.descriptor;
342
- const cursorPosition = (_b = (_a = d.item.prev) === null || _a === void 0 ? void 0 : _a.instance.descriptor.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
343
- const newCursorPosition = d.cursorPosition = owner.children.isStrict ? new CursorPosition(cursorPosition) : undefined;
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;
344
345
  const isCursorBlock = driver instanceof CursorCommandDriver;
345
- const coords = areaToCoords(!isCursorBlock, value, owner.maxColumnCount, owner.maxRowCount, cursorPosition, newCursorPosition);
346
+ const coords = getEffectiveBlockCoords(!isCursorBlock, value, owner.maxColumnCount, owner.maxRowCount, cursorPosition, newCursorPosition);
346
347
  if (!equalBlockCoords(coords, this._coords)) {
347
348
  driver.applyCoords(this, coords);
348
349
  this._coords = coords;
@@ -355,79 +356,79 @@ class XBlock {
355
356
  get widthGrowth() { return this._widthGrowth; }
356
357
  set widthGrowth(value) {
357
358
  if (value !== this._widthGrowth) {
358
- this.descriptor.driver.applyWidthGrowth(this, value);
359
+ this.node.driver.applyWidthGrowth(this, value);
359
360
  this._widthGrowth = value;
360
361
  }
361
362
  }
362
363
  get minWidth() { return this._minWidth; }
363
364
  set minWidth(value) {
364
365
  if (value !== this._minWidth) {
365
- this.descriptor.driver.applyMinWidth(this, value);
366
+ this.node.driver.applyMinWidth(this, value);
366
367
  this._minWidth = value;
367
368
  }
368
369
  }
369
370
  get maxWidth() { return this._maxWidth; }
370
371
  set maxWidth(value) {
371
372
  if (value !== this._maxWidth) {
372
- this.descriptor.driver.applyMaxWidth(this, value);
373
+ this.node.driver.applyMaxWidth(this, value);
373
374
  this._maxWidth = value;
374
375
  }
375
376
  }
376
377
  get heightGrowth() { return this._heightGrowth; }
377
378
  set heightGrowth(value) {
378
379
  if (value !== this._heightGrowth) {
379
- this.descriptor.driver.applyHeightGrowth(this, value);
380
+ this.node.driver.applyHeightGrowth(this, value);
380
381
  this._heightGrowth = value;
381
382
  }
382
383
  }
383
384
  get minHeight() { return this._minHeight; }
384
385
  set minHeight(value) {
385
386
  if (value !== this._minHeight) {
386
- this.descriptor.driver.applyMinHeight(this, value);
387
+ this.node.driver.applyMinHeight(this, value);
387
388
  this._minHeight = value;
388
389
  }
389
390
  }
390
391
  get maxHeight() { return this._maxHeight; }
391
392
  set maxHeight(value) {
392
393
  if (value !== this._maxHeight) {
393
- this.descriptor.driver.applyMaxHeight(this, value);
394
+ this.node.driver.applyMaxHeight(this, value);
394
395
  this._maxHeight = value;
395
396
  }
396
397
  }
397
398
  get contentAlignment() { return this._contentAlignment; }
398
399
  set contentAlignment(value) {
399
400
  if (value !== this._contentAlignment) {
400
- this.descriptor.driver.applyContentAlignment(this, value);
401
+ this.node.driver.applyContentAlignment(this, value);
401
402
  this._contentAlignment = value;
402
403
  }
403
404
  }
404
405
  get blockAlignment() { return this._blockAlignment; }
405
406
  set blockAlignment(value) {
406
407
  if (value !== this._blockAlignment) {
407
- this.descriptor.driver.applyBlockAlignment(this, value);
408
+ this.node.driver.applyBlockAlignment(this, value);
408
409
  this._blockAlignment = value;
409
410
  }
410
411
  }
411
412
  get contentWrapping() { return this._contentWrapping; }
412
413
  set contentWrapping(value) {
413
414
  if (value !== this._contentWrapping) {
414
- this.descriptor.driver.applyContentWrapping(this, value);
415
+ this.node.driver.applyContentWrapping(this, value);
415
416
  this._contentWrapping = value;
416
417
  }
417
418
  }
418
419
  get overlayVisible() { return this._overlayVisible; }
419
420
  set overlayVisible(value) {
420
421
  if (value !== this._overlayVisible) {
421
- this.descriptor.driver.applyOverlayVisible(this, value);
422
+ this.node.driver.applyOverlayVisible(this, value);
422
423
  this._overlayVisible = value;
423
424
  }
424
425
  }
425
- style(styleName, enabled) {
426
- this.descriptor.driver.applyStyle(this, this.hasStyles, styleName, enabled);
427
- this.hasStyles = true;
426
+ useStyle(styleName, enabled) {
427
+ this.node.driver.applyStyle(this, this._hasStyles, styleName, enabled);
428
+ this._hasStyles = true;
428
429
  }
429
430
  configureReactronic(options) {
430
- if (this.descriptor.stamp !== 1 || !this.has(Mode.SeparateReaction))
431
+ if (this.node.stamp !== 1 || !this.isOn(Mode.PinpointRefresh))
431
432
  throw new Error("reactronic can be configured only for blocks with separate reaction mode and only inside initialize");
432
433
  return Rx.getController(this.render).configure(options);
433
434
  }
@@ -436,57 +437,57 @@ class XBlock {
436
437
  throw new Error("current block is undefined");
437
438
  return gCurrent;
438
439
  }
439
- static tryUseContextVariable(variable) {
440
+ static tryUseSubTreeVariable(variable) {
440
441
  var _a, _b;
441
- let b = XBlock.curr.instance;
442
- while (((_a = b.descriptor.context) === null || _a === void 0 ? void 0 : _a.variable) !== variable && b.descriptor.owner !== b)
443
- b = b.descriptor.outer;
444
- return (_b = b.descriptor.context) === null || _b === void 0 ? void 0 : _b.value;
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;
445
446
  }
446
- static useContextVariableValue(variable) {
447
+ static useSubTreeVariableValue(variable) {
447
448
  var _a;
448
- const result = (_a = XBlock.tryUseContextVariable(variable)) !== null && _a !== void 0 ? _a : variable.defaultValue;
449
+ const result = (_a = BlockImpl.tryUseSubTreeVariable(variable)) !== null && _a !== void 0 ? _a : variable.defaultValue;
449
450
  if (!result)
450
451
  throw new Error("context doesn't exist");
451
452
  return result;
452
453
  }
453
- static setContextVariableValue(variable, value) {
454
- const b = XBlock.curr.instance;
455
- const d = b.descriptor;
456
- const owner = d.owner;
457
- const hostCtx = nonreactive(() => { var _a; return (_a = owner.descriptor.context) === null || _a === void 0 ? void 0 : _a.value; });
454
+ static setSubTreeVariableValue(variable, value) {
455
+ const b = BlockImpl.curr.instance;
456
+ const node = b.node;
457
+ const owner = node.owner;
458
+ const hostCtx = nonreactive(() => { var _a; return (_a = owner.node.context) === null || _a === void 0 ? void 0 : _a.value; });
458
459
  if (value && value !== hostCtx) {
459
460
  if (hostCtx)
460
- d.outer = owner;
461
+ node.outer = owner;
461
462
  else
462
- d.outer = owner.descriptor.outer;
463
+ node.outer = owner.node.outer;
463
464
  Transaction.run({ separation: true }, () => {
464
- const ctx = d.context;
465
+ const ctx = node.context;
465
466
  if (ctx) {
466
467
  ctx.variable = variable;
467
468
  ctx.value = value;
468
469
  }
469
470
  else
470
- d.context = new XBlockCtx(variable, value);
471
+ node.context = new BlockCtxImpl(variable, value);
471
472
  });
472
473
  }
473
474
  else if (hostCtx)
474
- d.outer = owner;
475
+ node.outer = owner;
475
476
  else
476
- d.outer = owner.descriptor.outer;
477
+ node.outer = owner.node.outer;
477
478
  }
478
479
  rowBreak() {
479
480
  var _a, _b;
480
- const d = this.descriptor;
481
- const cursorPosition = (_b = (_a = d.item.prev) === null || _a === void 0 ? void 0 : _a.instance.descriptor.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
482
- const newCursorPosition = this.descriptor.cursorPosition = new CursorPosition(cursorPosition);
481
+ 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);
483
484
  newCursorPosition.x = 1;
484
485
  newCursorPosition.y = newCursorPosition.runningMaxY + 1;
485
486
  }
486
487
  }
487
- XBlock.grandCount = 0;
488
- XBlock.disposableCount = 0;
489
- XBlock.logging = undefined;
488
+ BlockImpl.grandBlockCount = 0;
489
+ BlockImpl.disposableBlockCount = 0;
490
+ BlockImpl.logging = undefined;
490
491
  __decorate([
491
492
  reactive,
492
493
  options({
@@ -497,12 +498,12 @@ __decorate([
497
498
  __metadata("design:type", Function),
498
499
  __metadata("design:paramtypes", [Object]),
499
500
  __metadata("design:returntype", void 0)
500
- ], XBlock.prototype, "render", null);
501
+ ], BlockImpl.prototype, "render", null);
501
502
  function getBlockKey(block) {
502
- const d = block.descriptor;
503
- return d.stamp >= 0 ? d.key : undefined;
503
+ const node = block.node;
504
+ return node.stamp >= 0 ? node.key : undefined;
504
505
  }
505
- function areaToCoords(isRegularBlock, area, maxX, maxY, cursorPosition, newCursorPosition) {
506
+ function getEffectiveBlockCoords(isRegularBlock, area, maxX, maxY, cursorPosition, newCursorPosition) {
506
507
  var _a, _b;
507
508
  let result;
508
509
  if (typeof (area) === "string") {
@@ -581,9 +582,9 @@ function areaToCoords(isRegularBlock, area, maxX, maxY, cursorPosition, newCurso
581
582
  }
582
583
  function runRenderNestedTreesThenDo(error, action) {
583
584
  var _a;
584
- const curr = XBlock.curr;
585
+ const curr = BlockImpl.curr;
585
586
  const owner = curr.instance;
586
- const children = owner.descriptor.children;
587
+ const children = owner.node.children;
587
588
  if (children.isMergeInProgress) {
588
589
  let promised = undefined;
589
590
  try {
@@ -601,7 +602,7 @@ function runRenderNestedTreesThenDo(error, action) {
601
602
  if (Transaction.isCanceled)
602
603
  break;
603
604
  const block = item.instance;
604
- const isRow = block.descriptor.driver.isRow;
605
+ const isRow = block.node.driver.isRow;
605
606
  const host = isRow ? owner : hostingRow;
606
607
  const p = (_a = block.renderingPriority) !== null && _a !== void 0 ? _a : Priority.Realtime;
607
608
  mounting = markToMountIfNecessary(mounting, host, item, children, sequential);
@@ -624,23 +625,23 @@ function runRenderNestedTreesThenDo(error, action) {
624
625
  }
625
626
  }
626
627
  }
627
- function markToMountIfNecessary(mounting, host, item, children, sequential) {
628
- const b = item.instance;
629
- const d = b.descriptor;
630
- if (b.native && !b.has(Mode.ManualMount)) {
631
- if (mounting || d.host !== host) {
632
- children.markAsMoved(item);
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);
633
634
  mounting = false;
634
635
  }
635
636
  }
636
- else if (sequential && children.isMoved(item))
637
+ else if (sequential && children.isMoved(ties))
637
638
  mounting = true;
638
- d.host = host;
639
+ node.host = host;
639
640
  return mounting;
640
641
  }
641
642
  function startIncrementalRendering(owner, allChildren, priority1, priority2) {
642
643
  return __awaiter(this, void 0, void 0, function* () {
643
- const stamp = owner.instance.descriptor.stamp;
644
+ const stamp = owner.instance.node.stamp;
644
645
  if (priority1)
645
646
  yield renderIncrementally(owner, stamp, allChildren, priority1, Priority.Normal);
646
647
  if (priority2)
@@ -678,31 +679,31 @@ function renderIncrementally(owner, stamp, allChildren, items, priority) {
678
679
  }
679
680
  });
680
681
  }
681
- function triggerRendering(item) {
682
- const b = item.instance;
683
- const d = b.descriptor;
684
- if (d.stamp >= 0) {
685
- if (b.has(Mode.SeparateReaction)) {
686
- if (d.stamp === 0) {
682
+ function triggerRendering(ties) {
683
+ const b = ties.instance;
684
+ const node = b.node;
685
+ if (node.stamp >= 0) {
686
+ if (b.isOn(Mode.PinpointRefresh)) {
687
+ if (node.stamp === 0) {
687
688
  Transaction.outside(() => {
688
689
  if (Rx.isLogging)
689
- Rx.setLoggingHint(b, d.key);
690
+ Rx.setLoggingHint(b, node.key);
690
691
  Rx.getController(b.render).configure({
691
- order: d.level,
692
+ order: node.level,
692
693
  });
693
694
  });
694
695
  }
695
- nonreactive(b.render, d.builder.triggers);
696
+ nonreactive(b.render, node.builder.triggers);
696
697
  }
697
698
  else
698
- renderNow(item);
699
+ renderNow(ties);
699
700
  }
700
701
  }
701
702
  function mountIfNecessary(block) {
702
- const d = block.descriptor;
703
- const driver = d.driver;
704
- if (d.stamp === 0) {
705
- d.stamp = 1;
703
+ const node = block.node;
704
+ const driver = node.driver;
705
+ if (node.stamp === 0) {
706
+ node.stamp = 1;
706
707
  nonreactive(() => {
707
708
  driver.create(block, block);
708
709
  driver.initialize(block);
@@ -713,22 +714,21 @@ function mountIfNecessary(block) {
713
714
  else if (block.isMoved && block.isAutoMountEnabled)
714
715
  nonreactive(() => driver.mount(block));
715
716
  }
716
- function renderNow(item) {
717
- const b = item.instance;
718
- const d = b.descriptor;
719
- if (d.stamp >= 0) {
717
+ function renderNow(ties) {
718
+ const b = ties.instance;
719
+ const node = b.node;
720
+ if (node.stamp >= 0) {
720
721
  let result = undefined;
721
- runInside(item, () => {
722
+ runInside(ties, () => {
722
723
  try {
723
724
  mountIfNecessary(b);
724
- d.stamp++;
725
- d.numerator = 0;
726
- b._area = undefined;
727
- b.hasStyles = false;
728
- d.children.beginMerge();
729
- const driver = d.driver;
725
+ node.stamp++;
726
+ node.numerator = 0;
727
+ b.prepareForRender();
728
+ node.children.beginMerge();
729
+ const driver = node.driver;
730
730
  result = driver.render(b);
731
- if (b._area === undefined && d.owner.isTable)
731
+ if (b.area === undefined && node.owner.isTable)
732
732
  b.area = undefined;
733
733
  if (result instanceof Promise)
734
734
  result.then(v => { runRenderNestedTreesThenDo(undefined, NOP); return v; }, e => { console.log(e); runRenderNestedTreesThenDo(e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
@@ -737,38 +737,38 @@ function renderNow(item) {
737
737
  }
738
738
  catch (e) {
739
739
  runRenderNestedTreesThenDo(e, NOP);
740
- console.log(`Rendering failed: ${d.key}`);
740
+ console.log(`Rendering failed: ${node.key}`);
741
741
  console.log(`${e}`);
742
742
  }
743
743
  });
744
744
  }
745
745
  }
746
- function triggerFinalization(item, isLeader, individual) {
747
- const b = item.instance;
748
- const d = b.descriptor;
749
- if (d.stamp >= 0) {
750
- const driver = d.driver;
751
- if (individual && d.key !== d.builder.key && !driver.isRow)
752
- console.log(`WARNING: it is recommended to assign explicit key for conditionally rendered block in order to avoid unexpected side effects: ${d.key}`);
753
- d.stamp = ~d.stamp;
746
+ function triggerFinalization(ties, isLeader, individual) {
747
+ const b = ties.instance;
748
+ const node = b.node;
749
+ if (node.stamp >= 0) {
750
+ 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 conditionally rendered block in order to avoid unexpected side effects: ${node.key}`);
753
+ node.stamp = ~node.stamp;
754
754
  const childrenAreLeaders = nonreactive(() => driver.finalize(b, isLeader));
755
755
  b.native = null;
756
756
  b.controller = null;
757
- if (b.has(Mode.SeparateReaction)) {
758
- item.aux = undefined;
757
+ if (b.isOn(Mode.PinpointRefresh)) {
758
+ ties.aux = undefined;
759
759
  const last = gLastToDispose;
760
760
  if (last)
761
- gLastToDispose = last.aux = item;
761
+ gLastToDispose = last.aux = ties;
762
762
  else
763
- gFirstToDispose = gLastToDispose = item;
764
- if (gFirstToDispose === item)
765
- Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${item.instance.descriptor.key})` }, () => {
763
+ gFirstToDispose = gLastToDispose = ties;
764
+ if (gFirstToDispose === ties)
765
+ Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${ties.instance.node.key})` }, () => {
766
766
  void runDisposalLoop().then(NOP, error => console.log(error));
767
767
  });
768
768
  }
769
- for (const item of d.children.items())
769
+ for (const item of node.children.items())
770
770
  triggerFinalization(item, childrenAreLeaders, false);
771
- XBlock.grandCount--;
771
+ BlockImpl.grandBlockCount--;
772
772
  }
773
773
  }
774
774
  function runDisposalLoop() {
@@ -780,7 +780,7 @@ function runDisposalLoop() {
780
780
  yield Transaction.requestNextFrame();
781
781
  Rx.dispose(item.instance);
782
782
  item = item.aux;
783
- XBlock.disposableCount--;
783
+ BlockImpl.disposableBlockCount--;
784
784
  }
785
785
  gFirstToDispose = gLastToDispose = undefined;
786
786
  });
@@ -796,10 +796,10 @@ function wrapToRunInside(func) {
796
796
  wrappedToRunInside = func;
797
797
  return wrappedToRunInside;
798
798
  }
799
- function runInside(item, func, ...args) {
799
+ function runInside(ties, func, ...args) {
800
800
  const outer = gCurrent;
801
801
  try {
802
- gCurrent = item;
802
+ gCurrent = ties;
803
803
  return func(...args);
804
804
  }
805
805
  finally {