@mirascript/constants 0.1.62-alpha.15 → 0.1.62-alpha.21
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/README.md +39 -0
- package/package.json +6 -1
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @mirascript/constants
|
|
2
|
+
|
|
3
|
+
`@mirascript/constants` 导出 MiraScript 编译器常量与辅助类型,包括关键字、诊断码、操作码以及配置相关枚举转换逻辑。
|
|
4
|
+
|
|
5
|
+
## 主要内容
|
|
6
|
+
|
|
7
|
+
- `DiagnosticCode`
|
|
8
|
+
- `OpCode`
|
|
9
|
+
- `DIAGNOSTIC_MESSAGES`
|
|
10
|
+
- `KEYWORDS` 及相关关键字分类
|
|
11
|
+
- `Config`、`InputMode`、`DiagnosticPositionEncoding`
|
|
12
|
+
- `isKeyword()` 等辅助函数
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @mirascript/constants
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 示例
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { KEYWORDS, isKeyword, DiagnosticCode } from '@mirascript/constants';
|
|
24
|
+
|
|
25
|
+
console.log(KEYWORDS.includes('let'));
|
|
26
|
+
console.log(isKeyword('match'));
|
|
27
|
+
console.log(DiagnosticCode.InvalidKeyword);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 构建说明
|
|
31
|
+
|
|
32
|
+
该包会先从 Rust 常量 crate 生成 WebAssembly 产物,再在 JavaScript 层补充类型与工具方法。
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm --filter @mirascript/constants wasm
|
|
36
|
+
pnpm --filter @mirascript/constants build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
构建需要本地安装 `wasm-pack`。
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirascript/constants",
|
|
3
|
-
"version": "0.1.62-alpha.
|
|
3
|
+
"version": "0.1.62-alpha.21",
|
|
4
4
|
"author": "CloudPSS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "MiraScript constants",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/CloudPSS/MiraScript.git",
|
|
10
|
+
"directory": "packages/constants"
|
|
11
|
+
},
|
|
7
12
|
"type": "module",
|
|
8
13
|
"main": "dist/index.js",
|
|
9
14
|
"types": "dist/index.d.ts",
|