@argos-js/argox-core 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,82 @@
1
+ /**
2
+ * Argox Core Engine - Native FFI Type Declarations
3
+ *
4
+ * Hand-crafted type definitions representing the ABI boundary between
5
+ * the Rust native core (argox-core) and the TypeScript runtime (@argos-js).
6
+ */
7
+
8
+ export interface JsHttpRequest {
9
+ id: string;
10
+ method: string;
11
+ path: string;
12
+ headers: Record<string, string>;
13
+ query: Record<string, string>;
14
+ params: Record<string, string>;
15
+ body?: string;
16
+ }
17
+
18
+ export interface JsHttpResponse {
19
+ statusCode: number;
20
+ headers: Record<string, string>;
21
+ body?: string;
22
+ }
23
+
24
+ /**
25
+ * Returns the underlying Rust engine package version compiled into the binary.
26
+ */
27
+ export function engineVersion(): string;
28
+
29
+ /**
30
+ * Constructs a native HTTP response struct directly inside Rust memory.
31
+ *
32
+ * @param status - HTTP status code (e.g., 200, 404, 500)
33
+ * @param message - String payload message
34
+ */
35
+ export function createNativeResponse(status: number, message: string): JsHttpResponse;
36
+
37
+ /**
38
+ * Binds the native Rust TCP socket server to the specified host and port.
39
+ *
40
+ * @param port - Target TCP port to bind.
41
+ * @param host - Host interface address.
42
+ * @param handler - Callback function invoked for incoming HTTP requests.
43
+ */
44
+ export function startServer(
45
+ port: number,
46
+ host: string,
47
+ handler: (req: JsHttpRequest) => Promise<JsHttpResponse> | JsHttpResponse
48
+ ): void;
49
+
50
+ /**
51
+ * High-performance, concurrent in-memory atomic lock engine backed by Rust.
52
+ */
53
+ export class NativeLockManager {
54
+ constructor();
55
+ acquireLock(key: string, ttlMs: number): boolean;
56
+ acquire_lock(key: string, ttlMs: number): boolean;
57
+ releaseLock(key: string): boolean;
58
+ release_lock(key: string): boolean;
59
+ isLocked(key: string): boolean;
60
+ is_locked(key: string): boolean;
61
+ cleanExpired(): number;
62
+ destroy(): void;
63
+ }
64
+
65
+ /**
66
+ * High-precision temporal ticker backed by Rust/Tokio worker threads.
67
+ */
68
+ export class NativePrecisionTicker {
69
+ constructor();
70
+ start(intervalMs: number, callback: (timestamp: number) => void): boolean;
71
+ stop(): void;
72
+ isActive(): boolean;
73
+ is_active(): boolean;
74
+ }
75
+
76
+ /**
77
+ * Starts a native precision ticker with the given interval in milliseconds.
78
+ */
79
+ export function startPrecisionTicker(
80
+ intervalMs: number,
81
+ callback: (timestamp: number) => void
82
+ ): NativePrecisionTicker;
package/index.js ADDED
@@ -0,0 +1,107 @@
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
+ // For Linux libc determination
12
+ if (!process.report || typeof process.report.getReport !== 'function') {
13
+ try {
14
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
15
+ return require('fs').readFileSync(lddPath, 'utf8').includes('musl')
16
+ } catch {
17
+ return true
18
+ }
19
+ }
20
+ const { glibcVersionRuntime } = process.report.getReport().header
21
+ return !glibcVersionRuntime
22
+ }
23
+
24
+ switch (platform) {
25
+ case 'linux':
26
+ switch (arch) {
27
+ case 'x64':
28
+ if (isMusl()) {
29
+ localFileExisted = existsSync(join(__dirname, 'argox-core.linux-x64-musl.node'))
30
+ if (localFileExisted) {
31
+ nativeBinding = require('./argox-core.linux-x64-musl.node')
32
+ }
33
+ } else {
34
+ localFileExisted = existsSync(join(__dirname, 'argox-core.linux-x64-gnu.node'))
35
+ if (localFileExisted) {
36
+ nativeBinding = require('./argox-core.linux-x64-gnu.node')
37
+ }
38
+ }
39
+ break
40
+ case 'arm64':
41
+ if (isMusl()) {
42
+ localFileExisted = existsSync(join(__dirname, 'argox-core.linux-arm64-musl.node'))
43
+ if (localFileExisted) {
44
+ nativeBinding = require('./argox-core.linux-arm64-musl.node')
45
+ }
46
+ } else {
47
+ localFileExisted = existsSync(join(__dirname, 'argox-core.linux-arm64-gnu.node'))
48
+ if (localFileExisted) {
49
+ nativeBinding = require('./argox-core.linux-arm64-gnu.node')
50
+ }
51
+ }
52
+ break
53
+ default:
54
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
55
+ }
56
+ break
57
+ case 'darwin':
58
+ switch (arch) {
59
+ case 'x64':
60
+ localFileExisted = existsSync(join(__dirname, 'argox-core.darwin-x64.node'))
61
+ if (localFileExisted) {
62
+ nativeBinding = require('./argox-core.darwin-x64.node')
63
+ }
64
+ break
65
+ case 'arm64':
66
+ localFileExisted = existsSync(join(__dirname, 'argox-core.darwin-arm64.node'))
67
+ if (localFileExisted) {
68
+ nativeBinding = require('./argox-core.darwin-arm64.node')
69
+ }
70
+ break
71
+ default:
72
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
73
+ }
74
+ break
75
+ case 'win32':
76
+ switch (arch) {
77
+ case 'x64':
78
+ localFileExisted = existsSync(join(__dirname, 'argox-core.win32-x64-msvc.node'))
79
+ if (localFileExisted) {
80
+ nativeBinding = require('./argox-core.win32-x64-msvc.node')
81
+ }
82
+ break
83
+ default:
84
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
85
+ }
86
+ break
87
+ default:
88
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
89
+ }
90
+
91
+ if (!nativeBinding) {
92
+ // Fallback direct require attempt
93
+ try {
94
+ nativeBinding = require('./argox-core.node')
95
+ } catch (err) {
96
+ loadError = err
97
+ }
98
+ }
99
+
100
+ if (!nativeBinding) {
101
+ if (loadError) {
102
+ throw loadError
103
+ }
104
+ throw new Error(`Failed to load native binding for Argox Core (${platform}-${arch})`)
105
+ }
106
+
107
+ module.exports = nativeBinding
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@argos-js/argox-core",
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 core 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-core",
14
+ "packageName": "@argos-js/argox-core",
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.