@wardic/dom 1.1.0 → 1.1.2
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/dist/DomProjectionSystem.js +3 -3
- package/dist/DomProjectionSystem.js.map +1 -1
- package/dist/FlushGate.d.ts +6 -6
- package/dist/FlushGate.d.ts.map +1 -1
- package/dist/FlushGate.js +7 -5
- package/dist/FlushGate.js.map +1 -1
- package/dist/ReorderController.js +3 -3
- package/dist/ReorderController.js.map +1 -1
- package/dist/Report.d.ts +1 -1
- package/dist/Report.d.ts.map +1 -1
- package/dist/Report.js +3 -2
- package/dist/Report.js.map +1 -1
- package/dist/Style.d.ts +2 -1
- package/dist/Style.d.ts.map +1 -1
- package/dist/Style.js +3 -1
- package/dist/Style.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/batch-handoff.d.ts +25 -0
- package/dist/internal/batch-handoff.d.ts.map +1 -0
- package/dist/internal/batch-handoff.js +64 -0
- package/dist/internal/batch-handoff.js.map +1 -0
- package/dist/internal/gate-environment.d.ts +4 -0
- package/dist/internal/gate-environment.d.ts.map +1 -0
- package/dist/internal/gate-environment.js +21 -0
- package/dist/internal/gate-environment.js.map +1 -0
- package/dist/internal/projection.js +14 -14
- package/dist/internal/projection.js.map +1 -1
- package/dist/internal/reorder.d.ts +2 -2
- package/dist/internal/reorder.d.ts.map +1 -1
- package/dist/internal/reorder.js +2 -2
- package/dist/internal/reorder.js.map +1 -1
- package/dist/internal/starting-style.d.ts +0 -83
- package/dist/internal/starting-style.d.ts.map +1 -1
- package/dist/internal/starting-style.js +16 -143
- package/dist/internal/starting-style.js.map +1 -1
- package/dist/unstable/AppearAnimations.d.ts +191 -0
- package/dist/unstable/AppearAnimations.d.ts.map +1 -0
- package/dist/unstable/AppearAnimations.js +561 -0
- package/dist/unstable/AppearAnimations.js.map +1 -0
- package/dist/unstable/BatchMembers.d.ts +513 -0
- package/dist/unstable/BatchMembers.d.ts.map +1 -0
- package/dist/unstable/BatchMembers.js +2490 -0
- package/dist/unstable/BatchMembers.js.map +1 -0
- package/dist/unstable/DomValues.d.ts +25 -0
- package/dist/unstable/DomValues.d.ts.map +1 -0
- package/dist/unstable/DomValues.js +45 -0
- package/dist/unstable/DomValues.js.map +1 -0
- package/dist/unstable/DragConstraints.d.ts +48 -0
- package/dist/unstable/DragConstraints.d.ts.map +1 -0
- package/dist/unstable/DragConstraints.js +49 -0
- package/dist/unstable/DragConstraints.js.map +1 -0
- package/dist/unstable/DragControls.d.ts +50 -0
- package/dist/unstable/DragControls.d.ts.map +1 -0
- package/dist/unstable/DragControls.js +55 -0
- package/dist/unstable/DragControls.js.map +1 -0
- package/dist/unstable/DragDefaults.d.ts +34 -0
- package/dist/unstable/DragDefaults.d.ts.map +1 -0
- package/dist/unstable/DragDefaults.js +47 -0
- package/dist/unstable/DragDefaults.js.map +1 -0
- package/dist/unstable/DragTrack.d.ts +236 -0
- package/dist/unstable/DragTrack.d.ts.map +1 -0
- package/dist/unstable/DragTrack.js +646 -0
- package/dist/unstable/DragTrack.js.map +1 -0
- package/dist/unstable/DragTransition.d.ts +22 -0
- package/dist/unstable/DragTransition.d.ts.map +1 -0
- package/dist/unstable/DragTransition.js +31 -0
- package/dist/unstable/DragTransition.js.map +1 -0
- package/dist/unstable/ElementSetup.d.ts +144 -0
- package/dist/unstable/ElementSetup.d.ts.map +1 -0
- package/dist/unstable/ElementSetup.js +297 -0
- package/dist/unstable/ElementSetup.js.map +1 -0
- package/dist/unstable/Feature.d.ts +221 -0
- package/dist/unstable/Feature.d.ts.map +1 -0
- package/dist/unstable/Feature.js +281 -0
- package/dist/unstable/Feature.js.map +1 -0
- package/dist/unstable/GestureFeatures.d.ts +30 -0
- package/dist/unstable/GestureFeatures.d.ts.map +1 -0
- package/dist/unstable/GestureFeatures.js +32 -0
- package/dist/unstable/GestureFeatures.js.map +1 -0
- package/dist/unstable/GestureInfo.d.ts +61 -0
- package/dist/unstable/GestureInfo.d.ts.map +1 -0
- package/dist/unstable/GestureInfo.js +23 -0
- package/dist/unstable/GestureInfo.js.map +1 -0
- package/dist/unstable/Imperative.d.ts +214 -0
- package/dist/unstable/Imperative.d.ts.map +1 -0
- package/dist/unstable/Imperative.js +768 -0
- package/dist/unstable/Imperative.js.map +1 -0
- package/dist/unstable/Instant.d.ts +46 -0
- package/dist/unstable/Instant.d.ts.map +1 -0
- package/dist/unstable/Instant.js +49 -0
- package/dist/unstable/Instant.js.map +1 -0
- package/dist/unstable/LayoutGroup.d.ts +14 -0
- package/dist/unstable/LayoutGroup.d.ts.map +1 -0
- package/dist/unstable/LayoutGroup.js +31 -0
- package/dist/unstable/LayoutGroup.js.map +1 -0
- package/dist/unstable/LayoutMember.d.ts +127 -0
- package/dist/unstable/LayoutMember.d.ts.map +1 -0
- package/dist/unstable/LayoutMember.js +176 -0
- package/dist/unstable/LayoutMember.js.map +1 -0
- package/dist/unstable/LiveStyle.d.ts +171 -0
- package/dist/unstable/LiveStyle.d.ts.map +1 -0
- package/dist/unstable/LiveStyle.js +329 -0
- package/dist/unstable/LiveStyle.js.map +1 -0
- package/dist/unstable/MemberHold.d.ts +3 -0
- package/dist/unstable/MemberHold.d.ts.map +1 -0
- package/dist/unstable/MemberHold.js +223 -0
- package/dist/unstable/MemberHold.js.map +1 -0
- package/dist/unstable/OwnerScope.d.ts +16 -0
- package/dist/unstable/OwnerScope.d.ts.map +1 -0
- package/dist/unstable/OwnerScope.js +35 -0
- package/dist/unstable/OwnerScope.js.map +1 -0
- package/dist/unstable/PresenceController.d.ts +128 -0
- package/dist/unstable/PresenceController.d.ts.map +1 -0
- package/dist/unstable/PresenceController.js +1427 -0
- package/dist/unstable/PresenceController.js.map +1 -0
- package/dist/unstable/Press.d.ts +26 -0
- package/dist/unstable/Press.d.ts.map +1 -0
- package/dist/unstable/Press.js +19 -0
- package/dist/unstable/Press.js.map +1 -0
- package/dist/unstable/ServerInterpolators.d.ts +17 -0
- package/dist/unstable/ServerInterpolators.d.ts.map +1 -0
- package/dist/unstable/ServerInterpolators.js +20 -0
- package/dist/unstable/ServerInterpolators.js.map +1 -0
- package/dist/unstable/WardConfig.d.ts +567 -0
- package/dist/unstable/WardConfig.d.ts.map +1 -0
- package/dist/unstable/WardConfig.js +2 -0
- package/dist/unstable/WardConfig.js.map +1 -0
- package/dist/unstable/features/All.d.ts +24 -0
- package/dist/unstable/features/All.d.ts.map +1 -0
- package/dist/unstable/features/All.js +20 -0
- package/dist/unstable/features/All.js.map +1 -0
- package/dist/unstable/features/Colors.d.ts +12 -0
- package/dist/unstable/features/Colors.d.ts.map +1 -0
- package/dist/unstable/features/Colors.js +38 -0
- package/dist/unstable/features/Colors.js.map +1 -0
- package/dist/unstable/features/DomAnimation.d.ts +16 -0
- package/dist/unstable/features/DomAnimation.d.ts.map +1 -0
- package/dist/unstable/features/DomAnimation.js +19 -0
- package/dist/unstable/features/DomAnimation.js.map +1 -0
- package/dist/unstable/features/DomMax.d.ts +12 -0
- package/dist/unstable/features/DomMax.d.ts.map +1 -0
- package/dist/unstable/features/DomMax.js +14 -0
- package/dist/unstable/features/DomMax.js.map +1 -0
- package/dist/unstable/features/Drag.d.ts +5 -0
- package/dist/unstable/features/Drag.d.ts.map +1 -0
- package/dist/unstable/features/Drag.js +32 -0
- package/dist/unstable/features/Drag.js.map +1 -0
- package/dist/unstable/features/Focus.d.ts +5 -0
- package/dist/unstable/features/Focus.d.ts.map +1 -0
- package/dist/unstable/features/Focus.js +20 -0
- package/dist/unstable/features/Focus.js.map +1 -0
- package/dist/unstable/features/Hover.d.ts +5 -0
- package/dist/unstable/features/Hover.d.ts.map +1 -0
- package/dist/unstable/features/Hover.js +20 -0
- package/dist/unstable/features/Hover.js.map +1 -0
- package/dist/unstable/features/InView.d.ts +5 -0
- package/dist/unstable/features/InView.d.ts.map +1 -0
- package/dist/unstable/features/InView.js +20 -0
- package/dist/unstable/features/InView.js.map +1 -0
- package/dist/unstable/features/Input.d.ts +28 -0
- package/dist/unstable/features/Input.d.ts.map +1 -0
- package/dist/unstable/features/Input.js +31 -0
- package/dist/unstable/features/Input.js.map +1 -0
- package/dist/unstable/features/Keys.d.ts +95 -0
- package/dist/unstable/features/Keys.d.ts.map +1 -0
- package/dist/unstable/features/Keys.js +44 -0
- package/dist/unstable/features/Keys.js.map +1 -0
- package/dist/unstable/features/Layout.d.ts +43 -0
- package/dist/unstable/features/Layout.d.ts.map +1 -0
- package/dist/unstable/features/Layout.js +44 -0
- package/dist/unstable/features/Layout.js.map +1 -0
- package/dist/unstable/features/Pan.d.ts +5 -0
- package/dist/unstable/features/Pan.d.ts.map +1 -0
- package/dist/unstable/features/Pan.js +20 -0
- package/dist/unstable/features/Pan.js.map +1 -0
- package/dist/unstable/features/Press.d.ts +13 -0
- package/dist/unstable/features/Press.d.ts.map +1 -0
- package/dist/unstable/features/Press.js +10 -0
- package/dist/unstable/features/Press.js.map +1 -0
- package/dist/unstable/features/Scroll.d.ts +20 -0
- package/dist/unstable/features/Scroll.d.ts.map +1 -0
- package/dist/unstable/features/Scroll.js +34 -0
- package/dist/unstable/features/Scroll.js.map +1 -0
- package/dist/unstable/features/TimelineKeys.d.ts +7 -0
- package/dist/unstable/features/TimelineKeys.d.ts.map +1 -0
- package/dist/unstable/features/TimelineKeys.js +103 -0
- package/dist/unstable/features/TimelineKeys.js.map +1 -0
- package/package.json +4 -3
- package/src/DomProjectionSystem.ts +3 -3
- package/src/FlushGate.ts +11 -9
- package/src/ReorderController.ts +3 -3
- package/src/Report.ts +3 -7
- package/src/Style.ts +4 -1
- package/src/index.ts +1 -1
- package/src/internal/batch-handoff.ts +75 -0
- package/src/internal/gate-environment.ts +21 -0
- package/src/internal/projection.ts +14 -14
- package/src/internal/reorder.ts +4 -4
- package/src/internal/starting-style.ts +5 -204
- package/src/unstable/AppearAnimations.ts +837 -0
- package/src/unstable/BatchMembers.ts +3085 -0
- package/src/unstable/DomValues.ts +53 -0
- package/src/unstable/DragConstraints.ts +107 -0
- package/src/unstable/DragControls.ts +98 -0
- package/src/unstable/DragDefaults.ts +57 -0
- package/src/unstable/DragTrack.ts +959 -0
- package/src/unstable/DragTransition.ts +46 -0
- package/src/unstable/ElementSetup.ts +411 -0
- package/src/unstable/Feature.ts +494 -0
- package/src/unstable/GestureFeatures.ts +38 -0
- package/src/unstable/GestureInfo.ts +85 -0
- package/src/unstable/Imperative.ts +1037 -0
- package/src/unstable/Instant.ts +93 -0
- package/src/unstable/LayoutGroup.ts +36 -0
- package/src/unstable/LayoutMember.ts +319 -0
- package/src/unstable/LiveStyle.ts +497 -0
- package/src/unstable/MemberHold.ts +211 -0
- package/src/unstable/OwnerScope.ts +35 -0
- package/src/unstable/PresenceController.ts +1747 -0
- package/src/unstable/Press.ts +43 -0
- package/src/unstable/ServerInterpolators.ts +39 -0
- package/src/unstable/WardConfig.ts +704 -0
- package/src/unstable/features/All.ts +39 -0
- package/src/unstable/features/Colors.ts +40 -0
- package/src/unstable/features/DomAnimation.ts +19 -0
- package/src/unstable/features/DomMax.ts +14 -0
- package/src/unstable/features/Drag.ts +34 -0
- package/src/unstable/features/Focus.ts +21 -0
- package/src/unstable/features/Hover.ts +21 -0
- package/src/unstable/features/InView.ts +21 -0
- package/src/unstable/features/Input.ts +37 -0
- package/src/unstable/features/Keys.ts +124 -0
- package/src/unstable/features/Layout.ts +75 -0
- package/src/unstable/features/Pan.ts +21 -0
- package/src/unstable/features/Press.ts +21 -0
- package/src/unstable/features/Scroll.ts +35 -0
- package/src/unstable/features/TimelineKeys.ts +115 -0
- package/dist/internal/gate.d.ts +0 -199
- package/dist/internal/gate.d.ts.map +0 -1
- package/dist/internal/gate.js +0 -570
- package/dist/internal/gate.js.map +0 -1
- package/dist/internal/report.d.ts +0 -30
- package/dist/internal/report.d.ts.map +0 -1
- package/dist/internal/report.js +0 -60
- package/dist/internal/report.js.map +0 -1
- package/dist/internal/runner.d.ts +0 -22
- package/dist/internal/runner.d.ts.map +0 -1
- package/dist/internal/runner.js +0 -62
- package/dist/internal/runner.js.map +0 -1
- package/src/internal/gate.ts +0 -706
- package/src/internal/report.ts +0 -69
- package/src/internal/runner.ts +0 -78
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type * as FlushGate from "../FlushGate.ts";
|
|
2
|
+
import * as Cause from "effect/Cause";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import type * as WardConfig from "./WardConfig.ts";
|
|
6
|
+
import type * as Reactivity from "@wardic/core/unstable/Reactivity";
|
|
7
|
+
import type * as WardicServices from "@wardic/core/unstable/WardicServices";
|
|
8
|
+
/**
|
|
9
|
+
* A **Feature**: its name, the key of the service its Layer gives (what an element looks up),
|
|
10
|
+
* and that Layer, built on the provider's runtime: its Environment, its flush gate and its projection
|
|
11
|
+
* options. `server` is what a server render, which builds no runtime, does with it: the
|
|
12
|
+
* `colors` Feature registers its colour spaces there too, as the render reads colours; the rest do
|
|
13
|
+
* nothing. `N` is its name as a type, by which each binding finds the props it adds.
|
|
14
|
+
*/
|
|
15
|
+
export interface Feature<I = any, S = any, N extends string = string> {
|
|
16
|
+
readonly name: N;
|
|
17
|
+
readonly key: Context.Key<I, S>;
|
|
18
|
+
readonly layer: Layer.Layer<I, never, ProviderServices>;
|
|
19
|
+
readonly server?: (() => void) | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** Features as an app gives them: one, or a list, a preset's nested in it (`[domAnimation, layout]`). */
|
|
22
|
+
export type Features = Feature | ReadonlyArray<Features>;
|
|
23
|
+
/**
|
|
24
|
+
* The names of the Features in `F` (#516): a Feature's own, every one's in a list, nested lists
|
|
25
|
+
* flattened, and what a load resolves to. What a Wardic instance's types find their props by. A
|
|
26
|
+
* Feature typed without its name (`Feature`, whose `N` is `string`) names none: as a member of a
|
|
27
|
+
* union, `string` would swallow every other name.
|
|
28
|
+
*/
|
|
29
|
+
export type FeatureNames<F> = F extends ReadonlyArray<infer E> ? FeatureNames<E> : F extends () => PromiseLike<infer L> ? FeatureNames<L> : F extends {
|
|
30
|
+
readonly name: infer N extends string;
|
|
31
|
+
} ? string extends N ? never : N : never;
|
|
32
|
+
/**
|
|
33
|
+
* What a prop of a Feature a Wardic instance doesn't have takes: nothing, so giving it is an error
|
|
34
|
+
* naming the Feature, `Type 'boolean' is not assignable to type 'NeedsFeature<"drag">'`.
|
|
35
|
+
*/
|
|
36
|
+
export interface NeedsFeature<N extends string> {
|
|
37
|
+
readonly "needs the Feature": N;
|
|
38
|
+
}
|
|
39
|
+
/** A union's members, intersected. */
|
|
40
|
+
type UnionToIntersection<U> = (U extends unknown ? (u: U) => void : never) extends (i: infer I) => void ? I : never;
|
|
41
|
+
/** The props `Groups` gives the Features named `N`, a binding's map from a Feature's name to its props (#516). */
|
|
42
|
+
export type GroupsOf<Groups, N extends string> = UnionToIntersection<Groups[N & keyof Groups]>;
|
|
43
|
+
/** Every prop of the Features `Groups` has and `N` doesn't name, each {@link NeedsFeature} its own. */
|
|
44
|
+
export type AbsentGroupsOf<Groups, N extends string> = UnionToIntersection<Exclude<keyof Groups, N> extends infer A ? (A extends keyof Groups & string ? {
|
|
45
|
+
readonly [P in keyof Groups[A]]?: NeedsFeature<A>;
|
|
46
|
+
} : never) : never>;
|
|
47
|
+
/**
|
|
48
|
+
* The Features that add props to an element (#516): the gestures and `layout`. `colors` and `scroll`
|
|
49
|
+
* add none. Each binding's props for them are a map over these names.
|
|
50
|
+
*/
|
|
51
|
+
export type PropFeature = "hover" | "press" | "focus" | "inView" | "pan" | "drag" | "layout";
|
|
52
|
+
/**
|
|
53
|
+
* The names of those of Features `F` that add props (#516), on any binding. A Wardic instance's
|
|
54
|
+
* types take these, not `F`: every list with each of them is one type, and an error prints names, not
|
|
55
|
+
* each Feature's service.
|
|
56
|
+
*/
|
|
57
|
+
export type PropFeatureNames<F> = Extract<FeatureNames<F>, PropFeature>;
|
|
58
|
+
/** Whether `N` names every Feature in `Groups`: a Wardic instance whose props are the binding's plain ones. */
|
|
59
|
+
export type NamesEvery<Groups, N extends string> = [Exclude<keyof Groups, N>] extends [never] ? true : false;
|
|
60
|
+
/** A Wardic instance's layout hooks, `Hooks`, when its Features named `N` include `layout`; else nothing (#516, Q6). */
|
|
61
|
+
export type LayoutHooksFor<N extends string, Hooks> = "layout" extends N ? Hooks : unknown;
|
|
62
|
+
/** Features loaded lazily: `() => import("./features.ts").then((m) => m.domMax)`. */
|
|
63
|
+
export type FeatureLoad = () => Promise<Features>;
|
|
64
|
+
/** Features given to a `WardicProvider` or a `LazyWardic`: at once, or loaded lazily. */
|
|
65
|
+
export type FeaturesProp = Features | FeatureLoad;
|
|
66
|
+
/**
|
|
67
|
+
* `key`'s Layer for a Feature: the Environment's service when it gives one (`@wardic/test`'s `TestLive`),
|
|
68
|
+
* else `layer`, the DOM's, which a provider's `MemoMap` builds once for every Feature standing on it.
|
|
69
|
+
*/
|
|
70
|
+
export declare const fromEnvironmentOr: <I, S, R>(key: Context.Key<I, S>, layer: Layer.Layer<I, never, R>) => Layer.Layer<I, never, R>;
|
|
71
|
+
/** Features as one flat list, each once, in order. */
|
|
72
|
+
export declare const flatten: (features: Features) => ReadonlyArray<Feature>;
|
|
73
|
+
/** Whether a `features` prop loads lazily: a function, where Features are values. */
|
|
74
|
+
export declare const isLoad: (prop: FeaturesProp) => prop is FeatureLoad;
|
|
75
|
+
/**
|
|
76
|
+
* What a Wardic instance is made with (#516, Q8): Features, loads of them, or lists of either, nested
|
|
77
|
+
* (`[domAnimation, () => import("./drag-feature.ts").then((m) => m.drag)]`).
|
|
78
|
+
*/
|
|
79
|
+
export type InstanceFeaturesProp = Feature | FeatureLoad | ReadonlyArray<InstanceFeaturesProp>;
|
|
80
|
+
/**
|
|
81
|
+
* A Wardic instance's Features (#516): what its elements and hooks join their section's with, one per
|
|
82
|
+
* provider. Its code is its binding's, which only the binding's `createWardic` imports, so an app with no
|
|
83
|
+
* Wardic instance ships none of it: the spine only calls `own`.
|
|
84
|
+
*/
|
|
85
|
+
export interface InstanceFeatures {
|
|
86
|
+
/**
|
|
87
|
+
* Its Features in `registry`'s provider, one per provider: those given at once, built on first need,
|
|
88
|
+
* and each load, started on the client the first time it's asked for and built as it arrives, until
|
|
89
|
+
* the provider ends. A server render builds what's given and loads nothing.
|
|
90
|
+
*/
|
|
91
|
+
readonly own: (registry: FeatureRegistry, host: InstanceHost) => Own;
|
|
92
|
+
}
|
|
93
|
+
/** What an element's Features come from (#511, #516): those it brings, a Complete element's every one, or a Wardic instance's. */
|
|
94
|
+
export interface ElementFeatures {
|
|
95
|
+
readonly brings?: ReadonlyArray<Feature> | undefined;
|
|
96
|
+
readonly complete?: boolean | undefined;
|
|
97
|
+
readonly instance?: InstanceFeatures | undefined;
|
|
98
|
+
}
|
|
99
|
+
/** No Features. */
|
|
100
|
+
export declare const NONE: Context.Context<never>;
|
|
101
|
+
/**
|
|
102
|
+
* A section of the tree's Features (#511): a `WardicProvider`'s, a `LazyWardic`'s, or an element's,
|
|
103
|
+
* each its own joined with its parent's. Each binding makes its sections with its own signals.
|
|
104
|
+
*/
|
|
105
|
+
export interface FeatureSection {
|
|
106
|
+
/** The services of the Features it has now. Tracked: a lazy one arriving changes it. */
|
|
107
|
+
readonly services: () => Context.Context<never>;
|
|
108
|
+
/** Whether a lazy load of its own or a parent's is still on its way: no missing-Feature warning while one is. */
|
|
109
|
+
readonly pending: () => boolean;
|
|
110
|
+
/** Whether it, or a section above it, is `strict`: a Complete element under it is an error in development. */
|
|
111
|
+
readonly strict: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** Outside every provider, and above each provider's own: no Features, nothing on its way, not strict. */
|
|
114
|
+
export declare const ROOT: FeatureSection;
|
|
115
|
+
/** What a section takes from its binding: its reactivity, whether it renders on a server, and its owner's cleanup. */
|
|
116
|
+
export interface SectionHost {
|
|
117
|
+
readonly reactivity: Reactivity.Reactivity;
|
|
118
|
+
readonly server: boolean;
|
|
119
|
+
readonly onCleanup: (fn: () => void) => void;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A section under `parent` with `prop`'s Features (#511):
|
|
123
|
+
* - **Given at once**, they're built on first need, the first time an element in it asks (#51: a
|
|
124
|
+
* provider with no element under it builds nothing); a server render runs their `server` part at
|
|
125
|
+
* once, as its elements may read what it registers.
|
|
126
|
+
* - **Loaded lazily** (decision 8), the load starts now on the client and they're built as they
|
|
127
|
+
* arrive, from then on; `pending` until it settles. A failed load is `report`ed, once. A server
|
|
128
|
+
* render loads nothing: it renders as it would without them.
|
|
129
|
+
*
|
|
130
|
+
* Its services join its own and its parent's, joined again only when either changes.
|
|
131
|
+
*/
|
|
132
|
+
export declare const makeSection: (parent: FeatureSection, registry: FeatureRegistry, prop: FeaturesProp | undefined, strict: boolean, report: (cause: Cause.Cause<unknown>) => void, host: SectionHost) => FeatureSection;
|
|
133
|
+
/** `parent`'s Features and `own`'s, as a section: `parent`'s `strict`. */
|
|
134
|
+
export declare const joinSections: (parent: FeatureSection, own: Own) => FeatureSection;
|
|
135
|
+
/** `a`'s services and `b`'s, joined again only when either changes, and whether either's load is on its way. */
|
|
136
|
+
export declare const joinOwns: (a: Own, b: Own) => Own;
|
|
137
|
+
/** A section's own Features: their services and whether they're on their way. */
|
|
138
|
+
export interface Own {
|
|
139
|
+
readonly services: () => Context.Context<never>;
|
|
140
|
+
readonly pending: () => boolean;
|
|
141
|
+
}
|
|
142
|
+
export declare const ownOf: (build: Build, prop: FeaturesProp | undefined, report: (cause: Cause.Cause<unknown>) => void, host: SectionHost) => Own;
|
|
143
|
+
/** What builds Features: a registry's `build`. */
|
|
144
|
+
export type Build = (features: ReadonlyArray<Feature>) => Context.Context<never>;
|
|
145
|
+
/**
|
|
146
|
+
* A provider's Features: each built once, on first need, and every list it's asked for joined once.
|
|
147
|
+
* `build` is synchronous; a Feature's Layer that can't build at once is a defect.
|
|
148
|
+
*/
|
|
149
|
+
export interface FeatureRegistry {
|
|
150
|
+
/** The services of `features`, each Feature built the first time it's asked for. */
|
|
151
|
+
readonly build: (features: ReadonlyArray<Feature>) => Context.Context<never>;
|
|
152
|
+
/** A section of exactly `features`, nothing on its way: one per list, a Complete element's (#511). */
|
|
153
|
+
readonly section: (features: ReadonlyArray<Feature>) => FeatureSection;
|
|
154
|
+
/**
|
|
155
|
+
* The services of every Feature built so far, whichever section asked: what a part of the provider
|
|
156
|
+
* that brings no Feature works with when one is there (the projection system, for a presence).
|
|
157
|
+
*/
|
|
158
|
+
readonly built: () => Context.Context<never>;
|
|
159
|
+
/** Logs `message` at Warning the first time `feature` is named: development's word on a missing Feature. */
|
|
160
|
+
readonly warnOnce: (feature: string, message: string) => void;
|
|
161
|
+
/** Runs `end` as the provider ends, before its Features: what a Wardic instance's loads stop by (#516). */
|
|
162
|
+
readonly onEnd: (end: () => void) => void;
|
|
163
|
+
/** Ends every Feature built, the provider's runtime after (a Feature's Layer may stand on it). */
|
|
164
|
+
readonly dispose: () => Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* What a Wardic instance's Features take from the binding asking for them (#516): a section's host but
|
|
168
|
+
* its cleanup, which is its provider's (`FeatureRegistry.onEnd`), and what reports a failed load.
|
|
169
|
+
*/
|
|
170
|
+
export interface InstanceHost extends Omit<SectionHost, "onCleanup"> {
|
|
171
|
+
readonly report: (cause: Cause.Cause<unknown>) => void;
|
|
172
|
+
}
|
|
173
|
+
declare const ProjectionOptions_base: Context.ServiceClass<ProjectionOptions, "@wardic/dom/unstable/ProjectionOptions", import("../internal/projection.ts").ProjectionSystemOptions>;
|
|
174
|
+
/**
|
|
175
|
+
* What a client provider hands its projection system (#511): whether reduced motion applies now
|
|
176
|
+
* (ADR-0029), and the app's scale correctors (#443). The `layout` Feature's Layer reads it from the
|
|
177
|
+
* provider's runtime, as the projection system is no longer built with it.
|
|
178
|
+
*/
|
|
179
|
+
export declare class ProjectionOptions extends /*#__PURE__*/ ProjectionOptions_base {
|
|
180
|
+
}
|
|
181
|
+
/** What a provider's runtime holds: its Environment, and its flush gate and projection options over it. */
|
|
182
|
+
export type ProviderServices = WardicServices.WardicServices | FlushGate.FlushGate | ProjectionOptions;
|
|
183
|
+
/** What a provider's Features are built on (#672, Q10): its runtime as a Runner, with the MemoMap they share. */
|
|
184
|
+
export type FeatureRuntime = WardicServices.Runner<ProviderServices> & {
|
|
185
|
+
readonly memoMap: Layer.MemoMap;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* A client provider's Features (#511): built into `runtime`'s `MemoMap` in a Scope of their own, a child
|
|
189
|
+
* of the runtime's that closes before its Layers do, so a Feature ends before the Environment it stands
|
|
190
|
+
* on. A list asked for again (the Complete element's every Feature) is joined once.
|
|
191
|
+
*/
|
|
192
|
+
export declare const clientRegistry: (runtime: FeatureRuntime, dispose: () => Promise<void>) => FeatureRegistry;
|
|
193
|
+
/**
|
|
194
|
+
* A server render's Features (ADR-0021): none built, as no runtime is; each one's `server` run once,
|
|
195
|
+
* the first time it's asked for. Disposing disposes the unbuilt runtime (`dispose`), as on unmount.
|
|
196
|
+
*/
|
|
197
|
+
export declare const serverRegistry: (dispose: () => Promise<void>) => FeatureRegistry;
|
|
198
|
+
/**
|
|
199
|
+
* The first of `values` that only the `colors` Feature would read as a colour (#511, decision 7): a
|
|
200
|
+
* string naming a wide-gamut space, while no space beyond sRGB's is registered on the page.
|
|
201
|
+
* `undefined` when there's none. Asked of the page, not of an element's Features: culori's spaces are
|
|
202
|
+
* the page's, so one registered by any provider is read by every element (`features/Colors`).
|
|
203
|
+
*/
|
|
204
|
+
export declare const unreadColorIn: (values: Readonly<Record<string, unknown>>) => string | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Development's word on a Complete element under a `strict` section (#511, ADR-0067 decision 7,
|
|
207
|
+
* Motion's), naming the binding's `complete` forms and the `slim` ones to use.
|
|
208
|
+
*/
|
|
209
|
+
export declare const strictMessage: (complete: string, slim: string) => string;
|
|
210
|
+
/** What development's word on a missing `layout` Feature names (#511): the props that need it. */
|
|
211
|
+
export declare const LAYOUT_PROPS = "A layout prop (`layout`, `layoutId`, `layoutScroll` or `layoutRoot`)";
|
|
212
|
+
/** Whether a config makes its element a projection node: `layout` (or a mode), a `layoutId`, `layoutScroll` or `layoutRoot`. */
|
|
213
|
+
export declare const wantsLayoutNode: (c: WardConfig.WardConfig) => boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Development's word on a missing Feature (#511, ADR-0067 decision 7): what needed it, its import from
|
|
216
|
+
* the binding's `entry`, and where to add it. Not a Complete element, which a `strict` section makes
|
|
217
|
+
* an error (#581).
|
|
218
|
+
*/
|
|
219
|
+
export declare const missingMessage: (feature: string, what: string, entry: string) => string;
|
|
220
|
+
export {};
|
|
221
|
+
//# sourceMappingURL=Feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Feature.d.ts","sourceRoot":"","sources":["../../src/unstable/Feature.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAGjD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAGzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAKrC,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,KAAK,UAAU,MAAM,kCAAkC,CAAA;AACnE,OAAO,KAAK,KAAK,cAAc,MAAM,sCAAsC,CAAA;AAE3E;;;;;;GAMG;AAEH,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM;IAClE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IAChB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAA;IACvD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uB,CAAA;AAEtF,kGAAkG;AAClG,eAAO,MAAM,YAAY,yEAAyE,CAAA;AAElG,gIAAgI;AAChI,eAAO,MAAM,eAAe,MAAO,UAAU,CAAC,UAAU,KAAG,OACoF,CAAA;AAE/I;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAAa,MAAM,QAAQ,MAAM,SAAS,MAAM,KAAG,MAEuE,CAAA"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Features** (#511, ADR-0067): what an element pays for only when it needs it, shared by every DOM
|
|
3
|
+
* binding: each binding's `WardicProvider`, `LazyWardic` and elements read them through it.
|
|
4
|
+
*
|
|
5
|
+
* Each Feature is an Effect `Layer` (ADR-0067, *Features are Layers*): its services, built once per
|
|
6
|
+
* provider into the provider's runtime's `MemoMap` (`Layer.buildWithMemoMap`), so a Layer two Features
|
|
7
|
+
* share is built once, and ended with the provider. A Feature that arrives late, loaded lazily, is built
|
|
8
|
+
* the same way when it arrives: the runtime, made once, needn't change. A section of the tree (its
|
|
9
|
+
* `WardicProvider`, each `LazyWardic`) holds the services of the Features it has, a `Context`, joined
|
|
10
|
+
* with its parent's; an element looks a Feature up there.
|
|
11
|
+
*
|
|
12
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
// Unstable: ADR-0071, decision 5. #672: solid's `feature.ts`, moved to dom with the Features, on a Runner
|
|
17
|
+
// (Q10), naming the Features that add props (Q9).
|
|
18
|
+
import * as Color from "../Color.js";
|
|
19
|
+
import * as Arr from "effect/Array";
|
|
20
|
+
import * as Cause from "effect/Cause";
|
|
21
|
+
import * as Context from "effect/Context";
|
|
22
|
+
import * as Effect from "effect/Effect";
|
|
23
|
+
import { constFalse, constVoid, identity } from "effect/Function";
|
|
24
|
+
import * as Layer from "effect/Layer";
|
|
25
|
+
import * as Option from "effect/Option";
|
|
26
|
+
import * as Predicate from "effect/Predicate";
|
|
27
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
28
|
+
import * as OwnerScope from "./OwnerScope.js";
|
|
29
|
+
/**
|
|
30
|
+
* `key`'s Layer for a Feature: the Environment's service when it gives one (`@wardic/test`'s `TestLive`),
|
|
31
|
+
* else `layer`, the DOM's, which a provider's `MemoMap` builds once for every Feature standing on it.
|
|
32
|
+
*/
|
|
33
|
+
// ADR-0067 decision 14 (the gestures' input) and *Amendment (#518)*, decision 5 (the scroll). A Feature
|
|
34
|
+
// module's call to it is marked pure, so an app that never imports the module drops `layer`.
|
|
35
|
+
export const fromEnvironmentOr = (key, layer) => Layer.unwrap(Effect.map(Effect.serviceOption(key), Option.match({
|
|
36
|
+
onSome: (given) => Layer.succeed(key)(given),
|
|
37
|
+
onNone: () => layer,
|
|
38
|
+
})));
|
|
39
|
+
/** Features as one flat list, each once, in order. */
|
|
40
|
+
export const flatten = (features) => Arr.dedupeWith(flattenInto(features), (a, b) => a === b);
|
|
41
|
+
const flattenInto = (features) => {
|
|
42
|
+
if (isFeature(features))
|
|
43
|
+
return [features];
|
|
44
|
+
return Arr.flatMap(features, flattenInto);
|
|
45
|
+
};
|
|
46
|
+
const isFeature = (value) => Predicate.hasProperty(value, "layer");
|
|
47
|
+
/** Whether a `features` prop loads lazily: a function, where Features are values. */
|
|
48
|
+
export const isLoad = (prop) => Predicate.isFunction(prop);
|
|
49
|
+
/** No Features. */
|
|
50
|
+
export const NONE = Context.empty();
|
|
51
|
+
/** Outside every provider, and above each provider's own: no Features, nothing on its way, not strict. */
|
|
52
|
+
export const ROOT = { services: () => NONE, pending: constFalse, strict: false };
|
|
53
|
+
/**
|
|
54
|
+
* A section under `parent` with `prop`'s Features (#511):
|
|
55
|
+
* - **Given at once**, they're built on first need, the first time an element in it asks (#51: a
|
|
56
|
+
* provider with no element under it builds nothing); a server render runs their `server` part at
|
|
57
|
+
* once, as its elements may read what it registers.
|
|
58
|
+
* - **Loaded lazily** (decision 8), the load starts now on the client and they're built as they
|
|
59
|
+
* arrive, from then on; `pending` until it settles. A failed load is `report`ed, once. A server
|
|
60
|
+
* render loads nothing: it renders as it would without them.
|
|
61
|
+
*
|
|
62
|
+
* Its services join its own and its parent's, joined again only when either changes.
|
|
63
|
+
*/
|
|
64
|
+
export const makeSection = (parent, registry, prop, strict, report, host) => {
|
|
65
|
+
const own = ownOf(registry.build, prop, report, host);
|
|
66
|
+
return { ...joinSections(parent, own), strict: strict || parent.strict };
|
|
67
|
+
};
|
|
68
|
+
/** `parent`'s Features and `own`'s, as a section: `parent`'s `strict`. */
|
|
69
|
+
export const joinSections = (parent, own) => ({ ...joinOwns(parent, own), strict: parent.strict });
|
|
70
|
+
/** `a`'s services and `b`'s, joined again only when either changes, and whether either's load is on its way. */
|
|
71
|
+
export const joinOwns = (a, b) => {
|
|
72
|
+
let last;
|
|
73
|
+
const services = () => {
|
|
74
|
+
const first = a.services();
|
|
75
|
+
const second = b.services();
|
|
76
|
+
if (Predicate.isNotUndefined(last) && last.a === first && last.b === second)
|
|
77
|
+
return last.joined;
|
|
78
|
+
const joined = Context.merge(first, second);
|
|
79
|
+
last = { a: first, b: second, joined };
|
|
80
|
+
return joined;
|
|
81
|
+
};
|
|
82
|
+
return { services, pending: () => b.pending() || a.pending() };
|
|
83
|
+
};
|
|
84
|
+
const NO_OWN = { services: () => NONE, pending: constFalse };
|
|
85
|
+
export const ownOf = (build, prop, report, host) => {
|
|
86
|
+
if (Predicate.isUndefined(prop))
|
|
87
|
+
return NO_OWN;
|
|
88
|
+
if (isLoad(prop))
|
|
89
|
+
return loaded(build, prop, report, host);
|
|
90
|
+
const features = flatten(prop);
|
|
91
|
+
if (host.server)
|
|
92
|
+
build(features);
|
|
93
|
+
let built;
|
|
94
|
+
return {
|
|
95
|
+
services: () => UndefinedOr.match(built, {
|
|
96
|
+
onDefined: identity,
|
|
97
|
+
onUndefined: () => {
|
|
98
|
+
built = build(features);
|
|
99
|
+
return built;
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
pending: constFalse,
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
/** Features loaded lazily: none until they arrive, which a trigger tells; on the client only. */
|
|
106
|
+
const loaded = (build, load, report, host) => {
|
|
107
|
+
if (host.server)
|
|
108
|
+
return NO_OWN;
|
|
109
|
+
const changed = host.reactivity.trigger();
|
|
110
|
+
let services = NONE;
|
|
111
|
+
let pending = true;
|
|
112
|
+
let live = true;
|
|
113
|
+
host.onCleanup(() => {
|
|
114
|
+
live = false;
|
|
115
|
+
});
|
|
116
|
+
load().then((features) => {
|
|
117
|
+
if (!live)
|
|
118
|
+
return;
|
|
119
|
+
services = build(flatten(features));
|
|
120
|
+
pending = false;
|
|
121
|
+
changed.notify();
|
|
122
|
+
}, (error) => {
|
|
123
|
+
if (!live)
|
|
124
|
+
return;
|
|
125
|
+
pending = false;
|
|
126
|
+
changed.notify();
|
|
127
|
+
report(Cause.die(error));
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
services: () => {
|
|
131
|
+
changed.track();
|
|
132
|
+
return services;
|
|
133
|
+
},
|
|
134
|
+
pending: () => {
|
|
135
|
+
changed.track();
|
|
136
|
+
return pending;
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* A registry's sections of exactly a list, one per list; what runs as it ends (`onEnd`, run by `end`);
|
|
142
|
+
* and its warnings, one per Feature.
|
|
143
|
+
*/
|
|
144
|
+
const sectionsAndWarnings = (build, warn) => {
|
|
145
|
+
const sections = new WeakMap();
|
|
146
|
+
const ends = [];
|
|
147
|
+
const warned = new Set();
|
|
148
|
+
return {
|
|
149
|
+
onEnd: (end) => {
|
|
150
|
+
ends.push(end);
|
|
151
|
+
},
|
|
152
|
+
end: () => Arr.forEach(ends.splice(0), (end) => end()),
|
|
153
|
+
section: (features) => UndefinedOr.match(sections.get(features), {
|
|
154
|
+
onDefined: identity,
|
|
155
|
+
onUndefined: () => {
|
|
156
|
+
const services = build(features);
|
|
157
|
+
const section = { services: () => services, pending: constFalse, strict: false };
|
|
158
|
+
sections.set(features, section);
|
|
159
|
+
return section;
|
|
160
|
+
},
|
|
161
|
+
}),
|
|
162
|
+
warnOnce: (feature, message) => {
|
|
163
|
+
if (warned.has(feature))
|
|
164
|
+
return;
|
|
165
|
+
warned.add(feature);
|
|
166
|
+
warn(message);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* What a client provider hands its projection system (#511): whether reduced motion applies now
|
|
172
|
+
* (ADR-0029), and the app's scale correctors (#443). The `layout` Feature's Layer reads it from the
|
|
173
|
+
* provider's runtime, as the projection system is no longer built with it.
|
|
174
|
+
*/
|
|
175
|
+
export class ProjectionOptions extends /*#__PURE__*/ /*#__PURE__*/ Context.Service()("@wardic/dom/unstable/ProjectionOptions") {
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* A client provider's Features (#511): built into `runtime`'s `MemoMap` in a Scope of their own, a child
|
|
179
|
+
* of the runtime's that closes before its Layers do, so a Feature ends before the Environment it stands
|
|
180
|
+
* on. A list asked for again (the Complete element's every Feature) is joined once.
|
|
181
|
+
*/
|
|
182
|
+
// #618 (decision 4): the Scope was detached, closed by `dispose` before the runtime's, and a failing
|
|
183
|
+
// Feature finalizer skipped the runtime's disposal. A child forked after `ManagedRuntime.make`'s own
|
|
184
|
+
// closes first in its Scope's reverse order. #672 (Q10): it runs on a Runner with its MemoMap, and its
|
|
185
|
+
// binding disposes the runtime (`dispose`), so a Feature reads no binding's runtime type.
|
|
186
|
+
export const clientRegistry = (runtime, dispose) => {
|
|
187
|
+
const scope = OwnerScope.open(runtime);
|
|
188
|
+
const built = new Map();
|
|
189
|
+
const lists = new WeakMap();
|
|
190
|
+
let all = NONE;
|
|
191
|
+
const one = (feature) => UndefinedOr.match(built.get(feature), {
|
|
192
|
+
onDefined: (services) => services,
|
|
193
|
+
onUndefined: () => {
|
|
194
|
+
const services = runtime.runSync(Layer.buildWithMemoMap(feature.layer, runtime.memoMap, scope));
|
|
195
|
+
built.set(feature, services);
|
|
196
|
+
all = Context.merge(all, services);
|
|
197
|
+
return services;
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
const build = (features) => UndefinedOr.match(lists.get(features), {
|
|
201
|
+
onDefined: (services) => services,
|
|
202
|
+
onUndefined: () => {
|
|
203
|
+
const services = Arr.reduce(features, NONE, (joined, feature) => Context.merge(joined, one(feature)));
|
|
204
|
+
lists.set(features, services);
|
|
205
|
+
return services;
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
const { end, ...rest } = sectionsAndWarnings(build, (message) => {
|
|
209
|
+
runtime.runFork(Effect.logWarning(message));
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
build,
|
|
213
|
+
built: () => all,
|
|
214
|
+
...rest,
|
|
215
|
+
dispose: () => {
|
|
216
|
+
end();
|
|
217
|
+
return dispose();
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* A server render's Features (ADR-0021): none built, as no runtime is; each one's `server` run once,
|
|
223
|
+
* the first time it's asked for. Disposing disposes the unbuilt runtime (`dispose`), as on unmount.
|
|
224
|
+
*/
|
|
225
|
+
export const serverRegistry = (dispose) => {
|
|
226
|
+
const ran = new Set();
|
|
227
|
+
const build = (features) => {
|
|
228
|
+
Arr.forEach(features, (feature) => {
|
|
229
|
+
if (ran.has(feature))
|
|
230
|
+
return;
|
|
231
|
+
ran.add(feature);
|
|
232
|
+
UndefinedOr.map(feature.server, (server) => server());
|
|
233
|
+
});
|
|
234
|
+
return NONE;
|
|
235
|
+
};
|
|
236
|
+
// A server render says nothing: the client, rendering the same, does.
|
|
237
|
+
const { end, ...rest } = sectionsAndWarnings(build, constVoid);
|
|
238
|
+
return {
|
|
239
|
+
build,
|
|
240
|
+
built: () => NONE,
|
|
241
|
+
...rest,
|
|
242
|
+
dispose: () => {
|
|
243
|
+
end();
|
|
244
|
+
return dispose();
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* A CSS function naming a colour space only the `colors` Feature reads: `oklch()`, `oklab()`, `lab()`,
|
|
250
|
+
* `lch()`, `hwb()`, and `color()` in any space but `srgb`, which the base reads.
|
|
251
|
+
*/
|
|
252
|
+
const WIDE_GAMUT = /^\s*(?:(?:oklch|oklab|lab|lch|hwb)\(|color\(\s*(?!srgb\s))/i;
|
|
253
|
+
/**
|
|
254
|
+
* The first of `values` that only the `colors` Feature would read as a colour (#511, decision 7): a
|
|
255
|
+
* string naming a wide-gamut space, while no space beyond sRGB's is registered on the page.
|
|
256
|
+
* `undefined` when there's none. Asked of the page, not of an element's Features: culori's spaces are
|
|
257
|
+
* the page's, so one registered by any provider is read by every element (`features/Colors`).
|
|
258
|
+
*/
|
|
259
|
+
export const unreadColorIn = (values) => {
|
|
260
|
+
if (Color.spacesRegistered())
|
|
261
|
+
return undefined;
|
|
262
|
+
return Arr.findFirst(Object.values(values), (value) => Predicate.isString(value) && WIDE_GAMUT.test(value)).pipe(Option.getOrUndefined);
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Development's word on a Complete element under a `strict` section (#511, ADR-0067 decision 7,
|
|
266
|
+
* Motion's), naming the binding's `complete` forms and the `slim` ones to use.
|
|
267
|
+
*/
|
|
268
|
+
export const strictMessage = (complete, slim) => `wardic: a Complete element (${complete}) is rendered under a strict WardicProvider or LazyWardic. ` +
|
|
269
|
+
`It brings every Feature's code with it; render the Slim element (${slim}) instead.`;
|
|
270
|
+
/** What development's word on a missing `layout` Feature names (#511): the props that need it. */
|
|
271
|
+
export const LAYOUT_PROPS = "A layout prop (`layout`, `layoutId`, `layoutScroll` or `layoutRoot`)";
|
|
272
|
+
/** Whether a config makes its element a projection node: `layout` (or a mode), a `layoutId`, `layoutScroll` or `layoutRoot`. */
|
|
273
|
+
export const wantsLayoutNode = (c) => c.layout === true || Predicate.isString(c.layout) || Predicate.isNotUndefined(c.layoutId) || c.layoutScroll === true || c.layoutRoot === true;
|
|
274
|
+
/**
|
|
275
|
+
* Development's word on a missing Feature (#511, ADR-0067 decision 7): what needed it, its import from
|
|
276
|
+
* the binding's `entry`, and where to add it. Not a Complete element, which a `strict` section makes
|
|
277
|
+
* an error (#581).
|
|
278
|
+
*/
|
|
279
|
+
export const missingMessage = (feature, what, entry) => `wardic: ${what} needs the \`${feature}\` Feature, which no WardicProvider or LazyWardic above this element has. ` +
|
|
280
|
+
`Add it: \`import { ${feature} } from "${entry}"\`, then \`<WardicProvider features={[${feature}]}>\` or \`<LazyWardic features={[${feature}]}>\`.`;
|
|
281
|
+
//# sourceMappingURL=Feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Feature.js","sourceRoot":"","sources":["../../src/unstable/Feature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,0GAA0G;AAC1G,kDAAkD;AAClD,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AAGpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAuF7C;;;GAGG;AACH,wGAAwG;AACxG,6FAA6F;AAC7F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAU,GAAsB,EAAE,KAA+B,EAA4B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the gestures' input a section with one has, and the words
|
|
4
|
+
* development's message on a missing one names. Every binding's; it reaches no Feature's code, only
|
|
5
|
+
* their keys.
|
|
6
|
+
*
|
|
7
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import * as InputSource from "@wardic/core/InputSource";
|
|
12
|
+
import * as Context from "effect/Context";
|
|
13
|
+
/** `key`'s service among `services`, or `undefined` when they hold none: its Feature isn't there. */
|
|
14
|
+
export declare const serviceIn: <I, S>(services: Context.Context<never>, key: Context.Key<I, S>) => S | undefined;
|
|
15
|
+
/** The gestures' input among `services`: a section with any gesture Feature but `inView` has it. */
|
|
16
|
+
export declare const inputIn: (services: Context.Context<never>) => InputSource.InputSource["Service"];
|
|
17
|
+
/** What development's word on a missing gesture Feature names, by Feature: what the element asked of it. */
|
|
18
|
+
export declare const GESTURE_WORDS: {
|
|
19
|
+
readonly hover: "Its hover (`whileHover`, or a hover event)";
|
|
20
|
+
readonly press: "Its press (`whileTap`, or a tap event)";
|
|
21
|
+
readonly focus: "Its focus (`whileFocus`)";
|
|
22
|
+
readonly inView: "Its view (`whileInView`, or a viewport event)";
|
|
23
|
+
readonly pan: "Its pan (a pan event)";
|
|
24
|
+
readonly drag: "Its drag (`drag`)";
|
|
25
|
+
};
|
|
26
|
+
/** Whether `services` hold `key`'s service: its Feature is there. */
|
|
27
|
+
export declare const hasService: <I, S>(services: Context.Context<never>, key: Context.Key<I, S>) => boolean;
|
|
28
|
+
/** `key`'s service among `services`, which hold it: a Feature a hook or component brought. */
|
|
29
|
+
export declare const serviceOf: <I, S>(services: Context.Context<never>, key: Context.Key<I, S>) => S;
|
|
30
|
+
//# sourceMappingURL=GestureFeatures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GestureFeatures.d.ts","sourceRoot":"","sources":["../../src/unstable/GestureFeatures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA;AACvD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAGzC,qGAAqG;AACrG,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,YAAY,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAAC,GAAG,SAChB,CAAA;AAE/E,oGAAoG;AACpG,eAAO,MAAM,OAAO,aAAc,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAG,WAAW,CAAC,WAAW,CAAC,SAAS,CACA,CAAA;AAE5F,4GAA4G;AAC5G,eAAO,MAAM,aAAa;aACxB,KAAK,EAAE,4CAA4C;aACnD,KAAK,EAAE,wCAAwC;aAC/C,KAAK,EAAE,0BAA0B;aACjC,MAAM,EAAE,+CAA+C;aACvD,GAAG,EAAE,uBAAuB;aAC5B,IAAI,EAAE,mBAAmB;CACjB,CAAA;AAEV,qEAAqE;AACrE,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,CAAC,YAAY,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,OAAgF,CAAA;AAE5K,8FAA8F;AAC9F,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,YAAY,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAAqD,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an element reads of its section's gesture Features (#511, ADR-0067 decision 3): each gesture's
|
|
3
|
+
* service, `undefined` without its Feature, the gestures' input a section with one has, and the words
|
|
4
|
+
* development's message on a missing one names. Every binding's; it reaches no Feature's code, only
|
|
5
|
+
* their keys.
|
|
6
|
+
*
|
|
7
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
// Unstable: ADR-0071, decision 5. #672: solid's `gesture-features.ts`, moved to dom with the Features.
|
|
12
|
+
import * as InputSource from "@wardic/core/InputSource";
|
|
13
|
+
import * as Context from "effect/Context";
|
|
14
|
+
import * as Option from "effect/Option";
|
|
15
|
+
/** `key`'s service among `services`, or `undefined` when they hold none: its Feature isn't there. */
|
|
16
|
+
export const serviceIn = (services, key) => Option.getOrUndefined(Context.getOption(services, key));
|
|
17
|
+
/** The gestures' input among `services`: a section with any gesture Feature but `inView` has it. */
|
|
18
|
+
export const inputIn = (services) => Context.get(services, InputSource.InputSource);
|
|
19
|
+
/** What development's word on a missing gesture Feature names, by Feature: what the element asked of it. */
|
|
20
|
+
export const GESTURE_WORDS = {
|
|
21
|
+
hover: "Its hover (`whileHover`, or a hover event)",
|
|
22
|
+
press: "Its press (`whileTap`, or a tap event)",
|
|
23
|
+
focus: "Its focus (`whileFocus`)",
|
|
24
|
+
inView: "Its view (`whileInView`, or a viewport event)",
|
|
25
|
+
pan: "Its pan (a pan event)",
|
|
26
|
+
drag: "Its drag (`drag`)",
|
|
27
|
+
};
|
|
28
|
+
/** Whether `services` hold `key`'s service: its Feature is there. */
|
|
29
|
+
export const hasService = (services, key) => Option.isSome(Context.getOption(services, key));
|
|
30
|
+
/** `key`'s service among `services`, which hold it: a Feature a hook or component brought. */
|
|
31
|
+
export const serviceOf = (services, key) => Context.get(services, key);
|
|
32
|
+
//# sourceMappingURL=GestureFeatures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GestureFeatures.js","sourceRoot":"","sources":["../../src/unstable/GestureFeatures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,uGAAuG;AACvG,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA;AACvD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,qGAAqG;AACrG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAO,QAAgC,EAAE,GAAsB,EAAiB,EAAE,CACzG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,QAA8B,EAAE,GAAG,CAAC,CAAC,CAAA;AAE/E,oGAAoG;AACpG,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,QAAgC,EAAsC,EAAE,CAC9F,OAAO,CAAC,GAAG,CAAC,QAAoD,EAAE,WAAW,CAAC,WAAW,CAAC,CAAA;AAE5F,4GAA4G;AAC5G,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,4CAA4C;IACnD,KAAK,EAAE,wCAAwC;IAC/C,KAAK,EAAE,0BAA0B;IACjC,MAAM,EAAE,+CAA+C;IACvD,GAAG,EAAE,uBAAuB;IAC5B,IAAI,EAAE,mBAAmB;CACjB,CAAA;AAEV,qEAAqE;AACrE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAO,QAAgC,EAAE,GAAsB,EAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,QAA8B,EAAE,GAAG,CAAC,CAAC,CAAA;AAE5K,8FAA8F;AAC9F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAO,QAAgC,EAAE,GAAsB,EAAK,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAA8B,EAAE,GAAG,CAAC,CAAA"}
|