tutuca 0.9.62 → 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 +446 -432
- package/dist/tutuca-dev.js +566 -551
- package/dist/tutuca-dev.min.js +2 -2
- package/dist/tutuca-extra.js +566 -551
- package/dist/tutuca-extra.min.js +2 -2
- package/dist/tutuca.js +566 -551
- package/dist/tutuca.min.js +2 -2
- package/package.json +1 -1
package/dist/tutuca-dev.js
CHANGED
|
@@ -8155,7 +8155,12 @@ class ValParser {
|
|
|
8155
8155
|
const newS = px.frame.macroVars?.[name];
|
|
8156
8156
|
if (newS !== undefined) {
|
|
8157
8157
|
const tokens = tokenizeValue(newS.trim());
|
|
8158
|
-
|
|
8158
|
+
if (tokens.length !== 1)
|
|
8159
|
+
return null;
|
|
8160
|
+
const val = this.parseToken(tokens[0], px);
|
|
8161
|
+
if (val instanceof ConstVal)
|
|
8162
|
+
val.fromMacroVar = true;
|
|
8163
|
+
return val;
|
|
8159
8164
|
}
|
|
8160
8165
|
px.onParseIssue("bad-value", { role: "macro-var", name, value: s });
|
|
8161
8166
|
return null;
|
|
@@ -8379,7 +8384,7 @@ class StrTplVal extends VarVal {
|
|
|
8379
8384
|
toLiteralSource() {
|
|
8380
8385
|
let out = "";
|
|
8381
8386
|
for (const v of this.vals) {
|
|
8382
|
-
if (!(v instanceof ConstVal))
|
|
8387
|
+
if (!(v instanceof ConstVal) || v.fromMacroVar)
|
|
8383
8388
|
return null;
|
|
8384
8389
|
out += v.val;
|
|
8385
8390
|
}
|
|
@@ -8395,9 +8400,10 @@ class StrTplVal extends VarVal {
|
|
|
8395
8400
|
}
|
|
8396
8401
|
let lo = 0;
|
|
8397
8402
|
let hi = vals.length;
|
|
8398
|
-
|
|
8403
|
+
const isTrimmable = (v) => v instanceof ConstVal && v.val === "" && !v.fromMacroVar;
|
|
8404
|
+
while (lo < hi && isTrimmable(vals[lo]))
|
|
8399
8405
|
lo++;
|
|
8400
|
-
while (hi > lo && vals[hi - 1]
|
|
8406
|
+
while (hi > lo && isTrimmable(vals[hi - 1]))
|
|
8401
8407
|
hi--;
|
|
8402
8408
|
return new StrTplVal(lo === 0 && hi === vals.length ? vals : vals.slice(lo, hi));
|
|
8403
8409
|
}
|
|
@@ -8817,197 +8823,531 @@ class RequestHandler {
|
|
|
8817
8823
|
}
|
|
8818
8824
|
}
|
|
8819
8825
|
|
|
8820
|
-
// src/
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8826
|
+
// src/vdom.js
|
|
8827
|
+
var isHtmlAttribute = (propName) => propName[4] === "-" && (propName[0] === "d" || propName[0] === "a");
|
|
8828
|
+
var HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
8829
|
+
var isNamespaced = (node) => {
|
|
8830
|
+
const ns = node.namespaceURI;
|
|
8831
|
+
return ns !== null && ns !== HTML_NS;
|
|
8832
|
+
};
|
|
8833
|
+
function applyProperties(node, props, previous) {
|
|
8834
|
+
const namespaced = isNamespaced(node);
|
|
8835
|
+
for (const propName in props) {
|
|
8836
|
+
const propValue = props[propName];
|
|
8837
|
+
if (propValue === undefined)
|
|
8838
|
+
removeProperty(node, propName, previous);
|
|
8839
|
+
else if (propName === "dangerouslySetInnerHTML")
|
|
8840
|
+
node.innerHTML = propValue.__html ?? "";
|
|
8841
|
+
else if (propName === "className")
|
|
8842
|
+
node.setAttribute("class", propValue);
|
|
8843
|
+
else if (namespaced || isHtmlAttribute(propName))
|
|
8844
|
+
node.setAttribute(propName, propValue);
|
|
8845
|
+
else
|
|
8846
|
+
node[propName] = propValue;
|
|
8832
8847
|
}
|
|
8833
|
-
if (producerComp == null || producerDyn == null)
|
|
8834
|
-
return null;
|
|
8835
|
-
const pi = producerDyn.val?.toPathItem?.() ?? null;
|
|
8836
|
-
return { producerCompId: producerComp.id, producerSteps: pi ? [pi] : [] };
|
|
8837
8848
|
}
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8849
|
+
function removeProperty(node, propName, previous) {
|
|
8850
|
+
const previousValue = previous[propName];
|
|
8851
|
+
if (propName === "dangerouslySetInnerHTML")
|
|
8852
|
+
node.replaceChildren();
|
|
8853
|
+
else if (propName === "className")
|
|
8854
|
+
node.removeAttribute("class");
|
|
8855
|
+
else if (propName === "htmlFor")
|
|
8856
|
+
node.removeAttribute("for");
|
|
8857
|
+
else if (isNamespaced(node) || typeof previousValue === "string" || isHtmlAttribute(propName))
|
|
8858
|
+
node.removeAttribute(propName);
|
|
8859
|
+
else
|
|
8860
|
+
node[propName] = null;
|
|
8850
8861
|
}
|
|
8851
8862
|
|
|
8852
|
-
class
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
return this.val;
|
|
8859
|
-
}
|
|
8860
|
-
isWhiteSpace() {
|
|
8861
|
-
for (let i = 0;i < this.val.length; i++) {
|
|
8862
|
-
const c = this.val.charCodeAt(i);
|
|
8863
|
-
if (!(c === 32 || c === 10 || c === 9 || c === 13))
|
|
8864
|
-
return false;
|
|
8865
|
-
}
|
|
8866
|
-
return true;
|
|
8867
|
-
}
|
|
8868
|
-
hasNewLine() {
|
|
8869
|
-
for (let i = 0;i < this.val.length; i++) {
|
|
8870
|
-
const c = this.val.charCodeAt(i);
|
|
8871
|
-
if (c === 10 || c === 13)
|
|
8872
|
-
return true;
|
|
8873
|
-
}
|
|
8874
|
-
return false;
|
|
8875
|
-
}
|
|
8876
|
-
condenseWhiteSpace(replacement = "") {
|
|
8877
|
-
this.val = replacement;
|
|
8878
|
-
}
|
|
8879
|
-
isConstant() {
|
|
8863
|
+
class VBase {
|
|
8864
|
+
}
|
|
8865
|
+
var getKey = (child) => child instanceof VNode2 ? child.key : undefined;
|
|
8866
|
+
var isIterable = (obj) => obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function";
|
|
8867
|
+
function childsEqual(a, b) {
|
|
8868
|
+
if (a === b)
|
|
8880
8869
|
return true;
|
|
8881
|
-
|
|
8882
|
-
|
|
8870
|
+
for (let i = 0;i < a.length; i++)
|
|
8871
|
+
if (!a[i].isEqualTo(b[i]))
|
|
8872
|
+
return false;
|
|
8873
|
+
return true;
|
|
8883
8874
|
}
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
return rx.renderComment(this.val);
|
|
8888
|
-
}
|
|
8875
|
+
function appendChildNodes(parent, childs, opts) {
|
|
8876
|
+
for (const child of childs)
|
|
8877
|
+
parent.appendChild(child.toDom(opts));
|
|
8889
8878
|
}
|
|
8890
|
-
function
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8879
|
+
function addChild(normalizedChildren, child) {
|
|
8880
|
+
if (child == null)
|
|
8881
|
+
return;
|
|
8882
|
+
if (isIterable(child)) {
|
|
8883
|
+
for (const c of child)
|
|
8884
|
+
addChild(normalizedChildren, c);
|
|
8885
|
+
} else if (child instanceof VBase) {
|
|
8886
|
+
if (child instanceof VFragment)
|
|
8887
|
+
normalizedChildren.push(...child.childs);
|
|
8895
8888
|
else
|
|
8896
|
-
|
|
8897
|
-
}
|
|
8898
|
-
|
|
8899
|
-
function optimizeNode(node) {
|
|
8900
|
-
if (node.isConstant())
|
|
8901
|
-
return new RenderOnceNode(node);
|
|
8902
|
-
node.optimize();
|
|
8903
|
-
return node;
|
|
8889
|
+
normalizedChildren.push(child);
|
|
8890
|
+
} else
|
|
8891
|
+
normalizedChildren.push(new VText(child));
|
|
8904
8892
|
}
|
|
8905
8893
|
|
|
8906
|
-
class
|
|
8907
|
-
constructor(
|
|
8894
|
+
class VText extends VBase {
|
|
8895
|
+
constructor(text) {
|
|
8908
8896
|
super();
|
|
8909
|
-
this.
|
|
8897
|
+
this.text = String(text);
|
|
8910
8898
|
}
|
|
8911
|
-
|
|
8912
|
-
return
|
|
8899
|
+
get nodeType() {
|
|
8900
|
+
return 3;
|
|
8913
8901
|
}
|
|
8914
|
-
|
|
8915
|
-
|
|
8902
|
+
isEqualTo(other) {
|
|
8903
|
+
return other instanceof VText && this.text === other.text;
|
|
8904
|
+
}
|
|
8905
|
+
toDom(opts) {
|
|
8906
|
+
return opts.document.createTextNode(this.text);
|
|
8916
8907
|
}
|
|
8917
8908
|
}
|
|
8918
8909
|
|
|
8919
|
-
class
|
|
8920
|
-
constructor(
|
|
8921
|
-
super(
|
|
8922
|
-
this.
|
|
8923
|
-
this.attrs = attrs;
|
|
8910
|
+
class VComment extends VBase {
|
|
8911
|
+
constructor(text) {
|
|
8912
|
+
super();
|
|
8913
|
+
this.text = text;
|
|
8924
8914
|
}
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
for (let i = 0;i < childNodes.length; i++)
|
|
8928
|
-
childNodes[i] = this.childs[i]?.render?.(stack, rx) ?? null;
|
|
8929
|
-
return rx.renderTag(this.tagName, this.attrs.eval(stack), childNodes);
|
|
8915
|
+
get nodeType() {
|
|
8916
|
+
return 8;
|
|
8930
8917
|
}
|
|
8931
|
-
|
|
8932
|
-
this.
|
|
8918
|
+
isEqualTo(other) {
|
|
8919
|
+
return other instanceof VComment && this.text === other.text;
|
|
8933
8920
|
}
|
|
8934
|
-
|
|
8935
|
-
return
|
|
8921
|
+
toDom(opts) {
|
|
8922
|
+
return opts.document.createComment(this.text);
|
|
8936
8923
|
}
|
|
8937
8924
|
}
|
|
8938
8925
|
|
|
8939
|
-
class
|
|
8940
|
-
|
|
8941
|
-
|
|
8926
|
+
class VFragment extends VBase {
|
|
8927
|
+
constructor(childs) {
|
|
8928
|
+
super();
|
|
8929
|
+
this.childs = [];
|
|
8930
|
+
addChild(this.childs, childs);
|
|
8942
8931
|
}
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8932
|
+
get nodeType() {
|
|
8933
|
+
return 11;
|
|
8934
|
+
}
|
|
8935
|
+
isEqualTo(other) {
|
|
8936
|
+
if (!(other instanceof VFragment) || this.childs.length !== other.childs.length)
|
|
8937
|
+
return false;
|
|
8938
|
+
return childsEqual(this.childs, other.childs);
|
|
8939
|
+
}
|
|
8940
|
+
toDom(opts) {
|
|
8941
|
+
const fragment = opts.document.createDocumentFragment();
|
|
8942
|
+
appendChildNodes(fragment, this.childs, opts);
|
|
8943
|
+
return fragment;
|
|
8946
8944
|
}
|
|
8947
8945
|
}
|
|
8948
|
-
var maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs);
|
|
8949
|
-
var VALID_NODE_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/;
|
|
8950
8946
|
|
|
8951
|
-
class
|
|
8952
|
-
constructor(
|
|
8947
|
+
class VNode2 extends VBase {
|
|
8948
|
+
constructor(tag, attrs, childs, key, namespace) {
|
|
8953
8949
|
super();
|
|
8954
|
-
this.
|
|
8955
|
-
this.
|
|
8950
|
+
this.tag = tag;
|
|
8951
|
+
this.attrs = attrs ?? {};
|
|
8952
|
+
this.childs = childs ?? [];
|
|
8953
|
+
this.key = key != null ? String(key) : undefined;
|
|
8954
|
+
this.namespace = typeof namespace === "string" ? namespace : null;
|
|
8956
8955
|
}
|
|
8957
|
-
|
|
8958
|
-
return
|
|
8956
|
+
get nodeType() {
|
|
8957
|
+
return 1;
|
|
8959
8958
|
}
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
if (nodes.length === 0)
|
|
8963
|
-
return new CommentNode("Empty View in ANode.parse");
|
|
8964
|
-
if (nodes.length === 1)
|
|
8965
|
-
return ANode.fromDOM(nodes[0], px);
|
|
8966
|
-
const childs = [];
|
|
8967
|
-
for (let i = 0;i < nodes.length; i++) {
|
|
8968
|
-
const child = ANode.fromDOM(nodes[i], px);
|
|
8969
|
-
if (child !== null)
|
|
8970
|
-
childs.push(child);
|
|
8971
|
-
}
|
|
8972
|
-
const trimmed = condenseChildsWhites(childs);
|
|
8973
|
-
if (trimmed.length === 0)
|
|
8974
|
-
return new CommentNode("Empty View in ANode.parse");
|
|
8975
|
-
return maybeFragment(trimmed);
|
|
8959
|
+
isSameKind(other) {
|
|
8960
|
+
return this.tag === other.tag && this.namespace === other.namespace && this.key === other.key;
|
|
8976
8961
|
}
|
|
8977
|
-
|
|
8978
|
-
if (
|
|
8979
|
-
return
|
|
8980
|
-
|
|
8981
|
-
return
|
|
8982
|
-
const { childNodes, attributes: attrs, tagName: tag } = node;
|
|
8983
|
-
const childs = [];
|
|
8984
|
-
for (let i = 0;i < childNodes.length; i++) {
|
|
8985
|
-
const child = ANode.fromDOM(childNodes[i], px);
|
|
8986
|
-
if (child !== null)
|
|
8987
|
-
childs.push(child);
|
|
8962
|
+
isEqualTo(other) {
|
|
8963
|
+
if (this === other)
|
|
8964
|
+
return true;
|
|
8965
|
+
if (!(other instanceof VNode2) || !this.isSameKind(other) || this.childs.length !== other.childs.length) {
|
|
8966
|
+
return false;
|
|
8988
8967
|
}
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
8968
|
+
if (this.attrs !== other.attrs) {
|
|
8969
|
+
for (const key in this.attrs)
|
|
8970
|
+
if (this.attrs[key] !== other.attrs[key])
|
|
8971
|
+
return false;
|
|
8972
|
+
for (const key in other.attrs)
|
|
8973
|
+
if (!Object.hasOwn(this.attrs, key))
|
|
8974
|
+
return false;
|
|
8975
|
+
}
|
|
8976
|
+
return childsEqual(this.childs, other.childs);
|
|
8977
|
+
}
|
|
8978
|
+
toDom(opts) {
|
|
8979
|
+
const doc = opts.document;
|
|
8980
|
+
const node = this.namespace === null ? doc.createElement(this.tag) : doc.createElementNS(this.namespace, this.tag);
|
|
8981
|
+
if (this.tag === "SELECT" && "value" in this.attrs) {
|
|
8982
|
+
const { value, ...rest } = this.attrs;
|
|
8983
|
+
applyProperties(node, rest, {});
|
|
8984
|
+
appendChildNodes(node, this.childs, opts);
|
|
8985
|
+
applyProperties(node, { value }, {});
|
|
8986
|
+
} else {
|
|
8987
|
+
applyProperties(node, this.attrs, {});
|
|
8988
|
+
appendChildNodes(node, this.childs, opts);
|
|
8989
|
+
}
|
|
8990
|
+
return node;
|
|
8991
|
+
}
|
|
8992
|
+
}
|
|
8993
|
+
function diffProps(a, b) {
|
|
8994
|
+
if (a === b)
|
|
8995
|
+
return null;
|
|
8996
|
+
let diff = null;
|
|
8997
|
+
for (const aKey in a) {
|
|
8998
|
+
if (!Object.hasOwn(b, aKey)) {
|
|
8999
|
+
diff ??= {};
|
|
9000
|
+
diff[aKey] = undefined;
|
|
9001
|
+
} else if (a[aKey] !== b[aKey]) {
|
|
9002
|
+
diff ??= {};
|
|
9003
|
+
diff[aKey] = b[aKey];
|
|
9004
|
+
}
|
|
9005
|
+
}
|
|
9006
|
+
for (const bKey in b) {
|
|
9007
|
+
if (!Object.hasOwn(a, bKey)) {
|
|
9008
|
+
diff ??= {};
|
|
9009
|
+
diff[bKey] = b[bKey];
|
|
9010
|
+
}
|
|
9011
|
+
}
|
|
9012
|
+
return diff;
|
|
9013
|
+
}
|
|
9014
|
+
function morphNode(domNode, source, target, opts) {
|
|
9015
|
+
if (source === target || source.isEqualTo(target))
|
|
9016
|
+
return domNode;
|
|
9017
|
+
const type3 = source.nodeType;
|
|
9018
|
+
if (type3 === target.nodeType) {
|
|
9019
|
+
if (type3 === 3 || type3 === 8) {
|
|
9020
|
+
domNode.data = target.text;
|
|
9021
|
+
return domNode;
|
|
9022
|
+
}
|
|
9023
|
+
if (type3 === 1 && source.isSameKind(target)) {
|
|
9024
|
+
const propsDiff = diffProps(source.attrs, target.attrs);
|
|
9025
|
+
const isSelect = source.tag === "SELECT";
|
|
9026
|
+
if (propsDiff) {
|
|
9027
|
+
if (isSelect && "value" in propsDiff) {
|
|
9028
|
+
const { value: _v, ...rest } = propsDiff;
|
|
9029
|
+
applyProperties(domNode, rest, source.attrs);
|
|
9030
|
+
} else
|
|
9031
|
+
applyProperties(domNode, propsDiff, source.attrs);
|
|
9032
|
+
}
|
|
9033
|
+
if (!target.attrs.dangerouslySetInnerHTML)
|
|
9034
|
+
morphChildren(domNode, source.childs, target.childs, opts);
|
|
9035
|
+
if (isSelect && target.attrs.value !== undefined)
|
|
9036
|
+
applyProperties(domNode, { value: target.attrs.value }, source.attrs);
|
|
9037
|
+
return domNode;
|
|
9038
|
+
}
|
|
9039
|
+
if (type3 === 11) {
|
|
9040
|
+
morphChildren(domNode, source.childs, target.childs, opts);
|
|
9041
|
+
return domNode;
|
|
9042
|
+
}
|
|
9043
|
+
}
|
|
9044
|
+
const newNode = target.toDom(opts);
|
|
9045
|
+
domNode.parentNode?.replaceChild(newNode, domNode);
|
|
9046
|
+
return newNode;
|
|
9047
|
+
}
|
|
9048
|
+
function morphChildren(parentDom, oldChilds, newChilds, opts) {
|
|
9049
|
+
if (oldChilds.length === 0) {
|
|
9050
|
+
appendChildNodes(parentDom, newChilds, opts);
|
|
9051
|
+
return;
|
|
9052
|
+
}
|
|
9053
|
+
if (newChilds.length === 0) {
|
|
9054
|
+
parentDom.replaceChildren();
|
|
9055
|
+
return;
|
|
9056
|
+
}
|
|
9057
|
+
if (oldChilds.length === newChilds.length) {
|
|
9058
|
+
let hasKey = false;
|
|
9059
|
+
for (let i = 0;i < oldChilds.length; i++) {
|
|
9060
|
+
if (getKey(oldChilds[i]) != null || getKey(newChilds[i]) != null) {
|
|
9061
|
+
hasKey = true;
|
|
9062
|
+
break;
|
|
9063
|
+
}
|
|
9064
|
+
}
|
|
9065
|
+
if (!hasKey) {
|
|
9066
|
+
let dom = parentDom.firstChild;
|
|
9067
|
+
for (let i = 0;i < oldChilds.length; i++) {
|
|
9068
|
+
const next = dom.nextSibling;
|
|
9069
|
+
morphNode(dom, oldChilds[i], newChilds[i], opts);
|
|
9070
|
+
dom = next;
|
|
9071
|
+
}
|
|
9072
|
+
return;
|
|
9073
|
+
}
|
|
9074
|
+
}
|
|
9075
|
+
const domNodes = Array.from(parentDom.childNodes);
|
|
9076
|
+
const oldKeyMap = Object.create(null);
|
|
9077
|
+
for (let i = 0;i < oldChilds.length; i++) {
|
|
9078
|
+
const key = getKey(oldChilds[i]);
|
|
9079
|
+
if (key != null)
|
|
9080
|
+
oldKeyMap[key] = i;
|
|
9081
|
+
}
|
|
9082
|
+
const used2 = new Uint8Array(oldChilds.length);
|
|
9083
|
+
let unkeyedCursor = 0;
|
|
9084
|
+
for (let j = 0;j < newChilds.length; j++) {
|
|
9085
|
+
const newChild = newChilds[j];
|
|
9086
|
+
const newKey = getKey(newChild);
|
|
9087
|
+
let oldIdx = -1;
|
|
9088
|
+
if (newKey != null) {
|
|
9089
|
+
if (newKey in oldKeyMap && !used2[oldKeyMap[newKey]])
|
|
9090
|
+
oldIdx = oldKeyMap[newKey];
|
|
9091
|
+
} else {
|
|
9092
|
+
while (unkeyedCursor < oldChilds.length) {
|
|
9093
|
+
if (!used2[unkeyedCursor] && getKey(oldChilds[unkeyedCursor]) == null) {
|
|
9094
|
+
oldIdx = unkeyedCursor++;
|
|
9095
|
+
break;
|
|
9096
|
+
}
|
|
9097
|
+
unkeyedCursor++;
|
|
9098
|
+
}
|
|
9099
|
+
}
|
|
9100
|
+
if (oldIdx >= 0) {
|
|
9101
|
+
used2[oldIdx] = 1;
|
|
9102
|
+
const newDom = morphNode(domNodes[oldIdx], oldChilds[oldIdx], newChild, opts);
|
|
9103
|
+
const ref = parentDom.childNodes[j] ?? null;
|
|
9104
|
+
if (newDom !== ref)
|
|
9105
|
+
parentDom.insertBefore(newDom, ref);
|
|
9106
|
+
} else {
|
|
9107
|
+
const ref = parentDom.childNodes[j] ?? null;
|
|
9108
|
+
parentDom.insertBefore(newChild.toDom(opts), ref);
|
|
9109
|
+
}
|
|
9110
|
+
}
|
|
9111
|
+
for (let i = oldChilds.length - 1;i >= 0; i--)
|
|
9112
|
+
if (!used2[i] && domNodes[i].parentNode === parentDom)
|
|
9113
|
+
parentDom.removeChild(domNodes[i]);
|
|
9114
|
+
}
|
|
9115
|
+
function render(vnode, container, options, prev) {
|
|
9116
|
+
const isFragment = vnode instanceof VFragment;
|
|
9117
|
+
if (prev && prev.vnode instanceof VFragment === isFragment) {
|
|
9118
|
+
const oldDom = isFragment ? container : prev.dom;
|
|
9119
|
+
const newDom = morphNode(oldDom, prev.vnode, vnode, options);
|
|
9120
|
+
return { vnode, dom: isFragment ? container : newDom };
|
|
9121
|
+
}
|
|
9122
|
+
const domNode = vnode.toDom(options);
|
|
9123
|
+
container.replaceChildren(domNode);
|
|
9124
|
+
return { vnode, dom: isFragment ? container : domNode };
|
|
9125
|
+
}
|
|
9126
|
+
function h(tagName, properties, children, namespace) {
|
|
9127
|
+
const props = {};
|
|
9128
|
+
let key;
|
|
9129
|
+
if (properties) {
|
|
9130
|
+
for (const propName in properties) {
|
|
9131
|
+
const propVal = properties[propName];
|
|
9132
|
+
switch (propName) {
|
|
9133
|
+
case "key":
|
|
9134
|
+
key = propVal;
|
|
9135
|
+
break;
|
|
9136
|
+
case "namespace":
|
|
9137
|
+
namespace = namespace ?? propVal;
|
|
9138
|
+
break;
|
|
9139
|
+
case "class":
|
|
9140
|
+
props.className = propVal;
|
|
9141
|
+
break;
|
|
9142
|
+
case "for":
|
|
9143
|
+
props.htmlFor = propVal;
|
|
9144
|
+
break;
|
|
9145
|
+
default:
|
|
9146
|
+
props[propName] = isHtmlAttribute(propName) ? String(propVal) : propVal;
|
|
9147
|
+
}
|
|
9148
|
+
}
|
|
9149
|
+
}
|
|
9150
|
+
const c = tagName.charCodeAt(0);
|
|
9151
|
+
const tag = namespace == null && c >= 97 && c <= 122 ? tagName.toUpperCase() : tagName;
|
|
9152
|
+
const normalizedChildren = [];
|
|
9153
|
+
addChild(normalizedChildren, children);
|
|
9154
|
+
return new VNode2(tag, props, normalizedChildren, key, namespace);
|
|
9155
|
+
}
|
|
9156
|
+
|
|
9157
|
+
// src/anode.js
|
|
9158
|
+
function resolveDynProducer(comp, dynName) {
|
|
9159
|
+
const dyn = comp?.dynamic?.[dynName];
|
|
9160
|
+
if (dyn == null)
|
|
9161
|
+
return null;
|
|
9162
|
+
let producerComp, producerDyn;
|
|
9163
|
+
if (dyn.compName != null) {
|
|
9164
|
+
producerComp = comp.scope?.lookupComponent(dyn.compName);
|
|
9165
|
+
producerDyn = producerComp?.dynamic?.[dyn.dynName];
|
|
9166
|
+
} else {
|
|
9167
|
+
producerComp = comp;
|
|
9168
|
+
producerDyn = dyn;
|
|
9169
|
+
}
|
|
9170
|
+
if (producerComp == null || producerDyn == null)
|
|
9171
|
+
return null;
|
|
9172
|
+
const pi = producerDyn.val?.toPathItem?.() ?? null;
|
|
9173
|
+
return { producerCompId: producerComp.id, producerSteps: pi ? [pi] : [] };
|
|
9174
|
+
}
|
|
9175
|
+
|
|
9176
|
+
class BaseNode {
|
|
9177
|
+
render(_stack, _rx) {
|
|
9178
|
+
return null;
|
|
9179
|
+
}
|
|
9180
|
+
setDataAttr(key, val) {
|
|
9181
|
+
console.warn("setDataAttr not implemented for", this, { key, val });
|
|
9182
|
+
}
|
|
9183
|
+
isConstant() {
|
|
9184
|
+
return false;
|
|
9185
|
+
}
|
|
9186
|
+
optimize() {}
|
|
9187
|
+
}
|
|
9188
|
+
|
|
9189
|
+
class TextNode extends BaseNode {
|
|
9190
|
+
constructor(val) {
|
|
9191
|
+
super();
|
|
9192
|
+
this.val = val;
|
|
9193
|
+
}
|
|
9194
|
+
render(_stack, _rx) {
|
|
9195
|
+
return this.val;
|
|
9196
|
+
}
|
|
9197
|
+
isWhiteSpace() {
|
|
9198
|
+
for (let i = 0;i < this.val.length; i++) {
|
|
9199
|
+
const c = this.val.charCodeAt(i);
|
|
9200
|
+
if (!(c === 32 || c === 10 || c === 9 || c === 13))
|
|
9201
|
+
return false;
|
|
9202
|
+
}
|
|
9203
|
+
return true;
|
|
9204
|
+
}
|
|
9205
|
+
hasNewLine() {
|
|
9206
|
+
for (let i = 0;i < this.val.length; i++) {
|
|
9207
|
+
const c = this.val.charCodeAt(i);
|
|
9208
|
+
if (c === 10 || c === 13)
|
|
9209
|
+
return true;
|
|
9210
|
+
}
|
|
9211
|
+
return false;
|
|
9212
|
+
}
|
|
9213
|
+
condenseWhiteSpace(replacement = "") {
|
|
9214
|
+
this.val = replacement;
|
|
9215
|
+
}
|
|
9216
|
+
isConstant() {
|
|
9217
|
+
return true;
|
|
9218
|
+
}
|
|
9219
|
+
setDataAttr(_key, _val) {}
|
|
9220
|
+
}
|
|
9221
|
+
|
|
9222
|
+
class CommentNode extends TextNode {
|
|
9223
|
+
render(_stack, rx) {
|
|
9224
|
+
return rx.renderComment(this.val);
|
|
9225
|
+
}
|
|
9226
|
+
}
|
|
9227
|
+
function optimizeChilds(childs) {
|
|
9228
|
+
for (let i = 0;i < childs.length; i++) {
|
|
9229
|
+
const child = childs[i];
|
|
9230
|
+
if (child.isConstant())
|
|
9231
|
+
childs[i] = new RenderOnceNode(child);
|
|
9232
|
+
else
|
|
9233
|
+
child.optimize();
|
|
9234
|
+
}
|
|
9235
|
+
}
|
|
9236
|
+
function optimizeNode(node) {
|
|
9237
|
+
if (node.isConstant())
|
|
9238
|
+
return new RenderOnceNode(node);
|
|
9239
|
+
node.optimize();
|
|
9240
|
+
return node;
|
|
9241
|
+
}
|
|
9242
|
+
|
|
9243
|
+
class ChildsNode extends BaseNode {
|
|
9244
|
+
constructor(childs) {
|
|
9245
|
+
super();
|
|
9246
|
+
this.childs = childs;
|
|
9247
|
+
}
|
|
9248
|
+
isConstant() {
|
|
9249
|
+
return this.childs.every((v) => v.isConstant());
|
|
9250
|
+
}
|
|
9251
|
+
optimize() {
|
|
9252
|
+
optimizeChilds(this.childs);
|
|
9253
|
+
}
|
|
9254
|
+
}
|
|
9255
|
+
|
|
9256
|
+
class DomNode extends ChildsNode {
|
|
9257
|
+
constructor(tagName, attrs, childs, namespace = null) {
|
|
9258
|
+
super(childs);
|
|
9259
|
+
this.tagName = tagName;
|
|
9260
|
+
this.attrs = attrs;
|
|
9261
|
+
this.namespace = namespace;
|
|
9262
|
+
}
|
|
9263
|
+
render(stack, rx) {
|
|
9264
|
+
const childNodes = new Array(this.childs.length);
|
|
9265
|
+
for (let i = 0;i < childNodes.length; i++)
|
|
9266
|
+
childNodes[i] = this.childs[i]?.render?.(stack, rx) ?? null;
|
|
9267
|
+
return rx.renderTag(this.tagName, this.attrs.eval(stack), childNodes, this.namespace);
|
|
9268
|
+
}
|
|
9269
|
+
setDataAttr(key, val) {
|
|
9270
|
+
this.attrs.setDataAttr(key, val);
|
|
9271
|
+
}
|
|
9272
|
+
isConstant() {
|
|
9273
|
+
return this.attrs.isConstant() && super.isConstant();
|
|
9274
|
+
}
|
|
9275
|
+
}
|
|
9276
|
+
|
|
9277
|
+
class FragmentNode extends ChildsNode {
|
|
9278
|
+
render(stack, rx) {
|
|
9279
|
+
return rx.renderFragment(this.childs.map((c) => c?.render(stack, rx)));
|
|
9280
|
+
}
|
|
9281
|
+
setDataAttr(key, val) {
|
|
9282
|
+
for (const child of this.childs)
|
|
9283
|
+
child.setDataAttr(key, val);
|
|
9284
|
+
}
|
|
9285
|
+
}
|
|
9286
|
+
var maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs);
|
|
9287
|
+
var VALID_NODE_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/;
|
|
9288
|
+
|
|
9289
|
+
class ANode extends BaseNode {
|
|
9290
|
+
constructor(nodeId, val) {
|
|
9291
|
+
super();
|
|
9292
|
+
this.nodeId = nodeId;
|
|
9293
|
+
this.val = val;
|
|
9294
|
+
}
|
|
9295
|
+
toPathStep(ctx) {
|
|
9296
|
+
return ctx.applyKey(this.val?.toPathItem?.() ?? null);
|
|
9297
|
+
}
|
|
9298
|
+
static parse(html, px) {
|
|
9299
|
+
const nodes = px.parseHTML(html);
|
|
9300
|
+
if (nodes.length === 0)
|
|
9301
|
+
return new CommentNode("Empty View in ANode.parse");
|
|
9302
|
+
if (nodes.length === 1)
|
|
9303
|
+
return ANode.fromDOM(nodes[0], px);
|
|
9304
|
+
const childs = [];
|
|
9305
|
+
for (let i = 0;i < nodes.length; i++) {
|
|
9306
|
+
const child = ANode.fromDOM(nodes[i], px);
|
|
9307
|
+
if (child !== null)
|
|
9308
|
+
childs.push(child);
|
|
9309
|
+
}
|
|
9310
|
+
const trimmed = condenseChildsWhites(childs);
|
|
9311
|
+
if (trimmed.length === 0)
|
|
9312
|
+
return new CommentNode("Empty View in ANode.parse");
|
|
9313
|
+
return maybeFragment(trimmed);
|
|
9314
|
+
}
|
|
9315
|
+
static fromDOM(node, px) {
|
|
9316
|
+
if (node instanceof px.Text)
|
|
9317
|
+
return new TextNode(node.textContent);
|
|
9318
|
+
else if (node instanceof px.Comment)
|
|
9319
|
+
return new CommentNode(node.textContent);
|
|
9320
|
+
const { childNodes, attributes: attrs, tagName: tag } = node;
|
|
9321
|
+
const childs = [];
|
|
9322
|
+
for (let i = 0;i < childNodes.length; i++) {
|
|
9323
|
+
const child = ANode.fromDOM(childNodes[i], px);
|
|
9324
|
+
if (child !== null)
|
|
9325
|
+
childs.push(child);
|
|
9326
|
+
}
|
|
9327
|
+
const prevTag = px.currentTag;
|
|
9328
|
+
px.currentTag = tag;
|
|
9329
|
+
try {
|
|
9330
|
+
const isPseudoX = attrs[0]?.name === "@x";
|
|
9331
|
+
if (tag === "X" || isPseudoX)
|
|
9332
|
+
return parseXOp(attrs, childs, isPseudoX ? 1 : 0, px);
|
|
9333
|
+
else if (tag.charCodeAt(1) === 58 && tag.charCodeAt(0) === 88) {
|
|
9334
|
+
const macroName = tag.slice(2).toLowerCase();
|
|
9335
|
+
if (macroName === "slot") {
|
|
9336
|
+
const slotName = attrs.getNamedItem("name")?.value ?? "_";
|
|
9337
|
+
return px.frame.macroSlots[slotName] ?? maybeFragment(childs);
|
|
9338
|
+
}
|
|
9339
|
+
const [nAttrs, wrappers] = Attributes.parse(attrs, px, true);
|
|
9340
|
+
px.onAttributes(nAttrs, wrappers, null, true, tag);
|
|
9341
|
+
return wrap(px.newMacroNode(macroName, nAttrs.toMacroVars(), childs), px, wrappers);
|
|
9342
|
+
} else if (VALID_NODE_RE.test(tag)) {
|
|
9005
9343
|
const [nAttrs, wrappers, textChild] = Attributes.parse(attrs, px);
|
|
9006
9344
|
px.onAttributes(nAttrs, wrappers, textChild, false, tag);
|
|
9007
9345
|
if (textChild)
|
|
9008
9346
|
childs.unshift(new RenderTextNode(null, textChild));
|
|
9009
9347
|
const domChilds = tag !== "PRE" ? condenseChildsWhites(childs) : childs;
|
|
9010
|
-
|
|
9348
|
+
const ns = node.namespaceURI;
|
|
9349
|
+
const namespace = ns && ns !== HTML_NS ? ns : null;
|
|
9350
|
+
return wrap(new DomNode(tag, nAttrs, domChilds, namespace), px, wrappers);
|
|
9011
9351
|
}
|
|
9012
9352
|
return new CommentNode(`Error: InvalidTagName ${tag}`);
|
|
9013
9353
|
} finally {
|
|
@@ -13734,418 +14074,93 @@ class BubbleEvent extends SendEvent {
|
|
|
13734
14074
|
super(path, transactor, name, args, parent, opts);
|
|
13735
14075
|
this.targetPath = targetPath ?? path;
|
|
13736
14076
|
}
|
|
13737
|
-
stopPropagation() {
|
|
13738
|
-
this.opts.bubbles = false;
|
|
13739
|
-
}
|
|
13740
|
-
}
|
|
13741
|
-
|
|
13742
|
-
class Task {
|
|
13743
|
-
constructor() {
|
|
13744
|
-
this.deps = [];
|
|
13745
|
-
this.val = this.resolve = this.reject = null;
|
|
13746
|
-
this.promise = new Promise((res, rej) => {
|
|
13747
|
-
this.resolve = res;
|
|
13748
|
-
this.reject = rej;
|
|
13749
|
-
});
|
|
13750
|
-
this.isCompleted = false;
|
|
13751
|
-
}
|
|
13752
|
-
addDep(task) {
|
|
13753
|
-
console.assert(!this.isCompleted, "addDep for completed task", this, task);
|
|
13754
|
-
this.deps.push(task);
|
|
13755
|
-
task.promise.then((_) => this._check());
|
|
13756
|
-
}
|
|
13757
|
-
complete(val) {
|
|
13758
|
-
this.val = val;
|
|
13759
|
-
this._check();
|
|
13760
|
-
}
|
|
13761
|
-
_check() {
|
|
13762
|
-
if (this.deps.every((task) => task.isCompleted)) {
|
|
13763
|
-
this.isCompleted = true;
|
|
13764
|
-
this.resolve(this);
|
|
13765
|
-
}
|
|
13766
|
-
}
|
|
13767
|
-
}
|
|
13768
|
-
|
|
13769
|
-
class Dispatcher {
|
|
13770
|
-
constructor(path, transactor, parentTransaction) {
|
|
13771
|
-
this.path = path;
|
|
13772
|
-
this.transactor = transactor;
|
|
13773
|
-
this.parent = parentTransaction;
|
|
13774
|
-
}
|
|
13775
|
-
get at() {
|
|
13776
|
-
return new PathChanges(this);
|
|
13777
|
-
}
|
|
13778
|
-
send(name, args, opts) {
|
|
13779
|
-
return this.sendAtPath(this.path, name, args, opts);
|
|
13780
|
-
}
|
|
13781
|
-
bubble(name, args, opts) {
|
|
13782
|
-
return this.send(name, args, { skipSelf: true, bubbles: true, ...opts });
|
|
13783
|
-
}
|
|
13784
|
-
sendAtPath(path, name, args, opts) {
|
|
13785
|
-
return this.transactor.pushSend(path, name, args, opts, this.parent);
|
|
13786
|
-
}
|
|
13787
|
-
request(name, args, opts) {
|
|
13788
|
-
return this.requestAtPath(this.path, name, args, opts);
|
|
13789
|
-
}
|
|
13790
|
-
requestAtPath(path, name, args, opts) {
|
|
13791
|
-
return this.transactor.pushRequest(path, name, args, opts, this.parent);
|
|
13792
|
-
}
|
|
13793
|
-
lookupTypeFor(name, inst) {
|
|
13794
|
-
return this.transactor.comps.getCompFor(inst).scope.lookupComponent(name);
|
|
13795
|
-
}
|
|
13796
|
-
}
|
|
13797
|
-
|
|
13798
|
-
class EventContext extends Dispatcher {
|
|
13799
|
-
get name() {
|
|
13800
|
-
return this.parent?.name ?? null;
|
|
13801
|
-
}
|
|
13802
|
-
get targetPath() {
|
|
13803
|
-
return this.parent.targetPath;
|
|
13804
|
-
}
|
|
13805
|
-
stopPropagation() {
|
|
13806
|
-
return this.parent.stopPropagation();
|
|
13807
|
-
}
|
|
13808
|
-
}
|
|
13809
|
-
|
|
13810
|
-
class PathChanges extends PathBuilder {
|
|
13811
|
-
constructor(dispatcher) {
|
|
13812
|
-
super();
|
|
13813
|
-
this.dispatcher = dispatcher;
|
|
13814
|
-
}
|
|
13815
|
-
send(name, args, opts) {
|
|
13816
|
-
return this.dispatcher.sendAtPath(this.buildPath(), name, args, opts);
|
|
13817
|
-
}
|
|
13818
|
-
bubble(name, args, opts) {
|
|
13819
|
-
return this.send(name, args, { skipSelf: true, bubbles: true, ...opts });
|
|
13820
|
-
}
|
|
13821
|
-
buildPath() {
|
|
13822
|
-
return this.dispatcher.path.concat(this.pathChanges);
|
|
13823
|
-
}
|
|
13824
|
-
}
|
|
13825
|
-
|
|
13826
|
-
// src/vdom.js
|
|
13827
|
-
var isHtmlAttribute = (propName) => propName[4] === "-" && (propName[0] === "d" || propName[0] === "a");
|
|
13828
|
-
function applyProperties(node, props, previous) {
|
|
13829
|
-
for (const propName in props) {
|
|
13830
|
-
const propValue = props[propName];
|
|
13831
|
-
if (propValue === undefined)
|
|
13832
|
-
removeProperty(node, propName, previous);
|
|
13833
|
-
else if (isHtmlAttribute(propName))
|
|
13834
|
-
node.setAttribute(propName, propValue);
|
|
13835
|
-
else if (propName === "dangerouslySetInnerHTML")
|
|
13836
|
-
node.innerHTML = propValue.__html ?? "";
|
|
13837
|
-
else if (propName === "className")
|
|
13838
|
-
node.setAttribute("class", propValue);
|
|
13839
|
-
else
|
|
13840
|
-
node[propName] = propValue;
|
|
13841
|
-
}
|
|
13842
|
-
}
|
|
13843
|
-
function removeProperty(node, propName, previous) {
|
|
13844
|
-
const previousValue = previous[propName];
|
|
13845
|
-
if (propName === "dangerouslySetInnerHTML")
|
|
13846
|
-
node.replaceChildren();
|
|
13847
|
-
else if (propName === "className")
|
|
13848
|
-
node.removeAttribute("class");
|
|
13849
|
-
else if (propName === "htmlFor")
|
|
13850
|
-
node.removeAttribute("for");
|
|
13851
|
-
else if (typeof previousValue === "string" || isHtmlAttribute(propName))
|
|
13852
|
-
node.removeAttribute(propName);
|
|
13853
|
-
else
|
|
13854
|
-
node[propName] = null;
|
|
13855
|
-
}
|
|
13856
|
-
|
|
13857
|
-
class VBase {
|
|
13858
|
-
}
|
|
13859
|
-
var getKey = (child) => child instanceof VNode2 ? child.key : undefined;
|
|
13860
|
-
var isIterable = (obj) => obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function";
|
|
13861
|
-
function childsEqual(a, b) {
|
|
13862
|
-
if (a === b)
|
|
13863
|
-
return true;
|
|
13864
|
-
for (let i = 0;i < a.length; i++)
|
|
13865
|
-
if (!a[i].isEqualTo(b[i]))
|
|
13866
|
-
return false;
|
|
13867
|
-
return true;
|
|
13868
|
-
}
|
|
13869
|
-
function appendChildNodes(parent, childs, opts) {
|
|
13870
|
-
for (const child of childs)
|
|
13871
|
-
parent.appendChild(child.toDom(opts));
|
|
13872
|
-
}
|
|
13873
|
-
function addChild(normalizedChildren, child) {
|
|
13874
|
-
if (child == null)
|
|
13875
|
-
return;
|
|
13876
|
-
if (isIterable(child)) {
|
|
13877
|
-
for (const c of child)
|
|
13878
|
-
addChild(normalizedChildren, c);
|
|
13879
|
-
} else if (child instanceof VBase) {
|
|
13880
|
-
if (child instanceof VFragment)
|
|
13881
|
-
normalizedChildren.push(...child.childs);
|
|
13882
|
-
else
|
|
13883
|
-
normalizedChildren.push(child);
|
|
13884
|
-
} else
|
|
13885
|
-
normalizedChildren.push(new VText(child));
|
|
13886
|
-
}
|
|
13887
|
-
|
|
13888
|
-
class VText extends VBase {
|
|
13889
|
-
constructor(text) {
|
|
13890
|
-
super();
|
|
13891
|
-
this.text = String(text);
|
|
13892
|
-
}
|
|
13893
|
-
get nodeType() {
|
|
13894
|
-
return 3;
|
|
13895
|
-
}
|
|
13896
|
-
isEqualTo(other) {
|
|
13897
|
-
return other instanceof VText && this.text === other.text;
|
|
13898
|
-
}
|
|
13899
|
-
toDom(opts) {
|
|
13900
|
-
return opts.document.createTextNode(this.text);
|
|
13901
|
-
}
|
|
13902
|
-
}
|
|
13903
|
-
|
|
13904
|
-
class VComment extends VBase {
|
|
13905
|
-
constructor(text) {
|
|
13906
|
-
super();
|
|
13907
|
-
this.text = text;
|
|
13908
|
-
}
|
|
13909
|
-
get nodeType() {
|
|
13910
|
-
return 8;
|
|
13911
|
-
}
|
|
13912
|
-
isEqualTo(other) {
|
|
13913
|
-
return other instanceof VComment && this.text === other.text;
|
|
13914
|
-
}
|
|
13915
|
-
toDom(opts) {
|
|
13916
|
-
return opts.document.createComment(this.text);
|
|
13917
|
-
}
|
|
13918
|
-
}
|
|
13919
|
-
|
|
13920
|
-
class VFragment extends VBase {
|
|
13921
|
-
constructor(childs) {
|
|
13922
|
-
super();
|
|
13923
|
-
this.childs = [];
|
|
13924
|
-
addChild(this.childs, childs);
|
|
13925
|
-
}
|
|
13926
|
-
get nodeType() {
|
|
13927
|
-
return 11;
|
|
13928
|
-
}
|
|
13929
|
-
isEqualTo(other) {
|
|
13930
|
-
if (!(other instanceof VFragment) || this.childs.length !== other.childs.length)
|
|
13931
|
-
return false;
|
|
13932
|
-
return childsEqual(this.childs, other.childs);
|
|
13933
|
-
}
|
|
13934
|
-
toDom(opts) {
|
|
13935
|
-
const fragment = opts.document.createDocumentFragment();
|
|
13936
|
-
appendChildNodes(fragment, this.childs, opts);
|
|
13937
|
-
return fragment;
|
|
14077
|
+
stopPropagation() {
|
|
14078
|
+
this.opts.bubbles = false;
|
|
13938
14079
|
}
|
|
13939
14080
|
}
|
|
13940
14081
|
|
|
13941
|
-
class
|
|
13942
|
-
constructor(
|
|
13943
|
-
|
|
13944
|
-
this.
|
|
13945
|
-
this.
|
|
13946
|
-
|
|
13947
|
-
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
get nodeType() {
|
|
13951
|
-
return 1;
|
|
14082
|
+
class Task {
|
|
14083
|
+
constructor() {
|
|
14084
|
+
this.deps = [];
|
|
14085
|
+
this.val = this.resolve = this.reject = null;
|
|
14086
|
+
this.promise = new Promise((res, rej) => {
|
|
14087
|
+
this.resolve = res;
|
|
14088
|
+
this.reject = rej;
|
|
14089
|
+
});
|
|
14090
|
+
this.isCompleted = false;
|
|
13952
14091
|
}
|
|
13953
|
-
|
|
13954
|
-
|
|
14092
|
+
addDep(task) {
|
|
14093
|
+
console.assert(!this.isCompleted, "addDep for completed task", this, task);
|
|
14094
|
+
this.deps.push(task);
|
|
14095
|
+
task.promise.then((_) => this._check());
|
|
13955
14096
|
}
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
if (!(other instanceof VNode2) || !this.isSameKind(other) || this.childs.length !== other.childs.length) {
|
|
13960
|
-
return false;
|
|
13961
|
-
}
|
|
13962
|
-
if (this.attrs !== other.attrs) {
|
|
13963
|
-
for (const key in this.attrs)
|
|
13964
|
-
if (this.attrs[key] !== other.attrs[key])
|
|
13965
|
-
return false;
|
|
13966
|
-
for (const key in other.attrs)
|
|
13967
|
-
if (!Object.hasOwn(this.attrs, key))
|
|
13968
|
-
return false;
|
|
13969
|
-
}
|
|
13970
|
-
return childsEqual(this.childs, other.childs);
|
|
14097
|
+
complete(val) {
|
|
14098
|
+
this.val = val;
|
|
14099
|
+
this._check();
|
|
13971
14100
|
}
|
|
13972
|
-
|
|
13973
|
-
|
|
13974
|
-
|
|
13975
|
-
|
|
13976
|
-
const { value, ...rest } = this.attrs;
|
|
13977
|
-
applyProperties(node, rest, {});
|
|
13978
|
-
appendChildNodes(node, this.childs, opts);
|
|
13979
|
-
applyProperties(node, { value }, {});
|
|
13980
|
-
} else {
|
|
13981
|
-
applyProperties(node, this.attrs, {});
|
|
13982
|
-
appendChildNodes(node, this.childs, opts);
|
|
14101
|
+
_check() {
|
|
14102
|
+
if (this.deps.every((task) => task.isCompleted)) {
|
|
14103
|
+
this.isCompleted = true;
|
|
14104
|
+
this.resolve(this);
|
|
13983
14105
|
}
|
|
13984
|
-
return node;
|
|
13985
14106
|
}
|
|
13986
14107
|
}
|
|
13987
|
-
|
|
13988
|
-
|
|
13989
|
-
|
|
13990
|
-
|
|
13991
|
-
|
|
13992
|
-
|
|
13993
|
-
diff ??= {};
|
|
13994
|
-
diff[aKey] = undefined;
|
|
13995
|
-
} else if (a[aKey] !== b[aKey]) {
|
|
13996
|
-
diff ??= {};
|
|
13997
|
-
diff[aKey] = b[aKey];
|
|
13998
|
-
}
|
|
14108
|
+
|
|
14109
|
+
class Dispatcher {
|
|
14110
|
+
constructor(path, transactor, parentTransaction) {
|
|
14111
|
+
this.path = path;
|
|
14112
|
+
this.transactor = transactor;
|
|
14113
|
+
this.parent = parentTransaction;
|
|
13999
14114
|
}
|
|
14000
|
-
|
|
14001
|
-
|
|
14002
|
-
diff ??= {};
|
|
14003
|
-
diff[bKey] = b[bKey];
|
|
14004
|
-
}
|
|
14115
|
+
get at() {
|
|
14116
|
+
return new PathChanges(this);
|
|
14005
14117
|
}
|
|
14006
|
-
|
|
14007
|
-
|
|
14008
|
-
function morphNode(domNode, source, target, opts) {
|
|
14009
|
-
if (source === target || source.isEqualTo(target))
|
|
14010
|
-
return domNode;
|
|
14011
|
-
const type3 = source.nodeType;
|
|
14012
|
-
if (type3 === target.nodeType) {
|
|
14013
|
-
if (type3 === 3 || type3 === 8) {
|
|
14014
|
-
domNode.data = target.text;
|
|
14015
|
-
return domNode;
|
|
14016
|
-
}
|
|
14017
|
-
if (type3 === 1 && source.isSameKind(target)) {
|
|
14018
|
-
const propsDiff = diffProps(source.attrs, target.attrs);
|
|
14019
|
-
const isSelect = source.tag === "SELECT";
|
|
14020
|
-
if (propsDiff) {
|
|
14021
|
-
if (isSelect && "value" in propsDiff) {
|
|
14022
|
-
const { value: _v, ...rest } = propsDiff;
|
|
14023
|
-
applyProperties(domNode, rest, source.attrs);
|
|
14024
|
-
} else
|
|
14025
|
-
applyProperties(domNode, propsDiff, source.attrs);
|
|
14026
|
-
}
|
|
14027
|
-
if (!target.attrs.dangerouslySetInnerHTML)
|
|
14028
|
-
morphChildren(domNode, source.childs, target.childs, opts);
|
|
14029
|
-
if (isSelect && target.attrs.value !== undefined)
|
|
14030
|
-
applyProperties(domNode, { value: target.attrs.value }, source.attrs);
|
|
14031
|
-
return domNode;
|
|
14032
|
-
}
|
|
14033
|
-
if (type3 === 11) {
|
|
14034
|
-
morphChildren(domNode, source.childs, target.childs, opts);
|
|
14035
|
-
return domNode;
|
|
14036
|
-
}
|
|
14118
|
+
send(name, args, opts) {
|
|
14119
|
+
return this.sendAtPath(this.path, name, args, opts);
|
|
14037
14120
|
}
|
|
14038
|
-
|
|
14039
|
-
|
|
14040
|
-
return newNode;
|
|
14041
|
-
}
|
|
14042
|
-
function morphChildren(parentDom, oldChilds, newChilds, opts) {
|
|
14043
|
-
if (oldChilds.length === 0) {
|
|
14044
|
-
appendChildNodes(parentDom, newChilds, opts);
|
|
14045
|
-
return;
|
|
14121
|
+
bubble(name, args, opts) {
|
|
14122
|
+
return this.send(name, args, { skipSelf: true, bubbles: true, ...opts });
|
|
14046
14123
|
}
|
|
14047
|
-
|
|
14048
|
-
|
|
14049
|
-
return;
|
|
14124
|
+
sendAtPath(path, name, args, opts) {
|
|
14125
|
+
return this.transactor.pushSend(path, name, args, opts, this.parent);
|
|
14050
14126
|
}
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
for (let i = 0;i < oldChilds.length; i++) {
|
|
14054
|
-
if (getKey(oldChilds[i]) != null || getKey(newChilds[i]) != null) {
|
|
14055
|
-
hasKey = true;
|
|
14056
|
-
break;
|
|
14057
|
-
}
|
|
14058
|
-
}
|
|
14059
|
-
if (!hasKey) {
|
|
14060
|
-
let dom = parentDom.firstChild;
|
|
14061
|
-
for (let i = 0;i < oldChilds.length; i++) {
|
|
14062
|
-
const next = dom.nextSibling;
|
|
14063
|
-
morphNode(dom, oldChilds[i], newChilds[i], opts);
|
|
14064
|
-
dom = next;
|
|
14065
|
-
}
|
|
14066
|
-
return;
|
|
14067
|
-
}
|
|
14127
|
+
request(name, args, opts) {
|
|
14128
|
+
return this.requestAtPath(this.path, name, args, opts);
|
|
14068
14129
|
}
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
for (let i = 0;i < oldChilds.length; i++) {
|
|
14072
|
-
const key = getKey(oldChilds[i]);
|
|
14073
|
-
if (key != null)
|
|
14074
|
-
oldKeyMap[key] = i;
|
|
14130
|
+
requestAtPath(path, name, args, opts) {
|
|
14131
|
+
return this.transactor.pushRequest(path, name, args, opts, this.parent);
|
|
14075
14132
|
}
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
for (let j = 0;j < newChilds.length; j++) {
|
|
14079
|
-
const newChild = newChilds[j];
|
|
14080
|
-
const newKey = getKey(newChild);
|
|
14081
|
-
let oldIdx = -1;
|
|
14082
|
-
if (newKey != null) {
|
|
14083
|
-
if (newKey in oldKeyMap && !used2[oldKeyMap[newKey]])
|
|
14084
|
-
oldIdx = oldKeyMap[newKey];
|
|
14085
|
-
} else {
|
|
14086
|
-
while (unkeyedCursor < oldChilds.length) {
|
|
14087
|
-
if (!used2[unkeyedCursor] && getKey(oldChilds[unkeyedCursor]) == null) {
|
|
14088
|
-
oldIdx = unkeyedCursor++;
|
|
14089
|
-
break;
|
|
14090
|
-
}
|
|
14091
|
-
unkeyedCursor++;
|
|
14092
|
-
}
|
|
14093
|
-
}
|
|
14094
|
-
if (oldIdx >= 0) {
|
|
14095
|
-
used2[oldIdx] = 1;
|
|
14096
|
-
const newDom = morphNode(domNodes[oldIdx], oldChilds[oldIdx], newChild, opts);
|
|
14097
|
-
const ref = parentDom.childNodes[j] ?? null;
|
|
14098
|
-
if (newDom !== ref)
|
|
14099
|
-
parentDom.insertBefore(newDom, ref);
|
|
14100
|
-
} else {
|
|
14101
|
-
const ref = parentDom.childNodes[j] ?? null;
|
|
14102
|
-
parentDom.insertBefore(newChild.toDom(opts), ref);
|
|
14103
|
-
}
|
|
14133
|
+
lookupTypeFor(name, inst) {
|
|
14134
|
+
return this.transactor.comps.getCompFor(inst).scope.lookupComponent(name);
|
|
14104
14135
|
}
|
|
14105
|
-
for (let i = oldChilds.length - 1;i >= 0; i--)
|
|
14106
|
-
if (!used2[i] && domNodes[i].parentNode === parentDom)
|
|
14107
|
-
parentDom.removeChild(domNodes[i]);
|
|
14108
14136
|
}
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14137
|
+
|
|
14138
|
+
class EventContext extends Dispatcher {
|
|
14139
|
+
get name() {
|
|
14140
|
+
return this.parent?.name ?? null;
|
|
14141
|
+
}
|
|
14142
|
+
get targetPath() {
|
|
14143
|
+
return this.parent.targetPath;
|
|
14144
|
+
}
|
|
14145
|
+
stopPropagation() {
|
|
14146
|
+
return this.parent.stopPropagation();
|
|
14115
14147
|
}
|
|
14116
|
-
const domNode = vnode.toDom(options);
|
|
14117
|
-
container.replaceChildren(domNode);
|
|
14118
|
-
return { vnode, dom: isFragment ? container : domNode };
|
|
14119
14148
|
}
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
break;
|
|
14135
|
-
case "class":
|
|
14136
|
-
props.className = propVal;
|
|
14137
|
-
break;
|
|
14138
|
-
case "for":
|
|
14139
|
-
props.htmlFor = propVal;
|
|
14140
|
-
break;
|
|
14141
|
-
default:
|
|
14142
|
-
props[propName] = isHtmlAttribute(propName) ? String(propVal) : propVal;
|
|
14143
|
-
}
|
|
14144
|
-
}
|
|
14149
|
+
|
|
14150
|
+
class PathChanges extends PathBuilder {
|
|
14151
|
+
constructor(dispatcher) {
|
|
14152
|
+
super();
|
|
14153
|
+
this.dispatcher = dispatcher;
|
|
14154
|
+
}
|
|
14155
|
+
send(name, args, opts) {
|
|
14156
|
+
return this.dispatcher.sendAtPath(this.buildPath(), name, args, opts);
|
|
14157
|
+
}
|
|
14158
|
+
bubble(name, args, opts) {
|
|
14159
|
+
return this.send(name, args, { skipSelf: true, bubbles: true, ...opts });
|
|
14160
|
+
}
|
|
14161
|
+
buildPath() {
|
|
14162
|
+
return this.dispatcher.path.concat(this.pathChanges);
|
|
14145
14163
|
}
|
|
14146
|
-
const normalizedChildren = [];
|
|
14147
|
-
addChild(normalizedChildren, children);
|
|
14148
|
-
return new VNode2(tag, props, normalizedChildren, key, namespace);
|
|
14149
14164
|
}
|
|
14150
14165
|
|
|
14151
14166
|
// src/app.js
|
|
@@ -14256,7 +14271,7 @@ class App {
|
|
|
14256
14271
|
const txnPath = path.compact().toTransactionPath();
|
|
14257
14272
|
const value = txnPath.lookup(rootValue);
|
|
14258
14273
|
const dragType = e.target.dataset.dragtype ?? "?";
|
|
14259
|
-
const stack =
|
|
14274
|
+
const stack = path.toTransactionPath().buildStack(this.makeStack(rootValue));
|
|
14260
14275
|
this.dragInfo = new DragInfo(txnPath, stack, e, value, dragType, e.target);
|
|
14261
14276
|
} else if (type3 === "drop") {
|
|
14262
14277
|
e.preventDefault();
|