@volley/vwr-loader 1.1.0 → 1.3.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.
- package/README.md +7 -8
- package/dist/__mocks__/@datadog/browser-logs.d.ts +58 -0
- package/dist/__mocks__/@datadog/browser-logs.d.ts.map +1 -0
- package/dist/__mocks__/@datadog/browser-logs.js +34 -0
- package/dist/__mocks__/@datadog/browser-logs.js.map +1 -0
- package/dist/__mocks__/@datadog/browser-rum.d.ts +25 -0
- package/dist/__mocks__/@datadog/browser-rum.d.ts.map +1 -0
- package/dist/__mocks__/@datadog/browser-rum.js +25 -0
- package/dist/__mocks__/@datadog/browser-rum.js.map +1 -0
- package/dist/amplitudeFlagFetcher.d.ts +8 -3
- package/dist/amplitudeFlagFetcher.d.ts.map +1 -1
- package/dist/amplitudeFlagFetcher.js +14 -12
- package/dist/amplitudeFlagFetcher.js.map +1 -1
- package/dist/assets/intersection-observer-DAXvjMTZ.js +2 -0
- package/dist/assets/intersection-observer-DAXvjMTZ.js.map +1 -0
- package/dist/assets/profiler-BRmTNL9s.js +2 -0
- package/dist/assets/profiler-BRmTNL9s.js.map +1 -0
- package/dist/assets/resize-observer-DqyxKk7V.js +2 -0
- package/dist/assets/resize-observer-DqyxKk7V.js.map +1 -0
- package/dist/assets/startRecording-CuFdVhxx.js +3 -0
- package/dist/assets/startRecording-CuFdVhxx.js.map +1 -0
- package/dist/cli.js +42 -8
- package/dist/cli.js.map +1 -1
- package/dist/datadog.d.ts +19 -0
- package/dist/datadog.d.ts.map +1 -0
- package/dist/datadog.js +39 -0
- package/dist/datadog.js.map +1 -0
- package/dist/envDefaults.d.ts.map +1 -1
- package/dist/envDefaults.js +27 -2
- package/dist/envDefaults.js.map +1 -1
- package/dist/errors/InitializationError.d.ts +74 -0
- package/dist/errors/InitializationError.d.ts.map +1 -0
- package/dist/errors/InitializationError.js +77 -0
- package/dist/errors/InitializationError.js.map +1 -0
- package/dist/errors/ensureError.d.ts +2 -0
- package/dist/errors/ensureError.d.ts.map +1 -0
- package/dist/errors/ensureError.js +7 -0
- package/dist/errors/ensureError.js.map +1 -0
- package/dist/errors/index.d.ts +12 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +10 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/exitHandler.d.ts +32 -0
- package/dist/exitHandler.d.ts.map +1 -0
- package/dist/exitHandler.js +113 -0
- package/dist/exitHandler.js.map +1 -0
- package/dist/getDeviceId.d.ts +1 -2
- package/dist/getDeviceId.d.ts.map +1 -1
- package/dist/getDeviceId.js +17 -15
- package/dist/getDeviceId.js.map +1 -1
- package/dist/getEnvironment.d.ts +1 -2
- package/dist/getEnvironment.d.ts.map +1 -1
- package/dist/getEnvironment.js +4 -4
- package/dist/getEnvironment.js.map +1 -1
- package/dist/getShellVersion.d.ts +1 -2
- package/dist/getShellVersion.d.ts.map +1 -1
- package/dist/getShellVersion.js +4 -4
- package/dist/getShellVersion.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loadVwr.d.ts +4 -4
- package/dist/loadVwr.d.ts.map +1 -1
- package/dist/loadVwr.js +151 -37
- package/dist/loadVwr.js.map +1 -1
- package/dist/logger.d.ts +11 -6
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +107 -4
- package/dist/logger.js.map +1 -1
- package/dist/main.js +11 -1
- package/dist/main.js.map +1 -1
- package/dist/polyfills.d.ts +29 -0
- package/dist/polyfills.d.ts.map +1 -0
- package/dist/polyfills.js +32 -0
- package/dist/polyfills.js.map +1 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +5 -0
- package/dist/test-setup.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vwrConfig.d.ts +14 -2
- package/dist/vwrConfig.d.ts.map +1 -1
- package/dist/vwrConfig.js +74 -29
- package/dist/vwrConfig.js.map +1 -1
- package/package.json +61 -53
- package/src/__mocks__/@datadog/browser-logs.ts +35 -0
- package/src/__mocks__/@datadog/browser-rum.ts +27 -0
- package/src/amplitudeFlagFetcher.test.ts +28 -34
- package/src/amplitudeFlagFetcher.ts +22 -14
- package/src/datadog.ts +55 -0
- package/src/envDefaults.ts +32 -3
- package/src/errors/InitializationError.ts +105 -0
- package/src/errors/ensureError.ts +6 -0
- package/src/errors/index.ts +16 -0
- package/src/exitHandler.test.ts +179 -0
- package/src/exitHandler.ts +125 -0
- package/src/getDeviceId.test.ts +4 -5
- package/src/getDeviceId.ts +19 -18
- package/src/getEnvironment.test.ts +44 -106
- package/src/getEnvironment.ts +4 -5
- package/src/getShellVersion.test.ts +12 -6
- package/src/getShellVersion.ts +4 -7
- package/src/index.ts +0 -1
- package/src/loadVwr.test.ts +394 -0
- package/src/loadVwr.ts +243 -58
- package/src/logger.ts +118 -11
- package/src/main.test.ts +157 -0
- package/src/main.ts +99 -11
- package/src/polyfills.ts +32 -0
- package/src/test-setup.ts +5 -0
- package/src/types.ts +4 -0
- package/src/vite-env.d.ts +15 -1
- package/src/vwrConfig.test.ts +104 -34
- package/src/vwrConfig.ts +115 -37
package/README.md
CHANGED
|
@@ -36,8 +36,8 @@ pnpm build-loader --platform IOS_MOBILE --env dev --output ./dist-ios
|
|
|
36
36
|
- `--env`: Environment (`local`, `dev`, `staging`, `prod`)
|
|
37
37
|
- `--output`: Output directory for `index.html` and `main.js`
|
|
38
38
|
- `--hubUrl`: Override Hub URL (optional)
|
|
39
|
-
- `--vwrUrl`: Override VWR URL (optional)
|
|
40
39
|
- `--amplitudeKey`: Override Amplitude deployment key (optional)
|
|
40
|
+
- `--configUrl`: Override VWR Config URL (optional)
|
|
41
41
|
|
|
42
42
|
### Fetching Amplitude Flags
|
|
43
43
|
|
|
@@ -66,11 +66,11 @@ The package includes a `vwr-loader.html` template that can be used as the entry
|
|
|
66
66
|
3. Handles device ID resolution across platforms
|
|
67
67
|
4. Validates that build-time config was properly injected
|
|
68
68
|
|
|
69
|
-
**Build-time
|
|
70
|
-
- `
|
|
71
|
-
- `
|
|
72
|
-
- `
|
|
73
|
-
- `
|
|
69
|
+
**Build-time configuration** (injected via Vite `define`):
|
|
70
|
+
- `VITE_PLATFORM` - Platform name (SAMSUNG_TV, LG_TV, FIRE_TV, etc.)
|
|
71
|
+
- `VITE_AMPLITUDE_DEPLOYMENT_KEY` - Amplitude deployment key
|
|
72
|
+
- `VITE_HUB_URL` - Hub application URL
|
|
73
|
+
- `VITE_CONFIG_URL` - VWR config base URL
|
|
74
74
|
|
|
75
75
|
## CLI: build-loader
|
|
76
76
|
|
|
@@ -93,7 +93,6 @@ npx build-loader --platform <platform> --output <path> [--env <env>] [options]
|
|
|
93
93
|
|--------|-------------|
|
|
94
94
|
| `--env` | Environment: `local`, `dev`, `staging`, `prod` |
|
|
95
95
|
| `--hubUrl` | Override Hub URL |
|
|
96
|
-
| `--vwrUrl` | Override VWR URL |
|
|
97
96
|
| `--configUrl` | Override VWR Config URL |
|
|
98
97
|
| `--configFile` | Override VWR Config filename |
|
|
99
98
|
| `--amplitudeKey` | Override Amplitude deployment key |
|
|
@@ -139,7 +138,7 @@ Requires Chrome 66+ or equivalent browser with support for:
|
|
|
139
138
|
- Fetch API
|
|
140
139
|
- async/await
|
|
141
140
|
- AbortController
|
|
142
|
-
-
|
|
141
|
+
- uuidv4 library (for fallback device ID generation)
|
|
143
142
|
|
|
144
143
|
## API Reference
|
|
145
144
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export declare const datadogLogs: {
|
|
2
|
+
init: import("vitest").Mock<any, any>;
|
|
3
|
+
logger: {
|
|
4
|
+
debug: import("vitest").Mock<any, any>;
|
|
5
|
+
info: import("vitest").Mock<any, any>;
|
|
6
|
+
warn: import("vitest").Mock<any, any>;
|
|
7
|
+
error: import("vitest").Mock<any, any>;
|
|
8
|
+
log: import("vitest").Mock<any, any>;
|
|
9
|
+
setLevel: import("vitest").Mock<any, any>;
|
|
10
|
+
setHandler: import("vitest").Mock<any, any>;
|
|
11
|
+
setContext: import("vitest").Mock<any, any>;
|
|
12
|
+
addContext: import("vitest").Mock<any, any>;
|
|
13
|
+
removeContext: import("vitest").Mock<any, any>;
|
|
14
|
+
clearContext: import("vitest").Mock<any, any>;
|
|
15
|
+
getContext: import("vitest").Mock<[], {}>;
|
|
16
|
+
};
|
|
17
|
+
createLogger: import("vitest").Mock<[], {
|
|
18
|
+
debug: import("vitest").Mock<any, any>;
|
|
19
|
+
info: import("vitest").Mock<any, any>;
|
|
20
|
+
warn: import("vitest").Mock<any, any>;
|
|
21
|
+
error: import("vitest").Mock<any, any>;
|
|
22
|
+
log: import("vitest").Mock<any, any>;
|
|
23
|
+
setLevel: import("vitest").Mock<any, any>;
|
|
24
|
+
setHandler: import("vitest").Mock<any, any>;
|
|
25
|
+
setContext: import("vitest").Mock<any, any>;
|
|
26
|
+
addContext: import("vitest").Mock<any, any>;
|
|
27
|
+
removeContext: import("vitest").Mock<any, any>;
|
|
28
|
+
clearContext: import("vitest").Mock<any, any>;
|
|
29
|
+
getContext: import("vitest").Mock<[], {}>;
|
|
30
|
+
}>;
|
|
31
|
+
getLogger: import("vitest").Mock<[], {
|
|
32
|
+
debug: import("vitest").Mock<any, any>;
|
|
33
|
+
info: import("vitest").Mock<any, any>;
|
|
34
|
+
warn: import("vitest").Mock<any, any>;
|
|
35
|
+
error: import("vitest").Mock<any, any>;
|
|
36
|
+
log: import("vitest").Mock<any, any>;
|
|
37
|
+
setLevel: import("vitest").Mock<any, any>;
|
|
38
|
+
setHandler: import("vitest").Mock<any, any>;
|
|
39
|
+
setContext: import("vitest").Mock<any, any>;
|
|
40
|
+
addContext: import("vitest").Mock<any, any>;
|
|
41
|
+
removeContext: import("vitest").Mock<any, any>;
|
|
42
|
+
clearContext: import("vitest").Mock<any, any>;
|
|
43
|
+
getContext: import("vitest").Mock<[], {}>;
|
|
44
|
+
}>;
|
|
45
|
+
setUser: import("vitest").Mock<any, any>;
|
|
46
|
+
setUserProperty: import("vitest").Mock<any, any>;
|
|
47
|
+
removeUserProperty: import("vitest").Mock<any, any>;
|
|
48
|
+
clearUser: import("vitest").Mock<any, any>;
|
|
49
|
+
getUser: import("vitest").Mock<[], {}>;
|
|
50
|
+
setGlobalContext: import("vitest").Mock<any, any>;
|
|
51
|
+
setGlobalContextProperty: import("vitest").Mock<any, any>;
|
|
52
|
+
removeGlobalContextProperty: import("vitest").Mock<any, any>;
|
|
53
|
+
clearGlobalContext: import("vitest").Mock<any, any>;
|
|
54
|
+
getGlobalContext: import("vitest").Mock<[], {}>;
|
|
55
|
+
getInitConfiguration: import("vitest").Mock<[], {}>;
|
|
56
|
+
getInternalContext: import("vitest").Mock<[], {}>;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=browser-logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-logs.d.ts","sourceRoot":"","sources":["../../../src/__mocks__/@datadog/browser-logs.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBvB,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { vi } from "vitest";
|
|
2
|
+
const mockLogger = {
|
|
3
|
+
debug: vi.fn(),
|
|
4
|
+
info: vi.fn(),
|
|
5
|
+
warn: vi.fn(),
|
|
6
|
+
error: vi.fn(),
|
|
7
|
+
log: vi.fn(),
|
|
8
|
+
setLevel: vi.fn(),
|
|
9
|
+
setHandler: vi.fn(),
|
|
10
|
+
setContext: vi.fn(),
|
|
11
|
+
addContext: vi.fn(),
|
|
12
|
+
removeContext: vi.fn(),
|
|
13
|
+
clearContext: vi.fn(),
|
|
14
|
+
getContext: vi.fn(() => ({})),
|
|
15
|
+
};
|
|
16
|
+
export const datadogLogs = {
|
|
17
|
+
init: vi.fn(),
|
|
18
|
+
logger: mockLogger,
|
|
19
|
+
createLogger: vi.fn(() => mockLogger),
|
|
20
|
+
getLogger: vi.fn(() => mockLogger),
|
|
21
|
+
setUser: vi.fn(),
|
|
22
|
+
setUserProperty: vi.fn(),
|
|
23
|
+
removeUserProperty: vi.fn(),
|
|
24
|
+
clearUser: vi.fn(),
|
|
25
|
+
getUser: vi.fn(() => ({})),
|
|
26
|
+
setGlobalContext: vi.fn(),
|
|
27
|
+
setGlobalContextProperty: vi.fn(),
|
|
28
|
+
removeGlobalContextProperty: vi.fn(),
|
|
29
|
+
clearGlobalContext: vi.fn(),
|
|
30
|
+
getGlobalContext: vi.fn(() => ({})),
|
|
31
|
+
getInitConfiguration: vi.fn(() => ({})),
|
|
32
|
+
getInternalContext: vi.fn(() => ({})),
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=browser-logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-logs.js","sourceRoot":"","sources":["../../../src/__mocks__/@datadog/browser-logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE3B,MAAM,UAAU,GAAG;IACf,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;IACd,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;IACd,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;IACjB,UAAU,EAAE,EAAE,CAAC,EAAE,EAAE;IACnB,UAAU,EAAE,EAAE,CAAC,EAAE,EAAE;IACnB,UAAU,EAAE,EAAE,CAAC,EAAE,EAAE;IACnB,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE;IACtB,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE;IACrB,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;CAChC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,MAAM,EAAE,UAAU;IAClB,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC;IACrC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC;IAClC,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE;IAChB,eAAe,EAAE,EAAE,CAAC,EAAE,EAAE;IACxB,kBAAkB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC3B,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;IAClB,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1B,gBAAgB,EAAE,EAAE,CAAC,EAAE,EAAE;IACzB,wBAAwB,EAAE,EAAE,CAAC,EAAE,EAAE;IACjC,2BAA2B,EAAE,EAAE,CAAC,EAAE,EAAE;IACpC,kBAAkB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC3B,gBAAgB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACnC,oBAAoB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACvC,kBAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;CACxC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const datadogRum: {
|
|
2
|
+
init: import("vitest").Mock<any, any>;
|
|
3
|
+
startSessionReplayRecording: import("vitest").Mock<any, any>;
|
|
4
|
+
stopSessionReplayRecording: import("vitest").Mock<any, any>;
|
|
5
|
+
addAction: import("vitest").Mock<any, any>;
|
|
6
|
+
addError: import("vitest").Mock<any, any>;
|
|
7
|
+
addTiming: import("vitest").Mock<any, any>;
|
|
8
|
+
setUser: import("vitest").Mock<any, any>;
|
|
9
|
+
setUserProperty: import("vitest").Mock<any, any>;
|
|
10
|
+
removeUserProperty: import("vitest").Mock<any, any>;
|
|
11
|
+
clearUser: import("vitest").Mock<any, any>;
|
|
12
|
+
setGlobalContext: import("vitest").Mock<any, any>;
|
|
13
|
+
setGlobalContextProperty: import("vitest").Mock<any, any>;
|
|
14
|
+
removeGlobalContextProperty: import("vitest").Mock<any, any>;
|
|
15
|
+
clearGlobalContext: import("vitest").Mock<any, any>;
|
|
16
|
+
getGlobalContext: import("vitest").Mock<[], {}>;
|
|
17
|
+
getUser: import("vitest").Mock<[], {}>;
|
|
18
|
+
getInitConfiguration: import("vitest").Mock<[], {}>;
|
|
19
|
+
getInternalContext: import("vitest").Mock<[], {}>;
|
|
20
|
+
addFeatureFlagEvaluation: import("vitest").Mock<any, any>;
|
|
21
|
+
startView: import("vitest").Mock<any, any>;
|
|
22
|
+
stopView: import("vitest").Mock<any, any>;
|
|
23
|
+
};
|
|
24
|
+
export type RumGlobal = typeof datadogRum;
|
|
25
|
+
//# sourceMappingURL=browser-rum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-rum.d.ts","sourceRoot":"","sources":["../../../src/__mocks__/@datadog/browser-rum.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;CAsBtB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { vi } from "vitest";
|
|
2
|
+
export const datadogRum = {
|
|
3
|
+
init: vi.fn(),
|
|
4
|
+
startSessionReplayRecording: vi.fn(),
|
|
5
|
+
stopSessionReplayRecording: vi.fn(),
|
|
6
|
+
addAction: vi.fn(),
|
|
7
|
+
addError: vi.fn(),
|
|
8
|
+
addTiming: vi.fn(),
|
|
9
|
+
setUser: vi.fn(),
|
|
10
|
+
setUserProperty: vi.fn(),
|
|
11
|
+
removeUserProperty: vi.fn(),
|
|
12
|
+
clearUser: vi.fn(),
|
|
13
|
+
setGlobalContext: vi.fn(),
|
|
14
|
+
setGlobalContextProperty: vi.fn(),
|
|
15
|
+
removeGlobalContextProperty: vi.fn(),
|
|
16
|
+
clearGlobalContext: vi.fn(),
|
|
17
|
+
getGlobalContext: vi.fn(() => ({})),
|
|
18
|
+
getUser: vi.fn(() => ({})),
|
|
19
|
+
getInitConfiguration: vi.fn(() => ({})),
|
|
20
|
+
getInternalContext: vi.fn(() => ({})),
|
|
21
|
+
addFeatureFlagEvaluation: vi.fn(),
|
|
22
|
+
startView: vi.fn(),
|
|
23
|
+
stopView: vi.fn(),
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=browser-rum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-rum.js","sourceRoot":"","sources":["../../../src/__mocks__/@datadog/browser-rum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE3B,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,2BAA2B,EAAE,EAAE,CAAC,EAAE,EAAE;IACpC,0BAA0B,EAAE,EAAE,CAAC,EAAE,EAAE;IACnC,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;IAClB,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;IACjB,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;IAClB,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE;IAChB,eAAe,EAAE,EAAE,CAAC,EAAE,EAAE;IACxB,kBAAkB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC3B,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE,CAAC,EAAE,EAAE;IACzB,wBAAwB,EAAE,EAAE,CAAC,EAAE,EAAE;IACjC,2BAA2B,EAAE,EAAE,CAAC,EAAE,EAAE;IACpC,kBAAkB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC3B,gBAAgB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACnC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1B,oBAAoB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACvC,kBAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACrC,wBAAwB,EAAE,EAAE,CAAC,EAAE,EAAE;IACjC,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;IAClB,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;CACpB,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type Logger } from "./logger";
|
|
2
1
|
export interface AmplitudeConfig {
|
|
3
2
|
apiKey: string;
|
|
4
3
|
apiUrl?: string;
|
|
@@ -7,6 +6,11 @@ export interface AmplitudeConfig {
|
|
|
7
6
|
export interface FlagResult {
|
|
8
7
|
"vwr-enabled": boolean;
|
|
9
8
|
}
|
|
9
|
+
export declare class FlagFetchError extends Error {
|
|
10
|
+
readonly cause?: Error | undefined;
|
|
11
|
+
readonly name = "FlagFetchError";
|
|
12
|
+
constructor(message: string, cause?: Error | undefined);
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* Fetch feature flags from Amplitude Experiment REST API.
|
|
12
16
|
*
|
|
@@ -19,7 +23,8 @@ export interface FlagResult {
|
|
|
19
23
|
* @param config - Amplitude configuration
|
|
20
24
|
* @param shellVersion - Shell version for flag targeting
|
|
21
25
|
* @param logger - Optional logger, defaults to console
|
|
22
|
-
* @returns Flag values
|
|
26
|
+
* @returns Flag values on success
|
|
27
|
+
* @throws FlagFetchError on timeout or network error
|
|
23
28
|
*/
|
|
24
|
-
export declare function fetchAmplitudeFlags(deviceId: string, platform: string, config: AmplitudeConfig, shellVersion: string
|
|
29
|
+
export declare function fetchAmplitudeFlags(deviceId: string, platform: string, config: AmplitudeConfig, shellVersion: string): Promise<FlagResult>;
|
|
25
30
|
//# sourceMappingURL=amplitudeFlagFetcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplitudeFlagFetcher.d.ts","sourceRoot":"","sources":["../src/amplitudeFlagFetcher.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"amplitudeFlagFetcher.d.ts","sourceRoot":"","sources":["../src/amplitudeFlagFetcher.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACvB,aAAa,EAAE,OAAO,CAAA;CACzB;AAED,qBAAa,cAAe,SAAQ,KAAK;aAKjB,KAAK,CAAC,EAAE,KAAK;IAJjC,SAAgB,IAAI,oBAAmB;gBAGnC,OAAO,EAAE,MAAM,EACC,KAAK,CAAC,EAAE,KAAK,YAAA;CAKpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,mBAAmB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,CAAC,CA8DrB"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export class FlagFetchError extends Error {
|
|
2
|
+
constructor(message, cause) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.cause = cause;
|
|
5
|
+
this.name = "FlagFetchError";
|
|
6
|
+
Object.setPrototypeOf(this, FlagFetchError.prototype);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Fetch feature flags from Amplitude Experiment REST API.
|
|
4
11
|
*
|
|
@@ -11,9 +18,10 @@ import { defaultLogger } from "./logger";
|
|
|
11
18
|
* @param config - Amplitude configuration
|
|
12
19
|
* @param shellVersion - Shell version for flag targeting
|
|
13
20
|
* @param logger - Optional logger, defaults to console
|
|
14
|
-
* @returns Flag values
|
|
21
|
+
* @returns Flag values on success
|
|
22
|
+
* @throws FlagFetchError on timeout or network error
|
|
15
23
|
*/
|
|
16
|
-
export async function fetchAmplitudeFlags(deviceId, platform, config, shellVersion
|
|
24
|
+
export async function fetchAmplitudeFlags(deviceId, platform, config, shellVersion) {
|
|
17
25
|
var _a, _b, _c;
|
|
18
26
|
const { apiKey, apiUrl = "https://api.lab.amplitude.com/v1/vardata", timeout = 2000, } = config;
|
|
19
27
|
// Build context with user_properties
|
|
@@ -51,17 +59,11 @@ export async function fetchAmplitudeFlags(deviceId, platform, config, shellVersi
|
|
|
51
59
|
}
|
|
52
60
|
catch (error) {
|
|
53
61
|
clearTimeout(timeoutId);
|
|
54
|
-
// Provide clear
|
|
62
|
+
// Provide clear error message for abort vs other errors
|
|
55
63
|
if (error instanceof Error && error.name === "AbortError") {
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
logger.warn("[Shell] Amplitude flag fetch failed:", { error });
|
|
64
|
+
throw new FlagFetchError(`Amplitude flag fetch timed out after ${timeout}ms`);
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
"vwr-enabled": false,
|
|
64
|
-
};
|
|
66
|
+
throw new FlagFetchError("Amplitude flag fetch failed", error instanceof Error ? error : undefined);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
//# sourceMappingURL=amplitudeFlagFetcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplitudeFlagFetcher.js","sourceRoot":"","sources":["../src/amplitudeFlagFetcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"amplitudeFlagFetcher.js","sourceRoot":"","sources":["../src/amplitudeFlagFetcher.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAGrC,YACI,OAAe,EACC,KAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAA;QAFE,UAAK,GAAL,KAAK,CAAQ;QAJjB,SAAI,GAAG,gBAAgB,CAAA;QAOnC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;IACzD,CAAC;CACJ;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACrC,QAAgB,EAChB,QAAgB,EAChB,MAAuB,EACvB,YAAoB;;IAEpB,MAAM,EACF,MAAM,EACN,MAAM,GAAG,0CAA0C,EACnD,OAAO,GAAG,IAAI,GACjB,GAAG,MAAM,CAAA;IAEV,qCAAqC;IACrC,MAAM,OAAO,GAAG;QACZ,eAAe,EAAE;YACb,YAAY,EAAE,QAAQ;YACtB,qBAAqB,EAAE,YAAY;SACtC;KACJ,CAAA;IAED,yBAAyB;IACzB,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QAC/B,OAAO,EAAE,QAAQ;QACjB,SAAS,EAAE,aAAa;QACxB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KACnC,CAAC,CAAA;IAEF,sEAAsE;IACtE,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;IACxC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,CAAA;IAE/D,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,IAAI,MAAM,EAAE,EAAE;YAChD,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACL,aAAa,EAAE,WAAW,MAAM,EAAE;aACrC;YACD,MAAM,EAAE,UAAU,CAAC,MAAM;SAC5B,CAAC,CAAA;QAEF,YAAY,CAAC,SAAS,CAAC,CAAA;QAEvB,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;QAChE,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAElC,OAAO;YACH,aAAa,EACT,MAAA,MAAA,MAAA,IAAI,CAAC,aAAa,CAAC,0CAAE,OAAO,0CAAG,aAAa,CAAC,mCAAI,KAAK;SAC7D,CAAA;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,YAAY,CAAC,SAAS,CAAC,CAAA;QAEvB,wDAAwD;QACxD,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACxD,MAAM,IAAI,cAAc,CACpB,wCAAwC,OAAO,IAAI,CACtD,CAAA;QACL,CAAC;QAED,MAAM,IAAI,cAAc,CACpB,6BAA6B,EAC7B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAC7C,CAAA;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){if(typeof window!="object")return;if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype){"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});return}function p(t){try{return t.defaultView&&t.defaultView.frameElement||null}catch(e){return null}}var f=function(t){for(var e=t,i=p(e);i;)e=i.ownerDocument,i=p(e);return e}(window.document),g=[],v=null,c=null;function b(t){this.time=t.time,this.target=t.target,this.rootBounds=_(t.rootBounds),this.boundingClientRect=_(t.boundingClientRect),this.intersectionRect=_(t.intersectionRect||m()),this.isIntersecting=!!t.intersectionRect;var e=this.boundingClientRect,i=e.width*e.height,n=this.intersectionRect,r=n.width*n.height;i?this.intersectionRatio=Number((r/i).toFixed(4)):this.intersectionRatio=this.isIntersecting?1:0}function o(t,e){var i=e||{};if(typeof t!="function")throw new Error("callback must be a function");if(i.root&&i.root.nodeType!=1&&i.root.nodeType!=9)throw new Error("root must be a Document or Element");this._checkForIntersections=x(this._checkForIntersections.bind(this),this.THROTTLE_TIMEOUT),this._callback=t,this._observationTargets=[],this._queuedEntries=[],this._rootMarginValues=this._parseRootMargin(i.rootMargin),this.thresholds=this._initThresholds(i.threshold),this.root=i.root||null,this.rootMargin=this._rootMarginValues.map(function(n){return n.value+n.unit}).join(" "),this._monitoringDocuments=[],this._monitoringUnsubscribes=[]}o.prototype.THROTTLE_TIMEOUT=100,o.prototype.POLL_INTERVAL=null,o.prototype.USE_MUTATION_OBSERVER=!0,o._setupCrossOriginUpdater=function(){return v||(v=function(t,e){!t||!e?c=m():c=I(t,e),g.forEach(function(i){i._checkForIntersections()})}),v},o._resetCrossOriginUpdater=function(){v=null,c=null},o.prototype.observe=function(t){var e=this._observationTargets.some(function(i){return i.element==t});if(!e){if(!(t&&t.nodeType==1))throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(t.ownerDocument),this._checkForIntersections()}},o.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter(function(e){return e.element!=t}),this._unmonitorIntersections(t.ownerDocument),this._observationTargets.length==0&&this._unregisterInstance()},o.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()},o.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},o.prototype._initThresholds=function(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter(function(i,n,r){if(typeof i!="number"||isNaN(i)||i<0||i>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return i!==r[n-1]})},o.prototype._parseRootMargin=function(t){var e=t||"0px",i=e.split(/\s+/).map(function(n){var r=/^(-?\d*\.?\d+)(px|%)$/.exec(n);if(!r)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(r[1]),unit:r[2]}});return i[1]=i[1]||i[0],i[2]=i[2]||i[0],i[3]=i[3]||i[1],i},o.prototype._monitorIntersections=function(t){var e=t.defaultView;if(e&&this._monitoringDocuments.indexOf(t)==-1){var i=this._checkForIntersections,n=null,r=null;this.POLL_INTERVAL?n=e.setInterval(i,this.POLL_INTERVAL):(y(e,"resize",i,!0),y(t,"scroll",i,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in e&&(r=new e.MutationObserver(i),r.observe(t,{attributes:!0,childList:!0,characterData:!0,subtree:!0}))),this._monitoringDocuments.push(t),this._monitoringUnsubscribes.push(function(){var h=t.defaultView;h&&(n&&h.clearInterval(n),E(h,"resize",i,!0)),E(t,"scroll",i,!0),r&&r.disconnect()});var u=this.root&&(this.root.ownerDocument||this.root)||f;if(t!=u){var s=p(t);s&&this._monitorIntersections(s.ownerDocument)}}},o.prototype._unmonitorIntersections=function(t){var e=this._monitoringDocuments.indexOf(t);if(e!=-1){var i=this.root&&(this.root.ownerDocument||this.root)||f,n=this._observationTargets.some(function(s){var h=s.element.ownerDocument;if(h==t)return!0;for(;h&&h!=i;){var a=p(h);if(h=a&&a.ownerDocument,h==t)return!0}return!1});if(!n){var r=this._monitoringUnsubscribes[e];if(this._monitoringDocuments.splice(e,1),this._monitoringUnsubscribes.splice(e,1),r(),t!=i){var u=p(t);u&&this._unmonitorIntersections(u.ownerDocument)}}}},o.prototype._unmonitorAllIntersections=function(){var t=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var e=0;e<t.length;e++)t[e]()},o.prototype._checkForIntersections=function(){if(!(!this.root&&v&&!c)){var t=this._rootIsInDom(),e=t?this._getRootRect():m();this._observationTargets.forEach(function(i){var n=i.element,r=d(n),u=this._rootContainsTarget(n),s=i.entry,h=t&&u&&this._computeTargetAndRootIntersection(n,r,e),a=null;this._rootContainsTarget(n)?(!v||this.root)&&(a=e):a=m();var l=i.entry=new b({time:M(),target:n,boundingClientRect:r,rootBounds:a,intersectionRect:h});s?t&&u?this._hasCrossedThreshold(s,l)&&this._queuedEntries.push(l):s&&s.isIntersecting&&this._queuedEntries.push(l):this._queuedEntries.push(l)},this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)}},o.prototype._computeTargetAndRootIntersection=function(t,e,i){if(window.getComputedStyle(t).display!="none"){for(var n=e,r=w(t),u=!1;!u&&r;){var s=null,h=r.nodeType==1?window.getComputedStyle(r):{};if(h.display=="none")return null;if(r==this.root||r.nodeType==9)if(u=!0,r==this.root||r==f)v&&!this.root?!c||c.width==0&&c.height==0?(r=null,s=null,n=null):s=c:s=i;else{var a=w(r),l=a&&d(a),O=a&&this._computeTargetAndRootIntersection(a,l,i);l&&O?(r=a,s=I(l,O)):(r=null,n=null)}else{var D=r.ownerDocument;r!=D.body&&r!=D.documentElement&&h.overflow!="visible"&&(s=d(r))}if(s&&(n=L(s,n)),!n)break;r=r&&w(r)}return n}},o.prototype._getRootRect=function(){var t;if(this.root&&!R(this.root))t=d(this.root);else{var e=R(this.root)?this.root:f,i=e.documentElement,n=e.body;t={top:0,left:0,right:i.clientWidth||n.clientWidth,width:i.clientWidth||n.clientWidth,bottom:i.clientHeight||n.clientHeight,height:i.clientHeight||n.clientHeight}}return this._expandRectByRootMargin(t)},o.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map(function(n,r){return n.unit=="px"?n.value:n.value*(r%2?t.width:t.height)/100}),i={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};return i.width=i.right-i.left,i.height=i.bottom-i.top,i},o.prototype._hasCrossedThreshold=function(t,e){var i=t&&t.isIntersecting?t.intersectionRatio||0:-1,n=e.isIntersecting?e.intersectionRatio||0:-1;if(i!==n)for(var r=0;r<this.thresholds.length;r++){var u=this.thresholds[r];if(u==i||u==n||u<i!=u<n)return!0}},o.prototype._rootIsInDom=function(){return!this.root||T(f,this.root)},o.prototype._rootContainsTarget=function(t){var e=this.root&&(this.root.ownerDocument||this.root)||f;return T(e,t)&&(!this.root||e==t.ownerDocument)},o.prototype._registerInstance=function(){g.indexOf(this)<0&&g.push(this)},o.prototype._unregisterInstance=function(){var t=g.indexOf(this);t!=-1&&g.splice(t,1)};function M(){return window.performance&&performance.now&&performance.now()}function x(t,e){var i=null;return function(){i||(i=setTimeout(function(){t(),i=null},e))}}function y(t,e,i,n){typeof t.addEventListener=="function"?t.addEventListener(e,i,n):typeof t.attachEvent=="function"&&t.attachEvent("on"+e,i)}function E(t,e,i,n){typeof t.removeEventListener=="function"?t.removeEventListener(e,i,n):typeof t.detachEvent=="function"&&t.detachEvent("on"+e,i)}function L(t,e){var i=Math.max(t.top,e.top),n=Math.min(t.bottom,e.bottom),r=Math.max(t.left,e.left),u=Math.min(t.right,e.right),s=u-r,h=n-i;return s>=0&&h>=0&&{top:i,bottom:n,left:r,right:u,width:s,height:h}||null}function d(t){var e;try{e=t.getBoundingClientRect()}catch(i){}return e?(e.width&&e.height||(e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}),e):m()}function m(){return{top:0,bottom:0,left:0,right:0,width:0,height:0}}function _(t){return!t||"x"in t?t:{top:t.top,y:t.top,bottom:t.bottom,left:t.left,x:t.left,right:t.right,width:t.width,height:t.height}}function I(t,e){var i=e.top-t.top,n=e.left-t.left;return{top:i,left:n,height:e.height,width:e.width,bottom:i+e.height,right:n+e.width}}function T(t,e){for(var i=e;i;){if(i==t)return!0;i=w(i)}return!1}function w(t){var e=t.parentNode;return t.nodeType==9&&t!=f?p(t):(e&&e.assignedSlot&&(e=e.assignedSlot.parentNode),e&&e.nodeType==11&&e.host?e.host:e)}function R(t){return t&&t.nodeType===9}window.IntersectionObserver=o,window.IntersectionObserverEntry=b})();
|
|
2
|
+
//# sourceMappingURL=intersection-observer-DAXvjMTZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intersection-observer-DAXvjMTZ.js","sources":["../../../../node_modules/.pnpm/intersection-observer@0.12.2/node_modules/intersection-observer/intersection-observer.js"],"sourcesContent":["/**\n * Copyright 2016 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n *\n */\n(function() {\n'use strict';\n\n// Exit early if we're not running in a browser.\nif (typeof window !== 'object') {\n return;\n}\n\n// Exit early if all IntersectionObserver and IntersectionObserverEntry\n// features are natively supported.\nif ('IntersectionObserver' in window &&\n 'IntersectionObserverEntry' in window &&\n 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {\n\n // Minimal polyfill for Edge 15's lack of `isIntersecting`\n // See: https://github.com/w3c/IntersectionObserver/issues/211\n if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {\n Object.defineProperty(window.IntersectionObserverEntry.prototype,\n 'isIntersecting', {\n get: function () {\n return this.intersectionRatio > 0;\n }\n });\n }\n return;\n}\n\n/**\n * Returns the embedding frame element, if any.\n * @param {!Document} doc\n * @return {!Element}\n */\nfunction getFrameElement(doc) {\n try {\n return doc.defaultView && doc.defaultView.frameElement || null;\n } catch (e) {\n // Ignore the error.\n return null;\n }\n}\n\n/**\n * A local reference to the root document.\n */\nvar document = (function(startDoc) {\n var doc = startDoc;\n var frame = getFrameElement(doc);\n while (frame) {\n doc = frame.ownerDocument;\n frame = getFrameElement(doc);\n }\n return doc;\n})(window.document);\n\n/**\n * An IntersectionObserver registry. This registry exists to hold a strong\n * reference to IntersectionObserver instances currently observing a target\n * element. Without this registry, instances without another reference may be\n * garbage collected.\n */\nvar registry = [];\n\n/**\n * The signal updater for cross-origin intersection. When not null, it means\n * that the polyfill is configured to work in a cross-origin mode.\n * @type {function(DOMRect|ClientRect, DOMRect|ClientRect)}\n */\nvar crossOriginUpdater = null;\n\n/**\n * The current cross-origin intersection. Only used in the cross-origin mode.\n * @type {DOMRect|ClientRect}\n */\nvar crossOriginRect = null;\n\n\n/**\n * Creates the global IntersectionObserverEntry constructor.\n * https://w3c.github.io/IntersectionObserver/#intersection-observer-entry\n * @param {Object} entry A dictionary of instance properties.\n * @constructor\n */\nfunction IntersectionObserverEntry(entry) {\n this.time = entry.time;\n this.target = entry.target;\n this.rootBounds = ensureDOMRect(entry.rootBounds);\n this.boundingClientRect = ensureDOMRect(entry.boundingClientRect);\n this.intersectionRect = ensureDOMRect(entry.intersectionRect || getEmptyRect());\n this.isIntersecting = !!entry.intersectionRect;\n\n // Calculates the intersection ratio.\n var targetRect = this.boundingClientRect;\n var targetArea = targetRect.width * targetRect.height;\n var intersectionRect = this.intersectionRect;\n var intersectionArea = intersectionRect.width * intersectionRect.height;\n\n // Sets intersection ratio.\n if (targetArea) {\n // Round the intersection ratio to avoid floating point math issues:\n // https://github.com/w3c/IntersectionObserver/issues/324\n this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4));\n } else {\n // If area is zero and is intersecting, sets to 1, otherwise to 0\n this.intersectionRatio = this.isIntersecting ? 1 : 0;\n }\n}\n\n\n/**\n * Creates the global IntersectionObserver constructor.\n * https://w3c.github.io/IntersectionObserver/#intersection-observer-interface\n * @param {Function} callback The function to be invoked after intersection\n * changes have queued. The function is not invoked if the queue has\n * been emptied by calling the `takeRecords` method.\n * @param {Object=} opt_options Optional configuration options.\n * @constructor\n */\nfunction IntersectionObserver(callback, opt_options) {\n\n var options = opt_options || {};\n\n if (typeof callback != 'function') {\n throw new Error('callback must be a function');\n }\n\n if (\n options.root &&\n options.root.nodeType != 1 &&\n options.root.nodeType != 9\n ) {\n throw new Error('root must be a Document or Element');\n }\n\n // Binds and throttles `this._checkForIntersections`.\n this._checkForIntersections = throttle(\n this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);\n\n // Private properties.\n this._callback = callback;\n this._observationTargets = [];\n this._queuedEntries = [];\n this._rootMarginValues = this._parseRootMargin(options.rootMargin);\n\n // Public properties.\n this.thresholds = this._initThresholds(options.threshold);\n this.root = options.root || null;\n this.rootMargin = this._rootMarginValues.map(function(margin) {\n return margin.value + margin.unit;\n }).join(' ');\n\n /** @private @const {!Array<!Document>} */\n this._monitoringDocuments = [];\n /** @private @const {!Array<function()>} */\n this._monitoringUnsubscribes = [];\n}\n\n\n/**\n * The minimum interval within which the document will be checked for\n * intersection changes.\n */\nIntersectionObserver.prototype.THROTTLE_TIMEOUT = 100;\n\n\n/**\n * The frequency in which the polyfill polls for intersection changes.\n * this can be updated on a per instance basis and must be set prior to\n * calling `observe` on the first target.\n */\nIntersectionObserver.prototype.POLL_INTERVAL = null;\n\n/**\n * Use a mutation observer on the root element\n * to detect intersection changes.\n */\nIntersectionObserver.prototype.USE_MUTATION_OBSERVER = true;\n\n\n/**\n * Sets up the polyfill in the cross-origin mode. The result is the\n * updater function that accepts two arguments: `boundingClientRect` and\n * `intersectionRect` - just as these fields would be available to the\n * parent via `IntersectionObserverEntry`. This function should be called\n * each time the iframe receives intersection information from the parent\n * window, e.g. via messaging.\n * @return {function(DOMRect|ClientRect, DOMRect|ClientRect)}\n */\nIntersectionObserver._setupCrossOriginUpdater = function() {\n if (!crossOriginUpdater) {\n /**\n * @param {DOMRect|ClientRect} boundingClientRect\n * @param {DOMRect|ClientRect} intersectionRect\n */\n crossOriginUpdater = function(boundingClientRect, intersectionRect) {\n if (!boundingClientRect || !intersectionRect) {\n crossOriginRect = getEmptyRect();\n } else {\n crossOriginRect = convertFromParentRect(boundingClientRect, intersectionRect);\n }\n registry.forEach(function(observer) {\n observer._checkForIntersections();\n });\n };\n }\n return crossOriginUpdater;\n};\n\n\n/**\n * Resets the cross-origin mode.\n */\nIntersectionObserver._resetCrossOriginUpdater = function() {\n crossOriginUpdater = null;\n crossOriginRect = null;\n};\n\n\n/**\n * Starts observing a target element for intersection changes based on\n * the thresholds values.\n * @param {Element} target The DOM element to observe.\n */\nIntersectionObserver.prototype.observe = function(target) {\n var isTargetAlreadyObserved = this._observationTargets.some(function(item) {\n return item.element == target;\n });\n\n if (isTargetAlreadyObserved) {\n return;\n }\n\n if (!(target && target.nodeType == 1)) {\n throw new Error('target must be an Element');\n }\n\n this._registerInstance();\n this._observationTargets.push({element: target, entry: null});\n this._monitorIntersections(target.ownerDocument);\n this._checkForIntersections();\n};\n\n\n/**\n * Stops observing a target element for intersection changes.\n * @param {Element} target The DOM element to observe.\n */\nIntersectionObserver.prototype.unobserve = function(target) {\n this._observationTargets =\n this._observationTargets.filter(function(item) {\n return item.element != target;\n });\n this._unmonitorIntersections(target.ownerDocument);\n if (this._observationTargets.length == 0) {\n this._unregisterInstance();\n }\n};\n\n\n/**\n * Stops observing all target elements for intersection changes.\n */\nIntersectionObserver.prototype.disconnect = function() {\n this._observationTargets = [];\n this._unmonitorAllIntersections();\n this._unregisterInstance();\n};\n\n\n/**\n * Returns any queue entries that have not yet been reported to the\n * callback and clears the queue. This can be used in conjunction with the\n * callback to obtain the absolute most up-to-date intersection information.\n * @return {Array} The currently queued entries.\n */\nIntersectionObserver.prototype.takeRecords = function() {\n var records = this._queuedEntries.slice();\n this._queuedEntries = [];\n return records;\n};\n\n\n/**\n * Accepts the threshold value from the user configuration object and\n * returns a sorted array of unique threshold values. If a value is not\n * between 0 and 1 and error is thrown.\n * @private\n * @param {Array|number=} opt_threshold An optional threshold value or\n * a list of threshold values, defaulting to [0].\n * @return {Array} A sorted list of unique and valid threshold values.\n */\nIntersectionObserver.prototype._initThresholds = function(opt_threshold) {\n var threshold = opt_threshold || [0];\n if (!Array.isArray(threshold)) threshold = [threshold];\n\n return threshold.sort().filter(function(t, i, a) {\n if (typeof t != 'number' || isNaN(t) || t < 0 || t > 1) {\n throw new Error('threshold must be a number between 0 and 1 inclusively');\n }\n return t !== a[i - 1];\n });\n};\n\n\n/**\n * Accepts the rootMargin value from the user configuration object\n * and returns an array of the four margin values as an object containing\n * the value and unit properties. If any of the values are not properly\n * formatted or use a unit other than px or %, and error is thrown.\n * @private\n * @param {string=} opt_rootMargin An optional rootMargin value,\n * defaulting to '0px'.\n * @return {Array<Object>} An array of margin objects with the keys\n * value and unit.\n */\nIntersectionObserver.prototype._parseRootMargin = function(opt_rootMargin) {\n var marginString = opt_rootMargin || '0px';\n var margins = marginString.split(/\\s+/).map(function(margin) {\n var parts = /^(-?\\d*\\.?\\d+)(px|%)$/.exec(margin);\n if (!parts) {\n throw new Error('rootMargin must be specified in pixels or percent');\n }\n return {value: parseFloat(parts[1]), unit: parts[2]};\n });\n\n // Handles shorthand.\n margins[1] = margins[1] || margins[0];\n margins[2] = margins[2] || margins[0];\n margins[3] = margins[3] || margins[1];\n\n return margins;\n};\n\n\n/**\n * Starts polling for intersection changes if the polling is not already\n * happening, and if the page's visibility state is visible.\n * @param {!Document} doc\n * @private\n */\nIntersectionObserver.prototype._monitorIntersections = function(doc) {\n var win = doc.defaultView;\n if (!win) {\n // Already destroyed.\n return;\n }\n if (this._monitoringDocuments.indexOf(doc) != -1) {\n // Already monitoring.\n return;\n }\n\n // Private state for monitoring.\n var callback = this._checkForIntersections;\n var monitoringInterval = null;\n var domObserver = null;\n\n // If a poll interval is set, use polling instead of listening to\n // resize and scroll events or DOM mutations.\n if (this.POLL_INTERVAL) {\n monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL);\n } else {\n addEvent(win, 'resize', callback, true);\n addEvent(doc, 'scroll', callback, true);\n if (this.USE_MUTATION_OBSERVER && 'MutationObserver' in win) {\n domObserver = new win.MutationObserver(callback);\n domObserver.observe(doc, {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true\n });\n }\n }\n\n this._monitoringDocuments.push(doc);\n this._monitoringUnsubscribes.push(function() {\n // Get the window object again. When a friendly iframe is destroyed, it\n // will be null.\n var win = doc.defaultView;\n\n if (win) {\n if (monitoringInterval) {\n win.clearInterval(monitoringInterval);\n }\n removeEvent(win, 'resize', callback, true);\n }\n\n removeEvent(doc, 'scroll', callback, true);\n if (domObserver) {\n domObserver.disconnect();\n }\n });\n\n // Also monitor the parent.\n var rootDoc =\n (this.root && (this.root.ownerDocument || this.root)) || document;\n if (doc != rootDoc) {\n var frame = getFrameElement(doc);\n if (frame) {\n this._monitorIntersections(frame.ownerDocument);\n }\n }\n};\n\n\n/**\n * Stops polling for intersection changes.\n * @param {!Document} doc\n * @private\n */\nIntersectionObserver.prototype._unmonitorIntersections = function(doc) {\n var index = this._monitoringDocuments.indexOf(doc);\n if (index == -1) {\n return;\n }\n\n var rootDoc =\n (this.root && (this.root.ownerDocument || this.root)) || document;\n\n // Check if any dependent targets are still remaining.\n var hasDependentTargets =\n this._observationTargets.some(function(item) {\n var itemDoc = item.element.ownerDocument;\n // Target is in this context.\n if (itemDoc == doc) {\n return true;\n }\n // Target is nested in this context.\n while (itemDoc && itemDoc != rootDoc) {\n var frame = getFrameElement(itemDoc);\n itemDoc = frame && frame.ownerDocument;\n if (itemDoc == doc) {\n return true;\n }\n }\n return false;\n });\n if (hasDependentTargets) {\n return;\n }\n\n // Unsubscribe.\n var unsubscribe = this._monitoringUnsubscribes[index];\n this._monitoringDocuments.splice(index, 1);\n this._monitoringUnsubscribes.splice(index, 1);\n unsubscribe();\n\n // Also unmonitor the parent.\n if (doc != rootDoc) {\n var frame = getFrameElement(doc);\n if (frame) {\n this._unmonitorIntersections(frame.ownerDocument);\n }\n }\n};\n\n\n/**\n * Stops polling for intersection changes.\n * @param {!Document} doc\n * @private\n */\nIntersectionObserver.prototype._unmonitorAllIntersections = function() {\n var unsubscribes = this._monitoringUnsubscribes.slice(0);\n this._monitoringDocuments.length = 0;\n this._monitoringUnsubscribes.length = 0;\n for (var i = 0; i < unsubscribes.length; i++) {\n unsubscribes[i]();\n }\n};\n\n\n/**\n * Scans each observation target for intersection changes and adds them\n * to the internal entries queue. If new entries are found, it\n * schedules the callback to be invoked.\n * @private\n */\nIntersectionObserver.prototype._checkForIntersections = function() {\n if (!this.root && crossOriginUpdater && !crossOriginRect) {\n // Cross origin monitoring, but no initial data available yet.\n return;\n }\n\n var rootIsInDom = this._rootIsInDom();\n var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();\n\n this._observationTargets.forEach(function(item) {\n var target = item.element;\n var targetRect = getBoundingClientRect(target);\n var rootContainsTarget = this._rootContainsTarget(target);\n var oldEntry = item.entry;\n var intersectionRect = rootIsInDom && rootContainsTarget &&\n this._computeTargetAndRootIntersection(target, targetRect, rootRect);\n\n var rootBounds = null;\n if (!this._rootContainsTarget(target)) {\n rootBounds = getEmptyRect();\n } else if (!crossOriginUpdater || this.root) {\n rootBounds = rootRect;\n }\n\n var newEntry = item.entry = new IntersectionObserverEntry({\n time: now(),\n target: target,\n boundingClientRect: targetRect,\n rootBounds: rootBounds,\n intersectionRect: intersectionRect\n });\n\n if (!oldEntry) {\n this._queuedEntries.push(newEntry);\n } else if (rootIsInDom && rootContainsTarget) {\n // If the new entry intersection ratio has crossed any of the\n // thresholds, add a new entry.\n if (this._hasCrossedThreshold(oldEntry, newEntry)) {\n this._queuedEntries.push(newEntry);\n }\n } else {\n // If the root is not in the DOM or target is not contained within\n // root but the previous entry for this target had an intersection,\n // add a new record indicating removal.\n if (oldEntry && oldEntry.isIntersecting) {\n this._queuedEntries.push(newEntry);\n }\n }\n }, this);\n\n if (this._queuedEntries.length) {\n this._callback(this.takeRecords(), this);\n }\n};\n\n\n/**\n * Accepts a target and root rect computes the intersection between then\n * following the algorithm in the spec.\n * TODO(philipwalton): at this time clip-path is not considered.\n * https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo\n * @param {Element} target The target DOM element\n * @param {Object} targetRect The bounding rect of the target.\n * @param {Object} rootRect The bounding rect of the root after being\n * expanded by the rootMargin value.\n * @return {?Object} The final intersection rect object or undefined if no\n * intersection is found.\n * @private\n */\nIntersectionObserver.prototype._computeTargetAndRootIntersection =\n function(target, targetRect, rootRect) {\n // If the element isn't displayed, an intersection can't happen.\n if (window.getComputedStyle(target).display == 'none') return;\n\n var intersectionRect = targetRect;\n var parent = getParentNode(target);\n var atRoot = false;\n\n while (!atRoot && parent) {\n var parentRect = null;\n var parentComputedStyle = parent.nodeType == 1 ?\n window.getComputedStyle(parent) : {};\n\n // If the parent isn't displayed, an intersection can't happen.\n if (parentComputedStyle.display == 'none') return null;\n\n if (parent == this.root || parent.nodeType == /* DOCUMENT */ 9) {\n atRoot = true;\n if (parent == this.root || parent == document) {\n if (crossOriginUpdater && !this.root) {\n if (!crossOriginRect ||\n crossOriginRect.width == 0 && crossOriginRect.height == 0) {\n // A 0-size cross-origin intersection means no-intersection.\n parent = null;\n parentRect = null;\n intersectionRect = null;\n } else {\n parentRect = crossOriginRect;\n }\n } else {\n parentRect = rootRect;\n }\n } else {\n // Check if there's a frame that can be navigated to.\n var frame = getParentNode(parent);\n var frameRect = frame && getBoundingClientRect(frame);\n var frameIntersect =\n frame &&\n this._computeTargetAndRootIntersection(frame, frameRect, rootRect);\n if (frameRect && frameIntersect) {\n parent = frame;\n parentRect = convertFromParentRect(frameRect, frameIntersect);\n } else {\n parent = null;\n intersectionRect = null;\n }\n }\n } else {\n // If the element has a non-visible overflow, and it's not the <body>\n // or <html> element, update the intersection rect.\n // Note: <body> and <html> cannot be clipped to a rect that's not also\n // the document rect, so no need to compute a new intersection.\n var doc = parent.ownerDocument;\n if (parent != doc.body &&\n parent != doc.documentElement &&\n parentComputedStyle.overflow != 'visible') {\n parentRect = getBoundingClientRect(parent);\n }\n }\n\n // If either of the above conditionals set a new parentRect,\n // calculate new intersection data.\n if (parentRect) {\n intersectionRect = computeRectIntersection(parentRect, intersectionRect);\n }\n if (!intersectionRect) break;\n parent = parent && getParentNode(parent);\n }\n return intersectionRect;\n};\n\n\n/**\n * Returns the root rect after being expanded by the rootMargin value.\n * @return {ClientRect} The expanded root rect.\n * @private\n */\nIntersectionObserver.prototype._getRootRect = function() {\n var rootRect;\n if (this.root && !isDoc(this.root)) {\n rootRect = getBoundingClientRect(this.root);\n } else {\n // Use <html>/<body> instead of window since scroll bars affect size.\n var doc = isDoc(this.root) ? this.root : document;\n var html = doc.documentElement;\n var body = doc.body;\n rootRect = {\n top: 0,\n left: 0,\n right: html.clientWidth || body.clientWidth,\n width: html.clientWidth || body.clientWidth,\n bottom: html.clientHeight || body.clientHeight,\n height: html.clientHeight || body.clientHeight\n };\n }\n return this._expandRectByRootMargin(rootRect);\n};\n\n\n/**\n * Accepts a rect and expands it by the rootMargin value.\n * @param {DOMRect|ClientRect} rect The rect object to expand.\n * @return {ClientRect} The expanded rect.\n * @private\n */\nIntersectionObserver.prototype._expandRectByRootMargin = function(rect) {\n var margins = this._rootMarginValues.map(function(margin, i) {\n return margin.unit == 'px' ? margin.value :\n margin.value * (i % 2 ? rect.width : rect.height) / 100;\n });\n var newRect = {\n top: rect.top - margins[0],\n right: rect.right + margins[1],\n bottom: rect.bottom + margins[2],\n left: rect.left - margins[3]\n };\n newRect.width = newRect.right - newRect.left;\n newRect.height = newRect.bottom - newRect.top;\n\n return newRect;\n};\n\n\n/**\n * Accepts an old and new entry and returns true if at least one of the\n * threshold values has been crossed.\n * @param {?IntersectionObserverEntry} oldEntry The previous entry for a\n * particular target element or null if no previous entry exists.\n * @param {IntersectionObserverEntry} newEntry The current entry for a\n * particular target element.\n * @return {boolean} Returns true if a any threshold has been crossed.\n * @private\n */\nIntersectionObserver.prototype._hasCrossedThreshold =\n function(oldEntry, newEntry) {\n\n // To make comparing easier, an entry that has a ratio of 0\n // but does not actually intersect is given a value of -1\n var oldRatio = oldEntry && oldEntry.isIntersecting ?\n oldEntry.intersectionRatio || 0 : -1;\n var newRatio = newEntry.isIntersecting ?\n newEntry.intersectionRatio || 0 : -1;\n\n // Ignore unchanged ratios\n if (oldRatio === newRatio) return;\n\n for (var i = 0; i < this.thresholds.length; i++) {\n var threshold = this.thresholds[i];\n\n // Return true if an entry matches a threshold or if the new ratio\n // and the old ratio are on the opposite sides of a threshold.\n if (threshold == oldRatio || threshold == newRatio ||\n threshold < oldRatio !== threshold < newRatio) {\n return true;\n }\n }\n};\n\n\n/**\n * Returns whether or not the root element is an element and is in the DOM.\n * @return {boolean} True if the root element is an element and is in the DOM.\n * @private\n */\nIntersectionObserver.prototype._rootIsInDom = function() {\n return !this.root || containsDeep(document, this.root);\n};\n\n\n/**\n * Returns whether or not the target element is a child of root.\n * @param {Element} target The target element to check.\n * @return {boolean} True if the target element is a child of root.\n * @private\n */\nIntersectionObserver.prototype._rootContainsTarget = function(target) {\n var rootDoc =\n (this.root && (this.root.ownerDocument || this.root)) || document;\n return (\n containsDeep(rootDoc, target) &&\n (!this.root || rootDoc == target.ownerDocument)\n );\n};\n\n\n/**\n * Adds the instance to the global IntersectionObserver registry if it isn't\n * already present.\n * @private\n */\nIntersectionObserver.prototype._registerInstance = function() {\n if (registry.indexOf(this) < 0) {\n registry.push(this);\n }\n};\n\n\n/**\n * Removes the instance from the global IntersectionObserver registry.\n * @private\n */\nIntersectionObserver.prototype._unregisterInstance = function() {\n var index = registry.indexOf(this);\n if (index != -1) registry.splice(index, 1);\n};\n\n\n/**\n * Returns the result of the performance.now() method or null in browsers\n * that don't support the API.\n * @return {number} The elapsed time since the page was requested.\n */\nfunction now() {\n return window.performance && performance.now && performance.now();\n}\n\n\n/**\n * Throttles a function and delays its execution, so it's only called at most\n * once within a given time period.\n * @param {Function} fn The function to throttle.\n * @param {number} timeout The amount of time that must pass before the\n * function can be called again.\n * @return {Function} The throttled function.\n */\nfunction throttle(fn, timeout) {\n var timer = null;\n return function () {\n if (!timer) {\n timer = setTimeout(function() {\n fn();\n timer = null;\n }, timeout);\n }\n };\n}\n\n\n/**\n * Adds an event handler to a DOM node ensuring cross-browser compatibility.\n * @param {Node} node The DOM node to add the event handler to.\n * @param {string} event The event name.\n * @param {Function} fn The event handler to add.\n * @param {boolean} opt_useCapture Optionally adds the even to the capture\n * phase. Note: this only works in modern browsers.\n */\nfunction addEvent(node, event, fn, opt_useCapture) {\n if (typeof node.addEventListener == 'function') {\n node.addEventListener(event, fn, opt_useCapture || false);\n }\n else if (typeof node.attachEvent == 'function') {\n node.attachEvent('on' + event, fn);\n }\n}\n\n\n/**\n * Removes a previously added event handler from a DOM node.\n * @param {Node} node The DOM node to remove the event handler from.\n * @param {string} event The event name.\n * @param {Function} fn The event handler to remove.\n * @param {boolean} opt_useCapture If the event handler was added with this\n * flag set to true, it should be set to true here in order to remove it.\n */\nfunction removeEvent(node, event, fn, opt_useCapture) {\n if (typeof node.removeEventListener == 'function') {\n node.removeEventListener(event, fn, opt_useCapture || false);\n }\n else if (typeof node.detachEvent == 'function') {\n node.detachEvent('on' + event, fn);\n }\n}\n\n\n/**\n * Returns the intersection between two rect objects.\n * @param {Object} rect1 The first rect.\n * @param {Object} rect2 The second rect.\n * @return {?Object|?ClientRect} The intersection rect or undefined if no\n * intersection is found.\n */\nfunction computeRectIntersection(rect1, rect2) {\n var top = Math.max(rect1.top, rect2.top);\n var bottom = Math.min(rect1.bottom, rect2.bottom);\n var left = Math.max(rect1.left, rect2.left);\n var right = Math.min(rect1.right, rect2.right);\n var width = right - left;\n var height = bottom - top;\n\n return (width >= 0 && height >= 0) && {\n top: top,\n bottom: bottom,\n left: left,\n right: right,\n width: width,\n height: height\n } || null;\n}\n\n\n/**\n * Shims the native getBoundingClientRect for compatibility with older IE.\n * @param {Element} el The element whose bounding rect to get.\n * @return {DOMRect|ClientRect} The (possibly shimmed) rect of the element.\n */\nfunction getBoundingClientRect(el) {\n var rect;\n\n try {\n rect = el.getBoundingClientRect();\n } catch (err) {\n // Ignore Windows 7 IE11 \"Unspecified error\"\n // https://github.com/w3c/IntersectionObserver/pull/205\n }\n\n if (!rect) return getEmptyRect();\n\n // Older IE\n if (!(rect.width && rect.height)) {\n rect = {\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n width: rect.right - rect.left,\n height: rect.bottom - rect.top\n };\n }\n return rect;\n}\n\n\n/**\n * Returns an empty rect object. An empty rect is returned when an element\n * is not in the DOM.\n * @return {ClientRect} The empty rect.\n */\nfunction getEmptyRect() {\n return {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n width: 0,\n height: 0\n };\n}\n\n\n/**\n * Ensure that the result has all of the necessary fields of the DOMRect.\n * Specifically this ensures that `x` and `y` fields are set.\n *\n * @param {?DOMRect|?ClientRect} rect\n * @return {?DOMRect}\n */\nfunction ensureDOMRect(rect) {\n // A `DOMRect` object has `x` and `y` fields.\n if (!rect || 'x' in rect) {\n return rect;\n }\n // A IE's `ClientRect` type does not have `x` and `y`. The same is the case\n // for internally calculated Rect objects. For the purposes of\n // `IntersectionObserver`, it's sufficient to simply mirror `left` and `top`\n // for these fields.\n return {\n top: rect.top,\n y: rect.top,\n bottom: rect.bottom,\n left: rect.left,\n x: rect.left,\n right: rect.right,\n width: rect.width,\n height: rect.height\n };\n}\n\n\n/**\n * Inverts the intersection and bounding rect from the parent (frame) BCR to\n * the local BCR space.\n * @param {DOMRect|ClientRect} parentBoundingRect The parent's bound client rect.\n * @param {DOMRect|ClientRect} parentIntersectionRect The parent's own intersection rect.\n * @return {ClientRect} The local root bounding rect for the parent's children.\n */\nfunction convertFromParentRect(parentBoundingRect, parentIntersectionRect) {\n var top = parentIntersectionRect.top - parentBoundingRect.top;\n var left = parentIntersectionRect.left - parentBoundingRect.left;\n return {\n top: top,\n left: left,\n height: parentIntersectionRect.height,\n width: parentIntersectionRect.width,\n bottom: top + parentIntersectionRect.height,\n right: left + parentIntersectionRect.width\n };\n}\n\n\n/**\n * Checks to see if a parent element contains a child element (including inside\n * shadow DOM).\n * @param {Node} parent The parent element.\n * @param {Node} child The child element.\n * @return {boolean} True if the parent node contains the child node.\n */\nfunction containsDeep(parent, child) {\n var node = child;\n while (node) {\n if (node == parent) return true;\n\n node = getParentNode(node);\n }\n return false;\n}\n\n\n/**\n * Gets the parent node of an element or its host element if the parent node\n * is a shadow root.\n * @param {Node} node The node whose parent to get.\n * @return {Node|null} The parent node or null if no parent exists.\n */\nfunction getParentNode(node) {\n var parent = node.parentNode;\n\n if (node.nodeType == /* DOCUMENT */ 9 && node != document) {\n // If this node is a document node, look for the embedding frame.\n return getFrameElement(node);\n }\n\n // If the parent has element that is assigned through shadow root slot\n if (parent && parent.assignedSlot) {\n parent = parent.assignedSlot.parentNode\n }\n\n if (parent && parent.nodeType == 11 && parent.host) {\n // If the parent is a shadow root, return the host element.\n return parent.host;\n }\n\n return parent;\n}\n\n/**\n * Returns true if `node` is a Document.\n * @param {!Node} node\n * @returns {boolean}\n */\nfunction isDoc(node) {\n return node && node.nodeType === 9;\n}\n\n\n// Exposes the constructors globally.\nwindow.IntersectionObserver = IntersectionObserver;\nwindow.IntersectionObserverEntry = IntersectionObserverEntry;\n\n}());\n"],"names":["getFrameElement","doc","document","startDoc","frame","registry","crossOriginUpdater","crossOriginRect","IntersectionObserverEntry","entry","ensureDOMRect","getEmptyRect","targetRect","targetArea","intersectionRect","intersectionArea","IntersectionObserver","callback","opt_options","options","throttle","margin","boundingClientRect","convertFromParentRect","observer","target","isTargetAlreadyObserved","item","records","opt_threshold","threshold","t","i","a","opt_rootMargin","marginString","margins","parts","win","monitoringInterval","domObserver","addEvent","removeEvent","rootDoc","index","hasDependentTargets","itemDoc","unsubscribe","unsubscribes","rootIsInDom","rootRect","getBoundingClientRect","rootContainsTarget","oldEntry","rootBounds","newEntry","now","parent","getParentNode","atRoot","parentRect","parentComputedStyle","frameRect","frameIntersect","computeRectIntersection","isDoc","html","body","rect","newRect","oldRatio","newRatio","containsDeep","fn","timeout","timer","node","event","opt_useCapture","rect1","rect2","top","bottom","left","right","width","height","el","err","parentBoundingRect","parentIntersectionRect","child"],"mappings":"CAQC,UAAW,CAIZ,GAAI,OAAO,QAAW,SACpB,OAKF,GAAI,yBAA0B,QAC1B,8BAA+B,QAC/B,sBAAuB,OAAO,0BAA0B,UAAW,CAI/D,mBAAoB,OAAO,0BAA0B,WACzD,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EAAK,IACR,OAAQA,EAAK,OACb,KAAMA,EAAK,KACX,EAAGA,EAAK,KACR,MAAOA,EAAK,MACZ,MAAOA,EAAK,MACZ,OAAQA,EAAK,MACjB,CACA,CAUA,SAAS7C,EAAsBkE,EAAoBC,EAAwB,CACzE,IAAIT,EAAMS,EAAuB,IAAMD,EAAmB,IACtDN,EAAOO,EAAuB,KAAOD,EAAmB,KAC5D,MAAO,CACL,IAAKR,EACL,KAAME,EACN,OAAQO,EAAuB,OAC/B,MAAOA,EAAuB,MAC9B,OAAQT,EAAMS,EAAuB,OACrC,MAAOP,EAAOO,EAAuB,KACzC,CACA,CAUA,SAASlB,EAAaf,EAAQkC,EAAO,CAEnC,QADIf,EAAOe,EACJf,GAAM,CACX,GAAIA,GAAQnB,EAAQ,MAAO,GAE3BmB,EAAOlB,EAAckB,CAAI,CAC3B,CACA,MAAO,EACT,CASA,SAASlB,EAAckB,EAAM,CAC3B,IAAInB,EAASmB,EAAK,WAElB,OAAIA,EAAK,UAA2B,GAAKA,GAAQ1E,EAExCF,EAAgB4E,CAAI,GAIzBnB,GAAUA,EAAO,eACnBA,EAASA,EAAO,aAAa,YAG3BA,GAAUA,EAAO,UAAY,IAAMA,EAAO,KAErCA,EAAO,KAGTA,EACT,CAOA,SAASQ,EAAMW,EAAM,CACnB,OAAOA,GAAQA,EAAK,WAAa,CACnC,CAIA,OAAO,qBAAuB5D,EAC9B,OAAO,0BAA4BR,CAEnC,GAAC","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var $=Object.defineProperty,J=Object.defineProperties;var K=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var N=(e,t,n)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))R.call(t,n)&&N(e,n,t[n]);if(E)for(var n of E(t))j.call(t,n)&&N(e,n,t[n]);return e},V=(e,t)=>J(e,K(t));var A=(e,t)=>{var n={};for(var s in e)R.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&E)for(var s of E(e))t.indexOf(s)<0&&j.call(e,s)&&(n[s]=e[s]);return n};import{V as W,Y as B,Z as ee,X as te,_ as ne,$ as se,a0 as k,w as L,a1 as re,a2 as ae,Q as oe,a3 as F,O as ie,l as ce,a4 as le}from"../main.js";function ue(e,t,n,s){const u=o=>{t.notify(14,{error:o}),te("Error reported to customer",{"error.message":o.message})},f=W([e.profilingEndpointBuilder],u),p=n(s);return{async send(g){var v=g,{event:o}=v,P=A(v,["event"]);const a=new FormData,m=B(o);if(!m)throw new Error("Failed to serialize event");a.append("event",new Blob([m],{type:"application/json"}),"event.json");let y=m.length;for(const[w,I]of ee(P)){const d=B(I);if(!d)throw new Error("Failed to serialize attachment");const h=await de(p,d);y+=h.outputBytesCount,a.append(w,new Blob([h.output]),w)}f.send({data:a,bytesCount:y})}}}function de(e,t){return new Promise(n=>{e.write(t),e.finish(s=>{n(s)})})}function fe(e){let t=0;for(const n of e)n.stackId!==void 0&&t++;return t}const pe=/\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g;function me(e){return e?e.replace(pe,"/?"):"/"}const U=(e,t)=>e||me(t);function ve(e,t,n){const s={application:{id:t}};n&&(s.session={id:n});const{ids:u,names:f}=we(e.views);u.length&&(s.view={id:u,name:f});const p=e.longTasks.map(o=>o.id).filter(o=>o!==void 0);return p.length&&(s.long_task={id:p}),s}function we(e){const t={ids:[],names:[]};for(const n of e)t.ids.push(n.viewId),n.viewName&&t.names.push(n.viewName);return t.names=Array.from(new Set(t.names)),t}function he(e,t,n){return{event:be(e,t,n),"wall-time.json":e}}function be(e,t,n){const s=ne(t),u=ve(e,t.applicationId,n),f=ge(s);return V(M({},u),{attachments:["wall-time.json"],start:new Date(e.startClocks.timeStamp).toISOString(),end:new Date(e.endClocks.timeStamp).toISOString(),family:"chrome",runtime:"chrome",format:"json",version:4,tags_profiler:f.join(","),_dd:{clock_drift:se()}})}function ge(e){return e.concat(["language:javascript","runtime:chrome","family:chrome","host:browser"])}const ye={sampleIntervalMs:10,collectIntervalMs:6e4,minProfileDurationMs:5e3,minNumberOfSamples:50};function Pe(e,t,n,s,u,f,p,o=ye){const P=ue(e,t,f,6);let g;const v=[];let a={state:"stopped",stateReason:"initializing"};t.subscribe(9,()=>{w("session-expired").catch(k)}),t.subscribe(10,()=>{a.state==="stopped"&&a.stateReason==="session-expired"&&m()});function m(){if(a.state==="running")return;const r=p.findView();g=r?{startClocks:r.startClocks,viewId:r.id,viewName:U(r.name,document.location.pathname)}:void 0,v.push(L(e,window,"visibilitychange",C).stop,L(e,window,"beforeunload",q).stop),d()}async function y(){await w("stopped-by-user")}async function w(r){await z(r),v.forEach(i=>i()),s.set({status:"stopped",error_reason:void 0})}function I(r){if(r.state==="running")return{cleanupTasks:r.cleanupTasks};const i=[],l=t.subscribe(2,c=>{const b={viewId:c.id,viewName:U(c.name,document.location.pathname),startClocks:c.startClocks};S(b),g=b});return i.push(l.unsubscribe),{cleanupTasks:i}}function d(){const r=re().Profiler;if(!r)throw s.set({status:"error",error_reason:"not-supported-by-browser"}),new Error("RUM Profiler is not supported in this browser.");h(a).catch(k);const{cleanupTasks:i}=I(a);let l;try{l=new r({sampleInterval:o.sampleIntervalMs,maxBufferSize:Math.round(o.collectIntervalMs*1.5/o.sampleIntervalMs)})}catch(c){c instanceof Error&&c.message.includes("disabled by Document Policy")?(ae.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.",c),s.set({status:"error",error_reason:"missing-document-policy-header"})):s.set({status:"error",error_reason:"unexpected-exception"});return}s.set({status:"running",error_reason:void 0}),a={state:"running",startClocks:F(),profiler:l,timeoutId:oe(d,o.collectIntervalMs),views:[],cleanupTasks:i,longTasks:[]},S(g),l.addEventListener("samplebufferfull",D)}async function h(r){if(r.state!=="running")return;ie(r.timeoutId),r.profiler.removeEventListener("samplebufferfull",D);const{startClocks:i,views:l}=r;await r.profiler.stop().then(c=>{const b=F(),_=ce(i.timeStamp,b.timeStamp),O=u.findLongTasks(i.relative,_),Y=_<o.minProfileDurationMs,Z=fe(c.samples)<o.minNumberOfSamples;O.length===0&&(Y||Z)||x(Object.assign(c,{startClocks:i,endClocks:b,clocksOrigin:le(),longTasks:O,views:l,sampleInterval:o.sampleIntervalMs}))}).catch(k)}async function z(r){a.state==="running"&&(await T(),a={state:"stopped",stateReason:r})}async function H(){a.state==="running"&&(await T(),a={state:"paused"})}async function T(){a.state==="running"&&(a.cleanupTasks.forEach(r=>r()),await h(a))}function S(r){a.state!=="running"||!r||a.views.push(r)}function x(r){var i;const l=(i=n.findTrackedSession())===null||i===void 0?void 0:i.id,c=he(r,e,l);P.send(c)}function D(){d()}function C(){document.visibilityState==="hidden"&&a.state==="running"?H().catch(k):document.visibilityState==="visible"&&a.state==="paused"&&d()}function q(){d()}function G(){return a.state==="stopped"}function X(){return a.state==="running"}function Q(){return a.state==="paused"}return{start:m,stop:y,isStopped:G,isRunning:X,isPaused:Q}}export{ye as DEFAULT_RUM_PROFILER_CONFIGURATION,Pe as createRumProfiler};
|
|
2
|
+
//# sourceMappingURL=profiler-BRmTNL9s.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler-BRmTNL9s.js","sources":["../../../../node_modules/.pnpm/@datadog+browser-rum-core@6.25.2/node_modules/@datadog/browser-rum-core/esm/transport/formDataTransport.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/utils/getNumberOfSamples.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/utils/getDefaultViewName.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/utils/getCustomOrDefaultViewName.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/transport/buildProfileEventAttributes.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/transport/assembly.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/profiler.js"],"sourcesContent":["import { addTelemetryDebug, createHttpRequest, jsonStringify, objectEntries } from '@datadog/browser-core';\nexport function createFormDataTransport(configuration, lifeCycle, createEncoder, streamId) {\n const reportError = (error) => {\n lifeCycle.notify(14 /* LifeCycleEventType.RAW_ERROR_COLLECTED */, { error });\n // monitor-until: forever, to keep an eye on the errors reported to customers\n addTelemetryDebug('Error reported to customer', { 'error.message': error.message });\n };\n const httpRequest = createHttpRequest([configuration.profilingEndpointBuilder], reportError);\n const encoder = createEncoder(streamId);\n return {\n async send({ event, ...attachments }) {\n const formData = new FormData();\n const serializedEvent = jsonStringify(event);\n if (!serializedEvent) {\n throw new Error('Failed to serialize event');\n }\n formData.append('event', new Blob([serializedEvent], { type: 'application/json' }), 'event.json');\n let bytesCount = serializedEvent.length;\n for (const [key, value] of objectEntries(attachments)) {\n const serializedValue = jsonStringify(value);\n if (!serializedValue) {\n throw new Error('Failed to serialize attachment');\n }\n const result = await encode(encoder, serializedValue);\n bytesCount += result.outputBytesCount;\n formData.append(key, new Blob([result.output]), key);\n }\n httpRequest.send({\n data: formData,\n bytesCount,\n });\n },\n };\n}\nfunction encode(encoder, data) {\n return new Promise((resolve) => {\n encoder.write(data);\n encoder.finish((encoderResult) => {\n resolve(encoderResult);\n });\n });\n}\n//# sourceMappingURL=formDataTransport.js.map","/**\n * Counts number of samples when the thread was not idle (stackId is defined)\n *\n * @param samples - Array of collected samples\n * @returns Number of samples\n */\nexport function getNumberOfSamples(samples) {\n let numberOfSamples = 0;\n for (const sample of samples) {\n if (sample.stackId !== undefined) {\n numberOfSamples++;\n }\n }\n return numberOfSamples;\n}\n//# sourceMappingURL=getNumberOfSamples.js.map","// This is the regex used to extract the path from the url (from SimpleUrlGroupingProcessor.java)\n// It's a bit different from the one in the java code because we removed the lookbehind unsupported by Safari.\nconst PATH_MIXED_ALPHANUMERICS = /\\/(?![vV]\\d{1,2}\\/)([^/\\d?]*\\d+[^/?]*)/g;\nexport function getDefaultViewName(viewPathUrl) {\n if (!viewPathUrl) {\n return '/';\n }\n // Replace all the mixed alphanumerics with a ?\n return viewPathUrl.replace(PATH_MIXED_ALPHANUMERICS, '/?');\n}\n//# sourceMappingURL=getDefaultViewName.js.map","import { getDefaultViewName } from './getDefaultViewName';\nexport const getCustomOrDefaultViewName = (customViewName, viewPathUrl) => customViewName || getDefaultViewName(viewPathUrl);\n//# sourceMappingURL=getCustomOrDefaultViewName.js.map","/**\n * Builds attributes for the Profile Event.\n *\n * @param profilerTrace - Profiler trace\n * @param applicationId - application id.\n * @param sessionId - session id.\n * @returns Additional attributes.\n */\nexport function buildProfileEventAttributes(profilerTrace, applicationId, sessionId) {\n const attributes = {\n application: {\n id: applicationId,\n },\n };\n if (sessionId) {\n attributes.session = {\n id: sessionId,\n };\n }\n // Extract view ids and names from the profiler trace and add them as attributes of the profile event.\n // This will be used to filter the profiles by @view.id and/or @view.name.\n const { ids, names } = extractViewIdsAndNames(profilerTrace.views);\n if (ids.length) {\n attributes.view = {\n id: ids,\n name: names,\n };\n }\n const longTaskIds = profilerTrace.longTasks.map((longTask) => longTask.id).filter((id) => id !== undefined);\n if (longTaskIds.length) {\n attributes.long_task = { id: longTaskIds };\n }\n return attributes;\n}\nfunction extractViewIdsAndNames(views) {\n const result = { ids: [], names: [] };\n for (const view of views) {\n result.ids.push(view.viewId);\n if (view.viewName) {\n result.names.push(view.viewName);\n }\n }\n // Remove duplicates\n result.names = Array.from(new Set(result.names));\n return result;\n}\n//# sourceMappingURL=buildProfileEventAttributes.js.map","import { buildTags, currentDrift } from '@datadog/browser-core';\nimport { buildProfileEventAttributes } from './buildProfileEventAttributes';\nexport function assembleProfilingPayload(profilerTrace, configuration, sessionId) {\n const event = buildProfileEvent(profilerTrace, configuration, sessionId);\n return {\n event,\n 'wall-time.json': profilerTrace,\n };\n}\nfunction buildProfileEvent(profilerTrace, configuration, sessionId) {\n const tags = buildTags(configuration); // TODO: get that from the tagContext hook\n const profileAttributes = buildProfileEventAttributes(profilerTrace, configuration.applicationId, sessionId);\n const profileEventTags = buildProfileEventTags(tags);\n const profileEvent = {\n ...profileAttributes,\n attachments: ['wall-time.json'],\n start: new Date(profilerTrace.startClocks.timeStamp).toISOString(),\n end: new Date(profilerTrace.endClocks.timeStamp).toISOString(),\n family: 'chrome',\n runtime: 'chrome',\n format: 'json',\n version: 4, // Ingestion event version (not the version application tag)\n tags_profiler: profileEventTags.join(','),\n _dd: {\n clock_drift: currentDrift(),\n },\n };\n return profileEvent;\n}\n/**\n * Builds tags for the Profile Event.\n *\n * @param tags - RUM tags\n * @returns Combined tags for the Profile Event.\n */\nfunction buildProfileEventTags(tags) {\n // Tags already contains the common tags for all events. (service, env, version, etc.)\n // Here we are adding some specific-to-profiling tags.\n const profileEventTags = tags.concat(['language:javascript', 'runtime:chrome', 'family:chrome', 'host:browser']);\n return profileEventTags;\n}\n//# sourceMappingURL=assembly.js.map","import { addEventListener, clearTimeout, setTimeout, monitorError, display, getGlobalObject, clocksOrigin, clocksNow, elapsed, } from '@datadog/browser-core';\nimport { createFormDataTransport } from '@datadog/browser-rum-core';\nimport { getNumberOfSamples } from './utils/getNumberOfSamples';\nimport { getCustomOrDefaultViewName } from './utils/getCustomOrDefaultViewName';\nimport { assembleProfilingPayload } from './transport/assembly';\nexport const DEFAULT_RUM_PROFILER_CONFIGURATION = {\n sampleIntervalMs: 10, // Sample stack trace every 10ms\n collectIntervalMs: 60000, // Collect data every minute\n minProfileDurationMs: 5000, // Require at least 5 seconds of profile data to reduce noise and cost\n minNumberOfSamples: 50, // Require at least 50 samples (~500 ms) to report a profile to reduce noise and cost\n};\nexport function createRumProfiler(configuration, lifeCycle, session, profilingContextManager, longTaskContexts, createEncoder, viewHistory, profilerConfiguration = DEFAULT_RUM_PROFILER_CONFIGURATION) {\n const transport = createFormDataTransport(configuration, lifeCycle, createEncoder, 6 /* DeflateEncoderStreamId.PROFILING */);\n let lastViewEntry;\n // Global clean-up tasks for listeners that are not specific to a profiler instance (eg. visibility change, before unload)\n const globalCleanupTasks = [];\n let instance = { state: 'stopped', stateReason: 'initializing' };\n // Stops the profiler when session expires\n lifeCycle.subscribe(9 /* LifeCycleEventType.SESSION_EXPIRED */, () => {\n stopProfiling('session-expired').catch(monitorError);\n });\n // Start the profiler again when session is renewed\n lifeCycle.subscribe(10 /* LifeCycleEventType.SESSION_RENEWED */, () => {\n if (instance.state === 'stopped' && instance.stateReason === 'session-expired') {\n start(); // Only restart the profiler if it was stopped due to session expiration. Avoid restarting the profiler if it was stopped manually by the user.\n }\n });\n // Public API to start the profiler.\n function start() {\n if (instance.state === 'running') {\n return;\n }\n const viewEntry = viewHistory.findView();\n // Add initial view\n // Note: `viewEntry.name` is only filled when users use manual view creation via `startView` method.\n lastViewEntry = viewEntry\n ? {\n startClocks: viewEntry.startClocks,\n viewId: viewEntry.id,\n viewName: getCustomOrDefaultViewName(viewEntry.name, document.location.pathname),\n }\n : undefined;\n // Add global clean-up tasks for listeners that are not specific to a profiler instance (eg. visibility change, before unload)\n globalCleanupTasks.push(addEventListener(configuration, window, \"visibilitychange\" /* DOM_EVENT.VISIBILITY_CHANGE */, handleVisibilityChange).stop, addEventListener(configuration, window, \"beforeunload\" /* DOM_EVENT.BEFORE_UNLOAD */, handleBeforeUnload).stop);\n // Start profiler instance\n startNextProfilerInstance();\n }\n // Public API to manually stop the profiler.\n async function stop() {\n await stopProfiling('stopped-by-user');\n }\n async function stopProfiling(reason) {\n // Stop current profiler instance\n await stopProfilerInstance(reason);\n // Cleanup global listeners\n globalCleanupTasks.forEach((task) => task());\n // Update Profiling status once the Profiler has been stopped.\n profilingContextManager.set({ status: 'stopped', error_reason: undefined });\n }\n /**\n * Whenever a new Profiler instance is started, we need to add event listeners to surroundings (RUM Events, Long Tasks, etc) to enrich the Profiler data.\n * If the instance is already running, we can keep the same event listeners.\n */\n function addEventListeners(existingInstance) {\n if (existingInstance.state === 'running') {\n // Instance is already running, so we can keep same event listeners.\n return {\n cleanupTasks: existingInstance.cleanupTasks,\n };\n }\n // Store clean-up tasks for this instance (tasks to be executed when the Profiler is stopped or paused.)\n const cleanupTasks = [];\n // Whenever the View is updated, we add a views entry to the profiler instance.\n const viewUpdatedSubscription = lifeCycle.subscribe(2 /* LifeCycleEventType.VIEW_CREATED */, (view) => {\n const viewEntry = {\n viewId: view.id,\n // Note: `viewName` is only filled when users use manual view creation via `startView` method.\n viewName: getCustomOrDefaultViewName(view.name, document.location.pathname),\n startClocks: view.startClocks,\n };\n collectViewEntry(viewEntry);\n // Update last view entry\n lastViewEntry = viewEntry;\n });\n cleanupTasks.push(viewUpdatedSubscription.unsubscribe);\n return {\n cleanupTasks,\n };\n }\n function startNextProfilerInstance() {\n // These APIs might be unavailable in some browsers\n const globalThisProfiler = getGlobalObject().Profiler;\n if (!globalThisProfiler) {\n profilingContextManager.set({ status: 'error', error_reason: 'not-supported-by-browser' });\n throw new Error('RUM Profiler is not supported in this browser.');\n }\n // Don't wait for data collection to start next instance\n collectProfilerInstance(instance).catch(monitorError);\n const { cleanupTasks } = addEventListeners(instance);\n let profiler;\n try {\n // We have to create new Profiler each time we start a new instance\n profiler = new globalThisProfiler({\n sampleInterval: profilerConfiguration.sampleIntervalMs,\n // Keep buffer size at 1.5 times of minimum required to collect data for a profiling instance\n maxBufferSize: Math.round((profilerConfiguration.collectIntervalMs * 1.5) / profilerConfiguration.sampleIntervalMs),\n });\n }\n catch (e) {\n if (e instanceof Error && e.message.includes('disabled by Document Policy')) {\n // Missing Response Header (`js-profiling`) that is required to enable the profiler.\n // We should suggest the user to enable the Response Header in their server configuration.\n display.warn('[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.', e);\n profilingContextManager.set({ status: 'error', error_reason: 'missing-document-policy-header' });\n }\n else {\n profilingContextManager.set({ status: 'error', error_reason: 'unexpected-exception' });\n }\n return;\n }\n profilingContextManager.set({ status: 'running', error_reason: undefined });\n // Kick-off the new instance\n instance = {\n state: 'running',\n startClocks: clocksNow(),\n profiler,\n timeoutId: setTimeout(startNextProfilerInstance, profilerConfiguration.collectIntervalMs),\n views: [],\n cleanupTasks,\n longTasks: [],\n };\n // Add last view entry\n collectViewEntry(lastViewEntry);\n // Add event handler case we overflow the buffer\n profiler.addEventListener('samplebufferfull', handleSampleBufferFull);\n }\n async function collectProfilerInstance(lastInstance) {\n if (lastInstance.state !== 'running') {\n return;\n }\n // Cleanup instance\n clearTimeout(lastInstance.timeoutId);\n lastInstance.profiler.removeEventListener('samplebufferfull', handleSampleBufferFull);\n // Store instance data snapshot in local variables to use in async callback\n const { startClocks, views } = lastInstance;\n // Stop current profiler to get trace\n await lastInstance.profiler\n .stop()\n .then((trace) => {\n const endClocks = clocksNow();\n const duration = elapsed(startClocks.timeStamp, endClocks.timeStamp);\n const longTasks = longTaskContexts.findLongTasks(startClocks.relative, duration);\n const isBelowDurationThreshold = duration < profilerConfiguration.minProfileDurationMs;\n const isBelowSampleThreshold = getNumberOfSamples(trace.samples) < profilerConfiguration.minNumberOfSamples;\n if (longTasks.length === 0 && (isBelowDurationThreshold || isBelowSampleThreshold)) {\n // Skip very short profiles to reduce noise and cost, but keep them if they contain long tasks.\n return;\n }\n handleProfilerTrace(\n // Enrich trace with time and instance data\n Object.assign(trace, {\n startClocks,\n endClocks,\n clocksOrigin: clocksOrigin(),\n longTasks,\n views,\n sampleInterval: profilerConfiguration.sampleIntervalMs,\n }));\n })\n .catch(monitorError);\n }\n async function stopProfilerInstance(stateReason) {\n if (instance.state !== 'running') {\n return;\n }\n await onPauseOrStopProfilerInstance();\n instance = { state: 'stopped', stateReason };\n }\n async function pauseProfilerInstance() {\n if (instance.state !== 'running') {\n return;\n }\n await onPauseOrStopProfilerInstance();\n instance = { state: 'paused' };\n }\n async function onPauseOrStopProfilerInstance() {\n if (instance.state !== 'running') {\n return;\n }\n // Cleanup tasks\n instance.cleanupTasks.forEach((cleanupTask) => cleanupTask());\n await collectProfilerInstance(instance);\n }\n function collectViewEntry(viewEntry) {\n if (instance.state !== 'running' || !viewEntry) {\n return;\n }\n // Add entry to views\n instance.views.push(viewEntry);\n }\n function handleProfilerTrace(trace) {\n var _a;\n // Find current session to assign it to the Profile.\n const sessionId = (_a = session.findTrackedSession()) === null || _a === void 0 ? void 0 : _a.id;\n const payload = assembleProfilingPayload(trace, configuration, sessionId);\n void transport.send(payload);\n }\n function handleSampleBufferFull() {\n startNextProfilerInstance();\n }\n function handleVisibilityChange() {\n if (document.visibilityState === 'hidden' && instance.state === 'running') {\n // Pause when tab is hidden. We use paused state to distinguish between\n // paused by visibility change and stopped by user.\n // If profiler is paused by the visibility change, we should resume when\n // tab becomes visible again. That's not the case when user stops the profiler.\n pauseProfilerInstance().catch(monitorError);\n }\n else if (document.visibilityState === 'visible' && instance.state === 'paused') {\n // Resume when tab becomes visible again\n startNextProfilerInstance();\n }\n }\n function handleBeforeUnload() {\n // `unload` can in some cases be triggered while the page is still active (link to a different protocol like mailto:).\n // We can immediately flush (by starting a new profiler instance) to make sure we receive the data, and at the same time keep the profiler active.\n // In case of the regular unload, the profiler will be shut down anyway.\n startNextProfilerInstance();\n }\n function isStopped() {\n return instance.state === 'stopped';\n }\n function isRunning() {\n return instance.state === 'running';\n }\n function isPaused() {\n return instance.state === 'paused';\n }\n return { start, stop, isStopped, isRunning, isPaused };\n}\n//# sourceMappingURL=profiler.js.map"],"names":["createFormDataTransport","configuration","lifeCycle","createEncoder","streamId","reportError","error","addTelemetryDebug","httpRequest","createHttpRequest","encoder","_a","_b","event","attachments","__objRest","formData","serializedEvent","jsonStringify","bytesCount","key","value","objectEntries","serializedValue","result","encode","data","resolve","encoderResult","getNumberOfSamples","samples","numberOfSamples","sample","PATH_MIXED_ALPHANUMERICS","getDefaultViewName","viewPathUrl","getCustomOrDefaultViewName","customViewName","buildProfileEventAttributes","profilerTrace","applicationId","sessionId","attributes","ids","names","extractViewIdsAndNames","longTaskIds","longTask","id","views","view","assembleProfilingPayload","buildProfileEvent","tags","buildTags","profileAttributes","profileEventTags","buildProfileEventTags","__spreadProps","__spreadValues","currentDrift","DEFAULT_RUM_PROFILER_CONFIGURATION","createRumProfiler","session","profilingContextManager","longTaskContexts","viewHistory","profilerConfiguration","transport","lastViewEntry","globalCleanupTasks","instance","stopProfiling","monitorError","start","viewEntry","addEventListener","handleVisibilityChange","handleBeforeUnload","startNextProfilerInstance","stop","reason","stopProfilerInstance","task","addEventListeners","existingInstance","cleanupTasks","viewUpdatedSubscription","collectViewEntry","globalThisProfiler","getGlobalObject","collectProfilerInstance","profiler","e","display","clocksNow","setTimeout","handleSampleBufferFull","lastInstance","clearTimeout","startClocks","trace","endClocks","duration","elapsed","longTasks","isBelowDurationThreshold","isBelowSampleThreshold","handleProfilerTrace","clocksOrigin","stateReason","onPauseOrStopProfilerInstance","pauseProfilerInstance","cleanupTask","payload","isStopped","isRunning","isPaused"],"mappings":"+tBACO,SAASA,GAAwBC,EAAeC,EAAWC,EAAeC,EAAU,CACvF,MAAMC,EAAeC,GAAU,CAC3BJ,EAAU,OAAO,GAAiD,CAAE,MAAAI,CAAK,CAAE,EAE3EC,GAAkB,6BAA8B,CAAE,gBAAiBD,EAAM,OAAO,CAAE,CACtF,EACME,EAAcC,EAAkB,CAACR,EAAc,wBAAwB,EAAGI,CAAW,EACrFK,EAAUP,EAAcC,CAAQ,EACtC,MAAO,CACH,MAAM,KAAKO,EAA2B,CAA3B,IAAAC,EAAAD,EAAE,OAAAE,GAAFD,EAAYE,EAAAC,EAAZH,EA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/D,GAAyBkD,EAAOpG,EAAewC,CAAS,EACnE2B,EAAU,KAAK8C,CAAO,CAC/B,CACA,SAASjB,GAAyB,CAC9BlB,EAAyB,CAC7B,CACA,SAASF,GAAyB,CAC1B,SAAS,kBAAoB,UAAYN,EAAS,QAAU,UAK5DyC,EAAqB,EAAG,MAAMvC,CAAY,EAErC,SAAS,kBAAoB,WAAaF,EAAS,QAAU,UAElEQ,EAAyB,CAEjC,CACA,SAASD,GAAqB,CAI1BC,EAAyB,CAC7B,CACA,SAASoC,GAAY,CACjB,OAAO5C,EAAS,QAAU,SAC9B,CACA,SAAS6C,GAAY,CACjB,OAAO7C,EAAS,QAAU,SAC9B,CACA,SAAS8C,GAAW,CAChB,OAAO9C,EAAS,QAAU,QAC9B,CACA,MAAO,CAAE,MAAAG,EAAO,KAAAM,EAAM,UAAAmC,EAAW,UAAAC,EAAW,SAAAC,CAAQ,CACxD","x_google_ignoreList":[0,1,2,3,4,5,6]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=[],ne=function(){return c.some(function(e){return e.activeTargets.length>0})},oe=function(){return c.some(function(e){return e.skippedTargets.length>0})},P="ResizeObserver loop completed with undelivered notifications.",se=function(){var e;typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:P}):(e=document.createEvent("Event"),e.initEvent("error",!1,!1),e.message=P),window.dispatchEvent(e)},b;(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(b||(b={}));var u=function(e){return Object.freeze(e)},ae=function(){function e(t,r){this.inlineSize=t,this.blockSize=r,u(this)}return e}(),q=function(){function e(t,r,i,n){return this.x=t,this.y=r,this.width=i,this.height=n,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,u(this)}return e.prototype.toJSON=function(){var t=this,r=t.x,i=t.y,n=t.top,s=t.right,o=t.bottom,h=t.left,d=t.width,v=t.height;return{x:r,y:i,top:n,right:s,bottom:o,left:h,width:d,height:v}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),C=function(e){return e instanceof SVGElement&&"getBBox"in e},G=function(e){if(C(e)){var t=e.getBBox(),r=t.width,i=t.height;return!r&&!i}var n=e,s=n.offsetWidth,o=n.offsetHeight;return!(s||o||e.getClientRects().length)},I=function(e){var t;if(e instanceof Element)return!0;var r=(t=e==null?void 0:e.ownerDocument)===null||t===void 0?void 0:t.defaultView;return!!(r&&e instanceof r.Element)},ve=function(e){switch(e.tagName){case"INPUT":if(e.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},p=typeof window!="undefined"?window:{},z=new WeakMap,_=/auto|scroll/,ce=/^tb|vertical/,ue=/msie|trident/i.test(p.navigator&&p.navigator.userAgent),a=function(e){return parseFloat(e||"0")},f=function(e,t,r){return e===void 0&&(e=0),t===void 0&&(t=0),r===void 0&&(r=!1),new ae((r?t:e)||0,(r?e:t)||0)},W=u({devicePixelContentBoxSize:f(),borderBoxSize:f(),contentBoxSize:f(),contentRect:new q(0,0,0,0)}),J=function(e,t){if(t===void 0&&(t=!1),z.has(e)&&!t)return z.get(e);if(G(e))return z.set(e,W),W;var r=getComputedStyle(e),i=C(e)&&e.ownerSVGElement&&e.getBBox(),n=!ue&&r.boxSizing==="border-box",s=ce.test(r.writingMode||""),o=!i&&_.test(r.overflowY||""),h=!i&&_.test(r.overflowX||""),d=i?0:a(r.paddingTop),v=i?0:a(r.paddingRight),R=i?0:a(r.paddingBottom),l=i?0:a(r.paddingLeft),Q=i?0:a(r.borderTopWidth),Z=i?0:a(r.borderRightWidth),$=i?0:a(r.borderBottomWidth),j=i?0:a(r.borderLeftWidth),D=l+v,k=d+R,y=j+Z,T=Q+$,N=h?e.offsetHeight-T-e.clientHeight:0,A=o?e.offsetWidth-y-e.clientWidth:0,ee=n?D+y:0,te=n?k+T:0,g=i?i.width:a(r.width)-ee-A,x=i?i.height:a(r.height)-te-N,re=g+D+A+y,ie=x+k+N+T,M=u({devicePixelContentBoxSize:f(Math.round(g*devicePixelRatio),Math.round(x*devicePixelRatio),s),borderBoxSize:f(re,ie,s),contentBoxSize:f(g,x,s),contentRect:new q(l,d,g,x)});return z.set(e,M),M},U=function(e,t,r){var i=J(e,r),n=i.borderBoxSize,s=i.contentBoxSize,o=i.devicePixelContentBoxSize;switch(t){case b.DEVICE_PIXEL_CONTENT_BOX:return o;case b.BORDER_BOX:return n;default:return s}},he=function(){function e(t){var r=J(t);this.target=t,this.contentRect=r.contentRect,this.borderBoxSize=u([r.borderBoxSize]),this.contentBoxSize=u([r.contentBoxSize]),this.devicePixelContentBoxSize=u([r.devicePixelContentBoxSize])}return e}(),Y=function(e){if(G(e))return 1/0;for(var t=0,r=e.parentNode;r;)t+=1,r=r.parentNode;return t},de=function(){var e=1/0,t=[];c.forEach(function(o){if(o.activeTargets.length!==0){var h=[];o.activeTargets.forEach(function(v){var R=new he(v.target),l=Y(v.target);h.push(R),v.lastReportedSize=U(v.target,v.observedBox),l<e&&(e=l)}),t.push(function(){o.callback.call(o.observer,h,o.observer)}),o.activeTargets.splice(0,o.activeTargets.length)}});for(var r=0,i=t;r<i.length;r++){var n=i[r];n()}return e},L=function(e){c.forEach(function(r){r.activeTargets.splice(0,r.activeTargets.length),r.skippedTargets.splice(0,r.skippedTargets.length),r.observationTargets.forEach(function(n){n.isActive()&&(Y(n.target)>e?r.activeTargets.push(n):r.skippedTargets.push(n))})})},fe=function(){var e=0;for(L(e);ne();)e=de(),L(e);return oe()&&se(),e>0},m,K=[],le=function(){return K.splice(0).forEach(function(e){return e()})},pe=function(e){if(!m){var t=0,r=document.createTextNode(""),i={characterData:!0};new MutationObserver(function(){return le()}).observe(r,i),m=function(){r.textContent="".concat(t?t--:t++)}}K.push(e),m()},be=function(e){pe(function(){requestAnimationFrame(e)})},w=0,ge=function(){return!!w},xe=250,ze={attributes:!0,characterData:!0,childList:!0,subtree:!0},F=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],H=function(e){return e===void 0&&(e=0),Date.now()+e},B=!1,Ee=function(){function e(){var t=this;this.stopped=!0,this.listener=function(){return t.schedule()}}return e.prototype.run=function(t){var r=this;if(t===void 0&&(t=xe),!B){B=!0;var i=H(t);be(function(){var n=!1;try{n=fe()}finally{if(B=!1,t=i-H(),!ge())return;n?r.run(1e3):t>0?r.run(t):r.start()}})}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var t=this,r=function(){return t.observer&&t.observer.observe(document.body,ze)};document.body?r():p.addEventListener("DOMContentLoaded",r)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),F.forEach(function(r){return p.addEventListener(r,t.listener,!0)}))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),F.forEach(function(r){return p.removeEventListener(r,t.listener,!0)}),this.stopped=!0)},e}(),S=new Ee,V=function(e){!w&&e>0&&S.start(),w+=e,!w&&S.stop()},Oe=function(e){return!C(e)&&!ve(e)&&getComputedStyle(e).display==="inline"},we=function(){function e(t,r){this.target=t,this.observedBox=r||b.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t=U(this.target,this.observedBox,!0);return Oe(this.target)&&(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),Re=function(){function e(t,r){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=t,this.callback=r}return e}(),E=new WeakMap,X=function(e,t){for(var r=0;r<e.length;r+=1)if(e[r].target===t)return r;return-1},O=function(){function e(){}return e.connect=function(t,r){var i=new Re(t,r);E.set(t,i)},e.observe=function(t,r,i){var n=E.get(t),s=n.observationTargets.length===0;X(n.observationTargets,r)<0&&(s&&c.push(n),n.observationTargets.push(new we(r,i&&i.box)),V(1),S.schedule())},e.unobserve=function(t,r){var i=E.get(t),n=X(i.observationTargets,r),s=i.observationTargets.length===1;n>=0&&(s&&c.splice(c.indexOf(i),1),i.observationTargets.splice(n,1),V(-1))},e.disconnect=function(t){var r=this,i=E.get(t);i.observationTargets.slice().forEach(function(n){return r.unobserve(t,n.target)}),i.activeTargets.splice(0,i.activeTargets.length)},e}(),ye=function(){function e(t){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof t!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");O.connect(this,t)}return e.prototype.observe=function(t,r){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!I(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");O.observe(this,t,r)},e.prototype.unobserve=function(t){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!I(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");O.unobserve(this,t)},e.prototype.disconnect=function(){O.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}();export{ye as ResizeObserver,he as ResizeObserverEntry,ae as ResizeObserverSize};
|
|
2
|
+
//# sourceMappingURL=resize-observer-DqyxKk7V.js.map
|