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