@proton-app/preload 0.0.5 → 0.0.6

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/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { type IpcSchema, type IpcApi } from "./ipc";
2
- type SetupOptions<T extends Record<string, IpcSchema>> = {
2
+ type SetupOptions<T extends Record<string, IpcSchema>, K extends readonly string[]> = {
3
3
  ipc: T;
4
- env: readonly string[];
4
+ env: K;
5
5
  };
6
- export declare function setupPreload<T extends Record<string, IpcSchema>, const K extends readonly string[]>({ ipc, env }: SetupOptions<T>): void;
6
+ export declare function setupPreload<T extends Record<string, IpcSchema>, const K extends readonly string[]>({ ipc, env }: SetupOptions<T, K>): void;
7
7
  export type PreloadWindow<T extends Record<string, IpcSchema>, K extends readonly string[]> = IpcApi<T> & {
8
8
  env: {
9
- [P in K[number]]: string | undefined;
9
+ [P in K[number]]: string;
10
10
  };
11
11
  };
12
12
  export * from "./ipc";
package/dist/index.js CHANGED
@@ -19,6 +19,16 @@ const electron_1 = require("electron");
19
19
  const ipc_1 = require("./ipc");
20
20
  function setupPreload({ ipc, env }) {
21
21
  (0, ipc_1.setupIpcBridge)(ipc);
22
- electron_1.contextBridge.exposeInMainWorld("env", Object.fromEntries(env.map(key => [key, process.env[key]])));
22
+ electron_1.contextBridge.exposeInMainWorld("env", buildEnv(env));
23
+ }
24
+ function buildEnv(keys) {
25
+ const entries = keys.map((key) => {
26
+ const value = process.env[key];
27
+ if (value === undefined) {
28
+ throw new Error(`Missing required env var: ${key}`);
29
+ }
30
+ return [key, value];
31
+ });
32
+ return Object.fromEntries(entries);
23
33
  }
24
34
  __exportStar(require("./ipc"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@proton-app/preload",
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "description": "",
6
6
  "keywords": [],
7
7
  "author": "",