marko 6.0.0-3.13 → 6.0.0-3.14
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 +24 -17
- package/dist/debug/dom.mjs +24 -17
- 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 +20 -15
- package/dist/dom.mjs +20 -15
- 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 +4 -4
- package/package.json +2 -2
- package/tags-html.d.ts +1 -1
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
|
@@ -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
|
@@ -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;
|
package/dist/html.js
CHANGED
@@ -129,7 +129,7 @@ function isVoid(value) {
|
|
129
129
|
return value == null || value === !1;
|
130
130
|
}
|
131
131
|
function normalizeDynamicRenderer(value) {
|
132
|
-
if (value) return value.
|
132
|
+
if (value) return value.content || value.default || value;
|
133
133
|
}
|
134
134
|
|
135
135
|
// src/html/content.ts
|
@@ -1043,33 +1043,33 @@ function ensureScopeWithId(scopeId) {
|
|
1043
1043
|
function $global() {
|
1044
1044
|
return $chunk.boundary.state.$global;
|
1045
1045
|
}
|
1046
|
-
function fork(promise,
|
1046
|
+
function fork(promise, content) {
|
1047
1047
|
if (!isPromise(promise)) {
|
1048
|
-
|
1048
|
+
content(promise);
|
1049
1049
|
return;
|
1050
1050
|
}
|
1051
1051
|
let chunk = $chunk, { boundary } = chunk;
|
1052
1052
|
chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = { ...chunk.context, [kPendingContexts]: 0 }), boundary.startAsync(), promise.then(
|
1053
1053
|
(value) => {
|
1054
|
-
chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(
|
1054
|
+
chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(content, value), boundary.endAsync(chunk)));
|
1055
1055
|
},
|
1056
1056
|
(err) => {
|
1057
1057
|
chunk.async = !1, boundary.abort(err);
|
1058
1058
|
}
|
1059
1059
|
);
|
1060
1060
|
}
|
1061
|
-
function tryPlaceholder(
|
1061
|
+
function tryPlaceholder(content, placeholder) {
|
1062
1062
|
let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
|
1063
|
-
if (body === body.render(
|
1063
|
+
if (body === body.render(content)) {
|
1064
1064
|
chunk.append(body);
|
1065
1065
|
return;
|
1066
1066
|
}
|
1067
|
-
chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context), chunk.placeholderBody = body, chunk.placeholderRender =
|
1067
|
+
chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context), chunk.placeholderBody = body, chunk.placeholderRender = placeholder;
|
1068
1068
|
}
|
1069
|
-
function tryCatch(
|
1070
|
-
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = new Chunk(catchBoundary, null, chunk.context), bodyEnd = body.render(
|
1069
|
+
function tryCatch(content, catchContent) {
|
1070
|
+
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = new Chunk(catchBoundary, null, chunk.context), bodyEnd = body.render(content);
|
1071
1071
|
if (catchBoundary.signal.aborted) {
|
1072
|
-
|
1072
|
+
catchContent(catchBoundary.signal.reason);
|
1073
1073
|
return;
|
1074
1074
|
}
|
1075
1075
|
if (body === bodyEnd) {
|
@@ -1088,7 +1088,7 @@ function tryCatch(renderBody, renderCatch) {
|
|
1088
1088
|
} while (cur !== bodyNext);
|
1089
1089
|
}
|
1090
1090
|
let catchChunk = new Chunk(boundary, null, chunk.context);
|
1091
|
-
catchChunk.reorderId = reorderId, catchChunk.render(
|
1091
|
+
catchChunk.reorderId = reorderId, catchChunk.render(catchContent, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
|
1092
1092
|
} else catchBoundary.done ? boundary.endAsync() : boundary.onNext();
|
1093
1093
|
};
|
1094
1094
|
}
|
@@ -1208,11 +1208,11 @@ var State2 = class {
|
|
1208
1208
|
}
|
1209
1209
|
return cur;
|
1210
1210
|
}
|
1211
|
-
render(
|
1211
|
+
render(content, val) {
|
1212
1212
|
let prev = $chunk;
|
1213
1213
|
$chunk = this;
|
1214
1214
|
try {
|
1215
|
-
return
|
1215
|
+
return content(val), $chunk;
|
1216
1216
|
} catch (err) {
|
1217
1217
|
return this.boundary.abort(err), this;
|
1218
1218
|
} finally {
|
@@ -1320,14 +1320,14 @@ function optionValueAttr(value) {
|
|
1320
1320
|
return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
|
1321
1321
|
}
|
1322
1322
|
var kSelectedValue = Symbol("selectedValue");
|
1323
|
-
function controllable_select_value(scopeId, nodeAccessor, value, valueChange,
|
1323
|
+
function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
|
1324
1324
|
valueChange && writeControlledScope(
|
1325
1325
|
3 /* SelectValue */,
|
1326
1326
|
scopeId,
|
1327
1327
|
nodeAccessor,
|
1328
1328
|
value,
|
1329
1329
|
valueChange
|
1330
|
-
),
|
1330
|
+
), content && withContext(kSelectedValue, value, content);
|
1331
1331
|
}
|
1332
1332
|
function controllable_textarea_value(scopeId, nodeAccessor, value, valueChange) {
|
1333
1333
|
return valueChange && writeControlledScope(
|
@@ -1435,7 +1435,7 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
|
|
1435
1435
|
result += styleAttr(val);
|
1436
1436
|
break;
|
1437
1437
|
case "":
|
1438
|
-
case "
|
1438
|
+
case "content":
|
1439
1439
|
break;
|
1440
1440
|
default:
|
1441
1441
|
isVoid(val) || (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, {
|
@@ -1497,8 +1497,8 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
1497
1497
|
|
1498
1498
|
// src/html/dynamic-tag.ts
|
1499
1499
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
1500
|
-
function dynamicTagInput(scope, tag, input,
|
1501
|
-
if (!tag && !
|
1500
|
+
function dynamicTagInput(scope, tag, input, content, tagVar) {
|
1501
|
+
if (!tag && !content) return;
|
1502
1502
|
let scopeId = getScopeId(scope);
|
1503
1503
|
return write(`${markResumeScopeStart(scopeId)}`), writeScope(scopeId, scope), tag ? typeof tag == "string" ? (nextScopeId(), write(
|
1504
1504
|
`<${tag}${attrs(input, 0, scopeId, tag)}>`
|
@@ -1509,13 +1509,13 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
1509
1509
|
input.value,
|
1510
1510
|
input.valueChange
|
1511
1511
|
)
|
1512
|
-
) :
|
1512
|
+
) : content && (tag === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
|
1513
1513
|
scopeId,
|
1514
1514
|
0,
|
1515
1515
|
input.value,
|
1516
1516
|
input.valueChange,
|
1517
|
-
|
1518
|
-
) :
|
1517
|
+
content
|
1518
|
+
) : content()), write(`</${tag}>`)), null) : getDynamicRenderer(tag)(content ? { ...input, content } : input, tagVar) : content();
|
1519
1519
|
}
|
1520
1520
|
function dynamicTagArgs(scope, tag, args) {
|
1521
1521
|
if (!tag) return;
|
@@ -1565,13 +1565,18 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1565
1565
|
boundary,
|
1566
1566
|
null,
|
1567
1567
|
null
|
1568
|
-
);
|
1568
|
+
), normalizedInput = input;
|
1569
|
+
if ("renderBody" in input) {
|
1570
|
+
normalizedInput = {};
|
1571
|
+
for (let key in input)
|
1572
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1573
|
+
}
|
1569
1574
|
head.render(() => {
|
1570
1575
|
if (willRerender) {
|
1571
1576
|
let scopeId = peekNextScopeId();
|
1572
1577
|
writeScope(scopeId, { m5c: component.id }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
1573
1578
|
}
|
1574
|
-
renderer(
|
1579
|
+
renderer(normalizedInput);
|
1575
1580
|
});
|
1576
1581
|
let asyncOut = classAPIOut.beginAsync();
|
1577
1582
|
(boundary.onNext = () => {
|
package/dist/html.mjs
CHANGED
@@ -56,7 +56,7 @@ function isVoid(value) {
|
|
56
56
|
return value == null || value === !1;
|
57
57
|
}
|
58
58
|
function normalizeDynamicRenderer(value) {
|
59
|
-
if (value) return value.
|
59
|
+
if (value) return value.content || value.default || value;
|
60
60
|
}
|
61
61
|
|
62
62
|
// src/html/content.ts
|
@@ -970,33 +970,33 @@ function ensureScopeWithId(scopeId) {
|
|
970
970
|
function $global() {
|
971
971
|
return $chunk.boundary.state.$global;
|
972
972
|
}
|
973
|
-
function fork(promise,
|
973
|
+
function fork(promise, content) {
|
974
974
|
if (!isPromise(promise)) {
|
975
|
-
|
975
|
+
content(promise);
|
976
976
|
return;
|
977
977
|
}
|
978
978
|
let chunk = $chunk, { boundary } = chunk;
|
979
979
|
chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = { ...chunk.context, [kPendingContexts]: 0 }), boundary.startAsync(), promise.then(
|
980
980
|
(value) => {
|
981
|
-
chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(
|
981
|
+
chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(content, value), boundary.endAsync(chunk)));
|
982
982
|
},
|
983
983
|
(err) => {
|
984
984
|
chunk.async = !1, boundary.abort(err);
|
985
985
|
}
|
986
986
|
);
|
987
987
|
}
|
988
|
-
function tryPlaceholder(
|
988
|
+
function tryPlaceholder(content, placeholder) {
|
989
989
|
let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
|
990
|
-
if (body === body.render(
|
990
|
+
if (body === body.render(content)) {
|
991
991
|
chunk.append(body);
|
992
992
|
return;
|
993
993
|
}
|
994
|
-
chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context), chunk.placeholderBody = body, chunk.placeholderRender =
|
994
|
+
chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context), chunk.placeholderBody = body, chunk.placeholderRender = placeholder;
|
995
995
|
}
|
996
|
-
function tryCatch(
|
997
|
-
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = new Chunk(catchBoundary, null, chunk.context), bodyEnd = body.render(
|
996
|
+
function tryCatch(content, catchContent) {
|
997
|
+
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = new Chunk(catchBoundary, null, chunk.context), bodyEnd = body.render(content);
|
998
998
|
if (catchBoundary.signal.aborted) {
|
999
|
-
|
999
|
+
catchContent(catchBoundary.signal.reason);
|
1000
1000
|
return;
|
1001
1001
|
}
|
1002
1002
|
if (body === bodyEnd) {
|
@@ -1015,7 +1015,7 @@ function tryCatch(renderBody, renderCatch) {
|
|
1015
1015
|
} while (cur !== bodyNext);
|
1016
1016
|
}
|
1017
1017
|
let catchChunk = new Chunk(boundary, null, chunk.context);
|
1018
|
-
catchChunk.reorderId = reorderId, catchChunk.render(
|
1018
|
+
catchChunk.reorderId = reorderId, catchChunk.render(catchContent, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
|
1019
1019
|
} else catchBoundary.done ? boundary.endAsync() : boundary.onNext();
|
1020
1020
|
};
|
1021
1021
|
}
|
@@ -1135,11 +1135,11 @@ var State2 = class {
|
|
1135
1135
|
}
|
1136
1136
|
return cur;
|
1137
1137
|
}
|
1138
|
-
render(
|
1138
|
+
render(content, val) {
|
1139
1139
|
let prev = $chunk;
|
1140
1140
|
$chunk = this;
|
1141
1141
|
try {
|
1142
|
-
return
|
1142
|
+
return content(val), $chunk;
|
1143
1143
|
} catch (err) {
|
1144
1144
|
return this.boundary.abort(err), this;
|
1145
1145
|
} finally {
|
@@ -1247,14 +1247,14 @@ function optionValueAttr(value) {
|
|
1247
1247
|
return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
|
1248
1248
|
}
|
1249
1249
|
var kSelectedValue = Symbol("selectedValue");
|
1250
|
-
function controllable_select_value(scopeId, nodeAccessor, value, valueChange,
|
1250
|
+
function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
|
1251
1251
|
valueChange && writeControlledScope(
|
1252
1252
|
3 /* SelectValue */,
|
1253
1253
|
scopeId,
|
1254
1254
|
nodeAccessor,
|
1255
1255
|
value,
|
1256
1256
|
valueChange
|
1257
|
-
),
|
1257
|
+
), content && withContext(kSelectedValue, value, content);
|
1258
1258
|
}
|
1259
1259
|
function controllable_textarea_value(scopeId, nodeAccessor, value, valueChange) {
|
1260
1260
|
return valueChange && writeControlledScope(
|
@@ -1362,7 +1362,7 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
|
|
1362
1362
|
result += styleAttr(val);
|
1363
1363
|
break;
|
1364
1364
|
case "":
|
1365
|
-
case "
|
1365
|
+
case "content":
|
1366
1366
|
break;
|
1367
1367
|
default:
|
1368
1368
|
isVoid(val) || (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, {
|
@@ -1424,8 +1424,8 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
1424
1424
|
|
1425
1425
|
// src/html/dynamic-tag.ts
|
1426
1426
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
1427
|
-
function dynamicTagInput(scope, tag, input,
|
1428
|
-
if (!tag && !
|
1427
|
+
function dynamicTagInput(scope, tag, input, content, tagVar) {
|
1428
|
+
if (!tag && !content) return;
|
1429
1429
|
let scopeId = getScopeId(scope);
|
1430
1430
|
return write(`${markResumeScopeStart(scopeId)}`), writeScope(scopeId, scope), tag ? typeof tag == "string" ? (nextScopeId(), write(
|
1431
1431
|
`<${tag}${attrs(input, 0, scopeId, tag)}>`
|
@@ -1436,13 +1436,13 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
1436
1436
|
input.value,
|
1437
1437
|
input.valueChange
|
1438
1438
|
)
|
1439
|
-
) :
|
1439
|
+
) : content && (tag === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
|
1440
1440
|
scopeId,
|
1441
1441
|
0,
|
1442
1442
|
input.value,
|
1443
1443
|
input.valueChange,
|
1444
|
-
|
1445
|
-
) :
|
1444
|
+
content
|
1445
|
+
) : content()), write(`</${tag}>`)), null) : getDynamicRenderer(tag)(content ? { ...input, content } : input, tagVar) : content();
|
1446
1446
|
}
|
1447
1447
|
function dynamicTagArgs(scope, tag, args) {
|
1448
1448
|
if (!tag) return;
|
@@ -1492,13 +1492,18 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1492
1492
|
boundary,
|
1493
1493
|
null,
|
1494
1494
|
null
|
1495
|
-
);
|
1495
|
+
), normalizedInput = input;
|
1496
|
+
if ("renderBody" in input) {
|
1497
|
+
normalizedInput = {};
|
1498
|
+
for (let key in input)
|
1499
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1500
|
+
}
|
1496
1501
|
head.render(() => {
|
1497
1502
|
if (willRerender) {
|
1498
1503
|
let scopeId = peekNextScopeId();
|
1499
1504
|
writeScope(scopeId, { m5c: component.id }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
1500
1505
|
}
|
1501
|
-
renderer(
|
1506
|
+
renderer(normalizedInput);
|
1502
1507
|
});
|
1503
1508
|
let asyncOut = classAPIOut.beginAsync();
|
1504
1509
|
(boundary.onNext = () => {
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import type { Config } from "@marko/compiler";
|
2
|
+
export declare const tagDiscoveryDirs: string[];
|
2
3
|
export { default as internalEntryBuilder } from "./util/entry-builder";
|
4
|
+
export declare const preferAPI = "tags";
|
3
5
|
export declare const transform: import("@marko/compiler/babel-types").Visitor<unknown>, analyze: import("@marko/compiler/babel-types").Visitor<unknown>, translate: import("@marko/compiler/babel-types").Visitor<unknown>;
|
4
6
|
export declare const taglibs: (string | {
|
5
7
|
migrate: import("@marko/compiler/babel-types").Visitor<unknown>;
|