@alloy-framework/rust 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.
Files changed (3) hide show
  1. package/README.md +28 -0
  2. package/native.js +51 -0
  3. package/package.json +24 -0
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Alloy Framework — npm Packages
2
+
3
+ 이 디렉토리는 npm에 배포되는 패키지들을 포함합니다.
4
+
5
+ ## 구조
6
+
7
+ ```
8
+ npm/
9
+ ├── package.json → @alloy/rust (네이티브 로더)
10
+ ├── native.js → 플랫폼 감지 + 바이너리 로드
11
+ ├── framework/ → @alloy/framework (메인 패키지)
12
+ ├── client-wasm/ → @alloy/client-wasm (브라우저 WASM)
13
+ ├── darwin-arm64/ → @alloy/rust-darwin-arm64
14
+ ├── darwin-x64/ → @alloy/rust-darwin-x64
15
+ ├── linux-x64-gnu/ → @alloy/rust-linux-x64-gnu
16
+ └── win32-x64-msvc/ → @alloy/rust-win32-x64-msvc
17
+ ```
18
+
19
+ ## 배포 순서
20
+
21
+ ```
22
+ 1. 플랫폼 바이너리 (병렬) → @alloy/rust-{platform}
23
+ 2. WASM (병렬) → @alloy/client-wasm
24
+ 3. 네이티브 로더 → @alloy/rust
25
+ 4. 메인 패키지 → @alloy/framework
26
+ ```
27
+
28
+ CI가 `v*` 태그 push 또는 수동 실행 시 자동으로 배포합니다.
package/native.js ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * 🔧 @alloy-framework/rust — 네이티브 바이너리 로더
3
+ *
4
+ * 런타임 플랫폼(OS + CPU arch)에 맞는 네이티브 .node 바이너리를 자동으로 로드합니다.
5
+ * 지원 플랫폼:
6
+ * - macOS arm64 (Apple Silicon M1/M2/M3)
7
+ * - macOS x64 (Intel)
8
+ * - Linux x64 (glibc, Ubuntu/Debian 등)
9
+ * - Windows x64 (MSVC)
10
+ *
11
+ * @example
12
+ * import native from '@alloy-framework/rust';
13
+ * // → 플랫폼에 맞는 바이너리가 자동으로 로드됩니다
14
+ */
15
+
16
+ import { createRequire } from 'node:module';
17
+ import { platform, arch } from 'node:process';
18
+
19
+ const require = createRequire(import.meta.url);
20
+
21
+ const PLATFORM_MAP = {
22
+ 'darwin-arm64': '@alloy-framework/rust-darwin-arm64',
23
+ 'darwin-x64': '@alloy-framework/rust-darwin-x64',
24
+ 'linux-x64': '@alloy-framework/rust-linux-x64-gnu',
25
+ 'win32-x64': '@alloy-framework/rust-win32-x64-msvc',
26
+ };
27
+
28
+ const key = `${platform}-${arch}`;
29
+ const pkg = PLATFORM_MAP[key];
30
+
31
+ if (!pkg) {
32
+ throw new Error(
33
+ `[Alloy] Unsupported platform: ${platform}-${arch}\n` +
34
+ `Supported: ${Object.keys(PLATFORM_MAP).join(', ')}\n` +
35
+ `Please open an issue at https://github.com/saytohenry/alloy-framework/issues`
36
+ );
37
+ }
38
+
39
+ let native;
40
+ try {
41
+ native = require(pkg);
42
+ } catch (e) {
43
+ throw new Error(
44
+ `[Alloy] Failed to load native binary for ${platform}-${arch}\n` +
45
+ `Expected package: ${pkg}\n` +
46
+ `Install it with: npm install ${pkg}\n\n` +
47
+ `Original error: ${e.message}`
48
+ );
49
+ }
50
+
51
+ export default native;
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@alloy-framework/rust",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Alloy Framework native binary loader — auto-detects platform and loads the correct .node binary",
6
+ "main": "native.js",
7
+ "files": [
8
+ "native.js"
9
+ ],
10
+ "optionalDependencies": {
11
+ "@alloy-framework/rust-darwin-arm64": "0.1.0",
12
+ "@alloy-framework/rust-darwin-x64": "0.1.0",
13
+ "@alloy-framework/rust-linux-x64-gnu": "0.1.0",
14
+ "@alloy-framework/rust-win32-x64-msvc": "0.1.0"
15
+ },
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/saytohenry/alloy-framework.git"
20
+ },
21
+ "engines": {
22
+ "node": ">=20.0.0"
23
+ }
24
+ }