tutuca 0.9.75 → 0.9.76
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/tutuca-cli.js +36 -3
- package/dist/tutuca-dev.ext.js +36 -3
- package/dist/tutuca-dev.js +36 -3
- package/dist/tutuca-dev.min.js +2 -2
- package/dist/tutuca-extra.ext.js +36 -3
- package/dist/tutuca-extra.js +36 -3
- package/dist/tutuca-extra.min.js +2 -2
- package/dist/tutuca.ext.js +36 -3
- package/dist/tutuca.js +36 -3
- package/dist/tutuca.min.js +2 -2
- package/package.json +1 -1
- package/skill/tutuca-source/tutuca.ext.js +36 -3
package/package.json
CHANGED
|
@@ -17,6 +17,9 @@ class Step {
|
|
|
17
17
|
toAbstractPathStep() {
|
|
18
18
|
return this;
|
|
19
19
|
}
|
|
20
|
+
pinKey(_v) {
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
class BindStep extends Step {
|
|
@@ -98,6 +101,10 @@ class SeqAccessStep extends Step {
|
|
|
98
101
|
const key = root?.get(this.keyField, NONE);
|
|
99
102
|
return seq === NONE || key === NONE ? root : root.set(this.seqField, seq.set(key, v));
|
|
100
103
|
}
|
|
104
|
+
pinKey(v) {
|
|
105
|
+
const key = v?.get(this.keyField, NONE);
|
|
106
|
+
return key === NONE ? this : new SeqStep(this.seqField, key);
|
|
107
|
+
}
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
class EachBindStep extends Step {
|
|
@@ -220,6 +227,20 @@ class Path {
|
|
|
220
227
|
}
|
|
221
228
|
return new Path(out);
|
|
222
229
|
}
|
|
230
|
+
pinKeys(root) {
|
|
231
|
+
let curVal = root;
|
|
232
|
+
let out = null;
|
|
233
|
+
for (let i = 0;i < this.steps.length; i++) {
|
|
234
|
+
const step = this.steps[i];
|
|
235
|
+
const pinned = step.pinKey(curVal);
|
|
236
|
+
if (pinned !== step)
|
|
237
|
+
(out ??= this.steps.slice())[i] = pinned;
|
|
238
|
+
curVal = step.lookup(curVal, NONE);
|
|
239
|
+
if (curVal === NONE)
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
return out ? new Path(out) : this;
|
|
243
|
+
}
|
|
223
244
|
lookup(v, dval = null) {
|
|
224
245
|
let curVal = v;
|
|
225
246
|
for (const step of this.steps) {
|
|
@@ -2664,12 +2685,14 @@ class Transactor {
|
|
|
2664
2685
|
}
|
|
2665
2686
|
async pushRequest(path, name, args = [], opts = {}, parent = null) {
|
|
2666
2687
|
const curRoot = this.state.val;
|
|
2667
|
-
const
|
|
2688
|
+
const txnPath = path.toTransactionPath();
|
|
2689
|
+
const curLeaf = txnPath.lookup(curRoot);
|
|
2668
2690
|
const handler = this.comps.getRequestFor(curLeaf, name) ?? mkReq404(name);
|
|
2669
2691
|
const resHandlerName = opts?.onResName ?? name;
|
|
2692
|
+
const resPath = opts?.livePath ? null : txnPath.pinKeys(curRoot);
|
|
2670
2693
|
const push = (specificName, baseName, singleArg, result, error) => {
|
|
2671
2694
|
const resArgs = specificName ? [singleArg] : [result, error];
|
|
2672
|
-
const t = new ResponseEvent(path, this, specificName ?? baseName, resArgs, parent);
|
|
2695
|
+
const t = new ResponseEvent(path, this, specificName ?? baseName, resArgs, parent, resPath);
|
|
2673
2696
|
this.pushTransaction(t);
|
|
2674
2697
|
};
|
|
2675
2698
|
try {
|
|
@@ -2744,8 +2767,11 @@ class Transaction {
|
|
|
2744
2767
|
getHandlerAndArgs(_root, _instance, _comps) {
|
|
2745
2768
|
return null;
|
|
2746
2769
|
}
|
|
2770
|
+
getTransactionPath() {
|
|
2771
|
+
return this.path.toTransactionPath();
|
|
2772
|
+
}
|
|
2747
2773
|
updateRootValue(curRoot, comps) {
|
|
2748
|
-
const txnPath = this.
|
|
2774
|
+
const txnPath = this.getTransactionPath();
|
|
2749
2775
|
const curLeaf = txnPath.lookup(curRoot);
|
|
2750
2776
|
const newLeaf = this.callHandler(curRoot, curLeaf, comps);
|
|
2751
2777
|
this._task?.complete?.({ value: newLeaf, old: curLeaf });
|
|
@@ -2854,6 +2880,13 @@ class NameArgsTransaction extends Transaction {
|
|
|
2854
2880
|
|
|
2855
2881
|
class ResponseEvent extends NameArgsTransaction {
|
|
2856
2882
|
handlerProp = "response";
|
|
2883
|
+
constructor(path, transactor, name, args, parent, txnPath = null) {
|
|
2884
|
+
super(path, transactor, name, args, parent);
|
|
2885
|
+
this._txnPath = txnPath;
|
|
2886
|
+
}
|
|
2887
|
+
getTransactionPath() {
|
|
2888
|
+
return this._txnPath ?? super.getTransactionPath();
|
|
2889
|
+
}
|
|
2857
2890
|
}
|
|
2858
2891
|
|
|
2859
2892
|
class SendEvent extends NameArgsTransaction {
|