circuitscript 0.1.17 → 0.1.18

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.
@@ -364,13 +364,12 @@ class ExecutionContext {
364
364
  if (pinId === null) {
365
365
  usePinId = component.getDefaultPin();
366
366
  }
367
+ else if (component.hasPin(pinId)) {
368
+ usePinId = component.getPin(pinId);
369
+ }
367
370
  else {
368
- if (component.hasPin(pinId)) {
369
- usePinId = component.getPin(pinId);
370
- }
371
- else {
372
- throw 'Invalid pin number ' + pinId + ' in ' + component;
373
- }
371
+ throw new utils_js_1.RuntimeExecutionError('Invalid pin number '
372
+ + pinId + ' in ' + component);
374
373
  }
375
374
  this.scope.setCurrent(component, usePinId);
376
375
  if (!this.scope.hasNet(component, pinId)) {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SExpObject = exports._id = exports.IdObject = exports.printTree = exports.generateKiCADNetList = void 0;
3
+ exports.SExpObject = exports._id = exports.IdObject = exports.printTree = exports.generateKiCadNetList = void 0;
4
4
  const globals_js_1 = require("./globals.js");
5
5
  const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
6
- function generateKiCADNetList(netlist) {
6
+ function generateKiCadNetList(netlist) {
7
7
  const componentsList = [];
8
8
  const nets = {};
9
9
  const missingFootprints = [];
@@ -81,7 +81,7 @@ function generateKiCADNetList(netlist) {
81
81
  missingFootprints
82
82
  };
83
83
  }
84
- exports.generateKiCADNetList = generateKiCADNetList;
84
+ exports.generateKiCadNetList = generateKiCadNetList;
85
85
  function printTree(tree, level = 0) {
86
86
  const output = [];
87
87
  if (!Array.isArray(tree)) {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPaperSize = exports.isSupportedPaperSize = exports.PaperGridReferences = exports.pxToMM = exports.milsToMM = exports.UnitDimension = exports.detectJSModuleType = exports.renderScript = exports.validateScript = exports.ParseErrorStrategy = exports.getSemanticTokens = exports.prepareFile = exports.JSModuleType = void 0;
6
+ exports.getPaperSize = exports.isSupportedPaperSize = exports.PaperGridReferences = exports.pxToMM = exports.milsToMM = exports.UnitDimension = exports.detectJSModuleType = exports.KiCadNetListOutputHandler = exports.ParseOutputHandler = exports.renderScriptCustom = exports.renderScript = exports.validateScript = exports.ParseErrorStrategy = exports.getSemanticTokens = exports.prepareFile = exports.JSModuleType = void 0;
7
7
  const fs_1 = require("fs");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const pdfkit_1 = __importDefault(require("pdfkit"));
@@ -158,6 +158,13 @@ async function validateScript(filePath, scriptData, options) {
158
158
  }
159
159
  exports.validateScript = validateScript;
160
160
  async function renderScript(scriptData, outputPath, options) {
161
+ const parseHandlers = [
162
+ new KiCadNetListOutputHandler(),
163
+ ];
164
+ return renderScriptCustom(scriptData, outputPath, options, parseHandlers);
165
+ }
166
+ exports.renderScript = renderScript;
167
+ async function renderScriptCustom(scriptData, outputPath, options, parseHandlers) {
161
168
  const { dumpNets = false, dumpData = false, showStats = false, environment } = options;
162
169
  const errors = [];
163
170
  const onErrorHandler = (message, context, error) => {
@@ -206,6 +213,12 @@ async function renderScript(scriptData, outputPath, options) {
206
213
  (0, utils_js_1.printWarnings)(visitor.getWarnings());
207
214
  showStats && console.log('Lexing took:', lexerTimeTaken);
208
215
  showStats && console.log('Parsing took:', parserTimeTaken);
216
+ try {
217
+ visitor.annotateComponents();
218
+ }
219
+ catch (err) {
220
+ throw new utils_js_1.RenderError(`Error during component annotation: ${err}`, 'annotation');
221
+ }
209
222
  if (dumpNets) {
210
223
  const nets = visitor.dumpNets();
211
224
  nets.forEach(item => console.log(item.join(" | ")));
@@ -218,12 +231,6 @@ async function renderScript(scriptData, outputPath, options) {
218
231
  let svgOutput = "";
219
232
  if (errors.length === 0) {
220
233
  const { frameComponent } = visitor.applySheetFrameComponent();
221
- try {
222
- visitor.annotateComponents();
223
- }
224
- catch (err) {
225
- throw new utils_js_1.RenderError(`Error during component annotation: ${err}`, 'annotation');
226
- }
227
234
  const { sequence, nets } = visitor.getGraph();
228
235
  const tmpSequence = (0, utils_js_1.generateDebugSequenceAction)(sequence).map(item => (0, utils_js_1.sequenceActionString)(item));
229
236
  dumpData && (0, fs_1.writeFileSync)(dumpDirectory + 'raw-sequence.txt', tmpSequence.join('\n'));
@@ -232,21 +239,18 @@ async function renderScript(scriptData, outputPath, options) {
232
239
  let outputDefaultZoom = globals_js_1.defaultZoomScale;
233
240
  if (outputPath) {
234
241
  fileExtension = path_1.default.extname(outputPath).substring(1);
235
- if (fileExtension === "pdf") {
236
- outputDefaultZoom = 1;
237
- }
238
242
  }
239
- if (fileExtension === 'net') {
240
- const { tree: kicadNetList, missingFootprints } = (0, export_js_1.generateKiCADNetList)(visitor.getNetList());
241
- missingFootprints.forEach(entry => {
242
- console.log(`${entry.refdes} (${entry.instanceName}) does not have footprint`);
243
- });
244
- (0, fs_1.writeFileSync)(outputPath, (0, export_js_1.printTree)(kicadNetList));
245
- console.log('Generated file', outputPath);
246
- return {
247
- svgOutput: null,
248
- errors,
249
- };
243
+ for (let i = 0; i < parseHandlers.length; i++) {
244
+ const handler = parseHandlers[i];
245
+ if (handler.beforeRender) {
246
+ const keepParsing = handler.parse(visitor, outputPath, fileExtension);
247
+ if (!keepParsing) {
248
+ return {
249
+ svgOutput: null,
250
+ errors
251
+ };
252
+ }
253
+ }
250
254
  }
251
255
  const logger = new logger_js_1.Logger();
252
256
  const graphEngine = new graph_js_1.NetGraph(logger);
@@ -275,6 +279,9 @@ async function renderScript(scriptData, outputPath, options) {
275
279
  showStats && console.log('Render took:', generateSvgTimer.lap());
276
280
  dumpData && (0, fs_1.writeFileSync)(dumpDirectory + 'raw-render.txt', renderLogger.dump());
277
281
  try {
282
+ if (fileExtension === "pdf") {
283
+ outputDefaultZoom = 1;
284
+ }
278
285
  svgOutput = (0, render_js_1.generateSvgOutput)(svgCanvas, outputDefaultZoom);
279
286
  }
280
287
  catch (err) {
@@ -325,7 +332,33 @@ async function renderScript(scriptData, outputPath, options) {
325
332
  errors
326
333
  };
327
334
  }
328
- exports.renderScript = renderScript;
335
+ exports.renderScriptCustom = renderScriptCustom;
336
+ class ParseOutputHandler {
337
+ constructor() {
338
+ this.beforeRender = false;
339
+ this.afterRender = false;
340
+ }
341
+ }
342
+ exports.ParseOutputHandler = ParseOutputHandler;
343
+ class KiCadNetListOutputHandler extends ParseOutputHandler {
344
+ constructor() {
345
+ super(...arguments);
346
+ this.beforeRender = true;
347
+ }
348
+ parse(visitor, outputPath, fileExtension) {
349
+ if (outputPath !== null && fileExtension === "net") {
350
+ const { tree: kiCadNetList, missingFootprints } = (0, export_js_1.generateKiCadNetList)(visitor.getNetList());
351
+ missingFootprints.forEach(entry => {
352
+ console.log(`${entry.refdes} (${entry.instanceName}) does not have footprint`);
353
+ });
354
+ (0, fs_1.writeFileSync)(outputPath, (0, export_js_1.printTree)(kiCadNetList));
355
+ console.log('Generated file', outputPath);
356
+ return false;
357
+ }
358
+ return true;
359
+ }
360
+ }
361
+ exports.KiCadNetListOutputHandler = KiCadNetListOutputHandler;
329
362
  function detectJSModuleType() {
330
363
  if (typeof __filename === 'undefined' &&
331
364
  typeof __dirname === 'undefined') {
@@ -87,8 +87,8 @@ class ExecutionScope {
87
87
  const sortedNet = [...this.nets].sort((a, b) => {
88
88
  const netA = a[2];
89
89
  const netB = b[2];
90
- const netAId = netA.namespace + netA.name;
91
- const netBId = netB.namespace + b[2].name;
90
+ const netAId = netA.toString();
91
+ const netBId = netB.toString();
92
92
  if (netAId > netBId) {
93
93
  return 1;
94
94
  }
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Net = void 0;
4
+ const types_js_1 = require("./types.js");
4
5
  class Net {
5
- constructor(namespace, name, priority = 0, type = 'any') {
6
+ constructor(namespace, name, priority = 0, type = types_js_1.NetTypes.Any) {
6
7
  this.params = new Map();
7
8
  if (namespace.indexOf(' ') !== -1) {
8
9
  throw "Invalid net namespace provided";
@@ -112,6 +112,7 @@ var TypeProps;
112
112
  TypeProps["Net"] = "net";
113
113
  TypeProps["Port"] = "port";
114
114
  TypeProps["Graphic"] = "graphic";
115
+ TypeProps["Module"] = "module";
115
116
  TypeProps["Resistor"] = "res";
116
117
  TypeProps["Capacitor"] = "cap";
117
118
  TypeProps["Inductor"] = "ind";
@@ -1380,8 +1380,28 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
1380
1380
  this.log('Failed to annotate:', instance.instanceName);
1381
1381
  }
1382
1382
  });
1383
- this.log('===== annotate done =====');
1384
- this.log('');
1383
+ this.log('===== annotate components done =====');
1384
+ this.log('===== rename nets =====');
1385
+ this.renameNetsWithRefdes();
1386
+ this.log('===== rename nets done =====');
1387
+ }
1388
+ renameNetsWithRefdes() {
1389
+ const nets = this.getScope().getNets();
1390
+ const seenNets = [];
1391
+ const uniqueNets = new Set(nets.map(([, , net]) => net));
1392
+ const fullNetNames = Array.from(uniqueNets).map(item => item.toString());
1393
+ nets.forEach(([component, pin, net]) => {
1394
+ if (net.priority === 0 && seenNets.indexOf(net) === -1
1395
+ && component.typeProp !== types_js_1.TypeProps.Module
1396
+ && component.typeProp !== types_js_1.TypeProps.Net) {
1397
+ net.name = net.baseName =
1398
+ `NET-(${component.assignedRefDes}-${pin.toString()})`;
1399
+ if (fullNetNames.indexOf(net.toString()) !== -1) {
1400
+ throw new utils_js_2.RuntimeExecutionError('Net renaming failed due to clash: ' + net);
1401
+ }
1402
+ seenNets.push(net);
1403
+ }
1404
+ });
1385
1405
  }
1386
1406
  applySheetFrameComponent() {
1387
1407
  const baseScope = this.getScope();
@@ -369,13 +369,12 @@ export class ExecutionContext {
369
369
  if (pinId === null) {
370
370
  usePinId = component.getDefaultPin();
371
371
  }
372
+ else if (component.hasPin(pinId)) {
373
+ usePinId = component.getPin(pinId);
374
+ }
372
375
  else {
373
- if (component.hasPin(pinId)) {
374
- usePinId = component.getPin(pinId);
375
- }
376
- else {
377
- throw 'Invalid pin number ' + pinId + ' in ' + component;
378
- }
376
+ throw new RuntimeExecutionError('Invalid pin number '
377
+ + pinId + ' in ' + component);
379
378
  }
380
379
  this.scope.setCurrent(component, usePinId);
381
380
  if (!this.scope.hasNet(component, pinId)) {
@@ -1,6 +1,6 @@
1
1
  import { NoNetText } from "./globals.js";
2
2
  import { NumericValue } from "./objects/ParamDefinition.js";
3
- export function generateKiCADNetList(netlist) {
3
+ export function generateKiCadNetList(netlist) {
4
4
  const componentsList = [];
5
5
  const nets = {};
6
6
  const missingFootprints = [];
@@ -1,7 +1,7 @@
1
1
  import { writeFileSync, createWriteStream, existsSync, mkdirSync } from "fs";
2
2
  import path from "path";
3
3
  import PDFDocument from "pdfkit";
4
- import { generateKiCADNetList, printTree } from "./export.js";
4
+ import { generateKiCadNetList, printTree } from "./export.js";
5
5
  import { LayoutEngine } from "./layout.js";
6
6
  import { parseFileWithVisitor } from "./parser.js";
7
7
  import { generatePdfOutput, generateSvgOutput, renderSheetsToSVG } from "./render.js";
@@ -148,6 +148,12 @@ export async function validateScript(filePath, scriptData, options) {
148
148
  return visitorResolver;
149
149
  }
150
150
  export async function renderScript(scriptData, outputPath, options) {
151
+ const parseHandlers = [
152
+ new KiCadNetListOutputHandler(),
153
+ ];
154
+ return renderScriptCustom(scriptData, outputPath, options, parseHandlers);
155
+ }
156
+ export async function renderScriptCustom(scriptData, outputPath, options, parseHandlers) {
151
157
  const { dumpNets = false, dumpData = false, showStats = false, environment } = options;
152
158
  const errors = [];
153
159
  const onErrorHandler = (message, context, error) => {
@@ -196,6 +202,12 @@ export async function renderScript(scriptData, outputPath, options) {
196
202
  printWarnings(visitor.getWarnings());
197
203
  showStats && console.log('Lexing took:', lexerTimeTaken);
198
204
  showStats && console.log('Parsing took:', parserTimeTaken);
205
+ try {
206
+ visitor.annotateComponents();
207
+ }
208
+ catch (err) {
209
+ throw new RenderError(`Error during component annotation: ${err}`, 'annotation');
210
+ }
199
211
  if (dumpNets) {
200
212
  const nets = visitor.dumpNets();
201
213
  nets.forEach(item => console.log(item.join(" | ")));
@@ -208,12 +220,6 @@ export async function renderScript(scriptData, outputPath, options) {
208
220
  let svgOutput = "";
209
221
  if (errors.length === 0) {
210
222
  const { frameComponent } = visitor.applySheetFrameComponent();
211
- try {
212
- visitor.annotateComponents();
213
- }
214
- catch (err) {
215
- throw new RenderError(`Error during component annotation: ${err}`, 'annotation');
216
- }
217
223
  const { sequence, nets } = visitor.getGraph();
218
224
  const tmpSequence = generateDebugSequenceAction(sequence).map(item => sequenceActionString(item));
219
225
  dumpData && writeFileSync(dumpDirectory + 'raw-sequence.txt', tmpSequence.join('\n'));
@@ -222,21 +228,18 @@ export async function renderScript(scriptData, outputPath, options) {
222
228
  let outputDefaultZoom = defaultZoomScale;
223
229
  if (outputPath) {
224
230
  fileExtension = path.extname(outputPath).substring(1);
225
- if (fileExtension === "pdf") {
226
- outputDefaultZoom = 1;
227
- }
228
231
  }
229
- if (fileExtension === 'net') {
230
- const { tree: kicadNetList, missingFootprints } = generateKiCADNetList(visitor.getNetList());
231
- missingFootprints.forEach(entry => {
232
- console.log(`${entry.refdes} (${entry.instanceName}) does not have footprint`);
233
- });
234
- writeFileSync(outputPath, printTree(kicadNetList));
235
- console.log('Generated file', outputPath);
236
- return {
237
- svgOutput: null,
238
- errors,
239
- };
232
+ for (let i = 0; i < parseHandlers.length; i++) {
233
+ const handler = parseHandlers[i];
234
+ if (handler.beforeRender) {
235
+ const keepParsing = handler.parse(visitor, outputPath, fileExtension);
236
+ if (!keepParsing) {
237
+ return {
238
+ svgOutput: null,
239
+ errors
240
+ };
241
+ }
242
+ }
240
243
  }
241
244
  const logger = new Logger();
242
245
  const graphEngine = new NetGraph(logger);
@@ -265,6 +268,9 @@ export async function renderScript(scriptData, outputPath, options) {
265
268
  showStats && console.log('Render took:', generateSvgTimer.lap());
266
269
  dumpData && writeFileSync(dumpDirectory + 'raw-render.txt', renderLogger.dump());
267
270
  try {
271
+ if (fileExtension === "pdf") {
272
+ outputDefaultZoom = 1;
273
+ }
268
274
  svgOutput = generateSvgOutput(svgCanvas, outputDefaultZoom);
269
275
  }
270
276
  catch (err) {
@@ -315,6 +321,25 @@ export async function renderScript(scriptData, outputPath, options) {
315
321
  errors
316
322
  };
317
323
  }
324
+ export class ParseOutputHandler {
325
+ beforeRender = false;
326
+ afterRender = false;
327
+ }
328
+ export class KiCadNetListOutputHandler extends ParseOutputHandler {
329
+ beforeRender = true;
330
+ parse(visitor, outputPath, fileExtension) {
331
+ if (outputPath !== null && fileExtension === "net") {
332
+ const { tree: kiCadNetList, missingFootprints } = generateKiCadNetList(visitor.getNetList());
333
+ missingFootprints.forEach(entry => {
334
+ console.log(`${entry.refdes} (${entry.instanceName}) does not have footprint`);
335
+ });
336
+ writeFileSync(outputPath, printTree(kiCadNetList));
337
+ console.log('Generated file', outputPath);
338
+ return false;
339
+ }
340
+ return true;
341
+ }
342
+ }
318
343
  export function detectJSModuleType() {
319
344
  if (typeof __filename === 'undefined' &&
320
345
  typeof __dirname === 'undefined') {
@@ -86,8 +86,8 @@ export class ExecutionScope {
86
86
  const sortedNet = [...this.nets].sort((a, b) => {
87
87
  const netA = a[2];
88
88
  const netB = b[2];
89
- const netAId = netA.namespace + netA.name;
90
- const netBId = netB.namespace + b[2].name;
89
+ const netAId = netA.toString();
90
+ const netBId = netB.toString();
91
91
  if (netAId > netBId) {
92
92
  return 1;
93
93
  }
@@ -1,3 +1,4 @@
1
+ import { NetTypes } from "./types.js";
1
2
  export class Net {
2
3
  name;
3
4
  baseName;
@@ -5,7 +6,7 @@ export class Net {
5
6
  priority;
6
7
  type;
7
8
  params = new Map();
8
- constructor(namespace, name, priority = 0, type = 'any') {
9
+ constructor(namespace, name, priority = 0, type = NetTypes.Any) {
9
10
  if (namespace.indexOf(' ') !== -1) {
10
11
  throw "Invalid net namespace provided";
11
12
  }
@@ -111,6 +111,7 @@ export var TypeProps;
111
111
  TypeProps["Net"] = "net";
112
112
  TypeProps["Port"] = "port";
113
113
  TypeProps["Graphic"] = "graphic";
114
+ TypeProps["Module"] = "module";
114
115
  TypeProps["Resistor"] = "res";
115
116
  TypeProps["Capacitor"] = "cap";
116
117
  TypeProps["Inductor"] = "ind";
@@ -1374,8 +1374,28 @@ export class ParserVisitor extends BaseVisitor {
1374
1374
  this.log('Failed to annotate:', instance.instanceName);
1375
1375
  }
1376
1376
  });
1377
- this.log('===== annotate done =====');
1378
- this.log('');
1377
+ this.log('===== annotate components done =====');
1378
+ this.log('===== rename nets =====');
1379
+ this.renameNetsWithRefdes();
1380
+ this.log('===== rename nets done =====');
1381
+ }
1382
+ renameNetsWithRefdes() {
1383
+ const nets = this.getScope().getNets();
1384
+ const seenNets = [];
1385
+ const uniqueNets = new Set(nets.map(([, , net]) => net));
1386
+ const fullNetNames = Array.from(uniqueNets).map(item => item.toString());
1387
+ nets.forEach(([component, pin, net]) => {
1388
+ if (net.priority === 0 && seenNets.indexOf(net) === -1
1389
+ && component.typeProp !== TypeProps.Module
1390
+ && component.typeProp !== TypeProps.Net) {
1391
+ net.name = net.baseName =
1392
+ `NET-(${component.assignedRefDes}-${pin.toString()})`;
1393
+ if (fullNetNames.indexOf(net.toString()) !== -1) {
1394
+ throw new RuntimeExecutionError('Net renaming failed due to clash: ' + net);
1395
+ }
1396
+ seenNets.push(net);
1397
+ }
1398
+ });
1379
1399
  }
1380
1400
  applySheetFrameComponent() {
1381
1401
  const baseScope = this.getScope();
@@ -1,12 +1,12 @@
1
1
  import { NetListItem } from "./visitor.js";
2
- export declare function generateKiCADNetList(netlist: NetListItem[]): {
2
+ export declare function generateKiCadNetList(netlist: NetListItem[]): {
3
3
  tree: SExp;
4
4
  missingFootprints: {
5
5
  refdes: string;
6
6
  instanceName: string;
7
7
  }[];
8
8
  };
9
- export declare function printTree(tree: (IdObject | string)[] | string, level?: number): string;
9
+ export declare function printTree(tree: any, level?: number): string;
10
10
  export declare class IdObject {
11
11
  keyName: string;
12
12
  constructor(keyName: string);
@@ -1,4 +1,5 @@
1
1
  import { BaseError } from "./utils.js";
2
+ import { ParserVisitor } from "./visitor.js";
2
3
  import { SymbolValidatorVisitor } from "./validate/SymbolValidatorVisitor.js";
3
4
  import { CommonTokenStream, DefaultErrorStrategy, Parser } from "antlr4ng";
4
5
  import { CircuitScriptParser } from "./antlr/CircuitScriptParser.js";
@@ -32,10 +33,21 @@ export declare class ParseErrorStrategy extends DefaultErrorStrategy {
32
33
  reportUnwantedToken(recognizer: Parser): void;
33
34
  }
34
35
  export declare function validateScript(filePath: string, scriptData: string, options: ScriptOptions): Promise<SymbolValidatorVisitor>;
35
- export declare function renderScript(scriptData: string, outputPath: string | null, options: ScriptOptions): Promise<{
36
+ type RenderScriptReturn = {
36
37
  svgOutput: string | null;
37
38
  errors: BaseError[];
38
- }>;
39
+ };
40
+ export declare function renderScript(scriptData: string, outputPath: string | null, options: ScriptOptions): Promise<RenderScriptReturn>;
41
+ export declare function renderScriptCustom(scriptData: string, outputPath: string | null, options: ScriptOptions, parseHandlers: ParseOutputHandler[]): Promise<RenderScriptReturn>;
42
+ export declare abstract class ParseOutputHandler {
43
+ beforeRender: boolean;
44
+ afterRender: boolean;
45
+ abstract parse(visitor: ParserVisitor, outputPath: string | null, fileExtension: string | null): boolean;
46
+ }
47
+ export declare class KiCadNetListOutputHandler extends ParseOutputHandler {
48
+ beforeRender: boolean;
49
+ parse(visitor: ParserVisitor, outputPath: string | null, fileExtension: string | null): boolean;
50
+ }
39
51
  export declare function detectJSModuleType(): JSModuleType;
40
52
  export declare class UnitDimension {
41
53
  type: LengthUnit;
@@ -60,3 +72,4 @@ export declare function getPaperSize(type: string, margin?: number): {
60
72
  originalWidthMM: number;
61
73
  originalHeightMM: number;
62
74
  };
75
+ export {};
@@ -28,7 +28,7 @@ export declare class ExecutionScope {
28
28
  netCounter: number;
29
29
  unnamedCounter: number;
30
30
  currentComponent: ClassComponent | null;
31
- currentPin: number | null;
31
+ currentPin: PinId | null;
32
32
  currentWireId: number;
33
33
  currentFrameId: number;
34
34
  componentRoot: ClassComponent | null;
@@ -50,7 +50,7 @@ export declare class ExecutionScope {
50
50
  setVariable(name: string, value: any): void;
51
51
  setActive(type: ActiveObject, item: any): void;
52
52
  clearActive(): void;
53
- setCurrent(component: ClassComponent | null, pin?: number | null): void;
53
+ setCurrent(component: ClassComponent | null, pin?: PinId | null): void;
54
54
  enterContext(context: ParserRuleContext): void;
55
55
  exitContext(): ParserRuleContext;
56
56
  private findPropertyKeyTree;
@@ -1,11 +1,12 @@
1
+ import { NetTypes } from "./types.js";
1
2
  export declare class Net {
2
3
  name: string;
3
4
  baseName: string;
4
5
  namespace: string;
5
6
  priority: number;
6
- type: string;
7
+ type: NetTypes;
7
8
  params: Map<string, any>;
8
- constructor(namespace: string, name: string, priority?: number, type?: string);
9
+ constructor(namespace: string, name: string, priority?: number, type?: NetTypes);
9
10
  toString(): string;
10
11
  static isSame(netA: Net, netB: Net): boolean;
11
12
  }
@@ -38,7 +38,7 @@ export type ComponentPinWireId = [
38
38
  ];
39
39
  export type ComponentPin = [
40
40
  component: ClassComponent,
41
- pinId: number | string
41
+ pinId: PinId
42
42
  ];
43
43
  export type ComplexType = ValueType | ClassComponent | UndeclaredReference | null;
44
44
  export type ValueType = boolean | number | string | NumericValue | PercentageValue;
@@ -100,6 +100,7 @@ export declare enum TypeProps {
100
100
  Net = "net",
101
101
  Port = "port",
102
102
  Graphic = "graphic",
103
+ Module = "module",
103
104
  Resistor = "res",
104
105
  Capacitor = "cap",
105
106
  Inductor = "ind",
@@ -80,6 +80,7 @@ export declare class ParserVisitor extends BaseVisitor {
80
80
  nets: ComponentPinNetPair[];
81
81
  };
82
82
  annotateComponents(): void;
83
+ private renameNetsWithRefdes;
83
84
  applySheetFrameComponent(): {
84
85
  frameComponent: ClassComponent | null;
85
86
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "circuitscript",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Interpreter for the circuitscript language",
5
5
  "homepage": "https://circuitscript.net",
6
6
  "engines": {