marko 6.0.0-next.3.25 → 6.0.0-next.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/types.d.ts +4 -3
- package/dist/debug/dom.js +360 -340
- package/dist/debug/dom.mjs +360 -340
- package/dist/debug/html.js +7 -7
- package/dist/debug/html.mjs +7 -7
- package/dist/dom/compat.d.ts +3 -3
- package/dist/dom/dom.d.ts +2 -1
- package/dist/dom/reconcile.d.ts +1 -1
- package/dist/dom/renderer.d.ts +1 -1
- package/dist/dom/scope.d.ts +2 -2
- package/dist/dom/signals.d.ts +1 -1
- package/dist/dom/walker.d.ts +2 -2
- package/dist/dom.js +257 -249
- package/dist/dom.mjs +257 -249
- package/dist/html/writer.d.ts +3 -3
- package/dist/html.js +7 -7
- package/dist/html.mjs +7 -7
- package/dist/translator/index.js +40 -46
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/html/writer.d.ts
CHANGED
@@ -55,9 +55,9 @@ export declare class State {
|
|
55
55
|
renderId: string;
|
56
56
|
runtimeId: string;
|
57
57
|
};
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
tagId: number;
|
59
|
+
scopeId: number;
|
60
|
+
reorderId: number;
|
61
61
|
hasGlobals: boolean;
|
62
62
|
needsMainRuntime: boolean;
|
63
63
|
hasMainRuntime: boolean;
|
package/dist/html.js
CHANGED
@@ -1006,13 +1006,13 @@ function register2(val, id, scopeId) {
|
|
1006
1006
|
}
|
1007
1007
|
function nextTagId() {
|
1008
1008
|
let state = $chunk.boundary.state, { $global: $global2 } = state;
|
1009
|
-
return "s" + $global2.runtimeId + $global2.renderId + (state.
|
1009
|
+
return "s" + $global2.runtimeId + $global2.renderId + (state.tagId++).toString(36);
|
1010
1010
|
}
|
1011
1011
|
function nextScopeId() {
|
1012
|
-
return $chunk.boundary.state.
|
1012
|
+
return $chunk.boundary.state.scopeId++;
|
1013
1013
|
}
|
1014
1014
|
function peekNextScopeId() {
|
1015
|
-
return $chunk.boundary.state.
|
1015
|
+
return $chunk.boundary.state.scopeId;
|
1016
1016
|
}
|
1017
1017
|
function peekNextScope() {
|
1018
1018
|
return ensureScopeWithId(peekNextScopeId());
|
@@ -1220,9 +1220,9 @@ var State2 = class {
|
|
1220
1220
|
this.$global = $global2;
|
1221
1221
|
this.$global = $global2, $global2.cspNonce && (this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + ""));
|
1222
1222
|
}
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1223
|
+
tagId = 1;
|
1224
|
+
scopeId = 1;
|
1225
|
+
reorderId = 1;
|
1226
1226
|
hasGlobals = !1;
|
1227
1227
|
needsMainRuntime = !1;
|
1228
1228
|
hasMainRuntime = !1;
|
@@ -1246,7 +1246,7 @@ var State2 = class {
|
|
1246
1246
|
this.writeReorders ? this.writeReorders.push(chunk) : (this.needsMainRuntime = !0, this.writeReorders = [chunk]);
|
1247
1247
|
}
|
1248
1248
|
nextReorderId() {
|
1249
|
-
let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.
|
1249
|
+
let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.reorderId++, mod = index % encodeStartLen, id = encodeChars[mod];
|
1250
1250
|
for (index = (index - mod) / encodeStartLen; index > 0; )
|
1251
1251
|
mod = index % encodeLen, id += encodeChars[mod], index = (index - mod) / encodeLen;
|
1252
1252
|
return id;
|
package/dist/html.mjs
CHANGED
@@ -929,13 +929,13 @@ function register2(val, id, scopeId) {
|
|
929
929
|
}
|
930
930
|
function nextTagId() {
|
931
931
|
let state = $chunk.boundary.state, { $global: $global2 } = state;
|
932
|
-
return "s" + $global2.runtimeId + $global2.renderId + (state.
|
932
|
+
return "s" + $global2.runtimeId + $global2.renderId + (state.tagId++).toString(36);
|
933
933
|
}
|
934
934
|
function nextScopeId() {
|
935
|
-
return $chunk.boundary.state.
|
935
|
+
return $chunk.boundary.state.scopeId++;
|
936
936
|
}
|
937
937
|
function peekNextScopeId() {
|
938
|
-
return $chunk.boundary.state.
|
938
|
+
return $chunk.boundary.state.scopeId;
|
939
939
|
}
|
940
940
|
function peekNextScope() {
|
941
941
|
return ensureScopeWithId(peekNextScopeId());
|
@@ -1143,9 +1143,9 @@ var State2 = class {
|
|
1143
1143
|
this.$global = $global2;
|
1144
1144
|
this.$global = $global2, $global2.cspNonce && (this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + ""));
|
1145
1145
|
}
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1146
|
+
tagId = 1;
|
1147
|
+
scopeId = 1;
|
1148
|
+
reorderId = 1;
|
1149
1149
|
hasGlobals = !1;
|
1150
1150
|
needsMainRuntime = !1;
|
1151
1151
|
hasMainRuntime = !1;
|
@@ -1169,7 +1169,7 @@ var State2 = class {
|
|
1169
1169
|
this.writeReorders ? this.writeReorders.push(chunk) : (this.needsMainRuntime = !0, this.writeReorders = [chunk]);
|
1170
1170
|
}
|
1171
1171
|
nextReorderId() {
|
1172
|
-
let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.
|
1172
|
+
let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.reorderId++, mod = index % encodeStartLen, id = encodeChars[mod];
|
1173
1173
|
for (index = (index - mod) / encodeStartLen; index > 0; )
|
1174
1174
|
mod = index % encodeLen, id += encodeChars[mod], index = (index - mod) / encodeLen;
|
1175
1175
|
return id;
|
package/dist/translator/index.js
CHANGED
@@ -966,38 +966,13 @@ function createSectionState(key, init) {
|
|
966
966
|
// src/translator/util/tag-name-type.ts
|
967
967
|
var import_compiler5 = require("@marko/compiler");
|
968
968
|
var import_babel_utils6 = require("@marko/compiler/babel-utils");
|
969
|
-
|
970
|
-
// src/translator/util/with-previous-location.ts
|
971
|
-
function withPreviousLocation(newNode, originalNode) {
|
972
|
-
newNode.start = originalNode.start;
|
973
|
-
newNode.loc = originalNode.loc;
|
974
|
-
newNode.end = originalNode.end;
|
975
|
-
return newNode;
|
976
|
-
}
|
977
|
-
|
978
|
-
// src/translator/util/tag-name-type.ts
|
979
969
|
var MARKO_FILE_REG = /^<.*>$|\.marko$/;
|
980
|
-
var TAG_NAME_IDENTIFIER_REG = /^[A-Z][a-zA-Z0-9_$]*$/;
|
981
970
|
function analyzeTagNameType(tag) {
|
982
971
|
const extra = tag.node.extra ??= {};
|
983
972
|
if (extra.tagNameType === void 0) {
|
984
973
|
const name2 = tag.get("name");
|
985
974
|
if (name2.isStringLiteral()) {
|
986
975
|
extra.tagNameType = name2.node.value[0] === "@" ? 3 /* AttributeTag */ : (0, import_babel_utils6.isNativeTag)(tag) ? 0 /* NativeTag */ : 1 /* CustomTag */;
|
987
|
-
if (extra.tagNameType === 1 /* CustomTag */) {
|
988
|
-
const bindingName = name2.node.value;
|
989
|
-
const bindingIdentifier = tag.scope.getBinding(bindingName)?.identifier;
|
990
|
-
if (bindingIdentifier && TAG_NAME_IDENTIFIER_REG.test(bindingIdentifier.name)) {
|
991
|
-
const tagIdentifier = withPreviousLocation(
|
992
|
-
import_compiler5.types.identifier(bindingName),
|
993
|
-
name2.node
|
994
|
-
);
|
995
|
-
tagIdentifier.extra = {
|
996
|
-
referencedBindings: bindingIdentifier.extra?.binding
|
997
|
-
};
|
998
|
-
analyzeExpressionTagName(name2.replaceWith(tagIdentifier)[0], extra);
|
999
|
-
}
|
1000
|
-
}
|
1001
976
|
extra.tagNameNullable = extra.tagNameNullable = false;
|
1002
977
|
} else {
|
1003
978
|
analyzeExpressionTagName(name2, extra);
|
@@ -2045,7 +2020,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
2045
2020
|
buildSignalIntersections(signal)
|
2046
2021
|
);
|
2047
2022
|
};
|
2048
|
-
} else if (referencedBindings.section !== section) {
|
2023
|
+
} else if (referencedBindings.section !== section && bindingUtil.find(section.closures, referencedBindings)) {
|
2049
2024
|
getSignal(referencedBindings.section, referencedBindings).closures.set(
|
2050
2025
|
section,
|
2051
2026
|
signal
|
@@ -2066,7 +2041,6 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
2066
2041
|
const intersection = buildSignalIntersections(signal);
|
2067
2042
|
return isDynamicClosure ? callRuntime(
|
2068
2043
|
"dynamicClosure",
|
2069
|
-
getScopeAccessorLiteral(referencedBindings),
|
2070
2044
|
render,
|
2071
2045
|
isImmediateOwner ? null : import_compiler17.types.arrowFunctionExpression([scopeIdentifier], ownerScope),
|
2072
2046
|
intersection
|
@@ -3219,6 +3193,14 @@ function isFunctionExpression(path5) {
|
|
3219
3193
|
}
|
3220
3194
|
}
|
3221
3195
|
|
3196
|
+
// src/translator/util/with-previous-location.ts
|
3197
|
+
function withPreviousLocation(newNode, originalNode) {
|
3198
|
+
newNode.start = originalNode.start;
|
3199
|
+
newNode.loc = originalNode.loc;
|
3200
|
+
newNode.end = originalNode.end;
|
3201
|
+
return newNode;
|
3202
|
+
}
|
3203
|
+
|
3222
3204
|
// src/translator/util/references.ts
|
3223
3205
|
var [getBindings] = createProgramState(() => /* @__PURE__ */ new Set());
|
3224
3206
|
var [getNextBindingId, setNextBindingId] = createProgramState(() => 0);
|
@@ -9199,28 +9181,42 @@ var dynamic_tag_default = {
|
|
9199
9181
|
};
|
9200
9182
|
|
9201
9183
|
// src/translator/visitors/tag/index.ts
|
9184
|
+
var TAG_NAME_IDENTIFIER_REG = /^[A-Z][a-zA-Z0-9_$]*$/;
|
9202
9185
|
var tag_default = {
|
9203
9186
|
transform: {
|
9204
9187
|
enter(tag) {
|
9205
|
-
const
|
9206
|
-
|
9207
|
-
|
9208
|
-
|
9209
|
-
|
9188
|
+
const { node } = tag;
|
9189
|
+
const { name: name2, attributes } = tag.node;
|
9190
|
+
let crawl = false;
|
9191
|
+
if (import_compiler53.types.isStringLiteral(name2)) {
|
9192
|
+
const tagName = name2.value;
|
9193
|
+
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
9194
|
+
node.name = withPreviousLocation(import_compiler53.types.identifier(tagName), name2);
|
9195
|
+
crawl = true;
|
9196
|
+
}
|
9197
|
+
}
|
9198
|
+
for (let i = 0; i < attributes.length; i++) {
|
9199
|
+
const attr2 = attributes[i];
|
9200
|
+
if (import_compiler53.types.isMarkoAttribute(attr2) && attr2.bound) {
|
9201
|
+
attr2.bound = false;
|
9210
9202
|
const changeValue = getChangeHandler(tag, attr2);
|
9211
9203
|
if (changeValue === null) {
|
9212
|
-
throw
|
9204
|
+
throw tag.hub.buildError(
|
9205
|
+
attr2,
|
9213
9206
|
"Attributes may only be bound to identifiers or member expressions"
|
9214
9207
|
);
|
9215
9208
|
}
|
9216
|
-
|
9217
|
-
i
|
9209
|
+
attributes.splice(
|
9210
|
+
++i,
|
9218
9211
|
0,
|
9219
|
-
import_compiler53.types.markoAttribute(attr2.
|
9212
|
+
import_compiler53.types.markoAttribute(attr2.name + "Change", changeValue)
|
9220
9213
|
);
|
9221
|
-
|
9214
|
+
crawl = true;
|
9222
9215
|
}
|
9223
9216
|
}
|
9217
|
+
if (crawl) {
|
9218
|
+
tag.scope.crawl();
|
9219
|
+
}
|
9224
9220
|
}
|
9225
9221
|
},
|
9226
9222
|
analyze: {
|
@@ -9334,29 +9330,27 @@ var tag_default = {
|
|
9334
9330
|
}
|
9335
9331
|
};
|
9336
9332
|
function getChangeHandler(tag, attr2) {
|
9337
|
-
if (import_compiler53.types.isIdentifier(attr2.
|
9338
|
-
const valueId = tag.scope.generateUidIdentifier(
|
9339
|
-
"new_" + attr2.node.value.name
|
9340
|
-
);
|
9333
|
+
if (import_compiler53.types.isIdentifier(attr2.value)) {
|
9334
|
+
const valueId = tag.scope.generateUidIdentifier("new_" + attr2.value.name);
|
9341
9335
|
return import_compiler53.types.arrowFunctionExpression(
|
9342
9336
|
[valueId],
|
9343
9337
|
import_compiler53.types.blockStatement([
|
9344
9338
|
import_compiler53.types.expressionStatement(
|
9345
|
-
import_compiler53.types.assignmentExpression("=", import_compiler53.types.cloneNode(attr2.
|
9339
|
+
import_compiler53.types.assignmentExpression("=", import_compiler53.types.cloneNode(attr2.value), valueId)
|
9346
9340
|
)
|
9347
9341
|
])
|
9348
9342
|
);
|
9349
|
-
} else if (import_compiler53.types.isMemberExpression(attr2.
|
9350
|
-
const prop = attr2.
|
9343
|
+
} else if (import_compiler53.types.isMemberExpression(attr2.value)) {
|
9344
|
+
const prop = attr2.value.property;
|
9351
9345
|
if (import_compiler53.types.isPrivateName(prop)) return null;
|
9352
9346
|
if (import_compiler53.types.isIdentifier(prop)) {
|
9353
9347
|
return import_compiler53.types.memberExpression(
|
9354
|
-
import_compiler53.types.cloneNode(attr2.
|
9348
|
+
import_compiler53.types.cloneNode(attr2.value.object),
|
9355
9349
|
import_compiler53.types.identifier(prop.name + "Change")
|
9356
9350
|
);
|
9357
9351
|
} else {
|
9358
9352
|
return import_compiler53.types.memberExpression(
|
9359
|
-
import_compiler53.types.cloneNode(attr2.
|
9353
|
+
import_compiler53.types.cloneNode(attr2.value.object),
|
9360
9354
|
import_compiler53.types.binaryExpression("+", import_compiler53.types.cloneNode(prop), import_compiler53.types.stringLiteral("Change")),
|
9361
9355
|
true
|
9362
9356
|
);
|
package/index.d.ts
CHANGED
@@ -82,7 +82,7 @@ declare global {
|
|
82
82
|
/** Render and attach the template to a DOM node. */
|
83
83
|
abstract mount(
|
84
84
|
input: Marko.TemplateInput<Input>,
|
85
|
-
reference:
|
85
|
+
reference: Node,
|
86
86
|
position?: "afterbegin" | "afterend" | "beforebegin" | "beforeend",
|
87
87
|
): {
|
88
88
|
update(input: Marko.TemplateInput<Input>): void;
|