tycho-components 0.25.12 → 0.26.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.
@@ -18,6 +18,8 @@ export default class CytoscapeTreeConverter {
18
18
  private generateTokenId;
19
19
  private generateLeafId;
20
20
  private findParent;
21
+ private findContainingChunks;
22
+ private tightestChunk;
21
23
  private initTree;
22
24
  private sortChunks;
23
25
  private convertToken;
@@ -162,6 +162,11 @@ export default class CytoscapeTreeConverter {
162
162
  for (const token of tokens) {
163
163
  if (token.ec)
164
164
  continue;
165
+ if (token.l !== chunk.l)
166
+ continue;
167
+ const dominator = this.tightestChunk(this.findContainingChunks(struct, chunk.l, token.p, token.p));
168
+ if (!dominator || this.generateChunkId(dominator) !== nodeId)
169
+ continue;
165
170
  tree.edges.push({
166
171
  data: {
167
172
  id: this.uuid(),
@@ -184,8 +189,8 @@ export default class CytoscapeTreeConverter {
184
189
  ];
185
190
  }
186
191
  }
187
- leveledChunks = this.getChunksByLevel(struct, chunk, levelCount);
188
192
  levelCount++;
193
+ leveledChunks = this.getChunksByLevel(struct, chunk, levelCount);
189
194
  }
190
195
  }
191
196
  generateChunkId(chunk) {
@@ -212,18 +217,23 @@ export default class CytoscapeTreeConverter {
212
217
  return `${token.p}`;
213
218
  }
214
219
  findParent(struct, chunk) {
215
- const chunks = this.getChunksByLevel(struct, chunk, 1);
220
+ return this.tightestChunk(this.findContainingChunks(struct, chunk.l - 1, chunk.i, chunk.f));
221
+ }
222
+ findContainingChunks(struct, level, i, f) {
223
+ return struct.chunks.filter((c) => c.l === level && i >= c.i && f <= c.f);
224
+ }
225
+ tightestChunk(chunks) {
216
226
  if (chunks.length === 0)
217
227
  return null;
218
- for (const parent of chunks) {
219
- const tf = chunk.f;
220
- const ti = chunk.i;
221
- const ptf = parent.f;
222
- const pti = parent.i;
223
- if (tf <= ptf && ti >= pti)
224
- return parent;
225
- }
226
- return null;
228
+ return chunks.reduce((best, c) => {
229
+ const span = c.f - c.i;
230
+ const bestSpan = best.f - best.i;
231
+ if (span < bestSpan)
232
+ return c;
233
+ if (span > bestSpan)
234
+ return best;
235
+ return c.i > best.i ? c : best;
236
+ });
227
237
  }
228
238
  initTree(struct) {
229
239
  this.sortChunks(struct);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.25.12",
4
+ "version": "0.26.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -55,8 +55,8 @@
55
55
  "cytoscape-dagre": "^2.5.0",
56
56
  "cytoscape-node-html-label": "^1.2.2",
57
57
  "date-fns": "^4.1.0",
58
- "driver.js": "^1.4.0",
59
58
  "date-fns-tz": "^3.2.0",
59
+ "driver.js": "^1.4.0",
60
60
  "file-saver": "^2.0.5",
61
61
  "html2canvas": "^1.4.1",
62
62
  "js-cookie": "^3.0.5",
@@ -112,6 +112,7 @@
112
112
  "storybook": "^10.1.11",
113
113
  "typescript": "^5.7.3",
114
114
  "vite": "^7.0.0",
115
+ "vitest": "^3.2.6",
115
116
  "wavesurfer-react": "^2.2.2",
116
117
  "wavesurfer.js": "^6.6.3"
117
118
  },
@@ -120,6 +121,7 @@
120
121
  "build-storybook": "storybook build",
121
122
  "build": "tsc && node scripts/copy-package-json.js && npm run copy-css",
122
123
  "build-publish": "tsc && npm run copy-css",
123
- "copy-css": "node scripts/copy-css.js"
124
+ "copy-css": "node scripts/copy-css.js",
125
+ "test": "vitest run"
124
126
  }
125
127
  }