marko 6.3.45 → 6.3.47

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.
Files changed (55) hide show
  1. package/dist/common/constants/resume-symbol.d.ts +5 -2
  2. package/dist/common/helpers.d.ts +2 -0
  3. package/dist/debug/dom/catch.feat.js +1 -1
  4. package/dist/debug/dom/catch.feat.mjs +1 -1
  5. package/dist/debug/dom/controllable-input.feat.js +1 -1
  6. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  7. package/dist/debug/dom/controllable-open.feat.js +1 -1
  8. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  9. package/dist/debug/dom/controllable-select.feat.js +1 -1
  10. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  12. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable.feat.js +1 -1
  14. package/dist/debug/dom/controllable.feat.mjs +1 -1
  15. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  16. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  17. package/dist/debug/dom/placeholder.feat.js +1 -1
  18. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  19. package/dist/debug/{dom-DBuLwSOh.js → dom-BheMBjYT.js} +29 -8
  20. package/dist/debug/{dom-ky42a_qY.mjs → dom-DyBeisho.mjs} +24 -9
  21. package/dist/debug/dom.js +2 -1
  22. package/dist/debug/dom.mjs +2 -2
  23. package/dist/debug/html.js +33 -18
  24. package/dist/debug/html.mjs +32 -18
  25. package/dist/dom/catch.feat.js +3 -3
  26. package/dist/dom/catch.feat.mjs +1 -1
  27. package/dist/dom/controllable-input.feat.js +1 -1
  28. package/dist/dom/controllable-input.feat.mjs +1 -1
  29. package/dist/dom/controllable-open.feat.js +1 -1
  30. package/dist/dom/controllable-open.feat.mjs +1 -1
  31. package/dist/dom/controllable-select.feat.js +1 -1
  32. package/dist/dom/controllable-select.feat.mjs +1 -1
  33. package/dist/dom/controllable-textarea.feat.js +1 -1
  34. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  35. package/dist/dom/controllable.feat.js +1 -1
  36. package/dist/dom/controllable.feat.mjs +1 -1
  37. package/dist/dom/dom.d.ts +1 -1
  38. package/dist/dom/dynamic-tag-var.feat.js +1 -1
  39. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  40. package/dist/dom/placeholder.feat.js +3 -3
  41. package/dist/dom/placeholder.feat.mjs +1 -1
  42. package/dist/dom/resume.d.ts +1 -0
  43. package/dist/{dom-BSAs0ur8.mjs → dom-BbknkVDz.mjs} +13 -13
  44. package/dist/{dom-DHJCbngT.js → dom-DprILxYO.js} +64 -59
  45. package/dist/dom.d.ts +1 -1
  46. package/dist/dom.js +24 -24
  47. package/dist/dom.mjs +2 -2
  48. package/dist/html/writer.d.ts +2 -1
  49. package/dist/html.d.ts +1 -1
  50. package/dist/html.js +21 -10
  51. package/dist/html.mjs +21 -10
  52. package/dist/translator/index.js +36 -419
  53. package/dist/translator/util/signals.d.ts +4 -1
  54. package/dist/translator/visitors/constants/sibling-text.d.ts +0 -1
  55. package/package.json +3 -3
@@ -203,7 +203,6 @@ const StartNode$1 = "#StartNode";
203
203
  const Subscriptions$1 = "#Subscriptions";
204
204
  const TagVariable$1 = "#TagVariable";
205
205
  const TagVariableChange$2 = "#TagVariableChange";
206
- const Owner$1 = "owner";
207
206
  //#endregion
208
207
  //#region src/translator/util/evaluate.ts
