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

adding/updating javascript file versioning #269

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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