@newrelic/browser-agent 0.0.9 → 0.1.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/README.md +84 -207
  2. package/dist/cjs/cdn/lite.js +14 -0
  3. package/dist/cjs/cdn/polyfills/lite.js +4 -0
  4. package/dist/cjs/cdn/polyfills/pro.js +4 -0
  5. package/dist/cjs/cdn/polyfills/spa.js +4 -0
  6. package/dist/cjs/cdn/polyfills.js +14 -0
  7. package/dist/cjs/cdn/pro.js +19 -0
  8. package/dist/cjs/cdn/spa.js +19 -0
  9. package/dist/cjs/cdn/worker.js +16 -0
  10. package/dist/cjs/common/aggregate/aggregator.js +168 -0
  11. package/dist/cjs/common/browser-version/firefox-version.js +17 -0
  12. package/dist/cjs/common/browser-version/ios-version.js +18 -0
  13. package/dist/cjs/common/config/config.js +76 -0
  14. package/dist/cjs/common/config/state/configurable.js +32 -0
  15. package/dist/cjs/common/config/state/info.js +50 -0
  16. package/dist/cjs/common/config/state/init.js +86 -0
  17. package/dist/cjs/common/config/state/loader-config.js +28 -0
  18. package/dist/cjs/common/config/state/originals.js +9 -0
  19. package/dist/cjs/common/config/state/runtime.js +50 -0
  20. package/dist/cjs/common/constants/environment-variables.js +20 -0
  21. package/dist/cjs/common/context/shared-context.js +25 -0
  22. package/dist/cjs/common/deny-list/deny-list.js +108 -0
  23. package/dist/cjs/common/drain/drain.js +126 -0
  24. package/dist/cjs/common/event-emitter/contextual-ee.js +149 -0
  25. package/dist/cjs/common/event-emitter/handle.js +24 -0
  26. package/dist/cjs/common/event-emitter/register-handler.js +24 -0
  27. package/dist/cjs/common/event-listener/event-listener-opts.js +46 -0
  28. package/dist/cjs/common/harvest/harvest-scheduler.js +111 -0
  29. package/dist/cjs/common/harvest/harvest.js +236 -0
  30. package/dist/cjs/common/ids/id.js +30 -0
  31. package/dist/cjs/common/ids/unique-id.js +84 -0
  32. package/dist/cjs/common/metrics/framework-detection.js +72 -0
  33. package/dist/cjs/common/metrics/paint-metrics.js +13 -0
  34. package/dist/cjs/common/serialize/bel-serializer.js +89 -0
  35. package/dist/cjs/common/timing/nav-timing.js +77 -0
  36. package/dist/cjs/common/timing/now.js +15 -0
  37. package/dist/cjs/common/unload/eol.js +69 -0
  38. package/dist/cjs/common/url/clean-url.js +16 -0
  39. package/dist/cjs/common/url/encode.js +79 -0
  40. package/dist/cjs/common/url/location.js +14 -0
  41. package/dist/cjs/common/url/parse-url.js +66 -0
  42. package/dist/cjs/common/url/protocol.js +25 -0
  43. package/dist/cjs/common/util/console.js +17 -0
  44. package/dist/cjs/common/util/data-size.js +25 -0
  45. package/dist/cjs/common/util/feature-flags.js +42 -0
  46. package/dist/cjs/common/util/get-or-set.js +39 -0
  47. package/dist/cjs/common/util/global-scope.js +56 -0
  48. package/dist/cjs/common/util/map-own.js +24 -0
  49. package/dist/cjs/common/util/obfuscate.js +76 -0
  50. package/dist/cjs/common/util/reduce.js +22 -0
  51. package/dist/cjs/common/util/s-hash.js +19 -0
  52. package/dist/cjs/common/util/single.js +23 -0
  53. package/dist/cjs/common/util/stringify.js +47 -0
  54. package/dist/cjs/common/util/submit-data.js +99 -0
  55. package/dist/cjs/common/util/traverse.js +41 -0
  56. package/dist/cjs/common/util/user-agent.js +57 -0
  57. package/dist/cjs/common/window/load.js +19 -0
  58. package/dist/cjs/common/window/nreum.js +107 -0
  59. package/dist/cjs/common/window/page-visibility.js +28 -0
  60. package/dist/cjs/common/window/session-storage.js +42 -0
  61. package/dist/cjs/common/window/supports-performance-observer.js +15 -0
  62. package/dist/cjs/common/window/top-level-callers.js +23 -0
  63. package/dist/cjs/common/wrap/index.js +68 -0
  64. package/dist/cjs/common/wrap/wrap-events.js +105 -0
  65. package/dist/cjs/common/wrap/wrap-fetch.js +114 -0
  66. package/dist/cjs/common/wrap/wrap-function.js +269 -0
  67. package/dist/cjs/common/wrap/wrap-history.js +56 -0
  68. package/dist/cjs/common/wrap/wrap-jsonp.js +129 -0
  69. package/dist/cjs/common/wrap/wrap-mutation.js +61 -0
  70. package/dist/cjs/common/wrap/wrap-promise.js +160 -0
  71. package/dist/cjs/common/wrap/wrap-raf.js +55 -0
  72. package/dist/cjs/common/wrap/wrap-timer.js +70 -0
  73. package/dist/cjs/common/wrap/wrap-xhr.js +206 -0
  74. package/dist/cjs/features/ajax/aggregate/index.js +226 -0
  75. package/dist/cjs/features/ajax/constants.js +9 -0
  76. package/dist/cjs/features/ajax/index.js +12 -0
  77. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +145 -0
  78. package/dist/cjs/features/ajax/instrument/index.js +338 -0
  79. package/dist/cjs/features/ajax/instrument/response-size.js +26 -0
  80. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +18 -0
  81. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +30 -0
  82. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +216 -0
  83. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +257 -0
  84. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.js +36 -0
  85. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +39 -0
  86. package/dist/cjs/features/jserrors/aggregate/index.js +267 -0
  87. package/dist/cjs/features/jserrors/aggregate/string-hash-code.js +23 -0
  88. package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +26 -0
  89. package/dist/cjs/features/jserrors/constants.js +11 -0
  90. package/dist/cjs/features/jserrors/index.js +12 -0
  91. package/dist/cjs/features/jserrors/instrument/debug.js +40 -0
  92. package/dist/cjs/features/jserrors/instrument/index.js +158 -0
  93. package/dist/cjs/features/metrics/aggregate/index.js +136 -0
  94. package/dist/cjs/features/metrics/constants.js +17 -0
  95. package/dist/cjs/features/metrics/index.js +12 -0
  96. package/dist/cjs/features/metrics/instrument/index.js +20 -0
  97. package/dist/cjs/features/metrics/instrument/workers-helper.js +121 -0
  98. package/dist/cjs/features/page_action/aggregate/index.js +112 -0
  99. package/dist/cjs/features/page_action/constants.js +9 -0
  100. package/dist/cjs/features/page_action/index.js +12 -0
  101. package/dist/cjs/features/page_action/instrument/index.js +21 -0
  102. package/dist/cjs/features/page_view_event/aggregate/index.js +133 -0
  103. package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +39 -0
  104. package/dist/cjs/features/page_view_event/constants.js +15 -0
  105. package/dist/cjs/features/page_view_event/index.js +12 -0
  106. package/dist/cjs/features/page_view_event/instrument/index.js +38 -0
  107. package/dist/cjs/features/page_view_timing/aggregate/index.js +265 -0
  108. package/dist/cjs/features/page_view_timing/constants.js +9 -0
  109. package/dist/cjs/features/page_view_timing/first-paint.js +50 -0
  110. package/dist/cjs/features/page_view_timing/index.js +12 -0
  111. package/dist/cjs/features/page_view_timing/instrument/index.js +36 -0
  112. package/dist/cjs/features/page_view_timing/long-tasks.js +75 -0
  113. package/dist/cjs/features/session_trace/aggregate/index.js +375 -0
  114. package/dist/cjs/features/session_trace/constants.js +32 -0
  115. package/dist/cjs/features/session_trace/index.js +12 -0
  116. package/dist/cjs/features/session_trace/instrument/index.js +133 -0
  117. package/dist/cjs/features/spa/aggregate/index.js +684 -0
  118. package/dist/cjs/features/spa/aggregate/interaction-node.js +84 -0
  119. package/dist/cjs/features/spa/aggregate/interaction-node.test.js +16 -0
  120. package/dist/cjs/features/spa/aggregate/interaction.js +98 -0
  121. package/dist/cjs/features/spa/aggregate/serializer.js +147 -0
  122. package/dist/cjs/features/spa/constants.js +53 -0
  123. package/dist/cjs/features/spa/index.js +12 -0
  124. package/dist/cjs/features/spa/instrument/index.js +114 -0
  125. package/dist/cjs/features/utils/aggregate-base.js +13 -0
  126. package/dist/cjs/features/utils/feature-base.js +58 -0
  127. package/dist/cjs/features/utils/handler-cache.js +64 -0
  128. package/dist/cjs/features/utils/instrument-base.js +71 -0
  129. package/dist/cjs/features/utils/lazy-loader.js +44 -0
  130. package/dist/cjs/index.js +81 -58
  131. package/dist/cjs/loaders/agent.js +86 -0
  132. package/dist/cjs/loaders/api/api.js +109 -0
  133. package/dist/cjs/loaders/api/apiAsync.js +94 -0
  134. package/dist/cjs/loaders/browser-agent.js +29 -0
  135. package/dist/cjs/loaders/configure/configure.js +47 -0
  136. package/dist/cjs/loaders/features/enabled-features.js +19 -0
  137. package/dist/cjs/loaders/features/featureDependencies.js +32 -0
  138. package/dist/cjs/loaders/features/features.js +33 -0
  139. package/dist/cjs/loaders/micro-agent.js +93 -0
  140. package/dist/cjs/loaders/worker-agent.js +24 -0
  141. package/dist/esm/cdn/lite.js +12 -0
  142. package/dist/esm/cdn/polyfills/lite.js +7 -0
  143. package/dist/esm/cdn/polyfills/pro.js +7 -0
  144. package/dist/esm/cdn/polyfills/spa.js +7 -0
  145. package/dist/esm/cdn/polyfills.js +17 -0
  146. package/dist/esm/cdn/pro.js +17 -0
  147. package/dist/esm/cdn/spa.js +17 -0
  148. package/dist/esm/cdn/worker.js +14 -0
  149. package/dist/esm/common/aggregate/aggregator.js +161 -0
  150. package/dist/esm/common/browser-version/firefox-version.js +10 -0
  151. package/dist/esm/common/browser-version/ios-version.js +10 -0
  152. package/dist/esm/common/config/config.js +11 -0
  153. package/dist/esm/common/config/state/configurable.js +25 -0
  154. package/dist/esm/common/config/state/info.js +42 -0
  155. package/dist/esm/common/config/state/init.js +78 -0
  156. package/dist/esm/common/config/state/loader-config.js +21 -0
  157. package/dist/esm/common/config/state/originals.js +2 -0
  158. package/dist/esm/common/config/state/runtime.js +41 -0
  159. package/dist/esm/common/constants/environment-variables.js +11 -0
  160. package/dist/esm/common/context/shared-context.js +18 -0
  161. package/dist/esm/common/deny-list/deny-list.js +101 -0
  162. package/dist/esm/common/drain/drain.js +119 -0
  163. package/dist/esm/common/event-emitter/contextual-ee.js +142 -0
  164. package/dist/esm/common/event-emitter/handle.js +16 -0
  165. package/dist/esm/common/event-emitter/register-handler.js +19 -0
  166. package/dist/esm/common/event-listener/event-listener-opts.js +39 -0
  167. package/dist/esm/common/harvest/harvest-scheduler.js +105 -0
  168. package/dist/esm/common/harvest/harvest.js +228 -0
  169. package/dist/esm/common/ids/id.js +23 -0
  170. package/dist/esm/common/ids/unique-id.js +75 -0
  171. package/dist/esm/common/metrics/framework-detection.js +66 -0
  172. package/dist/esm/common/metrics/paint-metrics.js +6 -0
  173. package/dist/esm/common/serialize/bel-serializer.js +80 -0
  174. package/dist/esm/common/timing/nav-timing.js +67 -0
  175. package/dist/esm/common/timing/now.js +9 -0
  176. package/dist/esm/common/unload/eol.js +62 -0
  177. package/dist/esm/common/url/clean-url.js +10 -0
  178. package/dist/esm/common/url/encode.js +71 -0
  179. package/dist/esm/common/url/location.js +8 -0
  180. package/dist/esm/common/url/parse-url.js +60 -0
  181. package/dist/esm/common/url/protocol.js +17 -0
  182. package/dist/esm/common/util/console.js +11 -0
  183. package/dist/esm/common/util/data-size.js +19 -0
  184. package/dist/esm/common/util/feature-flags.js +33 -0
  185. package/dist/esm/common/util/get-or-set.js +33 -0
  186. package/dist/esm/common/util/global-scope.js +44 -0
  187. package/dist/esm/common/util/map-own.js +18 -0
  188. package/dist/esm/common/util/obfuscate.js +67 -0
  189. package/dist/esm/common/util/reduce.js +16 -0
  190. package/dist/esm/common/util/s-hash.js +13 -0
  191. package/dist/esm/common/util/single.js +16 -0
  192. package/dist/esm/common/util/stringify.js +42 -0
  193. package/dist/esm/common/util/submit-data.js +91 -0
  194. package/dist/esm/common/util/traverse.js +35 -0
  195. package/dist/esm/common/util/user-agent.js +48 -0
  196. package/dist/esm/common/window/load.js +12 -0
  197. package/dist/esm/common/window/nreum.js +91 -0
  198. package/dist/esm/common/window/page-visibility.js +23 -0
  199. package/dist/esm/common/window/session-storage.js +36 -0
  200. package/dist/esm/common/window/supports-performance-observer.js +9 -0
  201. package/dist/esm/common/window/top-level-callers.js +17 -0
  202. package/dist/esm/common/wrap/index.js +14 -0
  203. package/dist/esm/common/wrap/wrap-events.js +97 -0
  204. package/dist/esm/common/wrap/wrap-fetch.js +105 -0
  205. package/dist/esm/common/wrap/wrap-function.js +257 -0
  206. package/dist/esm/common/wrap/wrap-history.js +48 -0
  207. package/dist/esm/common/wrap/wrap-jsonp.js +122 -0
  208. package/dist/esm/common/wrap/wrap-mutation.js +54 -0
  209. package/dist/esm/common/wrap/wrap-promise.js +153 -0
  210. package/dist/esm/common/wrap/wrap-raf.js +48 -0
  211. package/dist/esm/common/wrap/wrap-timer.js +63 -0
  212. package/dist/esm/common/wrap/wrap-xhr.js +199 -0
  213. package/dist/esm/features/ajax/aggregate/index.js +218 -0
  214. package/dist/esm/features/ajax/constants.js +2 -0
  215. package/dist/esm/features/ajax/index.js +1 -0
  216. package/dist/esm/features/ajax/instrument/distributed-tracing.js +137 -0
  217. package/dist/esm/features/ajax/instrument/index.js +330 -0
  218. package/dist/esm/features/ajax/instrument/response-size.js +19 -0
  219. package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +12 -0
  220. package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +28 -0
  221. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +209 -0
  222. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +255 -0
  223. package/dist/esm/features/jserrors/aggregate/format-stack-trace.js +29 -0
  224. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +37 -0
  225. package/dist/esm/features/jserrors/aggregate/index.js +260 -0
  226. package/dist/esm/features/jserrors/aggregate/string-hash-code.js +17 -0
  227. package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +24 -0
  228. package/dist/esm/features/jserrors/constants.js +3 -0
  229. package/dist/esm/features/jserrors/index.js +1 -0
  230. package/dist/esm/features/jserrors/instrument/debug.js +38 -0
  231. package/dist/esm/features/jserrors/instrument/index.js +150 -0
  232. package/dist/esm/features/metrics/aggregate/index.js +129 -0
  233. package/dist/esm/features/metrics/constants.js +6 -0
  234. package/dist/esm/features/metrics/index.js +1 -0
  235. package/dist/esm/features/metrics/instrument/index.js +13 -0
  236. package/dist/esm/features/metrics/instrument/workers-helper.js +116 -0
  237. package/dist/esm/features/page_action/aggregate/index.js +105 -0
  238. package/dist/esm/features/page_action/constants.js +2 -0
  239. package/dist/esm/features/page_action/index.js +1 -0
  240. package/dist/esm/features/page_action/instrument/index.js +14 -0
  241. package/dist/esm/features/page_view_event/aggregate/index.js +124 -0
  242. package/dist/esm/features/page_view_event/aggregate/initialized-features.js +34 -0
  243. package/dist/esm/features/page_view_event/constants.js +5 -0
  244. package/dist/esm/features/page_view_event/index.js +1 -0
  245. package/dist/esm/features/page_view_event/instrument/index.js +29 -0
  246. package/dist/esm/features/page_view_timing/aggregate/index.js +258 -0
  247. package/dist/esm/features/page_view_timing/constants.js +2 -0
  248. package/dist/esm/features/page_view_timing/first-paint.js +43 -0
  249. package/dist/esm/features/page_view_timing/index.js +1 -0
  250. package/dist/esm/features/page_view_timing/instrument/index.js +28 -0
  251. package/dist/esm/features/page_view_timing/long-tasks.js +69 -0
  252. package/dist/esm/features/session_trace/aggregate/index.js +366 -0
  253. package/dist/esm/features/session_trace/constants.js +14 -0
  254. package/dist/esm/features/session_trace/index.js +1 -0
  255. package/dist/esm/features/session_trace/instrument/index.js +123 -0
  256. package/dist/esm/features/spa/aggregate/index.js +674 -0
  257. package/dist/esm/features/spa/aggregate/interaction-node.js +78 -0
  258. package/dist/esm/features/spa/aggregate/interaction-node.test.js +14 -0
  259. package/dist/esm/features/spa/aggregate/interaction.js +92 -0
  260. package/dist/esm/features/spa/aggregate/serializer.js +139 -0
  261. package/dist/esm/features/spa/constants.js +25 -0
  262. package/dist/esm/features/spa/index.js +1 -0
  263. package/dist/esm/features/spa/instrument/index.js +104 -0
  264. package/dist/esm/features/utils/aggregate-base.js +6 -0
  265. package/dist/esm/features/utils/feature-base.js +51 -0
  266. package/dist/esm/features/utils/handler-cache.js +57 -0
  267. package/dist/esm/features/utils/instrument-base.js +69 -0
  268. package/dist/esm/features/utils/lazy-loader.js +37 -0
  269. package/dist/esm/index.js +15 -0
  270. package/dist/esm/loaders/agent.js +77 -0
  271. package/dist/esm/loaders/api/api.js +104 -0
  272. package/dist/esm/loaders/api/apiAsync.js +88 -0
  273. package/dist/esm/loaders/browser-agent.js +23 -0
  274. package/dist/esm/loaders/configure/configure.js +41 -0
  275. package/dist/esm/loaders/features/enabled-features.js +13 -0
  276. package/dist/esm/loaders/features/featureDependencies.js +25 -0
  277. package/dist/esm/loaders/features/features.js +25 -0
  278. package/dist/esm/loaders/micro-agent.js +86 -0
  279. package/dist/esm/loaders/worker-agent.js +18 -0
  280. package/package.json +204 -71
  281. package/types.ts +221 -0
  282. package/dist/bundled/es5/index.js +0 -2
  283. package/dist/bundled/es5/index.js.map +0 -1
  284. package/dist/bundled/es6/index.js +0 -2
  285. package/dist/bundled/es6/index.js.map +0 -1
  286. package/dist/cjs/index.d.ts +0 -19
  287. package/dist/cjs/index.js.map +0 -1
  288. package/dist/cjs/types.d.ts +0 -94
  289. package/dist/cjs/types.js +0 -28
  290. package/dist/cjs/types.js.map +0 -1
  291. package/dist/cjs/utils/api/api.d.ts +0 -10
  292. package/dist/cjs/utils/api/api.js +0 -40
  293. package/dist/cjs/utils/api/api.js.map +0 -1
  294. package/dist/cjs/utils/config/build-configs.d.ts +0 -6
  295. package/dist/cjs/utils/config/build-configs.js +0 -68
  296. package/dist/cjs/utils/config/build-configs.js.map +0 -1
  297. package/dist/cjs/utils/features/features.d.ts +0 -5
  298. package/dist/cjs/utils/features/features.js +0 -14
  299. package/dist/cjs/utils/features/features.js.map +0 -1
  300. package/dist/cjs/utils/features/initialize.d.ts +0 -5
  301. package/dist/cjs/utils/features/initialize.js +0 -51
  302. package/dist/cjs/utils/features/initialize.js.map +0 -1
  303. package/dist/es/index.d.ts +0 -19
  304. package/dist/es/index.js +0 -55
  305. package/dist/es/index.js.map +0 -1
  306. package/dist/es/types.d.ts +0 -94
  307. package/dist/es/types.js +0 -24
  308. package/dist/es/types.js.map +0 -1
  309. package/dist/es/utils/api/api.d.ts +0 -10
  310. package/dist/es/utils/api/api.js +0 -36
  311. package/dist/es/utils/api/api.js.map +0 -1
  312. package/dist/es/utils/config/build-configs.d.ts +0 -6
  313. package/dist/es/utils/config/build-configs.js +0 -64
  314. package/dist/es/utils/config/build-configs.js.map +0 -1
  315. package/dist/es/utils/features/features.d.ts +0 -5
  316. package/dist/es/utils/features/features.js +0 -10
  317. package/dist/es/utils/features/features.js.map +0 -1
  318. package/dist/es/utils/features/initialize.d.ts +0 -5
  319. package/dist/es/utils/features/initialize.js +0 -24
  320. package/dist/es/utils/features/initialize.js.map +0 -1
  321. package/dist/umd/index.d.ts +0 -19
  322. package/dist/umd/index.js +0 -69
  323. package/dist/umd/index.js.map +0 -1
  324. package/dist/umd/types.d.ts +0 -94
  325. package/dist/umd/types.js +0 -38
  326. package/dist/umd/types.js.map +0 -1
  327. package/dist/umd/utils/api/api.d.ts +0 -10
  328. package/dist/umd/utils/api/api.js +0 -50
  329. package/dist/umd/utils/api/api.js.map +0 -1
  330. package/dist/umd/utils/config/build-configs.d.ts +0 -6
  331. package/dist/umd/utils/config/build-configs.js +0 -78
  332. package/dist/umd/utils/config/build-configs.js.map +0 -1
  333. package/dist/umd/utils/features/features.d.ts +0 -5
  334. package/dist/umd/utils/features/features.js +0 -24
  335. package/dist/umd/utils/features/features.js.map +0 -1
  336. package/dist/umd/utils/features/initialize.d.ts +0 -5
  337. package/dist/umd/utils/features/initialize.js +0 -63
  338. package/dist/umd/utils/features/initialize.js.map +0 -1
  339. package/dist/webpack-analysis.html +0 -38
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { mapOwn } from '../util/map-own';
7
+ import { stringify } from '../util/stringify';
8
+
9
+ // Characters that are safe in a qs, but get encoded.
10
+ var charMap = {
11
+ '%2C': ',',
12
+ '%3A': ':',
13
+ '%2F': '/',
14
+ '%40': '@',
15
+ '%24': '$',
16
+ '%3B': ';'
17
+ };
18
+ var charList = mapOwn(charMap, function (k) {
19
+ return k;
20
+ });
21
+ var safeEncoded = new RegExp(charList.join('|'), 'g');
22
+ function real(c) {
23
+ return charMap[c];
24
+ }
25
+
26
+ // Encode as URI Component, then unescape anything that is ok in the
27
+ // query string position.
28
+ export function qs(value) {
29
+ if (value === null || value === undefined) return 'null';
30
+ return encodeURIComponent(value).replace(safeEncoded, real);
31
+ }
32
+ export function fromArray(qs, maxBytes) {
33
+ var bytes = 0;
34
+ for (var i = 0; i < qs.length; i++) {
35
+ bytes += qs[i].length;
36
+ if (bytes > maxBytes) return qs.slice(0, i).join('');
37
+ }
38
+ return qs.join('');
39
+ }
40
+ export function obj(payload, maxBytes) {
41
+ var total = 0;
42
+ var result = '';
43
+ mapOwn(payload, function (feature, dataArray) {
44
+ var intermediate = [];
45
+ var next;
46
+ var i;
47
+ if (typeof dataArray === 'string') {
48
+ next = '&' + feature + '=' + qs(dataArray);
49
+ total += next.length;
50
+ result += next;
51
+ } else if (dataArray.length) {
52
+ total += 9;
53
+ for (i = 0; i < dataArray.length; i++) {
54
+ next = qs(stringify(dataArray[i]));
55
+ total += next.length;
56
+ if (typeof maxBytes !== 'undefined' && total >= maxBytes) break;
57
+ intermediate.push(next);
58
+ }
59
+ result += '&' + feature + '=%5B' + intermediate.join(',') + '%5D';
60
+ }
61
+ });
62
+ return result;
63
+ }
64
+
65
+ // Constructs an HTTP parameter to add to the BAM router URL
66
+ export function param(name, value) {
67
+ if (value && typeof value === 'string') {
68
+ return '&' + name + '=' + qs(value);
69
+ }
70
+ return '';
71
+ }
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ export function getLocation() {
7
+ return '' + location;
8
+ }
@@ -0,0 +1,60 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { globalScope, isBrowserScope } from '../util/global-scope';
7
+ var stringsToParsedUrls = {};
8
+ export function parseUrl(url) {
9
+ if (url in stringsToParsedUrls) {
10
+ return stringsToParsedUrls[url];
11
+ }
12
+
13
+ // Return if URL is a data URL, parseUrl assumes urls are http/https
14
+ if ((url || '').indexOf('data:') === 0) {
15
+ return {
16
+ protocol: 'data'
17
+ };
18
+ }
19
+ let urlEl;
20
+ var location = globalScope?.location;
21
+ var ret = {};
22
+ if (isBrowserScope) {
23
+ // Use an anchor dom element to resolve the url natively.
24
+ urlEl = document.createElement('a');
25
+ urlEl.href = url;
26
+ } else {
27
+ try {
28
+ urlEl = new URL(url, location.href);
29
+ } catch (err) {
30
+ return ret;
31
+ }
32
+ }
33
+ ret.port = urlEl.port;
34
+ var firstSplit = urlEl.href.split('://');
35
+ if (!ret.port && firstSplit[1]) {
36
+ ret.port = firstSplit[1].split('/')[0].split('@').pop().split(':')[1];
37
+ }
38
+ if (!ret.port || ret.port === '0') ret.port = firstSplit[0] === 'https' ? '443' : '80';
39
+
40
+ // Host not provided in IE for relative urls
41
+ ret.hostname = urlEl.hostname || location.hostname;
42
+ ret.pathname = urlEl.pathname;
43
+ ret.protocol = firstSplit[0];
44
+
45
+ // Pathname sometimes doesn't have leading slash (IE 8 and 9)
46
+ if (ret.pathname.charAt(0) !== '/') ret.pathname = '/' + ret.pathname;
47
+
48
+ // urlEl.protocol is ':' in old ie when protocol is not specified
49
+ var sameProtocol = !urlEl.protocol || urlEl.protocol === ':' || urlEl.protocol === location.protocol;
50
+ var sameDomain = urlEl.hostname === location.hostname && urlEl.port === location.port;
51
+
52
+ // urlEl.hostname is not provided by IE for relative urls, but relative urls are also same-origin
53
+ ret.sameOrigin = sameProtocol && (!urlEl.hostname || sameDomain);
54
+
55
+ // Only cache if url doesn't have a path
56
+ if (ret.pathname === '/') {
57
+ stringsToParsedUrls[url] = ret;
58
+ }
59
+ return ret;
60
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { getGlobalScope } from '../util/global-scope';
6
+ export const protocol = {
7
+ isFileProtocol: isFileProtocol,
8
+ supportabilityMetricSent: false
9
+ };
10
+ function isFileProtocol() {
11
+ let isFile = Boolean(getGlobalScope()?.location?.protocol === 'file:');
12
+ if (isFile) {
13
+ //metrics.recordSupportability('Generic/FileProtocol/Detected') -- may be implemented later? Probably make sure it's once per window
14
+ protocol.supportabilityMetricSent = true;
15
+ }
16
+ return isFile;
17
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A helper method to warn to the console with New Relic: decoration
3
+ * @param {string} message - The primary message to warn
4
+ * @param {*} secondary - Secondary data to include, usually an error or object
5
+ * @returns
6
+ */
7
+ export function warn(message, secondary) {
8
+ if (!console || !console.warn || typeof console.warn !== 'function') return;
9
+ console.warn(`New Relic: ${message}`);
10
+ if (secondary) console.warn(secondary);
11
+ }
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { stringify } from './stringify';
7
+ export function dataSize(data) {
8
+ if (typeof data === 'string' && data.length) return data.length;
9
+ if (typeof data !== 'object') return undefined;
10
+ // eslint-disable-next-line
11
+ if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer && data.byteLength) return data.byteLength;
12
+ if (typeof Blob !== 'undefined' && data instanceof Blob && data.size) return data.size;
13
+ if (typeof FormData !== 'undefined' && data instanceof FormData) return undefined;
14
+ try {
15
+ return stringify(data).length;
16
+ } catch (e) {
17
+ return undefined;
18
+ }
19
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { mapOwn } from './map-own';
6
+ import { ee } from '../event-emitter/contextual-ee';
7
+ import { handle } from '../event-emitter/handle';
8
+ import { drain } from '../drain/drain';
9
+ import { FEATURE_NAMES } from '../../loaders/features/features';
10
+ const bucketMap = {
11
+ stn: [FEATURE_NAMES.sessionTrace],
12
+ err: [FEATURE_NAMES.jserrors, FEATURE_NAMES.metrics],
13
+ ins: [FEATURE_NAMES.pageAction],
14
+ spa: [FEATURE_NAMES.spa]
15
+ };
16
+ export function activateFeatures(flags, agentIdentifier) {
17
+ var sharedEE = ee.get(agentIdentifier);
18
+ if (!(flags && typeof flags === 'object')) return;
19
+ mapOwn(flags, function (flag, val) {
20
+ if (!val) {
21
+ return (bucketMap[flag] || []).forEach(feat => {
22
+ handle('block-' + flag, [], undefined, feat, sharedEE);
23
+ });
24
+ }
25
+ if (activatedFeatures[flag]) {
26
+ return;
27
+ }
28
+ handle('feat-' + flag, [], undefined, bucketMap[flag], sharedEE);
29
+ activatedFeatures[flag] = true;
30
+ });
31
+ drain(agentIdentifier, FEATURE_NAMES.pageViewEvent);
32
+ }
33
+ export const activatedFeatures = {};
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ var has = Object.prototype.hasOwnProperty;
7
+
8
+ // Always returns the current value of obj[prop], even if it has to set it first
9
+ export function getOrSet(obj, prop, getVal) {
10
+ // If the value exists return it.
11
+ if (has.call(obj, prop)) return obj[prop];
12
+ var val = getVal();
13
+
14
+ // Attempt to set the property so it's not enumerable
15
+ if (Object.defineProperty && Object.keys) {
16
+ try {
17
+ Object.defineProperty(obj, prop, {
18
+ value: val,
19
+ // old IE inherits non-write-ability
20
+ writable: true,
21
+ enumerable: false
22
+ });
23
+ return val;
24
+ } catch (e) {
25
+ // Can't report internal errors,
26
+ // because GOS is a dependency of the reporting mechanisms
27
+ }
28
+ }
29
+
30
+ // fall back to setting normally
31
+ obj[prop] = val;
32
+ return val;
33
+ }
@@ -0,0 +1,44 @@
1
+ /* global globalThis, WorkerGlobalScope, WorkerNavigator */
2
+
3
+ export const isBrowserScope = Boolean(typeof window !== 'undefined' && window.document);
4
+ export const isWorkerScope = Boolean(typeof WorkerGlobalScope !== 'undefined' && self.navigator instanceof WorkerNavigator);
5
+ export let globalScope = (() => {
6
+ if (isBrowserScope) {
7
+ return window;
8
+ } else if (isWorkerScope) {
9
+ if (typeof globalThis !== 'undefined' && globalThis instanceof WorkerGlobalScope) {
10
+ return globalThis;
11
+ } else if (self instanceof WorkerGlobalScope) {
12
+ return self;
13
+ }
14
+ }
15
+ throw new Error('New Relic browser agent shutting down due to error: Unable to locate global scope. This is possibly due to code redefining browser global variables like "self" and "window".');
16
+ })();
17
+
18
+ /**
19
+ * The below methods are only used for testing and should be removed once the
20
+ * reliant tests are moved to Jest.
21
+ * tests/browser/protocol.browser.js
22
+ * tests/browser/obfuscate.browser.js
23
+ */
24
+ export function setScope(obj) {
25
+ globalScope = {
26
+ ...obj
27
+ };
28
+ }
29
+ export function resetScope() {
30
+ if (isBrowserScope) {
31
+ globalScope = window;
32
+ } else if (isWorkerScope) {
33
+ if (typeof globalThis !== 'undefined' && globalThis instanceof WorkerGlobalScope) {
34
+ globalScope = globalThis;
35
+ } else if (self instanceof WorkerGlobalScope) {
36
+ globalScope = self;
37
+ }
38
+ } else {
39
+ throw new Error('New Relic browser agent shutting down due to error: Unable to locate global scope. This is possibly due to code redefining browser global variables like "self" and "window".');
40
+ }
41
+ }
42
+ export function getGlobalScope() {
43
+ return globalScope;
44
+ }
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ var has = Object.prototype.hasOwnProperty;
7
+ export function mapOwn(obj, fn) {
8
+ var results = [];
9
+ var key = '';
10
+ var i = 0;
11
+ for (key in obj) {
12
+ if (has.call(obj, key)) {
13
+ results[i] = fn(key, obj[key]);
14
+ i += 1;
15
+ }
16
+ }
17
+ return results;
18
+ }
@@ -0,0 +1,67 @@
1
+ import { getConfigurationValue } from '../config/config';
2
+ import { SharedContext } from '../context/shared-context';
3
+ import { protocol } from '../url/protocol';
4
+ import { warn } from './console';
5
+ var fileProtocolRule = {
6
+ regex: /^file:\/\/(.*)/,
7
+ replacement: 'file://OBFUSCATED'
8
+ };
9
+ export class Obfuscator extends SharedContext {
10
+ constructor(parent) {
11
+ super(parent); // gets any allowed properties from the parent and stores them in `sharedContext`
12
+ }
13
+
14
+ shouldObfuscate() {
15
+ return getRules(this.sharedContext.agentIdentifier).length > 0;
16
+ }
17
+
18
+ // applies all regex obfuscation rules to provided URL string and returns the result
19
+ obfuscateString(string) {
20
+ // if string is empty string, null or not a string, return unmodified
21
+ if (!string || typeof string !== 'string') return string;
22
+ var rules = getRules(this.sharedContext.agentIdentifier);
23
+ var obfuscated = string;
24
+
25
+ // apply every rule to URL string
26
+ for (var i = 0; i < rules.length; i++) {
27
+ var regex = rules[i].regex;
28
+ var replacement = rules[i].replacement || '*';
29
+ obfuscated = obfuscated.replace(regex, replacement);
30
+ }
31
+ return obfuscated;
32
+ }
33
+ }
34
+
35
+ // TO DO: this function should be inside the Obfuscator class since its context relates to agentID
36
+ export function getRules(agentIdentifier) {
37
+ var rules = [];
38
+ var configRules = getConfigurationValue(agentIdentifier, 'obfuscate') || [];
39
+ rules = rules.concat(configRules);
40
+ if (protocol.isFileProtocol()) rules.push(fileProtocolRule);
41
+ // could add additional runtime/environment-specific rules here
42
+
43
+ return rules;
44
+ }
45
+
46
+ // takes array of rule objects, logs warning and returns false if any portion of rule is invalid
47
+ export function validateRules(rules) {
48
+ var invalidReplacementDetected = false;
49
+ var invalidRegexDetected = false;
50
+ for (var i = 0; i < rules.length; i++) {
51
+ if (!('regex' in rules[i])) {
52
+ warn('An obfuscation replacement rule was detected missing a "regex" value.');
53
+ invalidRegexDetected = true;
54
+ } else if (typeof rules[i].regex !== 'string' && !(rules[i].regex.constructor === RegExp)) {
55
+ warn('An obfuscation replacement rule contains a "regex" value with an invalid type (must be a string or RegExp)');
56
+ invalidRegexDetected = true;
57
+ }
58
+ var replacement = rules[i].replacement;
59
+ if (replacement) {
60
+ if (typeof replacement !== 'string') {
61
+ warn('An obfuscation replacement rule contains a "replacement" value with an invalid type (must be a string)');
62
+ invalidReplacementDetected = true;
63
+ }
64
+ }
65
+ }
66
+ return !invalidReplacementDetected && !invalidRegexDetected;
67
+ }
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ export function reduce(arr, fn, next) {
7
+ var i = 0;
8
+ if (typeof next === 'undefined') {
9
+ next = arr[0];
10
+ i = 1;
11
+ }
12
+ for (i; i < arr.length; i++) {
13
+ next = fn(next, arr[i]);
14
+ }
15
+ return next;
16
+ }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ export function sHash(s) {
7
+ var i;
8
+ var h = 0;
9
+ for (i = 0; i < s.length; i++) {
10
+ h += (i + 1) * s.charCodeAt(i);
11
+ }
12
+ return Math.abs(h);
13
+ }
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import slice from 'lodash._slice';
7
+ export function single(fn) {
8
+ var called = false;
9
+ var res;
10
+ return function () {
11
+ if (called) return res;
12
+ called = true;
13
+ res = fn.apply(this, slice(arguments));
14
+ return res;
15
+ };
16
+ }
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { ee } from '../event-emitter/contextual-ee';
7
+
8
+ /**
9
+ * Returns a function for use as a replacer parameter in JSON.stringify() to handle circular references.
10
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value MDN - Cyclical object value}
11
+ * @returns {Function} A function that filters out values it has seen before.
12
+ */
13
+ const getCircularReplacer = () => {
14
+ const seen = new WeakSet();
15
+ return (key, value) => {
16
+ if (typeof value === 'object' && value !== null) {
17
+ if (seen.has(value)) {
18
+ return;
19
+ }
20
+ seen.add(value);
21
+ }
22
+ return value;
23
+ };
24
+ };
25
+
26
+ /**
27
+ * The native JSON.stringify method augmented with a replacer function to handle circular references.
28
+ * Circular references will be excluded from the JSON output rather than triggering errors.
29
+ * @param {*} val - A value to be converted to a JSON string.
30
+ * @returns {string} A JSON string representation of the value, with circular references handled.
31
+ */
32
+ export function stringify(val) {
33
+ try {
34
+ return JSON.stringify(val, getCircularReplacer());
35
+ } catch (e) {
36
+ try {
37
+ ee.emit('internal-error', [e]);
38
+ } catch (err) {
39
+ // do nothing
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,91 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { isWorkerScope } from './global-scope';
6
+ export const submitData = {};
7
+
8
+ /**
9
+ * Send via JSONP. Do NOT call this function outside of a guaranteed web window environment.
10
+ * @param {string} url
11
+ * @param {string} jsonp
12
+ * @returns {Element}
13
+ */
14
+ submitData.jsonp = function jsonp(url, jsonp) {
15
+ try {
16
+ if (isWorkerScope) {
17
+ try {
18
+ return importScripts(url + '&jsonp=' + jsonp);
19
+ } catch (e) {
20
+ // for now theres no other way to execute the callback from ingest without jsonp, or unsafe eval / new Function calls
21
+ // future work needs to be conducted to allow ingest to return a more traditional JSON API-like experience for the entitlement flags
22
+ submitData.xhrGet(url + '&jsonp=' + jsonp);
23
+ return false;
24
+ }
25
+ } else {
26
+ var element = document.createElement('script');
27
+ element.type = 'text/javascript';
28
+ element.src = url + '&jsonp=' + jsonp;
29
+ var firstScript = document.getElementsByTagName('script')[0];
30
+ firstScript.parentNode.insertBefore(element, firstScript);
31
+ return element;
32
+ }
33
+ } catch (err) {
34
+ // do nothing
35
+ }
36
+ };
37
+ submitData.xhrGet = function xhrGet(url) {
38
+ return submitData.xhr(url, undefined, false, 'GET');
39
+ };
40
+
41
+ /**
42
+ * Send via XHR
43
+ * @param {string} url
44
+ * @param {string} body
45
+ * @param {boolean} sync
46
+ * @returns {XMLHttpRequest}
47
+ */
48
+ submitData.xhr = function xhr(url, body, sync, method = 'POST') {
49
+ var request = new XMLHttpRequest();
50
+ request.open(method, url, !sync);
51
+ try {
52
+ // Set cookie
53
+ if ('withCredentials' in request) request.withCredentials = true;
54
+ } catch (e) {
55
+ // do nothing
56
+ }
57
+ request.setRequestHeader('content-type', 'text/plain');
58
+ request.send(body);
59
+ return request;
60
+ };
61
+
62
+ /**
63
+ * Unused at the moment -- DEPRECATED
64
+ */
65
+ // submitData.xhrSync = function xhrSync (url, body) {
66
+ // return submitData.xhr(url, body, true)
67
+ // }
68
+
69
+ /**
70
+ * Send by appending an <img> element to the page. Do NOT call this function outside of a guaranteed web window environment.
71
+ * @param {string} url
72
+ * @returns {Element}
73
+ */
74
+ submitData.img = function img(url) {
75
+ var element = new Image();
76
+ element.src = url;
77
+ return element;
78
+ };
79
+
80
+ /**
81
+ * Send via sendBeacon. Do NOT call this function outside of a guaranteed web window environment.
82
+ * @param {string} url
83
+ * @param {string} body
84
+ * @returns {boolean}
85
+ */
86
+ submitData.beacon = function (url, body) {
87
+ // Navigator has to be bound to ensure it does not error in some browsers
88
+ // https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
89
+ const send = window.navigator.sendBeacon.bind(navigator);
90
+ return send(url, body);
91
+ };
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ // traverses an object and applies a fn to property values of a certain type
7
+ export function applyFnToProps(obj, fn, type, ignoreKeys) {
8
+ if (!obj || typeof obj !== 'object') return obj;
9
+ type = type || 'string';
10
+ ignoreKeys = ignoreKeys || [];
11
+ return traverse(obj);
12
+ function traverse(obj) {
13
+ for (var property in obj) {
14
+ // eslint-disable-next-line
15
+ if (obj.hasOwnProperty(property)) {
16
+ if (typeof obj[property] === 'object') {
17
+ traverse(obj[property]);
18
+ } else {
19
+ if (typeof obj[property] === type && !shouldIgnore(property)) obj[property] = fn(obj[property]);
20
+ }
21
+ }
22
+ }
23
+ return obj;
24
+ }
25
+ function shouldIgnore(key) {
26
+ var ignore = false;
27
+ for (var i = 0; i < ignoreKeys.length; i++) {
28
+ if (ignoreKeys[i] === key) {
29
+ ignore = true;
30
+ break;
31
+ }
32
+ }
33
+ return ignore;
34
+ }
35
+ }
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ // Feature-detection is much preferred over using User Agent to detect browser.
7
+ // However, there are cases where feature detection is not possible, for example
8
+ // when a specific version of a browser has a bug that requires a workaround in just
9
+ // that version.
10
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#Browser_Name
11
+ var agentName = null;
12
+ var agentVersion = null;
13
+ const safari = /Version\/(\S+)\s+Safari/;
14
+ if (navigator.userAgent) {
15
+ var userAgent = navigator.userAgent;
16
+ var parts = userAgent.match(safari);
17
+ if (parts && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Chromium') === -1) {
18
+ agentName = 'Safari';
19
+ agentVersion = parts[1];
20
+ }
21
+ }
22
+ export { agentName as agent, agentVersion as version };
23
+ export function match(name, version) {
24
+ if (!agentName) {
25
+ return false;
26
+ }
27
+ if (name !== agentName) {
28
+ return false;
29
+ }
30
+
31
+ // version not provided, only match by name
32
+ if (!version) {
33
+ return true;
34
+ }
35
+
36
+ // version provided, but not detected - not reliable match
37
+ if (!agentVersion) {
38
+ return false;
39
+ }
40
+ var detectedParts = agentVersion.split('.');
41
+ var requestedParts = version.split('.');
42
+ for (var i = 0; i < requestedParts.length; i++) {
43
+ if (requestedParts[i] !== detectedParts[i]) {
44
+ return false;
45
+ }
46
+ }
47
+ return true;
48
+ }
@@ -0,0 +1,12 @@
1
+ import { windowAddEventListener, documentAddEventListener } from '../event-listener/event-listener-opts';
2
+ function checkState() {
3
+ return typeof document === 'undefined' || document.readyState === 'complete';
4
+ }
5
+ export function onWindowLoad(cb, useCapture) {
6
+ if (checkState()) return cb();
7
+ windowAddEventListener('load', cb, useCapture);
8
+ }
9
+ export function onDOMContentLoaded(cb) {
10
+ if (checkState()) return cb();
11
+ documentAddEventListener('DOMContentLoaded', cb);
12
+ }