@bitblit/ratchet-common 4.0.99-alpha → 4.0.103-alpha

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 (298) hide show
  1. package/{dist/types → lib}/2d/line-2d.d.ts +1 -1
  2. package/{dist/types → lib}/2d/poly-line-2d.d.ts +1 -1
  3. package/{dist/types → lib}/2d/ratchet-2d.d.ts +4 -4
  4. package/{dist/es → lib}/2d/ratchet-2d.js +1 -1
  5. package/lib/2d/ratchet-2d.spec.js +117 -0
  6. package/{dist/types → lib}/build/ratchet-common-info.d.ts +1 -1
  7. package/{dist/types → lib}/histogram/histogram.d.ts +1 -4
  8. package/{dist/es → lib}/histogram/histogram.js +1 -3
  9. package/lib/histogram/histogram.spec.js +19 -0
  10. package/lib/jwt/common-jwt-token.d.ts +6 -0
  11. package/{dist/types → lib}/jwt/jwt-ratchet-like.d.ts +3 -6
  12. package/{dist/types → lib}/jwt/jwt-ratchet.d.ts +4 -13
  13. package/{dist/es → lib}/jwt/jwt-ratchet.js +12 -7
  14. package/lib/jwt/jwt-ratchet.spec.js +49 -0
  15. package/{dist/types → lib}/jwt/jwt-token-base.d.ts +0 -4
  16. package/lib/lang/array-ratchet.d.ts +14 -0
  17. package/{dist/es → lib}/lang/array-ratchet.js +2 -2
  18. package/lib/lang/array-ratchet.spec.js +68 -0
  19. package/{dist/types → lib}/lang/base64-ratchet.d.ts +1 -1
  20. package/{dist/es → lib}/lang/base64-ratchet.js +1 -1
  21. package/lib/lang/base64-ratchet.spec.js +28 -0
  22. package/{dist/es → lib}/lang/boolean-ratchet.js +1 -1
  23. package/lib/lang/boolean-ratchet.spec.js +81 -0
  24. package/{dist/types → lib}/lang/composite-last-success-provider.d.ts +1 -2
  25. package/{dist/es → lib}/lang/composite-last-success-provider.js +2 -0
  26. package/lib/lang/composite-last-success-provider.spec.js +26 -0
  27. package/{dist/es → lib}/lang/date-ratchet.js +5 -5
  28. package/lib/lang/date-ratchet.spec.js +21 -0
  29. package/{dist/es → lib}/lang/duration-ratchet.js +1 -1
  30. package/lib/lang/duration-ratchet.spec.js +39 -0
  31. package/lib/lang/enum-ratchet.d.ts +5 -0
  32. package/{dist/es → lib}/lang/enum-ratchet.js +1 -1
  33. package/lib/lang/enum-ratchet.spec.d.ts +5 -0
  34. package/lib/lang/enum-ratchet.spec.js +31 -0
  35. package/{dist/es → lib}/lang/error-ratchet.js +1 -1
  36. package/lib/lang/error-ratchet.spec.js +20 -0
  37. package/lib/lang/esm-ratchet.d.ts +4 -0
  38. package/lib/lang/esm-ratchet.js +11 -0
  39. package/{dist/types → lib}/lang/expiring-object.d.ts +1 -1
  40. package/{dist/es → lib}/lang/expiring-object.js +13 -4
  41. package/lib/lang/expiring-object.spec.js +51 -0
  42. package/{dist/es → lib}/lang/geolocation-ratchet.js +4 -4
  43. package/lib/lang/geolocation-ratchet.spec.d.ts +1 -0
  44. package/lib/lang/geolocation-ratchet.spec.js +74 -0
  45. package/{dist/es → lib}/lang/global-ratchet.js +3 -3
  46. package/lib/lang/global-ratchet.spec.d.ts +1 -0
  47. package/lib/lang/global-ratchet.spec.js +14 -0
  48. package/{dist/es → lib}/lang/key-value.js +2 -0
  49. package/lib/lang/last-success-provider.d.ts +3 -0
  50. package/lib/lang/last-success-provider.js +1 -0
  51. package/{dist/types → lib}/lang/map-ratchet.d.ts +1 -1
  52. package/{dist/es → lib}/lang/map-ratchet.js +3 -3
  53. package/lib/lang/map-ratchet.spec.d.ts +1 -0
  54. package/lib/lang/map-ratchet.spec.js +90 -0
  55. package/lib/lang/no.spec.d.ts +1 -0
  56. package/lib/lang/no.spec.js +7 -0
  57. package/{dist/es → lib}/lang/number-ratchet.js +3 -3
  58. package/lib/lang/number-ratchet.spec.d.ts +1 -0
  59. package/lib/lang/number-ratchet.spec.js +118 -0
  60. package/lib/lang/parsed-url.js +1 -0
  61. package/lib/lang/promise-ratchet.d.ts +18 -0
  62. package/{dist/es → lib}/lang/promise-ratchet.js +5 -5
  63. package/lib/lang/promise-ratchet.spec.d.ts +1 -0
  64. package/lib/lang/promise-ratchet.spec.js +74 -0
  65. package/{dist/es → lib}/lang/require-ratchet.js +1 -1
  66. package/lib/lang/require-ratchet.spec.d.ts +3 -0
  67. package/lib/lang/require-ratchet.spec.js +80 -0
  68. package/{dist/types → lib}/lang/stop-watch.d.ts +1 -1
  69. package/{dist/es → lib}/lang/stop-watch.js +9 -8
  70. package/{dist/es → lib}/lang/string-ratchet.js +2 -2
  71. package/lib/lang/string-ratchet.spec.d.ts +1 -0
  72. package/lib/lang/string-ratchet.spec.js +158 -0
  73. package/lib/lang/time-zone-ratchet.d.ts +19 -0
  74. package/{dist/es → lib}/lang/time-zone-ratchet.js +2 -1
  75. package/lib/lang/time-zone-ratchet.spec.d.ts +1 -0
  76. package/lib/lang/time-zone-ratchet.spec.js +40 -0
  77. package/{dist/types → lib}/lang/timeout-token.d.ts +1 -1
  78. package/{dist/es → lib}/lang/timeout-token.js +5 -3
  79. package/lib/lang/timeout-token.spec.d.ts +1 -0
  80. package/lib/lang/timeout-token.spec.js +9 -0
  81. package/{dist/types → lib}/lang/transform-ratchet.d.ts +1 -1
  82. package/{dist/es → lib}/lang/transform-ratchet.js +1 -1
  83. package/lib/lang/transform-ratchet.spec.d.ts +1 -0
  84. package/lib/lang/transform-ratchet.spec.js +118 -0
  85. package/lib/logger/classic-single-line-log-message-formatter.d.ts +6 -0
  86. package/{dist/types → lib}/logger/log-message-builder.d.ts +2 -2
  87. package/{dist/es → lib}/logger/log-message-builder.js +1 -0
  88. package/{dist/types → lib}/logger/log-message-formatter.d.ts +2 -2
  89. package/lib/logger/log-message-formatter.js +1 -0
  90. package/{dist/types → lib}/logger/log-message-processor.d.ts +1 -1
  91. package/lib/logger/log-message-processor.js +1 -0
  92. package/{dist/types → lib}/logger/log-message.d.ts +1 -1
  93. package/lib/logger/log-message.js +1 -0
  94. package/{dist/types → lib}/logger/log-snapshot.d.ts +1 -1
  95. package/lib/logger/log-snapshot.js +1 -0
  96. package/{dist/types → lib}/logger/logger-instance.d.ts +6 -6
  97. package/{dist/es → lib}/logger/logger-instance.js +15 -8
  98. package/{dist/types → lib}/logger/logger-meta.d.ts +1 -1
  99. package/lib/logger/logger-meta.js +1 -0
  100. package/{dist/types → lib}/logger/logger-options.d.ts +4 -4
  101. package/lib/logger/logger-options.js +1 -0
  102. package/{dist/types → lib}/logger/logger-ring-buffer.d.ts +2 -2
  103. package/{dist/es → lib}/logger/logger-ring-buffer.js +7 -6
  104. package/{dist/types → lib}/logger/logger-util.d.ts +2 -2
  105. package/{dist/es → lib}/logger/logger-util.js +10 -10
  106. package/lib/logger/logger-util.spec.d.ts +1 -0
  107. package/lib/logger/logger-util.spec.js +9 -0
  108. package/{dist/types → lib}/logger/logger.d.ts +7 -16
  109. package/{dist/es → lib}/logger/logger.js +14 -14
  110. package/lib/logger/logger.spec.d.ts +1 -0
  111. package/lib/logger/logger.spec.js +134 -0
  112. package/lib/logger/none-log-message-formatter.d.ts +6 -0
  113. package/lib/logger/structured-json-log-message-formatter.d.ts +6 -0
  114. package/{dist/types → lib}/network/browser-local-ip-provider.d.ts +1 -1
  115. package/{dist/es → lib}/network/browser-local-ip-provider.js +3 -3
  116. package/lib/network/browser-local-ip-provider.spec.d.ts +1 -0
  117. package/lib/network/browser-local-ip-provider.spec.js +16 -0
  118. package/{dist/types → lib}/network/fixed-local-ip-provider.d.ts +1 -1
  119. package/{dist/es → lib}/network/fixed-local-ip-provider.js +1 -0
  120. package/lib/network/local-ip-provider.d.ts +3 -0
  121. package/lib/network/local-ip-provider.js +1 -0
  122. package/{dist/types → lib}/network/network-ratchet.d.ts +1 -1
  123. package/{dist/es → lib}/network/network-ratchet.js +2 -2
  124. package/lib/network/network-ratchet.spec.d.ts +1 -0
  125. package/lib/network/network-ratchet.spec.js +13 -0
  126. package/{dist/types → lib}/stream/buffer-writable.d.ts +2 -2
  127. package/{dist/es → lib}/stream/buffer-writable.js +1 -1
  128. package/lib/stream/multi-stream.d.ts +7 -0
  129. package/lib/stream/multi-stream.js +12 -0
  130. package/{dist/types → lib}/stream/stream-ratchet.d.ts +2 -2
  131. package/{dist/es → lib}/stream/stream-ratchet.js +2 -2
  132. package/lib/stream/stream-ratchet.spec.d.ts +1 -0
  133. package/lib/stream/stream-ratchet.spec.js +13 -0
  134. package/{dist/types → lib}/stream/string-writable.d.ts +1 -1
  135. package/{dist/es → lib}/stream/string-writable.js +1 -1
  136. package/lib/stream/string-writable.spec.d.ts +1 -0
  137. package/lib/stream/string-writable.spec.js +12 -0
  138. package/{dist/es → lib}/third-party/google/google-recaptcha-ratchet.js +3 -3
  139. package/lib/third-party/google/google-recaptcha-ratchet.spec.d.ts +1 -0
  140. package/lib/third-party/google/google-recaptcha-ratchet.spec.js +20 -0
  141. package/{dist/types → lib}/third-party/twilio/twilio-ratchet.d.ts +0 -4
  142. package/{dist/es → lib}/third-party/twilio/twilio-ratchet.js +8 -5
  143. package/{dist/types → lib}/transform/built-in-transforms.d.ts +1 -1
  144. package/{dist/es → lib}/transform/built-in-transforms.js +2 -2
  145. package/lib/transform/transform-rule.js +1 -0
  146. package/{dist/types → lib}/tx/transaction-configuration.d.ts +2 -2
  147. package/lib/tx/transaction-configuration.js +1 -0
  148. package/{dist/types → lib}/tx/transaction-ratchet.d.ts +3 -3
  149. package/{dist/es → lib}/tx/transaction-ratchet.js +4 -4
  150. package/lib/tx/transaction-ratchet.spec.d.ts +1 -0
  151. package/lib/tx/transaction-ratchet.spec.js +130 -0
  152. package/{dist/types → lib}/tx/transaction-result.d.ts +1 -1
  153. package/lib/tx/transaction-result.js +1 -0
  154. package/lib/tx/transaction-step.js +1 -0
  155. package/package.json +11 -12
  156. package/dist/cjs/2d/line-2d.js +0 -2
  157. package/dist/cjs/2d/plane-2d.js +0 -2
  158. package/dist/cjs/2d/point-2d.js +0 -2
  159. package/dist/cjs/2d/poly-line-2d.js +0 -2
  160. package/dist/cjs/2d/ratchet-2d.js +0 -250
  161. package/dist/cjs/build/build-information.js +0 -2
  162. package/dist/cjs/build/ratchet-common-info.js +0 -18
  163. package/dist/cjs/histogram/histogram-entry.js +0 -2
  164. package/dist/cjs/histogram/histogram.js +0 -54
  165. package/dist/cjs/index.js +0 -74
  166. package/dist/cjs/jwt/common-jwt-token.js +0 -2
  167. package/dist/cjs/jwt/expired-jwt-handling.js +0 -9
  168. package/dist/cjs/jwt/jwt-ratchet-like.js +0 -2
  169. package/dist/cjs/jwt/jwt-ratchet.js +0 -164
  170. package/dist/cjs/jwt/jwt-token-base.js +0 -2
  171. package/dist/cjs/lang/array-ratchet.js +0 -87
  172. package/dist/cjs/lang/base64-ratchet.js +0 -49
  173. package/dist/cjs/lang/boolean-ratchet.js +0 -49
  174. package/dist/cjs/lang/composite-last-success-provider.js +0 -28
  175. package/dist/cjs/lang/date-ratchet.js +0 -33
  176. package/dist/cjs/lang/duration-ratchet.js +0 -46
  177. package/dist/cjs/lang/enum-ratchet.js +0 -34
  178. package/dist/cjs/lang/error-ratchet.js +0 -49
  179. package/dist/cjs/lang/expiring-object.js +0 -68
  180. package/dist/cjs/lang/geolocation-ratchet.js +0 -267
  181. package/dist/cjs/lang/global-ratchet.js +0 -48
  182. package/dist/cjs/lang/key-value.js +0 -6
  183. package/dist/cjs/lang/last-success-provider.js +0 -2
  184. package/dist/cjs/lang/map-ratchet.js +0 -168
  185. package/dist/cjs/lang/no.js +0 -8
  186. package/dist/cjs/lang/number-ratchet.js +0 -159
  187. package/dist/cjs/lang/parsed-url.js +0 -2
  188. package/dist/cjs/lang/promise-ratchet.js +0 -142
  189. package/dist/cjs/lang/require-ratchet.js +0 -60
  190. package/dist/cjs/lang/stop-watch.js +0 -117
  191. package/dist/cjs/lang/string-ratchet.js +0 -195
  192. package/dist/cjs/lang/time-zone-ratchet.js +0 -80
  193. package/dist/cjs/lang/timeout-token.js +0 -19
  194. package/dist/cjs/lang/transform-ratchet.js +0 -70
  195. package/dist/cjs/logger/classic-single-line-log-message-formatter.js +0 -18
  196. package/dist/cjs/logger/log-message-builder.js +0 -51
  197. package/dist/cjs/logger/log-message-format-type.js +0 -9
  198. package/dist/cjs/logger/log-message-formatter.js +0 -2
  199. package/dist/cjs/logger/log-message-processor.js +0 -2
  200. package/dist/cjs/logger/log-message.js +0 -2
  201. package/dist/cjs/logger/log-snapshot.js +0 -2
  202. package/dist/cjs/logger/logger-instance.js +0 -207
  203. package/dist/cjs/logger/logger-level-name.js +0 -12
  204. package/dist/cjs/logger/logger-meta.js +0 -2
  205. package/dist/cjs/logger/logger-options.js +0 -2
  206. package/dist/cjs/logger/logger-output-function.js +0 -9
  207. package/dist/cjs/logger/logger-ring-buffer.js +0 -76
  208. package/dist/cjs/logger/logger-util.js +0 -49
  209. package/dist/cjs/logger/logger.js +0 -139
  210. package/dist/cjs/logger/none-log-message-formatter.js +0 -9
  211. package/dist/cjs/logger/structured-json-log-message-formatter.js +0 -24
  212. package/dist/cjs/network/browser-local-ip-provider.js +0 -25
  213. package/dist/cjs/network/fixed-local-ip-provider.js +0 -12
  214. package/dist/cjs/network/local-ip-provider.js +0 -2
  215. package/dist/cjs/network/network-ratchet.js +0 -106
  216. package/dist/cjs/stream/buffer-writable.js +0 -20
  217. package/dist/cjs/stream/stream-ratchet.js +0 -72
  218. package/dist/cjs/stream/string-writable.js +0 -18
  219. package/dist/cjs/third-party/google/google-recaptcha-ratchet.js +0 -33
  220. package/dist/cjs/third-party/twilio/twilio-ratchet.js +0 -75
  221. package/dist/cjs/transform/built-in-transforms.js +0 -195
  222. package/dist/cjs/transform/transform-rule.js +0 -2
  223. package/dist/cjs/tx/transaction-configuration.js +0 -2
  224. package/dist/cjs/tx/transaction-final-state.js +0 -9
  225. package/dist/cjs/tx/transaction-ratchet.js +0 -80
  226. package/dist/cjs/tx/transaction-result.js +0 -2
  227. package/dist/cjs/tx/transaction-step.js +0 -2
  228. package/dist/es/index.js +0 -71
  229. package/dist/tsconfig.cjs.tsbuildinfo +0 -1
  230. package/dist/tsconfig.es.tsbuildinfo +0 -1
  231. package/dist/tsconfig.types.tsbuildinfo +0 -1
  232. package/dist/types/index.d.ts +0 -74
  233. package/dist/types/jwt/common-jwt-token.d.ts +0 -17
  234. package/dist/types/lang/array-ratchet.d.ts +0 -30
  235. package/dist/types/lang/enum-ratchet.d.ts +0 -12
  236. package/dist/types/lang/last-success-provider.d.ts +0 -4
  237. package/dist/types/lang/promise-ratchet.d.ts +0 -32
  238. package/dist/types/lang/time-zone-ratchet.d.ts +0 -50
  239. package/dist/types/logger/classic-single-line-log-message-formatter.d.ts +0 -6
  240. package/dist/types/logger/none-log-message-formatter.d.ts +0 -6
  241. package/dist/types/logger/structured-json-log-message-formatter.d.ts +0 -6
  242. package/dist/types/network/local-ip-provider.d.ts +0 -4
  243. /package/{dist/es → lib}/2d/line-2d.js +0 -0
  244. /package/{dist/types → lib}/2d/plane-2d.d.ts +0 -0
  245. /package/{dist/es → lib}/2d/plane-2d.js +0 -0
  246. /package/{dist/types → lib}/2d/point-2d.d.ts +0 -0
  247. /package/{dist/es → lib}/2d/point-2d.js +0 -0
  248. /package/{dist/es → lib}/2d/poly-line-2d.js +0 -0
  249. /package/{dist/es/build/build-information.js → lib/2d/ratchet-2d.spec.d.ts} +0 -0
  250. /package/{dist/types → lib}/build/build-information.d.ts +0 -0
  251. /package/{dist/es/histogram/histogram-entry.js → lib/build/build-information.js} +0 -0
  252. /package/{dist/es → lib}/build/ratchet-common-info.js +0 -0
  253. /package/{dist/types → lib}/histogram/histogram-entry.d.ts +0 -0
  254. /package/{dist/es/jwt/common-jwt-token.js → lib/histogram/histogram-entry.js} +0 -0
  255. /package/{dist/es/jwt/jwt-ratchet-like.js → lib/histogram/histogram.spec.d.ts} +0 -0
  256. /package/{dist/es/jwt/jwt-token-base.js → lib/index.d.ts} +0 -0
  257. /package/{dist/es/lang/last-success-provider.js → lib/index.js} +0 -0
  258. /package/{dist/es/lang/parsed-url.js → lib/jwt/common-jwt-token.js} +0 -0
  259. /package/{dist/types → lib}/jwt/expired-jwt-handling.d.ts +0 -0
  260. /package/{dist/es → lib}/jwt/expired-jwt-handling.js +0 -0
  261. /package/{dist/es/logger/log-message-formatter.js → lib/jwt/jwt-ratchet-like.js} +0 -0
  262. /package/{dist/es/logger/log-message-processor.js → lib/jwt/jwt-ratchet.spec.d.ts} +0 -0
  263. /package/{dist/es/logger/log-message.js → lib/jwt/jwt-token-base.js} +0 -0
  264. /package/{dist/es/logger/log-snapshot.js → lib/lang/array-ratchet.spec.d.ts} +0 -0
  265. /package/{dist/es/logger/logger-meta.js → lib/lang/base64-ratchet.spec.d.ts} +0 -0
  266. /package/{dist/types → lib}/lang/boolean-ratchet.d.ts +0 -0
  267. /package/{dist/es/logger/logger-options.js → lib/lang/boolean-ratchet.spec.d.ts} +0 -0
  268. /package/{dist/es/network/local-ip-provider.js → lib/lang/composite-last-success-provider.spec.d.ts} +0 -0
  269. /package/{dist/types → lib}/lang/date-ratchet.d.ts +0 -0
  270. /package/{dist/es/transform/transform-rule.js → lib/lang/date-ratchet.spec.d.ts} +0 -0
  271. /package/{dist/types → lib}/lang/duration-ratchet.d.ts +0 -0
  272. /package/{dist/es/tx/transaction-configuration.js → lib/lang/duration-ratchet.spec.d.ts} +0 -0
  273. /package/{dist/types → lib}/lang/error-ratchet.d.ts +0 -0
  274. /package/{dist/es/tx/transaction-result.js → lib/lang/error-ratchet.spec.d.ts} +0 -0
  275. /package/{dist/es/tx/transaction-step.js → lib/lang/expiring-object.spec.d.ts} +0 -0
  276. /package/{dist/types → lib}/lang/geolocation-ratchet.d.ts +0 -0
  277. /package/{dist/types → lib}/lang/global-ratchet.d.ts +0 -0
  278. /package/{dist/types → lib}/lang/key-value.d.ts +0 -0
  279. /package/{dist/types → lib}/lang/no.d.ts +0 -0
  280. /package/{dist/es → lib}/lang/no.js +0 -0
  281. /package/{dist/types → lib}/lang/number-ratchet.d.ts +0 -0
  282. /package/{dist/types → lib}/lang/parsed-url.d.ts +0 -0
  283. /package/{dist/types → lib}/lang/require-ratchet.d.ts +0 -0
  284. /package/{dist/types → lib}/lang/string-ratchet.d.ts +0 -0
  285. /package/{dist/es → lib}/logger/classic-single-line-log-message-formatter.js +0 -0
  286. /package/{dist/types → lib}/logger/log-message-format-type.d.ts +0 -0
  287. /package/{dist/es → lib}/logger/log-message-format-type.js +0 -0
  288. /package/{dist/types → lib}/logger/logger-level-name.d.ts +0 -0
  289. /package/{dist/es → lib}/logger/logger-level-name.js +0 -0
  290. /package/{dist/types → lib}/logger/logger-output-function.d.ts +0 -0
  291. /package/{dist/es → lib}/logger/logger-output-function.js +0 -0
  292. /package/{dist/es → lib}/logger/none-log-message-formatter.js +0 -0
  293. /package/{dist/es → lib}/logger/structured-json-log-message-formatter.js +0 -0
  294. /package/{dist/types → lib}/third-party/google/google-recaptcha-ratchet.d.ts +0 -0
  295. /package/{dist/types → lib}/transform/transform-rule.d.ts +0 -0
  296. /package/{dist/types → lib}/tx/transaction-final-state.d.ts +0 -0
  297. /package/{dist/es → lib}/tx/transaction-final-state.js +0 -0
  298. /package/{dist/types → lib}/tx/transaction-step.d.ts +0 -0
