Skip to content

Commit

Permalink
update deps and cleanup unused halo code (#11989)
Browse files Browse the repository at this point in the history
Fixes #11702

Updated dependencies, version-locked ones that caused trouble during update. There are many formatting changes due to prettier version bump.
  • Loading branch information
Frizi authored Jan 9, 2025
1 parent 0970a2a commit a617492
Show file tree
Hide file tree
Showing 131 changed files with 4,814 additions and 5,894 deletions.
20 changes: 14 additions & 6 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
overrides:
- files:
- "*.[j|t]s"
- "*.[j|t]sx"
- "*.m[j|t]s"
- "*.c[j|t]s"
- "*.js"
- "*.ts"
- "*.jsx"
- "*.tsx"
- "*.mjs"
- "*.cjs"
- "*.vue"
- "*.json"
- "*.html"
options:
plugins: ["prettier-plugin-organize-imports"]
plugins:
- "prettier-plugin-organize-imports"
- "prettier-plugin-tailwindcss"
semi: false
tabWidth: 2
singleQuote: true
printWidth: 100
trailingComma: "all"
arrowParens: "avoid"
arrowParens: "always"
organizeImportsSkipDestructiveCodeActions: true
experimentalTernaries: true
tailwindConfig: ./app/gui/tailwind.config.js

- files: "*.md"
options:
Expand Down
6 changes: 3 additions & 3 deletions app/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"dependencies": {
"@tanstack/query-persist-client-core": "5.59.20",
"@tanstack/vue-query": "5.59.20",
"lib0": "^0.2.85",
"lib0": "^0.2.99",
"react": "^18.3.1",
"vitest": "^1.3.1",
"vue": "^3.5.2"
"vitest": "3.0.0-beta.3",
"vue": "^3.5.13"
}
}
4 changes: 2 additions & 2 deletions app/common/src/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function readEnvironmentFromFile() {
const file = await fs.readFile(filePath, { encoding: 'utf-8' })
console.info(`Reading environment from file: ${filePath}`)
/** @type {readonly (readonly [string, string])[]} */
let entries = file.split('\n').flatMap(line => {
let entries = file.split('\n').flatMap((line) => {
if (/^\s*$|^.s*#/.test(line)) {
return []
} else {
Expand All @@ -43,7 +43,7 @@ export async function readEnvironmentFromFile() {
}
})
if (isProduction) {
entries = entries.filter(kv => {
entries = entries.filter((kv) => {
const [k, v] = kv
return v !== 'undefined' && process.env[k] == null
})
Expand Down
4 changes: 2 additions & 2 deletions app/common/src/backendQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ type BackendQueryNormalizers = {
}

const NORMALIZE_METHOD_QUERY: BackendQueryNormalizers = {
listDirectory: query => [query.parentId, object.omit(query, 'parentId')],
getFileDetails: fileId => [fileId],
listDirectory: (query) => [query.parentId, object.omit(query, 'parentId')],
getFileDetails: (fileId) => [fileId],
}

/** Creates a partial query key representing the given method and arguments. */
Expand Down
10 changes: 5 additions & 5 deletions app/common/src/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function createQueryClient<TStorageValue = string>(
// fallback to the local cache only if the user is offline
maxAge: DEFAULT_QUERY_PERSIST_TIME_MS,
buster: DEFAULT_BUSTER,
filters: { predicate: query => query.meta?.persist !== false },
filters: { predicate: (query) => query.meta?.persist !== false },
prefix: 'enso:query-persist:',
...(persisterStorage.serialize != null ? { serialize: persisterStorage.serialize } : {}),
...(persisterStorage.deserialize != null ?
Expand All @@ -109,21 +109,21 @@ export function createQueryClient<TStorageValue = string>(
}
})()
const invalidatesToIgnore = invalidates.filter(
queryKey => !invalidatesToAwait.includes(queryKey),
(queryKey) => !invalidatesToAwait.includes(queryKey),
)

for (const queryKey of invalidatesToIgnore) {
void queryClient.invalidateQueries({
predicate: query => queryCore.matchQuery({ queryKey }, query),
predicate: (query) => queryCore.matchQuery({ queryKey }, query),
refetchType,
})
}

if (invalidatesToAwait.length > 0) {
return Promise.all(
invalidatesToAwait.map(queryKey =>
invalidatesToAwait.map((queryKey) =>
queryClient.invalidateQueries({
predicate: query => queryCore.matchQuery({ queryKey }, query),
predicate: (query) => queryCore.matchQuery({ queryKey }, query),
refetchType,
}),
),
Expand Down
10 changes: 5 additions & 5 deletions app/common/src/services/Backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,10 @@ export function lChColorToCssColor(color: LChColor): string {
}

export const COLOR_STRING_TO_COLOR = new Map(
COLORS.map(color => [lChColorToCssColor(color), color]),
COLORS.map((color) => [lChColorToCssColor(color), color]),
)

export const INITIAL_COLOR_COUNTS = new Map(COLORS.map(color => [lChColorToCssColor(color), 0]))
export const INITIAL_COLOR_COUNTS = new Map(COLORS.map((color) => [lChColorToCssColor(color), 0]))

/** The color that is used for the least labels. Ties are broken by order. */
export function findLeastUsedColor(labels: Iterable<Label>) {
Expand All @@ -688,8 +688,8 @@ export function findLeastUsedColor(labels: Iterable<Label>) {
colorCounts.set(colorString, (colorCounts.get(colorString) ?? 0) + 1)
}
const min = Math.min(...colorCounts.values())
const [minColor] = [...colorCounts.entries()].find(kv => kv[1] === min) ?? []
return minColor == null ? COLORS[0] : COLOR_STRING_TO_COLOR.get(minColor) ?? COLORS[0]
const [minColor] = [...colorCounts.entries()].find((kv) => kv[1] === min) ?? []
return minColor == null ? COLORS[0] : (COLOR_STRING_TO_COLOR.get(minColor) ?? COLORS[0])
}

// =================
Expand Down Expand Up @@ -1546,7 +1546,7 @@ export function isNewTitleUnique(
) {
siblings ??= []

return siblings.every(sibling => {
return siblings.every((sibling) => {
if (sibling.id === item.id) {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion app/common/src/text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export type GetText = <K extends TextId>(
export function resolveUserLanguage() {
const locale = navigator.language
const language =
unsafeKeys(LANGUAGE_TO_LOCALE).find(language => locale === LANGUAGE_TO_LOCALE[language]) ??
unsafeKeys(LANGUAGE_TO_LOCALE).find((language) => locale === LANGUAGE_TO_LOCALE[language]) ??
Language.english

return language
Expand Down
2 changes: 1 addition & 1 deletion app/common/src/utilities/data/__tests__/iterator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function makeCases(): IteratorCase<unknown>[] {
count: 2,
},
{
iterable: iter.filter([7, 'a', 8, 'b', 9], el => typeof el === 'string'),
iterable: iter.filter([7, 'a', 8, 'b', 9], (el) => typeof el === 'string'),
soleValue: undefined,
first: 'a',
last: 'b',
Expand Down
2 changes: 1 addition & 1 deletion app/common/src/utilities/data/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ export function splicedAfter<T>(array: T[], items: T[], predicate: (value: T) =>
export function transpose<T>(matrix: T[][]): T[][] {
if (matrix.length === 0) return []
if (matrix[0] && matrix[0].length === 0) return [[]]
return matrix[0]!.map((_, colIndex) => matrix.map(row => row[colIndex]!))
return matrix[0]!.map((_, colIndex) => matrix.map((row) => row[colIndex]!))
}
2 changes: 1 addition & 1 deletion app/common/src/utilities/data/iter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function reduce<T, A>(
* it will be consumed.
*/
export function count(it: Iterable<unknown>): number {
return reduce(it, a => a + 1, 0)
return reduce(it, (a) => a + 1, 0)
}

/** An iterable with zero elements. */
Expand Down
4 changes: 2 additions & 2 deletions app/common/src/utilities/data/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function merge<T extends object>(object: T, update: Partial<T>): T {

/** Return a function to update an object with the given partial update. */
export function merger<T extends object>(update: Partial<NoInfer<T>>): (object: T) => T {
return object => merge(object, update)
return (object) => merge(object, update)
}

// ================
Expand Down Expand Up @@ -120,7 +120,7 @@ export function mapEntries<K extends PropertyKey, V, W>(
// @ts-expect-error It is known that the set of keys is the same for the input and the output,
// because the output is dynamically generated based on the input.
return Object.fromEntries(
unsafeEntries(object).map<[K, W]>(kv => {
unsafeEntries(object).map<[K, W]>((kv) => {
const [k, v] = kv
return [k, map(k, v)]
}),
Expand Down
11 changes: 0 additions & 11 deletions app/gui/.prettierrc.json

This file was deleted.

3 changes: 1 addition & 2 deletions app/gui/docs/browser_specific_behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ to be worked around.

### Drag event missing coordinates

Firefox sets `MouseEvent.pageX` and `MouseEvent.pageY` to `0` for `drag`
events.
Firefox sets `MouseEvent.pageX` and `MouseEvent.pageY` to `0` for `drag` events.

#### Fix

Expand Down
34 changes: 21 additions & 13 deletions app/gui/integration-test/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Running tests

Execute all commands from the parent directory.
Note that all options can be used in any combination.
Execute all commands from the parent directory. Note that all options can be
used in any combination.

```sh
# Run tests normally
Expand All @@ -25,25 +25,33 @@ PROD=true pnpm playwright test
// ONLY chain methods from `pageActions`.
// Using methods not in `pageActions` is UNDEFINED BEHAVIOR.
// If it is absolutely necessary though, please remember to `await` the method chain.
test('test name here', ({ page }) => mockAllAndLogin({ page }).goToPage.drive())
test("test name here", ({ page }) =>
mockAllAndLogin({ page }).goToPage.drive());
```

### Perform arbitrary actions (e.g. actions on the API)

```ts
test('test name here', ({ page }) =>
test("test name here", ({ page }) =>
mockAllAndLogin({ page }).do((_page, { api }) => {
api.foo()
api.bar()
expect(api.baz()?.quux).toEqual('bar')
}))
api.foo();
api.bar();
expect(api.baz()?.quux).toEqual("bar");
}));
```

### Writing new classes extending `BaseActions`

- Make sure that every method returns either the class itself (`this`) or `.into(AnotherActionsClass<Context>)`.
- Avoid constructing `new AnotherActionsClass()` - instead prefer `.into(AnotherActionsClass<Context>)` and optionally `.into(ThisClass<Context>)` if required.
- Make sure that every method returns either the class itself (`this`) or
`.into(AnotherActionsClass<Context>)`.
- Avoid constructing `new AnotherActionsClass()` - instead prefer
`.into(AnotherActionsClass<Context>)` and optionally
`.into(ThisClass<Context>)` if required.
- Never construct an `ActionsClass`
- In some rare exceptions, it is fine as long as you `await` the `PageActions` class - for example in `index.ts` there is `await new StartModalActions().close()`.
- Methods for locators are fine, but it is not recommended to expose them as it makes it easy to accidentally - i.e. it is fine as long as they are `private`.
- In general, avoid exposing any method that returns a `Promise` rather than a `PageActions`.
- In some rare exceptions, it is fine as long as you `await` the `PageActions`
class - for example in `index.ts` there is
`await new StartModalActions().close()`.
- Methods for locators are fine, but it is not recommended to expose them as it
makes it easy to accidentally - i.e. it is fine as long as they are `private`.
- In general, avoid exposing any method that returns a `Promise` rather than a
`PageActions`.
14 changes: 11 additions & 3 deletions app/gui/integration-test/project-view/pm-openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@
{
"name": "project/list",
"params": [
{ "name": "numberOfProjects", "schema": { "type": "integer" }, "required": false }
{
"name": "numberOfProjects",
"schema": { "type": "integer" },
"required": false
}
],
"result": {
"name": "listProject",
Expand All @@ -69,9 +73,13 @@
"name": { "type": "string" },
"namespace": { "type": "string" },
"id": { "type": "string" },
"engineVersion": { "anyOf": [{ "type": "string" }, { "type": "null" }] },
"engineVersion": {
"anyOf": [{ "type": "string" }, { "type": "null" }]
},
"created": { "type": "string" },
"lastOpened": { "anyOf": [{ "type": "string" }, { "type": "null" }] }
"lastOpened": {
"anyOf": [{ "type": "string" }, { "type": "null" }]
}
}
}
}
Expand Down
Loading

0 comments on commit a617492

Please sign in to comment.