verstak 0.22.412

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 (59) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +28 -0
  3. package/build/dist/source/api.d.ts +2 -0
  4. package/build/dist/source/api.js +2 -0
  5. package/build/dist/source/archive/RxDomV1.Types.d.ts +46 -0
  6. package/build/dist/source/archive/RxDomV1.Types.js +22 -0
  7. package/build/dist/source/archive/RxDomV1.d.ts +45 -0
  8. package/build/dist/source/archive/RxDomV1.js +556 -0
  9. package/build/dist/source/core/Elements.d.ts +4 -0
  10. package/build/dist/source/core/Elements.js +7 -0
  11. package/build/dist/source/core/Restyler.d.ts +7 -0
  12. package/build/dist/source/core/Restyler.js +30 -0
  13. package/build/dist/source/core/RxNode.d.ts +59 -0
  14. package/build/dist/source/core/RxNode.js +426 -0
  15. package/build/dist/source/core/Utils.d.ts +1 -0
  16. package/build/dist/source/core/Utils.js +3 -0
  17. package/build/dist/source/core/api.d.ts +4 -0
  18. package/build/dist/source/core/api.js +4 -0
  19. package/build/dist/source/html/CellRange.d.ts +11 -0
  20. package/build/dist/source/html/CellRange.js +175 -0
  21. package/build/dist/source/html/HtmlApiExt.d.ts +7 -0
  22. package/build/dist/source/html/HtmlApiExt.js +25 -0
  23. package/build/dist/source/html/HtmlElements.d.ts +349 -0
  24. package/build/dist/source/html/HtmlElements.js +529 -0
  25. package/build/dist/source/html/HtmlNodeFactory.d.ts +19 -0
  26. package/build/dist/source/html/HtmlNodeFactory.js +96 -0
  27. package/build/dist/source/html/RxFocuser.d.ts +2 -0
  28. package/build/dist/source/html/RxFocuser.js +11 -0
  29. package/build/dist/source/html/api.d.ts +18 -0
  30. package/build/dist/source/html/api.js +18 -0
  31. package/build/dist/source/html/sensors/BasePointerSensor.d.ts +18 -0
  32. package/build/dist/source/html/sensors/BasePointerSensor.js +32 -0
  33. package/build/dist/source/html/sensors/ButtonSensor.d.ts +32 -0
  34. package/build/dist/source/html/sensors/ButtonSensor.js +211 -0
  35. package/build/dist/source/html/sensors/DataForSensor.d.ts +27 -0
  36. package/build/dist/source/html/sensors/DataForSensor.js +72 -0
  37. package/build/dist/source/html/sensors/FocusSensor.d.ts +29 -0
  38. package/build/dist/source/html/sensors/FocusSensor.js +182 -0
  39. package/build/dist/source/html/sensors/HoverSensor.d.ts +10 -0
  40. package/build/dist/source/html/sensors/HoverSensor.js +80 -0
  41. package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +61 -0
  42. package/build/dist/source/html/sensors/HtmlDragSensor.js +386 -0
  43. package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +13 -0
  44. package/build/dist/source/html/sensors/HtmlElementSensor.js +53 -0
  45. package/build/dist/source/html/sensors/HtmlSensors.d.ts +22 -0
  46. package/build/dist/source/html/sensors/HtmlSensors.js +47 -0
  47. package/build/dist/source/html/sensors/KeyboardSensor.d.ts +33 -0
  48. package/build/dist/source/html/sensors/KeyboardSensor.js +143 -0
  49. package/build/dist/source/html/sensors/PointerSensor.d.ts +60 -0
  50. package/build/dist/source/html/sensors/PointerSensor.js +394 -0
  51. package/build/dist/source/html/sensors/ResizeSensor.d.ts +18 -0
  52. package/build/dist/source/html/sensors/ResizeSensor.js +72 -0
  53. package/build/dist/source/html/sensors/Sensor.d.ts +6 -0
  54. package/build/dist/source/html/sensors/Sensor.js +11 -0
  55. package/build/dist/source/html/sensors/WheelSensor.d.ts +13 -0
  56. package/build/dist/source/html/sensors/WheelSensor.js +86 -0
  57. package/build/dist/source/html/sensors/WindowSensor.d.ts +10 -0
  58. package/build/dist/source/html/sensors/WindowSensor.js +38 -0
  59. package/package.json +54 -0
