@campfire-interactive/shell-header 0.13.1 → 0.13.2

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.d.ts CHANGED
@@ -356,13 +356,30 @@ declare function LocaleSwitcher({ currentLocale, supportedLocales, onLocaleChang
356
356
  declare function installBugReportCapture(): void;
357
357
 
358
358
  declare const appCatalog: AppDefinition[];
359
+ /**
360
+ * Read the environment segment out of a deployed suite hostname.
361
+ *
362
+ * The environment is always the label adjacent to the base domain, deduced
363
+ * from the host rather than matched against a fixed list so a new environment
364
+ * needs no code change here:
365
+ * - `<app>.campfiresuite.com` → '' (prod)
366
+ * - `<app>.<env>.campfiresuite.com` → `<env>` (dev / uat / qa / …)
367
+ * - `pr-<n>.<app>.<env>.campfiresuite.com` → `<env>` (PR previews run against
368
+ * a shared env; the `pr-<n>` / app labels ahead of it don't change that)
369
+ *
370
+ * Anything that isn't a `*.campfiresuite.com` host is treated as prod (empty
371
+ * segment) — the same conservative default as before.
372
+ */
373
+ declare function getEnvSegment(host: string): string;
359
374
  /**
360
375
  * Derive the app URL from the current hostname, optionally appending the
361
- * catalog entry's preferred landing path.
376
+ * catalog entry's preferred landing path. Keeps whatever environment the
377
+ * current host is on (see {@link getEnvSegment}) and just swaps in the target
378
+ * app id:
362
379
  * - localhost → localhost:<localPort>[<path>]
363
- * - *.dev.campfiresuite.com → <id>.dev.campfiresuite.com[<path>]
364
- * - *.campfiresuite.com → <id>.campfiresuite.com[<path>]
380
+ * - <app>.campfiresuite.com → <id>.campfiresuite.com[<path>] (prod)
381
+ * - <app>.<env>.campfiresuite.com → <id>.<env>.campfiresuite.com[<path>]
365
382
  */
366
383
  declare function getAppUrl(app: AppDefinition): string;
367
384
 
368
- export { type AboutInfo, type AppDefinition, type BugReportConfig, type BugReportContext, type BugReportPayload, type CurrencyOption, type LocaleOption, LocaleSwitcher, type NotificationItem, ShellHeader, type ShellHeaderProps, type ShellUser, type VersionInfo, appCatalog, getAppUrl, installBugReportCapture };
385
+ export { type AboutInfo, type AppDefinition, type BugReportConfig, type BugReportContext, type BugReportPayload, type CurrencyOption, type LocaleOption, LocaleSwitcher, type NotificationItem, ShellHeader, type ShellHeaderProps, type ShellUser, type VersionInfo, appCatalog, getAppUrl, getEnvSegment, installBugReportCapture };
package/dist/index.js CHANGED
@@ -120,6 +120,13 @@ var appCatalog = [
120
120
  path: "/admin/users"
121
121
  }
122
122
  ];
123
+ var BASE_DOMAIN = "campfiresuite.com";
124
+ function getEnvSegment(host) {
125
+ const suffix = `.${BASE_DOMAIN}`;
126
+ if (!host.endsWith(suffix)) return "";
127
+ const labels = host.slice(0, -suffix.length).split(".");
128
+ return labels.length > 1 ? labels[labels.length - 1] : "";
129
+ }
123
130
  function getAppUrl(app) {
124
131
  const host = typeof window !== "undefined" ? window.location.hostname : "";
125
132
  const protocol = typeof window !== "undefined" ? window.location.protocol : "https:";
@@ -127,10 +134,9 @@ function getAppUrl(app) {
127
134
  if (host === "localhost" || host === "127.0.0.1") {
128
135
  return app.localPort ? `http://localhost:${app.localPort}${path}` : "#";
129
136
  }
130
- if (host.includes(".dev.")) {
131
- return `${protocol}//${app.id}.dev.campfiresuite.com${path}`;
132
- }
133
- return `${protocol}//${app.id}.campfiresuite.com${path}`;
137
+ const env = getEnvSegment(host);
138
+ const infix = env ? `.${env}` : "";
139
+ return `${protocol}//${app.id}${infix}.${BASE_DOMAIN}${path}`;
134
140
  }
135
141
 
136
142
  // src/AppSwitcher.tsx
@@ -1506,5 +1512,6 @@ export {
1506
1512
  ShellHeader,
1507
1513
  appCatalog,
1508
1514
  getAppUrl,
1515
+ getEnvSegment,
1509
1516
  installBugReportCapture
1510
1517
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campfire-interactive/shell-header",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "Shared shell header with app switcher for Campfire Suite",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",