marko 6.0.0-next.3.33 → 6.0.0-next.3.34

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.
@@ -3237,12 +3237,22 @@ function getExprRoot(path5) {
3237
3237
  }
3238
3238
  function getFnRoot(path5) {
3239
3239
  let curPath = path5;
3240
+ let fnPath;
3240
3241
  if (curPath.isProgram()) return;
3241
- while (!isFunctionExpression(curPath)) {
3242
- if (isMarko(curPath)) return;
3242
+ while (!isMarko(curPath)) {
3243
+ if (isFunction(curPath)) {
3244
+ fnPath = curPath;
3245
+ } else {
3246
+ switch (curPath.type) {
3247
+ case "CallExpression":
3248
+ case "NewExpression":
3249
+ fnPath = void 0;
3250
+ break;
3251
+ }
3252
+ }
3243
3253
  curPath = curPath.parentPath;
3244
3254
  }
3245
- return curPath;
3255
+ return fnPath;
3246
3256
  }
3247
3257
  function isMarko(path5) {
3248
3258
  switch (path5.type) {
@@ -3257,10 +3267,13 @@ function isMarko(path5) {
3257
3267
  return false;
3258
3268
  }
3259
3269
  }
3260
- function isFunctionExpression(path5) {
3270
+ function isFunction(path5) {
3261
3271
  switch (path5.type) {
3272
+ case "FunctionDeclaration":
3273
+ return !path5.node.declare;
3262
3274
  case "FunctionExpression":
3263
3275
  case "ArrowFunctionExpression":
3276
+ case "ObjectMethod":
3264
3277
  return true;
3265
3278
  default:
3266
3279
  return false;
@@ -3393,10 +3406,9 @@ function trackAssignment(assignment, binding) {
3393
3406
  });
3394
3407
  }
3395
3408
  function setReferencesScope(path5) {
3396
- let fnRoot = getFnRoot(path5);
3397
- while (fnRoot) {
3409
+ const fnRoot = getFnRoot(path5);
3410
+ if (fnRoot) {
3398
3411
  (fnRoot.node.extra ??= {}).referencesScope = true;
3399
- fnRoot = getFnRoot(fnRoot.parentPath);
3400
3412
  }
3401
3413
  }
3402
3414
  function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAlias, upstreamExpression, property) {
@@ -7989,10 +8001,10 @@ var import_babel_utils37 = require("@marko/compiler/babel-utils");
7989
8001
  var functionIdsBySection = /* @__PURE__ */ new WeakMap();
7990
8002
  var function_default = {
7991
8003
  analyze(fn) {
7992
- const fnRoot = getFnRoot(fn.parentPath);
7993
- const markoRoot = getMarkoRoot(fnRoot || fn);
7994
- const isStatic2 = !markoRoot || markoRoot.isMarkoScriptlet({ static: true });
7995
- if (fnRoot || !isFunction(fn, isStatic2)) return;
8004
+ if (fn !== getFnRoot(fn)) {
8005
+ return;
8006
+ }
8007
+ const markoRoot = getMarkoRoot(fn);
7996
8008
  if (markoRoot && (markoRoot.isMarkoPlaceholder() || markoRoot.isMarkoScriptlet() && markoRoot.node.target === "server")) {
7997
8009
  return;
7998
8010
  }
@@ -8029,18 +8041,6 @@ var function_default = {
8029
8041
  );
8030
8042
  }
8031
8043
  };
8032
- function isFunction(fn, isStatic2) {
8033
- switch (fn.node.type) {
8034
- case "FunctionDeclaration":
8035
- return isStatic2 && !fn.node.declare;
8036
- case "FunctionExpression":
8037
- case "ArrowFunctionExpression":
8038
- case "ObjectMethod":
8039
- return true;
8040
- default:
8041
- return false;
8042
- }
8043
- }
8044
8044
  function isMarkoAttribute(path5) {
8045
8045
  return path5 ? path5.isMarkoAttribute() : false;
8046
8046
  }
@@ -2,6 +2,6 @@ import type { types as t } from "@marko/compiler";
2
2
  type MarkoExprRootPath = t.NodePath<t.MarkoTag | t.MarkoTagBody | t.MarkoAttribute | t.MarkoSpreadAttribute | t.MarkoScriptlet | t.MarkoPlaceholder>;
3
3
  export declare function getMarkoRoot(path: t.NodePath<t.Node>): MarkoExprRootPath | null;
4
4
  export declare function getExprRoot(path: t.NodePath<t.Node>): t.NodePath<t.Node>;
5
- export declare function getFnRoot(path: t.NodePath<t.Node>): t.NodePath<t.ArrowFunctionExpression | t.FunctionExpression> | undefined;
5
+ export declare function getFnRoot(path: t.NodePath<t.Node>): t.NodePath<t.ArrowFunctionExpression | t.FunctionExpression | t.ObjectMember> | undefined;
6
6
  export declare function isMarko(path: t.NodePath<any>): path is MarkoExprRootPath;
7
7
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.0-next.3.33",
3
+ "version": "6.0.0-next.3.34",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",