@gjsify/utils 0.0.2 → 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/lib/cjs/cancel-handler.js +5 -24
- package/lib/cjs/cli.js +5 -34
- package/lib/cjs/error.js +3 -22
- package/lib/cjs/file.js +5 -34
- package/lib/cjs/fs.js +7 -36
- package/lib/cjs/index.js +14 -30
- package/lib/cjs/log.js +23 -52
- package/lib/cjs/message.js +4 -23
- package/lib/cjs/os.js +15 -44
- package/lib/cjs/path.js +13 -42
- package/lib/cjs/process.js +12 -41
- package/lib/cjs/system.js +11 -41
- package/lib/cjs/tty.js +8 -27
- package/lib/cjs/types/cancel-signals.js +0 -15
- package/lib/cjs/types/error-data.js +0 -15
- package/lib/cjs/types/index.js +8 -24
- package/lib/cjs/types/signal-methods.js +0 -15
- package/lib/cjs/types/stack-trace-frame.js +0 -15
- package/lib/cjs/types/structured-log-data.js +0 -15
- package/lib/cjs/types/uncaught-exception-data.js +0 -15
- package/lib/cjs/types/unhandled-rejection-data.js +0 -15
- package/lib/cjs/types/user-info.js +0 -15
- package/lib/cjs/version.js +3 -22
- package/package.json +6 -6
- package/test.gjs.js +524 -559
- package/tsconfig.json +1 -1
- package/tsconfig.types.tsbuildinfo +1 -1
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var cancel_handler_exports = {};
|
|
19
|
-
__export(cancel_handler_exports, {
|
|
20
|
-
closeCancelHandler: () => closeCancelHandler,
|
|
21
|
-
createCancelHandler: () => createCancelHandler,
|
|
22
|
-
getCancelHandler: () => getCancelHandler
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(cancel_handler_exports);
|
|
25
1
|
let nextRid = 1;
|
|
26
2
|
const resources = {};
|
|
27
3
|
const createCancelHandler = () => {
|
|
@@ -39,3 +15,8 @@ const closeCancelHandler = (rid) => {
|
|
|
39
15
|
const getCancelHandler = (rid) => {
|
|
40
16
|
return resources[rid];
|
|
41
17
|
};
|
|
18
|
+
export {
|
|
19
|
+
closeCancelHandler,
|
|
20
|
+
createCancelHandler,
|
|
21
|
+
getCancelHandler
|
|
22
|
+
};
|
package/lib/cjs/cli.js
CHANGED
|
@@ -1,40 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var cli_exports = {};
|
|
29
|
-
__export(cli_exports, {
|
|
30
|
-
cli: () => cli
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(cli_exports);
|
|
33
|
-
var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
|
|
1
|
+
import GLib from "@girs/glib-2.0";
|
|
34
2
|
const byteArray = imports.byteArray;
|
|
35
3
|
const cli = (commandLine) => {
|
|
36
|
-
const [res, out, err, status] =
|
|
4
|
+
const [res, out, err, status] = GLib.spawn_command_line_sync(commandLine);
|
|
37
5
|
if (err.byteLength)
|
|
38
6
|
throw new Error(byteArray.toString(err));
|
|
39
7
|
return byteArray.toString(out);
|
|
40
8
|
};
|
|
9
|
+
export {
|
|
10
|
+
cli
|
|
11
|
+
};
|
package/lib/cjs/error.js
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var error_exports = {};
|
|
19
|
-
__export(error_exports, {
|
|
20
|
-
initErrorV8Methods: () => initErrorV8Methods
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(error_exports);
|
|
23
1
|
const initErrorV8Methods = (ErrorConstructor) => {
|
|
24
2
|
if (!Error.captureStackTrace) {
|
|
25
3
|
Error.captureStackTrace = function(targetObject, constructorOpt) {
|
|
@@ -38,3 +16,6 @@ const initErrorV8Methods = (ErrorConstructor) => {
|
|
|
38
16
|
};
|
|
39
17
|
}
|
|
40
18
|
};
|
|
19
|
+
export {
|
|
20
|
+
initErrorV8Methods
|
|
21
|
+
};
|
package/lib/cjs/file.js
CHANGED
|
@@ -1,42 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var file_exports = {};
|
|
29
|
-
__export(file_exports, {
|
|
30
|
-
readJSON: () => readJSON
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(file_exports);
|
|
33
|
-
var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
|
|
1
|
+
import GLib from "@girs/glib-2.0";
|
|
34
2
|
const byteArray = imports.byteArray;
|
|
35
3
|
const readJSON = (path) => {
|
|
36
|
-
const [ok, contents] =
|
|
4
|
+
const [ok, contents] = GLib.file_get_contents(path);
|
|
37
5
|
if (ok) {
|
|
38
6
|
const map = JSON.parse(byteArray.toString(contents));
|
|
39
7
|
return map;
|
|
40
8
|
}
|
|
41
9
|
throw new Error(`Error on require "${path}"`);
|
|
42
10
|
};
|
|
11
|
+
export {
|
|
12
|
+
readJSON
|
|
13
|
+
};
|
package/lib/cjs/fs.js
CHANGED
|
@@ -1,40 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var fs_exports = {};
|
|
29
|
-
__export(fs_exports, {
|
|
30
|
-
existsFD: () => existsFD,
|
|
31
|
-
existsSync: () => existsSync
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(fs_exports);
|
|
34
|
-
var import_gio_2 = __toESM(require("@girs/gio-2.0"), 1);
|
|
1
|
+
import Gio from "@girs/gio-2.0";
|
|
35
2
|
const existsFD = (fd) => {
|
|
36
3
|
try {
|
|
37
|
-
let stream =
|
|
4
|
+
let stream = Gio.UnixInputStream.new(fd, false);
|
|
38
5
|
stream.close(null);
|
|
39
6
|
return true;
|
|
40
7
|
} catch (error) {
|
|
@@ -45,6 +12,10 @@ function existsSync(path) {
|
|
|
45
12
|
if (typeof path !== "string" || path === "") {
|
|
46
13
|
return false;
|
|
47
14
|
}
|
|
48
|
-
const file =
|
|
15
|
+
const file = Gio.File.new_for_path(path);
|
|
49
16
|
return file.query_exists(null);
|
|
50
17
|
}
|
|
18
|
+
export {
|
|
19
|
+
existsFD,
|
|
20
|
+
existsSync
|
|
21
|
+
};
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var src_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(src_exports);
|
|
17
|
-
__reExport(src_exports, require("./types/index.js"), module.exports);
|
|
18
|
-
__reExport(src_exports, require("./cancel-handler.js"), module.exports);
|
|
19
|
-
__reExport(src_exports, require("./cli.js"), module.exports);
|
|
20
|
-
__reExport(src_exports, require("./error.js"), module.exports);
|
|
21
|
-
__reExport(src_exports, require("./file.js"), module.exports);
|
|
22
|
-
__reExport(src_exports, require("./fs.js"), module.exports);
|
|
23
|
-
__reExport(src_exports, require("./log.js"), module.exports);
|
|
24
|
-
__reExport(src_exports, require("./message.js"), module.exports);
|
|
25
|
-
__reExport(src_exports, require("./os.js"), module.exports);
|
|
26
|
-
__reExport(src_exports, require("./path.js"), module.exports);
|
|
27
|
-
__reExport(src_exports, require("./process.js"), module.exports);
|
|
28
|
-
__reExport(src_exports, require("./system.js"), module.exports);
|
|
29
|
-
__reExport(src_exports, require("./tty.js"), module.exports);
|
|
30
|
-
__reExport(src_exports, require("./version.js"), module.exports);
|
|
1
|
+
export * from "./types/index.js";
|
|
2
|
+
export * from "./cancel-handler.js";
|
|
3
|
+
export * from "./cli.js";
|
|
4
|
+
export * from "./error.js";
|
|
5
|
+
export * from "./file.js";
|
|
6
|
+
export * from "./fs.js";
|
|
7
|
+
export * from "./log.js";
|
|
8
|
+
export * from "./message.js";
|
|
9
|
+
export * from "./os.js";
|
|
10
|
+
export * from "./path.js";
|
|
11
|
+
export * from "./process.js";
|
|
12
|
+
export * from "./system.js";
|
|
13
|
+
export * from "./tty.js";
|
|
14
|
+
export * from "./version.js";
|
package/lib/cjs/log.js
CHANGED
|
@@ -1,59 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var log_exports = {};
|
|
29
|
-
__export(log_exports, {
|
|
30
|
-
LogSignals: () => LogSignals,
|
|
31
|
-
extractErrorData: () => extractErrorData,
|
|
32
|
-
logLevelToString: () => logLevelToString,
|
|
33
|
-
logSignals: () => logSignals,
|
|
34
|
-
parseStackTrace: () => parseStackTrace
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(log_exports);
|
|
37
|
-
var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
|
|
1
|
+
import GLib from "@girs/glib-2.0";
|
|
38
2
|
const logLevelToString = (logLevel) => {
|
|
39
3
|
switch (logLevel) {
|
|
40
|
-
case
|
|
4
|
+
case GLib.LogLevelFlags.FLAG_FATAL:
|
|
41
5
|
return "FLAG_FATAL";
|
|
42
|
-
case
|
|
6
|
+
case GLib.LogLevelFlags.FLAG_RECURSION:
|
|
43
7
|
return "FLAG_RECURSION";
|
|
44
|
-
case
|
|
8
|
+
case GLib.LogLevelFlags.LEVEL_CRITICAL:
|
|
45
9
|
return "LEVEL_CRITICAL";
|
|
46
|
-
case
|
|
10
|
+
case GLib.LogLevelFlags.LEVEL_DEBUG:
|
|
47
11
|
return "LEVEL_DEBUG";
|
|
48
|
-
case
|
|
12
|
+
case GLib.LogLevelFlags.LEVEL_ERROR:
|
|
49
13
|
return "LEVEL_ERROR";
|
|
50
|
-
case
|
|
14
|
+
case GLib.LogLevelFlags.LEVEL_INFO:
|
|
51
15
|
return "LEVEL_INFO";
|
|
52
|
-
case
|
|
16
|
+
case GLib.LogLevelFlags.LEVEL_MASK:
|
|
53
17
|
return "LEVEL_MASK";
|
|
54
|
-
case
|
|
18
|
+
case GLib.LogLevelFlags.LEVEL_MESSAGE:
|
|
55
19
|
return "LEVEL_MESSAGE";
|
|
56
|
-
case
|
|
20
|
+
case GLib.LogLevelFlags.LEVEL_WARNING:
|
|
57
21
|
return "LEVEL_WARNING";
|
|
58
22
|
default:
|
|
59
23
|
return "UNKNOWN";
|
|
@@ -137,7 +101,7 @@ class LogSignals {
|
|
|
137
101
|
return LogSignals.instance;
|
|
138
102
|
}
|
|
139
103
|
initHandler() {
|
|
140
|
-
|
|
104
|
+
GLib.log_set_writer_func((level, fields) => {
|
|
141
105
|
const decoder = new TextDecoder("utf-8");
|
|
142
106
|
const message = decoder.decode(fields?.MESSAGE);
|
|
143
107
|
const priority = Number(decoder.decode(fields?.PRIORITY));
|
|
@@ -148,10 +112,10 @@ class LogSignals {
|
|
|
148
112
|
domain
|
|
149
113
|
};
|
|
150
114
|
if (!this.handler(level, data)) {
|
|
151
|
-
level |=
|
|
152
|
-
|
|
115
|
+
level |= GLib.LogLevelFlags.FLAG_RECURSION;
|
|
116
|
+
GLib.log_default_handler(domain, level, message, null);
|
|
153
117
|
}
|
|
154
|
-
return
|
|
118
|
+
return GLib.LogWriterOutput.HANDLED;
|
|
155
119
|
});
|
|
156
120
|
}
|
|
157
121
|
/**
|
|
@@ -161,7 +125,7 @@ class LogSignals {
|
|
|
161
125
|
* @returns `true` to catch the log or `false` to output the error to the console as usual
|
|
162
126
|
*/
|
|
163
127
|
handler(level, structuredData) {
|
|
164
|
-
if (level ===
|
|
128
|
+
if (level === GLib.LogLevelFlags.LEVEL_WARNING && structuredData.domain === "Gjs" && structuredData.message.startsWith("Unhandled promise rejection")) {
|
|
165
129
|
try {
|
|
166
130
|
const errorData = reconstructErrorFromMessage(structuredData.message);
|
|
167
131
|
const fakePromise = new Promise(() => {
|
|
@@ -177,7 +141,7 @@ class LogSignals {
|
|
|
177
141
|
} catch (error) {
|
|
178
142
|
printerr(error);
|
|
179
143
|
}
|
|
180
|
-
} else if (level ===
|
|
144
|
+
} else if (level === GLib.LogLevelFlags.LEVEL_CRITICAL) {
|
|
181
145
|
const errorData = reconstructErrorFromMessage(structuredData.message);
|
|
182
146
|
logSignals.emit("uncaughtException", structuredData, errorData);
|
|
183
147
|
}
|
|
@@ -186,3 +150,10 @@ class LogSignals {
|
|
|
186
150
|
}
|
|
187
151
|
imports.signals.addSignalMethods(LogSignals.prototype);
|
|
188
152
|
const logSignals = LogSignals.getSingleton();
|
|
153
|
+
export {
|
|
154
|
+
LogSignals,
|
|
155
|
+
extractErrorData,
|
|
156
|
+
logLevelToString,
|
|
157
|
+
logSignals,
|
|
158
|
+
parseStackTrace
|
|
159
|
+
};
|
package/lib/cjs/message.js
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var message_exports = {};
|
|
19
|
-
__export(message_exports, {
|
|
20
|
-
notImplemented: () => notImplemented,
|
|
21
|
-
warnNotImplemented: () => warnNotImplemented
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(message_exports);
|
|
24
1
|
const notImplemented = (msg) => {
|
|
25
2
|
const message = msg ? `Not implemented: ${msg}` : "Not implemented";
|
|
26
3
|
throw new Error(message);
|
|
@@ -30,3 +7,7 @@ const warnNotImplemented = (msg) => {
|
|
|
30
7
|
console.warn(message);
|
|
31
8
|
return message;
|
|
32
9
|
};
|
|
10
|
+
export {
|
|
11
|
+
notImplemented,
|
|
12
|
+
warnNotImplemented
|
|
13
|
+
};
|
package/lib/cjs/os.js
CHANGED
|
@@ -1,43 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var os_exports = {};
|
|
29
|
-
__export(os_exports, {
|
|
30
|
-
getArch: () => getArch,
|
|
31
|
-
getEnv: () => getEnv,
|
|
32
|
-
getOs: () => getOs,
|
|
33
|
-
getTarget: () => getTarget,
|
|
34
|
-
getUserInfo: () => getUserInfo,
|
|
35
|
-
getVendor: () => getVendor
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(os_exports);
|
|
38
|
-
var import_cli = require("./cli.js");
|
|
39
|
-
var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
|
|
40
|
-
var import_gio_2 = __toESM(require("@girs/gio-2.0"), 1);
|
|
1
|
+
import { cli } from "./cli.js";
|
|
2
|
+
import GLib from "@girs/glib-2.0";
|
|
3
|
+
import Gio from "@girs/gio-2.0";
|
|
41
4
|
let _arch = "";
|
|
42
5
|
let _os = "";
|
|
43
6
|
let _target = "";
|
|
@@ -46,14 +9,14 @@ const getArch = () => {
|
|
|
46
9
|
if (_arch) {
|
|
47
10
|
return _arch;
|
|
48
11
|
}
|
|
49
|
-
_arch =
|
|
12
|
+
_arch = cli("uname -m").trim();
|
|
50
13
|
return _arch;
|
|
51
14
|
};
|
|
52
15
|
const getOs = () => {
|
|
53
16
|
if (_os) {
|
|
54
17
|
return _os;
|
|
55
18
|
}
|
|
56
|
-
const os =
|
|
19
|
+
const os = cli("uname -o").trim();
|
|
57
20
|
if (/\bDarwin\b/i.test(os)) {
|
|
58
21
|
_os = "darwin";
|
|
59
22
|
return _os;
|
|
@@ -93,9 +56,9 @@ const extractUserInfo = (passwd, username) => {
|
|
|
93
56
|
return null;
|
|
94
57
|
};
|
|
95
58
|
const getUserInfo = (username) => {
|
|
96
|
-
const file =
|
|
59
|
+
const file = Gio.File.new_for_path("/etc/passwd");
|
|
97
60
|
if (!username) {
|
|
98
|
-
username =
|
|
61
|
+
username = GLib.get_user_name();
|
|
99
62
|
}
|
|
100
63
|
if (userInfo[username]) {
|
|
101
64
|
return userInfo[username];
|
|
@@ -108,3 +71,11 @@ const getUserInfo = (username) => {
|
|
|
108
71
|
userInfo[username] = extractUserInfo(contentStr, username);
|
|
109
72
|
return userInfo[username];
|
|
110
73
|
};
|
|
74
|
+
export {
|
|
75
|
+
getArch,
|
|
76
|
+
getEnv,
|
|
77
|
+
getOs,
|
|
78
|
+
getTarget,
|
|
79
|
+
getUserInfo,
|
|
80
|
+
getVendor
|
|
81
|
+
};
|
package/lib/cjs/path.js
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var path_exports = {};
|
|
29
|
-
__export(path_exports, {
|
|
30
|
-
getNodeModulesPath: () => getNodeModulesPath,
|
|
31
|
-
getPathSeparator: () => getPathSeparator,
|
|
32
|
-
getProgramDir: () => getProgramDir,
|
|
33
|
-
getProgramExe: () => getProgramExe,
|
|
34
|
-
resolve: () => resolve
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(path_exports);
|
|
37
|
-
var import_gio_2 = __toESM(require("@girs/gio-2.0"), 1);
|
|
38
|
-
var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
|
|
39
|
-
const { File } = import_gio_2.default;
|
|
1
|
+
import Gio from "@girs/gio-2.0";
|
|
2
|
+
import GLib from "@girs/glib-2.0";
|
|
3
|
+
const { File } = Gio;
|
|
40
4
|
const _getProgramDir = (programFile) => {
|
|
41
|
-
const info = programFile.query_info("standard::",
|
|
5
|
+
const info = programFile.query_info("standard::", Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
|
|
42
6
|
if (info.get_is_symlink()) {
|
|
43
7
|
const symlinkFile = programFile.get_parent().resolve_relative_path(info.get_symlink_target());
|
|
44
8
|
return symlinkFile.get_parent();
|
|
@@ -54,14 +18,14 @@ const resolve = (dir, ...filenames) => {
|
|
|
54
18
|
return file;
|
|
55
19
|
};
|
|
56
20
|
const getProgramExe = () => {
|
|
57
|
-
const currentDir =
|
|
21
|
+
const currentDir = GLib.get_current_dir();
|
|
58
22
|
return File.new_for_path(currentDir).resolve_relative_path(imports.system.programInvocationName);
|
|
59
23
|
};
|
|
60
24
|
const getProgramDir = () => {
|
|
61
25
|
return _getProgramDir(getProgramExe()).get_path();
|
|
62
26
|
};
|
|
63
27
|
const getPathSeparator = () => {
|
|
64
|
-
const currentDir =
|
|
28
|
+
const currentDir = GLib.get_current_dir();
|
|
65
29
|
return /^\//.test(currentDir) ? "/" : "\\";
|
|
66
30
|
};
|
|
67
31
|
const getNodeModulesPath = () => {
|
|
@@ -77,3 +41,10 @@ const getNodeModulesPath = () => {
|
|
|
77
41
|
} while (dir.has_parent(null) && !found);
|
|
78
42
|
return dir;
|
|
79
43
|
};
|
|
44
|
+
export {
|
|
45
|
+
getNodeModulesPath,
|
|
46
|
+
getPathSeparator,
|
|
47
|
+
getProgramDir,
|
|
48
|
+
getProgramExe,
|
|
49
|
+
resolve
|
|
50
|
+
};
|
package/lib/cjs/process.js
CHANGED
|
@@ -1,59 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var process_exports = {};
|
|
29
|
-
__export(process_exports, {
|
|
30
|
-
getLocale: () => getLocale,
|
|
31
|
-
getPid: () => getPid,
|
|
32
|
-
getPpid: () => getPpid,
|
|
33
|
-
getTitle: () => getTitle
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(process_exports);
|
|
36
|
-
var import_gio_2 = __toESM(require("@girs/gio-2.0"), 1);
|
|
37
|
-
var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
|
|
1
|
+
import Gio from "@girs/gio-2.0";
|
|
2
|
+
import GLib from "@girs/glib-2.0";
|
|
38
3
|
let PID = 0;
|
|
39
4
|
let PPID = 0;
|
|
40
5
|
let LOCALE = "";
|
|
41
6
|
const getLocale = () => {
|
|
42
7
|
if (!LOCALE) {
|
|
43
|
-
LOCALE =
|
|
8
|
+
LOCALE = GLib.getenv("LANG").split(".")[0].replace("_", "-");
|
|
44
9
|
}
|
|
45
10
|
return LOCALE;
|
|
46
11
|
};
|
|
47
12
|
const getPid = () => {
|
|
48
13
|
if (!PID) {
|
|
49
|
-
PID = new
|
|
14
|
+
PID = new Gio.Credentials().get_unix_pid();
|
|
50
15
|
}
|
|
51
16
|
return PID;
|
|
52
17
|
};
|
|
53
18
|
const getPpid = () => {
|
|
54
19
|
if (!PPID) {
|
|
55
20
|
const path = `/proc/${getPid()}/status`;
|
|
56
|
-
const file =
|
|
21
|
+
const file = Gio.File.new_for_path(path);
|
|
57
22
|
const [success, contents] = file.load_contents(null);
|
|
58
23
|
if (success) {
|
|
59
24
|
const contentStr = new TextDecoder().decode(contents);
|
|
@@ -66,5 +31,11 @@ const getPpid = () => {
|
|
|
66
31
|
return PPID;
|
|
67
32
|
};
|
|
68
33
|
const getTitle = () => {
|
|
69
|
-
return
|
|
34
|
+
return GLib.get_prgname();
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
getLocale,
|
|
38
|
+
getPid,
|
|
39
|
+
getPpid,
|
|
40
|
+
getTitle
|
|
70
41
|
};
|