Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update packages #179

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ nuget FSharp.Core >= 4.5.2
nuget Deedle
nuget MathNet.Numerics
nuget Google.DataTable.Net.Wrapper
nuget Newtonsoft.Json
nuget Newtonsoft.Json >= 13.0.1
nuget Microsoft.SourceLink.GitHub

group Formatting
Expand Down
876 changes: 438 additions & 438 deletions paket.lock

Large diffs are not rendered by default.

123 changes: 61 additions & 62 deletions src/XPlot.Plotly.Interactive/KernelExtension.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,68 +19,67 @@ open Giraffe.ViewEngine
open XPlot.Plotly.Interactive.PowerShell.Commands

type KernelExtension() =
let getScriptElementWithRequire (script: string) =
let newScript = StringBuilder()
newScript.AppendLine("""<script type="text/javascript">""") |> ignore
newScript.AppendLine("""
var renderPlotly = function() {
var xplotRequire = require.config({context:'xplot-3.0.1',paths:{plotly:'https://cdn.plot.ly/plotly-1.49.2.min'}}) || require;
xplotRequire(['plotly'], function(Plotly) { """) |> ignore
newScript.AppendLine(script) |> ignore
newScript.AppendLine(@"});
};"
) |> ignore
newScript.AppendLine(JavascriptUtilities.GetCodeForEnsureRequireJs(Uri("https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"), "renderPlotly")) |> ignore
newScript.AppendLine("</script>") |> ignore
newScript.ToString()

let getHtml (chart: PlotlyChart) =
let styleStr = $"width: {chart.Width}px; height: {chart.Height}px;"
let divElem =
div [_style styleStr; _id chart.Id] [] |> RenderView.AsString.htmlDocument

let js = chart.GetInlineJS().Replace("<script>", String.Empty).Replace("</script>", String.Empty)
HtmlString(divElem + getScriptElementWithRequire js)

let registerPlotlyFormatters () =
Formatter.Register<PlotlyChart>(
Action<_,_>(fun (chart: PlotlyChart) (writer: TextWriter) ->
writer.Write(getHtml chart)),
HtmlFormatter.MimeType)

let registerPowerShellAccelerators () =
// Register type accelerators for Plotly.
let accelerator = typeof<PSObject>.Assembly.GetType("System.Management.Automation.TypeAccelerators")
let addMethod = accelerator.GetMethod("Add", [| typeof<string>; typeof<Type> |])
let addAccelerator (name, objectType) = addMethod.Invoke(null, [| name; objectType |]) |> ignore
typeof<Trace>.Assembly.GetTypes()
|> Array.filter typeof<Trace>.IsAssignableFrom
|> Array.map (fun trace -> ($"Graph.{trace.Name}", trace))
|> Array.append [| ("Layout", typeof<Layout.Layout>); ("Chart", typeof<Chart>) |]
|> Array.iter addAccelerator

let registerPowerShellModule () =
// Add Modules directory that contains the helper modules.
let psModulePath = Environment.GetEnvironmentVariable("PSModulePath")
let psXPlotModulePath = Path.Join(Path.GetDirectoryName(typeof<NewPlotlyChartCommand>.Assembly.Location), "Modules")
Environment.SetEnvironmentVariable("PSModulePath", $"{psXPlotModulePath}{Path.PathSeparator}{psModulePath}")

let configurePowerShellKernel () =
KernelInvocationContext.Current.DisplayAs("Configuring PowerShell Kernel for XPlot.Plotly integration.","text/markdown") |> ignore
registerPowerShellAccelerators()
registerPowerShellModule()

interface IKernelExtension with
member _.OnLoadAsync kernel =
registerPlotlyFormatters()
let visitKernels (subKernel: Kernel) =
match subKernel with
| :? PowerShellKernel -> configurePowerShellKernel()
| _ -> ()

kernel.VisitSubkernelsAndSelf(Action<Kernel>(visitKernels),true)
KernelInvocationContext.Current.DisplayAs("Installed support for XPlot.Plotly.","text/markdown") |> ignore
Task.CompletedTask

