desck 0.4.3 → 0.4.5

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/desck.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("./server.cjs");
2
+ require(`${__dirname}/server.mjs`);
package/package.json CHANGED
@@ -1,17 +1,15 @@
1
1
  {
2
2
  "name": "desck",
3
- "version": "0.4.3",
3
+ "author": "Akos Plesznivy",
4
+ "version": "0.4.5",
4
5
  "description": "A card layout editor made for creating example images for our card games using the standard deck.",
5
- "main": "server.cjs",
6
+ "main": "server.mjs",
6
7
  "scripts": {
7
8
  "test": "echo \"Error: no test specified\" && exit 1",
8
9
  "build": "elm make src/Main.elm --output=public/main.js --optimize && cp README.md public/",
9
- "prepare": "npm run build",
10
10
  "prepack": "npm run build",
11
- "postinstall": "npm run build",
12
11
  "start": "node server.cjs"
13
12
  },
14
- "author": "Akos Plesznivy",
15
13
  "license": "ISC",
16
14
  "dependencies": {
17
15
  "express": "^4.21.1",
@@ -22,7 +20,8 @@
22
20
  "files": [
23
21
  "./public/",
24
22
  "./src/",
25
- "./server.cjs",
23
+ "./server.mjs",
24
+ "./settings.json",
26
25
  "./desck.cjs"
27
26
  ],
28
27
  "bin": {
package/public/main.js CHANGED
@@ -17393,6 +17393,7 @@ var $author$project$Project$Zoom = function (a) {
17393
17393
  var $elm$svg$Svg$trustedNode = _VirtualDom_nodeNS('http://www.w3.org/2000/svg');
17394
17394
  var $elm$svg$Svg$defs = $elm$svg$Svg$trustedNode('defs');
17395
17395
  var $elm$svg$Svg$Attributes$fill = _VirtualDom_attribute('fill');
17396
+ var $elm$svg$Svg$line = $elm$svg$Svg$trustedNode('line');
17396
17397
  var $elm$svg$Svg$marker = $elm$svg$Svg$trustedNode('marker');
17397
17398
  var $elm$svg$Svg$Attributes$markerHeight = _VirtualDom_attribute('markerHeight');
17398
17399
  var $elm$svg$Svg$Attributes$markerUnits = _VirtualDom_attribute('markerUnits');
@@ -17407,10 +17408,19 @@ var $elm$svg$Svg$Attributes$points = _VirtualDom_attribute('points');
17407
17408
  var $elm$svg$Svg$polygon = $elm$svg$Svg$trustedNode('polygon');
17408
17409
  var $elm$svg$Svg$Attributes$refX = _VirtualDom_attribute('refX');
17409
17410
  var $elm$svg$Svg$Attributes$refY = _VirtualDom_attribute('refY');
17411
+ var $elm$svg$Svg$Attributes$stroke = _VirtualDom_attribute('stroke');
17412
+ var $elm$svg$Svg$Attributes$strokeLinecap = _VirtualDom_attribute('stroke-linecap');
17413
+ var $elm$svg$Svg$Attributes$x1 = _VirtualDom_attribute('x1');
17414
+ var $elm$svg$Svg$Attributes$x2 = _VirtualDom_attribute('x2');
17415
+ var $elm$svg$Svg$Attributes$y1 = _VirtualDom_attribute('y1');
17416
+ var $elm$svg$Svg$Attributes$y2 = _VirtualDom_attribute('y2');
17410
17417
  var $author$project$Main$arrowDefs = function () {
17411
17418
  var w = 3.0;
17412
17419
  var w2 = w / 2.0;
17413
17420
  var h = 1.5;
17421
+ var h2 = h * 2;
17422
+ var h3 = h * 3;
17423
+ var h4 = h * 4;
17414
17424
  return A2(
17415
17425
  $elm$svg$Svg$defs,
17416
17426
  _List_Nil,
@@ -17440,6 +17450,46 @@ var $author$project$Main$arrowDefs = function () {
17440
17450
  '0,0 0,' + ($elm$core$String$fromFloat(w) + (' ' + ($elm$core$String$fromFloat(h) + (',' + $elm$core$String$fromFloat(w2))))))
17441
17451
  ]),
17442
17452
  _List_Nil)
17453
+ ])),
17454
+ A2(
17455
+ $elm$svg$Svg$marker,
17456
+ _List_fromArray(
17457
+ [
17458
+ $elm$svg$Svg$Attributes$id('cross'),
17459
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$markerWidth, h4),
17460
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$markerHeight, h4),
17461
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$refX, h2),
17462
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$refY, h2),
17463
+ $elm$svg$Svg$Attributes$orient('auto'),
17464
+ $elm$svg$Svg$Attributes$markerUnits('strokeWidth'),
17465
+ $elm$svg$Svg$Attributes$stroke('context-stroke')
17466
+ ]),
17467
+ _List_fromArray(
17468
+ [
17469
+ A2(
17470
+ $elm$svg$Svg$line,
17471
+ _List_fromArray(
17472
+ [
17473
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$x1, h),
17474
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$y1, h),
17475
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$x2, h3),
17476
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$y2, h3),
17477
+ $elm$svg$Svg$Attributes$stroke('context-stroke'),
17478
+ $elm$svg$Svg$Attributes$strokeLinecap('butt')
17479
+ ]),
17480
+ _List_Nil),
17481
+ A2(
17482
+ $elm$svg$Svg$line,
17483
+ _List_fromArray(
17484
+ [
17485
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$x1, h3),
17486
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$y1, h),
17487
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$x2, h),
17488
+ A2($author$project$Util$num, $elm$svg$Svg$Attributes$y2, h3),
17489
+ $elm$svg$Svg$Attributes$stroke('context-stroke'),
17490
+ $elm$svg$Svg$Attributes$strokeLinecap('butt')
17491
+ ]),
17492
+ _List_Nil)
17443
17493
  ]))
