@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,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createMmkvStore = createMmkvStore;
|
|
7
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
8
|
+
var _errors = require("../contract/errors.js");
|
|
9
|
+
/**
|
|
10
|
+
* MMKV-backed state store.
|
|
11
|
+
*
|
|
12
|
+
* Every MMKV import is confined to this file, so the rest of the package stays
|
|
13
|
+
* testable without a native module.
|
|
14
|
+
*
|
|
15
|
+
* Backup exclusion is achieved by *where* the data lives rather than by setting
|
|
16
|
+
* a file attribute: on iOS the instance is rooted under `Library/Caches`, which
|
|
17
|
+
* the platform excludes from iCloud and iTunes backup by design. The OS may
|
|
18
|
+
* purge that directory under storage pressure — acceptable here precisely
|
|
19
|
+
* because discarding and rebuilding this record is already a specified,
|
|
20
|
+
* non-blocking condition.
|
|
21
|
+
*
|
|
22
|
+
* On Android, backup exclusion is declared in the consuming app's
|
|
23
|
+
* `data_extraction_rules.xml` and `full_backup_content`, documented in the
|
|
24
|
+
* README. It is the app's manifest, so it is the app's declaration to make.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const INSTANCE_ID = 'chipmobilesdk.notification';
|
|
28
|
+
const mmkv = (0, _rnCore.lazyPeer)('react-native-mmkv', () => {
|
|
29
|
+
// Inside `try`, so Metro bundles an app that leaves this optional peer out.
|
|
30
|
+
try {
|
|
31
|
+
return require('react-native-mmkv');
|
|
32
|
+
} catch (cause) {
|
|
33
|
+
throw cause;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const channel = (0, _rnCore.createDiagnosticChannel)('rn-notification');
|
|
37
|
+
/**
|
|
38
|
+
* Creates the persistent store, falling back to memory when MMKV is absent.
|
|
39
|
+
*
|
|
40
|
+
* The fallback is deliberate: a missing optional native module degrades
|
|
41
|
+
* deduplication and cold-start buffering to session scope, which is a
|
|
42
|
+
* documented degradation. It must never stop notifications being delivered, and
|
|
43
|
+
* it is never silent (NOT-15): it reports `STATE_STORE_DEGRADED` to the app's SDK
|
|
44
|
+
* sinks and to `onDegraded`, and the store reports `durable: false`.
|
|
45
|
+
*/
|
|
46
|
+
function createMmkvStore(options = {}) {
|
|
47
|
+
const port = (0, _rnCore.openDurable)(() =>
|
|
48
|
+
// v4's factory: up to 0.2.0 this called the v3 `new MMKV()`, which v4 no
|
|
49
|
+
// longer exports as a value, so every device silently got memory.
|
|
50
|
+
mmkv.require(peer => new Error(`${peer} is not installed`)).createMMKV({
|
|
51
|
+
id: INSTANCE_ID,
|
|
52
|
+
// Caches is backup-excluded by platform design; see the note above.
|
|
53
|
+
...((0, _rnCore.currentPlatform)() === 'ios' ? {
|
|
54
|
+
path: 'Library/Caches/chipmobilesdk-notification'
|
|
55
|
+
} : {})
|
|
56
|
+
}), cause => {
|
|
57
|
+
channel.emit(_errors.DIAGNOSTIC_CODES.STATE_STORE_DEGRADED, 'warn');
|
|
58
|
+
options.onDegraded?.(cause);
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
getString: key => port.getString(key),
|
|
62
|
+
setString: (key, value) => port.set(key, value),
|
|
63
|
+
delete: key => port.remove(key),
|
|
64
|
+
clearAll: () => port.clearAll(),
|
|
65
|
+
approximateBytes: () => {
|
|
66
|
+
let total = 0;
|
|
67
|
+
for (const key of port.keys()) {
|
|
68
|
+
total += key.length + (port.getString(key)?.length ?? 0);
|
|
69
|
+
}
|
|
70
|
+
return total;
|
|
71
|
+
},
|
|
72
|
+
durable: port.durable
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=mmkv-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","_errors","INSTANCE_ID","mmkv","lazyPeer","cause","channel","createDiagnosticChannel","createMmkvStore","options","port","openDurable","peer","Error","createMMKV","id","currentPlatform","path","emit","DIAGNOSTIC_CODES","STATE_STORE_DEGRADED","onDegraded","getString","key","setString","value","set","delete","remove","clearAll","approximateBytes","total","keys","length","durable"],"sourceRoot":"../../../src","sources":["state/mmkv-store.ts"],"mappings":";;;;;;AAkBA,IAAAA,OAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAD,OAAA;AA1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,MAAME,WAAW,GAAG,4BAA4B;AAEhD,MAAMC,IAAI,GAAG,IAAAC,gBAAQ,EAAC,mBAAmB,EAAE,MAAM;EAChD;EACA,IAAI;IACH,OAAOJ,OAAO,CAAC,mBAAmB,CAAC;EAGpC,CAAC,CAAC,OAAOK,KAAK,EAAE;IACf,MAAMA,KAAK;EACZ;AACD,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,IAAAC,+BAAuB,EAAC,iBAAiB,CAAC;AAO1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAACC,OAAyB,GAAG,CAAC,CAAC,EAAc;EAC3E,MAAMC,IAAI,GAAG,IAAAC,mBAAW,EACvB;EACC;EACA;EACAR,IAAI,CACFH,OAAO,CAACY,IAAI,IAAI,IAAIC,KAAK,CAAC,GAAGD,IAAI,mBAAmB,CAAC,CAAC,CACtDE,UAAU,CAAC;IACXC,EAAE,EAAEb,WAAW;IACf;IACA,IAAI,IAAAc,uBAAe,EAAC,CAAC,KAAK,KAAK,GAC5B;MAAEC,IAAI,EAAE;IAA4C,CAAC,GACrD,CAAC,CAAC;EACN,CAAC,CAAC,EACJZ,KAAK,IAAI;IACRC,OAAO,CAACY,IAAI,CAACC,wBAAgB,CAACC,oBAAoB,EAAE,MAAM,CAAC;IAC3DX,OAAO,CAACY,UAAU,GAAGhB,KAAK,CAAC;EAC5B,CACD,CAAC;EACD,OAAO;IACNiB,SAAS,EAAEC,GAAG,IAAIb,IAAI,CAACY,SAAS,CAACC,GAAG,CAAC;IACrCC,SAAS,EAAEA,CAACD,GAAG,EAAEE,KAAK,KAAKf,IAAI,CAACgB,GAAG,CAACH,GAAG,EAAEE,KAAK,CAAC;IAC/CE,MAAM,EAAEJ,GAAG,IAAIb,IAAI,CAACkB,MAAM,CAACL,GAAG,CAAC;IAC/BM,QAAQ,EAAEA,CAAA,KAAMnB,IAAI,CAACmB,QAAQ,CAAC,CAAC;IAC/BC,gBAAgB,EAAEA,CAAA,KAAM;MACvB,IAAIC,KAAK,GAAG,CAAC;MACb,KAAK,MAAMR,GAAG,IAAIb,IAAI,CAACsB,IAAI,CAAC,CAAC,EAAE;QAC9BD,KAAK,IAAIR,GAAG,CAACU,MAAM,IAAIvB,IAAI,CAACY,SAAS,CAACC,GAAG,CAAC,EAAEU,MAAM,IAAI,CAAC,CAAC;MACzD;MACA,OAAOF,KAAK;IACb,CAAC;IACDG,OAAO,EAAExB,IAAI,CAACwB;EACf,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clearDenials = clearDenials;
|
|
7
|
+
exports.denialCount = denialCount;
|
|
8
|
+
exports.hasRequested = hasRequested;
|
|
9
|
+
exports.recordDenial = recordDenial;
|
|
10
|
+
exports.recordRequested = recordRequested;
|
|
11
|
+
/**
|
|
12
|
+
* Permission-request history.
|
|
13
|
+
*
|
|
14
|
+
* The platform cannot tell you whether you have already asked. On both
|
|
15
|
+
* platforms a second request after a denial is silently a no-op, so an app that
|
|
16
|
+
* does not remember will keep "asking" and keep appearing to be refused.
|
|
17
|
+
*
|
|
18
|
+
* Keyed by owner tag so a multi-account device can clear one account's history
|
|
19
|
+
* on sign-out without forgetting what it asked the others.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function key(kind, ownerTag) {
|
|
23
|
+
return `${ownerTag ?? '*'}:${kind}`;
|
|
24
|
+
}
|
|
25
|
+
function hasRequested(state, kind, ownerTag) {
|
|
26
|
+
const target = key(kind, ownerTag);
|
|
27
|
+
return state.read().permissionHistory.some(entry => entry.key === target && entry.requested);
|
|
28
|
+
}
|
|
29
|
+
function recordRequested(state, kind, now, ownerTag) {
|
|
30
|
+
const target = key(kind, ownerTag);
|
|
31
|
+
if (hasRequested(state, kind, ownerTag)) return;
|
|
32
|
+
state.update('permissionHistory', current => [...current.filter(entry => entry.key !== target), {
|
|
33
|
+
at: now,
|
|
34
|
+
key: target,
|
|
35
|
+
requested: true
|
|
36
|
+
}]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The device-wide key: a refusal is the user's answer to the app, not to one account. */
|
|
40
|
+
const DEVICE = '#device';
|
|
41
|
+
|
|
42
|
+
/** How many requests for `kind` the user has refused on this device. */
|
|
43
|
+
function denialCount(state, kind) {
|
|
44
|
+
const target = key(kind, DEVICE);
|
|
45
|
+
return state.read().permissionHistory.find(entry => entry.key === target)?.denials ?? 0;
|
|
46
|
+
}
|
|
47
|
+
function recordDenial(state, kind, now) {
|
|
48
|
+
const target = key(kind, DEVICE);
|
|
49
|
+
const denials = denialCount(state, kind) + 1;
|
|
50
|
+
state.update('permissionHistory', current => [...current.filter(entry => entry.key !== target), {
|
|
51
|
+
at: now,
|
|
52
|
+
key: target,
|
|
53
|
+
requested: true,
|
|
54
|
+
denials
|
|
55
|
+
}]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Forgets refusals once the permission is seen granted: the next refusal starts over. */
|
|
59
|
+
function clearDenials(state, kind) {
|
|
60
|
+
if (denialCount(state, kind) === 0) return;
|
|
61
|
+
const target = key(kind, DEVICE);
|
|
62
|
+
state.update('permissionHistory', current => current.filter(entry => entry.key !== target));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=permission-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["key","kind","ownerTag","hasRequested","state","target","read","permissionHistory","some","entry","requested","recordRequested","now","update","current","filter","at","DEVICE","denialCount","find","denials","recordDenial","clearDenials"],"sourceRoot":"../../../src","sources":["state/permission-history.ts"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,GAAGA,CAACC,IAAoB,EAAEC,QAAiB,EAAU;EAC7D,OAAO,GAAGA,QAAQ,IAAI,GAAG,IAAID,IAAI,EAAE;AACpC;AAEO,SAASE,YAAYA,CAC3BC,KAAmB,EACnBH,IAAoB,EACpBC,QAAiB,EACP;EACV,MAAMG,MAAM,GAAGL,GAAG,CAACC,IAAI,EAAEC,QAAQ,CAAC;EAClC,OAAOE,KAAK,CAACE,IAAI,CAAC,CAAC,CAACC,iBAAiB,CAACC,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACT,GAAG,KAAKK,MAAM,IAAII,KAAK,CAACC,SAAS,CAAC;AAC7F;AAEO,SAASC,eAAeA,CAC9BP,KAAmB,EACnBH,IAAoB,EACpBW,GAAW,EACXV,QAAiB,EACV;EACP,MAAMG,MAAM,GAAGL,GAAG,CAACC,IAAI,EAAEC,QAAQ,CAAC;EAClC,IAAIC,YAAY,CAACC,KAAK,EAAEH,IAAI,EAAEC,QAAQ,CAAC,EAAE;EAEzCE,KAAK,CAACS,MAAM,CAAC,mBAAmB,EAAEC,OAAO,IAAI,CAC5C,GAAGA,OAAO,CAACC,MAAM,CAACN,KAAK,IAAIA,KAAK,CAACT,GAAG,K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CAACT,GAAG,KAAKK,MAAM,CAAC,CAAC;AAC5F","ignoreList":[]}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StateManager = exports.STATE_SCHEMA_VERSION = void 0;
|
|
7
|
+
exports.emptyRecord = emptyRecord;
|
|
8
|
+
var _caps = require("./caps.js");
|
|
9
|
+
var _errors = require("../contract/errors.js");
|
|
10
|
+
/**
|
|
11
|
+
* The persisted state record.
|
|
12
|
+
*
|
|
13
|
+
* Six collections, holding only what the platform will not tell us. No
|
|
14
|
+
* notification content, no push token, no desired set. The interaction buffer
|
|
15
|
+
* is the sole content-bearing exception, and it evicts on delivery.
|
|
16
|
+
*
|
|
17
|
+
* Corrupt or incompatible state is discarded and rebuilt rather than blocking:
|
|
18
|
+
* everything already scheduled lives in the OS and is unaffected, which is what
|
|
19
|
+
* makes discarding safe rather than destructive.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** The single record before 0.6.0; read once to migrate, then deleted. */
|
|
23
|
+
const STATE_KEY = 'chipmobilesdk.notification.state';
|
|
24
|
+
/**
|
|
25
|
+
* Since 0.6.0 each collection has its own key, plus one for the schema version and
|
|
26
|
+
* summaries, so recording one dedup entry writes the dedup ledger and nothing else
|
|
27
|
+
* (NOT-16). Before, every update serialized the whole record — the 500-entry dedup
|
|
28
|
+
* ledger included — synchronously on the JS thread.
|
|
29
|
+
*/
|
|
30
|
+
const META_KEY = `${STATE_KEY}:meta`;
|
|
31
|
+
const COLLECTIONS = ['dedupLedger', 'interactionBuffer', 'migrationLedger', 'seriesLedger', 'permissionHistory'];
|
|
32
|
+
const keyFor = collection => `${STATE_KEY}:${collection}`;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Bumped whenever the shape below changes. A mismatch discards and rebuilds —
|
|
36
|
+
* never a migration, because none of this data is worth migrating and all of it
|
|
37
|
+
* is reconstructible.
|
|
38
|
+
*/
|
|
39
|
+
const STATE_SCHEMA_VERSION = exports.STATE_SCHEMA_VERSION = 1;
|
|
40
|
+
function emptyRecord() {
|
|
41
|
+
return {
|
|
42
|
+
schemaVersion: STATE_SCHEMA_VERSION,
|
|
43
|
+
dedupLedger: [],
|
|
44
|
+
interactionBuffer: [],
|
|
45
|
+
migrationLedger: [],
|
|
46
|
+
seriesLedger: [],
|
|
47
|
+
permissionHistory: []
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Owns the record's lifecycle. Reads are synchronous and cheap; writes are
|
|
52
|
+
* best-effort and never propagate a failure to the caller's operation.
|
|
53
|
+
*/
|
|
54
|
+
class StateManager {
|
|
55
|
+
rebuilt = false;
|
|
56
|
+
constructor(options) {
|
|
57
|
+
this.store = options.store;
|
|
58
|
+
this.now = options.now;
|
|
59
|
+
this.emit = options.emit ?? (() => {});
|
|
60
|
+
this.record = this.load();
|
|
61
|
+
}
|
|
62
|
+
load() {
|
|
63
|
+
try {
|
|
64
|
+
const meta = this.store.getString(META_KEY);
|
|
65
|
+
if (meta === undefined) {
|
|
66
|
+
return this.migrateLegacy();
|
|
67
|
+
}
|
|
68
|
+
const parsed = JSON.parse(meta);
|
|
69
|
+
if (parsed.schemaVersion !== STATE_SCHEMA_VERSION) {
|
|
70
|
+
return this.discardAndRebuild('schema-version-mismatch', {
|
|
71
|
+
found: parsed.schemaVersion,
|
|
72
|
+
expected: STATE_SCHEMA_VERSION
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const record = {
|
|
76
|
+
schemaVersion: STATE_SCHEMA_VERSION,
|
|
77
|
+
lastReconcileSummary: parsed.lastReconcileSummary,
|
|
78
|
+
lastMaintenanceSummary: parsed.lastMaintenanceSummary
|
|
79
|
+
};
|
|
80
|
+
for (const collection of COLLECTIONS) {
|
|
81
|
+
const raw = this.store.getString(keyFor(collection));
|
|
82
|
+
const entries = raw === undefined ? [] : JSON.parse(raw);
|
|
83
|
+
if (!Array.isArray(entries)) {
|
|
84
|
+
return this.discardAndRebuild('unparseable', {
|
|
85
|
+
collection
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
record[collection] = entries;
|
|
89
|
+
}
|
|
90
|
+
return record;
|
|
91
|
+
} catch {
|
|
92
|
+
return this.discardAndRebuild('unparseable');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Reads the pre-0.6.0 single record, writes it out per collection, and drops it. */
|
|
97
|
+
migrateLegacy() {
|
|
98
|
+
const raw = this.store.getString(STATE_KEY);
|
|
99
|
+
if (raw === undefined) {
|
|
100
|
+
const fresh = emptyRecord();
|
|
101
|
+
this.persistMeta(fresh);
|
|
102
|
+
return fresh;
|
|
103
|
+
}
|
|
104
|
+
const parsed = JSON.parse(raw);
|
|
105
|
+
if (parsed.schemaVersion !== STATE_SCHEMA_VERSION) {
|
|
106
|
+
return this.discardAndRebuild('schema-version-mismatch', {
|
|
107
|
+
found: parsed.schemaVersion,
|
|
108
|
+
expected: STATE_SCHEMA_VERSION
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
this.record = {
|
|
112
|
+
schemaVersion: STATE_SCHEMA_VERSION,
|
|
113
|
+
dedupLedger: parsed.dedupLedger ?? [],
|
|
114
|
+
interactionBuffer: parsed.interactionBuffer ?? [],
|
|
115
|
+
migrationLedger: parsed.migrationLedger ?? [],
|
|
116
|
+
seriesLedger: parsed.seriesLedger ?? [],
|
|
117
|
+
permissionHistory: parsed.permissionHistory ?? [],
|
|
118
|
+
lastReconcileSummary: parsed.lastReconcileSummary,
|
|
119
|
+
lastMaintenanceSummary: parsed.lastMaintenanceSummary
|
|
120
|
+
};
|
|
121
|
+
for (const collection of COLLECTIONS) {
|
|
122
|
+
this.persist(collection);
|
|
123
|
+
}
|
|
124
|
+
this.persistMeta(this.record);
|
|
125
|
+
this.store.delete(STATE_KEY);
|
|
126
|
+
return this.record;
|
|
127
|
+
}
|
|
128
|
+
discardAndRebuild(reason, extra) {
|
|
129
|
+
this.rebuilt = true;
|
|
130
|
+
this.deleteAll();
|
|
131
|
+
this.persistMeta(emptyRecord());
|
|
132
|
+
this.emit({
|
|
133
|
+
code: _errors.DIAGNOSTIC_CODES.STATE_CORRUPT_REBUILT,
|
|
134
|
+
// Note what is actually lost, so the consequence is stated rather than implied.
|
|
135
|
+
context: {
|
|
136
|
+
reason,
|
|
137
|
+
lost: ['dedupLedger', 'interactionBuffer'],
|
|
138
|
+
...extra
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return emptyRecord();
|
|
142
|
+
}
|
|
143
|
+
deleteAll() {
|
|
144
|
+
this.store.delete(STATE_KEY);
|
|
145
|
+
this.store.delete(META_KEY);
|
|
146
|
+
for (const collection of COLLECTIONS) {
|
|
147
|
+
this.store.delete(keyFor(collection));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Never throws. A storage failure degrades the affected guarantee, nothing more. */
|
|
152
|
+
write(key, value) {
|
|
153
|
+
try {
|
|
154
|
+
this.store.setString(key, JSON.stringify(value));
|
|
155
|
+
} catch (error) {
|
|
156
|
+
this.emit({
|
|
157
|
+
code: _errors.DIAGNOSTIC_CODES.STATE_WRITE_FAILED,
|
|
158
|
+
context: {
|
|
159
|
+
reason: error instanceof Error ? error.name : 'unknown'
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Writes one collection, and only that one. */
|
|
166
|
+
persist(collection) {
|
|
167
|
+
this.write(keyFor(collection), this.record[collection]);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** The schema version and summaries. Present whenever any collection is stored. */
|
|
171
|
+
persistMeta(record = this.record) {
|
|
172
|
+
this.write(META_KEY, {
|
|
173
|
+
schemaVersion: STATE_SCHEMA_VERSION,
|
|
174
|
+
lastReconcileSummary: record.lastReconcileSummary,
|
|
175
|
+
lastMaintenanceSummary: record.lastMaintenanceSummary
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
read() {
|
|
179
|
+
return this.record;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Applies a change, evicts the touched collection, and persists. */
|
|
183
|
+
update(collection, mutate) {
|
|
184
|
+
const next = mutate(this.record[collection]);
|
|
185
|
+
const {
|
|
186
|
+
kept,
|
|
187
|
+
evicted,
|
|
188
|
+
reason,
|
|
189
|
+
overCap
|
|
190
|
+
} = (0, _caps.evict)(next, collection, this.now());
|
|
191
|
+
if (overCap > 0) {
|
|
192
|
+
this.emit({
|
|
193
|
+
code: _errors.DIAGNOSTIC_CODES.STATE_CAP_EXCEEDED,
|
|
194
|
+
context: {
|
|
195
|
+
collection,
|
|
196
|
+
overCap,
|
|
197
|
+
cap: _caps.COLLECTION_CAPS[collection].maxEntries
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (evicted.length > 0) {
|
|
202
|
+
this.emit({
|
|
203
|
+
code: collection === 'interactionBuffer' ? _errors.DIAGNOSTIC_CODES.INTERACTION_BUFFER_EVICTED : _errors.DIAGNOSTIC_CODES.STATE_CAP_EVICTED,
|
|
204
|
+
context: {
|
|
205
|
+
collection,
|
|
206
|
+
evicted: evicted.length,
|
|
207
|
+
reason
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
this.record = {
|
|
212
|
+
...this.record,
|
|
213
|
+
[collection]: kept
|
|
214
|
+
};
|
|
215
|
+
this.persist(collection);
|
|
216
|
+
}
|
|
217
|
+
setSummary(key, value) {
|
|
218
|
+
this.record = {
|
|
219
|
+
...this.record,
|
|
220
|
+
[key]: value
|
|
221
|
+
};
|
|
222
|
+
this.persistMeta();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Clears everything. Public through `resetState()`. */
|
|
226
|
+
reset() {
|
|
227
|
+
this.record = emptyRecord();
|
|
228
|
+
this.rebuilt = false;
|
|
229
|
+
this.deleteAll();
|
|
230
|
+
this.persistMeta();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Clears one owner tag's entries, leaving every other tag untouched.
|
|
235
|
+
*
|
|
236
|
+
* Collections without an owner tag are left alone: a migration ledger and a
|
|
237
|
+
* series ledger describe the device, not an account.
|
|
238
|
+
*/
|
|
239
|
+
clearOwner(ownerTag) {
|
|
240
|
+
this.record = {
|
|
241
|
+
...this.record,
|
|
242
|
+
dedupLedger: this.record.dedupLedger.filter(e => e.ownerTag !== ownerTag),
|
|
243
|
+
interactionBuffer: this.record.interactionBuffer.filter(e => e.ownerTag !== ownerTag),
|
|
244
|
+
permissionHistory: this.record.permissionHistory.filter(e => !e.key.startsWith(`${ownerTag}:`))
|
|
245
|
+
};
|
|
246
|
+
this.persist('dedupLedger');
|
|
247
|
+
this.persist('interactionBuffer');
|
|
248
|
+
this.persist('permissionHistory');
|
|
249
|
+
}
|
|
250
|
+
health() {
|
|
251
|
+
const collections = Object.keys(_caps.COLLECTION_CAPS).map(name => {
|
|
252
|
+
const entries = this.record[name];
|
|
253
|
+
return {
|
|
254
|
+
name,
|
|
255
|
+
size: entries.length,
|
|
256
|
+
cap: _caps.COLLECTION_CAPS[name].maxEntries,
|
|
257
|
+
oldestEntryAt: entries.length > 0 ? Math.min(...entries.map(e => e.at)) : undefined
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
readable: true,
|
|
262
|
+
rebuilt: this.rebuilt,
|
|
263
|
+
collections,
|
|
264
|
+
approximateBytes: this.store.approximateBytes()
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
exports.StateManager = StateManager;
|
|
269
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_caps","require","_errors","STATE_KEY","META_KEY","COLLECTIONS","keyFor","collection","STATE_SCHEMA_VERSION","exports","emptyRecord","schemaVersion","dedupLedger","interactionBuffer","migrationLedger","seriesLedger","permissionHistory","StateManager","rebuilt","constructor","options","store","now","emit","record","load","meta","getString","undefined","migrateLegacy","parsed","JSON","parse","discardAndRebuild","found","expected","lastReconcileSummary","lastMaintenanceSummary","raw","entries","Array","isArray","fresh","persistMeta","persist","delete","reason","extra","deleteAll","code","DIAGNOSTIC_CODES","STATE_CORRUPT_REBUILT","context","lost","write","key","value","setString","stringify","error","STATE_WRITE_FAILED","Error","name","read","update","mutate","next","kept","evicted","overCap","evict","STATE_CAP_EXCEEDED","cap","COLLECTION_CAPS","maxEntries","length","INTERACTION_BUFFER_EVICTED","STATE_CAP_EVICTED","setSummary","reset","clearOwner","ownerTag","filter","e","startsWith","health","collections","Object","keys","map","size","oldestEntryAt","Math","min","at","readable","approximateBytes"],"sourceRoot":"../../../src","sources":["state/record.ts"],"mappings":";;;;;;;AAaA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA,MAAME,SAAS,GAAG,kCAAkC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAG,GAAGD,SAAS,OAAO;AACpC,MAAME,WAAsC,GAAG,CAC9C,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,CACnB;AACD,MAAMC,MAAM,GAAIC,UAA0B,IAAK,GAAGJ,SAAS,IAAII,UAAU,EAAE;;AAE3E;AACA;AACA;AACA;AACA;AACO,MAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,CAAC;AAwE9B,SAASE,WAAWA,CAAA,EAAgB;EAC1C,OAAO;IACNC,aAAa,EAAEH,oBAAoB;IACnCI,WAAW,EAAE,EAAE;IACfC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,YAAY,EAAE,EAAE;IAChB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ACtDC,CAAC,IAAI,CAACA,CAAC,CAAC5B,GAAG,CAAC6B,UAAU,CAAC,GAAGH,QAAQ,GAAG,CACtC;IACD,CAAC;IACD,IAAI,CAACrC,OAAO,CAAC,aAAa,CAAC;IAC3B,IAAI,CAACA,OAAO,CAAC,mBAAmB,CAAC;IACjC,IAAI,CAACA,OAAO,CAAC,mBAAmB,CAAC;EAClC;EAEAyC,MAAMA,CAAA,EAAgB;IACrB,MAAMC,WAA+B,GAAIC,MAAM,CAACC,IAAI,CAACf,qBAAe,CAAC,CAAsBgB,GAAG,CAC7F3B,IAAI,IAAI;MACP,MAAMvB,OAAO,GAAG,IAAI,CAACf,MAAM,CAACsC,IAAI,CAA2B;MAC3D,OAAO;QACNA,IAAI;QACJ4B,IAAI,EAAEnD,OAAO,CAACoC,MAAM;QACpBH,GAAG,EAAEC,qBAAe,CAACX,IAAI,CAAC,CAACY,UAAU;QACrCiB,aAAa,EAAEpD,OAAO,CAACoC,MAAM,GAAG,CAAC,GAAGiB,IAAI,CAACC,GAAG,CAAC,GAAGtD,OAAO,CAACkD,GAAG,CAACN,CAAC,IAAIA,CAAC,CAACW,EAAE,CAAC,CAAC,GAAGlE;MAC3E,CAAC;IACF,CACD,CAAC;IAED,OAAO;MACNmE,QAAQ,EAAE,IAAI;MACd7E,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBoE,WAAW;MACXU,gBAAgB,EAAE,IAAI,CAAC3E,KAAK,CAAC2E,gBAAgB,CAAC;IAC/C,CAAC;EACF;AACD;AAACvF,OAAA,CAAAQ,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clearOwner = clearOwner;
|
|
7
|
+
exports.resetState = resetState;
|
|
8
|
+
/**
|
|
9
|
+
* Public state reset and per-owner clearing.
|
|
10
|
+
*
|
|
11
|
+
* These are the only two ways a consumer may touch the persisted record. The
|
|
12
|
+
* record itself is unreachable — a consumer can discard state, but can never
|
|
13
|
+
* read or write it.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Discards the entire record. Nothing already scheduled with the OS is affected. */
|
|
17
|
+
function resetState(state) {
|
|
18
|
+
state.reset();
|
|
19
|
+
return {
|
|
20
|
+
clearedCollections: ['dedupLedger', 'interactionBuffer', 'migrationLedger', 'seriesLedger', 'permissionHistory']
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Clears one owner tag's entries on sign-out.
|
|
26
|
+
*
|
|
27
|
+
* Deliberately narrower than a full reset: the migration and series ledgers
|
|
28
|
+
* describe the device rather than an account, so signing one account out must
|
|
29
|
+
* not discard channel migration history that every account depends on.
|
|
30
|
+
*/
|
|
31
|
+
function clearOwner(state, ownerTag) {
|
|
32
|
+
state.clearOwner(ownerTag);
|
|
33
|
+
return {
|
|
34
|
+
clearedCollections: ['dedupLedger', 'interactionBuffer', 'permissionHistory']
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=reset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["resetState","state","reset","clearedCollections","clearOwner","ownerTag"],"sourceRoot":"../../../src","sources":["state/reset.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACO,SAASA,UAAUA,CAACC,KAAmB,EAAgB;EAC7DA,KAAK,CAACC,KAAK,CAAC,CAAC;EACb,OAAO;IACNC,kBAAkB,EAAE,CACnB,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,mBAAmB;EAErB,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAACH,KAAmB,EAAEI,QAAgB,EAAgB;EAC/EJ,KAAK,CAACG,UAAU,CAACC,QAAQ,CAAC;EAC1B,OAAO;IACNF,kBAAkB,EAAE,CAAC,aAAa,EAAE,mBAAmB,EAAE,mBAAmB;EAC7E,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.listSeries = listSeries;
|
|
7
|
+
exports.ownedIdentifiers = ownedIdentifiers;
|
|
8
|
+
exports.ownsIdentifier = ownsIdentifier;
|
|
9
|
+
exports.readSeries = readSeries;
|
|
10
|
+
exports.removeSeries = removeSeries;
|
|
11
|
+
exports.upsertSeries = upsertSeries;
|
|
12
|
+
/**
|
|
13
|
+
* The recurrence series ledger.
|
|
14
|
+
*
|
|
15
|
+
* What makes automatic maintenance possible without a desired set from the
|
|
16
|
+
* consumer: the package remembers which series it owns, how far each has been
|
|
17
|
+
* expanded, and how many occurrences a count-limited series has already
|
|
18
|
+
* emitted. None of that is derivable from the platform's pending set, which
|
|
19
|
+
* knows only about individual notifications.
|
|
20
|
+
*
|
|
21
|
+
* It also defines what maintenance is allowed to touch. An occurrence belongs
|
|
22
|
+
* to a series in this ledger, so cancelling it is within scope; anything else
|
|
23
|
+
* is a directly-scheduled notification the package does not own.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
function readSeries(state, seriesId) {
|
|
27
|
+
return state.read().seriesLedger.find(entry => entry.seriesId === seriesId);
|
|
28
|
+
}
|
|
29
|
+
function listSeries(state) {
|
|
30
|
+
return state.read().seriesLedger;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Records or updates a series. Replaces in place so a re-registration cannot duplicate. */
|
|
34
|
+
function upsertSeries(state, rule, update, now) {
|
|
35
|
+
const entry = {
|
|
36
|
+
at: now,
|
|
37
|
+
seriesId: rule.id,
|
|
38
|
+
anchoring: rule.anchoring ?? 'wallClock',
|
|
39
|
+
expandedThrough: update.expandedThrough,
|
|
40
|
+
emittedCount: update.emittedCount,
|
|
41
|
+
exhausted: update.exhausted,
|
|
42
|
+
...(update.lastEmittedKey !== undefined ? {
|
|
43
|
+
lastEmittedKey: update.lastEmittedKey
|
|
44
|
+
} : {})
|
|
45
|
+
};
|
|
46
|
+
state.update('seriesLedger', current => [...current.filter(existing => existing.seriesId !== rule.id), entry]);
|
|
47
|
+
}
|
|
48
|
+
function removeSeries(state, seriesId) {
|
|
49
|
+
state.update('seriesLedger', current => current.filter(entry => entry.seriesId !== seriesId));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Identifiers the package owns.
|
|
54
|
+
*
|
|
55
|
+
* An occurrence identifier is `<seriesId>#<instant>`, so ownership is decided
|
|
56
|
+
* by prefix rather than by an enumeration the ledger would have to keep in sync
|
|
57
|
+
* with the device. That keeps the check correct even for occurrences scheduled
|
|
58
|
+
* before the app last restarted.
|
|
59
|
+
*/
|
|
60
|
+
function ownsIdentifier(state, id) {
|
|
61
|
+
const separator = id.lastIndexOf('#');
|
|
62
|
+
if (separator === -1) return false;
|
|
63
|
+
const seriesId = id.slice(0, separator);
|
|
64
|
+
return state.read().seriesLedger.some(entry => entry.seriesId === seriesId);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Every occurrence identifier currently attributable to a tracked series. */
|
|
68
|
+
function ownedIdentifiers(state, pendingIds) {
|
|
69
|
+
return new Set(pendingIds.filter(id => ownsIdentifier(state, id)));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=series-ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["readSeries","state","seriesId","read","seriesLedger","find","entry","listSeries","upsertSeries","rule","update","now","at","id","anchoring","expandedThrough","emittedCount","exhausted","lastEmittedKey","undefined","current","filter","existing","removeSeries","ownsIdentifier","separator","lastIndexOf","slice","some","ownedIdentifiers","pendingIds","Set"],"sourceRoot":"../../../src","sources":["state/series-ledger.ts"],"mappings":";;;;;;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AEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASsB,cAAcA,CAACvB,KAAmB,EAAEY,EAAU,EAAW;EACxE,MAAMY,SAAS,GAAGZ,EAAE,CAACa,WAAW,CAAC,GAAG,CAAC;EACrC,IAAID,SAAS,KAAK,CAAC,CAAC,EAAE,OAAO,KAAK;EAElC,MAAMvB,QAAQ,GAAGW,EAAE,CAACc,KAAK,CAAC,CAAC,EAAEF,SAAS,CAAC;EACvC,OAAOxB,KAAK,CAACE,IAAI,CAAC,CAAC,CAACC,YAAY,CAACwB,IAAI,CAACtB,KAAK,IAAIA,KAAK,CAACJ,QAAQ,KAAKA,QAAQ,CAAC;AAC5E;;AAEA;AACO,SAAS2B,gBAAgBA,CAC/B5B,KAAmB,EACnB6B,UAA6B,EACP;EACtB,OAAO,IAAIC,GAAG,CAACD,UAAU,CAACT,MAAM,CAACR,EAAE,IAAIW,cAAc,CAACvB,KAAK,EAAEY,EAAE,CAAC,CAAC,CAAC;AACnE","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createMemoryStore = createMemoryStore;
|
|
7
|
+
/**
|
|
8
|
+
* The storage port behind the persisted state record.
|
|
9
|
+
*
|
|
10
|
+
* Kept as a port so the pure state logic is testable with no native module,
|
|
11
|
+
* and so MMKV stays confined to one file. This is internal — a consumer can
|
|
12
|
+
* reset or clear state, but can never read or write the record directly.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** In-memory store, used by tests and as the fallback when MMKV is unavailable. */
|
|
16
|
+
function createMemoryStore() {
|
|
17
|
+
const map = new Map();
|
|
18
|
+
return {
|
|
19
|
+
getString: key => map.get(key),
|
|
20
|
+
setString: (key, value) => {
|
|
21
|
+
map.set(key, value);
|
|
22
|
+
},
|
|
23
|
+
delete: key => {
|
|
24
|
+
map.delete(key);
|
|
25
|
+
},
|
|
26
|
+
clearAll: () => {
|
|
27
|
+
map.clear();
|
|
28
|
+
},
|
|
29
|
+
approximateBytes: () => {
|
|
30
|
+
let total = 0;
|
|
31
|
+
for (const [key, value] of map) {
|
|
32
|
+
total += key.length + value.length;
|
|
33
|
+
}
|
|
34
|
+
return total;
|
|
35
|
+
},
|
|
36
|
+
durable: false
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createMemoryStore","map","Map","getString","key","get","setString","value","set","delete","clearAll","clear","approximateBytes","total","length","durable"],"sourceRoot":"../../../src","sources":["state/store.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACO,SAASA,iBAAiBA,CAAA,EAAe;EAC/C,MAAMC,GAAG,GAAG,IAAIC,GAAG,CAAiB,CAAC;EACrC,OAAO;IACNC,SAAS,EAAEC,GAAG,IAAIH,GAAG,CAACI,GAAG,CAACD,GAAG,CAAC;IAC9BE,SAAS,EAAEA,CAACF,GAAG,EAAEG,KAAK,KAAK;MAC1BN,GAAG,CAACO,GAAG,CAACJ,GAAG,EAAEG,KAAK,CAAC;IACpB,CAAC;IACDE,MAAM,EAAEL,GAAG,IAAI;MACdH,GAAG,CAACQ,MAAM,CAACL,GAAG,CAAC;IAChB,CAAC;IACDM,QAAQ,EAAEA,CAAA,KAAM;MACfT,GAAG,CAACU,KAAK,CAAC,CAAC;IACZ,CAAC;IACDC,gBAAgB,EAAEA,CAAA,KAAM;MACvB,IAAIC,KAAK,GAAG,CAAC;MACb,KAAK,MAAM,CAACT,GAAG,EAAEG,KAAK,CAAC,IAAIN,GAAG,EAAE;QAC/BY,KAAK,IAAIT,GAAG,CAACU,MAAM,GAAGP,KAAK,CAACO,MAAM;MACnC;MACA,OAAOD,KAAK;IACb,CAAC;IACDE,OAAO,EAAE;EACV,CAAC;AACF","ignoreList":[]}
|