@openobserve/browser-core 0.2.11-rc1 → 0.2.11

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 (393) hide show
  1. package/cjs/boot/init.js +1 -1
  2. package/cjs/boot/init.js.map +1 -1
  3. package/cjs/browser/addEventListener.d.ts +4 -12
  4. package/cjs/browser/addEventListener.js +8 -50
  5. package/cjs/browser/addEventListener.js.map +1 -1
  6. package/cjs/browser/cookie.d.ts +0 -7
  7. package/cjs/browser/cookie.js +2 -19
  8. package/cjs/browser/cookie.js.map +1 -1
  9. package/cjs/browser/fetchObservable.js +19 -14
  10. package/cjs/browser/fetchObservable.js.map +1 -1
  11. package/cjs/browser/pageExitObservable.js +7 -6
  12. package/cjs/browser/pageExitObservable.js.map +1 -1
  13. package/cjs/browser/runOnReadyState.js +1 -1
  14. package/cjs/browser/runOnReadyState.js.map +1 -1
  15. package/cjs/browser/xhrObservable.d.ts +2 -1
  16. package/cjs/browser/xhrObservable.js +34 -26
  17. package/cjs/browser/xhrObservable.js.map +1 -1
  18. package/cjs/domain/configuration/configuration.d.ts +12 -17
  19. package/cjs/domain/configuration/configuration.js +9 -8
  20. package/cjs/domain/configuration/configuration.js.map +1 -1
  21. package/cjs/domain/configuration/endpointBuilder.d.ts +10 -6
  22. package/cjs/domain/configuration/endpointBuilder.js +33 -23
  23. package/cjs/domain/configuration/endpointBuilder.js.map +1 -1
  24. package/cjs/domain/configuration/index.d.ts +1 -2
  25. package/cjs/domain/configuration/index.js +1 -3
  26. package/cjs/domain/configuration/index.js.map +1 -1
  27. package/cjs/domain/configuration/tags.js.map +1 -1
  28. package/cjs/domain/configuration/transportConfiguration.js +1 -1
  29. package/cjs/domain/configuration/transportConfiguration.js.map +1 -1
  30. package/cjs/domain/console/consoleObservable.js +7 -4
  31. package/cjs/domain/console/consoleObservable.js.map +1 -1
  32. package/cjs/domain/deflate/index.d.ts +1 -0
  33. package/cjs/domain/{connectivity → deflate}/index.js +1 -1
  34. package/cjs/domain/deflate/index.js.map +1 -0
  35. package/cjs/domain/deflate/types.d.ts +26 -0
  36. package/cjs/domain/error/error.d.ts +1 -1
  37. package/cjs/domain/error/error.js +3 -3
  38. package/cjs/domain/error/error.js.map +1 -1
  39. package/cjs/domain/error/error.types.d.ts +2 -2
  40. package/cjs/domain/error/error.types.js.map +1 -1
  41. package/cjs/domain/error/trackRuntimeError.d.ts +0 -8
  42. package/cjs/domain/error/trackRuntimeError.js +6 -39
  43. package/cjs/domain/error/trackRuntimeError.js.map +1 -1
  44. package/cjs/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
  45. package/cjs/domain/report/browser.types.d.ts +0 -10
  46. package/cjs/domain/report/reportObservable.d.ts +0 -2
  47. package/cjs/domain/report/reportObservable.js +7 -7
  48. package/cjs/domain/report/reportObservable.js.map +1 -1
  49. package/cjs/domain/session/oldCookiesMigration.js +4 -4
  50. package/cjs/domain/session/oldCookiesMigration.js.map +1 -1
  51. package/cjs/domain/session/sessionManager.js +2 -2
  52. package/cjs/domain/session/sessionManager.js.map +1 -1
  53. package/cjs/domain/session/sessionState.js.map +1 -1
  54. package/cjs/domain/session/sessionStore.js.map +1 -1
  55. package/cjs/domain/session/sessionStoreOperations.d.ts +5 -0
  56. package/cjs/domain/session/sessionStoreOperations.js +14 -6
  57. package/cjs/domain/session/sessionStoreOperations.js.map +1 -1
  58. package/cjs/domain/session/storeStrategies/sessionInCookie.js +2 -13
  59. package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
  60. package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +0 -1
  61. package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
  62. package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -1
  63. package/cjs/domain/synthetics/syntheticsWorkerValues.js +3 -3
  64. package/cjs/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
  65. package/cjs/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -4
  66. package/cjs/domain/telemetry/telemetry.d.ts +1 -5
  67. package/cjs/domain/telemetry/telemetry.js +6 -17
  68. package/cjs/domain/telemetry/telemetry.js.map +1 -1
  69. package/cjs/domain/telemetry/telemetryEvent.types.d.ts +2 -18
  70. package/cjs/domain/tracekit/computeStackTrace.d.ts +5 -0
  71. package/cjs/domain/{error → tracekit}/computeStackTrace.js +4 -28
  72. package/cjs/domain/tracekit/computeStackTrace.js.map +1 -0
  73. package/cjs/domain/tracekit/index.d.ts +3 -0
  74. package/cjs/domain/tracekit/index.js +8 -0
  75. package/cjs/domain/tracekit/index.js.map +1 -0
  76. package/cjs/domain/tracekit/tracekit.d.ts +35 -0
  77. package/cjs/domain/tracekit/tracekit.js +95 -0
  78. package/cjs/domain/tracekit/tracekit.js.map +1 -0
  79. package/cjs/domain/tracekit/types.d.ts +44 -0
  80. package/cjs/domain/{context/contextConstants.js → tracekit/types.js} +1 -1
  81. package/cjs/domain/tracekit/types.js.map +1 -0
  82. package/cjs/domain/user/user.js.map +1 -1
  83. package/cjs/index.d.ts +63 -0
  84. package/cjs/index.js +155 -0
  85. package/cjs/index.js.map +1 -0
  86. package/cjs/tools/abstractLifeCycle.js.map +1 -1
  87. package/cjs/tools/boundedBuffer.js.map +1 -1
  88. package/cjs/tools/catchUserErrors.js.map +1 -1
  89. package/cjs/tools/display.d.ts +2 -2
  90. package/cjs/tools/display.js +17 -13
  91. package/cjs/tools/display.js.map +1 -1
  92. package/cjs/tools/experimentalFeatures.d.ts +5 -3
  93. package/cjs/tools/experimentalFeatures.js +4 -2
  94. package/cjs/tools/experimentalFeatures.js.map +1 -1
  95. package/cjs/tools/getGlobalObject.js.map +1 -1
  96. package/cjs/tools/getZoneJsOriginalValue.js.map +1 -1
  97. package/cjs/tools/instrumentMethod.d.ts +10 -50
  98. package/cjs/tools/instrumentMethod.js +36 -59
  99. package/cjs/tools/instrumentMethod.js.map +1 -1
  100. package/cjs/tools/matchOption.js.map +1 -1
  101. package/cjs/tools/mergeInto.js.map +1 -1
  102. package/cjs/tools/monitor.d.ts +2 -1
  103. package/cjs/tools/monitor.js +6 -6
  104. package/cjs/tools/monitor.js.map +1 -1
  105. package/cjs/tools/observable.d.ts +1 -1
  106. package/cjs/tools/observable.js +3 -2
  107. package/cjs/tools/observable.js.map +1 -1
  108. package/cjs/tools/readBytesFromStream.js.map +1 -1
  109. package/cjs/tools/sendToExtension.js.map +1 -1
  110. package/cjs/tools/serialisation/contextManager.d.ts +21 -0
  111. package/cjs/tools/serialisation/contextManager.js +70 -0
  112. package/cjs/tools/serialisation/contextManager.js.map +1 -0
  113. package/cjs/tools/serialisation/heavyCustomerDataWarning.d.ts +8 -0
  114. package/cjs/tools/serialisation/heavyCustomerDataWarning.js +18 -0
  115. package/cjs/tools/serialisation/heavyCustomerDataWarning.js.map +1 -0
  116. package/cjs/tools/serialisation/jsonStringify.d.ts +2 -1
  117. package/cjs/tools/serialisation/jsonStringify.js.map +1 -1
  118. package/cjs/tools/serialisation/sanitize.js.map +1 -1
  119. package/cjs/tools/utils/browserDetection.d.ts +0 -8
  120. package/cjs/tools/utils/browserDetection.js +3 -33
  121. package/cjs/tools/utils/browserDetection.js.map +1 -1
  122. package/cjs/tools/utils/byteUtils.js.map +1 -1
  123. package/cjs/tools/utils/functionUtils.js.map +1 -1
  124. package/cjs/tools/utils/objectUtils.js.map +1 -1
  125. package/cjs/tools/utils/polyfills.js.map +1 -1
  126. package/cjs/tools/utils/responseUtils.js.map +1 -1
  127. package/cjs/tools/utils/stringUtils.d.ts +0 -1
  128. package/cjs/tools/utils/stringUtils.js +4 -31
  129. package/cjs/tools/utils/stringUtils.js.map +1 -1
  130. package/cjs/tools/utils/timeUtils.js.map +1 -1
  131. package/cjs/tools/utils/typeUtils.js.map +1 -1
  132. package/cjs/tools/utils/urlPolyfill.js.map +1 -1
  133. package/cjs/tools/valueHistory.js.map +1 -1
  134. package/cjs/transport/batch.d.ts +3 -5
  135. package/cjs/transport/batch.js +29 -73
  136. package/cjs/transport/batch.js.map +1 -1
  137. package/cjs/transport/eventBridge.js.map +1 -1
  138. package/cjs/transport/flushController.d.ts +2 -12
  139. package/cjs/transport/flushController.js +7 -22
  140. package/cjs/transport/flushController.js.map +1 -1
  141. package/cjs/transport/httpRequest.d.ts +2 -3
  142. package/cjs/transport/httpRequest.js +17 -21
  143. package/cjs/transport/httpRequest.js.map +1 -1
  144. package/cjs/transport/sendWithRetryStrategy.d.ts +2 -2
  145. package/cjs/transport/sendWithRetryStrategy.js +9 -9
  146. package/cjs/transport/sendWithRetryStrategy.js.map +1 -1
  147. package/cjs/transport/startBatchWithReplica.d.ts +4 -9
  148. package/cjs/transport/startBatchWithReplica.js +4 -9
  149. package/cjs/transport/startBatchWithReplica.js.map +1 -1
  150. package/esm/boot/init.js +1 -1
  151. package/esm/boot/init.js.map +1 -1
  152. package/esm/browser/addEventListener.d.ts +4 -12
  153. package/esm/browser/addEventListener.js +7 -49
  154. package/esm/browser/addEventListener.js.map +1 -1
  155. package/esm/browser/cookie.d.ts +0 -7
  156. package/esm/browser/cookie.js +2 -17
  157. package/esm/browser/cookie.js.map +1 -1
  158. package/esm/browser/fetchObservable.js +20 -15
  159. package/esm/browser/fetchObservable.js.map +1 -1
  160. package/esm/browser/pageExitObservable.js +8 -7
  161. package/esm/browser/pageExitObservable.js.map +1 -1
  162. package/esm/browser/runOnReadyState.js +2 -2
  163. package/esm/browser/runOnReadyState.js.map +1 -1
  164. package/esm/browser/xhrObservable.d.ts +2 -1
  165. package/esm/browser/xhrObservable.js +36 -28
  166. package/esm/browser/xhrObservable.js.map +1 -1
  167. package/esm/domain/configuration/configuration.d.ts +12 -17
  168. package/esm/domain/configuration/configuration.js +9 -8
  169. package/esm/domain/configuration/configuration.js.map +1 -1
  170. package/esm/domain/configuration/endpointBuilder.d.ts +10 -6
  171. package/esm/domain/configuration/endpointBuilder.js +32 -22
  172. package/esm/domain/configuration/endpointBuilder.js.map +1 -1
  173. package/esm/domain/configuration/index.d.ts +1 -2
  174. package/esm/domain/configuration/index.js +0 -1
  175. package/esm/domain/configuration/index.js.map +1 -1
  176. package/esm/domain/configuration/tags.js.map +1 -1
  177. package/esm/domain/configuration/transportConfiguration.js +1 -1
  178. package/esm/domain/configuration/transportConfiguration.js.map +1 -1
  179. package/esm/domain/console/consoleObservable.js +5 -2
  180. package/esm/domain/console/consoleObservable.js.map +1 -1
  181. package/esm/domain/deflate/types.d.ts +0 -12
  182. package/esm/domain/error/error.d.ts +1 -1
  183. package/esm/domain/error/error.js +1 -1
  184. package/esm/domain/error/error.js.map +1 -1
  185. package/esm/domain/error/error.types.d.ts +2 -2
  186. package/esm/domain/error/error.types.js.map +1 -1
  187. package/esm/domain/error/trackRuntimeError.d.ts +0 -8
  188. package/esm/domain/error/trackRuntimeError.js +4 -35
  189. package/esm/domain/error/trackRuntimeError.js.map +1 -1
  190. package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
  191. package/esm/domain/report/browser.types.d.ts +0 -10
  192. package/esm/domain/report/reportObservable.d.ts +0 -2
  193. package/esm/domain/report/reportObservable.js +8 -8
  194. package/esm/domain/report/reportObservable.js.map +1 -1
  195. package/esm/domain/session/oldCookiesMigration.js +5 -5
  196. package/esm/domain/session/oldCookiesMigration.js.map +1 -1
  197. package/esm/domain/session/sessionManager.js +3 -3
  198. package/esm/domain/session/sessionManager.js.map +1 -1
  199. package/esm/domain/session/sessionState.js.map +1 -1
  200. package/esm/domain/session/sessionStore.js.map +1 -1
  201. package/esm/domain/session/sessionStoreOperations.d.ts +5 -0
  202. package/esm/domain/session/sessionStoreOperations.js +12 -5
  203. package/esm/domain/session/sessionStoreOperations.js.map +1 -1
  204. package/esm/domain/session/storeStrategies/sessionInCookie.js +2 -13
  205. package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
  206. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +0 -1
  207. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
  208. package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -1
  209. package/esm/domain/synthetics/syntheticsWorkerValues.js +4 -4
  210. package/esm/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
  211. package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -4
  212. package/esm/domain/telemetry/telemetry.d.ts +1 -5
  213. package/esm/domain/telemetry/telemetry.js +5 -16
  214. package/esm/domain/telemetry/telemetry.js.map +1 -1
  215. package/esm/domain/telemetry/telemetryEvent.types.d.ts +2 -18
  216. package/esm/domain/tracekit/computeStackTrace.d.ts +5 -0
  217. package/esm/domain/{error → tracekit}/computeStackTrace.js +3 -26
  218. package/esm/domain/tracekit/computeStackTrace.js.map +1 -0
  219. package/esm/domain/tracekit/index.d.ts +3 -0
  220. package/esm/domain/tracekit/index.js +3 -0
  221. package/esm/domain/tracekit/index.js.map +1 -0
  222. package/esm/domain/tracekit/tracekit.d.ts +35 -0
  223. package/esm/domain/tracekit/tracekit.js +91 -0
  224. package/esm/domain/tracekit/tracekit.js.map +1 -0
  225. package/esm/domain/tracekit/types.d.ts +44 -0
  226. package/esm/domain/tracekit/types.js +2 -0
  227. package/esm/domain/tracekit/types.js.map +1 -0
  228. package/esm/domain/user/user.js.map +1 -1
  229. package/esm/index.d.ts +5 -9
  230. package/esm/index.js +5 -8
  231. package/esm/index.js.map +1 -1
  232. package/esm/tools/abstractLifeCycle.js.map +1 -1
  233. package/esm/tools/boundedBuffer.js.map +1 -1
  234. package/esm/tools/catchUserErrors.js.map +1 -1
  235. package/esm/tools/display.d.ts +2 -2
  236. package/esm/tools/display.js +15 -12
  237. package/esm/tools/display.js.map +1 -1
  238. package/esm/tools/experimentalFeatures.d.ts +5 -3
  239. package/esm/tools/experimentalFeatures.js +4 -2
  240. package/esm/tools/experimentalFeatures.js.map +1 -1
  241. package/esm/tools/getGlobalObject.js.map +1 -1
  242. package/esm/tools/getZoneJsOriginalValue.js.map +1 -1
  243. package/esm/tools/instrumentMethod.d.ts +10 -50
  244. package/esm/tools/instrumentMethod.js +34 -58
  245. package/esm/tools/instrumentMethod.js.map +1 -1
  246. package/esm/tools/matchOption.js.map +1 -1
  247. package/esm/tools/mergeInto.js.map +1 -1
  248. package/esm/tools/monitor.d.ts +2 -1
  249. package/esm/tools/monitor.js +7 -7
  250. package/esm/tools/monitor.js.map +1 -1
  251. package/esm/tools/observable.d.ts +1 -1
  252. package/esm/tools/observable.js +3 -2
  253. package/esm/tools/observable.js.map +1 -1
  254. package/esm/tools/readBytesFromStream.js.map +1 -1
  255. package/esm/tools/sendToExtension.js.map +1 -1
  256. package/esm/tools/serialisation/contextManager.d.ts +21 -0
  257. package/esm/tools/serialisation/contextManager.js +66 -0
  258. package/esm/tools/serialisation/contextManager.js.map +1 -0
  259. package/esm/tools/serialisation/heavyCustomerDataWarning.d.ts +8 -0
  260. package/esm/tools/serialisation/heavyCustomerDataWarning.js +14 -0
  261. package/esm/tools/serialisation/heavyCustomerDataWarning.js.map +1 -0
  262. package/esm/tools/serialisation/jsonStringify.d.ts +2 -1
  263. package/esm/tools/serialisation/jsonStringify.js.map +1 -1
  264. package/esm/tools/serialisation/sanitize.js.map +1 -1
  265. package/esm/tools/utils/browserDetection.d.ts +0 -8
  266. package/esm/tools/utils/browserDetection.js +2 -30
  267. package/esm/tools/utils/browserDetection.js.map +1 -1
  268. package/esm/tools/utils/byteUtils.js.map +1 -1
  269. package/esm/tools/utils/functionUtils.js.map +1 -1
  270. package/esm/tools/utils/objectUtils.js.map +1 -1
  271. package/esm/tools/utils/polyfills.js.map +1 -1
  272. package/esm/tools/utils/responseUtils.js.map +1 -1
  273. package/esm/tools/utils/stringUtils.d.ts +0 -1
  274. package/esm/tools/utils/stringUtils.js +3 -29
  275. package/esm/tools/utils/stringUtils.js.map +1 -1
  276. package/esm/tools/utils/timeUtils.js.map +1 -1
  277. package/esm/tools/utils/typeUtils.js.map +1 -1
  278. package/esm/tools/utils/urlPolyfill.js.map +1 -1
  279. package/esm/tools/valueHistory.js.map +1 -1
  280. package/esm/transport/batch.d.ts +3 -5
  281. package/esm/transport/batch.js +29 -73
  282. package/esm/transport/batch.js.map +1 -1
  283. package/esm/transport/eventBridge.js.map +1 -1
  284. package/esm/transport/flushController.d.ts +2 -12
  285. package/esm/transport/flushController.js +7 -22
  286. package/esm/transport/flushController.js.map +1 -1
  287. package/esm/transport/httpRequest.d.ts +2 -3
  288. package/esm/transport/httpRequest.js +17 -21
  289. package/esm/transport/httpRequest.js.map +1 -1
  290. package/esm/transport/sendWithRetryStrategy.d.ts +2 -2
  291. package/esm/transport/sendWithRetryStrategy.js +9 -9
  292. package/esm/transport/sendWithRetryStrategy.js.map +1 -1
  293. package/esm/transport/startBatchWithReplica.d.ts +4 -9
  294. package/esm/transport/startBatchWithReplica.js +4 -9
  295. package/esm/transport/startBatchWithReplica.js.map +1 -1
  296. package/package.json +1 -1
  297. package/src/browser/addEventListener.ts +31 -37
  298. package/src/browser/cookie.ts +2 -21
  299. package/src/browser/fetchObservable.ts +25 -21
  300. package/src/browser/pageExitObservable.ts +3 -1
  301. package/src/browser/xhrObservable.ts +37 -31
  302. package/src/domain/configuration/configuration.ts +22 -24
  303. package/src/domain/configuration/endpointBuilder.ts +46 -33
  304. package/src/domain/configuration/index.ts +1 -2
  305. package/src/domain/configuration/transportConfiguration.ts +1 -1
  306. package/src/domain/console/consoleObservable.ts +7 -3
  307. package/src/domain/deflate/types.ts +0 -14
  308. package/src/domain/error/error.ts +2 -2
  309. package/src/domain/error/error.types.ts +2 -11
  310. package/src/domain/error/trackRuntimeError.ts +12 -44
  311. package/src/domain/report/browser.types.ts +0 -12
  312. package/src/domain/report/reportObservable.ts +6 -8
  313. package/src/domain/session/oldCookiesMigration.ts +5 -5
  314. package/src/domain/session/sessionStoreOperations.ts +13 -5
  315. package/src/domain/session/storeStrategies/sessionInCookie.ts +2 -13
  316. package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +0 -1
  317. package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +0 -1
  318. package/src/domain/synthetics/syntheticsWorkerValues.ts +4 -4
  319. package/src/domain/telemetry/rawTelemetryEvent.types.ts +0 -5
  320. package/src/domain/telemetry/telemetry.ts +7 -22
  321. package/src/domain/telemetry/telemetryEvent.types.ts +2 -18
  322. package/src/domain/{error → tracekit}/computeStackTrace.ts +4 -49
  323. package/src/domain/tracekit/index.ts +3 -0
  324. package/src/domain/tracekit/tracekit.ts +96 -0
  325. package/src/domain/tracekit/types.ts +47 -0
  326. package/src/index.ts +7 -13
  327. package/src/tools/display.ts +13 -14
  328. package/src/tools/experimentalFeatures.ts +4 -2
  329. package/src/tools/instrumentMethod.ts +59 -103
  330. package/src/tools/mergeInto.ts +16 -16
  331. package/src/tools/monitor.ts +5 -5
  332. package/src/tools/observable.ts +5 -3
  333. package/src/tools/serialisation/contextManager.ts +79 -0
  334. package/src/tools/serialisation/heavyCustomerDataWarning.ts +26 -0
  335. package/src/tools/utils/browserDetection.ts +2 -43
  336. package/src/tools/utils/polyfills.ts +4 -1
  337. package/src/tools/utils/stringUtils.ts +4 -30
  338. package/src/transport/batch.ts +31 -86
  339. package/src/transport/flushController.ts +7 -22
  340. package/src/transport/httpRequest.ts +16 -23
  341. package/src/transport/sendWithRetryStrategy.ts +10 -10
  342. package/src/transport/startBatchWithReplica.ts +6 -22
  343. package/cjs/domain/connectivity/connectivity.d.ts +0 -13
  344. package/cjs/domain/connectivity/connectivity.js +0 -14
  345. package/cjs/domain/connectivity/connectivity.js.map +0 -1
  346. package/cjs/domain/connectivity/index.d.ts +0 -1
  347. package/cjs/domain/connectivity/index.js.map +0 -1
  348. package/cjs/domain/context/contextConstants.d.ts +0 -5
  349. package/cjs/domain/context/contextConstants.js.map +0 -1
  350. package/cjs/domain/context/contextManager.d.ts +0 -12
  351. package/cjs/domain/context/contextManager.js +0 -43
  352. package/cjs/domain/context/contextManager.js.map +0 -1
  353. package/cjs/domain/context/customerDataTracker.d.ts +0 -45
  354. package/cjs/domain/context/customerDataTracker.js +0 -107
  355. package/cjs/domain/context/customerDataTracker.js.map +0 -1
  356. package/cjs/domain/context/storeContextManager.d.ts +0 -6
  357. package/cjs/domain/context/storeContextManager.js +0 -38
  358. package/cjs/domain/context/storeContextManager.js.map +0 -1
  359. package/cjs/domain/error/computeStackTrace.d.ts +0 -33
  360. package/cjs/domain/error/computeStackTrace.js.map +0 -1
  361. package/cjs/tools/encoder.d.ts +0 -53
  362. package/cjs/tools/encoder.js +0 -41
  363. package/cjs/tools/encoder.js.map +0 -1
  364. package/esm/domain/connectivity/connectivity.d.ts +0 -13
  365. package/esm/domain/connectivity/connectivity.js +0 -10
  366. package/esm/domain/connectivity/connectivity.js.map +0 -1
  367. package/esm/domain/connectivity/index.d.ts +0 -1
  368. package/esm/domain/connectivity/index.js +0 -2
  369. package/esm/domain/connectivity/index.js.map +0 -1
  370. package/esm/domain/context/contextConstants.d.ts +0 -5
  371. package/esm/domain/context/contextConstants.js +0 -2
  372. package/esm/domain/context/contextConstants.js.map +0 -1
  373. package/esm/domain/context/contextManager.d.ts +0 -12
  374. package/esm/domain/context/contextManager.js +0 -39
  375. package/esm/domain/context/contextManager.js.map +0 -1
  376. package/esm/domain/context/customerDataTracker.d.ts +0 -45
  377. package/esm/domain/context/customerDataTracker.js +0 -102
  378. package/esm/domain/context/customerDataTracker.js.map +0 -1
  379. package/esm/domain/context/storeContextManager.d.ts +0 -6
  380. package/esm/domain/context/storeContextManager.js +0 -32
  381. package/esm/domain/context/storeContextManager.js.map +0 -1
  382. package/esm/domain/error/computeStackTrace.d.ts +0 -33
  383. package/esm/domain/error/computeStackTrace.js.map +0 -1
  384. package/esm/tools/encoder.d.ts +0 -53
  385. package/esm/tools/encoder.js +0 -37
  386. package/esm/tools/encoder.js.map +0 -1
  387. package/src/domain/connectivity/connectivity.ts +0 -27
  388. package/src/domain/connectivity/index.ts +0 -1
  389. package/src/domain/context/contextConstants.ts +0 -5
  390. package/src/domain/context/contextManager.ts +0 -48
  391. package/src/domain/context/customerDataTracker.ts +0 -134
  392. package/src/domain/context/storeContextManager.ts +0 -51
  393. package/src/tools/encoder.ts +0 -102
