@black-duty/sing-box-schema 1.12.2 → 1.12.22

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  > Provides type-safe [**sing-box**](https://sing-box.sagernet.org/) configuration syntax support for code editors / TypeScript projects
6
6
 
7
- [![Version - v1.12.2](https://img.shields.io/badge/Version-v1.12.2-yellow?style=for-the-badge&logo=task&logoColor=white)](https://github.com/SagerNet/sing-box/tree/v1.12.2) [![JSON Schema - Draft 2020-12](/badges/JSON_Schema-Draft_2020--12-white.svg)](https://json-schema.org/draft/2020-12) [![Typescript - 5](https://img.shields.io/badge/typescript-5-grey.svg?style=for-the-badge&logo=typescript&logoColor=white&labelColor=007ACC)]([https://](https://www.typescriptlang.org/)) [![Zod - 4](https://img.shields.io/badge/Zod-4-grey.svg?style=for-the-badge&logo=zod&logoColor=white&labelColor=408AFE)](https://zod.dev)
7
+ [![Version - v1.12.22](https://img.shields.io/badge/Version-v1.12.22-yellow?style=for-the-badge&logo=task&logoColor=white)](https://github.com/SagerNet/sing-box/tree/v1.12.22) [![JSON Schema - Draft 2020-12](/badges/JSON_Schema-Draft_2020--12-white.svg)](https://json-schema.org/draft/2020-12) [![Typescript - 5](https://img.shields.io/badge/typescript-5-grey.svg?style=for-the-badge&logo=typescript&logoColor=white&labelColor=007ACC)](<[https://](https://www.typescriptlang.org/)>) [![Zod - 4](https://img.shields.io/badge/Zod-4-grey.svg?style=for-the-badge&logo=zod&logoColor=white&labelColor=408AFE)](https://zod.dev)
8
8
 
9
9
  **English** | [**中文**](/README_ZH.md)
10
10
 
@@ -16,6 +16,17 @@ Sing-box v1.12.x
16
16
 
17
17
  This project's tags correspond to the `sing-box` project's versions. Switch to different tags to get configuration formats compatible with different `sing-box` versions.
18
18
 
19
+ ## Branch Description
20
+
21
+ This project has the following branches, each adapted to different versions of `sing-box`:
22
+
23
+ - **main**: The main branch with the latest commits.
24
+ - **stable**: Adapts to the stable version of `sing-box` (currently v1.12.x).
25
+ - **legacy**: Adapts to older versions of `sing-box` (e.g., older versions in the Play Store / App Store that cannot be updated), currently v1.11.x.
26
+ - ** next**: Adapts to the actively developed version of `sing-box` (currently v1.13.x).
27
+
28
+ Developers can switch between different branches to adapt to their progress. For regular users, it is recommended to use tags to locate specific versions.
29
+
19
30
  ## Usage
20
31
 
21
32
  ### JSON Schema / For Users
@@ -24,7 +35,7 @@ You can use it in Visual Studio Code or other JSON Schema-supported editors. Ope
24
35
 
25
36
  ```json
26
37
  {
27
- "$schema": "https://unpkg.com/@black-duty/sing-box-schema@1.12.2/schema.json"
38
+ "$schema": "https://unpkg.com/@black-duty/sing-box-schema@1.12.22/schema.json"
28
39
  }
29
40
  ```
30
41
 
@@ -32,61 +43,82 @@ Or use the Chinese version:
32
43
 
33
44
  ```json
34
45
  {
35
- "$schema": "https://unpkg.com/@black-duty/sing-box-schema@1.12.2/schema.zh.json"
46
+ "$schema": "https://unpkg.com/@black-duty/sing-box-schema@1.12.22/schema.zh.json"
36
47
  }
37
48
  ```
38
49
 
39
- In addition to Unpkg's npm mirror, you can also directly use links from the GitHub repository or GitHub Releases:
50
+ In addition to Unpkg's npm mirror, you can use:
51
+
52
+ <details>
53
+ <summary>GitHub Repository</summary>
54
+
55
+ ```json
56
+ {
57
+ "$schema": "https://raw.githubusercontent.com/BlackDuty/sing-box-schema/refs/tags/v1.12.22/schema.json"
58
+ }
59
+ ```
60
+
61
+ Or use the Chinese version:
62
+
63
+ ```json
64
+ {
65
+ "$schema": "https://raw.githubusercontent.com/BlackDuty/sing-box-schema/refs/tags/v1.12.22/schema.zh.json"
66
+ }
67
+ ```
40
68
 
41
- - GitHub Repository (raw.githubusercontent.com):
69
+ </details>
70
+ <details>
71
+ <summary>Github Release</summary>
42
72
 
43
73
  ```json
44
74
  {
45
- "$schema": "https://raw.githubusercontent.com/BlackDuty/sing-box-schema/refs/tags/v1.12.2/schema.json"
75
+ "$schema": "https://github.com/BlackDuty/sing-box-schema/releases/download/v1.12.22/schema.json"
46
76
  }
47
77
  ```
48
78
 
49
- - GitHub Releases (for specific versions):
79
+ Or use the Chinese version:
50
80
 
51
81
  ```json
52
82
  {
53
- "$schema": "https://github.com/BlackDuty/sing-box-schema/releases/download/v1.12.2/schema.json"
83
+ "$schema": "https://github.com/BlackDuty/sing-box-schema/releases/download/v1.12.22/schema.zh.json"
54
84
  }
55
85
  ```
56
86
 
87
+ </details>
88
+
57
89
  ### Zod Schema / For Developers
58
90
 
59
91
  If you are a developer working with `sing-box` configurations in a TypeScript or JavaScript project, you can use the `Configuration` Schema to validate your configuration objects programmatically.
60
92
 
61
93
  ```typescript
62
- import { Configuration } from '@black-duty/sing-box-schema';
94
+ import { Configuration } from "@black-duty/sing-box-schema";
63
95
 
64
96
  // Your sing-box configuration object
65
97
  const myConfig = {
66
- "log": {
67
- "level": "info"
98
+ log: {
99
+ level: "info",
68
100
  },
69
- "inbounds": [
101
+ inbounds: [
70
102
  {
71
- "type": "socks",
72
- "listen": "127.0.0.1",
73
- "listen_port": 1080
74
- }
103
+ type: "socks",
104
+ listen: "127.0.0.1",
105
+ listen_port: 1080,
106
+ },
75
107
  ],
76
- "outbounds": [
108
+ outbounds: [
77
109
  {
78
- "type": "direct"
79
- }
80
- ]
110
+ type: "direct",
111
+ },
112
+ ],
81
113
 
82
114
  // ... more configurations
83
115
  };
84
116
 
85
117
  try {
86
118
  const validatedConfig = Configuration.parse(myConfig);
87
- console.log('Configuration is valid!', validatedConfig);
119
+ console.log("Configuration is valid!", validatedConfig);
88
120
  } catch (error) {
89
- console.error('Configuration is invalid:', error);
121
+ console.error("Configuration is invalid:", error);
90
122
  // 'error' will be a ZodError instance with detailed validation issues.
91
123
  }
92
124
  ```
@@ -108,31 +140,40 @@ yarn add @black-duty/sing-box-schema
108
140
  If you wish to contribute to the `sing-box-schema` project or develop locally, please follow these steps:
109
141
 
110
142
  1. **Clone the repository**:
143
+
111
144
  ```bash
112
145
  git clone https://github.com/BlackDuty/sing-box-schema.git
113
146
  cd sing-box-schema
114
147
  ```
148
+
115
149
  2. **Install dependencies**:
150
+
116
151
  ```bash
117
152
  bun install
118
153
  ```
154
+
119
155
  3. **Build the project**:
156
+
120
157
  ```bash
121
158
  bun run build
122
159
  ```
123
- This will compile the TypeScript code and generate the JSON Schema files in the `dist` directory.
124
- 4. **Code Linting and Formatting**:
160
+
161
+ This will compile the TypeScript code and generate the JSON Schema files in the `dist` directory. 4. **Code Linting and Formatting**:
162
+
125
163
  ```bash
126
164
  bun run lint
127
165
  ```
166
+
128
167
  5. **Manually Generate JSON Schema**:
168
+
129
169
  ```bash
130
170
  bun run generate
131
171
  ```
172
+
132
173
  This command is automatically run during the `build` process, but you can run it manually if needed.
133
174
 
134
175
  Contributions are welcome! Feel free to open an issue or submit a pull request.
135
176
 
136
177
  ## License
137
178
 
138
- This project is licensed under the MIT License.
179
+ This project is licensed under the MIT License.