track-cli 3.0.0-rc

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 (224) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +3 -0
  3. package/esm/_dnt.polyfills.d.ts +6 -0
  4. package/esm/_dnt.polyfills.js +1 -0
  5. package/esm/_dnt.shims.d.ts +19 -0
  6. package/esm/_dnt.shims.js +78 -0
  7. package/esm/deps/deno.land/std@0.170.0/fmt/colors.d.ts +270 -0
  8. package/esm/deps/deno.land/std@0.170.0/fmt/colors.js +473 -0
  9. package/esm/deps/deno.land/std@0.195.0/_util/os.d.ts +4 -0
  10. package/esm/deps/deno.land/std@0.195.0/_util/os.js +18 -0
  11. package/esm/deps/deno.land/std@0.195.0/assert/assert.d.ts +2 -0
  12. package/esm/deps/deno.land/std@0.195.0/assert/assert.js +8 -0
  13. package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.d.ts +4 -0
  14. package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.js +12 -0
  15. package/esm/deps/deno.land/std@0.195.0/datetime/_common.d.ts +50 -0
  16. package/esm/deps/deno.land/std@0.195.0/datetime/_common.js +545 -0
  17. package/esm/deps/deno.land/std@0.195.0/datetime/constants.d.ts +55 -0
  18. package/esm/deps/deno.land/std@0.195.0/datetime/constants.js +57 -0
  19. package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.d.ts +26 -0
  20. package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.js +45 -0
  21. package/esm/deps/deno.land/std@0.195.0/datetime/difference.d.ts +38 -0
  22. package/esm/deps/deno.land/std@0.195.0/datetime/difference.js +93 -0
  23. package/esm/deps/deno.land/std@0.195.0/datetime/format.d.ts +22 -0
  24. package/esm/deps/deno.land/std@0.195.0/datetime/format.js +28 -0
  25. package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.d.ts +49 -0
  26. package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.js +60 -0
  27. package/esm/deps/deno.land/std@0.195.0/datetime/mod.d.ts +43 -0
  28. package/esm/deps/deno.land/std@0.195.0/datetime/mod.js +45 -0
  29. package/esm/deps/deno.land/std@0.195.0/datetime/parse.d.ts +21 -0
  30. package/esm/deps/deno.land/std@0.195.0/datetime/parse.js +29 -0
  31. package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.d.ts +17 -0
  32. package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.js +44 -0
  33. package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.d.ts +13 -0
  34. package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.js +38 -0
  35. package/esm/deps/deno.land/std@0.195.0/fmt/colors.d.ts +270 -0
  36. package/esm/deps/deno.land/std@0.195.0/fmt/colors.js +474 -0
  37. package/esm/deps/deno.land/std@0.195.0/fmt/duration.d.ts +15 -0
  38. package/esm/deps/deno.land/std@0.195.0/fmt/duration.js +96 -0
  39. package/esm/deps/deno.land/std@0.195.0/fs/_util.d.ts +35 -0
  40. package/esm/deps/deno.land/std@0.195.0/fs/_util.js +80 -0
  41. package/esm/deps/deno.land/std@0.195.0/fs/copy.d.ts +51 -0
  42. package/esm/deps/deno.land/std@0.195.0/fs/copy.js +244 -0
  43. package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.d.ts +31 -0
  44. package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.js +74 -0
  45. package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.d.ts +27 -0
  46. package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.js +55 -0
  47. package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.d.ts +33 -0
  48. package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.js +75 -0
  49. package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.d.ts +31 -0
  50. package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.js +43 -0
  51. package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.d.ts +17 -0
  52. package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.js +68 -0
  53. package/esm/deps/deno.land/std@0.195.0/fs/eol.d.ts +40 -0
  54. package/esm/deps/deno.land/std@0.195.0/fs/eol.js +53 -0
  55. package/esm/deps/deno.land/std@0.195.0/fs/exists.d.ts +102 -0
  56. package/esm/deps/deno.land/std@0.195.0/fs/exists.js +163 -0
  57. package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.d.ts +37 -0
  58. package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.js +216 -0
  59. package/esm/deps/deno.land/std@0.195.0/fs/mod.d.ts +16 -0
  60. package/esm/deps/deno.land/std@0.195.0/fs/mod.js +17 -0
  61. package/esm/deps/deno.land/std@0.195.0/fs/move.d.ts +29 -0
  62. package/esm/deps/deno.land/std@0.195.0/fs/move.js +88 -0
  63. package/esm/deps/deno.land/std@0.195.0/fs/walk.d.ts +40 -0
  64. package/esm/deps/deno.land/std@0.195.0/fs/walk.js +158 -0
  65. package/esm/deps/deno.land/std@0.195.0/path/_constants.d.ts +39 -0
  66. package/esm/deps/deno.land/std@0.195.0/path/_constants.js +46 -0
  67. package/esm/deps/deno.land/std@0.195.0/path/_interface.d.ts +26 -0
  68. package/esm/deps/deno.land/std@0.195.0/path/_interface.js +3 -0
  69. package/esm/deps/deno.land/std@0.195.0/path/_util.d.ts +11 -0
  70. package/esm/deps/deno.land/std@0.195.0/path/_util.js +161 -0
  71. package/esm/deps/deno.land/std@0.195.0/path/common.d.ts +13 -0
  72. package/esm/deps/deno.land/std@0.195.0/path/common.js +36 -0
  73. package/esm/deps/deno.land/std@0.195.0/path/glob.d.ts +83 -0
  74. package/esm/deps/deno.land/std@0.195.0/path/glob.js +361 -0
  75. package/esm/deps/deno.land/std@0.195.0/path/mod.d.ts +9 -0
  76. package/esm/deps/deno.land/std@0.195.0/path/mod.js +33 -0
  77. package/esm/deps/deno.land/std@0.195.0/path/posix.d.ts +86 -0
  78. package/esm/deps/deno.land/std@0.195.0/path/posix.js +442 -0
  79. package/esm/deps/deno.land/std@0.195.0/path/separator.d.ts +2 -0
  80. package/esm/deps/deno.land/std@0.195.0/path/separator.js +5 -0
  81. package/esm/deps/deno.land/std@0.195.0/path/win32.d.ts +91 -0
  82. package/esm/deps/deno.land/std@0.195.0/path/win32.js +909 -0
  83. package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.d.ts +1 -0
  84. package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.js +26 -0
  85. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.d.ts +76 -0
  86. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.js +154 -0
  87. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.d.ts +32 -0
  88. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.js +105 -0
  89. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.d.ts +831 -0
  90. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.js +1701 -0
  91. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.d.ts +17 -0
  92. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.js +201 -0
  93. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.d.ts +14 -0
  94. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.js +141 -0
  95. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.d.ts +21 -0
  96. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.js +285 -0
  97. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.d.ts +6 -0
  98. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.js +38 -0
  99. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.d.ts +8 -0
  100. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.js +32 -0
  101. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.d.ts +6 -0
  102. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.js +38 -0
  103. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.d.ts +6 -0
  104. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.js +46 -0
  105. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.d.ts +6 -0
  106. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.js +38 -0
  107. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.d.ts +45 -0
  108. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.js +2 -0
  109. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.d.ts +1 -0
  110. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.js +1 -0
  111. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.d.ts +27 -0
  112. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.js +323 -0
  113. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.d.ts +6 -0
  114. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.js +34 -0
  115. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.d.ts +18 -0
  116. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.js +17 -0
  117. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.d.ts +41 -0
  118. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.js +24 -0
  119. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.d.ts +9 -0
  120. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.js +20 -0
  121. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.d.ts +9 -0
  122. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.js +13 -0
  123. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.d.ts +9 -0
  124. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.js +27 -0
  125. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.d.ts +7 -0
  126. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.js +9 -0
  127. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.d.ts +10 -0
  128. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.js +29 -0
  129. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.d.ts +5 -0
  130. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.js +12 -0
  131. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.d.ts +7 -0
  132. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.js +9 -0
  133. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.d.ts +7 -0
  134. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.js +9 -0
  135. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.d.ts +7 -0
  136. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.js +9 -0
  137. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.d.ts +118 -0
  138. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.js +2 -0
  139. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.d.ts +5 -0
  140. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.js +5 -0
  141. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.d.ts +14 -0
  142. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.js +46 -0
  143. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.d.ts +26 -0
  144. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.js +118 -0
  145. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.d.ts +14 -0
  146. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.js +55 -0
  147. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.d.ts +27 -0
  148. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.js +102 -0
  149. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.d.ts +17 -0
  150. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.js +75 -0
  151. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.d.ts +60 -0
  152. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.js +117 -0
  153. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.d.ts +18 -0
  154. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.js +106 -0
  155. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.d.ts +10 -0
  156. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.js +157 -0
  157. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.d.ts +24 -0
  158. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.js +9 -0
  159. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.d.ts +33 -0
  160. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.js +402 -0
  161. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.d.ts +3 -0
  162. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.js +11 -0
  163. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.d.ts +3 -0
  164. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.js +9 -0
  165. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.d.ts +3 -0
  166. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.js +9 -0
  167. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.d.ts +3 -0
  168. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.js +4 -0
  169. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.d.ts +59 -0
  170. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.js +1 -0
  171. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.d.ts +20 -0
  172. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.js +18 -0
  173. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.d.ts +78 -0
  174. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.js +128 -0
  175. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.d.ts +1 -0
  176. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.js +1 -0
  177. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.d.ts +99 -0
  178. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.js +529 -0
  179. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.d.ts +49 -0
  180. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.js +74 -0
  181. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.d.ts +135 -0
  182. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.js +237 -0
  183. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.d.ts +13 -0
  184. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.js +60 -0
  185. package/esm/package.json +3 -0
  186. package/esm/src/action/add.d.ts +1 -0
  187. package/esm/src/action/add.js +57 -0
  188. package/esm/src/action/clone.d.ts +6 -0
  189. package/esm/src/action/clone.js +108 -0
  190. package/esm/src/action/lang.d.ts +1 -0
  191. package/esm/src/action/lang.js +40 -0
  192. package/esm/src/action/pull.d.ts +1 -0
  193. package/esm/src/action/pull.js +22 -0
  194. package/esm/src/action/remove.d.ts +4 -0
  195. package/esm/src/action/remove.js +67 -0
  196. package/esm/src/action/reset.d.ts +1 -0
  197. package/esm/src/action/reset.js +21 -0
  198. package/esm/src/action/run.d.ts +4 -0
  199. package/esm/src/action/run.js +163 -0
  200. package/esm/src/action/status.d.ts +1 -0
  201. package/esm/src/action/status.js +5 -0
  202. package/esm/src/main.d.ts +2 -0
  203. package/esm/src/main.js +96 -0
  204. package/esm/src/meta.d.ts +3 -0
  205. package/esm/src/meta.js +51 -0
  206. package/esm/src/orca/client.d.ts +20 -0
  207. package/esm/src/orca/client.js +152 -0
  208. package/esm/src/orca/types.d.ts +54 -0
  209. package/esm/src/orca/types.js +12 -0
  210. package/esm/src/shared/config.d.ts +24 -0
  211. package/esm/src/shared/config.js +24 -0
  212. package/esm/src/shared/errors.d.ts +82 -0
  213. package/esm/src/shared/errors.js +228 -0
  214. package/esm/src/shared/file.d.ts +30 -0
  215. package/esm/src/shared/file.js +110 -0
  216. package/esm/src/shared/mod.d.ts +40 -0
  217. package/esm/src/shared/mod.js +383 -0
  218. package/esm/src/shared/types.d.ts +12 -0
  219. package/esm/src/shared/types.js +1 -0
  220. package/esm/src/track/client.d.ts +60 -0
  221. package/esm/src/track/client.js +268 -0
  222. package/esm/src/track/types.d.ts +210 -0
  223. package/esm/src/track/types.js +40 -0
  224. package/package.json +35 -0
