crash-js 0.1.4 → 0.1.6
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 +1 -1
- package/crash-js/crash-js +48 -14
- package/crash-js/fs-utils +23 -3
- package/examples/ahsi +126 -0
- package/examples/index.html +24 -0
- package/examples/package.json +38 -0
- package/examples/webpack.config.js +27 -0
- package/package.json +13 -1
- package/libcrash-js.1 +0 -119
package/README.md
CHANGED
package/crash-js/crash-js
CHANGED
|
@@ -21,14 +21,31 @@
|
|
|
21
21
|
// You should have received a copy of the GNU Affero General Public License
|
|
22
22
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
function
|
|
25
|
+
_process_exit(
|
|
26
|
+
_exit) {
|
|
27
|
+
return _exit;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if ( typeof window === 'undefined' ) {
|
|
31
|
+
_argv =
|
|
32
|
+
process.argv;
|
|
33
|
+
_process_exit =
|
|
34
|
+
process.exit;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
_argv = [
|
|
38
|
+
"crash",
|
|
39
|
+
"javascript"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
26
42
|
const
|
|
27
43
|
_fs_utils =
|
|
28
44
|
require(
|
|
29
45
|
"./fs-utils");
|
|
30
46
|
_basename =
|
|
31
|
-
_fs_utils._basename
|
|
47
|
+
_fs_utils._basename;
|
|
48
|
+
|
|
32
49
|
|
|
33
50
|
function
|
|
34
51
|
_app_name_get() {
|
|
@@ -98,7 +115,7 @@ function
|
|
|
98
115
|
console.error(
|
|
99
116
|
_out);
|
|
100
117
|
if ( _exit == "1" ) {
|
|
101
|
-
|
|
118
|
+
_process_exit(
|
|
102
119
|
1);
|
|
103
120
|
}
|
|
104
121
|
}
|
|
@@ -170,14 +187,19 @@ function
|
|
|
170
187
|
let
|
|
171
188
|
_program,
|
|
172
189
|
_program_name;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
190
|
+
if ( typeof window === 'undefined' ) {
|
|
191
|
+
_program =
|
|
192
|
+
_argv[
|
|
193
|
+
1];
|
|
194
|
+
_program_name =
|
|
195
|
+
_basename(
|
|
196
|
+
_program);
|
|
197
|
+
if ( _program_name == _app_name ) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
181
203
|
}
|
|
182
204
|
else {
|
|
183
205
|
return false;
|
|
@@ -192,8 +214,20 @@ function
|
|
|
192
214
|
function
|
|
193
215
|
_printf(
|
|
194
216
|
_text) {
|
|
195
|
-
|
|
196
|
-
|
|
217
|
+
let
|
|
218
|
+
_stdout_write;
|
|
219
|
+
if ( typeof window === 'undefined' ) {
|
|
220
|
+
process.stdout.write(
|
|
221
|
+
_text);
|
|
222
|
+
}
|
|
223
|
+
if ( typeof window != 'undefined' ) {
|
|
224
|
+
console.error("hello");
|
|
225
|
+
_stdout_write =
|
|
226
|
+
require(
|
|
227
|
+
"browser-stdout");
|
|
228
|
+
_stdout_write(
|
|
229
|
+
_text);
|
|
230
|
+
}
|
|
197
231
|
}
|
|
198
232
|
|
|
199
233
|
function
|
package/crash-js/fs-utils
CHANGED
|
@@ -21,14 +21,35 @@
|
|
|
21
21
|
// You should have received a copy of the GNU Affero General Public License
|
|
22
22
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
23
23
|
|
|
24
|
+
_window_type = typeof window;
|
|
25
|
+
if ( typeof window === 'undefined' ) {
|
|
26
|
+
_fs_module_name =
|
|
27
|
+
"fs";
|
|
28
|
+
_path_module_name =
|
|
29
|
+
"path";
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
_fs_module_name =
|
|
33
|
+
"happy-opfs";
|
|
34
|
+
_path_module_name =
|
|
35
|
+
"@std/path";
|
|
36
|
+
// Maybe not neeeded here
|
|
37
|
+
// window.addEventListener(
|
|
38
|
+
// 'load',
|
|
39
|
+
// function () {
|
|
40
|
+
// navigator
|
|
41
|
+
// .serviceWorker
|
|
42
|
+
// .register('/service-worker.js');
|
|
43
|
+
// });
|
|
44
|
+
}
|
|
24
45
|
const
|
|
25
46
|
_fs =
|
|
26
47
|
require(
|
|
27
|
-
|
|
48
|
+
_fs_module_name);
|
|
28
49
|
const
|
|
29
50
|
_path_module =
|
|
30
51
|
require(
|
|
31
|
-
|
|
52
|
+
_path_module_name);
|
|
32
53
|
_path_module_basename =
|
|
33
54
|
_path_module.basename;
|
|
34
55
|
_path_module_dirname =
|
|
@@ -86,7 +107,6 @@ function
|
|
|
86
107
|
return _return;
|
|
87
108
|
}
|
|
88
109
|
|
|
89
|
-
|
|
90
110
|
function
|
|
91
111
|
_file_read(
|
|
92
112
|
_path) {
|
package/examples/ahsi
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
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/>.
|
|
23
|
+
|
|
24
|
+
const
|
|
25
|
+
_libcrash =
|
|
26
|
+
require(
|
|
27
|
+
'../crash-js/crash-js');
|
|
28
|
+
_cmdline_check =
|
|
29
|
+
_libcrash._cmdline_check;
|
|
30
|
+
_error_display =
|
|
31
|
+
_libcrash._error_display;
|
|
32
|
+
_ext_rm =
|
|
33
|
+
_libcrash._ext_rm;
|
|
34
|
+
_file_read =
|
|
35
|
+
_libcrash._file_read;
|
|
36
|
+
_file_write =
|
|
37
|
+
_libcrash._file_write;
|
|
38
|
+
_json_read =
|
|
39
|
+
_libcrash._json_read;
|
|
40
|
+
_msg_info =
|
|
41
|
+
_libcrash._msg_info;
|
|
42
|
+
_msg_error =
|
|
43
|
+
_libcrash._msg_error;
|
|
44
|
+
|
|
45
|
+
function
|
|
46
|
+
_global_variables() {
|
|
47
|
+
app_name =
|
|
48
|
+
"ahsi";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function
|
|
52
|
+
_ahsi() {
|
|
53
|
+
_msg_info(
|
|
54
|
+
"ciao");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function
|
|
58
|
+
_usage(
|
|
59
|
+
_exit_code) {
|
|
60
|
+
let
|
|
61
|
+
_line,
|
|
62
|
+
_text;
|
|
63
|
+
_text = [
|
|
64
|
+
"wadddis",
|
|
65
|
+
"",
|
|
66
|
+
"Usage:",
|
|
67
|
+
" ahsi",
|
|
68
|
+
" <quiet>",
|
|
69
|
+
"",
|
|
70
|
+
"Args:",
|
|
71
|
+
" <quiet> Can be 'y' or 'n'",
|
|
72
|
+
" Default: y",
|
|
73
|
+
];
|
|
74
|
+
for ( _line of _text ) {
|
|
75
|
+
_msg_info(
|
|
76
|
+
_line);
|
|
77
|
+
}
|
|
78
|
+
process.exit(
|
|
79
|
+
_exit_code);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function
|
|
83
|
+
_cmdline_parse() {
|
|
84
|
+
quiet =
|
|
85
|
+
"y";
|
|
86
|
+
process.argv.forEach(
|
|
87
|
+
function (
|
|
88
|
+
_value,
|
|
89
|
+
_index,
|
|
90
|
+
_array) {
|
|
91
|
+
if ( _index == 2 ) {
|
|
92
|
+
quiet =
|
|
93
|
+
_value;
|
|
94
|
+
}
|
|
95
|
+
if ( _value == "-h" ||
|
|
96
|
+
_value == "--help" ) {
|
|
97
|
+
quiet =
|
|
98
|
+
"n";
|
|
99
|
+
_usage(
|
|
100
|
+
0);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_global_variables();
|
|
106
|
+
|
|
107
|
+
quiet =
|
|
108
|
+
"n";
|
|
109
|
+
|
|
110
|
+
app_opts = [
|
|
111
|
+
];
|
|
112
|
+
_ahsi.apply(
|
|
113
|
+
null,
|
|
114
|
+
app_opts);
|
|
115
|
+
// if ( _cmdline_check(
|
|
116
|
+
// "ahsi") == true ) {
|
|
117
|
+
// _global_variables();
|
|
118
|
+
// _cmdline_parse();
|
|
119
|
+
// app_opts = [
|
|
120
|
+
// ];
|
|
121
|
+
// _ahsi.apply(
|
|
122
|
+
// null,
|
|
123
|
+
// app_opts);
|
|
124
|
+
// }
|
|
125
|
+
|
|
126
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
----------------------------------------------------------------------
|
|
5
|
+
Copyright © 2024, 2025 Pellegrino Prevete
|
|
6
|
+
|
|
7
|
+
All rights reserved
|
|
8
|
+
----------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
This program is free software: you can redistribute it and/or modify
|
|
11
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
12
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
13
|
+
(at your option) any later version.
|
|
14
|
+
|
|
15
|
+
This program is distributed in the hope that it will be useful,
|
|
16
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18
|
+
GNU Affero General Public License for more details.
|
|
19
|
+
|
|
20
|
+
You should have received a copy of the GNU Affero General Public License
|
|
21
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
<script src="ahsi.js"></script>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ahsi",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Crash Javascript library example program.",
|
|
5
|
+
"funding": {
|
|
6
|
+
"type": "patreon",
|
|
7
|
+
"url": "https://patreon.com/tallero"
|
|
8
|
+
},
|
|
9
|
+
"man": "./man/ahsi.1",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"ur",
|
|
12
|
+
"themartiancompany",
|
|
13
|
+
"dogeos"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/themartiancompany/crash-js",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/themartiancompany/crash-js/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/themartiancompany/crash-js.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "AGPL-3.0-or-later",
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "Pellegrino Prevete",
|
|
26
|
+
"email": "pellegrinoprevete@gmail.com",
|
|
27
|
+
"url": "https://github.com/tallero"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"crash-js": "^0.1.5",
|
|
31
|
+
"webpack": "^5.102.1"
|
|
32
|
+
},
|
|
33
|
+
"type": "commonjs",
|
|
34
|
+
"main": "ahsi",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
let
|
|
2
|
+
_file_name,
|
|
3
|
+
_output,
|
|
4
|
+
_output_dir,
|
|
5
|
+
_path;
|
|
6
|
+
_path =
|
|
7
|
+
require(
|
|
8
|
+
'path');
|
|
9
|
+
_output_dir =
|
|
10
|
+
_path.resolve(
|
|
11
|
+
__dirname);
|
|
12
|
+
_file_name =
|
|
13
|
+
"ahsi.js";
|
|
14
|
+
|
|
15
|
+
_output = {
|
|
16
|
+
path:
|
|
17
|
+
_output_dir,
|
|
18
|
+
filename:
|
|
19
|
+
_file_name
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
entry:
|
|
24
|
+
'./ahsi',
|
|
25
|
+
output:
|
|
26
|
+
_output
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crash-js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Crash Javascript library.",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "patreon",
|
|
7
7
|
"url": "https://patreon.com/tallero"
|
|
8
8
|
},
|
|
9
|
+
"files": [
|
|
10
|
+
"AUTHORS.rst",
|
|
11
|
+
"COPYING",
|
|
12
|
+
"README.md",
|
|
13
|
+
"package.json",
|
|
14
|
+
"crash-js",
|
|
15
|
+
"examples"
|
|
16
|
+
],
|
|
9
17
|
"man": "./man/libcrash-js.1",
|
|
10
18
|
"keywords": [
|
|
11
19
|
"ur",
|
|
@@ -26,6 +34,10 @@
|
|
|
26
34
|
"email": "pellegrinoprevete@gmail.com",
|
|
27
35
|
"url": "https://github.com/tallero"
|
|
28
36
|
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"browser-stdout": "^1.3.1",
|
|
39
|
+
"happy-opfs": "npm:@themartiancompany/happy-opfs@^1.8.8"
|
|
40
|
+
},
|
|
29
41
|
"type": "commonjs",
|
|
30
42
|
"main": "crash-js/crash-js",
|
|
31
43
|
"scripts": {
|
package/libcrash-js.1
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
.\" Man page generated from reStructuredText.
|
|
2
|
-
.
|
|
3
|
-
.
|
|
4
|
-
.nr rst2man-indent-level 0
|
|
5
|
-
.
|
|
6
|
-
.de1 rstReportMargin
|
|
7
|
-
\\$1 \\n[an-margin]
|
|
8
|
-
level \\n[rst2man-indent-level]
|
|
9
|
-
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
|
10
|
-
-
|
|
11
|
-
\\n[rst2man-indent0]
|
|
12
|
-
\\n[rst2man-indent1]
|
|
13
|
-
\\n[rst2man-indent2]
|
|
14
|
-
..
|
|
15
|
-
.de1 INDENT
|
|
16
|
-
.\" .rstReportMargin pre:
|
|
17
|
-
. RS \\$1
|
|
18
|
-
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
|
|
19
|
-
. nr rst2man-indent-level +1
|
|
20
|
-
.\" .rstReportMargin post:
|
|
21
|
-
..
|
|
22
|
-
.de UNINDENT
|
|
23
|
-
. RE
|
|
24
|
-
.\" indent \\n[an-margin]
|
|
25
|
-
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
|
26
|
-
.nr rst2man-indent-level -1
|
|
27
|
-
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
|
28
|
-
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
|
|
29
|
-
..
|
|
30
|
-
.TH "LIBCRASH-JS" "1" "" "libcrash-js insert.version.here"
|
|
31
|
-
.SH NAME
|
|
32
|
-
libcrash-js \- Crash JavaScript Library
|
|
33
|
-
.\" SPDX-License-Identifier: AGPL-3.0-or-later
|
|
34
|
-
.\"
|
|
35
|
-
.\" ----------------------------------------------------------------------
|
|
36
|
-
.\" Copyright © 2024, 2025 Pellegrino Prevete
|
|
37
|
-
.\"
|
|
38
|
-
.\" All rights reserved
|
|
39
|
-
.\" ----------------------------------------------------------------------
|
|
40
|
-
.\"
|
|
41
|
-
.\" This program is free software: you can redistribute it and/or modify
|
|
42
|
-
.\" it under the terms of the GNU Affero General Public License as published by
|
|
43
|
-
.\" the Free Software Foundation, either version 3 of the License, or
|
|
44
|
-
.\" (at your option) any later version.
|
|
45
|
-
.\"
|
|
46
|
-
.\" This program is distributed in the hope that it will be useful,
|
|
47
|
-
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
48
|
-
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
49
|
-
.\" GNU Affero General Public License for more details.
|
|
50
|
-
.\"
|
|
51
|
-
.\" You should have received a copy of the GNU Affero General Public License
|
|
52
|
-
.\" along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
53
|
-
.
|
|
54
|
-
.SH SYNOPSIS
|
|
55
|
-
.INDENT 0.0
|
|
56
|
-
.INDENT 3.5
|
|
57
|
-
.sp
|
|
58
|
-
.EX
|
|
59
|
-
const
|
|
60
|
-
_libcrash =
|
|
61
|
-
require(
|
|
62
|
-
\(aqcrash\-js\(aq) ||
|
|
63
|
-
require(
|
|
64
|
-
\(aq../libcrash\-js/crash\-js\(aq);
|
|
65
|
-
.EE
|
|
66
|
-
.UNINDENT
|
|
67
|
-
.UNINDENT
|
|
68
|
-
.SH DESCRIPTION
|
|
69
|
-
.sp
|
|
70
|
-
JavaScript library providing useful functions
|
|
71
|
-
to write easy to read, easy to extend
|
|
72
|
-
JavaScript applications.
|
|
73
|
-
.sp
|
|
74
|
-
Most The Martian Company\(aqs JavaScript applications
|
|
75
|
-
use the Crash JavaScript library.
|
|
76
|
-
.sp
|
|
77
|
-
Significant applications developed using the library are
|
|
78
|
-
the Ethereum Virtual Machine File System (EVMFS) [1],
|
|
79
|
-
the Ur [2] uncensorable Life and DogeOS user repository
|
|
80
|
-
and application store, its reference
|
|
81
|
-
pub [3] publishing tool and source retrieval tool aspe [4],
|
|
82
|
-
EVM OpenPGP Key Server [5], the uncensorable, undeletable,
|
|
83
|
-
distributed, network\-neutral, decentralized Twitter
|
|
84
|
-
(whose sources are entirely hosted on
|
|
85
|
-
the EVMFS) and many others currently in development.
|
|
86
|
-
.sp
|
|
87
|
-
Crash JavaScript is a core component of the
|
|
88
|
-
Human Instrumentality Project (HIP).
|
|
89
|
-
.SH BUGS
|
|
90
|
-
.sp
|
|
91
|
-
<https://github.com/themartiancompany/crash\-js/\-/issues>
|
|
92
|
-
.SH COPYRIGHT
|
|
93
|
-
.sp
|
|
94
|
-
Copyright Pellegrino Prevete. AGPL\-3.0.
|
|
95
|
-
.SH SEE ALSO
|
|
96
|
-
.INDENT 0.0
|
|
97
|
-
.IP \(bu 2
|
|
98
|
-
libcrash\-gpg
|
|
99
|
-
.IP \(bu 2
|
|
100
|
-
libcrash\-bash
|
|
101
|
-
.UNINDENT
|
|
102
|
-
.SH EXTERNAL RESOURCES
|
|
103
|
-
.IP [1] 5
|
|
104
|
-
Ethereum Virtual Machine File System <https://github.com/themartiancompany/evmfs>
|
|
105
|
-
|
|
106
|
-
.IP [2] 5
|
|
107
|
-
Ur <https://github.com/themartiancompany/ur>
|
|
108
|
-
|
|
109
|
-
.IP [3] 5
|
|
110
|
-
Pub <https://github.com/themartiancompany/pub>
|
|
111
|
-
|
|
112
|
-
.IP [4] 5
|
|
113
|
-
Aspe <https://github.com/themartiancompany/aspe>
|
|
114
|
-
|
|
115
|
-
.IP [5] 5
|
|
116
|
-
EVM OpenPGP Key Server <https://github.com/themartiancompany/evm-openpgp-keyserver>
|
|
117
|
-
|
|
118
|
-
.\" Generated by docutils manpage writer.
|
|
119
|
-
.
|