marko 6.0.0-3.9 → 6.0.0-next.3.16
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/debug/dom.js +28 -22
- package/dist/debug/dom.mjs +28 -22
- package/dist/debug/html.js +36 -31
- package/dist/debug/html.mjs +36 -31
- package/dist/dom/compat.d.ts +1 -1
- package/dist/dom/renderer.d.ts +1 -1
- package/dist/dom/signals.d.ts +1 -1
- package/dist/dom.js +24 -19
- package/dist/dom.mjs +24 -19
- package/dist/html/attrs.d.ts +1 -1
- package/dist/html/dynamic-tag.d.ts +4 -4
- package/dist/html/writer.d.ts +5 -5
- package/dist/html.js +28 -23
- package/dist/html.mjs +28 -23
- package/dist/translator/index.d.ts +2 -0
- package/dist/translator/index.js +98 -63
- package/dist/translator/util/entry-builder.d.ts +1 -0
- package/dist/translator/util/runtime.d.ts +1 -0
- package/dist/translator/util/translate-attrs.d.ts +5 -3
- package/index.d.ts +144 -0
- package/package.json +24 -10
- package/tags-html.d.ts +3935 -0
package/dist/debug/html.mjs
CHANGED
@@ -77,7 +77,7 @@ function isVoid(value) {
|
|
77
77
|
return value == null || value === false;
|
78
78
|
}
|
79
79
|
function normalizeDynamicRenderer(value) {
|
80
|
-
if (value) return value.
|
80
|
+
if (value) return value.content || value.default || value;
|
81
81
|
}
|
82
82
|
|
83
83
|
// src/html/content.ts
|
@@ -1472,9 +1472,9 @@ function ensureScopeWithId(scopeId) {
|
|
1472
1472
|
function $global() {
|
1473
1473
|
return $chunk.boundary.state.$global;
|
1474
1474
|
}
|
1475
|
-
function fork(promise,
|
1475
|
+
function fork(promise, content) {
|
1476
1476
|
if (!isPromise(promise)) {
|
1477
|
-
|
1477
|
+
content(promise);
|
1478
1478
|
return;
|
1479
1479
|
}
|
1480
1480
|
const chunk = $chunk;
|
@@ -1490,7 +1490,7 @@ function fork(promise, renderBody) {
|
|
1490
1490
|
if (chunk.async) {
|
1491
1491
|
chunk.async = false;
|
1492
1492
|
if (!boundary.signal.aborted) {
|
1493
|
-
chunk.render(
|
1493
|
+
chunk.render(content, value);
|
1494
1494
|
boundary.endAsync(chunk);
|
1495
1495
|
}
|
1496
1496
|
}
|
@@ -1501,27 +1501,27 @@ function fork(promise, renderBody) {
|
|
1501
1501
|
}
|
1502
1502
|
);
|
1503
1503
|
}
|
1504
|
-
function tryPlaceholder(
|
1504
|
+
function tryPlaceholder(content, placeholder) {
|
1505
1505
|
const chunk = $chunk;
|
1506
1506
|
const { boundary } = chunk;
|
1507
1507
|
const body = new Chunk(boundary, null, chunk.context);
|
1508
|
-
if (body === body.render(
|
1508
|
+
if (body === body.render(content)) {
|
1509
1509
|
chunk.append(body);
|
1510
1510
|
return;
|
1511
1511
|
}
|
1512
1512
|
chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context);
|
1513
1513
|
chunk.placeholderBody = body;
|
1514
|
-
chunk.placeholderRender =
|
1514
|
+
chunk.placeholderRender = placeholder;
|
1515
1515
|
}
|
1516
|
-
function tryCatch(
|
1516
|
+
function tryCatch(content, catchContent) {
|
1517
1517
|
const chunk = $chunk;
|
1518
1518
|
const { boundary } = chunk;
|
1519
1519
|
const { state } = boundary;
|
1520
1520
|
const catchBoundary = new Boundary(state);
|
1521
1521
|
const body = new Chunk(catchBoundary, null, chunk.context);
|
1522
|
-
const bodyEnd = body.render(
|
1522
|
+
const bodyEnd = body.render(content);
|
1523
1523
|
if (catchBoundary.signal.aborted) {
|
1524
|
-
|
1524
|
+
catchContent(catchBoundary.signal.reason);
|
1525
1525
|
return;
|
1526
1526
|
}
|
1527
1527
|
if (body === bodyEnd) {
|
@@ -1559,7 +1559,7 @@ function tryCatch(renderBody, renderCatch) {
|
|
1559
1559
|
}
|
1560
1560
|
const catchChunk = new Chunk(boundary, null, chunk.context);
|
1561
1561
|
catchChunk.reorderId = reorderId;
|
1562
|
-
catchChunk.render(
|
1562
|
+
catchChunk.render(catchContent, catchBoundary.signal.reason);
|
1563
1563
|
state.reorder(catchChunk);
|
1564
1564
|
boundary.endAsync();
|
1565
1565
|
} else if (catchBoundary.done) {
|
@@ -1742,11 +1742,11 @@ var Chunk = class {
|
|
1742
1742
|
}
|
1743
1743
|
return cur;
|
1744
1744
|
}
|
1745
|
-
render(
|
1745
|
+
render(content, val) {
|
1746
1746
|
const prev = $chunk;
|
1747
1747
|
$chunk = this;
|
1748
1748
|
try {
|
1749
|
-
|
1749
|
+
content(val);
|
1750
1750
|
return $chunk;
|
1751
1751
|
} catch (err) {
|
1752
1752
|
this.boundary.abort(err);
|
@@ -1959,7 +1959,7 @@ function optionValueAttr(value) {
|
|
1959
1959
|
return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? ` selected` : "");
|
1960
1960
|
}
|
1961
1961
|
var kSelectedValue = Symbol("selectedValue");
|
1962
|
-
function controllable_select_value(scopeId, nodeAccessor, value, valueChange,
|
1962
|
+
function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
|
1963
1963
|
if (valueChange) {
|
1964
1964
|
writeControlledScope(
|
1965
1965
|
3 /* SelectValue */,
|
@@ -1969,8 +1969,8 @@ function controllable_select_value(scopeId, nodeAccessor, value, valueChange, re
|
|
1969
1969
|
valueChange
|
1970
1970
|
);
|
1971
1971
|
}
|
1972
|
-
if (
|
1973
|
-
withContext(kSelectedValue, value,
|
1972
|
+
if (content) {
|
1973
|
+
withContext(kSelectedValue, value, content);
|
1974
1974
|
}
|
1975
1975
|
}
|
1976
1976
|
function controllable_textarea_value(scopeId, nodeAccessor, value, valueChange) {
|
@@ -2106,7 +2106,7 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
|
|
2106
2106
|
result += styleAttr(val);
|
2107
2107
|
break;
|
2108
2108
|
case "":
|
2109
|
-
case "
|
2109
|
+
case "content":
|
2110
2110
|
break;
|
2111
2111
|
default:
|
2112
2112
|
if (!isVoid(val)) {
|
@@ -2184,13 +2184,13 @@ var DEFAULT_RENDER_ID = "_";
|
|
2184
2184
|
|
2185
2185
|
// src/html/dynamic-tag.ts
|
2186
2186
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
2187
|
-
function dynamicTagInput(scope, tag, input,
|
2188
|
-
if (!tag && !
|
2187
|
+
function dynamicTagInput(scope, tag, input, content, tagVar) {
|
2188
|
+
if (!tag && !content) return void 0;
|
2189
2189
|
const scopeId = getScopeId(scope);
|
2190
2190
|
write(`${markResumeScopeStart(scopeId)}`);
|
2191
2191
|
writeScope(scopeId, scope);
|
2192
2192
|
if (!tag) {
|
2193
|
-
return
|
2193
|
+
return content();
|
2194
2194
|
}
|
2195
2195
|
if (typeof tag === "string") {
|
2196
2196
|
nextScopeId();
|
@@ -2199,9 +2199,9 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2199
2199
|
);
|
2200
2200
|
if (!voidElementsReg.test(tag)) {
|
2201
2201
|
if (tag === "textarea") {
|
2202
|
-
if (
|
2202
|
+
if (content) {
|
2203
2203
|
throw new Error(
|
2204
|
-
"A dynamic tag rendering a `<textarea>` cannot have
|
2204
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
2205
2205
|
);
|
2206
2206
|
}
|
2207
2207
|
write(
|
@@ -2212,24 +2212,22 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2212
2212
|
input.valueChange
|
2213
2213
|
)
|
2214
2214
|
);
|
2215
|
-
} else if (
|
2215
|
+
} else if (content) {
|
2216
2216
|
if (tag === "select" && ("value" in input || "valueChange" in input)) {
|
2217
2217
|
controllable_select_value(
|
2218
2218
|
scopeId,
|
2219
2219
|
true ? `#${tag}/0` : 0,
|
2220
2220
|
input.value,
|
2221
2221
|
input.valueChange,
|
2222
|
-
|
2222
|
+
content
|
2223
2223
|
);
|
2224
2224
|
} else {
|
2225
|
-
|
2225
|
+
content();
|
2226
2226
|
}
|
2227
2227
|
}
|
2228
2228
|
write(`</${tag}>`);
|
2229
|
-
} else if (
|
2230
|
-
throw new Error(
|
2231
|
-
`A renderBody was provided for a "${tag}" tag, which cannot have children.`
|
2232
|
-
);
|
2229
|
+
} else if (content) {
|
2230
|
+
throw new Error(`Body content is not supported for a "${tag}" tag.`);
|
2233
2231
|
}
|
2234
2232
|
return null;
|
2235
2233
|
}
|
@@ -2239,7 +2237,7 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2239
2237
|
throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
|
2240
2238
|
}
|
2241
2239
|
}
|
2242
|
-
return renderer(
|
2240
|
+
return renderer(content ? { ...input, content } : input, tagVar);
|
2243
2241
|
}
|
2244
2242
|
function dynamicTagArgs(scope, tag, args) {
|
2245
2243
|
if (!tag) return void 0;
|
@@ -2316,13 +2314,20 @@ var compat = {
|
|
2316
2314
|
null,
|
2317
2315
|
null
|
2318
2316
|
);
|
2317
|
+
let normalizedInput = input;
|
2318
|
+
if ("renderBody" in input) {
|
2319
|
+
normalizedInput = {};
|
2320
|
+
for (const key in input) {
|
2321
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
2322
|
+
}
|
2323
|
+
}
|
2319
2324
|
head.render(() => {
|
2320
2325
|
if (willRerender) {
|
2321
2326
|
const scopeId = peekNextScopeId();
|
2322
2327
|
writeScope(scopeId, { m5c: component.id });
|
2323
2328
|
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
2324
2329
|
}
|
2325
|
-
renderer(
|
2330
|
+
renderer(normalizedInput);
|
2326
2331
|
});
|
2327
2332
|
const asyncOut = classAPIOut.beginAsync();
|
2328
2333
|
(boundary.onNext = () => {
|
package/dist/dom/compat.d.ts
CHANGED
@@ -16,5 +16,5 @@ export declare const compat: {
|
|
16
16
|
componentIdPrefix: string;
|
17
17
|
}): any;
|
18
18
|
createRenderer(setup: Renderer["___setup"], clone: Renderer["___clone"], args: Renderer["___args"]): Renderer;
|
19
|
-
render(out: any, component: any, renderer: Renderer,
|
19
|
+
render(out: any, component: any, renderer: Renderer, args: any): (Node & ChildNode) | ParentNode | null | undefined;
|
20
20
|
};
|
package/dist/dom/renderer.d.ts
CHANGED
@@ -15,7 +15,7 @@ type SetupFn = (scope: Scope) => void;
|
|
15
15
|
export declare function createScopeWithRenderer(renderer: Renderer, $global: Scope["___global"], ownerScope?: Scope): Scope;
|
16
16
|
export declare function createScopeWithTagNameOrRenderer(tagNameOrRenderer: Renderer | string, $global: Scope["___global"], ownerScope?: Scope): Scope;
|
17
17
|
export declare function initRenderer(renderer: Renderer, scope: Scope): Node;
|
18
|
-
export declare function dynamicTagAttrs(nodeAccessor: Accessor,
|
18
|
+
export declare function dynamicTagAttrs(nodeAccessor: Accessor, getContent?: (scope: Scope) => Renderer, inputIsArgs?: boolean): (scope: Scope, attrsOrOp: (() => Record<string, unknown>) | SignalOp) => void;
|
19
19
|
export declare function createRendererWithOwner(template: string, rawWalks?: string, setup?: SetupFn, getClosureSignals?: () => IntersectionSignal[], getArgs?: () => ValueSignal): (owner?: Scope) => Renderer;
|
20
20
|
export declare function createRenderer(template: string, walks?: string, setup?: SetupFn, getClosureSignals?: () => IntersectionSignal[], getArgs?: () => ValueSignal): Renderer;
|
21
21
|
export {};
|
package/dist/dom/signals.d.ts
CHANGED
@@ -31,7 +31,7 @@ export declare function setTagVar(scope: Scope, childAccessor: Accessor, tagVarS
|
|
31
31
|
export declare const tagVarSignal: (scope: Scope, valueOrOp: unknown | SignalOp) => any;
|
32
32
|
export declare function setTagVarChange(scope: Scope, changeHandler: (value: unknown) => void): void;
|
33
33
|
export declare const tagVarSignalChange: (scope: Scope, value: unknown) => any;
|
34
|
-
export declare const
|
34
|
+
export declare const contentClosures: (content: Renderer | string | undefined, childScope: Scope, op: SignalOp) => void;
|
35
35
|
export declare const inMany: (scopes: Scope[], op: SignalOp, signal: IntersectionSignal) => void;
|
36
36
|
export declare function nextTagId({ $global }: Scope): string;
|
37
37
|
export declare function inChild(childAccessor: Accessor, signal: ValueSignal): (scope: Scope, valueOrOp: unknown | SignalOp) => void;
|
package/dist/dom.js
CHANGED
@@ -389,8 +389,8 @@ var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrO
|
|
389
389
|
function setTagVarChange(scope, changeHandler) {
|
390
390
|
scope["@" /* TagVariableChange */] = changeHandler;
|
391
391
|
}
|
392
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2),
|
393
|
-
let signals =
|
392
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2), contentClosures = (content, childScope, op) => {
|
393
|
+
let signals = content?.c;
|
394
394
|
if (signals)
|
395
395
|
for (let signal of signals)
|
396
396
|
signal(childScope, op);
|
@@ -515,7 +515,7 @@ function getEventHandlerName(name) {
|
|
515
515
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
516
516
|
}
|
517
517
|
function normalizeDynamicRenderer(value2) {
|
518
|
-
if (value2) return value2.
|
518
|
+
if (value2) return value2.content || value2.default || value2;
|
519
519
|
}
|
520
520
|
|
521
521
|
// src/dom/reconcile.ts
|
@@ -731,14 +731,14 @@ function controllable_detailsOrDialog_open(scope, nodeAccessor, open, openChange
|
|
731
731
|
scope[nodeAccessor + ";" /* ControlledHandler */] = openChange, openChange ? scope[nodeAccessor + "=" /* ControlledType */] = 4 /* DetailsOrDialogOpen */ : scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */, scope[nodeAccessor].open = normalizeBoolProp(open);
|
732
732
|
}
|
733
733
|
function controllable_detailsOrDialog_open_effect(scope, nodeAccessor) {
|
734
|
-
let el = scope[nodeAccessor];
|
734
|
+
let el = scope[nodeAccessor], hasChanged = () => el.open !== scope[nodeAccessor + ":" /* ControlledValue */];
|
735
735
|
syncControllable(
|
736
736
|
el,
|
737
737
|
el.tagName === "DIALOG" ? "close" : "toggle",
|
738
|
-
|
738
|
+
hasChanged,
|
739
739
|
() => {
|
740
740
|
let openChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
741
|
-
openChange && (scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */, openChange(el.open), run(), scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */ && (el.open = !el.open));
|
741
|
+
openChange && hasChanged() && (scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */, openChange(el.open), run(), scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */ && (el.open = !el.open));
|
742
742
|
}
|
743
743
|
);
|
744
744
|
}
|
@@ -810,7 +810,7 @@ function toValueProp(it) {
|
|
810
810
|
}
|
811
811
|
|
812
812
|
// src/dom/parse-html.ts
|
813
|
-
var fallback = document.createTextNode(""), parser = /* @__PURE__ */ new Range();
|
813
|
+
var fallback = /* @__PURE__ */ document.createTextNode(""), parser = /* @__PURE__ */ new Range();
|
814
814
|
function parseHTML(html2) {
|
815
815
|
return parser.createContextualFragment(html2);
|
816
816
|
}
|
@@ -925,7 +925,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
925
925
|
case "style":
|
926
926
|
styleAttr(el, value2);
|
927
927
|
break;
|
928
|
-
case "
|
928
|
+
case "content":
|
929
929
|
break;
|
930
930
|
default:
|
931
931
|
isEventHandler(name) ? (events ||= scope[nodeAccessor + "~" /* EventAttributes */] = {})[getEventHandlerName(name)] = value2 : skip?.test(name) || attr(el, name, value2);
|
@@ -1054,7 +1054,7 @@ function initRenderer(renderer, scope) {
|
|
1054
1054
|
scope
|
1055
1055
|
), scope.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, scope.b = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.s && renderer.s(scope), dom;
|
1056
1056
|
}
|
1057
|
-
function dynamicTagAttrs(nodeAccessor,
|
1057
|
+
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
1058
1058
|
return (scope, attrsOrOp) => {
|
1059
1059
|
let renderer = scope[nodeAccessor + "(" /* ConditionalRenderer */];
|
1060
1060
|
if (!renderer || attrsOrOp === DIRTY)
|
@@ -1062,17 +1062,17 @@ function dynamicTagAttrs(nodeAccessor, getRenderBody, inputIsArgs) {
|
|
1062
1062
|
let childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
|
1063
1063
|
if (attrsOrOp === MARK || attrsOrOp === CLEAN)
|
1064
1064
|
return renderer.e?.(childScope, attrsOrOp);
|
1065
|
-
let
|
1065
|
+
let content = getContent?.(scope);
|
1066
1066
|
if (typeof renderer == "string")
|
1067
|
-
setConditionalRendererOnlyChild(childScope, 0,
|
1067
|
+
setConditionalRendererOnlyChild(childScope, 0, content), attrs(childScope, 0, attrsOrOp());
|
1068
1068
|
else if (renderer.e) {
|
1069
1069
|
let attributes = attrsOrOp();
|
1070
1070
|
renderer.e(
|
1071
1071
|
childScope,
|
1072
1072
|
inputIsArgs ? attributes : [
|
1073
|
-
|
1073
|
+
content ? {
|
1074
1074
|
...attributes,
|
1075
|
-
|
1075
|
+
content
|
1076
1076
|
} : attributes
|
1077
1077
|
]
|
1078
1078
|
);
|
@@ -1125,7 +1125,7 @@ var conditional = function(nodeAccessor, fn, getIntersection) {
|
|
1125
1125
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
1126
1126
|
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (currentRenderer = scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1127
1127
|
}
|
1128
|
-
intersection2?.(scope, op),
|
1128
|
+
intersection2?.(scope, op), contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1129
1129
|
};
|
1130
1130
|
};
|
1131
1131
|
function inConditionalScope(signal, nodeAccessor) {
|
@@ -1163,7 +1163,7 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
1163
1163
|
normalizedRenderer
|
1164
1164
|
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1165
1165
|
}
|
1166
|
-
intersection2?.(scope, op),
|
1166
|
+
intersection2?.(scope, op), contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1167
1167
|
};
|
1168
1168
|
};
|
1169
1169
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
@@ -1301,13 +1301,18 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1301
1301
|
);
|
1302
1302
|
return renderer.k = clone, renderer;
|
1303
1303
|
},
|
1304
|
-
render(out, component, renderer,
|
1304
|
+
render(out, component, renderer, args) {
|
1305
1305
|
let scope = component.scope;
|
1306
1306
|
scope || (scope = classIdToScope.get(component.id), scope && (component.scope = scope, classIdToScope.delete(component.id)));
|
1307
|
-
let
|
1307
|
+
let applyArgs = renderer.e || noop, existing = !1;
|
1308
|
+
if (typeof args[0] == "object" && "renderBody" in args[0]) {
|
1309
|
+
let input = args[0], normalizedInput = args[0] = {};
|
1310
|
+
for (let key in input)
|
1311
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1312
|
+
}
|
1308
1313
|
if (component.effects = prepareEffects(() => {
|
1309
1314
|
if (scope)
|
1310
|
-
|
1315
|
+
applyArgs(scope, MARK), existing = !0;
|
1311
1316
|
else {
|
1312
1317
|
scope = component.scope = createScopeWithRenderer(renderer, out.global);
|
1313
1318
|
let closures = renderer.c;
|
@@ -1315,7 +1320,7 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1315
1320
|
for (let signal of closures)
|
1316
1321
|
signal(component.scope, CLEAN);
|
1317
1322
|
}
|
1318
|
-
|
1323
|
+
applyArgs(scope, args);
|
1319
1324
|
}), !existing)
|
1320
1325
|
return scope.a === scope.b ? scope.a : scope.a.parentNode;
|
1321
1326
|
}
|
package/dist/dom.mjs
CHANGED
@@ -302,8 +302,8 @@ var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrO
|
|
302
302
|
function setTagVarChange(scope, changeHandler) {
|
303
303
|
scope["@" /* TagVariableChange */] = changeHandler;
|
304
304
|
}
|
305
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2),
|
306
|
-
let signals =
|
305
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2), contentClosures = (content, childScope, op) => {
|
306
|
+
let signals = content?.c;
|
307
307
|
if (signals)
|
308
308
|
for (let signal of signals)
|
309
309
|
signal(childScope, op);
|
@@ -428,7 +428,7 @@ function getEventHandlerName(name) {
|
|
428
428
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
429
429
|
}
|
430
430
|
function normalizeDynamicRenderer(value2) {
|
431
|
-
if (value2) return value2.
|
431
|
+
if (value2) return value2.content || value2.default || value2;
|
432
432
|
}
|
433
433
|
|
434
434
|
// src/dom/reconcile.ts
|
@@ -644,14 +644,14 @@ function controllable_detailsOrDialog_open(scope, nodeAccessor, open, openChange
|
|
644
644
|
scope[nodeAccessor + ";" /* ControlledHandler */] = openChange, openChange ? scope[nodeAccessor + "=" /* ControlledType */] = 4 /* DetailsOrDialogOpen */ : scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */, scope[nodeAccessor].open = normalizeBoolProp(open);
|
645
645
|
}
|
646
646
|
function controllable_detailsOrDialog_open_effect(scope, nodeAccessor) {
|
647
|
-
let el = scope[nodeAccessor];
|
647
|
+
let el = scope[nodeAccessor], hasChanged = () => el.open !== scope[nodeAccessor + ":" /* ControlledValue */];
|
648
648
|
syncControllable(
|
649
649
|
el,
|
650
650
|
el.tagName === "DIALOG" ? "close" : "toggle",
|
651
|
-
|
651
|
+
hasChanged,
|
652
652
|
() => {
|
653
653
|
let openChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
654
|
-
openChange && (scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */, openChange(el.open), run(), scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */ && (el.open = !el.open));
|
654
|
+
openChange && hasChanged() && (scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */, openChange(el.open), run(), scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */ && (el.open = !el.open));
|
655
655
|
}
|
656
656
|
);
|
657
657
|
}
|
@@ -723,7 +723,7 @@ function toValueProp(it) {
|
|
723
723
|
}
|
724
724
|
|
725
725
|
// src/dom/parse-html.ts
|
726
|
-
var fallback = document.createTextNode(""), parser = /* @__PURE__ */ new Range();
|
726
|
+
var fallback = /* @__PURE__ */ document.createTextNode(""), parser = /* @__PURE__ */ new Range();
|
727
727
|
function parseHTML(html2) {
|
728
728
|
return parser.createContextualFragment(html2);
|
729
729
|
}
|
@@ -838,7 +838,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
838
838
|
case "style":
|
839
839
|
styleAttr(el, value2);
|
840
840
|
break;
|
841
|
-
case "
|
841
|
+
case "content":
|
842
842
|
break;
|
843
843
|
default:
|
844
844
|
isEventHandler(name) ? (events ||= scope[nodeAccessor + "~" /* EventAttributes */] = {})[getEventHandlerName(name)] = value2 : skip?.test(name) || attr(el, name, value2);
|
@@ -967,7 +967,7 @@ function initRenderer(renderer, scope) {
|
|
967
967
|
scope
|
968
968
|
), scope.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, scope.b = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.s && renderer.s(scope), dom;
|
969
969
|
}
|
970
|
-
function dynamicTagAttrs(nodeAccessor,
|
970
|
+
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
971
971
|
return (scope, attrsOrOp) => {
|
972
972
|
let renderer = scope[nodeAccessor + "(" /* ConditionalRenderer */];
|
973
973
|
if (!renderer || attrsOrOp === DIRTY)
|
@@ -975,17 +975,17 @@ function dynamicTagAttrs(nodeAccessor, getRenderBody, inputIsArgs) {
|
|
975
975
|
let childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
|
976
976
|
if (attrsOrOp === MARK || attrsOrOp === CLEAN)
|
977
977
|
return renderer.e?.(childScope, attrsOrOp);
|
978
|
-
let
|
978
|
+
let content = getContent?.(scope);
|
979
979
|
if (typeof renderer == "string")
|
980
|
-
setConditionalRendererOnlyChild(childScope, 0,
|
980
|
+
setConditionalRendererOnlyChild(childScope, 0, content), attrs(childScope, 0, attrsOrOp());
|
981
981
|
else if (renderer.e) {
|
982
982
|
let attributes = attrsOrOp();
|
983
983
|
renderer.e(
|
984
984
|
childScope,
|
985
985
|
inputIsArgs ? attributes : [
|
986
|
-
|
986
|
+
content ? {
|
987
987
|
...attributes,
|
988
|
-
|
988
|
+
content
|
989
989
|
} : attributes
|
990
990
|
]
|
991
991
|
);
|
@@ -1038,7 +1038,7 @@ var conditional = function(nodeAccessor, fn, getIntersection) {
|
|
1038
1038
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
1039
1039
|
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (currentRenderer = scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1040
1040
|
}
|
1041
|
-
intersection2?.(scope, op),
|
1041
|
+
intersection2?.(scope, op), contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1042
1042
|
};
|
1043
1043
|
};
|
1044
1044
|
function inConditionalScope(signal, nodeAccessor) {
|
@@ -1076,7 +1076,7 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
1076
1076
|
normalizedRenderer
|
1077
1077
|
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1078
1078
|
}
|
1079
|
-
intersection2?.(scope, op),
|
1079
|
+
intersection2?.(scope, op), contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1080
1080
|
};
|
1081
1081
|
};
|
1082
1082
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
@@ -1214,13 +1214,18 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1214
1214
|
);
|
1215
1215
|
return renderer.k = clone, renderer;
|
1216
1216
|
},
|
1217
|
-
render(out, component, renderer,
|
1217
|
+
render(out, component, renderer, args) {
|
1218
1218
|
let scope = component.scope;
|
1219
1219
|
scope || (scope = classIdToScope.get(component.id), scope && (component.scope = scope, classIdToScope.delete(component.id)));
|
1220
|
-
let
|
1220
|
+
let applyArgs = renderer.e || noop, existing = !1;
|
1221
|
+
if (typeof args[0] == "object" && "renderBody" in args[0]) {
|
1222
|
+
let input = args[0], normalizedInput = args[0] = {};
|
1223
|
+
for (let key in input)
|
1224
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1225
|
+
}
|
1221
1226
|
if (component.effects = prepareEffects(() => {
|
1222
1227
|
if (scope)
|
1223
|
-
|
1228
|
+
applyArgs(scope, MARK), existing = !0;
|
1224
1229
|
else {
|
1225
1230
|
scope = component.scope = createScopeWithRenderer(renderer, out.global);
|
1226
1231
|
let closures = renderer.c;
|
@@ -1228,7 +1233,7 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1228
1233
|
for (let signal of closures)
|
1229
1234
|
signal(component.scope, CLEAN);
|
1230
1235
|
}
|
1231
|
-
|
1236
|
+
applyArgs(scope, args);
|
1232
1237
|
}), !existing)
|
1233
1238
|
return scope.a === scope.b ? scope.a : scope.a.parentNode;
|
1234
1239
|
}
|
package/dist/html/attrs.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { type Accessor } from "../common/types";
|
|
2
2
|
export declare function classAttr(val: unknown): string;
|
3
3
|
export declare function styleAttr(val: unknown): string;
|
4
4
|
export declare function optionValueAttr(value: unknown): string;
|
5
|
-
export declare function controllable_select_value(scopeId: number, nodeAccessor: Accessor, value: unknown, valueChange: unknown,
|
5
|
+
export declare function controllable_select_value(scopeId: number, nodeAccessor: Accessor, value: unknown, valueChange: unknown, content?: () => void): void;
|
6
6
|
export declare function controllable_textarea_value(scopeId: number, nodeAccessor: Accessor, value: unknown, valueChange: unknown): string;
|
7
7
|
export declare function controllable_input_value(scopeId: number, nodeAccessor: Accessor, value: unknown, valueChange: unknown): string;
|
8
8
|
export declare function controllable_input_checked(scopeId: number, nodeAccessor: Accessor, checked: unknown, checkedChange: unknown): string;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import type { ServerRenderer } from "./template";
|
2
2
|
import { type PartialScope } from "./writer";
|
3
|
-
interface
|
3
|
+
interface BodyContentObject {
|
4
4
|
[x: PropertyKey]: unknown;
|
5
|
-
|
5
|
+
content: ServerRenderer;
|
6
6
|
}
|
7
|
-
export declare function dynamicTagInput(scope: PartialScope, tag: unknown | string | ServerRenderer |
|
8
|
-
export declare function dynamicTagArgs(scope: PartialScope, tag: unknown | string | ServerRenderer |
|
7
|
+
export declare function dynamicTagInput(scope: PartialScope, tag: unknown | string | ServerRenderer | BodyContentObject, input: Record<string, unknown>, content?: () => void, tagVar?: unknown): unknown;
|
8
|
+
export declare function dynamicTagArgs(scope: PartialScope, tag: unknown | string | ServerRenderer | BodyContentObject, args: unknown[]): unknown;
|
9
9
|
declare let getDynamicRenderer: (value: any) => string | ServerRenderer | undefined;
|
10
10
|
export declare let createRenderer: (fn: ServerRenderer) => ServerRenderer;
|
11
11
|
export declare function patchDynamicTag(newGetDynamicRenderer: typeof getDynamicRenderer, newCreateRenderer: typeof createRenderer): void;
|
package/dist/html/writer.d.ts
CHANGED
@@ -40,9 +40,9 @@ export declare function $global(): $Global & {
|
|
40
40
|
renderId: string;
|
41
41
|
runtimeId: string;
|
42
42
|
};
|
43
|
-
export declare function fork<T>(promise: Promise<T> | T,
|
44
|
-
export declare function tryPlaceholder(
|
45
|
-
export declare function tryCatch(
|
43
|
+
export declare function fork<T>(promise: Promise<T> | T, content: (value: T) => void): void;
|
44
|
+
export declare function tryPlaceholder(content: () => void, placeholder: () => void): void;
|
45
|
+
export declare function tryCatch(content: () => void, catchContent: (err: unknown) => void): void;
|
46
46
|
export declare class State {
|
47
47
|
$global: $Global & {
|
48
48
|
renderId: string;
|
@@ -102,8 +102,8 @@ export declare class Chunk {
|
|
102
102
|
append(chunk: Chunk): void;
|
103
103
|
flushPlaceholder(): void;
|
104
104
|
consume(): Chunk;
|
105
|
-
render(
|
106
|
-
render<T>(
|
105
|
+
render(content: () => void): Chunk;
|
106
|
+
render<T>(content: (val: T) => void, val: T): Chunk;
|
107
107
|
}
|
108
108
|
export declare function prepareChunk(chunk: Chunk): Chunk;
|
109
109
|
export declare function flushChunk(head: Chunk, last: boolean): string;
|