mirror of
https://github.com/enso-org/enso.git
synced 2025-01-03 15:32:00 +03:00
c811a5ae8b
- Fix the UI problems with our CodeMirror integration (Fixed view stability; Fixed a focus bug; Fixed errors caused by diagnostics range exceptions; Fixed linter invalidation--see https://discuss.codemirror.net/t/problem-trying-to-force-linting/5823; Implemented edit-coalescing for performance). - Introduce an algorithm for applying text edits to an AST. Compared to the GUI1 approach, the new algorithm supports deeper identity-stability for expressions (which is important for subexpression metadata and Y.Js sync), as well as reordered-subtree identification. - Enable the code editor.
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { createXXHash128 } from 'hash-wasm'
|
|
import init, { is_ident_or_operator, parse, parse_doc_to_json } from '../../rust-ffi/pkg/rust_ffi'
|
|
import { assertDefined } from '../util/assert'
|
|
import { isNode } from '../util/detect'
|
|
|
|
let xxHasher128: Awaited<ReturnType<typeof createXXHash128>> | undefined
|
|
export function xxHash128(input: string) {
|
|
assertDefined(xxHasher128, 'Module should have been loaded with `initializeFFI`.')
|
|
xxHasher128.init()
|
|
xxHasher128.update(input)
|
|
return xxHasher128.digest()
|
|
}
|
|
|
|
export async function initializeFFI(path?: string | undefined) {
|
|
if (isNode) {
|
|
const fs = await import('node:fs/promises')
|
|
const buffer = fs.readFile(path ?? './rust-ffi/pkg/rust_ffi_bg.wasm')
|
|
await init(buffer)
|
|
} else {
|
|
await init()
|
|
}
|
|
xxHasher128 = await createXXHash128()
|
|
}
|
|
|
|
// TODO[ao]: We cannot to that, because the ffi is used by cjs modules.
|
|
// await initializeFFI()
|
|
|
|
/* eslint-disable-next-line camelcase */
|
|
export { is_ident_or_operator, parse_doc_to_json, parse as parse_tree }
|