@gjsify/os 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.
@@ -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 constants_exports = {};
19
- __export(constants_exports, {
20
- default: () => constants_default
21
- });
22
- module.exports = __toCommonJS(constants_exports);
23
1
  var constants_default = {
24
2
  "UV_UDP_REUSEADDR": 4,
25
3
  "errno": {
@@ -139,3 +117,6 @@ var constants_default = {
139
117
  "SIGSYS": 31
140
118
  }
141
119
  };
120
+ export {
121
+ constants_default as default
122
+ };
@@ -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 createSubnet_exports = {};
19
- __export(createSubnet_exports, {
20
- createSubnet: () => createSubnet,
21
- default: () => createSubnet_default
22
- });
23
- module.exports = __toCommonJS(createSubnet_exports);
24
1
  function createSubnet(size, segment, base, sep) {
25
2
  const empty = "0".repeat(size);
26
3
  return (mask) => {
@@ -34,3 +11,7 @@ function createSubnet(size, segment, base, sep) {
34
11
  }
35
12
  ;
36
13
  var createSubnet_default = { createSubnet };
14
+ export {
15
+ createSubnet,
16
+ createSubnet_default as default
17
+ };
package/lib/cjs/darwin.js CHANGED
@@ -1,36 +1,8 @@
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 darwin_exports = {};
19
- __export(darwin_exports, {
20
- cpus: () => cpus,
21
- endianness: () => endianness,
22
- freemem: () => freemem,
23
- loadavg: () => loadavg,
24
- networkInterfaces: () => networkInterfaces,
25
- totalmem: () => totalmem,
26
- uptime: () => uptime
27
- });
28
- module.exports = __toCommonJS(darwin_exports);
29
- var import_createSubnet = require("./createSubnet.js");
30
- var import_utils = require("@gjsify/utils");
1
+ import { createSubnet } from "./createSubnet.js";
2
+ import { cli } from "@gjsify/utils";
31
3
  const EOL = /\r\n|\n/;
32
4
  const NOMAC = "00:00:00:00:00:00";
33
- const getIPv6Subnet = (0, import_createSubnet.createSubnet)(128, 16, 16, ":");
5
+ const getIPv6Subnet = createSubnet(128, 16, 16, ":");
34
6
  const parseInterfaces = function(info) {
35
7
  info = info.trim();
36
8
  if (info.length < 1 || !/\binet\b/.test(info))
@@ -73,12 +45,12 @@ const parseInterfaces = function(info) {
73
45
  this[info.slice(0, info.indexOf(":"))] = iface;
74
46
  };
75
47
  const cpus = () => {
76
- let cores = parseFloat((0, import_utils.cli)("sysctl -n hw.ncpu"));
48
+ let cores = parseFloat(cli("sysctl -n hw.ncpu"));
77
49
  const cpus2 = [];
78
50
  while (cores--) {
79
51
  cpus2.push({
80
- model: (0, import_utils.cli)("sysctl -n machdep.cpu.brand_string").replace(/\s+/g, " "),
81
- speed: parseFloat((0, import_utils.cli)("sysctl -n hw.cpufrequency")) / 1e3 / 1e3,
52
+ model: cli("sysctl -n machdep.cpu.brand_string").replace(/\s+/g, " "),
53
+ speed: parseFloat(cli("sysctl -n hw.cpufrequency")) / 1e3 / 1e3,
82
54
  get times() {
83
55
  console.warn("cpus.times is not supported");
84
56
  return {};
@@ -88,9 +60,9 @@ const cpus = () => {
88
60
  return cpus2;
89
61
  };
90
62
  const endianness = () => "LE";
91
- const freemem = () => parseFloat((0, import_utils.cli)("sysctl -n hw.memsize")) - parseFloat((0, import_utils.cli)("sysctl -n hw.physmem"));
63
+ const freemem = () => parseFloat(cli("sysctl -n hw.memsize")) - parseFloat(cli("sysctl -n hw.physmem"));
92
64
  const loadavg = () => /load\s+averages:\s+(\d+(?:\.\d+))\s+(\d+(?:\.\d+))\s+(\d+(?:\.\d+))/.test(
93
- (0, import_utils.cli)("uptime")
65
+ cli("uptime")
94
66
  ) && [
95
67
  parseFloat(RegExp.$1),
96
68
  parseFloat(RegExp.$2),
@@ -99,7 +71,7 @@ const loadavg = () => /load\s+averages:\s+(\d+(?:\.\d+))\s+(\d+(?:\.\d+))\s+(\d+
99
71
  const networkInterfaces = () => {
100
72
  const ifaces = {};
101
73
  const groups = [];
102
- const lines = (0, import_utils.cli)("ifconfig").split(EOL);
74
+ const lines = cli("ifconfig").split(EOL);
103
75
  const length = lines.length;
104
76
  for (let group = [], re = /^\S+?:/, i = 0; i < length; i++) {
105
77
  if (re.test(lines[i])) {
@@ -115,12 +87,12 @@ const networkInterfaces = () => {
115
87
  return ifaces;
116
88
  };
117
89
  const totalmem = () => {
118
- let I, mem = (0, import_utils.cli)("free -b").split(EOL);
90
+ let I, mem = cli("free -b").split(EOL);
119
91
  mem[0].split(/\s+/).some((info, i) => info === "total" && (I = i));
120
92
  return parseFloat(mem[1].split(/\s+/)[I + 1]);
121
93
  };
122
94
  const uptime = () => {
123
- const uptime2 = (0, import_utils.cli)("uptime");
95
+ const uptime2 = cli("uptime");
124
96
  const up = /up\s+([^,]+)?,/.test(uptime2) && RegExp.$1;
125
97
  switch (true) {
126
98
  case /^(\d+):(\d+)$/.test(up):
@@ -132,3 +104,12 @@ const uptime = () => {
132
104
  }
133
105
  return up;
134
106
  };
107
+ export {
108
+ cpus,
109
+ endianness,
110
+ freemem,
111
+ loadavg,
112
+ networkInterfaces,
113
+ totalmem,
114
+ uptime
115
+ };
package/lib/cjs/index.js CHANGED
@@ -1,66 +1,22 @@
1
- var __create = Object.create;
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 src_exports = {};
29
- __export(src_exports, {
30
- EOL: () => EOL,
31
- constants: () => import_constants.default,
32
- cpus: () => cpus,
33
- endianness: () => endianness,
34
- freemem: () => freemem,
35
- homedir: () => homedir,
36
- hostname: () => hostname,
37
- loadavg: () => loadavg,
38
- networkInterfaces: () => networkInterfaces,
39
- release: () => release,
40
- tmpdir: () => tmpdir,
41
- type: () => type,
42
- userInfo: () => userInfo
43
- });
44
- module.exports = __toCommonJS(src_exports);
45
- var import_utils = require("@gjsify/utils");
46
- var linux = __toESM(require("./linux.js"), 1);
47
- var darwin = __toESM(require("./darwin.js"), 1);
48
- var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
49
- var import_constants = __toESM(require("./constants.js"), 1);
50
- const EOL = (0, import_utils.getPathSeparator)() === "/" ? "\n" : "\r\n";
51
- const homedir = () => import_glib_2.default.get_home_dir();
52
- const hostname = () => import_glib_2.default.get_host_name();
53
- const release = () => (0, import_utils.cli)("uname -r");
54
- const tmpdir = () => import_glib_2.default.get_tmp_dir();
55
- const type = () => (0, import_utils.cli)("uname");
1
+ import { cli, getPathSeparator, getOs } from "@gjsify/utils";
2
+ import * as linux from "./linux.js";
3
+ import * as darwin from "./darwin.js";
4
+ import GLib from "@girs/glib-2.0";
5
+ import constants from "./constants.js";
6
+ const EOL = getPathSeparator() === "/" ? "\n" : "\r\n";
7
+ const homedir = () => GLib.get_home_dir();
8
+ const hostname = () => GLib.get_host_name();
9
+ const release = () => cli("uname -r");
10
+ const tmpdir = () => GLib.get_tmp_dir();
11
+ const type = () => cli("uname");
56
12
  const userInfo = () => ({
57
13
  uid: 1e3,
58
14
  gid: 100,
59
- username: import_glib_2.default.get_user_name(),
60
- homedir: import_glib_2.default.get_home_dir()
15
+ username: GLib.get_user_name(),
16
+ homedir: GLib.get_home_dir()
61
17
  });
62
18
  const cpus = () => {
63
- const _os = (0, import_utils.getOs)();
19
+ const _os = getOs();
64
20
  switch (_os) {
65
21
  case "darwin":
66
22
  return darwin.cpus();
@@ -72,7 +28,7 @@ const cpus = () => {
72
28
  }
73
29
  };
74
30
  const endianness = () => {
75
- const _os = (0, import_utils.getOs)();
31
+ const _os = getOs();
76
32
  switch (_os) {
77
33
  case "darwin":
78
34
  return darwin.endianness();
@@ -84,7 +40,7 @@ const endianness = () => {
84
40
  }
85
41
  };
86
42
  const freemem = () => {
87
- const _os = (0, import_utils.getOs)();
43
+ const _os = getOs();
88
44
  switch (_os) {
89
45
  case "darwin":
90
46
  return darwin.freemem();
@@ -96,7 +52,7 @@ const freemem = () => {
96
52
  }
97
53
  };
98
54
  const loadavg = () => {
99
- const _os = (0, import_utils.getOs)();
55
+ const _os = getOs();
100
56
  switch (_os) {
101
57
  case "darwin":
102
58
  return darwin.loadavg();
@@ -108,7 +64,7 @@ const loadavg = () => {
108
64
  }
109
65
  };
110
66
  const networkInterfaces = () => {
111
- const _os = (0, import_utils.getOs)();
67
+ const _os = getOs();
112
68
  switch (_os) {
113
69
  case "darwin":
114
70
  return darwin.networkInterfaces();
@@ -119,3 +75,18 @@ const networkInterfaces = () => {
119
75
  break;
120
76
  }
121
77
  };
78
+ export {
79
+ EOL,
80
+ constants,
81
+ cpus,
82
+ endianness,
83
+ freemem,
84
+ homedir,
85
+ hostname,
86
+ loadavg,
87
+ networkInterfaces,
88
+ release,
89
+ tmpdir,
90
+ type,
91
+ userInfo
92
+ };
package/lib/cjs/linux.js CHANGED
@@ -1,36 +1,8 @@
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 linux_exports = {};
19
- __export(linux_exports, {
20
- cpus: () => cpus,
21
- endianness: () => endianness,
22
- freemem: () => freemem,
23
- loadavg: () => loadavg,
24
- networkInterfaces: () => networkInterfaces,
25
- totalmem: () => totalmem,
26
- uptime: () => uptime
27
- });
28
- module.exports = __toCommonJS(linux_exports);
29
- var import_createSubnet = require("./createSubnet.js");
30
- var import_utils = require("@gjsify/utils");
1
+ import { createSubnet } from "./createSubnet.js";
2
+ import { cli } from "@gjsify/utils";
31
3
  const EOL = /\r\n|\n/;
32
- const getIPv4Subnet = (0, import_createSubnet.createSubnet)(32, 8, 10, ".");
33
- const getIPv6Subnet = (0, import_createSubnet.createSubnet)(128, 16, 16, ":");
4
+ const getIPv4Subnet = createSubnet(32, 8, 10, ".");
5
+ const getIPv6Subnet = createSubnet(128, 16, 16, ":");
34
6
  function parseInterfaces(info) {
35
7
  info = info.trim();
36
8
  if (info.length < 1)
@@ -64,7 +36,7 @@ const cpus = () => {
64
36
  const FREQ = /^cpu[\s_]+MHz\s*:\s*(\d+)/i;
65
37
  const cpus2 = [];
66
38
  let cpu;
67
- (0, import_utils.cli)("cat /proc/cpuinfo").split(EOL).forEach((line) => {
39
+ cli("cat /proc/cpuinfo").split(EOL).forEach((line) => {
68
40
  switch (true) {
69
41
  case PROCESSOR.test(line):
70
42
  cpus2[RegExp.$1.trim()] = cpu = {
@@ -87,12 +59,12 @@ const cpus = () => {
87
59
  };
88
60
  const endianness = () => "LE";
89
61
  const freemem = () => {
90
- let I, mem = (0, import_utils.cli)("free -b").split(EOL);
62
+ let I, mem = cli("free -b").split(EOL);
91
63
  mem[0].split(/\s+/).some((info, i) => info === "free" && (I = i));
92
64
  return parseFloat(mem[1].split(/\s+/)[I + 1]);
93
65
  };
94
66
  const loadavg = () => /(\d+(?:\.\d+))\s+(\d+(?:\.\d+))\s+(\d+(?:\.\d+))/.test(
95
- (0, import_utils.cli)("cat /proc/loadavg")
67
+ cli("cat /proc/loadavg")
96
68
  ) && [
97
69
  parseFloat(RegExp.$1),
98
70
  parseFloat(RegExp.$2),
@@ -100,12 +72,21 @@ const loadavg = () => /(\d+(?:\.\d+))\s+(\d+(?:\.\d+))\s+(\d+(?:\.\d+))/.test(
100
72
  ];
101
73
  const networkInterfaces = () => {
102
74
  const ifaces = {};
103
- (0, import_utils.cli)("ip addr").split(/^\d+:\s+/m).forEach(parseInterfaces, ifaces);
75
+ cli("ip addr").split(/^\d+:\s+/m).forEach(parseInterfaces, ifaces);
104
76
  return ifaces;
105
77
  };
106
78
  const totalmem = () => {
107
- let I, mem = (0, import_utils.cli)("free -b").split(EOL);
79
+ let I, mem = cli("free -b").split(EOL);
108
80
  mem[0].split(/\s+/).some((info, i) => info === "total" && (I = i));
109
81
  return parseFloat(mem[1].split(/\s+/)[I + 1]);
110
82
  };
111
- const uptime = () => (Date.now() - Date.parse((0, import_utils.cli)("uptime -s").replace(" ", "T"))) / 1e3;
83
+ const uptime = () => (Date.now() - Date.parse(cli("uptime -s").replace(" ", "T"))) / 1e3;
84
+ export {
85
+ cpus,
86
+ endianness,
87
+ freemem,
88
+ loadavg,
89
+ networkInterfaces,
90
+ totalmem,
91
+ uptime
92
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/os",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Node.js os module for Gjs",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -35,10 +35,10 @@
35
35
  "os"
36
36
  ],
37
37
  "dependencies": {
38
- "@girs/gjs": "^3.1.0",
39
- "@gjsify/utils": "^0.0.2"
38
+ "@girs/gjs": "^3.2.6",
39
+ "@gjsify/utils": "^0.0.4"
40
40
  },
41
41
  "devDependencies": {
42
- "@gjsify/cli": "^0.0.2"
42
+ "@gjsify/cli": "^0.0.4"
43
43
  }
44
44
  }