marko 6.0.0-next.3.68 → 6.0.0-next.3.70

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.
@@ -1271,13 +1271,6 @@ var [_getScopeIdentifier] = createSectionState(
1271
1271
  "scopeIdentifier",
1272
1272
  () => import_compiler6.types.identifier("undefined")
1273
1273
  );
1274
- var getScopeIdentifier = (section, ignoreDefault) => {
1275
- const scopeId = _getScopeIdentifier(section);
1276
- if (!ignoreDefault && scopeId.name === "undefined") {
1277
- scopeId.name = currentProgramPath.scope.generateUid(`scope${section.id}_`);
1278
- }
1279
- return scopeId;
1280
- };
1281
1274
  function forEachSection(fn) {
1282
1275
  const { sections } = currentProgramPath.node.extra;
1283
1276
  sections?.forEach(fn);
@@ -5753,104 +5746,19 @@ var for_default = {
5753
5746
  const hasHoists = isSectionWithHoists(bodySection);
5754
5747
  const serializeReason = hasHoists || sectionSources?.all;
5755
5748
  const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild && bodySection.content.startType !== 4 /* Text */;
5756
- let keyExpression;
5757
- if (sectionSources?.referenced && onlyChildInParentOptimization) {
5749
+ if (serializeReason && onlyChildInParentOptimization) {
5758
5750
  getParentTag(tag).node.extra[kSerializeMarker] = false;
5759
5751
  }
5760
- if (serializeReason) {
5761
- serializeSectionIfNeeded(bodySection, serializeReason);
5762
- const defaultParamNames = {
5763
- of: ["list", "index"],
5764
- in: ["key", "value"],
5765
- to: ["value"]
5766
- }[forType];
5767
- const defaultByParamIndex = forType === "of" ? 1 : 0;
5768
- const requiredParamsIndex = forAttrs.by ? defaultParamNames.length - 1 : defaultByParamIndex;
5769
- for (let i = 0; i <= requiredParamsIndex; i++) {
5770
- const existingParam = params[i];
5771
- if (!existingParam || !import_compiler32.types.isIdentifier(existingParam)) {
5772
- const id = params[i] = currentProgramPath.scope.generateUidIdentifier(
5773
- defaultParamNames[i]
5774
- );
5775
- if (existingParam) {
5776
- bodyStatements.unshift(
5777
- import_compiler32.types.variableDeclaration("let", [
5778
- import_compiler32.types.variableDeclarator(existingParam, id)
5779
- ])
5780
- );
5781
- }
5782
- }
5783
- }
5784
- if (forAttrs.by) {
5785
- if (import_compiler32.types.isStringLiteral(forAttrs.by)) {
5786
- keyExpression = toMemberExpression(
5787
- params[0],
5788
- forAttrs.by.value
5789
- );
5790
- } else if (import_compiler32.types.isFunction(forAttrs.by)) {
5791
- const byIdentifier = currentProgramPath.scope.generateUidIdentifier("by");
5792
- statements.push(
5793
- import_compiler32.types.variableDeclaration("const", [
5794
- import_compiler32.types.variableDeclarator(byIdentifier, forAttrs.by)
5795
- ])
5796
- );
5797
- keyExpression = import_compiler32.types.callExpression(
5798
- byIdentifier,
5799
- params
5800
- );
5801
- } else {
5802
- keyExpression = callRuntime(
5803
- forTypeToHTMLByRuntime(forType),
5804
- forAttrs.by,
5805
- ...params
5806
- );
5807
- }
5808
- } else {
5809
- keyExpression = params[defaultByParamIndex];
5810
- }
5811
- const forScopesIdentifier = getScopeIdentifier(bodySection);
5812
- getHTMLSectionStatements(tagSection).push(
5813
- import_compiler32.types.variableDeclaration("const", [
5814
- import_compiler32.types.variableDeclarator(
5815
- forScopesIdentifier,
5816
- import_compiler32.types.newExpression(import_compiler32.types.identifier("Map"), [])
5817
- )
5818
- ])
5819
- );
5820
- bodyStatements.push(
5821
- import_compiler32.types.expressionStatement(
5822
- import_compiler32.types.callExpression(
5823
- import_compiler32.types.memberExpression(forScopesIdentifier, import_compiler32.types.identifier("set")),
5824
- [
5825
- keyExpression,
5826
- callRuntime(
5827
- "ensureScopeWithId",
5828
- getScopeIdIdentifier(bodySection)
5829
- )
5830
- ]
5831
- )
5832
- )
5833
- );
5834
- setSerializedProperty(
5835
- tagSection,
5836
- getAccessorPrefix().LoopScopeMap + getScopeAccessor(nodeRef2),
5837
- import_compiler32.types.conditionalExpression(
5838
- import_compiler32.types.memberExpression(forScopesIdentifier, import_compiler32.types.identifier("size")),
5839
- forScopesIdentifier,
5840
- import_compiler32.types.identifier("undefined")
5841
- ),
5842
- serializeReason
5843
- );
5844
- }
5845
5752
  flushInto(tag);
5846
5753
  writeHTMLResumeStatements(tagBody);
5847
5754
  const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
5848
- const forTagHTMLRuntime = sectionSources?.referenced ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
5755
+ const forTagHTMLRuntime = serializeReason ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
5849
5756
  forTagArgs.push(
5850
5757
  import_compiler32.types.arrowFunctionExpression(params, import_compiler32.types.blockStatement(bodyStatements))
5851
5758
  );
5852
- if (sectionSources?.referenced) {
5759
+ if (serializeReason) {
5853
5760
  forTagArgs.push(
5761
+ forAttrs.by || import_compiler32.types.numericLiteral(0),
5854
5762
  getScopeIdIdentifier(tagSection),
5855
5763
  getScopeAccessorLiteral(nodeRef2)
5856
5764
  );
@@ -6062,16 +5970,6 @@ function forTypeToDOMRuntime(type) {
6062
5970
  return "loopTo";
6063
5971
  }
6064
5972
  }
6065
- function forTypeToHTMLByRuntime(type) {
6066
- switch (type) {
6067
- case "of":
6068
- return "forOfBy";
6069
- case "in":
6070
- return "forInBy";
6071
- case "to":
6072
- return "forToBy";
6073
- }
6074
- }
6075
5973
  function getBaseArgsInForTag(type, attrs2) {
6076
5974
  switch (type) {
6077
5975
  case "in":
@@ -7624,7 +7522,6 @@ var IfTag = {
7624
7522
  const hasHoists = hasHoistsInBranches(branches);
7625
7523
  const serializeReason = hasHoists || branchSources?.all;
7626
7524
  if (bodySection) {
7627
- serializeSectionIfNeeded(bodySection, serializeReason);
7628
7525
  flushInto(tag);
7629
7526
  writeHTMLResumeStatements(tagBody);
7630
7527
  }
@@ -7632,38 +7529,17 @@ var IfTag = {
7632
7529
  const nodeRef2 = getOptimizedOnlyChildNodeRef(rootTag, section);
7633
7530
  const onlyChildInParentOptimization = isOnlyChildInParent(rootTag);
7634
7531
  const nextTag = tag.getNextSibling();
7635
- const ifScopeIdIdentifier = rootTag.scope.generateUidIdentifier("ifScopeId");
7636
- const ifBranchIdentifier = rootTag.scope.generateUidIdentifier("ifBranch");
7637
7532
  let statement;
7638
7533
  if (branchSources?.referenced && onlyChildInParentOptimization) {
7639
7534
  getParentTag(rootTag).node.extra[kSerializeMarker] = false;
7640
7535
  }
7641
7536
  for (let i = branches.length; i--; ) {
7642
- const [branchTag, branchBodySection] = branches[i];
7537
+ const [branchTag] = branches[i];
7643
7538
  const bodyStatements = branchTag.node.body.body;
7644
- if (branchBodySection) {
7645
- if (branchSources?.referenced) {
7646
- bodyStatements.push(
7647
- import_compiler41.types.expressionStatement(
7648
- import_compiler41.types.assignmentExpression(
7649
- "=",
7650
- ifBranchIdentifier,
7651
- import_compiler41.types.numericLiteral(i)
7652
- )
7653
- )
7654
- );
7655
- }
7656
- if (serializeReason) {
7657
- bodyStatements.push(
7658
- import_compiler41.types.expressionStatement(
7659
- import_compiler41.types.assignmentExpression(
7660
- "=",
7661
- ifScopeIdIdentifier,
7662
- getScopeIdIdentifier(branchBodySection)
7663
- )
7664
- )
7665
- );
7666
- }
7539
+ if (serializeReason) {
7540
+ bodyStatements.push(
7541
+ import_compiler41.types.returnStatement(import_compiler41.types.numericLiteral(i))
7542
+ );
7667
7543
  }
7668
7544
  const [testAttr] = branchTag.node.attributes;
7669
7545
  const curStatement = toFirstStatementOrBlock(bodyStatements);
@@ -7679,51 +7555,29 @@ var IfTag = {
7679
7555
  branchTag.remove();
7680
7556
  }
7681
7557
  if (serializeReason) {
7682
- if (branchSources?.referenced) {
7683
- setSerializedProperty(
7684
- section,
7685
- getAccessorPrefix().ConditionalRenderer + getScopeAccessor(nodeRef2),
7686
- ifBranchIdentifier,
7687
- branchSources.referenced
7688
- );
7689
- const cbNode = import_compiler41.types.arrowFunctionExpression(
7690
- [],
7691
- import_compiler41.types.blockStatement([statement])
7692
- );
7693
- statement = import_compiler41.types.expressionStatement(
7694
- singleNodeOptimization ? callRuntime(
7695
- "resumeSingleNodeConditional",
7696
- cbNode,
7697
- getScopeIdIdentifier(section),
7698
- getScopeAccessorLiteral(nodeRef2),
7699
- onlyChildInParentOptimization && import_compiler41.types.numericLiteral(1)
7700
- ) : callRuntime(
7701
- "resumeConditional",
7702
- cbNode,
7703
- getScopeIdIdentifier(section),
7704
- getScopeAccessorLiteral(nodeRef2)
7705
- )
7706
- );
7707
- }
7708
- nextTag.insertBefore(statement);
7709
- getHTMLSectionStatements(section).push(
7710
- import_compiler41.types.variableDeclaration(
7711
- "let",
7712
- [
7713
- import_compiler41.types.variableDeclarator(ifScopeIdIdentifier),
7714
- branchSources?.referenced && import_compiler41.types.variableDeclarator(ifBranchIdentifier)
7715
- ].filter(Boolean)
7716
- )
7558
+ const conditionSerializeReason = branchSources?.referenced;
7559
+ const cbNode = import_compiler41.types.arrowFunctionExpression(
7560
+ [],
7561
+ import_compiler41.types.blockStatement([statement])
7717
7562
  );
7718
- setSerializedProperty(
7719
- section,
7720
- getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2),
7721
- callRuntime("getScopeById", ifScopeIdIdentifier),
7722
- serializeReason
7563
+ statement = import_compiler41.types.expressionStatement(
7564
+ singleNodeOptimization ? callRuntime(
7565
+ "resumeSingleNodeConditional",
7566
+ cbNode,
7567
+ getScopeIdIdentifier(section),
7568
+ getScopeAccessorLiteral(nodeRef2),
7569
+ conditionSerializeReason ? import_compiler41.types.numericLiteral(1) : onlyChildInParentOptimization ? import_compiler41.types.numericLiteral(0) : void 0,
7570
+ onlyChildInParentOptimization && import_compiler41.types.numericLiteral(1)
7571
+ ) : callRuntime(
7572
+ "resumeConditional",
7573
+ cbNode,
7574
+ getScopeIdIdentifier(section),
7575
+ getScopeAccessorLiteral(nodeRef2),
7576
+ conditionSerializeReason ? import_compiler41.types.numericLiteral(1) : void 0
7577
+ )
7723
7578
  );
7724
- } else {
7725
- nextTag.insertBefore(statement);
7726
7579
  }
7580
+ nextTag.insertBefore(statement);
7727
7581
  }
7728
7582
  }
7729
7583
  },
@@ -9859,34 +9713,36 @@ var dynamic_tag_default = {
9859
9713
  if (isOutputHTML()) {
9860
9714
  flushInto(tag);
9861
9715
  writeHTMLResumeStatements(tag.get("body"));
9862
- if (node.var) {
9863
- if (!hasMultipleArgs && args.length === 1) {
9864
- args.push(import_compiler55.types.unaryExpression("void", import_compiler55.types.numericLiteral(0)));
9865
- }
9866
- }
9867
- const dynamicScopeIdentifier = currentProgramPath.scope.generateUidIdentifier("dynamicScope");
9716
+ const serializeReason = isClassAPI || !!node.var || getDynamicSourcesForReferences(referencedBindings);
9868
9717
  const dynamicTagExpr = hasMultipleArgs ? callRuntime(
9869
- "dynamicTagArgs",
9718
+ "dynamicTag",
9870
9719
  getScopeIdIdentifier(section),
9871
9720
  getScopeAccessorLiteral(nodeRef2),
9872
9721
  tagExpression,
9873
- import_compiler55.types.arrayExpression(args)
9722
+ import_compiler55.types.arrayExpression(args),
9723
+ import_compiler55.types.numericLiteral(0),
9724
+ import_compiler55.types.numericLiteral(1),
9725
+ serializeReason ? import_compiler55.types.numericLiteral(1) : void 0
9874
9726
  ) : callRuntime(
9875
- "dynamicTagInput",
9727
+ "dynamicTag",
9876
9728
  getScopeIdIdentifier(section),
9877
9729
  getScopeAccessorLiteral(nodeRef2),
9878
9730
  tagExpression,
9879
- ...args
9880
- );
9881
- statements.push(
9882
- import_compiler55.types.variableDeclaration("const", [
9883
- import_compiler55.types.variableDeclarator(
9884
- dynamicScopeIdentifier,
9885
- callRuntime("peekNextScope")
9886
- )
9887
- ])
9731
+ args[0],
9732
+ args[1] || (serializeReason ? import_compiler55.types.numericLiteral(0) : void 0),
9733
+ serializeReason ? import_compiler55.types.numericLiteral(0) : void 0,
9734
+ serializeReason ? import_compiler55.types.numericLiteral(1) : void 0
9888
9735
  );
9889
9736
  if (node.var) {
9737
+ const dynamicScopeIdentifier = currentProgramPath.scope.generateUidIdentifier("dynamicScope");
9738
+ statements.push(
9739
+ import_compiler55.types.variableDeclaration("const", [
9740
+ import_compiler55.types.variableDeclarator(
9741
+ dynamicScopeIdentifier,
9742
+ callRuntime("peekNextScope")
9743
+ )
9744
+ ])
9745
+ );
9890
9746
  statements.push(
9891
9747
  import_compiler55.types.variableDeclaration("const", [
9892
9748
  import_compiler55.types.variableDeclarator(node.var, dynamicTagExpr)
@@ -9913,24 +9769,6 @@ var dynamic_tag_default = {
9913
9769
  } else {
9914
9770
  statements.push(import_compiler55.types.expressionStatement(dynamicTagExpr));
9915
9771
  }
9916
- const serializeReason = isClassAPI || !!node.var || getDynamicSourcesForReferences(referencedBindings);
9917
- if (serializeReason) {
9918
- setSerializedProperty(
9919
- section,
9920
- getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2),
9921
- callRuntime("writeExistingScope", dynamicScopeIdentifier),
9922
- serializeReason
9923
- );
9924
- setSerializedProperty(
9925
- section,
9926
- getAccessorPrefix().ConditionalRenderer + getScopeAccessor(nodeRef2),
9927
- callRuntime(
9928
- "dynamicTagId",
9929
- import_compiler55.types.isIdentifier(tagExpression) ? import_compiler55.types.identifier(tagExpression.name) : tagExpression
9930
- ),
9931
- serializeReason
9932
- );
9933
- }
9934
9772
  for (const replacement of tag.replaceWithMultiple(statements)) {
9935
9773
  replacement.skip();
9936
9774
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.0-next.3.68",
3
+ "version": "6.0.0-next.3.70",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",