UNPKG

@casual-simulation/aux-common

Version:
144 lines 5.32 kB
import { z } from 'zod'; export const BIOS_OPTION_SCHEMA = z.enum([ 'enter join code', 'join inst', 'temp', 'temp local', 'static inst', 'local inst', 'local', 'public inst', 'public', 'free inst', 'free', 'private inst', 'studio inst', 'studio', 'locked', 'sign in', 'sign up', 'sign out', 'delete inst', ]); export const WEB_CONFIG_SCHEMA = z.object({ causalRepoConnectionProtocol: z .enum(['websocket', 'apiary-aws']) .prefault('websocket'), causalRepoConnectionUrl: z.string().min(1).max(512).optional(), collaborativeRepoLocalPersistence: z.boolean().prefault(false), staticRepoLocalPersistence: z.boolean().prefault(true), sharedPartitionsVersion: z.enum(['v2']).prefault('v2'), vmOrigin: z.string().min(1).max(128).nullable().optional(), disableVM: z.boolean().nullable().optional(), authOrigin: z.string().min(1).max(128).nullable().optional(), recordsOrigin: z.string().min(1).max(128).nullable().optional(), disableCollaboration: z.boolean().nullable().optional(), ab1BootstrapURL: z.string().min(1).max(512).nullable().optional(), serverInjectBootstrapper: z.boolean().nullable().optional(), arcGisApiKey: z.string().min(1).max(128).nullable().optional(), jitsiAppName: z.string().min(1).max(128).nullable().optional(), what3WordsApiKey: z.string().min(1).max(128).nullable().optional(), playerMode: z.enum(['player', 'builder']).nullable().optional(), requirePrivoLogin: z.boolean().prefault(false), allowedBiosOptions: z.array(BIOS_OPTION_SCHEMA).nullable().optional(), defaultBiosOption: BIOS_OPTION_SCHEMA.nullable().optional(), automaticBiosOption: BIOS_OPTION_SCHEMA.nullable().optional(), automaticBiosOptionInst: z .string() .nonempty() .nullable() .optional() .describe('The instance ID to use when executing the automatic BIOS option. Should be formatted as `{recordName/{instName}`. For local/public insts, recordName can be omitted (e.g. `/{instName}`).'), enableDom: z.boolean().prefault(false), debug: z.boolean().prefault(false), enableSmsAuthentication: z.boolean().nullable().optional(), logoUrl: z .string() .min(1) .max(512) .nullable() .optional() .describe('The URL of the logo to display in the loading screen.'), logoBackgroundColor: z .string() .min(1) .max(32) .nullable() .optional() .describe('The background color of the logo to display in the loading screen. This is used to set the background color of the splash screen.'), logoTitle: z .string() .min(1) .max(128) .nullable() .optional() .describe('The title text that accompanies the logo in the loading screen.'), pageTitle: z .string() .min(1) .max(128) .nullable() .optional() .describe('The title that should be used for the player page.'), pageDescription: z .string() .min(1) .max(512) .nullable() .optional() .describe('The description that should be used for the player page.'), icons: z .object({ favicon: z .string() .nonempty() .nullable() .optional() .describe('The favicon that should be served for the web client. If not specified, a default favicon will be used. Should be 48x48 px and utilize transparency.'), appleTouchIcon: z .string() .nonempty() .nullable() .optional() .describe('The apple touch icon that should be used for the web client. If not specified, a default apple touch icon will be used. Should be 180x180 px and not use transparency (background should be a solid color).'), }) .nullable() .optional() .describe('The set of icons that should be used for the web client.'), supportUrl: z.string().min(1).nullable().optional(), postHogApiKey: z .string() .min(1) .nullable() .optional() .describe('The API key that should be used for PostHog analytics. If not specified, then PostHog will not be initialized.'), postHogApiHost: z .string() .min(1) .nullable() .optional() .describe('The HTTP host that should be used for PostHog analytics. If not specified, then the default PostHog cloud host will be used.'), enableSimpleAnalytics: z .boolean() .nullable() .optional() .describe('Whether to enable simple analytics. Defaults to false.'), noAutomaticGridPortal: z .boolean() .nullable() .optional() .describe('Whether to disable loading the grid portal by default. Defaults to false.'), }); export function parseWebConfig(config, defaultConfig) { if (config) { const result = WEB_CONFIG_SCHEMA.safeParse(config); if (result.success) { return result.data; } else { console.error('[WebConfig] Invalid web config', result); } } return defaultConfig; } //# sourceMappingURL=WebConfig.js.map