tutuca 0.9.57 → 0.9.59
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 +78 -50
- package/dist/tutuca-dev.js +85 -64
- package/dist/tutuca-dev.min.js +3 -3
- package/dist/tutuca-extra.js +85 -64
- package/dist/tutuca-extra.min.js +3 -3
- package/dist/tutuca.js +85 -64
- package/dist/tutuca.min.js +3 -3
- package/package.json +1 -1
package/dist/tutuca-cli.js
CHANGED
|
@@ -3864,6 +3864,9 @@ class Step {
|
|
|
3864
3864
|
enterFrame(stack, _prev, next) {
|
|
3865
3865
|
return stack.enter(next, {}, true);
|
|
3866
3866
|
}
|
|
3867
|
+
toAbstractPathStep() {
|
|
3868
|
+
return this;
|
|
3869
|
+
}
|
|
3867
3870
|
}
|
|
3868
3871
|
|
|
3869
3872
|
class Path {
|
|
@@ -3876,6 +3879,15 @@ class Path {
|
|
|
3876
3879
|
popStep() {
|
|
3877
3880
|
return new Path(this.steps.slice(0, -1));
|
|
3878
3881
|
}
|
|
3882
|
+
compact() {
|
|
3883
|
+
const out = [];
|
|
3884
|
+
for (const step of this.steps) {
|
|
3885
|
+
const s = step.toAbstractPathStep();
|
|
3886
|
+
if (s !== null)
|
|
3887
|
+
out.push(s);
|
|
3888
|
+
}
|
|
3889
|
+
return new Path(out);
|
|
3890
|
+
}
|
|
3879
3891
|
lookup(v, dval = null) {
|
|
3880
3892
|
let curVal = v;
|
|
3881
3893
|
for (const step of this.steps) {
|
|
@@ -3916,6 +3928,7 @@ class Path {
|
|
|
3916
3928
|
}
|
|
3917
3929
|
static fromNodeAndEventName(node, eventName, rootNode, maxDepth, comps, stopOnNoEvent = true) {
|
|
3918
3930
|
const pathSteps = [];
|
|
3931
|
+
const bubbles = BUBBLING_EVENTS.has(eventName);
|
|
3919
3932
|
let depth = 0;
|
|
3920
3933
|
let eventIds = [];
|
|
3921
3934
|
let handlers = null;
|
|
@@ -3928,16 +3941,24 @@ class Path {
|
|
|
3928
3941
|
if (eid !== undefined)
|
|
3929
3942
|
eventIds.push(eid);
|
|
3930
3943
|
if (cid !== undefined) {
|
|
3931
|
-
const comp = comps.getComponentForId(+cid
|
|
3932
|
-
|
|
3944
|
+
const comp = comps.getComponentForId(+cid);
|
|
3945
|
+
let pushStep = true;
|
|
3946
|
+
if (handlers === null && (isLeafComponent || bubbles)) {
|
|
3933
3947
|
handlers = findHandlers(comp, eventIds, vid, eventName);
|
|
3934
|
-
if (handlers === null
|
|
3935
|
-
|
|
3936
|
-
|
|
3948
|
+
if (handlers === null) {
|
|
3949
|
+
if (isLeafComponent && stopOnNoEvent && !bubbles)
|
|
3950
|
+
return NO_EVENT_INFO;
|
|
3951
|
+
} else if (!isLeafComponent) {
|
|
3952
|
+
pathSteps.length = 0;
|
|
3953
|
+
pushStep = false;
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
isLeafComponent = false;
|
|
3957
|
+
if (pushStep) {
|
|
3958
|
+
const step = resolvePathStep(comp, nodeIds, vid);
|
|
3959
|
+
if (step)
|
|
3960
|
+
pathSteps.push(step);
|
|
3937
3961
|
}
|
|
3938
|
-
const step = resolvePathStep(comp, nodeIds, vid);
|
|
3939
|
-
if (step)
|
|
3940
|
-
pathSteps.push(step);
|
|
3941
3962
|
eventIds = [];
|
|
3942
3963
|
nodeIds = [];
|
|
3943
3964
|
}
|
|
@@ -4033,13 +4054,13 @@ class PathBuilder {
|
|
|
4033
4054
|
return this.add(new FieldStep(name));
|
|
4034
4055
|
}
|
|
4035
4056
|
index(name, index) {
|
|
4036
|
-
return this.add(new
|
|
4057
|
+
return this.add(new SeqStep(name, index));
|
|
4037
4058
|
}
|
|
4038
4059
|
key(name, key) {
|
|
4039
|
-
return this.add(new
|
|
4060
|
+
return this.add(new SeqStep(name, key));
|
|
4040
4061
|
}
|
|
4041
4062
|
}
|
|
4042
|
-
var NONE, BindStep, FieldStep,
|
|
4063
|
+
var NONE, BindStep, FieldStep, SeqStep, SeqAccessStep, EachBindStep, EachRenderItStep, EMPTY_META, NO_EVENT_INFO, BUBBLING_EVENTS;
|
|
4043
4064
|
var init_path = __esm(() => {
|
|
4044
4065
|
NONE = Symbol("NONE");
|
|
4045
4066
|
BindStep = class BindStep extends Step {
|
|
@@ -4062,6 +4083,9 @@ var init_path = __esm(() => {
|
|
|
4062
4083
|
withKey(key) {
|
|
4063
4084
|
return new BindStep({ ...this.binds, key });
|
|
4064
4085
|
}
|
|
4086
|
+
toAbstractPathStep() {
|
|
4087
|
+
return null;
|
|
4088
|
+
}
|
|
4065
4089
|
};
|
|
4066
4090
|
FieldStep = class FieldStep extends Step {
|
|
4067
4091
|
constructor(field) {
|
|
@@ -4075,13 +4099,13 @@ var init_path = __esm(() => {
|
|
|
4075
4099
|
return root.set(this.field, v);
|
|
4076
4100
|
}
|
|
4077
4101
|
withIndex(i) {
|
|
4078
|
-
return new
|
|
4102
|
+
return new SeqStep(this.field, i);
|
|
4079
4103
|
}
|
|
4080
4104
|
withKey(k) {
|
|
4081
|
-
return new
|
|
4105
|
+
return new SeqStep(this.field, k);
|
|
4082
4106
|
}
|
|
4083
4107
|
};
|
|
4084
|
-
|
|
4108
|
+
SeqStep = class SeqStep extends Step {
|
|
4085
4109
|
constructor(field, key) {
|
|
4086
4110
|
super();
|
|
4087
4111
|
this.field = field;
|
|
@@ -4092,16 +4116,13 @@ var init_path = __esm(() => {
|
|
|
4092
4116
|
return o?.get ? o.get(this.key, dval) : dval;
|
|
4093
4117
|
}
|
|
4094
4118
|
setValue(root, v) {
|
|
4095
|
-
|
|
4119
|
+
const seq = root?.get(this.field, null);
|
|
4120
|
+
return seq ? root.set(this.field, seq.set(this.key, v)) : root;
|
|
4096
4121
|
}
|
|
4097
4122
|
enterFrame(stack, _prev, next) {
|
|
4098
4123
|
return stack.enter(next, { key: this.key }, true);
|
|
4099
4124
|
}
|
|
4100
4125
|
};
|
|
4101
|
-
SeqKeyStep = class SeqKeyStep extends FieldSeqStep {
|
|
4102
|
-
};
|
|
4103
|
-
SeqIndexStep = class SeqIndexStep extends FieldSeqStep {
|
|
4104
|
-
};
|
|
4105
4126
|
SeqAccessStep = class SeqAccessStep extends Step {
|
|
4106
4127
|
constructor(seqField, keyField) {
|
|
4107
4128
|
super();
|
|
@@ -4135,27 +4156,21 @@ var init_path = __esm(() => {
|
|
|
4135
4156
|
const item = this.seqVal.eval(stack)?.get(this.key, null);
|
|
4136
4157
|
return stack.enter(next, { key: this.key, value: item }, false);
|
|
4137
4158
|
}
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
constructor(seqField, key) {
|
|
4141
|
-
super();
|
|
4142
|
-
this.seqField = seqField;
|
|
4143
|
-
this.key = key;
|
|
4144
|
-
}
|
|
4145
|
-
lookup(v, dval = null) {
|
|
4146
|
-
const seq = v?.get(this.seqField, null);
|
|
4147
|
-
return seq?.get ? seq.get(this.key, dval) : dval;
|
|
4148
|
-
}
|
|
4149
|
-
setValue(root, v) {
|
|
4150
|
-
const seq = root?.get(this.seqField, null);
|
|
4151
|
-
return seq ? root.set(this.seqField, seq.set(this.key, v)) : root;
|
|
4159
|
+
toAbstractPathStep() {
|
|
4160
|
+
return null;
|
|
4152
4161
|
}
|
|
4162
|
+
};
|
|
4163
|
+
EachRenderItStep = class EachRenderItStep extends SeqStep {
|
|
4153
4164
|
enterFrame(stack, _prev, next) {
|
|
4154
4165
|
return stack.enter(next, { key: this.key, value: next }, false).enter(next, {}, true);
|
|
4155
4166
|
}
|
|
4167
|
+
toAbstractPathStep() {
|
|
4168
|
+
return new SeqStep(this.field, this.key);
|
|
4169
|
+
}
|
|
4156
4170
|
};
|
|
4157
4171
|
EMPTY_META = {};
|
|
4158
4172
|
NO_EVENT_INFO = [null, null];
|
|
4173
|
+
BUBBLING_EVENTS = new Set(["drop"]);
|
|
4159
4174
|
});
|
|
4160
4175
|
|
|
4161
4176
|
// src/value.js
|
|
@@ -4473,7 +4488,7 @@ var init_value = __esm(() => {
|
|
|
4473
4488
|
}
|
|
4474
4489
|
eval(stack) {
|
|
4475
4490
|
const key = this.keyVal.eval(stack);
|
|
4476
|
-
return this.seqVal.eval(stack)
|
|
4491
|
+
return this.seqVal.eval(stack)?.get(key, null);
|
|
4477
4492
|
}
|
|
4478
4493
|
toString() {
|
|
4479
4494
|
return `${this.seqVal}[${this.keyVal}]`;
|
|
@@ -8519,9 +8534,9 @@ class Transactor {
|
|
|
8519
8534
|
pushSend(path, name, args = [], opts = {}, parent = null) {
|
|
8520
8535
|
this.pushTransaction(new SendEvent(path, this, name, args, parent, opts));
|
|
8521
8536
|
}
|
|
8522
|
-
pushBubble(path, name, args = [], opts = {}, parent = null) {
|
|
8537
|
+
pushBubble(path, name, args = [], opts = {}, parent = null, targetPath = null) {
|
|
8523
8538
|
const newOpts = opts.skipSelf ? { ...opts, skipSelf: false } : opts;
|
|
8524
|
-
this.pushTransaction(new BubbleEvent(path, this, name, args, parent, newOpts));
|
|
8539
|
+
this.pushTransaction(new BubbleEvent(path, this, name, args, parent, newOpts, targetPath));
|
|
8525
8540
|
}
|
|
8526
8541
|
async pushRequest(path, name, args = [], opts = {}, parent = null) {
|
|
8527
8542
|
const curRoot = this.state.val;
|
|
@@ -8620,8 +8635,7 @@ function getValue(e) {
|
|
|
8620
8635
|
}
|
|
8621
8636
|
|
|
8622
8637
|
class Task {
|
|
8623
|
-
constructor(
|
|
8624
|
-
this.info = info;
|
|
8638
|
+
constructor() {
|
|
8625
8639
|
this.deps = [];
|
|
8626
8640
|
this.val = this.resolve = this.reject = null;
|
|
8627
8641
|
this.promise = new Promise((res, rej) => {
|
|
@@ -8693,14 +8707,15 @@ var init_transactor = __esm(() => {
|
|
|
8693
8707
|
getHandlerAndArgs(root, _instance, comps) {
|
|
8694
8708
|
const stack = this.buildStack(root, comps);
|
|
8695
8709
|
const [handler, args] = this.handler.getHandlerAndArgs(stack, this);
|
|
8710
|
+
const path = this.path.compact();
|
|
8696
8711
|
let dispatcher;
|
|
8697
8712
|
for (let i = 0;i < args.length; i++) {
|
|
8698
8713
|
if (args[i]?.toHandlerArg) {
|
|
8699
|
-
dispatcher ??= new Dispatcher(
|
|
8714
|
+
dispatcher ??= new Dispatcher(path, this.transactor, this);
|
|
8700
8715
|
args[i] = args[i].toHandlerArg(dispatcher);
|
|
8701
8716
|
}
|
|
8702
8717
|
}
|
|
8703
|
-
args.push(new EventContext(
|
|
8718
|
+
args.push(new EventContext(path, this.transactor, this));
|
|
8704
8719
|
return [handler, args];
|
|
8705
8720
|
}
|
|
8706
8721
|
lookupName(name) {
|
|
@@ -8751,6 +8766,7 @@ var init_transactor = __esm(() => {
|
|
|
8751
8766
|
this.name = name;
|
|
8752
8767
|
this.args = args;
|
|
8753
8768
|
this.opts = opts;
|
|
8769
|
+
this.targetPath = path;
|
|
8754
8770
|
}
|
|
8755
8771
|
handlerProp = null;
|
|
8756
8772
|
getHandlerForName(comp) {
|
|
@@ -8771,13 +8787,17 @@ var init_transactor = __esm(() => {
|
|
|
8771
8787
|
return this.opts.skipSelf ? rootVal : this.updateRootValue(rootVal, comps);
|
|
8772
8788
|
}
|
|
8773
8789
|
afterTransaction() {
|
|
8774
|
-
const { path, name, args, opts } = this;
|
|
8790
|
+
const { path, name, args, opts, targetPath } = this;
|
|
8775
8791
|
if (opts.bubbles && path.steps.length > 0)
|
|
8776
|
-
this.transactor.pushBubble(path.popStep(), name, args, opts, this);
|
|
8792
|
+
this.transactor.pushBubble(path.popStep(), name, args, opts, this, targetPath);
|
|
8777
8793
|
}
|
|
8778
8794
|
};
|
|
8779
8795
|
BubbleEvent = class BubbleEvent extends SendEvent {
|
|
8780
8796
|
handlerProp = "bubble";
|
|
8797
|
+
constructor(path, transactor, name, args, parent, opts, targetPath) {
|
|
8798
|
+
super(path, transactor, name, args, parent, opts);
|
|
8799
|
+
this.targetPath = targetPath ?? path;
|
|
8800
|
+
}
|
|
8781
8801
|
stopPropagation() {
|
|
8782
8802
|
this.opts.bubbles = false;
|
|
8783
8803
|
}
|
|
@@ -8786,6 +8806,9 @@ var init_transactor = __esm(() => {
|
|
|
8786
8806
|
get name() {
|
|
8787
8807
|
return this.parent?.name ?? null;
|
|
8788
8808
|
}
|
|
8809
|
+
get targetPath() {
|
|
8810
|
+
return this.parent.targetPath;
|
|
8811
|
+
}
|
|
8789
8812
|
stopPropagation() {
|
|
8790
8813
|
return this.parent.stopPropagation();
|
|
8791
8814
|
}
|
|
@@ -9163,7 +9186,7 @@ class App {
|
|
|
9163
9186
|
}
|
|
9164
9187
|
_dispatchEvent(e) {
|
|
9165
9188
|
const { type: type3 } = e;
|
|
9166
|
-
const isDrag = type3 === "dragover" || type3 === "dragstart" || type3 === "dragend";
|
|
9189
|
+
const isDrag = type3 === "dragover" || type3 === "dragstart" || type3 === "dragend" || type3 === "drop";
|
|
9167
9190
|
const { rootNode: root, maxEventNodeDepth: maxDepth, comps, transactor } = this;
|
|
9168
9191
|
const [path, handlers] = Path.fromEvent(e, root, maxDepth, comps, !isDrag);
|
|
9169
9192
|
if (isDrag)
|
|
@@ -9199,7 +9222,7 @@ class App {
|
|
|
9199
9222
|
if (!_touch.active) {
|
|
9200
9223
|
const dx = clientX - _touch.startX;
|
|
9201
9224
|
const dy = clientY - _touch.startY;
|
|
9202
|
-
if (dx * dx + dy * dy <
|
|
9225
|
+
if (dx * dx + dy * dy < 100)
|
|
9203
9226
|
return;
|
|
9204
9227
|
_touch.active = true;
|
|
9205
9228
|
e.preventDefault();
|
|
@@ -9235,6 +9258,9 @@ class App {
|
|
|
9235
9258
|
const dragType = e.target.dataset.dragtype ?? "?";
|
|
9236
9259
|
const stack = path.buildStack(this.makeStack(rootValue));
|
|
9237
9260
|
this.dragInfo = new DragInfo(path, stack, e, value, dragType, e.target);
|
|
9261
|
+
} else if (type3 === "drop") {
|
|
9262
|
+
e.preventDefault();
|
|
9263
|
+
this._cleanDragOverAttrs();
|
|
9238
9264
|
} else {
|
|
9239
9265
|
if (this.dragInfo !== null) {
|
|
9240
9266
|
delete this.dragInfo.node.dataset.dragging;
|
|
@@ -9272,11 +9298,14 @@ class App {
|
|
|
9272
9298
|
}
|
|
9273
9299
|
this._compiled = true;
|
|
9274
9300
|
}
|
|
9301
|
+
subscribeToEvents(eventNames) {
|
|
9302
|
+
for (const name of eventNames)
|
|
9303
|
+
this.rootNode.addEventListener(name, this, listenerOpts(name));
|
|
9304
|
+
}
|
|
9275
9305
|
start(opts) {
|
|
9276
9306
|
if (!this._compiled)
|
|
9277
9307
|
this.compile();
|
|
9278
|
-
|
|
9279
|
-
this.rootNode.addEventListener(name, this, listenerOpts(name));
|
|
9308
|
+
this.subscribeToEvents(this._eventNames);
|
|
9280
9309
|
this.onChange((info) => {
|
|
9281
9310
|
if (info.val !== info.old)
|
|
9282
9311
|
this.render();
|
|
@@ -9376,7 +9405,7 @@ class DragInfo {
|
|
|
9376
9405
|
return this.stack.lookupBind(name);
|
|
9377
9406
|
}
|
|
9378
9407
|
}
|
|
9379
|
-
var _evs,
|
|
9408
|
+
var _evs, NOOP = () => {}, listenerOpts = (name) => name === "touchmove" ? { passive: false } : undefined;
|
|
9380
9409
|
var init_app = __esm(() => {
|
|
9381
9410
|
init_components();
|
|
9382
9411
|
init_path();
|
|
@@ -9384,7 +9413,6 @@ var init_app = __esm(() => {
|
|
|
9384
9413
|
init_transactor();
|
|
9385
9414
|
init_vdom();
|
|
9386
9415
|
_evs = "dragstart dragover dragend touchstart touchmove touchend touchcancel".split(" ");
|
|
9387
|
-
TOUCH_DRAG_THRESHOLD_SQ = TOUCH_DRAG_THRESHOLD_PX * TOUCH_DRAG_THRESHOLD_PX;
|
|
9388
9416
|
});
|
|
9389
9417
|
|
|
9390
9418
|
// deps/immutable.js
|
|
@@ -13709,7 +13737,7 @@ class Renderer {
|
|
|
13709
13737
|
}
|
|
13710
13738
|
renderRoot(stack, val, viewName = null) {
|
|
13711
13739
|
const comp = this.comps.getCompFor(val);
|
|
13712
|
-
const nid = comp
|
|
13740
|
+
const nid = comp?.getView(viewName).anode.nodeId ?? null;
|
|
13713
13741
|
return comp ? this._rValComp(stack, val, comp, nid, "ROOT", viewName) : null;
|
|
13714
13742
|
}
|
|
13715
13743
|
renderIt(stack, nodeId, key, viewName) {
|
|
@@ -13717,7 +13745,7 @@ class Renderer {
|
|
|
13717
13745
|
return comp ? this._rValComp(stack, stack.it, comp, nodeId, key, viewName) : null;
|
|
13718
13746
|
}
|
|
13719
13747
|
_rValComp(stack, val, comp, nid, key, viewName) {
|
|
13720
|
-
const cacheKey = `${viewName ?? stack.viewsId ?? ""}
|
|
13748
|
+
const cacheKey = `${viewName ?? stack.viewsId ?? ""}-${nid}-${key}`;
|
|
13721
13749
|
const cachePath = [val];
|
|
13722
13750
|
stack._pushDynBindValuesToArray(cachePath, comp.dynamic);
|
|
13723
13751
|
const cachedNode = this.cache.get(cachePath, cacheKey);
|