@asdf-overlay/core 1.2.5 → 2.0.0
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/addon.win32-arm64-msvc.node +0 -0
- package/addon.win32-ia32-msvc.node +0 -0
- package/addon.win32-x64-msvc.node +0 -0
- package/asdf_overlay-aarch64.dll +0 -0
- package/asdf_overlay-x64.dll +0 -0
- package/asdf_overlay-x86.dll +0 -0
- package/index.d.ts +6 -0
- package/index.js +11 -0
- package/native.d.ts +305 -0
- package/native.js +711 -0
- package/package.json +30 -27
- package/addon-aarch64.node +0 -0
- package/addon-x64.node +0 -0
- package/lib/addon.d.ts +0 -18
- package/lib/addon.js +0 -1
- package/lib/index.d.ts +0 -151
- package/lib/index.js +0 -202
- package/lib/input.d.ts +0 -240
- package/lib/input.js +0 -29
- package/lib/types.d.ts +0 -128
- package/lib/types.js +0 -48
- package/lib/util.d.ts +0 -13
- package/lib/util.js +0 -27
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asdf-overlay/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Asdf overlay core Node addon",
|
|
5
|
-
"main": "
|
|
6
|
-
"
|
|
7
|
-
"author": "storycraft <
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"author": "storycraft <me@pancake.sh>",
|
|
8
8
|
"homepage": "https://github.com/storycraft/asdf-overlay#readme",
|
|
9
9
|
"license": "MIT OR Apache-2.0",
|
|
10
10
|
"bugs": {
|
|
@@ -21,34 +21,37 @@
|
|
|
21
21
|
"x64",
|
|
22
22
|
"arm64"
|
|
23
23
|
],
|
|
24
|
-
"exports": {
|
|
25
|
-
".": {
|
|
26
|
-
"types": "./lib/index.d.ts",
|
|
27
|
-
"default": "./lib/index.js"
|
|
28
|
-
},
|
|
29
|
-
"./*": {
|
|
30
|
-
"types": "./lib/*.d.ts",
|
|
31
|
-
"default": "./lib/*.js"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"types": "./lib/index.d.ts",
|
|
35
24
|
"files": [
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
25
|
+
"index.js",
|
|
26
|
+
"index.d.ts",
|
|
27
|
+
"native.js",
|
|
28
|
+
"native.d.ts",
|
|
29
|
+
"addon.win32-arm64-msvc.node",
|
|
30
|
+
"addon.win32-ia32-msvc.node",
|
|
31
|
+
"addon.win32-x64-msvc.node",
|
|
32
|
+
"asdf_overlay-aarch64.dll",
|
|
39
33
|
"asdf_overlay-x64.dll",
|
|
40
|
-
"asdf_overlay-x86.dll"
|
|
41
|
-
"asdf_overlay-aarch64.dll"
|
|
34
|
+
"asdf_overlay-x86.dll"
|
|
42
35
|
],
|
|
36
|
+
"napi": {
|
|
37
|
+
"binaryName": "addon",
|
|
38
|
+
"targets": [
|
|
39
|
+
"aarch64-pc-windows-msvc",
|
|
40
|
+
"i686-pc-windows-msvc",
|
|
41
|
+
"x86_64-pc-windows-msvc"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0"
|
|
46
|
+
},
|
|
43
47
|
"devDependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
48
|
+
"@napi-rs/cli": "^3.2.0",
|
|
49
|
+
"@types/node": "^22.13.14"
|
|
46
50
|
},
|
|
47
51
|
"scripts": {
|
|
48
|
-
"build
|
|
49
|
-
"
|
|
50
|
-
"build
|
|
51
|
-
"build:
|
|
52
|
-
"build": "npm run cargo-build -- --release && npm run build-dll -- --release && npm run build:dist"
|
|
52
|
+
"build:addon": "node build.mjs",
|
|
53
|
+
"build:dll": "cargo xtask build-dll --",
|
|
54
|
+
"build": "npm run build:dll -- --release && npm run build:addon -- --release",
|
|
55
|
+
"build:debug": "npm run build:dll && npm run build:addon"
|
|
53
56
|
}
|
|
54
57
|
}
|
package/addon-aarch64.node
DELETED
|
Binary file
|
package/addon-x64.node
DELETED
|
Binary file
|
package/lib/addon.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { OverlayEventEmitter } from './index.js';
|
|
2
|
-
import { CopyRect, Cursor, PercentLength, type GpuLuid, type UpdateSharedHandle } from './types.js';
|
|
3
|
-
export type Addon = {
|
|
4
|
-
attach(dllDir: string, pid: number, timeout?: number): Promise<unknown>;
|
|
5
|
-
overlaySetPosition(id: unknown, winId: number, x: PercentLength, y: PercentLength): Promise<void>;
|
|
6
|
-
overlaySetAnchor(id: unknown, winId: number, x: PercentLength, y: PercentLength): Promise<void>;
|
|
7
|
-
overlaySetMargin(id: unknown, winId: number, top: PercentLength, right: PercentLength, bottom: PercentLength, left: PercentLength): Promise<void>;
|
|
8
|
-
overlayUpdateHandle(id: unknown, winId: number, update: UpdateSharedHandle): Promise<void>;
|
|
9
|
-
overlayListenInput(id: unknown, winId: number, cursor: boolean, keyboard: boolean): Promise<void>;
|
|
10
|
-
overlayBlockInput(id: unknown, winId: number, block: boolean): Promise<void>;
|
|
11
|
-
overlaySetBlockingCursor(id: unknown, winId: number, cursor?: Cursor): Promise<void>;
|
|
12
|
-
overlayCallNextEvent(id: unknown, emitter: OverlayEventEmitter, emit: OverlayEventEmitter['emit']): Promise<boolean>;
|
|
13
|
-
overlayDestroy(id: unknown): void;
|
|
14
|
-
surfaceCreate(luid: GpuLuid): unknown;
|
|
15
|
-
surfaceClear(id: unknown): void;
|
|
16
|
-
surfaceUpdateBitmap(id: unknown, width: number, data: Buffer): UpdateSharedHandle | null;
|
|
17
|
-
surfaceUpdateShtex(id: unknown, width: number, height: number, handle: Buffer, rect?: CopyRect): UpdateSharedHandle | null;
|
|
18
|
-
};
|
package/lib/addon.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/index.d.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
|
-
import { CursorInput, KeyboardInput } from './input.js';
|
|
3
|
-
import { PercentLength, CopyRect, Cursor, type UpdateSharedHandle, type GpuLuid } from './types.js';
|
|
4
|
-
export * from './types.js';
|
|
5
|
-
export * from './util.js';
|
|
6
|
-
/**
|
|
7
|
-
* Unique symbol for accessing internal id
|
|
8
|
-
*/
|
|
9
|
-
declare const idSym: unique symbol;
|
|
10
|
-
export type OverlayEventEmitter = EventEmitter<{
|
|
11
|
-
/**
|
|
12
|
-
* A window has been added.
|
|
13
|
-
*/
|
|
14
|
-
added: [id: number, width: number, height: number, luid: GpuLuid];
|
|
15
|
-
/**
|
|
16
|
-
* A window has been resized.
|
|
17
|
-
*/
|
|
18
|
-
resized: [id: number, width: number, height: number];
|
|
19
|
-
/**
|
|
20
|
-
* Cursor input from a window.
|
|
21
|
-
*/
|
|
22
|
-
cursor_input: [id: number, input: CursorInput];
|
|
23
|
-
/**
|
|
24
|
-
* Keyboard input from a window.
|
|
25
|
-
*/
|
|
26
|
-
keyboard_input: [id: number, input: KeyboardInput];
|
|
27
|
-
/**
|
|
28
|
-
* Input blocking to a window is interrupted and turned off.
|
|
29
|
-
*/
|
|
30
|
-
input_blocking_ended: [id: number];
|
|
31
|
-
/**
|
|
32
|
-
* Window is destroyed.
|
|
33
|
-
*/
|
|
34
|
-
destroyed: [id: number];
|
|
35
|
-
/**
|
|
36
|
-
* An error has occured on ipc connection.
|
|
37
|
-
*/
|
|
38
|
-
error: [err: unknown];
|
|
39
|
-
/**
|
|
40
|
-
* Ipc disconnected.
|
|
41
|
-
*/
|
|
42
|
-
disconnected: [];
|
|
43
|
-
}>;
|
|
44
|
-
export declare class Overlay {
|
|
45
|
-
readonly event: OverlayEventEmitter;
|
|
46
|
-
readonly [idSym]: unknown;
|
|
47
|
-
private destroyed;
|
|
48
|
-
private constructor();
|
|
49
|
-
/**
|
|
50
|
-
* Update overlay position relative to window
|
|
51
|
-
* @param id target window id
|
|
52
|
-
* @param x x position
|
|
53
|
-
* @param y y position
|
|
54
|
-
*/
|
|
55
|
-
setPosition(id: number, x: PercentLength, y: PercentLength): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Update overlay anchor
|
|
58
|
-
* @param id target window id
|
|
59
|
-
* @param x x anchor
|
|
60
|
-
* @param y y anchor
|
|
61
|
-
*/
|
|
62
|
-
setAnchor(id: number, x: PercentLength, y: PercentLength): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Update overlay margin
|
|
65
|
-
* @param id target window id
|
|
66
|
-
* @param top top margin
|
|
67
|
-
* @param right right margin
|
|
68
|
-
* @param bottom bottom margin
|
|
69
|
-
* @param left left margin
|
|
70
|
-
*/
|
|
71
|
-
setMargin(id: number, top: PercentLength, right: PercentLength, bottom: PercentLength, left: PercentLength): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Listen to window input without blocking
|
|
74
|
-
* @param id target window id
|
|
75
|
-
* @param cursor listen cursor input or not
|
|
76
|
-
* @param keyboard listen keyboard input or not
|
|
77
|
-
*/
|
|
78
|
-
listenInput(id: number, cursor: boolean, keyboard: boolean): Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* Block window input and listen them
|
|
81
|
-
* @param id target window id
|
|
82
|
-
* @param block set true to block input, false to release
|
|
83
|
-
*/
|
|
84
|
-
blockInput(id: number, block: boolean): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Set cursor while in input blocking mode
|
|
87
|
-
* @param id target window id
|
|
88
|
-
* @param cursor cursor to set. Do not supply this value to hide cursor.
|
|
89
|
-
*/
|
|
90
|
-
setBlockingCursor(id: number, cursor?: Cursor): Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* Update overlay surface.
|
|
93
|
-
* @param id target window id
|
|
94
|
-
* @param update shared handle update
|
|
95
|
-
*/
|
|
96
|
-
updateHandle(id: number, update: UpdateSharedHandle): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Destroy overlay
|
|
99
|
-
*/
|
|
100
|
-
destroy(): void;
|
|
101
|
-
/**
|
|
102
|
-
* Attach overlay to target process
|
|
103
|
-
*
|
|
104
|
-
* Name must be unique or it will fail if there is a connection with same name
|
|
105
|
-
* @param dllDir path to dlls
|
|
106
|
-
* @param pid target process pid
|
|
107
|
-
* @param timeout Timeout for injection, in milliseconds. Will wait indefinitely if not provided.
|
|
108
|
-
* @returns new {@link Overlay} object
|
|
109
|
-
*/
|
|
110
|
-
static attach(dllDir: string, pid: number, timeout?: number): Promise<Overlay>;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Represent a surface for overlay.
|
|
114
|
-
*/
|
|
115
|
-
export declare class OverlaySurface {
|
|
116
|
-
readonly [idSym]: unknown;
|
|
117
|
-
private constructor();
|
|
118
|
-
/**
|
|
119
|
-
* Update surface using bitmap buffer. The size of overlay is `width x (data.byteLength / 4 / width)`
|
|
120
|
-
* @param width width of the bitmap
|
|
121
|
-
* @param data bgra formatted bitmap
|
|
122
|
-
*/
|
|
123
|
-
updateBitmap(width: number, data: Buffer): UpdateSharedHandle | null;
|
|
124
|
-
/**
|
|
125
|
-
* Update surface using D3D11 shared texture.
|
|
126
|
-
* @param width width of the surface
|
|
127
|
-
* @param height height of the surface
|
|
128
|
-
* @param handle NT Handle of shared D3D11 Texture
|
|
129
|
-
* @param rect Area to update
|
|
130
|
-
*/
|
|
131
|
-
updateShtex(width: number, height: number, handle: Buffer, rect?: CopyRect): UpdateSharedHandle | null;
|
|
132
|
-
/**
|
|
133
|
-
* Clear the surface.
|
|
134
|
-
*/
|
|
135
|
-
clear(): void;
|
|
136
|
-
/**
|
|
137
|
-
* @deprecated Do not need to be called.
|
|
138
|
-
*
|
|
139
|
-
* Destroy the surface.
|
|
140
|
-
*/
|
|
141
|
-
destroy(): void;
|
|
142
|
-
/**
|
|
143
|
-
* Create a new overlay surface.
|
|
144
|
-
* @param luid The GPU LUID for surface textures.
|
|
145
|
-
*/
|
|
146
|
-
static create(luid: GpuLuid): OverlaySurface;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Default dll directory path
|
|
150
|
-
*/
|
|
151
|
-
export declare function defaultDllDir(): string;
|
package/lib/index.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { arch } from 'node:process';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { EventEmitter } from 'node:events';
|
|
5
|
-
export * from './types.js';
|
|
6
|
-
export * from './util.js';
|
|
7
|
-
/**
|
|
8
|
-
* Global node addon instance
|
|
9
|
-
*/
|
|
10
|
-
const addon = loadAddon();
|
|
11
|
-
/**
|
|
12
|
-
* Load node addon depending on system architecture.
|
|
13
|
-
*/
|
|
14
|
-
function loadAddon() {
|
|
15
|
-
const nodeModule = { exports: {} };
|
|
16
|
-
let name;
|
|
17
|
-
switch (arch) {
|
|
18
|
-
case 'arm64': {
|
|
19
|
-
name = '../addon-aarch64.node';
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
case 'x64': {
|
|
23
|
-
name = '../addon-x64.node';
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
default: throw new Error(`Unsupported arch: ${arch}`);
|
|
27
|
-
}
|
|
28
|
-
process.dlopen(nodeModule, path.resolve(path.dirname(fileURLToPath(new URL(import.meta.url))), name));
|
|
29
|
-
return nodeModule.exports;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Unique symbol for accessing internal id
|
|
33
|
-
*/
|
|
34
|
-
const idSym = Symbol('id');
|
|
35
|
-
export class Overlay {
|
|
36
|
-
event = new EventEmitter();
|
|
37
|
-
[idSym];
|
|
38
|
-
destroyed = false;
|
|
39
|
-
constructor(id) {
|
|
40
|
-
this[idSym] = id;
|
|
41
|
-
void (async () => {
|
|
42
|
-
// wait until next tick so no events are lost
|
|
43
|
-
await new Promise((resolve) => {
|
|
44
|
-
process.nextTick(resolve);
|
|
45
|
-
});
|
|
46
|
-
try {
|
|
47
|
-
for (;;) {
|
|
48
|
-
const hasNext = await addon.overlayCallNextEvent(id, this.event, (name, ...args) => this.event.emit(name, ...args));
|
|
49
|
-
if (!hasNext)
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
if (this.event.listenerCount('error') != 0) {
|
|
55
|
-
this.event.emit('error', err);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
throw err;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
finally {
|
|
62
|
-
this.destroy();
|
|
63
|
-
}
|
|
64
|
-
})();
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Update overlay position relative to window
|
|
68
|
-
* @param id target window id
|
|
69
|
-
* @param x x position
|
|
70
|
-
* @param y y position
|
|
71
|
-
*/
|
|
72
|
-
async setPosition(id, x, y) {
|
|
73
|
-
await addon.overlaySetPosition(this[idSym], id, x, y);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Update overlay anchor
|
|
77
|
-
* @param id target window id
|
|
78
|
-
* @param x x anchor
|
|
79
|
-
* @param y y anchor
|
|
80
|
-
*/
|
|
81
|
-
async setAnchor(id, x, y) {
|
|
82
|
-
await addon.overlaySetAnchor(this[idSym], id, x, y);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Update overlay margin
|
|
86
|
-
* @param id target window id
|
|
87
|
-
* @param top top margin
|
|
88
|
-
* @param right right margin
|
|
89
|
-
* @param bottom bottom margin
|
|
90
|
-
* @param left left margin
|
|
91
|
-
*/
|
|
92
|
-
async setMargin(id, top, right, bottom, left) {
|
|
93
|
-
await addon.overlaySetMargin(this[idSym], id, top, right, bottom, left);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Listen to window input without blocking
|
|
97
|
-
* @param id target window id
|
|
98
|
-
* @param cursor listen cursor input or not
|
|
99
|
-
* @param keyboard listen keyboard input or not
|
|
100
|
-
*/
|
|
101
|
-
async listenInput(id, cursor, keyboard) {
|
|
102
|
-
await addon.overlayListenInput(this[idSym], id, cursor, keyboard);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Block window input and listen them
|
|
106
|
-
* @param id target window id
|
|
107
|
-
* @param block set true to block input, false to release
|
|
108
|
-
*/
|
|
109
|
-
async blockInput(id, block) {
|
|
110
|
-
await addon.overlayBlockInput(this[idSym], id, block);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Set cursor while in input blocking mode
|
|
114
|
-
* @param id target window id
|
|
115
|
-
* @param cursor cursor to set. Do not supply this value to hide cursor.
|
|
116
|
-
*/
|
|
117
|
-
async setBlockingCursor(id, cursor) {
|
|
118
|
-
await addon.overlaySetBlockingCursor(this[idSym], id, cursor);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Update overlay surface.
|
|
122
|
-
* @param id target window id
|
|
123
|
-
* @param update shared handle update
|
|
124
|
-
*/
|
|
125
|
-
async updateHandle(id, update) {
|
|
126
|
-
await addon.overlayUpdateHandle(this[idSym], id, update);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Destroy overlay
|
|
130
|
-
*/
|
|
131
|
-
destroy() {
|
|
132
|
-
if (this.destroyed)
|
|
133
|
-
return;
|
|
134
|
-
this.destroyed = true;
|
|
135
|
-
addon.overlayDestroy(this[idSym]);
|
|
136
|
-
this.event.emit('disconnected');
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Attach overlay to target process
|
|
140
|
-
*
|
|
141
|
-
* Name must be unique or it will fail if there is a connection with same name
|
|
142
|
-
* @param dllDir path to dlls
|
|
143
|
-
* @param pid target process pid
|
|
144
|
-
* @param timeout Timeout for injection, in milliseconds. Will wait indefinitely if not provided.
|
|
145
|
-
* @returns new {@link Overlay} object
|
|
146
|
-
*/
|
|
147
|
-
static async attach(dllDir, pid, timeout) {
|
|
148
|
-
return new Overlay(await addon.attach(dllDir, pid, timeout));
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Represent a surface for overlay.
|
|
153
|
-
*/
|
|
154
|
-
export class OverlaySurface {
|
|
155
|
-
[idSym];
|
|
156
|
-
constructor(id) {
|
|
157
|
-
this[idSym] = id;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Update surface using bitmap buffer. The size of overlay is `width x (data.byteLength / 4 / width)`
|
|
161
|
-
* @param width width of the bitmap
|
|
162
|
-
* @param data bgra formatted bitmap
|
|
163
|
-
*/
|
|
164
|
-
updateBitmap(width, data) {
|
|
165
|
-
return addon.surfaceUpdateBitmap(this[idSym], width, data);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Update surface using D3D11 shared texture.
|
|
169
|
-
* @param width width of the surface
|
|
170
|
-
* @param height height of the surface
|
|
171
|
-
* @param handle NT Handle of shared D3D11 Texture
|
|
172
|
-
* @param rect Area to update
|
|
173
|
-
*/
|
|
174
|
-
updateShtex(width, height, handle, rect) {
|
|
175
|
-
return addon.surfaceUpdateShtex(this[idSym], width, height, handle, rect);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Clear the surface.
|
|
179
|
-
*/
|
|
180
|
-
clear() {
|
|
181
|
-
addon.surfaceClear(this[idSym]);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* @deprecated Do not need to be called.
|
|
185
|
-
*
|
|
186
|
-
* Destroy the surface.
|
|
187
|
-
*/
|
|
188
|
-
destroy() { }
|
|
189
|
-
/**
|
|
190
|
-
* Create a new overlay surface.
|
|
191
|
-
* @param luid The GPU LUID for surface textures.
|
|
192
|
-
*/
|
|
193
|
-
static create(luid) {
|
|
194
|
-
return new OverlaySurface(addon.surfaceCreate(luid));
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Default dll directory path
|
|
199
|
-
*/
|
|
200
|
-
export function defaultDllDir() {
|
|
201
|
-
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../');
|
|
202
|
-
}
|
package/lib/input.d.ts
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { Key } from './index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Describe a cursor input.
|
|
4
|
-
*/
|
|
5
|
-
export type CursorInput = {
|
|
6
|
-
/**
|
|
7
|
-
* X position relative to overlay surface.
|
|
8
|
-
*/
|
|
9
|
-
clientX: number;
|
|
10
|
-
/**
|
|
11
|
-
* Y position relative to overlay surface.
|
|
12
|
-
*/
|
|
13
|
-
clientY: number;
|
|
14
|
-
/**
|
|
15
|
-
* X position relative to window.
|
|
16
|
-
*/
|
|
17
|
-
windowX: number;
|
|
18
|
-
/**
|
|
19
|
-
* Y position relative to window.
|
|
20
|
-
*/
|
|
21
|
-
windowY: number;
|
|
22
|
-
} & ({
|
|
23
|
-
/**
|
|
24
|
-
* Cursor has entered to a window.
|
|
25
|
-
*/
|
|
26
|
-
kind: 'Enter';
|
|
27
|
-
} | {
|
|
28
|
-
/**
|
|
29
|
-
* Cursor left a window.
|
|
30
|
-
*/
|
|
31
|
-
kind: 'Leave';
|
|
32
|
-
} | {
|
|
33
|
-
/**
|
|
34
|
-
* Cursor button is pressed.
|
|
35
|
-
*/
|
|
36
|
-
kind: 'Action';
|
|
37
|
-
/**
|
|
38
|
-
* Cursor button input state.
|
|
39
|
-
*/
|
|
40
|
-
state: InputState;
|
|
41
|
-
/**
|
|
42
|
-
* True if `state` is `Pressed` and the button is secondly pressed within system double click time.
|
|
43
|
-
*/
|
|
44
|
-
doubleClick: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Pressed cursor button.
|
|
47
|
-
*/
|
|
48
|
-
action: CursorAction;
|
|
49
|
-
} | {
|
|
50
|
-
/**
|
|
51
|
-
* Cursor moved.
|
|
52
|
-
*/
|
|
53
|
-
kind: 'Move';
|
|
54
|
-
} | {
|
|
55
|
-
/**
|
|
56
|
-
* Cursor scrolled.
|
|
57
|
-
*/
|
|
58
|
-
kind: 'Scroll';
|
|
59
|
-
/**
|
|
60
|
-
* Scroll axis.
|
|
61
|
-
*/
|
|
62
|
-
axis: ScrollAxis;
|
|
63
|
-
/**
|
|
64
|
-
* Scroll tick delta.
|
|
65
|
-
*/
|
|
66
|
-
delta: number;
|
|
67
|
-
});
|
|
68
|
-
/**
|
|
69
|
-
* Describe a keyboard input.
|
|
70
|
-
*/
|
|
71
|
-
export type KeyboardInput = {
|
|
72
|
-
/**
|
|
73
|
-
* A key is pressed or released.
|
|
74
|
-
*/
|
|
75
|
-
kind: 'Key';
|
|
76
|
-
/**
|
|
77
|
-
* Keyboard key without considering keyboard layout.
|
|
78
|
-
*/
|
|
79
|
-
key: Key;
|
|
80
|
-
/**
|
|
81
|
-
* Keyboard key input state.
|
|
82
|
-
*/
|
|
83
|
-
state: InputState;
|
|
84
|
-
} | {
|
|
85
|
-
/**
|
|
86
|
-
* A character input due to a key press without involving IME.
|
|
87
|
-
*/
|
|
88
|
-
kind: 'Char';
|
|
89
|
-
/**
|
|
90
|
-
* Input character (1 character).
|
|
91
|
-
*/
|
|
92
|
-
ch: string;
|
|
93
|
-
} | {
|
|
94
|
-
/**
|
|
95
|
-
* IME related event.
|
|
96
|
-
*/
|
|
97
|
-
kind: 'Ime';
|
|
98
|
-
/**
|
|
99
|
-
* An IME event.
|
|
100
|
-
*/
|
|
101
|
-
ime: Ime;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Describe a IME event.
|
|
105
|
-
*/
|
|
106
|
-
export type Ime = {
|
|
107
|
-
/**
|
|
108
|
-
* IME is enabled due to window focus or etc.
|
|
109
|
-
*/
|
|
110
|
-
kind: 'Enabled';
|
|
111
|
-
/**
|
|
112
|
-
* Initial IME language in ETF language tag(BCP 47) format.
|
|
113
|
-
*/
|
|
114
|
-
lang: string;
|
|
115
|
-
/**
|
|
116
|
-
* Initial IME conversion mode.
|
|
117
|
-
*/
|
|
118
|
-
conversion: ImeConversion;
|
|
119
|
-
} | {
|
|
120
|
-
/**
|
|
121
|
-
* IME language is changed.
|
|
122
|
-
*/
|
|
123
|
-
kind: 'Changed';
|
|
124
|
-
/**
|
|
125
|
-
* Changed IME language.
|
|
126
|
-
*/
|
|
127
|
-
lang: string;
|
|
128
|
-
} | {
|
|
129
|
-
/**
|
|
130
|
-
* IME conversion mode is changed.
|
|
131
|
-
*/
|
|
132
|
-
kind: 'ChangedConversion';
|
|
133
|
-
/**
|
|
134
|
-
* Changed IME conversion mode.
|
|
135
|
-
*/
|
|
136
|
-
conversion: ImeConversion;
|
|
137
|
-
} | {
|
|
138
|
-
/**
|
|
139
|
-
* IME candidate is added/updated.
|
|
140
|
-
*
|
|
141
|
-
* The sent candidates are only valid until another `CandidateChanged` or `CandidateClosed` event.
|
|
142
|
-
*/
|
|
143
|
-
kind: 'CandidateChanged';
|
|
144
|
-
list: ImeCandidateList;
|
|
145
|
-
} | {
|
|
146
|
-
/**
|
|
147
|
-
* IME candidate window is closed.
|
|
148
|
-
*/
|
|
149
|
-
kind: 'CandidateClosed';
|
|
150
|
-
} | {
|
|
151
|
-
/**
|
|
152
|
-
* IME is composing text.
|
|
153
|
-
*/
|
|
154
|
-
kind: 'Compose';
|
|
155
|
-
/**
|
|
156
|
-
* Composing text.
|
|
157
|
-
*/
|
|
158
|
-
text: string;
|
|
159
|
-
/**
|
|
160
|
-
* Current caret index in composing text.
|
|
161
|
-
*/
|
|
162
|
-
caret: number;
|
|
163
|
-
} | {
|
|
164
|
-
/**
|
|
165
|
-
* IME commits text.
|
|
166
|
-
*
|
|
167
|
-
* This event should clear prior composing text.
|
|
168
|
-
*/
|
|
169
|
-
kind: 'Commit';
|
|
170
|
-
/**
|
|
171
|
-
* Composed text.
|
|
172
|
-
*/
|
|
173
|
-
text: string;
|
|
174
|
-
} | {
|
|
175
|
-
/**
|
|
176
|
-
* IME is disabled due to losing focus or etc.
|
|
177
|
-
*/
|
|
178
|
-
kind: 'Disabled';
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* IME candidate list.
|
|
182
|
-
*/
|
|
183
|
-
export type ImeCandidateList = {
|
|
184
|
-
/**
|
|
185
|
-
* Start index of current page.
|
|
186
|
-
*/
|
|
187
|
-
pageStartIndex: number;
|
|
188
|
-
/**
|
|
189
|
-
* Count of candidate item per page.
|
|
190
|
-
*/
|
|
191
|
-
pageSize: number;
|
|
192
|
-
/**
|
|
193
|
-
* Currently selected candidate index.
|
|
194
|
-
*/
|
|
195
|
-
selectedIndex: number;
|
|
196
|
-
/**
|
|
197
|
-
* Candidate list.
|
|
198
|
-
*/
|
|
199
|
-
candidates: string[];
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* IME conversion bit flags.
|
|
203
|
-
*
|
|
204
|
-
* There can be multiple flag set.
|
|
205
|
-
*/
|
|
206
|
-
export declare enum ImeConversion {
|
|
207
|
-
None = 0,
|
|
208
|
-
/**
|
|
209
|
-
* IME converts to native langauge.
|
|
210
|
-
*/
|
|
211
|
-
Native = 1,
|
|
212
|
-
/**
|
|
213
|
-
* IME composes in full-width characters.
|
|
214
|
-
*/
|
|
215
|
-
Fullshape = 2,
|
|
216
|
-
/**
|
|
217
|
-
* Conversion is disabled.
|
|
218
|
-
*/
|
|
219
|
-
NoConversion = 4,
|
|
220
|
-
/**
|
|
221
|
-
* Converting to hanja.
|
|
222
|
-
*/
|
|
223
|
-
HanjaConvert = 8,
|
|
224
|
-
/**
|
|
225
|
-
* Converting to katakana.
|
|
226
|
-
*/
|
|
227
|
-
Katakana = 16
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Key input state.
|
|
231
|
-
*/
|
|
232
|
-
export type InputState = 'Pressed' | 'Released';
|
|
233
|
-
/**
|
|
234
|
-
* Cursor buttons.
|
|
235
|
-
*/
|
|
236
|
-
export type CursorAction = 'Left' | 'Right' | 'Middle' | 'Back' | 'Forward';
|
|
237
|
-
/**
|
|
238
|
-
* Cursor scroll axis.
|
|
239
|
-
*/
|
|
240
|
-
export type ScrollAxis = 'X' | 'Y';
|