marko 6.0.129 → 6.0.131

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.
@@ -3320,7 +3320,7 @@ var compat = {
3320
3320
  if (!compatRegistered) {
3321
3321
  const registered = getRegistered(this);
3322
3322
  if (registered) {
3323
- const scopeId = getScopeId(registered.scope);
3323
+ const scopeId = registered.scope ? getScopeId(registered.scope) : void 0;
3324
3324
  if (scopeId !== void 0) {
3325
3325
  writeScopeToState(state, scopeId, {});
3326
3326
  }
@@ -3227,7 +3227,7 @@ var compat = {
3227
3227
  if (!compatRegistered) {
3228
3228
  const registered = getRegistered(this);
3229
3229
  if (registered) {
3230
- const scopeId = getScopeId(registered.scope);
3230
+ const scopeId = registered.scope ? getScopeId(registered.scope) : void 0;
3231
3231
  if (scopeId !== void 0) {
3232
3232
  writeScopeToState(state, scopeId, {});
3233
3233
  }
package/dist/html.js CHANGED
@@ -2094,7 +2094,7 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
2094
2094
  if (!compatRegistered) {
2095
2095
  let registered = getRegistered(this);
2096
2096
  if (registered) {
2097
- let scopeId = getScopeId(registered.scope);
2097
+ let scopeId = registered.scope ? getScopeId(registered.scope) : void 0;
2098
2098
  scopeId !== void 0 && writeScopeToState(state, scopeId, {}), COMPAT_REGISTRY.set(
2099
2099
  this,
2100
2100
  compatRegistered = [registered.id, scopeId]
package/dist/html.mjs CHANGED
@@ -2004,7 +2004,7 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
2004
2004
  if (!compatRegistered) {
2005
2005
  let registered = getRegistered(this);
2006
2006
  if (registered) {
2007
- let scopeId = getScopeId(registered.scope);
2007
+ let scopeId = registered.scope ? getScopeId(registered.scope) : void 0;
2008
2008
  scopeId !== void 0 && writeScopeToState(state, scopeId, {}), COMPAT_REGISTRY.set(
2009
2009
  this,
2010
2010
  compatRegistered = [registered.id, scopeId]
@@ -2061,7 +2061,7 @@ function canIgnoreRegister(markoRoot, exprRoot) {
2061
2061
  markoRoot.isMarkoPlaceholder() || // bail within a server only statement
2062
2062
  markoRoot.isMarkoScriptlet() && (!markoRoot.node.static || markoRoot.node.target === "server") || // bail within the tag name
2063
2063
  markoRoot.isMarkoTag() && markoRoot.node.name == exprRoot.node || isMarkoAttribute(markoRoot) && (analyzeTagNameType(markoRoot.parentPath) === 0 /* NativeTag */ && // TODO: all native tag functions should avoid registration but right now change handlers require it.
2064
- /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))
2064
+ /^on[A-Z-]/.test(markoRoot.node.name) && !hasSpreadAttributeAfter(markoRoot) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))
2065
2065
  );
2066
2066
  }
2067
2067
  function getStaticDeclRefs(fnExtra, path7, refs = /* @__PURE__ */ new Set()) {
@@ -2110,6 +2110,13 @@ function shouldAlwaysRegister(markoRoot) {
2110
2110
  }
2111
2111
  return false;
2112
2112
  }
2113
+ function hasSpreadAttributeAfter(attr) {
2114
+ const attrs = attr.parent.attributes;
2115
+ for (let i = attr.key + 1; i < attrs.length; i++) {
2116
+ if (attrs[i].type === "MarkoSpreadAttribute") return true;
2117
+ }
2118
+ return false;
2119
+ }
2113
2120
  function getTagFromMarkoRoot(markoRoot) {
2114
2121
  let cur = markoRoot;
2115
2122
  do {
@@ -3290,16 +3297,17 @@ function getScopeExpression(section, targetSection) {
3290
3297
  }
3291
3298
  return scope;
3292
3299
  }
3293
- function createScopeReadExpression(reference, section) {
3300
+ function createScopeReadExpression(reference, section = reference.section) {
3294
3301
  const propName = toPropertyName(getScopeAccessor(reference));
3295
- const scope = section && reference.type !== 4 /* local */ ? getScopeExpression(section, reference.section) : scopeIdentifier;
3296
3302
  const expr = import_compiler19.types.memberExpression(
3297
- scope,
3303
+ reference.type === 4 /* local */ ? scopeIdentifier : getScopeExpression(section, reference.section),
3298
3304
  propName,
3299
3305
  propName.type !== "Identifier"
3300
3306
  );
3301
- if (scope === scopeIdentifier) {
3302
- (expr.extra ??= {}).read = createRead(reference, void 0);
3307
+ if (section === reference.section && reference.type !== 0 /* dom */) {
3308
+ const exprExtra = expr.extra ??= {};
3309
+ exprExtra.read = createRead(reference, void 0);
3310
+ exprExtra.section = section;
3303
3311
  }
3304
3312
  return expr;
3305
3313
  }
@@ -3431,9 +3439,13 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
3431
3439
  renderReferencedBindings: void 0,
3432
3440
  effect: [],
3433
3441
  effectReferencedBindings: void 0,
3434
- subscribers: [],
3435
3442
  build: void 0,
3436
- export: !!exportName
3443
+ export: !!exportName,
3444
+ hasSideEffect: !!(referencedBindings && (Array.isArray(referencedBindings) || referencedBindings.type === 0 /* dom */ || referencedBindings.type === 1 /* let */ || referencedBindings.section !== section || referencedBindings.closureSections || referencedBindings.hoists.size)),
3445
+ hasDynamicSubscribers: false,
3446
+ extraArgs: void 0,
3447
+ prependStatements: void 0,
3448
+ buildAssignment: void 0
3437
3449
  }
3438
3450
  );
3439
3451
  if (isOutputHTML()) {
@@ -3678,7 +3690,6 @@ function getSignalFn(signal) {
3678
3690
  }
3679
3691
  if (signal.effect.length) {
3680
3692
  const effectIdentifier = import_compiler22.types.identifier(`${signal.identifier.name}__script`);
3681
- signal.hasSideEffect = true;
3682
3693
  signal.render.push(
3683
3694
  import_compiler22.types.expressionStatement(
3684
3695
  import_compiler22.types.callExpression(effectIdentifier, [scopeIdentifier])
@@ -3735,6 +3746,7 @@ function subscribe(references, subscriber) {
3735
3746
  if (binding.type !== 7 /* constant */) {
3736
3747
  const source = binding.property === void 0 && binding.excludeProperties === void 0 && binding.upstreamAlias || binding;
3737
3748
  const providerSignal = getSignal(subscriber.section, source);
3749
+ providerSignal.hasSideEffect = true;
3738
3750
  providerSignal.intersection = push(
3739
3751
  providerSignal.intersection,
3740
3752
  subscriber
@@ -3897,12 +3909,6 @@ function writeSignals(section) {
3897
3909
  traverseReplace(value, "value", replaceRenderNode);
3898
3910
  }
3899
3911
  forEach(signal.intersection, writeSignal);
3900
- if (!signal.hasSideEffect) {
3901
- const binding = signal.referencedBindings;
3902
- if (binding && (signal.intersection || Array.isArray(binding) || binding.type === 1 /* let */ || binding.closureSections || binding.hoists.size || binding.section !== signal.section)) {
3903
- signal.hasSideEffect = true;
3904
- }
3905
- }
3906
3912
  let effectDeclarator;
3907
3913
  if (signal.effect.length) {
3908
3914
  traverseReplace(signal, "effect", replaceEffectNode);
@@ -6946,7 +6952,7 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
6946
6952
  if (attrTagLookup) {
6947
6953
  for (const name2 in attrTagLookup) {
6948
6954
  const attrTagMeta = attrTagLookup[name2];
6949
- if (!seen.has(name2) && usesExport(templateExports, attrTagMeta.name)) {
6955
+ if (!seen.has(attrTagMeta.name) && usesExport(templateExports, attrTagMeta.name)) {
6950
6956
  seen.add(attrTagMeta.name);
6951
6957
  if (attrTagMeta.dynamic) {
6952
6958
  statements.push(
@@ -6969,6 +6975,7 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
6969
6975
  if (child.isMarkoTag()) {
6970
6976
  if ((0, import_babel_utils24.isAttributeTag)(child)) {
6971
6977
  const attrTagMeta = attrTagLookup[getTagName(child)];
6978
+ if (skip2?.has(attrTagMeta.name)) continue;
6972
6979
  if (attrTagMeta.dynamic) {
6973
6980
  i = addDynamicAttrTagStatements(
6974
6981
  attrTags2,
@@ -7712,7 +7719,9 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
7712
7719
  } else if (import_compiler37.types.isMarkoSpreadAttribute(attr)) {
7713
7720
  knownSpreadBinding = getSingleKnownSpreadBinding(attributes);
7714
7721
  if (knownSpreadBinding) {
7715
- dropRead(attr.value.extra);
7722
+ if (!propTree.rest || propTree.rest.props) {
7723
+ dropRead(attr.value.extra);
7724
+ }
7716
7725
  } else {
7717
7726
  spreadReferenceNodes = [attr.value];
7718
7727
  }
@@ -7730,7 +7739,6 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
7730
7739
  known[prop] = { value: propExtra };
7731
7740
  rootAttrExprs.add(propExtra);
7732
7741
  addRead(propExtra, propExtra, propBinding, section);
7733
- setBindingDownstream(propBinding, propExtra);
7734
7742
  }
7735
7743
  }
7736
7744
  } else if (spreadReferenceNodes) {
@@ -7753,14 +7761,15 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
7753
7761
  );
7754
7762
  }
7755
7763
  if (propTree.rest) {
7756
- setBindingDownstream(
7757
- propTree.binding,
7758
- inputExpr.value = mergeReferences(
7759
- section,
7760
- tag.node,
7761
- unknownReferences.flat()
7762
- )
7764
+ const restExtra = inputExpr.value = mergeReferences(
7765
+ section,
7766
+ tag.node,
7767
+ unknownReferences.flat()
7763
7768
  );
7769
+ setBindingDownstream(propTree.binding, restExtra);
7770
+ if (knownSpreadBinding && !propTree.rest.props) {
7771
+ addRead(restExtra, void 0, knownSpreadBinding, section);
7772
+ }
7764
7773
  } else {
7765
7774
  unknownReferences.forEach(dropReferences);
7766
7775
  }
@@ -8178,7 +8187,9 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
8178
8187
  createScopeReadExpression(info.childScopeBinding, info.tagSection),
8179
8188
  translatedProps
8180
8189
  ])
8181
- )
8190
+ ),
8191
+ void 0,
8192
+ true
8182
8193
  );
8183
8194
  }
8184
8195
  }
@@ -8306,7 +8317,9 @@ function trackDomVarReferences(tag, binding) {
8306
8317
  const refSection = getOrCreateSection(ref);
8307
8318
  setReferencesScope(ref);
8308
8319
  if (isSameOrChildSection(binding.section, refSection)) {
8309
- (ref.node.extra ??= {}).read = createRead(binding, void 0);
8320
+ const refExtra = ref.node.extra ??= {};
8321
+ refExtra.read = createRead(binding, void 0);
8322
+ refExtra.section = refSection;
8310
8323
  if (!isInvokedFunction(ref)) {
8311
8324
  section.domGetterBindings.set(
8312
8325
  binding,
@@ -9597,6 +9610,7 @@ function getAllSerializeReasonsForExtra(extra) {
9597
9610
  if (extra === (0, import_babel_utils26.getProgram)().node.extra?.returnValueExpr) {
9598
9611
  reason = true;
9599
9612
  } else {
9613
+ serializeReasonCache.set(extra, false);
9600
9614
  forEach(extra.downstream, (binding) => {
9601
9615
  reason = mergeSerializeReasons(
9602
9616
  reason,
@@ -9604,7 +9618,9 @@ function getAllSerializeReasonsForExtra(extra) {
9604
9618
  );
9605
9619
  });
9606
9620
  }
9607
- serializeReasonCache.set(extra, reason || false);
9621
+ if (reason) {
9622
+ serializeReasonCache.set(extra, reason);
9623
+ }
9608
9624
  }
9609
9625
  return reason;
9610
9626
  }
@@ -9614,6 +9630,9 @@ function getAllSerializeReasonsForBinding(binding) {
9614
9630
  if (reason === void 0) {
9615
9631
  reason = getSerializeReason(binding.section, binding);
9616
9632
  if (reason !== true) {
9633
+ if (!reason) {
9634
+ serializeReasonCache.set(binding, false);
9635
+ }
9617
9636
  for (const expr of binding.downstreamExpressions) {
9618
9637
  reason = expr.isEffect || mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(expr));
9619
9638
  if (reason === true) break;
@@ -9637,7 +9656,9 @@ function getAllSerializeReasonsForBinding(binding) {
9637
9656
  }
9638
9657
  }
9639
9658
  }
9640
- serializeReasonCache.set(binding, reason || false);
9659
+ if (reason) {
9660
+ serializeReasonCache.set(binding, reason);
9661
+ }
9641
9662
  }
9642
9663
  return reason;
9643
9664
  }
@@ -10040,15 +10061,18 @@ var define_default = {
10040
10061
  }
10041
10062
  }
10042
10063
  if (hasDirectReferences) {
10043
- const signal = getSignal(node.body.extra.section, void 0);
10044
- signal.build = () => {
10045
- if (signalHasStatements(signal)) {
10046
- return callRuntime("_child_setup", getSignalFn(signal));
10064
+ const bodySection = getSectionForBody(tag.get("body"));
10065
+ if (bodySection) {
10066
+ const signal = getSignal(bodySection, void 0);
10067
+ signal.build = () => {
10068
+ if (signalHasStatements(signal)) {
10069
+ return callRuntime("_child_setup", getSignalFn(signal));
10070
+ }
10071
+ };
10072
+ if (allDirectReferences) {
10073
+ tag.remove();
10074
+ return;
10047
10075
  }
10048
- };
10049
- if (allDirectReferences) {
10050
- tag.remove();
10051
- return;
10052
10076
  }
10053
10077
  }
10054
10078
  }
@@ -3,4 +3,4 @@ import { type Binding, type ReferencedBindings } from "./references";
3
3
  import type { Section } from "./sections";
4
4
  export declare function createScopeReadPattern(section: Section, referencedBindings: ReferencedBindings): t.ObjectPattern;
5
5
  export declare function getScopeExpression(section: Section, targetSection: Section): t.Identifier | t.MemberExpression;
6
- export declare function createScopeReadExpression(reference: Binding, section?: Section | undefined): t.MemberExpression;
6
+ export declare function createScopeReadExpression(reference: Binding, section?: Section): t.MemberExpression;
@@ -3,7 +3,7 @@ import { type AccessorPrefix, AccessorProp } from "../../common/types";
3
3
  import { type Opt } from "./optional";
4
4
  import { type Binding, type ReferencedBindings } from "./references";
5
5
  import { type Section } from "./sections";
6
- export type Signal = {
6
+ export interface Signal {
7
7
  identifier: t.Identifier;
8
8
  referencedBindings: ReferencedBindings;
9
9
  section: Section;
@@ -18,13 +18,13 @@ export type Signal = {
18
18
  renderReferencedBindings: ReferencedBindings;
19
19
  effect: t.Statement[];
20
20
  effectReferencedBindings: ReferencedBindings;
21
- hasDynamicSubscribers?: true;
22
- hasSideEffect?: true;
21
+ hasDynamicSubscribers: boolean;
22
+ hasSideEffect: boolean;
23
23
  export: boolean;
24
- extraArgs?: t.Expression[];
25
- prependStatements?: t.Statement[];
26
- buildAssignment?: (valueSection: Section, value: t.Expression) => t.Expression | undefined;
27
- };
24
+ extraArgs: t.Expression[] | undefined;
25
+ prependStatements: t.Statement[] | undefined;
26
+ buildAssignment: ((valueSection: Section, value: t.Expression) => t.Expression | undefined) | undefined;
27
+ }
28
28
  type closureSignalBuilder = (closure: Binding, render: t.Expression) => t.Expression;
29
29
  export declare function setClosureSignalBuilder(tag: t.NodePath<t.MarkoTag>, builder: closureSignalBuilder): void;
30
30
  export declare const getTryHasPlaceholder: (section: Section) => true | undefined, setTryHasPlaceholder: (section: Section, value: true | undefined) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.129",
3
+ "version": "6.0.131",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",