@amxts/config-core 0.1.0 → 0.1.2
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 +13 -13
- package/PAWN.ru.md +13 -13
- 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 +25 -17
- package/prebuilt/windows/config-core.aot +0 -0
- package/src/files.ts +27 -27
- package/src/index.ts +360 -360
- package/src/ini.ts +1 -1
- package/src/natives.ts +271 -271
package/PAWN.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# Config Core for Pawn plugins
|
|
2
|
-
|
|
3
|
-
[English](PAWN.md) | [Русский](PAWN.ru.md)
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## How the natives behave
|
|
10
|
-
|
|
11
|
-
- No
|
|
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
|
-
- `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.
|
|
1
|
+
# Config Core for Pawn plugins
|
|
2
|
+
|
|
3
|
+
[English](PAWN.md) | [Русский](PAWN.ru.md)
|
|
4
|
+
|
|
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
|
+
|
|
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
|
+
|
|
9
|
+
## How the natives behave
|
|
10
|
+
|
|
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
|
+
- 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
|
+
- `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
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# Config Core для Pawn-плагинов
|
|
2
|
-
|
|
3
|
-
[English](PAWN.md) | [Русский](PAWN.ru.md)
|
|
4
|
-
|
|
5
|
-
Config Core отдаёт Pawn-плагинам 28 нативов из `universal_config.inc` — `cfg_load_file`, `cfg_get_value`, `cfg_set_int` и остальные — с их сигнатурами, так что собранные `.amxx`-плагины (в том числе Pawn-плагины, работающие с Menu Core) работают без изменений.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Как работают нативы
|
|
10
|
-
|
|
11
|
-
- Нет ограничений
|
|
12
|
-
- Число читается так, как его читает `parseFloat` (`1e5` — это 100000), и записывается как есть (`2.5`, а не `2.500000`).
|
|
13
|
-
- `CFG_CONTENT_SIMPLE` и `CFG_CONTENT_STRINGS` — одно и то же содержимое: блок любого из них хранит строку значений, и `cfg_set_value` пишет в него.
|
|
1
|
+
# Config Core для Pawn-плагинов
|
|
2
|
+
|
|
3
|
+
[English](PAWN.md) | [Русский](PAWN.ru.md)
|
|
4
|
+
|
|
5
|
+
Config Core отдаёт Pawn-плагинам 28 нативов из `universal_config.inc` — `cfg_load_file`, `cfg_get_value`, `cfg_set_int` и остальные — с их сигнатурами, так что собранные `.amxx`-плагины (в том числе Pawn-плагины, работающие с Menu Core) работают без изменений.
|
|
6
|
+
|
|
7
|
+
Pawn-плагины пишут `#include <universal_config>`; в пакете лежит `include/universal_config.inc`. Отдавать эти нативы на сервере может только один плагин: если в `plugins.ini` есть другой Pawn-плагин с нативами `cfg_*`, закомментируйте его.
|
|
8
|
+
|
|
9
|
+
## Как работают нативы
|
|
10
|
+
|
|
11
|
+
- Нет ограничений длины: ключ и значение любой длины, секция хранит все записи, блоки вложены на любую глубину, загружается сколько угодно файлов.
|
|
12
|
+
- Число читается так, как его читает `parseFloat` (`1e5` — это 100000), и записывается как есть (`2.5`, а не `2.500000`).
|
|
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.2",
|
|
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.2"
|
|
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.2",
|
|
5
5
|
"from": {
|
|
6
6
|
"@amxts/core": {
|
|
7
|
-
"version": "0.
|
|
8
|
-
"hash": "
|
|
7
|
+
"version": "0.2.2",
|
|
8
|
+
"hash": "71afaf25b04163866b491556b2ae1740c8109576"
|
|
9
9
|
},
|
|
10
10
|
"@amxts/config-core": {
|
|
11
|
-
"version": "0.1.
|
|
12
|
-
"hash": "
|
|
11
|
+
"version": "0.1.2",
|
|
12
|
+
"hash": "d4f17332c3543c43e4c52535a89ca218a2af1742"
|
|
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",
|
|
@@ -53,7 +56,7 @@
|
|
|
53
56
|
}
|
|
54
57
|
],
|
|
55
58
|
"result": "int",
|
|
56
|
-
"doc": "/**\n * Loads a config file from `configs/<base dir>/`; \".ini\" is added when the\n * name has none. A file that is not there still gets a handle, empty.\n */",
|
|
59
|
+
"doc": "/**\r\n * Loads a config file from `configs/<base dir>/`; \".ini\" is added when the\r\n * name has none. A file that is not there still gets a handle, empty.\r\n */",
|
|
57
60
|
"layout": [
|
|
58
61
|
{
|
|
59
62
|
"param": {
|
|
@@ -165,7 +168,7 @@
|
|
|
165
168
|
}
|
|
166
169
|
],
|
|
167
170
|
"result": "string?",
|
|
168
|
-
"doc": "/**\n * The value of a key, or of a path (\"block/subkey\"), into value[]; index is\n * the value's place in its line. false when there is none.\n */",
|
|
171
|
+
"doc": "/**\r\n * The value of a key, or of a path (\"block/subkey\"), into value[]; index is\r\n * the value's place in its line. false when there is none.\r\n */",
|
|
169
172
|
"layout": [
|
|
170
173
|
{
|
|
171
174
|
"param": {
|
|
@@ -647,7 +650,7 @@
|
|
|
647
650
|
}
|
|
648
651
|
],
|
|
649
652
|
"result": "array",
|
|
650
|
-
"doc": "/**\n * The words of a key's line (index: which line, when the key is there more\n * than once); for a block, every value of every row. The caller destroys the\n * array; Invalid_Array when there are no words.\n */",
|
|
653
|
+
"doc": "/**\r\n * The words of a key's line (index: which line, when the key is there more\r\n * than once); for a block, every value of every row. The caller destroys the\r\n * array; Invalid_Array when there are no words.\r\n */",
|
|
651
654
|
"layout": [
|
|
652
655
|
{
|
|
653
656
|
"param": {
|
|
@@ -820,7 +823,7 @@
|
|
|
820
823
|
}
|
|
821
824
|
],
|
|
822
825
|
"result": "array",
|
|
823
|
-
"doc": "/**\n * Every value of the line a path leads to (lineIndex: the row of a block), as\n * written. The caller destroys the array.\n */",
|
|
826
|
+
"doc": "/**\r\n * Every value of the line a path leads to (lineIndex: the row of a block), as\r\n * written. The caller destroys the array.\r\n */",
|
|
824
827
|
"layout": [
|
|
825
828
|
{
|
|
826
829
|
"param": {
|
|
@@ -951,7 +954,7 @@
|
|
|
951
954
|
}
|
|
952
955
|
],
|
|
953
956
|
"result": "array",
|
|
954
|
-
"doc": "/**\n * The whole section, as an array of three: the keys, the values (an array of\n * strings per key, \"{block}\" for a block) and [key, value] index pairs.\n */",
|
|
957
|
+
"doc": "/**\r\n * The whole section, as an array of three: the keys, the values (an array of\r\n * strings per key, \"{block}\" for a block) and [key, value] index pairs.\r\n */",
|
|
955
958
|
"layout": [
|
|
956
959
|
{
|
|
957
960
|
"param": {
|
|
@@ -1862,7 +1865,7 @@
|
|
|
1862
1865
|
}
|
|
1863
1866
|
],
|
|
1864
1867
|
"result": "bool",
|
|
1865
|
-
"doc": "/**\n * Writes one section to a file; the file's other sections are not in it.\n * With cfg = CFG_FILE_INVALID the section is looked for in every loaded file.\n */",
|
|
1868
|
+
"doc": "/**\r\n * Writes one section to a file; the file's other sections are not in it.\r\n * With cfg = CFG_FILE_INVALID the section is looked for in every loaded file.\r\n */",
|
|
1866
1869
|
"layout": [
|
|
1867
1870
|
{
|
|
1868
1871
|
"param": {
|
|
@@ -1941,7 +1944,7 @@
|
|
|
1941
1944
|
}
|
|
1942
1945
|
],
|
|
1943
1946
|
"result": "bool",
|
|
1944
|
-
"doc": "/**\n * Saves every section of the file with the comments it was read with. The\n * file name has to be given: without one it returns false.\n */",
|
|
1947
|
+
"doc": "/**\r\n * Saves every section of the file with the comments it was read with. The\r\n * file name has to be given: without one it returns false.\r\n */",
|
|
1945
1948
|
"layout": [
|
|
1946
1949
|
{
|
|
1947
1950
|
"param": {
|
|
@@ -2125,7 +2128,7 @@
|
|
|
2125
2128
|
}
|
|
2126
2129
|
],
|
|
2127
2130
|
"result": "bool",
|
|
2128
|
-
"doc": "/**\n * The comment line written above row `row` of the block `key` - \"; ID | VALUE\",\n * say; \"\" removes it. false when there is no such block or row.\n */",
|
|
2131
|
+
"doc": "/**\r\n * The comment line written above row `row` of the block `key` - \"; ID | VALUE\",\r\n * say; \"\" removes it. false when there is no such block or row.\r\n */",
|
|
2129
2132
|
"layout": [
|
|
2130
2133
|
{
|
|
2131
2134
|
"param": {
|
|
@@ -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": "2494ed4bb7e290df5cbc26437b79cd78705b5576ab20121f056c8b9407c917dc"
|
|
2274
2277
|
},
|
|
2275
2278
|
"linux": {
|
|
2276
2279
|
"file": "prebuilt/linux/config-core.aot",
|
|
2277
|
-
"size":
|
|
2278
|
-
"sha256": "
|
|
2280
|
+
"size": 1226178,
|
|
2281
|
+
"sha256": "ca7cd3d9d27c847c76bab5fde950254549c353ad893818fed12f2dfa0abf6e79"
|
|
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
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where Config Core's files are: the folder under configs/ that names are
|
|
3
|
-
* relative to, and writing lines to a file. Not part of the API.
|
|
4
|
-
*/
|
|
5
|
-
import * as fs from "
|
|
6
|
-
import { EOL } from "
|
|
7
|
-
import { server } from "
|
|
8
|
-
|
|
9
|
-
let baseDir = "";
|
|
10
|
-
|
|
11
|
-
/** Sets the folder under configs/ that names are relative to, e.g. "myserver"; "" is configs/ itself. */
|
|
12
|
-
export function setBaseDir(dir: string) {
|
|
13
|
-
baseDir = dir.trim();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** A file's path: under configs/ and the base folder. */
|
|
17
|
-
export function configPath(file: string) {
|
|
18
|
-
const folder = baseDir.length > 0 ? `${server.configsDir}/${baseDir}` : server.configsDir;
|
|
19
|
-
return `${folder}/${file}`;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Lines to a file, its folder made when missing, each ended as this system ends them. */
|
|
23
|
-
export function writeLines(path: string, lines: string[]) {
|
|
24
|
-
const slash = path.lastIndexOf("/");
|
|
25
|
-
if (slash > 0) fs.mkdirSync(path.slice(0, slash), { recursive: true });
|
|
26
|
-
return fs.writeFileSync(path, lines.join(EOL) + EOL);
|
|
27
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Where Config Core's files are: the folder under configs/ that names are
|
|
3
|
+
* relative to, and writing lines to a file. Not part of the API.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "@amxts/core/fs";
|
|
6
|
+
import { EOL } from "@amxts/core/os";
|
|
7
|
+
import { server } from "@amxts/core";
|
|
8
|
+
|
|
9
|
+
let baseDir = "";
|
|
10
|
+
|
|
11
|
+
/** Sets the folder under configs/ that names are relative to, e.g. "myserver"; "" is configs/ itself. */
|
|
12
|
+
export function setBaseDir(dir: string) {
|
|
13
|
+
baseDir = dir.trim();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A file's path: under configs/ and the base folder. */
|
|
17
|
+
export function configPath(file: string) {
|
|
18
|
+
const folder = baseDir.length > 0 ? `${server.configsDir}/${baseDir}` : server.configsDir;
|
|
19
|
+
return `${folder}/${file}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Lines to a file, its folder made when missing, each ended as this system ends them. */
|
|
23
|
+
export function writeLines(path: string, lines: string[]) {
|
|
24
|
+
const slash = path.lastIndexOf("/");
|
|
25
|
+
if (slash > 0) fs.mkdirSync(path.slice(0, slash), { recursive: true });
|
|
26
|
+
return fs.writeFileSync(path, lines.join(EOL) + EOL);
|
|
27
|
+
}
|