@mirascript/bindings 0.1.62-alpha.15 → 0.1.62-alpha.20

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 (2) hide show
  1. package/README.md +42 -0
  2. package/package.json +8 -3
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @mirascript/bindings
2
+
3
+ `@mirascript/bindings` 提供 MiraScript 编译器的统一 JavaScript 绑定层。它会优先在 Node.js 环境加载 `@mirascript/napi` 原生实现,在浏览器或无法加载原生模块时回退到 `@mirascript/wasm`。
4
+
5
+ ## 适用场景
6
+
7
+ - 需要同时支持 Node.js 和浏览器环境
8
+ - 希望按统一接口访问底层编译器模块
9
+ - 作为上层包的基础依赖,例如 `@mirascript/mirascript`、`@mirascript/cli`、`@mirascript/monaco`
10
+
11
+ ## 安装
12
+
13
+ ```bash
14
+ pnpm add @mirascript/bindings
15
+ ```
16
+
17
+ ## 基本用法
18
+
19
+ ```ts
20
+ import { loadModule, getModule } from '@mirascript/bindings';
21
+
22
+ const mod = await loadModule();
23
+ const sameModule = getModule();
24
+
25
+ console.log(mod === sameModule);
26
+ ```
27
+
28
+ ## 导出内容
29
+
30
+ - `loadModule()`:异步加载底层编译器模块
31
+ - `getModule()`:获取已加载模块;若未加载会抛错
32
+ - `@mirascript/bindings/wasm`:显式使用 WebAssembly 实现
33
+ - `@mirascript/bindings/napi`:显式使用 Node 原生实现
34
+
35
+ ## 开发
36
+
37
+ ```bash
38
+ pnpm --filter @mirascript/bindings build
39
+ pnpm --filter @mirascript/bindings watch
40
+ ```
41
+
42
+ 该包本身只负责装配与分发,实际编译能力来自 `@mirascript/napi` 与 `@mirascript/wasm`。
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@mirascript/bindings",
3
- "version": "0.1.62-alpha.15",
3
+ "version": "0.1.62-alpha.20",
4
4
  "author": "CloudPSS",
5
5
  "license": "MIT",
6
6
  "description": "MiraScript compiler bindings",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/CloudPSS/MiraScript.git",
10
+ "directory": "packages/bindings"
11
+ },
7
12
  "type": "module",
8
13
  "main": "dist/index.js",
9
14
  "types": "dist/index.d.ts",
@@ -19,8 +24,8 @@
19
24
  }
20
25
  },
21
26
  "dependencies": {
22
- "@mirascript/napi": "~0.1.62-alpha.15",
23
- "@mirascript/wasm": "~0.1.62-alpha.15"
27
+ "@mirascript/napi": "~0.1.62-alpha.20",
28
+ "@mirascript/wasm": "~0.1.62-alpha.20"
24
29
  },
25
30
  "devDependencies": {
26
31
  "@types/node": "^25.6.0"