@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,187 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.initialize = initialize;
7
+ exports.resolveLookahead = resolveLookahead;
8
+ exports.validateConfig = validateConfig;
9
+ var _rnCore = require("@chipmobilesdk/rn-core");
10
+ var _recurrence = require("./contract/recurrence.js");
11
+ var _errors = require("./contract/errors.js");
12
+ var _events = require("./diagnostics/events.js");
13
+ var _cycle = require("./maintenance/cycle.js");
14
+ var _toggle = require("./maintenance/toggle.js");
15
+ var _record = require("./state/record.js");
16
+ var _seriesLedger = require("./state/series-ledger.js");
17
+ var _migrate = require("./channel/migrate.js");
18
+ var _anchor = require("./schedule/anchor.js");
19
+ /**
20
+ * Package initialization.
21
+ *
22
+ * Composes the parts that must be in place before the first schedule call:
23
+ * validate configuration, load persisted state, apply tone declarations, run
24
+ * any pending channel migration, and start the maintenance registry.
25
+ *
26
+ * Budgeted at 100 ms of app startup, which is why state loading is synchronous
27
+ * and tone declaration is the only platform round-trip.
28
+ *
29
+ * Automatic maintenance is started here too: whatever steps are registered on
30
+ * `runtime.registry` run when the app returns to the foreground, with the
31
+ * trigger reported as `timeZoneChange` when the device zone moved meanwhile.
32
+ * Until 0.4.0 nothing ever called `runAutomatic`, so "automatic" maintenance
33
+ * only ran when the app invoked it by hand.
34
+ */
35
+
36
+ /** The slice of React Native's `AppState` the lifecycle observer uses. */
37
+
38
+ /** rn-core's shared lifecycle port in the observer's shape: one native subscription for every package (PERF-07). */
39
+ const sharedLifecycle = {
40
+ addEventListener: (_type, listener) => ({
41
+ remove: (0, _rnCore.appLifecycle)().subscribe(state => listener(state))
42
+ })
43
+ };
44
+
45
+ /** Everything assembled at initialization, shared by the operation modules. */
46
+
47
+ /**
48
+ * Clamps the lookahead into its documented bounds.
49
+ *
50
+ * Bounded on adjustment because the platform ceiling is not negotiable: a
51
+ * consumer asking for a five-year window would silently exhaust the 64-entry
52
+ * iOS ceiling on the first frequent series.
53
+ */
54
+ function resolveLookahead(partial) {
55
+ const days = partial?.days ?? _recurrence.DEFAULT_LOOKAHEAD.days;
56
+ const occurrencesPerSeries = partial?.occurrencesPerSeries ?? _recurrence.DEFAULT_LOOKAHEAD.occurrencesPerSeries;
57
+ return {
58
+ days: Math.min(Math.max(days, _recurrence.LOOKAHEAD_BOUNDS.minDays), _recurrence.LOOKAHEAD_BOUNDS.maxDays),
59
+ occurrencesPerSeries: Math.min(Math.max(occurrencesPerSeries, _recurrence.LOOKAHEAD_BOUNDS.minOccurrences), _recurrence.LOOKAHEAD_BOUNDS.maxOccurrences)
60
+ };
61
+ }
62
+
63
+ /** Fails before any platform call, so a bad configuration never half-applies. */
64
+ function validateConfig(config) {
65
+ if (config.tones.length === 0) {
66
+ throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.UNDECLARED_TONE, 'At least one tone must be declared before notifications can be scheduled.');
67
+ }
68
+ const seen = new Set();
69
+ for (const tone of config.tones) {
70
+ if (seen.has(tone.id)) {
71
+ throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.UNDECLARED_TONE, `Tone "${tone.id}" is declared more than once.`, {
72
+ toneId: tone.id
73
+ });
74
+ }
75
+ seen.add(tone.id);
76
+ if (!Number.isInteger(tone.version) || tone.version < 1) {
77
+ throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.CHANNEL_MIGRATION_REQUIRED, `Tone "${tone.id}" must carry an integer version of 1 or greater, because a channel configuration change is a migration rather than an assignment.`, {
78
+ toneId: tone.id,
79
+ version: tone.version
80
+ });
81
+ }
82
+ }
83
+ const groupIds = new Set((config.channelGroups ?? []).map(group => group.id));
84
+ for (const tone of config.tones) {
85
+ if (tone.groupId !== undefined && !groupIds.has(tone.groupId)) {
86
+ throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.UNDECLARED_TONE, `Tone "${tone.id}" references undeclared channel group "${tone.groupId}".`, {
87
+ toneId: tone.id,
88
+ groupId: tone.groupId
89
+ });
90
+ }
91
+ }
92
+ }
93
+ async function initialize(config, deps) {
94
+ const now = deps.now ?? (() => Date.now());
95
+ const startedAt = now();
96
+ validateConfig(config);
97
+ const emitter = new _events.DiagnosticEmitter({
98
+ sink: config.eventSink,
99
+ verbose: config.verboseDiagnostics,
100
+ now
101
+ });
102
+ const state = new _record.StateManager({
103
+ store: deps.store,
104
+ now,
105
+ emit: event => emitter.emit(event.code, describeStateEvent(event.code), event.context)
106
+ });
107
+ const channels = (0, _migrate.createChannels)({
108
+ engine: deps.engine,
109
+ state,
110
+ now,
111
+ // The channel module emits only DIAGNOSTIC_CODES values; its port types the
112
+ // code as a string so it stays usable without the emitter.
113
+ emit: (code, message, context) => emitter.emit(code, message, context)
114
+ });
115
+ // Declares groups and tones, and runs any version migration. An unchanged
116
+ // configuration costs no platform work, so doing this on every launch is free.
117
+ const applied = await channels.apply(config.tones, config.channelGroups ?? []);
118
+ const registry = new _cycle.MaintenanceRegistry({
119
+ clock: now
120
+ });
121
+ const maintenance = new _toggle.MaintenanceController({
122
+ registry,
123
+ now,
124
+ // Occurrence identifiers, not series identifiers. Maintenance cancels
125
+ // occurrences, so a set of series ids made every legitimate cancel look
126
+ // like a scope violation.
127
+ ownedIds: async () => (0, _seriesLedger.ownedIdentifiers)(state, (await deps.engine.getPending()).map(entry => entry.id)),
128
+ enabled: config.automaticMaintenance ?? true
129
+ });
130
+ const timeZone = deps.timeZone ?? (0, _anchor.createPlatformTimeZoneReader)();
131
+ let lastZone = timeZone();
132
+ let lastAutomatic;
133
+ const onAppState = next => {
134
+ if (next !== 'active') return;
135
+ const zone = timeZone();
136
+ const trigger = zone !== lastZone ? 'timeZoneChange' : 'foreground';
137
+ lastZone = zone;
138
+ maintenance.runAutomatic(trigger).then(result => {
139
+ if (result !== undefined) lastAutomatic = result;
140
+ }, error => {
141
+ // Nothing awaits an automatic cycle, so a failure is reported here or
142
+ // not at all.
143
+ emitter.emit(_errors.DIAGNOSTIC_CODES.MAINTENANCE_FAILED, `Automatic maintenance (${trigger}) failed: ${error instanceof Error ? error.name : 'unknown error'}.`, {
144
+ trigger
145
+ });
146
+ });
147
+ };
148
+ const subscription = (deps.appState ?? sharedLifecycle).addEventListener('change', onAppState);
149
+ const runtime = {
150
+ engine: deps.engine,
151
+ state,
152
+ emitter,
153
+ registry,
154
+ maintenance,
155
+ channels,
156
+ lookahead: resolveLookahead(config.lookahead),
157
+ config,
158
+ now,
159
+ lastAutomaticMaintenance: () => lastAutomatic,
160
+ dispose: () => subscription.remove()
161
+ };
162
+ return {
163
+ runtime,
164
+ result: {
165
+ tonesApplied: config.tones.length,
166
+ migrationsRun: applied.migrated.length,
167
+ stateRebuilt: state.health().rebuilt,
168
+ automaticMaintenance: maintenance.isEnabled,
169
+ durationMs: now() - startedAt
170
+ }
171
+ };
172
+ }
173
+ function describeStateEvent(code) {
174
+ switch (code) {
175
+ case _errors.DIAGNOSTIC_CODES.STATE_CORRUPT_REBUILT:
176
+ return 'Persisted state was unreadable and has been rebuilt. Deduplication history and buffered interactions from before the loss are gone; scheduled notifications are unaffected.';
177
+ case _errors.DIAGNOSTIC_CODES.STATE_WRITE_FAILED:
178
+ return 'Persisted state could not be written. The affected guarantee degrades to this session only.';
179
+ case _errors.DIAGNOSTIC_CODES.STATE_CAP_EVICTED:
180
+ return 'A persisted collection reached its cap and the oldest entries were evicted.';
181
+ case _errors.DIAGNOSTIC_CODES.INTERACTION_BUFFER_EVICTED:
182
+ return 'Buffered interactions were evicted at the cap or retention limit.';
183
+ default:
184
+ return 'Persisted state event.';
185
+ }
186
+ }
187
+ //# sourceMappingURL=initialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rnCore","require","_recurrence","_errors","_events","_cycle","_toggle","_record","_seriesLedger","_migrate","_anchor","sharedLifecycle","addEventListener","_type","listener","remove","appLifecycle","subscribe","state","resolveLookahead","partial","days","DEFAULT_LOOKAHEAD","occurrencesPerSeries","Math","min","max","LOOKAHEAD_BOUNDS","minDays","maxDays","minOccurrences","maxOccurrences","validateConfig","config","tones","length","NotificationError","DIAGNOSTIC_CODES","UNDECLARED_TONE","seen","Set","tone","has","id","toneId","add","Number","isInteger","version","CHANNEL_MIGRATION_REQUIRED","groupIds","channelGroups","map","group","groupId","undefined","initialize","deps","now","Date","startedAt","emitter","DiagnosticEmitter","sink","eventSink","verbose","verboseDiagnostics","StateManager","store","emit","event","code","describeStateEvent","context","channels","createChannels","engine","message","applied","apply","registry","MaintenanceRegistry","clock","maintenance","MaintenanceController","ownedIds","ownedIdentifiers","getPending","entry","enabled","automaticMaintenance","timeZone","createPlatformTimeZoneReader","lastZone","lastAutomatic","onAppState","next","zone","trigger","runAutomatic","then","result","error","MAINTENANCE_FAILED","Error","name","subscription","appState","runtime","lookahead","lastAutomaticMaintenance","dispose","tonesApplied","migrationsRun","migrated","stateRebuilt","health","rebuilt","isEnabled","durationMs","STATE_CORRUPT_REBUILT","STATE_WRITE_FAILED","STATE_CAP_EVICTED","INTERACTION_BUFFER_EVICTED"],"sourceRoot":"../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YAAY,GAAG,CAACjD,IAAI,CAACkD,QAAQ,IAAIhG,eAAe,EAAEC,gBAAgB,CAAC,QAAQ,EAAEmF,UAAU,CAAC;EAE9F,MAAMa,OAA4B,GAAG;IACpChC,MAAM,EAAEnB,IAAI,CAACmB,MAAM;IACnB1D,KAAK;IACL2C,OAAO;IACPmB,QAAQ;IACRG,WAAW;IACXT,QAAQ;IACRmC,SAAS,EAAE1F,gBAAgB,CAACc,MAAM,CAAC4E,SAAS,CAAC;IAC7C5E,MAAM;IACNyB,GAAG;IACHoD,wBAAwB,EAAEA,CAAA,KAAMhB,aAAa;IAC7CiB,OAAO,EAAEA,CAAA,KAAML,YAAY,CAAC3F,MAAM,CAAC;EACpC,CAAC;EAED,OAAO;IACN6F,OAAO;IACPP,MAAM,EAAE;MACPW,YAAY,EAAE/E,MAAM,CAACC,KAAK,CAACC,MAAM;MACjC8E,aAAa,EAAEnC,OAAO,CAACoC,QAAQ,CAAC/E,MAAM;MACtCgF,YAAY,EAAEjG,KAAK,CAACkG,MAAM,CAAC,CAAC,CAACC,OAAO;MACpC3B,oBAAoB,EAAEP,WAAW,CAACmC,SAAS;MAC3CC,UAAU,EAAE7D,GAAG,CAAC,CAAC,GAAGE;IACrB;EACD,CAAC;AACF;AAEA,SAASY,kBAAkBA,CAACD,IAAY,EAAU;EACjD,QAAQA,IAAI;IACX,KAAKlC,wBAAgB,CAACmF,qBAAqB;MAC1C,OAAO,6KAA6K;IACrL,KAAKnF,wBAAgB,CAACoF,kBAAkB;MACvC,OAAO,6FAA6F;IACrG,KAAKpF,wBAAgB,CAACqF,iBAAiB;MACtC,OAAO,6EAA6E;IACrF,KAAKrF,wBAAgB,CAACsF,0BAA0B;MAC/C,OAAO,mEAAmE;IAC3E;MACC,OAAO,wBAAwB;EACjC;AACD","ignoreList":[]}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createInteractions = createInteractions;
7
+ var _errors = require("../contract/errors.js");
8
+ var _interactionBuffer = require("../state/interaction-buffer.js");
9
+ /**
10
+ * Interaction routing.
11
+ *
12
+ * One handler covers foreground, background, and cold start. The hard case is
13
+ * the last one: the tap happens before any JavaScript exists to receive it, so
14
+ * the event has to wait — durably — until a handler registers.
15
+ *
16
+ * Events are delivered in occurrence order and never dropped for want of a
17
+ * listener. After delivery the notification leaves the tray, because a
18
+ * notification the user has already acted on sitting there is noise.
19
+ */
20
+
21
+ function createInteractions(deps) {
22
+ const emit = deps.emit ?? (() => {});
23
+ let handlers = [];
24
+ let engineSubscription;
25
+ /** Serializes delivery so rapid interactions arrive in order, never interleaved. */
26
+ let deliveryChain = Promise.resolve();
27
+ const deliver = event => {
28
+ deliveryChain = deliveryChain.then(async () => {
29
+ for (const handler of handlers) {
30
+ try {
31
+ await handler(event);
32
+ } catch {
33
+ // A consumer's handler failing must not stop the next event, or one
34
+ // bad tap would silently swallow every tap after it.
35
+ }
36
+ }
37
+
38
+ // Acted on, so it leaves the tray and stops making noise.
39
+ if (event.kind !== 'dismiss') {
40
+ await deps.engine.cancel(event.notificationId).catch(() => undefined);
41
+ }
42
+ });
43
+ };
44
+ const route = event => {
45
+ if (handlers.length === 0) {
46
+ (0, _interactionBuffer.buffer)(deps.state, event);
47
+ return;
48
+ }
49
+ deliver(event);
50
+ };
51
+ const ensureSubscribed = () => {
52
+ engineSubscription ??= deps.engine.subscribeToInteractions(route);
53
+ };
54
+
55
+ // Subscribing immediately rather than on first handler registration: an
56
+ // interaction arriving in the gap would otherwise be lost entirely, which is
57
+ // the exact failure the buffer exists to prevent.
58
+ ensureSubscribed();
59
+ return {
60
+ /**
61
+ * Registers a handler and immediately drains anything that was waiting.
62
+ *
63
+ * The drain is what makes a cold-start tap work: the event was persisted
64
+ * before this handler existed, possibly before this process existed.
65
+ */
66
+ onInteraction(handler) {
67
+ handlers.push(handler);
68
+ for (const event of (0, _interactionBuffer.drain)(deps.state)) {
69
+ deliver(event);
70
+ }
71
+ return () => {
72
+ handlers = handlers.filter(h => h !== handler);
73
+ };
74
+ },
75
+ /**
76
+ * Collects the interaction that launched the app, if any.
77
+ *
78
+ * Called once during startup. If no handler exists yet the event is
79
+ * buffered rather than discarded.
80
+ */
81
+ async collectInitial() {
82
+ const initial = await deps.engine.takeInitialInteraction();
83
+ if (initial === undefined) return;
84
+ route(initial);
85
+ },
86
+ /**
87
+ * Signals that a routing target no longer exists.
88
+ *
89
+ * The consumer chooses its own fallback screen. No platform error is ever
90
+ * shown to the user for this — a notification pointing at deleted data is
91
+ * an ordinary condition, not a crash.
92
+ */
93
+ reportTargetMissing(signal) {
94
+ emit(_errors.DIAGNOSTIC_CODES.TARGET_MISSING, 'The routing target no longer exists. The consumer chooses a fallback; no platform error is shown to the user.', {
95
+ notificationId: signal.notificationId
96
+ });
97
+ },
98
+ /** Reports that a background action exceeded the platform's execution window. */
99
+ reportBackgroundTimeout(notificationId, windowMs) {
100
+ emit(_errors.DIAGNOSTIC_CODES.BACKGROUND_WINDOW_EXCEEDED, `A background action exceeded the platform's ${windowMs} ms execution window and was cut short.`, {
101
+ notificationId,
102
+ windowMs
103
+ });
104
+ },
105
+ /** How many interactions are waiting for a handler. */
106
+ pendingCount() {
107
+ return (0, _interactionBuffer.bufferedCount)(deps.state);
108
+ },
109
+ /** Settles outstanding deliveries. Exists for tests and orderly shutdown. */
110
+ async flush() {
111
+ await deliveryChain;
112
+ },
113
+ dispose() {
114
+ engineSubscription?.();
115
+ engineSubscription = undefined;
116
+ handlers = [];
117
+ }
118
+ };
119
+ }
120
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","_interactionBuffer","createInteractions","deps","emit","handlers","engineSubscription","deliveryChain","Promise","resolve","deliver","event","then","handler","kind","engine","cancel","notificationId","catch","undefined","route","length","buffer","state","ensureSubscribed","subscribeToInteractions","onInteraction","push","drain","filter","h","collectInitial","initial","takeInitialInteraction","reportTargetMissing","signal","DIAGNOSTIC_CODES","TARGET_MISSING","reportBackgroundTimeout","windowMs","BACKGROUND_WINDOW_EXCEEDED","pendingCount","bufferedCount","flush","dispose"],"sourceRoot":"../../../src","sources":["interaction/index.ts"],"mappings":";;;;;;AAoBA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBO,SAASE,kBAAkBA,CAACC,IAA6B,EAAE;EACjE,MAAMC,IAAI,GAAGD,IAAI,CAACC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC;EACpC,IAAIC,QAA8B,GAAG,EAAE;EACvC,IAAIC,kBAA2C;EAC/C;EACA,IAAIC,aAA4B,GAAGC,OAAO,CAACC,OAAO,CAAC,CAAC;EAEpD,MAAMC,OAAO,GAAIC,KAAuB,IAAW;IAClDJ,aAAa,GAAGA,aAAa,CAACK,IAAI,CAAC,YAAY;MAC9C,KAAK,MAAMC,OAAO,IAAIR,QAAQ,EAAE;QAC/B,IAAI;UACH,MAAMQ,OAAO,CAACF,KAAK,CAAC;QACrB,CAAC,CAAC,MAAM;UACP;UACA;QAAA;MAEF;;MAEA;MACA,IAAIA,KAAK,CAACG,IAAI,KAAK,SAAS,EAAE;QAC7B,MAAMX,IAAI,CAACY,MAAM,CAACC,MAAM,CAACL,KAAK,CAACM,cAAc,CAAC,CAACC,KAAK,CAAC,MAAMC,SAAS,CAAC;MACtE;IACD,CAAC,CAAC;EACH,CAAC;EAED,MAAMC,KAAK,GAAIT,KAAuB,IAAW;IAChD,IAAIN,QAAQ,CAACgB,MAAM,KAAK,CAAC,EAAE;MAC1B,IAAAC,yBAAM,EAACnB,IAAI,CAACoB,KAAK,EAAEZ,KAAK,CAAC;MACzB;IACD;IACAD,OAAO,CAACC,KAAK,CAAC;EACf,CAAC;EAED,MAAMa,gBAAgB,GAAGA,CAAA,KAAY;IACpClB,kBAAkB,KAAKH,IAAI,CAACY,MAAM,CAACU,uBAAuB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AC;IAEDqC,OAAOA,CAAA,EAAS;MACftC,kBAAkB,GAAG,CAAC;MACtBA,kBAAkB,GAAGa,SAAS;MAC9Bd,QAAQ,GAAG,EAAE;IACd;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MaintenanceScopeViolation = exports.MaintenanceRegistry = void 0;
7
+ /**
8
+ * The automatic maintenance cycle.
9
+ *
10
+ * Covers exactly what only the package can know — window refresh, recurrence
11
+ * expansion, wall-clock re-anchoring, pending-set verification, permission
12
+ * re-reads. Full desired-set reconciliation is never automatic, because only
13
+ * the consumer knows what its data implies and a package that guessed would
14
+ * cancel notifications it does not understand.
15
+ *
16
+ * Steps register themselves here rather than being wired in a fixed order. That
17
+ * is what lets scheduling, reconciliation, recurrence, and permissions each
18
+ * contribute a step without importing one another.
19
+ *
20
+ * The rule that makes automatic work safe: a step may act only on notifications
21
+ * the package owns, and may never cancel anything else. It is enforced here
22
+ * rather than trusted to each step.
23
+ */
24
+
25
+ class MaintenanceScopeViolation extends Error {
26
+ constructor(step, offendingIds) {
27
+ super(`Maintenance step "${step}" attempted to cancel ${offendingIds.length} notification(s) it does not own. ` + 'Automatic maintenance may never cancel a directly-scheduled notification.');
28
+ this.name = 'MaintenanceScopeViolation';
29
+ this.step = step;
30
+ this.offendingIds = offendingIds;
31
+ Object.setPrototypeOf(this, MaintenanceScopeViolation.prototype);
32
+ }
33
+ }
34
+ exports.MaintenanceScopeViolation = MaintenanceScopeViolation;
35
+ class MaintenanceRegistry {
36
+ steps = [];
37
+ inFlight = null;
38
+ constructor(options = {}) {
39
+ this.clock = options.clock ?? (() => Date.now());
40
+ }
41
+ register(step) {
42
+ this.steps.push(step);
43
+ this.steps.sort((a, b) => a.order - b.order);
44
+ return () => {
45
+ this.steps = this.steps.filter(s => s !== step);
46
+ };
47
+ }
48
+ get registered() {
49
+ return this.steps.map(s => s.name);
50
+ }
51
+
52
+ /**
53
+ * Runs every registered step in order.
54
+ *
55
+ * Overlapping cycles are joined rather than queued or dropped: a second
56
+ * caller arriving mid-cycle wants the work the running cycle is already
57
+ * doing, so it waits for that cycle and gets its result. It used to get an
58
+ * empty result at once. Since `initialize` started running a cycle on every
59
+ * foreground, an app that ran maintenance and then reconciled on the same
60
+ * event got that empty result and reconciled while the window refresh was
61
+ * still writing: a reminder the reconcile cancelled could be scheduled again.
62
+ */
63
+ run(context) {
64
+ if (this.inFlight) {
65
+ return this.inFlight;
66
+ }
67
+ const cycle = this.runSteps(context).finally(() => {
68
+ if (this.inFlight === cycle) this.inFlight = null;
69
+ });
70
+ this.inFlight = cycle;
71
+ return cycle;
72
+ }
73
+ async runSteps(context) {
74
+ const started = context.now;
75
+ const clockStart = this.clock();
76
+ const aggregate = {
77
+ windowRefreshed: false,
78
+ occurrencesScheduled: 0,
79
+ reAnchored: 0,
80
+ timeZoneChanged: false,
81
+ permissionChanged: false,
82
+ operationCount: 0
83
+ };
84
+ let discrepancy;
85
+ for (const step of this.steps) {
86
+ const outcome = await step.run(context);
87
+ const offending = (outcome.cancelledIds ?? []).filter(id => !context.ownedIds.has(id));
88
+ if (offending.length > 0) {
89
+ throw new MaintenanceScopeViolation(step.name, offending);
90
+ }
91
+ aggregate.windowRefreshed ||= outcome.windowRefreshed ?? false;
92
+ aggregate.occurrencesScheduled += outcome.occurrencesScheduled ?? 0;
93
+ aggregate.reAnchored += outcome.reAnchored ?? 0;
94
+ aggregate.timeZoneChanged ||= outcome.timeZoneChanged ?? false;
95
+ aggregate.permissionChanged ||= outcome.permissionChanged ?? false;
96
+ aggregate.operationCount += outcome.operationCount ?? 0;
97
+ discrepancy ??= outcome.discrepancy;
98
+ }
99
+ return {
100
+ ranAt: started,
101
+ ...aggregate,
102
+ discrepancy,
103
+ durationMs: this.clock() - clockStart
104
+ };
105
+ }
106
+ }
107
+ exports.MaintenanceRegistry = MaintenanceRegistry;
108
+ //# sourceMappingURL=cycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MaintenanceScopeViolation","Error","constructor","step","offendingIds","length","name","Object","setPrototypeOf","prototype","exports","MaintenanceRegistry","steps","inFlight","options","clock","Date","now","register","push","sort","a","b","order","filter","s","registered","map","run","context","cycle","runSteps","finally","started","clockStart","aggregate","windowRefreshed","occurrencesScheduled","reAnchored","timeZoneChanged","permissionChanged","operationCount","discrepancy","outcome","offending","cancelledIds","id","ownedIds","has","ranAt","durationMs"],"sourceRoot":"../../../src","sources":["maintenance/cycle.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCO,MAAMA,yBAAyB,SAASC,KAAK,CAAC;EAIpDC,WAAWA,CAACC,IAAY,EAAEC,YAA+B,EAAE;IAC1D,KAAK,CACJ,qBAAqBD,IAAI,yBAAyBC,YAAY,CAACC,MAAM,oCAAoC,GACxG,2EACF,CAAC;IACD,IAAI,CAACC,IAAI,GAAG,2BAA2B;IACvC,IAAI,CAACH,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,YAAY,GAAGA,YAAY;IAChCG,MAAM,CAACC,cAAc,CAAC,IAAI,EAAER,yBAAyB,CAACS,SAAS,CAAC;EACjE;AACD;AAACC,OAAA,CAAAV,yBAAA,GAAAA,yBAAA;AAOM,MAAMW,mBAAmB,CAAC;EACxBC,KAAK,GAAsB,EAAE;EAC7BC,QAAQ,GAAsC,IAAI;EAG1DX,WAAWA,CAACY,OAAmC,GAAG,CAAC,CAAC,EAAE;IACrD,IAAI,CAACC,KAAK,GAAGD,OAAO,CAACC,KAAK,KAAK,MAAMC,IAAI,CAACC,GAAG,CAAC,CAAC,CAAC;EACjD;EAEAC,QAAQA,CAACf,IAAqB,EAAc;IAC3C,IAAI,CAACS,KAAK,CAACO,IAAI,CAAChB,IAAI,CAAC;IACrB,IAAI,CAACS,KAAK,CAACQ,IAAI,CAAC,CAACC,C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,CAACC,OAAO,CAAC;MAEvC,MAAMe,SAAS,GAAG,CAACD,OAAO,CAACE,YAAY,IAAI,EAAE,EAAErB,MAAM,CAACsB,EAAE,IAAI,CAACjB,OAAO,CAACkB,QAAQ,CAACC,GAAG,CAACF,EAAE,CAAC,CAAC;MACtF,IAAIF,SAAS,CAACvC,MAAM,GAAG,CAAC,EAAE;QACzB,MAAM,IAAIL,yBAAyB,CAACG,IAAI,CAACG,IAAI,EAAEsC,SAAS,CAAC;MAC1D;MAEAT,SAAS,CAACC,eAAe,KAAKO,OAAO,CAACP,eAAe,IAAI,KAAK;MAC9DD,SAAS,CAACE,oBAAoB,IAAIM,OAAO,CAACN,oBAAoB,IAAI,CAAC;MACnEF,SAAS,CAACG,UAAU,IAAIK,OAAO,CAACL,UAAU,IAAI,CAAC;MAC/CH,SAAS,CAACI,eAAe,KAAKI,OAAO,CAACJ,eAAe,IAAI,KAAK;MAC9DJ,SAAS,CAACK,iBAAiB,KAAKG,OAAO,CAACH,iBAAiB,IAAI,KAAK;MAClEL,SAAS,CAACM,cAAc,IAAIE,OAAO,CAACF,cAAc,IAAI,CAAC;MACvDC,WAAW,KAAKC,OAAO,CAACD,WAAW;IACpC;IAEA,OAAO;MAAEO,KAAK,EAAEhB,OAAO;MAAE,GAAGE,SAAS;MAAEO,WAAW;MAAEQ,UAAU,EAAE,IAAI,CAACnC,KAAK,CAAC,CAAC,GAAGmB;IAAW,CAAC;EAC5F;AACD;AAACxB,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PERMISSION_REFRESH_ORDER = void 0;
7
+ exports.createPermissionRefreshStep = createPermissionRefreshStep;
8
+ /**
9
+ * The permission re-read maintenance step.
10
+ *
11
+ * The user can change permission in system settings while the app is
12
+ * backgrounded, and the platform does not tell anyone. Re-reading on foreground
13
+ * is the only way a consumer's interface avoids showing a stale answer.
14
+ *
15
+ * Runs last (order 30): permission state does not affect what the earlier steps
16
+ * expand or re-anchor, and reading it after they have run means the report
17
+ * reflects the device as the cycle leaves it.
18
+ */
19
+
20
+ const PERMISSION_REFRESH_ORDER = exports.PERMISSION_REFRESH_ORDER = 30;
21
+ function createPermissionRefreshStep(deps) {
22
+ return {
23
+ name: 'permission-refresh',
24
+ order: PERMISSION_REFRESH_ORDER,
25
+ async run(_context) {
26
+ const {
27
+ changed
28
+ } = await deps.permissions.refresh();
29
+ return {
30
+ // Reading permission is not a platform mutation, so it never counts
31
+ // toward the zero-operation guarantee.
32
+ operationCount: 0,
33
+ permissionChanged: changed,
34
+ cancelledIds: []
35
+ };
36
+ }
37
+ };
38
+ }
39
+ //# sourceMappingURL=permission-refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PERMISSION_REFRESH_ORDER","exports","createPermissionRefreshStep","deps","name","order","run","_context","changed","permissions","refresh","operationCount","permissionChanged","cancelledIds"],"sourceRoot":"../../../src","sources":["maintenance/permission-refresh.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKO,MAAMA,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,EAAE;AAMnC,SAASE,2BAA2BA,CAACC,IAAmC,EAAmB;EACjG,OAAO;IACNC,IAAI,EAAE,oBAAoB;IAC1BC,KAAK,EAAEL,wBAAwB;IAE/B,MAAMM,GAAGA,CAACC,QAA4B,EAAwB;MAC7D,MAAM;QAAEC;MAAQ,CAAC,GAAG,MAAML,IAAI,CAACM,WAAW,CAACC,OAAO,CAAC,CAAC;MAEpD,OAAO;QACN;QACA;QACAC,cAAc,EAAE,CAAC;QACjBC,iBAAiB,EAAEJ,OAAO;QAC1BK,YAAY,EAAE;MACf,CAAC;IACF;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RE_ANCHOR_ORDER = void 0;
7
+ exports.createReAnchorStep = createReAnchorStep;
8
+ var _anchor = require("../schedule/anchor.js");
9
+ var _writer = require("../schedule/writer.js");
10
+ /**
11
+ * The re-anchoring maintenance step.
12
+ *
13
+ * Registers itself with the maintenance registry rather than being wired into
14
+ * a fixed sequence, which is what keeps scheduling independent of
15
+ * reconciliation, recurrence, and permissions despite all four contributing a
16
+ * step.
17
+ *
18
+ * Runs early (order 10) because verification compares firing instants: if
19
+ * verification ran first it would compare against instants re-anchoring is
20
+ * about to rewrite, and report discrepancies that do not exist.
21
+ */
22
+
23
+ const RE_ANCHOR_ORDER = exports.RE_ANCHOR_ORDER = 10;
24
+ function createReAnchorStep(deps) {
25
+ // Through the shared writer so a repeating alert's stop marker moves with it;
26
+ // written directly, the marker kept the old instant and cut the alert short
27
+ // or let it run past its bound.
28
+ const writer = (0, _writer.createScheduleWriter)(deps.engine);
29
+ return {
30
+ name: 'reanchor',
31
+ order: RE_ANCHOR_ORDER,
32
+ async run(_context) {
33
+ const zone = deps.timeZone();
34
+ const pending = await deps.engine.getPending();
35
+ const plan = (0, _anchor.planReAnchor)(pending, zone);
36
+
37
+ // The no-change path costs one comparison per entry and issues zero
38
+ // platform operations. That is what makes re-anchoring idempotent.
39
+ if (plan.rewrites.length === 0) {
40
+ return {
41
+ operationCount: 0,
42
+ reAnchored: 0,
43
+ timeZoneChanged: false
44
+ };
45
+ }
46
+ deps.emit?.('REANCHOR', `Device time zone changed from ${plan.fromZone ?? 'unknown'} to ${plan.toZone}; re-anchoring ${plan.rewrites.length} wall-clock notification(s).`, {
47
+ from: plan.fromZone,
48
+ to: plan.toZone,
49
+ count: plan.rewrites.length
50
+ });
51
+ let operationCount = 0;
52
+ for (const {
53
+ entry,
54
+ resolvedAt
55
+ } of plan.rewrites) {
56
+ const tone = deps.resolveTone(entry.tone);
57
+ if (tone === undefined) {
58
+ // A tone that no longer exists means this entry belongs to a
59
+ // configuration the app has since dropped. Leaving it alone is
60
+ // correct: re-anchoring must never repair, only preserve.
61
+ continue;
62
+ }
63
+ await writer.write({
64
+ request: {
65
+ id: entry.id,
66
+ content: entry.content,
67
+ tone: entry.tone,
68
+ moment: {
69
+ at: resolvedAt,
70
+ anchoring: 'wallClock'
71
+ },
72
+ routing: entry.routing,
73
+ actions: entry.actions,
74
+ ownerTag: entry.ownerTag,
75
+ groupTag: entry.groupTag
76
+ },
77
+ resolvedAt,
78
+ tone,
79
+ // Re-anchored against the zone the device is in now — this is the
80
+ // value that stops the entry being reported as stale next time.
81
+ anchoringGeneration: zone,
82
+ approximate: !deps.canScheduleExactly(),
83
+ seriesId: entry.seriesId,
84
+ pushCreated: entry.pushCreated
85
+ });
86
+ operationCount += 1;
87
+ }
88
+ return {
89
+ operationCount,
90
+ reAnchored: operationCount,
91
+ timeZoneChanged: true,
92
+ // Re-anchoring replaces in place and cancels nothing, so it can never
93
+ // touch a notification outside what it was handed.
94
+ cancelledIds: []
95
+ };
96
+ }
97
+ };
98
+ }
99
+ //# sourceMappingURL=reanchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_anchor","require","_writer","RE_ANCHOR_ORDER","exports","createReAnchorStep","deps","writer","createScheduleWriter","engine","name","order","run","_context","zone","timeZone","pending","getPending","plan","planReAnchor","rewrites","length","operationCount","reAnchored","timeZoneChanged","emit","fromZone","toZone","from","to","count","entry","resolvedAt","tone","resolveTone","undefined","write","request","id","content","moment","at","anchoring","routing","actions","ownerTag","groupTag","anchoringGeneration","approximate","canScheduleExactly","seriesId","pushCreated","cancelledIds"],"sourceRoot":"../../../src","sources":["maintenance/reanchor.ts"],"mappings":";;;;;;;AAgBA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBO,MAAME,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,EAAE;AAE1B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E;YACRC,EAAE,EAAEP,KAAK,CAACO,EAAE;YACZC,OAAO,EAAER,KAAK,CAACQ,OAAO;YACtBN,IAAI,EAAEF,KAAK,CAACE,IAAI;YAChBO,MAAM,EAAE;cAAEC,EAAE,EAAET,UAAU;cAAEU,SAAS,EAAE;YAAY,CAAC;YAClDC,OAAO,EAAEZ,KAAK,CAACY,OAAO;YACtBC,OAAO,EAAEb,KAAK,CAACa,OAAO;YACtBC,QAAQ,EAAEd,KAAK,CAACc,QAAQ;YACxBC,QAAQ,EAAEf,KAAK,CAACe;UACjB,CAAC;UACDd,UAAU;UACVC,IAAI;UACJ;UACA;UACAc,mBAAmB,EAAEjC,IAAI;UACzBkC,WAAW,EAAE,CAAC1C,IAAI,CAAC2C,kBAAkB,CAAC,CAAC;UACvCC,QAAQ,EAAEnB,KAAK,CAACmB,QAAQ;UACxBC,WAAW,EAAEpB,KAAK,CAACoB;QACpB,CAAC,CAAC;QACF7B,cAAc,IAAI,CAAC;MACpB;MAEA,OAAO;QACNA,cAAc;QACdC,UAAU,EAAED,cAAc;QAC1BE,eAAe,EAAE,IAAI;QACrB;QACA;QACA4B,YAAY,EAAE;MACf,CAAC;IACF;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MaintenanceController = void 0;
7
+ /**
8
+ * The automatic-maintenance switch.
9
+ *
10
+ * A package that acts on its own must offer a way to stop it — and a consumer
11
+ * that takes control must not lose a feature as the price. Disabling automatic
12
+ * maintenance leaves every operation explicitly invocable through
13
+ * `runMaintenance()`, producing identical device state.
14
+ */
15
+
16
+ class MaintenanceController {
17
+ constructor(options) {
18
+ this.registry = options.registry;
19
+ this.now = options.now;
20
+ this.ownedIds = options.ownedIds;
21
+ this.enabled = options.enabled ?? true;
22
+ }
23
+ get isEnabled() {
24
+ return this.enabled;
25
+ }
26
+ setEnabled(enabled) {
27
+ this.enabled = enabled;
28
+ }
29
+
30
+ /** Called by lifecycle observers. A no-op when automatic maintenance is off. */
31
+ async runAutomatic(trigger) {
32
+ if (!this.enabled) return undefined;
33
+ return this.execute(trigger);
34
+ }
35
+
36
+ /** Always runs, regardless of the switch. This is what preserves capability parity. */
37
+ async runExplicit() {
38
+ return this.execute('explicit');
39
+ }
40
+ async execute(trigger) {
41
+ const context = {
42
+ trigger,
43
+ now: this.now(),
44
+ ownedIds: await this.ownedIds()
45
+ };
46
+ return this.registry.run(context);
47
+ }
48
+ }
49
+ exports.MaintenanceController = MaintenanceController;
50
+ //# sourceMappingURL=toggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MaintenanceController","constructor","options","registry","now","ownedIds","enabled","isEnabled","setEnabled","runAutomatic","trigger","undefined","execute","runExplicit","context","run","exports"],"sourceRoot":"../../../src","sources":["maintenance/toggle.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBO,MAAMA,qBAAqB,CAAC;EAMlCC,WAAWA,CAACC,OAAqC,EAAE;IAClD,IAAI,CAACC,QAAQ,GAAGD,OAAO,CAACC,QAAQ;IAChC,IAAI,CAACC,GAAG,GAAGF,OAAO,CAACE,GAAG;IACtB,IAAI,CAACC,QAAQ,GAAGH,OAAO,CAACG,QAAQ;IAChC,IAAI,CAACC,OAAO,GAAGJ,OAAO,CAACI,OAAO,IAAI,IAAI;EACvC;EAEA,IAAIC,SAASA,CAAA,EAAY;IACxB,OAAO,IAAI,CAACD,OAAO;EACpB;EAEAE,UAAUA,CAACF,OAAgB,EAAQ;IAClC,IAAI,CAACA,OAAO,GAAGA,OAAO;EACvB;;EAEA;EACA,MAAMG,YAAYA,CACjBC,OAAgD,EACP;IACzC,IAAI,CAAC,IAAI,CAACJ,OAAO,EAAE,OAAOK,SAAS;IACnC,OAAO,IAAI,CAACC,OAAO,CAACF,OAAO,CAAC;EAC7B;;EAEA;EACA,MAAMG,WAAWA,CAAA,EAA+B;IAC/C,OAAO,IAAI,CAACD,OAAO,CAAC,UAAU,CAAC;EAChC;EAEA,MAAcA,OAAOA,CAACF,OAA2B,EAA8B;IAC9E,MAAMI,OAA2B,GAAG;MACnCJ,OAAO;MACPN,GAAG,EAAE,IAAI,CAACA,GAAG,CAAC,CAAC;MACfC,QAAQ,EAAE,MAAM,IAAI,CAACA,QAAQ,CAAC;IAC/B,CAAC;IACD,OAAO,IAAI,CAACF,QAAQ,CAACY,GAAG,CAACD,OAAO,CAAC;EAClC;AACD;AAACE,OAAA,CAAAhB,qBAAA,GAAAA,qBAAA","ignoreList":[]}