marko 6.0.0-next.3.36 → 6.0.0-next.3.38
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 +87 -86
- package/dist/debug/dom.mjs +87 -86
- package/dist/debug/html.js +8 -8
- package/dist/debug/html.mjs +8 -8
- package/dist/dom/compat.d.ts +3 -3
- package/dist/dom/control-flow.d.ts +4 -5
- package/dist/dom/renderer.d.ts +3 -4
- package/dist/dom/signals.d.ts +1 -2
- package/dist/dom/template.d.ts +1 -1
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +92 -87
- package/dist/dom.mjs +92 -87
- package/dist/html/writer.d.ts +4 -4
- package/dist/html.js +8 -8
- package/dist/html.mjs +8 -8
- package/dist/translator/core/for.d.ts +0 -9
- package/dist/translator/core/if.d.ts +0 -8
- package/dist/translator/index.js +630 -567
- package/dist/translator/util/is-only-child-in-parent.d.ts +14 -0
- package/dist/translator/util/signals.d.ts +1 -0
- package/package.json +1 -1
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
@@ -1,13 +1,13 @@
|
|
1
|
-
import {
|
1
|
+
import { patchDynamicTag } from "./control-flow";
|
2
2
|
import { queueEffect } from "./queue";
|
3
3
|
import { type Renderer } from "./renderer";
|
4
4
|
export declare const compat: {
|
5
|
-
patchConditionals: typeof
|
5
|
+
patchConditionals: typeof patchDynamicTag;
|
6
6
|
queueEffect: typeof queueEffect;
|
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;
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import { type Accessor, type BranchScope, type Scope } from "../common/types";
|
2
2
|
import { type Renderer } from "./renderer";
|
3
3
|
import { type Signal, type SignalOp } from "./signals";
|
4
|
-
export declare function
|
5
|
-
export declare
|
6
|
-
export declare
|
7
|
-
export declare
|
8
|
-
export declare function setConditionalRendererOnlyChild(scope: Scope, nodeAccessor: Accessor, newRenderer: Renderer | string | undefined): void;
|
4
|
+
export declare function conditional(nodeAccessor: Accessor, ...branches: Renderer[]): Signal<number>;
|
5
|
+
export declare function patchDynamicTag(fn: <T extends typeof dynamicTag>(cond: T) => T): void;
|
6
|
+
export declare let dynamicTag: (nodeAccessor: Accessor, fn?: ((scope: Scope) => void) | 0, getIntersection?: () => Signal<never>) => Signal<Renderer | string | undefined>;
|
7
|
+
export declare function setConditionalRendererOnlyChild<T>(scope: Scope, nodeAccessor: Accessor, newRenderer: T, createBranch: (renderer: NonNullable<T>, $global: Scope["$global"], parentScope: Scope, parentNode: ParentNode) => BranchScope): void;
|
9
8
|
export declare const emptyMarkerArray: BranchScope[];
|
10
9
|
export declare function loopOf(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, valueOrOp: SignalOp | [all: unknown[], by?: ((item: unknown, index: number) => unknown) | undefined]) => void;
|
11
10
|
export declare function loopIn(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, valueOrOp: SignalOp | [obj: {}, by?: ((key: string, v: unknown) => unknown) | undefined]) => 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/signals.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { type Accessor, type Scope } from "../common/types";
|
2
|
-
import type { Renderer } from "./renderer";
|
3
2
|
export declare const MARK: unique symbol;
|
4
3
|
export declare const CLEAN: unique symbol;
|
5
4
|
export declare const DIRTY: unique symbol;
|
@@ -13,7 +12,7 @@ export declare function value<T>(valueAccessor: Accessor, fn: SignalFn<T> | 0, g
|
|
13
12
|
export declare function intersection(count: number, fn: SignalFn<never>, getIntersection?: () => Signal<never>): Signal<never>;
|
14
13
|
export declare function closure<T>(fn: SignalFn<T> | 0, getIntersection?: () => Signal<never>): Signal<T>;
|
15
14
|
export declare function loopClosure<T>(ownerLoopNodeAccessor: Accessor, fn: SignalFn<T> | 0, getIntersection?: () => Signal<never>): SignalFn<T>;
|
16
|
-
export declare function conditionalClosure<T>(ownerConditionalNodeAccessor: Accessor,
|
15
|
+
export declare function conditionalClosure<T>(ownerConditionalNodeAccessor: Accessor, branch: number, fn: SignalFn<T> | 0, getIntersection?: () => Signal<never>): SignalFn<T>;
|
17
16
|
export declare function dynamicClosure<T>(fn: Signal<T> | 0, getOwnerScope?: (scope: Scope) => Scope, getIntersection?: () => Signal<never>): SignalFn<T>;
|
18
17
|
export declare function setTagVar(scope: Scope, childAccessor: Accessor, tagVarSignal: Signal<unknown>): void;
|
19
18
|
export declare const tagVarSignal: (scope: Scope, valueOrOp: unknown | SignalOp) => any;
|
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.d.ts
CHANGED
@@ -2,7 +2,7 @@ export { attrTag, attrTags } from "./common/attr-tag";
|
|
2
2
|
export { forIn, forOf, forTo } from "./common/for";
|
3
3
|
export { getAbortSignal, resetAbortSignal } from "./dom/abort-signal";
|
4
4
|
export { compat } from "./dom/compat";
|
5
|
-
export { conditional,
|
5
|
+
export { conditional, dynamicTag, loopIn, loopOf, loopTo, } from "./dom/control-flow";
|
6
6
|
export { controllable_detailsOrDialog_open, controllable_detailsOrDialog_open_effect, controllable_input_checked, controllable_input_checked_effect, controllable_input_checkedValue, controllable_input_checkedValue_effect, controllable_input_value, controllable_input_value_effect, controllable_select_value, controllable_select_value_effect, controllable_textarea_value, controllable_textarea_value_effect, } from "./dom/controllable";
|
7
7
|
export { attr, attrs, attrsEvents, classAttr, data, html, lifecycle, partialAttrs, props, styleAttr, textContent, } from "./dom/dom";
|
8
8
|
export { on } from "./dom/event";
|
package/dist/dom.js
CHANGED
@@ -26,7 +26,6 @@ __export(dom_exports, {
|
|
26
26
|
compat: () => compat,
|
27
27
|
conditional: () => conditional,
|
28
28
|
conditionalClosure: () => conditionalClosure,
|
29
|
-
conditionalOnlyChild: () => conditionalOnlyChild,
|
30
29
|
controllable_detailsOrDialog_open: () => controllable_detailsOrDialog_open,
|
31
30
|
controllable_detailsOrDialog_open_effect: () => controllable_detailsOrDialog_open_effect,
|
32
31
|
controllable_input_checked: () => controllable_input_checked,
|
@@ -44,6 +43,7 @@ __export(dom_exports, {
|
|
44
43
|
createTemplate: () => createTemplate,
|
45
44
|
data: () => data,
|
46
45
|
dynamicClosure: () => dynamicClosure,
|
46
|
+
dynamicTag: () => dynamicTag,
|
47
47
|
dynamicTagAttrs: () => dynamicTagAttrs,
|
48
48
|
effect: () => effect,
|
49
49
|
forIn: () => forIn,
|
@@ -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) {
|
@@ -224,19 +224,19 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
224
224
|
|
225
225
|
// src/dom/resume.ts
|
226
226
|
var registeredValues = {}, Render = class {
|
227
|
-
|
228
|
-
|
227
|
+
m = [];
|
228
|
+
n = {};
|
229
229
|
A = {
|
230
230
|
_: registeredValues
|
231
231
|
};
|
232
232
|
constructor(renders, runtimeId, renderId) {
|
233
|
-
this.B = renders, this.C = runtimeId, this.
|
233
|
+
this.B = renders, this.C = runtimeId, this.o = renderId, this.p = renders[renderId], this.q();
|
234
234
|
}
|
235
235
|
w() {
|
236
|
-
this.
|
236
|
+
this.p.w(), this.q();
|
237
237
|
}
|
238
|
-
|
239
|
-
let data2 = this.
|
238
|
+
q() {
|
239
|
+
let data2 = this.p, serializeContext = this.A, scopeLookup = this.n, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
240
240
|
if (visits.length) {
|
241
241
|
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
|
242
242
|
data2.v = [];
|
@@ -258,7 +258,7 @@ var registeredValues = {}, Render = class {
|
|
258
258
|
else if (token === "$" /* ClosestBranch */)
|
259
259
|
closestBranchMarkers.set(scopeId, visit);
|
260
260
|
else if (token === "[" /* BranchStart */)
|
261
|
-
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.
|
261
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.m.push(this.e)), this.e = scopeId, scope.a = visit;
|
262
262
|
else if (token === "]" /* BranchEnd */) {
|
263
263
|
scope[data3] = visit;
|
264
264
|
let curParent = visit.parentNode, startNode = branchEnd(
|
@@ -266,10 +266,10 @@ var registeredValues = {}, Render = class {
|
|
266
266
|
visit,
|
267
267
|
visit
|
268
268
|
).a;
|
269
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.
|
270
|
-
} else if (token === "|" /* BranchSingleNode */) {
|
271
|
-
let next = data3.indexOf(" "), curNode =
|
272
|
-
for (; ~next; ) {
|
269
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.m.pop();
|
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);
|
@@ -287,7 +287,7 @@ var registeredValues = {}, Render = class {
|
|
287
287
|
let resumeData = resumes[i++];
|
288
288
|
if (typeof resumeData == "function") {
|
289
289
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
290
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.C, $global.renderId = this.
|
290
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.C, $global.renderId = this.o);
|
291
291
|
for (let scopeId in scopes)
|
292
292
|
if (scopeId !== "$") {
|
293
293
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -298,10 +298,10 @@ var registeredValues = {}, Render = class {
|
|
298
298
|
let parentBranchId = parentBranchIds.get(scopeId);
|
299
299
|
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
300
300
|
let branch = scope, parentBranch = branch.c;
|
301
|
-
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.
|
301
|
+
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.s = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch));
|
302
302
|
}
|
303
303
|
}
|
304
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.B[this.
|
304
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.B[this.o] : registeredValues[resumes[i++]](
|
305
305
|
scopeLookup[resumeData],
|
306
306
|
scopeLookup[resumeData]
|
307
307
|
);
|
@@ -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(() => {
|
@@ -734,10 +740,10 @@ function getEmptyBranch(marker) {
|
|
734
740
|
return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
|
735
741
|
}
|
736
742
|
function destroyBranch(branch) {
|
737
|
-
branch.
|
743
|
+
branch.s?.j?.delete(branch), destroyNestedBranches(branch);
|
738
744
|
}
|
739
745
|
function destroyNestedBranches(branch) {
|
740
|
-
branch.E = 1, branch.
|
746
|
+
branch.E = 1, branch.j?.forEach(destroyNestedBranches), branch.F?.forEach((scope) => {
|
741
747
|
for (let id in scope.h)
|
742
748
|
scope.h[id]?.abort();
|
743
749
|
});
|
@@ -876,7 +882,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
|
|
876
882
|
function createBranchScopeWithRenderer(renderer, $global, parentScope, parentNode) {
|
877
883
|
let branch = createBranch(
|
878
884
|
$global,
|
879
|
-
renderer.
|
885
|
+
renderer.t || parentScope,
|
880
886
|
parentScope
|
881
887
|
);
|
882
888
|
return initBranch(renderer, branch, parentNode), branch;
|
@@ -897,11 +903,11 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
897
903
|
}
|
898
904
|
function createBranch($global, ownerScope, parentScope) {
|
899
905
|
let branch = createScope($global), parentBranch = parentScope.c;
|
900
|
-
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.
|
906
|
+
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.s = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
|
901
907
|
}
|
902
908
|
function initBranch(renderer, branch, parentNode) {
|
903
|
-
let clone = renderer.
|
904
|
-
walk(cloneParent?.firstChild || clone, renderer.G, branch), branch.a = cloneParent?.firstChild || clone, branch.b = cloneParent?.lastChild || clone, renderer.
|
909
|
+
let clone = renderer.k(parentNode.namespaceURI), cloneParent = clone.parentNode;
|
910
|
+
walk(cloneParent?.firstChild || clone, renderer.G, branch), branch.a = cloneParent?.firstChild || clone, branch.b = cloneParent?.lastChild || clone, renderer.u && queueRender(branch, renderer.u);
|
905
911
|
}
|
906
912
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
907
913
|
return (scope, attrsOrOp) => {
|
@@ -913,7 +919,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
913
919
|
return renderer.d?.(childScope, attrsOrOp);
|
914
920
|
let content = getContent?.(scope);
|
915
921
|
if (typeof renderer == "string")
|
916
|
-
setConditionalRendererOnlyChild(
|
922
|
+
setConditionalRendererOnlyChild(
|
923
|
+
childScope,
|
924
|
+
0,
|
925
|
+
content,
|
926
|
+
createBranchScopeWithTagNameOrRenderer
|
927
|
+
), attrs(childScope, 0, attrsOrOp());
|
917
928
|
else if (renderer.d) {
|
918
929
|
let attributes = attrsOrOp();
|
919
930
|
renderer.d(
|
@@ -931,13 +942,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
931
942
|
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
932
943
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
933
944
|
return (owner) => ({
|
934
|
-
|
945
|
+
x: id,
|
935
946
|
y: template,
|
936
947
|
G: walks,
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
J: void 0,
|
948
|
+
u: setup,
|
949
|
+
k: _clone,
|
950
|
+
t: owner,
|
941
951
|
get d() {
|
942
952
|
return args ||= getArgs?.();
|
943
953
|
}
|
@@ -959,63 +969,58 @@ function createCloneableHTML(html2, ns) {
|
|
959
969
|
}
|
960
970
|
|
961
971
|
// src/dom/control-flow.ts
|
962
|
-
function
|
963
|
-
|
972
|
+
function conditional(nodeAccessor, ...branches) {
|
973
|
+
let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
974
|
+
return (scope, newBranchIndexOrOp) => {
|
975
|
+
newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN && (scope[nodeAccessor].nodeType > 1 /* Element */ ? setConditionalRenderer : setConditionalRendererOnlyChild)(
|
976
|
+
scope,
|
977
|
+
nodeAccessor,
|
978
|
+
branches[scope[branchAccessor] = newBranchIndexOrOp],
|
979
|
+
createBranchScopeWithRenderer
|
980
|
+
);
|
981
|
+
};
|
982
|
+
}
|
983
|
+
function patchDynamicTag(fn) {
|
984
|
+
dynamicTag = fn(dynamicTag);
|
964
985
|
}
|
965
|
-
var
|
986
|
+
var dynamicTag = function(nodeAccessor, fn, getIntersection) {
|
966
987
|
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
967
988
|
return (scope, newRendererOrOp) => {
|
968
989
|
if (newRendererOrOp === DIRTY) return;
|
969
990
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
970
991
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
971
992
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
972
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(
|
993
|
+
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(
|
994
|
+
scope,
|
995
|
+
nodeAccessor,
|
996
|
+
normalizedRenderer,
|
997
|
+
createBranchScopeWithTagNameOrRenderer
|
998
|
+
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
973
999
|
}
|
974
1000
|
intersection2?.(scope, op);
|
975
1001
|
};
|
976
1002
|
};
|
977
|
-
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
978
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ?
|
1003
|
+
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1004
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranch2(
|
979
1005
|
newRenderer,
|
980
1006
|
scope.$global,
|
981
1007
|
scope,
|
982
1008
|
prevBranch.b.parentNode
|
983
1009
|
) : getEmptyBranch(scope[nodeAccessor]);
|
984
|
-
insertBranchBefore(
|
1010
|
+
prevBranch !== newBranch && (insertBranchBefore(
|
985
1011
|
newBranch,
|
986
1012
|
prevBranch.b.parentNode,
|
987
1013
|
prevBranch.b.nextSibling
|
988
|
-
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
1014
|
+
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch);
|
989
1015
|
}
|
990
|
-
|
991
|
-
let
|
992
|
-
return (scope, newRendererOrOp) => {
|
993
|
-
if (newRendererOrOp === DIRTY) return;
|
994
|
-
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
995
|
-
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
996
|
-
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
997
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (currentRenderer = scope[rendererAccessor] = normalizedRenderer, setConditionalRendererOnlyChild(
|
998
|
-
scope,
|
999
|
-
nodeAccessor,
|
1000
|
-
normalizedRenderer
|
1001
|
-
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1002
|
-
}
|
1003
|
-
intersection2?.(scope, op);
|
1004
|
-
};
|
1005
|
-
};
|
1006
|
-
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
1007
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(
|
1008
|
-
newRenderer,
|
1009
|
-
scope.$global,
|
1010
|
-
scope,
|
1011
|
-
referenceNode
|
1012
|
-
) : void 0;
|
1016
|
+
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer, createBranch2) {
|
1017
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranch2(newRenderer, scope.$global, scope, referenceNode);
|
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(
|
@@ -1073,7 +1078,7 @@ function byFirstArg(name) {
|
|
1073
1078
|
return name;
|
1074
1079
|
}
|
1075
1080
|
function isDifferentRenderer(a, b) {
|
1076
|
-
return a !== b && (a?.
|
1081
|
+
return a !== b && (a?.x || 0) !== b?.x;
|
1077
1082
|
}
|
1078
1083
|
|
1079
1084
|
// src/dom/signals.ts
|
@@ -1118,10 +1123,10 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
|
1118
1123
|
};
|
1119
1124
|
return helperSignal._ = signal, helperSignal;
|
1120
1125
|
}
|
1121
|
-
function conditionalClosure(ownerConditionalNodeAccessor,
|
1122
|
-
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */,
|
1123
|
-
let
|
1124
|
-
|
1126
|
+
function conditionalClosure(ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
1127
|
+
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1128
|
+
let ifScope = scope[scopeAccessor];
|
1129
|
+
ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, signal, value2);
|
1125
1130
|
};
|
1126
1131
|
return helperSignal._ = signal, helperSignal;
|
1127
1132
|
}
|
@@ -1180,7 +1185,7 @@ function queueSource(scope, signal, value2) {
|
|
1180
1185
|
}
|
1181
1186
|
function queueRender(scope, signal, value2) {
|
1182
1187
|
let i = pendingRenders.length, render = {
|
1183
|
-
|
1188
|
+
l: scope,
|
1184
1189
|
H: signal,
|
1185
1190
|
I: value2,
|
1186
1191
|
z: i
|
@@ -1236,7 +1241,7 @@ function runRenders() {
|
|
1236
1241
|
}
|
1237
1242
|
pendingRenders[i] = item;
|
1238
1243
|
}
|
1239
|
-
render.
|
1244
|
+
render.l.c?.E || render.H(render.l, render.I);
|
1240
1245
|
}
|
1241
1246
|
finishPendingScopes();
|
1242
1247
|
}
|
@@ -1244,7 +1249,7 @@ function comparePendingRenders(a, b) {
|
|
1244
1249
|
return getBranchDepth(a) - getBranchDepth(b) || a.z - b.z;
|
1245
1250
|
}
|
1246
1251
|
function getBranchDepth(render) {
|
1247
|
-
return render.
|
1252
|
+
return render.l.c?.f || 0;
|
1248
1253
|
}
|
1249
1254
|
|
1250
1255
|
// src/dom/abort-signal.ts
|
@@ -1264,7 +1269,7 @@ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID =
|
|
1264
1269
|
|
1265
1270
|
// src/dom/compat.ts
|
1266
1271
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1267
|
-
patchConditionals,
|
1272
|
+
patchConditionals: patchDynamicTag,
|
1268
1273
|
queueEffect,
|
1269
1274
|
init(warp10Noop) {
|
1270
1275
|
register(SET_SCOPE_REGISTER_ID, (branch) => {
|
@@ -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.
|
1286
|
+
return renderer.k;
|
1282
1287
|
},
|
1283
1288
|
getStartNode(branch) {
|
1284
1289
|
return branch.a;
|
@@ -1298,12 +1303,12 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1298
1303
|
}) {
|
1299
1304
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1300
1305
|
value2[0],
|
1301
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1306
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.n[value2[1]]
|
1302
1307
|
) : value2;
|
1303
1308
|
},
|
1304
1309
|
createRenderer(setup, clone, args) {
|
1305
|
-
let renderer = createRenderer("",
|
1306
|
-
return renderer.
|
1310
|
+
let renderer = createRenderer("", 0, setup, args && (() => args));
|
1311
|
+
return renderer.k = clone, renderer;
|
1307
1312
|
},
|
1308
1313
|
render(out, component, renderer, args) {
|
1309
1314
|
let branch = component.scope;
|
@@ -1315,7 +1320,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1315
1320
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1316
1321
|
}
|
1317
1322
|
if (component.effects = prepareEffects(() => {
|
1318
|
-
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.
|
1323
|
+
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.t, initBranch(renderer, branch, document.body)), applyArgs(branch, args);
|
1319
1324
|
}), !existing)
|
1320
1325
|
return toInsertNode(branch.a, branch.b);
|
1321
1326
|
}
|