malinajs 0.7.0-a13 → 0.7.0-a16
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/CHANGELOG.md +1 -0
- package/malina.js +97 -68
- package/package.json +1 -1
- package/runtime.js +104 -121
package/CHANGELOG.md
CHANGED
package/malina.js
CHANGED
|
@@ -647,8 +647,8 @@
|
|
|
647
647
|
cloneNode = false;
|
|
648
648
|
if(!node.raw) template = htmlEntitiesToText(template);
|
|
649
649
|
} else {
|
|
650
|
-
if(get_context().config.hideLabel) convert = '$runtime
|
|
651
|
-
else convert = '$runtime
|
|
650
|
+
if(get_context().config.hideLabel) convert = '$runtime.htmlToFragmentClean';
|
|
651
|
+
else convert = '$runtime.htmlToFragment';
|
|
652
652
|
template = template.replace(/<!---->/g, '<>');
|
|
653
653
|
}
|
|
654
654
|
if(node.raw) {
|
|
@@ -672,14 +672,6 @@
|
|
|
672
672
|
|
|
673
673
|
function compactDOM() {
|
|
674
674
|
let data = this.DOM;
|
|
675
|
-
const details = {
|
|
676
|
-
node: [n => n.body],
|
|
677
|
-
each: [n => n.body],
|
|
678
|
-
slot: [n => n.body],
|
|
679
|
-
fragment: [n => n.body],
|
|
680
|
-
if: [n => n.body, n => n.bodyMain],
|
|
681
|
-
await: [n => n.parts.main, n => n.parts.then, n => n.parts.catch]
|
|
682
|
-
};
|
|
683
675
|
|
|
684
676
|
function go(body, parentNode) {
|
|
685
677
|
let i;
|
|
@@ -717,11 +709,28 @@
|
|
|
717
709
|
}
|
|
718
710
|
} else {
|
|
719
711
|
if(node.type == 'node' && (node.name == 'pre' || node.name == 'textarea')) continue;
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
712
|
+
switch(node.type) {
|
|
713
|
+
case 'node':
|
|
714
|
+
case 'slot':
|
|
715
|
+
case 'fragment':
|
|
716
|
+
if(node.body) go(node.body, node);
|
|
717
|
+
break
|
|
718
|
+
case 'each':
|
|
719
|
+
if(node.mainBlock) go(node.mainBlock, node);
|
|
720
|
+
if(node.elseBlock) go(node.elseBlock, node);
|
|
721
|
+
break
|
|
722
|
+
case 'await':
|
|
723
|
+
if(node.parts.main) go(node.parts.main, node);
|
|
724
|
+
if(node.parts.then) go(node.parts.then, node);
|
|
725
|
+
if(node.parts.catch) go(node.parts.catch, node);
|
|
726
|
+
break
|
|
727
|
+
case 'if':
|
|
728
|
+
node.parts.forEach(p => {
|
|
729
|
+
if(p.body) go(p.body, node);
|
|
730
|
+
});
|
|
731
|
+
if(node.elsePart) go(node.elsePart, node);
|
|
732
|
+
break
|
|
733
|
+
}
|
|
725
734
|
}
|
|
726
735
|
}
|
|
727
736
|
|
|
@@ -739,12 +748,12 @@
|
|
|
739
748
|
let prev = getPrev();
|
|
740
749
|
let next = getNext();
|
|
741
750
|
|
|
742
|
-
if(next?.type == 'node' && ['br', 'div'].includes(next.name)) {
|
|
751
|
+
if(next?.type == 'node' && ['br', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7'].includes(next.name)) {
|
|
743
752
|
body.splice(i, 1);
|
|
744
753
|
continue;
|
|
745
754
|
}
|
|
746
755
|
|
|
747
|
-
if(prev?.type == 'node' && ['br', 'div'].includes(prev.name)) {
|
|
756
|
+
if(prev?.type == 'node' && ['br', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7'].includes(prev.name)) {
|
|
748
757
|
body.splice(i, 1);
|
|
749
758
|
continue;
|
|
750
759
|
}
|
|
@@ -774,7 +783,7 @@
|
|
|
774
783
|
body.splice(i, 1);
|
|
775
784
|
continue;
|
|
776
785
|
}
|
|
777
|
-
if(parentNode.type == 'node' &&
|
|
786
|
+
if(parentNode.type == 'node' && ['div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7'].includes(parentNode.name)) {
|
|
778
787
|
body.splice(i, 1);
|
|
779
788
|
continue;
|
|
780
789
|
}
|
|
@@ -1548,7 +1557,7 @@
|
|
|
1548
1557
|
}, (ctx, n) => {
|
|
1549
1558
|
if(this.inuse.apply) {
|
|
1550
1559
|
if(this.config.immutable) ctx.write(true, `$watch(() => (${n.exp}), ${n.callback});`);
|
|
1551
|
-
else ctx.write(true, `$watch(() => (${n.exp}), ${n.callback}, {cmp: $runtime
|
|
1560
|
+
else ctx.write(true, `$watch(() => (${n.exp}), ${n.callback}, {cmp: $runtime.deepComparator(0)});`);
|
|
1552
1561
|
} else {
|
|
1553
1562
|
ctx.write(true, `(${n.callback})(${n.exp});`);
|
|
1554
1563
|
}
|
|
@@ -1565,7 +1574,7 @@
|
|
|
1565
1574
|
exp: astring.generate(exp),
|
|
1566
1575
|
callback
|
|
1567
1576
|
}, (ctx, n) => {
|
|
1568
|
-
if(this.inuse.apply) ctx.write(true, `$watch(() => ${n.exp}, ($args) => { (${n.callback}).apply(null, $args); }, {cmp: $runtime
|
|
1577
|
+
if(this.inuse.apply) ctx.write(true, `$watch(() => ${n.exp}, ($args) => { (${n.callback}).apply(null, $args); }, {cmp: $runtime.deepComparator(1)});`);
|
|
1569
1578
|
else ctx.write(true, `(${n.callback}).apply(null, ${n.exp})`);
|
|
1570
1579
|
}));
|
|
1571
1580
|
} else throw 'Error';
|
|
@@ -1663,8 +1672,8 @@
|
|
|
1663
1672
|
ctx.write(true, `let {${pa}, ...$attributes} = $props;`);
|
|
1664
1673
|
|
|
1665
1674
|
if(!this.script.readOnly && !n.constantProps) {
|
|
1666
|
-
ctx.write(true, `$runtime.current_component
|
|
1667
|
-
ctx.write(true, `$runtime.current_component
|
|
1675
|
+
ctx.write(true, `$runtime.current_component.$push = ($$props) => ({${n.props.map(p => p.name + '=' + p.name).join(', ')}, ...$attributes} = $props = $$props);`);
|
|
1676
|
+
ctx.write(true, `$runtime.current_component.$exportedProps = () => ({${n.props.map(p => p.name).join(', ')}});`);
|
|
1668
1677
|
}
|
|
1669
1678
|
} else if(this.inuse.$props) {
|
|
1670
1679
|
let pa = n.props.map(p => {
|
|
@@ -1674,8 +1683,8 @@
|
|
|
1674
1683
|
ctx.write(true, `let {${pa}} = $props;`);
|
|
1675
1684
|
|
|
1676
1685
|
if(!this.script.readOnly && !n.constantProps) {
|
|
1677
|
-
ctx.write(true, `$runtime.current_component
|
|
1678
|
-
ctx.write(true, `$runtime.current_component
|
|
1686
|
+
ctx.write(true, `$runtime.current_component.$push = ($$props) => ({${n.props.map(p => p.name + '=' + p.name).join(', ')}} = $props = $$props);`);
|
|
1687
|
+
ctx.write(true, `$runtime.current_component.$exportedProps = () => ({${n.props.map(p => p.name).join(', ')}});`);
|
|
1679
1688
|
}
|
|
1680
1689
|
}
|
|
1681
1690
|
}));
|
|
@@ -1685,13 +1694,13 @@
|
|
|
1685
1694
|
this.module.head.push(xNode('no-props', ctx => {
|
|
1686
1695
|
if(this.inuse.$props && this.inuse.$attributes) {
|
|
1687
1696
|
ctx.write(true, 'let $props = $option.props || {}, $attributes = $props;');
|
|
1688
|
-
if(!this.script.readOnly) ctx.write(true, '$runtime.current_component
|
|
1697
|
+
if(!this.script.readOnly) ctx.write(true, '$runtime.current_component.$push = ($$props) => $props = $attributes = $$props;');
|
|
1689
1698
|
} else if(this.inuse.$props) {
|
|
1690
1699
|
ctx.write(true, 'let $props = $option.props || {};');
|
|
1691
|
-
if(!this.script.readOnly) ctx.write(true, '$runtime.current_component
|
|
1700
|
+
if(!this.script.readOnly) ctx.write(true, '$runtime.current_component.$push = ($$props) => $props = $$props;');
|
|
1692
1701
|
} else if(this.inuse.$attributes) {
|
|
1693
1702
|
ctx.write(true, 'let $attributes = $option.props || {};');
|
|
1694
|
-
if(!this.script.readOnly) ctx.write(true, '$runtime.current_component
|
|
1703
|
+
if(!this.script.readOnly) ctx.write(true, '$runtime.current_component.$push = ($$props) => $attributes = $$props;');
|
|
1695
1704
|
}
|
|
1696
1705
|
}));
|
|
1697
1706
|
|
|
@@ -1781,22 +1790,13 @@
|
|
|
1781
1790
|
}
|
|
1782
1791
|
}));
|
|
1783
1792
|
|
|
1784
|
-
this.module.head.push(xNode('$context', {
|
|
1785
|
-
$
|
|
1786
|
-
}, (ctx) => {
|
|
1787
|
-
if(this.inuse.$context) {
|
|
1788
|
-
this.require('componentFn');
|
|
1789
|
-
ctx.write(true, 'const $context = $runtime.$context;');
|
|
1790
|
-
}
|
|
1793
|
+
this.module.head.push(xNode('$context', (ctx) => {
|
|
1794
|
+
if(this.inuse.$context) ctx.write(true, 'const $context = $option.context || {};');
|
|
1791
1795
|
}));
|
|
1792
1796
|
|
|
1793
1797
|
this.module.top.push(xNode(this.glob.$onMount, {
|
|
1794
|
-
$hold: ['componentFn']
|
|
1795
1798
|
}, (ctx, n) => {
|
|
1796
|
-
if(n.value) {
|
|
1797
|
-
this.require('componentFn');
|
|
1798
|
-
ctx.write(true, `import { $onMount } from 'malinajs/runtime.js';`);
|
|
1799
|
-
}
|
|
1799
|
+
if(n.value) ctx.write(true, `import { $onMount } from 'malinajs/runtime.js';`);
|
|
1800
1800
|
}));
|
|
1801
1801
|
|
|
1802
1802
|
this.module.top.push(xNode('$onDestroy', (ctx) => {
|
|
@@ -1815,7 +1815,7 @@
|
|
|
1815
1815
|
}));
|
|
1816
1816
|
|
|
1817
1817
|
this.module.head.push(xNode('$emit', (ctx) => {
|
|
1818
|
-
if(this.inuse.$emit) ctx.write(true, 'const $emit = $runtime
|
|
1818
|
+
if(this.inuse.$emit) ctx.write(true, 'const $emit = $runtime.makeEmitter($option);');
|
|
1819
1819
|
}));
|
|
1820
1820
|
|
|
1821
1821
|
if(this.config.autoSubscribe && !this.script.readOnly) {
|
|
@@ -1936,7 +1936,12 @@
|
|
|
1936
1936
|
if(nodesForSingleBlock.length == 1) {
|
|
1937
1937
|
let n = nodesForSingleBlock[0];
|
|
1938
1938
|
if(n.type == 'node' && n.name.match(/^[A-Z]/)) {
|
|
1939
|
-
let component
|
|
1939
|
+
let component;
|
|
1940
|
+
try {
|
|
1941
|
+
component = this.makeComponent(n);
|
|
1942
|
+
} catch (e) {
|
|
1943
|
+
wrapException(e, n);
|
|
1944
|
+
}
|
|
1940
1945
|
return {
|
|
1941
1946
|
singleBlock: component.bind,
|
|
1942
1947
|
reference: component.reference
|
|
@@ -2408,7 +2413,9 @@
|
|
|
2408
2413
|
base = n;
|
|
2409
2414
|
shift = 0;
|
|
2410
2415
|
} else if(n._innerBinding) {
|
|
2411
|
-
let npath
|
|
2416
|
+
let npath;
|
|
2417
|
+
if(base) npath = [base._boundName];
|
|
2418
|
+
else npath = [...path, 'firstChild'];
|
|
2412
2419
|
while(shift--) npath.push('nextSibling');
|
|
2413
2420
|
walk(n, npath);
|
|
2414
2421
|
shift = 0;
|
|
@@ -4444,6 +4451,7 @@
|
|
|
4444
4451
|
}
|
|
4445
4452
|
} else cleanSelectorItems.push(s);
|
|
4446
4453
|
}
|
|
4454
|
+
while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(cleanSelectorItems[0].type)) cleanSelectorItems.shift();
|
|
4447
4455
|
while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(last(cleanSelectorItems).type)) cleanSelectorItems.pop();
|
|
4448
4456
|
if(!cleanSelectorItems.length || globalBlock) { // fully global?
|
|
4449
4457
|
assert(origin.length);
|
|
@@ -4753,7 +4761,7 @@
|
|
|
4753
4761
|
this.require('$context');
|
|
4754
4762
|
|
|
4755
4763
|
let reference = null;
|
|
4756
|
-
let propsFn = [], propsSetter = [], $class = [], staticProps = true;
|
|
4764
|
+
let propsFn = [], propsSetter = [], $class = [], staticProps = true, deepChecking = false;
|
|
4757
4765
|
let slotBlocks = [];
|
|
4758
4766
|
let anchorBlocks = [];
|
|
4759
4767
|
|
|
@@ -4944,7 +4952,9 @@
|
|
|
4944
4952
|
return;
|
|
4945
4953
|
}
|
|
4946
4954
|
|
|
4947
|
-
let { event, fn } = this.makeEventProp(prop)
|
|
4955
|
+
let { event, fn } = this.makeEventProp(prop, () => {
|
|
4956
|
+
throw new Error('$element is not available for component, use $event instead');
|
|
4957
|
+
});
|
|
4948
4958
|
|
|
4949
4959
|
passEvent(event, xNode('passEvent', {
|
|
4950
4960
|
fn
|
|
@@ -4977,12 +4987,14 @@
|
|
|
4977
4987
|
if(ip.name == ip.value) propsFn.push(`${ip.name}`);
|
|
4978
4988
|
else propsFn.push(`${ip.name}: ${ip.value}`);
|
|
4979
4989
|
if(!ip.static) staticProps = false;
|
|
4990
|
+
if(ip.mod.deep) deepChecking = true;
|
|
4980
4991
|
});
|
|
4981
4992
|
|
|
4982
4993
|
|
|
4983
4994
|
if(Object.keys(events).length == 0) events = null;
|
|
4984
4995
|
|
|
4985
4996
|
let result = xNode('component', {
|
|
4997
|
+
$wait: ['apply'],
|
|
4986
4998
|
componentName,
|
|
4987
4999
|
staticProps,
|
|
4988
5000
|
props: propsFn,
|
|
@@ -4991,12 +5003,16 @@
|
|
|
4991
5003
|
forwardAllEvents,
|
|
4992
5004
|
events,
|
|
4993
5005
|
slots: slotBlocks.length ? slotBlocks : null,
|
|
4994
|
-
anchors: anchorBlocks.length ? anchorBlocks : null
|
|
5006
|
+
anchors: anchorBlocks.length ? anchorBlocks : null,
|
|
5007
|
+
deepChecking
|
|
4995
5008
|
}, (ctx, n) => {
|
|
4996
5009
|
let comma = false;
|
|
4997
|
-
ctx.write(`$runtime.callComponent($context, ${n.componentName}, {`);
|
|
4998
5010
|
|
|
4999
|
-
if(n.props.length && n.staticProps) {
|
|
5011
|
+
if(this.inuse.apply && (n.$class.length || n.propsSetter.length || n.props.length && !n.staticProps)) {
|
|
5012
|
+
ctx.write(`$runtime.callComponentDyn(${n.componentName}, $context, {`);
|
|
5013
|
+
} else ctx.write(`$runtime.callComponent(${n.componentName}, $context, {`);
|
|
5014
|
+
|
|
5015
|
+
if(n.props.length && (n.staticProps || !this.inuse.apply)) {
|
|
5000
5016
|
ctx.write(`props: {${n.props.join(', ')}}`);
|
|
5001
5017
|
comma = true;
|
|
5002
5018
|
n.props = [];
|
|
@@ -5067,16 +5083,16 @@
|
|
|
5067
5083
|
if(n.props.length) ctx.write(',\n', true, `() => ({${n.props.join(', ')}})`);
|
|
5068
5084
|
else other = ', null';
|
|
5069
5085
|
|
|
5070
|
-
if(
|
|
5086
|
+
if(this.inuse.apply && n.props.length) {
|
|
5071
5087
|
if(other) ctx.write(other);
|
|
5072
5088
|
other = '';
|
|
5073
5089
|
ctx.write(',');
|
|
5074
5090
|
if(n.props.length) ctx.write('\n', true);
|
|
5075
|
-
if(
|
|
5076
|
-
else ctx.write('$runtime
|
|
5091
|
+
if(n.deepChecking) ctx.write('$runtime.compareDeep');
|
|
5092
|
+
else ctx.write('$runtime.keyComparator');
|
|
5077
5093
|
} else other += ', null';
|
|
5078
5094
|
|
|
5079
|
-
if(n.propsSetter.length) {
|
|
5095
|
+
if(n.propsSetter.length && this.inuse.apply) {
|
|
5080
5096
|
if(other) ctx.write(other);
|
|
5081
5097
|
other = '';
|
|
5082
5098
|
ctx.write(',\n', true, `($$_value) => ({${n.propsSetter.join(', ')}} = $$_value)`);
|
|
@@ -5823,8 +5839,8 @@
|
|
|
5823
5839
|
el: label.bindName(),
|
|
5824
5840
|
exp
|
|
5825
5841
|
}, (ctx, n) => {
|
|
5826
|
-
if(this.inuse.apply) ctx.write(true, `$runtime
|
|
5827
|
-
else ctx.write(true, `$runtime
|
|
5842
|
+
if(this.inuse.apply) ctx.write(true, `$runtime.htmlBlock(${n.el}, () => (${n.exp}));`);
|
|
5843
|
+
else ctx.write(true, `$runtime.htmlBlockStatic(${n.el}, ${n.exp});`);
|
|
5828
5844
|
});
|
|
5829
5845
|
}
|
|
5830
5846
|
|
|
@@ -5887,7 +5903,7 @@
|
|
|
5887
5903
|
parts,
|
|
5888
5904
|
keywords
|
|
5889
5905
|
}, (ctx, n) => {
|
|
5890
|
-
ctx.write(true, `$runtime
|
|
5906
|
+
ctx.write(true, `$runtime.awaitBlock(${n.el}, () => [${n.keywords.join(', ')}], () => ${n.exp},`);
|
|
5891
5907
|
ctx.indent++;
|
|
5892
5908
|
n.parts.forEach((part, index) => {
|
|
5893
5909
|
if(index) ctx.write(', ');
|
|
@@ -5902,12 +5918,13 @@
|
|
|
5902
5918
|
}
|
|
5903
5919
|
|
|
5904
5920
|
function attachSlot(slotName, node) {
|
|
5905
|
-
let props = [], staticProps = true;
|
|
5921
|
+
let props = [], staticProps = true, deepChecking = false;
|
|
5906
5922
|
|
|
5907
5923
|
if(node.attributes && node.attributes.length) {
|
|
5908
5924
|
node.attributes.forEach(prop => {
|
|
5909
5925
|
let { name, value, ...ip } = this.inspectProp(prop);
|
|
5910
5926
|
if(!ip.static) staticProps = false;
|
|
5927
|
+
if(ip.mod.deep) deepChecking = true;
|
|
5911
5928
|
props.push(xNode('slot-prop', {
|
|
5912
5929
|
name,
|
|
5913
5930
|
value
|
|
@@ -5928,7 +5945,8 @@
|
|
|
5928
5945
|
name: slotName,
|
|
5929
5946
|
props,
|
|
5930
5947
|
staticProps,
|
|
5931
|
-
placeholder
|
|
5948
|
+
placeholder,
|
|
5949
|
+
deepChecking
|
|
5932
5950
|
}, (ctx, n) => {
|
|
5933
5951
|
let dynamicProps = this.inuse.apply && !n.staticProps;
|
|
5934
5952
|
|
|
@@ -5955,8 +5973,8 @@
|
|
|
5955
5973
|
|
|
5956
5974
|
if(dynamicProps) {
|
|
5957
5975
|
ctx.write(missed, ', ');
|
|
5958
|
-
if(
|
|
5959
|
-
else ctx.write('$runtime
|
|
5976
|
+
if(n.deepChecking) ctx.write('$runtime.compareDeep');
|
|
5977
|
+
else ctx.write('$runtime.keyComparator');
|
|
5960
5978
|
}
|
|
5961
5979
|
ctx.write(')');
|
|
5962
5980
|
});
|
|
@@ -5989,6 +6007,11 @@
|
|
|
5989
6007
|
});
|
|
5990
6008
|
}
|
|
5991
6009
|
|
|
6010
|
+
if(external) {
|
|
6011
|
+
this.require('$component');
|
|
6012
|
+
if(props?.length) this.require('apply');
|
|
6013
|
+
}
|
|
6014
|
+
|
|
5992
6015
|
return xNode('fragment', {
|
|
5993
6016
|
$compile: [block.source],
|
|
5994
6017
|
name,
|
|
@@ -6025,7 +6048,7 @@
|
|
|
6025
6048
|
ctx.indent--;
|
|
6026
6049
|
ctx.writeLine('}');
|
|
6027
6050
|
}
|
|
6028
|
-
if(n.external) ctx.writeLine(`$runtime.exportFragment('${n.name}', $fragment_${n.name});`);
|
|
6051
|
+
if(n.external) ctx.writeLine(`$runtime.exportFragment($component, '${n.name}', $fragment_${n.name});`);
|
|
6029
6052
|
});
|
|
6030
6053
|
}
|
|
6031
6054
|
|
|
@@ -6035,6 +6058,7 @@
|
|
|
6035
6058
|
let events = [];
|
|
6036
6059
|
let forwardAllEvents;
|
|
6037
6060
|
let staticProps = true;
|
|
6061
|
+
let deepChecking = false;
|
|
6038
6062
|
|
|
6039
6063
|
attributes.forEach(prop => {
|
|
6040
6064
|
let name = prop.name;
|
|
@@ -6059,10 +6083,11 @@
|
|
|
6059
6083
|
let ip = this.inspectProp(prop);
|
|
6060
6084
|
props.push(ip);
|
|
6061
6085
|
if(!ip.static) staticProps = false;
|
|
6086
|
+
if(ip.mod.deep) deepChecking = true;
|
|
6062
6087
|
}
|
|
6063
6088
|
});
|
|
6064
6089
|
|
|
6065
|
-
return { props, events, forwardAllEvents, staticProps };
|
|
6090
|
+
return { props, events, forwardAllEvents, staticProps, deepChecking };
|
|
6066
6091
|
}
|
|
6067
6092
|
|
|
6068
6093
|
|
|
@@ -6232,8 +6257,8 @@
|
|
|
6232
6257
|
ctx.write('() => (');
|
|
6233
6258
|
writeProps();
|
|
6234
6259
|
ctx.write('), ');
|
|
6235
|
-
if(
|
|
6236
|
-
else ctx.write('$runtime
|
|
6260
|
+
if(n.deepChecking) ctx.write('$runtime.compareDeep');
|
|
6261
|
+
else ctx.write('$runtime.keyComparator');
|
|
6237
6262
|
}
|
|
6238
6263
|
}
|
|
6239
6264
|
|
|
@@ -6310,7 +6335,7 @@
|
|
|
6310
6335
|
ctx.add(n.template);
|
|
6311
6336
|
ctx.add(n.source);
|
|
6312
6337
|
ctx.writeLine('let a=$parentElement.firstChild, b=$parentElement.lastChild;');
|
|
6313
|
-
ctx.writeLine('$onDestroy(() => {$runtime
|
|
6338
|
+
ctx.writeLine('$onDestroy(() => {$runtime.removeElements(a, b)});');
|
|
6314
6339
|
ctx.writeLine('document.head.appendChild($parentElement);');
|
|
6315
6340
|
ctx.indent--;
|
|
6316
6341
|
ctx.writeLine('}');
|
|
@@ -6321,14 +6346,18 @@
|
|
|
6321
6346
|
}
|
|
6322
6347
|
|
|
6323
6348
|
function inspectProp(prop) {
|
|
6324
|
-
let { name, value } = prop;
|
|
6349
|
+
let { name, value } = prop, mod = {};
|
|
6325
6350
|
if(name[0] == '{') {
|
|
6326
6351
|
assert(!prop.value);
|
|
6327
6352
|
value = name;
|
|
6328
6353
|
name = unwrapExp(name);
|
|
6354
|
+
} else {
|
|
6355
|
+
const p = name.split('|');
|
|
6356
|
+
name = p[0];
|
|
6357
|
+
p.slice(1).forEach(n => mod[n] = true);
|
|
6329
6358
|
}
|
|
6330
6359
|
|
|
6331
|
-
assert(name.match(/^([\w$_][\w\d$_
|
|
6360
|
+
assert(name.match(/^([\w$_][\w\d$_.\-|]*)$/), `Wrong property: '${name}'`);
|
|
6332
6361
|
name = toCamelCase(name);
|
|
6333
6362
|
if(name == 'class') name = '_class';
|
|
6334
6363
|
|
|
@@ -6367,7 +6396,7 @@
|
|
|
6367
6396
|
statical = true;
|
|
6368
6397
|
}
|
|
6369
6398
|
|
|
6370
|
-
return { name, value, rawValue, static: statical };
|
|
6399
|
+
return { name, value, rawValue, static: statical, mod };
|
|
6371
6400
|
}
|
|
6372
6401
|
|
|
6373
6402
|
function attachPortal(node) {
|
|
@@ -6399,7 +6428,7 @@
|
|
|
6399
6428
|
ctx.add(n.source);
|
|
6400
6429
|
ctx.writeLine('let $$first = $parentElement.firstChild;');
|
|
6401
6430
|
ctx.writeLine('let $$last = $parentElement.lastChild;');
|
|
6402
|
-
ctx.writeLine(`$runtime.$onDestroy(() => $runtime
|
|
6431
|
+
ctx.writeLine(`$runtime.$onDestroy(() => $runtime.removeElements($$first, $$last));`);
|
|
6403
6432
|
ctx.writeLine(`$tick(() => ${label}.appendChild($parentElement));`);
|
|
6404
6433
|
ctx.indent--;
|
|
6405
6434
|
ctx.writeLine('}');
|
|
@@ -6551,7 +6580,7 @@
|
|
|
6551
6580
|
return { event, fn, rootModifier };
|
|
6552
6581
|
}
|
|
6553
6582
|
|
|
6554
|
-
const version = '0.7.0-
|
|
6583
|
+
const version = '0.7.0-a16';
|
|
6555
6584
|
|
|
6556
6585
|
|
|
6557
6586
|
async function compile(source, config = {}) {
|
package/package.json
CHANGED
package/runtime.js
CHANGED
|
@@ -18,7 +18,7 @@ const safeCall = fn => {
|
|
|
18
18
|
|
|
19
19
|
const safeGroupCall = list => {
|
|
20
20
|
try {
|
|
21
|
-
list
|
|
21
|
+
list?.forEach(fn => fn?.());
|
|
22
22
|
} catch (e) {
|
|
23
23
|
__app_onerror(e);
|
|
24
24
|
}
|
|
@@ -58,7 +58,7 @@ function addEvent(el, event, callback) {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
function
|
|
61
|
+
function removeItem(array, item) {
|
|
62
62
|
let i = array.indexOf(item);
|
|
63
63
|
if(i >= 0) array.splice(i, 1);
|
|
64
64
|
}
|
|
@@ -77,20 +77,18 @@ const cd_component = cd => {
|
|
|
77
77
|
|
|
78
78
|
const cd_new = () => new $ChangeDetector();
|
|
79
79
|
|
|
80
|
-
const
|
|
80
|
+
const cd_attach = (parent, cd) => {
|
|
81
81
|
if(cd) {
|
|
82
82
|
cd.parent = parent;
|
|
83
83
|
parent.children.push(cd);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
const cd_detach = cd => $$removeItem(cd.parent.children, cd);
|
|
87
|
+
const cd_detach = cd => removeItem(cd.parent.children, cd);
|
|
90
88
|
|
|
91
89
|
const isArray = (a) => Array.isArray(a);
|
|
92
90
|
|
|
93
|
-
const
|
|
91
|
+
const _compareArray = (a, b) => {
|
|
94
92
|
let a0 = isArray(a);
|
|
95
93
|
let a1 = isArray(b);
|
|
96
94
|
if(a0 !== a1) return true;
|
|
@@ -103,15 +101,15 @@ const compareArray = (a, b) => {
|
|
|
103
101
|
};
|
|
104
102
|
|
|
105
103
|
|
|
106
|
-
function
|
|
107
|
-
if(!
|
|
104
|
+
function compareArray(w, value) {
|
|
105
|
+
if(!_compareArray(w.value, value)) return 0;
|
|
108
106
|
if(isArray(value)) w.value = value.slice();
|
|
109
107
|
else w.value = value;
|
|
110
108
|
w.cb(w.value);
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
|
|
114
|
-
const
|
|
112
|
+
const _compareDeep = (a, b, lvl) => {
|
|
115
113
|
if(lvl < 0 || !a || !b) return a !== b;
|
|
116
114
|
if(a === b) return false;
|
|
117
115
|
let o0 = isObject(a);
|
|
@@ -125,12 +123,12 @@ const compareDeep = (a, b, lvl) => {
|
|
|
125
123
|
if(a0) {
|
|
126
124
|
if(a.length !== b.length) return true;
|
|
127
125
|
for(let i = 0; i < a.length; i++) {
|
|
128
|
-
if(
|
|
126
|
+
if(_compareDeep(a[i], b[i], lvl - 1)) return true;
|
|
129
127
|
}
|
|
130
128
|
} else {
|
|
131
129
|
let set = {};
|
|
132
130
|
for(let k in a) {
|
|
133
|
-
if(
|
|
131
|
+
if(_compareDeep(a[k], b[k], lvl - 1)) return true;
|
|
134
132
|
set[k] = true;
|
|
135
133
|
}
|
|
136
134
|
for(let k in b) {
|
|
@@ -156,19 +154,16 @@ function cloneDeep(d, lvl) {
|
|
|
156
154
|
return d;
|
|
157
155
|
}
|
|
158
156
|
|
|
159
|
-
const $$cloneDeep = function(d) {
|
|
160
|
-
return cloneDeep(d, 10);
|
|
161
|
-
};
|
|
162
157
|
|
|
163
|
-
function
|
|
158
|
+
function deepComparator(depth) {
|
|
164
159
|
return function(w, value) {
|
|
165
|
-
let diff =
|
|
160
|
+
let diff = _compareDeep(w.value, value, depth);
|
|
166
161
|
diff && (w.value = cloneDeep(value, depth), !w.idle && w.cb(value));
|
|
167
162
|
w.idle = false;
|
|
168
163
|
};
|
|
169
164
|
}
|
|
170
165
|
|
|
171
|
-
const
|
|
166
|
+
const compareDeep = deepComparator(10);
|
|
172
167
|
|
|
173
168
|
|
|
174
169
|
const keyComparator = (w, value) => {
|
|
@@ -232,7 +227,7 @@ const insertAfter = (label, node) => {
|
|
|
232
227
|
|
|
233
228
|
const createTextNode = (text) => document.createTextNode(text);
|
|
234
229
|
|
|
235
|
-
const
|
|
230
|
+
const htmlToFragment = (html, option) => {
|
|
236
231
|
let result = templatecache[html];
|
|
237
232
|
if(!result) {
|
|
238
233
|
let t = document.createElement('template');
|
|
@@ -245,7 +240,7 @@ const $$htmlToFragment = (html, option) => {
|
|
|
245
240
|
return option & 1 ? result.cloneNode(true) : result;
|
|
246
241
|
};
|
|
247
242
|
|
|
248
|
-
const
|
|
243
|
+
const htmlToFragmentClean = (html, option) => {
|
|
249
244
|
let result = templatecache[html];
|
|
250
245
|
if(!result) {
|
|
251
246
|
let t = document.createElement('template');
|
|
@@ -290,7 +285,7 @@ const iterNodes = (el, last, fn) => {
|
|
|
290
285
|
};
|
|
291
286
|
|
|
292
287
|
|
|
293
|
-
const
|
|
288
|
+
const removeElements = (el, last) => iterNodes(el, last, n => n.remove());
|
|
294
289
|
|
|
295
290
|
|
|
296
291
|
function removeElementsBetween(el, stop) {
|
|
@@ -320,7 +315,7 @@ function $tick(fn) {
|
|
|
320
315
|
}
|
|
321
316
|
|
|
322
317
|
|
|
323
|
-
function
|
|
318
|
+
function makeEmitter(option) {
|
|
324
319
|
return (name, detail) => {
|
|
325
320
|
let fn = option.events?.[name];
|
|
326
321
|
if(!fn) return;
|
|
@@ -331,24 +326,7 @@ function $makeEmitter(option) {
|
|
|
331
326
|
}
|
|
332
327
|
|
|
333
328
|
|
|
334
|
-
|
|
335
|
-
let prev = list[event];
|
|
336
|
-
if(prev) {
|
|
337
|
-
if(prev._list) prev._list.push(fn);
|
|
338
|
-
else {
|
|
339
|
-
function handler(e) {
|
|
340
|
-
handler._list.forEach(fn => {
|
|
341
|
-
fn(e);
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
handler._list = [prev, fn];
|
|
345
|
-
list[event] = handler;
|
|
346
|
-
}
|
|
347
|
-
} else list[event] = fn;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
let current_component, $context;
|
|
329
|
+
let current_component;
|
|
352
330
|
|
|
353
331
|
|
|
354
332
|
const makeApply = () => {
|
|
@@ -370,8 +348,8 @@ const makeApply = () => {
|
|
|
370
348
|
return r;
|
|
371
349
|
};
|
|
372
350
|
|
|
373
|
-
current_component
|
|
374
|
-
current_component
|
|
351
|
+
current_component.$apply = apply;
|
|
352
|
+
current_component.$push = apply;
|
|
375
353
|
apply();
|
|
376
354
|
return apply;
|
|
377
355
|
};
|
|
@@ -379,21 +357,15 @@ const makeApply = () => {
|
|
|
379
357
|
|
|
380
358
|
const makeComponent = (init) => {
|
|
381
359
|
return ($option = {}) => {
|
|
382
|
-
$context = $option.context || {};
|
|
383
360
|
let prev_component = current_component,
|
|
384
361
|
prev_cd = current_cd,
|
|
385
|
-
$component = current_component = {
|
|
386
|
-
$option,
|
|
387
|
-
context: $context,
|
|
388
|
-
exported: {}
|
|
389
|
-
};
|
|
362
|
+
$component = current_component = { $option };
|
|
390
363
|
current_cd = null;
|
|
391
364
|
|
|
392
365
|
try {
|
|
393
366
|
$component.$dom = init($option);
|
|
394
367
|
} finally {
|
|
395
368
|
current_component = prev_component;
|
|
396
|
-
$context = null;
|
|
397
369
|
current_cd = prev_cd;
|
|
398
370
|
}
|
|
399
371
|
|
|
@@ -402,37 +374,40 @@ const makeComponent = (init) => {
|
|
|
402
374
|
};
|
|
403
375
|
|
|
404
376
|
|
|
405
|
-
const callComponent = (
|
|
377
|
+
const callComponent = (component, context, option = {}) => {
|
|
406
378
|
option.context = { ...context };
|
|
407
|
-
let $component
|
|
379
|
+
let $component = safeCall(() => component(option));
|
|
380
|
+
if($component instanceof Node) $component = { $dom: $component };
|
|
381
|
+
return $component;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
const callComponentDyn = (component, context, option = {}, propFn, cmp, setter, classFn) => {
|
|
386
|
+
let $component, parentWatch;
|
|
408
387
|
|
|
409
388
|
if(propFn) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
}, { value: {}, cmp });
|
|
418
|
-
fire(parentWatch);
|
|
419
|
-
} else option.props = propFn();
|
|
389
|
+
parentWatch = $watch(propFn, value => {
|
|
390
|
+
$component.$push?.(value);
|
|
391
|
+
$component.$apply?.();
|
|
392
|
+
}, { value: {}, idle: true, cmp });
|
|
393
|
+
fire(parentWatch);
|
|
394
|
+
option.props = parentWatch.value;
|
|
420
395
|
}
|
|
421
396
|
|
|
422
397
|
if(classFn) {
|
|
423
398
|
fire($watch(classFn, value => {
|
|
424
399
|
option.$class = value;
|
|
425
|
-
$component
|
|
400
|
+
$component?.$apply?.();
|
|
426
401
|
}, { value: {}, cmp: keyComparator }));
|
|
427
402
|
}
|
|
428
403
|
|
|
429
|
-
$component =
|
|
430
|
-
if(setter && $component
|
|
431
|
-
let w = new WatchObject($component
|
|
404
|
+
$component = callComponent(component, context, option);
|
|
405
|
+
if(setter && $component?.$exportedProps) {
|
|
406
|
+
let parentCD = current_cd, w = new WatchObject($component.$exportedProps, value => {
|
|
432
407
|
setter(value);
|
|
433
|
-
cd_component(parentCD)
|
|
434
|
-
|
|
435
|
-
$component
|
|
408
|
+
cd_component(parentCD).$apply();
|
|
409
|
+
$component.$push(parentWatch.fn());
|
|
410
|
+
$component.$apply();
|
|
436
411
|
});
|
|
437
412
|
Object.assign(w, { idle: true, cmp, value: parentWatch.value });
|
|
438
413
|
$component.$cd.watchers.push(w);
|
|
@@ -445,7 +420,7 @@ const callComponent = (context, component, option = {}, propFn, cmp, setter, cla
|
|
|
445
420
|
const attachDynComponent = (label, exp, bind) => {
|
|
446
421
|
let parentCD = current_cd;
|
|
447
422
|
let active, destroyList, $cd, $dom, finalLabel = getFinalLabel(label);
|
|
448
|
-
const destroy = () =>
|
|
423
|
+
const destroy = () => safeGroupCall(destroyList);
|
|
449
424
|
$onDestroy(destroy);
|
|
450
425
|
|
|
451
426
|
$watch(exp, (component) => {
|
|
@@ -455,15 +430,16 @@ const attachDynComponent = (label, exp, bind) => {
|
|
|
455
430
|
|
|
456
431
|
if(component) {
|
|
457
432
|
destroyList = current_destroyList = [];
|
|
433
|
+
current_mountList = [];
|
|
458
434
|
$cd = current_cd = cd_new();
|
|
459
435
|
try {
|
|
460
436
|
$dom = bind(component).$dom;
|
|
437
|
+
cd_attach(parentCD, $cd);
|
|
438
|
+
insertAfter(label, $dom);
|
|
439
|
+
safeCallMount(current_mountList, destroyList);
|
|
461
440
|
} finally {
|
|
462
|
-
current_destroyList = null;
|
|
463
|
-
current_cd = null;
|
|
441
|
+
current_destroyList = current_mountList = current_cd = null;
|
|
464
442
|
}
|
|
465
|
-
cd_attach2(parentCD, $cd);
|
|
466
|
-
insertAfter(label, $dom);
|
|
467
443
|
active = true;
|
|
468
444
|
} else {
|
|
469
445
|
$cd = null;
|
|
@@ -477,7 +453,7 @@ const attachDynComponent = (label, exp, bind) => {
|
|
|
477
453
|
const autoSubscribe = (...list) => {
|
|
478
454
|
list.forEach(i => {
|
|
479
455
|
if(isFunction(i.subscribe)) {
|
|
480
|
-
let unsub = i.subscribe(current_component
|
|
456
|
+
let unsub = i.subscribe(current_component.$apply);
|
|
481
457
|
if(isFunction(unsub)) $onDestroy(unsub);
|
|
482
458
|
}
|
|
483
459
|
});
|
|
@@ -559,7 +535,7 @@ const __bindActionSubscribe = (fn, handler, value) => {
|
|
|
559
535
|
if(handler?.update && fn) {
|
|
560
536
|
$watch(fn, args => {
|
|
561
537
|
handler.update.apply(handler, args);
|
|
562
|
-
}, { cmp:
|
|
538
|
+
}, { cmp: deepComparator(1), value: cloneDeep(value, 1) });
|
|
563
539
|
}
|
|
564
540
|
};
|
|
565
541
|
|
|
@@ -613,14 +589,11 @@ const makeExternalProperty = (name, getter, setter) => {
|
|
|
613
589
|
let $component = current_component;
|
|
614
590
|
Object.defineProperty($component, name, {
|
|
615
591
|
get: getter,
|
|
616
|
-
set: v => { setter(v); $component
|
|
592
|
+
set: v => { setter(v); $component.$apply(); }
|
|
617
593
|
});
|
|
618
594
|
};
|
|
619
595
|
|
|
620
596
|
|
|
621
|
-
const eachDefaultKey = (item, index, array) => isObject(array[0]) ? item : index;
|
|
622
|
-
|
|
623
|
-
|
|
624
597
|
const attachAnchor = ($option, el, name) => {
|
|
625
598
|
$option.anchor?.[name || 'default']?.(el);
|
|
626
599
|
};
|
|
@@ -630,7 +603,7 @@ const makeAnchor = (fn) => {
|
|
|
630
603
|
let parentCD = current_cd;
|
|
631
604
|
return ($dom) => {
|
|
632
605
|
let prev = current_cd, $cd = current_cd = cd_new();
|
|
633
|
-
|
|
606
|
+
cd_attach(parentCD, $cd);
|
|
634
607
|
$onDestroy(() => cd_detach($cd));
|
|
635
608
|
try {
|
|
636
609
|
fn($dom);
|
|
@@ -684,20 +657,27 @@ const callExportedFragment = (childComponent, name, slot, events, props, cmp) =>
|
|
|
684
657
|
fire(w);
|
|
685
658
|
props = () => result;
|
|
686
659
|
}
|
|
687
|
-
let fn = childComponent
|
|
660
|
+
let fn = childComponent.$exported?.[name];
|
|
688
661
|
([$dom, push] = fn(props, events, slot));
|
|
689
662
|
return $dom;
|
|
690
663
|
};
|
|
691
664
|
|
|
692
665
|
|
|
693
|
-
const exportFragment = (name, fn) => {
|
|
666
|
+
const exportFragment = (component, name, fn) => {
|
|
694
667
|
let childCD = current_cd;
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
668
|
+
if(!component.$exported) component.$exported = {};
|
|
669
|
+
component.$exported[name] = (props, events, slot) => {
|
|
670
|
+
let prev = current_cd, apply;
|
|
671
|
+
if(childCD) {
|
|
672
|
+
let $cd = current_cd = cd_new();
|
|
673
|
+
cd_attach(childCD, $cd);
|
|
674
|
+
$onDestroy(() => cd_detach($cd));
|
|
675
|
+
apply = component.$apply;
|
|
676
|
+
apply();
|
|
677
|
+
} else {
|
|
678
|
+
current_cd = null;
|
|
679
|
+
}
|
|
680
|
+
|
|
701
681
|
try {
|
|
702
682
|
return [fn(props, events || {}, slot), apply];
|
|
703
683
|
} finally {
|
|
@@ -734,7 +714,7 @@ const makeBlockBound = (fr, fn) => {
|
|
|
734
714
|
let parentCD = current_cd;
|
|
735
715
|
return () => {
|
|
736
716
|
let $dom = fr.cloneNode(true), prev = current_cd, $cd = current_cd = cd_new();
|
|
737
|
-
|
|
717
|
+
cd_attach(parentCD, $cd);
|
|
738
718
|
$onDestroy(() => cd_detach($cd));
|
|
739
719
|
try {
|
|
740
720
|
fn($dom);
|
|
@@ -813,12 +793,11 @@ const mount = (label, component, option) => {
|
|
|
813
793
|
label.appendChild($dom);
|
|
814
794
|
safeCallMount(current_mountList, destroyList);
|
|
815
795
|
} finally {
|
|
816
|
-
current_destroyList = null;
|
|
817
|
-
current_mountList = null;
|
|
796
|
+
current_destroyList = current_mountList = null;
|
|
818
797
|
}
|
|
819
798
|
app.destroy = () => {
|
|
820
799
|
safeGroupCall(destroyList);
|
|
821
|
-
|
|
800
|
+
removeElements(first, last);
|
|
822
801
|
};
|
|
823
802
|
return app;
|
|
824
803
|
};
|
|
@@ -832,8 +811,7 @@ const mountStatic = (label, component, option) => {
|
|
|
832
811
|
safeGroupCall(current_mountList);
|
|
833
812
|
return app;
|
|
834
813
|
} finally {
|
|
835
|
-
current_destroyList = null;
|
|
836
|
-
current_mountList = null;
|
|
814
|
+
current_destroyList = current_mountList = null;
|
|
837
815
|
}
|
|
838
816
|
};
|
|
839
817
|
|
|
@@ -887,11 +865,11 @@ let create = (tag, html) => {
|
|
|
887
865
|
return lastElement;
|
|
888
866
|
};
|
|
889
867
|
|
|
890
|
-
function
|
|
868
|
+
function htmlBlock(tag, fn) {
|
|
891
869
|
let lastElement;
|
|
892
870
|
let destroy = () => {
|
|
893
871
|
if(!lastElement) return;
|
|
894
|
-
|
|
872
|
+
removeElements(tag.nextSibling, lastElement);
|
|
895
873
|
lastElement = null;
|
|
896
874
|
};
|
|
897
875
|
$watch(fn, (html) => {
|
|
@@ -900,7 +878,7 @@ function $$htmlBlock(tag, fn) {
|
|
|
900
878
|
});
|
|
901
879
|
}
|
|
902
880
|
|
|
903
|
-
function
|
|
881
|
+
function htmlBlockStatic(tag, value) {
|
|
904
882
|
create(tag, value);
|
|
905
883
|
}
|
|
906
884
|
|
|
@@ -916,11 +894,9 @@ function ifBlock(label, fn, parts, parentLabel) {
|
|
|
916
894
|
try {
|
|
917
895
|
$dom = builder();
|
|
918
896
|
} finally {
|
|
919
|
-
current_destroyList = null;
|
|
920
|
-
current_mountList = null;
|
|
921
|
-
current_cd = null;
|
|
897
|
+
current_destroyList = current_mountList = current_cd = null;
|
|
922
898
|
}
|
|
923
|
-
|
|
899
|
+
cd_attach(parentCD, $cd);
|
|
924
900
|
if($dom.nodeType == 11) {
|
|
925
901
|
first = $dom.firstChild;
|
|
926
902
|
last = $dom.lastChild;
|
|
@@ -942,9 +918,9 @@ function ifBlock(label, fn, parts, parentLabel) {
|
|
|
942
918
|
if(destroyResults.length) {
|
|
943
919
|
let f = first, l = last;
|
|
944
920
|
Promise.allSettled(destroyResults).then(() => {
|
|
945
|
-
|
|
921
|
+
removeElements(f, l);
|
|
946
922
|
});
|
|
947
|
-
} else
|
|
923
|
+
} else removeElements(first, last);
|
|
948
924
|
first = last = null;
|
|
949
925
|
destroyResults = null;
|
|
950
926
|
}
|
|
@@ -961,7 +937,7 @@ function ifBlockReadOnly(label, fn, parts) {
|
|
|
961
937
|
if(value != null) insertAfter(label, parts[value]());
|
|
962
938
|
}
|
|
963
939
|
|
|
964
|
-
function
|
|
940
|
+
function awaitBlock(label, relation, fn, build_main, build_then, build_catch) {
|
|
965
941
|
let parentCD = current_cd, first, last, $cd, promise, destroyList, status = 0;
|
|
966
942
|
$onDestroy(() => safeGroupCall(destroyList));
|
|
967
943
|
|
|
@@ -974,7 +950,7 @@ function $$awaitBlock(label, relation, fn, build_main, build_then, build_catch)
|
|
|
974
950
|
cd_detach($cd);
|
|
975
951
|
$cd = null;
|
|
976
952
|
}
|
|
977
|
-
|
|
953
|
+
removeElements(first, last);
|
|
978
954
|
first = last = null;
|
|
979
955
|
}
|
|
980
956
|
|
|
@@ -990,14 +966,14 @@ function $$awaitBlock(label, relation, fn, build_main, build_then, build_catch)
|
|
|
990
966
|
} finally {
|
|
991
967
|
current_destroyList = current_mountList = current_cd = null;
|
|
992
968
|
}
|
|
993
|
-
|
|
969
|
+
cd_attach(parentCD, $cd);
|
|
994
970
|
if($dom.nodeType == 11) {
|
|
995
971
|
first = $dom.firstChild;
|
|
996
972
|
last = $dom.lastChild;
|
|
997
973
|
} else first = last = $dom;
|
|
998
974
|
insertAfter(label, $dom);
|
|
999
975
|
safeCallMount(mountList, destroyList);
|
|
1000
|
-
cd_component(parentCD)
|
|
976
|
+
cd_component(parentCD).$apply();
|
|
1001
977
|
}
|
|
1002
978
|
|
|
1003
979
|
$watch(relation, () => {
|
|
@@ -1019,6 +995,9 @@ function $$awaitBlock(label, relation, fn, build_main, build_then, build_catch)
|
|
|
1019
995
|
}, { value: [], cmp: keyComparator });
|
|
1020
996
|
}
|
|
1021
997
|
|
|
998
|
+
const eachDefaultKey = (item, index, array) => isObject(array[0]) ? item : index;
|
|
999
|
+
|
|
1000
|
+
|
|
1022
1001
|
const makeEachBlock = (fr, fn) => {
|
|
1023
1002
|
return (item, index) => {
|
|
1024
1003
|
let $dom = fr.cloneNode(true);
|
|
@@ -1040,22 +1019,23 @@ const makeEachElseBlock = (fn) => {
|
|
|
1040
1019
|
let first, last;
|
|
1041
1020
|
let destroyList = current_destroyList = [];
|
|
1042
1021
|
let $cd = current_cd = cd_new();
|
|
1022
|
+
current_mountList = [];
|
|
1043
1023
|
try {
|
|
1044
1024
|
let $dom = fn();
|
|
1045
1025
|
if($dom.nodeType == 11) {
|
|
1046
1026
|
first = $dom.firstChild;
|
|
1047
1027
|
last = $dom.lastChild;
|
|
1048
1028
|
} else first = last = $dom;
|
|
1049
|
-
|
|
1029
|
+
cd_attach(parentCD, $cd);
|
|
1050
1030
|
if(onlyChild) label.appendChild($dom);
|
|
1051
1031
|
else attachBlock(label, $dom);
|
|
1032
|
+
safeCallMount(current_mountList, destroyList);
|
|
1052
1033
|
} finally {
|
|
1053
|
-
current_destroyList = null;
|
|
1054
|
-
current_cd = null;
|
|
1034
|
+
current_destroyList = current_mountList = current_cd = null;
|
|
1055
1035
|
}
|
|
1056
1036
|
|
|
1057
1037
|
return () => {
|
|
1058
|
-
|
|
1038
|
+
removeElements(first, last);
|
|
1059
1039
|
cd_detach($cd);
|
|
1060
1040
|
safeGroupCall(destroyList);
|
|
1061
1041
|
};
|
|
@@ -1066,7 +1046,7 @@ const makeEachElseBlock = (fn) => {
|
|
|
1066
1046
|
function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
|
|
1067
1047
|
let parentCD = current_cd;
|
|
1068
1048
|
let eachCD = cd_new();
|
|
1069
|
-
cd_attach(eachCD);
|
|
1049
|
+
cd_attach(parentCD, eachCD);
|
|
1070
1050
|
|
|
1071
1051
|
let mapping = new Map();
|
|
1072
1052
|
let lastNode, vi = 0, p_promise = 0, p_destroy = 0, elseBlock;
|
|
@@ -1120,7 +1100,7 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
|
|
|
1120
1100
|
Promise.allSettled(destroyResults).then(() => removedNodes.forEach(n => n.remove()));
|
|
1121
1101
|
} else {
|
|
1122
1102
|
if(onlyChild) label.textContent = '';
|
|
1123
|
-
else
|
|
1103
|
+
else removeElements(label.nextSibling, lastNode);
|
|
1124
1104
|
}
|
|
1125
1105
|
|
|
1126
1106
|
destroyResults = null;
|
|
@@ -1133,7 +1113,7 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
|
|
|
1133
1113
|
ctx.$cd && eachCD.children.push(ctx.$cd);
|
|
1134
1114
|
return;
|
|
1135
1115
|
}
|
|
1136
|
-
|
|
1116
|
+
safeGroupCall(ctx.d);
|
|
1137
1117
|
iterNodes(ctx.first, ctx.last, n => removedNodes.push(n));
|
|
1138
1118
|
});
|
|
1139
1119
|
|
|
@@ -1198,7 +1178,7 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
|
|
|
1198
1178
|
current_destroyList = current_mountList = current_cd = null;
|
|
1199
1179
|
}
|
|
1200
1180
|
ctx = { $cd, rebind };
|
|
1201
|
-
|
|
1181
|
+
cd_attach(eachCD, $cd);
|
|
1202
1182
|
if($dom.nodeType == 11) {
|
|
1203
1183
|
ctx.first = $dom.firstChild;
|
|
1204
1184
|
ctx.last = $dom.lastChild;
|
|
@@ -1220,7 +1200,7 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
|
|
|
1220
1200
|
if(!array.length && !elseBlock && buildElseBlock) {
|
|
1221
1201
|
elseBlock = buildElseBlock(label, onlyChild, parentCD);
|
|
1222
1202
|
}
|
|
1223
|
-
}, { cmp:
|
|
1203
|
+
}, { cmp: compareArray });
|
|
1224
1204
|
}
|
|
1225
1205
|
|
|
1226
1206
|
const invokeSlotBase = ($component, slotName, $context, props, placeholder) => {
|
|
@@ -1250,10 +1230,13 @@ const invokeSlot = ($component, slotName, $context, propsFn, placeholder, cmp) =
|
|
|
1250
1230
|
const makeSlot = (fr, fn) => {
|
|
1251
1231
|
let parentCD = current_cd;
|
|
1252
1232
|
return (callerComponent, $context, props) => {
|
|
1253
|
-
let $dom = fr.cloneNode(true), prev = current_cd
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1233
|
+
let $dom = fr.cloneNode(true), prev = current_cd;
|
|
1234
|
+
if(parentCD) {
|
|
1235
|
+
let $cd = current_cd = cd_new();
|
|
1236
|
+
cd_attach(parentCD, $cd);
|
|
1237
|
+
$onDestroy(() => cd_detach($cd));
|
|
1238
|
+
cd_component(parentCD).$apply();
|
|
1239
|
+
} else current_cd = null;
|
|
1257
1240
|
try {
|
|
1258
1241
|
return { $dom, push: fn($dom, $context, callerComponent, props) };
|
|
1259
1242
|
} finally {
|
|
@@ -1262,4 +1245,4 @@ const makeSlot = (fr, fn) => {
|
|
|
1262
1245
|
};
|
|
1263
1246
|
};
|
|
1264
1247
|
|
|
1265
|
-
export { $$
|
|
1248
|
+
export { $$eachBlock, $digest, $onDestroy, $onMount, $tick, $watch, WatchObject, __app_onerror, __bindActionSubscribe, addClass, addEvent, addStyles, attachAnchor, attachBlock, attachDynComponent, autoSubscribe, awaitBlock, bindAction, bindAttribute, bindAttributeBase, bindClass, bindClassExp, bindInput, bindStyle, bindText, callComponent, callComponentDyn, callExportedFragment, cd_attach, cd_component, cd_detach, cd_new, cloneDeep, compareArray, compareDeep, configure, createTextNode, current_cd, current_component, current_destroyList, current_mountList, deepComparator, destroyResults, eachDefaultKey, exportFragment, fire, getFinalLabel, htmlBlock, htmlBlockStatic, htmlToFragment, htmlToFragmentClean, ifBlock, ifBlockReadOnly, insertAfter, invokeSlot, invokeSlotBase, isArray, isFunction, iterNodes, keyComparator, makeAnchor, makeApply, makeBlock, makeBlockBound, makeClassResolver, makeComponent, makeEachBlock, makeEachElseBlock, makeEachSingleBlock, makeEmitter, makeExternalProperty, makeRootEvent, makeSlot, mergeAllEvents, mergeEvents, mount, mountStatic, noop, prefixPush, refer, removeElements, removeElementsBetween, removeItem, setClassToElement, spreadAttributes, svgToFragment, unwrapProps };
|