Skip to content

Commit

Permalink
Merge pull request #269 from dymaptic/feature/268-javascript-versioning
Browse files Browse the repository at this point in the history
adding/updating versioning
  • Loading branch information
AndersenBell authored Dec 4, 2023
2 parents ef7505e + 7499278 commit e0a1234
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
9 changes: 7 additions & 2 deletions src/dymaptic.GeoBlazor.Core/JsModuleManager.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using Microsoft.JSInterop;
using System.Security.Claims;

namespace dymaptic.GeoBlazor.Core;

internal static class JsModuleManager
{
public static async Task<IJSObjectReference> GetArcGisJsCore(IJSRuntime jsRuntime, IJSObjectReference? proModule, CancellationToken cancellationToken)
{
var version = System.Reflection.Assembly.GetAssembly(typeof(JsModuleManager))!.GetName().Version;

if (proModule is null)
{
return await jsRuntime
.InvokeAsync<IJSObjectReference>("import", cancellationToken,
"./_content/dymaptic.GeoBlazor.Core/js/arcGisJsInterop.js");
$"./_content/dymaptic.GeoBlazor.Core/js/arcGisJsInterop.js?v={version}");
}

return await proModule.InvokeAsync<IJSObjectReference>("getCore", cancellationToken);
Expand All @@ -21,14 +24,16 @@ public static async Task<IJSObjectReference> GetArcGisJsCore(IJSRuntime jsRuntim
/// </summary>
public static async Task<IJSObjectReference?> GetArcGisJsPro(IJSRuntime jsRuntime, CancellationToken cancellationToken)
{
var version = System.Reflection.Assembly.GetAssembly(typeof(JsModuleManager))!.GetName().Version;

LicenseType licenseType = Licensing.GetLicenseType();

switch ((int)licenseType)
{
case >= 100:

return await jsRuntime.InvokeAsync<IJSObjectReference>("import", cancellationToken,
"./_content/dymaptic.GeoBlazor.Pro/js/arcGisPro.js");
$"./_content/dymaptic.GeoBlazor.Pro/js/arcGisPro.js?v={version}");
default:
return null;
}
Expand Down
22 changes: 7 additions & 15 deletions src/dymaptic.GeoBlazor.Core/Model/AuthenticationManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using dymaptic.GeoBlazor.Core.Components.Views;
using dymaptic.GeoBlazor.Core.Objects;
using Microsoft.Extensions.Configuration;
using Microsoft.JSInterop;

Expand Down Expand Up @@ -106,7 +107,7 @@ public async Task<bool> Initialize()
_module = await arcGisJsInterop.InvokeAsync<IJSObjectReference>("getAuthenticationManager",
_cancellationTokenSource.Token, DotNetObjectReference.Create(this), ApiKey, AppId, PortalUrl);
}

return true;
}

Expand Down Expand Up @@ -167,20 +168,11 @@ public async Task<IJSObjectReference> GetArcGisJsInterop()
{
LicenseType licenseType = Licensing.GetLicenseType();

switch ((int)licenseType)
{
case >= 100:
// this is here to support the pro extension library
IJSObjectReference proModule = await _jsRuntime
.InvokeAsync<IJSObjectReference>("import", _cancellationTokenSource.Token,
"./_content/dymaptic.GeoBlazor.Pro/js/arcGisPro.js");

return await proModule.InvokeAsync<IJSObjectReference>("getCore");
default:
return await _jsRuntime
.InvokeAsync<IJSObjectReference>("import", _cancellationTokenSource.Token,
"./_content/dymaptic.GeoBlazor.Core/js/arcGisJsInterop.js");
}
var token = new CancellationToken();
IJSObjectReference? arcGisPro = await JsModuleManager.GetArcGisJsPro(_jsRuntime, token);
IJSObjectReference arcGisJsInterop = await JsModuleManager.GetArcGisJsCore(_jsRuntime, arcGisPro, token);

return arcGisJsInterop;
}

private readonly IJSRuntime _jsRuntime;
Expand Down

0 comments on commit e0a1234

Please sign in to comment.