@dra2020/baseclient 1.0.82 → 1.0.85
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/baseclient.js +51 -7
- package/dist/baseclient.js.map +1 -1
- package/dist/csv/csv.d.ts +10 -0
- package/dist/fsm/fsm.d.ts +2 -0
- package/dist/ot-js/otsession.d.ts +1 -0
- package/docs/fsm.md +10 -6
- package/lib/csv/csv.ts +58 -2
- package/lib/fsm/fsm.ts +10 -3
- package/lib/ot-js/otsession.ts +2 -1
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -889,7 +889,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
889
889
|
return result;
|
|
890
890
|
};
|
|
891
891
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
892
|
-
exports.ParseOne = void 0;
|
|
892
|
+
exports.ParseOne = exports.ParseMany = void 0;
|
|
893
893
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
894
894
|
// Parse CSV.
|
|
895
895
|
// Fields are separated by commas or pipe symbol (census uses pipe separators.
|
|
@@ -910,6 +910,41 @@ const Pipe = 124;
|
|
|
910
910
|
function isWhite(c) {
|
|
911
911
|
return c === Space || c === Newline || c === Tab || c == CR;
|
|
912
912
|
}
|
|
913
|
+
// Keep calling next() to retrieve next parsed line. Returns false when done. Empty lines are ignored.
|
|
914
|
+
class ParseMany {
|
|
915
|
+
constructor(coder, buf) {
|
|
916
|
+
this.buf = buf;
|
|
917
|
+
this.n = 0;
|
|
918
|
+
this.one = new ParseOne(coder);
|
|
919
|
+
}
|
|
920
|
+
get length() { return this.one.length; }
|
|
921
|
+
get fields() { return this.one.fields; }
|
|
922
|
+
next() {
|
|
923
|
+
// Move past any leading CRLF
|
|
924
|
+
while (this.n < this.buf.length) {
|
|
925
|
+
let c = this.buf[this.n];
|
|
926
|
+
if (c == CR || c == Newline)
|
|
927
|
+
this.n++;
|
|
928
|
+
else
|
|
929
|
+
break;
|
|
930
|
+
}
|
|
931
|
+
let s = this.n;
|
|
932
|
+
while (this.n < this.buf.length) {
|
|
933
|
+
let c = this.buf[this.n];
|
|
934
|
+
if (c == CR || c == Newline)
|
|
935
|
+
break;
|
|
936
|
+
else
|
|
937
|
+
this.n++;
|
|
938
|
+
}
|
|
939
|
+
if (s != this.n) {
|
|
940
|
+
this.one.setBuf(this.buf.subarray(s, this.n));
|
|
941
|
+
return true;
|
|
942
|
+
}
|
|
943
|
+
else
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
exports.ParseMany = ParseMany;
|
|
913
948
|
class ParseOne {
|
|
914
949
|
constructor(coder, line) {
|
|
915
950
|
this.coder = coder;
|
|
@@ -919,9 +954,13 @@ class ParseOne {
|
|
|
919
954
|
this.fields = [];
|
|
920
955
|
}
|
|
921
956
|
set(line) {
|
|
957
|
+
this.setBuf(Util.s2u8(this.coder, line));
|
|
958
|
+
}
|
|
959
|
+
setBuf(buf) {
|
|
960
|
+
this.buf = buf;
|
|
922
961
|
this.fields = [];
|
|
923
|
-
this.
|
|
924
|
-
|
|
962
|
+
if (!this.tok || this.tok.length < this.buf.length)
|
|
963
|
+
this.tok = new Uint8Array(new ArrayBuffer(this.buf.length));
|
|
925
964
|
this.n = 0;
|
|
926
965
|
this.toklen = 0;
|
|
927
966
|
this.infield = false;
|
|
@@ -1813,14 +1852,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
1813
1852
|
return result;
|
|
1814
1853
|
};
|
|
1815
1854
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1816
|
-
exports.FsmArray = exports.FsmLoop = exports.DefaultLoopOptions = exports.FsmTracker = exports.FsmSerializer = exports.FsmSleep = exports.FsmOnDone = exports.Fsm = exports.FsmManager = exports.FSM_CUSTOM9 = exports.FSM_CUSTOM8 = exports.FSM_CUSTOM7 = exports.FSM_CUSTOM6 = exports.FSM_CUSTOM5 = exports.FSM_CUSTOM4 = exports.FSM_CUSTOM3 = exports.FSM_CUSTOM2 = exports.FSM_CUSTOM1 = exports.FSM_RELEASED = exports.FSM_ERROR = exports.FSM_DONE = exports.FSM_PENDING = exports.FSM_STARTING = void 0;
|
|
1855
|
+
exports.FsmArray = exports.FsmLoop = exports.DefaultLoopOptions = exports.FsmTracker = exports.FsmSerializer = exports.FsmSleep = exports.FsmOnDone = exports.Fsm = exports.FsmManager = exports.FSM_CUSTOM9 = exports.FSM_CUSTOM8 = exports.FSM_CUSTOM7 = exports.FSM_CUSTOM6 = exports.FSM_CUSTOM5 = exports.FSM_CUSTOM4 = exports.FSM_CUSTOM3 = exports.FSM_CUSTOM2 = exports.FSM_CUSTOM1 = exports.FSM_RELEASED = exports.FSM_CANCEL = exports.FSM_ERROR = exports.FSM_DONE = exports.FSM_PENDING = exports.FSM_STARTING = void 0;
|
|
1817
1856
|
// Shared libraries
|
|
1818
1857
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
1819
|
-
// States
|
|
1858
|
+
// States (note these are no longer bit flags - most uses create custom values incrementally from CUSTOM1)
|
|
1820
1859
|
exports.FSM_STARTING = 0;
|
|
1821
1860
|
exports.FSM_PENDING = 1 << 0;
|
|
1822
1861
|
exports.FSM_DONE = 1 << 1;
|
|
1823
1862
|
exports.FSM_ERROR = 1 << 2;
|
|
1863
|
+
exports.FSM_CANCEL = 5;
|
|
1824
1864
|
exports.FSM_RELEASED = 1 << 3;
|
|
1825
1865
|
exports.FSM_CUSTOM1 = 1 << 4;
|
|
1826
1866
|
exports.FSM_CUSTOM2 = 1 << 5;
|
|
@@ -1834,7 +1874,7 @@ exports.FSM_CUSTOM9 = 1 << 12;
|
|
|
1834
1874
|
// polyfill
|
|
1835
1875
|
let doLater = global && global.setImmediate ? setImmediate : (cb) => { setTimeout(cb, 0); };
|
|
1836
1876
|
function FsmDone(s) {
|
|
1837
|
-
return (s === exports.FSM_DONE || s === exports.FSM_ERROR || s === exports.FSM_RELEASED);
|
|
1877
|
+
return (s === exports.FSM_DONE || s === exports.FSM_ERROR || s === exports.FSM_RELEASED || s === exports.FSM_CANCEL);
|
|
1838
1878
|
}
|
|
1839
1879
|
function FsmStateToString(state) {
|
|
1840
1880
|
let a = [];
|
|
@@ -1928,11 +1968,15 @@ class Fsm {
|
|
|
1928
1968
|
return !this.done && this._waitOn == null;
|
|
1929
1969
|
}
|
|
1930
1970
|
get iserror() {
|
|
1931
|
-
return (this.state === exports.FSM_ERROR);
|
|
1971
|
+
return (this.state === exports.FSM_ERROR || this.state === exports.FSM_CANCEL);
|
|
1932
1972
|
}
|
|
1933
1973
|
get isDependentError() {
|
|
1934
1974
|
return this.dependentError;
|
|
1935
1975
|
}
|
|
1976
|
+
cancel() {
|
|
1977
|
+
// Override if you need to do more than marking complete
|
|
1978
|
+
this.setState(exports.FSM_CANCEL);
|
|
1979
|
+
}
|
|
1936
1980
|
setDependentError() {
|
|
1937
1981
|
this.dependentError = true;
|
|
1938
1982
|
}
|