kokorobox-native 0.7.0 → 0.8.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/README.md +8 -0
- package/index.d.ts +2 -0
- package/index.js +21 -2
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -19,12 +19,14 @@ macOS, and GNU/Linux. The loader also accepts a development binary through
|
|
|
19
19
|
import {
|
|
20
20
|
getNativeCapabilities,
|
|
21
21
|
getNetworkContext,
|
|
22
|
+
getTrafficPresenterPath,
|
|
22
23
|
inspectApplication,
|
|
23
24
|
} from "kokorobox-native";
|
|
24
25
|
|
|
25
26
|
const capabilities = getNativeCapabilities();
|
|
26
27
|
const network = await getNetworkContext();
|
|
27
28
|
const app = await inspectApplication("/Applications/KokoroBox.app");
|
|
29
|
+
const presenter = getTrafficPresenterPath();
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
The full TypeScript declarations are shipped in
|
|
@@ -35,6 +37,7 @@ The full TypeScript declarations are shipped in
|
|
|
35
37
|
| Area | Exports |
|
|
36
38
|
| --- | --- |
|
|
37
39
|
| Capabilities | `getNativeCapabilities` |
|
|
40
|
+
| Traffic presenter | `getTrafficPresenterPath` |
|
|
38
41
|
| Icons | `fileToDataUrl`, `getAppName` |
|
|
39
42
|
| Applications | `inspectApplication`, `scanWindowsApplications`, `findExecutables` |
|
|
40
43
|
| Rules | `fileToStr` |
|
|
@@ -80,6 +83,11 @@ use them as a general privileged-command interface. See the repository's
|
|
|
80
83
|
[platform-services contract](../docs/platform-services.md) for validation and
|
|
81
84
|
platform behavior.
|
|
82
85
|
|
|
86
|
+
`getTrafficPresenterPath()` returns the presenter executable shipped in the
|
|
87
|
+
same platform package as the loaded native binding. The presenter accepts the
|
|
88
|
+
versioned JSON-lines protocol documented by the `traffic-presenter` crate on
|
|
89
|
+
standard input and terminates when its parent closes that stream.
|
|
90
|
+
|
|
83
91
|
## Platform behavior
|
|
84
92
|
|
|
85
93
|
Use `getNativeCapabilities()` before enabling an optional system feature.
|
package/index.d.ts
CHANGED
|
@@ -135,6 +135,8 @@ export function fileToStr(
|
|
|
135
135
|
): RuleStringResult;
|
|
136
136
|
export function getAppName(path: string): string;
|
|
137
137
|
export function getNativeCapabilities(): NativeCapabilities;
|
|
138
|
+
/** Resolve the executable shipped beside the current platform binding. */
|
|
139
|
+
export function getTrafficPresenterPath(): string;
|
|
138
140
|
export function findExecutables(options: ExecutableSearchOptions): Promise<ExecutableCandidate[]>;
|
|
139
141
|
export function getLaunchAtLogin(options: LaunchAtLoginOptions): Promise<LaunchAtLoginStatus>;
|
|
140
142
|
export function setLaunchAtLogin(
|
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
5
|
import { existsSync } from 'node:fs'
|
|
6
|
-
import { join } from "node:path";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
@@ -15,6 +15,7 @@ const __dirname = new URL(".", import.meta.url).pathname.replace(
|
|
|
15
15
|
const packageName = "kokorobox-native";
|
|
16
16
|
const binaryName = "kokorobox-native";
|
|
17
17
|
const loadErrors = [];
|
|
18
|
+
let loadedTuple = null;
|
|
18
19
|
|
|
19
20
|
function requireLocal(tuple) {
|
|
20
21
|
const filename = join(__dirname, `${binaryName}.${tuple}.node`);
|
|
@@ -37,7 +38,25 @@ function requirePackage(tuple) {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
function requireBinding(tuple) {
|
|
40
|
-
|
|
41
|
+
const binding = requireLocal(tuple) || requirePackage(tuple);
|
|
42
|
+
if (binding) loadedTuple = tuple;
|
|
43
|
+
return binding;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getTrafficPresenterPath() {
|
|
47
|
+
const filename = `kokorobox-traffic-presenter${process.platform === "win32" ? ".exe" : ""}`;
|
|
48
|
+
const localPath = join(__dirname, filename);
|
|
49
|
+
if (existsSync(localPath)) return localPath;
|
|
50
|
+
|
|
51
|
+
if (loadedTuple) {
|
|
52
|
+
const packageEntry = require.resolve(`${packageName}-${loadedTuple}`);
|
|
53
|
+
const packagedPath = join(dirname(packageEntry), filename);
|
|
54
|
+
if (existsSync(packagedPath)) return packagedPath;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Traffic presenter is missing for ${process.platform} ${process.arch}`,
|
|
59
|
+
);
|
|
41
60
|
}
|
|
42
61
|
|
|
43
62
|
function requireNative() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kokorobox-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "KokoroBox native bridge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"build": "napi build --platform --release --strip --no-js --dts napi.generated.d.ts",
|
|
36
36
|
"build:debug": "napi build --platform --no-js --dts napi.generated.d.ts",
|
|
37
37
|
"create-npm-dirs": "napi create-npm-dirs",
|
|
38
|
-
"artifacts": "napi artifacts"
|
|
38
|
+
"artifacts": "napi artifacts",
|
|
39
|
+
"package-presenters": "node package-presenters.mjs"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@napi-rs/cli": "^3.8.6"
|
|
@@ -47,11 +48,11 @@
|
|
|
47
48
|
"access": "public"
|
|
48
49
|
},
|
|
49
50
|
"optionalDependencies": {
|
|
50
|
-
"kokorobox-native-win32-x64-msvc": "0.
|
|
51
|
-
"kokorobox-native-win32-arm64-msvc": "0.
|
|
52
|
-
"kokorobox-native-darwin-x64": "0.
|
|
53
|
-
"kokorobox-native-darwin-arm64": "0.
|
|
54
|
-
"kokorobox-native-linux-x64-gnu": "0.
|
|
55
|
-
"kokorobox-native-linux-arm64-gnu": "0.
|
|
51
|
+
"kokorobox-native-win32-x64-msvc": "0.8.0",
|
|
52
|
+
"kokorobox-native-win32-arm64-msvc": "0.8.0",
|
|
53
|
+
"kokorobox-native-darwin-x64": "0.8.0",
|
|
54
|
+
"kokorobox-native-darwin-arm64": "0.8.0",
|
|
55
|
+
"kokorobox-native-linux-x64-gnu": "0.8.0",
|
|
56
|
+
"kokorobox-native-linux-arm64-gnu": "0.8.0"
|
|
56
57
|
}
|
|
57
58
|
}
|