209
208
  function evaluate(value) {
@@ -354,120 +353,20 @@ function getEventHandlerName(name) {
354
353
  function isVoid(value) {
355
354
  return value == null || value === false;
356
355
  }
357
- function isNotVoid(value) {
358
- return value != null && value !== false;
359
- }
360
- function normalizeDynamicRenderer(value) {
361
- if (value) {
362
- if (typeof value === "string") return value;
363
- const normalized = value.content || value.default || value;
364
- if ("id" in normalized) return normalized;
365
- }
366
- }
367
356
  const decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36);
368
357
  //#endregion
369
358
  //#region src/html/serializer.ts
370
- const K_SCOPE_ID = Symbol("Scope ID");
371
- const kTouchedIterator = Symbol.for("marko.touchedIterator");
359
+ const kTouchedIterator = /* @__PURE__ */ Symbol.for("marko.touchedIterator");
372
360
  const { hasOwnProperty } = {};
373
361
  Array.prototype;
374
- const Generator = (function* () {})().constructor;
375
- const AsyncGenerator = (async function* () {})().constructor;
362
+ const Generator = (/* @__PURE__ */ (function* () {})()).constructor;
363
+ const AsyncGenerator = (/* @__PURE__ */ (async function* () {})()).constructor;
376
364
  patchIteratorNext(Generator.prototype);
377
365
  patchIteratorNext(AsyncGenerator.prototype);
378
- const REGISTRY = /* @__PURE__ */ new WeakMap();
379
- (() => {
380
- const KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
381
- for (const name of Object.getOwnPropertyNames(Symbol)) {
382
- const symbol = Symbol[name];
383
- if (typeof symbol === "symbol") KNOWN_SYMBOLS.set(symbol, "Symbol." + name);
384
- }
385
- return KNOWN_SYMBOLS;
386
- })();
387
- Array.from, Array.isArray, Array.of, ArrayBuffer.isView, Atomics.add, Atomics.and, Atomics.compareExchange, Atomics.exchange, Atomics.isLockFree, Atomics.load, Atomics.notify, Atomics.or, Atomics.store, Atomics.sub, Atomics.wait, BigInt.asIntN, BigInt.asUintN, BigInt64Array, BigInt64Array.from, BigInt64Array.of, BigUint64Array, BigUint64Array.from, BigUint64Array.of, console.timeStamp, Date.now, Date.parse, Date.UTC, Float32Array.from, Float32Array.of, Float64Array.from, Float64Array.of, globalThis.atob, globalThis.btoa, globalThis.clearImmediate, globalThis.clearInterval, globalThis.clearTimeout, globalThis.crypto?.getRandomValues, globalThis.crypto?.randomUUID, globalThis.fetch, globalThis.performance?.now, globalThis.queueMicrotask, globalThis.setImmediate, globalThis.setInterval, globalThis.setTimeout, globalThis.structuredClone, globalThis.URL, globalThis.URLSearchParams, globalThis.WritableStream, Int16Array.from, Int16Array.of, Int32Array.from, Int32Array.of, Int8Array.from, Int8Array.of, Intl.Collator, Intl.DateTimeFormat, Intl.DisplayNames, Intl.getCanonicalLocales, Intl.ListFormat, Intl.Locale, Intl.NumberFormat, Intl.PluralRules, Intl.RelativeTimeFormat, Intl.Segmenter, Intl.supportedValuesOf, Map.groupBy, Number.isFinite, Number.isInteger, Number.isNaN, Number.isSafeInteger, Number.parseFloat, Number.parseInt, String.fromCharCode, String.fromCodePoint, String.raw, Symbol.for, Uint16Array.from, Uint16Array.of, Uint32Array.from, Uint32Array.of, Uint8Array.from, Uint8Array.of, Uint8ClampedArray.from, Uint8ClampedArray.of;
388
- Atomics, globalThis.crypto;
389
- function register(id, val, scope) {
390
- REGISTRY.set(val, {
391
- id,
392
- scope,
393
- access: "_._" + toAccess(toObjectKey(id))
394
- });
395
- return val;
396
- }
397
- function toObjectKey(name) {
398
- if (name === "") return "\"\"";
399
- if (name === "__proto__") return "[\"__proto__\"]";
400
- const len = name.length;
401
- const c0 = name.charCodeAt(0);
402
- if (c0 >= 48 && c0 <= 57) if (c0 === 48) {
403
- if (len !== 1) return quote(name, 1);
404
- } else {
405
- for (let i = 1; i < len; i++) {
406
- const c = name.charCodeAt(i);
407
- if (c < 48 || c > 57) return quote(name, i);
408
- }
409
- if (len > 15 && "" + +name !== name) return quote(name, 0);
410
- }
411
- else if (c0 >= 97 && c0 <= 122 || c0 >= 65 && c0 <= 90 || c0 === 95 || c0 === 36) for (let i = 1; i < len; i++) {
412
- const c = name.charCodeAt(i);
413
- if (!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 95 || c === 36)) return quote(name, i);
414
- }
415
- else return quote(name, 0);
416
- return name;
417
- }
418
366
  function toAccess(accessor) {
419
367
  const start = accessor[0];
420
368
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
421
369
  }
