@gjsify/utils 0.0.4 → 0.1.0

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.
Files changed (119) hide show
  1. package/README.md +26 -0
  2. package/lib/esm/base64.js +72 -0
  3. package/lib/esm/byte-array.js +6 -0
  4. package/lib/esm/cli.js +1 -2
  5. package/lib/esm/defer.js +6 -0
  6. package/lib/esm/encoding.js +35 -0
  7. package/lib/esm/fs.js +2 -1
  8. package/lib/esm/gio-errors.js +98 -0
  9. package/lib/esm/gio.js +39 -0
  10. package/lib/esm/globals.js +8 -0
  11. package/lib/esm/index.js +10 -8
  12. package/lib/esm/main-loop.js +28 -0
  13. package/lib/esm/next-tick.js +6 -0
  14. package/lib/esm/structured-clone.js +169 -0
  15. package/lib/types/base64.d.ts +8 -0
  16. package/lib/types/byte-array.d.ts +7 -0
  17. package/lib/types/defer.d.ts +7 -0
  18. package/lib/types/encoding.d.ts +11 -0
  19. package/lib/types/gio-errors.d.ts +28 -0
  20. package/lib/types/gio.d.ts +17 -0
  21. package/lib/types/globals.d.ts +5 -0
  22. package/lib/types/index.d.ts +10 -8
  23. package/lib/types/main-loop.d.ts +20 -0
  24. package/lib/types/next-tick.d.ts +5 -0
  25. package/lib/types/structured-clone.d.ts +15 -0
  26. package/package.json +18 -20
  27. package/src/base64.ts +78 -0
  28. package/src/byte-array.ts +12 -0
  29. package/src/defer.ts +11 -0
  30. package/src/encoding.ts +36 -0
  31. package/src/fs.ts +2 -2
  32. package/src/gio-errors.ts +101 -0
  33. package/src/gio.ts +67 -0
  34. package/src/globals.ts +13 -0
  35. package/src/index.ts +10 -9
  36. package/src/main-loop.ts +62 -0
  37. package/src/next-tick.ts +16 -0
  38. package/src/structured-clone.ts +242 -0
  39. package/src/test.ts +1 -3
  40. package/tsconfig.json +27 -10
  41. package/tsconfig.tsbuildinfo +1 -0
  42. package/lib/cjs/cancel-handler.js +0 -22
  43. package/lib/cjs/cli.js +0 -11
  44. package/lib/cjs/error.js +0 -21
  45. package/lib/cjs/file.js +0 -13
  46. package/lib/cjs/fs.js +0 -21
  47. package/lib/cjs/index.js +0 -14
  48. package/lib/cjs/log.js +0 -159
  49. package/lib/cjs/message.js +0 -13
  50. package/lib/cjs/os.js +0 -81
  51. package/lib/cjs/path.js +0 -50
  52. package/lib/cjs/process.js +0 -41
  53. package/lib/cjs/system.js +0 -47
  54. package/lib/cjs/tty.js +0 -13
  55. package/lib/cjs/types/cancel-signals.js +0 -0
  56. package/lib/cjs/types/error-data.js +0 -0
  57. package/lib/cjs/types/index.js +0 -8
  58. package/lib/cjs/types/signal-methods.js +0 -0
  59. package/lib/cjs/types/stack-trace-frame.js +0 -0
  60. package/lib/cjs/types/structured-log-data.js +0 -0
  61. package/lib/cjs/types/uncaught-exception-data.js +0 -0
  62. package/lib/cjs/types/unhandled-rejection-data.js +0 -0
  63. package/lib/cjs/types/user-info.js +0 -0
  64. package/lib/cjs/version.js +0 -7
  65. package/lib/esm/cancel-handler.js +0 -22
  66. package/lib/esm/log.js +0 -159
  67. package/lib/esm/os.js +0 -81
  68. package/lib/esm/process.js +0 -41
  69. package/lib/esm/system.js +0 -47
  70. package/lib/esm/tty.js +0 -13
  71. package/lib/esm/types/cancel-signals.js +0 -0
  72. package/lib/esm/types/error-data.js +0 -0
  73. package/lib/esm/types/index.js +0 -8
  74. package/lib/esm/types/signal-methods.js +0 -0
  75. package/lib/esm/types/stack-trace-frame.js +0 -0
  76. package/lib/esm/types/structured-log-data.js +0 -0
  77. package/lib/esm/types/uncaught-exception-data.js +0 -0
  78. package/lib/esm/types/unhandled-rejection-data.js +0 -0
  79. package/lib/esm/types/user-info.js +0 -0
  80. package/lib/esm/version.js +0 -7
  81. package/lib/types/cancel-handler.d.ts +0 -4
  82. package/lib/types/log.d.ts +0 -29
  83. package/lib/types/os.d.ts +0 -7
  84. package/lib/types/process.d.ts +0 -6
  85. package/lib/types/system.d.ts +0 -5
  86. package/lib/types/tty.d.ts +0 -5
  87. package/lib/types/types/cancel-signals.d.ts +0 -5
  88. package/lib/types/types/error-data.d.ts +0 -7
  89. package/lib/types/types/index.d.ts +0 -8
  90. package/lib/types/types/signal-methods.d.ts +0 -62
  91. package/lib/types/types/stack-trace-frame.d.ts +0 -6
  92. package/lib/types/types/structured-log-data.d.ts +0 -5
  93. package/lib/types/types/uncaught-exception-data.d.ts +0 -4
  94. package/lib/types/types/unhandled-rejection-data.d.ts +0 -5
  95. package/lib/types/types/user-info.d.ts +0 -8
  96. package/lib/types/version.d.ts +0 -1
  97. package/src/cancel-handler.ts +0 -24
  98. package/src/log.ts +0 -218
  99. package/src/os.ts +0 -94
  100. package/src/process.spec.ts +0 -24
  101. package/src/process.ts +0 -46
  102. package/src/system.ts +0 -56
  103. package/src/tty.spec.ts +0 -10
  104. package/src/tty.ts +0 -10
  105. package/src/types/cancel-signals.ts +0 -6
  106. package/src/types/error-data.ts +0 -8
  107. package/src/types/index.ts +0 -8
  108. package/src/types/signal-methods.ts +0 -63
  109. package/src/types/stack-trace-frame.ts +0 -7
  110. package/src/types/structured-log-data.ts +0 -5
  111. package/src/types/uncaught-exception-data.ts +0 -5
  112. package/src/types/unhandled-rejection-data.ts +0 -6
  113. package/src/types/user-info.ts +0 -9
  114. package/src/version.ts +0 -4
  115. package/test.gjs.js +0 -34758
  116. package/test.gjs.js.map +0 -7
  117. package/test.gjs.js.meta.json +0 -1
  118. package/tsconfig.types.json +0 -7
  119. package/tsconfig.types.tsbuildinfo +0 -1
