verstak 0.22.514 → 0.22.516
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/CellRange.d.ts +2 -0
- package/build/dist/source/core/CellRange.js +17 -17
- package/build/dist/source/core/Utils.d.ts +1 -0
- package/build/dist/source/core/Utils.js +32 -0
- package/build/dist/source/core/VBlock.d.ts +9 -7
- package/build/dist/source/core/VBlock.js +51 -37
- package/build/dist/source/html/Blocks.d.ts +7 -7
- package/build/dist/source/html/Blocks.js +21 -24
- package/build/dist/source/html/HtmlBlocks.d.ts +174 -174
- package/build/dist/source/html/HtmlBlocks.js +176 -176
- package/build/dist/source/html/HtmlDriver.js +4 -4
- package/build/dist/source/html/ReactingFocuser.d.ts +1 -1
- package/build/dist/source/html/ReactingFocuser.js +2 -2
- package/package.json +2 -2
|
@@ -6,4 +6,6 @@ export interface CellRange {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function parseCellRange(text: string, result: CellRange): CellRange;
|
|
8
8
|
export declare function emitCellRange(value: CellRange): string;
|
|
9
|
+
export declare function emitLetters(n: number): string;
|
|
10
|
+
export declare function emitCellPosition(x: number, y: number): string;
|
|
9
11
|
export declare function equalCellRanges(a: CellRange, b: CellRange): boolean;
|
|
@@ -134,22 +134,7 @@ export function emitCellRange(value) {
|
|
|
134
134
|
const p2 = emitCellPosition(value.x2, value.y2);
|
|
135
135
|
return `${p1}${p2 !== "" ? `:${p2}` : ""}`;
|
|
136
136
|
}
|
|
137
|
-
export function
|
|
138
|
-
return a.x1 === b.x1 && a.y1 === b.y1 && a.x2 === b.x2 && a.y1 === b.y2;
|
|
139
|
-
}
|
|
140
|
-
function isWhitespace(char) {
|
|
141
|
-
return char === 32 || (char >= 9 && char <= 13) || char === 133 || char === 160;
|
|
142
|
-
}
|
|
143
|
-
function isDigit(input, index) {
|
|
144
|
-
return 48 <= input && input <= 57;
|
|
145
|
-
}
|
|
146
|
-
function isCapitalLetter(ch) {
|
|
147
|
-
return 65 <= ch && ch <= 90;
|
|
148
|
-
}
|
|
149
|
-
function isLowercaseLetter(ch) {
|
|
150
|
-
return 97 <= ch && ch <= 122;
|
|
151
|
-
}
|
|
152
|
-
function emitLetters(n) {
|
|
137
|
+
export function emitLetters(n) {
|
|
153
138
|
if (n < 0)
|
|
154
139
|
throw new Error(`emitLetters: argument (${n}) should not be negative or zero`);
|
|
155
140
|
let result = "";
|
|
@@ -160,7 +145,7 @@ function emitLetters(n) {
|
|
|
160
145
|
}
|
|
161
146
|
return result;
|
|
162
147
|
}
|
|
163
|
-
function emitCellPosition(x, y) {
|
|
148
|
+
export function emitCellPosition(x, y) {
|
|
164
149
|
let result = "";
|
|
165
150
|
if (x > 0 && y > 0)
|
|
166
151
|
result = `${emitLetters(x - 1)}${y}`;
|
|
@@ -174,3 +159,18 @@ function emitCellPosition(x, y) {
|
|
|
174
159
|
result = "";
|
|
175
160
|
return result;
|
|
176
161
|
}
|
|
162
|
+
export function equalCellRanges(a, b) {
|
|
163
|
+
return a.x1 === b.x1 && a.y1 === b.y1 && a.x2 === b.x2 && a.y1 === b.y2;
|
|
164
|
+
}
|
|
165
|
+
function isWhitespace(char) {
|
|
166
|
+
return char === 32 || (char >= 9 && char <= 13) || char === 133 || char === 160;
|
|
167
|
+
}
|
|
168
|
+
function isDigit(input, index) {
|
|
169
|
+
return 48 <= input && input <= 57;
|
|
170
|
+
}
|
|
171
|
+
function isCapitalLetter(ch) {
|
|
172
|
+
return 65 <= ch && ch <= 90;
|
|
173
|
+
}
|
|
174
|
+
function isLowercaseLetter(ch) {
|
|
175
|
+
return 97 <= ch && ch <= 122;
|
|
176
|
+
}
|
|
@@ -1,3 +1,35 @@
|
|
|
1
1
|
export function objectHasMember(obj, member) {
|
|
2
2
|
return obj === Object(obj) && !Array.isArray(obj) && member in obj;
|
|
3
3
|
}
|
|
4
|
+
export function getCallerInfo(prefix) {
|
|
5
|
+
const restore = Error.stackTraceLimit = 20;
|
|
6
|
+
const error = new Error();
|
|
7
|
+
const stack = error.stack || "";
|
|
8
|
+
Error.stackTraceLimit = restore;
|
|
9
|
+
const lines = stack.split("\n");
|
|
10
|
+
let i = lines.findIndex(x => x.indexOf(".claim") >= 0);
|
|
11
|
+
i = i >= 0 ? i + 2 : 5;
|
|
12
|
+
let caller = extractFunctionAndLocation(lines[i]);
|
|
13
|
+
let location = caller;
|
|
14
|
+
if (caller.func === "VerstakDriver.render" || caller.func === "render") {
|
|
15
|
+
i = i - 1;
|
|
16
|
+
caller = extractFunctionAndLocation(lines[i]);
|
|
17
|
+
location = extractFunctionAndLocation(lines[i + 1]);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
while (!caller.func) {
|
|
21
|
+
i = i - 1;
|
|
22
|
+
caller = extractFunctionAndLocation(lines[i]);
|
|
23
|
+
}
|
|
24
|
+
location = extractFunctionAndLocation(lines[i + 1]);
|
|
25
|
+
}
|
|
26
|
+
const result = `${prefix}:${caller.func}@${location.file}`;
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
function extractFunctionAndLocation(s) {
|
|
30
|
+
const match = s.match(/(?:\s*at\s+)?(?:(\S+)\s\()?(?:.*?)([^\/\(\):]+)(?:(:|\d)*\)?)$/);
|
|
31
|
+
return {
|
|
32
|
+
func: (match === null || match === void 0 ? void 0 : match[1]) || "",
|
|
33
|
+
file: (match === null || match === void 0 ? void 0 : match[2]) || "",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -12,6 +12,7 @@ export declare const enum Priority {
|
|
|
12
12
|
export declare type Type<T> = new (...args: any[]) => T;
|
|
13
13
|
export declare type BlockBody<T = unknown, M = unknown, R = void> = Render<T, M, R> | BlockVmt<T, M, R>;
|
|
14
14
|
export interface BlockVmt<T = unknown, M = unknown, R = void> {
|
|
15
|
+
key?: string;
|
|
15
16
|
reacting?: boolean;
|
|
16
17
|
triggers?: unknown;
|
|
17
18
|
initialize?: Render<T, M, R>;
|
|
@@ -19,15 +20,15 @@ export interface BlockVmt<T = unknown, M = unknown, R = void> {
|
|
|
19
20
|
render?: Render<T, M, R>;
|
|
20
21
|
finalize?: Render<T, M, R>;
|
|
21
22
|
}
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
23
|
+
export declare function asBaseFor<T, M, R>(outer: BlockBody<T, M, R> | undefined, base: BlockBody<T, M, R>): BlockVmt<T, M, R>;
|
|
24
|
+
export declare function nestedContext<T extends Object>(type: Type<T>, context: T): void;
|
|
25
|
+
export declare function useContext<T extends Object>(type: Type<T>): T;
|
|
25
26
|
export declare abstract class VBlock<T = unknown, M = unknown, R = void> {
|
|
26
27
|
static readonly shortFrameDuration = 16;
|
|
27
28
|
static readonly longFrameDuration = 300;
|
|
28
29
|
static currentRenderingPriority: Priority;
|
|
29
30
|
static frameDuration: number;
|
|
30
|
-
abstract readonly
|
|
31
|
+
abstract readonly key: string;
|
|
31
32
|
abstract readonly driver: AbstractDriver<T>;
|
|
32
33
|
abstract readonly body: Readonly<BlockVmt<T, M, R>>;
|
|
33
34
|
abstract model: M;
|
|
@@ -56,14 +57,15 @@ export declare abstract class VBlock<T = unknown, M = unknown, R = void> {
|
|
|
56
57
|
static get current(): VBlock;
|
|
57
58
|
static renderNestedTreesThenDo(action: (error: unknown) => void): void;
|
|
58
59
|
static runForAllBlocks<T>(action: (e: T) => void): void;
|
|
59
|
-
static claim<T = undefined, M = unknown, R = void>(
|
|
60
|
+
static claim<T = undefined, M = unknown, R = void>(driver: AbstractDriver<T> | undefined, body: BlockBody<T, M, R>): VBlock<T, M, R>;
|
|
61
|
+
private static generateKey;
|
|
60
62
|
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
61
63
|
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
62
64
|
}
|
|
63
65
|
export declare enum LayoutKind {
|
|
64
66
|
Block = 0,
|
|
65
67
|
Grid = 1,
|
|
66
|
-
|
|
68
|
+
Line = 2,
|
|
67
69
|
Group = 3,
|
|
68
70
|
Text = 4
|
|
69
71
|
}
|
|
@@ -76,7 +78,7 @@ export declare class AbstractDriver<T> {
|
|
|
76
78
|
get isAuxiliary(): boolean;
|
|
77
79
|
get isBlock(): boolean;
|
|
78
80
|
get isGrid(): boolean;
|
|
79
|
-
get
|
|
81
|
+
get isLine(): boolean;
|
|
80
82
|
constructor(name: string, layout: LayoutKind, createCursor?: () => Cursor);
|
|
81
83
|
initialize(block: VBlock<T>, native: T): void;
|
|
82
84
|
finalize(block: VBlock<T>, isLeader: boolean): boolean;
|
|
@@ -17,7 +17,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
import { reactive, nonreactive, Transaction, options, Reentrance, Rx, Collection, ObservableObject, raw } from "reactronic";
|
|
20
|
-
import {
|
|
20
|
+
import { getCallerInfo } from "./Utils";
|
|
21
|
+
import { emitLetters, equalCellRanges } from "./CellRange";
|
|
21
22
|
import { Cursor, Align } from "./Cursor";
|
|
22
23
|
export var Priority;
|
|
23
24
|
(function (Priority) {
|
|
@@ -25,7 +26,7 @@ export var Priority;
|
|
|
25
26
|
Priority[Priority["AsyncP1"] = 1] = "AsyncP1";
|
|
26
27
|
Priority[Priority["AsyncP2"] = 2] = "AsyncP2";
|
|
27
28
|
})(Priority || (Priority = {}));
|
|
28
|
-
export function
|
|
29
|
+
export function asBaseFor(outer, base) {
|
|
29
30
|
if (outer instanceof Function)
|
|
30
31
|
outer = { render: outer };
|
|
31
32
|
if (base instanceof Function)
|
|
@@ -37,10 +38,10 @@ function via(outer, base) {
|
|
|
37
38
|
const inherited = base !== null && base !== void 0 ? base : NOP;
|
|
38
39
|
return outer ? b => outer(b, () => inherited(b)) : inherited;
|
|
39
40
|
}
|
|
40
|
-
export function
|
|
41
|
-
return VBlockImpl.
|
|
41
|
+
export function nestedContext(type, context) {
|
|
42
|
+
return VBlockImpl.setContext(type, context);
|
|
42
43
|
}
|
|
43
|
-
export function
|
|
44
|
+
export function useContext(type) {
|
|
44
45
|
return VBlockImpl.use(type);
|
|
45
46
|
}
|
|
46
47
|
export class VBlock {
|
|
@@ -60,22 +61,22 @@ export class VBlock {
|
|
|
60
61
|
static runForAllBlocks(action) {
|
|
61
62
|
forEachChildRecursively(gSysRoot, action);
|
|
62
63
|
}
|
|
63
|
-
static claim(
|
|
64
|
+
static claim(driver, body) {
|
|
64
65
|
var _a, _b;
|
|
65
|
-
if (body instanceof Function)
|
|
66
|
-
body = { render: body };
|
|
67
66
|
let result;
|
|
68
67
|
const owner = gCurrent.instance;
|
|
69
68
|
const children = owner.children;
|
|
70
69
|
let ex = undefined;
|
|
71
70
|
driver !== null && driver !== void 0 ? driver : (driver = AbstractDriver.group);
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if (body instanceof Function)
|
|
72
|
+
body = { render: body };
|
|
73
|
+
let key = body.key;
|
|
74
|
+
if (driver.isLine) {
|
|
74
75
|
const last = children.lastClaimedItem();
|
|
75
76
|
if (((_a = last === null || last === void 0 ? void 0 : last.instance) === null || _a === void 0 ? void 0 : _a.driver) === driver)
|
|
76
77
|
ex = last;
|
|
77
78
|
}
|
|
78
|
-
ex !== null && ex !== void 0 ? ex : (ex = children.claim(
|
|
79
|
+
ex !== null && ex !== void 0 ? ex : (ex = children.claim(key = key || VBlock.generateKey(owner), undefined, "nested blocks can be declared inside render function only"));
|
|
79
80
|
if (ex) {
|
|
80
81
|
result = ex.instance;
|
|
81
82
|
if (result.driver !== driver && driver !== undefined)
|
|
@@ -86,7 +87,7 @@ export class VBlock {
|
|
|
86
87
|
result.body = body;
|
|
87
88
|
}
|
|
88
89
|
else {
|
|
89
|
-
result = new VBlockImpl(
|
|
90
|
+
result = new VBlockImpl(key || VBlock.generateKey(owner), driver, owner, body);
|
|
90
91
|
result.item = children.add(result);
|
|
91
92
|
VBlockImpl.grandCount++;
|
|
92
93
|
if (body.reacting)
|
|
@@ -94,6 +95,16 @@ export class VBlock {
|
|
|
94
95
|
}
|
|
95
96
|
return result;
|
|
96
97
|
}
|
|
98
|
+
static generateKey(owner) {
|
|
99
|
+
const n = owner.numerator++;
|
|
100
|
+
const lettered = emitLetters(n);
|
|
101
|
+
let result;
|
|
102
|
+
if (Rx.isLogging)
|
|
103
|
+
result = `[${getCallerInfo(lettered)}]`;
|
|
104
|
+
else
|
|
105
|
+
result = `[${lettered}]`;
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
97
108
|
static getDefaultLoggingOptions() {
|
|
98
109
|
return VBlockImpl.logging;
|
|
99
110
|
}
|
|
@@ -109,7 +120,7 @@ export var LayoutKind;
|
|
|
109
120
|
(function (LayoutKind) {
|
|
110
121
|
LayoutKind[LayoutKind["Block"] = 0] = "Block";
|
|
111
122
|
LayoutKind[LayoutKind["Grid"] = 1] = "Grid";
|
|
112
|
-
LayoutKind[LayoutKind["
|
|
123
|
+
LayoutKind[LayoutKind["Line"] = 2] = "Line";
|
|
113
124
|
LayoutKind[LayoutKind["Group"] = 3] = "Group";
|
|
114
125
|
LayoutKind[LayoutKind["Text"] = 4] = "Text";
|
|
115
126
|
})(LayoutKind || (LayoutKind = {}));
|
|
@@ -124,7 +135,7 @@ export class AbstractDriver {
|
|
|
124
135
|
get isAuxiliary() { return (this.layout & 2) === 2; }
|
|
125
136
|
get isBlock() { return this.layout === LayoutKind.Block; }
|
|
126
137
|
get isGrid() { return this.layout === LayoutKind.Grid; }
|
|
127
|
-
get
|
|
138
|
+
get isLine() { return this.layout === LayoutKind.Line; }
|
|
128
139
|
initialize(block, native) {
|
|
129
140
|
var _a, _b;
|
|
130
141
|
const b = block;
|
|
@@ -188,8 +199,8 @@ export class StaticDriver extends AbstractDriver {
|
|
|
188
199
|
super.initialize(block, this.element);
|
|
189
200
|
}
|
|
190
201
|
}
|
|
191
|
-
function
|
|
192
|
-
return block.stamp >= 0 ? block.
|
|
202
|
+
function getBlockKey(block) {
|
|
203
|
+
return block.stamp >= 0 ? block.key : undefined;
|
|
193
204
|
}
|
|
194
205
|
class VBlockContext extends ObservableObject {
|
|
195
206
|
constructor(type, instance) {
|
|
@@ -203,9 +214,9 @@ __decorate([
|
|
|
203
214
|
__metadata("design:type", Object)
|
|
204
215
|
], VBlockContext.prototype, "type", void 0);
|
|
205
216
|
class VBlockImpl extends VBlock {
|
|
206
|
-
constructor(
|
|
217
|
+
constructor(key, driver, owner, body) {
|
|
207
218
|
super();
|
|
208
|
-
this.
|
|
219
|
+
this.key = key;
|
|
209
220
|
this.driver = driver;
|
|
210
221
|
this.body = body;
|
|
211
222
|
this.model = undefined;
|
|
@@ -225,7 +236,7 @@ class VBlockImpl extends VBlock {
|
|
|
225
236
|
this.renderingPriority = Priority.SyncP0;
|
|
226
237
|
this.level = owner.level + 1;
|
|
227
238
|
this.host = owner;
|
|
228
|
-
this.children = new Collection(driver.isSequential,
|
|
239
|
+
this.children = new Collection(driver.isSequential, getBlockKey);
|
|
229
240
|
this.numerator = 0;
|
|
230
241
|
this.item = undefined;
|
|
231
242
|
this.stamp = 0;
|
|
@@ -278,16 +289,16 @@ class VBlockImpl extends VBlock {
|
|
|
278
289
|
}
|
|
279
290
|
get minHeight() { return this.appliedMinHeight; }
|
|
280
291
|
set minHeight(value) {
|
|
281
|
-
if (value !== this.
|
|
282
|
-
this.driver.
|
|
283
|
-
this.
|
|
292
|
+
if (value !== this.appliedMinHeight) {
|
|
293
|
+
this.driver.applyMinHeight(this, value);
|
|
294
|
+
this.appliedMinHeight = value;
|
|
284
295
|
}
|
|
285
296
|
}
|
|
286
297
|
get maxHeight() { return this.appliedMaxHeight; }
|
|
287
298
|
set maxHeight(value) {
|
|
288
|
-
if (value !== this.
|
|
289
|
-
this.driver.
|
|
290
|
-
this.
|
|
299
|
+
if (value !== this.appliedMaxHeight) {
|
|
300
|
+
this.driver.applyMaxHeight(this, value);
|
|
301
|
+
this.appliedMaxHeight = value;
|
|
291
302
|
}
|
|
292
303
|
}
|
|
293
304
|
get contentAlignment() { return this.appliedContentAlignment; }
|
|
@@ -332,7 +343,7 @@ class VBlockImpl extends VBlock {
|
|
|
332
343
|
throw new Error(`${type.name} context doesn't exist`);
|
|
333
344
|
return (_b = b.context) === null || _b === void 0 ? void 0 : _b.instance;
|
|
334
345
|
}
|
|
335
|
-
static
|
|
346
|
+
static setContext(type, context) {
|
|
336
347
|
const block = gCurrent.instance;
|
|
337
348
|
const host = block.host;
|
|
338
349
|
const hostCtx = nonreactive(() => { var _a; return (_a = host.context) === null || _a === void 0 ? void 0 : _a.instance; });
|
|
@@ -380,8 +391,9 @@ function runRenderNestedTreesThenDo(error, action) {
|
|
|
380
391
|
let promised = undefined;
|
|
381
392
|
try {
|
|
382
393
|
children.endMerge(error);
|
|
383
|
-
for (const item of children.removedItems(true))
|
|
384
|
-
runFinalize(item, true);
|
|
394
|
+
for (const item of children.removedItems(true)) {
|
|
395
|
+
runFinalize(item, true, true);
|
|
396
|
+
}
|
|
385
397
|
if (!error) {
|
|
386
398
|
const ownerIsBlock = owner.driver.isBlock;
|
|
387
399
|
const sequential = children.strict;
|
|
@@ -396,7 +408,7 @@ function runRenderNestedTreesThenDo(error, action) {
|
|
|
396
408
|
break;
|
|
397
409
|
const block = item.instance;
|
|
398
410
|
const driver = block.driver;
|
|
399
|
-
const host = driver.
|
|
411
|
+
const host = driver.isLine ? owner : partHost;
|
|
400
412
|
const p = (_a = block.renderingPriority) !== null && _a !== void 0 ? _a : Priority.SyncP0;
|
|
401
413
|
redeploy = markToRedeployIfNecessary(redeploy, host, item, children, sequential);
|
|
402
414
|
if (p === Priority.SyncP0)
|
|
@@ -405,7 +417,7 @@ function runRenderNestedTreesThenDo(error, action) {
|
|
|
405
417
|
p1 = push(item, p1);
|
|
406
418
|
else
|
|
407
419
|
p2 = push(item, p2);
|
|
408
|
-
if (ownerIsBlock && driver.
|
|
420
|
+
if (ownerIsBlock && driver.isLine)
|
|
409
421
|
partHost = block;
|
|
410
422
|
}
|
|
411
423
|
if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
|
|
@@ -493,7 +505,7 @@ function prepareRender(item, redeploy, sequential) {
|
|
|
493
505
|
if ((_a = block.body) === null || _a === void 0 ? void 0 : _a.reacting) {
|
|
494
506
|
Transaction.outside(() => {
|
|
495
507
|
if (Rx.isLogging)
|
|
496
|
-
Rx.setLoggingHint(block, block.
|
|
508
|
+
Rx.setLoggingHint(block, block.key);
|
|
497
509
|
Rx.getController(block.rerender).configure({
|
|
498
510
|
order: block.level,
|
|
499
511
|
});
|
|
@@ -519,7 +531,7 @@ function runRender(item) {
|
|
|
519
531
|
block.assignedCells = undefined;
|
|
520
532
|
block.children.beginMerge();
|
|
521
533
|
result = block.driver.render(block);
|
|
522
|
-
if (block.driver.
|
|
534
|
+
if (block.driver.isLine)
|
|
523
535
|
block.host.cursor.lineFeed();
|
|
524
536
|
else if (block.assignedCells === undefined)
|
|
525
537
|
block.cells = undefined;
|
|
@@ -530,16 +542,18 @@ function runRender(item) {
|
|
|
530
542
|
}
|
|
531
543
|
catch (e) {
|
|
532
544
|
runRenderNestedTreesThenDo(e, NOP);
|
|
533
|
-
console.log(`Rendering failed: ${block.
|
|
545
|
+
console.log(`Rendering failed: ${block.key}`);
|
|
534
546
|
console.log(`${e}`);
|
|
535
547
|
}
|
|
536
548
|
});
|
|
537
549
|
}
|
|
538
550
|
}
|
|
539
|
-
function runFinalize(item, isLeader) {
|
|
551
|
+
function runFinalize(item, isLeader, individual) {
|
|
540
552
|
var _a;
|
|
541
553
|
const block = item.instance;
|
|
542
554
|
if (block.stamp >= 0) {
|
|
555
|
+
if (individual && block.key !== block.body.key && !block.driver.isLine)
|
|
556
|
+
console.log(`WARNING: it is recommended to assign explicit key for conditionally rendered block in order to avoid unexpected side effects: ${block.key}`);
|
|
543
557
|
block.stamp = ~block.stamp;
|
|
544
558
|
const childrenAreLeaders = block.driver.finalize(block, isLeader);
|
|
545
559
|
if ((_a = block.body) === null || _a === void 0 ? void 0 : _a.reacting) {
|
|
@@ -550,12 +564,12 @@ function runFinalize(item, isLeader) {
|
|
|
550
564
|
else
|
|
551
565
|
gFirstToDispose = gLastToDispose = item;
|
|
552
566
|
if (gFirstToDispose === item)
|
|
553
|
-
Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${item.instance.
|
|
567
|
+
Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${item.instance.key})` }, () => {
|
|
554
568
|
void runDisposalLoop().then(NOP, error => console.log(error));
|
|
555
569
|
});
|
|
556
570
|
}
|
|
557
571
|
for (const item of block.children.items())
|
|
558
|
-
runFinalize(item, childrenAreLeaders);
|
|
572
|
+
runFinalize(item, childrenAreLeaders, false);
|
|
559
573
|
VBlockImpl.grandCount--;
|
|
560
574
|
}
|
|
561
575
|
}
|
|
@@ -648,7 +662,7 @@ function defaultReject(error) {
|
|
|
648
662
|
Promise.prototype.then = reactronicDomHookedThen;
|
|
649
663
|
const NOP = (...args) => { };
|
|
650
664
|
const gSysDriver = new StaticDriver(null, "SYSTEM", LayoutKind.Group);
|
|
651
|
-
const gSysRoot = Collection.createItem(new VBlockImpl(
|
|
665
|
+
const gSysRoot = Collection.createItem(new VBlockImpl(gSysDriver.name, gSysDriver, { level: 0 }, { reacting: true, render: NOP }));
|
|
652
666
|
gSysRoot.instance.item = gSysRoot;
|
|
653
667
|
Object.defineProperty(gSysRoot.instance, "host", {
|
|
654
668
|
value: gSysRoot.instance,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { VBlock, BlockBody, Align, CellRange } from "../core/api";
|
|
2
2
|
import { HtmlDriver } from "./HtmlDriver";
|
|
3
|
-
export declare function Block<M = unknown, R = void>(
|
|
4
|
-
export declare function PlainText(content: string,
|
|
5
|
-
export declare function HtmlText(content: string,
|
|
6
|
-
export declare function Grid<M = unknown, R = void>(
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function lineFeed(
|
|
9
|
-
export declare function Group<M = unknown, R = void>(
|
|
3
|
+
export declare function Block<M = unknown, R = void>(body: BlockBody<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
4
|
+
export declare function PlainText(content: string, body?: BlockBody<HTMLElement, void, void>): VBlock<HTMLElement, void, void>;
|
|
5
|
+
export declare function HtmlText(content: string, body?: BlockBody<HTMLElement, void, void>): VBlock<HTMLElement, void, void>;
|
|
6
|
+
export declare function Grid<M = unknown, R = void>(body: BlockBody<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
7
|
+
export declare function line<T = void>(body: (block: void) => T): void;
|
|
8
|
+
export declare function lineFeed(noCoalescing?: boolean, key?: string): VBlock<HTMLElement>;
|
|
9
|
+
export declare function Group<M = unknown, R = void>(body: BlockBody<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
10
10
|
export declare class VerstakDriver<T extends HTMLElement> extends HtmlDriver<T> {
|
|
11
11
|
applyCellRange(block: VBlock<T>, cellRange: CellRange | undefined): void;
|
|
12
12
|
applyWidthGrowth(block: VBlock<T>, widthGrowth: number): void;
|
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
import { VBlock, LayoutKind, Align, GridCursor,
|
|
1
|
+
import { VBlock, LayoutKind, Align, GridCursor, asBaseFor } from "../core/api";
|
|
2
2
|
import { HtmlDriver } from "./HtmlDriver";
|
|
3
|
-
export function Block(
|
|
4
|
-
return VBlock.claim(
|
|
3
|
+
export function Block(body) {
|
|
4
|
+
return VBlock.claim(VerstakTags.block, body);
|
|
5
5
|
}
|
|
6
|
-
export function PlainText(content,
|
|
7
|
-
return VBlock.claim(
|
|
6
|
+
export function PlainText(content, body) {
|
|
7
|
+
return VBlock.claim(VerstakTags.text, asBaseFor(body, {
|
|
8
8
|
render(b) {
|
|
9
9
|
b.native.innerText = content;
|
|
10
10
|
},
|
|
11
11
|
}));
|
|
12
12
|
}
|
|
13
|
-
export function HtmlText(content,
|
|
14
|
-
return VBlock.claim(
|
|
13
|
+
export function HtmlText(content, body) {
|
|
14
|
+
return VBlock.claim(VerstakTags.text, asBaseFor(body, {
|
|
15
15
|
render(b) {
|
|
16
16
|
b.native.innerHTML = content;
|
|
17
17
|
},
|
|
18
18
|
}));
|
|
19
19
|
}
|
|
20
|
-
export function Grid(
|
|
21
|
-
return VBlock.claim(
|
|
20
|
+
export function Grid(body) {
|
|
21
|
+
return VBlock.claim(VerstakTags.grid, body);
|
|
22
22
|
}
|
|
23
|
-
export function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
VBlock.claim("", VerstakTags.row, EMPTY_BLOCK_BODY);
|
|
27
|
-
return result;
|
|
23
|
+
export function line(body) {
|
|
24
|
+
lineFeed();
|
|
25
|
+
body();
|
|
28
26
|
}
|
|
29
|
-
export function lineFeed(
|
|
30
|
-
return VBlock.claim(
|
|
27
|
+
export function lineFeed(noCoalescing, key) {
|
|
28
|
+
return VBlock.claim(VerstakTags.line, { key });
|
|
31
29
|
}
|
|
32
|
-
export function Group(
|
|
33
|
-
return VBlock.claim(
|
|
30
|
+
export function Group(body) {
|
|
31
|
+
return VBlock.claim(VerstakTags.group, body);
|
|
34
32
|
}
|
|
35
33
|
export class VerstakDriver extends HtmlDriver {
|
|
36
34
|
applyCellRange(block, cellRange) {
|
|
@@ -64,14 +62,14 @@ export class VerstakDriver extends HtmlDriver {
|
|
|
64
62
|
block.native.style.maxWidth = `${maxWidth}`;
|
|
65
63
|
}
|
|
66
64
|
applyHeightGrowth(block, heightGrowth) {
|
|
67
|
-
if (block.driver.
|
|
65
|
+
if (block.driver.isLine) {
|
|
68
66
|
const css = block.native.style;
|
|
69
67
|
if (heightGrowth > 0)
|
|
70
68
|
css.flexGrow = `${heightGrowth}`;
|
|
71
69
|
else
|
|
72
70
|
css.flexGrow = "";
|
|
73
71
|
}
|
|
74
|
-
else if (block.host.driver.
|
|
72
|
+
else if (block.host.driver.isLine) {
|
|
75
73
|
block.driver.applyFrameAlignment(block, Align.Stretch);
|
|
76
74
|
block.host.driver.applyHeightGrowth(block.host, heightGrowth);
|
|
77
75
|
}
|
|
@@ -119,8 +117,8 @@ export class VerstakDriver extends HtmlDriver {
|
|
|
119
117
|
block.native.removeAttribute("floating");
|
|
120
118
|
}
|
|
121
119
|
render(block) {
|
|
122
|
-
if (block.driver.layout < LayoutKind.
|
|
123
|
-
|
|
120
|
+
if (block.driver.layout < LayoutKind.Line)
|
|
121
|
+
lineFeed();
|
|
124
122
|
return super.render(block);
|
|
125
123
|
}
|
|
126
124
|
}
|
|
@@ -128,9 +126,8 @@ const VerstakTags = {
|
|
|
128
126
|
block: new VerstakDriver("v-block", LayoutKind.Block),
|
|
129
127
|
text: new VerstakDriver("v-text", LayoutKind.Text),
|
|
130
128
|
grid: new VerstakDriver("v-grid", LayoutKind.Grid, () => new GridCursor()),
|
|
131
|
-
|
|
129
|
+
line: new VerstakDriver("v-line", LayoutKind.Line),
|
|
132
130
|
group: new VerstakDriver("v-group", LayoutKind.Group),
|
|
133
131
|
};
|
|
134
|
-
const EMPTY_BLOCK_BODY = { render() { } };
|
|
135
132
|
const AlignToCss = ["stretch", "start", "center", "end"];
|
|
136
133
|
const TextAlignCss = ["justify", "left", "center", "right"];
|