Skip to content

Commit 301fe26

Browse files
committed
Upgrade dependencies, including Electron 37.4.0.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 92a2b4e commit 301fe26

File tree

8 files changed

+578
-595
lines changed

8 files changed

+578
-595
lines changed

app/common/config-schemata.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const configSchemata = {
3737
useProxy: z.boolean(),
3838
useSystemProxy: z.boolean(),
3939
};
40+
export type ConfigSchemata = typeof configSchemata;
4041

4142
export const enterpriseConfigSchemata = {
4243
...configSchemata,

app/common/config-util.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import {DataError} from "node-json-db/dist/lib/Errors.js";
77
import type {z} from "zod";
88
import {app, dialog} from "zulip:remote";
99

10-
import {configSchemata} from "./config-schemata.ts";
10+
import {type ConfigSchemata, configSchemata} from "./config-schemata.ts";
1111
import * as EnterpriseUtil from "./enterprise-util.ts";
1212
import Logger from "./logger-util.ts";
1313

1414
export type Config = {
15-
[Key in keyof typeof configSchemata]: z.output<(typeof configSchemata)[Key]>;
15+
[Key in keyof ConfigSchemata]: z.output<ConfigSchemata[Key]>;
1616
};
1717

1818
const logger = new Logger({
@@ -26,7 +26,7 @@ reloadDatabase();
2626
export function getConfigItem<Key extends keyof Config>(
2727
key: Key,
2828
defaultValue: Config[Key],
29-
): z.output<(typeof configSchemata)[Key]> {
29+
): z.output<ConfigSchemata[Key]> {
3030
try {
3131
database.reload();
3232
} catch (error: unknown) {
@@ -35,7 +35,13 @@ export function getConfigItem<Key extends keyof Config>(
3535
}
3636

3737
try {
38-
return configSchemata[key].parse(database.getObject<unknown>(`/${key}`));
38+
const typedSchemata: {
39+
[Key in keyof Config]: z.ZodType<
40+
z.output<ConfigSchemata[Key]>,
41+
z.input<ConfigSchemata[Key]>
42+
>;
43+
} = configSchemata; // https://github.com/colinhacks/zod/issues/5154
44+
return typedSchemata[key].parse(database.getObject<unknown>(`/${key}`));
3945
} catch (error: unknown) {
4046
if (!(error instanceof DataError)) throw error;
4147
setConfigItem(key, defaultValue);

app/main/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const _getServerSettings = async (
5959
} = z
6060
.object({
6161
realm_name: z.string(),
62-
realm_uri: z.string().url(),
62+
realm_uri: z.url(),
6363
realm_icon: z.string(),
6464
zulip_version: z.string().default("unknown"),
6565
zulip_feature_level: z.number().default(0),

app/renderer/js/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import "./zod-config.ts"; // eslint-disable-line import-x/no-unassigned-import
2+
13
import {clipboard} from "electron/common";
24
import path from "node:path";
35
import process from "node:process";

app/renderer/js/utils/domain-util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const logger = new Logger({
2424
export const defaultIconSentinel = "../renderer/img/icon.png";
2525

2626
const serverConfigSchema = z.object({
27-
url: z.string().url(),
27+
url: z.url(),
2828
alias: z.string(),
2929
icon: z.string(),
3030
zulipVersion: z.string().default("unknown"),

app/renderer/js/zod-config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import * as z from "zod";
2+
3+
// In an Electron preload script, Content-Security-Policy only takes effect
4+
// after the page has loaded, which breaks Zod's detection of whether eval is
5+
// allowed.
6+
z.config({jitless: true});

0 commit comments

Comments
 (0)