@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,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One call that assembles the whole package (NOT-07).
|
|
5
|
+
*
|
|
6
|
+
* Until 0.5.0 an app wired a dozen factories itself — scheduler, reconciler,
|
|
7
|
+
* recurrence, permissions, channels, interactions, snapshot, maintenance steps
|
|
8
|
+
* — repeating the engine, tone resolver, clock and time-zone reader for each,
|
|
9
|
+
* and usually hard-coding `canScheduleExactly: () => true`. `createNotifications`
|
|
10
|
+
* does that wiring once, the way the package means it:
|
|
11
|
+
*
|
|
12
|
+
* - every part reports through the one redacting diagnostic emitter;
|
|
13
|
+
* - `canScheduleExactly` follows the exact-alarm permission the package last
|
|
14
|
+
* read, instead of a guess;
|
|
15
|
+
* - automatic maintenance has the standard steps registered (re-anchoring after
|
|
16
|
+
* a time-zone change, refreshing permissions, and refreshing recurrence
|
|
17
|
+
* windows when the app supplies its rules), so it does something on every
|
|
18
|
+
* return to the foreground.
|
|
19
|
+
*
|
|
20
|
+
* The individual factories stay exported for an app that needs a different
|
|
21
|
+
* wiring; they are also available from `@chipmobilesdk/rn-notification/advanced`.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { createToneResolver } from "./channel/tone-map.js";
|
|
25
|
+
import { createSnapshot } from "./diagnostics/snapshot.js";
|
|
26
|
+
import { createNotifyKitEngine } from "./engine/notify-kit-engine.js";
|
|
27
|
+
import { detectPlatform } from "./engine/notify-kit/platform/index.js";
|
|
28
|
+
import { initialize } from "./initialize.js";
|
|
29
|
+
import { createInteractions } from "./interaction/index.js";
|
|
30
|
+
import { createPermissionRefreshStep } from "./maintenance/permission-refresh.js";
|
|
31
|
+
import { createReAnchorStep } from "./maintenance/reanchor.js";
|
|
32
|
+
import { createWindowRefreshStep } from "./maintenance/window-refresh.js";
|
|
33
|
+
import { createPermissions } from "./permission/index.js";
|
|
34
|
+
import { createReconciler } from "./reconcile/index.js";
|
|
35
|
+
import { createRecurrence } from "./recurrence/index.js";
|
|
36
|
+
import { createScheduler } from "./schedule/index.js";
|
|
37
|
+
import { createPlatformTimeZoneReader } from "./schedule/anchor.js";
|
|
38
|
+
import { createMmkvStore } from "./state/mmkv-store.js";
|
|
39
|
+
/** Exact scheduling only on a positive answer; unknown degrades to approximate, never fails. */
|
|
40
|
+
function allowsExact(state) {
|
|
41
|
+
return state === 'granted' || state === 'notRequired';
|
|
42
|
+
}
|
|
43
|
+
export async function createNotifications(config, deps = {}) {
|
|
44
|
+
const engine = deps.engine ?? createNotifyKitEngine();
|
|
45
|
+
const now = deps.now ?? (() => Date.now());
|
|
46
|
+
const timeZone = deps.timeZone ?? createPlatformTimeZoneReader();
|
|
47
|
+
const {
|
|
48
|
+
runtime,
|
|
49
|
+
result
|
|
50
|
+
} = await initialize(config, {
|
|
51
|
+
engine,
|
|
52
|
+
store: deps.store ?? createMmkvStore(),
|
|
53
|
+
now,
|
|
54
|
+
timeZone
|
|
55
|
+
});
|
|
56
|
+
const {
|
|
57
|
+
state
|
|
58
|
+
} = runtime;
|
|
59
|
+
const emit = (code, message, context) => runtime.emitter.emit(code, message, context);
|
|
60
|
+
const resolveTone = createToneResolver(config.tones);
|
|
61
|
+
const permissions = createPermissions({
|
|
62
|
+
engine,
|
|
63
|
+
state,
|
|
64
|
+
platform: deps.platform ?? detectPlatform(),
|
|
65
|
+
now,
|
|
66
|
+
emit
|
|
67
|
+
});
|
|
68
|
+
let exactAlarm;
|
|
69
|
+
const stopWatchingPermissions = permissions.onPermissionChange(report => {
|
|
70
|
+
exactAlarm = report.exactAlarm;
|
|
71
|
+
});
|
|
72
|
+
// Seeds the answer before anything is scheduled. A failed read leaves it
|
|
73
|
+
// unknown, which schedules in approximate mode rather than failing.
|
|
74
|
+
await permissions.getPermissions().catch(() => undefined);
|
|
75
|
+
const canScheduleExactly = () => allowsExact(exactAlarm);
|
|
76
|
+
const scheduling = {
|
|
77
|
+
engine,
|
|
78
|
+
resolveTone,
|
|
79
|
+
timeZone,
|
|
80
|
+
now,
|
|
81
|
+
canScheduleExactly,
|
|
82
|
+
emit
|
|
83
|
+
};
|
|
84
|
+
const scheduler = createScheduler(scheduling);
|
|
85
|
+
const reconcilerCore = createReconciler(scheduling);
|
|
86
|
+
let lastReconcile;
|
|
87
|
+
const reconciler = {
|
|
88
|
+
...reconcilerCore,
|
|
89
|
+
async reconcile(input) {
|
|
90
|
+
lastReconcile = await reconcilerCore.reconcile(input);
|
|
91
|
+
return lastReconcile;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const recurrence = createRecurrence({
|
|
95
|
+
...scheduling,
|
|
96
|
+
state,
|
|
97
|
+
lookahead: runtime.lookahead
|
|
98
|
+
});
|
|
99
|
+
const interactions = createInteractions({
|
|
100
|
+
engine,
|
|
101
|
+
state,
|
|
102
|
+
now,
|
|
103
|
+
emit
|
|
104
|
+
});
|
|
105
|
+
let lastExplicit;
|
|
106
|
+
const snapshot = createSnapshot({
|
|
107
|
+
engine,
|
|
108
|
+
state,
|
|
109
|
+
now,
|
|
110
|
+
permissions: () => permissions.getPermissions(),
|
|
111
|
+
restrictions: () => permissions.getBackgroundRestrictions(),
|
|
112
|
+
appliedTones: () => runtime.channels.appliedVersions(),
|
|
113
|
+
lastReconcile: () => lastReconcile,
|
|
114
|
+
lastMaintenance: () => runtime.lastAutomaticMaintenance() ?? lastExplicit,
|
|
115
|
+
hasPushToken: deps.hasPushToken ?? (() => false)
|
|
116
|
+
});
|
|
117
|
+
const unregister = [runtime.registry.register(createReAnchorStep({
|
|
118
|
+
engine,
|
|
119
|
+
timeZone,
|
|
120
|
+
resolveTone,
|
|
121
|
+
canScheduleExactly,
|
|
122
|
+
emit
|
|
123
|
+
})), runtime.registry.register(createPermissionRefreshStep({
|
|
124
|
+
permissions
|
|
125
|
+
})), ...(deps.recurrenceRules ? [runtime.registry.register(createWindowRefreshStep({
|
|
126
|
+
recurrence,
|
|
127
|
+
registeredRules: deps.recurrenceRules,
|
|
128
|
+
emit
|
|
129
|
+
}))] : [])];
|
|
130
|
+
return {
|
|
131
|
+
scheduler,
|
|
132
|
+
reconciler,
|
|
133
|
+
recurrence,
|
|
134
|
+
permissions,
|
|
135
|
+
channels: runtime.channels,
|
|
136
|
+
interactions,
|
|
137
|
+
snapshot,
|
|
138
|
+
runtime,
|
|
139
|
+
initialization: result,
|
|
140
|
+
timeZone,
|
|
141
|
+
onInteraction: handler => interactions.onInteraction(handler),
|
|
142
|
+
async runMaintenance() {
|
|
143
|
+
lastExplicit = await runtime.maintenance.runExplicit();
|
|
144
|
+
return lastExplicit;
|
|
145
|
+
},
|
|
146
|
+
canScheduleExactly,
|
|
147
|
+
dispose() {
|
|
148
|
+
stopWatchingPermissions();
|
|
149
|
+
for (const remove of unregister) {
|
|
150
|
+
remove();
|
|
151
|
+
}
|
|
152
|
+
interactions.dispose();
|
|
153
|
+
runtime.dispose();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createToneResolver","createSnapshot","createNotifyKitEngine","detectPlatform","initialize","createInteractions","createPermissionRefreshStep","createReAnchorStep","createWindowRefreshStep","createPermissions","createReconciler","createRecurrence","createScheduler","createPlatformTimeZoneReader","createMmkvStore","allowsExact","state","createNotifications","config","deps","engine","now","Date","timeZone","runtime","result","store","emit","code","message","context","emitter","resolveTone","tones","permissions","platform","exactAlarm","stopWatchingPermissions","onPermissionChange","report","getPermissions","catch","undefined","canScheduleExactly","scheduling","scheduler","reconcilerCore","lastReconcile","reconciler","reconcile","input","recurrence","lookahead","interactions","lastExplicit","snapshot","restrictions","getBackgroundRestrictions","appliedTones","channels","appliedVersions","lastMaintenance","lastAutomaticMaintenance","hasPushToken","unregister","registry","register","recurrenceRules","registeredRules","initialization","onInteraction","handler","runMaintenance","maintenance","runExplicit","dispose","remove"],"sourceRoot":"../../src","sources":["notifications.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,kBAAkB,QAAQ,uBAAoB;AAMvD,SAASC,cAAc,QAAuB,2BAAwB;AAEtE,SAASC,qBAAqB,QAAQ,+BAA4B;AAClE,SAASC,cAAc,QAAQ,uCAA8B;AAC7D,SAASC,UAAU,QAAkC,iBAAc;AACnE,SAASC,kBAAkB,QAA2B,wBAAe;AACrE,SAASC,2BAA2B,QAAQ,qCAAkC;AAC9E,SAASC,kBAAkB,QAAQ,2BAAwB;AAC3D,SAASC,uBAAuB,QAAQ,iCAA8B;AACtE,SAASC,iBAAiB,QAA0B,uBAAc;AAElE,SAASC,gBAAgB,QAAyB,sBAAa;AAC/D,SAASC,gBAAgB,QAAyB,uBAAc;AAChE,SAASC,eAAe,QAAwB,qBAAY;AAC5D,SAASC,4BAA4B,QAA6B,sBAAmB;AACrF,SAASC,eAAe,QAAQ,uBAAoB;AA8CpD;AACA,SAASC,WAAWA,CAACC,KAAkC,EAAW;EACjE,OAAOA,KAAK,KAAK,SAAS,IAAIA,KAAK,KAAK,aAAa;AACtD;AAEA,OAAO,eAAeC,mBAAmBA,CACxCC,MAA0B,EAC1BC,IAA+B,GAAG,CAAC,CAAC,EACX;EACzB,MAAMC,MAAM,GAAGD,IAAI,CAACC,MAAM,IAAIlB,qBAAqB,CAAC,CAAC;EACrD,MAAMmB,GAAG,GAAGF,IAAI,CAACE,GAAG,KAAK,MAAMC,IAAI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2BAA2B,CAAC;IAAE4B;EAAY,CAAC,CAAC,CAAC,EACvE,IAAIf,IAAI,CAACgD,eAAe,GACrB,CACA3C,OAAO,CAACyC,QAAQ,CAACC,QAAQ,CACxB1D,uBAAuB,CAAC;IAAE2C,UAAU;IAAEiB,eAAe,EAAEjD,IAAI,CAACgD,eAAe;IAAExC;EAAK,CAAC,CACpF,CAAC,CACD,GACA,EAAE,CAAC,CACN;EAED,OAAO;IACNkB,SAAS;IACTG,UAAU;IACVG,UAAU;IACVjB,WAAW;IACXyB,QAAQ,EAAEnC,OAAO,CAACmC,QAAQ;IAC1BN,YAAY;IACZE,QAAQ;IACR/B,OAAO;IACP6C,cAAc,EAAE5C,MAAM;IACtBF,QAAQ;IACR+C,aAAa,EAAEC,OAAO,IAAIlB,YAAY,CAACiB,aAAa,CAACC,OAAO,CAAC;IAC7D,MAAMC,cAAcA,CAAA,EAAG;MACtBlB,YAAY,GAAG,MAAM9B,OAAO,CAACiD,WAAW,CAACC,WAAW,CAAC,CAAC;MACtD,OAAOpB,YAAY;IACpB,CAAC;IACDX,kBAAkB;IAClBgC,OAAOA,CAAA,EAAG;MACTtC,uBAAuB,CAAC,CAAC;MACzB,KAAK,MAAMuC,MAAM,IAAIZ,UAAU,EAAE;QAChCY,MAAM,CAAC,CAAC;MACT;MACAvB,YAAY,CAACsB,OAAO,CAAC,CAAC;MACtBnD,OAAO,CAACmD,OAAO,CAAC,CAAC;IAClB;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Permission coordination.
|
|
5
|
+
*
|
|
6
|
+
* Two rules shape everything here. Reading state never prompts, so the consumer
|
|
7
|
+
* decides when the user is asked — a prompt at the wrong moment is a permanent
|
|
8
|
+
* denial. And a refusal never fails the caller's business operation: the user's
|
|
9
|
+
* actual work completes, and the lost capability is reported separately.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { DIAGNOSTIC_CODES, NotificationError } from "../contract/errors.js";
|
|
13
|
+
import { capabilityFor, normalizeState } from "./state.js";
|
|
14
|
+
import { onForeground as onAppForeground } from '@chipmobilesdk/rn-core';
|
|
15
|
+
import { clearDenials, denialCount, hasRequested, recordDenial, recordRequested } from "../state/permission-history.js";
|
|
16
|
+
/**
|
|
17
|
+
* Refusals after which the system stops showing its prompt (NOT-12). Android 13+
|
|
18
|
+
* allows a second ask; iOS allows one.
|
|
19
|
+
*/
|
|
20
|
+
function denialLimit(platform) {
|
|
21
|
+
return platform.os === 'android' ? 2 : 1;
|
|
22
|
+
}
|
|
23
|
+
export function createPermissions(deps) {
|
|
24
|
+
const emit = deps.emit ?? (() => {});
|
|
25
|
+
let listeners = [];
|
|
26
|
+
let lastReport;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The engine's answer plus what only the package remembers. The platform
|
|
30
|
+
* reports a refusal as `denied` however often it happened; once the user has
|
|
31
|
+
* refused as many times as the system will ask, another request shows nothing,
|
|
32
|
+
* so the state is `permanentlyDenied` and the app should offer Settings.
|
|
33
|
+
*/
|
|
34
|
+
const derive = (kind, raw) => {
|
|
35
|
+
const state = normalizeState(kind, raw, deps.platform);
|
|
36
|
+
if (kind !== 'display') return state;
|
|
37
|
+
if (state === 'granted' || state === 'provisional') {
|
|
38
|
+
clearDenials(deps.state, kind);
|
|
39
|
+
return state;
|
|
40
|
+
}
|
|
41
|
+
return state === 'denied' && denialCount(deps.state, kind) >= denialLimit(deps.platform) ? 'permanentlyDenied' : state;
|
|
42
|
+
};
|
|
43
|
+
const read = async () => {
|
|
44
|
+
// Never prompts. This is what lets a consumer decide the moment to ask.
|
|
45
|
+
const [display, exactAlarm] = await Promise.all([deps.engine.getPermission('display'), deps.engine.getPermission('exactAlarm')]);
|
|
46
|
+
return {
|
|
47
|
+
display: derive('display', display),
|
|
48
|
+
exactAlarm: derive('exactAlarm', exactAlarm),
|
|
49
|
+
readAt: deps.now()
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const whenForeground = deps.onForeground ?? (listener => onAppForeground(listener));
|
|
53
|
+
let stopAwaitingSettings;
|
|
54
|
+
/**
|
|
55
|
+
* Exact alarms are granted on a system settings screen, so the answer read
|
|
56
|
+
* straight after opening it is always the old one. The real answer is read
|
|
57
|
+
* when the user comes back, and listeners hear it then (NOT-12).
|
|
58
|
+
*/
|
|
59
|
+
const rereadOnReturn = () => {
|
|
60
|
+
stopAwaitingSettings?.();
|
|
61
|
+
stopAwaitingSettings = whenForeground(() => {
|
|
62
|
+
stopAwaitingSettings?.();
|
|
63
|
+
stopAwaitingSettings = undefined;
|
|
64
|
+
read().then(notifyIfChanged, () => undefined);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const notifyIfChanged = report => {
|
|
68
|
+
const changed = lastReport === undefined || lastReport.display !== report.display || lastReport.exactAlarm !== report.exactAlarm;
|
|
69
|
+
lastReport = report;
|
|
70
|
+
if (!changed) return false;
|
|
71
|
+
for (const listener of listeners) {
|
|
72
|
+
try {
|
|
73
|
+
listener(report);
|
|
74
|
+
} catch {
|
|
75
|
+
// A consumer's handler must never break permission reading.
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
};
|
|
80
|
+
const request = async (kind, ownerTag) => {
|
|
81
|
+
const capability = capabilityFor(kind, deps.platform);
|
|
82
|
+
|
|
83
|
+
// Requesting something the platform version does not have is a no-op that
|
|
84
|
+
// shows no dialog, rather than a refusal.
|
|
85
|
+
if (!capability.supported) {
|
|
86
|
+
return 'notRequired';
|
|
87
|
+
}
|
|
88
|
+
recordRequested(deps.state, kind, deps.now(), ownerTag);
|
|
89
|
+
const raw = await deps.engine.requestPermission(kind);
|
|
90
|
+
if (kind === 'display' && normalizeState(kind, raw, deps.platform) === 'denied') {
|
|
91
|
+
recordDenial(deps.state, kind, deps.now());
|
|
92
|
+
}
|
|
93
|
+
const result = derive(kind, raw);
|
|
94
|
+
if (capability.settingsOnly && result !== 'granted') {
|
|
95
|
+
rereadOnReturn();
|
|
96
|
+
}
|
|
97
|
+
if (result === 'denied' || result === 'permanentlyDenied') {
|
|
98
|
+
emit(kind === 'display' ? result === 'permanentlyDenied' ? DIAGNOSTIC_CODES.DISPLAY_PERMISSION_PERMANENT : DIAGNOSTIC_CODES.DISPLAY_PERMISSION_DENIED : DIAGNOSTIC_CODES.EXACT_ALARM_UNAVAILABLE, kind === 'display' ? "Display permission was refused. The caller's operation still succeeded; notifications will not be shown until this is granted." : 'Exact-alarm capability is unavailable. Notifications are still scheduled, in approximate mode, and may be delivered late.', {
|
|
99
|
+
kind,
|
|
100
|
+
state: result
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
notifyIfChanged(await read());
|
|
104
|
+
return result;
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
/** Reads every permission state without triggering any dialog. */
|
|
108
|
+
async getPermissions() {
|
|
109
|
+
const report = await read();
|
|
110
|
+
notifyIfChanged(report);
|
|
111
|
+
return report;
|
|
112
|
+
},
|
|
113
|
+
/** Requested independently — an app may need one and not the other. */
|
|
114
|
+
requestDisplayPermission(ownerTag) {
|
|
115
|
+
return request('display', ownerTag);
|
|
116
|
+
},
|
|
117
|
+
requestExactAlarmPermission(ownerTag) {
|
|
118
|
+
return request('exactAlarm', ownerTag);
|
|
119
|
+
},
|
|
120
|
+
/** Whether the package has ever asked — the platform cannot answer this. */
|
|
121
|
+
hasEverRequested(kind, ownerTag) {
|
|
122
|
+
return hasRequested(deps.state, kind, ownerTag);
|
|
123
|
+
},
|
|
124
|
+
/**
|
|
125
|
+
* Opens the settings screen for one specific permission.
|
|
126
|
+
*
|
|
127
|
+
* Telling a user to "find it in settings" is how you lose them, so a
|
|
128
|
+
* platform with no reachable screen is an error rather than a silent no-op.
|
|
129
|
+
*/
|
|
130
|
+
async openSettings(kind) {
|
|
131
|
+
if (!capabilityFor(kind, deps.platform).supported) {
|
|
132
|
+
throw new NotificationError(DIAGNOSTIC_CODES.SETTINGS_UNAVAILABLE, `No settings screen exists for ${kind} on this platform version.`, {
|
|
133
|
+
kind,
|
|
134
|
+
os: deps.platform.os,
|
|
135
|
+
apiLevel: deps.platform.apiLevel
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
await deps.engine.openSettings(kind);
|
|
139
|
+
},
|
|
140
|
+
onPermissionChange(handler) {
|
|
141
|
+
listeners.push(handler);
|
|
142
|
+
return () => {
|
|
143
|
+
listeners = listeners.filter(l => l !== handler);
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* Manufacturer background restrictions, reported for information only.
|
|
148
|
+
*
|
|
149
|
+
* `unknown` is a first-class answer: some vendors stop apps in ways with no
|
|
150
|
+
* detection API, and guessing would be worse than admitting it. The package
|
|
151
|
+
* changes none of these settings on the user's behalf.
|
|
152
|
+
*/
|
|
153
|
+
async getBackgroundRestrictions() {
|
|
154
|
+
const report = await deps.engine.getRestrictions();
|
|
155
|
+
if (report.batteryOptimization === 'restricted' || report.autoStart === 'restricted') {
|
|
156
|
+
emit(DIAGNOSTIC_CODES.BACKGROUND_RESTRICTED, 'The device applies a manufacturer background restriction. Notifications may be delayed or suppressed.', {
|
|
157
|
+
battery: report.batteryOptimization,
|
|
158
|
+
autoStart: report.autoStart
|
|
159
|
+
});
|
|
160
|
+
} else if (report.batteryOptimization === 'unknown' || report.autoStart === 'unknown') {
|
|
161
|
+
emit(DIAGNOSTIC_CODES.BACKGROUND_RESTRICTION_UNKNOWN, 'Manufacturer background restriction could not be determined on this device. Reported as unknown rather than guessed.', {
|
|
162
|
+
battery: report.batteryOptimization,
|
|
163
|
+
autoStart: report.autoStart
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return report;
|
|
167
|
+
},
|
|
168
|
+
/** Called by the permission-refresh maintenance step. */
|
|
169
|
+
async refresh() {
|
|
170
|
+
const report = await read();
|
|
171
|
+
return {
|
|
172
|
+
report,
|
|
173
|
+
changed: notifyIfChanged(report)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DIAGNOSTIC_CODES","NotificationError","capabilityFor","normalizeState","onForeground","onAppForeground","clearDenials","denialCount","hasRequested","recordDenial","recordRequested","denialLimit","platform","os","createPermissions","deps","emit","listeners","lastReport","derive","kind","raw","state","read","display","exactAlarm","Promise","all","engine","getPermission","readAt","now","whenForeground","listener","stopAwaitingSettings","rereadOnReturn","undefined","then","notifyIfChanged","report","changed","request","ownerTag","capability","supported","requestPermission","result","settingsOnly","DISPLAY_PERMISSION_PERMANENT","DISPLAY_PERMISSION_DENIED","EXACT_ALARM_UNAVAILABLE","getPermissions","requestDisplayPermission","requestExactAlarmPermission","hasEverRequested","openSettings","SETTINGS_UNAVAILABLE","apiLevel","onPermissionChange","handler","push","filter","l","getBackgroundRestrictions","getRestrictions","batteryOptimization","autoStart","BACKGROUND_RESTRICTED","battery","BACKGROUND_RESTRICTION_UNKNOWN","refresh"],"sourceRoot":"../../../src","sources":["permission/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,gBAAgB,EAAEC,iBAAiB,QAAQ,uBAAoB;AACxE,SAASC,aAAa,EAAEC,cAAc,QAA2B,YAAS;AAC1E,SAASC,YAAY,IAAIC,eAAe,QAAQ,wBAAwB;AAExE,SACCC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,eAAe,QACT,gCAA6B;AAepC;AACA;AACA;AACA;AACA,SAASC,WAAWA,CAACC,QAAsB,EAAU;EACpD,OAAOA,QAAQ,CAACC,EAAE,KAAK,SAAS,GAAG,CAAC,GAAG,CAAC;AACzC;AAIA,OAAO,SAASC,iBAAiBA,CAACC,IAA4B,EAAE;EAC/D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SAAS,EAAE;QACtFlD,IAAI,CACHhB,gBAAgB,CAACqE,8BAA8B,EAC/C,sHAAsH,EACtH;UAAED,OAAO,EAAE7B,MAAM,CAAC0B,mBAAmB;UAAEC,SAAS,EAAE3B,MAAM,CAAC2B;QAAU,CACpE,CAAC;MACF;MAEA,OAAO3B,MAAM;IACd,CAAC;IAED;IACA,MAAM+B,OAAOA,CAAA,EAA8E;MAC1F,MAAM/B,MAAM,GAAG,MAAMhB,IAAI,CAAC,CAAC;MAC3B,OAAO;QAAEgB,MAAM;QAAEC,OAAO,EAAEF,eAAe,CAACC,MAAM;MAAE,CAAC;IACpD;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The permission state model.
|
|
5
|
+
*
|
|
6
|
+
* Six states, never collapsed. The two that matter most are the ones a naive
|
|
7
|
+
* model loses: `notAsked` must stay distinguishable from `denied`, or reading
|
|
8
|
+
* state without prompting buys nothing; and `notRequired` must never be
|
|
9
|
+
* reported as `denied`, because a platform version with no such concept never
|
|
10
|
+
* refused anything.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Android runtime notification permission arrived in API 33. */
|
|
14
|
+
export const ANDROID_DISPLAY_PERMISSION_API = 33;
|
|
15
|
+
/** Android exact-alarm permission arrived in API 31. */
|
|
16
|
+
export const ANDROID_EXACT_ALARM_API = 31;
|
|
17
|
+
/**
|
|
18
|
+
* Whether a permission concept exists at all on this platform version.
|
|
19
|
+
*
|
|
20
|
+
* Returning `supported: false` is what lets `notRequired` be reported honestly
|
|
21
|
+
* rather than inventing a refusal.
|
|
22
|
+
*/
|
|
23
|
+
export function capabilityFor(kind, platform) {
|
|
24
|
+
if (kind === 'display') {
|
|
25
|
+
if (platform.os === 'android' && (platform.apiLevel ?? 0) < ANDROID_DISPLAY_PERMISSION_API) {
|
|
26
|
+
return {
|
|
27
|
+
kind,
|
|
28
|
+
supported: false,
|
|
29
|
+
settingsOnly: false
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
kind,
|
|
34
|
+
supported: true,
|
|
35
|
+
settingsOnly: false
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Exact alarms exist only on Android 12+, and are granted through system
|
|
40
|
+
// settings rather than an in-app dialog on the versions that gate them.
|
|
41
|
+
if (platform.os !== 'android' || (platform.apiLevel ?? 0) < ANDROID_EXACT_ALARM_API) {
|
|
42
|
+
return {
|
|
43
|
+
kind,
|
|
44
|
+
supported: false,
|
|
45
|
+
settingsOnly: false
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
kind,
|
|
50
|
+
supported: true,
|
|
51
|
+
settingsOnly: true
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Normalizes a platform reading into the six-state model. */
|
|
56
|
+
export function normalizeState(kind, raw, platform) {
|
|
57
|
+
if (!capabilityFor(kind, platform).supported) {
|
|
58
|
+
return 'notRequired';
|
|
59
|
+
}
|
|
60
|
+
return raw;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Whether a state means the package can still show notifications.
|
|
65
|
+
*
|
|
66
|
+
* `provisional` counts: iOS quiet delivery still reaches the user, just without
|
|
67
|
+
* interrupting them. Treating it as denied would suppress notifications the
|
|
68
|
+
* user is in fact receiving.
|
|
69
|
+
*/
|
|
70
|
+
export function canDisplay(state) {
|
|
71
|
+
return state === 'granted' || state === 'provisional' || state === 'notRequired';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Whether asking again could produce a dialog, or whether settings is the only route. */
|
|
75
|
+
export function isTerminal(state) {
|
|
76
|
+
return state === 'permanentlyDenied' || state === 'notRequired';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Whether the package has ever asked, which the platform cannot answer after the fact. */
|
|
80
|
+
export function shouldOfferSettings(state) {
|
|
81
|
+
return state === 'denied' || state === 'permanentlyDenied';
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ANDROID_DISPLAY_PERMISSION_API","ANDROID_EXACT_ALARM_API","capabilityFor","kind","platform","os","apiLevel","supported","settingsOnly","normalizeState","raw","canDisplay","state","isTerminal","shouldOfferSettings"],"sourceRoot":"../../../src","sources":["permission/state.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,OAAO,MAAMA,8BAA8B,GAAG,EAAE;AAChD;AACA,OAAO,MAAMC,uBAAuB,GAAG,EAAE;AAQzC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,IAAoB,EAAEC,QAAsB,EAAwB;EACjG,IAAID,IAAI,KAAK,SAAS,EAAE;IACvB,IAAIC,QAAQ,CAACC,EAAE,KAAK,SAAS,IAAI,CAACD,QAAQ,CAACE,QAAQ,IAAI,CAAC,IAAIN,8BAA8B,EAAE;MAC3F,OAAO;QAAEG,IAAI;QAAEI,SAAS,EAAE,KAAK;QAAEC,YAAY,EAAE;MAAM,CAAC;IACvD;IACA,OAAO;MAAEL,IAAI;MAAEI,SAAS,EAAE,IAAI;MAAEC,YAAY,EAAE;IAAM,CAAC;EACtD;;EAEA;EACA;EACA,IAAIJ,QAAQ,CAACC,EAAE,KAAK,SAAS,IAAI,CAACD,QAAQ,CAACE,QAAQ,IAAI,CAAC,IAAIL,uBAAuB,EAAE;IACpF,OAAO;MAAEE,IAAI;MAAEI,SAAS,EAAE,KAAK;MAAEC,YAAY,EAAE;IAAM,CAAC;EACvD;EACA,OAAO;IAAEL,IAAI;IAAEI,SAAS,EAAE,IAAI;IAAEC,YAAY,EAAE;EAAK,CAAC;AACrD;;AAEA;AACA,OAAO,SAASC,cAAcA,CAC7BN,IAAoB,EACpBO,GAAoB,EACpBN,QAAsB,EACJ;EAClB,IAAI,CAACF,aAAa,CAACC,IAAI,EAAEC,QAAQ,CAAC,CAACG,SAAS,EAAE;IAC7C,OAAO,aAAa;EACrB;EACA,OAAOG,GAAG;AACX;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,KAAsB,EAAW;EAC3D,OAAOA,KAAK,KAAK,SAAS,IAAIA,KAAK,KAAK,aAAa,IAAIA,KAAK,KAAK,aAAa;AACjF;;AAEA;AACA,OAAO,SAASC,UAAUA,CAACD,KAAsB,EAAW;EAC3D,OAAOA,KAAK,KAAK,mBAAmB,IAAIA,KAAK,KAAK,aAAa;AAChE;;AAEA;AACA,OAAO,SAASE,mBAAmBA,CAACF,KAAsB,EAAW;EACpE,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,mBAAmB;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Payload normalization.
|
|
5
|
+
*
|
|
6
|
+
* Every provider's payload is reduced to one envelope shape before it reaches
|
|
7
|
+
* the consumer, so changing provider costs consumer code nothing.
|
|
8
|
+
*
|
|
9
|
+
* Version handling is best-effort: a payload declaring a version this build
|
|
10
|
+
* does not implement is still processed, honouring the fields it understands
|
|
11
|
+
* and ignoring the rest. Servers deploy ahead of app adoption and old app
|
|
12
|
+
* versions live on devices for months, so gating every server-side change on
|
|
13
|
+
* app rollout is the more expensive failure.
|
|
14
|
+
*
|
|
15
|
+
* That is only safe under an append-only discipline — a released field's
|
|
16
|
+
* meaning must never be repurposed. The version-skew diagnostic exists so a
|
|
17
|
+
* misprocessing incident is traceable to the skew rather than investigated as a
|
|
18
|
+
* logic defect.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { DIAGNOSTIC_CODES, NotificationError } from "../contract/errors.js";
|
|
22
|
+
|
|
23
|
+
/** The contract version this build implements. */
|
|
24
|
+
export const IMPLEMENTED_PAYLOAD_VERSION = 1;
|
|
25
|
+
const KINDS = new Set(['display', 'data', 'schedule', 'cancel']);
|
|
26
|
+
function asRecord(value) {
|
|
27
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Text, or nothing.
|
|
32
|
+
*
|
|
33
|
+
* Deliberately not `String(value)`: an object coerces to the literal string
|
|
34
|
+
* "[object Object]", which would be rendered to the user as a notification
|
|
35
|
+
* title. A field that is not text is treated as absent.
|
|
36
|
+
*/
|
|
37
|
+
function asText(value) {
|
|
38
|
+
if (typeof value === 'string') return value;
|
|
39
|
+
if (typeof value === 'number' && Number.isFinite(value)) return String(value);
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** An epoch instant from either a number or an ISO-8601 string. */
|
|
44
|
+
function asInstant(value) {
|
|
45
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
46
|
+
if (typeof value === 'string') return Date.parse(value);
|
|
47
|
+
return Number.NaN;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Extracts and validates the contract version, which every payload must declare. */
|
|
51
|
+
function readVersion(body) {
|
|
52
|
+
const raw = body.v;
|
|
53
|
+
const version = typeof raw === 'number' ? raw : Number.parseInt(asText(raw) ?? '', 10);
|
|
54
|
+
if (!Number.isInteger(version) || version < 1) {
|
|
55
|
+
throw new NotificationError(DIAGNOSTIC_CODES.PAYLOAD_MALFORMED, 'Push payload carries no usable contract version. Every payload must declare `v` from the first release.', {
|
|
56
|
+
received: typeof raw
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return version;
|
|
60
|
+
}
|
|
61
|
+
function readKind(body) {
|
|
62
|
+
const kind = asText(body.kind);
|
|
63
|
+
if (kind === undefined || !KINDS.has(kind)) {
|
|
64
|
+
throw new NotificationError(DIAGNOSTIC_CODES.PAYLOAD_MALFORMED, `Push payload declares unknown kind "${kind ?? ''}".`, {
|
|
65
|
+
kind
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return kind;
|
|
69
|
+
}
|
|
70
|
+
function readId(body) {
|
|
71
|
+
const id = asText(body.id);
|
|
72
|
+
if (id === undefined || id.length === 0) {
|
|
73
|
+
throw new NotificationError(DIAGNOSTIC_CODES.PAYLOAD_MALFORMED, 'Push payload carries no identifier.');
|
|
74
|
+
}
|
|
75
|
+
return id;
|
|
76
|
+
}
|
|
77
|
+
function readContent(body) {
|
|
78
|
+
const content = asRecord(body.content);
|
|
79
|
+
if (content === undefined) return undefined;
|
|
80
|
+
return {
|
|
81
|
+
title: asText(content.title) ?? '',
|
|
82
|
+
body: asText(content.body) ?? '',
|
|
83
|
+
subtitle: asText(content.subtitle)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function readMoment(body) {
|
|
87
|
+
const moment = asRecord(body.moment);
|
|
88
|
+
if (moment === undefined) return undefined;
|
|
89
|
+
return {
|
|
90
|
+
at: asInstant(moment.at),
|
|
91
|
+
anchoring: moment.anchoring === 'absolute' ? 'absolute' : 'wallClock'
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Normalizes a raw provider payload.
|
|
96
|
+
*
|
|
97
|
+
* Throws only for a **structurally unparseable** payload — a broken message.
|
|
98
|
+
* An unrecognized version is a healthy message from a newer contract and must
|
|
99
|
+
* never collapse into the same condition.
|
|
100
|
+
*/
|
|
101
|
+
export function normalizeEnvelope(raw, receivedAt) {
|
|
102
|
+
const record = asRecord(raw);
|
|
103
|
+
if (record === undefined) {
|
|
104
|
+
throw new NotificationError(DIAGNOSTIC_CODES.PAYLOAD_MALFORMED, 'Push payload is not an object and cannot be interpreted.', {
|
|
105
|
+
received: Array.isArray(raw) ? 'array' : typeof raw
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Providers deliver the payload under a data bag; accept either shape so the
|
|
110
|
+
// adapter does not have to reshape before handing it over.
|
|
111
|
+
const body = asRecord(record.data) ?? record;
|
|
112
|
+
const version = readVersion(body);
|
|
113
|
+
const kind = readKind(body);
|
|
114
|
+
const id = readId(body);
|
|
115
|
+
const versionSkew = version !== IMPLEMENTED_PAYLOAD_VERSION;
|
|
116
|
+
return {
|
|
117
|
+
versionSkew,
|
|
118
|
+
envelope: {
|
|
119
|
+
version,
|
|
120
|
+
kind,
|
|
121
|
+
id,
|
|
122
|
+
ownerTag: asText(body.ownerTag),
|
|
123
|
+
content: readContent(body),
|
|
124
|
+
tone: asText(body.tone),
|
|
125
|
+
moment: readMoment(body),
|
|
126
|
+
routing: asRecord(body.routing),
|
|
127
|
+
// Falls back to the identifier, so a server that omits it still gets
|
|
128
|
+
// de-duplication rather than silently losing it.
|
|
129
|
+
dedupId: asText(body.dedupId) ?? id,
|
|
130
|
+
receivedAt,
|
|
131
|
+
versionSkew
|
|
132
|
+
// Fields this build does not understand are simply not read — that is
|
|
133
|
+
// what best-effort processing means in practice.
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DIAGNOSTIC_CODES","NotificationError","IMPLEMENTED_PAYLOAD_VERSION","KINDS","Set","asRecord","value","Array","isArray","undefined","asText","Number","isFinite","String","asInstant","Date","parse","NaN","readVersion","body","raw","v","version","parseInt","isInteger","PAYLOAD_MALFORMED","received","readKind","kind","has","readId","id","length","readContent","content","title","subtitle","readMoment","moment","at","anchoring","normalizeEnvelope","receivedAt","record","data","versionSkew","envelope","ownerTag","tone","routing","dedupId"],"sourceRoot":"../../../src","sources":["push/envelope.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,gBAAgB,EAAEC,iBAAiB,QAAQ,uBAAoB;;AAExE;AACA,OA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