422
- const unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u;
423
- function quote(str, startPos) {
424
- if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
425
- let result = "";
426
- let lastPos = 0;
427
- for (let i = startPos; i < str.length; i++) {
428
- let replacement;
429
- const code = str.charCodeAt(i);
430
- switch (code) {
431
- case 34:
432
- replacement = "\\\"";
433
- break;
434
- case 92:
435
- replacement = "\\\\";
436
- break;
437
- case 60:
438
- replacement = "\\x3C";
439
- break;
440
- case 10:
441
- replacement = "\\n";
442
- break;
443
- case 13:
444
- replacement = "\\r";
445
- break;
446
- case 8232:
447
- replacement = "\\u2028";
448
- break;
449
- case 8233:
450
- replacement = "\\u2029";
451
- break;
452
- case 0:
453
- replacement = "\\x00";
454
- break;
455
- default:
456
- if (code < 55296 || code > 57343) continue;
457
- if (code < 56320) {
458
- const next = str.charCodeAt(i + 1);
459
- if (next >= 56320 && next <= 57343) {
460
- i++;
461
- continue;
462
- }
463
- }
464
- replacement = "\\u" + code.toString(16);
465
- }
466
- result += str.slice(lastPos, i) + replacement;
467
- lastPos = i + 1;
468
- }
469
- return "\"" + (lastPos === startPos ? str : result + str.slice(lastPos)) + "\"";
470
- }
471
370
  function patchIteratorNext(proto) {
472
371
  if (proto.next[kTouchedIterator]) return;
473
372
  const { next } = proto;
@@ -1710,10 +1609,11 @@ var function_default = { analyze(fn) {
1710
1609
  throw fn.hub.buildError(highlight, "Attribute methods containing `await` must be `async`. Add `async` before the method name.");
1711
1610
  }
1712
1611
  if (fn !== getFnRoot(fn)) return;
1612
+ const { node } = fn;
1613
+ if ((_marko_compiler.types.isObjectMethod(node) || _marko_compiler.types.isClassMethod(node)) && (node.kind === "get" || node.kind === "set")) return;
1713
1614
  const exprRoot = getExprRoot(fn);
1714
1615
  const markoRoot = getMarkoRoot(exprRoot);
1715
1616
  if (!markoRoot || canIgnoreRegister(markoRoot, exprRoot)) return;
1716
- const { node } = fn;
1717
1617
  const section = getSection(fn);
1718
1618
  const fnExtra = node.extra ??= {};
1719
1619
  fnExtra.section = section;
@@ -2127,6 +2027,8 @@ const regexpCharsReg = /[\\^$.*+?()[\]{}|]/g;
2127
2027
  function escapeRegExp(str) {
2128
2028
  return str.replace(regexpCharsReg, "\\$&");
2129
2029
  }
2030
+ //#endregion
2031
+ //#region src/common/errors.ts
2130
2032
  function assertExclusiveAttrs(attrs, onError = throwErr) {
2131
2033
  if (attrs) {
2132
2034
  let exclusiveAttrs;
@@ -2182,95 +2084,6 @@ const escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsaf
2182
2084
  function _escape_comment(val) {
2183
2085
  return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
2184
2086
  }
2185
- //#endregion
2186
- //#region src/html/writer.ts
2187
- let $chunk;
2188
- function getContext(key) {
2189
- return $chunk.context?.[key];
2190
- }
2191
- function getState() {
2192
- return $chunk.boundary.state;
2193
- }
2194
- function rendererKey(renderer) {
2195
- return renderer?.["owner"] === void 0 ? renderer?.["id"] || renderer : renderer["id"] + " " + renderer[Owner$1];
2196
- }
2197
- function getScopeById(scopeId) {
2198
- if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
2199
- }
2200
- function _scope_id() {
2201
- return $chunk.boundary.state.scopeId++;
2202
- }
2203
- function _peek_scope_id() {
2204
- return $chunk.boundary.state.scopeId;
2205
- }
2206
- const kPendingContexts = Symbol("Pending Contexts");
2207
- function withContext(key, value, cb, cbValue) {
2208
- const ctx = $chunk.context ||= { [kPendingContexts]: 0 };
2209
- const prev = ctx[key];
2210
- ctx[kPendingContexts]++;
2211
- ctx[key] = value;
2212
- try {
2213
- return cb(cbValue);
2214
- } finally {
2215
- ctx[kPendingContexts]--;
2216
- ctx[key] = prev;
2217
- }
2218
- }
2219
- const kBranchId = Symbol("Branch Id");
2220
- const kIsAsync = Symbol("Is Async");
2221
- function withBranchId(branchId, cb) {
2222
- return withContext(kBranchId, branchId, cb);
2223
- }
2224
- function _html(html) {
2225
- $chunk.writeHTML(html);
2226
- }
2227
- function _script(scopeId, registryId) {
2228
- if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
2229
- $chunk.boundary.state.needsMainRuntime = true;
2230
- $chunk.writeEffect(scopeId, registryId);
2231
- }
2232
- function _resume(val, id, scopeId) {
2233
- return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
2234
- }
2235
- function _el(scopeId, id) {
2236
- return _resume(() => void 0, id, scopeId);
2237
- }
2238
- function _resume_branch(scopeId) {
2239
- const branchId = $chunk.context?.[kBranchId];
2240
- if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId$1]: branchId });
2241
- }
2242
- function deferBranchStart(chunk) {
2243
- const beforeBranch = chunk.html;
2244
- chunk.html = "";
2245
- return beforeBranch;
2246
- }
2247
- function applyBranchStart(chunk, beforeBranch, rendered) {
2248
- chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
2249
- }
2250
- let writeScope = (scopeId, partialScope) => {
2251
- const { state } = $chunk.boundary;
2252
- const target = $chunk.serializeState;
2253
- const scope = scopeWithId(state, scopeId);
2254
- const pending = target.writeScopes[scopeId];
2255
- state.needsMainRuntime = true;
2256
- Object.assign(scope, partialScope);
2257
- if (pending && pending !== partialScope) Object.assign(pending, partialScope);
2258
- else target.writeScopes[scopeId] = partialScope;
2259
- target.flushScopes = true;
2260
- return scope;
2261
- };
2262
- function _scope_with_id(scopeId) {
2263
- return scopeWithId($chunk.boundary.state, scopeId);
2264
- }
2265
- function scopeWithId(state, scopeId) {
2266
- const { scopes } = state;
2267
- let scope = scopes.get(scopeId);
2268
- if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
2269
- return scope;
2270
- }
2271
- function _set_serialize_reason(reason) {
2272
- $chunk.boundary.state.serializeReason = reason;
2273
- }
2274
2087
  globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask;
2275
2088
  //#endregion
2276
2089
  //#region src/html/attrs.ts
@@ -2280,124 +2093,9 @@ function _attr_class(value) {
2280
2093
  function _attr_style(value) {
2281
2094
  return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
2282
2095
  }
2283
- function _attr_option_value(value) {
2284
- const valueAttr = _attr("value", value);
2285
- const selectedValue = getContext(kSelectedValue);
2286
- if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) return valueAttr + " selected";
2287
- return valueAttr;
2288
- }
2289
- const kSelectedValue = Symbol("selectedValue");
2290
- function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
2291
- if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2292
- if (content) withContext(kSelectedValue, value ?? "", content);
2293
- }
2294
- function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
2295
- if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2296
- return _textarea_value(value);
2297
- }
2298
- function _textarea_value(value) {
2299
- const escaped = _escape(normalizeStrAttrValue(value));
2300
- return escaped[0] === "\n" ? "\n" + escaped : escaped;
2301
- }
2302
- function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
2303
- if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2304
- return _attr("value", value);
2305
- }
2306
- function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
2307
- if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType);
2308
- return isNotVoid(checked) ? " checked" : "";
2309
- }
2310
- function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
2311
- const valueAttr = _attr("value", value);
2312
- if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType);
2313
- return normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
2314
- }
2315
- const checkedValuesRefs = /* @__PURE__ */ new WeakMap();
2316
- function getCheckedValueRef(checkedValue) {
2317
- if (Array.isArray(checkedValue)) {
2318
- let ref = checkedValuesRefs.get(checkedValue);
2319
- if (!ref) {
2320
- ref = [];
2321
- checkedValuesRefs.set(checkedValue, ref);
2322
- }
2323
- return ref;
2324
- }
2325
- }
2326
- function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
2327
- const normalizedOpen = isNotVoid(open);
2328
- if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType);
2329
- return normalizedOpen ? " open" : "";
2330
- }
2331
2096
  function _attr(name, value) {
2332
2097
  return isVoid(value) ? "" : nonVoidAttr(name, value);
2333
2098
  }
