@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.
- package/CHANGELOG.md +111 -0
- package/README.md +8 -6
- package/lib/commonjs/advanced.js +139 -0
- package/lib/commonjs/advanced.js.map +1 -0
- package/lib/commonjs/channel/migrate.js +246 -0
- package/lib/commonjs/channel/migrate.js.map +1 -0
- package/lib/commonjs/channel/tone-map.js +120 -0
- package/lib/commonjs/channel/tone-map.js.map +1 -0
- package/lib/commonjs/channel/validate-tone.js +61 -0
- package/lib/commonjs/channel/validate-tone.js.map +1 -0
- package/lib/commonjs/contract/channel.js +52 -0
- package/lib/commonjs/contract/channel.js.map +1 -0
- package/lib/commonjs/contract/diagnostics.js +25 -0
- package/lib/commonjs/contract/diagnostics.js.map +1 -0
- package/lib/commonjs/contract/errors.js +126 -0
- package/lib/commonjs/contract/errors.js.map +1 -0
- package/lib/commonjs/contract/hash.js +35 -0
- package/lib/commonjs/contract/hash.js.map +1 -0
- package/lib/commonjs/contract/index.js +94 -0
- package/lib/commonjs/contract/index.js.map +1 -0
- package/lib/commonjs/contract/interaction.js +37 -0
- package/lib/commonjs/contract/interaction.js.map +1 -0
- package/lib/commonjs/contract/notification.js +42 -0
- package/lib/commonjs/contract/notification.js.map +1 -0
- package/lib/commonjs/contract/permission.js +2 -0
- package/lib/commonjs/contract/permission.js.map +1 -0
- package/lib/commonjs/contract/reconcile.js +6 -0
- package/lib/commonjs/contract/reconcile.js.map +1 -0
- package/lib/commonjs/contract/recurrence.js +53 -0
- package/lib/commonjs/contract/recurrence.js.map +1 -0
- package/lib/commonjs/diagnostics/burst.js +89 -0
- package/lib/commonjs/diagnostics/burst.js.map +1 -0
- package/lib/commonjs/diagnostics/events.js +63 -0
- package/lib/commonjs/diagnostics/events.js.map +1 -0
- package/lib/commonjs/diagnostics/redact.js +48 -0
- package/lib/commonjs/diagnostics/redact.js.map +1 -0
- package/lib/commonjs/diagnostics/snapshot.js +68 -0
- package/lib/commonjs/diagnostics/snapshot.js.map +1 -0
- package/lib/commonjs/engine/adapter.js +6 -0
- package/lib/commonjs/engine/adapter.js.map +1 -0
- package/lib/commonjs/engine/codec.js +84 -0
- package/lib/commonjs/engine/codec.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/events.js +148 -0
- package/lib/commonjs/engine/notify-kit/events.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/module.js +119 -0
- package/lib/commonjs/engine/notify-kit/module.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/android.js +159 -0
- package/lib/commonjs/engine/notify-kit/platform/android.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/index.js +57 -0
- package/lib/commonjs/engine/notify-kit/platform/index.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/ios.js +54 -0
- package/lib/commonjs/engine/notify-kit/platform/ios.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/types.js +6 -0
- package/lib/commonjs/engine/notify-kit/platform/types.js.map +1 -0
- package/lib/commonjs/engine/notify-kit-engine.js +260 -0
- package/lib/commonjs/engine/notify-kit-engine.js.map +1 -0
- package/lib/commonjs/index.js +367 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/initialize.js +187 -0
- package/lib/commonjs/initialize.js.map +1 -0
- package/lib/commonjs/interaction/index.js +120 -0
- package/lib/commonjs/interaction/index.js.map +1 -0
- package/lib/commonjs/maintenance/cycle.js +108 -0
- package/lib/commonjs/maintenance/cycle.js.map +1 -0
- package/lib/commonjs/maintenance/permission-refresh.js +39 -0
- package/lib/commonjs/maintenance/permission-refresh.js.map +1 -0
- package/lib/commonjs/maintenance/reanchor.js +99 -0
- package/lib/commonjs/maintenance/reanchor.js.map +1 -0
- package/lib/commonjs/maintenance/toggle.js +50 -0
- package/lib/commonjs/maintenance/toggle.js.map +1 -0
- package/lib/commonjs/maintenance/verify.js +70 -0
- package/lib/commonjs/maintenance/verify.js.map +1 -0
- package/lib/commonjs/maintenance/window-refresh.js +53 -0
- package/lib/commonjs/maintenance/window-refresh.js.map +1 -0
- package/lib/commonjs/notifications.js +161 -0
- package/lib/commonjs/notifications.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/permission/index.js +182 -0
- package/lib/commonjs/permission/index.js.map +1 -0
- package/lib/commonjs/permission/state.js +92 -0
- package/lib/commonjs/permission/state.js.map +1 -0
- package/lib/commonjs/push/envelope.js +141 -0
- package/lib/commonjs/push/envelope.js.map +1 -0
- package/lib/commonjs/push/fcm-provider.js +122 -0
- package/lib/commonjs/push/fcm-provider.js.map +1 -0
- package/lib/commonjs/push/gate.js +162 -0
- package/lib/commonjs/push/gate.js.map +1 -0
- package/lib/commonjs/push/index.js +47 -0
- package/lib/commonjs/push/index.js.map +1 -0
- package/lib/commonjs/push/instructions.js +101 -0
- package/lib/commonjs/push/instructions.js.map +1 -0
- package/lib/commonjs/push/provider-adapter.js +6 -0
- package/lib/commonjs/push/provider-adapter.js.map +1 -0
- package/lib/commonjs/push/signout.js +55 -0
- package/lib/commonjs/push/signout.js.map +1 -0
- package/lib/commonjs/reconcile/chunk.js +49 -0
- package/lib/commonjs/reconcile/chunk.js.map +1 -0
- package/lib/commonjs/reconcile/diff.js +105 -0
- package/lib/commonjs/reconcile/diff.js.map +1 -0
- package/lib/commonjs/reconcile/duplicates.js +60 -0
- package/lib/commonjs/reconcile/duplicates.js.map +1 -0
- package/lib/commonjs/reconcile/index.js +164 -0
- package/lib/commonjs/reconcile/index.js.map +1 -0
- package/lib/commonjs/reconcile/truncate.js +50 -0
- package/lib/commonjs/reconcile/truncate.js.map +1 -0
- package/lib/commonjs/recurrence/clock-guard.js +65 -0
- package/lib/commonjs/recurrence/clock-guard.js.map +1 -0
- package/lib/commonjs/recurrence/expand.js +254 -0
- package/lib/commonjs/recurrence/expand.js.map +1 -0
- package/lib/commonjs/recurrence/index.js +212 -0
- package/lib/commonjs/recurrence/index.js.map +1 -0
- package/lib/commonjs/repeat/expiry.js +41 -0
- package/lib/commonjs/repeat/expiry.js.map +1 -0
- package/lib/commonjs/repeat/index.js +100 -0
- package/lib/commonjs/repeat/index.js.map +1 -0
- package/lib/commonjs/repeat/marker.js +58 -0
- package/lib/commonjs/repeat/marker.js.map +1 -0
- package/lib/commonjs/repeat/place.js +83 -0
- package/lib/commonjs/repeat/place.js.map +1 -0
- package/lib/commonjs/schedule/anchor.js +243 -0
- package/lib/commonjs/schedule/anchor.js.map +1 -0
- package/lib/commonjs/schedule/index.js +142 -0
- package/lib/commonjs/schedule/index.js.map +1 -0
- package/lib/commonjs/schedule/partition.js +59 -0
- package/lib/commonjs/schedule/partition.js.map +1 -0
- package/lib/commonjs/schedule/resolve-moment.js +72 -0
- package/lib/commonjs/schedule/resolve-moment.js.map +1 -0
- package/lib/commonjs/schedule/validate-content.js +101 -0
- package/lib/commonjs/schedule/validate-content.js.map +1 -0
- package/lib/commonjs/schedule/validate-identifier.js +126 -0
- package/lib/commonjs/schedule/validate-identifier.js.map +1 -0
- package/lib/commonjs/schedule/writer.js +44 -0
- package/lib/commonjs/schedule/writer.js.map +1 -0
- package/lib/commonjs/state/caps.js +101 -0
- package/lib/commonjs/state/caps.js.map +1 -0
- package/lib/commonjs/state/dedup-ledger.js +39 -0
- package/lib/commonjs/state/dedup-ledger.js.map +1 -0
- package/lib/commonjs/state/interaction-buffer.js +98 -0
- package/lib/commonjs/state/interaction-buffer.js.map +1 -0
- package/lib/commonjs/state/mmkv-store.js +75 -0
- package/lib/commonjs/state/mmkv-store.js.map +1 -0
- package/lib/commonjs/state/permission-history.js +64 -0
- package/lib/commonjs/state/permission-history.js.map +1 -0
- package/lib/commonjs/state/record.js +269 -0
- package/lib/commonjs/state/record.js.map +1 -0
- package/lib/commonjs/state/reset.js +37 -0
- package/lib/commonjs/state/reset.js.map +1 -0
- package/lib/commonjs/state/series-ledger.js +71 -0
- package/lib/commonjs/state/series-ledger.js.map +1 -0
- package/lib/commonjs/state/store.js +39 -0
- package/lib/commonjs/state/store.js.map +1 -0
- package/lib/commonjs/testing/conformance/index.js +218 -0
- package/lib/commonjs/testing/conformance/index.js.map +1 -0
- package/lib/commonjs/testing/fake-engine.js +338 -0
- package/lib/commonjs/testing/fake-engine.js.map +1 -0
- package/lib/commonjs/testing/fake-provider.js +93 -0
- package/lib/commonjs/testing/fake-provider.js.map +1 -0
- package/lib/commonjs/testing/faults.js +59 -0
- package/lib/commonjs/testing/faults.js.map +1 -0
- package/lib/commonjs/testing/index.js +54 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/testing/measure.js +298 -0
- package/lib/commonjs/testing/measure.js.map +1 -0
- package/lib/module/advanced.js +29 -0
- package/lib/module/advanced.js.map +1 -0
- package/lib/module/channel/migrate.js +242 -0
- package/lib/module/channel/migrate.js.map +1 -0
- package/lib/module/channel/tone-map.js +112 -0
- package/lib/module/channel/tone-map.js.map +1 -0
- package/lib/module/channel/validate-tone.js +57 -0
- package/lib/module/channel/validate-tone.js.map +1 -0
- package/lib/module/contract/channel.js +48 -0
- package/lib/module/contract/channel.js.map +1 -0
- package/lib/module/contract/diagnostics.js +21 -0
- package/lib/module/contract/diagnostics.js.map +1 -0
- package/lib/module/contract/errors.js +119 -0
- package/lib/module/contract/errors.js.map +1 -0
- package/lib/module/contract/hash.js +29 -0
- package/lib/module/contract/hash.js.map +1 -0
- package/lib/module/contract/index.js +13 -0
- package/lib/module/contract/index.js.map +1 -0
- package/lib/module/contract/interaction.js +33 -0
- package/lib/module/contract/interaction.js.map +1 -0
- package/lib/module/contract/notification.js +38 -0
- package/lib/module/contract/notification.js.map +1 -0
- package/lib/module/contract/permission.js +2 -0
- package/lib/module/contract/permission.js.map +1 -0
- package/lib/module/contract/reconcile.js +4 -0
- package/lib/module/contract/reconcile.js.map +1 -0
- package/lib/module/contract/recurrence.js +49 -0
- package/lib/module/contract/recurrence.js.map +1 -0
- package/lib/module/diagnostics/burst.js +85 -0
- package/lib/module/diagnostics/burst.js.map +1 -0
- package/lib/module/diagnostics/events.js +58 -0
- package/lib/module/diagnostics/events.js.map +1 -0
- package/lib/module/diagnostics/redact.js +44 -0
- package/lib/module/diagnostics/redact.js.map +1 -0
- package/lib/module/diagnostics/snapshot.js +64 -0
- package/lib/module/diagnostics/snapshot.js.map +1 -0
- package/lib/module/engine/adapter.js +4 -0
- package/lib/module/engine/adapter.js.map +1 -0
- package/lib/module/engine/codec.js +79 -0
- package/lib/module/engine/codec.js.map +1 -0
- package/lib/module/engine/notify-kit/events.js +139 -0
- package/lib/module/engine/notify-kit/events.js.map +1 -0
- package/lib/module/engine/notify-kit/module.js +113 -0
- package/lib/module/engine/notify-kit/module.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/android.js +155 -0
- package/lib/module/engine/notify-kit/platform/android.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/index.js +51 -0
- package/lib/module/engine/notify-kit/platform/index.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/ios.js +49 -0
- package/lib/module/engine/notify-kit/platform/ios.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/types.js +4 -0
- package/lib/module/engine/notify-kit/platform/types.js.map +1 -0
- package/lib/module/engine/notify-kit-engine.js +257 -0
- package/lib/module/engine/notify-kit-engine.js.map +1 -0
- package/lib/module/index.js +98 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/initialize.js +182 -0
- package/lib/module/initialize.js.map +1 -0
- package/lib/module/interaction/index.js +116 -0
- package/lib/module/interaction/index.js.map +1 -0
- package/lib/module/maintenance/cycle.js +102 -0
- package/lib/module/maintenance/cycle.js.map +1 -0
- package/lib/module/maintenance/permission-refresh.js +34 -0
- package/lib/module/maintenance/permission-refresh.js.map +1 -0
- package/lib/module/maintenance/reanchor.js +94 -0
- package/lib/module/maintenance/reanchor.js.map +1 -0
- package/lib/module/maintenance/toggle.js +45 -0
- package/lib/module/maintenance/toggle.js.map +1 -0
- package/lib/module/maintenance/verify.js +65 -0
- package/lib/module/maintenance/verify.js.map +1 -0
- package/lib/module/maintenance/window-refresh.js +48 -0
- package/lib/module/maintenance/window-refresh.js.map +1 -0
- package/lib/module/notifications.js +157 -0
- package/lib/module/notifications.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permission/index.js +178 -0
- package/lib/module/permission/index.js.map +1 -0
- package/lib/module/permission/state.js +83 -0
- package/lib/module/permission/state.js.map +1 -0
- package/lib/module/push/envelope.js +137 -0
- package/lib/module/push/envelope.js.map +1 -0
- package/lib/module/push/fcm-provider.js +119 -0
- package/lib/module/push/fcm-provider.js.map +1 -0
- package/lib/module/push/gate.js +158 -0
- package/lib/module/push/gate.js.map +1 -0
- package/lib/module/push/index.js +16 -0
- package/lib/module/push/index.js.map +1 -0
- package/lib/module/push/instructions.js +97 -0
- package/lib/module/push/instructions.js.map +1 -0
- package/lib/module/push/provider-adapter.js +4 -0
- package/lib/module/push/provider-adapter.js.map +1 -0
- package/lib/module/push/signout.js +51 -0
- package/lib/module/push/signout.js.map +1 -0
- package/lib/module/reconcile/chunk.js +43 -0
- package/lib/module/reconcile/chunk.js.map +1 -0
- package/lib/module/reconcile/diff.js +101 -0
- package/lib/module/reconcile/diff.js.map +1 -0
- package/lib/module/reconcile/duplicates.js +56 -0
- package/lib/module/reconcile/duplicates.js.map +1 -0
- package/lib/module/reconcile/index.js +161 -0
- package/lib/module/reconcile/index.js.map +1 -0
- package/lib/module/reconcile/truncate.js +46 -0
- package/lib/module/reconcile/truncate.js.map +1 -0
- package/lib/module/recurrence/clock-guard.js +60 -0
- package/lib/module/recurrence/clock-guard.js.map +1 -0
- package/lib/module/recurrence/expand.js +248 -0
- package/lib/module/recurrence/expand.js.map +1 -0
- package/lib/module/recurrence/index.js +208 -0
- package/lib/module/recurrence/index.js.map +1 -0
- package/lib/module/repeat/expiry.js +37 -0
- package/lib/module/repeat/expiry.js.map +1 -0
- package/lib/module/repeat/index.js +67 -0
- package/lib/module/repeat/index.js.map +1 -0
- package/lib/module/repeat/marker.js +51 -0
- package/lib/module/repeat/marker.js.map +1 -0
- package/lib/module/repeat/place.js +79 -0
- package/lib/module/repeat/place.js.map +1 -0
- package/lib/module/schedule/anchor.js +234 -0
- package/lib/module/schedule/anchor.js.map +1 -0
- package/lib/module/schedule/index.js +137 -0
- package/lib/module/schedule/index.js.map +1 -0
- package/lib/module/schedule/partition.js +53 -0
- package/lib/module/schedule/partition.js.map +1 -0
- package/lib/module/schedule/resolve-moment.js +66 -0
- package/lib/module/schedule/resolve-moment.js.map +1 -0
- package/lib/module/schedule/validate-content.js +95 -0
- package/lib/module/schedule/validate-content.js.map +1 -0
- package/lib/module/schedule/validate-identifier.js +119 -0
- package/lib/module/schedule/validate-identifier.js.map +1 -0
- package/lib/module/schedule/writer.js +40 -0
- package/lib/module/schedule/writer.js.map +1 -0
- package/lib/module/state/caps.js +96 -0
- package/lib/module/state/caps.js.map +1 -0
- package/lib/module/state/dedup-ledger.js +34 -0
- package/lib/module/state/dedup-ledger.js.map +1 -0
- package/lib/module/state/interaction-buffer.js +92 -0
- package/lib/module/state/interaction-buffer.js.map +1 -0
- package/lib/module/state/mmkv-store.js +71 -0
- package/lib/module/state/mmkv-store.js.map +1 -0
- package/lib/module/state/permission-history.js +56 -0
- package/lib/module/state/permission-history.js.map +1 -0
- package/lib/module/state/record.js +264 -0
- package/lib/module/state/record.js.map +1 -0
- package/lib/module/state/reset.js +32 -0
- package/lib/module/state/reset.js.map +1 -0
- package/lib/module/state/series-ledger.js +62 -0
- package/lib/module/state/series-ledger.js.map +1 -0
- package/lib/module/state/store.js +35 -0
- package/lib/module/state/store.js.map +1 -0
- package/lib/module/testing/conformance/index.js +214 -0
- package/lib/module/testing/conformance/index.js.map +1 -0
- package/lib/module/testing/fake-engine.js +335 -0
- package/lib/module/testing/fake-engine.js.map +1 -0
- package/lib/module/testing/fake-provider.js +89 -0
- package/lib/module/testing/fake-provider.js.map +1 -0
- package/lib/module/testing/faults.js +55 -0
- package/lib/module/testing/faults.js.map +1 -0
- package/lib/module/testing/index.js +19 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/module/testing/measure.js +294 -0
- package/lib/module/testing/measure.js.map +1 -0
- package/lib/typescript/commonjs/advanced.d.ts +36 -0
- package/lib/typescript/commonjs/advanced.d.ts.map +1 -0
- package/lib/typescript/commonjs/channel/migrate.d.ts +38 -0
- package/lib/typescript/commonjs/channel/migrate.d.ts.map +1 -0
- package/lib/typescript/commonjs/channel/tone-map.d.ts +34 -0
- package/lib/typescript/commonjs/channel/tone-map.d.ts.map +1 -0
- package/lib/typescript/commonjs/channel/validate-tone.d.ts +23 -0
- package/lib/typescript/commonjs/channel/validate-tone.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/channel.d.ts +185 -0
- package/lib/typescript/commonjs/contract/channel.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/diagnostics.d.ts +92 -0
- package/lib/typescript/commonjs/contract/diagnostics.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/errors.d.ts +91 -0
- package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/hash.d.ts +14 -0
- package/lib/typescript/commonjs/contract/hash.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/index.d.ts +10 -0
- package/lib/typescript/commonjs/contract/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts +53 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/notification.d.ts +110 -0
- package/lib/typescript/commonjs/contract/notification.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/permission.d.ts +49 -0
- package/lib/typescript/commonjs/contract/permission.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/reconcile.d.ts +82 -0
- package/lib/typescript/commonjs/contract/reconcile.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/recurrence.d.ts +118 -0
- package/lib/typescript/commonjs/contract/recurrence.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/burst.d.ts +39 -0
- package/lib/typescript/commonjs/diagnostics/burst.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/events.d.ts +28 -0
- package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts +22 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/snapshot.d.ts +40 -0
- package/lib/typescript/commonjs/diagnostics/snapshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/adapter.d.ts +172 -0
- package/lib/typescript/commonjs/engine/adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/codec.d.ts +20 -0
- package/lib/typescript/commonjs/engine/codec.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/events.d.ts +37 -0
- package/lib/typescript/commonjs/engine/notify-kit/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/module.d.ts +103 -0
- package/lib/typescript/commonjs/engine/notify-kit/module.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts +3 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts +12 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts +3 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts +33 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts +25 -0
- package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +106 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/initialize.d.ts +74 -0
- package/lib/typescript/commonjs/initialize.d.ts.map +1 -0
- package/lib/typescript/commonjs/interaction/index.d.ts +53 -0
- package/lib/typescript/commonjs/interaction/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/cycle.d.ts +77 -0
- package/lib/typescript/commonjs/maintenance/cycle.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts +19 -0
- package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/reanchor.d.ts +26 -0
- package/lib/typescript/commonjs/maintenance/reanchor.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/toggle.d.ts +35 -0
- package/lib/typescript/commonjs/maintenance/toggle.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/verify.d.ts +32 -0
- package/lib/typescript/commonjs/maintenance/verify.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/window-refresh.d.ts +29 -0
- package/lib/typescript/commonjs/maintenance/window-refresh.d.ts.map +1 -0
- package/lib/typescript/commonjs/notifications.d.ts +78 -0
- package/lib/typescript/commonjs/notifications.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/permission/index.d.ts +57 -0
- package/lib/typescript/commonjs/permission/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/permission/state.d.ts +41 -0
- package/lib/typescript/commonjs/permission/state.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/envelope.d.ts +33 -0
- package/lib/typescript/commonjs/push/envelope.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/fcm-provider.d.ts +43 -0
- package/lib/typescript/commonjs/push/fcm-provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/gate.d.ts +57 -0
- package/lib/typescript/commonjs/push/gate.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/index.d.ts +19 -0
- package/lib/typescript/commonjs/push/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/instructions.d.ts +45 -0
- package/lib/typescript/commonjs/push/instructions.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/provider-adapter.d.ts +50 -0
- package/lib/typescript/commonjs/push/provider-adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/signout.d.ts +33 -0
- package/lib/typescript/commonjs/push/signout.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/chunk.d.ts +24 -0
- package/lib/typescript/commonjs/reconcile/chunk.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/diff.d.ts +54 -0
- package/lib/typescript/commonjs/reconcile/diff.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/duplicates.d.ts +32 -0
- package/lib/typescript/commonjs/reconcile/duplicates.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/index.d.ts +35 -0
- package/lib/typescript/commonjs/reconcile/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/truncate.d.ts +26 -0
- package/lib/typescript/commonjs/reconcile/truncate.d.ts.map +1 -0
- package/lib/typescript/commonjs/recurrence/clock-guard.d.ts +37 -0
- package/lib/typescript/commonjs/recurrence/clock-guard.d.ts.map +1 -0
- package/lib/typescript/commonjs/recurrence/expand.d.ts +75 -0
- package/lib/typescript/commonjs/recurrence/expand.d.ts.map +1 -0
- package/lib/typescript/commonjs/recurrence/index.d.ts +40 -0
- package/lib/typescript/commonjs/recurrence/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/expiry.d.ts +23 -0
- package/lib/typescript/commonjs/repeat/expiry.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/index.d.ts +49 -0
- package/lib/typescript/commonjs/repeat/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/marker.d.ts +36 -0
- package/lib/typescript/commonjs/repeat/marker.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/place.d.ts +39 -0
- package/lib/typescript/commonjs/repeat/place.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/anchor.d.ts +118 -0
- package/lib/typescript/commonjs/schedule/anchor.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/index.d.ts +40 -0
- package/lib/typescript/commonjs/schedule/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/partition.d.ts +29 -0
- package/lib/typescript/commonjs/schedule/partition.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/resolve-moment.d.ts +35 -0
- package/lib/typescript/commonjs/schedule/resolve-moment.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/validate-content.d.ts +42 -0
- package/lib/typescript/commonjs/schedule/validate-content.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/validate-identifier.d.ts +30 -0
- package/lib/typescript/commonjs/schedule/validate-identifier.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/writer.d.ts +36 -0
- package/lib/typescript/commonjs/schedule/writer.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/caps.d.ts +51 -0
- package/lib/typescript/commonjs/state/caps.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/dedup-ledger.d.ts +21 -0
- package/lib/typescript/commonjs/state/dedup-ledger.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/interaction-buffer.d.ts +30 -0
- package/lib/typescript/commonjs/state/interaction-buffer.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/mmkv-store.d.ts +33 -0
- package/lib/typescript/commonjs/state/mmkv-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/permission-history.d.ts +20 -0
- package/lib/typescript/commonjs/state/permission-history.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/record.d.ts +134 -0
- package/lib/typescript/commonjs/state/record.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/reset.d.ts +22 -0
- package/lib/typescript/commonjs/state/reset.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/series-ledger.d.ts +47 -0
- package/lib/typescript/commonjs/state/series-ledger.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/store.d.ts +20 -0
- package/lib/typescript/commonjs/state/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts +32 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/fake-engine.d.ts +91 -0
- package/lib/typescript/commonjs/testing/fake-engine.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/fake-provider.d.ts +35 -0
- package/lib/typescript/commonjs/testing/fake-provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/faults.d.ts +38 -0
- package/lib/typescript/commonjs/testing/faults.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +22 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/measure.d.ts +59 -0
- package/lib/typescript/commonjs/testing/measure.d.ts.map +1 -0
- package/lib/typescript/module/advanced.d.ts +36 -0
- package/lib/typescript/module/advanced.d.ts.map +1 -0
- package/lib/typescript/module/channel/migrate.d.ts +38 -0
- package/lib/typescript/module/channel/migrate.d.ts.map +1 -0
- package/lib/typescript/module/channel/tone-map.d.ts +34 -0
- package/lib/typescript/module/channel/tone-map.d.ts.map +1 -0
- package/lib/typescript/module/channel/validate-tone.d.ts +23 -0
- package/lib/typescript/module/channel/validate-tone.d.ts.map +1 -0
- package/lib/typescript/module/contract/channel.d.ts +185 -0
- package/lib/typescript/module/contract/channel.d.ts.map +1 -0
- package/lib/typescript/module/contract/diagnostics.d.ts +92 -0
- package/lib/typescript/module/contract/diagnostics.d.ts.map +1 -0
- package/lib/typescript/module/contract/errors.d.ts +91 -0
- package/lib/typescript/module/contract/errors.d.ts.map +1 -0
- package/lib/typescript/module/contract/hash.d.ts +14 -0
- package/lib/typescript/module/contract/hash.d.ts.map +1 -0
- package/lib/typescript/module/contract/index.d.ts +10 -0
- package/lib/typescript/module/contract/index.d.ts.map +1 -0
- package/lib/typescript/module/contract/interaction.d.ts +53 -0
- package/lib/typescript/module/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/module/contract/notification.d.ts +110 -0
- package/lib/typescript/module/contract/notification.d.ts.map +1 -0
- package/lib/typescript/module/contract/permission.d.ts +49 -0
- package/lib/typescript/module/contract/permission.d.ts.map +1 -0
- package/lib/typescript/module/contract/reconcile.d.ts +82 -0
- package/lib/typescript/module/contract/reconcile.d.ts.map +1 -0
- package/lib/typescript/module/contract/recurrence.d.ts +118 -0
- package/lib/typescript/module/contract/recurrence.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/burst.d.ts +39 -0
- package/lib/typescript/module/diagnostics/burst.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/events.d.ts +28 -0
- package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/redact.d.ts +22 -0
- package/lib/typescript/module/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/snapshot.d.ts +40 -0
- package/lib/typescript/module/diagnostics/snapshot.d.ts.map +1 -0
- package/lib/typescript/module/engine/adapter.d.ts +172 -0
- package/lib/typescript/module/engine/adapter.d.ts.map +1 -0
- package/lib/typescript/module/engine/codec.d.ts +20 -0
- package/lib/typescript/module/engine/codec.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/events.d.ts +37 -0
- package/lib/typescript/module/engine/notify-kit/events.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/module.d.ts +103 -0
- package/lib/typescript/module/engine/notify-kit/module.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/android.d.ts +3 -0
- package/lib/typescript/module/engine/notify-kit/platform/android.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/index.d.ts +12 -0
- package/lib/typescript/module/engine/notify-kit/platform/index.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts +3 -0
- package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/types.d.ts +33 -0
- package/lib/typescript/module/engine/notify-kit/platform/types.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit-engine.d.ts +25 -0
- package/lib/typescript/module/engine/notify-kit-engine.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +106 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/initialize.d.ts +74 -0
- package/lib/typescript/module/initialize.d.ts.map +1 -0
- package/lib/typescript/module/interaction/index.d.ts +53 -0
- package/lib/typescript/module/interaction/index.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/cycle.d.ts +77 -0
- package/lib/typescript/module/maintenance/cycle.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/permission-refresh.d.ts +19 -0
- package/lib/typescript/module/maintenance/permission-refresh.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/reanchor.d.ts +26 -0
- package/lib/typescript/module/maintenance/reanchor.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/toggle.d.ts +35 -0
- package/lib/typescript/module/maintenance/toggle.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/verify.d.ts +32 -0
- package/lib/typescript/module/maintenance/verify.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/window-refresh.d.ts +29 -0
- package/lib/typescript/module/maintenance/window-refresh.d.ts.map +1 -0
- package/lib/typescript/module/notifications.d.ts +78 -0
- package/lib/typescript/module/notifications.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/permission/index.d.ts +57 -0
- package/lib/typescript/module/permission/index.d.ts.map +1 -0
- package/lib/typescript/module/permission/state.d.ts +41 -0
- package/lib/typescript/module/permission/state.d.ts.map +1 -0
- package/lib/typescript/module/push/envelope.d.ts +33 -0
- package/lib/typescript/module/push/envelope.d.ts.map +1 -0
- package/lib/typescript/module/push/fcm-provider.d.ts +43 -0
- package/lib/typescript/module/push/fcm-provider.d.ts.map +1 -0
- package/lib/typescript/module/push/gate.d.ts +57 -0
- package/lib/typescript/module/push/gate.d.ts.map +1 -0
- package/lib/typescript/module/push/index.d.ts +19 -0
- package/lib/typescript/module/push/index.d.ts.map +1 -0
- package/lib/typescript/module/push/instructions.d.ts +45 -0
- package/lib/typescript/module/push/instructions.d.ts.map +1 -0
- package/lib/typescript/module/push/provider-adapter.d.ts +50 -0
- package/lib/typescript/module/push/provider-adapter.d.ts.map +1 -0
- package/lib/typescript/module/push/signout.d.ts +33 -0
- package/lib/typescript/module/push/signout.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/chunk.d.ts +24 -0
- package/lib/typescript/module/reconcile/chunk.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/diff.d.ts +54 -0
- package/lib/typescript/module/reconcile/diff.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/duplicates.d.ts +32 -0
- package/lib/typescript/module/reconcile/duplicates.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/index.d.ts +35 -0
- package/lib/typescript/module/reconcile/index.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/truncate.d.ts +26 -0
- package/lib/typescript/module/reconcile/truncate.d.ts.map +1 -0
- package/lib/typescript/module/recurrence/clock-guard.d.ts +37 -0
- package/lib/typescript/module/recurrence/clock-guard.d.ts.map +1 -0
- package/lib/typescript/module/recurrence/expand.d.ts +75 -0
- package/lib/typescript/module/recurrence/expand.d.ts.map +1 -0
- package/lib/typescript/module/recurrence/index.d.ts +40 -0
- package/lib/typescript/module/recurrence/index.d.ts.map +1 -0
- package/lib/typescript/module/repeat/expiry.d.ts +23 -0
- package/lib/typescript/module/repeat/expiry.d.ts.map +1 -0
- package/lib/typescript/module/repeat/index.d.ts +49 -0
- package/lib/typescript/module/repeat/index.d.ts.map +1 -0
- package/lib/typescript/module/repeat/marker.d.ts +36 -0
- package/lib/typescript/module/repeat/marker.d.ts.map +1 -0
- package/lib/typescript/module/repeat/place.d.ts +39 -0
- package/lib/typescript/module/repeat/place.d.ts.map +1 -0
- package/lib/typescript/module/schedule/anchor.d.ts +118 -0
- package/lib/typescript/module/schedule/anchor.d.ts.map +1 -0
- package/lib/typescript/module/schedule/index.d.ts +40 -0
- package/lib/typescript/module/schedule/index.d.ts.map +1 -0
- package/lib/typescript/module/schedule/partition.d.ts +29 -0
- package/lib/typescript/module/schedule/partition.d.ts.map +1 -0
- package/lib/typescript/module/schedule/resolve-moment.d.ts +35 -0
- package/lib/typescript/module/schedule/resolve-moment.d.ts.map +1 -0
- package/lib/typescript/module/schedule/validate-content.d.ts +42 -0
- package/lib/typescript/module/schedule/validate-content.d.ts.map +1 -0
- package/lib/typescript/module/schedule/validate-identifier.d.ts +30 -0
- package/lib/typescript/module/schedule/validate-identifier.d.ts.map +1 -0
- package/lib/typescript/module/schedule/writer.d.ts +36 -0
- package/lib/typescript/module/schedule/writer.d.ts.map +1 -0
- package/lib/typescript/module/state/caps.d.ts +51 -0
- package/lib/typescript/module/state/caps.d.ts.map +1 -0
- package/lib/typescript/module/state/dedup-ledger.d.ts +21 -0
- package/lib/typescript/module/state/dedup-ledger.d.ts.map +1 -0
- package/lib/typescript/module/state/interaction-buffer.d.ts +30 -0
- package/lib/typescript/module/state/interaction-buffer.d.ts.map +1 -0
- package/lib/typescript/module/state/mmkv-store.d.ts +33 -0
- package/lib/typescript/module/state/mmkv-store.d.ts.map +1 -0
- package/lib/typescript/module/state/permission-history.d.ts +20 -0
- package/lib/typescript/module/state/permission-history.d.ts.map +1 -0
- package/lib/typescript/module/state/record.d.ts +134 -0
- package/lib/typescript/module/state/record.d.ts.map +1 -0
- package/lib/typescript/module/state/reset.d.ts +22 -0
- package/lib/typescript/module/state/reset.d.ts.map +1 -0
- package/lib/typescript/module/state/series-ledger.d.ts +47 -0
- package/lib/typescript/module/state/series-ledger.d.ts.map +1 -0
- package/lib/typescript/module/state/store.d.ts +20 -0
- package/lib/typescript/module/state/store.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/index.d.ts +32 -0
- package/lib/typescript/module/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/fake-engine.d.ts +91 -0
- package/lib/typescript/module/testing/fake-engine.d.ts.map +1 -0
- package/lib/typescript/module/testing/fake-provider.d.ts +35 -0
- package/lib/typescript/module/testing/fake-provider.d.ts.map +1 -0
- package/lib/typescript/module/testing/faults.d.ts +38 -0
- package/lib/typescript/module/testing/faults.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +22 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/measure.d.ts +59 -0
- package/lib/typescript/module/testing/measure.d.ts.map +1 -0
- package/package.json +72 -26
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `react-native-notify-kit` engine implementation.
|
|
5
|
+
*
|
|
6
|
+
* Nothing above this adapter knows which engine is in use — which is what
|
|
7
|
+
* allowed the original Notifee choice to be swapped for its maintained fork
|
|
8
|
+
* without touching a requirement, a test, or a line of consumer code.
|
|
9
|
+
*
|
|
10
|
+
* This file is what both platforms share: scheduling, cancelling, reading the
|
|
11
|
+
* pending set, and routing events. The engine module and its constants live in
|
|
12
|
+
* `notify-kit/module.ts`, decoding in `notify-kit/events.ts`, and everything
|
|
13
|
+
* that differs between Android and iOS in `notify-kit/platform/` — chosen once
|
|
14
|
+
* when the engine is created (NOT-18, IOS-08).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { isRepeatStopId } from "../repeat/marker.js";
|
|
18
|
+
import { packData } from "./codec.js";
|
|
19
|
+
import { DIAGNOSTIC_CODES, NotificationError } from "../contract/errors.js";
|
|
20
|
+
import { toDelivery, toInteraction, toPermissionState, unpackEntry, unpackRepeatStops } from "./notify-kit/events.js";
|
|
21
|
+
import { ALARM_TYPE_EXACT_AND_ALLOW_WHILE_IDLE, ALARM_TYPE_INEXACT_AND_ALLOW_WHILE_IDLE, ANDROID_CATEGORY_ALARM, ANDROID_IMPORTANCE, MARKER_CHANNEL_ID, TRIGGER_TYPE_TIMESTAMP, compact, loadEngine } from "./notify-kit/module.js";
|
|
22
|
+
import { createNotifyKitPlatform } from "./notify-kit/platform/index.js";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether this *process* has a background delivery handler.
|
|
26
|
+
*
|
|
27
|
+
* Module scope, not adapter instance state. The engine registers one headless
|
|
28
|
+
* task per process, so registering through any adapter registers it for all of
|
|
29
|
+
* them. Keeping the flag per instance made an app that had wired the handler up
|
|
30
|
+
* correctly report that it had not — which is worse than not reporting at all,
|
|
31
|
+
* because the warning tells the consumer to fix something that is not broken.
|
|
32
|
+
*/
|
|
33
|
+
let backgroundHandlerRegistered = false;
|
|
34
|
+
/**
|
|
35
|
+
* Interaction subscribers alive in this process, across engine instances: the
|
|
36
|
+
* one registered at module scope in `index.js` and the one the app's runtime
|
|
37
|
+
* uses are different instances, and a background interaction has to reach the
|
|
38
|
+
* runtime's subscribers when there are any (NOT-10).
|
|
39
|
+
*/
|
|
40
|
+
const liveInteractionListeners = new Set();
|
|
41
|
+
export function createNotifyKitEngine(options = {}) {
|
|
42
|
+
let cached = options.module;
|
|
43
|
+
const engine = () => cached ??= loadEngine();
|
|
44
|
+
const now = options.now ?? (() => Date.now());
|
|
45
|
+
const platform = createNotifyKitPlatform(engine, options.platform);
|
|
46
|
+
const getPermission = async kind => platform.permissionFrom(kind, await engine().getNotificationSettings());
|
|
47
|
+
return {
|
|
48
|
+
name: 'react-native-notify-kit',
|
|
49
|
+
withChannelSnapshot: work => platform.withChannelSnapshot(work),
|
|
50
|
+
async pendingIds() {
|
|
51
|
+
const module = engine();
|
|
52
|
+
if (module.getTriggerNotificationIds) {
|
|
53
|
+
return module.getTriggerNotificationIds();
|
|
54
|
+
}
|
|
55
|
+
return (await module.getTriggerNotifications()).flatMap(raw => {
|
|
56
|
+
const id = raw.notification?.id;
|
|
57
|
+
return typeof id === 'string' ? [id] : [];
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
getCapabilities: async () => platform.capabilities(),
|
|
61
|
+
async schedule(request) {
|
|
62
|
+
const actions = request.request.actions?.map(action => compact({
|
|
63
|
+
title: action.title,
|
|
64
|
+
pressAction: compact({
|
|
65
|
+
id: action.id,
|
|
66
|
+
launchActivity: action.mode === 'foreground' ? 'default' : undefined
|
|
67
|
+
}),
|
|
68
|
+
input: action.input === undefined ? undefined : compact({
|
|
69
|
+
placeholder: action.input.placeholder
|
|
70
|
+
})
|
|
71
|
+
}));
|
|
72
|
+
const isMarker = request.repeatStop !== undefined;
|
|
73
|
+
if (isMarker) {
|
|
74
|
+
await platform.ensureMarkerChannel();
|
|
75
|
+
}
|
|
76
|
+
await engine().createTriggerNotification(compact({
|
|
77
|
+
id: request.request.id,
|
|
78
|
+
title: request.request.content.title,
|
|
79
|
+
body: request.request.content.body,
|
|
80
|
+
subtitle: request.request.content.subtitle,
|
|
81
|
+
data: packData(request),
|
|
82
|
+
android: compact({
|
|
83
|
+
// A marker gets the quietest channel the package owns rather than
|
|
84
|
+
// the consumer's tone. It exists to be delivered and removed, and
|
|
85
|
+
// borrowing the alarm's own channel would make it alarm too.
|
|
86
|
+
channelId: isMarker ? MARKER_CHANNEL_ID : request.tone.android.channelId,
|
|
87
|
+
// Numeric enum, not the string name — see ANDROID_IMPORTANCE.
|
|
88
|
+
importance: isMarker ? ANDROID_IMPORTANCE.min : ANDROID_IMPORTANCE[request.tone.android.importance],
|
|
89
|
+
sound: isMarker ? undefined : request.tone.android.sound,
|
|
90
|
+
groupId: isMarker ? undefined : request.tone.android.groupId,
|
|
91
|
+
// Per-notification, not channel configuration. That is what lets
|
|
92
|
+
// a consumer add a repeating alert to an existing tone without
|
|
93
|
+
// bumping its version and costing the user their settings.
|
|
94
|
+
loopSound: !isMarker && request.tone.android.loopSound ? true : undefined,
|
|
95
|
+
category: !isMarker && request.tone.android.alarmCategory ? ANDROID_CATEGORY_ALARM : undefined,
|
|
96
|
+
actions: isMarker ? undefined : actions
|
|
97
|
+
}),
|
|
98
|
+
ios: compact({
|
|
99
|
+
categoryId: request.tone.ios.categoryId,
|
|
100
|
+
// This one genuinely is a string union in the engine's types.
|
|
101
|
+
interruptionLevel: request.tone.ios.interruptionLevel,
|
|
102
|
+
sound: request.tone.ios.sound
|
|
103
|
+
})
|
|
104
|
+
}), {
|
|
105
|
+
type: TRIGGER_TYPE_TIMESTAMP,
|
|
106
|
+
timestamp: request.resolvedAt,
|
|
107
|
+
// Approximate mode is a degradation, not a failure: the notification
|
|
108
|
+
// is still scheduled and the caller is told it may arrive late.
|
|
109
|
+
alarmManager: {
|
|
110
|
+
allowWhileIdle: true,
|
|
111
|
+
type: request.approximate ? ALARM_TYPE_INEXACT_AND_ALLOW_WHILE_IDLE : ALARM_TYPE_EXACT_AND_ALLOW_WHILE_IDLE
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
async cancel(id) {
|
|
116
|
+
await engine().cancelNotification(id);
|
|
117
|
+
},
|
|
118
|
+
async cancelMany(ids) {
|
|
119
|
+
// Sequential rather than parallel: the engine bridges each call to
|
|
120
|
+
// native, and a burst of concurrent cancels is where duplicate-delivery
|
|
121
|
+
// races have historically appeared.
|
|
122
|
+
for (const id of ids) {
|
|
123
|
+
await engine().cancelNotification(id);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
async cancelAll() {
|
|
127
|
+
await engine().cancelAllNotifications();
|
|
128
|
+
},
|
|
129
|
+
async getPending() {
|
|
130
|
+
const raw = await engine().getTriggerNotifications();
|
|
131
|
+
return raw.map(entry => unpackEntry(entry, now)).filter(entry => entry !== undefined)
|
|
132
|
+
// Stop markers are package-owned artifacts. A consumer diffing the
|
|
133
|
+
// device against its own intent would otherwise see a notification it
|
|
134
|
+
// never scheduled and, quite reasonably, cancel it.
|
|
135
|
+
.filter(entry => !isRepeatStopId(entry.id)).sort((a, b) => a.resolvedAt - b.resolvedAt);
|
|
136
|
+
},
|
|
137
|
+
declareTone: tone => platform.declareTone(tone),
|
|
138
|
+
retireTone: channelId => platform.retireTone(channelId),
|
|
139
|
+
declareGroups: groups => platform.declareGroups(groups),
|
|
140
|
+
listDeclaredChannels: () => platform.listDeclaredChannels(),
|
|
141
|
+
getPermission,
|
|
142
|
+
async requestPermission(kind) {
|
|
143
|
+
if (kind === 'display') {
|
|
144
|
+
const result = await engine().requestPermission();
|
|
145
|
+
return toPermissionState(result.authorizationStatus);
|
|
146
|
+
}
|
|
147
|
+
// Exact-alarm capability is granted only through system settings on the
|
|
148
|
+
// versions that gate it — there is no in-app dialog to present.
|
|
149
|
+
if (!platform.gatesExactAlarms()) {
|
|
150
|
+
return 'notRequired';
|
|
151
|
+
}
|
|
152
|
+
await engine().openAlarmPermissionSettings();
|
|
153
|
+
return getPermission('exactAlarm');
|
|
154
|
+
},
|
|
155
|
+
async openSettings(kind) {
|
|
156
|
+
if (kind === 'exactAlarm') {
|
|
157
|
+
if (!platform.gatesExactAlarms()) {
|
|
158
|
+
throw new NotificationError(DIAGNOSTIC_CODES.SETTINGS_UNAVAILABLE, 'No exact-alarm settings screen exists on this platform version.');
|
|
159
|
+
}
|
|
160
|
+
await engine().openAlarmPermissionSettings();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await engine().openNotificationSettings();
|
|
164
|
+
},
|
|
165
|
+
getRestrictions: () => platform.restrictions(now),
|
|
166
|
+
subscribeToInteractions(handler) {
|
|
167
|
+
liveInteractionListeners.add(handler);
|
|
168
|
+
const unsubscribe = engine().onForegroundEvent(raw => {
|
|
169
|
+
const event = toInteraction(raw, now);
|
|
170
|
+
if (event !== undefined) handler(event);
|
|
171
|
+
});
|
|
172
|
+
return () => {
|
|
173
|
+
liveInteractionListeners.delete(handler);
|
|
174
|
+
unsubscribe();
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
async takeInitialInteraction() {
|
|
178
|
+
const raw = await engine().getInitialNotification();
|
|
179
|
+
if (raw === null) return undefined;
|
|
180
|
+
const event = toInteraction(raw, now);
|
|
181
|
+
// A cold-start tap arrives before any handler exists, so it is reported
|
|
182
|
+
// with the state that actually produced it.
|
|
183
|
+
return event === undefined ? undefined : {
|
|
184
|
+
...event,
|
|
185
|
+
appState: 'coldStart'
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
async silenceDelivered(id) {
|
|
189
|
+
const displayed = await engine().getDisplayedNotifications();
|
|
190
|
+
const match = displayed.find(entry => {
|
|
191
|
+
const notification = entry.notification ?? entry;
|
|
192
|
+
return notification.id === id;
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Not displayed is the ordinary outcome, not a failure: the user handled
|
|
196
|
+
// it before the window ran out.
|
|
197
|
+
if (match === undefined) return false;
|
|
198
|
+
const notification = match.notification ?? match;
|
|
199
|
+
const android = notification.android ?? {};
|
|
200
|
+
|
|
201
|
+
// Re-posted under the *same* identifier, so it lands on the same tray
|
|
202
|
+
// slot and replaces in place. Cancelling instead would remove it, and a
|
|
203
|
+
// notification that vanished is worse than one that never sounded — the
|
|
204
|
+
// user comes home to a silent phone and no idea what they missed.
|
|
205
|
+
await engine().displayNotification({
|
|
206
|
+
...notification,
|
|
207
|
+
android: {
|
|
208
|
+
...android,
|
|
209
|
+
loopSound: false,
|
|
210
|
+
// Without this the replacement re-alerts once on its way to going
|
|
211
|
+
// quiet, which is a strange thing to do to someone who has already
|
|
212
|
+
// heard it for fifteen minutes.
|
|
213
|
+
onlyAlertOnce: true
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
return true;
|
|
217
|
+
},
|
|
218
|
+
async listRepeatStops() {
|
|
219
|
+
return unpackRepeatStops(await engine().getTriggerNotifications());
|
|
220
|
+
},
|
|
221
|
+
subscribeToDeliveries(handler) {
|
|
222
|
+
return engine().onForegroundEvent(raw => {
|
|
223
|
+
const event = toDelivery(raw, now);
|
|
224
|
+
if (event !== undefined) handler(event);
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
registerBackgroundDeliveryHandler(handler, onInteraction) {
|
|
228
|
+
engine().onBackgroundEvent(async raw => {
|
|
229
|
+
const delivery = toDelivery(raw, now);
|
|
230
|
+
if (delivery !== undefined) {
|
|
231
|
+
await handler(delivery);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
// A tap, an action or a dismissal while the app was not in front. Until
|
|
235
|
+
// 0.6.0 only deliveries were looked at here, so a background action
|
|
236
|
+
// ("Taken", "Snooze", an inline reply) never reached the app (NOT-10).
|
|
237
|
+
const interaction = toInteraction(raw, now);
|
|
238
|
+
if (interaction === undefined) return;
|
|
239
|
+
const event = {
|
|
240
|
+
...interaction,
|
|
241
|
+
appState: 'background'
|
|
242
|
+
};
|
|
243
|
+
if (liveInteractionListeners.size > 0) {
|
|
244
|
+
// The app's runtime is alive: its handlers get it, as in the foreground.
|
|
245
|
+
for (const listener of [...liveInteractionListeners]) listener(event);
|
|
246
|
+
} else {
|
|
247
|
+
await onInteraction?.(event);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
backgroundHandlerRegistered = true;
|
|
251
|
+
},
|
|
252
|
+
hasBackgroundDeliveryHandler() {
|
|
253
|
+
return backgroundHandlerRegistered;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=notify-kit-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isRepeatStopId","packData","DIAGNOSTIC_CODES","NotificationError","toDelivery","toInteraction","toPermissionState","unpackEntry","unpackRepeatStops","ALARM_TYPE_EXACT_AND_ALLOW_WHILE_IDLE","ALARM_TYPE_INEXACT_AND_ALLOW_WHILE_IDLE","ANDROID_CATEGORY_ALARM","ANDROID_IMPORTANCE","MARKER_CHANNEL_ID","TRIGGER_TYPE_TIMESTAMP","compact","loadEngine","createNotifyKitPlatform","backgroundHandlerRegistered","liveInteractionListeners","Set","createNotifyKitEngine","options","cached","module","engine","now","Date","platform","getPermission","kind","permissionFrom","getNotificationSettings","name","withChannelSnapshot","work","pendingIds","getTriggerNotificationIds","getTriggerNotifications","flatMap","raw","id","notification","getCapabilities","capabilities","schedule","request","actions","map","action","title","pressAction","launchActivity","mode","undefined","input","placeholder","isMarker","repeatStop","ensureMarkerChannel","createTriggerNotification","content","body","subtitle","data","android","channelId","tone","importance","min","sound","groupId","loopSound","category","alarmCategory","ios","categoryId","interruptionLevel","type","timestamp","resolvedAt","alarmManager","allowWhileIdle","approximate","cancel","cancelNotification","cancelMany","ids","cancelAll","cancelAllNotifications","getPending","entry","filter","sort","a","b","declareTone","retireTone","declareGroups","groups","listDeclaredChannels","requestPermission","result","authorizationStatus","gatesExactAlarms","openAlarmPermissionSettings","openSettings","SETTINGS_UNAVAILABLE","openNotificationSettings","getRestrictions","restrictions","subscribeToInteractions","handler","add","unsubscribe","onForegroundEvent","event","delete","takeInitialInteraction","getInitialNotification","appState","silenceDelivered","displayed","getDisplayedNotifications","match","find","displayNotification","onlyAlertOnce","listRepeatStops","subscribeToDeliveries","registerBackgroundDeliveryHandler","onInteraction","onBackgroundEvent","delivery","interaction","size","listener","hasBackgroundDeliveryHandler"],"sourceRoot":"../../../src","sources":["engine/notify-kit-engine.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,cAAc,QAAQ,qBAAkB;AACjD,SAASC,QAAQ,QAAQ,YAAS;AAIlC,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,uBAAoB;AAExE,SACCC,UAAU,EACVC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,iBAAiB,QACX,wBAAqB;AAC5B,SACCC,qCAAqC,EACrCC,uCAAuC,EACvCC,sBAAsB,EACtBC,kBAAkB,EAClBC,iBAAiB,EACjBC,sBAAsB,EACtBC,OAAO,EACPC,UAAU,QAEJ,wBAAqB;AAC5B,SAASC,uBAAuB,QAAQ,gCAAuB;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,2BAA2B,GAAG,KAAK;AACvC;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,wBAAwB,GAAG,IAAIC,GAAG,CAAoC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AK9D,SAAS,EAAE0D,OAAO,CAACI,KAAK,CAAC;MACxC,CAAC,CAAC;IACH,CAAC;IAEDc,iCAAiCA,CAChClB,OAAgD,EAChDmB,aAA0D,EACnD;MACP1G,MAAM,CAAC,CAAC,CAAC2G,iBAAiB,CAAC,MAAM5F,GAAG,IAAI;QACvC,MAAM6F,QAAQ,GAAGjI,UAAU,CAACoC,GAAG,EAAEd,GAAG,CAAC;QACrC,IAAI2G,QAAQ,KAAK/E,SAAS,EAAE;UAC3B,MAAM0D,OAAO,CAACqB,QAAQ,CAAC;UACvB;QACD;QACA;QACA;QACA;QACA,MAAMC,WAAW,GAAGjI,aAAa,CAACmC,GAAG,EAAEd,GAAG,CAAC;QAC3C,IAAI4G,WAAW,KAAKhF,SAAS,EAAE;QAC/B,MAAM8D,KAAuB,GAAG;UAAE,GAAGkB,WAAW;UAAEd,QAAQ,EAAE;QAAa,CAAC;QAC1E,IAAIrG,wBAAwB,CAACoH,IAAI,GAAG,CAAC,EAAE;UACtC;UACA,KAAK,MAAMC,QAAQ,IAAI,CAAC,GAAGrH,wBAAwB,CAAC,EAAEqH,QAAQ,CAACpB,KAAK,CAAC;QACtE,CAAC,MAAM;UACN,MAAMe,aAAa,GAAGf,KAAK,CAAC;QAC7B;MACD,CAAC,CAAC;MACFlG,2BAA2B,GAAG,IAAI;IACnC,CAAC;IAEDuH,4BAA4BA,CAAA,EAAY;MACvC,OAAOvH,2BAA2B;IACnC;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @chipmobilesdk/rn-notification
|
|
5
|
+
*
|
|
6
|
+
* Default entrypoint: scheduling, recurrence, reconciliation, permissions,
|
|
7
|
+
* channels, interaction, and diagnostics.
|
|
8
|
+
*
|
|
9
|
+
* Push lives behind `@chipmobilesdk/rn-notification/push` so an app that never
|
|
10
|
+
* enables it ships no provider code, no push permissions, and no entitlements.
|
|
11
|
+
* Test doubles live behind `@chipmobilesdk/rn-notification/testing` so they
|
|
12
|
+
* never reach a production bundle.
|
|
13
|
+
*
|
|
14
|
+
* No engine, provider, or storage type is reachable from here — that is what
|
|
15
|
+
* makes each of them replaceable.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export { DEFAULT_ANCHORING_MODE, DEFAULT_LOOKAHEAD, REPEAT_ALERT_BOUNDS, LOOKAHEAD_BOUNDS, INTERACTION_BUFFER_LIMITS, MAX_ROUTING_PAYLOAD_BYTES, MAX_ACTIONS_PER_NOTIFICATION, DEFAULT_BURST_THRESHOLD, DIAGNOSTIC_CODES, ALL_DIAGNOSTIC_CODES, NotificationError, isNotificationError, isNonFailure } from "./contract/index.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The engine port. Exported so a consuming app can supply its own engine, which
|
|
22
|
+
* is the mechanism behind provider and engine substitution.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** The default engine. Consumers may substitute their own via the port above. */
|
|
26
|
+
export { createNotifyKitEngine } from "./engine/notify-kit-engine.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The whole package, assembled (0.6.0): scheduler, reconciler, recurrence,
|
|
30
|
+
* permissions, channels, interactions, snapshot and maintenance, wired the way the
|
|
31
|
+
* package means them to be. Start here; the factories below are for an app that
|
|
32
|
+
* needs a different wiring, and are also exported from `./advanced`.
|
|
33
|
+
*/
|
|
34
|
+
export { createNotifications } from "./notifications.js";
|
|
35
|
+
/** Initialization and the assembled runtime. */
|
|
36
|
+
export { initialize } from "./initialize.js";
|
|
37
|
+
/** Scheduling operations. */
|
|
38
|
+
export { createScheduler } from "./schedule/index.js";
|
|
39
|
+
/** Reconciliation — always consumer-invoked, never automatic. */
|
|
40
|
+
export { createReconciler } from "./reconcile/index.js";
|
|
41
|
+
/** Recurrence — declare a rule once; the package maintains a bounded window. */
|
|
42
|
+
export { createRecurrence } from "./recurrence/index.js";
|
|
43
|
+
export { occurrenceId } from "./recurrence/expand.js";
|
|
44
|
+
|
|
45
|
+
/** Channels and tones — declared once, mapped to each platform, migrated on change. */
|
|
46
|
+
export { createChannels } from "./channel/migrate.js";
|
|
47
|
+
export { channelIdFor, createToneResolver, parseChannelId, resolveTone } from "./channel/tone-map.js";
|
|
48
|
+
export { validateToneDeclaration, validateToneDeclarations } from "./channel/validate-tone.js";
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Repeat expiry — what bounds an alert that repeats until it is handled.
|
|
52
|
+
*
|
|
53
|
+
* `registerBackgroundNotificationHandler` is the one piece a consumer wires up
|
|
54
|
+
* themselves, at module scope in `index.js`. An app that declares no repeating
|
|
55
|
+
* tone needs none of this.
|
|
56
|
+
*/
|
|
57
|
+
export { createRepeatExpiryHandler, registerBackgroundNotificationHandler, REPEAT_STOP_PREFIX } from "./repeat/index.js";
|
|
58
|
+
/** Interaction routing — one handler for foreground, background, and cold start. */
|
|
59
|
+
export { createInteractions } from "./interaction/index.js";
|
|
60
|
+
/** Observability — snapshot and burst detection. */
|
|
61
|
+
export { createSnapshot } from "./diagnostics/snapshot.js";
|
|
62
|
+
export { createBurstDetector } from "./diagnostics/burst.js";
|
|
63
|
+
export { DiagnosticEmitter } from "./diagnostics/events.js";
|
|
64
|
+
|
|
65
|
+
/** Permission coordination — reading never prompts; a refusal never fails the caller. */
|
|
66
|
+
export { createPermissions } from "./permission/index.js";
|
|
67
|
+
export { canDisplay, capabilityFor, isTerminal, shouldOfferSettings } from "./permission/state.js";
|
|
68
|
+
/** Maintenance steps, registered with the runtime's registry. */
|
|
69
|
+
export { createPermissionRefreshStep } from "./maintenance/permission-refresh.js";
|
|
70
|
+
export { createReAnchorStep } from "./maintenance/reanchor.js";
|
|
71
|
+
export { createVerifyStep } from "./maintenance/verify.js";
|
|
72
|
+
export { createWindowRefreshStep } from "./maintenance/window-refresh.js";
|
|
73
|
+
export { MaintenanceRegistry, MaintenanceScopeViolation } from "./maintenance/cycle.js";
|
|
74
|
+
export { MaintenanceController } from "./maintenance/toggle.js";
|
|
75
|
+
|
|
76
|
+
/** Public state controls — the only two ways a consumer may touch persisted state. */
|
|
77
|
+
export { resetState, clearOwner } from "./state/reset.js";
|
|
78
|
+
/**
|
|
79
|
+
* State plumbing. The record's *schema* stays private — a consumer can create
|
|
80
|
+
* and reset the store, but has no way to read or write what is inside it.
|
|
81
|
+
*/
|
|
82
|
+
export { createMmkvStore } from "./state/mmkv-store.js";
|
|
83
|
+
export { StateManager } from "./state/record.js";
|
|
84
|
+
/** Documented limits, exported so a consumer can validate before calling. */
|
|
85
|
+
export { MAX_IDENTIFIER_LENGTH } from "./schedule/validate-identifier.js";
|
|
86
|
+
export { CONTENT_LIMITS } from "./schedule/validate-content.js";
|
|
87
|
+
export { PAST_TOLERANCE_MS } from "./schedule/resolve-moment.js";
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Reads the platform time zone, which anchoring depends on.
|
|
91
|
+
*
|
|
92
|
+
* Exported because every consumer needs it and pure JavaScript cannot provide
|
|
93
|
+
* it reliably — `Intl.DateTimeFormat().resolvedOptions().timeZone` does not
|
|
94
|
+
* update when the device zone changes. Leaving consumers to write this
|
|
95
|
+
* themselves is how a subtly wrong version ends up in each of them.
|
|
96
|
+
*/
|
|
97
|
+
export { createPlatformTimeZoneReader, isValidTimeZone } from "./schedule/anchor.js";
|
|
98
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_ANCHORING_MODE","DEFAULT_LOOKAHEAD","REPEAT_ALERT_BOUNDS","LOOKAHEAD_BOUNDS","INTERACTION_BUFFER_LIMITS","MAX_ROUTING_PAYLOAD_BYTES","MAX_ACTIONS_PER_NOTIFICATION","DEFAULT_BURST_THRESHOLD","DIAGNOSTIC_CODES","ALL_DIAGNOSTIC_CODES","NotificationError","isNotificationError","isNonFailure","createNotifyKitEngine","createNotifications","initialize","createScheduler","createReconciler","createRecurrence","occurrenceId","createChannels","channelIdFor","createToneResolver","parseChannelId","resolveTone","validateToneDeclaration","validateToneDeclarations","createRepeatExpiryHandler","registerBackgroundNotificationHandler","REPEAT_STOP_PREFIX","createInteractions","createSnapshot","createBurstDetector","DiagnosticEmitter","createPermissions","canDisplay","capabilityFor","isTerminal","shouldOfferSettings","createPermissionRefreshStep","createReAnchorStep","createVerifyStep","createWindowRefreshStep","MaintenanceRegistry","MaintenanceScopeViolation","MaintenanceController","resetState","clearOwner","createMmkvStore","StateManager","MAX_IDENTIFIER_LENGTH","CONTENT_LIMITS","PAST_TOLERANCE_MS","createPlatformTimeZoneReader","isValidTimeZone"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmEA,SACCA,sBAAsB,EACtBC,iBAAiB,EACjBC,mBAAmB,EACnBC,gBAAgB,EAChBC,yBAAyB,EACzBC,yBAAyB,EACzBC,4BAA4B,EAC5BC,uBAAuB,EACvBC,gBAAgB,EAChBC,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,YAAY,QACN,qBAAY;;AAInB;AACA;AACA;AACA;;AAUA;AACA,SAASC,qBAAqB,QAAQ,+BAA4B;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,mBAAmB,QAAQ,oBAAiB;AAGrD;AACA,SAASC,UAAU,QAAQ,iBAAc;AAGzC;AACA,SAASC,eAAe,QAAQ,qBAAY;AAG5C;AACA,SAASC,gBAAgB,QAAQ,sBAAa;AAG9C;AACA,SAASC,gBAAgB,QAAQ,uBAAc;AAE/C,SAASC,YAAY,QAAQ,wBAAqB;;AAElD;AACA,SAASC,cAAc,QAAQ,sBAAmB;AAElD,SAASC,YAAY,EAAEC,kBAAkB,EAAEC,cAAc,EAAEC,WAAW,QAAQ,uBAAoB;AAClG,SAASC,uBAAuB,EAAEC,wBAAwB,QAAQ,4BAAyB;;AAE3F;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACCC,yBAAyB,EACzBC,qCAAqC,EACrCC,kBAAkB,QACZ,mBAAU;AAOjB;AACA,SAASC,kBAAkB,QAAQ,wBAAe;AAGlD;AACA,SAASC,cAAc,QAAQ,2BAAwB;AAEvD,SAASC,mBAAmB,QAAQ,wBAAqB;AAEzD,SAASC,iBAAiB,QAAQ,yBAAsB;;AAExD;AACA,SAASC,iBAAiB,QAAQ,uBAAc;AAEhD,SAASC,UAAU,EAAEC,aAAa,EAAEC,UAAU,EAAEC,mBAAmB,QAAQ,uBAAoB;AAG/F;AACA,SAASC,2BAA2B,QAAQ,qCAAkC;AAC9E,SAASC,kBAAkB,QAAQ,2BAAwB;AAC3D,SAASC,gBAAgB,QAAQ,yBAAsB;AACvD,SAASC,uBAAuB,QAAQ,iCAA8B;AAEtE,SAASC,mBAAmB,EAAEC,yBAAyB,QAAQ,wBAAqB;AACpF,SAASC,qBAAqB,QAAQ,yBAAsB;;AAE5D;AACA,SAASC,UAAU,EAAEC,UAAU,QAAQ,kBAAe;AAGtD;AACA;AACA;AACA;AACA,SAASC,eAAe,QAAQ,uBAAoB;AACpD,SAASC,YAAY,QAAQ,mBAAgB;AAG7C;AACA,SAASC,qBAAqB,QAAQ,mCAAgC;AACtE,SAASC,cAAc,QAAQ,gCAA6B;AAC5D,SAASC,iBAAiB,QAAQ,8BAA2B;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,4BAA4B,EAAEC,eAAe,QAAQ,sBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Package initialization.
|
|
5
|
+
*
|
|
6
|
+
* Composes the parts that must be in place before the first schedule call:
|
|
7
|
+
* validate configuration, load persisted state, apply tone declarations, run
|
|
8
|
+
* any pending channel migration, and start the maintenance registry.
|
|
9
|
+
*
|
|
10
|
+
* Budgeted at 100 ms of app startup, which is why state loading is synchronous
|
|
11
|
+
* and tone declaration is the only platform round-trip.
|
|
12
|
+
*
|
|
13
|
+
* Automatic maintenance is started here too: whatever steps are registered on
|
|
14
|
+
* `runtime.registry` run when the app returns to the foreground, with the
|
|
15
|
+
* trigger reported as `timeZoneChange` when the device zone moved meanwhile.
|
|
16
|
+
* Until 0.4.0 nothing ever called `runAutomatic`, so "automatic" maintenance
|
|
17
|
+
* only ran when the app invoked it by hand.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { appLifecycle } from '@chipmobilesdk/rn-core';
|
|
21
|
+
import { DEFAULT_LOOKAHEAD, LOOKAHEAD_BOUNDS } from "./contract/recurrence.js";
|
|
22
|
+
import { DIAGNOSTIC_CODES, NotificationError } from "./contract/errors.js";
|
|
23
|
+
import { DiagnosticEmitter } from "./diagnostics/events.js";
|
|
24
|
+
import { MaintenanceRegistry } from "./maintenance/cycle.js";
|
|
25
|
+
import { MaintenanceController } from "./maintenance/toggle.js";
|
|
26
|
+
import { StateManager } from "./state/record.js";
|
|
27
|
+
import { ownedIdentifiers } from "./state/series-ledger.js";
|
|
28
|
+
import { createChannels } from "./channel/migrate.js";
|
|
29
|
+
import { createPlatformTimeZoneReader } from "./schedule/anchor.js";
|
|
30
|
+
|
|
31
|
+
/** The slice of React Native's `AppState` the lifecycle observer uses. */
|
|
32
|
+
|
|
33
|
+
/** rn-core's shared lifecycle port in the observer's shape: one native subscription for every package (PERF-07). */
|
|
34
|
+
const sharedLifecycle = {
|
|
35
|
+
addEventListener: (_type, listener) => ({
|
|
36
|
+
remove: appLifecycle().subscribe(state => listener(state))
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Everything assembled at initialization, shared by the operation modules. */
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Clamps the lookahead into its documented bounds.
|
|
44
|
+
*
|
|
45
|
+
* Bounded on adjustment because the platform ceiling is not negotiable: a
|
|
46
|
+
* consumer asking for a five-year window would silently exhaust the 64-entry
|
|
47
|
+
* iOS ceiling on the first frequent series.
|
|
48
|
+
*/
|
|
49
|
+
export function resolveLookahead(partial) {
|
|
50
|
+
const days = partial?.days ?? DEFAULT_LOOKAHEAD.days;
|
|
51
|
+
const occurrencesPerSeries = partial?.occurrencesPerSeries ?? DEFAULT_LOOKAHEAD.occurrencesPerSeries;
|
|
52
|
+
return {
|
|
53
|
+
days: Math.min(Math.max(days, LOOKAHEAD_BOUNDS.minDays), LOOKAHEAD_BOUNDS.maxDays),
|
|
54
|
+
occurrencesPerSeries: Math.min(Math.max(occurrencesPerSeries, LOOKAHEAD_BOUNDS.minOccurrences), LOOKAHEAD_BOUNDS.maxOccurrences)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Fails before any platform call, so a bad configuration never half-applies. */
|
|
59
|
+
export function validateConfig(config) {
|
|
60
|
+
if (config.tones.length === 0) {
|
|
61
|
+
throw new NotificationError(DIAGNOSTIC_CODES.UNDECLARED_TONE, 'At least one tone must be declared before notifications can be scheduled.');
|
|
62
|
+
}
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
for (const tone of config.tones) {
|
|
65
|
+
if (seen.has(tone.id)) {
|
|
66
|
+
throw new NotificationError(DIAGNOSTIC_CODES.UNDECLARED_TONE, `Tone "${tone.id}" is declared more than once.`, {
|
|
67
|
+
toneId: tone.id
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
seen.add(tone.id);
|
|
71
|
+
if (!Number.isInteger(tone.version) || tone.version < 1) {
|
|
72
|
+
throw new NotificationError(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.`, {
|
|
73
|
+
toneId: tone.id,
|
|
74
|
+
version: tone.version
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const groupIds = new Set((config.channelGroups ?? []).map(group => group.id));
|
|
79
|
+
for (const tone of config.tones) {
|
|
80
|
+
if (tone.groupId !== undefined && !groupIds.has(tone.groupId)) {
|
|
81
|
+
throw new NotificationError(DIAGNOSTIC_CODES.UNDECLARED_TONE, `Tone "${tone.id}" references undeclared channel group "${tone.groupId}".`, {
|
|
82
|
+
toneId: tone.id,
|
|
83
|
+
groupId: tone.groupId
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export async function initialize(config, deps) {
|
|
89
|
+
const now = deps.now ?? (() => Date.now());
|
|
90
|
+
const startedAt = now();
|
|
91
|
+
validateConfig(config);
|
|
92
|
+
const emitter = new DiagnosticEmitter({
|
|
93
|
+
sink: config.eventSink,
|
|
94
|
+
verbose: config.verboseDiagnostics,
|
|
95
|
+
now
|
|
96
|
+
});
|
|
97
|
+
const state = new StateManager({
|
|
98
|
+
store: deps.store,
|
|
99
|
+
now,
|
|
100
|
+
emit: event => emitter.emit(event.code, describeStateEvent(event.code), event.context)
|
|
101
|
+
});
|
|
102
|
+
const channels = createChannels({
|
|
103
|
+
engine: deps.engine,
|
|
104
|
+
state,
|
|
105
|
+
now,
|
|
106
|
+
// The channel module emits only DIAGNOSTIC_CODES values; its port types the
|
|
107
|
+
// code as a string so it stays usable without the emitter.
|
|
108
|
+
emit: (code, message, context) => emitter.emit(code, message, context)
|
|
109
|
+
});
|
|
110
|
+
// Declares groups and tones, and runs any version migration. An unchanged
|
|
111
|
+
// configuration costs no platform work, so doing this on every launch is free.
|
|
112
|
+
const applied = await channels.apply(config.tones, config.channelGroups ?? []);
|
|
113
|
+
const registry = new MaintenanceRegistry({
|
|
114
|
+
clock: now
|
|
115
|
+
});
|
|
116
|
+
const maintenance = new MaintenanceController({
|
|
117
|
+
registry,
|
|
118
|
+
now,
|
|
119
|
+
// Occurrence identifiers, not series identifiers. Maintenance cancels
|
|
120
|
+
// occurrences, so a set of series ids made every legitimate cancel look
|
|
121
|
+
// like a scope violation.
|
|
122
|
+
ownedIds: async () => ownedIdentifiers(state, (await deps.engine.getPending()).map(entry => entry.id)),
|
|
123
|
+
enabled: config.automaticMaintenance ?? true
|
|
124
|
+
});
|
|
125
|
+
const timeZone = deps.timeZone ?? createPlatformTimeZoneReader();
|
|
126
|
+
let lastZone = timeZone();
|
|
127
|
+
let lastAutomatic;
|
|
128
|
+
const onAppState = next => {
|
|
129
|
+
if (next !== 'active') return;
|
|
130
|
+
const zone = timeZone();
|
|
131
|
+
const trigger = zone !== lastZone ? 'timeZoneChange' : 'foreground';
|
|
132
|
+
lastZone = zone;
|
|
133
|
+
maintenance.runAutomatic(trigger).then(result => {
|
|
134
|
+
if (result !== undefined) lastAutomatic = result;
|
|
135
|
+
}, error => {
|
|
136
|
+
// Nothing awaits an automatic cycle, so a failure is reported here or
|
|
137
|
+
// not at all.
|
|
138
|
+
emitter.emit(DIAGNOSTIC_CODES.MAINTENANCE_FAILED, `Automatic maintenance (${trigger}) failed: ${error instanceof Error ? error.name : 'unknown error'}.`, {
|
|
139
|
+
trigger
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
const subscription = (deps.appState ?? sharedLifecycle).addEventListener('change', onAppState);
|
|
144
|
+
const runtime = {
|
|
145
|
+
engine: deps.engine,
|
|
146
|
+
state,
|
|
147
|
+
emitter,
|
|
148
|
+
registry,
|
|
149
|
+
maintenance,
|
|
150
|
+
channels,
|
|
151
|
+
lookahead: resolveLookahead(config.lookahead),
|
|
152
|
+
config,
|
|
153
|
+
now,
|
|
154
|
+
lastAutomaticMaintenance: () => lastAutomatic,
|
|
155
|
+
dispose: () => subscription.remove()
|
|
156
|
+
};
|
|
157
|
+
return {
|
|
158
|
+
runtime,
|
|
159
|
+
result: {
|
|
160
|
+
tonesApplied: config.tones.length,
|
|
161
|
+
migrationsRun: applied.migrated.length,
|
|
162
|
+
stateRebuilt: state.health().rebuilt,
|
|
163
|
+
automaticMaintenance: maintenance.isEnabled,
|
|
164
|
+
durationMs: now() - startedAt
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function describeStateEvent(code) {
|
|
169
|
+
switch (code) {
|
|
170
|
+
case DIAGNOSTIC_CODES.STATE_CORRUPT_REBUILT:
|
|
171
|
+
return 'Persisted state was unreadable and has been rebuilt. Deduplication history and buffered interactions from before the loss are gone; scheduled notifications are unaffected.';
|
|
172
|
+
case DIAGNOSTIC_CODES.STATE_WRITE_FAILED:
|
|
173
|
+
return 'Persisted state could not be written. The affected guarantee degrades to this session only.';
|
|
174
|
+
case DIAGNOSTIC_CODES.STATE_CAP_EVICTED:
|
|
175
|
+
return 'A persisted collection reached its cap and the oldest entries were evicted.';
|
|
176
|
+
case DIAGNOSTIC_CODES.INTERACTION_BUFFER_EVICTED:
|
|
177
|
+
return 'Buffered interactions were evicted at the cap or retention limit.';
|
|
178
|
+
default:
|
|
179
|
+
return 'Persisted state event.';
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=initialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["appLifecycle","DEFAULT_LOOKAHEAD","LOOKAHEAD_BOUNDS","DIAGNOSTIC_CODES","NotificationError","DiagnosticEmitter","MaintenanceRegistry","MaintenanceController","StateManager","ownedIdentifiers","createChannels","createPlatformTimeZoneReader","sharedLifecycle","addEventListener","_type","listener","remove","subscribe","state","resolveLookahead","partial","days","occurrencesPerSeries","Math","min","max","minDays","maxDays","minOccurrences","maxOccurrences","validateConfig","config","tones","length","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","sink","eventSink","verbose","verboseDiagnostics","store","emit","event","code","describeStateEvent","context","channels","engine","message","applied","apply","registry","clock","maintenance","ownedIds","getPending","entry","enabled","automaticMaintenance","timeZone","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":"../../src","sources":["initialize.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,wBAAwB;AAErD,SAASC,iBAAiB,EAAEC,gBAAgB,QAA8B,0BAAuB;AAEjG,SAASC,gBAAgB,EAAEC,iBAAiB,QAA6B,sBAAmB;AAC5F,SAASC,iBAAiB,QAAQ,yBAAsB;AACxD,SAASC,mBAAmB,QAAQ,wBAAqB;AACzD,SAASC,qBAAqB,QAAQ,yBAAsB;AAC5D,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,0BAAuB;AAGxD,SAASC,cAAc,QAAuB,sBAAmB;AACjE,SAASC,4BAA4B,QAA6B,sBAAmB;;AAErF;;AAKA;AACA,MAAMC,eAA+B,GAAG;EACvCC,gBAAgB,EAAEA,CAACC,KAAK,EAAEC,QAAQ,MAAM;IACvCC,MAAM,EAAEhB,YAAY,CAAC,CAAC,CAACiB,SAAS,CAACC,KAAK,IAAIH,QAAQ,CAACG,KAAK,CAAC;EAC1D,CAAC;AACF,CAAC;;AAYD;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACC,OAA6C,EAAmB;EAChG,MAAMC,IAAI,GAAGD,OAAO,EAAEC,IAAI,IAAIpB,iBAAiB,CAACoB,IAAI;EACpD,MAAMC,oBAAoB,GACzBF,OAAO,EAAEE,oBAAoB,IAAIrB,iBAAiB,CAACqB,oBAAoB;EAExE,OAAO;IACND,IAAI,EAAEE,IAAI,CAACC,GAAG,CAACD,IAAI,CAACE,GAAG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