@wardic/solid 2.2.0 → 3.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -18
- package/dist/browser/animation-frame.js +1 -1
- package/dist/browser/animation-frame.js.map +1 -1
- package/dist/browser/config-view.js +35 -6
- package/dist/browser/config-view.js.map +1 -1
- package/dist/browser/create-batch.js +1 -1
- package/dist/browser/diagnostic-codes.js +216 -0
- package/dist/browser/diagnostic-codes.js.map +1 -0
- package/dist/browser/diagnostics.js +79 -0
- package/dist/browser/diagnostics.js.map +1 -0
- package/dist/browser/element-style.js +61 -7
- package/dist/browser/element-style.js.map +1 -1
- package/dist/browser/element.js +24 -6
- package/dist/browser/element.js.map +1 -1
- package/dist/browser/feature-section.js +5 -13
- package/dist/browser/feature-section.js.map +1 -1
- package/dist/browser/frame-effect.js +1 -1
- package/dist/browser/frame-effect.js.map +1 -1
- package/dist/browser/gesture-callbacks.js +1 -1
- package/dist/browser/gesture-callbacks.js.map +1 -1
- package/dist/browser/hooks/auto.js +270 -0
- package/dist/browser/hooks/auto.js.map +1 -0
- package/dist/browser/hooks/config-scope.js +120 -0
- package/dist/browser/hooks/config-scope.js.map +1 -0
- package/dist/browser/hooks/config.js +37 -0
- package/dist/browser/hooks/config.js.map +1 -0
- package/dist/browser/hooks/drag.js +633 -0
- package/dist/browser/hooks/drag.js.map +1 -0
- package/dist/browser/hooks/elements.js +183 -0
- package/dist/browser/hooks/elements.js.map +1 -0
- package/dist/browser/hooks/group.js +28 -0
- package/dist/browser/hooks/group.js.map +1 -0
- package/dist/browser/hooks/index.js +10 -0
- package/dist/browser/hooks/index.js.map +1 -0
- package/dist/browser/hooks/kept.js +32 -0
- package/dist/browser/hooks/kept.js.map +1 -0
- package/dist/browser/hooks/layout-group-of.js +39 -0
- package/dist/browser/hooks/layout-group-of.js.map +1 -0
- package/dist/browser/hooks/layout-group.js +92 -0
- package/dist/browser/hooks/layout-group.js.map +1 -0
- package/dist/browser/hooks/make-ward.js +157 -0
- package/dist/browser/hooks/make-ward.js.map +1 -0
- package/dist/browser/hooks/presence-scope.js +88 -0
- package/dist/browser/hooks/presence-scope.js.map +1 -0
- package/dist/browser/hooks/presence.js +24 -0
- package/dist/browser/hooks/presence.js.map +1 -0
- package/dist/browser/hooks/props.js +148 -0
- package/dist/browser/hooks/props.js.map +1 -0
- package/dist/browser/hooks/reads.js +241 -0
- package/dist/browser/hooks/reads.js.map +1 -0
- package/dist/browser/hooks/refs.js +87 -0
- package/dist/browser/hooks/refs.js.map +1 -0
- package/dist/browser/hooks/reorder-elements.js +269 -0
- package/dist/browser/hooks/reorder-elements.js.map +1 -0
- package/dist/browser/hooks/reorder.js +176 -0
- package/dist/browser/hooks/reorder.js.map +1 -0
- package/dist/browser/hooks/rune.js +800 -0
- package/dist/browser/hooks/rune.js.map +1 -0
- package/dist/browser/hooks/server-features.client.js +2 -0
- package/dist/browser/hooks/server-features.client.js.map +1 -0
- package/dist/browser/hooks/server-features.js +13 -0
- package/dist/browser/hooks/server-features.js.map +1 -0
- package/dist/browser/hooks/settings.js +29 -0
- package/dist/browser/hooks/settings.js.map +1 -0
- package/dist/browser/hooks/setup.js +154 -0
- package/dist/browser/hooks/setup.js.map +1 -0
- package/dist/browser/hooks/stage.js +117 -0
- package/dist/browser/hooks/stage.js.map +1 -0
- package/dist/browser/hooks/ward.js +2212 -0
- package/dist/browser/hooks/ward.js.map +1 -0
- package/dist/browser/hooks/wardic-provider.js +29 -0
- package/dist/browser/hooks/wardic-provider.js.map +1 -0
- package/dist/browser/hooks/wardic-scope.js +68 -0
- package/dist/browser/hooks/wardic-scope.js.map +1 -0
- package/dist/browser/hooks/wards.js +563 -0
- package/dist/browser/hooks/wards.js.map +1 -0
- package/dist/browser/index.js +23 -11
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/layout.js +7 -58
- package/dist/browser/layout.js.map +1 -1
- package/dist/browser/lazy-batch-gestures.js +1 -1
- package/dist/browser/lifecycle.js +37 -0
- package/dist/browser/lifecycle.js.map +1 -1
- package/dist/browser/presence-handle.js +28 -12
- package/dist/browser/presence-handle.js.map +1 -1
- package/dist/browser/presence.js +3 -1
- package/dist/browser/presence.js.map +1 -1
- package/dist/browser/provider.js +124 -90
- package/dist/browser/provider.js.map +1 -1
- package/dist/browser/reorder-components.js +50 -0
- package/dist/browser/reorder-components.js.map +1 -0
- package/dist/browser/reorder.js +51 -278
- package/dist/browser/reorder.js.map +1 -1
- package/dist/browser/runtime.js +26 -15
- package/dist/browser/runtime.js.map +1 -1
- package/dist/browser/spans-check.js +8 -3
- package/dist/browser/spans-check.js.map +1 -1
- package/dist/browser/stage.js.map +1 -1
- package/dist/browser/unstable/v2/index.js +0 -8
- package/dist/browser/unstable/v2/index.js.map +1 -1
- package/dist/browser/v1/index.js +1 -1
- package/dist/browser/v1/index.js.map +1 -1
- package/dist/browser/variant-node.js +4 -2
- package/dist/browser/variant-node.js.map +1 -1
- package/dist/browser/w.js +33 -3
- package/dist/browser/w.js.map +1 -1
- package/dist/browser/ward.js +594 -61
- package/dist/browser/ward.js.map +1 -1
- package/dist/browser/wardic-config.js +62 -29
- package/dist/browser/wardic-config.js.map +1 -1
- package/dist/browser/wardic-context.js +23 -0
- package/dist/browser/wardic-context.js.map +1 -0
- package/dist/browser/wardic.js +3 -0
- package/dist/browser/wardic.js.map +1 -1
- package/dist/server/animation-frame.js +1 -1
- package/dist/server/animation-frame.js.map +1 -1
- package/dist/server/config-view.js +35 -6
- package/dist/server/config-view.js.map +1 -1
- package/dist/server/create-batch.js +1 -1
- package/dist/server/diagnostic-codes.js +216 -0
- package/dist/server/diagnostic-codes.js.map +1 -0
- package/dist/server/diagnostics.js +79 -0
- package/dist/server/diagnostics.js.map +1 -0
- package/dist/server/element-style.js +61 -7
- package/dist/server/element-style.js.map +1 -1
- package/dist/server/element.js +24 -6
- package/dist/server/element.js.map +1 -1
- package/dist/server/feature-section.js +5 -13
- package/dist/server/feature-section.js.map +1 -1
- package/dist/server/frame-effect.js +1 -1
- package/dist/server/frame-effect.js.map +1 -1
- package/dist/server/gesture-callbacks.js +1 -1
- package/dist/server/gesture-callbacks.js.map +1 -1
- package/dist/server/hooks/auto.js +270 -0
- package/dist/server/hooks/auto.js.map +1 -0
- package/dist/server/hooks/config-scope.js +120 -0
- package/dist/server/hooks/config-scope.js.map +1 -0
- package/dist/server/hooks/config.js +37 -0
- package/dist/server/hooks/config.js.map +1 -0
- package/dist/server/hooks/drag.js +633 -0
- package/dist/server/hooks/drag.js.map +1 -0
- package/dist/server/hooks/elements.js +192 -0
- package/dist/server/hooks/elements.js.map +1 -0
- package/dist/server/hooks/group.js +28 -0
- package/dist/server/hooks/group.js.map +1 -0
- package/dist/server/hooks/index.js +10 -0
- package/dist/server/hooks/index.js.map +1 -0
- package/dist/server/hooks/kept.js +32 -0
- package/dist/server/hooks/kept.js.map +1 -0
- package/dist/server/hooks/layout-group-of.js +39 -0
- package/dist/server/hooks/layout-group-of.js.map +1 -0
- package/dist/server/hooks/layout-group.js +109 -0
- package/dist/server/hooks/layout-group.js.map +1 -0
- package/dist/server/hooks/make-ward.js +157 -0
- package/dist/server/hooks/make-ward.js.map +1 -0
- package/dist/server/hooks/presence-scope.js +87 -0
- package/dist/server/hooks/presence-scope.js.map +1 -0
- package/dist/server/hooks/presence.js +24 -0
- package/dist/server/hooks/presence.js.map +1 -0
- package/dist/server/hooks/props.js +148 -0
- package/dist/server/hooks/props.js.map +1 -0
- package/dist/server/hooks/reads.js +241 -0
- package/dist/server/hooks/reads.js.map +1 -0
- package/dist/server/hooks/refs.js +87 -0
- package/dist/server/hooks/refs.js.map +1 -0
- package/dist/server/hooks/reorder-elements.js +309 -0
- package/dist/server/hooks/reorder-elements.js.map +1 -0
- package/dist/server/hooks/reorder.js +176 -0
- package/dist/server/hooks/reorder.js.map +1 -0
- package/dist/server/hooks/rune.js +800 -0
- package/dist/server/hooks/rune.js.map +1 -0
- package/dist/server/hooks/server-features.client.js +2 -0
- package/dist/server/hooks/server-features.client.js.map +1 -0
- package/dist/server/hooks/server-features.js +13 -0
- package/dist/server/hooks/server-features.js.map +1 -0
- package/dist/server/hooks/settings.js +29 -0
- package/dist/server/hooks/settings.js.map +1 -0
- package/dist/server/hooks/setup.js +154 -0
- package/dist/server/hooks/setup.js.map +1 -0
- package/dist/server/hooks/stage.js +117 -0
- package/dist/server/hooks/stage.js.map +1 -0
- package/dist/server/hooks/ward.js +2212 -0
- package/dist/server/hooks/ward.js.map +1 -0
- package/dist/server/hooks/wardic-provider.js +29 -0
- package/dist/server/hooks/wardic-provider.js.map +1 -0
- package/dist/server/hooks/wardic-scope.js +68 -0
- package/dist/server/hooks/wardic-scope.js.map +1 -0
- package/dist/server/hooks/wards.js +563 -0
- package/dist/server/hooks/wards.js.map +1 -0
- package/dist/server/index.js +23 -11
- package/dist/server/index.js.map +1 -1
- package/dist/server/layout.js +7 -75
- package/dist/server/layout.js.map +1 -1
- package/dist/server/lazy-batch-gestures.js +1 -1
- package/dist/server/lifecycle.js +37 -0
- package/dist/server/lifecycle.js.map +1 -1
- package/dist/server/presence-handle.js +28 -12
- package/dist/server/presence-handle.js.map +1 -1
- package/dist/server/presence.js +3 -1
- package/dist/server/presence.js.map +1 -1
- package/dist/server/provider.js +125 -100
- package/dist/server/provider.js.map +1 -1
- package/dist/server/reorder-components.js +50 -0
- package/dist/server/reorder-components.js.map +1 -0
- package/dist/server/reorder.js +51 -348
- package/dist/server/reorder.js.map +1 -1
- package/dist/server/runtime.js +26 -15
- package/dist/server/runtime.js.map +1 -1
- package/dist/server/spans-check.js +8 -3
- package/dist/server/spans-check.js.map +1 -1
- package/dist/server/stage.js.map +1 -1
- package/dist/server/unstable/v2/index.js +0 -8
- package/dist/server/unstable/v2/index.js.map +1 -1
- package/dist/server/v1/index.js +1 -1
- package/dist/server/v1/index.js.map +1 -1
- package/dist/server/variant-node.js +4 -2
- package/dist/server/variant-node.js.map +1 -1
- package/dist/server/w.js +33 -3
- package/dist/server/w.js.map +1 -1
- package/dist/server/ward.js +594 -61
- package/dist/server/ward.js.map +1 -1
- package/dist/server/wardic-config.js +63 -30
- package/dist/server/wardic-config.js.map +1 -1
- package/dist/server/wardic-context.js +23 -0
- package/dist/server/wardic-context.js.map +1 -0
- package/dist/server/wardic.js +3 -0
- package/dist/server/wardic.js.map +1 -1
- package/dist/solid/animation-frame.js +1 -1
- package/dist/solid/animation-frame.js.map +1 -1
- package/dist/solid/batch-reorder-group.d.ts +1 -1
- package/dist/solid/batch-reorder.d.ts +1 -1
- package/dist/solid/batch-reorder.d.ts.map +1 -1
- package/dist/solid/config-view.d.ts +11 -0
- package/dist/solid/config-view.d.ts.map +1 -1
- package/dist/solid/config-view.js +31 -7
- package/dist/solid/config-view.js.map +1 -1
- package/dist/solid/create-batch.jsx +1 -1
- package/dist/solid/diagnostic-codes.d.ts +10 -0
- package/dist/solid/diagnostic-codes.d.ts.map +1 -0
- package/dist/solid/diagnostic-codes.js +246 -0
- package/dist/solid/diagnostic-codes.js.map +1 -0
- package/dist/solid/diagnostics.d.ts +33 -0
- package/dist/solid/diagnostics.d.ts.map +1 -0
- package/dist/solid/diagnostics.js +76 -0
- package/dist/solid/diagnostics.js.map +1 -0
- package/dist/solid/element-style.d.ts +16 -2
- package/dist/solid/element-style.d.ts.map +1 -1
- package/dist/solid/element-style.js +61 -7
- package/dist/solid/element-style.js.map +1 -1
- package/dist/solid/element.d.ts +3 -1
- package/dist/solid/element.d.ts.map +1 -1
- package/dist/solid/element.jsx +27 -8
- package/dist/solid/element.jsx.map +1 -1
- package/dist/solid/feature-section.d.ts +0 -7
- package/dist/solid/feature-section.d.ts.map +1 -1
- package/dist/solid/feature-section.js +5 -13
- package/dist/solid/feature-section.js.map +1 -1
- package/dist/solid/frame-effect.jsx +1 -1
- package/dist/solid/frame-effect.jsx.map +1 -1
- package/dist/solid/gesture-callbacks.js +1 -1
- package/dist/solid/gesture-callbacks.js.map +1 -1
- package/dist/solid/hooks/auto.d.ts +44 -0
- package/dist/solid/hooks/auto.d.ts.map +1 -0
- package/dist/solid/hooks/auto.js +269 -0
- package/dist/solid/hooks/auto.js.map +1 -0
- package/dist/solid/hooks/config-scope.d.ts +84 -0
- package/dist/solid/hooks/config-scope.d.ts.map +1 -0
- package/dist/solid/hooks/config-scope.jsx +128 -0
- package/dist/solid/hooks/config-scope.jsx.map +1 -0
- package/dist/solid/hooks/config.d.ts +28 -0
- package/dist/solid/hooks/config.d.ts.map +1 -0
- package/dist/solid/hooks/config.jsx +37 -0
- package/dist/solid/hooks/config.jsx.map +1 -0
- package/dist/solid/hooks/drag.d.ts +220 -0
- package/dist/solid/hooks/drag.d.ts.map +1 -0
- package/dist/solid/hooks/drag.js +586 -0
- package/dist/solid/hooks/drag.js.map +1 -0
- package/dist/solid/hooks/elements.d.ts +11 -0
- package/dist/solid/hooks/elements.d.ts.map +1 -0
- package/dist/solid/hooks/elements.jsx +218 -0
- package/dist/solid/hooks/elements.jsx.map +1 -0
- package/dist/solid/hooks/group.d.ts +46 -0
- package/dist/solid/hooks/group.d.ts.map +1 -0
- package/dist/solid/hooks/group.jsx +25 -0
- package/dist/solid/hooks/group.jsx.map +1 -0
- package/dist/solid/hooks/index.d.ts +28 -0
- package/dist/solid/hooks/index.d.ts.map +1 -0
- package/dist/solid/hooks/index.js +10 -0
- package/dist/solid/hooks/index.js.map +1 -0
- package/dist/solid/hooks/kept.d.ts +60 -0
- package/dist/solid/hooks/kept.d.ts.map +1 -0
- package/dist/solid/hooks/kept.js +33 -0
- package/dist/solid/hooks/kept.js.map +1 -0
- package/dist/solid/hooks/layout-group-of.d.ts +27 -0
- package/dist/solid/hooks/layout-group-of.d.ts.map +1 -0
- package/dist/solid/hooks/layout-group-of.js +39 -0
- package/dist/solid/hooks/layout-group-of.js.map +1 -0
- package/dist/solid/hooks/layout-group.d.ts +60 -0
- package/dist/solid/hooks/layout-group.d.ts.map +1 -0
- package/dist/solid/hooks/layout-group.jsx +80 -0
- package/dist/solid/hooks/layout-group.jsx.map +1 -0
- package/dist/solid/hooks/make-ward.d.ts +123 -0
- package/dist/solid/hooks/make-ward.d.ts.map +1 -0
- package/dist/solid/hooks/make-ward.js +147 -0
- package/dist/solid/hooks/make-ward.js.map +1 -0
- package/dist/solid/hooks/presence-scope.d.ts +84 -0
- package/dist/solid/hooks/presence-scope.d.ts.map +1 -0
- package/dist/solid/hooks/presence-scope.jsx +63 -0
- package/dist/solid/hooks/presence-scope.jsx.map +1 -0
- package/dist/solid/hooks/presence.d.ts +51 -0
- package/dist/solid/hooks/presence.d.ts.map +1 -0
- package/dist/solid/hooks/presence.jsx +26 -0
- package/dist/solid/hooks/presence.jsx.map +1 -0
- package/dist/solid/hooks/props.d.ts +52 -0
- package/dist/solid/hooks/props.d.ts.map +1 -0
- package/dist/solid/hooks/props.js +140 -0
- package/dist/solid/hooks/props.js.map +1 -0
- package/dist/solid/hooks/reads.d.ts +38 -0
- package/dist/solid/hooks/reads.d.ts.map +1 -0
- package/dist/solid/hooks/reads.js +218 -0
- package/dist/solid/hooks/reads.js.map +1 -0
- package/dist/solid/hooks/refs.d.ts +25 -0
- package/dist/solid/hooks/refs.d.ts.map +1 -0
- package/dist/solid/hooks/refs.js +89 -0
- package/dist/solid/hooks/refs.js.map +1 -0
- package/dist/solid/hooks/reorder-elements.d.ts +23 -0
- package/dist/solid/hooks/reorder-elements.d.ts.map +1 -0
- package/dist/solid/hooks/reorder-elements.jsx +274 -0
- package/dist/solid/hooks/reorder-elements.jsx.map +1 -0
- package/dist/solid/hooks/reorder.d.ts +55 -0
- package/dist/solid/hooks/reorder.d.ts.map +1 -0
- package/dist/solid/hooks/reorder.js +152 -0
- package/dist/solid/hooks/reorder.js.map +1 -0
- package/dist/solid/hooks/rune.d.ts +885 -0
- package/dist/solid/hooks/rune.d.ts.map +1 -0
- package/dist/solid/hooks/rune.js +817 -0
- package/dist/solid/hooks/rune.js.map +1 -0
- package/dist/solid/hooks/server-features.client.d.ts +10 -0
- package/dist/solid/hooks/server-features.client.d.ts.map +1 -0
- package/dist/solid/hooks/server-features.client.js +2 -0
- package/dist/solid/hooks/server-features.client.js.map +1 -0
- package/dist/solid/hooks/server-features.d.ts +10 -0
- package/dist/solid/hooks/server-features.d.ts.map +1 -0
- package/dist/solid/hooks/server-features.js +13 -0
- package/dist/solid/hooks/server-features.js.map +1 -0
- package/dist/solid/hooks/settings.d.ts +11 -0
- package/dist/solid/hooks/settings.d.ts.map +1 -0
- package/dist/solid/hooks/settings.js +31 -0
- package/dist/solid/hooks/settings.js.map +1 -0
- package/dist/solid/hooks/setup.d.ts +31 -0
- package/dist/solid/hooks/setup.d.ts.map +1 -0
- package/dist/solid/hooks/setup.js +155 -0
- package/dist/solid/hooks/setup.js.map +1 -0
- package/dist/solid/hooks/stage.d.ts +187 -0
- package/dist/solid/hooks/stage.d.ts.map +1 -0
- package/dist/solid/hooks/stage.js +117 -0
- package/dist/solid/hooks/stage.js.map +1 -0
- package/dist/solid/hooks/ward.d.ts +394 -0
- package/dist/solid/hooks/ward.d.ts.map +1 -0
- package/dist/solid/hooks/ward.js +2258 -0
- package/dist/solid/hooks/ward.js.map +1 -0
- package/dist/solid/hooks/wardic-provider.d.ts +32 -0
- package/dist/solid/hooks/wardic-provider.d.ts.map +1 -0
- package/dist/solid/hooks/wardic-provider.jsx +29 -0
- package/dist/solid/hooks/wardic-provider.jsx.map +1 -0
- package/dist/solid/hooks/wardic-scope.d.ts +49 -0
- package/dist/solid/hooks/wardic-scope.d.ts.map +1 -0
- package/dist/solid/hooks/wardic-scope.jsx +63 -0
- package/dist/solid/hooks/wardic-scope.jsx.map +1 -0
- package/dist/solid/hooks/wards.d.ts +157 -0
- package/dist/solid/hooks/wards.d.ts.map +1 -0
- package/dist/solid/hooks/wards.js +523 -0
- package/dist/solid/hooks/wards.js.map +1 -0
- package/dist/solid/index.d.ts +21 -14
- package/dist/solid/index.d.ts.map +1 -1
- package/dist/solid/index.jsx +23 -11
- package/dist/solid/index.jsx.map +1 -1
- package/dist/solid/layout.d.ts +2 -44
- package/dist/solid/layout.d.ts.map +1 -1
- package/dist/solid/layout.jsx +7 -49
- package/dist/solid/layout.jsx.map +1 -1
- package/dist/solid/lazy-batch-gestures.js +1 -1
- package/dist/solid/lazy-batch-gestures.js.map +1 -1
- package/dist/solid/lifecycle.d.ts +19 -0
- package/dist/solid/lifecycle.d.ts.map +1 -1
- package/dist/solid/lifecycle.js +40 -0
- package/dist/solid/lifecycle.js.map +1 -1
- package/dist/solid/presence-handle.d.ts +13 -6
- package/dist/solid/presence-handle.d.ts.map +1 -1
- package/dist/solid/presence-handle.js +30 -12
- package/dist/solid/presence-handle.js.map +1 -1
- package/dist/solid/presence.d.ts +3 -1
- package/dist/solid/presence.d.ts.map +1 -1
- package/dist/solid/presence.jsx +3 -1
- package/dist/solid/presence.jsx.map +1 -1
- package/dist/solid/provider.d.ts +25 -32
- package/dist/solid/provider.d.ts.map +1 -1
- package/dist/solid/provider.jsx +126 -82
- package/dist/solid/provider.jsx.map +1 -1
- package/dist/solid/reorder-components.d.ts +32 -0
- package/dist/solid/reorder-components.d.ts.map +1 -0
- package/dist/solid/reorder-components.jsx +49 -0
- package/dist/solid/reorder-components.jsx.map +1 -0
- package/dist/solid/reorder.d.ts +50 -76
- package/dist/solid/reorder.d.ts.map +1 -1
- package/dist/solid/reorder.jsx +45 -206
- package/dist/solid/reorder.jsx.map +1 -1
- package/dist/solid/runtime.d.ts +20 -7
- package/dist/solid/runtime.d.ts.map +1 -1
- package/dist/solid/runtime.js +25 -14
- package/dist/solid/runtime.js.map +1 -1
- package/dist/solid/spans-check.d.ts +5 -1
- package/dist/solid/spans-check.d.ts.map +1 -1
- package/dist/solid/spans-check.js +8 -3
- package/dist/solid/spans-check.js.map +1 -1
- package/dist/solid/stage.d.ts +14 -0
- package/dist/solid/stage.d.ts.map +1 -1
- package/dist/solid/stage.js.map +1 -1
- package/dist/solid/unstable/v2/index.d.ts +2 -26
- package/dist/solid/unstable/v2/index.d.ts.map +1 -1
- package/dist/solid/unstable/v2/index.jsx +0 -16
- package/dist/solid/unstable/v2/index.jsx.map +1 -1
- package/dist/solid/v1/index.d.ts +1 -1
- package/dist/solid/v1/index.d.ts.map +1 -1
- package/dist/solid/v1/index.jsx +1 -1
- package/dist/solid/v1/index.jsx.map +1 -1
- package/dist/solid/variant-node.d.ts +6 -0
- package/dist/solid/variant-node.d.ts.map +1 -1
- package/dist/solid/variant-node.js +2 -0
- package/dist/solid/variant-node.js.map +1 -1
- package/dist/solid/w.d.ts +9 -3
- package/dist/solid/w.d.ts.map +1 -1
- package/dist/solid/w.jsx +36 -3
- package/dist/solid/w.jsx.map +1 -1
- package/dist/solid/ward.d.ts +134 -7
- package/dist/solid/ward.d.ts.map +1 -1
- package/dist/solid/ward.jsx +564 -60
- package/dist/solid/ward.jsx.map +1 -1
- package/dist/solid/wardic-config.d.ts +17 -12
- package/dist/solid/wardic-config.d.ts.map +1 -1
- package/dist/solid/wardic-config.jsx +68 -22
- package/dist/solid/wardic-config.jsx.map +1 -1
- package/dist/solid/wardic-context.d.ts +15 -0
- package/dist/solid/wardic-context.d.ts.map +1 -0
- package/dist/solid/wardic-context.js +23 -0
- package/dist/solid/wardic-context.js.map +1 -0
- package/dist/solid/wardic-instance.d.ts +6 -4
- package/dist/solid/wardic-instance.d.ts.map +1 -1
- package/dist/solid/wardic.d.ts +3 -0
- package/dist/solid/wardic.d.ts.map +1 -1
- package/dist/solid/wardic.jsx +3 -0
- package/dist/solid/wardic.jsx.map +1 -1
- package/package.json +29 -7
- package/skills/wardic-diagnostics/SKILL.md +472 -0
- package/skills/wardic-migrate/SKILL.md +204 -0
- package/skills/wardic-solid/SKILL.md +60 -0
- package/skills/wardic-solid/events.md +70 -0
- package/skills/wardic-solid/from-motion.md +59 -0
- package/skills/wardic-solid/lists-and-presence.md +110 -0
- package/skills/wardic-solid/reorder-and-grips.md +88 -0
- package/skills/wardic-solid/runes.md +151 -0
- package/skills/wardic-solid/scopes-and-settings.md +75 -0
- package/src/animation-frame.ts +1 -1
- package/src/batch-reorder-group.tsx +1 -1
- package/src/batch-reorder.ts +1 -1
- package/src/config-view.ts +35 -7
- package/src/create-batch.tsx +1 -1
- package/src/diagnostic-codes.ts +254 -0
- package/src/diagnostics.ts +88 -0
- package/src/element-style.ts +77 -9
- package/src/element.tsx +36 -12
- package/src/feature-section.ts +5 -15
- package/src/frame-effect.tsx +1 -1
- package/src/gesture-callbacks.ts +1 -1
- package/src/hooks/auto.ts +303 -0
- package/src/hooks/config-scope.tsx +215 -0
- package/src/hooks/config.tsx +54 -0
- package/src/hooks/drag.ts +741 -0
- package/src/hooks/elements.tsx +234 -0
- package/src/hooks/group.tsx +55 -0
- package/src/hooks/index.ts +41 -0
- package/src/hooks/kept.ts +89 -0
- package/src/hooks/layout-group-of.ts +46 -0
- package/src/hooks/layout-group.tsx +111 -0
- package/src/hooks/make-ward.ts +218 -0
- package/src/hooks/presence-scope.tsx +156 -0
- package/src/hooks/presence.tsx +67 -0
- package/src/hooks/props.ts +190 -0
- package/src/hooks/reads.ts +258 -0
- package/src/hooks/refs.ts +114 -0
- package/src/hooks/reorder-elements.tsx +323 -0
- package/src/hooks/reorder.ts +205 -0
- package/src/hooks/rune.ts +1756 -0
- package/src/hooks/server-features.client.ts +10 -0
- package/src/hooks/server-features.ts +12 -0
- package/src/hooks/settings.ts +44 -0
- package/src/hooks/setup.ts +184 -0
- package/src/hooks/stage.ts +359 -0
- package/src/hooks/ward.ts +2587 -0
- package/src/hooks/wardic-provider.tsx +51 -0
- package/src/hooks/wardic-scope.tsx +112 -0
- package/src/hooks/wards.ts +681 -0
- package/src/index.tsx +27 -15
- package/src/layout.tsx +7 -74
- package/src/lazy-batch-gestures.ts +1 -1
- package/src/lifecycle.ts +40 -0
- package/src/presence-handle.ts +39 -20
- package/src/presence.tsx +3 -1
- package/src/provider.tsx +136 -88
- package/src/reorder-components.tsx +61 -0
- package/src/reorder.tsx +89 -307
- package/src/runtime.ts +43 -13
- package/src/spans-check.ts +12 -3
- package/src/stage.ts +15 -0
- package/src/unstable/v2/index.tsx +2 -26
- package/src/v1/index.tsx +1 -1
- package/src/variant-node.ts +8 -0
- package/src/w.tsx +38 -5
- package/src/ward.tsx +694 -60
- package/src/wardic-config.tsx +68 -21
- package/src/wardic-context.ts +26 -0
- package/src/wardic-instance.ts +6 -4
- package/src/wardic.tsx +3 -0
- package/dist/browser/create-wardic.js +0 -36
- package/dist/browser/create-wardic.js.map +0 -1
- package/dist/browser/presence-hooks.js +0 -144
- package/dist/browser/presence-hooks.js.map +0 -1
- package/dist/server/create-wardic.js +0 -36
- package/dist/server/create-wardic.js.map +0 -1
- package/dist/server/presence-hooks.js +0 -144
- package/dist/server/presence-hooks.js.map +0 -1
- package/dist/solid/create-wardic.d.ts +0 -25
- package/dist/solid/create-wardic.d.ts.map +0 -1
- package/dist/solid/create-wardic.jsx +0 -34
- package/dist/solid/create-wardic.jsx.map +0 -1
- package/dist/solid/presence-hooks.d.ts +0 -53
- package/dist/solid/presence-hooks.d.ts.map +0 -1
- package/dist/solid/presence-hooks.jsx +0 -117
- package/dist/solid/presence-hooks.jsx.map +0 -1
- package/src/create-wardic.tsx +0 -46
- package/src/presence-hooks.tsx +0 -159
|
@@ -0,0 +1,817 @@
|
|
|
1
|
+
import * as AnimationControls from "@wardic/core/unstable/AnimationControls";
|
|
2
|
+
import * as Arr from "effect/Array";
|
|
3
|
+
import * as Bool from "effect/Boolean";
|
|
4
|
+
import * as Iter from "effect/Iterable";
|
|
5
|
+
import * as Match from "effect/Match";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import * as Predicate from "effect/Predicate";
|
|
8
|
+
import * as Rec from "effect/Record";
|
|
9
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
10
|
+
import { $PROXY, DEV, untrack } from "solid-js";
|
|
11
|
+
import { misuse } from "../diagnostics.js";
|
|
12
|
+
const RUNE = Symbol("wardic.rune");
|
|
13
|
+
const CARRIED = Symbol("wardic.carriedRune");
|
|
14
|
+
/** `value` marked a {@link CarriedRune}: a rune as it is wherever a ward is given it. */
|
|
15
|
+
export const carriedRune = (value) => Object.defineProperty(value, CARRIED, { value: true });
|
|
16
|
+
/** The mark on a value that carries an API ({@link createRuneWith}): not enumerable, so a spread never sees it. */
|
|
17
|
+
const RUNE_API = Symbol("wardic.runeApi");
|
|
18
|
+
/**
|
|
19
|
+
* `api`'s own members as a value carrying them has them: hidden, not enumerable, so a ward and a spread never
|
|
20
|
+
* see them, and read-only, as the API it is; and the mark that says the value carries one.
|
|
21
|
+
*/
|
|
22
|
+
const hiddenMembersOf = (api) => ({
|
|
23
|
+
...Rec.map(Object.getOwnPropertyDescriptors(api), (member) => ({
|
|
24
|
+
...member,
|
|
25
|
+
enumerable: false,
|
|
26
|
+
configurable: false,
|
|
27
|
+
...Bool.match("value" in member, { onTrue: () => ({ writable: false }), onFalse: () => ({}) }),
|
|
28
|
+
})),
|
|
29
|
+
[RUNE_API]: { value: true },
|
|
30
|
+
});
|
|
31
|
+
export function createRuneWith(rune, api) {
|
|
32
|
+
if (DEV)
|
|
33
|
+
refusedInDevelopment(rune, api);
|
|
34
|
+
return carrierOf(rune)(hiddenMembersOf(api));
|
|
35
|
+
}
|
|
36
|
+
/** What development says of `key`, an API member named like one of its rune's keys (the rune-with grill's Q10). */
|
|
37
|
+
const clashOf = (key) => `createRuneWith(rune, api): "${key}" is one of its rune's keys, and the API's would hide it from the ward. Give the API member another name.`;
|
|
38
|
+
/** What development says of an API given to a value that carries one already (the rune-with grill's Q8). */
|
|
39
|
+
const SECOND_API = "createRuneWith(rune, api): this rune already carries an API. Give its rune as it was written, with one API that has every member.";
|
|
40
|
+
/** What development says of a function that's no ref carrying its props, a behaviour written without `createRune` (the review of Q8). */
|
|
41
|
+
const BARE_FUNCTION = "createRuneWith(rune, api): a bare function isn't a rune, and a ward would read nothing of it. A behaviour is `createRune((ward) => …)`.";
|
|
42
|
+
/** Whether `key` is one of `value`'s own keys a ward or a spread reads: an enumerable one. */
|
|
43
|
+
const isOwnKeyOf = (value) => (key) => Object.prototype.propertyIsEnumerable.call(value, key);
|
|
44
|
+
/** Whether `rune` is a function that's no ref carrying its props, nor a behaviour. */
|
|
45
|
+
const isBareFunction = (rune) => {
|
|
46
|
+
if (!Predicate.isFunction(rune))
|
|
47
|
+
return false;
|
|
48
|
+
return Bool.not(isOwnKeyOf(rune)("ref"));
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Development's word on `rune` given `api`: refused where it carries one already, where it's a bare function,
|
|
52
|
+
* or where the API would hide one of its keys.
|
|
53
|
+
*/
|
|
54
|
+
const refusedInDevelopment = (rune, api) => {
|
|
55
|
+
if (RUNE_API in rune)
|
|
56
|
+
throw misuse("WARDIC_RUNE_WITH_INVALID", SECOND_API);
|
|
57
|
+
if (isBareFunction(rune))
|
|
58
|
+
throw misuse("WARDIC_RUNE_WITH_INVALID", BARE_FUNCTION);
|
|
59
|
+
const clash = Arr.findFirst(Object.keys(api), isOwnKeyOf(rune));
|
|
60
|
+
if (Option.isSome(clash))
|
|
61
|
+
throw misuse("WARDIC_RUNE_WITH_INVALID", clashOf(clash.value));
|
|
62
|
+
};
|
|
63
|
+
const isMake = (given) => Predicate.isFunction(given);
|
|
64
|
+
// Its own signature gives back an object: a rune made of a config keeps what its targets were written as.
|
|
65
|
+
export function createRune(given) {
|
|
66
|
+
if (isMake(given))
|
|
67
|
+
return Object.freeze({ [RUNE]: given });
|
|
68
|
+
return madeRune(given);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* `config` made a rune ({@link createRune}): fixed, the data inside it too, and what a ward works out
|
|
72
|
+
* of it worked out now and kept with it. Read untracked, as it may be made in a component's body: its
|
|
73
|
+
* getters, and a store's keys, are read for what they are, not followed. A Stage's `createRune` too.
|
|
74
|
+
*/
|
|
75
|
+
export const madeRune = (config) => untrack(() => {
|
|
76
|
+
// The data inside it frozen in development, as an object given straight to `createWard` is: in
|
|
77
|
+
// a build the rune itself is frozen and its keys fixed, and the walk isn't shipped.
|
|
78
|
+
if (DEV)
|
|
79
|
+
freezeIfPlain(config);
|
|
80
|
+
const rune = fixedRune(config);
|
|
81
|
+
FACTS.set(rune, factsOf(rune, true));
|
|
82
|
+
return rune;
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Each of `runes` fixed as a ward is made of them ({@link fixedRune}), one `createRune` made as it is:
|
|
86
|
+
* an object given straight to `createWard`, a function rune's config, a list's row's own. Frozen, the
|
|
87
|
+
* plain data inside it too, in development alone: a write to one throws there, where an app is made,
|
|
88
|
+
* and a build doesn't pay to freeze a literal for every ward. A rune `createRune` made is frozen in
|
|
89
|
+
* a build too, once. The runes themselves, but for a store or Solid's merged props, which are read
|
|
90
|
+
* through an object of their keys as they are now, in a build as in development.
|
|
91
|
+
*/
|
|
92
|
+
export const fixedRunes = (runes) => {
|
|
93
|
+
if (DEV)
|
|
94
|
+
Arr.forEach(runes, fixInPlace);
|
|
95
|
+
if (!Arr.some(runes, readsThrough))
|
|
96
|
+
return runes;
|
|
97
|
+
return untrack(() => Arr.map(runes, fixedRune));
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Keys whose values are the app's own: a rune fixes the key, and leaves what's inside it to the app.
|
|
101
|
+
* `custom` is handed to its variants, `layoutDependency` compared, `dragControls` driven, and a
|
|
102
|
+
* Subject is the app's object.
|
|
103
|
+
*/
|
|
104
|
+
const KEPT_AS_GIVEN = new Set(["custom", "layoutDependency", "dragControls", "subject"]);
|
|
105
|
+
/** A store, or Solid's merged or omitted props: read through, never frozen. */
|
|
106
|
+
const isProxied = (value) => Predicate.isObject(value) && $PROXY in value;
|
|
107
|
+
/**
|
|
108
|
+
* A carried rune ({@link CarriedRune}), a Reorder list, a function whose own keys are what it gives: an
|
|
109
|
+
* object or a function (`isObjectKeyword`, where `isObject` is no function). Composed once, here: asked of
|
|
110
|
+
* every rune of every ward as it's made, it makes no `dual` call there.
|
|
111
|
+
*/
|
|
112
|
+
const isCarried = Predicate.and(Predicate.isObjectKeyword, (value) => CARRIED in value);
|
|
113
|
+
/**
|
|
114
|
+
* A rune read through an object of its keys as they are now: a store, Solid's merged props, or a
|
|
115
|
+
* carried rune, which as itself was taken for a ward's config where it alone gave the ward keys, and a
|
|
116
|
+
* function is no config (the Reorder round's utilities: a group with no motion props of its own).
|
|
117
|
+
*/
|
|
118
|
+
const readsThrough = Predicate.or(isProxied, isCarried);
|
|
119
|
+
/** Plain data a rune holds: an array, or an object of no class, and no store or Solid's merged props. */
|
|
120
|
+
const isPlainData = (value) => {
|
|
121
|
+
if (!Predicate.isObject(value))
|
|
122
|
+
return false;
|
|
123
|
+
if (Predicate.isFunction(value))
|
|
124
|
+
return false;
|
|
125
|
+
if ($PROXY in value)
|
|
126
|
+
return false;
|
|
127
|
+
if (Array.isArray(value))
|
|
128
|
+
return true;
|
|
129
|
+
const prototype = Object.getPrototypeOf(value);
|
|
130
|
+
if (prototype === Object.prototype)
|
|
131
|
+
return true;
|
|
132
|
+
return prototype === null;
|
|
133
|
+
};
|
|
134
|
+
/** `value` frozen, and every piece of plain data under it: a getter's value isn't read. */
|
|
135
|
+
const freezeData = (value) => {
|
|
136
|
+
if (!isPlainData(value))
|
|
137
|
+
return;
|
|
138
|
+
if (Object.isFrozen(value))
|
|
139
|
+
return;
|
|
140
|
+
Object.freeze(value);
|
|
141
|
+
Arr.forEach(Object.values(Object.getOwnPropertyDescriptors(value)), freezeHeld);
|
|
142
|
+
};
|
|
143
|
+
const freezeHeld = (descriptor) => freezeData(descriptor.value);
|
|
144
|
+
/** The plain data under each of `rune`'s keys frozen, but for what's the app's own ({@link KEPT_AS_GIVEN}). */
|
|
145
|
+
const freezeValues = (rune) => {
|
|
146
|
+
Arr.forEach(Object.keys(rune), (key) => {
|
|
147
|
+
if (KEPT_AS_GIVEN.has(key))
|
|
148
|
+
return;
|
|
149
|
+
const descriptor = Object.getOwnPropertyDescriptor(rune, key);
|
|
150
|
+
if (Predicate.isUndefined(descriptor))
|
|
151
|
+
return;
|
|
152
|
+
freezeData(descriptor.value);
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* `rune` fixed: frozen, and given back. A store or Solid's merged props, which change by their own
|
|
157
|
+
* rules and aren't ours to freeze, and a carried rune, as an object of the keys they have now, frozen,
|
|
158
|
+
* each a getter read through them. An object of a class is given back as it is.
|
|
159
|
+
*/
|
|
160
|
+
const fixedRune = (rune) => {
|
|
161
|
+
if (readsThrough(rune))
|
|
162
|
+
return keysThrough(rune);
|
|
163
|
+
if (!isPlainData(rune))
|
|
164
|
+
return rune;
|
|
165
|
+
if (!Object.isFrozen(rune))
|
|
166
|
+
Object.freeze(rune);
|
|
167
|
+
return rune;
|
|
168
|
+
};
|
|
169
|
+
/** The plain data under `rune`'s keys frozen, where it's a plain object: what development checks ({@link freezeValues}). */
|
|
170
|
+
const freezeIfPlain = (rune) => {
|
|
171
|
+
if (!isPlainData(rune))
|
|
172
|
+
return;
|
|
173
|
+
freezeValues(rune);
|
|
174
|
+
};
|
|
175
|
+
/** One of a ward's runes fixed as it's made, where it isn't one {@link createRune} made: frozen where it's plain, the data inside it too. In development ({@link fixedRunes}). */
|
|
176
|
+
const fixInPlace = (rune) => {
|
|
177
|
+
if (!isPlainData(rune))
|
|
178
|
+
return;
|
|
179
|
+
if (FACTS.has(rune))
|
|
180
|
+
return;
|
|
181
|
+
freezeValues(rune);
|
|
182
|
+
if (!Object.isFrozen(rune))
|
|
183
|
+
Object.freeze(rune);
|
|
184
|
+
};
|
|
185
|
+
/** The descriptors of `source`'s keys as they are now, each a getter read through `source` where it's read. */
|
|
186
|
+
const descriptorsThrough = (source) => {
|
|
187
|
+
const through = {};
|
|
188
|
+
Arr.forEach(Object.keys(source), (key) => {
|
|
189
|
+
through[key] = { enumerable: true, get: () => source[key] };
|
|
190
|
+
});
|
|
191
|
+
return through;
|
|
192
|
+
};
|
|
193
|
+
/** `source`'s keys as they are now, frozen, each read through `source` where it's read. Called untracked. */
|
|
194
|
+
const keysThrough = (source) => Object.freeze(Object.defineProperties({}, descriptorsThrough(source)));
|
|
195
|
+
/** What's fixed for a getter's key: read across the runes, where it's read. */
|
|
196
|
+
const ACROSS = Symbol("wardic.rune.across");
|
|
197
|
+
/**
|
|
198
|
+
* What's worked out of each rune `createRune` made, held by the rune: the same for every ward made of it.
|
|
199
|
+
*
|
|
200
|
+
* Module state (#460, Q7): a cache held weakly by the rune it's for, so it goes with it.
|
|
201
|
+
*/
|
|
202
|
+
const FACTS = new WeakMap();
|
|
203
|
+
/**
|
|
204
|
+
* `rune`'s facts ({@link RuneFacts}), worked out of its keys, each read once. Read untracked: a getter
|
|
205
|
+
* read here isn't followed. With `fixes` for a rune that keeps them.
|
|
206
|
+
*/
|
|
207
|
+
const factsOf = (rune, kept) => {
|
|
208
|
+
const keys = Object.keys(rune);
|
|
209
|
+
let fixes;
|
|
210
|
+
if (kept)
|
|
211
|
+
fixes = {};
|
|
212
|
+
let seen = 0;
|
|
213
|
+
let joins = false;
|
|
214
|
+
let callback = false;
|
|
215
|
+
let gives = false;
|
|
216
|
+
Arr.forEach(keys, (key) => {
|
|
217
|
+
const bit = SEEN_BIT.get(key);
|
|
218
|
+
if (Predicate.isNotUndefined(bit))
|
|
219
|
+
seen |= bit;
|
|
220
|
+
if (key === "follow")
|
|
221
|
+
joins = true;
|
|
222
|
+
if (key === "followers")
|
|
223
|
+
joins = true;
|
|
224
|
+
// The hooks' own: never the ward's config's.
|
|
225
|
+
if (OWN_KEYS.has(key))
|
|
226
|
+
return;
|
|
227
|
+
gives = true;
|
|
228
|
+
if (key === "variants") {
|
|
229
|
+
if (variantsNeedJoining(rune))
|
|
230
|
+
joins = true;
|
|
231
|
+
}
|
|
232
|
+
if (AS_GIVEN.has(key))
|
|
233
|
+
callback = true;
|
|
234
|
+
if (Predicate.isNotUndefined(fixes))
|
|
235
|
+
fixes[key] = fixOf(rune, key);
|
|
236
|
+
});
|
|
237
|
+
// Whether it's a ward's config alone is asked of a rune kept, as a ward may be made of it alone;
|
|
238
|
+
// of any other it's asked where it is, so it isn't worked out here for every rune of every ward.
|
|
239
|
+
let plain = false;
|
|
240
|
+
if (kept)
|
|
241
|
+
plain = isPlainConfig(rune);
|
|
242
|
+
return { plain, givesTheWard: gives, joins, callback, seen, keys, fixes };
|
|
243
|
+
};
|
|
244
|
+
/** What's fixed for `key` of `rune` over another rune's, where it alone gives it: its value, or its accessor, or {@link ACROSS} for a getter's. */
|
|
245
|
+
const fixOf = (rune, key) => {
|
|
246
|
+
const descriptor = Object.getOwnPropertyDescriptor(rune, key);
|
|
247
|
+
if (Predicate.isUndefined(descriptor))
|
|
248
|
+
return ACROSS;
|
|
249
|
+
if (Predicate.isNotUndefined(descriptor.get))
|
|
250
|
+
return ACROSS;
|
|
251
|
+
return descriptor.value;
|
|
252
|
+
};
|
|
253
|
+
/** A rune's facts: kept, for one `createRune` made, or worked out now, as a ward is made of it. */
|
|
254
|
+
const factsFor = (rune) => {
|
|
255
|
+
const kept = FACTS.get(rune);
|
|
256
|
+
if (Predicate.isNotUndefined(kept))
|
|
257
|
+
return kept;
|
|
258
|
+
return factsOf(rune, false);
|
|
259
|
+
};
|
|
260
|
+
/** Whether one rune can be a ward's config as it is ({@link isPlainConfig}): kept, for one `createRune` made, or worked out now, untracked. */
|
|
261
|
+
export const isPlainRune = (rune) => {
|
|
262
|
+
const kept = FACTS.get(rune);
|
|
263
|
+
if (Predicate.isNotUndefined(kept))
|
|
264
|
+
return kept.plain;
|
|
265
|
+
return untrack(() => isPlainConfig(rune));
|
|
266
|
+
};
|
|
267
|
+
/** Whether `value` is a `createRune(fn)`. */
|
|
268
|
+
export const isFunctionRune = (value) => {
|
|
269
|
+
// Asked of every rune of every ward as it's made: plain checks, where `Predicate.hasProperty` is a
|
|
270
|
+
// `dual` call with what it allocates for one (188 bytes a ward of five runes, by a heap profile).
|
|
271
|
+
if (!Predicate.isObject(value))
|
|
272
|
+
return false;
|
|
273
|
+
return RUNE in value;
|
|
274
|
+
};
|
|
275
|
+
/** `value`'s function: what `createRune(fn)` holds. */
|
|
276
|
+
export const functionOf = (value) => value[RUNE];
|
|
277
|
+
/**
|
|
278
|
+
* The value that carries an API's `members` beside `rune` (the rune-with grill's Q8), by what the rune is:
|
|
279
|
+
* a behaviour, frozen, in a new one of its own; a function (a ref carrying its props, a Reorder group) as it
|
|
280
|
+
* is, so it's still called as a ref; a plain rune, a fresh value read through it, so a rune shared between
|
|
281
|
+
* calls is never changed, its keys as they are now, each read live (Q3). Built once, at module load: after
|
|
282
|
+
* {@link isFunctionRune}, which it reads.
|
|
283
|
+
*/
|
|
284
|
+
const carrierOf = Match.type().pipe(Match.when(isFunctionRune, (behaviour) => (members) => Object.freeze(Object.defineProperties({ [RUNE]: functionOf(behaviour) }, members))), Match.when(Predicate.isFunction, (ref) => (members) => carriedRune(Object.defineProperties(ref, members))),
|
|
285
|
+
// Its keys read untracked, as `createRune(config)` reads them: a store's are what they are, not followed.
|
|
286
|
+
Match.orElse((plain) => (members) => Object.freeze(carriedRune(Object.defineProperties({}, { ...untrack(() => descriptorsThrough(plain)), ...members })))));
|
|
287
|
+
/** The keys whose values are targets: two objects merge their keys. */
|
|
288
|
+
const TARGET_KEYS = new Set(["initial", "animate", "exit", "whileHover", "whileTap", "whileFocus", "whileInView", "whileDrag"]);
|
|
289
|
+
/** The keys whose objects merge their keys. */
|
|
290
|
+
const OBJECT_KEYS = new Set([...TARGET_KEYS, "transition", "style", "viewport", "followers"]);
|
|
291
|
+
/** The keys a function is the value of, never an accessor: the ward's callbacks, and the hooks' own. */
|
|
292
|
+
const AS_GIVEN = new Set(["onUpdate", "dragConstraints", "onMeasureDragConstraints", "transformTemplate", "onBeforeLayoutMeasure", "onLayoutMeasure", "follow", "show", "popBox", "subject", "ref", "lifted", "transformPagePoint"]);
|
|
293
|
+
/**
|
|
294
|
+
* The keys the hooks read themselves, which the ward's config never carries. A `ref` is every rune's
|
|
295
|
+
* own: none wins (`refs.ts`). Its `props` are joined name by name, onto the ward's spread (`props.ts`).
|
|
296
|
+
*/
|
|
297
|
+
const OWN_KEYS = new Set(["follow", "show", "followers", "pop", "enter", "popBox", "subject", "ref", "props", "tag", "lifted"]);
|
|
298
|
+
const isPlain = (value) => Predicate.isObject(value) && !Array.isArray(value) && !Predicate.isFunction(value);
|
|
299
|
+
/** A rune's value for `key`: an accessor called, as the ward itself reads one. */
|
|
300
|
+
const read = (config, key) => {
|
|
301
|
+
const value = config[key];
|
|
302
|
+
if (AS_GIVEN.has(key))
|
|
303
|
+
return value;
|
|
304
|
+
if (Predicate.isFunction(value))
|
|
305
|
+
return value();
|
|
306
|
+
return value;
|
|
307
|
+
};
|
|
308
|
+
const mergeObjects = (earlier, later) => {
|
|
309
|
+
if (Predicate.isUndefined(later))
|
|
310
|
+
return earlier;
|
|
311
|
+
if (isPlain(earlier) && isPlain(later))
|
|
312
|
+
return { ...earlier, ...later };
|
|
313
|
+
return later;
|
|
314
|
+
};
|
|
315
|
+
/** A variant as its target: a function of `custom` called with it. */
|
|
316
|
+
const variantWith = (variant, custom) => {
|
|
317
|
+
if (Predicate.isFunction(variant))
|
|
318
|
+
return variant(custom);
|
|
319
|
+
return variant;
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* One rune's variant over another's, under one name. Two targets merge their keys. With a function of
|
|
323
|
+
* `custom` among them the two still join, as a function of it: each is resolved with the `custom` it's
|
|
324
|
+
* called with, and their targets merge. So a rune that says where a name puts a ward by its `custom`
|
|
325
|
+
* and a rune that says how the name fades it are one variant, where the later one replaced the other.
|
|
326
|
+
*/
|
|
327
|
+
const mergeVariant = (earlier, later) => {
|
|
328
|
+
if (Predicate.isUndefined(later))
|
|
329
|
+
return earlier;
|
|
330
|
+
if (Predicate.isUndefined(earlier))
|
|
331
|
+
return later;
|
|
332
|
+
if (!Predicate.isFunction(earlier) && !Predicate.isFunction(later))
|
|
333
|
+
return mergeObjects(earlier, later);
|
|
334
|
+
return (custom) => mergeObjects(variantWith(earlier, custom), variantWith(later, custom));
|
|
335
|
+
};
|
|
336
|
+
const mergeVariants = (earlier, later) => {
|
|
337
|
+
if (Predicate.isUndefined(later))
|
|
338
|
+
return earlier;
|
|
339
|
+
if (!isPlain(earlier) || !isPlain(later))
|
|
340
|
+
return later;
|
|
341
|
+
return { ...earlier, ...Rec.map(later, (variant, name) => mergeVariant(earlier[name], variant)) };
|
|
342
|
+
};
|
|
343
|
+
/** `followers`' timing as the transition keys core reads. */
|
|
344
|
+
const timingOf = (followers) => {
|
|
345
|
+
const timing = {};
|
|
346
|
+
if (Predicate.isNotUndefined(followers.stagger))
|
|
347
|
+
timing.staggerChildren = followers.stagger;
|
|
348
|
+
if (Predicate.isNotUndefined(followers.delay))
|
|
349
|
+
timing.delayChildren = followers.delay;
|
|
350
|
+
if (followers.from === "last")
|
|
351
|
+
timing.staggerDirection = -1;
|
|
352
|
+
if (followers.order === "leader-first")
|
|
353
|
+
timing.when = "beforeChildren";
|
|
354
|
+
if (followers.order === "followers-first")
|
|
355
|
+
timing.when = "afterChildren";
|
|
356
|
+
return timing;
|
|
357
|
+
};
|
|
358
|
+
/** `transition` with `followers`' timing under its own keys. */
|
|
359
|
+
const withTiming = (transition, followers) => {
|
|
360
|
+
if (!isPlain(followers))
|
|
361
|
+
return transition;
|
|
362
|
+
if (isPlain(transition))
|
|
363
|
+
return { ...timingOf(followers), ...transition };
|
|
364
|
+
return timingOf(followers);
|
|
365
|
+
};
|
|
366
|
+
/** A variant without its `followers`, its timing in its `transition`. */
|
|
367
|
+
const variantWithTiming = (variant) => {
|
|
368
|
+
if (!isPlain(variant))
|
|
369
|
+
return variant;
|
|
370
|
+
if (!("followers" in variant))
|
|
371
|
+
return variant;
|
|
372
|
+
const { followers, transition, ...target } = variant;
|
|
373
|
+
return { ...target, transition: withTiming(transition, followers) };
|
|
374
|
+
};
|
|
375
|
+
/** Whether a variant carries `followers`. */
|
|
376
|
+
const hasFollowers = (variant) => isPlain(variant) && "followers" in variant;
|
|
377
|
+
/** Whether any variant in `variants` carries `followers`. */
|
|
378
|
+
const anyTiming = (variants) => {
|
|
379
|
+
if (!isPlain(variants))
|
|
380
|
+
return false;
|
|
381
|
+
return Rec.some(variants, hasFollowers);
|
|
382
|
+
};
|
|
383
|
+
const variantsWithTiming = (variants) => {
|
|
384
|
+
if (!anyTiming(variants))
|
|
385
|
+
return variants;
|
|
386
|
+
return Rec.map(variants, variantWithTiming);
|
|
387
|
+
};
|
|
388
|
+
const isLabels = (value) => Predicate.isString(value) || Array.isArray(value);
|
|
389
|
+
/** A follower's own names as targets: each name's variant, a function's called with `custom`, merged in order. */
|
|
390
|
+
const targetOf = (labels, variants, custom) => {
|
|
391
|
+
if (!isPlain(variants))
|
|
392
|
+
return undefined;
|
|
393
|
+
return Arr.reduce(Arr.ensure(labels), undefined, (target, name) => mergeObjects(target, variantWith(variants[name], custom)));
|
|
394
|
+
};
|
|
395
|
+
/** Whether a value written at a target key may name a state: a name, a function, or Animation controls, which can start one. */
|
|
396
|
+
const mayNameBy = (value) => Bool.or(Bool.or(isLabels(value), Predicate.isFunction(value)), AnimationControls.isAnimationControls(value));
|
|
397
|
+
/** Whether `rune`'s `key`, as it's written, may name a state ({@link mayNameBy}), or is a getter's, which isn't called here. */
|
|
398
|
+
const mayNameAt = (rune, key) => {
|
|
399
|
+
const descriptor = Object.getOwnPropertyDescriptor(rune, key);
|
|
400
|
+
if (Predicate.isUndefined(descriptor))
|
|
401
|
+
return false;
|
|
402
|
+
if (Predicate.isNotUndefined(descriptor.get))
|
|
403
|
+
return true;
|
|
404
|
+
return mayNameBy(descriptor.value);
|
|
405
|
+
};
|
|
406
|
+
/** The keys that give a ward names whatever its targets say: its own `variants`, its `inherit`, or a ward it follows, whose it hands on. */
|
|
407
|
+
const NAMES_GIVEN_BY = new Set(["variants", "inherit", "follow"]);
|
|
408
|
+
/**
|
|
409
|
+
* Whether a ward of `rune` may name a state a follower takes: one that sets a key of
|
|
410
|
+
* {@link NAMES_GIVEN_BY}, or at any target key may name one ({@link mayNameAt}). A function rune, and any
|
|
411
|
+
* value that isn't a plain rune, may: neither is read here.
|
|
412
|
+
*/
|
|
413
|
+
const mayName = (rune) => {
|
|
414
|
+
if (isFunctionRune(rune))
|
|
415
|
+
return true;
|
|
416
|
+
if (!isPlain(rune))
|
|
417
|
+
return true;
|
|
418
|
+
if (Iter.some(NAMES_GIVEN_BY, (key) => key in rune))
|
|
419
|
+
return true;
|
|
420
|
+
return Iter.some(TARGET_KEYS, (key) => mayNameAt(rune, key));
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Whether a ward of `runes` names no state at all, as they're written (the follow grill's Q2): what a ward
|
|
424
|
+
* that follows it is warned of in development. Nothing is read to say so: a function, a getter or a
|
|
425
|
+
* function rune may name one, and isn't called.
|
|
426
|
+
*/
|
|
427
|
+
export const namesNothing = (runes) => !Arr.some(runes, mayName);
|
|
428
|
+
/** Whether `rune` sets `variants` of its own, as it's written: a function rune's aren't read here. */
|
|
429
|
+
const setsVariants = (rune) => {
|
|
430
|
+
if (isFunctionRune(rune))
|
|
431
|
+
return false;
|
|
432
|
+
if (!isPlain(rune))
|
|
433
|
+
return false;
|
|
434
|
+
return "variants" in rune;
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* Whether a ward of `runes` has `variants` of its own, as they're written (the follow grill's Q12): one a
|
|
438
|
+
* follower is warned for, where the ward it follows names no state, since none of its variants can ever be
|
|
439
|
+
* chosen. One with none follows only to leave with its leader (Q12, Q20), and isn't.
|
|
440
|
+
*/
|
|
441
|
+
export const hasOwnVariants = (runes) => Arr.some(runes, setsVariants);
|
|
442
|
+
/** The gesture keys: a follower keeps its own names in these (the gap grill's Q26). */
|
|
443
|
+
const GESTURE_KEYS = ["whileHover", "whileTap", "whileFocus", "whileInView", "whileDrag"];
|
|
444
|
+
/** Whether `key` is a gesture's. */
|
|
445
|
+
const isGestureKey = (key) => Arr.contains(GESTURE_KEYS, key);
|
|
446
|
+
/**
|
|
447
|
+
* Whether `config` names a gesture of its own, as it's written (Q26). A follower that does keeps the
|
|
448
|
+
* name and is a Variant child by its own word (core's `variantChild`): it joins its leader, and hands
|
|
449
|
+
* the name down to followers of its own. One behind an accessor isn't seen here.
|
|
450
|
+
*/
|
|
451
|
+
const namesGesture = (config) => Arr.some(GESTURE_KEYS, (key) => isLabels(config[key]));
|
|
452
|
+
/** Whether one config alone needs none of the hooks' own work: it can be the ward's config as it is. */
|
|
453
|
+
export const isPlainConfig = (config) => {
|
|
454
|
+
const loose = config;
|
|
455
|
+
if (Iter.some(OWN_KEYS, (key) => key in loose))
|
|
456
|
+
return false;
|
|
457
|
+
// A getter's variants are read where the ward reads them; a plain object is checked here.
|
|
458
|
+
const descriptor = Object.getOwnPropertyDescriptor(loose, "variants");
|
|
459
|
+
if (Predicate.isUndefined(descriptor))
|
|
460
|
+
return true;
|
|
461
|
+
if (Predicate.isNotUndefined(descriptor.get))
|
|
462
|
+
return false;
|
|
463
|
+
return !anyTiming(descriptor.value);
|
|
464
|
+
};
|
|
465
|
+
/** No key left out of a joined config: the page's wards. */
|
|
466
|
+
const NONE_OMITTED = new Set();
|
|
467
|
+
/**
|
|
468
|
+
* Whether a rune's `variants` have to be joined ({@link joined}), and can't be read as they're
|
|
469
|
+
* written: they carry timing for its followers, or they're an accessor's or a getter's, where that's
|
|
470
|
+
* found as they're read.
|
|
471
|
+
*/
|
|
472
|
+
const variantsNeedJoining = (config) => {
|
|
473
|
+
const descriptor = Object.getOwnPropertyDescriptor(config, "variants");
|
|
474
|
+
if (Predicate.isUndefined(descriptor))
|
|
475
|
+
return false;
|
|
476
|
+
if (Predicate.isNotUndefined(descriptor.get))
|
|
477
|
+
return true;
|
|
478
|
+
if (Predicate.isFunction(descriptor.value))
|
|
479
|
+
return true;
|
|
480
|
+
return anyTiming(descriptor.value);
|
|
481
|
+
};
|
|
482
|
+
/** Whether `config` gives `key`: one of its own, as its keys are listed, with no list made of them. */
|
|
483
|
+
const givenBy = (config, key) => Object.prototype.propertyIsEnumerable.call(config, key);
|
|
484
|
+
/**
|
|
485
|
+
* What's fixed over the source for `key`, which `config` gives beside it.
|
|
486
|
+
*
|
|
487
|
+
* Where no rune before it gives the key and it's written plainly, that's the rune's own: its value,
|
|
488
|
+
* or its accessor, called as the ward calls the source's own. Nothing stands between the ward and
|
|
489
|
+
* it: a function for each, read at every read, cost a ward of five runes a microsecond as it
|
|
490
|
+
* mounted. Otherwise it's a function that reads the key across the runes as it's read: one several
|
|
491
|
+
* of them give (a later one wins, objects merge, their `variants` name by name), and a getter's,
|
|
492
|
+
* which is read where the ward reads it and not here. A key across the runes is the runes' own:
|
|
493
|
+
* none of them follows, times its followers or carries timing in its variants, which is all a joined
|
|
494
|
+
* read adds.
|
|
495
|
+
*
|
|
496
|
+
* One rune's `variants` are its own, as written, as any key it alone gives is: merged across the
|
|
497
|
+
* runes with nothing beside them, they were the same object, found by a pass over every rune at each
|
|
498
|
+
* read, which a ward of ten runes paid for a point or two at its Retarget. Ones that are an accessor's,
|
|
499
|
+
* a getter's or carry timing never come here: such a rune is joined.
|
|
500
|
+
*
|
|
501
|
+
* A key a later rune gives too is found as that rune is read, and fixed again, across them.
|
|
502
|
+
*/
|
|
503
|
+
const besideOf = (runes, source, beside, config, facts, key) => {
|
|
504
|
+
if (key in source)
|
|
505
|
+
return () => acrossIn(runes, key);
|
|
506
|
+
if (key in beside)
|
|
507
|
+
return () => acrossIn(runes, key);
|
|
508
|
+
// A store is read through an object of its keys' getters (`fixedRunes`), so its keys are getters
|
|
509
|
+
// here: read as the ward reads them, through the store (HY7).
|
|
510
|
+
const fixed = fixedIn(facts, config, key);
|
|
511
|
+
if (fixed === ACROSS)
|
|
512
|
+
return () => acrossIn(runes, key);
|
|
513
|
+
return fixed;
|
|
514
|
+
};
|
|
515
|
+
/** What's fixed for `key` of `config`: kept in its facts, for a rune `createRune` made, else looked up now. */
|
|
516
|
+
const fixedIn = (facts, config, key) => {
|
|
517
|
+
const fixes = facts.fixes;
|
|
518
|
+
if (Predicate.isUndefined(fixes))
|
|
519
|
+
return fixOf(config, key);
|
|
520
|
+
return fixes[key];
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* Keys only some wards' runes give, each with work of the hooks' own behind it: a rune's `props`
|
|
524
|
+
* and `ref`, a ward's `subject`, a twin's `layoutId`, the `animate` a presence takes a ward by, a
|
|
525
|
+
* ward's `show` and `enter`, and its Subject's `tag`. The pass that reads a ward's runes notes which it saw ({@link ReadThrough.seen}), so each needn't
|
|
526
|
+
* be looked for across the runes again: a pass apiece, for every ward, most with none of them.
|
|
527
|
+
*/
|
|
528
|
+
export const SEEN = { props: 1, ref: 2, subject: 4, layoutId: 8, animate: 16, show: 32, enter: 64, exit: 128, tag: 256 };
|
|
529
|
+
const SEEN_BIT = new Map(Object.entries(SEEN));
|
|
530
|
+
/**
|
|
531
|
+
* The answers for runes `createRune` made, by the runes in the order they're given, from the first.
|
|
532
|
+
*
|
|
533
|
+
* Module state (#460, Q7): a cache held weakly by the runes it's for, so it goes with them.
|
|
534
|
+
*/
|
|
535
|
+
const COMBINED = new WeakMap();
|
|
536
|
+
/** The step for `configs` from `at` on, made as it's first asked for; none where one isn't a rune `createRune` made. */
|
|
537
|
+
const combinedAt = (configs, at, steps) => {
|
|
538
|
+
const rune = configs[at];
|
|
539
|
+
if (!FACTS.has(rune))
|
|
540
|
+
return undefined;
|
|
541
|
+
let step = steps.get(rune);
|
|
542
|
+
if (Predicate.isUndefined(step)) {
|
|
543
|
+
step = { known: false, through: undefined, next: new WeakMap() };
|
|
544
|
+
steps.set(rune, step);
|
|
545
|
+
}
|
|
546
|
+
if (at === configs.length - 1)
|
|
547
|
+
return step;
|
|
548
|
+
return combinedAt(configs, at + 1, step.next);
|
|
549
|
+
};
|
|
550
|
+
/**
|
|
551
|
+
* `configs` as runes read through as they're written ({@link joinedOver}), when they can be: one
|
|
552
|
+
* gives the ward a key, and none has to be joined key by key ({@link joined}). A list's row
|
|
553
|
+
* (`{ show }`, the row's own runes, and where it popped), a ward of one rune, a ward of several.
|
|
554
|
+
*
|
|
555
|
+
* A rune has to be joined that follows, or times its followers, whose names and timing are
|
|
556
|
+
* resolved as each key is read; whose `variants` carry timing, or are an accessor's or a getter's
|
|
557
|
+
* ({@link variantsNeedJoining}); or that gives a
|
|
558
|
+
* callback beside the source. What's fixed over a config is a function the ward calls for a key's
|
|
559
|
+
* value, and a callback's value is the function itself, which the ward calls with what it tells:
|
|
560
|
+
* fixed that way, `onUpdate` was asked for and never told (HY5). A callback of the source's own is
|
|
561
|
+
* the ward's as it's written.
|
|
562
|
+
*
|
|
563
|
+
* In one pass over the runes, each one's facts read once ({@link readRune}): kept with a rune
|
|
564
|
+
* `createRune` made, and worked out for any other. Where every rune is one `createRune` made, the
|
|
565
|
+
* answer is the same each time they're given together in that order, and kept too ({@link COMBINED}):
|
|
566
|
+
* a component that makes its ward of runes kept in constants works none of it out again.
|
|
567
|
+
*/
|
|
568
|
+
export const readThroughOf = (configs) => {
|
|
569
|
+
const step = combinedAt(configs, 0, COMBINED);
|
|
570
|
+
if (Predicate.isUndefined(step))
|
|
571
|
+
return untrack(() => readAll(configs));
|
|
572
|
+
if (step.known)
|
|
573
|
+
return step.through;
|
|
574
|
+
const through = readAll(configs);
|
|
575
|
+
step.through = through;
|
|
576
|
+
step.known = true;
|
|
577
|
+
return through;
|
|
578
|
+
};
|
|
579
|
+
/** {@link readThroughOf}, worked out: one pass over `configs`. */
|
|
580
|
+
const readAll = (configs) => {
|
|
581
|
+
const runes = configs;
|
|
582
|
+
const reading = { source: undefined, beside: undefined, seen: 0, joined: false, made: true };
|
|
583
|
+
Arr.forEach(runes, (config) => readRune(reading, runes, config));
|
|
584
|
+
if (reading.joined)
|
|
585
|
+
return undefined;
|
|
586
|
+
const source = reading.source;
|
|
587
|
+
if (Predicate.isUndefined(source))
|
|
588
|
+
return undefined;
|
|
589
|
+
return { source, configs, beside: reading.beside, seen: reading.seen };
|
|
590
|
+
};
|
|
591
|
+
/** Where what's beside the source is kept, made at the first key there. */
|
|
592
|
+
const besideIn = (reading) => {
|
|
593
|
+
const made = reading.beside;
|
|
594
|
+
if (Predicate.isNotUndefined(made))
|
|
595
|
+
return made;
|
|
596
|
+
const beside = {};
|
|
597
|
+
reading.beside = beside;
|
|
598
|
+
return beside;
|
|
599
|
+
};
|
|
600
|
+
/**
|
|
601
|
+
* One rune, by its facts ({@link readThroughOf}): whether it has to be joined, whether it's the
|
|
602
|
+
* source, the first to give the ward a key, and what it gives beside the source.
|
|
603
|
+
*/
|
|
604
|
+
const readRune = (reading, runes, config) => {
|
|
605
|
+
if (reading.joined)
|
|
606
|
+
return;
|
|
607
|
+
const facts = factsFor(config);
|
|
608
|
+
reading.seen |= facts.seen;
|
|
609
|
+
if (facts.joins) {
|
|
610
|
+
reading.joined = true;
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
if (!facts.givesTheWard)
|
|
614
|
+
return;
|
|
615
|
+
const source = reading.source;
|
|
616
|
+
if (Predicate.isUndefined(source)) {
|
|
617
|
+
reading.source = config;
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
if (facts.callback) {
|
|
621
|
+
reading.joined = true;
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const beside = besideIn(reading);
|
|
625
|
+
Arr.forEach(facts.keys, (key) => {
|
|
626
|
+
// The hooks' own give the ward nothing.
|
|
627
|
+
if (OWN_KEYS.has(key))
|
|
628
|
+
return;
|
|
629
|
+
beside[key] = besideOf(runes, source, beside, config, facts, key);
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
/** What a rune read through is viewed over, for its keys as they read ({@link Joined.asRead}): every answer is the view's. */
|
|
633
|
+
const NO_KEYS = {};
|
|
634
|
+
/**
|
|
635
|
+
* One plain rune's keys as its ward reads them, an accessor's as its result: what {@link Joined.asRead}
|
|
636
|
+
* is for runes that are joined, for a rune that's its ward's config as it is.
|
|
637
|
+
*/
|
|
638
|
+
export const asReadOf = (config) => new Proxy(NO_KEYS, { get: (_none, key) => read(config, key) });
|
|
639
|
+
/**
|
|
640
|
+
* The keys a ward's wiring reads, each as how it's read through that wiring: `initial` where the
|
|
641
|
+
* ward has no entrance, `animate`, and `exit`, `custom` and `style` where the wiring has one for it
|
|
642
|
+
* and, for the first two, a rune gives the key (`has`). The one set, for a joined config's getters
|
|
643
|
+
* and for a rune read through.
|
|
644
|
+
*/
|
|
645
|
+
export const wiredOf = (wiring, unentered, value, has) => {
|
|
646
|
+
const wired = {};
|
|
647
|
+
// No entrance: none, so it starts at its `animate`; its own `initial` for an element that enters afresh later.
|
|
648
|
+
if (unentered) {
|
|
649
|
+
wired["initial"] = () => {
|
|
650
|
+
if (Predicate.isUndefined(wiring))
|
|
651
|
+
return false;
|
|
652
|
+
if (Predicate.isUndefined(wiring.reenters))
|
|
653
|
+
return false;
|
|
654
|
+
if (wiring.reenters())
|
|
655
|
+
return value("initial");
|
|
656
|
+
return false;
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
if (Predicate.isUndefined(wiring))
|
|
660
|
+
return wired;
|
|
661
|
+
wired["animate"] = () => wiring.animate(value("animate"));
|
|
662
|
+
const hidden = wiring.exit;
|
|
663
|
+
if (Predicate.isNotUndefined(hidden) && has("exit"))
|
|
664
|
+
wired["exit"] = () => hidden(value("exit"));
|
|
665
|
+
const kept = wiring.custom;
|
|
666
|
+
if (Predicate.isNotUndefined(kept) && has("custom"))
|
|
667
|
+
wired["custom"] = () => kept(() => value("custom"));
|
|
668
|
+
const styled = wiring.style;
|
|
669
|
+
if (Predicate.isNotUndefined(styled))
|
|
670
|
+
wired["style"] = () => styled(value("style"));
|
|
671
|
+
return wired;
|
|
672
|
+
};
|
|
673
|
+
/**
|
|
674
|
+
* Runes as a ward's config with no key joined: what {@link joined} gives for them, where none of
|
|
675
|
+
* them needs it ({@link readThroughOf}). The config is one of the runes itself, the first that
|
|
676
|
+
* gives the ward a key, read as a ward reads any config. Whatever else is to be read from somewhere
|
|
677
|
+
* other than that rune is handed back (`wired`) for the ward to fix over it, its own way to read a
|
|
678
|
+
* key from elsewhere: a key another rune gives, read across them all as joined; a key the ward's
|
|
679
|
+
* wiring reads. So nothing is copied, no getter is made, and no rune is an object's prototype: one
|
|
680
|
+
* over each rune was tried first, and a ward's reads of its config cost more through it than the
|
|
681
|
+
* join had (`docs/research/hooks-first-probe.md`, *The trims*).
|
|
682
|
+
*/
|
|
683
|
+
export const joinedOver = ({ source, configs, beside, seen }, shown) => {
|
|
684
|
+
const loose = configs;
|
|
685
|
+
const first = source;
|
|
686
|
+
const own = (key) => acrossIn(loose, key);
|
|
687
|
+
const has = (key) => Arr.some(loose, (config) => givenBy(config, key));
|
|
688
|
+
// A key of the ward's that no rune beside the source gives is the source's own, read straight
|
|
689
|
+
// from it: a list's row, whose other runes give keys of the hooks' own alone.
|
|
690
|
+
const value = (key) => {
|
|
691
|
+
if (OWN_KEYS.has(key))
|
|
692
|
+
return own(key);
|
|
693
|
+
if (Predicate.isUndefined(beside))
|
|
694
|
+
return read(first, key);
|
|
695
|
+
if (Object.hasOwn(beside, key))
|
|
696
|
+
return own(key);
|
|
697
|
+
return read(first, key);
|
|
698
|
+
};
|
|
699
|
+
// Made when it's asked for: only a ward whose Features are found by its config asks. A key fixed
|
|
700
|
+
// over the source reads as it's fixed, as a joined config's getter does. Over an object with no
|
|
701
|
+
// keys, not over the rune: a view must answer a frozen object's key with that object's own value,
|
|
702
|
+
// and a frozen rune's accessor reads as its result.
|
|
703
|
+
const asRead = () => new Proxy(NO_KEYS, {
|
|
704
|
+
get: (_rune, key) => {
|
|
705
|
+
const wired = self.wired;
|
|
706
|
+
if (Predicate.isUndefined(wired))
|
|
707
|
+
return value(key);
|
|
708
|
+
if (!Object.hasOwn(wired, key))
|
|
709
|
+
return value(key);
|
|
710
|
+
// As the ward reads what's fixed: a value, or a function called for it.
|
|
711
|
+
const fixed = wired[key];
|
|
712
|
+
if (Predicate.isFunction(fixed))
|
|
713
|
+
return fixed();
|
|
714
|
+
return fixed;
|
|
715
|
+
},
|
|
716
|
+
});
|
|
717
|
+
// Its `enter` and its `show`, looked for across the runes only where one of them gives it.
|
|
718
|
+
let enter;
|
|
719
|
+
if ((seen & SEEN.enter) !== 0)
|
|
720
|
+
enter = own("enter");
|
|
721
|
+
const unentered = enter === false;
|
|
722
|
+
let show;
|
|
723
|
+
if ((seen & SEEN.show) !== 0)
|
|
724
|
+
show = own("show");
|
|
725
|
+
// One record, its `wired` said once its wiring is known: what reads it later reads this one.
|
|
726
|
+
const self = { config: source, follow: undefined, show, value, own, has, unentered, variantChild: false, asRead };
|
|
727
|
+
const wiring = shown(self);
|
|
728
|
+
// No wiring of its own, and an entrance: what's fixed over it is what the runes beside the source
|
|
729
|
+
// give, as it is. A ward of several runes with no `show`, most of them.
|
|
730
|
+
if (Predicate.isUndefined(wiring) && !unentered) {
|
|
731
|
+
self.wired = beside;
|
|
732
|
+
return self;
|
|
733
|
+
}
|
|
734
|
+
self.wired = { ...beside, ...wiredOf(wiring, unentered, value, has) };
|
|
735
|
+
return self;
|
|
736
|
+
};
|
|
737
|
+
/** What a `show`'s wiring gives a ward's `style`, where it gives one. */
|
|
738
|
+
const styleOfShown = (shown) => shown.style;
|
|
739
|
+
/** `key` across `runes`, a later one winning, objects merged where the key takes them: how a ward's config reads a key that several runes give. */
|
|
740
|
+
const acrossIn = (runes, key) => Arr.reduce(runes, undefined, (value, config) => {
|
|
741
|
+
if (!(key in config))
|
|
742
|
+
return value;
|
|
743
|
+
return overIn(key, value, read(config, key));
|
|
744
|
+
});
|
|
745
|
+
/** `next`, a later rune's `key`, over `value`, what the runes before it gave: variants and objects merged, else the later one's where it gives one. */
|
|
746
|
+
const overIn = (key, value, next) => {
|
|
747
|
+
if (key === "variants")
|
|
748
|
+
return mergeVariants(value, next);
|
|
749
|
+
if (OBJECT_KEYS.has(key))
|
|
750
|
+
return mergeObjects(value, next);
|
|
751
|
+
if (Predicate.isNotUndefined(next))
|
|
752
|
+
return next;
|
|
753
|
+
return value;
|
|
754
|
+
};
|
|
755
|
+
/**
|
|
756
|
+
* `configs` as one ward's config. Each key is a getter that reads the runes' as the ward reads it, so
|
|
757
|
+
* a rune's accessor or getter is tracked there, and nothing is read before the ward asks. `omitted`
|
|
758
|
+
* are keys its ward doesn't take, though the hooks still read them: a Stage ward's `exit`.
|
|
759
|
+
*/
|
|
760
|
+
export const joined = (configs, shown, omitted = NONE_OMITTED) => {
|
|
761
|
+
const loose = configs;
|
|
762
|
+
const keys = new Set(Arr.flatMap(loose, (config) => Object.keys(config)));
|
|
763
|
+
/** `key` across the runes, a later one winning, objects merged where the key takes them. */
|
|
764
|
+
const across = (key) => acrossIn(loose, key);
|
|
765
|
+
const follow = across("follow");
|
|
766
|
+
const show = across("show");
|
|
767
|
+
const following = Predicate.isNotUndefined(follow);
|
|
768
|
+
// A follower that names a gesture of its own keeps the name, and is a Variant child by its own word (Q26).
|
|
769
|
+
const variantChild = following && Arr.some(loose, namesGesture);
|
|
770
|
+
// A leader that names its states and has no `variants` needs none to be followed: every hook ward
|
|
771
|
+
// carries its variants (`HOOK_TOLD`, the follow grill's Q1).
|
|
772
|
+
const variants = () => variantsWithTiming(across("variants"));
|
|
773
|
+
/** A target key's value: a follower's own names resolved against its variants, but a gesture's, which it keeps (Q26). */
|
|
774
|
+
const target = (key) => {
|
|
775
|
+
const value = across(key);
|
|
776
|
+
if (following && isLabels(value) && !isGestureKey(key))
|
|
777
|
+
return targetOf(value, variants(), across("custom"));
|
|
778
|
+
return value;
|
|
779
|
+
};
|
|
780
|
+
const value = (key) => {
|
|
781
|
+
if (key === "variants")
|
|
782
|
+
return variants();
|
|
783
|
+
if (key === "transition")
|
|
784
|
+
return withTiming(across("transition"), across("followers"));
|
|
785
|
+
if (TARGET_KEYS.has(key))
|
|
786
|
+
return target(key);
|
|
787
|
+
return across(key);
|
|
788
|
+
};
|
|
789
|
+
const config = {};
|
|
790
|
+
// No entrance: its Starting style is its `animate`, though its `initial` is still read above.
|
|
791
|
+
const unentered = across("enter") === false;
|
|
792
|
+
const self = { config: config, follow, show, value, own: across, has: (key) => keys.has(key), unentered, variantChild, asRead: () => config };
|
|
793
|
+
const wiring = shown(self);
|
|
794
|
+
if (keys.has("followers"))
|
|
795
|
+
keys.add("transition");
|
|
796
|
+
if (unentered)
|
|
797
|
+
keys.add("initial");
|
|
798
|
+
const styled = UndefinedOr.map(wiring, styleOfShown);
|
|
799
|
+
if (Predicate.isNotUndefined(wiring))
|
|
800
|
+
keys.add("animate");
|
|
801
|
+
if (Predicate.isNotUndefined(styled))
|
|
802
|
+
keys.add("style");
|
|
803
|
+
// The keys its wiring reads are read through it; every other, as the runes give it.
|
|
804
|
+
const wired = wiredOf(wiring, unentered, value, self.has);
|
|
805
|
+
Iter.forEach(keys, (key) => {
|
|
806
|
+
if (OWN_KEYS.has(key))
|
|
807
|
+
return;
|
|
808
|
+
if (omitted.has(key))
|
|
809
|
+
return;
|
|
810
|
+
let get = () => value(key);
|
|
811
|
+
if (Object.hasOwn(wired, key))
|
|
812
|
+
get = wired[key];
|
|
813
|
+
Object.defineProperty(config, key, { get, enumerable: true });
|
|
814
|
+
});
|
|
815
|
+
return self;
|
|
816
|
+
};
|
|
817
|
+
//# sourceMappingURL=rune.js.map
|