thebaselab / codeapp

Building a full-fledged code editor for iPad
https://code.thebaselab.com
MIT License
2.77k stars 186 forks source link

Plugins (Like VSC) #28

Open luni-moon opened 3 years ago

luni-moon commented 3 years ago

I would like to see community supported plugins, like VSCode, but not from there, I mean new ones from scratch. It would really help with features the community would like to see, but the devs don’t have time or are not ready to add/support in the recent updates.

bummoblizard commented 3 years ago

This could be possible, but it would be rather restricted. I can see syntax highlighting for new languages, or color themes could be supported, and possibly code snippets since they can be represented as JSON files and contains no executable codes.

But ideally you'd want some degree of logic in the extension. Downloadable scripting languages like Python and Javascript are actually allowed on iOS. To achieve that, we would need to build a bridge between the native platform and those scripts. This could be rather difficult since the project isn't really stable enough to maintain a stable set of APIs.

Of course it would be even more ideal if the app could actually use VSCode extensions. Since VSCode extensions are written in Javascript anyway, extensions that don't need a node environment or other executable binary could work. (though I'm not ruling out the possibility to run node on iOS :) )

As a side project, I am actually also attempting to bring the web version of VSCode to iOS and it has some degree of VSCode extension support: https://medium.com/@thebaselab/my-attempt-to-run-vs-code-on-ipad-687aceaa82f4 In that way, it might be a better idea to port VSCode to iOS with the large existing community support.

Anyway, I'd like to hear more about the use cases of the plugins. What would you want to do with them?

luni-moon commented 3 years ago

They don’t necessarily have to be written in JS, they could be written in SwiftUI, as I assume that is the language that this app is written in, based on the platform, but that could cause even more restriction, due to the cause of presumably less knowing Swift, over JS.

I would use it to allow programs to have certain user inputs in terminal, adding live previews (on iPadOS) for certain languages, in split screen mode, and much more.

luni-moon commented 3 years ago

Also, I would like to see a plugin added for language terminal offline capabilities.

Rishi5813 commented 3 years ago

You could also add Programming languages as downloadable in plugins which will further enhance the Terminal and This App by adding an Option to compile online with the server and then Offline with the plugins Downloaded Earlier

luni-moon commented 3 years ago

You could also add Programming languages as downloadable in plugins which will further enhance the Terminal and This App by adding an Option to compile online with the server and then Offline with the plugins Downloaded Earlier

That is a splendid idea, that is probably the best way to go for this type of feature.

luni-moon commented 3 years ago

Also, I just reread:

Of course it would be even more ideal if the app could actually use VSCode extensions. Since VSCode extensions are written in Javascript anyway, extensions that don't need a node environment or other executable binary could work. (though I'm not ruling out the possibility to run node on iOS :) )

and the last part in parentheses, really stood out to me:

