@ms-cloudpack/common-types-browser 0.5.6 → 0.6.0

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.
Files changed (3) hide show
  1. package/README.md +7 -10
  2. package/index.d.ts +23 -27
  3. package/package.json +5 -1
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
- ## Directly: You can import types directly from this package
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. However, if you are writing code that runs in the browser, you should consider the second option.
11
+ This is useful for server code, since it **does not** define the `window.__cloudpack` global.
12
12
 
13
- ## Configure tsconfig.json to have @ms-cloudpack/common-types by default
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/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
- declare global {
64
- interface Window {
65
- __cloudpack?: {
66
- /** Get page load time for telemetry (defined in `getPageLoadTime.inline.ts`) */
67
- getPageLoadTime?: () => Promise<number>;
68
- /** Get cache hit ratio for telemetry (defined in `getBrowserCacheRatio.inline.ts`) */
69
- getBrowserCacheRatio?: () => {
70
- ratio: number;
71
- hit: number;
72
- total: number;
73
- };
74
- /** Set up a Cloudpack app in side-loading scenarios (defined in `bootstrap.inline.ts`) */
75
- bootstrap?: (input: BootstrapInput) => void;
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
- /** Whether the bootstrap script has run (defined in `bootstrap.inline.ts`). */
78
- hasBootstrapRun?: boolean;
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
- /** Client-side context object for a Cloudpack session (defined by the app server while rendering HTML routes) */
81
- pageSessionContext?: PageSessionContext;
82
- };
83
- /** Track uncaught errors (defined in `errorHandler.inline.ts` and read by the overlay) */
84
- __pageErrors: {
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.5.6",
3
+ "version": "0.6.0",
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": {