@@ -1,33 +0,0 @@
1
- /**
2
- * Cross-browser stack trace computation.
3
- *
4
- * Reference implementation: https://github.com/csnover/TraceKit/blob/04530298073c3823de72deb0b97e7b38ca7bcb59/tracekit.js
5
- */
6
- export interface StackFrame {
7
- url?: string;
8
- func?: string;
9
- /** The arguments passed to the function, if known. */
10
- args?: string[];
11
- line?: number;
12
- column?: number;
13
- /** An array of source code lines; the middle element corresponds to the correct line. */
14
- context?: string[];
15
- }
16
- export interface StackTrace {
17
- name?: string;
18
- message?: string;
19
- url?: string;
20
- stack: StackFrame[];
21
- incomplete?: boolean;
22
- partial?: boolean;
23
- }
24
- export declare function computeStackTrace(ex: unknown): StackTrace;
25
- export declare function computeStackTraceFromOnErrorMessage(messageObj: unknown, url?: string, line?: number, column?: number): {
26
- name: string | undefined;
27
- message: string | undefined;
28
- stack: {
29
- url: string | undefined;
30
- column: number | undefined;
31
- line: number | undefined;
32
- }[];
33
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"computeStackTrace.js","sourceRoot":"","sources":["../../../src/domain/error/computeStackTrace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAsBxD,IAAM,gBAAgB,GAAG,GAAG,CAAA;AAE5B,MAAM,UAAU,iBAAiB,CAAC,EAAW;IAC3C,IAAM,KAAK,GAAiB,EAAE,CAAA;IAE9B,IAAI,aAAa,GAAG,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAC/C,IAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;IAC3B,IAAI,aAAa,IAAI,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,CAAC;QACzD,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACtD,CAAC;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,a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AAS,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,mCAAmC,CAAC,UAAmB,EAAE,GAAY,EAAE,IAAa,EAAE,MAAe;IACnH,IAAM,KAAK,GAAG,CAAC,EAAE,GAAG,KAAA,EAAE,MAAM,QAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAA;IAC/B,IAAA,KAAoB,iBAAiB,CAAC,UAAU,CAAC,EAA/C,IAAI,UAAA,EAAE,OAAO,aAAkC,CAAA;IACvD,OAAO;QACL,IAAI,MAAA;QACJ,OAAO,SAAA;QACP,KAAK,OAAA;KACN,CAAA;AACH,CAAC;AAED,qGAAqG;AACrG,IAAM,cAAc,GAClB,8GAA8G,CAAA;AAEhH,SAAS,iBAAiB,CAAC,UAAmB;;IAC5C,IAAI,IAAI,CAAA;IACR,IAAI,OAAO,CAAA;IACX,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,iBAAiB,EAAE,CAAC;QACvD,CAAC;QAAA,KAAoB,cAAc,CAAC,IAAI,CAAC,UAAoB,CAAE,EAA3D,IAAI,QAAA,EAAE,OAAO,QAAA,CAA8C;IACjE,CAAC;IACD,OAAO,EAAE,IAAI,MAAA,EAAE,OAAO,SAAA,EAAE,CAAA;AAC1B,CAAC"}
@@ -1,53 +0,0 @@
1
- export interface Encoder<Output extends string | Uint8Array = string | Uint8Array> {
2
- /**
3
- * Whether this encoder might call the provided callbacks asynchronously
4
- */
5
- isAsync: boolean;
6
- /**
7
- * Whether some data has been written since the last finish() or finishSync() call
8
- */
9
- isEmpty: boolean;
10
- /**
11
- * Write a string to be encoded.
12
- *
13
- * This operation can be synchronous or asynchronous depending on the encoder implementation.
14
- *
15
- * If specified, the callback will be invoked when the operation finishes, unless the operation is
16
- * asynchronous and finish() or finishSync() is called in the meantime.
17
- */
18
- write(data: string, callback?: (additionalEncodedBytesCount: number) => void): void;
19
- /**
20
- * Waits for pending data to be encoded and resets the encoder state.
21
- *
22
- * This operation can be synchronous or asynchronous depending on the encoder implementation.
23
- *
24
- * The callback will be invoked when the operation finishes, unless the operation is asynchronous
25
- * and another call to finish() or finishSync() occurs in the meantime.
26
- */
27
- finish(callback: (result: EncoderResult<Output>) => void): void;
28
- /**
29
- * Resets the encoder state then returns the encoded data and any potential pending data directly,
30
- * discarding all pending write operations and finish() callbacks.
31
- */
32
- finishSync(): EncoderResult<Output> & {
33
- pendingData: string;
34
- };
35
- /**
36
- * Returns a rough estimation of the bytes count if the data was encoded.
37
- */
38
- estimateEncodedBytesCount(data: string): number;
39
- }
40
- export interface EncoderResult<Output extends string | Uint8Array = string | Uint8Array> {
41
- output: Output;
42
- outputBytesCount: number;
43
- /**
44
- * An encoding type supported by HTTP Content-Encoding, if applicable.
45
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding#directives
46
- */
47
- encoding?: 'deflate';
48
- /**
49
- * Total bytes count of the input strings encoded to UTF-8.
50
- */
51
- rawBytesCount: number;
52
- }
53
- export declare function createIdentityEncoder(): Encoder<string>;
@@ -1,37 +0,0 @@
1
- import { computeBytesCount } from './utils/byteUtils';
2
- export function createIdentityEncoder() {
3
- var output = '';
4
- var outputBytesCount = 0;
5
- return {
6
- isAsync: false,
7
- get isEmpty() {
8
- return !output;
9
- },
10
- write: function (data, callback) {
11
- var additionalEncodedBytesCount = computeBytesCount(data);
12
- outputBytesCount += additionalEncodedBytesCount;
13
- output += data;
14
- if (callback) {
15
- callback(additionalEncodedBytesCount);
16
- }
17
- },
18
- finish: function (callback) {
19
- callback(this.finishSync());
20
- },
21
- finishSync: function () {
22
- var result = {
23
- output: output,
24
- outputBytesCount: outputBytesCount,
25
- rawBytesCount: outputBytesCount,
26
- pendingData: '',
27
- };
28
- output = '';
29
- outputBytesCount = 0;
30
- return result;
31
- },
32
- estimateEncodedBytesCount: function (data) {
33
- return data.length;
34
- },
35
- };
36
- }
37
- //# sourceMappingURL=encoder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../src/tools/encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AA6DrD,MAAM,UAAU,qBAAqB;IACnC,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,IAAI,gBAAgB,GAAG,CAAC,CAAA;IAExB,OAAO;QACL,OAAO,EAAE,KAAK;QAEd,IAAI,OAAO;YACT,OAAO,CAAC,MAAM,CAAA;QAChB,CAAC;QAED,KAAK,YAAC,IAAI,EAAE,QAAQ;YAClB,IAAM,2BAA2B,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;YAC3D,gBAAgB,IAAI,2BAA2B,CAAA;YAC/C,MAAM,IAAI,IAAI,CAAA;YACd,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,2BAA2B,CAAC,CAAA;YACvC,CAAC;QACH,CAAC;QAED,MAAM,YAAC,QAAQ;YACb,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;QAC7B,CAAC;QAED,UAAU;YACR,IAAM,MAAM,GAAG;gBACb,MAAM,QAAA;gBACN,gBAAgB,kBAAA;gBAChB,aAAa,EAAE,gBAAgB;gBAC/B,WAAW,EAAE,EAAE;aAChB,CAAA;YACD,MAAM,GAAG,EAAE,CAAA;YACX,gBAAgB,GAAG,CAAC,CAAA;YACpB,OAAO,MAAM,CAAA;QACf,CAAC;QAED,yBAAyB,YAAC,IAAI;YAC5B,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -1,27 +0,0 @@
1
- export type NetworkInterface = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown'
2
- export type EffectiveType = 'slow-2g' | '2g' | '3g' | '4g'
3
-
4
- interface BrowserNavigator extends Navigator {
5
- connection?: NetworkInformation
6
- }
7
-
8
- export interface NetworkInformation {
9
- type?: NetworkInterface
10
- effectiveType?: EffectiveType
11
- }
12
-
13
- export interface Connectivity {
14
- status: 'connected' | 'not_connected'
15
- interfaces?: NetworkInterface[]
16
- effective_type?: EffectiveType
17
- [key: string]: unknown
18
- }
19
-
20
- export function getConnectivity(): Connectivity {
21
- const navigator = window.navigator as BrowserNavigator
22
- return {
23
- status: navigator.onLine ? 'connected' : 'not_connected',
24
- interfaces: navigator.connection && navigator.connection.type ? [navigator.connection.type] : undefined,
25
- effective_type: navigator.connection?.effectiveType,
26
- }
27
- }
@@ -1 +0,0 @@
1
- export * from './connectivity'
@@ -1,5 +0,0 @@
1
- export const enum CustomerDataType {
2
- FeatureFlag,
3
- User,
4
- GlobalContext,
5
- }
@@ -1,48 +0,0 @@
1
- import { deepClone } from '../../tools/mergeInto'
2
- import { getType } from '../../tools/utils/typeUtils'
3
- import { sanitize } from '../../tools/serialisation/sanitize'
4
- import type { Context } from '../../tools/serialisation/context'
5
- import { Observable } from '../../tools/observable'
6
- import type { CustomerDataTracker } from './customerDataTracker'
7
-
8
- export type ContextManager = ReturnType<typeof createContextManager>
9
-
10
- export function createContextManager(customerDataTracker: CustomerDataTracker) {
11
- let context: Context = {}
12
- const changeObservable = new Observable<void>()
13
-
14
- const contextManager = {
15
- getContext: () => deepClone(context),
16
-
17
- setContext: (newContext: Context) => {
18
- if (getType(newContext) === 'object') {
19
- context = sanitize(newContext)
20
- customerDataTracker.updateCustomerData(context)
21
- } else {
22
- contextManager.clearContext()
23
- }
24
- changeObservable.notify()
25
- },
26
-
27
- setContextProperty: (key: string, property: any) => {
28
- context[key] = sanitize(property)
29
- customerDataTracker.updateCustomerData(context)
30
- changeObservable.notify()
31
- },
32
-
33
- removeContextProperty: (key: string) => {
34
- delete context[key]
35
- customerDataTracker.updateCustomerData(context)
36
- changeObservable.notify()
37
- },
38
-
39
- clearContext: () => {
40
- context = {}
41
- customerDataTracker.resetCustomerData()
42
- changeObservable.notify()
43
- },
44
-
45
- changeObservable,
46
- }
47
- return contextManager
48
- }
@@ -1,134 +0,0 @@
1
- import { ONE_KIBI_BYTE, computeBytesCount } from '../../tools/utils/byteUtils'
2
- import { throttle } from '../../tools/utils/functionUtils'
3
- import type { Context } from '../../tools/serialisation/context'
4
- import { jsonStringify } from '../../tools/serialisation/jsonStringify'
5
- import { display } from '../../tools/display'
6
- import { isEmptyObject } from '../../tools/utils/objectUtils'
7
- import type { CustomerDataType } from './contextConstants'
8
-
9
- // RUM and logs batch bytes limit is 16KB
10
- // ensure that we leave room for other event attributes and maintain a decent amount of event per batch
11
- // (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
12
- export const CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE
13
-
14
- // We observed that the compression ratio is around 8 in general, but we also want to keep a margin
15
- // because some data might not be compressed (ex: last view update on page exit). We chose 16KiB
16
- // because it is also the limit of the 'batchBytesCount' that we use for RUM and Logs data, but this
17
- // is a bit arbitrary.
18
- export const CUSTOMER_COMPRESSED_DATA_BYTES_LIMIT = 16 * ONE_KIBI_BYTE
19
-
20
- export const BYTES_COMPUTATION_THROTTLING_DELAY = 200
21
-
22
- export type CustomerDataTracker = ReturnType<typeof createCustomerDataTracker>
23
- export type CustomerDataTrackerManager = ReturnType<typeof createCustomerDataTrackerManager>
24
-
25
- export const enum CustomerDataCompressionStatus {
26
- Unknown,
27
- Enabled,
28
- Disabled,
29
- }
30
-
31
- export function createCustomerDataTrackerManager(
32
- compressionStatus: CustomerDataCompressionStatus = CustomerDataCompressionStatus.Disabled
33
- ) {
34
- const customerDataTrackers = new Map<CustomerDataType, CustomerDataTracker>()
35
-
36
- let alreadyWarned = false
37
- function checkCustomerDataLimit(initialBytesCount = 0) {
38
- if (alreadyWarned || compressionStatus === CustomerDataCompressionStatus.Unknown) {
39
- return
40
- }
41
-
42
- const bytesCountLimit =
43
- compressionStatus === CustomerDataCompressionStatus.Disabled
44
- ? CUSTOMER_DATA_BYTES_LIMIT
45
- : CUSTOMER_COMPRESSED_DATA_BYTES_LIMIT
46
-
47
- let bytesCount = initialBytesCount
48
- customerDataTrackers.forEach((tracker) => {
49
- bytesCount += tracker.getBytesCount()
50
- })
51
-
52
- if (bytesCount > bytesCountLimit) {
53
- displayCustomerDataLimitReachedWarning(bytesCountLimit)
54
- alreadyWarned = true
55
- }
56
- }
57
-
58
- return {
59
- /**
60
- * Creates a detached tracker. The manager will not store a reference to that tracker, and the
61
- * bytes count will be counted independently from other detached trackers.
62
- *
63
- * This is particularly useful when we don't know when the tracker will be unused, so we don't
64
- * leak memory (ex: when used in Logger instances).
65
- */
66
- createDetachedTracker: () => {
67
- const tracker = createCustomerDataTracker(() => checkCustomerDataLimit(tracker.getBytesCount()))
68
- return tracker
69
- },
70
-
71
- /**
72
- * Creates a tracker if it doesn't exist, and returns it.
73
- */
74
- getOrCreateTracker: (type: CustomerDataType) => {
75
- if (!customerDataTrackers.has(type)) {
76
- customerDataTrackers.set(type, createCustomerDataTracker(checkCustomerDataLimit))
77
- }
78
- return customerDataTrackers.get(type)!
79
- },
80
-
81
- setCompressionStatus: (newCompressionStatus: CustomerDataCompressionStatus) => {
82
- if (compressionStatus === CustomerDataCompressionStatus.Unknown) {
83
- compressionStatus = newCompressionStatus
84
- checkCustomerDataLimit()
85
- }
86
- },
87
-
88
- getCompressionStatus: () => compressionStatus,
89
-
90
- stop: () => {
91
- customerDataTrackers.forEach((tracker) => tracker.stop())
92
- customerDataTrackers.clear()
93
- },
94
- }
95
- }
96
-
97
- export function createCustomerDataTracker(checkCustomerDataLimit: () => void) {
98
- let bytesCountCache = 0
99
-
100
- // Throttle the bytes computation to minimize the impact on performance.
101
- // Especially useful if the user call context APIs synchronously multiple times in a row
102
- const { throttled: computeBytesCountThrottled, cancel: cancelComputeBytesCount } = throttle((context: Context) => {
103
- bytesCountCache = computeBytesCount(jsonStringify(context)!)
104
- checkCustomerDataLimit()
105
- }, BYTES_COMPUTATION_THROTTLING_DELAY)
106
-
107
- const resetBytesCount = () => {
108
- cancelComputeBytesCount()
109
- bytesCountCache = 0
110
- }
111
-
112
- return {
113
- updateCustomerData: (context: Context) => {
114
- if (isEmptyObject(context)) {
115
- resetBytesCount()
116
- } else {
117
- computeBytesCountThrottled(context)
118
- }
119
- },
120
- resetCustomerData: resetBytesCount,
121
- getBytesCount: () => bytesCountCache,
122
- stop: () => {
123
- cancelComputeBytesCount()
124
- },
125
- }
126
- }
127
-
128
- function displayCustomerDataLimitReachedWarning(bytesCountLimit: number) {
129
- display.warn(
130
- `Customer data exceeds the recommended ${
131
- bytesCountLimit / ONE_KIBI_BYTE
132
- }KiB threshold. More details: https://docs.datadoghq.com/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-threshold-warning`
133
- )
134
- }
@@ -1,51 +0,0 @@
1
- import { addEventListener, DOM_EVENT } from '../../browser/addEventListener'
2
- import type { Context } from '../../tools/serialisation/context'
3
- import type { Configuration } from '../configuration'
4
- import { combine } from '../../tools/mergeInto'
5
- import type { ContextManager } from './contextManager'
6
- import type { CustomerDataType } from './contextConstants'
7
-
8
- const CONTEXT_STORE_KEY_PREFIX = '_oo_c'
9
-
10
- const storageListeners: Array<{ stop: () => void }> = []
11
-
12
- export function storeContextManager(
13
- configuration: Configuration,
14
- contextManager: ContextManager,
15
- productKey: string,
16
- customerDataType: CustomerDataType
17
- ) {
18
- const storageKey = buildStorageKey(productKey, customerDataType)
19
-
20
- storageListeners.push(
21
- addEventListener(configuration, window, DOM_EVENT.STORAGE, ({ key }) => {
22
- if (storageKey === key) {
23
- synchronizeWithStorage()
24
- }
25
- })
26
- )
27
- contextManager.changeObservable.subscribe(dumpToStorage)
28
-
29
- contextManager.setContext(combine(getFromStorage(), contextManager.getContext()))
30
-
31
- function synchronizeWithStorage() {
32
- contextManager.setContext(getFromStorage())
33
- }
34
-
35
- function dumpToStorage() {
36
- localStorage.setItem(storageKey, JSON.stringify(contextManager.getContext()))
37
- }
38
-
39
- function getFromStorage() {
40
- const rawContext = localStorage.getItem(storageKey)
41
- return rawContext !== null ? (JSON.parse(rawContext) as Context) : {}
42
- }
43
- }
44
-
45
- export function buildStorageKey(productKey: string, customerDataType: CustomerDataType) {
46
- return `${CONTEXT_STORE_KEY_PREFIX}_${productKey}_${customerDataType}`
47
- }
48
-
49
- export function removeStorageListeners() {
50
- storageListeners.map((listener) => listener.stop())
51
- }
@@ -1,102 +0,0 @@
1
- import { computeBytesCount } from './utils/byteUtils'
2
-
3
- export interface Encoder<Output extends string | Uint8Array = string | Uint8Array> {
4
- /**
5
- * Whether this encoder might call the provided callbacks asynchronously
6
- */
7
- isAsync: boolean
8
-
9
- /**
10
- * Whether some data has been written since the last finish() or finishSync() call
11
- */
12
- isEmpty: boolean
13
-
14
- /**
15
- * Write a string to be encoded.
16
- *
17
- * This operation can be synchronous or asynchronous depending on the encoder implementation.
18
- *
19
- * If specified, the callback will be invoked when the operation finishes, unless the operation is
20
- * asynchronous and finish() or finishSync() is called in the meantime.
21
- */
22
- write(data: string, callback?: (additionalEncodedBytesCount: number) => void): void
23
-
24
- /**
25
- * Waits for pending data to be encoded and resets the encoder state.
26
- *
27
- * This operation can be synchronous or asynchronous depending on the encoder implementation.
28
- *
29
- * The callback will be invoked when the operation finishes, unless the operation is asynchronous
30
- * and another call to finish() or finishSync() occurs in the meantime.
31
- */
32
- finish(callback: (result: EncoderResult<Output>) => void): void
33
-
34
- /**
35
- * Resets the encoder state then returns the encoded data and any potential pending data directly,
36
- * discarding all pending write operations and finish() callbacks.
37
- */
38
- finishSync(): EncoderResult<Output> & { pendingData: string }
39
-
40
- /**
41
- * Returns a rough estimation of the bytes count if the data was encoded.
42
- */
43
- estimateEncodedBytesCount(data: string): number
44
- }
45
-
46
- export interface EncoderResult<Output extends string | Uint8Array = string | Uint8Array> {
47
- output: Output
48
- outputBytesCount: number
49
-
50
- /**
51
- * An encoding type supported by HTTP Content-Encoding, if applicable.
52
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding#directives
53
- */
54
- encoding?: 'deflate'
55
-
56
- /**
57
- * Total bytes count of the input strings encoded to UTF-8.
58
- */
59
- rawBytesCount: number
60
- }
61
-
62
- export function createIdentityEncoder(): Encoder<string> {
63
- let output = ''
64
- let outputBytesCount = 0
65
-
66
- return {
67
- isAsync: false,
68
-
69
- get isEmpty() {
70
- return !output
71
- },
72
-
73
- write(data, callback) {
74
- const additionalEncodedBytesCount = computeBytesCount(data)
75
- outputBytesCount += additionalEncodedBytesCount
76
- output += data
77
- if (callback) {
78
- callback(additionalEncodedBytesCount)
79
- }
80
- },
81
-
82
- finish(callback) {
83
- callback(this.finishSync())
84
- },
85
-
86
- finishSync() {
87
- const result = {
88
- output,
89
- outputBytesCount,
90
- rawBytesCount: outputBytesCount,
91
- pendingData: '',
92
- }
93
- output = ''
94
- outputBytesCount = 0
95
- return result
96
- },
97
-
98
- estimateEncodedBytesCount(data) {
99
- return data.length
100
- },
101
- }
102
- }