@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
package/dist/bus.js
ADDED
|
@@ -0,0 +1,2647 @@
|
|
|
1
|
+
//
|
|
2
|
+
// bus.ts - the DSX native message bus, web twin: modules provide, surfaces consume.
|
|
3
|
+
// Mirrors Module.kt / Context.kt in contract: a scheme ROUTE TABLE (one module answers
|
|
4
|
+
// under its own scheme, the GeneratedModuleSchemes twin), envelope error codes from
|
|
5
|
+
// OpenSource/Conformance/api/wire-contract.json (not_loaded / unsupported_platform),
|
|
6
|
+
// fire/hook/claim/collect, declared state under `global.<scheme>.<var>`.
|
|
7
|
+
//
|
|
8
|
+
// Constitution: the kernel names no module — everything arrives through register().
|
|
9
|
+
// Export-presence is the web's file-presence gate (/web/03): a module without a web
|
|
10
|
+
// entry is `dsx.has() === false`, never a crash.
|
|
11
|
+
//
|
|
12
|
+
// Diagnostics: EVERY call failure (excluded / not_loaded / unsupported_platform /
|
|
13
|
+
// unknown_action / a handler's error settle) reports to the ONE funnel before rejecting — a console.warn
|
|
14
|
+
// plus the `module.callFailed` bus event ({ scheme, action, code, data?, delivered }) —
|
|
15
|
+
// the three-renderer contract shared with Context.swift / Context.kt. `.post` failures
|
|
16
|
+
// are `delivered: false`: the call site discards the rejection by shape, so the funnel
|
|
17
|
+
// is the only place they can surface. Nothing on the bus fails invisibly.
|
|
18
|
+
//
|
|
19
|
+
import { ELEMENT_DETACHED, ELEMENT_REQUIRED, isDsxElement } from "./element.js";
|
|
20
|
+
import { DSXState, noteGlobalRead } from "./store.js";
|
|
21
|
+
import { ReadCache } from "./read-cache.js";
|
|
22
|
+
import { markCallValue } from "./call-value.js";
|
|
23
|
+
import { publishDeclaredContext } from "./state-primitive.js";
|
|
24
|
+
import { JSESeams, isDesktopOS } from "./jse/jse.js";
|
|
25
|
+
import { NSNull, isDict, plainNulls, string, truthy } from "./jse/values.js";
|
|
26
|
+
import { facetTablesFor, openedFor } from "./boot-tables.js";
|
|
27
|
+
/** The once-read snapshot of `__DSX_OPTIONAL_BOOT_TABLES__` (boot-tables-flag.ts says why it is its own module). */
|
|
28
|
+
import { BOOT_TABLES_ENABLED } from "./boot-tables-flag.js";
|
|
29
|
+
import { DSXLogs, reportLog } from "./logs.js";
|
|
30
|
+
import { DEBUG_BUILD, SETTING_REFUSED, bootArguments, offeredSettings, settingDiagnosticLine, settingsVerdict, } from "./settings-plane.js";
|
|
31
|
+
import { formatLogArgs } from "./jse/core.js";
|
|
32
|
+
import { proxyAdmits } from "./proxy-denylist.js";
|
|
33
|
+
import { AvailabilityProbes, CONDITIONS, DEFAULT_AXES, readiness as readinessFold, resolve as resolveMember, rollUp as rollUpAnswers, } from "./availability.js";
|
|
34
|
+
import { EXPLAIN_CATALOG } from "./availability-explain.js";
|
|
35
|
+
import { DSXStrings } from "./strings.js";
|
|
36
|
+
import { publicConfigTable, readPublicConfig } from "./public-config.js";
|
|
37
|
+
export class ModuleCallError extends Error {
|
|
38
|
+
code;
|
|
39
|
+
data;
|
|
40
|
+
constructor(code, message, data = null) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.code = code;
|
|
43
|
+
this.data = data;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export const LinkSeam = {
|
|
47
|
+
/** the emitted client link table; empty until a surface installs it */
|
|
48
|
+
routes: [],
|
|
49
|
+
/** the platform transport; null = no link, and the ladder falls through unchanged */
|
|
50
|
+
invoke: null,
|
|
51
|
+
/** the header source the app opted into (an auth provider): asked before each linked call and
|
|
52
|
+
* once more after a 401 (link.ts runLink). null = calls carry only the installer's headers. */
|
|
53
|
+
headerSource: null,
|
|
54
|
+
/** Bind an opted-in auth source to one session for both attempts of a call. */
|
|
55
|
+
headerSourceForCall: null,
|
|
56
|
+
};
|
|
57
|
+
/** The presentation door a renderer fills (proposals/module-component-presentation.md). A module's web
|
|
58
|
+
* facet presents its own component through the SAME machine the markup verb `dsx.component.present`
|
|
59
|
+
* drives: the renderer installs its router's handler here, and `DsxContext.component` forwards to it.
|
|
60
|
+
* The kernel names no DOM and no renderer; with nothing installed (a server pass, a headless test)
|
|
61
|
+
* the door is inert and `present` answers `false`, so a facet fails open instead of throwing. */
|
|
62
|
+
export const ComponentSeam = {
|
|
63
|
+
run: null,
|
|
64
|
+
/** The native `ui` handle's twin: the renderer answers the live surface a presented component
|
|
65
|
+
* stands on, so a facet can keep the facts it owns (a variable the component derives from) in
|
|
66
|
+
* step and call the component's own actions. null = no renderer, or nothing presented by that name. */
|
|
67
|
+
surface: null,
|
|
68
|
+
/** A component rendered where nothing can see it, for a facet that rasterises it (capture.offscreen).
|
|
69
|
+
* The renderer owns the hidden host and answers its node as an OPAQUE value (the kernel names no DOM);
|
|
70
|
+
* `settled` resolves once the tree has laid out at the requested size and its own assets have loaded,
|
|
71
|
+
* `dispose` releases the host, the store and everything the mount registered. null = no renderer. */
|
|
72
|
+
offscreen: null,
|
|
73
|
+
/** A component defined at RUNTIME from compiled IR (the native `dsx.stack.component(name, xml:)` twin): the
|
|
74
|
+
* facet compiles the markup with the public compiler and hands the IR (opaque to the kernel) and its sheet
|
|
75
|
+
* here; the renderer registers it under the caller's scheme so `present` and nested tags resolve it.
|
|
76
|
+
* `overTheAir` marks markup that did not ship in the binary, which the renderer runs on the JSE tier only.
|
|
77
|
+
* Answers whether a renderer took it. */
|
|
78
|
+
define: null,
|
|
79
|
+
};
|
|
80
|
+
export const BootGateSeam = {
|
|
81
|
+
gates: [],
|
|
82
|
+
/** the gates in the order they run */
|
|
83
|
+
ordered() {
|
|
84
|
+
return this.gates.map((g, i) => ({ g, i })).sort((a, b) => b.g.priority - a.g.priority || a.i - b.i).map((x) => x.g);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
export const BootCoverSeam = {
|
|
88
|
+
covers: [],
|
|
89
|
+
};
|
|
90
|
+
/** `unreachable` — the frozen pass-through spelling (durability P4, errors corpus). */
|
|
91
|
+
export const ERROR_UNREACHABLE = "unreachable";
|
|
92
|
+
export const ERROR_NOT_LOADED = "not_loaded";
|
|
93
|
+
export const ERROR_UNSUPPORTED_PLATFORM = "unsupported_platform";
|
|
94
|
+
/** typed absence (durability.md P4): this build dropped the module — the split out of
|
|
95
|
+
* not_loaded, driven by the build-excluded overlay (errors corpus) */
|
|
96
|
+
export const ERROR_EXCLUDED = "excluded";
|
|
97
|
+
/** the caller named an action the LOCAL module does not register — a caller bug, never absence */
|
|
98
|
+
export const ERROR_UNKNOWN_ACTION = "unknown_action";
|
|
99
|
+
/** typed absence (durability.md P4): the capability row PROMISES a local implementation on
|
|
100
|
+
* this facet and nothing stood it up (an unlinked framework, an OS floor, a dropped
|
|
101
|
+
* companion) — a different fact from "never here" and from "this build dropped it" */
|
|
102
|
+
export const ERROR_PREREQUISITES_MISSING = "prerequisites_missing";
|
|
103
|
+
export const FacetSeam = {
|
|
104
|
+
/** the registered facet word THIS runtime binds; null = unbound (the honest default) */
|
|
105
|
+
facet: null,
|
|
106
|
+
/** the compiled capability table; empty until a build installs it */
|
|
107
|
+
rows: {},
|
|
108
|
+
/** the reach transport; null = no link, and the ladder answers the typed `unreachable`
|
|
109
|
+
* instead of hanging (facet-contracts.md: absence is load-bearing) */
|
|
110
|
+
invoke: null,
|
|
111
|
+
/** The row for one call, or null. THE ONE LOOKUP, named on all three lanes and pinned by the
|
|
112
|
+
* corpus `seamLookup` block, so no lane can answer it privately again.
|
|
113
|
+
*
|
|
114
|
+
* The CHAIN is lower cased, because a chain is a resolved IDENTITY and this kernel already
|
|
115
|
+
* folds identities exactly that way (`resolveChain` lower cases each segment, the route keys
|
|
116
|
+
* are lower cased, the build-excluded overlay is lower cased): the table's chain keys are
|
|
117
|
+
* canonically lower case. The ACTION key is matched VERBATIM first and lower cased second,
|
|
118
|
+
* because an action is NOT an identity, so a manifest's `heartRate` reaches its own key and
|
|
119
|
+
* an upper cased caller still reaches a lower cased one. Nothing case folds the TABLE.
|
|
120
|
+
*
|
|
121
|
+
* This kernel used to index `rows[chain]` raw while the Kotlin and Swift seams lower cased,
|
|
122
|
+
* and only its caller hid the difference: the funnel lower cases the identity before it asks,
|
|
123
|
+
* while `Context.facetFacts` on both native lanes hands the lookup the arriving spelling. */
|
|
124
|
+
row(chain, action) {
|
|
125
|
+
const forChain = FacetSeam.rows[chain.toLowerCase()];
|
|
126
|
+
if (forChain === undefined)
|
|
127
|
+
return null;
|
|
128
|
+
return forChain[action] ?? forChain[action.toLowerCase()] ?? null;
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
/** The action catalog's key. The manifest spells a nested action path with dots and the wire
|
|
132
|
+
* spells it with slashes, so both fold to one spelling here rather than at each call site. */
|
|
133
|
+
export function actionPlatformKey(chain, action) {
|
|
134
|
+
return `${chain.toLowerCase()}.${action.toLowerCase().replace(/\//g, ".")}`;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* THE LADDER, pure (`OpenSource/Conformance/facets/facets.json` drives exactly this):
|
|
138
|
+
*
|
|
139
|
+
* 1. **local** — a registered module answering this action wins before anything else is
|
|
140
|
+
* consulted, so a partly-local chain never pays for the table.
|
|
141
|
+
* 2. **reach** — the row admits THIS facet ⇒ over the link; admitted with no transport ⇒
|
|
142
|
+
* the typed `unreachable`, never a hang. A generated client-link route is the same rung.
|
|
143
|
+
* 3. **typed unavailable** — the reason IS the code (durability.md P4). Precedence is frozen
|
|
144
|
+
* by the shipped funnels and deliberate: `unknown_action` (the module IS here — a caller
|
|
145
|
+
* bug, not absence — but an ACTION the catalog declares off this platform outranks even
|
|
146
|
+
* that, since the caller asked for something declared impossible) > `unsupported_platform`
|
|
147
|
+
* (the platform catalog, then the row that
|
|
148
|
+
* neither provides nor reaches us — the NEVER-ON-THIS-FACET class, which keeps its
|
|
149
|
+
* shipping name; the draft spelling `never_on_facet` is retired) > `excluded` (a build
|
|
150
|
+
* fact beats a runtime one) > `prerequisites_missing` (the row promised a local
|
|
151
|
+
* implementation nothing stood up) > `not_loaded` (nothing known at all).
|
|
152
|
+
*/
|
|
153
|
+
export function resolveFacetLadder(f) {
|
|
154
|
+
if (f.local)
|
|
155
|
+
return { rung: "local", code: null, via: null };
|
|
156
|
+
const reached = facetReach(f);
|
|
157
|
+
if (reached !== null)
|
|
158
|
+
return reached;
|
|
159
|
+
if (f.linked)
|
|
160
|
+
return { rung: "reach", code: null, via: "link" };
|
|
161
|
+
let code = ERROR_NOT_LOADED;
|
|
162
|
+
// The ACTION-level narrowing sits AHEAD of `unknown_action` — the one rung that can be
|
|
163
|
+
// true while the module itself is present. Everything below it keeps the frozen order.
|
|
164
|
+
if (f.offPlatformAction === true)
|
|
165
|
+
code = ERROR_UNSUPPORTED_PLATFORM;
|
|
166
|
+
else if (f.module)
|
|
167
|
+
code = ERROR_UNKNOWN_ACTION;
|
|
168
|
+
else if (f.offPlatform)
|
|
169
|
+
code = ERROR_UNSUPPORTED_PLATFORM;
|
|
170
|
+
else
|
|
171
|
+
code = facetAbsence(f) ?? (f.excluded ? ERROR_EXCLUDED : ERROR_NOT_LOADED);
|
|
172
|
+
return { rung: "unavailable", code, via: null };
|
|
173
|
+
}
|
|
174
|
+
// THE FOLD. The two functions below carry every facet-dependent rung, and each opens with
|
|
175
|
+
// the `__DSX_OPTIONAL_LINK__` guard the client link already rides — false in any bundle
|
|
176
|
+
// built with no peer node (every embed slice). Such a surface binds no facet word and
|
|
177
|
+
// installs no transport, so it can never take a facet rung; esbuild turns each guard into
|
|
178
|
+
// `if (true) return null`, drops the bodies, and the surface pays nothing for a ladder it
|
|
179
|
+
// cannot climb. Nothing is duplicated — the rungs live here once, and `resolveFacetLadder`
|
|
180
|
+
// reads as the whole law either way. (The guard is an early RETURN, not a folded local:
|
|
181
|
+
// esbuild constant-folds a condition, it does not propagate a `const` into later ones.)
|
|
182
|
+
/** Rung two, facet half: the row admits THIS facet ⇒ over the link; admitted with no
|
|
183
|
+
* transport ⇒ the typed `unreachable`, never a hang. `null` = not our rung. */
|
|
184
|
+
function facetReach(f) {
|
|
185
|
+
if (globalThis
|
|
186
|
+
.__DSX_OPTIONAL_LINK__ === false)
|
|
187
|
+
return null;
|
|
188
|
+
const facet = f.facet;
|
|
189
|
+
const reach = f.row?.reach;
|
|
190
|
+
// fail-closed: absent `reach` admits nobody, explicit `false` is the deny
|
|
191
|
+
if (facet === null || !Array.isArray(reach) || !reach.includes(facet))
|
|
192
|
+
return null;
|
|
193
|
+
return f.transport
|
|
194
|
+
? { rung: "reach", code: null, via: "facet" }
|
|
195
|
+
: { rung: "unavailable", code: ERROR_UNREACHABLE, via: null };
|
|
196
|
+
}
|
|
197
|
+
/** The three FACET-seam facts, read once per call. Folded like its siblings: a peer-less
|
|
198
|
+
* bundle answers the unbound triple without ever touching `FacetSeam`, which then has no
|
|
199
|
+
* live reference left and drops out of the bundle entirely. */
|
|
200
|
+
function facetSeamFacts(chain, action) {
|
|
201
|
+
if (globalThis
|
|
202
|
+
.__DSX_OPTIONAL_LINK__ === false)
|
|
203
|
+
return { facet: null, row: null, transport: false };
|
|
204
|
+
return {
|
|
205
|
+
facet: FacetSeam.facet,
|
|
206
|
+
row: FacetSeam.row(chain, action),
|
|
207
|
+
transport: FacetSeam.invoke !== null,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/** Rung three, facet half — evaluated between the platform catalog and the excluded overlay,
|
|
211
|
+
* which is exactly the frozen precedence: a row that neither provides nor reaches us is
|
|
212
|
+
* NEVER-ON-THIS-FACET and outranks `excluded`, while a row that promises a local
|
|
213
|
+
* implementation yields to `excluded` (a build fact beats a runtime one) by answering null. */
|
|
214
|
+
function facetAbsence(f) {
|
|
215
|
+
if (globalThis
|
|
216
|
+
.__DSX_OPTIONAL_LINK__ === false)
|
|
217
|
+
return null;
|
|
218
|
+
const facet = f.facet;
|
|
219
|
+
const row = f.row;
|
|
220
|
+
if (facet === null || row === null)
|
|
221
|
+
return null;
|
|
222
|
+
if (!row.provides.includes(facet))
|
|
223
|
+
return ERROR_UNSUPPORTED_PLATFORM;
|
|
224
|
+
return f.excluded ? null : ERROR_PREREQUISITES_MISSING;
|
|
225
|
+
}
|
|
226
|
+
class DSXErrorLedgerImpl {
|
|
227
|
+
static cap = 128;
|
|
228
|
+
entries = [];
|
|
229
|
+
total = 0;
|
|
230
|
+
append(e) {
|
|
231
|
+
this.entries.push(e);
|
|
232
|
+
this.total += 1;
|
|
233
|
+
if (this.entries.length > DSXErrorLedgerImpl.cap) {
|
|
234
|
+
this.entries.splice(0, this.entries.length - DSXErrorLedgerImpl.cap);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/** the retained tail, oldest → newest (snapshot) */
|
|
238
|
+
recent() { return [...this.entries]; }
|
|
239
|
+
/** monotonic count of every error ever recorded (survives ring eviction) */
|
|
240
|
+
count() { return this.total; }
|
|
241
|
+
/** dev tooling only — drops the retained tail (the monotonic count stays) */
|
|
242
|
+
clear() { this.entries = []; }
|
|
243
|
+
}
|
|
244
|
+
export const DSXErrors = new DSXErrorLedgerImpl();
|
|
245
|
+
/** The opaque origin's serialization (HTML "serialization of an origin"). */
|
|
246
|
+
export const OPAQUE_CALLER_ORIGIN = "null";
|
|
247
|
+
/** The one spelling of an attested caller origin (corpus web-surface/caller-origin.json; the
|
|
248
|
+
* natives' twins are CallerOrigin.swift / CallerOrigin.kt): `scheme://host[:port]`, lowercased,
|
|
249
|
+
* the scheme's default port omitted. Anything that is not a tuple origin is the opaque "null". */
|
|
250
|
+
export function normalizeCallerOrigin(serialized) {
|
|
251
|
+
const raw = typeof serialized === "string" ? serialized.trim() : "";
|
|
252
|
+
if (raw.length === 0 || raw.toLowerCase() === OPAQUE_CALLER_ORIGIN)
|
|
253
|
+
return OPAQUE_CALLER_ORIGIN;
|
|
254
|
+
const m = /^([A-Za-z][A-Za-z0-9+.-]*):\/\/(\[[0-9A-Fa-f:.]+\]|[A-Za-z0-9._-]+)(?::(\d{1,5}))?\/?$/.exec(raw);
|
|
255
|
+
if (m === null)
|
|
256
|
+
return OPAQUE_CALLER_ORIGIN;
|
|
257
|
+
const scheme = m[1].toLowerCase();
|
|
258
|
+
const host = m[2].toLowerCase();
|
|
259
|
+
const port = m[3] === undefined ? 0 : Number(m[3]);
|
|
260
|
+
if (port > 65535)
|
|
261
|
+
return OPAQUE_CALLER_ORIGIN;
|
|
262
|
+
const fallback = scheme === "https" ? 443 : scheme === "http" ? 80 : -1;
|
|
263
|
+
return port <= 0 || port === fallback ? `${scheme}://${host}` : `${scheme}://${host}:${port}`;
|
|
264
|
+
}
|
|
265
|
+
const CALL_ROUTES = new WeakMap();
|
|
266
|
+
/** THE RELAY DEPTH LIMIT (a safety line, not an opinion): a chain of calls each handing on the next is refused
|
|
267
|
+
* past this many hops, as is any chain that comes back to an action already in it. Each hop runs inline on the
|
|
268
|
+
* main thread on the native lanes, so an unbounded chain is a stack overflow; no relay has a use past a handful. */
|
|
269
|
+
export const RELAY_DEPTH_LIMIT = 16;
|
|
270
|
+
/** THE RELAY'S FIELD CHECK (constitution Article 28.13): the first place where `payload` is not what `fields`
|
|
271
|
+
* declares, at any depth, or null when it conforms. `fields` null means the event declares no payload map, so
|
|
272
|
+
* only an absent or empty payload conforms. The payload itself must be an object (null only when no field is
|
|
273
|
+
* required); a field not declared, a value of another type word, and an item of an array are each checked. */
|
|
274
|
+
export function relayPayloadViolation(payload, fields) {
|
|
275
|
+
const declared = fields ?? {};
|
|
276
|
+
if (payload === null || payload === undefined) {
|
|
277
|
+
return Object.values(declared).some((f) => f.optional !== true) ? "(payload)" : null;
|
|
278
|
+
}
|
|
279
|
+
if (!isDict(payload))
|
|
280
|
+
return "(payload)";
|
|
281
|
+
return relayObjectViolation(payload, declared, "");
|
|
282
|
+
}
|
|
283
|
+
function relayObjectViolation(value, fields, at) {
|
|
284
|
+
for (const key of Object.keys(value).sort()) {
|
|
285
|
+
const path = at === "" ? key : `${at}.${key}`;
|
|
286
|
+
const spec = Object.prototype.hasOwnProperty.call(fields, key) ? fields[key] : undefined;
|
|
287
|
+
if (spec === undefined)
|
|
288
|
+
return path;
|
|
289
|
+
const wrong = relayValueViolation(value[key], spec, path);
|
|
290
|
+
if (wrong !== null)
|
|
291
|
+
return wrong;
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
function relayValueViolation(value, spec, at) {
|
|
296
|
+
if (value === null || value === undefined)
|
|
297
|
+
return null;
|
|
298
|
+
const type = typeof spec.type === "string" ? spec.type : null;
|
|
299
|
+
const isNumber = typeof value === "number";
|
|
300
|
+
if (type === "string" && typeof value !== "string")
|
|
301
|
+
return at;
|
|
302
|
+
if ((type === "number" || type === "integer") && !isNumber)
|
|
303
|
+
return at;
|
|
304
|
+
if (type === "boolean" && typeof value !== "boolean")
|
|
305
|
+
return at;
|
|
306
|
+
if (type === "object" && !isDict(value))
|
|
307
|
+
return at;
|
|
308
|
+
if (type === "array" && !Array.isArray(value))
|
|
309
|
+
return at;
|
|
310
|
+
if (spec.fields !== undefined) {
|
|
311
|
+
if (!isDict(value))
|
|
312
|
+
return at;
|
|
313
|
+
return relayObjectViolation(value, spec.fields, at);
|
|
314
|
+
}
|
|
315
|
+
if (spec.items !== undefined && Array.isArray(value)) {
|
|
316
|
+
for (let i = 0; i < value.length; i++) {
|
|
317
|
+
const wrong = relayValueViolation(value[i], spec.items, `${at}[${i}]`);
|
|
318
|
+
if (wrong !== null)
|
|
319
|
+
return wrong;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
/** A chain proxy's path, so `relay` takes `ctx.dsx.module.<chain>.<action>` itself. */
|
|
325
|
+
const CHAIN_PATHS = new WeakMap();
|
|
326
|
+
export function defineModule(m) {
|
|
327
|
+
return m;
|
|
328
|
+
}
|
|
329
|
+
/** Does this module ANSWER anything a caller can reach — an action, a bus hook, an object
|
|
330
|
+
* handle, a component, declared state or a boot block? The registry's capability answer
|
|
331
|
+
* (`isAvailable`, the `has()` builtin) reads this, never the bare table membership. */
|
|
332
|
+
// REGISTRY DIAGNOSTICS fold per SITE: the console sentences that tell an AUTHOR what the
|
|
333
|
+
// registry refused or could not disambiguate are guarded by the define INLINE, because
|
|
334
|
+
// esbuild folds `false !== false` and the dead branch only when the read sits in the
|
|
335
|
+
// condition itself — a helper function keeps every sentence in the bundle (measured: +79
|
|
336
|
+
// bytes on each playback embed). An embed build pins `__DSX_OPTIONAL_MODULE_DIAGNOSTICS__`
|
|
337
|
+
// false (embedDefines); the decision at each site never folds.
|
|
338
|
+
export function moduleAnswers(m) {
|
|
339
|
+
const some = (o) => !!o && !!Object.keys(o).length;
|
|
340
|
+
return some(m.actions) || some(m.hooks) || some(m.objects) || some(m.components) || some(m.state) || typeof m.boot === "function";
|
|
341
|
+
}
|
|
342
|
+
// ── module-identity chains (OpenSource/Conformance/chains — the frozen contract) ─────
|
|
343
|
+
//
|
|
344
|
+
// A module's identity is its dotted CHAIN (watch.health) derived from Modules/ nesting;
|
|
345
|
+
// the chain is both the API face (dsx.module.watch.health.heartRate) and the wire scheme
|
|
346
|
+
// token (watch.health://heartRate). Resolution is the incremental FOLD at the ONE
|
|
347
|
+
// dispatch funnel, never dot-counting, never a first-dot split: the arriving HEAD is
|
|
348
|
+
// the chain it spells, then while chain + "." + next is in
|
|
349
|
+
// the IDENTITY SET (registered chains ∪ build-excluded chains — the honest universe),
|
|
350
|
+
// fold that segment into the chain; the remainder is the action path (empty = the bare
|
|
351
|
+
// call). A leading RESERVED word in the remainder routes to the MEMBER plane, never an
|
|
352
|
+
// action. The build-time bidirectional ban (a child segment can never equal a parent
|
|
353
|
+
// action/group first-segment or a reserved member) is what makes the fold total.
|
|
354
|
+
/** The reserved MEMBER words — never actions. CLOSED and FROZEN (chains corpus):
|
|
355
|
+
* growth is a major-version event. */
|
|
356
|
+
export const RESERVED_MEMBERS = new Set([
|
|
357
|
+
"on", "available", "excluded", "availability", "context", "object", "delegate", "dsx", "then",
|
|
358
|
+
]);
|
|
359
|
+
/** The corpus fold, pure. `segments` carry the caller's natural segmentation: the
|
|
360
|
+
* dotted-callee face splits on dots (head = the first segment); the wire face passes
|
|
361
|
+
* its scheme token as ONE head segment (an already-dotted chain token) plus the
|
|
362
|
+
* action-path segments. */
|
|
363
|
+
export function resolveChain(segments, table) {
|
|
364
|
+
const parts = segments.filter((s) => s.length > 0);
|
|
365
|
+
const head = parts[0] ?? "";
|
|
366
|
+
let chain = head.toLowerCase();
|
|
367
|
+
let spelling = head;
|
|
368
|
+
let i = 1;
|
|
369
|
+
while (i < parts.length && table.isIdentity(`${chain}.${parts[i].toLowerCase()}`)) {
|
|
370
|
+
chain = `${chain}.${parts[i].toLowerCase()}`;
|
|
371
|
+
// the arriving spelling tracks the folded segments
|
|
372
|
+
spelling = `${spelling}.${parts[i]}`;
|
|
373
|
+
i += 1;
|
|
374
|
+
}
|
|
375
|
+
const remainder = parts.slice(i);
|
|
376
|
+
const known = chain.length > 0 && table.isIdentity(chain);
|
|
377
|
+
const excluded = table.isExcluded(chain);
|
|
378
|
+
const first = remainder[0] ?? "";
|
|
379
|
+
if (first.length > 0 && RESERVED_MEMBERS.has(first.toLowerCase())) {
|
|
380
|
+
return { chain, spelling, action: [], member: first.toLowerCase(), rest: remainder.slice(1), known, excluded };
|
|
381
|
+
}
|
|
382
|
+
return { chain, spelling, action: remainder, member: null, rest: [], known, excluded };
|
|
383
|
+
}
|
|
384
|
+
/** How a delegate fold combines its listeners' answers — the twin of the natives'
|
|
385
|
+
* fold policy enum (Kotlin `ModuleRegistry.Combine` in Module.kt, Swift `DSXBus.Combine`
|
|
386
|
+
* in DSXBus.swift), same five cases and same
|
|
387
|
+
* meanings. This IS the difference the four deleted legacy verbs used to encode. */
|
|
388
|
+
export const COMBINE_POLICIES = ["void", "any", "claim", "collect", "veto"];
|
|
389
|
+
/** THE RESIDENCE WORD of the generated platform-support column. A server-tier module
|
|
390
|
+
* provides a SERVICE, not a platform, so its row spells where it lives instead of leaving
|
|
391
|
+
* the column empty (`DSXGraph.SERVER_RESIDENCE` writes it into all four maps; the twins
|
|
392
|
+
* that accept and ignore it are `DesktopPackageCatalog.parse`, `ModuleRegistry.platformSupport`
|
|
393
|
+
* on Android and its `didSet` on iOS). It is a residence, never a platform: it must never
|
|
394
|
+
* satisfy the `includes(os)` test and must never reach a caller as a supportedPlatforms
|
|
395
|
+
* entry, so it is dropped at the one seam the catalog comes through. */
|
|
396
|
+
export const SERVER_RESIDENCE = "provides: server";
|
|
397
|
+
const ignoringResidence = (platforms) => platforms.filter((word) => word !== SERVER_RESIDENCE);
|
|
398
|
+
/** The AMBIENT error hat (error-system.md §3.2/3.3) — `dsx.error`/`dsx.fail` on the module
|
|
399
|
+
* handle, where there is no call to settle: the error reports to the APP instead, and is
|
|
400
|
+
* REPEATABLE by design (no settle guard — the property the old accidental registrar path
|
|
401
|
+
* fatally lacked). Deterministic fan-out: the ledger + reactive keys
|
|
402
|
+
* (`global.dsx.lastError` / `global.dsx.errorCount` — error state IS observable state),
|
|
403
|
+
* the `module.error` hook (the semantic sibling of the transport-level
|
|
404
|
+
* `module.callFailed`), and the page channel — the module's OWN scheme, event "error",
|
|
405
|
+
* plus the reserved `dsx` mirror so an app builds ONE global error listener. A nested
|
|
406
|
+
* emission from inside a hook or page handler stays log-only (the guard below) — the
|
|
407
|
+
* fan-out never feeds an observer its own output. One body for the registry and its inert
|
|
408
|
+
* twin (`NO_MODULE_REGISTRY`), which differ only in the delegate fold `fold` sends `module.error` through. */
|
|
409
|
+
let reportingAmbientError = false;
|
|
410
|
+
function reportAmbient(fold, scheme, code, opts) {
|
|
411
|
+
const message = opts.message ?? null;
|
|
412
|
+
const origin = opts.origin ?? "raised";
|
|
413
|
+
console.warn(`[dsx.error] ${scheme} → ${code}${origin === "uncaught" ? " (uncaught)" : ""}${message ? ` — ${message}` : ""}`);
|
|
414
|
+
if (reportingAmbientError)
|
|
415
|
+
return; // nested inside the fan-out below → log-only
|
|
416
|
+
reportingAmbientError = true;
|
|
417
|
+
try {
|
|
418
|
+
const wire = { code, message, recoverable: opts.recoverable ?? false, scheme, origin };
|
|
419
|
+
if (opts.data !== undefined && opts.data !== null)
|
|
420
|
+
wire["data"] = opts.data;
|
|
421
|
+
DSXErrors.append({ code, message, recoverable: opts.recoverable ?? false,
|
|
422
|
+
data: opts.data ?? null, scheme, origin, at: Date.now() });
|
|
423
|
+
DSXState.set("dsx.lastError", wire);
|
|
424
|
+
DSXState.set("dsx.errorCount", DSXErrors.count());
|
|
425
|
+
fold("module.error", wire);
|
|
426
|
+
DSXEvents.publish(`${scheme}:error`, wire);
|
|
427
|
+
if (scheme !== "dsx")
|
|
428
|
+
DSXEvents.publish("dsx:error", wire);
|
|
429
|
+
}
|
|
430
|
+
finally {
|
|
431
|
+
reportingAmbientError = false;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/** `dsx.stop(call)` for the registry and its inert twin: see `ModuleRegistryImpl.stop`. */
|
|
435
|
+
function stopCall(call) {
|
|
436
|
+
const routes = call !== null && typeof call === "object" ? CALL_ROUTES.get(call) : undefined;
|
|
437
|
+
if (routes === undefined)
|
|
438
|
+
return Promise.reject(new ModuleCallError("call_ended", "Not a live call value.", null));
|
|
439
|
+
routes.stop();
|
|
440
|
+
return Promise.resolve();
|
|
441
|
+
}
|
|
442
|
+
/** The refusal of a control on a value that is no live call (`ModuleRegistryImpl.control`), for the registry and its twin. */
|
|
443
|
+
function controlEnded(name) {
|
|
444
|
+
return Promise.reject(new ModuleCallError("call_ended", "Not a live call value.", { control: name }));
|
|
445
|
+
}
|
|
446
|
+
/** Whether `path` names a control of `call`, for the registry and its inert twin: see `ModuleRegistryImpl.namesControl`. */
|
|
447
|
+
function namesCallControl(call, path) {
|
|
448
|
+
const cut = path.lastIndexOf(".");
|
|
449
|
+
if (cut <= 0 || call === null || typeof call !== "object")
|
|
450
|
+
return false;
|
|
451
|
+
const routes = CALL_ROUTES.get(call);
|
|
452
|
+
if (routes === undefined)
|
|
453
|
+
return shapedLikeCall(call);
|
|
454
|
+
return path.slice(0, cut).toLowerCase() === routes.chain;
|
|
455
|
+
}
|
|
456
|
+
export class ModuleRegistryImpl {
|
|
457
|
+
modules = new Map();
|
|
458
|
+
/** scheme (lowercased) -> action (lowercased, dotted for groups) -> facts; a scheme with no row has no
|
|
459
|
+
* installed facts (a dynamic module, a kernel test), and a relay from it carries only explicit maps. */
|
|
460
|
+
callFacts = new Map();
|
|
461
|
+
hooks = [];
|
|
462
|
+
/** Who asked to hear when a point gains its first listener or loses its last (`observeWatchers`). */
|
|
463
|
+
watcherObservers = new Map();
|
|
464
|
+
/** the build-excluded overlay (facet-contracts.md build visibility): chain → its
|
|
465
|
+
* DespiaExcluded-shaped entry. Part of the fold's identity set so an excluded child
|
|
466
|
+
* still resolves for attribution — never a phantom action on its parent. */
|
|
467
|
+
excludedIdentities = new Map();
|
|
468
|
+
/** MODULE CONFIG — scheme → its `config.json` values, the twin of the natives' compiled
|
|
469
|
+
* `GeneratedConfigRaw`. Populated from the build manifest (`setModuleConfig`, fed by
|
|
470
|
+
* the generated module config), exactly the way `setPlatformSupport`
|
|
471
|
+
* fills the platform catalog for the same reason: both natives can compile a table into the
|
|
472
|
+
* binary and this renderer has no compile step to hide one in. Its absence was not a missing
|
|
473
|
+
* nicety — twelve web facets read `dsx.config?.<key>` with a fallback that always won, and
|
|
474
|
+
* Firebase, PostHog, Net, Media and Files each wrote in their own headers that "a web facet
|
|
475
|
+
* has no config plane" and then invented a different substitute. Empty until a host installs
|
|
476
|
+
* it, so a bare kernel keeps every one of those fallbacks working unchanged. */
|
|
477
|
+
moduleConfig = new Map();
|
|
478
|
+
/** THE SETTINGS PLANE (settings-plane.ts): each package's declared setting rows (rules, setters, boot
|
|
479
|
+
* setters) and the build the binary is, from the build manifest; then the two layers above the build
|
|
480
|
+
* table, remote and runtime, each written only through the gate. `configFor` reads build < remote < runtime. */
|
|
481
|
+
settingsSpecs = new Map();
|
|
482
|
+
pendingSettings = "{}";
|
|
483
|
+
readPendingSettings() {
|
|
484
|
+
try {
|
|
485
|
+
const store = globalThis.localStorage;
|
|
486
|
+
const value = JSON.parse(store ? (store.getItem("dsx.settings.ota") ?? "{}") : this.pendingSettings);
|
|
487
|
+
return isDict(value) ? value : {};
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
return {};
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
// read only by the settings gate, which folds with module dispatch (a widget that calls no module)
|
|
494
|
+
settingsBuild = (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false
|
|
495
|
+
? DEBUG_BUILD : null);
|
|
496
|
+
remoteSettings = new Map();
|
|
497
|
+
runtimeSettings = new Map();
|
|
498
|
+
/** THE PUBLIC CONFIG TABLE (public-config.ts): the settings a page may read as `dsx.config.<chain>.<key>`. */
|
|
499
|
+
publicConfig = null;
|
|
500
|
+
/** schemes whose CURRENT registrant arrived via `register(…, { fallback: true })` —
|
|
501
|
+
* a later provided module replaces it and clears the mark; a later fallback may too. */
|
|
502
|
+
fallbackSchemes = new Set();
|
|
503
|
+
/** platform catalog — schemes that exist in the product but not on this OS (X-tier),
|
|
504
|
+
* each mapped to the platforms that DO implement it. Populated from the build manifest
|
|
505
|
+
* (`setPlatformSupport`) so `unsupported_platform` is honest. PRE-FILTERED by design: a
|
|
506
|
+
* chain is in this map only when the current OS is absent from its list, which is what
|
|
507
|
+
* lets `offPlatform` be a `.has()` and the ladder stay a pure function of facts. */
|
|
508
|
+
unsupportedPlatforms = new Map();
|
|
509
|
+
/** the same, keyed "<chain>.<action>". The generated catalog is DENSE (K10): every declared
|
|
510
|
+
* action has a row, so a platform absent from one is a declared refusal rather than a hole,
|
|
511
|
+
* and a declared action with no handler here can no longer read as the typo it is not. This
|
|
512
|
+
* map stays PRE-FILTERED like its sibling above: a row survives the fold only when the
|
|
513
|
+
* current OS is absent from the action's list. */
|
|
514
|
+
unsupportedActionPlatforms = new Map();
|
|
515
|
+
/** module-call diagnostics funnel: true while `module.callFailed` hooks are delivering
|
|
516
|
+
* (fire is synchronous), so a hook whose own body makes a failing call can't feed the
|
|
517
|
+
* funnel its own output (fire → hook → failing call → fire → …). */
|
|
518
|
+
reportingCallFailure = false;
|
|
519
|
+
/** EVERY module-call failure lands here — the web twin of Context.reportCallFailure
|
|
520
|
+
* (Swift/Kotlin): a console.warn (the web's kernelLog), a LEDGER entry (origin "call" —
|
|
521
|
+
* the error system's unified record, error-system.md §3.3a), and the `module.callFailed`
|
|
522
|
+
* bus event, payload { scheme, action, code, data?, delivered } — the global observer
|
|
523
|
+
* seam (`dsx.delegate.listen("module.callFailed")`) for dev tooling. `delivered: false` marks a
|
|
524
|
+
* `.post` (fire-and-forget) failure: the call site discarded the rejection by shape,
|
|
525
|
+
* so this funnel is the only place it can surface. Observing never swallows — the
|
|
526
|
+
* awaited caller still gets the typed ModuleCallError rejection. `message`/`recoverable`
|
|
527
|
+
* arrive from the handler's own `fail(...)` when it authored them (full fidelity in the
|
|
528
|
+
* record even where the caller envelope stays narrow). */
|
|
529
|
+
reportCallFailure(scheme, action, code, data, delivered, message = null, recoverable = false) {
|
|
530
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
531
|
+
console.warn(`[dsx.module] ${scheme}.${action} → ${code}${delivered ? "" : " (fire-and-forget — the error never reaches the call site)"}`);
|
|
532
|
+
if (this.reportingCallFailure)
|
|
533
|
+
return;
|
|
534
|
+
this.reportingCallFailure = true;
|
|
535
|
+
try {
|
|
536
|
+
DSXErrors.append({ code, message, recoverable, data: data ?? null, scheme, origin: "call", delivered, at: Date.now() });
|
|
537
|
+
// `dsx.errorCount` tracks the ledger's monotonic total from EVERY feeder (a stale
|
|
538
|
+
// counter between ambient emissions would jump unpredictably); `dsx.lastError` stays
|
|
539
|
+
// ambient-only (semantic errors, not transport noise like card_declined).
|
|
540
|
+
DSXState.set("dsx.errorCount", DSXErrors.count());
|
|
541
|
+
const payload = { scheme, action, code, delivered };
|
|
542
|
+
if (data !== undefined && data !== null)
|
|
543
|
+
payload["data"] = data;
|
|
544
|
+
this.foldDelegate("module.callFailed", payload, "void");
|
|
545
|
+
}
|
|
546
|
+
finally {
|
|
547
|
+
this.reportingCallFailure = false;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
/** The AMBIENT error hat: the fan-out is `reportAmbient` (above the class), with `module.error` sent through this
|
|
552
|
+
* registry's delegate fold. */
|
|
553
|
+
reportAmbientError(scheme, code, opts = {}) {
|
|
554
|
+
reportAmbient((event, wire) => this.foldDelegate(event, wire, "void"), scheme, code, opts);
|
|
555
|
+
}
|
|
556
|
+
/** Install the build's call facts (scheme -> action -> CallFacts), generated from each package's dsx.json. */
|
|
557
|
+
setCallFacts(table) {
|
|
558
|
+
for (const [scheme, actions] of Object.entries(table)) {
|
|
559
|
+
this.callFacts.set(scheme.toLowerCase(), new Map(Object.entries(actions).map(([a, f]) => [a.toLowerCase(), f])));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/** The facts of `<scheme>.<action>`: null when the scheme has no installed facts. */
|
|
563
|
+
callFactsOf(scheme, action) {
|
|
564
|
+
const row = this.callFacts.get(scheme.toLowerCase());
|
|
565
|
+
if (row === undefined)
|
|
566
|
+
return null;
|
|
567
|
+
return row.get(action.toLowerCase()) ?? row.get(action.split("/").join(".").toLowerCase()) ?? {};
|
|
568
|
+
}
|
|
569
|
+
// ── THE BARRIER's registration half (screen-presentation.md `The barrier`; Constitution Article 26.12) ──
|
|
570
|
+
/** The generated barrier facts in force: chain -> its grant row, frozen into the kernel by `registerBoot`. */
|
|
571
|
+
barrierGrants = {};
|
|
572
|
+
/** The generated facts' module objects: chain -> the module OBJECT the bootloader passes for it. */
|
|
573
|
+
barrierGranted = {};
|
|
574
|
+
/** the module the boot loop is registering right now: only that call is the boot's own */
|
|
575
|
+
bootEntry = null;
|
|
576
|
+
/** the declaring chains registered in the current boot (a second registrant of one is refused) */
|
|
577
|
+
bootRegistered = new Set();
|
|
578
|
+
/** the first boot's facts, a fingerprint of them: they never change afterwards */
|
|
579
|
+
barrierFirst = null;
|
|
580
|
+
/** THE BOOT REGISTRATION. `bootDsx` hands its module list here with the build's generated barrier facts
|
|
581
|
+
* (chain -> { module, components, secure }, from each package's `presentation.barrier` declaration); each
|
|
582
|
+
* module of the list registers through the loop's own call, the only place an identity is minted WITH a
|
|
583
|
+
* grant. The FIRST boot installs the facts and they never change after it, as on Swift and Kotlin: a later
|
|
584
|
+
* boot whose facts differ is ignored and logged `[Barrier] barrier facts install after boot refused`
|
|
585
|
+
* (corpus router/barrier.json C32), so no later boot can widen a grant or take one away from a package
|
|
586
|
+
* whose barrier is up. A later boot with the same facts is the same boot's facts. No App.json key is read.
|
|
587
|
+
* Registration order and every other rule are `register`'s own. */
|
|
588
|
+
registerBoot(modules, barrier = {}) {
|
|
589
|
+
const grants = barrierGrantTable(barrier.facts);
|
|
590
|
+
const granted = {};
|
|
591
|
+
for (const [chain, fact] of Object.entries(barrier.facts ?? {})) {
|
|
592
|
+
if (fact !== null && typeof fact === "object" && fact.module !== undefined)
|
|
593
|
+
granted[chain.toLowerCase()] = fact.module;
|
|
594
|
+
}
|
|
595
|
+
const print = factsPrint(grants, granted);
|
|
596
|
+
if (this.barrierFirst === null) {
|
|
597
|
+
this.barrierGrants = Object.freeze(grants);
|
|
598
|
+
this.barrierGranted = Object.freeze(granted);
|
|
599
|
+
this.barrierFirst = print;
|
|
600
|
+
}
|
|
601
|
+
else if (this.barrierFirst !== print) {
|
|
602
|
+
console.warn("[Barrier] barrier facts install after boot refused");
|
|
603
|
+
}
|
|
604
|
+
this.bootRegistered = new Set();
|
|
605
|
+
for (const m of modules) {
|
|
606
|
+
this.bootEntry = m;
|
|
607
|
+
try {
|
|
608
|
+
this.register(m);
|
|
609
|
+
}
|
|
610
|
+
finally {
|
|
611
|
+
this.bootEntry = null;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
/** The renderer binds the document's barrier ledger here, ONCE per document: a second bind is
|
|
616
|
+
* refused and logged, so no later script can stand in front of the ledger the router bound. The
|
|
617
|
+
* slot itself is module-private and never exported. Answers whether it bound. */
|
|
618
|
+
bindBarrierLedger(door) {
|
|
619
|
+
if (BarrierSlot.door !== null) {
|
|
620
|
+
console.warn("[Barrier] second barrier ledger bind refused");
|
|
621
|
+
return false;
|
|
622
|
+
}
|
|
623
|
+
BarrierSlot.door = door;
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
register(module, opts = {}) {
|
|
627
|
+
const scheme = module.scheme.toLowerCase();
|
|
628
|
+
if (module.facts !== undefined)
|
|
629
|
+
this.setCallFacts({ [scheme]: module.facts });
|
|
630
|
+
// `dsx` is RESERVED (the error-system's global mirror channel, error-system.md §3.3b) —
|
|
631
|
+
// a module claiming it would shadow every app's global error listener. Refused, loudly.
|
|
632
|
+
if (scheme === "dsx") {
|
|
633
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DIAGNOSTICS__ !== false)
|
|
634
|
+
console.warn(`[dsx bus] scheme "dsx" is reserved (the error-system mirror) — module refused`);
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
// THE BARRIER REGISTRATION RULE (screen-presentation.md `The barrier`, corpus
|
|
638
|
+
// router/barrier.json C21, C24-C24c). A chain the generated barrier facts declare registers ONLY as
|
|
639
|
+
// its generated object (`facts[chain].module`, by reference), ONLY from the boot loop's own call for that
|
|
640
|
+
// entry, and ONLY once per boot. Any other registrant of that chain (a look-alike object, a runtime
|
|
641
|
+
// `register`, a registration a module makes from its own boot) is refused and replaces nothing;
|
|
642
|
+
// the same object registering again is not a new registrant. The module gets its identity here.
|
|
643
|
+
const fromBoot = this.bootEntry === module;
|
|
644
|
+
const grantRow = this.barrierGrants[scheme];
|
|
645
|
+
if (grantRow !== undefined) {
|
|
646
|
+
const again = this.modules.get(scheme) === module;
|
|
647
|
+
const admitted = this.barrierGranted[scheme] === module && (again || (fromBoot && !this.bootRegistered.has(scheme)));
|
|
648
|
+
if (!admitted) {
|
|
649
|
+
console.warn(`[Barrier] runtime registration of granted chain ${scheme} refused`);
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
if (fromBoot)
|
|
653
|
+
this.bootRegistered.add(scheme);
|
|
654
|
+
}
|
|
655
|
+
let identity = IDENTITY.get(module);
|
|
656
|
+
if (identity === undefined) {
|
|
657
|
+
identity = Object.freeze({});
|
|
658
|
+
IDENTITY.set(module, identity);
|
|
659
|
+
}
|
|
660
|
+
if (grantRow !== undefined)
|
|
661
|
+
GRANTS.set(identity, grantRow);
|
|
662
|
+
else if (fromBoot)
|
|
663
|
+
GRANTS.delete(identity); // a boot that no longer grants this object takes it back
|
|
664
|
+
// A FALLBACK registration (the surface's built-in twin, e.g. boot's route module)
|
|
665
|
+
// yields to a PROVIDED module: it lands only while the scheme is unowned or owned by
|
|
666
|
+
// a previous fallback — a re-boot replaces its own stale instance, never a facet's.
|
|
667
|
+
// Modules provide, surfaces consume; the built-in twin must never shadow the module.
|
|
668
|
+
if (opts.fallback === true) {
|
|
669
|
+
if (this.modules.has(scheme) && !this.fallbackSchemes.has(scheme))
|
|
670
|
+
return;
|
|
671
|
+
this.fallbackSchemes.add(scheme);
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
this.fallbackSchemes.delete(scheme);
|
|
675
|
+
}
|
|
676
|
+
this.modules.set(scheme, module);
|
|
677
|
+
if ((globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false)) {
|
|
678
|
+
for (const [member, fn] of Object.entries(module.probe ?? {})) {
|
|
679
|
+
this.probes.set(`${scheme}.${member.split("/").join(".")}`, fn);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
// A HOLLOW REGISTRATION IS SAID OUT LOUD, ONCE, HERE: the scheme is routed, but `has()`
|
|
683
|
+
// answers false until the module carries something a caller can reach — a licence refusal
|
|
684
|
+
// or a stripped facet is exactly what lands here, and before this line nothing logged it.
|
|
685
|
+
// The define is checked INSIDE the condition on purpose (the markdown fold's pattern):
|
|
686
|
+
// an embed build pins __DSX_OPTIONAL_MODULE_DIAGNOSTICS__ false and esbuild folds the
|
|
687
|
+
// sentence away; has() itself still answers the live truth there.
|
|
688
|
+
if (!moduleAnswers(module) && globalThis.__DSX_OPTIONAL_MODULE_DIAGNOSTICS__ !== false) {
|
|
689
|
+
console.warn(`[dsx bus] ${scheme}: registered nothing to answer with — has("${scheme}") is false until it does`);
|
|
690
|
+
}
|
|
691
|
+
// The module's declared context defaults, by the one law all three lanes run
|
|
692
|
+
// (state-primitive.ts publishDeclaredContext, corpus state/primitive.json declaredDefaults):
|
|
693
|
+
// an unset slot gets its default, a published value is never overwritten.
|
|
694
|
+
if (module.state) {
|
|
695
|
+
const rows = {};
|
|
696
|
+
for (const [k, v] of Object.entries(module.state))
|
|
697
|
+
rows[k] = { default: v };
|
|
698
|
+
publishDeclaredContext({ [scheme]: rows }, (p) => DSXState.get(p), (p, v) => DSXState.set(p, v));
|
|
699
|
+
}
|
|
700
|
+
if (module.hooks) {
|
|
701
|
+
for (const [event, fn] of Object.entries(module.hooks)) {
|
|
702
|
+
const was = this.hasWatchers(event);
|
|
703
|
+
this.hooks.push({ event, priority: 0, fn });
|
|
704
|
+
if (!was)
|
|
705
|
+
this.notifyWatchers(event, true);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
// THE MODULE'S BOOT BLOCK rides `__DSX_OPTIONAL_MODULE_BOOT__` (cli embed/emit.ts): a self-contained widget
|
|
709
|
+
// registers only the facets its entry bundles, and when none of them spells `boot` none has a boot block, so the
|
|
710
|
+
// handle a boot receives (makeDsx: the module proxy, the chain proxies, the delegate and context doors) is
|
|
711
|
+
// never built. Every other place a handle is built sits inside the module dispatch, which folds on its own flag.
|
|
712
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_BOOT__ !== false)
|
|
713
|
+
module.boot?.(makeModuleDsx(module));
|
|
714
|
+
}
|
|
715
|
+
/** A ROUTE-TABLE ENTRY IS NOT A CAPABILITY. A module lands in the table the moment it
|
|
716
|
+
* registers, whether or not it carries anything — so a module registered with an empty
|
|
717
|
+
* action table (a licence decision, a build that stripped its facet, a surface it means to
|
|
718
|
+
* add later) used to read `has(scheme) === true` while every call into it answered
|
|
719
|
+
* `unknown_action`. The honest answer is the live one: available when the module ANSWERS —
|
|
720
|
+
* an action, a hook, an object handle, a component, declared state or a boot block
|
|
721
|
+
* (`moduleAnswers`). The Kotlin and Swift registries answer identically; pinned by
|
|
722
|
+
* Conformance/errors/errors.json (`schemeAvailable`, the hollow-module case). */
|
|
723
|
+
isAvailable(scheme) {
|
|
724
|
+
const m = this.modules.get(scheme.toLowerCase());
|
|
725
|
+
return !!m && moduleAnswers(m);
|
|
726
|
+
}
|
|
727
|
+
// ── AVAILABILITY (proposals/availability.md v2): per member, ONE function feeds pre-flight AND call ──
|
|
728
|
+
// THE WHOLE PLANE FOLDS with `__DSX_OPTIONAL_AVAILABILITY__` (cli embed/entry.ts
|
|
729
|
+
// `registryUsesAvailability`): a slice that never spells `availability`, `has(` or `has:` and whose
|
|
730
|
+
// facet declares no `probe` can neither ask a verdict nor meet a runtime rung. Each guard is an
|
|
731
|
+
// inline `if (<flag expression>)` on purpose: esbuild folds the define through the expression
|
|
732
|
+
// but not through a module-level alias, and an early return elsewhere would keep every import.
|
|
733
|
+
/** the per-member probe cache; `version` is the reactive tick */
|
|
734
|
+
probes = (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) ? new AvailabilityProbes() : null;
|
|
735
|
+
/** v2.1: the live conditions each module published (scheme -> code -> fact), and the app-scoped
|
|
736
|
+
* ones (`offline` only), and the live degradations (member key -> id) */
|
|
737
|
+
liveConditions = new Map();
|
|
738
|
+
appConditions = new Map();
|
|
739
|
+
appConditionOwners = new Map();
|
|
740
|
+
liveDegradations = new Map();
|
|
741
|
+
/** the target row NAME this runtime is (readiness reads its `remedies` and `floor`) */
|
|
742
|
+
targetName = null;
|
|
743
|
+
/** v2.1 D9: a module publishes (`data`) or clears (`null`) one live condition. Unknown codes are
|
|
744
|
+
* refused loudly (the vocabulary is closed); `scope: "app"` is admitted for `offline` only. */
|
|
745
|
+
setCondition(scheme, code, data) {
|
|
746
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
747
|
+
if (!CONDITIONS.includes(code)) {
|
|
748
|
+
reportLog(scheme, "log", `dsx.condition: "${code}" is not a condition word (${CONDITIONS.join(" ")})`);
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
const c = code;
|
|
752
|
+
// an app-scoped fact is cleared by the module that published it (a null carries no scope)
|
|
753
|
+
const app = c === "offline" && (data === null ? this.appConditionOwners.get(c) === scheme.toLowerCase() : data.scope === "app");
|
|
754
|
+
if (app) {
|
|
755
|
+
if (data === null)
|
|
756
|
+
this.appConditionOwners.delete(c);
|
|
757
|
+
else
|
|
758
|
+
this.appConditionOwners.set(c, scheme.toLowerCase());
|
|
759
|
+
}
|
|
760
|
+
const store = app ? this.appConditions : (this.liveConditions.get(scheme.toLowerCase()) ??
|
|
761
|
+
(this.liveConditions.set(scheme.toLowerCase(), new Map()), this.liveConditions.get(scheme.toLowerCase())));
|
|
762
|
+
const before = store.get(c);
|
|
763
|
+
const after = data === null ? undefined : {
|
|
764
|
+
code: c, setting: data.setting ?? null, inCall: data.inCall === true,
|
|
765
|
+
members: data.members == null ? null : data.members.map((m) => m.toLowerCase()), pending: data.pending === true,
|
|
766
|
+
};
|
|
767
|
+
if (JSON.stringify(before ?? null) === JSON.stringify(after ?? null))
|
|
768
|
+
return false;
|
|
769
|
+
if (after === undefined)
|
|
770
|
+
store.delete(c);
|
|
771
|
+
else
|
|
772
|
+
store.set(c, after);
|
|
773
|
+
this.probes.bump(scheme.toLowerCase());
|
|
774
|
+
return true;
|
|
775
|
+
}
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
/** v2.1 D5: a lane publishes (or clears with null) a live named degradation for one member. */
|
|
779
|
+
setDegradation(scheme, member, id) {
|
|
780
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
781
|
+
const key = this.rowKey(scheme.toLowerCase(), member);
|
|
782
|
+
const before = this.liveDegradations.get(key) ?? null;
|
|
783
|
+
if (before === id)
|
|
784
|
+
return false;
|
|
785
|
+
if (id === null)
|
|
786
|
+
this.liveDegradations.delete(key);
|
|
787
|
+
else
|
|
788
|
+
this.liveDegradations.set(key, id);
|
|
789
|
+
this.probes.bump(scheme.toLowerCase());
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
/** the live facts the readiness fold reads for one member. BLOCK-FORM FOLD (the plane's convention,
|
|
795
|
+
* 20091f1309): a class method survives tree shaking, so its body sits under the guard, or its
|
|
796
|
+
* DSXStrings reads keep strings.ts and message.ts (about 5 KB gz) in every embed that never asks a verdict. */
|
|
797
|
+
readinessFacts(chain, args, key) {
|
|
798
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
799
|
+
const scheme = chain.toLowerCase();
|
|
800
|
+
// the permission plane, composed: the package's own published `permission` object, read
|
|
801
|
+
// through the tracked door so a republish re-evaluates every read that depended on it
|
|
802
|
+
noteGlobalRead(scheme.split(".")[0]);
|
|
803
|
+
const p = DSXState.get(`${scheme}.permission`);
|
|
804
|
+
const permission = p !== null && typeof p === "object" && typeof p.status === "string"
|
|
805
|
+
? { status: p.status, canAsk: p.canAsk === true } : null;
|
|
806
|
+
const conditions = [...(this.liveConditions.get(scheme)?.values() ?? []), ...this.appConditions.values()];
|
|
807
|
+
const locale = DSXStrings.activeLocale();
|
|
808
|
+
return {
|
|
809
|
+
target: this.targetName, conditions, permission, args,
|
|
810
|
+
degradation: key === undefined ? null : (this.liveDegradations.get(key) ?? null),
|
|
811
|
+
locales: DSXStrings.candidates(locale),
|
|
812
|
+
lookup: (english) => DSXStrings.lookup(english),
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
return null;
|
|
816
|
+
}
|
|
817
|
+
/** the generated member table (`DespiaAvailability.generated.json`); empty until a host installs it */
|
|
818
|
+
// read only inside the availability plane, so it folds with it (the axes table drops out of a widget)
|
|
819
|
+
availabilityTable = (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false
|
|
820
|
+
? { axes: DEFAULT_AXES, targets: [], members: {} } : null);
|
|
821
|
+
/** lowercase member key -> the table's own spelling (components keep their PascalCase) */
|
|
822
|
+
memberIndex = new Map();
|
|
823
|
+
/** the constraint values THIS runtime is: a TargetRow.values */
|
|
824
|
+
targetValues = null;
|
|
825
|
+
/** this runtime's OS version ("17.2"; an Android API level "34"); null = unknown, fail-open */
|
|
826
|
+
osVersion = null;
|
|
827
|
+
/** The build seam for the MEMBER TABLE: the generated file verbatim, plus which of its target
|
|
828
|
+
* rows this runtime is (by name; default the app target of this OS). The platform maps the
|
|
829
|
+
* call ladder reads are derived from the same rows, so the table is the one source. */
|
|
830
|
+
setAvailabilityTable(table, opts = {}) {
|
|
831
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
832
|
+
this.availabilityTable = { ...table, axes: table.axes ?? DEFAULT_AXES };
|
|
833
|
+
this.memberIndex.clear();
|
|
834
|
+
for (const key of Object.keys(table.members))
|
|
835
|
+
this.memberIndex.set(key.toLowerCase(), key);
|
|
836
|
+
this.osVersion = opts.osVersion ?? this.osVersion;
|
|
837
|
+
const os = JSESeams.platformOS;
|
|
838
|
+
const row = table.targets.find((t) => t.name === opts.target) ??
|
|
839
|
+
table.targets.find((t) => t.values["platform"] === os && t.values["facet"] === "app");
|
|
840
|
+
this.targetValues = row?.values ?? null;
|
|
841
|
+
this.targetName = row?.name ?? null;
|
|
842
|
+
const byScheme = {};
|
|
843
|
+
const byAction = {};
|
|
844
|
+
for (const [key, m] of Object.entries(table.members)) {
|
|
845
|
+
const platforms = m.requires?.["platform"];
|
|
846
|
+
if (platforms === undefined || (platforms.length === 0 && m.kind !== "action"))
|
|
847
|
+
continue;
|
|
848
|
+
if (m.kind === "module")
|
|
849
|
+
byScheme[key] = [...platforms];
|
|
850
|
+
else if (m.kind === "action")
|
|
851
|
+
byAction[key] = [...platforms];
|
|
852
|
+
}
|
|
853
|
+
this.setPlatformSupport({ byScheme, byAction }, os);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
// BLOCK-FORM FOLDS OF THE PLANE'S PRIVATE HELPERS (`__DSX_OPTIONAL_AVAILABILITY__`). A class member survives tree
|
|
857
|
+
// shaking, so a helper whose every caller sits inside the plane's folded blocks keeps its body in every widget unless
|
|
858
|
+
// the body is under the guard too. findHandler, hasComponent, environment and shape are called only from the plane.
|
|
859
|
+
findHandler(module, host) {
|
|
860
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ === false || module === undefined)
|
|
861
|
+
return undefined;
|
|
862
|
+
const grouped = host.includes("/") ? host.split("/").join(".") : null;
|
|
863
|
+
return module.actions[host] ?? module.actions[host.toLowerCase()]
|
|
864
|
+
?? (grouped === null ? undefined : (module.actions[grouped] ?? module.actions[grouped.toLowerCase()]))
|
|
865
|
+
?? module.actions["*"];
|
|
866
|
+
}
|
|
867
|
+
hasComponent(module, name) {
|
|
868
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ === false)
|
|
869
|
+
return false;
|
|
870
|
+
const comps = module?.components;
|
|
871
|
+
if (!comps)
|
|
872
|
+
return false;
|
|
873
|
+
const wanted = name.toLowerCase();
|
|
874
|
+
return Object.keys(comps).some((c) => c.toLowerCase() === wanted);
|
|
875
|
+
}
|
|
876
|
+
/** the facts a caller knows: the target's values, the excluded overlay, the OS, the live probes */
|
|
877
|
+
environment() {
|
|
878
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ === false)
|
|
879
|
+
return { values: {}, excluded: [], osVersion: null, probe: () => null };
|
|
880
|
+
return {
|
|
881
|
+
values: this.targetValues ?? { platform: JSESeams.platformOS, facet: FacetSeam.facet ?? "app" },
|
|
882
|
+
excluded: [...this.excludedIdentities.keys()],
|
|
883
|
+
osVersion: this.osVersion,
|
|
884
|
+
probe: (m, a) => this.probes.ask(m, a),
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
rowKey(chain, member) {
|
|
888
|
+
const dotted = member.split("/").join(".");
|
|
889
|
+
const raw = dotted.length === 0 ? chain : `${chain}.${dotted}`;
|
|
890
|
+
return this.memberIndex.get(raw.toLowerCase()) ?? raw.toLowerCase();
|
|
891
|
+
}
|
|
892
|
+
/** The member's answer, through the ONE function. A member the table does not know gets a row
|
|
893
|
+
* from the live registry (its own row only, v2 5.2); a member nothing knows is `no` with no
|
|
894
|
+
* reason (the call fails `unknown_action` / `not_loaded`, which are not availability). */
|
|
895
|
+
memberAnswer(chain, member, args, opts = {}) {
|
|
896
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
897
|
+
const id = chain.toLowerCase();
|
|
898
|
+
const key = this.rowKey(id, member);
|
|
899
|
+
const known = this.availabilityTable.members[key];
|
|
900
|
+
const module = this.modules.get(id);
|
|
901
|
+
const host = member.split(".").join("/");
|
|
902
|
+
const local = member.length === 0
|
|
903
|
+
? module !== undefined && moduleAnswers(module)
|
|
904
|
+
: module !== undefined && (this.findHandler(module, host) !== undefined || this.hasComponent(module, member));
|
|
905
|
+
const hasProbe = this.probes.has(key);
|
|
906
|
+
let row = known;
|
|
907
|
+
if (row === undefined) {
|
|
908
|
+
const platforms = member.length === 0
|
|
909
|
+
? this.unsupportedPlatforms.get(id)
|
|
910
|
+
: (this.unsupportedActionPlatforms.get(actionPlatformKey(id, host)) ?? this.unsupportedPlatforms.get(id));
|
|
911
|
+
const excluded = this.excludedIdentities.has(id);
|
|
912
|
+
if (!local && platforms === undefined && !excluded) {
|
|
913
|
+
return { status: "no", reason: null, via: [], conditions: [], remote: false };
|
|
914
|
+
}
|
|
915
|
+
row = { kind: member.length === 0 ? "module" : "action", of: id, requires: platforms ? { platform: platforms } : {} };
|
|
916
|
+
}
|
|
917
|
+
if (hasProbe && row.probe !== true)
|
|
918
|
+
row = { ...row, probe: true };
|
|
919
|
+
const members = Object.create(this.availabilityTable.members);
|
|
920
|
+
members[key] = row;
|
|
921
|
+
return resolveMember({ ...this.availabilityTable, members }, key, this.environment(), args, opts);
|
|
922
|
+
}
|
|
923
|
+
return { status: "yes", reason: null, via: [], conditions: [], remote: false };
|
|
924
|
+
}
|
|
925
|
+
/** The runtime shape an author reads: `{ available, reason, via }` (depends = unknown facts =
|
|
926
|
+
* available, and NOT settled), then the v2.1 readiness fields for `key` (`chain` when null). */
|
|
927
|
+
shape(a, chain, key, args) {
|
|
928
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ === false)
|
|
929
|
+
return { available: true, reason: null, via: [], ready: true, condition: null, settled: true, degradation: null, remedy: null, explain: null };
|
|
930
|
+
const base = {
|
|
931
|
+
available: a.status !== "no", reason: a.reason,
|
|
932
|
+
via: a.via.map((v) => ({ member: v.member, reason: v.reason ?? null })),
|
|
933
|
+
settled: a.status !== "depends",
|
|
934
|
+
};
|
|
935
|
+
// the guard lets an embed that never asks a verdict fold the fold and its catalog away
|
|
936
|
+
const r = chain === undefined || globalThis.__DSX_OPTIONAL_AVAILABILITY__ === false
|
|
937
|
+
? { ready: base.available, condition: null, settled: base.settled, degradation: null, remedy: null, explain: null }
|
|
938
|
+
: readinessFold(this.availabilityTable, EXPLAIN_CATALOG, key ?? chain.toLowerCase(), base, this.readinessFacts(chain, args, key));
|
|
939
|
+
return { available: base.available, reason: base.reason, via: base.via, ...r };
|
|
940
|
+
}
|
|
941
|
+
/** The verdict for ONE member (an action path or a component name) of `chain`, with the
|
|
942
|
+
* call's arguments when a variant is asked. */
|
|
943
|
+
memberAvailability(chain, member, args) {
|
|
944
|
+
if (!(globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false)) {
|
|
945
|
+
return { available: true, reason: null, via: [], ready: true, condition: null, settled: true, degradation: null, remedy: null, explain: null };
|
|
946
|
+
}
|
|
947
|
+
const id = chain.toLowerCase();
|
|
948
|
+
return this.shape(this.memberAnswer(chain, member, args), id, this.rowKey(id, member), args);
|
|
949
|
+
}
|
|
950
|
+
/** The module-level roll-up: AVAILABLE when any member can run here; the members' most static
|
|
951
|
+
* reason when none can. A module with no member rows answers from its own row. */
|
|
952
|
+
moduleAvailability(chain) {
|
|
953
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
954
|
+
const id = chain.toLowerCase();
|
|
955
|
+
const members = new Set();
|
|
956
|
+
const prefix = `${id}.`;
|
|
957
|
+
for (const [k, row] of Object.entries(this.availabilityTable.members)) {
|
|
958
|
+
// a control speaks for its action's call, never for the module (the action's row does)
|
|
959
|
+
if (row.of === id && row.kind !== "module" && row.kind !== "control")
|
|
960
|
+
members.add(k.slice(prefix.length));
|
|
961
|
+
}
|
|
962
|
+
for (const k of this.unsupportedActionPlatforms.keys()) {
|
|
963
|
+
if (k.startsWith(prefix) && !this.availabilityTable.members[k])
|
|
964
|
+
members.add(k.slice(prefix.length));
|
|
965
|
+
}
|
|
966
|
+
const module = this.modules.get(id);
|
|
967
|
+
if (module !== undefined) {
|
|
968
|
+
for (const a of Object.keys(module.actions))
|
|
969
|
+
if (a !== "*")
|
|
970
|
+
members.add(a);
|
|
971
|
+
for (const c of Object.keys(module.components ?? {}))
|
|
972
|
+
members.add(c);
|
|
973
|
+
}
|
|
974
|
+
if (members.size === 0)
|
|
975
|
+
return this.shape(this.memberAnswer(id, ""), id, this.rowKey(id, ""));
|
|
976
|
+
// v2.1 roll-up: ready when ANY member is ready; otherwise the roll-up reason (none
|
|
977
|
+
// available), or the member holding the most durable live condition, speaks for the module
|
|
978
|
+
const shaped = [...members].map((m) => this.memberAvailability(id, m));
|
|
979
|
+
const rolled = this.shape(rollUpAnswers([...members].map((m) => this.memberAnswer(id, m))));
|
|
980
|
+
const ready = shaped.find((s) => s.ready);
|
|
981
|
+
const settled = shaped.every((s) => s.settled);
|
|
982
|
+
if (ready !== undefined)
|
|
983
|
+
return { ...rolled, ready: true, condition: null, settled, degradation: null, remedy: null, explain: null };
|
|
984
|
+
const speaker = rolled.available
|
|
985
|
+
? shaped.filter((s) => s.condition !== null).sort((a, b) => CONDITIONS.indexOf(a.condition) - CONDITIONS.indexOf(b.condition))[0]
|
|
986
|
+
: shaped.find((s) => s.reason === rolled.reason);
|
|
987
|
+
return speaker === undefined ? { ...rolled, settled }
|
|
988
|
+
: { ...rolled, ready: false, condition: speaker.condition, settled, degradation: speaker.degradation, remedy: speaker.remedy, explain: speaker.explain };
|
|
989
|
+
}
|
|
990
|
+
return { available: true, reason: null, via: [], ready: true, condition: null, settled: true, degradation: null, remedy: null, explain: null };
|
|
991
|
+
}
|
|
992
|
+
/** v2.1 D10: the live condition a call meets when calling cannot remedy it in the call
|
|
993
|
+
* (`inCall` false). `permission_denied` stays the package's own gate. null = the call may run. */
|
|
994
|
+
conditionRefusal(chain, host, args) {
|
|
995
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
996
|
+
const s = this.memberAvailability(chain, host.split("/").join("."), args);
|
|
997
|
+
if (s.condition === null || s.condition === "permission_denied" || s.remedy === null || s.remedy.inCall)
|
|
998
|
+
return null;
|
|
999
|
+
return { code: s.condition, setting: s.remedy.setting, explain: s.explain };
|
|
1000
|
+
}
|
|
1001
|
+
return null;
|
|
1002
|
+
}
|
|
1003
|
+
/** `dsx.has(name, args?)`: a MODULE chain keeps its long-standing answer (registered and
|
|
1004
|
+
* answering); `chain.member` asks the member, with the call's own arguments for a variant.
|
|
1005
|
+
* The fold settles which dots are the chain. */
|
|
1006
|
+
has(name, args) {
|
|
1007
|
+
if (args === undefined && this.isAvailable(name))
|
|
1008
|
+
return true;
|
|
1009
|
+
if (!(globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false))
|
|
1010
|
+
return false;
|
|
1011
|
+
const r = resolveChain(name.split("."), this.chainTable());
|
|
1012
|
+
if (r.action.length === 0)
|
|
1013
|
+
return args === undefined ? false : this.memberAnswer(r.chain, "", args).status !== "no";
|
|
1014
|
+
return this.memberAnswer(r.chain, r.action.join("."), args).status !== "no";
|
|
1015
|
+
}
|
|
1016
|
+
/** The `availability` member plane: `.available` / `.reason` for the module, `.<member>` for
|
|
1017
|
+
* one action or component (`{ available, reason, via }`), and `.<member>.variants.<arg>.<value>`
|
|
1018
|
+
* for one variant. */
|
|
1019
|
+
availabilityPlane(chain) {
|
|
1020
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
1021
|
+
const id = chain.toLowerCase();
|
|
1022
|
+
const base = this.moduleAvailability(id);
|
|
1023
|
+
return new Proxy({}, {
|
|
1024
|
+
get: (_t, key) => {
|
|
1025
|
+
if (typeof key !== "string" || !proxyAdmits(key))
|
|
1026
|
+
return undefined;
|
|
1027
|
+
if (key === "available" || key === "reason" || key === "via")
|
|
1028
|
+
return base[key];
|
|
1029
|
+
const own = this.memberAvailability(id, key);
|
|
1030
|
+
// `.availability.<action>.<control>`: each control the table declares on this action
|
|
1031
|
+
const controls = {};
|
|
1032
|
+
const prefix = `${this.rowKey(id, key)}.`;
|
|
1033
|
+
for (const [k, row] of Object.entries(this.availabilityTable.members)) {
|
|
1034
|
+
if (row.kind === "control" && k.startsWith(prefix) && !k.slice(prefix.length).includes(".")) {
|
|
1035
|
+
controls[k.slice(prefix.length)] = this.memberAvailability(id, `${key}.${k.slice(prefix.length)}`);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
return {
|
|
1039
|
+
...controls,
|
|
1040
|
+
...own,
|
|
1041
|
+
variants: new Proxy({}, {
|
|
1042
|
+
get: (_v, arg) => typeof arg !== "string" || !proxyAdmits(arg) ? undefined : new Proxy({}, {
|
|
1043
|
+
get: (_w, value) => typeof value !== "string" || !proxyAdmits(value) ? undefined : this.memberAvailability(id, key, { [arg]: value }),
|
|
1044
|
+
}),
|
|
1045
|
+
}),
|
|
1046
|
+
};
|
|
1047
|
+
},
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
return undefined;
|
|
1051
|
+
}
|
|
1052
|
+
/** The refusal a call meets AFTER a handler is found: the SAME own-row answer the pre-flight
|
|
1053
|
+
* gives (`unsupported_os`, `unsupported_device`, or any other reason). null = the call may run. */
|
|
1054
|
+
runtimeRefusal(chain, host, args) {
|
|
1055
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
1056
|
+
const a = this.memberAnswer(chain, host.split("/").join("."), args, { own: true });
|
|
1057
|
+
return a.status === "no" ? a.reason : null;
|
|
1058
|
+
}
|
|
1059
|
+
return null;
|
|
1060
|
+
}
|
|
1061
|
+
/** The build seam for the excluded-identities overlay — chains that exist in the
|
|
1062
|
+
* product but are excluded from THIS build. Default empty; the build wires it (the
|
|
1063
|
+
* runtime.js `despia.excluded` twin). A chain whose nearest ancestor is also excluded
|
|
1064
|
+
* carries the cascade entry shape ({ reason: "cascade", from: <parent chain> }).
|
|
1065
|
+
* Entries are chain strings, or `{ chain }` objects; `excludedFact` answers them 1:1
|
|
1066
|
+
* with the page's matchesEntry. */
|
|
1067
|
+
setExcludedIdentities(chains) {
|
|
1068
|
+
// a build-manifest table only an app boot installs: a self-contained widget folds the writer (embed entry.ts)
|
|
1069
|
+
if (!BOOT_TABLES_ENABLED)
|
|
1070
|
+
return;
|
|
1071
|
+
this.excludedIdentities.clear();
|
|
1072
|
+
const entries = chains.map((c) => typeof c === "string" ? { chain: c.toLowerCase() }
|
|
1073
|
+
: { chain: c.chain.toLowerCase() });
|
|
1074
|
+
const set = new Set(entries.map((e) => e.chain));
|
|
1075
|
+
for (const { chain } of entries) {
|
|
1076
|
+
let from = null;
|
|
1077
|
+
for (let i = chain.lastIndexOf("."); i > 0; i = chain.lastIndexOf(".", i - 1)) {
|
|
1078
|
+
const parent = chain.substring(0, i);
|
|
1079
|
+
if (set.has(parent)) {
|
|
1080
|
+
from = parent;
|
|
1081
|
+
break;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
this.excludedIdentities.set(chain, from === null ? { reason: "excluded" } : { reason: "cascade", from });
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
/** THE DERIVATION SEAM of the member table's platform maps, not a second owner. `setAvailabilityTable`
|
|
1088
|
+
* calls it with the maps it derives from the table rows, and no build hands a catalog to a runtime any
|
|
1089
|
+
* more (v2.1: one owner per fact; `BootOptions.platformSupport` is gone). The ladder corpus
|
|
1090
|
+
* (`Conformance/actions/declared-actions.json`) and the kernel tests drive the same maps directly,
|
|
1091
|
+
* which is why it stays callable.
|
|
1092
|
+
*
|
|
1093
|
+
* The build seam for the PLATFORM CATALOG — the twin of `setExcludedIdentities`, and the
|
|
1094
|
+
* thing whose absence made `unsupported_platform` unreachable on this renderer (X1 H3: the
|
|
1095
|
+
* ladder and the table both shipped; nothing ever filled the table outside a test, so 359
|
|
1096
|
+
* native-only actions answered `not_loaded`, which the bus itself documents as a caller bug).
|
|
1097
|
+
*
|
|
1098
|
+
* Takes the FULL catalog — every chain and every action, exactly as the member table's
|
|
1099
|
+
* rows carry it (`requires.platform`) — and folds it
|
|
1100
|
+
* against this runtime's OS, so what lands in the maps is only what is off-platform HERE.
|
|
1101
|
+
* Filtering at install rather than at lookup is what keeps the ladder a pure function of
|
|
1102
|
+
* facts and the `.has()` reads honest. Re-callable; each call replaces both tables. */
|
|
1103
|
+
setPlatformSupport(catalog, os = JSESeams.platformOS) {
|
|
1104
|
+
if (!BOOT_TABLES_ENABLED)
|
|
1105
|
+
return;
|
|
1106
|
+
this.unsupportedPlatforms.clear();
|
|
1107
|
+
this.unsupportedActionPlatforms.clear();
|
|
1108
|
+
for (const [chain, platforms] of Object.entries(catalog.byScheme ?? {})) {
|
|
1109
|
+
const supported = ignoringResidence(platforms);
|
|
1110
|
+
if (!supported.includes(os))
|
|
1111
|
+
this.unsupportedPlatforms.set(chain.toLowerCase(), supported);
|
|
1112
|
+
}
|
|
1113
|
+
for (const [key, platforms] of Object.entries(catalog.byAction ?? {})) {
|
|
1114
|
+
const supported = ignoringResidence(platforms);
|
|
1115
|
+
if (!supported.includes(os))
|
|
1116
|
+
this.unsupportedActionPlatforms.set(key.toLowerCase(), supported);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
/** The build seam for MODULE CONFIG — the twin of `setPlatformSupport`, same shape, same
|
|
1120
|
+
* reason. Takes the full `{ byScheme }` catalog the build emits and stores it lowercased, so a
|
|
1121
|
+
* facet registered under any spelling of its scheme reads its own values. Re-callable; each
|
|
1122
|
+
* call replaces the table. */
|
|
1123
|
+
setModuleConfig(catalog) {
|
|
1124
|
+
if (!BOOT_TABLES_ENABLED)
|
|
1125
|
+
return;
|
|
1126
|
+
this.moduleConfig.clear();
|
|
1127
|
+
for (const [scheme, values] of Object.entries(catalog.byScheme ?? {})) {
|
|
1128
|
+
if (isDict(values))
|
|
1129
|
+
this.moduleConfig.set(scheme.toLowerCase(), { ...values });
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
/** The build seam for `dsx.config.<chain>.<key>`: `DespiaConfig.json` as the build wrote it. Re-callable;
|
|
1133
|
+
* a value that is not a table installs none, so every read is null. */
|
|
1134
|
+
setPublicConfig(table) {
|
|
1135
|
+
// BLOCK-FORM FOLD (`__DSX_OPTIONAL_PUBLIC_CONFIG__`): a class method survives tree shaking, so its body sits under
|
|
1136
|
+
// the guard, or public-config.ts, config-values.ts and the strings and message tier they read stay in every widget.
|
|
1137
|
+
if (globalThis.__DSX_OPTIONAL_PUBLIC_CONFIG__ !== false)
|
|
1138
|
+
this.publicConfig = publicConfigTable(table);
|
|
1139
|
+
DSXState.invalidate("config");
|
|
1140
|
+
}
|
|
1141
|
+
/** `dsx.config.<path>`: a public setting through the live layers, resolved for this device, or null. */
|
|
1142
|
+
readConfig(path) {
|
|
1143
|
+
if (globalThis.__DSX_OPTIONAL_PUBLIC_CONFIG__ !== false) {
|
|
1144
|
+
return readPublicConfig(this.publicConfig, path, (chain) => ({ remote: this.remoteSettings.get(chain), runtime: this.runtimeSettings.get(chain) }), { platform: JSESeams.platformOS, locale: DSXStrings.activeLocale() });
|
|
1145
|
+
}
|
|
1146
|
+
return null;
|
|
1147
|
+
}
|
|
1148
|
+
/** One module's config values, or an empty object. A COPY per read: a facet that mutated what
|
|
1149
|
+
* it was handed would edit the build manifest for every other reader, and the shape a caller
|
|
1150
|
+
* gets from `dsx.config` should behave like the frozen table the natives compile in. */
|
|
1151
|
+
configFor(scheme) {
|
|
1152
|
+
const key = scheme.toLowerCase();
|
|
1153
|
+
// A widget that dispatches no module call has no setter to write the live layers: the plane folds with dispatch
|
|
1154
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ === false)
|
|
1155
|
+
return { ...(this.moduleConfig.get(key) ?? {}) };
|
|
1156
|
+
return { ...(this.moduleConfig.get(key) ?? {}), ...(this.remoteSettings.get(key) ?? {}), ...(this.runtimeSettings.get(key) ?? {}) };
|
|
1157
|
+
}
|
|
1158
|
+
/** One module's config as this build shipped it, before any remote or runtime value: what a declaration
|
|
1159
|
+
* frozen into the build was generated from, so a live value can narrow it but never widen it. */
|
|
1160
|
+
builtConfigFor(scheme) {
|
|
1161
|
+
return { ...(this.moduleConfig.get(scheme.toLowerCase()) ?? {}) };
|
|
1162
|
+
}
|
|
1163
|
+
/** The build seam for the SETTINGS PLANE: every package's declared rules and setters, and the build
|
|
1164
|
+
* this binary is (`dsx.build`). Re-callable; each call replaces the table and clears both live layers. */
|
|
1165
|
+
setSettingRules(catalog) {
|
|
1166
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ === false)
|
|
1167
|
+
return;
|
|
1168
|
+
this.settingsSpecs.clear();
|
|
1169
|
+
this.remoteSettings.clear();
|
|
1170
|
+
this.runtimeSettings.clear();
|
|
1171
|
+
for (const [scheme, spec] of Object.entries(catalog.byScheme ?? {})) {
|
|
1172
|
+
if (isDict(spec))
|
|
1173
|
+
this.settingsSpecs.set(scheme.toLowerCase(), spec);
|
|
1174
|
+
}
|
|
1175
|
+
this.settingsBuild = catalog.build ?? DEBUG_BUILD;
|
|
1176
|
+
this.applyLaunchSettings();
|
|
1177
|
+
}
|
|
1178
|
+
/** Persist an OTA snapshot for the next launch. SDKs already initialized in this process keep
|
|
1179
|
+
* their current values. A refused package is omitted; every offer meets the declared rules. */
|
|
1180
|
+
applyRemoteSettings(byScheme) {
|
|
1181
|
+
return this.remoteSettingsOffer(byScheme, false);
|
|
1182
|
+
}
|
|
1183
|
+
/** The boot seam, called after build rows/config and before package setup. Re-judges persisted values. */
|
|
1184
|
+
applyLaunchSettings() {
|
|
1185
|
+
const out = this.remoteSettingsOffer(this.readPendingSettings(), true);
|
|
1186
|
+
DSXState.invalidate("config");
|
|
1187
|
+
return out;
|
|
1188
|
+
}
|
|
1189
|
+
remoteSettingsOffer(byScheme, launch) {
|
|
1190
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
1191
|
+
const out = [];
|
|
1192
|
+
const accepted = {};
|
|
1193
|
+
for (const [scheme, values] of Object.entries(byScheme)) {
|
|
1194
|
+
if (!isDict(values))
|
|
1195
|
+
continue;
|
|
1196
|
+
const key = scheme.toLowerCase();
|
|
1197
|
+
const verdict = settingsVerdict(this.settingsSpecs.get(key) ?? {}, key, this.configFor(key), values, this.settingsBuild, "remote");
|
|
1198
|
+
this.reportSettingDiagnostics(key, verdict.diagnostics);
|
|
1199
|
+
out.push(...verdict.diagnostics);
|
|
1200
|
+
if (!verdict.refused) {
|
|
1201
|
+
accepted[key] = values;
|
|
1202
|
+
if (launch)
|
|
1203
|
+
this.remoteSettings.set(key, { ...(this.remoteSettings.get(key) ?? {}), ...values });
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
if (!launch) {
|
|
1207
|
+
this.pendingSettings = JSON.stringify(accepted);
|
|
1208
|
+
try {
|
|
1209
|
+
globalThis.localStorage?.setItem("dsx.settings.ota", this.pendingSettings);
|
|
1210
|
+
}
|
|
1211
|
+
catch { /* A blocked store keeps the build fallback on the next process. */ }
|
|
1212
|
+
}
|
|
1213
|
+
return out;
|
|
1214
|
+
}
|
|
1215
|
+
return [];
|
|
1216
|
+
}
|
|
1217
|
+
/** The declared setters a boot calls, with their build values: `[{ callee, args }]`. */
|
|
1218
|
+
bootSetterCalls() {
|
|
1219
|
+
// an `if` block, not an early return: a return guard folds too late for the linker, which has
|
|
1220
|
+
// already counted the settings plane (settings-plane.ts) as reached (embed-media-surfaces-slicing)
|
|
1221
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
1222
|
+
const calls = [];
|
|
1223
|
+
for (const [scheme, spec] of this.settingsSpecs) {
|
|
1224
|
+
for (const action of spec.boot ?? []) {
|
|
1225
|
+
const mapping = spec.setters?.[action];
|
|
1226
|
+
if (mapping === undefined || !this.modules.has(scheme))
|
|
1227
|
+
continue;
|
|
1228
|
+
const args = bootArguments(mapping, this.configFor(scheme));
|
|
1229
|
+
if (args !== null)
|
|
1230
|
+
calls.push({ callee: `${scheme}.${action}`, args });
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return calls;
|
|
1234
|
+
}
|
|
1235
|
+
return [];
|
|
1236
|
+
}
|
|
1237
|
+
/** Call every boot setter once (settled, never thrown: a refusal is already a typed diagnostic). */
|
|
1238
|
+
async applyBootSetters() {
|
|
1239
|
+
for (const { callee, args } of this.bootSetterCalls()) {
|
|
1240
|
+
try {
|
|
1241
|
+
await this.call(callee, args);
|
|
1242
|
+
}
|
|
1243
|
+
catch { /* reported on the funnel */ }
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
/** THE SETTINGS RUNG: a declared setter's offered values, judged before the handler runs. Answers the
|
|
1247
|
+
* refusal, or null after committing the values to the runtime layer. */
|
|
1248
|
+
settingsRung(identity, host, args) {
|
|
1249
|
+
// an `if` block, not an early return: a return guard folds too late for the linker, which has
|
|
1250
|
+
// already counted the settings plane (settings-plane.ts) as reached (embed-media-surfaces-slicing)
|
|
1251
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
1252
|
+
const spec = this.settingsSpecs.get(identity);
|
|
1253
|
+
const mapping = spec?.setters?.[host] ?? spec?.setters?.[host.split("/").join(".")];
|
|
1254
|
+
if (spec === undefined || mapping === undefined)
|
|
1255
|
+
return null;
|
|
1256
|
+
const offered = offeredSettings(mapping, args);
|
|
1257
|
+
const verdict = settingsVerdict(spec, identity, this.configFor(identity), offered, this.settingsBuild, "runtime");
|
|
1258
|
+
this.reportSettingDiagnostics(identity, verdict.diagnostics);
|
|
1259
|
+
if (verdict.refused) {
|
|
1260
|
+
const first = verdict.diagnostics.find((d) => d.level === "error");
|
|
1261
|
+
return { message: `${first.reason} ${first.remedy}`, data: { diagnostics: verdict.diagnostics } };
|
|
1262
|
+
}
|
|
1263
|
+
if (Object.keys(offered).length > 0) {
|
|
1264
|
+
this.runtimeSettings.set(identity, { ...(this.runtimeSettings.get(identity) ?? {}), ...offered });
|
|
1265
|
+
DSXState.invalidate("config");
|
|
1266
|
+
}
|
|
1267
|
+
return null;
|
|
1268
|
+
}
|
|
1269
|
+
return null;
|
|
1270
|
+
}
|
|
1271
|
+
reportSettingDiagnostics(scheme, diagnostics) {
|
|
1272
|
+
// an `if` block, not an early return: a return guard folds too late for the linker, which has
|
|
1273
|
+
// already counted the settings plane (settings-plane.ts) as reached (embed-media-surfaces-slicing)
|
|
1274
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
1275
|
+
for (const d of diagnostics)
|
|
1276
|
+
reportLog(scheme, d.level === "error" && this.settingsBuild.release ? "error" : "warn", settingDiagnosticLine(d));
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
/** The `.excluded` build fact: false, or the DespiaExcluded-shaped entry
|
|
1280
|
+
* ({ reason: "excluded" } | { reason: "cascade", from }), build facts must answer. */
|
|
1281
|
+
excludedFact(chain) {
|
|
1282
|
+
const direct = this.excludedIdentities.get(chain.toLowerCase());
|
|
1283
|
+
return direct === undefined ? false : { ...direct };
|
|
1284
|
+
}
|
|
1285
|
+
/** Resolve a dotted callee against the LIVE identity table (the chains-corpus fold) —
|
|
1286
|
+
* the introspection seam the chain proxy and the conformance runner share. */
|
|
1287
|
+
resolve(callee) {
|
|
1288
|
+
return resolveChain(callee.split("."), this.chainTable());
|
|
1289
|
+
}
|
|
1290
|
+
/** The live ChainTable view: registered chains ∪ the excluded overlay form the
|
|
1291
|
+
* identity set. */
|
|
1292
|
+
chainTable() {
|
|
1293
|
+
return {
|
|
1294
|
+
isIdentity: (chain) => {
|
|
1295
|
+
const m = this.modules.get(chain);
|
|
1296
|
+
return (m !== undefined && m.scheme.toLowerCase() === chain) || this.excludedIdentities.has(chain);
|
|
1297
|
+
},
|
|
1298
|
+
isExcluded: (chain) => this.excludedIdentities.has(chain),
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
schemes() {
|
|
1302
|
+
return [...this.modules.keys()];
|
|
1303
|
+
}
|
|
1304
|
+
/** The kernel-INTERNAL append. `dsx.delegate.listen` is its one public spelling — the
|
|
1305
|
+
* natives deleted the public `hook` for exactly this reason (delegates.md phase 4: two
|
|
1306
|
+
* competing attach idioms is the failure the collapse exists to end). Named
|
|
1307
|
+
* `registerDelegate` because `register` on this class is already MODULE registration —
|
|
1308
|
+
* the natives can call it `register` only because theirs hangs off `Context`. */
|
|
1309
|
+
registerDelegate(event, priority, fn) {
|
|
1310
|
+
const h = { event, priority, fn };
|
|
1311
|
+
const was = this.hasWatchers(event);
|
|
1312
|
+
this.hooks.push(h);
|
|
1313
|
+
if (!was)
|
|
1314
|
+
this.notifyWatchers(event, true);
|
|
1315
|
+
return () => {
|
|
1316
|
+
const i = this.hooks.indexOf(h);
|
|
1317
|
+
if (i < 0)
|
|
1318
|
+
return;
|
|
1319
|
+
this.hooks.splice(i, 1);
|
|
1320
|
+
if (!this.hasWatchers(event))
|
|
1321
|
+
this.notifyWatchers(event, false);
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
/** HEAR WHEN A POINT GAINS ITS FIRST LISTENER OR LOSES ITS LAST: `fn(true)` when `event` goes from no listener
|
|
1325
|
+
* to one, `fn(false)` when its last listener leaves. Nothing is called at subscription; read `hasWatchers`
|
|
1326
|
+
* for the current answer. An emitter whose platform charges for merely listening (a browser's
|
|
1327
|
+
* `beforeunload`, which costs the page its back/forward cache) attaches its source only while someone
|
|
1328
|
+
* listens. Generic: it names no point. Returns the unsubscribe. */
|
|
1329
|
+
observeWatchers(event, fn) {
|
|
1330
|
+
let set = this.watcherObservers.get(event);
|
|
1331
|
+
if (set === undefined) {
|
|
1332
|
+
set = new Set();
|
|
1333
|
+
this.watcherObservers.set(event, set);
|
|
1334
|
+
}
|
|
1335
|
+
set.add(fn);
|
|
1336
|
+
return () => {
|
|
1337
|
+
const current = this.watcherObservers.get(event);
|
|
1338
|
+
if (current === undefined)
|
|
1339
|
+
return;
|
|
1340
|
+
current.delete(fn);
|
|
1341
|
+
if (current.size === 0)
|
|
1342
|
+
this.watcherObservers.delete(event);
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
notifyWatchers(event, watched) {
|
|
1346
|
+
const set = this.watcherObservers.get(event);
|
|
1347
|
+
if (set === undefined)
|
|
1348
|
+
return;
|
|
1349
|
+
for (const fn of [...set])
|
|
1350
|
+
fn(watched);
|
|
1351
|
+
}
|
|
1352
|
+
/** IS ANYONE LISTENING (the engine's guard before it builds a point it sends, `handler.start` first): true when at
|
|
1353
|
+
* least one listener is attached to `event`. No copy, no sort, no allocation, so a site that sends a point on
|
|
1354
|
+
* every handler run pays one walk of the hook list when nobody listens and builds nothing. Generic: it answers for
|
|
1355
|
+
* every point, and a package may ask it on its bound `dsx.delegate`. Twins: Swift `DSXBus.hasWatchers`, Kotlin
|
|
1356
|
+
* `ModuleRegistry.hasWatchers`. */
|
|
1357
|
+
hasWatchers(event) {
|
|
1358
|
+
for (const h of this.hooks)
|
|
1359
|
+
if (h.event === event)
|
|
1360
|
+
return true;
|
|
1361
|
+
return false;
|
|
1362
|
+
}
|
|
1363
|
+
/** THE delegate fold — the ONE place every cross-module event collapses, and the twin of
|
|
1364
|
+
* the natives' `ModuleRegistry.dispatch`. `combine` IS the difference between the four
|
|
1365
|
+
* legacy verbs, and there is no verb in between. It is named `foldDelegate` rather than
|
|
1366
|
+
* the natives' `dispatch` only because `dispatch` on this class is already the CALL path.
|
|
1367
|
+
*
|
|
1368
|
+
* The combines, matching the natives bit for bit: `void` runs every listener and answers
|
|
1369
|
+
* nothing; `any` and `claim` both stop at the first non-nil answer (a claim is answered by
|
|
1370
|
+
* ONE owner) and differ in intent, not mechanism; `collect` runs all and gathers the
|
|
1371
|
+
* non-nil; `veto` stops at the first `false` and otherwise allows. A listener that throws
|
|
1372
|
+
* is skipped and never settles the fold — one bad watcher cannot silently deny an event. */
|
|
1373
|
+
foldDelegate(event, input = null, combine = "claim") {
|
|
1374
|
+
const collected = [];
|
|
1375
|
+
for (const h of [...this.hooks].sort((a, b) => b.priority - a.priority)) {
|
|
1376
|
+
if (h.event !== event)
|
|
1377
|
+
continue;
|
|
1378
|
+
let value;
|
|
1379
|
+
try {
|
|
1380
|
+
value = h.fn(input);
|
|
1381
|
+
}
|
|
1382
|
+
catch (e) {
|
|
1383
|
+
console.warn(`[dsx bus] ${combine} ${event}:`, e);
|
|
1384
|
+
continue;
|
|
1385
|
+
}
|
|
1386
|
+
if (combine === "void")
|
|
1387
|
+
continue;
|
|
1388
|
+
if (combine === "veto") {
|
|
1389
|
+
if (value === false)
|
|
1390
|
+
return false;
|
|
1391
|
+
continue;
|
|
1392
|
+
}
|
|
1393
|
+
if (value === null || value === undefined)
|
|
1394
|
+
continue;
|
|
1395
|
+
if (combine === "collect")
|
|
1396
|
+
collected.push(value);
|
|
1397
|
+
else
|
|
1398
|
+
return value; // any | claim — first non-nil settles it
|
|
1399
|
+
}
|
|
1400
|
+
if (combine === "collect")
|
|
1401
|
+
return collected;
|
|
1402
|
+
if (combine === "veto")
|
|
1403
|
+
return true;
|
|
1404
|
+
return null;
|
|
1405
|
+
}
|
|
1406
|
+
/** Point-to-point call, the legacy WIRE face (URL navigations, the v3 string
|
|
1407
|
+
* transport): a scheme token (a chain, flat or dotted, ONE head unit, never
|
|
1408
|
+
* re-split) + a slash-joined action path. EXEMPT from
|
|
1409
|
+
* the reserved-member refusal (corpus _note): reserved words are banned from
|
|
1410
|
+
* MANIFESTS, never from the wire, so a code-only legacy shim registered under a
|
|
1411
|
+
* reserved spelling (biometric://available, bluetooth://state) keeps answering
|
|
1412
|
+
* shipped pages. Resolves with the module's resolve() data; rejects with
|
|
1413
|
+
* ModuleCallError (excluded / not_loaded / unsupported_platform / action code). Every failure —
|
|
1414
|
+
* thrown here or settled by the handler — also reports to the diagnostics funnel
|
|
1415
|
+
* (reportCallFailure above); `fireAndForget` marks a `.post` call, whose rejection
|
|
1416
|
+
* the call site discards by shape (delivered: false in the funnel event). */
|
|
1417
|
+
async dispatch(scheme, host, args, opts = {}) {
|
|
1418
|
+
return this.dispatchSegments([scheme, ...host.split("/").filter((s) => s.length > 0)], args, opts, "wire");
|
|
1419
|
+
}
|
|
1420
|
+
/** `dsx.stop(call)`: stop listening to one call (its own `onStop` runs; never a cancel). Resolves for any
|
|
1421
|
+
* call value (stopping twice, or after the call ended, is a no-op); rejects `call_ended` for a value
|
|
1422
|
+
* that is not a call value (a typo, `undefined`, a foreign value), the same refusal `control` gives,
|
|
1423
|
+
* so a mistaken stop is never silent. */
|
|
1424
|
+
stop(call) {
|
|
1425
|
+
return stopCall(call);
|
|
1426
|
+
}
|
|
1427
|
+
/** `dsx.module.<chain>.<action>.<control>(call, args)`: `path` is the dotted path the author wrote
|
|
1428
|
+
* (`print.document.cancel`). The action part must be the action the call was made to, else
|
|
1429
|
+
* `unknown_control`; after the call's stream ended, `call_ended`. */
|
|
1430
|
+
control(call, path, args = {}) {
|
|
1431
|
+
const routes = call !== null && typeof call === "object" ? CALL_ROUTES.get(call) : undefined;
|
|
1432
|
+
const cut = path.lastIndexOf(".");
|
|
1433
|
+
const name = cut > 0 ? path.slice(cut + 1) : "";
|
|
1434
|
+
const action = cut > 0 ? path.slice(0, cut).toLowerCase() : "";
|
|
1435
|
+
// A call value, and the routes it keys, are minted only inside the module dispatch: with it folded
|
|
1436
|
+
// (`__DSX_OPTIONAL_MODULE_DISPATCH__`) every value is this refusal, and the rest of the method folds with it.
|
|
1437
|
+
if (routes === undefined || globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ === false)
|
|
1438
|
+
return controlEnded(name);
|
|
1439
|
+
if (name === "" || action !== routes.chain) {
|
|
1440
|
+
return Promise.reject(new ModuleCallError("unknown_control", `This call has no control named ${name || path}.`, { control: name || path }));
|
|
1441
|
+
}
|
|
1442
|
+
// A control the table narrows away from this platform answers its availability reason, with
|
|
1443
|
+
// `via`, before any handler runs: the same answer `dsx.has('<chain>.<action>.<control>')` gives.
|
|
1444
|
+
// Same order as Swift and Kotlin: a closed call is `call_ended` first, whatever the name.
|
|
1445
|
+
const refusal = routes.open() ? this.controlRefusal(routes.module, routes.action, name) : null;
|
|
1446
|
+
if (refusal !== null)
|
|
1447
|
+
return Promise.reject(refusal);
|
|
1448
|
+
return routes.control(name, args);
|
|
1449
|
+
}
|
|
1450
|
+
/** Whether `path`, the dotted path a document wrote after `dsx.module.` (`print.document.cancel`), names a
|
|
1451
|
+
* control of `call`: a call value this bus minted, and the path's action part is the action that call was
|
|
1452
|
+
* made to (the rule `control` applies). A value only shaped like a call (frozen, no prototype, no members),
|
|
1453
|
+
* which this bus never minted (a value from another runtime instance, a forgery), names a control at any path
|
|
1454
|
+
* with a control's shape, as the package lanes route it (`controlTarget`): it is refused `call_ended`, as a
|
|
1455
|
+
* call another document started is on Kotlin and Swift, and never sent on as data. Any other path that takes a
|
|
1456
|
+
* minted call as its first argument is not a control: there the call goes where data goes (constitution
|
|
1457
|
+
* Article 14.2). */
|
|
1458
|
+
namesControl(call, path) {
|
|
1459
|
+
return namesCallControl(call, path);
|
|
1460
|
+
}
|
|
1461
|
+
/** The availability refusal of one declared control (a `control` row of the member table), or null
|
|
1462
|
+
* when the table has no row for it or it is available here. */
|
|
1463
|
+
controlRefusal(chain, action, name) {
|
|
1464
|
+
if (globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) {
|
|
1465
|
+
const member = `${action}.${name}`;
|
|
1466
|
+
const row = this.availabilityTable.members[this.rowKey(chain, member)];
|
|
1467
|
+
if (row === undefined || row.kind !== "control")
|
|
1468
|
+
return null;
|
|
1469
|
+
const shaped = this.memberAvailability(chain, member);
|
|
1470
|
+
if (shaped.available || shaped.reason === null)
|
|
1471
|
+
return null;
|
|
1472
|
+
return new ModuleCallError(shaped.reason, `${chain}.${member} is not available here (${shaped.reason}).`, { control: name, action, platform: JSESeams.platformOS, via: shaped.via });
|
|
1473
|
+
}
|
|
1474
|
+
return null;
|
|
1475
|
+
}
|
|
1476
|
+
/** The dotted-CALLEE face — the text after `dsx.module.` arrives WHOLE (the runner's
|
|
1477
|
+
* statements, the chain proxy); the funnel folds identity vs action. A MODERN face:
|
|
1478
|
+
* a reserved member arriving here as a call is refused (`reserved_member`). */
|
|
1479
|
+
async call(callee, args, opts = {}) {
|
|
1480
|
+
return this.dispatchSegments(callee.split(".").filter((s) => s.length > 0), args, opts, "modern");
|
|
1481
|
+
}
|
|
1482
|
+
/** THE dispatch funnel (chains corpus): every call face lands here with its natural
|
|
1483
|
+
* segmentation, and the FOLD (resolveChain) settles module identity vs action path
|
|
1484
|
+
* against the live identity table before any route is taken. Errors echo the scheme
|
|
1485
|
+
* AS CALLED while identity, state, events, the bound dsx, stays the resolved
|
|
1486
|
+
* chain. The `face` splits the reserved-member law: MODERN faces
|
|
1487
|
+
* (the chain proxy, the dotted-callee `call`) refuse a member route as an action;
|
|
1488
|
+
* the legacy WIRE face routes it DIRECT under the arriving spelling. */
|
|
1489
|
+
/**
|
|
1490
|
+
* Rung two lookup. `null` means "this call is not linked", and the caller must fall through to
|
|
1491
|
+
* the answer it would have given anyway — never a substitute failure.
|
|
1492
|
+
*
|
|
1493
|
+
* Requires BOTH a transport and a listed route: a table with no transport (a build that emitted
|
|
1494
|
+
* the link but never installed one) must not swallow `not_loaded`, because a caller told
|
|
1495
|
+
* "unreachable" would go looking for a network problem that does not exist.
|
|
1496
|
+
*/
|
|
1497
|
+
linkRouteFor(chain, action) {
|
|
1498
|
+
// A bundle that reaches no server should not carry the route walk. esbuild cannot
|
|
1499
|
+
// tree-shake a class METHOD (it is a prototype property), so the flag has to fold
|
|
1500
|
+
// inside the body — `define` turns this into `if (true) return null` and the rest
|
|
1501
|
+
// of the body becomes dead code. Default (undefined) keeps the full behaviour.
|
|
1502
|
+
if (globalThis
|
|
1503
|
+
.__DSX_OPTIONAL_LINK__ === false)
|
|
1504
|
+
return null;
|
|
1505
|
+
if (LinkSeam.invoke === null)
|
|
1506
|
+
return null;
|
|
1507
|
+
const wanted = action.toLowerCase();
|
|
1508
|
+
for (const route of LinkSeam.routes) {
|
|
1509
|
+
if (route.chain === chain && route.action.toLowerCase() === wanted)
|
|
1510
|
+
return route;
|
|
1511
|
+
}
|
|
1512
|
+
return null;
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Invoke over the link, and map failure onto the ONE closed vocabulary.
|
|
1516
|
+
*
|
|
1517
|
+
* A `ModuleCallError` from the transport is the SERVER's own typed answer (`unauthenticated`,
|
|
1518
|
+
* `invalid_request`, …) and passes through with its reason intact — flattening it to `unreachable`
|
|
1519
|
+
* would tell a caller the network failed when in fact the server answered, precisely.
|
|
1520
|
+
* Everything else IS a link failure and becomes `unreachable`, the spelling durability P4
|
|
1521
|
+
* froze for exactly this and the errors corpus already pins on the ordinary call path.
|
|
1522
|
+
*/
|
|
1523
|
+
async callOverLink(route, scheme, host, args, delivered) {
|
|
1524
|
+
// Unreachable when the link is compiled out (linkRouteFor already returned null), so the
|
|
1525
|
+
// same fold drops this body too — see the note there.
|
|
1526
|
+
if (globalThis
|
|
1527
|
+
.__DSX_OPTIONAL_LINK__ === false) {
|
|
1528
|
+
throw new ModuleCallError(ERROR_UNREACHABLE, `${scheme}.${host} has no link transport`, { chain: route.chain });
|
|
1529
|
+
}
|
|
1530
|
+
const invoke = LinkSeam.invoke;
|
|
1531
|
+
if (invoke === null)
|
|
1532
|
+
throw new ModuleCallError(ERROR_UNREACHABLE, `${scheme}.${host} has no link transport`, { chain: route.chain });
|
|
1533
|
+
try {
|
|
1534
|
+
return await invoke(route, args);
|
|
1535
|
+
}
|
|
1536
|
+
catch (e) {
|
|
1537
|
+
if (e instanceof ModuleCallError) {
|
|
1538
|
+
this.reportCallFailure(scheme, host, e.code, e.data, delivered, e.message);
|
|
1539
|
+
throw e;
|
|
1540
|
+
}
|
|
1541
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
1542
|
+
const data = { chain: route.chain, action: route.action, method: route.method, path: route.path };
|
|
1543
|
+
this.reportCallFailure(scheme, host, ERROR_UNREACHABLE, data, delivered, message);
|
|
1544
|
+
throw new ModuleCallError(ERROR_UNREACHABLE, `${scheme}.${host} could not reach the server: ${message}`, data);
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
/** The live FACTS for one call — the registry read once, so the pure ladder above decides
|
|
1548
|
+
* on exactly what ships and the conformance runner can state the same eight fields
|
|
1549
|
+
* literally. The facet half folds out of a peer-less bundle with the ladder's own guard. */
|
|
1550
|
+
facetFacts(chain, action, hasModule, hasHandler) {
|
|
1551
|
+
// BLOCK-FORM FOLD: the one caller is the module dispatch (`__DSX_OPTIONAL_MODULE_DISPATCH__`).
|
|
1552
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ === false)
|
|
1553
|
+
return { local: hasModule && hasHandler, module: hasModule };
|
|
1554
|
+
return {
|
|
1555
|
+
local: hasModule && hasHandler,
|
|
1556
|
+
module: hasModule,
|
|
1557
|
+
...facetSeamFacts(chain, action),
|
|
1558
|
+
linked: this.linkRouteFor(chain, action) !== null,
|
|
1559
|
+
// the OVERLAY identity set, exactly what the fold's `excluded` flag reads
|
|
1560
|
+
excluded: this.excludedIdentities.has(chain),
|
|
1561
|
+
offPlatform: this.unsupportedPlatforms.has(chain),
|
|
1562
|
+
// only when the MODULE itself is on-platform: otherwise the module-level rung already
|
|
1563
|
+
// says it, and the two would race to describe the same absence
|
|
1564
|
+
offPlatformAction: !this.unsupportedPlatforms.has(chain) &&
|
|
1565
|
+
this.unsupportedActionPlatforms.has(actionPlatformKey(chain, action)),
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Rung two over the FACET link (the sibling of `callOverLink`, which rides the server
|
|
1570
|
+
* node's client-link table). A `ModuleCallError` from the transport is the far node's own
|
|
1571
|
+
* typed answer and passes through with its reason intact; anything else IS a link failure
|
|
1572
|
+
* and becomes `unreachable`, the spelling durability P4 froze for exactly this.
|
|
1573
|
+
*/
|
|
1574
|
+
async callOverReach(chain, scheme, host, args, delivered) {
|
|
1575
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
1576
|
+
// The same fold as the rungs (see resolveFacetLadder): with the facet rungs compiled out
|
|
1577
|
+
// the ladder can never answer `reach` via "facet", so this body is dead weight there.
|
|
1578
|
+
const invoke = globalThis
|
|
1579
|
+
.__DSX_OPTIONAL_LINK__ === false ? null : FacetSeam.invoke;
|
|
1580
|
+
const facet = FacetSeam.facet ?? "";
|
|
1581
|
+
// one shape for the code, wherever it is raised — who was asked, for what, on which
|
|
1582
|
+
// facet (the scheme AS CALLED, like every other envelope on this funnel)
|
|
1583
|
+
const data = { scheme, action: host, facet, chain };
|
|
1584
|
+
if (invoke === null) {
|
|
1585
|
+
this.reportCallFailure(scheme, host, ERROR_UNREACHABLE, data, delivered);
|
|
1586
|
+
throw new ModuleCallError(ERROR_UNREACHABLE, `${scheme}.${host} has no reach transport`, data);
|
|
1587
|
+
}
|
|
1588
|
+
try {
|
|
1589
|
+
return await invoke({ chain, action: host, facet }, args);
|
|
1590
|
+
}
|
|
1591
|
+
catch (e) {
|
|
1592
|
+
if (e instanceof ModuleCallError) {
|
|
1593
|
+
this.reportCallFailure(scheme, host, e.code, e.data, delivered, e.message);
|
|
1594
|
+
throw e;
|
|
1595
|
+
}
|
|
1596
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
1597
|
+
this.reportCallFailure(scheme, host, ERROR_UNREACHABLE, data, delivered, message);
|
|
1598
|
+
throw new ModuleCallError(ERROR_UNREACHABLE, `${scheme}.${host} could not reach its facet: ${message}`, data);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
return null;
|
|
1602
|
+
}
|
|
1603
|
+
/** The wire payload each typed-absence code has always carried — the ladder picks the code,
|
|
1604
|
+
* this composes the envelope, so the shipped shapes (errors corpus) are untouched. The two
|
|
1605
|
+
* facet-only codes carry the same triple: who was asked, for what, on which facet. */
|
|
1606
|
+
absencePayload(code, scheme, host, chain) {
|
|
1607
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
1608
|
+
if (code === ERROR_UNKNOWN_ACTION)
|
|
1609
|
+
return { action: host };
|
|
1610
|
+
if (code === ERROR_EXCLUDED) {
|
|
1611
|
+
// the DespiaExcluded-shaped entry rides VERBATIM — the same fact `.excluded` answers
|
|
1612
|
+
return this.excludedFact(chain);
|
|
1613
|
+
}
|
|
1614
|
+
if (code === ERROR_UNSUPPORTED_PLATFORM) {
|
|
1615
|
+
// the ACTION row first — it is the more specific claim (facetFacts pins the precedence)
|
|
1616
|
+
const platforms = this.unsupportedActionPlatforms.get(actionPlatformKey(chain, host)) ??
|
|
1617
|
+
this.unsupportedPlatforms.get(chain);
|
|
1618
|
+
// the platform catalog's own shape when it owns the answer; otherwise the FACET
|
|
1619
|
+
// shape — the row exists and neither provides nor reaches this runtime's word
|
|
1620
|
+
if (platforms)
|
|
1621
|
+
return { scheme, platform: JSESeams.platformOS, supportedPlatforms: platforms };
|
|
1622
|
+
}
|
|
1623
|
+
else if (code === ERROR_NOT_LOADED) {
|
|
1624
|
+
return { scheme };
|
|
1625
|
+
}
|
|
1626
|
+
return { scheme, action: host, facet: FacetSeam.facet };
|
|
1627
|
+
}
|
|
1628
|
+
return null;
|
|
1629
|
+
}
|
|
1630
|
+
async dispatchSegments(segments, args, opts = {}, face = "modern") {
|
|
1631
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
1632
|
+
const delivered = !opts.fireAndForget;
|
|
1633
|
+
// The KERNEL answers the reserved scheme's verbs before any module route (the scheme
|
|
1634
|
+
// is refused to modules, so there is never a collision): the `dsx.log` / `dsx.error`
|
|
1635
|
+
// verbs are how the DSXWebView PAGE reaches the log ring and the ambient error fan-out
|
|
1636
|
+
// (window.dsx + window.onerror forwarding — runtime.js; dot notation IS the API, the
|
|
1637
|
+
// scheme is only a bus routing key). `dsx.has("dsx")` stays false — a kernel channel,
|
|
1638
|
+
// not a module.
|
|
1639
|
+
if ((segments[0] ?? "").toLowerCase() === "dsx") {
|
|
1640
|
+
return this.kernelVerb(segments.slice(1).join("/"), args, delivered);
|
|
1641
|
+
}
|
|
1642
|
+
const r = resolveChain(segments, this.chainTable());
|
|
1643
|
+
const scheme = r.spelling;
|
|
1644
|
+
let host = r.action.join("/");
|
|
1645
|
+
if (r.member !== null) {
|
|
1646
|
+
if (face === "modern") {
|
|
1647
|
+
// a reserved member is a MEMBER route, never an action — the modern faces
|
|
1648
|
+
// refuse it (impossible through the proxies themselves, i.e. a caller bug)
|
|
1649
|
+
const data = { member: r.member, rest: r.rest.join("/") };
|
|
1650
|
+
this.reportCallFailure(scheme, [r.member, ...r.rest].join("/"), "reserved_member", data, delivered);
|
|
1651
|
+
throw new ModuleCallError("reserved_member", `${scheme}.${r.member} is a member route, never an action`, data);
|
|
1652
|
+
}
|
|
1653
|
+
// The legacy WIRE face is EXEMPT and routes DIRECT to the owner (corpus _note):
|
|
1654
|
+
// reserved words are banned from MANIFESTS, never from the v3 wire — the compat
|
|
1655
|
+
// shims exist exactly for this. The remainder rides through with its arriving
|
|
1656
|
+
// spelling; an unregistered name still answers unknown_action honestly below.
|
|
1657
|
+
const parts = segments.filter((s) => s.length > 0);
|
|
1658
|
+
host = parts.slice(parts.length - (1 + r.rest.length)).join("/");
|
|
1659
|
+
}
|
|
1660
|
+
// THE FACET RESOLUTION LADDER (facet-contracts.md, corpus Conformance/facets): local →
|
|
1661
|
+
// reach over the link → typed unavailable, decided ONCE by the pure function so every
|
|
1662
|
+
// face of this funnel answers identically and the corpus can drive the decision without
|
|
1663
|
+
// driving a call. Rung two applies per-ACTION, not just per-chain: a chain may be PARTLY
|
|
1664
|
+
// local, and a module that gained one remote action must not answer `unknown_action` for
|
|
1665
|
+
// it while its siblings resolve here.
|
|
1666
|
+
const module = this.modules.get(r.chain);
|
|
1667
|
+
// A GROUPED ACTION is declared with its dotted spelling (`assets.upload` in a manifest, the
|
|
1668
|
+
// key a web module's table carries, `dsx.group` on the natives), and the fold hands the
|
|
1669
|
+
// funnel the slash-joined path (`assets/upload`). The dotted key is the same action: without
|
|
1670
|
+
// this rung every grouped action was `unknown_action` from `dsx.module.<scheme>.<group>.<verb>()`.
|
|
1671
|
+
const grouped = host.includes("/") ? host.split("/").join(".") : null;
|
|
1672
|
+
const handler = module === undefined
|
|
1673
|
+
? undefined
|
|
1674
|
+
: (module.actions[host] ?? module.actions[host.toLowerCase()]
|
|
1675
|
+
?? (grouped === null ? undefined : (module.actions[grouped] ?? module.actions[grouped.toLowerCase()]))
|
|
1676
|
+
?? module.actions["*"]);
|
|
1677
|
+
if (module === undefined || handler === undefined) {
|
|
1678
|
+
const verdict = resolveFacetLadder(this.facetFacts(r.chain, host, module !== undefined, handler !== undefined));
|
|
1679
|
+
if (verdict.rung === "reach") {
|
|
1680
|
+
const linked = verdict.via === "link" ? this.linkRouteFor(r.chain, host) : null;
|
|
1681
|
+
return linked === null
|
|
1682
|
+
? this.callOverReach(r.chain, scheme, host, args, delivered)
|
|
1683
|
+
: this.callOverLink(linked, scheme, host, args, delivered);
|
|
1684
|
+
}
|
|
1685
|
+
// TYPED ABSENCE (durability.md P4, errors + facets corpora): the reason IS the code,
|
|
1686
|
+
// carried on the ordinary call-failure path into the ledger — never a side channel.
|
|
1687
|
+
// The ladder chose the code; the funnel composes the wire payload each code has always
|
|
1688
|
+
// carried, so the shipped envelopes are unchanged.
|
|
1689
|
+
// THE ONE FUNCTION decides which availability reason names this absence, so the call's
|
|
1690
|
+
// code can never differ from the pre-flight (excluded > unsupported_platform, v2 4.3).
|
|
1691
|
+
let code = verdict.code;
|
|
1692
|
+
if ((globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false) && (code === ERROR_UNSUPPORTED_PLATFORM || code === ERROR_EXCLUDED)) {
|
|
1693
|
+
code = this.memberAnswer(r.chain, host.split("/").join("."), args, { own: true }).reason ?? code;
|
|
1694
|
+
}
|
|
1695
|
+
const data = this.absencePayload(code, scheme, host, r.chain);
|
|
1696
|
+
this.reportCallFailure(scheme, host, code, data, delivered);
|
|
1697
|
+
throw new ModuleCallError(code, `${scheme}.${host} → ${code}`, data);
|
|
1698
|
+
}
|
|
1699
|
+
// THE RUNTIME RUNGS (availability.md): the OS floor and the device probe, the SAME function
|
|
1700
|
+
// the pre-flight asks, so `dsx.has('x.y')` and this refusal can never disagree.
|
|
1701
|
+
const refused = this.runtimeRefusal(r.chain, host, args);
|
|
1702
|
+
if (refused !== null) {
|
|
1703
|
+
const data = { scheme, action: host, platform: JSESeams.platformOS };
|
|
1704
|
+
this.reportCallFailure(scheme, host, refused, data, delivered);
|
|
1705
|
+
throw new ModuleCallError(refused, `${scheme}.${host} → ${refused}`, data);
|
|
1706
|
+
}
|
|
1707
|
+
// THE LIVE RUNG (v2.1 D10): a condition the call cannot remedy itself refuses with the
|
|
1708
|
+
// condition's own code, the same fold the pre-flight reads, so the two never disagree
|
|
1709
|
+
const blocked = this.conditionRefusal(r.chain, host, args);
|
|
1710
|
+
if (blocked !== null) {
|
|
1711
|
+
const data = { condition: blocked.code, setting: blocked.setting };
|
|
1712
|
+
this.reportCallFailure(scheme, host, blocked.code, data, delivered, blocked.explain, true);
|
|
1713
|
+
throw new ModuleCallError(blocked.code, `${scheme}.${host} → ${blocked.code}`, data);
|
|
1714
|
+
}
|
|
1715
|
+
// The module's IDENTITY (its bound dsx, declared-state writes, event names) is its
|
|
1716
|
+
// own scheme; errors keep echoing the scheme as called, like the native envelope.
|
|
1717
|
+
const identity = module.scheme.toLowerCase();
|
|
1718
|
+
// THE SETTINGS RUNG (settings-plane.ts): a declared setter's values meet the package's own rules
|
|
1719
|
+
// before its handler sees them, from every face: markup, a module, a V3 page through Legacy.
|
|
1720
|
+
const settingRefusal = this.settingsRung(identity, host, args);
|
|
1721
|
+
if (settingRefusal !== null) {
|
|
1722
|
+
this.reportCallFailure(scheme, host, SETTING_REFUSED, settingRefusal.data, delivered, settingRefusal.message);
|
|
1723
|
+
throw new ModuleCallError(SETTING_REFUSED, settingRefusal.message, settingRefusal.data);
|
|
1724
|
+
}
|
|
1725
|
+
// Funnel handle for the settle paths below (object-literal methods own their `this`).
|
|
1726
|
+
const report = (code, data, message = null, recoverable = false) => this.reportCallFailure(scheme, host, code, data, delivered, message, recoverable);
|
|
1727
|
+
const invoke = () => new Promise((resolvePromise, rejectPromise) => {
|
|
1728
|
+
let settled = false;
|
|
1729
|
+
// THE CALL'S STREAM (Article 23.6): open until the settle, or for a retained action until the
|
|
1730
|
+
// operation ends, the call fails or the caller stops it. `null` = this module installed no facts.
|
|
1731
|
+
const holderFacts = this.callFactsOf(r.chain, grouped ?? host);
|
|
1732
|
+
const retention = module.retained !== undefined
|
|
1733
|
+
? module.retained.some((a) => a.toLowerCase() === host.toLowerCase() || (grouped !== null && a.toLowerCase() === grouped.toLowerCase()))
|
|
1734
|
+
: holderFacts === null ? null : holderFacts.retained === true;
|
|
1735
|
+
// THE CALLS THIS CALL HANDS ON (relay): each stops its callee once, when this call is stopped or its
|
|
1736
|
+
// stream closes; and the controls they carry (one relay per control name).
|
|
1737
|
+
const relayStops = [];
|
|
1738
|
+
const relayedControls = new Set();
|
|
1739
|
+
const stopRelays = () => { for (const s of relayStops.splice(0))
|
|
1740
|
+
s(); };
|
|
1741
|
+
let streamOpen = true;
|
|
1742
|
+
const controls = new Map();
|
|
1743
|
+
let stopHandler = null;
|
|
1744
|
+
const closeStream = () => {
|
|
1745
|
+
if (!streamOpen)
|
|
1746
|
+
return;
|
|
1747
|
+
streamOpen = false;
|
|
1748
|
+
controls.clear();
|
|
1749
|
+
stopHandler = null;
|
|
1750
|
+
stopRelays();
|
|
1751
|
+
};
|
|
1752
|
+
const afterSettle = (failed) => {
|
|
1753
|
+
if (retention !== null && (failed || !retention))
|
|
1754
|
+
closeStream();
|
|
1755
|
+
};
|
|
1756
|
+
const routes = {
|
|
1757
|
+
chain: `${r.chain}.${grouped ?? host}`.toLowerCase(),
|
|
1758
|
+
module: r.chain.toLowerCase(),
|
|
1759
|
+
action: (grouped ?? host).toLowerCase(),
|
|
1760
|
+
open: () => streamOpen,
|
|
1761
|
+
control(name, cargs = {}) {
|
|
1762
|
+
const data = { control: name, action: host };
|
|
1763
|
+
if (!streamOpen)
|
|
1764
|
+
return Promise.reject(new ModuleCallError("call_ended", "The call this control belongs to has ended.", data));
|
|
1765
|
+
const run = controls.get(name);
|
|
1766
|
+
if (run === undefined)
|
|
1767
|
+
return Promise.reject(new ModuleCallError("unknown_control", `This call has no control named ${name}.`, data));
|
|
1768
|
+
return new Promise((ok, no) => {
|
|
1769
|
+
let done = false;
|
|
1770
|
+
const cctx = {
|
|
1771
|
+
scheme, action: host,
|
|
1772
|
+
// a control is not an attested page call: no origin, no generation (fail closed)
|
|
1773
|
+
callerOrigin: null, pageGeneration: null,
|
|
1774
|
+
args(k) { return k === undefined ? { ...cargs } : (cargs[k] === undefined ? null : cargs[k]); },
|
|
1775
|
+
socket: () => null,
|
|
1776
|
+
element(k) { throw new ModuleCallError(ERROR_UNSUPPORTED_PLATFORM, `element(${JSON.stringify(k)}): a control takes no element`, { key: k }); },
|
|
1777
|
+
resolve(v = null) { if (!done) {
|
|
1778
|
+
done = true;
|
|
1779
|
+
ok(v);
|
|
1780
|
+
} },
|
|
1781
|
+
error(code = "error", v = null) { if (!done) {
|
|
1782
|
+
done = true;
|
|
1783
|
+
no(new ModuleCallError(code, `${scheme}.${host} control ${name} failed: ${code}`, v));
|
|
1784
|
+
} },
|
|
1785
|
+
fail(code, message, _r = false, v = null) { if (!done) {
|
|
1786
|
+
done = true;
|
|
1787
|
+
no(new ModuleCallError(code, message ?? `${scheme}.${host} control ${name} failed: ${code}`, v));
|
|
1788
|
+
} },
|
|
1789
|
+
event() { },
|
|
1790
|
+
end() { },
|
|
1791
|
+
onControl() { },
|
|
1792
|
+
onStop() { return false; /* a control has no stream to stop */ },
|
|
1793
|
+
relay() { return Promise.reject(new ModuleCallError("call_ended", "A control hands on no call.", { call: "relay" })); },
|
|
1794
|
+
broadcast(n, v = null) { DSXEvents.publish(broadcastChannel(identity, n), v); },
|
|
1795
|
+
dsx: makeModuleDsx(module),
|
|
1796
|
+
};
|
|
1797
|
+
Promise.resolve().then(() => run(cctx)).then((v) => { if (!done)
|
|
1798
|
+
cctx.resolve(v ?? null); })
|
|
1799
|
+
.catch((e) => {
|
|
1800
|
+
const t = (typeof e === "object" && e !== null ? e : {});
|
|
1801
|
+
cctx.fail(typeof t.code === "string" ? t.code : "error", typeof t.message === "string" ? t.message : undefined, false, t.data ?? null);
|
|
1802
|
+
});
|
|
1803
|
+
});
|
|
1804
|
+
},
|
|
1805
|
+
stop() {
|
|
1806
|
+
if (!streamOpen)
|
|
1807
|
+
return;
|
|
1808
|
+
// As on the native lanes (runOnStop, then closeStream): the call's own onStop runs first, so
|
|
1809
|
+
// what it reports synchronously (a speech `cancel`) still reaches its caller; then the
|
|
1810
|
+
// stream ends and every later event is dropped.
|
|
1811
|
+
const own = stopHandler;
|
|
1812
|
+
stopHandler = null;
|
|
1813
|
+
if (own !== null) {
|
|
1814
|
+
try {
|
|
1815
|
+
const pending = own(ctx);
|
|
1816
|
+
if (pending instanceof Promise)
|
|
1817
|
+
pending.catch(() => { });
|
|
1818
|
+
}
|
|
1819
|
+
catch { /* a throwing stop handler still ends the stream */ }
|
|
1820
|
+
}
|
|
1821
|
+
// then the calls it hands on, in the same turn, while its stream is still open: what each
|
|
1822
|
+
// callee emits on its stop still reaches this call's caller (relay, R4)
|
|
1823
|
+
stopRelays();
|
|
1824
|
+
closeStream();
|
|
1825
|
+
},
|
|
1826
|
+
};
|
|
1827
|
+
if (opts.call !== undefined) {
|
|
1828
|
+
const value = Object.freeze(Object.create(null));
|
|
1829
|
+
CALL_ROUTES.set(value, routes);
|
|
1830
|
+
markCallValue(value, () => routes.stop(), () => routes.open());
|
|
1831
|
+
opts.call(value);
|
|
1832
|
+
}
|
|
1833
|
+
const registry = this;
|
|
1834
|
+
const relay = (target, rargs = {}, ropts = {}) => {
|
|
1835
|
+
const refuse = (code, message, data) => Promise.reject(new ModuleCallError(code, message, data));
|
|
1836
|
+
if (!streamOpen)
|
|
1837
|
+
return refuse("call_ended", "relay: this call has ended.", { call: "relay" });
|
|
1838
|
+
const path = target !== null && (typeof target === "object" || typeof target === "function") ? CHAIN_PATHS.get(target) : undefined;
|
|
1839
|
+
if (path === undefined || path.length < 2)
|
|
1840
|
+
return refuse("invalid_param", "relay: the target is not a module action.", { call: "relay" });
|
|
1841
|
+
const chain = path.join(".");
|
|
1842
|
+
// THE LINEAGE (a safety line): a relay whose target is already in its own chain of relays, or a chain
|
|
1843
|
+
// deeper than RELAY_DEPTH_LIMIT, is refused, so a configuration that names an owner as its own
|
|
1844
|
+
// provider degrades one call instead of exhausting the stack or the heap (Article 7).
|
|
1845
|
+
const own = `${r.chain}.${grouped ?? host}`.toLowerCase();
|
|
1846
|
+
const lineage = [...(opts.lineage ?? []), own];
|
|
1847
|
+
const at = chain.toLowerCase();
|
|
1848
|
+
if (lineage.includes(at) || lineage.length >= RELAY_DEPTH_LIMIT) {
|
|
1849
|
+
return refuse("invalid_param", `relay: ${at} is already in this chain of relays, or the chain is too deep.`, { call: "relay", cycle: [...lineage, at] });
|
|
1850
|
+
}
|
|
1851
|
+
const calleeFacts = registry.callFactsOf(path.slice(0, -1).join("."), path[path.length - 1]);
|
|
1852
|
+
const declared = (names) => Object.fromEntries([...(names ?? [])].map((n) => [n, n]));
|
|
1853
|
+
const eventMap = ropts.events ?? (holderFacts === null ? {} : declared(Object.keys(holderFacts.events ?? {})));
|
|
1854
|
+
const controlMap = ropts.controls ?? (holderFacts === null ? {} : declared(holderFacts.controls));
|
|
1855
|
+
// a map only RENAMES: on a scheme with installed facts, every name it gives must be one this action declares
|
|
1856
|
+
if (holderFacts !== null) {
|
|
1857
|
+
const undeclared = Object.keys(eventMap).find((n) => !Object.prototype.hasOwnProperty.call(holderFacts.events ?? {}, n));
|
|
1858
|
+
if (undeclared !== undefined)
|
|
1859
|
+
return refuse("invalid_param", `relay: ${scheme}.${host} declares no event ${undeclared}.`, { call: "relay", event: undeclared });
|
|
1860
|
+
const ctl = Object.keys(controlMap).find((n) => !(holderFacts.controls ?? []).includes(n));
|
|
1861
|
+
if (ctl !== undefined)
|
|
1862
|
+
return refuse("invalid_param", `relay: ${scheme}.${host} declares no control ${ctl}.`, { call: "relay", control: ctl });
|
|
1863
|
+
}
|
|
1864
|
+
for (const name of Object.keys(controlMap)) {
|
|
1865
|
+
if (relayedControls.has(name)) {
|
|
1866
|
+
return refuse("invalid_param", `relay: the control ${name} already belongs to another relay of this call.`, { call: "relay", control: name });
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
// callee name -> this action's names
|
|
1870
|
+
const byCallee = new Map();
|
|
1871
|
+
for (const [mine, theirs] of Object.entries(eventMap))
|
|
1872
|
+
byCallee.set(theirs, [...(byCallee.get(theirs) ?? []), mine]);
|
|
1873
|
+
const noted = new Set();
|
|
1874
|
+
const forward = (name, value) => {
|
|
1875
|
+
const mine = byCallee.get(name);
|
|
1876
|
+
if (mine === undefined) {
|
|
1877
|
+
// not this action's event: it stays on the callee's call (Article 21.1); noted once
|
|
1878
|
+
if (!noted.has(name)) {
|
|
1879
|
+
noted.add(name);
|
|
1880
|
+
console.debug(`[dsx relay] ${scheme}.${host}: ${name} is not an event of this action; not forwarded`);
|
|
1881
|
+
}
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
for (const mineName of mine) {
|
|
1885
|
+
const payload = ropts.event === undefined ? value : ropts.event(mineName, value);
|
|
1886
|
+
if (holderFacts !== null) {
|
|
1887
|
+
const wide = relayPayloadViolation(payload, holderFacts.events?.[mineName] ?? null);
|
|
1888
|
+
if (wide !== null) {
|
|
1889
|
+
registry.reportAmbientError(identity, "invalid_param", {
|
|
1890
|
+
message: `relay: ${wide} of ${mineName} is not what ${scheme}.${host} declares; the event is refused.`,
|
|
1891
|
+
data: { call: "relay", event: mineName, field: wide }, origin: "uncaught"
|
|
1892
|
+
});
|
|
1893
|
+
continue;
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
ctx.event(mineName, payload);
|
|
1897
|
+
}
|
|
1898
|
+
};
|
|
1899
|
+
let held = null;
|
|
1900
|
+
let stopped = false;
|
|
1901
|
+
// the controls, before the callee's handler runs: one sent in reply to an event raised inside that handler
|
|
1902
|
+
// reaches the callee (D8)
|
|
1903
|
+
const mineControls = [];
|
|
1904
|
+
for (const [mine, theirs] of Object.entries(controlMap)) {
|
|
1905
|
+
relayedControls.add(mine);
|
|
1906
|
+
if (controls.has(mine))
|
|
1907
|
+
continue; // a handler this call registered itself wins
|
|
1908
|
+
mineControls.push(mine);
|
|
1909
|
+
controls.set(mine, async (cctx) => {
|
|
1910
|
+
if (calleeFacts !== null && !(calleeFacts.controls ?? []).includes(theirs)) {
|
|
1911
|
+
throw new ModuleCallError("unsupported_by_provider", `${chain} declares no control ${theirs}.`, { action: `${scheme}.${host}`, control: mine, raw: chain });
|
|
1912
|
+
}
|
|
1913
|
+
if (held === null)
|
|
1914
|
+
throw new ModuleCallError("call_ended", "relay: the call this control reaches has not started.", { control: mine });
|
|
1915
|
+
const cargs = cctx.args();
|
|
1916
|
+
let sent = cargs;
|
|
1917
|
+
if (ropts.control !== undefined) {
|
|
1918
|
+
try {
|
|
1919
|
+
sent = ropts.control(mine, cargs);
|
|
1920
|
+
}
|
|
1921
|
+
catch (e) {
|
|
1922
|
+
throw e instanceof ModuleCallError ? e : new ModuleCallError("invalid_param", `relay: the control ${mine} was refused.`, { control: mine });
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
return registry.control(held, `${chain}.${theirs}`, sent);
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
// bound BEFORE the callee's handler runs, so an event it raises inside that handler is forwarded;
|
|
1929
|
+
// a retained callee whose stream ends (its `end()`) ends this call too, by default (R7)
|
|
1930
|
+
const ended = () => { if (streamOpen && !stopped)
|
|
1931
|
+
(ropts.ended ?? (() => ctx.end()))(); };
|
|
1932
|
+
const settled = registry.call(chain, rargs, { held: true, events: forward, ended, lineage, call: (v) => { held = v; } });
|
|
1933
|
+
relayStops.push(() => {
|
|
1934
|
+
if (stopped || held === null)
|
|
1935
|
+
return;
|
|
1936
|
+
stopped = true;
|
|
1937
|
+
registry.stop(held).catch(() => { });
|
|
1938
|
+
});
|
|
1939
|
+
// a refusal releases the names this relay reserved
|
|
1940
|
+
return settled.catch((e) => {
|
|
1941
|
+
for (const n of Object.keys(controlMap))
|
|
1942
|
+
relayedControls.delete(n);
|
|
1943
|
+
for (const n of mineControls)
|
|
1944
|
+
controls.delete(n);
|
|
1945
|
+
throw e;
|
|
1946
|
+
});
|
|
1947
|
+
};
|
|
1948
|
+
const ctx = {
|
|
1949
|
+
scheme,
|
|
1950
|
+
action: host,
|
|
1951
|
+
relay,
|
|
1952
|
+
args(k) {
|
|
1953
|
+
if (k === undefined) {
|
|
1954
|
+
const out = {};
|
|
1955
|
+
for (const [kk, v] of Object.entries(args))
|
|
1956
|
+
if (!kk.startsWith("__"))
|
|
1957
|
+
out[kk] = plainNulls(v);
|
|
1958
|
+
return out;
|
|
1959
|
+
}
|
|
1960
|
+
const v = args[k];
|
|
1961
|
+
return v === undefined ? null : plainNulls(v);
|
|
1962
|
+
},
|
|
1963
|
+
socket(as) {
|
|
1964
|
+
return opts.sockets?.(as) ?? null;
|
|
1965
|
+
},
|
|
1966
|
+
element(k) {
|
|
1967
|
+
// THE ONE ACCESSOR (ADR 0025 D6). A handle the calling document passed (`dsx.this.target`,
|
|
1968
|
+
// `dsx.ref.<name>`) is answered as it is while its element is mounted; a handle whose element has
|
|
1969
|
+
// unmounted is `element_detached`; anything else (no value, a serialized reference that no
|
|
1970
|
+
// mounted document resolved, a rectangle) is `element_required`. No package resolves one itself.
|
|
1971
|
+
const v = args[k];
|
|
1972
|
+
if (isDsxElement(v)) {
|
|
1973
|
+
if (!v.isConnected)
|
|
1974
|
+
throw new ModuleCallError(ELEMENT_DETACHED, `element(${JSON.stringify(k)}): the element is no longer mounted`, { key: k });
|
|
1975
|
+
return v;
|
|
1976
|
+
}
|
|
1977
|
+
throw new ModuleCallError(ELEMENT_REQUIRED, `element(${JSON.stringify(k)}): the argument is not an element handle (pass dsx.this.target, dsx.this.currentTarget or dsx.ref.<name> from a mounted document)`, { key: k });
|
|
1978
|
+
},
|
|
1979
|
+
resolve(data = null) {
|
|
1980
|
+
if (settled)
|
|
1981
|
+
return;
|
|
1982
|
+
settled = true;
|
|
1983
|
+
afterSettle(false);
|
|
1984
|
+
resolvePromise(data);
|
|
1985
|
+
},
|
|
1986
|
+
error(code = "error", data = null) {
|
|
1987
|
+
if (settled)
|
|
1988
|
+
return;
|
|
1989
|
+
settled = true;
|
|
1990
|
+
afterSettle(true);
|
|
1991
|
+
report(code, data);
|
|
1992
|
+
rejectPromise(new ModuleCallError(code, `${scheme}.${host} failed: ${code}`, data));
|
|
1993
|
+
},
|
|
1994
|
+
fail(code, message, recoverable = false, data = null) {
|
|
1995
|
+
if (settled)
|
|
1996
|
+
return;
|
|
1997
|
+
settled = true;
|
|
1998
|
+
afterSettle(true);
|
|
1999
|
+
report(code, data, message ?? null, recoverable); // full fidelity into the record
|
|
2000
|
+
rejectPromise(new ModuleCallError(code, message ?? `${scheme}.${host} failed: ${code}`, data));
|
|
2001
|
+
},
|
|
2002
|
+
event(name, value = null) {
|
|
2003
|
+
if (!streamOpen)
|
|
2004
|
+
return;
|
|
2005
|
+
// A CALL event belongs to the call that started it (Article 23.6): it reaches that
|
|
2006
|
+
// caller's stream (CallOpts.events) and nobody else, as on the native lanes. The
|
|
2007
|
+
// module's channel `<scheme>:<name>` carries its broadcasts (broadcastChannel), which
|
|
2008
|
+
// are for independent subscribers; a lane that tells both sends one of each.
|
|
2009
|
+
opts.events?.(name, value);
|
|
2010
|
+
if (name === "error" && retention !== null)
|
|
2011
|
+
closeStream();
|
|
2012
|
+
},
|
|
2013
|
+
end() {
|
|
2014
|
+
if (!streamOpen)
|
|
2015
|
+
return;
|
|
2016
|
+
closeStream();
|
|
2017
|
+
// A retained call that has not settled is settled by its end (the native `ended` twin);
|
|
2018
|
+
// any other call keeps its own resolve or failure.
|
|
2019
|
+
if (retention === true && !settled) {
|
|
2020
|
+
settled = true;
|
|
2021
|
+
resolvePromise(null);
|
|
2022
|
+
}
|
|
2023
|
+
if (retention === true)
|
|
2024
|
+
opts.ended?.();
|
|
2025
|
+
},
|
|
2026
|
+
onStop(fn) { if (!streamOpen)
|
|
2027
|
+
return false; stopHandler = fn; return true; },
|
|
2028
|
+
onControl(name, fn) { if (streamOpen)
|
|
2029
|
+
controls.set(name, fn); },
|
|
2030
|
+
broadcast(name, value = null) {
|
|
2031
|
+
DSXEvents.publish(broadcastChannel(identity, name), value);
|
|
2032
|
+
},
|
|
2033
|
+
dsx: makeModuleDsx(module),
|
|
2034
|
+
callerOrigin: opts.callerOrigin === undefined ? null : normalizeCallerOrigin(opts.callerOrigin),
|
|
2035
|
+
pageGeneration: opts.callerOrigin === undefined || typeof opts.pageGeneration !== "number" ? null : opts.pageGeneration,
|
|
2036
|
+
};
|
|
2037
|
+
Promise.resolve()
|
|
2038
|
+
.then(() => handler(ctx))
|
|
2039
|
+
.then((v) => {
|
|
2040
|
+
// returned value = implicit resolve (the lean authoring shape)
|
|
2041
|
+
if (!settled && v !== undefined)
|
|
2042
|
+
ctx.resolve(v ?? null);
|
|
2043
|
+
else if (!settled && v === undefined && !(opts.held === true && retention === true))
|
|
2044
|
+
ctx.resolve(null);
|
|
2045
|
+
})
|
|
2046
|
+
.catch((e) => {
|
|
2047
|
+
if (settled)
|
|
2048
|
+
return;
|
|
2049
|
+
settled = true;
|
|
2050
|
+
afterSettle(true);
|
|
2051
|
+
// A web facet refuses by throwing an Error carrying a string `code` (the twin of
|
|
2052
|
+
// dsx.fail natively): the code, message, recoverable and data survive, the same law
|
|
2053
|
+
// the errors corpus holds for a thrown dict (7). Only a codeless throw is "error".
|
|
2054
|
+
const thrown = (typeof e === "object" && e !== null ? e : {});
|
|
2055
|
+
if (!(e instanceof ModuleCallError) && typeof thrown.code === "string" && thrown.code !== "") {
|
|
2056
|
+
const message = typeof thrown.message === "string" ? thrown.message : `${scheme}.${host} failed: ${thrown.code}`;
|
|
2057
|
+
const data = thrown.data === undefined ? null : thrown.data;
|
|
2058
|
+
report(thrown.code, data, message, thrown.recoverable === true);
|
|
2059
|
+
rejectPromise(new ModuleCallError(thrown.code, message, data));
|
|
2060
|
+
return;
|
|
2061
|
+
}
|
|
2062
|
+
const err = e instanceof ModuleCallError ? e : new ModuleCallError("error", String(e));
|
|
2063
|
+
report(err.code, err.data ?? String(e));
|
|
2064
|
+
rejectPromise(err);
|
|
2065
|
+
});
|
|
2066
|
+
});
|
|
2067
|
+
// THE DATA IS ALREADY THERE (read-cache.ts): a declared read answers from the held answer and
|
|
2068
|
+
// revalidates behind it; a declared write marks what it changes stale once it has settled.
|
|
2069
|
+
if (ReadCache.isRead(identity, host))
|
|
2070
|
+
return await ReadCache.read(identity, host, args, invoke);
|
|
2071
|
+
const value = await invoke();
|
|
2072
|
+
ReadCache.wrote(identity, host);
|
|
2073
|
+
return value;
|
|
2074
|
+
}
|
|
2075
|
+
return null;
|
|
2076
|
+
}
|
|
2077
|
+
object(scheme, name) {
|
|
2078
|
+
const module = this.modules.get(scheme.toLowerCase());
|
|
2079
|
+
return module?.objects?.[name]?.() ?? null;
|
|
2080
|
+
}
|
|
2081
|
+
/** Resolve a module-provided component (/web/18). A qualified tag's prefix is everything
|
|
2082
|
+
* before its LAST dot, the providing module's chain (`payments.stripe.connect.Payouts` is
|
|
2083
|
+
* module `payments.stripe.connect`, component `Payouts`; R1, corpus chains.json
|
|
2084
|
+
* `componentTags`); bare `Name` → the ONE registered module providing it (a cross-package
|
|
2085
|
+
* ambiguity resolves to none, loudly: qualify the tag). The impl stays opaque here (kernel
|
|
2086
|
+
* DOM-free law); the renderer holds it to its contract. */
|
|
2087
|
+
facetComponent(tag) {
|
|
2088
|
+
const dot = tag.lastIndexOf(".");
|
|
2089
|
+
if (dot >= 0) {
|
|
2090
|
+
const scheme = tag.substring(0, dot).toLowerCase();
|
|
2091
|
+
const name = tag.substring(dot + 1);
|
|
2092
|
+
if (scheme.length === 0 || name.length === 0)
|
|
2093
|
+
return null;
|
|
2094
|
+
const impl = this.modules.get(scheme)?.components?.[name];
|
|
2095
|
+
return impl === undefined ? null : { scheme, name, impl };
|
|
2096
|
+
}
|
|
2097
|
+
const hits = [];
|
|
2098
|
+
const seen = new Set(); // one module can front more than one component
|
|
2099
|
+
for (const m of this.modules.values()) {
|
|
2100
|
+
if (seen.has(m))
|
|
2101
|
+
continue;
|
|
2102
|
+
seen.add(m);
|
|
2103
|
+
const impl = m.components?.[tag];
|
|
2104
|
+
if (impl !== undefined)
|
|
2105
|
+
hits.push({ scheme: m.scheme.toLowerCase(), name: tag, impl });
|
|
2106
|
+
}
|
|
2107
|
+
if (hits.length > 1) {
|
|
2108
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DIAGNOSTICS__ !== false)
|
|
2109
|
+
console.warn(`[dsx bus] component <${tag}> is provided by ${hits.map((h) => h.scheme).join(" + ")} — qualify the tag (<${hits[0].scheme}.${tag}>)`);
|
|
2110
|
+
return null;
|
|
2111
|
+
}
|
|
2112
|
+
return hits[0] ?? null;
|
|
2113
|
+
}
|
|
2114
|
+
/** The reserved scheme's kernel verbs (logs corpus / errors corpus): `log` records one
|
|
2115
|
+
* line ({ message, scheme? } — source defaults to "page", the bridge's caller), `error`
|
|
2116
|
+
* runs the ambient fan-out ({ code, message?, recoverable?, data?, scheme? }). Both
|
|
2117
|
+
* resolve null. Anything else answers `unknown_action` honestly — never `not_loaded`
|
|
2118
|
+
* (the kernel does own this scheme). */
|
|
2119
|
+
async kernelVerb(host, args, delivered) {
|
|
2120
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
2121
|
+
const action = host.toLowerCase();
|
|
2122
|
+
const source = string(args["scheme"] ?? "") || "page";
|
|
2123
|
+
if (action === "log") {
|
|
2124
|
+
reportLog(source, "log", string(args["message"] ?? ""));
|
|
2125
|
+
return null;
|
|
2126
|
+
}
|
|
2127
|
+
if (action === "error") {
|
|
2128
|
+
const m = args["message"];
|
|
2129
|
+
this.reportAmbientError(source, string(args["code"] ?? "") || "error", {
|
|
2130
|
+
message: m === undefined || m === null || m === NSNull ? null : string(m),
|
|
2131
|
+
recoverable: truthy(args["recoverable"]),
|
|
2132
|
+
data: args["data"],
|
|
2133
|
+
});
|
|
2134
|
+
return null;
|
|
2135
|
+
}
|
|
2136
|
+
this.reportCallFailure("dsx", host, "unknown_action", { action }, delivered);
|
|
2137
|
+
throw new ModuleCallError("unknown_action", `dsx.${host} is not a kernel verb`, { action });
|
|
2138
|
+
}
|
|
2139
|
+
return null;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
/** The inert registry's one throw (see below). */
|
|
2143
|
+
function noModuleHost() { throw new Error("[dsx bus] this widget was built without a module host"); }
|
|
2144
|
+
/** THE INERT MODULE HOST (`__DSX_OPTIONAL_MODULE_HOST__`, cli embed entry.ts `registryUsesModuleHost`), the twin of
|
|
2145
|
+
* dom mount.ts `NO_ACTION_RUNNER`. A widget whose slice registers no module, mounts no package component, spells no
|
|
2146
|
+
* `dsx.` door to a module (`dsx.module`, `dsx.has`, `dsx.delegate`, `dsx.stop`, `dsx.config`), hears no
|
|
2147
|
+
* `on:<chain>.<event>`, decides no tag at run time and uses no row a package declares can never put a module or a
|
|
2148
|
+
* delegate listener into this registry, and nothing outside the bundle can reach it (an embed exports nothing). The
|
|
2149
|
+
* registry stays EMPTY for the widget's whole life, so every answer it can give is the empty registry's answer, and
|
|
2150
|
+
* this object gives exactly those: no module is available (`has`, `isAvailable`), nobody listens (`hasWatchers`, so
|
|
2151
|
+
* `handler.start` is never built), a delegate fold has no listener to ask (`foldDelegate`: `void`/`claim`/`any`
|
|
2152
|
+
* null, `collect` [], `veto` true), no component is a package's (`facetComponent`), a call answers what the folded
|
|
2153
|
+
* dispatch answers (the fold is decided only where `__DSX_OPTIONAL_MODULE_DISPATCH__` is folded too, and the folded
|
|
2154
|
+
* `dispatchSegments` resolves null), a stop or a control finds no live call (the shared `stopCall`, `controlEnded`,
|
|
2155
|
+
* `namesCallControl`), and an ambient error runs the one fan-out (`reportAmbient`) with nobody on `module.error`.
|
|
2156
|
+
* Registering a module or a listener here would be a wrong fold decision, so it throws instead of dropping it
|
|
2157
|
+
* silently. Why it exists: esbuild never drops a class member, so the empty registry carried every member of
|
|
2158
|
+
* `ModuleRegistryImpl` into every widget. STOPGAP (Article 17.4) for moving the registry's administration surface out
|
|
2159
|
+
* of the class (WIDGET-EMBED-BUDGET design 3.2b), backlog row EMBED-MEMBER-FOLDS-STOPGAP-1120. */
|
|
2160
|
+
const NO_MODULE_REGISTRY = {
|
|
2161
|
+
has: () => false,
|
|
2162
|
+
isAvailable: () => false,
|
|
2163
|
+
hasWatchers: () => false,
|
|
2164
|
+
facetComponent: () => null,
|
|
2165
|
+
foldDelegate: (_event, _input = null, combine = "claim") => combine === "collect" ? [] : combine === "veto" ? true : null,
|
|
2166
|
+
reportAmbientError: (scheme, code, opts = {}) => reportAmbient(() => { }, scheme, code, opts),
|
|
2167
|
+
call: async () => null,
|
|
2168
|
+
dispatch: async () => null,
|
|
2169
|
+
stop: stopCall,
|
|
2170
|
+
namesControl: namesCallControl,
|
|
2171
|
+
control: (_call, path) => controlEnded(path.lastIndexOf(".") > 0 ? path.slice(path.lastIndexOf(".") + 1) : ""),
|
|
2172
|
+
// one throw for both: the build decided this widget can register nothing, so a registration is a build defect
|
|
2173
|
+
register: noModuleHost,
|
|
2174
|
+
registerDelegate: noModuleHost,
|
|
2175
|
+
};
|
|
2176
|
+
export const ModuleRegistry = globalThis.__DSX_OPTIONAL_MODULE_HOST__ !== false
|
|
2177
|
+
? new ModuleRegistryImpl() : NO_MODULE_REGISTRY;
|
|
2178
|
+
// `dsx.config.<chain>.<key>` (public-config.ts). An embed whose slice spells no `dsx.config` read folds the seam
|
|
2179
|
+
// (`__DSX_OPTIONAL_PUBLIC_CONFIG__`, cli embed/entry.ts registryUsesPublicConfig) and JSE keeps its null default.
|
|
2180
|
+
if (globalThis.__DSX_OPTIONAL_PUBLIC_CONFIG__ !== false) {
|
|
2181
|
+
JSESeams.configRead = (path) => ModuleRegistry.readConfig(path);
|
|
2182
|
+
}
|
|
2183
|
+
// availability seam for `has(scheme)` / `visible-if="has:x"`
|
|
2184
|
+
JSESeams.moduleAvailable = (scheme, args) => ModuleRegistry.has(scheme, args);
|
|
2185
|
+
if ((globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false)) {
|
|
2186
|
+
JSESeams.moduleAvailability = (chain, member, args) => member === null ? ModuleRegistry.moduleAvailability(chain) : ModuleRegistry.memberAvailability(chain, member, args);
|
|
2187
|
+
}
|
|
2188
|
+
// the reactive tick: a CHANGED probe answer republishes this key, and every `dsx.has('x.y')` /
|
|
2189
|
+
// `dsx.module.x.availability.*` read tracked under the global head `availability` re-evaluates.
|
|
2190
|
+
if ((globalThis.__DSX_OPTIONAL_AVAILABILITY__ !== false))
|
|
2191
|
+
ModuleRegistry.probes.onChange(() => DSXState.set("availability.version", ModuleRegistry.probes.version));
|
|
2192
|
+
// ── DSXEvents (scheme:event pub/sub — the `despia.on` / dsx.delegate.listen twin) ───────────────
|
|
2193
|
+
/** THE FAN OUT LAW (Conformance/bus/fan-out.json), one law on four renderers:
|
|
2194
|
+
*
|
|
2195
|
+
* 1. publish order is subscription order
|
|
2196
|
+
* 2. a re-entrant publish QUEUES behind the current one, on one queue for the whole bus
|
|
2197
|
+
* 3. an unsubscribe during delivery takes effect for the NEXT publish (the subscriber
|
|
2198
|
+
* set of a publish is frozen when that publish begins delivering, and a subscribe
|
|
2199
|
+
* during delivery is the mirror: absent here, present next)
|
|
2200
|
+
* 4. a subscriber that throws is reported through the diagnostic channel and never
|
|
2201
|
+
* stops delivery
|
|
2202
|
+
*
|
|
2203
|
+
* Clause 3 is what makes clause 1 checkable: consulting the live registry mid-flight
|
|
2204
|
+
* would make the delivery log a function of what each handler did to the registry, and a
|
|
2205
|
+
* hundred-publish recording would stop being a function of the script. This lane used to
|
|
2206
|
+
* iterate the live Set (clause 3 broken), recurse (clause 2 broken), and report a throw
|
|
2207
|
+
* to console.warn alone. */
|
|
2208
|
+
class DSXEventsImpl {
|
|
2209
|
+
listeners = new Map();
|
|
2210
|
+
queue = [];
|
|
2211
|
+
#draining = false;
|
|
2212
|
+
/** THE diagnostic channel for a throwing subscriber. The default is the web lane's own
|
|
2213
|
+
* error record: the kernel warning plus a ledger row, which is where every other
|
|
2214
|
+
* swallowed failure in this file lands. Replaceable so a host (and the corpus runner)
|
|
2215
|
+
* can observe it; a replacement never changes the fact that delivery continues. */
|
|
2216
|
+
diagnostic = (name, error) => {
|
|
2217
|
+
console.warn(`[dsx events] ${name}:`, error);
|
|
2218
|
+
DSXErrors.append({
|
|
2219
|
+
code: "event_subscriber_failed",
|
|
2220
|
+
message: error instanceof Error ? error.message : String(error),
|
|
2221
|
+
recoverable: true, data: null, scheme: name, origin: "call", delivered: false, at: Date.now(),
|
|
2222
|
+
});
|
|
2223
|
+
};
|
|
2224
|
+
on(name, fn) {
|
|
2225
|
+
const set = this.listeners.get(name) ?? new Set();
|
|
2226
|
+
set.add(fn);
|
|
2227
|
+
this.listeners.set(name, set);
|
|
2228
|
+
this.refreshWatchers();
|
|
2229
|
+
return () => { if (set.delete(fn))
|
|
2230
|
+
this.refreshWatchers(); };
|
|
2231
|
+
}
|
|
2232
|
+
/** Who asked to hear when a channel gains its first subscriber or loses its last, and the answer they last heard. */
|
|
2233
|
+
presence = new Map();
|
|
2234
|
+
/** WOULD ANYONE HEAR `channel` (bus/watcher-presence.json; Article 20.3): a subscriber of the channel itself, or of
|
|
2235
|
+
* its chain's `<chain>:*` (the module handle's kind-less `.on(handler)`, which `deliver` reaches for every kind).
|
|
2236
|
+
* The module handle asks it scoped to its own broadcasts, `dsx.events.hasWatchers(name)`. Twins: Swift and
|
|
2237
|
+
* Kotlin `DSXEventBus.hasWatchers`. */
|
|
2238
|
+
hasWatchers(channel) {
|
|
2239
|
+
if ((this.listeners.get(channel)?.size ?? 0) > 0)
|
|
2240
|
+
return true;
|
|
2241
|
+
const colon = channel.indexOf(":");
|
|
2242
|
+
return colon > 0 && (this.listeners.get(`${channel.substring(0, colon)}:*`)?.size ?? 0) > 0;
|
|
2243
|
+
}
|
|
2244
|
+
/** HEAR WHEN `channel` GAINS ITS FIRST SUBSCRIBER OR LOSES ITS LAST: `fn(true)` / `fn(false)`, on the subscribe or
|
|
2245
|
+
* unsubscribe that changed the answer, in the order the observers registered. Nothing is called here; read
|
|
2246
|
+
* `hasWatchers` for the present answer (the delegate plane's `ModuleRegistry.observeWatchers` is the same rule).
|
|
2247
|
+
* An observer that throws is reported through `diagnostic` and the next observer still hears. Returns the stop. */
|
|
2248
|
+
observeWatchers(channel, fn) {
|
|
2249
|
+
let entry = this.presence.get(channel);
|
|
2250
|
+
if (entry === undefined) {
|
|
2251
|
+
entry = { watched: this.hasWatchers(channel), observers: new Set() };
|
|
2252
|
+
this.presence.set(channel, entry);
|
|
2253
|
+
}
|
|
2254
|
+
entry.observers.add(fn);
|
|
2255
|
+
return () => {
|
|
2256
|
+
const current = this.presence.get(channel);
|
|
2257
|
+
if (current === undefined)
|
|
2258
|
+
return;
|
|
2259
|
+
current.observers.delete(fn);
|
|
2260
|
+
if (current.observers.size === 0)
|
|
2261
|
+
this.presence.delete(channel);
|
|
2262
|
+
};
|
|
2263
|
+
}
|
|
2264
|
+
refreshWatchers() {
|
|
2265
|
+
for (const [channel, entry] of [...this.presence]) {
|
|
2266
|
+
const watched = this.hasWatchers(channel);
|
|
2267
|
+
if (watched === entry.watched)
|
|
2268
|
+
continue;
|
|
2269
|
+
entry.watched = watched;
|
|
2270
|
+
for (const fn of [...entry.observers]) {
|
|
2271
|
+
try {
|
|
2272
|
+
fn(watched);
|
|
2273
|
+
}
|
|
2274
|
+
catch (e) {
|
|
2275
|
+
this.diagnostic(channel, e);
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
publish(name, value) {
|
|
2281
|
+
this.queue.push({ name, value });
|
|
2282
|
+
if (this.#draining)
|
|
2283
|
+
return; // clause 2: queue behind the publish in flight
|
|
2284
|
+
this.#draining = true;
|
|
2285
|
+
try {
|
|
2286
|
+
for (;;) {
|
|
2287
|
+
const next = this.queue.shift();
|
|
2288
|
+
if (next === undefined)
|
|
2289
|
+
break;
|
|
2290
|
+
this.deliver(next.name, next.value);
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
finally {
|
|
2294
|
+
this.#draining = false;
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
/** One publish, delivered. The two subscriber sets are COPIED here, at the moment this
|
|
2298
|
+
* publish begins, which is clause 3. */
|
|
2299
|
+
deliver(name, value) {
|
|
2300
|
+
for (const fn of [...(this.listeners.get(name) ?? [])]) {
|
|
2301
|
+
try {
|
|
2302
|
+
fn(value);
|
|
2303
|
+
}
|
|
2304
|
+
catch (e) {
|
|
2305
|
+
this.diagnostic(name, e);
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
// the `<chain>:*` wildcard, the module handle's kind-less `.on(handler)`: every
|
|
2309
|
+
// event published under the chain, delivered as handler(value, kind)
|
|
2310
|
+
const colon = name.indexOf(":");
|
|
2311
|
+
if (colon > 0) {
|
|
2312
|
+
const kind = name.substring(colon + 1);
|
|
2313
|
+
for (const fn of [...(this.listeners.get(`${name.substring(0, colon)}:*`) ?? [])]) {
|
|
2314
|
+
try {
|
|
2315
|
+
fn(value, kind);
|
|
2316
|
+
}
|
|
2317
|
+
catch (e) {
|
|
2318
|
+
this.diagnostic(name, e);
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
export const DSXEvents = new DSXEventsImpl();
|
|
2325
|
+
function moduleEvents(scheme) {
|
|
2326
|
+
return {
|
|
2327
|
+
on: (name, fn) => DSXEvents.on(name, fn),
|
|
2328
|
+
publish: (name, value) => DSXEvents.publish(name, value),
|
|
2329
|
+
get diagnostic() { return DSXEvents.diagnostic; },
|
|
2330
|
+
set diagnostic(fn) { DSXEvents.diagnostic = fn; },
|
|
2331
|
+
hasWatchers: (name) => DSXEvents.hasWatchers(broadcastChannel(scheme, name)),
|
|
2332
|
+
observeWatchers: (name, fn) => DSXEvents.observeWatchers(broadcastChannel(scheme, name), fn),
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
/** The declared-variable read plane, served by `.context` over the identity chain. */
|
|
2336
|
+
function contextProxy(chain) {
|
|
2337
|
+
const identity = chain.toLowerCase();
|
|
2338
|
+
return new Proxy({}, {
|
|
2339
|
+
get(_t, varName) {
|
|
2340
|
+
if (!proxyAdmits(varName))
|
|
2341
|
+
return undefined;
|
|
2342
|
+
return DSXState.get(`${identity}.${varName}`);
|
|
2343
|
+
},
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
/** One dotted-chain node (`dsx.module.watch.health.heartRate`): each property get
|
|
2347
|
+
* extends the path one segment; a call at any depth rides the ONE funnel (the fold
|
|
2348
|
+
* settles identity vs action — a bare chain call included). At an IDENTITY position
|
|
2349
|
+
* (no action segments yet) the reserved members answer the MEMBER plane; past it,
|
|
2350
|
+
* `.post` is the fire-and-forget verb on the bound action. */
|
|
2351
|
+
/** The first argument of a module call names a CALL: a value this bus minted (live or ended), or a value only
|
|
2352
|
+
* shaped like one (frozen, no prototype, no members) or a thenable, which the bus never minted (a value from
|
|
2353
|
+
* another runtime instance, a settled copy, a forgery). The second kind is refused `call_ended` by `control`,
|
|
2354
|
+
* exactly as the page bridge refuses it (`runtime.js` foreignCallValue, CED:198); neither is ever sent on as an
|
|
2355
|
+
* ordinary call whose arguments are that value. */
|
|
2356
|
+
function controlTarget(value) {
|
|
2357
|
+
if (value === null || (typeof value !== "object" && typeof value !== "function"))
|
|
2358
|
+
return false;
|
|
2359
|
+
if (CALL_ROUTES.has(value))
|
|
2360
|
+
return true;
|
|
2361
|
+
try {
|
|
2362
|
+
if (typeof value.then === "function")
|
|
2363
|
+
return true;
|
|
2364
|
+
return shapedLikeCall(value);
|
|
2365
|
+
}
|
|
2366
|
+
catch {
|
|
2367
|
+
return false;
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
/** A value only shaped like a call value: frozen, no prototype, no members (what the bus mints, `CallValue`). */
|
|
2371
|
+
function shapedLikeCall(value) {
|
|
2372
|
+
try {
|
|
2373
|
+
return Object.getPrototypeOf(value) === null && Object.isFrozen(value) && Object.keys(value).length === 0;
|
|
2374
|
+
}
|
|
2375
|
+
catch {
|
|
2376
|
+
return false;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
function chainProxy(path) {
|
|
2380
|
+
const target = () => { }; // arrow fn: no own `prototype` to collide with the traps
|
|
2381
|
+
const proxy = new Proxy(target, {
|
|
2382
|
+
apply(_t, _this, argArray) {
|
|
2383
|
+
// A CONTROL on a call this package holds (Article 23.6, CED "A call a native package holds"):
|
|
2384
|
+
// `dsx.module.<chain>.<action>.<control>(call, args)`, the page bridge's rule and the spelling Swift and
|
|
2385
|
+
// Kotlin have. A call value first routes to that call's control and is never sent on as an ordinary
|
|
2386
|
+
// action; a value only shaped like one is refused `call_ended` there (CED:198).
|
|
2387
|
+
const first = argArray[0];
|
|
2388
|
+
if (controlTarget(first))
|
|
2389
|
+
return ModuleRegistry.control(first, path.join("."), isDict(argArray[1]) ? argArray[1] : {});
|
|
2390
|
+
const args = isDict(first) ? first : {};
|
|
2391
|
+
// A HELD call (Article 23.6): an events FUNCTION, never a page's handler map (an object), and an
|
|
2392
|
+
// optional receiver for the call's opaque value. Nothing else changes: the promise is the settle.
|
|
2393
|
+
if (typeof argArray[1] === "function") {
|
|
2394
|
+
const events = argArray[1];
|
|
2395
|
+
const held = typeof argArray[2] === "function" ? argArray[2] : undefined;
|
|
2396
|
+
return ModuleRegistry.call(path.join("."), args, { events, held: true, ...(held === undefined ? {} : { call: held }) });
|
|
2397
|
+
}
|
|
2398
|
+
return ModuleRegistry.call(path.join("."), args);
|
|
2399
|
+
},
|
|
2400
|
+
get(_t, key) {
|
|
2401
|
+
// R1 proxy safety: Symbols and the denylist never traverse, never call
|
|
2402
|
+
if (!proxyAdmits(key))
|
|
2403
|
+
return undefined;
|
|
2404
|
+
const r = ModuleRegistry.resolve(path.join("."));
|
|
2405
|
+
if (r.action.length === 0 && r.member === null) {
|
|
2406
|
+
// identity position — the reserved words are MEMBER routes, never actions
|
|
2407
|
+
if (key === "object")
|
|
2408
|
+
return (name) => ModuleRegistry.object(r.chain, name);
|
|
2409
|
+
// the declared-vars plane, and `.context.<var>` is the ONE spelling that reads it
|
|
2410
|
+
// (facet-contracts.md). `.state` was the pre-rename alias and is deleted.
|
|
2411
|
+
if (key === "context")
|
|
2412
|
+
return contextProxy(r.chain);
|
|
2413
|
+
if (key === "available")
|
|
2414
|
+
return ModuleRegistry.isAvailable(r.chain) && ModuleRegistry.excludedFact(r.chain) === false;
|
|
2415
|
+
if (key === "excluded")
|
|
2416
|
+
return ModuleRegistry.excludedFact(r.chain);
|
|
2417
|
+
if (key === "availability")
|
|
2418
|
+
return ModuleRegistry.availabilityPlane(r.chain);
|
|
2419
|
+
if (key === "on") {
|
|
2420
|
+
// event sugar over the module's DSXEvents channel (`<chain>:<kind>` — the names the
|
|
2421
|
+
// module's broadcasts and the ambient error fan-out publish; a call event stays on its
|
|
2422
|
+
// call): on(kind, fn) →
|
|
2423
|
+
// fn(value) for that kind; on(fn) → every event of the chain, fn(value, kind).
|
|
2424
|
+
// Returns the unsubscribe function either way.
|
|
2425
|
+
return (kindOrHandler, maybeHandler) => {
|
|
2426
|
+
const all = typeof kindOrHandler === "function";
|
|
2427
|
+
const handler = (all ? kindOrHandler : maybeHandler);
|
|
2428
|
+
if (typeof handler !== "function")
|
|
2429
|
+
return () => { };
|
|
2430
|
+
const name = all ? `${r.chain}:*` : `${r.chain}:${String(kindOrHandler)}`;
|
|
2431
|
+
return DSXEvents.on(name, handler);
|
|
2432
|
+
};
|
|
2433
|
+
}
|
|
2434
|
+
if (RESERVED_MEMBERS.has(key))
|
|
2435
|
+
return undefined; // delegate/dsx: no web surface
|
|
2436
|
+
}
|
|
2437
|
+
else if (key === "post") {
|
|
2438
|
+
// Fire-and-forget on the bound action: the rejection is discarded by shape — the
|
|
2439
|
+
// funnel reports it (module.callFailed, delivered: false) before rejecting, so
|
|
2440
|
+
// the catch here swallows a rejection that is already observable, never a silent
|
|
2441
|
+
// one. (At identity position `post` stays a plain first action segment.)
|
|
2442
|
+
// A call value first is a CONTROL named `post` on that call, never the action dispatched again with the
|
|
2443
|
+
// call as its arguments: the grammar keeps `post` open as a control name (Article 23.6; above every article).
|
|
2444
|
+
return (args = {}, controlArgs) => {
|
|
2445
|
+
if (controlTarget(args))
|
|
2446
|
+
return ModuleRegistry.control(args, `${path.join(".")}.post`, isDict(controlArgs) ? controlArgs : {});
|
|
2447
|
+
ModuleRegistry.call(path.join("."), args, { fireAndForget: true }).catch(() => { });
|
|
2448
|
+
return undefined;
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
2451
|
+
return chainProxy([...path, key]);
|
|
2452
|
+
},
|
|
2453
|
+
});
|
|
2454
|
+
CHAIN_PATHS.set(proxy, path);
|
|
2455
|
+
return proxy;
|
|
2456
|
+
}
|
|
2457
|
+
function makeModuleProxy() {
|
|
2458
|
+
return new Proxy({}, {
|
|
2459
|
+
get(_t, scheme) {
|
|
2460
|
+
if (!proxyAdmits(scheme))
|
|
2461
|
+
return undefined;
|
|
2462
|
+
return chainProxy([scheme]);
|
|
2463
|
+
},
|
|
2464
|
+
});
|
|
2465
|
+
}
|
|
2466
|
+
/** THE CHANNEL A MODULE BROADCAST TRAVELS ON: `<scheme>:<name>`, the name `dsx.module.<chain>.on(name)`
|
|
2467
|
+
* subscribes to and the same scoping the native lanes give a broadcast (Context.swift/Context.kt
|
|
2468
|
+
* `broadcast` carries the module's scheme). A bare name would reach no subscriber of the module and
|
|
2469
|
+
* would collide with every other module's broadcast of the same name. */
|
|
2470
|
+
export function broadcastChannel(scheme, name) {
|
|
2471
|
+
return `${scheme.toLowerCase()}:${name}`;
|
|
2472
|
+
}
|
|
2473
|
+
const IDENTITY = new WeakMap();
|
|
2474
|
+
const GRANTS = new WeakMap();
|
|
2475
|
+
const BarrierSlot = { door: null };
|
|
2476
|
+
/** The facts of one boot as comparable text: each chain's components, `secure` and module object (by an
|
|
2477
|
+
* index into the objects seen so far, so a different object is a different fact). */
|
|
2478
|
+
const FACT_OBJECTS = new WeakMap();
|
|
2479
|
+
let factObjectSeq = 0;
|
|
2480
|
+
function factsPrint(grants, granted) {
|
|
2481
|
+
const rows = Object.keys(grants).sort().map((chain) => {
|
|
2482
|
+
const m = granted[chain];
|
|
2483
|
+
let n = m === undefined ? -1 : FACT_OBJECTS.get(m);
|
|
2484
|
+
if (m !== undefined && n === undefined) {
|
|
2485
|
+
n = (factObjectSeq += 1);
|
|
2486
|
+
FACT_OBJECTS.set(m, n);
|
|
2487
|
+
}
|
|
2488
|
+
return [chain, grants[chain].components, grants[chain].secure, n];
|
|
2489
|
+
});
|
|
2490
|
+
return JSON.stringify(rows);
|
|
2491
|
+
}
|
|
2492
|
+
function barrierGrantTable(raw) {
|
|
2493
|
+
const out = {};
|
|
2494
|
+
for (const [chain, row] of Object.entries(raw ?? {})) {
|
|
2495
|
+
if (row === null || typeof row !== "object" || row.module === undefined)
|
|
2496
|
+
continue;
|
|
2497
|
+
const key = chain.toLowerCase();
|
|
2498
|
+
const components = Array.isArray(row.components) ? row.components.filter((c) => typeof c === "string") : [];
|
|
2499
|
+
out[key] = Object.freeze({ chain: key, components: Object.freeze([...components]), secure: row.secure === true });
|
|
2500
|
+
}
|
|
2501
|
+
return out;
|
|
2502
|
+
}
|
|
2503
|
+
const BARRIER_MESSAGES = {
|
|
2504
|
+
barrier_not_granted: "This call carries no barrier grant: only a package whose manifest declares presentation.barrier can raise, update or lower a barrier, from its own handle.",
|
|
2505
|
+
barrier_component_undeclared: "That component is not among the components this package's presentation.barrier declares.",
|
|
2506
|
+
barrier_not_owner: "That barrier belongs to another package; only the package that raised it can update or lower it.",
|
|
2507
|
+
invalid_param: "The attributes do not match the component's declared attribute table.",
|
|
2508
|
+
unavailable: "No barrier ledger is attached to this document.",
|
|
2509
|
+
};
|
|
2510
|
+
/** One barrier verb from a package handle. `module` is the handle's own module (null for the exported
|
|
2511
|
+
* `makeDsx`, which carries no identity). Rejects with the typed code. */
|
|
2512
|
+
function barrierVerb(module, verb, scheme, name, attrs) {
|
|
2513
|
+
const door = BarrierSlot.door;
|
|
2514
|
+
const component = name === "barrier" || name.includes(".") ? name : `${scheme}.${name}`;
|
|
2515
|
+
if (door === null)
|
|
2516
|
+
return Promise.reject(new ModuleCallError("unavailable", BARRIER_MESSAGES["unavailable"], { component }));
|
|
2517
|
+
const identity = module === null ? null : (IDENTITY.get(module) ?? null);
|
|
2518
|
+
const grant = identity === null ? null : (GRANTS.get(identity) ?? null);
|
|
2519
|
+
const code = door.run(verb, identity, grant, component, attrs);
|
|
2520
|
+
if (code !== null)
|
|
2521
|
+
return Promise.reject(new ModuleCallError(code, BARRIER_MESSAGES[code] ?? code, { component }));
|
|
2522
|
+
return Promise.resolve();
|
|
2523
|
+
}
|
|
2524
|
+
function namesBarrier(scheme, name) {
|
|
2525
|
+
if (name === "barrier")
|
|
2526
|
+
return true;
|
|
2527
|
+
const door = BarrierSlot.door;
|
|
2528
|
+
return door !== null && name.length > 0 && door.names(name.includes(".") ? name : `${scheme}.${name}`);
|
|
2529
|
+
}
|
|
2530
|
+
function barrierAttrs(raw) {
|
|
2531
|
+
return typeof raw === "object" && raw !== null && !Array.isArray(raw) ? raw : undefined;
|
|
2532
|
+
}
|
|
2533
|
+
/** The handle a module's own boot and call contexts carry: `makeDsx`'s surface with the module's identity
|
|
2534
|
+
* on the barrier verbs. Module-private. */
|
|
2535
|
+
function makeModuleDsx(module) {
|
|
2536
|
+
return buildDsx(module.scheme.toLowerCase(), module);
|
|
2537
|
+
}
|
|
2538
|
+
/** A handle for `scheme` WITHOUT identity: every barrier verb through it answers `barrier_not_granted`
|
|
2539
|
+
* (corpus router/barrier.json C22). Kept for every caller that builds a handle from a scheme string. */
|
|
2540
|
+
export function makeDsx(scheme) {
|
|
2541
|
+
return buildDsx(scheme, null);
|
|
2542
|
+
}
|
|
2543
|
+
function buildDsx(scheme, owner) {
|
|
2544
|
+
// the one inert door an embed gets: falsy, so present/update/dismiss answer `false` and surface/offscreen read as absent
|
|
2545
|
+
const absent = () => false;
|
|
2546
|
+
const facetDoors = globalThis.__DSX_OPTIONAL_FACET_DOORS__ !== false;
|
|
2547
|
+
return {
|
|
2548
|
+
scheme,
|
|
2549
|
+
has: (s) => ModuleRegistry.has(s),
|
|
2550
|
+
module: makeModuleProxy(),
|
|
2551
|
+
stop: (call) => ModuleRegistry.stop(call),
|
|
2552
|
+
delegate: {
|
|
2553
|
+
listen: (event, fn, priority = 0) => ModuleRegistry.registerDelegate(event, priority, fn),
|
|
2554
|
+
send: (event, payload = null, combine = "claim") => ModuleRegistry.foldDelegate(event, payload, combine),
|
|
2555
|
+
hasWatchers: (event) => ModuleRegistry.hasWatchers(event),
|
|
2556
|
+
observeWatchers: (event, fn) => ModuleRegistry.observeWatchers(event, fn),
|
|
2557
|
+
},
|
|
2558
|
+
broadcast: (name, value = null) => DSXEvents.publish(broadcastChannel(scheme, name), value),
|
|
2559
|
+
component: {
|
|
2560
|
+
// `as: "barrier"`, and an update or dismiss whose target names a barrier entry, never go through
|
|
2561
|
+
// the replaceable ComponentSeam: they reach the plane through the module-private slot with this
|
|
2562
|
+
// handle's identity, and answer a promise that rejects with the typed code.
|
|
2563
|
+
present: (facetDoors ? (name, opts = {}) => {
|
|
2564
|
+
if (opts["as"] === "barrier")
|
|
2565
|
+
return barrierVerb(owner, "present", scheme, name, barrierAttrs(opts["attributes"]));
|
|
2566
|
+
if (ComponentSeam.run === null)
|
|
2567
|
+
return false;
|
|
2568
|
+
ComponentSeam.run("present", name, opts, scheme);
|
|
2569
|
+
return true;
|
|
2570
|
+
} : absent),
|
|
2571
|
+
update: facetDoors ? (name, attributes, opts = {}) => {
|
|
2572
|
+
if (namesBarrier(scheme, name))
|
|
2573
|
+
return barrierVerb(owner, "update", scheme, name, barrierAttrs(attributes));
|
|
2574
|
+
if (ComponentSeam.run === null)
|
|
2575
|
+
return false;
|
|
2576
|
+
ComponentSeam.run("update", name, { ...opts, attributes }, scheme);
|
|
2577
|
+
return true;
|
|
2578
|
+
} : absent,
|
|
2579
|
+
dismiss: facetDoors ? (name, opts = {}) => {
|
|
2580
|
+
if (namesBarrier(scheme, name))
|
|
2581
|
+
return barrierVerb(owner, "dismiss", scheme, name, undefined);
|
|
2582
|
+
if (ComponentSeam.run === null)
|
|
2583
|
+
return false;
|
|
2584
|
+
ComponentSeam.run("dismiss", name, opts, scheme);
|
|
2585
|
+
return true;
|
|
2586
|
+
} : absent,
|
|
2587
|
+
// An embed pins __DSX_OPTIONAL_FACET_DOORS__ false: a widget has no router to present, hand out a surface or an
|
|
2588
|
+
// offscreen mount and no boot to gate, so these closures and the gate seam fold away.
|
|
2589
|
+
surface: facetDoors ? (name) => (ComponentSeam.surface === null ? null : ComponentSeam.surface(name, scheme)) : absent,
|
|
2590
|
+
offscreen: facetDoors ? (name, opts) => (ComponentSeam.offscreen === null ? null : ComponentSeam.offscreen(name, opts, scheme)) : absent,
|
|
2591
|
+
define: facetDoors ? (name, ir, opts = {}) => (ComponentSeam.define === null ? false : ComponentSeam.define(name, ir, opts, scheme)) : absent,
|
|
2592
|
+
},
|
|
2593
|
+
boot: {
|
|
2594
|
+
gate: !facetDoors
|
|
2595
|
+
? absent
|
|
2596
|
+
: (spec) => {
|
|
2597
|
+
if (spec.when === false)
|
|
2598
|
+
return;
|
|
2599
|
+
BootGateSeam.gates.push({ scheme, priority: spec.priority ?? 0, run: spec.run });
|
|
2600
|
+
},
|
|
2601
|
+
cover: !facetDoors
|
|
2602
|
+
? absent
|
|
2603
|
+
: (spec) => {
|
|
2604
|
+
if (spec.when === false)
|
|
2605
|
+
return;
|
|
2606
|
+
BootCoverSeam.covers.push({ scheme, run: spec.run });
|
|
2607
|
+
},
|
|
2608
|
+
},
|
|
2609
|
+
error: (code, data = null) => ModuleRegistry.reportAmbientError(scheme, code, { data }),
|
|
2610
|
+
condition: (code, data) => ModuleRegistry.setCondition(scheme, code, data),
|
|
2611
|
+
degradation: (member, id) => ModuleRegistry.setDegradation(scheme, member, id),
|
|
2612
|
+
refresh: () => ModuleRegistry.probes.refresh(scheme),
|
|
2613
|
+
fail: (code, message, recoverable = false, data = null) => ModuleRegistry.reportAmbientError(scheme, code, { message, recoverable, data }),
|
|
2614
|
+
errors: DSXErrors,
|
|
2615
|
+
log: (...args) => reportLog(scheme, "log", formatLogArgs(args)),
|
|
2616
|
+
logs: DSXLogs,
|
|
2617
|
+
config: ModuleRegistry.configFor(scheme),
|
|
2618
|
+
facets: facetTablesFor(scheme),
|
|
2619
|
+
opened: (line) => openedFor(scheme, line),
|
|
2620
|
+
context: {
|
|
2621
|
+
set: (name, value) => DSXState.set(`${scheme}.${name}`, value),
|
|
2622
|
+
get: (name) => DSXState.get(`${scheme}.${name}`),
|
|
2623
|
+
},
|
|
2624
|
+
// THE READ CACHE serves only declared reads answered through module dispatch (`dispatchSegments`, which folds
|
|
2625
|
+
// under `__DSX_OPTIONAL_MODULE_DISPATCH__`). A widget that folds the dispatch holds no cached answer to scope, so
|
|
2626
|
+
// the door is a no-op there and read-cache.ts leaves the bundle.
|
|
2627
|
+
reads: {
|
|
2628
|
+
scope: globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false
|
|
2629
|
+
? (user, partition = "") => ReadCache.scope(scheme, user, partition)
|
|
2630
|
+
: () => { },
|
|
2631
|
+
},
|
|
2632
|
+
global: {
|
|
2633
|
+
get: (path) => DSXState.get(path),
|
|
2634
|
+
set: (path, value) => DSXState.set(path, value),
|
|
2635
|
+
},
|
|
2636
|
+
env: () => string(DSXState.get("app.env")) || JSESeams.appEnvironment(),
|
|
2637
|
+
platform: {
|
|
2638
|
+
os: JSESeams.platformOS,
|
|
2639
|
+
native: JSESeams.platformOS !== "web",
|
|
2640
|
+
desktop: isDesktopOS(JSESeams.platformOS),
|
|
2641
|
+
embed: JSESeams.platformEmbed,
|
|
2642
|
+
},
|
|
2643
|
+
events: moduleEvents(scheme),
|
|
2644
|
+
};
|
|
2645
|
+
}
|
|
2646
|
+
export { isDict };
|
|
2647
|
+
//# sourceMappingURL=bus.js.map
|