-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtension.fs
28 lines (19 loc) · 894 Bytes
/
Extension.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
namespace PolyglotExtension.Commands
open System.Threading.Tasks
open Microsoft.AspNetCore.Html
open Microsoft.DotNet.Interactive
type FableKernelExtension() =
interface IKernelExtension with
member this.OnLoadAsync(kernel:Kernel) : Task =
// run code on extension load
PolyglotFacade.send "javascript" StaticCode.pyodideAndTurfLoader
// run custom code on demand (via magic command)
LoadPackage.code |> kernel.AddDirective
FablePython.code |> kernel.AddDirective
match KernelInvocationContext.Current.HandlingKernel with
| null -> ()
| x ->
HtmlString($@"<code>Polyglot extension -> .net/js/python playground. </code>")
|> KernelInvocationContext.Current.Display
|> ignore
Task.CompletedTask