Skip to content

Commit

Permalink
Merge branch 'develop' into wip/akirathan/11589-builtins-expose-methods
Browse files Browse the repository at this point in the history
# Conflicts:
#	distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso
  • Loading branch information
Akirathan committed Jan 13, 2025
2 parents 0c97057 + 3543bd9 commit 523321c
Show file tree
Hide file tree
Showing 455 changed files with 17,912 additions and 12,853 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ test-results/
test-traces/
playwright-report/
playwright/.cache/

#########
## Git ##
#########

/.mailmap
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
[11902]: https://github.com/enso-org/enso/pull/11902
[11908]: https://github.com/enso-org/enso/pull/11908

#### Enso Standard Library

- [Allow using `/` to access files inside a directory reached through a data
link.][11926]

[11926]: https://github.com/enso-org/enso/pull/11926

#### Enso Language & Runtime

- [Promote broken values instead of ignoring them][11777].
Expand All @@ -24,13 +31,15 @@
- [Native libraries of projects can be added to `polyglot/lib` directory][11874]
- [Redo stack is no longer lost when interacting with text literals][11908].
- Symetric, transitive and reflexive [equality for intersection types][11897]
- [IR definitions are generated by an annotation processor][11770]

[11777]: https://github.com/enso-org/enso/pull/11777
[11600]: https://github.com/enso-org/enso/pull/11600
[11856]: https://github.com/enso-org/enso/pull/11856
[11874]: https://github.com/enso-org/enso/pull/11874
[11908]: https://github.com/enso-org/enso/pull/11908
[11897]: https://github.com/enso-org/enso/pull/11897
[11770]: https://github.com/enso-org/enso/pull/11770

# Enso 2024.5

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
14 changes: 8 additions & 6 deletions app/common/src/backendQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ export type BackendMethods = object.ExtractKeys<Backend, object.MethodOf<Backend

