Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/empty-olives-read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@arcanewizards/sigil': patch
---

Add optional extra system information

Allow a sigil app to include additional system information to display in
the Debugger component, such as additional paths.
11 changes: 9 additions & 2 deletions packages/sigil/src/app-shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type AppShellProps = {
logEventEmitter: SigilLogEventEmitter;
shutdownContext: ShutdownContextData;
children: ReactNode;
extraSystemInformation?: Record<string, string>;
};

export const AppShell = ({
Expand All @@ -29,6 +30,7 @@ export const AppShell = ({
logEventEmitter,
shutdownContext,
children,
extraSystemInformation,
}: AppShellProps): JSX.Element => {
const [logs, setLogs] = useState<AppRootLogEntry[]>([]);

Expand All @@ -44,8 +46,13 @@ export const AppShell = ({
}, [logEventEmitter]);

const system = useMemo(
() => createSystemInformation({ dataDirectory, version }),
[dataDirectory, version],
() =>
createSystemInformation({
dataDirectory,
version,
extra: extraSystemInformation,
}),
[dataDirectory, version, extraSystemInformation],
);

const appInformation: AppInformationContextData = useMemo(
Expand Down
1 change: 1 addition & 0 deletions packages/sigil/src/backend/app-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const DEFAULT_PROPS: AppRootProps = {
cwd: 'unknown',
os: 'unknown',
dataDirectory: 'unknown',
extra: {},
},
};

Expand Down
20 changes: 18 additions & 2 deletions packages/sigil/src/frontend/debugger.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, ReactNode, useCallback, useEffect, useRef } from 'react';
import { FC, ReactNode, useCallback, useEffect, useMemo, useRef } from 'react';
import { useBrowserContext } from './browser-context';
import { useDebuggerContext, useSystemInformation } from './context';
import { AppRootLogEntryStackFrame } from '../shared/types';
Expand Down Expand Up @@ -79,6 +79,22 @@ export const Debugger: FC<DebuggerProps> = ({ title, className }) => {
scrollToBottomIfRequired();
}, [scrollToBottomIfRequired]);

const systemInfo = useMemo(() => {
let info = '';

info += `OS: ${system.os}\n`;
info += `Version: ${system.version}\n`;
info += `App Path: ${system.appPath}\n`;
info += `CWD: ${system.cwd}\n`;
info += `Data Directory: ${system.dataDirectory}\n`;

for (const [key, value] of Object.entries(system.extra ?? {})) {
info += `${key}: ${value}\n`;
}

return info;
}, [system]);

return (
<div className={cn('flex flex-col', className)}>
<ToolbarWrapper>
Expand Down Expand Up @@ -112,7 +128,7 @@ export const Debugger: FC<DebuggerProps> = ({ title, className }) => {
select-text scrollbar-sigil
"
>
{`OS: ${system.os}\nVersion: ${system.version}\nApp Path: ${system.appPath}\nCWD: ${system.cwd}\nData Directory: ${system.dataDirectory}`}
{systemInfo}
</pre>
<div
ref={scrollRef}
Expand Down
3 changes: 3 additions & 0 deletions packages/sigil/src/runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,19 @@ const getStackFramesFromError = (error: unknown): AppRootLogEntryStackFrame => {
export const createSystemInformation = ({
dataDirectory,
version,
extra,
}: {
dataDirectory: string;
version: string;
extra?: SystemInformation['extra'];
}): SystemInformation => {
return {
appPath: process.execPath,
cwd: process.cwd(),
os: process.platform,
version,
dataDirectory,
extra,
};
};

Expand Down
1 change: 1 addition & 0 deletions packages/sigil/src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export type SystemInformation = {
appPath: string;
cwd: string;
dataDirectory: string;
extra?: Record<string, string>;
};