-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced source-gen for dependency of callbacks.
- Loading branch information
1 parent
d3b3bc0
commit 0fbb558
Showing
30 changed files
with
775 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/Blazor.Geolocation.WebAssembly/Blazor.Geolocation.WebAssembly.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Description>Source generated JavaScript interop for the browser's geolocation API compatible with Blazor WebAssembly.</Description> | ||
<Copyright>Copyright © David Pine. All rights reserved. Licensed under the MIT License.</Copyright> | ||
<NeutralLanguage>en-US</NeutralLanguage> | ||
<CurrentDate>$([System.DateTime]::Now.ToString(yyyyMMdd))</CurrentDate> | ||
<ClientVersion Condition=" '$(IsPreview)' != 'true' ">$(ClientOfficialVersion)</ClientVersion> | ||
<ClientVersion Condition=" '$(IsPreview)' == 'true' ">$(ClientPreviewVersion)</ClientVersion> | ||
<VersionSuffix Condition=" '$(IsNightly)' == 'true' ">nightly-$(CurrentDate)</VersionSuffix> | ||
<VersionSuffix Condition=" '$(IsPreview)' == 'true' ">preview</VersionSuffix> | ||
<Version Condition=" '$(VersionSuffix)' == '' ">$(ClientVersion)</Version> | ||
<Version Condition=" '$(VersionSuffix)' != '' ">$(ClientVersion)-$(VersionSuffix)</Version> | ||
<FileVersion>$(ClientVersion)</FileVersion> | ||
<Authors>David Pine</Authors> | ||
<!--<TreatWarningsAsErrors>true</TreatWarningsAsErrors>--> | ||
<AssemblyName>Blazor.Geolocation.WebAssembly</AssemblyName> | ||
<Title>A C# source-generated Razor class library implementation of the native browser's geolocation API available as a DI-ready service.</Title> | ||
<PackageId>Blazor.LocalStorage.WebAssembly</PackageId> | ||
<PackageTags>dotnet;dotnetcore;csharp;blazor;webassembly;wasm;generators;sourcegen;roslyn;</PackageTags> | ||
<PackageReleaseNotes></PackageReleaseNotes> | ||
<PackageProjectUrl>https://github.com/IEvangelist/blazorators</PackageProjectUrl> | ||
<PublishRepositoryUrl Condition=" '$(ProjectRef)' != 'True' ">true</PublishRepositoryUrl> | ||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo> | ||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<ShippingScope>External</ShippingScope> | ||
<SigningType>Product</SigningType> | ||
<DebugType>embedded</DebugType> | ||
<IncludeSymbols>false</IncludeSymbols> | ||
<IncludeSource>false</IncludeSource> | ||
<RootNamespace>Blazor.Geolocation.WebAssembly</RootNamespace> | ||
<NoWarn>NU5125;NU5039;</NoWarn> | ||
<Optimize Condition="'$(Configuration)'=='Release'">true</Optimize> | ||
<RepositoryUrl>https://github.com/IEvangelist/blazorators</RepositoryUrl> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<RepositoryType>git</RepositoryType> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder> | ||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<IsPackable>true</IsPackable> | ||
<PackageIcon>logo.png</PackageIcon> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<SupportedPlatform Include="browser" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="MinVer" Version="2.5.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Blazor.SourceGenerators\Blazor.SourceGenerators.csproj" OutputItemType="Analyzer" SetTargetFramework="TargetFramework=netstandard2.0" ReferenceOutputAssembly="false" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Label="Files"> | ||
<None Include="..\..\LICENSE" Pack="true" PackagePath="\" /> | ||
<None Include="..\..\README.md" Pack="true" PackagePath="\" /> | ||
<None Include="..\..\logo.png" Pack="true" PackagePath="\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
12 changes: 12 additions & 0 deletions
12
src/Blazor.Geolocation.WebAssembly/GeolocationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) David Pine. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.JSInterop; | ||
|
||
[JSAutoInterop( | ||
TypeName = "Geolocation", | ||
Implementation = "window.navigator.geolocation", | ||
Url = "https://developer.mozilla.org/docs/Web/API/Geolocation")] | ||
internal static partial class GeolocationExtensions | ||
{ | ||
} |
43 changes: 43 additions & 0 deletions
43
src/Blazor.Geolocation.WebAssembly/wwwroot/blazorators.geolocation.g.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// TODO: source-generate this. | ||
|
||
const getCurrentPosition = ( | ||
dotnetObj, | ||
successMethodName, | ||
errorMethodName, | ||
options) => { | ||
navigator.geolocation.getCurrentPosition( | ||
position => { | ||
const result = { | ||
Timestamp: new Date(position.timestamp).toISOString(), | ||
Coords: { | ||
Accuracy: position.coords.accuracy, | ||
Altitude: position.coords.altitude, | ||
AltitudeAccuracy: position.coords.altitudeAccuracy, | ||
Heading: position.coords.heading, | ||
Latitude: position.coords.latitude, | ||
Longitude: position.coords.longitude, | ||
Speed: position.coords.speed | ||
} | ||
}; | ||
var json = JSON.stringify(result); | ||
dotnetObj.invokeMethodAsync(successMethodName, result); | ||
}, | ||
error => dotnetObj.invokeMethodAsync(errorMethodName, error), | ||
options); | ||
} | ||
|
||
const watchPosition = ( | ||
dotnetObj, | ||
successMethodName, | ||
errorMethodName, | ||
options) => { | ||
return navigator.geolocation.watchPosition( | ||
position => dotnetObj.invokeMethodAsync(successMethodName, position), | ||
error => dotnetObj.invokeMethodAsync(errorMethodName, error), | ||
options); | ||
} | ||
|
||
window.blazorators = { | ||
getCurrentPosition, | ||
watchPosition | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.