@dra2020/baseclient 1.0.12 → 1.0.13

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 (120) hide show
  1. package/package.json +16 -15
  2. package/LICENSE +0 -21
  3. package/README.md +0 -26
  4. package/dist/all/all.d.ts +0 -20
  5. package/dist/baseclient.js +0 -10113
  6. package/dist/baseclient.js.map +0 -1
  7. package/dist/context/all.d.ts +0 -1
  8. package/dist/context/context.d.ts +0 -13
  9. package/dist/filterexpr/all.d.ts +0 -1
  10. package/dist/filterexpr/filterexpr.d.ts +0 -67
  11. package/dist/fsm/all.d.ts +0 -1
  12. package/dist/fsm/fsm.d.ts +0 -119
  13. package/dist/geo/all.d.ts +0 -2
  14. package/dist/geo/geo.d.ts +0 -67
  15. package/dist/geo/vfeature.d.ts +0 -4
  16. package/dist/logabstract/all.d.ts +0 -1
  17. package/dist/logabstract/log.d.ts +0 -26
  18. package/dist/logclient/all.d.ts +0 -1
  19. package/dist/logclient/log.d.ts +0 -6
  20. package/dist/ot-editutil/all.d.ts +0 -2
  21. package/dist/ot-editutil/oteditutil.d.ts +0 -14
  22. package/dist/ot-editutil/otmaputil.d.ts +0 -21
  23. package/dist/ot-js/all.d.ts +0 -9
  24. package/dist/ot-js/otarray.d.ts +0 -111
  25. package/dist/ot-js/otclientengine.d.ts +0 -38
  26. package/dist/ot-js/otcomposite.d.ts +0 -37
  27. package/dist/ot-js/otcounter.d.ts +0 -17
  28. package/dist/ot-js/otengine.d.ts +0 -22
  29. package/dist/ot-js/otmap.d.ts +0 -19
  30. package/dist/ot-js/otserverengine.d.ts +0 -38
  31. package/dist/ot-js/otsession.d.ts +0 -114
  32. package/dist/ot-js/ottypes.d.ts +0 -29
  33. package/dist/poly/all.d.ts +0 -15
  34. package/dist/poly/blend.d.ts +0 -1
  35. package/dist/poly/boundbox.d.ts +0 -16
  36. package/dist/poly/cartesian.d.ts +0 -5
  37. package/dist/poly/graham-scan.d.ts +0 -8
  38. package/dist/poly/hash.d.ts +0 -1
  39. package/dist/poly/matrix.d.ts +0 -24
  40. package/dist/poly/minbound.d.ts +0 -1
  41. package/dist/poly/poly.d.ts +0 -52
  42. package/dist/poly/polybin.d.ts +0 -5
  43. package/dist/poly/polylabel.d.ts +0 -7
  44. package/dist/poly/polypack.d.ts +0 -30
  45. package/dist/poly/polyround.d.ts +0 -1
  46. package/dist/poly/polysimplify.d.ts +0 -1
  47. package/dist/poly/quad.d.ts +0 -48
  48. package/dist/poly/selfintersect.d.ts +0 -1
  49. package/dist/poly/shamos.d.ts +0 -1
  50. package/dist/poly/simplify.d.ts +0 -2
  51. package/dist/poly/topo.d.ts +0 -46
  52. package/dist/poly/union.d.ts +0 -49
  53. package/dist/util/all.d.ts +0 -5
  54. package/dist/util/bintrie.d.ts +0 -93
  55. package/dist/util/countedhash.d.ts +0 -19
  56. package/dist/util/gradient.d.ts +0 -15
  57. package/dist/util/indexedarray.d.ts +0 -15
  58. package/dist/util/util.d.ts +0 -68
  59. package/docs/context.md +0 -2
  60. package/docs/filterexpr.md +0 -22
  61. package/docs/fsm.md +0 -243
  62. package/docs/logabstract.md +0 -2
  63. package/docs/logclient.md +0 -2
  64. package/docs/ot-editutil.md +0 -2
  65. package/docs/ot-js.md +0 -95
  66. package/docs/poly.md +0 -103
  67. package/docs/util.md +0 -2
  68. package/lib/all/all.ts +0 -21
  69. package/lib/context/all.ts +0 -1
  70. package/lib/context/context.ts +0 -82
  71. package/lib/filterexpr/all.ts +0 -1
  72. package/lib/filterexpr/filterexpr.ts +0 -699
  73. package/lib/fsm/all.ts +0 -1
  74. package/lib/fsm/fsm.ts +0 -559
  75. package/lib/geo/all.ts +0 -2
  76. package/lib/geo/geo.ts +0 -452
  77. package/lib/geo/vfeature.ts +0 -34
  78. package/lib/logabstract/all.ts +0 -1
  79. package/lib/logabstract/log.ts +0 -55
  80. package/lib/logclient/all.ts +0 -1
  81. package/lib/logclient/log.ts +0 -105
  82. package/lib/ot-editutil/all.ts +0 -2
  83. package/lib/ot-editutil/oteditutil.ts +0 -180
  84. package/lib/ot-editutil/otmaputil.ts +0 -209
  85. package/lib/ot-js/all.ts +0 -9
  86. package/lib/ot-js/otarray.ts +0 -1168
  87. package/lib/ot-js/otclientengine.ts +0 -327
  88. package/lib/ot-js/otcomposite.ts +0 -247
  89. package/lib/ot-js/otcounter.ts +0 -145
  90. package/lib/ot-js/otengine.ts +0 -71
  91. package/lib/ot-js/otmap.ts +0 -144
  92. package/lib/ot-js/otserverengine.ts +0 -329
  93. package/lib/ot-js/otsession.ts +0 -202
  94. package/lib/ot-js/ottypes.ts +0 -98
  95. package/lib/poly/all.ts +0 -15
  96. package/lib/poly/blend.ts +0 -27
  97. package/lib/poly/boundbox.ts +0 -102
  98. package/lib/poly/cartesian.ts +0 -130
  99. package/lib/poly/graham-scan.ts +0 -401
  100. package/lib/poly/hash.ts +0 -15
  101. package/lib/poly/matrix.ts +0 -309
  102. package/lib/poly/minbound.ts +0 -211
  103. package/lib/poly/poly.ts +0 -767
  104. package/lib/poly/polybin.ts +0 -218
  105. package/lib/poly/polylabel.ts +0 -204
  106. package/lib/poly/polypack.ts +0 -468
  107. package/lib/poly/polyround.ts +0 -30
  108. package/lib/poly/polysimplify.ts +0 -24
  109. package/lib/poly/quad.ts +0 -272
  110. package/lib/poly/selfintersect.ts +0 -87
  111. package/lib/poly/shamos.ts +0 -297
  112. package/lib/poly/simplify.ts +0 -119
  113. package/lib/poly/topo.ts +0 -499
  114. package/lib/poly/union.ts +0 -388
  115. package/lib/util/all.ts +0 -5
  116. package/lib/util/bintrie.ts +0 -603
  117. package/lib/util/countedhash.ts +0 -83
  118. package/lib/util/gradient.ts +0 -108
  119. package/lib/util/indexedarray.ts +0 -80
  120. package/lib/util/util.ts +0 -695
