@despia-native/kernel 0.0.0-stage → 0.3.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/LICENSE +202 -0
- package/NOTICE +1414 -0
- package/README.md +17 -2
- package/dist/.dsx-build-stamp.json +7 -0
- package/dist/api-cohort.d.ts +27 -0
- package/dist/api-cohort.d.ts.map +1 -0
- package/dist/api-cohort.js +94 -0
- package/dist/api-cohort.js.map +1 -0
- package/dist/api.d.ts +454 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +2442 -0
- package/dist/api.js.map +1 -0
- package/dist/app-consts.d.ts +10 -0
- package/dist/app-consts.d.ts.map +1 -0
- package/dist/app-consts.js +39 -0
- package/dist/app-consts.js.map +1 -0
- package/dist/app-update.d.ts +12 -0
- package/dist/app-update.d.ts.map +1 -0
- package/dist/app-update.js +32 -0
- package/dist/app-update.js.map +1 -0
- package/dist/aria.d.ts +152 -0
- package/dist/aria.d.ts.map +1 -0
- package/dist/aria.js +524 -0
- package/dist/aria.js.map +1 -0
- package/dist/audio-core.d.ts +260 -0
- package/dist/audio-core.d.ts.map +1 -0
- package/dist/audio-core.js +1440 -0
- package/dist/audio-core.js.map +1 -0
- package/dist/audio-edit.d.ts +100 -0
- package/dist/audio-edit.d.ts.map +1 -0
- package/dist/audio-edit.js +489 -0
- package/dist/audio-edit.js.map +1 -0
- package/dist/audio-mix.d.ts +84 -0
- package/dist/audio-mix.d.ts.map +1 -0
- package/dist/audio-mix.js +393 -0
- package/dist/audio-mix.js.map +1 -0
- package/dist/auth-proof.d.ts +145 -0
- package/dist/auth-proof.d.ts.map +1 -0
- package/dist/auth-proof.js +644 -0
- package/dist/auth-proof.js.map +1 -0
- package/dist/availability-explain.d.ts +3 -0
- package/dist/availability-explain.d.ts.map +1 -0
- package/dist/availability-explain.js +322 -0
- package/dist/availability-explain.js.map +1 -0
- package/dist/availability.d.ts +246 -0
- package/dist/availability.d.ts.map +1 -0
- package/dist/availability.js +615 -0
- package/dist/availability.js.map +1 -0
- package/dist/background.d.ts +116 -0
- package/dist/background.d.ts.map +1 -0
- package/dist/background.js +235 -0
- package/dist/background.js.map +1 -0
- package/dist/boot-tables-flag.d.ts +2 -0
- package/dist/boot-tables-flag.d.ts.map +1 -0
- package/dist/boot-tables-flag.js +16 -0
- package/dist/boot-tables-flag.js.map +1 -0
- package/dist/boot-tables.d.ts +40 -0
- package/dist/boot-tables.d.ts.map +1 -0
- package/dist/boot-tables.js +102 -0
- package/dist/boot-tables.js.map +1 -0
- package/dist/border-edges.d.ts +5 -0
- package/dist/border-edges.d.ts.map +1 -0
- package/dist/border-edges.js +47 -0
- package/dist/border-edges.js.map +1 -0
- package/dist/bus.d.ts +1203 -0
- package/dist/bus.d.ts.map +1 -0
- package/dist/bus.js +2647 -0
- package/dist/bus.js.map +1 -0
- package/dist/calendar-core.d.ts +143 -0
- package/dist/calendar-core.d.ts.map +1 -0
- package/dist/calendar-core.js +372 -0
- package/dist/calendar-core.js.map +1 -0
- package/dist/call-value.d.ts +16 -0
- package/dist/call-value.d.ts.map +1 -0
- package/dist/call-value.js +54 -0
- package/dist/call-value.js.map +1 -0
- package/dist/camera-core.d.ts +222 -0
- package/dist/camera-core.d.ts.map +1 -0
- package/dist/camera-core.js +980 -0
- package/dist/camera-core.js.map +1 -0
- package/dist/canvas-core.d.ts +404 -0
- package/dist/canvas-core.d.ts.map +1 -0
- package/dist/canvas-core.js +2186 -0
- package/dist/canvas-core.js.map +1 -0
- package/dist/capture-core.d.ts +74 -0
- package/dist/capture-core.d.ts.map +1 -0
- package/dist/capture-core.js +158 -0
- package/dist/capture-core.js.map +1 -0
- package/dist/compile/codegen.d.ts +146 -0
- package/dist/compile/codegen.d.ts.map +1 -0
- package/dist/compile/codegen.js +1949 -0
- package/dist/compile/codegen.js.map +1 -0
- package/dist/compile/jstier.d.ts +44 -0
- package/dist/compile/jstier.d.ts.map +1 -0
- package/dist/compile/jstier.js +181 -0
- package/dist/compile/jstier.js.map +1 -0
- package/dist/compile/tier-door.d.ts +41 -0
- package/dist/compile/tier-door.d.ts.map +1 -0
- package/dist/compile/tier-door.js +167 -0
- package/dist/compile/tier-door.js.map +1 -0
- package/dist/compile/tier-realm.d.ts +49 -0
- package/dist/compile/tier-realm.d.ts.map +1 -0
- package/dist/compile/tier-realm.js +368 -0
- package/dist/compile/tier-realm.js.map +1 -0
- package/dist/compile/tier.d.ts +23 -0
- package/dist/compile/tier.d.ts.map +1 -0
- package/dist/compile/tier.js +157 -0
- package/dist/compile/tier.js.map +1 -0
- package/dist/compose-core.d.ts +86 -0
- package/dist/compose-core.d.ts.map +1 -0
- package/dist/compose-core.js +112 -0
- package/dist/compose-core.js.map +1 -0
- package/dist/config-validate.d.ts +31 -0
- package/dist/config-validate.d.ts.map +1 -0
- package/dist/config-validate.js +147 -0
- package/dist/config-validate.js.map +1 -0
- package/dist/config-values.d.ts +106 -0
- package/dist/config-values.d.ts.map +1 -0
- package/dist/config-values.js +340 -0
- package/dist/config-values.js.map +1 -0
- package/dist/contacts-core.d.ts +127 -0
- package/dist/contacts-core.d.ts.map +1 -0
- package/dist/contacts-core.js +211 -0
- package/dist/contacts-core.js.map +1 -0
- package/dist/content-transition.d.ts +58 -0
- package/dist/content-transition.d.ts.map +1 -0
- package/dist/content-transition.js +94 -0
- package/dist/content-transition.js.map +1 -0
- package/dist/controls-core.d.ts +227 -0
- package/dist/controls-core.d.ts.map +1 -0
- package/dist/controls-core.js +652 -0
- package/dist/controls-core.js.map +1 -0
- package/dist/cookies.d.ts +78 -0
- package/dist/cookies.d.ts.map +1 -0
- package/dist/cookies.js +265 -0
- package/dist/cookies.js.map +1 -0
- package/dist/corner-shape-core.d.ts +69 -0
- package/dist/corner-shape-core.d.ts.map +1 -0
- package/dist/corner-shape-core.js +261 -0
- package/dist/corner-shape-core.js.map +1 -0
- package/dist/crypto-core.d.ts +57 -0
- package/dist/crypto-core.d.ts.map +1 -0
- package/dist/crypto-core.js +128 -0
- package/dist/crypto-core.js.map +1 -0
- package/dist/dataviz.d.ts +436 -0
- package/dist/dataviz.d.ts.map +1 -0
- package/dist/dataviz.js +956 -0
- package/dist/dataviz.js.map +1 -0
- package/dist/debug.d.ts +293 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +767 -0
- package/dist/debug.js.map +1 -0
- package/dist/device-ownership.d.ts +50 -0
- package/dist/device-ownership.d.ts.map +1 -0
- package/dist/device-ownership.js +105 -0
- package/dist/device-ownership.js.map +1 -0
- package/dist/effects.d.ts +86 -0
- package/dist/effects.d.ts.map +1 -0
- package/dist/effects.js +98 -0
- package/dist/effects.js.map +1 -0
- package/dist/element.d.ts +108 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/element.js +63 -0
- package/dist/element.js.map +1 -0
- package/dist/file-watch.d.ts +16 -0
- package/dist/file-watch.d.ts.map +1 -0
- package/dist/file-watch.js +49 -0
- package/dist/file-watch.js.map +1 -0
- package/dist/filepaths.d.ts +72 -0
- package/dist/filepaths.d.ts.map +1 -0
- package/dist/filepaths.js +271 -0
- package/dist/filepaths.js.map +1 -0
- package/dist/film.d.ts +264 -0
- package/dist/film.d.ts.map +1 -0
- package/dist/film.js +313 -0
- package/dist/film.js.map +1 -0
- package/dist/fonts.d.ts +66 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +135 -0
- package/dist/fonts.js.map +1 -0
- package/dist/forms.d.ts +191 -0
- package/dist/forms.d.ts.map +1 -0
- package/dist/forms.js +663 -0
- package/dist/forms.js.map +1 -0
- package/dist/geo.d.ts +289 -0
- package/dist/geo.d.ts.map +1 -0
- package/dist/geo.js +460 -0
- package/dist/geo.js.map +1 -0
- package/dist/handler-announce.d.ts +46 -0
- package/dist/handler-announce.d.ts.map +1 -0
- package/dist/handler-announce.js +96 -0
- package/dist/handler-announce.js.map +1 -0
- package/dist/handoff.d.ts +71 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +250 -0
- package/dist/handoff.js.map +1 -0
- package/dist/identity-durability.d.ts +76 -0
- package/dist/identity-durability.d.ts.map +1 -0
- package/dist/identity-durability.js +150 -0
- package/dist/identity-durability.js.map +1 -0
- package/dist/image-core.d.ts +240 -0
- package/dist/image-core.d.ts.map +1 -0
- package/dist/image-core.js +618 -0
- package/dist/image-core.js.map +1 -0
- package/dist/image-schemes.d.ts +10 -0
- package/dist/image-schemes.d.ts.map +1 -0
- package/dist/image-schemes.js +28 -0
- package/dist/image-schemes.js.map +1 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +299 -0
- package/dist/index.js.map +1 -0
- package/dist/ink-core.d.ts +53 -0
- package/dist/ink-core.d.ts.map +1 -0
- package/dist/ink-core.js +119 -0
- package/dist/ink-core.js.map +1 -0
- package/dist/input.d.ts +148 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +358 -0
- package/dist/input.js.map +1 -0
- package/dist/integrity.d.ts +63 -0
- package/dist/integrity.d.ts.map +1 -0
- package/dist/integrity.js +150 -0
- package/dist/integrity.js.map +1 -0
- package/dist/intents.d.ts +95 -0
- package/dist/intents.d.ts.map +1 -0
- package/dist/intents.js +282 -0
- package/dist/intents.js.map +1 -0
- package/dist/interpolate-core.d.ts +37 -0
- package/dist/interpolate-core.d.ts.map +1 -0
- package/dist/interpolate-core.js +443 -0
- package/dist/interpolate-core.js.map +1 -0
- package/dist/jse/color.d.ts +12 -0
- package/dist/jse/color.d.ts.map +1 -0
- package/dist/jse/color.js +196 -0
- package/dist/jse/color.js.map +1 -0
- package/dist/jse/core.d.ts +54 -0
- package/dist/jse/core.d.ts.map +1 -0
- package/dist/jse/core.js +1519 -0
- package/dist/jse/core.js.map +1 -0
- package/dist/jse/dispatch.d.ts +28 -0
- package/dist/jse/dispatch.d.ts.map +1 -0
- package/dist/jse/dispatch.js +116 -0
- package/dist/jse/dispatch.js.map +1 -0
- package/dist/jse/highlight-grammar.d.ts +15 -0
- package/dist/jse/highlight-grammar.d.ts.map +1 -0
- package/dist/jse/highlight-grammar.js +161 -0
- package/dist/jse/highlight-grammar.js.map +1 -0
- package/dist/jse/highlight-grammars.generated.d.ts +2 -0
- package/dist/jse/highlight-grammars.generated.d.ts.map +1 -0
- package/dist/jse/highlight-grammars.generated.js +4 -0
- package/dist/jse/highlight-grammars.generated.js.map +1 -0
- package/dist/jse/highlight.d.ts +37 -0
- package/dist/jse/highlight.d.ts.map +1 -0
- package/dist/jse/highlight.js +323 -0
- package/dist/jse/highlight.js.map +1 -0
- package/dist/jse/jse.d.ts +674 -0
- package/dist/jse/jse.d.ts.map +1 -0
- package/dist/jse/jse.js +5841 -0
- package/dist/jse/jse.js.map +1 -0
- package/dist/jse/pathmatch.d.ts +10 -0
- package/dist/jse/pathmatch.d.ts.map +1 -0
- package/dist/jse/pathmatch.js +73 -0
- package/dist/jse/pathmatch.js.map +1 -0
- package/dist/jse/regex.d.ts +33 -0
- package/dist/jse/regex.d.ts.map +1 -0
- package/dist/jse/regex.js +375 -0
- package/dist/jse/regex.js.map +1 -0
- package/dist/jse/stdlib.d.ts +8 -0
- package/dist/jse/stdlib.d.ts.map +1 -0
- package/dist/jse/stdlib.js +765 -0
- package/dist/jse/stdlib.js.map +1 -0
- package/dist/jse/tokens.d.ts +102 -0
- package/dist/jse/tokens.d.ts.map +1 -0
- package/dist/jse/tokens.js +982 -0
- package/dist/jse/tokens.js.map +1 -0
- package/dist/jse/values.d.ts +206 -0
- package/dist/jse/values.d.ts.map +1 -0
- package/dist/jse/values.js +846 -0
- package/dist/jse/values.js.map +1 -0
- package/dist/keyboard.d.ts +196 -0
- package/dist/keyboard.d.ts.map +1 -0
- package/dist/keyboard.js +186 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/label-choices.d.ts +3 -0
- package/dist/label-choices.d.ts.map +1 -0
- package/dist/label-choices.js +168 -0
- package/dist/label-choices.js.map +1 -0
- package/dist/language.d.ts +33 -0
- package/dist/language.d.ts.map +1 -0
- package/dist/language.js +50 -0
- package/dist/language.js.map +1 -0
- package/dist/length-units.d.ts +30 -0
- package/dist/length-units.d.ts.map +1 -0
- package/dist/length-units.js +83 -0
- package/dist/length-units.js.map +1 -0
- package/dist/lightsensor.d.ts +48 -0
- package/dist/lightsensor.d.ts.map +1 -0
- package/dist/lightsensor.js +97 -0
- package/dist/lightsensor.js.map +1 -0
- package/dist/link-refresh.d.ts +27 -0
- package/dist/link-refresh.d.ts.map +1 -0
- package/dist/link-refresh.js +166 -0
- package/dist/link-refresh.js.map +1 -0
- package/dist/link.d.ts +57 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +333 -0
- package/dist/link.js.map +1 -0
- package/dist/linkpreview.d.ts +114 -0
- package/dist/linkpreview.d.ts.map +1 -0
- package/dist/linkpreview.js +439 -0
- package/dist/linkpreview.js.map +1 -0
- package/dist/list-presence.d.ts +32 -0
- package/dist/list-presence.d.ts.map +1 -0
- package/dist/list-presence.js +48 -0
- package/dist/list-presence.js.map +1 -0
- package/dist/live-stream.d.ts +27 -0
- package/dist/live-stream.d.ts.map +1 -0
- package/dist/live-stream.js +274 -0
- package/dist/live-stream.js.map +1 -0
- package/dist/livelogs.d.ts +134 -0
- package/dist/livelogs.d.ts.map +1 -0
- package/dist/livelogs.js +409 -0
- package/dist/livelogs.js.map +1 -0
- package/dist/logs.d.ts +80 -0
- package/dist/logs.d.ts.map +1 -0
- package/dist/logs.js +206 -0
- package/dist/logs.js.map +1 -0
- package/dist/mcp/apps.d.ts +82 -0
- package/dist/mcp/apps.d.ts.map +1 -0
- package/dist/mcp/apps.js +219 -0
- package/dist/mcp/apps.js.map +1 -0
- package/dist/mcp/entities.d.ts +25 -0
- package/dist/mcp/entities.d.ts.map +1 -0
- package/dist/mcp/entities.js +71 -0
- package/dist/mcp/entities.js.map +1 -0
- package/dist/mcp/result.d.ts +73 -0
- package/dist/mcp/result.d.ts.map +1 -0
- package/dist/mcp/result.js +119 -0
- package/dist/mcp/result.js.map +1 -0
- package/dist/mcp/webmcp.d.ts +162 -0
- package/dist/mcp/webmcp.d.ts.map +1 -0
- package/dist/mcp/webmcp.js +214 -0
- package/dist/mcp/webmcp.js.map +1 -0
- package/dist/mcp.d.ts +5 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +14 -0
- package/dist/mcp.js.map +1 -0
- package/dist/media-core.d.ts +191 -0
- package/dist/media-core.d.ts.map +1 -0
- package/dist/media-core.js +446 -0
- package/dist/media-core.js.map +1 -0
- package/dist/media-timeline-core.d.ts +94 -0
- package/dist/media-timeline-core.d.ts.map +1 -0
- package/dist/media-timeline-core.js +620 -0
- package/dist/media-timeline-core.js.map +1 -0
- package/dist/message.d.ts +42 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +582 -0
- package/dist/message.js.map +1 -0
- package/dist/missing-element.d.ts +29 -0
- package/dist/missing-element.d.ts.map +1 -0
- package/dist/missing-element.js +76 -0
- package/dist/missing-element.js.map +1 -0
- package/dist/motion-core.d.ts +160 -0
- package/dist/motion-core.d.ts.map +1 -0
- package/dist/motion-core.js +752 -0
- package/dist/motion-core.js.map +1 -0
- package/dist/motion-pose.d.ts +65 -0
- package/dist/motion-pose.d.ts.map +1 -0
- package/dist/motion-pose.js +143 -0
- package/dist/motion-pose.js.map +1 -0
- package/dist/motion.d.ts +132 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +260 -0
- package/dist/motion.js.map +1 -0
- package/dist/mount-core.d.ts +203 -0
- package/dist/mount-core.d.ts.map +1 -0
- package/dist/mount-core.js +437 -0
- package/dist/mount-core.js.map +1 -0
- package/dist/net-core.d.ts +110 -0
- package/dist/net-core.d.ts.map +1 -0
- package/dist/net-core.js +225 -0
- package/dist/net-core.js.map +1 -0
- package/dist/notify.d.ts +399 -0
- package/dist/notify.d.ts.map +1 -0
- package/dist/notify.js +964 -0
- package/dist/notify.js.map +1 -0
- package/dist/orientation-binding.d.ts +39 -0
- package/dist/orientation-binding.d.ts.map +1 -0
- package/dist/orientation-binding.js +64 -0
- package/dist/orientation-binding.js.map +1 -0
- package/dist/orientation.d.ts +55 -0
- package/dist/orientation.d.ts.map +1 -0
- package/dist/orientation.js +89 -0
- package/dist/orientation.js.map +1 -0
- package/dist/ota.d.ts +52 -0
- package/dist/ota.d.ts.map +1 -0
- package/dist/ota.js +122 -0
- package/dist/ota.js.map +1 -0
- package/dist/passkeys.d.ts +91 -0
- package/dist/passkeys.d.ts.map +1 -0
- package/dist/passkeys.js +307 -0
- package/dist/passkeys.js.map +1 -0
- package/dist/payment.d.ts +85 -0
- package/dist/payment.d.ts.map +1 -0
- package/dist/payment.js +270 -0
- package/dist/payment.js.map +1 -0
- package/dist/pending-presenter.d.ts +31 -0
- package/dist/pending-presenter.d.ts.map +1 -0
- package/dist/pending-presenter.js +119 -0
- package/dist/pending-presenter.js.map +1 -0
- package/dist/permission-core.d.ts +59 -0
- package/dist/permission-core.d.ts.map +1 -0
- package/dist/permission-core.js +102 -0
- package/dist/permission-core.js.map +1 -0
- package/dist/persist.d.ts +169 -0
- package/dist/persist.d.ts.map +1 -0
- package/dist/persist.js +361 -0
- package/dist/persist.js.map +1 -0
- package/dist/phase-plan.d.ts +114 -0
- package/dist/phase-plan.d.ts.map +1 -0
- package/dist/phase-plan.js +837 -0
- package/dist/phase-plan.js.map +1 -0
- package/dist/playback-core.d.ts +64 -0
- package/dist/playback-core.d.ts.map +1 -0
- package/dist/playback-core.js +176 -0
- package/dist/playback-core.js.map +1 -0
- package/dist/player-sources.d.ts +12 -0
- package/dist/player-sources.d.ts.map +1 -0
- package/dist/player-sources.js +44 -0
- package/dist/player-sources.js.map +1 -0
- package/dist/proxy-denylist.d.ts +11 -0
- package/dist/proxy-denylist.d.ts.map +1 -0
- package/dist/proxy-denylist.js +44 -0
- package/dist/proxy-denylist.js.map +1 -0
- package/dist/public-config.d.ts +20 -0
- package/dist/public-config.d.ts.map +1 -0
- package/dist/public-config.js +109 -0
- package/dist/public-config.js.map +1 -0
- package/dist/qoe-core.d.ts +72 -0
- package/dist/qoe-core.d.ts.map +1 -0
- package/dist/qoe-core.js +113 -0
- package/dist/qoe-core.js.map +1 -0
- package/dist/reactive-request.d.ts +80 -0
- package/dist/reactive-request.d.ts.map +1 -0
- package/dist/reactive-request.js +192 -0
- package/dist/reactive-request.js.map +1 -0
- package/dist/read-cache.d.ts +129 -0
- package/dist/read-cache.d.ts.map +1 -0
- package/dist/read-cache.js +566 -0
- package/dist/read-cache.js.map +1 -0
- package/dist/recorder-core.d.ts +57 -0
- package/dist/recorder-core.d.ts.map +1 -0
- package/dist/recorder-core.js +136 -0
- package/dist/recorder-core.js.map +1 -0
- package/dist/ref.d.ts +41 -0
- package/dist/ref.d.ts.map +1 -0
- package/dist/ref.js +98 -0
- package/dist/ref.js.map +1 -0
- package/dist/refusal.d.ts +82 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +218 -0
- package/dist/refusal.js.map +1 -0
- package/dist/region-insets.d.ts +61 -0
- package/dist/region-insets.d.ts.map +1 -0
- package/dist/region-insets.js +67 -0
- package/dist/region-insets.js.map +1 -0
- package/dist/rive-core.d.ts +323 -0
- package/dist/rive-core.d.ts.map +1 -0
- package/dist/rive-core.js +677 -0
- package/dist/rive-core.js.map +1 -0
- package/dist/runner.d.ts +595 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +4094 -0
- package/dist/runner.js.map +1 -0
- package/dist/scene/a11y.d.ts +11 -0
- package/dist/scene/a11y.d.ts.map +1 -0
- package/dist/scene/a11y.js +67 -0
- package/dist/scene/a11y.js.map +1 -0
- package/dist/scene/anim.d.ts +149 -0
- package/dist/scene/anim.d.ts.map +1 -0
- package/dist/scene/anim.js +396 -0
- package/dist/scene/anim.js.map +1 -0
- package/dist/scene/bind.d.ts +33 -0
- package/dist/scene/bind.d.ts.map +1 -0
- package/dist/scene/bind.js +66 -0
- package/dist/scene/bind.js.map +1 -0
- package/dist/scene/collide.d.ts +56 -0
- package/dist/scene/collide.d.ts.map +1 -0
- package/dist/scene/collide.js +146 -0
- package/dist/scene/collide.js.map +1 -0
- package/dist/scene/frame.d.ts +22 -0
- package/dist/scene/frame.d.ts.map +1 -0
- package/dist/scene/frame.js +57 -0
- package/dist/scene/frame.js.map +1 -0
- package/dist/scene/gltf.d.ts +79 -0
- package/dist/scene/gltf.d.ts.map +1 -0
- package/dist/scene/gltf.js +409 -0
- package/dist/scene/gltf.js.map +1 -0
- package/dist/scene/ir.d.ts +293 -0
- package/dist/scene/ir.d.ts.map +1 -0
- package/dist/scene/ir.js +692 -0
- package/dist/scene/ir.js.map +1 -0
- package/dist/scene/math.d.ts +50 -0
- package/dist/scene/math.d.ts.map +1 -0
- package/dist/scene/math.js +180 -0
- package/dist/scene/math.js.map +1 -0
- package/dist/scene/orbit.d.ts +19 -0
- package/dist/scene/orbit.d.ts.map +1 -0
- package/dist/scene/orbit.js +60 -0
- package/dist/scene/orbit.js.map +1 -0
- package/dist/scene/physics.d.ts +228 -0
- package/dist/scene/physics.d.ts.map +1 -0
- package/dist/scene/physics.js +1500 -0
- package/dist/scene/physics.js.map +1 -0
- package/dist/scene/registry.d.ts +85 -0
- package/dist/scene/registry.d.ts.map +1 -0
- package/dist/scene/registry.js +75 -0
- package/dist/scene/registry.js.map +1 -0
- package/dist/scene/skin.d.ts +82 -0
- package/dist/scene/skin.d.ts.map +1 -0
- package/dist/scene/skin.js +351 -0
- package/dist/scene/skin.js.map +1 -0
- package/dist/scene/sprite.d.ts +36 -0
- package/dist/scene/sprite.d.ts.map +1 -0
- package/dist/scene/sprite.js +107 -0
- package/dist/scene/sprite.js.map +1 -0
- package/dist/scene/viewer.d.ts +96 -0
- package/dist/scene/viewer.d.ts.map +1 -0
- package/dist/scene/viewer.js +235 -0
- package/dist/scene/viewer.js.map +1 -0
- package/dist/scoped-slots.d.ts +9 -0
- package/dist/scoped-slots.d.ts.map +1 -0
- package/dist/scoped-slots.js +42 -0
- package/dist/scoped-slots.js.map +1 -0
- package/dist/screen.d.ts +109 -0
- package/dist/screen.d.ts.map +1 -0
- package/dist/screen.js +309 -0
- package/dist/screen.js.map +1 -0
- package/dist/scroll.d.ts +525 -0
- package/dist/scroll.d.ts.map +1 -0
- package/dist/scroll.js +1226 -0
- package/dist/scroll.js.map +1 -0
- package/dist/settings-plane.d.ts +58 -0
- package/dist/settings-plane.d.ts.map +1 -0
- package/dist/settings-plane.js +86 -0
- package/dist/settings-plane.js.map +1 -0
- package/dist/share-inbox.d.ts +56 -0
- package/dist/share-inbox.d.ts.map +1 -0
- package/dist/share-inbox.js +114 -0
- package/dist/share-inbox.js.map +1 -0
- package/dist/shared-transition.d.ts +152 -0
- package/dist/shared-transition.d.ts.map +1 -0
- package/dist/shared-transition.js +257 -0
- package/dist/shared-transition.js.map +1 -0
- package/dist/sheet-content-padding.d.ts +24 -0
- package/dist/sheet-content-padding.d.ts.map +1 -0
- package/dist/sheet-content-padding.js +32 -0
- package/dist/sheet-content-padding.js.map +1 -0
- package/dist/shot-devices.d.ts +36 -0
- package/dist/shot-devices.d.ts.map +1 -0
- package/dist/shot-devices.js +90 -0
- package/dist/shot-devices.js.map +1 -0
- package/dist/shot-guards.d.ts +100 -0
- package/dist/shot-guards.d.ts.map +1 -0
- package/dist/shot-guards.js +260 -0
- package/dist/shot-guards.js.map +1 -0
- package/dist/shot-scope.d.ts +140 -0
- package/dist/shot-scope.d.ts.map +1 -0
- package/dist/shot-scope.js +302 -0
- package/dist/shot-scope.js.map +1 -0
- package/dist/slot-partition.d.ts +9 -0
- package/dist/slot-partition.d.ts.map +1 -0
- package/dist/slot-partition.js +38 -0
- package/dist/slot-partition.js.map +1 -0
- package/dist/snackbar.d.ts +165 -0
- package/dist/snackbar.d.ts.map +1 -0
- package/dist/snackbar.js +220 -0
- package/dist/snackbar.js.map +1 -0
- package/dist/socket.d.ts +96 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +370 -0
- package/dist/socket.js.map +1 -0
- package/dist/spotlight.d.ts +77 -0
- package/dist/spotlight.d.ts.map +1 -0
- package/dist/spotlight.js +174 -0
- package/dist/spotlight.js.map +1 -0
- package/dist/state-primitive.d.ts +37 -0
- package/dist/state-primitive.d.ts.map +1 -0
- package/dist/state-primitive.js +91 -0
- package/dist/state-primitive.js.map +1 -0
- package/dist/store-query.d.ts +25 -0
- package/dist/store-query.d.ts.map +1 -0
- package/dist/store-query.js +88 -0
- package/dist/store-query.js.map +1 -0
- package/dist/store-value.d.ts +48 -0
- package/dist/store-value.d.ts.map +1 -0
- package/dist/store-value.js +264 -0
- package/dist/store-value.js.map +1 -0
- package/dist/store-versioning.d.ts +70 -0
- package/dist/store-versioning.d.ts.map +1 -0
- package/dist/store-versioning.js +188 -0
- package/dist/store-versioning.js.map +1 -0
- package/dist/store.d.ts +282 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +1144 -0
- package/dist/store.js.map +1 -0
- package/dist/strings.d.ts +141 -0
- package/dist/strings.d.ts.map +1 -0
- package/dist/strings.js +581 -0
- package/dist/strings.js.map +1 -0
- package/dist/telemetry.d.ts +95 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +255 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/transform-core.d.ts +228 -0
- package/dist/transform-core.d.ts.map +1 -0
- package/dist/transform-core.js +921 -0
- package/dist/transform-core.js.map +1 -0
- package/dist/transition-core.d.ts +58 -0
- package/dist/transition-core.d.ts.map +1 -0
- package/dist/transition-core.js +352 -0
- package/dist/transition-core.js.map +1 -0
- package/dist/trim-trailing.d.ts +3 -0
- package/dist/trim-trailing.d.ts.map +1 -0
- package/dist/trim-trailing.js +14 -0
- package/dist/trim-trailing.js.map +1 -0
- package/dist/upload.d.ts +51 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +68 -0
- package/dist/upload.js.map +1 -0
- package/dist/vendor-face.d.ts +44 -0
- package/dist/vendor-face.d.ts.map +1 -0
- package/dist/vendor-face.js +80 -0
- package/dist/vendor-face.js.map +1 -0
- package/dist/vendor-session.d.ts +166 -0
- package/dist/vendor-session.d.ts.map +1 -0
- package/dist/vendor-session.js +423 -0
- package/dist/vendor-session.js.map +1 -0
- package/dist/vendor-surface.d.ts +290 -0
- package/dist/vendor-surface.d.ts.map +1 -0
- package/dist/vendor-surface.js +439 -0
- package/dist/vendor-surface.js.map +1 -0
- package/dist/version-rules.generated.d.ts +17 -0
- package/dist/version-rules.generated.d.ts.map +1 -0
- package/dist/version-rules.generated.js +99 -0
- package/dist/version-rules.generated.js.map +1 -0
- package/dist/view-transition-core.d.ts +99 -0
- package/dist/view-transition-core.d.ts.map +1 -0
- package/dist/view-transition-core.js +127 -0
- package/dist/view-transition-core.js.map +1 -0
- package/dist/view-transition-door.d.ts +26 -0
- package/dist/view-transition-door.d.ts.map +1 -0
- package/dist/view-transition-door.js +88 -0
- package/dist/view-transition-door.js.map +1 -0
- package/dist/window-identity.d.ts +3 -0
- package/dist/window-identity.d.ts.map +1 -0
- package/dist/window-identity.js +27 -0
- package/dist/window-identity.js.map +1 -0
- package/package.json +139 -4
package/dist/notify.js
ADDED
|
@@ -0,0 +1,964 @@
|
|
|
1
|
+
//
|
|
2
|
+
// notify.ts - the shared Core/Notify pure core: the permission ladder (including
|
|
3
|
+
// iOS provisional authorization and the Settings-changed-while-backgrounded transition),
|
|
4
|
+
// the TRIGGER RESOLVER, the Android channel-importance fold, the foreground-presentation
|
|
5
|
+
// resolution and the tap-payload normalisation. The law is the corpus,
|
|
6
|
+
// OpenSource/Conformance/notify/*.json (parity/F02-notifications.md); the Kotlin twin is
|
|
7
|
+
// :core NotifyCore.kt and the Swift twin is Engine/Swift/NotifyCore.swift.
|
|
8
|
+
//
|
|
9
|
+
// Everything platform-shaped lives OUTSIDE this file: UNUserNotificationCenter,
|
|
10
|
+
// NotificationManagerCompat and the browser Notification API all ask this module WHAT to do
|
|
11
|
+
// and then do it. That split is what lets one corpus judge three renderers.
|
|
12
|
+
//
|
|
13
|
+
// THE THREE RULES THIS FILE EXISTS FOR:
|
|
14
|
+
//
|
|
15
|
+
// 1. A REMINDER MUST FIRE AT THE SAME INSTANT ON EVERY PLATFORM. Scheduling is pure date
|
|
16
|
+
// math, and it is where a notification stack is quietly wrong on exactly one platform:
|
|
17
|
+
// an hour early in March, twice on the first Sunday in November, never on a leap day.
|
|
18
|
+
// So the resolver takes ZONE RULES as data - a base offset plus the instants at which it
|
|
19
|
+
// changes - and never asks a platform calendar anything.
|
|
20
|
+
//
|
|
21
|
+
// 2. PROVISIONAL AUTHORIZATION IS ONE FLAG. iOS will deliver quietly with no prompt at all
|
|
22
|
+
// and then let the user promote it; it is the highest-conversion path in mobile and
|
|
23
|
+
// almost nobody ships it, because it is one constant buried in a bitmask. Here it is
|
|
24
|
+
// `{ provisional: true }`, and the escalation to full authorization is a real transition
|
|
25
|
+
// with its own rule: a DECLINED escalation keeps the quiet grant.
|
|
26
|
+
//
|
|
27
|
+
// 3. AN UNDECLARED ANDROID CHANNEL IS A TYPED REFUSAL. Post to a channel that was never
|
|
28
|
+
// created and the OS drops the notification with no exception and no log line. The
|
|
29
|
+
// refusal names the id, because "channel not found" without it is the same afternoon.
|
|
30
|
+
//
|
|
31
|
+
// ---------------------------------------------------------------------------------------
|
|
32
|
+
// The permission ladder
|
|
33
|
+
// ---------------------------------------------------------------------------------------
|
|
34
|
+
/** The authorization statuses, as the module reports them (never a platform enum). */
|
|
35
|
+
export const NOTIFY_STATUSES = ["undetermined", "denied", "provisional", "granted"];
|
|
36
|
+
/** The option vocabulary, exact case. `provisional` is an option like the rest so that quiet
|
|
37
|
+
* authorization is one flag rather than a second API. */
|
|
38
|
+
export const NOTIFY_OPTIONS = [
|
|
39
|
+
"alert", "sound", "badge", "carPlay", "announcement", "critical", "provisional",
|
|
40
|
+
];
|
|
41
|
+
/** What a request that names no option at all asks for. */
|
|
42
|
+
export const NOTIFY_DEFAULT_OPTIONS = ["alert", "badge", "sound"];
|
|
43
|
+
/** What each platform can actually honour. Anything else is dropped AND REPORTED - an app
|
|
44
|
+
* that asked for critical alerts and got ordinary ones has to be able to find that out. */
|
|
45
|
+
export const NOTIFY_PLATFORM_OPTIONS = {
|
|
46
|
+
ios: ["alert", "sound", "badge", "carPlay", "announcement", "critical", "provisional"],
|
|
47
|
+
android: ["alert", "sound", "badge"],
|
|
48
|
+
web: ["alert", "sound", "badge"],
|
|
49
|
+
};
|
|
50
|
+
/** POST_NOTIFICATIONS became a runtime permission here. Below it there is nothing to ask. */
|
|
51
|
+
export const NOTIFY_ANDROID_RUNTIME_PERMISSION_SDK = 33;
|
|
52
|
+
/** `provisional` and `critical` are MODIFIERS, not content: they say HOW the authorization is
|
|
53
|
+
* obtained and how loud it may be, not what the notification is allowed to do. So naming one
|
|
54
|
+
* does not suppress the default alert/badge/sound - `{ provisional: true }` means "the usual
|
|
55
|
+
* notification, delivered quietly", which is the only reading an author ever intends. */
|
|
56
|
+
export const NOTIFY_MODIFIER_OPTIONS = ["provisional", "critical"];
|
|
57
|
+
function requestedOptions(request) {
|
|
58
|
+
const record = request;
|
|
59
|
+
const content = NOTIFY_OPTIONS
|
|
60
|
+
.filter((word) => !NOTIFY_MODIFIER_OPTIONS.includes(word))
|
|
61
|
+
.filter((word) => record[word] === true);
|
|
62
|
+
const modifiers = NOTIFY_MODIFIER_OPTIONS.filter((word) => record[word] === true);
|
|
63
|
+
// A request that names no CONTENT option asks for the sensible default. A request that names
|
|
64
|
+
// only options this platform cannot honour is NOT defaulted afterwards - it asked for
|
|
65
|
+
// something specific, and the honest answer is an empty set plus the dropped list.
|
|
66
|
+
const base = content.length === 0 ? [...NOTIFY_DEFAULT_OPTIONS] : content;
|
|
67
|
+
return [...base, ...modifiers];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Decide what a `permission(...)` call should do.
|
|
71
|
+
*
|
|
72
|
+
* The whole ladder in one function. `status` never reaches here: reading is a different verb
|
|
73
|
+
* and it must never be able to prompt.
|
|
74
|
+
*/
|
|
75
|
+
export function notifyPermissionPlan(request, state, platform, sdk = 0) {
|
|
76
|
+
const supported = NOTIFY_PLATFORM_OPTIONS[platform];
|
|
77
|
+
if (supported === undefined) {
|
|
78
|
+
return {
|
|
79
|
+
action: "refuse", prompted: false, quiet: false, escalation: false,
|
|
80
|
+
options: [], dropped: [], error: "unsupported_platform",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const asked = requestedOptions(request);
|
|
84
|
+
const dropped = [];
|
|
85
|
+
const options = [];
|
|
86
|
+
for (const word of asked) {
|
|
87
|
+
if (!supported.includes(word)) {
|
|
88
|
+
dropped.push(word);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
// The entitlement is not a platform capability, it is a per-app grant, so it is checked
|
|
92
|
+
// separately - and a missing one DROPS the option rather than refusing the whole request,
|
|
93
|
+
// because that is exactly what the platform API does and refusing would be worse.
|
|
94
|
+
if (word === "critical" && state.criticalEntitled !== true) {
|
|
95
|
+
dropped.push(word);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
options.push(word);
|
|
99
|
+
}
|
|
100
|
+
options.sort();
|
|
101
|
+
dropped.sort();
|
|
102
|
+
const wantsProvisional = options.includes("provisional");
|
|
103
|
+
const settle = (status) => ({
|
|
104
|
+
action: "settle", status, prompted: false, quiet: false, escalation: false, options, dropped,
|
|
105
|
+
});
|
|
106
|
+
const refuse = (error) => ({
|
|
107
|
+
action: "refuse", prompted: false, quiet: false, escalation: false, options, dropped, error,
|
|
108
|
+
});
|
|
109
|
+
if (platform === "android" && sdk < NOTIFY_ANDROID_RUNTIME_PERMISSION_SDK) {
|
|
110
|
+
// NOTHING TO ASK. A user who switched the app's notifications off in system settings
|
|
111
|
+
// still reads denied, and no in-app dialog can undo that - so it is a refusal pointing at
|
|
112
|
+
// Settings rather than a prompt that will never appear.
|
|
113
|
+
if (state.status === "denied")
|
|
114
|
+
return refuse("permission_denied");
|
|
115
|
+
return settle("granted");
|
|
116
|
+
}
|
|
117
|
+
switch (state.status) {
|
|
118
|
+
case "granted":
|
|
119
|
+
return settle("granted");
|
|
120
|
+
case "denied":
|
|
121
|
+
return refuse("permission_denied");
|
|
122
|
+
case "provisional":
|
|
123
|
+
// Asking for quiet again while already quiet changes nothing. Asking for FULL is the
|
|
124
|
+
// conversion, and it is the one prompt iOS will still show from here.
|
|
125
|
+
if (wantsProvisional)
|
|
126
|
+
return settle("provisional");
|
|
127
|
+
return { action: "prompt", prompted: true, quiet: false, escalation: true, options, dropped };
|
|
128
|
+
default:
|
|
129
|
+
if (wantsProvisional) {
|
|
130
|
+
return { action: "authorize", prompted: false, quiet: true, escalation: false, options, dropped };
|
|
131
|
+
}
|
|
132
|
+
return { action: "prompt", prompted: true, quiet: false, escalation: false, options, dropped };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Fold the OS's answer to a prompt back into the state.
|
|
137
|
+
*
|
|
138
|
+
* A DECLINED ESCALATION IS NOT A LOST GRANT: an app that was delivering quietly and asked for
|
|
139
|
+
* more must still be delivering quietly afterwards. The naive `granted ? granted : denied`
|
|
140
|
+
* throws away a working feature to record the refusal of a different one, and the user never
|
|
141
|
+
* sees another notification.
|
|
142
|
+
*/
|
|
143
|
+
export function notifyApplyPermission(state, plan, granted) {
|
|
144
|
+
if (plan.action === "authorize") {
|
|
145
|
+
return { status: granted ? "provisional" : "denied", promptShown: state.promptShown, criticalEntitled: state.criticalEntitled };
|
|
146
|
+
}
|
|
147
|
+
if (plan.action === "prompt") {
|
|
148
|
+
if (plan.escalation === true) {
|
|
149
|
+
return { status: granted ? "granted" : "provisional", promptShown: true, criticalEntitled: state.criticalEntitled };
|
|
150
|
+
}
|
|
151
|
+
return { status: granted ? "granted" : "denied", promptShown: true, criticalEntitled: state.criticalEntitled };
|
|
152
|
+
}
|
|
153
|
+
return state;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* THE SETTINGS-CHANGED-WHILE-BACKGROUNDED TRANSITION.
|
|
157
|
+
*
|
|
158
|
+
* The user turns notifications off (or on) in Settings while the app is not running. A module
|
|
159
|
+
* that trusts its cached status then prompts into a void forever, or tells a settings screen
|
|
160
|
+
* that notifications are on when they are not. The OS reading always wins.
|
|
161
|
+
*
|
|
162
|
+
* `undetermined` from the OS means the app was reinstalled, so the spent-prompt memory resets
|
|
163
|
+
* with it - otherwise the module would believe it had already burned a dialog it now has back.
|
|
164
|
+
*/
|
|
165
|
+
export function notifyObservePermission(state, osStatus) {
|
|
166
|
+
const status = NOTIFY_STATUSES.includes(osStatus) ? osStatus : state.status;
|
|
167
|
+
const promptShown = status === "undetermined" ? false : state.promptShown;
|
|
168
|
+
const changed = status !== state.status || promptShown !== state.promptShown;
|
|
169
|
+
return {
|
|
170
|
+
state: { status, promptShown, criticalEntitled: state.criticalEntitled },
|
|
171
|
+
changed,
|
|
172
|
+
broadcast: status !== state.status,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export const NOTIFY_UTC = { base: 0, transitions: [] };
|
|
176
|
+
const MINUTE_MS = 60_000;
|
|
177
|
+
const HOUR_MS = 3_600_000;
|
|
178
|
+
const DAY_MS = 86_400_000;
|
|
179
|
+
export function notifyOffsetAt(zone, instant) {
|
|
180
|
+
let offset = zone.base;
|
|
181
|
+
for (const transition of zone.transitions) {
|
|
182
|
+
if (instant >= transition.at)
|
|
183
|
+
offset = transition.offset;
|
|
184
|
+
else
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
return offset;
|
|
188
|
+
}
|
|
189
|
+
/** An instant, expressed as the epoch-ms value that PRINTS as local time when read as UTC. */
|
|
190
|
+
export function notifyToWall(zone, instant) {
|
|
191
|
+
return instant + notifyOffsetAt(zone, instant) * MINUTE_MS;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A wall-clock value back to an instant.
|
|
195
|
+
*
|
|
196
|
+
* THE TWO CASES DATE MATH DIES ON:
|
|
197
|
+
* GAP (spring forward) - the wall time does not exist. Answer the first instant that does,
|
|
198
|
+
* i.e. the transition itself. A daily reminder that silently skips a day once a year is
|
|
199
|
+
* worse than one that runs half an hour late once a year.
|
|
200
|
+
* OVERLAP (fall back) - the wall time happens twice. Answer the EARLIER instant, once.
|
|
201
|
+
* Firing on both is a duplicate; firing on the second is an hour late.
|
|
202
|
+
*/
|
|
203
|
+
export function notifyFromWall(zone, wall) {
|
|
204
|
+
const offsets = new Set([zone.base]);
|
|
205
|
+
for (const transition of zone.transitions)
|
|
206
|
+
offsets.add(transition.offset);
|
|
207
|
+
let best = null;
|
|
208
|
+
for (const offset of [...offsets].sort((a, b) => a - b)) {
|
|
209
|
+
const instant = wall - offset * MINUTE_MS;
|
|
210
|
+
if (notifyOffsetAt(zone, instant) !== offset)
|
|
211
|
+
continue;
|
|
212
|
+
if (best === null || instant < best)
|
|
213
|
+
best = instant;
|
|
214
|
+
}
|
|
215
|
+
if (best !== null)
|
|
216
|
+
return best;
|
|
217
|
+
for (const transition of zone.transitions) {
|
|
218
|
+
const before = notifyOffsetAt(zone, transition.at - 1);
|
|
219
|
+
const after = transition.offset;
|
|
220
|
+
if (after <= before)
|
|
221
|
+
continue;
|
|
222
|
+
const low = transition.at + before * MINUTE_MS;
|
|
223
|
+
const high = transition.at + after * MINUTE_MS;
|
|
224
|
+
if (wall >= low && wall < high)
|
|
225
|
+
return transition.at;
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
function isLeap(year) {
|
|
230
|
+
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
231
|
+
}
|
|
232
|
+
const MONTH_LENGTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
233
|
+
export function notifyDaysInMonth(year, month) {
|
|
234
|
+
return month === 2 && isLeap(year) ? 29 : MONTH_LENGTHS[month - 1];
|
|
235
|
+
}
|
|
236
|
+
/** Days from 1970-01-01 to year-month-day, Howard Hinnant's civil_from_days inverted. */
|
|
237
|
+
export function notifyDaysFromCivil(year, month, day) {
|
|
238
|
+
const y = year - (month <= 2 ? 1 : 0);
|
|
239
|
+
const era = Math.floor(y / 400);
|
|
240
|
+
const yoe = y - era * 400;
|
|
241
|
+
const doy = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;
|
|
242
|
+
const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
|
|
243
|
+
return era * 146097 + doe - 719468;
|
|
244
|
+
}
|
|
245
|
+
export function notifyCivilFromDays(days) {
|
|
246
|
+
const z = days + 719468;
|
|
247
|
+
const era = Math.floor(z / 146097);
|
|
248
|
+
const doe = z - era * 146097;
|
|
249
|
+
const yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);
|
|
250
|
+
const y = yoe + era * 400;
|
|
251
|
+
const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));
|
|
252
|
+
const mp = Math.floor((5 * doy + 2) / 153);
|
|
253
|
+
const day = doy - Math.floor((153 * mp + 2) / 5) + 1;
|
|
254
|
+
const month = mp + (mp < 10 ? 3 : -9);
|
|
255
|
+
return { year: y + (month <= 2 ? 1 : 0), month, day };
|
|
256
|
+
}
|
|
257
|
+
/** 0 = Sunday. 1970-01-01 was a Thursday. */
|
|
258
|
+
export function notifyWeekday(days) {
|
|
259
|
+
return ((days % 7) + 11) % 7;
|
|
260
|
+
}
|
|
261
|
+
export function notifyWallOf(civil) {
|
|
262
|
+
return notifyDaysFromCivil(civil.year, civil.month, civil.day) * DAY_MS
|
|
263
|
+
+ civil.hour * HOUR_MS + civil.minute * MINUTE_MS;
|
|
264
|
+
}
|
|
265
|
+
export function notifyCivilOf(wall) {
|
|
266
|
+
const days = Math.floor(wall / DAY_MS);
|
|
267
|
+
const rest = wall - days * DAY_MS;
|
|
268
|
+
const { year, month, day } = notifyCivilFromDays(days);
|
|
269
|
+
return { year, month, day, hour: Math.floor(rest / HOUR_MS), minute: Math.floor((rest % HOUR_MS) / MINUTE_MS) };
|
|
270
|
+
}
|
|
271
|
+
// ---------------------------------------------------------------------------------------
|
|
272
|
+
// Cron
|
|
273
|
+
// ---------------------------------------------------------------------------------------
|
|
274
|
+
/** The cron search is BOUNDED. A bound is what makes `0 12 30 2 *` answer "never" instead of
|
|
275
|
+
* hanging a scheduler on a date that does not exist. A shade over four years, so the leap-day
|
|
276
|
+
* case is inside it. */
|
|
277
|
+
export const NOTIFY_CRON_SEARCH_DAYS = 1600;
|
|
278
|
+
function parseCronField(text, low, high) {
|
|
279
|
+
const out = new Set();
|
|
280
|
+
for (const part of text.split(",")) {
|
|
281
|
+
if (part.length === 0)
|
|
282
|
+
return null;
|
|
283
|
+
let body = part;
|
|
284
|
+
let step = 1;
|
|
285
|
+
const slash = body.indexOf("/");
|
|
286
|
+
if (slash >= 0) {
|
|
287
|
+
const stepText = body.slice(slash + 1);
|
|
288
|
+
body = body.slice(0, slash);
|
|
289
|
+
if (!/^[0-9]+$/.test(stepText))
|
|
290
|
+
return null;
|
|
291
|
+
step = Number(stepText);
|
|
292
|
+
if (step <= 0)
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
let from;
|
|
296
|
+
let to;
|
|
297
|
+
if (body === "*") {
|
|
298
|
+
from = low;
|
|
299
|
+
to = high;
|
|
300
|
+
}
|
|
301
|
+
else if (body.includes("-")) {
|
|
302
|
+
const [a, b] = body.split("-");
|
|
303
|
+
if (a === undefined || b === undefined || !/^[0-9]+$/.test(a) || !/^[0-9]+$/.test(b))
|
|
304
|
+
return null;
|
|
305
|
+
from = Number(a);
|
|
306
|
+
to = Number(b);
|
|
307
|
+
if (from > to)
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
if (!/^[0-9]+$/.test(body))
|
|
312
|
+
return null;
|
|
313
|
+
from = Number(body);
|
|
314
|
+
to = from;
|
|
315
|
+
}
|
|
316
|
+
if (from < low || to > high)
|
|
317
|
+
return null;
|
|
318
|
+
for (let value = from; value <= to; value += step)
|
|
319
|
+
out.add(value);
|
|
320
|
+
}
|
|
321
|
+
return [...out].sort((a, b) => a - b);
|
|
322
|
+
}
|
|
323
|
+
export function notifyParseCron(expression) {
|
|
324
|
+
const fields = expression.trim().split(/\s+/);
|
|
325
|
+
if (fields.length !== 5)
|
|
326
|
+
return null;
|
|
327
|
+
const minutes = parseCronField(fields[0], 0, 59);
|
|
328
|
+
const hours = parseCronField(fields[1], 0, 23);
|
|
329
|
+
const daysOfMonth = parseCronField(fields[2], 1, 31);
|
|
330
|
+
const months = parseCronField(fields[3], 1, 12);
|
|
331
|
+
const rawDow = parseCronField(fields[4], 0, 7);
|
|
332
|
+
if (minutes === null || hours === null || daysOfMonth === null || months === null || rawDow === null)
|
|
333
|
+
return null;
|
|
334
|
+
// 7 and 0 are both Sunday, everywhere cron is spoken.
|
|
335
|
+
const daysOfWeek = [...new Set(rawDow.map((d) => (d === 7 ? 0 : d)))].sort((a, b) => a - b);
|
|
336
|
+
return {
|
|
337
|
+
minutes, hours, daysOfMonth, months, daysOfWeek,
|
|
338
|
+
domRestricted: fields[2] !== "*",
|
|
339
|
+
dowRestricted: fields[4] !== "*",
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function cronDayMatches(spec, year, month, day) {
|
|
343
|
+
if (!spec.months.includes(month))
|
|
344
|
+
return false;
|
|
345
|
+
const dow = notifyWeekday(notifyDaysFromCivil(year, month, day));
|
|
346
|
+
// Cron's classic OR: when BOTH day fields are restricted, either one matching is a match.
|
|
347
|
+
if (spec.domRestricted && spec.dowRestricted) {
|
|
348
|
+
return spec.daysOfMonth.includes(day) || spec.daysOfWeek.includes(dow);
|
|
349
|
+
}
|
|
350
|
+
if (spec.domRestricted)
|
|
351
|
+
return spec.daysOfMonth.includes(day);
|
|
352
|
+
if (spec.dowRestricted)
|
|
353
|
+
return spec.daysOfWeek.includes(dow);
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
// ---------------------------------------------------------------------------------------
|
|
357
|
+
// The trigger resolver
|
|
358
|
+
// ---------------------------------------------------------------------------------------
|
|
359
|
+
export const NOTIFY_REPEAT_UNITS = ["hourly", "daily", "weekly", "monthly", "yearly"];
|
|
360
|
+
/** Only the shape the module accepts on the wire: an epoch-ms number, or an ISO-8601 instant
|
|
361
|
+
* with an explicit zone. A bare local date and time with no zone is refused rather than guessed at, because
|
|
362
|
+
* the guess is exactly the bug this whole file exists to prevent. */
|
|
363
|
+
export function notifyParseInstant(value) {
|
|
364
|
+
if (typeof value === "number")
|
|
365
|
+
return Number.isFinite(value) ? Math.trunc(value) : null;
|
|
366
|
+
const text = value.trim();
|
|
367
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})[Tt ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,3})\d*)?(Z|z|[+-]\d{2}:?\d{2})$/.exec(text);
|
|
368
|
+
if (match === null)
|
|
369
|
+
return null;
|
|
370
|
+
const [, y, mo, d, h, mi, s, ms, zone] = match;
|
|
371
|
+
const year = Number(y);
|
|
372
|
+
const month = Number(mo);
|
|
373
|
+
const day = Number(d);
|
|
374
|
+
const hour = Number(h);
|
|
375
|
+
const minute = Number(mi);
|
|
376
|
+
const second = s === undefined ? 0 : Number(s);
|
|
377
|
+
const milli = ms === undefined ? 0 : Number(ms.padEnd(3, "0"));
|
|
378
|
+
if (month < 1 || month > 12)
|
|
379
|
+
return null;
|
|
380
|
+
if (day < 1 || day > notifyDaysInMonth(year, month))
|
|
381
|
+
return null;
|
|
382
|
+
if (hour > 23 || minute > 59 || second > 60)
|
|
383
|
+
return null;
|
|
384
|
+
let offsetMinutes = 0;
|
|
385
|
+
if (zone !== "Z" && zone !== "z") {
|
|
386
|
+
const sign = zone.startsWith("-") ? -1 : 1;
|
|
387
|
+
const digits = zone.slice(1).replace(":", "");
|
|
388
|
+
offsetMinutes = sign * (Number(digits.slice(0, 2)) * 60 + Number(digits.slice(2, 4)));
|
|
389
|
+
}
|
|
390
|
+
return notifyDaysFromCivil(year, month, day) * DAY_MS
|
|
391
|
+
+ hour * HOUR_MS + minute * MINUTE_MS + second * 1000 + milli
|
|
392
|
+
- offsetMinutes * MINUTE_MS;
|
|
393
|
+
}
|
|
394
|
+
function addMonths(year, month, count) {
|
|
395
|
+
const index = year * 12 + (month - 1) + count;
|
|
396
|
+
return { year: Math.floor(index / 12), month: (index % 12) + 1 };
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Resolve a trigger to its next `count` fire instants.
|
|
400
|
+
*
|
|
401
|
+
* WALL CLOCK VERSUS INTERVAL, the distinction the corpus exists to pin: `hourly` is an
|
|
402
|
+
* INTERVAL - exactly 3600000 ms apart, straight through a DST transition. Every other unit is
|
|
403
|
+
* WALL CLOCK - a 09:00 daily reminder is still 09:00 the day the clocks move, so the gap
|
|
404
|
+
* between those two fires is 23 or 25 hours. Both are correct; they are different.
|
|
405
|
+
*/
|
|
406
|
+
export function notifyFireTimes(trigger, from, zone, count) {
|
|
407
|
+
const rules = zone ?? NOTIFY_UTC;
|
|
408
|
+
const want = Math.max(0, Math.trunc(count));
|
|
409
|
+
const invalid = { ok: false, error: "invalid_trigger" };
|
|
410
|
+
const hasAt = trigger.at !== undefined && trigger.at !== null;
|
|
411
|
+
const hasIn = trigger.in !== undefined && trigger.in !== null;
|
|
412
|
+
const hasCron = typeof trigger.cron === "string" && trigger.cron.trim() !== "";
|
|
413
|
+
const hasRepeats = typeof trigger.repeats === "string" && trigger.repeats.trim() !== "";
|
|
414
|
+
const anchors = (hasAt ? 1 : 0) + (hasIn ? 1 : 0) + (hasCron ? 1 : 0);
|
|
415
|
+
if (anchors !== 1)
|
|
416
|
+
return invalid;
|
|
417
|
+
if (hasCron && hasRepeats)
|
|
418
|
+
return invalid; // a cron already repeats
|
|
419
|
+
if (hasRepeats && !NOTIFY_REPEAT_UNITS.includes(trigger.repeats.trim()))
|
|
420
|
+
return invalid;
|
|
421
|
+
if (hasCron) {
|
|
422
|
+
const spec = notifyParseCron(trigger.cron);
|
|
423
|
+
if (spec === null)
|
|
424
|
+
return invalid;
|
|
425
|
+
return cronFires(spec, from, rules, want);
|
|
426
|
+
}
|
|
427
|
+
let anchor;
|
|
428
|
+
if (hasAt) {
|
|
429
|
+
anchor = notifyParseInstant(trigger.at);
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
const seconds = trigger.in;
|
|
433
|
+
if (typeof seconds !== "number" || !Number.isFinite(seconds) || seconds <= 0)
|
|
434
|
+
return invalid;
|
|
435
|
+
anchor = from + Math.round(seconds * 1000);
|
|
436
|
+
}
|
|
437
|
+
if (anchor === null)
|
|
438
|
+
return invalid;
|
|
439
|
+
if (!hasRepeats) {
|
|
440
|
+
// An `at` already in the past resolves to NOTHING rather than firing immediately. A
|
|
441
|
+
// scheduler that fires a stale reminder the moment the app opens is how a user gets
|
|
442
|
+
// yesterday's alarm at breakfast.
|
|
443
|
+
return { ok: true, kind: "once", fires: anchor > from ? [anchor] : [], exhausted: false };
|
|
444
|
+
}
|
|
445
|
+
return repeatFires(anchor, trigger.repeats.trim(), from, rules, want);
|
|
446
|
+
}
|
|
447
|
+
function cronFires(spec, from, zone, count) {
|
|
448
|
+
const fires = [];
|
|
449
|
+
if (count === 0)
|
|
450
|
+
return { ok: true, kind: "repeating", fires, exhausted: false };
|
|
451
|
+
const startWall = notifyToWall(zone, from);
|
|
452
|
+
const startDay = Math.floor(startWall / DAY_MS);
|
|
453
|
+
for (let offset = 0; offset < NOTIFY_CRON_SEARCH_DAYS; offset += 1) {
|
|
454
|
+
const { year, month, day } = notifyCivilFromDays(startDay + offset);
|
|
455
|
+
if (!cronDayMatches(spec, year, month, day))
|
|
456
|
+
continue;
|
|
457
|
+
for (const hour of spec.hours) {
|
|
458
|
+
for (const minute of spec.minutes) {
|
|
459
|
+
const wall = notifyWallOf({ year, month, day, hour, minute });
|
|
460
|
+
if (wall <= startWall)
|
|
461
|
+
continue;
|
|
462
|
+
const instant = notifyFromWall(zone, wall);
|
|
463
|
+
if (instant === null || instant <= from)
|
|
464
|
+
continue;
|
|
465
|
+
// The gap rule can map two distinct wall times onto the same instant (02:00 and 02:30
|
|
466
|
+
// both become 03:00 on the spring-forward day). One fire, not two.
|
|
467
|
+
if (fires.length > 0 && instant <= fires[fires.length - 1])
|
|
468
|
+
continue;
|
|
469
|
+
fires.push(instant);
|
|
470
|
+
if (fires.length >= count)
|
|
471
|
+
return { ok: true, kind: "repeating", fires, exhausted: false };
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return { ok: true, kind: "repeating", fires, exhausted: true };
|
|
476
|
+
}
|
|
477
|
+
function repeatFires(anchor, unit, from, zone, count) {
|
|
478
|
+
const fires = [];
|
|
479
|
+
if (count === 0)
|
|
480
|
+
return { ok: true, kind: "repeating", fires, exhausted: false };
|
|
481
|
+
if (unit === "hourly") {
|
|
482
|
+
let instant = anchor;
|
|
483
|
+
// Skip forward in whole hours rather than looping one at a time from a distant anchor.
|
|
484
|
+
if (instant <= from) {
|
|
485
|
+
const steps = Math.floor((from - instant) / HOUR_MS) + 1;
|
|
486
|
+
instant += steps * HOUR_MS;
|
|
487
|
+
}
|
|
488
|
+
while (fires.length < count) {
|
|
489
|
+
fires.push(instant);
|
|
490
|
+
instant += HOUR_MS;
|
|
491
|
+
}
|
|
492
|
+
return { ok: true, kind: "repeating", fires, exhausted: false };
|
|
493
|
+
}
|
|
494
|
+
const base = notifyCivilOf(notifyToWall(zone, anchor));
|
|
495
|
+
const baseDays = notifyDaysFromCivil(base.year, base.month, base.day);
|
|
496
|
+
let step = 0;
|
|
497
|
+
let guard = 0;
|
|
498
|
+
const guardLimit = unit === "yearly" ? 4000 : unit === "monthly" ? 4000 : NOTIFY_CRON_SEARCH_DAYS * 2;
|
|
499
|
+
while (fires.length < count && guard < guardLimit) {
|
|
500
|
+
guard += 1;
|
|
501
|
+
let year = base.year;
|
|
502
|
+
let month = base.month;
|
|
503
|
+
let day = base.day;
|
|
504
|
+
if (unit === "daily" || unit === "weekly") {
|
|
505
|
+
const days = baseDays + step * (unit === "weekly" ? 7 : 1);
|
|
506
|
+
({ year, month, day } = notifyCivilFromDays(days));
|
|
507
|
+
}
|
|
508
|
+
else if (unit === "monthly") {
|
|
509
|
+
({ year, month } = addMonths(base.year, base.month, step));
|
|
510
|
+
day = base.day;
|
|
511
|
+
// SKIP, never clamp: "the 31st" means the 31st. Clamping to the 30th silently invents a
|
|
512
|
+
// fire the author never asked for, and it is indistinguishable from a bug in February.
|
|
513
|
+
if (day > notifyDaysInMonth(year, month)) {
|
|
514
|
+
step += 1;
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
year = base.year + step;
|
|
520
|
+
day = base.day;
|
|
521
|
+
if (day > notifyDaysInMonth(year, month)) {
|
|
522
|
+
step += 1;
|
|
523
|
+
continue;
|
|
524
|
+
} // 29 February
|
|
525
|
+
}
|
|
526
|
+
step += 1;
|
|
527
|
+
const instant = notifyFromWall(zone, notifyWallOf({ year, month, day, hour: base.hour, minute: base.minute }));
|
|
528
|
+
if (instant === null || instant <= from)
|
|
529
|
+
continue;
|
|
530
|
+
if (fires.length > 0 && instant <= fires[fires.length - 1])
|
|
531
|
+
continue;
|
|
532
|
+
fires.push(instant);
|
|
533
|
+
}
|
|
534
|
+
return { ok: true, kind: "repeating", fires, exhausted: fires.length < count };
|
|
535
|
+
}
|
|
536
|
+
/** Six words, exact case. `android` is the real NotificationManager constant; `ios` is the
|
|
537
|
+
* UNNotificationInterruptionLevel the same intent maps to. `critical` is deliberately absent
|
|
538
|
+
* from the iOS column: it needs an Apple entitlement, and a channel word must never be the
|
|
539
|
+
* thing that silently asks for one. */
|
|
540
|
+
export const NOTIFY_IMPORTANCE = [
|
|
541
|
+
{ word: "none", android: 0, ios: "passive", headsUp: false, sound: false },
|
|
542
|
+
{ word: "min", android: 1, ios: "passive", headsUp: false, sound: false },
|
|
543
|
+
{ word: "low", android: 2, ios: "passive", headsUp: false, sound: false },
|
|
544
|
+
{ word: "default", android: 3, ios: "active", headsUp: false, sound: true },
|
|
545
|
+
{ word: "high", android: 4, ios: "timeSensitive", headsUp: true, sound: true },
|
|
546
|
+
{ word: "max", android: 5, ios: "timeSensitive", headsUp: true, sound: true },
|
|
547
|
+
];
|
|
548
|
+
export const NOTIFY_DEFAULT_IMPORTANCE = "default";
|
|
549
|
+
/** Channels arrived in Android 8. Below it a channel id is meaningless, not an error. */
|
|
550
|
+
export const NOTIFY_ANDROID_CHANNEL_SDK = 26;
|
|
551
|
+
export function notifyImportance(word) {
|
|
552
|
+
const wanted = (word ?? "").trim() === "" ? NOTIFY_DEFAULT_IMPORTANCE : (word ?? "").trim();
|
|
553
|
+
const found = NOTIFY_IMPORTANCE.find((entry) => entry.word === wanted);
|
|
554
|
+
return found === undefined ? { ok: false, error: "invalid_argument" } : { ok: true, value: found };
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* What a `channels.set` will ACTUALLY produce.
|
|
558
|
+
*
|
|
559
|
+
* THE RULE EVERY LIBRARY GETS WRONG: once a channel exists, Android lets the app LOWER its
|
|
560
|
+
* importance and silently ignores every attempt to raise it, and it remembers a user's own
|
|
561
|
+
* choice forever - deleting and recreating the id does not reset it. So this is not an update,
|
|
562
|
+
* it is a negotiation, and the answer says what the channel will be rather than what was asked
|
|
563
|
+
* for. `lockedByUser` is what a settings screen needs in order to say "you turned this down"
|
|
564
|
+
* instead of rendering a control that does nothing.
|
|
565
|
+
*/
|
|
566
|
+
export function notifyChannelFold(existing, requested) {
|
|
567
|
+
const resolved = notifyImportance(requested);
|
|
568
|
+
if (resolved.ok !== true)
|
|
569
|
+
return { ok: false, error: "invalid_argument" };
|
|
570
|
+
const wanted = resolved.value;
|
|
571
|
+
if (existing === null || existing === undefined) {
|
|
572
|
+
return { ok: true, importance: wanted.word, created: true, changed: true, lockedByUser: false, blocked: false };
|
|
573
|
+
}
|
|
574
|
+
const current = notifyImportance(existing.importance);
|
|
575
|
+
const held = current.ok === true ? current.value : NOTIFY_IMPORTANCE[3];
|
|
576
|
+
const lockedByUser = existing.userSet === true;
|
|
577
|
+
const blocked = existing.blocked === true;
|
|
578
|
+
if (lockedByUser || wanted.android >= held.android) {
|
|
579
|
+
return { ok: true, importance: held.word, created: false, changed: false, lockedByUser, blocked };
|
|
580
|
+
}
|
|
581
|
+
return { ok: true, importance: wanted.word, created: false, changed: true, lockedByUser, blocked };
|
|
582
|
+
}
|
|
583
|
+
/** The module's own channel, created at first use so that an app which never thinks about
|
|
584
|
+
* channels still works. */
|
|
585
|
+
export const NOTIFY_DEFAULT_CHANNEL = "default";
|
|
586
|
+
/**
|
|
587
|
+
* Can this notification be posted.
|
|
588
|
+
*
|
|
589
|
+
* On Android 8+ a post to a channel that was never created is DROPPED BY THE OS - no
|
|
590
|
+
* exception, no log line, no callback. That is the number-one cause of "push does not
|
|
591
|
+
* arrive". Refuse first, and NAME THE ID.
|
|
592
|
+
*/
|
|
593
|
+
export function notifyChannelRequired(platform, sdk, channel, known) {
|
|
594
|
+
if (platform !== "android" || sdk < NOTIFY_ANDROID_CHANNEL_SDK)
|
|
595
|
+
return { ok: true, channel: null };
|
|
596
|
+
const id = (channel ?? "").trim();
|
|
597
|
+
if (id === "")
|
|
598
|
+
return { ok: true, channel: NOTIFY_DEFAULT_CHANNEL };
|
|
599
|
+
if (known.includes(id))
|
|
600
|
+
return { ok: true, channel: id };
|
|
601
|
+
return { ok: false, error: "channel_required", channel: id };
|
|
602
|
+
}
|
|
603
|
+
// ---------------------------------------------------------------------------------------
|
|
604
|
+
// Foreground presentation
|
|
605
|
+
// ---------------------------------------------------------------------------------------
|
|
606
|
+
/** The four words, canonical order - which is the order they are reported in, never sorted. */
|
|
607
|
+
export const NOTIFY_PRESENTATION_WORDS = ["alert", "sound", "badge", "list"];
|
|
608
|
+
/** `banner` is what the platforms call it in their own settings UI. */
|
|
609
|
+
export const NOTIFY_PRESENTATION_ALIASES = { banner: "alert" };
|
|
610
|
+
/**
|
|
611
|
+
* What a notification does while the app is open.
|
|
612
|
+
*
|
|
613
|
+
* THE DEFAULT IS NOTHING, on every platform, and it surprises every author. iOS makes it a
|
|
614
|
+
* delegate callback nobody implements; Android makes it a channel-importance question; the
|
|
615
|
+
* browser shows the notification but the page usually never hears about it. One word decides
|
|
616
|
+
* it everywhere.
|
|
617
|
+
*/
|
|
618
|
+
export function notifyPresentation(configured, claimed, platform, importance) {
|
|
619
|
+
const words = [];
|
|
620
|
+
for (const raw of configured ?? []) {
|
|
621
|
+
const word = NOTIFY_PRESENTATION_ALIASES[raw] ?? raw;
|
|
622
|
+
if (!NOTIFY_PRESENTATION_WORDS.includes(word))
|
|
623
|
+
return { ok: false, error: "invalid_argument" };
|
|
624
|
+
if (!words.includes(word))
|
|
625
|
+
words.push(word);
|
|
626
|
+
}
|
|
627
|
+
// A CLAIMED notify.received suppresses the system presentation, whatever was configured -
|
|
628
|
+
// that is the entire point of a claimable hook.
|
|
629
|
+
if (claimed) {
|
|
630
|
+
return { ok: true, present: [], suppressed: true, headsUp: false, dropped: [], degraded: [] };
|
|
631
|
+
}
|
|
632
|
+
if (platform === "android") {
|
|
633
|
+
// The OS posts it regardless: `list` is implicit and cannot be configured away. A heads-up
|
|
634
|
+
// needs BOTH the alert word and a high-importance channel, and the channel wins.
|
|
635
|
+
const present = NOTIFY_PRESENTATION_WORDS.filter((w) => words.includes(w) || w === "list");
|
|
636
|
+
const resolved = notifyImportance(importance);
|
|
637
|
+
const level = resolved.ok === true ? resolved.value : NOTIFY_IMPORTANCE[3];
|
|
638
|
+
const headsUp = words.includes("alert") && level.headsUp;
|
|
639
|
+
const degraded = words.includes("alert") && !level.headsUp ? ["alert"] : [];
|
|
640
|
+
return { ok: true, present, suppressed: false, headsUp, dropped: [], degraded };
|
|
641
|
+
}
|
|
642
|
+
if (platform === "web") {
|
|
643
|
+
// There is no notification list to land in. Say so rather than accepting the word.
|
|
644
|
+
const dropped = words.includes("list") ? ["list"] : [];
|
|
645
|
+
const present = NOTIFY_PRESENTATION_WORDS.filter((w) => words.includes(w) && w !== "list");
|
|
646
|
+
return { ok: true, present, suppressed: false, headsUp: present.includes("alert"), dropped, degraded: [] };
|
|
647
|
+
}
|
|
648
|
+
const present = NOTIFY_PRESENTATION_WORDS.filter((w) => words.includes(w));
|
|
649
|
+
return { ok: true, present, suppressed: false, headsUp: present.includes("alert"), dropped: [], degraded: [] };
|
|
650
|
+
}
|
|
651
|
+
// ---------------------------------------------------------------------------------------
|
|
652
|
+
// Tap routing
|
|
653
|
+
// ---------------------------------------------------------------------------------------
|
|
654
|
+
/** The platform constants for "the user tapped the notification body". Normalised AWAY, so
|
|
655
|
+
* that `if (payload.actionId)` means what it reads like. */
|
|
656
|
+
export const NOTIFY_DEFAULT_ACTION_IDS = [
|
|
657
|
+
"com.apple.UNNotificationDefaultActionIdentifier", "android.intent.action.MAIN", "default",
|
|
658
|
+
];
|
|
659
|
+
export const NOTIFY_DISMISS_ACTION_IDS = [
|
|
660
|
+
"com.apple.UNNotificationDismissActionIdentifier",
|
|
661
|
+
];
|
|
662
|
+
/** One tap arrives in four envelope shapes - plain, action button, text-input action, and a
|
|
663
|
+
* COLD START where the app was not running. All four end up here, or an app routes three of
|
|
664
|
+
* them and loses the fourth. */
|
|
665
|
+
export function notifyOpenPayload(raw, coldStart) {
|
|
666
|
+
const id = typeof raw.id === "string" ? raw.id : "";
|
|
667
|
+
const actionId = typeof raw.actionId === "string" ? raw.actionId : "";
|
|
668
|
+
if (NOTIFY_DISMISS_ACTION_IDS.includes(actionId)) {
|
|
669
|
+
return { kind: "dismissed", id, data: {}, coldStart };
|
|
670
|
+
}
|
|
671
|
+
const payload = {
|
|
672
|
+
kind: "opened", id,
|
|
673
|
+
data: (raw.data ?? {}),
|
|
674
|
+
coldStart,
|
|
675
|
+
};
|
|
676
|
+
const named = actionId !== "" && !NOTIFY_DEFAULT_ACTION_IDS.includes(actionId);
|
|
677
|
+
// An EMPTY reply is still a reply, so `userText` rides whenever the platform gave us one.
|
|
678
|
+
if (named && typeof raw.userText === "string") {
|
|
679
|
+
return { ...payload, actionId, userText: raw.userText };
|
|
680
|
+
}
|
|
681
|
+
if (named)
|
|
682
|
+
return { ...payload, actionId };
|
|
683
|
+
return payload;
|
|
684
|
+
}
|
|
685
|
+
export const NOTIFY_PATH_BYTES = 8192;
|
|
686
|
+
export const NOTIFY_URL_BYTES = 8192;
|
|
687
|
+
export const NOTIFY_EVENT_BYTES = 65536;
|
|
688
|
+
function utf8Length(text) {
|
|
689
|
+
let total = 0;
|
|
690
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
691
|
+
const code = text.codePointAt(i);
|
|
692
|
+
if (code > 0xffff) {
|
|
693
|
+
total += 4;
|
|
694
|
+
i += 1;
|
|
695
|
+
}
|
|
696
|
+
else if (code > 0x7ff)
|
|
697
|
+
total += 3;
|
|
698
|
+
else if (code > 0x7f)
|
|
699
|
+
total += 2;
|
|
700
|
+
else
|
|
701
|
+
total += 1;
|
|
702
|
+
}
|
|
703
|
+
return total;
|
|
704
|
+
}
|
|
705
|
+
function hasControlCharacter(text) {
|
|
706
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
707
|
+
const code = text.charCodeAt(i);
|
|
708
|
+
if (code < 0x20 || code === 0x7f)
|
|
709
|
+
return true;
|
|
710
|
+
}
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* The record `Mandatory/PushRouting` already consumes for a VENDOR open, produced for a
|
|
715
|
+
* first-party one.
|
|
716
|
+
*
|
|
717
|
+
* The bounds are restated rather than skipped: a first-party payload must not be the one that
|
|
718
|
+
* gets to bypass the checks a Firebase payload goes through. A field that fails a bound is
|
|
719
|
+
* dropped; the OPEN still happens, because losing the whole event over a bad deep link is a
|
|
720
|
+
* worse failure than losing the deep link.
|
|
721
|
+
*/
|
|
722
|
+
export function notifyRoutingRecord(payload) {
|
|
723
|
+
const data = payload.data ?? {};
|
|
724
|
+
const rawPath = typeof data["path"] === "string" ? data["path"] : "";
|
|
725
|
+
const rawURL = typeof data["url"] === "string" ? data["url"] : "";
|
|
726
|
+
let path = null;
|
|
727
|
+
if (rawPath.startsWith("/") && !rawPath.startsWith("//")
|
|
728
|
+
&& !hasControlCharacter(rawPath) && utf8Length(rawPath) <= NOTIFY_PATH_BYTES) {
|
|
729
|
+
path = rawPath;
|
|
730
|
+
}
|
|
731
|
+
let url = null;
|
|
732
|
+
const lower = rawURL.toLowerCase();
|
|
733
|
+
if ((lower.startsWith("http://") || lower.startsWith("https://"))
|
|
734
|
+
&& !hasControlCharacter(rawURL) && utf8Length(rawURL) <= NOTIFY_URL_BYTES) {
|
|
735
|
+
const authority = rawURL.slice(rawURL.indexOf("://") + 3).split("/")[0] ?? "";
|
|
736
|
+
// Credentials in a notification URL are how a phishing payload borrows an app's trust.
|
|
737
|
+
if (!authority.includes("@"))
|
|
738
|
+
url = rawURL;
|
|
739
|
+
}
|
|
740
|
+
return { path, url };
|
|
741
|
+
}
|
|
742
|
+
export const NOTIFY_RICH_INTERRUPTIONS = ["passive", "active", "time-sensitive", "critical"];
|
|
743
|
+
export const NOTIFY_RICH_MEDIA_TYPES = ["image", "video", "gif"];
|
|
744
|
+
export const NOTIFY_RICH_ALGORITHMS = ["A256GCM"];
|
|
745
|
+
const RICH_LOOPBACK = ["127.0.0.1", "localhost", "10.0.2.2", "[::1]"];
|
|
746
|
+
const richObj = (v) => (typeof v === "object" && v !== null && !Array.isArray(v) ? v : null);
|
|
747
|
+
const richStr = (v) => (typeof v === "string" ? v : "");
|
|
748
|
+
function richHttps(url) { return /^https:\/\/[^\s/]+/.test(url); }
|
|
749
|
+
/** https anywhere; http only to a loopback host, which is how a local server is reached. */
|
|
750
|
+
function richReplyUrl(url) {
|
|
751
|
+
if (richHttps(url))
|
|
752
|
+
return true;
|
|
753
|
+
const m = /^http:\/\/([^/:\s]+|\[[^\]]+\])(:\d+)?(\/|$)/.exec(url);
|
|
754
|
+
return m !== null && RICH_LOOPBACK.includes(m[1]);
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* The plan for a payload whose encrypted part (if any) is already opened. `sounds` is the list
|
|
758
|
+
* of package resource references the project declared as notification sounds. Returns null for
|
|
759
|
+
* anything that is not a version 1 `dsx_notify` payload.
|
|
760
|
+
*/
|
|
761
|
+
export function notifyRichPlan(payload, sounds, reports = []) {
|
|
762
|
+
const p = richObj(payload);
|
|
763
|
+
if (p === null || p["v"] !== 1)
|
|
764
|
+
return null;
|
|
765
|
+
const out = {
|
|
766
|
+
style: "plain", id: richStr(p["id"]), title: richStr(p["title"]), body: richStr(p["body"]),
|
|
767
|
+
subtitle: richStr(p["subtitle"]), person: null, thread: "", group: false, conversationTitle: "",
|
|
768
|
+
interruption: "active", channel: richStr(p["channel"]), sound: "default", media: null, reply: null,
|
|
769
|
+
data: richObj(p["data"]) ?? {}, reports: [...reports],
|
|
770
|
+
};
|
|
771
|
+
const sender = richObj(p["sender"]);
|
|
772
|
+
if (sender !== null && (richStr(sender["id"]) !== "" || richStr(sender["name"]) !== "")) {
|
|
773
|
+
const id = richStr(sender["id"]) || richStr(sender["name"]);
|
|
774
|
+
const avatar = richStr(sender["avatar"]);
|
|
775
|
+
if (avatar !== "" && !richHttps(avatar))
|
|
776
|
+
out.reports.push("avatar_invalid");
|
|
777
|
+
out.person = { id, name: richStr(sender["name"]) || id, avatar: richHttps(avatar) ? avatar : "" };
|
|
778
|
+
}
|
|
779
|
+
const conversation = richObj(p["conversation"]);
|
|
780
|
+
if (conversation !== null) {
|
|
781
|
+
out.thread = richStr(conversation["id"]);
|
|
782
|
+
out.group = conversation["group"] === true;
|
|
783
|
+
out.conversationTitle = richStr(conversation["title"]);
|
|
784
|
+
}
|
|
785
|
+
const media = richObj(p["media"]);
|
|
786
|
+
if (media !== null) {
|
|
787
|
+
const url = richStr(media["url"]);
|
|
788
|
+
if (richHttps(url)) {
|
|
789
|
+
const type = richStr(media["type"]);
|
|
790
|
+
out.media = { url, type: NOTIFY_RICH_MEDIA_TYPES.includes(type) ? type : "image" };
|
|
791
|
+
}
|
|
792
|
+
else {
|
|
793
|
+
out.reports.push("media_invalid");
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
out.style = out.person !== null ? "messaging" : out.media !== null ? "picture" : "plain";
|
|
797
|
+
const interruption = richStr(p["interruption"]);
|
|
798
|
+
if (interruption !== "") {
|
|
799
|
+
if (NOTIFY_RICH_INTERRUPTIONS.includes(interruption))
|
|
800
|
+
out.interruption = interruption;
|
|
801
|
+
else
|
|
802
|
+
out.reports.push("interruption_invalid");
|
|
803
|
+
}
|
|
804
|
+
const sound = richStr(p["sound"]);
|
|
805
|
+
if (sound === "none")
|
|
806
|
+
out.sound = "none";
|
|
807
|
+
else if (sound !== "" && sound !== "default") {
|
|
808
|
+
if (sounds.includes(sound))
|
|
809
|
+
out.sound = sound;
|
|
810
|
+
else
|
|
811
|
+
out.reports.push("sound_undeclared");
|
|
812
|
+
}
|
|
813
|
+
const reply = richObj(p["reply"]);
|
|
814
|
+
if (reply !== null) {
|
|
815
|
+
const url = richStr(reply["url"]);
|
|
816
|
+
const token = richStr(reply["token"]);
|
|
817
|
+
if (richReplyUrl(url) && token !== "") {
|
|
818
|
+
out.reply = { url, token, placeholder: richStr(reply["placeholder"]) || "Reply", label: richStr(reply["label"]) || "Reply" };
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
out.reports.push("reply_invalid");
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return out;
|
|
825
|
+
}
|
|
826
|
+
function richB64(s) {
|
|
827
|
+
try {
|
|
828
|
+
const bin = atob(s);
|
|
829
|
+
const out = new Uint8Array(bin.length);
|
|
830
|
+
for (let i = 0; i < bin.length; i++)
|
|
831
|
+
out[i] = bin.charCodeAt(i);
|
|
832
|
+
return out;
|
|
833
|
+
}
|
|
834
|
+
catch {
|
|
835
|
+
return null;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Open the encrypted part and plan the result. The plaintext fields replace the outer ones; when
|
|
840
|
+
* the key id is unknown, the algorithm unregistered or the tag fails, the outer fields are the
|
|
841
|
+
* fallback and the reason is reported.
|
|
842
|
+
*/
|
|
843
|
+
export async function notifyRichResolve(payload, sounds, keys, open) {
|
|
844
|
+
const p = richObj(payload);
|
|
845
|
+
if (p === null || p["v"] !== 1)
|
|
846
|
+
return null;
|
|
847
|
+
const enc = richObj(p["encrypted"]);
|
|
848
|
+
if (enc === null)
|
|
849
|
+
return notifyRichPlan(p, sounds);
|
|
850
|
+
const outer = { ...p };
|
|
851
|
+
delete outer["encrypted"];
|
|
852
|
+
if (!NOTIFY_RICH_ALGORITHMS.includes(richStr(enc["alg"])))
|
|
853
|
+
return notifyRichPlan(outer, sounds, ["alg_unsupported"]);
|
|
854
|
+
const keyText = keys[richStr(enc["kid"])];
|
|
855
|
+
if (keyText === undefined)
|
|
856
|
+
return notifyRichPlan(outer, sounds, ["key_unknown"]);
|
|
857
|
+
const key = richB64(keyText), iv = richB64(richStr(enc["iv"])), ct = richB64(richStr(enc["ct"]));
|
|
858
|
+
if (key === null || iv === null || ct === null || key.length !== 32 || iv.length !== 12 || ct.length < 16) {
|
|
859
|
+
return notifyRichPlan(outer, sounds, ["decrypt_failed"]);
|
|
860
|
+
}
|
|
861
|
+
const plain = await open(key, iv, ct);
|
|
862
|
+
if (plain === null)
|
|
863
|
+
return notifyRichPlan(outer, sounds, ["decrypt_failed"]);
|
|
864
|
+
let fields = null;
|
|
865
|
+
try {
|
|
866
|
+
fields = richObj(JSON.parse(new TextDecoder().decode(plain)));
|
|
867
|
+
}
|
|
868
|
+
catch {
|
|
869
|
+
fields = null;
|
|
870
|
+
}
|
|
871
|
+
if (fields === null)
|
|
872
|
+
return notifyRichPlan(outer, sounds, ["decrypt_failed"]);
|
|
873
|
+
return notifyRichPlan({ ...outer, ...fields, v: 1, id: outer["id"] }, sounds);
|
|
874
|
+
}
|
|
875
|
+
/** OneSignal's APNs shape (aps alert, custom.i, custom.a, att) as a `dsx_notify` payload, so one
|
|
876
|
+
* extension renders both. Null when the push carries no OneSignal `custom` block. */
|
|
877
|
+
export function notifyRichFromOneSignal(raw) {
|
|
878
|
+
const r = richObj(raw);
|
|
879
|
+
const custom = r === null ? null : richObj(r["custom"]);
|
|
880
|
+
if (r === null || custom === null)
|
|
881
|
+
return null;
|
|
882
|
+
const aps = richObj(r["aps"]) ?? {};
|
|
883
|
+
const alertObj = richObj(aps["alert"]);
|
|
884
|
+
const out = {
|
|
885
|
+
v: 1, id: richStr(custom["i"]),
|
|
886
|
+
title: alertObj === null ? "" : richStr(alertObj["title"]),
|
|
887
|
+
subtitle: alertObj === null ? "" : richStr(alertObj["subtitle"]),
|
|
888
|
+
body: alertObj === null ? richStr(aps["alert"]) : richStr(alertObj["body"]),
|
|
889
|
+
};
|
|
890
|
+
const thread = richStr(aps["thread-id"]);
|
|
891
|
+
if (thread !== "")
|
|
892
|
+
out["conversation"] = { id: thread };
|
|
893
|
+
const att = richObj(r["att"]);
|
|
894
|
+
const first = att === null ? "" : richStr(att["id"]) || richStr(Object.values(att)[0]);
|
|
895
|
+
if (first !== "")
|
|
896
|
+
out["media"] = { url: first, type: "image" };
|
|
897
|
+
out["data"] = richObj(custom["a"]) ?? {};
|
|
898
|
+
return out;
|
|
899
|
+
}
|
|
900
|
+
// ── notification sounds (OpenSource/Conformance/notify/sounds.json) ─────────────────────────
|
|
901
|
+
//
|
|
902
|
+
// Core/Notify/Modules/Sounds ships the app's own sound files: flat at the iOS bundle root and as
|
|
903
|
+
// Android raw resources. These three rules are the whole law; every runner implements the same
|
|
904
|
+
// ones, and prepare_modules_android (package_sound_raw.rb) applies `resources` at build time.
|
|
905
|
+
/** Java keywords and literals: R.raw.<name> must compile, so none of them is a resource name. */
|
|
906
|
+
export const NOTIFY_SOUND_RESERVED = [
|
|
907
|
+
"abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const",
|
|
908
|
+
"continue", "default", "do", "double", "else", "enum", "extends", "false", "final", "finally",
|
|
909
|
+
"float", "for", "goto", "if", "implements", "import", "instanceof", "int", "interface", "long",
|
|
910
|
+
"native", "new", "null", "package", "private", "protected", "public", "return", "short",
|
|
911
|
+
"static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws",
|
|
912
|
+
"transient", "true", "try", "void", "volatile", "while",
|
|
913
|
+
];
|
|
914
|
+
/** A file name as its Android raw resource name (the Core/Alarms lookup rule), or null. */
|
|
915
|
+
export function notifySoundResourceName(file) {
|
|
916
|
+
const dot = file.lastIndexOf(".");
|
|
917
|
+
const stem = (dot < 0 ? file : file.slice(0, dot)).toLowerCase().replace(/[^a-z0-9_]/gu, "_"); // per code point, like Kotlin, Swift and Ruby
|
|
918
|
+
if (!/^[a-z_][a-z0-9_]*$/.test(stem))
|
|
919
|
+
return null;
|
|
920
|
+
return NOTIFY_SOUND_RESERVED.includes(stem) ? null : stem;
|
|
921
|
+
}
|
|
922
|
+
const byCodePoint = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
923
|
+
/** The build-time plan over one folder set: every file to its resource, refusals by name. */
|
|
924
|
+
export function notifySoundResources(files) {
|
|
925
|
+
const invalid = [];
|
|
926
|
+
const groups = new Map();
|
|
927
|
+
for (const file of files) {
|
|
928
|
+
const resource = notifySoundResourceName(file);
|
|
929
|
+
if (resource === null) {
|
|
930
|
+
invalid.push(file);
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
groups.set(resource, [...(groups.get(resource) ?? []), file]);
|
|
934
|
+
}
|
|
935
|
+
const resources = [];
|
|
936
|
+
const collisions = [];
|
|
937
|
+
for (const resource of [...groups.keys()].sort(byCodePoint)) {
|
|
938
|
+
const owners = [...groups.get(resource)].sort(byCodePoint);
|
|
939
|
+
if (owners.length === 1)
|
|
940
|
+
resources.push({ file: owners[0], resource });
|
|
941
|
+
else
|
|
942
|
+
collisions.push({ code: "sound_collision", resource, files: owners });
|
|
943
|
+
}
|
|
944
|
+
const errors = [
|
|
945
|
+
...invalid.sort(byCodePoint).map((file) => ({ code: "sound_name_invalid", resource: null, files: [file] })),
|
|
946
|
+
...collisions,
|
|
947
|
+
];
|
|
948
|
+
return { ok: errors.length === 0, resources, errors };
|
|
949
|
+
}
|
|
950
|
+
/** What a `sound` argument plays: declared package reference, then a shipped raw resource. */
|
|
951
|
+
export function notifySoundSource(sound, declared, rawShipped) {
|
|
952
|
+
const none = { resource: null, ref: null, iosFile: null, report: null };
|
|
953
|
+
if (sound === null || sound === undefined || sound === "default")
|
|
954
|
+
return { kind: "default", ...none };
|
|
955
|
+
if (sound === "")
|
|
956
|
+
return { kind: "silent", ...none };
|
|
957
|
+
if (declared.includes(sound))
|
|
958
|
+
return { kind: "package", ...none, ref: sound, iosFile: sound.split("/").join("--") };
|
|
959
|
+
const resource = notifySoundResourceName(sound);
|
|
960
|
+
if (resource !== null && rawShipped(resource))
|
|
961
|
+
return { kind: "raw", ...none, resource, iosFile: sound };
|
|
962
|
+
return { kind: "default", ...none, report: "sound_undeclared" };
|
|
963
|
+
}
|
|
964
|
+
//# sourceMappingURL=notify.js.map
|