marko 6.3.13 → 6.3.15
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/html.js +197 -173
- package/dist/debug/html.mjs +197 -173
- package/dist/html/writer.d.ts +36 -36
- package/dist/html.js +149 -129
- package/dist/html.mjs +149 -129
- package/dist/translator/index.js +63 -51
- package/package.json +1 -1
package/dist/html.mjs
CHANGED
|
@@ -238,24 +238,26 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
238
238
|
[JSON, "JSON"],
|
|
239
239
|
[Math, "Math"],
|
|
240
240
|
[Reflect, "Reflect"]
|
|
241
|
-
]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, $chunk,
|
|
241
|
+
]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, $chunk, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
|
|
242
242
|
let { state } = $chunk.boundary, target = $chunk.serializeState, scope = scopeWithId(state, scopeId), pending = target.writeScopes[scopeId];
|
|
243
243
|
return state.needsMainRuntime = !0, Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
|
|
244
|
-
}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
|
244
|
+
}, NOOP$2 = () => {}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
|
245
245
|
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
|
|
246
246
|
if (typeof renderer == "string") {
|
|
247
247
|
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if (
|
|
253
|
-
|
|
248
|
+
rendered = !0, (() => {
|
|
249
|
+
if (_scope_id(), _html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`), !voidElementsReg.test(renderer)) {
|
|
250
|
+
let renderContent = content || normalizeDynamicRenderer(input.content);
|
|
251
|
+
if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
|
|
252
|
+
else if (renderContent) {
|
|
253
|
+
if (typeof renderContent != "function") throw Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
254
|
+
renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent, 1) : _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
|
|
255
|
+
}
|
|
256
|
+
_html(`</${renderer}>`);
|
|
254
257
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
needsScript && (writeScope(branchId, { R: renderer }), _script(branchId, "d")), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
258
|
+
let childScope = getScopeById(branchId), needsScript = childScope && (childScope.Ia || childScope.Ea);
|
|
259
|
+
needsScript && (writeScope(branchId, { R: renderer }), _script(branchId, "d")), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
260
|
+
})();
|
|
259
261
|
} else {
|
|
260
262
|
shouldResume && _html(state.mark("[", ""));
|
|
261
263
|
let render = () => {
|
|
@@ -673,13 +675,15 @@ function writeUnknownObject(state, val, ref) {
|
|
|
673
675
|
case Int32Array:
|
|
674
676
|
case Uint32Array:
|
|
675
677
|
case Float32Array:
|
|
676
|
-
case Float64Array:
|
|
678
|
+
case Float64Array:
|
|
679
|
+
case BigInt64Array:
|
|
680
|
+
case BigUint64Array: return writeTypedArray(state, val, ref);
|
|
677
681
|
case WeakSet: return writeWeakSet(state);
|
|
678
682
|
case WeakMap: return writeWeakMap(state);
|
|
679
683
|
case globalThis.URL: return writeURL(state, val);
|
|
680
684
|
case globalThis.URLSearchParams: return writeURLSearchParams(state, val);
|
|
681
685
|
case globalThis.Headers: return writeHeaders(state, val);
|
|
682
|
-
case globalThis.FormData: return writeFormData(state, val);
|
|
686
|
+
case globalThis.FormData: return writeFormData(state, val, ref);
|
|
683
687
|
case globalThis.ReadableStream: return writeReadableStream(state, val, ref);
|
|
684
688
|
case globalThis.Request: return writeRequest(state, val, ref);
|
|
685
689
|
case globalThis.Response: return writeResponse(state, val, ref);
|
|
@@ -788,12 +792,15 @@ function writeURLSearchParams(state, val) {
|
|
|
788
792
|
return str ? state.buf.push("new URLSearchParams(" + quote(str, 0) + ")") : state.buf.push("new URLSearchParams"), !0;
|
|
789
793
|
}
|
|
790
794
|
function writeHeaders(state, val) {
|
|
791
|
-
let headers =
|
|
792
|
-
return state.buf.push("new Headers" + (headers ? "(
|
|
795
|
+
let headers = stringEntriesToHeadersInit(val);
|
|
796
|
+
return state.buf.push("new Headers" + (headers ? "(" + headers + ")" : "")), !0;
|
|
793
797
|
}
|
|
794
|
-
function writeFormData(state, val) {
|
|
798
|
+
function writeFormData(state, val, ref) {
|
|
795
799
|
let sep = "[", valStr = "";
|
|
796
|
-
for (let [key, value] of val)
|
|
800
|
+
for (let [key, value] of val) {
|
|
801
|
+
if (typeof value != "string") return !1;
|
|
802
|
+
valStr += sep + quote(key, 0) + "," + quote(value, 0), sep = ",";
|
|
803
|
+
}
|
|
797
804
|
return sep === "[" ? state.buf.push("new FormData") : state.buf.push(valStr + "].reduce((f,v,i,a)=>i%2&&f.append(a[i-1],v)||f,new FormData)"), !0;
|
|
798
805
|
}
|
|
799
806
|
function writeRequest(state, val, ref) {
|
|
@@ -801,14 +808,14 @@ function writeRequest(state, val, ref) {
|
|
|
801
808
|
state.buf.push("new Request(" + quote(val.url, 0)), hasBody && (state.buf.push(",{body:"), writeProp(state, val.body, ref, "body") ? (state.buf.push(",duplex:\"half\""), sep = ",", bodySerialized = !0) : state.buf.pop());
|
|
802
809
|
let options = "";
|
|
803
810
|
val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
|
|
804
|
-
let headers =
|
|
805
|
-
return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:
|
|
811
|
+
let headers = stringEntriesToHeadersInit(val.headers);
|
|
812
|
+
return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:" + headers, sep = ","), val.integrity && (options += sep + "integrity:" + quote(val.integrity, 0), sep = ","), val.keepalive && (options += sep + "keepalive:true", sep = ","), val.method !== "GET" && (options += sep + "method:" + quote(val.method, 0), sep = ","), val.mode !== "cors" && (options += sep + "mode:" + quote(val.mode, 0), sep = ","), val.redirect !== "follow" && (options += sep + "redirect:" + quote(val.redirect, 0), sep = ","), val.referrer !== "about:client" && (options += sep + "referrer:" + quote(val.referrer, 0), sep = ","), val.referrerPolicy && (options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0)), state.buf.push(bodySerialized ? options + "})" : options ? ",{" + options + "})" : ")"), !0;
|
|
806
813
|
}
|
|
807
814
|
function writeResponse(state, val, ref) {
|
|
808
815
|
let sep = "", options = "";
|
|
809
816
|
val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
|
|
810
|
-
let headers =
|
|
811
|
-
return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:
|
|
817
|
+
let headers = stringEntriesToHeadersInit(val.headers);
|
|
818
|
+
return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:" + headers), !val.body || val.bodyUsed ? state.buf.push("new Response" + (options ? "(null,{" + options + "})" : "")) : (state.buf.push("new Response("), state.buf.push((writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")"))), !0;
|
|
812
819
|
}
|
|
813
820
|
function writeReadableStream(state, val, ref) {
|
|
814
821
|
let { boundary, channel } = state;
|
|
@@ -1020,18 +1027,29 @@ function nextId(state) {
|
|
|
1020
1027
|
function hasSymbolIterator(value) {
|
|
1021
1028
|
return Symbol.iterator in value;
|
|
1022
1029
|
}
|
|
1023
|
-
function
|
|
1030
|
+
function stringEntriesToHeadersInit(entries) {
|
|
1031
|
+
let list = [...entries];
|
|
1032
|
+
if (!list.length) return "";
|
|
1033
|
+
let duplicate = !1, seen = /* @__PURE__ */ new Set();
|
|
1034
|
+
for (let [key] of list) {
|
|
1035
|
+
if (seen.has(key)) {
|
|
1036
|
+
duplicate = !0;
|
|
1037
|
+
break;
|
|
1038
|
+
}
|
|
1039
|
+
seen.add(key);
|
|
1040
|
+
}
|
|
1024
1041
|
let result = "", sep = "";
|
|
1025
|
-
for (let [key, value] of
|
|
1026
|
-
return result;
|
|
1042
|
+
for (let [key, value] of list) result += duplicate ? sep + "[" + quote(key, 0) + "," + quote(value, 0) + "]" : sep + toObjectKey(key) + ":" + quote(value, 0), sep = ",";
|
|
1043
|
+
return duplicate ? "[" + result + "]" : "{" + result + "}";
|
|
1027
1044
|
}
|
|
1028
1045
|
function typedArrayToInitString(view) {
|
|
1029
|
-
let result = "[", sep = "";
|
|
1030
|
-
for (let i = 0; i < view.length; i++) result += sep + view[i], sep = ",";
|
|
1046
|
+
let suffix = typeof view[0] == "bigint" ? "n" : "", result = "[", sep = "";
|
|
1047
|
+
for (let i = 0; i < view.length; i++) result += sep + view[i] + suffix, sep = ",";
|
|
1031
1048
|
return result += "]", result;
|
|
1032
1049
|
}
|
|
1033
1050
|
function hasOnlyZeros(typedArray) {
|
|
1034
|
-
|
|
1051
|
+
let zero = typeof typedArray[0] == "bigint" ? 0n : 0;
|
|
1052
|
+
for (let i = 0; i < typedArray.length; i++) if (typedArray[i] !== zero) return !1;
|
|
1035
1053
|
return !0;
|
|
1036
1054
|
}
|
|
1037
1055
|
function patchIteratorNext(proto) {
|
|
@@ -1106,35 +1124,21 @@ function getState() {
|
|
|
1106
1124
|
function getScopeId(scope) {
|
|
1107
1125
|
return scope[K_SCOPE_ID];
|
|
1108
1126
|
}
|
|
1109
|
-
function
|
|
1110
|
-
$chunk.
|
|
1111
|
-
}
|
|
1112
|
-
function writeScript(script) {
|
|
1113
|
-
$chunk.writeScript(script);
|
|
1127
|
+
function getScopeById(scopeId) {
|
|
1128
|
+
if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
|
|
1114
1129
|
}
|
|
1115
|
-
function
|
|
1116
|
-
|
|
1117
|
-
readyId,
|
|
1118
|
-
parent: chunk.serializeState,
|
|
1119
|
-
resumes: "",
|
|
1120
|
-
writeScopes: {},
|
|
1121
|
-
flushScopes: !1
|
|
1122
|
-
}), bodyEnd = body.render(renderer, input);
|
|
1123
|
-
body === bodyEnd ? (chunk.writeHTML(body.html), body.deferOwnReady(), chunk.deferredReady = push(chunk.deferredReady, body)) : (bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next), chunk.next = body);
|
|
1130
|
+
function $global() {
|
|
1131
|
+
return $chunk.boundary.state.$global;
|
|
1124
1132
|
}
|
|
1125
|
-
function
|
|
1126
|
-
|
|
1133
|
+
function _id() {
|
|
1134
|
+
let state = $chunk.boundary.state, { $global } = state;
|
|
1135
|
+
return "s" + $global.runtimeId + $global.renderId + (state.tagId++).toString(36);
|
|
1127
1136
|
}
|
|
1128
|
-
function
|
|
1129
|
-
|
|
1130
|
-
render && (shouldResume ? withBranchId(branchId, render) : render()), _peek_scope_id() === branchId ? _scope_id() : shouldResume && writeScope(scopeId, {
|
|
1131
|
-
["A" + nodeAccessor]: writeScope(branchId, {}),
|
|
1132
|
-
["D" + nodeAccessor]: render?.a
|
|
1133
|
-
});
|
|
1137
|
+
function _scope_id() {
|
|
1138
|
+
return $chunk.boundary.state.scopeId++;
|
|
1134
1139
|
}
|
|
1135
|
-
function
|
|
1136
|
-
|
|
1137
|
-
if (renderer && typeof renderer == "function") return renderer;
|
|
1140
|
+
function _peek_scope_id() {
|
|
1141
|
+
return $chunk.boundary.state.scopeId;
|
|
1138
1142
|
}
|
|
1139
1143
|
function withContext(key, value, cb, cbValue) {
|
|
1140
1144
|
let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
|
|
@@ -1145,43 +1149,36 @@ function withContext(key, value, cb, cbValue) {
|
|
|
1145
1149
|
ctx[kPendingContexts]--, ctx[key] = prev;
|
|
1146
1150
|
}
|
|
1147
1151
|
}
|
|
1148
|
-
function
|
|
1149
|
-
|
|
1150
|
-
let childScope = writeScopePassive(childScopeId, { T: _resume({}, registryId, parentScopeId) });
|
|
1151
|
-
nodeAccessor !== void 0 && writeScope(parentScopeId, { ["A" + nodeAccessor]: childScope });
|
|
1152
|
-
}
|
|
1153
|
-
function writeScopePassive(scopeId, partialScope) {
|
|
1154
|
-
let target = $chunk.serializeState, scope = _scope_with_id(scopeId), passive = target.passiveScopes ||= {};
|
|
1155
|
-
return Object.assign(scope, partialScope), passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope), scope;
|
|
1152
|
+
function isInResumedBranch() {
|
|
1153
|
+
return $chunk?.context?.[kBranchId] !== void 0;
|
|
1156
1154
|
}
|
|
1157
|
-
function
|
|
1158
|
-
return
|
|
1155
|
+
function withBranchId(branchId, cb) {
|
|
1156
|
+
return withContext(kBranchId, branchId, cb);
|
|
1159
1157
|
}
|
|
1160
|
-
function
|
|
1161
|
-
|
|
1162
|
-
return "s" + $global.runtimeId + $global.renderId + (state.tagId++).toString(36);
|
|
1158
|
+
function withIsAsync(cb, value) {
|
|
1159
|
+
return withContext(kIsAsync, !0, cb, value);
|
|
1163
1160
|
}
|
|
1164
|
-
function
|
|
1165
|
-
|
|
1161
|
+
function _html(html) {
|
|
1162
|
+
$chunk.writeHTML(html);
|
|
1166
1163
|
}
|
|
1167
|
-
function
|
|
1168
|
-
|
|
1164
|
+
function writeScript(script) {
|
|
1165
|
+
$chunk.writeScript(script);
|
|
1169
1166
|
}
|
|
1170
|
-
function
|
|
1171
|
-
|
|
1167
|
+
function _script(scopeId, registryId) {
|
|
1168
|
+
($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) && _resume_branch(scopeId), $chunk.boundary.state.needsMainRuntime = !0, $chunk.writeEffect(scopeId, registryId);
|
|
1172
1169
|
}
|
|
1173
|
-
function
|
|
1174
|
-
$chunk.boundary.state.
|
|
1170
|
+
function _trailers(html) {
|
|
1171
|
+
$chunk.boundary.state.trailerHTML += html;
|
|
1175
1172
|
}
|
|
1176
|
-
function
|
|
1177
|
-
|
|
1178
|
-
return $chunk.boundary.state.serializeReason = void 0, reason;
|
|
1173
|
+
function _resume(val, id, scopeId) {
|
|
1174
|
+
return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
|
|
1179
1175
|
}
|
|
1180
|
-
function
|
|
1181
|
-
return
|
|
1176
|
+
function _el(scopeId, id) {
|
|
1177
|
+
return _resume(() => void 0, id, scopeId);
|
|
1182
1178
|
}
|
|
1183
|
-
function
|
|
1184
|
-
|
|
1179
|
+
function _hoist(scopeId, id) {
|
|
1180
|
+
let getter = () => void 0;
|
|
1181
|
+
return getter[Symbol.iterator] = _hoist_read_error, _resume(getter, id, scopeId);
|
|
1185
1182
|
}
|
|
1186
1183
|
function _el_resume(scopeId, accessor, shouldResume) {
|
|
1187
1184
|
if (shouldResume === 0) return "";
|
|
@@ -1191,25 +1188,36 @@ function _el_resume(scopeId, accessor, shouldResume) {
|
|
|
1191
1188
|
function _sep(shouldResume) {
|
|
1192
1189
|
return shouldResume === 0 ? "" : "<!>";
|
|
1193
1190
|
}
|
|
1194
|
-
function _el(scopeId, id) {
|
|
1195
|
-
return _resume(() => void 0, id, scopeId);
|
|
1196
|
-
}
|
|
1197
|
-
function _hoist(scopeId, id) {
|
|
1198
|
-
let getter = () => void 0;
|
|
1199
|
-
return getter[Symbol.iterator] = _hoist_read_error, _resume(getter, id, scopeId);
|
|
1200
|
-
}
|
|
1201
1191
|
function _resume_branch(scopeId) {
|
|
1202
1192
|
let branchId = $chunk.context?.[kBranchId];
|
|
1203
1193
|
branchId !== void 0 && branchId !== scopeId && writeScope(scopeId, { G: branchId });
|
|
1204
1194
|
}
|
|
1205
|
-
function
|
|
1206
|
-
|
|
1195
|
+
function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
|
|
1196
|
+
let shouldResume = serializeReason !== 0, render = normalizeServerRender(content), branchId = _peek_scope_id();
|
|
1197
|
+
render && (shouldResume ? withBranchId(branchId, render) : render()), _peek_scope_id() === branchId ? _scope_id() : shouldResume && writeScope(scopeId, {
|
|
1198
|
+
["A" + nodeAccessor]: writeScope(branchId, {}),
|
|
1199
|
+
["D" + nodeAccessor]: render?.a
|
|
1200
|
+
});
|
|
1207
1201
|
}
|
|
1208
|
-
function
|
|
1209
|
-
|
|
1202
|
+
function normalizeServerRender(value) {
|
|
1203
|
+
let renderer = normalizeDynamicRenderer(value);
|
|
1204
|
+
if (renderer && typeof renderer == "function") return renderer;
|
|
1210
1205
|
}
|
|
1211
|
-
function
|
|
1212
|
-
|
|
1206
|
+
function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, nodeAccessor) {
|
|
1207
|
+
writeScopePassive(parentScopeId, { [scopeOffsetAccessor]: _scope_id() });
|
|
1208
|
+
let childScope = writeScopePassive(childScopeId, { T: _resume({}, registryId, parentScopeId) });
|
|
1209
|
+
nodeAccessor !== void 0 && writeScope(parentScopeId, { ["A" + nodeAccessor]: childScope });
|
|
1210
|
+
}
|
|
1211
|
+
function writeScopePassive(scopeId, partialScope) {
|
|
1212
|
+
let target = $chunk.serializeState, scope = _scope_with_id(scopeId), passive = target.passiveScopes ||= {};
|
|
1213
|
+
return Object.assign(scope, partialScope), passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope), scope;
|
|
1214
|
+
}
|
|
1215
|
+
function _show_start(display, mark) {
|
|
1216
|
+
display ? mark && $chunk.writeHTML($chunk.boundary.state.mark("[", "")) : $chunk.writeHTML("<t hidden>");
|
|
1217
|
+
}
|
|
1218
|
+
function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1219
|
+
let branchId = _scope_id(), wrap = !display;
|
|
1220
|
+
wrap && $chunk.writeHTML("</t>"), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
1213
1221
|
}
|
|
1214
1222
|
function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1215
1223
|
forBranches(by, (each) => each ? forOf(list, (item, index) => {
|
|
@@ -1272,13 +1280,6 @@ function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, p
|
|
|
1272
1280
|
} else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
1273
1281
|
else $chunk.writeHTML(endTag);
|
|
1274
1282
|
}
|
|
1275
|
-
function _show_start(display, mark) {
|
|
1276
|
-
display ? mark && $chunk.writeHTML($chunk.boundary.state.mark("[", "")) : $chunk.writeHTML("<t hidden>");
|
|
1277
|
-
}
|
|
1278
|
-
function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1279
|
-
let branchId = _scope_id(), wrap = !display;
|
|
1280
|
-
wrap && $chunk.writeHTML("</t>"), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
1281
|
-
}
|
|
1282
1283
|
function _existing_scope(scopeId) {
|
|
1283
1284
|
return writeScope(scopeId, {});
|
|
1284
1285
|
}
|
|
@@ -1289,8 +1290,35 @@ function scopeWithId(state, scopeId) {
|
|
|
1289
1290
|
let { scopes } = state, scope = scopes.get(scopeId);
|
|
1290
1291
|
return scope || scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId }), scope;
|
|
1291
1292
|
}
|
|
1292
|
-
function
|
|
1293
|
-
|
|
1293
|
+
function _subscribe(subscribers, scope) {
|
|
1294
|
+
if (subscribers) {
|
|
1295
|
+
let { serializer } = $chunk.boundary.state;
|
|
1296
|
+
!$chunk.serializeState.readyId && !serializer.written(subscribers) ? subscribers.add(scope) : serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
|
|
1297
|
+
}
|
|
1298
|
+
return scope;
|
|
1299
|
+
}
|
|
1300
|
+
function _set_serialize_reason(reason) {
|
|
1301
|
+
$chunk.boundary.state.serializeReason = reason;
|
|
1302
|
+
}
|
|
1303
|
+
function _scope_reason() {
|
|
1304
|
+
let reason = $chunk.boundary.state.serializeReason;
|
|
1305
|
+
return $chunk.boundary.state.serializeReason = void 0, reason;
|
|
1306
|
+
}
|
|
1307
|
+
function _serialize_if(condition, key) {
|
|
1308
|
+
return condition && (condition === 1 || (typeof condition == "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
|
|
1309
|
+
}
|
|
1310
|
+
function _serialize_guard(condition, key) {
|
|
1311
|
+
return _serialize_if(condition, key) || 0;
|
|
1312
|
+
}
|
|
1313
|
+
function writeWaitReady(readyId, renderer, input) {
|
|
1314
|
+
let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context, {
|
|
1315
|
+
readyId,
|
|
1316
|
+
parent: chunk.serializeState,
|
|
1317
|
+
resumes: "",
|
|
1318
|
+
writeScopes: {},
|
|
1319
|
+
flushScopes: !1
|
|
1320
|
+
}), bodyEnd = body.render(renderer, input);
|
|
1321
|
+
body === bodyEnd ? (chunk.writeHTML(body.html), body.deferOwnReady(), chunk.deferredReady = push(chunk.deferredReady, body)) : (bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next), chunk.next = body);
|
|
1294
1322
|
}
|
|
1295
1323
|
function _await(scopeId, accessor, promise, content, serializeMarker) {
|
|
1296
1324
|
let resumeMarker = serializeMarker !== 0;
|
|
@@ -1617,8 +1645,20 @@ function depsMarker(deps) {
|
|
|
1617
1645
|
}
|
|
1618
1646
|
return marker;
|
|
1619
1647
|
}
|
|
1620
|
-
function
|
|
1621
|
-
|
|
1648
|
+
function getFilteredGlobals($global) {
|
|
1649
|
+
if (!$global) return 0;
|
|
1650
|
+
let serializedGlobals = $global.serializedGlobals;
|
|
1651
|
+
if (!serializedGlobals) return 0;
|
|
1652
|
+
let filtered = 0;
|
|
1653
|
+
if (Array.isArray(serializedGlobals)) for (let key of serializedGlobals) {
|
|
1654
|
+
let value = $global[key];
|
|
1655
|
+
value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
|
|
1656
|
+
}
|
|
1657
|
+
else for (let key in serializedGlobals) if (serializedGlobals[key]) {
|
|
1658
|
+
let value = $global[key];
|
|
1659
|
+
value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
|
|
1660
|
+
}
|
|
1661
|
+
return filtered;
|
|
1622
1662
|
}
|
|
1623
1663
|
function concatEffects(a, b) {
|
|
1624
1664
|
return a ? b ? a + " " + b : a : b;
|
|
@@ -1640,28 +1680,6 @@ function flushTickQueue() {
|
|
|
1640
1680
|
tickQueue = void 0;
|
|
1641
1681
|
for (let cb of queue) cb(!0);
|
|
1642
1682
|
}
|
|
1643
|
-
function getFilteredGlobals($global) {
|
|
1644
|
-
if (!$global) return 0;
|
|
1645
|
-
let serializedGlobals = $global.serializedGlobals;
|
|
1646
|
-
if (!serializedGlobals) return 0;
|
|
1647
|
-
let filtered = 0;
|
|
1648
|
-
if (Array.isArray(serializedGlobals)) for (let key of serializedGlobals) {
|
|
1649
|
-
let value = $global[key];
|
|
1650
|
-
value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
|
|
1651
|
-
}
|
|
1652
|
-
else for (let key in serializedGlobals) if (serializedGlobals[key]) {
|
|
1653
|
-
let value = $global[key];
|
|
1654
|
-
value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
|
|
1655
|
-
}
|
|
1656
|
-
return filtered;
|
|
1657
|
-
}
|
|
1658
|
-
function _subscribe(subscribers, scope) {
|
|
1659
|
-
if (subscribers) {
|
|
1660
|
-
let { serializer } = $chunk.boundary.state;
|
|
1661
|
-
!$chunk.serializeState.readyId && !serializer.written(subscribers) ? subscribers.add(scope) : serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
|
|
1662
|
-
}
|
|
1663
|
-
return scope;
|
|
1664
|
-
}
|
|
1665
1683
|
//#endregion
|
|
1666
1684
|
//#region src/html/attrs.ts
|
|
1667
1685
|
function _attr_class(value) {
|
|
@@ -1942,9 +1960,11 @@ var ServerRendered = class {
|
|
|
1942
1960
|
case 2:
|
|
1943
1961
|
boundary.onNext = NOOP$1, reject(boundary.signal.reason);
|
|
1944
1962
|
break;
|
|
1945
|
-
case 0:
|
|
1946
|
-
|
|
1963
|
+
case 0: {
|
|
1964
|
+
let consumed = head.consume();
|
|
1965
|
+
boundary.signal.aborted || resolve(consumed.flushHTML());
|
|
1947
1966
|
break;
|
|
1967
|
+
}
|
|
1948
1968
|
}
|
|
1949
1969
|
})();
|
|
1950
1970
|
});
|
package/dist/translator/index.js
CHANGED
|
@@ -1754,13 +1754,14 @@ function getContext(key) {
|
|
|
1754
1754
|
function getState() {
|
|
1755
1755
|
return $chunk.boundary.state;
|
|
1756
1756
|
}
|
|
1757
|
-
function
|
|
1758
|
-
$chunk.
|
|
1757
|
+
function getScopeById(scopeId) {
|
|
1758
|
+
if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
|
|
1759
1759
|
}
|
|
1760
|
-
function
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1760
|
+
function _scope_id() {
|
|
1761
|
+
return $chunk.boundary.state.scopeId++;
|
|
1762
|
+
}
|
|
1763
|
+
function _peek_scope_id() {
|
|
1764
|
+
return $chunk.boundary.state.scopeId;
|
|
1764
1765
|
}
|
|
1765
1766
|
const kPendingContexts = Symbol("Pending Contexts");
|
|
1766
1767
|
function withContext(key, value, cb, cbValue) {
|
|
@@ -1775,27 +1776,23 @@ function withContext(key, value, cb, cbValue) {
|
|
|
1775
1776
|
ctx[key] = prev;
|
|
1776
1777
|
}
|
|
1777
1778
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
return $chunk.boundary.state.scopeId;
|
|
1779
|
+
const kBranchId = Symbol("Branch Id");
|
|
1780
|
+
const kIsAsync = Symbol("Is Async");
|
|
1781
|
+
function withBranchId(branchId, cb) {
|
|
1782
|
+
return withContext(kBranchId, branchId, cb);
|
|
1783
1783
|
}
|
|
1784
|
-
function
|
|
1785
|
-
|
|
1784
|
+
function _html(html) {
|
|
1785
|
+
$chunk.writeHTML(html);
|
|
1786
1786
|
}
|
|
1787
|
-
function
|
|
1788
|
-
$chunk.
|
|
1787
|
+
function _script(scopeId, registryId) {
|
|
1788
|
+
if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
|
|
1789
|
+
$chunk.boundary.state.needsMainRuntime = true;
|
|
1790
|
+
$chunk.writeEffect(scopeId, registryId);
|
|
1789
1791
|
}
|
|
1790
1792
|
function _resume_branch(scopeId) {
|
|
1791
1793
|
const branchId = $chunk.context?.[kBranchId];
|
|
1792
1794
|
if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { ["#ClosestBranchId"]: branchId });
|
|
1793
1795
|
}
|
|
1794
|
-
const kBranchId = Symbol("Branch Id");
|
|
1795
|
-
const kIsAsync = Symbol("Is Async");
|
|
1796
|
-
function withBranchId(branchId, cb) {
|
|
1797
|
-
return withContext(kBranchId, branchId, cb);
|
|
1798
|
-
}
|
|
1799
1796
|
let writeScope = (scopeId, partialScope) => {
|
|
1800
1797
|
const { state } = $chunk.boundary;
|
|
1801
1798
|
const target = $chunk.serializeState;
|
|
@@ -1814,6 +1811,9 @@ function scopeWithId(state, scopeId) {
|
|
|
1814
1811
|
if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
|
|
1815
1812
|
return scope;
|
|
1816
1813
|
}
|
|
1814
|
+
function _set_serialize_reason(reason) {
|
|
1815
|
+
$chunk.boundary.state.serializeReason = reason;
|
|
1816
|
+
}
|
|
1817
1817
|
globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask;
|
|
1818
1818
|
//#endregion
|
|
1819
1819
|
//#region src/html/attrs.ts
|
|
@@ -1989,25 +1989,28 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
1989
1989
|
if (typeof renderer === "string") {
|
|
1990
1990
|
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
1991
1991
|
rendered = true;
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
if (
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
1992
|
+
const renderNative = () => {
|
|
1993
|
+
_scope_id();
|
|
1994
|
+
_html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`);
|
|
1995
|
+
if (!voidElementsReg.test(renderer)) {
|
|
1996
|
+
const renderContent = content || normalizeDynamicRenderer(input.content);
|
|
1997
|
+
if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
|
|
1998
|
+
else if (renderContent) {
|
|
1999
|
+
if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2000
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent, 1);
|
|
2001
|
+
else _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
|
|
2002
|
+
}
|
|
2003
|
+
_html(`</${renderer}>`);
|
|
2004
|
+
}
|
|
2005
|
+
const childScope = getScopeById(branchId);
|
|
2006
|
+
const needsScript = childScope && (childScope["EventAttributes:a"] || childScope["ControlledHandler:a"]);
|
|
2007
|
+
if (needsScript) {
|
|
2008
|
+
writeScope(branchId, { ["#Renderer"]: renderer });
|
|
2009
|
+
_script(branchId, "d");
|
|
2010
|
+
}
|
|
2011
|
+
if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
2012
|
+
};
|
|
2013
|
+
renderNative();
|
|
2011
2014
|
} else {
|
|
2012
2015
|
if (shouldResume) _html(state.mark("[", ""));
|
|
2013
2016
|
const render = () => {
|
|
@@ -2298,7 +2301,10 @@ function getScopeReasonDeclaration(section) {
|
|
|
2298
2301
|
return _marko_compiler.types.variableDeclaration("const", getSectionReasonState(section).declarators);
|
|
2299
2302
|
}
|
|
2300
2303
|
function getSerializeGuard(section, reason, optional) {
|
|
2301
|
-
if (!isReasonDynamic(reason) || isCrossSection(section, reason))
|
|
2304
|
+
if (!isReasonDynamic(reason) || isCrossSection(section, reason)) {
|
|
2305
|
+
if (!reason) return _marko_compiler.types.numericLiteral(0);
|
|
2306
|
+
return optional ? void 0 : withLeadingComment(_marko_compiler.types.numericLiteral(1), getDebugNames(reason === true ? void 0 : reason.state));
|
|
2307
|
+
}
|
|
2302
2308
|
return getOrHoist(reason, true);
|
|
2303
2309
|
}
|
|
2304
2310
|
function getSerializeGuardForAny(section, reasons, optional) {
|
|
@@ -3013,12 +3019,14 @@ function getSignalFn(signal) {
|
|
|
3013
3019
|
}
|
|
3014
3020
|
for (const value of signal.values) {
|
|
3015
3021
|
if (value.signal.inline) continue;
|
|
3016
|
-
if (signalHasStatements(value.signal))
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
+
if (signalHasStatements(value.signal)) {
|
|
3023
|
+
const invocation = _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(value.signal.identifier, [
|
|
3024
|
+
scopeIdentifier,
|
|
3025
|
+
value.value,
|
|
3026
|
+
...getTranslatedExtraArgs(value.signal)
|
|
3027
|
+
]));
|
|
3028
|
+
signal.render.push(invocation);
|
|
3029
|
+
} else signal.render.push(_marko_compiler.types.expressionStatement(withLeadingComment(value.value, getDebugNames(value.signal.referencedBindings))));
|
|
3022
3030
|
}
|
|
3023
3031
|
forEach(signal.intersection, (intersection) => {
|
|
3024
3032
|
signal.render.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(intersection.identifier, [scopeIdentifier])));
|
|
@@ -3150,13 +3158,16 @@ function addValue(targetSection, referencedBindings, signal, value) {
|
|
|
3150
3158
|
});
|
|
3151
3159
|
if (value.extra?.referencedBindingsInFunction) parentSignal.hasSideEffect = true;
|
|
3152
3160
|
}
|
|
3153
|
-
function
|
|
3154
|
-
const { markoOpts, opts: { filename } } = (0, _marko_compiler_babel_utils.getFile)();
|
|
3161
|
+
function buildResumeRegisterKey(section, referencedBindings, type) {
|
|
3155
3162
|
let name = "";
|
|
3156
3163
|
if (referencedBindings) if (typeof referencedBindings === "string") name += `_${referencedBindings}`;
|
|
3157
3164
|
else if (Array.isArray(referencedBindings)) for (const ref of referencedBindings) name += `_${ref.name}`;
|
|
3158
3165
|
else name += `_${referencedBindings.name}`;
|
|
3159
|
-
return
|
|
3166
|
+
return `${section.id}${name}${type ? "/" + type : ""}`;
|
|
3167
|
+
}
|
|
3168
|
+
function getResumeRegisterId(section, referencedBindings, type) {
|
|
3169
|
+
const { markoOpts, opts: { filename } } = (0, _marko_compiler_babel_utils.getFile)();
|
|
3170
|
+
return (0, _marko_compiler_babel_utils.getTemplateId)(markoOpts, filename, buildResumeRegisterKey(section, referencedBindings, type));
|
|
3160
3171
|
}
|
|
3161
3172
|
function writeSignals(section) {
|
|
3162
3173
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -3175,7 +3186,8 @@ function writeSignals(section) {
|
|
|
3175
3186
|
if (signal.effect.length) {
|
|
3176
3187
|
traverseReplace(signal, "effect", replaceEffectNode);
|
|
3177
3188
|
const effectIdentifier = _marko_compiler.types.identifier(`${signal.identifier.name}__script`);
|
|
3178
|
-
|
|
3189
|
+
const effectFn = _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], toFirstExpressionOrBlock(signal.effect));
|
|
3190
|
+
effectDeclarator = _marko_compiler.types.variableDeclarator(effectIdentifier, callRuntime("_script", _marko_compiler.types.stringLiteral(getResumeRegisterId(section, signal.referencedBindings)), effectFn));
|
|
3179
3191
|
}
|
|
3180
3192
|
let signalDeclaration;
|
|
3181
3193
|
if (signal.build) {
|
|
@@ -8488,7 +8500,7 @@ function checkStyleInterpolations(tag) {
|
|
|
8488
8500
|
let runAfterColon = false;
|
|
8489
8501
|
let runDecl = false;
|
|
8490
8502
|
const endRun = (selector) => {
|
|
8491
|
-
if (runPlaceholder && !runAfterColon &&
|
|
8503
|
+
if (runPlaceholder && (selector || !runAfterColon && runDecl)) throw tag.hub.buildError(runPlaceholder, selector ? styleSelectorMsg : stylePropertyMsg);
|
|
8492
8504
|
valueColon = false;
|
|
8493
8505
|
runPlaceholder = void 0;
|
|
8494
8506
|
};
|