circuitscript 0.0.34 → 0.0.36
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/dist/cjs/BaseVisitor.js +2 -62
- package/dist/cjs/antlr/CircuitScriptParser.js +110 -85
- package/dist/cjs/builtinMethods.js +96 -0
- package/dist/cjs/layout.js +2 -2
- package/dist/cjs/objects/Frame.js +1 -1
- package/dist/cjs/render.js +3 -3
- package/dist/cjs/visitor.js +11 -5
- package/dist/esm/BaseVisitor.mjs +2 -62
- package/dist/esm/antlr/CircuitScriptParser.mjs +110 -85
- package/dist/esm/builtinMethods.mjs +92 -0
- package/dist/esm/layout.mjs +2 -2
- package/dist/esm/objects/Frame.mjs +1 -1
- package/dist/esm/render.mjs +3 -3
- package/dist/esm/visitor.mjs +11 -5
- package/dist/types/BaseVisitor.d.ts +0 -1
- package/dist/types/antlr/CircuitScriptParser.d.ts +2 -1
- package/dist/types/builtinMethods.d.ts +3 -0
- package/dist/types/objects/Frame.d.ts +1 -1
- package/libs/lib.cst +81 -228
- package/package.json +8 -2
package/libs/lib.cst
CHANGED
|
@@ -221,45 +221,9 @@ def arrow_point():
|
|
|
221
221
|
path: ("M", -5, 0, "L", -20, 0)
|
|
222
222
|
hpin: 1, 0, 0, 0, display_pin_id=false
|
|
223
223
|
|
|
224
|
-
def
|
|
225
|
-
inner_frame_margin = 50
|
|
226
|
-
|
|
227
|
-
type: "frame"
|
|
228
|
-
display: create graphic:
|
|
229
|
-
fill: "none"
|
|
230
|
-
|
|
231
|
-
# outer rect
|
|
232
|
-
lineColor: "#cccccc"
|
|
233
|
-
rect: paper_width/2, paper_height/2, paper_width, paper_height
|
|
234
|
-
|
|
235
|
-
# inner rect
|
|
236
|
-
lineColor: "#111111"
|
|
237
|
-
rect: paper_width/2, paper_height/2, paper_width - 2 * margin_x, paper_height - 2 * margin_y
|
|
238
|
-
|
|
239
|
-
rect: (paper_width/2, paper_height/2,
|
|
240
|
-
paper_width - 2 * margin_x + inner_frame_margin * 2,
|
|
241
|
-
paper_height - 2 * margin_y + inner_frame_margin * 2)
|
|
242
|
-
|
|
243
|
-
params:
|
|
244
|
-
paper_size: paper_size_name
|
|
245
|
-
paper_width: paper_width
|
|
246
|
-
paper_height: paper_height
|
|
247
|
-
|
|
248
|
-
offset_x: margin_x
|
|
249
|
-
offset_y: margin_y
|
|
250
|
-
|
|
251
|
-
grid_width: paper_width - 2 * margin_x
|
|
252
|
-
grid_height: paper_height - 2 * margin_y
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
def frame_A4 ():
|
|
256
|
-
paper_width = 297 / 25.4 * 1000
|
|
257
|
-
paper_height = 210 / 25.4 * 1000
|
|
258
|
-
margin_x = 400
|
|
259
|
-
margin_y = 400
|
|
260
|
-
|
|
261
|
-
inner_frame_margin = 50
|
|
262
|
-
|
|
224
|
+
def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin_y,
|
|
225
|
+
col_display_value, row_display_value, inner_frame_margin = 50):
|
|
226
|
+
|
|
263
227
|
horizontal_1 = margin_x - inner_frame_margin
|
|
264
228
|
horizontal_2 = paper_width - margin_x + inner_frame_margin
|
|
265
229
|
|
|
@@ -274,8 +238,11 @@ def frame_A4 ():
|
|
|
274
238
|
|
|
275
239
|
fontSize = 30
|
|
276
240
|
|
|
277
|
-
|
|
278
|
-
|
|
241
|
+
num_columns = len(col_display_value)
|
|
242
|
+
num_rows = len(row_display_value)
|
|
243
|
+
|
|
244
|
+
ratio_x = 1 / num_columns
|
|
245
|
+
ratio_y = 1 / num_rows
|
|
279
246
|
|
|
280
247
|
return create component:
|
|
281
248
|
type: "frame"
|
|
@@ -294,170 +261,47 @@ def frame_A4 ():
|
|
|
294
261
|
paper_width - 2 * margin_x + inner_frame_margin * 2,
|
|
295
262
|
paper_height - 2 * margin_y + inner_frame_margin * 2)
|
|
296
263
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
hline: horizontal_2, (tmp_y + tmp_height * ratio_y), -inner_frame_margin
|
|
302
|
-
hline: horizontal_2, (tmp_y + tmp_height * ratio_y * 2), -inner_frame_margin
|
|
303
|
-
hline: horizontal_2, (tmp_y + tmp_height * ratio_y * 3), -inner_frame_margin
|
|
304
|
-
|
|
305
|
-
vline: (tmp_x + tmp_width * ratio_x), vertical_1, inner_frame_margin
|
|
306
|
-
vline: (tmp_x + tmp_width * ratio_x * 2), vertical_1, inner_frame_margin
|
|
307
|
-
vline: (tmp_x + tmp_width * ratio_x * 3), vertical_1, inner_frame_margin
|
|
308
|
-
vline: (tmp_x + tmp_width * ratio_x * 4), vertical_1, inner_frame_margin
|
|
309
|
-
vline: (tmp_x + tmp_width * ratio_x * 5), vertical_1, inner_frame_margin
|
|
264
|
+
for i in range(1, num_rows):
|
|
265
|
+
hline: horizontal_1, (tmp_y + tmp_height * ratio_y * i), inner_frame_margin
|
|
266
|
+
hline: horizontal_2, (tmp_y + tmp_height * ratio_y * i), -inner_frame_margin
|
|
310
267
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
vline: (tmp_x + tmp_width * ratio_x * 4), vertical_2, -inner_frame_margin
|
|
315
|
-
vline: (tmp_x + tmp_width * ratio_x * 5), vertical_2, -inner_frame_margin
|
|
268
|
+
for i in range(1, num_columns):
|
|
269
|
+
vline: (tmp_x + tmp_width * ratio_x * i), vertical_1, inner_frame_margin
|
|
270
|
+
vline: (tmp_x + tmp_width * ratio_x * i), vertical_2, -inner_frame_margin
|
|
316
271
|
|
|
317
272
|
# labels on the columns
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
content: "3"
|
|
348
|
-
offset: tmp_x + tmp_width * ratio_x * 2.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
349
|
-
fontSize: fontSize
|
|
350
|
-
anchor: "middle"
|
|
351
|
-
vanchor: "middle"
|
|
352
|
-
|
|
353
|
-
text:
|
|
354
|
-
content: "3"
|
|
355
|
-
offset: tmp_x + tmp_width * ratio_x * 2.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
356
|
-
fontSize: fontSize
|
|
357
|
-
anchor: "middle"
|
|
358
|
-
vanchor: "middle"
|
|
359
|
-
|
|
360
|
-
text:
|
|
361
|
-
content: "4"
|
|
362
|
-
offset: tmp_x + tmp_width * ratio_x * 3.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
363
|
-
fontSize: fontSize
|
|
364
|
-
anchor: "middle"
|
|
365
|
-
vanchor: "middle"
|
|
366
|
-
|
|
367
|
-
text:
|
|
368
|
-
content: "4"
|
|
369
|
-
offset: tmp_x + tmp_width * ratio_x * 3.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
370
|
-
fontSize: fontSize
|
|
371
|
-
anchor: "middle"
|
|
372
|
-
vanchor: "middle"
|
|
373
|
-
|
|
374
|
-
text:
|
|
375
|
-
content: "5"
|
|
376
|
-
offset: tmp_x + tmp_width * ratio_x * 4.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
377
|
-
fontSize: fontSize
|
|
378
|
-
anchor: "middle"
|
|
379
|
-
vanchor: "middle"
|
|
380
|
-
|
|
381
|
-
text:
|
|
382
|
-
content: "5"
|
|
383
|
-
offset: tmp_x + tmp_width * ratio_x * 4.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
384
|
-
fontSize: fontSize
|
|
385
|
-
anchor: "middle"
|
|
386
|
-
vanchor: "middle"
|
|
387
|
-
|
|
388
|
-
text:
|
|
389
|
-
content: "6"
|
|
390
|
-
offset: tmp_x + tmp_width * ratio_x * 5.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
391
|
-
fontSize: fontSize
|
|
392
|
-
anchor: "middle"
|
|
393
|
-
vanchor: "middle"
|
|
394
|
-
|
|
395
|
-
text:
|
|
396
|
-
content: "6"
|
|
397
|
-
offset: tmp_x + tmp_width * ratio_x * 5.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
398
|
-
fontSize: fontSize
|
|
399
|
-
anchor: "middle"
|
|
400
|
-
vanchor: "middle"
|
|
401
|
-
|
|
402
|
-
# labels on the rows
|
|
403
|
-
text:
|
|
404
|
-
content: "A"
|
|
405
|
-
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 0.5
|
|
406
|
-
fontSize: fontSize
|
|
407
|
-
anchor: "middle"
|
|
408
|
-
vanchor: "middle"
|
|
409
|
-
|
|
410
|
-
text:
|
|
411
|
-
content: "A"
|
|
412
|
-
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 0.5
|
|
413
|
-
fontSize: fontSize
|
|
414
|
-
anchor: "middle"
|
|
415
|
-
vanchor: "middle"
|
|
416
|
-
|
|
417
|
-
text:
|
|
418
|
-
content: "B"
|
|
419
|
-
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 1.5
|
|
420
|
-
fontSize: fontSize
|
|
421
|
-
anchor: "middle"
|
|
422
|
-
vanchor: "middle"
|
|
423
|
-
|
|
424
|
-
text:
|
|
425
|
-
content: "B"
|
|
426
|
-
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 1.5
|
|
427
|
-
fontSize: fontSize
|
|
428
|
-
anchor: "middle"
|
|
429
|
-
vanchor: "middle"
|
|
430
|
-
|
|
431
|
-
text:
|
|
432
|
-
content: "C"
|
|
433
|
-
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 2.5
|
|
434
|
-
fontSize: fontSize
|
|
435
|
-
anchor: "middle"
|
|
436
|
-
vanchor: "middle"
|
|
437
|
-
|
|
438
|
-
text:
|
|
439
|
-
content: "C"
|
|
440
|
-
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 2.5
|
|
441
|
-
fontSize: fontSize
|
|
442
|
-
anchor: "middle"
|
|
443
|
-
vanchor: "middle"
|
|
444
|
-
|
|
445
|
-
text:
|
|
446
|
-
content: "D"
|
|
447
|
-
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 3.5
|
|
448
|
-
fontSize: fontSize
|
|
449
|
-
anchor: "middle"
|
|
450
|
-
vanchor: "middle"
|
|
451
|
-
|
|
452
|
-
text:
|
|
453
|
-
content: "D"
|
|
454
|
-
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 3.5
|
|
455
|
-
fontSize: fontSize
|
|
456
|
-
anchor: "middle"
|
|
457
|
-
vanchor: "middle"
|
|
273
|
+
for i in col_display_value:
|
|
274
|
+
text:
|
|
275
|
+
content: i
|
|
276
|
+
offset: tmp_x + tmp_width * ratio_x * (0.5 + (i-1)), tmp_y + inner_frame_margin * 0.5 + 2
|
|
277
|
+
fontSize: fontSize
|
|
278
|
+
anchor: "middle"
|
|
279
|
+
vanchor: "middle"
|
|
280
|
+
|
|
281
|
+
text:
|
|
282
|
+
content: i
|
|
283
|
+
offset: tmp_x + tmp_width * ratio_x * (0.5 + (i-1)), tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
284
|
+
fontSize: fontSize
|
|
285
|
+
anchor: "middle"
|
|
286
|
+
vanchor: "middle"
|
|
287
|
+
|
|
288
|
+
for index, val in enumerate(row_display_value):
|
|
289
|
+
text:
|
|
290
|
+
content: val
|
|
291
|
+
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * (0.5 + index)
|
|
292
|
+
fontSize: fontSize
|
|
293
|
+
anchor: "middle"
|
|
294
|
+
vanchor: "middle"
|
|
295
|
+
|
|
296
|
+
text:
|
|
297
|
+
content: val
|
|
298
|
+
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * (0.5 + index)
|
|
299
|
+
fontSize: fontSize
|
|
300
|
+
anchor: "middle"
|
|
301
|
+
vanchor: "middle"
|
|
458
302
|
|
|
459
303
|
params:
|
|
460
|
-
paper_size:
|
|
304
|
+
paper_size: paper_size_name
|
|
461
305
|
paper_width: paper_width
|
|
462
306
|
paper_height: paper_height
|
|
463
307
|
|
|
@@ -467,39 +311,48 @@ def frame_A4 ():
|
|
|
467
311
|
grid_width: paper_width - 2 * margin_x
|
|
468
312
|
grid_height: paper_height - 2 * margin_y
|
|
469
313
|
|
|
314
|
+
def sheet_A1():
|
|
315
|
+
paper_width = toMils(841)
|
|
316
|
+
paper_height = toMils(594)
|
|
317
|
+
margin = 400
|
|
470
318
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
type: "frame"
|
|
474
|
-
display: create graphic:
|
|
475
|
-
fill: "none"
|
|
319
|
+
return sheet_generator("A1", paper_width, paper_height, margin, margin,
|
|
320
|
+
range(1, 17), ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"])
|
|
476
321
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
322
|
+
def sheet_A2():
|
|
323
|
+
paper_width = toMils(594)
|
|
324
|
+
paper_height = toMils(420)
|
|
325
|
+
margin = 400
|
|
480
326
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
rect: paper_width/2, paper_height/2, paper_width - 2 * margin_x, paper_height - 2 * margin_y
|
|
327
|
+
return sheet_generator("A2", paper_width, paper_height, margin, margin,
|
|
328
|
+
range(1, 13), ["A", "B", "C", "D", "E", "F", "G", "H"])
|
|
484
329
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
330
|
+
def sheet_A3():
|
|
331
|
+
paper_width = toMils(420)
|
|
332
|
+
paper_height = toMils(297)
|
|
333
|
+
margin = 400
|
|
488
334
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
335
|
+
return sheet_generator("A3", paper_width, paper_height, margin, margin,
|
|
336
|
+
range(1, 9), ["A", "B", "C", "D", "E", "F"])
|
|
337
|
+
|
|
338
|
+
def sheet_A4():
|
|
339
|
+
paper_width = toMils(297)
|
|
340
|
+
paper_height = toMils(210)
|
|
341
|
+
margin = 400
|
|
342
|
+
|
|
343
|
+
return sheet_generator("A4", paper_width, paper_height, margin, margin,
|
|
344
|
+
range(1, 7), ["A", "B", "C", "D"])
|
|
345
|
+
|
|
346
|
+
def sheet_A5():
|
|
347
|
+
paper_width = toMils(210)
|
|
348
|
+
paper_height = toMils(148)
|
|
349
|
+
margin = 400
|
|
350
|
+
|
|
351
|
+
return sheet_generator("A5", paper_width, paper_height, margin, margin, range(1, 5), ["A", "B", "C"])
|
|
499
352
|
|
|
500
|
-
def
|
|
501
|
-
paper_width = 148
|
|
502
|
-
paper_height = 105
|
|
353
|
+
def sheet_A6():
|
|
354
|
+
paper_width = toMils(148)
|
|
355
|
+
paper_height = toMils(105)
|
|
503
356
|
margin = 400
|
|
504
357
|
|
|
505
|
-
return
|
|
358
|
+
return sheet_generator("A6", paper_width, paper_height, margin, margin, range(1, 4), ["A", "B"])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "circuitscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "Interpreter for the circuitscript language",
|
|
5
5
|
"homepage": "https://circuitscript.net",
|
|
6
6
|
"engines": {
|
|
@@ -68,7 +68,8 @@
|
|
|
68
68
|
"profile": "node --prof build/src/main.js examples/example_garden_pump.cst",
|
|
69
69
|
"profile-flame": "node --prof-process --preprocess -j isolate*.log | flamebearer",
|
|
70
70
|
"server": "node server.js",
|
|
71
|
-
"pack-local": "npm pack; rm circuitscript-install.tgz; mv `ls | grep circuitscript` circuitscript-install.tgz; cp circuitscript-install.tgz ../circuitscript-vscode/client; cp circuitscript-install.tgz ../circuitscript-vscode/server"
|
|
71
|
+
"pack-local": "npm pack; rm circuitscript-install.tgz; mv `ls | grep circuitscript` circuitscript-install.tgz; cp circuitscript-install.tgz ../circuitscript-vscode/client; cp circuitscript-install.tgz ../circuitscript-vscode/server",
|
|
72
|
+
"changelog": "auto-changelog --handlebars-setup ../changelog/helper.js"
|
|
72
73
|
},
|
|
73
74
|
"boilerplate_author": "Jakub Synowiec <jsynowiec@users.noreply.github.com>",
|
|
74
75
|
"license": "MIT",
|
|
@@ -90,5 +91,10 @@
|
|
|
90
91
|
},
|
|
91
92
|
"volta": {
|
|
92
93
|
"node": "18.12.1"
|
|
94
|
+
},
|
|
95
|
+
"auto-changelog": {
|
|
96
|
+
"output": "CHANGELOG.md",
|
|
97
|
+
"commitLimit": false,
|
|
98
|
+
"template": "../changelog/template.hbs"
|
|
93
99
|
}
|
|
94
100
|
}
|