Skip to content
Draft
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2512bb9
feat: build insight script
4e6 Dec 23, 2024
4477b4a
feat: initialize polyfill parser
4e6 Dec 25, 2024
31c97b9
DRAFT: insight parse tree
4e6 Dec 25, 2024
936bf45
feat: enso.dev.inspectPort
4e6 Dec 26, 2024
d9ce757
DRAFT: set widget metadata
4e6 Dec 27, 2024
50266f9
DRAFT: y-websocket
4e6 Dec 31, 2024
93ba1dc
DRAFT: debug websocket
4e6 Jan 1, 2025
7c889c6
Merge branch 'develop' into wip/db/11477-execute-yjs-insight
4e6 Mar 10, 2025
2932fac
update: after merge
4e6 Mar 10, 2025
8d17b9e
Combine previous value of ENSO_JVM_OPTS together WithDebugCommand.DEB…
JaroslavTulach Mar 13, 2025
814eb91
Re-try callback when JavaScript refuses to execute because of Multi t…
JaroslavTulach Mar 13, 2025
c8acbb2
Merging with latest develop
JaroslavTulach Mar 31, 2025
557bd00
Reverting unnecessary changes in ContextFactory
JaroslavTulach Mar 31, 2025
696d9e3
Use normal --inspect or DAP debugging
JaroslavTulach Mar 31, 2025
dc1a883
Merging with most recent develop
JaroslavTulach Apr 7, 2025
d0610ba
Merge remote-tracking branch 'origin/develop' into wip/db/11477-execu…
JaroslavTulach Apr 8, 2025
048bd5c
Merging with Share getThreadManager pool
JaroslavTulach Apr 11, 2025
d0d71be
Merging with most recent develop
JaroslavTulach May 7, 2025
31729b7
Merge remote-tracking branch 'origin/develop' into wip/db/11477-execu…
JaroslavTulach May 12, 2025
bce8380
Merging with origin/develop
JaroslavTulach May 12, 2025
ec78a92
Formatting import statements
JaroslavTulach May 12, 2025
2d91f12
Include requested URL in the failure message
JaroslavTulach May 12, 2025
dca720d
No need to change Zlib when allowBufferAccess is on
JaroslavTulach May 12, 2025
f383682
Updating to helidon 4.2.2
JaroslavTulach May 12, 2025
877b227
Removing outdated debug configuration
JaroslavTulach May 12, 2025
7df699c
Merge remote-tracking branch 'origin/develop' into wip/db/11477-execu…
JaroslavTulach May 16, 2025
e29bfc1
Merge remote-tracking branch 'origin/develop' into wip/db/11477-execu…
JaroslavTulach May 23, 2025
8e21525
Create zlib Buffer over ArrayBuffer view
JaroslavTulach May 23, 2025
1c7e750
WebSocketClient utility to check compatibility of the polyfill
JaroslavTulach May 24, 2025
6f0d885
Delay initialization of insight by ten seconds to not interfere with …
JaroslavTulach May 24, 2025
b10c9c7
Don't clean the session to avoid NPE and get more explainable exception
JaroslavTulach May 24, 2025
a44375a
Turn into interfactive shell
JaroslavTulach May 24, 2025
efda23a
Merging in #13159
JaroslavTulach May 26, 2025
1ed6d4d
Allow override (composition) of ENSO_JVM_OPTS env variable
JaroslavTulach May 27, 2025
e8c11ab
Use /home/devel/NetBeansProjects/enso/enso.ide to reference current w…
JaroslavTulach May 27, 2025
1ec18f1
Cannot stringify frame - the content may be too deep
JaroslavTulach May 27, 2025
b81b815
--jvm option takes argument in enso, but not in project-manager
JaroslavTulach May 27, 2025
c8e5342
Allow project-manager --jvm to have an argument
JaroslavTulach May 27, 2025
2be45bf
Unexpected exceptions like IllegalStateException should be reported. …
JaroslavTulach May 27, 2025
08c21ae
prepareFunctionCall may need Truffle context. Wrapping in submitExecu…
JaroslavTulach May 27, 2025
8a73292
Merge remote-tracking branch 'origin/develop' into wip/db/11477-execu…
JaroslavTulach May 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,4 @@ storybook-static
#########

