verstak 0.22.500 → 0.22.503
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/api.d.ts +2 -2
- package/build/dist/source/api.js +2 -2
- package/build/dist/source/archive/RxDomV1.d.ts +1 -1
- package/build/dist/source/archive/RxDomV1.js +13 -13
- package/build/dist/source/core/Allocator.d.ts +64 -0
- package/build/dist/source/core/Allocator.js +141 -0
- package/build/dist/source/core/CellRange.d.ts +8 -0
- package/build/dist/source/core/CellRange.js +173 -0
- package/build/dist/source/core/Kernel.d.ts +77 -0
- package/build/dist/source/core/Kernel.js +504 -0
- package/build/dist/source/core/Restyler.js +1 -1
- package/build/dist/source/core/api.d.ts +5 -5
- package/build/dist/source/core/api.js +5 -5
- package/build/dist/source/html/Blocks.d.ts +14 -0
- package/build/dist/source/html/Blocks.js +124 -0
- package/build/dist/source/html/HtmlApiExt.d.ts +1 -1
- package/build/dist/source/html/HtmlApiExt.js +3 -3
- package/build/dist/source/html/HtmlBlocks.d.ts +175 -0
- package/build/dist/source/html/HtmlBlocks.js +356 -0
- package/build/dist/source/html/HtmlDriver.d.ts +20 -0
- package/build/dist/source/html/{HtmlNodeFactory.js → HtmlDriver.js} +25 -23
- package/build/dist/source/html/ReactingFocuser.d.ts +2 -0
- package/build/dist/source/html/ReactingFocuser.js +16 -0
- package/build/dist/source/html/api.d.ts +18 -17
- package/build/dist/source/html/api.js +18 -17
- package/build/dist/source/html/sensors/BasePointerSensor.d.ts +4 -4
- package/build/dist/source/html/sensors/BasePointerSensor.js +2 -2
- package/build/dist/source/html/sensors/ButtonSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/ButtonSensor.js +17 -17
- package/build/dist/source/html/sensors/DataForSensor.js +6 -6
- package/build/dist/source/html/sensors/FocusSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/FocusSensor.js +27 -27
- package/build/dist/source/html/sensors/HoverSensor.d.ts +1 -1
- package/build/dist/source/html/sensors/HoverSensor.js +9 -9
- package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +6 -6
- package/build/dist/source/html/sensors/HtmlDragSensor.js +28 -28
- package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/HtmlElementSensor.js +4 -4
- package/build/dist/source/html/sensors/HtmlSensors.d.ts +9 -9
- package/build/dist/source/html/sensors/HtmlSensors.js +10 -10
- package/build/dist/source/html/sensors/KeyboardSensor.d.ts +1 -1
- package/build/dist/source/html/sensors/KeyboardSensor.js +18 -18
- package/build/dist/source/html/sensors/PointerSensor.d.ts +4 -4
- package/build/dist/source/html/sensors/PointerSensor.js +20 -20
- package/build/dist/source/html/sensors/ResizeSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/ResizeSensor.js +13 -13
- package/build/dist/source/html/sensors/Sensor.d.ts +1 -1
- package/build/dist/source/html/sensors/Sensor.js +1 -1
- package/build/dist/source/html/sensors/WheelSensor.d.ts +1 -1
- package/build/dist/source/html/sensors/WheelSensor.js +7 -7
- package/build/dist/source/html/sensors/WindowSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/WindowSensor.js +5 -5
- package/package.json +3 -3
- package/build/dist/source/core/Block.d.ts +0 -62
- package/build/dist/source/core/Block.js +0 -431
- package/build/dist/source/core/Elements.d.ts +0 -3
- package/build/dist/source/core/Elements.js +0 -7
- package/build/dist/source/core/Layout.d.ts +0 -27
- package/build/dist/source/core/Layout.js +0 -259
- package/build/dist/source/html/Cluster.d.ts +0 -11
- package/build/dist/source/html/Cluster.js +0 -14
- package/build/dist/source/html/HtmlElements.d.ts +0 -349
- package/build/dist/source/html/HtmlElements.js +0 -529
- package/build/dist/source/html/HtmlNodeFactory.d.ts +0 -19
- package/build/dist/source/html/RxFocuser.d.ts +0 -2
- package/build/dist/source/html/RxFocuser.js +0 -11
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
16
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
import { reactive, nonreactive, Transaction, options, Reentrance, Rx, Collection } from "reactronic";
|
|
20
|
+
import { Allocator, To } from "./Allocator";
|
|
21
|
+
export var Priority;
|
|
22
|
+
(function (Priority) {
|
|
23
|
+
Priority[Priority["SyncP0"] = 0] = "SyncP0";
|
|
24
|
+
Priority[Priority["AsyncP1"] = 1] = "AsyncP1";
|
|
25
|
+
Priority[Priority["AsyncP2"] = 2] = "AsyncP2";
|
|
26
|
+
})(Priority || (Priority = {}));
|
|
27
|
+
export class VBlock {
|
|
28
|
+
baseRender() {
|
|
29
|
+
return callRenderFunctions(this);
|
|
30
|
+
}
|
|
31
|
+
get isInitialRendering() {
|
|
32
|
+
return this.stamp === 2;
|
|
33
|
+
}
|
|
34
|
+
static root(render) {
|
|
35
|
+
gSysRoot.instance.args.render = render;
|
|
36
|
+
prepareAndRunRender(gSysRoot, false, false);
|
|
37
|
+
}
|
|
38
|
+
static get current() {
|
|
39
|
+
return gContext.instance;
|
|
40
|
+
}
|
|
41
|
+
static renderNestedTreesThenDo(action) {
|
|
42
|
+
runRenderNestedTreesThenDo(undefined, action);
|
|
43
|
+
}
|
|
44
|
+
static runForAllBlocks(action) {
|
|
45
|
+
forEachChildRecursively(gSysRoot, action);
|
|
46
|
+
}
|
|
47
|
+
static claim(name, args, driver) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
let result;
|
|
50
|
+
const owner = gContext.instance;
|
|
51
|
+
const children = owner.children;
|
|
52
|
+
let existing = undefined;
|
|
53
|
+
driver !== null && driver !== void 0 ? driver : (driver = AbstractDriver.group);
|
|
54
|
+
name || (name = `${++owner.numerator}`);
|
|
55
|
+
if (driver.isLine) {
|
|
56
|
+
const last = children.lastClaimedItem();
|
|
57
|
+
if (((_a = last === null || last === void 0 ? void 0 : last.instance) === null || _a === void 0 ? void 0 : _a.driver) === driver)
|
|
58
|
+
existing = last;
|
|
59
|
+
}
|
|
60
|
+
existing !== null && existing !== void 0 ? existing : (existing = children.claim(name));
|
|
61
|
+
if (existing) {
|
|
62
|
+
result = existing.instance;
|
|
63
|
+
if (result.driver !== driver && driver !== undefined)
|
|
64
|
+
throw new Error(`changing block driver is not yet supported: "${result.driver.name}" -> "${driver === null || driver === void 0 ? void 0 : driver.name}"`);
|
|
65
|
+
const exTriggers = (_b = result.args) === null || _b === void 0 ? void 0 : _b.triggers;
|
|
66
|
+
if (triggersAreEqual(args.triggers, exTriggers))
|
|
67
|
+
args.triggers = exTriggers;
|
|
68
|
+
result.args = args;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
result = new VBlockImpl(name, driver, owner, args);
|
|
72
|
+
result.item = children.add(result);
|
|
73
|
+
VBlockImpl.grandCount++;
|
|
74
|
+
if (args.reacting)
|
|
75
|
+
VBlockImpl.disposableCount++;
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
static getDefaultLoggingOptions() {
|
|
80
|
+
return VBlockImpl.logging;
|
|
81
|
+
}
|
|
82
|
+
static setDefaultLoggingOptions(logging) {
|
|
83
|
+
VBlockImpl.logging = logging;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
VBlock.shortFrameDuration = 16;
|
|
87
|
+
VBlock.longFrameDuration = 300;
|
|
88
|
+
VBlock.currentRenderingPriority = Priority.SyncP0;
|
|
89
|
+
VBlock.frameDuration = VBlock.longFrameDuration;
|
|
90
|
+
export var LayoutKind;
|
|
91
|
+
(function (LayoutKind) {
|
|
92
|
+
LayoutKind[LayoutKind["Block"] = 0] = "Block";
|
|
93
|
+
LayoutKind[LayoutKind["Grid"] = 1] = "Grid";
|
|
94
|
+
LayoutKind[LayoutKind["Line"] = 2] = "Line";
|
|
95
|
+
LayoutKind[LayoutKind["Group"] = 3] = "Group";
|
|
96
|
+
LayoutKind[LayoutKind["Text"] = 4] = "Text";
|
|
97
|
+
})(LayoutKind || (LayoutKind = {}));
|
|
98
|
+
const createDefaultAllocator = () => new Allocator();
|
|
99
|
+
export class AbstractDriver {
|
|
100
|
+
constructor(name, layout, createAllocator) {
|
|
101
|
+
this.name = name;
|
|
102
|
+
this.layout = layout;
|
|
103
|
+
this.createAllocator = createAllocator !== null && createAllocator !== void 0 ? createAllocator : createDefaultAllocator;
|
|
104
|
+
}
|
|
105
|
+
get isSequential() { return (this.layout & 1) === 0; }
|
|
106
|
+
get isAuxiliary() { return (this.layout & 2) === 2; }
|
|
107
|
+
get isBlock() { return this.layout === LayoutKind.Block; }
|
|
108
|
+
get isGrid() { return this.layout === LayoutKind.Grid; }
|
|
109
|
+
get isLine() { return this.layout === LayoutKind.Line; }
|
|
110
|
+
initialize(block, native) {
|
|
111
|
+
const b = block;
|
|
112
|
+
b.native = native;
|
|
113
|
+
}
|
|
114
|
+
finalize(block, isLeader) {
|
|
115
|
+
const b = block;
|
|
116
|
+
b.native = undefined;
|
|
117
|
+
return isLeader;
|
|
118
|
+
}
|
|
119
|
+
deploy(block, sequential) {
|
|
120
|
+
}
|
|
121
|
+
arrange(block, place, heightGrab) {
|
|
122
|
+
var _a, _b, _c;
|
|
123
|
+
const b = block;
|
|
124
|
+
if (heightGrab === undefined) {
|
|
125
|
+
b.place = place;
|
|
126
|
+
const host = b.host;
|
|
127
|
+
if (host.driver.isLine) {
|
|
128
|
+
const grab = (_a = place === null || place === void 0 ? void 0 : place.heightGrab) !== null && _a !== void 0 ? _a : 0;
|
|
129
|
+
if (grab > 0 && ((_c = (_b = host.place) === null || _b === void 0 ? void 0 : _b.heightGrab) !== null && _c !== void 0 ? _c : 0) < grab)
|
|
130
|
+
host.driver.arrange(host, undefined, grab);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (heightGrab > 0) {
|
|
134
|
+
if (b.place === undefined)
|
|
135
|
+
b.place = {
|
|
136
|
+
exact: undefined,
|
|
137
|
+
widthMin: "", widthMax: "", widthGrab: 0,
|
|
138
|
+
heightMin: "", heightMax: "", heightGrab,
|
|
139
|
+
align: To.Default,
|
|
140
|
+
dock: To.Default,
|
|
141
|
+
};
|
|
142
|
+
else
|
|
143
|
+
b.place.heightGrab = heightGrab;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
render(block) {
|
|
147
|
+
var _a;
|
|
148
|
+
let result;
|
|
149
|
+
const wrapper = (_a = block.args) === null || _a === void 0 ? void 0 : _a.wrapper;
|
|
150
|
+
if (wrapper)
|
|
151
|
+
result = wrapper(block.native, block);
|
|
152
|
+
else
|
|
153
|
+
result = callRenderFunctions(block);
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
AbstractDriver.group = new AbstractDriver("group", LayoutKind.Group);
|
|
158
|
+
function callRenderFunctions(block) {
|
|
159
|
+
var _a;
|
|
160
|
+
const uses = (_a = block.args) === null || _a === void 0 ? void 0 : _a.mixins;
|
|
161
|
+
if (uses)
|
|
162
|
+
for (const use of uses)
|
|
163
|
+
use(block.native, block);
|
|
164
|
+
return block.args.render(block.native, block);
|
|
165
|
+
}
|
|
166
|
+
export class StaticDriver extends AbstractDriver {
|
|
167
|
+
constructor(element, name, layout, createAllocator) {
|
|
168
|
+
super(name, layout, createAllocator);
|
|
169
|
+
this.element = element;
|
|
170
|
+
}
|
|
171
|
+
initialize(block, element) {
|
|
172
|
+
super.initialize(block, this.element);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function getBlockName(block) {
|
|
176
|
+
return block.stamp >= 0 ? block.name : undefined;
|
|
177
|
+
}
|
|
178
|
+
class VBlockImpl extends VBlock {
|
|
179
|
+
constructor(name, driver, owner, options) {
|
|
180
|
+
super();
|
|
181
|
+
this.name = name;
|
|
182
|
+
this.driver = driver;
|
|
183
|
+
this.args = options;
|
|
184
|
+
this.model = undefined;
|
|
185
|
+
this.level = owner.level + 1;
|
|
186
|
+
this.host = owner;
|
|
187
|
+
this.children = new Collection(driver.isSequential, getBlockName);
|
|
188
|
+
this.numerator = 0;
|
|
189
|
+
this.item = undefined;
|
|
190
|
+
this.stamp = 0;
|
|
191
|
+
this.native = undefined;
|
|
192
|
+
this.place = undefined;
|
|
193
|
+
this.allocator = driver.createAllocator();
|
|
194
|
+
}
|
|
195
|
+
rerender(_triggers) {
|
|
196
|
+
runRender(this.item);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
VBlockImpl.grandCount = 0;
|
|
200
|
+
VBlockImpl.disposableCount = 0;
|
|
201
|
+
VBlockImpl.logging = undefined;
|
|
202
|
+
__decorate([
|
|
203
|
+
reactive,
|
|
204
|
+
options({
|
|
205
|
+
reentrance: Reentrance.CancelPrevious,
|
|
206
|
+
triggeringArgs: true,
|
|
207
|
+
noSideEffects: false,
|
|
208
|
+
}),
|
|
209
|
+
__metadata("design:type", Function),
|
|
210
|
+
__metadata("design:paramtypes", [Object]),
|
|
211
|
+
__metadata("design:returntype", void 0)
|
|
212
|
+
], VBlockImpl.prototype, "rerender", null);
|
|
213
|
+
function runRenderNestedTreesThenDo(error, action) {
|
|
214
|
+
var _a;
|
|
215
|
+
const context = gContext;
|
|
216
|
+
const owner = context.instance;
|
|
217
|
+
const children = owner.children;
|
|
218
|
+
if (children.isMergeInProgress) {
|
|
219
|
+
let promised = undefined;
|
|
220
|
+
try {
|
|
221
|
+
children.endMerge(error);
|
|
222
|
+
for (const item of children.removedItems(true))
|
|
223
|
+
runFinalize(item, true);
|
|
224
|
+
if (!error) {
|
|
225
|
+
const isBlockOwner = owner.driver.isBlock;
|
|
226
|
+
const sequential = children.strict;
|
|
227
|
+
const allocator = owner.allocator;
|
|
228
|
+
allocator.reset();
|
|
229
|
+
let p1 = undefined;
|
|
230
|
+
let p2 = undefined;
|
|
231
|
+
let redeploy = false;
|
|
232
|
+
let lineHost = owner;
|
|
233
|
+
for (const item of children.items()) {
|
|
234
|
+
if (Transaction.isCanceled)
|
|
235
|
+
break;
|
|
236
|
+
const block = item.instance;
|
|
237
|
+
const driver = block.driver;
|
|
238
|
+
const opt = block.args;
|
|
239
|
+
if (!driver.isLine) {
|
|
240
|
+
const place = allocator.allocate(opt);
|
|
241
|
+
driver.arrange(block, place, undefined);
|
|
242
|
+
}
|
|
243
|
+
else
|
|
244
|
+
allocator.lineFeed();
|
|
245
|
+
const host = driver.isLine ? owner : lineHost;
|
|
246
|
+
redeploy = markToRedeployIfNecessary(redeploy, host, item, children, sequential);
|
|
247
|
+
const priority = (_a = opt === null || opt === void 0 ? void 0 : opt.priority) !== null && _a !== void 0 ? _a : Priority.SyncP0;
|
|
248
|
+
if (priority === Priority.SyncP0)
|
|
249
|
+
prepareAndRunRender(item, children.isMoved(item), sequential);
|
|
250
|
+
else if (priority === Priority.AsyncP1)
|
|
251
|
+
p1 = push(item, p1);
|
|
252
|
+
else
|
|
253
|
+
p2 = push(item, p2);
|
|
254
|
+
if (isBlockOwner && driver.isLine)
|
|
255
|
+
lineHost = block;
|
|
256
|
+
}
|
|
257
|
+
if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
|
|
258
|
+
promised = startIncrementalRendering(context, children, p1, p2).then(() => action(error), e => action(e));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
if (!promised)
|
|
263
|
+
action(error);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function markToRedeployIfNecessary(redeploy, host, item, children, sequential) {
|
|
268
|
+
const block = item.instance;
|
|
269
|
+
if (block.native) {
|
|
270
|
+
if (redeploy || block.host !== host) {
|
|
271
|
+
children.markAsMoved(item);
|
|
272
|
+
redeploy = false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else if (sequential && children.isMoved(item))
|
|
276
|
+
redeploy = true;
|
|
277
|
+
block.host = host;
|
|
278
|
+
return redeploy;
|
|
279
|
+
}
|
|
280
|
+
function startIncrementalRendering(owner, allChildren, priority1, priority2) {
|
|
281
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
282
|
+
const stamp = owner.instance.stamp;
|
|
283
|
+
if (priority1)
|
|
284
|
+
yield renderIncrementally(owner, stamp, allChildren, priority1, Priority.AsyncP1);
|
|
285
|
+
if (priority2)
|
|
286
|
+
yield renderIncrementally(owner, stamp, allChildren, priority2, Priority.AsyncP2);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function renderIncrementally(owner, stamp, allChildren, items, priority) {
|
|
290
|
+
var _a;
|
|
291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
yield Transaction.requestNextFrame();
|
|
293
|
+
const block = owner.instance;
|
|
294
|
+
if (!Transaction.isCanceled || !Transaction.isFrameOver(1, VBlock.shortFrameDuration / 3)) {
|
|
295
|
+
let outerPriority = VBlock.currentRenderingPriority;
|
|
296
|
+
VBlock.currentRenderingPriority = priority;
|
|
297
|
+
try {
|
|
298
|
+
const sequential = block.children.strict;
|
|
299
|
+
if ((_a = block.args) === null || _a === void 0 ? void 0 : _a.shuffle)
|
|
300
|
+
shuffle(items);
|
|
301
|
+
const frameDurationLimit = priority === Priority.AsyncP2 ? VBlock.shortFrameDuration : Infinity;
|
|
302
|
+
let frameDuration = Math.min(frameDurationLimit, Math.max(VBlock.frameDuration / 4, VBlock.shortFrameDuration));
|
|
303
|
+
for (const child of items) {
|
|
304
|
+
prepareAndRunRender(child, allChildren.isMoved(child), sequential);
|
|
305
|
+
if (Transaction.isFrameOver(1, frameDuration)) {
|
|
306
|
+
VBlock.currentRenderingPriority = outerPriority;
|
|
307
|
+
yield Transaction.requestNextFrame(0);
|
|
308
|
+
outerPriority = VBlock.currentRenderingPriority;
|
|
309
|
+
VBlock.currentRenderingPriority = priority;
|
|
310
|
+
frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, VBlock.frameDuration));
|
|
311
|
+
}
|
|
312
|
+
if (Transaction.isCanceled && Transaction.isFrameOver(1, VBlock.shortFrameDuration / 3))
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
finally {
|
|
317
|
+
VBlock.currentRenderingPriority = outerPriority;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
function prepareAndRunRender(item, redeploy, sequential) {
|
|
323
|
+
var _a, _b;
|
|
324
|
+
const block = item.instance;
|
|
325
|
+
if (block.stamp >= 0) {
|
|
326
|
+
prepareRender(item, redeploy, sequential);
|
|
327
|
+
if ((_a = block.args) === null || _a === void 0 ? void 0 : _a.reacting)
|
|
328
|
+
nonreactive(block.rerender, (_b = block.args) === null || _b === void 0 ? void 0 : _b.triggers);
|
|
329
|
+
else
|
|
330
|
+
runRender(item);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function prepareRender(item, redeploy, sequential) {
|
|
334
|
+
var _a;
|
|
335
|
+
const block = item.instance;
|
|
336
|
+
const driver = block.driver;
|
|
337
|
+
if (block.stamp === 0) {
|
|
338
|
+
block.stamp = 1;
|
|
339
|
+
if ((_a = block.args) === null || _a === void 0 ? void 0 : _a.reacting) {
|
|
340
|
+
Transaction.outside(() => {
|
|
341
|
+
var _a, _b, _c;
|
|
342
|
+
if (Rx.isLogging)
|
|
343
|
+
Rx.setLoggingHint(block, block.name);
|
|
344
|
+
Rx.getController(block.rerender).configure({
|
|
345
|
+
order: block.level,
|
|
346
|
+
monitor: (_a = block.args) === null || _a === void 0 ? void 0 : _a.monitor,
|
|
347
|
+
throttling: (_b = block.args) === null || _b === void 0 ? void 0 : _b.throttling,
|
|
348
|
+
logging: (_c = block.args) === null || _c === void 0 ? void 0 : _c.logging,
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
driver.initialize(block, undefined);
|
|
353
|
+
driver.deploy(block, sequential);
|
|
354
|
+
driver.arrange(block, block.place, undefined);
|
|
355
|
+
}
|
|
356
|
+
else if (redeploy)
|
|
357
|
+
driver.deploy(block, sequential);
|
|
358
|
+
}
|
|
359
|
+
function runRender(item) {
|
|
360
|
+
const block = item.instance;
|
|
361
|
+
if (block.stamp >= 0) {
|
|
362
|
+
runUnder(item, () => {
|
|
363
|
+
let result = undefined;
|
|
364
|
+
try {
|
|
365
|
+
block.stamp++;
|
|
366
|
+
block.numerator = 0;
|
|
367
|
+
block.children.beginMerge();
|
|
368
|
+
result = block.driver.render(block);
|
|
369
|
+
if (result instanceof Promise)
|
|
370
|
+
result.then(v => { runRenderNestedTreesThenDo(undefined, NOP); return v; }, e => { console.log(e); runRenderNestedTreesThenDo(e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
|
|
371
|
+
else
|
|
372
|
+
runRenderNestedTreesThenDo(undefined, NOP);
|
|
373
|
+
}
|
|
374
|
+
catch (e) {
|
|
375
|
+
runRenderNestedTreesThenDo(e, NOP);
|
|
376
|
+
console.log(`Rendering failed: ${block.name}`);
|
|
377
|
+
console.log(`${e}`);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function runFinalize(item, isLeader) {
|
|
383
|
+
var _a;
|
|
384
|
+
const block = item.instance;
|
|
385
|
+
if (block.stamp >= 0) {
|
|
386
|
+
block.stamp = ~block.stamp;
|
|
387
|
+
const childrenAreLeaders = block.driver.finalize(block, isLeader);
|
|
388
|
+
if ((_a = block.args) === null || _a === void 0 ? void 0 : _a.reacting) {
|
|
389
|
+
item.aux = undefined;
|
|
390
|
+
const last = gLastToDispose;
|
|
391
|
+
if (last)
|
|
392
|
+
gLastToDispose = last.aux = item;
|
|
393
|
+
else
|
|
394
|
+
gFirstToDispose = gLastToDispose = item;
|
|
395
|
+
if (gFirstToDispose === item)
|
|
396
|
+
Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${item.instance.name})` }, () => {
|
|
397
|
+
void runDisposalLoop().then(NOP, error => console.log(error));
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
for (const item of block.children.items())
|
|
401
|
+
runFinalize(item, childrenAreLeaders);
|
|
402
|
+
VBlockImpl.grandCount--;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function runDisposalLoop() {
|
|
406
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
407
|
+
yield Transaction.requestNextFrame();
|
|
408
|
+
let item = gFirstToDispose;
|
|
409
|
+
while (item !== undefined) {
|
|
410
|
+
if (Transaction.isFrameOver(500, 5))
|
|
411
|
+
yield Transaction.requestNextFrame();
|
|
412
|
+
Rx.dispose(item.instance);
|
|
413
|
+
item = item.aux;
|
|
414
|
+
VBlockImpl.disposableCount--;
|
|
415
|
+
}
|
|
416
|
+
gFirstToDispose = gLastToDispose = undefined;
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
function forEachChildRecursively(item, action) {
|
|
420
|
+
const block = item.instance;
|
|
421
|
+
const native = block.native;
|
|
422
|
+
native && action(native);
|
|
423
|
+
for (const item of block.children.items())
|
|
424
|
+
forEachChildRecursively(item, action);
|
|
425
|
+
}
|
|
426
|
+
function wrap(func) {
|
|
427
|
+
const ctx = gContext;
|
|
428
|
+
const wrappedRunUnder = (...args) => {
|
|
429
|
+
return runUnder(ctx, func, ...args);
|
|
430
|
+
};
|
|
431
|
+
return wrappedRunUnder;
|
|
432
|
+
}
|
|
433
|
+
function runUnder(item, func, ...args) {
|
|
434
|
+
const outer = gContext;
|
|
435
|
+
try {
|
|
436
|
+
gContext = item;
|
|
437
|
+
return func(...args);
|
|
438
|
+
}
|
|
439
|
+
finally {
|
|
440
|
+
gContext = outer;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function triggersAreEqual(a1, a2) {
|
|
444
|
+
let result = a1 === a2;
|
|
445
|
+
if (!result) {
|
|
446
|
+
if (Array.isArray(a1)) {
|
|
447
|
+
result = Array.isArray(a2) &&
|
|
448
|
+
a1.length === a2.length &&
|
|
449
|
+
a1.every((t, i) => t === a2[i]);
|
|
450
|
+
}
|
|
451
|
+
else if (a1 === Object(a1) && a2 === Object(a2)) {
|
|
452
|
+
for (const p in a1) {
|
|
453
|
+
result = a1[p] === a2[p];
|
|
454
|
+
if (!result)
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return result;
|
|
460
|
+
}
|
|
461
|
+
function push(item, array) {
|
|
462
|
+
if (array == undefined)
|
|
463
|
+
array = new Array();
|
|
464
|
+
array.push(item);
|
|
465
|
+
return array;
|
|
466
|
+
}
|
|
467
|
+
function shuffle(array) {
|
|
468
|
+
const n = array.length - 1;
|
|
469
|
+
let i = n;
|
|
470
|
+
while (i >= 0) {
|
|
471
|
+
const j = Math.floor(Math.random() * n);
|
|
472
|
+
const t = array[i];
|
|
473
|
+
array[i] = array[j];
|
|
474
|
+
array[j] = t;
|
|
475
|
+
i--;
|
|
476
|
+
}
|
|
477
|
+
return array;
|
|
478
|
+
}
|
|
479
|
+
const ORIGINAL_PROMISE_THEN = Promise.prototype.then;
|
|
480
|
+
function reactronicDomHookedThen(resolve, reject) {
|
|
481
|
+
resolve = resolve ? wrap(resolve) : defaultResolve;
|
|
482
|
+
reject = reject ? wrap(reject) : defaultReject;
|
|
483
|
+
return ORIGINAL_PROMISE_THEN.call(this, resolve, reject);
|
|
484
|
+
}
|
|
485
|
+
function defaultResolve(value) {
|
|
486
|
+
return value;
|
|
487
|
+
}
|
|
488
|
+
function defaultReject(error) {
|
|
489
|
+
throw error;
|
|
490
|
+
}
|
|
491
|
+
Promise.prototype.then = reactronicDomHookedThen;
|
|
492
|
+
const NOP = () => { };
|
|
493
|
+
const gSysDriver = new StaticDriver(null, "SYSTEM", LayoutKind.Group);
|
|
494
|
+
const gSysRoot = Collection.createItem(new VBlockImpl("SYSTEM", gSysDriver, { level: 0 }, { reacting: true, render: NOP }));
|
|
495
|
+
gSysRoot.instance.item = gSysRoot;
|
|
496
|
+
Object.defineProperty(gSysRoot.instance, "host", {
|
|
497
|
+
value: gSysRoot.instance,
|
|
498
|
+
writable: false,
|
|
499
|
+
configurable: false,
|
|
500
|
+
enumerable: true,
|
|
501
|
+
});
|
|
502
|
+
let gContext = gSysRoot;
|
|
503
|
+
let gFirstToDispose = undefined;
|
|
504
|
+
let gLastToDispose = undefined;
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { cached, Transaction } from
|
|
10
|
+
import { cached, Transaction } from "reactronic";
|
|
11
11
|
export function restyler(restyle) {
|
|
12
12
|
return Transaction.run(null, () => new ObservablesStyles(restyle));
|
|
13
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./Utils";
|
|
2
|
+
export * from "./CellRange";
|
|
3
|
+
export * from "./Allocator";
|
|
4
|
+
export * from "./Kernel";
|
|
5
|
+
export * from "./Restyler";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./Utils";
|
|
2
|
+
export * from "./CellRange";
|
|
3
|
+
export * from "./Allocator";
|
|
4
|
+
export * from "./Kernel";
|
|
5
|
+
export * from "./Restyler";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { VBlock, Place, BlockArgs } from "../core/api";
|
|
2
|
+
import { HtmlDriver } from "./HtmlDriver";
|
|
3
|
+
export declare function Block<M = unknown, R = void>(name: string, args: BlockArgs<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
4
|
+
export declare function PlainText(content: string): VBlock<HTMLElement, void, void>;
|
|
5
|
+
export declare function MdText(content: string): VBlock<HTMLElement, void, void>;
|
|
6
|
+
export declare function HtmlText(content: string): VBlock<HTMLElement, void, void>;
|
|
7
|
+
export declare function Grid<M = unknown, R = void>(name: string, args: BlockArgs<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
8
|
+
export declare function Line<T = void>(claim: (x: void) => T): VBlock<HTMLElement>;
|
|
9
|
+
export declare function lineFeed(args?: BlockArgs<HTMLElement, void, void>, noCoalescing?: boolean): VBlock<HTMLElement>;
|
|
10
|
+
export declare function Group<M = unknown, R = void>(name: string, args: BlockArgs<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
11
|
+
export declare class VerstakDriver<T extends HTMLElement> extends HtmlDriver<T> {
|
|
12
|
+
arrange(block: VBlock<T>, place: Place | undefined, heightGrab: number | undefined): void;
|
|
13
|
+
render(block: VBlock<T>): void | Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { VBlock, LayoutKind, To, GridBasedAllocator } from "../core/api";
|
|
2
|
+
import { HtmlDriver } from "./HtmlDriver";
|
|
3
|
+
export function Block(name, args) {
|
|
4
|
+
return VBlock.claim(name, args, VerstakTags.block);
|
|
5
|
+
}
|
|
6
|
+
export function PlainText(content) {
|
|
7
|
+
return VBlock.claim("", { render(e) { e.innerText = content; } }, VerstakTags.text);
|
|
8
|
+
}
|
|
9
|
+
export function MdText(content) {
|
|
10
|
+
return VBlock.claim("", { render(e) { e.innerHTML = content; } }, VerstakTags.text);
|
|
11
|
+
}
|
|
12
|
+
export function HtmlText(content) {
|
|
13
|
+
return VBlock.claim("", { render(e) { e.innerHTML = content; } }, VerstakTags.text);
|
|
14
|
+
}
|
|
15
|
+
export function Grid(name, args) {
|
|
16
|
+
return VBlock.claim(name, args, VerstakTags.grid);
|
|
17
|
+
}
|
|
18
|
+
export function Line(claim) {
|
|
19
|
+
const result = VBlock.claim("", EMPTY_RENDER, VerstakTags.line);
|
|
20
|
+
claim();
|
|
21
|
+
VBlock.claim("", EMPTY_RENDER, VerstakTags.line);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
export function lineFeed(args, noCoalescing) {
|
|
25
|
+
return VBlock.claim("", args !== null && args !== void 0 ? args : EMPTY_RENDER, VerstakTags.line);
|
|
26
|
+
}
|
|
27
|
+
export function Group(name, args) {
|
|
28
|
+
return VBlock.claim(name, args, VerstakTags.group);
|
|
29
|
+
}
|
|
30
|
+
export class VerstakDriver extends HtmlDriver {
|
|
31
|
+
arrange(block, place, heightGrab) {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
33
|
+
if (block.native) {
|
|
34
|
+
if (heightGrab === undefined) {
|
|
35
|
+
const existing = block.stamp > 1 ? block.place : undefined;
|
|
36
|
+
if (place !== existing) {
|
|
37
|
+
const css = block.native.style;
|
|
38
|
+
const exact = place === null || place === void 0 ? void 0 : place.exact;
|
|
39
|
+
if (exact !== (existing === null || existing === void 0 ? void 0 : existing.exact)) {
|
|
40
|
+
if (exact) {
|
|
41
|
+
const x1 = exact.x1 || 1;
|
|
42
|
+
const y1 = exact.y1 || 1;
|
|
43
|
+
const x2 = exact.x2 || x1;
|
|
44
|
+
const y2 = exact.y2 || y1;
|
|
45
|
+
css.gridArea = `${y1} / ${x1} / span ${y2 - y1 + 1} / span ${x2 - x1 + 1}`;
|
|
46
|
+
}
|
|
47
|
+
else
|
|
48
|
+
css.gridArea = "";
|
|
49
|
+
}
|
|
50
|
+
const widthGrab = (_a = place === null || place === void 0 ? void 0 : place.widthGrab) !== null && _a !== void 0 ? _a : 0;
|
|
51
|
+
if (widthGrab !== ((_b = existing === null || existing === void 0 ? void 0 : existing.widthGrab) !== null && _b !== void 0 ? _b : 0)) {
|
|
52
|
+
if (widthGrab > 0)
|
|
53
|
+
css.flexGrow = `${widthGrab}`;
|
|
54
|
+
else
|
|
55
|
+
css.flexGrow = "";
|
|
56
|
+
}
|
|
57
|
+
const widthMin = (_c = place === null || place === void 0 ? void 0 : place.widthMin) !== null && _c !== void 0 ? _c : "";
|
|
58
|
+
if (widthMin !== ((_d = existing === null || existing === void 0 ? void 0 : existing.widthMin) !== null && _d !== void 0 ? _d : ""))
|
|
59
|
+
css.minWidth = `${widthMin}`;
|
|
60
|
+
const widthMax = (_e = place === null || place === void 0 ? void 0 : place.widthMax) !== null && _e !== void 0 ? _e : "";
|
|
61
|
+
if (widthMax !== ((_f = existing === null || existing === void 0 ? void 0 : existing.widthMax) !== null && _f !== void 0 ? _f : ""))
|
|
62
|
+
css.maxWidth = `${widthMax}`;
|
|
63
|
+
const heightMin = (_g = place === null || place === void 0 ? void 0 : place.heightMin) !== null && _g !== void 0 ? _g : "";
|
|
64
|
+
if (heightMin !== ((_h = existing === null || existing === void 0 ? void 0 : existing.heightMin) !== null && _h !== void 0 ? _h : ""))
|
|
65
|
+
css.minHeight = `${heightMin}`;
|
|
66
|
+
const heightMax = (_j = place === null || place === void 0 ? void 0 : place.heightMax) !== null && _j !== void 0 ? _j : "";
|
|
67
|
+
if (heightMax !== ((_k = existing === null || existing === void 0 ? void 0 : existing.heightMax) !== null && _k !== void 0 ? _k : ""))
|
|
68
|
+
css.maxHeight = `${heightMax}`;
|
|
69
|
+
const align = (_l = place === null || place === void 0 ? void 0 : place.align) !== null && _l !== void 0 ? _l : To.Default;
|
|
70
|
+
if (align !== ((_m = existing === null || existing === void 0 ? void 0 : existing.align) !== null && _m !== void 0 ? _m : To.Default)) {
|
|
71
|
+
if ((align & To.Default) === 0) {
|
|
72
|
+
const v = AlignCss[(align >> 2) & 0b11];
|
|
73
|
+
const h = AlignCss[align & 0b11];
|
|
74
|
+
const t = TextAlignCss[align & 0b11];
|
|
75
|
+
css.justifyContent = v;
|
|
76
|
+
css.alignItems = h;
|
|
77
|
+
css.textAlign = t;
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
css.justifyContent = css.alignItems = css.textAlign = "";
|
|
81
|
+
}
|
|
82
|
+
const heightGrab = (_o = place === null || place === void 0 ? void 0 : place.heightGrab) !== null && _o !== void 0 ? _o : 0;
|
|
83
|
+
const dock = (_p = place === null || place === void 0 ? void 0 : place.dock) !== null && _p !== void 0 ? _p : To.Default;
|
|
84
|
+
if (dock !== ((_q = existing === null || existing === void 0 ? void 0 : existing.dock) !== null && _q !== void 0 ? _q : To.Default) ||
|
|
85
|
+
heightGrab !== ((_r = existing === null || existing === void 0 ? void 0 : existing.heightGrab) !== null && _r !== void 0 ? _r : 0)) {
|
|
86
|
+
if ((dock & To.Default) === 0) {
|
|
87
|
+
const v = AlignCss[(dock >> 2) & 0b11];
|
|
88
|
+
const h = AlignCss[dock & 0b11];
|
|
89
|
+
css.alignSelf = v;
|
|
90
|
+
css.justifySelf = h;
|
|
91
|
+
}
|
|
92
|
+
else if (heightGrab > 0) {
|
|
93
|
+
css.alignSelf = AlignCss[To.Fit];
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
css.alignSelf = css.justifySelf = "";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (heightGrab > 0)
|
|
102
|
+
block.native.style.flexGrow = `${heightGrab}`;
|
|
103
|
+
else
|
|
104
|
+
block.native.style.flexGrow = "";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
super.arrange(block, place, heightGrab);
|
|
108
|
+
}
|
|
109
|
+
render(block) {
|
|
110
|
+
if (!block.driver.isLine)
|
|
111
|
+
VBlock.claim("", EMPTY_RENDER, VerstakTags.line);
|
|
112
|
+
return super.render(block);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const VerstakTags = {
|
|
116
|
+
block: new VerstakDriver("v-block", LayoutKind.Block),
|
|
117
|
+
text: new VerstakDriver("v-text", LayoutKind.Text),
|
|
118
|
+
grid: new VerstakDriver("v-grid", LayoutKind.Grid, () => new GridBasedAllocator()),
|
|
119
|
+
line: new VerstakDriver("v-line", LayoutKind.Line),
|
|
120
|
+
group: new VerstakDriver("v-group", LayoutKind.Group),
|
|
121
|
+
};
|
|
122
|
+
const EMPTY_RENDER = { render() { } };
|
|
123
|
+
const AlignCss = ["stretch", "start", "center", "end"];
|
|
124
|
+
const TextAlignCss = ["justify", "left", "center", "right"];
|