tutuca 0.9.7 → 0.9.9
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 +70 -1
- package/dist/tutuca-dev.js +114 -71
- package/dist/tutuca-dev.min.js +3 -3
- package/dist/tutuca-extra.js +114 -71
- package/dist/tutuca-extra.min.js +3 -3
- package/dist/tutuca.js +114 -71
- package/dist/tutuca.min.js +3 -3
- package/package.json +22 -1
package/dist/tutuca.js
CHANGED
|
@@ -1089,6 +1089,10 @@ class ANode extends BaseNode {
|
|
|
1089
1089
|
return px.addNodeIf(RenderItNode, vp.bindValIt, as);
|
|
1090
1090
|
case "render-each":
|
|
1091
1091
|
return RenderEachNode.parse(px, vp, value, as, attrs);
|
|
1092
|
+
case "show":
|
|
1093
|
+
return px.addNodeIf(ShowNode, vp.parseCondValue(value, px), maybeFragment(childs));
|
|
1094
|
+
case "hide":
|
|
1095
|
+
return px.addNodeIf(HideNode, vp.parseCondValue(value, px), maybeFragment(childs));
|
|
1092
1096
|
}
|
|
1093
1097
|
return new CommentNode(`Error: InvalidSpecialTagOp ${name}=${value}`);
|
|
1094
1098
|
} else if (tag.charCodeAt(1) === 58 && tag.charCodeAt(0) === 88) {
|
|
@@ -6366,6 +6370,7 @@ var Record = (defaultValues, name) => {
|
|
|
6366
6370
|
hasInitialized = true;
|
|
6367
6371
|
const keys = Object.keys(defaultValues);
|
|
6368
6372
|
const indices = RecordTypePrototype._indices = {};
|
|
6373
|
+
RecordTypePrototype._name = name;
|
|
6369
6374
|
RecordTypePrototype._keys = keys;
|
|
6370
6375
|
RecordTypePrototype._defaultValues = defaultValues;
|
|
6371
6376
|
for (let i = 0;i < keys.length; i++) {
|
|
@@ -6759,6 +6764,62 @@ class RepeatImpl extends IndexedSeqImpl {
|
|
|
6759
6764
|
this.prototype[Symbol.iterator] = this.prototype.values;
|
|
6760
6765
|
}
|
|
6761
6766
|
}
|
|
6767
|
+
var asValues = (collection) => isKeyed(collection) ? collection.valueSeq() : collection;
|
|
6768
|
+
function initCollectionConversions() {
|
|
6769
|
+
CollectionImpl.prototype.toMap = function toMap() {
|
|
6770
|
+
return Map2(this.toKeyedSeq());
|
|
6771
|
+
};
|
|
6772
|
+
CollectionImpl.prototype.toOrderedMap = function toOrderedMap() {
|
|
6773
|
+
return OrderedMap(this.toKeyedSeq());
|
|
6774
|
+
};
|
|
6775
|
+
CollectionImpl.prototype.toOrderedSet = function toOrderedSet() {
|
|
6776
|
+
return OrderedSet(asValues(this));
|
|
6777
|
+
};
|
|
6778
|
+
CollectionImpl.prototype.toSet = function toSet() {
|
|
6779
|
+
return Set2(asValues(this));
|
|
6780
|
+
};
|
|
6781
|
+
CollectionImpl.prototype.toStack = function toStack() {
|
|
6782
|
+
return Stack2(asValues(this));
|
|
6783
|
+
};
|
|
6784
|
+
CollectionImpl.prototype.toList = function toList() {
|
|
6785
|
+
return List(asValues(this));
|
|
6786
|
+
};
|
|
6787
|
+
CollectionImpl.prototype.countBy = function countBy(grouper, context) {
|
|
6788
|
+
const groups = Map2().asMutable();
|
|
6789
|
+
this.__iterate((v, k) => {
|
|
6790
|
+
groups.update(grouper.call(context, v, k, this), 0, (a) => a + 1);
|
|
6791
|
+
});
|
|
6792
|
+
return groups.asImmutable();
|
|
6793
|
+
};
|
|
6794
|
+
CollectionImpl.prototype.groupBy = function groupBy(grouper, context) {
|
|
6795
|
+
const isKeyedIter = isKeyed(this);
|
|
6796
|
+
const groups = (isOrdered(this) ? OrderedMap() : Map2()).asMutable();
|
|
6797
|
+
this.__iterate((v, k) => {
|
|
6798
|
+
groups.update(grouper.call(context, v, k, this), (a) => {
|
|
6799
|
+
a ??= [];
|
|
6800
|
+
a.push(isKeyedIter ? [k, v] : v);
|
|
6801
|
+
return a;
|
|
6802
|
+
});
|
|
6803
|
+
});
|
|
6804
|
+
return groups.map((arr) => reifyValues(this, arr)).asImmutable();
|
|
6805
|
+
};
|
|
6806
|
+
IndexedCollectionImpl.prototype.keySeq = function keySeq() {
|
|
6807
|
+
return Range(0, this.size);
|
|
6808
|
+
};
|
|
6809
|
+
MapImpl.prototype.sort = function sort(comparator) {
|
|
6810
|
+
return OrderedMap(sortFactory(this, comparator));
|
|
6811
|
+
};
|
|
6812
|
+
MapImpl.prototype.sortBy = function sortBy(mapper, comparator) {
|
|
6813
|
+
return OrderedMap(sortFactory(this, comparator, mapper));
|
|
6814
|
+
};
|
|
6815
|
+
SetImpl.prototype.sort = function sort(comparator) {
|
|
6816
|
+
return OrderedSet(sortFactory(this, comparator));
|
|
6817
|
+
};
|
|
6818
|
+
SetImpl.prototype.sortBy = function sortBy(mapper, comparator) {
|
|
6819
|
+
return OrderedSet(sortFactory(this, comparator, mapper));
|
|
6820
|
+
};
|
|
6821
|
+
}
|
|
6822
|
+
initCollectionConversions();
|
|
6762
6823
|
|
|
6763
6824
|
// src/renderer.js
|
|
6764
6825
|
var DATASET_ATTRS = ["nid", "cid", "eid", "vid", "si", "sk"];
|
|
@@ -6902,9 +6963,8 @@ function basicGetSeqInfo(seq) {
|
|
|
6902
6963
|
}
|
|
6903
6964
|
|
|
6904
6965
|
// src/vdom.js
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
}
|
|
6966
|
+
var isHtmlAttribute = (propName) => propName[4] === "-" && (propName[0] === "d" || propName[0] === "a");
|
|
6967
|
+
var isObject = (v) => v !== null && typeof v === "object";
|
|
6908
6968
|
function applyProperties(node, props, previous) {
|
|
6909
6969
|
for (const propName in props) {
|
|
6910
6970
|
const propValue = props[propName];
|
|
@@ -6914,7 +6974,7 @@ function applyProperties(node, props, previous) {
|
|
|
6914
6974
|
node.setAttribute(propName, propValue);
|
|
6915
6975
|
} else if (propName === "dangerouslySetInnerHTML") {
|
|
6916
6976
|
node.innerHTML = propValue.__html ?? "";
|
|
6917
|
-
} else if (
|
|
6977
|
+
} else if (isObject(propValue)) {
|
|
6918
6978
|
patchObject(node, previous, propName, propValue);
|
|
6919
6979
|
} else if (propName === "className") {
|
|
6920
6980
|
node.setAttribute("class", propValue);
|
|
@@ -6927,11 +6987,7 @@ function removeProperty(node, propName, previous) {
|
|
|
6927
6987
|
const previousValue = previous[propName];
|
|
6928
6988
|
if (propName === "dangerouslySetInnerHTML") {
|
|
6929
6989
|
node.innerHTML = "";
|
|
6930
|
-
} else if (isHtmlAttribute(propName)) {
|
|
6931
|
-
node.removeAttribute(propName);
|
|
6932
|
-
} else if (typeof previousValue === "string") {
|
|
6933
|
-
if (propName !== "className")
|
|
6934
|
-
node[propName] = "";
|
|
6990
|
+
} else if (typeof previousValue === "string" || isHtmlAttribute(propName)) {
|
|
6935
6991
|
const attrName = propName === "className" ? "class" : propName === "htmlFor" ? "for" : propName;
|
|
6936
6992
|
node.removeAttribute(attrName);
|
|
6937
6993
|
} else {
|
|
@@ -6940,12 +6996,12 @@ function removeProperty(node, propName, previous) {
|
|
|
6940
6996
|
}
|
|
6941
6997
|
function patchObject(node, previous, propName, propValue) {
|
|
6942
6998
|
const previousValue = previous?.[propName];
|
|
6943
|
-
if (previousValue &&
|
|
6999
|
+
if (isObject(previousValue) && Object.getPrototypeOf(previousValue) !== Object.getPrototypeOf(propValue)) {
|
|
6944
7000
|
node[propName] = propValue;
|
|
6945
7001
|
return;
|
|
6946
7002
|
}
|
|
6947
7003
|
let current = node[propName];
|
|
6948
|
-
if (
|
|
7004
|
+
if (!isObject(current)) {
|
|
6949
7005
|
node[propName] = {};
|
|
6950
7006
|
current = node[propName];
|
|
6951
7007
|
}
|
|
@@ -6963,16 +7019,11 @@ class VBase {
|
|
|
6963
7019
|
return null;
|
|
6964
7020
|
}
|
|
6965
7021
|
}
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
}
|
|
6969
|
-
function isIterable(obj) {
|
|
6970
|
-
return obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function";
|
|
6971
|
-
}
|
|
7022
|
+
var getKey = (child) => child instanceof VNode2 ? child.key : undefined;
|
|
7023
|
+
var isIterable = (obj) => obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function";
|
|
6972
7024
|
function addChild(normalizedChildren, child) {
|
|
6973
|
-
if (child == null)
|
|
7025
|
+
if (child == null)
|
|
6974
7026
|
return;
|
|
6975
|
-
}
|
|
6976
7027
|
if (isIterable(child)) {
|
|
6977
7028
|
for (const c of child) {
|
|
6978
7029
|
addChild(normalizedChildren, c);
|
|
@@ -7023,9 +7074,8 @@ class VComment extends VBase {
|
|
|
7023
7074
|
class VFragment extends VBase {
|
|
7024
7075
|
constructor(childs) {
|
|
7025
7076
|
super();
|
|
7026
|
-
|
|
7027
|
-
addChild(
|
|
7028
|
-
this.childs = normalized;
|
|
7077
|
+
this.childs = [];
|
|
7078
|
+
addChild(this.childs, childs);
|
|
7029
7079
|
}
|
|
7030
7080
|
get nodeType() {
|
|
7031
7081
|
return 11;
|
|
@@ -7109,7 +7159,7 @@ function diffProps(a, b) {
|
|
|
7109
7159
|
}
|
|
7110
7160
|
const aValue = a[aKey];
|
|
7111
7161
|
const bValue = b[aKey];
|
|
7112
|
-
if (aValue === bValue) {} else if (
|
|
7162
|
+
if (aValue === bValue) {} else if (isObject(aValue) && isObject(bValue)) {
|
|
7113
7163
|
if (Object.getPrototypeOf(bValue) !== Object.getPrototypeOf(aValue)) {
|
|
7114
7164
|
diff ??= {};
|
|
7115
7165
|
diff[aKey] = bValue;
|
|
@@ -7141,14 +7191,15 @@ function replaceNode(domNode, vnode, options) {
|
|
|
7141
7191
|
}
|
|
7142
7192
|
return newNode || domNode;
|
|
7143
7193
|
}
|
|
7194
|
+
var bothInstanceOf = (a, b, C) => a instanceof C && b instanceof C;
|
|
7144
7195
|
function morphNode(domNode, source, target, opts) {
|
|
7145
7196
|
if (source === target || source.isEqualTo(target))
|
|
7146
7197
|
return domNode;
|
|
7147
|
-
if (source
|
|
7198
|
+
if (bothInstanceOf(source, target, VText) || bothInstanceOf(source, target, VComment)) {
|
|
7148
7199
|
domNode.data = target.text;
|
|
7149
7200
|
return domNode;
|
|
7150
7201
|
}
|
|
7151
|
-
if (source
|
|
7202
|
+
if (bothInstanceOf(source, target, VNode2) && source.tag === target.tag && source.namespace === target.namespace && source.key === target.key) {
|
|
7152
7203
|
const propsDiff = diffProps(source.attrs, target.attrs);
|
|
7153
7204
|
if (propsDiff) {
|
|
7154
7205
|
applyProperties(domNode, propsDiff, source.attrs);
|
|
@@ -7158,7 +7209,7 @@ function morphNode(domNode, source, target, opts) {
|
|
|
7158
7209
|
}
|
|
7159
7210
|
return domNode;
|
|
7160
7211
|
}
|
|
7161
|
-
if (source
|
|
7212
|
+
if (bothInstanceOf(source, target, VFragment)) {
|
|
7162
7213
|
morphChildren(domNode, source.childs, target.childs, null, opts);
|
|
7163
7214
|
return domNode;
|
|
7164
7215
|
}
|
|
@@ -7235,10 +7286,8 @@ function render(vnode, container, options) {
|
|
|
7235
7286
|
if (wasFragment === isFragment) {
|
|
7236
7287
|
const rootNode = wasFragment ? container : cached.dom;
|
|
7237
7288
|
const newDom = morphNode(rootNode, cached.vnode, vnode, options);
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
dom: isFragment ? container : newDom
|
|
7241
|
-
});
|
|
7289
|
+
const domToCache = isFragment ? container : newDom;
|
|
7290
|
+
renderCache.set(container, { vnode, dom: domToCache });
|
|
7242
7291
|
return newDom;
|
|
7243
7292
|
}
|
|
7244
7293
|
renderCache.delete(container);
|
|
@@ -7247,32 +7296,33 @@ function render(vnode, container, options) {
|
|
|
7247
7296
|
if (domNode) {
|
|
7248
7297
|
container.innerHTML = "";
|
|
7249
7298
|
container.appendChild(domNode);
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
dom: isFragment ? container : domNode
|
|
7253
|
-
});
|
|
7299
|
+
const domToCache = isFragment ? container : domNode;
|
|
7300
|
+
renderCache.set(container, { vnode, dom: domToCache });
|
|
7254
7301
|
}
|
|
7255
7302
|
return domNode;
|
|
7256
7303
|
}
|
|
7257
7304
|
function h(tagName, properties, children) {
|
|
7258
7305
|
const tag = tagName.toUpperCase();
|
|
7259
7306
|
const props = {};
|
|
7260
|
-
let key;
|
|
7261
|
-
let namespace;
|
|
7307
|
+
let key, namespace;
|
|
7262
7308
|
if (properties) {
|
|
7263
7309
|
for (const propName in properties) {
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7310
|
+
const propVal = properties[propName];
|
|
7311
|
+
switch (propName) {
|
|
7312
|
+
case "key":
|
|
7313
|
+
key = propVal;
|
|
7314
|
+
break;
|
|
7315
|
+
case "namespace":
|
|
7316
|
+
namespace = propVal;
|
|
7317
|
+
break;
|
|
7318
|
+
case "class":
|
|
7319
|
+
props.className = propVal;
|
|
7320
|
+
break;
|
|
7321
|
+
case "for":
|
|
7322
|
+
props.htmlFor = propVal;
|
|
7323
|
+
break;
|
|
7324
|
+
default:
|
|
7325
|
+
props[propName] = isHtmlAttribute(propName) ? String(propVal) : propVal;
|
|
7276
7326
|
}
|
|
7277
7327
|
}
|
|
7278
7328
|
}
|
|
@@ -7422,14 +7472,8 @@ class FieldString extends Field {
|
|
|
7422
7472
|
constructor(name, defaultValue = "") {
|
|
7423
7473
|
super("text", name, CHECK_TYPE_STRING, stringCoercer, defaultValue);
|
|
7424
7474
|
}
|
|
7425
|
-
extendProtoForType(proto,
|
|
7426
|
-
|
|
7427
|
-
proto[`${name}IsEmpty`] = function() {
|
|
7428
|
-
return this.get(name, "").length === 0;
|
|
7429
|
-
};
|
|
7430
|
-
proto[`${name}Len`] = function() {
|
|
7431
|
-
return this.get(name, "").length;
|
|
7432
|
-
};
|
|
7475
|
+
extendProtoForType(proto, uname) {
|
|
7476
|
+
extendProtoSized(proto, this.name, uname, "", "length");
|
|
7433
7477
|
}
|
|
7434
7478
|
}
|
|
7435
7479
|
var intCoercer = (v) => Number.isFinite(v) ? Math.trunc(v) : null;
|
|
@@ -7472,7 +7516,7 @@ class FieldComp extends Field {
|
|
|
7472
7516
|
}
|
|
7473
7517
|
var NONE2 = Symbol("NONE");
|
|
7474
7518
|
function extendProtoForKeyed(proto, name, uname) {
|
|
7475
|
-
|
|
7519
|
+
extendProtoSized(proto, name, uname, EMPTY_LIST);
|
|
7476
7520
|
proto[`setIn${uname}At`] = function(i, v) {
|
|
7477
7521
|
return this.set(name, this.get(name).set(i, v));
|
|
7478
7522
|
};
|
|
@@ -7488,11 +7532,13 @@ function extendProtoForKeyed(proto, name, uname) {
|
|
|
7488
7532
|
console.warn("key", i, "not found in", name, col);
|
|
7489
7533
|
return this;
|
|
7490
7534
|
};
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
proto[`deleteIn${uname}
|
|
7495
|
-
|
|
7535
|
+
extendDeleteInAt(proto, name, `${uname}At`);
|
|
7536
|
+
}
|
|
7537
|
+
function extendDeleteInAt(proto, name, uname) {
|
|
7538
|
+
proto[`deleteIn${uname}`] = function(v) {
|
|
7539
|
+
return this.set(name, this.get(name).delete(v));
|
|
7540
|
+
};
|
|
7541
|
+
proto[`removeIn${uname}`] = proto[`deleteIn${uname}`];
|
|
7496
7542
|
}
|
|
7497
7543
|
var EMPTY_LIST = List();
|
|
7498
7544
|
var listCoercer = (v) => Array.isArray(v) ? List(v) : null;
|
|
@@ -7532,12 +7578,12 @@ class FieldOMap extends Field {
|
|
|
7532
7578
|
extendProtoForKeyed(proto, this.name, uname);
|
|
7533
7579
|
}
|
|
7534
7580
|
}
|
|
7535
|
-
function
|
|
7536
|
-
proto[
|
|
7537
|
-
return this.get(name, defaultEmpty)
|
|
7581
|
+
function extendProtoSized(proto, name, uname, defaultEmpty, propName = "size") {
|
|
7582
|
+
proto[`is${uname}Empty`] = function() {
|
|
7583
|
+
return this.get(name, defaultEmpty)[propName] === 0;
|
|
7538
7584
|
};
|
|
7539
7585
|
proto[`${name}Len`] = function() {
|
|
7540
|
-
return this.get(name, defaultEmpty)
|
|
7586
|
+
return this.get(name, defaultEmpty)[propName];
|
|
7541
7587
|
};
|
|
7542
7588
|
}
|
|
7543
7589
|
var EMPTY_SET2 = Set2();
|
|
@@ -7549,14 +7595,11 @@ class FieldSet extends Field {
|
|
|
7549
7595
|
}
|
|
7550
7596
|
extendProtoForType(proto, uname) {
|
|
7551
7597
|
const { name } = this;
|
|
7552
|
-
|
|
7598
|
+
extendProtoSized(proto, name, uname, EMPTY_SET2);
|
|
7553
7599
|
proto[`addIn${uname}`] = function(v) {
|
|
7554
7600
|
return this.set(name, this.get(name).add(v));
|
|
7555
7601
|
};
|
|
7556
|
-
proto
|
|
7557
|
-
return this.set(name, this.get(name).delete(v));
|
|
7558
|
-
};
|
|
7559
|
-
proto[`removeIn${uname}`] = proto[`deleteIn${uname}`];
|
|
7602
|
+
extendDeleteInAt(proto, name, uname);
|
|
7560
7603
|
proto[`hasIn${uname}`] = function(v) {
|
|
7561
7604
|
return this.get(name).has(v);
|
|
7562
7605
|
};
|