@despia-native/kernel 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +1414 -0
- package/README.md +17 -2
- package/dist/.dsx-build-stamp.json +7 -0
- package/dist/api-cohort.d.ts +27 -0
- package/dist/api-cohort.d.ts.map +1 -0
- package/dist/api-cohort.js +94 -0
- package/dist/api-cohort.js.map +1 -0
- package/dist/api.d.ts +454 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +2442 -0
- package/dist/api.js.map +1 -0
- package/dist/app-consts.d.ts +10 -0
- package/dist/app-consts.d.ts.map +1 -0
- package/dist/app-consts.js +39 -0
- package/dist/app-consts.js.map +1 -0
- package/dist/app-update.d.ts +12 -0
- package/dist/app-update.d.ts.map +1 -0
- package/dist/app-update.js +32 -0
- package/dist/app-update.js.map +1 -0
- package/dist/aria.d.ts +152 -0
- package/dist/aria.d.ts.map +1 -0
- package/dist/aria.js +524 -0
- package/dist/aria.js.map +1 -0
- package/dist/audio-core.d.ts +260 -0
- package/dist/audio-core.d.ts.map +1 -0
- package/dist/audio-core.js +1440 -0
- package/dist/audio-core.js.map +1 -0
- package/dist/audio-edit.d.ts +100 -0
- package/dist/audio-edit.d.ts.map +1 -0
- package/dist/audio-edit.js +489 -0
- package/dist/audio-edit.js.map +1 -0
- package/dist/audio-mix.d.ts +84 -0
- package/dist/audio-mix.d.ts.map +1 -0
- package/dist/audio-mix.js +393 -0
- package/dist/audio-mix.js.map +1 -0
- package/dist/auth-proof.d.ts +145 -0
- package/dist/auth-proof.d.ts.map +1 -0
- package/dist/auth-proof.js +644 -0
- package/dist/auth-proof.js.map +1 -0
- package/dist/availability-explain.d.ts +3 -0
- package/dist/availability-explain.d.ts.map +1 -0
- package/dist/availability-explain.js +322 -0
- package/dist/availability-explain.js.map +1 -0
- package/dist/availability.d.ts +246 -0
- package/dist/availability.d.ts.map +1 -0
- package/dist/availability.js +615 -0
- package/dist/availability.js.map +1 -0
- package/dist/background.d.ts +116 -0
- package/dist/background.d.ts.map +1 -0
- package/dist/background.js +235 -0
- package/dist/background.js.map +1 -0
- package/dist/boot-tables-flag.d.ts +2 -0
- package/dist/boot-tables-flag.d.ts.map +1 -0
- package/dist/boot-tables-flag.js +16 -0
- package/dist/boot-tables-flag.js.map +1 -0
- package/dist/boot-tables.d.ts +40 -0
- package/dist/boot-tables.d.ts.map +1 -0
- package/dist/boot-tables.js +102 -0
- package/dist/boot-tables.js.map +1 -0
- package/dist/border-edges.d.ts +5 -0
- package/dist/border-edges.d.ts.map +1 -0
- package/dist/border-edges.js +47 -0
- package/dist/border-edges.js.map +1 -0
- package/dist/bus.d.ts +1203 -0
- package/dist/bus.d.ts.map +1 -0
- package/dist/bus.js +2647 -0
- package/dist/bus.js.map +1 -0
- package/dist/calendar-core.d.ts +143 -0
- package/dist/calendar-core.d.ts.map +1 -0
- package/dist/calendar-core.js +372 -0
- package/dist/calendar-core.js.map +1 -0
- package/dist/call-value.d.ts +16 -0
- package/dist/call-value.d.ts.map +1 -0
- package/dist/call-value.js +54 -0
- package/dist/call-value.js.map +1 -0
- package/dist/camera-core.d.ts +222 -0
- package/dist/camera-core.d.ts.map +1 -0
- package/dist/camera-core.js +980 -0
- package/dist/camera-core.js.map +1 -0
- package/dist/canvas-core.d.ts +404 -0
- package/dist/canvas-core.d.ts.map +1 -0
- package/dist/canvas-core.js +2186 -0
- package/dist/canvas-core.js.map +1 -0
- package/dist/capture-core.d.ts +74 -0
- package/dist/capture-core.d.ts.map +1 -0
- package/dist/capture-core.js +158 -0
- package/dist/capture-core.js.map +1 -0
- package/dist/compile/codegen.d.ts +146 -0
- package/dist/compile/codegen.d.ts.map +1 -0
- package/dist/compile/codegen.js +1949 -0
- package/dist/compile/codegen.js.map +1 -0
- package/dist/compile/jstier.d.ts +44 -0
- package/dist/compile/jstier.d.ts.map +1 -0
- package/dist/compile/jstier.js +181 -0
- package/dist/compile/jstier.js.map +1 -0
- package/dist/compile/tier-door.d.ts +41 -0
- package/dist/compile/tier-door.d.ts.map +1 -0
- package/dist/compile/tier-door.js +167 -0
- package/dist/compile/tier-door.js.map +1 -0
- package/dist/compile/tier-realm.d.ts +49 -0
- package/dist/compile/tier-realm.d.ts.map +1 -0
- package/dist/compile/tier-realm.js +368 -0
- package/dist/compile/tier-realm.js.map +1 -0
- package/dist/compile/tier.d.ts +23 -0
- package/dist/compile/tier.d.ts.map +1 -0
- package/dist/compile/tier.js +157 -0
- package/dist/compile/tier.js.map +1 -0
- package/dist/compose-core.d.ts +86 -0
- package/dist/compose-core.d.ts.map +1 -0
- package/dist/compose-core.js +112 -0
- package/dist/compose-core.js.map +1 -0
- package/dist/config-validate.d.ts +31 -0
- package/dist/config-validate.d.ts.map +1 -0
- package/dist/config-validate.js +147 -0
- package/dist/config-validate.js.map +1 -0
- package/dist/config-values.d.ts +106 -0
- package/dist/config-values.d.ts.map +1 -0
- package/dist/config-values.js +340 -0
- package/dist/config-values.js.map +1 -0
- package/dist/contacts-core.d.ts +127 -0
- package/dist/contacts-core.d.ts.map +1 -0
- package/dist/contacts-core.js +211 -0
- package/dist/contacts-core.js.map +1 -0
- package/dist/content-transition.d.ts +58 -0
- package/dist/content-transition.d.ts.map +1 -0
- package/dist/content-transition.js +94 -0
- package/dist/content-transition.js.map +1 -0
- package/dist/controls-core.d.ts +227 -0
- package/dist/controls-core.d.ts.map +1 -0
- package/dist/controls-core.js +652 -0
- package/dist/controls-core.js.map +1 -0
- package/dist/cookies.d.ts +78 -0
- package/dist/cookies.d.ts.map +1 -0
- package/dist/cookies.js +265 -0
- package/dist/cookies.js.map +1 -0
- package/dist/corner-shape-core.d.ts +69 -0
- package/dist/corner-shape-core.d.ts.map +1 -0
- package/dist/corner-shape-core.js +261 -0
- package/dist/corner-shape-core.js.map +1 -0
- package/dist/crypto-core.d.ts +57 -0
- package/dist/crypto-core.d.ts.map +1 -0
- package/dist/crypto-core.js +128 -0
- package/dist/crypto-core.js.map +1 -0
- package/dist/dataviz.d.ts +436 -0
- package/dist/dataviz.d.ts.map +1 -0
- package/dist/dataviz.js +956 -0
- package/dist/dataviz.js.map +1 -0
- package/dist/debug.d.ts +293 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +767 -0
- package/dist/debug.js.map +1 -0
- package/dist/device-ownership.d.ts +50 -0
- package/dist/device-ownership.d.ts.map +1 -0
- package/dist/device-ownership.js +105 -0
- package/dist/device-ownership.js.map +1 -0
- package/dist/effects.d.ts +86 -0
- package/dist/effects.d.ts.map +1 -0
- package/dist/effects.js +98 -0
- package/dist/effects.js.map +1 -0
- package/dist/element.d.ts +108 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/element.js +63 -0
- package/dist/element.js.map +1 -0
- package/dist/file-watch.d.ts +16 -0
- package/dist/file-watch.d.ts.map +1 -0
- package/dist/file-watch.js +49 -0
- package/dist/file-watch.js.map +1 -0
- package/dist/filepaths.d.ts +72 -0
- package/dist/filepaths.d.ts.map +1 -0
- package/dist/filepaths.js +271 -0
- package/dist/filepaths.js.map +1 -0
- package/dist/film.d.ts +264 -0
- package/dist/film.d.ts.map +1 -0
- package/dist/film.js +313 -0
- package/dist/film.js.map +1 -0
- package/dist/fonts.d.ts +66 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +135 -0
- package/dist/fonts.js.map +1 -0
- package/dist/forms.d.ts +191 -0
- package/dist/forms.d.ts.map +1 -0
- package/dist/forms.js +663 -0
- package/dist/forms.js.map +1 -0
- package/dist/geo.d.ts +289 -0
- package/dist/geo.d.ts.map +1 -0
- package/dist/geo.js +460 -0
- package/dist/geo.js.map +1 -0
- package/dist/handler-announce.d.ts +46 -0
- package/dist/handler-announce.d.ts.map +1 -0
- package/dist/handler-announce.js +96 -0
- package/dist/handler-announce.js.map +1 -0
- package/dist/handoff.d.ts +71 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +250 -0
- package/dist/handoff.js.map +1 -0
- package/dist/identity-durability.d.ts +76 -0
- package/dist/identity-durability.d.ts.map +1 -0
- package/dist/identity-durability.js +150 -0
- package/dist/identity-durability.js.map +1 -0
- package/dist/image-core.d.ts +240 -0
- package/dist/image-core.d.ts.map +1 -0
- package/dist/image-core.js +618 -0
- package/dist/image-core.js.map +1 -0
- package/dist/image-schemes.d.ts +10 -0
- package/dist/image-schemes.d.ts.map +1 -0
- package/dist/image-schemes.js +28 -0
- package/dist/image-schemes.js.map +1 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +299 -0
- package/dist/index.js.map +1 -0
- package/dist/ink-core.d.ts +53 -0
- package/dist/ink-core.d.ts.map +1 -0
- package/dist/ink-core.js +119 -0
- package/dist/ink-core.js.map +1 -0
- package/dist/input.d.ts +148 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +358 -0
- package/dist/input.js.map +1 -0
- package/dist/integrity.d.ts +63 -0
- package/dist/integrity.d.ts.map +1 -0
- package/dist/integrity.js +150 -0
- package/dist/integrity.js.map +1 -0
- package/dist/intents.d.ts +95 -0
- package/dist/intents.d.ts.map +1 -0
- package/dist/intents.js +282 -0
- package/dist/intents.js.map +1 -0
- package/dist/interpolate-core.d.ts +37 -0
- package/dist/interpolate-core.d.ts.map +1 -0
- package/dist/interpolate-core.js +443 -0
- package/dist/interpolate-core.js.map +1 -0
- package/dist/jse/color.d.ts +12 -0
- package/dist/jse/color.d.ts.map +1 -0
- package/dist/jse/color.js +196 -0
- package/dist/jse/color.js.map +1 -0
- package/dist/jse/core.d.ts +54 -0
- package/dist/jse/core.d.ts.map +1 -0
- package/dist/jse/core.js +1519 -0
- package/dist/jse/core.js.map +1 -0
- package/dist/jse/dispatch.d.ts +28 -0
- package/dist/jse/dispatch.d.ts.map +1 -0
- package/dist/jse/dispatch.js +116 -0
- package/dist/jse/dispatch.js.map +1 -0
- package/dist/jse/highlight-grammar.d.ts +15 -0
- package/dist/jse/highlight-grammar.d.ts.map +1 -0
- package/dist/jse/highlight-grammar.js +161 -0
- package/dist/jse/highlight-grammar.js.map +1 -0
- package/dist/jse/highlight-grammars.generated.d.ts +2 -0
- package/dist/jse/highlight-grammars.generated.d.ts.map +1 -0
- package/dist/jse/highlight-grammars.generated.js +4 -0
- package/dist/jse/highlight-grammars.generated.js.map +1 -0
- package/dist/jse/highlight.d.ts +37 -0
- package/dist/jse/highlight.d.ts.map +1 -0
- package/dist/jse/highlight.js +323 -0
- package/dist/jse/highlight.js.map +1 -0
- package/dist/jse/jse.d.ts +674 -0
- package/dist/jse/jse.d.ts.map +1 -0
- package/dist/jse/jse.js +5841 -0
- package/dist/jse/jse.js.map +1 -0
- package/dist/jse/pathmatch.d.ts +10 -0
- package/dist/jse/pathmatch.d.ts.map +1 -0
- package/dist/jse/pathmatch.js +73 -0
- package/dist/jse/pathmatch.js.map +1 -0
- package/dist/jse/regex.d.ts +33 -0
- package/dist/jse/regex.d.ts.map +1 -0
- package/dist/jse/regex.js +375 -0
- package/dist/jse/regex.js.map +1 -0
- package/dist/jse/stdlib.d.ts +8 -0
- package/dist/jse/stdlib.d.ts.map +1 -0
- package/dist/jse/stdlib.js +765 -0
- package/dist/jse/stdlib.js.map +1 -0
- package/dist/jse/tokens.d.ts +102 -0
- package/dist/jse/tokens.d.ts.map +1 -0
- package/dist/jse/tokens.js +982 -0
- package/dist/jse/tokens.js.map +1 -0
- package/dist/jse/values.d.ts +206 -0
- package/dist/jse/values.d.ts.map +1 -0
- package/dist/jse/values.js +846 -0
- package/dist/jse/values.js.map +1 -0
- package/dist/keyboard.d.ts +196 -0
- package/dist/keyboard.d.ts.map +1 -0
- package/dist/keyboard.js +186 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/label-choices.d.ts +3 -0
- package/dist/label-choices.d.ts.map +1 -0
- package/dist/label-choices.js +168 -0
- package/dist/label-choices.js.map +1 -0
- package/dist/language.d.ts +33 -0
- package/dist/language.d.ts.map +1 -0
- package/dist/language.js +50 -0
- package/dist/language.js.map +1 -0
- package/dist/length-units.d.ts +30 -0
- package/dist/length-units.d.ts.map +1 -0
- package/dist/length-units.js +83 -0
- package/dist/length-units.js.map +1 -0
- package/dist/lightsensor.d.ts +48 -0
- package/dist/lightsensor.d.ts.map +1 -0
- package/dist/lightsensor.js +97 -0
- package/dist/lightsensor.js.map +1 -0
- package/dist/link-refresh.d.ts +27 -0
- package/dist/link-refresh.d.ts.map +1 -0
- package/dist/link-refresh.js +166 -0
- package/dist/link-refresh.js.map +1 -0
- package/dist/link.d.ts +57 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +333 -0
- package/dist/link.js.map +1 -0
- package/dist/linkpreview.d.ts +114 -0
- package/dist/linkpreview.d.ts.map +1 -0
- package/dist/linkpreview.js +439 -0
- package/dist/linkpreview.js.map +1 -0
- package/dist/list-presence.d.ts +32 -0
- package/dist/list-presence.d.ts.map +1 -0
- package/dist/list-presence.js +48 -0
- package/dist/list-presence.js.map +1 -0
- package/dist/live-stream.d.ts +27 -0
- package/dist/live-stream.d.ts.map +1 -0
- package/dist/live-stream.js +274 -0
- package/dist/live-stream.js.map +1 -0
- package/dist/livelogs.d.ts +134 -0
- package/dist/livelogs.d.ts.map +1 -0
- package/dist/livelogs.js +409 -0
- package/dist/livelogs.js.map +1 -0
- package/dist/logs.d.ts +80 -0
- package/dist/logs.d.ts.map +1 -0
- package/dist/logs.js +206 -0
- package/dist/logs.js.map +1 -0
- package/dist/mcp/apps.d.ts +82 -0
- package/dist/mcp/apps.d.ts.map +1 -0
- package/dist/mcp/apps.js +219 -0
- package/dist/mcp/apps.js.map +1 -0
- package/dist/mcp/entities.d.ts +25 -0
- package/dist/mcp/entities.d.ts.map +1 -0
- package/dist/mcp/entities.js +71 -0
- package/dist/mcp/entities.js.map +1 -0
- package/dist/mcp/result.d.ts +73 -0
- package/dist/mcp/result.d.ts.map +1 -0
- package/dist/mcp/result.js +119 -0
- package/dist/mcp/result.js.map +1 -0
- package/dist/mcp/webmcp.d.ts +162 -0
- package/dist/mcp/webmcp.d.ts.map +1 -0
- package/dist/mcp/webmcp.js +214 -0
- package/dist/mcp/webmcp.js.map +1 -0
- package/dist/mcp.d.ts +5 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +14 -0
- package/dist/mcp.js.map +1 -0
- package/dist/media-core.d.ts +191 -0
- package/dist/media-core.d.ts.map +1 -0
- package/dist/media-core.js +446 -0
- package/dist/media-core.js.map +1 -0
- package/dist/media-timeline-core.d.ts +94 -0
- package/dist/media-timeline-core.d.ts.map +1 -0
- package/dist/media-timeline-core.js +620 -0
- package/dist/media-timeline-core.js.map +1 -0
- package/dist/message.d.ts +42 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +582 -0
- package/dist/message.js.map +1 -0
- package/dist/missing-element.d.ts +29 -0
- package/dist/missing-element.d.ts.map +1 -0
- package/dist/missing-element.js +76 -0
- package/dist/missing-element.js.map +1 -0
- package/dist/motion-core.d.ts +160 -0
- package/dist/motion-core.d.ts.map +1 -0
- package/dist/motion-core.js +752 -0
- package/dist/motion-core.js.map +1 -0
- package/dist/motion-pose.d.ts +65 -0
- package/dist/motion-pose.d.ts.map +1 -0
- package/dist/motion-pose.js +143 -0
- package/dist/motion-pose.js.map +1 -0
- package/dist/motion.d.ts +132 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +260 -0
- package/dist/motion.js.map +1 -0
- package/dist/mount-core.d.ts +203 -0
- package/dist/mount-core.d.ts.map +1 -0
- package/dist/mount-core.js +437 -0
- package/dist/mount-core.js.map +1 -0
- package/dist/net-core.d.ts +110 -0
- package/dist/net-core.d.ts.map +1 -0
- package/dist/net-core.js +225 -0
- package/dist/net-core.js.map +1 -0
- package/dist/notify.d.ts +399 -0
- package/dist/notify.d.ts.map +1 -0
- package/dist/notify.js +964 -0
- package/dist/notify.js.map +1 -0
- package/dist/orientation-binding.d.ts +39 -0
- package/dist/orientation-binding.d.ts.map +1 -0
- package/dist/orientation-binding.js +64 -0
- package/dist/orientation-binding.js.map +1 -0
- package/dist/orientation.d.ts +55 -0
- package/dist/orientation.d.ts.map +1 -0
- package/dist/orientation.js +89 -0
- package/dist/orientation.js.map +1 -0
- package/dist/ota.d.ts +52 -0
- package/dist/ota.d.ts.map +1 -0
- package/dist/ota.js +122 -0
- package/dist/ota.js.map +1 -0
- package/dist/passkeys.d.ts +91 -0
- package/dist/passkeys.d.ts.map +1 -0
- package/dist/passkeys.js +307 -0
- package/dist/passkeys.js.map +1 -0
- package/dist/payment.d.ts +85 -0
- package/dist/payment.d.ts.map +1 -0
- package/dist/payment.js +270 -0
- package/dist/payment.js.map +1 -0
- package/dist/pending-presenter.d.ts +31 -0
- package/dist/pending-presenter.d.ts.map +1 -0
- package/dist/pending-presenter.js +119 -0
- package/dist/pending-presenter.js.map +1 -0
- package/dist/permission-core.d.ts +59 -0
- package/dist/permission-core.d.ts.map +1 -0
- package/dist/permission-core.js +102 -0
- package/dist/permission-core.js.map +1 -0
- package/dist/persist.d.ts +169 -0
- package/dist/persist.d.ts.map +1 -0
- package/dist/persist.js +361 -0
- package/dist/persist.js.map +1 -0
- package/dist/phase-plan.d.ts +114 -0
- package/dist/phase-plan.d.ts.map +1 -0
- package/dist/phase-plan.js +837 -0
- package/dist/phase-plan.js.map +1 -0
- package/dist/playback-core.d.ts +64 -0
- package/dist/playback-core.d.ts.map +1 -0
- package/dist/playback-core.js +176 -0
- package/dist/playback-core.js.map +1 -0
- package/dist/player-sources.d.ts +12 -0
- package/dist/player-sources.d.ts.map +1 -0
- package/dist/player-sources.js +44 -0
- package/dist/player-sources.js.map +1 -0
- package/dist/proxy-denylist.d.ts +11 -0
- package/dist/proxy-denylist.d.ts.map +1 -0
- package/dist/proxy-denylist.js +44 -0
- package/dist/proxy-denylist.js.map +1 -0
- package/dist/public-config.d.ts +20 -0
- package/dist/public-config.d.ts.map +1 -0
- package/dist/public-config.js +109 -0
- package/dist/public-config.js.map +1 -0
- package/dist/qoe-core.d.ts +72 -0
- package/dist/qoe-core.d.ts.map +1 -0
- package/dist/qoe-core.js +113 -0
- package/dist/qoe-core.js.map +1 -0
- package/dist/reactive-request.d.ts +80 -0
- package/dist/reactive-request.d.ts.map +1 -0
- package/dist/reactive-request.js +192 -0
- package/dist/reactive-request.js.map +1 -0
- package/dist/read-cache.d.ts +129 -0
- package/dist/read-cache.d.ts.map +1 -0
- package/dist/read-cache.js +566 -0
- package/dist/read-cache.js.map +1 -0
- package/dist/recorder-core.d.ts +57 -0
- package/dist/recorder-core.d.ts.map +1 -0
- package/dist/recorder-core.js +136 -0
- package/dist/recorder-core.js.map +1 -0
- package/dist/ref.d.ts +41 -0
- package/dist/ref.d.ts.map +1 -0
- package/dist/ref.js +98 -0
- package/dist/ref.js.map +1 -0
- package/dist/refusal.d.ts +82 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +218 -0
- package/dist/refusal.js.map +1 -0
- package/dist/region-insets.d.ts +61 -0
- package/dist/region-insets.d.ts.map +1 -0
- package/dist/region-insets.js +67 -0
- package/dist/region-insets.js.map +1 -0
- package/dist/rive-core.d.ts +323 -0
- package/dist/rive-core.d.ts.map +1 -0
- package/dist/rive-core.js +677 -0
- package/dist/rive-core.js.map +1 -0
- package/dist/runner.d.ts +595 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +4094 -0
- package/dist/runner.js.map +1 -0
- package/dist/scene/a11y.d.ts +11 -0
- package/dist/scene/a11y.d.ts.map +1 -0
- package/dist/scene/a11y.js +67 -0
- package/dist/scene/a11y.js.map +1 -0
- package/dist/scene/anim.d.ts +149 -0
- package/dist/scene/anim.d.ts.map +1 -0
- package/dist/scene/anim.js +396 -0
- package/dist/scene/anim.js.map +1 -0
- package/dist/scene/bind.d.ts +33 -0
- package/dist/scene/bind.d.ts.map +1 -0
- package/dist/scene/bind.js +66 -0
- package/dist/scene/bind.js.map +1 -0
- package/dist/scene/collide.d.ts +56 -0
- package/dist/scene/collide.d.ts.map +1 -0
- package/dist/scene/collide.js +146 -0
- package/dist/scene/collide.js.map +1 -0
- package/dist/scene/frame.d.ts +22 -0
- package/dist/scene/frame.d.ts.map +1 -0
- package/dist/scene/frame.js +57 -0
- package/dist/scene/frame.js.map +1 -0
- package/dist/scene/gltf.d.ts +79 -0
- package/dist/scene/gltf.d.ts.map +1 -0
- package/dist/scene/gltf.js +409 -0
- package/dist/scene/gltf.js.map +1 -0
- package/dist/scene/ir.d.ts +293 -0
- package/dist/scene/ir.d.ts.map +1 -0
- package/dist/scene/ir.js +692 -0
- package/dist/scene/ir.js.map +1 -0
- package/dist/scene/math.d.ts +50 -0
- package/dist/scene/math.d.ts.map +1 -0
- package/dist/scene/math.js +180 -0
- package/dist/scene/math.js.map +1 -0
- package/dist/scene/orbit.d.ts +19 -0
- package/dist/scene/orbit.d.ts.map +1 -0
- package/dist/scene/orbit.js +60 -0
- package/dist/scene/orbit.js.map +1 -0
- package/dist/scene/physics.d.ts +228 -0
- package/dist/scene/physics.d.ts.map +1 -0
- package/dist/scene/physics.js +1500 -0
- package/dist/scene/physics.js.map +1 -0
- package/dist/scene/registry.d.ts +85 -0
- package/dist/scene/registry.d.ts.map +1 -0
- package/dist/scene/registry.js +75 -0
- package/dist/scene/registry.js.map +1 -0
- package/dist/scene/skin.d.ts +82 -0
- package/dist/scene/skin.d.ts.map +1 -0
- package/dist/scene/skin.js +351 -0
- package/dist/scene/skin.js.map +1 -0
- package/dist/scene/sprite.d.ts +36 -0
- package/dist/scene/sprite.d.ts.map +1 -0
- package/dist/scene/sprite.js +107 -0
- package/dist/scene/sprite.js.map +1 -0
- package/dist/scene/viewer.d.ts +96 -0
- package/dist/scene/viewer.d.ts.map +1 -0
- package/dist/scene/viewer.js +235 -0
- package/dist/scene/viewer.js.map +1 -0
- package/dist/scoped-slots.d.ts +9 -0
- package/dist/scoped-slots.d.ts.map +1 -0
- package/dist/scoped-slots.js +42 -0
- package/dist/scoped-slots.js.map +1 -0
- package/dist/screen.d.ts +109 -0
- package/dist/screen.d.ts.map +1 -0
- package/dist/screen.js +309 -0
- package/dist/screen.js.map +1 -0
- package/dist/scroll.d.ts +525 -0
- package/dist/scroll.d.ts.map +1 -0
- package/dist/scroll.js +1226 -0
- package/dist/scroll.js.map +1 -0
- package/dist/settings-plane.d.ts +58 -0
- package/dist/settings-plane.d.ts.map +1 -0
- package/dist/settings-plane.js +86 -0
- package/dist/settings-plane.js.map +1 -0
- package/dist/share-inbox.d.ts +56 -0
- package/dist/share-inbox.d.ts.map +1 -0
- package/dist/share-inbox.js +114 -0
- package/dist/share-inbox.js.map +1 -0
- package/dist/shared-transition.d.ts +152 -0
- package/dist/shared-transition.d.ts.map +1 -0
- package/dist/shared-transition.js +257 -0
- package/dist/shared-transition.js.map +1 -0
- package/dist/sheet-content-padding.d.ts +24 -0
- package/dist/sheet-content-padding.d.ts.map +1 -0
- package/dist/sheet-content-padding.js +32 -0
- package/dist/sheet-content-padding.js.map +1 -0
- package/dist/shot-devices.d.ts +36 -0
- package/dist/shot-devices.d.ts.map +1 -0
- package/dist/shot-devices.js +90 -0
- package/dist/shot-devices.js.map +1 -0
- package/dist/shot-guards.d.ts +100 -0
- package/dist/shot-guards.d.ts.map +1 -0
- package/dist/shot-guards.js +260 -0
- package/dist/shot-guards.js.map +1 -0
- package/dist/shot-scope.d.ts +140 -0
- package/dist/shot-scope.d.ts.map +1 -0
- package/dist/shot-scope.js +302 -0
- package/dist/shot-scope.js.map +1 -0
- package/dist/slot-partition.d.ts +9 -0
- package/dist/slot-partition.d.ts.map +1 -0
- package/dist/slot-partition.js +38 -0
- package/dist/slot-partition.js.map +1 -0
- package/dist/snackbar.d.ts +165 -0
- package/dist/snackbar.d.ts.map +1 -0
- package/dist/snackbar.js +220 -0
- package/dist/snackbar.js.map +1 -0
- package/dist/socket.d.ts +96 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +370 -0
- package/dist/socket.js.map +1 -0
- package/dist/spotlight.d.ts +77 -0
- package/dist/spotlight.d.ts.map +1 -0
- package/dist/spotlight.js +174 -0
- package/dist/spotlight.js.map +1 -0
- package/dist/state-primitive.d.ts +37 -0
- package/dist/state-primitive.d.ts.map +1 -0
- package/dist/state-primitive.js +91 -0
- package/dist/state-primitive.js.map +1 -0
- package/dist/store-query.d.ts +25 -0
- package/dist/store-query.d.ts.map +1 -0
- package/dist/store-query.js +88 -0
- package/dist/store-query.js.map +1 -0
- package/dist/store-value.d.ts +48 -0
- package/dist/store-value.d.ts.map +1 -0
- package/dist/store-value.js +264 -0
- package/dist/store-value.js.map +1 -0
- package/dist/store-versioning.d.ts +70 -0
- package/dist/store-versioning.d.ts.map +1 -0
- package/dist/store-versioning.js +188 -0
- package/dist/store-versioning.js.map +1 -0
- package/dist/store.d.ts +282 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +1144 -0
- package/dist/store.js.map +1 -0
- package/dist/strings.d.ts +141 -0
- package/dist/strings.d.ts.map +1 -0
- package/dist/strings.js +581 -0
- package/dist/strings.js.map +1 -0
- package/dist/telemetry.d.ts +95 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +255 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/transform-core.d.ts +228 -0
- package/dist/transform-core.d.ts.map +1 -0
- package/dist/transform-core.js +921 -0
- package/dist/transform-core.js.map +1 -0
- package/dist/transition-core.d.ts +58 -0
- package/dist/transition-core.d.ts.map +1 -0
- package/dist/transition-core.js +352 -0
- package/dist/transition-core.js.map +1 -0
- package/dist/trim-trailing.d.ts +3 -0
- package/dist/trim-trailing.d.ts.map +1 -0
- package/dist/trim-trailing.js +14 -0
- package/dist/trim-trailing.js.map +1 -0
- package/dist/upload.d.ts +51 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +68 -0
- package/dist/upload.js.map +1 -0
- package/dist/vendor-face.d.ts +44 -0
- package/dist/vendor-face.d.ts.map +1 -0
- package/dist/vendor-face.js +80 -0
- package/dist/vendor-face.js.map +1 -0
- package/dist/vendor-session.d.ts +166 -0
- package/dist/vendor-session.d.ts.map +1 -0
- package/dist/vendor-session.js +423 -0
- package/dist/vendor-session.js.map +1 -0
- package/dist/vendor-surface.d.ts +290 -0
- package/dist/vendor-surface.d.ts.map +1 -0
- package/dist/vendor-surface.js +439 -0
- package/dist/vendor-surface.js.map +1 -0
- package/dist/version-rules.generated.d.ts +17 -0
- package/dist/version-rules.generated.d.ts.map +1 -0
- package/dist/version-rules.generated.js +99 -0
- package/dist/version-rules.generated.js.map +1 -0
- package/dist/view-transition-core.d.ts +99 -0
- package/dist/view-transition-core.d.ts.map +1 -0
- package/dist/view-transition-core.js +127 -0
- package/dist/view-transition-core.js.map +1 -0
- package/dist/view-transition-door.d.ts +26 -0
- package/dist/view-transition-door.d.ts.map +1 -0
- package/dist/view-transition-door.js +88 -0
- package/dist/view-transition-door.js.map +1 -0
- package/dist/window-identity.d.ts +3 -0
- package/dist/window-identity.d.ts.map +1 -0
- package/dist/window-identity.js +27 -0
- package/dist/window-identity.js.map +1 -0
- package/package.json +139 -4
package/dist/store.js
ADDED
|
@@ -0,0 +1,1144 @@
|
|
|
1
|
+
//
|
|
2
|
+
// store.ts - the reactive store layer: fine-grained signals over the DSX store
|
|
3
|
+
// (/web/01 — Option C: own kernel, per-binding invalidation, no VDOM).
|
|
4
|
+
//
|
|
5
|
+
// Two store layers, identical shape (the kernel contract):
|
|
6
|
+
// • DSXState — the ONE app-wide reactive store, read as `global.*` / `route.*`.
|
|
7
|
+
// • per-surface ReactiveStore — bare-name surface state (wraps the JSE StackStore).
|
|
8
|
+
//
|
|
9
|
+
// Granularity: writes publish per top-level key immediately (deep-equal elided — the
|
|
10
|
+
// reference behavior); a BINDING subscribes to exactly the keys its expression READ
|
|
11
|
+
// (read-tracking through JSE.lookup), and re-runs only when one of them changes —
|
|
12
|
+
// dedup by watchKey so equal recomputes don't touch the DOM.
|
|
13
|
+
//
|
|
14
|
+
import { StackStore, JSE, JSESeams, judgeDeclaredShape } from "./jse/jse.js";
|
|
15
|
+
import { NSNull, isDict, watchKey, jseEquals, ARRAY_WRITE_LIMITS } from "./jse/values.js";
|
|
16
|
+
import { persistCommit, persistBind, persistDeclare } from "./persist.js";
|
|
17
|
+
import { watchOrigin, stateApplyRefusal } from "./state-primitive.js";
|
|
18
|
+
import { isCallValue, releaseCallValue, callValueOpen } from "./call-value.js";
|
|
19
|
+
// ── THE BUDGET SUBJECT'S HOST HALF ───────────────────────────────────────────────────
|
|
20
|
+
//
|
|
21
|
+
// WHAT WAS MISSING. `JSESeams.evaluationSubject` landed with the evaluator's half of the
|
|
22
|
+
// budget diagnostic (e48900a36) and nothing installed it, so every budget exhaustion in a
|
|
23
|
+
// real app said "an expression exhausted its evaluation budget" - the cost, honestly, and
|
|
24
|
+
// no name. This is the host half: the one string the seam answers, and the doors that set
|
|
25
|
+
// it.
|
|
26
|
+
//
|
|
27
|
+
// A STRING ON THE FRAME, NOT AN OBJECT, and not a stack. `beginEvaluation` calls the seam
|
|
28
|
+
// on EVERY outermost door, so a seam that built a sentence would allocate once per binding
|
|
29
|
+
// per render. It answers a string the host ALREADY BUILT - mount.ts builds a binding's
|
|
30
|
+
// subject once when the binding is created, never when it runs - so the hot path is two
|
|
31
|
+
// field assignments and a read. A host that sets nothing leaves it "" and the diagnostic
|
|
32
|
+
// keeps saying "an expression", which is the honest answer rather than an invented one.
|
|
33
|
+
//
|
|
34
|
+
// RESTORE, NEVER CLEAR. Bindings nest (a repeater's row binding evaluates inside no
|
|
35
|
+
// binding, a handler runs inside none, but a component's mount pass runs inside its
|
|
36
|
+
// parent's), so each door remembers what it displaced and puts it back. That is what
|
|
37
|
+
// `setEvaluationSubject` returning the previous value is for.
|
|
38
|
+
let hostSubject = "";
|
|
39
|
+
/** Name what the host is about to evaluate, for the budget diagnostic and for nothing else.
|
|
40
|
+
* Answers the subject that was in force, which the caller puts back when its door closes. */
|
|
41
|
+
export function setEvaluationSubject(next) {
|
|
42
|
+
const previous = hostSubject;
|
|
43
|
+
hostSubject = next;
|
|
44
|
+
return previous;
|
|
45
|
+
}
|
|
46
|
+
// INSTALLED HERE, ONCE, because this module is the one every host of the web lane loads:
|
|
47
|
+
// the render lane (mount.ts) reaches the subject through `setEvaluationSubject` rather than
|
|
48
|
+
// through a second seam install, so there is one holder and the two hosts cannot disagree
|
|
49
|
+
// about whose name is in force.
|
|
50
|
+
JSESeams.evaluationSubject = () => hostSubject;
|
|
51
|
+
let currentFrame = null;
|
|
52
|
+
export function trackReads(run, owner = null) {
|
|
53
|
+
const frame = {
|
|
54
|
+
owner, surface: new Set(), global: new Set(), foreign: null,
|
|
55
|
+
};
|
|
56
|
+
const prev = currentFrame;
|
|
57
|
+
currentFrame = frame;
|
|
58
|
+
try {
|
|
59
|
+
const value = run();
|
|
60
|
+
return { value, surface: frame.surface, global: frame.global, foreign: frame.foreign };
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
currentFrame = prev;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function noteSurfaceRead(key, owner) {
|
|
67
|
+
const frame = currentFrame;
|
|
68
|
+
if (frame === null)
|
|
69
|
+
return;
|
|
70
|
+
// An untagged read, and a read of the frame's own store, are the surface set they always
|
|
71
|
+
// were. Only a read of ANOTHER store is foreign, which is why the ordinary binding pays
|
|
72
|
+
// one reference comparison and nothing else.
|
|
73
|
+
if (owner === undefined || frame.owner === null || owner === frame.owner
|
|
74
|
+
|| globalThis.__DSX_OPTIONAL_CONTEXT__ === false) {
|
|
75
|
+
frame.surface.add(key);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let keys = frame.foreign?.get(owner);
|
|
79
|
+
if (keys === undefined) {
|
|
80
|
+
keys = new Set();
|
|
81
|
+
(frame.foreign ??= new Map()).set(owner, keys);
|
|
82
|
+
}
|
|
83
|
+
keys.add(key);
|
|
84
|
+
}
|
|
85
|
+
export function noteGlobalRead(key) { currentFrame?.global.add(key); }
|
|
86
|
+
let cookieRevision = 0;
|
|
87
|
+
/** Identity partition for implicit browser/native cookies. API materialization reads
|
|
88
|
+
* this under dependency tracking so an explicit cookie change refetches live GETs. */
|
|
89
|
+
export function readCookiePartition() {
|
|
90
|
+
noteGlobalRead("cookie");
|
|
91
|
+
return { revision: cookieRevision, jar: JSESeams.cookieJar() };
|
|
92
|
+
}
|
|
93
|
+
// ── path get/set (the State.kt getPath/setPath contract: COW, arrays grow) ──────────
|
|
94
|
+
/** One bounded dot-path contract shared with the native engines. Authored/remote
|
|
95
|
+
* paths fail closed before copy-on-write allocates any containers. */
|
|
96
|
+
export const STATE_PATH_LIMITS = Object.freeze({
|
|
97
|
+
maxPathBytes: 4_096,
|
|
98
|
+
maxSegments: 64,
|
|
99
|
+
maxSegmentBytes: 256,
|
|
100
|
+
maxArrayIndex: ARRAY_WRITE_LIMITS.maxArrayIndex,
|
|
101
|
+
maxArrayGrowth: ARRAY_WRITE_LIMITS.maxArrayGrowth,
|
|
102
|
+
maxContainerEntries: 10_000,
|
|
103
|
+
maxIdentifierBytes: 128,
|
|
104
|
+
});
|
|
105
|
+
const UNSAFE_PATH_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
106
|
+
const UTF8_ENCODER = new TextEncoder();
|
|
107
|
+
function isWithinUtf8Limit(value, limit) {
|
|
108
|
+
// A UTF-16 code unit consumes at least one UTF-8 byte. Bound length first so
|
|
109
|
+
// checking attacker-sized input never allocates another attacker-sized buffer.
|
|
110
|
+
return value.length <= limit && (/^[\x00-\x7f]*$/.test(value) || UTF8_ENCODER.encode(value).byteLength <= limit);
|
|
111
|
+
}
|
|
112
|
+
const VALIDATED_PATHS = new Map();
|
|
113
|
+
const EMPTY_PATH = [];
|
|
114
|
+
export function statePathParts(path, allowEmpty = false) {
|
|
115
|
+
const parts = validatedPathParts(path, allowEmpty);
|
|
116
|
+
return parts === null ? null : [...parts];
|
|
117
|
+
}
|
|
118
|
+
function validatedPathParts(path, allowEmpty = false) {
|
|
119
|
+
if (path.length === 0)
|
|
120
|
+
return allowEmpty ? EMPTY_PATH : null;
|
|
121
|
+
const cached = VALIDATED_PATHS.get(path);
|
|
122
|
+
if (cached !== undefined)
|
|
123
|
+
return cached;
|
|
124
|
+
if (!isWithinUtf8Limit(path, STATE_PATH_LIMITS.maxPathBytes))
|
|
125
|
+
return null;
|
|
126
|
+
const parts = path.split(".");
|
|
127
|
+
if (parts.some((part) => part.length === 0) || parts.length > STATE_PATH_LIMITS.maxSegments)
|
|
128
|
+
return null;
|
|
129
|
+
for (const part of parts) {
|
|
130
|
+
if (!isWithinUtf8Limit(part, STATE_PATH_LIMITS.maxSegmentBytes) || UNSAFE_PATH_KEYS.has(part))
|
|
131
|
+
return null;
|
|
132
|
+
const digits = /^\d+$/.test(part);
|
|
133
|
+
if (/^[+-]\d+$/.test(part))
|
|
134
|
+
return null;
|
|
135
|
+
if (digits) {
|
|
136
|
+
const index = Number(part);
|
|
137
|
+
if (!Number.isSafeInteger(index) || index > STATE_PATH_LIMITS.maxArrayIndex)
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (VALIDATED_PATHS.size >= 512)
|
|
142
|
+
VALIDATED_PATHS.delete(VALIDATED_PATHS.keys().next().value);
|
|
143
|
+
VALIDATED_PATHS.set(path, parts);
|
|
144
|
+
return parts;
|
|
145
|
+
}
|
|
146
|
+
/** `<api as>` owns one top-level store identifier, never an arbitrary dot path. */
|
|
147
|
+
export function isStateIdentifier(value) {
|
|
148
|
+
return value.length > 0
|
|
149
|
+
&& isWithinUtf8Limit(value, STATE_PATH_LIMITS.maxIdentifierBytes)
|
|
150
|
+
&& /^[A-Za-z_][A-Za-z0-9_]*$/.test(value);
|
|
151
|
+
}
|
|
152
|
+
/** Rebuild a validated path without mutating the input. A rejected result means
|
|
153
|
+
* the write exceeded a container/growth budget and state must remain unchanged. */
|
|
154
|
+
export function rebuildStatePath(container, parts, value) {
|
|
155
|
+
if (parts.length === 0)
|
|
156
|
+
return { accepted: true, value };
|
|
157
|
+
const p = parts[0];
|
|
158
|
+
// AN ARRAY'S `length` IS ITS LENGTH (logic parity sweep 5, actions `array-length-*`): a write
|
|
159
|
+
// truncates, or grows with null under the growth budget; a length JavaScript refuses writes
|
|
160
|
+
// nothing. It keyed a `length` entry and turned the array into an object. Twins: jse.ts
|
|
161
|
+
// `arrayWithLength` (the block half), JSE.swift DsxStatePathPolicy.rebuild, Jse.kt.
|
|
162
|
+
if (p === "length" && parts.length === 1 && Array.isArray(container)) {
|
|
163
|
+
const n = typeof value === "number" ? value : null;
|
|
164
|
+
if (n === null || !Number.isInteger(n) || n < 0)
|
|
165
|
+
return { accepted: true, value: container };
|
|
166
|
+
if (n <= container.length)
|
|
167
|
+
return { accepted: true, value: container.slice(0, n) };
|
|
168
|
+
if (n - container.length > STATE_PATH_LIMITS.maxArrayGrowth || n - 1 > STATE_PATH_LIMITS.maxArrayIndex)
|
|
169
|
+
return { accepted: false, value: container };
|
|
170
|
+
const grown = [...container];
|
|
171
|
+
while (grown.length < n)
|
|
172
|
+
grown.push(null);
|
|
173
|
+
return { accepted: true, value: grown };
|
|
174
|
+
}
|
|
175
|
+
// A NUMERIC SEGMENT IS AN INDEX UNDER AN ARRAY OR WHERE NOTHING IS YET, and a KEY under an
|
|
176
|
+
// object, as JavaScript writes `o['10'] = v` (logic parity B3, actions `key-order-*`): this
|
|
177
|
+
// replaced the object with an eleven element array. Twins: JSE.swift DsxStatePathPolicy.rebuild,
|
|
178
|
+
// the Kotlin path writer.
|
|
179
|
+
const i = /^\d+$/.test(p) && !isDict(container) ? Number(p) : null;
|
|
180
|
+
if (i !== null) {
|
|
181
|
+
const arr = Array.isArray(container) ? [...container] : [];
|
|
182
|
+
const growth = i >= arr.length ? i - arr.length + 1 : 0;
|
|
183
|
+
if (growth > STATE_PATH_LIMITS.maxArrayGrowth)
|
|
184
|
+
return { accepted: false, value: container };
|
|
185
|
+
// THE GAP IS NULL (JSE-VS-JS #18): it was filled with empty objects, so `xs[3] = 4` on `[1]`
|
|
186
|
+
// read `[1, {}, {}, 4]`. The written slot itself is built from nothing, as before.
|
|
187
|
+
while (arr.length < i)
|
|
188
|
+
arr.push(null);
|
|
189
|
+
const child = rebuildStatePath(i < arr.length ? arr[i] : undefined, parts.slice(1), value);
|
|
190
|
+
if (!child.accepted)
|
|
191
|
+
return child;
|
|
192
|
+
arr[i] = child.value;
|
|
193
|
+
return { accepted: true, value: arr };
|
|
194
|
+
}
|
|
195
|
+
const dict = isDict(container) ? { ...container } : {};
|
|
196
|
+
if (!Object.prototype.hasOwnProperty.call(dict, p)
|
|
197
|
+
&& Object.keys(dict).length >= STATE_PATH_LIMITS.maxContainerEntries) {
|
|
198
|
+
return { accepted: false, value: container };
|
|
199
|
+
}
|
|
200
|
+
const child = rebuildStatePath(dict[p], parts.slice(1), value);
|
|
201
|
+
if (!child.accepted)
|
|
202
|
+
return child;
|
|
203
|
+
dict[p] = child.value;
|
|
204
|
+
return { accepted: true, value: dict };
|
|
205
|
+
}
|
|
206
|
+
/** The unlink twin of `rebuildStatePath`: the container without the leaf `parts` names, rebuilt
|
|
207
|
+
* without mutating the input. `removed` is false when nothing was there to unlink. */
|
|
208
|
+
export function unlinkStatePath(container, parts) {
|
|
209
|
+
const p = parts[0];
|
|
210
|
+
const last = parts.length === 1;
|
|
211
|
+
if (Array.isArray(container)) {
|
|
212
|
+
if (!/^\d+$/.test(p))
|
|
213
|
+
return { removed: false, value: container };
|
|
214
|
+
const i = Number(p);
|
|
215
|
+
if (i >= container.length)
|
|
216
|
+
return { removed: false, value: container };
|
|
217
|
+
const arr = [...container];
|
|
218
|
+
if (last) {
|
|
219
|
+
arr.splice(i, 1);
|
|
220
|
+
return { removed: true, value: arr };
|
|
221
|
+
}
|
|
222
|
+
const child = unlinkStatePath(arr[i], parts.slice(1));
|
|
223
|
+
if (!child.removed)
|
|
224
|
+
return { removed: false, value: container };
|
|
225
|
+
arr[i] = child.value;
|
|
226
|
+
return { removed: true, value: arr };
|
|
227
|
+
}
|
|
228
|
+
if (!isDict(container) || !Object.prototype.hasOwnProperty.call(container, p))
|
|
229
|
+
return { removed: false, value: container };
|
|
230
|
+
const dict = { ...container };
|
|
231
|
+
if (last) {
|
|
232
|
+
delete dict[p];
|
|
233
|
+
return { removed: true, value: dict };
|
|
234
|
+
}
|
|
235
|
+
const child = unlinkStatePath(dict[p], parts.slice(1));
|
|
236
|
+
if (!child.removed)
|
|
237
|
+
return { removed: false, value: container };
|
|
238
|
+
dict[p] = child.value;
|
|
239
|
+
return { removed: true, value: dict };
|
|
240
|
+
}
|
|
241
|
+
export function getPath(vars, path) {
|
|
242
|
+
const parts = validatedPathParts(path);
|
|
243
|
+
if (parts === null)
|
|
244
|
+
return null;
|
|
245
|
+
let cur = vars.get(parts[0]);
|
|
246
|
+
for (const p of parts.slice(1)) {
|
|
247
|
+
const i = /^\d+$/.test(p) ? Number(p) : null;
|
|
248
|
+
if (i !== null && Array.isArray(cur))
|
|
249
|
+
cur = i >= 0 && i < cur.length ? cur[i] : null;
|
|
250
|
+
else
|
|
251
|
+
cur = isDict(cur) ? (cur[p] ?? null) : null;
|
|
252
|
+
}
|
|
253
|
+
return cur ?? null;
|
|
254
|
+
}
|
|
255
|
+
/** THE RE-RENDER LOG (the live inspector, backlog inspect-live-tree-state, SPEC item 7). A
|
|
256
|
+
* development host installs a listener; with none this costs one null test per notify and one
|
|
257
|
+
* per re-run, and an embed folds the sites with the rest of the debug plane. */
|
|
258
|
+
export const StoreDebugSeam = {
|
|
259
|
+
onRerender: null,
|
|
260
|
+
};
|
|
261
|
+
function recordWhy(sub, names, via) {
|
|
262
|
+
const held = sub.why ?? (sub.why = { names: new Set(), via });
|
|
263
|
+
for (const name of names)
|
|
264
|
+
held.names.add(name);
|
|
265
|
+
if (held.via !== via && via === "write")
|
|
266
|
+
held.via = via;
|
|
267
|
+
}
|
|
268
|
+
const pendingEffects = new Set();
|
|
269
|
+
let flushQueued = false;
|
|
270
|
+
function scheduleEffect(sub) {
|
|
271
|
+
pendingEffects.add(sub);
|
|
272
|
+
if (!flushQueued) {
|
|
273
|
+
flushQueued = true;
|
|
274
|
+
queueMicrotask(flushEffects);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/** Drain all pending binding re-runs NOW (tests, SSR, imperative flush points).
|
|
278
|
+
* Effects that write the store re-schedule; the drain budget contains cycles. */
|
|
279
|
+
export function flushEffects() {
|
|
280
|
+
flushQueued = false;
|
|
281
|
+
let rounds = 0;
|
|
282
|
+
while (pendingEffects.size > 0) {
|
|
283
|
+
if (rounds >= 64) {
|
|
284
|
+
console.warn(`[dsx store] effect flush budget (64 rounds) exceeded — a binding writes what it reads; remaining ${pendingEffects.size} deferred`);
|
|
285
|
+
pendingEffects.clear();
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
rounds += 1;
|
|
289
|
+
const batch = [...pendingEffects];
|
|
290
|
+
pendingEffects.clear();
|
|
291
|
+
for (const sub of batch) {
|
|
292
|
+
if (sub.disposed === true)
|
|
293
|
+
continue;
|
|
294
|
+
// One throwing binding must not starve the rest of the batch or escape the
|
|
295
|
+
// microtask — same isolation the bus gives its handlers (/web/20 render-safety).
|
|
296
|
+
try {
|
|
297
|
+
sub.run();
|
|
298
|
+
}
|
|
299
|
+
catch (e) {
|
|
300
|
+
console.warn("[dsx store] binding threw during flush", e);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const storeHolds = new WeakMap();
|
|
306
|
+
export function holdStore(store) {
|
|
307
|
+
const view = store;
|
|
308
|
+
const held = storeHolds.get(store) ?? { n: 0, owned: false };
|
|
309
|
+
held.n += 1;
|
|
310
|
+
if (held.n === 1 && view.pending === null) {
|
|
311
|
+
view.pending = new Set();
|
|
312
|
+
held.owned = true;
|
|
313
|
+
}
|
|
314
|
+
storeHolds.set(store, held);
|
|
315
|
+
}
|
|
316
|
+
export function releaseStore(store) {
|
|
317
|
+
const held = storeHolds.get(store);
|
|
318
|
+
if (held === undefined || held.n === 0)
|
|
319
|
+
return;
|
|
320
|
+
held.n -= 1;
|
|
321
|
+
if (held.n > 0 || !held.owned)
|
|
322
|
+
return;
|
|
323
|
+
const view = store;
|
|
324
|
+
const keys = view.pending;
|
|
325
|
+
view.pending = null;
|
|
326
|
+
held.owned = false;
|
|
327
|
+
if (keys.size > 0)
|
|
328
|
+
view.notify(keys, false);
|
|
329
|
+
}
|
|
330
|
+
/** A FRAGMENT SHARES ITS CONSUMER'S STATE FOR WHAT IT EXPECTS (dsx-anatomy.md `<expects>`,
|
|
331
|
+
* corpus composition/fragment-expects.json; Swift StackStore.shareExpected). Each name the
|
|
332
|
+
* fragment expects that `consumer` holds, and that the fragment does not declare as its own
|
|
333
|
+
* `<variable>`, is read at birth, written back to the consumer, and follows its writes.
|
|
334
|
+
* Module level (it was a ReactiveStore method): esbuild never drops a class
|
|
335
|
+
* method, and a sliced embed with no `<expects>` (dom mount.ts, __DSX_OPTIONAL_EXPECTS__) never
|
|
336
|
+
* calls this, so the plane leaves the widget with it. */
|
|
337
|
+
export function shareExpected(consumer, fragment, expected) {
|
|
338
|
+
// A name the consumer DERIVES (`<variable computed="true">`) has no value to copy and nothing to write: the
|
|
339
|
+
// fragment follows the consumer's answer, re-read whenever it changes.
|
|
340
|
+
for (const name of expected) {
|
|
341
|
+
if (!consumer.jse.computed.has(name) || consumer.jse.vars.has(name) || fragment.jse.initials.has(name))
|
|
342
|
+
continue;
|
|
343
|
+
const read = () => JSE.lookup(`dsx.variable.${name}`, consumer.jse, null);
|
|
344
|
+
fragment.jse.vars.set(name, read());
|
|
345
|
+
(fragment.expectsFollow ??= []).push(consumer.effect(read, (v) => { fragment.commit(name, v, "local"); }));
|
|
346
|
+
}
|
|
347
|
+
const shared = expected.filter((name) => !fragment.jse.initials.has(name)
|
|
348
|
+
&& (consumer.jse.vars.has(name) || consumer.jse.initials.has(name)));
|
|
349
|
+
if (shared.length === 0)
|
|
350
|
+
return;
|
|
351
|
+
for (const name of shared) {
|
|
352
|
+
fragment.jse.vars.set(name, consumer.jse.vars.has(name) ? consumer.jse.vars.get(name) : consumer.jse.initials.get(name));
|
|
353
|
+
}
|
|
354
|
+
fragment.sharedExpected = new Set(shared);
|
|
355
|
+
fragment.expectsHost = consumer;
|
|
356
|
+
(consumer.expectsMirrors ??= new Set()).add(fragment);
|
|
357
|
+
}
|
|
358
|
+
/** A consumer's write reaching each fragment that shares the key, and the fragments nested in it. */
|
|
359
|
+
function mirrorExpected(mirrors, key, value, origin) {
|
|
360
|
+
for (const fragment of mirrors) {
|
|
361
|
+
if (!fragment.sharedExpected.has(key))
|
|
362
|
+
continue;
|
|
363
|
+
fragment.commit(key, value, origin);
|
|
364
|
+
if (fragment.expectsMirrors !== null)
|
|
365
|
+
mirrorExpected(fragment.expectsMirrors, key, value, origin);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
export class ReactiveStore {
|
|
369
|
+
jse = new StackStore();
|
|
370
|
+
disposePresentation = null;
|
|
371
|
+
subscribers = new Set();
|
|
372
|
+
sinks = new Set();
|
|
373
|
+
/** batch depth — writes inside an action coalesce notifications per key set */
|
|
374
|
+
pending = null;
|
|
375
|
+
/** Each var's watch key AS WRITTEN. The dedupe below has to compare the past to the
|
|
376
|
+
* present, and it only holds a reference: re-deriving the "previous" key from that
|
|
377
|
+
* reference reads the value as it is NOW, so a value that was mutated in place looks
|
|
378
|
+
* unchanged and the write is elided. That is not hypothetical - a keyed row's item
|
|
379
|
+
* view is deliberately one object whose contents move, and handing it to a component
|
|
380
|
+
* as a prop silently stopped notifying the child. Remembering the key at write time
|
|
381
|
+
* is the fix, and it is also cheaper: the old code walked the value twice per set. */
|
|
382
|
+
#varKeys = new Map();
|
|
383
|
+
/** Bindings on OTHER stores that read a key of this one through `dsx.context`
|
|
384
|
+
* (proposals/context.md). Never through DSXState, whose notify walks every attached
|
|
385
|
+
* store in the process. */
|
|
386
|
+
foreignSubscribers = new Set();
|
|
387
|
+
constructor() {
|
|
388
|
+
this.jse.onVarRead = (name) => noteSurfaceRead(name, this);
|
|
389
|
+
DSXState.attach(this); // global-store writes poke this surface's global-read bindings
|
|
390
|
+
}
|
|
391
|
+
// member folds under `__DSX_OPTIONAL_CONTEXT__`, the stopgap canHoldCall names: the only callers are `tracked`'s
|
|
392
|
+
// foreign-read registration, behind the same flag
|
|
393
|
+
adoptForeign(sub) { if (globalThis.__DSX_OPTIONAL_CONTEXT__ !== false)
|
|
394
|
+
this.foreignSubscribers.add(sub); }
|
|
395
|
+
dropForeign(sub) { if (globalThis.__DSX_OPTIONAL_CONTEXT__ !== false)
|
|
396
|
+
this.foreignSubscribers.delete(sub); }
|
|
397
|
+
/** true once the surface unmounted; a late callback addressed to it is dropped */
|
|
398
|
+
isDisposed = false;
|
|
399
|
+
/** The calls this surface's documents started with a callback map and whose stream is still open
|
|
400
|
+
* (call-value.ts): held strongly, so its unmount stops them (constitution Article 20.4). A call leaves
|
|
401
|
+
* this set once its stream ended, and is then only remembered weakly in `startedCalls`. */
|
|
402
|
+
#heldCalls = null;
|
|
403
|
+
/** Every call this surface started and held, live or ended, weakly: `dsx.stop` of an ended one is a
|
|
404
|
+
* no-op that answers ok, and remembering it keeps nothing alive. */
|
|
405
|
+
#startedCalls = null;
|
|
406
|
+
/** The bound shared with the page bridge (runtime.js `MAX_PENDING`): at most this many live calls one
|
|
407
|
+
* surface holds; past it a new held call is refused `pending_limit_exceeded`. */
|
|
408
|
+
static HELD_CALL_BOUND = 2000;
|
|
409
|
+
/** @internal drop the held calls whose stream has ended; they stay remembered weakly */
|
|
410
|
+
forgetEndedCalls() {
|
|
411
|
+
// member fold under `__DSX_OPTIONAL_MODULE_DISPATCH__`, the stopgap canHoldCall names: with no dispatch no call is
|
|
412
|
+
// held, so `heldCalls` stays null and the unfolded body returns at once too
|
|
413
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false && this.#heldCalls !== null) {
|
|
414
|
+
for (const call of this.#heldCalls)
|
|
415
|
+
if (!callValueOpen(call))
|
|
416
|
+
this.#heldCalls.delete(call);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
/** @internal can this surface hold one more live call (the bound counts live calls only) */
|
|
420
|
+
canHoldCall() {
|
|
421
|
+
// MEMBER FOLD, a STOPGAP for design 3.2b (Article 17.4, backlog row EMBED-MEMBER-FOLDS-STOPGAP-1120): esbuild keeps
|
|
422
|
+
// every class member, so a member whose only callers sit behind a fold keeps its body unless the body folds too.
|
|
423
|
+
// Removed when 3.2b moves the member out of the class. A call value is minted only by the module dispatch (`__DSX_OPTIONAL_MODULE_DISPATCH__`).
|
|
424
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
425
|
+
this.forgetEndedCalls();
|
|
426
|
+
return this.#heldCalls === null || this.#heldCalls.size < ReactiveStore.HELD_CALL_BOUND;
|
|
427
|
+
}
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
/** @internal the runner, when one of this surface's calls hands back its value */
|
|
431
|
+
holdCall(call) {
|
|
432
|
+
// member fold under `__DSX_OPTIONAL_MODULE_DISPATCH__`, the stopgap canHoldCall names
|
|
433
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
434
|
+
this.forgetEndedCalls();
|
|
435
|
+
(this.#startedCalls ??= new WeakSet()).add(call);
|
|
436
|
+
if (callValueOpen(call))
|
|
437
|
+
(this.#heldCalls ??= new Set()).add(call);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/** @internal did this surface start and hold that call (a value it started, not one passed to it) */
|
|
441
|
+
holdsCall(value) {
|
|
442
|
+
// member fold under `__DSX_OPTIONAL_MODULE_DISPATCH__`, the stopgap canHoldCall names: with no dispatch no call
|
|
443
|
+
// was ever started, which is the answer the unfolded body gives (`startedCalls` stays null)
|
|
444
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
445
|
+
return typeof value === "object" && value !== null && this.#startedCalls !== null && this.#startedCalls.has(value);
|
|
446
|
+
}
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
/** @internal has this surface ever held a call: until it has, no binding of its documents can carry one, so the
|
|
450
|
+
* renderers skip the refusal of a running call bound to an attribute (constitution Article 14.2) */
|
|
451
|
+
startedAnyCall() { return this.#startedCalls !== null; }
|
|
452
|
+
/** @internal the number of live calls this surface holds (a test seam for the bound) */
|
|
453
|
+
liveHeldCalls() {
|
|
454
|
+
// member fold under `__DSX_OPTIONAL_MODULE_DISPATCH__` (see forgetEndedCalls): no call held answers 0, as unfolded
|
|
455
|
+
if (globalThis.__DSX_OPTIONAL_MODULE_DISPATCH__ !== false) {
|
|
456
|
+
this.forgetEndedCalls();
|
|
457
|
+
return this.#heldCalls?.size ?? 0;
|
|
458
|
+
}
|
|
459
|
+
return 0;
|
|
460
|
+
}
|
|
461
|
+
/** unmount: detach from the global store (bindings die with their subscribers) */
|
|
462
|
+
dispose() {
|
|
463
|
+
this.isDisposed = true;
|
|
464
|
+
if (this.#heldCalls !== null) {
|
|
465
|
+
const held = this.#heldCalls;
|
|
466
|
+
this.#heldCalls = null;
|
|
467
|
+
for (const call of held)
|
|
468
|
+
releaseCallValue(call);
|
|
469
|
+
}
|
|
470
|
+
this.disposePresentation?.();
|
|
471
|
+
this.jse.actionEntries.clear(); // a suspended action may finalize after its store leaves
|
|
472
|
+
this.expectsHost?.expectsMirrors?.delete(this);
|
|
473
|
+
this.expectsHost = null;
|
|
474
|
+
this.expectsFollow?.forEach((stop) => stop());
|
|
475
|
+
DSXState.detach(this);
|
|
476
|
+
if (this.#persistUnbind !== null) {
|
|
477
|
+
for (const unbind of this.#persistUnbind)
|
|
478
|
+
unbind();
|
|
479
|
+
this.#persistUnbind = null;
|
|
480
|
+
}
|
|
481
|
+
// THE PROVIDER'S HALF OF THE CONTEXT LIFETIME RULE (proposals/context.md; corpus
|
|
482
|
+
// composition/context.json `lifetime`). The consumer's half is `effect`'s own disposer,
|
|
483
|
+
// and it only covers the consumer dying FIRST. A slotted consumer can outlive its
|
|
484
|
+
// provider — slotted content's disposers live on the caller, and the slot owner IS the
|
|
485
|
+
// resolved provider for that content — and then the departed provider's store stays
|
|
486
|
+
// reachable from a live subscriber, and the live subscriber stays reachable from the
|
|
487
|
+
// departed store. Both directions are cut here, at the instant the frame is invalidated,
|
|
488
|
+
// so nothing leaks either way and a later write on a resurrected reference wakes nobody.
|
|
489
|
+
if (globalThis
|
|
490
|
+
.__DSX_OPTIONAL_CONTEXT__ !== false && this.foreignSubscribers.size > 0) {
|
|
491
|
+
for (const sub of [...this.foreignSubscribers])
|
|
492
|
+
sub.foreign?.delete(this);
|
|
493
|
+
this.foreignSubscribers.clear();
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
/** FOR THE LIFETIME ROWS AND THE RENDERER'S PROOFS: how many bindings on other stores are
|
|
497
|
+
* currently registered against this one. A count, not the set: the subscribers are private
|
|
498
|
+
* and stay private, and what the corpus asks is "is it zero". */
|
|
499
|
+
get foreignSubscriberCount() {
|
|
500
|
+
// member fold under `__DSX_OPTIONAL_CONTEXT__` (see adoptForeign): nothing adopts a foreign subscriber, so 0, as unfolded
|
|
501
|
+
if (globalThis.__DSX_OPTIONAL_CONTEXT__ !== false)
|
|
502
|
+
return this.foreignSubscribers.size;
|
|
503
|
+
return 0;
|
|
504
|
+
}
|
|
505
|
+
get vars() { return this.jse.vars; }
|
|
506
|
+
/** whole-snapshot sink (the `$vars.sink` twin: fires once on subscribe without keys, then per write with the keys written) */
|
|
507
|
+
sink(fn) {
|
|
508
|
+
this.sinks.add(fn);
|
|
509
|
+
fn(this.jse.vars);
|
|
510
|
+
return () => this.sinks.delete(fn);
|
|
511
|
+
}
|
|
512
|
+
/** one write — deep-equal writes are elided (the reference behavior). `origin` is where the
|
|
513
|
+
* write came from (proposals/cloud-state.md section 7): an assignment is `local`, and
|
|
514
|
+
* `dsx.module.global.apply` or a scope provider says otherwise. */
|
|
515
|
+
set(key, value, origin = "local") {
|
|
516
|
+
if (this.expectsHost !== null && this.sharedExpected.has(key)) {
|
|
517
|
+
this.expectsHost.set(key, value, origin);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
this.commit(key, value, origin);
|
|
521
|
+
if (this.expectsMirrors !== null)
|
|
522
|
+
mirrorExpected(this.expectsMirrors, key, value, origin);
|
|
523
|
+
}
|
|
524
|
+
/** @internal the fragment `<expects>` plane (module-level shareExpected / mirrorExpected below):
|
|
525
|
+
* the consumer a fragment writes through, the fragments that follow this store, and the names
|
|
526
|
+
* shared. Fields rather than methods, so a sliced embed with no `<expects>` sheds the plane. */
|
|
527
|
+
expectsHost = null;
|
|
528
|
+
/** @internal */
|
|
529
|
+
expectsMirrors = null;
|
|
530
|
+
/** @internal stops for the consumer's derived names this fragment follows (shareExpected) */
|
|
531
|
+
expectsFollow = null;
|
|
532
|
+
/** @internal */
|
|
533
|
+
sharedExpected = new Set();
|
|
534
|
+
/** @internal one write with no fragment routing: `set` minus the `<expects>` plane. */
|
|
535
|
+
commit(key, value, origin) {
|
|
536
|
+
const prev = this.jse.vars.get(key);
|
|
537
|
+
// A first write has nothing to compare against, so it must not fingerprint the value
|
|
538
|
+
// at all: a hostile row object throws on enumeration, and seeding a bound collection
|
|
539
|
+
// is exactly where one arrives.
|
|
540
|
+
if (prev === undefined) {
|
|
541
|
+
this.jse.vars.set(key, value);
|
|
542
|
+
this.#logWrite(key, origin);
|
|
543
|
+
this.changed(key);
|
|
544
|
+
this.keep(key, value, origin);
|
|
545
|
+
if (globalThis
|
|
546
|
+
.__DSX_OPTIONAL_DEV_LINES__ !== false)
|
|
547
|
+
judgeWrite(this, key, value, this.jse.initials.get(key));
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
const nextKey = watchKey(value);
|
|
551
|
+
const prevKey = this.#varKeys.get(key) ?? watchKey(prev);
|
|
552
|
+
// Remembered whether or not the write lands — an elided write is still the moment the
|
|
553
|
+
// stored value's fingerprint was last known to be true.
|
|
554
|
+
this.#varKeys.set(key, nextKey);
|
|
555
|
+
// equal fingerprints of an array or a plain dict ARE the structural equality jseEquals would compute again
|
|
556
|
+
// a running call is equal only to itself: two calls share a fingerprint and are not the same call
|
|
557
|
+
if (prevKey === nextKey && !isCallValue(value) && !isCallValue(prev) && (Array.isArray(value) || (isDict(value) && Object.getPrototypeOf(value) === Object.prototype) || jseEquals(prev, value)))
|
|
558
|
+
return;
|
|
559
|
+
this.jse.vars.set(key, value);
|
|
560
|
+
this.#logWrite(key, origin);
|
|
561
|
+
this.changed(key);
|
|
562
|
+
this.keep(key, value, origin);
|
|
563
|
+
if (globalThis
|
|
564
|
+
.__DSX_OPTIONAL_DEV_LINES__ !== false)
|
|
565
|
+
judgeWrite(this, key, value, prev);
|
|
566
|
+
}
|
|
567
|
+
// ── PERSISTED VARIABLES (`<variable persist="device">`, proposals/persistence.md) ──────
|
|
568
|
+
//
|
|
569
|
+
// THE WRITE COMMITS HERE AND NOWHERE ELSE. `set` is the one place a variable write lands:
|
|
570
|
+
// `setPath` routes a single segment to it and rebuilds a deeper path through it, and every
|
|
571
|
+
// `dsx.variable.<as> = v` the runner evaluates arrives here. Persisting at each call site
|
|
572
|
+
// would be as many copies of the rule as there are call sites, and they would drift.
|
|
573
|
+
//
|
|
574
|
+
// Three properties fall out of that placement, and each is a decision rather than an
|
|
575
|
+
// accident:
|
|
576
|
+
// • AN ELIDED WRITE IS NOT PERSISTED. The deep-equal elision returns above, so a value
|
|
577
|
+
// that did not change costs no I/O — and the slot's mtime stays honest about when the
|
|
578
|
+
// value last actually changed.
|
|
579
|
+
// • A DEEP WRITE PERSISTS THE WHOLE TOP-LEVEL VALUE. `setPath("prefs.theme", …)` rebuilds
|
|
580
|
+
// `prefs` copy-on-write and calls `set("prefs", rebuilt)`, so the slot holds the rebuilt
|
|
581
|
+
// root. There is no per-path slot; the variable is the unit.
|
|
582
|
+
// • THE FAILURE IS DEGRADATION, NEVER A CRASH. The in-memory value has ALREADY changed by
|
|
583
|
+
// the time `keep` runs. `localStorage` is the one browser store that throws rather than
|
|
584
|
+
// degrading (Safari private mode, blocked site data and a full quota all raise), and
|
|
585
|
+
// `persistWrite` is total over every one of those: an app whose store is blocked behaves
|
|
586
|
+
// exactly like an app with no `persist`, which is a shipped app. A document that wants to
|
|
587
|
+
// KNOW reads the fact the store already publishes, `dsx.module.storage.available`.
|
|
588
|
+
/** `as` → the slot it occupies, for the variables this surface declared `persist` on. Empty on
|
|
589
|
+
* every surface that declares none, which is the byte budget: the map is allocated lazily and
|
|
590
|
+
* a `keep` over an empty map is one `size` check. */
|
|
591
|
+
persisted = null;
|
|
592
|
+
/** Register one persisted variable (the head fold's seed step calls this, once, at mount).
|
|
593
|
+
* `scope` is its word: a string is a literal word, and a function is a word with a hole
|
|
594
|
+
* (ADR 0017), read at every write, answering a word, or "" for off. The store holds no word of
|
|
595
|
+
* its own (RULING-PERSIST-WORD-1122 M1): the words are the build's `persist` facet rows. */
|
|
596
|
+
markPersisted(as, slot, scope, merge, transitions, fallback) {
|
|
597
|
+
// MEMBER FOLD, a STOPGAP for design 3.2b (Article 17.4, backlog row EMBED-MEMBER-FOLDS-STOPGAP-1120): esbuild keeps
|
|
598
|
+
// every class member, so a member whose only callers sit behind a fold keeps its body unless the body folds too.
|
|
599
|
+
// Removed when 3.2b moves the member out of the class. The one caller is the head fold's persist seed, under `__DSX_OPTIONAL_PERSIST__`.
|
|
600
|
+
// Block form (store.ts `keep` says why): an early return would keep `persistDeclare` and `persistBind` counted.
|
|
601
|
+
if (globalThis.__DSX_OPTIONAL_PERSIST__ !== false) {
|
|
602
|
+
if (this.persisted === null)
|
|
603
|
+
this.persisted = new Map();
|
|
604
|
+
this.persisted.set(as, slot);
|
|
605
|
+
(this.persistGates ??= new Map()).set(as, scope);
|
|
606
|
+
if (merge !== undefined && merge !== "") {
|
|
607
|
+
persistDeclare(slot, {
|
|
608
|
+
merge,
|
|
609
|
+
...(transitions?.login === undefined ? {} : { login: transitions.login }),
|
|
610
|
+
...(transitions?.logout === undefined ? {} : { logout: transitions.logout }),
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
// BOUND TO ITS ADDRESS, so a scope provider can put a value that arrived from elsewhere into
|
|
614
|
+
// this surface (`persistRemote`), or return it to its declared default at a sign-out
|
|
615
|
+
// (`persistReset`), and unbound when the surface goes.
|
|
616
|
+
(this.#persistUnbind ??= []).push(persistBind(slot, {
|
|
617
|
+
apply: (value, origin) => { this.set(as, value, origin); },
|
|
618
|
+
reset: (origin) => { this.set(as, fallback === undefined ? null : fallback(), origin); },
|
|
619
|
+
}));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
/** The unbinds of this surface's persisted addresses, run at dispose. */
|
|
623
|
+
#persistUnbind = null;
|
|
624
|
+
/** `as` -> its scope word, or its hole (read at every write; an off word forgets the slot).
|
|
625
|
+
* Null on every surface that persists nothing. */
|
|
626
|
+
persistGates = null;
|
|
627
|
+
/** `as` -> the word its last write went to, so switching a hole off forgets the right slot. */
|
|
628
|
+
persistLast = null;
|
|
629
|
+
/** The word one persisted variable resolves to NOW ("" when a hole switched it off). */
|
|
630
|
+
persistedWord(as) {
|
|
631
|
+
// member fold under `__DSX_OPTIONAL_PERSIST__`, the stopgap markPersisted names (its one caller, `keep`, folds too)
|
|
632
|
+
if (globalThis.__DSX_OPTIONAL_PERSIST__ !== false) {
|
|
633
|
+
const scope = this.persistGates?.get(as);
|
|
634
|
+
if (scope === undefined)
|
|
635
|
+
return "";
|
|
636
|
+
return typeof scope === "string" ? scope : scope();
|
|
637
|
+
}
|
|
638
|
+
return "";
|
|
639
|
+
}
|
|
640
|
+
/** The slot this variable occupies, or "" when it is an ordinary in-memory variable. */
|
|
641
|
+
persistedSlot(as) {
|
|
642
|
+
return this.persisted?.get(as) ?? "";
|
|
643
|
+
}
|
|
644
|
+
/** Write one committed value through to its slot, if it has one. Total by construction.
|
|
645
|
+
*
|
|
646
|
+
* A SLICEABLE FEATURE, and the guard is the FIRST line rather than a condition further down.
|
|
647
|
+
* `this.persisted` is null in every document that declares no `persist=`, so the runtime cost
|
|
648
|
+
* was already zero - but the BYTES were not: the reference to `persistWrite` below holds
|
|
649
|
+
* `kernel/persist.js` and, through it, `kernel/store-value.js`, and a bundler cannot shake
|
|
650
|
+
* what a live reference names. For example:
|
|
651
|
+
* `persist.js` 761 bytes and `store-value.js` 2100 bytes in a widget that persists nothing.
|
|
652
|
+
* With `__DSX_OPTIONAL_PERSIST__` folded false the whole body below is dead and both modules
|
|
653
|
+
* leave the slice; with it on, nothing about the behaviour changes. */
|
|
654
|
+
keep(key, value, origin) {
|
|
655
|
+
// THE WHOLE BODY SITS INSIDE THE GUARD rather than behind an early return, because that is
|
|
656
|
+
// what a minifier can remove: esbuild drops the BODY of an `if` whose condition folds to
|
|
657
|
+
// false, and keeps everything that FOLLOWS an `if (true) { return; }`. An early-return
|
|
658
|
+
// guard here would leave the `persistWrite` reference in the bundle and save nothing.
|
|
659
|
+
if (globalThis
|
|
660
|
+
.__DSX_OPTIONAL_PERSIST__ !== false) {
|
|
661
|
+
if (this.persisted === null)
|
|
662
|
+
return;
|
|
663
|
+
const slot = this.persisted.get(key);
|
|
664
|
+
if (slot === undefined || this.persistGates?.has(key) !== true)
|
|
665
|
+
return;
|
|
666
|
+
const word = this.persistedWord(key);
|
|
667
|
+
persistCommit(word, this.persistLast?.get(key) ?? "", slot, value, origin);
|
|
668
|
+
if (word !== "")
|
|
669
|
+
(this.persistLast ??= new Map()).set(key, word);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
// ── THE ORIGIN OF EACH WRITE (proposals/cloud-state.md section 5) ──────────────────────
|
|
673
|
+
//
|
|
674
|
+
// Per top-level key, the sequence and origin of its last committed write. Allocated when the
|
|
675
|
+
// first `<watch detail>` subscribes, so a surface with none pays one null check per write.
|
|
676
|
+
#writeLog = null;
|
|
677
|
+
#writeSeq = 0;
|
|
678
|
+
#logWrite(key, origin) {
|
|
679
|
+
if (this.#writeLog === null)
|
|
680
|
+
return;
|
|
681
|
+
this.#writeSeq += 1;
|
|
682
|
+
this.#writeLog.set(key, [this.#writeSeq, origin]);
|
|
683
|
+
}
|
|
684
|
+
/** `dsx.module.global.apply` (proposals/cloud-state.md section 6): write one declared variable
|
|
685
|
+
* of this surface with a non-local origin. Answers the refusal code, or "" when applied. */
|
|
686
|
+
apply(as, value, origin) {
|
|
687
|
+
const refusal = stateApplyRefusal(origin, this.jse.vars.has(as) || this.jse.initials.has(as));
|
|
688
|
+
if (refusal !== "")
|
|
689
|
+
return refusal;
|
|
690
|
+
this.set(as, value, (origin ?? "remote"));
|
|
691
|
+
return "";
|
|
692
|
+
}
|
|
693
|
+
/** `<watch detail="true">`: like `watch`, and the change arrives as its descriptor. `keys` are
|
|
694
|
+
* the variables the value expression names (`watchVariableKeys`), which the origin law reads.
|
|
695
|
+
* `immediate` fires once now with `previous` null and origin `restore`. */
|
|
696
|
+
watchDetail(read, keys, onChange, immediate = false, subject = "") {
|
|
697
|
+
this.#writeLog ??= new Map();
|
|
698
|
+
let first = true;
|
|
699
|
+
let previous = null;
|
|
700
|
+
let since = this.#writeSeq;
|
|
701
|
+
return this.effect(read, (v) => {
|
|
702
|
+
if (first) {
|
|
703
|
+
first = false;
|
|
704
|
+
previous = v;
|
|
705
|
+
if (immediate)
|
|
706
|
+
onChange(v, null, "restore");
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
const origin = watchOrigin(keys, (k) => this.#writeLog?.get(k), since);
|
|
710
|
+
since = this.#writeSeq;
|
|
711
|
+
const before = previous;
|
|
712
|
+
previous = v;
|
|
713
|
+
onChange(v, before, origin);
|
|
714
|
+
}, subject);
|
|
715
|
+
}
|
|
716
|
+
/** dotted-path write — single segment routes to set(); deeper paths rebuild COW. */
|
|
717
|
+
setPath(path, value, origin = "local") {
|
|
718
|
+
const parts = validatedPathParts(path);
|
|
719
|
+
if (parts === null)
|
|
720
|
+
return;
|
|
721
|
+
const top = parts[0];
|
|
722
|
+
if (!this.jse.vars.has(top) && this.jse.vars.size >= STATE_PATH_LIMITS.maxContainerEntries)
|
|
723
|
+
return;
|
|
724
|
+
if (parts.length === 1) {
|
|
725
|
+
this.set(top, value, origin);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
// A DEEP WRITE STARTS FROM THE VALUE A READ SEES. A declared `<variable>` nobody has written
|
|
729
|
+
// yet holds its value in `initials`, and the read ladder answers it from there; the write
|
|
730
|
+
// rebuilt from the empty `vars` slot instead, so `a[0].on = true` (or a row control bound to
|
|
731
|
+
// `dsx.this.on`) replaced the whole list with `[{ on: true }]` (composition/row-writeback.json).
|
|
732
|
+
const current = this.jse.vars.get(top);
|
|
733
|
+
const base = current === undefined || current === null ? this.jse.initials.get(top) ?? current : current;
|
|
734
|
+
const rebuilt = rebuildStatePath(base, parts.slice(1), value);
|
|
735
|
+
if (rebuilt.accepted)
|
|
736
|
+
this.set(top, rebuilt.value, origin);
|
|
737
|
+
}
|
|
738
|
+
getPath(path) { return getPath(this.jse.vars, path); }
|
|
739
|
+
/** run writes batched: notifications coalesce and fire once at the end. */
|
|
740
|
+
batch(run) {
|
|
741
|
+
if (this.pending !== null) {
|
|
742
|
+
run();
|
|
743
|
+
return;
|
|
744
|
+
} // already inside a batch
|
|
745
|
+
this.pending = new Set();
|
|
746
|
+
try {
|
|
747
|
+
run();
|
|
748
|
+
}
|
|
749
|
+
finally {
|
|
750
|
+
const keys = this.pending;
|
|
751
|
+
this.pending = null;
|
|
752
|
+
if (keys.size > 0)
|
|
753
|
+
this.notify(keys);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
actionEntry(name, delta) {
|
|
757
|
+
// MEMBER FOLD, a STOPGAP for design 3.2b (Article 17.4, backlog row EMBED-MEMBER-FOLDS-STOPGAP-1120): esbuild keeps
|
|
758
|
+
// every class member, so a member whose only callers sit behind a fold keeps its body unless the body folds too.
|
|
759
|
+
// Removed when 3.2b moves the member out of the class. Its callers are the runner's named-action call, under `__DSX_OPTIONAL_NAMED_ACTIONS__`.
|
|
760
|
+
if (globalThis.__DSX_OPTIONAL_NAMED_ACTIONS__ !== false) {
|
|
761
|
+
const count = Math.max(0, (this.jse.actionEntries.get(name) ?? 0) + delta);
|
|
762
|
+
if (count === 0)
|
|
763
|
+
this.jse.actionEntries.delete(name);
|
|
764
|
+
else
|
|
765
|
+
this.jse.actionEntries.set(name, count);
|
|
766
|
+
this.changed(`@action:${name}`);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
presentationChanged(key) { this.notify(new Set([key]), false); }
|
|
770
|
+
changed(key) {
|
|
771
|
+
if (this.pending !== null) {
|
|
772
|
+
this.pending.add(key);
|
|
773
|
+
if (globalThis
|
|
774
|
+
.__DSX_OPTIONAL_ACTION_FRAME__ !== false && storeHolds.get(this)?.owned === true && this.sinks.size > 0) {
|
|
775
|
+
const keys = new Set([key]);
|
|
776
|
+
for (const s of this.sinks)
|
|
777
|
+
s(this.jse.vars, keys);
|
|
778
|
+
}
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
this.notify(new Set([key]));
|
|
782
|
+
}
|
|
783
|
+
notify(keys, sinks = true) {
|
|
784
|
+
if (sinks)
|
|
785
|
+
for (const s of this.sinks)
|
|
786
|
+
s(this.jse.vars, keys); // snapshot sinks stay synchronous (store contract)
|
|
787
|
+
const logging = globalThis.__DSX_OPTIONAL_DEBUG__ !== false
|
|
788
|
+
&& StoreDebugSeam.onRerender !== null;
|
|
789
|
+
for (const sub of [...this.subscribers]) {
|
|
790
|
+
let hit = false;
|
|
791
|
+
for (const k of keys)
|
|
792
|
+
if (sub.keys.has(k)) {
|
|
793
|
+
hit = true;
|
|
794
|
+
if (globalThis.__DSX_OPTIONAL_DEBUG__ !== false && logging)
|
|
795
|
+
recordWhy(sub, [k], "write");
|
|
796
|
+
else
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
if (hit)
|
|
800
|
+
scheduleEffect(sub); // bindings coalesce per microtask (the scheduler)
|
|
801
|
+
}
|
|
802
|
+
// THE CONTEXT CONSUMERS, per key. The set is empty on every store nobody consumes, so
|
|
803
|
+
// this loop costs one `Set.size` check on an ordinary write; where it is not empty, a
|
|
804
|
+
// consumer wakes only for the names it actually read, which is the whole cost argument
|
|
805
|
+
// for the primitive at the size the Canvas is.
|
|
806
|
+
if (globalThis
|
|
807
|
+
.__DSX_OPTIONAL_CONTEXT__ === false || this.foreignSubscribers.size === 0)
|
|
808
|
+
return;
|
|
809
|
+
for (const sub of [...this.foreignSubscribers]) {
|
|
810
|
+
const mine = sub.foreign?.get(this);
|
|
811
|
+
if (mine === undefined)
|
|
812
|
+
continue;
|
|
813
|
+
let hit = false;
|
|
814
|
+
for (const k of keys)
|
|
815
|
+
if (mine.has(k)) {
|
|
816
|
+
hit = true;
|
|
817
|
+
if (globalThis.__DSX_OPTIONAL_DEBUG__ !== false && logging)
|
|
818
|
+
recordWhy(sub, [`${k}`], "context");
|
|
819
|
+
else
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
if (hit)
|
|
823
|
+
scheduleEffect(sub);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
/** DSXState pokes surface subscribers whose GLOBAL read-set intersects. */
|
|
827
|
+
notifyGlobal(keys) {
|
|
828
|
+
const logging = globalThis.__DSX_OPTIONAL_DEBUG__ !== false
|
|
829
|
+
&& StoreDebugSeam.onRerender !== null;
|
|
830
|
+
for (const sub of [...this.subscribers]) {
|
|
831
|
+
let hit = false;
|
|
832
|
+
for (const k of keys)
|
|
833
|
+
if (sub.globalKeys.has(k)) {
|
|
834
|
+
hit = true;
|
|
835
|
+
if (globalThis.__DSX_OPTIONAL_DEBUG__ !== false && logging)
|
|
836
|
+
recordWhy(sub, [k], "global");
|
|
837
|
+
else
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
if (hit)
|
|
841
|
+
scheduleEffect(sub);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
/** A binding: evaluate `read` with dependency tracking; re-run `onChange` when any
|
|
845
|
+
* read key changes AND the computed value meaningfully changed (watchKey dedup).
|
|
846
|
+
* Returns a disposer. Fires `onChange` once immediately with the initial value.
|
|
847
|
+
*
|
|
848
|
+
* `subject` NAMES THIS BINDING for the budget diagnostic and for nothing else - it is
|
|
849
|
+
* never read by the evaluator and changes no result. It is a string the CALLER already
|
|
850
|
+
* built (once, when the binding was created), because this function runs on every render
|
|
851
|
+
* of every bound attribute in the document. "" means the caller did not name it, and the
|
|
852
|
+
* diagnostic then says "an expression" rather than inventing a name. */
|
|
853
|
+
effect(read, onChange, subject = "", address = "") {
|
|
854
|
+
let lastKey = "";
|
|
855
|
+
return this.tracked(read, (value, fire) => {
|
|
856
|
+
const k = watchKey(value);
|
|
857
|
+
if (fire || k !== lastKey) {
|
|
858
|
+
lastKey = k;
|
|
859
|
+
onChange(value);
|
|
860
|
+
return true;
|
|
861
|
+
}
|
|
862
|
+
return false;
|
|
863
|
+
}, subject, address);
|
|
864
|
+
}
|
|
865
|
+
/** A TRACKED BINDING THAT DOES NOT FINGERPRINT ITS VALUE: `onChange` runs on the first
|
|
866
|
+
* evaluation and on every re-run a tracked read schedules, and the caller decides what
|
|
867
|
+
* "changed" means. It exists for the bound collections (dom mount.ts
|
|
868
|
+
* `collectionContextEffect`), which compare the evaluated array by REFERENCE because
|
|
869
|
+
* fingerprinting a 100k-row or cyclic host array on every write would defeat their work
|
|
870
|
+
* caps, and which used to follow the surface's own snapshot `sink` instead of a read set.
|
|
871
|
+
* A sink fires only for a write to ITS OWN store, so a collection whose rows came through
|
|
872
|
+
* `dsx.context` (a read registered on the PROVIDER's store, `foreign` below), or through a
|
|
873
|
+
* consumer formula over one, drew once and never again while a text binding beside it
|
|
874
|
+
* redrew (composition/context.json `redraw`). Tracking the reads is what subscribes the
|
|
875
|
+
* collection to the plane, one subscription per used declaration, like every other binding. */
|
|
876
|
+
observe(read, onChange, subject = "", address = "") {
|
|
877
|
+
return this.tracked(read, (value) => { onChange(value); return true; }, subject, address);
|
|
878
|
+
}
|
|
879
|
+
/** The one read-tracking subscription `effect` and `observe` share; `deliver` receives the
|
|
880
|
+
* value and whether this is the first (synchronous) evaluation. */
|
|
881
|
+
tracked(read, deliver, subject, address = "") {
|
|
882
|
+
const sub = { keys: new Set(), globalKeys: new Set(), run: () => { } };
|
|
883
|
+
const evaluate = (fire) => {
|
|
884
|
+
// THE SUBJECT IS IN FORCE FOR THE READ AND NOTHING ELSE: `onChange` below writes to
|
|
885
|
+
// the DOM, and an evaluation opened from there (a handler, a nested mount) is its own
|
|
886
|
+
// subject, not this binding's. Restored rather than cleared, because a binding can be
|
|
887
|
+
// evaluated inside another host door.
|
|
888
|
+
const held = setEvaluationSubject(subject);
|
|
889
|
+
let tracked;
|
|
890
|
+
try {
|
|
891
|
+
tracked = trackReads(read, this);
|
|
892
|
+
}
|
|
893
|
+
finally {
|
|
894
|
+
setEvaluationSubject(held);
|
|
895
|
+
}
|
|
896
|
+
const { value, surface, global, foreign } = tracked;
|
|
897
|
+
sub.keys = surface;
|
|
898
|
+
sub.globalKeys = global;
|
|
899
|
+
// RE-REGISTER THE FOREIGN READS EVERY EVALUATION, because a binding's read set is not
|
|
900
|
+
// fixed: `visible-if` can take a branch that reads a provider on one pass and not on
|
|
901
|
+
// the next. A store this pass did not read drops the subscriber, which is the same
|
|
902
|
+
// discipline `sub.keys` already gets by re-assignment.
|
|
903
|
+
if (globalThis
|
|
904
|
+
.__DSX_OPTIONAL_CONTEXT__ !== false) {
|
|
905
|
+
const held = sub.foreign;
|
|
906
|
+
if (held !== undefined) {
|
|
907
|
+
for (const store of held.keys())
|
|
908
|
+
if (foreign === null || !foreign.has(store))
|
|
909
|
+
store.dropForeign(sub);
|
|
910
|
+
}
|
|
911
|
+
if (foreign === null)
|
|
912
|
+
delete sub.foreign;
|
|
913
|
+
else {
|
|
914
|
+
for (const store of foreign.keys())
|
|
915
|
+
store.adoptForeign(sub);
|
|
916
|
+
sub.foreign = foreign;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
const changed = deliver(value, fire);
|
|
920
|
+
// THE RE-RENDER LOG (SPEC item 7): only a re-run (never the first, synchronous render)
|
|
921
|
+
// and only while a development host listens. `why` is consumed either way so a stale
|
|
922
|
+
// reason can never be attributed to a later run.
|
|
923
|
+
// BLOCK-FORM FOLD: an embed (debug plane folded) never records a `why`, so the whole log folds.
|
|
924
|
+
if (globalThis.__DSX_OPTIONAL_DEBUG__ !== false) {
|
|
925
|
+
const why = sub.why;
|
|
926
|
+
if (why !== undefined)
|
|
927
|
+
delete sub.why;
|
|
928
|
+
const listener = StoreDebugSeam.onRerender;
|
|
929
|
+
if (!fire && listener !== null) {
|
|
930
|
+
const reads = [...sub.keys, ...sub.globalKeys];
|
|
931
|
+
if (sub.foreign !== undefined)
|
|
932
|
+
for (const keys of sub.foreign.values())
|
|
933
|
+
reads.push(...keys);
|
|
934
|
+
const names = why === undefined ? [] : [...why.names];
|
|
935
|
+
listener({
|
|
936
|
+
store: this, subject, address, names, via: why?.via ?? "write", reads,
|
|
937
|
+
readsName: names.some((n) => reads.includes(n)), changed,
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
sub.run = () => evaluate(false);
|
|
943
|
+
this.subscribers.add(sub);
|
|
944
|
+
evaluate(true); // the first run is synchronous — mount sees real content
|
|
945
|
+
return () => {
|
|
946
|
+
sub.disposed = true;
|
|
947
|
+
this.subscribers.delete(sub);
|
|
948
|
+
// THE LEAK THIS LINE EXISTS FOR: `effect`'s own disposer deletes from `this`, so a
|
|
949
|
+
// foreign registration left behind survives the consumer's unmount and keeps the
|
|
950
|
+
// provider's store reachable. Report 02 named it the single most likely defect in the
|
|
951
|
+
// design; it has a corpus row (composition/context.json, `lifetime.cases`).
|
|
952
|
+
if (globalThis
|
|
953
|
+
.__DSX_OPTIONAL_CONTEXT__ !== false) {
|
|
954
|
+
const held = sub.foreign;
|
|
955
|
+
if (held !== undefined)
|
|
956
|
+
for (const store of held.keys())
|
|
957
|
+
store.dropForeign(sub);
|
|
958
|
+
delete sub.foreign;
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
/** `<watch value= on:change=>` — like effect, but NEVER fires on subscribe. */
|
|
963
|
+
watch(read, onChange, subject = "") {
|
|
964
|
+
let first = true;
|
|
965
|
+
return this.effect(read, (v) => {
|
|
966
|
+
if (first) {
|
|
967
|
+
first = false;
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
onChange(v);
|
|
971
|
+
}, subject);
|
|
972
|
+
}
|
|
973
|
+
eval(expr, item = null) { return JSE.eval(expr, this.jse, item); }
|
|
974
|
+
evalBlock(body, item = null) { return JSE.evalBlock(body, this.jse, item); }
|
|
975
|
+
interpolate(s, item = null) { return JSE.interpolate(s, this.jse, item); }
|
|
976
|
+
}
|
|
977
|
+
// ── the app-wide store (DSX.state twin) ──────────────────────────────────────────────
|
|
978
|
+
class DSXStateStore {
|
|
979
|
+
vars = {};
|
|
980
|
+
sinks = new Set();
|
|
981
|
+
surfaces = new Set();
|
|
982
|
+
pending = null;
|
|
983
|
+
attach(surface) {
|
|
984
|
+
this.surfaces.add(surface);
|
|
985
|
+
}
|
|
986
|
+
detach(surface) {
|
|
987
|
+
this.surfaces.delete(surface);
|
|
988
|
+
}
|
|
989
|
+
sink(fn) {
|
|
990
|
+
this.sinks.add(fn);
|
|
991
|
+
fn(this.vars);
|
|
992
|
+
return () => this.sinks.delete(fn);
|
|
993
|
+
}
|
|
994
|
+
/** A server render's own values for this request (a package's server context), read ahead of the shared plane. The
|
|
995
|
+
* server installs it over its per-request scope, so two readers an isolate serves at once never see each other's. */
|
|
996
|
+
overlay = null;
|
|
997
|
+
get(path) {
|
|
998
|
+
const own = this.overlay?.(path) ?? null;
|
|
999
|
+
if (own !== null)
|
|
1000
|
+
return own.value;
|
|
1001
|
+
const parts = validatedPathParts(path, true);
|
|
1002
|
+
if (parts === null)
|
|
1003
|
+
return null;
|
|
1004
|
+
let cur = this.vars;
|
|
1005
|
+
for (const p of parts) {
|
|
1006
|
+
const i = /^\d+$/.test(p) ? Number(p) : null;
|
|
1007
|
+
if (i !== null && Array.isArray(cur))
|
|
1008
|
+
cur = i >= 0 && i < cur.length ? cur[i] : null;
|
|
1009
|
+
else
|
|
1010
|
+
cur = isDict(cur) ? (cur[p] ?? null) : null;
|
|
1011
|
+
}
|
|
1012
|
+
return cur ?? null;
|
|
1013
|
+
}
|
|
1014
|
+
set(path, value) {
|
|
1015
|
+
// A RUNNING CALL IS NEVER PASSED TO ANOTHER DOCUMENT (constitution Article 14.2): the app-wide
|
|
1016
|
+
// store refuses it and keeps what it held, as a persisted slot does (store-value.ts).
|
|
1017
|
+
if (isCallValue(value))
|
|
1018
|
+
return;
|
|
1019
|
+
const parts = validatedPathParts(path);
|
|
1020
|
+
if (parts === null)
|
|
1021
|
+
return;
|
|
1022
|
+
const top = parts[0];
|
|
1023
|
+
if (!Object.prototype.hasOwnProperty.call(this.vars, top)
|
|
1024
|
+
&& Object.keys(this.vars).length >= STATE_PATH_LIMITS.maxContainerEntries)
|
|
1025
|
+
return;
|
|
1026
|
+
const prev = this.vars[top];
|
|
1027
|
+
const rebuilt = parts.length === 1
|
|
1028
|
+
? { accepted: true, value }
|
|
1029
|
+
: rebuildStatePath(prev, parts.slice(1), value);
|
|
1030
|
+
if (!rebuilt.accepted)
|
|
1031
|
+
return;
|
|
1032
|
+
const next = rebuilt.value;
|
|
1033
|
+
if (prev !== undefined && jseEquals(prev, next) && watchKey(prev) === watchKey(next))
|
|
1034
|
+
return;
|
|
1035
|
+
this.vars = { ...this.vars, [top]: next };
|
|
1036
|
+
this.changed(top);
|
|
1037
|
+
}
|
|
1038
|
+
/** Unlink the value at a dot-path: a top-level key leaves the store, an object key leaves its
|
|
1039
|
+
* object, an array index leaves its array (the elements after it move down). A path that holds
|
|
1040
|
+
* nothing changes nothing and notifies nobody. Twins: DSXState.swift `StackStore.removePath`,
|
|
1041
|
+
* State.kt `StackStore.removePath`; Mandatory/State's `remove` is its module face. */
|
|
1042
|
+
remove(path) {
|
|
1043
|
+
const parts = validatedPathParts(path);
|
|
1044
|
+
if (parts === null)
|
|
1045
|
+
return;
|
|
1046
|
+
const top = parts[0];
|
|
1047
|
+
if (!Object.prototype.hasOwnProperty.call(this.vars, top))
|
|
1048
|
+
return;
|
|
1049
|
+
if (parts.length === 1) {
|
|
1050
|
+
const next = { ...this.vars };
|
|
1051
|
+
delete next[top];
|
|
1052
|
+
this.vars = next;
|
|
1053
|
+
this.changed(top);
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
const pruned = unlinkStatePath(this.vars[top], parts.slice(1));
|
|
1057
|
+
if (!pruned.removed)
|
|
1058
|
+
return;
|
|
1059
|
+
this.vars = { ...this.vars, [top]: pruned.value };
|
|
1060
|
+
this.changed(top);
|
|
1061
|
+
}
|
|
1062
|
+
batch(run) {
|
|
1063
|
+
if (this.pending !== null) {
|
|
1064
|
+
run();
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
this.pending = new Set();
|
|
1068
|
+
try {
|
|
1069
|
+
run();
|
|
1070
|
+
}
|
|
1071
|
+
finally {
|
|
1072
|
+
const keys = this.pending;
|
|
1073
|
+
this.pending = null;
|
|
1074
|
+
if (keys.size > 0)
|
|
1075
|
+
this.notify(keys);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
changed(key) {
|
|
1079
|
+
if (this.pending !== null) {
|
|
1080
|
+
this.pending.add(key);
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
this.notify(new Set([key]));
|
|
1084
|
+
}
|
|
1085
|
+
notify(keys) {
|
|
1086
|
+
for (const s of this.sinks)
|
|
1087
|
+
s(this.vars);
|
|
1088
|
+
for (const surface of this.surfaces)
|
|
1089
|
+
surface.notifyGlobal(keys);
|
|
1090
|
+
}
|
|
1091
|
+
/** Notify tracked external state (cookies, reachability, host-owned signals)
|
|
1092
|
+
* without exposing a synthetic value through `global.*`. */
|
|
1093
|
+
invalidate(key) {
|
|
1094
|
+
this.notify(new Set([key]));
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
/** the ONE app-wide store */
|
|
1098
|
+
export const DSXState = new DSXStateStore();
|
|
1099
|
+
/** Call after a cookie write or a mutation that may rotate an HttpOnly session.
|
|
1100
|
+
* GET `<api>` blocks include the revision in their materialized identity, so
|
|
1101
|
+
* this forces a safe refetch even when JavaScript cannot read the cookie value. */
|
|
1102
|
+
export function invalidateCookies() {
|
|
1103
|
+
cookieRevision += 1;
|
|
1104
|
+
DSXState.invalidate("cookie");
|
|
1105
|
+
}
|
|
1106
|
+
// wire the JSE seams: `global.*` reads come from DSXState, with read tracking.
|
|
1107
|
+
JSESeams.stateVars = () => DSXState.vars;
|
|
1108
|
+
JSESeams.onGlobalRead = (key) => noteGlobalRead(key);
|
|
1109
|
+
export { NSNull, JSESeams };
|
|
1110
|
+
// ── DECLARED SHAPES (`type=` and `moves=`, proposals/types-on-declarations.md Decision 6) ──
|
|
1111
|
+
//
|
|
1112
|
+
// JUDGED IN `ReactiveStore.set`, AFTER THE WRITE LANDED, for the `keep` reason: `set` is the one
|
|
1113
|
+
// place a variable write lands, so it is the one place a write can be judged without a copy of
|
|
1114
|
+
// the rule per call site. The judgement changes nothing - the value is already stored and its
|
|
1115
|
+
// bindings already scheduled - it only speaks, in dev, through the kernel's diagnostic wire
|
|
1116
|
+
// (`judgeDeclaredShape`, jse.ts). An elided write is not judged: nothing arrived.
|
|
1117
|
+
//
|
|
1118
|
+
// MODULE FUNCTIONS OVER A WEAK MAP, NOT MEMBERS OF THE CLASS. A class member survives every
|
|
1119
|
+
// fold (a bundler cannot prove a method is never called), so as members these shipped in every
|
|
1120
|
+
// embed under the dev-lines guard as an empty `judged(){}`, a `shapes` field and a
|
|
1121
|
+
// `declareShape` body, and pushed the EmbedCard qualification over its 40KB law. As functions
|
|
1122
|
+
// referenced only inside `__DSX_OPTIONAL_DEV_LINES__` branches they fold out with the guard.
|
|
1123
|
+
/** store → (`as` → the declaration it is judged against). Absent for every store that declares
|
|
1124
|
+
* no shape or is not in dev, which is every shipped app: the head fold registers a row only
|
|
1125
|
+
* when `JSESeams.dev` is on. */
|
|
1126
|
+
let declaredShapes = null;
|
|
1127
|
+
/** Register one typed variable of a store (the head fold's seed step calls this, once, at
|
|
1128
|
+
* mount, in dev). */
|
|
1129
|
+
export function declareShape(store, as, subject, type, moves) {
|
|
1130
|
+
if (declaredShapes === null)
|
|
1131
|
+
declaredShapes = new WeakMap();
|
|
1132
|
+
let rows = declaredShapes.get(store);
|
|
1133
|
+
if (rows === undefined) {
|
|
1134
|
+
rows = new Map();
|
|
1135
|
+
declaredShapes.set(store, rows);
|
|
1136
|
+
}
|
|
1137
|
+
rows.set(as, { subject, type, moves });
|
|
1138
|
+
}
|
|
1139
|
+
function judgeWrite(store, key, value, previous) {
|
|
1140
|
+
const row = declaredShapes?.get(store)?.get(key);
|
|
1141
|
+
if (row !== undefined)
|
|
1142
|
+
judgeDeclaredShape(row, value, previous);
|
|
1143
|
+
}
|
|
1144
|
+
//# sourceMappingURL=store.js.map
|