@argos-js/argox-net 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Argos-JS Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
Binary file
package/index.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ export interface NativeTcpOptions {
2
+ host: string
3
+ port: number
4
+ delimiter?: string | undefined
5
+ maxFrameSize?: number | undefined
6
+ noDelay?: boolean | undefined
7
+ keepAliveMs?: number | undefined
8
+ }
9
+
10
+ export declare class NativeTcpChannel {
11
+ static connect(options: NativeTcpOptions): Promise<NativeTcpChannel>
12
+ onFrame(callback: (data: Buffer) => void): void
13
+ onError(callback: (error: string) => void): void
14
+ onClose(callback: () => void): void
15
+ send(data: Buffer): Promise<void>
16
+ close(): Promise<void>
17
+ get isClosed(): boolean
18
+ }
19
+
20
+ export declare class NativeWsClient {
21
+ static connect(url: string): Promise<NativeWsClient>
22
+ onMessage(callback: (data: string | Buffer) => void): void
23
+ onError(callback: (error: string) => void): void
24
+ onClose(callback: (code: number, reason: string) => void): void
25
+ sendText(msg: string): Promise<void>
26
+ sendBinary(data: Buffer): Promise<void>
27
+ close(code?: number, reason?: string): Promise<void>
28
+ get isClosed(): boolean
29
+ }
30
+
31
+ export interface BinaryStreamOptions {
32
+ highWaterMark?: number | undefined
33
+ lowWaterMark?: number | undefined
34
+ }
35
+
36
+ export declare class NativeBinaryStream {
37
+ constructor(options?: BinaryStreamOptions)
38
+ pushChunk(data: Buffer): boolean
39
+ ack(bytes: number): void
40
+ readChunk(maxBytes?: number): Buffer | null
41
+ pause(): void
42
+ resume(): void
43
+ end(): void
44
+ onChunk(callback: (data: Buffer) => void): void
45
+ onDrain(callback: () => void): void
46
+ onEnd(callback: () => void): void
47
+ get bufferedBytes(): number
48
+ get isEnded(): boolean
49
+ }
50
+
51
+ export declare function netEngineVersion(): string
package/index.js ADDED
@@ -0,0 +1,113 @@
1
+ const { existsSync } = require('fs')
2
+ const { join } = require('path')
3
+
4
+ const { platform, arch } = process
5
+
6
+ let nativeBinding = null
7
+ let localFileExisted = false
8
+ let loadError = null
9
+
10
+ function isMusl() {
11
+ if (!process.report || typeof process.report.getReport !== 'function') {
12
+ try {
13
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
14
+ return require('fs').readFileSync(lddPath, 'utf8').includes('musl')
15
+ } catch {
16
+ return true
17
+ }
18
+ }
19
+ const { glibcVersionRuntime } = process.report.getReport().header
20
+ return !glibcVersionRuntime
21
+ }
22
+
23
+ switch (platform) {
24
+ case 'linux':
25
+ switch (arch) {
26
+ case 'x64':
27
+ if (isMusl()) {
28
+ localFileExisted = existsSync(join(__dirname, 'argox-net.linux-x64-musl.node'))
29
+ if (localFileExisted) {
30
+ nativeBinding = require('./argox-net.linux-x64-musl.node')
31
+ }
32
+ } else {
33
+ localFileExisted = existsSync(join(__dirname, 'argox-net.linux-x64-gnu.node'))
34
+ if (localFileExisted) {
35
+ nativeBinding = require('./argox-net.linux-x64-gnu.node')
36
+ }
37
+ }
38
+ break
39
+ case 'arm64':
40
+ if (isMusl()) {
41
+ localFileExisted = existsSync(join(__dirname, 'argox-net.linux-arm64-musl.node'))
42
+ if (localFileExisted) {
43
+ nativeBinding = require('./argox-net.linux-arm64-musl.node')
44
+ }
45
+ } else {
46
+ localFileExisted = existsSync(join(__dirname, 'argox-net.linux-arm64-gnu.node'))
47
+ if (localFileExisted) {
48
+ nativeBinding = require('./argox-net.linux-arm64-gnu.node')
49
+ }
50
+ }
51
+ break
52
+ default:
53
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
54
+ }
55
+ break
56
+ case 'darwin':
57
+ switch (arch) {
58
+ case 'x64':
59
+ localFileExisted = existsSync(join(__dirname, 'argox-net.darwin-x64.node'))
60
+ if (localFileExisted) {
61
+ nativeBinding = require('./argox-net.darwin-x64.node')
62
+ }
63
+ break
64
+ case 'arm64':
65
+ localFileExisted = existsSync(join(__dirname, 'argox-net.darwin-arm64.node'))
66
+ if (localFileExisted) {
67
+ nativeBinding = require('./argox-net.darwin-arm64.node')
68
+ }
69
+ break
70
+ default:
71
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
72
+ }
73
+ break
74
+ case 'win32':
75
+ switch (arch) {
76
+ case 'x64':
77
+ localFileExisted = existsSync(join(__dirname, 'argox-net.win32-x64-msvc.node'))
78
+ if (localFileExisted) {
79
+ nativeBinding = require('./argox-net.win32-x64-msvc.node')
80
+ }
81
+ break
82
+ default:
83
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
84
+ }
85
+ break
86
+ default:
87
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
88
+ }
89
+
90
+ if (!nativeBinding) {
91
+ try {
92
+ nativeBinding = require('./argox-net.node')
93
+ } catch (err) {
94
+ loadError = err
95
+ }
96
+ }
97
+
98
+ if (!nativeBinding) {
99
+ try {
100
+ nativeBinding = require('./index.node')
101
+ } catch (err) {
102
+ loadError = err
103
+ }
104
+ }
105
+
106
+ if (!nativeBinding) {
107
+ if (loadError) {
108
+ throw loadError
109
+ }
110
+ throw new Error(`Failed to load native binding for Argox Net (${platform}-${arch})`)
111
+ }
112
+
113
+ module.exports = nativeBinding
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@argos-js/argox-net",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Native Rust network engine bindings for Argos-JS",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "files": [
8
+ "index.js",
9
+ "index.d.ts",
10
+ "*.node"
11
+ ],
12
+ "napi": {
13
+ "binaryName": "argox-net",
14
+ "packageName": "@argos-js/argox-net",
15
+ "targets": [
16
+ "x86_64-unknown-linux-gnu",
17
+ "aarch64-unknown-linux-gnu",
18
+ "x86_64-apple-darwin",
19
+ "aarch64-apple-darwin",
20
+ "x86_64-pc-windows-msvc"
21
+ ]
22
+ },
23
+ "license": "MIT",
24
+ "scripts": {
25
+ "build": "napi build --platform --release --dts napi-generated.d.ts",
26
+ "build:debug": "napi build --platform --dts napi-generated.d.ts"
27
+ }
6
28
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.