@mercurjs/dashboard-sdk 2.1.0-canary.6 → 2.1.0-canary.8

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.cjs CHANGED
@@ -699,7 +699,14 @@ function resolvePluginExtensions(plugins, configDir, appType) {
699
699
  }
700
700
  return extensions;
701
701
  }
702
- async function loadMedusaConfig(medusaConfigPath, root) {
702
+ function trimTrailingSlashes(value) {
703
+ let end = value.length;
704
+ while (end > 0 && value.charCodeAt(end - 1) === 47) {
705
+ end -= 1;
706
+ }
707
+ return end === value.length ? value : value.slice(0, end);
708
+ }
709
+ async function loadMedusaConfig(medusaConfigPath, root, options) {
703
710
  try {
704
711
  const mod = await getFileExports(medusaConfigPath);
705
712
  const medusaConfig = mod.default ?? mod;
@@ -707,6 +714,18 @@ async function loadMedusaConfig(medusaConfigPath, root) {
707
714
  const configDir = import_path5.default.dirname(medusaConfigPath);
708
715
  let base;
709
716
  let appType = "admin";
717
+ let vendorAppUrl;
718
+ const vendorModule = modules.vendor_ui;
719
+ const vendorPath = vendorModule?.options?.path ?? "/seller";
720
+ if (options.vendorUrl) {
721
+ vendorAppUrl = trimTrailingSlashes(options.vendorUrl);
722
+ } else if (options.isDevelopment) {
723
+ const vendorHost = vendorModule?.options?.viteDevServerHost ?? "localhost";
724
+ const vendorPort = vendorModule?.options?.viteDevServerPort ?? 7001;
725
+ vendorAppUrl = `http://${vendorHost}:${vendorPort}${vendorPath}`;
726
+ } else {
727
+ vendorAppUrl = vendorPath;
728
+ }
710
729
  for (const key of UI_MODULE_KEYS) {
711
730
  const value = modules[key];
712
731
  if (!value || typeof value !== "object" || !value.options?.appDir)
@@ -722,7 +741,7 @@ async function loadMedusaConfig(medusaConfigPath, root) {
722
741
  (plugin) => plugin.resolve !== "@medusajs/draft-order"
723
742
  ) ?? [];
724
743
  const pluginExtensions = resolvePluginExtensions(plugins, configDir, appType);
725
- return { base, pluginExtensions };
744
+ return { base, pluginExtensions, vendorAppUrl };
726
745
  } catch {
727
746
  return { pluginExtensions: [] };
728
747
  }
@@ -734,13 +753,18 @@ function mercurDashboardPlugin(pluginConfig) {
734
753
  name: "@mercurjs/dashboard-sdk",
735
754
  async config(viteConfig) {
736
755
  root = viteConfig.root || process.cwd();
756
+ const isDevelopment = (viteConfig.mode || process.env.NODE_ENV || "development") !== "production";
737
757
  const medusaConfigPath = import_path5.default.resolve(
738
758
  root,
739
759
  pluginConfig.medusaConfigPath
740
760
  );
741
- const { base, pluginExtensions } = await loadMedusaConfig(
761
+ const { base, pluginExtensions, vendorAppUrl } = await loadMedusaConfig(
742
762
  medusaConfigPath,
743
- root
763
+ root,
764
+ {
765
+ isDevelopment,
766
+ vendorUrl: pluginConfig.vendorUrl
767
+ }
744
768
  );
745
769
  const srcDir = import_path5.default.join(root, "src");
746
770
  const backendUrl = pluginConfig.backendUrl ?? "http://localhost:9000";
@@ -756,7 +780,8 @@ function mercurDashboardPlugin(pluginConfig) {
756
780
  base: config.base,
757
781
  define: {
758
782
  __BACKEND_URL__: JSON.stringify(config.backendUrl),
759
- __BASE__: JSON.stringify(config.base || "/")
783
+ __BASE__: JSON.stringify(config.base || "/"),
784
+ __VENDOR_URL__: JSON.stringify(vendorAppUrl || "")
760
785
  },
761
786
  optimizeDeps: {
762
787
  exclude: [
package/dist/index.d.cts CHANGED
@@ -23,6 +23,19 @@ interface MercurConfig {
23
23
  * @default "http://localhost:9000"
24
24
  */
25
25
  backendUrl?: string;
26
+ /**
27
+ * Absolute base URL for the vendor dashboard, including any path prefix
28
+ * (for example `https://vendors.example.com/seller`).
29
+ *
30
+ * The plugin does not read `.env` files on its own. Load env in your
31
+ * app's `vite.config.ts` and pass the value here when you need
32
+ * cross-origin links such as seller invite URLs.
33
+ *
34
+ * If omitted, the plugin falls back to vendor module dev server
35
+ * detection in development and to the configured vendor path in
36
+ * production.
37
+ */
38
+ vendorUrl?: string;
26
39
  /** Dashboard display name. */
27
40
  name?: string;
28
41
  /** Path to a logo asset for the dashboard. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercurjs/dashboard-sdk",
3
- "version": "2.1.0-canary.6",
3
+ "version": "2.1.0-canary.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mercurjs/mercur",