feat: Add Controls/FullScreen bindings

Provides a button that when clicked fills up the full screen with the map.
It is supported by 82% of browser [ref](https://caniuse.com/fullscreen).

Also changes TargetFramework to netstandard2.1 for better compat
This commit is contained in:
2025-08-19 15:33:09 +02:00
parent 203adc0de8
commit 854fecd670
16 changed files with 78 additions and 107 deletions

View File

@@ -18,7 +18,7 @@ let versionFile = Path.getFullName ".version"
Target.create "Clean" (fun _ -> Shell.cleanDir distPath)
Target.create "InstallClient" (fun _ ->
run npm "install" "."
run bun "install" "."
run dotnet "tool restore" "."
)

View File

@@ -72,16 +72,16 @@ let createProcess exe arg dir =
|> CreateProcess.ensureExitCode
let dotnet = createProcess "dotnet"
let npm =
let npmPath =
match ProcessUtils.tryFindFileOnPath "npm" with
let bun =
let bunPath =
match ProcessUtils.tryFindFileOnPath "bun" with
| Some path -> path
| None ->
"npm was not found in path. Please install it and make sure it's available from your path. " +
"bun was not found in path. Please install it and make sure it's available from your path. " +
"See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
|> failwith
createProcess npmPath
createProcess bunPath
let run proc arg dir =
proc arg dir

View File

@@ -10,7 +10,7 @@
"rollForward": false
},
"fantomas": {
"version": "7.0.0",
"version": "7.0.3",
"commands": [
"fantomas"
],

View File

@@ -1,21 +1,27 @@
FROM mcr.microsoft.com/dotnet/sdk:9.0
# Add keys and sources lists
RUN apt-get update && apt-get install -y ca-certificates gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
ENV NODE_MAJOR=20
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
# Bun version
ARG BUN_INSTALL=/usr/local
ARG BUN_VERSION=bun-v1.2.16
# Install node, 7zip, git, process tools
RUN apt-get update \
&& apt-get install -y nodejs p7zip-full git procps ssh-client
&& apt-get install -y nodejs unzip p7zip-full git procps ssh-client
# Install Bun
RUN set -eux; \
curl -fsSL https://bun.sh/install > /usr/local/bin/install-bun \
&& chmod +x /usr/local/bin/install-bun \
&& /usr/local/bin/install-bun $BUN_VERSION debug-info
# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Add dotnet tools to path to pick up fake and paket installation
ENV PATH="/root/.dotnet/tools:${PATH}"
# Copy endpoint specific user settings into container to specify
# .NET Core should be used as the runtime.
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
.fable/
.fake/
dist/
.vs/
obj/
bin/

View File

@@ -1,10 +1,11 @@
variables:
DEPLOY_NAME: default
DEPLOY_NAMESPACE: default
SDK_VERSION: 9.0
SKIP_TESTS: "true"
include:
- project: oceanbox/gitlab-ci
ref: main
ref: v4.1
file: DotnetPackage.gitlab-ci.yml
inputs:
project-name: Fable.OpenLayers
project-dir: .

View File

@@ -1,77 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D939B1CF-478F-4A38-B306-AEB5292814C0}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
LICENSE = LICENSE
Dockerfile = Dockerfile
EndProjectSection
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Build", "Build.fsproj", "{66B2CD7E-27CC-4011-88BF-B09F1317555A}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "src", "src/Fable.OpenLayers.fsproj", "{5B875512-A9C1-4F66-A880-E06351893933}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "test", "test\Tests.fsproj", "{1DD5605F-15E8-4814-A51F-04858B3EDD7B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Debug|x64.ActiveCfg = Debug|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Debug|x64.Build.0 = Debug|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Debug|x86.ActiveCfg = Debug|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Debug|x86.Build.0 = Debug|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Release|Any CPU.Build.0 = Release|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Release|x64.ActiveCfg = Release|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Release|x64.Build.0 = Release|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Release|x86.ActiveCfg = Release|Any CPU
{66B2CD7E-27CC-4011-88BF-B09F1317555A}.Release|x86.Build.0 = Release|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Debug|x64.ActiveCfg = Debug|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Debug|x64.Build.0 = Debug|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Debug|x86.ActiveCfg = Debug|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Debug|x86.Build.0 = Debug|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Release|Any CPU.Build.0 = Release|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Release|x64.ActiveCfg = Release|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Release|x64.Build.0 = Release|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Release|x86.ActiveCfg = Release|Any CPU
{5B875512-A9C1-4F66-A880-E06351893933}.Release|x86.Build.0 = Release|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Debug|x64.ActiveCfg = Debug|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Debug|x64.Build.0 = Debug|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Debug|x86.ActiveCfg = Debug|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Debug|x86.Build.0 = Debug|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Release|Any CPU.Build.0 = Release|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Release|x64.ActiveCfg = Release|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Release|x64.Build.0 = Release|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Release|x86.ActiveCfg = Release|Any CPU
{1DD5605F-15E8-4814-A51F-04858B3EDD7B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FDFC8500-74D4-4302-8ADC-D84EC240EEB9}
EndGlobalSection
EndGlobal

15
Fable.OpenLayers.slnx Normal file
View File

@@ -0,0 +1,15 @@
<Solution>
<Configurations>
<Platform Name="Any CPU" />
<Platform Name="x64" />
<Platform Name="x86" />
</Configurations>
<Folder Name="/Solution Items/">
<File Path="Dockerfile" />
<File Path="LICENSE" />
<File Path="README.md" />
</Folder>
<Project Path="Build.fsproj" />
<Project Path="src/Fable.OpenLayers.fsproj" />
<Project Path="test/Tests.fsproj" />
</Solution>

View File

@@ -1,5 +1,6 @@
{
"private": true,
"name": "Fable.OpenLayers",
"scripts": {
"install": "dotnet tool restore; dotnet femto src/",
"build": "dotnet fable src -o dist/",

View File

@@ -1,7 +1,10 @@
{ pkgs ? import <nixpkgs> {} }:
{
pkgs ? import <nixpkgs> { },
}:
pkgs.mkShell {
buildInputs = with pkgs; [
nodejs_20
packages = with pkgs; [
nodejs_20
bun
dotnetCorePackages.sdk_9_0_3xx
];
}
}

View File

@@ -40,3 +40,22 @@ module ScaleLine =
let scaleLine (options: ScaleLineProp seq) =
let opts = keyValueList CaseRules.LowerFirst options
createScaleLine opts
type fullscreen =
static member inline element (value: Browser.Types.Element) = Interop.mkFullScreenProp "element" value
static member inline render (value: unit -> unit) = Interop.mkFullScreenProp "render" value
static member inline target (value: Browser.Types.Element) = Interop.mkFullScreenProp "target" value
static member inline target (value: string) = Interop.mkFullScreenProp "target" value
static member inline label (value: string) = Interop.mkFullScreenProp "label" value
static member inline labelActive (value: string) = Interop.mkFullScreenProp "labelActive" value
static member inline tipLabel (value: string) = Interop.mkFullScreenProp "tipLabel" value
module FullScreen =
[<Import("default", "ol/control/FullScreen")>]
[<Emit("new FullScreen($1)")>]
let createFullScreen (opts: obj) : Control = jsNative
let fullScreen (options: FullScreenProp seq) =
let opts = keyValueList CaseRules.LowerFirst options
createFullScreen opts

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<IsPackable>true</IsPackable>
<PackageId>Fable.OpenLayers</PackageId>

View File

@@ -27,4 +27,5 @@ module Interop =
let inline mkRendererProp (key: string) (value: obj): RendererProp = unbox (key, value)
let inline mkGlRendererProp (key: string) (value: obj): GlRendererProp = unbox (key, value)
let inline mkGeometryProp (key: string) (value: obj): GeometryProp = unbox (key, value)
let inline mkTileJsonProp (key: string) (value: obj) : TileJsonProp = unbox (key, value)
let inline mkTileJsonProp (key: string) (value: obj) : TileJsonProp = unbox (key, value)
let inline mkFullScreenProp (key: string) (value: obj) : FullScreenProp = unbox (key, value)

View File

@@ -1,6 +1,6 @@
namespace Fable.OpenLayers
open System.Reflection.Metadata
// open System.Reflection.Metadata
open Fable.Core
open Fable.Core.JsInterop
open Fable.OpenLayers.Ol.Renderer

View File

@@ -45,6 +45,7 @@ type EasingFunction = float -> float
[<Erase>] type GlRendererProp = interface end
[<Erase>] type GeometryProp = interface end
[<Erase>] type TileJsonProp = interface end
[<Erase>] type FullScreenProp = interface end
[<AutoOpen>]
module Options =

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"dependencies": {
"net9.0": {
".NETStandard,Version=v2.1": {
"Fable.Browser.Dom": {
"type": "Direct",
"requested": "[2.18.0, )",
@@ -35,9 +35,9 @@
},
"FSharp.Core": {
"type": "Direct",
"requested": "[9.0.100, )",
"resolved": "9.0.100",
"contentHash": "ye8yagHGsH08H2Twno5GRWkSbrMtxK/SWiHuPcF+3nODpW65/VJ8RO0aWxp8n9+KQbmahg90wAEL3TEXjF0r6A=="
"requested": "[9.0.303, )",
"resolved": "9.0.303",
"contentHash": "6JlV8aD8qQvcmfoe/PMOxCHXc0uX4lR23u0fAyQtnVQxYULLoTZgwgZHSnRcuUHOvS3wULFWcwdnP1iwslH60g=="
},
"Fable.Browser.Blob": {
"type": "Transitive",