@swagger-api/apidom-parser-adapter-openapi-json-3-0 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,14 @@
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
+ **Note:** Version bump only for package @swagger-api/apidom-parser-adapter-openapi-json-3-0
9
+
10
+ # [1.9.0](https://github.com/swagger-api/apidom/compare/v1.8.0...v1.9.0) (2026-03-30)
11
+
12
+ **Note:** Version bump only for package @swagger-api/apidom-parser-adapter-openapi-json-3-0
13
+
6
14
  # [1.8.0](https://github.com/swagger-api/apidom/compare/v1.7.0...v1.8.0) (2026-03-20)
7
15
 
8
16
  **Note:** Version bump only for package @swagger-api/apidom-parser-adapter-openapi-json-3-0
@@ -17954,14 +17954,12 @@
17954
17954
 
17955
17955
  let parser = null;
17956
17956
  let parserInitLock = null;
17957
- let currentTree = null;
17957
+ const activeTrees = new Set();
17958
+ const MAX_ACTIVE_TREES = 5;
17958
17959
 
17959
17960
  /**
17960
17961
  * Lexical Analysis of source string using WebTreeSitter.
17961
17962
  * This is WebAssembly version of TreeSitters Lexical Analysis.
17962
- *
17963
- * Given JavaScript doesn't support true parallelism, this
17964
- * code should be as lazy as possible and temporal safety should be fine.
17965
17963
  * @public
17966
17964
  */
17967
17965
  const analyze$2 = async source => {
@@ -17982,9 +17980,28 @@
17982
17980
  } else if (parser === null) {
17983
17981
  throw new ApiDOMError('Error while initializing web-tree-sitter and loading tree-sitter-json grammar.');
17984
17982
  }
17985
- currentTree = parser.parse(source);
17983
+
17984
+ // prevent WASM OOM during concurrency spikes by evicting oldest trees
17985
+ // when the pool exceeds threshold; tree.delete() is idempotent so
17986
+ // callers that still hold a reference can safely call delete() again
17987
+ if (activeTrees.size >= MAX_ACTIVE_TREES) {
17988
+ const treesToEvict = [...activeTrees];
17989
+ activeTrees.clear();
17990
+ for (const oldTree of treesToEvict) {
17991
+ oldTree.delete();
17992
+ }
17993
+ }
17994
+ const tree = parser.parse(source);
17995
+ activeTrees.add(tree);
17996
+
17997
+ // remove from tracking when caller deletes
17998
+ const originalDelete = tree.delete;
17999
+ tree.delete = function deleteAndUntrack() {
18000
+ activeTrees.delete(this);
18001
+ originalDelete.call(this);
18002
+ };
17986
18003
  parser.reset();
17987
- return currentTree;
18004
+ return tree;
17988
18005
  };
17989
18006
 
17990
18007
  class TreeCursorSyntaxNode {
@@ -18638,13 +18655,17 @@
18638
18655
  if (!detectionRegExp$1.test(source)) {
18639
18656
  return false;
18640
18657
  }
18658
+ let cst = null;
18641
18659
  try {
18642
- const cst = await analyze$2(source);
18660
+ cst = await analyze$2(source);
18643
18661
  const isError = cst.rootNode.type !== 'ERROR';
18644
- cst.delete();
18645
18662
  return isError;
18646
18663
  } catch {
18647
18664
  return false;
18665
+ } finally {
18666
+ if (cst !== null) {
18667
+ cst.delete();
18668
+ }
18648
18669
  }
18649
18670
  };
18650
18671
 
@@ -18663,19 +18684,22 @@
18663
18684
  sourceMap = false,
18664
18685
  syntacticAnalysis = 'direct'
18665
18686
  } = {}) => {
18666
- const cst = await analyze$2(source);
18667
- let apiDOM;
18668
- if (syntacticAnalysis === 'indirect') {
18669
- apiDOM = analyze(cst, {
18670
- sourceMap
18671
- });
18672
- } else {
18673
- apiDOM = analyze$1(cst, {
18687
+ let cst = null;
18688
+ try {
18689
+ cst = await analyze$2(source);
18690
+ if (syntacticAnalysis === 'indirect') {
18691
+ return analyze(cst, {
18692
+ sourceMap
18693
+ });
18694
+ }
18695
+ return analyze$1(cst, {
18674
18696
  sourceMap
18675
18697
  });
18698
+ } finally {
18699
+ if (cst !== null) {
18700
+ cst.delete();
18701
+ }
18676
18702
  }
18677
- cst.delete();
18678
- return apiDOM;
18679
18703
  };
18680
18704
 
18681
18705
  /**