@cryptforge/key-exchange 0.1.0 → 0.2.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/dist/vite.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ /**
4
+ * Vite plugin that automatically externalizes native Node.js modules
5
+ * required by @cryptforge/key-exchange for Electron main process builds.
6
+ *
7
+ * This prevents Vite from trying to bundle native modules, which would fail.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * // vite.main.config.ts
12
+ * import { defineConfig } from "vite";
13
+ * import { cryptforgeMainPlugin } from "@cryptforge/key-exchange/vite";
14
+ *
15
+ * export default defineConfig({
16
+ * plugins: [cryptforgeMainPlugin()],
17
+ * // ... rest of config
18
+ * });
19
+ * ```
20
+ */
21
+ declare const cryptforgeMainPlugin: () => Plugin;
22
+
23
+ export { cryptforgeMainPlugin };
package/dist/vite.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/vite.ts
21
+ var vite_exports = {};
22
+ __export(vite_exports, {
23
+ cryptforgeMainPlugin: () => cryptforgeMainPlugin
24
+ });
25
+ module.exports = __toCommonJS(vite_exports);
26
+ var NATIVE_EXTERNALS = [
27
+ "hyperswarm",
28
+ "hyperdht",
29
+ "udx-native",
30
+ "utp-native",
31
+ "sodium-native",
32
+ "hypercore",
33
+ "hypercore-crypto",
34
+ "random-access-file",
35
+ "compact-encoding",
36
+ "b4a",
37
+ "@cryptforge/key-exchange"
38
+ ];
39
+ var cryptforgeMainPlugin = () => {
40
+ return {
41
+ name: "cryptforge-main-externals",
42
+ enforce: "pre",
43
+ config(config) {
44
+ if (!config.build) {
45
+ config.build = {};
46
+ }
47
+ if (!config.build.rollupOptions) {
48
+ config.build.rollupOptions = {};
49
+ }
50
+ const existingExternal = config.build.rollupOptions.external;
51
+ if (existingExternal) {
52
+ if (typeof existingExternal === "function") {
53
+ config.build.rollupOptions.external = (id, parentId, isResolved) => {
54
+ if (NATIVE_EXTERNALS.some((ext) => id === ext || id.startsWith(ext + "/"))) {
55
+ return true;
56
+ }
57
+ return existingExternal(id, parentId, isResolved);
58
+ };
59
+ } else {
60
+ const existingArray = Array.isArray(existingExternal) ? existingExternal : [existingExternal];
61
+ config.build.rollupOptions.external = [
62
+ ...existingArray,
63
+ ...NATIVE_EXTERNALS
64
+ ];
65
+ }
66
+ } else {
67
+ config.build.rollupOptions.external = NATIVE_EXTERNALS;
68
+ }
69
+ return config;
70
+ }
71
+ };
72
+ };
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ cryptforgeMainPlugin
76
+ });
package/dist/vite.mjs ADDED
@@ -0,0 +1,51 @@
1
+ // src/vite.ts
2
+ var NATIVE_EXTERNALS = [
3
+ "hyperswarm",
4
+ "hyperdht",
5
+ "udx-native",
6
+ "utp-native",
7
+ "sodium-native",
8
+ "hypercore",
9
+ "hypercore-crypto",
10
+ "random-access-file",
11
+ "compact-encoding",
12
+ "b4a",
13
+ "@cryptforge/key-exchange"
14
+ ];
15
+ var cryptforgeMainPlugin = () => {
16
+ return {
17
+ name: "cryptforge-main-externals",
18
+ enforce: "pre",
19
+ config(config) {
20
+ if (!config.build) {
21
+ config.build = {};
22
+ }
23
+ if (!config.build.rollupOptions) {
24
+ config.build.rollupOptions = {};
25
+ }
26
+ const existingExternal = config.build.rollupOptions.external;
27
+ if (existingExternal) {
28
+ if (typeof existingExternal === "function") {
29
+ config.build.rollupOptions.external = (id, parentId, isResolved) => {
30
+ if (NATIVE_EXTERNALS.some((ext) => id === ext || id.startsWith(ext + "/"))) {
31
+ return true;
32
+ }
33
+ return existingExternal(id, parentId, isResolved);
34
+ };
35
+ } else {
36
+ const existingArray = Array.isArray(existingExternal) ? existingExternal : [existingExternal];
37
+ config.build.rollupOptions.external = [
38
+ ...existingArray,
39
+ ...NATIVE_EXTERNALS
40
+ ];
41
+ }
42
+ } else {
43
+ config.build.rollupOptions.external = NATIVE_EXTERNALS;
44
+ }
45
+ return config;
46
+ }
47
+ };
48
+ };
49
+ export {
50
+ cryptforgeMainPlugin
51
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptforge/key-exchange",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Peer-to-peer key exchange and device synchronization for CryptForge",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -45,6 +45,11 @@
45
45
  "types": "./dist/electron-renderer.d.ts",
46
46
  "import": "./dist/electron-renderer.mjs",
47
47
  "require": "./dist/electron-renderer.js"
48
+ },
49
+ "./vite": {
50
+ "types": "./dist/vite.d.ts",
51
+ "import": "./dist/vite.mjs",
52
+ "require": "./dist/vite.js"
48
53
  }
49
54
  },
50
55
  "keywords": [
@@ -75,7 +80,7 @@
75
80
  "test": "echo \"Error: no test specified\" && exit 1"
76
81
  },
77
82
  "dependencies": {
78
- "@cryptforge/core": "^0.1.0",
83
+ "@cryptforge/core": "workspace:*",
79
84
  "b4a": "^1.6.6",
80
85
  "hyperswarm": "^4.8.0",
81
86
  "systeminformation": "^5.23.5",
@@ -85,7 +90,8 @@
85
90
  "@types/node": "^20.10.0",
86
91
  "@types/systeminformation": "^3.54.1",
87
92
  "@types/ws": "^8.5.12",
88
- "electron": "^33.2.1"
93
+ "electron": "^33.2.1",
94
+ "vite": "^5.0.0"
89
95
  },
90
96
  "peerDependencies": {
91
97
  "electron": ">=28.0.0"