marko 6.0.133 → 6.0.135

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.
@@ -1028,8 +1028,8 @@ var Sorted = class {
1028
1028
  return false;
1029
1029
  }
1030
1030
  for (let i = subLen; i--; ) {
1031
- const supIndex = this.findIndex(superset, subset[i]);
1032
- if (supIndex === -1 || supLen - supIndex <= i) return false;
1031
+ const found = findIndexSorted(this.compare, superset, subset[i]);
1032
+ if (found === -1 || supLen - found <= i) return false;
1033
1033
  }
1034
1034
  return true;
1035
1035
  }
@@ -3460,8 +3460,16 @@ function getBindingGetterIdentifier(binding) {
3460
3460
  return identifier;
3461
3461
  }
3462
3462
  function getSignal(section, referencedBindings, name2 = generateSignalName(referencedBindings)) {
3463
- if (!Array.isArray(referencedBindings) && referencedBindings?.type === 7 /* constant */) {
3464
- return getSignal(section, void 0);
3463
+ if (referencedBindings && !Array.isArray(referencedBindings)) {
3464
+ if (referencedBindings.type === 7 /* constant */) {
3465
+ return getSignal(section, void 0);
3466
+ }
3467
+ if (referencedBindings.type !== 4 /* local */ && referencedBindings.section !== section) {
3468
+ const canonicalReference = getCanonicalBinding(referencedBindings);
3469
+ if (canonicalReference !== referencedBindings) {
3470
+ return getSignal(section, canonicalReference);
3471
+ }
3472
+ }
3465
3473
  }
3466
3474
  const signals = getSignals(section);
3467
3475
  let signal = signals.get(referencedBindings);
@@ -3506,9 +3514,9 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
3506
3514
  scopeOffset && getScopeAccessorLiteral(scopeOffset, true)
3507
3515
  );
3508
3516
  };
3509
- } else if (referencedBindings.section !== section && bindingUtil.find(section.referencedClosures, referencedBindings)) {
3517
+ } else if (referencedBindings.section !== section && sectionUtil.has(referencedBindings.closureSections, section)) {
3510
3518
  signal.build = () => {
3511
- const closure = getCanonicalBinding(referencedBindings);
3519
+ const closure = referencedBindings;
3512
3520
  const render = getSignalFn(signal);
3513
3521
  const closureSignalBuilder = getClosureSignalBuilder(section);
3514
3522
  if (closureSignalBuilder && !isDynamicClosure(section, closure)) {
@@ -3690,7 +3698,7 @@ function getSignalFn(signal) {
3690
3698
  )
3691
3699
  );
3692
3700
  });
