@chipmobilesdk/rn-notification 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (647) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/README.md +8 -6
  3. package/lib/commonjs/advanced.js +139 -0
  4. package/lib/commonjs/advanced.js.map +1 -0
  5. package/lib/commonjs/channel/migrate.js +246 -0
  6. package/lib/commonjs/channel/migrate.js.map +1 -0
  7. package/lib/commonjs/channel/tone-map.js +120 -0
  8. package/lib/commonjs/channel/tone-map.js.map +1 -0
  9. package/lib/commonjs/channel/validate-tone.js +61 -0
  10. package/lib/commonjs/channel/validate-tone.js.map +1 -0
  11. package/lib/commonjs/contract/channel.js +52 -0
  12. package/lib/commonjs/contract/channel.js.map +1 -0
  13. package/lib/commonjs/contract/diagnostics.js +25 -0
  14. package/lib/commonjs/contract/diagnostics.js.map +1 -0
  15. package/lib/commonjs/contract/errors.js +126 -0
  16. package/lib/commonjs/contract/errors.js.map +1 -0
  17. package/lib/commonjs/contract/hash.js +35 -0
  18. package/lib/commonjs/contract/hash.js.map +1 -0
  19. package/lib/commonjs/contract/index.js +94 -0
  20. package/lib/commonjs/contract/index.js.map +1 -0
  21. package/lib/commonjs/contract/interaction.js +37 -0
  22. package/lib/commonjs/contract/interaction.js.map +1 -0
  23. package/lib/commonjs/contract/notification.js +42 -0
  24. package/lib/commonjs/contract/notification.js.map +1 -0
  25. package/lib/commonjs/contract/permission.js +2 -0
  26. package/lib/commonjs/contract/permission.js.map +1 -0
  27. package/lib/commonjs/contract/reconcile.js +6 -0
  28. package/lib/commonjs/contract/reconcile.js.map +1 -0
  29. package/lib/commonjs/contract/recurrence.js +53 -0
  30. package/lib/commonjs/contract/recurrence.js.map +1 -0
  31. package/lib/commonjs/diagnostics/burst.js +89 -0
  32. package/lib/commonjs/diagnostics/burst.js.map +1 -0
  33. package/lib/commonjs/diagnostics/events.js +63 -0
  34. package/lib/commonjs/diagnostics/events.js.map +1 -0
  35. package/lib/commonjs/diagnostics/redact.js +48 -0
  36. package/lib/commonjs/diagnostics/redact.js.map +1 -0
  37. package/lib/commonjs/diagnostics/snapshot.js +68 -0
  38. package/lib/commonjs/diagnostics/snapshot.js.map +1 -0
  39. package/lib/commonjs/engine/adapter.js +6 -0
  40. package/lib/commonjs/engine/adapter.js.map +1 -0
  41. package/lib/commonjs/engine/codec.js +84 -0
  42. package/lib/commonjs/engine/codec.js.map +1 -0
  43. package/lib/commonjs/engine/notify-kit/events.js +148 -0
  44. package/lib/commonjs/engine/notify-kit/events.js.map +1 -0
  45. package/lib/commonjs/engine/notify-kit/module.js +119 -0
  46. package/lib/commonjs/engine/notify-kit/module.js.map +1 -0
  47. package/lib/commonjs/engine/notify-kit/platform/android.js +159 -0
  48. package/lib/commonjs/engine/notify-kit/platform/android.js.map +1 -0
  49. package/lib/commonjs/engine/notify-kit/platform/index.js +57 -0
  50. package/lib/commonjs/engine/notify-kit/platform/index.js.map +1 -0
  51. package/lib/commonjs/engine/notify-kit/platform/ios.js +54 -0
  52. package/lib/commonjs/engine/notify-kit/platform/ios.js.map +1 -0
  53. package/lib/commonjs/engine/notify-kit/platform/types.js +6 -0
  54. package/lib/commonjs/engine/notify-kit/platform/types.js.map +1 -0
  55. package/lib/commonjs/engine/notify-kit-engine.js +260 -0
  56. package/lib/commonjs/engine/notify-kit-engine.js.map +1 -0
  57. package/lib/commonjs/index.js +367 -0
  58. package/lib/commonjs/index.js.map +1 -0
  59. package/lib/commonjs/initialize.js +187 -0
  60. package/lib/commonjs/initialize.js.map +1 -0
  61. package/lib/commonjs/interaction/index.js +120 -0
  62. package/lib/commonjs/interaction/index.js.map +1 -0
  63. package/lib/commonjs/maintenance/cycle.js +108 -0
  64. package/lib/commonjs/maintenance/cycle.js.map +1 -0
  65. package/lib/commonjs/maintenance/permission-refresh.js +39 -0
  66. package/lib/commonjs/maintenance/permission-refresh.js.map +1 -0
  67. package/lib/commonjs/maintenance/reanchor.js +99 -0
  68. package/lib/commonjs/maintenance/reanchor.js.map +1 -0
  69. package/lib/commonjs/maintenance/toggle.js +50 -0
  70. package/lib/commonjs/maintenance/toggle.js.map +1 -0
  71. package/lib/commonjs/maintenance/verify.js +70 -0
  72. package/lib/commonjs/maintenance/verify.js.map +1 -0
  73. package/lib/commonjs/maintenance/window-refresh.js +53 -0
  74. package/lib/commonjs/maintenance/window-refresh.js.map +1 -0
  75. package/lib/commonjs/notifications.js +161 -0
  76. package/lib/commonjs/notifications.js.map +1 -0
  77. package/lib/commonjs/package.json +1 -0
  78. package/lib/commonjs/permission/index.js +182 -0
  79. package/lib/commonjs/permission/index.js.map +1 -0
  80. package/lib/commonjs/permission/state.js +92 -0
  81. package/lib/commonjs/permission/state.js.map +1 -0
  82. package/lib/commonjs/push/envelope.js +141 -0
  83. package/lib/commonjs/push/envelope.js.map +1 -0
  84. package/lib/commonjs/push/fcm-provider.js +122 -0
  85. package/lib/commonjs/push/fcm-provider.js.map +1 -0
  86. package/lib/commonjs/push/gate.js +162 -0
  87. package/lib/commonjs/push/gate.js.map +1 -0
  88. package/lib/commonjs/push/index.js +47 -0
  89. package/lib/commonjs/push/index.js.map +1 -0
  90. package/lib/commonjs/push/instructions.js +101 -0
  91. package/lib/commonjs/push/instructions.js.map +1 -0
  92. package/lib/commonjs/push/provider-adapter.js +6 -0
  93. package/lib/commonjs/push/provider-adapter.js.map +1 -0
  94. package/lib/commonjs/push/signout.js +55 -0
  95. package/lib/commonjs/push/signout.js.map +1 -0
  96. package/lib/commonjs/reconcile/chunk.js +49 -0
  97. package/lib/commonjs/reconcile/chunk.js.map +1 -0
  98. package/lib/commonjs/reconcile/diff.js +105 -0
  99. package/lib/commonjs/reconcile/diff.js.map +1 -0
  100. package/lib/commonjs/reconcile/duplicates.js +60 -0
  101. package/lib/commonjs/reconcile/duplicates.js.map +1 -0
  102. package/lib/commonjs/reconcile/index.js +164 -0
  103. package/lib/commonjs/reconcile/index.js.map +1 -0
  104. package/lib/commonjs/reconcile/truncate.js +50 -0
  105. package/lib/commonjs/reconcile/truncate.js.map +1 -0
  106. package/lib/commonjs/recurrence/clock-guard.js +65 -0
  107. package/lib/commonjs/recurrence/clock-guard.js.map +1 -0
  108. package/lib/commonjs/recurrence/expand.js +254 -0
  109. package/lib/commonjs/recurrence/expand.js.map +1 -0
  110. package/lib/commonjs/recurrence/index.js +212 -0
  111. package/lib/commonjs/recurrence/index.js.map +1 -0
  112. package/lib/commonjs/repeat/expiry.js +41 -0
  113. package/lib/commonjs/repeat/expiry.js.map +1 -0
  114. package/lib/commonjs/repeat/index.js +100 -0
  115. package/lib/commonjs/repeat/index.js.map +1 -0
  116. package/lib/commonjs/repeat/marker.js +58 -0
  117. package/lib/commonjs/repeat/marker.js.map +1 -0
  118. package/lib/commonjs/repeat/place.js +83 -0
  119. package/lib/commonjs/repeat/place.js.map +1 -0
  120. package/lib/commonjs/schedule/anchor.js +243 -0
  121. package/lib/commonjs/schedule/anchor.js.map +1 -0
  122. package/lib/commonjs/schedule/index.js +142 -0
  123. package/lib/commonjs/schedule/index.js.map +1 -0
  124. package/lib/commonjs/schedule/partition.js +59 -0
  125. package/lib/commonjs/schedule/partition.js.map +1 -0
  126. package/lib/commonjs/schedule/resolve-moment.js +72 -0
  127. package/lib/commonjs/schedule/resolve-moment.js.map +1 -0
  128. package/lib/commonjs/schedule/validate-content.js +101 -0
  129. package/lib/commonjs/schedule/validate-content.js.map +1 -0
  130. package/lib/commonjs/schedule/validate-identifier.js +126 -0
  131. package/lib/commonjs/schedule/validate-identifier.js.map +1 -0
  132. package/lib/commonjs/schedule/writer.js +44 -0
  133. package/lib/commonjs/schedule/writer.js.map +1 -0
  134. package/lib/commonjs/state/caps.js +101 -0
  135. package/lib/commonjs/state/caps.js.map +1 -0
  136. package/lib/commonjs/state/dedup-ledger.js +39 -0
  137. package/lib/commonjs/state/dedup-ledger.js.map +1 -0
  138. package/lib/commonjs/state/interaction-buffer.js +98 -0
  139. package/lib/commonjs/state/interaction-buffer.js.map +1 -0
  140. package/lib/commonjs/state/mmkv-store.js +75 -0
  141. package/lib/commonjs/state/mmkv-store.js.map +1 -0
  142. package/lib/commonjs/state/permission-history.js +64 -0
  143. package/lib/commonjs/state/permission-history.js.map +1 -0
  144. package/lib/commonjs/state/record.js +269 -0
  145. package/lib/commonjs/state/record.js.map +1 -0
  146. package/lib/commonjs/state/reset.js +37 -0
  147. package/lib/commonjs/state/reset.js.map +1 -0
  148. package/lib/commonjs/state/series-ledger.js +71 -0
  149. package/lib/commonjs/state/series-ledger.js.map +1 -0
  150. package/lib/commonjs/state/store.js +39 -0
  151. package/lib/commonjs/state/store.js.map +1 -0
  152. package/lib/commonjs/testing/conformance/index.js +218 -0
  153. package/lib/commonjs/testing/conformance/index.js.map +1 -0
  154. package/lib/commonjs/testing/fake-engine.js +338 -0
  155. package/lib/commonjs/testing/fake-engine.js.map +1 -0
  156. package/lib/commonjs/testing/fake-provider.js +93 -0
  157. package/lib/commonjs/testing/fake-provider.js.map +1 -0
  158. package/lib/commonjs/testing/faults.js +59 -0
  159. package/lib/commonjs/testing/faults.js.map +1 -0
  160. package/lib/commonjs/testing/index.js +54 -0
  161. package/lib/commonjs/testing/index.js.map +1 -0
  162. package/lib/commonjs/testing/measure.js +298 -0
  163. package/lib/commonjs/testing/measure.js.map +1 -0
  164. package/lib/module/advanced.js +29 -0
  165. package/lib/module/advanced.js.map +1 -0
  166. package/lib/module/channel/migrate.js +242 -0
  167. package/lib/module/channel/migrate.js.map +1 -0
  168. package/lib/module/channel/tone-map.js +112 -0
  169. package/lib/module/channel/tone-map.js.map +1 -0
  170. package/lib/module/channel/validate-tone.js +57 -0
  171. package/lib/module/channel/validate-tone.js.map +1 -0
  172. package/lib/module/contract/channel.js +48 -0
  173. package/lib/module/contract/channel.js.map +1 -0
  174. package/lib/module/contract/diagnostics.js +21 -0
  175. package/lib/module/contract/diagnostics.js.map +1 -0
  176. package/lib/module/contract/errors.js +119 -0
  177. package/lib/module/contract/errors.js.map +1 -0
  178. package/lib/module/contract/hash.js +29 -0
  179. package/lib/module/contract/hash.js.map +1 -0
  180. package/lib/module/contract/index.js +13 -0
  181. package/lib/module/contract/index.js.map +1 -0
  182. package/lib/module/contract/interaction.js +33 -0
  183. package/lib/module/contract/interaction.js.map +1 -0
  184. package/lib/module/contract/notification.js +38 -0
  185. package/lib/module/contract/notification.js.map +1 -0
  186. package/lib/module/contract/permission.js +2 -0
  187. package/lib/module/contract/permission.js.map +1 -0
  188. package/lib/module/contract/reconcile.js +4 -0
  189. package/lib/module/contract/reconcile.js.map +1 -0
  190. package/lib/module/contract/recurrence.js +49 -0
  191. package/lib/module/contract/recurrence.js.map +1 -0
  192. package/lib/module/diagnostics/burst.js +85 -0
  193. package/lib/module/diagnostics/burst.js.map +1 -0
  194. package/lib/module/diagnostics/events.js +58 -0
  195. package/lib/module/diagnostics/events.js.map +1 -0
  196. package/lib/module/diagnostics/redact.js +44 -0
  197. package/lib/module/diagnostics/redact.js.map +1 -0
  198. package/lib/module/diagnostics/snapshot.js +64 -0
  199. package/lib/module/diagnostics/snapshot.js.map +1 -0
  200. package/lib/module/engine/adapter.js +4 -0
  201. package/lib/module/engine/adapter.js.map +1 -0
  202. package/lib/module/engine/codec.js +79 -0
  203. package/lib/module/engine/codec.js.map +1 -0
  204. package/lib/module/engine/notify-kit/events.js +139 -0
  205. package/lib/module/engine/notify-kit/events.js.map +1 -0
  206. package/lib/module/engine/notify-kit/module.js +113 -0
  207. package/lib/module/engine/notify-kit/module.js.map +1 -0
  208. package/lib/module/engine/notify-kit/platform/android.js +155 -0
  209. package/lib/module/engine/notify-kit/platform/android.js.map +1 -0
  210. package/lib/module/engine/notify-kit/platform/index.js +51 -0
  211. package/lib/module/engine/notify-kit/platform/index.js.map +1 -0
  212. package/lib/module/engine/notify-kit/platform/ios.js +49 -0
  213. package/lib/module/engine/notify-kit/platform/ios.js.map +1 -0
  214. package/lib/module/engine/notify-kit/platform/types.js +4 -0
  215. package/lib/module/engine/notify-kit/platform/types.js.map +1 -0
  216. package/lib/module/engine/notify-kit-engine.js +257 -0
  217. package/lib/module/engine/notify-kit-engine.js.map +1 -0
  218. package/lib/module/index.js +98 -0
  219. package/lib/module/index.js.map +1 -0
  220. package/lib/module/initialize.js +182 -0
  221. package/lib/module/initialize.js.map +1 -0
  222. package/lib/module/interaction/index.js +116 -0
  223. package/lib/module/interaction/index.js.map +1 -0
  224. package/lib/module/maintenance/cycle.js +102 -0
  225. package/lib/module/maintenance/cycle.js.map +1 -0
  226. package/lib/module/maintenance/permission-refresh.js +34 -0
  227. package/lib/module/maintenance/permission-refresh.js.map +1 -0
  228. package/lib/module/maintenance/reanchor.js +94 -0
  229. package/lib/module/maintenance/reanchor.js.map +1 -0
  230. package/lib/module/maintenance/toggle.js +45 -0
  231. package/lib/module/maintenance/toggle.js.map +1 -0
  232. package/lib/module/maintenance/verify.js +65 -0
  233. package/lib/module/maintenance/verify.js.map +1 -0
  234. package/lib/module/maintenance/window-refresh.js +48 -0
  235. package/lib/module/maintenance/window-refresh.js.map +1 -0
  236. package/lib/module/notifications.js +157 -0
  237. package/lib/module/notifications.js.map +1 -0
  238. package/lib/module/package.json +1 -0
  239. package/lib/module/permission/index.js +178 -0
  240. package/lib/module/permission/index.js.map +1 -0
  241. package/lib/module/permission/state.js +83 -0
  242. package/lib/module/permission/state.js.map +1 -0
  243. package/lib/module/push/envelope.js +137 -0
  244. package/lib/module/push/envelope.js.map +1 -0
  245. package/lib/module/push/fcm-provider.js +119 -0
  246. package/lib/module/push/fcm-provider.js.map +1 -0
  247. package/lib/module/push/gate.js +158 -0
  248. package/lib/module/push/gate.js.map +1 -0
  249. package/lib/module/push/index.js +16 -0
  250. package/lib/module/push/index.js.map +1 -0
  251. package/lib/module/push/instructions.js +97 -0
  252. package/lib/module/push/instructions.js.map +1 -0
  253. package/lib/module/push/provider-adapter.js +4 -0
  254. package/lib/module/push/provider-adapter.js.map +1 -0
  255. package/lib/module/push/signout.js +51 -0
  256. package/lib/module/push/signout.js.map +1 -0
  257. package/lib/module/reconcile/chunk.js +43 -0
  258. package/lib/module/reconcile/chunk.js.map +1 -0
  259. package/lib/module/reconcile/diff.js +101 -0
  260. package/lib/module/reconcile/diff.js.map +1 -0
  261. package/lib/module/reconcile/duplicates.js +56 -0
  262. package/lib/module/reconcile/duplicates.js.map +1 -0
  263. package/lib/module/reconcile/index.js +161 -0
  264. package/lib/module/reconcile/index.js.map +1 -0
  265. package/lib/module/reconcile/truncate.js +46 -0
  266. package/lib/module/reconcile/truncate.js.map +1 -0
  267. package/lib/module/recurrence/clock-guard.js +60 -0
  268. package/lib/module/recurrence/clock-guard.js.map +1 -0
  269. package/lib/module/recurrence/expand.js +248 -0
  270. package/lib/module/recurrence/expand.js.map +1 -0
  271. package/lib/module/recurrence/index.js +208 -0
  272. package/lib/module/recurrence/index.js.map +1 -0
  273. package/lib/module/repeat/expiry.js +37 -0
  274. package/lib/module/repeat/expiry.js.map +1 -0
  275. package/lib/module/repeat/index.js +67 -0
  276. package/lib/module/repeat/index.js.map +1 -0
  277. package/lib/module/repeat/marker.js +51 -0
  278. package/lib/module/repeat/marker.js.map +1 -0
  279. package/lib/module/repeat/place.js +79 -0
  280. package/lib/module/repeat/place.js.map +1 -0
  281. package/lib/module/schedule/anchor.js +234 -0
  282. package/lib/module/schedule/anchor.js.map +1 -0
  283. package/lib/module/schedule/index.js +137 -0
  284. package/lib/module/schedule/index.js.map +1 -0
  285. package/lib/module/schedule/partition.js +53 -0
  286. package/lib/module/schedule/partition.js.map +1 -0
  287. package/lib/module/schedule/resolve-moment.js +66 -0
  288. package/lib/module/schedule/resolve-moment.js.map +1 -0
  289. package/lib/module/schedule/validate-content.js +95 -0
  290. package/lib/module/schedule/validate-content.js.map +1 -0
  291. package/lib/module/schedule/validate-identifier.js +119 -0
  292. package/lib/module/schedule/validate-identifier.js.map +1 -0
  293. package/lib/module/schedule/writer.js +40 -0
  294. package/lib/module/schedule/writer.js.map +1 -0
  295. package/lib/module/state/caps.js +96 -0
  296. package/lib/module/state/caps.js.map +1 -0
  297. package/lib/module/state/dedup-ledger.js +34 -0
  298. package/lib/module/state/dedup-ledger.js.map +1 -0
  299. package/lib/module/state/interaction-buffer.js +92 -0
  300. package/lib/module/state/interaction-buffer.js.map +1 -0
  301. package/lib/module/state/mmkv-store.js +71 -0
  302. package/lib/module/state/mmkv-store.js.map +1 -0
  303. package/lib/module/state/permission-history.js +56 -0
  304. package/lib/module/state/permission-history.js.map +1 -0
  305. package/lib/module/state/record.js +264 -0
  306. package/lib/module/state/record.js.map +1 -0
  307. package/lib/module/state/reset.js +32 -0
  308. package/lib/module/state/reset.js.map +1 -0
  309. package/lib/module/state/series-ledger.js +62 -0
  310. package/lib/module/state/series-ledger.js.map +1 -0
  311. package/lib/module/state/store.js +35 -0
  312. package/lib/module/state/store.js.map +1 -0
  313. package/lib/module/testing/conformance/index.js +214 -0
  314. package/lib/module/testing/conformance/index.js.map +1 -0
  315. package/lib/module/testing/fake-engine.js +335 -0
  316. package/lib/module/testing/fake-engine.js.map +1 -0
  317. package/lib/module/testing/fake-provider.js +89 -0
  318. package/lib/module/testing/fake-provider.js.map +1 -0
  319. package/lib/module/testing/faults.js +55 -0
  320. package/lib/module/testing/faults.js.map +1 -0
  321. package/lib/module/testing/index.js +19 -0
  322. package/lib/module/testing/index.js.map +1 -0
  323. package/lib/module/testing/measure.js +294 -0
  324. package/lib/module/testing/measure.js.map +1 -0
  325. package/lib/typescript/commonjs/advanced.d.ts +36 -0
  326. package/lib/typescript/commonjs/advanced.d.ts.map +1 -0
  327. package/lib/typescript/commonjs/channel/migrate.d.ts +38 -0
  328. package/lib/typescript/commonjs/channel/migrate.d.ts.map +1 -0
  329. package/lib/typescript/commonjs/channel/tone-map.d.ts +34 -0
  330. package/lib/typescript/commonjs/channel/tone-map.d.ts.map +1 -0
  331. package/lib/typescript/commonjs/channel/validate-tone.d.ts +23 -0
  332. package/lib/typescript/commonjs/channel/validate-tone.d.ts.map +1 -0
  333. package/lib/typescript/commonjs/contract/channel.d.ts +185 -0
  334. package/lib/typescript/commonjs/contract/channel.d.ts.map +1 -0
  335. package/lib/typescript/commonjs/contract/diagnostics.d.ts +92 -0
  336. package/lib/typescript/commonjs/contract/diagnostics.d.ts.map +1 -0
  337. package/lib/typescript/commonjs/contract/errors.d.ts +91 -0
  338. package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
  339. package/lib/typescript/commonjs/contract/hash.d.ts +14 -0
  340. package/lib/typescript/commonjs/contract/hash.d.ts.map +1 -0
  341. package/lib/typescript/commonjs/contract/index.d.ts +10 -0
  342. package/lib/typescript/commonjs/contract/index.d.ts.map +1 -0
  343. package/lib/typescript/commonjs/contract/interaction.d.ts +53 -0
  344. package/lib/typescript/commonjs/contract/interaction.d.ts.map +1 -0
  345. package/lib/typescript/commonjs/contract/notification.d.ts +110 -0
  346. package/lib/typescript/commonjs/contract/notification.d.ts.map +1 -0
  347. package/lib/typescript/commonjs/contract/permission.d.ts +49 -0
  348. package/lib/typescript/commonjs/contract/permission.d.ts.map +1 -0
  349. package/lib/typescript/commonjs/contract/reconcile.d.ts +82 -0
  350. package/lib/typescript/commonjs/contract/reconcile.d.ts.map +1 -0
  351. package/lib/typescript/commonjs/contract/recurrence.d.ts +118 -0
  352. package/lib/typescript/commonjs/contract/recurrence.d.ts.map +1 -0
  353. package/lib/typescript/commonjs/diagnostics/burst.d.ts +39 -0
  354. package/lib/typescript/commonjs/diagnostics/burst.d.ts.map +1 -0
  355. package/lib/typescript/commonjs/diagnostics/events.d.ts +28 -0
  356. package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
  357. package/lib/typescript/commonjs/diagnostics/redact.d.ts +22 -0
  358. package/lib/typescript/commonjs/diagnostics/redact.d.ts.map +1 -0
  359. package/lib/typescript/commonjs/diagnostics/snapshot.d.ts +40 -0
  360. package/lib/typescript/commonjs/diagnostics/snapshot.d.ts.map +1 -0
  361. package/lib/typescript/commonjs/engine/adapter.d.ts +172 -0
  362. package/lib/typescript/commonjs/engine/adapter.d.ts.map +1 -0
  363. package/lib/typescript/commonjs/engine/codec.d.ts +20 -0
  364. package/lib/typescript/commonjs/engine/codec.d.ts.map +1 -0
  365. package/lib/typescript/commonjs/engine/notify-kit/events.d.ts +37 -0
  366. package/lib/typescript/commonjs/engine/notify-kit/events.d.ts.map +1 -0
  367. package/lib/typescript/commonjs/engine/notify-kit/module.d.ts +103 -0
  368. package/lib/typescript/commonjs/engine/notify-kit/module.d.ts.map +1 -0
  369. package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts +3 -0
  370. package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts.map +1 -0
  371. package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts +12 -0
  372. package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts.map +1 -0
  373. package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts +3 -0
  374. package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts.map +1 -0
  375. package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts +33 -0
  376. package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts.map +1 -0
  377. package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts +25 -0
  378. package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts.map +1 -0
  379. package/lib/typescript/commonjs/index.d.ts +106 -0
  380. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  381. package/lib/typescript/commonjs/initialize.d.ts +74 -0
  382. package/lib/typescript/commonjs/initialize.d.ts.map +1 -0
  383. package/lib/typescript/commonjs/interaction/index.d.ts +53 -0
  384. package/lib/typescript/commonjs/interaction/index.d.ts.map +1 -0
  385. package/lib/typescript/commonjs/maintenance/cycle.d.ts +77 -0
  386. package/lib/typescript/commonjs/maintenance/cycle.d.ts.map +1 -0
  387. package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts +19 -0
  388. package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts.map +1 -0
  389. package/lib/typescript/commonjs/maintenance/reanchor.d.ts +26 -0
  390. package/lib/typescript/commonjs/maintenance/reanchor.d.ts.map +1 -0
  391. package/lib/typescript/commonjs/maintenance/toggle.d.ts +35 -0
  392. package/lib/typescript/commonjs/maintenance/toggle.d.ts.map +1 -0
  393. package/lib/typescript/commonjs/maintenance/verify.d.ts +32 -0
  394. package/lib/typescript/commonjs/maintenance/verify.d.ts.map +1 -0
  395. package/lib/typescript/commonjs/maintenance/window-refresh.d.ts +29 -0
  396. package/lib/typescript/commonjs/maintenance/window-refresh.d.ts.map +1 -0
  397. package/lib/typescript/commonjs/notifications.d.ts +78 -0
  398. package/lib/typescript/commonjs/notifications.d.ts.map +1 -0
  399. package/lib/typescript/commonjs/package.json +1 -0
  400. package/lib/typescript/commonjs/permission/index.d.ts +57 -0
  401. package/lib/typescript/commonjs/permission/index.d.ts.map +1 -0
  402. package/lib/typescript/commonjs/permission/state.d.ts +41 -0
  403. package/lib/typescript/commonjs/permission/state.d.ts.map +1 -0
  404. package/lib/typescript/commonjs/push/envelope.d.ts +33 -0
  405. package/lib/typescript/commonjs/push/envelope.d.ts.map +1 -0
  406. package/lib/typescript/commonjs/push/fcm-provider.d.ts +43 -0
  407. package/lib/typescript/commonjs/push/fcm-provider.d.ts.map +1 -0
  408. package/lib/typescript/commonjs/push/gate.d.ts +57 -0
  409. package/lib/typescript/commonjs/push/gate.d.ts.map +1 -0
  410. package/lib/typescript/commonjs/push/index.d.ts +19 -0
  411. package/lib/typescript/commonjs/push/index.d.ts.map +1 -0
  412. package/lib/typescript/commonjs/push/instructions.d.ts +45 -0
  413. package/lib/typescript/commonjs/push/instructions.d.ts.map +1 -0
  414. package/lib/typescript/commonjs/push/provider-adapter.d.ts +50 -0
  415. package/lib/typescript/commonjs/push/provider-adapter.d.ts.map +1 -0
  416. package/lib/typescript/commonjs/push/signout.d.ts +33 -0
  417. package/lib/typescript/commonjs/push/signout.d.ts.map +1 -0
  418. package/lib/typescript/commonjs/reconcile/chunk.d.ts +24 -0
  419. package/lib/typescript/commonjs/reconcile/chunk.d.ts.map +1 -0
  420. package/lib/typescript/commonjs/reconcile/diff.d.ts +54 -0
  421. package/lib/typescript/commonjs/reconcile/diff.d.ts.map +1 -0
  422. package/lib/typescript/commonjs/reconcile/duplicates.d.ts +32 -0
  423. package/lib/typescript/commonjs/reconcile/duplicates.d.ts.map +1 -0
  424. package/lib/typescript/commonjs/reconcile/index.d.ts +35 -0
  425. package/lib/typescript/commonjs/reconcile/index.d.ts.map +1 -0
  426. package/lib/typescript/commonjs/reconcile/truncate.d.ts +26 -0
  427. package/lib/typescript/commonjs/reconcile/truncate.d.ts.map +1 -0
  428. package/lib/typescript/commonjs/recurrence/clock-guard.d.ts +37 -0
  429. package/lib/typescript/commonjs/recurrence/clock-guard.d.ts.map +1 -0
  430. package/lib/typescript/commonjs/recurrence/expand.d.ts +75 -0
  431. package/lib/typescript/commonjs/recurrence/expand.d.ts.map +1 -0
  432. package/lib/typescript/commonjs/recurrence/index.d.ts +40 -0
  433. package/lib/typescript/commonjs/recurrence/index.d.ts.map +1 -0
  434. package/lib/typescript/commonjs/repeat/expiry.d.ts +23 -0
  435. package/lib/typescript/commonjs/repeat/expiry.d.ts.map +1 -0
  436. package/lib/typescript/commonjs/repeat/index.d.ts +49 -0
  437. package/lib/typescript/commonjs/repeat/index.d.ts.map +1 -0
  438. package/lib/typescript/commonjs/repeat/marker.d.ts +36 -0
  439. package/lib/typescript/commonjs/repeat/marker.d.ts.map +1 -0
  440. package/lib/typescript/commonjs/repeat/place.d.ts +39 -0
  441. package/lib/typescript/commonjs/repeat/place.d.ts.map +1 -0
  442. package/lib/typescript/commonjs/schedule/anchor.d.ts +118 -0
  443. package/lib/typescript/commonjs/schedule/anchor.d.ts.map +1 -0
  444. package/lib/typescript/commonjs/schedule/index.d.ts +40 -0
  445. package/lib/typescript/commonjs/schedule/index.d.ts.map +1 -0
  446. package/lib/typescript/commonjs/schedule/partition.d.ts +29 -0
  447. package/lib/typescript/commonjs/schedule/partition.d.ts.map +1 -0
  448. package/lib/typescript/commonjs/schedule/resolve-moment.d.ts +35 -0
  449. package/lib/typescript/commonjs/schedule/resolve-moment.d.ts.map +1 -0
  450. package/lib/typescript/commonjs/schedule/validate-content.d.ts +42 -0
  451. package/lib/typescript/commonjs/schedule/validate-content.d.ts.map +1 -0
  452. package/lib/typescript/commonjs/schedule/validate-identifier.d.ts +30 -0
  453. package/lib/typescript/commonjs/schedule/validate-identifier.d.ts.map +1 -0
  454. package/lib/typescript/commonjs/schedule/writer.d.ts +36 -0
  455. package/lib/typescript/commonjs/schedule/writer.d.ts.map +1 -0
  456. package/lib/typescript/commonjs/state/caps.d.ts +51 -0
  457. package/lib/typescript/commonjs/state/caps.d.ts.map +1 -0
  458. package/lib/typescript/commonjs/state/dedup-ledger.d.ts +21 -0
  459. package/lib/typescript/commonjs/state/dedup-ledger.d.ts.map +1 -0
  460. package/lib/typescript/commonjs/state/interaction-buffer.d.ts +30 -0
  461. package/lib/typescript/commonjs/state/interaction-buffer.d.ts.map +1 -0
  462. package/lib/typescript/commonjs/state/mmkv-store.d.ts +33 -0
  463. package/lib/typescript/commonjs/state/mmkv-store.d.ts.map +1 -0
  464. package/lib/typescript/commonjs/state/permission-history.d.ts +20 -0
  465. package/lib/typescript/commonjs/state/permission-history.d.ts.map +1 -0
  466. package/lib/typescript/commonjs/state/record.d.ts +134 -0
  467. package/lib/typescript/commonjs/state/record.d.ts.map +1 -0
  468. package/lib/typescript/commonjs/state/reset.d.ts +22 -0
  469. package/lib/typescript/commonjs/state/reset.d.ts.map +1 -0
  470. package/lib/typescript/commonjs/state/series-ledger.d.ts +47 -0
  471. package/lib/typescript/commonjs/state/series-ledger.d.ts.map +1 -0
  472. package/lib/typescript/commonjs/state/store.d.ts +20 -0
  473. package/lib/typescript/commonjs/state/store.d.ts.map +1 -0
  474. package/lib/typescript/commonjs/testing/conformance/index.d.ts +32 -0
  475. package/lib/typescript/commonjs/testing/conformance/index.d.ts.map +1 -0
  476. package/lib/typescript/commonjs/testing/fake-engine.d.ts +91 -0
  477. package/lib/typescript/commonjs/testing/fake-engine.d.ts.map +1 -0
  478. package/lib/typescript/commonjs/testing/fake-provider.d.ts +35 -0
  479. package/lib/typescript/commonjs/testing/fake-provider.d.ts.map +1 -0
  480. package/lib/typescript/commonjs/testing/faults.d.ts +38 -0
  481. package/lib/typescript/commonjs/testing/faults.d.ts.map +1 -0
  482. package/lib/typescript/commonjs/testing/index.d.ts +22 -0
  483. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  484. package/lib/typescript/commonjs/testing/measure.d.ts +59 -0
  485. package/lib/typescript/commonjs/testing/measure.d.ts.map +1 -0
  486. package/lib/typescript/module/advanced.d.ts +36 -0
  487. package/lib/typescript/module/advanced.d.ts.map +1 -0
  488. package/lib/typescript/module/channel/migrate.d.ts +38 -0
  489. package/lib/typescript/module/channel/migrate.d.ts.map +1 -0
  490. package/lib/typescript/module/channel/tone-map.d.ts +34 -0
  491. package/lib/typescript/module/channel/tone-map.d.ts.map +1 -0
  492. package/lib/typescript/module/channel/validate-tone.d.ts +23 -0
  493. package/lib/typescript/module/channel/validate-tone.d.ts.map +1 -0
  494. package/lib/typescript/module/contract/channel.d.ts +185 -0
  495. package/lib/typescript/module/contract/channel.d.ts.map +1 -0
  496. package/lib/typescript/module/contract/diagnostics.d.ts +92 -0
  497. package/lib/typescript/module/contract/diagnostics.d.ts.map +1 -0
  498. package/lib/typescript/module/contract/errors.d.ts +91 -0
  499. package/lib/typescript/module/contract/errors.d.ts.map +1 -0
  500. package/lib/typescript/module/contract/hash.d.ts +14 -0
  501. package/lib/typescript/module/contract/hash.d.ts.map +1 -0
  502. package/lib/typescript/module/contract/index.d.ts +10 -0
  503. package/lib/typescript/module/contract/index.d.ts.map +1 -0
  504. package/lib/typescript/module/contract/interaction.d.ts +53 -0
  505. package/lib/typescript/module/contract/interaction.d.ts.map +1 -0
  506. package/lib/typescript/module/contract/notification.d.ts +110 -0
  507. package/lib/typescript/module/contract/notification.d.ts.map +1 -0
  508. package/lib/typescript/module/contract/permission.d.ts +49 -0
  509. package/lib/typescript/module/contract/permission.d.ts.map +1 -0
  510. package/lib/typescript/module/contract/reconcile.d.ts +82 -0
  511. package/lib/typescript/module/contract/reconcile.d.ts.map +1 -0
  512. package/lib/typescript/module/contract/recurrence.d.ts +118 -0
  513. package/lib/typescript/module/contract/recurrence.d.ts.map +1 -0
  514. package/lib/typescript/module/diagnostics/burst.d.ts +39 -0
  515. package/lib/typescript/module/diagnostics/burst.d.ts.map +1 -0
  516. package/lib/typescript/module/diagnostics/events.d.ts +28 -0
  517. package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
  518. package/lib/typescript/module/diagnostics/redact.d.ts +22 -0
  519. package/lib/typescript/module/diagnostics/redact.d.ts.map +1 -0
  520. package/lib/typescript/module/diagnostics/snapshot.d.ts +40 -0
  521. package/lib/typescript/module/diagnostics/snapshot.d.ts.map +1 -0
  522. package/lib/typescript/module/engine/adapter.d.ts +172 -0
  523. package/lib/typescript/module/engine/adapter.d.ts.map +1 -0
  524. package/lib/typescript/module/engine/codec.d.ts +20 -0
  525. package/lib/typescript/module/engine/codec.d.ts.map +1 -0
  526. package/lib/typescript/module/engine/notify-kit/events.d.ts +37 -0
  527. package/lib/typescript/module/engine/notify-kit/events.d.ts.map +1 -0
  528. package/lib/typescript/module/engine/notify-kit/module.d.ts +103 -0
  529. package/lib/typescript/module/engine/notify-kit/module.d.ts.map +1 -0
  530. package/lib/typescript/module/engine/notify-kit/platform/android.d.ts +3 -0
  531. package/lib/typescript/module/engine/notify-kit/platform/android.d.ts.map +1 -0
  532. package/lib/typescript/module/engine/notify-kit/platform/index.d.ts +12 -0
  533. package/lib/typescript/module/engine/notify-kit/platform/index.d.ts.map +1 -0
  534. package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts +3 -0
  535. package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts.map +1 -0
  536. package/lib/typescript/module/engine/notify-kit/platform/types.d.ts +33 -0
  537. package/lib/typescript/module/engine/notify-kit/platform/types.d.ts.map +1 -0
  538. package/lib/typescript/module/engine/notify-kit-engine.d.ts +25 -0
  539. package/lib/typescript/module/engine/notify-kit-engine.d.ts.map +1 -0
  540. package/lib/typescript/module/index.d.ts +106 -0
  541. package/lib/typescript/module/index.d.ts.map +1 -0
  542. package/lib/typescript/module/initialize.d.ts +74 -0
  543. package/lib/typescript/module/initialize.d.ts.map +1 -0
  544. package/lib/typescript/module/interaction/index.d.ts +53 -0
  545. package/lib/typescript/module/interaction/index.d.ts.map +1 -0
  546. package/lib/typescript/module/maintenance/cycle.d.ts +77 -0
  547. package/lib/typescript/module/maintenance/cycle.d.ts.map +1 -0
  548. package/lib/typescript/module/maintenance/permission-refresh.d.ts +19 -0
  549. package/lib/typescript/module/maintenance/permission-refresh.d.ts.map +1 -0
  550. package/lib/typescript/module/maintenance/reanchor.d.ts +26 -0
  551. package/lib/typescript/module/maintenance/reanchor.d.ts.map +1 -0
  552. package/lib/typescript/module/maintenance/toggle.d.ts +35 -0
  553. package/lib/typescript/module/maintenance/toggle.d.ts.map +1 -0
  554. package/lib/typescript/module/maintenance/verify.d.ts +32 -0
  555. package/lib/typescript/module/maintenance/verify.d.ts.map +1 -0
  556. package/lib/typescript/module/maintenance/window-refresh.d.ts +29 -0
  557. package/lib/typescript/module/maintenance/window-refresh.d.ts.map +1 -0
  558. package/lib/typescript/module/notifications.d.ts +78 -0
  559. package/lib/typescript/module/notifications.d.ts.map +1 -0
  560. package/lib/typescript/module/package.json +1 -0
  561. package/lib/typescript/module/permission/index.d.ts +57 -0
  562. package/lib/typescript/module/permission/index.d.ts.map +1 -0
  563. package/lib/typescript/module/permission/state.d.ts +41 -0
  564. package/lib/typescript/module/permission/state.d.ts.map +1 -0
  565. package/lib/typescript/module/push/envelope.d.ts +33 -0
  566. package/lib/typescript/module/push/envelope.d.ts.map +1 -0
  567. package/lib/typescript/module/push/fcm-provider.d.ts +43 -0
  568. package/lib/typescript/module/push/fcm-provider.d.ts.map +1 -0
  569. package/lib/typescript/module/push/gate.d.ts +57 -0
  570. package/lib/typescript/module/push/gate.d.ts.map +1 -0
  571. package/lib/typescript/module/push/index.d.ts +19 -0
  572. package/lib/typescript/module/push/index.d.ts.map +1 -0
  573. package/lib/typescript/module/push/instructions.d.ts +45 -0
  574. package/lib/typescript/module/push/instructions.d.ts.map +1 -0
  575. package/lib/typescript/module/push/provider-adapter.d.ts +50 -0
  576. package/lib/typescript/module/push/provider-adapter.d.ts.map +1 -0
  577. package/lib/typescript/module/push/signout.d.ts +33 -0
  578. package/lib/typescript/module/push/signout.d.ts.map +1 -0
  579. package/lib/typescript/module/reconcile/chunk.d.ts +24 -0
  580. package/lib/typescript/module/reconcile/chunk.d.ts.map +1 -0
  581. package/lib/typescript/module/reconcile/diff.d.ts +54 -0
  582. package/lib/typescript/module/reconcile/diff.d.ts.map +1 -0
  583. package/lib/typescript/module/reconcile/duplicates.d.ts +32 -0
  584. package/lib/typescript/module/reconcile/duplicates.d.ts.map +1 -0
  585. package/lib/typescript/module/reconcile/index.d.ts +35 -0
  586. package/lib/typescript/module/reconcile/index.d.ts.map +1 -0
  587. package/lib/typescript/module/reconcile/truncate.d.ts +26 -0
  588. package/lib/typescript/module/reconcile/truncate.d.ts.map +1 -0
  589. package/lib/typescript/module/recurrence/clock-guard.d.ts +37 -0
  590. package/lib/typescript/module/recurrence/clock-guard.d.ts.map +1 -0
  591. package/lib/typescript/module/recurrence/expand.d.ts +75 -0
  592. package/lib/typescript/module/recurrence/expand.d.ts.map +1 -0
  593. package/lib/typescript/module/recurrence/index.d.ts +40 -0
  594. package/lib/typescript/module/recurrence/index.d.ts.map +1 -0
  595. package/lib/typescript/module/repeat/expiry.d.ts +23 -0
  596. package/lib/typescript/module/repeat/expiry.d.ts.map +1 -0
  597. package/lib/typescript/module/repeat/index.d.ts +49 -0
  598. package/lib/typescript/module/repeat/index.d.ts.map +1 -0
  599. package/lib/typescript/module/repeat/marker.d.ts +36 -0
  600. package/lib/typescript/module/repeat/marker.d.ts.map +1 -0
  601. package/lib/typescript/module/repeat/place.d.ts +39 -0
  602. package/lib/typescript/module/repeat/place.d.ts.map +1 -0
  603. package/lib/typescript/module/schedule/anchor.d.ts +118 -0
  604. package/lib/typescript/module/schedule/anchor.d.ts.map +1 -0
  605. package/lib/typescript/module/schedule/index.d.ts +40 -0
  606. package/lib/typescript/module/schedule/index.d.ts.map +1 -0
  607. package/lib/typescript/module/schedule/partition.d.ts +29 -0
  608. package/lib/typescript/module/schedule/partition.d.ts.map +1 -0
  609. package/lib/typescript/module/schedule/resolve-moment.d.ts +35 -0
  610. package/lib/typescript/module/schedule/resolve-moment.d.ts.map +1 -0
  611. package/lib/typescript/module/schedule/validate-content.d.ts +42 -0
  612. package/lib/typescript/module/schedule/validate-content.d.ts.map +1 -0
  613. package/lib/typescript/module/schedule/validate-identifier.d.ts +30 -0
  614. package/lib/typescript/module/schedule/validate-identifier.d.ts.map +1 -0
  615. package/lib/typescript/module/schedule/writer.d.ts +36 -0
  616. package/lib/typescript/module/schedule/writer.d.ts.map +1 -0
  617. package/lib/typescript/module/state/caps.d.ts +51 -0
  618. package/lib/typescript/module/state/caps.d.ts.map +1 -0
  619. package/lib/typescript/module/state/dedup-ledger.d.ts +21 -0
  620. package/lib/typescript/module/state/dedup-ledger.d.ts.map +1 -0
  621. package/lib/typescript/module/state/interaction-buffer.d.ts +30 -0
  622. package/lib/typescript/module/state/interaction-buffer.d.ts.map +1 -0
  623. package/lib/typescript/module/state/mmkv-store.d.ts +33 -0
  624. package/lib/typescript/module/state/mmkv-store.d.ts.map +1 -0
  625. package/lib/typescript/module/state/permission-history.d.ts +20 -0
  626. package/lib/typescript/module/state/permission-history.d.ts.map +1 -0
  627. package/lib/typescript/module/state/record.d.ts +134 -0
  628. package/lib/typescript/module/state/record.d.ts.map +1 -0
  629. package/lib/typescript/module/state/reset.d.ts +22 -0
  630. package/lib/typescript/module/state/reset.d.ts.map +1 -0
  631. package/lib/typescript/module/state/series-ledger.d.ts +47 -0
  632. package/lib/typescript/module/state/series-ledger.d.ts.map +1 -0
  633. package/lib/typescript/module/state/store.d.ts +20 -0
  634. package/lib/typescript/module/state/store.d.ts.map +1 -0
  635. package/lib/typescript/module/testing/conformance/index.d.ts +32 -0
  636. package/lib/typescript/module/testing/conformance/index.d.ts.map +1 -0
  637. package/lib/typescript/module/testing/fake-engine.d.ts +91 -0
  638. package/lib/typescript/module/testing/fake-engine.d.ts.map +1 -0
  639. package/lib/typescript/module/testing/fake-provider.d.ts +35 -0
  640. package/lib/typescript/module/testing/fake-provider.d.ts.map +1 -0
  641. package/lib/typescript/module/testing/faults.d.ts +38 -0
  642. package/lib/typescript/module/testing/faults.d.ts.map +1 -0
  643. package/lib/typescript/module/testing/index.d.ts +22 -0
  644. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  645. package/lib/typescript/module/testing/measure.d.ts +59 -0
  646. package/lib/typescript/module/testing/measure.d.ts.map +1 -0
  647. package/package.json +72 -26
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Series registration and the lookahead window.
5
+ *
6
+ * A caller declares a rule once. The package expands it inside a finite window
7
+ * and refreshes that window on its own, because only it knows when the horizon
8
+ * has moved — that is the one piece of recurrence knowledge the consumer does
9
+ * not have.
10
+ *
11
+ * Occurrences carry derived identifiers, so re-expanding a series recognises
12
+ * what it already scheduled instead of creating duplicates. That is what makes
13
+ * a window refresh with nothing to do cost zero platform operations.
14
+ *
15
+ * Occurrences are written through the shared `ScheduleWriter`, like every other
16
+ * consumer notification, so a repeating tone gets its stop marker and the
17
+ * platform ceiling is respected here too.
18
+ */
19
+
20
+ import { partsInZone } from "../schedule/anchor.js";
21
+ import { validateIdentifier } from "../schedule/validate-identifier.js";
22
+ import { validateRequest } from "../schedule/index.js";
23
+ import { createScheduleWriter } from "../schedule/writer.js";
24
+ import { DIAGNOSTIC_CODES, NotificationError } from "../contract/errors.js";
25
+ import { expand, occurrenceKey } from "./expand.js";
26
+ import { guardAgainstClockChange } from "./clock-guard.js";
27
+ import { listSeries as readLedger, readSeries, removeSeries, upsertSeries } from "../state/series-ledger.js";
28
+ /** Builds the request for one occurrence from the series template. */
29
+ function toRequest(rule, occurrence) {
30
+ return {
31
+ id: occurrence.id,
32
+ content: rule.template.content,
33
+ tone: rule.template.tone,
34
+ moment: {
35
+ at: occurrence.at,
36
+ anchoring: occurrence.anchoring
37
+ },
38
+ routing: rule.template.routing,
39
+ actions: rule.template.actions,
40
+ ownerTag: rule.template.ownerTag,
41
+ groupTag: rule.template.groupTag
42
+ };
43
+ }
44
+ const belongsTo = (entry, seriesId) => entry.seriesId === seriesId || entry.id.startsWith(`${seriesId}#`);
45
+
46
+ /**
47
+ * The latest occurrence a ledger entry written before 0.4.0 had emitted. Those
48
+ * entries kept no key, so it is read back off the device: the last occurrence
49
+ * still pending is the last one emitted.
50
+ */
51
+ function recoverLastEmittedKey(pending, anchoring, zone) {
52
+ if (pending.length === 0) return undefined;
53
+ const latest = Math.max(...pending.map(entry => entry.resolvedAt));
54
+ return occurrenceKey(partsInZone(latest, anchoring === 'absolute' ? 'UTC' : zone));
55
+ }
56
+ export function createRecurrence(deps) {
57
+ const emit = deps.emit ?? (() => {});
58
+ const writer = createScheduleWriter(deps.engine);
59
+
60
+ /**
61
+ * Validates the template as the request every occurrence will be, once, so
62
+ * a series is refused at registration for exactly what a direct schedule
63
+ * would be refused for — an undeclared tone, too many actions, an oversized
64
+ * routing payload — rather than failing later inside maintenance.
65
+ */
66
+ const validateTemplate = rule => validateRequest({
67
+ id: rule.id,
68
+ content: rule.template.content,
69
+ tone: rule.template.tone,
70
+ moment: {
71
+ at: deps.now(),
72
+ anchoring: rule.anchoring ?? 'wallClock'
73
+ },
74
+ routing: rule.template.routing,
75
+ actions: rule.template.actions,
76
+ ownerTag: rule.template.ownerTag,
77
+ groupTag: rule.template.groupTag
78
+ }, deps.resolveTone);
79
+ const toneFor = rule => {
80
+ const tone = deps.resolveTone(rule.template.tone);
81
+ if (tone === undefined) {
82
+ throw new NotificationError(DIAGNOSTIC_CODES.UNDECLARED_TONE, `Tone "${rule.template.tone}" was never declared in the package configuration.`, {
83
+ toneId: rule.template.tone,
84
+ seriesId: rule.id
85
+ });
86
+ }
87
+ return tone;
88
+ };
89
+
90
+ /** Expands and registers, scheduling only occurrences the device lacks. */
91
+ const materialize = async (rule, tone) => {
92
+ const now = deps.now();
93
+ const zone = deps.timeZone();
94
+ const previous = readSeries(deps.state, rule.id);
95
+ const pending = await deps.engine.getPending();
96
+ const ofSeries = pending.filter(entry => belongsTo(entry, rule.id));
97
+ const expansion = expand({
98
+ rule,
99
+ from: now,
100
+ lookahead: deps.lookahead,
101
+ timeZone: zone,
102
+ alreadyEmitted: previous?.emittedCount ?? 0,
103
+ lastEmittedKey: previous?.lastEmittedKey ?? (previous !== undefined ? recoverLastEmittedKey(ofSeries, rule.anchoring, zone) : undefined)
104
+ });
105
+ const guarded = guardAgainstClockChange({
106
+ occurrences: expansion.occurrences,
107
+ previousHorizon: previous?.expandedThrough,
108
+ now,
109
+ previousNow: previous?.at
110
+ });
111
+ if (guarded.discontinuity !== 'none') {
112
+ emit('CLOCK_DISCONTINUITY', `Device clock moved ${guarded.discontinuity}; ${guarded.suppressed} already-handled occurrence(s) were suppressed rather than re-delivered.`, {
113
+ direction: guarded.discontinuity,
114
+ suppressed: guarded.suppressed,
115
+ seriesId: rule.id
116
+ });
117
+ }
118
+ const wanted = new Set(guarded.occurrences.map(occurrence => occurrence.id));
119
+
120
+ // Upcoming entries of this series the expansion no longer produces: ones
121
+ // written under the instant-based identity before 0.4.0, or ones whose slot
122
+ // the rule no longer has. Left in place, each would fire beside its
123
+ // replacement. Entries already due are left alone — they may be firing now.
124
+ const stale = ofSeries.filter(entry => !wanted.has(entry.id) && entry.resolvedAt > now);
125
+ for (const entry of stale) {
126
+ await writer.cancel(entry.id);
127
+ }
128
+ const onDevice = new Set(ofSeries.filter(entry => !stale.includes(entry)).map(entry => entry.id));
129
+ const missing = guarded.occurrences.filter(occurrence => !onDevice.has(occurrence.id));
130
+
131
+ // The same ceiling reconciliation respects: soonest first, the rest
132
+ // registered by a later refresh once they move into range.
133
+ const room = Math.max(0, (await writer.capacity()) - (pending.length - stale.length));
134
+ const toSchedule = missing.slice(0, room);
135
+ if (toSchedule.length < missing.length) {
136
+ emit(DIAGNOSTIC_CODES.TRUNCATED_OVER_CEILING, `Series "${rule.id}" has ${missing.length - toSchedule.length} occurrence(s) beyond the platform ceiling; they are registered by a later window refresh.`, {
137
+ seriesId: rule.id,
138
+ dropped: missing.length - toSchedule.length
139
+ });
140
+ }
141
+ const approximate = !deps.canScheduleExactly();
142
+ for (const occurrence of toSchedule) {
143
+ await writer.write({
144
+ request: toRequest(rule, occurrence),
145
+ resolvedAt: occurrence.at,
146
+ tone,
147
+ // The zone the series was expanded against; absent for absolute series.
148
+ anchoringGeneration: occurrence.anchoring === 'absolute' ? undefined : zone,
149
+ approximate,
150
+ seriesId: rule.id
151
+ });
152
+ }
153
+
154
+ // Counted once, when first emitted — whether or not the ceiling let it on
155
+ // the device yet. Occurrences re-produced from an earlier expansion are not
156
+ // counted again.
157
+ const newlyEmitted = guarded.occurrences.filter(occurrence => !occurrence.previouslyEmitted);
158
+ const lastEmittedKey = newlyEmitted.length > 0 ? newlyEmitted[newlyEmitted.length - 1].key : previous?.lastEmittedKey;
159
+ upsertSeries(deps.state, rule, {
160
+ expandedThrough: expansion.expandedThrough,
161
+ emittedCount: (previous?.emittedCount ?? 0) + newlyEmitted.length,
162
+ exhausted: expansion.exhausted,
163
+ lastEmittedKey
164
+ }, now);
165
+ return {
166
+ seriesId: rule.id,
167
+ scheduled: toSchedule.length,
168
+ expandedThrough: expansion.expandedThrough,
169
+ exhausted: expansion.exhausted,
170
+ cancelled: stale.map(entry => entry.id)
171
+ };
172
+ };
173
+ return {
174
+ async registerSeries(rule) {
175
+ validateIdentifier(rule.id, 'seriesId');
176
+ return materialize(rule, validateTemplate(rule));
177
+ },
178
+ /** Re-expands a tracked series. Called by the window-refresh maintenance step. */
179
+ async refreshSeries(rule) {
180
+ return materialize(rule, toneFor(rule));
181
+ },
182
+ async cancelSeries(seriesId) {
183
+ validateIdentifier(seriesId, 'seriesId');
184
+
185
+ // Every occurrence already scheduled from this series goes, identified by
186
+ // its derived prefix rather than by a list the ledger would have to keep
187
+ // in sync with the device.
188
+ const pending = await deps.engine.getPending();
189
+ const ids = pending.filter(entry => belongsTo(entry, seriesId)).map(entry => entry.id);
190
+ await deps.engine.cancelMany(ids);
191
+ const pass = writer.pass();
192
+ for (const id of ids) await pass.releaseStop(id);
193
+ removeSeries(deps.state, seriesId);
194
+ return ids;
195
+ },
196
+ async listSeries() {
197
+ const pending = await deps.engine.getPending();
198
+ return readLedger(deps.state).map(entry => ({
199
+ seriesId: entry.seriesId,
200
+ anchoring: entry.anchoring,
201
+ expandedThrough: entry.expandedThrough,
202
+ pendingOccurrences: pending.filter(p => belongsTo(p, entry.seriesId)).length,
203
+ exhausted: entry.exhausted
204
+ }));
205
+ }
206
+ };
207
+ }
208
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["partsInZone","validateIdentifier","validateRequest","createScheduleWriter","DIAGNOSTIC_CODES","NotificationError","expand","occurrenceKey","guardAgainstClockChange","listSeries","readLedger","readSeries","removeSeries","upsertSeries","toRequest","rule","occurrence","id","content","template","tone","moment","at","anchoring","routing","actions","ownerTag","groupTag","belongsTo","entry","seriesId","startsWith","recoverLastEmittedKey","pending","zone","length","undefined","latest","Math","max","map","resolvedAt","createRecurrence","deps","emit","writer","engine","validateTemplate","now","resolveTone","toneFor","UNDECLARED_TONE","toneId","materialize","timeZone","previous","state","getPending","ofSeries","filter","expansion","from","lookahead","alreadyEmitted","emittedCount","lastEmittedKey","guarded","occurrences","previousHorizon","expandedThrough","previousNow","discontinuity","suppressed","direction","wanted","Set","stale","has","cancel","onDevice","includes","missing","room","capacity","toSchedule","slice","TRUNCATED_OVER_CEILING","dropped","approximate","canScheduleExactly","write","request","anchoringGeneration","newlyEmitted","previouslyEmitted","key","exhausted","scheduled","cancelled","registerSeries","refreshSeries","cancelSeries","ids","cancelMany","pass","releaseStop","pendingOccurrences","p"],"sourceRoot":"../../../src","sources":["recurrence/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,WAAW,QAA6B,uBAAoB;AACrE,SAASC,kBAAkB,QAAQ,oCAAiC;AACpE,SAASC,eAAe,QAAQ,sBAAa;AAC7C,SAASC,oBAAoB,QAAQ,uBAAoB;AACzD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,uBAAoB;AACxE,SAASC,MAAM,EAAEC,aAAa,QAAyB,aAAU;AACjE,SAASC,uBAAuB,QAAQ,kBAAe;AACvD,SACCC,UAAU,IAAIC,UAAU,EACxBC,UAAU,EACVC,YAAY,EACZC,YAAY,QACN,2BAAwB;AAa/B;AACA,SAASC,SAASA,CAACC,IAAoB,EAAEC,UAAsB,EAAuB;EACrF,OAAO;IACNC,EAAE,EAAED,UAAU,CAACC,EAAE;IACjBC,OAAO,EAAEH,IAAI,CAACI,QAAQ,CAACD,OAAO;IAC9BE,IAAI,EAAEL,IAAI,CAACI,QAAQ,CAACC,IAAI;IACxBC,MAAM,EAAE;MAAEC,EAAE,EAAEN,UAAU,CAACM,EAAE;MAAEC,SAAS,EAAEP,UAAU,CAACO;IAAU,CAAC;IAC9DC,OAAO,EAAET,IAAI,CAACI,QAAQ,CAACK,OAAO;IAC9BC,OAAO,EAAEV,IAAI,CAACI,QAAQ,CAACM,OAAO;IAC9BC,QAAQ,EAAEX,IAAI,CAACI,QAAQ,CAACO,QAAQ;IAChCC,QAAQ,EAAEZ,IAAI,CAACI,QAAQ,CAACQ;EACzB,CAAC;AACF;AAEA,MAAMC,SAAS,GAAGA,CAACC,KAAmB,EAAEC,QAAgB,KACvDD,KAAK,CAACC,Q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AAC;;MAExC;MACA;MACA;MACA,MAAMG,OAAO,GAAG,MAAMU,IAAI,CAACG,MAAM,CAACW,UAAU,CAAC,CAAC;MAC9C,MAAM6C,GAAG,GAAGrE,OAAO,CAAC0B,MAAM,CAAC9B,KAAK,IAAID,SAAS,CAACC,KAAK,EAAEC,QAAQ,CAAC,CAAC,CAACU,GAAG,CAACX,KAAK,IAAIA,KAAK,CAACZ,EAAE,CAAC;MAEtF,MAAM0B,IAAI,CAACG,MAAM,CAACyD,UAAU,CAACD,GAAG,CAAC;MACjC,MAAME,IAAI,GAAG3D,MAAM,CAAC2D,IAAI,CAAC,CAAC;MAC1B,KAAK,MAAMvF,EAAE,IAAIqF,GAAG,EAAE,MAAME,IAAI,CAACC,WAAW,CAACxF,EAAE,CAAC;MAChDL,YAAY,CAAC+B,IAAI,CAACa,KAAK,EAAE1B,QAAQ,CAAC;MAClC,OAAOwE,GAAG;IACX,CAAC;IAED,MAAM7F,UAAUA,CAAA,EAAsC;MACrD,MAAMwB,OAAO,GAAG,MAAMU,IAAI,CAACG,MAAM,CAACW,UAAU,CAAC,CAAC;MAE9C,OAAO/C,UAAU,CAACiC,IAAI,CAACa,KAAK,CAAC,CAAChB,GAAG,CAACX,KAAK,KAAK;QAC3CC,QAAQ,EAAED,KAAK,CAACC,QAAQ;QACxBP,SAAS,EAAEM,KAAK,CAACN,SAAS;QAC1B8C,eAAe,EAAExC,KAAK,CAACwC,eAAe;QACtCqC,kBAAkB,EAAEzE,OAAO,CAAC0B,MAAM,CAACgD,CAAC,IAAI/E,SAAS,CAAC+E,CAAC,EAAE9E,KAAK,CAACC,QAAQ,CAAC,CAAC,CAACK,MAAM;QAC5E6D,SAAS,EAAEnE,KAAK,CAACmE;MAClB,CAAC,CAAC,CAAC;IACJ;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Repeat expiry.
5
+ *
6
+ * When a stop marker is delivered, the alert it guards has run its declared
7
+ * course. This handler ends the sound and leaves the notification exactly where
8
+ * it is, then removes the marker.
9
+ *
10
+ * Nothing here imports the engine. It talks to the port, which is what lets the
11
+ * whole mechanism be proven on a virtual clock with no device.
12
+ */
13
+
14
+ import { createStopPlacement } from "./place.js";
15
+ export function createRepeatExpiryHandler(deps) {
16
+ return {
17
+ async handle(event) {
18
+ const stop = event.repeatStop;
19
+ if (stop === undefined) return;
20
+
21
+ // Order matters. Silence first, remove the marker second: if the
22
+ // process dies between the two, a marker left behind is harmless
23
+ // noise, whereas a device left sounding is the failure this exists to
24
+ // prevent.
25
+ //
26
+ // `silenceDelivered` returning false is the ordinary case, not an
27
+ // error — it means the user already handled the notification. Checking
28
+ // the tray rather than racing to cancel the marker on interaction is
29
+ // what makes early handling correct by construction: even if the marker
30
+ // fires, there is nothing left to act on.
31
+ await deps.engine.silenceDelivered(stop.targetId);
32
+ await deps.engine.cancel(stop.markerId);
33
+ },
34
+ release: targetId => createStopPlacement(deps.engine).release(targetId)
35
+ };
36
+ }
37
+ //# sourceMappingURL=expiry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createStopPlacement","createRepeatExpiryHandler","deps","handle","event","stop","repeatStop","undefined","engine","silenceDelivered","targetId","cancel","markerId","release"],"sourceRoot":"../../../src","sources":["repeat/expiry.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,mBAAmB,QAAQ,YAAS;AAc7C,OAAO,SAASC,yBAAyBA,CAACC,IAA8B,EAAuB;EAC9F,OAAO;IACN,MAAMC,MAAMA,CAACC,KAAoB,EAAiB;MACjD,MAAMC,IAAI,GAAGD,KAAK,CAACE,UAAU;MAC7B,IAAID,IAAI,KAAKE,SAAS,EAAE;;MAExB;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,MAAML,IAAI,CAACM,MAAM,CAACC,gBAAgB,CAACJ,IAAI,CAACK,QAAQ,CAAC;MACjD,MAAMR,IAAI,CAACM,MAAM,CAACG,MAAM,CAACN,IAAI,CAACO,QAAQ,CAAC;IACxC,CAAC;IAEDC,OAAO,EAAEH,QAAQ,IAAIV,mBAAmB,CAACE,IAAI,CAACM,MAAM,CAAC,CAACK,OAAO,CAACH,QAAQ;EACvE,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Repeat expiry — bounding an alert that repeats until it is handled.
5
+ *
6
+ * The one piece of this package a consumer has to wire up themselves. The
7
+ * engine registers its background task at module scope, outside the React tree,
8
+ * and no library can perform that registration on an app's behalf.
9
+ *
10
+ * An app that declares no repeating tone needs none of this.
11
+ */
12
+
13
+ import { buffer } from "../state/interaction-buffer.js";
14
+ import { StateManager } from "../state/record.js";
15
+ import { createRepeatExpiryHandler } from "./expiry.js";
16
+ export { createRepeatExpiryHandler } from "./expiry.js";
17
+ export { REPEAT_STOP_PREFIX, isRepeatStopId, markerIdFor, repeatStopFor } from "./marker.js";
18
+ /**
19
+ * Registers the handler that ends a repeating alert while the app is dead.
20
+ *
21
+ * Call this at module scope in `index.js`, beside the app registration — not
22
+ * inside a component, and not inside an effect. By the time a component mounts,
23
+ * the process that needed this handler has already been asked to run it.
24
+ *
25
+ * Without it a repeating alert still starts and still stops when the user
26
+ * handles it, but nothing ends it on a device left face-down on a table. That
27
+ * is the whole reason the feature exists, so `apply()` reports its absence
28
+ * rather than letting anyone find out the hard way.
29
+ */
30
+ export function registerBackgroundNotificationHandler(registration) {
31
+ const handler = createRepeatExpiryHandler(registration);
32
+ const keep = event => {
33
+ if (registration.store === undefined) return;
34
+ // A manager of its own: this runs in a process with no runtime, and the
35
+ // runtime created later loads what is written here.
36
+ buffer(new StateManager({
37
+ store: registration.store,
38
+ now: registration.now ?? (() => Date.now())
39
+ }), event);
40
+ };
41
+ registration.engine.registerBackgroundDeliveryHandler(event => handler.handle(event), async event => {
42
+ if (registration.onInteraction === undefined) {
43
+ keep(event);
44
+ return;
45
+ }
46
+ try {
47
+ await registration.onInteraction(event);
48
+ } catch {
49
+ // The app's handler failed; the interaction is kept rather than lost.
50
+ keep(event);
51
+ }
52
+ });
53
+
54
+ // Both paths, not just the background one. The engine routes a delivery to
55
+ // the foreground listener while the app is alive and to the headless task
56
+ // only when it is not — so registering only the latter leaves the alert
57
+ // sounding for anyone holding the phone when the window runs out, which is
58
+ // the one case they would certainly notice.
59
+ registration.engine.subscribeToDeliveries(event => {
60
+ // Deliberately not awaited: the engine's foreground listener is
61
+ // synchronous, and a rejection here must not take the subscription down
62
+ // with it — a handler that stopped listening would leave every later
63
+ // alarm unbounded.
64
+ handler.handle(event).catch(() => {});
65
+ });
66
+ }
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["buffer","StateManager","createRepeatExpiryHandler","REPEAT_STOP_PREFIX","isRepeatStopId","markerIdFor","repeatStopFor","registerBackgroundNotificationHandler","registration","handler","keep","event","store","undefined","now","Date","engine","registerBackgroundDeliveryHandler","handle","onInteraction","subscribeToDeliveries","catch"],"sourceRoot":"../../../src","sources":["repeat/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,MAAM,QAAQ,gCAA6B;AACpD,SAASC,YAAY,QAAQ,oBAAiB;AAE9C,SAASC,yBAAyB,QAAQ,aAAU;AAEpD,SAASA,yBAAyB,QAAQ,aAAU;AAEpD,SAASC,kBAAkB,EAAEC,cAAc,EAAEC,WAAW,EAAEC,aAAa,QAAQ,aAAU;AAuBzF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qCAAqCA,CACpDC,YAA2C,EACpC;EACP,MAAMC,OAAO,GAAGP,yBAAyB,CAACM,YAAY,CAAC;EAEvD,MAAME,IAAI,GAAIC,KAAuB,IAAW;IAC/C,IAAIH,YAAY,CAACI,KAAK,KAAKC,SAAS,EAAE;IACtC;IACA;IACAb,MAAM,CACL,IAAIC,YAAY,CAAC;MAAEW,KAAK,EAAEJ,YAAY,CAACI,KAAK;MAAEE,GAAG,EAAEN,YAAY,CAACM,GAAG,KAAK,MAAMC,IAAI,CAACD,GAAG,CAAC,CAAC;IAAE,CAAC,CAAC,EAC5FH,KACD,CAAC;EACF,CAAC;EAEDH,YAAY,CAACQ,MAAM,CAACC,iCAAiC,CACpDN,KAAK,IAAIF,OAAO,CAACS,MAAM,CAACP,KAAK,CAAC,EAC9B,MAAMA,KAAK,IAAI;IACd,IAAIH,YAAY,CAACW,aAAa,KAAKN,SAAS,EAAE;MAC7CH,IAAI,CAACC,KAAK,CAAC;MACX;IACD;IACA,IAAI;MACH,MAAMH,YAAY,CAACW,aAAa,CAACR,KAAK,CAAC;IACxC,CAAC,CAAC,MAAM;MACP;MACAD,IAAI,CAACC,KAAK,CAAC;IACZ;EACD,CACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACAH,YAAY,CAACQ,MAAM,CAACI,qBAAqB,CAACT,KAAK,IAAI;IAClD;IACA;IACA;IACA;IACAF,OAAO,CAACS,MAAM,CAACP,KAAK,CAAC,CAACU,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;EACtC,CAAC,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Stop-marker identity.
5
+ *
6
+ * A repeating alert has to end without the app being alive, and no platform
7
+ * offers "stop the sound at time T but keep the notification". So the package
8
+ * schedules its own notification at T and reacts to its delivery. That
9
+ * notification is a *marker*: it exists to be delivered and immediately
10
+ * removed, never to be read.
11
+ *
12
+ * The marker's identifier is derived from the target's by hashing rather than by
13
+ * concatenation. Concatenation would overflow the package's 128-character
14
+ * identifier limit for any target already near it, and would make the marker's
15
+ * identity a function of a value the consumer controls — which is how a
16
+ * consumer identifier ends up colliding with an internal one.
17
+ */
18
+
19
+ import { fnv1a, hex8 } from "../contract/hash.js";
20
+ /**
21
+ * Reserved identifier namespace.
22
+ *
23
+ * Rejected as a consumer identifier prefix. A consumer id colliding with a
24
+ * marker would not merely confuse a listing: the expiry handler cancels
25
+ * markers, so the collision would delete a real notification.
26
+ */
27
+ export const REPEAT_STOP_PREFIX = 'cms.stop:';
28
+
29
+ /**
30
+ * The marker identifier for a target notification.
31
+ *
32
+ * Two independent hashes rather than one: a single 32-bit hash collides often
33
+ * enough to matter once a device holds a handful of alarms, and a collision here
34
+ * means one alarm's marker silences the other alarm and never silences its own.
35
+ */
36
+ export function markerIdFor(targetId) {
37
+ return `${REPEAT_STOP_PREFIX}${hex8(fnv1a(targetId, 0x811c9dc5))}${hex8(fnv1a(targetId, 0x9e3779b9))}`;
38
+ }
39
+ export function isRepeatStopId(id) {
40
+ return id.startsWith(REPEAT_STOP_PREFIX);
41
+ }
42
+
43
+ /** Describes the stop for a target whose alert must end at a known instant. */
44
+ export function repeatStopFor(targetId, deliveredAt, forMs) {
45
+ return {
46
+ markerId: markerIdFor(targetId),
47
+ targetId,
48
+ dueAt: deliveredAt + forMs
49
+ };
50
+ }
51
+ //# sourceMappingURL=marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fnv1a","hex8","REPEAT_STOP_PREFIX","markerIdFor","targetId","isRepeatStopId","id","startsWith","repeatStopFor","deliveredAt","forMs","markerId","dueAt"],"sourceRoot":"../../../src","sources":["repeat/marker.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,EAAEC,IAAI,QAAQ,qBAAkB;AAG9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAG,WAAW;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,QAAgB,EAAU;EACrD,OAAO,GAAGF,kBAAkB,GAAGD,IAAI,CAACD,KAAK,CAACI,QAAQ,EAAE,UAAU,CAAC,CAAC,GAAGH,IAAI,CAACD,KAAK,CAACI,QAAQ,EAAE,UAAU,CAAC,CAAC,EAAE;AACvG;AAEA,OAAO,SAASC,cAAcA,CAACC,EAAU,EAAW;EACnD,OAAOA,EAAE,CAACC,UAAU,CAACL,kBAAkB,CAAC;AACzC;;AAEA;AACA,OAAO,SAASM,aAAaA,CAACJ,QAAgB,EAAEK,WAAmB,EAAEC,KAAa,EAAc;EAC/F,OAAO;IACNC,QAAQ,EAAER,WAAW,CAACC,QAAQ,CAAC;IAC/BA,QAAQ;IACRQ,KAAK,EAAEH,WAAW,GAAGC;EACtB,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Keeping a notification's stop marker in step with the notification.
5
+ *
6
+ * Shared by the scheduler and the reconciler rather than written twice. They are
7
+ * two doors into the same act — reconciliation is how most consumers schedule —
8
+ * and a bound that only existed on one path would be a bound that mostly did not
9
+ * exist.
10
+ */
11
+
12
+ import { repeatStopFor } from "./marker.js";
13
+ export function createStopPlacement(engine) {
14
+ /** `snapshot`: read once and kept current, for a pass; otherwise read on every call. */
15
+ function placement(snapshot) {
16
+ let known;
17
+
18
+ /** targetId → markerId of every outstanding stop. */
19
+ const outstanding = async () => {
20
+ if (snapshot && known) {
21
+ return known;
22
+ }
23
+ const read = new Map((await engine.listRepeatStops()).map(stop => [stop.targetId, stop.markerId]));
24
+ if (snapshot) {
25
+ known = read;
26
+ }
27
+ return read;
28
+ };
29
+ const release = async targetId => {
30
+ const stops = await outstanding();
31
+ const markerId = stops.get(targetId);
32
+ if (markerId !== undefined) {
33
+ await engine.cancel(markerId);
34
+ stops.delete(targetId);
35
+ }
36
+ };
37
+ return {
38
+ release,
39
+ async count() {
40
+ return (await outstanding()).size;
41
+ },
42
+ async sync(targetId, tone, deliversAt) {
43
+ await release(targetId);
44
+ const forMs = tone.android.repeatForMs;
45
+ if (!tone.android.loopSound || forMs === undefined) return;
46
+ const capabilities = await engine.getCapabilities();
47
+ if (!capabilities.supportsRepeatingAlert) return;
48
+ const stop = repeatStopFor(targetId, deliversAt, forMs);
49
+ await engine.schedule({
50
+ request: {
51
+ id: stop.markerId,
52
+ // Deliberately empty. A marker is delivered and removed within the
53
+ // same handler invocation; anything readable here would be text a
54
+ // user might glimpse and be confused by.
55
+ content: {
56
+ title: '',
57
+ body: ''
58
+ },
59
+ tone: tone.toneId,
60
+ // Absolute: the bound is a duration from a known instant, not a
61
+ // wall-clock time that should follow the user across time zones.
62
+ moment: {
63
+ at: stop.dueAt,
64
+ anchoring: 'absolute'
65
+ }
66
+ },
67
+ resolvedAt: stop.dueAt,
68
+ tone,
69
+ approximate: false,
70
+ repeatStop: stop
71
+ });
72
+ known?.set(targetId, stop.markerId);
73
+ },
74
+ pass: () => placement(true)
75
+ };
76
+ }
77
+ return placement(false);
78
+ }
79
+ //# sourceMappingURL=place.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["repeatStopFor","createStopPlacement","engine","placement","snapshot","known","outstanding","read","Map","listRepeatStops","map","stop","targetId","markerId","release","stops","get","undefined","cancel","delete","count","size","sync","tone","deliversAt","forMs","android","repeatForMs","loopSound","capabilities","getCapabilities","supportsRepeatingAlert","schedule","request","id","content","title","body","toneId","moment","at","dueAt","anchoring","resolvedAt","approximate","repeatStop","set","pass"],"sourceRoot":"../../../src","sources":["repeat/place.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,aAAa,QAAQ,aAAU;AA8BxC,OAAO,SAASC,mBAAmBA,CAACC,MAAiC,EAAiB;EACrF;EACA,SAASC,SAASA,CAACC,QAAiB,EAAiB;IACpD,IAAIC,KAAsC;;IAE1C;IACA,MAAMC,WAAW,GAAG,MAAAA,CAAA,KAA0C;MAC7D,IAAIF,QAAQ,IAAIC,KAAK,EAAE;QACtB,OAAOA,KAAK;MACb;MACA,MAAME,IAAI,GAAG,IAAIC,GAAG,CACnB,CAAC,MAAMN,MAAM,CAACO,eAAe,CAAC,CAAC,EAAEC,GAAG,CAACC,IAAI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