joyride

dangercoder 2023-01-12T17:35:30.868469Z

Is it possible to use extensions.getExtension('myExtension') from joyride or is it only available when building vscode extensions?

dangercoder 2023-01-12T17:38:31.729409Z

(.getExtension (.-extensions vscode) "myExtension")

borkdude 2023-01-12T17:44:18.426669Z

(vscode/extensions.getExtension ..) should also work

pez 2023-01-12T17:44:31.016549Z

Yes, that's how you do it. I'd use (vscode/extensions.getExtension "myExtension"). There is an example in the default user activate script. https://github.com/BetterThanTomorrow/joyride/blob/master/assets/getting-started-content/user/user_activate.cljs#L101

dangercoder 2023-01-12T17:46:06.978589Z

awesome, thanks!

borkdude 2023-01-12T17:46:38.041679Z

you'll even get auto-completions for vscode/ext.. and vscode/extensions.get...

2
pez 2023-01-12T17:54:40.449409Z

If this is not in an activation script you need it, @jarvinenemil, you can also use the special extension require syntax to get the extension's API. (ns ... (:require ["" :as my-extension])) There's an example here: https://github.com/BetterThanTomorrow/joyride/blob/master/examples/.joyride/scripts/joyride_api.cljs#L3

dangercoder 2023-01-12T19:30:01.630269Z

is there a nifty way to find all public properties of a vscode extension? I tried via the repl but it always returns #js ["id" "extensionUri" "extensionPath" "packageJSON" "extensionKind" "isFromDifferentExtensionHost"]

pez 2023-01-12T19:34:34.505379Z

This is a bit limited in Joyride. What public properties are you missing there?

dangercoder 2023-01-12T19:35:45.311799Z

I expected e.g the joyride to show the joyride keys (e.g. isActive) when I tried to list all object keys

dangercoder 2023-01-12T19:36:55.364379Z

I simply want to list all props for any extension which I can use to do stuff 😄

pez 2023-01-12T20:05:51.294899Z

I don't know why isActive doesn't show with js-keys. Or, rather, why the object does not include it, which you can see if you try

(js/JSON.parse (js/JSON.stringify joy))
There's something special about some of the properties.

borkdude 2023-01-12T20:06:23.321529Z

Maybe (js/Object.getOwnPropertyNames ..)?

pez 2023-01-12T20:07:25.972489Z

Please file an issue about it, @jarvinenemil. I think there should be something we could do about it.

👍 1
pez 2023-01-12T20:09:18.985679Z

getOwnProperties is what we use for completions, isn't it, @borkdude? In any case it shows the same as js-keys does.

borkdude 2023-01-12T20:10:16.580819Z

I think so, check the impl if you want to be sure

dangercoder 2023-01-12T21:12:23.613539Z

@pez issue created https://github.com/BetterThanTomorrow/joyride/issues/147

pez 2023-01-12T21:15:31.183719Z

Thanks! I think the behaviour of js-keys might be defined in a way that Joyride should not change. The problem rather is that we lack a way to see all properties.

borkdude 2023-01-12T21:15:49.945439Z

it's not clear to me what the expected behavior is. what is the JS invocation with the expected output?

pez 2023-01-12T21:18:13.834809Z

@borkdude. The node repl shows all the properties for these objects. The expected behaviour is that we can see them from the Joyride REPL somehow. At least that's what I am lacking.

dangercoder 2023-01-12T21:18:13.973979Z

e.g. (.-isActive joyride) is not returned. But it's there.

pez 2023-01-15T15:26:29.658999Z

I can get the missing properties like so:

(ns joyride.js-completions
  (:require ["repl" :as node-repl]
            ["vscode" :as vscode]))

(comment
  (def !completions (atom []))
  (defn completions-cb [err result]
    (if err
      (js/console.error err)
      (reset! !completions (-> result js->clj first))))

  (def repl (.start node-repl))
  (def context (.-context repl))
  (unchecked-set context "ext" (vscode/extensions.getExtension "betterthantomorrow.joyride"))
  (defn complete [s]
    (.completer repl s completions-cb  context)
    @!completions)

  (complete "ext.") => ["ext.__proto__"
                        "ext.hasOwnProperty"
                        "ext.isPrototypeOf"
                        "ext.propertyIsEnumerable"
                        "ext.toLocaleString"
                        "ext.toString"
                        "ext.valueOf"
                        ""
                        "ext.activate"
                        "ext.constructor"
                        "ext.exports"
                        "ext.isActive"
                        ""
                        "ext.extensionKind"
                        "ext.extensionPath"
                        "ext.extensionUri"
                        "ext.id"
                        "ext.isFromDifferentExtensionHost"
                        "ext.packageJSON"]
  :rcf)

pez 2023-01-15T15:27:24.541589Z

(I did this in the joyride source code, but should work in Joyride as well?)

borkdude 2023-01-13T11:58:55.345749Z

but what is the equivalent JS invocation that does show these? joyride supports JS scripts now - is it possible to make a repro in .js that does work?