17444
17494
  ]));
17445
17495
  }();
@@ -17518,7 +17568,6 @@ var $author$project$Main$getColor = F2(
17518
17568
  return 'var(--' + ($author$project$Palette$colorAsString(c) + ')');
17519
17569
  }
17520
17570
  });
17521
- var $elm$svg$Svg$line = $elm$svg$Svg$trustedNode('line');
17522
17571
  var $elm$svg$Svg$Attributes$markerEnd = _VirtualDom_attribute('marker-end');
17523
17572
  var $author$project$Util$transform = F3(
17524
17573
  function (op, ls, sep) {
@@ -17563,8 +17612,6 @@ var $author$project$Main$preventContextMenu = A2(
17563
17612
  _Utils_Tuple2(
17564
17613
  $author$project$Main$Noop(''),
17565
17614
  true)));
17566
- var $elm$svg$Svg$Attributes$stroke = _VirtualDom_attribute('stroke');
17567
- var $elm$svg$Svg$Attributes$strokeLinecap = _VirtualDom_attribute('stroke-linecap');
17568
17615
  var $elm$svg$Svg$Attributes$strokeWidth = _VirtualDom_attribute('stroke-width');
17569
17616
  var $elm$svg$Svg$text = $elm$virtual_dom$VirtualDom$text;
17570
17617
  var $elm$svg$Svg$text_ = $elm$svg$Svg$trustedNode('text');
@@ -17584,10 +17631,6 @@ var $author$project$Util$translateXY = function (pos) {
17584
17631
  var $author$project$Util$url = function (s) {
17585
17632
  return 'url(#' + (s + ')');
17586
17633
  };
17587
- var $elm$svg$Svg$Attributes$x1 = _VirtualDom_attribute('x1');
17588
- var $elm$svg$Svg$Attributes$x2 = _VirtualDom_attribute('x2');
17589
- var $elm$svg$Svg$Attributes$y1 = _VirtualDom_attribute('y1');
17590
- var $elm$svg$Svg$Attributes$y2 = _VirtualDom_attribute('y2');
17591
17634
  var $author$project$Main$arrowView = F3(
17592
17635
  function (model, _v0, a) {
17593
17636
  var from = _v0.a;
@@ -17640,14 +17683,21 @@ var $author$project$Main$arrowView = F3(
17640
17683
  ]),
17641
17684
  function () {
17642
17685
  var _v2 = a.bt;
17643
- if (_v2 === 1) {
17644
- return _List_fromArray(
17645
- [
17646
- $elm$svg$Svg$Attributes$markerEnd(
17647
- $author$project$Util$url('arrow'))
17648
- ]);
17649
- } else {
17650
- return _List_Nil;
17686
+ switch (_v2) {
17687
+ case 1:
17688
+ return _List_fromArray(
17689
+ [
17690
+ $elm$svg$Svg$Attributes$markerEnd(
17691
+ $author$project$Util$url('arrow'))
17692
+ ]);
17693
+ case 2:
17694
+ return _List_fromArray(
17695
+ [
17696
+ $elm$svg$Svg$Attributes$markerEnd(
17697
+ $author$project$Util$url('cross'))
17698
+ ]);
17699
+ default:
17700
+ return _List_Nil;
17651
17701
  }
17652
17702
  }()),
17653
17703
  _List_Nil),
package/public/script.js CHANGED
@@ -134,13 +134,13 @@ function exportSymbols(settings) {
134
134
 
135
135
  const backface = svg.querySelector("#backface");
136
136
 
137
- if (settings.stripBackface) {
137
+ if (backface && settings.stripBackface) {
138
138
  backface.id = null;
139
139
  }
140
140
 
141
141
  let data = new XMLSerializer().serializeToString(svg.querySelector("#defs"));
142
142
 
143
- if (settings.stripBackface) {
143
+ if (backface && settings.stripBackface) {
144
144
  backface.id = "backface";
145
145
  }
146
146
 
@@ -453,6 +453,10 @@ async function init() {
453
453
  // "./svg/backface.svg",
454
454
  // document.querySelector(symbol_container),
455
455
  // );
456
+ // loadSymbolsInto(
457
+ // "./svg/backface.svg",
458
+ // document.querySelector(symbol_container),
459
+ // );
456
460
 
457
461
  let mods = {
458
462
  ctrl: false,
@@ -1,62 +1,76 @@
1
- const express = require("express");
2
- const http = require("http");
3
- const socketIo = require("socket.io");
4
- const path = require("path");
5
- const fs = require("fs");
1
+ import express from "express";
2
+ import http from "http";
3
+ import { Server } from "socket.io";
4
+ import path from "node:path";
5
+ import fs from "node:fs";
6
+ import { parseArgs } from "node:util";
7
+
8
+ const __dirname = path.dirname(new URL(import.meta.url).pathname);
9
+ const parseConfig = (argv) => {
10
+ const { values, positionals } = parseArgs({
11
+ argv: argv.slice(2), // Skip 'node' and script name
12
+ options: {
13
+ input: { type: "string", short: "i" },
14
+ output: { type: "string", short: "o" },
15
+ settings: { type: "string" },
16
+ port: { type: "string", short: "p" },
17
+ png: { type: "boolean" },
18
+ svg: { type: "boolean" },
19
+ symbols: { type: "boolean" },
20
+ },
21
+ allowPositionals: true,
22
+ });
6
23
 
7
- const app = express();
8
- const server = http.createServer(app);
9
- const io = socketIo(server, { maxHttpBufferSize: 1e8 });
10
-
11
- const parseConfig = (args) => {
12
- let flags = args.filter((a) => a.substr(0, 2) === "--");
13
- args = args.filter((a) => a.substr(0, 2) !== "--");
14
- let c = {
15
- port: 3000,
16
- mode: "dev",
24
+ const parsePath = (value, def) => {
25
+ return value ? path.join(process.cwd(), value) : path.join(__dirname, def);
26
+ };
27
+
28
+ const parseMode = (value) => {
29
+ if (["dev", "watch", "export"].includes(value)) return value;
30
+ else return null;
31
+ };
32
+
33
+ const mode = parseMode(positionals[0]);
34
+
35
+ if (!mode) {
36
+ console.error(`unrecognized mode "${positionals[0]}"`);
37
+ process.exit();
38
+ }
39
+
40
+ const c = {
41
+ port: parseInt(values.port) || 8000,
42
+ mode: mode,
17
43
  formats: [],
18
- symbols: false,
19
- input: null,
20
- output: null,
44
+ symbols: values.symbols || false,
45
+ input: parsePath(values.input, "public/projects"),
46
+ output: parsePath(values.output, "exports"),
21
47
  settings: null,
22
48
  };
23
49
 
24
- c.port = 8000;
25
-
26
- c.mode = flags.includes("--watch")
27
- ? "watch"
28
- : flags.includes("--export")
29
- ? "export"
30
- : "dev";
31
-
32
- c.formats = [];
33
- if (flags.includes("--svg")) c.formats.push("svg");
34
- if (flags.includes("--png")) c.formats.push("png");
35
- c.symbols = flags.includes("--symbols");
36
-
37
- c.input = args[2]
38
- ? path.join(process.cwd(), args[2])
39
- : path.join(__dirname, "public/projects");
40
-
41
- c.output = args[3]
42
- ? path.join(process.cwd(), args[3])
43
- : path.join(__dirname, "exports");
44
-
45
- c.settings = JSON.parse(
46
- fs.readFileSync(
47
- args[4]
48
- ? path.join(process.cwd(), args[4])
49
- : path.join(__dirname, "settings.json"),
50
- ),
51
- );
50
+ if (values.svg) c.formats.push("svg");
51
+ if (values.png) c.formats.push("png");
52
+
53
+ const defaultSettings = "settings.json";
54
+ const settingsPath = values.settings
55
+ ? path.join(process.cwd(), values.settings)
56
+ : fs.existsSync(path.join(c.input, defaultSettings))
57
+ ? path.join(c.input, defaultSettings)
58
+ : path.join(__dirname, defaultSettings);
59
+
60
+ c.settings = JSON.parse(fs.readFileSync(settingsPath));
61
+
62
+ c.verbose = c.mode == "dev";
63
+
52
64
  return c;
53
65
  };
54
66
 
67
+ const app = express();
68
+ const server = http.createServer(app);
69
+ const io = new Server(server, { maxHttpBufferSize: 1e8 });
70
+
55
71
  let config = parseConfig(process.argv);
56
72
  console.log(config);
57
73
 
58
- const verbose = !["watch", "export"].includes(config.mode);
59
-
60
74
  const ensureDir = (dir) => {
61
75
  if (!fs.existsSync(dir)) {
62
76
  fs.mkdirSync(dir, { recursive: true });
@@ -108,7 +122,7 @@ io.on("connection", (socket) => {
108
122
  const readProjects = () => {
109
123
  return readFiles(config.input);
110
124
  };
111
- if (verbose) {
125
+ if (config.verbose) {
112
126
  logMessage("connect", "gui");
113
127
  }
114
128
  let files = readProjects();
@@ -129,7 +143,7 @@ io.on("connection", (socket) => {
129
143
  emitList();
130
144
  });
131
145
  socket.onAny((message, data) => {
132
- if (verbose) {
146
+ if (config.verbose) {
133
147
  logMessage(message, data);
134
148
  }
135
149
  });
@@ -142,7 +156,7 @@ io.on("connection", (socket) => {
142
156
  socket.on("import", (name) => {
143
157
  const filepath = inputFile(`${name}.json`);
144
158
  if (fs.existsSync(filepath)) {
145
- if (verbose) {
159
+ if (config.verbose) {
146
160
  logMessage("load", `${name}`);
147
161
  }
148
162
  const json = fs.readFileSync(filepath, "utf-8");
@@ -154,7 +168,7 @@ io.on("connection", (socket) => {
154
168
  });
155
169
 
156
170
  socket.on("disconnect", () => {
157
- if (verbose) {
171
+ if (config.verbose) {
158
172
  logMessage("disconnect", "gui");
159
173
  }
160
174
  });
@@ -209,7 +223,7 @@ const exportProject = async (browser, config, jsonData, format) => {
209
223
  }
210
224
  };
211
225
 
212
- const puppeteer = require("puppeteer");
226
+ import puppeteer from "puppeteer";
213
227
 
214
228
  const withBrowser = async (fun) => {
215
229
  try {
package/settings.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "stripData": true,
3
+ "embedSymbols": false,
4
+ "mapColors": false,
5
+ "mapFont": false,
6
+ "stripBackface": true,
7
+ "primaryFont": null,
8
+ "secondaryFont": null,
9
+ "heightPixels": 128
10
+ }
package/src/Main.elm CHANGED
@@ -3083,6 +3083,15 @@ arrowDefs =
3083
3083
  h =
3084
3084
  1.5
3085
3085
 
3086
+ h2 =
3087
+ h * 2
3088
+
3089
+ h3 =
3090
+ h * 3
3091
+
3092
+ h4 =
3093
+ h * 4
3094
+
3086
3095
  w2 =
3087
3096
  w / 2.0
3088
3097
  in
@@ -3103,6 +3112,35 @@ arrowDefs =
3103
3112
  ]
3104
3113
  []
3105
3114
  ]
3115
+ , Svg.marker
3116
+ [ Attr.id "cross"
3117
+ , num Attr.markerWidth h4
3118
+ , num Attr.markerHeight h4
3119
+ , num Attr.refX h2
3120
+ , num Attr.refY h2
3121
+ , Attr.orient "auto"
3122
+ , Attr.markerUnits "strokeWidth"
3123
+ , Attr.stroke "context-stroke"
3124
+ ]
3125
+ [ Svg.line
3126
+ [ num Attr.x1 h
3127
+ , num Attr.y1 h
3128
+ , num Attr.x2 h3
3129
+ , num Attr.y2 h3
3130
+ , Attr.stroke "context-stroke"
3131
+ , Attr.strokeLinecap "butt"
3132
+ ]
3133
+ []
3134
+ , Svg.line
3135
+ [ num Attr.x1 h3
3136
+ , num Attr.y1 h
3137
+ , num Attr.x2 h
3138
+ , num Attr.y2 h3
3139
+ , Attr.stroke "context-stroke"
3140
+ , Attr.strokeLinecap "butt"
3141
+ ]
3142
+ []
3143
+ ]
3106
3144
 
3107
3145
  -- , Svg.filter
3108
3146
  -- [ Attr.id "shadow" ]
@@ -3185,6 +3223,9 @@ arrowView model ( from, to ) a =
3185
3223
  Triangle ->
3186
3224
  [ Attr.markerEnd (url "arrow") ]
3187
3225
 
3226
+ Cross ->
3227
+ [ Attr.markerEnd (url "cross") ]
3228
+
3188
3229
  -- TODO Arrow - cross head!
3189
3230
  _ ->
3190
3231
  []