@@ -1,6 +0,0 @@
1
- import type { SignalMethods } from './signal-methods.js';
2
-
3
- export interface CancelSignals extends SignalMethods {
4
- connect(sigName: "close", callback: (self: SignalMethods) => void): number;
5
- emit(sigName: "close"): void;
6
- }
@@ -1,8 +0,0 @@
1
- import { StackTraceFrame } from './stack-trace-frame.js';
2
-
3
- export interface ErrorData {
4
- errorType: string;
5
- message: string;
6
- frames: StackTraceFrame[],
7
- stackTraceLines: string[];
8
- }
@@ -1,8 +0,0 @@
1
- export * from './cancel-signals.js';
2
- export * from './error-data.js';
3
- export * from './signal-methods.js';
4
- export * from './stack-trace-frame.js';
5
- export * from './structured-log-data.js';
6
- export * from './uncaught-exception-data.js';
7
- export * from './unhandled-rejection-data.js';
8
- export * from './user-info.js';
@@ -1,63 +0,0 @@
1
- // TODO: Use Methods interface from @girs/gjs instead
2
- /**
3
- * You can use the `Signals.addSignalMethods` method to apply the `Signals` convenience methods to an `Object`.
4
- * Generally, this is called on an object prototype, but may also be called on an object instance.
5
- * You can use this Interface for this object or prototype to make the methods in typescript known
6
- * @example
7
- * ```ts
8
- * const Signals = imports.signals;
9
- *
10
- * // Define an interface with the same name of your class to make the methods known
11
- * interface Events extends SignalMethods {}
12
- *
13
- * class Events {}
14
- * Signals.addSignalMethods(Events.prototype);
15
- *
16
- * const events = new Events();
17
- *
18
- * // Typescript will not complain here
19
- * events.emit("test-signal", "test argument");
20
- * ```
21
- */
22
- export interface SignalMethods {
23
- /**
24
- * Connects a callback to a signal for an object. Pass the returned ID to
25
- * `disconect()` to remove the handler.
26
- *
27
- * If `callback` returns `true`, emission will stop and no other handlers will be
28
- * invoked.
29
- *
30
- * > Warning: Unlike GObject signals, `this` within a signal callback will always
31
- * > refer to the global object (ie. `globalThis`).
32
- *
33
- * @param sigName A signal name
34
- * @param callback A callback function
35
- * @returns A handler ID
36
- */
37
- connect(sigName: string, callback: (self: any, ...args: any[]) => void): number;
38
- /**
39
- * Emits a signal for an object. Emission stops if a signal handler returns `true`.
40
- *
41
- * Unlike GObject signals, it is not necessary to declare signals or define their
42
- * signature. Simply call `emit()` with whatever signal name you wish, with
43
- * whatever arguments you wish.
44
- * @param sigName A signal name
45
- * @param args Any number of arguments, of any type
46
- */
47
- emit(sigName: string, ...args: any[]): void;
48
- /**
49
- * Disconnects a handler for a signal.
50
- * @param id The ID of the handler to be disconnected
51
- */
52
- disconnect(id: number): void;
53
- /**
54
- * Disconnects all signal handlers for an object.
55
- */
56
- disconnectAll(): void
57
- /**
58
- * Checks if a handler ID is connected.
59
- * @param id The ID of the handler to be disconnected
60
- * @returns `true` if connected, or `false` if not
61
- */
62
- signalHandlerIsConnected(id: number): boolean;
63
- }
@@ -1,7 +0,0 @@
1
- export interface StackTraceFrame {
2
- fileName: string;
3
- lineNumber: number;
4
- columnNumber: number;
5
- line: string;
6
- }
7
-
@@ -1,5 +0,0 @@
1
- export interface StructuredLogData {
2
- message: string;
3
- priority: number;
4
- domain: string;
5
- }
@@ -1,5 +0,0 @@
1
- import { ErrorData } from './error-data.js';
2
-
3
- export interface UncaughtExceptionData extends ErrorData {
4
- error: Error;
5
- }
@@ -1,6 +0,0 @@
1
- import { ErrorData } from './error-data.js';
2
-
3
- export interface UnhandledRejectionData extends ErrorData {
4
- reason: any;
5
- promise: Promise<any>;
6
- }
@@ -1,9 +0,0 @@
1
- export interface UserInfo {
2
- username: string;
3
- // password: string;
4
- userId: number;
5
- groupId: number;
6
- userInfo: string;
7
- homeDirectory: string;
8
- shell: string;
9
- }
package/src/version.ts DELETED
@@ -1,4 +0,0 @@
1
- export const getGjsVersion = () => {
2
- const v = imports.system.version.toString();
3
- return `${v[0]}.${+(v[1] + v[2])}.${+(v[3] + v[4])}`;
4
- }