@bouko/electron 1.1.6 → 1.1.7

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.
@@ -33,3 +33,4 @@ export function setupAppIpc() {
33
33
  });
34
34
  });
35
35
  }
36
+ export * from "./manager";
@@ -0,0 +1,34 @@
1
+ export class IpcMainManager {
2
+ adapter;
3
+ delimiter;
4
+ ipc;
5
+ constructor(adapter, delimiter = ":") {
6
+ this.adapter = adapter;
7
+ this.delimiter = delimiter;
8
+ this.ipc = new Proxy({}, { get: (_t, ns) => this.makeNamespace(ns) });
9
+ }
10
+ makeNamespace(ns) {
11
+ const ch = (key) => `${ns}${this.delimiter}${key}`;
12
+ return {
13
+ on: (key, handler) => {
14
+ this.adapter.handle(ch(key), (...args) => handler(...args));
15
+ }
16
+ };
17
+ }
18
+ }
19
+ export class IpcRendererManager {
20
+ adapter;
21
+ delimiter;
22
+ ipc;
23
+ constructor(adapter, delimiter = ":") {
24
+ this.adapter = adapter;
25
+ this.delimiter = delimiter;
26
+ this.ipc = new Proxy({}, { get: (_t, ns) => this.makeNamespace(ns) });
27
+ }
28
+ makeNamespace(ns) {
29
+ const ch = (key) => `${ns}${this.delimiter}${key}`;
30
+ return {
31
+ call: (key, ...args) => this.adapter.invoke(ch(key), ...args),
32
+ };
33
+ }
34
+ }
@@ -1,4 +1,4 @@
1
1
  import { app } from "electron";
2
2
  import { join } from "path";
3
- export const getUserDataPath = (x) => join(app.getPath("userData"), x);
4
- export const getAppDataPath = (x) => join(app.getPath("appData"), x);
3
+ export const getUserDataPath = (...segments) => join(app.getPath("userData"), ...segments);
4
+ export const getAppDataPath = (...segments) => join(app.getPath("appData"), ...segments);
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference path="./ipc.d.ts" />
2
+ import "./ipc";
2
3
  export * from "./communication";
3
4
  export * from "./csp";
4
5
  export * from "./files/_";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/electron",
4
- "version": "1.1.6",
4
+ "version": "1.1.7",
5
5
  "description": "",
6
6
  "keywords": [],
7
7
  "author": "",