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.
- 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 +82 -0
- package/build/dist/source/core/Kernel.js +559 -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 +13 -0
- package/build/dist/source/html/Blocks.js +121 -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 +7 -7
- 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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./core/api";
|
|
2
|
+
export * from "./html/api";
|
package/build/dist/source/api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./core/api";
|
|
2
|
+
export * from "./html/api";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Render, SuperRender, RxNodeType, RxNodeInstance, RxNode } from
|
|
1
|
+
import { Render, SuperRender, RxNodeType, RxNodeInstance, RxNode } from "./RxDomV1.Types";
|
|
2
2
|
export declare class BasicNodeType<E, O> implements RxNodeType<E, O> {
|
|
3
3
|
readonly name: string;
|
|
4
4
|
readonly sequential: boolean;
|
|
@@ -16,8 +16,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
16
16
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
|
-
import { reactive, nonreactive, Transaction, Rx, options, Reentrance } from
|
|
20
|
-
import { RxNode } from
|
|
19
|
+
import { reactive, nonreactive, Transaction, Rx, options, Reentrance } from "reactronic";
|
|
20
|
+
import { RxNode } from "./RxDomV1.Types";
|
|
21
21
|
export class BasicNodeType {
|
|
22
22
|
constructor(name, sequential) {
|
|
23
23
|
this.name = name;
|
|
@@ -30,9 +30,9 @@ export class BasicNodeType {
|
|
|
30
30
|
render(node, args) {
|
|
31
31
|
const inst = node.instance;
|
|
32
32
|
if (!inst)
|
|
33
|
-
throw new Error(
|
|
33
|
+
throw new Error("element must be initialized before rendering");
|
|
34
34
|
if (inst.buffer)
|
|
35
|
-
throw new Error(
|
|
35
|
+
throw new Error("rendering re-entrance is not supported yet");
|
|
36
36
|
inst.buffer = [];
|
|
37
37
|
let result;
|
|
38
38
|
if (node.superRender)
|
|
@@ -96,7 +96,7 @@ export class RxDom {
|
|
|
96
96
|
static Root(render) {
|
|
97
97
|
const inst = SYSTEM.instance;
|
|
98
98
|
if (inst.buffer)
|
|
99
|
-
throw new Error(
|
|
99
|
+
throw new Error("rendering re-entrance is not supported yet");
|
|
100
100
|
inst.buffer = [];
|
|
101
101
|
let result = render();
|
|
102
102
|
if (result instanceof Promise)
|
|
@@ -110,14 +110,14 @@ export class RxDom {
|
|
|
110
110
|
const o = creator !== null && creator !== void 0 ? creator : gCreator;
|
|
111
111
|
const inst = o.instance;
|
|
112
112
|
if (!inst)
|
|
113
|
-
throw new Error(
|
|
113
|
+
throw new Error("element must be initialized before children");
|
|
114
114
|
if (type === undefined)
|
|
115
115
|
type = RxDom.basic;
|
|
116
116
|
if (!host)
|
|
117
117
|
host = gHost;
|
|
118
118
|
const node = new RxNode(id, args, render, superRender, 0, false, type, inline !== null && inline !== void 0 ? inline : false, o, host);
|
|
119
119
|
if (inst.buffer === undefined)
|
|
120
|
-
throw new Error(
|
|
120
|
+
throw new Error("children are rendered already");
|
|
121
121
|
const rev = (_b = (_a = host.instance) === null || _a === void 0 ? void 0 : _a.revision) !== null && _b !== void 0 ? _b : ~1;
|
|
122
122
|
if (rev >= ~0)
|
|
123
123
|
inst.buffer.push(node);
|
|
@@ -148,8 +148,8 @@ export class RxDom {
|
|
|
148
148
|
const inst = new RxNodeInstanceImpl(0);
|
|
149
149
|
const node = new RxNode(id, null, () => { }, undefined, 0, false, { name: id, sequential }, false, {}, {}, inst);
|
|
150
150
|
const a = node;
|
|
151
|
-
a[
|
|
152
|
-
a[
|
|
151
|
+
a["creator"] = node;
|
|
152
|
+
a["host"] = node;
|
|
153
153
|
inst.native = native;
|
|
154
154
|
return node;
|
|
155
155
|
}
|
|
@@ -159,13 +159,13 @@ export class RxDom {
|
|
|
159
159
|
static currentNodeInstance() {
|
|
160
160
|
const inst = gCreator.instance;
|
|
161
161
|
if (!inst)
|
|
162
|
-
throw new Error(
|
|
162
|
+
throw new Error("currentNodeInstance function can be called only inside rendering function");
|
|
163
163
|
return inst;
|
|
164
164
|
}
|
|
165
165
|
static currentNodeInstanceInternal() {
|
|
166
166
|
const inst = gCreator.instance;
|
|
167
167
|
if (!inst)
|
|
168
|
-
throw new Error(
|
|
168
|
+
throw new Error("currentNodeInstanceInternal function can be called only inside rendering function");
|
|
169
169
|
return inst;
|
|
170
170
|
}
|
|
171
171
|
static currentNodeRevision() {
|
|
@@ -416,7 +416,7 @@ export class RxDom {
|
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
|
-
RxDom.basic = new BasicNodeType(
|
|
419
|
+
RxDom.basic = new BasicNodeType("basic", false);
|
|
420
420
|
function tryToRender(node) {
|
|
421
421
|
const inst = node.instance;
|
|
422
422
|
if (node.inline)
|
|
@@ -551,6 +551,6 @@ export function rejectRethrow(error) {
|
|
|
551
551
|
Promise.prototype.then = reactronicDomHookedThen;
|
|
552
552
|
const NOP = () => { };
|
|
553
553
|
const EMPTY = Object.freeze([]);
|
|
554
|
-
const SYSTEM = RxDom.createRootNode(
|
|
554
|
+
const SYSTEM = RxDom.createRootNode("SYSTEM", false, "SYSTEM");
|
|
555
555
|
let gCreator = SYSTEM;
|
|
556
556
|
let gHost = SYSTEM;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CellRange } from "./CellRange";
|
|
2
|
+
export declare enum To {
|
|
3
|
+
Fit = 0,
|
|
4
|
+
Left = 1,
|
|
5
|
+
Center = 2,
|
|
6
|
+
Right = 3,
|
|
7
|
+
Top = 4,
|
|
8
|
+
CenterV = 8,
|
|
9
|
+
Bottom = 12,
|
|
10
|
+
Default = 16
|
|
11
|
+
}
|
|
12
|
+
export interface ElasticSize {
|
|
13
|
+
cells?: number;
|
|
14
|
+
min?: string;
|
|
15
|
+
max?: string;
|
|
16
|
+
growth?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface TrackSize extends ElasticSize {
|
|
19
|
+
track?: string | number;
|
|
20
|
+
}
|
|
21
|
+
export interface Bounds {
|
|
22
|
+
place?: string;
|
|
23
|
+
widthSpan?: number;
|
|
24
|
+
widthMin?: string;
|
|
25
|
+
widthMax?: string;
|
|
26
|
+
widthGrowth?: number;
|
|
27
|
+
widthOverlap?: boolean;
|
|
28
|
+
heightSpan?: number;
|
|
29
|
+
heightMin?: string;
|
|
30
|
+
heightMax?: string;
|
|
31
|
+
heightGrowth?: number;
|
|
32
|
+
heightOverlap?: boolean;
|
|
33
|
+
alignContent?: To;
|
|
34
|
+
alignFrame?: To;
|
|
35
|
+
}
|
|
36
|
+
export interface Place {
|
|
37
|
+
exact: CellRange | undefined;
|
|
38
|
+
widthMin: string;
|
|
39
|
+
widthMax: string;
|
|
40
|
+
widthGrowth: number;
|
|
41
|
+
heightMin: string;
|
|
42
|
+
heightMax: string;
|
|
43
|
+
heightGrowth: number;
|
|
44
|
+
alignContent: To;
|
|
45
|
+
alignFrame: To;
|
|
46
|
+
}
|
|
47
|
+
export declare class Allocator {
|
|
48
|
+
reset(): void;
|
|
49
|
+
lineFeed(): void;
|
|
50
|
+
allocate(bounds: Bounds | undefined): Place | undefined;
|
|
51
|
+
}
|
|
52
|
+
export declare class GridBasedAllocator implements Allocator {
|
|
53
|
+
private maxColumnCount;
|
|
54
|
+
private maxRowCount;
|
|
55
|
+
private actualColumnCount;
|
|
56
|
+
private actualRowCount;
|
|
57
|
+
private columnCursor;
|
|
58
|
+
private rowCursor;
|
|
59
|
+
private newRowCursor;
|
|
60
|
+
reset(): void;
|
|
61
|
+
lineFeed(): void;
|
|
62
|
+
allocate(bounds: Bounds | undefined): Place | undefined;
|
|
63
|
+
}
|
|
64
|
+
export declare function equalPlaces(a: Place | undefined, b: Place | undefined): boolean;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { parseCellRange } from "./CellRange";
|
|
2
|
+
export var To;
|
|
3
|
+
(function (To) {
|
|
4
|
+
To[To["Fit"] = 0] = "Fit";
|
|
5
|
+
To[To["Left"] = 1] = "Left";
|
|
6
|
+
To[To["Center"] = 2] = "Center";
|
|
7
|
+
To[To["Right"] = 3] = "Right";
|
|
8
|
+
To[To["Top"] = 4] = "Top";
|
|
9
|
+
To[To["CenterV"] = 8] = "CenterV";
|
|
10
|
+
To[To["Bottom"] = 12] = "Bottom";
|
|
11
|
+
To[To["Default"] = 16] = "Default";
|
|
12
|
+
})(To || (To = {}));
|
|
13
|
+
export class Allocator {
|
|
14
|
+
reset() {
|
|
15
|
+
}
|
|
16
|
+
lineFeed() {
|
|
17
|
+
}
|
|
18
|
+
allocate(bounds) {
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
20
|
+
return !bounds ? undefined : {
|
|
21
|
+
exact: bounds.place ? parseCellRange(bounds.place, { x1: 0, y1: 0, x2: 0, y2: 0 }) : undefined,
|
|
22
|
+
widthMin: (_a = bounds.widthMin) !== null && _a !== void 0 ? _a : "",
|
|
23
|
+
widthMax: (_b = bounds.widthMax) !== null && _b !== void 0 ? _b : "",
|
|
24
|
+
widthGrowth: (_c = bounds.widthGrowth) !== null && _c !== void 0 ? _c : 0,
|
|
25
|
+
heightMin: (_d = bounds.heightMin) !== null && _d !== void 0 ? _d : "",
|
|
26
|
+
heightMax: (_e = bounds.heightMax) !== null && _e !== void 0 ? _e : "",
|
|
27
|
+
heightGrowth: (_f = bounds.heightGrowth) !== null && _f !== void 0 ? _f : 0,
|
|
28
|
+
alignContent: (_g = bounds.alignContent) !== null && _g !== void 0 ? _g : To.Default,
|
|
29
|
+
alignFrame: (_h = bounds.alignFrame) !== null && _h !== void 0 ? _h : To.Default,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class GridBasedAllocator {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.maxColumnCount = 0;
|
|
36
|
+
this.maxRowCount = 0;
|
|
37
|
+
this.actualColumnCount = 0;
|
|
38
|
+
this.actualRowCount = 0;
|
|
39
|
+
this.columnCursor = 0;
|
|
40
|
+
this.rowCursor = 0;
|
|
41
|
+
this.newRowCursor = 0;
|
|
42
|
+
}
|
|
43
|
+
reset() {
|
|
44
|
+
this.maxColumnCount = 0;
|
|
45
|
+
this.maxRowCount = 0;
|
|
46
|
+
this.actualColumnCount = 0;
|
|
47
|
+
this.actualRowCount = 0;
|
|
48
|
+
this.columnCursor = 0;
|
|
49
|
+
this.rowCursor = 0;
|
|
50
|
+
this.newRowCursor = 0;
|
|
51
|
+
}
|
|
52
|
+
lineFeed() {
|
|
53
|
+
this.columnCursor = 0;
|
|
54
|
+
this.rowCursor = this.newRowCursor;
|
|
55
|
+
}
|
|
56
|
+
allocate(bounds) {
|
|
57
|
+
var _a, _b, _c, _d;
|
|
58
|
+
const result = {
|
|
59
|
+
exact: undefined,
|
|
60
|
+
widthMin: "", widthMax: "", widthGrowth: 0,
|
|
61
|
+
heightMin: "", heightMax: "", heightGrowth: 0,
|
|
62
|
+
alignContent: (_a = bounds === null || bounds === void 0 ? void 0 : bounds.alignContent) !== null && _a !== void 0 ? _a : To.Default,
|
|
63
|
+
alignFrame: (_b = bounds === null || bounds === void 0 ? void 0 : bounds.alignFrame) !== null && _b !== void 0 ? _b : To.Default,
|
|
64
|
+
};
|
|
65
|
+
if (bounds === null || bounds === void 0 ? void 0 : bounds.place) {
|
|
66
|
+
result.exact = parseCellRange(bounds.place, { x1: 0, y1: 0, x2: 0, y2: 0 });
|
|
67
|
+
absolutizeCellRange(result.exact, this.columnCursor + 1, this.rowCursor + 1, this.maxColumnCount || Infinity, this.maxRowCount || Infinity, result.exact);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const totalColumnCount = this.maxColumnCount !== 0 ? this.maxColumnCount : this.actualColumnCount;
|
|
71
|
+
const totalRowCount = this.maxRowCount !== 0 ? this.maxRowCount : this.actualRowCount;
|
|
72
|
+
const cr = result.exact = { x1: 0, y1: 0, x2: 0, y2: 0 };
|
|
73
|
+
let w = (_c = bounds === null || bounds === void 0 ? void 0 : bounds.widthSpan) !== null && _c !== void 0 ? _c : 1;
|
|
74
|
+
if (w === 0)
|
|
75
|
+
w = totalColumnCount || 1;
|
|
76
|
+
if (w >= 0) {
|
|
77
|
+
cr.x1 = this.columnCursor + 1;
|
|
78
|
+
cr.x2 = absolutizePosition(cr.x1 + w - 1, 0, this.maxColumnCount || Infinity);
|
|
79
|
+
if (!(bounds === null || bounds === void 0 ? void 0 : bounds.widthOverlap))
|
|
80
|
+
this.columnCursor = cr.x2;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
cr.x1 = Math.max(this.columnCursor + w, 1);
|
|
84
|
+
cr.x2 = this.columnCursor;
|
|
85
|
+
}
|
|
86
|
+
let h = (_d = bounds === null || bounds === void 0 ? void 0 : bounds.heightSpan) !== null && _d !== void 0 ? _d : 1;
|
|
87
|
+
if (h === 0)
|
|
88
|
+
h = totalRowCount || 1;
|
|
89
|
+
if (h >= 0) {
|
|
90
|
+
cr.y1 = this.rowCursor + 1;
|
|
91
|
+
cr.y2 = absolutizePosition(cr.y1 + h - 1, 0, this.maxRowCount || Infinity);
|
|
92
|
+
if (!(bounds === null || bounds === void 0 ? void 0 : bounds.heightOverlap) && cr.y2 > this.newRowCursor)
|
|
93
|
+
this.newRowCursor = cr.y2;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
cr.y1 = Math.max(this.rowCursor + h, 1);
|
|
97
|
+
cr.y2 = this.rowCursor;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function absolutizeCellRange(area, cursorX, cursorY, maxWidth, maxHeight, result) {
|
|
104
|
+
const x1 = absolutizePosition(area.x1, cursorX, maxWidth);
|
|
105
|
+
const x2 = absolutizePosition(area.x2, x1, maxWidth);
|
|
106
|
+
if (x1 <= x2)
|
|
107
|
+
result.x1 = x1, result.x2 = x2;
|
|
108
|
+
else
|
|
109
|
+
result.x1 = x2, result.x2 = x1;
|
|
110
|
+
const y1 = absolutizePosition(area.y1, cursorY, maxHeight);
|
|
111
|
+
const y2 = absolutizePosition(area.y2, y1, maxHeight);
|
|
112
|
+
if (y1 <= y2)
|
|
113
|
+
result.y1 = y1, result.y2 = y2;
|
|
114
|
+
else
|
|
115
|
+
result.y1 = y2, result.y2 = y1;
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
function absolutizePosition(pos, cursor, max) {
|
|
119
|
+
if (pos === 0)
|
|
120
|
+
pos = cursor;
|
|
121
|
+
else if (pos < 0)
|
|
122
|
+
pos = Math.max(max + pos, 1);
|
|
123
|
+
else
|
|
124
|
+
pos = Math.min(pos, max);
|
|
125
|
+
return pos;
|
|
126
|
+
}
|
|
127
|
+
export function equalPlaces(a, b) {
|
|
128
|
+
let result;
|
|
129
|
+
if (a) {
|
|
130
|
+
if (b) {
|
|
131
|
+
result = a.widthGrowth == b.widthGrowth;
|
|
132
|
+
}
|
|
133
|
+
else
|
|
134
|
+
result = false;
|
|
135
|
+
}
|
|
136
|
+
else if (b)
|
|
137
|
+
result = false;
|
|
138
|
+
else
|
|
139
|
+
result = true;
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export function parseCellRange(text, result) {
|
|
2
|
+
let i = 0;
|
|
3
|
+
let value = 0;
|
|
4
|
+
let sign = 1;
|
|
5
|
+
let component = 0;
|
|
6
|
+
while (i < text.length) {
|
|
7
|
+
const charCode = text.charCodeAt(i);
|
|
8
|
+
if (isCapitalLetter(charCode)) {
|
|
9
|
+
if (component % 2 === 0)
|
|
10
|
+
value = value * 26 + charCode - 64;
|
|
11
|
+
else
|
|
12
|
+
console.error(`Digit is expected, but letter ('${text[i]}') was read`);
|
|
13
|
+
}
|
|
14
|
+
else if (isLowercaseLetter(charCode)) {
|
|
15
|
+
if (component % 2 === 0) {
|
|
16
|
+
value = value * 26 + charCode - 96;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
console.error(`Digit is expected, but letter ('${text[i]}') was read`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (isDigit(charCode)) {
|
|
23
|
+
if (component % 2 === 0) {
|
|
24
|
+
if (value !== 0) {
|
|
25
|
+
if (component === 0)
|
|
26
|
+
result.x1 = value * sign;
|
|
27
|
+
else
|
|
28
|
+
result.x2 = value * sign;
|
|
29
|
+
value = 0;
|
|
30
|
+
}
|
|
31
|
+
component++;
|
|
32
|
+
}
|
|
33
|
+
value = value * 10 + charCode - 48;
|
|
34
|
+
}
|
|
35
|
+
else if (charCode === 40) {
|
|
36
|
+
if (component === 0)
|
|
37
|
+
result.x1 = value * sign;
|
|
38
|
+
else if (component === 2)
|
|
39
|
+
result.x2 = value * sign;
|
|
40
|
+
if (sign > 0) {
|
|
41
|
+
sign = -1;
|
|
42
|
+
component &= ~1;
|
|
43
|
+
value = 0;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
console.error("Sign must not be negative");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (charCode === 41) {
|
|
50
|
+
if (sign > 0) {
|
|
51
|
+
console.error("Sign must be negative");
|
|
52
|
+
}
|
|
53
|
+
switch (component) {
|
|
54
|
+
case 0:
|
|
55
|
+
result.x1 = value * sign;
|
|
56
|
+
break;
|
|
57
|
+
case 1:
|
|
58
|
+
result.y1 = value * sign;
|
|
59
|
+
break;
|
|
60
|
+
case 2:
|
|
61
|
+
result.x2 = value * sign;
|
|
62
|
+
break;
|
|
63
|
+
case 3:
|
|
64
|
+
result.y2 = value * sign;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
sign = 1;
|
|
68
|
+
value = 0;
|
|
69
|
+
component++;
|
|
70
|
+
}
|
|
71
|
+
else if (charCode === 58) {
|
|
72
|
+
if (sign < 0)
|
|
73
|
+
console.error(`area '${text}': e1`);
|
|
74
|
+
if (component === 1)
|
|
75
|
+
result.y1 = value * sign;
|
|
76
|
+
else if (component !== 2)
|
|
77
|
+
console.error(`area '${text}': [e2] component = ${component}`);
|
|
78
|
+
component = 2;
|
|
79
|
+
value = 0;
|
|
80
|
+
}
|
|
81
|
+
else if (isWhitespace(charCode)) {
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.error(`Unknown symbol '${text[i]}' in '${text}'`);
|
|
85
|
+
}
|
|
86
|
+
i++;
|
|
87
|
+
}
|
|
88
|
+
if (value !== 0) {
|
|
89
|
+
switch (component) {
|
|
90
|
+
case 0: {
|
|
91
|
+
result.x1 = value * sign;
|
|
92
|
+
if (sign < 0 && result.y1 === 0)
|
|
93
|
+
result.y1 = sign;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case 1: {
|
|
97
|
+
if (sign < 0 && result.x1 === 0)
|
|
98
|
+
result.x1 = sign;
|
|
99
|
+
result.y1 = value * sign;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case 2: {
|
|
103
|
+
result.x2 = value * sign;
|
|
104
|
+
if (sign < 0 && result.y2 === 0)
|
|
105
|
+
result.y2 = sign;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case 3: {
|
|
109
|
+
if (sign < 0 && result.x2 === 0)
|
|
110
|
+
result.x2 = sign;
|
|
111
|
+
result.y2 = value * sign;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else if (sign < 0) {
|
|
117
|
+
if (component === 0) {
|
|
118
|
+
if (result.x1 === 0)
|
|
119
|
+
result.x1 = sign;
|
|
120
|
+
if (result.y1 === 0)
|
|
121
|
+
result.y1 = sign;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
if (result.x2 === 0)
|
|
125
|
+
result.x2 = sign;
|
|
126
|
+
if (result.y2 === 0)
|
|
127
|
+
result.y2 = sign;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
export function emitCellRange(value) {
|
|
133
|
+
const p1 = emitCellPosition(value.x1, value.y1);
|
|
134
|
+
const p2 = emitCellPosition(value.x2, value.y2);
|
|
135
|
+
return `${p1}${p2 !== "" ? `:${p2}` : ""}`;
|
|
136
|
+
}
|
|
137
|
+
function isWhitespace(char) {
|
|
138
|
+
return char === 32 || (char >= 9 && char <= 13) || char === 133 || char === 160;
|
|
139
|
+
}
|
|
140
|
+
function isDigit(input, index) {
|
|
141
|
+
return 48 <= input && input <= 57;
|
|
142
|
+
}
|
|
143
|
+
function isCapitalLetter(ch) {
|
|
144
|
+
return 65 <= ch && ch <= 90;
|
|
145
|
+
}
|
|
146
|
+
function isLowercaseLetter(ch) {
|
|
147
|
+
return 97 <= ch && ch <= 122;
|
|
148
|
+
}
|
|
149
|
+
function emitLetters(n) {
|
|
150
|
+
if (n < 0)
|
|
151
|
+
throw new Error(`emitLetters: argument (${n}) should not be negative or zero`);
|
|
152
|
+
let result = "";
|
|
153
|
+
while (n >= 0) {
|
|
154
|
+
const r = n % 26;
|
|
155
|
+
n = Math.floor(n / 26) - 1;
|
|
156
|
+
result = String.fromCharCode(65 + r) + result;
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
function emitCellPosition(x, y) {
|
|
161
|
+
let result = "";
|
|
162
|
+
if (x > 0 && y > 0)
|
|
163
|
+
result = `${emitLetters(x - 1)}${y}`;
|
|
164
|
+
else if (x > 0 && y < 0)
|
|
165
|
+
result = `${emitLetters(x - 1)}(${-y})`;
|
|
166
|
+
else if (x < 0 && y > 0)
|
|
167
|
+
result = `(${emitLetters(-x - 1)})${y}`;
|
|
168
|
+
else if (x < 0 && y < 0)
|
|
169
|
+
result = `(${emitLetters(-x - 1)}${-y})`;
|
|
170
|
+
else
|
|
171
|
+
result = "";
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Monitor, LoggingOptions, Item, CollectionReader } from "reactronic";
|
|
2
|
+
import { Bounds, Place, Allocator } from "./Allocator";
|
|
3
|
+
export declare type Callback<T = unknown> = (native: T) => void;
|
|
4
|
+
export declare type Render<T = unknown, M = unknown, R = void> = (native: T, block: VBlock<T, M, R>) => R;
|
|
5
|
+
export declare type AsyncRender<T = unknown, M = unknown> = (native: T, block: VBlock<T, M, Promise<void>>) => Promise<void>;
|
|
6
|
+
export declare const enum Priority {
|
|
7
|
+
SyncP0 = 0,
|
|
8
|
+
AsyncP1 = 1,
|
|
9
|
+
AsyncP2 = 2
|
|
10
|
+
}
|
|
11
|
+
export interface BlockArgs<T = unknown, M = unknown, R = void> extends Bounds {
|
|
12
|
+
reacting?: boolean;
|
|
13
|
+
triggers?: unknown;
|
|
14
|
+
priority?: Priority;
|
|
15
|
+
monitor?: Monitor;
|
|
16
|
+
throttling?: number;
|
|
17
|
+
logging?: Partial<LoggingOptions>;
|
|
18
|
+
shuffle?: boolean;
|
|
19
|
+
render: Render<T, M, R>;
|
|
20
|
+
initialize?: Render<T, M, R> | Array<Render<T, M, R>>;
|
|
21
|
+
finalize?: Render<T, M, R> | Array<Render<T, M, R>>;
|
|
22
|
+
override?: Render<T, M, R>;
|
|
23
|
+
subTreeContext?: Object;
|
|
24
|
+
subTreeContextType?: Object;
|
|
25
|
+
}
|
|
26
|
+
export declare function useContext<T extends Object>(type: new (...args: any[]) => T): T;
|
|
27
|
+
export declare abstract class VBlock<T = unknown, M = unknown, R = void> {
|
|
28
|
+
static readonly shortFrameDuration = 16;
|
|
29
|
+
static readonly longFrameDuration = 300;
|
|
30
|
+
static currentRenderingPriority: Priority;
|
|
31
|
+
static frameDuration: number;
|
|
32
|
+
abstract readonly name: string;
|
|
33
|
+
abstract readonly driver: AbstractDriver<T>;
|
|
34
|
+
abstract readonly args: Readonly<BlockArgs<T, M, R>>;
|
|
35
|
+
abstract model?: M;
|
|
36
|
+
abstract readonly level: number;
|
|
37
|
+
abstract readonly host: VBlock;
|
|
38
|
+
abstract readonly children: CollectionReader<VBlock>;
|
|
39
|
+
abstract readonly item: Item<VBlock> | undefined;
|
|
40
|
+
abstract readonly stamp: number;
|
|
41
|
+
abstract readonly native: T | undefined;
|
|
42
|
+
abstract readonly place: Readonly<Place> | undefined;
|
|
43
|
+
render(): R;
|
|
44
|
+
get isInitialRendering(): boolean;
|
|
45
|
+
static root(render: () => void): void;
|
|
46
|
+
static get current(): VBlock;
|
|
47
|
+
static renderNestedTreesThenDo(action: (error: unknown) => void): void;
|
|
48
|
+
static runForAllBlocks<T>(action: (e: T) => void): void;
|
|
49
|
+
static claim<T = undefined, M = unknown, R = void, C = void>(name: string, args: BlockArgs<T, M, R>, driver?: AbstractDriver<T>): VBlock<T, M, R>;
|
|
50
|
+
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
51
|
+
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
52
|
+
private static trySwitchContext;
|
|
53
|
+
}
|
|
54
|
+
export declare enum LayoutKind {
|
|
55
|
+
Block = 0,
|
|
56
|
+
Grid = 1,
|
|
57
|
+
Line = 2,
|
|
58
|
+
Group = 3,
|
|
59
|
+
Text = 4
|
|
60
|
+
}
|
|
61
|
+
export declare class AbstractDriver<T> {
|
|
62
|
+
static readonly group: AbstractDriver<any>;
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly layout: LayoutKind;
|
|
65
|
+
readonly createAllocator: () => Allocator;
|
|
66
|
+
get isSequential(): boolean;
|
|
67
|
+
get isAuxiliary(): boolean;
|
|
68
|
+
get isBlock(): boolean;
|
|
69
|
+
get isGrid(): boolean;
|
|
70
|
+
get isLine(): boolean;
|
|
71
|
+
constructor(name: string, layout: LayoutKind, createAllocator?: () => Allocator);
|
|
72
|
+
initialize(block: VBlock<T>, native: T | undefined): void;
|
|
73
|
+
finalize(block: VBlock<T>, isLeader: boolean): boolean;
|
|
74
|
+
deploy(block: VBlock<T>, sequential: boolean): void;
|
|
75
|
+
arrange(block: VBlock<T>, place: Place | undefined, heightGrowth: number | undefined): void;
|
|
76
|
+
render(block: VBlock<T>): void | Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
export declare class StaticDriver<T> extends AbstractDriver<T> {
|
|
79
|
+
readonly element: T;
|
|
80
|
+
constructor(element: T, name: string, layout: LayoutKind, createAllocator?: () => Allocator);
|
|
81
|
+
initialize(block: VBlock<T>, element: T | undefined): void;
|
|
82
|
+
}
|