marko 6.0.41 → 6.0.42

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.
@@ -802,6 +802,7 @@ function getFnRoot(path5) {
802
802
  fnPath = curPath;
803
803
  } else {
804
804
  switch (curPath.type) {
805
+ case "OptionalCallExpression":
805
806
  case "CallExpression":
806
807
  case "NewExpression":
807
808
  fnPath = void 0;
@@ -850,6 +851,7 @@ function isInvokedFunction(expr) {
850
851
  while (curPath) {
851
852
  const { parent, node } = curPath;
852
853
  switch (parent.type) {
854
+ case "OptionalCallExpression":
853
855
  case "CallExpression":
854
856
  return parent.callee === node;
855
857
  case "TSNonNullExpression":
@@ -3412,24 +3414,33 @@ function generateSignalName(referencedBindings) {
3412
3414
  return name2;
3413
3415
  }
3414
3416
  function replaceNullishAndEmptyFunctionsWith0(args) {
3415
- for (let i = args.length; i--; ) {
3417
+ const len = args.length;
3418
+ let finalLen = void 0;
3419
+ for (let i = len; i--; ) {
3416
3420
  const arg = args[i];
3417
3421
  if (!arg) {
3418
3422
  args[i] = import_compiler20.types.numericLiteral(0);
3419
- } else if (import_compiler20.types.isArrowFunctionExpression(arg) && import_compiler20.types.isBlockStatement(arg.body)) {
3423
+ continue;
3424
+ }
3425
+ if (import_compiler20.types.isNullLiteral(arg) || import_compiler20.types.isUnaryExpression(arg) && arg.operator === "void") {
3426
+ args[i] = import_compiler20.types.numericLiteral(0);
3427
+ continue;
3428
+ }
3429
+ if (import_compiler20.types.isArrowFunctionExpression(arg) && import_compiler20.types.isBlockStatement(arg.body)) {
3420
3430
  const body = arg.body.body;
3421
3431
  if (body.length === 0) {
3422
3432
  args[i] = import_compiler20.types.numericLiteral(0);
3423
- } else if (body.length === 1 && import_compiler20.types.isExpressionStatement(body[0])) {
3433
+ continue;
3434
+ }
3435
+ if (body.length === 1 && import_compiler20.types.isExpressionStatement(body[0])) {
3424
3436
  arg.body = toParenthesizedExpressionIfNeeded(body[0].expression);
3425
3437
  }
3426
- } else if (import_compiler20.types.isNullLiteral(arg) || import_compiler20.types.isUnaryExpression(arg) && arg.operator === "void") {
3427
- args[i] = import_compiler20.types.numericLiteral(0);
3438
+ }
3439
+ if (finalLen === void 0) {
3440
+ finalLen = i + 1;
3428
3441
  }
3429
3442
  }
3430
- for (let i = args.length - 1; import_compiler20.types.isNumericLiteral(args[i]) && args[i].value === 0; ) {
3431
- args.length = i--;
3432
- }
3443
+ args.length = finalLen || 0;
3433
3444
  return args;
3434
3445
  }
3435
3446
  function addStatement(type, targetSection, referencedBindings, statement, usedReferences) {
@@ -1,5 +1,5 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  export default function isInvokedFunction(expr: t.NodePath<t.Node>): expr is typeof expr & {
3
- parent: t.CallExpression;
3
+ parent: t.CallExpression | t.OptionalCallExpression;
4
4
  parentPath: t.NodePath<t.CallExpression>;
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.41",
3
+ "version": "6.0.42",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -48,7 +48,7 @@
48
48
  "build": "node -r ~ts ./scripts/bundle.ts"
49
49
  },
50
50
  "dependencies": {
51
- "@marko/compiler": "^5.39.29",
51
+ "@marko/compiler": "^5.39.31",
52
52
  "csstype": "^3.1.3",
53
53
  "magic-string": "^0.30.17"
54
54
  },