marko 6.0.152 → 6.0.154
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 +127 -193
- package/dist/debug/dom.mjs +127 -193
- package/dist/debug/html.js +3 -5
- package/dist/debug/html.mjs +3 -5
- package/dist/dom.js +56 -90
- package/dist/dom.mjs +56 -90
- package/dist/html.js +5 -5
- package/dist/html.mjs +5 -5
- package/dist/translator/index.js +32 -30
- package/dist/translator/util/known-tag.d.ts +0 -1
- package/package.json +3 -2
- package/dist/dom/reconcile.d.ts +0 -2
package/dist/dom.mjs
CHANGED
|
@@ -167,10 +167,11 @@ function destroyBranch(branch) {
|
|
|
167
167
|
), destroyNestedBranches(branch);
|
|
168
168
|
}
|
|
169
169
|
function destroyNestedBranches(branch) {
|
|
170
|
-
branch.I = 1, branch.D?.forEach(destroyNestedBranches), branch.B?.forEach(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
branch.I = 1, branch.D?.forEach(destroyNestedBranches), branch.B?.forEach(resetControllers);
|
|
171
|
+
}
|
|
172
|
+
function resetControllers(scope) {
|
|
173
|
+
for (let id in scope.A)
|
|
174
|
+
$signalReset(scope, id);
|
|
174
175
|
}
|
|
175
176
|
function removeAndDestroyBranch(branch) {
|
|
176
177
|
destroyBranch(branch), removeChildNodes(
|
|
@@ -335,7 +336,7 @@ function walk(startNode, walkCodes, branch) {
|
|
|
335
336
|
walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
|
|
336
337
|
}
|
|
337
338
|
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
338
|
-
let value,
|
|
339
|
+
let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
|
|
339
340
|
for (; currentWalkIndex < walkCodes.length; )
|
|
340
341
|
if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32 /* Get */) {
|
|
341
342
|
let node = walker.currentNode;
|
|
@@ -960,81 +961,6 @@ function toInsertNode(startNode, endNode) {
|
|
|
960
961
|
return parent;
|
|
961
962
|
}
|
|
962
963
|
|
|
963
|
-
// src/dom/reconcile.ts
|
|
964
|
-
var WRONG_POS = 2147483647;
|
|
965
|
-
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
966
|
-
let oldStart = 0, newStart = 0, oldEnd = oldBranches.length - 1, newEnd = newBranches.length - 1, oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart], oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd], i, j, k, nextSibling, oldBranch, newBranch;
|
|
967
|
-
outer: {
|
|
968
|
-
for (; oldStartBranch === newStartBranch; ) {
|
|
969
|
-
if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
|
|
970
|
-
break outer;
|
|
971
|
-
oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
|
|
972
|
-
}
|
|
973
|
-
for (; oldEndBranch === newEndBranch; ) {
|
|
974
|
-
if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
|
|
975
|
-
break outer;
|
|
976
|
-
oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
if (oldStart > oldEnd) {
|
|
980
|
-
if (newStart <= newEnd) {
|
|
981
|
-
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].S : afterReference;
|
|
982
|
-
do
|
|
983
|
-
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
|
984
|
-
while (newStart <= newEnd);
|
|
985
|
-
}
|
|
986
|
-
} else if (newStart > newEnd)
|
|
987
|
-
do
|
|
988
|
-
removeAndDestroyBranch(oldBranches[oldStart++]);
|
|
989
|
-
while (oldStart <= oldEnd);
|
|
990
|
-
else {
|
|
991
|
-
let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
|
|
992
|
-
for (i = 0; i < newLength; ++i)
|
|
993
|
-
sources[i] = -1;
|
|
994
|
-
let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
|
|
995
|
-
for (j = newStart; j <= newEnd; ++j)
|
|
996
|
-
keyIndex.set(newBranches[j], j);
|
|
997
|
-
for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
|
|
998
|
-
oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
|
|
999
|
-
if (oldLength === oldBranches.length && synced === 0) {
|
|
1000
|
-
for (; newStart < newLength; ++newStart)
|
|
1001
|
-
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
|
1002
|
-
for (; oldStart < oldLength; ++oldStart)
|
|
1003
|
-
removeAndDestroyBranch(oldBranches[oldStart]);
|
|
1004
|
-
} else {
|
|
1005
|
-
for (i = oldLength - synced; i > 0; )
|
|
1006
|
-
oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
|
|
1007
|
-
if (pos === WRONG_POS) {
|
|
1008
|
-
let seq = longestIncreasingSubsequence(sources);
|
|
1009
|
-
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
|
1010
|
-
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].S : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].S : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : --j;
|
|
1011
|
-
} else if (synced !== newLength)
|
|
1012
|
-
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
|
1013
|
-
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].S : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
function longestIncreasingSubsequence(a) {
|
|
1018
|
-
let p = a.slice(), result = [0], u, v;
|
|
1019
|
-
for (let i = 0, il = a.length; i < il; ++i) {
|
|
1020
|
-
if (a[i] === -1)
|
|
1021
|
-
continue;
|
|
1022
|
-
let j = result[result.length - 1];
|
|
1023
|
-
if (a[j] < a[i]) {
|
|
1024
|
-
p[i] = j, result.push(i);
|
|
1025
|
-
continue;
|
|
1026
|
-
}
|
|
1027
|
-
for (u = 0, v = result.length - 1; u < v; ) {
|
|
1028
|
-
let c = (u + v) / 2 | 0;
|
|
1029
|
-
a[result[c]] < a[i] ? u = c + 1 : v = c;
|
|
1030
|
-
}
|
|
1031
|
-
a[i] < a[result[u]] && (u > 0 && (p[i] = result[u - 1]), result[u] = i);
|
|
1032
|
-
}
|
|
1033
|
-
for (u = result.length, v = result[u - 1]; u-- > 0; )
|
|
1034
|
-
result[u] = v, v = p[v];
|
|
1035
|
-
return result;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
964
|
// src/dom/control-flow.ts
|
|
1039
965
|
function _await_promise(nodeAccessor, params) {
|
|
1040
966
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
@@ -1288,23 +1214,63 @@ var _for_of = loop(([all, by = bySecondArg], cb) => {
|
|
|
1288
1214
|
function loop(forEach) {
|
|
1289
1215
|
return (nodeAccessor, template, walks, setup, params) => {
|
|
1290
1216
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1291
|
-
let scopesAccessor = "A" /* BranchScopes */ + nodeAccessor,
|
|
1217
|
+
let scopesAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1292
1218
|
return enableBranches(), (scope, value) => {
|
|
1293
|
-
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]),
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
), newScopes = scope[scopesAccessor] = [], newScopesByKey = scope[scopesByKeyAccessor] = /* @__PURE__ */ new Map(), parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode;
|
|
1219
|
+
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = [], oldLen = oldScopes.length, parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode, oldScopesByKey, hasPotentialMoves;
|
|
1220
|
+
if (0)
|
|
1221
|
+
var seenKeys;
|
|
1297
1222
|
forEach(value, (key, args) => {
|
|
1298
|
-
let branch = oldScopesByKey
|
|
1223
|
+
let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce(
|
|
1224
|
+
(map, scope2, i) => map.set(scope2.M ?? i, scope2),
|
|
1225
|
+
/* @__PURE__ */ new Map()
|
|
1226
|
+
)).get(key);
|
|
1227
|
+
branch ? hasPotentialMoves = oldScopesByKey.delete(key) : branch = createAndSetupBranch(
|
|
1299
1228
|
scope.$,
|
|
1300
1229
|
renderer,
|
|
1301
1230
|
scope,
|
|
1302
1231
|
parentNode
|
|
1303
|
-
);
|
|
1304
|
-
branch.M = key, params?.(branch, args), newScopesByKey.set(key, branch), newScopes.push(branch);
|
|
1232
|
+
), branch.M = key, newScopes.push(branch), params?.(branch, args);
|
|
1305
1233
|
});
|
|
1306
|
-
let afterReference = null;
|
|
1307
|
-
|
|
1234
|
+
let newLen = newScopes.length, hasSiblings = referenceNode !== parentNode, afterReference = null, oldEnd = oldLen - 1, newEnd = newLen - 1, start = 0;
|
|
1235
|
+
if (hasSiblings && (oldLen ? (afterReference = oldScopes[oldEnd].K.nextSibling, newLen || parentNode.insertBefore(referenceNode, afterReference)) : newLen && (afterReference = referenceNode.nextSibling, referenceNode.remove())), !hasPotentialMoves) {
|
|
1236
|
+
oldLen && (oldScopes.forEach(
|
|
1237
|
+
hasSiblings ? removeAndDestroyBranch : destroyBranch
|
|
1238
|
+
), hasSiblings || (parentNode.textContent = ""));
|
|
1239
|
+
for (let newScope of newScopes)
|
|
1240
|
+
insertBranchBefore(newScope, parentNode, afterReference);
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
for (let branch of oldScopesByKey.values())
|
|
1244
|
+
removeAndDestroyBranch(branch);
|
|
1245
|
+
for (; start < oldLen && start < newLen && oldScopes[start] === newScopes[start]; )
|
|
1246
|
+
start++;
|
|
1247
|
+
for (; oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd]; )
|
|
1248
|
+
oldEnd--, newEnd--;
|
|
1249
|
+
if (oldEnd + 1 < oldLen && (afterReference = oldScopes[oldEnd + 1].S), start > oldEnd) {
|
|
1250
|
+
if (start <= newEnd)
|
|
1251
|
+
for (let i = start; i <= newEnd; i++)
|
|
1252
|
+
insertBranchBefore(newScopes[i], parentNode, afterReference);
|
|
1253
|
+
return;
|
|
1254
|
+
} else if (start > newEnd)
|
|
1255
|
+
return;
|
|
1256
|
+
let diffLen = newEnd - start + 1, oldPos = /* @__PURE__ */ new Map(), sources = new Array(diffLen), pred = new Array(diffLen), tails = [], tail = -1, lo, hi, mid;
|
|
1257
|
+
for (let i = start; i <= oldEnd; i++)
|
|
1258
|
+
oldPos.set(oldScopes[i], i);
|
|
1259
|
+
for (let i = diffLen; i--; )
|
|
1260
|
+
sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
|
|
1261
|
+
for (let i = 0; i < diffLen; i++)
|
|
1262
|
+
if (~sources[i])
|
|
1263
|
+
if (tail < 0 || sources[tails[tail]] < sources[i])
|
|
1264
|
+
~tail && (pred[i] = tails[tail]), tails[++tail] = i;
|
|
1265
|
+
else {
|
|
1266
|
+
for (lo = 0, hi = tail; lo < hi; )
|
|
1267
|
+
mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
|
|
1268
|
+
sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
|
|
1269
|
+
}
|
|
1270
|
+
for (hi = tails[tail], lo = tail + 1; lo-- > 0; )
|
|
1271
|
+
tails[lo] = hi, hi = pred[hi];
|
|
1272
|
+
for (let i = diffLen; i--; )
|
|
1273
|
+
~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
|
|
1308
1274
|
};
|
|
1309
1275
|
};
|
|
1310
1276
|
}
|
package/dist/html.js
CHANGED
|
@@ -542,7 +542,7 @@ function getRegistered(val) {
|
|
|
542
542
|
return { id: registered.id, scope: registered.scope };
|
|
543
543
|
}
|
|
544
544
|
function writeRoot(state, root) {
|
|
545
|
-
let { buf } = state, hadBuf = buf.length !== 0, result
|
|
545
|
+
let { buf } = state, hadBuf = buf.length !== 0, result;
|
|
546
546
|
if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
|
|
547
547
|
let rootRef = state.refs.get(root);
|
|
548
548
|
if (rootRef) {
|
|
@@ -836,7 +836,7 @@ function writeSet(state, val, ref) {
|
|
|
836
836
|
), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
|
|
837
837
|
}
|
|
838
838
|
function writeArrayBuffer(state, val) {
|
|
839
|
-
let result
|
|
839
|
+
let result;
|
|
840
840
|
if (val.byteLength) {
|
|
841
841
|
let view = new Int8Array(val);
|
|
842
842
|
result = hasOnlyZeros(view) ? "new ArrayBuffer(" + val.byteLength + ")" : "new Int8Array(" + typedArrayToInitString(view) + ").buffer";
|
|
@@ -887,7 +887,7 @@ function writeRequest(state, val, ref) {
|
|
|
887
887
|
let options = "";
|
|
888
888
|
val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
|
|
889
889
|
let headers = stringEntriesToProps(val.headers);
|
|
890
|
-
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)
|
|
890
|
+
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(
|
|
891
891
|
hasBody ? options + "})" : options ? ",{" + options + "})" : ")"
|
|
892
892
|
), !0;
|
|
893
893
|
}
|
|
@@ -895,7 +895,7 @@ function writeResponse(state, val, ref) {
|
|
|
895
895
|
let sep = "", options = "";
|
|
896
896
|
val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
|
|
897
897
|
let headers = stringEntriesToProps(val.headers);
|
|
898
|
-
return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}"
|
|
898
|
+
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(
|
|
899
899
|
"new Response" + (options ? "(null,{" + options + "})" : "")
|
|
900
900
|
) : (state.buf.push("new Response("), state.buf.push(
|
|
901
901
|
(writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")")
|
|
@@ -2008,7 +2008,7 @@ var RENDERER_REGISTER_ID = "$C_r", SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_I
|
|
|
2008
2008
|
|
|
2009
2009
|
// src/html/dynamic-tag.ts
|
|
2010
2010
|
var 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) => {
|
|
2011
|
-
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered
|
|
2011
|
+
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
|
|
2012
2012
|
if (typeof renderer == "string") {
|
|
2013
2013
|
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
2014
2014
|
if (rendered = !0, _scope_id(), _html(
|
package/dist/html.mjs
CHANGED
|
@@ -452,7 +452,7 @@ function getRegistered(val) {
|
|
|
452
452
|
return { id: registered.id, scope: registered.scope };
|
|
453
453
|
}
|
|
454
454
|
function writeRoot(state, root) {
|
|
455
|
-
let { buf } = state, hadBuf = buf.length !== 0, result
|
|
455
|
+
let { buf } = state, hadBuf = buf.length !== 0, result;
|
|
456
456
|
if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
|
|
457
457
|
let rootRef = state.refs.get(root);
|
|
458
458
|
if (rootRef) {
|
|
@@ -746,7 +746,7 @@ function writeSet(state, val, ref) {
|
|
|
746
746
|
), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
|
|
747
747
|
}
|
|
748
748
|
function writeArrayBuffer(state, val) {
|
|
749
|
-
let result
|
|
749
|
+
let result;
|
|
750
750
|
if (val.byteLength) {
|
|
751
751
|
let view = new Int8Array(val);
|
|
752
752
|
result = hasOnlyZeros(view) ? "new ArrayBuffer(" + val.byteLength + ")" : "new Int8Array(" + typedArrayToInitString(view) + ").buffer";
|
|
@@ -797,7 +797,7 @@ function writeRequest(state, val, ref) {
|
|
|
797
797
|
let options = "";
|
|
798
798
|
val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
|
|
799
799
|
let headers = stringEntriesToProps(val.headers);
|
|
800
|
-
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)
|
|
800
|
+
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(
|
|
801
801
|
hasBody ? options + "})" : options ? ",{" + options + "})" : ")"
|
|
802
802
|
), !0;
|
|
803
803
|
}
|
|
@@ -805,7 +805,7 @@ function writeResponse(state, val, ref) {
|
|
|
805
805
|
let sep = "", options = "";
|
|
806
806
|
val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
|
|
807
807
|
let headers = stringEntriesToProps(val.headers);
|
|
808
|
-
return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}"
|
|
808
|
+
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(
|
|
809
809
|
"new Response" + (options ? "(null,{" + options + "})" : "")
|
|
810
810
|
) : (state.buf.push("new Response("), state.buf.push(
|
|
811
811
|
(writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")")
|
|
@@ -1918,7 +1918,7 @@ var RENDERER_REGISTER_ID = "$C_r", SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_I
|
|
|
1918
1918
|
|
|
1919
1919
|
// src/html/dynamic-tag.ts
|
|
1920
1920
|
var 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) => {
|
|
1921
|
-
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered
|
|
1921
|
+
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
|
|
1922
1922
|
if (typeof renderer == "string") {
|
|
1923
1923
|
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
1924
1924
|
if (rendered = !0, _scope_id(), _html(
|
package/dist/translator/index.js
CHANGED
|
@@ -9388,7 +9388,7 @@ function createSources(state, param) {
|
|
|
9388
9388
|
return { state, param };
|
|
9389
9389
|
}
|
|
9390
9390
|
function compareSources(a, b) {
|
|
9391
|
-
let delta
|
|
9391
|
+
let delta;
|
|
9392
9392
|
if (a.param) {
|
|
9393
9393
|
if (!b.param) return 1;
|
|
9394
9394
|
if (delta = compareReferences(a.param, b.param)) return delta;
|
|
@@ -9775,21 +9775,21 @@ function findClosestReference(from, refs) {
|
|
|
9775
9775
|
return from;
|
|
9776
9776
|
}
|
|
9777
9777
|
for (const ref of refs) {
|
|
9778
|
-
const
|
|
9779
|
-
if (
|
|
9778
|
+
const closest2 = findClosestUpstream(from, ref);
|
|
9779
|
+
if (closest2) return closest2;
|
|
9780
9780
|
}
|
|
9781
9781
|
} else {
|
|
9782
|
-
const
|
|
9783
|
-
if (
|
|
9782
|
+
const closest2 = findClosestUpstream(from, refs);
|
|
9783
|
+
if (closest2) return closest2;
|
|
9784
9784
|
}
|
|
9785
9785
|
}
|
|
9786
9786
|
function findClosestUpstream(from, to) {
|
|
9787
|
-
let
|
|
9787
|
+
let closest2 = from;
|
|
9788
9788
|
do {
|
|
9789
|
-
if (
|
|
9790
|
-
return
|
|
9789
|
+
if (closest2 === to) {
|
|
9790
|
+
return closest2;
|
|
9791
9791
|
}
|
|
9792
|
-
} while (
|
|
9792
|
+
} while (closest2 = closest2.upstreamAlias);
|
|
9793
9793
|
}
|
|
9794
9794
|
function getRootBindings(reads) {
|
|
9795
9795
|
let rootRefs;
|
|
@@ -12396,22 +12396,13 @@ var attribute_tag_default = {
|
|
|
12396
12396
|
// src/translator/visitors/tag/custom-tag.ts
|
|
12397
12397
|
var import_compiler61 = require("@marko/compiler");
|
|
12398
12398
|
var import_babel_utils49 = require("@marko/compiler/babel-utils");
|
|
12399
|
+
var import_fastest_levenshtein = require("fastest-levenshtein");
|
|
12399
12400
|
var import_path4 = __toESM(require("path"));
|
|
12400
12401
|
var custom_tag_default = {
|
|
12401
12402
|
analyze: {
|
|
12402
12403
|
enter(tag) {
|
|
12403
12404
|
const templateFile = (0, import_babel_utils49.getTagTemplate)(tag);
|
|
12404
|
-
if (!templateFile)
|
|
12405
|
-
const tagName = getTagName(tag);
|
|
12406
|
-
if (tagName && tag.scope.hasBinding(tagName)) {
|
|
12407
|
-
throw tag.get("name").buildCodeFrameError(
|
|
12408
|
-
`Local variables must be in a [dynamic tag](https://markojs.com/docs/reference/language#dynamic-tags) unless they are PascalCase. Use \`<\${${tagName}}/>\` or rename to \`${tagName.charAt(0).toUpperCase() + tagName.slice(1)}\`.`
|
|
12409
|
-
);
|
|
12410
|
-
}
|
|
12411
|
-
throw tag.get("name").buildCodeFrameError(
|
|
12412
|
-
`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.`
|
|
12413
|
-
);
|
|
12414
|
-
}
|
|
12405
|
+
if (!templateFile) throw tagNotFoundError(tag);
|
|
12415
12406
|
(0, import_babel_utils49.assertAttributesOrSingleArg)(tag);
|
|
12416
12407
|
const childFile = (0, import_babel_utils49.loadFileForTag)(tag);
|
|
12417
12408
|
if (!childFile) {
|
|
@@ -12542,18 +12533,29 @@ function getTagRelativePath(tag) {
|
|
|
12542
12533
|
} else if (node.extra?.tagNameImported) {
|
|
12543
12534
|
relativePath = node.extra.tagNameImported;
|
|
12544
12535
|
}
|
|
12545
|
-
if (!relativePath)
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12549
|
-
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
|
|
12553
|
-
`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.`
|
|
12536
|
+
if (!relativePath) throw tagNotFoundError(tag);
|
|
12537
|
+
return relativePath;
|
|
12538
|
+
}
|
|
12539
|
+
function tagNotFoundError(tag) {
|
|
12540
|
+
const tagName = getTagName(tag);
|
|
12541
|
+
if (tagName && tag.scope.hasBinding(tagName)) {
|
|
12542
|
+
return tag.get("name").buildCodeFrameError(
|
|
12543
|
+
`Local variables must be in a [dynamic tag](https://markojs.com/docs/reference/language#dynamic-tags) unless they are PascalCase. Use \`<\${${tagName}}/>\` or rename to \`${tagName.charAt(0).toUpperCase() + tagName.slice(1)}\`.`
|
|
12554
12544
|
);
|
|
12555
12545
|
}
|
|
12556
|
-
|
|
12546
|
+
let didYouMean = "";
|
|
12547
|
+
if (tagName) {
|
|
12548
|
+
const closestTag = (0, import_fastest_levenshtein.closest)(
|
|
12549
|
+
tagName,
|
|
12550
|
+
Object.keys(tag.state.file.___taglibLookup.merged.tags)
|
|
12551
|
+
);
|
|
12552
|
+
if ((0, import_fastest_levenshtein.distance)(tagName, closestTag) < 4) {
|
|
12553
|
+
didYouMean = ` Did you mean \`<${closestTag}>\`?`;
|
|
12554
|
+
}
|
|
12555
|
+
}
|
|
12556
|
+
return tag.get("name").buildCodeFrameError(
|
|
12557
|
+
`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.${didYouMean}`
|
|
12558
|
+
);
|
|
12557
12559
|
}
|
|
12558
12560
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
12559
12561
|
if (isCircularRequest(file, request)) {
|
|
@@ -21,6 +21,5 @@ declare module "@marko/compiler/dist/types" {
|
|
|
21
21
|
export declare function knownTagAnalyze(tag: t.NodePath<t.MarkoTag>, contentSection: Section, propTree: BindingPropTree | undefined): void;
|
|
22
22
|
export declare function knownTagTranslateHTML(tag: t.NodePath<t.MarkoTag>, tagIdentifier: t.Expression, contentSection: Section, propTree: BindingPropTree | undefined): void;
|
|
23
23
|
export declare function knownTagTranslateDOM(tag: t.NodePath<t.MarkoTag>, propTree: BindingPropTree | undefined, getBindingIdentifier: (binding: Binding, preferedName?: string) => t.Identifier, callSetup: (section: Section, childBinding: Binding) => void): void;
|
|
24
|
-
export declare function getTagRelativePath(tag: t.NodePath<t.MarkoTag>): string;
|
|
25
24
|
export declare function finalizeKnownTags(section: Section): void;
|
|
26
25
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.154",
|
|
4
4
|
"description": "Optimized runtime for Marko templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
"build": "node -r ~ts ./scripts/bundle.ts"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@marko/compiler": "^5.39.
|
|
51
|
+
"@marko/compiler": "^5.39.59",
|
|
52
52
|
"csstype": "^3.2.3",
|
|
53
|
+
"fastest-levenshtein": "^1.0.16",
|
|
53
54
|
"magic-string": "^0.30.21"
|
|
54
55
|
},
|
|
55
56
|
"engines": {
|
package/dist/dom/reconcile.d.ts
DELETED