@herdingbits/trailhead-types 0.0.4 → 0.0.5
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 +13 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @herdingbits/trailhead-types
|
|
2
2
|
|
|
3
|
-
TypeScript
|
|
3
|
+
TypeScript types for Trailhead SPAs. Provides shell API types for independent applications.
|
|
4
4
|
|
|
5
5
|
**Note:** This package is auto-generated from `@herdingbits/trailhead-core` during build. Do not edit these files directly.
|
|
6
6
|
|
|
@@ -8,6 +8,8 @@ TypeScript type definitions for Trailhead single page applications (SPAs).
|
|
|
8
8
|
|
|
9
9
|
Provides TypeScript types for single page applications (SPAs) that integrate with the Trailhead shell. Install this as a dev dependency to get type checking and IntelliSense for the shell API.
|
|
10
10
|
|
|
11
|
+
**Your SPAs don't import the shell** - they access it via `window.shell`. These types just help TypeScript understand what's available.
|
|
12
|
+
|
|
11
13
|
## Installation
|
|
12
14
|
|
|
13
15
|
```bash
|
|
@@ -21,11 +23,18 @@ npm install --save-dev @herdingbits/trailhead-types
|
|
|
21
23
|
```typescript
|
|
22
24
|
import type { ShellAPI } from '@herdingbits/trailhead-types';
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
// Declare global type
|
|
27
|
+
declare global {
|
|
28
|
+
interface Window {
|
|
29
|
+
shell: ShellAPI;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function init() {
|
|
25
34
|
// TypeScript knows the shell API
|
|
26
|
-
shell.feedback.success('App loaded!');
|
|
35
|
+
window.shell.feedback.success('App loaded!');
|
|
27
36
|
|
|
28
|
-
const result = await shell.http.get('/api/data');
|
|
37
|
+
const result = await window.shell.http.get('/api/data');
|
|
29
38
|
if (result.success) {
|
|
30
39
|
console.log(result.data);
|
|
31
40
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herdingbits/trailhead-types",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "TypeScript
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "TypeScript types for Trailhead SPAs. Provides shell API types for independent applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./public-api.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
"url": "https://github.com/herdingbits/trailhead.git",
|
|
34
34
|
"directory": "packages/types"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|