@wardic/solid 2.2.0 → 3.0.0-next.1
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/README.md +39 -18
- package/dist/browser/animation-frame.js +1 -1
- package/dist/browser/animation-frame.js.map +1 -1
- package/dist/browser/config-view.js +35 -6
- package/dist/browser/config-view.js.map +1 -1
- package/dist/browser/create-batch.js +1 -1
- package/dist/browser/diagnostic-codes.js +216 -0
- package/dist/browser/diagnostic-codes.js.map +1 -0
- package/dist/browser/diagnostics.js +79 -0
- package/dist/browser/diagnostics.js.map +1 -0
- package/dist/browser/element-style.js +61 -7
- package/dist/browser/element-style.js.map +1 -1
- package/dist/browser/element.js +24 -6
- package/dist/browser/element.js.map +1 -1
- package/dist/browser/feature-section.js +5 -13
- package/dist/browser/feature-section.js.map +1 -1
- package/dist/browser/frame-effect.js +1 -1
- package/dist/browser/frame-effect.js.map +1 -1
- package/dist/browser/gesture-callbacks.js +1 -1
- package/dist/browser/gesture-callbacks.js.map +1 -1
- package/dist/browser/hooks/auto.js +270 -0
- package/dist/browser/hooks/auto.js.map +1 -0
- package/dist/browser/hooks/config-scope.js +120 -0
- package/dist/browser/hooks/config-scope.js.map +1 -0
- package/dist/browser/hooks/config.js +37 -0
- package/dist/browser/hooks/config.js.map +1 -0
- package/dist/browser/hooks/drag.js +633 -0
- package/dist/browser/hooks/drag.js.map +1 -0
- package/dist/browser/hooks/elements.js +183 -0
- package/dist/browser/hooks/elements.js.map +1 -0
- package/dist/browser/hooks/group.js +28 -0
- package/dist/browser/hooks/group.js.map +1 -0
- package/dist/browser/hooks/index.js +10 -0
- package/dist/browser/hooks/index.js.map +1 -0
- package/dist/browser/hooks/kept.js +32 -0
- package/dist/browser/hooks/kept.js.map +1 -0
- package/dist/browser/hooks/layout-group-of.js +39 -0
- package/dist/browser/hooks/layout-group-of.js.map +1 -0
- package/dist/browser/hooks/layout-group.js +92 -0
- package/dist/browser/hooks/layout-group.js.map +1 -0
- package/dist/browser/hooks/make-ward.js +157 -0
- package/dist/browser/hooks/make-ward.js.map +1 -0
- package/dist/browser/hooks/presence-scope.js +88 -0
- package/dist/browser/hooks/presence-scope.js.map +1 -0
- package/dist/browser/hooks/presence.js +24 -0
- package/dist/browser/hooks/presence.js.map +1 -0
- package/dist/browser/hooks/props.js +148 -0
- package/dist/browser/hooks/props.js.map +1 -0
- package/dist/browser/hooks/reads.js +241 -0
- package/dist/browser/hooks/reads.js.map +1 -0
- package/dist/browser/hooks/refs.js +87 -0
- package/dist/browser/hooks/refs.js.map +1 -0
- package/dist/browser/hooks/reorder-elements.js +269 -0
- package/dist/browser/hooks/reorder-elements.js.map +1 -0
- package/dist/browser/hooks/reorder.js +176 -0
- package/dist/browser/hooks/reorder.js.map +1 -0
- package/dist/browser/hooks/rune.js +800 -0
- package/dist/browser/hooks/rune.js.map +1 -0
- package/dist/browser/hooks/server-features.client.js +2 -0
- package/dist/browser/hooks/server-features.client.js.map +1 -0
- package/dist/browser/hooks/server-features.js +13 -0
- package/dist/browser/hooks/server-features.js.map +1 -0
- package/dist/browser/hooks/settings.js +29 -0
- package/dist/browser/hooks/settings.js.map +1 -0
- package/dist/browser/hooks/setup.js +154 -0
- package/dist/browser/hooks/setup.js.map +1 -0
- package/dist/browser/hooks/stage.js +117 -0
- package/dist/browser/hooks/stage.js.map +1 -0
- package/dist/browser/hooks/ward.js +2212 -0
- package/dist/browser/hooks/ward.js.map +1 -0
- package/dist/browser/hooks/wardic-provider.js +29 -0
- package/dist/browser/hooks/wardic-provider.js.map +1 -0
- package/dist/browser/hooks/wardic-scope.js +68 -0
- package/dist/browser/hooks/wardic-scope.js.map +1 -0
- package/dist/browser/hooks/wards.js +563 -0
- package/dist/browser/hooks/wards.js.map +1 -0
- package/dist/browser/index.js +23 -11
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/layout.js +7 -58
- package/dist/browser/layout.js.map +1 -1
- package/dist/browser/lazy-batch-gestures.js +1 -1
- package/dist/browser/lifecycle.js +37 -0
- package/dist/browser/lifecycle.js.map +1 -1
- package/dist/browser/presence-handle.js +28 -12
- package/dist/browser/presence-handle.js.map +1 -1
- package/dist/browser/presence.js +3 -1
- package/dist/browser/presence.js.map +1 -1
- package/dist/browser/provider.js +124 -90
- package/dist/browser/provider.js.map +1 -1
- package/dist/browser/reorder-components.js +50 -0
- package/dist/browser/reorder-components.js.map +1 -0
- package/dist/browser/reorder.js +51 -278
- package/dist/browser/reorder.js.map +1 -1
- package/dist/browser/runtime.js +26 -15
- package/dist/browser/runtime.js.map +1 -1
- package/dist/browser/spans-check.js +8 -3
- package/dist/browser/spans-check.js.map +1 -1
- package/dist/browser/stage.js.map +1 -1
- package/dist/browser/unstable/v2/index.js +0 -8
- package/dist/browser/unstable/v2/index.js.map +1 -1
- package/dist/browser/v1/index.js +1 -1
- package/dist/browser/v1/index.js.map +1 -1
- package/dist/browser/variant-node.js +4 -2
- package/dist/browser/variant-node.js.map +1 -1
- package/dist/browser/w.js +33 -3
- package/dist/browser/w.js.map +1 -1
- package/dist/browser/ward.js +594 -61
- package/dist/browser/ward.js.map +1 -1
- package/dist/browser/wardic-config.js +62 -29
- package/dist/browser/wardic-config.js.map +1 -1
- package/dist/browser/wardic-context.js +23 -0
- package/dist/browser/wardic-context.js.map +1 -0
- package/dist/browser/wardic.js +3 -0
- package/dist/browser/wardic.js.map +1 -1
- package/dist/server/animation-frame.js +1 -1
- package/dist/server/animation-frame.js.map +1 -1
- package/dist/server/config-view.js +35 -6
- package/dist/server/config-view.js.map +1 -1
- package/dist/server/create-batch.js +1 -1
- package/dist/server/diagnostic-codes.js +216 -0
- package/dist/server/diagnostic-codes.js.map +1 -0
- package/dist/server/diagnostics.js +79 -0
- package/dist/server/diagnostics.js.map +1 -0
- package/dist/server/element-style.js +61 -7
- package/dist/server/element-style.js.map +1 -1
- package/dist/server/element.js +24 -6
- package/dist/server/element.js.map +1 -1
- package/dist/server/feature-section.js +5 -13
- package/dist/server/feature-section.js.map +1 -1
- package/dist/server/frame-effect.js +1 -1
- package/dist/server/frame-effect.js.map +1 -1
- package/dist/server/gesture-callbacks.js +1 -1
- package/dist/server/gesture-callbacks.js.map +1 -1
- package/dist/server/hooks/auto.js +270 -0
- package/dist/server/hooks/auto.js.map +1 -0
- package/dist/server/hooks/config-scope.js +120 -0
- package/dist/server/hooks/config-scope.js.map +1 -0
- package/dist/server/hooks/config.js +37 -0
- package/dist/server/hooks/config.js.map +1 -0
- package/dist/server/hooks/drag.js +633 -0
- package/dist/server/hooks/drag.js.map +1 -0
- package/dist/server/hooks/elements.js +192 -0
- package/dist/server/hooks/elements.js.map +1 -0
- package/dist/server/hooks/group.js +28 -0
- package/dist/server/hooks/group.js.map +1 -0
- package/dist/server/hooks/index.js +10 -0
- package/dist/server/hooks/index.js.map +1 -0
- package/dist/server/hooks/kept.js +32 -0
- package/dist/server/hooks/kept.js.map +1 -0
- package/dist/server/hooks/layout-group-of.js +39 -0
- package/dist/server/hooks/layout-group-of.js.map +1 -0
- package/dist/server/hooks/layout-group.js +109 -0
- package/dist/server/hooks/layout-group.js.map +1 -0
- package/dist/server/hooks/make-ward.js +157 -0
- package/dist/server/hooks/make-ward.js.map +1 -0
- package/dist/server/hooks/presence-scope.js +87 -0
- package/dist/server/hooks/presence-scope.js.map +1 -0
- package/dist/server/hooks/presence.js +24 -0
- package/dist/server/hooks/presence.js.map +1 -0
- package/dist/server/hooks/props.js +148 -0
- package/dist/server/hooks/props.js.map +1 -0
- package/dist/server/hooks/reads.js +241 -0
- package/dist/server/hooks/reads.js.map +1 -0
- package/dist/server/hooks/refs.js +87 -0
- package/dist/server/hooks/refs.js.map +1 -0
- package/dist/server/hooks/reorder-elements.js +309 -0
- package/dist/server/hooks/reorder-elements.js.map +1 -0
- package/dist/server/hooks/reorder.js +176 -0
- package/dist/server/hooks/reorder.js.map +1 -0
- package/dist/server/hooks/rune.js +800 -0
- package/dist/server/hooks/rune.js.map +1 -0
- package/dist/server/hooks/server-features.client.js +2 -0
- package/dist/server/hooks/server-features.client.js.map +1 -0
- package/dist/server/hooks/server-features.js +13 -0
- package/dist/server/hooks/server-features.js.map +1 -0
- package/dist/server/hooks/settings.js +29 -0
- package/dist/server/hooks/settings.js.map +1 -0
- package/dist/server/hooks/setup.js +154 -0
- package/dist/server/hooks/setup.js.map +1 -0
- package/dist/server/hooks/stage.js +117 -0
- package/dist/server/hooks/stage.js.map +1 -0
- package/dist/server/hooks/ward.js +2212 -0
- package/dist/server/hooks/ward.js.map +1 -0
- package/dist/server/hooks/wardic-provider.js +29 -0
- package/dist/server/hooks/wardic-provider.js.map +1 -0
- package/dist/server/hooks/wardic-scope.js +68 -0
- package/dist/server/hooks/wardic-scope.js.map +1 -0
- package/dist/server/hooks/wards.js +563 -0
- package/dist/server/hooks/wards.js.map +1 -0
- package/dist/server/index.js +23 -11
- package/dist/server/index.js.map +1 -1
- package/dist/server/layout.js +7 -75
- package/dist/server/layout.js.map +1 -1
- package/dist/server/lazy-batch-gestures.js +1 -1
- package/dist/server/lifecycle.js +37 -0
- package/dist/server/lifecycle.js.map +1 -1
- package/dist/server/presence-handle.js +28 -12
- package/dist/server/presence-handle.js.map +1 -1
- package/dist/server/presence.js +3 -1
- package/dist/server/presence.js.map +1 -1
- package/dist/server/provider.js +125 -100
- package/dist/server/provider.js.map +1 -1
- package/dist/server/reorder-components.js +50 -0
- package/dist/server/reorder-components.js.map +1 -0
- package/dist/server/reorder.js +51 -348
- package/dist/server/reorder.js.map +1 -1
- package/dist/server/runtime.js +26 -15
- package/dist/server/runtime.js.map +1 -1
- package/dist/server/spans-check.js +8 -3
- package/dist/server/spans-check.js.map +1 -1
- package/dist/server/stage.js.map +1 -1
- package/dist/server/unstable/v2/index.js +0 -8
- package/dist/server/unstable/v2/index.js.map +1 -1
- package/dist/server/v1/index.js +1 -1
- package/dist/server/v1/index.js.map +1 -1
- package/dist/server/variant-node.js +4 -2
- package/dist/server/variant-node.js.map +1 -1
- package/dist/server/w.js +33 -3
- package/dist/server/w.js.map +1 -1
- package/dist/server/ward.js +594 -61
- package/dist/server/ward.js.map +1 -1
- package/dist/server/wardic-config.js +63 -30
- package/dist/server/wardic-config.js.map +1 -1
- package/dist/server/wardic-context.js +23 -0
- package/dist/server/wardic-context.js.map +1 -0
- package/dist/server/wardic.js +3 -0
- package/dist/server/wardic.js.map +1 -1
- package/dist/solid/animation-frame.js +1 -1
- package/dist/solid/animation-frame.js.map +1 -1
- package/dist/solid/batch-reorder-group.d.ts +1 -1
- package/dist/solid/batch-reorder.d.ts +1 -1
- package/dist/solid/batch-reorder.d.ts.map +1 -1
- package/dist/solid/config-view.d.ts +11 -0
- package/dist/solid/config-view.d.ts.map +1 -1
- package/dist/solid/config-view.js +31 -7
- package/dist/solid/config-view.js.map +1 -1
- package/dist/solid/create-batch.jsx +1 -1
- package/dist/solid/diagnostic-codes.d.ts +10 -0
- package/dist/solid/diagnostic-codes.d.ts.map +1 -0
- package/dist/solid/diagnostic-codes.js +246 -0
- package/dist/solid/diagnostic-codes.js.map +1 -0
- package/dist/solid/diagnostics.d.ts +33 -0
- package/dist/solid/diagnostics.d.ts.map +1 -0
- package/dist/solid/diagnostics.js +76 -0
- package/dist/solid/diagnostics.js.map +1 -0
- package/dist/solid/element-style.d.ts +16 -2
- package/dist/solid/element-style.d.ts.map +1 -1
- package/dist/solid/element-style.js +61 -7
- package/dist/solid/element-style.js.map +1 -1
- package/dist/solid/element.d.ts +3 -1
- package/dist/solid/element.d.ts.map +1 -1
- package/dist/solid/element.jsx +27 -8
- package/dist/solid/element.jsx.map +1 -1
- package/dist/solid/feature-section.d.ts +0 -7
- package/dist/solid/feature-section.d.ts.map +1 -1
- package/dist/solid/feature-section.js +5 -13
- package/dist/solid/feature-section.js.map +1 -1
- package/dist/solid/frame-effect.jsx +1 -1
- package/dist/solid/frame-effect.jsx.map +1 -1
- package/dist/solid/gesture-callbacks.js +1 -1
- package/dist/solid/gesture-callbacks.js.map +1 -1
- package/dist/solid/hooks/auto.d.ts +44 -0
- package/dist/solid/hooks/auto.d.ts.map +1 -0
- package/dist/solid/hooks/auto.js +269 -0
- package/dist/solid/hooks/auto.js.map +1 -0
- package/dist/solid/hooks/config-scope.d.ts +84 -0
- package/dist/solid/hooks/config-scope.d.ts.map +1 -0
- package/dist/solid/hooks/config-scope.jsx +128 -0
- package/dist/solid/hooks/config-scope.jsx.map +1 -0
- package/dist/solid/hooks/config.d.ts +28 -0
- package/dist/solid/hooks/config.d.ts.map +1 -0
- package/dist/solid/hooks/config.jsx +37 -0
- package/dist/solid/hooks/config.jsx.map +1 -0
- package/dist/solid/hooks/drag.d.ts +220 -0
- package/dist/solid/hooks/drag.d.ts.map +1 -0
- package/dist/solid/hooks/drag.js +586 -0
- package/dist/solid/hooks/drag.js.map +1 -0
- package/dist/solid/hooks/elements.d.ts +11 -0
- package/dist/solid/hooks/elements.d.ts.map +1 -0
- package/dist/solid/hooks/elements.jsx +218 -0
- package/dist/solid/hooks/elements.jsx.map +1 -0
- package/dist/solid/hooks/group.d.ts +46 -0
- package/dist/solid/hooks/group.d.ts.map +1 -0
- package/dist/solid/hooks/group.jsx +25 -0
- package/dist/solid/hooks/group.jsx.map +1 -0
- package/dist/solid/hooks/index.d.ts +28 -0
- package/dist/solid/hooks/index.d.ts.map +1 -0
- package/dist/solid/hooks/index.js +10 -0
- package/dist/solid/hooks/index.js.map +1 -0
- package/dist/solid/hooks/kept.d.ts +60 -0
- package/dist/solid/hooks/kept.d.ts.map +1 -0
- package/dist/solid/hooks/kept.js +33 -0
- package/dist/solid/hooks/kept.js.map +1 -0
- package/dist/solid/hooks/layout-group-of.d.ts +27 -0
- package/dist/solid/hooks/layout-group-of.d.ts.map +1 -0
- package/dist/solid/hooks/layout-group-of.js +39 -0
- package/dist/solid/hooks/layout-group-of.js.map +1 -0
- package/dist/solid/hooks/layout-group.d.ts +60 -0
- package/dist/solid/hooks/layout-group.d.ts.map +1 -0
- package/dist/solid/hooks/layout-group.jsx +80 -0
- package/dist/solid/hooks/layout-group.jsx.map +1 -0
- package/dist/solid/hooks/make-ward.d.ts +123 -0
- package/dist/solid/hooks/make-ward.d.ts.map +1 -0
- package/dist/solid/hooks/make-ward.js +147 -0
- package/dist/solid/hooks/make-ward.js.map +1 -0
- package/dist/solid/hooks/presence-scope.d.ts +84 -0
- package/dist/solid/hooks/presence-scope.d.ts.map +1 -0
- package/dist/solid/hooks/presence-scope.jsx +63 -0
- package/dist/solid/hooks/presence-scope.jsx.map +1 -0
- package/dist/solid/hooks/presence.d.ts +51 -0
- package/dist/solid/hooks/presence.d.ts.map +1 -0
- package/dist/solid/hooks/presence.jsx +26 -0
- package/dist/solid/hooks/presence.jsx.map +1 -0
- package/dist/solid/hooks/props.d.ts +52 -0
- package/dist/solid/hooks/props.d.ts.map +1 -0
- package/dist/solid/hooks/props.js +140 -0
- package/dist/solid/hooks/props.js.map +1 -0
- package/dist/solid/hooks/reads.d.ts +38 -0
- package/dist/solid/hooks/reads.d.ts.map +1 -0
- package/dist/solid/hooks/reads.js +218 -0
- package/dist/solid/hooks/reads.js.map +1 -0
- package/dist/solid/hooks/refs.d.ts +25 -0
- package/dist/solid/hooks/refs.d.ts.map +1 -0
- package/dist/solid/hooks/refs.js +89 -0
- package/dist/solid/hooks/refs.js.map +1 -0
- package/dist/solid/hooks/reorder-elements.d.ts +23 -0
- package/dist/solid/hooks/reorder-elements.d.ts.map +1 -0
- package/dist/solid/hooks/reorder-elements.jsx +274 -0
- package/dist/solid/hooks/reorder-elements.jsx.map +1 -0
- package/dist/solid/hooks/reorder.d.ts +55 -0
- package/dist/solid/hooks/reorder.d.ts.map +1 -0
- package/dist/solid/hooks/reorder.js +152 -0
- package/dist/solid/hooks/reorder.js.map +1 -0
- package/dist/solid/hooks/rune.d.ts +885 -0
- package/dist/solid/hooks/rune.d.ts.map +1 -0
- package/dist/solid/hooks/rune.js +817 -0
- package/dist/solid/hooks/rune.js.map +1 -0
- package/dist/solid/hooks/server-features.client.d.ts +10 -0
- package/dist/solid/hooks/server-features.client.d.ts.map +1 -0
- package/dist/solid/hooks/server-features.client.js +2 -0
- package/dist/solid/hooks/server-features.client.js.map +1 -0
- package/dist/solid/hooks/server-features.d.ts +10 -0
- package/dist/solid/hooks/server-features.d.ts.map +1 -0
- package/dist/solid/hooks/server-features.js +13 -0
- package/dist/solid/hooks/server-features.js.map +1 -0
- package/dist/solid/hooks/settings.d.ts +11 -0
- package/dist/solid/hooks/settings.d.ts.map +1 -0
- package/dist/solid/hooks/settings.js +31 -0
- package/dist/solid/hooks/settings.js.map +1 -0
- package/dist/solid/hooks/setup.d.ts +31 -0
- package/dist/solid/hooks/setup.d.ts.map +1 -0
- package/dist/solid/hooks/setup.js +155 -0
- package/dist/solid/hooks/setup.js.map +1 -0
- package/dist/solid/hooks/stage.d.ts +187 -0
- package/dist/solid/hooks/stage.d.ts.map +1 -0
- package/dist/solid/hooks/stage.js +117 -0
- package/dist/solid/hooks/stage.js.map +1 -0
- package/dist/solid/hooks/ward.d.ts +394 -0
- package/dist/solid/hooks/ward.d.ts.map +1 -0
- package/dist/solid/hooks/ward.js +2258 -0
- package/dist/solid/hooks/ward.js.map +1 -0
- package/dist/solid/hooks/wardic-provider.d.ts +32 -0
- package/dist/solid/hooks/wardic-provider.d.ts.map +1 -0
- package/dist/solid/hooks/wardic-provider.jsx +29 -0
- package/dist/solid/hooks/wardic-provider.jsx.map +1 -0
- package/dist/solid/hooks/wardic-scope.d.ts +49 -0
- package/dist/solid/hooks/wardic-scope.d.ts.map +1 -0
- package/dist/solid/hooks/wardic-scope.jsx +63 -0
- package/dist/solid/hooks/wardic-scope.jsx.map +1 -0
- package/dist/solid/hooks/wards.d.ts +157 -0
- package/dist/solid/hooks/wards.d.ts.map +1 -0
- package/dist/solid/hooks/wards.js +523 -0
- package/dist/solid/hooks/wards.js.map +1 -0
- package/dist/solid/index.d.ts +21 -14
- package/dist/solid/index.d.ts.map +1 -1
- package/dist/solid/index.jsx +23 -11
- package/dist/solid/index.jsx.map +1 -1
- package/dist/solid/layout.d.ts +2 -44
- package/dist/solid/layout.d.ts.map +1 -1
- package/dist/solid/layout.jsx +7 -49
- package/dist/solid/layout.jsx.map +1 -1
- package/dist/solid/lazy-batch-gestures.js +1 -1
- package/dist/solid/lazy-batch-gestures.js.map +1 -1
- package/dist/solid/lifecycle.d.ts +19 -0
- package/dist/solid/lifecycle.d.ts.map +1 -1
- package/dist/solid/lifecycle.js +40 -0
- package/dist/solid/lifecycle.js.map +1 -1
- package/dist/solid/presence-handle.d.ts +13 -6
- package/dist/solid/presence-handle.d.ts.map +1 -1
- package/dist/solid/presence-handle.js +30 -12
- package/dist/solid/presence-handle.js.map +1 -1
- package/dist/solid/presence.d.ts +3 -1
- package/dist/solid/presence.d.ts.map +1 -1
- package/dist/solid/presence.jsx +3 -1
- package/dist/solid/presence.jsx.map +1 -1
- package/dist/solid/provider.d.ts +25 -32
- package/dist/solid/provider.d.ts.map +1 -1
- package/dist/solid/provider.jsx +126 -82
- package/dist/solid/provider.jsx.map +1 -1
- package/dist/solid/reorder-components.d.ts +32 -0
- package/dist/solid/reorder-components.d.ts.map +1 -0
- package/dist/solid/reorder-components.jsx +49 -0
- package/dist/solid/reorder-components.jsx.map +1 -0
- package/dist/solid/reorder.d.ts +50 -76
- package/dist/solid/reorder.d.ts.map +1 -1
- package/dist/solid/reorder.jsx +45 -206
- package/dist/solid/reorder.jsx.map +1 -1
- package/dist/solid/runtime.d.ts +20 -7
- package/dist/solid/runtime.d.ts.map +1 -1
- package/dist/solid/runtime.js +25 -14
- package/dist/solid/runtime.js.map +1 -1
- package/dist/solid/spans-check.d.ts +5 -1
- package/dist/solid/spans-check.d.ts.map +1 -1
- package/dist/solid/spans-check.js +8 -3
- package/dist/solid/spans-check.js.map +1 -1
- package/dist/solid/stage.d.ts +14 -0
- package/dist/solid/stage.d.ts.map +1 -1
- package/dist/solid/stage.js.map +1 -1
- package/dist/solid/unstable/v2/index.d.ts +2 -26
- package/dist/solid/unstable/v2/index.d.ts.map +1 -1
- package/dist/solid/unstable/v2/index.jsx +0 -16
- package/dist/solid/unstable/v2/index.jsx.map +1 -1
- package/dist/solid/v1/index.d.ts +1 -1
- package/dist/solid/v1/index.d.ts.map +1 -1
- package/dist/solid/v1/index.jsx +1 -1
- package/dist/solid/v1/index.jsx.map +1 -1
- package/dist/solid/variant-node.d.ts +6 -0
- package/dist/solid/variant-node.d.ts.map +1 -1
- package/dist/solid/variant-node.js +2 -0
- package/dist/solid/variant-node.js.map +1 -1
- package/dist/solid/w.d.ts +9 -3
- package/dist/solid/w.d.ts.map +1 -1
- package/dist/solid/w.jsx +36 -3
- package/dist/solid/w.jsx.map +1 -1
- package/dist/solid/ward.d.ts +134 -7
- package/dist/solid/ward.d.ts.map +1 -1
- package/dist/solid/ward.jsx +564 -60
- package/dist/solid/ward.jsx.map +1 -1
- package/dist/solid/wardic-config.d.ts +17 -12
- package/dist/solid/wardic-config.d.ts.map +1 -1
- package/dist/solid/wardic-config.jsx +68 -22
- package/dist/solid/wardic-config.jsx.map +1 -1
- package/dist/solid/wardic-context.d.ts +15 -0
- package/dist/solid/wardic-context.d.ts.map +1 -0
- package/dist/solid/wardic-context.js +23 -0
- package/dist/solid/wardic-context.js.map +1 -0
- package/dist/solid/wardic-instance.d.ts +6 -4
- package/dist/solid/wardic-instance.d.ts.map +1 -1
- package/dist/solid/wardic.d.ts +3 -0
- package/dist/solid/wardic.d.ts.map +1 -1
- package/dist/solid/wardic.jsx +3 -0
- package/dist/solid/wardic.jsx.map +1 -1
- package/package.json +29 -7
- package/skills/wardic-diagnostics/SKILL.md +472 -0
- package/skills/wardic-migrate/SKILL.md +204 -0
- package/skills/wardic-solid/SKILL.md +60 -0
- package/skills/wardic-solid/events.md +70 -0
- package/skills/wardic-solid/from-motion.md +59 -0
- package/skills/wardic-solid/lists-and-presence.md +110 -0
- package/skills/wardic-solid/reorder-and-grips.md +88 -0
- package/skills/wardic-solid/runes.md +151 -0
- package/skills/wardic-solid/scopes-and-settings.md +75 -0
- package/src/animation-frame.ts +1 -1
- package/src/batch-reorder-group.tsx +1 -1
- package/src/batch-reorder.ts +1 -1
- package/src/config-view.ts +35 -7
- package/src/create-batch.tsx +1 -1
- package/src/diagnostic-codes.ts +254 -0
- package/src/diagnostics.ts +88 -0
- package/src/element-style.ts +77 -9
- package/src/element.tsx +36 -12
- package/src/feature-section.ts +5 -15
- package/src/frame-effect.tsx +1 -1
- package/src/gesture-callbacks.ts +1 -1
- package/src/hooks/auto.ts +303 -0
- package/src/hooks/config-scope.tsx +215 -0
- package/src/hooks/config.tsx +54 -0
- package/src/hooks/drag.ts +741 -0
- package/src/hooks/elements.tsx +234 -0
- package/src/hooks/group.tsx +55 -0
- package/src/hooks/index.ts +41 -0
- package/src/hooks/kept.ts +89 -0
- package/src/hooks/layout-group-of.ts +46 -0
- package/src/hooks/layout-group.tsx +111 -0
- package/src/hooks/make-ward.ts +218 -0
- package/src/hooks/presence-scope.tsx +156 -0
- package/src/hooks/presence.tsx +67 -0
- package/src/hooks/props.ts +190 -0
- package/src/hooks/reads.ts +258 -0
- package/src/hooks/refs.ts +114 -0
- package/src/hooks/reorder-elements.tsx +323 -0
- package/src/hooks/reorder.ts +205 -0
- package/src/hooks/rune.ts +1756 -0
- package/src/hooks/server-features.client.ts +10 -0
- package/src/hooks/server-features.ts +12 -0
- package/src/hooks/settings.ts +44 -0
- package/src/hooks/setup.ts +184 -0
- package/src/hooks/stage.ts +359 -0
- package/src/hooks/ward.ts +2587 -0
- package/src/hooks/wardic-provider.tsx +51 -0
- package/src/hooks/wardic-scope.tsx +112 -0
- package/src/hooks/wards.ts +681 -0
- package/src/index.tsx +27 -15
- package/src/layout.tsx +7 -74
- package/src/lazy-batch-gestures.ts +1 -1
- package/src/lifecycle.ts +40 -0
- package/src/presence-handle.ts +39 -20
- package/src/presence.tsx +3 -1
- package/src/provider.tsx +136 -88
- package/src/reorder-components.tsx +61 -0
- package/src/reorder.tsx +89 -307
- package/src/runtime.ts +43 -13
- package/src/spans-check.ts +12 -3
- package/src/stage.ts +15 -0
- package/src/unstable/v2/index.tsx +2 -26
- package/src/v1/index.tsx +1 -1
- package/src/variant-node.ts +8 -0
- package/src/w.tsx +38 -5
- package/src/ward.tsx +694 -60
- package/src/wardic-config.tsx +68 -21
- package/src/wardic-context.ts +26 -0
- package/src/wardic-instance.ts +6 -4
- package/src/wardic.tsx +3 -0
- package/dist/browser/create-wardic.js +0 -36
- package/dist/browser/create-wardic.js.map +0 -1
- package/dist/browser/presence-hooks.js +0 -144
- package/dist/browser/presence-hooks.js.map +0 -1
- package/dist/server/create-wardic.js +0 -36
- package/dist/server/create-wardic.js.map +0 -1
- package/dist/server/presence-hooks.js +0 -144
- package/dist/server/presence-hooks.js.map +0 -1
- package/dist/solid/create-wardic.d.ts +0 -25
- package/dist/solid/create-wardic.d.ts.map +0 -1
- package/dist/solid/create-wardic.jsx +0 -34
- package/dist/solid/create-wardic.jsx.map +0 -1
- package/dist/solid/presence-hooks.d.ts +0 -53
- package/dist/solid/presence-hooks.d.ts.map +0 -1
- package/dist/solid/presence-hooks.jsx +0 -117
- package/dist/solid/presence-hooks.jsx.map +0 -1
- package/src/create-wardic.tsx +0 -46
- package/src/presence-hooks.tsx +0 -159
|
@@ -0,0 +1,2258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createWard(...runes)` (probe: hooks-first): one element's motion, made of runes, with `follow` and
|
|
3
|
+
* `show` as keys of its config. A new function beside `ward(config, options)`, which it leaves as it is.
|
|
4
|
+
*
|
|
5
|
+
* - **One plain rune** with none of the hooks' keys is today's ward on that config, with nothing
|
|
6
|
+
* between: what `ward(config)` costs.
|
|
7
|
+
* - **Runes join** into one config (`rune.ts`). A `createRune(fn)` is handed a ward before the finished one
|
|
8
|
+
* exists: a holder (`holderWard`, the ward split), which the finished ward then drives, as a component
|
|
9
|
+
* given a `wardRef` does (#349), so the rune's `when`, `next` and `read` are the finished ward's.
|
|
10
|
+
* - **`follow`** is the ward's variant parent (`ward(config, { parent })`).
|
|
11
|
+
* - **`show`** (an accessor): shown, it animates to `animate` from `initial`; not shown, it animates to
|
|
12
|
+
* its `exit` (its `initial`, with none; `exit: false` leaves at once), then sets `display: none`.
|
|
13
|
+
* `mounted()` stays true until that exit has landed, and its followers', for a `<Show>` that removes
|
|
14
|
+
* it instead. It's the ward's own Retarget, run while it lives: no `<AnimatePresence>`.
|
|
15
|
+
* - **`pop`** takes a `show` ward out of the flow as it starts to leave, pinned where it was with the
|
|
16
|
+
* presence's own measure (dom's `popBoxOf` and `pin`), by its top left or the corner it names, and
|
|
17
|
+
* puts it back when it's shown again. Whatever its mode, the layout projection is told as it comes, pops and goes, so a `layout`
|
|
18
|
+
* element beside it animates into or out of the space.
|
|
19
|
+
*
|
|
20
|
+
* - **A presence takes the ward itself** (`createPresence(ward, value)`, `wards.ts`): the one ward leaves
|
|
21
|
+
* and comes back, on a new element for each value. A ward `createWard` hands out is made ready for
|
|
22
|
+
* one: its `animate` is read through a wiring that does nothing until a presence takes it, and then
|
|
23
|
+
* is `show`'s, the presence's word in `show`'s place. One with a `show` of its own, or a row's, isn't.
|
|
24
|
+
*
|
|
25
|
+
* Throwaway code: `show` is wired through the config (`animate` and `style` read through it), where a
|
|
26
|
+
* real one would Retarget its spine itself, as a Scene object's exit does (`stage-ward.tsx`).
|
|
27
|
+
*
|
|
28
|
+
* @module
|
|
29
|
+
*/
|
|
30
|
+
import { isServer, spread } from "@solidjs/web";
|
|
31
|
+
import * as Arr from "effect/Array";
|
|
32
|
+
import * as Cause from "effect/Cause";
|
|
33
|
+
import * as Bool from "effect/Boolean";
|
|
34
|
+
import { constFalse, constUndefined, constVoid, identity } from "effect/Function";
|
|
35
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
36
|
+
import * as Iter from "effect/Iterable";
|
|
37
|
+
import * as Option from "effect/Option";
|
|
38
|
+
import * as Predicate from "effect/Predicate";
|
|
39
|
+
import { createEffect, createMemo, createRoot, createSignal, DEV, getOwner, onCleanup, runWithOwner, untrack } from "solid-js";
|
|
40
|
+
import * as Report from "@wardic/dom/Report";
|
|
41
|
+
import { pin, popBoxOf } from "@wardic/dom/unstable/PresenceController";
|
|
42
|
+
import * as RefreshFrameSource from "@wardic/core/RefreshFrameSource";
|
|
43
|
+
import { useBuiltProjection, useInstanceFeatures, useWardicRuntime } from "../provider.jsx";
|
|
44
|
+
import { useWardicConfig } from "../wardic-config.jsx";
|
|
45
|
+
import { layoutGroupIn } from "./layout-group-of.js";
|
|
46
|
+
import { givesSettings, runeGivesSettings, settingsOver } from "./settings.js";
|
|
47
|
+
import { eachOf, Waiters, whenOf } from "../waiters.js";
|
|
48
|
+
import { CLIENT_ONLY, onSettledClientOnly } from "../solid-reactivity.js";
|
|
49
|
+
import { misuse, report } from "../diagnostics.js";
|
|
50
|
+
import { fixLater, GESTURE_KEYS, holderFinished, holderWard, internalsOf, keepsState, sensedOf, sharedMember, shareMembers, shareOf, SLIM, targetAgain, wardWith } from "../ward.jsx";
|
|
51
|
+
import { asking, colorsOnceLoaded, featureOfEvent, wantedBy } from "./auto.js";
|
|
52
|
+
import { bothHandles, dragAccessorOf, dragAxisAt, dragAxisOf, givesDrag, isDragOnly, keysRuneOf, liftedOf, makeSite, raiseOf, runeWardOf, siteIfAny, siteInternalsOf, siteKeptFor, warnIfUndragged, withDrag, withGrips } from "./drag.js";
|
|
53
|
+
import { asReadOf, fixedRunes, functionOf, hasOwnVariants, isFunctionRune, isPlainRune, joined, joinedOver, namesNothing, readThroughOf, SEEN, wiredOf } from "./rune.js";
|
|
54
|
+
import { ALWAYS, keptFor, keptOf } from "./kept.js";
|
|
55
|
+
import { drivenBy, onOf, READS } from "./reads.js";
|
|
56
|
+
import { addedTo, carrying, isOneOf, propKeysOf, runePropsOf, settingOn, withCarrying } from "./props.js";
|
|
57
|
+
import { attending, refsRun, runeRefsOf } from "./refs.js";
|
|
58
|
+
const NO_CONFIG = {};
|
|
59
|
+
/** What a behaviour that reads `ward.drag` asks for (probe: behaviour-runes, Q5). */
|
|
60
|
+
const DRAG_WANTED = ["drag"];
|
|
61
|
+
/**
|
|
62
|
+
* Whether a ward drags, and so has grips (probe: behaviour-runes, Q14): a `drag` given as an accessor,
|
|
63
|
+
* or one that's on. The accessor first: the value is read only where there's none.
|
|
64
|
+
*/
|
|
65
|
+
const drags = (axisAt, dragRead) => {
|
|
66
|
+
if (Predicate.isNotUndefined(axisAt))
|
|
67
|
+
return true;
|
|
68
|
+
return dragAxisAt(dragRead)() !== false;
|
|
69
|
+
};
|
|
70
|
+
const NEVER = () => false;
|
|
71
|
+
const AT_ONCE = (count) => count();
|
|
72
|
+
const NO_EXIT = () => undefined;
|
|
73
|
+
const NO_TURN = () => 0;
|
|
74
|
+
/** A hold with nothing to hold: a ward no hook shows, or one not leaving. */
|
|
75
|
+
const NO_HOLD = () => constVoid;
|
|
76
|
+
const NAME = "createWard(...runes)";
|
|
77
|
+
const isPlain = (value) => Predicate.isObject(value) && !Array.isArray(value) && !Predicate.isFunction(value);
|
|
78
|
+
/**
|
|
79
|
+
* `ward` with `mounted`, `shown` and `exiting`, and its reads (`reads.ts`). A client's ward shares
|
|
80
|
+
* them with every other ({@link SHARED}) and is only told whether it's mounted and shown (`kept.ts`).
|
|
81
|
+
* A ward with no state of its own, a server's or a Stage's, is given each as a property of its
|
|
82
|
+
* own, not enumerable, so a spread never sees them.
|
|
83
|
+
*/
|
|
84
|
+
export const withMounted = (ward, mounted, shown) => {
|
|
85
|
+
if (!keepsState(ward)) {
|
|
86
|
+
return Object.defineProperties(ward, { mounted: { value: mounted }, shown: { value: shown }, exiting: { value: () => !shown() && mounted() }, hold: { value: NO_HOLD }, ...READS });
|
|
87
|
+
}
|
|
88
|
+
const kept = keptOf(ward);
|
|
89
|
+
kept.mounted = mounted;
|
|
90
|
+
kept.shown = shown;
|
|
91
|
+
return ward;
|
|
92
|
+
};
|
|
93
|
+
/** A ward's state before any `show` is wired: always shown, always there. */
|
|
94
|
+
export const showState = () => {
|
|
95
|
+
const state = {
|
|
96
|
+
shown: ALWAYS,
|
|
97
|
+
mounted: ALWAYS,
|
|
98
|
+
leaves: ALWAYS,
|
|
99
|
+
exits: ALWAYS,
|
|
100
|
+
waits: constFalse,
|
|
101
|
+
followersLanded: ALWAYS,
|
|
102
|
+
counted: AT_ONCE,
|
|
103
|
+
landed: constVoid,
|
|
104
|
+
holds: 0,
|
|
105
|
+
released: constVoid,
|
|
106
|
+
turn: NO_TURN,
|
|
107
|
+
sweeps: false,
|
|
108
|
+
affectsLayout: true,
|
|
109
|
+
mountMoves: false,
|
|
110
|
+
committed: false,
|
|
111
|
+
gone: constVoid,
|
|
112
|
+
letGo: constVoid,
|
|
113
|
+
left: constVoid,
|
|
114
|
+
ends: NEVER,
|
|
115
|
+
// Read late: `show`'s wiring gives it its `mounted`.
|
|
116
|
+
onPage: () => state.mounted(),
|
|
117
|
+
awaited: true,
|
|
118
|
+
told: undefined,
|
|
119
|
+
early: undefined,
|
|
120
|
+
};
|
|
121
|
+
return state;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Read with a ward's `shown` and `mounted`, and with what a presence says of it, where they're
|
|
125
|
+
* tracked: has what reads them told once the ward's word arrives, if it hasn't yet ({@link tell}).
|
|
126
|
+
*
|
|
127
|
+
* A ward says whether it's shown by its `show`, or by a presence that takes it, and both can come
|
|
128
|
+
* after something has read it. A function rune's body runs before its ward's config is known, and an
|
|
129
|
+
* effect or a memo made there runs at once; a presence takes a ward after `createWard` has handed it
|
|
130
|
+
* out, and after the ward's own target has read its `animate`. What read then read a ward with
|
|
131
|
+
* nothing wired, always shown, and followed nothing: it never heard the `show` or the presence that
|
|
132
|
+
* came after.
|
|
133
|
+
*
|
|
134
|
+
* So such a read follows one signal of its ward's, made at the first of them, and written at most
|
|
135
|
+
* once: as the page settles after the word has arrived, which is where Solid 2 allows the write (none
|
|
136
|
+
* while a component's body runs). The read runs again and finds what's wired by then. Nothing is
|
|
137
|
+
* made for a ward read only after its word is settled, which is every read made as it's rendered.
|
|
138
|
+
*/
|
|
139
|
+
const hearing = (state) => {
|
|
140
|
+
// A server reads as it renders, after every ward of the page is made, and nothing settles there.
|
|
141
|
+
if (isServer)
|
|
142
|
+
return;
|
|
143
|
+
if (!state.awaited)
|
|
144
|
+
return;
|
|
145
|
+
if (Predicate.isUndefined(state.told))
|
|
146
|
+
state.told = createSignal(0);
|
|
147
|
+
state.told[0]();
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Says `state`'s word has arrived, or that none ever will: reads from here on make nothing more, and
|
|
151
|
+
* whoever read before is told once the page has settled ({@link hearing}). Called under the owner
|
|
152
|
+
* the ward was made under, or the presence's.
|
|
153
|
+
*/
|
|
154
|
+
const tell = (state) => {
|
|
155
|
+
state.awaited = false;
|
|
156
|
+
const told = state.told;
|
|
157
|
+
if (isServer)
|
|
158
|
+
return;
|
|
159
|
+
if (Predicate.isUndefined(told))
|
|
160
|
+
return;
|
|
161
|
+
// Taken by a leaving row or value, nothing is settling: told now, from outside any computation.
|
|
162
|
+
if (takingLate) {
|
|
163
|
+
told[1]((turn) => turn + 1);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
// The one write, where Solid 2 has one made. `void`: what a settle returns is its cleanup.
|
|
167
|
+
onSettledClientOnly(() => void told[1]((turn) => turn + 1));
|
|
168
|
+
};
|
|
169
|
+
// Module state (#460, Q7): whether a ward is being taken late, by a leaving row or value (`takenInside`),
|
|
170
|
+
// with no component being made and nothing settling. Set and reset in one synchronous call.
|
|
171
|
+
let takingLate = false;
|
|
172
|
+
/**
|
|
173
|
+
* A `show` memo's next value from the one before: twice the changes so far, with one added while
|
|
174
|
+
* it's shown. The same value while the answer is the same, so what reads it runs again only when
|
|
175
|
+
* the answer changes. Worked out from the value before and nothing else: nothing is written from
|
|
176
|
+
* inside the memo.
|
|
177
|
+
*/
|
|
178
|
+
const countedNext = (before, shown) => {
|
|
179
|
+
if (Predicate.isUndefined(before))
|
|
180
|
+
return Number(shown);
|
|
181
|
+
const was = before % 2;
|
|
182
|
+
if (was === Number(shown))
|
|
183
|
+
return before;
|
|
184
|
+
return before - was + 2 + Number(shown);
|
|
185
|
+
};
|
|
186
|
+
/** `given` as a ward's `show` is read, through a memo: only a new answer is a change, and each one is counted. */
|
|
187
|
+
const shownBy = (given) => {
|
|
188
|
+
const counted = createMemo((before) => countedNext(before, given() === true));
|
|
189
|
+
return { show: () => counted() % 2 === 1, turns: () => (counted() - (counted() % 2)) / 2 };
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* A plain rune's `show` wired before any function rune of the ward runs, so what one reads of its
|
|
193
|
+
* ward in its own body is right from that first read: `shown()` is the memo `show`'s wiring then
|
|
194
|
+
* takes for its own ({@link showing}), and `mounted()` the same until that wiring makes its own, the
|
|
195
|
+
* two agreeing until the ward first leaves. A read made here follows the memo, runs again as `show`
|
|
196
|
+
* changes, and finds the wired `mounted` then.
|
|
197
|
+
*/
|
|
198
|
+
const showingEarly = (state, given) => {
|
|
199
|
+
const shows = shownBy(given);
|
|
200
|
+
state.early = { given, shows };
|
|
201
|
+
state.shown = shows.show;
|
|
202
|
+
state.mounted = shows.show;
|
|
203
|
+
};
|
|
204
|
+
/** The memo wired early for `given`: none where no `show` was wired early, or another was. */
|
|
205
|
+
const wiredEarlyFor = (state, given) => {
|
|
206
|
+
const early = state.early;
|
|
207
|
+
if (Predicate.isUndefined(early))
|
|
208
|
+
return undefined;
|
|
209
|
+
if (early.given !== given)
|
|
210
|
+
return undefined;
|
|
211
|
+
return early.shows;
|
|
212
|
+
};
|
|
213
|
+
/** `given` through a memo, as a ward's `show` is read: the one made early for it, where there is one. */
|
|
214
|
+
const showMemoOf = (state, given) => {
|
|
215
|
+
const early = wiredEarlyFor(state, given);
|
|
216
|
+
if (Predicate.isUndefined(early))
|
|
217
|
+
return shownBy(given);
|
|
218
|
+
return early;
|
|
219
|
+
};
|
|
220
|
+
/** Whether `on` is something on the page: a presence's value, or a `show` ward that's mounted. */
|
|
221
|
+
const isOn = (on) => Predicate.isNotUndefined(on) && on !== false;
|
|
222
|
+
/** Where a ward a hook shows keeps what brings its exits up to date, when it has no state to keep it by. */
|
|
223
|
+
const EXITS = Symbol("wardic.hooks.exits");
|
|
224
|
+
/**
|
|
225
|
+
* Something the hooks keep of `ward`: `of` what they keep of a client's (`kept.ts`), none where
|
|
226
|
+
* they've kept nothing of it; `own` for a ward with no state of its own, which carries it itself.
|
|
227
|
+
*/
|
|
228
|
+
const keptElse = (ward, of, own) => {
|
|
229
|
+
if (!keepsState(ward))
|
|
230
|
+
return own();
|
|
231
|
+
const kept = keptFor(ward);
|
|
232
|
+
if (Predicate.isUndefined(kept))
|
|
233
|
+
return undefined;
|
|
234
|
+
return of(kept);
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Tells `ward` of its own exits, as a hook shows it and takes it away: `exitStart` as it starts to
|
|
238
|
+
* leave, `exitComplete` once what was on the page has gone. They're told to the ward's lifecycle, so
|
|
239
|
+
* its own `next`, `each` and `when` hear them, a `createRune(fn)`'s ward among them, and they end as
|
|
240
|
+
* every other wait of the ward's does.
|
|
241
|
+
*
|
|
242
|
+
* - **It turned round:** shown again, with what was on the page still there. Nothing completes.
|
|
243
|
+
* - **Nowhere to leave to:** it's gone in the flush it left in, so its start and its end are told together.
|
|
244
|
+
* - **One value after another** (a presence): the first has gone as the next takes its place.
|
|
245
|
+
*
|
|
246
|
+
* One effect a ward, over `state` as it's read then: called once its `shown` and `onPage` are the ones
|
|
247
|
+
* it goes by, after a presence has given its own. Throwaway: a real one tells them from the leave it
|
|
248
|
+
* already tracks, with no effect of its own.
|
|
249
|
+
*/
|
|
250
|
+
export const tellingExits = (ward, state) => {
|
|
251
|
+
const settle = exitsOf(ward);
|
|
252
|
+
const seen = () => ({ shown: state.shown(), on: state.onPage() });
|
|
253
|
+
createEffect(seen, settle);
|
|
254
|
+
exitsBy(ward, () => settle(untrack(seen)));
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* What tells `ward` of its own exits, given where it is each time it's shown, hidden or gone
|
|
258
|
+
* ({@link tellingExits}'s rules). With no effect of its own: {@link tellingExits} gives it one, and a
|
|
259
|
+
* ward with a `show` of its own has it called from the one its place in the layout has ({@link popping}).
|
|
260
|
+
*/
|
|
261
|
+
const exitsOf = (ward) => {
|
|
262
|
+
const sensed = sensedOf(ward);
|
|
263
|
+
let was;
|
|
264
|
+
let leaving = false;
|
|
265
|
+
const tell = (name) => {
|
|
266
|
+
// A server's ward has no lifecycle, and nothing leaves there.
|
|
267
|
+
if (Predicate.isUndefined(sensed))
|
|
268
|
+
return;
|
|
269
|
+
sensed.lifecycle.exited(name);
|
|
270
|
+
};
|
|
271
|
+
const settle = (now) => {
|
|
272
|
+
const before = was;
|
|
273
|
+
was = now;
|
|
274
|
+
const leavingNow = !now.shown && isOn(now.on);
|
|
275
|
+
// Its first run: where it starts from, with nothing to tell.
|
|
276
|
+
if (Predicate.isUndefined(before)) {
|
|
277
|
+
leaving = leavingNow;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
// What was on the page has gone: its exit is complete, begun just now if it had nowhere to leave to.
|
|
281
|
+
if (now.on !== before.on && isOn(before.on)) {
|
|
282
|
+
if (!leaving)
|
|
283
|
+
tell("exitStart");
|
|
284
|
+
leaving = false;
|
|
285
|
+
tell("exitComplete");
|
|
286
|
+
}
|
|
287
|
+
if (leavingNow && !leaving)
|
|
288
|
+
tell("exitStart");
|
|
289
|
+
leaving = leavingNow;
|
|
290
|
+
};
|
|
291
|
+
return settle;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Keeps `sync` as what brings `ward`'s exits up to date now ({@link exitsNow}): of a client's ward
|
|
295
|
+
* (`kept.ts`); its own property on one with no state to keep it by, not enumerable, so a spread
|
|
296
|
+
* never sees it.
|
|
297
|
+
*/
|
|
298
|
+
const exitsBy = (ward, sync) => {
|
|
299
|
+
if (keepsState(ward)) {
|
|
300
|
+
keptOf(ward).exits = sync;
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
Object.defineProperty(ward, EXITS, { value: sync });
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Brings `ward`'s exits up to date now, where it's about to be ended: a list's row is disposed in the
|
|
307
|
+
* flush its exit lands in, and its end is told first. Nothing for a ward whose exits aren't told.
|
|
308
|
+
*/
|
|
309
|
+
export const exitsNow = (ward) => {
|
|
310
|
+
const sync = keptElse(ward, (kept) => kept.exits, () => ward[EXITS]);
|
|
311
|
+
if (Predicate.isUndefined(sync))
|
|
312
|
+
return;
|
|
313
|
+
sync();
|
|
314
|
+
};
|
|
315
|
+
/** The leave a `show` ward's exit counts as landed in as it's made: none yet for one shown, the first for one hidden. */
|
|
316
|
+
const exitedAtFirst = (shown) => {
|
|
317
|
+
if (shown)
|
|
318
|
+
return -1;
|
|
319
|
+
return 0;
|
|
320
|
+
};
|
|
321
|
+
/** The wiring of `show` over `runes`, and its state in `state`; none without a `show`. */
|
|
322
|
+
export const showing = (state) => (runes) => {
|
|
323
|
+
const given = runes.show;
|
|
324
|
+
if (Predicate.isUndefined(given))
|
|
325
|
+
return undefined;
|
|
326
|
+
// Its value, through a memo: an accessor such as `() => open().has(id)` runs again whenever what
|
|
327
|
+
// it reads changes, with the same answer most times, and only a new answer is a change here.
|
|
328
|
+
// The memo made early for it, where a function rune ran before this (`showingEarly`).
|
|
329
|
+
const shows = showMemoOf(state, given);
|
|
330
|
+
const show = shows.show;
|
|
331
|
+
state.shown = show;
|
|
332
|
+
// `show`'s changes so far, and each exit records the count it landed in: a later change of `show`
|
|
333
|
+
// makes an earlier landing stale with nothing to reset (as @solid-primitives/presence does).
|
|
334
|
+
const turnsNow = () => untrack(shows.turns);
|
|
335
|
+
// Written as its exit lands: from an effect's callback, or a frame or a handover's end after it.
|
|
336
|
+
const [exitedIn, setExitedIn] = createSignal(exitedAtFirst(untrack(show)));
|
|
337
|
+
/** Where it goes to leave: its `exit`, else its `initial`; none with `exit: false`, or with neither. */
|
|
338
|
+
const exit = () => {
|
|
339
|
+
const own = runes.value("exit");
|
|
340
|
+
if (own === false)
|
|
341
|
+
return undefined;
|
|
342
|
+
if (Predicate.isNotUndefined(own))
|
|
343
|
+
return own;
|
|
344
|
+
const initial = runes.value("initial");
|
|
345
|
+
if (initial === false)
|
|
346
|
+
return undefined;
|
|
347
|
+
return initial;
|
|
348
|
+
};
|
|
349
|
+
/** Where it rests while hidden, to enter from: its `initial`, at once, when its `exit` went elsewhere. */
|
|
350
|
+
const rest = (leaving) => {
|
|
351
|
+
if (Predicate.isUndefined(runes.value("exit")))
|
|
352
|
+
return leaving;
|
|
353
|
+
const initial = runes.value("initial");
|
|
354
|
+
if (isPlain(initial))
|
|
355
|
+
return { ...initial, transition: { duration: 0 } };
|
|
356
|
+
if (Predicate.isUndefined(initial) || initial === false)
|
|
357
|
+
return leaving;
|
|
358
|
+
return initial;
|
|
359
|
+
};
|
|
360
|
+
const exits = () => Predicate.isNotUndefined(exit());
|
|
361
|
+
// With no exit of its own, whether what's inside it or following it holds it, asked as it's
|
|
362
|
+
// hidden, of the page as it is then: untracked, a plain walk, with nothing written.
|
|
363
|
+
const waits = () => untrack(state.waits);
|
|
364
|
+
const mounted = createMemo(() => {
|
|
365
|
+
if (show())
|
|
366
|
+
return true;
|
|
367
|
+
if (!exits() && !waits())
|
|
368
|
+
return false;
|
|
369
|
+
if (exitedIn() !== shows.turns())
|
|
370
|
+
return true;
|
|
371
|
+
return !state.followersLanded();
|
|
372
|
+
});
|
|
373
|
+
state.mounted = mounted;
|
|
374
|
+
state.turn = turnsNow;
|
|
375
|
+
state.exits = exits;
|
|
376
|
+
state.leaves = () => exits() || waits();
|
|
377
|
+
// The change of `show` its exit last landed in: it's gone once that's this one, and nothing holds it.
|
|
378
|
+
let landedIn = -1;
|
|
379
|
+
const finish = () => {
|
|
380
|
+
if (untrack(show))
|
|
381
|
+
return;
|
|
382
|
+
const now = turnsNow();
|
|
383
|
+
if (landedIn !== now)
|
|
384
|
+
return;
|
|
385
|
+
if (state.holds > 0)
|
|
386
|
+
return;
|
|
387
|
+
setExitedIn(now);
|
|
388
|
+
// Read as it's told: a presence that took the ward says what follows, in this same write.
|
|
389
|
+
state.gone();
|
|
390
|
+
};
|
|
391
|
+
state.landed = () => {
|
|
392
|
+
if (untrack(show))
|
|
393
|
+
return;
|
|
394
|
+
landedIn = turnsNow();
|
|
395
|
+
// A leader's landing counts a frame on. One with nothing of its own to animate lands as it's told
|
|
396
|
+
// to leave, in the flush its followers are told in, before any of them reads as moving: counted
|
|
397
|
+
// then, it was gone with its followers' exits not yet begun, some runs and not others.
|
|
398
|
+
state.counted(finish);
|
|
399
|
+
};
|
|
400
|
+
state.released = finish;
|
|
401
|
+
return {
|
|
402
|
+
animate: (shown) => {
|
|
403
|
+
if (show())
|
|
404
|
+
return shown;
|
|
405
|
+
const leaving = exit();
|
|
406
|
+
if (Predicate.isUndefined(leaving))
|
|
407
|
+
return shown;
|
|
408
|
+
// A ward that ends as it goes has nowhere to rest: it stays where it left to, and whether
|
|
409
|
+
// it's mounted isn't read for it, so nothing is worked out again as it goes.
|
|
410
|
+
if (state.ends())
|
|
411
|
+
return leaving;
|
|
412
|
+
if (mounted())
|
|
413
|
+
return leaving;
|
|
414
|
+
return rest(leaving);
|
|
415
|
+
},
|
|
416
|
+
style: (style) => {
|
|
417
|
+
// Nor is it hidden: it's off the page in the flush it goes in.
|
|
418
|
+
if (state.ends())
|
|
419
|
+
return style;
|
|
420
|
+
if (mounted())
|
|
421
|
+
return style;
|
|
422
|
+
if (Predicate.isString(style))
|
|
423
|
+
return `${style};display:none`;
|
|
424
|
+
if (isPlain(style))
|
|
425
|
+
return { ...style, display: "none" };
|
|
426
|
+
return { display: "none" };
|
|
427
|
+
},
|
|
428
|
+
// Its exit is this wiring's to run, through `animate` above: none is left in the ward's own config.
|
|
429
|
+
exit: NO_EXIT,
|
|
430
|
+
custom: customAtLeave(runes, show),
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* `custom` as a ward that leaves reads it: the runes' own while it's shown, and the one it started to
|
|
435
|
+
* leave with from then until it's shown again. None for a ward whose runes give no `custom`.
|
|
436
|
+
*
|
|
437
|
+
* A presence reads its `custom` as each child leaves, since a child that has left takes nothing new.
|
|
438
|
+
* A hook's ward is still there as it leaves, and went on reading: a photo sliding off to the left
|
|
439
|
+
* turned back across the stage when the next change went the other way.
|
|
440
|
+
*/
|
|
441
|
+
const customAtLeave = (runes, show) => {
|
|
442
|
+
if (!runes.has("custom"))
|
|
443
|
+
return undefined;
|
|
444
|
+
// Made again only as `show` changes: read once as it starts to leave, and not followed after.
|
|
445
|
+
const leftWith = createMemo(() => {
|
|
446
|
+
if (show())
|
|
447
|
+
return undefined;
|
|
448
|
+
return untrack(() => runes.value("custom"));
|
|
449
|
+
});
|
|
450
|
+
return (own) => {
|
|
451
|
+
if (show())
|
|
452
|
+
return own();
|
|
453
|
+
return leftWith();
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
/** The layout projection told that what's on the page has changed. */
|
|
457
|
+
const notified = (projection) => projection.notify();
|
|
458
|
+
/** Where a list measured a row before the change, asked now. */
|
|
459
|
+
const boxNow = (box) => box();
|
|
460
|
+
/** What `pin` sets on a popped element, taken off again when it comes back or has gone. */
|
|
461
|
+
const PINNED = ["position", "width", "height", "top", "bottom", "left", "right", "pointer-events"];
|
|
462
|
+
/** A popped element back in the flow: every property its pin set, removed. */
|
|
463
|
+
const unpin = (el) => Arr.forEach(PINNED, (property) => void el.style.removeProperty(property));
|
|
464
|
+
/** The edges a `pop` pins by, a ward's or a `<Presence>`'s: its top left for `true`, the corner it names, and none without one. */
|
|
465
|
+
export const popAnchorsOf = (pop) => {
|
|
466
|
+
if (pop === true || pop === "top-left")
|
|
467
|
+
return { x: "left", y: "top" };
|
|
468
|
+
if (pop === "top-right")
|
|
469
|
+
return { x: "right", y: "top" };
|
|
470
|
+
if (pop === "bottom-left")
|
|
471
|
+
return { x: "left", y: "bottom" };
|
|
472
|
+
if (pop === "bottom-right")
|
|
473
|
+
return { x: "right", y: "bottom" };
|
|
474
|
+
return undefined;
|
|
475
|
+
};
|
|
476
|
+
// Module state (#460, Q7): each popping ward's anchors, held weakly by the ward, for a list to measure it by.
|
|
477
|
+
const POPS = new WeakMap();
|
|
478
|
+
// Module state (#460, Q7): each hook ward that has a `layoutId`, kept while its owner lives. A leaving ward finds the twins inside its own element among them.
|
|
479
|
+
const TWINS = new Set();
|
|
480
|
+
// Module state (#460, Q7): each twin's ward, held weakly. A leaving row leaves it to its own way of
|
|
481
|
+
// leaving (Q20): its handback.
|
|
482
|
+
const TWIN_WARDS = new WeakSet();
|
|
483
|
+
// Module state (#460, Q7): each ward that follows another, held weakly. A leaving row leaves it to its
|
|
484
|
+
// own way of leaving (Q20): its leader's.
|
|
485
|
+
const FOLLOWING = new WeakSet();
|
|
486
|
+
// Module state (#460, Q7; the gap grill's Q20): the ward each element was last handed to, held weakly by
|
|
487
|
+
// the element. Kept by the hooks alone (the code review of the gap grill's work): a component's ward isn't told.
|
|
488
|
+
const WARD_ON = new WeakMap();
|
|
489
|
+
// Module state (#460, Q7; the code review of the gap grill's work): the presence each hook ward was made
|
|
490
|
+
// under, held weakly by the ward, kept only for one made under a presence.
|
|
491
|
+
const PRESENCE_ON = new WeakMap();
|
|
492
|
+
/** The ward `el` was last handed to, if the hooks made it: how a leaving row or presence value finds the wards inside its element (Q20). */
|
|
493
|
+
const wardOn = (el) => WARD_ON.get(el);
|
|
494
|
+
/** The presence `ward` was made under, if any: what it watches its child's leave by ({@link watchedUnder}). */
|
|
495
|
+
const presenceOn = (ward) => PRESENCE_ON.get(ward);
|
|
496
|
+
// Module state (#460, Q7; the gap grill's Q29): in development, each hook ward whose `style` an element's
|
|
497
|
+
// props have read, held weakly. Nothing is added to it in a production build.
|
|
498
|
+
const STYLE_READ = new WeakSet();
|
|
499
|
+
// Module state (#460, Q7; the gap grill's Q29, DW4): in development, each hook ward its `ref` has handed an
|
|
500
|
+
// element, as it's handed it, held weakly: what the warning below goes by. Its element itself is a signal's,
|
|
501
|
+
// and a hydration's writes land only after the ward's owner has settled. Nothing is added in a production build.
|
|
502
|
+
const HANDED = new WeakSet();
|
|
503
|
+
/**
|
|
504
|
+
* What every ward the hooks make tells them, through its internals: each element it's handed, the
|
|
505
|
+
* presence it's made under, and, in development, that an element's props read its `style`. And what it
|
|
506
|
+
* tells the base ward: it carries its variants whatever its runes set (the follow grill's Q1), so a ward
|
|
507
|
+
* that follows it joins it however it names its states. One object, shared by every hook ward's internals.
|
|
508
|
+
*/
|
|
509
|
+
export const HOOK_TOLD = {
|
|
510
|
+
handed: (element, ward) => {
|
|
511
|
+
WARD_ON.set(element, ward);
|
|
512
|
+
if (DEV)
|
|
513
|
+
HANDED.add(ward);
|
|
514
|
+
},
|
|
515
|
+
madeUnder: (ward, presence) => void PRESENCE_ON.set(ward, presence),
|
|
516
|
+
styled: (ward) => void STYLE_READ.add(ward),
|
|
517
|
+
carries: true,
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* In development, a warning for a ward spread on a component that never calls its `ref` (the gap
|
|
521
|
+
* grill's Q29): an element's props read its `style`, so it was spread, and its `ref` hasn't been handed
|
|
522
|
+
* an element by the time its owner has settled. Asked of the `ref` itself, not of the element it set: a
|
|
523
|
+
* hydrated page's writes, that one's among them, land after its owners settle (DW4). Today's
|
|
524
|
+
* `create(Component)` fails such a component; a hook ward spread on it would otherwise move nothing, and
|
|
525
|
+
* say nothing. One whose `style` no element has read yet, a closed dialog's, isn't warned of. And the other
|
|
526
|
+
* way round (step 2 of the skill grill's order, Q20): its `ref` handed an element whose props read none of its
|
|
527
|
+
* `style`, a `style` beside the spread having replaced it. Nothing on a server, where no `ref` is called.
|
|
528
|
+
*/
|
|
529
|
+
const warnsOfItsSpread = (ward) => {
|
|
530
|
+
if (Predicate.isNull(getOwner()))
|
|
531
|
+
return;
|
|
532
|
+
onSettledClientOnly(() => {
|
|
533
|
+
const read = STYLE_READ.has(ward);
|
|
534
|
+
const handed = HANDED.has(ward);
|
|
535
|
+
if (Bool.and(read, Bool.not(handed)))
|
|
536
|
+
report("WARDIC_REF_NOT_CALLED", UNFORWARDED);
|
|
537
|
+
// Its `ref` called and its `style` read by nothing: a `style` beside the spread replaced it (step 2, Q20).
|
|
538
|
+
if (Bool.and(handed, Bool.not(read)))
|
|
539
|
+
report("WARDIC_STYLE_BESIDE_SPREAD", STYLE_BESIDE);
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
/** `ward`, made, with the warnings above for it in development, in a browser: every hook ward's make path ends here. */
|
|
543
|
+
const checked = (ward) => {
|
|
544
|
+
if (DEV && !isServer)
|
|
545
|
+
warnsOfItsSpread(ward);
|
|
546
|
+
return ward;
|
|
547
|
+
};
|
|
548
|
+
const STYLE_BESIDE = "createWard: the ward's `style` was replaced: a `style` beside its spread (`<div {...ward} style={…}>`), or a component that doesn't pass `props.style` on. Give the style through the ward, `{...ward.with({ style })}`, or as its own `style`.";
|
|
549
|
+
const UNFORWARDED = "createWard: a ward was spread on a component that never called its `ref`, so no element is its and nothing it says will move. The component must pass `props.ref` to the element it renders (`<div ref={props.ref}>`), or spread its props on that element whole.";
|
|
550
|
+
// Module state (#460, Q7): each leader's followers, held weakly by the leader, each one dropped as its
|
|
551
|
+
// owner ends. What a leader that leaves takes with it (the gap grill's Q12).
|
|
552
|
+
const FOLLOWERS = new WeakMap();
|
|
553
|
+
/** Notes `follower` as one of `leader`'s, until the owner it's made under ends. */
|
|
554
|
+
const followsOf = (leader, follower) => {
|
|
555
|
+
let all = FOLLOWERS.get(leader);
|
|
556
|
+
if (Predicate.isUndefined(all)) {
|
|
557
|
+
all = new Set();
|
|
558
|
+
FOLLOWERS.set(leader, all);
|
|
559
|
+
}
|
|
560
|
+
const kept = all;
|
|
561
|
+
kept.add(follower);
|
|
562
|
+
if (Predicate.isNotNull(getOwner()))
|
|
563
|
+
onCleanup(() => void kept.delete(follower));
|
|
564
|
+
};
|
|
565
|
+
/** Whether any of a ward's configs gives it a `layoutId`: a twin, which a leaving ward that holds it hands to its other. */
|
|
566
|
+
const hasLayoutId = (configs) => Arr.some(configs, (config) => "layoutId" in config);
|
|
567
|
+
/** The element `ward` is on now, read once and not followed. */
|
|
568
|
+
const elementOf = (ward) => {
|
|
569
|
+
const sensed = sensedOf(ward);
|
|
570
|
+
if (Predicate.isUndefined(sensed))
|
|
571
|
+
return undefined;
|
|
572
|
+
return untrack(() => sensed.element());
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* The element `ward` is on while it's on show, followed: none while it's hidden or gone, by
|
|
576
|
+
* `mounted`, the same element again once it's shown again, and another as the ward moves to one. What
|
|
577
|
+
* its runes' `ref`s go by (`refs.ts`).
|
|
578
|
+
*/
|
|
579
|
+
const elementOnShow = (ward, mounted) => () => {
|
|
580
|
+
if (!mounted())
|
|
581
|
+
return undefined;
|
|
582
|
+
const sensed = sensedOf(ward);
|
|
583
|
+
if (Predicate.isUndefined(sensed))
|
|
584
|
+
return undefined;
|
|
585
|
+
return sensed.element();
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* `refs` at work on `ward` (`refs.ts`): each handed the element it's on while `mounted` says that's on
|
|
589
|
+
* show. A `show` ward's, a ward's a presence took before it was on the page, and one's a presence takes
|
|
590
|
+
* after ({@link refsTaken}).
|
|
591
|
+
*
|
|
592
|
+
* Begun once the page has settled, where Solid has what needs an element on the page begin
|
|
593
|
+
* (`onSettled`), under the owner the ward was made under. Not as the ward is made: a presence gives a
|
|
594
|
+
* ward a `mounted` of its own after that, later in the same component's body, and what followed the
|
|
595
|
+
* first one had nothing to read the next by. A ward given its element as its `subject` and then
|
|
596
|
+
* taken by a presence was never undone. A signal written as the ward is taken had it read again,
|
|
597
|
+
* and was a write in a component's body, which Solid 2 doesn't allow; begun at the settle, the
|
|
598
|
+
* `mounted` it reads is already the one the ward goes by, and nothing is written.
|
|
599
|
+
*/
|
|
600
|
+
const refsAtWork = (refs, ward, mounted) => {
|
|
601
|
+
const owner = getOwner();
|
|
602
|
+
onSettledClientOnly(() => {
|
|
603
|
+
runWithOwner(owner, () => attending(refs, elementOnShow(ward, mounted), Option.none()));
|
|
604
|
+
});
|
|
605
|
+
};
|
|
606
|
+
/** Its runes' `ref`s, where it has any: none on a server, where nothing is on show. */
|
|
607
|
+
const refsIn = (seen, configs) => {
|
|
608
|
+
if (isServer)
|
|
609
|
+
return undefined;
|
|
610
|
+
if (!sawOf(seen, SEEN.ref))
|
|
611
|
+
return undefined;
|
|
612
|
+
const refs = runeRefsOf(configs);
|
|
613
|
+
if (Arr.isReadonlyArrayEmpty(refs))
|
|
614
|
+
return undefined;
|
|
615
|
+
return refs;
|
|
616
|
+
};
|
|
617
|
+
/**
|
|
618
|
+
* `refs` for its binding to run, none run yet: a ward's with no `show` (the cheap `ref`). None for a
|
|
619
|
+
* ward with none, or with a `show`, whose `refs` go by it ({@link refsAtWork}).
|
|
620
|
+
*/
|
|
621
|
+
const mountedRefsFor = (refs, show, mounted) => {
|
|
622
|
+
if (Predicate.isUndefined(refs))
|
|
623
|
+
return undefined;
|
|
624
|
+
if (Predicate.isNotUndefined(show))
|
|
625
|
+
return undefined;
|
|
626
|
+
return { refs, mounted, owner: null, attended: undefined, taken: false };
|
|
627
|
+
};
|
|
628
|
+
/** What the binding tells of each element it mounts (`afterMount`): `at`'s refs run on it, and undone as it goes. */
|
|
629
|
+
const afterMountOf = (at) => (element) => {
|
|
630
|
+
if (at.taken)
|
|
631
|
+
return constVoid;
|
|
632
|
+
const attended = { subject: element, undo: refsRun(at.refs, element) };
|
|
633
|
+
at.attended = attended;
|
|
634
|
+
return () => {
|
|
635
|
+
// Handed to a presence's word since: that undoes them now.
|
|
636
|
+
if (at.attended !== attended)
|
|
637
|
+
return;
|
|
638
|
+
at.attended = undefined;
|
|
639
|
+
attended.undo();
|
|
640
|
+
};
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* `ward`, whose refs `at` are, taken by a presence: they go by that presence's word from now, as a
|
|
644
|
+
* `show` ward's do. Once: a presence takes a ward once (`takenOf`, `takenLate`).
|
|
645
|
+
*/
|
|
646
|
+
const refsTaken = (at, ward) => {
|
|
647
|
+
at.taken = true;
|
|
648
|
+
const attended = at.attended;
|
|
649
|
+
at.attended = undefined;
|
|
650
|
+
runWithOwner(at.owner, () => refsByPresence(at, ward, attended));
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* Where `at`'s refs go by its presence's word from: on an element already, they're handed over as they
|
|
654
|
+
* are, not run again there, and undone once it says the element has gone. On none, taken before its
|
|
655
|
+
* binding mounted anything (`createPresence` in the body that made it), they begin at the settle, as a
|
|
656
|
+
* `show` ward's; taken late, as nothing settles (a leaving row's, held as its mount was), at once.
|
|
657
|
+
*/
|
|
658
|
+
const refsByPresence = (at, ward, attended) => UndefinedOr.match(attended, {
|
|
659
|
+
onDefined: (already) => attending(at.refs, elementOnShow(ward, at.mounted), Option.some(already)),
|
|
660
|
+
onUndefined: () => Bool.match(takingLate, {
|
|
661
|
+
onTrue: () => attending(at.refs, elementOnShow(ward, at.mounted), Option.none()),
|
|
662
|
+
onFalse: () => refsAtWork(at.refs, ward, at.mounted),
|
|
663
|
+
}),
|
|
664
|
+
});
|
|
665
|
+
/**
|
|
666
|
+
* A twin's ward, made by `make` under a root of its own, so a leaving ward that holds it can end it
|
|
667
|
+
* while its element stays: what a framework does to a presence's leaving child, before the presence
|
|
668
|
+
* hands that child's twins back. Its root ends with the owner it's made under, if not sooner.
|
|
669
|
+
*
|
|
670
|
+
* The root is made on a server as in a browser, so both count the same hydration ids; only a browser
|
|
671
|
+
* keeps it among the twins, since nothing leaves on a server.
|
|
672
|
+
*/
|
|
673
|
+
const twinOf = (make) => {
|
|
674
|
+
let dispose = constVoid;
|
|
675
|
+
const ward = createRoot((end) => {
|
|
676
|
+
dispose = end;
|
|
677
|
+
return make();
|
|
678
|
+
});
|
|
679
|
+
// Handed home as a leaving ward starts to leave: not one a leaving row takes as well (Q20).
|
|
680
|
+
TWIN_WARDS.add(ward);
|
|
681
|
+
let ended = false;
|
|
682
|
+
const twin = {
|
|
683
|
+
element: () => elementOf(ward),
|
|
684
|
+
end: () => {
|
|
685
|
+
if (ended)
|
|
686
|
+
return;
|
|
687
|
+
ended = true;
|
|
688
|
+
TWINS.delete(twin);
|
|
689
|
+
dispose();
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
if (!isServer)
|
|
693
|
+
TWINS.add(twin);
|
|
694
|
+
onCleanup(twin.end);
|
|
695
|
+
return ward;
|
|
696
|
+
};
|
|
697
|
+
const NOT_ONE_ELEMENT = "createWard(...runes): its `subject` on the page is one element, or what resolves to one. Give it an element of its own, or spread the ward on one.";
|
|
698
|
+
const isHtmlElement = (node) => node instanceof HTMLElement;
|
|
699
|
+
const isSvgElement = (node) => node instanceof SVGElement;
|
|
700
|
+
/** Whether `node` is an element a ward moves: an HTML element, or an SVG one (the gap grill's Q23). */
|
|
701
|
+
const isWardElement = /*#__PURE__*/ Predicate.or(isHtmlElement, isSvgElement);
|
|
702
|
+
/** The one element `subject` is: itself, an accessor's, or the only one among a resolved child's nodes. */
|
|
703
|
+
const elementIn = (subject) => {
|
|
704
|
+
if (isWardElement(subject))
|
|
705
|
+
return subject;
|
|
706
|
+
if (Predicate.isFunction(subject))
|
|
707
|
+
return elementIn(untrack(subject));
|
|
708
|
+
if (!Array.isArray(subject))
|
|
709
|
+
return undefined;
|
|
710
|
+
const elements = Arr.filter(subject, isWardElement);
|
|
711
|
+
if (elements.length !== 1)
|
|
712
|
+
return undefined;
|
|
713
|
+
return elements[0];
|
|
714
|
+
};
|
|
715
|
+
/**
|
|
716
|
+
* The Subject a ward is given (a rune's `subject`), as the one element it is, found as the ward is made,
|
|
717
|
+
* before the base ward is: so an SVG element's own tag routes its keys from its first frame (Q23). In a
|
|
718
|
+
* browser alone: a server's markup is whoever rendered it.
|
|
719
|
+
*/
|
|
720
|
+
const subjectElementOf = (subject) => {
|
|
721
|
+
const el = elementIn(subject);
|
|
722
|
+
if (Predicate.isUndefined(el))
|
|
723
|
+
throw misuse("WARDIC_SUBJECT_NOT_ONE_ELEMENT", NOT_ONE_ELEMENT);
|
|
724
|
+
return el;
|
|
725
|
+
};
|
|
726
|
+
/** `internal` with `el`'s own tag where it's an SVG element, whose attribute keys render as attributes: as it is for an HTML one. */
|
|
727
|
+
const elementTagged = (internal, el) => {
|
|
728
|
+
if (!(el instanceof SVGElement))
|
|
729
|
+
return internal;
|
|
730
|
+
return { ...internal, tag: el.localName };
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* `ward` put on the Subject it's given (a rune's `subject`): an element the hooks' caller didn't spread
|
|
734
|
+
* it on, another's to render, as a router's page is its layout's to move. What a spread of the ward on
|
|
735
|
+
* that element does, its `ref`, its `style` and its attributes, is done here.
|
|
736
|
+
*
|
|
737
|
+
* In a browser alone. A server's markup is whoever rendered the element's, so a ward given its Subject
|
|
738
|
+
* has no Starting style there: what's on the page as it opens should have no entrance (`enter: false`,
|
|
739
|
+
* or a list's `initial: false`).
|
|
740
|
+
*
|
|
741
|
+
* But for `propKeys`, the names its runes' `props` set there: those the hooks write themselves
|
|
742
|
+
* (`settingOn`, `props.ts`), a spread writing no attribute on a server's element as the page
|
|
743
|
+
* hydrates, and the element getting back what it had under each once the ward's owner ends.
|
|
744
|
+
*/
|
|
745
|
+
const putOn = (ward, el, propKeys) => {
|
|
746
|
+
settingOn(el, propKeys);
|
|
747
|
+
spread(el, ward, true, isOneOf(propKeys));
|
|
748
|
+
};
|
|
749
|
+
/**
|
|
750
|
+
* Whether a pass over a ward's runes saw `what` among them (`SEEN`, `rune.ts`). Yes where there was
|
|
751
|
+
* no such pass, for runes that are joined: it's to be looked for then, as it was.
|
|
752
|
+
*/
|
|
753
|
+
const sawOf = (seen, what) => {
|
|
754
|
+
if (Predicate.isUndefined(seen))
|
|
755
|
+
return true;
|
|
756
|
+
return (seen & what) !== 0;
|
|
757
|
+
};
|
|
758
|
+
/** No rune's `props`: most wards'. */
|
|
759
|
+
const NO_PROP_KEYS = {};
|
|
760
|
+
/** `make`'s ward: a twin's under its own root, when any of `configs` gives it a `layoutId`, which `seen` says where it's known. */
|
|
761
|
+
const wardFor = (configs, make, seen) => {
|
|
762
|
+
if (!sawOf(seen, SEEN.layoutId))
|
|
763
|
+
return make();
|
|
764
|
+
if (hasLayoutId(configs))
|
|
765
|
+
return twinOf(make);
|
|
766
|
+
return make();
|
|
767
|
+
};
|
|
768
|
+
/** Whether `twin`'s element is inside `el`, and not `el` itself. */
|
|
769
|
+
const within = (el) => (twin) => {
|
|
770
|
+
const other = twin.element();
|
|
771
|
+
if (Predicate.isUndefined(other))
|
|
772
|
+
return false;
|
|
773
|
+
if (other === el)
|
|
774
|
+
return false;
|
|
775
|
+
return el.contains(other);
|
|
776
|
+
};
|
|
777
|
+
/** The edges `ward` is pinned by as it leaves, when it pops: what `createWards` measures a leaving row with. */
|
|
778
|
+
export const popAnchorsFor = (ward) => POPS.get(ward);
|
|
779
|
+
// Module state (#460, Q7): the wards leaving in this flush, popped together once its effects have run.
|
|
780
|
+
const leavingNow = [];
|
|
781
|
+
/**
|
|
782
|
+
* Pops every ward that asked in this flush, in two passes: each one measured where it is, then each
|
|
783
|
+
* one pinned. One at a time, a pin takes its ward out of the flow before the next is measured, which
|
|
784
|
+
* then reads as having moved into its place: several leaving together all ended where the first was.
|
|
785
|
+
*/
|
|
786
|
+
const popAll = () => {
|
|
787
|
+
const pops = leavingNow.splice(0);
|
|
788
|
+
const boxes = pops.map((pop) => popBoxOf(pop.el, pop.anchors, undefined));
|
|
789
|
+
pops.forEach((pop, at) => {
|
|
790
|
+
pop.pinAt(boxes[at]);
|
|
791
|
+
pop.told();
|
|
792
|
+
});
|
|
793
|
+
};
|
|
794
|
+
/** `pop`, with whatever else leaves in this flush: after its effects, before the browser paints. */
|
|
795
|
+
const popTogether = (pop) => {
|
|
796
|
+
if (leavingNow.length === 0)
|
|
797
|
+
queueMicrotask(popAll);
|
|
798
|
+
leavingNow.push(pop);
|
|
799
|
+
};
|
|
800
|
+
/**
|
|
801
|
+
* A `show` ward's place in the layout: popped out of the flow as it starts to leave, when its `pop`
|
|
802
|
+
* says so, and the layout projection told as it comes, pops and goes (a presence tells it the same,
|
|
803
|
+
* `PresenceController`'s `projection.notify()`). Nothing with no `layout` Feature built, or on a server.
|
|
804
|
+
*/
|
|
805
|
+
const popping = (ward, made, state, exits) => {
|
|
806
|
+
if (Predicate.isUndefined(made.show))
|
|
807
|
+
return;
|
|
808
|
+
const show = state.shown;
|
|
809
|
+
const mounted = state.mounted;
|
|
810
|
+
const projection = useBuiltProjection();
|
|
811
|
+
const anchors = popAnchorsOf(made.own("pop"));
|
|
812
|
+
if (Predicate.isNotUndefined(anchors))
|
|
813
|
+
POPS.set(ward, anchors);
|
|
814
|
+
state.waits = () => waitsAsItLeaves(ward, state);
|
|
815
|
+
// What it does as it's hidden, shown again, gone or let go, made the first time one of those
|
|
816
|
+
// happens: a ward that only ever mounts makes none of it. Every `show` ward made all of it as it
|
|
817
|
+
// was wired, a dozen closures a ward, a list's row among them.
|
|
818
|
+
let done;
|
|
819
|
+
const popped = () => {
|
|
820
|
+
if (Predicate.isNotUndefined(done))
|
|
821
|
+
return done;
|
|
822
|
+
const now = poppedOf(ward, made, state, show, projection, anchors);
|
|
823
|
+
done = now;
|
|
824
|
+
return now;
|
|
825
|
+
};
|
|
826
|
+
onCleanup(() => {
|
|
827
|
+
if (Predicate.isNotUndefined(done))
|
|
828
|
+
done.ended();
|
|
829
|
+
});
|
|
830
|
+
state.letGo = () => popped().letGo();
|
|
831
|
+
let wasShown;
|
|
832
|
+
const shownIs = (shown) => {
|
|
833
|
+
const before = wasShown;
|
|
834
|
+
wasShown = shown;
|
|
835
|
+
// Its first run is its mount, which a `layout` node of its own measures as it registers. A row that
|
|
836
|
+
// comes after its list's first pushes what's after it, which nothing else would tell the projection.
|
|
837
|
+
if (Predicate.isUndefined(before)) {
|
|
838
|
+
if (shown && state.mountMoves && state.affectsLayout) {
|
|
839
|
+
const system = projection();
|
|
840
|
+
if (Predicate.isNotUndefined(system))
|
|
841
|
+
system.notify();
|
|
842
|
+
}
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
if (before === shown)
|
|
846
|
+
return;
|
|
847
|
+
popped().shown(shown);
|
|
848
|
+
};
|
|
849
|
+
let wasMounted = untrack(mounted);
|
|
850
|
+
/** Whether it has just gone. */
|
|
851
|
+
const mountedIs = (now) => {
|
|
852
|
+
if (now === wasMounted)
|
|
853
|
+
return false;
|
|
854
|
+
wasMounted = now;
|
|
855
|
+
if (now)
|
|
856
|
+
return false;
|
|
857
|
+
popped().gone();
|
|
858
|
+
return true;
|
|
859
|
+
};
|
|
860
|
+
// One effect for whether it's shown and whether it's mounted, where there were two, and its exits
|
|
861
|
+
// told from it too where they go by the same two (`exits`: a ward with a `show` of its own, a
|
|
862
|
+
// list's row), where that was a third. In the order the three ran in: shown, mounted, its exits.
|
|
863
|
+
createEffect(() => Number(show()) + 2 * Number(mounted()), (now) => {
|
|
864
|
+
const shown = now % 2 === 1;
|
|
865
|
+
const on = now >= 2;
|
|
866
|
+
shownIs(shown);
|
|
867
|
+
const went = mountedIs(on);
|
|
868
|
+
if (Predicate.isNotUndefined(exits))
|
|
869
|
+
exits({ shown, on });
|
|
870
|
+
// Last, as a list's own effect over its row came last: its row is dropped, and its ward ended.
|
|
871
|
+
if (went)
|
|
872
|
+
state.left();
|
|
873
|
+
});
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
876
|
+
* What a `show` ward's place in the layout does ({@link Popped}), made the first time something
|
|
877
|
+
* happens to it past its mount: it's hidden, shown again, let go of or ended. A ward that's shown
|
|
878
|
+
* from its mount to its end makes none of it.
|
|
879
|
+
*/
|
|
880
|
+
const poppedOf = (ward, made, state, show, projection, anchors) => {
|
|
881
|
+
const sensed = sensedOf(ward);
|
|
882
|
+
const told = () => {
|
|
883
|
+
if (!state.affectsLayout)
|
|
884
|
+
return;
|
|
885
|
+
UndefinedOr.map(projection(), notified);
|
|
886
|
+
};
|
|
887
|
+
let pinned;
|
|
888
|
+
const back = () => {
|
|
889
|
+
if (Predicate.isUndefined(pinned))
|
|
890
|
+
return;
|
|
891
|
+
unpin(pinned);
|
|
892
|
+
pinned = undefined;
|
|
893
|
+
};
|
|
894
|
+
// The `layoutId` twins inside its element, handed to their other twins as it starts to leave, in a
|
|
895
|
+
// presence's own order (ADR-0010 *Amendment (#181)*): each twin's ward ends, its element kept, as a
|
|
896
|
+
// framework disposes a presence's leaving child; then the projection brings them back as leaving
|
|
897
|
+
// Followers of their Leads (`handBackWithin`), which fly home. It stays on the page until every
|
|
898
|
+
// handover has ended, as until its own exit lands.
|
|
899
|
+
//
|
|
900
|
+
// Telling the projection of each twin while its ward lived (`handleLeave`'s live branch) was tried
|
|
901
|
+
// first: a twin still flying to its place as the leave began kept that flight running underneath,
|
|
902
|
+
// and as it ended the element was drawn at rest for a frame, the view flashing open as it closed.
|
|
903
|
+
let leaves = 0;
|
|
904
|
+
const handBack = (el) => {
|
|
905
|
+
const system = projection();
|
|
906
|
+
if (Predicate.isUndefined(system))
|
|
907
|
+
return;
|
|
908
|
+
const inside = Arr.filter(Arr.fromIterable(TWINS), within(el));
|
|
909
|
+
leaves += 1;
|
|
910
|
+
const leave = leaves;
|
|
911
|
+
Arr.forEach(inside, (twin) => twin.end());
|
|
912
|
+
// With twins of its own ended, there's no turning round: a presence has its value come back afresh.
|
|
913
|
+
if (!Arr.isArrayEmpty(inside))
|
|
914
|
+
state.committed = true;
|
|
915
|
+
// Asked whether it ended any or none: a page its router has just disposed holds twins the same
|
|
916
|
+
// way, their wards ended by the navigation and not by it.
|
|
917
|
+
const ask = () => {
|
|
918
|
+
if (leave !== leaves)
|
|
919
|
+
return;
|
|
920
|
+
// Its own layout node, if it has one, lives on while it leaves (`live`): a row that lays out.
|
|
921
|
+
const drop = system.handBackWithin(el, () => {
|
|
922
|
+
// A handover from a leave it has since turned round from: nothing of this one to let go.
|
|
923
|
+
if (leave !== leaves)
|
|
924
|
+
return;
|
|
925
|
+
state.holds -= 1;
|
|
926
|
+
state.released();
|
|
927
|
+
}, true);
|
|
928
|
+
if (Option.isSome(drop)) {
|
|
929
|
+
state.holds += 1;
|
|
930
|
+
dropHeld = drop.value;
|
|
931
|
+
}
|
|
932
|
+
// What it still holds with no other to take it stays a later twin's to take while it's on the
|
|
933
|
+
// page (ADR-0010 *Amendment (#402)*), and one that does holds it for that handover. Kept this way
|
|
934
|
+
// so it can be ended as the element goes: left to a task's end, a twin nobody took kept its record
|
|
935
|
+
// for as long as nothing asked, and a card made much later flew in from where it had been.
|
|
936
|
+
forget = system.keepLeaving(el, () => {
|
|
937
|
+
// Taken after it let go, or turned round: not this leave's to hold for.
|
|
938
|
+
if (leave !== leaves)
|
|
939
|
+
return constVoid;
|
|
940
|
+
state.holds += 1;
|
|
941
|
+
return () => {
|
|
942
|
+
if (leave !== leaves)
|
|
943
|
+
return;
|
|
944
|
+
state.holds -= 1;
|
|
945
|
+
state.released();
|
|
946
|
+
};
|
|
947
|
+
});
|
|
948
|
+
};
|
|
949
|
+
// A twin it holds with no other on the page yet: that one may come later in this update, a page
|
|
950
|
+
// the router is still mounting, so it's asked at the task's end, as a presence decides (#482).
|
|
951
|
+
if (system.awaitsTwin(el)) {
|
|
952
|
+
queueMicrotask(ask);
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
ask();
|
|
956
|
+
};
|
|
957
|
+
// What the projection keeps of it while it leaves, ended as it goes or comes back.
|
|
958
|
+
let forget;
|
|
959
|
+
const forgetKept = () => {
|
|
960
|
+
const end = forget;
|
|
961
|
+
if (Predicate.isUndefined(end))
|
|
962
|
+
return;
|
|
963
|
+
forget = undefined;
|
|
964
|
+
end();
|
|
965
|
+
};
|
|
966
|
+
// The handovers of what it handed back, dropped at once: as its ward ends with any still running.
|
|
967
|
+
let dropHeld;
|
|
968
|
+
const ended = () => {
|
|
969
|
+
// A leave still to be asked about at its task's end is nobody's once its ward has ended.
|
|
970
|
+
leaves += 1;
|
|
971
|
+
const drop = dropHeld;
|
|
972
|
+
dropHeld = undefined;
|
|
973
|
+
if (Predicate.isNotUndefined(drop))
|
|
974
|
+
drop();
|
|
975
|
+
forgetKept();
|
|
976
|
+
};
|
|
977
|
+
// What it handed on holds it no more (a list's row whose item has a row of its own): the handovers
|
|
978
|
+
// run on, hidden or drawn by the projection, until its ward ends; a twin that comes later isn't its
|
|
979
|
+
// to wait for; and it's gone as its own exit lands, or now if that has.
|
|
980
|
+
const letGo = () => {
|
|
981
|
+
leaves += 1;
|
|
982
|
+
state.holds = 0;
|
|
983
|
+
forgetKept();
|
|
984
|
+
state.released();
|
|
985
|
+
};
|
|
986
|
+
/**
|
|
987
|
+
* It's shown again: what still held it lets go. A presence's ward that handed twins home is shown
|
|
988
|
+
* again only on a new element, with twins of its own; a `show` ward's turns round where it is, its
|
|
989
|
+
* twins' wards ended and not coming back.
|
|
990
|
+
*/
|
|
991
|
+
const takeBack = () => {
|
|
992
|
+
leaves += 1;
|
|
993
|
+
state.holds = 0;
|
|
994
|
+
state.committed = false;
|
|
995
|
+
forgetKept();
|
|
996
|
+
};
|
|
997
|
+
/** The element it's on now, read where it's used and not followed: an effect's callback doesn't track. */
|
|
998
|
+
const elementNow = () => {
|
|
999
|
+
if (Predicate.isUndefined(sensed))
|
|
1000
|
+
return undefined;
|
|
1001
|
+
return untrack(() => sensed.element());
|
|
1002
|
+
};
|
|
1003
|
+
// What it has taken to leave with it, held for at each of its leaves until their exits land: the
|
|
1004
|
+
// wards inside a row's or a presence value's element (Q20), and its followers with an exit of their own (Q12).
|
|
1005
|
+
const swept = [];
|
|
1006
|
+
/**
|
|
1007
|
+
* Its leave, for what leaves with it. A row's or a presence value's element: the wards inside it,
|
|
1008
|
+
* still alive as it stays to leave (Q20). Any leader's followers with an `exit` of their own, which
|
|
1009
|
+
* they'd never run by its variant names alone (Q12). Taken a microtask on, out of the effect phase,
|
|
1010
|
+
* where Solid makes nothing even under an owner given it; it stays until each one's exit has landed.
|
|
1011
|
+
*/
|
|
1012
|
+
const leaveWithIt = (el) => {
|
|
1013
|
+
queueMicrotask(() => {
|
|
1014
|
+
if (untrack(state.shown))
|
|
1015
|
+
return;
|
|
1016
|
+
if (state.sweeps)
|
|
1017
|
+
sweepInside(el, ward, state.shown, swept);
|
|
1018
|
+
followersLeaving(ward, state.shown, swept);
|
|
1019
|
+
Arr.forEach(swept, (inner) => {
|
|
1020
|
+
if (!untrack(inner.leaves))
|
|
1021
|
+
return;
|
|
1022
|
+
inner.gone = holdOn(state)();
|
|
1023
|
+
});
|
|
1024
|
+
// With no exit of its own, it has nothing to land: its leave is landed now, and it's gone once
|
|
1025
|
+
// what it took has let it go, or at once if it took nothing that leaves.
|
|
1026
|
+
if (!untrack(state.exits))
|
|
1027
|
+
state.landed();
|
|
1028
|
+
});
|
|
1029
|
+
};
|
|
1030
|
+
const shownTo = (shown) => {
|
|
1031
|
+
if (shown)
|
|
1032
|
+
takeBack();
|
|
1033
|
+
if (!shown && untrack(state.leaves)) {
|
|
1034
|
+
const leaving = elementNow();
|
|
1035
|
+
// The projection reads each twin's options as it hands it over, once, as at a mount: untracked, so said.
|
|
1036
|
+
if (Predicate.isNotUndefined(leaving)) {
|
|
1037
|
+
untrack(() => handBack(leaving));
|
|
1038
|
+
leaveWithIt(leaving);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
if (shown) {
|
|
1042
|
+
back();
|
|
1043
|
+
told();
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
if (Predicate.isNotUndefined(anchors) && untrack(state.leaves))
|
|
1047
|
+
popOut(anchors);
|
|
1048
|
+
told();
|
|
1049
|
+
};
|
|
1050
|
+
/** It pops as it leaves (`pop`), by `anchors`: its element, where it's on one, pinned where it is. */
|
|
1051
|
+
const popOut = (anchors) => {
|
|
1052
|
+
const el = elementNow();
|
|
1053
|
+
if (Predicate.isUndefined(el))
|
|
1054
|
+
return;
|
|
1055
|
+
// Where it was before the change, when a list measured it then (`createWards`); else where it is,
|
|
1056
|
+
// measured with every other ward leaving in this flush, before any of them is pinned.
|
|
1057
|
+
const ahead = UndefinedOr.map(made.own("popBox"), boxNow);
|
|
1058
|
+
const pinAt = (box) => {
|
|
1059
|
+
if (Predicate.isUndefined(box))
|
|
1060
|
+
return;
|
|
1061
|
+
if (untrack(show))
|
|
1062
|
+
return;
|
|
1063
|
+
pin(box);
|
|
1064
|
+
pinned = el;
|
|
1065
|
+
};
|
|
1066
|
+
UndefinedOr.match(ahead, { onDefined: pinAt, onUndefined: () => popTogether({ el, anchors, pinAt, told }) });
|
|
1067
|
+
};
|
|
1068
|
+
// Gone: hidden by its `style`, so its pin comes off, and what's beside it closes up if it wasn't popped.
|
|
1069
|
+
const gone = () => {
|
|
1070
|
+
back();
|
|
1071
|
+
forgetKept();
|
|
1072
|
+
told();
|
|
1073
|
+
};
|
|
1074
|
+
return { shown: shownTo, gone, letGo, ended };
|
|
1075
|
+
};
|
|
1076
|
+
/** A rune that's a config as it's written: not a `createRune(fn)`, whose config isn't known until it has run. */
|
|
1077
|
+
const isWrittenConfig = (rune) => !isFunctionRune(rune);
|
|
1078
|
+
/**
|
|
1079
|
+
* `key` as the runes written as configs give it, the last of them that gives one, as a later rune's
|
|
1080
|
+
* wins when they join: what's known of it before a `createRune(fn)` among them has run, whose ward is
|
|
1081
|
+
* made before its config is known.
|
|
1082
|
+
*/
|
|
1083
|
+
const knownBeforeFunctionRunes = (runes, key) =>
|
|
1084
|
+
// Found from the last rune back, with no list made on the way. Read untracked, as the ward's made:
|
|
1085
|
+
// a getter's is read for what it is now, not followed.
|
|
1086
|
+
untrack(() => Option.getOrUndefined(Option.map(Arr.findLast(runes, (rune) => isWrittenConfig(rune) && Predicate.isNotUndefined(rune[key])), (rune) => rune[key])));
|
|
1087
|
+
/**
|
|
1088
|
+
* `internal` with the tag the last of `configs` to name one gives (a function rune's among them, run
|
|
1089
|
+
* by now), so an SVG element's attribute keys render as attributes: as it is where none names one.
|
|
1090
|
+
* Read untracked, as the ward's made.
|
|
1091
|
+
*/
|
|
1092
|
+
const taggedOf = (internal, configs) => {
|
|
1093
|
+
const tag = untrack(() => Option.getOrUndefined(Option.map(Arr.findLast(configs, (config) => Predicate.isNotUndefined(config.tag)), (config) => config.tag)));
|
|
1094
|
+
if (Predicate.isUndefined(tag))
|
|
1095
|
+
return internal;
|
|
1096
|
+
return { ...internal, tag };
|
|
1097
|
+
};
|
|
1098
|
+
/**
|
|
1099
|
+
* `internal`, told its ward can never want a gesture where `has` gives none of `GESTURE_KEYS` (#525's
|
|
1100
|
+
* `gestureless`, as today's elements tell it). A ward's keys are fixed as it's made, so one that names
|
|
1101
|
+
* no gesture watches for one only from a first want through its lifecycle (a `when("hover")`), and
|
|
1102
|
+
* makes no computation for gestures until then: a hook ward made one every time (the gap grill's
|
|
1103
|
+
* Q27, the utility `w.div`'s computation more than today's). Its factory's `kind` told so is kept, so a
|
|
1104
|
+
* ward made with it as it is makes no internals of its own.
|
|
1105
|
+
*/
|
|
1106
|
+
const gesturesTold = (internal, kind, has) => {
|
|
1107
|
+
if (internal.gestureless === true)
|
|
1108
|
+
return internal;
|
|
1109
|
+
// One sharing another's lifecycle, a function rune's (`share`), is told its wants through that
|
|
1110
|
+
// one's: what reads `hovering` there wants its gesture, and only its own watch would start it here.
|
|
1111
|
+
if (Predicate.isNotUndefined(internal.share))
|
|
1112
|
+
return internal;
|
|
1113
|
+
if (Arr.some(GESTURE_KEYS, (key) => has(key)))
|
|
1114
|
+
return internal;
|
|
1115
|
+
if (internal === kind)
|
|
1116
|
+
return gesturelessKind(kind);
|
|
1117
|
+
return { ...internal, gestureless: true };
|
|
1118
|
+
};
|
|
1119
|
+
/**
|
|
1120
|
+
* Each factory's internals, told gestureless: made as a factory's are first asked for, by `gesturelessKind`.
|
|
1121
|
+
*
|
|
1122
|
+
* Module state (#460, Q7): held weakly by the internals it's for, so it goes with them.
|
|
1123
|
+
*/
|
|
1124
|
+
const GESTURELESS = new WeakMap();
|
|
1125
|
+
/** `kind`, a factory's internals, told gestureless, kept for the next ward it makes. */
|
|
1126
|
+
const gesturelessKind = (kind) => {
|
|
1127
|
+
const kept = GESTURELESS.get(kind);
|
|
1128
|
+
if (Predicate.isNotUndefined(kept))
|
|
1129
|
+
return kept;
|
|
1130
|
+
const told = { ...kind, gestureless: true };
|
|
1131
|
+
GESTURELESS.set(kind, told);
|
|
1132
|
+
return told;
|
|
1133
|
+
};
|
|
1134
|
+
/** The ward's `follow`, as the runes written as configs give it: a function rune's ward is made under it. */
|
|
1135
|
+
const followOf = (runes) => knownBeforeFunctionRunes(runes, "follow");
|
|
1136
|
+
/** A follower's options: the ward it follows, its variant parent. */
|
|
1137
|
+
const parentOptions = (parent) => ({ parent });
|
|
1138
|
+
/** The binding's ward of `config`: `begun`'s own maker's, else a plain ward. */
|
|
1139
|
+
const bindingWardOf = (begun, config, internal, propKeys) => {
|
|
1140
|
+
const make = begun.make;
|
|
1141
|
+
if (Predicate.isUndefined(make))
|
|
1142
|
+
return wardWith(config, internal);
|
|
1143
|
+
return make(config, internal, propKeys);
|
|
1144
|
+
};
|
|
1145
|
+
/**
|
|
1146
|
+
* `"ready"` for a ward whose Features are `instance`'s (probe: hooks-first): one promise, made the
|
|
1147
|
+
* first time it's asked for and kept, resolved once none of them is still on its way. So it can't be
|
|
1148
|
+
* missed: asked for after the last has arrived, it's resolved already.
|
|
1149
|
+
*
|
|
1150
|
+
* Nothing is made for a ward nobody asks: what follows its Features is one effect, under the owner the
|
|
1151
|
+
* ward was made under, started at the first ask.
|
|
1152
|
+
*/
|
|
1153
|
+
const readyOf = (instance, owner) => {
|
|
1154
|
+
let arrived;
|
|
1155
|
+
const next = () => {
|
|
1156
|
+
if (Predicate.isNotUndefined(arrived))
|
|
1157
|
+
return arrived;
|
|
1158
|
+
const landing = new Promise((resolve) => {
|
|
1159
|
+
runWithOwner(owner, () => {
|
|
1160
|
+
// The ward's own Features on this page: the loads its elements started, or start now.
|
|
1161
|
+
const own = useInstanceFeatures(instance);
|
|
1162
|
+
createEffect(() => own.pending(), (pending) => {
|
|
1163
|
+
if (!pending)
|
|
1164
|
+
resolve(undefined);
|
|
1165
|
+
}, CLIENT_ONLY);
|
|
1166
|
+
});
|
|
1167
|
+
});
|
|
1168
|
+
arrived = landing;
|
|
1169
|
+
return landing;
|
|
1170
|
+
};
|
|
1171
|
+
return {
|
|
1172
|
+
next,
|
|
1173
|
+
// Its promise is made here, where it's asked for, and only read in the memo: a promise made
|
|
1174
|
+
// inside a computation while the page hydrates is one that never settles.
|
|
1175
|
+
when: () => {
|
|
1176
|
+
const landing = next();
|
|
1177
|
+
return createMemo(() => landing, { equals: false });
|
|
1178
|
+
},
|
|
1179
|
+
};
|
|
1180
|
+
};
|
|
1181
|
+
const READY = "ready";
|
|
1182
|
+
/**
|
|
1183
|
+
* A ward's own `when`, `next` and `each`, over the ones every ward shares. A gesture's event asks for
|
|
1184
|
+
* its Feature as it's first listened to (`ask`), and `"ready"` is the hooks' to tell ({@link readyOf}),
|
|
1185
|
+
* of the Features `instance` brings.
|
|
1186
|
+
*/
|
|
1187
|
+
const withOwnEvents = (ward, ask, instance) => {
|
|
1188
|
+
// Told what they go by, and no more: its `when`, `next` and `each` are every ward's ({@link SHARED}),
|
|
1189
|
+
// each made for this ward the first time it's read. What its reads go by too (`reads.ts`).
|
|
1190
|
+
const kept = keptOf(ward);
|
|
1191
|
+
kept.ask = ask;
|
|
1192
|
+
kept.instance = instance;
|
|
1193
|
+
kept.owner = getOwner();
|
|
1194
|
+
return ward;
|
|
1195
|
+
};
|
|
1196
|
+
/** `kept`'s ward's readiness, made the first time it's asked for. */
|
|
1197
|
+
const readinessOf = (kept, instance) => {
|
|
1198
|
+
const known = kept.ready;
|
|
1199
|
+
if (Predicate.isNotUndefined(known))
|
|
1200
|
+
return known;
|
|
1201
|
+
const made = readyOf(instance, kept.owner);
|
|
1202
|
+
kept.ready = made;
|
|
1203
|
+
return made;
|
|
1204
|
+
};
|
|
1205
|
+
/** The members every ward shares as they were, before the hooks' own took their place: what a ward the hooks didn't make still reads, and what theirs listen through. */
|
|
1206
|
+
const SHARED_BEFORE = { when: sharedMember("when"), next: sharedMember("next"), each: sharedMember("each") };
|
|
1207
|
+
/**
|
|
1208
|
+
* One of a hooks ward's `when`, `next` and `each`, for `kept`'s ward: `shared` with a gesture's
|
|
1209
|
+
* Feature asked for as its event is first listened to, and `"ready"` told by the hooks. `each` has
|
|
1210
|
+
* no `"ready"`: it's a moment, not a stream.
|
|
1211
|
+
*/
|
|
1212
|
+
const listening = (member, kept, ask, instance, shared) => {
|
|
1213
|
+
const through = (event) => {
|
|
1214
|
+
const feature = featureOfEvent(event);
|
|
1215
|
+
if (Predicate.isNotUndefined(feature))
|
|
1216
|
+
ask(feature);
|
|
1217
|
+
return shared(event);
|
|
1218
|
+
};
|
|
1219
|
+
if (member === "each")
|
|
1220
|
+
return through;
|
|
1221
|
+
return (event) => {
|
|
1222
|
+
if (event === READY)
|
|
1223
|
+
return readinessOf(kept, instance)[member]();
|
|
1224
|
+
return through(event);
|
|
1225
|
+
};
|
|
1226
|
+
};
|
|
1227
|
+
/** A ward's own exits: what one made under a presence hears of its own waiters ({@link Watched}). */
|
|
1228
|
+
const EXIT_NAMES = new Set(["exitStart", "exitComplete"]);
|
|
1229
|
+
/** `member` of `watched`'s exits, for one of their names. */
|
|
1230
|
+
const watchedExit = (member, watched, event) => {
|
|
1231
|
+
if (member === "next")
|
|
1232
|
+
return watched.waiters.wait(event);
|
|
1233
|
+
if (member === "each")
|
|
1234
|
+
return eachOf(watched.waiters, event);
|
|
1235
|
+
return whenOf(watched.waiters, event);
|
|
1236
|
+
};
|
|
1237
|
+
/** `base`, its exits heard of `watched` where the ward was made under a presence. */
|
|
1238
|
+
const watchedListening = (member, watched, base) => (event) => {
|
|
1239
|
+
if (EXIT_NAMES.has(event))
|
|
1240
|
+
return watchedExit(member, watched, event);
|
|
1241
|
+
return base(event);
|
|
1242
|
+
};
|
|
1243
|
+
/**
|
|
1244
|
+
* `member` as every ward shares it: the hooks' own for a ward with Features of its own, and its exits
|
|
1245
|
+
* its own waiters' for one made under a presence, made at its first read and kept; as it was for any other.
|
|
1246
|
+
*/
|
|
1247
|
+
const sharedListening = (member) => ({
|
|
1248
|
+
configurable: true,
|
|
1249
|
+
get() {
|
|
1250
|
+
const shared = SHARED_BEFORE[member].call(this);
|
|
1251
|
+
const kept = keptFor(this);
|
|
1252
|
+
if (Predicate.isUndefined(kept))
|
|
1253
|
+
return shared;
|
|
1254
|
+
const made = kept[member];
|
|
1255
|
+
if (Predicate.isNotUndefined(made))
|
|
1256
|
+
return made;
|
|
1257
|
+
const ask = kept.ask;
|
|
1258
|
+
const instance = kept.instance;
|
|
1259
|
+
let base = shared;
|
|
1260
|
+
if (Predicate.isNotUndefined(ask) && Predicate.isNotUndefined(instance))
|
|
1261
|
+
base = listening(member, kept, ask, instance, shared);
|
|
1262
|
+
const watched = kept.watched;
|
|
1263
|
+
let own = base;
|
|
1264
|
+
if (Predicate.isNotUndefined(watched))
|
|
1265
|
+
own = watchedListening(member, watched, base);
|
|
1266
|
+
if (own === shared)
|
|
1267
|
+
return shared;
|
|
1268
|
+
kept[member] = own;
|
|
1269
|
+
return own;
|
|
1270
|
+
},
|
|
1271
|
+
});
|
|
1272
|
+
/**
|
|
1273
|
+
* What the hooks give every client ward to share (`shareMembers`, `ward.tsx`), once, as they load:
|
|
1274
|
+
* whether it's mounted, shown and leaving, its six reads, and their own `when`, `next` and `each`.
|
|
1275
|
+
* Each reads what the hooks keep of the ward it's read on (`kept.ts`), so a ward carries nothing
|
|
1276
|
+
* for them. A ward the hooks didn't make reads as one with no `show`: on the page, shown, not leaving.
|
|
1277
|
+
*/
|
|
1278
|
+
const SHARED = {
|
|
1279
|
+
mounted: {
|
|
1280
|
+
configurable: true,
|
|
1281
|
+
get() {
|
|
1282
|
+
const kept = keptFor(this);
|
|
1283
|
+
if (Predicate.isUndefined(kept))
|
|
1284
|
+
return ALWAYS;
|
|
1285
|
+
return kept.mounted;
|
|
1286
|
+
},
|
|
1287
|
+
},
|
|
1288
|
+
shown: {
|
|
1289
|
+
configurable: true,
|
|
1290
|
+
get() {
|
|
1291
|
+
const kept = keptFor(this);
|
|
1292
|
+
if (Predicate.isUndefined(kept))
|
|
1293
|
+
return ALWAYS;
|
|
1294
|
+
return kept.shown;
|
|
1295
|
+
},
|
|
1296
|
+
},
|
|
1297
|
+
exiting: {
|
|
1298
|
+
configurable: true,
|
|
1299
|
+
get() {
|
|
1300
|
+
const kept = keptFor(this);
|
|
1301
|
+
if (Predicate.isUndefined(kept))
|
|
1302
|
+
return NEVER;
|
|
1303
|
+
const made = kept.exiting;
|
|
1304
|
+
if (Predicate.isNotUndefined(made))
|
|
1305
|
+
return made;
|
|
1306
|
+
const exiting = () => !kept.shown() && kept.mounted();
|
|
1307
|
+
kept.exiting = exiting;
|
|
1308
|
+
return exiting;
|
|
1309
|
+
},
|
|
1310
|
+
},
|
|
1311
|
+
hold: {
|
|
1312
|
+
configurable: true,
|
|
1313
|
+
get() {
|
|
1314
|
+
// A function rune's ward holds the leave of the ward it's part of.
|
|
1315
|
+
const kept = keptFor(onOf(this));
|
|
1316
|
+
if (Predicate.isUndefined(kept))
|
|
1317
|
+
return NO_HOLD;
|
|
1318
|
+
const made = kept.hold;
|
|
1319
|
+
if (Predicate.isNotUndefined(made))
|
|
1320
|
+
return made;
|
|
1321
|
+
const state = leavingOf(kept);
|
|
1322
|
+
const watched = kept.watched;
|
|
1323
|
+
if (Predicate.isUndefined(state))
|
|
1324
|
+
return NO_HOLD;
|
|
1325
|
+
let hold = holdOn(state);
|
|
1326
|
+
// Made under a presence: its leave is that presence's to hold, unless one of the hooks' took it.
|
|
1327
|
+
if (Predicate.isNotUndefined(watched))
|
|
1328
|
+
hold = heldBy(kept, watched, hold);
|
|
1329
|
+
kept.hold = hold;
|
|
1330
|
+
return hold;
|
|
1331
|
+
},
|
|
1332
|
+
},
|
|
1333
|
+
...READS,
|
|
1334
|
+
when: sharedListening("when"),
|
|
1335
|
+
next: sharedListening("next"),
|
|
1336
|
+
each: sharedListening("each"),
|
|
1337
|
+
};
|
|
1338
|
+
/**
|
|
1339
|
+
* `ward.hold()` for a ward made under a presence ({@link watchedUnder}): the presence's hold on the leave
|
|
1340
|
+
* under way, from its leave to its end; nothing before or after. `own`, where a presence of the hooks'
|
|
1341
|
+
* has taken it since, and its leave is that one's.
|
|
1342
|
+
*/
|
|
1343
|
+
const heldBy = (kept, watched, own) => () => {
|
|
1344
|
+
if (takenNow(kept))
|
|
1345
|
+
return own();
|
|
1346
|
+
const late = watched.late;
|
|
1347
|
+
if (Predicate.isUndefined(late))
|
|
1348
|
+
return constVoid;
|
|
1349
|
+
return late();
|
|
1350
|
+
};
|
|
1351
|
+
/** The state a ward leaves by, where a hook shows it: its `show`'s or a list row's, or a presence's that may take it. */
|
|
1352
|
+
const leavingOf = (kept) => {
|
|
1353
|
+
const show = kept.show;
|
|
1354
|
+
if (Predicate.isNotUndefined(show))
|
|
1355
|
+
return show;
|
|
1356
|
+
const take = kept.take;
|
|
1357
|
+
if (Predicate.isUndefined(take))
|
|
1358
|
+
return undefined;
|
|
1359
|
+
return take.state;
|
|
1360
|
+
};
|
|
1361
|
+
/**
|
|
1362
|
+
* `ward.hold()` for a ward that leaves by `state` (Q15): one more thing keeping it on the page, as the
|
|
1363
|
+
* `layoutId` handovers it gave back do ({@link ShowState.holds}), until the release it hands back.
|
|
1364
|
+
* Nothing, where it isn't leaving. Its turn round lets every hold go (`takeBack`), so a release from
|
|
1365
|
+
* an earlier leave does nothing.
|
|
1366
|
+
*/
|
|
1367
|
+
const holdOn = (state) => () => {
|
|
1368
|
+
if (untrack(state.shown) || !untrack(state.mounted))
|
|
1369
|
+
return constVoid;
|
|
1370
|
+
const turn = state.turn();
|
|
1371
|
+
state.holds += 1;
|
|
1372
|
+
let released = false;
|
|
1373
|
+
return () => {
|
|
1374
|
+
if (released)
|
|
1375
|
+
return;
|
|
1376
|
+
released = true;
|
|
1377
|
+
if (state.turn() !== turn)
|
|
1378
|
+
return;
|
|
1379
|
+
state.holds -= 1;
|
|
1380
|
+
state.released();
|
|
1381
|
+
};
|
|
1382
|
+
};
|
|
1383
|
+
// Module state (#460, Q7): the one prototype every client ward shares has the hooks' members added
|
|
1384
|
+
// to it, once, as this module loads. Nothing a ward made before it reads differently: the members
|
|
1385
|
+
// here are the hooks' own, and the three that take a base member's place answer as it did for a
|
|
1386
|
+
// ward the hooks keep nothing of.
|
|
1387
|
+
shareMembers(SHARED);
|
|
1388
|
+
/** A ward's Features from `kind`, the same for every ward: a `makeWard` given its Features. */
|
|
1389
|
+
export const fixed = (kind) => {
|
|
1390
|
+
const instance = kind.instance;
|
|
1391
|
+
// A server's ward hears nothing, and one with no Features of its own (a Reorder's row) is left as it is.
|
|
1392
|
+
const made = (ward) => {
|
|
1393
|
+
if (isServer)
|
|
1394
|
+
return ward;
|
|
1395
|
+
if (Predicate.isUndefined(instance))
|
|
1396
|
+
return ward;
|
|
1397
|
+
return withOwnEvents(ward, constVoid, instance);
|
|
1398
|
+
};
|
|
1399
|
+
// Once for every ward made with them: whether an element enters afresh is asked of the ward itself.
|
|
1400
|
+
const begun = { kind: { ...kind, ...HOOK_TOLD, entersFresh: saidFresh }, config: constVoid, made };
|
|
1401
|
+
return () => begun;
|
|
1402
|
+
};
|
|
1403
|
+
/** A ward's Features read from its own config (`auto.ts`): each loaded the first time one is asked for. */
|
|
1404
|
+
export const auto = () => {
|
|
1405
|
+
const features = asking();
|
|
1406
|
+
return {
|
|
1407
|
+
kind: { ...SLIM, ...HOOK_TOLD, instance: features.instance, entersFresh: saidFresh, targeted: features.targeted },
|
|
1408
|
+
config: (config) => {
|
|
1409
|
+
// A key still loading as the ward is made is left out, and followed until it lands (`auto.ts`).
|
|
1410
|
+
const pending = [];
|
|
1411
|
+
features.want(wantedBy(config(), pending));
|
|
1412
|
+
if (pending.length > 0)
|
|
1413
|
+
colorsOnceLoaded(config, pending, features.ask);
|
|
1414
|
+
},
|
|
1415
|
+
want: (names) => void features.want(names),
|
|
1416
|
+
// A server's ward hears nothing: its `when` is left as it is.
|
|
1417
|
+
made: (ward) => {
|
|
1418
|
+
if (isServer)
|
|
1419
|
+
return ward;
|
|
1420
|
+
return withOwnEvents(ward, features.ask, features.instance);
|
|
1421
|
+
},
|
|
1422
|
+
};
|
|
1423
|
+
};
|
|
1424
|
+
/**
|
|
1425
|
+
* Whether the next element `ward` is given enters afresh, from its `initial`: its presence said so
|
|
1426
|
+
* ({@link Taken.fresh}). The one function every hooks ward's internals carry (`entersFresh`), asked
|
|
1427
|
+
* of the ward itself, so nothing is made for it ward by ward.
|
|
1428
|
+
*/
|
|
1429
|
+
const saidFresh = (ward) => {
|
|
1430
|
+
const kept = keptFor(ward);
|
|
1431
|
+
if (Predicate.isUndefined(kept))
|
|
1432
|
+
return false;
|
|
1433
|
+
return kept.fresh;
|
|
1434
|
+
};
|
|
1435
|
+
/** Where a ward `createWard` made keeps how a presence takes it. */
|
|
1436
|
+
const TAKE = Symbol("wardic.hooks.take");
|
|
1437
|
+
const TAKEN_TWICE = "createPresence(ward, value): this ward already has a presence. Make a ward for each.";
|
|
1438
|
+
/**
|
|
1439
|
+
* Takes `ward` for a presence, once: `undefined` for a ward that isn't one `createWard` handed out (a
|
|
1440
|
+
* row's, another library's), or that has a `show` of its own and comes and goes by that.
|
|
1441
|
+
*/
|
|
1442
|
+
export const takenOf = (ward) => {
|
|
1443
|
+
const take = keptElse(ward, (kept) => kept.take, () => ward[TAKE]);
|
|
1444
|
+
if (Predicate.isUndefined(take))
|
|
1445
|
+
return undefined;
|
|
1446
|
+
if (take.taken)
|
|
1447
|
+
throw misuse("WARDIC_PRESENCE_WARD_TAKEN", TAKEN_TWICE);
|
|
1448
|
+
take.taken = true;
|
|
1449
|
+
return takenBy(take);
|
|
1450
|
+
};
|
|
1451
|
+
/** How `take`'s ward is taken: at once, with nowhere to leave to, else by its runes. Its refs go by its presence's word from then. */
|
|
1452
|
+
const takenBy = (take) => {
|
|
1453
|
+
const taken = UndefinedOr.match(take.runes, {
|
|
1454
|
+
onUndefined: () => takenAtOnce(take.state)(),
|
|
1455
|
+
onDefined: (runes) => takenLater(take.ward, take.state, runes)(),
|
|
1456
|
+
});
|
|
1457
|
+
UndefinedOr.map(take.refs, (refs) => refsTaken(refs, take.ward));
|
|
1458
|
+
return taken;
|
|
1459
|
+
};
|
|
1460
|
+
/** Whether a ward comes and goes by a `show` or a presence of its own: a row, a `show` ward, a presence's ward. */
|
|
1461
|
+
const ownsItsLeave = (kept) => {
|
|
1462
|
+
if (Predicate.isNotUndefined(kept.show))
|
|
1463
|
+
return true;
|
|
1464
|
+
const take = kept.take;
|
|
1465
|
+
return Predicate.isNotUndefined(take) && take.taken;
|
|
1466
|
+
};
|
|
1467
|
+
/**
|
|
1468
|
+
* `found`, a ward inside a leaving row or presence value (the gap grill's Q20), taken by it as it first
|
|
1469
|
+
* leaves: its presence's word is whether that one is `shown`, so it leaves and comes back with it, and
|
|
1470
|
+
* as it leaves it sweeps what's inside its own element. Its leaving state; none where it isn't the
|
|
1471
|
+
* row's to take: a follower, one a presence may not take, or one made under no owner. Taken late, as
|
|
1472
|
+
* nothing is settling and no component is being made: what's told at a settle is told now, and it's
|
|
1473
|
+
* aimed again outside any owner.
|
|
1474
|
+
*/
|
|
1475
|
+
const takenInside = (found, kept, shown) => {
|
|
1476
|
+
if (FOLLOWING.has(found))
|
|
1477
|
+
return undefined;
|
|
1478
|
+
return takenLate(found, kept, shown);
|
|
1479
|
+
};
|
|
1480
|
+
/**
|
|
1481
|
+
* `found` taken late by something that leaves, as a leaving row takes what's inside it (Q20) and a
|
|
1482
|
+
* leader its followers with an exit of their own (Q12): its presence's word is whether that one is
|
|
1483
|
+
* `shown`. Its leaving state; none for one a presence may not take, one taken already, or one made
|
|
1484
|
+
* under no owner.
|
|
1485
|
+
*/
|
|
1486
|
+
const takenLate = (found, kept, shown) => {
|
|
1487
|
+
const take = kept.take;
|
|
1488
|
+
if (Predicate.isUndefined(take) || take.taken)
|
|
1489
|
+
return undefined;
|
|
1490
|
+
const owner = kept.owner;
|
|
1491
|
+
if (Predicate.isNull(owner))
|
|
1492
|
+
return undefined;
|
|
1493
|
+
take.taken = true;
|
|
1494
|
+
takingLate = true;
|
|
1495
|
+
try {
|
|
1496
|
+
runWithOwner(owner, () => takenBy(take)).drive(shown);
|
|
1497
|
+
}
|
|
1498
|
+
finally {
|
|
1499
|
+
takingLate = false;
|
|
1500
|
+
}
|
|
1501
|
+
// It ends with what took it, unless that comes back: it stays where its exit left it, as a list's
|
|
1502
|
+
// leaving row does, where it rested at its `initial`, and showed, its spread's `style` not read again.
|
|
1503
|
+
take.state.ends = () => !untrack(shown);
|
|
1504
|
+
targetAgain(found);
|
|
1505
|
+
return take.state;
|
|
1506
|
+
};
|
|
1507
|
+
/** `leader`'s followers with an `exit` of their own, each taken by it as it first leaves (Q12), each one's leaving state added to `into`. */
|
|
1508
|
+
const followersLeaving = (leader, shown, into) => {
|
|
1509
|
+
const all = FOLLOWERS.get(leader);
|
|
1510
|
+
if (Predicate.isUndefined(all))
|
|
1511
|
+
return;
|
|
1512
|
+
Iter.forEach(all, (follower) => {
|
|
1513
|
+
if (!follower.exits)
|
|
1514
|
+
return;
|
|
1515
|
+
const kept = keptFor(follower.ward);
|
|
1516
|
+
if (Predicate.isUndefined(kept))
|
|
1517
|
+
return;
|
|
1518
|
+
const taken = takenLate(follower.ward, kept, shown);
|
|
1519
|
+
if (Predicate.isNotUndefined(taken))
|
|
1520
|
+
into.push(taken);
|
|
1521
|
+
});
|
|
1522
|
+
};
|
|
1523
|
+
/**
|
|
1524
|
+
* What `self`, a leaving row or presence value, takes inside `el` (Q20), depth first, each one's
|
|
1525
|
+
* leaving state added to `into`. A ward with a leave of its own (a row, a `show` ward, a presence's)
|
|
1526
|
+
* keeps what's inside it, and so does a twin, its handback's; one it takes sweeps its own inside as it
|
|
1527
|
+
* leaves; past any other element it looks further in.
|
|
1528
|
+
*/
|
|
1529
|
+
const sweepInside = (el, self, shown, into) => Iter.forEach(el.children, (child) => {
|
|
1530
|
+
const found = wardOn(child);
|
|
1531
|
+
if (Predicate.isNotUndefined(found) && found !== self) {
|
|
1532
|
+
const kept = keptFor(found);
|
|
1533
|
+
if (Predicate.isNotUndefined(kept)) {
|
|
1534
|
+
if (ownsItsLeave(kept) || TWIN_WARDS.has(found))
|
|
1535
|
+
return;
|
|
1536
|
+
const taken = takenInside(found, kept, shown);
|
|
1537
|
+
if (Predicate.isNotUndefined(taken)) {
|
|
1538
|
+
into.push(taken);
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
sweepInside(child, self, shown, into);
|
|
1544
|
+
});
|
|
1545
|
+
const WATCHED_GONE = "The ward went before its next exit.";
|
|
1546
|
+
/** Whether a presence of the hooks' has taken `kept`'s ward (`createPresence`), which then says when it leaves. */
|
|
1547
|
+
const takenNow = (kept) => Predicate.isNotUndefined(kept.take) && kept.take.taken;
|
|
1548
|
+
/**
|
|
1549
|
+
* A ward made under a presence (`<Presence>`, `<AnimatePresence>`) with no leave of its own hears its
|
|
1550
|
+
* child's leave from that presence, by a watch of its own, as the deleted `usePresence` did (the code review of the
|
|
1551
|
+
* gap grill's work). Its owner has ended by then, with the child's: what still runs, an event handler, a
|
|
1552
|
+
* timer, the code after an `await`, reads it leaving, `exiting()` and not `shown()`, and its `next`,
|
|
1553
|
+
* `each` and `when` of its exits hear them on waiters its owner's end doesn't end. Its `hold()` holds the
|
|
1554
|
+
* leave under way. In a browser alone, and only under a presence.
|
|
1555
|
+
*/
|
|
1556
|
+
const watchedUnder = (made, ward, state) => {
|
|
1557
|
+
const presence = presenceOn(ward);
|
|
1558
|
+
if (Predicate.isUndefined(presence))
|
|
1559
|
+
return;
|
|
1560
|
+
const register = presence.watch;
|
|
1561
|
+
if (Predicate.isUndefined(register))
|
|
1562
|
+
return;
|
|
1563
|
+
const [present, setPresent] = createSignal(true);
|
|
1564
|
+
const [ended, setEnded] = createSignal(false);
|
|
1565
|
+
const watched = { waiters: new Waiters(WATCHED_GONE), late: undefined };
|
|
1566
|
+
state.shown = present;
|
|
1567
|
+
// eslint-disable-next-line solid/reactivity -- an accessor, read where the ward's `mounted` is, which tracks it
|
|
1568
|
+
state.mounted = () => !ended();
|
|
1569
|
+
const kept = keptOf(made);
|
|
1570
|
+
kept.watched = watched;
|
|
1571
|
+
const end = () => {
|
|
1572
|
+
watched.late = undefined;
|
|
1573
|
+
watched.waiters.dispose();
|
|
1574
|
+
};
|
|
1575
|
+
register({
|
|
1576
|
+
subject: () => elementOf(ward),
|
|
1577
|
+
holds: false,
|
|
1578
|
+
leave: (_custom, _release, hold) => {
|
|
1579
|
+
// A presence of the hooks' that took it since says when it leaves.
|
|
1580
|
+
if (takenNow(kept))
|
|
1581
|
+
return;
|
|
1582
|
+
watched.late = hold;
|
|
1583
|
+
setPresent(false);
|
|
1584
|
+
watched.waiters.tell("exitStart", constUndefined);
|
|
1585
|
+
},
|
|
1586
|
+
gone: end,
|
|
1587
|
+
interrupted: () => {
|
|
1588
|
+
setEnded(true);
|
|
1589
|
+
end();
|
|
1590
|
+
},
|
|
1591
|
+
ended: () => {
|
|
1592
|
+
setEnded(true);
|
|
1593
|
+
watched.waiters.tell("exitComplete", constUndefined);
|
|
1594
|
+
end();
|
|
1595
|
+
},
|
|
1596
|
+
});
|
|
1597
|
+
};
|
|
1598
|
+
/** Whether `leader` has a follower with an `exit` of its own, which it takes as it leaves (Q12). */
|
|
1599
|
+
const followerWithExit = (leader) => {
|
|
1600
|
+
const all = FOLLOWERS.get(leader);
|
|
1601
|
+
if (Predicate.isUndefined(all))
|
|
1602
|
+
return false;
|
|
1603
|
+
return Iter.some(all, (follower) => follower.exits);
|
|
1604
|
+
};
|
|
1605
|
+
/**
|
|
1606
|
+
* Whether `self`, a leaving row or presence value, has a ward inside `el` it would take to leave by
|
|
1607
|
+
* that ward's own exit ({@link sweepInside}, read and not taken): one a presence may take, with an
|
|
1608
|
+
* `animate` or an `exit`, not taken yet, made under an owner, and following nothing. One with only an
|
|
1609
|
+
* `animate` is taken and then lets it go, a microtask on.
|
|
1610
|
+
*/
|
|
1611
|
+
const leavesInside = (el, self) => Iter.some(el.children, (child) => {
|
|
1612
|
+
const found = wardOn(child);
|
|
1613
|
+
if (Predicate.isNotUndefined(found) && found !== self) {
|
|
1614
|
+
const kept = keptFor(found);
|
|
1615
|
+
if (Predicate.isNotUndefined(kept)) {
|
|
1616
|
+
if (ownsItsLeave(kept) || TWIN_WARDS.has(found))
|
|
1617
|
+
return false;
|
|
1618
|
+
if (takesInside(found, kept))
|
|
1619
|
+
return true;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
return leavesInside(child, self);
|
|
1623
|
+
});
|
|
1624
|
+
/** Whether {@link takenInside} would take `found`: what {@link takenLate} asks, before taking it. */
|
|
1625
|
+
const takesInside = (found, kept) => {
|
|
1626
|
+
if (FOLLOWING.has(found))
|
|
1627
|
+
return false;
|
|
1628
|
+
const take = kept.take;
|
|
1629
|
+
if (Predicate.isUndefined(take) || take.taken || Predicate.isUndefined(take.runes))
|
|
1630
|
+
return false;
|
|
1631
|
+
return Predicate.isNotNull(kept.owner);
|
|
1632
|
+
};
|
|
1633
|
+
/** What `ward` waits for as it leaves with no exit of its own ({@link ShowState.waits}): its followers with an exit, and what's inside a row or a presence value. */
|
|
1634
|
+
const waitsAsItLeaves = (ward, state) => {
|
|
1635
|
+
if (followerWithExit(ward))
|
|
1636
|
+
return true;
|
|
1637
|
+
if (!state.sweeps)
|
|
1638
|
+
return false;
|
|
1639
|
+
const el = elementOf(ward);
|
|
1640
|
+
if (Predicate.isUndefined(el))
|
|
1641
|
+
return false;
|
|
1642
|
+
return leavesInside(el, ward);
|
|
1643
|
+
};
|
|
1644
|
+
/**
|
|
1645
|
+
* Whether `ward` stays to leave ({@link ShowState.leaves}), asked untracked: a list's, of a row whose
|
|
1646
|
+
* item has left, so one with nowhere to leave to and nothing to wait for is left out in that same
|
|
1647
|
+
* change, where its own effect dropping it tore the list. Yes for a ward the hooks keep no state of
|
|
1648
|
+
* (a Stage's), which the list watches for itself.
|
|
1649
|
+
*/
|
|
1650
|
+
export const leavesNow = (ward) => {
|
|
1651
|
+
const state = showOf(ward);
|
|
1652
|
+
if (Predicate.isUndefined(state))
|
|
1653
|
+
return true;
|
|
1654
|
+
return untrack(state.leaves);
|
|
1655
|
+
};
|
|
1656
|
+
/**
|
|
1657
|
+
* `ward` with what a presence takes it by ({@link Takeable}). Kept of a client's ward (`kept.ts`); its
|
|
1658
|
+
* own property on one with no state to keep it by, not enumerable, so a spread never sees it.
|
|
1659
|
+
*/
|
|
1660
|
+
const takeable = (made, ward, state, runes, refs) => {
|
|
1661
|
+
const take = { ward, state, runes, refs, taken: false };
|
|
1662
|
+
if (!keepsState(made))
|
|
1663
|
+
return Object.defineProperty(made, TAKE, { value: take });
|
|
1664
|
+
const kept = keptOf(made);
|
|
1665
|
+
kept.take = take;
|
|
1666
|
+
// Where a leaving row takes it later (Q20), its wiring made under the owner it was made under.
|
|
1667
|
+
if (Predicate.isNull(kept.owner))
|
|
1668
|
+
kept.owner = getOwner();
|
|
1669
|
+
return made;
|
|
1670
|
+
};
|
|
1671
|
+
/** A ward with nowhere to leave to, taken: on the page while its presence says so, and gone at once. */
|
|
1672
|
+
const takenAtOnce = (state) => () => {
|
|
1673
|
+
state.leaves = NEVER;
|
|
1674
|
+
return {
|
|
1675
|
+
// Nothing of its own reads its presence's word, so it's given at once, with nothing written. What
|
|
1676
|
+
// read the ward before this presence had it is told at the settle (`hearing`).
|
|
1677
|
+
drive: (shown) => {
|
|
1678
|
+
state.shown = shown;
|
|
1679
|
+
state.mounted = shown;
|
|
1680
|
+
tell(state);
|
|
1681
|
+
},
|
|
1682
|
+
state,
|
|
1683
|
+
fresh: constVoid,
|
|
1684
|
+
};
|
|
1685
|
+
};
|
|
1686
|
+
/** What `ward` hands the wards that follow it, where it leads any: whether they've all landed is read of it. */
|
|
1687
|
+
const providedBy = (ward) => {
|
|
1688
|
+
const share = shareOf(ward);
|
|
1689
|
+
if (Predicate.isUndefined(share))
|
|
1690
|
+
return undefined;
|
|
1691
|
+
return share.provided;
|
|
1692
|
+
};
|
|
1693
|
+
/**
|
|
1694
|
+
* `show`'s other half, once its ward is made: its followers' landings and its own, and its place in
|
|
1695
|
+
* the layout. Made where its `show` is wired: as the ward is made, or as a presence takes it. Its
|
|
1696
|
+
* exits are told from here too where `exits` is given ({@link exitsOf}): a ward with a `show` of its
|
|
1697
|
+
* own. A presence's ward has them told once that presence's word and value are its state's
|
|
1698
|
+
* ({@link tellingExits}).
|
|
1699
|
+
*/
|
|
1700
|
+
const wiredFor = (ward, state, runes, exits) => {
|
|
1701
|
+
const provided = providedBy(ward);
|
|
1702
|
+
if (Predicate.isNotUndefined(provided)) {
|
|
1703
|
+
state.followersLanded = provided.allChildrenSettled;
|
|
1704
|
+
// In a browser alone: nothing lands on a server.
|
|
1705
|
+
if (!isServer) {
|
|
1706
|
+
const runtime = useWardicRuntime();
|
|
1707
|
+
state.counted = (count) => {
|
|
1708
|
+
// Called detached, as core calls it: the web's is `requestAnimationFrame` itself.
|
|
1709
|
+
const { requestFrame } = runtime.runSync(RefreshFrameSource.RefreshFrameSource);
|
|
1710
|
+
// Two frames on. A follower says it's moving as its spine is stepped, the frame after it's
|
|
1711
|
+
// told to leave, and this frame's own callback may come before that step: one frame on, a
|
|
1712
|
+
// view closed from rest read its followers as landed and went before any had moved.
|
|
1713
|
+
requestFrame(() => requestFrame(count));
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
// Each landing, told by its lifecycle to the one listener the hooks have there: not an effect over
|
|
1718
|
+
// `ward.when("settled")`, a memo that pends until the first, with an error of Solid's made for
|
|
1719
|
+
// each; and not a listener for `settled`, which had the ward make its waits and read every
|
|
1720
|
+
// landing for a wiring that reads none. Read at each landing: a presence that takes the ward adds
|
|
1721
|
+
// what it's told to. A server's ward has no lifecycle, and nothing lands there.
|
|
1722
|
+
const sensed = sensedOf(ward);
|
|
1723
|
+
if (Predicate.isNotUndefined(sensed))
|
|
1724
|
+
onCleanup(sensed.lifecycle.landingsHeardBy({ next: () => state.landed(), error: landingFailed(getOwner()) }));
|
|
1725
|
+
popping(ward, runes, state, exits);
|
|
1726
|
+
};
|
|
1727
|
+
/** `show`'s wiring as a presence's ward reads it: its `animate`, `exit` and `custom`, and whether an element enters afresh. Not its `style`: a presence takes its element off the page itself. */
|
|
1728
|
+
const takenWiring = (built, kept) => {
|
|
1729
|
+
if (Predicate.isUndefined(built))
|
|
1730
|
+
return undefined;
|
|
1731
|
+
return { animate: built.animate, exit: built.exit, custom: built.custom, reenters: () => kept.fresh };
|
|
1732
|
+
};
|
|
1733
|
+
/**
|
|
1734
|
+
* How a presence takes a ward that has an `animate` to leave by and no `show` of its own
|
|
1735
|
+
* (`createPresence(ward, value)`): `show`'s wiring over its `runes`, made as the presence takes it
|
|
1736
|
+
* and where the presence is, its `show` the presence's word.
|
|
1737
|
+
*
|
|
1738
|
+
* Nothing is set up for this as a ward is made, so a ward no presence takes carries none of it.
|
|
1739
|
+
* Every animated ward used to: its `animate` read through a wrapper that followed a signal of its
|
|
1740
|
+
* own, in case. The keys the wiring reads are fixed over the ward's config now (`fixLater`), and
|
|
1741
|
+
* its target is worked out again once the page has settled (`targetAgain`): it read its `animate`
|
|
1742
|
+
* as the ward was made, before any presence was, and follows nothing that says one has it.
|
|
1743
|
+
*/
|
|
1744
|
+
const takenLater = (ward, state, runes) => () => {
|
|
1745
|
+
// Its presence's word, given in `drive`: on the page until then. Not reactive itself, so what
|
|
1746
|
+
// read it before it was given is told at the settle (`hearing`).
|
|
1747
|
+
let by;
|
|
1748
|
+
const present = () => {
|
|
1749
|
+
hearing(state);
|
|
1750
|
+
if (Predicate.isUndefined(by))
|
|
1751
|
+
return true;
|
|
1752
|
+
return by();
|
|
1753
|
+
};
|
|
1754
|
+
const made = runes();
|
|
1755
|
+
const driven = { ...made, show: present };
|
|
1756
|
+
// What's inside its element leaves with it (Q20): a presence's value stays on the page as it leaves.
|
|
1757
|
+
state.sweeps = true;
|
|
1758
|
+
const built = showing(state)(driven);
|
|
1759
|
+
wiredFor(ward, state, driven, undefined);
|
|
1760
|
+
// A server's ward animates nothing and stays as it was made: it has no state to fix more over.
|
|
1761
|
+
if (keepsState(ward)) {
|
|
1762
|
+
fixLater(ward, wiredOf(takenWiring(built, keptOf(ward)), made.unentered, made.value, made.has));
|
|
1763
|
+
// Taken late by a leaving row or value (`takenInside`), nothing is settling: it's aimed again by
|
|
1764
|
+
// whoever took it, outside any owner, since `refresh` is refused in one.
|
|
1765
|
+
if (!takingLate)
|
|
1766
|
+
onSettledClientOnly(() => targetAgain(ward));
|
|
1767
|
+
}
|
|
1768
|
+
return {
|
|
1769
|
+
// Its presence's word. What read the ward before this presence had it is told of it at the
|
|
1770
|
+
// settle (`hearing`). In a browser alone: a server's ward animates nothing, and what's told at
|
|
1771
|
+
// a settle is client-only code's, which takes a hydration id on a server and none in a browser.
|
|
1772
|
+
drive: (shown) => {
|
|
1773
|
+
tell(state);
|
|
1774
|
+
if (isServer)
|
|
1775
|
+
return;
|
|
1776
|
+
by = shown;
|
|
1777
|
+
},
|
|
1778
|
+
state,
|
|
1779
|
+
fresh: () => {
|
|
1780
|
+
if (keepsState(ward))
|
|
1781
|
+
keptOf(ward).fresh = true;
|
|
1782
|
+
},
|
|
1783
|
+
};
|
|
1784
|
+
};
|
|
1785
|
+
// Module state (#460, Q7): the `show` state of each ward with no state of its own to keep it by (a
|
|
1786
|
+
// server's), held weakly by the ward, for the list that made it to read. A client's is kept of the ward (`kept.ts`).
|
|
1787
|
+
const SHOWN = new WeakMap();
|
|
1788
|
+
/** `ward`'s `show` state, where it has one: what the list that made it reads. */
|
|
1789
|
+
const showOf = (ward) => keptElse(ward, (kept) => kept.show, () => SHOWN.get(ward));
|
|
1790
|
+
/** Keeps `state` as `ward`'s `show` state. */
|
|
1791
|
+
const showIs = (ward, state) => {
|
|
1792
|
+
if (!keepsState(ward)) {
|
|
1793
|
+
SHOWN.set(ward, state);
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
keptOf(ward).show = state;
|
|
1797
|
+
};
|
|
1798
|
+
/**
|
|
1799
|
+
* Whether `ward`'s leave can't be turned round: the wards of the twins it handed home as it left have
|
|
1800
|
+
* ended ({@link ShowState.committed}). A list reads it of a row whose item has come back: that row
|
|
1801
|
+
* goes on leaving, and the item has a row of its own, on a new element. False for any other ward.
|
|
1802
|
+
*/
|
|
1803
|
+
export const leaveCommitted = (ward) => {
|
|
1804
|
+
const state = showOf(ward);
|
|
1805
|
+
if (Predicate.isUndefined(state))
|
|
1806
|
+
return false;
|
|
1807
|
+
return state.committed;
|
|
1808
|
+
};
|
|
1809
|
+
/**
|
|
1810
|
+
* `ward` leaves by its own exit alone from here on ({@link ShowState.letGo}): a list tells it of a row
|
|
1811
|
+
* whose item has come back to a row of its own. Nothing for any other ward.
|
|
1812
|
+
*/
|
|
1813
|
+
export const letGo = (ward) => {
|
|
1814
|
+
const state = showOf(ward);
|
|
1815
|
+
if (Predicate.isUndefined(state))
|
|
1816
|
+
return;
|
|
1817
|
+
state.letGo();
|
|
1818
|
+
};
|
|
1819
|
+
/**
|
|
1820
|
+
* How a list's row reaches the layout around it: its mount told to the projection when it comes after
|
|
1821
|
+
* the list's first rows (`later`, {@link ShowState.mountMoves}), and nothing told at all where its list
|
|
1822
|
+
* says `affectsLayout: false` ({@link ShowState.affectsLayout}). Nothing for a ward with no `show`.
|
|
1823
|
+
*/
|
|
1824
|
+
export const rowInLayout = (ward, later, affects) => {
|
|
1825
|
+
const state = showOf(ward);
|
|
1826
|
+
if (Predicate.isUndefined(state))
|
|
1827
|
+
return;
|
|
1828
|
+
state.mountMoves = later;
|
|
1829
|
+
state.affectsLayout = affects;
|
|
1830
|
+
};
|
|
1831
|
+
/**
|
|
1832
|
+
* Has `then` called once `ward` has gone ({@link ShowState.left}): a list's, for its row, which is
|
|
1833
|
+
* dropped then and its ward ended where `ends` says so as it goes ({@link ShowState.ends}). False
|
|
1834
|
+
* for a ward that tells no such thing, which the list watches for itself: a Stage's.
|
|
1835
|
+
*/
|
|
1836
|
+
export const whenLeft = (ward, then, ends) => {
|
|
1837
|
+
const state = showOf(ward);
|
|
1838
|
+
if (Predicate.isUndefined(state))
|
|
1839
|
+
return false;
|
|
1840
|
+
state.left = then;
|
|
1841
|
+
state.ends = ends;
|
|
1842
|
+
// What's inside its element leaves with it (Q20): a list keeps a leaving row on the page.
|
|
1843
|
+
state.sweeps = true;
|
|
1844
|
+
return true;
|
|
1845
|
+
};
|
|
1846
|
+
/**
|
|
1847
|
+
* `configs` as one ward's config, its wired keys read through `wired`: runes written plain are read
|
|
1848
|
+
* through as they are (`joinedOver`), one of them the config itself and the rest fixed over it. A
|
|
1849
|
+
* rune that follows, times its followers or carries timing in its variants is joined, key by key.
|
|
1850
|
+
*/
|
|
1851
|
+
const joinedOf = (begun, runes, configs, wired) => madeBy(throughOf(begun, runes, Arr.some(runes, isFunctionRune)), configs, wired);
|
|
1852
|
+
/** A ward's runes as its one config: read through as they're written where they were found to be (`through`), else joined key by key. */
|
|
1853
|
+
const madeBy = (through, configs, wired) => {
|
|
1854
|
+
if (Predicate.isUndefined(through))
|
|
1855
|
+
return joined(configs, wired);
|
|
1856
|
+
return joinedOver(through, wired);
|
|
1857
|
+
};
|
|
1858
|
+
/**
|
|
1859
|
+
* `runes` read through as they're written, where they can be (`readThroughOf`). Not with a function
|
|
1860
|
+
* rune among them, whose config is made as it's called: a ward of those is read through once they've
|
|
1861
|
+
* been called, from the configs they gave (probe: behaviour-runes). Nor for a binding that makes the ward itself:
|
|
1862
|
+
* it adds to the config it's given (a Reorder row's `value`), so that's a config of its own, and not
|
|
1863
|
+
* the rune.
|
|
1864
|
+
*/
|
|
1865
|
+
const throughOf = (begun, runes, anyFunction) => {
|
|
1866
|
+
if (anyFunction)
|
|
1867
|
+
return undefined;
|
|
1868
|
+
if (Predicate.isNotUndefined(begun.make))
|
|
1869
|
+
return undefined;
|
|
1870
|
+
return readThroughOf(runes);
|
|
1871
|
+
};
|
|
1872
|
+
/**
|
|
1873
|
+
* A landing that failed, reported as the binding reports any failure. An effect over
|
|
1874
|
+
* `ward.when("settled")` had Solid log it; heard from the lifecycle, it's the listener's to report.
|
|
1875
|
+
* Its runtime is found then, under the `owner` the ward was wired under: nothing is read for it for
|
|
1876
|
+
* a ward whose landings never fail.
|
|
1877
|
+
*/
|
|
1878
|
+
const landingFailed = (owner) => (error) => {
|
|
1879
|
+
// Uncoded: a leg that failed is Wardic's own failure; an app's function that made it fail is coded where it ran.
|
|
1880
|
+
runWithOwner(owner, () => void useWardicRuntime().runFork(Report.failure("wardic.createWard: a landing failed", Cause.die(error))));
|
|
1881
|
+
};
|
|
1882
|
+
/** `internal` with a rune's `wired` keys fixed over its config (`joinedOver`), over what its kind fixes already. */
|
|
1883
|
+
const wiredOver = (internal, wired) => {
|
|
1884
|
+
if (Predicate.isUndefined(wired))
|
|
1885
|
+
return internal;
|
|
1886
|
+
const fixed = internal.fixed;
|
|
1887
|
+
// Its kind fixes nothing, most do: what's wired is what's fixed, as it is. Nothing writes to either.
|
|
1888
|
+
if (Predicate.isUndefined(fixed))
|
|
1889
|
+
return { ...internal, fixed: wired };
|
|
1890
|
+
return { ...internal, fixed: { ...fixed, ...wired } };
|
|
1891
|
+
};
|
|
1892
|
+
/** The key a ward's exit is told through: with none in its runes, it leaves at once, and nothing is wired. */
|
|
1893
|
+
const animates = (configs) => Arr.some(configs, (config) => "animate" in config);
|
|
1894
|
+
/**
|
|
1895
|
+
* One plain rune's keys, for its ward's Features to be found by. As they read, an accessor's as its
|
|
1896
|
+
* result, for a ward a presence may take by its `animate`: such a ward was joined in case one did,
|
|
1897
|
+
* and its Features found that way, so a colour only `colors` reads was found in an `animate` that's
|
|
1898
|
+
* an accessor (HY6). Any other is read as it's written, as it was.
|
|
1899
|
+
*/
|
|
1900
|
+
const featureKeysOf = (only, open) => () => {
|
|
1901
|
+
if (open && animates([only]))
|
|
1902
|
+
return asReadOf(only);
|
|
1903
|
+
return only;
|
|
1904
|
+
};
|
|
1905
|
+
/** Whether a ward's runes give it an `exit` to leave to. */
|
|
1906
|
+
const exits = (configs) => Arr.some(configs, (config) => "exit" in config);
|
|
1907
|
+
/** Whether an `exit` is one to leave to: given, and not `false`, which is no exit as `show`'s wiring reads it, though the key's type doesn't name it. */
|
|
1908
|
+
const isAnExit = /*#__PURE__*/ Predicate.and(Predicate.isNotUndefined, (exit) => exit !== false);
|
|
1909
|
+
/** Whether a rune written as a config gives an `exit` of its own: a follower's that its leader runs (Q12). */
|
|
1910
|
+
const ownExit = (rune) => {
|
|
1911
|
+
if (isFunctionRune(rune))
|
|
1912
|
+
return false;
|
|
1913
|
+
return isAnExit(rune.exit);
|
|
1914
|
+
};
|
|
1915
|
+
/**
|
|
1916
|
+
* The runes a presence takes a ward by (`takenLater`), given when it does: none for a ward with
|
|
1917
|
+
* neither an `animate` to leave from nor an `exit` to leave to, which leaves at once. One with an
|
|
1918
|
+
* `exit` alone leaves by it (Q16): it was dropped at once, its exit never run.
|
|
1919
|
+
*/
|
|
1920
|
+
const takingOf = (configs, joinedNow) => {
|
|
1921
|
+
if (!animates(configs) && !exits(configs))
|
|
1922
|
+
return undefined;
|
|
1923
|
+
return joinedNow;
|
|
1924
|
+
};
|
|
1925
|
+
// Module state (#460, Q7): in development, each ward whose runes name no state as they're written (the
|
|
1926
|
+
// follow grill's Q2), held weakly: what a ward that follows one is warned of. A ward is its own request's.
|
|
1927
|
+
const NAMING_NOTHING = new WeakSet();
|
|
1928
|
+
// Module state (#460, Q7): in development, each leader a follower has been warned of already, held weakly:
|
|
1929
|
+
// once a leader, however many follow it (Q6). A ward is its own request's.
|
|
1930
|
+
const WARNED_OF = new WeakSet();
|
|
1931
|
+
/** Development's word for a ward that follows one naming no state (Q2): it's made, and follows nothing. */
|
|
1932
|
+
const FOLLOWS_NOTHING = "createWard({ follow }): the ward it follows names no states, so there's nothing to follow; give it `variants`, or name its states in `animate`.";
|
|
1933
|
+
/** In development, the word for a ward following `leader` where `leader` names no state: once for that leader (Q2, Q6). */
|
|
1934
|
+
const warnIfFollowingNothing = (leader) => {
|
|
1935
|
+
if (Predicate.isUndefined(leader))
|
|
1936
|
+
return;
|
|
1937
|
+
if (!NAMING_NOTHING.has(leader))
|
|
1938
|
+
return;
|
|
1939
|
+
if (WARNED_OF.has(leader))
|
|
1940
|
+
return;
|
|
1941
|
+
WARNED_OF.add(leader);
|
|
1942
|
+
report("WARDIC_FOLLOW_LEADER_UNNAMED", FOLLOWS_NOTHING);
|
|
1943
|
+
};
|
|
1944
|
+
/**
|
|
1945
|
+
* `make`, warning in development when a ward with variants of its own follows one that names no state,
|
|
1946
|
+
* once for that leader (the follow grill's Q2, Q6 and Q12), on a server too. A leader is judged by its runes
|
|
1947
|
+
* as they're written: one that names its states through a function, a getter or a function rune may name
|
|
1948
|
+
* them, and is never warned of; a follower with no variants follows only to leave with it, and isn't. In a
|
|
1949
|
+
* production build, `make` as it is.
|
|
1950
|
+
*/
|
|
1951
|
+
const warnsFollowingNothing = (make) => {
|
|
1952
|
+
if (!DEV)
|
|
1953
|
+
return make;
|
|
1954
|
+
return ((...written) => {
|
|
1955
|
+
// A follower with variants of its own, none of which can be chosen (Q12): one with none follows only to leave with it.
|
|
1956
|
+
if (hasOwnVariants(written))
|
|
1957
|
+
warnIfFollowingNothing(knownBeforeFunctionRunes(written, "follow"));
|
|
1958
|
+
const ward = make(...written);
|
|
1959
|
+
if (namesNothing(written))
|
|
1960
|
+
NAMING_NOTHING.add(ward);
|
|
1961
|
+
return ward;
|
|
1962
|
+
});
|
|
1963
|
+
};
|
|
1964
|
+
/** `internal`, its ward in `group` where a rune gives it one: as it is where none does. */
|
|
1965
|
+
const groupedIn = (internal, group) => {
|
|
1966
|
+
if (Predicate.isUndefined(group))
|
|
1967
|
+
return internal;
|
|
1968
|
+
return { ...internal, layoutGroup: group };
|
|
1969
|
+
};
|
|
1970
|
+
/** `createWard(...runes)`, each ward's Features from `begin`; `open` for one a presence may take. */
|
|
1971
|
+
const wardOf = (begin, open) => ownerChecked(warnsFollowingNothing(wardMakerOf(begin, open)));
|
|
1972
|
+
/**
|
|
1973
|
+
* `make`, refusing in development a ward made with no owner, outside a component or a root (step 2 of the
|
|
1974
|
+
* skill grill's order, Q20): it fails then anyway, on Solid's own error, which names neither the call nor
|
|
1975
|
+
* the fix. In a production build, `make` as it is.
|
|
1976
|
+
*/
|
|
1977
|
+
const ownerChecked = (make) => {
|
|
1978
|
+
if (!DEV)
|
|
1979
|
+
return make;
|
|
1980
|
+
return ((...runes) => {
|
|
1981
|
+
if (Predicate.isNull(getOwner()))
|
|
1982
|
+
throw misuse("WARDIC_WARD_WITHOUT_OWNER", WITHOUT_OWNER);
|
|
1983
|
+
return make(...runes);
|
|
1984
|
+
});
|
|
1985
|
+
};
|
|
1986
|
+
const WITHOUT_OWNER = "createWard: a ward was made with no owner, outside a component or a root, where nothing would end it. Make it in the component that draws its Subject.";
|
|
1987
|
+
/** {@link wardOf}'s maker, without development's word on a ward following one that names nothing. */
|
|
1988
|
+
const wardMakerOf = (begin, open) => (...written) => {
|
|
1989
|
+
// Each rune fixed as the ward is made of it (`fixedRunes`): its keys are the ones it has now,
|
|
1990
|
+
// and a plain value in it can't change. One `createRune` made is fixed already. Plain runes from
|
|
1991
|
+
// here: a tag types its runes' `ref` and `props` for its caller alone.
|
|
1992
|
+
const runes = fixedRunes(written);
|
|
1993
|
+
// The Layout group it's in, where a rune is one (the scopes round's Q44): found among its runes as
|
|
1994
|
+
// they're written, as fixing one copies it, and joined to the group around it here, where it's made.
|
|
1995
|
+
const group = layoutGroupIn(written);
|
|
1996
|
+
const begun = begin();
|
|
1997
|
+
const kind = begun.kind;
|
|
1998
|
+
const state = showState();
|
|
1999
|
+
// Read late: a presence that takes the ward gives it a state of its own. And heard, by whatever
|
|
2000
|
+
// reads before the ward's word has arrived: a function rune's body, a read made before a presence.
|
|
2001
|
+
const mounted = () => {
|
|
2002
|
+
hearing(state);
|
|
2003
|
+
return state.mounted();
|
|
2004
|
+
};
|
|
2005
|
+
const shown = () => {
|
|
2006
|
+
hearing(state);
|
|
2007
|
+
return state.shown();
|
|
2008
|
+
};
|
|
2009
|
+
/**
|
|
2010
|
+
* A ward with no `show`, as it's handed out. One a presence may take is taken by `taking`'s
|
|
2011
|
+
* runes, where it has an `animate` to leave by (`takenLater`); with none, it leaves at once. Its
|
|
2012
|
+
* runes' `ref`s, where its binding runs them, go by that presence's word once it does (`refs`).
|
|
2013
|
+
*/
|
|
2014
|
+
const plain = (ward, taking, refs) => {
|
|
2015
|
+
const made = withMounted(ward, mounted, shown);
|
|
2016
|
+
if (!open) {
|
|
2017
|
+
// No presence takes it, and it has no `show`: nothing more is to come.
|
|
2018
|
+
tell(state);
|
|
2019
|
+
return made;
|
|
2020
|
+
}
|
|
2021
|
+
// A follower leaves with its leader, and isn't one a leaving row takes as well (Q20); one with an
|
|
2022
|
+
// `exit` of its own is taken by its leader as it leaves, to run it (Q12).
|
|
2023
|
+
const leader = knownBeforeFunctionRunes(runes, "follow");
|
|
2024
|
+
if (Predicate.isNotUndefined(leader)) {
|
|
2025
|
+
FOLLOWING.add(made);
|
|
2026
|
+
followsOf(leader, { ward: made, exits: Arr.some(runes, ownExit) });
|
|
2027
|
+
}
|
|
2028
|
+
// Made under a presence: it hears its child's leave from it, its owner ended by then.
|
|
2029
|
+
if (!isServer)
|
|
2030
|
+
watchedUnder(made, ward, state);
|
|
2031
|
+
// What a presence would take it by, and nothing of how: that's `takenOf`'s.
|
|
2032
|
+
return takeable(made, ward, state, taking, refs);
|
|
2033
|
+
};
|
|
2034
|
+
// The two fast paths are a plain ward's: one its kind makes itself (a Reorder list's row, `reorder.ts`)
|
|
2035
|
+
// goes the way below, as `throughOf` sends it, so its maker makes it (the Reorder round's utilities: a
|
|
2036
|
+
// row of no rune, or of one plain rune, was made a plain ward).
|
|
2037
|
+
const plainKind = Predicate.isUndefined(begun.make);
|
|
2038
|
+
// No runes, no keys: it names no gesture.
|
|
2039
|
+
if (runes.length === 0 && plainKind)
|
|
2040
|
+
return plain(begun.made(checked(wardWith(NO_CONFIG, gesturelessKind(kind)))), undefined, undefined);
|
|
2041
|
+
// One plain rune is the ward's config as it is.
|
|
2042
|
+
if (runes.length === 1 && plainKind) {
|
|
2043
|
+
const only = runes[0];
|
|
2044
|
+
// Its runes are joined only if a presence takes it.
|
|
2045
|
+
// One that drags goes the way below, which gives it grips (probe: behaviour-runes).
|
|
2046
|
+
// One that gives settings of its own goes that way too, which lays them over the config around it,
|
|
2047
|
+
// and a layout group, which puts the ward in it.
|
|
2048
|
+
if (!isFunctionRune(only) && isPlainRune(only) && Bool.not(givesDrag(only)) && Bool.not(runeGivesSettings(only)) && Predicate.isUndefined(group)) {
|
|
2049
|
+
begun.config(featureKeysOf(only, open));
|
|
2050
|
+
// Its runes are its one config: the list of them is the one it was called with.
|
|
2051
|
+
const configs = runes;
|
|
2052
|
+
const told = gesturesTold(kind, kind, (key) => key in only);
|
|
2053
|
+
const ward = begun.made(wardFor(configs, () => checked(wardWith(only, told))));
|
|
2054
|
+
return plain(ward, takingOf(configs, () => joinedOf(begun, runes, configs, constUndefined)), undefined);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
// Whether any is a `createRune(fn)`: asked once here, where each step below asked it of them all.
|
|
2058
|
+
const anyFunction = Arr.some(runes, isFunctionRune);
|
|
2059
|
+
// Runes written plainly are read through as they're written, found in the one pass that reads
|
|
2060
|
+
// them. What else that pass saw of them (`seen`) says which of the steps below this ward needs:
|
|
2061
|
+
// each looked across the runes for itself, for every ward, and most wards need none of them.
|
|
2062
|
+
const through = throughOf(begun, runes, anyFunction);
|
|
2063
|
+
let seen;
|
|
2064
|
+
if (Predicate.isNotUndefined(through))
|
|
2065
|
+
seen = through.seen;
|
|
2066
|
+
// A rune read through follows nothing: one that follows is joined.
|
|
2067
|
+
let follow;
|
|
2068
|
+
if (Predicate.isUndefined(through))
|
|
2069
|
+
follow = followOf(runes);
|
|
2070
|
+
const options = UndefinedOr.map(follow, parentOptions);
|
|
2071
|
+
// Whether it's shown, where a plain rune says so, before any function rune reads it.
|
|
2072
|
+
if (anyFunction) {
|
|
2073
|
+
const known = knownBeforeFunctionRunes(runes, "show");
|
|
2074
|
+
if (Predicate.isNotUndefined(known))
|
|
2075
|
+
showingEarly(state, known);
|
|
2076
|
+
}
|
|
2077
|
+
// A createRune(fn)'s ward (probe: behaviour-runes, the ward split's Q6, Q8 and Q12): a holder, made
|
|
2078
|
+
// now, under this owner, before any rune runs. The finished ward adopts its lifecycle and drives it, so
|
|
2079
|
+
// its events, reads and gestures are that ward's, and it's no binding ward of its own: a second
|
|
2080
|
+
// `wardWith` a row was half of what a Reorder row allocated. Whether it's shown, mounted and leaving are
|
|
2081
|
+
// the finished ward's own accessors; its `drag`, `ward.drag`, is made at its first read. Gestureless,
|
|
2082
|
+
// as it never mounts an element of its own. Where every function rune reads nothing but its `drag`
|
|
2083
|
+
// (`dragOnly`, Wardic's `list.item`), a stand-in instead, which costs a row less than a holder (Q12):
|
|
2084
|
+
// anything else read of it is a holder's, made then, or the finished ward's once that's made.
|
|
2085
|
+
let handle;
|
|
2086
|
+
let holder;
|
|
2087
|
+
let finished;
|
|
2088
|
+
const holderNow = () => {
|
|
2089
|
+
if (Predicate.isUndefined(holder))
|
|
2090
|
+
holder = withMounted(begun.made(holderWard(groupedIn(gesturelessKind(internalsOf(options, kind)), group))), mounted, shown);
|
|
2091
|
+
return holder;
|
|
2092
|
+
};
|
|
2093
|
+
let configs = runes;
|
|
2094
|
+
if (anyFunction) {
|
|
2095
|
+
const standIn = Arr.every(runes, (rune) => Bool.or(Bool.not(isFunctionRune(rune)), isDragOnly(rune)));
|
|
2096
|
+
const given = Bool.match(standIn, {
|
|
2097
|
+
onTrue: () => runeWardOf(() => UndefinedOr.match(finished, { onUndefined: holderNow, onDefined: identity })),
|
|
2098
|
+
onFalse: () => withDrag(holderNow()),
|
|
2099
|
+
});
|
|
2100
|
+
handle = given;
|
|
2101
|
+
configs = runes.map((each) => {
|
|
2102
|
+
if (!isFunctionRune(each))
|
|
2103
|
+
return each;
|
|
2104
|
+
// Its config fixed once it's made, as a rune written as one is.
|
|
2105
|
+
return fixedRunes([functionOf(each)(given)])[0];
|
|
2106
|
+
});
|
|
2107
|
+
}
|
|
2108
|
+
// A `drag` given as an accessor by the last rune to give one: its gestures' axis, read at each one's
|
|
2109
|
+
// start (probe: behaviour-runes, Q6), and a later rune's `drag` the ward's (Q7).
|
|
2110
|
+
const axisAt = dragAccessorOf(configs);
|
|
2111
|
+
// What its runes heard of its drag, a behaviour's (probe: behaviour-runes): its keys make it a tab
|
|
2112
|
+
// stop, by a rune after its own that reads theirs, so an app's own `tabindex` wins and its ids come first.
|
|
2113
|
+
const behaviour = UndefinedOr.match(handle, { onUndefined: constUndefined, onDefined: siteIfAny });
|
|
2114
|
+
let site = behaviour;
|
|
2115
|
+
if (Predicate.isNotUndefined(site)) {
|
|
2116
|
+
const keys = keysRuneOf(site, configs);
|
|
2117
|
+
if (Predicate.isNotUndefined(keys))
|
|
2118
|
+
configs = [...configs, keys];
|
|
2119
|
+
}
|
|
2120
|
+
// A function rune's config, once it's called, is fixed as a plain rune's is: read through as one, where
|
|
2121
|
+
// the ward's runes can be (probe: behaviour-runes, the speed step: the join was a behaviour's row's
|
|
2122
|
+
// largest cost left). What has to be joined is joined as a plain rune's is (`readThroughOf`): one that
|
|
2123
|
+
// follows or times its followers, whose variants need joining, or that gives a callback beside the source.
|
|
2124
|
+
let readThrough = through;
|
|
2125
|
+
if (Bool.and(anyFunction, plainKind)) {
|
|
2126
|
+
readThrough = readThroughOf(configs);
|
|
2127
|
+
if (Predicate.isNotUndefined(readThrough))
|
|
2128
|
+
seen = readThrough.seen;
|
|
2129
|
+
}
|
|
2130
|
+
// Wired for its own `show` alone. A ward a presence takes is wired as it's taken (`takenLater`).
|
|
2131
|
+
const made = madeBy(readThrough, configs, showing(state));
|
|
2132
|
+
begun.config(made.asRead);
|
|
2133
|
+
// A behaviour that reads `ward.drag` asks for the drag Feature, whose input its keys are heard by (Q5).
|
|
2134
|
+
if (Predicate.isNotUndefined(behaviour))
|
|
2135
|
+
UndefinedOr.map(begun.want, (want) => want(DRAG_WANTED));
|
|
2136
|
+
let internal = internalsOf(options, kind);
|
|
2137
|
+
// Driving its function runes' holder, where it has one: that holder's lifecycle is this one's.
|
|
2138
|
+
if (Predicate.isNotUndefined(holder))
|
|
2139
|
+
internal = { ...kind, name: NAME, share: shareOf(holder) };
|
|
2140
|
+
// In the layout group a rune gives it, where one does: a holder's is that group too.
|
|
2141
|
+
internal = groupedIn(internal, group);
|
|
2142
|
+
// A behaviour's drag (probe: behaviour-runes): its samples, its node and its input heard; its
|
|
2143
|
+
// `lifted` raising it (Q9); its axis read per gesture (Q6); development's word on no drag (Q19). A
|
|
2144
|
+
// ward that drags has grips (Q14), its site made for them where no behaviour made one.
|
|
2145
|
+
// Its `drag` as its runes join it, whichever gives it: read through, the config is the source rune alone,
|
|
2146
|
+
// whose `drag` isn't another rune's (the speed step's review).
|
|
2147
|
+
const dragRead = UndefinedOr.match(axisAt, { onUndefined: () => () => made.value("drag"), onDefined: identity });
|
|
2148
|
+
if (drags(axisAt, dragRead)) {
|
|
2149
|
+
if (Predicate.isUndefined(site))
|
|
2150
|
+
site = makeSite();
|
|
2151
|
+
withGrips(site, dragAxisOf(dragRead));
|
|
2152
|
+
}
|
|
2153
|
+
if (Predicate.isNotUndefined(site))
|
|
2154
|
+
internal = { ...internal, ...siteInternalsOf(site) };
|
|
2155
|
+
// At its first settle (Q19), so a listener its runes add later is counted too. In a browser alone: a
|
|
2156
|
+
// server's settled effect takes a hydration id the client's doesn't (KH9).
|
|
2157
|
+
if (DEV && !isServer && Predicate.isNotUndefined(behaviour))
|
|
2158
|
+
onSettledClientOnly(() => warnIfUndragged(behaviour, made.has("drag")));
|
|
2159
|
+
const lifted = liftedOf(made.own("lifted"));
|
|
2160
|
+
if (Predicate.isNotUndefined(lifted))
|
|
2161
|
+
internal = { ...internal, lifted, raiseWhileDragged: true, onLayoutHandle: bothHandles(internal.onLayoutHandle, raiseOf(lifted)) };
|
|
2162
|
+
if (Predicate.isNotUndefined(axisAt))
|
|
2163
|
+
internal = { ...internal, dragAxis: dragAxisAt(axisAt) };
|
|
2164
|
+
// A follower that names a gesture of its own: a Variant child by its own word, which core is told (Q26).
|
|
2165
|
+
if (made.variantChild)
|
|
2166
|
+
internal = { ...internal, variantChild: true };
|
|
2167
|
+
// Its own settings, where its runes give any (the scopes round's Q10): laid over the config around it,
|
|
2168
|
+
// and read by the base ward in that config's place.
|
|
2169
|
+
if (givesSettings(made.has))
|
|
2170
|
+
internal = { ...internal, wardicConfig: settingsOver(useWardicConfig(), made.value) };
|
|
2171
|
+
// A rune read through as it's written: its wired keys are fixed over it.
|
|
2172
|
+
internal = wiredOver(internal, made.wired);
|
|
2173
|
+
// Naming no gesture, it makes nothing to watch for one until a first want (#525's `gestureless`).
|
|
2174
|
+
internal = gesturesTold(internal, kind, made.has);
|
|
2175
|
+
// Its Subject's tag, where a rune names it (the gap grill's Q22): what its attribute keys render by.
|
|
2176
|
+
if (sawOf(seen, SEEN.tag))
|
|
2177
|
+
internal = taggedOf(internal, configs);
|
|
2178
|
+
// Given its Subject: the one element it is, whose own tag it's routed by (Q23). In a browser alone.
|
|
2179
|
+
let onto;
|
|
2180
|
+
if (!isServer && sawOf(seen, SEEN.subject)) {
|
|
2181
|
+
const subject = made.own("subject");
|
|
2182
|
+
if (Predicate.isNotUndefined(subject)) {
|
|
2183
|
+
onto = subjectElementOf(subject);
|
|
2184
|
+
internal = elementTagged(internal, onto);
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
// What its runes' `props` set on its Subject, name by name (`props.ts`): none where no rune has any.
|
|
2188
|
+
let given = NO_PROP_KEYS;
|
|
2189
|
+
if (sawOf(seen, SEEN.props))
|
|
2190
|
+
given = propKeysOf(runePropsOf(configs));
|
|
2191
|
+
// Each rune's `ref`, handed its Subject, the element it's on, while that's on show. With no `show`,
|
|
2192
|
+
// its binding runs them as it mounts that element and lets it go (the cheap `ref`), until a
|
|
2193
|
+
// presence takes it; a `show` ward's go by its `show`.
|
|
2194
|
+
const refs = refsIn(seen, configs);
|
|
2195
|
+
const atMount = mountedRefsFor(refs, made.show, mounted);
|
|
2196
|
+
if (Predicate.isNotUndefined(atMount))
|
|
2197
|
+
internal = { ...internal, afterMount: afterMountOf(atMount) };
|
|
2198
|
+
const ward = begun.made(wardFor(configs, () => {
|
|
2199
|
+
const bound = bindingWardOf(begun, made.config, internal, given);
|
|
2200
|
+
// Made with the ward, under its own root where it has one (a `layoutId` twin's), so they're
|
|
2201
|
+
// undone as the ward ends: a twin's as the leaving ward that holds it ends it, its element
|
|
2202
|
+
// still there.
|
|
2203
|
+
if (Predicate.isNotUndefined(refs)) {
|
|
2204
|
+
UndefinedOr.match(atMount, {
|
|
2205
|
+
onUndefined: () => refsAtWork(refs, bound, mounted),
|
|
2206
|
+
onDefined: (at) => {
|
|
2207
|
+
at.owner = getOwner();
|
|
2208
|
+
},
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
return checked(bound);
|
|
2212
|
+
}, seen));
|
|
2213
|
+
// Its function runes' holder reads this one's element for its focus (`reads.ts`), and hands on to it
|
|
2214
|
+
// what only this one has; a stand-in reads it from here on.
|
|
2215
|
+
finished = ward;
|
|
2216
|
+
if (Predicate.isNotUndefined(holder)) {
|
|
2217
|
+
drivenBy(holder, ward);
|
|
2218
|
+
holderFinished(holder, ward);
|
|
2219
|
+
}
|
|
2220
|
+
// Its site kept by the ward it hands back, for `createGrip(ward)` (probe: behaviour-runes).
|
|
2221
|
+
if (Predicate.isNotUndefined(site))
|
|
2222
|
+
siteKeptFor(ward, site);
|
|
2223
|
+
// Those of them the binding doesn't set itself are carried on its spread, a server's too, and by
|
|
2224
|
+
// what `ward.with()` gives. Before anything spreads it.
|
|
2225
|
+
let propKeys = given;
|
|
2226
|
+
if (given !== NO_PROP_KEYS) {
|
|
2227
|
+
propKeys = addedTo(ward, given);
|
|
2228
|
+
withCarrying(carrying(ward, propKeys), propKeys);
|
|
2229
|
+
}
|
|
2230
|
+
// Given its Subject, it's put on that element here: nothing spreads it.
|
|
2231
|
+
if (Predicate.isNotUndefined(onto))
|
|
2232
|
+
putOn(ward, onto, propKeys);
|
|
2233
|
+
if (Predicate.isNotUndefined(made.show)) {
|
|
2234
|
+
// Its exits are told by the one effect its place in the layout has: they go by the same two
|
|
2235
|
+
// things, whether it's shown and whether it's mounted.
|
|
2236
|
+
const settle = exitsOf(ward);
|
|
2237
|
+
wiredFor(ward, state, made, settle);
|
|
2238
|
+
exitsBy(ward, () => settle({ shown: untrack(state.shown), on: untrack(state.onPage) }));
|
|
2239
|
+
showIs(ward, state);
|
|
2240
|
+
// Its word is its `show`, here now. What a function rune read before it is told, unless what
|
|
2241
|
+
// it read was this `show` already, wired early: that read was right, and follows it.
|
|
2242
|
+
if (Predicate.isUndefined(wiredEarlyFor(state, made.show)))
|
|
2243
|
+
tell(state);
|
|
2244
|
+
state.awaited = false;
|
|
2245
|
+
return withMounted(ward, mounted, shown);
|
|
2246
|
+
}
|
|
2247
|
+
// No `show` of its own: a presence may take it, by the runes it was made of, where one gives it
|
|
2248
|
+
// an `animate` to leave from or an `exit` to leave to.
|
|
2249
|
+
let taking;
|
|
2250
|
+
if (sawOf(seen, SEEN.animate | SEEN.exit))
|
|
2251
|
+
taking = takingOf(configs, () => made);
|
|
2252
|
+
return plain(ward, taking, atMount);
|
|
2253
|
+
};
|
|
2254
|
+
/** `createWard(...runes)` as a list's rows are made, each ward's Features from `begin`: {@link fixed}'s, or {@link auto}. */
|
|
2255
|
+
export const rawWardOf = (begin) => wardOf(begin, false);
|
|
2256
|
+
/** `createWard(...runes)` as an app calls it: a ward a `createPresence` may be given. */
|
|
2257
|
+
export const hookWardOf = (begin) => wardOf(begin, true);
|
|
2258
|
+
//# sourceMappingURL=ward.js.map
|