@asdf-overlay/core 0.9.0 → 0.9.2

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.
Binary file
package/addon-x64.node CHANGED
Binary file
Binary file
Binary file
Binary file
package/lib/index.d.ts CHANGED
@@ -3,15 +3,42 @@ import { CursorInput, KeyboardInput } from './input.js';
3
3
  import { PercentLength, CopyRect, Cursor } from './types.js';
4
4
  export * from './types.js';
5
5
  export * from './util.js';
6
+ /**
7
+ * Unique symbol for accessing internal id
8
+ */
6
9
  declare const idSym: unique symbol;
7
10
  export type OverlayEventEmitter = EventEmitter<{
11
+ /**
12
+ * A window has been added.
13
+ */
8
14
  added: [id: number, width: number, height: number];
15
+ /**
16
+ * A window has been resized.
17
+ */
9
18
  resized: [id: number, width: number, height: number];
19
+ /**
20
+ * Cursor input from a window.
21
+ */
10
22
  cursor_input: [id: number, input: CursorInput];
23
+ /**
24
+ * Keyboard input from a window.
25
+ */
11
26
  keyboard_input: [id: number, input: KeyboardInput];
27
+ /**
28
+ * Input blocking to a window is interrupted and turned off.
29
+ */
12
30
  input_blocking_ended: [id: number];
31
+ /**
32
+ * Window is destroyed.
33
+ */
13
34
  destroyed: [id: number];
35
+ /**
36
+ * An error has occured on ipc connection.
37
+ */
14
38
  error: [err: unknown];
39
+ /**
40
+ * Ipc disconnected.
41
+ */
15
42
  disconnected: [];
16
43
  }>;
