Skip to content

v0.7.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@mingyaulee mingyaulee released this 23 Sep 06:39
· 124 commits to main since this release
  • Use config file instead of replacing tokens in JavaScript files
  • Script assets are now included as static web assets/RCL assets instead of linked files
  • Fix error when resolving XML static web asset path that contains relative path (i.e. basepath/../filepath)
  • Update JsBind.Net from v0.1.4 to v0.2.5 and WebExtensions.Net from v0.9.0 to v0.9.2

Breaking changes:

  • MsBuild property LinkBrowserExtensionAssetsPath is removed
  • Projects with content script need to use app.js pre-initialization script
  • Option is removed from the service dependency registration
  • Path to ContentScript.js and Core.js is changed from "BrowserExtensionScripts" to "content/Blazor.BrowserExtension"
  • Global variable in JavaScript to change initialization behaviour is now within the "BlazorBrowserExtension" object

Migration Guide:

  1. Update Program.cs to remove the configuration action in the .AddBrowserExtensionServices() parameter

    // Before
    builder.Services.AddBrowserExtensionServices(options =>
    {
        options.ProjectNamespace = typeof(Program).Namespace;
    });
    // After
    builder.Services.AddBrowserExtensionServices();
  2. Update index.html and manifest.json and anywhere with reference to the scripts from this package from "BrowserExtensionScripts/" to "content/Blazor.BrowserExtension/"

    <!-- Before -->
    <script src="BrowserExtensionScripts/Core.js"></script>
    <!-- After -->
    <script src="content/Blazor.BrowserExtension/Core.js"></script>
  3. "BrowserExtensionScripts/*" can be removed from the web_accessible_resources key in manifest.json

Projects with content scripts

  1. Add a new file named app.js under the directory wwwroot
  2. Add the following code into the new file.
    if (globalThis.BlazorBrowserExtension.BrowserExtension.Mode === globalThis.BlazorBrowserExtension.Modes.ContentScript) {
      const appDiv = document.createElement("div");
      appDiv.id = "My_Unique_Extension_App_Id"; // this ID should be the same as the container ID in the index.html file
      document.body.appendChild(appDiv);
    }
  3. Add "app.js" to the web_accessible_resources key in manifest.json

Projects with custom initialization behaviour
Move the initialization logic into app.js file. Refer to the readme to read on the way to change initialization behaviour in this version.