encoding-tools 0.0.1 → 0.0.4

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/encoding-tools CHANGED
@@ -2,24 +2,28 @@
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
+ * Copyright ©
7
+ * Pellegrino Prevete
8
+ * 2024, 2025, 2026
9
+ *
10
+ * All rights reserved
11
+ * ------------------------------------------------------------------
12
+ *
13
+ * This program is free software: you can redistribute it and/or
14
+ * modify it under the terms of the GNU General Public License as
15
+ * published by the Free Software Foundation, either version 3 of
16
+ * the License, or (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program.
25
+ * If not, see <https://www.gnu.org/licenses/>.
26
+ */
23
27
 
24
28
  const
25
29
  _bin2txt_module =
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,170 @@
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
- '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;
33
+ "crash-js");
34
+ const
35
+ _dirname =
36
+ _libcrash._dirname;
37
+ const
38
+ _error_display =
39
+ _libcrash._error_display;
40
+ const
41
+ _ext_rm =
42
+ _libcrash._ext_rm;
43
+ const
44
+ _file_exists =
45
+ _libcrash._file_exists;
46
+ const
47
+ _file_read =
48
+ _libcrash._file_read;
49
+ const
50
+ _file_write =
51
+ _libcrash._file_write;
52
+ const
53
+ _fs_worker_start =
54
+ _libcrash._fs_worker_start;
55
+ const
56
+ _json_read =
57
+ _libcrash._json_read;
58
+ const
59
+ _ls =
60
+ _libcrash._ls;
61
+ const
62
+ _mkdir =
63
+ _libcrash._mkdir;
64
+ const
65
+ _msg_info =
66
+ _libcrash._msg_info;
67
+ const
68
+ _msg_error =
69
+ _libcrash._msg_error;
70
+ const
71
+ _stat =
72
+ _libcrash._stat;
73
+ const
74
+ _tmcsplit =
75
+ require(
76
+ "tmcsplit");
77
+ const
78
+ _split =
79
+ _tmcsplit._split;
80
+
81
+ async function
82
+ _blocks_find(
83
+ _pattern) {
84
+ let
85
+ _dir,
86
+ _dir_content,
87
+ _msg;
88
+ _msg =
89
+ "Looking for files " +
90
+ `respecting pattern '^${_pattern}*.`;
91
+ _msg_info(
92
+ _msg);
93
+ _dir =
94
+ _dirname(
95
+ _pattern);
96
+ console.log(_dir);
97
+ _dir_content =
98
+ _ls(
99
+ _dir);
100
+ for ( _file of _dir_content ) {
101
+ if ( _file.startsWith(
102
+ _pattern)) {
103
+ }
104
+ }
105
+ console.log(
106
+ typeof(_dir_content));
107
+ console.log(
108
+ _dir_content);
109
+ }
110
+
111
+ async function
112
+ _buffer_prepare(
113
+ _in,
114
+ _out,
115
+ _buffer_size_bytes) {
116
+ let
117
+ _in_size_bytes,
118
+ _size_max,
119
+ _split_opts,
120
+ _msg;
121
+ _size_max =
122
+ 0;
123
+ if ( ! _file_exists(
124
+ _in) ) {
125
+ _msg =
126
+ `File '${_in}' does ` +
127
+ 'not exist.';
128
+ _msg_error(
129
+ _msg,
130
+ 1);
131
+ }
132
+ // console.log(
133
+ // _in);
134
+ _in_size_bytes =
135
+ _stat(
136
+ _in).size;
137
+ _msg =
138
+ `File '${_in}' has size ` +
139
+ `'${_in_size_bytes}' bytes.`;
140
+ _msg_info(
141
+ _msg);
142
+ console.log(
143
+ typeof(
144
+ _in_size_bytes));
145
+ _blocks_total =
146
+ Math.ceil(
147
+ _in_size_bytes /
148
+ _buffer_size_bytes);
149
+ console.log(_in_size_bytes);
150
+ console.log(_buffer_size_bytes);
151
+ console.log(_blocks_total);
152
+ _split_opts = [
153
+ _in,
154
+ `${_out}.block.`,
155
+ _blocks_total,
156
+ _size_max
157
+ ];
158
+ await _split.apply(
159
+ null,
160
+ _split_opts);
161
+ _blocks_find(
162
+ `${_out}.sf-part`);
163
+ // console.log(
164
+ // _stat(
165
+ // _in).size / 1000);
166
+ // console.log(
167
+ // _out);
168
+ }
50
169
 
51
170
  async function
52
171
  _bin2txt(
@@ -76,13 +195,13 @@ async function
76
195
  await _fs_worker_start(
77
196
  "fs-worker.js");
78
197
  }
79
- _split(
80
- "red-sun-in-the-sky.mp4",
81
- 2,
82
-
83
- console.log(
84
- _split
85
- );
198
+ _buffer_prepare(
199
+ _in,
200
+ _out,
201
+ _buffer_size_bytes);
202
+ // console.log(
203
+ // _split
204
+ // );
86
205
  // _msg =
87
206
  // `Creating directory '${_dir}':`;
88
207
  // _msg_info(