@gloom-sh/terminal 0.19.6 → 0.20.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.
- package/LICENSE +0 -4
- package/package.json +6 -5
- package/patches/electrobun-devkit@2.0.5.patch +148 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/data.ts +21 -0
- package/src/api-client/index.ts +2 -0
- package/src/api-client/types/account.ts +86 -0
- package/src/api-client/types/assist.ts +32 -0
- package/src/api-client/types/auth.ts +63 -0
- package/src/api-client/types/billing.ts +54 -0
- package/src/api-client/types/chat.ts +180 -0
- package/src/api-client/types/congress.ts +107 -0
- package/src/api-client/types/credit.ts +110 -0
- package/src/api-client/types/econ.ts +158 -0
- package/src/api-client/types/equity-diagnostic.ts +73 -0
- package/src/api-client/types/filings-and-calls.ts +350 -0
- package/src/api-client/types/index.ts +25 -0
- package/src/api-client/types/jobs.ts +147 -0
- package/src/api-client/types/market.ts +122 -0
- package/src/api-client/types/news.ts +91 -0
- package/src/api-client/types/notes-and-theses.ts +172 -0
- package/src/api-client/types/quotes.ts +28 -0
- package/src/api-client/types/scanners.ts +125 -0
- package/src/api-client/types/screener.ts +65 -0
- package/src/api-client/types/search.ts +107 -0
- package/src/api-client/types/sync.ts +14 -0
- package/src/api-client/types/team-collections.ts +43 -0
- package/src/api-client/types/team-views.ts +32 -0
- package/src/api-client/types/teams.ts +135 -0
- package/src/api-client/types/ticker-data.ts +57 -0
- package/src/api-client/types/tweets.ts +59 -0
- package/src/api-client/types/world-venues.ts +23 -0
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +1 -7
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- package/src/cli/commands/ticker.ts +17 -4
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- package/src/cli/pane-functions/catalog.ts +3 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +11 -2
- package/src/components/data-table/export.ts +4 -1
- package/src/components/layout/detached-pane-shell.tsx +10 -37
- package/src/components/layout/double-escape-close.ts +90 -0
- package/src/components/layout/header.tsx +3 -2
- package/src/components/layout/market-summary.ts +6 -3
- package/src/components/layout/pane/footer/index.tsx +2 -6
- package/src/components/layout/pane/footer/model.ts +6 -12
- package/src/components/layout/shell/active-drag.ts +53 -11
- package/src/components/layout/shell/drag/magnets.ts +128 -19
- package/src/components/layout/shell/pane/actions.ts +6 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/status-bar.tsx +4 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +1 -1
- package/src/components/ui/data-table/index.tsx +5 -1
- package/src/components/ui/data-table/render-cell.ts +19 -0
- package/src/components/ui/delayed-mark.tsx +59 -7
- package/src/components/ui/icon.tsx +1 -8
- package/src/components/ui/menu.tsx +6 -1
- package/src/i18n/es.ts +3 -3
- package/src/i18n/ja.ts +3 -3
- package/src/i18n/ko.ts +3 -3
- package/src/i18n/zh-cn.ts +3 -3
- package/src/i18n/zh-tw.ts +3 -3
- package/src/plugins/builtin/chat/content/composer.tsx +21 -27
- package/src/plugins/builtin/chat/content/index.tsx +31 -3
- package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
- package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +32 -25
- package/src/plugins/builtin/congress-trades/model.ts +2 -1
- package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
- package/src/plugins/builtin/custom-view/index.tsx +1 -1
- package/src/plugins/builtin/custom-view/loader.ts +85 -8
- package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +13 -4
- package/src/plugins/builtin/equity-screener/headless.ts +33 -1
- package/src/plugins/builtin/equity-screener/model.ts +58 -15
- package/src/plugins/builtin/equity-screener/pane.tsx +36 -6
- package/src/plugins/builtin/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +55 -1
- package/src/plugins/builtin/insider/model.ts +30 -2
- package/src/plugins/builtin/jobs/model.ts +2 -2
- package/src/plugins/builtin/mna/model.ts +2 -2
- package/src/plugins/builtin/notes/files.ts +2 -0
- package/src/plugins/builtin/notes/owner.tsx +20 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
- package/src/plugins/builtin/notes/store.ts +6 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- package/src/plugins/builtin/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
- package/src/plugins/builtin/short-interest/headless.ts +1 -1
- package/src/plugins/builtin/short-interest/model.ts +15 -6
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
- package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
- package/src/plugins/builtin/trace-bonds/history.ts +155 -0
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- package/src/plugins/installer.ts +16 -3
- package/src/plugins/plugin-names.ts +11 -2
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/cloudflare/http-proxy.ts +67 -8
- package/src/renderers/cloudflare/proxy-session.ts +1 -1
- package/src/renderers/cloudflare/worker.ts +29 -2
- package/src/renderers/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- package/src/renderers/electrobun/bun/index.ts +19 -13
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +4 -4
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +1 -1
- package/src/sources/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financials.ts +18 -4
- package/src/types/data-provider.ts +14 -0
- package/src/types/financials.ts +15 -3
- package/src/types/headless.ts +2 -0
- package/src/utils/double-escape-close.ts +38 -16
- package/src/utils/format.ts +23 -3
- package/src/utils/price-earnings.ts +18 -0
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
|
@@ -11,20 +11,29 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const PLUGIN_NAME_PREFIXES = ["gloom-", "gloomberb-"] as const;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* A plugin package name is one folder name: a prefix, then letters, digits,
|
|
16
|
+
* dots, dashes and underscores. A name read from a plugin's manifest is
|
|
17
|
+
* joined to the plugins folder, so a slash or a backslash would reach past it.
|
|
18
|
+
*/
|
|
19
|
+
const PLUGIN_PACKAGE_NAME = /^(?:gloom|gloomberb)-[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
20
|
+
|
|
14
21
|
/** True for a name that belongs to a plugin package under either product name. */
|
|
15
22
|
export function isPluginPackageName(name: string): boolean {
|
|
16
|
-
return
|
|
23
|
+
return PLUGIN_PACKAGE_NAME.test(name);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
/**
|
|
20
27
|
* The directory names a plugin could be installed under, the given name first.
|
|
21
28
|
*
|
|
22
29
|
* A name with neither prefix is returned alone, so this is safe to call on any
|
|
23
|
-
* dependency name.
|
|
30
|
+
* dependency name. A name with a prefix that is not a plugin package name has
|
|
31
|
+
* no folder to look in.
|
|
24
32
|
*/
|
|
25
33
|
export function pluginDirectoryNames(name: string): string[] {
|
|
26
34
|
for (const prefix of PLUGIN_NAME_PREFIXES) {
|
|
27
35
|
if (!name.startsWith(prefix)) continue;
|
|
36
|
+
if (!isPluginPackageName(name)) return [];
|
|
28
37
|
const other = PLUGIN_NAME_PREFIXES.find((candidate) => candidate !== prefix);
|
|
29
38
|
return [name, `${other}${name.slice(prefix.length)}`];
|
|
30
39
|
}
|
package/src/remote/controller.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
customViewInstanceSettings,
|
|
18
18
|
parseViewSpecOr,
|
|
19
19
|
trialLoadViewSource,
|
|
20
|
+
UnknownViewKeysError,
|
|
20
21
|
type ViewSpec,
|
|
21
22
|
} from "../plugins/builtin/custom-view";
|
|
22
23
|
import { findPaneInstance, getPlacedPaneInstanceIds, type PaneInstanceConfig, resolvePaneInstance } from "../types/config";
|
|
@@ -409,13 +410,18 @@ export function createAppRemoteController({
|
|
|
409
410
|
/**
|
|
410
411
|
* A view's source loads once before the view is kept, so a function that
|
|
411
412
|
* does not exist or cannot read answers with its own error instead of
|
|
412
|
-
* leaving a pane that never fills
|
|
413
|
+
* leaving a pane that never fills, and a column, filter or sort on a key its
|
|
414
|
+
* rows never carry is answered with the keys they do carry. What the load
|
|
415
|
+
* noted comes back as warnings.
|
|
413
416
|
*/
|
|
414
417
|
const checkViewSource = async (spec: ViewSpec, action: "create" | "update", signal?: AbortSignal): Promise<string[]> => {
|
|
415
418
|
try {
|
|
416
419
|
return await trialLoadViewSource(spec, getState().config, { registry: pluginRegistry, signal });
|
|
417
420
|
} catch (error) {
|
|
418
421
|
const reason = error instanceof Error ? error.message : String(error);
|
|
422
|
+
if (error instanceof UnknownViewKeysError) {
|
|
423
|
+
throw new Error(`${action === "create" ? "No view was created" : "The view was left as it was"}. ${reason}`);
|
|
424
|
+
}
|
|
419
425
|
throw new Error(`The view's source did not load, so ${action === "create" ? "no view was created" : "the view was left as it was"}. ${reason}`);
|
|
420
426
|
}
|
|
421
427
|
};
|
|
@@ -497,7 +503,8 @@ export function createAppRemoteController({
|
|
|
497
503
|
const name = optionalString(input, "name");
|
|
498
504
|
if (name) layout = updatePaneInstance(layout, instanceId, (entry: PaneInstanceConfig) => ({ ...entry, title: name }));
|
|
499
505
|
pluginRegistry.updateLayout(layout);
|
|
500
|
-
|
|
506
|
+
const warnings = [...parsed.result.warnings.map((entry) => entry.message), ...loadWarnings];
|
|
507
|
+
return getAfterMutationSummary({ affectedPaneIds: [instanceId], ...(warnings.length ? { warnings } : {}) });
|
|
501
508
|
}
|
|
502
509
|
case "pane.setState":
|
|
503
510
|
dispatch({
|
package/src/remote/schema.ts
CHANGED
|
@@ -169,7 +169,8 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
|
|
|
169
169
|
+ "spec = { source: { pane: <function code>, argument?: <one string>, options?: { <flag>: <value> } }, projection: { columns?: [{ key, label?, transform? }], filters?: [{ key, op, value }], sort?: { by, direction }, limit? }, presentation?: { title?, symbolKey? } }. "
|
|
170
170
|
+ "pane is a function code (app://pane-templates says what each does), never an invented name; an unknown one is answered with the closest codes and the valid ones. "
|
|
171
171
|
+ "argument is always one string, several tickers separated by spaces: \"CME AAPL\". "
|
|
172
|
-
+ "options sets the function's own flags; a wrong flag or value is answered with the ones it takes."
|
|
172
|
+
+ "options sets the function's own flags; a wrong flag or value is answered with the ones it takes. "
|
|
173
|
+
+ "Column, filter and sort keys are keys the source's rows carry; one they do not is answered with the keys they do, and no pane opens.",
|
|
173
174
|
"{ name?: string, spec: object }",
|
|
174
175
|
"local-write",
|
|
175
176
|
objectSchema({ name: stringSchema, spec: openObjectSchema }, ["spec"]),
|
|
@@ -25,13 +25,60 @@ import { fetchCheckingRedirects, readBytesWithin, type ProxyUpstreamResult } fro
|
|
|
25
25
|
import type { ProxySessionGate } from "./proxy-session";
|
|
26
26
|
|
|
27
27
|
const PROXY_METHODS = new Set(["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"]);
|
|
28
|
+
|
|
29
|
+
/** Requests a caller without a confirmed session may send to one host. */
|
|
30
|
+
export interface SignedOutRoute {
|
|
31
|
+
methods: readonly ("GET" | "HEAD" | "POST")[];
|
|
32
|
+
/** A path and anything under it; one ending in a slash covers only what is under it. */
|
|
33
|
+
path: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const READ = ["GET", "HEAD"] as const;
|
|
37
|
+
|
|
28
38
|
/**
|
|
29
|
-
* What a caller without a confirmed session may send
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
39
|
+
* What a caller without a confirmed session may send, host by host: the
|
|
40
|
+
* reads the plugins that work signed out make, and nothing else. The Origin
|
|
41
|
+
* check is no barrier to a script, so anonymous use stays a read-only proxy
|
|
42
|
+
* to those endpoints (a POST carries a search, as FINRA's tape and Pascal's
|
|
43
|
+
* market search do), never to the rest of an exchange's API. Every proxied
|
|
44
|
+
* host is listed, with no routes when it needs a sign-in; a test holds the
|
|
45
|
+
* two lists together.
|
|
33
46
|
*/
|
|
34
|
-
const
|
|
47
|
+
export const SIGNED_OUT_ROUTES: Readonly<Record<string, readonly SignedOutRoute[]>> = {
|
|
48
|
+
"api.crypto.com": [{ methods: READ, path: "/dcm/v1/public/" }],
|
|
49
|
+
"api.elections.kalshi.com": [{ methods: READ, path: "/trade-api/v2/" }],
|
|
50
|
+
"api.fda.gov": [{ methods: READ, path: "/" }],
|
|
51
|
+
"api.gemini.com": [{ methods: READ, path: "/v1/prediction-markets/" }],
|
|
52
|
+
"api.limitless.exchange": [{ methods: READ, path: "/markets/" }],
|
|
53
|
+
"api.votehub.com": [{ methods: READ, path: "/polls" }],
|
|
54
|
+
"clinicaltrials.gov": [{ methods: READ, path: "/api/v2/" }],
|
|
55
|
+
"data.pascal.trade": [
|
|
56
|
+
{ methods: READ, path: "/api/v1/markets" },
|
|
57
|
+
{ methods: ["POST"], path: "/api/v1/markets/text-search" },
|
|
58
|
+
],
|
|
59
|
+
"efts.sec.gov": [{ methods: READ, path: "/LATEST/search-index" }],
|
|
60
|
+
"forms13f.com": [{ methods: READ, path: "/api/v1/" }],
|
|
61
|
+
"gateway.polymarket.us": [{ methods: READ, path: "/v1/markets" }],
|
|
62
|
+
"markets.newyorkfed.org": [{ methods: READ, path: "/api/" }],
|
|
63
|
+
"nasdaqtrader.com": [{ methods: READ, path: "/rss.aspx" }],
|
|
64
|
+
"production.dataviz.cnn.io": [{ methods: READ, path: "/index/fearandgreed/" }],
|
|
65
|
+
"services-dynarep.ddwa.finra.org": [{ methods: ["POST"], path: "/public/reporting/v2/data/group/" }],
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** Whether a caller without a confirmed session may send `method` to `url`. */
|
|
69
|
+
export function signedOutRouteAllows(
|
|
70
|
+
url: URL,
|
|
71
|
+
method: string,
|
|
72
|
+
routes: Readonly<Record<string, readonly SignedOutRoute[]>> = SIGNED_OUT_ROUTES,
|
|
73
|
+
): boolean {
|
|
74
|
+
const host = url.hostname.toLowerCase();
|
|
75
|
+
const entry = Object.entries(routes).find(([allowed]) => host === allowed || host.endsWith(`.${allowed}`));
|
|
76
|
+
return !!entry?.[1].some((route) => (route.methods as readonly string[]).includes(method) && (
|
|
77
|
+
route.path.endsWith("/")
|
|
78
|
+
? url.pathname.startsWith(route.path)
|
|
79
|
+
: url.pathname === route.path || url.pathname.startsWith(`${route.path}/`)
|
|
80
|
+
));
|
|
81
|
+
}
|
|
35
82
|
const MAX_BODY_BYTES = 5 * 1024 * 1024;
|
|
36
83
|
/** Plugin request bodies are small JSON; anything near this is not one. */
|
|
37
84
|
const MAX_REQUEST_BYTES = 1024 * 1024;
|
|
@@ -90,6 +137,13 @@ function upstreamFailure(error: unknown): Response {
|
|
|
90
137
|
export interface HttpProxyOptions {
|
|
91
138
|
/** Rate limits the caller, by user when signed in. One per isolate, so its cache is shared. */
|
|
92
139
|
sessions: ProxySessionGate;
|
|
140
|
+
/**
|
|
141
|
+
* The limit on signed-out calls across isolates (Cloudflare's rate limiting
|
|
142
|
+
* binding): false once the caller's address, or signed-out callers as a
|
|
143
|
+
* whole, have had their share. Absent where there is none, as in tests.
|
|
144
|
+
*/
|
|
145
|
+
signedOutLimit?: (request: Request) => Promise<boolean>;
|
|
146
|
+
signedOutRoutes?: Readonly<Record<string, readonly SignedOutRoute[]>>;
|
|
93
147
|
/** Reaches the Gloomberb API for that check. */
|
|
94
148
|
fetchApi: (request: Request) => Promise<Response>;
|
|
95
149
|
/** Reaches the plugin's target. */
|
|
@@ -103,7 +157,7 @@ export interface HttpProxyOptions {
|
|
|
103
157
|
* to a third party, which is the opposite of what this exists to do.
|
|
104
158
|
*/
|
|
105
159
|
export async function handleHttpProxy(request: Request, options: HttpProxyOptions): Promise<Response> {
|
|
106
|
-
const { sessions, fetchApi, fetchUpstream = fetch, hosts = PROXY_ALLOWED_HOSTS } = options;
|
|
160
|
+
const { sessions, fetchApi, fetchUpstream = fetch, hosts = PROXY_ALLOWED_HOSTS, signedOutRoutes = SIGNED_OUT_ROUTES } = options;
|
|
107
161
|
if (request.method !== "POST") {
|
|
108
162
|
return proxyError("Method not allowed", 405);
|
|
109
163
|
}
|
|
@@ -142,8 +196,13 @@ export async function handleHttpProxy(request: Request, options: HttpProxyOption
|
|
|
142
196
|
if (!PROXY_METHODS.has(init.method)) {
|
|
143
197
|
return proxyError("Method not allowed", 405);
|
|
144
198
|
}
|
|
145
|
-
if (!admission.signedIn
|
|
146
|
-
|
|
199
|
+
if (!admission.signedIn) {
|
|
200
|
+
if (!signedOutRouteAllows(target.url, init.method, signedOutRoutes)) {
|
|
201
|
+
return proxyError("Sign in to Gloom to send this request.", 401);
|
|
202
|
+
}
|
|
203
|
+
if (options.signedOutLimit && !(await options.signedOutLimit(request).catch(() => true))) {
|
|
204
|
+
return proxyError("Too many requests right now. Sign in to Gloom, or try again in a minute.", 429, { "retry-after": "60" });
|
|
205
|
+
}
|
|
147
206
|
}
|
|
148
207
|
|
|
149
208
|
const signal = AbortSignal.timeout(Math.min(init.timeoutMs ?? DEFAULT_TIMEOUT_MS, MAX_TIMEOUT_MS));
|
|
@@ -106,7 +106,7 @@ export interface ProxySessionGateOptions {
|
|
|
106
106
|
* is counted by its /64, the block one subscriber is usually handed, so
|
|
107
107
|
* rotating through it does not open fresh windows.
|
|
108
108
|
*/
|
|
109
|
-
function anonymousRateKey(request: Request): string {
|
|
109
|
+
export function anonymousRateKey(request: Request): string {
|
|
110
110
|
const ip = request.headers.get("cf-connecting-ip")?.trim().toLowerCase() ?? "";
|
|
111
111
|
if (!ip.includes(":")) return `ip:${ip || "unknown"}`;
|
|
112
112
|
const [head = "", tail] = ip.split("::", 2);
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import { handleHttpProxy } from "./http-proxy";
|
|
2
|
-
import { createProxySessionGate } from "./proxy-session";
|
|
2
|
+
import { anonymousRateKey, createProxySessionGate } from "./proxy-session";
|
|
3
3
|
import { HTTP_PROXY_PATH, WEB_DIRECT_HOSTS } from "../../utils/plugin-proxy-hosts";
|
|
4
4
|
|
|
5
5
|
interface StaticAssetsBinding {
|
|
6
6
|
fetch(request: Request): Promise<Response>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/** Cloudflare's rate limiting binding: counts per key, per location, across isolates. */
|
|
10
|
+
interface RateLimitBinding {
|
|
11
|
+
limit(options: { key: string }): Promise<{ success: boolean }>;
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
export interface WorkerEnv {
|
|
10
15
|
ASSETS: StaticAssetsBinding;
|
|
16
|
+
/** Signed-out plugin proxy calls per address (wrangler.jsonc `ratelimits`). */
|
|
17
|
+
SIGNED_OUT_PROXY_PER_ADDRESS?: RateLimitBinding;
|
|
18
|
+
/** Signed-out plugin proxy calls from everyone together. */
|
|
19
|
+
SIGNED_OUT_PROXY_TOTAL?: RateLimitBinding;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The isolate's own window can be dodged by landing on many isolates, so a
|
|
24
|
+
* signed-out call also counts against Cloudflare's limits per address and
|
|
25
|
+
* for every signed-out caller together. Either one spent refuses it.
|
|
26
|
+
*/
|
|
27
|
+
export function signedOutProxyLimit(env: WorkerEnv): ((request: Request) => Promise<boolean>) | undefined {
|
|
28
|
+
const { SIGNED_OUT_PROXY_PER_ADDRESS: perAddress, SIGNED_OUT_PROXY_TOTAL: total } = env;
|
|
29
|
+
if (!perAddress && !total) return undefined;
|
|
30
|
+
return async (request) => {
|
|
31
|
+
if (perAddress && !(await perAddress.limit({ key: anonymousRateKey(request) })).success) return false;
|
|
32
|
+
return !total || (await total.limit({ key: "signed-out" })).success;
|
|
33
|
+
};
|
|
11
34
|
}
|
|
12
35
|
|
|
13
36
|
const SHARE_PATH = /^\/s\/[a-f0-9]{32}\/?$/;
|
|
@@ -129,7 +152,11 @@ export async function handleRequest(request: Request, env: WorkerEnv, fetchApi:
|
|
|
129
152
|
if (API_PATH.test(url.pathname)) return proxyApi(request, fetchApi);
|
|
130
153
|
// Before the GET/HEAD gate below, since plugin requests arrive as POST.
|
|
131
154
|
if (url.pathname === HTTP_PROXY_PATH) {
|
|
132
|
-
return withSecurityHeaders(await handleHttpProxy(request, {
|
|
155
|
+
return withSecurityHeaders(await handleHttpProxy(request, {
|
|
156
|
+
sessions: proxySessions,
|
|
157
|
+
fetchApi,
|
|
158
|
+
signedOutLimit: signedOutProxyLimit(env),
|
|
159
|
+
}));
|
|
133
160
|
}
|
|
134
161
|
|
|
135
162
|
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
@@ -225,7 +225,6 @@ export function WebIconButton({
|
|
|
225
225
|
disabled = false,
|
|
226
226
|
size = 12,
|
|
227
227
|
stopPropagation = true,
|
|
228
|
-
text,
|
|
229
228
|
}: IconButtonProps) {
|
|
230
229
|
return (
|
|
231
230
|
<button
|
|
@@ -262,7 +261,6 @@ export function WebIconButton({
|
|
|
262
261
|
}}
|
|
263
262
|
>
|
|
264
263
|
<WebIcon name={icon} size={size} />
|
|
265
|
-
{text ? <span className="gloom-icon-button-text">{text}</span> : null}
|
|
266
264
|
</button>
|
|
267
265
|
);
|
|
268
266
|
}
|
|
@@ -1533,9 +1533,6 @@ html[data-gloom-screenshot="true"] [data-gloom-role="chart-watermark"] {
|
|
|
1533
1533
|
.gloom-icon-button:disabled, [data-gloom-role="pane-footer-icon"] { cursor: default; }
|
|
1534
1534
|
.gloom-icon-button:not(:disabled):hover { background: var(--gloom-hover-fill); color: var(--gloom-text-bright); }
|
|
1535
1535
|
.gloom-icon-button[aria-pressed="true"] { color: var(--gloom-warning); }
|
|
1536
|
-
/* A status's few characters after its icon (a delay's 15m): read without hovering, in the muted tone of the meta text around it. */
|
|
1537
|
-
.gloom-icon-button-text, [data-gloom-role="pane-footer-icon-text"] { margin-left: var(--gloom-space-xs); color: var(--gloom-text-muted); }
|
|
1538
|
-
.gloom-icon-button:not(:disabled):hover .gloom-icon-button-text { color: inherit; }
|
|
1539
1536
|
.gloom-qb-view button:disabled { color: var(--gloom-text-muted); opacity: 0.55; cursor: default; }
|
|
1540
1537
|
[data-gloom-role="field-grid-value"] button,
|
|
1541
1538
|
[data-gloom-role="field-grid-value"] button > span { justify-content: flex-end !important; text-align: right; padding-inline: 0 !important; }
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { lstat, mkdir } from "fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "path";
|
|
3
|
+
import { logFailure } from "../../../../utils/log-failure";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Electrobun 2 keeps an install's records (its uninstaller and the manifest
|
|
7
|
+
* of what the app put where) in the app's folder under Application Support,
|
|
8
|
+
* and its launcher writes them at every start until they exist. It never
|
|
9
|
+
* makes that folder: on a Mac the app is copied out of the disk image or by
|
|
10
|
+
* Homebrew, and the folder only appears once an update downloads into it.
|
|
11
|
+
* Until then every start logged "Bootstrap install failed ... FileNotFound".
|
|
12
|
+
* So the app makes the folder and has its bundled uninstaller write the
|
|
13
|
+
* records right away, as the launcher would have.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export interface InstallRecordsContext {
|
|
17
|
+
platform: string;
|
|
18
|
+
/** The running Bun: `<bundle>/Contents/MacOS/bun`. */
|
|
19
|
+
execPath: string;
|
|
20
|
+
/** Electrobun's folder for this install, `~/Library/Application Support/<identifier>/<channel>`. */
|
|
21
|
+
channelRoot: () => Promise<string>;
|
|
22
|
+
/** The build's channel; a dev build has no records. */
|
|
23
|
+
channel: () => Promise<string>;
|
|
24
|
+
run?: (command: string[]) => Promise<number>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type InstallRecordsResult = "none" | "written" | "failed";
|
|
28
|
+
|
|
29
|
+
const MANIFEST = ".electrobun-uninstall.json";
|
|
30
|
+
const MANAGER = "uninstall";
|
|
31
|
+
|
|
32
|
+
async function isFile(path: string): Promise<boolean> {
|
|
33
|
+
return lstat(path).then((stat) => stat.isFile(), () => false);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function runQuietly(command: string[]): Promise<number> {
|
|
37
|
+
const child = Bun.spawn(command, { stdio: ["ignore", "ignore", "pipe"] });
|
|
38
|
+
const [code, stderr] = await Promise.all([child.exited, new Response(child.stderr).text()]);
|
|
39
|
+
if (code !== 0 && stderr.trim()) console.error(`[desktop] ${stderr.trim()}`);
|
|
40
|
+
return code;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function ensureInstallRecords(context: InstallRecordsContext): Promise<InstallRecordsResult> {
|
|
44
|
+
if (context.platform !== "darwin") return "none";
|
|
45
|
+
try {
|
|
46
|
+
if ((await context.channel()) === "dev") return "none";
|
|
47
|
+
const root = await context.channelRoot();
|
|
48
|
+
if (await isFile(join(root, MANIFEST)) && await isFile(join(root, MANAGER))) return "none";
|
|
49
|
+
const bundledManager = resolve(dirname(context.execPath), "..", "Resources", MANAGER);
|
|
50
|
+
if (!await isFile(bundledManager)) return "none";
|
|
51
|
+
await mkdir(root, { recursive: true });
|
|
52
|
+
const code = await (context.run ?? runQuietly)([bundledManager, "--bootstrap-install", root, "--quiet"]);
|
|
53
|
+
if (code !== 0) throw new Error(`the uninstaller exited with ${code}`);
|
|
54
|
+
return "written";
|
|
55
|
+
} catch (error) {
|
|
56
|
+
logFailure("desktop-install-records", "Could not write the app's install records")(error);
|
|
57
|
+
return "failed";
|
|
58
|
+
}
|
|
59
|
+
}
|