static member Load (kernel: Kernel) =
let getScriptElementWithRequire (script: string) =
let newScript = StringBuilder()
newScript.AppendLine("""<script type="text/javascript">""") |> ignore
newScript.AppendLine("""
var renderPlotly = function() {
var xplotRequire = require.config({context:'xplot-3.0.1',paths:{plotly:'https://cdn.plot.ly/plotly-1.49.2.min'}}) || require;
xplotRequire(['plotly'], function(Plotly) { """) |> ignore
newScript.AppendLine(script) |> ignore
newScript.AppendLine(@"});
};"
) |> ignore
newScript.AppendLine(JavascriptUtilities.GetCodeForEnsureRequireJs(Uri("https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"), "renderPlotly")) |> ignore
newScript.AppendLine("</script>") |> ignore
newScript.ToString()

let getHtml (chart: PlotlyChart) =
let styleStr = $"width: {chart.Width}px; height: {chart.Height}px;"
let divElem =
div [_style styleStr; _id chart.Id] [] |> RenderView.AsString.htmlDocument

let js = chart.GetInlineJS().Replace("<script>", String.Empty).Replace("</script>", String.Empty)
HtmlString(divElem + getScriptElementWithRequire js)

let registerPlotlyFormatters () =
Formatter.Register<PlotlyChart>(
Action<_,_>(fun (chart: PlotlyChart) (writer: TextWriter) ->
writer.Write(getHtml chart)),
HtmlFormatter.MimeType)

let registerPowerShellAccelerators () =
// Register type accelerators for Plotly.
let accelerator = typeof<PSObject>.Assembly.GetType("System.Management.Automation.TypeAccelerators")
let addMethod = accelerator.GetMethod("Add", [| typeof<string>; typeof<Type> |])
let addAccelerator (name, objectType) = addMethod.Invoke(null, [| name; objectType |]) |> ignore
typeof<Trace>.Assembly.GetTypes()
|> Array.filter typeof<Trace>.IsAssignableFrom
|> Array.map (fun trace -> ($"Graph.{trace.Name}", trace))
|> Array.append [| ("Layout", typeof<Layout.Layout>); ("Chart", typeof<Chart>) |]
|> Array.iter addAccelerator

let registerPowerShellModule () =
// Add Modules directory that contains the helper modules.
let psModulePath = Environment.GetEnvironmentVariable("PSModulePath")
let psXPlotModulePath = Path.Join(Path.GetDirectoryName(typeof<NewPlotlyChartCommand>.Assembly.Location), "Modules")
Environment.SetEnvironmentVariable("PSModulePath", $"{psXPlotModulePath}{Path.PathSeparator}{psModulePath}")

let configurePowerShellKernel () =
KernelInvocationContext.Current.DisplayAs("Configuring PowerShell Kernel for XPlot.Plotly integration.","text/markdown") |> ignore
registerPowerShellAccelerators()
registerPowerShellModule()

let visitKernels (subKernel: Kernel) =
match subKernel with
| :? PowerShellKernel -> configurePowerShellKernel()
| _ -> ()

registerPlotlyFormatters()
kernel.VisitSubkernelsAndSelf(Action<Kernel>(visitKernels),true)
KernelInvocationContext.Current.DisplayAs("Installed support for XPlot.Plotly.","text/markdown") |> ignore



92 changes: 48 additions & 44 deletions src/XPlot.Plotly.Interactive/XPlot.Plotly.Interactive.fsproj
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net7.0</TargetFramework>
<PackageId>XPlot.Plotly.Interactive</PackageId>
<IsPackable>true</IsPackable>
<PackageVersion>4.0.7</PackageVersion>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://fslab.org/XPlot/</PackageProjectUrl>
<RepositoryUrl>https://github.com/fslaborg/XPlot</RepositoryUrl>
<Authors>fsproject contributors</Authors>
<Description>Enables XPlot.Plotly to be used in .NET Interactive. When you use this package, you can embed Plotly charts directly into a .NET Interactive notebook!</Description>
<PackageIcon>logo.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<Compile Include="NewPlotlyChartCommand.fs" />
<Compile Include="KernelExtension.fs" />
<Compile Include="XPlotExtensions.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Giraffe.ViewEngine" Version="1.2.0" />
<PackageReference Include="Microsoft.DotNet.Interactive" Version="1.0.0-beta.23258.3" />
<PackageReference Include="Microsoft.DotNet.Interactive.PowerShell" Version="1.0.0-beta.23258.3" />
<PackageReference Include="Microsoft.Dotnet.Interactive.http" Version="1.0.0-beta.23258.3" />
</ItemGroup>

