@vulfram/transport-napi 0.22.4-alpha → 0.22.5-alpha
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/linux-arm64/manifest.json +2 -2
- package/dist/linux-arm64/vulfram_core.node +0 -0
- package/dist/linux-arm64/vulfram_core.node.sha256 +1 -1
- package/dist/linux-x64/manifest.json +2 -2
- package/dist/linux-x64/vulfram_core.node +0 -0
- package/dist/linux-x64/vulfram_core.node.sha256 +1 -1
- package/dist/macos-arm64/manifest.json +2 -2
- package/dist/macos-arm64/vulfram_core.node +0 -0
- package/dist/macos-arm64/vulfram_core.node.sha256 +1 -1
- package/dist/macos-x64/manifest.json +2 -2
- package/dist/macos-x64/vulfram_core.node +0 -0
- package/dist/macos-x64/vulfram_core.node.sha256 +1 -1
- package/dist/windows-arm64/manifest.json +2 -2
- package/dist/windows-arm64/vulfram_core.node +0 -0
- package/dist/windows-arm64/vulfram_core.node.sha256 +1 -1
- package/dist/windows-x64/manifest.json +2 -2
- package/dist/windows-x64/vulfram_core.node +0 -0
- package/dist/windows-x64/vulfram_core.node.sha256 +1 -1
- package/package.json +6 -5
- package/src/bind/napi-loader.ts +119 -0
- package/src/bind/types.ts +4 -0
- package/src/index.ts +4 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"channel": "alpha",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.5-alpha",
|
|
4
4
|
"binding": "napi",
|
|
5
5
|
"platform": "linux-arm64",
|
|
6
6
|
"rust_target": "aarch64-unknown-linux-gnu",
|
|
7
7
|
"artifact": "vulfram_core.node",
|
|
8
|
-
"sha256": "
|
|
8
|
+
"sha256": "6dac157a93731953ac36d714f4f50499de748f34e89f38da8307d07596fd726a"
|
|
9
9
|
}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
6dac157a93731953ac36d714f4f50499de748f34e89f38da8307d07596fd726a
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"channel": "alpha",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.5-alpha",
|
|
4
4
|
"binding": "napi",
|
|
5
5
|
"platform": "linux-x64",
|
|
6
6
|
"rust_target": "x86_64-unknown-linux-gnu",
|
|
7
7
|
"artifact": "vulfram_core.node",
|
|
8
|
-
"sha256": "
|
|
8
|
+
"sha256": "b8c93c82ca1cd617c440e3c190aa47ac3aee0bcb8c232e8c55c3a84506fc2d95"
|
|
9
9
|
}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
b8c93c82ca1cd617c440e3c190aa47ac3aee0bcb8c232e8c55c3a84506fc2d95
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"channel": "alpha",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.5-alpha",
|
|
4
4
|
"binding": "napi",
|
|
5
5
|
"platform": "macos-arm64",
|
|
6
6
|
"rust_target": "aarch64-apple-darwin",
|
|
7
7
|
"artifact": "vulfram_core.node",
|
|
8
|
-
"sha256": "
|
|
8
|
+
"sha256": "d306e85b4956565e8ead6803fd603c2f1e113a8b3d6b7bba0e296ba2e76e2435"
|
|
9
9
|
}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d306e85b4956565e8ead6803fd603c2f1e113a8b3d6b7bba0e296ba2e76e2435
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"channel": "alpha",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.5-alpha",
|
|
4
4
|
"binding": "napi",
|
|
5
5
|
"platform": "macos-x64",
|
|
6
6
|
"rust_target": "x86_64-apple-darwin",
|
|
7
7
|
"artifact": "vulfram_core.node",
|
|
8
|
-
"sha256": "
|
|
8
|
+
"sha256": "c32ae74c0cbe84eed04c0821da22831421326aa9b7733940584f6244734f422e"
|
|
9
9
|
}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
c32ae74c0cbe84eed04c0821da22831421326aa9b7733940584f6244734f422e
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"channel": "alpha",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.5-alpha",
|
|
4
4
|
"binding": "napi",
|
|
5
5
|
"platform": "windows-arm64",
|
|
6
6
|
"rust_target": "aarch64-pc-windows-msvc",
|
|
7
7
|
"artifact": "vulfram_core.node",
|
|
8
|
-
"sha256": "
|
|
8
|
+
"sha256": "e6303d6ae36de86ed8bb998fd2c764d9ba8076c1e10c8c75b8ff664fb0c2521f"
|
|
9
9
|
}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e6303d6ae36de86ed8bb998fd2c764d9ba8076c1e10c8c75b8ff664fb0c2521f
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"channel": "alpha",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.5-alpha",
|
|
4
4
|
"binding": "napi",
|
|
5
5
|
"platform": "windows-x64",
|
|
6
6
|
"rust_target": "x86_64-pc-windows-msvc",
|
|
7
7
|
"artifact": "vulfram_core.node",
|
|
8
|
-
"sha256": "
|
|
8
|
+
"sha256": "884bb87f8ff45c410c94320ba998bfc1e5848a2cbeb4081b84477b1018e9a3fb"
|
|
9
9
|
}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
884bb87f8ff45c410c94320ba998bfc1e5848a2cbeb4081b84477b1018e9a3fb
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulfram/transport-napi",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.5-alpha",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
"directory": "packages/transport-napi"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
|
-
"types": "
|
|
12
|
-
"main": "
|
|
13
|
-
"module": "
|
|
11
|
+
"types": "src/index.ts",
|
|
12
|
+
"main": "src/index.ts",
|
|
13
|
+
"module": "src/index.ts",
|
|
14
14
|
"files": [
|
|
15
|
+
"src",
|
|
15
16
|
"dist",
|
|
16
17
|
"README.md"
|
|
17
18
|
],
|
|
@@ -22,6 +23,6 @@
|
|
|
22
23
|
"@vulfram/transport-types": "^0.3.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@types/bun": "^1.3.
|
|
26
|
+
"@types/bun": "^1.3.11"
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
detectRuntime,
|
|
3
|
+
getArtifactFileName,
|
|
4
|
+
resolveNativePlatform,
|
|
5
|
+
selectPlatformLoader,
|
|
6
|
+
type PlatformLoaderMap
|
|
7
|
+
} from '@vulfram/transport-types';
|
|
8
|
+
import type { BufferResult } from './types';
|
|
9
|
+
import { createRequire } from 'module';
|
|
10
|
+
import { dirname, join } from 'path';
|
|
11
|
+
import { existsSync } from 'fs';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
|
|
14
|
+
const requireNative = createRequire(import.meta.url);
|
|
15
|
+
|
|
16
|
+
const bundledLoaders: PlatformLoaderMap<{ default: string }> = {
|
|
17
|
+
darwin: {
|
|
18
|
+
arm64: () =>
|
|
19
|
+
// @ts-expect-error
|
|
20
|
+
import('../../dist/macos-arm64/vulfram_core.node', {
|
|
21
|
+
with: { type: 'file' }
|
|
22
|
+
}),
|
|
23
|
+
x64: () =>
|
|
24
|
+
// @ts-expect-error
|
|
25
|
+
import('../../dist/macos-x64/vulfram_core.node', {
|
|
26
|
+
with: { type: 'file' }
|
|
27
|
+
})
|
|
28
|
+
},
|
|
29
|
+
linux: {
|
|
30
|
+
arm64: () =>
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
import('../../dist/linux-arm64/vulfram_core.node', {
|
|
33
|
+
with: { type: 'file' }
|
|
34
|
+
}),
|
|
35
|
+
x64: () =>
|
|
36
|
+
// @ts-expect-error
|
|
37
|
+
import('../../dist/linux-x64/vulfram_core.node', {
|
|
38
|
+
with: { type: 'file' }
|
|
39
|
+
})
|
|
40
|
+
},
|
|
41
|
+
win32: {
|
|
42
|
+
arm64: () =>
|
|
43
|
+
// @ts-expect-error
|
|
44
|
+
import('../../dist/windows-arm64/vulfram_core.node', {
|
|
45
|
+
with: { type: 'file' }
|
|
46
|
+
}),
|
|
47
|
+
x64: () =>
|
|
48
|
+
// @ts-expect-error
|
|
49
|
+
import('../../dist/windows-x64/vulfram_core.node', {
|
|
50
|
+
with: { type: 'file' }
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
function getExpectedLocalArtifact(): string {
|
|
56
|
+
try {
|
|
57
|
+
const platform = resolveNativePlatform();
|
|
58
|
+
const filename = getArtifactFileName('napi', platform);
|
|
59
|
+
return `../../dist/${platform}/${filename}`;
|
|
60
|
+
} catch {
|
|
61
|
+
return '../../dist/<platform>/vulfram_core.node';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function resolveNativeModulePath(): Promise<string> {
|
|
66
|
+
const platform = resolveNativePlatform();
|
|
67
|
+
const filename = getArtifactFileName('napi', platform);
|
|
68
|
+
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
69
|
+
const candidates = [
|
|
70
|
+
join(moduleDir, '..', '..', 'dist', platform, filename),
|
|
71
|
+
join(moduleDir, platform, filename),
|
|
72
|
+
join(moduleDir, '..', platform, filename)
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const resolved = candidates.find((candidate) => existsSync(candidate));
|
|
77
|
+
if (resolved) {
|
|
78
|
+
return resolved;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const importLoader = selectPlatformLoader(bundledLoaders, 'N-API');
|
|
82
|
+
return (await importLoader()).default;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
const runtime = detectRuntime();
|
|
85
|
+
const expectedArtifact = getExpectedLocalArtifact();
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Failed to load bundled N-API artifact (runtime=${runtime.runtime}, platform=${runtime.platform ?? 'unknown'}, arch=${runtime.arch ?? 'unknown'}, expected=${expectedArtifact}): ${String(error)}`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const modulePath = await resolveNativeModulePath();
|
|
93
|
+
const raw = requireNative(modulePath) as {
|
|
94
|
+
vulframInit: () => number;
|
|
95
|
+
vulframDispose: () => number;
|
|
96
|
+
vulframSendQueue: (buffer: Buffer) => number;
|
|
97
|
+
vulframReceiveQueue: () => BufferResult;
|
|
98
|
+
vulframReceiveEvents: () => BufferResult;
|
|
99
|
+
vulframUploadBuffer: (id: number, uploadType: number, buffer: Buffer) => number;
|
|
100
|
+
vulframTick: (timeMs: number, deltaMs: number) => number;
|
|
101
|
+
vulframGetProfiling: () => BufferResult;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const VULFRAM_CORE = {
|
|
105
|
+
vulframInit: () => raw.vulframInit(),
|
|
106
|
+
vulframDispose: () => raw.vulframDispose(),
|
|
107
|
+
vulframReceiveQueue: () => raw.vulframReceiveQueue(),
|
|
108
|
+
vulframReceiveEvents: () => raw.vulframReceiveEvents(),
|
|
109
|
+
vulframTick: (timeMs: number, deltaMs: number) => raw.vulframTick(timeMs, deltaMs),
|
|
110
|
+
vulframGetProfiling: () => raw.vulframGetProfiling(),
|
|
111
|
+
vulframSendQueue: (buffer: Uint8Array) => {
|
|
112
|
+
const data = Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer);
|
|
113
|
+
return raw.vulframSendQueue(data);
|
|
114
|
+
},
|
|
115
|
+
vulframUploadBuffer: (id: number, uploadType: number, buffer: Uint8Array) => {
|
|
116
|
+
const data = Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer);
|
|
117
|
+
return raw.vulframUploadBuffer(id, uploadType, data);
|
|
118
|
+
}
|
|
119
|
+
};
|
package/src/index.ts
ADDED