(though I'm not ruling out the possibility to run node on iOS :) )

Since the app now can run NODE, this would open up more possibilities to add plugins that are already in VSCode, contrary to my original request, although I would prefer it at some point, I can live with importing the important plugins from VSCode, for a while. @bummoblizard, let me know what you think. Thanks!

eiiot commented 3 years ago

I would love to get the SSH plugin, as that's my main use for an app like this. I don't have a way to edit my sever's files without it :/

bummoblizard commented 3 years ago

I would love to get the SSH plugin, as that's my main use for an app like this. I don't have a way to edit my sever's files without it :/

Noted! I understand this is quite useful.

eiiot commented 3 years ago

I would love to get the SSH plugin, as that's my main use for an app like this. I don't have a way to edit my sever's files without it :/

Noted! I understand this is quite useful.

I was actually able to access my files using Samba Share, however, the app doesn't allow me to open network folders, for some reason. It just crashes. Probably related to #62

luni-moon commented 3 years ago

I would love to get the SSH plugin, as that's my main use for an app like this. I don't have a way to edit my sever's files without it :/

Noted! I understand this is quite useful.

I was actually able to access my files using Samba Share, however, the app doesn't allow me to open network folders, for some reason. It just crashes. Probably related to #62

Yeah, I would say it is related to #62. Also, @bummoblizard Is there going to be some sort of milestone attached to this, or is this too far in the future to know when or if it will be implemented?

bummoblizard commented 3 years ago

I would love to get the SSH plugin, as that's my main use for an app like this. I don't have a way to edit my sever's files without it :/

Noted! I understand this is quite useful.

I was actually able to access my files using Samba Share, however, the app doesn't allow me to open network folders, for some reason. It just crashes. Probably related to #62

Yeah, I would say it is related to #62. Also, @bummoblizard Is there going to be some sort of milestone attached to this, or is this too far in the future to know when or if it will be implemented?

I'll try to add this in the next release.

chris-copleston commented 2 years ago

+1 for vscode plug-ins. Sadly I can’t use this app because our company repos use es-lint and when I run

npm run serve

it fails with…

Screenshot 2021-08-21 at 6 04 38 pm
ckanthony commented 2 years ago

+1 for vscode plug-ins, my main use of vscode is using Remote Development via SSH, which I can offload all the processing overhead to my server, and have no problem switching working environment between machine

luni-moon commented 2 years ago

@bummoblizard Are there any updates on this?

zaptrem commented 2 years ago

is LiveShare an option in this app?

luni-moon commented 2 years ago

is LiveShare an option in this app?

I do not think so, yet.

luni-moon commented 1 year ago

Why was this issued referenced in that commit 🤔

bummoblizard commented 1 year ago

I've introduced something called extensions in the recent commits. Although it cannot be dynamically loaded, nor compatible with VS code extensions, it allows a way to extend the editor functionalities in an enclosed environment.

For instance, this single file adds support for viewing images in Code App.

//
//  ImageEditorExtension.swift
//  Code
//
//  Created by Ken Chung on 22/11/2022.
//

import SwiftUI

private class Storage: ObservableObject {
    @Published var data: Data? = nil
}

private struct ImageContextMenu: View {

    let uiImage: UIImage

    var body: some View {
        Button {
            UIImageWriteToSavedPhotosAlbum(uiImage, nil, nil, nil)
        } label: {
            Label("Add to Photos", systemImage: "square.and.arrow.down")
        }
        Button {
            UIPasteboard.general.image = uiImage
        } label: {
            Label("Copy Image", systemImage: "doc.on.doc")
        }

    }

}

private struct ImageView: View {

    @EnvironmentObject var storage: Storage

    var body: some View {
        if let data = storage.data {
            if let uiImage = UIImage(data: data) {
                Image(uiImage: uiImage)
                    .resizable()
                    .scaledToFit()
                    .contextMenu {
                        ImageContextMenu(uiImage: uiImage)
                    }
            }else{
                Text("Unsupported image")
            }
        }else{
            Text("Loading Image")
        }
    }

}

class ImageEditorExtension: CodeAppExtension {

    override func onInitialize(app: MainApp, contribution: CodeAppExtension.Contribution) {
        let provider = EditorProvider(
            registeredFileExtensions: ["png", "tiff", "tif", "jpeg", "jpg", "gif", "bmp", "bmp", "BMPf", "ico", "cur", "xbm", "heic", "webp"],
            onCreateEditor: { url in
                let storage = Storage()
                let editorInstance = EditorInstanceWithURL(
                    view: AnyView(ImageView().environmentObject(storage)),
                    title: url.lastPathComponent,
                    url: url
                )

                app.workSpaceStorage.contents(at: url, completionHandler: { data, error in
                    storage.data = data
                    if let error {
                        app.notificationManager.showErrorMessage(error.localizedDescription)
                    }
                })

                return editorInstance
            }
        )
        contribution.editorProvider.register(provider: provider)
    }
}
luni-moon commented 1 year ago

That's exactly what I was looking for to be added! Is there a way we can make our own .swift extension files, and import them - preferably from the app? If not, I know that may be a lot of work, but it'd be sick! Keep up the awesome work!

bummoblizard commented 1 year ago

Right now you need to compile the app from Xcode. But in the future it is possible to build a JS bridge to enable dynamic extensions.

luni-moon commented 1 year ago

Right now you need to compile the app from Xcode. But in the future it is possible to build a JS bridge to enable dynamic extensions.

Ah, ok. Got it. I know this is probably in the README, or another issue, but what version of Xcode and Swift is needed to compile the app? Right now I am stuck on Swift 5.x.x, and Xcode 12.x, if I recall correctly (due to macOS Catalina as the last update available on m (13,2) iMac)

bummoblizard commented 1 year ago

I’m using the latest version but Xcode 12 should be fine.

「BatemaDevelopment @.***>」在 2022年12月2日 週五,21:39 寫道:

Right now you need to compile the app from Xcode. But in the future it is possible to build a JS bridge to enable dynamic extensions.

Ah, ok. Got it. I know this is probably in the README, or another issue, but what version of Xcode and Swift is needed to compile the app? Right now I am stuck on Swift 5.x.x, and Xcode 12.x, if I recall correctly.

— Reply to this email directly, view it on GitHub https://github.com/thebaselab/codeapp/issues/28#issuecomment-1335247750, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJE6T22H2DX2JRTWDYZL6MTWLH32TANCNFSM4XNDFP7A . You are receiving this because you were mentioned.Message ID: @.***>

luni-moon commented 1 year ago

I’m using the latest version but Xcode 12 should be fine.

「BatemaDevelopment @.***>」在 2022年12月2日 週五,21:39 寫道:

Right now you need to compile the app from Xcode. But in the future it is possible to build a JS bridge to enable dynamic extensions.

Ah, ok. Got it. I know this is probably in the README, or another issue, but what version of Xcode and Swift is needed to compile the app? Right now I am stuck on Swift 5.x.x, and Xcode 12.x, if I recall correctly.

— Reply to this email directly, view it on GitHub https://github.com/thebaselab/codeapp/issues/28#issuecomment-1335247750, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJE6T22H2DX2JRTWDYZL6MTWLH32TANCNFSM4XNDFP7A . You are receiving this because you were mentioned.Message ID: @.***>

Thanks for the info! I'll try to do so!