tutuca 0.9.63 → 0.9.64
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 +435 -427
- package/dist/tutuca-dev.js +555 -546
- package/dist/tutuca-dev.min.js +2 -2
- package/dist/tutuca-extra.js +555 -546
- package/dist/tutuca-extra.min.js +2 -2
- package/dist/tutuca.js +555 -546
- package/dist/tutuca.min.js +2 -2
- package/package.json +1 -1
package/dist/tutuca-extra.js
CHANGED
|
@@ -5528,197 +5528,531 @@ class RequestHandler {
|
|
|
5528
5528
|
}
|
|
5529
5529
|
}
|
|
5530
5530
|
|
|
5531
|
-
// src/
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5531
|
+
// src/vdom.js
|
|
5532
|
+
var isHtmlAttribute = (propName) => propName[4] === "-" && (propName[0] === "d" || propName[0] === "a");
|
|
5533
|
+
var HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
5534
|
+
var isNamespaced = (node) => {
|
|
5535
|
+
const ns = node.namespaceURI;
|
|
5536
|
+
return ns !== null && ns !== HTML_NS;
|
|
5537
|
+
};
|
|
5538
|
+
function applyProperties(node, props, previous) {
|
|
5539
|
+
const namespaced = isNamespaced(node);
|
|
5540
|
+
for (const propName in props) {
|
|
5541
|
+
const propValue = props[propName];
|
|
5542
|
+
if (propValue === undefined)
|
|
5543
|
+
removeProperty(node, propName, previous);
|
|
5544
|
+
else if (propName === "dangerouslySetInnerHTML")
|
|
5545
|
+
node.innerHTML = propValue.__html ?? "";
|
|
5546
|
+
else if (propName === "className")
|
|
5547
|
+
node.setAttribute("class", propValue);
|
|
5548
|
+
else if (namespaced || isHtmlAttribute(propName))
|
|
5549
|
+
node.setAttribute(propName, propValue);
|
|
5550
|
+
else
|
|
5551
|
+
node[propName] = propValue;
|
|
5543
5552
|
}
|
|
5544
|
-
if (producerComp == null || producerDyn == null)
|
|
5545
|
-
return null;
|
|
5546
|
-
const pi = producerDyn.val?.toPathItem?.() ?? null;
|
|
5547
|
-
return { producerCompId: producerComp.id, producerSteps: pi ? [pi] : [] };
|
|
5548
5553
|
}
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5554
|
+
function removeProperty(node, propName, previous) {
|
|
5555
|
+
const previousValue = previous[propName];
|
|
5556
|
+
if (propName === "dangerouslySetInnerHTML")
|
|
5557
|
+
node.replaceChildren();
|
|
5558
|
+
else if (propName === "className")
|
|
5559
|
+
node.removeAttribute("class");
|
|
5560
|
+
else if (propName === "htmlFor")
|
|
5561
|
+
node.removeAttribute("for");
|
|
5562
|
+
else if (isNamespaced(node) || typeof previousValue === "string" || isHtmlAttribute(propName))
|
|
5563
|
+
node.removeAttribute(propName);
|
|
5564
|
+
else
|
|
5565
|
+
node[propName] = null;
|
|
5561
5566
|
}
|
|
5562
5567
|
|
|
5563
|
-
class
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
return this.val;
|
|
5570
|
-
}
|
|
5571
|
-
isWhiteSpace() {
|
|
5572
|
-
for (let i = 0;i < this.val.length; i++) {
|
|
5573
|
-
const c = this.val.charCodeAt(i);
|
|
5574
|
-
if (!(c === 32 || c === 10 || c === 9 || c === 13))
|
|
5575
|
-
return false;
|
|
5576
|
-
}
|
|
5577
|
-
return true;
|
|
5578
|
-
}
|
|
5579
|
-
hasNewLine() {
|
|
5580
|
-
for (let i = 0;i < this.val.length; i++) {
|
|
5581
|
-
const c = this.val.charCodeAt(i);
|
|
5582
|
-
if (c === 10 || c === 13)
|
|
5583
|
-
return true;
|
|
5584
|
-
}
|
|
5585
|
-
return false;
|
|
5586
|
-
}
|
|
5587
|
-
condenseWhiteSpace(replacement = "") {
|
|
5588
|
-
this.val = replacement;
|
|
5589
|
-
}
|
|
5590
|
-
isConstant() {
|
|
5568
|
+
class VBase {
|
|
5569
|
+
}
|
|
5570
|
+
var getKey = (child) => child instanceof VNode2 ? child.key : undefined;
|
|
5571
|
+
var isIterable = (obj) => obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function";
|
|
5572
|
+
function childsEqual(a, b) {
|
|
5573
|
+
if (a === b)
|
|
5591
5574
|
return true;
|
|
5592
|
-
|
|
5593
|
-
|
|
5575
|
+
for (let i = 0;i < a.length; i++)
|
|
5576
|
+
if (!a[i].isEqualTo(b[i]))
|
|
5577
|
+
return false;
|
|
5578
|
+
return true;
|
|
5594
5579
|
}
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
return rx.renderComment(this.val);
|
|
5599
|
-
}
|
|
5580
|
+
function appendChildNodes(parent, childs, opts) {
|
|
5581
|
+
for (const child of childs)
|
|
5582
|
+
parent.appendChild(child.toDom(opts));
|
|
5600
5583
|
}
|
|
5601
|
-
function
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5584
|
+
function addChild(normalizedChildren, child) {
|
|
5585
|
+
if (child == null)
|
|
5586
|
+
return;
|
|
5587
|
+
if (isIterable(child)) {
|
|
5588
|
+
for (const c of child)
|
|
5589
|
+
addChild(normalizedChildren, c);
|
|
5590
|
+
} else if (child instanceof VBase) {
|
|
5591
|
+
if (child instanceof VFragment)
|
|
5592
|
+
normalizedChildren.push(...child.childs);
|
|
5606
5593
|
else
|
|
5607
|
-
|
|
5608
|
-
}
|
|
5609
|
-
|
|
5610
|
-
function optimizeNode(node) {
|
|
5611
|
-
if (node.isConstant())
|
|
5612
|
-
return new RenderOnceNode(node);
|
|
5613
|
-
node.optimize();
|
|
5614
|
-
return node;
|
|
5594
|
+
normalizedChildren.push(child);
|
|
5595
|
+
} else
|
|
5596
|
+
normalizedChildren.push(new VText(child));
|
|
5615
5597
|
}
|
|
5616
5598
|
|
|
5617
|
-
class
|
|
5618
|
-
constructor(
|
|
5599
|
+
class VText extends VBase {
|
|
5600
|
+
constructor(text) {
|
|
5619
5601
|
super();
|
|
5620
|
-
this.
|
|
5602
|
+
this.text = String(text);
|
|
5621
5603
|
}
|
|
5622
|
-
|
|
5623
|
-
return
|
|
5604
|
+
get nodeType() {
|
|
5605
|
+
return 3;
|
|
5624
5606
|
}
|
|
5625
|
-
|
|
5626
|
-
|
|
5607
|
+
isEqualTo(other) {
|
|
5608
|
+
return other instanceof VText && this.text === other.text;
|
|
5609
|
+
}
|
|
5610
|
+
toDom(opts) {
|
|
5611
|
+
return opts.document.createTextNode(this.text);
|
|
5627
5612
|
}
|
|
5628
5613
|
}
|
|
5629
5614
|
|
|
5630
|
-
class
|
|
5631
|
-
constructor(
|
|
5632
|
-
super(
|
|
5633
|
-
this.
|
|
5634
|
-
this.attrs = attrs;
|
|
5615
|
+
class VComment extends VBase {
|
|
5616
|
+
constructor(text) {
|
|
5617
|
+
super();
|
|
5618
|
+
this.text = text;
|
|
5635
5619
|
}
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
for (let i = 0;i < childNodes.length; i++)
|
|
5639
|
-
childNodes[i] = this.childs[i]?.render?.(stack, rx) ?? null;
|
|
5640
|
-
return rx.renderTag(this.tagName, this.attrs.eval(stack), childNodes);
|
|
5620
|
+
get nodeType() {
|
|
5621
|
+
return 8;
|
|
5641
5622
|
}
|
|
5642
|
-
|
|
5643
|
-
this.
|
|
5623
|
+
isEqualTo(other) {
|
|
5624
|
+
return other instanceof VComment && this.text === other.text;
|
|
5644
5625
|
}
|
|
5645
|
-
|
|
5646
|
-
return
|
|
5626
|
+
toDom(opts) {
|
|
5627
|
+
return opts.document.createComment(this.text);
|
|
5647
5628
|
}
|
|
5648
5629
|
}
|
|
5649
5630
|
|
|
5650
|
-
class
|
|
5651
|
-
|
|
5652
|
-
|
|
5631
|
+
class VFragment extends VBase {
|
|
5632
|
+
constructor(childs) {
|
|
5633
|
+
super();
|
|
5634
|
+
this.childs = [];
|
|
5635
|
+
addChild(this.childs, childs);
|
|
5653
5636
|
}
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5637
|
+
get nodeType() {
|
|
5638
|
+
return 11;
|
|
5639
|
+
}
|
|
5640
|
+
isEqualTo(other) {
|
|
5641
|
+
if (!(other instanceof VFragment) || this.childs.length !== other.childs.length)
|
|
5642
|
+
return false;
|
|
5643
|
+
return childsEqual(this.childs, other.childs);
|
|
5644
|
+
}
|
|
5645
|
+
toDom(opts) {
|
|
5646
|
+
const fragment = opts.document.createDocumentFragment();
|
|
5647
|
+
appendChildNodes(fragment, this.childs, opts);
|
|
5648
|
+
return fragment;
|
|
5657
5649
|
}
|
|
5658
5650
|
}
|
|
5659
|
-
var maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs);
|
|
5660
|
-
var VALID_NODE_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/;
|
|
5661
5651
|
|
|
5662
|
-
class
|
|
5663
|
-
constructor(
|
|
5652
|
+
class VNode2 extends VBase {
|
|
5653
|
+
constructor(tag, attrs, childs, key, namespace) {
|
|
5664
5654
|
super();
|
|
5665
|
-
this.
|
|
5666
|
-
this.
|
|
5655
|
+
this.tag = tag;
|
|
5656
|
+
this.attrs = attrs ?? {};
|
|
5657
|
+
this.childs = childs ?? [];
|
|
5658
|
+
this.key = key != null ? String(key) : undefined;
|
|
5659
|
+
this.namespace = typeof namespace === "string" ? namespace : null;
|
|
5667
5660
|
}
|
|
5668
|
-
|
|
5669
|
-
return
|
|
5661
|
+
get nodeType() {
|
|
5662
|
+
return 1;
|
|
5670
5663
|
}
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
if (nodes.length === 0)
|
|
5674
|
-
return new CommentNode("Empty View in ANode.parse");
|
|
5675
|
-
if (nodes.length === 1)
|
|
5676
|
-
return ANode.fromDOM(nodes[0], px);
|
|
5677
|
-
const childs = [];
|
|
5678
|
-
for (let i = 0;i < nodes.length; i++) {
|
|
5679
|
-
const child = ANode.fromDOM(nodes[i], px);
|
|
5680
|
-
if (child !== null)
|
|
5681
|
-
childs.push(child);
|
|
5682
|
-
}
|
|
5683
|
-
const trimmed = condenseChildsWhites(childs);
|
|
5684
|
-
if (trimmed.length === 0)
|
|
5685
|
-
return new CommentNode("Empty View in ANode.parse");
|
|
5686
|
-
return maybeFragment(trimmed);
|
|
5664
|
+
isSameKind(other) {
|
|
5665
|
+
return this.tag === other.tag && this.namespace === other.namespace && this.key === other.key;
|
|
5687
5666
|
}
|
|
5688
|
-
|
|
5689
|
-
if (
|
|
5690
|
-
return
|
|
5691
|
-
|
|
5692
|
-
return
|
|
5693
|
-
const { childNodes, attributes: attrs, tagName: tag } = node;
|
|
5694
|
-
const childs = [];
|
|
5695
|
-
for (let i = 0;i < childNodes.length; i++) {
|
|
5696
|
-
const child = ANode.fromDOM(childNodes[i], px);
|
|
5697
|
-
if (child !== null)
|
|
5698
|
-
childs.push(child);
|
|
5667
|
+
isEqualTo(other) {
|
|
5668
|
+
if (this === other)
|
|
5669
|
+
return true;
|
|
5670
|
+
if (!(other instanceof VNode2) || !this.isSameKind(other) || this.childs.length !== other.childs.length) {
|
|
5671
|
+
return false;
|
|
5699
5672
|
}
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5673
|
+
if (this.attrs !== other.attrs) {
|
|
5674
|
+
for (const key in this.attrs)
|
|
5675
|
+
if (this.attrs[key] !== other.attrs[key])
|
|
5676
|
+
return false;
|
|
5677
|
+
for (const key in other.attrs)
|
|
5678
|
+
if (!Object.hasOwn(this.attrs, key))
|
|
5679
|
+
return false;
|
|
5680
|
+
}
|
|
5681
|
+
return childsEqual(this.childs, other.childs);
|
|
5682
|
+
}
|
|
5683
|
+
toDom(opts) {
|
|
5684
|
+
const doc = opts.document;
|
|
5685
|
+
const node = this.namespace === null ? doc.createElement(this.tag) : doc.createElementNS(this.namespace, this.tag);
|
|
5686
|
+
if (this.tag === "SELECT" && "value" in this.attrs) {
|
|
5687
|
+
const { value, ...rest } = this.attrs;
|
|
5688
|
+
applyProperties(node, rest, {});
|
|
5689
|
+
appendChildNodes(node, this.childs, opts);
|
|
5690
|
+
applyProperties(node, { value }, {});
|
|
5691
|
+
} else {
|
|
5692
|
+
applyProperties(node, this.attrs, {});
|
|
5693
|
+
appendChildNodes(node, this.childs, opts);
|
|
5694
|
+
}
|
|
5695
|
+
return node;
|
|
5696
|
+
}
|
|
5697
|
+
}
|
|
5698
|
+
function diffProps(a, b) {
|
|
5699
|
+
if (a === b)
|
|
5700
|
+
return null;
|
|
5701
|
+
let diff = null;
|
|
5702
|
+
for (const aKey in a) {
|
|
5703
|
+
if (!Object.hasOwn(b, aKey)) {
|
|
5704
|
+
diff ??= {};
|
|
5705
|
+
diff[aKey] = undefined;
|
|
5706
|
+
} else if (a[aKey] !== b[aKey]) {
|
|
5707
|
+
diff ??= {};
|
|
5708
|
+
diff[aKey] = b[aKey];
|
|
5709
|
+
}
|
|
5710
|
+
}
|
|
5711
|
+
for (const bKey in b) {
|
|
5712
|
+
if (!Object.hasOwn(a, bKey)) {
|
|
5713
|
+
diff ??= {};
|
|
5714
|
+
diff[bKey] = b[bKey];
|
|
5715
|
+
}
|
|
5716
|
+
}
|
|
5717
|
+
return diff;
|
|
5718
|
+
}
|
|
5719
|
+
function morphNode(domNode, source, target, opts) {
|
|
5720
|
+
if (source === target || source.isEqualTo(target))
|
|
5721
|
+
return domNode;
|
|
5722
|
+
const type = source.nodeType;
|
|
5723
|
+
if (type === target.nodeType) {
|
|
5724
|
+
if (type === 3 || type === 8) {
|
|
5725
|
+
domNode.data = target.text;
|
|
5726
|
+
return domNode;
|
|
5727
|
+
}
|
|
5728
|
+
if (type === 1 && source.isSameKind(target)) {
|
|
5729
|
+
const propsDiff = diffProps(source.attrs, target.attrs);
|
|
5730
|
+
const isSelect = source.tag === "SELECT";
|
|
5731
|
+
if (propsDiff) {
|
|
5732
|
+
if (isSelect && "value" in propsDiff) {
|
|
5733
|
+
const { value: _v, ...rest } = propsDiff;
|
|
5734
|
+
applyProperties(domNode, rest, source.attrs);
|
|
5735
|
+
} else
|
|
5736
|
+
applyProperties(domNode, propsDiff, source.attrs);
|
|
5737
|
+
}
|
|
5738
|
+
if (!target.attrs.dangerouslySetInnerHTML)
|
|
5739
|
+
morphChildren(domNode, source.childs, target.childs, opts);
|
|
5740
|
+
if (isSelect && target.attrs.value !== undefined)
|
|
5741
|
+
applyProperties(domNode, { value: target.attrs.value }, source.attrs);
|
|
5742
|
+
return domNode;
|
|
5743
|
+
}
|
|
5744
|
+
if (type === 11) {
|
|
5745
|
+
morphChildren(domNode, source.childs, target.childs, opts);
|
|
5746
|
+
return domNode;
|
|
5747
|
+
}
|
|
5748
|
+
}
|
|
5749
|
+
const newNode = target.toDom(opts);
|
|
5750
|
+
domNode.parentNode?.replaceChild(newNode, domNode);
|
|
5751
|
+
return newNode;
|
|
5752
|
+
}
|
|
5753
|
+
function morphChildren(parentDom, oldChilds, newChilds, opts) {
|
|
5754
|
+
if (oldChilds.length === 0) {
|
|
5755
|
+
appendChildNodes(parentDom, newChilds, opts);
|
|
5756
|
+
return;
|
|
5757
|
+
}
|
|
5758
|
+
if (newChilds.length === 0) {
|
|
5759
|
+
parentDom.replaceChildren();
|
|
5760
|
+
return;
|
|
5761
|
+
}
|
|
5762
|
+
if (oldChilds.length === newChilds.length) {
|
|
5763
|
+
let hasKey = false;
|
|
5764
|
+
for (let i = 0;i < oldChilds.length; i++) {
|
|
5765
|
+
if (getKey(oldChilds[i]) != null || getKey(newChilds[i]) != null) {
|
|
5766
|
+
hasKey = true;
|
|
5767
|
+
break;
|
|
5768
|
+
}
|
|
5769
|
+
}
|
|
5770
|
+
if (!hasKey) {
|
|
5771
|
+
let dom = parentDom.firstChild;
|
|
5772
|
+
for (let i = 0;i < oldChilds.length; i++) {
|
|
5773
|
+
const next = dom.nextSibling;
|
|
5774
|
+
morphNode(dom, oldChilds[i], newChilds[i], opts);
|
|
5775
|
+
dom = next;
|
|
5776
|
+
}
|
|
5777
|
+
return;
|
|
5778
|
+
}
|
|
5779
|
+
}
|
|
5780
|
+
const domNodes = Array.from(parentDom.childNodes);
|
|
5781
|
+
const oldKeyMap = Object.create(null);
|
|
5782
|
+
for (let i = 0;i < oldChilds.length; i++) {
|
|
5783
|
+
const key = getKey(oldChilds[i]);
|
|
5784
|
+
if (key != null)
|
|
5785
|
+
oldKeyMap[key] = i;
|
|
5786
|
+
}
|
|
5787
|
+
const used = new Uint8Array(oldChilds.length);
|
|
5788
|
+
let unkeyedCursor = 0;
|
|
5789
|
+
for (let j = 0;j < newChilds.length; j++) {
|
|
5790
|
+
const newChild = newChilds[j];
|
|
5791
|
+
const newKey = getKey(newChild);
|
|
5792
|
+
let oldIdx = -1;
|
|
5793
|
+
if (newKey != null) {
|
|
5794
|
+
if (newKey in oldKeyMap && !used[oldKeyMap[newKey]])
|
|
5795
|
+
oldIdx = oldKeyMap[newKey];
|
|
5796
|
+
} else {
|
|
5797
|
+
while (unkeyedCursor < oldChilds.length) {
|
|
5798
|
+
if (!used[unkeyedCursor] && getKey(oldChilds[unkeyedCursor]) == null) {
|
|
5799
|
+
oldIdx = unkeyedCursor++;
|
|
5800
|
+
break;
|
|
5801
|
+
}
|
|
5802
|
+
unkeyedCursor++;
|
|
5803
|
+
}
|
|
5804
|
+
}
|
|
5805
|
+
if (oldIdx >= 0) {
|
|
5806
|
+
used[oldIdx] = 1;
|
|
5807
|
+
const newDom = morphNode(domNodes[oldIdx], oldChilds[oldIdx], newChild, opts);
|
|
5808
|
+
const ref = parentDom.childNodes[j] ?? null;
|
|
5809
|
+
if (newDom !== ref)
|
|
5810
|
+
parentDom.insertBefore(newDom, ref);
|
|
5811
|
+
} else {
|
|
5812
|
+
const ref = parentDom.childNodes[j] ?? null;
|
|
5813
|
+
parentDom.insertBefore(newChild.toDom(opts), ref);
|
|
5814
|
+
}
|
|
5815
|
+
}
|
|
5816
|
+
for (let i = oldChilds.length - 1;i >= 0; i--)
|
|
5817
|
+
if (!used[i] && domNodes[i].parentNode === parentDom)
|
|
5818
|
+
parentDom.removeChild(domNodes[i]);
|
|
5819
|
+
}
|
|
5820
|
+
function render(vnode, container, options, prev) {
|
|
5821
|
+
const isFragment = vnode instanceof VFragment;
|
|
5822
|
+
if (prev && prev.vnode instanceof VFragment === isFragment) {
|
|
5823
|
+
const oldDom = isFragment ? container : prev.dom;
|
|
5824
|
+
const newDom = morphNode(oldDom, prev.vnode, vnode, options);
|
|
5825
|
+
return { vnode, dom: isFragment ? container : newDom };
|
|
5826
|
+
}
|
|
5827
|
+
const domNode = vnode.toDom(options);
|
|
5828
|
+
container.replaceChildren(domNode);
|
|
5829
|
+
return { vnode, dom: isFragment ? container : domNode };
|
|
5830
|
+
}
|
|
5831
|
+
function h(tagName, properties, children, namespace) {
|
|
5832
|
+
const props = {};
|
|
5833
|
+
let key;
|
|
5834
|
+
if (properties) {
|
|
5835
|
+
for (const propName in properties) {
|
|
5836
|
+
const propVal = properties[propName];
|
|
5837
|
+
switch (propName) {
|
|
5838
|
+
case "key":
|
|
5839
|
+
key = propVal;
|
|
5840
|
+
break;
|
|
5841
|
+
case "namespace":
|
|
5842
|
+
namespace = namespace ?? propVal;
|
|
5843
|
+
break;
|
|
5844
|
+
case "class":
|
|
5845
|
+
props.className = propVal;
|
|
5846
|
+
break;
|
|
5847
|
+
case "for":
|
|
5848
|
+
props.htmlFor = propVal;
|
|
5849
|
+
break;
|
|
5850
|
+
default:
|
|
5851
|
+
props[propName] = isHtmlAttribute(propName) ? String(propVal) : propVal;
|
|
5852
|
+
}
|
|
5853
|
+
}
|
|
5854
|
+
}
|
|
5855
|
+
const c = tagName.charCodeAt(0);
|
|
5856
|
+
const tag = namespace == null && c >= 97 && c <= 122 ? tagName.toUpperCase() : tagName;
|
|
5857
|
+
const normalizedChildren = [];
|
|
5858
|
+
addChild(normalizedChildren, children);
|
|
5859
|
+
return new VNode2(tag, props, normalizedChildren, key, namespace);
|
|
5860
|
+
}
|
|
5861
|
+
|
|
5862
|
+
// src/anode.js
|
|
5863
|
+
function resolveDynProducer(comp, dynName) {
|
|
5864
|
+
const dyn = comp?.dynamic?.[dynName];
|
|
5865
|
+
if (dyn == null)
|
|
5866
|
+
return null;
|
|
5867
|
+
let producerComp, producerDyn;
|
|
5868
|
+
if (dyn.compName != null) {
|
|
5869
|
+
producerComp = comp.scope?.lookupComponent(dyn.compName);
|
|
5870
|
+
producerDyn = producerComp?.dynamic?.[dyn.dynName];
|
|
5871
|
+
} else {
|
|
5872
|
+
producerComp = comp;
|
|
5873
|
+
producerDyn = dyn;
|
|
5874
|
+
}
|
|
5875
|
+
if (producerComp == null || producerDyn == null)
|
|
5876
|
+
return null;
|
|
5877
|
+
const pi = producerDyn.val?.toPathItem?.() ?? null;
|
|
5878
|
+
return { producerCompId: producerComp.id, producerSteps: pi ? [pi] : [] };
|
|
5879
|
+
}
|
|
5880
|
+
|
|
5881
|
+
class BaseNode {
|
|
5882
|
+
render(_stack, _rx) {
|
|
5883
|
+
return null;
|
|
5884
|
+
}
|
|
5885
|
+
setDataAttr(key, val) {
|
|
5886
|
+
console.warn("setDataAttr not implemented for", this, { key, val });
|
|
5887
|
+
}
|
|
5888
|
+
isConstant() {
|
|
5889
|
+
return false;
|
|
5890
|
+
}
|
|
5891
|
+
optimize() {}
|
|
5892
|
+
}
|
|
5893
|
+
|
|
5894
|
+
class TextNode extends BaseNode {
|
|
5895
|
+
constructor(val) {
|
|
5896
|
+
super();
|
|
5897
|
+
this.val = val;
|
|
5898
|
+
}
|
|
5899
|
+
render(_stack, _rx) {
|
|
5900
|
+
return this.val;
|
|
5901
|
+
}
|
|
5902
|
+
isWhiteSpace() {
|
|
5903
|
+
for (let i = 0;i < this.val.length; i++) {
|
|
5904
|
+
const c = this.val.charCodeAt(i);
|
|
5905
|
+
if (!(c === 32 || c === 10 || c === 9 || c === 13))
|
|
5906
|
+
return false;
|
|
5907
|
+
}
|
|
5908
|
+
return true;
|
|
5909
|
+
}
|
|
5910
|
+
hasNewLine() {
|
|
5911
|
+
for (let i = 0;i < this.val.length; i++) {
|
|
5912
|
+
const c = this.val.charCodeAt(i);
|
|
5913
|
+
if (c === 10 || c === 13)
|
|
5914
|
+
return true;
|
|
5915
|
+
}
|
|
5916
|
+
return false;
|
|
5917
|
+
}
|
|
5918
|
+
condenseWhiteSpace(replacement = "") {
|
|
5919
|
+
this.val = replacement;
|
|
5920
|
+
}
|
|
5921
|
+
isConstant() {
|
|
5922
|
+
return true;
|
|
5923
|
+
}
|
|
5924
|
+
setDataAttr(_key, _val) {}
|
|
5925
|
+
}
|
|
5926
|
+
|
|
5927
|
+
class CommentNode extends TextNode {
|
|
5928
|
+
render(_stack, rx) {
|
|
5929
|
+
return rx.renderComment(this.val);
|
|
5930
|
+
}
|
|
5931
|
+
}
|
|
5932
|
+
function optimizeChilds(childs) {
|
|
5933
|
+
for (let i = 0;i < childs.length; i++) {
|
|
5934
|
+
const child = childs[i];
|
|
5935
|
+
if (child.isConstant())
|
|
5936
|
+
childs[i] = new RenderOnceNode(child);
|
|
5937
|
+
else
|
|
5938
|
+
child.optimize();
|
|
5939
|
+
}
|
|
5940
|
+
}
|
|
5941
|
+
function optimizeNode(node) {
|
|
5942
|
+
if (node.isConstant())
|
|
5943
|
+
return new RenderOnceNode(node);
|
|
5944
|
+
node.optimize();
|
|
5945
|
+
return node;
|
|
5946
|
+
}
|
|
5947
|
+
|
|
5948
|
+
class ChildsNode extends BaseNode {
|
|
5949
|
+
constructor(childs) {
|
|
5950
|
+
super();
|
|
5951
|
+
this.childs = childs;
|
|
5952
|
+
}
|
|
5953
|
+
isConstant() {
|
|
5954
|
+
return this.childs.every((v) => v.isConstant());
|
|
5955
|
+
}
|
|
5956
|
+
optimize() {
|
|
5957
|
+
optimizeChilds(this.childs);
|
|
5958
|
+
}
|
|
5959
|
+
}
|
|
5960
|
+
|
|
5961
|
+
class DomNode extends ChildsNode {
|
|
5962
|
+
constructor(tagName, attrs, childs, namespace = null) {
|
|
5963
|
+
super(childs);
|
|
5964
|
+
this.tagName = tagName;
|
|
5965
|
+
this.attrs = attrs;
|
|
5966
|
+
this.namespace = namespace;
|
|
5967
|
+
}
|
|
5968
|
+
render(stack, rx) {
|
|
5969
|
+
const childNodes = new Array(this.childs.length);
|
|
5970
|
+
for (let i = 0;i < childNodes.length; i++)
|
|
5971
|
+
childNodes[i] = this.childs[i]?.render?.(stack, rx) ?? null;
|
|
5972
|
+
return rx.renderTag(this.tagName, this.attrs.eval(stack), childNodes, this.namespace);
|
|
5973
|
+
}
|
|
5974
|
+
setDataAttr(key, val) {
|
|
5975
|
+
this.attrs.setDataAttr(key, val);
|
|
5976
|
+
}
|
|
5977
|
+
isConstant() {
|
|
5978
|
+
return this.attrs.isConstant() && super.isConstant();
|
|
5979
|
+
}
|
|
5980
|
+
}
|
|
5981
|
+
|
|
5982
|
+
class FragmentNode extends ChildsNode {
|
|
5983
|
+
render(stack, rx) {
|
|
5984
|
+
return rx.renderFragment(this.childs.map((c) => c?.render(stack, rx)));
|
|
5985
|
+
}
|
|
5986
|
+
setDataAttr(key, val) {
|
|
5987
|
+
for (const child of this.childs)
|
|
5988
|
+
child.setDataAttr(key, val);
|
|
5989
|
+
}
|
|
5990
|
+
}
|
|
5991
|
+
var maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs);
|
|
5992
|
+
var VALID_NODE_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/;
|
|
5993
|
+
|
|
5994
|
+
class ANode extends BaseNode {
|
|
5995
|
+
constructor(nodeId, val) {
|
|
5996
|
+
super();
|
|
5997
|
+
this.nodeId = nodeId;
|
|
5998
|
+
this.val = val;
|
|
5999
|
+
}
|
|
6000
|
+
toPathStep(ctx) {
|
|
6001
|
+
return ctx.applyKey(this.val?.toPathItem?.() ?? null);
|
|
6002
|
+
}
|
|
6003
|
+
static parse(html, px) {
|
|
6004
|
+
const nodes = px.parseHTML(html);
|
|
6005
|
+
if (nodes.length === 0)
|
|
6006
|
+
return new CommentNode("Empty View in ANode.parse");
|
|
6007
|
+
if (nodes.length === 1)
|
|
6008
|
+
return ANode.fromDOM(nodes[0], px);
|
|
6009
|
+
const childs = [];
|
|
6010
|
+
for (let i = 0;i < nodes.length; i++) {
|
|
6011
|
+
const child = ANode.fromDOM(nodes[i], px);
|
|
6012
|
+
if (child !== null)
|
|
6013
|
+
childs.push(child);
|
|
6014
|
+
}
|
|
6015
|
+
const trimmed = condenseChildsWhites(childs);
|
|
6016
|
+
if (trimmed.length === 0)
|
|
6017
|
+
return new CommentNode("Empty View in ANode.parse");
|
|
6018
|
+
return maybeFragment(trimmed);
|
|
6019
|
+
}
|
|
6020
|
+
static fromDOM(node, px) {
|
|
6021
|
+
if (node instanceof px.Text)
|
|
6022
|
+
return new TextNode(node.textContent);
|
|
6023
|
+
else if (node instanceof px.Comment)
|
|
6024
|
+
return new CommentNode(node.textContent);
|
|
6025
|
+
const { childNodes, attributes: attrs, tagName: tag } = node;
|
|
6026
|
+
const childs = [];
|
|
6027
|
+
for (let i = 0;i < childNodes.length; i++) {
|
|
6028
|
+
const child = ANode.fromDOM(childNodes[i], px);
|
|
6029
|
+
if (child !== null)
|
|
6030
|
+
childs.push(child);
|
|
6031
|
+
}
|
|
6032
|
+
const prevTag = px.currentTag;
|
|
6033
|
+
px.currentTag = tag;
|
|
6034
|
+
try {
|
|
6035
|
+
const isPseudoX = attrs[0]?.name === "@x";
|
|
6036
|
+
if (tag === "X" || isPseudoX)
|
|
6037
|
+
return parseXOp(attrs, childs, isPseudoX ? 1 : 0, px);
|
|
6038
|
+
else if (tag.charCodeAt(1) === 58 && tag.charCodeAt(0) === 88) {
|
|
6039
|
+
const macroName = tag.slice(2).toLowerCase();
|
|
6040
|
+
if (macroName === "slot") {
|
|
6041
|
+
const slotName = attrs.getNamedItem("name")?.value ?? "_";
|
|
6042
|
+
return px.frame.macroSlots[slotName] ?? maybeFragment(childs);
|
|
6043
|
+
}
|
|
6044
|
+
const [nAttrs, wrappers] = Attributes.parse(attrs, px, true);
|
|
6045
|
+
px.onAttributes(nAttrs, wrappers, null, true, tag);
|
|
6046
|
+
return wrap(px.newMacroNode(macroName, nAttrs.toMacroVars(), childs), px, wrappers);
|
|
6047
|
+
} else if (VALID_NODE_RE.test(tag)) {
|
|
5716
6048
|
const [nAttrs, wrappers, textChild] = Attributes.parse(attrs, px);
|
|
5717
6049
|
px.onAttributes(nAttrs, wrappers, textChild, false, tag);
|
|
5718
6050
|
if (textChild)
|
|
5719
6051
|
childs.unshift(new RenderTextNode(null, textChild));
|
|
5720
6052
|
const domChilds = tag !== "PRE" ? condenseChildsWhites(childs) : childs;
|
|
5721
|
-
|
|
6053
|
+
const ns = node.namespaceURI;
|
|
6054
|
+
const namespace = ns && ns !== HTML_NS ? ns : null;
|
|
6055
|
+
return wrap(new DomNode(tag, nAttrs, domChilds, namespace), px, wrappers);
|
|
5722
6056
|
}
|
|
5723
6057
|
return new CommentNode(`Error: InvalidTagName ${tag}`);
|
|
5724
6058
|
} finally {
|
|
@@ -6841,418 +7175,93 @@ class BubbleEvent extends SendEvent {
|
|
|
6841
7175
|
super(path, transactor, name, args, parent, opts);
|
|
6842
7176
|
this.targetPath = targetPath ?? path;
|
|
6843
7177
|
}
|
|
6844
|
-
stopPropagation() {
|
|
6845
|
-
this.opts.bubbles = false;
|
|
6846
|
-
}
|
|
6847
|
-
}
|
|
6848
|
-
|
|
6849
|
-
class Task {
|
|
6850
|
-
constructor() {
|
|
6851
|
-
this.deps = [];
|
|
6852
|
-
this.val = this.resolve = this.reject = null;
|
|
6853
|
-
this.promise = new Promise((res, rej) => {
|
|
6854
|
-
this.resolve = res;
|
|
6855
|
-
this.reject = rej;
|
|
6856
|
-
});
|
|
6857
|
-
this.isCompleted = false;
|
|
6858
|
-
}
|
|
6859
|
-
addDep(task) {
|
|
6860
|
-
console.assert(!this.isCompleted, "addDep for completed task", this, task);
|
|
6861
|
-
this.deps.push(task);
|
|
6862
|
-
task.promise.then((_) => this._check());
|
|
6863
|
-
}
|
|
6864
|
-
complete(val) {
|
|
6865
|
-
this.val = val;
|
|
6866
|
-
this._check();
|
|
6867
|
-
}
|
|
6868
|
-
_check() {
|
|
6869
|
-
if (this.deps.every((task) => task.isCompleted)) {
|
|
6870
|
-
this.isCompleted = true;
|
|
6871
|
-
this.resolve(this);
|
|
6872
|
-
}
|
|
6873
|
-
}
|
|
6874
|
-
}
|
|
6875
|
-
|
|
6876
|
-
class Dispatcher {
|
|
6877
|
-
constructor(path, transactor, parentTransaction) {
|
|
6878
|
-
this.path = path;
|
|
6879
|
-
this.transactor = transactor;
|
|
6880
|
-
this.parent = parentTransaction;
|
|
6881
|
-
}
|
|
6882
|
-
get at() {
|
|
6883
|
-
return new PathChanges(this);
|
|
6884
|
-
}
|
|
6885
|
-
send(name, args, opts) {
|
|
6886
|
-
return this.sendAtPath(this.path, name, args, opts);
|
|
6887
|
-
}
|
|
6888
|
-
bubble(name, args, opts) {
|
|
6889
|
-
return this.send(name, args, { skipSelf: true, bubbles: true, ...opts });
|
|
6890
|
-
}
|
|
6891
|
-
sendAtPath(path, name, args, opts) {
|
|
6892
|
-
return this.transactor.pushSend(path, name, args, opts, this.parent);
|
|
6893
|
-
}
|
|
6894
|
-
request(name, args, opts) {
|
|
6895
|
-
return this.requestAtPath(this.path, name, args, opts);
|
|
6896
|
-
}
|
|
6897
|
-
requestAtPath(path, name, args, opts) {
|
|
6898
|
-
return this.transactor.pushRequest(path, name, args, opts, this.parent);
|
|
6899
|
-
}
|
|
6900
|
-
lookupTypeFor(name, inst) {
|
|
6901
|
-
return this.transactor.comps.getCompFor(inst).scope.lookupComponent(name);
|
|
6902
|
-
}
|
|
6903
|
-
}
|
|
6904
|
-
|
|
6905
|
-
class EventContext extends Dispatcher {
|
|
6906
|
-
get name() {
|
|
6907
|
-
return this.parent?.name ?? null;
|
|
6908
|
-
}
|
|
6909
|
-
get targetPath() {
|
|
6910
|
-
return this.parent.targetPath;
|
|
6911
|
-
}
|
|
6912
|
-
stopPropagation() {
|
|
6913
|
-
return this.parent.stopPropagation();
|
|
6914
|
-
}
|
|
6915
|
-
}
|
|
6916
|
-
|
|
6917
|
-
class PathChanges extends PathBuilder {
|
|
6918
|
-
constructor(dispatcher) {
|
|
6919
|
-
super();
|
|
6920
|
-
this.dispatcher = dispatcher;
|
|
6921
|
-
}
|
|
6922
|
-
send(name, args, opts) {
|
|
6923
|
-
return this.dispatcher.sendAtPath(this.buildPath(), name, args, opts);
|
|
6924
|
-
}
|
|
6925
|
-
bubble(name, args, opts) {
|
|
6926
|
-
return this.send(name, args, { skipSelf: true, bubbles: true, ...opts });
|
|
6927
|
-
}
|
|
6928
|
-
buildPath() {
|
|
6929
|
-
return this.dispatcher.path.concat(this.pathChanges);
|
|
6930
|
-
}
|
|
6931
|
-
}
|
|
6932
|
-
|
|
6933
|
-
// src/vdom.js
|
|
6934
|
-
var isHtmlAttribute = (propName) => propName[4] === "-" && (propName[0] === "d" || propName[0] === "a");
|
|
6935
|
-
function applyProperties(node, props, previous) {
|
|
6936
|
-
for (const propName in props) {
|
|
6937
|
-
const propValue = props[propName];
|
|
6938
|
-
if (propValue === undefined)
|
|
6939
|
-
removeProperty(node, propName, previous);
|
|
6940
|
-
else if (isHtmlAttribute(propName))
|
|
6941
|
-
node.setAttribute(propName, propValue);
|
|
6942
|
-
else if (propName === "dangerouslySetInnerHTML")
|
|
6943
|
-
node.innerHTML = propValue.__html ?? "";
|
|
6944
|
-
else if (propName === "className")
|
|
6945
|
-
node.setAttribute("class", propValue);
|
|
6946
|
-
else
|
|
6947
|
-
node[propName] = propValue;
|
|
6948
|
-
}
|
|
6949
|
-
}
|
|
6950
|
-
function removeProperty(node, propName, previous) {
|
|
6951
|
-
const previousValue = previous[propName];
|
|
6952
|
-
if (propName === "dangerouslySetInnerHTML")
|
|
6953
|
-
node.replaceChildren();
|
|
6954
|
-
else if (propName === "className")
|
|
6955
|
-
node.removeAttribute("class");
|
|
6956
|
-
else if (propName === "htmlFor")
|
|
6957
|
-
node.removeAttribute("for");
|
|
6958
|
-
else if (typeof previousValue === "string" || isHtmlAttribute(propName))
|
|
6959
|
-
node.removeAttribute(propName);
|
|
6960
|
-
else
|
|
6961
|
-
node[propName] = null;
|
|
6962
|
-
}
|
|
6963
|
-
|
|
6964
|
-
class VBase {
|
|
6965
|
-
}
|
|
6966
|
-
var getKey = (child) => child instanceof VNode2 ? child.key : undefined;
|
|
6967
|
-
var isIterable = (obj) => obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function";
|
|
6968
|
-
function childsEqual(a, b) {
|
|
6969
|
-
if (a === b)
|
|
6970
|
-
return true;
|
|
6971
|
-
for (let i = 0;i < a.length; i++)
|
|
6972
|
-
if (!a[i].isEqualTo(b[i]))
|
|
6973
|
-
return false;
|
|
6974
|
-
return true;
|
|
6975
|
-
}
|
|
6976
|
-
function appendChildNodes(parent, childs, opts) {
|
|
6977
|
-
for (const child of childs)
|
|
6978
|
-
parent.appendChild(child.toDom(opts));
|
|
6979
|
-
}
|
|
6980
|
-
function addChild(normalizedChildren, child) {
|
|
6981
|
-
if (child == null)
|
|
6982
|
-
return;
|
|
6983
|
-
if (isIterable(child)) {
|
|
6984
|
-
for (const c of child)
|
|
6985
|
-
addChild(normalizedChildren, c);
|
|
6986
|
-
} else if (child instanceof VBase) {
|
|
6987
|
-
if (child instanceof VFragment)
|
|
6988
|
-
normalizedChildren.push(...child.childs);
|
|
6989
|
-
else
|
|
6990
|
-
normalizedChildren.push(child);
|
|
6991
|
-
} else
|
|
6992
|
-
normalizedChildren.push(new VText(child));
|
|
6993
|
-
}
|
|
6994
|
-
|
|
6995
|
-
class VText extends VBase {
|
|
6996
|
-
constructor(text) {
|
|
6997
|
-
super();
|
|
6998
|
-
this.text = String(text);
|
|
6999
|
-
}
|
|
7000
|
-
get nodeType() {
|
|
7001
|
-
return 3;
|
|
7002
|
-
}
|
|
7003
|
-
isEqualTo(other) {
|
|
7004
|
-
return other instanceof VText && this.text === other.text;
|
|
7005
|
-
}
|
|
7006
|
-
toDom(opts) {
|
|
7007
|
-
return opts.document.createTextNode(this.text);
|
|
7008
|
-
}
|
|
7009
|
-
}
|
|
7010
|
-
|
|
7011
|
-
class VComment extends VBase {
|
|
7012
|
-
constructor(text) {
|
|
7013
|
-
super();
|
|
7014
|
-
this.text = text;
|
|
7015
|
-
}
|
|
7016
|
-
get nodeType() {
|
|
7017
|
-
return 8;
|
|
7018
|
-
}
|
|
7019
|
-
isEqualTo(other) {
|
|
7020
|
-
return other instanceof VComment && this.text === other.text;
|
|
7021
|
-
}
|
|
7022
|
-
toDom(opts) {
|
|
7023
|
-
return opts.document.createComment(this.text);
|
|
7024
|
-
}
|
|
7025
|
-
}
|
|
7026
|
-
|
|
7027
|
-
class VFragment extends VBase {
|
|
7028
|
-
constructor(childs) {
|
|
7029
|
-
super();
|
|
7030
|
-
this.childs = [];
|
|
7031
|
-
addChild(this.childs, childs);
|
|
7032
|
-
}
|
|
7033
|
-
get nodeType() {
|
|
7034
|
-
return 11;
|
|
7035
|
-
}
|
|
7036
|
-
isEqualTo(other) {
|
|
7037
|
-
if (!(other instanceof VFragment) || this.childs.length !== other.childs.length)
|
|
7038
|
-
return false;
|
|
7039
|
-
return childsEqual(this.childs, other.childs);
|
|
7040
|
-
}
|
|
7041
|
-
toDom(opts) {
|
|
7042
|
-
const fragment = opts.document.createDocumentFragment();
|
|
7043
|
-
appendChildNodes(fragment, this.childs, opts);
|
|
7044
|
-
return fragment;
|
|
7178
|
+
stopPropagation() {
|
|
7179
|
+
this.opts.bubbles = false;
|
|
7045
7180
|
}
|
|
7046
7181
|
}
|
|
7047
7182
|
|
|
7048
|
-
class
|
|
7049
|
-
constructor(
|
|
7050
|
-
|
|
7051
|
-
this.
|
|
7052
|
-
this.
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
get nodeType() {
|
|
7058
|
-
return 1;
|
|
7183
|
+
class Task {
|
|
7184
|
+
constructor() {
|
|
7185
|
+
this.deps = [];
|
|
7186
|
+
this.val = this.resolve = this.reject = null;
|
|
7187
|
+
this.promise = new Promise((res, rej) => {
|
|
7188
|
+
this.resolve = res;
|
|
7189
|
+
this.reject = rej;
|
|
7190
|
+
});
|
|
7191
|
+
this.isCompleted = false;
|
|
7059
7192
|
}
|
|
7060
|
-
|
|
7061
|
-
|
|
7193
|
+
addDep(task) {
|
|
7194
|
+
console.assert(!this.isCompleted, "addDep for completed task", this, task);
|
|
7195
|
+
this.deps.push(task);
|
|
7196
|
+
task.promise.then((_) => this._check());
|
|
7062
7197
|
}
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
if (!(other instanceof VNode2) || !this.isSameKind(other) || this.childs.length !== other.childs.length) {
|
|
7067
|
-
return false;
|
|
7068
|
-
}
|
|
7069
|
-
if (this.attrs !== other.attrs) {
|
|
7070
|
-
for (const key in this.attrs)
|
|
7071
|
-
if (this.attrs[key] !== other.attrs[key])
|
|
7072
|
-
return false;
|
|
7073
|
-
for (const key in other.attrs)
|
|
7074
|
-
if (!Object.hasOwn(this.attrs, key))
|
|
7075
|
-
return false;
|
|
7076
|
-
}
|
|
7077
|
-
return childsEqual(this.childs, other.childs);
|
|
7198
|
+
complete(val) {
|
|
7199
|
+
this.val = val;
|
|
7200
|
+
this._check();
|
|
7078
7201
|
}
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
const { value, ...rest } = this.attrs;
|
|
7084
|
-
applyProperties(node, rest, {});
|
|
7085
|
-
appendChildNodes(node, this.childs, opts);
|
|
7086
|
-
applyProperties(node, { value }, {});
|
|
7087
|
-
} else {
|
|
7088
|
-
applyProperties(node, this.attrs, {});
|
|
7089
|
-
appendChildNodes(node, this.childs, opts);
|
|
7202
|
+
_check() {
|
|
7203
|
+
if (this.deps.every((task) => task.isCompleted)) {
|
|
7204
|
+
this.isCompleted = true;
|
|
7205
|
+
this.resolve(this);
|
|
7090
7206
|
}
|
|
7091
|
-
return node;
|
|
7092
7207
|
}
|
|
7093
7208
|
}
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
diff ??= {};
|
|
7101
|
-
diff[aKey] = undefined;
|
|
7102
|
-
} else if (a[aKey] !== b[aKey]) {
|
|
7103
|
-
diff ??= {};
|
|
7104
|
-
diff[aKey] = b[aKey];
|
|
7105
|
-
}
|
|
7209
|
+
|
|
7210
|
+
class Dispatcher {
|
|
7211
|
+
constructor(path, transactor, parentTransaction) {
|
|
7212
|
+
this.path = path;
|
|
7213
|
+
this.transactor = transactor;
|
|
7214
|
+
this.parent = parentTransaction;
|
|
7106
7215
|
}
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
diff ??= {};
|
|
7110
|
-
diff[bKey] = b[bKey];
|
|
7111
|
-
}
|
|
7216
|
+
get at() {
|
|
7217
|
+
return new PathChanges(this);
|
|
7112
7218
|
}
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
function morphNode(domNode, source, target, opts) {
|
|
7116
|
-
if (source === target || source.isEqualTo(target))
|
|
7117
|
-
return domNode;
|
|
7118
|
-
const type = source.nodeType;
|
|
7119
|
-
if (type === target.nodeType) {
|
|
7120
|
-
if (type === 3 || type === 8) {
|
|
7121
|
-
domNode.data = target.text;
|
|
7122
|
-
return domNode;
|
|
7123
|
-
}
|
|
7124
|
-
if (type === 1 && source.isSameKind(target)) {
|
|
7125
|
-
const propsDiff = diffProps(source.attrs, target.attrs);
|
|
7126
|
-
const isSelect = source.tag === "SELECT";
|
|
7127
|
-
if (propsDiff) {
|
|
7128
|
-
if (isSelect && "value" in propsDiff) {
|
|
7129
|
-
const { value: _v, ...rest } = propsDiff;
|
|
7130
|
-
applyProperties(domNode, rest, source.attrs);
|
|
7131
|
-
} else
|
|
7132
|
-
applyProperties(domNode, propsDiff, source.attrs);
|
|
7133
|
-
}
|
|
7134
|
-
if (!target.attrs.dangerouslySetInnerHTML)
|
|
7135
|
-
morphChildren(domNode, source.childs, target.childs, opts);
|
|
7136
|
-
if (isSelect && target.attrs.value !== undefined)
|
|
7137
|
-
applyProperties(domNode, { value: target.attrs.value }, source.attrs);
|
|
7138
|
-
return domNode;
|
|
7139
|
-
}
|
|
7140
|
-
if (type === 11) {
|
|
7141
|
-
morphChildren(domNode, source.childs, target.childs, opts);
|
|
7142
|
-
return domNode;
|
|
7143
|
-
}
|
|
7219
|
+
send(name, args, opts) {
|
|
7220
|
+
return this.sendAtPath(this.path, name, args, opts);
|
|
7144
7221
|
}
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
return newNode;
|
|
7148
|
-
}
|
|
7149
|
-
function morphChildren(parentDom, oldChilds, newChilds, opts) {
|
|
7150
|
-
if (oldChilds.length === 0) {
|
|
7151
|
-
appendChildNodes(parentDom, newChilds, opts);
|
|
7152
|
-
return;
|
|
7222
|
+
bubble(name, args, opts) {
|
|
7223
|
+
return this.send(name, args, { skipSelf: true, bubbles: true, ...opts });
|
|
7153
7224
|
}
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
return;
|
|
7225
|
+
sendAtPath(path, name, args, opts) {
|
|
7226
|
+
return this.transactor.pushSend(path, name, args, opts, this.parent);
|
|
7157
7227
|
}
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
for (let i = 0;i < oldChilds.length; i++) {
|
|
7161
|
-
if (getKey(oldChilds[i]) != null || getKey(newChilds[i]) != null) {
|
|
7162
|
-
hasKey = true;
|
|
7163
|
-
break;
|
|
7164
|
-
}
|
|
7165
|
-
}
|
|
7166
|
-
if (!hasKey) {
|
|
7167
|
-
let dom = parentDom.firstChild;
|
|
7168
|
-
for (let i = 0;i < oldChilds.length; i++) {
|
|
7169
|
-
const next = dom.nextSibling;
|
|
7170
|
-
morphNode(dom, oldChilds[i], newChilds[i], opts);
|
|
7171
|
-
dom = next;
|
|
7172
|
-
}
|
|
7173
|
-
return;
|
|
7174
|
-
}
|
|
7228
|
+
request(name, args, opts) {
|
|
7229
|
+
return this.requestAtPath(this.path, name, args, opts);
|
|
7175
7230
|
}
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
for (let i = 0;i < oldChilds.length; i++) {
|
|
7179
|
-
const key = getKey(oldChilds[i]);
|
|
7180
|
-
if (key != null)
|
|
7181
|
-
oldKeyMap[key] = i;
|
|
7231
|
+
requestAtPath(path, name, args, opts) {
|
|
7232
|
+
return this.transactor.pushRequest(path, name, args, opts, this.parent);
|
|
7182
7233
|
}
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
for (let j = 0;j < newChilds.length; j++) {
|
|
7186
|
-
const newChild = newChilds[j];
|
|
7187
|
-
const newKey = getKey(newChild);
|
|
7188
|
-
let oldIdx = -1;
|
|
7189
|
-
if (newKey != null) {
|
|
7190
|
-
if (newKey in oldKeyMap && !used[oldKeyMap[newKey]])
|
|
7191
|
-
oldIdx = oldKeyMap[newKey];
|
|
7192
|
-
} else {
|
|
7193
|
-
while (unkeyedCursor < oldChilds.length) {
|
|
7194
|
-
if (!used[unkeyedCursor] && getKey(oldChilds[unkeyedCursor]) == null) {
|
|
7195
|
-
oldIdx = unkeyedCursor++;
|
|
7196
|
-
break;
|
|
7197
|
-
}
|
|
7198
|
-
unkeyedCursor++;
|
|
7199
|
-
}
|
|
7200
|
-
}
|
|
7201
|
-
if (oldIdx >= 0) {
|
|
7202
|
-
used[oldIdx] = 1;
|
|
7203
|
-
const newDom = morphNode(domNodes[oldIdx], oldChilds[oldIdx], newChild, opts);
|
|
7204
|
-
const ref = parentDom.childNodes[j] ?? null;
|
|
7205
|
-
if (newDom !== ref)
|
|
7206
|
-
parentDom.insertBefore(newDom, ref);
|
|
7207
|
-
} else {
|
|
7208
|
-
const ref = parentDom.childNodes[j] ?? null;
|
|
7209
|
-
parentDom.insertBefore(newChild.toDom(opts), ref);
|
|
7210
|
-
}
|
|
7234
|
+
lookupTypeFor(name, inst) {
|
|
7235
|
+
return this.transactor.comps.getCompFor(inst).scope.lookupComponent(name);
|
|
7211
7236
|
}
|
|
7212
|
-
for (let i = oldChilds.length - 1;i >= 0; i--)
|
|
7213
|
-
if (!used[i] && domNodes[i].parentNode === parentDom)
|
|
7214
|
-
parentDom.removeChild(domNodes[i]);
|
|
7215
7237
|
}
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7238
|
+
|
|
7239
|
+
class EventContext extends Dispatcher {
|
|
7240
|
+
get name() {
|
|
7241
|
+
return this.parent?.name ?? null;
|
|
7242
|
+
}
|
|
7243
|
+
get targetPath() {
|
|
7244
|
+
return this.parent.targetPath;
|
|
7245
|
+
}
|
|
7246
|
+
stopPropagation() {
|
|
7247
|
+
return this.parent.stopPropagation();
|
|
7222
7248
|
}
|
|
7223
|
-
const domNode = vnode.toDom(options);
|
|
7224
|
-
container.replaceChildren(domNode);
|
|
7225
|
-
return { vnode, dom: isFragment ? container : domNode };
|
|
7226
7249
|
}
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
break;
|
|
7242
|
-
case "class":
|
|
7243
|
-
props.className = propVal;
|
|
7244
|
-
break;
|
|
7245
|
-
case "for":
|
|
7246
|
-
props.htmlFor = propVal;
|
|
7247
|
-
break;
|
|
7248
|
-
default:
|
|
7249
|
-
props[propName] = isHtmlAttribute(propName) ? String(propVal) : propVal;
|
|
7250
|
-
}
|
|
7251
|
-
}
|
|
7250
|
+
|
|
7251
|
+
class PathChanges extends PathBuilder {
|
|
7252
|
+
constructor(dispatcher) {
|
|
7253
|
+
super();
|
|
7254
|
+
this.dispatcher = dispatcher;
|
|
7255
|
+
}
|
|
7256
|
+
send(name, args, opts) {
|
|
7257
|
+
return this.dispatcher.sendAtPath(this.buildPath(), name, args, opts);
|
|
7258
|
+
}
|
|
7259
|
+
bubble(name, args, opts) {
|
|
7260
|
+
return this.send(name, args, { skipSelf: true, bubbles: true, ...opts });
|
|
7261
|
+
}
|
|
7262
|
+
buildPath() {
|
|
7263
|
+
return this.dispatcher.path.concat(this.pathChanges);
|
|
7252
7264
|
}
|
|
7253
|
-
const normalizedChildren = [];
|
|
7254
|
-
addChild(normalizedChildren, children);
|
|
7255
|
-
return new VNode2(tag, props, normalizedChildren, key, namespace);
|
|
7256
7265
|
}
|
|
7257
7266
|
|
|
7258
7267
|
// src/app.js
|