@@ -1,180 +0,0 @@
1
- import * as LogAbstract from '../logabstract/all';
2
- import * as OT from '../ot-js/all';
3
-
4
- import * as DMP from "diff-match-patch";
5
- let DiffMatchPatch = new DMP.diff_match_patch();
6
- let DIFF_DELETE = DMP.DIFF_DELETE;
7
- let DIFF_INSERT = DMP.DIFF_INSERT;
8
- let DIFF_EQUAL = DMP.DIFF_EQUAL;
9
-
10
- export class OTEditUtil
11
- {
12
- // Data members
13
- ilog: LogAbstract.ILog;
14
- resourceID: string;
15
- resourceName: string;
16
- clientID: string;
17
-
18
- // Constructor
19
- constructor(ilog: LogAbstract.ILog, rid: string, cid: string, name: string)
20
- {
21
- this.ilog = ilog;
22
- this.resourceID = rid;
23
- this.clientID = cid;
24
- this.resourceName = name;
25
- }
26
-
27
- //
28
- // Function: insertAtStart
29
- //
30
- // Description:
31
- // Generate an OTCompositeResource to insert a string at the start of a buffer of the given size.
32
- //
33
-
34
- insertAtStart(s: any, nCurrentLen: number): OT.OTCompositeResource
35
- {
36
- let edit = new OT.OTCompositeResource(this.resourceID, this.clientID);
37
- let sEdit = new OT.OTStringResource(this.resourceName);
38
- sEdit.edits.push([ OT.OpInsert, s.length, s ]);
39
- sEdit.edits.push([ OT.OpCursor, 0, '' ]);
40
- sEdit.edits.push([ OT.OpRetain, nCurrentLen, '' ]);
41
- edit.edits.push(sEdit);
42
- return edit;
43
- }
44
-
45
- //
46
- // Function: insertAtEnd
47
- //
48
- // Description:
49
- // Generate an OTCompositeResource to insert a string at the end of a buffer of the given size.
50
- //
51
-
52
- insertAtEnd(s: any, nCurrentLen: number): OT.OTCompositeResource
53
- {
54
- let edit = new OT.OTCompositeResource(this.resourceID, this.clientID);
55
- let sEdit = new OT.OTStringResource(this.resourceName);
56
- sEdit.edits.push([ OT.OpRetain, nCurrentLen, '' ]);
57
- sEdit.edits.push([ OT.OpInsert, s.length, s ]);
58
- sEdit.edits.push([ OT.OpCursor, 0, '' ]);
59
- edit.edits.push(sEdit);
60
- return edit;
61
- }
62
-
63
- //
64
- // Function: injectCursor
65
- //
66
- // Inject start/end cursor positions into an existing string resource.
67
- //
68
-
69
- injectCursor(edit: OT.OTCompositeResource, start: number, end?: number): void
70
- {
71
- if (start === undefined) return;
72
- if (end === undefined) end = start;
73
-
74
- let sEdit: OT.OTStringResource = edit.findResource(this.resourceName) as OT.OTStringResource;
75
- if (sEdit == null)
76
- return;
77
- let cEdit: OT.OTStringResource = new OT.OTStringResource(this.resourceName);
78
- if (start != 0)
79
- cEdit.edits.push( [ OT.OpRetain, start, '' ] );
80
- cEdit.edits.push( [ OT.OpCursor, 0, this.clientID ] );
81
- if (end != start)
82
- {
83
- cEdit.edits.push( [ OT.OpRetain, end-start, '' ] );
84
- cEdit.edits.push( [ OT.OpCursor, 1, this.clientID ] );
85
- }
86
- let nFinal: number = sEdit.finalLength();
87
- if (end != nFinal)
88
- cEdit.edits.push( [ OT.OpRetain, nFinal-end, '' ] );
89
- sEdit.compose(cEdit);
90
- }
91
-
92
- //
93
- // Function: extractCursor
94
- //
95
- // Extract cursor information by client. Returns an object indexed by clientID with an object with
96
- // properties startSelection, endSelection.
97
- //
98
-
99
- extractCursor(edit: OT.OTCompositeResource): any
100
- {
101
- let cursors: any = { };
102
- let sEdit: OT.OTStringResource = edit.findResource(this.resourceName) as OT.OTStringResource;
103
- if (sEdit == null)
104
- return cursors;
105
- let pos: number = 0;
106
- for (let i: number = 0; i < sEdit.length; i++)
107
- {
108
- let a: OT.OTSingleArrayEdit = sEdit.edits[i];
109
- switch (a[0])
110
- {
111
- case OT.OpInsert:
112
- pos += a[1];
113
- break;
114
- case OT.OpDelete:
115
- break;
116
- case OT.OpRetain:
117
- pos += a[1];
118
- break;
119
- case OT.OpCursor:
120
- if (a[2] != '') // should have clientID...
121
- {
122
- let sel: any = cursors[a[2]]; // a[2] is clientID
123
- if (sel === undefined) { sel = { }; cursors[a[2]] = sel; }
124
- if (a[1] == 0)
125
- sel['selectionStart'] = pos; // 0 is selectionStart
126
- else
127
- sel['selectionEnd'] = pos; // 1 is selectionEnd
128
- }
129
- break;
130
- case OT.OpSet:
131
- pos += a[1];
132
- break;
133
- }
134
- }
135
- return cursors;
136
- }
137
-
138
- //
139
- // Function: computeEdit
140
- //
141
- // Description:
142
- // Given an old and new string, generate the (minimal) edits list necessary to convert the old
143
- // string into the new string.
144
- //
145
- // This is useful if you're not actually tracking the specfic edit operations happening to the
146
- // underlying string but rather just examining old and new values and trying to transmit
147
- // minimal diffs.
148
- //
149
- // There are various good algorithms for computing the "edit distance" between two strings.
150
- // Here I've used the google DiffMatchPatch algorithm.
151
- //
152
-
153
- computeEdit(sOld: string, sNew: string): OT.OTCompositeResource
154
- {
155
- let edit = new OT.OTCompositeResource(this.resourceID, this.clientID);
156
- let sEdit = new OT.OTStringResource(this.resourceName);
157
- let diffs: DMP.Diff[] = DiffMatchPatch.diff_main(sOld, sNew);
158
- if (diffs)
159
- for (let i: number = 0; i < diffs.length; i++)
160
- {
161
- let diff: DMP.Diff = diffs[i];
162
- let s = diff[1];
163
- switch (diff[0])
164
- {
165
- case DIFF_DELETE:
166
- sEdit.edits.push([ OT.OpDelete, s.length, '' ]);
167
- break;
168
- case DIFF_INSERT:
169
- sEdit.edits.push([ OT.OpInsert, s.length, s ]);
170
- break;
171
- case DIFF_EQUAL:
172
- sEdit.edits.push([ OT.OpRetain, s.length, '' ]);
173
- break;
174
- }
175
- }
176
-
177
- edit.edits.push(sEdit);
178
- return edit;
179
- }
180
- }
@@ -1,209 +0,0 @@
1
- import * as OT from '../ot-js/all';
2
- import * as Util from '../util/all';
3
-
4
- export const MERGE: number = 0;
5
- export const REPLACE: number = 1;
6
-
7
- export class Editor
8
- {
9
- private engine: OT.OTEngine;
10
- private root: OT.OTCompositeResource;
11
- private stamps: OT.OTCounterResource;
12
-
13
- constructor(engine: OT.OTEngine)
14
- {
15
- this.engine = engine;
16
- this.root = null;
17
- this.stamps = null;
18
- }
19
-
20
- startLocalEdit(): void
21
- {
22
- if (this.root == null)
23
- this.root = this.engine.startLocalEdit();
24
- }
25
-
26
- stamp(rid: string, prop: string): void
27
- {
28
- if (this.stamps == null)
29
- {
30
- this.startLocalEdit();
31
- this.stamps = new OT.OTCounterResource(rid);
32
- this.root.edits.push(this.stamps);
33
- }
34
- this.stamps.edits.push([ OT.OpCounterAdd, prop, 1 ]);
35
- }
36
-
37
- set(rid: string, p: string, v: any): Editor
38
- {
39
- this.rawObject(rid).set(p, v);
40
- return this;
41
- }
42
-
43
- del(rid: string, p: string): Editor
44
- {
45
- this.rawObject(rid).del(p);
46
- return this;
47
- }
48
-
49
- rawObject(rid: string): OT.OTMapResource
50
- {
51
- this.startLocalEdit();
52
- return this.root.map(rid);
53
- }
54
-
55
- rawArray(rid: string): OT.OTArrayResource
56
- {
57
- this.startLocalEdit();
58
- return this.root.array(rid);
59
- }
60
-
61
- editCounter(rid: string, oNew: any, mode: number = MERGE): void
62
- {
63
- let oOld = this.engine.toPartialValue(rid);
64
- let aDiff: string[] = keyDiff(oOld, oNew);
65
-
66
- let mEdit = new OT.OTCounterResource(rid);
67
-
68
- // Propagate sets
69
- for (let i: number = 0; i < aDiff.length; i++)
70
- mEdit.edits.push([ OT.OpCounterAdd, aDiff[i], oNew[aDiff[i]] ]);
71
-
72
- // Also propagate deletes if REPLACE mode
73
- if (mode == REPLACE)
74
- {
75
- for (var p in oOld) if (oOld.hasOwnProperty(p))
76
- if (oNew[p] === undefined)
77
- mEdit.edits.push([ OT.OpCounterDel, p, 0 ]);
78
- }
79
-
80
- if (mEdit.edits.length)
81
- {
82
- this.startLocalEdit();
83
- this.root.edits.push(mEdit);
84
- }
85
- }
86
-
87
- editObject(rid: string, oNew: any, mode: number = MERGE): void
88
- {
89
- if (rid === 'stamps')
90
- {
91
- this.editCounter(rid, oNew, mode);
92
- return;
93
- }
94
-
95
- let oOld = this.engine.toPartialValue(rid);
96
- let aDiff: string[] = keyDiff(oOld, oNew);
97
-
98
- let mEdit = new OT.OTMapResource(rid);
99
-
100
- // Propagate sets
101
- for (let i: number = 0; i < aDiff.length; i++)
102
- mEdit.edits.push([ OT.OpMapSet, aDiff[i], oNew[aDiff[i]] ]);
103
-
104
- // Also propagate deletes if REPLACE mode
105
- if (mode == REPLACE)
106
- {
107
- for (var p in oOld) if (oOld.hasOwnProperty(p))
108
- if (oNew[p] === undefined)
109
- mEdit.edits.push([ OT.OpMapDel, p, 0 ]);
110
- }
111
-
112
- if (mEdit.edits.length)
113
- {
114
- this.startLocalEdit();
115
- this.root.edits.push(mEdit);
116
- }
117
- }
118
-
119
- editArray(rid: string, aNew: any[]): void
120
- {
121
- let aOld = this.engine.toPartialValue(rid);
122
- if (aOld == null) aOld = [];
123
- if (Util.deepEqual(aNew, aOld))
124
- return;
125
-
126
- let aEdit = new OT.OTArrayResource(rid);
127
-
128
- let i: number = 0;
129
- let iRetain: number = 0;
130
- for (; i < aNew.length && i < aOld.length; i++)
131
- if (Util.deepEqual(aNew[i], aOld[i]))
132
- iRetain++;
133
- else
134
- {
135
- if (iRetain > 0)
136
- {
137
- aEdit.edits.push([ OT.OpRetain, iRetain, [] ] );
138
- iRetain = 0;
139
- }
140
- aEdit.edits.push([ OT.OpSet, 1, [ aNew[i] ] ]);
141
- }
142
- // Preserve equal ones at end
143
- if (iRetain > 0)
144
- aEdit.edits.push([ OT.OpRetain, iRetain, [] ] );
145
- // Add new ones
146
- if (aNew.length > i)
147
- aEdit.edits.push([ OT.OpInsert, aNew.length - i, aNew.slice(i) ]);
148
- // Or delete old ones
149
- else if (aOld.length > i)
150
- aEdit.edits.push([ OT.OpDelete, aOld.length - i, [] ]);
151
-
152
- if (aEdit.edits.length)
153
- {
154
- this.startLocalEdit();
155
- this.root.edits.push(aEdit);
156
- }
157
- }
158
-
159
- edit(oNew: any): boolean
160
- {
161
- for (var p in oNew) if (oNew.hasOwnProperty(p))
162
- if (Array.isArray(oNew[p]))
163
- this.editArray(p, oNew[p]);
164
- else
165
- this.editObject(p, oNew[p]);
166
- return this.commit();
167
- }
168
-
169
- get length(): number
170
- {
171
- return this.root && this.root.edits ? this.root.edits.length : 0;
172
- }
173
-
174
- commit(): boolean
175
- {
176
- if (this.root)
177
- {
178
- try
179
- {
180
- if (this.root.edits.length)
181
- this.engine.addLocalEdit(this.root);
182
- this.root = null;
183
- this.stamps = null;
184
- return true;
185
- }
186
- catch (err)
187
- {
188
- // Really would like to log this, but effectively this is a programming error of mismatched bases.
189
- return false;
190
- }
191
- }
192
- }
193
- }
194
-
195
- function keyDiff(oOld: any, oNew: any): string[]
196
- {
197
- if (oNew == null)
198
- return [];
199
-
200
- let aDiff: string[] = [];
201
- for (var p in oNew) if (oNew.hasOwnProperty(p))
202
- {
203
- if (oOld == null || oOld[p] === undefined)
204
- aDiff.push(p)
205
- else if (! Util.deepEqual(oNew[p], oOld[p]))
206
- aDiff.push(p);
207
- }
208
- return aDiff;
209
- }
package/lib/ot-js/all.ts DELETED
@@ -1,9 +0,0 @@
1
- export * from "./otarray";
2
- export * from "./otengine";
3
- export * from "./otclientengine";
4
- export * from "./otcomposite";
5
- export * from "./otmap";
6
- export * from "./otcounter";
7
- export * from "./otserverengine";
8
- export * from "./ottypes";
9
- export * from "./otsession";