@chipmobilesdk/rn-notification 0.5.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 +184 -0
- package/README.md +108 -16
- 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 +74 -23
- package/skills/sdk-rn-notification/SKILL.md +6 -5
- package/src/advanced.ts +35 -0
- package/src/channel/migrate.ts +176 -158
- package/src/channel/tone-map.ts +2 -10
- package/src/contract/errors.ts +7 -0
- package/src/contract/hash.ts +26 -0
- package/src/engine/adapter.ts +21 -1
- package/src/engine/notify-kit/events.ts +155 -0
- package/src/engine/notify-kit/module.ts +148 -0
- package/src/engine/notify-kit/platform/android.ts +172 -0
- package/src/engine/notify-kit/platform/index.ts +55 -0
- package/src/engine/notify-kit/platform/ios.ts +54 -0
- package/src/engine/notify-kit/platform/types.ts +40 -0
- package/src/engine/notify-kit-engine.ts +96 -477
- package/src/index.ts +9 -0
- package/src/notifications.ts +195 -0
- package/src/permission/index.ts +65 -4
- package/src/push/fcm-provider.ts +14 -4
- package/src/push/gate.ts +27 -5
- package/src/reconcile/diff.ts +38 -27
- package/src/reconcile/index.ts +13 -4
- package/src/recurrence/index.ts +2 -1
- package/src/repeat/expiry.ts +2 -6
- package/src/repeat/index.ts +45 -1
- package/src/repeat/marker.ts +1 -22
- package/src/repeat/place.ts +74 -35
- package/src/schedule/index.ts +10 -4
- package/src/schedule/partition.ts +0 -19
- package/src/schedule/validate-identifier.ts +8 -6
- package/src/schedule/writer.ts +13 -4
- package/src/state/caps.ts +28 -3
- package/src/state/permission-history.ts +25 -0
- package/src/state/record.ts +110 -20
- package/src/testing/fake-engine.ts +17 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The re-anchoring maintenance step.
|
|
5
|
+
*
|
|
6
|
+
* Registers itself with the maintenance registry rather than being wired into
|
|
7
|
+
* a fixed sequence, which is what keeps scheduling independent of
|
|
8
|
+
* reconciliation, recurrence, and permissions despite all four contributing a
|
|
9
|
+
* step.
|
|
10
|
+
*
|
|
11
|
+
* Runs early (order 10) because verification compares firing instants: if
|
|
12
|
+
* verification ran first it would compare against instants re-anchoring is
|
|
13
|
+
* about to rewrite, and report discrepancies that do not exist.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { planReAnchor } from "../schedule/anchor.js";
|
|
17
|
+
import { createScheduleWriter } from "../schedule/writer.js";
|
|
18
|
+
export const RE_ANCHOR_ORDER = 10;
|
|
19
|
+
export function createReAnchorStep(deps) {
|
|
20
|
+
// Through the shared writer so a repeating alert's stop marker moves with it;
|
|
21
|
+
// written directly, the marker kept the old instant and cut the alert short
|
|
22
|
+
// or let it run past its bound.
|
|
23
|
+
const writer = createScheduleWriter(deps.engine);
|
|
24
|
+
return {
|
|
25
|
+
name: 'reanchor',
|
|
26
|
+
order: RE_ANCHOR_ORDER,
|
|
27
|
+
async run(_context) {
|
|
28
|
+
const zone = deps.timeZone();
|
|
29
|
+
const pending = await deps.engine.getPending();
|
|
30
|
+
const plan = planReAnchor(pending, zone);
|
|
31
|
+
|
|
32
|
+
// The no-change path costs one comparison per entry and issues zero
|
|
33
|
+
// platform operations. That is what makes re-anchoring idempotent.
|
|
34
|
+
if (plan.rewrites.length === 0) {
|
|
35
|
+
return {
|
|
36
|
+
operationCount: 0,
|
|
37
|
+
reAnchored: 0,
|
|
38
|
+
timeZoneChanged: false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
deps.emit?.('REANCHOR', `Device time zone changed from ${plan.fromZone ?? 'unknown'} to ${plan.toZone}; re-anchoring ${plan.rewrites.length} wall-clock notification(s).`, {
|
|
42
|
+
from: plan.fromZone,
|
|
43
|
+
to: plan.toZone,
|
|
44
|
+
count: plan.rewrites.length
|
|
45
|
+
});
|
|
46
|
+
let operationCount = 0;
|
|
47
|
+
for (const {
|
|
48
|
+
entry,
|
|
49
|
+
resolvedAt
|
|
50
|
+
} of plan.rewrites) {
|
|
51
|
+
const tone = deps.resolveTone(entry.tone);
|
|
52
|
+
if (tone === undefined) {
|
|
53
|
+
// A tone that no longer exists means this entry belongs to a
|
|
54
|
+
// configuration the app has since dropped. Leaving it alone is
|
|
55
|
+
// correct: re-anchoring must never repair, only preserve.
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
await writer.write({
|
|
59
|
+
request: {
|
|
60
|
+
id: entry.id,
|
|
61
|
+
content: entry.content,
|
|
62
|
+
tone: entry.tone,
|
|
63
|
+
moment: {
|
|
64
|
+
at: resolvedAt,
|
|
65
|
+
anchoring: 'wallClock'
|
|
66
|
+
},
|
|
67
|
+
routing: entry.routing,
|
|
68
|
+
actions: entry.actions,
|
|
69
|
+
ownerTag: entry.ownerTag,
|
|
70
|
+
groupTag: entry.groupTag
|
|
71
|
+
},
|
|
72
|
+
resolvedAt,
|
|
73
|
+
tone,
|
|
74
|
+
// Re-anchored against the zone the device is in now — this is the
|
|
75
|
+
// value that stops the entry being reported as stale next time.
|
|
76
|
+
anchoringGeneration: zone,
|
|
77
|
+
approximate: !deps.canScheduleExactly(),
|
|
78
|
+
seriesId: entry.seriesId,
|
|
79
|
+
pushCreated: entry.pushCreated
|
|
80
|
+
});
|
|
81
|
+
operationCount += 1;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
operationCount,
|
|
85
|
+
reAnchored: operationCount,
|
|
86
|
+
timeZoneChanged: true,
|
|
87
|
+
// Re-anchoring replaces in place and cancels nothing, so it can never
|
|
88
|
+
// touch a notification outside what it was handed.
|
|
89
|
+
cancelledIds: []
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=reanchor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["planReAnchor","createScheduleWriter","RE_ANCHOR_ORDER","createReAnchorStep","deps","writer","engine","name","order","run","_context","zone","timeZone","pending","getPending","plan","rewrites","length","operationCount","reAnchored","timeZoneChanged","emit","fromZone","toZone","from","to","count","entry","resolvedAt","tone","resolveTone","undefined","write","request","id","content","moment","at","anchoring","routing","actions","ownerTag","groupTag","anchoringGeneration","approximate","canScheduleExactly","seriesId","pushCreated","cancelledIds"],"sourceRoot":"../../../src","sources":["maintenance/reanchor.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,YAAY,QAA6B,uBAAoB;AACtE,SAASC,oBAAoB,QAAQ,uBAAoB;AAUzD,OAAO,MAAMC,eAAe,GAAG,EAAE;AAEjC,OAAO,SAASC,kBAAkBA,CAACC,IAA8B,EAAmB;EACnF;EACA;EACA;EACA,MAAMC,MAAM,GAAGJ,oBAAoB,CAACG,IAAI,CAACE,MAAM,CAAC;EAEhD,OAAO;IACNC,IAAI,EAAE,UAAU;IAChBC,KAAK,EAAEN,eAAe;IAEtB,MAAMO,GAAGA,CAACC,QAA4B,EAAwB;MAC7D,MAAMC,IAAI,GAAGP,IAAI,CAACQ,QAAQ,CAAC,CAAC;MAC5B,MAAMC,OAAO,GAAG,MAAMT,IAAI,CAACE,MAAM,CAACQ,UAAU,CAAC,CAAC;MAC9C,MAAMC,IAAI,GAAGf,YAAY,CAACa,OAAO,EAAEF,IAAI,CAAC;;MAExC;MACA;MACA,IAAII,IAAI,CAACC,QAAQ,CAACC,MAAM,KAAK,CAAC,EAAE;QAC/B,OAAO;UAAEC,cAAc,EAAE,CAAC;UAAEC,UAAU,EAAE,CAAC;UAAEC,eAAe,EAAE;QAAM,CAAC;MACpE;MAEAhB,IAAI,CAACiB,IAAI,GACR,UAAU,EACV,iCAAiCN,IAAI,CAACO,QAAQ,IAAI,SAAS,OAAOP,IAAI,CAACQ,MAAM,kBAAkBR,IAAI,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AC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The automatic-maintenance switch.
|
|
5
|
+
*
|
|
6
|
+
* A package that acts on its own must offer a way to stop it — and a consumer
|
|
7
|
+
* that takes control must not lose a feature as the price. Disabling automatic
|
|
8
|
+
* maintenance leaves every operation explicitly invocable through
|
|
9
|
+
* `runMaintenance()`, producing identical device state.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export class MaintenanceController {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.registry = options.registry;
|
|
15
|
+
this.now = options.now;
|
|
16
|
+
this.ownedIds = options.ownedIds;
|
|
17
|
+
this.enabled = options.enabled ?? true;
|
|
18
|
+
}
|
|
19
|
+
get isEnabled() {
|
|
20
|
+
return this.enabled;
|
|
21
|
+
}
|
|
22
|
+
setEnabled(enabled) {
|
|
23
|
+
this.enabled = enabled;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Called by lifecycle observers. A no-op when automatic maintenance is off. */
|
|
27
|
+
async runAutomatic(trigger) {
|
|
28
|
+
if (!this.enabled) return undefined;
|
|
29
|
+
return this.execute(trigger);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Always runs, regardless of the switch. This is what preserves capability parity. */
|
|
33
|
+
async runExplicit() {
|
|
34
|
+
return this.execute('explicit');
|
|
35
|
+
}
|
|
36
|
+
async execute(trigger) {
|
|
37
|
+
const context = {
|
|
38
|
+
trigger,
|
|
39
|
+
now: this.now(),
|
|
40
|
+
ownedIds: await this.ownedIds()
|
|
41
|
+
};
|
|
42
|
+
return this.registry.run(context);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MaintenanceController","constructor","options","registry","now","ownedIds","enabled","isEnabled","setEnabled","runAutomatic","trigger","undefined","execute","runExplicit","context","run"],"sourceRoot":"../../../src","sources":["maintenance/toggle.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,OAAO,MAAMA,qBAAqB,CAAC;EAMlCC,WAAWA,CAACC,OAAqC,EAAE;IAClD,IAAI,CAACC,QAAQ,GAAGD,OAAO,CAACC,QAAQ;IAChC,IAAI,CAACC,GAAG,GAAGF,OAAO,CAACE,GAAG;IACtB,IAAI,CAACC,QAAQ,GAAGH,OAAO,CAACG,QAAQ;IAChC,IAAI,CAACC,OAAO,GAAGJ,OAAO,CAACI,OAAO,IAAI,IAAI;EACvC;EAEA,IAAIC,SAASA,CAAA,EAAY;IACxB,OAAO,IAAI,CAACD,OAAO;EACpB;EAEAE,UAAUA,CAACF,OAAgB,EAAQ;IAClC,IAAI,CAACA,OAAO,GAAGA,OAAO;EACvB;;EAEA;EACA,MAAMG,YAAYA,CACjBC,OAAgD,EACP;IACzC,IAAI,CAAC,IAAI,CAACJ,OAAO,EAAE,OAAOK,SAAS;IACnC,OAAO,IAAI,CAACC,OAAO,CAACF,OAAO,CAAC;EAC7B;;EAEA;EACA,MAAMG,WAAWA,CAAA,EAA+B;IAC/C,OAAO,IAAI,CAACD,OAAO,CAAC,UAAU,CAAC;EAChC;EAEA,MAAcA,OAAOA,CAACF,OAA2B,EAA8B;IAC9E,MAAMI,OAA2B,GAAG;MACnCJ,OAAO;MACPN,GAAG,EAAE,IAAI,CAACA,GAAG,CAAC,CAAC;MACfC,QAAQ,EAAE,MAAM,IAAI,CAACA,QAAQ,CAAC;IAC/B,CAAC;IACD,OAAO,IAAI,CAACF,QAAQ,CAACY,GAAG,CAACD,OAAO,CAAC;EAClC;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pending-set verification.
|
|
5
|
+
*
|
|
6
|
+
* Engine boot restoration coverage varies by manufacturer, so after a restart
|
|
7
|
+
* the device may hold fewer notifications than the package expects. This step
|
|
8
|
+
* notices that.
|
|
9
|
+
*
|
|
10
|
+
* It **detects and reports only**. It never re-registers, cancels, or repairs
|
|
11
|
+
* anything — the package deliberately does not persist a desired set, so it
|
|
12
|
+
* cannot tell a restoration gap from an intentional consumer change. Guessing
|
|
13
|
+
* would mean either resurrecting notifications the user cancelled or deleting
|
|
14
|
+
* ones they still want. Repair is consumer-invoked reconciliation.
|
|
15
|
+
*
|
|
16
|
+
* Runs at order 20, after re-anchoring (order 10): re-anchoring rewrites firing
|
|
17
|
+
* instants, and verifying first would compare against instants that are about
|
|
18
|
+
* to change.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { DIAGNOSTIC_CODES } from "../contract/errors.js";
|
|
22
|
+
export const VERIFY_ORDER = 20;
|
|
23
|
+
export function createVerifyStep(deps) {
|
|
24
|
+
return {
|
|
25
|
+
name: 'verify',
|
|
26
|
+
order: VERIFY_ORDER,
|
|
27
|
+
async run(context) {
|
|
28
|
+
const expected = deps.expectedIds();
|
|
29
|
+
|
|
30
|
+
// No recorded expectation is not the same as expecting an empty device.
|
|
31
|
+
// Reporting every pending entry as "unrecognized" on a fresh install
|
|
32
|
+
// would be noise, not a finding.
|
|
33
|
+
if (expected === undefined) {
|
|
34
|
+
return {
|
|
35
|
+
operationCount: 0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const pending = await deps.engine.getPending();
|
|
39
|
+
const actual = new Set(pending.map(entry => entry.id));
|
|
40
|
+
const missing = [...expected].filter(id => !actual.has(id)).sort();
|
|
41
|
+
const unrecognized = [...actual].filter(id => !expected.has(id)).sort();
|
|
42
|
+
if (missing.length === 0 && unrecognized.length === 0) {
|
|
43
|
+
return {
|
|
44
|
+
operationCount: 0
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const discrepancy = {
|
|
48
|
+
missing,
|
|
49
|
+
unrecognized,
|
|
50
|
+
detectedAt: context.now
|
|
51
|
+
};
|
|
52
|
+
deps.emit?.(DIAGNOSTIC_CODES.PENDING_SET_DISCREPANCY, `Pending set differs from expectation: ${missing.length} expected but absent, ${unrecognized.length} present but unrecognized. ` + 'Reported only — run reconciliation to repair, since the package cannot distinguish a restoration gap from an intentional change.', {
|
|
53
|
+
missing: missing.length,
|
|
54
|
+
unrecognized: unrecognized.length
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
operationCount: 0,
|
|
58
|
+
discrepancy,
|
|
59
|
+
// Verification repairs nothing, so it cancels nothing.
|
|
60
|
+
cancelledIds: []
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DIAGNOSTIC_CODES","VERIFY_ORDER","createVerifyStep","deps","name","order","run","context","expected","expectedIds","undefined","operationCount","pending","engine","getPending","actual","Set","map","entry","id","missing","filter","has","sort","unrecognized","length","discrepancy","detectedAt","now","emit","PENDING_SET_DISCREPANCY","cancelledIds"],"sourceRoot":"../../../src","sources":["maintenance/verify.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,gBAAgB,QAAQ,uBAAoB;AAErD,OAAO,MAAMC,YAAY,GAAG,EAAE;AAa9B,OAAO,SAASC,gBAAgBA,CAACC,IAA4B,EAAmB;EAC/E,OAAO;IACNC,IAAI,EAAE,QAAQ;IACdC,KAAK,EAAEJ,YAAY;IAEnB,MAAMK,GAAGA,CAACC,OAA2B,EAAwB;MAC5D,MAAMC,QAAQ,GAAGL,IAAI,CAACM,WAAW,CAAC,CAAC;;MAEnC;MACA;MACA;MACA,IAAID,QAAQ,KAAKE,SAAS,EAAE;QAC3B,OAAO;UAAEC,cAAc,EAAE;QAAE,CAAC;MAC7B;MAEA,MAAMC,OAAO,GAAG,MAAMT,IAAI,CAACU,MAAM,CAACC,UAAU,CAAC,CAAC;MAC9C,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAACJ,OAAO,CAACK,GAAG,CAACC,KAAK,IAAIA,KAAK,CAACC,EAAE,CAAC,CAAC;MAEtD,MAAMC,OAAO,GAAG,CAAC,GAAGZ,QAAQ,CAAC,CAACa,MAAM,CAACF,EAAE,IAAI,CAACJ,MAAM,CAACO,GAAG,CAACH,EAAE,CAAC,CAAC,CAACI,IAAI,CAAC,CAAC;MAClE,MAAMC,YAAY,GAAG,CAAC,GAAGT,MAAM,CAAC,CAACM,MAAM,CAACF,EAAE,IAAI,CAACX,QAAQ,CAACc,GAAG,CAACH,EAAE,CAAC,CAAC,CAACI,IAAI,CAAC,CAAC;MAEvE,IAAIH,OAAO,CAACK,MAAM,KAAK,CAAC,IAAID,YAAY,CAACC,MAAM,KAAK,CAAC,EAAE;QACtD,OAAO;UAAEd,cAAc,EAAE;QAAE,CAAC;MAC7B;MAEA,MAAMe,WAA+B,GAAG;QACvCN,OAAO;QACPI,YAAY;QACZG,UAAU,EAAEpB,OAAO,CAACqB;MACrB,CAAC;MAEDzB,IAAI,CAAC0B,IAAI,GACR7B,gBAAgB,CAAC8B,uBAAuB,EACxC,yCAAyCV,OAAO,CAACK,MAAM,yBAAyBD,YAAY,CAACC,MAAM,6BAA6B,GAC/H,kIAAkI,EACnI;QAAEL,OAAO,EAAEA,OAAO,CAACK,MAAM;QAAED,YAAY,EAAEA,YAAY,CAACC;MAAO,CAC9D,CAAC;MAED,OAAO;QACNd,cAAc,EAAE,CAAC;QACjBe,WAAW;QACX;QACAK,YAAY,EAAE;MACf,CAAC;IACF;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The window-refresh maintenance step.
|
|
5
|
+
*
|
|
6
|
+
* Runs at order 15 — after re-anchoring (10) so it expands against corrected
|
|
7
|
+
* instants, before verification (20) so verification sees the refreshed set
|
|
8
|
+
* rather than reporting occurrences the refresh was about to add.
|
|
9
|
+
*
|
|
10
|
+
* This step is the reason automatic maintenance exists at all: only the package
|
|
11
|
+
* knows when a series' horizon has moved, and it can act on that without ever
|
|
12
|
+
* needing a desired set from the consumer.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const WINDOW_REFRESH_ORDER = 15;
|
|
16
|
+
export function createWindowRefreshStep(deps) {
|
|
17
|
+
return {
|
|
18
|
+
name: 'window-refresh',
|
|
19
|
+
order: WINDOW_REFRESH_ORDER,
|
|
20
|
+
async run(_context) {
|
|
21
|
+
const rules = deps.registeredRules();
|
|
22
|
+
if (rules.length === 0) {
|
|
23
|
+
return {
|
|
24
|
+
operationCount: 0,
|
|
25
|
+
windowRefreshed: false
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
let scheduled = 0;
|
|
29
|
+
const cancelled = [];
|
|
30
|
+
for (const rule of rules) {
|
|
31
|
+
const result = await deps.recurrence.refreshSeries(rule);
|
|
32
|
+
scheduled += result.scheduled;
|
|
33
|
+
cancelled.push(...(result.cancelled ?? []));
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
operationCount: scheduled + cancelled.length,
|
|
37
|
+
occurrencesScheduled: scheduled,
|
|
38
|
+
// A refresh that found nothing to add still ran; reporting it as
|
|
39
|
+
// refreshed distinguishes "nothing due" from "step never executed".
|
|
40
|
+
windowRefreshed: true,
|
|
41
|
+
// Only stale occurrences of series the package owns; reported so the
|
|
42
|
+
// registry's scope guard checks them rather than taking it on trust.
|
|
43
|
+
cancelledIds: cancelled
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=window-refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WINDOW_REFRESH_ORDER","createWindowRefreshStep","deps","name","order","run","_context","rules","registeredRules","length","operationCount","windowRefreshed","scheduled","cancelled","rule","result","recurrence","refreshSeries","push","occurrencesScheduled","cancelledIds"],"sourceRoot":"../../../src","sources":["maintenance/window-refresh.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,MAAMA,oBAAoB,GAAG,EAAE;AAetC,OAAO,SAASC,uBAAuBA,CAACC,IAA+B,EAAmB;EACzF,OAAO;IACNC,IAAI,EAAE,gBAAgB;IACtBC,KAAK,EAAEJ,oBAAoB;IAE3B,MAAMK,GAAGA,CAACC,QAA4B,EAAwB;MAC7D,MAAMC,KAAK,GAAGL,IAAI,CAACM,eAAe,CAAC,CAAC;MACpC,IAAID,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO;UAAEC,cAAc,EAAE,CAAC;UAAEC,eAAe,EAAE;QAAM,CAAC;MACrD;MAEA,IAAIC,SAAS,GAAG,CAAC;MACjB,MAAMC,SAAmB,GAAG,EAAE;MAE9B,KAAK,MAAMC,IAAI,IAAIP,KAAK,EAAE;QACzB,MAAMQ,MAAM,GAAG,MAAMb,IAAI,CAACc,UAAU,CAACC,aAAa,CAACH,IAAI,CAAC;QACxDF,SAAS,IAAIG,MAAM,CAACH,SAAS;QAC7BC,SAAS,CAACK,IAAI,CAAC,IAAIH,MAAM,CAACF,SAAS,IAAI,EAAE,CAAC,CAAC;MAC5C;MAEA,OAAO;QACNH,cAAc,EAAEE,SAAS,GAAGC,SAAS,CAACJ,MAAM;QAC5CU,oBAAoB,EAAEP,SAAS;QAC/B;QACA;QACAD,eAAe,EAAE,IAAI;QACrB;QACA;QACAS,YAAY,EAAEP;MACf,CAAC;IACF;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -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,qBAAq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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,MAAMC,IAAI,GAAGD,IAAI,CAACC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC;EACpC,IAAIC,SAAoC,GAAG,EAAE;EAC7C,IAAIC,UAAwC;;EAE5C;AACD;AACA;AACA;AACA;AACA;EACC,MAAMC,MAAM,GAAGA,CAACC,IAAoB,EAAEC,GAAoB,KAAsB;IAC/E,MAAMC,KAAK,GAAGnB,cAAc,CAACiB,IAAI,EAAEC,GAAG,EAAEN,IAAI,CAACH,QAAQ,CAAC;IACtD,IAAIQ,IAAI,KAAK,SAAS,EAAE,OAAOE,KAAK;IACpC,IAAIA,KAAK,KAAK,SAAS,IAAIA,KAAK,KAAK,aAAa,EAAE;MACnDhB,YAAY,CAACS,IAAI,CAACO,KAAK,E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