@herdingbits/trailhead-core 0.0.15 → 0.0.16

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/README.md CHANGED
@@ -34,7 +34,8 @@ import { YourAdapter } from '@herdingbits/trailhead-your-design-system';
34
34
 
35
35
  const shell = new Trailhead({
36
36
  adapter: new YourAdapter(),
37
- basePath: '/app',
37
+ appBasePath: '/app', // URL prefix where SPAs are hosted
38
+ shellUrl: '/app', // URL where shell.js and navigation.json are served (defaults to appBasePath)
38
39
  apiUrl: 'https://api.example.com'
39
40
  });
40
41
  ```
@@ -61,7 +61,7 @@ export interface DesignSystemAdapter {
61
61
  * Called once at shell startup. Register web component base paths,
62
62
  * inject global stylesheets, or perform any other design-system-specific setup.
63
63
  */
64
- init(basePath: string): Promise<void>;
64
+ init(shellUrl: string): Promise<void>;
65
65
  /** Feedback implementation backed by this adapter's design system components. */
66
66
  feedback: FeedbackAdapter;
67
67
  }
package/dist/shell.d.ts CHANGED
@@ -9,12 +9,12 @@ import type { DesignSystemAdapter } from "./adapters/types.js";
9
9
  export interface ShellConfig {
10
10
  /** Design system adapter that backs all shell UI — toasts, dialogs, and busy overlays. */
11
11
  adapter: DesignSystemAdapter;
12
- /** URL prefix under which the shell is hosted (e.g., `"/sample/trailhead"`). Used to strip the prefix from routes and prepend it to SPA asset URLs. */
13
- basePath?: string;
12
+ /** URL prefix under which SPAs are hosted (e.g., `"/sample/trailhead"`). Used to strip the prefix from routes, construct SPA asset URLs, and build navigation links. */
13
+ appBasePath?: string;
14
14
  /** Base URL prepended to all SPA HTTP requests made via `shell.http`. */
15
15
  apiUrl?: string;
16
- /** URL from which shell static assets (e.g., `navigation.json`) are fetched. Defaults to `basePath`. */
17
- shellResourceUrl?: string;
16
+ /** URL from which the shell bundle and static assets (e.g., `navigation.json`) are fetched. Defaults to `appBasePath`. */
17
+ shellUrl?: string;
18
18
  }
19
19
  /**
20
20
  * The Trailhead shell. Bootstraps the micro-frontend host by loading navigation config,
@@ -31,9 +31,9 @@ export interface ShellConfig {
31
31
  export declare class Trailhead {
32
32
  private navigation;
33
33
  private routeChangeCallbacks;
34
- /** URL prefix under which the shell is hosted. Empty string when hosted at the root. */
35
- readonly basePath: string;
36
- private readonly shellResourceUrl;
34
+ /** URL prefix under which SPAs are hosted. Empty string when hosted at the root. */
35
+ readonly appBasePath: string;
36
+ private readonly shellUrl;
37
37
  /** The active design system adapter supplying UI components to the shell. */
38
38
  readonly adapter: DesignSystemAdapter;
39
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAY,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAI/D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,0FAA0F;IAC1F,OAAO,EAAE,mBAAmB,CAAC;IAE7B,uJAAuJ;IACvJ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,wGAAwG;IACxG,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,oBAAoB,CAAqC;IAEjE,wFAAwF;IACxF,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAE1C,6EAA6E;IAC7E,SAAgB,OAAO,EAAE,mBAAmB,CAAC;IAE7C;;;;;OAKG;gBACS,MAAM,EAAE,WAAW;IAO/B;;;OAGG;IACI,aAAa,IAAI,OAAO,EAAE;IAIjC;;OAEG;YACW,IAAI;IAwBlB;;OAEG;YACW,WAAW;IAUzB;;OAEG;IACH,OAAO,CAAC,SAAS;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YAAY;IAMpB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;OAEG;IACH,OAAO,CAAC,WAAW;IAsBnB;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;YACW,UAAU;CAqDzB"}
package/dist/shell.js CHANGED
@@ -22,8 +22,8 @@ export class Trailhead {
22
22
  constructor(config) {
23
23
  this.navigation = [];
24
24
  this.routeChangeCallbacks = [];
25
- this.basePath = config.basePath || "";
26
- this.shellResourceUrl = config.shellResourceUrl || this.basePath;
25
+ this.appBasePath = config.appBasePath || "";
26
+ this.shellUrl = config.shellUrl || this.appBasePath;
27
27
  this.adapter = config.adapter;
28
28
  this.init(config.apiUrl);
29
29
  }
@@ -59,7 +59,7 @@ export class Trailhead {
59
59
  */
60
60
  async initAdapter() {
61
61
  try {
62
- await this.adapter.init(this.basePath);
62
+ await this.adapter.init(this.shellUrl);
63
63
  console.log(`[Trailhead] Initialized ${this.adapter.name} adapter v${this.adapter.version}`);
64
64
  }
65
65
  catch (error) {
@@ -149,7 +149,7 @@ export class Trailhead {
149
149
  */
150
150
  async loadNavigation() {
151
151
  try {
152
- const response = await fetch(`${this.shellResourceUrl}/navigation.json`);
152
+ const response = await fetch(`${this.shellUrl}/navigation.json`);
153
153
  this.navigation = await response.json();
154
154
  }
155
155
  catch (error) {
@@ -166,7 +166,7 @@ export class Trailhead {
166
166
  return;
167
167
  nav.innerHTML = this.navigation
168
168
  .map((item) => `
