@wardic/solid 2.2.0 → 3.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -18
- package/dist/browser/config-view.js +33 -5
- package/dist/browser/config-view.js.map +1 -1
- package/dist/browser/create-batch.js +1 -1
- package/dist/browser/element-style.js +61 -7
- package/dist/browser/element-style.js.map +1 -1
- package/dist/browser/element.js +19 -2
- 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/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 +632 -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 +87 -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 +268 -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 +799 -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 +2193 -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 +562 -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 +85 -70
- 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 +46 -274
- package/dist/browser/reorder.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 +576 -49
- 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/config-view.js +33 -5
- package/dist/server/config-view.js.map +1 -1
- package/dist/server/create-batch.js +1 -1
- package/dist/server/element-style.js +61 -7
- package/dist/server/element-style.js.map +1 -1
- package/dist/server/element.js +19 -2
- 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/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 +632 -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 +86 -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 +308 -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 +799 -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 +2193 -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 +562 -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 +86 -80
- 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 +46 -344
- package/dist/server/reorder.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 +576 -49
- 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/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 +29 -6
- package/dist/solid/config-view.js.map +1 -1
- package/dist/solid/create-batch.jsx +1 -1
- 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 +21 -2
- 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/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 +585 -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 +62 -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 +273 -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 +816 -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 +2237 -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 +522 -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 +86 -62
- 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 +40 -202
- package/dist/solid/reorder.jsx.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 +546 -48
- 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 +26 -6
- package/src/batch-reorder-group.tsx +1 -1
- package/src/batch-reorder.ts +1 -1
- package/src/config-view.ts +30 -6
- package/src/create-batch.tsx +1 -1
- package/src/element-style.ts +77 -9
- package/src/element.tsx +25 -4
- package/src/feature-section.ts +5 -15
- 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 +740 -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 +155 -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 +321 -0
- package/src/hooks/reorder.ts +205 -0
- package/src/hooks/rune.ts +1755 -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 +2563 -0
- package/src/hooks/wardic-provider.tsx +51 -0
- package/src/hooks/wardic-scope.tsx +112 -0
- package/src/hooks/wards.ts +679 -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 +96 -71
- package/src/reorder-components.tsx +61 -0
- package/src/reorder.tsx +84 -303
- 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 +674 -48
- 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
package/src/ward.tsx
CHANGED
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
* @module
|
|
48
48
|
*/
|
|
49
49
|
import type * as Drag from "@wardic/core/Drag"
|
|
50
|
+
import * as InputSource from "@wardic/core/InputSource"
|
|
50
51
|
import type * as InputFeed from "@wardic/core/InputFeed"
|
|
51
52
|
import * as Press from "@wardic/dom/unstable/Press"
|
|
52
53
|
import * as Report from "@wardic/dom/Report"
|
|
@@ -79,6 +80,7 @@ import {
|
|
|
79
80
|
isHydrating,
|
|
80
81
|
type Owner,
|
|
81
82
|
onCleanup,
|
|
83
|
+
refresh,
|
|
82
84
|
runWithOwner,
|
|
83
85
|
type Signal,
|
|
84
86
|
untrack,
|
|
@@ -129,7 +131,7 @@ import * as Feature from "@wardic/dom/unstable/Feature"
|
|
|
129
131
|
import type * as All from "@wardic/dom/unstable/features/All"
|
|
130
132
|
import { CLIENT_ONLY, CLIENT_ONLY_DEFERRED, CLIENT_ONLY_SYNC, CLIENT_ONLY_SYNC_DEFERRED, firstCallOwnerHere, reactivityIn } from "./solid-reactivity.ts"
|
|
131
133
|
import { useWardicConfig } from "./wardic-config.tsx"
|
|
132
|
-
import { configView, type Fixed, type PerKey, type PerKeyApart } from "./config-view.ts"
|
|
134
|
+
import { configView, type Fixed, fixedOver, fixMore, type PerKey, type PerKeyApart } from "./config-view.ts"
|
|
133
135
|
import { type EventNeeds, Lifecycle, type WardEvent, type WardEvents, type WardPressInfo, type WardSettled } from "./lifecycle.ts"
|
|
134
136
|
import { neverLands, NO_EVENTS, serverWhen } from "./waiters.ts"
|
|
135
137
|
import { usePresenceContext } from "./presence.tsx"
|
|
@@ -148,6 +150,18 @@ export type WardStyle = { readonly [K in keyof DomWardConfig.WardicValues]?: Dom
|
|
|
148
150
|
/** The entry a missing Feature's message tells the app to import it from: this binding's (#566). */
|
|
149
151
|
const ENTRY = "@wardic/solid"
|
|
150
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Development's word on a missing Feature (#511), with how a Solid 2 app adds it: dom's default names
|
|
155
|
+
* `<LazyWardic>`, Solid 1's still, deleted from Solid 2 (probe: behaviour-runes, after the scopes round).
|
|
156
|
+
*/
|
|
157
|
+
const missingMessage = (feature: string, what: string): string =>
|
|
158
|
+
Feature.missingMessage(
|
|
159
|
+
feature,
|
|
160
|
+
what,
|
|
161
|
+
ENTRY,
|
|
162
|
+
`which this element's WardicProvider doesn't have. Add it: \`import { ${feature} } from "${ENTRY}"\`, then \`<WardicProvider features={[${feature}]}>\`, or give it to \`makeWard({ features })\`.`,
|
|
163
|
+
)
|
|
164
|
+
|
|
151
165
|
/** A ward's config values: the element's motion, and its `style`. */
|
|
152
166
|
export interface WardConfigValues extends Omit<DomWardConfig.WardConfig, SolidOneCallback> {
|
|
153
167
|
/**
|
|
@@ -312,11 +326,31 @@ interface WardState {
|
|
|
312
326
|
readonly element: Accessor<HTMLElement | undefined>
|
|
313
327
|
/** Reads its config's keys still loading at setup: a `held` read holds its boundary while one is (#884). */
|
|
314
328
|
readonly hold: () => void
|
|
329
|
+
/** Its config as it's written, before a Config transition or Animation controls are over it: where more is fixed later ({@link fixLater}). */
|
|
330
|
+
readonly written: WardConfigValues
|
|
331
|
+
/**
|
|
332
|
+
* Its target, worked out from its config: worked out again when more of that is fixed later ({@link targetAgain}).
|
|
333
|
+
* None for a function rune's ward ({@link holderWard}), which has no config.
|
|
334
|
+
*/
|
|
335
|
+
readonly target: Parameters<typeof refresh>[0] | undefined
|
|
336
|
+
/** The names it hands its Variant children, where it hands any down: read from its config's `animate` too, and read again with its target. */
|
|
337
|
+
readonly handsDown: Parameters<typeof refresh>[0] | undefined
|
|
338
|
+
/**
|
|
339
|
+
* What its exit resolves from under a presence above it, and how that's read of its config: read
|
|
340
|
+
* again with its target ({@link targetAgain}). No reader with no presence above it.
|
|
341
|
+
*/
|
|
342
|
+
readonly exitConfig: { current: Spine.ExitConfig }
|
|
343
|
+
readonly exitNow: (() => Spine.ExitConfig) | undefined
|
|
315
344
|
settled: Accessor<WardSettled | undefined> | undefined
|
|
316
345
|
tapped: Accessor<WardPressInfo | undefined> | undefined
|
|
317
346
|
next: (<E extends WardEvent>(name: E) => Promise<WardEvents[E]>) | undefined
|
|
318
347
|
each: (<E extends WardEvent>(name: E) => AsyncIterable<WardEvents[E]>) | undefined
|
|
319
348
|
when: (<E extends WardEvent>(name: E) => Accessor<WardEvents[E]>) | undefined
|
|
349
|
+
/**
|
|
350
|
+
* What the hooks keep of a ward they made (probe: hooks-first): theirs to write and to read, by
|
|
351
|
+
* the members they share ({@link shareMembers}). None for a ward they didn't make.
|
|
352
|
+
*/
|
|
353
|
+
hooks: unknown
|
|
320
354
|
}
|
|
321
355
|
|
|
322
356
|
/** Where a ward keeps its {@link WardState}: on itself, not enumerable, so a spread never sees it. */
|
|
@@ -407,7 +441,9 @@ const WARD_MEMBER_KEYS: PropertyDescriptorMap = {
|
|
|
407
441
|
return state.tapped
|
|
408
442
|
},
|
|
409
443
|
},
|
|
444
|
+
// `next`, `each` and `when` can be given again: the hooks' own take their place ({@link shareMembers}).
|
|
410
445
|
next: {
|
|
446
|
+
configurable: true,
|
|
411
447
|
get(this: object): NonNullable<WardState["next"]> {
|
|
412
448
|
const state = stateOf(this)
|
|
413
449
|
if (Predicate.isNotUndefined(state.next)) return state.next
|
|
@@ -418,6 +454,7 @@ const WARD_MEMBER_KEYS: PropertyDescriptorMap = {
|
|
|
418
454
|
},
|
|
419
455
|
},
|
|
420
456
|
each: {
|
|
457
|
+
configurable: true,
|
|
421
458
|
get(this: object): NonNullable<WardState["each"]> {
|
|
422
459
|
const state = stateOf(this)
|
|
423
460
|
if (Predicate.isNotUndefined(state.each)) return state.each
|
|
@@ -428,6 +465,7 @@ const WARD_MEMBER_KEYS: PropertyDescriptorMap = {
|
|
|
428
465
|
},
|
|
429
466
|
},
|
|
430
467
|
when: {
|
|
468
|
+
configurable: true,
|
|
431
469
|
get(this: object): NonNullable<WardState["when"]> {
|
|
432
470
|
const state = stateOf(this)
|
|
433
471
|
if (Predicate.isNotUndefined(state.when)) return state.when
|
|
@@ -439,9 +477,76 @@ const WARD_MEMBER_KEYS: PropertyDescriptorMap = {
|
|
|
439
477
|
},
|
|
440
478
|
}
|
|
441
479
|
|
|
442
|
-
/**
|
|
480
|
+
/**
|
|
481
|
+
* {@link WARD_MEMBER_KEYS} on one prototype over `Function.prototype`.
|
|
482
|
+
*
|
|
483
|
+
* Module state (#460, Q7): made once, and added to once more where the hooks are loaded
|
|
484
|
+
* ({@link shareMembers}), with their own members for every ward.
|
|
485
|
+
*/
|
|
443
486
|
const WARD_MEMBERS: object = /*#__PURE__*/ Object.create(Function.prototype, WARD_MEMBER_KEYS)
|
|
444
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Whether `ward` has a state of its own, as a client's has and a server's hasn't: where the hooks
|
|
490
|
+
* keep what they know of it (probe: hooks-first). True of nothing but a ward made here.
|
|
491
|
+
*/
|
|
492
|
+
export const keepsState = (ward: object): boolean => Predicate.hasProperty(ward, WARD_STATE)
|
|
493
|
+
|
|
494
|
+
/** What the hooks keep of `ward`, one with a state of its own ({@link keepsState}): none until they've kept something. */
|
|
495
|
+
export const hooksOf = (ward: object): unknown => stateOf(ward).hooks
|
|
496
|
+
|
|
497
|
+
/** Keeps `kept` of `ward` for the hooks, one with a state of its own ({@link keepsState}). */
|
|
498
|
+
export const keepForHooks = (ward: object, kept: unknown): void => {
|
|
499
|
+
stateOf(ward).hooks = kept
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Fixes more of `ward`'s config from here on (probe: hooks-first), a ward with a state of its own:
|
|
504
|
+
* what a presence that takes it after it's made has its `animate`, `exit` and `custom` read
|
|
505
|
+
* through, with nothing set up for it on a ward no presence takes. Read in the config's place at
|
|
506
|
+
* the next read of each key; {@link targetAgain} makes that read happen.
|
|
507
|
+
*/
|
|
508
|
+
export const fixLater = (ward: object, fixed: Readonly<Record<string, unknown>>): void => {
|
|
509
|
+
fixMore(stateOf(ward).written, fixed as Fixed<WardConfigValues>)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Works `ward`'s target out again (probe: hooks-first): after {@link fixLater}, since what read those
|
|
514
|
+
* keys read them before they were fixed, and follows nothing that says so. From then on it follows
|
|
515
|
+
* whatever the fixed values read. Not in a component's body or a computation, where Solid allows no
|
|
516
|
+
* refresh: at the settle.
|
|
517
|
+
*/
|
|
518
|
+
export const targetAgain = (ward: object): void => {
|
|
519
|
+
const state = stateOf(ward)
|
|
520
|
+
const target = state.target
|
|
521
|
+
if (Predicate.isNotUndefined(target)) void refresh(target)
|
|
522
|
+
// The names it hands its followers come from its `animate` too: a leader a presence takes hands
|
|
523
|
+
// down the name it leaves by.
|
|
524
|
+
const handsDown = state.handsDown
|
|
525
|
+
if (Predicate.isNotUndefined(handsDown)) void refresh(handsDown)
|
|
526
|
+
// And what a presence above it leaves it by: its `exit`, kept current by an effect that read it
|
|
527
|
+
// before more was fixed, and isn't told. A ward a presence of the hooks takes keeps its `exit` for
|
|
528
|
+
// that presence, so one above it runs none for it (HP30). Read here; the effect follows whatever it
|
|
529
|
+
// followed, and reads through what's fixed the next time it runs.
|
|
530
|
+
const exitNow = state.exitNow
|
|
531
|
+
if (Predicate.isNotUndefined(exitNow)) state.exitConfig.current = untrack(exitNow)
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* More members for the prototype every client ward shares (probe: hooks-first): the hooks' own, a
|
|
536
|
+
* ward's reads and whether it's shown, given once as the hooks load. Each a getter over what the
|
|
537
|
+
* hooks keep of the ward ({@link hooksOf}), as the members here are over its state, so a ward
|
|
538
|
+
* carries nothing for them. One given a name that's here already takes its place.
|
|
539
|
+
*/
|
|
540
|
+
export const shareMembers = (keys: PropertyDescriptorMap): void => {
|
|
541
|
+
Object.defineProperties(WARD_MEMBERS, keys)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/** A member every client ward shares, as it's read of `ward`: for one that takes its place for some wards ({@link shareMembers}). */
|
|
545
|
+
export const sharedMember = (name: "when" | "next" | "each"): ((this: object) => (event: string) => unknown) => {
|
|
546
|
+
const descriptor = Object.getOwnPropertyDescriptor(WARD_MEMBERS, name) as PropertyDescriptor
|
|
547
|
+
return descriptor.get as (this: object) => (event: string) => unknown
|
|
548
|
+
}
|
|
549
|
+
|
|
445
550
|
/** `ward(config, options)`'s options. */
|
|
446
551
|
export interface WardOptions {
|
|
447
552
|
/**
|
|
@@ -611,6 +716,11 @@ export interface WardInternals {
|
|
|
611
716
|
readonly onLayoutHandle?: ((handle: ProjectionSystem.NodeHandle) => () => void) | undefined
|
|
612
717
|
/** A `<Reorder>` item's: its node raised while dragged. */
|
|
613
718
|
readonly raiseWhileDragged?: boolean | undefined
|
|
719
|
+
/**
|
|
720
|
+
* A hooks ward's grips' (probe: behaviour-runes): which of its presses drag it, asked of each down, over
|
|
721
|
+
* its config's `dragListener`: a press on one of its grips while it has any, and any while it has none.
|
|
722
|
+
*/
|
|
723
|
+
readonly dragListen?: ((down: InputSource.PointerLikeEvent) => boolean) | undefined
|
|
614
724
|
/** A `<Reorder>` item's: its Enter and Space are its **Keyboard reorder**'s (ADR-0037), so its press hears no keys (#427). */
|
|
615
725
|
readonly keysTaken?: boolean | undefined
|
|
616
726
|
/** A `<Reorder>` item's: whether a **Keyboard reorder** has it lifted (ADR-0037), which turns its `whileDrag` on. */
|
|
@@ -622,7 +732,23 @@ export interface WardInternals {
|
|
|
622
732
|
* `onDefect`: closed at the unmount. What it returns is called at unmount.
|
|
623
733
|
*/
|
|
624
734
|
readonly onMount?: ((element: HTMLElement, watch: (make: (onDefect: InputFeed.OnDefect) => Effect.Effect<void, never, Scope.Scope | WardicServices>) => void) => () => void) | undefined
|
|
625
|
-
/**
|
|
735
|
+
/**
|
|
736
|
+
* A hooks ward's: told the element once it's mounted, its first Retarget done (probe: behaviour-runes,
|
|
737
|
+
* the cheap `ref`). Outside `untrack`, so a signal read there is one Solid reports, and after the mount
|
|
738
|
+
* is kept, so a throw there leaves nothing of it unended. What it returns is called at unmount, once
|
|
739
|
+
* the binding's own end has run: before the next element's, or after its lifecycle's end.
|
|
740
|
+
*/
|
|
741
|
+
readonly afterMount?: ((element: HTMLElement) => () => void) | undefined
|
|
742
|
+
/**
|
|
743
|
+
* Told the element and its gestures' input once both are there (probe: behaviour-runes): at its
|
|
744
|
+
* mount, or as a gesture Feature that brings the input arrives after it. Once a mount, with how to run
|
|
745
|
+
* a watch in its watch Scope and how to fork a response: a behaviour's keys, blur and press.
|
|
746
|
+
*/
|
|
747
|
+
readonly onInput?: ((element: HTMLElement, input: InputSource.InputSource["Service"], watch: (make: (onDefect: InputFeed.OnDefect) => Effect.Effect<void, never, Scope.Scope | WardicServices>) => void, fork: (effect: Effect.Effect<void>) => void, runtime: WardicRuntime) => void) | undefined
|
|
748
|
+
/**
|
|
749
|
+
* Values fixed over the config's, read as its own are: a `<Reorder>` item's `layout`, its Layout mode.
|
|
750
|
+
* More is fixed over a ward that's made with {@link fixLater}.
|
|
751
|
+
*/
|
|
626
752
|
readonly fixed?: Fixed<WardConfigValues> | undefined
|
|
627
753
|
/** A `<Reorder>` item's group, which `Reorder.Item` checks a given item against (#349). */
|
|
628
754
|
readonly group?: unknown
|
|
@@ -641,6 +767,62 @@ export interface WardInternals {
|
|
|
641
767
|
readonly instance?: Feature.InstanceFeatures | undefined
|
|
642
768
|
/** Whether it's a **Complete element** (#511): an error in development under a `strict` section. */
|
|
643
769
|
readonly complete?: boolean | undefined
|
|
770
|
+
/**
|
|
771
|
+
* Told each target it runs, as resolved, just before it's run: for a ward that asks for its Features
|
|
772
|
+
* as it uses them (the hooks' `auto`), so a colour only the `colors` Feature reads, shown by an
|
|
773
|
+
* accessor only after the ward is made, still asks for it (the scopes round's CL1).
|
|
774
|
+
*/
|
|
775
|
+
readonly targeted?: ((values: Readonly<Record<string, unknown>>) => void) | undefined
|
|
776
|
+
/**
|
|
777
|
+
* Its own settings over the config around it (probe: behaviour-runes, the scopes round's Q10): a hook
|
|
778
|
+
* ward's `reducedMotion`, `skipAnimations` and `transformPagePoint`, laid over its nearest
|
|
779
|
+
* `WardicConfig`'s and read in its place. None for a ward that gives none of them.
|
|
780
|
+
*/
|
|
781
|
+
readonly wardicConfig?: WardicConfigValue.WardicConfigValue | undefined
|
|
782
|
+
/**
|
|
783
|
+
* The **Layout group** its `layoutId` goes in, where its maker chose one (probe: behaviour-runes, the
|
|
784
|
+
* scopes round's Q44): a hook ward given a layout group as a rune, its id resolved where the ward is
|
|
785
|
+
* made. Read in place of the group around it. None, and it's in the one it's made in.
|
|
786
|
+
*/
|
|
787
|
+
readonly layoutGroup?: { readonly id: string | undefined } | undefined
|
|
788
|
+
/**
|
|
789
|
+
* Whether an element given to it now enters afresh, from its config's `initial` as it is then, as
|
|
790
|
+
* one given after the last left the page does (#414). The hooks' presence (probe: hooks-first), for
|
|
791
|
+
* a value that came after the page opened or after another: read as its ref is called, of the ward
|
|
792
|
+
* itself, so one function answers for every ward and none is made ward by ward.
|
|
793
|
+
*/
|
|
794
|
+
readonly entersFresh?: ((ward: object) => boolean) | undefined
|
|
795
|
+
/**
|
|
796
|
+
* Told each element it's handed, as Solid calls it as a ref (probe: hooks-first): how the hooks keep
|
|
797
|
+
* which ward each element was last handed to, for a leaving row to find the wards inside it. Left out,
|
|
798
|
+
* nothing is told, and a component's ward keeps nothing for it.
|
|
799
|
+
*/
|
|
800
|
+
readonly handed?: ((element: Element, ward: Ward) => void) | undefined
|
|
801
|
+
/**
|
|
802
|
+
* Told the presence it's made under, where there's one (probe: hooks-first): what a hook ward watches
|
|
803
|
+
* its child's leave by, found where the ward looks it up already. Left out, nothing is told.
|
|
804
|
+
*/
|
|
805
|
+
readonly madeUnder?: ((ward: Ward, presence: PresenceRecord.PresenceContextValue<Element>) => void) | undefined
|
|
806
|
+
/**
|
|
807
|
+
* Told, in development alone, each time an element's props first read the ward's `style` (probe:
|
|
808
|
+
* hooks-first, the gap grill's Q29): how the hooks see a ward spread on a component that never calls
|
|
809
|
+
* its `ref`. Left out, or in a production build, nothing is told.
|
|
810
|
+
*/
|
|
811
|
+
readonly styled?: ((ward: Ward) => void) | undefined
|
|
812
|
+
/**
|
|
813
|
+
* Whether the ward is a **Variant child** by its own word (probe: hooks-first, the gap grill's Q26):
|
|
814
|
+
* core's `variantChild`, set on the config its variant node and spine read, so a follower naming
|
|
815
|
+
* gesture variants of its own still joins the ward it follows, and hands its names down. Left out,
|
|
816
|
+
* nothing is set.
|
|
817
|
+
*/
|
|
818
|
+
readonly variantChild?: boolean | undefined
|
|
819
|
+
/**
|
|
820
|
+
* Whether it carries its variants whatever its config sets (probe: behaviour-runes, the follow grill's
|
|
821
|
+
* Q1): a hook ward's. Its config is all its runes, so its own variant node is always the one a ward
|
|
822
|
+
* that follows it joins, however it names its states, and it's never a **Listening ward** (#398), whose
|
|
823
|
+
* element builds a node of its own from its props. Left out, it carries them by its config alone.
|
|
824
|
+
*/
|
|
825
|
+
readonly carries?: boolean | undefined
|
|
644
826
|
}
|
|
645
827
|
|
|
646
828
|
|
|
@@ -655,6 +837,12 @@ export interface WardShare {
|
|
|
655
837
|
readonly setup: WardConfigValues
|
|
656
838
|
/** What made it adds (a `<Reorder>` item's), and its parent. */
|
|
657
839
|
readonly internal: WardInternals
|
|
840
|
+
/**
|
|
841
|
+
* What's fixed over its config as it is now: what made it fixed (`internal.fixed`), and whatever
|
|
842
|
+
* was fixed over it since ({@link fixLater}). A ward driving an element for it reads through the
|
|
843
|
+
* same: a ward a presence of the hooks took leaves by its `animate` on a component too (HP31).
|
|
844
|
+
*/
|
|
845
|
+
readonly fixed: () => WardInternals["fixed"]
|
|
658
846
|
/** The variant context it was made under, or its given parent's. */
|
|
659
847
|
readonly parent: VariantTree.WardicVariantContextValue | undefined
|
|
660
848
|
/** Whether its parent was given (`ward(config, { parent })`). */
|
|
@@ -769,7 +957,7 @@ const warnUnreadColors = (registry: Feature.FeatureRegistry, features: Feature.F
|
|
|
769
957
|
},
|
|
770
958
|
(unread) => {
|
|
771
959
|
if (Predicate.isUndefined(unread)) return
|
|
772
|
-
registry.warnOnce("colors",
|
|
960
|
+
registry.warnOnce("colors", missingMessage("colors", `The colour \`${unread}\``))
|
|
773
961
|
},
|
|
774
962
|
CLIENT_ONLY,
|
|
775
963
|
)
|
|
@@ -778,20 +966,31 @@ const warnUnreadColors = (registry: Feature.FeatureRegistry, features: Feature.F
|
|
|
778
966
|
/** Whether a config carries its variants (#398): it sets `variants` or `inherit`. */
|
|
779
967
|
const carriesVariants = (config: WardConfigValues): boolean => Bool.or(Predicate.isNotUndefined(config.variants), Predicate.isNotUndefined(config.inherit))
|
|
780
968
|
|
|
969
|
+
/** Whether a ward made with `internal` and `config` carries its variants (#398): by its config, or by its maker's word (a hook ward's). */
|
|
970
|
+
const carriesFor = (internal: WardInternals, config: WardConfigValues): boolean => Bool.or(internal.carries === true, carriesVariants(config))
|
|
971
|
+
|
|
781
972
|
/** A child made with `{ parent }` naming a Listening ward (#398's Q10). */
|
|
782
973
|
const LISTENING_PARENT =
|
|
783
974
|
"ward(config, { parent }): the parent given carries no variants (no `variants` or `inherit` in its ward({ … })): it only listens, " +
|
|
784
975
|
"and its element's props hold its variants, so a child can't join it by `{ parent }` (#398). Render the child inside that " +
|
|
785
976
|
"ward's element, where it joins through the tree, or put the variants in the parent's ward({ … })."
|
|
786
977
|
|
|
978
|
+
/** The **Layout group** a ward made here with `internal` is in: its maker's choice, else the one around it. */
|
|
979
|
+
const groupOf = (internal: WardInternals): string | undefined => {
|
|
980
|
+
const chosen = internal.layoutGroup
|
|
981
|
+
if (Predicate.isNotUndefined(chosen)) return chosen.id
|
|
982
|
+
return useLayoutGroupId()
|
|
983
|
+
}
|
|
984
|
+
|
|
787
985
|
/**
|
|
788
986
|
* The **Layout group** a ward's `layoutId` goes in (#432): the one it's made in, as its presence and
|
|
789
|
-
* variant parent are; a driving ward's is its given ward's, where that was made,
|
|
790
|
-
* own props set the `layoutId` (#398), which is then the element's.
|
|
987
|
+
* variant parent are, or its maker's choice; a driving ward's is its given ward's, where that was made,
|
|
988
|
+
* unless the element's own props set the `layoutId` (#398), which is then the element's.
|
|
791
989
|
*/
|
|
792
|
-
const layoutGroupFor = (share: WardShare | undefined,
|
|
793
|
-
if (Predicate.isUndefined(share)) return
|
|
794
|
-
|
|
990
|
+
const layoutGroupFor = (share: WardShare | undefined, internal: WardInternals): string | undefined => {
|
|
991
|
+
if (Predicate.isUndefined(share)) return groupOf(internal)
|
|
992
|
+
const fixed = internal.fixed
|
|
993
|
+
if (Bool.and(Predicate.isNotUndefined(fixed), Predicate.hasProperty(fixed, "layoutId"))) return groupOf(internal)
|
|
795
994
|
return share.layoutGroup
|
|
796
995
|
}
|
|
797
996
|
|
|
@@ -861,6 +1060,13 @@ const controlsOf = (given: WardConfigValues, animate: WardConfigValues["animate"
|
|
|
861
1060
|
return { controls, view, change, set: (made) => setChange(() => made) }
|
|
862
1061
|
}
|
|
863
1062
|
|
|
1063
|
+
/** A ward's config settings: its own over its nearest `WardicConfig`'s, where it has any (`wardicConfig`), else that config's. */
|
|
1064
|
+
const configOf = (internal: WardInternals): WardicConfigValue.WardicConfigValue | undefined => {
|
|
1065
|
+
const own = internal.wardicConfig
|
|
1066
|
+
if (Predicate.isNotUndefined(own)) return own
|
|
1067
|
+
return useWardicConfig()
|
|
1068
|
+
}
|
|
1069
|
+
|
|
864
1070
|
/**
|
|
865
1071
|
* `view` with its **Config transition** as its own when it gives none (#434, Motion's
|
|
866
1072
|
* `{ ...config, ...props }`), read per read as its keys are; `view` itself with no `WardicConfig` above.
|
|
@@ -893,6 +1099,11 @@ const lifecycleOfShare = (share: WardShare): Lifecycle | undefined => share.life
|
|
|
893
1099
|
const runCleanup = (cleanup: () => void): void => cleanup()
|
|
894
1100
|
/** A mount's element. */
|
|
895
1101
|
const elementOfMount = (m: { readonly element: HTMLElement }): HTMLElement => m.element
|
|
1102
|
+
/** Where an element entering fresh starts (#414): its start, and the Starting style that draws it. */
|
|
1103
|
+
interface FreshStart {
|
|
1104
|
+
readonly from: Spine.Start
|
|
1105
|
+
readonly starting: Renderer.Patch
|
|
1106
|
+
}
|
|
896
1107
|
|
|
897
1108
|
/**
|
|
898
1109
|
* A ward mounting an element another ward left in the same task: a spread's expression
|
|
@@ -926,6 +1137,16 @@ const LOADING_NAMES: ReadonlyArray<string> = []
|
|
|
926
1137
|
* `animate` names the ward's own variants when it has `variants` (what it can name), and is a target
|
|
927
1138
|
* of values otherwise: setup reads it only to tell which.
|
|
928
1139
|
*/
|
|
1140
|
+
/**
|
|
1141
|
+
* `config` a **Variant child** by its own word, where its internals say so (probe: hooks-first, the
|
|
1142
|
+
* gap grill's Q26): core's `variantChild` set on the copy its variant decisions read. As it is for
|
|
1143
|
+
* every other ward, a component's among them.
|
|
1144
|
+
*/
|
|
1145
|
+
const variantChildBy = <C extends WardConfigValues>(internal: WardInternals, config: C): C => {
|
|
1146
|
+
if (internal.variantChild !== true) return config
|
|
1147
|
+
return { ...config, variantChild: true }
|
|
1148
|
+
}
|
|
1149
|
+
|
|
929
1150
|
export const configAtSetup = (setup: { readonly config: WardConfigValues; readonly pending: ReadonlyArray<string> }): WardConfigValues => {
|
|
930
1151
|
if (setup.pending.length === 0) return setup.config
|
|
931
1152
|
const fixed = Arr.findFirst(setup.pending, (key) => Bool.not(LOADS_AS_IT_GOES.has(key)))
|
|
@@ -952,6 +1173,7 @@ const layoutArrivedIn = (arrive: ((projection: ProjectionSystem.Shape) => void)
|
|
|
952
1173
|
UndefinedOr.map(arrive, (make) => UndefinedOr.map(Keys.projectionIn(services), make))
|
|
953
1174
|
}
|
|
954
1175
|
|
|
1176
|
+
|
|
955
1177
|
export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
956
1178
|
if (Predicate.isFunction(config)) throw new Error(WHOLE_ACCESSOR)
|
|
957
1179
|
const runtime = useWardicRuntime()
|
|
@@ -966,11 +1188,14 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
966
1188
|
const layoutProjection = Keys.projectionIn(untrack(features.services))
|
|
967
1189
|
// The provider's, once any section has built it: what its values register with.
|
|
968
1190
|
const builtProjection = useBuiltProjection()
|
|
969
|
-
|
|
1191
|
+
// Its config's settings: its own over its nearest WardicConfig's, where a hook ward gives any
|
|
1192
|
+
// (probe: behaviour-runes), else that config's.
|
|
1193
|
+
const wardicConfig = configOf(internal)
|
|
1194
|
+
const reducedMotion = useWardicReducedMotion(wardicConfig)
|
|
970
1195
|
// Whether its animations are skipped (#468): its nearest WardicConfig's, read as each starts.
|
|
971
|
-
const skipAnimations = useWardicSkipAnimations()
|
|
1196
|
+
const skipAnimations = useWardicSkipAnimations(wardicConfig)
|
|
972
1197
|
// Where its drag's and pan's points are (#443): its nearest WardicConfig's, read as each starts.
|
|
973
|
-
const pagePoint = WardicConfigValue.transformPagePointOf(
|
|
1198
|
+
const pagePoint = WardicConfigValue.transformPagePointOf(wardicConfig)
|
|
974
1199
|
const positionalKeys = useWardicPositionalKeys()
|
|
975
1200
|
const defaultTransition = useWardicDefaultTransition()
|
|
976
1201
|
// How a value is read in the Environment's own terms (#672).
|
|
@@ -987,7 +1212,8 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
987
1212
|
// Its config, read per key where it's read (#259): a change re-runs only what reads the key. With
|
|
988
1213
|
// Animation controls for its `animate` (#433), read once, each change they make is its entry.
|
|
989
1214
|
// Under a `WardicConfig`, its Config transition is its own when it gives none (#434).
|
|
990
|
-
const
|
|
1215
|
+
const written = WARD_VIEW.of(config, internal.fixed)
|
|
1216
|
+
const asGiven = configuredView(written, wardicConfig)
|
|
991
1217
|
// The config at setup, a plain copy read untracked: what setup reads, the keys read once among it.
|
|
992
1218
|
// A key still loading (#257 item 1) is left out of it: one the ward reads as it goes holds its
|
|
993
1219
|
// region until it lands; one setup fixes is an error, naming it. Its `animate` there tells
|
|
@@ -997,7 +1223,10 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
997
1223
|
const view = UndefinedOr.match(controls, { onUndefined: () => asGiven, onDefined: (c) => c.view })
|
|
998
1224
|
const cfg = (): WardConfigValues => view
|
|
999
1225
|
const setup = UndefinedOr.match(controls, { onUndefined: () => givenSetup, onDefined: () => WARD_VIEW.setupOf(view) })
|
|
1000
|
-
const initialConfig =
|
|
1226
|
+
const initialConfig = variantChildBy(
|
|
1227
|
+
internal,
|
|
1228
|
+
UndefinedOr.match(controls, { onUndefined: () => configAtSetup(setup), onDefined: () => AnimationControls.controlledConfigOf(configAtSetup(setup), undefined) }),
|
|
1229
|
+
)
|
|
1001
1230
|
// Its Animation controls' change (#433), read with the Override stack: none without them.
|
|
1002
1231
|
const ownChange = UndefinedOr.match(controls, { onUndefined: () => NO_CHANGE, onDefined: (c) => c.change })
|
|
1003
1232
|
|
|
@@ -1015,13 +1244,15 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1015
1244
|
// The nearest <AnimatePresence> (ADR-0007), or none.
|
|
1016
1245
|
const presence = usePresenceContext()
|
|
1017
1246
|
// The Layout group its `layoutId` goes in (#432): where it's made, or a given ward's.
|
|
1018
|
-
const layoutGroup = layoutGroupFor(share, internal
|
|
1247
|
+
const layoutGroup = layoutGroupFor(share, internal)
|
|
1019
1248
|
|
|
1020
1249
|
// The values it starts from, read once (ADR-0003): its `initial`, or the one it inherits, or its
|
|
1021
1250
|
// `animate` with `initial={false}` (its own, inherited, or its presence's first render, #134).
|
|
1022
1251
|
const presenceBlocks = PresenceRecord.presenceBlocksInitial(presence)
|
|
1023
1252
|
if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(initialConfig, node.inherited, presenceBlocks))) throw new Error(STARTS_AT_PENDING)
|
|
1024
|
-
|
|
1253
|
+
// Untracked as a whole: a target that's a store's (a store given as a hook's rune) is read here,
|
|
1254
|
+
// in the component's body, for its values now.
|
|
1255
|
+
const start = untrack(() => Spine.startOf(initialConfig, node.inherited, presenceBlocks, untrack))
|
|
1025
1256
|
// A variant whose resolver throws is this element's alone: reported once until it resolves, the element
|
|
1026
1257
|
// keeping its last target (#979; ADR-0074).
|
|
1027
1258
|
Spine.reportStart(variantFailures, start)
|
|
@@ -1076,15 +1307,25 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1076
1307
|
// last one left the page, as a mount after the first render's (no presence holds its `initial`
|
|
1077
1308
|
// back). Its Snapshot goes back to it, and its Starting style comes back on until its first commit.
|
|
1078
1309
|
let begun = start
|
|
1079
|
-
|
|
1080
|
-
|
|
1310
|
+
// A fresh start and the Starting style it draws, from the config now: a plain copy read untracked,
|
|
1311
|
+
// as setup reads it. Read in the mount effect, and by an element's first read of its style.
|
|
1312
|
+
const freshStart = (): FreshStart => {
|
|
1081
1313
|
const now = WARD_VIEW.setupOf(view).config
|
|
1082
|
-
|
|
1314
|
+
const from = Spine.startOf(now, node.inherited, false, untrack)
|
|
1315
|
+
return { from, starting: Svg.splitPatchForTag(internal.tag, project(ElementSetup.drawnAtRest(from.initialValues, layoutNode, now.transformTemplate))).style }
|
|
1316
|
+
}
|
|
1317
|
+
const freshStarting = (): Renderer.Patch => freshStart().starting
|
|
1318
|
+
const beginFresh = (): void => {
|
|
1319
|
+
const fresh = freshStart()
|
|
1320
|
+
begun = fresh.from
|
|
1321
|
+
// As the first start (#979): its variant's resolver that throws is reported, here where it begins.
|
|
1083
1322
|
Spine.reportStart(variantFailures, begun)
|
|
1084
1323
|
snapshot.values = { ...begun.initialValues }
|
|
1085
1324
|
snapshot.velocities = {}
|
|
1086
1325
|
snapshot.drawnAt = {}
|
|
1087
|
-
|
|
1326
|
+
// Its element read this Starting style as it was made, where it was seen coming, so that read
|
|
1327
|
+
// isn't run again: any other read of its style is.
|
|
1328
|
+
elementStyle.restart(fresh.starting)
|
|
1088
1329
|
}
|
|
1089
1330
|
const configNow = (): WardConfigValues => view
|
|
1090
1331
|
const styleNow = (): WardStyle | string | undefined => untrack(userStyle)
|
|
@@ -1092,11 +1333,16 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1092
1333
|
// What its exit resolves from under an <AnimatePresence> (#277: its `exit`, `variants`, `custom` and
|
|
1093
1334
|
// transition), kept current while it's alive: the presence resolves it as the ward leaves (ADR-0007).
|
|
1094
1335
|
const exitConfig = { current: Spine.NO_EXIT_CONFIG }
|
|
1336
|
+
// How it's read of its config, under a presence: none with no presence above it, and nothing
|
|
1337
|
+
// made for it then. Mapped from the presence, a function was made for every ward to make it by.
|
|
1338
|
+
let exitNow: (() => Spine.ExitConfig) | undefined
|
|
1095
1339
|
if (Predicate.isNotUndefined(presence)) {
|
|
1340
|
+
const now = (): Spine.ExitConfig => Spine.exitConfigOf(cfg(), node.inherited)
|
|
1341
|
+
exitNow = now
|
|
1096
1342
|
// Its inherited transition is read untracked here: the effect keeps it current.
|
|
1097
1343
|
exitConfig.current = untrack(() => Spine.exitConfigOf(initialConfig, node.inherited))
|
|
1098
1344
|
createEffect(
|
|
1099
|
-
|
|
1345
|
+
now,
|
|
1100
1346
|
(config) => {
|
|
1101
1347
|
exitConfig.current = config
|
|
1102
1348
|
},
|
|
@@ -1109,8 +1355,18 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1109
1355
|
// (#140)*). Its section's `layout` makes its node (#511): without it, its layout props do nothing,
|
|
1110
1356
|
// and development says so once, unless `layout` is on its way.
|
|
1111
1357
|
const wantsNode = Feature.wantsLayoutNode(initialConfig)
|
|
1358
|
+
/**
|
|
1359
|
+
* Whether its drag waits for its layout node (probe: behaviour-runes): it wants one, has none yet, and a
|
|
1360
|
+
* Feature is still on its way (`pending`, read now where not given). A hook row's lazy `layout` that came
|
|
1361
|
+
* after `drag` was left out of the track (#582), so a behaviour's `measured()` never saw the drag.
|
|
1362
|
+
*/
|
|
1363
|
+
const holdsForNode = (wants: boolean, node: unknown, pending?: boolean): boolean => {
|
|
1364
|
+
if (Bool.not(wants)) return false
|
|
1365
|
+
if (Predicate.isNotUndefined(node)) return false
|
|
1366
|
+
return UndefinedOr.match(pending, { onUndefined: () => untrack(features.pending), onDefined: identity })
|
|
1367
|
+
}
|
|
1112
1368
|
if (DEV && wantsNode && Predicate.isUndefined(layoutProjection) && Bool.not(untrack(features.pending))) {
|
|
1113
|
-
useFeatureRegistry().warnOnce("layout",
|
|
1369
|
+
useFeatureRegistry().warnOnce("layout", missingMessage("layout", Feature.LAYOUT_PROPS))
|
|
1114
1370
|
}
|
|
1115
1371
|
const layoutNodes = Bool.match(wantsNode, { onTrue: () => layoutProjection, onFalse: constUndefined })
|
|
1116
1372
|
const dragTransition = DragTransition.dragTransitionOf(initialConfig.dragElastic, initialConfig.dragTransition)
|
|
@@ -1244,6 +1500,10 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1244
1500
|
pan: boolean
|
|
1245
1501
|
inView: boolean
|
|
1246
1502
|
focus: boolean
|
|
1503
|
+
/** Whether `onInput` was told (probe: behaviour-runes). */
|
|
1504
|
+
input: boolean
|
|
1505
|
+
/** What `afterMount` returned, called once the mount has ended (probe: behaviour-runes). */
|
|
1506
|
+
afterUnmount: () => void
|
|
1247
1507
|
readonly dispose: () => void
|
|
1248
1508
|
}
|
|
1249
1509
|
/** A handler's throw, reported as a fiber's failure is (ADR-0030, decision 4); the watch goes on. */
|
|
@@ -1260,7 +1520,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1260
1520
|
if (Bool.not(wanted)) return undefined
|
|
1261
1521
|
const service = GestureFeatures.serviceIn(services, key)
|
|
1262
1522
|
if (DEV && Predicate.isUndefined(service) && Bool.not(untrack(features.pending))) {
|
|
1263
|
-
featureRegistry.warnOnce(name,
|
|
1523
|
+
featureRegistry.warnOnce(name, missingMessage(name, GestureFeatures.GESTURE_WORDS[name]))
|
|
1264
1524
|
}
|
|
1265
1525
|
return service
|
|
1266
1526
|
}
|
|
@@ -1332,6 +1592,14 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1332
1592
|
m.focus = true
|
|
1333
1593
|
m.watch(focus.watch(m.element, { visible: true }, { on: (focused) => setGesture(m.element, "focused", focused), onDefect }))
|
|
1334
1594
|
}
|
|
1595
|
+
// A behaviour's input (probe: behaviour-runes): told once a mount, once its gestures' input is there.
|
|
1596
|
+
const onInput = internal.onInput
|
|
1597
|
+
if (Predicate.isNotUndefined(onInput) && Bool.not(m.input)) {
|
|
1598
|
+
UndefinedOr.map(GestureFeatures.serviceIn(services, InputSource.InputSource), (input) => {
|
|
1599
|
+
m.input = true
|
|
1600
|
+
onInput(m.element, input, (make) => m.watch(make(onDefect)), (effect) => void runtime.runFork(effect), runtime)
|
|
1601
|
+
})
|
|
1602
|
+
}
|
|
1335
1603
|
}
|
|
1336
1604
|
let mounted: Mounted | undefined
|
|
1337
1605
|
// The last two elements given to its ref, for a second one still on the page as it mounts (#349's Q5).
|
|
@@ -1363,22 +1631,29 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1363
1631
|
held = PresenceRecord.presenceHold(presence, el, shown)
|
|
1364
1632
|
return Predicate.isNotUndefined(held)
|
|
1365
1633
|
}
|
|
1366
|
-
|
|
1634
|
+
/**
|
|
1635
|
+
* Its element's mount ended, and what `afterMount` gave it handed back to be called once the caller's
|
|
1636
|
+
* own work is done (probe: behaviour-runes): a rune's undoing that throws ends nothing of the binding's.
|
|
1637
|
+
*/
|
|
1638
|
+
const unmount = (): (() => void) => {
|
|
1367
1639
|
unhold()
|
|
1368
|
-
if (Predicate.isUndefined(mounted)) return
|
|
1640
|
+
if (Predicate.isUndefined(mounted)) return constVoid
|
|
1369
1641
|
const left = mounted.element
|
|
1642
|
+
const afterUnmount = mounted.afterUnmount
|
|
1370
1643
|
mounted.dispose()
|
|
1371
1644
|
mounted = undefined
|
|
1372
1645
|
if (justLeft.size === 0) queueMicrotask(forgetJustLeft)
|
|
1373
1646
|
justLeft.add(left)
|
|
1647
|
+
return afterUnmount
|
|
1374
1648
|
}
|
|
1375
1649
|
// Its element's mount goes, and its lifecycle's waits are rejected (#257): one cleanup, which ends
|
|
1376
1650
|
// what its accessors mounted at their first calls too (#566).
|
|
1377
1651
|
// A driving ward's lifecycle is its given ward's, which outlives the element (#349).
|
|
1378
1652
|
onCleanup(() => {
|
|
1379
|
-
unmount()
|
|
1653
|
+
const afterUnmount = unmount()
|
|
1380
1654
|
if (Predicate.isUndefined(share)) lifecycle.dispose()
|
|
1381
1655
|
UndefinedOr.map(cleanups, (all) => Arr.forEach(all, runCleanup))
|
|
1656
|
+
afterUnmount()
|
|
1382
1657
|
})
|
|
1383
1658
|
|
|
1384
1659
|
const mount = (el: HTMLElement): Mounted => {
|
|
@@ -1537,7 +1812,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1537
1812
|
propagation: initialConfig.dragPropagation,
|
|
1538
1813
|
directionLock: initialConfig.dragDirectionLock,
|
|
1539
1814
|
transition: dragTransition,
|
|
1540
|
-
listen: initialConfig.dragListener,
|
|
1815
|
+
listen: UndefinedOr.match(internal.dragListen, { onUndefined: () => initialConfig.dragListener, onDefined: identity }),
|
|
1541
1816
|
},
|
|
1542
1817
|
container: constraints.container,
|
|
1543
1818
|
controls: initialConfig.dragControls,
|
|
@@ -1556,7 +1831,11 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1556
1831
|
onReleaseEnd: () => lifecycle.released(),
|
|
1557
1832
|
})
|
|
1558
1833
|
}
|
|
1559
|
-
|
|
1834
|
+
// One that wants a layout node whose `layout` is still on its way holds its drag back until the node
|
|
1835
|
+
// is made, so its track drives the node (probe: behaviour-runes): a hook row's Features come as its
|
|
1836
|
+
// config asks, `drag` before `layout` as often as not, and a node made after the track was left out
|
|
1837
|
+
// of it (#582), so a behaviour's `measured()` never saw the drag.
|
|
1838
|
+
let dragTrack = Bool.match(holdsForNode(wantsNode, layout), { onTrue: constUndefined, onFalse: () => UndefinedOr.map(dragGesture, driveDrag) })
|
|
1560
1839
|
const spineOptions: Spine.SubjectSpineOptions = {
|
|
1561
1840
|
runtime,
|
|
1562
1841
|
gate,
|
|
@@ -1629,6 +1908,8 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1629
1908
|
pan: false,
|
|
1630
1909
|
inView: false,
|
|
1631
1910
|
focus: false,
|
|
1911
|
+
input: false,
|
|
1912
|
+
afterUnmount: constVoid,
|
|
1632
1913
|
dispose: () => {
|
|
1633
1914
|
if (Predicate.isNotUndefined(undrive)) undrive()
|
|
1634
1915
|
UndefinedOr.map(mountedHook, (end) => end())
|
|
@@ -1679,9 +1960,10 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1679
1960
|
() => ({ services: features.services(), pending: features.pending() }),
|
|
1680
1961
|
// Its apply returns nothing: a function returned there would be its cleanup.
|
|
1681
1962
|
({ services, pending }) => {
|
|
1682
|
-
|
|
1963
|
+
// Its node reads its config's options (its `layoutId`, an accessor's): untracked, as at its mount, so said.
|
|
1964
|
+
UndefinedOr.map(mounted, (m) => untrack(() => layoutArrivedIn(m.arriveLayout, services)))
|
|
1683
1965
|
if (DEV && Predicate.isUndefined(Keys.projectionIn(services)) && Bool.not(pending)) {
|
|
1684
|
-
featureRegistry.warnOnce("layout",
|
|
1966
|
+
featureRegistry.warnOnce("layout", missingMessage("layout", Feature.LAYOUT_PROPS))
|
|
1685
1967
|
}
|
|
1686
1968
|
},
|
|
1687
1969
|
CLIENT_ONLY_DEFERRED,
|
|
@@ -1700,11 +1982,14 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1700
1982
|
// A `layout` from the same load makes its node first, so the track drives it (#582).
|
|
1701
1983
|
onDefined: (gesture) =>
|
|
1702
1984
|
UndefinedOr.map(mounted, (m) => {
|
|
1703
|
-
layoutArrivedIn(m.arriveLayout, services)
|
|
1704
|
-
|
|
1985
|
+
untrack(() => layoutArrivedIn(m.arriveLayout, services))
|
|
1986
|
+
// One that wants a node starts its drag once it has one, or once nothing more is coming.
|
|
1987
|
+
if (Bool.not(holdsForNode(wantsNode, m.layout, pending))) UndefinedOr.map(m.startDrag, (start) => start(gesture))
|
|
1988
|
+
// Its input with it, for a behaviour's keys (probe: behaviour-runes).
|
|
1989
|
+
startRecognizers(m)
|
|
1705
1990
|
}),
|
|
1706
1991
|
onUndefined: () => {
|
|
1707
|
-
if (DEV && Bool.not(pending)) featureRegistry.warnOnce("drag",
|
|
1992
|
+
if (DEV && Bool.not(pending)) featureRegistry.warnOnce("drag", missingMessage("drag", GestureFeatures.GESTURE_WORDS.drag))
|
|
1708
1993
|
},
|
|
1709
1994
|
})
|
|
1710
1995
|
},
|
|
@@ -1744,6 +2029,9 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1744
2029
|
(mounting) => {
|
|
1745
2030
|
if (Predicate.isUndefined(mounting)) return
|
|
1746
2031
|
const { el, resolution } = mounting
|
|
2032
|
+
let mountedNow = false
|
|
2033
|
+
// What the last element's `afterMount` gave, called once this one is mounted and aimed.
|
|
2034
|
+
let afterLast: () => void = constVoid
|
|
1747
2035
|
if (Predicate.isUndefined(mounted) || mounted.element !== el) {
|
|
1748
2036
|
// Another element it was spread on, or the one it's on, still on the page: a ward drives one
|
|
1749
2037
|
// element at a time (#349's Q5). One the page has let go of is left behind.
|
|
@@ -1752,18 +2040,29 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1752
2040
|
// Held off the page: nothing starts until it's on it.
|
|
1753
2041
|
if (heldBack(el)) return
|
|
1754
2042
|
// A new element starts with no gesture on, read from its gesture state (#257's audit).
|
|
1755
|
-
unmount()
|
|
1756
|
-
// One that came after the last left the page enters fresh (#414).
|
|
1757
|
-
|
|
2043
|
+
afterLast = unmount()
|
|
2044
|
+
// One that came after the last left the page enters fresh (#414). One that doesn't, read as
|
|
2045
|
+
// one that would, reads its style again.
|
|
2046
|
+
Bool.match(el === fresh, { onTrue: beginFresh, onFalse: elementStyle.notFresh })
|
|
1758
2047
|
// Its config is read at mount (its layout node's options, its `onUpdate`, its spine's) through
|
|
1759
2048
|
// the per-key view (#259): untracked, so said, as the Retarget below.
|
|
1760
2049
|
mounted = untrack(() => mount(el))
|
|
2050
|
+
mountedNow = true
|
|
1761
2051
|
}
|
|
1762
2052
|
// The spine reads the variant context (its gates, its stagger, what it inherits) at the
|
|
1763
2053
|
// Retarget, once: untracked, so said (Solid 2's dev build warns of a reactive read in an
|
|
1764
2054
|
// effect's apply, STRICT_READ_UNTRACKED). The effect's compute is what re-runs it.
|
|
1765
|
-
const
|
|
2055
|
+
const m = mounted
|
|
2056
|
+
const spine = m.spine
|
|
2057
|
+
// What it resolved to, told to a ward that asks for its Features as it uses them (`targeted`).
|
|
2058
|
+
const targeted = internal.targeted
|
|
2059
|
+
if (Predicate.isNotUndefined(targeted)) targeted(resolution.resolved)
|
|
1766
2060
|
untrack(() => spine.retarget(resolution))
|
|
2061
|
+
// A hooks ward's runes' `ref`s, once it's mounted and aimed (probe: behaviour-runes): the last
|
|
2062
|
+
// element's undone, then this one's run. Not untracked, which is the `ref`'s author's to say.
|
|
2063
|
+
afterLast()
|
|
2064
|
+
const afterMount = internal.afterMount
|
|
2065
|
+
if (mountedNow && Predicate.isNotUndefined(afterMount)) m.afterUnmount = afterMount(el)
|
|
1767
2066
|
},
|
|
1768
2067
|
CLIENT_ONLY_SYNC,
|
|
1769
2068
|
)
|
|
@@ -1834,9 +2133,45 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1834
2133
|
}
|
|
1835
2134
|
},
|
|
1836
2135
|
})
|
|
2136
|
+
// Whether its presence says the next element it's given enters afresh (probe: hooks-first).
|
|
2137
|
+
const presenceSaysFresh = (): boolean => {
|
|
2138
|
+
const enters = internal.entersFresh
|
|
2139
|
+
if (Predicate.isUndefined(enters)) return false
|
|
2140
|
+
return enters(self)
|
|
2141
|
+
}
|
|
2142
|
+
// Whether the element a first read of its style is for enters fresh (#414), told before its mount
|
|
2143
|
+
// begins it: its ref has decided it for one given and not yet mounted, and will say this of the next.
|
|
2144
|
+
const comesFresh = (): boolean => {
|
|
2145
|
+
const last = refdLast
|
|
2146
|
+
if (Predicate.isUndefined(last)) return presenceSaysFresh()
|
|
2147
|
+
if (UndefinedOr.map(mounted, elementOfMount) !== last) return fresh === last
|
|
2148
|
+
return Bool.or(Bool.not(last.isConnected), presenceSaysFresh())
|
|
2149
|
+
}
|
|
2150
|
+
// Each computation that has read its style: one for each element it's on, the same at every run of
|
|
2151
|
+
// that element's props. So a first read is an element's being made.
|
|
2152
|
+
const styleReaders = new WeakSet<Owner>()
|
|
1837
2153
|
const renderedStyle = (): JSX.CSSProperties => {
|
|
1838
2154
|
holdWhileLoading()
|
|
1839
|
-
|
|
2155
|
+
const user = userStyle()
|
|
2156
|
+
const reader = getOwner()
|
|
2157
|
+
// Read outside a computation, or by one that has read it before: as the gate has it.
|
|
2158
|
+
if (Predicate.isNull(reader)) return elementStyle.style(user) as JSX.CSSProperties
|
|
2159
|
+
if (styleReaders.has(reader)) return elementStyle.style(user) as JSX.CSSProperties
|
|
2160
|
+
// An element that enters fresh reads its Starting style here, derived from what its ref goes by.
|
|
2161
|
+
// Its mount begins the entry once the ref has given it, and doesn't run this read again: told
|
|
2162
|
+
// of the restart afterwards, a spread re-ran on a write its own effect had led to, through the
|
|
2163
|
+
// ref it calls (EFFECT_WRITES_OWN_SOURCE).
|
|
2164
|
+
const style = Bool.match(comesFresh(), {
|
|
2165
|
+
onTrue: () => elementStyle.entering(user, untrack(freshStarting)),
|
|
2166
|
+
onFalse: () => elementStyle.style(user),
|
|
2167
|
+
})
|
|
2168
|
+
styleReaders.add(reader)
|
|
2169
|
+
// Told to the hooks, where they made it, in development alone (probe: hooks-first, Q29).
|
|
2170
|
+
if (DEV) {
|
|
2171
|
+
const styled = internal.styled
|
|
2172
|
+
if (Predicate.isNotUndefined(styled)) styled(self)
|
|
2173
|
+
}
|
|
2174
|
+
return style as JSX.CSSProperties
|
|
1840
2175
|
}
|
|
1841
2176
|
|
|
1842
2177
|
// The ward: a ref, and its own props. Under a presence, its element is told to it as it's made
|
|
@@ -1864,9 +2199,10 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1864
2199
|
config,
|
|
1865
2200
|
setup: initialConfig,
|
|
1866
2201
|
internal,
|
|
2202
|
+
fixed: () => fixedOver(written),
|
|
1867
2203
|
parent,
|
|
1868
2204
|
chosen: Predicate.isNotUndefined(internal.parent),
|
|
1869
|
-
carries:
|
|
2205
|
+
carries: carriesFor(internal, initialConfig),
|
|
1870
2206
|
provided: node.provided,
|
|
1871
2207
|
layoutGroup,
|
|
1872
2208
|
node,
|
|
@@ -1879,6 +2215,10 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1879
2215
|
const setMade = Spine.madeWith(presence, setElement, initialConfig)
|
|
1880
2216
|
const self = ((value?: unknown): WardProps | undefined => {
|
|
1881
2217
|
if (isElement(value)) {
|
|
2218
|
+
// Told to the hooks, where they made it (probe: hooks-first): what a leaving row finds inside it.
|
|
2219
|
+
// No callback made for it: this runs for every element of every ward.
|
|
2220
|
+
const handed = internal.handed
|
|
2221
|
+
if (Predicate.isNotUndefined(handed)) handed(value, self)
|
|
1882
2222
|
const last = refdLast
|
|
1883
2223
|
if (Predicate.isNotUndefined(last)) {
|
|
1884
2224
|
if (last !== value) {
|
|
@@ -1886,12 +2226,21 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1886
2226
|
if (Bool.not(last.isConnected)) fresh = value
|
|
1887
2227
|
}
|
|
1888
2228
|
}
|
|
2229
|
+
// A presence's next value (probe: hooks-first): its element enters afresh though the last may
|
|
2230
|
+
// still be on the page, and so does the first one of a value that came after the page opened.
|
|
2231
|
+
if (Bool.and(last !== value, presenceSaysFresh())) fresh = value
|
|
1889
2232
|
refdLast = value
|
|
1890
2233
|
setMade(value)
|
|
1891
2234
|
return undefined
|
|
1892
2235
|
}
|
|
1893
2236
|
return spreadNow()
|
|
1894
2237
|
}) as Ward
|
|
2238
|
+
// The presence it's made under, for a hook ward to watch its child's leave by (probe: hooks-first).
|
|
2239
|
+
// No callback made for it: this runs for every ward under a presence, each row of a list.
|
|
2240
|
+
if (Predicate.isNotUndefined(presence)) {
|
|
2241
|
+
const madeUnder = internal.madeUnder
|
|
2242
|
+
if (Predicate.isNotUndefined(madeUnder)) madeUnder(self, presence)
|
|
2243
|
+
}
|
|
1895
2244
|
// What a spread of the ward reads (#495): its spread's props alone, made at its first spread, so a
|
|
1896
2245
|
// ward given only to `ref` makes none, and a Reorder item's keyboard attributes are in it.
|
|
1897
2246
|
let spread: WardProps | undefined
|
|
@@ -1918,11 +2267,17 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1918
2267
|
lifecycle,
|
|
1919
2268
|
element,
|
|
1920
2269
|
hold: holdWhileLoading,
|
|
2270
|
+
written,
|
|
2271
|
+
target,
|
|
2272
|
+
handsDown: node.handsDown as Parameters<typeof refresh>[0] | undefined,
|
|
2273
|
+
exitConfig,
|
|
2274
|
+
exitNow,
|
|
1921
2275
|
settled: undefined,
|
|
1922
2276
|
tapped: undefined,
|
|
1923
2277
|
next: undefined,
|
|
1924
2278
|
each: undefined,
|
|
1925
2279
|
when: undefined,
|
|
2280
|
+
hooks: undefined,
|
|
1926
2281
|
}
|
|
1927
2282
|
Object.setPrototypeOf(self, WARD_MEMBERS)
|
|
1928
2283
|
Object.defineProperties(self, {
|
|
@@ -2045,19 +2400,19 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
|
|
|
2045
2400
|
// A server's own values: the DOM's, its context's constant (#672).
|
|
2046
2401
|
const ownValues = ElementSetup.valueReadsOf(useWardicValueReads()).ownValues
|
|
2047
2402
|
createUniqueId()
|
|
2048
|
-
const view = configuredView(WARD_VIEW.of(config, internal.fixed),
|
|
2403
|
+
const view = configuredView(WARD_VIEW.of(config, internal.fixed), configOf(internal))
|
|
2049
2404
|
// A key still loading (#257 item 1): one setup fixes is the client's error here too. One the ward
|
|
2050
2405
|
// reads as it goes is read again, throwing Solid's `NotReadyError`: a server waits for it and
|
|
2051
2406
|
// renders the component again, so its region streams once the data is in, Appear and all.
|
|
2052
2407
|
// Both are checked before the read that waits.
|
|
2053
2408
|
const setup = WARD_VIEW.setupOf(view)
|
|
2054
2409
|
// Animation controls (#433) set nothing on a server: no entry yet, and controlled, as on the client.
|
|
2055
|
-
const atSetup = AnimationControls.uncontrolledOf(configAtSetup(setup))
|
|
2410
|
+
const atSetup = variantChildBy(internal, AnimationControls.uncontrolledOf(configAtSetup(setup)))
|
|
2056
2411
|
// Where it's made, its given parent's, or its given ward's (#349).
|
|
2057
2412
|
const parent = variantParentOf(internal)
|
|
2058
2413
|
const presenceBlocks = PresenceRecord.presenceBlocksInitial(usePresenceContext())
|
|
2059
2414
|
if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(atSetup, VariantTree.inheritedContext(atSetup, parent), presenceBlocks))) throw new Error(STARTS_AT_PENDING)
|
|
2060
|
-
const c = AnimationControls.uncontrolledOf(WARD_VIEW.snapshotOf(view))
|
|
2415
|
+
const c = variantChildBy(internal, AnimationControls.uncontrolledOf(WARD_VIEW.snapshotOf(view)))
|
|
2061
2416
|
const node = VariantTree.serverVariantNode(c, parent)
|
|
2062
2417
|
const serverStart = Spine.startOf(c, node.inherited, presenceBlocks, untrack)
|
|
2063
2418
|
// A variant that throws leaves its values out of the markup, logged on the server (#979).
|
|
@@ -2092,13 +2447,19 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
|
|
|
2092
2447
|
Style.over(appear.style),
|
|
2093
2448
|
) as JSX.CSSProperties
|
|
2094
2449
|
}
|
|
2095
|
-
|
|
2450
|
+
// Worked out at its first read, a spread's (probe: behaviour-runes): what's made after the ward and
|
|
2451
|
+
// before its element renders still counts, a hooks row's grip, which takes its `touch-action` away.
|
|
2452
|
+
let style: JSX.CSSProperties | undefined
|
|
2453
|
+
const styleNow = (): JSX.CSSProperties => {
|
|
2454
|
+
if (Predicate.isUndefined(style)) style = styleFor(c.style)
|
|
2455
|
+
return style
|
|
2456
|
+
}
|
|
2096
2457
|
let given: WardWithProps = NO_WITH
|
|
2097
2458
|
const attributes = attributeKeysOf(seed.attrs, Predicate.isNotUndefined(dragDefaults))
|
|
2098
2459
|
// A spread of it reads its spread's props alone, made at its first spread, as the client's (#495).
|
|
2099
2460
|
let spread: WardProps | undefined
|
|
2100
2461
|
const self = ((): WardProps => {
|
|
2101
|
-
if (Predicate.isUndefined(spread)) spread = spreadOfWard(self, { value: noRef, enumerable: true }, {
|
|
2462
|
+
if (Predicate.isUndefined(spread)) spread = spreadOfWard(self, { value: noRef, enumerable: true }, { get: styleNow, enumerable: true }, attributes)
|
|
2102
2463
|
return spread
|
|
2103
2464
|
}) as Ward
|
|
2104
2465
|
// What it shares with a component it's given to (#349): a server's component renders its own.
|
|
@@ -2106,11 +2467,12 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
|
|
|
2106
2467
|
config,
|
|
2107
2468
|
setup: atSetup,
|
|
2108
2469
|
internal,
|
|
2470
|
+
fixed: () => internal.fixed,
|
|
2109
2471
|
parent,
|
|
2110
2472
|
chosen: Predicate.isNotUndefined(internal.parent),
|
|
2111
|
-
carries:
|
|
2473
|
+
carries: carriesFor(internal, atSetup),
|
|
2112
2474
|
provided: appear.provided,
|
|
2113
|
-
layoutGroup:
|
|
2475
|
+
layoutGroup: groupOf(internal),
|
|
2114
2476
|
node: undefined,
|
|
2115
2477
|
lifecycle: undefined,
|
|
2116
2478
|
drive: () => constVoid,
|
|
@@ -2118,7 +2480,7 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
|
|
|
2118
2480
|
Object.defineProperties(self, {
|
|
2119
2481
|
[WARD]: { value: shared },
|
|
2120
2482
|
ref: { value: noRef, enumerable: true },
|
|
2121
|
-
style: {
|
|
2483
|
+
style: { get: styleNow, enumerable: true },
|
|
2122
2484
|
...attributes,
|
|
2123
2485
|
Provider: { value: Provider },
|
|
2124
2486
|
read: { value: (key: string) => () => ElementSetup.restingOf(key, initialValues, withStyleOver(c.style, given.style), readServerStyle) },
|
|
@@ -2130,8 +2492,11 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
|
|
|
2130
2492
|
next: { value: neverLands },
|
|
2131
2493
|
each: { value: () => NO_EVENTS },
|
|
2132
2494
|
when: { value: serverWhen },
|
|
2133
|
-
// The element's own style over the config's, rendered in its Starting style (#264).
|
|
2495
|
+
// The element's own style over the config's, rendered in its Starting style (#264). Configurable,
|
|
2496
|
+
// as a client's is by being a shared member: so what makes a ward of this one can give it a
|
|
2497
|
+
// `with` of its own, on a server as in a browser (the hooks', for what their runes add to a spread).
|
|
2134
2498
|
with: {
|
|
2499
|
+
configurable: true,
|
|
2135
2500
|
value: (own: WardWithProps): WardProps => {
|
|
2136
2501
|
given = own
|
|
2137
2502
|
return spreadPropsOf({
|
|
@@ -2148,4 +2513,265 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
|
|
|
2148
2513
|
/** A server render's `ref`: Solid never calls it there. */
|
|
2149
2514
|
const noRef = constUndefined
|
|
2150
2515
|
|
|
2516
|
+
/** No values: what a function rune's ward rests at, having no config ({@link holderWard}). */
|
|
2517
|
+
const NO_VALUES: Values.Values = {}
|
|
2518
|
+
/** A function rune's ward's config, as it's written and at setup: none. */
|
|
2519
|
+
const NO_WRITTEN: WardConfigValues = Object.freeze({})
|
|
2520
|
+
/** A function rune's ward's exit: none, never read again, as it has no `exitNow`. */
|
|
2521
|
+
const NO_EXIT: { current: Spine.ExitConfig } = Object.freeze({ current: Spine.NO_EXIT_CONFIG })
|
|
2522
|
+
|
|
2523
|
+
/** What a function rune's ward hands on to its finished ward, by name, in the words development uses. */
|
|
2524
|
+
type HandedOn = "Provider" | "with" | "the ward as a ref or a spread" | "style"
|
|
2525
|
+
|
|
2526
|
+
/**
|
|
2527
|
+
* What development says of `member` used in a function rune's body (the ward split's Q7): it's the
|
|
2528
|
+
* finished ward's, and that ward isn't made yet.
|
|
2529
|
+
*/
|
|
2530
|
+
const usedEarly = (member: HandedOn): string =>
|
|
2531
|
+
`createRune(fn): ${member} was used in the rune's body, before its ward is made. It's the ward's, and the ward ` +
|
|
2532
|
+
"doesn't exist until every rune has run: use it where the ward is rendered, or in an effect or a callback."
|
|
2533
|
+
|
|
2534
|
+
// Module state (#460, Q7): what development has said, each member once.
|
|
2535
|
+
const SAID_EARLY = new Set<HandedOn>()
|
|
2536
|
+
|
|
2537
|
+
/** Says {@link usedEarly} of `member`, once, in development. */
|
|
2538
|
+
const sayEarly = (member: HandedOn): void => {
|
|
2539
|
+
if (Predicate.isUndefined(DEV)) return
|
|
2540
|
+
if (SAID_EARLY.has(member)) return
|
|
2541
|
+
SAID_EARLY.add(member)
|
|
2542
|
+
console.warn(usedEarly(member))
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
/** The finished ward each function rune's ward hands on to, told it by {@link holderFinished}. */
|
|
2546
|
+
// Module state (#460, Q7): held weakly by the function rune's ward.
|
|
2547
|
+
const FINISHING = new WeakMap<object, (ward: Ward) => void>()
|
|
2548
|
+
|
|
2549
|
+
/** Tells `holder`, a function rune's ward ({@link holderWard}), the ward it's part of, now that it's made. */
|
|
2550
|
+
export const holderFinished = (holder: object, ward: Ward): void => {
|
|
2551
|
+
UndefinedOr.map(FINISHING.get(holder), (finish) => finish(ward))
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
/**
|
|
2555
|
+
* A function rune's ward (probe: behaviour-runes, the ward split's Q6–Q8, Q11), made before the ward it's
|
|
2556
|
+
* part of, since every rune runs before that ward is: a lifecycle and what the hooks keep, with no config,
|
|
2557
|
+
* no variant node and no mount. The finished ward adopts its lifecycle through its share, as a ward given
|
|
2558
|
+
* to a component does (#349), and drives its `read` and `atom` while it's on an element: as the second
|
|
2559
|
+
* binding ward this replaces did, at a fraction of its cost. What only the finished ward has, its
|
|
2560
|
+
* `Provider`, its spread and `with`, its `style` and its element, it hands on to that ward once
|
|
2561
|
+
* {@link holderFinished} says which: used in the rune's body, before then, development says so. It takes
|
|
2562
|
+
* no hydration id, on a server or in a browser.
|
|
2563
|
+
*/
|
|
2564
|
+
export const holderWard = (internal: WardInternals): Ward => {
|
|
2565
|
+
// Where it's made: the variant context and Layout group its finished ward takes through its share.
|
|
2566
|
+
const parent = variantParentOf(internal)
|
|
2567
|
+
const layoutGroup = groupOf(internal)
|
|
2568
|
+
if (isServer) return serverHolder(internal, parent, layoutGroup)
|
|
2569
|
+
return clientHolder(internal, parent, layoutGroup)
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
/** A function rune's ward in a browser ({@link holderWard}). */
|
|
2573
|
+
const clientHolder = (internal: WardInternals, parent: VariantTree.WardicVariantContextValue | undefined, layoutGroup: string | undefined): Ward => {
|
|
2574
|
+
const registry = Spine.registryOf(useWardicRuntime())
|
|
2575
|
+
const firstCallOwner = firstCallOwnerHere()
|
|
2576
|
+
let finished: Ward | undefined
|
|
2577
|
+
// The finished ward on its element (#349's driver): what its `read`, `atom` and `next` follow.
|
|
2578
|
+
let driver: Driver | undefined
|
|
2579
|
+
let driven: Atom.Writable<Driver | undefined> | undefined
|
|
2580
|
+
let cleanups: Array<() => void> | undefined
|
|
2581
|
+
const addCleanup = (cleanup: () => void): void => {
|
|
2582
|
+
if (Predicate.isUndefined(cleanups)) cleanups = []
|
|
2583
|
+
cleanups.push(cleanup)
|
|
2584
|
+
}
|
|
2585
|
+
const drivenAtom = (): Atom.Writable<Driver | undefined> => {
|
|
2586
|
+
if (Predicate.isNotUndefined(driven)) return driven
|
|
2587
|
+
const atom = Atom.make<Driver | undefined>(driver)
|
|
2588
|
+
addCleanup(registry().mount(atom))
|
|
2589
|
+
driven = atom
|
|
2590
|
+
return atom
|
|
2591
|
+
}
|
|
2592
|
+
// Its gestures are its finished ward's: a `next` that asks for one starts it on that ward's element.
|
|
2593
|
+
const lifecycle = new Lifecycle(firstCallOwner, () => {
|
|
2594
|
+
UndefinedOr.map(driver, (d) => d.wanted())
|
|
2595
|
+
})
|
|
2596
|
+
onCleanup(() => {
|
|
2597
|
+
lifecycle.dispose()
|
|
2598
|
+
UndefinedOr.map(cleanups, (all) => Arr.forEach(all, runCleanup))
|
|
2599
|
+
})
|
|
2600
|
+
// A key's value: the finished ward's element's, while it drives this one; where nothing rests, else.
|
|
2601
|
+
let reads: Map<string, Accessor<unknown>> | undefined
|
|
2602
|
+
const read = (key: string): Accessor<unknown> => {
|
|
2603
|
+
if (Predicate.isUndefined(reads)) reads = new Map()
|
|
2604
|
+
const known = reads.get(key)
|
|
2605
|
+
if (Predicate.isNotUndefined(known)) return known
|
|
2606
|
+
const following = drivenAtom()
|
|
2607
|
+
const resting = ElementSetup.restingOf(key, NO_VALUES, undefined, identity)
|
|
2608
|
+
const atom = Atom.make((get) => UndefinedOr.match(get(following), { onUndefined: () => resting, onDefined: (d) => get(d.readAtom(key)) }))
|
|
2609
|
+
const accessor = runWithOwner(firstCallOwner, () => followAtom(registry(), atom, addCleanup))
|
|
2610
|
+
reads.set(key, accessor)
|
|
2611
|
+
return accessor
|
|
2612
|
+
}
|
|
2613
|
+
const atomOf = (key: string): Atom.Atom<unknown> => {
|
|
2614
|
+
const following = drivenAtom()
|
|
2615
|
+
return Atom.make((get) => UndefinedOr.match(get(following), { onUndefined: constUndefined, onDefined: (d) => get(d.atom(key)) }))
|
|
2616
|
+
}
|
|
2617
|
+
// Followed by one finished ward at a time (#349's Q5).
|
|
2618
|
+
const drive = (next: Driver, name: string): (() => void) => {
|
|
2619
|
+
if (Predicate.isNotUndefined(driver)) throw new Error(secondElement(name))
|
|
2620
|
+
driver = next
|
|
2621
|
+
UndefinedOr.map(driven, (atom) => registry().set(atom, next))
|
|
2622
|
+
return () => {
|
|
2623
|
+
if (driver !== next) return
|
|
2624
|
+
driver = undefined
|
|
2625
|
+
UndefinedOr.map(driven, (atom) => registry().set(atom, undefined))
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
const shared: WardShare = {
|
|
2629
|
+
config: NO_WRITTEN,
|
|
2630
|
+
setup: NO_WRITTEN,
|
|
2631
|
+
internal,
|
|
2632
|
+
fixed: () => internal.fixed,
|
|
2633
|
+
parent,
|
|
2634
|
+
chosen: Predicate.isNotUndefined(internal.parent),
|
|
2635
|
+
carries: false,
|
|
2636
|
+
provided: undefined,
|
|
2637
|
+
layoutGroup,
|
|
2638
|
+
node: undefined,
|
|
2639
|
+
lifecycle,
|
|
2640
|
+
drive,
|
|
2641
|
+
}
|
|
2642
|
+
const self = ((value?: unknown): unknown =>
|
|
2643
|
+
UndefinedOr.match(finished, {
|
|
2644
|
+
onUndefined: (): unknown => {
|
|
2645
|
+
sayEarly("the ward as a ref or a spread")
|
|
2646
|
+
return undefined
|
|
2647
|
+
},
|
|
2648
|
+
onDefined: (to): unknown => to(value as HTMLElement),
|
|
2649
|
+
})) as Ward
|
|
2650
|
+
const state: WardState = {
|
|
2651
|
+
shared: () => shared,
|
|
2652
|
+
Provider: (props) =>
|
|
2653
|
+
UndefinedOr.match(finished, {
|
|
2654
|
+
onUndefined: () => {
|
|
2655
|
+
sayEarly("Provider")
|
|
2656
|
+
return props.children
|
|
2657
|
+
},
|
|
2658
|
+
onDefined: (to) => to.Provider(props),
|
|
2659
|
+
}),
|
|
2660
|
+
read,
|
|
2661
|
+
atom: atomOf,
|
|
2662
|
+
with: (own) =>
|
|
2663
|
+
UndefinedOr.match(finished, {
|
|
2664
|
+
onUndefined: () => {
|
|
2665
|
+
sayEarly("with")
|
|
2666
|
+
return spreadPropsOf({})
|
|
2667
|
+
},
|
|
2668
|
+
onDefined: (to) => to.with(own),
|
|
2669
|
+
}),
|
|
2670
|
+
lifecycle,
|
|
2671
|
+
element: () =>
|
|
2672
|
+
UndefinedOr.match(finished, {
|
|
2673
|
+
onUndefined: constUndefined,
|
|
2674
|
+
onDefined: (to) => UndefinedOr.match(sensedOf(to), { onUndefined: constUndefined, onDefined: (sensed) => sensed.element() }),
|
|
2675
|
+
}),
|
|
2676
|
+
hold: () => {
|
|
2677
|
+
UndefinedOr.map(finished, (to) => stateOf(to).hold())
|
|
2678
|
+
},
|
|
2679
|
+
written: NO_WRITTEN,
|
|
2680
|
+
target: undefined,
|
|
2681
|
+
handsDown: undefined,
|
|
2682
|
+
exitConfig: NO_EXIT,
|
|
2683
|
+
exitNow: undefined,
|
|
2684
|
+
settled: undefined,
|
|
2685
|
+
tapped: undefined,
|
|
2686
|
+
next: undefined,
|
|
2687
|
+
each: undefined,
|
|
2688
|
+
when: undefined,
|
|
2689
|
+
hooks: undefined,
|
|
2690
|
+
}
|
|
2691
|
+
FINISHING.set(self, (ward) => {
|
|
2692
|
+
finished = ward
|
|
2693
|
+
})
|
|
2694
|
+
Object.setPrototypeOf(self, WARD_MEMBERS)
|
|
2695
|
+
Object.defineProperties(self, {
|
|
2696
|
+
[WARD_STATE]: { value: state },
|
|
2697
|
+
ref: { value: self, enumerable: true },
|
|
2698
|
+
style: { get: () => styleOf(finished), enumerable: true },
|
|
2699
|
+
})
|
|
2700
|
+
return self
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
/** A function rune's ward's `style`: its finished ward's. */
|
|
2704
|
+
const styleOf = (finished: Ward | undefined): JSX.CSSProperties =>
|
|
2705
|
+
UndefinedOr.match(finished, {
|
|
2706
|
+
onUndefined: (): JSX.CSSProperties => {
|
|
2707
|
+
sayEarly("style")
|
|
2708
|
+
return {}
|
|
2709
|
+
},
|
|
2710
|
+
onDefined: (to) => to.style as JSX.CSSProperties,
|
|
2711
|
+
})
|
|
2712
|
+
|
|
2713
|
+
/** A function rune's ward on a server ({@link holderWard}): a server ward's members, and its share. Nothing hears anything there. */
|
|
2714
|
+
const serverHolder = (internal: WardInternals, parent: VariantTree.WardicVariantContextValue | undefined, layoutGroup: string | undefined): Ward => {
|
|
2715
|
+
let finished: Ward | undefined
|
|
2716
|
+
const self = ((): WardProps | undefined =>
|
|
2717
|
+
UndefinedOr.match(finished, {
|
|
2718
|
+
onUndefined: (): WardProps | undefined => {
|
|
2719
|
+
sayEarly("the ward as a ref or a spread")
|
|
2720
|
+
return undefined
|
|
2721
|
+
},
|
|
2722
|
+
onDefined: (to) => to(),
|
|
2723
|
+
})) as Ward
|
|
2724
|
+
const shared: WardShare = {
|
|
2725
|
+
config: NO_WRITTEN,
|
|
2726
|
+
setup: NO_WRITTEN,
|
|
2727
|
+
internal,
|
|
2728
|
+
fixed: () => internal.fixed,
|
|
2729
|
+
parent,
|
|
2730
|
+
chosen: Predicate.isNotUndefined(internal.parent),
|
|
2731
|
+
carries: false,
|
|
2732
|
+
provided: undefined,
|
|
2733
|
+
layoutGroup,
|
|
2734
|
+
node: undefined,
|
|
2735
|
+
lifecycle: undefined,
|
|
2736
|
+
drive: () => constVoid,
|
|
2737
|
+
}
|
|
2738
|
+
FINISHING.set(self, (ward) => {
|
|
2739
|
+
finished = ward
|
|
2740
|
+
})
|
|
2741
|
+
Object.defineProperties(self, {
|
|
2742
|
+
[WARD]: { value: shared },
|
|
2743
|
+
ref: { value: noRef, enumerable: true },
|
|
2744
|
+
style: { get: () => styleOf(finished), enumerable: true },
|
|
2745
|
+
Provider: {
|
|
2746
|
+
value: (props: { readonly children?: JSX.Element }): JSX.Element =>
|
|
2747
|
+
UndefinedOr.match(finished, {
|
|
2748
|
+
onUndefined: () => {
|
|
2749
|
+
sayEarly("Provider")
|
|
2750
|
+
return props.children
|
|
2751
|
+
},
|
|
2752
|
+
onDefined: (to) => to.Provider(props),
|
|
2753
|
+
}),
|
|
2754
|
+
},
|
|
2755
|
+
read: { value: (key: string) => () => ElementSetup.restingOf(key, NO_VALUES, undefined, identity) },
|
|
2756
|
+
atom: { value: (): Atom.Atom<unknown> => NO_OUTPUT },
|
|
2757
|
+
settled: { value: constUndefined },
|
|
2758
|
+
tapped: { value: constUndefined },
|
|
2759
|
+
next: { value: neverLands },
|
|
2760
|
+
each: { value: () => NO_EVENTS },
|
|
2761
|
+
when: { value: serverWhen },
|
|
2762
|
+
with: {
|
|
2763
|
+
configurable: true,
|
|
2764
|
+
value: (own: WardWithProps): WardProps =>
|
|
2765
|
+
UndefinedOr.match(finished, {
|
|
2766
|
+
onUndefined: () => {
|
|
2767
|
+
sayEarly("with")
|
|
2768
|
+
return spreadPropsOf({})
|
|
2769
|
+
},
|
|
2770
|
+
onDefined: (to) => to.with(own),
|
|
2771
|
+
}),
|
|
2772
|
+
},
|
|
2773
|
+
})
|
|
2774
|
+
return self
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2151
2777
|
|