Skip to content

Commit

Permalink
Merging with develop and its Dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Jul 9, 2024
2 parents 091b0fd + 71a6e21 commit 76fdb98
Show file tree
Hide file tree
Showing 234 changed files with 4,381 additions and 4,024 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ Cargo.toml
# The data-link schema is owned by the libraries team
/app/ide-desktop/lib/dashboard/src/data/datalinkSchema.json @radeusgd @jdunkerley @GregoryTravis @AdRiley @marthasharkey
/app/ide-desktop/lib/dashboard/src/data/__tests__ @radeusgd @jdunkerley @GregoryTravis @AdRiley @marthasharkey @PabloBuchu @indiv0 @somebody1234

# GUI / Dashboard shared
/app/ide-desktop/lib/common @PabloBuchu @indiv0 @somebody1234 @MrFlashAccount @Frizi @farmaazon @vitvakatu @kazcw @AdRiley
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
methods.][10434]
- [Renamed `Location.Start` to `Location.Left` and `Location.End` to
`Location.Right`.][10445]
- [Renamed `Postgres_Details.Postgres` to `Postgres.Server`.][10466]
- [Remove `First` and `Last` from namespace, use auto-scoped.][10467]
- [Rename `Map` to `Dictionary` and `Set` to `Hashset`.][10474]

[10434]: https://github.com/enso-org/enso/pull/10434
[10445]: https://github.com/enso-org/enso/pull/10445
[10466]: https://github.com/enso-org/enso/pull/10466
[10467]: https://github.com/enso-org/enso/pull/10467
[10474]: https://github.com/enso-org/enso/pull/10474

# Enso 2024.2

Expand Down
1 change: 1 addition & 0 deletions app/gui2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@lezer/highlight": "^1.1.6",
"@noble/hashes": "^1.3.2",
"@open-rpc/client-js": "^1.8.1",
"@tanstack/vue-query": ">= 5.45.0 < 5.46.0",
"@vueuse/core": "^10.4.1",
"ag-grid-community": "^30.2.1",
"ag-grid-enterprise": "^30.2.1",
Expand Down
10 changes: 8 additions & 2 deletions app/gui2/shared/languageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type {
ExpressionId,
FileEdit,
FileSystemObject,
IdMapTriple,
IdMapTuple,
Notifications,
Path,
RegisterOptions,
Expand Down Expand Up @@ -288,8 +290,12 @@ export class LanguageServer extends ObservableV2<Notifications & TransportEvents
}

/** [Documentation](https://github.com/enso-org/enso/blob/develop/docs/language-server/protocol-language-server.md#textapplyedit) */
applyEdit(edit: FileEdit, execute: boolean): Promise<LsRpcResult<void>> {
return this.request('text/applyEdit', { edit, execute })
applyEdit(
edit: FileEdit,
execute: boolean,
idMap?: IdMapTriple[] | IdMapTuple[],
): Promise<LsRpcResult<void>> {
return this.request('text/applyEdit', { edit, execute, idMap })
}

/** [Documentation](https://github.com/enso-org/enso/blob/develop/docs/language-server/protocol-language-server.md#filewrite) */
Expand Down
9 changes: 9 additions & 0 deletions app/gui2/shared/languageServerTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ export interface Position {
character: number
}

interface IdMapSpan {
index: { value: number }
size: { value: number }
}

export type IdMapTuple = [IdMapSpan, string]

export type IdMapTriple = [number, number, string]

export type RegisterOptions = { path: Path } | { contextId: ContextId } | {}

export interface CapabilityRegistration {
Expand Down
15 changes: 13 additions & 2 deletions app/gui2/src/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { baseConfig, configValue, mergeConfig } from '@/util/config'
import { urlParams } from '@/util/urlParams'
import * as vueQuery from '@tanstack/vue-query'
import { isOnLinux } from 'enso-common/src/detect'
import * as commonQuery from 'enso-common/src/queryClient'
import * as dashboard from 'enso-dashboard'
import { isDevMode } from 'shared/util/detect'
import { lazyVueInReact } from 'veaury'
import { type App } from 'vue'

import 'enso-dashboard/src/tailwind.css'
import type { EditorRunner } from '../../ide-desktop/lib/types/types'
Expand Down Expand Up @@ -46,8 +49,6 @@ window.addEventListener('resize', () => {
scamWarningHandle = window.setTimeout(printScamWarning, SCAM_WARNING_TIMEOUT)
})

const appRunner = lazyVueInReact(AsyncApp as any /* async VueComponent */) as EditorRunner

/** The entrypoint into the IDE. */
function main() {
/** Note: Signing out always redirects to `/`. It is impossible to make this work,
Expand All @@ -74,6 +75,15 @@ function main() {
const projectManagerUrl = config.engine.projectManagerUrl || PROJECT_MANAGER_URL
const ydocUrl = config.engine.ydocUrl === '' ? YDOC_SERVER_URL : config.engine.ydocUrl
const initialProjectName = config.startup.project || null
const queryClient = commonQuery.createQueryClient()

const registerPlugins = (app: App) => {
app.use(vueQuery.VueQueryPlugin, { queryClient })
}

const appRunner = lazyVueInReact(AsyncApp as any /* async VueComponent */, {
beforeVueAppMount: (app) => registerPlugins(app as App),
}) as EditorRunner

dashboard.run({
appRunner,
Expand All @@ -96,6 +106,7 @@ function main() {
}
}
},
queryClient,
})
}