2334
- function _attrs(data, nodeAccessor, scopeId, tagName) {
2335
- let result = "";
2336
- let skip = /[\s/>"'=]/;
2337
- let events;
2338
- switch (data && tagName) {
2339
- case "input":
2340
- if (data.checkedChange) {
2341
- result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
2342
- skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
2343
- } else if ("checkedValue" in data || data.checkedValueChange) {
2344
- result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
2345
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2346
- } else if (data.valueChange) {
2347
- result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
2348
- skip = /^value(?:Change)?$|[\s/>"'=]/;
2349
- }
2350
- break;
2351
- case "select":
2352
- case "textarea":
2353
- if ("value" in data || data.valueChange) skip = /^value(?:Change)?$|[\s/>"'=]/;
2354
- break;
2355
- case "option":
2356
- if ("value" in data) {
2357
- result += _attr_option_value(data.value);
2358
- skip = /^value$|[\s/>"'=]/;
2359
- }
2360
- break;
2361
- case "details":
2362
- case "dialog":
2363
- if (data.openChange) {
2364
- result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1);
2365
- skip = /^open(?:Change)?$|[\s/>"'=]/;
2366
- }
2367
- break;
2368
- }
2369
- for (const name in data) {
2370
- const value = data[name];
2371
- switch (name) {
2372
- case "class":
2373
- result += _attr_class(value);
2374
- break;
2375
- case "style":
2376
- result += _attr_style(value);
2377
- break;
2378
- default:
2379
- if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) if (isEventHandler(name)) {
2380
- if (!events) {
2381
- events = {};
2382
- writeScope(scopeId, { [EventAttributes$1 + nodeAccessor]: events });
2383
- }
2384
- events[getEventHandlerName(name)] = value;
2385
- } else result += nonVoidAttr(name, value);
2386
- break;
2387
- }
2388
- }
2389
- return result;
2390
- }
2391
- function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
2392
- writeScope(scopeId, serializeType ? {
2393
- [ControlledType$1 + nodeAccessor]: type,
2394
- [ControlledValue$1 + nodeAccessor]: value,
2395
- [ControlledHandler$1 + nodeAccessor]: valueChange
2396
- } : {
2397
- [ControlledValue$1 + nodeAccessor]: value,
2398
- [ControlledHandler$1 + nodeAccessor]: valueChange
2399
- });
2400
- }
2401
2099
  function stringAttr(name, value) {
2402
2100
  return value && " " + name + attrAssignment(value);
2403
2101
  }
@@ -2427,83 +2125,6 @@ function escapeDoubleQuotedAttrValue(value) {
2427
2125
  function replaceUnsafeDoubleQuoteAttrChar(match) {
2428
2126
  return match === "\"" ? "&#34;" : match === "\r" ? "&#13;" : "&amp;";
2429
2127
  }
2430
- function normalizedValueMatches(a, b) {
2431
- const value = normalizeStrAttrValue(b);
2432
- if (Array.isArray(a)) {
2433
- for (const item of a) if (normalizeStrAttrValue(item) === value) return true;
2434
- } else if (normalizeStrAttrValue(a) === value) return true;
2435
- return false;
2436
- }
2437
- function normalizeStrAttrValue(value) {
2438
- return isNotVoid(value) && value !== true ? value + "" : "";
2439
- }
2440
- //#endregion
2441
- //#region src/html/dynamic-tag.ts
2442
- const voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
2443
- let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
2444
- const shouldResume = serializeReason !== 0;
2445
- const renderer = normalizeDynamicRenderer(tag);
2446
- const state = getState();
2447
- const branchId = _peek_scope_id();
2448
- let rendered;
2449
- let result;
2450
- if (typeof renderer === "string") {
2451
- const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2452
- rendered = true;
2453
- const renderNative = () => {
2454
- _scope_id();
2455
- _html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`);
2456
- if (!voidElementsReg.test(renderer)) {
2457
- const renderContent = content || normalizeDynamicRenderer(input.content);
2458
- if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
2459
- else {
2460
- if (renderContent && typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2461
- if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason) : void 0, 1);
2462
- else if (renderContent) _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
2463
- }
2464
- _html(`</${renderer}>`);
2465
- }
2466
- const childScope = getScopeById(branchId);
2467
- const needsScript = childScope && (childScope["EventAttributes:a"] || childScope["ControlledHandler:a"]);
2468
- if (needsScript) _script(branchId, "_d");
2469
- if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
2470
- };
2471
- renderNative();
2472
- result = _el(branchId, "_e");
2473
- } else {
2474
- const chunk = void 0;
2475
- const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
2476
- const render = () => {
2477
- if (renderer) try {
2478
- _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0);
2479
- return inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
2480
- ...inputOrArgs,
2481
- content
2482
- } : inputOrArgs);
2483
- } finally {
2484
- _set_serialize_reason(void 0);
2485
- }
2486
- else if (content) return content();
2487
- };
2488
- result = shouldResume ? withBranchId(branchId, render) : render();
2489
- rendered = _peek_scope_id() !== branchId;
2490
- if (beforeBranch !== void 0) {
2491
- applyBranchStart(chunk, beforeBranch, rendered);
2492
- _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
2493
- }
2494
- }
2495
- if (rendered) {
2496
- if (shouldResume) writeScope(scopeId, { [ConditionalRenderer$1 + accessor]: rendererKey(renderer) });
2497
- } else _scope_id();
2498
- return result;
2499
- };
2500
- ((originalDynamicTag) => (patch) => {
2501
- _dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
2502
- const patched = patch(tag, scopeId, accessor);
2503
- if (patched !== tag) patched["id"] = tag;
2504
- return originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume);
2505
- };
2506
- })(_dynamic_tag);
2507
2128
  //#endregion
2508
2129
  //#region src/translator/util/runtime.ts
2509
2130
  const pureDOMFunctions = /* @__PURE__ */ new Set([
@@ -3279,6 +2900,7 @@ function getSignal(section, referencedBindings, name) {
3279
2900
  values: [],
3280
2901
  intersection: void 0,
3281
2902
  forwards: void 0,
2903
+ prepare: [],
3282
2904
  render: [],
3283
2905
  effect: [],
3284
2906
  hasHTMLEffect: false,
@@ -3343,7 +2965,7 @@ function initValue(binding, isLet = false) {
3343
2965
  return signal;
3344
2966
  }
3345
2967
  function signalHasStatements(signal) {
3346
- if (signal.extraArgs || signal.forcePersist || signal.render.length || signal.effect.length || signal.hasHTMLEffect || signal.values.length || signal.intersection) return true;
2968
+ if (signal.extraArgs || signal.forcePersist || signal.prepare.length || signal.render.length || signal.effect.length || signal.hasHTMLEffect || signal.values.length || signal.intersection) return true;
3347
2969
  const binding = signal.referencedBindings;
3348
2970
  if (binding) {
3349
2971
  if (!Array.isArray(binding) && (binding.closureSections || binding.type === 0 || binding.section === signal.section && (binding.hoists || binding.aliases.size || hasNonConstantPropertyAlias(binding)))) return true;
@@ -3441,20 +3063,21 @@ function getSignalFn(signal) {
3441
3063
  signal.render.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(effectIdentifier, [scopeIdentifier])));
3442
3064
  }
3443
3065
  if (isValue && getSerializeReason(section, binding)) signal.hasSideEffect = true;
3066
+ const render = signal.prepare.length ? signal.prepare.concat(signal.render) : signal.render;
3444
3067
  if (!signal.hasSideEffect) {
3445
- if (isValue && signal.render.length === 1) {
3446
- const render = signal.render[0];
3447
- if (render.type === "ExpressionStatement") {
3448
- const { expression } = render;
3068
+ if (isValue && render.length === 1) {
3069
+ const first = render[0];
3070
+ if (first.type === "ExpressionStatement") {
3071
+ const { expression } = first;
3449
3072
  if (expression.type === "CallExpression" && expression.callee.type === "Identifier" && expression.arguments.length === 2 && expression.arguments[0] === scopeIdentifier && isOwnValueRead(expression.arguments[1], binding)) return expression.callee;
3450
3073
  }
3451
3074
  }
3452
- return _marko_compiler.types.arrowFunctionExpression(isValue ? [scopeIdentifier, getSignalValueIdentifier(signal)] : [scopeIdentifier], toFirstExpressionOrBlock(signal.render));
3075
+ return _marko_compiler.types.arrowFunctionExpression(isValue ? [scopeIdentifier, getSignalValueIdentifier(signal)] : [scopeIdentifier], toFirstExpressionOrBlock(render));
3453
3076
  }
3454
- if (signal.render.length === 1) {
3455
- const render = signal.render[0];
3456
- if (render.type === "ExpressionStatement") {
3457
- const { expression } = render;
3077
+ if (render.length === 1) {
3078
+ const first = render[0];
3079
+ if (first.type === "ExpressionStatement") {
3080
+ const { expression } = first;
3458
3081
  if (expression.type === "CallExpression") {
3459
3082
  const args = expression.arguments;
3460
3083
  if (args.length === 1 && args[0] === scopeIdentifier) {
@@ -3464,7 +3087,7 @@ function getSignalFn(signal) {
3464
3087
  }
3465
3088
  }
3466
3089
  }
3467
- return _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], _marko_compiler.types.blockStatement(signal.render));
3090
+ return _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], _marko_compiler.types.blockStatement(render));
3468
3091
  }
3469
3092
  const hasTranslatedExtraArgs = /* @__PURE__ */ new WeakSet();
3470
3093
  const emptyExtraArgs = [];
@@ -5864,7 +5487,7 @@ function getOnlyChildParentTagName(tag, branchSize = 1) {
5864
5487
  const extra = tag.node.extra;
5865
5488
  if (extra[kOnlyChildInParent] !== void 0) return extra[kOnlyChildInParent];
5866
5489
  const parentTag = getParentTag(tag);
5867
- return extra[kOnlyChildInParent] = parentTag && (0, _marko_compiler_babel_utils.getTagDef)(parentTag)?.html && parentTag.node.name.type === "StringLiteral" && tag.parent.body.filter((node) => node.type !== "MarkoComment").length === branchSize ? parentTag.node.name.value : false;
5490
+ return extra[kOnlyChildInParent] = parentTag && analyzeTagNameType(parentTag) === 0 && parentTag.node.name.type === "StringLiteral" && tag.parent.body.filter((node) => node.type !== "MarkoComment").length === branchSize ? parentTag.node.name.value : false;
5868
5491
  }
5869
5492
  function getOptimizedOnlyChildNodeBinding(tag, section, branchSize = 1) {
5870
5493
  if (getOnlyChildParentTagName(tag, branchSize)) {
@@ -6453,7 +6076,9 @@ var program_default = {
6453
6076
  if (isLoadEntry) {
6454
6077
  const entryFile = program.hub.file;
6455
6078
  const { filename } = entryFile.opts;
6456
- program.node.body = [_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier("ready"), _marko_compiler.types.identifier("ready"))], _marko_compiler.types.stringLiteral(getRuntimePath("dom"))), _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(_marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename))]), _marko_compiler.types.identifier("then")), [_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.identifier("ready"), [_marko_compiler.types.stringLiteral(getReadyId(entryFile))]))]))];
6079
+ const readyId = getReadyId(entryFile);
6080
+ const report = !markoOpts.optimize;
6081
+ program.node.body = [_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier("ready"), _marko_compiler.types.identifier("ready")), ...report ? [_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier("readyFailed"), _marko_compiler.types.identifier("readyFailed"))] : []], _marko_compiler.types.stringLiteral(getRuntimePath("dom"))), _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(_marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename))]), _marko_compiler.types.identifier("then")), [_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.identifier("ready"), [_marko_compiler.types.stringLiteral(readyId)])), ...report ? [_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.identifier("readyFailed"), [_marko_compiler.types.stringLiteral(readyId)]))] : []]))];
6457
6082
  program.skip();
6458
6083
  return;
6459
6084
  }
@@ -6697,7 +6322,7 @@ function knownTagTranslateDOM(tag, propTree, getBindingIdentifier, callSetup) {
6697
6322
  if (!isOptimize()) changeArgs.push(_marko_compiler.types.stringLiteral(varBinding.name));
6698
6323
  return _marko_compiler.types.callExpression(importRuntime("_var_change"), changeArgs);
6699
6324
  };
6700
- addStatement("render", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_var", scopeIdentifier, getScopeAccessorLiteral(childScopeBinding, true), source.identifier)));
6325
+ addStatement("prepare", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_var", scopeIdentifier, getScopeAccessorLiteral(childScopeBinding, true), source.identifier)));
6701
6326
  }
6702
6327
  callSetup?.(tagSection, childScopeBinding);
6703
6328
  if (propTree) writeParamsToSignals(tag, propTree, getTagName(tag) || "tag", {
@@ -9390,7 +9015,10 @@ function assertHasBody(tag) {
9390
9015
  function assertHasValueAttribute(tag) {
9391
9016
  const { node } = tag;
9392
9017
  const [valueAttr] = node.attributes;
9393
- if (!_marko_compiler.types.isMarkoAttribute(valueAttr) || !(valueAttr.default || valueAttr.name === "value")) throw tag.get("name").buildCodeFrameError(`The [\`<${getTagName(tag)}>\` tag](https://markojs.com/docs/reference/core-tag#show) requires a [\`value=\` attribute](https://markojs.com/docs/reference/language#shorthand-value).`);
9018
+ if (!_marko_compiler.types.isMarkoAttribute(valueAttr) || !(valueAttr.default || valueAttr.name === "value")) {
9019
+ const wrongName = _marko_compiler.types.isMarkoAttribute(valueAttr) && valueAttr.name;
9020
+ throw (wrongName ? tag.get("attributes")[0] : tag.get("name")).buildCodeFrameError(`The [\`<${getTagName(tag)}>\` tag](https://markojs.com/docs/reference/core-tag#show) requires the [\`value=\` attribute](https://markojs.com/docs/reference/language#shorthand-value).${wrongName ? ` Use \`<${getTagName(tag)}=condition>\` instead of \`<${getTagName(tag)} ${wrongName}=condition>\`.` : ""}`);
9021
+ }
9394
9022
  if (node.attributes.length > 1) throw tag.get("name").buildCodeFrameError(`The [\`<${getTagName(tag)}>\` tag](https://markojs.com/docs/reference/core-tag#show) only supports the [\`value=\` attribute](https://markojs.com/docs/reference/language#shorthand-value).`);
9395
9023
  }
9396
9024
  //#endregion
@@ -10089,14 +9717,11 @@ function translateExit(placeholder) {
10089
9717
  const section = getSection(placeholder);
10090
9718
  const siblingText = extra[kSiblingText];
10091
9719
  const markerSerializeReason = nodeBinding && getSerializeReason(section, nodeBinding);
10092
- if (isHTML && markerSerializeReason) {
10093
- if (siblingText === 1) writeSeparator(write, section, markerSerializeReason);
10094
- else if (siblingText === 3) writeSeparator(write, section, markerSerializeReason);
10095
- }
10096
- if (isHTML) {
10097
- write`${method === "_escape" ? buildEscapedTextExpression(value) : callRuntime(method, value)}`;
10098
- if (nodeBinding) markNode(placeholder, nodeBinding, markerSerializeReason);
10099
- } else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))), true);
9720
+ if (isHTML) if (markerSerializeReason) {
9721
+ const guard = getSerializeGuard(section, markerSerializeReason, true);
9722
+ write`${callRuntime(node.escape ? "_text_resume" : "_html_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), value, siblingText === 1 ? guard ? _marko_compiler.types.binaryExpression("*", guard, _marko_compiler.types.numericLiteral(2)) : _marko_compiler.types.numericLiteral(2) : guard)}`;
9723
+ } else write`${method === "_escape" ? buildEscapedTextExpression(value) : callRuntime(method, value)}`;
9724
+ else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))), true);
10100
9725
  }
