@vizejs/vite-plugin-musea 0.283.0 → 0.284.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3478,6 +3478,19 @@ function emptyTokens() {
3478
3478
  };
3479
3479
  }
3480
3480
  //#endregion
3481
+ //#region src/static-base.ts
3482
+ const TEXT_GALLERY_ASSET_EXT = /\.(?:css|html|js|map|mjs)$/u;
3483
+ function rewriteGalleryBase(source, basePath) {
3484
+ return source.replaceAll("/__musea__/", `${basePath.replace(/\/?$/, "/")}`);
3485
+ }
3486
+ function rewriteGalleryTextAssetBase(source, relativePath, basePath) {
3487
+ if (!TEXT_GALLERY_ASSET_EXT.test(relativePath)) return source;
3488
+ return rewriteGalleryBase(Buffer.from(source).toString("utf-8"), basePath);
3489
+ }
3490
+ function publicBasePathFromViteBase(viteBase, basePath) {
3491
+ return viteBase && viteBase !== "/" && viteBase !== "./" ? joinUrlPath(viteBase, basePath) : basePath;
3492
+ }
3493
+ //#endregion
3481
3494
  //#region src/static-export.ts
3482
3495
  const MUSEA_STATIC_BUILD_ENV = "VIZE_MUSEA_STATIC_BUILD";
3483
3496
  const VIRTUAL_STATIC_RUNTIME = "virtual:musea-static-runtime";
@@ -3588,7 +3601,7 @@ async function emitGalleryShell(emitFile, staticRoot, ctx, payload) {
3588
3601
  else emitFile({
3589
3602
  type: "asset",
3590
3603
  fileName: target,
3591
- source: content
3604
+ source: rewriteGalleryTextAssetBase(content, relative, ctx.basePath)
3592
3605
  });
3593
3606
  }
3594
3607
  }
@@ -3660,12 +3673,6 @@ function injectStaticGlobals(html, ctx, payload) {
3660
3673
  })}<\/script>`;
3661
3674
  return html.includes("</head>") ? html.replace("</head>", `${script}</head>`) : `${script}${html}`;
3662
3675
  }
3663
- function rewriteGalleryBase(html, basePath) {
3664
- return html.replaceAll("/__musea__/", `${basePath.replace(/\/?$/, "/")}`);
3665
- }
3666
- function publicBasePathFromViteBase(viteBase, basePath) {
3667
- return viteBase && viteBase !== "/" && viteBase !== "./" ? joinUrlPath(viteBase, basePath) : basePath;
3668
- }
3669
3676
  function emitRootRedirect(emitFile, staticRoot, basePath) {
3670
3677
  if (!staticRoot) return;
3671
3678
  const target = joinUrlPath(basePath, "");