@@ -0,0 +1,545 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4
+ if (kind === "m") throw new TypeError("Private method is not writable");
5
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
7
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8
+ };
9
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
12
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13
+ };
14
+ var _DateTimeFormatter_format;
15
+ export class Tokenizer {
16
+ constructor(rules = []) {
17
+ Object.defineProperty(this, "rules", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ this.rules = rules;
24
+ }
25
+ addRule(test, fn) {
26
+ this.rules.push({ test, fn });
27
+ return this;
28
+ }
29
+ tokenize(string, receiver = (token) => token) {
30
+ function* generator(rules) {
31
+ let index = 0;
32
+ for (const rule of rules) {
33
+ const result = rule.test(string);
34
+ if (result) {
35
+ const { value, length } = result;
36
+ index += length;
37
+ string = string.slice(length);
38
+ const token = { ...rule.fn(value), index };
39
+ yield receiver(token);
40
+ yield* generator(rules);
41
+ }
42
+ }
43
+ }
44
+ const tokenGenerator = generator(this.rules);
45
+ const tokens = [];
46
+ for (const token of tokenGenerator) {
47
+ tokens.push(token);
48
+ }
49
+ if (string.length) {
50
+ throw new Error(`parser error: string not fully parsed! ${string.slice(0, 25)}`);
51
+ }
52
+ return tokens;
53
+ }
54
+ }
55
+ function digits(value, count = 2) {
56
+ return String(value).padStart(count, "0");
57
+ }
58
+ function createLiteralTestFunction(value) {
59
+ return (string) => {
60
+ return string.startsWith(value)
61
+ ? { value, length: value.length }
62
+ : undefined;
63
+ };
64
+ }
65
+ function createMatchTestFunction(match) {
66
+ return (string) => {
67
+ const result = match.exec(string);
68
+ if (result)
69
+ return { value: result, length: result[0].length };
70
+ };
71
+ }
72
+ // according to unicode symbols (http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table)
73
+ const defaultRules = [
74
+ {
75
+ test: createLiteralTestFunction("yyyy"),
76
+ fn: () => ({ type: "year", value: "numeric" }),
77
+ },
78
+ {
79
+ test: createLiteralTestFunction("yy"),
80
+ fn: () => ({ type: "year", value: "2-digit" }),
81
+ },
82
+ {
83
+ test: createLiteralTestFunction("MM"),
84
+ fn: () => ({ type: "month", value: "2-digit" }),
85
+ },
86
+ {
87
+ test: createLiteralTestFunction("M"),
88
+ fn: () => ({ type: "month", value: "numeric" }),
89
+ },
90
+ {
91
+ test: createLiteralTestFunction("dd"),
92
+ fn: () => ({ type: "day", value: "2-digit" }),
93
+ },
94
+ {
95
+ test: createLiteralTestFunction("d"),
96
+ fn: () => ({ type: "day", value: "numeric" }),
97
+ },
98
+ {
99
+ test: createLiteralTestFunction("HH"),
100
+ fn: () => ({ type: "hour", value: "2-digit" }),
101
+ },
102
+ {
103
+ test: createLiteralTestFunction("H"),
104
+ fn: () => ({ type: "hour", value: "numeric" }),
105
+ },
106
+ {
107
+ test: createLiteralTestFunction("hh"),
108
+ fn: () => ({
109
+ type: "hour",
110
+ value: "2-digit",
111
+ hour12: true,
112
+ }),
113
+ },
114
+ {
115
+ test: createLiteralTestFunction("h"),
116
+ fn: () => ({
117
+ type: "hour",
118
+ value: "numeric",
119
+ hour12: true,
120
+ }),
121
+ },
122
+ {
123
+ test: createLiteralTestFunction("mm"),
124
+ fn: () => ({ type: "minute", value: "2-digit" }),
125
+ },
126
+ {
127
+ test: createLiteralTestFunction("m"),
128
+ fn: () => ({ type: "minute", value: "numeric" }),
129
+ },
130
+ {
131
+ test: createLiteralTestFunction("ss"),
132
+ fn: () => ({ type: "second", value: "2-digit" }),
133
+ },
134
+ {
135
+ test: createLiteralTestFunction("s"),
136
+ fn: () => ({ type: "second", value: "numeric" }),
137
+ },
138
+ {
139
+ test: createLiteralTestFunction("SSS"),
140
+ fn: () => ({ type: "fractionalSecond", value: 3 }),
141
+ },
142
+ {
143
+ test: createLiteralTestFunction("SS"),
144
+ fn: () => ({ type: "fractionalSecond", value: 2 }),
145
+ },
146
+ {
147
+ test: createLiteralTestFunction("S"),
148
+ fn: () => ({ type: "fractionalSecond", value: 1 }),
149
+ },
150
+ {
151
+ test: createLiteralTestFunction("a"),
152
+ fn: (value) => ({
153
+ type: "dayPeriod",
154
+ value: value,
155
+ }),
156
+ },
157
+ // quoted literal
158
+ {
159
+ test: createMatchTestFunction(/^(')(?<value>\\.|[^\']*)\1/),
160
+ fn: (match) => ({
161
+ type: "literal",
162
+ value: match.groups.value,
163
+ }),
164
+ },
165
+ // literal
166
+ {
167
+ test: createMatchTestFunction(/^.+?\s*/),
168
+ fn: (match) => ({
169
+ type: "literal",
170
+ value: match[0],
171
+ }),
172
+ },
173
+ ];
174
+ export class DateTimeFormatter {
175
+ constructor(formatString, rules = defaultRules) {
176
+ _DateTimeFormatter_format.set(this, void 0);
177
+ const tokenizer = new Tokenizer(rules);
178
+ __classPrivateFieldSet(this, _DateTimeFormatter_format, tokenizer.tokenize(formatString, ({ type, value, hour12 }) => {
179
+ const result = {
180
+ type,
181
+ value,
182
+ };
183
+ if (hour12)
184
+ result.hour12 = hour12;
185
+ return result;
186
+ }), "f");
187
+ }
188
+ format(date, options = {}) {
189
+ let string = "";
190
+ const utc = options.timeZone === "UTC";
191
+ for (const token of __classPrivateFieldGet(this, _DateTimeFormatter_format, "f")) {
192
+ const type = token.type;
193
+ switch (type) {
194
+ case "year": {
195
+ const value = utc ? date.getUTCFullYear() : date.getFullYear();
196
+ switch (token.value) {
197
+ case "numeric": {
198
+ string += value;
199
+ break;
200
+ }
201
+ case "2-digit": {
202
+ string += digits(value, 2).slice(-2);
203
+ break;
204
+ }
205
+ default:
206
+ throw Error(`FormatterError: value "${token.value}" is not supported`);
207
+ }
208
+ break;
209
+ }
210
+ case "month": {
211
+ const value = (utc ? date.getUTCMonth() : date.getMonth()) + 1;
212
+ switch (token.value) {
213
+ case "numeric": {
214
+ string += value;
215
+ break;
216
+ }
217
+ case "2-digit": {
218
+ string += digits(value, 2);
219
+ break;
220
+ }
221
+ default:
222
+ throw Error(`FormatterError: value "${token.value}" is not supported`);
223
+ }
224
+ break;
225
+ }
226
+ case "day": {
227
+ const value = utc ? date.getUTCDate() : date.getDate();
228
+ switch (token.value) {
229
+ case "numeric": {
230
+ string += value;
231
+ break;
232
+ }
233
+ case "2-digit": {
234
+ string += digits(value, 2);
235
+ break;
236
+ }
237
+ default:
238
+ throw Error(`FormatterError: value "${token.value}" is not supported`);
239
+ }
240
+ break;
241
+ }
242
+ case "hour": {
243
+ let value = utc ? date.getUTCHours() : date.getHours();
244
+ value -= token.hour12 && date.getHours() > 12 ? 12 : 0;
245
+ switch (token.value) {
246
+ case "numeric": {
247
+ string += value;
248
+ break;
249
+ }
250
+ case "2-digit": {
251
+ string += digits(value, 2);
252
+ break;
253
+ }
254
+ default:
255
+ throw Error(`FormatterError: value "${token.value}" is not supported`);
256
+ }
257
+ break;
258
+ }
259
+ case "minute": {
260
+ const value = utc ? date.getUTCMinutes() : date.getMinutes();
261
+ switch (token.value) {
262
+ case "numeric": {
263
+ string += value;
264
+ break;
265
+ }
266
+ case "2-digit": {
267
+ string += digits(value, 2);
268
+ break;
269
+ }
270
+ default:
271
+ throw Error(`FormatterError: value "${token.value}" is not supported`);
272
+ }
273
+ break;
274
+ }
275
+ case "second": {
276
+ const value = utc ? date.getUTCSeconds() : date.getSeconds();
277
+ switch (token.value) {
278
+ case "numeric": {
279
+ string += value;
280
+ break;
281
+ }
282
+ case "2-digit": {
283
+ string += digits(value, 2);
284
+ break;
285
+ }
286
+ default:
287
+ throw Error(`FormatterError: value "${token.value}" is not supported`);
288
+ }
289
+ break;
290
+ }
291
+ case "fractionalSecond": {
292
+ const value = utc
293
+ ? date.getUTCMilliseconds()
294
+ : date.getMilliseconds();
295
+ string += digits(value, Number(token.value));
296
+ break;
297
+ }
298
+ // FIXME(bartlomieju)
299
+ case "timeZoneName": {
300
+ // string += utc ? "Z" : token.value
301
+ break;
302
+ }
303
+ case "dayPeriod": {
304
+ string += token.value ? (date.getHours() >= 12 ? "PM" : "AM") : "";
305
+ break;
306
+ }
307
+ case "literal": {
308
+ string += token.value;
309
+ break;
310
+ }
311
+ default:
312
+ throw Error(`FormatterError: { ${token.type} ${token.value} }`);
313
+ }
314
+ }
315
+ return string;
316
+ }
317
+ parseToParts(string) {
318
+ const parts = [];
319
+ for (const token of __classPrivateFieldGet(this, _DateTimeFormatter_format, "f")) {
320
+ const type = token.type;
321
+ let value = "";
322
+ switch (token.type) {
323
+ case "year": {
324
+ switch (token.value) {
325
+ case "numeric": {
326
+ value = /^\d{1,4}/.exec(string)?.[0];
327
+ break;
328
+ }
329
+ case "2-digit": {
330
+ value = /^\d{1,2}/.exec(string)?.[0];
331
+ break;
332
+ }
333
+ }
334
+ break;
335
+ }
336
+ case "month": {
337
+ switch (token.value) {
338
+ case "numeric": {
339
+ value = /^\d{1,2}/.exec(string)?.[0];
340
+ break;
341
+ }
342
+ case "2-digit": {
343
+ value = /^\d{2}/.exec(string)?.[0];
344
+ break;
345
+ }
346
+ case "narrow": {
347
+ value = /^[a-zA-Z]+/.exec(string)?.[0];
348
+ break;
349
+ }
350
+ case "short": {
351
+ value = /^[a-zA-Z]+/.exec(string)?.[0];
352
+ break;
353
+ }
354
+ case "long": {
355
+ value = /^[a-zA-Z]+/.exec(string)?.[0];
356
+ break;
357
+ }
358
+ default:
359
+ throw Error(`ParserError: value "${token.value}" is not supported`);
360
+ }
361
+ break;
362
+ }
363
+ case "day": {
364
+ switch (token.value) {
365
+ case "numeric": {
366
+ value = /^\d{1,2}/.exec(string)?.[0];
367
+ break;
368
+ }
369
+ case "2-digit": {
370
+ value = /^\d{2}/.exec(string)?.[0];
371
+ break;
372
+ }
373
+ default:
374
+ throw Error(`ParserError: value "${token.value}" is not supported`);
375
+ }
376
+ break;
377
+ }
378
+ case "hour": {
379
+ switch (token.value) {
380
+ case "numeric": {
381
+ value = /^\d{1,2}/.exec(string)?.[0];
382
+ if (token.hour12 && parseInt(value) > 12) {
383
+ console.error(`Trying to parse hour greater than 12. Use 'H' instead of 'h'.`);
384
+ }
385
+ break;
386
+ }
387
+ case "2-digit": {
388
+ value = /^\d{2}/.exec(string)?.[0];
389
+ if (token.hour12 && parseInt(value) > 12) {
390
+ console.error(`Trying to parse hour greater than 12. Use 'HH' instead of 'hh'.`);
391
+ }
392
+ break;
393
+ }
394
+ default:
395
+ throw Error(`ParserError: value "${token.value}" is not supported`);
396
+ }
397
+ break;
398
+ }
399
+ case "minute": {
400
+ switch (token.value) {
401
+ case "numeric": {
402
+ value = /^\d{1,2}/.exec(string)?.[0];
403
+ break;
404
+ }
405
+ case "2-digit": {
406
+ value = /^\d{2}/.exec(string)?.[0];
407
+ break;
408
+ }
409
+ default:
410
+ throw Error(`ParserError: value "${token.value}" is not supported`);
411
+ }
412
+ break;
413
+ }
414
+ case "second": {
415
+ switch (token.value) {
416
+ case "numeric": {
417
+ value = /^\d{1,2}/.exec(string)?.[0];
418
+ break;
419
+ }
420
+ case "2-digit": {
421
+ value = /^\d{2}/.exec(string)?.[0];
422
+ break;
423
+ }
424
+ default:
425
+ throw Error(`ParserError: value "${token.value}" is not supported`);
426
+ }
427
+ break;
428
+ }
429
+ case "fractionalSecond": {
430
+ value = new RegExp(`^\\d{${token.value}}`).exec(string)?.[0];
431
+ break;
432
+ }
433
+ case "timeZoneName": {
434
+ value = token.value;
435
+ break;
436
+ }
437
+ case "dayPeriod": {
438
+ value = /^(A|P)M/.exec(string)?.[0];
439
+ break;
440
+ }
441
+ case "literal": {
442
+ if (!string.startsWith(token.value)) {
443
+ throw Error(`Literal "${token.value}" not found "${string.slice(0, 25)}"`);
444
+ }
445
+ value = token.value;
446
+ break;
447
+ }
448
+ default:
449
+ throw Error(`${token.type} ${token.value}`);
450
+ }
451
+ if (!value) {
452
+ throw Error(`value not valid for token { ${type} ${value} } ${string.slice(0, 25)}`);
453
+ }
454
+ parts.push({ type, value });
455
+ string = string.slice(value.length);
456
+ }
457
+ if (string.length) {
458
+ throw Error(`datetime string was not fully parsed! ${string.slice(0, 25)}`);
459
+ }
460
+ return parts;
461
+ }
462
+ /** sort & filter dateTimeFormatPart */
463
+ sortDateTimeFormatPart(parts) {
464
+ let result = [];
465
+ const typeArray = [
466
+ "year",
467
+ "month",
468
+ "day",
469
+ "hour",
470
+ "minute",
471
+ "second",
472
+ "fractionalSecond",
473
+ ];
474
+ for (const type of typeArray) {
475
+ const current = parts.findIndex((el) => el.type === type);
476
+ if (current !== -1) {
477
+ result = result.concat(parts.splice(current, 1));
478
+ }
479
+ }
480
+ result = result.concat(parts);
481
+ return result;
482
+ }
483
+ partsToDate(parts) {
484
+ const date = new Date();
485
+ const utc = parts.find((part) => part.type === "timeZoneName" && part.value === "UTC");
486
+ const dayPart = parts.find((part) => part.type === "day");
487
+ utc ? date.setUTCHours(0, 0, 0, 0) : date.setHours(0, 0, 0, 0);
488
+ for (const part of parts) {
489
+ switch (part.type) {
490
+ case "year": {
491
+ const value = Number(part.value.padStart(4, "20"));
492
+ utc ? date.setUTCFullYear(value) : date.setFullYear(value);
493
+ break;
494
+ }
495
+ case "month": {
496
+ const value = Number(part.value) - 1;
497
+ if (dayPart) {
498
+ utc
499
+ ? date.setUTCMonth(value, Number(dayPart.value))
500
+ : date.setMonth(value, Number(dayPart.value));
501
+ }
502
+ else {
503
+ utc ? date.setUTCMonth(value) : date.setMonth(value);
504
+ }
505
+ break;
506
+ }
507
+ case "day": {
508
+ const value = Number(part.value);
509
+ utc ? date.setUTCDate(value) : date.setDate(value);
510
+ break;
511
+ }
512
+ case "hour": {
513
+ let value = Number(part.value);
514
+ const dayPeriod = parts.find((part) => part.type === "dayPeriod");
515
+ if (dayPeriod?.value === "PM")
516
+ value += 12;
517
+ utc ? date.setUTCHours(value) : date.setHours(value);
518
+ break;
519
+ }
520
+ case "minute": {
521
+ const value = Number(part.value);
522
+ utc ? date.setUTCMinutes(value) : date.setMinutes(value);
523
+ break;
524
+ }
525
+ case "second": {
526
+ const value = Number(part.value);
527
+ utc ? date.setUTCSeconds(value) : date.setSeconds(value);
528
+ break;
529
+ }
530
+ case "fractionalSecond": {
531
+ const value = Number(part.value);
532
+ utc ? date.setUTCMilliseconds(value) : date.setMilliseconds(value);
533
+ break;
534
+ }
535
+ }
536
+ }
537
+ return date;
538
+ }
539
+ parse(string) {
540
+ const parts = this.parseToParts(string);
541
+ const sortParts = this.sortDateTimeFormatPart(parts);
542
+ return this.partsToDate(sortParts);
543
+ }
544
+ }
545
+ _DateTimeFormatter_format = new WeakMap();
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The number of milliseconds in a second.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { SECOND } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
7
+ *
8
+ * console.log(SECOND); // => 1000
9
+ * ```
10
+ */
11
+ export declare const SECOND = 1000;
12
+ /**
13
+ * The number of milliseconds in a minute.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { MINUTE } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
18
+ *
19
+ * console.log(MINUTE); // => 60000 (60 * 1000)
20
+ * ```
21
+ */
22
+ export declare const MINUTE: number;
23
+ /**
24
+ * The number of milliseconds in an hour.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { HOUR } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
29
+ *
30
+ * console.log(HOUR); // => 3600000 (60 * 60 * 1000)
31
+ * ```
32
+ */
33
+ export declare const HOUR: number;
34
+ /**
35
+ * The number of milliseconds in a day.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { DAY } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
40
+ *
41
+ * console.log(DAY); // => 86400000 (24 * 60 * 60 * 1000)
42
+ * ```
43
+ */
44
+ export declare const DAY: number;
45
+ /**
46
+ * The number of milliseconds in a week.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { WEEK } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
51
+ *
52
+ * console.log(WEEK); // => 604800000 (7 * 24 * 60 * 60 * 1000)
53
+ * ```
54
+ */
55
+ export declare const WEEK: number;
@@ -0,0 +1,57 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ /**
4
+ * The number of milliseconds in a second.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { SECOND } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
9
+ *
10
+ * console.log(SECOND); // => 1000
11
+ * ```
12
+ */
13
+ export const SECOND = 1e3;
14
+ /**
15
+ * The number of milliseconds in a minute.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { MINUTE } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
20
+ *
21
+ * console.log(MINUTE); // => 60000 (60 * 1000)
22
+ * ```
23
+ */
24
+ export const MINUTE = SECOND * 60;
25
+ /**
26
+ * The number of milliseconds in an hour.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { HOUR } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
31
+ *
32
+ * console.log(HOUR); // => 3600000 (60 * 60 * 1000)
33
+ * ```
34
+ */
35
+ export const HOUR = MINUTE * 60;
36
+ /**
37
+ * The number of milliseconds in a day.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { DAY } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
42
+ *
43
+ * console.log(DAY); // => 86400000 (24 * 60 * 60 * 1000)
44
+ * ```
45
+ */
46
+ export const DAY = HOUR * 24;
47
+ /**
48
+ * The number of milliseconds in a week.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import { WEEK } from "https://deno.land/std@$STD_VERSION/datetime/constants.ts";
53
+ *
54
+ * console.log(WEEK); // => 604800000 (7 * 24 * 60 * 60 * 1000)
55
+ * ```
56
+ */
57
+ export const WEEK = DAY * 7;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Returns the number of the day in the year in the local time zone.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { dayOfYear } from "https://deno.land/std@$STD_VERSION/datetime/mod.ts";
7
+ *
8
+ * dayOfYear(new Date("2019-03-11T03:24:00")); // output: 70
9
+ * ```
10
+ *
11
+ * @return Number of the day in the year in the local time zone
12
+ */
13
+ export declare function dayOfYear(date: Date): number;
14
+ /**
15
+ * Returns the number of the day in the year in UTC time.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { dayOfYearUtc } from "https://deno.land/std@$STD_VERSION/datetime/mod.ts";
20
+ *
21
+ * dayOfYearUtc(new Date("2019-03-11T03:24:00.000Z")) // output 70
22
+ * ```
23
+ *
24
+ * @return Number of the day in the year in UTC time
25
+ */
26
+ export declare function dayOfYearUtc(date: Date): number;