3693
- if (isValue && binding.sources && binding.type !== 4 /* local */) {
3701
+ if (isValue && binding.sources) {
3694
3702
  let dynamicClosureArgs;
3695
3703
  let dynamicClosureSignalIdentifier;
3696
3704
  forEach(binding.closureSections, (closureSection) => {
@@ -4391,23 +4399,20 @@ function replaceAssignedNode(node) {
4391
4399
  switch (node.left.type) {
4392
4400
  case "Identifier": {
4393
4401
  const { extra } = node.left;
4394
- if (isAssignedBindingExtra(extra)) {
4395
- return getBuildAssignment(extra)?.(
4396
- extra.section,
4397
- node.operator === "=" ? node.right : import_compiler22.types.binaryExpression(
4398
- node.operator.slice(
4399
- 0,
4400
- -1
4401
- ),
4402
- createScopeReadExpression(
4403
- extra.assignment,
4404
- extra.section
4405
- ),
4406
- node.right
4407
- )
4408
- ) || extra?.assignment && withLeadingComment(node.right, getDebugName(extra.assignment));
4409
- }
4410
- break;
4402
+ return isAssignedBindingExtra(extra) && getBuildAssignment(extra)?.(
4403
+ extra.section,
4404
+ node.operator === "=" ? node.right : import_compiler22.types.binaryExpression(
4405
+ node.operator.slice(
4406
+ 0,
4407
+ -1
4408
+ ),
4409
+ createScopeReadExpression(
4410
+ extra.assignment,
4411
+ extra.section
4412
+ ),
4413
+ node.right
4414
+ )
4415
+ ) || extra?.assignment && withLeadingComment(node.right, getDebugName(extra.assignment));
4411
4416
  }
4412
4417
  case "ArrayPattern":
4413
4418
  case "ObjectPattern": {
@@ -4435,7 +4440,7 @@ function replaceAssignedNode(node) {
4435
4440
  (params ||= []).push(import_compiler22.types.identifier(id.name));
4436
4441
  }
4437
4442
  });
4438
- if (assignments) {
4443
+ if (assignments || params) {
4439
4444
  const resultId = generateUid("result");
4440
4445
  return import_compiler22.types.callExpression(
4441
4446
  import_compiler22.types.arrowFunctionExpression(
@@ -4446,7 +4451,7 @@ function replaceAssignedNode(node) {
4446
4451
  node.left,
4447
4452
  import_compiler22.types.identifier(resultId)
4448
4453
  ),
4449
- ...assignments,
4454
+ ...assignments || [],
4450
4455
  import_compiler22.types.identifier(resultId)
4451
4456
  ])
4452
4457
  ),
@@ -8477,8 +8482,10 @@ var kIsInvoked = Symbol("hoist is invoked");
8477
8482
  var kBranchSerializeReason = Symbol("branch serialize reason");
8478
8483
  var [getBindings] = createProgramState(() => /* @__PURE__ */ new Set());
8479
8484
  var [getNextBindingId, setNextBindingId] = createProgramState(() => 0);
8480
- function createBinding(name2, type, section, upstreamAlias, property, excludeProperties, loc = null, declared = false) {
8485
+ function createBinding(name2, type, refSection, upstreamAlias, property, excludeProperties, loc = null, refDeclared = false) {
8481
8486
  const id = getNextBindingId();
8487
+ const section = upstreamAlias ? upstreamAlias.section : refSection;
8488
+ const declared = refDeclared && refSection === section;
8482
8489
  const binding = {
8483
8490
  id,
8484
8491
  name: name2,
@@ -8573,6 +8580,7 @@ function trackDomVarReferences(tag, binding) {
8573
8580
  function trackVarReferences(tag, type, upstreamAlias) {
8574
8581
  const tagVar = tag.node.var;
8575
8582
  if (tagVar) {
8583
+ const section = getOrCreateSection(tag);
8576
8584
  let canonicalUpstreamAlias = upstreamAlias && getCanonicalBinding(upstreamAlias);
8577
8585
  if (canonicalUpstreamAlias) {
8578
8586
  const { excludeProperties } = canonicalUpstreamAlias;
@@ -8583,7 +8591,7 @@ function trackVarReferences(tag, type, upstreamAlias) {
8583
8591
  tagVar,
8584
8592
  canonicalUpstreamAlias.type,
8585
8593
  tag.scope,
8586
- canonicalUpstreamAlias.section,
8594
+ section,
8587
8595
  canonicalUpstreamAlias,
8588
8596
  void 0,
8589
8597
  excludeProperties
@@ -8594,7 +8602,7 @@ function trackVarReferences(tag, type, upstreamAlias) {
8594
8602
  tagVar,
8595
8603
  type,
8596
8604
  tag.scope,
8597
- getOrCreateSection(tag),
8605
+ section,
8598
8606
  void 0,
8599
8607
  void 0,
8600
8608
  void 0
@@ -9038,20 +9046,20 @@ function finalizeReferences() {
9038
9046
  );
9039
9047
  for (const { isEffect, section: section2 } of binding.reads) {
9040
9048
  if (section2 !== binding.section) {
9041
- const canonicalUpstreamAlias = getCanonicalBinding(binding);
9042
- canonicalUpstreamAlias.closureSections = sectionUtil.add(
9043
- canonicalUpstreamAlias.closureSections,
9044
- section2
9045
- );
9046
9049
  if (binding.type === 4 /* local */) {
9047
9050
  section2.referencedLocalClosures = bindingUtil.add(
9048
9051
  section2.referencedLocalClosures,
9049
9052
  binding
9050
9053
  );
9051
9054
  } else {
9055
+ const canonicalUpstreamAlias = getCanonicalBinding(binding);
9056
+ canonicalUpstreamAlias.closureSections = sectionUtil.add(
9057
+ canonicalUpstreamAlias.closureSections,
9058
+ section2
9059
+ );
9052
9060
  section2.referencedClosures = bindingUtil.add(
9053
9061
  section2.referencedClosures,
9054
- binding
9062
+ canonicalUpstreamAlias
9055
9063
  );
9056
9064
  addOwnerSerializeReason(
9057
9065
  section2,
@@ -10286,12 +10294,13 @@ var define_default = {
10286
10294
  dropNodes(getAllTagReferenceNodes(tag.node));
10287
10295
  return;
10288
10296
  }
10289
- trackParamsReferences(tagBody, 3 /* param */);
10297
+ const paramsBinding = trackParamsReferences(tagBody, 3 /* param */);
10290
10298
  setTagDownstream(tag, varBinding);
10291
10299
  if (bodySection) {
10292
10300
  if (import_compiler43.types.isIdentifier(tag.node.var)) {
10293
10301
  const babelBinding = tag.scope.getBinding(tag.node.var.name);
10294
10302
  let allDirectReferences = true;
10303
+ let allHaveInput = true;
10295
10304
  for (const ref of babelBinding.referencePaths) {
10296
10305
  if (isReferenceHoisted(babelBinding.path, ref)) {
10297
10306
  throw ref.buildCodeFrameError(
@@ -10300,12 +10309,18 @@ var define_default = {
10300
10309
  }
10301
10310
  if (ref.parent.type === "MarkoTag" && ref.parent.name === ref.node) {
10302
10311
  (ref.parent.extra ??= {}).defineBodySection = bodySection;
10312
+ allHaveInput &&= !ref.parent.arguments?.length;
10303
10313
  dropNodes(ref.parent.name);
10304
10314
  } else {
10315
+ allHaveInput = false;
10305
10316
  allDirectReferences = false;
10306
10317
  }
10307
10318
  }
10308
10319
  if (allDirectReferences) {
10320
+ const inputAlias = allHaveInput && paramsBinding?.propertyAliases.get("0");
10321
+ if (inputAlias) {
10322
+ inputAlias.nullable = false;
10323
+ }
10309
10324
  dropNodes(getAllTagReferenceNodes(tag.node));
10310
10325
  return;
10311
10326
  }
@@ -90,7 +90,7 @@ declare module "@marko/compiler/dist/types" {
90
90
  interface FunctionExpressionExtra extends FunctionExtra {
91
91
  }
92
92
  }
93
- export declare function createBinding(name: string, type: Binding["type"], section: Section, upstreamAlias?: Binding["upstreamAlias"], property?: string, excludeProperties?: Opt<string>, loc?: t.SourceLocation | null, declared?: boolean): Binding;
93
+ export declare function createBinding(name: string, type: Binding["type"], refSection: Section, upstreamAlias?: Binding["upstreamAlias"], property?: string, excludeProperties?: Opt<string>, loc?: t.SourceLocation | null, refDeclared?: boolean): Binding;
94
94
  export declare function getOrCreatePropertyAlias(binding: Binding, property: string): Binding;
95
95
  export declare function trackDomVarReferences(tag: t.NodePath<t.MarkoTag>, binding: Binding): Binding | undefined;
96
96
  export declare function trackVarReferences(tag: t.NodePath<t.MarkoTag>, type: BindingType, upstreamAlias?: Binding["upstreamAlias"]): Binding | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.133",
3
+ "version": "6.0.135",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",