<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)Modules\**" Link="Modules\%(RecursiveDir)%(FileName)%(Extension)" PackagePath="contentFiles/any/any/Modules" PackageCopyToOutput="true" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)Modules\**" Link="Modules\%(RecursiveDir)%(FileName)%(Extension)" PackagePath="interactive-extensions/dotnet/Modules" PackageCopyToOutput="true" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<None Include="$(OutputPath)/XPlot.Plotly.Interactive.dll" Pack="true" PackagePath="interactive-extensions/dotnet" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../XPlot.Plotly/XPlot.Plotly.fsproj"/>
</ItemGroup>

<ItemGroup>
<None Include="..\..\docs\img\logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net7.0</TargetFramework>
<PackageId>XPlot.Plotly.Interactive</PackageId>
<IsPackable>true</IsPackable>
<PackageVersion>4.0.7</PackageVersion>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://fslab.org/XPlot/</PackageProjectUrl>
<RepositoryUrl>https://github.com/fslaborg/XPlot</RepositoryUrl>
<Authors>fsproject contributors</Authors>
<Description>Enables XPlot.Plotly to be used in .NET Interactive. When you use this package, you can embed Plotly charts directly into a .NET Interactive notebook!</Description>
cartermp marked this conversation as resolved.
Show resolved Hide resolved
<PackageIcon>logo.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<Compile Include="NewPlotlyChartCommand.fs" />
<Compile Include="KernelExtension.fs" />
<Compile Include="XPlotExtensions.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Giraffe.ViewEngine" Version="1.2.0" />
<PackageReference Include="Microsoft.DotNet.Interactive" Version="1.0.0-beta.23562.1" />
<PackageReference Include="Microsoft.DotNet.Interactive.Formatting" Version="1.0.0-beta.23562.1" />
<PackageReference Include="Microsoft.DotNet.Interactive.PowerShell" Version="1.0.0-beta.23562.1" />
</ItemGroup>

<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)Modules\**" Link="Modules\%(RecursiveDir)%(FileName)%(Extension)" PackagePath="contentFiles/any/any/Modules" PackageCopyToOutput="true" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)Modules\**" Link="Modules\%(RecursiveDir)%(FileName)%(Extension)" PackagePath="interactive-extensions/dotnet/Modules" PackageCopyToOutput="true" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<None Include="extension.dib" Pack="true" PackagePath="interactive-extensions/dotnet" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../XPlot.Plotly/XPlot.Plotly.fsproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\docs\img\logo.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="8.0.100" />
</ItemGroup>
Comment on lines +48 to +50
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also not pull in latest FSharp.Core here, esp. since it's an older TFM (.NET 7)


</Project>
5 changes: 2 additions & 3 deletions src/XPlot.Plotly.Interactive/XPlotExtensions.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace XPlot.Plotly.Interactive
namespace XPlot.Plotly.Interactive

open Microsoft.DotNet.Interactive
open System.Runtime.CompilerServices
Expand All @@ -7,7 +7,6 @@ open System.Runtime.CompilerServices
type XplotExtensions =
[<Extension>]
static member inline UseXplot<'a when 'a :> Kernel>(kernel: 'a) : 'a =
let extension = KernelExtension() :> IKernelExtension
extension.OnLoadAsync(kernel) |> ignore
KernelExtension.Load(kernel) |> ignore
kernel

3 changes: 3 additions & 0 deletions src/XPlot.Plotly.Interactive/extension.dib
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!csharp

XPlot.Plotly.Interactive.KernelExtension.Load(Microsoft.DotNet.Interactive.Kernel.Root);
4 changes: 2 additions & 2 deletions src/XPlot.Plotly/XPlot.Plotly.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<None Include="..\..\docs\img\logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.7.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Update="FSharp.Core" Version="8.0.100" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colombod I believe this needs to be bumped back down

<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions tools/BaselineGenerator/BaselineGenerator.fsproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="../../tests/TestData/XPlot.Plotly/Shapes.fs" Link="XPlot.Plotly/Shapes.fs" />
Expand Down