/.mailmap
/app/ydoc-server-polyglot/nbproject/private/
8 changes: 0 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
"debugServer": 4711,
"request": "attach"
},
{
"type": "node-terminal",
"name": "Run Script: dev",
"request": "launch",
"command": "npm run dev",
// "env": {"NODE_OPTIONS": "--inspect"},
"cwd": "${workspaceFolder}/app/gui2"
},
{
"type": "nativeimage",
"request": "launch",
Expand Down
17 changes: 0 additions & 17 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/ydoc-server-polyglot/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const globals = {
}

const ctx = await esbuild.context({
outfile: 'dist/main.cjs',
outdir: 'dist',
sourcemap: 'linked',
entryPoints: ['src/main.ts'],
entryPoints: ['src/main.ts', 'src/insight.ts'],
bundle: true,
platform: 'browser',
define: {
Expand Down
6 changes: 4 additions & 2 deletions app/ydoc-server-polyglot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
"main": "./dist/main.js",
"scripts": {
"compile": "node ./build.mjs build",
"start": "node ./dist/main.cjs",
"start": "node ./dist/main.js",
"dev:watch": "node ./build.mjs watch",
"lint": "eslint . --cache --max-warnings=0"
},
"dependencies": {
"y-websocket": "^1.5.4",
"ydoc-server": "workspace:*",
"ydoc-shared": "workspace:*"
"ydoc-shared": "workspace:*",
"yjs": "^13.6.21"
},
"devDependencies": {
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
Expand Down
148 changes: 148 additions & 0 deletions app/ydoc-server-polyglot/src/insight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import { WebsocketProvider } from 'y-websocket'
import { deserializeIdMap } from 'ydoc-server'
import * as Ast from 'ydoc-shared/ast'
import { splitFileContents } from 'ydoc-shared/ensoFile'
import { DistributedProject } from 'ydoc-shared/yjsModel'
import * as Y from 'yjs'

interface SubdocsEvent {
loaded: Set<Y.Doc>
added: Set<Y.Doc>
removed: Set<Y.Doc>
}
declare let insight: any
console.log(`Initializing Insight: ${JSON.stringify(insight)} in 10s`)

function initializeLater() {
console.log(`Initializing Insight now...`)

const PROJECT_NAME = 'NewProject1'
const RETURN_VALUE_KEY = 'insight_return_value'

//const doc = new ModuleDoc(new Y.Doc())
const doc = new Y.Doc()
const syncModule = new Ast.MutableModule(doc)
let spanMap = null

function attachProvider(url: string, room: string, doc: Y.Doc) {
console.log(`attachProvider ${url} ${room}`)
const provider = new WebsocketProvider(url, room, doc)
const onSync = () => doc.emit('sync', [true, doc])
const onDrop = () => doc.emit('sync', [false, doc])

const attachedSubdocs = new Map<Y.Doc, ReturnType<typeof attachProvider>>()

function onSubdocs(e: SubdocsEvent) {
e.loaded.forEach((subdoc) => {
attachedSubdocs.set(subdoc, attachProvider(url, subdoc.guid, subdoc))
})
e.removed.forEach((subdoc) => {
const subdocProvider = attachedSubdocs.get(subdoc)
attachedSubdocs.delete(subdoc)
if (subdocProvider != null) {
subdocProvider.dispose()
}
})
}

provider.on('sync', onSync)
provider.on('connection-close', onDrop)
provider.on('connection-error', onDrop)
doc.on('subdocs', onSubdocs)

function dispose() {
provider.disconnect()
provider.off('sync', onSync)
provider.off('connection-close', onDrop)
provider.off('connection-error', onDrop)
doc.off('subdocs', onSubdocs)
attachedSubdocs.forEach((subdocProvider) => {
subdocProvider.dispose()
})
}
return { provider, dispose }
}

const d = new Y.Doc()
const project = new DistributedProject(d)
console.log(`Insight: got project ${project}`)
let provider = null
try {
provider = attachProvider('ws://localhost:5976/project', 'index', d)
} catch (err) {
console.error(`Insight: Failed to initialize provider`)
console.error(err)
}
console.log(`Insight: got provider ${provider}`)

function parseContents(contents: string, syncModule: Ast.MutableModule) {
const { code, idMapJson, metadataJson } = splitFileContents(contents)

Check warning on line 79 in app/ydoc-server-polyglot/src/insight.ts

View workflow job for this annotation

GitHub Actions / 🧹 GUI Lint Results

app/ydoc-server-polyglot/src/insight.ts#L79

[@typescript-eslint/no-unused-vars] 'metadataJson' is assigned a value but never used. Allowed unused vars must match /^_/u.
const parsedIdMap = deserializeIdMap(idMapJson)

const { root, spans } = Ast.parseModuleWithSpans(code, syncModule)
syncModule.setRoot(root)
spanMap = spans

Ast.setExternalIds(syncModule, spans, parsedIdMap)
console.log(`[parseContents] idMap.entries=${parsedIdMap.entries()}`)
}

console.log(`Insight: listen on sources`)
insight.on('source', function (ctx, frame) {

Check warning on line 91 in app/ydoc-server-polyglot/src/insight.ts

View workflow job for this annotation

GitHub Actions / 🧹 GUI Lint Results

app/ydoc-server-polyglot/src/insight.ts#L91

[@typescript-eslint/no-unused-vars] 'frame' is defined but never used. Allowed unused args must match /^_/u.
console.log(`[source] ctx.uri=${ctx.name}`)
if (ctx.name.includes(PROJECT_NAME)) {
console.log(`[source] MATCHED ctx=${JSON.stringify(ctx)}`)
parseContents(ctx.characters, syncModule)
}
})

function resultToString(result: any): string {
return '' + result
}

/*
class IdMap {
private readonly rangeToExpr: Map<SourceRange, ExternalId>
}
interface SpanMap {
nodes: Map<NodeKey, Ast[]>
tokens: Map<TokenKey, Token>
}
type NodeKey = TokenKey = SourceRangeKey
*/
console.log(`Insight: listen on return`)
insight.on(
'return',
function (ctx, frame) {
console.log(`[return] ctx='${JSON.stringify(ctx)}'`)
console.log(`[return] frame='${JSON.stringify(frame)}'`)
console.log(`[return] ctx.returnValue='${ctx.returnValue(frame)}'`)

const p = project

Check warning on line 121 in app/ydoc-server-polyglot/src/insight.ts

View workflow job for this annotation

GitHub Actions / 🧹 GUI Lint Results

app/ydoc-server-polyglot/src/insight.ts#L121

[@typescript-eslint/no-unused-vars] 'p' is assigned a value but never used. Allowed unused vars must match /^_/u.
const result = ctx.returnValue(frame)
if (result && spanMap) {
const key = Ast.nodeKey(ctx.charIndex, ctx.charEndIndex - ctx.charIndex)
const asts = spanMap.nodes.get(key)
if (asts) {
const resultValue = resultToString(result)
for (const ast of asts) {
const editAst = syncModule.getVersion(ast)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (editAst.widgetMetadata(RETURN_VALUE_KEY) !== resultValue) {
console.log(`[return] setWidgetMetadata ${ast.code()} : ${resultValue}`)
editAst.setWidgetMetadata(RETURN_VALUE_KEY, resultValue)
}
}
}
}
},
{
expressions: true,
statements: false,
roots: false,
rootNameFilter: '.*main',
},
)
console.log(`Initialization of Insight is over!`)
}

setTimeout(initializeLater, 10000)
4 changes: 4 additions & 0 deletions app/ydoc-server-polyglot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*.ts"],
"references": [
{ "path": "../ydoc-server" },
{ "path": "../ydoc-shared" },
],
"compilerOptions": {
"composite": true,
"noEmit": false,
Expand Down
2 changes: 1 addition & 1 deletion app/ydoc-shared/src/ast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { reachable } from '../util/data/graph'
import type { Module } from './mutableModule'
import type { AstId } from './tree'

export { spanMapToIdMap } from './idMap'
export { nodeKey, spanMapToIdMap } from './idMap'
export * from './mutableModule'
export * from './parse'
export { printWithSpans } from './print'
Expand Down
82 changes: 45 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -507,43 +507,51 @@ val commons = Seq(
)

// === Helidon ================================================================
val jakartaVersion = "2.0.1"
val helidonVersion = "4.1.2"
val helidon = Seq(
"io.helidon" % "helidon" % helidonVersion,
"io.helidon.builder" % "helidon-builder-api" % helidonVersion,
"io.helidon.common" % "helidon-common" % helidonVersion,
"io.helidon.common" % "helidon-common-buffers" % helidonVersion,
"io.helidon.common" % "helidon-common-config" % helidonVersion,
"io.helidon.common" % "helidon-common-configurable" % helidonVersion,
"io.helidon.common" % "helidon-common-context" % helidonVersion,
"io.helidon.common" % "helidon-common-key-util" % helidonVersion,
"io.helidon.common" % "helidon-common-mapper" % helidonVersion,
"io.helidon.common" % "helidon-common-media-type" % helidonVersion,
"io.helidon.common" % "helidon-common-parameters" % helidonVersion,
"io.helidon.common" % "helidon-common-socket" % helidonVersion,
"io.helidon.common" % "helidon-common-security" % helidonVersion,
"io.helidon.common" % "helidon-common-task" % helidonVersion,
"io.helidon.common" % "helidon-common-types" % helidonVersion,
"io.helidon.common" % "helidon-common-tls" % helidonVersion,
"io.helidon.common" % "helidon-common-uri" % helidonVersion,
"io.helidon.common.features" % "helidon-common-features" % helidonVersion,
"io.helidon.common.features" % "helidon-common-features-api" % helidonVersion,
"io.helidon.config" % "helidon-config" % helidonVersion,
"io.helidon.logging" % "helidon-logging-common" % helidonVersion,
"io.helidon.inject" % "helidon-inject-api" % helidonVersion,
"io.helidon.http" % "helidon-http" % helidonVersion,
"io.helidon.http.encoding" % "helidon-http-encoding" % helidonVersion,
"io.helidon.http.media" % "helidon-http-media" % helidonVersion,
"io.helidon.webclient" % "helidon-webclient" % helidonVersion,
"io.helidon.webclient" % "helidon-webclient-api" % helidonVersion,
"io.helidon.webclient" % "helidon-webclient-http1" % helidonVersion,
"io.helidon.webclient" % "helidon-webclient-websocket" % helidonVersion,
"io.helidon.webserver" % "helidon-webserver" % helidonVersion,
"io.helidon.webserver" % "helidon-webserver-websocket" % helidonVersion,
"io.helidon.websocket" % "helidon-websocket" % helidonVersion,
"jakarta.inject" % "jakarta.inject-api" % jakartaVersion
)
val helidonVersion = "4.2.2"
val helidon = {
val clientAndSharedDeps = Seq(
"io.helidon" % "helidon" % helidonVersion,
"io.helidon.builder" % "helidon-builder-api" % helidonVersion,
"io.helidon.common" % "helidon-common" % helidonVersion,
"io.helidon.common" % "helidon-common-buffers" % helidonVersion,
"io.helidon.common" % "helidon-common-config" % helidonVersion,
"io.helidon.common" % "helidon-common-configurable" % helidonVersion,
"io.helidon.common" % "helidon-common-context" % helidonVersion,
"io.helidon.common" % "helidon-common-key-util" % helidonVersion,
"io.helidon.common" % "helidon-common-mapper" % helidonVersion,
"io.helidon.common" % "helidon-common-media-type" % helidonVersion,
"io.helidon.common" % "helidon-common-parameters" % helidonVersion,
"io.helidon.common" % "helidon-common-resumable" % helidonVersion,
"io.helidon.common" % "helidon-common-socket" % helidonVersion,
"io.helidon.common" % "helidon-common-tls" % helidonVersion,
"io.helidon.common" % "helidon-common-types" % helidonVersion,
"io.helidon.common" % "helidon-common-uri" % helidonVersion,
"io.helidon.http" % "helidon-http" % helidonVersion,
"io.helidon.http.encoding" % "helidon-http-encoding" % helidonVersion,
"io.helidon.http.media" % "helidon-http-media" % helidonVersion,
"io.helidon.logging" % "helidon-logging-common" % helidonVersion,
"io.helidon.metadata" % "helidon-metadata-hson" % helidonVersion,
"io.helidon.service" % "helidon-service-metadata" % helidonVersion,
"io.helidon.service" % "helidon-service-registry" % helidonVersion,
"io.helidon.webclient" % "helidon-webclient" % helidonVersion,
"io.helidon.webclient" % "helidon-webclient-api" % helidonVersion,
"io.helidon.webclient" % "helidon-webclient-http1" % helidonVersion,
"io.helidon.webclient" % "helidon-webclient-websocket" % helidonVersion,
"io.helidon.websocket" % "helidon-websocket" % helidonVersion
)
val serverDeps = Seq(
"io.helidon.webserver" % "helidon-webserver" % helidonVersion,
"io.helidon.webserver" % "helidon-webserver-websocket" % helidonVersion,
"io.helidon.config" % "helidon-config" % helidonVersion,
"io.helidon.common" % "helidon-common-security" % helidonVersion,
"io.helidon.common.concurrency" % "helidon-common-concurrency-limits" % helidonVersion,
"io.helidon.common.features" % "helidon-common-features" % helidonVersion,
"io.helidon.common.features" % "helidon-common-features-api" % helidonVersion,
"io.helidon.common" % "helidon-common-task" % helidonVersion,
"io.helidon.metrics" % "helidon-metrics-api" % helidonVersion
)
clientAndSharedDeps ++ serverDeps
}

// === Jackson ================================================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.function.Function;
import java.util.logging.Level;
import org.enso.runtime.utils.ThreadUtils;
import org.enso.ydoc.polyfill.ParserPolyfill;
import org.enso.ydoc.polyfill.web.WebEnvironment;
import org.graalvm.polyglot.Value;

Expand Down Expand Up @@ -90,6 +91,7 @@ public void log(Level level, String msg, Object... args) {

final void initializePolyfill(Node node, TruffleContext ctx) {
if (!polyfillInitialized) {
var parserPolyfill = new ParserPolyfill();
polyfillInitialized = true;
var ensoLanguage = getEnv().getInternalLanguages().get("enso");
var exec = getEnv().lookup(ensoLanguage, ScheduledExecutorService.class);
Expand All @@ -105,6 +107,7 @@ final void initializePolyfill(Node node, TruffleContext ctx) {
}
};
WebEnvironment.initialize(eval, exec);
parserPolyfill.initialize(eval);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.enso.ydoc.polyfill;

import java.net.URL;
import java.util.function.Function;
import org.enso.syntax2.Parser;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Source;
Expand All @@ -22,10 +24,17 @@ public final class ParserPolyfill implements ProxyExecutable {
public ParserPolyfill() {}

public void initialize(Context ctx) {
Source parserJs =
Source.newBuilder("js", ParserPolyfill.class.getResource(PARSER_JS)).buildLiteral();
Function<URL, Value> eval =
(url) -> {
var src = Source.newBuilder("js", url).buildLiteral();
return ctx.eval(src);
};
initialize(eval);
}

ctx.eval(parserJs).execute(this);
public void initialize(Function<URL, Value> eval) {
final Value fn = eval.apply(getClass().getResource(PARSER_JS));
fn.execute(this);
}

@Override
Expand Down
Loading
Loading