@swagger-api/apidom-parser-adapter-api-design-systems-json 1.9.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,10 @@
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-api-design-systems-json
9
+
6
10
  # [1.9.0](https://github.com/swagger-api/apidom/compare/v1.8.0...v1.9.0) (2026-03-30)
7
11
 
8
12
  **Note:** Version bump only for package @swagger-api/apidom-parser-adapter-api-design-systems-json
@@ -16825,14 +16825,12 @@
16825
16825
 
16826
16826
  let parser = null;
16827
16827
  let parserInitLock = null;
16828
- let currentTree = null;
16828
+ const activeTrees = new Set();
16829
+ const MAX_ACTIVE_TREES = 5;
16829
16830
 
16830
16831
  /**
16831
16832
  * Lexical Analysis of source string using WebTreeSitter.
16832
16833
  * This is WebAssembly version of TreeSitters Lexical Analysis.
16833
- *
16834
- * Given JavaScript doesn't support true parallelism, this
16835
- * code should be as lazy as possible and temporal safety should be fine.
16836
16834
  * @public
16837
16835
  */
16838
16836
  const analyze$2 = async source => {
@@ -16853,9 +16851,28 @@
16853
16851
  } else if (parser === null) {
16854
16852
  throw new ApiDOMError('Error while initializing web-tree-sitter and loading tree-sitter-json grammar.');
16855
16853
  }
16856
- currentTree = parser.parse(source);
16854
+
16855
+ // prevent WASM OOM during concurrency spikes by evicting oldest trees
16856
+ // when the pool exceeds threshold; tree.delete() is idempotent so
16857
+ // callers that still hold a reference can safely call delete() again
16858
+ if (activeTrees.size >= MAX_ACTIVE_TREES) {
16859
+ const treesToEvict = [...activeTrees];
16860
+ activeTrees.clear();
16861
+ for (const oldTree of treesToEvict) {
16862
+ oldTree.delete();
16863
+ }
16864
+ }
16865
+ const tree = parser.parse(source);
16866
+ activeTrees.add(tree);
16867
+
16868
+ // remove from tracking when caller deletes
16869
+ const originalDelete = tree.delete;
16870
+ tree.delete = function deleteAndUntrack() {
16871
+ activeTrees.delete(this);
16872
+ originalDelete.call(this);
16873
+ };
16857
16874
  parser.reset();
16858
- return currentTree;
16875
+ return tree;
16859
16876
  };
16860
16877
 
16861
16878
  class TreeCursorSyntaxNode {
@@ -17509,13 +17526,17 @@
17509
17526
  if (!detectionRegExp$1.test(source)) {
17510
17527
  return false;
17511
17528
  }
17529
+ let cst = null;
17512
17530
  try {
17513
- const cst = await analyze$2(source);
17531
+ cst = await analyze$2(source);
17514
17532
  const isError = cst.rootNode.type !== 'ERROR';
17515
- cst.delete();
17516
17533
  return isError;
17517
17534
  } catch {
17518
17535
  return false;
17536
+ } finally {
17537
+ if (cst !== null) {
17538
+ cst.delete();
17539
+ }
17519
17540
  }
17520
17541
  };
17521
17542
 
@@ -17534,19 +17555,22 @@
17534
17555
  sourceMap = false,
17535
17556
  syntacticAnalysis = 'direct'
17536
17557
  } = {}) => {
17537
- const cst = await analyze$2(source);
17538
- let apiDOM;
17539
- if (syntacticAnalysis === 'indirect') {
17540
- apiDOM = analyze(cst, {
17541
- sourceMap
17542
- });
17543
- } else {
17544
- apiDOM = analyze$1(cst, {
17558
+ let cst = null;
17559
+ try {
17560
+ cst = await analyze$2(source);
17561
+ if (syntacticAnalysis === 'indirect') {
17562
+ return analyze(cst, {
17563
+ sourceMap
17564
+ });
17565
+ }
17566
+ return analyze$1(cst, {
17545
17567
  sourceMap
17546
17568
  });
17569
+ } finally {
17570
+ if (cst !== null) {
17571
+ cst.delete();
17572
+ }
17547
17573
  }
17548
- cst.delete();
17549
- return apiDOM;
17550
17574
  };
17551
17575
 
17552
17576
  /**