@amxts/config-core 0.1.1 → 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 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
- 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.
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
- 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` пишет в него.
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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@amxts/config-core",
3
3
  "type": "module",
4
- "version": "0.1.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.2.0"
48
+ "@amxts/core": "^0.2.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@e18e/eslint-plugin": "^0.8.1",
Binary file
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "format": 1,
3
3
  "module": "@amxts/config-core",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "from": {
6
6
  "@amxts/core": {
7
- "version": "0.2.0",
8
- "hash": "86146344f98b3f7285b3307a254d359d7080ae7c"
7
+ "version": "0.2.2",
8
+ "hash": "71afaf25b04163866b491556b2ae1740c8109576"
9
9
  },
10
10
  "@amxts/config-core": {
11
- "version": "0.1.1",
12
- "hash": "1e49ebcfbf431b802df05bacaae593ab563b5119"
11
+ "version": "0.1.2",
12
+ "hash": "d4f17332c3543c43e4c52535a89ca218a2af1742"
13
13
  }
14
14
  },
15
15
  "options": {
@@ -56,7 +56,7 @@
56
56
  }
57
57
  ],
58
58
  "result": "int",
59
- "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 */",
60
60
  "layout": [
61
61
  {
62
62
  "param": {
@@ -168,7 +168,7 @@
168
168
  }
169
169
  ],
170
170
  "result": "string?",
171
- "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 */",
172
172
  "layout": [
173
173
  {
174
174
  "param": {
@@ -650,7 +650,7 @@
650
650
  }
651
651
  ],
652
652
  "result": "array",
653
- "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 */",
654
654
  "layout": [
655
655
  {
656
656
  "param": {
@@ -823,7 +823,7 @@
823
823
  }
824
824
  ],
825
825
  "result": "array",
826
- "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 */",
827
827
  "layout": [
828
828
  {
829
829
  "param": {
@@ -954,7 +954,7 @@
954
954
  }
955
955
  ],
956
956
  "result": "array",
957
- "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 */",
958
958
  "layout": [
959
959
  {
960
960
  "param": {
@@ -1865,7 +1865,7 @@
1865
1865
  }
1866
1866
  ],
1867
1867
  "result": "bool",
1868
- "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 */",
1869
1869
  "layout": [
1870
1870
  {
1871
1871
  "param": {
@@ -1944,7 +1944,7 @@
1944
1944
  }
1945
1945
  ],
1946
1946
  "result": "bool",
1947
- "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 */",
1948
1948
  "layout": [
1949
1949
  {
1950
1950
  "param": {
@@ -2128,7 +2128,7 @@
2128
2128
  }
2129
2129
  ],
2130
2130
  "result": "bool",
2131
- "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 */",
2132
2132
  "layout": [
2133
2133
  {
2134
2134
  "param": {
@@ -2273,12 +2273,12 @@
2273
2273
  "windows": {
2274
2274
  "file": "prebuilt/windows/config-core.aot",
2275
2275
  "size": 1211754,
2276
- "sha256": "2d71649ae35f4065e3a0ecfa0189ea8ba43a877727d7afc7066548306e027f1d"
2276
+ "sha256": "2494ed4bb7e290df5cbc26437b79cd78705b5576ab20121f056c8b9407c917dc"
2277
2277
  },
2278
2278
  "linux": {
2279
2279
  "file": "prebuilt/linux/config-core.aot",
2280
2280
  "size": 1226178,
2281
- "sha256": "76e0726ea2dc34ca11f2be6d78b22f78b87f2f6d245cdea30b4a966d203a2e8d"
2281
+ "sha256": "ca7cd3d9d27c847c76bab5fde950254549c353ad893818fed12f2dfa0abf6e79"
2282
2282
  }
2283
2283
  },
2284
2284
  "surface": {
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 "@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
- }
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
+ }