Code Monkey home page Code Monkey logo

Comments (6)

spoenemann avatar spoenemann commented on June 9, 2024

Doesn't this mean that the diagram is expected to be served from the language server?

No, it just means that the default is to provide the diagram from the backend of the VS Code extension. We just released a new package sprotty-protocol that can be used in the backend (main extension code), but it's true that an example for this is missing. I hope we can provide one soon.

If you want to create the model directly in the frontend (webview), you can rebind TYPES.ModelSource to LocalModelSource.

from sprotty-vscode.

zam1kor avatar zam1kor commented on June 9, 2024

is there any update regarding this topic?

from sprotty-vscode.

spoenemann avatar spoenemann commented on June 9, 2024

Please check out v0.5.0. It brings a major redesign of the API. This includes an option for the new WebviewEndpoint class to communicate via a DiagramServer as defined in sprotty-protocol:

https://github.com/eclipse/sprotty-vscode/blob/fa9c9ac4cc36960208ea732d22fc0904d4fcd5b2/packages/sprotty-vscode/src/webview-endpoint.ts#L47

You can create this DiagramServer in the VS Code extension to generate diagrams and handle client actions.

from sprotty-vscode.

christianmalek avatar christianmalek commented on June 9, 2024

Hi, is there an example for the usage of DiagramServer and WebviewEndpoint available yet?

from sprotty-vscode.

spoenemann avatar spoenemann commented on June 9, 2024

I don't know of a publicly available example. But something like this could be a good start:

export class StatesWPM extends WebviewPanelManager {

    protected override createEndpoint(identifier: SprottyDiagramIdentifier): WebviewEndpoint {
        const webviewContainer = this.createWebview(identifier);
        const participant = this.messenger.registerWebviewPanel(webviewContainer);
        const diagramServices: DiagramServices = {
            DiagramGenerator: new StatesDiagramGenerator()
        };
        return new WebviewEndpoint({
            webviewContainer,
            messenger: this.messenger,
            messageParticipant: participant,
            identifier,
            diagramServerFactory: (dispatch) => new DiagramServer(dispatch, diagramServices)
        });
    }

}

export class StatesDiagramGenerator implements IDiagramGenerator {
    generate(args: GeneratorArguments): SModelRoot | Promise<SModelRoot> {
        // Generate a diagram model based on options like `args.options.sourceUri`
    }
}

from sprotty-vscode.

christianmalek avatar christianmalek commented on June 9, 2024

I appreciate it. Thank you for the fast response!

from sprotty-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.