@swagger-api/apidom-parser-adapter-openapi-json-3-1 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-openapi-json-3-1
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-openapi-json-3-1
@@ -18479,14 +18479,12 @@
18479
18479
 
18480
18480
  let parser = null;
18481
18481
  let parserInitLock = null;
18482
- let currentTree = null;
18482
+ const activeTrees = new Set();
18483
+ const MAX_ACTIVE_TREES = 5;
18483
18484
 
18484
18485
  /**
18485
18486
  * Lexical Analysis of source string using WebTreeSitter.
18486
18487
  * This is WebAssembly version of TreeSitters Lexical Analysis.
18487
- *
18488
- * Given JavaScript doesn't support true parallelism, this
18489
- * code should be as lazy as possible and temporal safety should be fine.
18490
18488
  * @public
18491
18489
  */
18492
18490
  const analyze$2 = async source => {
@@ -18507,9 +18505,28 @@
18507
18505
  } else if (parser === null) {
18508
18506
  throw new ApiDOMError('Error while initializing web-tree-sitter and loading tree-sitter-json grammar.');
18509
18507
  }
18510
- currentTree = parser.parse(source);
18508
+
18509
+ // prevent WASM OOM during concurrency spikes by evicting oldest trees
18510
+ // when the pool exceeds threshold; tree.delete() is idempotent so
18511
+ // callers that still hold a reference can safely call delete() again
18512
+ if (activeTrees.size >= MAX_ACTIVE_TREES) {
18513
+ const treesToEvict = [...activeTrees];
18514
+ activeTrees.clear();
18515
+ for (const oldTree of treesToEvict) {
18516
+ oldTree.delete();
18517
+ }
18518
+ }
18519
+ const tree = parser.parse(source);
18520
+ activeTrees.add(tree);
18521
+
18522
+ // remove from tracking when caller deletes
18523
+ const originalDelete = tree.delete;
18524
+ tree.delete = function deleteAndUntrack() {
18525
+ activeTrees.delete(this);
18526
+ originalDelete.call(this);
18527
+ };
18511
18528
  parser.reset();
18512
- return currentTree;
18529
+ return tree;
18513
18530
  };
18514
18531
 
18515
18532
  class TreeCursorSyntaxNode {
@@ -19163,13 +19180,17 @@
19163
19180
  if (!detectionRegExp$1.test(source)) {
19164
19181
  return false;
19165
19182
  }
19183
+ let cst = null;
19166
19184
  try {
19167
- const cst = await analyze$2(source);
19185
+ cst = await analyze$2(source);
19168
19186
  const isError = cst.rootNode.type !== 'ERROR';
19169
- cst.delete();
19170
19187
  return isError;
19171
19188
  } catch {
19172
19189
  return false;
19190
+ } finally {
19191
+ if (cst !== null) {
19192
+ cst.delete();
19193
+ }
19173
19194
  }
19174
19195
  };
19175
19196
 
@@ -19188,19 +19209,22 @@
19188
19209
  sourceMap = false,
19189
19210
  syntacticAnalysis = 'direct'
19190
19211
  } = {}) => {
19191
- const cst = await analyze$2(source);
19192
- let apiDOM;
19193
- if (syntacticAnalysis === 'indirect') {
19194
- apiDOM = analyze(cst, {
19195
- sourceMap
19196
- });
19197
- } else {
19198
- apiDOM = analyze$1(cst, {
19212
+ let cst = null;
19213
+ try {
19214
+ cst = await analyze$2(source);
19215
+ if (syntacticAnalysis === 'indirect') {
19216
+ return analyze(cst, {
19217
+ sourceMap
19218
+ });
19219
+ }
19220
+ return analyze$1(cst, {
19199
19221
  sourceMap
19200
19222
  });
19223
+ } finally {
19224
+ if (cst !== null) {
19225
+ cst.delete();
19226
+ }
19201
19227
  }
19202
- cst.delete();
19203
- return apiDOM;
19204
19228
  };
19205
19229
 
19206
19230
  /**