@newrelic/browser-agent 1.237.1 → 1.239.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/dist/cjs/common/config/state/init.js +21 -13
- package/dist/cjs/common/config/state/runtime.js +0 -4
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +3 -3
- package/dist/cjs/common/constants/shared-channel.js +3 -1
- package/dist/cjs/common/deny-list/deny-list.js +3 -9
- package/dist/cjs/common/drain/drain.js +1 -1
- package/dist/cjs/common/event-emitter/contextual-ee.js +24 -32
- package/dist/cjs/common/event-emitter/event-context.js +12 -0
- package/dist/cjs/common/harvest/harvest-scheduler.js +2 -4
- package/dist/cjs/common/harvest/harvest.js +4 -7
- package/dist/cjs/common/ids/bundle-id.js +19 -0
- package/dist/cjs/common/serialize/bel-serializer.js +1 -1
- package/dist/cjs/common/session/session-entity.js +16 -12
- package/dist/cjs/common/storage/first-party-cookies.js +5 -4
- package/dist/cjs/common/storage/local-storage.js +3 -2
- package/dist/cjs/common/timer/interaction-timer.js +14 -6
- package/dist/cjs/common/timing/nav-timing.js +1 -1
- package/dist/cjs/common/unload/eol.js +4 -30
- package/dist/cjs/common/util/feature-flags.js +14 -15
- package/dist/cjs/common/util/invoke.js +3 -1
- package/dist/cjs/common/util/obfuscate.js +3 -5
- package/dist/cjs/common/util/traverse.js +1 -0
- package/dist/cjs/common/window/page-visibility.js +1 -2
- package/dist/cjs/common/wrap/wrap-events.js +3 -2
- package/dist/cjs/common/wrap/wrap-fetch.js +1 -3
- package/dist/cjs/common/wrap/wrap-function.js +15 -46
- package/dist/cjs/common/wrap/wrap-jsonp.js +1 -1
- package/dist/cjs/common/wrap/wrap-mutation.js +1 -2
- package/dist/cjs/common/wrap/wrap-promise.js +2 -3
- package/dist/cjs/common/wrap/wrap-xhr.js +23 -27
- package/dist/cjs/features/ajax/aggregate/index.js +5 -7
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +8 -12
- package/dist/cjs/features/ajax/instrument/index.js +66 -24
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +0 -1
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +4 -4
- package/dist/cjs/features/jserrors/aggregate/index.js +4 -5
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +103 -7
- package/dist/cjs/features/metrics/aggregate/index.js +20 -37
- package/dist/cjs/features/metrics/instrument/index.js +0 -2
- package/dist/cjs/features/page_action/aggregate/index.js +17 -19
- package/dist/cjs/features/page_view_event/aggregate/index.js +1 -2
- package/dist/cjs/features/page_view_event/instrument/index.js +4 -2
- package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -7
- package/dist/cjs/features/session_replay/aggregate/index.js +5 -3
- package/dist/cjs/features/session_trace/aggregate/index.js +22 -16
- package/dist/cjs/features/spa/aggregate/index.js +14 -20
- package/dist/cjs/features/spa/aggregate/interaction.js +0 -2
- package/dist/cjs/features/spa/aggregate/serializer.js +1 -1
- package/dist/cjs/features/utils/aggregate-base.js +4 -0
- package/dist/cjs/features/utils/handler-cache.js +3 -1
- package/dist/cjs/features/utils/instrument-base.js +24 -6
- package/dist/cjs/loaders/agent-base.js +23 -0
- package/dist/cjs/loaders/agent.js +7 -7
- package/dist/cjs/loaders/api/api.js +34 -4
- package/dist/cjs/loaders/api/apiAsync.js +19 -20
- package/dist/cjs/loaders/api/interaction-types.js +11 -4
- package/dist/cjs/loaders/configure/configure.js +3 -0
- package/dist/cjs/loaders/micro-agent.js +20 -3
- package/dist/esm/common/config/state/init.js +21 -13
- package/dist/esm/common/config/state/runtime.js +0 -4
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +1 -1
- package/dist/esm/common/constants/shared-channel.js +3 -1
- package/dist/esm/common/deny-list/deny-list.js +3 -9
- package/dist/esm/common/drain/drain.js +1 -1
- package/dist/esm/common/event-emitter/contextual-ee.js +22 -29
- package/dist/esm/common/event-emitter/event-context.js +5 -0
- package/dist/esm/common/harvest/harvest-scheduler.js +2 -4
- package/dist/esm/common/harvest/harvest.js +4 -7
- package/dist/esm/common/ids/bundle-id.js +13 -0
- package/dist/esm/common/serialize/bel-serializer.js +1 -1
- package/dist/esm/common/session/session-entity.js +16 -12
- package/dist/esm/common/storage/first-party-cookies.js +5 -4
- package/dist/esm/common/storage/local-storage.js +3 -2
- package/dist/esm/common/timer/interaction-timer.js +14 -6
- package/dist/esm/common/timing/nav-timing.js +1 -1
- package/dist/esm/common/unload/eol.js +5 -31
- package/dist/esm/common/util/feature-flags.js +14 -15
- package/dist/esm/common/util/invoke.js +3 -1
- package/dist/esm/common/util/obfuscate.js +3 -5
- package/dist/esm/common/util/traverse.js +1 -0
- package/dist/esm/common/window/page-visibility.js +1 -2
- package/dist/esm/common/wrap/wrap-events.js +4 -3
- package/dist/esm/common/wrap/wrap-fetch.js +2 -4
- package/dist/esm/common/wrap/wrap-function.js +15 -44
- package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
- package/dist/esm/common/wrap/wrap-mutation.js +2 -3
- package/dist/esm/common/wrap/wrap-promise.js +3 -4
- package/dist/esm/common/wrap/wrap-xhr.js +23 -27
- package/dist/esm/features/ajax/aggregate/index.js +5 -7
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +8 -12
- package/dist/esm/features/ajax/instrument/index.js +67 -25
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +0 -1
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +4 -4
- package/dist/esm/features/jserrors/aggregate/index.js +4 -5
- package/dist/esm/features/metrics/aggregate/framework-detection.js +103 -7
- package/dist/esm/features/metrics/aggregate/index.js +22 -39
- package/dist/esm/features/metrics/instrument/index.js +1 -3
- package/dist/esm/features/page_action/aggregate/index.js +17 -19
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
- package/dist/esm/features/page_view_event/instrument/index.js +4 -2
- package/dist/esm/features/page_view_timing/aggregate/index.js +7 -8
- package/dist/esm/features/session_replay/aggregate/index.js +4 -2
- package/dist/esm/features/session_trace/aggregate/index.js +22 -16
- package/dist/esm/features/spa/aggregate/index.js +14 -20
- package/dist/esm/features/spa/aggregate/interaction.js +0 -2
- package/dist/esm/features/spa/aggregate/serializer.js +1 -1
- package/dist/esm/features/utils/aggregate-base.js +4 -0
- package/dist/esm/features/utils/handler-cache.js +3 -1
- package/dist/esm/features/utils/instrument-base.js +24 -6
- package/dist/esm/loaders/agent-base.js +23 -0
- package/dist/esm/loaders/agent.js +7 -7
- package/dist/esm/loaders/api/api.js +34 -4
- package/dist/esm/loaders/api/apiAsync.js +19 -20
- package/dist/esm/loaders/api/interaction-types.js +11 -4
- package/dist/esm/loaders/configure/configure.js +3 -0
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/micro-agent.js +21 -4
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/constants/runtime.d.ts +1 -1
- package/dist/types/common/constants/runtime.d.ts.map +1 -1
- package/dist/types/common/event-emitter/contextual-ee.d.ts +22 -2
- package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
- package/dist/types/common/event-emitter/event-context.d.ts +5 -0
- package/dist/types/common/event-emitter/event-context.d.ts.map +1 -0
- package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/ids/bundle-id.d.ts +5 -0
- package/dist/types/common/ids/bundle-id.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +12 -15
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/storage/first-party-cookies.d.ts +1 -1
- package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -1
- package/dist/types/common/storage/local-storage.d.ts.map +1 -1
- package/dist/types/common/timer/interaction-timer.d.ts +3 -0
- package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
- package/dist/types/common/unload/eol.d.ts +1 -2
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/util/traverse.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts +2 -2
- package/dist/types/common/window/page-visibility.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-events.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-function.d.ts +1 -19
- package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +5 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +1 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +15 -0
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts +7 -0
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
- package/dist/types/loaders/api/interaction-types.d.ts +18 -7
- package/dist/types/loaders/api/interaction-types.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts +2 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +9 -9
- package/dist/types/loaders/micro-agent.d.ts +7 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +62 -38
- package/src/common/aggregate/aggregator.test.js +107 -0
- package/src/common/config/state/configurable.test.js +73 -0
- package/src/common/config/state/info.test.js +31 -0
- package/src/common/config/state/init.js +13 -12
- package/src/common/config/state/init.test.js +28 -0
- package/src/common/config/state/loader-config.test.js +21 -0
- package/src/common/config/state/runtime.js +0 -2
- package/src/common/config/state/runtime.test.js +21 -0
- package/src/common/constants/__mocks__/runtime.js +1 -1
- package/src/common/constants/runtime.js +1 -1
- package/src/common/constants/runtime.test.js +2 -2
- package/src/common/constants/shared-channel.js +1 -1
- package/src/common/deny-list/deny-list.js +3 -11
- package/src/common/deny-list/deny-list.test.js +103 -30
- package/src/common/drain/drain.js +1 -1
- package/src/common/drain/drain.test.js +74 -0
- package/src/common/event-emitter/{contextual-ee.test.js → contextual-ee.component-test.js} +15 -32
- package/src/common/event-emitter/contextual-ee.js +26 -37
- package/src/common/event-emitter/event-context.js +5 -0
- package/src/common/harvest/harvest-scheduler.js +2 -5
- package/src/common/harvest/harvest-scheduler.test.js +2 -6
- package/src/common/harvest/harvest.js +4 -7
- package/src/common/harvest/harvest.test.js +1 -3
- package/src/common/ids/__mocks__/bundle-id.js +2 -0
- package/src/common/ids/__mocks__/unique-id.js +17 -0
- package/src/common/ids/bundle-id.js +13 -0
- package/src/common/ids/id.test.js +6 -6
- package/src/common/serialize/bel-serializer.js +1 -1
- package/src/common/session/session-entity.component-test.js +3 -2
- package/src/common/session/session-entity.js +11 -9
- package/src/common/storage/first-party-cookies.js +5 -4
- package/src/common/storage/local-storage.js +3 -2
- package/src/common/timer/interaction-timer.component-test.js +52 -7
- package/src/common/timer/interaction-timer.js +15 -6
- package/src/common/timer/timer.test.js +0 -1
- package/src/common/timing/nav-timing.js +1 -1
- package/src/common/unload/eol.js +5 -31
- package/src/common/url/__mocks__/parse-url.js +15 -0
- package/src/common/url/{encode.component-test.js → encode.test.js} +1 -0
- package/src/common/util/__mocks__/get-or-set.js +5 -0
- package/src/common/util/__mocks__/invoke.js +1 -0
- package/src/common/util/data-size.test.js +0 -1
- package/src/common/util/feature-flags.js +15 -17
- package/src/common/util/feature-flags.test.js +4 -8
- package/src/common/util/invoke.js +1 -1
- package/src/common/util/obfuscate.js +3 -5
- package/src/common/util/submit-data.test.js +1 -1
- package/src/common/util/traverse.js +1 -0
- package/src/common/window/__mocks__/nreum.js +12 -0
- package/src/common/window/page-visibility.js +1 -2
- package/src/common/wrap/wrap-events.js +4 -3
- package/src/common/wrap/wrap-fetch.js +2 -4
- package/src/common/wrap/wrap-function.js +16 -44
- package/src/common/wrap/wrap-jsonp.js +1 -1
- package/src/common/wrap/wrap-mutation.js +2 -3
- package/src/common/wrap/{wrap-promise.test.js → wrap-promise.component-test.js} +2 -32
- package/src/common/wrap/wrap-promise.js +3 -4
- package/src/common/wrap/wrap-xhr.js +24 -28
- package/src/features/ajax/aggregate/index.js +5 -7
- package/src/features/ajax/instrument/distributed-tracing.js +8 -12
- package/src/features/ajax/instrument/distributed-tracing.test.js +375 -0
- package/src/features/ajax/instrument/index.js +62 -27
- package/src/features/jserrors/aggregate/canonical-function-name.js +0 -2
- package/src/features/jserrors/aggregate/compute-stack-trace.js +4 -4
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
- package/src/features/jserrors/aggregate/index.js +4 -5
- package/src/features/metrics/aggregate/framework-detection.js +129 -8
- package/src/features/metrics/aggregate/framework-detection.test.js +213 -82
- package/src/features/metrics/aggregate/index.js +22 -45
- package/src/features/metrics/instrument/index.js +1 -3
- package/src/features/page_action/aggregate/index.js +12 -13
- package/src/features/page_view_event/aggregate/index.js +1 -2
- package/src/features/page_view_event/instrument/index.js +2 -2
- package/src/features/page_view_timing/aggregate/index.js +7 -8
- package/src/features/session_replay/aggregate/index.component-test.js +3 -15
- package/src/features/session_replay/aggregate/index.js +4 -2
- package/src/features/session_trace/aggregate/index.js +22 -16
- package/src/features/spa/aggregate/index.js +14 -20
- package/src/features/spa/aggregate/interaction.js +0 -2
- package/src/features/spa/aggregate/serializer.js +1 -1
- package/src/features/utils/aggregate-base.js +5 -0
- package/src/features/utils/aggregate-base.test.js +2 -1
- package/src/features/utils/handler-cache.js +3 -2
- package/src/features/utils/instrument-base.js +25 -6
- package/src/features/utils/instrument-base.test.js +2 -2
- package/src/loaders/agent-base.js +23 -0
- package/src/loaders/agent.js +7 -7
- package/src/loaders/api/api.component-test.js +45 -0
- package/src/loaders/api/api.js +34 -4
- package/src/loaders/api/api.test.js +85 -0
- package/src/loaders/api/apiAsync.js +19 -20
- package/src/loaders/api/apiAsync.test.js +17 -0
- package/src/loaders/api/interaction-types.js +11 -4
- package/src/loaders/configure/configure.js +3 -0
- package/src/loaders/features/enabled-features.js +1 -1
- package/src/loaders/micro-agent.js +22 -4
- package/dist/cjs/features/metrics/aggregate/endpoint-map.js +0 -14
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +0 -14
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +0 -53
- package/dist/esm/features/metrics/aggregate/endpoint-map.js +0 -7
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
- package/dist/esm/features/metrics/aggregate/polyfill-detection.js +0 -47
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +0 -8
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts.map +0 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +0 -6
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +0 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +0 -7
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +0 -1
- package/src/features/metrics/aggregate/endpoint-map.js +0 -7
- package/src/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
- package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -16
- package/src/features/metrics/aggregate/polyfill-detection.js +0 -48
- package/src/features/metrics/aggregate/polyfill-detection.test.js +0 -163
- /package/src/common/url/{protocol.component-test.js → protocol.test.js} +0 -0
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks for native globals to see if they have been polyfilled by customer code.
|
|
3
|
-
* @returns {string[]} Array of methods that were detected to have been polyfilled
|
|
4
|
-
*/
|
|
5
|
-
export function getPolyfills(): string[];
|
|
6
|
-
//# sourceMappingURL=polyfill-detection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill-detection.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/aggregate/polyfill-detection.js"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,gCAFa,MAAM,EAAE,CA0BpB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is used as a replacement for the polyfill-detection.es5.js
|
|
3
|
-
* file when running the polyfills webpack build.
|
|
4
|
-
* @returns {string[]} an empty array
|
|
5
|
-
*/
|
|
6
|
-
export function getPolyfills(): string[];
|
|
7
|
-
//# sourceMappingURL=polyfill-detection.es5.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill-detection.es5.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/aggregate/polyfill-detection.es5.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,gCAFa,MAAM,EAAE,CAIpB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getPolyfills } from './polyfill-detection.es5'
|
|
2
|
-
|
|
3
|
-
afterEach(() => {
|
|
4
|
-
jest.resetAllMocks()
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
test('should always return an empty array', () => {
|
|
8
|
-
const originalFn = Array.from
|
|
9
|
-
Array.from = jest.fn(function (...args) {
|
|
10
|
-
return originalFn.apply(this, args)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
expect(getPolyfills()).toEqual([])
|
|
14
|
-
|
|
15
|
-
Array.from = originalFn
|
|
16
|
-
})
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const detectionRegex = /\{ \[native code\] \}/
|
|
2
|
-
const POLYFILLS = {
|
|
3
|
-
FUNCTION_BIND: 'Function.bind',
|
|
4
|
-
FUNCTION_APPLY: 'Function.apply',
|
|
5
|
-
FUNCTION_CALL: 'Function.call',
|
|
6
|
-
ARRAY_INCLUDES: 'Array.includes',
|
|
7
|
-
ARRAY_FROM: 'Array.from',
|
|
8
|
-
ARRAY_FIND: 'Array.find',
|
|
9
|
-
ARRAY_FLAT: 'Array.flat',
|
|
10
|
-
ARRAY_FLATMAP: 'Array.flatMap',
|
|
11
|
-
OBJECT_ASSIGN: 'Object.assign',
|
|
12
|
-
OBJECT_ENTRIES: 'Object.entries',
|
|
13
|
-
OBJECT_VALUES: 'Object.values',
|
|
14
|
-
MAP: 'Map',
|
|
15
|
-
SET: 'Set',
|
|
16
|
-
WEAK_MAP: 'WeakMap',
|
|
17
|
-
WEAK_SET: 'WeakSet'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Checks for native globals to see if they have been polyfilled by customer code.
|
|
22
|
-
* @returns {string[]} Array of methods that were detected to have been polyfilled
|
|
23
|
-
*/
|
|
24
|
-
export function getPolyfills () {
|
|
25
|
-
const polyfills = []
|
|
26
|
-
const mockFunction = function () { /* noop */ }
|
|
27
|
-
try {
|
|
28
|
-
if (typeof mockFunction.bind === 'function' && !detectionRegex.test(mockFunction.bind.toString())) polyfills.push(POLYFILLS.FUNCTION_BIND)
|
|
29
|
-
if (typeof mockFunction.apply === 'function' && !detectionRegex.test(mockFunction.apply.toString())) polyfills.push(POLYFILLS.FUNCTION_APPLY)
|
|
30
|
-
if (typeof mockFunction.call === 'function' && !detectionRegex.test(mockFunction.call.toString())) polyfills.push(POLYFILLS.FUNCTION_CALL)
|
|
31
|
-
if (typeof [].includes === 'function' && !detectionRegex.test([].includes.toString())) polyfills.push(POLYFILLS.ARRAY_INCLUDES)
|
|
32
|
-
if (typeof Array.from === 'function' && !detectionRegex.test(Array.from.toString())) polyfills.push(POLYFILLS.ARRAY_FROM)
|
|
33
|
-
if (typeof [].find === 'function' && !detectionRegex.test([].find.toString())) polyfills.push(POLYFILLS.ARRAY_FIND)
|
|
34
|
-
if (typeof [].flat === 'function' && !detectionRegex.test([].flat.toString())) polyfills.push(POLYFILLS.ARRAY_FLAT)
|
|
35
|
-
if (typeof [].flatMap === 'function' && !detectionRegex.test([].flatMap.toString())) polyfills.push(POLYFILLS.ARRAY_FLATMAP)
|
|
36
|
-
if (typeof Object.assign === 'function' && !detectionRegex.test(Object.assign.toString())) polyfills.push(POLYFILLS.OBJECT_ASSIGN)
|
|
37
|
-
if (typeof Object.entries === 'function' && !detectionRegex.test(Object.entries.toString())) polyfills.push(POLYFILLS.OBJECT_ENTRIES)
|
|
38
|
-
if (typeof Object.values === 'function' && !detectionRegex.test(Object.values.toString())) polyfills.push(POLYFILLS.OBJECT_VALUES)
|
|
39
|
-
if (typeof Map === 'function' && !detectionRegex.test(Map.toString())) polyfills.push(POLYFILLS.MAP)
|
|
40
|
-
if (typeof Set === 'function' && !detectionRegex.test(Set.toString())) polyfills.push(POLYFILLS.SET)
|
|
41
|
-
if (typeof WeakMap === 'function' && !detectionRegex.test(WeakMap.toString())) polyfills.push(POLYFILLS.WEAK_MAP)
|
|
42
|
-
if (typeof WeakSet === 'function' && !detectionRegex.test(WeakSet.toString())) polyfills.push(POLYFILLS.WEAK_SET)
|
|
43
|
-
} catch (err) {
|
|
44
|
-
// Possibly not supported
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return polyfills
|
|
48
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-global-assign */
|
|
2
|
-
/* eslint-disable no-extend-native */
|
|
3
|
-
import { getPolyfills } from './polyfill-detection'
|
|
4
|
-
|
|
5
|
-
// DO NOT test Function.prototype.apply, it causes recursion in Jest
|
|
6
|
-
|
|
7
|
-
test('should return an empty array when nothing is polyfilled', () => {
|
|
8
|
-
expect(getPolyfills()).toEqual([])
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
test('should indicate Function.prototype.bind is polyfilled', () => {
|
|
12
|
-
const originalFn = Function.prototype.bind
|
|
13
|
-
Function.prototype.bind = jest.fn(function (...args) {
|
|
14
|
-
return originalFn.apply(this, args)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
expect(getPolyfills()).toEqual(['Function.bind'])
|
|
18
|
-
|
|
19
|
-
Function.prototype.bind = originalFn
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test('should indicate Function.prototype.call is polyfilled', () => {
|
|
23
|
-
const originalFn = Function.prototype.call
|
|
24
|
-
Function.prototype.call = jest.fn(function (...args) {
|
|
25
|
-
return originalFn.apply(this, args)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
expect(getPolyfills()).toEqual(['Function.call'])
|
|
29
|
-
|
|
30
|
-
Function.prototype.call = originalFn
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
test('should indicate Array.prototype.includes is polyfilled', () => {
|
|
34
|
-
const originalFn = Array.prototype.includes
|
|
35
|
-
Array.prototype.includes = jest.fn(function (...args) {
|
|
36
|
-
return originalFn.apply(this, args)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
expect(getPolyfills()).toEqual(['Array.includes'])
|
|
40
|
-
|
|
41
|
-
Array.prototype.includes = originalFn
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test('should indicate Array.from is polyfilled', () => {
|
|
45
|
-
const originalFn = Array.from
|
|
46
|
-
Array.from = jest.fn(function (...args) {
|
|
47
|
-
return originalFn.apply(this, args)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
expect(getPolyfills()).toEqual(['Array.from'])
|
|
51
|
-
|
|
52
|
-
Array.from = originalFn
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test('should indicate Array.prototype.find is polyfilled', () => {
|
|
56
|
-
const originalFn = Array.prototype.find
|
|
57
|
-
Array.prototype.find = jest.fn(function (...args) {
|
|
58
|
-
return originalFn.apply(this, args)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
expect(getPolyfills()).toEqual(['Array.find'])
|
|
62
|
-
|
|
63
|
-
Array.prototype.find = originalFn
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
test('should indicate Array.prototype.flat is polyfilled', () => {
|
|
67
|
-
const originalFn = Array.prototype.flat
|
|
68
|
-
Array.prototype.flat = jest.fn(function (...args) {
|
|
69
|
-
return originalFn.apply(this, args)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
expect(getPolyfills()).toEqual(['Array.flat'])
|
|
73
|
-
|
|
74
|
-
Array.prototype.flat = originalFn
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test('should indicate Array.prototype.flatMap is polyfilled', () => {
|
|
78
|
-
const originalFn = Array.prototype.flatMap
|
|
79
|
-
Array.prototype.flatMap = jest.fn(function (...args) {
|
|
80
|
-
return originalFn.apply(this, args)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
expect(getPolyfills()).toEqual(['Array.flatMap'])
|
|
84
|
-
|
|
85
|
-
Array.prototype.flatMap = originalFn
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test('should indicate Object.assign is polyfilled', () => {
|
|
89
|
-
const originalFn = Object.assign
|
|
90
|
-
Object.assign = jest.fn(function (...args) {
|
|
91
|
-
return originalFn.apply(this, args)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
expect(getPolyfills()).toEqual(['Object.assign'])
|
|
95
|
-
|
|
96
|
-
Object.assign = originalFn
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
test('should indicate Object.entries is polyfilled', () => {
|
|
100
|
-
const originalFn = Object.entries
|
|
101
|
-
Object.entries = jest.fn(function (...args) {
|
|
102
|
-
return originalFn.apply(this, args)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
expect(getPolyfills()).toEqual(['Object.entries'])
|
|
106
|
-
|
|
107
|
-
Object.entries = originalFn
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
test('should indicate Object.values is polyfilled', () => {
|
|
111
|
-
const originalFn = Object.values
|
|
112
|
-
Object.values = jest.fn(function (...args) {
|
|
113
|
-
return originalFn.apply(this, args)
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
expect(getPolyfills()).toEqual(['Object.values'])
|
|
117
|
-
|
|
118
|
-
Object.values = originalFn
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
test('should indicate Map constructor is polyfilled', () => {
|
|
122
|
-
const originalFn = Map
|
|
123
|
-
Map = jest.fn(function (...args) {
|
|
124
|
-
return originalFn.apply(this, args)
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
expect(getPolyfills()).toEqual(['Map'])
|
|
128
|
-
|
|
129
|
-
Map = originalFn
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
test('should indicate Set constructor is polyfilled', () => {
|
|
133
|
-
const originalFn = Set
|
|
134
|
-
Set = jest.fn(function (...args) {
|
|
135
|
-
return originalFn.apply(this, args)
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
expect(getPolyfills()).toEqual(['Set'])
|
|
139
|
-
|
|
140
|
-
Set = originalFn
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
test('should indicate WeakMap constructor is polyfilled', () => {
|
|
144
|
-
const originalFn = WeakMap
|
|
145
|
-
WeakMap = jest.fn(function (...args) {
|
|
146
|
-
return originalFn.apply(this, args)
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
expect(getPolyfills()).toEqual(['WeakMap'])
|
|
150
|
-
|
|
151
|
-
WeakMap = originalFn
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
test('should indicate WeakSet constructor is polyfilled', () => {
|
|
155
|
-
const originalFn = WeakSet
|
|
156
|
-
WeakSet = jest.fn(function (...args) {
|
|
157
|
-
return originalFn.apply(this, args)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
expect(getPolyfills()).toEqual(['WeakSet'])
|
|
161
|
-
|
|
162
|
-
WeakSet = originalFn
|
|
163
|
-
})
|
|
File without changes
|