10101
9726
  placeholder.remove();
10102
9727
  }
@@ -10120,13 +9745,8 @@ function buildEscapedTextExpression(value) {
10120
9745
  default: return callRuntime("_escape", value);
10121
9746
  }
10122
9747
  }
10123
- function writeSeparator(write, section, reason) {
10124
- if (reason === true || reason.state) write`<!>`;
10125
- else write`${callRuntime("_sep", getSerializeGuard(section, reason, true))}`;
10126
- }
10127
9748
  function analyzeSiblingText(placeholder) {
10128
9749
  const placeholderExtra = placeholder.node.extra;
10129
- let hasNodeBefore = false;
10130
9750
  let prev = placeholder.getPrevSibling();
10131
9751
  let prevParent = placeholder.parentPath;
10132
9752
  for (;;) {
@@ -10142,10 +9762,7 @@ function analyzeSiblingText(placeholder) {
10142
9762
  const contentType = getNodeContentType(prev, "endType");
10143
9763
  if (contentType === null) prev = prev.getPrevSibling();
10144
9764
  else if (contentType === 4 || contentType === 1 || contentType === 2) return placeholderExtra[kSiblingText] = 1;
10145
- else {
10146
- hasNodeBefore = true;
10147
- break;
10148
- }
9765
+ else break;
10149
9766
  }
10150
9767
  if (!prev.node && prevParent.isProgram()) return placeholderExtra[kSiblingText] = 1;
10151
9768
  let next = placeholder.getNextSibling();
@@ -10166,7 +9783,7 @@ function analyzeSiblingText(placeholder) {
10166
9783
  else break;
10167
9784
  }
10168
9785
  if (!next.node && nextParent.isProgram()) return placeholderExtra[kSiblingText] = 2;
10169
- return placeholderExtra[kSiblingText] = hasNodeBefore ? 3 : 0;
9786
+ return placeholderExtra[kSiblingText] = 0;
10170
9787
  }
10171
9788
  function getInlinedBodyTag(parent) {
10172
9789
  if (parent.isMarkoTagBody()) {
@@ -18,6 +18,9 @@ export interface Signal {
18
18
  /** Signals this one forwards into: they must declare first when the
19
19
  * forward simplifies to a bare, eagerly evaluated reference. */
20
20
  forwards: Opt<Signal>;
21
+ /** Runs before `render`: registrations (eg `_var`) that an earlier tag's
22
+ * synchronous `_return` may reach before the registering tag's own setup. */
23
+ prepare: t.Statement[];
21
24
  render: t.Statement[];
22
25
  effect: t.Statement[];
23
26
  hasHTMLEffect: boolean;
@@ -49,7 +52,7 @@ export declare function signalHasStatements(signal: Signal): boolean;
49
52
  export declare function getSignalFn(signal: Signal): t.Expression;
50
53
  export declare function getSignalValueIdentifier(signal: Signal): t.Identifier;
51
54
  export declare function replaceNullishAndEmptyFunctionsWith0(args: (t.Expression | undefined | false)[]): t.Expression[];
52
- export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], isPure?: boolean): void;
55
+ export declare function addStatement(type: "prepare" | "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], isPure?: boolean): void;
53
56
  export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal, value: t.Expression): void;
54
57
  export declare function getResumeRegisterId(section: Section, referencedBindings: string | ReferencedBindings, type?: string): string;
55
58
  export declare function writeSignals(section: Section): Set<Signal>;
@@ -1,7 +1,6 @@
1
1
  export declare const None = 0;
2
2
  export declare const Before = 1;
3
3
  export declare const After = 2;
4
- export declare const NodeBefore = 3;
5
4
  type Self = typeof import("./sibling-text");
6
5
  export type Value = Self[keyof Self];
7
6
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.3.45",
3
+ "version": "6.3.47",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -57,8 +57,8 @@
57
57
  "magic-string": "^0.30.21"
58
58
  },
59
59
  "devDependencies": {
60
- "marko": "5.39.37",
61
- "@marko/runtime-tags": "npm:marko@6.3.45"
60
+ "@marko/runtime-tags": "npm:marko@6.3.47",
61
+ "marko": "5.39.38"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=22"