Skip to content

Commit 56788b4

Browse files
committed
fix importing errors by declaring minimal specs
1 parent 5d1596f commit 56788b4

File tree

3 files changed

+35
-27
lines changed

3 files changed

+35
-27
lines changed

src/lib/loadExtensions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { InstructionInfo, ExtensionInfo } from "./types.js";
21
import { extensionDescriptions } from "./hardcodedData.js";
32
import loadInstructions from "./loadInstructions.js";
43

src/lib/loadInstructions.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// generates compact bitfield layouts for visualization using `bit-field`.
44

55

6-
import { YamlDoc, Segment, Field, InstructionInfo } from "./types.js";
76
import render from "bit-field/lib/render.js";
87
import * as yaml from "js-yaml";
98
import * as onml from "onml";
@@ -256,9 +255,14 @@ export default function loadInstructions(): InstructionInfo[] {
256255
let bitfieldSVG = "";
257256
try {
258257
const segments = bitfieldJSON.reg.slice().reverse();
259-
const jsonml = render(segments, { bits: totalBits, vflip: false }); // MSB→LSB order
258+
const jsonml = render(segments, {
259+
bits: totalBits,
260+
vflip: false,
261+
lanes: 1,
262+
hspace: 800,
263+
}); // MSB→LSB order
260264
bitfieldSVG = onml.stringify(jsonml);
261-
} catch (err) { console.warn(`Failed to render SVG for ${name}:`, err); }
265+
} catch (err) { console.warn(`Failed to render SVG for ${doc.name}:`, err); }
262266

263267
instructions.push({
264268
name: doc.name,

src/lib/types.d.ts

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
1-
export interface YamlDoc {
2-
name: string;
3-
long_name?: string;
4-
description?: string;
5-
definedBy?: unknown;
6-
base?: number;
7-
assembly?: string | string[];
8-
encoding?: {
9-
match?: string;
10-
variables?: { name: string; location: string | number }[];
11-
[key: string]: any;
12-
};
13-
}
14-
15-
16-
export interface Segment {
1+
interface Segment {
172
from: number;
183
to: number;
19-
width?: number;
204
}
215

22-
23-
export interface Field {
6+
interface Field {
247
label: string;
258
from: number;
269
to: number;
@@ -29,8 +12,21 @@ export interface Field {
2912
segments?: Segment[];
3013
}
3114

15+
interface YamlDoc {
16+
name: string;
17+
long_name?: string;
18+
description?: string;
19+
definedBy?: unknown;
20+
base?: number;
21+
assembly?: string | string[];
22+
encoding?: {
23+
match?: string;
24+
variables?: { name: string; location: string | number }[];
25+
[key: string]: any;
26+
};
27+
}
3228

33-
export interface InstructionInfo {
29+
interface InstructionInfo {
3430
name: string;
3531
longName: string;
3632
description: string;
@@ -41,7 +37,7 @@ export interface InstructionInfo {
4137
encodingType?: string;
4238
encoding: {
4339
match: string | null;
44-
variables: unknown[];
40+
variables: any[];
4541
fields: Field[];
4642
opcode?: string;
4743
funct3?: string;
@@ -52,11 +48,20 @@ export interface InstructionInfo {
5248
bitfieldSVG: string;
5349
}
5450

55-
56-
export interface ExtensionInfo {
51+
interface ExtensionInfo {
5752
name: string;
5853
slug: string;
5954
description: string | null;
6055
instructions: InstructionInfo[];
6156
count?: number;
6257
}
58+
59+
declare module "bit-field/lib/render.js" {
60+
const render: (segments: any[], options?: any) => any;
61+
export default render;
62+
}
63+
64+
declare module "onml" {
65+
export function stringify(jsonml: any, options?: any): string;
66+
export function parse(xml: string): any;
67+
}

0 commit comments

Comments
 (0)