marko 6.0.155 → 6.0.157

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.
@@ -133,33 +133,33 @@ var AccessorPrefix = /* @__PURE__ */ ((AccessorPrefix4) => {
133
133
  AccessorPrefix4["TagVariableChange"] = "TagVariableChange:";
134
134
  return AccessorPrefix4;
135
135
  })(AccessorPrefix || {});
136
- var AccessorProp = /* @__PURE__ */ ((AccessorProp5) => {
137
- AccessorProp5["Global"] = "$global";
138
- AccessorProp5["Owner"] = "_";
139
- AccessorProp5["AbortControllers"] = "#AbortControllers";
140
- AccessorProp5["AbortScopes"] = "#AbortScopes";
141
- AccessorProp5["AwaitCounter"] = "#AwaitCounter";
142
- AccessorProp5["BranchAccessor"] = "#BranchAccessor";
143
- AccessorProp5["BranchScopes"] = "#BranchScopes";
144
- AccessorProp5["CatchContent"] = "#CatchContent";
145
- AccessorProp5["ClosestBranch"] = "#ClosestBranch";
146
- AccessorProp5["ClosestBranchId"] = "#ClosestBranchId";
147
- AccessorProp5["Creating"] = "#Creating";
148
- AccessorProp5["Destroyed"] = "#Destroyed";
149
- AccessorProp5["DetachedAwait"] = "#DetachedAwait";
150
- AccessorProp5["EndNode"] = "#EndNode";
151
- AccessorProp5["Id"] = "#Id";
152
- AccessorProp5["LoopKey"] = "#LoopKey";
153
- AccessorProp5["ParentBranch"] = "#ParentBranch";
154
- AccessorProp5["PendingEffects"] = "#PendingEffects";
155
- AccessorProp5["PendingRenders"] = "#PendingRenders";
156
- AccessorProp5["PlaceholderBranch"] = "#PlaceholderBranch";
157
- AccessorProp5["PlaceholderContent"] = "#PlaceholderContent";
158
- AccessorProp5["Renderer"] = "#Renderer";
159
- AccessorProp5["StartNode"] = "#StartNode";
160
- AccessorProp5["TagVariable"] = "#TagVariable";
161
- AccessorProp5["TagVariableChange"] = "#TagVariableChange";
162
- return AccessorProp5;
136
+ var AccessorProp = /* @__PURE__ */ ((AccessorProp6) => {
137
+ AccessorProp6["Global"] = "$global";
138
+ AccessorProp6["Owner"] = "_";
139
+ AccessorProp6["AbortControllers"] = "#AbortControllers";
140
+ AccessorProp6["AbortScopes"] = "#AbortScopes";
141
+ AccessorProp6["AwaitCounter"] = "#AwaitCounter";
142
+ AccessorProp6["BranchAccessor"] = "#BranchAccessor";
143
+ AccessorProp6["BranchScopes"] = "#BranchScopes";
144
+ AccessorProp6["CatchContent"] = "#CatchContent";
145
+ AccessorProp6["ClosestBranch"] = "#ClosestBranch";
146
+ AccessorProp6["ClosestBranchId"] = "#ClosestBranchId";
147
+ AccessorProp6["Creating"] = "#Creating";
148
+ AccessorProp6["Destroyed"] = "#Destroyed";
149
+ AccessorProp6["DetachedAwait"] = "#DetachedAwait";
150
+ AccessorProp6["EndNode"] = "#EndNode";
151
+ AccessorProp6["Id"] = "#Id";
152
+ AccessorProp6["LoopKey"] = "#LoopKey";
153
+ AccessorProp6["ParentBranch"] = "#ParentBranch";
154
+ AccessorProp6["PendingEffects"] = "#PendingEffects";
155
+ AccessorProp6["PendingRenders"] = "#PendingRenders";
156
+ AccessorProp6["PlaceholderBranch"] = "#PlaceholderBranch";
157
+ AccessorProp6["PlaceholderContent"] = "#PlaceholderContent";
158
+ AccessorProp6["Renderer"] = "#Renderer";
159
+ AccessorProp6["StartNode"] = "#StartNode";
160
+ AccessorProp6["TagVariable"] = "#TagVariable";
161
+ AccessorProp6["TagVariableChange"] = "#TagVariableChange";
162
+ return AccessorProp6;
163
163
  })(AccessorProp || {});
164
164
 
165
165
  // src/translator/util/evaluate.ts
@@ -253,6 +253,7 @@ function isNullableExpr(expr) {
253
253
  // src/translator/util/references.ts
254
254
  var import_compiler38 = require("@marko/compiler");
255
255
  var import_babel_utils26 = require("@marko/compiler/babel-utils");
256
+ var import_config = require("@marko/compiler/config");
256
257
 
257
258
  // src/common/helpers.ts
258
259
  function classValue(classValue2) {
@@ -1298,33 +1299,33 @@ var AccessorPrefix2 = /* @__PURE__ */ ((AccessorPrefix4) => {
1298
1299
  AccessorPrefix4["TagVariableChange"] = "M";
1299
1300
  return AccessorPrefix4;
1300
1301
  })(AccessorPrefix2 || {});
1301
- var AccessorProp2 = /* @__PURE__ */ ((AccessorProp5) => {
1302
- AccessorProp5["Global"] = "$";
1303
- AccessorProp5["Owner"] = "_";
1304
- AccessorProp5["AbortControllers"] = "A";
1305
- AccessorProp5["AbortScopes"] = "B";
1306
- AccessorProp5["AwaitCounter"] = "O";
1307
- AccessorProp5["BranchAccessor"] = "C";
1308
- AccessorProp5["BranchScopes"] = "D";
1309
- AccessorProp5["CatchContent"] = "E";
1310
- AccessorProp5["ClosestBranch"] = "F";
1311
- AccessorProp5["ClosestBranchId"] = "G";
1312
- AccessorProp5["Creating"] = "H";
1313
- AccessorProp5["Destroyed"] = "I";
1314
- AccessorProp5["DetachedAwait"] = "V";
1315
- AccessorProp5["EndNode"] = "K";
1316
- AccessorProp5["Id"] = "L";
1317
- AccessorProp5["LoopKey"] = "M";
1318
- AccessorProp5["ParentBranch"] = "N";
1319
- AccessorProp5["PendingEffects"] = "J";
1320
- AccessorProp5["PendingRenders"] = "W";
1321
- AccessorProp5["PlaceholderBranch"] = "P";
1322
- AccessorProp5["PlaceholderContent"] = "Q";
1323
- AccessorProp5["Renderer"] = "R";
1324
- AccessorProp5["StartNode"] = "S";
1325
- AccessorProp5["TagVariable"] = "T";
1326
- AccessorProp5["TagVariableChange"] = "U";
1327
- return AccessorProp5;
1302
+ var AccessorProp2 = /* @__PURE__ */ ((AccessorProp6) => {
1303
+ AccessorProp6["Global"] = "$";
1304
+ AccessorProp6["Owner"] = "_";
1305
+ AccessorProp6["AbortControllers"] = "A";
1306
+ AccessorProp6["AbortScopes"] = "B";
1307
+ AccessorProp6["AwaitCounter"] = "O";
1308
+ AccessorProp6["BranchAccessor"] = "C";
1309
+ AccessorProp6["BranchScopes"] = "D";
1310
+ AccessorProp6["CatchContent"] = "E";
1311
+ AccessorProp6["ClosestBranch"] = "F";
1312
+ AccessorProp6["ClosestBranchId"] = "G";
1313
+ AccessorProp6["Creating"] = "H";
1314
+ AccessorProp6["Destroyed"] = "I";
1315
+ AccessorProp6["DetachedAwait"] = "V";
1316
+ AccessorProp6["EndNode"] = "K";
1317
+ AccessorProp6["Id"] = "L";
1318
+ AccessorProp6["LoopKey"] = "M";
1319
+ AccessorProp6["ParentBranch"] = "N";
1320
+ AccessorProp6["PendingEffects"] = "J";
1321
+ AccessorProp6["PendingRenders"] = "W";
1322
+ AccessorProp6["PlaceholderBranch"] = "P";
1323
+ AccessorProp6["PlaceholderContent"] = "Q";
1324
+ AccessorProp6["Renderer"] = "R";
1325
+ AccessorProp6["StartNode"] = "S";
1326
+ AccessorProp6["TagVariable"] = "T";
1327
+ AccessorProp6["TagVariableChange"] = "U";
1328
+ return AccessorProp6;
1328
1329
  })(AccessorProp2 || {});
1329
1330
 
1330
1331
  // src/translator/util/marko-config.ts
@@ -2169,87 +2170,6 @@ function isStaticRoot(path7) {
2169
2170
  }
2170
2171
  }
2171
2172
 
2172
- // src/translator/util/for-each-identifier.ts
2173
- function forEachIdentifier(node, cb) {
2174
- switch (node.type) {
2175
- case "ObjectPattern":
2176
- for (const prop of node.properties) {
2177
- switch (prop.type) {
2178
- case "ObjectProperty":
2179
- if (prop.value.type === "AssignmentPattern") {
2180
- forEachIdentifier(prop.value.left, cb);
2181
- } else {
2182
- forEachIdentifier(prop.value, cb);
2183
- }
2184
- break;
2185
- case "RestElement":
2186
- forEachIdentifier(prop.argument, cb);
2187
- break;
2188
- }
2189
- }
2190
- break;
2191
- case "ArrayPattern":
2192
- for (const el of node.elements) {
2193
- if (el != null) {
2194
- switch (el.type) {
2195
- case "RestElement":
2196
- forEachIdentifier(el.argument, cb);
2197
- break;
2198
- case "AssignmentPattern":
2199
- forEachIdentifier(el.left, cb);
2200
- break;
2201
- default:
2202
- forEachIdentifier(el, cb);
2203
- break;
2204
- }
2205
- }
2206
- }
2207
- break;
2208
- case "Identifier":
2209
- cb(node);
2210
- break;
2211
- }
2212
- }
2213
- function forEachIdentifierPath(nodePath, cb) {
2214
- if (nodePath.isIdentifier()) {
2215
- cb(nodePath);
2216
- } else if (nodePath.isObjectPattern()) {
2217
- for (const prop of nodePath.get("properties")) {
2218
- if (prop.isObjectProperty()) {
2219
- const value = prop.get("value");
2220
- if (value.isAssignmentPattern()) {
2221
- forEachIdentifierPath(value.get("left"), cb);
2222
- } else {
2223
- forEachIdentifierPath(value, cb);
2224
- }
2225
- } else if (prop.isRestElement()) {
2226
- forEachIdentifierPath(prop.get("argument"), cb);
2227
- }
2228
- }
2229
- } else if (nodePath.isArrayPattern()) {
2230
- for (const el of nodePath.get("elements")) {
2231
- if (el) {
2232
- if (el.isRestElement()) {
2233
- forEachIdentifierPath(el.get("argument"), cb);
2234
- } else if (el.isAssignmentPattern()) {
2235
- forEachIdentifierPath(el.get("left"), cb);
2236
- } else {
2237
- forEachIdentifierPath(el, cb);
2238
- }
2239
- }
2240
- }
2241
- }
2242
- }
2243
-
2244
- // src/translator/util/is-event-or-change-handler.ts
2245
- function isEventOrChangeHandler(prop) {
2246
- return /^on[-A-Z][a-zA-Z0-9_$]|[a-zA-Z_$][a-zA-Z0-9_$]*Change$/.test(prop);
2247
- }
2248
-
2249
- // src/translator/util/known-tag.ts
2250
- var import_compiler37 = require("@marko/compiler");
2251
- var import_babel_utils25 = require("@marko/compiler/babel-utils");
2252
-
2253
2173
  // src/translator/visitors/program/index.ts
2254
2174
  var import_compiler27 = require("@marko/compiler");
2255
2175
  var import_babel_utils17 = require("@marko/compiler/babel-utils");
@@ -2336,18 +2256,26 @@ var entry_builder_default = {
2336
2256
  (it) => import_compiler9.types.importDeclaration([], import_compiler9.types.stringLiteral(it))
2337
2257
  );
2338
2258
  if (state.init) {
2259
+ const isPage = entryFile.path.node.extra.page;
2260
+ const initHelper = isPage ? "init" : "initEmbedded";
2339
2261
  body.unshift(
2340
2262
  import_compiler9.types.importDeclaration(
2341
- [import_compiler9.types.importSpecifier(import_compiler9.types.identifier("init"), import_compiler9.types.identifier("init"))],
2263
+ [
2264
+ import_compiler9.types.importSpecifier(
2265
+ import_compiler9.types.identifier(initHelper),
2266
+ import_compiler9.types.identifier(initHelper)
2267
+ )
2268
+ ],
2342
2269
  import_compiler9.types.stringLiteral(
2343
2270
  `${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`
2344
2271
  )
2345
2272
  )
2346
2273
  );
2347
2274
  const { runtimeId } = entryFile.markoOpts;
2275
+ const readyId = !isPage && (0, import_babel_utils12.getTemplateId)(entryFile.markoOpts, entryFile.opts.filename);
2348
2276
  const initExpression = import_compiler9.types.callExpression(
2349
- import_compiler9.types.identifier("init"),
2350
- runtimeId ? [import_compiler9.types.stringLiteral(runtimeId)] : []
2277
+ import_compiler9.types.identifier(initHelper),
2278
+ readyId ? runtimeId ? [import_compiler9.types.stringLiteral(readyId), import_compiler9.types.stringLiteral(runtimeId)] : [import_compiler9.types.stringLiteral(readyId)] : runtimeId ? [import_compiler9.types.stringLiteral(runtimeId)] : []
2351
2279
  );
2352
2280
  body.push(
2353
2281
  exportInit ? import_compiler9.types.exportDefaultDeclaration(
@@ -2611,8 +2539,8 @@ function getHTMLRuntime() {
2611
2539
  };
2612
2540
  }
2613
2541
  function getRuntimePath(output) {
2614
- const { optimize } = getMarkoOpts();
2615
- return `${runtime_info_default.name}/${optimize ? "" : "debug/"}${output === "html" ? "html" : "dom"}`;
2542
+ const { optimize: optimize2 } = getMarkoOpts();
2543
+ return `${runtime_info_default.name}/${optimize2 ? "" : "debug/"}${output === "html" ? "html" : "dom"}`;
2616
2544
  }
2617
2545
  function filterArguments(args) {
2618
2546
  const filteredArgs = [];
@@ -3297,6 +3225,78 @@ var return_default = {
3297
3225
  ]
3298
3226
  };
3299
3227
 
3228
+ // src/translator/util/for-each-identifier.ts
3229
+ function forEachIdentifier(node, cb) {
3230
+ switch (node.type) {
3231
+ case "ObjectPattern":
3232
+ for (const prop of node.properties) {
3233
+ switch (prop.type) {
3234
+ case "ObjectProperty":
3235
+ if (prop.value.type === "AssignmentPattern") {
3236
+ forEachIdentifier(prop.value.left, cb);
3237
+ } else {
3238
+ forEachIdentifier(prop.value, cb);
3239
+ }
3240
+ break;
3241
+ case "RestElement":
3242
+ forEachIdentifier(prop.argument, cb);
3243
+ break;
3244
+ }
3245
+ }
3246
+ break;
3247
+ case "ArrayPattern":
3248
+ for (const el of node.elements) {
3249
+ if (el != null) {
3250
+ switch (el.type) {
3251
+ case "RestElement":
3252
+ forEachIdentifier(el.argument, cb);
3253
+ break;
3254
+ case "AssignmentPattern":
3255
+ forEachIdentifier(el.left, cb);
3256
+ break;
3257
+ default:
3258
+ forEachIdentifier(el, cb);
3259
+ break;
3260
+ }
3261
+ }
3262
+ }
3263
+ break;
3264
+ case "Identifier":
3265
+ cb(node);
3266
+ break;
3267
+ }
3268
+ }
3269
+ function forEachIdentifierPath(nodePath, cb) {
3270
+ if (nodePath.isIdentifier()) {
3271
+ cb(nodePath);
3272
+ } else if (nodePath.isObjectPattern()) {
3273
+ for (const prop of nodePath.get("properties")) {
3274
+ if (prop.isObjectProperty()) {
3275
+ const value = prop.get("value");
3276
+ if (value.isAssignmentPattern()) {
3277
+ forEachIdentifierPath(value.get("left"), cb);
3278
+ } else {
3279
+ forEachIdentifierPath(value, cb);
3280
+ }
3281
+ } else if (prop.isRestElement()) {
3282
+ forEachIdentifierPath(prop.get("argument"), cb);
3283
+ }
3284
+ }
3285
+ } else if (nodePath.isArrayPattern()) {
3286
+ for (const el of nodePath.get("elements")) {
3287
+ if (el) {
3288
+ if (el.isRestElement()) {
3289
+ forEachIdentifierPath(el.get("argument"), cb);
3290
+ } else if (el.isAssignmentPattern()) {
3291
+ forEachIdentifierPath(el.get("left"), cb);
3292
+ } else {
3293
+ forEachIdentifierPath(el, cb);
3294
+ }
3295
+ }
3296
+ }
3297
+ }
3298
+ }
3299
+
3300
3300
  // src/translator/util/get-defined-binding-expression.ts
3301
3301
  var import_compiler18 = require("@marko/compiler");
3302
3302
  function getDeclaredBindingExpression(binding) {
@@ -3336,7 +3336,7 @@ function createScopeReadExpression(reference, section = reference.section) {
3336
3336
  );
3337
3337
  if (section === reference.section && reference.type !== 0 /* dom */) {
3338
3338
  const exprExtra = expr.extra ??= {};
3339
- exprExtra.read = createRead(reference, void 0, void 0);
3339
+ exprExtra.read = createRead(reference, void 0);
3340
3340
  exprExtra.section = section;
3341
3341
  }
3342
3342
  return expr;
@@ -4802,7 +4802,8 @@ var html_default = {
4802
4802
  callRuntime(
4803
4803
  "_template",
4804
4804
  import_compiler24.types.stringLiteral(program.hub.file.metadata.marko.id),
4805
- contentId ? import_compiler24.types.identifier(contentId) : contentFn
4805
+ contentId ? import_compiler24.types.identifier(contentId) : contentFn,
4806
+ program.node.extra.page ? import_compiler24.types.numericLiteral(1) : void 0
4806
4807
  )
4807
4808
  );
4808
4809
  if (contentId) {
@@ -4988,31 +4989,44 @@ function normalizeTag(tag) {
4988
4989
  }
4989
4990
  for (let i = 0; i < attributes.length; i++) {
4990
4991
  const attr = attributes[i];
4991
- if (import_compiler26.types.isMarkoAttribute(attr) && attr.bound) {
4992
- attr.bound = false;
4993
- attributes.splice(++i, 0, getChangeHandler(tag, attr));
4992
+ if (import_compiler26.types.isMarkoAttribute(attr)) {
4993
+ if (attr.bound) {
4994
+ attributes.splice(++i, 0, getChangeHandler(tag, attr));
4995
+ attr.bound = false;
4996
+ } else if (attr.modifier != null) {
4997
+ attr.name += ":" + attr.modifier;
4998
+ }
4999
+ attr.modifier = null;
4994
5000
  }
4995
5001
  }
4996
5002
  }
4997
5003
  function getChangeHandler(tag, attr) {
4998
5004
  const attrName = attr.name;
4999
5005
  const changeAttrName = attrName + "Change";
5006
+ const modifier = attr.modifier == null ? void 0 : withPreviousLocation(import_compiler26.types.identifier(attr.modifier), attr);
5000
5007
  if (import_compiler26.types.isIdentifier(attr.value)) {
5001
5008
  const binding = tag.scope.getBinding(attr.value.name);
5002
5009
  if (!binding)
5003
5010
  return import_compiler26.types.markoAttribute(
5004
5011
  changeAttrName,
5005
- buildChangeHandlerFunction(attr.value)
5012
+ buildChangeHandlerFunction(attr.value, modifier)
5006
5013
  );
5007
5014
  const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
5008
5015
  if (!existingChangedAttr) {
5009
5016
  const bindingIdentifierPath = binding.path.getOuterBindingIdentifierPaths()[binding.identifier.name];
5010
- const changeAttrExpr = bindingIdentifierPath ? bindingIdentifierPath.parentPath === binding.path ? buildChangeHandlerFunction(attr.value) : bindingIdentifierPath.parentPath.isObjectProperty() ? getChangeHandlerFromObjectPattern(
5017
+ let changeAttrExpr = bindingIdentifierPath ? bindingIdentifierPath.parentPath === binding.path ? buildChangeHandlerFunction(attr.value, modifier) : bindingIdentifierPath.parentPath.isObjectProperty() ? getChangeHandlerFromObjectPattern(
5011
5018
  bindingIdentifierPath.parentPath
5012
5019
  ) : void 0 : void 0;
5013
5020
  if (!changeAttrExpr) {
5014
5021
  throw tag.hub.buildError(attr.value, "Unable to bind to value.");
5015
5022
  }
5023
+ if (modifier && import_compiler26.types.isIdentifier(changeAttrExpr)) {
5024
+ changeAttrExpr = import_compiler26.types.logicalExpression(
5025
+ "&&",
5026
+ changeAttrExpr,
5027
+ buildChangeHandlerFunction(attr.value, modifier)
5028
+ );
5029
+ }
5016
5030
  const changeHandlerAttr = import_compiler26.types.markoAttribute(
5017
5031
  changeAttrName,
5018
5032
  changeAttrExpr
@@ -5064,10 +5078,26 @@ function getChangeHandler(tag, attr) {
5064
5078
  import_compiler26.types.stringLiteral("Change")
5065
5079
  );
5066
5080
  const computed = memberProp.type !== "Identifier";
5067
- return import_compiler26.types.markoAttribute(
5068
- changeAttrName,
5069
- attr.value.optional ? import_compiler26.types.optionalMemberExpression(memberObj, memberProp, computed, true) : import_compiler26.types.memberExpression(memberObj, memberProp, computed)
5070
- );
5081
+ let changeAttrExpr = attr.value.optional ? import_compiler26.types.optionalMemberExpression(memberObj, memberProp, computed, true) : import_compiler26.types.memberExpression(memberObj, memberProp, computed);
5082
+ if (modifier) {
5083
+ const newValueId = generateUid("next");
5084
+ changeAttrExpr = import_compiler26.types.logicalExpression(
5085
+ "&&",
5086
+ changeAttrExpr,
5087
+ import_compiler26.types.arrowFunctionExpression(
5088
+ [import_compiler26.types.identifier(newValueId)],
5089
+ import_compiler26.types.blockStatement([
5090
+ import_compiler26.types.expressionStatement(
5091
+ import_compiler26.types.callExpression(
5092
+ import_compiler26.types.memberExpression(memberObj, memberProp, computed),
5093
+ [import_compiler26.types.callExpression(modifier, [import_compiler26.types.identifier(newValueId)])]
5094
+ )
5095
+ )
5096
+ ])
5097
+ )
5098
+ );
5099
+ }
5100
+ return import_compiler26.types.markoAttribute(changeAttrName, changeAttrExpr);
5071
5101
  }
5072
5102
  }
5073
5103
  throw tag.hub.buildError(
@@ -5075,8 +5105,12 @@ function getChangeHandler(tag, attr) {
5075
5105
  "Attributes may only be bound to identifiers or member expressions"
5076
5106
  );
5077
5107
  }
5078
- function buildChangeHandlerFunction(id) {
5108
+ function buildChangeHandlerFunction(id, modifier) {
5079
5109
  const newId = "_new_" + id.name;
5110
+ let newValue = withPreviousLocation(import_compiler26.types.identifier(newId), id);
5111
+ if (modifier) {
5112
+ newValue = import_compiler26.types.callExpression(modifier, [newValue]);
5113
+ }
5080
5114
  return import_compiler26.types.arrowFunctionExpression(
5081
5115
  [withPreviousLocation(import_compiler26.types.identifier(newId), id)],
5082
5116
  import_compiler26.types.blockStatement([
@@ -5084,7 +5118,7 @@ function buildChangeHandlerFunction(id) {
5084
5118
  import_compiler26.types.assignmentExpression(
5085
5119
  "=",
5086
5120
  withPreviousLocation(import_compiler26.types.identifier(id.name), id),
5087
- withPreviousLocation(import_compiler26.types.identifier(newId), id)
5121
+ newValue
5088
5122
  )
5089
5123
  )
5090
5124
  ])
@@ -5317,6 +5351,15 @@ function resolveRelativeToEntry(entryFile, file, req) {
5317
5351
  );
5318
5352
  }
5319
5353
 
5354
+ // src/translator/util/is-event-or-change-handler.ts
5355
+ function isEventOrChangeHandler(prop) {
5356
+ return /^on[-A-Z][a-zA-Z0-9_$]|[a-zA-Z_$][a-zA-Z0-9_$]*Change$/.test(prop);
5357
+ }
5358
+
5359
+ // src/translator/util/known-tag.ts
5360
+ var import_compiler37 = require("@marko/compiler");
5361
+ var import_babel_utils25 = require("@marko/compiler/babel-utils");
5362
+
5320
5363
  // src/translator/util/nested-attribute-tags.ts
5321
5364
  var import_compiler28 = require("@marko/compiler");
5322
5365
  var import_babel_utils18 = require("@marko/compiler/babel-utils");
@@ -5578,6 +5621,13 @@ var native_tag_default = {
5578
5621
  );
5579
5622
  }
5580
5623
  const tagName = getCanonicalTagName(tag);
5624
+ switch (tagName) {
5625
+ case "html":
5626
+ case "body":
5627
+ case "head":
5628
+ (0, import_babel_utils21.getProgram)().node.extra.page ??= true;
5629
+ break;
5630
+ }
5581
5631
  const isTextOnly = isTextOnlyNativeTag(tag);
5582
5632
  const seen = {};
5583
5633
  const { attributes } = tag.node;
@@ -8685,9 +8735,30 @@ function trackParamsReferences(body, type) {
8685
8735
  return paramsBinding;
8686
8736
  }
8687
8737
  }
8738
+ function getMarkoRootAsTag(path7) {
8739
+ const tag = path7.isMarkoTag() ? path7 : getMarkoRoot(path7)?.parentPath;
8740
+ if (tag?.isMarkoTag()) {
8741
+ return tag;
8742
+ }
8743
+ }
8744
+ function isReferenceInOwnBody(bindingPath, reference) {
8745
+ const tag = getMarkoRootAsTag(bindingPath);
8746
+ if (!tag) {
8747
+ return false;
8748
+ }
8749
+ const body = tag.get("body");
8750
+ let cur = reference;
8751
+ while (cur) {
8752
+ if (cur === body) {
8753
+ return true;
8754
+ }
8755
+ cur = cur.parentPath;
8756
+ }
8757
+ return false;
8758
+ }
8688
8759
  function isReferenceHoisted(bindingPath, reference) {
8689
- const tag = bindingPath.isMarkoTag() ? bindingPath : getMarkoRoot(bindingPath)?.parentPath;
8690
- if (!tag?.isMarkoTag()) {
8760
+ const tag = getMarkoRootAsTag(bindingPath);
8761
+ if (!tag) {
8691
8762
  return false;
8692
8763
  }
8693
8764
  const body = tag.parentPath;
@@ -9440,7 +9511,7 @@ var [getFunctionReadsByExpression] = createProgramState(
9440
9511
  );
9441
9512
  function addRead(exprExtra, extra, binding, section, getter) {
9442
9513
  const readsByExpression = getReadsByExpression();
9443
- const read = { binding, extra, getter };
9514
+ const read = { binding, extra, getter, ownVar: false };
9444
9515
  binding.reads.add(exprExtra);
9445
9516
  exprExtra.section = section;
9446
9517
  readsByExpression.set(
@@ -9485,6 +9556,10 @@ function addReadToExpression(root, binding, getter) {
9485
9556
  section,
9486
9557
  getter
9487
9558
  );
9559
+ if (!getter && binding.type === 5 /* derived */) {
9560
+ const babelBinding = root.scope.getBinding(binding.name);
9561
+ read.ownVar = !!babelBinding && babelBinding.kind !== "param" && isReferenceInOwnBody(babelBinding.path, root);
9562
+ }
9488
9563
  if (root.parent.type === "MarkoSpreadAttribute") {
9489
9564
  exprExtra.spreadFrom = binding;
9490
9565
  }
@@ -9620,6 +9695,12 @@ function getReadReplacement(node, signal) {
9620
9695
  [getScopeExpression(extra.section, readBinding.section)]
9621
9696
  );
9622
9697
  }
9698
+ } else if (!import_config.optimize && read.ownVar) {
9699
+ replacement = callRuntime(
9700
+ "_assert_init",
9701
+ extra.section ? getScopeExpression(extra.section, readBinding.section) : scopeIdentifier,
9702
+ getScopeAccessorLiteral(readBinding)
9703
+ );
9623
9704
  } else {
9624
9705
  replacement = createScopeReadExpression(readBinding, extra.section);
9625
9706
  }
@@ -9831,7 +9912,7 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
9831
9912
  const { extra, getter } = read;
9832
9913
  if (getter) {
9833
9914
  extra.section = expr.section;
9834
- extra.read = createRead(binding, void 0, getter);
9915
+ extra.read = createGetterRead(binding, void 0, getter);
9835
9916
  addBindingGetter(binding, getter);
9836
9917
  if (getter.hoisted) {
9837
9918
  binding.hoists = sectionUtil.add(binding.hoists, getter.hoisted);
@@ -9854,20 +9935,23 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
9854
9935
  allBindings = bindingUtil.add(allBindings, binding);
9855
9936
  }
9856
9937
  } else if (reads) {
9857
- const { binding, extra, getter } = reads;
9938
+ const { binding, extra, getter, ownVar } = reads;
9858
9939
  if (getter) {
9940
+ extra.read = createGetterRead(binding, void 0, getter);
9859
9941
  addBindingGetter(binding, getter);
9860
9942
  if (getter.hoisted) {
9861
9943
  binding.hoists = sectionUtil.add(binding.hoists, getter.hoisted);
9862
9944
  hoistedBindings = bindingUtil.add(hoistedBindings, binding);
9863
9945
  }
9864
- } else if (binding.type === 6 /* constant */) {
9865
- constantBindings = binding;
9866
- } else if (binding.type !== 0 /* dom */) {
9867
- referencedBindings = binding;
9946
+ } else {
9947
+ extra.read = createRead(binding, void 0, ownVar);
9948
+ if (binding.type === 6 /* constant */) {
9949
+ constantBindings = binding;
9950
+ } else if (binding.type !== 0 /* dom */) {
9951
+ referencedBindings = binding;
9952
+ }
9868
9953
  }
9869
9954
  extra.section = expr.section;
9870
- extra.read = createRead(binding, void 0, getter);
9871
9955
  allBindings = binding;
9872
9956
  }
9873
9957
  if (Array.isArray(referencedBindings)) {
@@ -9914,7 +9998,7 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
9914
9998
  function resolveExpressionReference(rootBindings, readBinding) {
9915
9999
  const upstreamRoot = readBinding.upstreamAlias && findClosestReference(readBinding.upstreamAlias, rootBindings);
9916
10000
  if (!upstreamRoot) {
9917
- return createRead(readBinding, void 0, void 0);
10001
+ return createRead(readBinding, void 0);
9918
10002
  }
9919
10003
  let curBinding = readBinding;
9920
10004
  let props;
@@ -9927,15 +10011,18 @@ function resolveExpressionReference(rootBindings, readBinding) {
9927
10011
  if (Array.isArray(props)) {
9928
10012
  props.reverse();
9929
10013
  }
9930
- return createRead(upstreamRoot, props, void 0);
10014
+ return createRead(upstreamRoot, props);
9931
10015
  }
9932
10016
  function isSupersetSources(a, b) {
9933
10017
  if (!b.sources) return true;
9934
10018
  if (!a.sources) return false;
9935
10019
  return bindingUtil.isSuperset(a.sources.state, b.sources.state) && bindingUtil.isSuperset(a.sources.param, b.sources.param);
9936
10020
  }
9937
- function createRead(binding, props, getter) {
9938
- return { binding, props, getter };
10021
+ function createRead(binding, props, ownVar = false) {
10022
+ return { binding, props, ownVar, getter: void 0 };
10023
+ }
10024
+ function createGetterRead(binding, props, getter) {
10025
+ return { binding, props, ownVar: false, getter };
9939
10026
  }
9940
10027
  function getMemberExpressionPropString(expr) {
9941
10028
  switch (expr.property.type) {
@@ -12408,10 +12495,14 @@ var custom_tag_default = {
12408
12495
  if (!childFile) {
12409
12496
  throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
12410
12497
  }
12411
- const programSection = (0, import_babel_utils49.getProgram)().node.extra.section;
12498
+ const programExtra = (0, import_babel_utils49.getProgram)().node.extra;
12499
+ const programSection = programExtra.section;
12412
12500
  const childProgram = childFile.ast.program;
12413
12501
  const childExtra = childProgram.extra;
12414
12502
  const childSection = childExtra.section;
12503
+ if (childExtra.page) {
12504
+ programExtra.page ??= true;
12505
+ }
12415
12506
  knownTagAnalyze(
12416
12507
  tag,
12417
12508
  childSection,
@@ -12956,15 +13047,6 @@ var tag_default = {
12956
13047
  `Unsupported arguments on the \`${attr.node.name}\` attribute.`
12957
13048
  );
12958
13049
  }
12959
- if (attr.node.modifier) {
12960
- if ((0, import_babel_utils51.isNativeTag)(attr.parentPath)) {
12961
- attr.node.name += `:${attr.node.modifier}`;
12962
- } else {
12963
- throw attr.buildCodeFrameError(
12964
- `Unsupported modifier \`${attr.node.modifier}\`.`
12965
- );
12966
- }
12967
- }
12968
13050
  }
12969
13051
  }
12970
13052
  switch (analyzeTagNameType(tag)) {
@@ -13195,9 +13277,6 @@ function scanTag(state, tag) {
13195
13277
  attr.get("arguments")[0]
13196
13278
  );
13197
13279
  break;
13198
- } else if (attr.node.modifier) {
13199
- addFeature(state, "class" /* Class */, "Attribute modifier", attr);
13200
- break;
13201
13280
  } else if (attr.node.bound) {
13202
13281
  addFeature(state, "tags" /* Tags */, "Bound attribute", attr);
13203
13282
  break;
@@ -13269,10 +13348,10 @@ function createInteropTranslator(translate5) {
13269
13348
  import_compiler65.taglib.resolveOptionalTaglibs(translate5.optionalTaglibs).concat(translate5.taglibs),
13270
13349
  taglibs
13271
13350
  ),
13272
- getRuntimeEntryFiles(output, optimize) {
13351
+ getRuntimeEntryFiles(output, optimize2) {
13273
13352
  return [
13274
- ...translate5.getRuntimeEntryFiles(output, optimize),
13275
- ...getRuntimeEntryFiles(output, optimize)
13353
+ ...translate5.getRuntimeEntryFiles(output, optimize2),
13354
+ ...getRuntimeEntryFiles(output, optimize2)
13276
13355
  ];
13277
13356
  }
13278
13357
  };
@@ -13552,9 +13631,9 @@ var taglibs = [
13552
13631
  }
13553
13632
  ]
13554
13633
  ];
13555
- function getRuntimeEntryFiles(output, optimize) {
13634
+ function getRuntimeEntryFiles(output, optimize2) {
13556
13635
  return [
13557
- `${runtime_info_default.name}${optimize ? "" : "/debug"}/${output === "html" ? "html" : "dom"}`
13636
+ `${runtime_info_default.name}${optimize2 ? "" : "/debug"}/${output === "html" ? "html" : "dom"}`
13558
13637
  ];
13559
13638
  }
13560
13639
  // Annotate the CommonJS export names for ESM import in node: