gloomberb 0.9.0 → 0.9.2
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/package.json +6 -2
- package/patches/electrobun@1.18.1.patch +85 -0
- package/src/app/global-shortcuts.test.tsx +12 -0
- package/src/app/global-shortcuts.ts +1 -1
- package/src/assets/gloomberb-logo-windows.ico +0 -0
- package/src/assets/gloomberb-logo-windows.png +0 -0
- package/src/assets/gloomberb-logo.ico +0 -0
- package/src/components/chart/comparison-stock-chart/helpers.ts +0 -32
- package/src/components/chart/comparison-stock-chart/layout-metrics.ts +6 -6
- package/src/components/chart/comparison-stock-chart/legend.tsx +41 -44
- package/src/components/chart/comparison-stock-chart/view.tsx +46 -6
- package/src/components/layout/detached-pane-shell.tsx +11 -4
- package/src/components/layout/header.tsx +25 -10
- package/src/components/layout/titlebar-overlay.ts +16 -0
- package/src/components/layout/window-controls.tsx +99 -0
- package/src/components/price-performance.tsx +175 -0
- package/src/market-data/performance.test.ts +54 -0
- package/src/market-data/performance.ts +109 -0
- package/src/plugins/builtin/comparison-chart/index.test.tsx +88 -9
- package/src/plugins/builtin/congress-trades/detail.tsx +204 -68
- package/src/plugins/builtin/congress-trades/footer.ts +14 -8
- package/src/plugins/builtin/congress-trades/keyboard.ts +4 -23
- package/src/plugins/builtin/congress-trades/model.ts +29 -0
- package/src/plugins/builtin/congress-trades/pane.tsx +8 -13
- package/src/plugins/builtin/congress-trades/table.tsx +10 -1
- package/src/plugins/builtin/ticker-detail/overview/model.ts +0 -14
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +25 -0
- package/src/renderers/electrobun/bun/application-menu/index.test.ts +12 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -0
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +51 -3
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +31 -0
- package/src/renderers/electrobun/bun/desktop/initialization.ts +1 -0
- package/src/renderers/electrobun/bun/desktop/window-controls.test.ts +53 -0
- package/src/renderers/electrobun/bun/desktop/window-controls.ts +73 -0
- package/src/renderers/electrobun/bun/desktop/window-style.ts +31 -0
- package/src/renderers/electrobun/bun/desktop/windows-custom-chrome.ts +58 -0
- package/src/renderers/electrobun/bun/desktop/windows-icons.ts +70 -0
- package/src/renderers/electrobun/bun/desktop/windows-native.ts +75 -0
- package/src/renderers/electrobun/bun/index.ts +36 -7
- package/src/renderers/electrobun/bun/window/frame.test.ts +7 -0
- package/src/renderers/electrobun/bun/window/frame.ts +5 -0
- package/src/renderers/electrobun/shared/protocol.ts +1 -0
- package/src/renderers/electrobun/view/build-assets.ts +2 -1
- package/src/renderers/electrobun/view/host/text.tsx +29 -9
- package/src/renderers/electrobun/view/main.tsx +2 -1
- package/src/renderers/electrobun/view/styles.css +29 -8
- package/src/renderers/electrobun/view/ui-host.tsx +113 -74
- package/src/ui/host.tsx +2 -0
- package/src/updater.test.ts +47 -2
- package/src/updater.ts +67 -10
- package/src/version.ts +1 -1
|
@@ -14,6 +14,7 @@ export interface ElectrobunBackendInit {
|
|
|
14
14
|
desktopThemePreview: DesktopThemePreviewState;
|
|
15
15
|
pluginState: Record<string, Record<string, unknown>>;
|
|
16
16
|
capabilityManifests: CapabilityManifest[];
|
|
17
|
+
desktopPlatform: string;
|
|
17
18
|
windowKind: "main" | "detached";
|
|
18
19
|
paneId?: string;
|
|
19
20
|
}
|
|
@@ -108,10 +108,11 @@ ${bootstrapScript}
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
function resolveAlias(args: { path: string; importer?: string }, aliasRules: AliasRule[]) {
|
|
111
|
+
const importer = args.importer?.replaceAll("\\", "/");
|
|
111
112
|
for (const rule of aliasRules) {
|
|
112
113
|
const target = rule.length === 2
|
|
113
114
|
? args.path.endsWith(rule[0]) && rule[1]
|
|
114
|
-
: args.path === rule[0] &&
|
|
115
|
+
: args.path === rule[0] && importer?.endsWith(rule[1]) && rule[2];
|
|
115
116
|
if (target) return { path: electrobunViewPath(target) };
|
|
116
117
|
}
|
|
117
118
|
}
|
|
@@ -8,9 +8,20 @@ import {
|
|
|
8
8
|
type TextProps,
|
|
9
9
|
} from "../../../../ui/host";
|
|
10
10
|
import { renderAsciiText } from "../../../../ui/ascii-font";
|
|
11
|
+
import { WEB_CELL_WIDTH } from "../input-host";
|
|
11
12
|
import { hasDirectMouseHandler, mouseHandlers } from "./mouse";
|
|
12
13
|
import { cleanDomProps, commonStyle, textStyle } from "./style";
|
|
13
14
|
|
|
15
|
+
const WEB_GLOOMBERB_WORDMARK = [
|
|
16
|
+
" ____ _ _ _ ",
|
|
17
|
+
" / ___| | ___ ___ _ __ ___ | |__ ___ _ __| |__ ",
|
|
18
|
+
"| | _| |/ _ \\ / _ \\| '_ ` _ \\| '_ \\ / _ \\ '__| '_ \\ ",
|
|
19
|
+
"| |_| | | (_) | (_) | | | | | | |_) | __/ | | |_) |",
|
|
20
|
+
" \\____|_|\\___/ \\___/|_| |_| |_|_.__/ \\___|_| |_.__/ ",
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const WEB_WORDMARK_CHAR_WIDTH_PX = Math.max(10, WEB_CELL_WIDTH);
|
|
24
|
+
|
|
14
25
|
function isStyledTextContent(value: unknown): value is { chunks: StyledTextChunk[] } {
|
|
15
26
|
return value instanceof StyledText
|
|
16
27
|
|| (!!value && typeof value === "object" && Array.isArray((value as { chunks?: unknown }).chunks));
|
|
@@ -91,31 +102,40 @@ export function WebAsciiText({
|
|
|
91
102
|
selectable = false,
|
|
92
103
|
...props
|
|
93
104
|
}: AsciiTextProps) {
|
|
94
|
-
const
|
|
105
|
+
const isWordmark = font === "wordmark";
|
|
106
|
+
const lines = isWordmark && text.trim().toLowerCase() === "gloomberb"
|
|
107
|
+
? WEB_GLOOMBERB_WORDMARK
|
|
108
|
+
: renderAsciiText(text, font);
|
|
95
109
|
const resolvedColor = color ?? fg;
|
|
96
110
|
const resolvedBackground = bg ?? backgroundColor;
|
|
111
|
+
const lineHeightPx = isWordmark ? 16 : 12;
|
|
112
|
+
const wordmarkWidthPx = isWordmark
|
|
113
|
+
? Math.max(...lines.map((line) => line.length)) * WEB_WORDMARK_CHAR_WIDTH_PX
|
|
114
|
+
: undefined;
|
|
97
115
|
return (
|
|
98
116
|
<div
|
|
99
117
|
{...cleanDomProps(props)}
|
|
100
118
|
data-gloom-role={(props["data-gloom-role"] as string | undefined) ?? "ascii-text"}
|
|
101
119
|
style={{
|
|
102
120
|
...commonStyle({ ...props, fg: resolvedColor, bg: resolvedBackground }),
|
|
103
|
-
display: "
|
|
104
|
-
flexDirection: "column",
|
|
121
|
+
display: "block",
|
|
105
122
|
flexShrink: 0,
|
|
123
|
+
...(wordmarkWidthPx != null && props.width == null
|
|
124
|
+
? { width: `${wordmarkWidthPx}px`, minWidth: `${wordmarkWidthPx}px` }
|
|
125
|
+
: {}),
|
|
106
126
|
color: resolvedColor,
|
|
107
127
|
backgroundColor: resolvedBackground,
|
|
108
|
-
|
|
128
|
+
fontFamily: isWordmark ? "\"Cascadia Mono\", Consolas, \"Courier New\", monospace" : undefined,
|
|
129
|
+
fontSize: isWordmark ? "16px" : undefined,
|
|
130
|
+
fontVariantLigatures: "none",
|
|
131
|
+
lineHeight: `${lineHeightPx}px`,
|
|
109
132
|
whiteSpace: "pre",
|
|
133
|
+
letterSpacing: 0,
|
|
110
134
|
userSelect: selectable ? "text" : "none",
|
|
111
135
|
...(props.style as CSSProperties | undefined),
|
|
112
136
|
}}
|
|
113
137
|
>
|
|
114
|
-
{lines.
|
|
115
|
-
<span key={index} style={{ display: "block", height: "12px", lineHeight: "12px" }}>
|
|
116
|
-
{line}
|
|
117
|
-
</span>
|
|
118
|
-
))}
|
|
138
|
+
{lines.join("\n")}
|
|
119
139
|
</div>
|
|
120
140
|
);
|
|
121
141
|
}
|
|
@@ -19,7 +19,7 @@ import { DesktopFatalScreen, ElectrobunErrorBoundary } from "./fatal-screen";
|
|
|
19
19
|
import { WebInputHostProvider } from "./input-host";
|
|
20
20
|
import { webNativeRenderer } from "./native-renderer";
|
|
21
21
|
import { WebToastHostProvider } from "./toast-host";
|
|
22
|
-
import {
|
|
22
|
+
import { createWebUiHost, webRendererHost } from "./ui-host";
|
|
23
23
|
import { createApplicationMenuBridge } from "./application-menu-bridge";
|
|
24
24
|
import { createDesktopWindowBridge } from "./desktop/window/bridge";
|
|
25
25
|
import { prepareDetachedSnapshot } from "./desktop/window/snapshot";
|
|
@@ -88,6 +88,7 @@ async function boot() {
|
|
|
88
88
|
const config = desktopSnapshot?.config ?? init.config;
|
|
89
89
|
const desktopWindowBridge = createDesktopWindowBridge(init.windowKind, init.paneId);
|
|
90
90
|
const desktopApplicationMenuBridge = createApplicationMenuBridge();
|
|
91
|
+
const webUiHost = createWebUiHost(init.desktopPlatform);
|
|
91
92
|
measurePerfAsync("startup.electrobun.root-render", async () => {
|
|
92
93
|
root.render(
|
|
93
94
|
<ElectrobunErrorBoundary>
|
|
@@ -32,15 +32,9 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
|
|
|
32
32
|
[data-gloom-role="app-header"][data-titlebar-overlay="true"],
|
|
33
33
|
.electrobun-webkit-app-region-drag {
|
|
34
34
|
cursor: default;
|
|
35
|
-
-webkit-app-region: drag;
|
|
36
|
-
app-region: drag;
|
|
37
35
|
-webkit-user-select: none;
|
|
38
36
|
user-select: none;
|
|
39
37
|
}
|
|
40
|
-
.electrobun-webkit-app-region-no-drag {
|
|
41
|
-
-webkit-app-region: no-drag;
|
|
42
|
-
app-region: no-drag;
|
|
43
|
-
}
|
|
44
38
|
[data-titlebar-overlay="true"] {
|
|
45
39
|
min-height: __TITLEBAR_OVERLAY_HEIGHT_PX__px;
|
|
46
40
|
max-height: __TITLEBAR_OVERLAY_HEIGHT_PX__px;
|
|
@@ -55,8 +49,35 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
|
|
|
55
49
|
[data-titlebar-overlay="true"] a,
|
|
56
50
|
[data-titlebar-overlay="true"] .electrobun-webkit-app-region-no-drag,
|
|
57
51
|
[data-titlebar-overlay="true"] [data-gloom-interactive="true"] {
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
}
|
|
54
|
+
[data-gloom-role="window-controls"] {
|
|
55
|
+
height: 100%;
|
|
56
|
+
color: var(--gloom-header-text, #f2f2f2);
|
|
57
|
+
}
|
|
58
|
+
[data-gloom-role="window-control"] {
|
|
59
|
+
appearance: none;
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
border: 0;
|
|
64
|
+
padding: 0;
|
|
65
|
+
background: transparent;
|
|
66
|
+
color: color-mix(in srgb, var(--gloom-header-text, #f2f2f2) 86%, transparent);
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
transition: background-color 90ms linear, color 90ms linear;
|
|
69
|
+
}
|
|
70
|
+
[data-gloom-role="window-control"] svg {
|
|
71
|
+
display: block;
|
|
72
|
+
pointer-events: none;
|
|
73
|
+
}
|
|
74
|
+
[data-gloom-role="window-control"]:hover {
|
|
75
|
+
background: color-mix(in srgb, var(--gloom-header-text, #f2f2f2) 13%, transparent);
|
|
76
|
+
color: var(--gloom-header-text, #f2f2f2);
|
|
77
|
+
}
|
|
78
|
+
[data-gloom-role="window-control"][data-window-control-action="close"]:hover {
|
|
79
|
+
background: #c42b1c;
|
|
80
|
+
color: #ffffff;
|
|
60
81
|
}
|
|
61
82
|
[data-gloom-role="pane-window"][data-floating="true"] {
|
|
62
83
|
border: 0;
|
|
@@ -27,85 +27,121 @@ import { cleanDomProps, commonStyle } from "./host/style";
|
|
|
27
27
|
import { WebAsciiText, WebSpan, WebStrong, WebText, WebUnderline } from "./host/text";
|
|
28
28
|
import { WebTabs } from "./host/tabs";
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
30
|
+
function currentDesktopPlatform(): string {
|
|
31
|
+
const navigatorWithUserAgentData = navigator as Navigator & {
|
|
32
|
+
userAgentData?: { platform?: string };
|
|
33
|
+
};
|
|
34
|
+
return [
|
|
35
|
+
navigatorWithUserAgentData.userAgentData?.platform,
|
|
36
|
+
navigator.platform,
|
|
37
|
+
navigator.userAgent,
|
|
38
|
+
].filter((value): value is string => Boolean(value)).join(" ");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const DESKTOP_PLATFORM = currentDesktopPlatform();
|
|
42
|
+
const USES_WINDOWS_CONTROLS = !/(darwin|ipad|iphone|linux|mac)/i.test(DESKTOP_PLATFORM);
|
|
43
|
+
const NON_WINDOWS_DESKTOP_PLATFORMS = /^(darwin|linux|freebsd|openbsd|aix|sunos)$/i;
|
|
44
|
+
|
|
45
|
+
function usesWindowsWindowControls(desktopPlatform?: string): boolean {
|
|
46
|
+
const platform = desktopPlatform?.trim();
|
|
47
|
+
if (!platform) {
|
|
48
|
+
return USES_WINDOWS_CONTROLS;
|
|
49
|
+
}
|
|
50
|
+
if (/^win/i.test(platform)) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
if (NON_WINDOWS_DESKTOP_PLATFORMS.test(platform)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return USES_WINDOWS_CONTROLS;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function createWebUiHost(desktopPlatform?: string): UiHost {
|
|
60
|
+
const usesWindowsControls = usesWindowsWindowControls(desktopPlatform);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
kind: "desktop-web",
|
|
64
|
+
capabilities: {
|
|
65
|
+
nativePaneChrome: true,
|
|
66
|
+
titleBarOverlay: true,
|
|
67
|
+
precisePointer: true,
|
|
68
|
+
fractionalViewport: true,
|
|
69
|
+
cellWidthPx: WEB_CELL_WIDTH,
|
|
70
|
+
cellHeightPx: WEB_CELL_HEIGHT,
|
|
71
|
+
pixelRatio: Math.min(window.devicePixelRatio || 1, 2),
|
|
72
|
+
canvasCharts: true,
|
|
73
|
+
nativeContextMenu: NATIVE_CONTEXT_MENU_SUPPORTED,
|
|
74
|
+
windowControls: usesWindowsControls ? "windows" : undefined,
|
|
75
|
+
},
|
|
76
|
+
Box: WebBox,
|
|
77
|
+
Text: WebText,
|
|
78
|
+
Span: WebSpan,
|
|
79
|
+
Strong: WebStrong,
|
|
80
|
+
Underline: WebUnderline,
|
|
81
|
+
ScrollBox: WebScrollBox,
|
|
82
|
+
Input: WebInput,
|
|
83
|
+
Textarea: WebTextarea,
|
|
84
|
+
Button: WebButton,
|
|
85
|
+
TextField: WebTextField,
|
|
86
|
+
MessageComposer: WebMessageComposer,
|
|
87
|
+
ListView: WebListView,
|
|
88
|
+
SegmentedControl: WebSegmentedControl,
|
|
89
|
+
DialogFrame: WebDialogFrame,
|
|
90
|
+
PageStackView: WebPageStackView,
|
|
91
|
+
DataTable: WebDataTable,
|
|
92
|
+
Tabs: WebTabs,
|
|
93
|
+
ChartSurface: WebChartSurface,
|
|
94
|
+
ImageSurface: ({ children, src, alt = "", objectFit = "contain", ...props }) => {
|
|
95
|
+
const imageSrc = typeof src === "string" ? src.trim() : "";
|
|
96
|
+
const [failed, setFailed] = useState(false);
|
|
97
|
+
useEffect(() => setFailed(false), [imageSrc]);
|
|
98
|
+
const baseStyle = commonStyle(props);
|
|
99
|
+
return (
|
|
100
|
+
<div
|
|
101
|
+
{...cleanDomProps(props)}
|
|
102
|
+
style={{
|
|
103
|
+
...baseStyle,
|
|
104
|
+
overflow: baseStyle.overflow ?? "hidden",
|
|
105
|
+
...(props.style as CSSProperties | undefined),
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{imageSrc && !failed ? (
|
|
109
|
+
<img
|
|
110
|
+
src={imageSrc}
|
|
111
|
+
alt={alt}
|
|
112
|
+
draggable={false}
|
|
113
|
+
onError={() => setFailed(true)}
|
|
114
|
+
style={{
|
|
115
|
+
width: "100%",
|
|
116
|
+
height: "100%",
|
|
117
|
+
display: "block",
|
|
118
|
+
objectFit,
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
) : children as ReactNode}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
SpinnerMark: ({ color, ...props }) => (
|
|
126
|
+
<span
|
|
68
127
|
{...cleanDomProps(props)}
|
|
128
|
+
aria-hidden="true"
|
|
69
129
|
style={{
|
|
70
|
-
|
|
71
|
-
|
|
130
|
+
color,
|
|
131
|
+
display: "inline-block",
|
|
132
|
+
width: "1ch",
|
|
133
|
+
animation: "gloom-spin 0.9s steps(8) infinite",
|
|
72
134
|
...(props.style as CSSProperties | undefined),
|
|
73
135
|
}}
|
|
74
136
|
>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
height: "100%",
|
|
84
|
-
display: "block",
|
|
85
|
-
objectFit,
|
|
86
|
-
}}
|
|
87
|
-
/>
|
|
88
|
-
) : children as ReactNode}
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
},
|
|
92
|
-
SpinnerMark: ({ color, ...props }) => (
|
|
93
|
-
<span
|
|
94
|
-
{...cleanDomProps(props)}
|
|
95
|
-
aria-hidden="true"
|
|
96
|
-
style={{
|
|
97
|
-
color,
|
|
98
|
-
display: "inline-block",
|
|
99
|
-
width: "1ch",
|
|
100
|
-
animation: "gloom-spin 0.9s steps(8) infinite",
|
|
101
|
-
...(props.style as CSSProperties | undefined),
|
|
102
|
-
}}
|
|
103
|
-
>
|
|
104
|
-
*
|
|
105
|
-
</span>
|
|
106
|
-
),
|
|
107
|
-
AsciiText: WebAsciiText,
|
|
108
|
-
};
|
|
137
|
+
*
|
|
138
|
+
</span>
|
|
139
|
+
),
|
|
140
|
+
AsciiText: WebAsciiText,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const webUiHost: UiHost = createWebUiHost();
|
|
109
145
|
|
|
110
146
|
export const webRendererHost: RendererHost = {
|
|
111
147
|
supportsNativeDesktopNotifications: true,
|
|
@@ -115,6 +151,9 @@ export const webRendererHost: RendererHost = {
|
|
|
115
151
|
startWindowDrag() {
|
|
116
152
|
startElectrobunWindowDrag();
|
|
117
153
|
},
|
|
154
|
+
async controlWindow(action) {
|
|
155
|
+
await backendRequest("host.windowControl", { action });
|
|
156
|
+
},
|
|
118
157
|
async openExternal(url) {
|
|
119
158
|
await backendRequest("host.openExternal", { url });
|
|
120
159
|
},
|
package/src/ui/host.tsx
CHANGED
|
@@ -260,6 +260,7 @@ export interface UiHost {
|
|
|
260
260
|
canvasCharts?: boolean;
|
|
261
261
|
nativeCharts?: boolean;
|
|
262
262
|
nativeContextMenu?: boolean;
|
|
263
|
+
windowControls?: "windows";
|
|
263
264
|
};
|
|
264
265
|
Box: ComponentType<BoxProps>;
|
|
265
266
|
Text: ComponentType<TextProps>;
|
|
@@ -289,6 +290,7 @@ export interface UiHost {
|
|
|
289
290
|
export interface RendererHost {
|
|
290
291
|
requestExit(): void;
|
|
291
292
|
startWindowDrag?(): Promise<void> | void;
|
|
293
|
+
controlWindow?(action: "minimize" | "toggle-maximize" | "close"): Promise<void> | void;
|
|
292
294
|
openExternal(url: string): Promise<void>;
|
|
293
295
|
copyText(text: string): Promise<void>;
|
|
294
296
|
copyPngImage?(pngBase64: string): Promise<void>;
|
package/src/updater.test.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
checkForUpdate,
|
|
9
9
|
checkForUpdateDetailed,
|
|
10
10
|
detectUpdateAction,
|
|
11
|
+
getAssetBaseNameForRuntime,
|
|
11
12
|
performUpdate,
|
|
12
13
|
resolveSelfUpdateTargetPath,
|
|
13
14
|
setUpdateHost,
|
|
@@ -23,11 +24,21 @@ afterEach(() => {
|
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
function expectedAssetName(compressed = false): string {
|
|
26
|
-
const os = process.platform === "darwin" ? "darwin" : "linux";
|
|
27
|
+
const os = process.platform === "darwin" ? "darwin" : process.platform === "win32" ? "windows" : "linux";
|
|
27
28
|
const arch = os === "darwin" || process.arch === "arm64" ? "arm64" : "x64";
|
|
28
|
-
|
|
29
|
+
const extension = os === "windows" ? ".exe" : "";
|
|
30
|
+
return compressed ? `gloomberb-${os}-${arch}${extension}.gz` : `gloomberb-${os}-${arch}${extension}`;
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
describe("getAssetBaseNameForRuntime", () => {
|
|
34
|
+
test("uses the Windows executable release asset name on win32", () => {
|
|
35
|
+
expect(getAssetBaseNameForRuntime({
|
|
36
|
+
platform: "win32",
|
|
37
|
+
arch: "x64",
|
|
38
|
+
})).toBe("gloomberb-windows-x64.exe");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
31
42
|
describe("detectUpdateAction", () => {
|
|
32
43
|
test("uses self-update for standalone binaries", () => {
|
|
33
44
|
expect(detectUpdateAction(
|
|
@@ -46,6 +57,16 @@ describe("detectUpdateAction", () => {
|
|
|
46
57
|
});
|
|
47
58
|
});
|
|
48
59
|
|
|
60
|
+
test("uses manual bun updates for Windows bun-managed installs", () => {
|
|
61
|
+
expect(detectUpdateAction(
|
|
62
|
+
"C:\\Program Files\\Bun\\bun.exe",
|
|
63
|
+
["C:\\Program Files\\Bun\\bun.exe", "C:\\Users\\vince\\.bun\\install\\global\\node_modules\\gloomberb\\bin\\gloomberb"],
|
|
64
|
+
)).toEqual({
|
|
65
|
+
kind: "manual",
|
|
66
|
+
command: "bun install -g gloomberb@latest",
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
49
70
|
test("uses manual npm updates for node-managed installs", () => {
|
|
50
71
|
expect(detectUpdateAction(
|
|
51
72
|
"/opt/homebrew/bin/node",
|
|
@@ -56,6 +77,13 @@ describe("detectUpdateAction", () => {
|
|
|
56
77
|
});
|
|
57
78
|
});
|
|
58
79
|
|
|
80
|
+
test("does not offer self-update for standalone Windows executables", () => {
|
|
81
|
+
expect(detectUpdateAction(
|
|
82
|
+
"C:\\Users\\vince\\Downloads\\gloomberb.exe",
|
|
83
|
+
["C:\\Users\\vince\\Downloads\\gloomberb.exe"],
|
|
84
|
+
)).toBeNull();
|
|
85
|
+
});
|
|
86
|
+
|
|
59
87
|
test("skips updates when launched from source under bun", () => {
|
|
60
88
|
expect(detectUpdateAction(
|
|
61
89
|
"/opt/homebrew/bin/bun",
|
|
@@ -76,6 +104,16 @@ describe("detectUpdateAction", () => {
|
|
|
76
104
|
["/Applications/Gloomberb.app/Contents/MacOS/bun", "/Applications/Gloomberb.app/Contents/Resources/gloomberb-tui/tui-entry.js"],
|
|
77
105
|
)).toBeNull();
|
|
78
106
|
});
|
|
107
|
+
|
|
108
|
+
test("does not suggest Bun-managed updates for the bundled Windows app TUI runtime", () => {
|
|
109
|
+
expect(detectUpdateAction(
|
|
110
|
+
"C:\\Users\\vince\\AppData\\Local\\Programs\\Gloomberb\\bin\\bun.exe",
|
|
111
|
+
[
|
|
112
|
+
"C:\\Users\\vince\\AppData\\Local\\Programs\\Gloomberb\\bin\\bun.exe",
|
|
113
|
+
"C:\\Users\\vince\\AppData\\Local\\Programs\\Gloomberb\\Resources\\gloomberb-tui\\tui-entry.js",
|
|
114
|
+
],
|
|
115
|
+
)).toBeNull();
|
|
116
|
+
});
|
|
79
117
|
});
|
|
80
118
|
|
|
81
119
|
describe("resolveSelfUpdateTargetPath", () => {
|
|
@@ -93,6 +131,13 @@ describe("resolveSelfUpdateTargetPath", () => {
|
|
|
93
131
|
)).toBeNull();
|
|
94
132
|
});
|
|
95
133
|
|
|
134
|
+
it("rejects Windows Bun runtime paths", () => {
|
|
135
|
+
expect(resolveSelfUpdateTargetPath(
|
|
136
|
+
"C:\\Program Files\\Bun\\bun.exe",
|
|
137
|
+
["C:\\Program Files\\Bun\\bun.exe", "dist\\index.js"],
|
|
138
|
+
)).toBeNull();
|
|
139
|
+
});
|
|
140
|
+
|
|
96
141
|
it("accepts packaged gloomberb binaries", () => {
|
|
97
142
|
expect(resolveSelfUpdateTargetPath(
|
|
98
143
|
"/Applications/gloomberb",
|
package/src/updater.ts
CHANGED
|
@@ -52,12 +52,22 @@ function compareSemver(a: string, b: string): number {
|
|
|
52
52
|
return 0;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
export function getAssetBaseNameForRuntime(
|
|
56
|
+
runtimeProcess: Pick<NodeJS.Process, "platform" | "arch"> | null = getRuntimeProcess(),
|
|
57
|
+
): string {
|
|
58
|
+
const os = runtimeProcess?.platform === "darwin"
|
|
59
|
+
? "darwin"
|
|
60
|
+
: runtimeProcess?.platform === "win32"
|
|
61
|
+
? "windows"
|
|
62
|
+
: "linux";
|
|
58
63
|
// macOS x64 uses arm64 binary (runs via Rosetta 2)
|
|
59
64
|
const arch = os === "darwin" || runtimeProcess?.arch === "arm64" ? "arm64" : "x64";
|
|
60
|
-
|
|
65
|
+
const extension = os === "windows" ? ".exe" : "";
|
|
66
|
+
return `gloomberb-${os}-${arch}${extension}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getAssetBaseName(): string {
|
|
70
|
+
return getAssetBaseNameForRuntime();
|
|
61
71
|
}
|
|
62
72
|
|
|
63
73
|
function resolveReleaseAsset(
|
|
@@ -90,6 +100,29 @@ function basename(value: string): string {
|
|
|
90
100
|
return normalized.slice(normalized.lastIndexOf("/") + 1);
|
|
91
101
|
}
|
|
92
102
|
|
|
103
|
+
const runtimeExecutables = new Set([
|
|
104
|
+
"bun",
|
|
105
|
+
"bun.exe",
|
|
106
|
+
"bunx",
|
|
107
|
+
"bunx.exe",
|
|
108
|
+
"node",
|
|
109
|
+
"node.exe",
|
|
110
|
+
"nodejs",
|
|
111
|
+
"nodejs.exe",
|
|
112
|
+
"npm",
|
|
113
|
+
"npm.cmd",
|
|
114
|
+
"npm.exe",
|
|
115
|
+
"npx",
|
|
116
|
+
"npx.cmd",
|
|
117
|
+
"npx.exe",
|
|
118
|
+
"pnpm",
|
|
119
|
+
"pnpm.cmd",
|
|
120
|
+
"pnpm.exe",
|
|
121
|
+
"yarn",
|
|
122
|
+
"yarn.cmd",
|
|
123
|
+
"yarn.exe",
|
|
124
|
+
]);
|
|
125
|
+
|
|
93
126
|
function resolveEntrypointPath(argv = process.argv): string {
|
|
94
127
|
return tryRealpath(argv[1] ?? "");
|
|
95
128
|
}
|
|
@@ -104,6 +137,15 @@ function isMacAppBundleExecutable(execPath: string): boolean {
|
|
|
104
137
|
return normalizePath(execPath).includes(".app/contents/macos/");
|
|
105
138
|
}
|
|
106
139
|
|
|
140
|
+
function isBundledDesktopTuiRuntime(execPath: string, argv: string[]): boolean {
|
|
141
|
+
const normalizedExecPath = normalizePath(tryRealpath(execPath));
|
|
142
|
+
const entrypoint = normalizePath(resolveEntrypointPath(argv));
|
|
143
|
+
if (!entrypoint.endsWith("/resources/gloomberb-tui/tui-entry.js")) return false;
|
|
144
|
+
return normalizedExecPath.endsWith("/contents/macos/bun")
|
|
145
|
+
|| normalizedExecPath.endsWith("/bin/bun")
|
|
146
|
+
|| normalizedExecPath.endsWith("/bin/bun.exe");
|
|
147
|
+
}
|
|
148
|
+
|
|
107
149
|
export function resolveSelfUpdateTargetPath(
|
|
108
150
|
execPath = getRuntimeProcess()?.execPath ?? "",
|
|
109
151
|
argv = getRuntimeProcess()?.argv ?? [],
|
|
@@ -113,7 +155,6 @@ export function resolveSelfUpdateTargetPath(
|
|
|
113
155
|
if (isMacAppBundleExecutable(resolvedExecPath)) return null;
|
|
114
156
|
|
|
115
157
|
const execBase = basename(normalizedExecPath);
|
|
116
|
-
const runtimeExecutables = new Set(["bun", "bunx", "node", "nodejs", "npm", "npx", "pnpm", "yarn"]);
|
|
117
158
|
if (runtimeExecutables.has(execBase)) return null;
|
|
118
159
|
if (normalizedExecPath.includes("/.bun/bin/")) return null;
|
|
119
160
|
|
|
@@ -128,20 +169,24 @@ export function detectUpdateAction(
|
|
|
128
169
|
argv = getRuntimeProcess()?.argv ?? [],
|
|
129
170
|
): UpdateAction | null {
|
|
130
171
|
if (isMacAppBundleExecutable(execPath)) return null;
|
|
131
|
-
|
|
132
|
-
if (resolveSelfUpdateTargetPath(execPath, argv)) {
|
|
133
|
-
return { kind: "self" };
|
|
134
|
-
}
|
|
172
|
+
if (isBundledDesktopTuiRuntime(execPath, argv)) return null;
|
|
135
173
|
|
|
136
174
|
const normalizedExecPath = normalizePath(tryRealpath(execPath));
|
|
137
175
|
const execBase = basename(normalizedExecPath);
|
|
138
176
|
const entrypoint = normalizePath(resolveEntrypointPath(argv));
|
|
177
|
+
if (execBase === "gloomberb.exe") return null;
|
|
178
|
+
|
|
179
|
+
if (resolveSelfUpdateTargetPath(execPath, argv)) {
|
|
180
|
+
return { kind: "self" };
|
|
181
|
+
}
|
|
139
182
|
|
|
140
183
|
if (!entrypoint || isSourceEntrypoint(entrypoint)) return null;
|
|
141
184
|
|
|
142
185
|
if (
|
|
143
186
|
execBase === "bun"
|
|
187
|
+
|| execBase === "bun.exe"
|
|
144
188
|
|| execBase === "bunx"
|
|
189
|
+
|| execBase === "bunx.exe"
|
|
145
190
|
|| normalizedExecPath.includes("/.bun/bin/")
|
|
146
191
|
|| entrypoint.includes("/.bun/install/")
|
|
147
192
|
|| entrypoint.includes("/install/global/")
|
|
@@ -151,11 +196,21 @@ export function detectUpdateAction(
|
|
|
151
196
|
|
|
152
197
|
if (
|
|
153
198
|
execBase === "node"
|
|
199
|
+
|| execBase === "node.exe"
|
|
154
200
|
|| execBase === "nodejs"
|
|
201
|
+
|| execBase === "nodejs.exe"
|
|
155
202
|
|| execBase === "npm"
|
|
203
|
+
|| execBase === "npm.cmd"
|
|
204
|
+
|| execBase === "npm.exe"
|
|
156
205
|
|| execBase === "npx"
|
|
206
|
+
|| execBase === "npx.cmd"
|
|
207
|
+
|| execBase === "npx.exe"
|
|
157
208
|
|| execBase === "pnpm"
|
|
209
|
+
|| execBase === "pnpm.cmd"
|
|
210
|
+
|| execBase === "pnpm.exe"
|
|
158
211
|
|| execBase === "yarn"
|
|
212
|
+
|| execBase === "yarn.cmd"
|
|
213
|
+
|| execBase === "yarn.exe"
|
|
159
214
|
|| entrypoint.includes("/lib/node_modules/")
|
|
160
215
|
|| entrypoint.includes("/node_modules/")
|
|
161
216
|
) {
|
|
@@ -283,6 +338,7 @@ export async function performUpdate(
|
|
|
283
338
|
|
|
284
339
|
const updatePath = execPath + ".update";
|
|
285
340
|
const oldPath = execPath + ".old";
|
|
341
|
+
let unlinkUpdatePath: ((path: string) => void) | null = null;
|
|
286
342
|
|
|
287
343
|
try {
|
|
288
344
|
const fsModulePath = "fs";
|
|
@@ -293,6 +349,7 @@ export async function performUpdate(
|
|
|
293
349
|
unlinkSync,
|
|
294
350
|
chmodSync,
|
|
295
351
|
} = await import(fsModulePath) as typeof import("fs");
|
|
352
|
+
unlinkUpdatePath = unlinkSync;
|
|
296
353
|
const { gunzipSync } = await import(zlibModulePath) as typeof import("zlib");
|
|
297
354
|
|
|
298
355
|
onProgress({ phase: "downloading", percent: 0 });
|
|
@@ -343,7 +400,7 @@ export async function performUpdate(
|
|
|
343
400
|
} catch (err: unknown) {
|
|
344
401
|
// Clean up temp file on failure
|
|
345
402
|
try {
|
|
346
|
-
|
|
403
|
+
unlinkUpdatePath?.(updatePath);
|
|
347
404
|
} catch {}
|
|
348
405
|
onProgress({
|
|
349
406
|
phase: "error",
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.9.
|
|
1
|
+
export const VERSION = "0.9.2";
|