@asdf-overlay/electron 0.9.1 → 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.
package/lib/index.d.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  import type { Overlay } from '@asdf-overlay/core';
2
+ /**
3
+ * Describe a window in `Overlay`.
4
+ */
2
5
  export type OverlayWindow = {
6
+ /**
7
+ * Associated `Overlay` instance.
8
+ */
3
9
  overlay: Overlay;
10
+ /**
11
+ * Window id.
12
+ */
4
13
  id: number;
5
14
  };
@@ -1,3 +1,17 @@
1
1
  import { Cursor } from '@asdf-overlay/core';
2
+ /**
3
+ * Map CSS cursor into overlay `Cursor`.
4
+ *
5
+ * Invalid CSS cursors will be mapped to `Default`.
6
+ *
7
+ * @see https://developer.mozilla.org/ko/docs/Web/CSS/cursor
8
+ * @see https://www.electronjs.org/docs/latest/api/web-contents
9
+ */
2
10
  export declare function mapCssCursor(cursor: string): Cursor | undefined;
11
+ /**
12
+ * Map Windows virtual key code into Electron accelerator keycode.
13
+ *
14
+ * @see https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
15
+ * @see https://www.electronjs.org/docs/latest/api/accelerator
16
+ */
3
17
  export declare function mapKeycode(code: number): string | undefined;
