The script local namespace is destroyed after it's finished. On Sunday, September 3, 2023 at 11:16:44 PM UTC-4 tbp1...@gmail.com wrote:
> That's very nice! What is the scope of variable defined in a script like > this? For example, you wrote const userInput = await vscode.... where I > would have expected let userInput = .... If the script were to be run > again, then *userInput* might want to take on a different value which > would be disallowed by the *const*. If each script got a new namespace > each time it executed, though, there would be no problem. > > On Sunday, September 3, 2023 at 9:33:38 PM UTC-4 Félix wrote: > > I thought I'd share this :) > > Just a small example script that is possible to run in leojs, (with also > having the vscode API available in g.app.vscode) > > Incredibly, when executing the script, the global objects you'd expect to > see in javascript ,(console, fetch, ect...) are available, as shown below! > > Hoping to release a beta before the autumn starts! > Félix > > @language javascript > const vscode = g.app.vscode; > g.es("hahahaha"); > // 'await' for doCommandByName required only if other code in script is > 'awaited'. > await c.doCommandByName('insert-headline-time'); > > const userInput = await vscode.window.showInputBox({ > placeHolder: 'Enter something', // Placeholder text in the input box > prompt: 'Please enter some text:', // Prompt message above the input box > }); > if (userInput === undefined) { > g.es('User canceled the input.'); > } else { > g.es('User input:', userInput); > } > try { > const apiUrl = 'https://jsonplaceholder.typicode.com/users'; > const response = await fetch(apiUrl); > g.es("about to call"); > if (!response.ok) { > throw new Error('Network response was not ok'); > } > const data = await response.json(); > g.es("got it!!", JSON.stringify(data)); > } catch (error) { > g.es("oh no!"); > console.error('Fetch error:', error); > } > > On Sunday, September 3, 2023 at 3:02:54 PM UTC-4 Félix wrote: > > Thanks to you both!! > > g.app.vscode also felt right to me, so I'm glad this is a shared view! > > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/ac661f97-3f8d-4795-bb8d-5ea4389d45ecn%40googlegroups.com.