@elgato/utils 0.4.4 → 0.4.5

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/dist/index.d.ts CHANGED
@@ -10,3 +10,7 @@ export * from "./promises.js";
10
10
  export * from "./strings.js";
11
11
  export * from "./timers.js";
12
12
  export * from "./types.js";
13
+ export type { DataList } from "./lists/data-list.js";
14
+ export { OptionGroup, optionGroup } from "./lists/option-group.js";
15
+ export type { OptionList } from "./lists/option-list.js";
16
+ export { Option, option } from "./lists/option.js";
package/dist/index.js CHANGED
@@ -10,3 +10,5 @@ export * from "./promises.js";
10
10
  export * from "./strings.js";
11
11
  export * from "./timers.js";
12
12
  export * from "./types.js";
13
+ export { OptionGroup, optionGroup } from "./lists/option-group.js";
14
+ export { Option, option } from "./lists/option.js";
@@ -0,0 +1,6 @@
1
+ import type { OptionGroup } from "./option-group.js";
2
+ import type { Option } from "./option.js";
3
+ /**
4
+ * Collection of options and/or option groups.
5
+ */
6
+ export type DataList = (Option | OptionGroup)[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { z } from "zod/v4-mini";
2
+ import type { DataList } from "./data-list.js";
3
+ /**
4
+ * Serializable structure that represents a group of options.
5
+ */
6
+ export type OptionGroup = {
7
+ /**
8
+ * Discriminator property used to identify an option group.
9
+ */
10
+ readonly type: "option-group";
11
+ /**
12
+ * Determines whether the option group is disabled.
13
+ */
14
+ disabled?: boolean;
15
+ /**
16
+ * Options within the group.
17
+ */
18
+ options: DataList;
19
+ /**
20
+ * Label that represents the option group.
21
+ */
22
+ label: string;
23
+ };
24
+ /**
25
+ * Serializable structure that represents a group of options.
26
+ */
27
+ export declare const OptionGroup: z.ZodMiniType<OptionGroup>;
28
+ /**
29
+ * Creates a new option group.
30
+ * @param props Properties that define the option group.
31
+ * @returns The option group.
32
+ */
33
+ export declare function optionGroup(props: OptionGroupProps): OptionGroup;
34
+ /**
35
+ * Properties that define an option group.
36
+ */
37
+ type OptionGroupProps = Omit<OptionGroup, "type">;
38
+ export {};
@@ -0,0 +1,25 @@
1
+ import { z } from "zod/v4-mini";
2
+ import { Option } from "./option.js";
3
+ /**
4
+ * Serializable structure that represents a group of options.
5
+ */
6
+ export const OptionGroup = z.object({
7
+ type: z.literal("option-group"),
8
+ disabled: z.optional(z.boolean()),
9
+ options: z.lazy(() => z.array(z.union([Option, OptionGroup]))),
10
+ label: z.string(),
11
+ });
12
+ /**
13
+ * Creates a new option group.
14
+ * @param props Properties that define the option group.
15
+ * @returns The option group.
16
+ */
17
+ export function optionGroup(props) {
18
+ const { disabled, options, label } = props;
19
+ return {
20
+ type: "option-group",
21
+ disabled,
22
+ label,
23
+ options,
24
+ };
25
+ }
@@ -0,0 +1,5 @@
1
+ import type { Option } from "./option.js";
2
+ /**
3
+ * Collection of options.
4
+ */
5
+ export type OptionList = Option[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import { z } from "zod/v4-mini";
2
+ /**
3
+ * Serializable structure that represents an option.
4
+ */
5
+ export type Option = {
6
+ /**
7
+ * Discriminator property used to identify an option.
8
+ */
9
+ readonly type: "option";
10
+ /**
11
+ * Determines whether the option is disabled.
12
+ */
13
+ disabled?: boolean;
14
+ /**
15
+ * Label that represents the option.
16
+ */
17
+ label: string;
18
+ /**
19
+ * Value this option represents.
20
+ */
21
+ value: boolean | number | string;
22
+ };
23
+ /**
24
+ * Serializable structure that represents an option.
25
+ */
26
+ export declare const Option: z.ZodMiniType<Option>;
27
+ /**
28
+ * Creates a new option.
29
+ * @param props Properties that define the option.
30
+ * @returns The option.
31
+ */
32
+ export declare function option(props: OptionProps): Option;
33
+ /**
34
+ * Properties that define an option.
35
+ */
36
+ type OptionProps = Omit<Option, "type">;
37
+ export {};
@@ -0,0 +1,24 @@
1
+ import { z } from "zod/v4-mini";
2
+ /**
3
+ * Serializable structure that represents an option.
4
+ */
5
+ export const Option = z.object({
6
+ type: z.literal("option"),
7
+ disabled: z.optional(z.boolean()),
8
+ label: z.string(),
9
+ value: z.union([z.boolean(), z.number(), z.string()]),
10
+ });
11
+ /**
12
+ * Creates a new option.
13
+ * @param props Properties that define the option.
14
+ * @returns The option.
15
+ */
16
+ export function option(props) {
17
+ const { disabled, label, value } = props;
18
+ return {
19
+ type: "option",
20
+ disabled,
21
+ label,
22
+ value,
23
+ };
24
+ }
@@ -1,12 +1,12 @@
1
- import { execFile } from "node:child_process";
2
- import { promisify } from "node:util";
3
- const execFileAsync = promisify(execFile);
4
1
  /**
5
2
  * Uses `ps` to list running processes on POSIX-compliant systems (Linux, macOS, BSD, etc.).
6
3
  * @returns A promise that resolves to an array of `ProcessInfo` objects representing the currently running processes on the system. Each object contains the PID and the full command line of the process. If the `ps` command fails for any reason, it returns an empty array.
7
4
  */
8
5
  export async function getPosixProcesses() {
9
6
  try {
7
+ const { execFile } = await import("node:child_process");
8
+ const { promisify } = await import("node:util");
9
+ const execFileAsync = promisify(execFile);
10
10
  const { stdout } = await execFileAsync("ps", ["-ax", "-ww", "-o", "pid=,command="], {
11
11
  maxBuffer: 10 * 1024 * 1024,
12
12
  });
@@ -1,6 +1,3 @@
1
- import { execFile } from "node:child_process";
2
- import { promisify } from "node:util";
3
- const execFileAsync = promisify(execFile);
4
1
  /**
5
2
  * Uses PowerShell's `Get-CimInstance` to retrieve process information on Windows. This method is more robust than parsing `tasklist` output and handles command lines with spaces correctly.
6
3
  * @returns A promise that resolves to an array of `ProcessInfo` objects representing the currently running processes on a Windows system. Each object contains the PID and the full command line of the process. If the PowerShell command fails for any reason, it returns an empty array.
@@ -8,6 +5,9 @@ const execFileAsync = promisify(execFile);
8
5
  export async function getWindowsProcesses() {
9
6
  const script = "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; Get-CimInstance Win32_Process | Select-Object ProcessId,CommandLine,Name | ConvertTo-Json -Compress";
10
7
  try {
8
+ const { execFile } = await import("node:child_process");
9
+ const { promisify } = await import("node:util");
10
+ const execFileAsync = promisify(execFile);
11
11
  const { stdout } = await execFileAsync("powershell", ["-NoProfile", "-Command", script], {
12
12
  maxBuffer: 10 * 1024 * 1024,
13
13
  encoding: "utf8",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elgato/utils",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Utilities used throughout the Elgato ecosystem.",
5
5
  "type": "module",
6
6
  "files": [