@dra2020/baseclient 1.0.20 → 1.0.23
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 +85 -3
- 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/util/bintrie.d.ts +2 -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/util/bintrie.ts +23 -2
- 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/util/bintrie.d.ts
CHANGED
|
@@ -69,9 +69,11 @@ 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;
|
|
76
|
+
verbose?: boolean;
|
|
75
77
|
}
|
|
76
78
|
export declare class BinTrieBuilder {
|
|
77
79
|
options: BinTrieOptions;
|
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/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,13 +345,31 @@ 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
|
|
349
368
|
{
|
|
350
369
|
dedup?: boolean,
|
|
370
|
+
verbose?: boolean,
|
|
351
371
|
}
|
|
352
|
-
let DefaultOptions: BinTrieOptions = { dedup: true };
|
|
372
|
+
let DefaultOptions: BinTrieOptions = { dedup: true, verbose: false };
|
|
353
373
|
|
|
354
374
|
export class BinTrieBuilder
|
|
355
375
|
{
|
|
@@ -607,7 +627,8 @@ export class BinTrieBuilder
|
|
|
607
627
|
}
|
|
608
628
|
});
|
|
609
629
|
|
|
610
|
-
|
|
630
|
+
if (btb.options.verbose)
|
|
631
|
+
console.log(`bintrie: total size: ${btb.u8.length}, value table size: ${btb.vtb.u8.length}`);
|
|
611
632
|
|
|
612
633
|
return bt;
|
|
613
634
|
}
|