@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/link.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type LinkRoute } from "./bus.ts";
|
|
2
|
+
import type { Dict } from "./jse/values.ts";
|
|
3
|
+
/** A ceiling on a single response. An unbounded read is a memory-exhaustion primitive. */
|
|
4
|
+
export declare const MAX_LINK_RESPONSE_BYTES: number;
|
|
5
|
+
/** Where a call goes: a route of the emitted table under `baseUrl`, or one absolute HTTPS URL. */
|
|
6
|
+
export type LinkTarget = {
|
|
7
|
+
route: Pick<LinkRoute, "chain" | "action" | "method" | "path">;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
} | {
|
|
10
|
+
url: string;
|
|
11
|
+
method?: string;
|
|
12
|
+
};
|
|
13
|
+
/** The request the law prepared: what any transport sends, byte for byte. */
|
|
14
|
+
export interface LinkRequest {
|
|
15
|
+
method: string;
|
|
16
|
+
url: string;
|
|
17
|
+
headers: Record<string, string>;
|
|
18
|
+
body: string | null;
|
|
19
|
+
}
|
|
20
|
+
/** "initial" before the call, "retry" after a 401; answers headers, or throws to refuse the call. */
|
|
21
|
+
export type LinkHeaderSource = ((attempt: "initial" | "retry") => Promise<Record<string, string>> | Record<string, string>) & {
|
|
22
|
+
/** An auth owner may bind this source to its existing session epoch for one call. */
|
|
23
|
+
isCurrent?: () => boolean;
|
|
24
|
+
};
|
|
25
|
+
export interface HttpLinkOptions {
|
|
26
|
+
/** where the server lives — scheme + host (+ optional mount). The token never leaves it. */
|
|
27
|
+
baseUrl: string;
|
|
28
|
+
/** the caller's bearer token, read PER CALL so a refresh is picked up without reinstalling */
|
|
29
|
+
token?: () => string | null | undefined;
|
|
30
|
+
/** explicit headers sent with every call (an API key, a tenant id) */
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
/** fresh headers per call, asked once more after a 401 (an auth provider, a refresh call) */
|
|
33
|
+
headerSource?: LinkHeaderSource;
|
|
34
|
+
/** injected for tests; defaults to the platform fetch */
|
|
35
|
+
fetchImpl?: typeof fetch;
|
|
36
|
+
}
|
|
37
|
+
/** The law, pure: target + arguments + headers → the exact request. Throws the typed refusal. */
|
|
38
|
+
export declare function prepareLinkRequest(target: LinkTarget, args: Dict, headers?: Record<string, string>): LinkRequest;
|
|
39
|
+
/** The law, pure: what a status and body mean. HTTP is the envelope; the status decides. */
|
|
40
|
+
export declare function interpretLinkResponse(status: number, text: string, label: string): unknown;
|
|
41
|
+
/** One answer of a transport: a status and the body text. A transport failure throws. */
|
|
42
|
+
export type LinkSend = (request: LinkRequest) => Promise<{
|
|
43
|
+
status: number;
|
|
44
|
+
text: string;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* The call: headers from the source, prepare, send, interpret; on a 401 with a source, ask the
|
|
48
|
+
* source again and send once more. A source that refuses is `unauthenticated` with no request.
|
|
49
|
+
*/
|
|
50
|
+
export declare function runLink(target: LinkTarget, args: Dict, options: {
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
headerSource?: LinkHeaderSource;
|
|
53
|
+
}, send: LinkSend): Promise<unknown>;
|
|
54
|
+
/** The platform fetch as a LinkSend: no redirect is followed and ambient credentials never ride. */
|
|
55
|
+
export declare function fetchSend(doFetch: typeof fetch): LinkSend;
|
|
56
|
+
export declare function createHttpLink(options: HttpLinkOptions): (route: LinkRoute, args: Dict) => Promise<unknown>;
|
|
57
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AA8BA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAU5C,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB,QAAkB,CAAC;AAEvD,kGAAkG;AAClG,MAAM,MAAM,UAAU,GAClB;IAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACnF;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,qGAAqG;AACrG,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG;IAC5H,qFAAqF;IACrF,SAAS,CAAC,EAAE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EAAE,eAAe,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC,CAiB3G"}
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
//
|
|
2
|
+
// link.ts — the HTTP filler for the client link seam (full-stack.md T2, "the client link").
|
|
3
|
+
//
|
|
4
|
+
// `bus.ts` declares WHERE the link sits in the resolution ladder and knows no transport. This
|
|
5
|
+
// is a transport: the one an ordinary HTTPS deployment uses. A surface installs it at boot
|
|
6
|
+
//
|
|
7
|
+
// LinkSeam.routes = linkRoutes; // the emitted table
|
|
8
|
+
// LinkSeam.invoke = createHttpLink({ baseUrl, token }); // how to reach it
|
|
9
|
+
//
|
|
10
|
+
// and from then on `dsx.module.orders.create({…})` reaches the server without any call site
|
|
11
|
+
// naming a URL, a method, or a header. Moving an action between client and server changes the
|
|
12
|
+
// build, never the markup — which is the entire promise the ladder exists to keep.
|
|
13
|
+
//
|
|
14
|
+
// WHAT THIS FILE REFUSES TO DO, and why each refusal is load-bearing:
|
|
15
|
+
//
|
|
16
|
+
// • It never chooses a route. It is handed one from the emitted table, which the gateway
|
|
17
|
+
// already filtered — so an internal endpoint cannot be reached from here even by a caller
|
|
18
|
+
// who knows its path, because no LinkRoute for it exists to be handed over.
|
|
19
|
+
// • It never sends the bearer token anywhere but `baseUrl`'s own origin. The origin is fixed
|
|
20
|
+
// at install; a route path cannot escape it (see `resolveUrl`). A link that followed a
|
|
21
|
+
// redirect or an absolute path would post the user's credential to whoever asked.
|
|
22
|
+
// • It never attaches anything implicitly. No cookie rides (`credentials: "omit"`),
|
|
23
|
+
// no token the caller did not hand over. Native runtimes cannot see a
|
|
24
|
+
// page's cookies at all, so an implicit cookie would make the same call mean two things.
|
|
25
|
+
// • It never invents a failure. The server answers in a closed vocabulary
|
|
26
|
+
// (`unauthenticated` · `invalid_request` · `handler_failed` · …); those pass through as the
|
|
27
|
+
// call's reason. Only a genuine transport failure becomes `unreachable` — and that mapping
|
|
28
|
+
// lives in bus.ts, not here, so there is one place that decides it.
|
|
29
|
+
//
|
|
30
|
+
import { LinkSeam, ModuleCallError } from "./bus.js";
|
|
31
|
+
// THE ONE LINK LAW (corpus OpenSource/Conformance/link/http.json; twins
|
|
32
|
+
// Engine/Swift/ClientLinkLaw.swift and Engine/Kotlin/core/.../ClientLinkLaw.kt). A call names a
|
|
33
|
+
// TARGET: a DSX server route from the emitted table plus the base URL, or any HTTPS endpoint on any
|
|
34
|
+
// origin (a Supabase function, a Firebase HTTPS function, an own API). Headers are explicit; a header
|
|
35
|
+
// SOURCE (an auth provider, a declared refresh call) is asked before the call and once more after a
|
|
36
|
+
// 401, which is the only retry. `prepareLinkRequest` and `interpretLinkResponse` are pure, so a
|
|
37
|
+
// background uploader (iOS background URLSession, Android WorkManager) runs the same law.
|
|
38
|
+
/** A ceiling on a single response. An unbounded read is a memory-exhaustion primitive. */
|
|
39
|
+
export const MAX_LINK_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
40
|
+
/** Methods that carry a JSON body; everything else puts its arguments in the query string. */
|
|
41
|
+
const BODY_METHODS = new Set(["POST", "PUT", "PATCH"]);
|
|
42
|
+
/** encodeURIComponent's unreserved set, spelled so the twins can copy it exactly. */
|
|
43
|
+
function encodeSegment(value) {
|
|
44
|
+
return encodeURIComponent(value);
|
|
45
|
+
}
|
|
46
|
+
/** application/x-www-form-urlencoded, the URLSearchParams serializer. */
|
|
47
|
+
function encodeQueryPart(value) {
|
|
48
|
+
return encodeURIComponent(value).replace(/[!'()~]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase()).replace(/%20/g, "+");
|
|
49
|
+
}
|
|
50
|
+
function queryValue(key, value) {
|
|
51
|
+
if (typeof value === "string")
|
|
52
|
+
return value;
|
|
53
|
+
if (typeof value === "boolean")
|
|
54
|
+
return value ? "true" : "false";
|
|
55
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
56
|
+
return String(value);
|
|
57
|
+
throw new ModuleCallError("invalid_request", `the query argument "${key}" must be a string, number or boolean`, { param: key });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Fill `:param` placeholders from `args`, and report which keys were consumed.
|
|
61
|
+
*
|
|
62
|
+
* A consumed key must NOT also ride in the body or query: sending `id` twice invites the server
|
|
63
|
+
* and the client to disagree about which one is authoritative.
|
|
64
|
+
*/
|
|
65
|
+
function fillPath(path, args) {
|
|
66
|
+
const consumed = new Set();
|
|
67
|
+
const filled = path
|
|
68
|
+
.split("/")
|
|
69
|
+
.map((segment) => {
|
|
70
|
+
if (!segment.startsWith(":") || segment.length < 2)
|
|
71
|
+
return segment;
|
|
72
|
+
const name = segment.slice(1);
|
|
73
|
+
const value = args[name];
|
|
74
|
+
if (value === undefined || value === null) {
|
|
75
|
+
throw new ModuleCallError("invalid_request", `the route needs a "${name}" argument`, { param: name });
|
|
76
|
+
}
|
|
77
|
+
consumed.add(name);
|
|
78
|
+
// encode: a path argument is DATA and must never add segments or a query of its own
|
|
79
|
+
return encodeSegment(String(value));
|
|
80
|
+
})
|
|
81
|
+
.join("/");
|
|
82
|
+
return { path: filled, consumed };
|
|
83
|
+
}
|
|
84
|
+
/** scheme://host[:port] + path of an absolute http(s) URL, or null. Plain HTTP only for this device. */
|
|
85
|
+
function parseAbsolute(raw) {
|
|
86
|
+
let url;
|
|
87
|
+
try {
|
|
88
|
+
url = new URL(raw);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
if (url.username !== "" || url.password !== "")
|
|
94
|
+
return null;
|
|
95
|
+
if (url.protocol === "https:")
|
|
96
|
+
return url;
|
|
97
|
+
if (url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))
|
|
98
|
+
return url;
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
/** "." or "..", also percent-encoded: a URL parser would walk it up the path. */
|
|
102
|
+
function isDotSegment(segment) {
|
|
103
|
+
const s = segment.toLowerCase().replace(/%2e/g, ".");
|
|
104
|
+
return s === "." || s === "..";
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Join the fixed base to a route path, and refuse anything that would leave the origin.
|
|
108
|
+
*
|
|
109
|
+
* The emitted table only ever holds `/`-rooted paths validated by the emitter, so this cannot
|
|
110
|
+
* trigger in a healthy build — which is exactly why it is here: a link that silently followed a
|
|
111
|
+
* path to another host would carry the bearer token with it. Dot segments and backslashes are
|
|
112
|
+
* refused outright so every runtime agrees without a URL parser's normalisation.
|
|
113
|
+
*/
|
|
114
|
+
function resolveRoute(baseUrl, path) {
|
|
115
|
+
if (baseUrl === "")
|
|
116
|
+
throw new ModuleCallError("unreachable", "the link has no base URL (Core/Server serverUrl)", { path });
|
|
117
|
+
const base = parseAbsolute(baseUrl);
|
|
118
|
+
if (base === null)
|
|
119
|
+
throw new ModuleCallError("invalid_request", "the link base URL must be an https URL", { path });
|
|
120
|
+
const segments = path.split("/").slice(1);
|
|
121
|
+
if (!path.startsWith("/") || path.startsWith("//") || path.includes("\\") || segments.some(isDotSegment)) {
|
|
122
|
+
throw new ModuleCallError("invalid_request", `the route "${path}" resolves outside ${base.origin}`, { path });
|
|
123
|
+
}
|
|
124
|
+
return new URL(base.origin + base.pathname.replace(/\/$/, "") + path);
|
|
125
|
+
}
|
|
126
|
+
/** The law, pure: target + arguments + headers → the exact request. Throws the typed refusal. */
|
|
127
|
+
export function prepareLinkRequest(target, args, headers = {}) {
|
|
128
|
+
let method;
|
|
129
|
+
let url;
|
|
130
|
+
const rest = {};
|
|
131
|
+
if ("route" in target) {
|
|
132
|
+
method = target.route.method.toUpperCase();
|
|
133
|
+
const { path, consumed } = fillPath(target.route.path, args);
|
|
134
|
+
url = resolveRoute(target.baseUrl, path);
|
|
135
|
+
for (const [key, value] of Object.entries(args))
|
|
136
|
+
if (!consumed.has(key))
|
|
137
|
+
rest[key] = value;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
method = (target.method ?? "POST").toUpperCase();
|
|
141
|
+
const parsed = parseAbsolute(target.url);
|
|
142
|
+
if (parsed === null)
|
|
143
|
+
throw new ModuleCallError("invalid_request", "the link URL must be an https URL with no credentials in it", {});
|
|
144
|
+
url = parsed;
|
|
145
|
+
url.hash = "";
|
|
146
|
+
Object.assign(rest, args);
|
|
147
|
+
}
|
|
148
|
+
const out = { accept: "application/json" };
|
|
149
|
+
let body = null;
|
|
150
|
+
if (BODY_METHODS.has(method)) {
|
|
151
|
+
out["content-type"] = "application/json";
|
|
152
|
+
body = JSON.stringify(rest);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const pairs = [];
|
|
156
|
+
for (const key of Object.keys(rest).sort()) {
|
|
157
|
+
const value = rest[key];
|
|
158
|
+
if (value === undefined || value === null)
|
|
159
|
+
continue;
|
|
160
|
+
pairs.push(encodeQueryPart(key) + "=" + encodeQueryPart(queryValue(key, value)));
|
|
161
|
+
}
|
|
162
|
+
if (pairs.length > 0)
|
|
163
|
+
url.search = (url.search === "" ? "" : url.search.slice(1) + "&") + pairs.join("&");
|
|
164
|
+
}
|
|
165
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
166
|
+
if (/[\r\n]/.test(name) || /[\r\n]/.test(value) || name === "") {
|
|
167
|
+
throw new ModuleCallError("invalid_request", `the header "${name.replace(/[\r\n]/g, " ")}" is not a valid header`, {});
|
|
168
|
+
}
|
|
169
|
+
out[name.toLowerCase()] = value;
|
|
170
|
+
}
|
|
171
|
+
return { method, url: url.toString(), headers: out, body };
|
|
172
|
+
}
|
|
173
|
+
/** The law, pure: what a status and body mean. HTTP is the envelope; the status decides. */
|
|
174
|
+
export function interpretLinkResponse(status, text, label) {
|
|
175
|
+
if (new TextEncoder().encode(text).byteLength > MAX_LINK_RESPONSE_BYTES) {
|
|
176
|
+
throw new ModuleCallError("handler_failed", `the response exceeds ${MAX_LINK_RESPONSE_BYTES} bytes`, { status });
|
|
177
|
+
}
|
|
178
|
+
let body;
|
|
179
|
+
try {
|
|
180
|
+
body = text === "" ? null : JSON.parse(text);
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
// Not JSON at all — a proxy error page, a captive portal, an HTML 502. Reporting the body
|
|
184
|
+
// would leak whatever it contains into the caller's error; the status is enough.
|
|
185
|
+
throw new ModuleCallError("handler_failed", `the server answered ${status} with a non-JSON body`, { status });
|
|
186
|
+
}
|
|
187
|
+
// A success is 2xx carrying the handler's value VERBATIM; a failure is its real status carrying
|
|
188
|
+
// `{error: {code, message}}` (or the flat `{error: "<code>", message}` an older server answers).
|
|
189
|
+
// The STATUS decides, never a field in the body: a handler may return a payload containing
|
|
190
|
+
// `error`. A redirect is never followed (it would carry the credential elsewhere) and fails here.
|
|
191
|
+
if (status < 200 || status > 299) {
|
|
192
|
+
const record = typeof body === "object" && body !== null ? body : {};
|
|
193
|
+
const nested = record["error"] !== null && typeof record["error"] === "object" && !Array.isArray(record["error"])
|
|
194
|
+
? record["error"] : null;
|
|
195
|
+
const code = nested !== null ? nested["code"] : record["error"];
|
|
196
|
+
const said = nested !== null ? nested["message"] : record["message"];
|
|
197
|
+
const reason = typeof code === "string" && code !== "" ? code : "handler_failed";
|
|
198
|
+
const message = typeof said === "string" && said !== "" ? said : `the server refused ${label}`;
|
|
199
|
+
throw new ModuleCallError(reason, message, { status });
|
|
200
|
+
}
|
|
201
|
+
return body;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The call: headers from the source, prepare, send, interpret; on a 401 with a source, ask the
|
|
205
|
+
* source again and send once more. A source that refuses is `unauthenticated` with no request.
|
|
206
|
+
*/
|
|
207
|
+
export async function runLink(target, args, options, send) {
|
|
208
|
+
const label = "route" in target ? `${target.route.chain}.${target.route.action}` : "the request";
|
|
209
|
+
// Serialize the operation before asking auth anything. Neither a delayed source nor a 401
|
|
210
|
+
// may observe later mutations of the caller's nested objects, arrays or typed bytes.
|
|
211
|
+
const snapshot = prepareLinkRequest(target, args, options.headers ?? {});
|
|
212
|
+
const source = options.headerSource;
|
|
213
|
+
const attempt = async (which) => {
|
|
214
|
+
let fresh = {};
|
|
215
|
+
if (source) {
|
|
216
|
+
try {
|
|
217
|
+
fresh = await source(which);
|
|
218
|
+
if (source.isCurrent?.() === false)
|
|
219
|
+
throw new Error("the session changed");
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
throw new ModuleCallError("unauthenticated", e instanceof Error ? e.message : "the header source refused", { attempt: which });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// Normalize each layer before merging: source headers override installer headers even
|
|
226
|
+
// when their spelling differs. Never let fetch combine two Authorization values.
|
|
227
|
+
const headers = {};
|
|
228
|
+
for (const layer of [snapshot.headers, fresh]) {
|
|
229
|
+
for (const [name, value] of Object.entries(layer)) {
|
|
230
|
+
if (name === "" || /[\r\n]/.test(name + value)) {
|
|
231
|
+
throw new ModuleCallError("invalid_request", "a header is not a valid header", {});
|
|
232
|
+
}
|
|
233
|
+
headers[name.toLowerCase()] = value;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const request = { ...snapshot, headers };
|
|
237
|
+
const answer = await send(request);
|
|
238
|
+
if (answer.status === 401 && which === "initial" && source)
|
|
239
|
+
return RETRY;
|
|
240
|
+
return interpretLinkResponse(answer.status, answer.text, label);
|
|
241
|
+
};
|
|
242
|
+
const first = await attempt("initial");
|
|
243
|
+
return first === RETRY ? attempt("retry") : first;
|
|
244
|
+
}
|
|
245
|
+
const RETRY = Symbol("retry");
|
|
246
|
+
/** The platform fetch as a LinkSend: no redirect is followed and ambient credentials never ride. */
|
|
247
|
+
export function fetchSend(doFetch) {
|
|
248
|
+
return async (request) => {
|
|
249
|
+
const controller = new AbortController();
|
|
250
|
+
let reader;
|
|
251
|
+
let expired = false;
|
|
252
|
+
let timer;
|
|
253
|
+
const deadline = new Promise((_, reject) => {
|
|
254
|
+
timer = setTimeout(() => {
|
|
255
|
+
expired = true;
|
|
256
|
+
controller.abort();
|
|
257
|
+
void reader?.cancel().catch(() => { });
|
|
258
|
+
reject(new ModuleCallError("unreachable", "the request timed out", {}));
|
|
259
|
+
}, 30_000);
|
|
260
|
+
});
|
|
261
|
+
const init = { method: request.method, headers: request.headers, credentials: "omit", redirect: "manual", signal: controller.signal };
|
|
262
|
+
if (request.body !== null)
|
|
263
|
+
init.body = request.body;
|
|
264
|
+
const receive = async () => {
|
|
265
|
+
const response = await doFetch(request.url, init);
|
|
266
|
+
if (expired) {
|
|
267
|
+
void response.body?.cancel().catch(() => { });
|
|
268
|
+
throw new ModuleCallError("unreachable", "the request timed out", {});
|
|
269
|
+
}
|
|
270
|
+
// A browser hands a manual redirect over as an opaque response with status 0.
|
|
271
|
+
const status = response.type === "opaqueredirect" ? 302 : response.status;
|
|
272
|
+
if (response.body === null)
|
|
273
|
+
return { status, text: "" };
|
|
274
|
+
reader = response.body.getReader();
|
|
275
|
+
let bytes = new Uint8Array(0);
|
|
276
|
+
let size = 0;
|
|
277
|
+
try {
|
|
278
|
+
while (true) {
|
|
279
|
+
const chunk = await reader.read();
|
|
280
|
+
if (expired)
|
|
281
|
+
throw new ModuleCallError("unreachable", "the request timed out", {});
|
|
282
|
+
if (chunk.done)
|
|
283
|
+
break;
|
|
284
|
+
if (chunk.value.byteLength > MAX_LINK_RESPONSE_BYTES - size) {
|
|
285
|
+
// Cancel before retaining the excess chunk or decoding any of the body.
|
|
286
|
+
void reader.cancel().catch(() => { });
|
|
287
|
+
controller.abort();
|
|
288
|
+
throw new ModuleCallError("handler_failed", `the response exceeds ${MAX_LINK_RESPONSE_BYTES} bytes`, { status });
|
|
289
|
+
}
|
|
290
|
+
const end = size + chunk.value.byteLength;
|
|
291
|
+
if (end > bytes.length) {
|
|
292
|
+
const grown = new Uint8Array(Math.min(MAX_LINK_RESPONSE_BYTES, Math.max(end, 65536, bytes.length * 2)));
|
|
293
|
+
grown.set(bytes.subarray(0, size));
|
|
294
|
+
bytes = grown;
|
|
295
|
+
}
|
|
296
|
+
bytes.set(chunk.value, size);
|
|
297
|
+
size = end;
|
|
298
|
+
}
|
|
299
|
+
return { status, text: new TextDecoder().decode(bytes.subarray(0, size)) };
|
|
300
|
+
}
|
|
301
|
+
finally {
|
|
302
|
+
reader.releaseLock();
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
try {
|
|
306
|
+
return await Promise.race([receive(), deadline]);
|
|
307
|
+
}
|
|
308
|
+
finally {
|
|
309
|
+
clearTimeout(timer);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
export function createHttpLink(options) {
|
|
314
|
+
const doFetch = options.fetchImpl ?? globalThis.fetch;
|
|
315
|
+
if (typeof doFetch !== "function") {
|
|
316
|
+
throw new Error("@despia-native/kernel: createHttpLink needs a fetch implementation on this platform");
|
|
317
|
+
}
|
|
318
|
+
const send = fetchSend(doFetch);
|
|
319
|
+
return async (route, args) => {
|
|
320
|
+
const headers = { ...(options.headers ?? {}) };
|
|
321
|
+
const token = options.token?.();
|
|
322
|
+
// Attached only for THIS origin — the route resolver refuses anything else.
|
|
323
|
+
if (typeof token === "string" && token !== "")
|
|
324
|
+
headers.authorization = `Bearer ${token}`;
|
|
325
|
+
const linkOptions = { headers };
|
|
326
|
+
// The installer's own source, else the one the app opted into on the seam, read per call.
|
|
327
|
+
const source = options.headerSource ?? LinkSeam.headerSourceForCall?.() ?? LinkSeam.headerSource;
|
|
328
|
+
if (source !== null)
|
|
329
|
+
linkOptions.headerSource = source;
|
|
330
|
+
return runLink({ route, baseUrl: options.baseUrl }, args, linkOptions, send);
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=link.js.map
|
package/dist/link.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,6FAA6F;AAC7F,EAAE;AACF,+FAA+F;AAC/F,4FAA4F;AAC5F,EA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AAmB,EAAE,EAAE,IAAI,QAAQ,CAAC,YAAY,CAAC;QACjG,IAAI,MAAM,KAAK,IAAI;YAAE,WAAW,CAAC,YAAY,GAAG,MAAM,CAAC;QACvD,OAAO,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** A single response ceiling. An unbounded read of an attacker-chosen URL is a memory
|
|
2
|
+
* exhaustion primitive, and the head is all a preview ever needs. */
|
|
3
|
+
export declare const PREVIEW_MAX_BYTES = 262144;
|
|
4
|
+
/** Redirect chains terminate. Five is what browsers and curl converge on. */
|
|
5
|
+
export declare const PREVIEW_MAX_REDIRECTS = 5;
|
|
6
|
+
export declare const PREVIEW_DEFAULT_TIMEOUT_MS = 8000;
|
|
7
|
+
export declare const PREVIEW_MIN_TIMEOUT_MS = 1000;
|
|
8
|
+
export declare const PREVIEW_MAX_TIMEOUT_MS = 30000;
|
|
9
|
+
/** Why a URL was refused before a single byte moved. */
|
|
10
|
+
export type PreviewRefusal = "invalid_url" | "unsupported_scheme" | "credentials_in_url";
|
|
11
|
+
/** A validated fetch target, split the way every renderer needs it. */
|
|
12
|
+
export interface PreviewTarget {
|
|
13
|
+
/** the normalized absolute URL — lowercase scheme and host, default port dropped */
|
|
14
|
+
readonly url: string;
|
|
15
|
+
/** `scheme://host[:port]` — the only origin a relative reference may resolve into */
|
|
16
|
+
readonly origin: string;
|
|
17
|
+
/** host[:port], lowercase */
|
|
18
|
+
readonly host: string;
|
|
19
|
+
/** `http` or `https`, lowercase */
|
|
20
|
+
readonly scheme: string;
|
|
21
|
+
/** path, always leading-slash; query and fragment excluded */
|
|
22
|
+
readonly path: string;
|
|
23
|
+
}
|
|
24
|
+
export interface LinkPreview {
|
|
25
|
+
readonly title: string;
|
|
26
|
+
readonly description: string;
|
|
27
|
+
readonly image: string;
|
|
28
|
+
readonly siteName: string;
|
|
29
|
+
readonly favicon: string;
|
|
30
|
+
readonly type: string;
|
|
31
|
+
readonly canonical: string;
|
|
32
|
+
}
|
|
33
|
+
export type PreviewResult<T> = {
|
|
34
|
+
ok: true;
|
|
35
|
+
value: T;
|
|
36
|
+
} | {
|
|
37
|
+
ok: false;
|
|
38
|
+
error: PreviewRefusal;
|
|
39
|
+
};
|
|
40
|
+
/** Clamp an author-supplied timeout into the band the module will actually honour. A value
|
|
41
|
+
* outside the band is clamped rather than refused: a caller asking for 5 minutes wants
|
|
42
|
+
* "as long as you can", not an error. */
|
|
43
|
+
export declare function clampPreviewTimeout(raw: unknown): number;
|
|
44
|
+
/**
|
|
45
|
+
* Parse and normalize an absolute http(s) URL.
|
|
46
|
+
*
|
|
47
|
+
* Refuses, loudly and before the network:
|
|
48
|
+
* • anything that is not http or https — `file:`, `data:` and custom schemes are how a
|
|
49
|
+
* preview scraper becomes a local-file exfiltration gadget;
|
|
50
|
+
* • userinfo (`https://user:pass@host/`) — the credential would be logged, cached and
|
|
51
|
+
* handed to a redirect target.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolvePreviewTarget(raw: unknown): PreviewResult<PreviewTarget>;
|
|
54
|
+
/** RFC 3986 §5.2.4 remove_dot_segments, restricted to the absolute-path case we ever hold. */
|
|
55
|
+
export declare function normalizePreviewPath(path: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a reference found in a document against the document's own URL.
|
|
58
|
+
*
|
|
59
|
+
* Returns "" for anything that cannot become an absolute http(s) URL — an empty href, a
|
|
60
|
+
* `javascript:` handler, a `data:` blob. "" is the typed absence for every string field in a
|
|
61
|
+
* LinkPreview, so a hostile page cannot smuggle a scheme through the image slot.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolvePreviewReference(base: PreviewTarget, ref: unknown): string;
|
|
64
|
+
/** What a scan of a document head found, before precedence is applied. */
|
|
65
|
+
export interface PreviewTags {
|
|
66
|
+
/** `<meta property|name=…>` → content, keyed by the LOWERCASED property */
|
|
67
|
+
readonly meta: Readonly<Record<string, string>>;
|
|
68
|
+
/** `<link rel=…>` → href, keyed by the LOWERCASED rel; first occurrence wins */
|
|
69
|
+
readonly links: Readonly<Record<string, string>>;
|
|
70
|
+
/** the `<title>` element's text, entity-decoded and collapsed */
|
|
71
|
+
readonly documentTitle: string;
|
|
72
|
+
}
|
|
73
|
+
/** Decode the entity set a real page actually uses in a title. Unknown entities are left
|
|
74
|
+
* verbatim rather than dropped: `AT&T` written badly must not become `ATT`. */
|
|
75
|
+
export declare function decodePreviewEntities(input: string): string;
|
|
76
|
+
/** Collapse the whitespace a hand-written `<title>` carries across three source lines. */
|
|
77
|
+
export declare function collapsePreviewText(input: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Scan a document for its preview tags. Deliberately NOT a DOM parse: this runs over the
|
|
80
|
+
* first 256 KB of an untrusted response on three runtimes, so it is a forward character
|
|
81
|
+
* scan that never backtracks, never executes anything, and stops the moment `<body>` or
|
|
82
|
+
* `</head>` proves there is nothing left worth reading.
|
|
83
|
+
*
|
|
84
|
+
* FIRST OCCURRENCE WINS for every key. A page that ships `og:image` twice means the first
|
|
85
|
+
* one; the alternative (last wins) lets an injected comment thread override the publisher.
|
|
86
|
+
*/
|
|
87
|
+
export declare function scanPreviewTags(html: string): PreviewTags;
|
|
88
|
+
/** The registrable-looking part of a host, used as the site-name fallback. `www.` is dropped
|
|
89
|
+
* because no publisher calls itself "www.example.com". */
|
|
90
|
+
export declare function previewSiteFallback(host: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Fold a scanned document into the preview a caller receives. THE PRECEDENCE IS THE PRODUCT
|
|
93
|
+
* and is pinned case by case in the corpus:
|
|
94
|
+
*
|
|
95
|
+
* title og:title → twitter:title → <title> → ""
|
|
96
|
+
* description og:description → twitter:description → description → ""
|
|
97
|
+
* image og:image → og:image:url → og:image:secure_url → twitter:image
|
|
98
|
+
* → twitter:image:src → link[rel=image_src] → "" (resolved absolute)
|
|
99
|
+
* siteName og:site_name → application-name → host without `www.`
|
|
100
|
+
* favicon link[rel=icon] → shortcut icon → apple-touch-icon → mask-icon
|
|
101
|
+
* → <origin>/favicon.ico (resolved absolute)
|
|
102
|
+
* type og:type → "website"
|
|
103
|
+
* canonical link[rel=canonical] → og:url → the request URL (resolved absolute)
|
|
104
|
+
*
|
|
105
|
+
* Every field is a String and absence is "", never null: a preview card renders the same on
|
|
106
|
+
* three renderers only if "no image" has one spelling.
|
|
107
|
+
*/
|
|
108
|
+
export declare function foldLinkPreview(tags: PreviewTags, target: PreviewTarget): LinkPreview;
|
|
109
|
+
/** The whole read, once the bytes are in hand. The module facets differ only in how they
|
|
110
|
+
* got the bytes. */
|
|
111
|
+
export declare function parseLinkPreview(html: string, target: PreviewTarget): LinkPreview;
|
|
112
|
+
/** Human copy for each refusal, so three renderers apologise with one sentence. */
|
|
113
|
+
export declare const PREVIEW_MESSAGES: Readonly<Record<PreviewRefusal, string>>;
|
|
114
|
+
//# sourceMappingURL=linkpreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkpreview.d.ts","sourceRoot":"","sources":["../src/linkpreview.ts"],"names":[],"mappings":"AAsBA;sEACsE;AACtE,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAExC,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAC/C,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAE5C,wDAAwD;AACxD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AAEzF,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,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