marko 6.0.0-next.3.36 → 6.0.0-next.3.37
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/common/types.d.ts +1 -0
- package/dist/debug/dom.js +41 -34
- package/dist/debug/dom.mjs +41 -34
- package/dist/debug/html.js +8 -8
- package/dist/debug/html.mjs +8 -8
- package/dist/dom/compat.d.ts +1 -1
- package/dist/dom/renderer.d.ts +3 -4
- package/dist/dom/template.d.ts +1 -1
- package/dist/dom.js +28 -23
- package/dist/dom.mjs +28 -23
- package/dist/html/writer.d.ts +4 -4
- package/dist/html.js +8 -8
- package/dist/html.mjs +8 -8
- package/dist/translator/index.js +112 -49
- package/dist/translator/util/signals.d.ts +1 -0
- package/package.json +1 -1
package/dist/common/types.d.ts
CHANGED
package/dist/debug/dom.js
CHANGED
@@ -239,20 +239,13 @@ function on(element, type, handler) {
|
|
239
239
|
if (!handlersByElement.has(element)) {
|
240
240
|
defaultDelegator(element, type, handleDelegated);
|
241
241
|
}
|
242
|
-
handlersByElement.set(element, handler ||
|
242
|
+
handlersByElement.set(element, handler || null);
|
243
243
|
}
|
244
244
|
function createDelegator() {
|
245
|
-
const
|
245
|
+
const kEvents = Symbol();
|
246
246
|
return function ensureDelegated(node, type, handler) {
|
247
247
|
const root = node.getRootNode();
|
248
|
-
|
249
|
-
if (!delegatedEvents) {
|
250
|
-
delegatedEventsByRoot.set(root, delegatedEvents = /* @__PURE__ */ new Set());
|
251
|
-
}
|
252
|
-
if (!delegatedEvents.has(type)) {
|
253
|
-
delegatedEvents.add(type);
|
254
|
-
root.addEventListener(type, handler, true);
|
255
|
-
}
|
248
|
+
(root[kEvents] ||= {})[type] ||= (root.addEventListener(type, handler, true), 1);
|
256
249
|
};
|
257
250
|
}
|
258
251
|
function handleDelegated(ev) {
|
@@ -386,9 +379,10 @@ var Render = class {
|
|
386
379
|
curParent.prepend(startNode);
|
387
380
|
}
|
388
381
|
this.___currentScopeId = this.___scopeStack.pop();
|
389
|
-
} else if (token === "|" /* BranchSingleNode */) {
|
382
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
390
383
|
let next = data3.indexOf(" ");
|
391
|
-
let curNode =
|
384
|
+
let curNode = visit;
|
385
|
+
scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
|
392
386
|
while (~next) {
|
393
387
|
const start = next + 1;
|
394
388
|
next = data3.indexOf(" ", start);
|
@@ -627,7 +621,7 @@ function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
|
627
621
|
}
|
628
622
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
629
623
|
const el = scope[nodeAccessor];
|
630
|
-
|
624
|
+
const onChange = () => {
|
631
625
|
const valueChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
632
626
|
if (valueChange) {
|
633
627
|
scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */;
|
@@ -643,7 +637,19 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
643
637
|
);
|
644
638
|
}
|
645
639
|
}
|
646
|
-
}
|
640
|
+
};
|
641
|
+
if (!controllableHandlers.has(el)) {
|
642
|
+
new MutationObserver(() => {
|
643
|
+
const value2 = scope[nodeAccessor + ":" /* ControlledValue */];
|
644
|
+
if (Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) {
|
645
|
+
onChange();
|
646
|
+
}
|
647
|
+
}).observe(el, {
|
648
|
+
childList: true,
|
649
|
+
subtree: true
|
650
|
+
});
|
651
|
+
}
|
652
|
+
syncControllable(el, "input", hasSelectChanged, onChange);
|
647
653
|
}
|
648
654
|
function setSelectOptions(el, value2, valueChange) {
|
649
655
|
if (Array.isArray(value2)) {
|
@@ -726,25 +732,27 @@ function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
|
726
732
|
scope[nodeAccessor].defaultChecked = checked;
|
727
733
|
}
|
728
734
|
}
|
729
|
-
var
|
730
|
-
var
|
735
|
+
var controllableDelegate = createDelegator();
|
736
|
+
var controllableHandlers = /* @__PURE__ */ new WeakMap();
|
731
737
|
function syncControllable(el, event, hasChanged, onChange) {
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
738
|
+
if (!controllableHandlers.has(el)) {
|
739
|
+
controllableDelegate(el, event, handleChange);
|
740
|
+
if (el.form) {
|
741
|
+
controllableDelegate(el.form, "reset", handleFormReset);
|
742
|
+
}
|
743
|
+
if (isResuming && hasChanged(el)) {
|
744
|
+
queueMicrotask(onChange);
|
745
|
+
}
|
739
746
|
}
|
747
|
+
controllableHandlers.set(el, onChange);
|
740
748
|
}
|
741
|
-
function
|
742
|
-
|
749
|
+
function handleChange(ev) {
|
750
|
+
controllableHandlers.get(ev.target)?.(ev);
|
743
751
|
}
|
744
|
-
function
|
752
|
+
function handleFormReset(ev) {
|
745
753
|
const handlers = [];
|
746
754
|
for (const el of ev.target.elements) {
|
747
|
-
const handler =
|
755
|
+
const handler = controllableHandlers.get(el);
|
748
756
|
if (handler && hasFormElementChanged(el)) {
|
749
757
|
handlers.push(handler);
|
750
758
|
}
|
@@ -1435,7 +1443,6 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
|
1435
1443
|
___setup: setup,
|
1436
1444
|
___clone: _clone,
|
1437
1445
|
___owner: owner,
|
1438
|
-
___sourceNode: void 0,
|
1439
1446
|
get ___args() {
|
1440
1447
|
return args ||= getArgs?.();
|
1441
1448
|
}
|
@@ -1529,12 +1536,12 @@ var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersecti
|
|
1529
1536
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
1530
1537
|
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */];
|
1531
1538
|
const referenceNode = scope[nodeAccessor];
|
1532
|
-
const newBranch = newRenderer
|
1539
|
+
const newBranch = newRenderer && createBranchScopeWithTagNameOrRenderer(
|
1533
1540
|
newRenderer,
|
1534
1541
|
scope.$global,
|
1535
1542
|
scope,
|
1536
1543
|
referenceNode
|
1537
|
-
)
|
1544
|
+
);
|
1538
1545
|
referenceNode.textContent = "";
|
1539
1546
|
if (newBranch) {
|
1540
1547
|
insertBranchBefore(newBranch, referenceNode, null);
|
@@ -1543,10 +1550,10 @@ function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
|
1543
1550
|
scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1544
1551
|
}
|
1545
1552
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1546
|
-
[Symbol(), getEmptyBranch(
|
1553
|
+
[Symbol(), /* @__PURE__ */ getEmptyBranch(0)]
|
1547
1554
|
]);
|
1548
1555
|
var emptyMarkerArray = [
|
1549
|
-
/* @__PURE__ */ getEmptyBranch(
|
1556
|
+
/* @__PURE__ */ getEmptyBranch(0)
|
1550
1557
|
];
|
1551
1558
|
var emptyMap = /* @__PURE__ */ new Map();
|
1552
1559
|
var emptyArray = [];
|
@@ -1988,7 +1995,7 @@ var compat = {
|
|
1988
1995
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
1989
1996
|
},
|
1990
1997
|
isRenderer(renderer) {
|
1991
|
-
return renderer.___clone
|
1998
|
+
return renderer.___clone;
|
1992
1999
|
},
|
1993
2000
|
getStartNode(branch) {
|
1994
2001
|
return branch.___startNode;
|
@@ -2018,7 +2025,7 @@ var compat = {
|
|
2018
2025
|
return value2;
|
2019
2026
|
},
|
2020
2027
|
createRenderer(setup, clone, args) {
|
2021
|
-
const renderer = createRenderer("",
|
2028
|
+
const renderer = createRenderer("", 0, setup, args && (() => args));
|
2022
2029
|
renderer.___clone = clone;
|
2023
2030
|
return renderer;
|
2024
2031
|
},
|
package/dist/debug/dom.mjs
CHANGED
@@ -153,20 +153,13 @@ function on(element, type, handler) {
|
|
153
153
|
if (!handlersByElement.has(element)) {
|
154
154
|
defaultDelegator(element, type, handleDelegated);
|
155
155
|
}
|
156
|
-
handlersByElement.set(element, handler ||
|
156
|
+
handlersByElement.set(element, handler || null);
|
157
157
|
}
|
158
158
|
function createDelegator() {
|
159
|
-
const
|
159
|
+
const kEvents = Symbol();
|
160
160
|
return function ensureDelegated(node, type, handler) {
|
161
161
|
const root = node.getRootNode();
|
162
|
-
|
163
|
-
if (!delegatedEvents) {
|
164
|
-
delegatedEventsByRoot.set(root, delegatedEvents = /* @__PURE__ */ new Set());
|
165
|
-
}
|
166
|
-
if (!delegatedEvents.has(type)) {
|
167
|
-
delegatedEvents.add(type);
|
168
|
-
root.addEventListener(type, handler, true);
|
169
|
-
}
|
162
|
+
(root[kEvents] ||= {})[type] ||= (root.addEventListener(type, handler, true), 1);
|
170
163
|
};
|
171
164
|
}
|
172
165
|
function handleDelegated(ev) {
|
@@ -300,9 +293,10 @@ var Render = class {
|
|
300
293
|
curParent.prepend(startNode);
|
301
294
|
}
|
302
295
|
this.___currentScopeId = this.___scopeStack.pop();
|
303
|
-
} else if (token === "|" /* BranchSingleNode */) {
|
296
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
304
297
|
let next = data3.indexOf(" ");
|
305
|
-
let curNode =
|
298
|
+
let curNode = visit;
|
299
|
+
scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
|
306
300
|
while (~next) {
|
307
301
|
const start = next + 1;
|
308
302
|
next = data3.indexOf(" ", start);
|
@@ -541,7 +535,7 @@ function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
|
541
535
|
}
|
542
536
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
543
537
|
const el = scope[nodeAccessor];
|
544
|
-
|
538
|
+
const onChange = () => {
|
545
539
|
const valueChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
546
540
|
if (valueChange) {
|
547
541
|
scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */;
|
@@ -557,7 +551,19 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
557
551
|
);
|
558
552
|
}
|
559
553
|
}
|
560
|
-
}
|
554
|
+
};
|
555
|
+
if (!controllableHandlers.has(el)) {
|
556
|
+
new MutationObserver(() => {
|
557
|
+
const value2 = scope[nodeAccessor + ":" /* ControlledValue */];
|
558
|
+
if (Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) {
|
559
|
+
onChange();
|
560
|
+
}
|
561
|
+
}).observe(el, {
|
562
|
+
childList: true,
|
563
|
+
subtree: true
|
564
|
+
});
|
565
|
+
}
|
566
|
+
syncControllable(el, "input", hasSelectChanged, onChange);
|
561
567
|
}
|
562
568
|
function setSelectOptions(el, value2, valueChange) {
|
563
569
|
if (Array.isArray(value2)) {
|
@@ -640,25 +646,27 @@ function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
|
640
646
|
scope[nodeAccessor].defaultChecked = checked;
|
641
647
|
}
|
642
648
|
}
|
643
|
-
var
|
644
|
-
var
|
649
|
+
var controllableDelegate = createDelegator();
|
650
|
+
var controllableHandlers = /* @__PURE__ */ new WeakMap();
|
645
651
|
function syncControllable(el, event, hasChanged, onChange) {
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
652
|
+
if (!controllableHandlers.has(el)) {
|
653
|
+
controllableDelegate(el, event, handleChange);
|
654
|
+
if (el.form) {
|
655
|
+
controllableDelegate(el.form, "reset", handleFormReset);
|
656
|
+
}
|
657
|
+
if (isResuming && hasChanged(el)) {
|
658
|
+
queueMicrotask(onChange);
|
659
|
+
}
|
653
660
|
}
|
661
|
+
controllableHandlers.set(el, onChange);
|
654
662
|
}
|
655
|
-
function
|
656
|
-
|
663
|
+
function handleChange(ev) {
|
664
|
+
controllableHandlers.get(ev.target)?.(ev);
|
657
665
|
}
|
658
|
-
function
|
666
|
+
function handleFormReset(ev) {
|
659
667
|
const handlers = [];
|
660
668
|
for (const el of ev.target.elements) {
|
661
|
-
const handler =
|
669
|
+
const handler = controllableHandlers.get(el);
|
662
670
|
if (handler && hasFormElementChanged(el)) {
|
663
671
|
handlers.push(handler);
|
664
672
|
}
|
@@ -1349,7 +1357,6 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
|
1349
1357
|
___setup: setup,
|
1350
1358
|
___clone: _clone,
|
1351
1359
|
___owner: owner,
|
1352
|
-
___sourceNode: void 0,
|
1353
1360
|
get ___args() {
|
1354
1361
|
return args ||= getArgs?.();
|
1355
1362
|
}
|
@@ -1443,12 +1450,12 @@ var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersecti
|
|
1443
1450
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
1444
1451
|
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */];
|
1445
1452
|
const referenceNode = scope[nodeAccessor];
|
1446
|
-
const newBranch = newRenderer
|
1453
|
+
const newBranch = newRenderer && createBranchScopeWithTagNameOrRenderer(
|
1447
1454
|
newRenderer,
|
1448
1455
|
scope.$global,
|
1449
1456
|
scope,
|
1450
1457
|
referenceNode
|
1451
|
-
)
|
1458
|
+
);
|
1452
1459
|
referenceNode.textContent = "";
|
1453
1460
|
if (newBranch) {
|
1454
1461
|
insertBranchBefore(newBranch, referenceNode, null);
|
@@ -1457,10 +1464,10 @@ function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
|
1457
1464
|
scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1458
1465
|
}
|
1459
1466
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1460
|
-
[Symbol(), getEmptyBranch(
|
1467
|
+
[Symbol(), /* @__PURE__ */ getEmptyBranch(0)]
|
1461
1468
|
]);
|
1462
1469
|
var emptyMarkerArray = [
|
1463
|
-
/* @__PURE__ */ getEmptyBranch(
|
1470
|
+
/* @__PURE__ */ getEmptyBranch(0)
|
1464
1471
|
];
|
1465
1472
|
var emptyMap = /* @__PURE__ */ new Map();
|
1466
1473
|
var emptyArray = [];
|
@@ -1902,7 +1909,7 @@ var compat = {
|
|
1902
1909
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
1903
1910
|
},
|
1904
1911
|
isRenderer(renderer) {
|
1905
|
-
return renderer.___clone
|
1912
|
+
return renderer.___clone;
|
1906
1913
|
},
|
1907
1914
|
getStartNode(branch) {
|
1908
1915
|
return branch.___startNode;
|
@@ -1932,7 +1939,7 @@ var compat = {
|
|
1932
1939
|
return value2;
|
1933
1940
|
},
|
1934
1941
|
createRenderer(setup, clone, args) {
|
1935
|
-
const renderer = createRenderer("",
|
1942
|
+
const renderer = createRenderer("", 0, setup, args && (() => args));
|
1936
1943
|
renderer.___clone = clone;
|
1937
1944
|
return renderer;
|
1938
1945
|
},
|
package/dist/debug/html.js
CHANGED
@@ -1614,7 +1614,7 @@ function resumeForOf(list, cb, scopeId, accessor) {
|
|
1614
1614
|
)
|
1615
1615
|
);
|
1616
1616
|
}
|
1617
|
-
function resumeSingleNodeForOf(list, cb, scopeId, accessor) {
|
1617
|
+
function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
|
1618
1618
|
let branchIds = "";
|
1619
1619
|
forOf(list, (item, index) => {
|
1620
1620
|
const branchId = peekNextScopeId();
|
@@ -1623,7 +1623,7 @@ function resumeSingleNodeForOf(list, cb, scopeId, accessor) {
|
|
1623
1623
|
});
|
1624
1624
|
$chunk.writeHTML(
|
1625
1625
|
$chunk.boundary.state.mark(
|
1626
|
-
"|" /* BranchSingleNode */,
|
1626
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1627
1627
|
scopeId + " " + accessor + branchIds
|
1628
1628
|
)
|
1629
1629
|
);
|
@@ -1645,7 +1645,7 @@ function resumeForIn(obj, cb, scopeId, accessor) {
|
|
1645
1645
|
)
|
1646
1646
|
);
|
1647
1647
|
}
|
1648
|
-
function resumeSingleNodeForIn(obj, cb, scopeId, accessor) {
|
1648
|
+
function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
|
1649
1649
|
let branchIds = "";
|
1650
1650
|
forIn(obj, (key, value) => {
|
1651
1651
|
const branchId = peekNextScopeId();
|
@@ -1654,7 +1654,7 @@ function resumeSingleNodeForIn(obj, cb, scopeId, accessor) {
|
|
1654
1654
|
});
|
1655
1655
|
$chunk.writeHTML(
|
1656
1656
|
$chunk.boundary.state.mark(
|
1657
|
-
"|" /* BranchSingleNode */,
|
1657
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1658
1658
|
scopeId + " " + accessor + branchIds
|
1659
1659
|
)
|
1660
1660
|
);
|
@@ -1676,7 +1676,7 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
|
|
1676
1676
|
)
|
1677
1677
|
);
|
1678
1678
|
}
|
1679
|
-
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor) {
|
1679
|
+
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild) {
|
1680
1680
|
let branchIds = "";
|
1681
1681
|
forTo(to, from, step, (index) => {
|
1682
1682
|
const branchId = peekNextScopeId();
|
@@ -1685,7 +1685,7 @@ function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor) {
|
|
1685
1685
|
});
|
1686
1686
|
$chunk.writeHTML(
|
1687
1687
|
$chunk.boundary.state.mark(
|
1688
|
-
"|" /* BranchSingleNode */,
|
1688
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1689
1689
|
scopeId + " " + accessor + branchIds
|
1690
1690
|
)
|
1691
1691
|
);
|
@@ -1709,7 +1709,7 @@ function resumeConditional(cb, scopeId, accessor) {
|
|
1709
1709
|
)
|
1710
1710
|
);
|
1711
1711
|
}
|
1712
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor) {
|
1712
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, onlyChild) {
|
1713
1713
|
const branchId = peekNextScopeId();
|
1714
1714
|
withContext(branchIdKey, branchId, cb);
|
1715
1715
|
const rendered = peekNextScopeId() !== branchId;
|
@@ -1720,7 +1720,7 @@ function resumeSingleNodeConditional(cb, scopeId, accessor) {
|
|
1720
1720
|
}
|
1721
1721
|
$chunk.writeHTML(
|
1722
1722
|
$chunk.boundary.state.mark(
|
1723
|
-
"|" /* BranchSingleNode */,
|
1723
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1724
1724
|
scopeId + " " + accessor + (rendered ? " " + branchId : "")
|
1725
1725
|
)
|
1726
1726
|
);
|
package/dist/debug/html.mjs
CHANGED
@@ -1532,7 +1532,7 @@ function resumeForOf(list, cb, scopeId, accessor) {
|
|
1532
1532
|
)
|
1533
1533
|
);
|
1534
1534
|
}
|
1535
|
-
function resumeSingleNodeForOf(list, cb, scopeId, accessor) {
|
1535
|
+
function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
|
1536
1536
|
let branchIds = "";
|
1537
1537
|
forOf(list, (item, index) => {
|
1538
1538
|
const branchId = peekNextScopeId();
|
@@ -1541,7 +1541,7 @@ function resumeSingleNodeForOf(list, cb, scopeId, accessor) {
|
|
1541
1541
|
});
|
1542
1542
|
$chunk.writeHTML(
|
1543
1543
|
$chunk.boundary.state.mark(
|
1544
|
-
"|" /* BranchSingleNode */,
|
1544
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1545
1545
|
scopeId + " " + accessor + branchIds
|
1546
1546
|
)
|
1547
1547
|
);
|
@@ -1563,7 +1563,7 @@ function resumeForIn(obj, cb, scopeId, accessor) {
|
|
1563
1563
|
)
|
1564
1564
|
);
|
1565
1565
|
}
|
1566
|
-
function resumeSingleNodeForIn(obj, cb, scopeId, accessor) {
|
1566
|
+
function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
|
1567
1567
|
let branchIds = "";
|
1568
1568
|
forIn(obj, (key, value) => {
|
1569
1569
|
const branchId = peekNextScopeId();
|
@@ -1572,7 +1572,7 @@ function resumeSingleNodeForIn(obj, cb, scopeId, accessor) {
|
|
1572
1572
|
});
|
1573
1573
|
$chunk.writeHTML(
|
1574
1574
|
$chunk.boundary.state.mark(
|
1575
|
-
"|" /* BranchSingleNode */,
|
1575
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1576
1576
|
scopeId + " " + accessor + branchIds
|
1577
1577
|
)
|
1578
1578
|
);
|
@@ -1594,7 +1594,7 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
|
|
1594
1594
|
)
|
1595
1595
|
);
|
1596
1596
|
}
|
1597
|
-
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor) {
|
1597
|
+
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild) {
|
1598
1598
|
let branchIds = "";
|
1599
1599
|
forTo(to, from, step, (index) => {
|
1600
1600
|
const branchId = peekNextScopeId();
|
@@ -1603,7 +1603,7 @@ function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor) {
|
|
1603
1603
|
});
|
1604
1604
|
$chunk.writeHTML(
|
1605
1605
|
$chunk.boundary.state.mark(
|
1606
|
-
"|" /* BranchSingleNode */,
|
1606
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1607
1607
|
scopeId + " " + accessor + branchIds
|
1608
1608
|
)
|
1609
1609
|
);
|
@@ -1627,7 +1627,7 @@ function resumeConditional(cb, scopeId, accessor) {
|
|
1627
1627
|
)
|
1628
1628
|
);
|
1629
1629
|
}
|
1630
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor) {
|
1630
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, onlyChild) {
|
1631
1631
|
const branchId = peekNextScopeId();
|
1632
1632
|
withContext(branchIdKey, branchId, cb);
|
1633
1633
|
const rendered = peekNextScopeId() !== branchId;
|
@@ -1638,7 +1638,7 @@ function resumeSingleNodeConditional(cb, scopeId, accessor) {
|
|
1638
1638
|
}
|
1639
1639
|
$chunk.writeHTML(
|
1640
1640
|
$chunk.boundary.state.mark(
|
1641
|
-
"|" /* BranchSingleNode */,
|
1641
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1642
1642
|
scopeId + " " + accessor + (rendered ? " " + branchId : "")
|
1643
1643
|
)
|
1644
1644
|
);
|
package/dist/dom/compat.d.ts
CHANGED
@@ -7,7 +7,7 @@ export declare const compat: {
|
|
7
7
|
init(warp10Noop: any): void;
|
8
8
|
registerRenderer(fn: any): void;
|
9
9
|
isOp(value: any): boolean;
|
10
|
-
isRenderer(renderer: any):
|
10
|
+
isRenderer(renderer: any): any;
|
11
11
|
getStartNode(branch: any): any;
|
12
12
|
setScopeNodes(branch: any, startNode: Node, endNode: Node): void;
|
13
13
|
runComponentEffects(this: any): void;
|
package/dist/dom/renderer.d.ts
CHANGED
@@ -4,9 +4,8 @@ export type Renderer = {
|
|
4
4
|
___id: symbol;
|
5
5
|
___template: string;
|
6
6
|
___walks: string;
|
7
|
-
___setup: SetupFn | undefined;
|
7
|
+
___setup: SetupFn | undefined | 0;
|
8
8
|
___clone: (ns: string) => ChildNode;
|
9
|
-
___sourceNode: Node | undefined;
|
10
9
|
___args: Signal<unknown> | undefined;
|
11
10
|
___owner: Scope | undefined;
|
12
11
|
};
|
@@ -15,6 +14,6 @@ export declare function createBranchScopeWithRenderer(renderer: Renderer, $globa
|
|
15
14
|
export declare function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer: Renderer | string, $global: Scope["$global"], parentScope: Scope, parentNode: ParentNode): BranchScope;
|
16
15
|
export declare function initBranch(renderer: Renderer, branch: BranchScope, parentNode: ParentNode): void;
|
17
16
|
export declare function dynamicTagAttrs(nodeAccessor: Accessor, getContent?: (scope: Scope) => Renderer, inputIsArgs?: boolean): (scope: Scope, attrsOrOp: (() => Record<string, unknown>) | SignalOp) => void;
|
18
|
-
export declare function createRendererWithOwner(template: string, rawWalks?: string, setup?: SetupFn, getArgs?: () => Signal<unknown>): (owner?: Scope) => Renderer;
|
19
|
-
export declare function createRenderer(template: string, walks?: string, setup?: SetupFn, getArgs?: () => Signal<unknown>): Renderer;
|
17
|
+
export declare function createRendererWithOwner(template: string, rawWalks?: string | 0, setup?: SetupFn | 0, getArgs?: () => Signal<unknown>): (owner?: Scope) => Renderer;
|
18
|
+
export declare function createRenderer(template: string, walks?: string | 0, setup?: SetupFn | 0, getArgs?: () => Signal<unknown>): Renderer;
|
20
19
|
export {};
|
package/dist/dom/template.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
import type { Template } from "../common/types";
|
2
2
|
import { createRenderer } from "./renderer";
|
3
|
-
export declare const createTemplate: (templateId: string, template: string, walks?: string | undefined, setup?: ((scope: import("../common/types").Scope) => void) | undefined, getArgs?: (() => import("./signals").Signal<unknown>) | undefined) => Template;
|
3
|
+
export declare const createTemplate: (templateId: string, template: string, walks?: string | 0 | undefined, setup?: 0 | ((scope: import("../common/types").Scope) => void) | undefined, getArgs?: (() => import("./signals").Signal<unknown>) | undefined) => Template;
|
package/dist/dom.js
CHANGED
@@ -178,13 +178,13 @@ function normalizeDynamicRenderer(value2) {
|
|
178
178
|
var elementHandlersByEvent = /* @__PURE__ */ new Map(), defaultDelegator = createDelegator();
|
179
179
|
function on(element, type, handler) {
|
180
180
|
let handlersByElement = elementHandlersByEvent.get(type);
|
181
|
-
handlersByElement || elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap()), handlersByElement.has(element) || defaultDelegator(element, type, handleDelegated), handlersByElement.set(element, handler ||
|
181
|
+
handlersByElement || elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap()), handlersByElement.has(element) || defaultDelegator(element, type, handleDelegated), handlersByElement.set(element, handler || null);
|
182
182
|
}
|
183
183
|
function createDelegator() {
|
184
|
-
let
|
184
|
+
let kEvents = Symbol();
|
185
185
|
return function(node, type, handler) {
|
186
|
-
let root = node.getRootNode()
|
187
|
-
|
186
|
+
let root = node.getRootNode();
|
187
|
+
(root[kEvents] ||= {})[type] ||= (root.addEventListener(type, handler, !0), 1);
|
188
188
|
};
|
189
189
|
}
|
190
190
|
function handleDelegated(ev) {
|
@@ -267,9 +267,9 @@ var registeredValues = {}, Render = class {
|
|
267
267
|
visit
|
268
268
|
).a;
|
269
269
|
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.n.pop();
|
270
|
-
} else if (token === "|" /* BranchSingleNode */) {
|
271
|
-
let next = data3.indexOf(" "), curNode =
|
272
|
-
for (; ~next; ) {
|
270
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
271
|
+
let next = data3.indexOf(" "), curNode = visit;
|
272
|
+
for (scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
273
273
|
let start = next + 1;
|
274
274
|
next = data3.indexOf(" ", start);
|
275
275
|
let childScopeId = data3.slice(start, ~next ? next : data3.length);
|
@@ -408,8 +408,7 @@ function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
|
408
408
|
);
|
409
409
|
}
|
410
410
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
411
|
-
let el = scope[nodeAccessor]
|
412
|
-
syncControllable(el, "input", hasSelectChanged, () => {
|
411
|
+
let el = scope[nodeAccessor], onChange = () => {
|
413
412
|
let valueChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
414
413
|
valueChange && (scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */, valueChange(
|
415
414
|
Array.isArray(scope[nodeAccessor + ":" /* ControlledValue */]) ? Array.from(el.selectedOptions, toValueProp) : el.value
|
@@ -418,7 +417,14 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
418
417
|
scope[nodeAccessor + ":" /* ControlledValue */],
|
419
418
|
valueChange
|
420
419
|
));
|
421
|
-
}
|
420
|
+
};
|
421
|
+
controllableHandlers.has(el) || new MutationObserver(() => {
|
422
|
+
let value2 = scope[nodeAccessor + ":" /* ControlledValue */];
|
423
|
+
(Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) && onChange();
|
424
|
+
}).observe(el, {
|
425
|
+
childList: !0,
|
426
|
+
subtree: !0
|
427
|
+
}), syncControllable(el, "input", hasSelectChanged, onChange);
|
422
428
|
}
|
423
429
|
function setSelectOptions(el, value2, valueChange) {
|
424
430
|
if (Array.isArray(value2))
|
@@ -470,17 +476,17 @@ function setValueAndUpdateSelection(el, value2) {
|
|
470
476
|
function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
471
477
|
scope[nodeAccessor + ";" /* ControlledHandler */] = checkedChange, checkedChange ? (scope[nodeAccessor + "=" /* ControlledType */] = type, scope[nodeAccessor].checked = checked) : (scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */, scope[nodeAccessor].defaultChecked = checked);
|
472
478
|
}
|
473
|
-
var
|
479
|
+
var controllableDelegate = createDelegator(), controllableHandlers = /* @__PURE__ */ new WeakMap();
|
474
480
|
function syncControllable(el, event, hasChanged, onChange) {
|
475
|
-
|
481
|
+
controllableHandlers.has(el) || (controllableDelegate(el, event, handleChange), el.form && controllableDelegate(el.form, "reset", handleFormReset), isResuming && hasChanged(el) && queueMicrotask(onChange)), controllableHandlers.set(el, onChange);
|
476
482
|
}
|
477
|
-
function
|
478
|
-
|
483
|
+
function handleChange(ev) {
|
484
|
+
controllableHandlers.get(ev.target)?.(ev);
|
479
485
|
}
|
480
|
-
function
|
486
|
+
function handleFormReset(ev) {
|
481
487
|
let handlers = [];
|
482
488
|
for (let el of ev.target.elements) {
|
483
|
-
let handler =
|
489
|
+
let handler = controllableHandlers.get(el);
|
484
490
|
handler && hasFormElementChanged(el) && handlers.push(handler);
|
485
491
|
}
|
486
492
|
requestAnimationFrame(() => {
|
@@ -937,7 +943,6 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
|
937
943
|
x: setup,
|
938
944
|
l: _clone,
|
939
945
|
u: owner,
|
940
|
-
J: void 0,
|
941
946
|
get d() {
|
942
947
|
return args ||= getArgs?.();
|
943
948
|
}
|
@@ -1004,18 +1009,18 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
1004
1009
|
};
|
1005
1010
|
};
|
1006
1011
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
1007
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer
|
1012
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranchScopeWithTagNameOrRenderer(
|
1008
1013
|
newRenderer,
|
1009
1014
|
scope.$global,
|
1010
1015
|
scope,
|
1011
1016
|
referenceNode
|
1012
|
-
)
|
1017
|
+
);
|
1013
1018
|
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1014
1019
|
}
|
1015
1020
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1016
|
-
[Symbol(), getEmptyBranch(
|
1021
|
+
[Symbol(), /* @__PURE__ */ getEmptyBranch(0)]
|
1017
1022
|
]), emptyMarkerArray = [
|
1018
|
-
/* @__PURE__ */ getEmptyBranch(
|
1023
|
+
/* @__PURE__ */ getEmptyBranch(0)
|
1019
1024
|
], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
|
1020
1025
|
function loopOf(nodeAccessor, renderer) {
|
1021
1026
|
return loop(
|
@@ -1278,7 +1283,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1278
1283
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
1279
1284
|
},
|
1280
1285
|
isRenderer(renderer) {
|
1281
|
-
return renderer.l
|
1286
|
+
return renderer.l;
|
1282
1287
|
},
|
1283
1288
|
getStartNode(branch) {
|
1284
1289
|
return branch.a;
|
@@ -1302,7 +1307,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1302
1307
|
) : value2;
|
1303
1308
|
},
|
1304
1309
|
createRenderer(setup, clone, args) {
|
1305
|
-
let renderer = createRenderer("",
|
1310
|
+
let renderer = createRenderer("", 0, setup, args && (() => args));
|
1306
1311
|
return renderer.l = clone, renderer;
|
1307
1312
|
},
|
1308
1313
|
render(out, component, renderer, args) {
|
package/dist/dom.mjs
CHANGED
@@ -95,13 +95,13 @@ function normalizeDynamicRenderer(value2) {
|
|
95
95
|
var elementHandlersByEvent = /* @__PURE__ */ new Map(), defaultDelegator = createDelegator();
|
96
96
|
function on(element, type, handler) {
|
97
97
|
let handlersByElement = elementHandlersByEvent.get(type);
|
98
|
-
handlersByElement || elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap()), handlersByElement.has(element) || defaultDelegator(element, type, handleDelegated), handlersByElement.set(element, handler ||
|
98
|
+
handlersByElement || elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap()), handlersByElement.has(element) || defaultDelegator(element, type, handleDelegated), handlersByElement.set(element, handler || null);
|
99
99
|
}
|
100
100
|
function createDelegator() {
|
101
|
-
let
|
101
|
+
let kEvents = Symbol();
|
102
102
|
return function(node, type, handler) {
|
103
|
-
let root = node.getRootNode()
|
104
|
-
|
103
|
+
let root = node.getRootNode();
|
104
|
+
(root[kEvents] ||= {})[type] ||= (root.addEventListener(type, handler, !0), 1);
|
105
105
|
};
|
106
106
|
}
|
107
107
|
function handleDelegated(ev) {
|
@@ -184,9 +184,9 @@ var registeredValues = {}, Render = class {
|
|
184
184
|
visit
|
185
185
|
).a;
|
186
186
|
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.n.pop();
|
187
|
-
} else if (token === "|" /* BranchSingleNode */) {
|
188
|
-
let next = data3.indexOf(" "), curNode =
|
189
|
-
for (; ~next; ) {
|
187
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
188
|
+
let next = data3.indexOf(" "), curNode = visit;
|
189
|
+
for (scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
190
190
|
let start = next + 1;
|
191
191
|
next = data3.indexOf(" ", start);
|
192
192
|
let childScopeId = data3.slice(start, ~next ? next : data3.length);
|
@@ -325,8 +325,7 @@ function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
|
325
325
|
);
|
326
326
|
}
|
327
327
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
328
|
-
let el = scope[nodeAccessor]
|
329
|
-
syncControllable(el, "input", hasSelectChanged, () => {
|
328
|
+
let el = scope[nodeAccessor], onChange = () => {
|
330
329
|
let valueChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
331
330
|
valueChange && (scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */, valueChange(
|
332
331
|
Array.isArray(scope[nodeAccessor + ":" /* ControlledValue */]) ? Array.from(el.selectedOptions, toValueProp) : el.value
|
@@ -335,7 +334,14 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
335
334
|
scope[nodeAccessor + ":" /* ControlledValue */],
|
336
335
|
valueChange
|
337
336
|
));
|
338
|
-
}
|
337
|
+
};
|
338
|
+
controllableHandlers.has(el) || new MutationObserver(() => {
|
339
|
+
let value2 = scope[nodeAccessor + ":" /* ControlledValue */];
|
340
|
+
(Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) && onChange();
|
341
|
+
}).observe(el, {
|
342
|
+
childList: !0,
|
343
|
+
subtree: !0
|
344
|
+
}), syncControllable(el, "input", hasSelectChanged, onChange);
|
339
345
|
}
|
340
346
|
function setSelectOptions(el, value2, valueChange) {
|
341
347
|
if (Array.isArray(value2))
|
@@ -387,17 +393,17 @@ function setValueAndUpdateSelection(el, value2) {
|
|
387
393
|
function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
388
394
|
scope[nodeAccessor + ";" /* ControlledHandler */] = checkedChange, checkedChange ? (scope[nodeAccessor + "=" /* ControlledType */] = type, scope[nodeAccessor].checked = checked) : (scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */, scope[nodeAccessor].defaultChecked = checked);
|
389
395
|
}
|
390
|
-
var
|
396
|
+
var controllableDelegate = createDelegator(), controllableHandlers = /* @__PURE__ */ new WeakMap();
|
391
397
|
function syncControllable(el, event, hasChanged, onChange) {
|
392
|
-
|
398
|
+
controllableHandlers.has(el) || (controllableDelegate(el, event, handleChange), el.form && controllableDelegate(el.form, "reset", handleFormReset), isResuming && hasChanged(el) && queueMicrotask(onChange)), controllableHandlers.set(el, onChange);
|
393
399
|
}
|
394
|
-
function
|
395
|
-
|
400
|
+
function handleChange(ev) {
|
401
|
+
controllableHandlers.get(ev.target)?.(ev);
|
396
402
|
}
|
397
|
-
function
|
403
|
+
function handleFormReset(ev) {
|
398
404
|
let handlers = [];
|
399
405
|
for (let el of ev.target.elements) {
|
400
|
-
let handler =
|
406
|
+
let handler = controllableHandlers.get(el);
|
401
407
|
handler && hasFormElementChanged(el) && handlers.push(handler);
|
402
408
|
}
|
403
409
|
requestAnimationFrame(() => {
|
@@ -854,7 +860,6 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
|
854
860
|
x: setup,
|
855
861
|
l: _clone,
|
856
862
|
u: owner,
|
857
|
-
J: void 0,
|
858
863
|
get d() {
|
859
864
|
return args ||= getArgs?.();
|
860
865
|
}
|
@@ -921,18 +926,18 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
921
926
|
};
|
922
927
|
};
|
923
928
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
924
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer
|
929
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranchScopeWithTagNameOrRenderer(
|
925
930
|
newRenderer,
|
926
931
|
scope.$global,
|
927
932
|
scope,
|
928
933
|
referenceNode
|
929
|
-
)
|
934
|
+
);
|
930
935
|
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
931
936
|
}
|
932
937
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
933
|
-
[Symbol(), getEmptyBranch(
|
938
|
+
[Symbol(), /* @__PURE__ */ getEmptyBranch(0)]
|
934
939
|
]), emptyMarkerArray = [
|
935
|
-
/* @__PURE__ */ getEmptyBranch(
|
940
|
+
/* @__PURE__ */ getEmptyBranch(0)
|
936
941
|
], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
|
937
942
|
function loopOf(nodeAccessor, renderer) {
|
938
943
|
return loop(
|
@@ -1195,7 +1200,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1195
1200
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
1196
1201
|
},
|
1197
1202
|
isRenderer(renderer) {
|
1198
|
-
return renderer.l
|
1203
|
+
return renderer.l;
|
1199
1204
|
},
|
1200
1205
|
getStartNode(branch) {
|
1201
1206
|
return branch.a;
|
@@ -1219,7 +1224,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1219
1224
|
) : value2;
|
1220
1225
|
},
|
1221
1226
|
createRenderer(setup, clone, args) {
|
1222
|
-
let renderer = createRenderer("",
|
1227
|
+
let renderer = createRenderer("", 0, setup, args && (() => args));
|
1223
1228
|
return renderer.l = clone, renderer;
|
1224
1229
|
},
|
1225
1230
|
render(out, component, renderer, args) {
|
package/dist/html/writer.d.ts
CHANGED
@@ -27,13 +27,13 @@ export declare function markResumeNode(scopeId: number, accessor: Accessor): str
|
|
27
27
|
export declare function nodeRef(scopeId: number, id?: string): () => void;
|
28
28
|
export declare function resumeClosestBranch(scopeId: number): void;
|
29
29
|
export declare function resumeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, scopeId: number, accessor: Accessor): void;
|
30
|
-
export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, scopeId: number, accessor: Accessor): void;
|
30
|
+
export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, scopeId: number, accessor: Accessor, onlyChildInParent?: 1): void;
|
31
31
|
export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, scopeId: number, accessor: Accessor): void;
|
32
|
-
export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, scopeId: number, accessor: Accessor): void;
|
32
|
+
export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, scopeId: number, accessor: Accessor, onlyChild?: 1): void;
|
33
33
|
export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, scopeId: number, accessor: Accessor): void;
|
34
|
-
export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, scopeId: number, accessor: Accessor): void;
|
34
|
+
export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, scopeId: number, accessor: Accessor, onlyChild?: 1): void;
|
35
35
|
export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor): void;
|
36
|
-
export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor): void;
|
36
|
+
export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, onlyChild?: 1): void;
|
37
37
|
export declare function writeScope(scopeId: number, partialScope: PartialScope): ScopeInternals;
|
38
38
|
export declare function writeExistingScope(scope: ScopeInternals): ScopeInternals;
|
39
39
|
export declare function ensureScopeWithId(scopeId: number): PartialScope;
|
package/dist/html.js
CHANGED
@@ -1066,14 +1066,14 @@ function resumeForOf(list, cb, scopeId, accessor) {
|
|
1066
1066
|
)
|
1067
1067
|
);
|
1068
1068
|
}
|
1069
|
-
function resumeSingleNodeForOf(list, cb, scopeId, accessor) {
|
1069
|
+
function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
|
1070
1070
|
let branchIds = "";
|
1071
1071
|
forOf(list, (item, index) => {
|
1072
1072
|
let branchId = peekNextScopeId();
|
1073
1073
|
branchIds = " " + branchId + branchIds, withContext(branchIdKey, branchId, () => cb(item, index));
|
1074
1074
|
}), $chunk.writeHTML(
|
1075
1075
|
$chunk.boundary.state.mark(
|
1076
|
-
"|" /* BranchSingleNode */,
|
1076
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1077
1077
|
scopeId + " " + accessor + branchIds
|
1078
1078
|
)
|
1079
1079
|
);
|
@@ -1092,14 +1092,14 @@ function resumeForIn(obj, cb, scopeId, accessor) {
|
|
1092
1092
|
)
|
1093
1093
|
);
|
1094
1094
|
}
|
1095
|
-
function resumeSingleNodeForIn(obj, cb, scopeId, accessor) {
|
1095
|
+
function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
|
1096
1096
|
let branchIds = "";
|
1097
1097
|
forIn(obj, (key, value) => {
|
1098
1098
|
let branchId = peekNextScopeId();
|
1099
1099
|
branchIds = " " + branchId + branchIds, withContext(branchIdKey, branchId, () => cb(key, value));
|
1100
1100
|
}), $chunk.writeHTML(
|
1101
1101
|
$chunk.boundary.state.mark(
|
1102
|
-
"|" /* BranchSingleNode */,
|
1102
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1103
1103
|
scopeId + " " + accessor + branchIds
|
1104
1104
|
)
|
1105
1105
|
);
|
@@ -1118,14 +1118,14 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
|
|
1118
1118
|
)
|
1119
1119
|
);
|
1120
1120
|
}
|
1121
|
-
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor) {
|
1121
|
+
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild) {
|
1122
1122
|
let branchIds = "";
|
1123
1123
|
forTo(to, from, step, (index) => {
|
1124
1124
|
let branchId = peekNextScopeId();
|
1125
1125
|
branchIds = " " + branchId + branchIds, withContext(branchIdKey, branchId, () => cb(index));
|
1126
1126
|
}), $chunk.writeHTML(
|
1127
1127
|
$chunk.boundary.state.mark(
|
1128
|
-
"|" /* BranchSingleNode */,
|
1128
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1129
1129
|
scopeId + " " + accessor + branchIds
|
1130
1130
|
)
|
1131
1131
|
);
|
@@ -1141,13 +1141,13 @@ function resumeConditional(cb, scopeId, accessor) {
|
|
1141
1141
|
)
|
1142
1142
|
);
|
1143
1143
|
}
|
1144
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor) {
|
1144
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, onlyChild) {
|
1145
1145
|
let branchId = peekNextScopeId();
|
1146
1146
|
withContext(branchIdKey, branchId, cb);
|
1147
1147
|
let rendered = peekNextScopeId() !== branchId;
|
1148
1148
|
rendered ? writeScope(branchId, {}) : nextScopeId(), $chunk.writeHTML(
|
1149
1149
|
$chunk.boundary.state.mark(
|
1150
|
-
"|" /* BranchSingleNode */,
|
1150
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1151
1151
|
scopeId + " " + accessor + (rendered ? " " + branchId : "")
|
1152
1152
|
)
|
1153
1153
|
);
|
package/dist/html.mjs
CHANGED
@@ -987,14 +987,14 @@ function resumeForOf(list, cb, scopeId, accessor) {
|
|
987
987
|
)
|
988
988
|
);
|
989
989
|
}
|
990
|
-
function resumeSingleNodeForOf(list, cb, scopeId, accessor) {
|
990
|
+
function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
|
991
991
|
let branchIds = "";
|
992
992
|
forOf(list, (item, index) => {
|
993
993
|
let branchId = peekNextScopeId();
|
994
994
|
branchIds = " " + branchId + branchIds, withContext(branchIdKey, branchId, () => cb(item, index));
|
995
995
|
}), $chunk.writeHTML(
|
996
996
|
$chunk.boundary.state.mark(
|
997
|
-
"|" /* BranchSingleNode */,
|
997
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
998
998
|
scopeId + " " + accessor + branchIds
|
999
999
|
)
|
1000
1000
|
);
|
@@ -1013,14 +1013,14 @@ function resumeForIn(obj, cb, scopeId, accessor) {
|
|
1013
1013
|
)
|
1014
1014
|
);
|
1015
1015
|
}
|
1016
|
-
function resumeSingleNodeForIn(obj, cb, scopeId, accessor) {
|
1016
|
+
function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
|
1017
1017
|
let branchIds = "";
|
1018
1018
|
forIn(obj, (key, value) => {
|
1019
1019
|
let branchId = peekNextScopeId();
|
1020
1020
|
branchIds = " " + branchId + branchIds, withContext(branchIdKey, branchId, () => cb(key, value));
|
1021
1021
|
}), $chunk.writeHTML(
|
1022
1022
|
$chunk.boundary.state.mark(
|
1023
|
-
"|" /* BranchSingleNode */,
|
1023
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1024
1024
|
scopeId + " " + accessor + branchIds
|
1025
1025
|
)
|
1026
1026
|
);
|
@@ -1039,14 +1039,14 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
|
|
1039
1039
|
)
|
1040
1040
|
);
|
1041
1041
|
}
|
1042
|
-
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor) {
|
1042
|
+
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild) {
|
1043
1043
|
let branchIds = "";
|
1044
1044
|
forTo(to, from, step, (index) => {
|
1045
1045
|
let branchId = peekNextScopeId();
|
1046
1046
|
branchIds = " " + branchId + branchIds, withContext(branchIdKey, branchId, () => cb(index));
|
1047
1047
|
}), $chunk.writeHTML(
|
1048
1048
|
$chunk.boundary.state.mark(
|
1049
|
-
"|" /* BranchSingleNode */,
|
1049
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1050
1050
|
scopeId + " " + accessor + branchIds
|
1051
1051
|
)
|
1052
1052
|
);
|
@@ -1062,13 +1062,13 @@ function resumeConditional(cb, scopeId, accessor) {
|
|
1062
1062
|
)
|
1063
1063
|
);
|
1064
1064
|
}
|
1065
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor) {
|
1065
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, onlyChild) {
|
1066
1066
|
let branchId = peekNextScopeId();
|
1067
1067
|
withContext(branchIdKey, branchId, cb);
|
1068
1068
|
let rendered = peekNextScopeId() !== branchId;
|
1069
1069
|
rendered ? writeScope(branchId, {}) : nextScopeId(), $chunk.writeHTML(
|
1070
1070
|
$chunk.boundary.state.mark(
|
1071
|
-
"|" /* BranchSingleNode */,
|
1071
|
+
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1072
1072
|
scopeId + " " + accessor + (rendered ? " " + branchId : "")
|
1073
1073
|
)
|
1074
1074
|
);
|
package/dist/translator/index.js
CHANGED
@@ -1990,6 +1990,10 @@ function setForceResumeScope(section) {
|
|
1990
1990
|
_setForceResumeScope(section, true);
|
1991
1991
|
}
|
1992
1992
|
var [getSerializedScopeProperties] = createSectionState("serializedScopeProperties", () => /* @__PURE__ */ new Map());
|
1993
|
+
var [getHTMLSectionStatements] = createSectionState(
|
1994
|
+
"htmlScopeStatements",
|
1995
|
+
() => []
|
1996
|
+
);
|
1993
1997
|
var unimplementedBuild = () => {
|
1994
1998
|
return import_compiler17.types.stringLiteral("SIGNAL NOT INITIALIZED");
|
1995
1999
|
};
|
@@ -2680,13 +2684,14 @@ function writeHTMLResumeStatements(path5) {
|
|
2680
2684
|
)
|
2681
2685
|
);
|
2682
2686
|
}
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2687
|
+
const additionalStatements = getHTMLSectionStatements(section);
|
2688
|
+
if (path5.get("body").length || additionalStatements.length) {
|
2689
|
+
path5.unshiftContainer("body", [
|
2686
2690
|
import_compiler17.types.variableDeclaration("const", [
|
2687
2691
|
import_compiler17.types.variableDeclarator(scopeIdIdentifier, callRuntime("nextScopeId"))
|
2688
|
-
])
|
2689
|
-
|
2692
|
+
]),
|
2693
|
+
...additionalStatements
|
2694
|
+
]);
|
2690
2695
|
}
|
2691
2696
|
const returnIdentifier = getSectionReturnValueIdentifier(section);
|
2692
2697
|
if (returnIdentifier !== void 0) {
|
@@ -4524,7 +4529,9 @@ var native_tag_default = {
|
|
4524
4529
|
const tagName2 = node.name.type === "StringLiteral" ? node.name.value : import_compiler28.types.toIdentifier(tag.get("name"));
|
4525
4530
|
const tagExtra = node.extra ??= {};
|
4526
4531
|
const bindingName = "#" + tagName2;
|
4527
|
-
|
4532
|
+
if (hasEventHandlers || node.var) {
|
4533
|
+
tagExtra[kSerializeMarker] = true;
|
4534
|
+
}
|
4528
4535
|
tagExtra[kNativeTagBinding] = createBinding(
|
4529
4536
|
bindingName,
|
4530
4537
|
0 /* dom */,
|
@@ -4905,9 +4912,9 @@ var native_tag_default = {
|
|
4905
4912
|
import_compiler28.types.ifStatement(tag.node.name, consumeHTML(tag))
|
4906
4913
|
)[0].skip();
|
4907
4914
|
}
|
4908
|
-
if (nodeRef2 && (extra[kSerializeMarker] || isStatefulReferences(extra.referencedBindings) || tag.node.attributes.some(
|
4915
|
+
if (nodeRef2 && (extra[kSerializeMarker] || extra[kSerializeMarker] === void 0 && (isStatefulReferences(extra.referencedBindings) || tag.node.attributes.some(
|
4909
4916
|
(attr2) => isStatefulReferences(attr2.value.extra?.referencedBindings)
|
4910
|
-
))) {
|
4917
|
+
)))) {
|
4911
4918
|
markNode(tag, nodeRef2);
|
4912
4919
|
}
|
4913
4920
|
exit2(tag);
|
@@ -5086,17 +5093,18 @@ var for_default = {
|
|
5086
5093
|
const tagExtra = node.extra;
|
5087
5094
|
const isStateful = isStatefulReferences(tagExtra.referencedBindings);
|
5088
5095
|
const parentTag = getParentTag(tag);
|
5089
|
-
const
|
5096
|
+
const onlyChildInParentOptimization = isOnlyChildInParent(tag);
|
5097
|
+
const nodeRef2 = onlyChildInParentOptimization ? parentTag.node.extra[kNativeTagBinding] : tag.node.extra[kForMarkerBinding];
|
5090
5098
|
const forAttrs = getKnownAttrValues(node);
|
5091
5099
|
const forType = getForType(node);
|
5092
5100
|
const params = node.body.params;
|
5093
5101
|
const statements = [];
|
5094
5102
|
const bodyStatements = node.body.body;
|
5095
5103
|
const hasStatefulClosures = checkStatefulClosures(bodySection, true);
|
5096
|
-
const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild
|
5104
|
+
const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild && bodySection.content.startType !== 4 /* Text */;
|
5097
5105
|
let keyExpression;
|
5098
|
-
if (
|
5099
|
-
parentTag.node.extra[kSerializeMarker] =
|
5106
|
+
if (singleNodeOptimization && onlyChildInParentOptimization) {
|
5107
|
+
parentTag.node.extra[kSerializeMarker] = false;
|
5100
5108
|
}
|
5101
5109
|
if (isStateful || hasStatefulClosures) {
|
5102
5110
|
const defaultParamNames = {
|
@@ -5150,7 +5158,7 @@ var for_default = {
|
|
5150
5158
|
keyExpression = params[defaultByParamIndex];
|
5151
5159
|
}
|
5152
5160
|
const forScopesIdentifier = getScopeIdentifier(bodySection);
|
5153
|
-
|
5161
|
+
getHTMLSectionStatements(tagSection).push(
|
5154
5162
|
import_compiler29.types.variableDeclaration("const", [
|
5155
5163
|
import_compiler29.types.variableDeclarator(
|
5156
5164
|
forScopesIdentifier,
|
@@ -5203,6 +5211,9 @@ var for_default = {
|
|
5203
5211
|
getScopeAccessorLiteral(nodeRef2)
|
5204
5212
|
);
|
5205
5213
|
}
|
5214
|
+
if (singleNodeOptimization && onlyChildInParentOptimization) {
|
5215
|
+
forTagArgs.push(import_compiler29.types.numericLiteral(1));
|
5216
|
+
}
|
5206
5217
|
statements.push(
|
5207
5218
|
import_compiler29.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
|
5208
5219
|
);
|
@@ -6946,7 +6957,7 @@ var IfTag = {
|
|
6946
6957
|
if (branchBodySection) {
|
6947
6958
|
branchBodySection.isBranch = true;
|
6948
6959
|
branchBodySection.upstreamExpression = rootExtra;
|
6949
|
-
if (!(branchBodySection.content === null || branchBodySection.content?.singleChild)) {
|
6960
|
+
if (!(branchBodySection.content === null || branchBodySection.content?.singleChild && branchBodySection.content.startType !== 4 /* Text */)) {
|
6950
6961
|
singleNodeOptimization = false;
|
6951
6962
|
}
|
6952
6963
|
}
|
@@ -7087,16 +7098,16 @@ var IfTag = {
|
|
7087
7098
|
)
|
7088
7099
|
);
|
7089
7100
|
}
|
7090
|
-
nextTag.insertBefore(
|
7101
|
+
nextTag.insertBefore(statement);
|
7102
|
+
getHTMLSectionStatements(section).push(
|
7091
7103
|
import_compiler38.types.variableDeclaration(
|
7092
7104
|
"let",
|
7093
7105
|
[
|
7094
7106
|
import_compiler38.types.variableDeclarator(ifScopeIdIdentifier),
|
7095
7107
|
isStateful && import_compiler38.types.variableDeclarator(ifRendererIdentifier)
|
7096
7108
|
].filter(Boolean)
|
7097
|
-
)
|
7098
|
-
|
7099
|
-
]);
|
7109
|
+
)
|
7110
|
+
);
|
7100
7111
|
getSerializedScopeProperties(section).set(
|
7101
7112
|
import_compiler38.types.stringLiteral(
|
7102
7113
|
getScopeAccessorLiteral(nodeRef2).value + "!" /* ConditionalScope */
|
@@ -8037,6 +8048,7 @@ var function_default = {
|
|
8037
8048
|
if (index === void 0) {
|
8038
8049
|
functionNameCounts.set(name2, 0);
|
8039
8050
|
} else {
|
8051
|
+
functionNameCounts.set(name2, index + 1);
|
8040
8052
|
id = `_${index}`;
|
8041
8053
|
}
|
8042
8054
|
extra.section = section;
|
@@ -9318,6 +9330,7 @@ var dynamic_tag_default = {
|
|
9318
9330
|
|
9319
9331
|
// src/translator/visitors/tag/index.ts
|
9320
9332
|
var TAG_NAME_IDENTIFIER_REG = /^[A-Z][a-zA-Z0-9_$]*$/;
|
9333
|
+
var BINDING_CHANGE_HANDLER = /* @__PURE__ */ new WeakMap();
|
9321
9334
|
var tag_default = {
|
9322
9335
|
transform: {
|
9323
9336
|
enter(tag) {
|
@@ -9335,18 +9348,7 @@ var tag_default = {
|
|
9335
9348
|
const attr2 = attributes[i];
|
9336
9349
|
if (import_compiler53.types.isMarkoAttribute(attr2) && attr2.bound) {
|
9337
9350
|
attr2.bound = false;
|
9338
|
-
|
9339
|
-
if (changeValue === null) {
|
9340
|
-
throw tag.hub.buildError(
|
9341
|
-
attr2,
|
9342
|
-
"Attributes may only be bound to identifiers or member expressions"
|
9343
|
-
);
|
9344
|
-
}
|
9345
|
-
attributes.splice(
|
9346
|
-
++i,
|
9347
|
-
0,
|
9348
|
-
import_compiler53.types.markoAttribute(attr2.name + "Change", changeValue)
|
9349
|
-
);
|
9351
|
+
attributes.splice(++i, 0, getChangeHandler(tag, attr2));
|
9350
9352
|
crawl = true;
|
9351
9353
|
}
|
9352
9354
|
}
|
@@ -9466,33 +9468,94 @@ var tag_default = {
|
|
9466
9468
|
}
|
9467
9469
|
};
|
9468
9470
|
function getChangeHandler(tag, attr2) {
|
9471
|
+
const attrName = attr2.name;
|
9472
|
+
const changeAttrName = attrName + "Change";
|
9469
9473
|
if (import_compiler53.types.isIdentifier(attr2.value)) {
|
9470
|
-
const
|
9471
|
-
|
9472
|
-
|
9473
|
-
|
9474
|
-
|
9475
|
-
|
9474
|
+
const binding = tag.scope.getBinding(attr2.value.name);
|
9475
|
+
if (!binding)
|
9476
|
+
return import_compiler53.types.markoAttribute(
|
9477
|
+
changeAttrName,
|
9478
|
+
buildChangeHandlerFunction(attr2.value)
|
9479
|
+
);
|
9480
|
+
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
9481
|
+
if (!existingChangedAttr) {
|
9482
|
+
const changeHandlerAttr = import_compiler53.types.markoAttribute(
|
9483
|
+
changeAttrName,
|
9484
|
+
buildChangeHandlerFunction(attr2.value)
|
9485
|
+
);
|
9486
|
+
BINDING_CHANGE_HANDLER.set(binding.identifier, changeHandlerAttr);
|
9487
|
+
return changeHandlerAttr;
|
9488
|
+
}
|
9489
|
+
if (existingChangedAttr.type === "Identifier") {
|
9490
|
+
return import_compiler53.types.markoAttribute(
|
9491
|
+
changeAttrName,
|
9492
|
+
withPreviousLocation(
|
9493
|
+
import_compiler53.types.identifier(existingChangedAttr.name),
|
9494
|
+
attr2.value
|
9476
9495
|
)
|
9477
|
-
|
9496
|
+
);
|
9497
|
+
}
|
9498
|
+
const markoRoot = isMarko(binding.path) ? binding.path : getMarkoRoot(binding.path);
|
9499
|
+
if (!(markoRoot?.isMarkoTag() || markoRoot?.isMarkoTagBody())) {
|
9500
|
+
throw tag.hub.buildError(attr2.value, "Unable to bind to value.");
|
9501
|
+
}
|
9502
|
+
const changeHandlerId = markoRoot.scope.generateUid(changeAttrName);
|
9503
|
+
const changeHandlerConst = import_compiler53.types.markoTag(
|
9504
|
+
import_compiler53.types.stringLiteral("const"),
|
9505
|
+
[import_compiler53.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
|
9506
|
+
import_compiler53.types.markoTagBody([]),
|
9507
|
+
null,
|
9508
|
+
import_compiler53.types.identifier(changeHandlerId)
|
9509
|
+
);
|
9510
|
+
BINDING_CHANGE_HANDLER.set(
|
9511
|
+
binding.identifier,
|
9512
|
+
existingChangedAttr.value = import_compiler53.types.identifier(changeHandlerId)
|
9513
|
+
);
|
9514
|
+
if (markoRoot.isMarkoTag()) {
|
9515
|
+
markoRoot.insertAfter(changeHandlerConst);
|
9516
|
+
} else {
|
9517
|
+
markoRoot.unshiftContainer("body", changeHandlerConst);
|
9518
|
+
}
|
9519
|
+
return import_compiler53.types.markoAttribute(
|
9520
|
+
changeAttrName,
|
9521
|
+
withPreviousLocation(import_compiler53.types.identifier(changeHandlerId), attr2.value)
|
9478
9522
|
);
|
9479
9523
|
} else if (import_compiler53.types.isMemberExpression(attr2.value)) {
|
9480
9524
|
const prop = attr2.value.property;
|
9481
|
-
if (import_compiler53.types.isPrivateName(
|
9482
|
-
|
9483
|
-
|
9484
|
-
import_compiler53.types.
|
9485
|
-
|
9486
|
-
|
9487
|
-
|
9488
|
-
|
9489
|
-
|
9490
|
-
|
9491
|
-
|
9525
|
+
if (!import_compiler53.types.isPrivateName(attr2.value.property)) {
|
9526
|
+
return import_compiler53.types.markoAttribute(
|
9527
|
+
changeAttrName,
|
9528
|
+
import_compiler53.types.memberExpression(
|
9529
|
+
import_compiler53.types.cloneNode(attr2.value.object),
|
9530
|
+
prop.type === "Identifier" ? withPreviousLocation(import_compiler53.types.identifier(prop.name + "Change"), prop) : import_compiler53.types.binaryExpression(
|
9531
|
+
"+",
|
9532
|
+
import_compiler53.types.cloneNode(prop),
|
9533
|
+
import_compiler53.types.stringLiteral("Change")
|
9534
|
+
),
|
9535
|
+
prop.type !== "Identifier"
|
9536
|
+
)
|
9492
9537
|
);
|
9493
9538
|
}
|
9494
9539
|
}
|
9495
|
-
|
9540
|
+
throw tag.hub.buildError(
|
9541
|
+
attr2.value,
|
9542
|
+
"Attributes may only be bound to identifiers or member expressions"
|
9543
|
+
);
|
9544
|
+
}
|
9545
|
+
function buildChangeHandlerFunction(id) {
|
9546
|
+
const newId = "_new_" + id.name;
|
9547
|
+
return import_compiler53.types.arrowFunctionExpression(
|
9548
|
+
[withPreviousLocation(import_compiler53.types.identifier(newId), id)],
|
9549
|
+
import_compiler53.types.blockStatement([
|
9550
|
+
import_compiler53.types.expressionStatement(
|
9551
|
+
import_compiler53.types.assignmentExpression(
|
9552
|
+
"=",
|
9553
|
+
withPreviousLocation(import_compiler53.types.identifier(id.name), id),
|
9554
|
+
withPreviousLocation(import_compiler53.types.identifier(newId), id)
|
9555
|
+
)
|
9556
|
+
)
|
9557
|
+
])
|
9558
|
+
);
|
9496
9559
|
}
|
9497
9560
|
|
9498
9561
|
// src/translator/visitors/text.ts
|
@@ -38,6 +38,7 @@ export type Signal = {
|
|
38
38
|
export declare function setClosureSignalBuilder(tag: t.NodePath<t.MarkoTag>, builder: closureSignalBuilder): void;
|
39
39
|
export declare function setForceResumeScope(section: Section): void;
|
40
40
|
export declare const getSerializedScopeProperties: (section: Section) => Map<t.StringLiteral | t.NumericLiteral, t.Expression>;
|
41
|
+
export declare const getHTMLSectionStatements: (section: Section) => t.Statement[];
|
41
42
|
export declare function getSignal(section: Section, referencedBindings: ReferencedBindings, name?: string): Signal;
|
42
43
|
export declare function initValue(binding: Binding, runtimeHelper?: "value" | "state"): Signal;
|
43
44
|
export declare function getSignalFn(signal: Signal, params: Array<t.Identifier | t.Pattern>, referencedBindings?: ReferencedBindings): t.ArrowFunctionExpression;
|