@@ -0,0 +1,12 @@
1
+ import { StringWritable } from './string-writable.js';
2
+ describe('#StringWritable', function () {
3
+ it('should write cumulatively to a string', async () => {
4
+ const sr = new StringWritable();
5
+ const callback = () => {
6
+ };
7
+ sr._write('a', null, callback);
8
+ sr._write('b', null, callback);
9
+ sr._write('c', null, callback);
10
+ expect(sr.value.length).toEqual(3);
11
+ });
12
+ });
@@ -1,7 +1,8 @@
1
- import { Logger } from '../../logger/logger';
2
- import { StringRatchet } from '../../lang/string-ratchet';
1
+ import { Logger } from '../../logger/logger.js';
2
+ import { StringRatchet } from '../../lang/string-ratchet.js';
3
3
  import fetch from 'cross-fetch';
4
4
  export class GoogleRecaptchaRatchet {
5
+ static GOOGLE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify?secret={{KEY}}&response={{TOKEN}}';
5
6
  static async verifyRecaptchaToken(keySecret, token, fetchFn = fetch) {
6
7
  Logger.debug('Verifying recaptcha token : %s', token);
7
8
  let rval = null;
@@ -25,4 +26,3 @@ export class GoogleRecaptchaRatchet {
25
26
  return rval;
26
27
  }
27
28
  }
28
- GoogleRecaptchaRatchet.GOOGLE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify?secret={{KEY}}&response={{TOKEN}}';
@@ -0,0 +1,20 @@
1
+ import { GoogleRecaptchaRatchet } from './google-recaptcha-ratchet.js';
2
+ import { jest } from '@jest/globals';
3
+ const fakeFetch = jest.fn((input, init) => Promise.resolve({
4
+ json: () => Promise.resolve({ success: true }),
5
+ }));
6
+ const fakeFailFetch = jest.fn((input, init) => Promise.reject('Failed to read'));
7
+ describe('#googleRecaptchaService', () => {
8
+ it('should validate a recaptcha token', async () => {
9
+ const res = await GoogleRecaptchaRatchet.verifyRecaptchaToken('anykey', 'anytoken', fakeFetch);
10
+ expect(res).toBeTruthy();
11
+ });
12
+ it('should fail with no token', async () => {
13
+ const res = await GoogleRecaptchaRatchet.verifyRecaptchaToken('anykey', null, fakeFetch);
14
+ expect(res).toBeFalsy();
15
+ });
16
+ it('should fail if http fails', async () => {
17
+ const res = await GoogleRecaptchaRatchet.verifyRecaptchaToken('anykey', 'anytoken', fakeFailFetch);
18
+ expect(res).toBeFalsy();
19
+ });
20
+ });
@@ -1,7 +1,3 @@
1
- /**
2
- * This class is for people who just need to send an occasionaly outbound text message and don't need
3
- * Twilio's 7mb non-tree-shakable library
4
- */
5
1
  export declare class TwilioRatchet {
6
2
  private accountSid;
7
3
  private authToken;
@@ -1,9 +1,13 @@
1
1
  import fetch from 'cross-fetch';
2
- import { RequireRatchet } from '../../lang/require-ratchet';
3
- import { Base64Ratchet } from '../../lang/base64-ratchet';
4
- import { StringRatchet } from '../../lang/string-ratchet';
5
- import { Logger } from '../../logger/logger';
2
+ import { RequireRatchet } from '../../lang/require-ratchet.js';
3
+ import { Base64Ratchet } from '../../lang/base64-ratchet.js';
4
+ import { StringRatchet } from '../../lang/string-ratchet.js';
5
+ import { Logger } from '../../logger/logger.js';
6
6
  export class TwilioRatchet {
7
+ accountSid;
8
+ authToken;
9
+ outBoundNumber;
10
+ static TWILLIO_BASE_API_URL = 'https://api.twilio.com/2010-04-01';
7
11
  constructor(accountSid, authToken, outBoundNumber) {
8
12
  this.accountSid = accountSid;
9
13
  this.authToken = authToken;
@@ -67,4 +71,3 @@ export class TwilioRatchet {
67
71
  return /^\+?[1-9]\d{1,14}$/.test(num);
68
72
  }
69
73
  }
70
- TwilioRatchet.TWILLIO_BASE_API_URL = 'https://api.twilio.com/2010-04-01';
@@ -1,4 +1,4 @@
1
- import { TransformRule } from './transform-rule';
1
+ import { TransformRule } from './transform-rule.js';
2
2
  export declare class BuiltInTransforms {
3
3
  static keysOnly(rule: TransformRule): TransformRule;
4
4
  static valuesOnly(rule: TransformRule): TransformRule;
@@ -1,5 +1,5 @@
1
- import { Logger } from '../logger/logger';
2
- import { NumberRatchet } from '../lang/number-ratchet';
1
+ import { Logger } from '../logger/logger.js';
2
+ import { NumberRatchet } from '../lang/number-ratchet.js';
3
3
  import { DateTime } from 'luxon';
4
4
  export class BuiltInTransforms {
5
5
  static keysOnly(rule) {
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
- import { TransactionResult } from './transaction-result';
2
- import { LoggerLevelName } from '../logger/logger-level-name';
1
+ import { TransactionResult } from './transaction-result.js';
2
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
3
3
  export interface TransactionConfiguration<T> {
4
4
  stepLogLevel?: LoggerLevelName;
5
5
  executeAfterRollback?(result: TransactionResult<T>): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { TransactionStep } from './transaction-step';
2
- import { TransactionResult } from './transaction-result';
3
- import { TransactionConfiguration } from './transaction-configuration';
1
+ import { TransactionStep } from './transaction-step.js';
2
+ import { TransactionResult } from './transaction-result.js';
3
+ import { TransactionConfiguration } from './transaction-configuration.js';
4
4
  export declare class TransactionRatchet {
5
5
  static execute<T>(steps: TransactionStep<T>[], initialContext: T, inConfiguration?: TransactionConfiguration<T>): Promise<TransactionResult<T>>;
6
6
  }
@@ -1,7 +1,7 @@
1
- import { Logger } from '../logger/logger';
2
- import { RequireRatchet } from '../lang/require-ratchet';
3
- import { LoggerLevelName } from '../logger/logger-level-name';
4
- import { TransactionFinalState } from './transaction-final-state';
1
+ import { Logger } from '../logger/logger.js';
2
+ import { RequireRatchet } from '../lang/require-ratchet.js';
3
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
4
+ import { TransactionFinalState } from './transaction-final-state.js';
5
5
  export class TransactionRatchet {
6
6
  static async execute(steps, initialContext, inConfiguration) {
7
7
  RequireRatchet.notNullOrUndefined(steps, 'steps');
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,130 @@
1
+ import { TransactionRatchet } from './transaction-ratchet.js';
2
+ import { TransactionFinalState } from './transaction-final-state.js';
3
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
4
+ class TestTransactionStep {
5
+ async execute(context, stepNumber) {
6
+ context.runningTotal += stepNumber;
7
+ if (stepNumber === context?.failStep) {
8
+ throw new Error('Forced error at step ' + stepNumber);
9
+ }
10
+ }
11
+ async rollback(context, stepNumber) {
12
+ context.runningTotal -= stepNumber;
13
+ if (stepNumber === context?.failRollbackStep) {
14
+ throw new Error('Forced rollback error at step ' + stepNumber);
15
+ }
16
+ }
17
+ }
18
+ describe('#TransactionRatchet.execute', function () {
19
+ it('should return the right value when it executes successfully', async () => {
20
+ const steps = [new TestTransactionStep(), new TestTransactionStep(), new TestTransactionStep()];
21
+ const ctx = { runningTotal: 0 };
22
+ const result = await TransactionRatchet.execute(steps, ctx);
23
+ expect(result).not.toBeNull();
24
+ expect(result.error).toBeUndefined();
25
+ expect(result.finalState).toEqual(TransactionFinalState.Success);
26
+ expect(result.finalContext.runningTotal).toEqual(3);
27
+ });
28
+ it('should return the right value when it rolls back successfully fail step 2', async () => {
29
+ const steps = [new TestTransactionStep(), new TestTransactionStep(), new TestTransactionStep()];
30
+ const ctx = { runningTotal: 0, failStep: 2 };
31
+ const result = await TransactionRatchet.execute(steps, ctx);
32
+ expect(result).not.toBeUndefined();
33
+ expect(result.finalState).toEqual(TransactionFinalState.RolledBack);
34
+ expect(result.errorStep).toEqual(2);
35
+ expect(result.error).not.toBeUndefined();
36
+ expect(result.finalContext.runningTotal).toEqual(0);
37
+ });
38
+ it('should return the right value when it rolls back successfully fail step 1', async () => {
39
+ const steps = [new TestTransactionStep(), new TestTransactionStep(), new TestTransactionStep()];
40
+ const ctx = { runningTotal: 0, failStep: 2 };
41
+ const result = await TransactionRatchet.execute(steps, ctx);
42
+ expect(result).not.toBeUndefined();
43
+ expect(result.finalState).toEqual(TransactionFinalState.RolledBack);
44
+ expect(result.errorStep).toEqual(2);
45
+ expect(result.error).not.toBeUndefined();
46
+ expect(result.finalContext.runningTotal).toEqual(0);
47
+ });
48
+ it('should return the right value the rollback fails', async () => {
49
+ const steps = [new TestTransactionStep(), new TestTransactionStep(), new TestTransactionStep()];
50
+ const ctx = { runningTotal: 0, failStep: 2, failRollbackStep: 1 };
51
+ const result = await TransactionRatchet.execute(steps, ctx);
52
+ expect(result).not.toBeUndefined();
53
+ expect(result.finalState).toEqual(TransactionFinalState.RollbackFailed);
54
+ expect(result.finalContext.runningTotal).toEqual(0);
55
+ expect(result.errorStep).toEqual(2);
56
+ expect(result.rollbackErrorStep).toEqual(1);
57
+ expect(result.error).not.toBeUndefined();
58
+ expect(result.rollbackError).not.toBeUndefined();
59
+ });
60
+ it('should run the post-error handler when a failure happens', async () => {
61
+ const steps = [new TestTransactionStep(), new TestTransactionStep(), new TestTransactionStep()];
62
+ const ctx = { runningTotal: 0, failStep: 2 };
63
+ const result = await TransactionRatchet.execute(steps, ctx, {
64
+ executeAfterRollback: async (res) => {
65
+ res.finalContext.postTxTracker = 1;
66
+ },
67
+ });
68
+ expect(result).not.toBeUndefined();
69
+ expect(result.finalState).toEqual(TransactionFinalState.RolledBack);
70
+ expect(result.errorStep).toEqual(2);
71
+ expect(result.error).not.toBeUndefined();
72
+ expect(result.finalContext.postTxTracker).toEqual(1);
73
+ });
74
+ it('should run both post-error handler when a failure happens in both error and rollback', async () => {
75
+ const steps = [new TestTransactionStep(), new TestTransactionStep(), new TestTransactionStep()];
76
+ const ctx = { runningTotal: 0, failStep: 2, failRollbackStep: 1 };
77
+ const result = await TransactionRatchet.execute(steps, ctx, {
78
+ executeAfterRollback: async (res) => {
79
+ res.finalContext.postTxTracker = 1;
80
+ },
81
+ executeAfterRollbackFailure: async (res) => {
82
+ res.finalContext.postTxTracker += 1;
83
+ },
84
+ });
85
+ expect(result).not.toBeUndefined();
86
+ expect(result.finalState).toEqual(TransactionFinalState.RollbackFailed);
87
+ expect(result.errorStep).toEqual(2);
88
+ expect(result.error).not.toBeUndefined();
89
+ expect(result.finalContext.postTxTracker).toEqual(2);
90
+ });
91
+ it('should still return if a post-tx executor fails', async () => {
92
+ const steps = [new TestTransactionStep(), new TestTransactionStep(), new TestTransactionStep()];
93
+ const ctx = { runningTotal: 0, failStep: 2, failRollbackStep: 1 };
94
+ const result = await TransactionRatchet.execute(steps, ctx, {
95
+ executeAfterRollback: async (res) => {
96
+ res.finalContext.postTxTracker = 1;
97
+ },
98
+ executeAfterRollbackFailure: async (res) => {
99
+ res.finalContext.postTxTracker += 1;
100
+ throw new Error('Forced tracker failure');
101
+ },
102
+ });
103
+ expect(result).not.toBeUndefined();
104
+ expect(result.finalState).toEqual(TransactionFinalState.RollbackFailed);
105
+ expect(result.errorStep).toEqual(2);
106
+ expect(result.error).not.toBeUndefined();
107
+ expect(result.finalContext.postTxTracker).toEqual(2);
108
+ });
109
+ it('should work with transaction configuration that only provides read log level access', async () => {
110
+ const steps = [new TestTransactionStep(), new TestTransactionStep(), new TestTransactionStep()];
111
+ const ctx = { runningTotal: 0, failStep: 2, failRollbackStep: 1 };
112
+ const result = await TransactionRatchet.execute(steps, ctx, {
113
+ get stepLogLevel() {
114
+ return LoggerLevelName.info;
115
+ },
116
+ executeAfterRollback: async (res) => {
117
+ res.finalContext.postTxTracker = 1;
118
+ },
119
+ executeAfterRollbackFailure: async (res) => {
120
+ res.finalContext.postTxTracker += 1;
121
+ throw new Error('Forced tracker failure');
122
+ },
123
+ });
124
+ expect(result).not.toBeUndefined();
125
+ expect(result.finalState).toEqual(TransactionFinalState.RollbackFailed);
126
+ expect(result.errorStep).toEqual(2);
127
+ expect(result.error).not.toBeUndefined();
128
+ expect(result.finalContext.postTxTracker).toEqual(2);
129
+ });
130
+ });
@@ -1,4 +1,4 @@
1
- import { TransactionFinalState } from './transaction-final-state';
1
+ import { TransactionFinalState } from './transaction-final-state.js';
2
2
  export interface TransactionResult<T> {
3
3
  finalContext: T;
4
4
  finalState: TransactionFinalState;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bitblit/ratchet-common",
3
- "version": "4.0.99-alpha",
3
+ "version": "4.0.103-alpha",
4
4
  "description": "Common tools for general use",
5
- "main": "./dist/cjs/index.js",
6
- "module": "./dist/esm/index.js",
7
- "types": "./dist/types/index.d.ts",
5
+ "type": "module",
6
+ "module": "index.js",
8
7
  "files": [
9
- "dist/*"
8
+ "lib/*",
9
+ "bin/*"
10
10
  ],
11
11
  "contributors": [
12
12
  "Christopher Weiss <bitblit@gmail.com>",
@@ -29,16 +29,15 @@
29
29
  "config": {},
30
30
  "scripts": {
31
31
  "watch": "tsc-watch",
32
- "clean": "shx rm -Rf dist",
33
- "test": "jest",
32
+ "clean": "shx rm -Rf lib",
33
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
34
34
  "docs": "typedoc",
35
35
  "lint": "eslint src/**/*.ts",
36
36
  "lint-fix": "eslint --fix src/**/*.ts",
37
- "generate-barrels": "barrelsby -q --delete -d src -e .*\\.spec\\.ts",
38
- "build": "yarn run generate-barrels && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
39
- "build:cjs": "tsc -p tsconfig.cjs.json",
40
- "build:es": "tsc -p tsconfig.es.json",
41
- "build:types": "tsc -p tsconfig.types.json"
37
+ "__generate-barrels": "barrelsby -q --delete -d src -e .*\\.spec\\.ts",
38
+ "__build": "yarn run generate-barrels && tsc",
39
+ "build": "tsc",
40
+ "force-build": "tsc --build --force"
42
41
  },
43
42
  "repository": {
44
43
  "type": "git",
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,250 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Ratchet2d = void 0;
4
- const boolean_ratchet_1 = require("../lang/boolean-ratchet");
5
- class Ratchet2d {
6
- constructor() { }
7
- static translateToOriginVector(points) {
8
- let rval = null;
9
- if (Ratchet2d.validPoints(points)) {
10
- rval = {
11
- x: null,
12
- y: null,
13
- };
14
- points.forEach((p) => {
15
- rval.x = rval.x === null || p.x < rval.x ? p.x : rval.x;
16
- rval.y = rval.y === null || p.y < rval.y ? p.y : rval.y;
17
- });
18
- rval.x *= -1;
19
- rval.y *= -1;
20
- }
21
- return rval;
22
- }
23
- static minimalContainingPlane(points) {
24
- let rval = null;
25
- if (Ratchet2d.validPoints(points)) {
26
- rval = {
27
- width: 0,
28
- height: 0,
29
- };
30
- points.forEach((p) => {
31
- rval.width = Math.max(rval.width, p.x + 1);
32
- rval.height = Math.max(rval.height, p.y + 1);
33
- });
34
- }
35
- return rval;
36
- }
37
- static scaleVector(src, dst) {
38
- let rval = null;
39
- if (Ratchet2d.validPlane(src) && Ratchet2d.validPlane(dst)) {
40
- rval = {
41
- x: dst.width / src.width,
42
- y: dst.height / src.height,
43
- };
44
- }
45
- return rval;
46
- }
47
- static samePoint(p1, p2) {
48
- return !!p1 && !!p2 && p1.x === p2.x && p1.y === p2.y;
49
- }
50
- static atLeastOneDimensionShared(p1, p2) {
51
- return !!p1 && !!p2 && (p1.x === p2.x || p1.y === p2.y);
52
- }
53
- static validPlane(plane) {
54
- return !!plane && !!plane.height && !!plane.width;
55
- }
56
- static validLine(line) {
57
- return !!line && Ratchet2d.validPoint(line.p1) && Ratchet2d.validPoint(line.p2) && !Ratchet2d.samePoint(line.p1, line.p2);
58
- }
59
- static validLines(lines) {
60
- return !!lines && boolean_ratchet_1.BooleanRatchet.allTrue(lines.map((l) => Ratchet2d.validLine(l)));
61
- }
62
- static validPolyLine(pline) {
63
- var _a;
64
- return !!pline && ((_a = pline.pts) === null || _a === void 0 ? void 0 : _a.length) > 1 && boolean_ratchet_1.BooleanRatchet.allTrue(pline.pts.map((p) => Ratchet2d.validPoint(p)));
65
- }
66
- static polyLineToLines(pline) {
67
- let rval = null;
68
- if (Ratchet2d.validPolyLine(pline)) {
69
- rval = [];
70
- for (let i = 1; i < pline.pts.length; i++) {
71
- rval.push({ p1: pline.pts[i - 1], p2: pline.pts[i] });
72
- }
73
- }
74
- return rval;
75
- }
76
- static lastPointOnPolyLine(polyLine) {
77
- return Ratchet2d.validPolyLine(polyLine) ? polyLine.pts[polyLine.pts.length - 1] : null;
78
- }
79
- static lineToPolyLine(line) {
80
- return Ratchet2d.validLine(line) ? { pts: [line.p1, line.p2] } : null;
81
- }
82
- static linesToPolyLines(lines) {
83
- let rval = null;
84
- if (Ratchet2d.validLines(lines)) {
85
- rval = [];
86
- let currentPLine = Ratchet2d.lineToPolyLine(lines[0]);
87
- for (let i = 1; i < lines.length; i++) {
88
- if (Ratchet2d.samePoint(Ratchet2d.lastPointOnPolyLine(currentPLine), lines[i].p1)) {
89
- currentPLine.pts.push(lines[i].p2);
90
- }
91
- else {
92
- rval.push(currentPLine);
93
- currentPLine = Ratchet2d.lineToPolyLine(lines[i]);
94
- }
95
- }
96
- rval.push(currentPLine);
97
- }
98
- return rval;
99
- }
100
- static validPoint(pt) {
101
- return !!pt && pt.x != null && pt.x != undefined && pt.y !== null && pt.y !== undefined;
102
- }
103
- static validPoints(pt) {
104
- return (!!pt &&
105
- boolean_ratchet_1.BooleanRatchet.allTrue(pt.map((p) => Ratchet2d.validPoint(p)), false));
106
- }
107
- static planeContainsPoint(pt, plane) {
108
- return Ratchet2d.validPlane(plane) && Ratchet2d.validPoint(pt) && pt.x >= 0 && pt.x < plane.width && pt.y >= 0 && pt.y < plane.height;
109
- }
110
- static planeContainsPoints(pt, plane) {
111
- return pt && pt.map((p) => Ratchet2d.planeContainsPoint(p, plane)).reduce((a, i) => a && i, true);
112
- }
113
- static linesToPoints(lines) {
114
- let rval = null;
115
- if (Ratchet2d.validLines(lines)) {
116
- rval = lines.map((l) => [l.p1, l.p2]).flat();
117
- }
118
- return rval;
119
- }
120
- static pointsToLines(points) {
121
- let rval = null;
122
- if (Ratchet2d.validPoints(points)) {
123
- if (points.length % 2 == 0) {
124
- rval = [];
125
- for (let i = 0; i < points.length; i += 2) {
126
- rval.push({ p1: points[i], p2: points[i + 1] });
127
- }
128
- }
129
- else {
130
- throw new Error('Cannot convert non-even array of points into lines');
131
- }
132
- }
133
- return rval;
134
- }
135
- static rotateRightAboutOrigin90Degrees(points, times = 1) {
136
- let rval = null;
137
- let translate = { x: 0, y: 0 };
138
- if (Ratchet2d.validPoints(points)) {
139
- rval = Object.assign([], points);
140
- translate = Ratchet2d.translateToOriginVector(rval);
141
- rval = Ratchet2d.translate(rval, translate);
142
- let plane = Ratchet2d.minimalContainingPlane(rval);
143
- rval = Ratchet2d.xToY(rval);
144
- plane = { width: plane.height, height: plane.width };
145
- translate = { x: translate.y * -1, y: translate.x * -1 };
146
- rval = Ratchet2d.mirrorPointsOnPlane(rval, plane, true, false);
147
- rval = Ratchet2d.translate(rval, translate);
148
- }
149
- const timesToRotate = times > 4 ? times % 4 : times;
150
- if (timesToRotate > 1) {
151
- rval = Ratchet2d.rotateRightAboutOrigin90Degrees(rval, timesToRotate - 1);
152
- }
153
- return rval;
154
- }
155
- static planeContainsLines(lines, plane) {
156
- return lines && Ratchet2d.planeContainsPoints(lines.map((l) => [l.p1, l.p2]).flat(), plane);
157
- }
158
- static planeContainsPolyLine(pline, plane) {
159
- return Ratchet2d.planeContainsLines(Ratchet2d.polyLineToLines(pline), plane);
160
- }
161
- static planeContainsLine(line, plane) {
162
- return (Ratchet2d.validPlane(plane) &&
163
- Ratchet2d.validLine(line) &&
164
- Ratchet2d.planeContainsPoint(line.p1, plane) &&
165
- Ratchet2d.planeContainsPoint(line.p2, plane));
166
- }
167
- static xToY(points) {
168
- let rval = null;
169
- if (Ratchet2d.validPoints(points)) {
170
- rval = points.map((p) => {
171
- const next = { x: p.y, y: p.x };
172
- return next;
173
- });
174
- }
175
- return rval;
176
- }
177
- static translate(points, xlate) {
178
- let rval = null;
179
- if (Ratchet2d.validPoints(points) && Ratchet2d.validPoint(xlate)) {
180
- rval = points.map((p) => {
181
- const next = {
182
- x: p.x + xlate.x,
183
- y: p.y + xlate.y,
184
- };
185
- return next;
186
- });
187
- }
188
- return rval;
189
- }
190
- static mirrorPointsOnPlane(points, src, mirrorX, mirrorY) {
191
- let rval = null;
192
- if (Ratchet2d.validPoints(points) && Ratchet2d.validPlane(src)) {
193
- if (mirrorX || mirrorY) {
194
- rval = points.map((p) => {
195
- const next = {
196
- x: mirrorX ? src.width - 1 - p.x : p.x,
197
- y: mirrorY ? src.height - 1 - p.y : p.y,
198
- };
199
- return next;
200
- });
201
- }
202
- else {
203
- rval = Object.assign([], points);
204
- }
205
- }
206
- return rval;
207
- }
208
- static transformPointsToNewPlane(points, src, dst) {
209
- let rval = null;
210
- if (Ratchet2d.validPoints(points) && Ratchet2d.validPlane(src) && Ratchet2d.validPlane(dst)) {
211
- const scale = Ratchet2d.scaleVector(src, dst);
212
- rval = points.map((p) => {
213
- const next = { x: p.x * scale.x, y: p.y * scale.y };
214
- return next;
215
- });
216
- rval = Ratchet2d.mirrorPointsOnPlane(rval, dst, dst.rightToLeft !== src.rightToLeft, dst.topToBottom !== src.topToBottom);
217
- }
218
- return rval;
219
- }
220
- static transformPointToNewPlane(point, src, dst) {
221
- const tmp = Ratchet2d.transformPointsToNewPlane([point], src, dst);
222
- return tmp.length === 1 ? tmp[0] : null;
223
- }
224
- static transformLines(lines, src, dst) {
225
- return null;
226
- }
227
- static fitCurve(curveDef, inputX) {
228
- curveDef.sort((a, b) => {
229
- return a.x - b.x;
230
- });
231
- if (inputX <= curveDef[0].x) {
232
- return curveDef[0].y;
233
- }
234
- else if (inputX >= curveDef[curveDef.length - 1].x) {
235
- return curveDef[curveDef.length - 1].y;
236
- }
237
- else {
238
- let idx = 0;
239
- while (curveDef[idx + 1].x < inputX) {
240
- idx++;
241
- }
242
- const xSpread = curveDef[idx + 1].x - curveDef[idx].x;
243
- const ySpread = curveDef[idx + 1].y - curveDef[idx].y;
244
- const pct = (inputX - curveDef[idx].x) / xSpread;
245
- const yAdd = pct * ySpread;
246
- return curveDef[idx].y + yAdd;
247
- }
248
- }
249
- }
250
- exports.Ratchet2d = Ratchet2d;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RatchetInfo = void 0;
4
- class RatchetInfo {
5
- constructor() { }
6
- static buildInformation() {
7
- const val = {
8
- version: 'LOCAL-SNAPSHOT',
9
- hash: 'LOCAL-HASH',
10
- branch: 'LOCAL-BRANCH',
11
- tag: 'LOCAL-TAG',
12
- timeBuiltISO: 'LOCAL-TIME-ISO',
13
- notes: 'LOCAL-NOTES',
14
- };
15
- return val;
16
- }
17
- }
18
- exports.RatchetInfo = RatchetInfo;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });