-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from dymaptic/bug/262-pro-wasm
fix pro wasm bug, refactor JS module loading
- Loading branch information
Showing
6 changed files
with
66 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,56 @@ | ||
using Microsoft.JSInterop; | ||
|
||
#if NET7_0_OR_GREATER | ||
using System.Runtime.InteropServices.JavaScript; | ||
#endif | ||
|
||
namespace dymaptic.GeoBlazor.Core; | ||
|
||
internal static class JsModuleManager | ||
{ | ||
public static async Task<IJSObjectReference> GetJsModule(IJSRuntime jsRuntime) | ||
public static async Task<IJSObjectReference> GetArcGisJsCore(IJSRuntime jsRuntime, IJSObjectReference? proModule, CancellationToken cancellationToken) | ||
{ | ||
LicenseType licenseType = Licensing.GetLicenseType(); | ||
|
||
if (proModule is null) | ||
{ | ||
#if NET7_0_OR_GREATER | ||
if (OperatingSystem.IsBrowser()) | ||
{ | ||
#pragma warning disable CA1416 | ||
await JSHost.ImportAsync("arcGisJsInterop", "../_content/dymaptic.GeoBlazor.Core/js/arcGisJsInterop.js"); | ||
#pragma warning restore CA1416 | ||
} | ||
#endif | ||
return await jsRuntime | ||
.InvokeAsync<IJSObjectReference>("import", cancellationToken, "./_content/dymaptic.GeoBlazor.Core/js/arcGisJsInterop.js"); | ||
} | ||
|
||
return await proModule.InvokeAsync<IJSObjectReference>("getCore"); | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves the main entry point for the optional GeoBlazor Pro JavaScript module. | ||
/// </summary> | ||
public static async Task<IJSObjectReference?> GetArcGisJsPro(IJSRuntime jsRuntime, CancellationToken cancellationToken) | ||
{ | ||
LicenseType licenseType = Licensing.GetLicenseType(); | ||
IJSObjectReference jsModule; | ||
|
||
switch ((int)licenseType) | ||
{ | ||
case >= 100: | ||
// this is here to support the pro extension library | ||
IJSObjectReference proModule = await jsRuntime | ||
.InvokeAsync<IJSObjectReference>("import", | ||
"./_content/dymaptic.GeoBlazor.Pro/js/arcGisPro.js"); | ||
jsModule = await proModule.InvokeAsync<IJSObjectReference>("getCore"); | ||
|
||
break; | ||
|
||
#if NET7_0_OR_GREATER | ||
if (OperatingSystem.IsBrowser()) | ||
{ | ||
#pragma warning disable CA1416 | ||
await JSHost.ImportAsync("arcGisPro", "../_content/dymaptic.GeoBlazor.Pro/js/arcGisPro.js"); | ||
#pragma warning restore CA1416 | ||
} | ||
#endif | ||
return await jsRuntime.InvokeAsync<IJSObjectReference>("import", cancellationToken, | ||
"./_content/dymaptic.GeoBlazor.Pro/js/arcGisPro.js"); | ||
default: | ||
jsModule = await jsRuntime | ||
.InvokeAsync<IJSObjectReference>("import", | ||
"./_content/dymaptic.GeoBlazor.Core/js/arcGisJsInterop.js"); | ||
|
||
break; | ||
return null; | ||
} | ||
|
||
return jsModule; | ||
} | ||
} |
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