@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/dataviz.js
ADDED
|
@@ -0,0 +1,956 @@
|
|
|
1
|
+
//
|
|
2
|
+
// dataviz.ts — the shared `<chart>` / `<map>` numeric core: scale domains and ticks, mark
|
|
3
|
+
// geometry, interaction payload arithmetic, the accessible table, web-mercator camera maths
|
|
4
|
+
// and pin clustering. The law is the corpus, OpenSource/Conformance/dataviz/ (six files —
|
|
5
|
+
// scales · marks · interaction · a11y · camera · cluster; parity/U09-dataviz.md); the Kotlin
|
|
6
|
+
// twin is :core Dataviz.kt and the Swift twin is Engine/Swift/Dataviz.swift, and all three run
|
|
7
|
+
// the SAME files.
|
|
8
|
+
//
|
|
9
|
+
// Everything platform-shaped lives OUTSIDE this file. Swift Charts, the Compose canvas and
|
|
10
|
+
// the DOM renderer paint pixels three different ways; what they may NOT do is disagree on
|
|
11
|
+
// where a datum lands, how many gridlines there are, which pins share a cluster, or what a
|
|
12
|
+
// screen reader is told. Keeping the DECISION separate from the PAINTING is what lets one
|
|
13
|
+
// corpus judge three renderers.
|
|
14
|
+
//
|
|
15
|
+
// Two rules that look like fussiness and are not:
|
|
16
|
+
// * the decimal exponent and powers of ten are integer LOOPS, never log10/pow — libm
|
|
17
|
+
// rounding differs between platforms and floor(log10(1000)) is allowed to come back 2,
|
|
18
|
+
// which silently moves every tick on one renderer only;
|
|
19
|
+
// * the cluster level is floor(zoom), never zoom — a continuous grid slides continuously,
|
|
20
|
+
// so markers visibly flicker while the user pinches.
|
|
21
|
+
//
|
|
22
|
+
// ── scales: the arithmetic before a single pixel ────────────────────────────────────────
|
|
23
|
+
/**
|
|
24
|
+
* floor(log10(|x|)), by an integer loop.
|
|
25
|
+
*
|
|
26
|
+
* Never `Math.log10` + `Math.floor`: libm is entitled to return 2.9999999999999996 for
|
|
27
|
+
* log10(1000), and one renderer's axis then steps differently from the other two. Zero has
|
|
28
|
+
* no exponent; it answers 0 so callers never see a NaN.
|
|
29
|
+
*/
|
|
30
|
+
export function decimalExponent(x) {
|
|
31
|
+
let a = Math.abs(x);
|
|
32
|
+
if (a === 0 || !Number.isFinite(a))
|
|
33
|
+
return 0;
|
|
34
|
+
let e = 0;
|
|
35
|
+
while (a >= 10) {
|
|
36
|
+
a /= 10;
|
|
37
|
+
e += 1;
|
|
38
|
+
}
|
|
39
|
+
while (a < 1) {
|
|
40
|
+
a *= 10;
|
|
41
|
+
e -= 1;
|
|
42
|
+
}
|
|
43
|
+
return e;
|
|
44
|
+
}
|
|
45
|
+
/** 10^n, by an integer loop, for the same reason `decimalExponent` is one. */
|
|
46
|
+
export function powerOfTen(n) {
|
|
47
|
+
const k = Math.abs(Math.trunc(n));
|
|
48
|
+
let r = 1;
|
|
49
|
+
for (let i = 0; i < k; i += 1)
|
|
50
|
+
r *= 10;
|
|
51
|
+
return n < 0 ? 1 / r : r;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Heckbert's nice number: the closest "human" number to `x` — 1, 2, 5 or 10 times a power
|
|
55
|
+
* of ten. `round` picks the nearest; otherwise it rounds UP, which is what an axis range
|
|
56
|
+
* wants so the data always fits inside it.
|
|
57
|
+
*/
|
|
58
|
+
export function niceNumber(x, round) {
|
|
59
|
+
if (!(x > 0))
|
|
60
|
+
return 0;
|
|
61
|
+
const exp = decimalExponent(x);
|
|
62
|
+
const f = x / powerOfTen(exp);
|
|
63
|
+
let nf;
|
|
64
|
+
if (round)
|
|
65
|
+
nf = f < 1.5 ? 1 : f < 3 ? 2 : f < 7 ? 5 : 10;
|
|
66
|
+
else
|
|
67
|
+
nf = f <= 1 ? 1 : f <= 2 ? 2 : f <= 5 ? 5 : 10;
|
|
68
|
+
return nf * powerOfTen(exp);
|
|
69
|
+
}
|
|
70
|
+
/** The padding a zero-span domain gets before it is made nice, so one datum is not a line. */
|
|
71
|
+
const ZERO_SPAN_PAD = 0.5;
|
|
72
|
+
/**
|
|
73
|
+
* Heckbert loose labelling: the domain EXTENDS to the nice bounds rather than the ticks
|
|
74
|
+
* shrinking inside it, so the first and last tick are always the axis ends. Reversed bounds
|
|
75
|
+
* are ordered first; a zero span is padded before it is made nice.
|
|
76
|
+
*
|
|
77
|
+
* Ticks are `lo + i * step`, never an accumulator — accumulating drifts, and a tick that
|
|
78
|
+
* reads 5.000000000000001 on one renderer and 5 on another is a diff nobody can explain.
|
|
79
|
+
*/
|
|
80
|
+
export function niceLinearDomain(lo, hi, count) {
|
|
81
|
+
let low = Math.min(lo, hi);
|
|
82
|
+
let high = Math.max(lo, hi);
|
|
83
|
+
if (low === high) {
|
|
84
|
+
low -= ZERO_SPAN_PAD;
|
|
85
|
+
high += ZERO_SPAN_PAD;
|
|
86
|
+
}
|
|
87
|
+
const n = Math.max(2, Math.trunc(count));
|
|
88
|
+
const range = niceNumber(high - low, false);
|
|
89
|
+
const step = niceNumber(range / (n - 1), true);
|
|
90
|
+
if (!(step > 0))
|
|
91
|
+
return { lo: low, hi: high, step: 0, ticks: [low] };
|
|
92
|
+
const gLo = Math.floor(low / step) * step;
|
|
93
|
+
const gHi = Math.ceil(high / step) * step;
|
|
94
|
+
const steps = Math.max(0, Math.round((gHi - gLo) / step));
|
|
95
|
+
const ticks = [];
|
|
96
|
+
for (let i = 0; i <= steps; i += 1)
|
|
97
|
+
ticks.push(gLo + i * step);
|
|
98
|
+
return { lo: gLo, hi: gHi, step, ticks };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The axis a series actually gets. `includeZero` is the bar/area rule (a bar that does not
|
|
102
|
+
* start at zero lies about its length); a line does not invent a zero it was never given.
|
|
103
|
+
* An empty series is a unit domain, not a NaN.
|
|
104
|
+
*/
|
|
105
|
+
export function valueDomain(values, includeZero, count) {
|
|
106
|
+
if (values.length === 0)
|
|
107
|
+
return niceLinearDomain(0, 1, count);
|
|
108
|
+
let lo = values[0];
|
|
109
|
+
let hi = values[0];
|
|
110
|
+
for (const v of values) {
|
|
111
|
+
if (v < lo)
|
|
112
|
+
lo = v;
|
|
113
|
+
if (v > hi)
|
|
114
|
+
hi = v;
|
|
115
|
+
}
|
|
116
|
+
if (includeZero) {
|
|
117
|
+
lo = Math.min(lo, 0);
|
|
118
|
+
hi = Math.max(hi, 0);
|
|
119
|
+
}
|
|
120
|
+
return niceLinearDomain(lo, hi, count);
|
|
121
|
+
}
|
|
122
|
+
/** Map a value onto a range. An inverted range is the y axis; a degenerate domain lands mid. */
|
|
123
|
+
export function linearScale(v, domain, range) {
|
|
124
|
+
if (domain[1] === domain[0])
|
|
125
|
+
return (range[0] + range[1]) / 2;
|
|
126
|
+
return range[0] + ((v - domain[0]) / (domain[1] - domain[0])) * (range[1] - range[0]);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The d3 band scale, verbatim: `step = span / (count - paddingInner + 2 * paddingOuter)`,
|
|
130
|
+
* `bandwidth = step * (1 - paddingInner)`, and the leftover centred by `align`.
|
|
131
|
+
*/
|
|
132
|
+
export function bandScale(count, range, paddingInner, paddingOuter, align) {
|
|
133
|
+
const span = range[1] - range[0];
|
|
134
|
+
if (count <= 0) {
|
|
135
|
+
return { step: 0, bandwidth: 0, start: range[0], positions: [], centers: [] };
|
|
136
|
+
}
|
|
137
|
+
const divisor = Math.max(1e-12, count - paddingInner + 2 * paddingOuter);
|
|
138
|
+
const step = span / divisor;
|
|
139
|
+
const bandwidth = step * (1 - paddingInner);
|
|
140
|
+
const start = range[0] + (span - step * (count - paddingInner)) * align;
|
|
141
|
+
const positions = [];
|
|
142
|
+
const centers = [];
|
|
143
|
+
for (let i = 0; i < count; i += 1) {
|
|
144
|
+
const p = start + step * i;
|
|
145
|
+
positions.push(p);
|
|
146
|
+
centers.push(p + bandwidth / 2);
|
|
147
|
+
}
|
|
148
|
+
return { step, bandwidth, start, positions, centers };
|
|
149
|
+
}
|
|
150
|
+
/** The decade a value's upper bound rounds up to (exact powers of ten stay put). */
|
|
151
|
+
function decimalExponentCeiling(x) {
|
|
152
|
+
const e = decimalExponent(x);
|
|
153
|
+
return powerOfTen(e) === x ? e : e + 1;
|
|
154
|
+
}
|
|
155
|
+
/** The refusal a log axis reports rather than clamping a non-positive bound into existence. */
|
|
156
|
+
export const LOG_NONPOSITIVE_DOMAIN = "nonpositive_domain";
|
|
157
|
+
/**
|
|
158
|
+
* The log decade ladder. The domain extends to whole decades; two decades or fewer get the
|
|
159
|
+
* 1-2-5 ladder inside each, more get plain decades on a stride that keeps the label count
|
|
160
|
+
* near `maxTicks`.
|
|
161
|
+
*
|
|
162
|
+
* A non-positive bound is a TYPED REFUSAL, never a silent clamp to some epsilon: a log axis
|
|
163
|
+
* over data containing a zero is an authoring mistake and the author has to see it.
|
|
164
|
+
*/
|
|
165
|
+
export function logDomain(lo, hi, maxTicks) {
|
|
166
|
+
if (!(lo > 0) || !(hi > 0)) {
|
|
167
|
+
return { valid: false, reason: LOG_NONPOSITIVE_DOMAIN, lo: 0, hi: 0, ticks: [] };
|
|
168
|
+
}
|
|
169
|
+
const low = Math.min(lo, hi);
|
|
170
|
+
const high = Math.max(lo, hi);
|
|
171
|
+
const loDec = decimalExponent(low);
|
|
172
|
+
let hiDec = decimalExponentCeiling(high);
|
|
173
|
+
if (hiDec <= loDec)
|
|
174
|
+
hiDec = loDec + 1;
|
|
175
|
+
const decades = hiDec - loDec;
|
|
176
|
+
const ticks = [];
|
|
177
|
+
if (decades <= 2) {
|
|
178
|
+
for (let d = loDec; d < hiDec; d += 1) {
|
|
179
|
+
const base = powerOfTen(d);
|
|
180
|
+
ticks.push(base, 2 * base, 5 * base);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const stride = Math.max(1, Math.ceil(decades / Math.max(1, Math.trunc(maxTicks))));
|
|
185
|
+
for (let d = loDec; d < hiDec; d += stride)
|
|
186
|
+
ticks.push(powerOfTen(d));
|
|
187
|
+
}
|
|
188
|
+
ticks.push(powerOfTen(hiDec));
|
|
189
|
+
return { valid: true, reason: "", lo: powerOfTen(loDec), hi: powerOfTen(hiDec), ticks };
|
|
190
|
+
}
|
|
191
|
+
/** Position on a log axis. A non-positive value pins to the range start rather than -Inf. */
|
|
192
|
+
export function logScale(v, domain, range) {
|
|
193
|
+
if (!(domain[0] > 0) || !(domain[1] > 0) || domain[0] === domain[1])
|
|
194
|
+
return range[0];
|
|
195
|
+
if (!(v > 0))
|
|
196
|
+
return range[0];
|
|
197
|
+
const t = (Math.log(v) - Math.log(domain[0])) / (Math.log(domain[1]) - Math.log(domain[0]));
|
|
198
|
+
return range[0] + t * (range[1] - range[0]);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The fixed-duration ladder, in seconds. Every entry is a duration a human names — a
|
|
202
|
+
* quarter minute, a quarter hour, six hours, a week. No months and no years: a month is not
|
|
203
|
+
* a duration, and a ladder that pretends otherwise ticks 28, 30 or 31 days apart depending
|
|
204
|
+
* on where the window happens to start.
|
|
205
|
+
*/
|
|
206
|
+
export const TIME_TICK_LADDER = [
|
|
207
|
+
1, 2, 5, 10, 15, 30,
|
|
208
|
+
60, 120, 300, 600, 900, 1800,
|
|
209
|
+
3600, 7200, 10800, 21600, 43200,
|
|
210
|
+
86400, 172800, 604800,
|
|
211
|
+
];
|
|
212
|
+
const SECONDS_PER_DAY = 86400;
|
|
213
|
+
/**
|
|
214
|
+
* Ticks on a time axis, in epoch seconds. Ticks snap to the STEP GRID rather than to the
|
|
215
|
+
* window start, so a chart of the last hour puts labels on the quarter hours instead of on
|
|
216
|
+
* whatever second the user opened the screen, and they stay INSIDE the domain.
|
|
217
|
+
*/
|
|
218
|
+
export function timeTicks(lo, hi, count) {
|
|
219
|
+
const low = Math.min(lo, hi);
|
|
220
|
+
const high = Math.max(lo, hi);
|
|
221
|
+
if (low === high)
|
|
222
|
+
return { step: 1, ticks: [low] };
|
|
223
|
+
const n = Math.max(2, Math.trunc(count));
|
|
224
|
+
const target = (high - low) / (n - 1);
|
|
225
|
+
let step = 0;
|
|
226
|
+
for (const candidate of TIME_TICK_LADDER) {
|
|
227
|
+
if (candidate >= target) {
|
|
228
|
+
step = candidate;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (step === 0)
|
|
233
|
+
step = niceNumber(target / SECONDS_PER_DAY, true) * SECONDS_PER_DAY;
|
|
234
|
+
if (!(step > 0))
|
|
235
|
+
return { step: 1, ticks: [low] };
|
|
236
|
+
const first = Math.ceil(low / step - 1e-9);
|
|
237
|
+
const last = Math.floor(high / step + 1e-9);
|
|
238
|
+
const ticks = [];
|
|
239
|
+
for (let i = first; i <= last; i += 1)
|
|
240
|
+
ticks.push(i * step);
|
|
241
|
+
return { step, ticks };
|
|
242
|
+
}
|
|
243
|
+
// ── marks: datum to coordinate ──────────────────────────────────────────────────────────
|
|
244
|
+
const DEGREES = Math.PI / 180;
|
|
245
|
+
/**
|
|
246
|
+
* Pie / donut geometry. Angles are DEGREES, screen-oriented: -90 is twelve o'clock, +y is
|
|
247
|
+
* down, and a clockwise pie sweeps toward +x first.
|
|
248
|
+
*
|
|
249
|
+
* Negative values are SKIPPED, keeping their index, never folded into the total — a pie of a
|
|
250
|
+
* signed series is meaningless, and quietly taking absolute values is how it ships anyway.
|
|
251
|
+
* A total of zero is `empty`, not a division by zero.
|
|
252
|
+
*/
|
|
253
|
+
export function pieSlices(values, options) {
|
|
254
|
+
const inner = options.innerRadius <= 1
|
|
255
|
+
? options.innerRadius * options.outerRadius
|
|
256
|
+
: options.innerRadius;
|
|
257
|
+
let total = 0;
|
|
258
|
+
for (const v of values)
|
|
259
|
+
if (v > 0)
|
|
260
|
+
total += v;
|
|
261
|
+
if (!(total > 0)) {
|
|
262
|
+
return {
|
|
263
|
+
total: 0, empty: true, innerRadius: inner, outerRadius: options.outerRadius, slices: [],
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
const centroidRadius = (inner + options.outerRadius) / 2;
|
|
267
|
+
const slices = [];
|
|
268
|
+
let cursor = options.startAngle;
|
|
269
|
+
for (let i = 0; i < values.length; i += 1) {
|
|
270
|
+
const v = values[i];
|
|
271
|
+
if (!(v > 0))
|
|
272
|
+
continue;
|
|
273
|
+
const fraction = v / total;
|
|
274
|
+
const raw = fraction * 360;
|
|
275
|
+
const sweep = Math.max(0, raw - options.padAngle);
|
|
276
|
+
const startAngle = cursor;
|
|
277
|
+
const endAngle = options.clockwise ? cursor + sweep : cursor - sweep;
|
|
278
|
+
cursor = options.clockwise ? cursor + raw : cursor - raw;
|
|
279
|
+
const mid = (startAngle + endAngle) / 2;
|
|
280
|
+
slices.push({
|
|
281
|
+
index: i,
|
|
282
|
+
value: v,
|
|
283
|
+
fraction,
|
|
284
|
+
startAngle,
|
|
285
|
+
endAngle,
|
|
286
|
+
sweep,
|
|
287
|
+
centroidX: centroidRadius * Math.cos(mid * DEGREES),
|
|
288
|
+
centroidY: centroidRadius * Math.sin(mid * DEGREES),
|
|
289
|
+
full: Math.abs(sweep) >= 360 - 1e-9,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
total, empty: false, innerRadius: inner, outerRadius: options.outerRadius, slices,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Bubble radius for a scatter `size` field. Interpolates AREA, not radius, because the eye
|
|
298
|
+
* reads area: a datum twice as large must cover twice the ink, and a linear radius ramp
|
|
299
|
+
* makes it cover four times. An all-equal series takes the midpoint rather than the floor —
|
|
300
|
+
* every bubble at `rMin` reads as "no data" instead of "all the same".
|
|
301
|
+
*/
|
|
302
|
+
export function bubbleRadius(v, min, max, rMin, rMax) {
|
|
303
|
+
if (!(max > min))
|
|
304
|
+
return (rMin + rMax) / 2;
|
|
305
|
+
let t = (v - min) / (max - min);
|
|
306
|
+
if (t < 0)
|
|
307
|
+
t = 0;
|
|
308
|
+
if (t > 1)
|
|
309
|
+
t = 1;
|
|
310
|
+
return Math.sqrt(rMin * rMin + t * (rMax * rMax - rMin * rMin));
|
|
311
|
+
}
|
|
312
|
+
/** Radar / spider vertices: axis 0 at twelve o'clock, then clockwise, clamped to the ring. */
|
|
313
|
+
export function radarPoints(values, max, radius, centerX, centerY) {
|
|
314
|
+
const n = values.length;
|
|
315
|
+
const out = [];
|
|
316
|
+
for (let i = 0; i < n; i += 1) {
|
|
317
|
+
let fraction = max > 0 ? values[i] / max : 0;
|
|
318
|
+
if (fraction < 0)
|
|
319
|
+
fraction = 0;
|
|
320
|
+
if (fraction > 1)
|
|
321
|
+
fraction = 1;
|
|
322
|
+
const angle = -90 + (360 * i) / n;
|
|
323
|
+
out.push({
|
|
324
|
+
index: i,
|
|
325
|
+
fraction,
|
|
326
|
+
angle,
|
|
327
|
+
x: centerX + radius * fraction * Math.cos(angle * DEGREES),
|
|
328
|
+
y: centerY + radius * fraction * Math.sin(angle * DEGREES),
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return out;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Funnel stages. Widths are normalised by the LARGEST value (a widening stage is drawn, not
|
|
335
|
+
* clamped — a funnel that hides a stage growing is hiding the interesting one), while the
|
|
336
|
+
* ratios are against the first and the previous stage. The last stage is a rectangle: a
|
|
337
|
+
* taper to nothing implies a conversion to zero that the data never said.
|
|
338
|
+
*/
|
|
339
|
+
export function funnelStages(values, width, height, gap) {
|
|
340
|
+
const n = values.length;
|
|
341
|
+
if (n === 0)
|
|
342
|
+
return [];
|
|
343
|
+
let max = values[0];
|
|
344
|
+
for (const v of values)
|
|
345
|
+
if (v > max)
|
|
346
|
+
max = v;
|
|
347
|
+
const stageHeight = (height - gap * (n - 1)) / n;
|
|
348
|
+
const first = values[0];
|
|
349
|
+
const out = [];
|
|
350
|
+
for (let i = 0; i < n; i += 1) {
|
|
351
|
+
const v = values[i];
|
|
352
|
+
const next = i + 1 < n ? values[i + 1] : v;
|
|
353
|
+
const previous = i === 0 ? v : values[i - 1];
|
|
354
|
+
const top = i * (stageHeight + gap);
|
|
355
|
+
out.push({
|
|
356
|
+
index: i,
|
|
357
|
+
topWidth: max > 0 ? (width * v) / max : 0,
|
|
358
|
+
bottomWidth: max > 0 ? (width * next) / max : 0,
|
|
359
|
+
top,
|
|
360
|
+
bottom: top + stageHeight,
|
|
361
|
+
ofFirst: first === 0 ? 0 : v / first,
|
|
362
|
+
ofPrevious: i === 0 ? 1 : (previous === 0 ? 0 : v / previous),
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
return out;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Fold a tick stream into OHLC buckets on a fixed grid anchored at `origin`.
|
|
369
|
+
*
|
|
370
|
+
* Empty buckets are SKIPPED, never emitted as zeros: a market that did not trade is not a
|
|
371
|
+
* market that traded at zero, and a chart that draws the gap as a crash is worse than a
|
|
372
|
+
* chart with a gap. Points are ordered by (t, arrival) first, so `open` and `close` do not
|
|
373
|
+
* depend on the platform's sort being stable.
|
|
374
|
+
*/
|
|
375
|
+
export function candleBuckets(points, interval, origin) {
|
|
376
|
+
if (!(interval > 0) || points.length === 0)
|
|
377
|
+
return [];
|
|
378
|
+
const order = points.map((_, i) => i);
|
|
379
|
+
order.sort((a, b) => (points[a].t - points[b].t) || (a - b));
|
|
380
|
+
const byBucket = new Map();
|
|
381
|
+
for (const i of order) {
|
|
382
|
+
const p = points[i];
|
|
383
|
+
const bucket = Math.floor((p.t - origin) / interval);
|
|
384
|
+
const existing = byBucket.get(bucket);
|
|
385
|
+
if (existing === undefined) {
|
|
386
|
+
byBucket.set(bucket, {
|
|
387
|
+
bucket,
|
|
388
|
+
start: origin + bucket * interval,
|
|
389
|
+
open: p.v, high: p.v, low: p.v, close: p.v, count: 1,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
if (p.v > existing.high)
|
|
394
|
+
existing.high = p.v;
|
|
395
|
+
if (p.v < existing.low)
|
|
396
|
+
existing.low = p.v;
|
|
397
|
+
existing.close = p.v;
|
|
398
|
+
existing.count += 1;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
const buckets = [...byBucket.keys()].sort((a, b) => a - b);
|
|
402
|
+
return buckets.map((b) => {
|
|
403
|
+
const c = byBucket.get(b);
|
|
404
|
+
return {
|
|
405
|
+
bucket: c.bucket,
|
|
406
|
+
start: c.start,
|
|
407
|
+
open: c.open,
|
|
408
|
+
high: c.high,
|
|
409
|
+
low: c.low,
|
|
410
|
+
close: c.close,
|
|
411
|
+
count: c.count,
|
|
412
|
+
direction: candleDirection(c.open, c.close),
|
|
413
|
+
};
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function candleDirection(open, close) {
|
|
417
|
+
if (close > open)
|
|
418
|
+
return "up";
|
|
419
|
+
if (close < open)
|
|
420
|
+
return "down";
|
|
421
|
+
return "flat";
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* One candle's pixels. The range is screen-oriented: `range[1]` is the BOTTOM, so the
|
|
425
|
+
* domain maximum sits at `range[0]`.
|
|
426
|
+
*
|
|
427
|
+
* A doji (open === close) is expanded to `minBody` around its centre — a zero-height body
|
|
428
|
+
* is invisible, and the flat day is exactly the one a reader is looking for.
|
|
429
|
+
*/
|
|
430
|
+
export function candleGeometry(open, high, low, close, domain, range, minBody) {
|
|
431
|
+
const y = (v) => {
|
|
432
|
+
if (domain[1] === domain[0])
|
|
433
|
+
return (range[0] + range[1]) / 2;
|
|
434
|
+
return range[1] - ((v - domain[0]) / (domain[1] - domain[0])) * (range[1] - range[0]);
|
|
435
|
+
};
|
|
436
|
+
const yOpen = y(open);
|
|
437
|
+
const yClose = y(close);
|
|
438
|
+
let bodyTop = Math.min(yOpen, yClose);
|
|
439
|
+
let bodyBottom = Math.max(yOpen, yClose);
|
|
440
|
+
if (bodyBottom - bodyTop < minBody) {
|
|
441
|
+
const mid = (bodyTop + bodyBottom) / 2;
|
|
442
|
+
bodyTop = mid - minBody / 2;
|
|
443
|
+
bodyBottom = mid + minBody / 2;
|
|
444
|
+
}
|
|
445
|
+
return {
|
|
446
|
+
bodyTop,
|
|
447
|
+
bodyBottom,
|
|
448
|
+
wickTop: y(high),
|
|
449
|
+
wickBottom: y(low),
|
|
450
|
+
direction: candleDirection(open, close),
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Bin weighted points into a heat-map grid.
|
|
455
|
+
*
|
|
456
|
+
* The last bin owns its own upper edge: `floor(t * bins)` puts the domain maximum in a
|
|
457
|
+
* phantom bin `bins`, which is the off-by-one every heat map ships once. Out-of-domain
|
|
458
|
+
* points clamp into the edge bins rather than vanishing, and an empty grid is zero
|
|
459
|
+
* intensity everywhere, never NaN.
|
|
460
|
+
*/
|
|
461
|
+
export function heatmapCells(points, xBins, yBins, xDomain, yDomain) {
|
|
462
|
+
if (xBins <= 0 || yBins <= 0)
|
|
463
|
+
return { max: 0, cells: [] };
|
|
464
|
+
const grid = new Array(xBins * yBins).fill(0);
|
|
465
|
+
for (const p of points) {
|
|
466
|
+
const bx = binIndex(p.x, xDomain, xBins);
|
|
467
|
+
const by = binIndex(p.y, yDomain, yBins);
|
|
468
|
+
grid[by * xBins + bx] += p.w;
|
|
469
|
+
}
|
|
470
|
+
let max = 0;
|
|
471
|
+
for (const v of grid)
|
|
472
|
+
if (v > max)
|
|
473
|
+
max = v;
|
|
474
|
+
const cells = [];
|
|
475
|
+
for (let by = 0; by < yBins; by += 1) {
|
|
476
|
+
for (let bx = 0; bx < xBins; bx += 1) {
|
|
477
|
+
const value = grid[by * xBins + bx];
|
|
478
|
+
cells.push({ xBin: bx, yBin: by, value, intensity: max > 0 ? value / max : 0 });
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return { max, cells };
|
|
482
|
+
}
|
|
483
|
+
function binIndex(v, domain, bins) {
|
|
484
|
+
if (domain[1] === domain[0])
|
|
485
|
+
return 0;
|
|
486
|
+
const i = Math.floor(((v - domain[0]) / (domain[1] - domain[0])) * bins);
|
|
487
|
+
if (i < 0)
|
|
488
|
+
return 0;
|
|
489
|
+
if (i > bins - 1)
|
|
490
|
+
return bins - 1;
|
|
491
|
+
return i;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* The one default series ramp of `<chart>` on every lane: the series colours a stock Swift Charts chart takes, in
|
|
495
|
+
* its order, light and dark, read from a stock chart with no style scale (probe Core/Charts/shared/tests/stock-palette.sh);
|
|
496
|
+
* they equal Apple's HIG Color values. `colors` overrides it.
|
|
497
|
+
*/
|
|
498
|
+
export const SERIES_PALETTE = [
|
|
499
|
+
{ name: "blue", light: "#0088FF", dark: "#0091FF" },
|
|
500
|
+
{ name: "green", light: "#34C759", dark: "#30D158" },
|
|
501
|
+
{ name: "orange", light: "#FF8D28", dark: "#FF9230" },
|
|
502
|
+
{ name: "purple", light: "#CB30E0", dark: "#DB34F2" },
|
|
503
|
+
{ name: "red", light: "#FF383C", dark: "#FF4245" },
|
|
504
|
+
{ name: "teal", light: "#00C3D0", dark: "#00D2E0" },
|
|
505
|
+
{ name: "yellow", light: "#FFCC00", dark: "#FFD600" },
|
|
506
|
+
];
|
|
507
|
+
/** The default colour of series `index`, past the end the ramp repeats in order. */
|
|
508
|
+
export function seriesColor(index, dark) {
|
|
509
|
+
const n = SERIES_PALETTE.length;
|
|
510
|
+
const entry = SERIES_PALETTE[((Math.trunc(index) % n) + n) % n];
|
|
511
|
+
return dark ? entry.dark : entry.light;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* The rows a line or an area must draw so the picture equals drawing every row: split
|
|
515
|
+
* the x extent into `columns` pixel columns and keep, per column, the first, lowest, highest and last row. A row
|
|
516
|
+
* with a non-finite x or y is always kept. With no columns, or few rows, every row is kept. Indices come back
|
|
517
|
+
* ascending. Bars, points, selection, events and the accessible table never use this: they read every row.
|
|
518
|
+
*/
|
|
519
|
+
export function columnExtremes(xs, ys, x0, x1, columns) {
|
|
520
|
+
const n = Math.min(xs.length, ys.length);
|
|
521
|
+
const all = () => Array.from({ length: n }, (_, i) => i);
|
|
522
|
+
const cols = Math.trunc(columns);
|
|
523
|
+
const lo = Math.min(x0, x1);
|
|
524
|
+
const hi = Math.max(x0, x1);
|
|
525
|
+
// An extent too wide to subtract (hi - lo overflows) cannot be split into columns: every row is kept.
|
|
526
|
+
if (!(cols > 0) || n <= 4 * cols || !(hi > lo) || !Number.isFinite(hi - lo))
|
|
527
|
+
return all();
|
|
528
|
+
const first = new Map();
|
|
529
|
+
const last = new Map();
|
|
530
|
+
const min = new Map();
|
|
531
|
+
const max = new Map();
|
|
532
|
+
const keep = new Set();
|
|
533
|
+
for (let i = 0; i < n; i += 1) {
|
|
534
|
+
const x = xs[i];
|
|
535
|
+
const y = ys[i];
|
|
536
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
|
537
|
+
keep.add(i);
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
const c = Math.min(cols - 1, Math.max(0, Math.floor((x - lo) / (hi - lo) * cols)));
|
|
541
|
+
if (!first.has(c))
|
|
542
|
+
first.set(c, i);
|
|
543
|
+
last.set(c, i);
|
|
544
|
+
const m = min.get(c);
|
|
545
|
+
if (m === undefined || y < ys[m])
|
|
546
|
+
min.set(c, i);
|
|
547
|
+
const M = max.get(c);
|
|
548
|
+
if (M === undefined || y > ys[M])
|
|
549
|
+
max.set(c, i);
|
|
550
|
+
}
|
|
551
|
+
for (const map of [first, last, min, max])
|
|
552
|
+
for (const i of map.values())
|
|
553
|
+
keep.add(i);
|
|
554
|
+
return [...keep].sort((a, b) => a - b);
|
|
555
|
+
}
|
|
556
|
+
// ── interaction: what on:select / on:hover / on:brush actually carry ─────────────────────
|
|
557
|
+
/**
|
|
558
|
+
* The index a tap at `fraction` across the plot selects. This is the rule the shipped
|
|
559
|
+
* renderers already use for `on:select`, lifted out so `on:hover` inherits it exactly
|
|
560
|
+
* instead of growing a second, subtly different one.
|
|
561
|
+
*
|
|
562
|
+
* An empty series answers -1 — a typed absence, never index 0 pointing at nothing.
|
|
563
|
+
*/
|
|
564
|
+
export function nearestIndex(fraction, count) {
|
|
565
|
+
if (count <= 0)
|
|
566
|
+
return -1;
|
|
567
|
+
if (count === 1)
|
|
568
|
+
return 0;
|
|
569
|
+
const i = Math.floor(fraction * (count - 1) + 0.5);
|
|
570
|
+
if (i < 0)
|
|
571
|
+
return 0;
|
|
572
|
+
if (i > count - 1)
|
|
573
|
+
return count - 1;
|
|
574
|
+
return i;
|
|
575
|
+
}
|
|
576
|
+
/** The nearest datum by VALUE (a continuous x axis). A tie takes the lower index. */
|
|
577
|
+
export function nearestValueIndex(value, values) {
|
|
578
|
+
if (values.length === 0)
|
|
579
|
+
return -1;
|
|
580
|
+
let best = 0;
|
|
581
|
+
let bestDistance = Math.abs(value - values[0]);
|
|
582
|
+
for (let i = 1; i < values.length; i += 1) {
|
|
583
|
+
const d = Math.abs(value - values[i]);
|
|
584
|
+
if (d < bestDistance) {
|
|
585
|
+
bestDistance = d;
|
|
586
|
+
best = i;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return best;
|
|
590
|
+
}
|
|
591
|
+
/** Below this fraction of the plot a drag is a tap, and a tap clears the brush. */
|
|
592
|
+
export const BRUSH_MIN_FRACTION = 0.01;
|
|
593
|
+
/**
|
|
594
|
+
* Fold a drag into a brush payload. Direction does not matter — a right-to-left drag
|
|
595
|
+
* reports the same window — and both ends clamp into the plot.
|
|
596
|
+
*/
|
|
597
|
+
export function brushWindow(from, to, domain) {
|
|
598
|
+
const lo = clamp(Math.min(from, to), 0, 1);
|
|
599
|
+
const hi = clamp(Math.max(from, to), 0, 1);
|
|
600
|
+
if (hi - lo < BRUSH_MIN_FRACTION) {
|
|
601
|
+
return { start: domain[0], end: domain[1], cleared: true };
|
|
602
|
+
}
|
|
603
|
+
const span = domain[1] - domain[0];
|
|
604
|
+
return { start: domain[0] + lo * span, end: domain[0] + hi * span, cleared: false };
|
|
605
|
+
}
|
|
606
|
+
/** The tightest window a pinch may reach, as a fraction of the full data extent. */
|
|
607
|
+
export const ZOOM_MIN_SPAN_FRACTION = 0.01;
|
|
608
|
+
/**
|
|
609
|
+
* Zoom the visible domain about an anchor (0 = left edge, 1 = right edge of the plot).
|
|
610
|
+
*
|
|
611
|
+
* The window clamps to the full data extent — no rubber band past the data, no inversion —
|
|
612
|
+
* and the span has a floor so a fast pinch cannot divide by zero. A window pushed past an
|
|
613
|
+
* edge is SHIFTED back in, not clipped: clipping silently changes the zoom level the user
|
|
614
|
+
* asked for.
|
|
615
|
+
*/
|
|
616
|
+
export function zoomDomain(domain, full, factor, anchor) {
|
|
617
|
+
const fullSpan = full[1] - full[0];
|
|
618
|
+
if (!(fullSpan > 0) || !(factor > 0))
|
|
619
|
+
return { lo: full[0], hi: full[1] };
|
|
620
|
+
const span = domain[1] - domain[0];
|
|
621
|
+
const newSpan = clamp(span / factor, fullSpan * ZOOM_MIN_SPAN_FRACTION, fullSpan);
|
|
622
|
+
const anchorValue = domain[0] + anchor * span;
|
|
623
|
+
let lo = anchorValue - anchor * newSpan;
|
|
624
|
+
if (lo < full[0])
|
|
625
|
+
lo = full[0];
|
|
626
|
+
if (lo + newSpan > full[1])
|
|
627
|
+
lo = full[1] - newSpan;
|
|
628
|
+
if (lo < full[0])
|
|
629
|
+
lo = full[0];
|
|
630
|
+
return { lo, hi: lo + newSpan };
|
|
631
|
+
}
|
|
632
|
+
/** Pan by a fraction of the visible span, keeping the span and staying inside the extent. */
|
|
633
|
+
export function panDomain(domain, full, delta) {
|
|
634
|
+
const span = domain[1] - domain[0];
|
|
635
|
+
let lo = domain[0] + delta * span;
|
|
636
|
+
if (lo < full[0])
|
|
637
|
+
lo = full[0];
|
|
638
|
+
if (lo + span > full[1])
|
|
639
|
+
lo = full[1] - span;
|
|
640
|
+
if (lo < full[0])
|
|
641
|
+
lo = full[0];
|
|
642
|
+
return { lo, hi: lo + span };
|
|
643
|
+
}
|
|
644
|
+
function clamp(v, lo, hi) {
|
|
645
|
+
if (v < lo)
|
|
646
|
+
return lo;
|
|
647
|
+
if (v > hi)
|
|
648
|
+
return hi;
|
|
649
|
+
return v;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Format one cell. An integer prints as an integer and everything else to two decimals —
|
|
653
|
+
* a screen reader saying "one thousand two hundred point zero zero" for a whole number is
|
|
654
|
+
* noise, and "1500.5" read as digits is worse than "1500.50".
|
|
655
|
+
*/
|
|
656
|
+
export function formatDatavizCell(value) {
|
|
657
|
+
if (value === null || value === undefined)
|
|
658
|
+
return "";
|
|
659
|
+
if (typeof value === "boolean")
|
|
660
|
+
return value ? "true" : "false";
|
|
661
|
+
if (typeof value === "number") {
|
|
662
|
+
if (!Number.isFinite(value))
|
|
663
|
+
return "";
|
|
664
|
+
if (Math.floor(value) === value && Math.abs(value) < 1e15)
|
|
665
|
+
return String(value);
|
|
666
|
+
return value.toFixed(2);
|
|
667
|
+
}
|
|
668
|
+
return String(value);
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Pivot a chart's bound rows into the table `accessibleTable` renders. Default ON, and
|
|
672
|
+
* nearly free: the data is already structured and `<table>` already exists, so a blind user
|
|
673
|
+
* gets the numbers, a sighted user gets the chart, and the author writes one element.
|
|
674
|
+
*
|
|
675
|
+
* Both axes are in FIRST APPEARANCE order, never sorted — the author's row order is the
|
|
676
|
+
* author's intent. A missing (x, series) cell is an EMPTY STRING, never a zero: a datum
|
|
677
|
+
* that was not measured is not a measurement of nothing. A duplicate pair is last-wins.
|
|
678
|
+
*/
|
|
679
|
+
export function accessibleTable(rows, spec) {
|
|
680
|
+
const multiSeries = spec.series !== "";
|
|
681
|
+
const xLabels = [];
|
|
682
|
+
const seriesLabels = [];
|
|
683
|
+
const cells = new Map();
|
|
684
|
+
let min = Number.NaN;
|
|
685
|
+
let max = Number.NaN;
|
|
686
|
+
let sawNumber = false;
|
|
687
|
+
for (const row of rows) {
|
|
688
|
+
const xLabel = formatDatavizCell(row[spec.x]);
|
|
689
|
+
if (!xLabels.includes(xLabel))
|
|
690
|
+
xLabels.push(xLabel);
|
|
691
|
+
const seriesLabel = multiSeries ? formatDatavizCell(row[spec.series]) : "";
|
|
692
|
+
if (multiSeries && !seriesLabels.includes(seriesLabel))
|
|
693
|
+
seriesLabels.push(seriesLabel);
|
|
694
|
+
const raw = row[spec.y];
|
|
695
|
+
if (typeof raw === "number" && Number.isFinite(raw)) {
|
|
696
|
+
if (!sawNumber) {
|
|
697
|
+
min = raw;
|
|
698
|
+
max = raw;
|
|
699
|
+
sawNumber = true;
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
if (raw < min)
|
|
703
|
+
min = raw;
|
|
704
|
+
if (raw > max)
|
|
705
|
+
max = raw;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
let bySeries = cells.get(xLabel);
|
|
709
|
+
if (bySeries === undefined) {
|
|
710
|
+
bySeries = new Map();
|
|
711
|
+
cells.set(xLabel, bySeries);
|
|
712
|
+
}
|
|
713
|
+
bySeries.set(seriesLabel, formatDatavizCell(raw));
|
|
714
|
+
}
|
|
715
|
+
const xHeader = spec.xTitle !== "" ? spec.xTitle : spec.x;
|
|
716
|
+
const yHeader = spec.yTitle !== "" ? spec.yTitle : spec.y;
|
|
717
|
+
const columns = multiSeries ? [xHeader, ...seriesLabels] : [xHeader, yHeader];
|
|
718
|
+
const table = [];
|
|
719
|
+
for (const xLabel of xLabels) {
|
|
720
|
+
const bySeries = cells.get(xLabel);
|
|
721
|
+
const out = [xLabel];
|
|
722
|
+
if (multiSeries) {
|
|
723
|
+
for (const seriesLabel of seriesLabels)
|
|
724
|
+
out.push(bySeries?.get(seriesLabel) ?? "");
|
|
725
|
+
}
|
|
726
|
+
else {
|
|
727
|
+
out.push(bySeries?.get("") ?? "");
|
|
728
|
+
}
|
|
729
|
+
table.push(out);
|
|
730
|
+
}
|
|
731
|
+
const caption = multiSeries
|
|
732
|
+
? `${spec.type} chart. ${rows.length} data points in ${seriesLabels.length} series. ${yHeader} by ${xHeader}.`
|
|
733
|
+
: `${spec.type} chart. ${rows.length} data points. ${yHeader} by ${xHeader}.`;
|
|
734
|
+
let summary = `${spec.type} chart with ${rows.length} points`;
|
|
735
|
+
if (sawNumber) {
|
|
736
|
+
summary += `; values range from ${formatDatavizCell(min)} to ${formatDatavizCell(max)}`;
|
|
737
|
+
}
|
|
738
|
+
return { caption, columns, rows: table, summary };
|
|
739
|
+
}
|
|
740
|
+
// ── camera: web mercator, and the two things nobody gets right ───────────────────────────
|
|
741
|
+
/** One map tile's edge, in points. Every zoom level is `tileSize * 2^zoom` across. */
|
|
742
|
+
export const MAP_TILE_SIZE = 256;
|
|
743
|
+
export const MAP_MIN_ZOOM = 0;
|
|
744
|
+
export const MAP_MAX_ZOOM = 22;
|
|
745
|
+
/** Where a camera sits when the content cannot imply a zoom (one pin, or none). */
|
|
746
|
+
export const MAP_DEFAULT_ZOOM = 16;
|
|
747
|
+
/** Web mercator cannot reach a pole; this is where the projection is cut. */
|
|
748
|
+
export const MAP_MAX_MERCATOR_LATITUDE = 85.05112878;
|
|
749
|
+
/** Wrap a longitude into [-180, 180). The antimeridian normalises WEST. */
|
|
750
|
+
export function normalizeLongitude(lon) {
|
|
751
|
+
let r = (lon + 180) % 360;
|
|
752
|
+
if (r < 0)
|
|
753
|
+
r += 360;
|
|
754
|
+
return r - 180;
|
|
755
|
+
}
|
|
756
|
+
/** Longitude to normalised world x, 0 at -180 and 1 at +180. */
|
|
757
|
+
export function mercatorX(lon) {
|
|
758
|
+
return (normalizeLongitude(lon) + 180) / 360;
|
|
759
|
+
}
|
|
760
|
+
/** Latitude to normalised world y, 0 at the north cut and 1 at the south. */
|
|
761
|
+
export function mercatorY(lat) {
|
|
762
|
+
const clamped = clamp(lat, -MAP_MAX_MERCATOR_LATITUDE, MAP_MAX_MERCATOR_LATITUDE);
|
|
763
|
+
const s = Math.sin(clamped * DEGREES);
|
|
764
|
+
return 0.5 - Math.log((1 + s) / (1 - s)) / (4 * Math.PI);
|
|
765
|
+
}
|
|
766
|
+
/** World x back to longitude. */
|
|
767
|
+
export function longitudeAtWorldX(worldX) {
|
|
768
|
+
return worldX * 360 - 180;
|
|
769
|
+
}
|
|
770
|
+
/** World y back to latitude. */
|
|
771
|
+
export function latitudeAtWorldY(worldY) {
|
|
772
|
+
return Math.atan(Math.sinh(Math.PI * (1 - 2 * worldY))) / DEGREES;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* The minimal enclosing longitude arc of a set of points: its western end and its width.
|
|
776
|
+
*
|
|
777
|
+
* Taking min and max longitude of a set straddling 180 degrees produces a span of nearly
|
|
778
|
+
* the whole planet and a camera that flies the long way round. The fix is to sort the
|
|
779
|
+
* longitudes, find the largest circular GAP, and keep what is left.
|
|
780
|
+
*/
|
|
781
|
+
export function minimalLongitudeArc(lons) {
|
|
782
|
+
const n = lons.length;
|
|
783
|
+
if (n === 0)
|
|
784
|
+
return { start: 0, span: 0 };
|
|
785
|
+
const sorted = lons.map(normalizeLongitude).sort((a, b) => a - b);
|
|
786
|
+
if (n === 1)
|
|
787
|
+
return { start: sorted[0], span: 0 };
|
|
788
|
+
let gap = -1;
|
|
789
|
+
let gapIndex = 0;
|
|
790
|
+
for (let i = 0; i < n; i += 1) {
|
|
791
|
+
const next = (i + 1) % n;
|
|
792
|
+
const g = next === 0 ? sorted[0] + 360 - sorted[n - 1] : sorted[next] - sorted[i];
|
|
793
|
+
if (g > gap) {
|
|
794
|
+
gap = g;
|
|
795
|
+
gapIndex = i;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
return { start: sorted[(gapIndex + 1) % n], span: 360 - gap };
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* The camera that fits `coords` into a viewport, respecting asymmetric padding.
|
|
802
|
+
*
|
|
803
|
+
* The content is centred in the USABLE rectangle, not the viewport, so the camera centre
|
|
804
|
+
* shifts by half the padding difference converted back to world units AT THE CHOSEN ZOOM —
|
|
805
|
+
* a bottom sheet covering 40% of the screen otherwise hides the very pins that were fitted.
|
|
806
|
+
* A single coordinate is not a zero-span bug, it is a request to sit at the default zoom;
|
|
807
|
+
* no coordinates is a typed invalid.
|
|
808
|
+
*/
|
|
809
|
+
export function fitCamera(coords, width, height, padding) {
|
|
810
|
+
if (coords.length === 0) {
|
|
811
|
+
return { valid: false, lat: 0, lon: 0, zoom: MAP_DEFAULT_ZOOM };
|
|
812
|
+
}
|
|
813
|
+
const usableWidth = Math.max(1, width - padding.left - padding.right);
|
|
814
|
+
const usableHeight = Math.max(1, height - padding.top - padding.bottom);
|
|
815
|
+
const arc = minimalLongitudeArc(coords.map((c) => c.lon));
|
|
816
|
+
let yLo = mercatorY(coords[0].lat);
|
|
817
|
+
let yHi = yLo;
|
|
818
|
+
for (const c of coords) {
|
|
819
|
+
const y = mercatorY(c.lat);
|
|
820
|
+
if (y < yLo)
|
|
821
|
+
yLo = y;
|
|
822
|
+
if (y > yHi)
|
|
823
|
+
yHi = y;
|
|
824
|
+
}
|
|
825
|
+
const spanX = arc.span / 360;
|
|
826
|
+
const spanY = yHi - yLo;
|
|
827
|
+
const zoomX = spanX > 0 ? Math.log2(usableWidth / (spanX * MAP_TILE_SIZE)) : Infinity;
|
|
828
|
+
const zoomY = spanY > 0 ? Math.log2(usableHeight / (spanY * MAP_TILE_SIZE)) : Infinity;
|
|
829
|
+
let zoom = Math.min(zoomX, zoomY);
|
|
830
|
+
if (!Number.isFinite(zoom))
|
|
831
|
+
zoom = MAP_DEFAULT_ZOOM;
|
|
832
|
+
zoom = clamp(zoom, MAP_MIN_ZOOM, MAP_MAX_ZOOM);
|
|
833
|
+
const scale = MAP_TILE_SIZE * Math.pow(2, zoom);
|
|
834
|
+
const shiftX = (padding.left + (width - padding.right)) / 2 - width / 2;
|
|
835
|
+
const shiftY = (padding.top + (height - padding.bottom)) / 2 - height / 2;
|
|
836
|
+
const centerX = mercatorX(arc.start) + spanX / 2 - shiftX / scale;
|
|
837
|
+
const centerY = (yLo + yHi) / 2 - shiftY / scale;
|
|
838
|
+
return {
|
|
839
|
+
valid: true,
|
|
840
|
+
lat: latitudeAtWorldY(centerY),
|
|
841
|
+
lon: normalizeLongitude(longitudeAtWorldX(centerX)),
|
|
842
|
+
zoom,
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* The region a camera sees. The latitude span is measured by unprojecting both edges, not
|
|
847
|
+
* by scaling the longitude span: mercator stretches with latitude, and a "square" viewport
|
|
848
|
+
* over Oslo covers far less ground north to south than one over Quito.
|
|
849
|
+
*/
|
|
850
|
+
export function mapRegion(lat, lon, zoom, width, height) {
|
|
851
|
+
const scale = MAP_TILE_SIZE * Math.pow(2, zoom);
|
|
852
|
+
const centerY = mercatorY(lat);
|
|
853
|
+
const north = latitudeAtWorldY(centerY - height / 2 / scale);
|
|
854
|
+
const south = latitudeAtWorldY(centerY + height / 2 / scale);
|
|
855
|
+
return {
|
|
856
|
+
centerLat: clamp(lat, -MAP_MAX_MERCATOR_LATITUDE, MAP_MAX_MERCATOR_LATITUDE),
|
|
857
|
+
centerLon: normalizeLongitude(lon),
|
|
858
|
+
zoom,
|
|
859
|
+
latSpan: north - south,
|
|
860
|
+
lonSpan: (width / scale) * 360,
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
// ── cluster: five hundred pins, grouped the same way three times ─────────────────────────
|
|
864
|
+
/** The default cell side, in points, at the cluster level. */
|
|
865
|
+
export const CLUSTER_DEFAULT_RADIUS = 60;
|
|
866
|
+
/** The deepest level the expansion search will look for a split at. */
|
|
867
|
+
export const CLUSTER_MAX_ZOOM = 20;
|
|
868
|
+
function clusterCell(worldX, worldY, level, radius) {
|
|
869
|
+
const worldSize = MAP_TILE_SIZE * Math.pow(2, level);
|
|
870
|
+
return [
|
|
871
|
+
Math.floor((worldX * worldSize) / radius),
|
|
872
|
+
Math.floor((worldY * worldSize) / radius),
|
|
873
|
+
];
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Grid-cluster pins for one camera.
|
|
877
|
+
*
|
|
878
|
+
* The algorithm is pinned here rather than left to MKClusterAnnotation, maps-utils and
|
|
879
|
+
* Supercluster, which group differently at the same zoom and make a screenshot test
|
|
880
|
+
* impossible: project each pin to world space, multiply by the world size at the CLUSTER
|
|
881
|
+
* LEVEL, and take the integer cell of side `radius`.
|
|
882
|
+
*
|
|
883
|
+
* The level is `floor(zoom)`, never `zoom` — a continuous grid slides continuously, so at
|
|
884
|
+
* 12.37 a pin sits in one cell and at 12.38 in the next, and markers flicker while the user
|
|
885
|
+
* pinches. Quantising means membership is identical for every fractional zoom inside a
|
|
886
|
+
* level. Output is row-major by cell (cy, then cx) so all three renderers emit the same
|
|
887
|
+
* nodes in the same order with the same ids, which is what stops marker churn on redraw. A
|
|
888
|
+
* cell holding one pin is NOT a cluster, and a cluster's coordinate is the mean of its
|
|
889
|
+
* members in WORLD space, not the mean of their latitudes.
|
|
890
|
+
*/
|
|
891
|
+
export function clusterPins(pins, zoom, radius, maxZoom) {
|
|
892
|
+
const level = Math.trunc(clamp(Math.floor(zoom), 0, maxZoom));
|
|
893
|
+
const worldXs = [];
|
|
894
|
+
const worldYs = [];
|
|
895
|
+
for (const p of pins) {
|
|
896
|
+
worldXs.push(mercatorX(p.lon));
|
|
897
|
+
worldYs.push(mercatorY(p.lat));
|
|
898
|
+
}
|
|
899
|
+
const cells = new Map();
|
|
900
|
+
for (let i = 0; i < pins.length; i += 1) {
|
|
901
|
+
const [cx, cy] = clusterCell(worldXs[i], worldYs[i], level, radius);
|
|
902
|
+
const key = `${cx}:${cy}`;
|
|
903
|
+
const bucket = cells.get(key);
|
|
904
|
+
if (bucket === undefined)
|
|
905
|
+
cells.set(key, { cx, cy, members: [i] });
|
|
906
|
+
else
|
|
907
|
+
bucket.members.push(i);
|
|
908
|
+
}
|
|
909
|
+
const ordered = [...cells.values()].sort((a, b) => (a.cy - b.cy) || (a.cx - b.cx));
|
|
910
|
+
const out = [];
|
|
911
|
+
for (const cell of ordered) {
|
|
912
|
+
if (cell.members.length === 1) {
|
|
913
|
+
const i = cell.members[0];
|
|
914
|
+
out.push({
|
|
915
|
+
cluster: false,
|
|
916
|
+
id: `p:${i}`,
|
|
917
|
+
lat: pins[i].lat,
|
|
918
|
+
lon: pins[i].lon,
|
|
919
|
+
count: 1,
|
|
920
|
+
members: [i],
|
|
921
|
+
expansionZoom: level,
|
|
922
|
+
});
|
|
923
|
+
continue;
|
|
924
|
+
}
|
|
925
|
+
let sumX = 0;
|
|
926
|
+
let sumY = 0;
|
|
927
|
+
for (const i of cell.members) {
|
|
928
|
+
sumX += worldXs[i];
|
|
929
|
+
sumY += worldYs[i];
|
|
930
|
+
}
|
|
931
|
+
const meanX = sumX / cell.members.length;
|
|
932
|
+
const meanY = sumY / cell.members.length;
|
|
933
|
+
out.push({
|
|
934
|
+
cluster: true,
|
|
935
|
+
id: `c:${level}:${cell.cx}:${cell.cy}`,
|
|
936
|
+
lat: latitudeAtWorldY(meanY),
|
|
937
|
+
lon: normalizeLongitude(longitudeAtWorldX(meanX)),
|
|
938
|
+
count: cell.members.length,
|
|
939
|
+
members: cell.members,
|
|
940
|
+
expansionZoom: clusterExpansionZoom(cell.members, worldXs, worldYs, level, radius, maxZoom),
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
return out;
|
|
944
|
+
}
|
|
945
|
+
function clusterExpansionZoom(members, worldXs, worldYs, level, radius, maxZoom) {
|
|
946
|
+
for (let l = level + 1; l <= maxZoom; l += 1) {
|
|
947
|
+
const [cx0, cy0] = clusterCell(worldXs[members[0]], worldYs[members[0]], l, radius);
|
|
948
|
+
for (let k = 1; k < members.length; k += 1) {
|
|
949
|
+
const [cx, cy] = clusterCell(worldXs[members[k]], worldYs[members[k]], l, radius);
|
|
950
|
+
if (cx !== cx0 || cy !== cy0)
|
|
951
|
+
return l;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
return maxZoom;
|
|
955
|
+
}
|
|
956
|
+
//# sourceMappingURL=dataviz.js.map
|