@ms-cloudpack/common-types-browser 0.5.6 → 0.6.1
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 +7 -10
- package/global.d.ts +11 -0
- package/index.d.ts +23 -27
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
# @ms-cloudpack/common-types-browser
|
|
2
2
|
|
|
3
|
-
This package provides types that are specific to the browser environment. There are two ways to use this package.
|
|
3
|
+
This package provides Cloudpack types that are specific to the browser environment. There are two ways to use this package.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Import types directly
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
8
|
import { PageSessionContext } from '@ms-cloudpack/common-types-browser';
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
This is useful for server code
|
|
11
|
+
This is useful for server code, since it **does not** define the `window.__cloudpack` global.
|
|
12
12
|
|
|
13
|
-
## Configure tsconfig.json to
|
|
13
|
+
## Configure tsconfig.json to include the globals
|
|
14
|
+
|
|
15
|
+
This makes `window.__cloudpack` and `window.__pageEvents` available to your code. (You can combine this with importing individual types as needed.)
|
|
14
16
|
|
|
15
17
|
```json
|
|
16
18
|
{
|
|
17
|
-
"extends": "@ms-cloudpack/scripts/tsconfig.browser.json",
|
|
18
|
-
"include": ["./src"],
|
|
19
19
|
"compilerOptions": {
|
|
20
|
-
"types": ["@ms-cloudpack/common-types-browser"]
|
|
21
|
-
"customConditions": ["browser"]
|
|
20
|
+
"types": ["@ms-cloudpack/common-types-browser/global"]
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
```
|
|
25
|
-
|
|
26
|
-
This will make the types from this package available by default in your browser code.
|
package/global.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CloudpackGlobal, PageErrorsGlobal } from './index.js';
|
|
2
|
+
|
|
3
|
+
export {}; // Make this a module
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
__cloudpack?: CloudpackGlobal;
|
|
8
|
+
/** Track uncaught errors (defined in `errorHandler.inline.ts` and read by the overlay) */
|
|
9
|
+
__pageErrors?: PageErrorsGlobal;
|
|
10
|
+
}
|
|
11
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export {}; // Make this a module
|
|
2
|
-
|
|
3
1
|
/** Client and server side object for Cloudpack to detect app-specific page load time entry */
|
|
4
2
|
export interface PageLoadTimePerformanceEntry {
|
|
5
3
|
/** The name of the performance mark/measure to query. */
|
|
@@ -60,31 +58,29 @@ export interface BootstrapInput {
|
|
|
60
58
|
entryScripts?: string[];
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
/** Types for `window.__cloudpack` */
|
|
62
|
+
export interface CloudpackGlobal {
|
|
63
|
+
/** Get page load time for telemetry (defined in `getPageLoadTime.inline.ts`) */
|
|
64
|
+
getPageLoadTime?: () => Promise<number>;
|
|
65
|
+
/** Get cache hit ratio for telemetry (defined in `getBrowserCacheRatio.inline.ts`) */
|
|
66
|
+
getBrowserCacheRatio?: () => {
|
|
67
|
+
ratio: number;
|
|
68
|
+
hit: number;
|
|
69
|
+
total: number;
|
|
70
|
+
};
|
|
71
|
+
/** Set up a Cloudpack app in side-loading scenarios (defined in `bootstrap.inline.ts`) */
|
|
72
|
+
bootstrap?: (input: BootstrapInput) => void;
|
|
73
|
+
|
|
74
|
+
/** Whether the bootstrap script has run (defined in `bootstrap.inline.ts`). */
|
|
75
|
+
hasBootstrapRun?: boolean;
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
/** Client-side context object for a Cloudpack session (defined by the app server while rendering HTML routes) */
|
|
78
|
+
pageSessionContext?: PageSessionContext;
|
|
79
|
+
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
uncaughtErrors: ErrorEvent[];
|
|
86
|
-
uncaughtRejections: PromiseRejectionEvent[];
|
|
87
|
-
unregister: () => void;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
81
|
+
/** Types for Cloudpack `window.__pageErrors` */
|
|
82
|
+
export interface PageErrorsGlobal {
|
|
83
|
+
uncaughtErrors: ErrorEvent[];
|
|
84
|
+
uncaughtRejections: PromiseRejectionEvent[];
|
|
85
|
+
unregister: () => void;
|
|
90
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/common-types-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Types for Cloudpack browser globals.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"types": "./index.d.ts",
|
|
10
10
|
"default": null
|
|
11
11
|
},
|
|
12
|
+
"./global": {
|
|
13
|
+
"types": "./global.d.ts",
|
|
14
|
+
"default": null
|
|
15
|
+
},
|
|
12
16
|
"./package.json": "./package.json"
|
|
13
17
|
},
|
|
14
18
|
"scripts": {
|
|
@@ -21,6 +25,6 @@
|
|
|
21
25
|
"@ms-cloudpack/scripts": "^0.0.1"
|
|
22
26
|
},
|
|
23
27
|
"files": [
|
|
24
|
-
"
|
|
28
|
+
"*.d.ts"
|
|
25
29
|
]
|
|
26
30
|
}
|