169
- <a href="${this.basePath}${item.path}"
169
+ <a href="${this.appBasePath}${item.path}"
170
170
  class="shell-nav-item"
171
171
  data-path="${item.path}"
172
172
  data-app="${item.app}">
@@ -197,15 +197,15 @@ export class Trailhead {
197
197
  * Navigate to path
198
198
  */
199
199
  navigate(path) {
200
- window.location.href = this.basePath + path;
200
+ window.location.href = this.appBasePath + path;
201
201
  }
202
202
  /**
203
203
  * Handle route change
204
204
  */
205
205
  handleRoute() {
206
206
  let path = window.location.pathname;
207
- if (this.basePath && path.startsWith(this.basePath)) {
208
- path = path.substring(this.basePath.length) || "/";
207
+ if (this.appBasePath && path.startsWith(this.appBasePath)) {
208
+ path = path.substring(this.appBasePath.length) || "/";
209
209
  }
210
210
  const navItem = this.navigation.find((item) => path.startsWith(item.path));
211
211
  if (navItem) {
@@ -244,19 +244,19 @@ export class Trailhead {
244
244
  return;
245
245
  root.innerHTML = `<div class="shell-loading">Loading...</div>`;
246
246
  const isDev = window.__SHELL_DEV__ === true;
247
- const appBasePath = this.basePath + appPath;
247
+ const appBasePath = this.appBasePath + appPath;
248
248
  try {
249
249
  if (isDev) {
250
250
  // ✅ DEV PATH — Vite-native, HMR-compatible
251
251
  const mod = await import(
252
252
  /* @vite-ignore */
253
- `${this.basePath}${appPath}/src/index.ts`);
253
+ `${this.appBasePath}${appPath}/src/index.ts`);
254
254
  root.innerHTML = "";
255
255
  mod.AppMount(root, appBasePath);
256
256
  return;
257
257
  }
258
- const pluginUrl = `${this.basePath}${appPath}/app.js`;
259
- const pluginCss = `${this.basePath}${appPath}/${appName}.css`;
258
+ const pluginUrl = `${this.appBasePath}${appPath}/app.js`;
259
+ const pluginCss = `${this.appBasePath}${appPath}/${appName}.css`;
260
260
  // Load CSS
261
261
  const link = document.createElement("link");
262
262
  link.rel = "stylesheet";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herdingbits/trailhead-core",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "Simple application shell that orchestrates multiple SPAs. No webpack magic, just the browser's native module system.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",