@marko/language-tools 2.5.13 → 2.5.14

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.
@@ -9,11 +9,13 @@ export interface ProgramScope {
9
9
  parent: undefined;
10
10
  hoists: false;
11
11
  bindings: Bindings;
12
+ mutatedBindings: undefined | Set<VarBinding>;
12
13
  }
13
14
  export interface TagScope {
14
15
  parent: Scope;
15
16
  hoists: boolean;
16
17
  bindings: undefined | Bindings;
18
+ mutatedBindings: undefined | Set<VarBinding>;
17
19
  }
18
20
  export type Binding = VarBinding | ParamBinding | HoistedBinding;
19
21
  export interface VarBinding {
@@ -53,7 +55,7 @@ type Bindings = {
53
55
  export declare function crawlProgramScope(parsed: Parsed, scriptParser: ScriptParser): [number, ...number[]] | [...number[], number] | undefined;
54
56
  export declare function getHoists(node: Node.Program): Repeatable<string>;
55
57
  export declare function getHoistSources(node: Node.ParentNode): Repeatable<string>;
56
- export declare function getMutatedVars(node: Node.ParentNode): Repeatable<VarBinding>;
58
+ export declare function getMutatedVars(node: Node.ParentNode): Set<VarBinding> | undefined;
57
59
  export declare function isMutatedVar(node: Node.ParentNode, name: string): boolean;
58
60
  export declare function hasHoists(node: Node.ParentTag): boolean;
59
61
  export declare function getBoundAttrMemberExpressionStartOffset(value: Node.AttrValue): number | undefined;
package/dist/index.js CHANGED
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  NodeType: () => NodeType,
34
34
  Processors: () => processors_exports,
35
35
  Project: () => project_exports,
@@ -46,7 +46,7 @@ __export(src_exports, {
46
46
  isDefinitionFile: () => isDefinitionFile,
47
47
  parse: () => parse
48
48
  });
49
- module.exports = __toCommonJS(src_exports);
49
+ module.exports = __toCommonJS(index_exports);
50
50
 
51
51
  // src/parser.ts
52
52
  var import_htmljs_parser = require("htmljs-parser");
@@ -1083,7 +1083,8 @@ function crawlProgramScope(parsed, scriptParser) {
1083
1083
  const programScope = {
1084
1084
  parent: void 0,
1085
1085
  hoists: false,
1086
- bindings: {}
1086
+ bindings: {},
1087
+ mutatedBindings: void 0
1087
1088
  };
1088
1089
  programScope.bindings.input = {
1089
1090
  type: 0 /* var */,
@@ -1178,7 +1179,8 @@ function crawlProgramScope(parsed, scriptParser) {
1178
1179
  const bodyScope = {
1179
1180
  parent: parentScope,
1180
1181
  hoists: false,
1181
- bindings: {}
1182
+ bindings: {},
1183
+ mutatedBindings: void 0
1182
1184
  };
1183
1185
  if (child.params) {
1184
1186
  bodyScope.bindings ??= {};
@@ -1249,6 +1251,9 @@ ${read({
1249
1251
  );
1250
1252
  if (binding) {
1251
1253
  binding.mutated = true;
1254
+ (parentScope.mutatedBindings ||= /* @__PURE__ */ new Set()).add(
1255
+ binding
1256
+ );
1252
1257
  }
1253
1258
  }
1254
1259
  break;
@@ -1333,24 +1338,16 @@ function getHoistSources(node) {
1333
1338
  return result;
1334
1339
  }
1335
1340
  function getMutatedVars(node) {
1336
- let result;
1337
- const { bindings } = Scopes.get(node.body);
1338
- for (const key in bindings) {
1339
- const binding = bindings[key];
1340
- if (binding.type === 0 /* var */ && binding.mutated) {
1341
- if (result) {
1342
- result.push(binding);
1343
- } else {
1344
- result = [binding];
1345
- }
1346
- }
1347
- }
1348
- return result;
1341
+ return Scopes.get(node.body).mutatedBindings;
1349
1342
  }
1350
1343
  function isMutatedVar(node, name) {
1351
- const { bindings } = Scopes.get(node.body);
1352
- const binding = bindings == null ? void 0 : bindings[name];
1353
- return (binding == null ? void 0 : binding.type) === 0 /* var */ && binding.mutated;
1344
+ const { mutatedBindings } = Scopes.get(node.body);
1345
+ if (mutatedBindings) {
1346
+ for (const binding of mutatedBindings) {
1347
+ if (binding.name === name) return true;
1348
+ }
1349
+ }
1350
+ return false;
1354
1351
  }
1355
1352
  function hasHoists(node) {
1356
1353
  return node.body ? Scopes.get(node.body).hoists : false;
@@ -1600,6 +1597,7 @@ function trackMutations(node, scope, mutations, parentBlock, parentBlockShadows,
1600
1597
  if (binding) {
1601
1598
  binding.mutated = true;
1602
1599
  mutations.push(start);
1600
+ (scope.mutatedBindings ||= /* @__PURE__ */ new Set()).add(binding);
1603
1601
  }
1604
1602
  }
1605
1603
  }
package/dist/index.mjs CHANGED
@@ -1043,7 +1043,8 @@ function crawlProgramScope(parsed, scriptParser) {
1043
1043
  const programScope = {
1044
1044
  parent: void 0,
1045
1045
  hoists: false,
1046
- bindings: {}
1046
+ bindings: {},
1047
+ mutatedBindings: void 0
1047
1048
  };
1048
1049
  programScope.bindings.input = {
1049
1050
  type: 0 /* var */,
@@ -1138,7 +1139,8 @@ function crawlProgramScope(parsed, scriptParser) {
1138
1139
  const bodyScope = {
1139
1140
  parent: parentScope,
1140
1141
  hoists: false,
1141
- bindings: {}
1142
+ bindings: {},
1143
+ mutatedBindings: void 0
1142
1144
  };
1143
1145
  if (child.params) {
1144
1146
  bodyScope.bindings ??= {};
@@ -1209,6 +1211,9 @@ ${read({
1209
1211
  );
1210
1212
  if (binding) {
1211
1213
  binding.mutated = true;
1214
+ (parentScope.mutatedBindings ||= /* @__PURE__ */ new Set()).add(
1215
+ binding
1216
+ );
1212
1217
  }
1213
1218
  }
1214
1219
  break;
@@ -1293,24 +1298,16 @@ function getHoistSources(node) {
1293
1298
  return result;
1294
1299
  }
1295
1300
  function getMutatedVars(node) {
1296
- let result;
1297
- const { bindings } = Scopes.get(node.body);
1298
- for (const key in bindings) {
1299
- const binding = bindings[key];
1300
- if (binding.type === 0 /* var */ && binding.mutated) {
1301
- if (result) {
1302
- result.push(binding);
1303
- } else {
1304
- result = [binding];
1305
- }
1306
- }
1307
- }
1308
- return result;
1301
+ return Scopes.get(node.body).mutatedBindings;
1309
1302
  }
1310
1303
  function isMutatedVar(node, name) {
1311
- const { bindings } = Scopes.get(node.body);
1312
- const binding = bindings == null ? void 0 : bindings[name];
1313
- return (binding == null ? void 0 : binding.type) === 0 /* var */ && binding.mutated;
1304
+ const { mutatedBindings } = Scopes.get(node.body);
1305
+ if (mutatedBindings) {
1306
+ for (const binding of mutatedBindings) {
1307
+ if (binding.name === name) return true;
1308
+ }
1309
+ }
1310
+ return false;
1314
1311
  }
1315
1312
  function hasHoists(node) {
1316
1313
  return node.body ? Scopes.get(node.body).hoists : false;
@@ -1560,6 +1557,7 @@ function trackMutations(node, scope, mutations, parentBlock, parentBlockShadows,
1560
1557
  if (binding) {
1561
1558
  binding.mutated = true;
1562
1559
  mutations.push(start);
1560
+ (scope.mutatedBindings ||= /* @__PURE__ */ new Set()).add(binding);
1563
1561
  }
1564
1562
  }
1565
1563
  }
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@marko/language-tools",
3
3
  "description": "Marko Language Tools",
4
- "version": "2.5.13",
4
+ "version": "2.5.14",
5
5
  "bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
6
6
  "peerDependencies": {
7
7
  "@marko/compiler": "^5.28.4"
8
8
  },
9
9
  "dependencies": {
10
- "@babel/parser": "^7.26.3",
11
- "@luxass/strip-json-comments": "^1.3.2",
10
+ "@babel/parser": "^7.26.7",
11
+ "@luxass/strip-json-comments": "^1.4.0",
12
12
  "htmljs-parser": "^5.5.3",
13
13
  "relative-import-path": "^1.0.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@babel/code-frame": "^7.26.2",
17
- "@marko/compiler": "^5.39.6",
17
+ "@marko/compiler": "^5.39.11",
18
18
  "@types/babel__code-frame": "^7.0.6",
19
19
  "@typescript/vfs": "^1.6.0",
20
- "marko": "^5.37.7",
21
- "mitata": "^1.0.21",
20
+ "marko": "^5.37.12",
21
+ "mitata": "^1.0.33",
22
22
  "tsx": "^4.19.2"
23
23
  },
24
24
  "exports": {