@nativewindow/webview 0.1.1
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/LICENSE +21 -0
- package/README.md +341 -0
- package/dist/index.d.ts +268 -0
- package/dist/index.js +406 -0
- package/native-window.d.ts +264 -0
- package/native-window.js +62 -0
- package/package.json +77 -0
package/native-window.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// JS loader for the native addon.
|
|
3
|
+
// Tries local .node files first (development), then per-platform npm packages (production).
|
|
4
|
+
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const { platform, arch } = process;
|
|
9
|
+
|
|
10
|
+
const platforms = {
|
|
11
|
+
"darwin-arm64": {
|
|
12
|
+
pkg: "@nativewindow/webview-darwin-arm64",
|
|
13
|
+
file: "native-window.darwin-arm64.node",
|
|
14
|
+
},
|
|
15
|
+
"darwin-x64": {
|
|
16
|
+
pkg: "@nativewindow/webview-darwin-x64",
|
|
17
|
+
file: "native-window.darwin-x64.node",
|
|
18
|
+
},
|
|
19
|
+
"win32-x64": {
|
|
20
|
+
pkg: "@nativewindow/webview-win32-x64-msvc",
|
|
21
|
+
file: "native-window.win32-x64-msvc.node",
|
|
22
|
+
},
|
|
23
|
+
"win32-arm64": {
|
|
24
|
+
pkg: "@nativewindow/webview-win32-arm64-msvc",
|
|
25
|
+
file: "native-window.win32-arm64-msvc.node",
|
|
26
|
+
},
|
|
27
|
+
"linux-x64": {
|
|
28
|
+
pkg: "@nativewindow/webview-linux-x64-gnu",
|
|
29
|
+
file: "native-window.linux-x64-gnu.node",
|
|
30
|
+
},
|
|
31
|
+
"linux-arm64": {
|
|
32
|
+
pkg: "@nativewindow/webview-linux-arm64-gnu",
|
|
33
|
+
file: "native-window.linux-arm64-gnu.node",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const key = `${platform}-${arch}`;
|
|
38
|
+
const entry = platforms[key];
|
|
39
|
+
|
|
40
|
+
if (!entry) {
|
|
41
|
+
throw new Error(`Unsupported platform: ${key}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const tryRequire = (id) => {
|
|
45
|
+
try {
|
|
46
|
+
return require(id);
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const nativeBinding = tryRequire(`./${entry.file}`) ?? tryRequire(entry.pkg);
|
|
53
|
+
|
|
54
|
+
if (!nativeBinding) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Failed to load native binding for platform: ${key}. ` +
|
|
57
|
+
`Ensure the correct platform package is installed or the .node file exists.`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const { NativeWindow, init, pumpEvents, checkRuntime, ensureRuntime, loadHtmlOrigin } =
|
|
62
|
+
nativeBinding;
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nativewindow/webview",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Native OS webview windows for Bun & Node.js (alpha)",
|
|
5
|
+
"homepage": "https://nativewindow.fcannizzaro.com",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/nativewindow/webview/issues"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Francesco Saverio Cannizzaro (fcannizzaro)",
|
|
12
|
+
"url": "https://fcannizzaro.com"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/nativewindow/webview"
|
|
17
|
+
},
|
|
18
|
+
"funding": [
|
|
19
|
+
{
|
|
20
|
+
"type": "patreon",
|
|
21
|
+
"url": "https://www.patreon.com/fcannizzaro"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"native-window.js",
|
|
27
|
+
"native-window.d.ts",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"type": "module",
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "napi build --release --platform && vite build",
|
|
42
|
+
"build:debug": "napi build --platform && vite build",
|
|
43
|
+
"build:ts": "vite build",
|
|
44
|
+
"version": "napi version"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"zod": "^4.3.6"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@napi-rs/cli": "^3.0.0",
|
|
51
|
+
"@types/bun": "^1.3.9",
|
|
52
|
+
"vite": "^7.3.1",
|
|
53
|
+
"vite-plugin-dts": "^4.5.4"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"typescript": "^5"
|
|
57
|
+
},
|
|
58
|
+
"optionalDependencies": {
|
|
59
|
+
"@nativewindow/webview-darwin-arm64": "0.1.1",
|
|
60
|
+
"@nativewindow/webview-darwin-x64": "0.1.1",
|
|
61
|
+
"@nativewindow/webview-linux-arm64-gnu": "0.1.1",
|
|
62
|
+
"@nativewindow/webview-linux-x64-gnu": "0.1.1",
|
|
63
|
+
"@nativewindow/webview-win32-arm64-msvc": "0.1.1",
|
|
64
|
+
"@nativewindow/webview-win32-x64-msvc": "0.1.1"
|
|
65
|
+
},
|
|
66
|
+
"napi": {
|
|
67
|
+
"binaryName": "native-window",
|
|
68
|
+
"targets": [
|
|
69
|
+
"aarch64-apple-darwin",
|
|
70
|
+
"x86_64-apple-darwin",
|
|
71
|
+
"x86_64-pc-windows-msvc",
|
|
72
|
+
"aarch64-pc-windows-msvc",
|
|
73
|
+
"x86_64-unknown-linux-gnu",
|
|
74
|
+
"aarch64-unknown-linux-gnu"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
}
|