17
44
  export declare class Overlay {
package/lib/index.js CHANGED
@@ -4,7 +4,13 @@ import { fileURLToPath } from 'node:url';
4
4
  import { EventEmitter } from 'node:events';
5
5
  export * from './types.js';
6
6
  export * from './util.js';
7
+ /**
8
+ * Global node addon instance
9
+ */
7
10
  const addon = loadAddon();
11
+ /**
12
+ * Load node addon depending on system architecture.
13
+ */
8
14
  function loadAddon() {
9
15
  const nodeModule = { exports: {} };
10
16
  let name;
@@ -22,6 +28,9 @@ function loadAddon() {
22
28
  process.dlopen(nodeModule, path.resolve(path.dirname(fileURLToPath(new URL(import.meta.url))), name));
23
29
  return nodeModule.exports;
24
30
  }
31
+ /**
32
+ * Unique symbol for accessing internal id
33
+ */
25
34
  const idSym = Symbol('id');
26
35
  export class Overlay {
27
36
  event = new EventEmitter();
package/lib/input.d.ts CHANGED
@@ -1,82 +1,240 @@
1
1
  import { Key } from './index.js';
2
+ /**
3
+ * Describe a cursor input.
4
+ */
2
5
  export type CursorInput = {
6
+ /**
7
+ * X position relative to overlay surface.
8
+ */
3
9
  clientX: number;
10
+ /**
11
+ * Y position relative to overlay surface.
12
+ */
4
13
  clientY: number;
14
+ /**
15
+ * X position relative to window.
16
+ */
5
17
  windowX: number;
18
+ /**
19
+ * Y position relative to window.
20
+ */
6
21
  windowY: number;
7
22
  } & ({
23
+ /**
24
+ * Cursor has entered to a window.
25
+ */
8
26
  kind: 'Enter';
9
27
  } | {
28
+ /**
29
+ * Cursor left a window.
30
+ */
10
31
  kind: 'Leave';
11
32
  } | {
33
+ /**
34
+ * Cursor button is pressed.
35
+ */
12
36
  kind: 'Action';
37
+ /**
38
+ * Cursor button input state.
39
+ */
13
40
  state: InputState;
41
+ /**
42
+ * True if `state` is `Pressed` and the button is secondly pressed within system double click time.
43
+ */
14
44
  doubleClick: boolean;
45
+ /**
46
+ * Pressed cursor button.
47
+ */
15
48
  action: CursorAction;
16
49
  } | {
50
+ /**
51
+ * Cursor moved.
52
+ */
17
53
  kind: 'Move';
18
54
  } | {
55
+ /**
56
+ * Cursor scrolled.
57
+ */
19
58
  kind: 'Scroll';
59
+ /**
60
+ * Scroll axis.
61
+ */
20
62
  axis: ScrollAxis;
21
63
  /**
22
- * Scroll tick delta
64
+ * Scroll tick delta.
23
65
  */
24
66
  delta: number;
25
67
  });
68
+ /**
69
+ * Describe a keyboard input.
70
+ */
26
71
  export type KeyboardInput = {
72
+ /**
73
+ * A key is pressed or released.
74
+ */
27
75
  kind: 'Key';
76
+ /**
77
+ * Keyboard key without considering keyboard layout.
78
+ */
28
79
  key: Key;
29
80
  /**
30
- * Key input state
81
+ * Keyboard key input state.
31
82
  */
32
83
  state: InputState;
33
84
  } | {
85
+ /**
86
+ * A character input due to a key press without involving IME.
87
+ */
34
88
  kind: 'Char';
89
+ /**
90
+ * Input character (1 character).
91
+ */
35
92
  ch: string;
36
93
  } | {
94
+ /**
95
+ * IME related event.
96
+ */
37
97
  kind: 'Ime';
98
+ /**
99
+ * An IME event.
100
+ */
38
101
  ime: Ime;
39
102
  };
103
+ /**
104
+ * Describe a IME event.
105
+ */
40
106
  export type Ime = {
107
+ /**
108
+ * IME is enabled due to window focus or etc.
109
+ */
41
110
  kind: 'Enabled';
111
+ /**
112
+ * Initial IME language in ETF language tag(BCP 47) format.
113
+ */
42
114
  lang: string;
115
+ /**
116
+ * Initial IME conversion mode.
117
+ */
43
118
  conversion: ImeConversion;
44
119
  } | {
120
+ /**
121
+ * IME language is changed.
122
+ */
45
123
  kind: 'Changed';
46
- /** ETF language tag(BCP 47) */
124
+ /**
125
+ * Changed IME language.
126
+ */
47
127
  lang: string;
48
128
  } | {
129
+ /**
130
+ * IME conversion mode is changed.
131
+ */
49
132
  kind: 'ChangedConversion';
133
+ /**
134
+ * Changed IME conversion mode.
135
+ */
50
136
  conversion: ImeConversion;
51
137
  } | {
138
+ /**
139
+ * IME candidate is added/updated.
140
+ *
141
+ * The sent candidates are only valid until another `CandidateChanged` or `CandidateClosed` event.
142
+ */
52
143
  kind: 'CandidateChanged';
53
144
  list: ImeCandidateList;
54
145
  } | {
146
+ /**
147
+ * IME candidate window is closed.
148
+ */
55
149
  kind: 'CandidateClosed';
56
150
  } | {
151
+ /**
152
+ * IME is composing text.
153
+ */
57
154
  kind: 'Compose';
155
+ /**
156
+ * Composing text.
157
+ */
58
158
  text: string;
159
+ /**
160
+ * Current caret index in composing text.
161
+ */
59
162
  caret: number;
60
163
  } | {
164
+ /**
165
+ * IME commits text.
166
+ *
167
+ * This event should clear prior composing text.
168
+ */
61
169
  kind: 'Commit';
170
+ /**
171
+ * Composed text.
172
+ */
62
173
  text: string;
63
174
  } | {
175
+ /**
176
+ * IME is disabled due to losing focus or etc.
177
+ */
64
178
  kind: 'Disabled';
65
179
  };
180
+ /**
181
+ * IME candidate list.
182
+ */
66
183
  export type ImeCandidateList = {
184
+ /**
185
+ * Start index of current page.
186
+ */
67
187
  pageStartIndex: number;
188
+ /**
189
+ * Count of candidate item per page.
190
+ */
68
191
  pageSize: number;
192
+ /**
193
+ * Currently selected candidate index.
194
+ */
69
195
  selectedIndex: number;
196
+ /**
197
+ * Candidate list.
198
+ */
70
199
  candidates: string[];
71
200
  };
72
- export declare const enum ImeConversion {
201
+ /**
202
+ * IME conversion bit flags.
203
+ *
204
+ * There can be multiple flag set.
205
+ */
206
+ export declare enum ImeConversion {
73
207
  None = 0,
208
+ /**
209
+ * IME converts to native langauge.
210
+ */
74
211
  Native = 1,
212
+ /**
213
+ * IME composes in full-width characters.
214
+ */
75
215
  Fullshape = 2,
216
+ /**
217
+ * Conversion is disabled.
218
+ */
76
219
  NoConversion = 4,
220
+ /**
221
+ * Converting to hanja.
222
+ */
77
223
  HanjaConvert = 8,
224
+ /**
225
+ * Converting to katakana.
226
+ */
78
227
  Katakana = 16
79
228
  }
229
+ /**
230
+ * Key input state.
231
+ */
80
232
  export type InputState = 'Pressed' | 'Released';
233
+ /**
234
+ * Cursor buttons.
235
+ */
81
236
  export type CursorAction = 'Left' | 'Right' | 'Middle' | 'Back' | 'Forward';
237
+ /**
238
+ * Cursor scroll axis.
239
+ */
82
240
  export type ScrollAxis = 'X' | 'Y';
package/lib/input.js CHANGED
@@ -1,9 +1,29 @@
1
+ /**
2
+ * IME conversion bit flags.
3
+ *
4
+ * There can be multiple flag set.
5
+ */
1
6
  export var ImeConversion;
2
7
  (function (ImeConversion) {
3
8
  ImeConversion[ImeConversion["None"] = 0] = "None";
9
+ /**
10
+ * IME converts to native langauge.
11
+ */
4
12
  ImeConversion[ImeConversion["Native"] = 1] = "Native";
13
+ /**
14
+ * IME composes in full-width characters.
15
+ */
5
16
  ImeConversion[ImeConversion["Fullshape"] = 2] = "Fullshape";
17
+ /**
18
+ * Conversion is disabled.
19
+ */
6
20
  ImeConversion[ImeConversion["NoConversion"] = 4] = "NoConversion";
21
+ /**
22
+ * Converting to hanja.
23
+ */
7
24
  ImeConversion[ImeConversion["HanjaConvert"] = 8] = "HanjaConvert";
25
+ /**
26
+ * Converting to katakana.
27
+ */
8
28
  ImeConversion[ImeConversion["Katakana"] = 16] = "Katakana";
9
29
  })(ImeConversion || (ImeConversion = {}));
package/lib/types.d.ts CHANGED
@@ -1,28 +1,66 @@
1
+ /**
2
+ * A length which can be expressed in absolute or relative percent.
3
+ */
1
4
  export type PercentLength = {
2
5
  ty: 'percent' | 'length';
3
6
  value: number;
4
7
  };
8
+ /**
9
+ * Describe a rectangle when copying from source to destination.
10
+ */
5
11
  export type CopyRect = {
12
+ /**
13
+ * Destination X position.
14
+ */
6
15
  dstX: number;
16
+ /**
17
+ * Destination Y position.
18
+ */
7
19
  dstY: number;
20
+ /**
21
+ * Source rectangle.
22
+ */
8
23
  src: Rect;
9
24
  };
25
+ /**
26
+ * Describe a Reactangle.
27
+ */
10
28
  export type Rect = {
29
+ /**
30
+ * X position.
31
+ */
11
32
  x: number;
33
+ /**
34
+ * Y position.
35
+ */
12
36
  y: number;
37
+ /**
38
+ * Width of the Rectangle.
39
+ */
13
40
  width: number;
41
+ /**
42
+ * Height of the Rectangle.
43
+ */
14
44
  height: number;
15
45
  };
46
+ /**
47
+ * A keyboard key.
48
+ */
16
49
  export type Key = {
17
50
  /**
18
- * Windows virtual key code
51
+ * Windows virtual key code.
19
52
  */
20
53
  code: number;
21
54
  /**
22
- * Extended flag
55
+ * Extended flag.
56
+ *
57
+ * True for right key variant (e.g. Right shift), or Numpad variant (e.g. NumPad 1)
23
58
  */
24
59
  extended: boolean;
25
60
  };
61
+ /**
62
+ * Describe a cursor type.
63
+ */
26
64
  export declare enum Cursor {
27
65
  Default = 0,
28
66
  Help = 1,
package/lib/types.js CHANGED
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Describe a cursor type.
3
+ */
1
4
  export var Cursor;
2
5
  (function (Cursor) {
3
6
  Cursor[Cursor["Default"] = 0] = "Default";
@@ -29,7 +32,7 @@ export var Cursor;
29
32
  Cursor[Cursor["Person"] = 25] = "Person";
30
33
  Cursor[Cursor["Pen"] = 26] = "Pen";
31
34
  Cursor[Cursor["Cd"] = 27] = "Cd";
32
- // panning
35
+ // Panning cursors
33
36
  Cursor[Cursor["PanMiddle"] = 28] = "PanMiddle";
34
37
  Cursor[Cursor["PanMiddleHorizontal"] = 29] = "PanMiddleHorizontal";
35
38
  Cursor[Cursor["PanMiddleVertical"] = 30] = "PanMiddleVertical";
package/lib/util.d.ts CHANGED
@@ -1,4 +1,13 @@
1
1
  import { Key, PercentLength } from './index.js';
2
+ /**
3
+ * Utility function to create `PercentLength` using percent relative value.
4
+ */
2
5
  export declare function percent(value: number): PercentLength;
6
+ /**
7
+ * Utilty function to create `PercentLength` using absolute length value.
8
+ */
3
9
  export declare function length(value: number): PercentLength;
10
+ /**
11
+ * Utility function to create `Key` using key code and optional extended flag.
12
+ */
4
13
  export declare function key(code: number, extended?: boolean): Key;
package/lib/util.js CHANGED
@@ -1,15 +1,24 @@
1
+ /**
2
+ * Utility function to create `PercentLength` using percent relative value.
3
+ */
1
4
  export function percent(value) {
2
5
  return {
3
6
  ty: 'percent',
4
7
  value,
5
8
  };
6
9
  }
10
+ /**
11
+ * Utilty function to create `PercentLength` using absolute length value.
12
+ */
7
13
  export function length(value) {
8
14
  return {
9
15
  ty: 'length',
10
16
  value,
11
17
  };
12
18
  }
19
+ /**
20
+ * Utility function to create `Key` using key code and optional extended flag.
21
+ */
13
22
  export function key(code, extended = false) {
14
23
  return {
15
24
  code,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asdf-overlay/core",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Asdf overlay core Node addon",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",