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,426 @@
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
+ export var Priority;
21
+ (function (Priority) {
22
+ Priority[Priority["SyncP0"] = 0] = "SyncP0";
23
+ Priority[Priority["AsyncP1"] = 1] = "AsyncP1";
24
+ Priority[Priority["AsyncP2"] = 2] = "AsyncP2";
25
+ })(Priority || (Priority = {}));
26
+ export class RxNode {
27
+ render() {
28
+ return this.renderer(this.element, this);
29
+ }
30
+ get isInitialRendering() {
31
+ return this.stamp === 2;
32
+ }
33
+ static root(render) {
34
+ gSysRoot.self.renderer = render;
35
+ prepareThenRunRender(gSysRoot, false, false);
36
+ }
37
+ static get current() {
38
+ return gContext.self;
39
+ }
40
+ static shuffleChildrenRendering(shuffle) {
41
+ gContext.self.shuffle = shuffle;
42
+ }
43
+ static renderChildrenThenDo(action) {
44
+ runRenderChildrenThenDo(undefined, action);
45
+ }
46
+ static forAllNodesDo(action) {
47
+ forEachChildRecursively(gSysRoot, action);
48
+ }
49
+ static claim(name, triggers, inline, renderer, priority, monitor, throttling, logging, factory) {
50
+ const parent = gContext.self;
51
+ const children = parent.children;
52
+ const item = children.claim(name);
53
+ let node;
54
+ if (item) {
55
+ node = item.self;
56
+ if (node.factory !== factory && factory !== undefined)
57
+ throw new Error(`changing node type is not yet supported: "${node.factory.name}" -> "${factory === null || factory === void 0 ? void 0 : factory.name}"`);
58
+ if (node.inline || !triggersAreEqual(node.triggers, triggers))
59
+ node.triggers = triggers;
60
+ node.renderer = renderer;
61
+ node.priority = priority !== null && priority !== void 0 ? priority : Priority.SyncP0;
62
+ }
63
+ else {
64
+ node = new RxNodeImpl(name, factory !== null && factory !== void 0 ? factory : NodeFactory.default, inline !== null && inline !== void 0 ? inline : false, parent, triggers, renderer, undefined, priority, monitor, throttling, logging);
65
+ node.item = children.add(node);
66
+ RxNodeImpl.grandCount++;
67
+ if (!node.inline)
68
+ RxNodeImpl.disposableCount++;
69
+ }
70
+ return node;
71
+ }
72
+ static getDefaultLoggingOptions() {
73
+ return RxNodeImpl.logging;
74
+ }
75
+ static setDefaultLoggingOptions(logging) {
76
+ RxNodeImpl.logging = logging;
77
+ }
78
+ }
79
+ RxNode.currentRenderingPriority = Priority.SyncP0;
80
+ RxNode.shortFrameDuration = 16;
81
+ RxNode.longFrameDuration = 300;
82
+ RxNode.frameDuration = RxNode.longFrameDuration;
83
+ const NOP = () => { };
84
+ export class NodeFactory {
85
+ constructor(name, strict) {
86
+ this.name = name;
87
+ this.strict = strict;
88
+ }
89
+ initialize(node, element) {
90
+ const impl = node;
91
+ impl.element = element;
92
+ }
93
+ finalize(node, isLeader) {
94
+ const impl = node;
95
+ impl.element = undefined;
96
+ return isLeader;
97
+ }
98
+ arrange(node, strict) {
99
+ }
100
+ render(node) {
101
+ let result;
102
+ if (node.wrapper)
103
+ result = node.wrapper(node.element, node);
104
+ else
105
+ result = node.render();
106
+ return result;
107
+ }
108
+ }
109
+ NodeFactory.default = new NodeFactory('default', false);
110
+ export class StaticNodeFactory extends NodeFactory {
111
+ constructor(name, sequential, element) {
112
+ super(name, sequential);
113
+ this.element = element;
114
+ }
115
+ initialize(node, element) {
116
+ super.initialize(node, this.element);
117
+ }
118
+ }
119
+ function getNodeName(node) {
120
+ return node.stamp >= 0 ? node.name : undefined;
121
+ }
122
+ class RxNodeImpl extends RxNode {
123
+ constructor(name, factory, inline, parent, triggers, renderer, wrapper, priority, monitor, throttling, logging) {
124
+ super();
125
+ this.name = name;
126
+ this.factory = factory;
127
+ this.inline = inline;
128
+ this.triggers = triggers;
129
+ this.renderer = renderer;
130
+ this.wrapper = wrapper;
131
+ this.monitor = monitor;
132
+ this.throttling = throttling !== null && throttling !== void 0 ? throttling : -1;
133
+ this.logging = logging !== null && logging !== void 0 ? logging : RxNodeImpl.logging;
134
+ this.priority = priority !== null && priority !== void 0 ? priority : Priority.SyncP0;
135
+ this.shuffle = false;
136
+ this.model = undefined;
137
+ this.level = parent.level + 1;
138
+ this.parent = parent;
139
+ this.children = new Collection(factory.strict, getNodeName);
140
+ this.item = undefined;
141
+ this.stamp = 0;
142
+ this.element = undefined;
143
+ }
144
+ autorender(_triggers) {
145
+ runRender(this.item);
146
+ }
147
+ wrapBy(renderer) {
148
+ this.wrapper = renderer;
149
+ return this;
150
+ }
151
+ }
152
+ RxNodeImpl.grandCount = 0;
153
+ RxNodeImpl.disposableCount = 0;
154
+ RxNodeImpl.logging = undefined;
155
+ __decorate([
156
+ reactive,
157
+ options({
158
+ reentrance: Reentrance.CancelPrevious,
159
+ triggeringArgs: true,
160
+ noSideEffects: false,
161
+ }),
162
+ __metadata("design:type", Function),
163
+ __metadata("design:paramtypes", [Object]),
164
+ __metadata("design:returntype", void 0)
165
+ ], RxNodeImpl.prototype, "autorender", null);
166
+ function runRenderChildrenThenDo(error, action) {
167
+ const context = gContext;
168
+ const node = context.self;
169
+ const children = node.children;
170
+ if (children.isMergeInProgress) {
171
+ let promised = undefined;
172
+ try {
173
+ children.endMerge(error);
174
+ for (const child of children.removedItems(true))
175
+ runFinalize(child, true);
176
+ if (!error) {
177
+ const strict = children.strict;
178
+ let p1 = undefined;
179
+ let p2 = undefined;
180
+ let isMoved = false;
181
+ for (const child of children.items()) {
182
+ if (Transaction.isCanceled)
183
+ break;
184
+ const x = child.self;
185
+ if (x.element) {
186
+ if (isMoved) {
187
+ children.markAsMoved(child);
188
+ isMoved = false;
189
+ }
190
+ }
191
+ else if (strict && children.isMoved(child))
192
+ isMoved = true;
193
+ if (x.priority === Priority.SyncP0)
194
+ prepareThenRunRender(child, children.isMoved(child), strict);
195
+ else if (x.priority === Priority.AsyncP1)
196
+ p1 = push(p1, child);
197
+ else
198
+ p2 = push(p2, child);
199
+ }
200
+ if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
201
+ promised = startIncrementalRendering(context, children, p1, p2).then(() => action(error), e => action(e));
202
+ }
203
+ }
204
+ finally {
205
+ if (!promised)
206
+ action(error);
207
+ }
208
+ }
209
+ }
210
+ function startIncrementalRendering(parent, allChildren, priority1, priority2) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ const stamp = parent.self.stamp;
213
+ if (priority1)
214
+ yield renderIncrementally(parent, stamp, allChildren, priority1, Priority.AsyncP1);
215
+ if (priority2)
216
+ yield renderIncrementally(parent, stamp, allChildren, priority2, Priority.AsyncP2);
217
+ });
218
+ }
219
+ function renderIncrementally(parent, stamp, allChildren, items, priority) {
220
+ return __awaiter(this, void 0, void 0, function* () {
221
+ yield Transaction.requestNextFrame();
222
+ const node = parent.self;
223
+ if (!Transaction.isCanceled || !Transaction.isFrameOver(1, RxNode.shortFrameDuration / 3)) {
224
+ let outerPriority = RxNode.currentRenderingPriority;
225
+ RxNode.currentRenderingPriority = priority;
226
+ try {
227
+ const strict = node.children.strict;
228
+ if (node.shuffle)
229
+ shuffle(items);
230
+ const frameDurationLimit = priority === Priority.AsyncP2 ? RxNode.shortFrameDuration : Infinity;
231
+ let frameDuration = Math.min(frameDurationLimit, Math.max(RxNode.frameDuration / 4, RxNode.shortFrameDuration));
232
+ for (const child of items) {
233
+ prepareThenRunRender(child, allChildren.isMoved(child), strict);
234
+ if (Transaction.isFrameOver(1, frameDuration)) {
235
+ RxNode.currentRenderingPriority = outerPriority;
236
+ yield Transaction.requestNextFrame(0);
237
+ outerPriority = RxNode.currentRenderingPriority;
238
+ RxNode.currentRenderingPriority = priority;
239
+ frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, RxNode.frameDuration));
240
+ }
241
+ if (Transaction.isCanceled && Transaction.isFrameOver(1, RxNode.shortFrameDuration / 3))
242
+ break;
243
+ }
244
+ }
245
+ finally {
246
+ RxNode.currentRenderingPriority = outerPriority;
247
+ }
248
+ }
249
+ });
250
+ }
251
+ function prepareThenRunRender(item, moved, strict) {
252
+ const node = item.self;
253
+ if (node.stamp >= 0) {
254
+ prepareRender(item, moved, strict);
255
+ if (node.inline)
256
+ runRender(item);
257
+ else
258
+ nonreactive(node.autorender, node.triggers);
259
+ }
260
+ }
261
+ function prepareRender(item, moved, strict) {
262
+ var _a, _b, _c;
263
+ const node = item.self;
264
+ const factory = node.factory;
265
+ if (node.stamp === 0) {
266
+ node.stamp = 1;
267
+ if (!node.inline) {
268
+ Transaction.outside(() => {
269
+ if (Rx.isLogging)
270
+ Rx.setLoggingHint(node, node.name);
271
+ Rx.getController(node.autorender).configure({
272
+ order: node.level,
273
+ monitor: node.monitor,
274
+ throttling: node.throttling,
275
+ logging: node.logging,
276
+ });
277
+ });
278
+ }
279
+ (_a = factory.initialize) === null || _a === void 0 ? void 0 : _a.call(factory, node, undefined);
280
+ (_b = factory.arrange) === null || _b === void 0 ? void 0 : _b.call(factory, node, strict);
281
+ }
282
+ else if (moved)
283
+ (_c = factory.arrange) === null || _c === void 0 ? void 0 : _c.call(factory, node, strict);
284
+ }
285
+ function runRender(item) {
286
+ const node = item.self;
287
+ if (node.stamp >= 0) {
288
+ runUnder(item, () => {
289
+ let result = undefined;
290
+ try {
291
+ node.stamp++;
292
+ node.children.beginMerge();
293
+ result = node.factory.render(node);
294
+ if (result instanceof Promise)
295
+ result.then(v => { runRenderChildrenThenDo(undefined, NOP); return v; }, e => { console.log(e); runRenderChildrenThenDo(e !== null && e !== void 0 ? e : new Error('unknown error'), NOP); });
296
+ else
297
+ runRenderChildrenThenDo(undefined, NOP);
298
+ }
299
+ catch (e) {
300
+ runRenderChildrenThenDo(e, NOP);
301
+ console.log(`Rendering failed: ${node.name}`);
302
+ console.log(`${e}`);
303
+ }
304
+ });
305
+ }
306
+ }
307
+ function runFinalize(item, isLeader) {
308
+ const node = item.self;
309
+ if (node.stamp >= 0) {
310
+ node.stamp = ~node.stamp;
311
+ const childrenAreLeaders = node.factory.finalize(node, isLeader);
312
+ if (!node.inline) {
313
+ item.aux = undefined;
314
+ const last = gLastToDispose;
315
+ if (last)
316
+ gLastToDispose = last.aux = item;
317
+ else
318
+ gFirstToDispose = gLastToDispose = item;
319
+ if (gFirstToDispose === item)
320
+ Transaction.run({ separation: 'disposal', hint: `runDisposalLoop(initiator=${item.self.name})` }, () => {
321
+ void runDisposalLoop().then(NOP, error => console.log(error));
322
+ });
323
+ }
324
+ for (const item of node.children.items())
325
+ runFinalize(item, childrenAreLeaders);
326
+ RxNodeImpl.grandCount--;
327
+ }
328
+ }
329
+ function runDisposalLoop() {
330
+ return __awaiter(this, void 0, void 0, function* () {
331
+ yield Transaction.requestNextFrame();
332
+ let item = gFirstToDispose;
333
+ while (item !== undefined) {
334
+ if (Transaction.isFrameOver(500, 5))
335
+ yield Transaction.requestNextFrame();
336
+ Rx.dispose(item.self);
337
+ item = item.aux;
338
+ RxNodeImpl.disposableCount--;
339
+ }
340
+ gFirstToDispose = gLastToDispose = undefined;
341
+ });
342
+ }
343
+ function forEachChildRecursively(item, action) {
344
+ const node = item.self;
345
+ const e = node.element;
346
+ e && action(e);
347
+ for (const item of node.children.items())
348
+ forEachChildRecursively(item, action);
349
+ }
350
+ function wrap(func) {
351
+ const parent = gContext;
352
+ const wrappedRunUnder = (...args) => {
353
+ return runUnder(parent, func, ...args);
354
+ };
355
+ return wrappedRunUnder;
356
+ }
357
+ function runUnder(item, func, ...args) {
358
+ const outer = gContext;
359
+ try {
360
+ gContext = item;
361
+ return func(...args);
362
+ }
363
+ finally {
364
+ gContext = outer;
365
+ }
366
+ }
367
+ function triggersAreEqual(a1, a2) {
368
+ let result = a1 === a2;
369
+ if (!result) {
370
+ if (Array.isArray(a1)) {
371
+ result = Array.isArray(a2) &&
372
+ a1.length === a2.length &&
373
+ a1.every((t, i) => t === a2[i]);
374
+ }
375
+ else if (a1 === Object(a1) && a2 === Object(a2)) {
376
+ for (const p in a1) {
377
+ result = a1[p] === a2[p];
378
+ if (!result)
379
+ break;
380
+ }
381
+ }
382
+ }
383
+ return result;
384
+ }
385
+ function push(array, item) {
386
+ if (array == undefined)
387
+ array = new Array();
388
+ array.push(item);
389
+ return array;
390
+ }
391
+ function shuffle(array) {
392
+ const n = array.length - 1;
393
+ let i = n;
394
+ while (i >= 0) {
395
+ const j = Math.floor(Math.random() * n);
396
+ const t = array[i];
397
+ array[i] = array[j];
398
+ array[j] = t;
399
+ i--;
400
+ }
401
+ return array;
402
+ }
403
+ const ORIGINAL_PROMISE_THEN = Promise.prototype.then;
404
+ function reactronicDomHookedThen(resolve, reject) {
405
+ resolve = resolve ? wrap(resolve) : defaultResolve;
406
+ reject = reject ? wrap(reject) : defaultReject;
407
+ return ORIGINAL_PROMISE_THEN.call(this, resolve, reject);
408
+ }
409
+ function defaultResolve(value) {
410
+ return value;
411
+ }
412
+ function defaultReject(error) {
413
+ throw error;
414
+ }
415
+ Promise.prototype.then = reactronicDomHookedThen;
416
+ const gSysRoot = Collection.createItem(new RxNodeImpl('SYSTEM', new StaticNodeFactory('SYSTEM', false, null), false, { level: 0 }, undefined, NOP));
417
+ gSysRoot.self.item = gSysRoot;
418
+ Object.defineProperty(gSysRoot, 'parent', {
419
+ value: gSysRoot,
420
+ writable: false,
421
+ configurable: false,
422
+ enumerable: true,
423
+ });
424
+ let gContext = gSysRoot;
425
+ let gFirstToDispose = undefined;
426
+ let gLastToDispose = undefined;
@@ -0,0 +1 @@
1
+ export declare function objectHasMember<T>(obj: any, member: string): obj is T;
@@ -0,0 +1,3 @@
1
+ export function objectHasMember(obj, member) {
2
+ return obj === Object(obj) && !Array.isArray(obj) && member in obj;
3
+ }
@@ -0,0 +1,4 @@
1
+ export * from './RxNode';
2
+ export * from './Elements';
3
+ export * from './Restyler';
4
+ export * from './Utils';
@@ -0,0 +1,4 @@
1
+ export * from './RxNode';
2
+ export * from './Elements';
3
+ export * from './Restyler';
4
+ export * from './Utils';
@@ -0,0 +1,11 @@
1
+ export interface CellRange {
2
+ x1: number;
3
+ y1: number;
4
+ x2: number;
5
+ y2: number;
6
+ }
7
+ export declare class CellRangeUtils {
8
+ static parseCellRange(text: string, result: CellRange): CellRange;
9
+ static emitCellRange(value: CellRange): string;
10
+ private static emitCellPos;
11
+ }
@@ -0,0 +1,175 @@
1
+ export class CellRangeUtils {
2
+ static parseCellRange(text, result) {
3
+ let i = 0;
4
+ let value = 0;
5
+ let sign = 1;
6
+ let component = 0;
7
+ while (i < text.length) {
8
+ const charCode = text.charCodeAt(i);
9
+ if (isCapitalLetter(charCode)) {
10
+ if (component % 2 === 0)
11
+ value = value * 26 + charCode - 64;
12
+ else
13
+ console.error(`Digit is expected, but letter ('${text[i]}') was read`);
14
+ }
15
+ else if (isLowercaseLetter(charCode)) {
16
+ if (component % 2 === 0) {
17
+ value = value * 26 + charCode - 96;
18
+ }
19
+ else {
20
+ console.error(`Digit is expected, but letter ('${text[i]}') was read`);
21
+ }
22
+ }
23
+ else if (isDigit(charCode)) {
24
+ if (component % 2 === 0) {
25
+ if (value !== 0) {
26
+ if (component === 0)
27
+ result.x1 = value * sign;
28
+ else
29
+ result.x2 = value * sign;
30
+ value = 0;
31
+ }
32
+ component++;
33
+ }
34
+ value = value * 10 + charCode - 48;
35
+ }
36
+ else if (charCode === 40) {
37
+ if (component === 0)
38
+ result.x1 = value * sign;
39
+ else if (component === 2)
40
+ result.x2 = value * sign;
41
+ if (sign > 0) {
42
+ sign = -1;
43
+ component &= ~1;
44
+ value = 0;
45
+ }
46
+ else {
47
+ console.error('Sign must not be negative');
48
+ }
49
+ }
50
+ else if (charCode === 41) {
51
+ if (sign > 0) {
52
+ console.error('Sign must be negative');
53
+ }
54
+ switch (component) {
55
+ case 0:
56
+ result.x1 = value * sign;
57
+ break;
58
+ case 1:
59
+ result.y1 = value * sign;
60
+ break;
61
+ case 2:
62
+ result.x2 = value * sign;
63
+ break;
64
+ case 3:
65
+ result.y2 = value * sign;
66
+ break;
67
+ }
68
+ sign = 1;
69
+ value = 0;
70
+ component++;
71
+ }
72
+ else if (charCode === 58) {
73
+ if (sign < 0)
74
+ console.error(`area '${text}': e1`);
75
+ if (component === 1)
76
+ result.y1 = value * sign;
77
+ else if (component !== 2)
78
+ console.error(`area '${text}': [e2] component = ${component}`);
79
+ component = 2;
80
+ value = 0;
81
+ }
82
+ else if (isWhitespace(charCode)) {
83
+ }
84
+ else {
85
+ console.error(`Unknown symbol '${text[i]}' in '${text}'`);
86
+ }
87
+ i++;
88
+ }
89
+ if (value !== 0) {
90
+ switch (component) {
91
+ case 0: {
92
+ result.x1 = value * sign;
93
+ if (sign < 0 && result.y1 === 0)
94
+ result.y1 = sign;
95
+ break;
96
+ }
97
+ case 1: {
98
+ if (sign < 0 && result.x1 === 0)
99
+ result.x1 = sign;
100
+ result.y1 = value * sign;
101
+ break;
102
+ }
103
+ case 2: {
104
+ result.x2 = value * sign;
105
+ if (sign < 0 && result.y2 === 0)
106
+ result.y2 = sign;
107
+ break;
108
+ }
109
+ case 3: {
110
+ if (sign < 0 && result.x2 === 0)
111
+ result.x2 = sign;
112
+ result.y2 = value * sign;
113
+ break;
114
+ }
115
+ }
116
+ }
117
+ else if (sign < 0) {
118
+ if (component === 0) {
119
+ if (result.x1 === 0)
120
+ result.x1 = sign;
121
+ if (result.y1 === 0)
122
+ result.y1 = sign;
123
+ }
124
+ else {
125
+ if (result.x2 === 0)
126
+ result.x2 = sign;
127
+ if (result.y2 === 0)
128
+ result.y2 = sign;
129
+ }
130
+ }
131
+ return result;
132
+ }
133
+ static emitCellRange(value) {
134
+ const p1 = CellRangeUtils.emitCellPos(value.x1, value.y1);
135
+ const p2 = CellRangeUtils.emitCellPos(value.x2, value.y2);
136
+ return `${p1}${p2 !== '' ? `:${p2}` : ''}`;
137
+ }
138
+ static emitCellPos(x, y) {
139
+ let result = '';
140
+ if (x > 0 && y > 0)
141
+ result = `${emitLetters(x - 1)}${y}`;
142
+ else if (x > 0 && y < 0)
143
+ result = `${emitLetters(x - 1)}(${-y})`;
144
+ else if (x < 0 && y > 0)
145
+ result = `(${emitLetters(-x - 1)})${y}`;
146
+ else if (x < 0 && y < 0)
147
+ result = `(${emitLetters(-x - 1)}${-y})`;
148
+ else
149
+ result = '';
150
+ return result;
151
+ }
152
+ }
153
+ function isWhitespace(char) {
154
+ return char === 32 || (char >= 9 && char <= 13) || char === 133 || char === 160;
155
+ }
156
+ function isDigit(input, index) {
157
+ return 48 <= input && input <= 57;
158
+ }
159
+ function isCapitalLetter(ch) {
160
+ return 65 <= ch && ch <= 90;
161
+ }
162
+ function isLowercaseLetter(ch) {
163
+ return 97 <= ch && ch <= 122;
164
+ }
165
+ function emitLetters(n) {
166
+ if (n < 0)
167
+ throw new Error(`emitLetters: argument (${n}) should not be negative or zero`);
168
+ let result = '';
169
+ while (n >= 0) {
170
+ const r = n % 26;
171
+ n = Math.floor(n / 26) - 1;
172
+ result = String.fromCharCode(65 + r) + result;
173
+ }
174
+ return result;
175
+ }
@@ -0,0 +1,7 @@
1
+ import { DataForSensor } from './sensors/DataForSensor';
2
+ declare global {
3
+ interface Element {
4
+ dataForSensor: DataForSensor;
5
+ resizeObserver?: ResizeObserver;
6
+ }
7
+ }
@@ -0,0 +1,25 @@
1
+ import { SymDataForSensor, SymResizeObserver } from './sensors/DataForSensor';
2
+ const ElementType = global.Element;
3
+ if (ElementType !== undefined) {
4
+ Object.defineProperty(ElementType.prototype, 'dataForSensor', {
5
+ configurable: false, enumerable: false,
6
+ get() {
7
+ let result = this[SymDataForSensor];
8
+ if (result === undefined)
9
+ result = this[SymDataForSensor] = {};
10
+ return result;
11
+ },
12
+ set(value) {
13
+ this[SymDataForSensor] = value;
14
+ },
15
+ });
16
+ Object.defineProperty(ElementType.prototype, 'resizeObserver', {
17
+ configurable: false, enumerable: false,
18
+ get() {
19
+ return this[SymResizeObserver];
20
+ },
21
+ set(value) {
22
+ this[SymResizeObserver] = value;
23
+ },
24
+ });
25
+ }