/** For each backend method, an optional function defining how to create a query key from its arguments. */
type BackendQueryNormalizers = {
[Method in BackendMethods]?: (...args: Parameters<Backend[Method]>) => queryCore.QueryKey
[Method in BackendMethods]?: (
...args: Readonly<Parameters<Backend[Method]>>
) => queryCore.QueryKey
}

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. */
function normalizeMethodQuery<Method extends BackendMethods>(
method: Method,
args: Parameters<Backend[Method]>,
args: Readonly<Parameters<Backend[Method]>>,
) {
return NORMALIZE_METHOD_QUERY[method]?.(...args) ?? args
}
Expand All @@ -31,7 +33,7 @@ function normalizeMethodQuery<Method extends BackendMethods>(
export function backendQueryOptions<Method extends BackendMethods>(
backend: Backend | null,
method: Method,
args: Parameters<Backend[Method]>,
args: Readonly<Parameters<Backend[Method]>>,
keyExtra?: queryCore.QueryKey | undefined,
): {
queryKey: queryCore.QueryKey
Expand All @@ -47,7 +49,7 @@ export function backendQueryOptions<Method extends BackendMethods>(
export function backendQueryKey<Method extends BackendMethods>(
backend: Backend | null,
method: Method,
args: Parameters<Backend[Method]>,
args: Readonly<Parameters<Backend[Method]>>,
keyExtra?: queryCore.QueryKey | undefined,
): queryCore.QueryKey {
return [backend?.type, method, ...normalizeMethodQuery(method, args), ...(keyExtra ?? [])]
Expand Down
14 changes: 9 additions & 5 deletions app/common/src/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ declare module '@tanstack/query-core' {
* @default false
*/
readonly awaitInvalidates?: queryCore.QueryKey[] | boolean
readonly refetchType?: queryCore.InvalidateQueryFilters['refetchType']
}

readonly queryMeta: {
Expand Down Expand Up @@ -85,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 @@ -98,6 +99,7 @@ export function createQueryClient<TStorageValue = string>(
mutationCache: new queryCore.MutationCache({
onSuccess: (_data, _variables, _context, mutation) => {
const shouldAwaitInvalidates = mutation.meta?.awaitInvalidates ?? false
const refetchType = mutation.meta?.refetchType ?? 'active'
const invalidates = mutation.meta?.invalidates ?? []
const invalidatesToAwait = (() => {
if (Array.isArray(shouldAwaitInvalidates)) {
Expand All @@ -107,20 +109,22 @@ 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
32 changes: 20 additions & 12 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 @@ -1070,6 +1070,18 @@ export function assetIsType<Type extends AssetType>(type: Type) {
return (asset: AnyAsset): asset is Extract<AnyAsset, Asset<Type>> => asset.type === type
}

/** Extract the type of an id and return a discriminated union containing both id and type. */
export function extractTypeFromId(id: AssetId): AnyAsset extends infer T ?
T extends T ?
Pick<T, ('id' | 'type') & keyof T>
: never
: never {
return {
type: id.match(/^(.+?)-/)?.[1],
id,
} as never
}

/** Creates a new placeholder asset id for the given asset type. */
export function createPlaceholderAssetId<Type extends AssetType>(
type: Type,
Expand Down Expand Up @@ -1534,7 +1546,7 @@ export function isNewTitleUnique(
) {
siblings ??= []

return siblings.every(sibling => {
return siblings.every((sibling) => {
if (sibling.id === item.id) {
return true
}
Expand Down Expand Up @@ -1674,11 +1686,7 @@ export default abstract class Backend {
title: string,
): Promise<CreatedProject>
/** Return project details. */
abstract getProjectDetails(
projectId: ProjectId,
directoryId: DirectoryId | null,
getPresignedUrl?: boolean,
): Promise<Project>
abstract getProjectDetails(projectId: ProjectId, getPresignedUrl?: boolean): Promise<Project>
/** Return Language Server logs for a project session. */
abstract getProjectSessionLogs(
projectSessionId: ProjectSessionId,
Expand Down Expand Up @@ -1767,8 +1775,8 @@ export default abstract class Backend {
projectId?: string | null,
metadata?: object | null,
): Promise<void>
/** Download from an arbitrary URL that is assumed to originate from this backend. */
abstract download(url: string, name?: string): Promise<void>
/** Download an asset. */
abstract download(assetId: AssetId, title: string): Promise<void>

/**
* Get the URL for the customer portal.
Expand Down
4 changes: 0 additions & 4 deletions app/common/src/text/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"editDescriptionError": "Could not edit description",
"canOnlyDownloadFilesError": "You currently can only download files.",
"noProjectSelectedError": "First select a project to download.",
"downloadInvalidTypeError": "You can only download files, projects, and Datalinks",
"downloadProjectError": "Could not download project '$0'",
"downloadFileError": "Could not download file '$0'",
"downloadDatalinkError": "Could not download Datalink '$0'",
Expand All @@ -64,9 +63,6 @@
"nameShouldNotContainInvalidCharacters": "Name should not contain invalid characters",
"invalidEmailValidationError": "Please enter a valid email address",

"projectHasNoSourceFilesPhrase": "project has no source files",
"fileNotFoundPhrase": "file not found",

"noNewProfilePictureError": "Could not upload a new profile picture because no image was found",

"registrationError": "Something went wrong! Please try again or contact the administrators.",
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
4 changes: 2 additions & 2 deletions app/common/src/utilities/data/array.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file Utilities for manipulating arrays. */

export const EMPTY_ARRAY: readonly never[] = []
export const EMPTY_ARRAY: readonly [] = []

// ====================
// === shallowEqual ===
Expand Down 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
13 changes: 11 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 Expand Up @@ -219,3 +219,12 @@ export function useObjectId() {
* can be used to splice together objects without the risk of collisions.
*/
export type DisjointKeysUnion<A, B> = keyof A & keyof B extends never ? A & B : never

/**
* Merge types of values of an object union. Useful to return an object that UNSAFELY
* (at runtime) conforms to the shape of a discriminated union.
* Especially useful for things like Tanstack Query results.
*/
export type MergeValuesOfObjectUnion<T> = {
[K in `${keyof T & string}`]: T[K & keyof T]
}
11 changes: 0 additions & 11 deletions app/gui/.prettierrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion app/gui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const reactPreview: ReactPreview = {

(Story, context) => (
<>
<div className="enso-dashboard">
<div className="enso-app">
<Story {...context} />
</div>
<div id="enso-portal-root" className="enso-portal-root" />
Expand Down
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
Loading

0 comments on commit 523321c

Please sign in to comment.