@despia-native/kernel 0.0.0-coming-soon.0 → 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 +16 -1
- 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 +141 -2
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
//
|
|
2
|
+
// stdlib.ts - THE `dsx.` STANDARD LIBRARY of a body.
|
|
3
|
+
//
|
|
4
|
+
// Eight names a body reaches: `dsx.bytes`, `dsx.cache`, `dsx.clock`, `dsx.color`,
|
|
5
|
+
// `dsx.decimal`, `dsx.format`, `dsx.pattern` and `dsx.random`. Only `dsx.cache.invalidate`
|
|
6
|
+
// has an effect (it drops cached answers); no other verb writes anything. Three read more
|
|
7
|
+
// than their arguments: `dsx.clock.now` reads the evaluation's latched instant,
|
|
8
|
+
// `dsx.random.int`, `.token` and `.uuid` draw fresh entropy (`dsx.random.stream` is seeded
|
|
9
|
+
// and pure), and `dsx.format.*` reads the active locale when the call names none (and
|
|
10
|
+
// `.date` and `.time` the display time zone, else the device's). Every other verb is a
|
|
11
|
+
// pure function of its arguments. Each is reached as a dotted `dsx.` call and no other way.
|
|
12
|
+
// Six land here (`dsx.color` is color.ts, `dsx.cache.invalidate` is the runner's seam in
|
|
13
|
+
// jse.ts) rather than in jse.ts, so a slice that spells none of them carries none of them
|
|
14
|
+
// (the `__DSX_OPTIONAL_DSX_STDLIB__` fold, /web/13 embed size law).
|
|
15
|
+
//
|
|
16
|
+
// Swift twin: Engine/Swift/JSELibrary.swift `DSXStdlib`. Kotlin twin: Engine/Kotlin
|
|
17
|
+
// core/.../Stdlib.kt `DSXStdlib`. The corpus that holds all three to one answer is
|
|
18
|
+
// OpenSource/Conformance/jse/dsx-*.json.
|
|
19
|
+
//
|
|
20
|
+
// WHY A CLOSED NAMESPACE AND NOT A PACKAGE. Every one of Despia's own services hides these
|
|
21
|
+
// behind a private TypeScript package today (the dogfood ledger's `expiryFromNow`,
|
|
22
|
+
// `mintUserCode`, thirty hand-written shape predicates "because the interpreter has no
|
|
23
|
+
// regular expressions"). A language whose own vendor cannot write a timestamp in it is not
|
|
24
|
+
// complete, and a package per author means two ways to do each thing forever.
|
|
25
|
+
//
|
|
26
|
+
import { base64Encode, base64Decode } from "./core.js";
|
|
27
|
+
import { number, safeInt, string, NSNull, activeLocaleTag } from "./values.js";
|
|
28
|
+
import { DSXFormat } from "../message.js";
|
|
29
|
+
import { reDoSProne } from "./regex.js";
|
|
30
|
+
// ── bytes ────────────────────────────────────────────────────────────────────────────
|
|
31
|
+
//
|
|
32
|
+
// WHAT A BYTES VALUE IS: the byte array the language already has (jse.md:135-137, a list of
|
|
33
|
+
// numbers 0-255). No new value type is minted. A value model change would have to travel
|
|
34
|
+
// through JSON, through the store, through every native bridge and through the debugger's
|
|
35
|
+
// recorder, and the existing array already does all four; `Uint8Array`, `toHex`, `toBase64`
|
|
36
|
+
// and `TextEncoder` have spoken it since the JS-globals layer was written.
|
|
37
|
+
//
|
|
38
|
+
// WHAT IT MEASURES AND IN WHAT UNIT: OCTETS. `dsx.bytes.length` counts bytes of the UTF-8
|
|
39
|
+
// encoding, never graphemes and never UTF-16 units. This is the one measurement on which the
|
|
40
|
+
// build's own size facts are stated - the G10 widget law is written in bytes ("EmbedCard is
|
|
41
|
+
// 41425B gz; the law is 40960B"), the upload ceiling is bytes, the OTA generation size is
|
|
42
|
+
// bytes - so an author who asks how big a payload is gets the number the build would print.
|
|
43
|
+
// It is deliberately NOT `String.length`, which is grapheme based on all three runners by
|
|
44
|
+
// law (values.ts graphemes): `dsx.bytes.length('é')` is 3 where `'é'.length` is 1,
|
|
45
|
+
// and both are right about different questions.
|
|
46
|
+
/** Bytes in, from anything the library accepts: a byte array, or text (as its UTF-8 octets).
|
|
47
|
+
* Null for anything else, and for an array element that is not a number. */
|
|
48
|
+
function bytesIn(v) {
|
|
49
|
+
if (typeof v === "string")
|
|
50
|
+
return [...new TextEncoder().encode(v)];
|
|
51
|
+
if (!Array.isArray(v))
|
|
52
|
+
return null;
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const e of v) {
|
|
55
|
+
const n = number(e);
|
|
56
|
+
if (n === null)
|
|
57
|
+
return null;
|
|
58
|
+
out.push(safeInt(n) & 0xff);
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
const HEX = "0123456789abcdef";
|
|
63
|
+
// ── clock ────────────────────────────────────────────────────────────────────────────
|
|
64
|
+
//
|
|
65
|
+
// A FORMULA THAT READS THE WALL CLOCK IS NOT A FORMULA, so time is an INPUT here and not a
|
|
66
|
+
// reach. `dsx.clock.now()` answers THE EVALUATION'S INSTANT: one instant, latched when the
|
|
67
|
+
// evaluation's door opens and held until it closes, so two reads in one body are the same
|
|
68
|
+
// number and a body is a pure function of its inputs plus that one instant. On the server
|
|
69
|
+
// that instant is the request's clock, which is what makes a workflow replay exact; in a
|
|
70
|
+
// test it is whatever the test installed; in the debugger's replay it is the instant the
|
|
71
|
+
// recorder wrote down.
|
|
72
|
+
//
|
|
73
|
+
// WHERE IT IS LATCHED: `beginEvaluation` already calls the host clock once, for the wall
|
|
74
|
+
// clock deadline, and now keeps that same reading on the budget as `instant`. So the clock
|
|
75
|
+
// costs nothing per evaluation, and the deadline and the clock can never disagree about
|
|
76
|
+
// when the evaluation began. A TEST CONTROLS IT through `JSESeams.clockNow`, the one seam
|
|
77
|
+
// `beginEvaluation` reads; the natives carry the same seam on their own budget.
|
|
78
|
+
//
|
|
79
|
+
// EVERY OTHER VERB IS PURE. `instant`, `text`, `add`, `diff`, `startOf` and `parts` take an
|
|
80
|
+
// instant and answer a value, so a body that wants to be testable passes an instant in and
|
|
81
|
+
// never calls `now()` at all, which is the shape that makes time testable in any language.
|
|
82
|
+
//
|
|
83
|
+
// AND IT AGREES WITH THE ONE DATE LAW (Appendix E item 11, commit 3189a0d33): `instant`
|
|
84
|
+
// parses ISO 8601 with a zone, or `yyyy-MM-dd` as UTC midnight, AND NOTHING ELSE. A
|
|
85
|
+
// zone-less date-time means the host's timezone, so the same markup answered a different
|
|
86
|
+
// instant on a phone in Dubai and a server in UTC and the record lane measured the two
|
|
87
|
+
// natives four hours apart on `2026/09/19`. `text` answers the same shape it accepts.
|
|
88
|
+
/** Every unit the clock names, as milliseconds. `month` and `year` are absent on purpose:
|
|
89
|
+
* they are not fixed spans, so `add(t, 1, 'month')` would have to pick a convention for
|
|
90
|
+
* the 31st of January and every lane would pick its own. `startOf` and `parts` do the
|
|
91
|
+
* calendar work instead, on the proleptic Gregorian calendar in UTC, where there is one
|
|
92
|
+
* answer. */
|
|
93
|
+
const CLOCK_UNITS = {
|
|
94
|
+
ms: 1, second: 1000, minute: 60000, hour: 3600000, day: 86400000, week: 604800000,
|
|
95
|
+
};
|
|
96
|
+
/** ISO 8601 with a zone, or `yyyy-MM-dd` read as UTC midnight. Nothing else, and null for
|
|
97
|
+
* everything else, which is the item 11 law verbatim. */
|
|
98
|
+
const ISO_INSTANT = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?(Z|[+-]\d{2}:?\d{2}))?$/;
|
|
99
|
+
function clockInstant(text) {
|
|
100
|
+
const m = ISO_INSTANT.exec(text.trim());
|
|
101
|
+
if (m === null)
|
|
102
|
+
return null;
|
|
103
|
+
const [, y, mo, d, h, mi, sec, ms, zone] = m;
|
|
104
|
+
const year = Number(y), month = Number(mo), day = Number(d);
|
|
105
|
+
if (month < 1 || month > 12 || day < 1 || day > 31)
|
|
106
|
+
return null;
|
|
107
|
+
let t = Date.UTC(year, month - 1, day, Number(h ?? 0), Number(mi ?? 0), Number(sec ?? 0), Number((ms ?? "").padEnd(3, "0") || 0));
|
|
108
|
+
if (!Number.isFinite(t))
|
|
109
|
+
return null;
|
|
110
|
+
if (zone !== undefined && zone !== "Z") {
|
|
111
|
+
const sign = zone.startsWith("-") ? 1 : -1;
|
|
112
|
+
const [zh, zm] = zone.substring(1).replace(":", "").match(/\d{2}/g) ?? ["0", "0"];
|
|
113
|
+
t += sign * (Number(zh) * 3600000 + Number(zm) * 60000);
|
|
114
|
+
}
|
|
115
|
+
return t;
|
|
116
|
+
}
|
|
117
|
+
/** The instant as ISO 8601 UTC with milliseconds - the one shape `instant` reads back. */
|
|
118
|
+
function clockText(t) {
|
|
119
|
+
if (!Number.isFinite(t) || Math.abs(t) > 8.64e15)
|
|
120
|
+
return null;
|
|
121
|
+
return new Date(t).toISOString();
|
|
122
|
+
}
|
|
123
|
+
/** Days since the epoch, floored, and the civil date it names. Written out rather than
|
|
124
|
+
* taken from the host's calendar so the three runners cannot disagree about a year before
|
|
125
|
+
* 1970 or about a leap day: this is Howard Hinnant's civil_from_days, the algorithm the
|
|
126
|
+
* Swift and Kotlin twins carry line for line. */
|
|
127
|
+
function civilFromDays(z0) {
|
|
128
|
+
const z = z0 + 719468;
|
|
129
|
+
const era = Math.floor(z / 146097);
|
|
130
|
+
const doe = z - era * 146097;
|
|
131
|
+
const yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);
|
|
132
|
+
const y = yoe + era * 400;
|
|
133
|
+
const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));
|
|
134
|
+
const mp = Math.floor((5 * doy + 2) / 153);
|
|
135
|
+
const d = doy - Math.floor((153 * mp + 2) / 5) + 1;
|
|
136
|
+
const m = mp < 10 ? mp + 3 : mp - 9;
|
|
137
|
+
return { y: m <= 2 ? y + 1 : y, m, d };
|
|
138
|
+
}
|
|
139
|
+
function daysFromCivil(y0, m, d) {
|
|
140
|
+
const y = m <= 2 ? y0 - 1 : y0;
|
|
141
|
+
const era = Math.floor(y / 400);
|
|
142
|
+
const yoe = y - era * 400;
|
|
143
|
+
const doy = Math.floor((153 * (m > 2 ? m - 3 : m + 9) + 2) / 5) + d - 1;
|
|
144
|
+
const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
|
|
145
|
+
return era * 146097 + doe - 719468;
|
|
146
|
+
}
|
|
147
|
+
// ── random ───────────────────────────────────────────────────────────────────────────
|
|
148
|
+
//
|
|
149
|
+
// HOW IT IS SEEDED, AND WHETHER A DETERMINISTIC MODE EXISTS. Two generators, one door.
|
|
150
|
+
//
|
|
151
|
+
// By default every draw is CRYPTOGRAPHIC: the platform CSPRNG and nothing else
|
|
152
|
+
// (`crypto.getRandomValues` here, `SecRandomCopyBytes` on iOS, `SecureRandom` on Android).
|
|
153
|
+
// A token an author mints is a token an attacker must not predict, and a library that
|
|
154
|
+
// offered a fast unsafe default would be used for exactly that.
|
|
155
|
+
//
|
|
156
|
+
// DETERMINISTIC MODE EXISTS AND IT IS EXPLICIT: `dsx.random.stream(seed, count)` answers
|
|
157
|
+
// `count` doubles in [0, 1) from a named seed, and it is PURE - same seed, same numbers,
|
|
158
|
+
// on every runner, forever. It is a verb rather than a mode switch because the debugger's
|
|
159
|
+
// replay already depends on a run being reproducible, and a hidden global "test mode" that
|
|
160
|
+
// changed what `token()` returns would make a replay reproduce a DIFFERENT program from the
|
|
161
|
+
// one that ran. A body that needs reproducible draws asks for them by name, in the source,
|
|
162
|
+
// where the reader can see it; a body that asks for a token gets a real one in every lane
|
|
163
|
+
// including the replay, and the recorder records the token it got.
|
|
164
|
+
//
|
|
165
|
+
// THE GENERATOR is a 32 bit xorshift, written in 32 bit arithmetic on every lane so the
|
|
166
|
+
// sequence is identical: Swift on UInt32, Kotlin on UInt, TypeScript on `>>> 0`. A seed of
|
|
167
|
+
// zero is the generator's fixed point, so it folds to the golden ratio constant rather than
|
|
168
|
+
// answering zero forever, and the corpus pins that.
|
|
169
|
+
function xorshift32(seed) {
|
|
170
|
+
let x = (safeInt(seed) >>> 0) || 0x9e3779b9;
|
|
171
|
+
return () => {
|
|
172
|
+
x ^= (x << 13) >>> 0;
|
|
173
|
+
x >>>= 0;
|
|
174
|
+
x ^= x >>> 17;
|
|
175
|
+
x ^= (x << 5) >>> 0;
|
|
176
|
+
x >>>= 0;
|
|
177
|
+
return x / 4294967296;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/** `count` cryptographic bytes, or null when the lane has no CSPRNG - never a fallback to a
|
|
181
|
+
* weak one, because a token that is only probably unpredictable is worse than no token. */
|
|
182
|
+
function cryptoBytes(count) {
|
|
183
|
+
const c = globalThis.crypto;
|
|
184
|
+
if (c?.getRandomValues === undefined)
|
|
185
|
+
return null;
|
|
186
|
+
const buf = new Uint8Array(count);
|
|
187
|
+
c.getRandomValues(buf);
|
|
188
|
+
return buf;
|
|
189
|
+
}
|
|
190
|
+
// ── patterns ─────────────────────────────────────────────────────────────────────────
|
|
191
|
+
//
|
|
192
|
+
// WHAT A PATTERN IS: a BOUNDED regular expression, the portable subset of the three host
|
|
193
|
+
// engines, and nothing more. The dialect is defined by what it REFUSES.
|
|
194
|
+
//
|
|
195
|
+
// HOW A CATASTROPHIC ONE IS REFUSED RATHER THAN ALLOWED TO HANG A REQUEST. Three screens,
|
|
196
|
+
// all structural, all run before a single character of the subject is read:
|
|
197
|
+
//
|
|
198
|
+
// 1. STAR HEIGHT 2 is refused - a group that holds an unbounded quantifier and is itself
|
|
199
|
+
// unbounded-quantified, `(a+)+`, `(a*)*`, `(\d+)*`. This is the existing `reDoSProne`
|
|
200
|
+
// screen (regex.ts, and its Swift and Kotlin twins), which the `regex()` validator has
|
|
201
|
+
// used since it was written; the library reuses it rather than growing a second opinion.
|
|
202
|
+
// 2. A BACKREFERENCE is refused, `\1` … `\9`. It is the other classic door to catastrophic
|
|
203
|
+
// backtracking and no structural screen can bound it.
|
|
204
|
+
// 3. LOOKAROUND is refused, `(?=`, `(?!`, `(?<=`, `(?<!`. Not for cost: for AGREEMENT.
|
|
205
|
+
// JavaScript's RegExp, NSRegularExpression and java.util.regex do not answer the same
|
|
206
|
+
// thing for unbounded lookbehind, and a pattern that means one thing on a phone and
|
|
207
|
+
// another on the server is the silent class this whole library exists to end.
|
|
208
|
+
//
|
|
209
|
+
// Plus two lengths: a pattern source past 512 characters and a subject past 1,000,000 are
|
|
210
|
+
// refused, because the honest bound on a host engine with no step counter is the amount of
|
|
211
|
+
// work it can be handed.
|
|
212
|
+
//
|
|
213
|
+
// A REFUSED PATTERN ANSWERS NULL FROM EVERY VERB, and that is the whole point of the design:
|
|
214
|
+
// `test` answers false for "this text does not match" and NULL for "this pattern is not a
|
|
215
|
+
// pattern". A validator that reads a refusal as "no match" passes bad data silently, and
|
|
216
|
+
// silence is what a request deadline turns into a timeout nobody can explain.
|
|
217
|
+
//
|
|
218
|
+
// The final backstop is the evaluation's own wall clock, 2000 ms on all three runners
|
|
219
|
+
// (budget-001.json `wallClockMs`), which a host engine with no step counter cannot be given
|
|
220
|
+
// any other way. That is stated rather than hidden: the screens above are structural, the
|
|
221
|
+
// deadline is the only dynamic bound, and no runner has a per-step regex budget.
|
|
222
|
+
const PATTERN_SOURCE_MAX = 512;
|
|
223
|
+
const PATTERN_SUBJECT_MAX = 1_000_000;
|
|
224
|
+
/** True when the source leaves the bounded dialect. Reads the source with the same
|
|
225
|
+
* escape-and-class walk `reDoSProne` uses, so `\\1` inside a class or an escaped `\\\\1`
|
|
226
|
+
* is not a backreference. */
|
|
227
|
+
function patternRefused(source) {
|
|
228
|
+
if (source.length === 0 || source.length > PATTERN_SOURCE_MAX)
|
|
229
|
+
return true;
|
|
230
|
+
let inClass = false;
|
|
231
|
+
for (let i = 0; i < source.length; i++) {
|
|
232
|
+
const ch = source[i];
|
|
233
|
+
if (ch === "\\") {
|
|
234
|
+
const next = source[i + 1] ?? "";
|
|
235
|
+
if (!inClass && next >= "1" && next <= "9")
|
|
236
|
+
return true; // a backreference
|
|
237
|
+
i += 1;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (inClass) {
|
|
241
|
+
if (ch === "]")
|
|
242
|
+
inClass = false;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (ch === "[") {
|
|
246
|
+
inClass = true;
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (ch === "(" && source[i + 1] === "?") {
|
|
250
|
+
const k = source[i + 2] ?? "";
|
|
251
|
+
if (k === "=" || k === "!")
|
|
252
|
+
return true; // lookahead
|
|
253
|
+
if (k === "<" && (source[i + 3] === "=" || source[i + 3] === "!"))
|
|
254
|
+
return true; // lookbehind
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return reDoSProne(source);
|
|
258
|
+
}
|
|
259
|
+
/** `$1` to `$9`, `$&` for the whole match and `$$` for a literal dollar. Deliberately the
|
|
260
|
+
* small set the three host engines all agree on: `$\`` and `$\u0027` are absent on one of
|
|
261
|
+
* them and a template that means two things is the drift this library exists to end. An
|
|
262
|
+
* unmatched group expands to the empty string, which is what NSRegularExpression does and
|
|
263
|
+
* what the existing `JSERegex.expand` already settled for the language. */
|
|
264
|
+
function expand(template, m) {
|
|
265
|
+
let out = "";
|
|
266
|
+
for (let i = 0; i < template.length; i++) {
|
|
267
|
+
const ch = template[i];
|
|
268
|
+
if (ch !== "$" || i + 1 >= template.length) {
|
|
269
|
+
out += ch;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const next = template[i + 1];
|
|
273
|
+
if (next === "$") {
|
|
274
|
+
out += "$";
|
|
275
|
+
i += 1;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (next === "&") {
|
|
279
|
+
out += m[0];
|
|
280
|
+
i += 1;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (next >= "1" && next <= "9") {
|
|
284
|
+
out += m[Number(next)] ?? "";
|
|
285
|
+
i += 1;
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
out += ch;
|
|
289
|
+
}
|
|
290
|
+
return out;
|
|
291
|
+
}
|
|
292
|
+
/** The compiled pattern, or null when the dialect or a length refuses it. */
|
|
293
|
+
function patternOf(source, subject) {
|
|
294
|
+
if (patternRefused(source) || subject.length > PATTERN_SUBJECT_MAX)
|
|
295
|
+
return null;
|
|
296
|
+
try {
|
|
297
|
+
return new RegExp(source, "g");
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// ── decimal ──────────────────────────────────────────────────────────────────────────
|
|
304
|
+
//
|
|
305
|
+
// WHAT IT GUARANTEES AND OVER WHAT RANGE: EXACT decimal arithmetic on a signed significand
|
|
306
|
+
// of at most 18 significant digits with a scale of 0 to 18 places, and NULL rather than a
|
|
307
|
+
// wrong answer outside that. Nothing rounds unless the author names the rounding.
|
|
308
|
+
//
|
|
309
|
+
// WHY THAT IS THE RIGHT GUARANTEE FOR MONEY. A double cannot hold 0.1, so `0.1 + 0.2` is
|
|
310
|
+
// 0.30000000000000004 and a ledger that sums a million rows is wrong by an amount nobody
|
|
311
|
+
// can predict or reconcile. 18 digits is not a compromise: it is the widest exact decimal
|
|
312
|
+
// that fits a signed 64 bit integer significand, which is the widest exact integer the
|
|
313
|
+
// three runners share (Swift Int64, Kotlin Long, and the same bound enforced here by digit
|
|
314
|
+
// count rather than by the host's number type, so the web agrees with them rather than
|
|
315
|
+
// merely being wider). It is also what every database this language will talk to calls
|
|
316
|
+
// NUMERIC(18, s), and a price that cannot survive the round trip to the column it lives in
|
|
317
|
+
// is not exact in any useful sense. Past that range the answer is null, LOUDLY, because a
|
|
318
|
+
// saturating or wrapping total is the defect this type exists to prevent.
|
|
319
|
+
//
|
|
320
|
+
// A DECIMAL IS ITS TEXT, and that is the second decision. No new value type: the input is
|
|
321
|
+
// text, the output is text, `dsx.decimal.add('0.10', '0.20')` is `'0.30'`. Money crosses
|
|
322
|
+
// JSON, a database column, a payment gateway's API and three native bridges, and text is
|
|
323
|
+
// the only representation that survives all five without passing through a double on the
|
|
324
|
+
// way. It also means the scale is carried rather than inferred: `'10.00'` stays `'10.00'`,
|
|
325
|
+
// which is what a receipt has to print.
|
|
326
|
+
//
|
|
327
|
+
// THE SCALE RULES are SQL's and BigDecimal's, not invented here: add and sub answer the
|
|
328
|
+
// wider scale of the two, mul answers the sum of the scales, and div is the one verb that
|
|
329
|
+
// MUST be told its scale and its rounding because the exact answer may not terminate.
|
|
330
|
+
// Rounding is by name: `half_up` (what a receipt does), `half_even` (banker's, what an
|
|
331
|
+
// auditor does) and `down` (truncation).
|
|
332
|
+
const DECIMAL_DIGITS_MAX = 18;
|
|
333
|
+
const DECIMAL_SCALE_MAX = 18;
|
|
334
|
+
/** Text to a decimal, or null. `digits` is the significand without a sign and without a
|
|
335
|
+
* decimal point, leading zeros stripped; `scale` is how many of its digits are fractional. */
|
|
336
|
+
function decIn(v) {
|
|
337
|
+
const t = string(v).trim();
|
|
338
|
+
if (!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(t))
|
|
339
|
+
return null;
|
|
340
|
+
const neg = t.startsWith("-");
|
|
341
|
+
const body = t.replace(/^[+-]/, "");
|
|
342
|
+
const dot = body.indexOf(".");
|
|
343
|
+
const scale = dot < 0 ? 0 : body.length - dot - 1;
|
|
344
|
+
if (scale > DECIMAL_SCALE_MAX)
|
|
345
|
+
return null;
|
|
346
|
+
const digits = (dot < 0 ? body : body.substring(0, dot) + body.substring(dot + 1))
|
|
347
|
+
.replace(/^0+(?=\d)/, "");
|
|
348
|
+
if (digits.replace(/^0+/, "").length > DECIMAL_DIGITS_MAX)
|
|
349
|
+
return null;
|
|
350
|
+
return { neg: neg && /[1-9]/.test(digits), digits, scale };
|
|
351
|
+
}
|
|
352
|
+
function decText(d) {
|
|
353
|
+
const padded = d.digits.padStart(d.scale + 1, "0");
|
|
354
|
+
const whole = padded.substring(0, padded.length - d.scale);
|
|
355
|
+
const frac = d.scale === 0 ? "" : "." + padded.substring(padded.length - d.scale);
|
|
356
|
+
return (d.neg ? "-" : "") + whole + frac;
|
|
357
|
+
}
|
|
358
|
+
/** The significand as a BigInt, signed. BigInt is an implementation detail of THIS runner and
|
|
359
|
+
* never a JSE value (the law is that an id above 2^53 rides as text); every result is
|
|
360
|
+
* screened back to 18 digits before it leaves, so the web cannot answer a number the two
|
|
361
|
+
* Int64 runners would have refused. */
|
|
362
|
+
function decUnits(d, scale) {
|
|
363
|
+
const n = BigInt(d.digits === "" ? "0" : d.digits) * 10n ** BigInt(scale - d.scale);
|
|
364
|
+
return d.neg ? -n : n;
|
|
365
|
+
}
|
|
366
|
+
function decOut(units, scale) {
|
|
367
|
+
const neg = units < 0n;
|
|
368
|
+
const digits = (neg ? -units : units).toString();
|
|
369
|
+
if (digits.replace(/^0+/, "").length > DECIMAL_DIGITS_MAX || scale > DECIMAL_SCALE_MAX)
|
|
370
|
+
return null;
|
|
371
|
+
return decText({ neg, digits, scale });
|
|
372
|
+
}
|
|
373
|
+
/** One rounding step: `units` is the value scaled to `scale + 1 …` places already divided,
|
|
374
|
+
* `rem` the remainder and `div` the divisor. Named modes only; an unknown name is null. */
|
|
375
|
+
function decRound(q, rem, div, neg, mode) {
|
|
376
|
+
if (rem === 0n)
|
|
377
|
+
return q;
|
|
378
|
+
const twice = rem * 2n;
|
|
379
|
+
if (mode === "down")
|
|
380
|
+
return q;
|
|
381
|
+
if (mode === "half_up")
|
|
382
|
+
return twice >= div ? q + 1n : q;
|
|
383
|
+
if (mode === "half_even") {
|
|
384
|
+
if (twice > div)
|
|
385
|
+
return q + 1n;
|
|
386
|
+
if (twice < div)
|
|
387
|
+
return q;
|
|
388
|
+
return q % 2n === 0n ? q : q + 1n;
|
|
389
|
+
}
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
/** `a` rescaled to `scale` places under `mode`, exactly. */
|
|
393
|
+
function decRescale(d, scale, mode) {
|
|
394
|
+
if (scale < 0 || scale > DECIMAL_SCALE_MAX)
|
|
395
|
+
return null;
|
|
396
|
+
if (scale >= d.scale)
|
|
397
|
+
return decOut(decUnits(d, scale), scale);
|
|
398
|
+
const div = 10n ** BigInt(d.scale - scale);
|
|
399
|
+
const mag = BigInt(d.digits === "" ? "0" : d.digits);
|
|
400
|
+
const q = decRound(mag / div, mag % div, div, d.neg, mode);
|
|
401
|
+
if (q === null)
|
|
402
|
+
return null;
|
|
403
|
+
return decOut(d.neg ? -q : q, scale);
|
|
404
|
+
}
|
|
405
|
+
export const DSXStdlib = {
|
|
406
|
+
/** Every `dsx.<library>.<verb>(...)` call. The name arrives whole: the Parser holds a
|
|
407
|
+
* `dsx.` library name out of its trailing-method split (dispatch.ts `dsxLibCall`).
|
|
408
|
+
* `instant` is the evaluation's latched clock reading, the ONE impure input in the whole
|
|
409
|
+
* library, and every other verb here is a pure function of its arguments. */
|
|
410
|
+
call(name, a, instant) {
|
|
411
|
+
switch (name) {
|
|
412
|
+
// ── bytes ────────────────────────────────────────────────────────────────────
|
|
413
|
+
case "dsx.bytes.fromText":
|
|
414
|
+
return [...new TextEncoder().encode(string(a[0]))];
|
|
415
|
+
case "dsx.bytes.text": {
|
|
416
|
+
const d = bytesIn(a[0]);
|
|
417
|
+
if (d === null)
|
|
418
|
+
return null;
|
|
419
|
+
// STRICT UTF-8. A lone continuation byte is not text, and answering the replacement
|
|
420
|
+
// character would let a corrupt payload pass a round trip that never happened.
|
|
421
|
+
try {
|
|
422
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(new Uint8Array(d));
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
case "dsx.bytes.base64": {
|
|
429
|
+
const d = bytesIn(a[0]);
|
|
430
|
+
return d === null ? null : base64Encode(new Uint8Array(d));
|
|
431
|
+
}
|
|
432
|
+
case "dsx.bytes.fromBase64": {
|
|
433
|
+
const d = base64Decode(string(a[0]));
|
|
434
|
+
return d === null ? null : [...d];
|
|
435
|
+
}
|
|
436
|
+
case "dsx.bytes.hex": {
|
|
437
|
+
const d = bytesIn(a[0]);
|
|
438
|
+
if (d === null)
|
|
439
|
+
return null;
|
|
440
|
+
let out = "";
|
|
441
|
+
for (const b of d)
|
|
442
|
+
out += HEX[b >> 4] + HEX[b & 15];
|
|
443
|
+
return out;
|
|
444
|
+
}
|
|
445
|
+
case "dsx.bytes.fromHex": {
|
|
446
|
+
const t = string(a[0]);
|
|
447
|
+
if (t.length % 2 !== 0)
|
|
448
|
+
return null;
|
|
449
|
+
const out = [];
|
|
450
|
+
for (let i = 0; i < t.length; i += 2) {
|
|
451
|
+
const hi = HEX.indexOf(t[i].toLowerCase());
|
|
452
|
+
const lo = HEX.indexOf(t[i + 1].toLowerCase());
|
|
453
|
+
if (hi < 0 || lo < 0)
|
|
454
|
+
return null;
|
|
455
|
+
out.push((hi << 4) | lo);
|
|
456
|
+
}
|
|
457
|
+
return out;
|
|
458
|
+
}
|
|
459
|
+
case "dsx.bytes.length": {
|
|
460
|
+
const d = bytesIn(a[0]);
|
|
461
|
+
return d === null ? null : d.length;
|
|
462
|
+
}
|
|
463
|
+
case "dsx.bytes.slice": {
|
|
464
|
+
const d = bytesIn(a[0]);
|
|
465
|
+
if (d === null)
|
|
466
|
+
return null;
|
|
467
|
+
const n = d.length;
|
|
468
|
+
const clamp = (raw) => {
|
|
469
|
+
const i = raw < 0 ? n + raw : raw;
|
|
470
|
+
return i < 0 ? 0 : i > n ? n : i;
|
|
471
|
+
};
|
|
472
|
+
const from = a.length > 1 ? clamp(safeInt(number(a[1]) ?? 0)) : 0;
|
|
473
|
+
const to = a.length > 2 ? clamp(safeInt(number(a[2]) ?? 0)) : n;
|
|
474
|
+
return to <= from ? [] : d.slice(from, to);
|
|
475
|
+
}
|
|
476
|
+
// ── clock ────────────────────────────────────────────────────────────────────
|
|
477
|
+
case "dsx.clock.now":
|
|
478
|
+
return instant;
|
|
479
|
+
case "dsx.clock.instant":
|
|
480
|
+
return clockInstant(string(a[0]));
|
|
481
|
+
case "dsx.clock.text": {
|
|
482
|
+
const t = number(a[0]);
|
|
483
|
+
return t === null ? null : clockText(Math.trunc(t));
|
|
484
|
+
}
|
|
485
|
+
case "dsx.clock.add": {
|
|
486
|
+
const t = number(a[0]), amount = number(a[1]);
|
|
487
|
+
const unit = CLOCK_UNITS[string(a[2])];
|
|
488
|
+
if (t === null || amount === null || unit === undefined)
|
|
489
|
+
return null;
|
|
490
|
+
const out = Math.trunc(t) + Math.trunc(amount) * unit;
|
|
491
|
+
return Number.isFinite(out) && Math.abs(out) <= 8.64e15 ? out : null;
|
|
492
|
+
}
|
|
493
|
+
case "dsx.clock.diff": {
|
|
494
|
+
const from = number(a[0]), to = number(a[1]);
|
|
495
|
+
const unit = CLOCK_UNITS[string(a[2])];
|
|
496
|
+
if (from === null || to === null || unit === undefined)
|
|
497
|
+
return null;
|
|
498
|
+
return Math.trunc((Math.trunc(to) - Math.trunc(from)) / unit);
|
|
499
|
+
}
|
|
500
|
+
case "dsx.clock.startOf": {
|
|
501
|
+
const t = number(a[0]);
|
|
502
|
+
if (t === null || !Number.isFinite(t) || Math.abs(t) > 8.64e15)
|
|
503
|
+
return null;
|
|
504
|
+
const ms = Math.trunc(t);
|
|
505
|
+
const unit = string(a[1]);
|
|
506
|
+
const span = CLOCK_UNITS[unit];
|
|
507
|
+
// A FIXED SPAN FLOORS, and it floors toward the epoch on both sides of it, so the
|
|
508
|
+
// start of a day before 1970 is still midnight rather than the following midnight.
|
|
509
|
+
if (span !== undefined)
|
|
510
|
+
return Math.floor(ms / span) * span;
|
|
511
|
+
const day = Math.floor(ms / 86400000);
|
|
512
|
+
const c = civilFromDays(day);
|
|
513
|
+
if (unit === "month")
|
|
514
|
+
return daysFromCivil(c.y, c.m, 1) * 86400000;
|
|
515
|
+
if (unit === "year")
|
|
516
|
+
return daysFromCivil(c.y, 1, 1) * 86400000;
|
|
517
|
+
return null;
|
|
518
|
+
}
|
|
519
|
+
case "dsx.clock.parts": {
|
|
520
|
+
const t = number(a[0]);
|
|
521
|
+
if (t === null || !Number.isFinite(t) || Math.abs(t) > 8.64e15)
|
|
522
|
+
return null;
|
|
523
|
+
const ms = Math.trunc(t);
|
|
524
|
+
const day = Math.floor(ms / 86400000);
|
|
525
|
+
const rest = ms - day * 86400000;
|
|
526
|
+
const c = civilFromDays(day);
|
|
527
|
+
// WEEKDAY IS 1 FOR MONDAY THROUGH 7 FOR SUNDAY (ISO 8601), not 0 for Sunday: the
|
|
528
|
+
// language already reads dates the ISO way and two numbering schemes for one
|
|
529
|
+
// concept is the drift this library exists to end. 1970-01-01 was a Thursday.
|
|
530
|
+
const out = {
|
|
531
|
+
year: c.y, month: c.m, day: c.d,
|
|
532
|
+
hour: Math.floor(rest / 3600000), minute: Math.floor(rest / 60000) % 60,
|
|
533
|
+
second: Math.floor(rest / 1000) % 60, ms: rest % 1000,
|
|
534
|
+
weekday: ((day + 3) % 7 + 7) % 7 + 1,
|
|
535
|
+
};
|
|
536
|
+
return out;
|
|
537
|
+
}
|
|
538
|
+
// ── random ───────────────────────────────────────────────────────────────────
|
|
539
|
+
case "dsx.random.int": {
|
|
540
|
+
const lo = number(a[0]), hi = number(a[1]);
|
|
541
|
+
if (lo === null || hi === null)
|
|
542
|
+
return null;
|
|
543
|
+
const min = Math.ceil(lo), max = Math.floor(hi);
|
|
544
|
+
if (!(min <= max))
|
|
545
|
+
return null;
|
|
546
|
+
const span = max - min + 1;
|
|
547
|
+
if (!Number.isFinite(span) || span > 4294967296)
|
|
548
|
+
return null;
|
|
549
|
+
const buf = cryptoBytes(4);
|
|
550
|
+
if (buf === null)
|
|
551
|
+
return null;
|
|
552
|
+
// REJECTION SAMPLING, not a modulo. A modulo of a 32 bit draw over a span that does
|
|
553
|
+
// not divide 2^32 makes the low values likelier, and a dice roll that favours 1 is
|
|
554
|
+
// a defect nobody notices until a game is unfair.
|
|
555
|
+
const limit = Math.floor(4294967296 / span) * span;
|
|
556
|
+
let draw = ((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]) >>> 0;
|
|
557
|
+
for (let tries = 0; draw >= limit && tries < 64; tries++) {
|
|
558
|
+
const again = cryptoBytes(4);
|
|
559
|
+
if (again === null)
|
|
560
|
+
return null;
|
|
561
|
+
draw = ((again[0] << 24) | (again[1] << 16) | (again[2] << 8) | again[3]) >>> 0;
|
|
562
|
+
}
|
|
563
|
+
return min + (draw % span);
|
|
564
|
+
}
|
|
565
|
+
case "dsx.random.token": {
|
|
566
|
+
const n = number(a[0]);
|
|
567
|
+
const count = n === null ? 16 : safeInt(n);
|
|
568
|
+
if (count < 1 || count > 1024)
|
|
569
|
+
return null;
|
|
570
|
+
const buf = cryptoBytes(count);
|
|
571
|
+
if (buf === null)
|
|
572
|
+
return null;
|
|
573
|
+
let out = "";
|
|
574
|
+
for (const b of buf)
|
|
575
|
+
out += HEX[b >> 4] + HEX[b & 15];
|
|
576
|
+
return out;
|
|
577
|
+
}
|
|
578
|
+
case "dsx.random.uuid": {
|
|
579
|
+
const buf = cryptoBytes(16);
|
|
580
|
+
if (buf === null)
|
|
581
|
+
return null;
|
|
582
|
+
buf[6] = (buf[6] & 0x0f) | 0x40; // version 4
|
|
583
|
+
buf[8] = (buf[8] & 0x3f) | 0x80; // variant 10
|
|
584
|
+
let hex = "";
|
|
585
|
+
for (const b of buf)
|
|
586
|
+
hex += HEX[b >> 4] + HEX[b & 15];
|
|
587
|
+
return `${hex.substring(0, 8)}-${hex.substring(8, 12)}-${hex.substring(12, 16)}-` +
|
|
588
|
+
`${hex.substring(16, 20)}-${hex.substring(20)}`;
|
|
589
|
+
}
|
|
590
|
+
case "dsx.random.stream": {
|
|
591
|
+
const seed = number(a[0]), count = number(a[1]);
|
|
592
|
+
if (seed === null || count === null)
|
|
593
|
+
return null;
|
|
594
|
+
const n = safeInt(count);
|
|
595
|
+
if (n < 0 || n > 4096)
|
|
596
|
+
return null;
|
|
597
|
+
const next = xorshift32(seed);
|
|
598
|
+
const out = [];
|
|
599
|
+
for (let i = 0; i < n; i++)
|
|
600
|
+
out.push(next());
|
|
601
|
+
return out;
|
|
602
|
+
}
|
|
603
|
+
// ── patterns ─────────────────────────────────────────────────────────────────
|
|
604
|
+
case "dsx.pattern.test": {
|
|
605
|
+
const re = patternOf(string(a[0]), string(a[1]));
|
|
606
|
+
return re === null ? null : re.test(string(a[1]));
|
|
607
|
+
}
|
|
608
|
+
case "dsx.pattern.match": {
|
|
609
|
+
const subject = string(a[1]);
|
|
610
|
+
const re = patternOf(string(a[0]), subject);
|
|
611
|
+
if (re === null)
|
|
612
|
+
return null;
|
|
613
|
+
re.lastIndex = 0;
|
|
614
|
+
const m = re.exec(subject);
|
|
615
|
+
// NO MATCH IS THE EMPTY LIST, not null, because null is the refusal. A body that
|
|
616
|
+
// asks whether a pattern is a pattern and a body that asks whether a text matches
|
|
617
|
+
// are asking different questions and must be able to tell the answers apart.
|
|
618
|
+
return m === null ? [] : [...m].map((g) => (g === undefined ? NSNull : g));
|
|
619
|
+
}
|
|
620
|
+
case "dsx.pattern.replace": {
|
|
621
|
+
const subject = string(a[1]);
|
|
622
|
+
const re = patternOf(string(a[0]), subject);
|
|
623
|
+
if (re === null)
|
|
624
|
+
return null;
|
|
625
|
+
const template = string(a[2]);
|
|
626
|
+
re.lastIndex = 0;
|
|
627
|
+
let out = "";
|
|
628
|
+
let from = 0;
|
|
629
|
+
for (let m = re.exec(subject); m !== null; m = re.exec(subject)) {
|
|
630
|
+
out += subject.substring(from, m.index) + expand(template, m);
|
|
631
|
+
from = m.index + m[0].length;
|
|
632
|
+
if (m[0].length === 0) {
|
|
633
|
+
if (re.lastIndex >= subject.length)
|
|
634
|
+
break;
|
|
635
|
+
re.lastIndex += 1;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return out + subject.substring(from);
|
|
639
|
+
}
|
|
640
|
+
case "dsx.pattern.split": {
|
|
641
|
+
const subject = string(a[1]);
|
|
642
|
+
const re = patternOf(string(a[0]), subject);
|
|
643
|
+
if (re === null)
|
|
644
|
+
return null;
|
|
645
|
+
re.lastIndex = 0;
|
|
646
|
+
const out = [];
|
|
647
|
+
let from = 0;
|
|
648
|
+
for (let m = re.exec(subject); m !== null; m = re.exec(subject)) {
|
|
649
|
+
if (m[0].length === 0) {
|
|
650
|
+
if (re.lastIndex >= subject.length)
|
|
651
|
+
break;
|
|
652
|
+
re.lastIndex += 1;
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
out.push(subject.substring(from, m.index));
|
|
656
|
+
from = m.index + m[0].length;
|
|
657
|
+
}
|
|
658
|
+
out.push(subject.substring(from));
|
|
659
|
+
return out;
|
|
660
|
+
}
|
|
661
|
+
// ── decimal ──────────────────────────────────────────────────────────────────
|
|
662
|
+
case "dsx.decimal.text": {
|
|
663
|
+
const d = decIn(a[0]);
|
|
664
|
+
return d === null ? null : decText(d);
|
|
665
|
+
}
|
|
666
|
+
case "dsx.decimal.number": {
|
|
667
|
+
const d = decIn(a[0]);
|
|
668
|
+
// LOSSY BY NAME. This is the one verb that hands a decimal to a double, and it is
|
|
669
|
+
// spelled `number` so a reader of the body can see the exactness end here.
|
|
670
|
+
return d === null ? null : Number(decText(d));
|
|
671
|
+
}
|
|
672
|
+
case "dsx.decimal.add":
|
|
673
|
+
case "dsx.decimal.sub": {
|
|
674
|
+
const x = decIn(a[0]), y = decIn(a[1]);
|
|
675
|
+
if (x === null || y === null)
|
|
676
|
+
return null;
|
|
677
|
+
const scale = Math.max(x.scale, y.scale);
|
|
678
|
+
const sum = name.endsWith("add")
|
|
679
|
+
? decUnits(x, scale) + decUnits(y, scale)
|
|
680
|
+
: decUnits(x, scale) - decUnits(y, scale);
|
|
681
|
+
return decOut(sum, scale);
|
|
682
|
+
}
|
|
683
|
+
case "dsx.decimal.mul": {
|
|
684
|
+
const x = decIn(a[0]), y = decIn(a[1]);
|
|
685
|
+
if (x === null || y === null)
|
|
686
|
+
return null;
|
|
687
|
+
const scale = x.scale + y.scale;
|
|
688
|
+
if (scale > DECIMAL_SCALE_MAX)
|
|
689
|
+
return null;
|
|
690
|
+
return decOut(decUnits(x, x.scale) * decUnits(y, y.scale), scale);
|
|
691
|
+
}
|
|
692
|
+
case "dsx.decimal.div": {
|
|
693
|
+
const x = decIn(a[0]), y = decIn(a[1]);
|
|
694
|
+
const scaleN = number(a[2]);
|
|
695
|
+
if (x === null || y === null || scaleN === null)
|
|
696
|
+
return null;
|
|
697
|
+
const scale = safeInt(scaleN);
|
|
698
|
+
if (scale < 0 || scale > DECIMAL_SCALE_MAX)
|
|
699
|
+
return null;
|
|
700
|
+
const mode = a.length > 3 ? string(a[3]) : "half_up";
|
|
701
|
+
// x / y at `scale` places is Ux * 10^(scale + sy) / (Uy * 10^sx), where U is the
|
|
702
|
+
// significand and s the scale of each side. Written this way both exponents are non
|
|
703
|
+
// negative, so the two Int64 runners do the same integer division this does and no
|
|
704
|
+
// lane needs a negative power of ten.
|
|
705
|
+
const num = decUnits(x, x.scale) * 10n ** BigInt(scale + y.scale);
|
|
706
|
+
const den0 = decUnits(y, y.scale) * 10n ** BigInt(x.scale);
|
|
707
|
+
if (den0 === 0n)
|
|
708
|
+
return null; // a division by zero is not a number
|
|
709
|
+
const neg = (num < 0n) !== (den0 < 0n);
|
|
710
|
+
const mag = num < 0n ? -num : num;
|
|
711
|
+
const den = den0 < 0n ? -den0 : den0;
|
|
712
|
+
const q = decRound(mag / den, mag % den, den, neg, mode);
|
|
713
|
+
if (q === null)
|
|
714
|
+
return null;
|
|
715
|
+
return decOut(neg ? -q : q, scale);
|
|
716
|
+
}
|
|
717
|
+
case "dsx.decimal.round": {
|
|
718
|
+
const d = decIn(a[0]);
|
|
719
|
+
const scaleN = number(a[1]);
|
|
720
|
+
if (d === null || scaleN === null)
|
|
721
|
+
return null;
|
|
722
|
+
return decRescale(d, safeInt(scaleN), a.length > 2 ? string(a[2]) : "half_up");
|
|
723
|
+
}
|
|
724
|
+
case "dsx.decimal.cmp": {
|
|
725
|
+
const x = decIn(a[0]), y = decIn(a[1]);
|
|
726
|
+
if (x === null || y === null)
|
|
727
|
+
return null;
|
|
728
|
+
const scale = Math.max(x.scale, y.scale);
|
|
729
|
+
const d = decUnits(x, scale) - decUnits(y, scale);
|
|
730
|
+
return d === 0n ? 0 : d < 0n ? -1 : 1;
|
|
731
|
+
}
|
|
732
|
+
// ── format ───────────────────────────────────────────────────────────────────
|
|
733
|
+
// `dsx.format.<kind>(value, argument?, locale?)` (proposals/localization-and-caching.md
|
|
734
|
+
// L4): the SAME DSXFormat call a display group makes (message.ts `formatted`), in the
|
|
735
|
+
// ACTIVE locale unless the caller names one, so `dsx.format.currency(p, 'EUR')` and
|
|
736
|
+
// `{p, currency, EUR}` are one function. The active locale is the tracked read
|
|
737
|
+
// (strings.ts installs it), so a binding that formats re-renders on a locale switch.
|
|
738
|
+
case "dsx.format.number":
|
|
739
|
+
case "dsx.format.integer":
|
|
740
|
+
case "dsx.format.percent":
|
|
741
|
+
case "dsx.format.compact":
|
|
742
|
+
case "dsx.format.currency":
|
|
743
|
+
case "dsx.format.date":
|
|
744
|
+
case "dsx.format.time":
|
|
745
|
+
case "dsx.format.relative": {
|
|
746
|
+
if (a[0] === null || a[0] === undefined || a[0] === NSNull)
|
|
747
|
+
return null;
|
|
748
|
+
const kind = name.substring(11);
|
|
749
|
+
const argument = a.length > 1 ? string(a[1]) : "";
|
|
750
|
+
const named = a.length > 2 ? string(a[2]) : "";
|
|
751
|
+
const tag = named.length > 0 ? named : activeLocaleTag();
|
|
752
|
+
const n = number(a[0]);
|
|
753
|
+
if (n === null)
|
|
754
|
+
return string(a[0]);
|
|
755
|
+
if (kind === "date" || kind === "time")
|
|
756
|
+
return DSXFormat.date(n, kind, argument.length === 0 ? "medium" : argument, tag);
|
|
757
|
+
if (kind === "relative")
|
|
758
|
+
return DSXFormat.relative(n, argument.length === 0 ? "day" : argument, tag);
|
|
759
|
+
return DSXFormat.number(n, kind, argument, tag);
|
|
760
|
+
}
|
|
761
|
+
default: return null;
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
};
|
|
765
|
+
//# sourceMappingURL=stdlib.js.map
|