encoding-tools 0.0.1 → 0.0.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/README.md ADDED
@@ -0,0 +1,85 @@
1
+ [comment]: <> (SPDX-License-Identifier: AGPL-3.0)
2
+
3
+ [comment]: <> (------------------------------------------------------)
4
+ [comment]: <> (Copyright © 2024, 2025, 2026 Pellegrino Prevete)
5
+ [comment]: <> (All rights reserved)
6
+ [comment]: <> (------------------------------------------------------)
7
+
8
+ [comment]: <> (This program is free software: you can redistribute)
9
+ [comment]: <> (it and/or modify it under the terms of the GNU Affero)
10
+ [comment]: <> (General Public License as published by the Free)
11
+ [comment]: <> (Software Foundation, either version 3 of the License.)
12
+
13
+ [comment]: <> (This program is distributed in the hope that it will be)
14
+ [comment]: <> (useful, but WITHOUT ANY WARRANTY; without even the)
15
+ [comment]: <> (implied warranty of MERCHANTABILITY or FITNESS FOR)
16
+ [comment]: <> (A PARTICULAR PURPOSE. See the)
17
+ [comment]: <> (See the GNU Affero General Public License for)
18
+ [comment]: <> (more details.)
19
+
20
+ [comment]: <> (You should have received a copy of the GNU Affero)
21
+ [comment]: <> (General Public License along with this program.)
22
+ [comment]: <> (If not, see <https://www.gnu.org/licenses/>.)
23
+
24
+ # Encoding Tools (`encoding-tools.js`)
25
+
26
+ Simple, easy to read and use collection of Javascript
27
+ encoding tools.
28
+
29
+ This collection is the Javascript programming
30
+ language implementation of
31
+ [Encoding Tools](
32
+ https://github.com/themartiancompany/encoding-tools),
33
+ in which it is included.
34
+
35
+ The tools are a dependency for the
36
+ [Ethereum Virtual Machine File System](
37
+ https://github.com/themartiancompany/evmfs)
38
+ and for the uncensorable Twitter.
39
+
40
+ They depend on the `base64` encoding tool
41
+ and the
42
+ [Crash Javascript](
43
+ https://github.com/themartiancompany/crash-js)
44
+ library.
45
+
46
+ ## Installation
47
+
48
+ The tools in this source repo
49
+ can be installed from source using GNU Make.
50
+
51
+ ```bash
52
+ make \
53
+ install
54
+ ```
55
+
56
+ The collection has been officially published
57
+ on the the uncensorable
58
+ [Ur](
59
+ https://github.com/themartiancompany/ur)
60
+ user repository and application store as
61
+ `encoding-tools`.
62
+ The source code is published on the
63
+ [Ethereum Virtual Machine File System](
64
+ https://github.com/themartiancompany/evmfs)
65
+ so it can't possibly be taken down.
66
+
67
+ To install it from there just type
68
+
69
+ ```bash
70
+ ur \
71
+ encoding-tools
72
+ ```
73
+
74
+ A censorable HTTP Github mirror of the recipe published there,
75
+ containing a full list of the software dependencies needed to run the
76
+ tools is hosted on
77
+ [encoding-tools-ur](
78
+ https://github.com/themartiancompany/encoding-tools-ur).
79
+ Be aware the mirror could go offline any time as Github and more
80
+ in general all HTTP resources are inherently unstable and censorable.
81
+
82
+ ## License
83
+
84
+ This program is released by Pellegrino Prevete under the terms
85
+ of the GNU Affero General Public License version 3.
package/bin2txt CHANGED
@@ -2,56 +2,110 @@
2
2
 
3
3
  // SPDX-License-Identifier: AGPL-3.0-or-later
4
4
 
5
- // ----------------------------------------------------------------------
6
- // Copyright © 2024, 2025 Pellegrino Prevete
7
- //
8
- // All rights reserved
9
- // ----------------------------------------------------------------------
10
- //
11
- // This program is free software: you can redistribute it and/or modify
12
- // it under the terms of the GNU Affero General Public License as published by
13
- // the Free Software Foundation, either version 3 of the License, or
14
- // (at your option) any later version.
15
- //
16
- // This program is distributed in the hope that it will be useful,
17
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- // GNU Affero General Public License for more details.
20
- //
21
- // You should have received a copy of the GNU Affero General Public License
22
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
5
+ /** ----------------------------------------------------------------
6
+ * bin2txt
7
+ * ----------------------------------------------------------------
8
+ * Copyright ©
9
+ * Pellegrino Prevete
10
+ * 2024, 2025, 2026
11
+ *
12
+ * All rights reserved
13
+ * ----------------------------------------------------------------
14
+ *
15
+ * This program is free software: you can redistribute it and/or
16
+ * modify it under the terms of the GNU General Public License as
17
+ * published by the Free Software Foundation, either version 3 of
18
+ * the License, or (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program.
27
+ * If not, see <https://www.gnu.org/licenses/>.
28
+ */
23
29
 
24
30
  const
25
31
  _libcrash =
26
32
  require(
27
33
  'crash-js');
28
- _cmdline_check =
29
- _libcrash._cmdline_check;
30
- _msg_info =
31
- _libcrash._msg_info;
32
- _msg_error =
33
- _libcrash._msg_error;
34
+ /* global
35
+ _cmdline_check */
36
+ const
37
+ _cmdline_check =
38
+ _libcrash._cmdline_check;
39
+ /* global
40
+ _msg_info */
41
+ const
42
+ _msg_info =
43
+ _libcrash._msg_info;
44
+ /* global
45
+ _msg_error */
46
+ const
47
+ _msg_error =
48
+ _libcrash._msg_error;
49
+ /* global
50
+ _argv_get */
51
+ const
52
+ _argv_get =
53
+ _libcrash._argv_get;
54
+
34
55
  const
35
56
  _encoding_tools =
36
57
  require(
37
58
  "./encoding-tools");
59
+ /* global
60
+ _bin2txt */
38
61
  _bin2txt =
39
62
  _encoding_tools._bin2txt;
40
63
 
41
64
  function
42
65
  _global_variables() {
66
+ /* global
67
+ app_name:
68
+ writable */
43
69
  app_name =
44
70
  "bin2txt";
71
+ /* global
72
+ app_opts:
73
+ writable */
74
+ app_opts =
75
+ [];
76
+ /* global
77
+ encoding_format:
78
+ writable */
45
79
  encoding_format =
46
80
  "";
81
+ /* global
82
+ buffer_size:
83
+ writable */
47
84
  buffer_size =
48
85
  "";
86
+ /* global
87
+ string_length:
88
+ writable */
49
89
  string_length =
50
90
  "";
91
+ /* global
92
+ in_file:
93
+ writable */
51
94
  in_file =
52
95
  "";
96
+ /* global
97
+ out_txt_prefix:
98
+ writable */
53
99
  out_txt_prefix =
54
100
  "";
101
+ /* global
102
+ amount_only:
103
+ writable */
104
+ amount_only =
105
+ "";
106
+ /* global
107
+ quiet:
108
+ writable */
55
109
  quiet =
56
110
  "";
57
111
  }
@@ -137,7 +191,7 @@ function
137
191
  " -v --verbose Enable verbose output."
138
192
  ];
139
193
  for ( _line of _text ) {
140
- _msg_info(
194
+ console.log(
141
195
  _line);
142
196
  }
143
197
  process.exit(
@@ -148,25 +202,29 @@ function
148
202
  _cmdline_parse() {
149
203
  let
150
204
  _argv,
205
+ _help_display,
151
206
  _msg;
152
207
  _argv =
153
- _yargv_get();
208
+ _argv_get();
154
209
  quiet =
155
210
  "y";
156
211
  runtime_environment =
157
212
  "node";
158
- help_display =
159
- _argv[
160
- "help"] ||
161
- _argv[
162
- "h"];
163
- if ( help_display ) {
213
+ if ( "help" in _argv ||
214
+ "h" in _argv) {
215
+ _help_display =
216
+ true;
217
+ }
218
+ if ( _help_display ) {
164
219
  quiet =
165
220
  "n";
166
221
  _usage(
167
222
  0);
168
223
  }
169
- if ( _argv[
224
+ console.log(_argv);
225
+ if ( typeof(
226
+ _argv) == "undefined" ||
227
+ _argv[
170
228
  "_"].length < 1 ) {
171
229
  _msg =
172
230
  "Input file argument required.";
@@ -183,7 +241,8 @@ function
183
241
  if ( _argv[
184
242
  "_"].length < 2 ) {
185
243
  out_txt_prefix =
186
- in_file + ".base64"
244
+ in_file +
245
+ ".base64";
187
246
  }
188
247
  if ( "s" in _argv ) {
189
248
  string_length =
@@ -238,12 +297,9 @@ function
238
297
 
239
298
  _global_variables();
240
299
  if ( _cmdline_check(
241
- "bin2txt") == true ) {
300
+ "bin2txt.js") == true ) {
242
301
  _cmdline_parse();
243
302
  }
244
- else {
245
- _url_parse();
246
- }
247
303
  _config_show();
248
304
  app_opts = [
249
305
  in_file,
package/fs-worker.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{var e={816(e,o,n){function t(){let e;return"undefined"==typeof window&&void 0!==n.g&&n.g.global===n.g&&"function"!=typeof n||(e=function(){let e;try{e=n(816)}catch(e){console.log(e);const o="Error importing the '@themartiancompany/opfs' module as 'opfs'. If you got this error while bundling a webpack for a project depending on this module double check its 'webpack.config.js' file or whether the 'opfs' module is listed in developer dependencies and install them.I'm sorry for this inconvenience but Node packagement system does not currently distinguish 'development' from 'build' dependencies.";throw console.error(o),e}return e}()),e}const r=t();e.exports=r,e.exports.getModule=function(e){let o;if(""==_module_name||"undefined"==typeof _module_name)o=t();else if("opfs"==_module_name)o=n(816);else{if("fs"!=_module_name){const e="Unknown file system module "+`'${_module_name}'.`.const;throw _error={msg:e},console.error(e),_error}o=n(816)}return o}},314(e,o,n){const t=n(816);_sync_agent=t.startSyncAgent,e.exports={_sync_agent},_sync_agent()}},o={};function n(t){var r=o[t];if(void 0!==r)return r.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,n),s.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(314)})();
package/libbin2txt CHANGED
@@ -2,51 +2,112 @@
2
2
 
3
3
  // SPDX-License-Identifier: AGPL-3.0-or-later
4
4
 
5
- // ----------------------------------------------------------------------
6
- // Copyright © 2024, 2025 Pellegrino Prevete
7
- //
8
- // All rights reserved
9
- // ----------------------------------------------------------------------
10
- //
11
- // This program is free software: you can redistribute it and/or modify
12
- // it under the terms of the GNU Affero General Public License as
13
- // published by the Free Software Foundation, either version 3 of
14
- // the License, or (at your option) any later version.
15
- //
16
- // This program is distributed in the hope that it will be useful,
17
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- // GNU Affero General Public License for more details.
20
- //
21
- // You should have received a copy of the GNU Affero General Public License
22
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
5
+ /** ----------------------------------------------------------------
6
+ * libbin2txt
7
+ * ----------------------------------------------------------------
8
+ * Copyright ©
9
+ * Pellegrino Prevete
10
+ * 2024, 2025, 2026
11
+ *
12
+ * All rights reserved
13
+ * ----------------------------------------------------------------
14
+ *
15
+ * This program is free software: you can redistribute it and/or
16
+ * modify it under the terms of the GNU General Public License as
17
+ * published by the Free Software Foundation, either version 3 of
18
+ * the License, or (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program.
27
+ * If not, see <https://www.gnu.org/licenses/>.
28
+ */
23
29
 
24
30
  const
25
31
  _libcrash =
26
32
  require(
27
33
  'crash-js');
28
- _error_display =
29
- _libcrash._error_display;
30
- _ext_rm =
31
- _libcrash._ext_rm;
32
- _file_read =
33
- _libcrash._file_read;
34
- _file_write =
35
- _libcrash._file_write;
36
- _fs_worker_start =
37
- _libcrash._fs_worker_start;
38
- _json_read =
39
- _libcrash._json_read;
40
- _ls =
41
- _libcrash._ls;
42
- _mkdir =
43
- _libcrash._mkdir;
44
- _msg_info =
45
- _libcrash._msg_info;
46
- _msg_error =
47
- _libcrash._msg_error;
48
- _split =
49
- _libcrash._split;
34
+ const
35
+ _error_display =
36
+ _libcrash._error_display;
37
+ const
38
+ _ext_rm =
39
+ _libcrash._ext_rm;
40
+ const
41
+ _file_read =
42
+ _libcrash._file_read;
43
+ const
44
+ _file_write =
45
+ _libcrash._file_write;
46
+ const
47
+ _fs_worker_start =
48
+ _libcrash._fs_worker_start;
49
+ const
50
+ _json_read =
51
+ _libcrash._json_read;
52
+ const
53
+ _ls =
54
+ _libcrash._ls;
55
+ const
56
+ _mkdir =
57
+ _libcrash._mkdir;
58
+ const
59
+ _msg_info =
60
+ _libcrash._msg_info;
61
+ const
62
+ _msg_error =
63
+ _libcrash._msg_error;
64
+ const
65
+ _split =
66
+ _libcrash._split;
67
+ const
68
+ _stat =
69
+ _libcrash._stat;
70
+
71
+ async function
72
+ _buffer_prepare(
73
+ _in,
74
+ _out,
75
+ _buffer_size_bytes) {
76
+ let
77
+ _in_size_bytes,
78
+ _split_opts,
79
+ _msg;
80
+ _split_opts =
81
+ [];
82
+ console.log(
83
+ _stat);
84
+ console.log(
85
+ _in);
86
+ console.log(
87
+ _out);
88
+ // _in_size_bytes="$( \
89
+ // du \
90
+ // -bs \
91
+ // "${_in}" | \
92
+ // awk \
93
+ // '{print $1}')"
94
+ // _msg=(
95
+ // "File '${_in}' has size"
96
+ // "'${_in_size_bytes}' bytes."
97
+ // )
98
+ // _msg_info \
99
+ // "${_msg[*]}"
100
+ // _blocks_total="$(( \
101
+ // _in_size_bytes / _buffer_size_bytes + 1))"
102
+ // split \
103
+ // -n \
104
+ // "l/${_blocks_total}" \
105
+ // --numeric-suffixes="1" \
106
+ // "${_in}" \
107
+ // "${_out}.block."
108
+ // _blocks_find \
109
+ // "${_out}.block"
110
+ }
50
111
 
51
112
  async function
52
113
  _bin2txt(
@@ -76,13 +137,21 @@ async function
76
137
  await _fs_worker_start(
77
138
  "fs-worker.js");
78
139
  }
79
- _split(
80
- "red-sun-in-the-sky.mp4",
81
- 2,
82
-
83
- console.log(
84
- _split
85
- );
140
+ _buffer_prepare(
141
+ _in,
142
+ _out,
143
+ _buffer_size_bytes);
144
+ // _split(
145
+ // "",
146
+ // 2);
147
+ // _split(
148
+ // _input_file,
149
+ // _output_prefix,
150
+ // _chunks_amount,
151
+ // _size_max) {
152
+ // console.log(
153
+ // _split
154
+ // );
86
155
  // _msg =
87
156
  // `Creating directory '${_dir}':`;
88
157
  // _msg_info(
package/libtxt2bin CHANGED
@@ -2,24 +2,30 @@
2
2
 
3
3
  // SPDX-License-Identifier: AGPL-3.0-or-later
4
4
 
5
- // ----------------------------------------------------------------------
6
- // Copyright © 2024, 2025 Pellegrino Prevete
7
- //
8
- // All rights reserved
9
- // ----------------------------------------------------------------------
10
- //
11
- // This program is free software: you can redistribute it and/or modify
12
- // it under the terms of the GNU Affero General Public License as published by
13
- // the Free Software Foundation, either version 3 of the License, or
14
- // (at your option) any later version.
15
- //
16
- // This program is distributed in the hope that it will be useful,
17
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- // GNU Affero General Public License for more details.
20
- //
21
- // You should have received a copy of the GNU Affero General Public License
22
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
5
+ /** ----------------------------------------------------------------
6
+ * libtxt2bin
7
+ * ----------------------------------------------------------------
8
+ * Copyright ©
9
+ * Pellegrino Prevete
10
+ * 2024, 2025, 2026
11
+ *
12
+ * All rights reserved
13
+ * ----------------------------------------------------------------
14
+ *
15
+ * This program is free software: you can redistribute it and/or
16
+ * modify it under the terms of the GNU General Public License as
17
+ * published by the Free Software Foundation, either version 3 of
18
+ * the License, or (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program.
27
+ * If not, see <https://www.gnu.org/licenses/>.
28
+ */
23
29
 
24
30
  const
25
31
  _libcrash =
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name":
3
3
  "encoding-tools",
4
4
  "version":
5
- "0.0.1",
5
+ "0.0.2",
6
6
  "description":
7
7
  "A multi-language collection of encoding tools.",
8
8
  "funding": {
@@ -11,16 +11,18 @@
11
11
  "url":
12
12
  "https://patreon.com/tallero"
13
13
  },
14
- "man":
15
- "./man/ahsi.1",
14
+ "man": [
15
+ "./man/bin2txt.js.1",
16
+ "./man/txt2bin.js.1"
17
+ ],
16
18
  "files": [
17
19
  "AUTHORS.rst",
18
20
  "COPYING",
19
21
  "README.md",
20
22
  "bin2txt",
23
+ "encoding-tools",
21
24
  "libbin2txt",
22
25
  "libtxt2bin",
23
- "ahsi",
24
26
  "fs-worker.js",
25
27
  "fs-worker.webpack.config.js",
26
28
  "index.html",
@@ -57,8 +59,14 @@
57
59
  "https://github.com/tallero"
58
60
  },
59
61
  "devDependencies": {
62
+ "crash-js-webpack":
63
+ "^0.0.3",
60
64
  "eslint":
61
- "^9.32.0",
65
+ "^10.0.3",
66
+ "globals":
67
+ "^17.3.0",
68
+ "@eslint/js":
69
+ "^10.0.1",
62
70
  "safely-serve":
63
71
  "^0.0.9",
64
72
  "webpack":
@@ -68,9 +76,9 @@
68
76
  },
69
77
  "dependencies": {
70
78
  "crash-js":
71
- "^0.1.51",
79
+ "^0.1.76",
72
80
  "tmcsplit":
73
- "^0.0.2",
81
+ "^0.0.4",
74
82
  "yargs":
75
83
  "18.0.0"
76
84
  },
@@ -78,15 +86,24 @@
78
86
  "commonjs",
79
87
  "main":
80
88
  "encoding-tools",
89
+ "bin":
90
+ { "bin2txt.js":
91
+ "bin2txt" },
81
92
  "scripts": {
93
+ "build-fs-worker":
94
+ "npx webpack --mode 'production' --config 'fs-worker.webpack.config.cjs' --stats-error-details",
95
+ "build-lib":
96
+ "npx webpack --mode 'production' --config 'libbin2txt.webpack.config.cjs' --stats-error-details && npx webpack --mode 'production' --config 'libtxt2bin.webpack.config.cjs' --stats-error-details",
97
+ "build-bin":
98
+ "npx webpack --mode 'production' --config 'bin2txt.webpack.config.cjs' --stats-error-details && npx webpack --mode 'production' --config 'txt2bin.webpack.config.cjs' --stats-error-details",
82
99
  "build":
83
- "cd ../.. && make build-npm && encoding-tools/nodejs",
100
+ "npm run lint && npm run build-fs-worker && npm run build-lib && npm run build-bin",
84
101
  "lint":
85
102
  "npx eslint .",
86
- "publish-npm":
103
+ "publish-pnm":
87
104
  "npm run build && npm publish --access public",
88
105
  "start":
89
- "serve -c 'serve.json'",
106
+ "npx safely-serve --help # index.html --port 3000 --https --no-cache",
90
107
  "test":
91
108
  "echo \"Error: no test specified\" && exit 1"
92
109
  }
package/txt2bin CHANGED
@@ -2,24 +2,30 @@
2
2
 
3
3
  // SPDX-License-Identifier: AGPL-3.0-or-later
4
4
 
5
- // ----------------------------------------------------------------------
6
- // Copyright © 2024, 2025 Pellegrino Prevete
7
- //
8
- // All rights reserved
9
- // ----------------------------------------------------------------------
10
- //
11
- // This program is free software: you can redistribute it and/or modify
12
- // it under the terms of the GNU Affero General Public License as published by
13
- // the Free Software Foundation, either version 3 of the License, or
14
- // (at your option) any later version.
15
- //
16
- // This program is distributed in the hope that it will be useful,
17
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- // GNU Affero General Public License for more details.
20
- //
21
- // You should have received a copy of the GNU Affero General Public License
22
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
5
+ /** ----------------------------------------------------------------
6
+ * txt2bin
7
+ * ----------------------------------------------------------------
8
+ * Copyright ©
9
+ * Pellegrino Prevete
10
+ * 2024, 2025, 2026
11
+ *
12
+ * All rights reserved
13
+ * ----------------------------------------------------------------
14
+ *
15
+ * This program is free software: you can redistribute it and/or
16
+ * modify it under the terms of the GNU General Public License as
17
+ * published by the Free Software Foundation, either version 3 of
18
+ * the License, or (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program.
27
+ * If not, see <https://www.gnu.org/licenses/>.
28
+ */
23
29
 
24
30
  const
25
31
  _libcrash =