meta-json-schema 1.18.4-beta4 → 1.18.4-beta6
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/CHANGELOG.md +45 -40
- package/LICENSE +21 -21
- package/README.md +204 -204
- package/package.json +50 -41
- package/schemas/clash-verge-merge-json-schema.json +1 -1
- package/schemas/meta-json-schema.json +1 -1
- package/.gitattributes +0 -2
- package/.github/workflows/release_on_tag.yml +0 -44
- package/.github/workflows/workflow_runs_cleaner.yml +0 -18
- package/.vscode/extensions.json +0 -3
- package/.vscode/settings.json +0 -30
- package/scripts/release.mjs +0 -29
- package/scripts/util/bundle.mjs +0 -91
- package/scripts/util/env.mjs +0 -9
- package/scripts/util/file.mjs +0 -13
- package/scripts/watch.mjs +0 -28
- package/src/clash-verge-merge-json-schema.json +0 -58
- package/src/definitions/compatible.json +0 -6
- package/src/definitions/enums.json +0 -58
- package/src/definitions/patterns.json +0 -87
- package/src/definitions/types.json +0 -70
- package/src/meta-json-schema.json +0 -168
- package/src/modules/adapter/outbound/base.json +0 -91
- package/src/modules/adapter/outbound/direct.json +0 -39
- package/src/modules/adapter/outbound/dns.json +0 -39
- package/src/modules/adapter/outbound/http.json +0 -101
- package/src/modules/adapter/outbound/hysteria.json +0 -182
- package/src/modules/adapter/outbound/hysteria2.json +0 -146
- package/src/modules/adapter/outbound/reality.json +0 -25
- package/src/modules/adapter/outbound/shadowsocks.json +0 -308
- package/src/modules/adapter/outbound/shadowsocksr.json +0 -151
- package/src/modules/adapter/outbound/singmux.json +0 -95
- package/src/modules/adapter/outbound/snell.json +0 -65
- package/src/modules/adapter/outbound/socks5.json +0 -88
- package/src/modules/adapter/outbound/ssh.json +0 -87
- package/src/modules/adapter/outbound/trojan.json +0 -93
- package/src/modules/adapter/outbound/tuic.json +0 -213
- package/src/modules/adapter/outbound/vless.json +0 -146
- package/src/modules/adapter/outbound/vmess.json +0 -251
- package/src/modules/adapter/outbound/wireguard.json +0 -150
- package/src/modules/adapter/outboundgroup/fallback.json +0 -18
- package/src/modules/adapter/outboundgroup/groupbase.json +0 -98
- package/src/modules/adapter/outboundgroup/loadbalance.json +0 -29
- package/src/modules/adapter/outboundgroup/relay.json +0 -18
- package/src/modules/adapter/outboundgroup/urltest.json +0 -25
- package/src/modules/adapter/provider/health-check.json +0 -74
- package/src/modules/adapter/provider/provider.json +0 -159
- package/src/modules/config/authentication.json +0 -9
- package/src/modules/config/controller.json +0 -53
- package/src/modules/config/dns.json +0 -163
- package/src/modules/config/ebpf.json +0 -22
- package/src/modules/config/experimental.json +0 -29
- package/src/modules/config/general.json +0 -140
- package/src/modules/config/geox-url.json +0 -38
- package/src/modules/config/hosts.json +0 -9
- package/src/modules/config/inbound.json +0 -107
- package/src/modules/config/iptables.json +0 -38
- package/src/modules/config/listeners.json +0 -90
- package/src/modules/config/ntp.json +0 -50
- package/src/modules/config/profile.json +0 -24
- package/src/modules/config/proxies.json +0 -118
- package/src/modules/config/proxy-groups.json +0 -21
- package/src/modules/config/proxy-providers.json +0 -11
- package/src/modules/config/rules.json +0 -11
- package/src/modules/config/sniffer.json +0 -111
- package/src/modules/config/sub-rules.json +0 -14
- package/src/modules/config/tls.json +0 -28
- package/src/modules/config/tunnels.json +0 -49
- package/src/modules/listener/config/tuic.json +0 -102
- package/src/modules/listener/config/tun.json +0 -205
- package/src/modules/listener/inbound/base.json +0 -43
- package/src/modules/listener/inbound/http.json +0 -18
- package/src/modules/listener/inbound/hysteria2.json +0 -102
- package/src/modules/listener/inbound/mixed.json +0 -26
- package/src/modules/listener/inbound/mux.json +0 -42
- package/src/modules/listener/inbound/redir.json +0 -18
- package/src/modules/listener/inbound/shadowsocks.json +0 -41
- package/src/modules/listener/inbound/socks.json +0 -26
- package/src/modules/listener/inbound/tproxy.json +0 -26
- package/src/modules/listener/inbound/tuic.json +0 -84
- package/src/modules/listener/inbound/tun.json +0 -207
- package/src/modules/listener/inbound/tunnel.json +0 -33
- package/src/modules/listener/inbound/vmess.json +0 -72
- package/src/modules/listener/sing/sing.json +0 -42
- package/src/modules/rules/provider/provider.json +0 -71
- package/src/modules/rules/rule.json +0 -165
- package/test/clash-meta/example1.yaml +0 -3170
- package/test/clash-verge/merge.yaml +0 -212
package/CHANGELOG.md
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
|
-
## v1.18.
|
|
2
|
-
|
|
3
|
-
### Changes
|
|
4
|
-
|
|
5
|
-
- 新增: `dns` 新增配置项 `use-system-hosts`
|
|
6
|
-
- 调整: 调整部分配置描述
|
|
7
|
-
- 移除: Clash Verge Merge 配置移除`prepend-rule-providers`、`prepend-proxy-providers`、`append-rule-providers`、`append-proxy-providers`
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
## v1.18.6
|
|
2
|
+
|
|
3
|
+
### Changes
|
|
4
|
+
|
|
5
|
+
- 新增: `dns` 新增配置项 `use-system-hosts`
|
|
6
|
+
- 调整: 调整部分配置描述
|
|
7
|
+
- 移除: Clash Verge Merge 配置移除`prepend-rule-providers`、`prepend-proxy-providers`、`append-rule-providers`、`append-proxy-providers`
|
|
8
|
+
- 新增: `sniffer` 未配置 `sniff` 警告
|
|
9
|
+
- 新增: `vless` 使用旧版 `XTLS` 协议警告
|
|
10
|
+
- 新增: `rules` 新增规则 `PROCESS-NAME-REGEX` 、 `PROCESS-PATH-REGEX`
|
|
11
|
+
|
|
12
|
+
### Bugs Fixes
|
|
13
|
+
|
|
14
|
+
- 修复: cipher 缺少 `none`
|
|
15
|
+
- 修复: `default-nameserver`类型错误
|
|
16
|
+
- 修复: `nameserver-policy` 不支持配置单个DNS服务器字符串
|
|
17
|
+
- 修复: 域名通配格式错误
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## v1.18.4
|
|
22
|
+
|
|
23
|
+
### Changes
|
|
24
|
+
|
|
25
|
+
- 新增: `proxy-providers` 新增配置项 `header`
|
|
26
|
+
- 调整: `proxy-providers`,`proxy-group` 配置项 `health-check`的`interval` 和 `timeout` 属性类型变更(`integer` --> `string`), 支持配置时间单位
|
|
27
|
+
- 新增: 新增配置项`external-controller-unix`,允许使用Unix Socket访问API
|
|
28
|
+
|
|
29
|
+
### Bugs Fixes
|
|
30
|
+
|
|
31
|
+
- 字符串数组类型错误
|
|
32
|
+
- 监听地址支持`:port`
|
|
33
|
+
- sniffer的http ports类型错误
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## v1.18.3
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
- 首个JSON Schema版本
|
|
42
|
+
|
|
43
|
+
### Bugs Fixes
|
|
44
|
+
|
|
45
|
+
---
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 dongchengjie
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 dongchengjie
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,204 +1,204 @@
|
|
|
1
|
-
### 🧩 VSCode 插件
|
|
2
|
-
|
|
3
|
-
VS Code 扩展商店搜索 `Meta JSON Schema` 或 `ClashMeta.meta-json-schema`,安装扩展后即可获取 `Clash.Meta`的语法支持。
|
|
4
|
-
|
|
5
|
-
## 💡 用法
|
|
6
|
-
|
|
7
|
-
<details>
|
|
8
|
-
<summary>Visual Studio Code中使用</summary>
|
|
9
|
-
|
|
10
|
-
1. 安装YAML语法支持插件`redhat.vscode-yaml`。
|
|
11
|
-
2. 在`.vscode`目录下的`settings.json`文件中(如不存在则手动创建),填入以下内容。其中,key为schema文件的地址,value为路径通配符,请根据需求自行修改。
|
|
12
|
-
```json
|
|
13
|
-
{
|
|
14
|
-
"yaml.schemas": {
|
|
15
|
-
"https://fastly.jsdelivr.net/gh/dongchengjie/meta-json-schema@main/schemas/meta-json-schema.json": "**/*.yaml"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
</details>
|
|
21
|
-
<details>
|
|
22
|
-
<summary>Monaco Editor中使用</summary>
|
|
23
|
-
|
|
24
|
-
1. 安装`monaco-editor`(编辑器)和`monaco-yaml`(YAML支持)。
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
npm install monaco-editor
|
|
28
|
-
npm install monaco-yaml
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
2. 如果是vite项目,可通过安装插件简化初始化(其他构建工具如`webpack`请参考[monaco-yaml文档](https://github.com/remcohaszing/monaco-yaml?tab=readme-ov-file#using-monaco-webpack-loader-plugin))。
|
|
32
|
-
|
|
33
|
-
1. 安装`vite-plugin-monaco-editor`。
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
npm install vite-plugin-monaco-editor
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
2. 配置`vite.config.ts`。
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
import { defineConfig } from "vite";
|
|
43
|
-
import monacoEditor from "vite-plugin-monaco-editor";
|
|
44
|
-
export default defineConfig({
|
|
45
|
-
plugins: [
|
|
46
|
-
monacoEditor({
|
|
47
|
-
languageWorkers: ["editorWorkerService"],
|
|
48
|
-
customWorkers: [
|
|
49
|
-
{
|
|
50
|
-
label: "yaml",
|
|
51
|
-
entry: "monaco-yaml/yaml.worker"
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
})
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
3. 代码中配置schema(请根据需求自行修改`fileMatch`)。
|
|
60
|
-
|
|
61
|
-
```javascript
|
|
62
|
-
import * as monaco from "monaco-editor";
|
|
63
|
-
import { configureMonacoYaml } from "monaco-yaml";
|
|
64
|
-
|
|
65
|
-
configureMonacoYaml(monaco, {
|
|
66
|
-
validate: true,
|
|
67
|
-
enableSchemaRequest: true,
|
|
68
|
-
schemas: [
|
|
69
|
-
{
|
|
70
|
-
uri: "https://fastly.jsdelivr.net/gh/dongchengjie/airport@main/meta-json-schema.json",
|
|
71
|
-
fileMatch: ["**/*.clash.yaml"]
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
});
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
</details>
|
|
78
|
-
|
|
79
|
-
## 可视化
|
|
80
|
-
|
|
81
|
-
- <a href="https://dongchengjie.github.io/meta-json-schema/?schema=https://raw.githubusercontent.com/dongchengjie/meta-json-schema/main/schemas/meta-json-schema.json" target="_blank">meta-json-schema</a>
|
|
82
|
-
|
|
83
|
-
- <a href="https://dongchengjie.github.io/meta-json-schema/?schema=https://raw.githubusercontent.com/dongchengjie/meta-json-schema/main/schemas/clash-verge-merge-json-schema.json" target="_blank">clash-verge-merge-json-schema</a>
|
|
84
|
-
|
|
85
|
-
## 🖥️ 开发
|
|
86
|
-
|
|
87
|
-
1. 下载代码
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
git clone https://github.com/dongchengjie/meta-json-schema.git
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
2. 使用Visual Studio Code打开项目(工作目录为.vscode所在目录)。
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
code /path/to/project/location
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
> [!NOTE]
|
|
100
|
-
> 项目打开后会弹出建议安装YAML插件的提示,请点击确认安装或手动安装,以获取良好的开发体验。
|
|
101
|
-
|
|
102
|
-
3. 安装依赖
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
npm install
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
4. 启动项目。执行下列命令后,会对`src`目录进行监视,如果发生变动则会对项目进行bundle,输出到`.temp`目录下。
|
|
109
|
-
|
|
110
|
-
```
|
|
111
|
-
npm run dev
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
5. 测试schema。由于`.vscode`目录下`settings.json`中已事先配置了如下配置(`test`目录下的文件使用`.temp`目录下输出的schema文件)。因此可以对`src`进行修改,并在`test`目录下新增测试文件,及时观察变动并做出修正。
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
"yaml.schemas": {
|
|
118
|
-
".temp/meta-json-schema.json": "test/clash-meta/**/*.yaml",
|
|
119
|
-
".temp/clash-verge-merge-json-schema.json": "test/clash-verge/**/*.yaml"
|
|
120
|
-
},
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
6. 发布release。执行下列命令后,会根据`package.json`文件中定义的`releases`进行输出,并根据`optimization`决定是否进行压缩。
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
npm run release
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## 语法参考
|
|
130
|
-
|
|
131
|
-
<details>
|
|
132
|
-
<summary>JSON Schema标准语法</summary>
|
|
133
|
-
|
|
134
|
-
项目使用的JSON Schema版本为[`draft-07`](https://json-schema.org/draft-07/json-schema-release-notes),语法请参考[JSON Schema Reference](https://json-schema.org/understanding-json-schema/reference)。
|
|
135
|
-
|
|
136
|
-
</details>
|
|
137
|
-
|
|
138
|
-
<details>
|
|
139
|
-
<summary>Monaco Editor扩展语法</summary>
|
|
140
|
-
|
|
141
|
-
> Monaco 编辑器是为 VS Code 提供支持的开源代码编辑器,使用下列属性提供更丰富的`Snippet`支持。
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
interface JSONSchema {
|
|
145
|
-
// 自定义Snippet建议(数组)
|
|
146
|
-
defaultSnippets?: {
|
|
147
|
-
label: string; // 标签文本(索引)
|
|
148
|
-
description?: string; // 标签描述(需要点击展开)
|
|
149
|
-
markdownDescription?: string; // 标签描述(需要点击展开,markdown格式,优先级高于description,)
|
|
150
|
-
body: any; // 实际取值内容
|
|
151
|
-
bodyText?: string; // 实际取值内容文本(暂无作用)
|
|
152
|
-
}[];
|
|
153
|
-
errorMessage?: string; // 错误信息
|
|
154
|
-
patternErrorMessage?: string; // 格式错误信息(优先级高于errorMessage)
|
|
155
|
-
deprecationMessage?: string; // 过时错误信息
|
|
156
|
-
enumDescriptions?: string[]; // 枚举描述信息(数组)
|
|
157
|
-
markdownEnumDescriptions?: string[]; // 枚举描述信息(markdown格式)
|
|
158
|
-
markdownDescription?: string; // 描述信息(markdown格式)
|
|
159
|
-
doNotSuggest?: boolean; // 不显示建议
|
|
160
|
-
suggestSortText?: string; // 属性值建议排序符(默认为属性名)
|
|
161
|
-
allowComments?: boolean; // 允许注释
|
|
162
|
-
allowTrailingCommas?: boolean; // 允许尾随逗号
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
</details>
|
|
167
|
-
|
|
168
|
-
## FAQ
|
|
169
|
-
|
|
170
|
-
### definitions中的`compatible.json`文件的用途是什么?
|
|
171
|
-
|
|
172
|
-
YAML支持`Folded Style`和`Inline Style`的写法。
|
|
173
|
-
使用`"type": "boolean"`来定义某个属性,那么`'true'`和`'false'`就会提示`Incorrect type. Expected "boolean".`。因此引入compatible类型,以兼容多种编码风格。
|
|
174
|
-
|
|
175
|
-
<details>
|
|
176
|
-
<summary>Inline Style</summary>
|
|
177
|
-
|
|
178
|
-
```
|
|
179
|
-
proxies:
|
|
180
|
-
- {name:
|
|
181
|
-
- {name: proxy2, type: ss, cipher: auto, tls: true}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
</details>
|
|
185
|
-
|
|
186
|
-
<details>
|
|
187
|
-
<summary>Folded Style</summary>
|
|
188
|
-
|
|
189
|
-
```
|
|
190
|
-
proxies:
|
|
191
|
-
- name:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
- name: proxy1
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
</details>
|
|
202
|
-
|
|
203
|
-
> [!NOTE]
|
|
204
|
-
> 由于这种情况多发生于`proxies`配置部分,所以目前仅`proxies`配置中使用了`compatible.json`,其余地方可视情况使用。
|
|
1
|
+
### 🧩 VSCode 插件
|
|
2
|
+
|
|
3
|
+
VS Code 扩展商店搜索 `Meta JSON Schema` 或 `ClashMeta.meta-json-schema`,安装扩展后即可获取 `Clash.Meta`的语法支持。
|
|
4
|
+
|
|
5
|
+
## 💡 用法
|
|
6
|
+
|
|
7
|
+
<details>
|
|
8
|
+
<summary>Visual Studio Code中使用</summary>
|
|
9
|
+
|
|
10
|
+
1. 安装YAML语法支持插件`redhat.vscode-yaml`。
|
|
11
|
+
2. 在`.vscode`目录下的`settings.json`文件中(如不存在则手动创建),填入以下内容。其中,key为schema文件的地址,value为路径通配符,请根据需求自行修改。
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"yaml.schemas": {
|
|
15
|
+
"https://fastly.jsdelivr.net/gh/dongchengjie/meta-json-schema@main/schemas/meta-json-schema.json": "**/*.yaml"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
</details>
|
|
21
|
+
<details>
|
|
22
|
+
<summary>Monaco Editor中使用</summary>
|
|
23
|
+
|
|
24
|
+
1. 安装`monaco-editor`(编辑器)和`monaco-yaml`(YAML支持)。
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npm install monaco-editor
|
|
28
|
+
npm install monaco-yaml
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
2. 如果是vite项目,可通过安装插件简化初始化(其他构建工具如`webpack`请参考[monaco-yaml文档](https://github.com/remcohaszing/monaco-yaml?tab=readme-ov-file#using-monaco-webpack-loader-plugin))。
|
|
32
|
+
|
|
33
|
+
1. 安装`vite-plugin-monaco-editor`。
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
npm install vite-plugin-monaco-editor
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. 配置`vite.config.ts`。
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { defineConfig } from "vite";
|
|
43
|
+
import monacoEditor from "vite-plugin-monaco-editor";
|
|
44
|
+
export default defineConfig({
|
|
45
|
+
plugins: [
|
|
46
|
+
monacoEditor({
|
|
47
|
+
languageWorkers: ["editorWorkerService"],
|
|
48
|
+
customWorkers: [
|
|
49
|
+
{
|
|
50
|
+
label: "yaml",
|
|
51
|
+
entry: "monaco-yaml/yaml.worker"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
3. 代码中配置schema(请根据需求自行修改`fileMatch`)。
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
import * as monaco from "monaco-editor";
|
|
63
|
+
import { configureMonacoYaml } from "monaco-yaml";
|
|
64
|
+
|
|
65
|
+
configureMonacoYaml(monaco, {
|
|
66
|
+
validate: true,
|
|
67
|
+
enableSchemaRequest: true,
|
|
68
|
+
schemas: [
|
|
69
|
+
{
|
|
70
|
+
uri: "https://fastly.jsdelivr.net/gh/dongchengjie/airport@main/meta-json-schema.json",
|
|
71
|
+
fileMatch: ["**/*.clash.yaml"]
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
</details>
|
|
78
|
+
|
|
79
|
+
## 👓 JSON Schema可视化
|
|
80
|
+
|
|
81
|
+
- <a href="https://dongchengjie.github.io/meta-json-schema/?schema=https://raw.githubusercontent.com/dongchengjie/meta-json-schema/main/schemas/meta-json-schema.json" target="_blank">meta-json-schema</a>
|
|
82
|
+
|
|
83
|
+
- <a href="https://dongchengjie.github.io/meta-json-schema/?schema=https://raw.githubusercontent.com/dongchengjie/meta-json-schema/main/schemas/clash-verge-merge-json-schema.json" target="_blank">clash-verge-merge-json-schema</a>
|
|
84
|
+
|
|
85
|
+
## 🖥️ 开发
|
|
86
|
+
|
|
87
|
+
1. 下载代码
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/dongchengjie/meta-json-schema.git
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
2. 使用Visual Studio Code打开项目(工作目录为.vscode所在目录)。
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
code /path/to/project/location
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
> [!NOTE]
|
|
100
|
+
> 项目打开后会弹出建议安装YAML插件的提示,请点击确认安装或手动安装,以获取良好的开发体验。
|
|
101
|
+
|
|
102
|
+
3. 安装依赖
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm install
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
4. 启动项目。执行下列命令后,会对`src`目录进行监视,如果发生变动则会对项目进行bundle,输出到`.temp`目录下。
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm run dev
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
5. 测试schema。由于`.vscode`目录下`settings.json`中已事先配置了如下配置(`test`目录下的文件使用`.temp`目录下输出的schema文件)。因此可以对`src`进行修改,并在`test`目录下新增测试文件,及时观察变动并做出修正。
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
"yaml.schemas": {
|
|
118
|
+
".temp/meta-json-schema.json": "test/clash-meta/**/*.yaml",
|
|
119
|
+
".temp/clash-verge-merge-json-schema.json": "test/clash-verge/**/*.yaml"
|
|
120
|
+
},
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
6. 发布release。执行下列命令后,会根据`package.json`文件中定义的`releases`进行输出,并根据`optimization`决定是否进行压缩。
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm run release
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## 📚 语法参考
|
|
130
|
+
|
|
131
|
+
<details>
|
|
132
|
+
<summary>JSON Schema标准语法</summary>
|
|
133
|
+
|
|
134
|
+
项目使用的JSON Schema版本为[`draft-07`](https://json-schema.org/draft-07/json-schema-release-notes),语法请参考[JSON Schema Reference](https://json-schema.org/understanding-json-schema/reference)。
|
|
135
|
+
|
|
136
|
+
</details>
|
|
137
|
+
|
|
138
|
+
<details>
|
|
139
|
+
<summary>Monaco Editor扩展语法</summary>
|
|
140
|
+
|
|
141
|
+
> Monaco 编辑器是为 VS Code 提供支持的开源代码编辑器,使用下列属性提供更丰富的`Snippet`支持。
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
interface JSONSchema {
|
|
145
|
+
// 自定义Snippet建议(数组)
|
|
146
|
+
defaultSnippets?: {
|
|
147
|
+
label: string; // 标签文本(索引)
|
|
148
|
+
description?: string; // 标签描述(需要点击展开)
|
|
149
|
+
markdownDescription?: string; // 标签描述(需要点击展开,markdown格式,优先级高于description,)
|
|
150
|
+
body: any; // 实际取值内容
|
|
151
|
+
bodyText?: string; // 实际取值内容文本(暂无作用)
|
|
152
|
+
}[];
|
|
153
|
+
errorMessage?: string; // 错误信息
|
|
154
|
+
patternErrorMessage?: string; // 格式错误信息(优先级高于errorMessage)
|
|
155
|
+
deprecationMessage?: string; // 过时错误信息
|
|
156
|
+
enumDescriptions?: string[]; // 枚举描述信息(数组)
|
|
157
|
+
markdownEnumDescriptions?: string[]; // 枚举描述信息(markdown格式)
|
|
158
|
+
markdownDescription?: string; // 描述信息(markdown格式)
|
|
159
|
+
doNotSuggest?: boolean; // 不显示建议
|
|
160
|
+
suggestSortText?: string; // 属性值建议排序符(默认为属性名)
|
|
161
|
+
allowComments?: boolean; // 允许注释
|
|
162
|
+
allowTrailingCommas?: boolean; // 允许尾随逗号
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
</details>
|
|
167
|
+
|
|
168
|
+
## 🤔 FAQ
|
|
169
|
+
|
|
170
|
+
### definitions中的`compatible.json`文件的用途是什么?
|
|
171
|
+
|
|
172
|
+
YAML支持`Folded Style`和`Inline Style`的写法。
|
|
173
|
+
使用`"type": "boolean"`来定义某个属性,那么`'true'`和`'false'`就会提示`Incorrect type. Expected "boolean".`。因此引入compatible类型,以兼容多种编码风格。
|
|
174
|
+
|
|
175
|
+
<details>
|
|
176
|
+
<summary>Inline Style</summary>
|
|
177
|
+
|
|
178
|
+
```yaml
|
|
179
|
+
proxies:
|
|
180
|
+
- { name: "proxy1", type: "ss", cipher: "auto", tls: "true" }
|
|
181
|
+
- { name: proxy2, type: ss, cipher: auto, tls: true }
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
</details>
|
|
185
|
+
|
|
186
|
+
<details>
|
|
187
|
+
<summary>Folded Style</summary>
|
|
188
|
+
|
|
189
|
+
```yaml
|
|
190
|
+
proxies:
|
|
191
|
+
- name: "proxy1"
|
|
192
|
+
type: "ss"
|
|
193
|
+
cipher: "auto"
|
|
194
|
+
tls: "true"
|
|
195
|
+
- name: proxy1
|
|
196
|
+
type: ss
|
|
197
|
+
cipher: auto
|
|
198
|
+
tls: true
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
</details>
|
|
202
|
+
|
|
203
|
+
> [!NOTE]
|
|
204
|
+
> 由于这种情况多发生于`proxies`配置部分,所以目前仅`proxies`配置中使用了`compatible.json`,其余地方可视情况使用。
|
package/package.json
CHANGED
|
@@ -1,41 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "meta-json-schema",
|
|
3
|
-
"version": "1.18.4-
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"clash
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "meta-json-schema",
|
|
3
|
+
"version": "1.18.4-beta6",
|
|
4
|
+
"description": "JSON Schema for Clash Meta",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"clash",
|
|
7
|
+
"clash.meta",
|
|
8
|
+
"schema"
|
|
9
|
+
],
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"registry": "https://registry.npmjs.org"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/dongchengjie/meta-json-schema",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/dongchengjie/meta-json-schema/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/dongchengjie/meta-json-schema"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"dev": "node ./scripts/watch.mjs",
|
|
24
|
+
"release": "node ./scripts/release.mjs"
|
|
25
|
+
},
|
|
26
|
+
"config": {
|
|
27
|
+
"watches": [
|
|
28
|
+
"./src/meta-json-schema.json",
|
|
29
|
+
"./src/clash-verge-merge-json-schema.json"
|
|
30
|
+
],
|
|
31
|
+
"releases": [
|
|
32
|
+
{
|
|
33
|
+
"enabled": true,
|
|
34
|
+
"source": "./src/meta-json-schema.json",
|
|
35
|
+
"target": "./schemas/meta-json-schema.json",
|
|
36
|
+
"optimization": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"enabled": true,
|
|
40
|
+
"source": "./src/clash-verge-merge-json-schema.json",
|
|
41
|
+
"target": "./schemas/clash-verge-merge-json-schema.json",
|
|
42
|
+
"optimization": true
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@apidevtools/json-schema-ref-parser": "^11.5.4",
|
|
48
|
+
"prettier": "^3.2.5"
|
|
49
|
+
}
|
|
50
|
+
}
|