@dra2020/baseclient 1.0.75 → 1.0.78
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/README.md +1 -0
- package/dist/baseclient.js +36 -23
- package/dist/baseclient.js.map +1 -1
- package/dist/dataflow/dataflow.d.ts +19 -9
- package/docs/dataflow.md +167 -0
- package/lib/dataflow/dataflow.ts +52 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ These libraries are used across both client and server:
|
|
|
19
19
|
- [Poly](./docs/poly.md): A set of functions for processing polygons, typically in GeoJSON format.
|
|
20
20
|
- [Context](./docs/context.md): A set of functions for interrogating the context supplied to the application, either as
|
|
21
21
|
- [FSM](./docs/fsm.md): A set of functions for managing asynchronous, chainable finite state machines.
|
|
22
|
+
- [DataFlow](./docs/dataflow.md): A set of classes for managing synchronous, chainable dataflow.
|
|
22
23
|
- [LogAbstract](./docs/logabstract.md): An abstract logging interface. Different implementations are used on client and server.
|
|
23
24
|
- [LogClient](./docs/logclient.md): A client implementation of the logging abstract interface.
|
|
24
25
|
- [OT](./docs/ot-js.md): An Operational Transformation implementation, used as the basis for all content editing.
|
package/dist/baseclient.js
CHANGED
|
@@ -1016,45 +1016,49 @@ __exportStar(__webpack_require__(/*! ./dataflow */ "./lib/dataflow/dataflow.ts")
|
|
|
1016
1016
|
// DataFlow: mechanism for setting up a data-flow dependency graph that gets computed on demand.
|
|
1017
1017
|
//
|
|
1018
1018
|
// Semantics are these:
|
|
1019
|
-
// 1. The simplest "atomic" DataFlow object just has an id()
|
|
1020
|
-
// equivalence when determining if any dependents need to be recomputed.
|
|
1021
|
-
// for something that just creates a new whole object when recomputed. In other cases, id() might represent a
|
|
1022
|
-
// hash or changestamp/timestamp that is distinct from the value(). The value may or may not be "ready" as well.
|
|
1023
|
-
// If the value is not "ready", no dependents can be computed.
|
|
1019
|
+
// 1. The simplest "atomic" DataFlow object just has an id(). The id() is used to check for exact
|
|
1020
|
+
// equivalence when determining if any dependents need to be recomputed.
|
|
1024
1021
|
// 2. A DataFlow object can record that it "uses" another DataFlow object. If it does, it can use a set of helper
|
|
1025
|
-
// routines to track the state of its dependents. When its dependents are
|
|
1026
|
-
//
|
|
1022
|
+
// routines to track the state of its dependents. When its dependents are "stale" (have changed) the computation
|
|
1023
|
+
// needs to be run.
|
|
1027
1024
|
//
|
|
1028
1025
|
//
|
|
1029
1026
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1030
|
-
exports.DataFlowCallback = exports.DataFlow = void 0;
|
|
1027
|
+
exports.DataFlowStamp = exports.DataFlowCallback = exports.DataFlow = void 0;
|
|
1031
1028
|
class DataFlow {
|
|
1032
1029
|
constructor() {
|
|
1033
1030
|
this.usesList = [];
|
|
1034
1031
|
}
|
|
1035
1032
|
// override in subclass
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1033
|
+
dfid() { return null; }
|
|
1034
|
+
// override in subclass
|
|
1035
|
+
compute() {
|
|
1036
|
+
}
|
|
1037
|
+
uses(df, name) {
|
|
1038
|
+
this.usesList.push({ name: name, df: df });
|
|
1040
1039
|
}
|
|
1041
|
-
|
|
1040
|
+
stale() {
|
|
1042
1041
|
let isstale = false;
|
|
1043
|
-
this.usesList.forEach(ui => {
|
|
1044
|
-
|
|
1042
|
+
this.usesList.forEach(ui => {
|
|
1043
|
+
ui.wasfresh = ui.id !== ui.df.dfid();
|
|
1044
|
+
if (ui.wasfresh)
|
|
1045
|
+
isstale = true;
|
|
1046
|
+
});
|
|
1045
1047
|
return isstale;
|
|
1046
1048
|
}
|
|
1047
|
-
|
|
1048
|
-
this.usesList.
|
|
1049
|
+
wasFresh(name) {
|
|
1050
|
+
let ui = this.usesList.find((ui) => ui.name === name);
|
|
1051
|
+
return ui != null && ui.wasfresh;
|
|
1052
|
+
}
|
|
1053
|
+
remember() {
|
|
1054
|
+
this.usesList.forEach(ui => { ui.id = ui.df.dfid(); });
|
|
1049
1055
|
}
|
|
1050
1056
|
ifcompute() {
|
|
1051
|
-
if (this.
|
|
1052
|
-
this.
|
|
1057
|
+
if (this.stale()) {
|
|
1058
|
+
this.remember();
|
|
1053
1059
|
this.compute();
|
|
1054
1060
|
}
|
|
1055
1061
|
}
|
|
1056
|
-
compute() {
|
|
1057
|
-
}
|
|
1058
1062
|
}
|
|
1059
1063
|
exports.DataFlow = DataFlow;
|
|
1060
1064
|
// Takes callback that, eventually, returns non-null. The return value is both the value and the id.
|
|
@@ -1064,11 +1068,20 @@ class DataFlowCallback extends DataFlow {
|
|
|
1064
1068
|
super();
|
|
1065
1069
|
this._cb = cb;
|
|
1066
1070
|
}
|
|
1067
|
-
|
|
1071
|
+
dfid() { if (!this._value)
|
|
1068
1072
|
this._value = this._cb(); return this._value; }
|
|
1069
|
-
value() { return this.id(); }
|
|
1070
1073
|
}
|
|
1071
1074
|
exports.DataFlowCallback = DataFlowCallback;
|
|
1075
|
+
// Simple helper that maintains a simple monotonically increasing stamp
|
|
1076
|
+
class DataFlowStamp extends DataFlow {
|
|
1077
|
+
constructor() {
|
|
1078
|
+
super();
|
|
1079
|
+
this._stamp = 0;
|
|
1080
|
+
}
|
|
1081
|
+
dfid() { return this._stamp; }
|
|
1082
|
+
stamp() { this._stamp++; }
|
|
1083
|
+
}
|
|
1084
|
+
exports.DataFlowStamp = DataFlowStamp;
|
|
1072
1085
|
|
|
1073
1086
|
|
|
1074
1087
|
/***/ }),
|