@@ -0,0 +1,556 @@
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, Rx, options, Reentrance } from 'reactronic';
20
+ import { RxNode } from './RxDomV1.Types';
21
+ export class BasicNodeType {
22
+ constructor(name, sequential) {
23
+ this.name = name;
24
+ this.sequential = sequential;
25
+ }
26
+ initialize(node) {
27
+ if (!node.inline)
28
+ Rx.setLoggingHint(node, node.id);
29
+ }
30
+ render(node, args) {
31
+ const inst = node.instance;
32
+ if (!inst)
33
+ throw new Error('element must be initialized before rendering');
34
+ if (inst.buffer)
35
+ throw new Error('rendering re-entrance is not supported yet');
36
+ inst.buffer = [];
37
+ let result;
38
+ if (node.superRender)
39
+ result = node.superRender(options => {
40
+ const res = node.render(inst.native, options);
41
+ if (res instanceof Promise)
42
+ return res.then();
43
+ else
44
+ return options;
45
+ }, inst.native);
46
+ else
47
+ result = node.render(inst.native, args);
48
+ if (result instanceof Promise)
49
+ result = result.then(value => { RxDom.renderChildrenThenDo(NOP); return value; }, error => { console.log(error); RxDom.renderChildrenThenDo(NOP); });
50
+ else
51
+ RxDom.renderChildrenThenDo(NOP);
52
+ }
53
+ finalize(node, initiator) {
54
+ const inst = node.instance;
55
+ if (inst) {
56
+ inst.native = undefined;
57
+ if (!node.inline && node.instance)
58
+ Transaction.separate(() => Rx.dispose(node.instance));
59
+ for (const x of inst.children)
60
+ tryToFinalize(x, initiator);
61
+ for (const x of inst.guests)
62
+ tryToFinalize(x, initiator);
63
+ }
64
+ }
65
+ }
66
+ export class RxNodeInstanceImpl {
67
+ constructor(level) {
68
+ this.revision = ~0;
69
+ this.native = undefined;
70
+ this.model = undefined;
71
+ this.children = EMPTY;
72
+ this.buffer = undefined;
73
+ this.guests = EMPTY;
74
+ this.resizeObserver = undefined;
75
+ this.uuid = ++RxNodeInstanceImpl.gUuid;
76
+ this.level = level;
77
+ }
78
+ rerender(node) {
79
+ invokeRender(node, node.args);
80
+ Rx.configureCurrentOperation({ order: this.level });
81
+ }
82
+ }
83
+ RxNodeInstanceImpl.gUuid = 0;
84
+ __decorate([
85
+ reactive,
86
+ options({
87
+ reentrance: Reentrance.CancelPrevious,
88
+ triggeringArgs: true,
89
+ noSideEffects: true
90
+ }),
91
+ __metadata("design:type", Function),
92
+ __metadata("design:paramtypes", [RxNode]),
93
+ __metadata("design:returntype", void 0)
94
+ ], RxNodeInstanceImpl.prototype, "rerender", null);
95
+ export class RxDom {
96
+ static Root(render) {
97
+ const inst = SYSTEM.instance;
98
+ if (inst.buffer)
99
+ throw new Error('rendering re-entrance is not supported yet');
100
+ inst.buffer = [];
101
+ let result = render();
102
+ if (result instanceof Promise)
103
+ result = result.then(value => { Transaction.run(null, RxDom.renderChildrenThenDo, NOP); return value; }, error => { console.log(error); Transaction.run(null, RxDom.renderChildrenThenDo, NOP); });
104
+ else
105
+ Transaction.run(null, RxDom.renderChildrenThenDo, NOP);
106
+ return result;
107
+ }
108
+ static Node(id, args, render, superRender, type, inline, creator, host) {
109
+ var _a, _b;
110
+ const o = creator !== null && creator !== void 0 ? creator : gCreator;
111
+ const inst = o.instance;
112
+ if (!inst)
113
+ throw new Error('element must be initialized before children');
114
+ if (type === undefined)
115
+ type = RxDom.basic;
116
+ if (!host)
117
+ host = gHost;
118
+ const node = new RxNode(id, args, render, superRender, 0, false, type, inline !== null && inline !== void 0 ? inline : false, o, host);
119
+ if (inst.buffer === undefined)
120
+ throw new Error('children are rendered already');
121
+ const rev = (_b = (_a = host.instance) === null || _a === void 0 ? void 0 : _a.revision) !== null && _b !== void 0 ? _b : ~1;
122
+ if (rev >= ~0)
123
+ inst.buffer.push(node);
124
+ return node;
125
+ }
126
+ static renderChildrenThenDo(action) {
127
+ const node = gCreator;
128
+ if (node.type.sequential)
129
+ RxDom.mergeAndRenderSequentialChildren(node, action);
130
+ else
131
+ RxDom.mergeAndRenderChildren(node, action);
132
+ }
133
+ static usingAnotherHost(host, run) {
134
+ var _a;
135
+ const native = (_a = host.instance) === null || _a === void 0 ? void 0 : _a.native;
136
+ if (native !== undefined) {
137
+ const outer = gHost;
138
+ try {
139
+ gHost = host;
140
+ run(native);
141
+ }
142
+ finally {
143
+ gHost = outer;
144
+ }
145
+ }
146
+ }
147
+ static createRootNode(id, sequential, native) {
148
+ const inst = new RxNodeInstanceImpl(0);
149
+ const node = new RxNode(id, null, () => { }, undefined, 0, false, { name: id, sequential }, false, {}, {}, inst);
150
+ const a = node;
151
+ a['creator'] = node;
152
+ a['host'] = node;
153
+ inst.native = native;
154
+ return node;
155
+ }
156
+ static get self() {
157
+ return gCreator;
158
+ }
159
+ static currentNodeInstance() {
160
+ const inst = gCreator.instance;
161
+ if (!inst)
162
+ throw new Error('currentNodeInstance function can be called only inside rendering function');
163
+ return inst;
164
+ }
165
+ static currentNodeInstanceInternal() {
166
+ const inst = gCreator.instance;
167
+ if (!inst)
168
+ throw new Error('currentNodeInstanceInternal function can be called only inside rendering function');
169
+ return inst;
170
+ }
171
+ static currentNodeRevision() {
172
+ var _a, _b;
173
+ return (_b = (_a = gCreator.instance) === null || _a === void 0 ? void 0 : _a.revision) !== null && _b !== void 0 ? _b : ~0;
174
+ }
175
+ static forAll(action) {
176
+ RxDom.forEachChildRecursively(SYSTEM, action);
177
+ }
178
+ static mergeAndRenderSequentialChildren(node, finish) {
179
+ var _a, _b, _c;
180
+ const inst = node.instance;
181
+ if (inst !== undefined && inst.buffer !== undefined) {
182
+ try {
183
+ const existing = inst.children;
184
+ const sequenced = inst.buffer;
185
+ const sorted = sequenced.slice().sort(compareNodes);
186
+ inst.buffer = undefined;
187
+ let host = inst;
188
+ let guests = EMPTY;
189
+ let sibling = undefined;
190
+ let i = 0, j = 0;
191
+ while (i < existing.length) {
192
+ const old = existing[i];
193
+ const x = sorted[j];
194
+ const diff = x !== undefined ? compareNodes(x, old) : 1;
195
+ if (diff <= 0) {
196
+ const h = x.host.instance;
197
+ if (h !== inst) {
198
+ if (h !== host) {
199
+ RxDom.mergeGuests(host, inst, guests);
200
+ guests = [];
201
+ host = h;
202
+ }
203
+ guests.push(x);
204
+ }
205
+ if (sibling !== undefined && x.id === sibling.id)
206
+ throw new Error(`duplicate id '${sibling.id}' inside '${node.id}'`);
207
+ if (diff === 0) {
208
+ x.instance = old.instance;
209
+ x.old = old;
210
+ i++, j++;
211
+ }
212
+ else
213
+ j++;
214
+ sibling = x;
215
+ }
216
+ else {
217
+ if (!Transaction.isCanceled)
218
+ tryToFinalize(old, old);
219
+ i++;
220
+ }
221
+ }
222
+ if (host !== inst)
223
+ RxDom.mergeGuests(host, inst, guests);
224
+ sibling = undefined;
225
+ i = 0;
226
+ while (i < sequenced.length && !Transaction.isCanceled) {
227
+ const x = sequenced[i];
228
+ const old = x.old;
229
+ x.old = undefined;
230
+ x.prevSibling = sibling;
231
+ const instance = x.instance;
232
+ if (old && instance) {
233
+ if ((sibling === null || sibling === void 0 ? void 0 : sibling.instance) !== ((_a = old.prevSibling) === null || _a === void 0 ? void 0 : _a.instance))
234
+ (_c = (_b = x.type).mount) === null || _c === void 0 ? void 0 : _c.call(_b, x);
235
+ if (x.inline || !argsAreEqual(x.args, old.args))
236
+ tryToRender(x);
237
+ }
238
+ else {
239
+ tryToInitialize(x);
240
+ tryToRender(x);
241
+ }
242
+ if (x.native)
243
+ sibling = x;
244
+ i++;
245
+ }
246
+ if (!Transaction.isCanceled)
247
+ inst.children = sorted;
248
+ }
249
+ finally {
250
+ finish();
251
+ }
252
+ }
253
+ }
254
+ static mergeAndRenderChildren(node, finish) {
255
+ const inst = node.instance;
256
+ if (inst !== undefined && inst.buffer !== undefined) {
257
+ let promised = undefined;
258
+ try {
259
+ const existing = inst.children;
260
+ const buffer = inst.buffer.sort(compareNodes);
261
+ inst.buffer = undefined;
262
+ let p1 = undefined;
263
+ let p2 = undefined;
264
+ let host = inst;
265
+ let guests = EMPTY;
266
+ let sibling = undefined;
267
+ let i = 0, j = 0;
268
+ while (i < existing.length || j < buffer.length) {
269
+ const old = existing[i];
270
+ const x = buffer[j];
271
+ const diff = compareNullable(x, old, compareNodes);
272
+ if (diff <= 0) {
273
+ const h = x.host.instance;
274
+ if (h !== inst) {
275
+ if (h !== host) {
276
+ RxDom.mergeGuests(host, inst, guests);
277
+ guests = [];
278
+ host = h;
279
+ }
280
+ guests.push(x);
281
+ }
282
+ if (sibling !== undefined && x.id === sibling.id)
283
+ throw new Error(`duplicate id '${sibling.id}' inside '${node.id}'`);
284
+ if (diff === 0) {
285
+ if (old.instance) {
286
+ x.instance = old.instance;
287
+ if (x.inline || !argsAreEqual(x.args, old.args)) {
288
+ if (!Transaction.isCanceled) {
289
+ if (x.priority === 0)
290
+ tryToRender(x);
291
+ else if (x.priority === 1)
292
+ p1 = push(p1, x);
293
+ else
294
+ p2 = push(p2, x);
295
+ }
296
+ }
297
+ }
298
+ else {
299
+ if (!Transaction.isCanceled) {
300
+ if (x.priority === 0) {
301
+ tryToInitialize(x);
302
+ tryToRender(x);
303
+ }
304
+ else if (x.priority === 1)
305
+ p1 = push(p1, x);
306
+ else
307
+ p2 = push(p2, x);
308
+ }
309
+ }
310
+ i++, j++;
311
+ }
312
+ else {
313
+ if (!Transaction.isCanceled) {
314
+ if (x.priority === 0) {
315
+ tryToInitialize(x);
316
+ tryToRender(x);
317
+ }
318
+ else if (x.priority === 1)
319
+ p1 = push(p1, x);
320
+ else
321
+ p2 = push(p2, x);
322
+ }
323
+ j++;
324
+ }
325
+ sibling = x;
326
+ }
327
+ else {
328
+ if (!Transaction.isCanceled)
329
+ tryToFinalize(old, old);
330
+ i++;
331
+ }
332
+ }
333
+ if (host !== inst)
334
+ RxDom.mergeGuests(host, inst, guests);
335
+ if (!Transaction.isCanceled) {
336
+ inst.children = buffer;
337
+ if (p1 !== undefined || p2 !== undefined)
338
+ promised = RxDom.renderIncrementally(node, p1, p2).then(finish, finish);
339
+ }
340
+ }
341
+ finally {
342
+ if (!promised)
343
+ finish();
344
+ }
345
+ }
346
+ }
347
+ static renderIncrementally(parent, p1, p2, checkEveryN = 30, timeLimit = 12) {
348
+ return __awaiter(this, void 0, void 0, function* () {
349
+ if (Transaction.isFrameOver(checkEveryN, timeLimit))
350
+ yield Transaction.requestNextFrame();
351
+ if (!Transaction.isCanceled) {
352
+ if (p1 !== undefined) {
353
+ if (parent.childrenShuffling)
354
+ shuffle(p1);
355
+ for (const x of p1) {
356
+ if (!x.instance)
357
+ tryToInitialize(x);
358
+ tryToRender(x);
359
+ if (Transaction.isCanceled)
360
+ break;
361
+ if (Transaction.isFrameOver(checkEveryN, timeLimit))
362
+ yield Transaction.requestNextFrame();
363
+ if (Transaction.isCanceled)
364
+ break;
365
+ }
366
+ }
367
+ if (p2 !== undefined) {
368
+ if (parent.childrenShuffling)
369
+ shuffle(p2);
370
+ for (const x of p2) {
371
+ if (!x.instance)
372
+ tryToInitialize(x);
373
+ tryToRender(x);
374
+ if (Transaction.isCanceled)
375
+ break;
376
+ if (Transaction.isFrameOver(checkEveryN, timeLimit))
377
+ yield Transaction.requestNextFrame();
378
+ if (Transaction.isCanceled)
379
+ break;
380
+ }
381
+ }
382
+ }
383
+ });
384
+ }
385
+ static mergeGuests(host, creator, guests) {
386
+ if (host !== creator) {
387
+ const existing = host.guests;
388
+ const merged = [];
389
+ let i = 0, j = 0;
390
+ while (i < existing.length || j < guests.length) {
391
+ const old = existing[i];
392
+ const x = guests[j];
393
+ const diff = compareNullable(x, old, compareNodes);
394
+ if (diff <= 0) {
395
+ merged.push(x);
396
+ if (diff === 0)
397
+ i++, j++;
398
+ else
399
+ j++;
400
+ }
401
+ else {
402
+ if (old.creator.instance !== creator)
403
+ merged.push(old);
404
+ i++;
405
+ }
406
+ }
407
+ host.guests = merged;
408
+ }
409
+ }
410
+ static forEachChildRecursively(node, action) {
411
+ const inst = node.instance;
412
+ if (inst) {
413
+ const native = inst.native;
414
+ native && action(native);
415
+ inst.children.forEach(x => RxDom.forEachChildRecursively(x, action));
416
+ }
417
+ }
418
+ }
419
+ RxDom.basic = new BasicNodeType('basic', false);
420
+ function tryToRender(node) {
421
+ const inst = node.instance;
422
+ if (node.inline)
423
+ invokeRender(node, node.args);
424
+ else
425
+ nonreactive(inst.rerender, node);
426
+ }
427
+ function tryToInitialize(node) {
428
+ var _a, _b;
429
+ const type = node.type;
430
+ const inst = node.instance = new RxNodeInstanceImpl(node.creator.instance.level + 1);
431
+ (_a = type.initialize) === null || _a === void 0 ? void 0 : _a.call(type, node);
432
+ (_b = type.mount) === null || _b === void 0 ? void 0 : _b.call(type, node);
433
+ if (!node.inline)
434
+ Rx.setLoggingHint(inst, node.id);
435
+ return inst;
436
+ }
437
+ function tryToFinalize(node, initiator) {
438
+ const inst = node.instance;
439
+ if (inst && inst.revision >= ~0) {
440
+ inst.revision = ~inst.revision;
441
+ invokeFinalize(node, initiator);
442
+ }
443
+ }
444
+ function invokeRender(node, args) {
445
+ const host = node.native !== undefined ? node : node.host;
446
+ runUnder(node, host, () => {
447
+ node.instance.revision++;
448
+ const type = node.type;
449
+ if (type.render)
450
+ type.render(node, args);
451
+ else
452
+ RxDom.basic.render(node, args);
453
+ });
454
+ }
455
+ function invokeFinalize(node, initiator) {
456
+ const type = node.type;
457
+ if (type.finalize)
458
+ type.finalize(node, initiator);
459
+ else
460
+ RxDom.basic.finalize(node, initiator);
461
+ }
462
+ function wrap(func) {
463
+ const creator = gCreator;
464
+ const host = gHost;
465
+ const wrappedRendering = (...args) => {
466
+ return runUnder(creator, host, func, ...args);
467
+ };
468
+ return wrappedRendering;
469
+ }
470
+ function runUnder(creator, host, func, ...args) {
471
+ const outerCreator = gCreator;
472
+ const outerHost = gHost;
473
+ try {
474
+ gCreator = creator;
475
+ gHost = host;
476
+ return func(...args);
477
+ }
478
+ finally {
479
+ gHost = outerHost;
480
+ gCreator = outerCreator;
481
+ }
482
+ }
483
+ function compareNodes(node1, node2) {
484
+ let result = 0;
485
+ const hp1 = node1.host.instance;
486
+ const hp2 = node2.host.instance;
487
+ if (hp1 !== hp2) {
488
+ result = hp1.uuid - hp2.uuid;
489
+ if (result === 0)
490
+ result = node1.id.localeCompare(node2.id);
491
+ }
492
+ else
493
+ result = node1.id.localeCompare(node2.id);
494
+ return result;
495
+ }
496
+ function compareNullable(a, b, comparer) {
497
+ let diff;
498
+ if (b !== undefined)
499
+ diff = a !== undefined ? comparer(a, b) : 1;
500
+ else
501
+ diff = a !== undefined ? -1 : 0;
502
+ return diff;
503
+ }
504
+ function argsAreEqual(a1, a2) {
505
+ let result = a1 === a2;
506
+ if (!result) {
507
+ if (Array.isArray(a1)) {
508
+ result = Array.isArray(a2) &&
509
+ a1.length === a2.length &&
510
+ a1.every((t, i) => t === a2[i]);
511
+ }
512
+ else if (a1 === Object(a1) && a2 === Object(a2)) {
513
+ for (const p in a1) {
514
+ result = a1[p] === a2[p];
515
+ if (!result)
516
+ break;
517
+ }
518
+ }
519
+ }
520
+ return result;
521
+ }
522
+ function push(array, item) {
523
+ if (array == undefined)
524
+ array = new Array();
525
+ array.push(item);
526
+ return array;
527
+ }
528
+ function shuffle(array) {
529
+ let i = array.length - 1;
530
+ while (i >= 0) {
531
+ const j = Math.floor(Math.random() * i);
532
+ const t = array[i];
533
+ array[i] = array[j];
534
+ array[j] = t;
535
+ i--;
536
+ }
537
+ return array;
538
+ }
539
+ const ORIGINAL_PROMISE_THEN = Promise.prototype.then;
540
+ function reactronicDomHookedThen(resolve, reject) {
541
+ resolve = resolve ? wrap(resolve) : resolveReturn;
542
+ reject = reject ? wrap(reject) : rejectRethrow;
543
+ return ORIGINAL_PROMISE_THEN.call(this, resolve, reject);
544
+ }
545
+ export function resolveReturn(value) {
546
+ return value;
547
+ }
548
+ export function rejectRethrow(error) {
549
+ throw error;
550
+ }
551
+ Promise.prototype.then = reactronicDomHookedThen;
552
+ const NOP = () => { };
553
+ const EMPTY = Object.freeze([]);
554
+ const SYSTEM = RxDom.createRootNode('SYSTEM', false, 'SYSTEM');
555
+ let gCreator = SYSTEM;
556
+ let gHost = SYSTEM;
@@ -0,0 +1,4 @@
1
+ import { Monitor, LoggingOptions } from 'reactronic';
2
+ import { RxNode, Render, NodeFactory, Priority } from './RxNode';
3
+ export declare function Reaction<E = undefined, M = unknown, R = void>(name: string, triggers: unknown, renderer: Render<E, M, R>, priority?: Priority, monitor?: Monitor, throttling?: number, logging?: Partial<LoggingOptions>, factory?: NodeFactory<E>): RxNode<E, M, R>;
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>;
@@ -0,0 +1,7 @@
1
+ import { RxNode } from './RxNode';
2
+ export function Reaction(name, triggers, renderer, priority, monitor, throttling, logging, factory) {
3
+ return RxNode.claim(name, triggers, false, renderer, priority, monitor, throttling, logging, factory);
4
+ }
5
+ export function Inline(name, renderer, priority, factory) {
6
+ return RxNode.claim(name, undefined, true, renderer, priority, undefined, undefined, undefined, factory);
7
+ }
@@ -0,0 +1,7 @@
1
+ export declare function restyler<T>(restyle: () => T): RxStyler<T>;
2
+ export declare class RxStyler<T> {
3
+ private readonly restyle;
4
+ constructor(restyle: () => T);
5
+ protected cache(): T;
6
+ get class(): T;
7
+ }
@@ -0,0 +1,30 @@
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
+ import { cached, Transaction } from 'reactronic';
11
+ export function restyler(restyle) {
12
+ return Transaction.run(null, () => new RxStyler(restyle));
13
+ }
14
+ export class RxStyler {
15
+ constructor(restyle) {
16
+ this.restyle = restyle;
17
+ }
18
+ cache() {
19
+ return this.restyle();
20
+ }
21
+ get class() {
22
+ return this.cache();
23
+ }
24
+ }
25
+ __decorate([
26
+ cached,
27
+ __metadata("design:type", Function),
28
+ __metadata("design:paramtypes", []),
29
+ __metadata("design:returntype", Object)
30
+ ], RxStyler.prototype, "cache", null);
@@ -0,0 +1,59 @@
1
+ import { Monitor, LoggingOptions, Item, CollectionReader } from 'reactronic';
2
+ export declare type Callback<E = unknown> = (element: E) => void;
3
+ export declare type Render<E = unknown, M = unknown, R = void> = (element: E, node: RxNode<E, M, R>) => R;
4
+ export declare type AsyncRender<E = unknown, M = unknown> = (element: E, node: RxNode<E, M, Promise<void>>) => Promise<void>;
5
+ export declare const enum Priority {
6
+ SyncP0 = 0,
7
+ AsyncP1 = 1,
8
+ AsyncP2 = 2
9
+ }
10
+ export declare abstract class RxNode<E = any, M = unknown, R = void> {
11
+ static currentRenderingPriority: Priority;
12
+ static readonly shortFrameDuration = 16;
13
+ static readonly longFrameDuration = 300;
14
+ static frameDuration: number;
15
+ abstract readonly name: string;
16
+ abstract readonly factory: NodeFactory<E>;
17
+ abstract readonly inline: boolean;
18
+ abstract readonly triggers: unknown;
19
+ abstract readonly renderer: Render<E, M, R>;
20
+ abstract readonly wrapper: Render<E, M, R> | undefined;
21
+ abstract readonly monitor?: Monitor;
22
+ abstract readonly throttling?: number;
23
+ abstract readonly logging?: Partial<LoggingOptions>;
24
+ abstract readonly priority: Priority;
25
+ abstract readonly shuffle: boolean;
26
+ abstract model?: M;
27
+ abstract readonly level: number;
28
+ abstract readonly parent: RxNode;
29
+ abstract readonly children: CollectionReader<RxNode>;
30
+ abstract readonly item: Item<RxNode> | undefined;
31
+ abstract readonly stamp: number;
32
+ abstract readonly element?: E;
33
+ render(): R;
34
+ get isInitialRendering(): boolean;
35
+ abstract wrapBy(renderer: Render<E, M, R> | undefined): this;
36
+ static root(render: () => void): void;
37
+ static get current(): RxNode;
38
+ static shuffleChildrenRendering(shuffle: boolean): void;
39
+ static renderChildrenThenDo(action: (error: unknown) => void): void;
40
+ static forAllNodesDo<E>(action: (e: E) => void): void;
41
+ static claim<E = undefined, M = unknown, R = void>(name: string, triggers: unknown, inline: boolean, renderer: Render<E, M, R>, priority?: Priority, monitor?: Monitor, throttling?: number, logging?: Partial<LoggingOptions>, factory?: NodeFactory<E>): RxNode<E, M, R>;
42
+ static getDefaultLoggingOptions(): LoggingOptions | undefined;
43
+ static setDefaultLoggingOptions(logging?: LoggingOptions): void;
44
+ }
45
+ export declare class NodeFactory<E> {
46
+ static readonly default: NodeFactory<any>;
47
+ readonly name: string;
48
+ readonly strict: boolean;
49
+ constructor(name: string, strict: boolean);
50
+ initialize(node: RxNode<E>, element: E | undefined): void;
51
+ finalize(node: RxNode<E>, isLeader: boolean): boolean;
52
+ arrange(node: RxNode<E>, strict: boolean): void;
53
+ render(node: RxNode<E>): void | Promise<void>;
54
+ }
55
+ export declare class StaticNodeFactory<E> extends NodeFactory<E> {
56
+ readonly element: E;
57
+ constructor(name: string, sequential: boolean, element: E);
58
+ initialize(node: RxNode<E>, element: E | undefined): void;
59
+ }