custardkit-ts 0.2.1 → 0.2.3

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
@@ -2,6 +2,12 @@
2
2
 
3
3
  TypeScript implementation of [CustardKit](https://github.com/azooKey/CustardKit)
4
4
 
5
+ ## Features
6
+
7
+ - **Type Safety**: Fully typed with TypeScript, ensuring autocomplete and compile-time error checking.
8
+ - **Runtime Validation**: Validates inputs at runtime to prevent invalid keyboard configurations.
9
+ - **Direct Serialization**: Classes support direct JSON serialization via `JSON.stringify()`.
10
+
5
11
  ## Installation
6
12
 
7
13
  ```bash
@@ -11,22 +17,11 @@ npm add custardkit-ts
11
17
  ## Usage
12
18
 
13
19
  ```typescript
14
- import {
15
- Action,
16
- Custard,
17
- CustomKey,
18
- GridFitSpecifier,
19
- InputStyle,
20
- Interface,
21
- KeyColor,
22
- KeyData,
23
- KeyDesign,
24
- KeyStyle,
25
- Label,
26
- Language,
27
- Layout,
28
- Metadata,
29
- } from "custardkit-ts";
20
+ import { Custard, Interface, Metadata } from "custardkit-ts/Custard";
21
+ import { CustomKey, KeyDesign } from "custardkit-ts/Keys";
22
+ import { Action } from "custardkit-ts/Actions";
23
+ import { Layout, KeyData, GridFitSpecifier } from "custardkit-ts/Layout";
24
+ import { InputStyle, KeyStyle, Language } from "custardkit-ts";
30
25
 
31
26
  // Create a simple key using factory methods
32
27
  const key = new CustomKey({
@@ -62,18 +57,6 @@ const custard = new Custard({
62
57
  await custard.write("my_keyboard.json");
63
58
  ```
64
59
 
65
- ## Subpath Imports
66
-
67
- For direct class access:
68
-
69
- ```typescript
70
- import { InputAction, DeleteAction } from "custardkit-ts/Actions";
71
- import { TextLabel } from "custardkit-ts/Labels";
72
- import { CustomKey, KeyDesign } from "custardkit-ts/Keys";
73
- import { GridFitLayout } from "custardkit-ts/Layout";
74
- import { Custard, Metadata, Interface } from "custardkit-ts/Custard";
75
- ```
76
-
77
60
  ## License
78
61
 
79
62
  MIT
@@ -1,3 +1,3 @@
1
- import { _ as DismissKeyboardAction, a as SmartMoveCursorAction, b as CompleteAction, c as SelectCandidateAction, d as PasteAction, f as MoveTabAction, g as EnableResizingModeAction, h as InputAction, i as ToggleCapsLockStateAction, l as ReplaceLastCharactersAction, m as LaunchApplicationAction, n as ToggleTabBarAction, o as SmartDeleteDefaultAction, p as MoveCursorAction, r as ToggleCursorBarAction, s as SmartDeleteAction, t as Action, u as ReplaceDefaultAction, v as DeleteAction, x as BaseAction, y as CompleteCharacterFormAction } from "../Actions-DGz8CoQU.mjs";
1
+ import { _ as DismissKeyboardAction, a as SmartMoveCursorAction, b as CompleteAction, c as SelectCandidateAction, d as PasteAction, f as MoveTabAction, g as EnableResizingModeAction, h as InputAction, i as ToggleCapsLockStateAction, l as ReplaceLastCharactersAction, m as LaunchApplicationAction, n as ToggleTabBarAction, o as SmartDeleteDefaultAction, p as MoveCursorAction, r as ToggleCursorBarAction, s as SmartDeleteAction, t as Action, u as ReplaceDefaultAction, v as DeleteAction, x as BaseAction, y as CompleteCharacterFormAction } from "../Actions-CicRxnRj.mjs";
2
2
 
3
3
  export { Action, BaseAction, CompleteAction, CompleteCharacterFormAction, DeleteAction, DismissKeyboardAction, EnableResizingModeAction, InputAction, LaunchApplicationAction, MoveCursorAction, MoveTabAction, PasteAction, ReplaceDefaultAction, ReplaceLastCharactersAction, SelectCandidateAction, SmartDeleteAction, SmartDeleteDefaultAction, SmartMoveCursorAction, ToggleCapsLockStateAction, ToggleCursorBarAction, ToggleTabBarAction };
@@ -20,8 +20,8 @@ var CompleteCharacterFormAction = class extends BaseAction {
20
20
  }
21
21
  toJSON() {
22
22
  return {
23
- forms: this.forms,
24
- type: this.type
23
+ type: this.type,
24
+ forms: this.forms
25
25
  };
26
26
  }
27
27
  };
@@ -37,8 +37,8 @@ var DeleteAction = class extends BaseAction {
37
37
  }
38
38
  toJSON() {
39
39
  return {
40
- count: this.count,
41
- type: this.type
40
+ type: this.type,
41
+ count: this.count
42
42
  };
43
43
  }
44
44
  };
@@ -72,8 +72,8 @@ var InputAction = class extends BaseAction {
72
72
  }
73
73
  toJSON() {
74
74
  return {
75
- text: this.text,
76
- type: this.type
75
+ type: this.type,
76
+ text: this.text
77
77
  };
78
78
  }
79
79
  };
@@ -89,9 +89,9 @@ var LaunchApplicationAction = class extends BaseAction {
89
89
  }
90
90
  toJSON() {
91
91
  return {
92
+ type: this.type,
92
93
  scheme_type: this.schemeType,
93
- target: this.target,
94
- type: this.type
94
+ target: this.target
95
95
  };
96
96
  }
97
97
  };
@@ -107,8 +107,8 @@ var MoveCursorAction = class extends BaseAction {
107
107
  }
108
108
  toJSON() {
109
109
  return {
110
- count: this.count,
111
- type: this.type
110
+ type: this.type,
111
+ count: this.count
112
112
  };
113
113
  }
114
114
  };
@@ -124,9 +124,9 @@ var MoveTabAction = class extends BaseAction {
124
124
  }
125
125
  toJSON() {
126
126
  return {
127
- identifier: this.identifier,
127
+ type: this.type,
128
128
  tab_type: this.tabType,
129
- type: this.type
129
+ identifier: this.identifier
130
130
  };
131
131
  }
132
132
  };
@@ -167,8 +167,8 @@ var ReplaceLastCharactersAction = class extends BaseAction {
167
167
  }
168
168
  toJSON() {
169
169
  return {
170
- table: this.table,
171
- type: this.type
170
+ type: this.type,
171
+ table: this.table
172
172
  };
173
173
  }
174
174
  };
@@ -183,8 +183,8 @@ var SelectCandidateAction = class extends BaseAction {
183
183
  }
184
184
  toJSON() {
185
185
  return {
186
- selection: this.selection,
187
- type: this.type
186
+ type: this.type,
187
+ selection: this.selection
188
188
  };
189
189
  }
190
190
  };
@@ -200,9 +200,9 @@ var SmartDeleteAction = class extends BaseAction {
200
200
  }
201
201
  toJSON() {
202
202
  return {
203
+ type: this.type,
203
204
  direction: this.direction,
204
- targets: this.targets,
205
- type: this.type
205
+ targets: this.targets
206
206
  };
207
207
  }
208
208
  };
@@ -227,9 +227,9 @@ var SmartMoveCursorAction = class extends BaseAction {
227
227
  }
228
228
  toJSON() {
229
229
  return {
230
+ type: this.type,
230
231
  direction: this.direction,
231
- targets: this.targets,
232
- type: this.type
232
+ targets: this.targets
233
233
  };
234
234
  }
235
235
  };
@@ -1,3 +1,3 @@
1
- import { a as VariationDesign, c as FlickVariationData, i as Variation, n as LongpressVariationData, o as LongpressAction, r as CustomKey, s as KeyDesign, t as SystemKey } from "../Keys-HP_Fh_Lv.mjs";
1
+ import { a as VariationDesign, c as FlickVariationData, i as Variation, n as LongpressVariationData, o as LongpressAction, r as CustomKey, s as KeyDesign, t as SystemKey } from "../Keys-0-JGAoj2.mjs";
2
2
 
3
3
  export { CustomKey, FlickVariationData, KeyDesign, LongpressAction, LongpressVariationData, SystemKey, Variation, VariationDesign };
@@ -1,6 +1,6 @@
1
1
  import { i as KeyColor, n as FlickDirection } from "./enums-BySrsID6.mjs";
2
- import { t as Label } from "./Labels-D8TEwrN8.mjs";
3
- import { t as Action } from "./Actions-DGz8CoQU.mjs";
2
+ import { t as Label } from "./Labels-M8b3K2tQ.mjs";
3
+ import { t as Action } from "./Actions-CicRxnRj.mjs";
4
4
 
5
5
  //#region src/Keys/FlickVariationData.ts
6
6
  var FlickVariationData = class {
@@ -12,9 +12,9 @@ var FlickVariationData = class {
12
12
  }
13
13
  toJSON() {
14
14
  return {
15
+ type: "flick_variation",
15
16
  direction: this.direction,
16
- key: this.key.toJSON(),
17
- type: "flick_variation"
17
+ key: this.key.toJSON()
18
18
  };
19
19
  }
20
20
  };
@@ -30,8 +30,8 @@ var KeyDesign = class KeyDesign {
30
30
  }
31
31
  toJSON() {
32
32
  return {
33
- color: this.color,
34
- label: this.label.toJSON()
33
+ label: this.label.toJSON(),
34
+ color: this.color
35
35
  };
36
36
  }
37
37
  static create(label, color) {
@@ -98,8 +98,8 @@ var Variation = class Variation {
98
98
  toJSON() {
99
99
  return {
100
100
  design: this.design.toJSON(),
101
- longpress_actions: this.longpressActions.toJSON(),
102
- press_actions: this.pressActions.map((a) => a.toJSON())
101
+ press_actions: this.pressActions.map((a) => a.toJSON()),
102
+ longpress_actions: this.longpressActions.toJSON()
103
103
  };
104
104
  }
105
105
  static simpleInput(text, label) {
@@ -126,8 +126,8 @@ var CustomKey = class CustomKey {
126
126
  toJSON() {
127
127
  return {
128
128
  design: this.design.toJSON(),
129
- longpress_actions: this.longpressActions.toJSON(),
130
129
  press_actions: this.pressActions.map((a) => a.toJSON()),
130
+ longpress_actions: this.longpressActions.toJSON(),
131
131
  variations: this.variations.map((v) => v.toJSON())
132
132
  };
133
133
  }
@@ -200,8 +200,8 @@ var LongpressVariationData = class {
200
200
  }
201
201
  toJSON() {
202
202
  return {
203
- key: this.key.toJSON(),
204
- type: "longpress_variation"
203
+ type: "longpress_variation",
204
+ key: this.key.toJSON()
205
205
  };
206
206
  }
207
207
  };
@@ -1,3 +1,3 @@
1
- import { a as MainAndDirectionsLabel, i as MainAndSubLabel, n as TextLabel, r as SystemImageLabel, t as Label } from "../Labels-D8TEwrN8.mjs";
1
+ import { a as MainAndDirectionsLabel, i as MainAndSubLabel, n as TextLabel, r as SystemImageLabel, t as Label } from "../Labels-M8b3K2tQ.mjs";
2
2
 
3
3
  export { Label, MainAndDirectionsLabel, MainAndSubLabel, SystemImageLabel, TextLabel };
@@ -6,9 +6,9 @@ var MainAndDirectionsLabel = class {
6
6
  }
7
7
  toJSON() {
8
8
  return {
9
- directions: this.directions,
9
+ type: "main_and_directions",
10
10
  main: this.main,
11
- type: "main_and_directions"
11
+ directions: this.directions
12
12
  };
13
13
  }
14
14
  };
@@ -22,9 +22,9 @@ var MainAndSubLabel = class {
22
22
  }
23
23
  toJSON() {
24
24
  return {
25
+ type: "main_and_sub",
25
26
  main: this.main,
26
- sub: this.sub,
27
- type: "main_and_sub"
27
+ sub: this.sub
28
28
  };
29
29
  }
30
30
  };
@@ -1,3 +1,3 @@
1
- import { a as GridFitSpecifier, i as GridScrollLayout, n as KeyData, o as GridFitLayout, r as GridScrollSpecifier, t as Layout } from "../Layout-BYGdAtQk.mjs";
1
+ import { a as GridFitSpecifier, i as GridScrollLayout, n as KeyData, o as GridFitLayout, r as GridScrollSpecifier, t as Layout } from "../Layout-Cb2Aanqv.mjs";
2
2
 
3
3
  export { GridFitLayout, GridFitSpecifier, GridScrollLayout, GridScrollSpecifier, KeyData, Layout };
@@ -1,5 +1,5 @@
1
1
  import { a as InvalidLayoutSizeError } from "./errors-BPMIP-gS.mjs";
2
- import { r as CustomKey } from "./Keys-HP_Fh_Lv.mjs";
2
+ import { r as CustomKey } from "./Keys-0-JGAoj2.mjs";
3
3
 
4
4
  //#region src/Layout/GridFitLayout.ts
5
5
  var GridFitLayout = class {
@@ -35,9 +35,9 @@ var GridFitLayout = class {
35
35
  }
36
36
  toJSON() {
37
37
  return {
38
- column_count: this.columnCount,
38
+ type: "grid_fit",
39
39
  row_count: this.rowCount,
40
- type: "grid_fit"
40
+ column_count: this.columnCount
41
41
  };
42
42
  }
43
43
  };
@@ -61,10 +61,10 @@ var GridFitSpecifier = class {
61
61
  }
62
62
  toJSON() {
63
63
  return {
64
- height: this.height,
65
- width: this.width,
66
64
  x: this.x,
67
- y: this.y
65
+ y: this.y,
66
+ width: this.width,
67
+ height: this.height
68
68
  };
69
69
  }
70
70
  get specifierType() {
@@ -104,10 +104,10 @@ var GridScrollLayout = class {
104
104
  }
105
105
  toJSON() {
106
106
  return {
107
- column_count: this.columnCount,
107
+ type: "grid_scroll",
108
108
  direction: this.direction,
109
109
  row_count: this.rowCount,
110
- type: "grid_scroll"
110
+ column_count: this.columnCount
111
111
  };
112
112
  }
113
113
  };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as KeyStyle, c as ReplaceType, d as SystemKeyType, f as SystemTabType, i as KeyColor, l as ScanDirection, n as FlickDirection, o as Language, r as InputStyle, s as LongpressDuration, t as CharacterForm, u as ScrollDirection } from "./enums-BySrsID6.mjs";
2
2
  import { i as InvalidKeyPositionError, n as EmptyDisplayNameError, o as LayoutSpecifierMismatchError, r as InvalidIdentifierError, s as ValidationError, t as CustardKitError } from "./errors-BPMIP-gS.mjs";
3
- import { a as GridFitSpecifier, i as GridScrollLayout, o as GridFitLayout, r as GridScrollSpecifier } from "./Layout-BYGdAtQk.mjs";
3
+ import { a as GridFitSpecifier, i as GridScrollLayout, o as GridFitLayout, r as GridScrollSpecifier } from "./Layout-Cb2Aanqv.mjs";
4
4
  import { writeFile } from "node:fs/promises";
5
5
 
6
6
  //#region src/Custard/Custard.ts
@@ -22,16 +22,16 @@ var Custard = class {
22
22
  toJSON() {
23
23
  return {
24
24
  identifier: this.identifier,
25
- input_style: this.inputStyle,
26
- interface: this.interface.toJSON(),
27
25
  language: this.language,
28
- metadata: this.metadata.toJSON()
26
+ input_style: this.inputStyle,
27
+ metadata: this.metadata.toJSON(),
28
+ interface: this.interface.toJSON()
29
29
  };
30
30
  }
31
31
  async write(name) {
32
32
  let filename = name;
33
33
  if (!name.endsWith(".json")) filename = `${name}.json`;
34
- const content = `${JSON.stringify(this, null, 2)}\n`;
34
+ const content = `${JSON.stringify(this, null)}\n`;
35
35
  await writeFile(filename, content, { encoding: "utf8" });
36
36
  }
37
37
  };
@@ -46,7 +46,7 @@ var CustardList = class {
46
46
  async write(name) {
47
47
  let filename = name;
48
48
  if (!name.endsWith(".json")) filename = `${name}.json`;
49
- const content = `${JSON.stringify(this.toJSON(), null, 2)}\n`;
49
+ const content = `${JSON.stringify(this.toJSON(), null)}\n`;
50
50
  await writeFile(filename, content, { encoding: "utf8" });
51
51
  }
52
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "custardkit-ts",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ph0ryn/CustardKitTS.git"