@amxts/config-core 0.1.0 → 0.1.1
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/PAWN.md +2 -2
- package/PAWN.ru.md +2 -2
- package/README.md +9 -1
- package/README.ru.md +9 -1
- package/package.json +2 -2
- package/prebuilt/linux/config-core.aot +0 -0
- package/prebuilt/manifest.json +17 -9
- package/prebuilt/windows/config-core.aot +0 -0
- package/src/files.ts +3 -3
- package/src/index.ts +1 -1
- package/src/ini.ts +1 -1
- package/src/natives.ts +5 -5
package/PAWN.md
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
Config Core gives Pawn plugins the 28 natives of `universal_config.inc` — `cfg_load_file`, `cfg_get_value`, `cfg_set_int` and the rest — with their signatures, so compiled `.amxx` plugins (Menu Core's Pawn users among them) work against it unchanged.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Pawn plugins write `#include <universal_config>`; the package ships `include/universal_config.inc`. Only one plugin on a server can give these natives: if another Pawn plugin in `plugins.ini` registers `cfg_*` natives too, comment it out.
|
|
8
8
|
|
|
9
9
|
## How the natives behave
|
|
10
10
|
|
|
11
|
-
- No
|
|
11
|
+
- No length limits: a key or a value is as long as it is written, a section keeps every entry, blocks nest as deep as they are written, any number of files loads.
|
|
12
12
|
- A number reads the way `parseFloat` reads it (`1e5` is 100000) and is written as the number it is (`2.5`, not `2.500000`).
|
|
13
13
|
- `CFG_CONTENT_SIMPLE` and `CFG_CONTENT_STRINGS` are one content: a block of either holds a line of values, and `cfg_set_value` writes into it.
|
package/PAWN.ru.md
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
Config Core отдаёт Pawn-плагинам 28 нативов из `universal_config.inc` — `cfg_load_file`, `cfg_get_value`, `cfg_set_int` и остальные — с их сигнатурами, так что собранные `.amxx`-плагины (в том числе Pawn-плагины, работающие с Menu Core) работают без изменений.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Pawn-плагины пишут `#include <universal_config>`; в пакете лежит `include/universal_config.inc`. Отдавать эти нативы на сервере может только один плагин: если в `plugins.ini` есть другой Pawn-плагин с нативами `cfg_*`, закомментируйте его.
|
|
8
8
|
|
|
9
9
|
## Как работают нативы
|
|
10
10
|
|
|
11
|
-
- Нет ограничений
|
|
11
|
+
- Нет ограничений длины: ключ и значение любой длины, секция хранит все записи, блоки вложены на любую глубину, загружается сколько угодно файлов.
|
|
12
12
|
- Число читается так, как его читает `parseFloat` (`1e5` — это 100000), и записывается как есть (`2.5`, а не `2.500000`).
|
|
13
13
|
- `CFG_CONTENT_SIMPLE` и `CFG_CONTENT_STRINGS` — одно и то же содержимое: блок любого из них хранит строку значений, и `cfg_set_value` пишет в него.
|
package/README.md
CHANGED
|
@@ -246,4 +246,12 @@ for (const row of settings.MAIN.CVARS) {
|
|
|
246
246
|
|
|
247
247
|
## Pawn plugins
|
|
248
248
|
|
|
249
|
-
Pawn
|
|
249
|
+
A Pawn plugin reads and writes configs through Config Core too, with its 28 natives whose names start with `cfg_`: `cfg_load_file`, `cfg_get_value`, `cfg_set_int` and the rest. They read INI files. The package ships their include in `include/`:
|
|
250
|
+
|
|
251
|
+
```pawn
|
|
252
|
+
#include <universal_config>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
A Pawn plugin already compiled against this include works as it is, with nothing to rebuild.
|
|
256
|
+
|
|
257
|
+
Config Core runs on the server as one of the project's plugins. When no TypeScript plugin of the project uses it, keep it in the build for the Pawn plugins: `pawn: ["@amxts/config-core"]` in `amxts.config.ts`. Every native with its signature: [PAWN.md](PAWN.md).
|
package/README.ru.md
CHANGED
|
@@ -246,4 +246,12 @@ for (const row of settings.MAIN.CVARS) {
|
|
|
246
246
|
|
|
247
247
|
## Pawn-плагины
|
|
248
248
|
|
|
249
|
-
Pawn
|
|
249
|
+
Pawn-плагин тоже читает и пишет конфиги через Config Core — 28 нативами, имена которых начинаются с `cfg_`: `cfg_load_file`, `cfg_get_value`, `cfg_set_int` и остальные. Они читают INI-файлы. Их include лежит в пакете в `include/`:
|
|
250
|
+
|
|
251
|
+
```pawn
|
|
252
|
+
#include <universal_config>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Pawn-плагин, уже собранный с этим include, работает как есть — пересобирать ничего не нужно.
|
|
256
|
+
|
|
257
|
+
Config Core работает на сервере как один из плагинов проекта. Если им не пользуется ни один плагин проекта на TypeScript, оставьте его в сборке для Pawn-плагинов: `pawn: ["@amxts/config-core"]` в `amxts.config.ts`. Все нативы с сигнатурами — в [PAWN.ru.md](PAWN.ru.md).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amxts/config-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "Configs in INI, YAML or JSON for amxts plugins, read into typed objects and written back - and the cfg_* natives for Pawn plugins.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "kukson777",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"lint:fix": "oxfmt && oxlint --fix --silent || oxlint --fix --silent || oxlint --fix"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@amxts/core": "^0.
|
|
48
|
+
"@amxts/core": "^0.2.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@e18e/eslint-plugin": "^0.8.1",
|
|
Binary file
|
package/prebuilt/manifest.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"format": 1,
|
|
3
3
|
"module": "@amxts/config-core",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"from": {
|
|
6
6
|
"@amxts/core": {
|
|
7
|
-
"version": "0.
|
|
8
|
-
"hash": "
|
|
7
|
+
"version": "0.2.0",
|
|
8
|
+
"hash": "86146344f98b3f7285b3307a254d359d7080ae7c"
|
|
9
9
|
},
|
|
10
10
|
"@amxts/config-core": {
|
|
11
|
-
"version": "0.1.
|
|
12
|
-
"hash": "
|
|
11
|
+
"version": "0.1.1",
|
|
12
|
+
"hash": "1e49ebcfbf431b802df05bacaae593ab563b5119"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"options": {
|
|
@@ -25,9 +25,12 @@
|
|
|
25
25
|
"entities.ts",
|
|
26
26
|
"events.ts",
|
|
27
27
|
"facade.ts",
|
|
28
|
+
"fetch.ts",
|
|
28
29
|
"flags.ts",
|
|
29
30
|
"fs.ts",
|
|
31
|
+
"hlds.ts",
|
|
30
32
|
"hooks.ts",
|
|
33
|
+
"kit.ts",
|
|
31
34
|
"modules/config-core.ts",
|
|
32
35
|
"modules/config-core/src/files.ts",
|
|
33
36
|
"modules/config-core/src/ini-tree.ts",
|
|
@@ -2269,13 +2272,18 @@
|
|
|
2269
2272
|
"systems": {
|
|
2270
2273
|
"windows": {
|
|
2271
2274
|
"file": "prebuilt/windows/config-core.aot",
|
|
2272
|
-
"size":
|
|
2273
|
-
"sha256": "
|
|
2275
|
+
"size": 1211754,
|
|
2276
|
+
"sha256": "2d71649ae35f4065e3a0ecfa0189ea8ba43a877727d7afc7066548306e027f1d"
|
|
2274
2277
|
},
|
|
2275
2278
|
"linux": {
|
|
2276
2279
|
"file": "prebuilt/linux/config-core.aot",
|
|
2277
|
-
"size":
|
|
2278
|
-
"sha256": "
|
|
2280
|
+
"size": 1226178,
|
|
2281
|
+
"sha256": "76e0726ea2dc34ca11f2be6d78b22f78b87f2f6d245cdea30b4a966d203a2e8d"
|
|
2279
2282
|
}
|
|
2283
|
+
},
|
|
2284
|
+
"surface": {
|
|
2285
|
+
"proxy": "// GENERATED by scripts/shared-modules.ts: ~/modules/config-core in a plugin that does not own it.\n// Each function runs in config-core.aot, the one instance on the server.\nimport { Reader as __Reader, Writer as __Writer, beginCallback as __beginCallback, callBack as __callBack, receiveFunction as __receiveFunction, remoteTarget as __remoteTarget, sendFunction as __sendFunction, Service as __Service } from \"~/remote\";\nimport { Player as __Player } from \"~/facade\";\n\nexport type ConfigFormat = \"ini\" | \"yaml\" | \"json\";\n\nexport type ConfigKind = \"object\" | \"array\" | \"string\" | \"number\" | \"boolean\" | \"null\";\n\nexport interface ConfigCoreOptions {\n\t/** The folder under `configs/` that names are loaded from, e.g. `\"myserver\"`; `\"\"` is `configs/` itself. */\n\tbaseDir: string;\n}\n\n/** ConfigNode in config-core's plugin: each field is read and written there, each method runs there. */\nexport class ConfigNode {\n\tconstructor(public __handle: i32) {}\n\n\tget kind(): string {\n\t\tconst w = __service.begin(6);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\n\tget key(): string {\n\t\tconst w = __service.begin(7);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\n\tget file(): string {\n\t\tconst w = __service.begin(8);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\n\tget format(): string {\n\t\tconst w = __service.begin(9);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\n\tget line(): f64 {\n\t\tconst w = __service.begin(10);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\n\tget column(): f64 {\n\t\tconst w = __service.begin(11);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\n\tget(path: string): ConfigNode | null {\n\t\tconst __w = __service.begin(12);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, path);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r2(__r);\n\t}\n\n\thas(path: string): bool {\n\t\tconst __w = __service.begin(13);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, path);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r4(__r);\n\t}\n\n\tkeys(path?: string): Array<string> {\n\t\tconst __w = __service.begin(14);\n\t\t__w.i32(this.__handle);\n\t\t__w5(__w, path);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r6(__r);\n\t}\n\n\tvalues(path?: string): Array<ConfigNode> {\n\t\tconst __w = __service.begin(15);\n\t\t__w.i32(this.__handle);\n\t\t__w5(__w, path);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r7(__r);\n\t}\n\n\tgetString(path?: string, fallback?: string): string {\n\t\tconst __w = __service.begin(16);\n\t\t__w.i32(this.__handle);\n\t\t__w5(__w, path);\n\t\t__w5(__w, fallback);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r0(__r);\n\t}\n\n\tgetNumber(path?: string, fallback = 0): f64 {\n\t\tconst __w = __service.begin(17);\n\t\t__w.i32(this.__handle);\n\t\t__w5(__w, path);\n\t\t__w1(__w, fallback);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r1(__r);\n\t}\n\n\tgetBoolean(path?: string, fallback = false): bool {\n\t\tconst __w = __service.begin(18);\n\t\t__w.i32(this.__handle);\n\t\t__w5(__w, path);\n\t\t__w4(__w, fallback);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r4(__r);\n\t}\n\n\tgetStrings(path?: string): Array<string> {\n\t\tconst __w = __service.begin(19);\n\t\t__w.i32(this.__handle);\n\t\t__w5(__w, path);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r6(__r);\n\t}\n\n\tset(path: string, value: string): bool {\n\t\tconst __w = __service.begin(20);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, path);\n\t\t__w0(__w, value);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r4(__r);\n\t}\n\n\tsetNumber(path: string, value: number): bool {\n\t\tconst __w = __service.begin(21);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, path);\n\t\t__w1(__w, value);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r4(__r);\n\t}\n\n\tsetBoolean(path: string, value: boolean): bool {\n\t\tconst __w = __service.begin(22);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, path);\n\t\t__w4(__w, value);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r4(__r);\n\t}\n\n\tsetStrings(path: string, values: string[]): bool {\n\t\tconst __w = __service.begin(23);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, path);\n\t\t__w6(__w, values);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r4(__r);\n\t}\n\n\tremove(path: string): bool {\n\t\tconst __w = __service.begin(24);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, path);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r4(__r);\n\t}\n\n\tsave(): bool {\n\t\tconst __w = __service.begin(25);\n\t\t__w.i32(this.__handle);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r4(__r);\n\t}\n}\n\n\n\nconst __service = new __Service(\"config-core\", -1306878287);\n\nfunction __w0(w: __Writer, v: string): void { w.str(v); }\n\nfunction __r0(r: __Reader): string { return r.str(); }\n\nfunction __w1(w: __Writer, v: f64): void { w.f64(<f64>v); }\n\nfunction __r1(r: __Reader): f64 { return <f64>r.f64(); }\n\nconst __h3 = new Map<i32, ConfigNode>();\n\nfunction __w3(w: __Writer, v: ConfigNode): void { w.i32(v.__handle); }\n\nfunction __r3(r: __Reader): ConfigNode {\n\tconst id = r.i32();\n\tif (__h3.has(id)) return __h3.get(id);\n\tconst o = new ConfigNode(id);\n\t__h3.set(id, o);\n\treturn o;\n}\n\nfunction __w2(w: __Writer, v: ConfigNode | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w3(w, v!);\n}\n\nfunction __r2(r: __Reader): ConfigNode | null {\n\tif (!r.bool()) return null;\n\treturn __r3(r);\n}\n\nfunction __w4(w: __Writer, v: bool): void { w.bool(v); }\n\nfunction __r4(r: __Reader): bool { return r.bool(); }\n\nfunction __w5(w: __Writer, v: string | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w0(w, v!);\n}\n\nfunction __r5(r: __Reader): string | null {\n\tif (!r.bool()) return null;\n\treturn __r0(r);\n}\n\nfunction __w6(w: __Writer, v: Array<string>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w0(w, v[i]);\n}\n\nfunction __r6(r: __Reader): Array<string> {\n\tconst count = r.i32();\n\tconst list = new Array<string>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r0(r));\n\treturn list;\n}\n\nfunction __w7(w: __Writer, v: Array<ConfigNode>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w3(w, v[i]);\n}\n\nfunction __r7(r: __Reader): Array<ConfigNode> {\n\tconst count = r.i32();\n\tconst list = new Array<ConfigNode>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r3(r));\n\treturn list;\n}\n\nfunction __invoke(fn: usize, sig: i32, r: __Reader, w: __Writer): void {\n\tswitch (sig) {\n\n\t}\n}\n\nexport function setBaseDir(dir: string): void {\n\tconst __w = __service.begin(0);\n\t__w0(__w, dir);\n\tconst __r = __service.call(__w);\n}\n\nexport function load(name: string): ConfigNode {\n\tconst __w = __service.begin(1);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r3(__r);\n}\n\nexport function save(_settings: ConfigNode): bool {\n\tconst __w = __service.begin(2);\n\t__w3(__w, _settings);\n\tconst __r = __service.call(__w);\n\treturn __r4(__r);\n}\n\nexport function resolve(name: string): string {\n\tconst __w = __service.begin(3);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r0(__r);\n}\n\nexport function read(name: string): ConfigNode {\n\tconst __w = __service.begin(4);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r3(__r);\n}\n\nexport function parse(text: string, format: ConfigFormat): ConfigNode {\n\tconst __w = __service.begin(5);\n\t__w0(__w, text);\n\t__w0(__w, format);\n\tconst __r = __service.call(__w);\n\treturn __r3(__r);\n}\n",
|
|
2286
|
+
"serve": "// GENERATED by scripts/shared-modules.ts: ~/modules/config-core, run by this plugin for every other.\nimport { Reader as __Reader, Writer as __Writer, beginCallback as __beginCallback, callBack as __callBack, receiveFunction as __receiveFunction, remoteTarget as __remoteTarget, sendFunction as __sendFunction, Handles as __Handles, serve as __serve } from \"~/remote\";\nimport * as __m from \"~/modules/config-core\";\nimport { Player as __Player } from \"~/facade\";\nimport { ConfigNode as __M_ConfigNode } from \"~/modules/config-core\";\n\nconst __handles = new __Handles();\n// The exported objects are handles 1, 2, ... - the numbers the proxies have.\n\nfunction __dispatch(op: i32, r: __Reader, w: __Writer): void {\n\tswitch (op) {\n\t\tcase 0: {\n\t\t\tconst a0 = __r0(r);\n\t\t\t__m.setBaseDir(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.load(a0);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 2: {\n\t\t\tconst a0 = __r1(r);\n\t\t\tconst result = __m.save(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 3: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.resolve(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 4: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.read(a0);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 5: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst result = __m.parse(a0, a1);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 6: {\n\t\t\tconst o = __r1(r);\n\t\t\t__w0(w, o.kind);\n\t\t\tbreak;\n\t\t}\n\t\tcase 7: {\n\t\t\tconst o = __r1(r);\n\t\t\t__w0(w, o.key);\n\t\t\tbreak;\n\t\t}\n\t\tcase 8: {\n\t\t\tconst o = __r1(r);\n\t\t\t__w0(w, o.file);\n\t\t\tbreak;\n\t\t}\n\t\tcase 9: {\n\t\t\tconst o = __r1(r);\n\t\t\t__w0(w, o.format);\n\t\t\tbreak;\n\t\t}\n\t\tcase 10: {\n\t\t\tconst o = __r1(r);\n\t\t\t__w3(w, o.line);\n\t\t\tbreak;\n\t\t}\n\t\tcase 11: {\n\t\t\tconst o = __r1(r);\n\t\t\t__w3(w, o.column);\n\t\t\tbreak;\n\t\t}\n\t\tcase 12: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = o.get(a0);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 13: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = o.has(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 14: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst result = o.keys(a0);\n\t\t\t__w6(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 15: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst result = o.values(a0);\n\t\t\t__w7(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 16: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst a1 = __r5(r);\n\t\t\tconst result = o.getString(a0, a1);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 17: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst a1 = __r3(r);\n\t\t\tconst result = o.getNumber(a0, a1);\n\t\t\t__w3(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 18: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst a1 = __r2(r);\n\t\t\tconst result = o.getBoolean(a0, a1);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 19: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst result = o.getStrings(a0);\n\t\t\t__w6(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 20: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst result = o.set(a0, a1);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 21: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r3(r);\n\t\t\tconst result = o.setNumber(a0, a1);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 22: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r2(r);\n\t\t\tconst result = o.setBoolean(a0, a1);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 23: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r6(r);\n\t\t\tconst result = o.setStrings(a0, a1);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 24: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = o.remove(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 25: {\n\t\t\tconst o = __r1(r);\n\t\t\tconst result = o.save();\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction __invoke(fn: usize, sig: i32, r: __Reader, w: __Writer): void {\n\tswitch (sig) {\n\n\t}\n}\n\nfunction __w0(w: __Writer, v: string): void { w.str(v); }\n\nfunction __r0(r: __Reader): string { return r.str(); }\n\nfunction __w1(w: __Writer, v: __M_ConfigNode): void { w.i32(__handles.id(changetype<usize>(v))); }\n\nfunction __r1(r: __Reader): __M_ConfigNode { return changetype<__M_ConfigNode>(__handles.at(r.i32())); }\n\nfunction __w2(w: __Writer, v: bool): void { w.bool(v); }\n\nfunction __r2(r: __Reader): bool { return r.bool(); }\n\nfunction __w3(w: __Writer, v: f64): void { w.f64(<f64>v); }\n\nfunction __r3(r: __Reader): f64 { return <f64>r.f64(); }\n\nfunction __w4(w: __Writer, v: __M_ConfigNode | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w1(w, v!);\n}\n\nfunction __r4(r: __Reader): __M_ConfigNode | null {\n\tif (!r.bool()) return null;\n\treturn __r1(r);\n}\n\nfunction __w5(w: __Writer, v: string | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w0(w, v!);\n}\n\nfunction __r5(r: __Reader): string | null {\n\tif (!r.bool()) return null;\n\treturn __r0(r);\n}\n\nfunction __w6(w: __Writer, v: Array<string>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w0(w, v[i]);\n}\n\nfunction __r6(r: __Reader): Array<string> {\n\tconst count = r.i32();\n\tconst list = new Array<string>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r0(r));\n\treturn list;\n}\n\nfunction __w7(w: __Writer, v: Array<__M_ConfigNode>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w1(w, v[i]);\n}\n\nfunction __r7(r: __Reader): Array<__M_ConfigNode> {\n\tconst count = r.i32();\n\tconst list = new Array<__M_ConfigNode>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r1(r));\n\treturn list;\n}\n\n__serve(\"config-core\", -1306878287, __dispatch);\n",
|
|
2287
|
+
"callbacks": false
|
|
2280
2288
|
}
|
|
2281
2289
|
}
|
|
Binary file
|
package/src/files.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Where Config Core's files are: the folder under configs/ that names are
|
|
3
3
|
* relative to, and writing lines to a file. Not part of the API.
|
|
4
4
|
*/
|
|
5
|
-
import * as fs from "
|
|
6
|
-
import { EOL } from "
|
|
7
|
-
import { server } from "
|
|
5
|
+
import * as fs from "@amxts/core/fs";
|
|
6
|
+
import { EOL } from "@amxts/core/os";
|
|
7
|
+
import { server } from "@amxts/core";
|
|
8
8
|
|
|
9
9
|
let baseDir = "";
|
|
10
10
|
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* object and written back, or read as a tree of values when the shape is not
|
|
4
4
|
* known beforehand. How to use it: README.md.
|
|
5
5
|
*/
|
|
6
|
-
import * as fs from "
|
|
6
|
+
import * as fs from "@amxts/core/fs";
|
|
7
7
|
import { ConfigFormat, ConfigKind, ConfigCoreOptions } from "./types";
|
|
8
8
|
import { TreeDocument, TreeNode } from "./internal";
|
|
9
9
|
import * as tree from "./tree";
|
package/src/ini.ts
CHANGED
package/src/natives.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Config Core for Pawn plugins: the 28 cfg_* natives of the original
|
|
3
3
|
* universal_config.amxx, as include/universal_config.inc declares them.
|
|
4
4
|
*/
|
|
5
|
-
import { Player, plugin, print, server } from "
|
|
6
|
-
import { console_print } from "
|
|
5
|
+
import { Player, plugin, print, server } from "@amxts/core";
|
|
6
|
+
import { console_print } from "@amxts/core/natives";
|
|
7
7
|
import { setBaseDir } from "./index";
|
|
8
8
|
import * as ini from "./ini";
|
|
9
9
|
|
|
10
|
-
plugin({ name: "Config Core", version: "0.1.
|
|
10
|
+
plugin({ name: "Config Core", version: "0.1.1", author: "kukson777", description: "INI configs for plugins: the cfg_* natives", include: "universal_config.inc" });
|
|
11
11
|
|
|
12
12
|
/** A loaded config file. */
|
|
13
13
|
export enum ConfigFile {
|
|
@@ -33,10 +33,10 @@ export enum ContentType {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
server.addEventListener("init", () => {
|
|
36
|
-
console.log("[ConfigCore] Plugin initialized (v0.1.
|
|
36
|
+
console.log("[ConfigCore] Plugin initialized (v0.1.1)");
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
server.addCommand("dump_config", dumpConfig, { access: "
|
|
39
|
+
server.addCommand("dump_config", ({ player }) => dumpConfig(player), { access: "cvar", description: "Dumps all configurations" });
|
|
40
40
|
|
|
41
41
|
/** Every loaded section and its entries: headings to the admin's console, entries to the server's, as the original does. */
|
|
42
42
|
function dumpConfig(player: Player) {
|