@rulecad/keyboard-layout 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @rulecad/keyboard-layout
2
2
 
3
3
  A keyboard layout as plain JSON that everything else can read: the plate, the keycaps, the case and the circuit board
4
- all take their positions from one file. No dependencies; browsers and Node 18+.
4
+ all take their positions from one file. No dependencies; browsers and Node 20+.
5
5
 
6
6
  ```json
7
7
  {
@@ -90,9 +90,11 @@ export function fromKLE(kle) {
90
90
 
91
91
  // "Raw data" from keyboard-layout-editor.com is JSON with its object keys unquoted and the outer brackets left off
92
92
  function parseRaw(text) {
93
- try { return JSON.parse(text); } catch {}
93
+ // (one row on its own is a list with no lists in it: a three-key macropad's raw data. It is a layout of one row)
94
+ const rows = (data) => (Array.isArray(data) && data.length && !data.some(Array.isArray) ? [data] : data);
95
+ try { return rows(JSON.parse(text)); } catch {}
94
96
  const quoted = `[${text}]`.replace(/([{,]\s*)([A-Za-z_][\w]*)\s*:/g, '$1"$2":');
95
- try { return JSON.parse(quoted); } catch { throw new Error("this isn't keyboard-layout-editor data: paste its Raw data, or use its JSON download"); }
97
+ try { return rows(JSON.parse(quoted)); } catch { throw new Error("this isn't keyboard-layout-editor data: paste its Raw data, or use its JSON download"); }
96
98
  }
97
99
 
98
100
  // A key's legends: "Q", or "!\n1" (top-left shifted, bottom-left main), up to twelve positions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/keyboard-layout",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "A plain JSON keyboard layout format: rows of keys with widths and any per-key properties.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -20,7 +20,7 @@
20
20
  "mechanical-keyboard"
21
21
  ],
22
22
  "engines": {
23
- "node": ">=18"
23
+ "node": ">=20"
24
24
  },
25
25
  "sideEffects": false,
26
26
  "repository": {