verstak 0.22.500 → 0.22.504

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