verstak 0.22.412 → 0.22.500
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 +3 -2
- package/build/dist/source/core/Block.d.ts +62 -0
- package/build/dist/source/core/{RxNode.js → Block.js} +130 -125
- package/build/dist/source/core/Elements.d.ts +3 -4
- package/build/dist/source/core/Elements.js +5 -5
- package/build/dist/source/core/Layout.d.ts +27 -0
- package/build/dist/source/{html/CellRange.js → core/Layout.js} +101 -17
- package/build/dist/source/core/Restyler.d.ts +2 -2
- package/build/dist/source/core/Restyler.js +3 -3
- package/build/dist/source/core/api.d.ts +3 -2
- package/build/dist/source/core/api.js +3 -2
- package/build/dist/source/html/Cluster.d.ts +11 -0
- package/build/dist/source/html/Cluster.js +14 -0
- package/build/dist/source/html/HtmlElements.d.ts +348 -348
- package/build/dist/source/html/HtmlElements.js +523 -523
- package/build/dist/source/html/HtmlNodeFactory.d.ts +13 -13
- package/build/dist/source/html/HtmlNodeFactory.js +30 -30
- package/build/dist/source/html/RxFocuser.js +2 -2
- package/build/dist/source/html/api.d.ts +0 -1
- package/build/dist/source/html/api.js +0 -1
- package/build/dist/source/html/sensors/ResizeSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/ResizeSensor.js +11 -11
- package/package.json +6 -6
- package/build/dist/source/core/RxNode.d.ts +0 -59
- package/build/dist/source/html/CellRange.d.ts +0 -11
package/README.md
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/verstak)
|
|
4
4
|
[](https://bundlephobia.com/result?p=verstak)
|
|
5
5
|
|
|
6
|
-
# **Verstak** -
|
|
6
|
+
# **Verstak** - Experimental Front-End Library
|
|
7
7
|
|
|
8
8
|
Verstak is an experimental JavaScript library that provides
|
|
9
|
+
grid-based layout and
|
|
9
10
|
[transactional reactive](https://blog.nezaboodka.com/post/2019/593-modern-database-should-natively-support-transactionally-reactive-programming)
|
|
10
|
-
facilities
|
|
11
|
+
facilities for building front-end applications.
|
|
11
12
|
|
|
12
13
|
Transactional reactivity means that state changes are being made in an
|
|
13
14
|
isolated data snapshot and then, once atomically applied, are
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Monitor, LoggingOptions, Item, CollectionReader } from 'reactronic';
|
|
2
|
+
export declare type Callback<T = unknown> = (impl: T) => void;
|
|
3
|
+
export declare type Render<T = unknown, M = unknown, P = void, R = void> = (impl: T, block: Block<T, M, P, R>) => R;
|
|
4
|
+
export declare type AsyncRender<T = unknown, M = unknown, P = void> = (impl: T, block: Block<T, M, P, Promise<void>>) => Promise<void>;
|
|
5
|
+
export declare const enum Priority {
|
|
6
|
+
SyncP0 = 0,
|
|
7
|
+
AsyncP1 = 1,
|
|
8
|
+
AsyncP2 = 2
|
|
9
|
+
}
|
|
10
|
+
export interface BlockOptions<P = void> {
|
|
11
|
+
place?: P;
|
|
12
|
+
triggers?: unknown;
|
|
13
|
+
priority?: Priority;
|
|
14
|
+
monitor?: Monitor;
|
|
15
|
+
throttling?: number;
|
|
16
|
+
logging?: Partial<LoggingOptions>;
|
|
17
|
+
shuffle?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare abstract class Block<T = unknown, M = unknown, P = void, R = void> {
|
|
20
|
+
static readonly shortFrameDuration = 16;
|
|
21
|
+
static readonly longFrameDuration = 300;
|
|
22
|
+
static currentRenderingPriority: Priority;
|
|
23
|
+
static frameDuration: number;
|
|
24
|
+
abstract readonly name: string;
|
|
25
|
+
abstract readonly factory: BlockFactory<T>;
|
|
26
|
+
abstract readonly inline: boolean;
|
|
27
|
+
abstract readonly renderer: Render<T, M, P, R>;
|
|
28
|
+
abstract readonly wrapper: Render<T, M, P, R> | undefined;
|
|
29
|
+
abstract readonly options: Readonly<BlockOptions<P>> | undefined;
|
|
30
|
+
abstract model?: M;
|
|
31
|
+
abstract readonly level: number;
|
|
32
|
+
abstract readonly parent: Block;
|
|
33
|
+
abstract readonly children: CollectionReader<Block>;
|
|
34
|
+
abstract readonly item: Item<Block> | undefined;
|
|
35
|
+
abstract readonly stamp: number;
|
|
36
|
+
abstract readonly impl?: T;
|
|
37
|
+
render(): R;
|
|
38
|
+
get isInitialRendering(): boolean;
|
|
39
|
+
abstract wrapBy(renderer: Render<T, M, P, R> | undefined): this;
|
|
40
|
+
static root(render: () => void): void;
|
|
41
|
+
static get current(): Block;
|
|
42
|
+
static renderChildrenThenDo(action: (error: unknown) => void): void;
|
|
43
|
+
static forAllBlocksDo<T>(action: (e: T) => void): void;
|
|
44
|
+
static claim<T = undefined, M = unknown, P = void, R = void>(name: string, inline: boolean, options: BlockOptions<P> | undefined, renderer: Render<T, M, P, R>, factory?: BlockFactory<T>): Block<T, M, P, R>;
|
|
45
|
+
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
46
|
+
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
47
|
+
}
|
|
48
|
+
export declare class BlockFactory<T> {
|
|
49
|
+
static readonly default: BlockFactory<any>;
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly strict: boolean;
|
|
52
|
+
constructor(name: string, strict: boolean);
|
|
53
|
+
initialize(block: Block<T>, impl: T | undefined): void;
|
|
54
|
+
finalize(block: Block<T>, isLeader: boolean): boolean;
|
|
55
|
+
layout(block: Block<T>, strict: boolean): void;
|
|
56
|
+
render(block: Block<T>): void | Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
export declare class StaticBlockFactory<T> extends BlockFactory<T> {
|
|
59
|
+
readonly element: T;
|
|
60
|
+
constructor(name: string, sequential: boolean, element: T);
|
|
61
|
+
initialize(block: Block<T>, element: T | undefined): void;
|
|
62
|
+
}
|
|
@@ -23,9 +23,9 @@ export var Priority;
|
|
|
23
23
|
Priority[Priority["AsyncP1"] = 1] = "AsyncP1";
|
|
24
24
|
Priority[Priority["AsyncP2"] = 2] = "AsyncP2";
|
|
25
25
|
})(Priority || (Priority = {}));
|
|
26
|
-
export class
|
|
26
|
+
export class Block {
|
|
27
27
|
render() {
|
|
28
|
-
return this.renderer(this.
|
|
28
|
+
return this.renderer(this.impl, this);
|
|
29
29
|
}
|
|
30
30
|
get isInitialRendering() {
|
|
31
31
|
return this.stamp === 2;
|
|
@@ -37,109 +37,105 @@ export class RxNode {
|
|
|
37
37
|
static get current() {
|
|
38
38
|
return gContext.self;
|
|
39
39
|
}
|
|
40
|
-
static shuffleChildrenRendering(shuffle) {
|
|
41
|
-
gContext.self.shuffle = shuffle;
|
|
42
|
-
}
|
|
43
40
|
static renderChildrenThenDo(action) {
|
|
44
41
|
runRenderChildrenThenDo(undefined, action);
|
|
45
42
|
}
|
|
46
|
-
static
|
|
43
|
+
static forAllBlocksDo(action) {
|
|
47
44
|
forEachChildRecursively(gSysRoot, action);
|
|
48
45
|
}
|
|
49
|
-
static claim(name,
|
|
46
|
+
static claim(name, inline, options, renderer, factory) {
|
|
47
|
+
var _a;
|
|
50
48
|
const parent = gContext.self;
|
|
51
49
|
const children = parent.children;
|
|
52
50
|
const item = children.claim(name);
|
|
53
|
-
let
|
|
51
|
+
let block;
|
|
54
52
|
if (item) {
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
throw new Error(`changing
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
block = item.self;
|
|
54
|
+
if (block.factory !== factory && factory !== undefined)
|
|
55
|
+
throw new Error(`changing block type is not yet supported: "${block.factory.name}" -> "${factory === null || factory === void 0 ? void 0 : factory.name}"`);
|
|
56
|
+
if (options) {
|
|
57
|
+
const existingTriggers = (_a = block.options) === null || _a === void 0 ? void 0 : _a.triggers;
|
|
58
|
+
if (triggersAreEqual(options.triggers, existingTriggers))
|
|
59
|
+
options.triggers = existingTriggers;
|
|
60
|
+
}
|
|
61
|
+
block.options = options;
|
|
62
|
+
block.renderer = renderer;
|
|
62
63
|
}
|
|
63
64
|
else {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (!
|
|
68
|
-
|
|
65
|
+
block = new VerstakBlock(name, factory !== null && factory !== void 0 ? factory : BlockFactory.default, inline !== null && inline !== void 0 ? inline : false, parent, options, renderer, undefined);
|
|
66
|
+
block.item = children.add(block);
|
|
67
|
+
VerstakBlock.grandCount++;
|
|
68
|
+
if (!block.inline)
|
|
69
|
+
VerstakBlock.disposableCount++;
|
|
69
70
|
}
|
|
70
|
-
return
|
|
71
|
+
return block;
|
|
71
72
|
}
|
|
72
73
|
static getDefaultLoggingOptions() {
|
|
73
|
-
return
|
|
74
|
+
return VerstakBlock.logging;
|
|
74
75
|
}
|
|
75
76
|
static setDefaultLoggingOptions(logging) {
|
|
76
|
-
|
|
77
|
+
VerstakBlock.logging = logging;
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
Block.shortFrameDuration = 16;
|
|
81
|
+
Block.longFrameDuration = 300;
|
|
82
|
+
Block.currentRenderingPriority = Priority.SyncP0;
|
|
83
|
+
Block.frameDuration = Block.longFrameDuration;
|
|
83
84
|
const NOP = () => { };
|
|
84
|
-
export class
|
|
85
|
+
export class BlockFactory {
|
|
85
86
|
constructor(name, strict) {
|
|
86
87
|
this.name = name;
|
|
87
88
|
this.strict = strict;
|
|
88
89
|
}
|
|
89
|
-
initialize(
|
|
90
|
-
const
|
|
91
|
-
impl
|
|
90
|
+
initialize(block, impl) {
|
|
91
|
+
const b = block;
|
|
92
|
+
b.impl = impl;
|
|
92
93
|
}
|
|
93
|
-
finalize(
|
|
94
|
-
const
|
|
95
|
-
impl
|
|
94
|
+
finalize(block, isLeader) {
|
|
95
|
+
const b = block;
|
|
96
|
+
b.impl = undefined;
|
|
96
97
|
return isLeader;
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
+
layout(block, strict) {
|
|
99
100
|
}
|
|
100
|
-
render(
|
|
101
|
+
render(block) {
|
|
101
102
|
let result;
|
|
102
|
-
if (
|
|
103
|
-
result =
|
|
103
|
+
if (block.wrapper)
|
|
104
|
+
result = block.wrapper(block.impl, block);
|
|
104
105
|
else
|
|
105
|
-
result =
|
|
106
|
+
result = block.render();
|
|
106
107
|
return result;
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
-
export class
|
|
110
|
+
BlockFactory.default = new BlockFactory('default', false);
|
|
111
|
+
export class StaticBlockFactory extends BlockFactory {
|
|
111
112
|
constructor(name, sequential, element) {
|
|
112
113
|
super(name, sequential);
|
|
113
114
|
this.element = element;
|
|
114
115
|
}
|
|
115
|
-
initialize(
|
|
116
|
-
super.initialize(
|
|
116
|
+
initialize(block, element) {
|
|
117
|
+
super.initialize(block, this.element);
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
120
|
+
function getBlockName(block) {
|
|
121
|
+
return block.stamp >= 0 ? block.name : undefined;
|
|
121
122
|
}
|
|
122
|
-
class
|
|
123
|
-
constructor(name, factory, inline, parent,
|
|
123
|
+
class VerstakBlock extends Block {
|
|
124
|
+
constructor(name, factory, inline, parent, options, renderer, wrapper) {
|
|
124
125
|
super();
|
|
125
126
|
this.name = name;
|
|
126
127
|
this.factory = factory;
|
|
127
128
|
this.inline = inline;
|
|
128
|
-
this.
|
|
129
|
+
this.options = options;
|
|
129
130
|
this.renderer = renderer;
|
|
130
131
|
this.wrapper = wrapper;
|
|
131
|
-
this.monitor = monitor;
|
|
132
|
-
this.throttling = throttling !== null && throttling !== void 0 ? throttling : -1;
|
|
133
|
-
this.logging = logging !== null && logging !== void 0 ? logging : RxNodeImpl.logging;
|
|
134
|
-
this.priority = priority !== null && priority !== void 0 ? priority : Priority.SyncP0;
|
|
135
|
-
this.shuffle = false;
|
|
136
132
|
this.model = undefined;
|
|
137
133
|
this.level = parent.level + 1;
|
|
138
134
|
this.parent = parent;
|
|
139
|
-
this.children = new Collection(factory.strict,
|
|
135
|
+
this.children = new Collection(factory.strict, getBlockName);
|
|
140
136
|
this.item = undefined;
|
|
141
137
|
this.stamp = 0;
|
|
142
|
-
this.
|
|
138
|
+
this.impl = undefined;
|
|
143
139
|
}
|
|
144
140
|
autorender(_triggers) {
|
|
145
141
|
runRender(this.item);
|
|
@@ -149,9 +145,9 @@ class RxNodeImpl extends RxNode {
|
|
|
149
145
|
return this;
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
VerstakBlock.grandCount = 0;
|
|
149
|
+
VerstakBlock.disposableCount = 0;
|
|
150
|
+
VerstakBlock.logging = undefined;
|
|
155
151
|
__decorate([
|
|
156
152
|
reactive,
|
|
157
153
|
options({
|
|
@@ -162,11 +158,12 @@ __decorate([
|
|
|
162
158
|
__metadata("design:type", Function),
|
|
163
159
|
__metadata("design:paramtypes", [Object]),
|
|
164
160
|
__metadata("design:returntype", void 0)
|
|
165
|
-
],
|
|
161
|
+
], VerstakBlock.prototype, "autorender", null);
|
|
166
162
|
function runRenderChildrenThenDo(error, action) {
|
|
163
|
+
var _a, _b;
|
|
167
164
|
const context = gContext;
|
|
168
|
-
const
|
|
169
|
-
const children =
|
|
165
|
+
const block = context.self;
|
|
166
|
+
const children = block.children;
|
|
170
167
|
if (children.isMergeInProgress) {
|
|
171
168
|
let promised = undefined;
|
|
172
169
|
try {
|
|
@@ -181,21 +178,15 @@ function runRenderChildrenThenDo(error, action) {
|
|
|
181
178
|
for (const child of children.items()) {
|
|
182
179
|
if (Transaction.isCanceled)
|
|
183
180
|
break;
|
|
181
|
+
isMoved = checkIsMoved(isMoved, child, children, strict);
|
|
184
182
|
const x = child.self;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
children.markAsMoved(child);
|
|
188
|
-
isMoved = false;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
else if (strict && children.isMoved(child))
|
|
192
|
-
isMoved = true;
|
|
193
|
-
if (x.priority === Priority.SyncP0)
|
|
183
|
+
const priority = (_b = (_a = x.options) === null || _a === void 0 ? void 0 : _a.priority) !== null && _b !== void 0 ? _b : Priority.SyncP0;
|
|
184
|
+
if (priority === Priority.SyncP0)
|
|
194
185
|
prepareThenRunRender(child, children.isMoved(child), strict);
|
|
195
|
-
else if (
|
|
196
|
-
p1 = push(
|
|
186
|
+
else if (priority === Priority.AsyncP1)
|
|
187
|
+
p1 = push(child, p1);
|
|
197
188
|
else
|
|
198
|
-
p2 = push(
|
|
189
|
+
p2 = push(child, p2);
|
|
199
190
|
}
|
|
200
191
|
if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
|
|
201
192
|
promised = startIncrementalRendering(context, children, p1, p2).then(() => action(error), e => action(e));
|
|
@@ -207,6 +198,17 @@ function runRenderChildrenThenDo(error, action) {
|
|
|
207
198
|
}
|
|
208
199
|
}
|
|
209
200
|
}
|
|
201
|
+
function checkIsMoved(isMoved, child, children, strict) {
|
|
202
|
+
if (child.self.impl) {
|
|
203
|
+
if (isMoved) {
|
|
204
|
+
children.markAsMoved(child);
|
|
205
|
+
isMoved = false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else if (strict && children.isMoved(child))
|
|
209
|
+
isMoved = true;
|
|
210
|
+
return isMoved;
|
|
211
|
+
}
|
|
210
212
|
function startIncrementalRendering(parent, allChildren, priority1, priority2) {
|
|
211
213
|
return __awaiter(this, void 0, void 0, function* () {
|
|
212
214
|
const stamp = parent.self.stamp;
|
|
@@ -217,80 +219,83 @@ function startIncrementalRendering(parent, allChildren, priority1, priority2) {
|
|
|
217
219
|
});
|
|
218
220
|
}
|
|
219
221
|
function renderIncrementally(parent, stamp, allChildren, items, priority) {
|
|
222
|
+
var _a;
|
|
220
223
|
return __awaiter(this, void 0, void 0, function* () {
|
|
221
224
|
yield Transaction.requestNextFrame();
|
|
222
|
-
const
|
|
223
|
-
if (!Transaction.isCanceled || !Transaction.isFrameOver(1,
|
|
224
|
-
let outerPriority =
|
|
225
|
-
|
|
225
|
+
const block = parent.self;
|
|
226
|
+
if (!Transaction.isCanceled || !Transaction.isFrameOver(1, Block.shortFrameDuration / 3)) {
|
|
227
|
+
let outerPriority = Block.currentRenderingPriority;
|
|
228
|
+
Block.currentRenderingPriority = priority;
|
|
226
229
|
try {
|
|
227
|
-
const strict =
|
|
228
|
-
if (
|
|
230
|
+
const strict = block.children.strict;
|
|
231
|
+
if ((_a = block.options) === null || _a === void 0 ? void 0 : _a.shuffle)
|
|
229
232
|
shuffle(items);
|
|
230
|
-
const frameDurationLimit = priority === Priority.AsyncP2 ?
|
|
231
|
-
let frameDuration = Math.min(frameDurationLimit, Math.max(
|
|
233
|
+
const frameDurationLimit = priority === Priority.AsyncP2 ? Block.shortFrameDuration : Infinity;
|
|
234
|
+
let frameDuration = Math.min(frameDurationLimit, Math.max(Block.frameDuration / 4, Block.shortFrameDuration));
|
|
232
235
|
for (const child of items) {
|
|
233
236
|
prepareThenRunRender(child, allChildren.isMoved(child), strict);
|
|
234
237
|
if (Transaction.isFrameOver(1, frameDuration)) {
|
|
235
|
-
|
|
238
|
+
Block.currentRenderingPriority = outerPriority;
|
|
236
239
|
yield Transaction.requestNextFrame(0);
|
|
237
|
-
outerPriority =
|
|
238
|
-
|
|
239
|
-
frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit,
|
|
240
|
+
outerPriority = Block.currentRenderingPriority;
|
|
241
|
+
Block.currentRenderingPriority = priority;
|
|
242
|
+
frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, Block.frameDuration));
|
|
240
243
|
}
|
|
241
|
-
if (Transaction.isCanceled && Transaction.isFrameOver(1,
|
|
244
|
+
if (Transaction.isCanceled && Transaction.isFrameOver(1, Block.shortFrameDuration / 3))
|
|
242
245
|
break;
|
|
243
246
|
}
|
|
244
247
|
}
|
|
245
248
|
finally {
|
|
246
|
-
|
|
249
|
+
Block.currentRenderingPriority = outerPriority;
|
|
247
250
|
}
|
|
248
251
|
}
|
|
249
252
|
});
|
|
250
253
|
}
|
|
251
254
|
function prepareThenRunRender(item, moved, strict) {
|
|
252
|
-
|
|
253
|
-
|
|
255
|
+
var _a;
|
|
256
|
+
const block = item.self;
|
|
257
|
+
if (block.stamp >= 0) {
|
|
254
258
|
prepareRender(item, moved, strict);
|
|
255
|
-
if (
|
|
259
|
+
if (block.inline)
|
|
256
260
|
runRender(item);
|
|
257
261
|
else
|
|
258
|
-
nonreactive(
|
|
262
|
+
nonreactive(block.autorender, (_a = block.options) === null || _a === void 0 ? void 0 : _a.triggers);
|
|
259
263
|
}
|
|
260
264
|
}
|
|
261
265
|
function prepareRender(item, moved, strict) {
|
|
262
266
|
var _a, _b, _c;
|
|
263
|
-
const
|
|
264
|
-
const factory =
|
|
265
|
-
if (
|
|
266
|
-
|
|
267
|
-
if (!
|
|
267
|
+
const block = item.self;
|
|
268
|
+
const factory = block.factory;
|
|
269
|
+
if (block.stamp === 0) {
|
|
270
|
+
block.stamp = 1;
|
|
271
|
+
if (!block.inline) {
|
|
268
272
|
Transaction.outside(() => {
|
|
273
|
+
var _a, _b, _c;
|
|
269
274
|
if (Rx.isLogging)
|
|
270
|
-
Rx.setLoggingHint(
|
|
271
|
-
Rx.getController(
|
|
272
|
-
order:
|
|
273
|
-
monitor:
|
|
274
|
-
throttling:
|
|
275
|
-
logging:
|
|
275
|
+
Rx.setLoggingHint(block, block.name);
|
|
276
|
+
Rx.getController(block.autorender).configure({
|
|
277
|
+
order: block.level,
|
|
278
|
+
monitor: (_a = block.options) === null || _a === void 0 ? void 0 : _a.monitor,
|
|
279
|
+
throttling: (_b = block.options) === null || _b === void 0 ? void 0 : _b.throttling,
|
|
280
|
+
logging: (_c = block.options) === null || _c === void 0 ? void 0 : _c.logging,
|
|
276
281
|
});
|
|
277
282
|
});
|
|
278
283
|
}
|
|
279
|
-
(_a = factory.initialize) === null || _a === void 0 ? void 0 : _a.call(factory,
|
|
280
|
-
(_b = factory.
|
|
284
|
+
(_a = factory.initialize) === null || _a === void 0 ? void 0 : _a.call(factory, block, undefined);
|
|
285
|
+
(_b = factory.layout) === null || _b === void 0 ? void 0 : _b.call(factory, block, strict);
|
|
281
286
|
}
|
|
282
287
|
else if (moved)
|
|
283
|
-
(_c = factory.
|
|
288
|
+
(_c = factory.layout) === null || _c === void 0 ? void 0 : _c.call(factory, block, strict);
|
|
284
289
|
}
|
|
285
290
|
function runRender(item) {
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
291
|
+
const block = item.self;
|
|
292
|
+
if (block.stamp >= 0) {
|
|
288
293
|
runUnder(item, () => {
|
|
289
294
|
let result = undefined;
|
|
290
295
|
try {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
result =
|
|
296
|
+
block.stamp++;
|
|
297
|
+
block.children.beginMerge();
|
|
298
|
+
result = block.factory.render(block);
|
|
294
299
|
if (result instanceof Promise)
|
|
295
300
|
result.then(v => { runRenderChildrenThenDo(undefined, NOP); return v; }, e => { console.log(e); runRenderChildrenThenDo(e !== null && e !== void 0 ? e : new Error('unknown error'), NOP); });
|
|
296
301
|
else
|
|
@@ -298,18 +303,18 @@ function runRender(item) {
|
|
|
298
303
|
}
|
|
299
304
|
catch (e) {
|
|
300
305
|
runRenderChildrenThenDo(e, NOP);
|
|
301
|
-
console.log(`Rendering failed: ${
|
|
306
|
+
console.log(`Rendering failed: ${block.name}`);
|
|
302
307
|
console.log(`${e}`);
|
|
303
308
|
}
|
|
304
309
|
});
|
|
305
310
|
}
|
|
306
311
|
}
|
|
307
312
|
function runFinalize(item, isLeader) {
|
|
308
|
-
const
|
|
309
|
-
if (
|
|
310
|
-
|
|
311
|
-
const childrenAreLeaders =
|
|
312
|
-
if (!
|
|
313
|
+
const block = item.self;
|
|
314
|
+
if (block.stamp >= 0) {
|
|
315
|
+
block.stamp = ~block.stamp;
|
|
316
|
+
const childrenAreLeaders = block.factory.finalize(block, isLeader);
|
|
317
|
+
if (!block.inline) {
|
|
313
318
|
item.aux = undefined;
|
|
314
319
|
const last = gLastToDispose;
|
|
315
320
|
if (last)
|
|
@@ -321,9 +326,9 @@ function runFinalize(item, isLeader) {
|
|
|
321
326
|
void runDisposalLoop().then(NOP, error => console.log(error));
|
|
322
327
|
});
|
|
323
328
|
}
|
|
324
|
-
for (const item of
|
|
329
|
+
for (const item of block.children.items())
|
|
325
330
|
runFinalize(item, childrenAreLeaders);
|
|
326
|
-
|
|
331
|
+
VerstakBlock.grandCount--;
|
|
327
332
|
}
|
|
328
333
|
}
|
|
329
334
|
function runDisposalLoop() {
|
|
@@ -335,16 +340,16 @@ function runDisposalLoop() {
|
|
|
335
340
|
yield Transaction.requestNextFrame();
|
|
336
341
|
Rx.dispose(item.self);
|
|
337
342
|
item = item.aux;
|
|
338
|
-
|
|
343
|
+
VerstakBlock.disposableCount--;
|
|
339
344
|
}
|
|
340
345
|
gFirstToDispose = gLastToDispose = undefined;
|
|
341
346
|
});
|
|
342
347
|
}
|
|
343
348
|
function forEachChildRecursively(item, action) {
|
|
344
|
-
const
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
for (const item of
|
|
349
|
+
const block = item.self;
|
|
350
|
+
const impl = block.impl;
|
|
351
|
+
impl && action(impl);
|
|
352
|
+
for (const item of block.children.items())
|
|
348
353
|
forEachChildRecursively(item, action);
|
|
349
354
|
}
|
|
350
355
|
function wrap(func) {
|
|
@@ -382,7 +387,7 @@ function triggersAreEqual(a1, a2) {
|
|
|
382
387
|
}
|
|
383
388
|
return result;
|
|
384
389
|
}
|
|
385
|
-
function push(
|
|
390
|
+
function push(item, array) {
|
|
386
391
|
if (array == undefined)
|
|
387
392
|
array = new Array();
|
|
388
393
|
array.push(item);
|
|
@@ -413,7 +418,7 @@ function defaultReject(error) {
|
|
|
413
418
|
throw error;
|
|
414
419
|
}
|
|
415
420
|
Promise.prototype.then = reactronicDomHookedThen;
|
|
416
|
-
const gSysRoot = Collection.createItem(new
|
|
421
|
+
const gSysRoot = Collection.createItem(new VerstakBlock('SYSTEM', new StaticBlockFactory('SYSTEM', false, null), false, { level: 0 }, undefined, NOP));
|
|
417
422
|
gSysRoot.self.item = gSysRoot;
|
|
418
423
|
Object.defineProperty(gSysRoot, 'parent', {
|
|
419
424
|
value: gSysRoot,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function Inline<E = undefined, M = unknown, R = void>(name: string, renderer: Render<E, M, R>, priority?: Priority, factory?: NodeFactory<E>): RxNode<E, M, R>;
|
|
1
|
+
import { Block, Render, BlockFactory, BlockOptions } from './Block';
|
|
2
|
+
export declare function Reaction<T = undefined, M = unknown, P = void, R = void>(name: string, options: BlockOptions<P> | undefined, renderer: Render<T, M, P, R>, factory?: BlockFactory<T>): Block<T, M, P, R>;
|
|
3
|
+
export declare function Inline<T = undefined, M = unknown, P = void, R = void>(name: string, options: BlockOptions<P> | undefined, renderer: Render<T, M, P, R>, factory?: BlockFactory<T>): Block<T, M, P, R>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export function Reaction(name,
|
|
3
|
-
return
|
|
1
|
+
import { Block } from './Block';
|
|
2
|
+
export function Reaction(name, options, renderer, factory) {
|
|
3
|
+
return Block.claim(name, false, options, renderer, factory);
|
|
4
4
|
}
|
|
5
|
-
export function Inline(name,
|
|
6
|
-
return
|
|
5
|
+
export function Inline(name, options, renderer, factory) {
|
|
6
|
+
return Block.claim(name, true, options, renderer, factory);
|
|
7
7
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface Place {
|
|
2
|
+
lineBegin?: boolean;
|
|
3
|
+
area?: string;
|
|
4
|
+
columns?: number;
|
|
5
|
+
rows?: number;
|
|
6
|
+
cursorRight?: boolean;
|
|
7
|
+
cursorDown?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CellRange {
|
|
10
|
+
x1: number;
|
|
11
|
+
y1: number;
|
|
12
|
+
x2: number;
|
|
13
|
+
y2: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class Layout {
|
|
16
|
+
private maxColumnCount;
|
|
17
|
+
private maxRowCount;
|
|
18
|
+
private actualColumnCount;
|
|
19
|
+
private actualRowCount;
|
|
20
|
+
private columnCursor;
|
|
21
|
+
private rowCursor;
|
|
22
|
+
private newRowCursor;
|
|
23
|
+
reset(maxColumnCount: number, maxRowCount: number): void;
|
|
24
|
+
claim(p: Place, result: CellRange): CellRange;
|
|
25
|
+
static parseCellRange(text: string, result: CellRange): CellRange;
|
|
26
|
+
static emitCellRange(value: CellRange): string;
|
|
27
|
+
}
|