@swagger-api/apidom-parser-adapter-yaml-1-2 1.8.0 → 1.10.0

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.10.0](https://github.com/swagger-api/apidom/compare/v1.9.0...v1.10.0) (2026-04-01)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **parser-adapter:** move tree lifecycle management to callers ([#5156](https://github.com/swagger-api/apidom/issues/5156)) ([30f173b](https://github.com/swagger-api/apidom/commit/30f173b6ac5a13c7f53e01440dde6ded222bd18a))
11
+
12
+ # [1.9.0](https://github.com/swagger-api/apidom/compare/v1.8.0...v1.9.0) (2026-03-30)
13
+
14
+ ### Bug Fixes
15
+
16
+ - **parser-adapter-yaml-1-2:** free WASM tree memory between parses ([#5152](https://github.com/swagger-api/apidom/issues/5152)) ([749deb2](https://github.com/swagger-api/apidom/commit/749deb2e389e971dd343641388785d5ac53dfe01))
17
+
6
18
  # [1.8.0](https://github.com/swagger-api/apidom/compare/v1.7.0...v1.8.0) (2026-03-20)
7
19
 
8
20
  ### Bug Fixes
@@ -9895,7 +9895,8 @@
9895
9895
  };
9896
9896
  let parser = null;
9897
9897
  let parserInitLock = null;
9898
- let currentTree = null;
9898
+ const activeTrees = /* @__PURE__ */ new Set();
9899
+ const MAX_ACTIVE_TREES = 5;
9899
9900
  const createAnalyze = (treeSitterYaml) => (source) => __async$1(null, null, function* () {
9900
9901
  if (parser === null && parserInitLock === null) {
9901
9902
  parserInitLock = Parser.init().then(() => Parser.Language.load(treeSitterYaml)).then((yamlLanguage) => {
@@ -9914,9 +9915,22 @@
9914
9915
  "Error while initializing web-tree-sitter and loading tree-sitter-yaml grammar."
9915
9916
  );
9916
9917
  }
9917
- currentTree = parser.parse(source);
9918
+ if (activeTrees.size >= MAX_ACTIVE_TREES) {
9919
+ const treesToEvict = [...activeTrees];
9920
+ activeTrees.clear();
9921
+ for (const oldTree of treesToEvict) {
9922
+ oldTree.delete();
9923
+ }
9924
+ }
9925
+ const tree = parser.parse(source);
9926
+ activeTrees.add(tree);
9927
+ const originalDelete = tree.delete;
9928
+ tree.delete = function deleteAndUntrack() {
9929
+ activeTrees.delete(this);
9930
+ originalDelete.call(this);
9931
+ };
9918
9932
  parser.reset();
9919
- return currentTree;
9933
+ return tree;
9920
9934
  });
9921
9935
 
9922
9936
  const analyze$1 = createAnalyze(treeSitterYaml);
@@ -19477,20 +19491,28 @@
19477
19491
  });
19478
19492
  };
19479
19493
  const detect = (source) => __async(null, null, function* () {
19494
+ let cst = null;
19480
19495
  try {
19481
- const cst = yield analyze$1(source);
19482
- const isError = !cst.rootNode.isError;
19483
- cst.delete();
19484
- return isError;
19496
+ cst = yield analyze$1(source);
19497
+ return !cst.rootNode.isError;
19485
19498
  } catch (e) {
19486
19499
  return false;
19500
+ } finally {
19501
+ if (cst !== null) {
19502
+ cst.delete();
19503
+ }
19487
19504
  }
19488
19505
  });
19489
19506
  const parse = (_0, ..._1) => __async(null, [_0, ..._1], function* (source, { sourceMap = false } = {}) {
19490
- const cst = yield analyze$1(source);
19491
- const syntacticAnalysisResult = analyze(cst, { sourceMap });
19492
- cst.delete();
19493
- return syntacticAnalysisResult;
19507
+ let cst = null;
19508
+ try {
19509
+ cst = yield analyze$1(source);
19510
+ return analyze(cst, { sourceMap });
19511
+ } finally {
19512
+ if (cst !== null) {
19513
+ cst.delete();
19514
+ }
19515
+ }
19494
19516
  });
19495
19517
 
19496
19518
  exports.detect = detect;