package/lib/input/conv.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import { Cursor } from '@asdf-overlay/core';
2
- // https://www.electronjs.org/docs/latest/api/web-contents
3
- // https://developer.mozilla.org/ko/docs/Web/CSS/cursor
2
+ /**
3
+ * Map CSS cursor into overlay `Cursor`.
4
+ *
5
+ * Invalid CSS cursors will be mapped to `Default`.
6
+ *
7
+ * @see https://developer.mozilla.org/ko/docs/Web/CSS/cursor
8
+ * @see https://www.electronjs.org/docs/latest/api/web-contents
9
+ */
4
10
  export function mapCssCursor(cursor) {
5
11
  switch (cursor) {
6
12
  case 'pointer': return Cursor.Default;
@@ -50,11 +56,18 @@ export function mapCssCursor(cursor) {
50
56
  default: return Cursor.Default;
51
57
  }
52
58
  }
59
+ /**
60
+ * Map Windows virtual key code into Electron accelerator keycode.
61
+ *
62
+ * @see https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
63
+ * @see https://www.electronjs.org/docs/latest/api/accelerator
64
+ */
53
65
  export function mapKeycode(code) {
54
66
  return KEYS[code];
55
67
  }
56
- // As per https://www.electronjs.org/docs/latest/api/accelerator
57
- // and https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
68
+ /**
69
+ * Conversion map from windows keycode to Electron accelerator keycode.
70
+ */
58
71
  const KEYS = {
59
72
  8: 'Backspace',
60
73
  9: 'Tab',
package/lib/input.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { WebContents } from 'electron';
2
2
  import type { OverlayWindow } from './index.js';
3
3
  import type { CursorInput, KeyboardInput } from '@asdf-overlay/core/input';
4
+ /**
5
+ * Connection from a overlay window to a Electron window.
6
+ */
4
7
  export declare class ElectronOverlayInput {
5
8
  private readonly window;
6
9
  private readonly contents;
@@ -8,7 +11,13 @@ export declare class ElectronOverlayInput {
8
11
  private readonly keyboardInputHandler;
9
12
  private readonly cursorChangedHandler;
10
13
  private constructor();
14
+ /**
15
+ * Connect overlay inputs to a Electron `WebContents`.
16
+ */
11
17
  static connect(window: OverlayWindow, contents: WebContents): ElectronOverlayInput;
18
+ /**
19
+ * Disconnect overlay inputs.
20
+ */
12
21
  disconnect(): Promise<void>;
13
22
  private readonly clickCounts;
14
23
  private processCursorAction;
package/lib/input.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import { mapCssCursor, mapKeycode } from './input/conv.js';
2
2
  import { Cursor } from '@asdf-overlay/core';
3
+ /**
4
+ * Connection from a overlay window to a Electron window.
5
+ */
3
6
  export class ElectronOverlayInput {
4
7
  window;
5
8
  contents;
@@ -26,9 +29,15 @@ export class ElectronOverlayInput {
26
29
  void this.window.overlay.setBlockingCursor(this.window.id, mapCssCursor(type));
27
30
  });
28
31
  }
32
+ /**
33
+ * Connect overlay inputs to a Electron `WebContents`.
34
+ */
29
35
  static connect(window, contents) {
30
36
  return new ElectronOverlayInput({ ...window }, contents);
31
37
  }
38
+ /**
39
+ * Disconnect overlay inputs.
40
+ */
32
41
  async disconnect() {
33
42
  this.window.overlay.event.off('cursor_input', this.cursorInputHandler);
34
43
  this.window.overlay.event.off('keyboard_input', this.keyboardInputHandler);
package/lib/surface.d.ts CHANGED
@@ -2,17 +2,38 @@ import type { WebContents } from 'electron';
2
2
  import type { OverlayWindow } from './index.js';
3
3
  import EventEmitter from 'node:events';
4
4
  type Emitter = EventEmitter<{
5
+ /**
6
+ * An error has been occured while copying to overlay surface.
7
+ */
5
8
  error: [e: unknown];
6
9
  }>;
10
+ /**
11
+ * Connection from a Electron offscreen window to a overlay surface.
12
+ */
7
13
  export declare class ElectronOverlaySurface {
8
14
  private readonly window;
9
15
  private readonly contents;
16
+ /**
17
+ * Events during paints.
18
+ */
10
19
  readonly events: Emitter;
11
20
  private handler;
12
21
  private constructor();
22
+ /**
23
+ * Connect Electron `WebContents` surface to target overlay window.
24
+ */
13
25
  static connect(window: OverlayWindow, contents: WebContents): ElectronOverlaySurface;
26
+ /**
27
+ * Disconnect surface from Electron window and clear overlay surface.
28
+ */
14
29
  disconnect(): Promise<void>;
30
+ /**
31
+ * Copy overlay texture in gpu accelerated shared texture mode.
32
+ */
15
33
  private paintAccelerated;
34
+ /**
35
+ * Copy overlay texture from bitmap surface.
36
+ */
16
37
  private paintSoftware;
17
38
  private emitError;
18
39
  }
package/lib/surface.js CHANGED
@@ -1,7 +1,13 @@
1
1
  import EventEmitter from 'node:events';
2
+ /**
3
+ * Connection from a Electron offscreen window to a overlay surface.
4
+ */
2
5
  export class ElectronOverlaySurface {
3
6
  window;
4
7
  contents;
8
+ /**
9
+ * Events during paints.
10
+ */
5
11
  events = new EventEmitter();
6
12
  handler;
7
13
  constructor(window, contents) {
@@ -26,13 +32,22 @@ export class ElectronOverlaySurface {
26
32
  contents.on('paint', this.handler);
27
33
  contents.invalidate();
28
34
  }
35
+ /**
36
+ * Connect Electron `WebContents` surface to target overlay window.
37
+ */
29
38
  static connect(window, contents) {
30
39
  return new ElectronOverlaySurface({ ...window }, contents);
31
40
  }
41
+ /**
42
+ * Disconnect surface from Electron window and clear overlay surface.
43
+ */
32
44
  async disconnect() {
33
45
  this.contents.off('paint', this.handler);
34
46
  await this.window.overlay.clearSurface(this.window.id);
35
47
  }
48
+ /**
49
+ * Copy overlay texture in gpu accelerated shared texture mode.
50
+ */
36
51
  async paintAccelerated(texture) {
37
52
  const rect = texture.metadata.captureUpdateRect ?? texture.contentRect;
38
53
  // update only changed part
@@ -47,6 +62,9 @@ export class ElectronOverlaySurface {
47
62
  this.emitError(e);
48
63
  }
49
64
  }
65
+ /**
66
+ * Copy overlay texture from bitmap surface.
67
+ */
50
68
  async paintSoftware(_dirtyRect, image) {
51
69
  // TODO:: update only changed part
52
70
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asdf-overlay/electron",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Asdf overlay Electron integration",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "peerDependencies": {
36
36
  "electron": "^37.3.1",
37
- "@asdf-overlay/core": "0.9.0"
37
+ "@asdf-overlay/core": "0.9.2"
38
38
  },
39
39
  "scripts": {
40
40
  "build:dist": "tsc",