verstak 0.23.100 → 0.23.101
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.
|
@@ -2,28 +2,22 @@ import { LoggingOptions, Item, CollectionReader, MemberOptions } from "reactroni
|
|
|
2
2
|
import { CellRange } from "./CellRange";
|
|
3
3
|
import { Cursor, Align, Cells } from "./Cursor";
|
|
4
4
|
export type Callback<T = unknown> = (native: T) => void;
|
|
5
|
-
export type Operation<T = unknown, M = unknown, R = void> = (block: VBlock<T, M, R
|
|
6
|
-
export type VirtualOperation<T = unknown, M = unknown, R = void> = (block: VBlock<T, M, R>, base: () => R) => R;
|
|
5
|
+
export type Operation<T = unknown, M = unknown, R = void> = (block: VBlock<T, M, R>, base: () => R) => R;
|
|
7
6
|
export type AsyncOperation<T = unknown, M = unknown> = (block: VBlock<T, M, Promise<void>>) => Promise<void>;
|
|
8
|
-
export type BlockBody<T = unknown, M = unknown, R = void> = Operation<T, M, R> | BlockVmt<T, M, R>;
|
|
9
7
|
export declare const enum Priority {
|
|
10
8
|
Realtime = 0,
|
|
11
9
|
Normal = 1,
|
|
12
10
|
Background = 2
|
|
13
11
|
}
|
|
14
|
-
export interface
|
|
15
|
-
base?:
|
|
12
|
+
export interface BlockBody<T = unknown, M = unknown, R = void> {
|
|
13
|
+
base?: BlockBody<T, M, R>;
|
|
16
14
|
key?: string;
|
|
17
|
-
|
|
15
|
+
reaction?: boolean;
|
|
18
16
|
triggers?: unknown;
|
|
19
17
|
initialize?: Operation<T, M, R>;
|
|
20
18
|
render?: Operation<T, M, R>;
|
|
21
19
|
finalize?: Operation<T, M, R>;
|
|
22
|
-
redefinedInitialize?: VirtualOperation<T, M, R>;
|
|
23
|
-
redefinedRender?: VirtualOperation<T, M, R>;
|
|
24
|
-
redefinedFinalize?: VirtualOperation<T, M, R>;
|
|
25
20
|
}
|
|
26
|
-
export declare function vmt<T, M, R>(body: BlockBody<T, M, R> | undefined): BlockVmt<T, M, R> | undefined;
|
|
27
21
|
export declare abstract class VBlock<T = unknown, M = unknown, R = void> {
|
|
28
22
|
static readonly shortFrameDuration = 16;
|
|
29
23
|
static readonly longFrameDuration = 300;
|
|
@@ -31,7 +25,7 @@ export declare abstract class VBlock<T = unknown, M = unknown, R = void> {
|
|
|
31
25
|
static frameDuration: number;
|
|
32
26
|
abstract readonly key: string;
|
|
33
27
|
abstract readonly driver: AbstractDriver<T>;
|
|
34
|
-
abstract readonly body: Readonly<
|
|
28
|
+
abstract readonly body: Readonly<BlockBody<T, M, R>>;
|
|
35
29
|
abstract model: M;
|
|
36
30
|
abstract cells: Cells;
|
|
37
31
|
abstract widthGrowth: number;
|
|
@@ -59,7 +53,7 @@ export declare abstract class VBlock<T = unknown, M = unknown, R = void> {
|
|
|
59
53
|
static get current(): VBlock;
|
|
60
54
|
static renderNestedTreesThenDo(action: (error: unknown) => void): void;
|
|
61
55
|
static runForAllBlocks<T>(action: (e: T) => void): void;
|
|
62
|
-
static claim<T = undefined, M = unknown, R = void>(driver: AbstractDriver<T> | undefined, body
|
|
56
|
+
static claim<T = undefined, M = unknown, R = void>(driver: AbstractDriver<T> | undefined, body?: BlockBody<T, M, R>, base?: BlockBody<T, M, R>): VBlock<T, M, R>;
|
|
63
57
|
private static generateKey;
|
|
64
58
|
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
65
59
|
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
@@ -68,7 +62,7 @@ export declare enum LayoutKind {
|
|
|
68
62
|
Block = 0,
|
|
69
63
|
Grid = 1,
|
|
70
64
|
Line = 2,
|
|
71
|
-
|
|
65
|
+
Fragment = 3,
|
|
72
66
|
Text = 4
|
|
73
67
|
}
|
|
74
68
|
export declare class AbstractDriver<T> {
|
|
@@ -26,11 +26,6 @@ export var Priority;
|
|
|
26
26
|
Priority[Priority["Normal"] = 1] = "Normal";
|
|
27
27
|
Priority[Priority["Background"] = 2] = "Background";
|
|
28
28
|
})(Priority || (Priority = {}));
|
|
29
|
-
export function vmt(body) {
|
|
30
|
-
if (body instanceof Function)
|
|
31
|
-
body = { render: body };
|
|
32
|
-
return body;
|
|
33
|
-
}
|
|
34
29
|
export class VBlock {
|
|
35
30
|
get isInitialRendering() {
|
|
36
31
|
return this.stamp === 2;
|
|
@@ -48,15 +43,17 @@ export class VBlock {
|
|
|
48
43
|
static runForAllBlocks(action) {
|
|
49
44
|
forEachChildRecursively(gSysRoot, action);
|
|
50
45
|
}
|
|
51
|
-
static claim(driver, body) {
|
|
46
|
+
static claim(driver, body, base) {
|
|
52
47
|
var _a;
|
|
53
48
|
let result;
|
|
54
49
|
const owner = gCurrent.instance;
|
|
55
50
|
const children = owner.children;
|
|
56
51
|
let ex = undefined;
|
|
52
|
+
if (body)
|
|
53
|
+
body.base = base;
|
|
54
|
+
else
|
|
55
|
+
body = base !== null && base !== void 0 ? base : {};
|
|
57
56
|
driver !== null && driver !== void 0 ? driver : (driver = AbstractDriver.group);
|
|
58
|
-
if (body instanceof Function)
|
|
59
|
-
body = { render: body };
|
|
60
57
|
let key = body.key;
|
|
61
58
|
if (driver.isLine) {
|
|
62
59
|
const last = children.lastClaimedItem();
|
|
@@ -77,7 +74,7 @@ export class VBlock {
|
|
|
77
74
|
result = new VBlockImpl(key || VBlock.generateKey(owner), driver, owner, body);
|
|
78
75
|
result.item = children.add(result);
|
|
79
76
|
VBlockImpl.grandCount++;
|
|
80
|
-
if (body
|
|
77
|
+
if (isReaction(body))
|
|
81
78
|
VBlockImpl.disposableCount++;
|
|
82
79
|
}
|
|
83
80
|
return result;
|
|
@@ -87,9 +84,9 @@ export class VBlock {
|
|
|
87
84
|
const lettered = emitLetters(n);
|
|
88
85
|
let result;
|
|
89
86
|
if (Rx.isLogging)
|
|
90
|
-
result =
|
|
87
|
+
result = `·${getCallerInfo(lettered)}`;
|
|
91
88
|
else
|
|
92
|
-
result =
|
|
89
|
+
result = `·${lettered}`;
|
|
93
90
|
return result;
|
|
94
91
|
}
|
|
95
92
|
static getDefaultLoggingOptions() {
|
|
@@ -108,7 +105,7 @@ export var LayoutKind;
|
|
|
108
105
|
LayoutKind[LayoutKind["Block"] = 0] = "Block";
|
|
109
106
|
LayoutKind[LayoutKind["Grid"] = 1] = "Grid";
|
|
110
107
|
LayoutKind[LayoutKind["Line"] = 2] = "Line";
|
|
111
|
-
LayoutKind[LayoutKind["
|
|
108
|
+
LayoutKind[LayoutKind["Fragment"] = 3] = "Fragment";
|
|
112
109
|
LayoutKind[LayoutKind["Text"] = 4] = "Text";
|
|
113
110
|
})(LayoutKind || (LayoutKind = {}));
|
|
114
111
|
const createDefaultCursor = () => new Cursor();
|
|
@@ -164,42 +161,34 @@ export class AbstractDriver {
|
|
|
164
161
|
applyStyling(block, secondary, styleName, enabled) {
|
|
165
162
|
}
|
|
166
163
|
}
|
|
167
|
-
AbstractDriver.group = new AbstractDriver("group", LayoutKind.
|
|
168
|
-
function
|
|
164
|
+
AbstractDriver.group = new AbstractDriver("group", LayoutKind.Fragment);
|
|
165
|
+
function isReaction(body) {
|
|
169
166
|
var _a;
|
|
170
|
-
|
|
171
|
-
const base = vmt.base;
|
|
172
|
-
if (!redefined) {
|
|
173
|
-
(_a = vmt.initialize) === null || _a === void 0 ? void 0 : _a.call(vmt, block);
|
|
174
|
-
if (base)
|
|
175
|
-
invokeInitializeChain(block, base);
|
|
176
|
-
}
|
|
177
|
-
else
|
|
178
|
-
redefined(block, base ? () => invokeInitializeChain(block, base) : NOP);
|
|
167
|
+
return (_a = body === null || body === void 0 ? void 0 : body.reaction) !== null && _a !== void 0 ? _a : ((body === null || body === void 0 ? void 0 : body.base) ? isReaction(body === null || body === void 0 ? void 0 : body.base) : false);
|
|
179
168
|
}
|
|
180
|
-
function
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
(_a = vmt.render) === null || _a === void 0 ? void 0 : _a.call(vmt, block);
|
|
188
|
-
}
|
|
189
|
-
else
|
|
190
|
-
redefined(block, base ? () => invokeRenderChain(block, base) : NOP);
|
|
169
|
+
function invokeInitializeChain(block, body) {
|
|
170
|
+
const initialize = body.initialize;
|
|
171
|
+
const base = body.base;
|
|
172
|
+
if (initialize)
|
|
173
|
+
initialize(block, base ? () => invokeInitializeChain(block, base) : NOP);
|
|
174
|
+
else if (base)
|
|
175
|
+
invokeInitializeChain(block, base);
|
|
191
176
|
}
|
|
192
|
-
function
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
177
|
+
function invokeRenderChain(block, body) {
|
|
178
|
+
const render = body.render;
|
|
179
|
+
const base = body.base;
|
|
180
|
+
if (render)
|
|
181
|
+
render(block, base ? () => invokeRenderChain(block, base) : NOP);
|
|
182
|
+
else if (base)
|
|
183
|
+
invokeRenderChain(block, base);
|
|
184
|
+
}
|
|
185
|
+
function invokeFinalizeChain(block, body) {
|
|
186
|
+
const finalize = body.finalize;
|
|
187
|
+
const base = body.base;
|
|
188
|
+
if (finalize)
|
|
189
|
+
finalize(block, base ? () => invokeFinalizeChain(block, base) : NOP);
|
|
190
|
+
else if (base)
|
|
191
|
+
invokeFinalizeChain(block, base);
|
|
203
192
|
}
|
|
204
193
|
export class StaticDriver extends AbstractDriver {
|
|
205
194
|
constructor(element, name, layout, createCursor) {
|
|
@@ -371,7 +360,7 @@ class VBlockImpl extends VBlock {
|
|
|
371
360
|
this.assignedStyle = true;
|
|
372
361
|
}
|
|
373
362
|
configureReactronic(options) {
|
|
374
|
-
if (this.stamp !== 1 || !this.body
|
|
363
|
+
if (this.stamp !== 1 || !isReaction(this.body))
|
|
375
364
|
throw new Error("reactronic can be configured only for reacting blocks and only inside initialize");
|
|
376
365
|
return Rx.getController(this.render).configure(options);
|
|
377
366
|
}
|
|
@@ -532,7 +521,7 @@ function renderIncrementally(owner, stamp, allChildren, items, priority) {
|
|
|
532
521
|
function triggerRendering(item) {
|
|
533
522
|
const block = item.instance;
|
|
534
523
|
if (block.stamp >= 0) {
|
|
535
|
-
if (block.body
|
|
524
|
+
if (isReaction(block.body)) {
|
|
536
525
|
if (block.stamp === 0) {
|
|
537
526
|
Transaction.outside(() => {
|
|
538
527
|
if (Rx.isLogging)
|
|
@@ -595,7 +584,7 @@ function triggerFinalization(item, isLeader, individual) {
|
|
|
595
584
|
console.log(`WARNING: it is recommended to assign explicit key for conditionally rendered block in order to avoid unexpected side effects: ${block.key}`);
|
|
596
585
|
block.stamp = ~block.stamp;
|
|
597
586
|
const childrenAreLeaders = block.driver.finalize(block, isLeader);
|
|
598
|
-
if (block.body
|
|
587
|
+
if (isReaction(block.body)) {
|
|
599
588
|
item.aux = undefined;
|
|
600
589
|
const last = gLastToDispose;
|
|
601
590
|
if (last)
|
|
@@ -700,8 +689,8 @@ function defaultReject(error) {
|
|
|
700
689
|
}
|
|
701
690
|
Promise.prototype.then = reactronicDomHookedThen;
|
|
702
691
|
const NOP = (...args) => { };
|
|
703
|
-
const gSysDriver = new StaticDriver(null, "SYSTEM", LayoutKind.
|
|
704
|
-
const gSysRoot = Collection.createItem(new VBlockImpl(gSysDriver.name, gSysDriver, { level: 0 }, {
|
|
692
|
+
const gSysDriver = new StaticDriver(null, "SYSTEM", LayoutKind.Fragment);
|
|
693
|
+
const gSysRoot = Collection.createItem(new VBlockImpl(gSysDriver.name, gSysDriver, { level: 0 }, { reaction: true, render: NOP }));
|
|
705
694
|
gSysRoot.instance.item = gSysRoot;
|
|
706
695
|
Object.defineProperty(gSysRoot.instance, "host", {
|
|
707
696
|
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>(body
|
|
3
|
+
export declare function Block<M = unknown, R = void>(body?: BlockBody<HTMLElement, M, R>, base?: BlockBody<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
4
4
|
export declare function PlainText(content: string, body?: BlockBody<HTMLElement, void, void>): VBlock<HTMLElement, void, void>;
|
|
5
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
|
|
6
|
+
export declare function Grid<M = unknown, R = void>(body?: BlockBody<HTMLElement, M, R>, base?: BlockBody<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
7
7
|
export declare function line<T = void>(body: (block: void) => T): void;
|
|
8
8
|
export declare function lineFeed(noCoalescing?: boolean, key?: string): VBlock<HTMLElement>;
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function Fragment<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,24 +1,24 @@
|
|
|
1
|
-
import { VBlock, LayoutKind, Align, GridCursor
|
|
1
|
+
import { VBlock, LayoutKind, Align, GridCursor } from "../core/api";
|
|
2
2
|
import { HtmlDriver } from "./HtmlDriver";
|
|
3
|
-
export function Block(body) {
|
|
4
|
-
return VBlock.claim(VerstakTags.block, body);
|
|
3
|
+
export function Block(body, base) {
|
|
4
|
+
return VBlock.claim(VerstakTags.block, body, base);
|
|
5
5
|
}
|
|
6
6
|
export function PlainText(content, body) {
|
|
7
|
-
return VBlock.claim(VerstakTags.text,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
return VBlock.claim(VerstakTags.text, body, {
|
|
8
|
+
render(b) {
|
|
9
|
+
b.native.innerText = content;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
12
|
}
|
|
13
13
|
export function HtmlText(content, body) {
|
|
14
|
-
return VBlock.claim(VerstakTags.text,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
return VBlock.claim(VerstakTags.text, body, {
|
|
15
|
+
render(b) {
|
|
16
|
+
b.native.innerHTML = content;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
19
|
}
|
|
20
|
-
export function Grid(body) {
|
|
21
|
-
return VBlock.claim(VerstakTags.grid, body);
|
|
20
|
+
export function Grid(body, base) {
|
|
21
|
+
return VBlock.claim(VerstakTags.grid, body, base);
|
|
22
22
|
}
|
|
23
23
|
export function line(body) {
|
|
24
24
|
lineFeed();
|
|
@@ -27,8 +27,8 @@ export function line(body) {
|
|
|
27
27
|
export function lineFeed(noCoalescing, key) {
|
|
28
28
|
return VBlock.claim(VerstakTags.line, { key });
|
|
29
29
|
}
|
|
30
|
-
export function
|
|
31
|
-
return VBlock.claim(VerstakTags.
|
|
30
|
+
export function Fragment(body) {
|
|
31
|
+
return VBlock.claim(VerstakTags.fragment, body);
|
|
32
32
|
}
|
|
33
33
|
export class VerstakDriver extends HtmlDriver {
|
|
34
34
|
applyCellRange(block, cellRange) {
|
|
@@ -148,7 +148,7 @@ const VerstakTags = {
|
|
|
148
148
|
text: new VerstakDriver("v-text", LayoutKind.Text),
|
|
149
149
|
grid: new VerstakDriver("v-grid", LayoutKind.Grid, () => new GridCursor()),
|
|
150
150
|
line: new VerstakDriver("v-line", LayoutKind.Line),
|
|
151
|
-
|
|
151
|
+
fragment: new VerstakDriver("v-fragment", LayoutKind.Fragment),
|
|
152
152
|
};
|
|
153
153
|
const AlignToCss = ["stretch", "start", "center", "end"];
|
|
154
154
|
const TextAlignCss = ["justify", "left", "center", "right"];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment } from "./Blocks";
|
|
2
2
|
export function ReactingFocuser(target, model, switchEditMode = undefined) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Fragment({
|
|
4
|
+
reaction: true,
|
|
5
5
|
triggers: { target, model },
|
|
6
6
|
initialize(b) {
|
|
7
7
|
b.configureReactronic({ throttling: 0 });
|