-
Notifications
You must be signed in to change notification settings - Fork 334
Prune ide-desktop package #14069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Prune ide-desktop package #14069
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
9f05851
Remove ide-desktop/icons generator, commit generated files to the repo.
vitvakatu e8078b3
Remove unused IPC channels
vitvakatu 75fda27
Simplify logging
vitvakatu e2741e3
Remove vibrancy effect support
vitvakatu 6478f78
Cut down unused config parameters
vitvakatu 9c5d4cd
Remove unused performance options
vitvakatu c26dd3a
Remove config.json
vitvakatu 10f6cf3
Get rid of config groups merge functionality
vitvakatu 92212ab
Remove custom help
vitvakatu 12ca79d
Use commander.js for cli parsing
vitvakatu c81cf88
Experimenting with cli config
vitvakatu 839a6e9
Nuke HelpScreen
vitvakatu f180115
Massive refactoring of options stuff using zod-derived schema
vitvakatu 3f17f1d
refactoring with zod
vitvakatu db7d413
refactorings
vitvakatu 50f61fe
Removing unnecessary stuff
vitvakatu aecdb12
Move ide-desktop/client one level up
vitvakatu 6f2c05e
Remove debug logs
vitvakatu 29cce14
Try using .icns icon for linux builds
vitvakatu 5c7927b
Merge develop
vitvakatu 7a21c5d
Keep CLI option description short for readability
vitvakatu a00ff5a
Remove unused dependencies
vitvakatu 90fb0d4
Change log format & remove unused dependencies
vitvakatu e330446
Merge develop
vitvakatu d3ea8f5
Fix CI tests
vitvakatu 8bac889
Use default viewport size in package tests as we removed window.size …
vitvakatu ceea71b
Try fixing windows build
vitvakatu 2e42ea0
Fix
vitvakatu 311b9f9
Reexport fileAssociations constants
vitvakatu b728211
Handle console.info in logger
vitvakatu 518d231
Remove stale ide-desktop package from pnpm-workspace
vitvakatu cf11b57
Rename client → electron-client
vitvakatu db7e247
Deduplicate env.d.ts and globals.d.ts
vitvakatu cf33edf
Fix linter and tests, I guess?
vitvakatu f866114
Run prettier
vitvakatu 0e744df
Do not download eslint cache when CI: clean build label is used
vitvakatu f295643
Try reverting viewport size in tests
vitvakatu cf0a51f
Debugging linux CI crashes
vitvakatu a6b3c9a
Log chromium options
vitvakatu 2b53383
Chrome flags go brrrrrrr
vitvakatu 495b1a9
Enable new project manager
vitvakatu 0f83049
Back out "Enable new project manager"
vitvakatu 6cd8afb
Disable chrome logging
vitvakatu 768e215
remove disable-dev-shm-usage flag
vitvakatu f61d25e
Using only disable-dev-shm-usage
vitvakatu b6502b1
Bring back chrome options from develop, rollback changes for debug
vitvakatu 6682b87
Try removing excess chrome options
vitvakatu 8c05643
Bring back ignore-gpu-blocklist
vitvakatu 06d840b
Add changelog entry
vitvakatu a9246dc
Reenable backgroundThrottling
vitvakatu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| /** @file Shared application options schema and helpers. */ | ||
|
|
||
| import { z } from 'zod' | ||
|
|
||
| const DEFAULT_PROFILING_TIME = 120 | ||
| const DEFAULT_PORT = 8080 | ||
|
|
||
| /** Schema for app-wide configuration options. */ | ||
| export const OptionsSchema = z.object({ | ||
| version: z.boolean().default(false), | ||
| displayWindow: z.boolean().default(true), | ||
| useServer: z.boolean().default(true), | ||
| engineEnabled: z.boolean().default(true), | ||
| useJvm: z.boolean().default(false), | ||
| startup: z | ||
| .object({ | ||
| project: z.string().default(''), | ||
| displayedProjectName: z.string().default(''), | ||
| }) | ||
| .default({}), | ||
| authentication: z | ||
| .object({ | ||
| enabled: z.boolean().default(true), | ||
| email: z.string().default(''), | ||
| }) | ||
| .default({}), | ||
| server: z | ||
| .object({ | ||
| port: z.number().int().default(DEFAULT_PORT), | ||
| }) | ||
| .default({}), | ||
| engine: z | ||
| .object({ | ||
| projectManagerPath: z.string().default(''), | ||
| projectManagerUrl: z.string().default(''), | ||
| ydocUrl: z.string().default(''), | ||
| }) | ||
| .default({}), | ||
| debug: z | ||
| .object({ | ||
| info: z.boolean().default(false), | ||
| verbose: z.boolean().default(false), | ||
| devTools: z.boolean().default(false), | ||
| profile: z.boolean().default(false), | ||
| profileTime: z.number().int().default(DEFAULT_PROFILING_TIME), | ||
| }) | ||
| .default({}), | ||
| }) | ||
|
|
||
| /** Global configuration of Enso Studio, parsed from CLI arguments and passed to web application via URL params. */ | ||
| export type Options = z.infer<typeof OptionsSchema> | ||
|
|
||
| /** Default values for all configuration options. */ | ||
| export function defaultOptions(): Options { | ||
| return OptionsSchema.parse({}) | ||
| } | ||
|
|
||
| /** | ||
| * Dotted keys which should be synced to the web application via URL params. | ||
| * Other options are only used by Electron and not passed to the web application. | ||
| */ | ||
| export const PASS_TO_WEB: ReadonlySet<string> = new Set([ | ||
| 'startup.project', | ||
| 'startup.displayedProjectName', | ||
| 'authentication.enabled', | ||
| 'authentication.email', | ||
| 'engine.projectManagerUrl', | ||
| 'engine.ydocUrl', | ||
| ]) | ||
|
|
||
| /** Possible values for options. */ | ||
| export type OptionValue = string | number | boolean | ||
|
|
||
| const phantomKey = Symbol('flattened') | ||
| type Flat<T> = Record<string, OptionValue> & { readonly [phantomKey]?: T } | ||
|
|
||
| /** Flatten a nested object into a dotted-key record. */ | ||
| export function flattenObject<T extends object>(obj: T, prefix = ''): Flat<T> { | ||
| const out: Flat<T> = {} | ||
| if (obj != null) { | ||
| for (const [k, v] of Object.entries(obj)) { | ||
| const key = prefix ? `${prefix}.${k}` : k | ||
| if (v != null && typeof v === 'object' && !Array.isArray(v)) { | ||
| Object.assign(out, flattenObject(v, key)) | ||
| } else { | ||
| out[key] = v | ||
| } | ||
| } | ||
| } | ||
| return out | ||
| } | ||
|
|
||
| /** Turn a flat dotted-record into a nested object. */ | ||
| export function unflattenObject<T extends object>(flat: Flat<T>): T { | ||
| const out: any = {} | ||
| for (const [k, v] of Object.entries(flat)) { | ||
| const pathSegments = k.split('.') | ||
| let cur = out | ||
| for (const segment of pathSegments.slice(0, -1)) { | ||
| cur[segment] ??= {} | ||
| cur = cur[segment] | ||
| } | ||
| const last = pathSegments[pathSegments.length - 1]! | ||
| cur[last] = v | ||
| } | ||
| return out as T | ||
| } | ||
|
|
||
| /** Build URLSearchParams for non-default pass-to-web options. */ | ||
| export function buildWebAppURLSearchParamsFromArgs(args: Options): URLSearchParams { | ||
| const params = new URLSearchParams() | ||
| const entries = collectWebAppOptionsFromArgs(args) | ||
| Object.entries(entries).forEach(([key, val]) => params.append(key, String(val))) | ||
| return params | ||
| } | ||
|
|
||
| /** Collect non-default values of pass-to-web options from parsed args. */ | ||
| function collectWebAppOptionsFromArgs(options: Options): Record<string, string | number | boolean> { | ||
| const result: Record<string, string | number | boolean> = {} | ||
| const defaults = defaultOptions() | ||
| const flatDefaults = flattenObject(defaults) | ||
| const flatOptions = flattenObject(options) | ||
| for (const key of PASS_TO_WEB) { | ||
| const value = flatOptions[key] | ||
| if (value == null) | ||
| throw new Error(`Option ${key} not found, but needs to be passed to web application`) | ||
| const def = flatDefaults[key] | ||
| if (value != null && JSON.stringify(value) !== JSON.stringify(def)) { | ||
| result[key] = value | ||
| } | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| /** Parse pass-to-web options from URLSearchParams. For missing values, defaults are used. */ | ||
| export function parseWebAppOptionsFromSearchParams(params: URLSearchParams): Options { | ||
| const out = flattenObject(defaultOptions()) | ||
| for (const key of PASS_TO_WEB) { | ||
| const value = params.get(key) | ||
| if (value == null) continue | ||
| const def = out[key] | ||
| switch (typeof def) { | ||
| case 'boolean': { | ||
| const b = coerceBoolean(value) | ||
| if (b != null) { | ||
| out[key] = b | ||
| } else { | ||
| console.warn(`Invalid boolean value for option ${key}: ${value}, using default ${def}.`) | ||
| } | ||
| break | ||
| } | ||
| case 'number': { | ||
| const n = Number(value) | ||
| if (!Number.isNaN(n)) { | ||
| out[key] = n | ||
| } else { | ||
| console.warn(`Invalid number value for option ${key}: ${value}, using default ${def}.`) | ||
| } | ||
| break | ||
| } | ||
| case 'string': { | ||
| out[key] = value | ||
| break | ||
| } | ||
| default: | ||
| throw new Error(`Invalid option type for option ${key}: ${typeof def}.`) | ||
| } | ||
| } | ||
| return unflattenObject<Options>(out) | ||
| } | ||
|
|
||
| /** | ||
| * Coerce a string to a boolean. | ||
| * | ||
| * true, 1, yes, enabled → true | ||
| * false, 0, no, disabled → false | ||
| * anything else → undefined | ||
| */ | ||
| function coerceBoolean(v: string): boolean | undefined { | ||
| switch (v.toLowerCase()) { | ||
| case 'true': | ||
| case '1': | ||
| case 'yes': | ||
| case 'enabled': | ||
| return true | ||
| case 'false': | ||
| case '0': | ||
| case 'no': | ||
| case 'disabled': | ||
| return false | ||
| default: | ||
| return undefined | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.