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.
- package/README.md +38 -17
- package/build/dist/source/core/Interfaces.d.ts +61 -60
- package/build/dist/source/core/Interfaces.js +2 -1
- package/build/dist/source/core/Verstak.d.ts +26 -25
- package/build/dist/source/core/Verstak.js +217 -217
- package/build/dist/source/html/Blocks.d.ts +21 -21
- package/build/dist/source/html/Blocks.js +65 -68
- package/build/dist/source/html/HtmlBlocks.d.ts +175 -175
- package/build/dist/source/html/HtmlBlocks.js +173 -173
- package/build/dist/source/html/HtmlDriver.d.ts +11 -11
- package/build/dist/source/html/HtmlDriver.js +17 -16
- package/build/dist/source/html/ReactingFocuser.js +1 -1
- package/build/dist/source/html/sensors/ResizeSensor.d.ts +2 -2
- package/package.json +1 -1
|
@@ -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,
|
|
23
|
+
static claim(driver, builder, base) {
|
|
24
24
|
var _a;
|
|
25
25
|
let result;
|
|
26
26
|
if (builder)
|
|
27
|
-
builder.
|
|
27
|
+
builder.base = base;
|
|
28
28
|
else
|
|
29
|
-
builder =
|
|
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.
|
|
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.
|
|
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
|
|
44
|
-
if (
|
|
45
|
-
throw new Error(`changing block driver is not yet supported: "${result.
|
|
46
|
-
const exTriggers =
|
|
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
|
-
|
|
49
|
+
node.builder = builder;
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
result = new
|
|
53
|
-
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
|
|
58
|
-
result.
|
|
59
|
-
triggerRendering(result.
|
|
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
|
|
80
|
+
return BlockImpl.logging;
|
|
73
81
|
}
|
|
74
82
|
static setDefaultLoggingOptions(logging) {
|
|
75
|
-
|
|
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.
|
|
98
|
+
chainedClaim(b, b.node.builder);
|
|
91
99
|
}
|
|
92
100
|
create(block, b) {
|
|
93
|
-
chainedCreate(block, block.
|
|
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.
|
|
107
|
+
chainedInitialize(b, b.node.builder);
|
|
100
108
|
}
|
|
101
109
|
mount(block) {
|
|
102
110
|
}
|
|
103
111
|
render(block) {
|
|
104
|
-
chainedRender(block, block.
|
|
112
|
+
chainedRender(block, block.node.builder);
|
|
105
113
|
}
|
|
106
114
|
finalize(block, isLeader) {
|
|
107
115
|
const b = block;
|
|
108
|
-
chainedFinalize(b, b.
|
|
116
|
+
chainedFinalize(b, b.node.builder);
|
|
109
117
|
return isLeader;
|
|
110
118
|
}
|
|
111
|
-
applyKind(block, value) {
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
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.
|
|
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(
|
|
144
|
+
function chainedMode(bb) {
|
|
150
145
|
var _a;
|
|
151
|
-
return (_a =
|
|
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,
|
|
154
|
-
const claim =
|
|
155
|
-
const
|
|
148
|
+
function chainedClaim(block, bb) {
|
|
149
|
+
const claim = bb.claim;
|
|
150
|
+
const base = bb.base;
|
|
156
151
|
if (claim)
|
|
157
|
-
claim(block,
|
|
158
|
-
else if (
|
|
159
|
-
chainedClaim(block,
|
|
152
|
+
claim(block, base ? () => chainedClaim(block, base) : NOP);
|
|
153
|
+
else if (base)
|
|
154
|
+
chainedClaim(block, base);
|
|
160
155
|
}
|
|
161
|
-
function chainedCreate(block,
|
|
162
|
-
const create =
|
|
163
|
-
const
|
|
156
|
+
function chainedCreate(block, bb) {
|
|
157
|
+
const create = bb.create;
|
|
158
|
+
const base = bb.base;
|
|
164
159
|
if (create)
|
|
165
|
-
create(block,
|
|
166
|
-
else if (
|
|
167
|
-
chainedCreate(block,
|
|
160
|
+
create(block, base ? () => chainedCreate(block, base) : NOP);
|
|
161
|
+
else if (base)
|
|
162
|
+
chainedCreate(block, base);
|
|
168
163
|
}
|
|
169
|
-
function chainedInitialize(block,
|
|
170
|
-
const initialize =
|
|
171
|
-
const
|
|
164
|
+
function chainedInitialize(block, bb) {
|
|
165
|
+
const initialize = bb.initialize;
|
|
166
|
+
const base = bb.base;
|
|
172
167
|
if (initialize)
|
|
173
|
-
initialize(block,
|
|
174
|
-
else if (
|
|
175
|
-
chainedInitialize(block,
|
|
168
|
+
initialize(block, base ? () => chainedInitialize(block, base) : NOP);
|
|
169
|
+
else if (base)
|
|
170
|
+
chainedInitialize(block, base);
|
|
176
171
|
}
|
|
177
|
-
function chainedRender(block,
|
|
178
|
-
const render =
|
|
179
|
-
const
|
|
172
|
+
function chainedRender(block, bb) {
|
|
173
|
+
const render = bb.render;
|
|
174
|
+
const base = bb.base;
|
|
180
175
|
if (render)
|
|
181
|
-
render(block,
|
|
182
|
-
else if (
|
|
183
|
-
chainedRender(block,
|
|
176
|
+
render(block, base ? () => chainedRender(block, base) : NOP);
|
|
177
|
+
else if (base)
|
|
178
|
+
chainedRender(block, base);
|
|
184
179
|
}
|
|
185
|
-
function chainedFinalize(block,
|
|
186
|
-
const finalize =
|
|
187
|
-
const
|
|
180
|
+
function chainedFinalize(block, bb) {
|
|
181
|
+
const finalize = bb.finalize;
|
|
182
|
+
const base = bb.base;
|
|
188
183
|
if (finalize)
|
|
189
|
-
finalize(block,
|
|
190
|
-
else if (
|
|
191
|
-
chainedFinalize(block,
|
|
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
|
|
208
|
+
export class SubTreeVariable {
|
|
214
209
|
constructor(defaultValue) {
|
|
215
210
|
this.defaultValue = defaultValue;
|
|
216
211
|
}
|
|
217
212
|
set value(value) {
|
|
218
|
-
|
|
213
|
+
BlockImpl.setSubTreeVariableValue(this, value);
|
|
219
214
|
}
|
|
220
215
|
get value() {
|
|
221
|
-
return
|
|
216
|
+
return BlockImpl.useSubTreeVariableValue(this);
|
|
222
217
|
}
|
|
223
218
|
get valueOrUndefined() {
|
|
224
|
-
return
|
|
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
|
|
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
|
-
],
|
|
251
|
+
], BlockCtxImpl.prototype, "next", void 0);
|
|
257
252
|
__decorate([
|
|
258
253
|
raw,
|
|
259
|
-
__metadata("design:type",
|
|
260
|
-
],
|
|
261
|
-
class
|
|
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
|
|
270
|
-
this.level =
|
|
264
|
+
const node = owner.node;
|
|
265
|
+
this.level = node.level + 1;
|
|
271
266
|
this.owner = owner;
|
|
272
|
-
this.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.
|
|
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
|
|
285
|
+
class BlockImpl {
|
|
291
286
|
constructor(key, driver, owner, builder) {
|
|
292
|
-
this.
|
|
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 =
|
|
302
|
+
this._contentWrapping = true;
|
|
308
303
|
this._overlayVisible = undefined;
|
|
309
|
-
this.
|
|
310
|
-
this.childrenShuffling = false;
|
|
304
|
+
this._hasStyles = false;
|
|
311
305
|
this.renderingPriority = Priority.Realtime;
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
327
|
-
get isMoved() { return this.
|
|
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.
|
|
331
|
-
this.
|
|
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
|
|
339
|
-
const driver =
|
|
339
|
+
const node = this.node;
|
|
340
|
+
const driver = node.driver;
|
|
340
341
|
if (!driver.isRow) {
|
|
341
|
-
const owner =
|
|
342
|
-
const cursorPosition = (_b = (_a =
|
|
343
|
-
const newCursorPosition =
|
|
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 =
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
422
|
+
this.node.driver.applyOverlayVisible(this, value);
|
|
422
423
|
this._overlayVisible = value;
|
|
423
424
|
}
|
|
424
425
|
}
|
|
425
|
-
|
|
426
|
-
this.
|
|
427
|
-
this.
|
|
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.
|
|
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
|
|
440
|
+
static tryUseSubTreeVariable(variable) {
|
|
440
441
|
var _a, _b;
|
|
441
|
-
let b =
|
|
442
|
-
while (((_a = b.
|
|
443
|
-
b = b.
|
|
444
|
-
return (_b = 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;
|
|
445
446
|
}
|
|
446
|
-
static
|
|
447
|
+
static useSubTreeVariableValue(variable) {
|
|
447
448
|
var _a;
|
|
448
|
-
const result = (_a =
|
|
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
|
|
454
|
-
const b =
|
|
455
|
-
const
|
|
456
|
-
const owner =
|
|
457
|
-
const hostCtx = nonreactive(() => { var _a; return (_a = owner.
|
|
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
|
-
|
|
461
|
+
node.outer = owner;
|
|
461
462
|
else
|
|
462
|
-
|
|
463
|
+
node.outer = owner.node.outer;
|
|
463
464
|
Transaction.run({ separation: true }, () => {
|
|
464
|
-
const ctx =
|
|
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
|
-
|
|
471
|
+
node.context = new BlockCtxImpl(variable, value);
|
|
471
472
|
});
|
|
472
473
|
}
|
|
473
474
|
else if (hostCtx)
|
|
474
|
-
|
|
475
|
+
node.outer = owner;
|
|
475
476
|
else
|
|
476
|
-
|
|
477
|
+
node.outer = owner.node.outer;
|
|
477
478
|
}
|
|
478
479
|
rowBreak() {
|
|
479
480
|
var _a, _b;
|
|
480
|
-
const
|
|
481
|
-
const cursorPosition = (_b = (_a =
|
|
482
|
-
const newCursorPosition = this.
|
|
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
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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
|
-
],
|
|
501
|
+
], BlockImpl.prototype, "render", null);
|
|
501
502
|
function getBlockKey(block) {
|
|
502
|
-
const
|
|
503
|
-
return
|
|
503
|
+
const node = block.node;
|
|
504
|
+
return node.stamp >= 0 ? node.key : undefined;
|
|
504
505
|
}
|
|
505
|
-
function
|
|
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 =
|
|
585
|
+
const curr = BlockImpl.curr;
|
|
585
586
|
const owner = curr.instance;
|
|
586
|
-
const children = owner.
|
|
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.
|
|
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,
|
|
628
|
-
const b =
|
|
629
|
-
const
|
|
630
|
-
if (b.native && !b.
|
|
631
|
-
if (mounting ||
|
|
632
|
-
children.markAsMoved(
|
|
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(
|
|
637
|
+
else if (sequential && children.isMoved(ties))
|
|
637
638
|
mounting = true;
|
|
638
|
-
|
|
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.
|
|
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(
|
|
682
|
-
const b =
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
685
|
-
if (b.
|
|
686
|
-
if (
|
|
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,
|
|
690
|
+
Rx.setLoggingHint(b, node.key);
|
|
690
691
|
Rx.getController(b.render).configure({
|
|
691
|
-
order:
|
|
692
|
+
order: node.level,
|
|
692
693
|
});
|
|
693
694
|
});
|
|
694
695
|
}
|
|
695
|
-
nonreactive(b.render,
|
|
696
|
+
nonreactive(b.render, node.builder.triggers);
|
|
696
697
|
}
|
|
697
698
|
else
|
|
698
|
-
renderNow(
|
|
699
|
+
renderNow(ties);
|
|
699
700
|
}
|
|
700
701
|
}
|
|
701
702
|
function mountIfNecessary(block) {
|
|
702
|
-
const
|
|
703
|
-
const driver =
|
|
704
|
-
if (
|
|
705
|
-
|
|
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(
|
|
717
|
-
const b =
|
|
718
|
-
const
|
|
719
|
-
if (
|
|
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(
|
|
722
|
+
runInside(ties, () => {
|
|
722
723
|
try {
|
|
723
724
|
mountIfNecessary(b);
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
b.
|
|
727
|
-
|
|
728
|
-
|
|
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.
|
|
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: ${
|
|
740
|
+
console.log(`Rendering failed: ${node.key}`);
|
|
741
741
|
console.log(`${e}`);
|
|
742
742
|
}
|
|
743
743
|
});
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
|
-
function triggerFinalization(
|
|
747
|
-
const b =
|
|
748
|
-
const
|
|
749
|
-
if (
|
|
750
|
-
const driver =
|
|
751
|
-
if (individual &&
|
|
752
|
-
console.log(`WARNING: it is recommended to assign explicit key for conditionally rendered block in order to avoid unexpected side effects: ${
|
|
753
|
-
|
|
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.
|
|
758
|
-
|
|
757
|
+
if (b.isOn(Mode.PinpointRefresh)) {
|
|
758
|
+
ties.aux = undefined;
|
|
759
759
|
const last = gLastToDispose;
|
|
760
760
|
if (last)
|
|
761
|
-
gLastToDispose = last.aux =
|
|
761
|
+
gLastToDispose = last.aux = ties;
|
|
762
762
|
else
|
|
763
|
-
gFirstToDispose = gLastToDispose =
|
|
764
|
-
if (gFirstToDispose ===
|
|
765
|
-
Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${
|
|
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
|
|
769
|
+
for (const item of node.children.items())
|
|
770
770
|
triggerFinalization(item, childrenAreLeaders, false);
|
|
771
|
-
|
|
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
|
-
|
|
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(
|
|
799
|
+
function runInside(ties, func, ...args) {
|
|
800
800
|
const outer = gCurrent;
|
|
801
801
|
try {
|
|
802
|
-
gCurrent =
|
|
802
|
+
gCurrent = ties;
|
|
803
803
|
return func(...args);
|
|
804
804
|
}
|
|
805
805
|
finally {
|