Expand Down
30 changes: 24 additions & 6 deletions app/gui2/ydoc-server/languageServerSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
translateVisualizationFromFile,
} from './edits'
import * as fileFormat from './fileFormat'
import { deserializeIdMap, serializeIdMap } from './serialization'
import { deserializeIdMap, idMapToArray, serializeIdMap } from './serialization'
import { WSSharedDoc } from './ydoc'

const SOURCE_DIR = 'src'
Expand Down Expand Up @@ -457,6 +457,18 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> {
}
}

private static getIdMapToPersist(
idMap: IdMap | undefined,
metadata: fileFormat.IdeMetadata['node'],
): IdMap | undefined {
if (idMap === undefined) {
return
} else {
const entriesIntersection = idMap.entries().filter(([, id]) => id in metadata)
return new IdMap(entriesIntersection)
}
}

private sendLsUpdate(
synced: EnsoFileParts,
newCode: string | undefined,
Expand All @@ -468,11 +480,17 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> {
const code = newCode ?? synced.code
const newMetadataJson =
newMetadata &&
json.stringify({ ...this.syncedMeta, ide: { ...this.syncedMeta.ide, node: newMetadata } })
const newIdMapJson = newIdMap && serializeIdMap(newIdMap)
json.stringify({
...this.syncedMeta,
ide: { ...this.syncedMeta.ide, node: newMetadata },
})
const idMapToPersist =
(newIdMap || newMetadata) &&
ModulePersistence.getIdMapToPersist(newIdMap, newMetadata ?? this.syncedMeta.ide.node)
const newIdMapToPersistJson = idMapToPersist && serializeIdMap(idMapToPersist)
const newContent = combineFileParts({
code,
idMapJson: newIdMapJson ?? synced.idMapJson ?? '[]',
idMapJson: newIdMapToPersistJson ?? synced.idMapJson ?? '[]',
metadataJson: newMetadataJson ?? synced.metadataJson ?? '{}',
})

Expand Down Expand Up @@ -502,7 +520,7 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> {

const execute = newCode != null || newIdMap != null
const edit: FileEdit = { path: this.path, edits, oldVersion: this.syncedVersion, newVersion }
const apply = this.ls.applyEdit(edit, execute)
const apply = this.ls.applyEdit(edit, execute, newIdMap && idMapToArray(newIdMap))
const handleError = (error: unknown) => {
console.error('Could not apply edit:', error)
// Try to recover by reloading the file.
Expand All @@ -521,7 +539,7 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> {
this.syncedVersion = newVersion
if (newMetadata) this.syncedMeta.ide.node = newMetadata
if (newCode) this.syncedCode = newCode
if (newIdMapJson) this.syncedIdMap = newIdMapJson
if (newIdMapToPersistJson) this.syncedIdMap = newIdMapToPersistJson
if (newMetadataJson) this.syncedMetaJson = newMetadataJson
this.setState(LsSyncState.Synchronized)
}, handleError)
Expand Down
2 changes: 1 addition & 1 deletion app/gui2/ydoc-server/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function serializeIdMap(map: IdMap): string {
return json.stringify(idMapToArray(map))
}

function idMapToArray(map: IdMap): fileFormat.IdMapEntry[] {
export function idMapToArray(map: IdMap): fileFormat.IdMapEntry[] {
const entries: fileFormat.IdMapEntry[] = []
map.entries().forEach(([rangeBuffer, id]) => {
const decoded = sourceRangeFromKey(rangeBuffer)
Expand Down
10 changes: 10 additions & 0 deletions app/ide-desktop/lib/assets/computer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions app/ide-desktop/lib/assets/not_cloud.svg

This file was deleted.

7 changes: 0 additions & 7 deletions app/ide-desktop/lib/common/README.md

This file was deleted.

13 changes: 12 additions & 1 deletion app/ide-desktop/lib/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
"./src/buildUtils": "./src/buildUtils.js",
"./src/detect": "./src/detect.ts",
"./src/gtag": "./src/gtag.ts",
"./src/load": "./src/load.ts"
"./src/load": "./src/load.ts",
"./src/queryClient": "./src/queryClient.ts"
},
"peerDependencies": {
"@tanstack/query-core": "5.45.0",
"@tanstack/vue-query": ">= 5.45.0 < 5.46.0"
},
"dependencies": {
"idb-keyval": "^6.2.1",
"@tanstack/query-persist-client-core": "^5.45.0",
"@tanstack/vue-query": ">= 5.45.0 < 5.46.0",
"vue": "^3.4.19"
}
}
Loading

0 comments on commit 76fdb98

Please sign in to comment.