@ms-cloudpack/common-types-browser 0.2.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 +26 -0
  2. package/index.d.ts +35 -0
  3. package/package.json +26 -0
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @ms-cloudpack/common-types-browser
2
+
3
+ This package provides types that are specific to the browser environment. There are two ways to use this package.
4
+
5
+ ## Directly: You can import types directly from this package
6
+
7
+ ```typescript
8
+ import { PageSessionContext } from '@ms-cloudpack/common-types-browser';
9
+ ```
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.
12
+
13
+ ## Configure tsconfig.json to have @ms-cloudpack/common-types by default
14
+
15
+ ```json
16
+ {
17
+ "extends": "@ms-cloudpack/scripts/tsconfig.browser.json",
18
+ "include": ["./src"],
19
+ "compilerOptions": {
20
+ "types": ["@ms-cloudpack/common-types-browser"],
21
+ "customConditions": ["browser"]
22
+ }
23
+ }
24
+ ```
25
+
26
+ This will make the types from this package available by default in your browser code.
package/index.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ export {}; // Make this a module
2
+
3
+ export interface PageSessionContext {
4
+ sessionId: string;
5
+ apiUrl: string;
6
+ currentSequence: number;
7
+ bundleServerUrl: string;
8
+ }
9
+
10
+ export interface BootstrapInput {
11
+ inlineScripts: string[];
12
+ overlayScript: string;
13
+ importMap: {
14
+ imports: Record<string, string>;
15
+ scopes?: Record<string, Record<string, string>>;
16
+ };
17
+ pageSessionContext: PageSessionContext;
18
+ entryScript?: string;
19
+ }
20
+
21
+ declare global {
22
+ interface Window {
23
+ __cloudpack?: {
24
+ getPageLoadTime?: () => Promise<number>;
25
+ getBrowserCacheRatio?: () => number;
26
+ bootstrap?: (input: BootstrapInput) => void;
27
+ pageSessionContext?: PageSessionContext;
28
+ };
29
+ __pageErrors: {
30
+ uncaughtErrors: ErrorEvent[];
31
+ uncaughtRejections: PromiseRejectionEvent[];
32
+ unregister: () => void;
33
+ };
34
+ }
35
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@ms-cloudpack/common-types-browser",
3
+ "version": "0.2.0",
4
+ "description": "The Cloudpack overlay ux.",
5
+ "license": "MIT",
6
+ "main": "",
7
+ "types": "index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "scripts": {
15
+ "api": "cloudpack-scripts api",
16
+ "lint:update": "cloudpack-scripts lint-update",
17
+ "lint": "cloudpack-scripts lint"
18
+ },
19
+ "devDependencies": {
20
+ "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
21
+ "@ms-cloudpack/scripts": "^0.0.1"
22
+ },
23
+ "files": [
24
+ "index.d.ts"
25
+ ]
26
+ }