@dra2020/baseclient 1.0.21 → 1.0.24
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/dist/all/all.d.ts +2 -0
- package/dist/baseclient.js +107 -18
- package/dist/baseclient.js.map +1 -1
- package/dist/emit/all.d.ts +1 -0
- package/dist/emit/emit.d.ts +7 -0
- package/dist/ot-js/otsession.d.ts +2 -0
- package/dist/poly/boundbox.d.ts +1 -0
- package/dist/poly/quad.d.ts +3 -1
- package/dist/util/bintrie.d.ts +1 -0
- package/lib/all/all.ts +2 -0
- package/lib/emit/all.ts +1 -0
- package/lib/emit/emit.ts +40 -0
- package/lib/ot-js/otsession.ts +2 -0
- package/lib/poly/boundbox.ts +5 -0
- package/lib/poly/quad.ts +27 -18
- package/lib/util/bintrie.ts +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './emit';
|
|
@@ -53,10 +53,12 @@ export declare type RevisionList = Revision[];
|
|
|
53
53
|
export interface SessionUser {
|
|
54
54
|
id: string;
|
|
55
55
|
name: string;
|
|
56
|
+
twitterhandle: string;
|
|
56
57
|
}
|
|
57
58
|
export interface ActiveUser {
|
|
58
59
|
id: string;
|
|
59
60
|
name: string;
|
|
61
|
+
twitterhandle: string;
|
|
60
62
|
active: number;
|
|
61
63
|
}
|
|
62
64
|
export interface SessionUserIndex {
|
package/dist/poly/boundbox.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export declare function boundbox(poly: any, bbox?: BoundBox): BoundBox;
|
|
|
14
14
|
export declare function boundboxPoly(bb: BoundBox): any;
|
|
15
15
|
export declare function boundboxArea(poly: any): number;
|
|
16
16
|
export declare function boundboxIntersects(bb1: BoundBox, bb2: BoundBox): boolean;
|
|
17
|
+
export declare function boundboxContains(bb: BoundBox, x: number, y: number): boolean;
|
package/dist/poly/quad.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as FSM from '../fsm/all';
|
|
|
2
2
|
import * as Poly from './poly';
|
|
3
3
|
import * as BB from './boundbox';
|
|
4
4
|
export interface WrappedPoly {
|
|
5
|
+
f: any;
|
|
5
6
|
box: BB.BoundBox;
|
|
6
7
|
p: any;
|
|
7
8
|
}
|
|
@@ -24,11 +25,12 @@ declare class QuadLevel {
|
|
|
24
25
|
options: QuadOptions;
|
|
25
26
|
level: number;
|
|
26
27
|
children: QuadLevel[];
|
|
27
|
-
features:
|
|
28
|
+
features: WrappedPoly[];
|
|
28
29
|
box: BB.BoundBox;
|
|
29
30
|
asyncUnion: any;
|
|
30
31
|
constructor(options: QuadOptions, level: number, box: BB.BoundBox, features: WrappedPoly[]);
|
|
31
32
|
private featureInBox;
|
|
33
|
+
featureUnderCoord(coord: [number, number]): any;
|
|
32
34
|
union(): any;
|
|
33
35
|
get isempty(): boolean;
|
|
34
36
|
tickUnion(tickCounter: TickCounter): void;
|
package/dist/util/bintrie.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ export declare class BinTrie {
|
|
|
69
69
|
constructor(coder: Coder);
|
|
70
70
|
static fromBuffer(coder: Coder, ab: ArrayBuffer): BinTrie;
|
|
71
71
|
get(key: string): string;
|
|
72
|
+
forEach(cb: (k: string, v: string) => void): void;
|
|
72
73
|
}
|
|
73
74
|
export interface BinTrieOptions {
|
|
74
75
|
dedup?: boolean;
|
package/lib/all/all.ts
CHANGED
package/lib/emit/all.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './emit';
|
package/lib/emit/emit.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class Emit
|
|
2
|
+
{
|
|
3
|
+
onList: any;
|
|
4
|
+
|
|
5
|
+
constructor()
|
|
6
|
+
{
|
|
7
|
+
this.onList = {};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
on(eventName: string, cb: any): void
|
|
11
|
+
{
|
|
12
|
+
let aCB: any = this.onList[eventName];
|
|
13
|
+
if (aCB === undefined)
|
|
14
|
+
{
|
|
15
|
+
aCB = [];
|
|
16
|
+
this.onList[eventName] = aCB;
|
|
17
|
+
}
|
|
18
|
+
aCB.push(cb);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
emit(eventName: string, arg1?: any, arg2?: any, arg3?: any): void
|
|
22
|
+
{
|
|
23
|
+
let aCB: any[] = this.onList[eventName];
|
|
24
|
+
if (aCB !== undefined)
|
|
25
|
+
for (let i: number = 0; i < aCB.length; i++)
|
|
26
|
+
(aCB[i])(arg1, arg2, arg3);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
off(eventName: string, cb: any): void
|
|
30
|
+
{
|
|
31
|
+
let aCB: any = this.onList[eventName];
|
|
32
|
+
if (aCB !== undefined)
|
|
33
|
+
for (let i: number = 0; i < aCB.length; i++)
|
|
34
|
+
if (aCB[i] === cb)
|
|
35
|
+
{
|
|
36
|
+
aCB.splice(i, 1);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/lib/ot-js/otsession.ts
CHANGED
package/lib/poly/boundbox.ts
CHANGED
|
@@ -100,3 +100,8 @@ export function boundboxIntersects(bb1: BoundBox, bb2: BoundBox): boolean
|
|
|
100
100
|
{
|
|
101
101
|
return !(bb1.left > bb2.right || bb1.right < bb2.left || bb1.top < bb2.bottom || bb1.bottom > bb2.top);
|
|
102
102
|
}
|
|
103
|
+
|
|
104
|
+
export function boundboxContains(bb: BoundBox, x: number, y: number): boolean
|
|
105
|
+
{
|
|
106
|
+
return !(bb.left >= x || bb.right < x || bb.top <= y || bb.bottom > y);
|
|
107
|
+
}
|
package/lib/poly/quad.ts
CHANGED
|
@@ -10,6 +10,7 @@ import * as Poly from './poly';
|
|
|
10
10
|
import * as PP from './polypack';
|
|
11
11
|
import * as BB from './boundbox';
|
|
12
12
|
import * as PR from './polyround';
|
|
13
|
+
import { polyContainsPoint } from './pointinpoly';
|
|
13
14
|
|
|
14
15
|
let _union: any = undefined;
|
|
15
16
|
let anyPC: any = PC;
|
|
@@ -17,7 +18,7 @@ if (anyPC.union) _union = anyPC.union;
|
|
|
17
18
|
if (anyPC.default && anyPC.default.union) _union = anyPC.default.union;
|
|
18
19
|
if (_union === undefined) throw 'Unable to load union function from polygon-clipping';
|
|
19
20
|
|
|
20
|
-
export interface WrappedPoly { box: BB.BoundBox, p: any };
|
|
21
|
+
export interface WrappedPoly { f: any, box: BB.BoundBox, p: any };
|
|
21
22
|
|
|
22
23
|
export interface WorkDone
|
|
23
24
|
{
|
|
@@ -28,19 +29,6 @@ export interface WorkDone
|
|
|
28
29
|
|
|
29
30
|
function featureCoords(feature: any): any
|
|
30
31
|
{
|
|
31
|
-
/*
|
|
32
|
-
if (feature.geometry !== undefined)
|
|
33
|
-
{
|
|
34
|
-
if (feature.geometry.packed !== undefined)
|
|
35
|
-
return PP.polyUnpack(feature.geometry.packed);
|
|
36
|
-
else
|
|
37
|
-
return feature.geometry.coordinates;
|
|
38
|
-
}
|
|
39
|
-
else if (feature.offset !== undefined)
|
|
40
|
-
return PP.polyUnpack(feature);
|
|
41
|
-
else
|
|
42
|
-
return feature;
|
|
43
|
-
*/
|
|
44
32
|
if (feature.geometry !== undefined)
|
|
45
33
|
{
|
|
46
34
|
if (feature.geometry.packed !== undefined)
|
|
@@ -85,7 +73,7 @@ class QuadLevel
|
|
|
85
73
|
options: QuadOptions;
|
|
86
74
|
level: number;
|
|
87
75
|
children: QuadLevel[];
|
|
88
|
-
features:
|
|
76
|
+
features: WrappedPoly[];
|
|
89
77
|
box: BB.BoundBox;
|
|
90
78
|
asyncUnion: any;
|
|
91
79
|
|
|
@@ -98,7 +86,7 @@ class QuadLevel
|
|
|
98
86
|
{
|
|
99
87
|
if (this.level >= options.maxDepth)
|
|
100
88
|
throw `QuadTree: maximum depth of ${options.maxDepth} exceeded`;
|
|
101
|
-
this.features = features
|
|
89
|
+
this.features = features;
|
|
102
90
|
this.children = null;
|
|
103
91
|
}
|
|
104
92
|
else
|
|
@@ -143,12 +131,33 @@ class QuadLevel
|
|
|
143
131
|
return BB.boundboxIntersects(box, f.box);
|
|
144
132
|
}
|
|
145
133
|
|
|
134
|
+
featureUnderCoord(coord: [ number, number ]): any
|
|
135
|
+
{
|
|
136
|
+
if (! BB.boundboxContains(this.box, coord[0], coord[1]))
|
|
137
|
+
return null;
|
|
138
|
+
if (this.features)
|
|
139
|
+
{
|
|
140
|
+
let wp = this.features.find(wp => polyContainsPoint(wp.p, coord[0], coord[1]));
|
|
141
|
+
return wp ? wp.f : null;
|
|
142
|
+
}
|
|
143
|
+
else
|
|
144
|
+
{
|
|
145
|
+
for (let i = 0; i < this.children.length; i++)
|
|
146
|
+
{
|
|
147
|
+
let f = this.children[i].featureUnderCoord(coord);
|
|
148
|
+
if (f)
|
|
149
|
+
return f;
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
146
155
|
union(): any
|
|
147
156
|
{
|
|
148
157
|
if (this.asyncUnion == null)
|
|
149
158
|
{
|
|
150
159
|
if (this.children == null)
|
|
151
|
-
this.asyncUnion = unionPolys(this.features);
|
|
160
|
+
this.asyncUnion = unionPolys(this.features.map(f => f.p));
|
|
152
161
|
else
|
|
153
162
|
this.asyncUnion = unionPolys(this.children.map((q: QuadLevel) => q.union()));
|
|
154
163
|
}
|
|
@@ -217,7 +226,7 @@ export class FsmQuadTree extends FSM.Fsm
|
|
|
217
226
|
this.isempty = features.length == 0;
|
|
218
227
|
|
|
219
228
|
// Compute BoundBox for each feature
|
|
220
|
-
let wrapped: WrappedPoly[] = features.map((f: any) => { return { box: BB.boundbox(f), p: featureCoords(f) } });
|
|
229
|
+
let wrapped: WrappedPoly[] = features.map((f: any) => { return { f: f, box: BB.boundbox(f), p: featureCoords(f) } });
|
|
221
230
|
|
|
222
231
|
let box = BB.boundbox(col);
|
|
223
232
|
this.quad = new QuadLevel(this.options, 0, box, wrapped);
|
package/lib/util/bintrie.ts
CHANGED
|
@@ -57,6 +57,8 @@ Util.setCoder({ encoder: new u.TextEncoder(), decoder: new u.TextDecoder('utf-8'
|
|
|
57
57
|
Util.setCoder({ encoder: new TextEncoder(), decoder: new TextDecoder('utf-8') });
|
|
58
58
|
*/
|
|
59
59
|
|
|
60
|
+
const MaxKeyLength = 128;
|
|
61
|
+
|
|
60
62
|
export function s2u8(coder: Coder, s: string): Uint8Array
|
|
61
63
|
{
|
|
62
64
|
return coder.encoder.encode(s);
|
|
@@ -343,6 +345,23 @@ export class BinTrie
|
|
|
343
345
|
}
|
|
344
346
|
return undefined;
|
|
345
347
|
}
|
|
348
|
+
|
|
349
|
+
forEach(cb: (k: string, v: string) => void)
|
|
350
|
+
{
|
|
351
|
+
let keybuf = new Uint8Array(MaxKeyLength);
|
|
352
|
+
let keylen = 0;
|
|
353
|
+
|
|
354
|
+
let processNode = (len: number, byteOffset: number) => {
|
|
355
|
+
let iOffset = byteOffset >> 2;
|
|
356
|
+
let n = this.i32[iOffset];
|
|
357
|
+
byteOffset += 4;
|
|
358
|
+
for (let j = 0; j < n; j++)
|
|
359
|
+
{
|
|
360
|
+
keybuf[keylen++] = this.u8[byteOffset+j];
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
processNode(0, 4);
|
|
364
|
+
}
|
|
346
365
|
}
|
|
347
366
|
|
|
348
367
|
export interface BinTrieOptions
|