@wardic/solid 3.0.0-next.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 +17 -0
- package/dist/browser/animation-frame.js +1 -1
- package/dist/browser/animation-frame.js.map +1 -1
- package/dist/browser/config-view.js +2 -1
- package/dist/browser/config-view.js.map +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.js +7 -6
- package/dist/browser/element.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/drag.js +4 -3
- package/dist/browser/hooks/drag.js.map +1 -1
- package/dist/browser/hooks/presence-scope.js +2 -1
- package/dist/browser/hooks/presence-scope.js.map +1 -1
- package/dist/browser/hooks/reorder-elements.js +5 -4
- package/dist/browser/hooks/reorder-elements.js.map +1 -1
- package/dist/browser/hooks/rune.js +4 -3
- package/dist/browser/hooks/rune.js.map +1 -1
- package/dist/browser/hooks/ward.js +31 -12
- package/dist/browser/hooks/ward.js.map +1 -1
- package/dist/browser/hooks/wards.js +3 -2
- package/dist/browser/hooks/wards.js.map +1 -1
- package/dist/browser/provider.js +40 -21
- package/dist/browser/provider.js.map +1 -1
- package/dist/browser/reorder.js +5 -4
- 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/v1/index.js +1 -1
- package/dist/browser/ward.js +25 -19
- package/dist/browser/ward.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 +2 -1
- package/dist/server/config-view.js.map +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.js +7 -6
- package/dist/server/element.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/drag.js +4 -3
- package/dist/server/hooks/drag.js.map +1 -1
- package/dist/server/hooks/presence-scope.js +2 -1
- package/dist/server/hooks/presence-scope.js.map +1 -1
- package/dist/server/hooks/reorder-elements.js +5 -4
- package/dist/server/hooks/reorder-elements.js.map +1 -1
- package/dist/server/hooks/rune.js +4 -3
- package/dist/server/hooks/rune.js.map +1 -1
- package/dist/server/hooks/ward.js +31 -12
- package/dist/server/hooks/ward.js.map +1 -1
- package/dist/server/hooks/wards.js +3 -2
- package/dist/server/hooks/wards.js.map +1 -1
- package/dist/server/provider.js +40 -21
- package/dist/server/provider.js.map +1 -1
- package/dist/server/reorder.js +5 -4
- 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/v1/index.js +1 -1
- package/dist/server/ward.js +25 -19
- package/dist/server/ward.js.map +1 -1
- package/dist/solid/animation-frame.js +1 -1
- package/dist/solid/animation-frame.js.map +1 -1
- package/dist/solid/config-view.d.ts.map +1 -1
- package/dist/solid/config-view.js +2 -1
- package/dist/solid/config-view.js.map +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.d.ts.map +1 -1
- package/dist/solid/element.jsx +8 -8
- package/dist/solid/element.jsx.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/drag.d.ts.map +1 -1
- package/dist/solid/hooks/drag.js +4 -3
- package/dist/solid/hooks/drag.js.map +1 -1
- package/dist/solid/hooks/presence-scope.d.ts.map +1 -1
- package/dist/solid/hooks/presence-scope.jsx +2 -1
- package/dist/solid/hooks/presence-scope.jsx.map +1 -1
- package/dist/solid/hooks/reorder-elements.d.ts.map +1 -1
- package/dist/solid/hooks/reorder-elements.jsx +5 -4
- package/dist/solid/hooks/reorder-elements.jsx.map +1 -1
- package/dist/solid/hooks/rune.d.ts.map +1 -1
- package/dist/solid/hooks/rune.js +4 -3
- package/dist/solid/hooks/rune.js.map +1 -1
- package/dist/solid/hooks/ward.d.ts.map +1 -1
- package/dist/solid/hooks/ward.js +35 -14
- package/dist/solid/hooks/ward.js.map +1 -1
- package/dist/solid/hooks/wards.d.ts.map +1 -1
- package/dist/solid/hooks/wards.js +3 -2
- package/dist/solid/hooks/wards.js.map +1 -1
- package/dist/solid/provider.d.ts.map +1 -1
- package/dist/solid/provider.jsx +41 -21
- package/dist/solid/provider.jsx.map +1 -1
- package/dist/solid/reorder.d.ts.map +1 -1
- package/dist/solid/reorder.jsx +5 -4
- 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/v1/index.d.ts +1 -1
- package/dist/solid/v1/index.jsx +1 -1
- package/dist/solid/ward.d.ts.map +1 -1
- package/dist/solid/ward.jsx +25 -19
- package/dist/solid/ward.jsx.map +1 -1
- package/package.json +8 -6
- 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/config-view.ts +5 -1
- package/src/diagnostic-codes.ts +254 -0
- package/src/diagnostics.ts +88 -0
- package/src/element.tsx +13 -10
- package/src/frame-effect.tsx +1 -1
- package/src/gesture-callbacks.ts +1 -1
- package/src/hooks/drag.ts +4 -3
- package/src/hooks/presence-scope.tsx +2 -1
- package/src/hooks/reorder-elements.tsx +6 -4
- package/src/hooks/rune.ts +4 -3
- package/src/hooks/ward.ts +36 -12
- package/src/hooks/wards.ts +4 -2
- package/src/provider.tsx +43 -20
- package/src/reorder.tsx +5 -4
- package/src/runtime.ts +43 -13
- package/src/spans-check.ts +12 -3
- package/src/v1/index.tsx +1 -1
- package/src/ward.tsx +27 -19
package/src/hooks/ward.ts
CHANGED
|
@@ -50,6 +50,7 @@ import { eachOf, Waiters, whenOf } from "../waiters.ts"
|
|
|
50
50
|
import { CLIENT_ONLY, onSettledClientOnly } from "../solid-reactivity.ts"
|
|
51
51
|
import type { WardElement } from "../lifecycle.ts"
|
|
52
52
|
import type * as PresenceRecord from "@wardic/core/unstable/PresenceRecord"
|
|
53
|
+
import { misuse, report } from "../diagnostics.ts"
|
|
53
54
|
import { fixLater, GESTURE_KEYS, holderFinished, holderWard, internalsOf, keepsState, sensedOf, sharedMember, shareMembers, shareOf, SLIM, targetAgain, type Ward, type WardConfig, type WardInternals, wardWith } from "../ward.tsx"
|
|
54
55
|
import { asking, type AutoFeature, colorsOnceLoaded, featureOfEvent, wantedBy } from "./auto.ts"
|
|
55
56
|
import { bothHandles, dragAccessorOf, dragAxisAt, dragAxisOf, givesDrag, isDragOnly, keysRuneOf, liftedOf, makeSite, raiseOf, runeWardOf, siteIfAny, siteInternalsOf, siteKeptFor, warnIfUndragged, withDrag, withGrips } from "./drag.ts"
|
|
@@ -744,24 +745,30 @@ export const HOOK_TOLD: Pick<WardInternals, "handed" | "madeUnder" | "styled" |
|
|
|
744
745
|
* an element by the time its owner has settled. Asked of the `ref` itself, not of the element it set: a
|
|
745
746
|
* hydrated page's writes, that one's among them, land after its owners settle (DW4). Today's
|
|
746
747
|
* `create(Component)` fails such a component; a hook ward spread on it would otherwise move nothing, and
|
|
747
|
-
* say nothing. One whose `style` no element has read yet, a closed dialog's, isn't warned of.
|
|
748
|
-
*
|
|
748
|
+
* say nothing. One whose `style` no element has read yet, a closed dialog's, isn't warned of. And the other
|
|
749
|
+
* way round (step 2 of the skill grill's order, Q20): its `ref` handed an element whose props read none of its
|
|
750
|
+
* `style`, a `style` beside the spread having replaced it. Nothing on a server, where no `ref` is called.
|
|
749
751
|
*/
|
|
750
|
-
const
|
|
752
|
+
const warnsOfItsSpread = (ward: Ward): void => {
|
|
751
753
|
if (Predicate.isNull(getOwner())) return
|
|
752
754
|
onSettledClientOnly(() => {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
755
|
+
const read = STYLE_READ.has(ward)
|
|
756
|
+
const handed = HANDED.has(ward)
|
|
757
|
+
if (Bool.and(read, Bool.not(handed))) report("WARDIC_REF_NOT_CALLED", UNFORWARDED)
|
|
758
|
+
// Its `ref` called and its `style` read by nothing: a `style` beside the spread replaced it (step 2, Q20).
|
|
759
|
+
if (Bool.and(handed, Bool.not(read))) report("WARDIC_STYLE_BESIDE_SPREAD", STYLE_BESIDE)
|
|
756
760
|
})
|
|
757
761
|
}
|
|
758
762
|
|
|
759
|
-
/** `ward`, made, with the
|
|
763
|
+
/** `ward`, made, with the warnings above for it in development, in a browser: every hook ward's make path ends here. */
|
|
760
764
|
const checked = (ward: Ward): Ward => {
|
|
761
|
-
if (DEV && !isServer)
|
|
765
|
+
if (DEV && !isServer) warnsOfItsSpread(ward)
|
|
762
766
|
return ward
|
|
763
767
|
}
|
|
764
768
|
|
|
769
|
+
const STYLE_BESIDE =
|
|
770
|
+
"createWard: the ward's `style` was replaced: a `style` beside its spread (`<div {...ward} style={…}>`), or a component that doesn't pass `props.style` on. Give the style through the ward, `{...ward.with({ style })}`, or as its own `style`."
|
|
771
|
+
|
|
765
772
|
const UNFORWARDED =
|
|
766
773
|
"createWard: a ward was spread on a component that never called its `ref`, so no element is its and nothing it says will move. The component must pass `props.ref` to the element it renders (`<div ref={props.ref}>`), or spread its props on that element whole."
|
|
767
774
|
|
|
@@ -969,7 +976,7 @@ const elementIn = (subject: unknown): WardElement | undefined => {
|
|
|
969
976
|
*/
|
|
970
977
|
const subjectElementOf = (subject: unknown): WardElement => {
|
|
971
978
|
const el = elementIn(subject)
|
|
972
|
-
if (Predicate.isUndefined(el)) throw
|
|
979
|
+
if (Predicate.isUndefined(el)) throw misuse("WARDIC_SUBJECT_NOT_ONE_ELEMENT", NOT_ONE_ELEMENT)
|
|
973
980
|
return el
|
|
974
981
|
}
|
|
975
982
|
|
|
@@ -1764,7 +1771,7 @@ export interface Takeable {
|
|
|
1764
1771
|
export const takenOf = (ward: object): Taken | undefined => {
|
|
1765
1772
|
const take = keptElse(ward, (kept) => kept.take, () => (ward as { readonly [TAKE]?: Takeable })[TAKE])
|
|
1766
1773
|
if (Predicate.isUndefined(take)) return undefined
|
|
1767
|
-
if (take.taken) throw
|
|
1774
|
+
if (take.taken) throw misuse("WARDIC_PRESENCE_WARD_TAKEN", TAKEN_TWICE)
|
|
1768
1775
|
take.taken = true
|
|
1769
1776
|
return takenBy(take)
|
|
1770
1777
|
}
|
|
@@ -2207,6 +2214,7 @@ const throughOf = (begun: Begun, runes: ReadonlyArray<Rune>, anyFunction: boolea
|
|
|
2207
2214
|
const landingFailed =
|
|
2208
2215
|
(owner: Owner | null) =>
|
|
2209
2216
|
(error: unknown): void => {
|
|
2217
|
+
// Uncoded: a leg that failed is Wardic's own failure; an app's function that made it fail is coded where it ran.
|
|
2210
2218
|
runWithOwner(owner, () => void useWardicRuntime().runFork(Report.failure("wardic.createWard: a landing failed", Cause.die(error))))
|
|
2211
2219
|
}
|
|
2212
2220
|
|
|
@@ -2275,7 +2283,7 @@ const warnIfFollowingNothing = (leader: object | undefined): void => {
|
|
|
2275
2283
|
if (!NAMING_NOTHING.has(leader)) return
|
|
2276
2284
|
if (WARNED_OF.has(leader)) return
|
|
2277
2285
|
WARNED_OF.add(leader)
|
|
2278
|
-
|
|
2286
|
+
report("WARDIC_FOLLOW_LEADER_UNNAMED", FOLLOWS_NOTHING)
|
|
2279
2287
|
}
|
|
2280
2288
|
|
|
2281
2289
|
/**
|
|
@@ -2303,7 +2311,23 @@ const groupedIn = (internal: WardInternals, group: WardInternals["layoutGroup"])
|
|
|
2303
2311
|
}
|
|
2304
2312
|
|
|
2305
2313
|
/** `createWard(...runes)`, each ward's Features from `begin`; `open` for one a presence may take. */
|
|
2306
|
-
const wardOf = (begin: () => Begun, open: boolean): WardMaker => warnsFollowingNothing(wardMakerOf(begin, open))
|
|
2314
|
+
const wardOf = (begin: () => Begun, open: boolean): WardMaker => ownerChecked(warnsFollowingNothing(wardMakerOf(begin, open)))
|
|
2315
|
+
|
|
2316
|
+
/**
|
|
2317
|
+
* `make`, refusing in development a ward made with no owner, outside a component or a root (step 2 of the
|
|
2318
|
+
* skill grill's order, Q20): it fails then anyway, on Solid's own error, which names neither the call nor
|
|
2319
|
+
* the fix. In a production build, `make` as it is.
|
|
2320
|
+
*/
|
|
2321
|
+
const ownerChecked = (make: WardMaker): WardMaker => {
|
|
2322
|
+
if (!DEV) return make
|
|
2323
|
+
return ((...runes: ReadonlyArray<Rune>) => {
|
|
2324
|
+
if (Predicate.isNull(getOwner())) throw misuse("WARDIC_WARD_WITHOUT_OWNER", WITHOUT_OWNER)
|
|
2325
|
+
return (make as (...given: ReadonlyArray<Rune>) => HookWard)(...runes)
|
|
2326
|
+
}) as WardMaker
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
const WITHOUT_OWNER =
|
|
2330
|
+
"createWard: a ward was made with no owner, outside a component or a root, where nothing would end it. Make it in the component that draws its Subject."
|
|
2307
2331
|
|
|
2308
2332
|
/** {@link wardOf}'s maker, without development's word on a ward following one that names nothing. */
|
|
2309
2333
|
const wardMakerOf =
|
package/src/hooks/wards.ts
CHANGED
|
@@ -54,6 +54,7 @@ import * as UndefinedOr from "effect/UndefinedOr"
|
|
|
54
54
|
import { type Accessor, createEffect, createMemo, createRoot, createSignal, getOwner, runWithOwner, untrack } from "solid-js"
|
|
55
55
|
import { makePresenceHandle } from "../presence-handle.ts"
|
|
56
56
|
import { sensedOf } from "../ward.tsx"
|
|
57
|
+
import { misuse } from "../diagnostics.ts"
|
|
57
58
|
import { type DragIn, type FitRune, type FitTaggedRune, isFunctionRune, type OnThePage, type Rune, type RuneIn, type RunesTaken, type TagIn } from "./rune.ts"
|
|
58
59
|
import type { Drags } from "./drag.ts"
|
|
59
60
|
import { type ExitEvent, type ExitEvents, exitsNow, type HookWard, type HookWardOf, leaveCommitted, leavesNow, letGo, popAnchorsFor, rowInLayout, type TaggedWard, takenOf, tellingExits, whenLeft } from "./ward.ts"
|
|
@@ -565,7 +566,8 @@ const stagePresenceOf = <T>(source: Accessor<T> | StagePresenceSource<T>): { rea
|
|
|
565
566
|
return { options: source, value: source.value }
|
|
566
567
|
}
|
|
567
568
|
|
|
568
|
-
const NOT_MADE =
|
|
569
|
+
const NOT_MADE =
|
|
570
|
+
"createPresence(ward, value): its ward is one `createWard` made, with no `show` of its own, and not a list's row. Make a ward for the presence alone, and let the presence show it, not a `show`."
|
|
569
571
|
|
|
570
572
|
/** What's on the page: what its value is matched by, and the latest value seen under that. */
|
|
571
573
|
interface On<T> {
|
|
@@ -594,7 +596,7 @@ const sourceOf = <T>(source: Accessor<T> | PresenceSource<T>): { readonly value:
|
|
|
594
596
|
*/
|
|
595
597
|
export const hookPresence: HookPresenceOf = <T>(given: HookWard, source: Accessor<T> | (PresenceSource<T> & AffectsLayout)): Accessor<NonNullable<T> | undefined> & Leaving => {
|
|
596
598
|
const taken = takenOf(given)
|
|
597
|
-
if (Predicate.isUndefined(taken)) throw
|
|
599
|
+
if (Predicate.isUndefined(taken)) throw misuse("WARDIC_PRESENCE_WARD_HAS_SHOW", NOT_MADE)
|
|
598
600
|
const { value, key } = sourceOf(source)
|
|
599
601
|
const state = taken.state
|
|
600
602
|
if (!Predicate.isFunction(source) && source.affectsLayout === false) state.affectsLayout = false
|
package/src/provider.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import * as Effect from "effect/Effect"
|
|
|
26
26
|
import * as Fiber from "effect/Fiber"
|
|
27
27
|
import { constFalse, constUndefined } from "effect/Function"
|
|
28
28
|
import * as Latch from "effect/Latch"
|
|
29
|
+
import * as Layer from "effect/Layer"
|
|
29
30
|
import * as Predicate from "effect/Predicate"
|
|
30
31
|
import * as UndefinedOr from "effect/UndefinedOr"
|
|
31
32
|
import type * as DefaultTransition from "@wardic/core/DefaultTransition"
|
|
@@ -59,6 +60,7 @@ import {
|
|
|
59
60
|
} from "./runtime.ts"
|
|
60
61
|
import type * as ElementSetup from "@wardic/dom/unstable/ElementSetup"
|
|
61
62
|
import { WAITING_ENV_FIX, WAITING_ENV_LINE } from "./messages.ts"
|
|
63
|
+
import { misuse, reporterLayer } from "./diagnostics.ts"
|
|
62
64
|
import { warnWithoutSpans } from "./spans-check.ts"
|
|
63
65
|
import { onSettledClientOnly, reactivityIn, untracked } from "./solid-reactivity.ts"
|
|
64
66
|
import { useWardicConfig } from "./wardic-config.tsx"
|
|
@@ -90,6 +92,19 @@ const contextValue = (): WardicContextValue | undefined => {
|
|
|
90
92
|
return pageContext()
|
|
91
93
|
}
|
|
92
94
|
|
|
95
|
+
/**
|
|
96
|
+
* How Solid 2's error for a read with neither a provider nor a page ends: in development, the fix, the
|
|
97
|
+
* page its hooks set up needing no provider (the skill grill's Q19); in a production build, the line
|
|
98
|
+
* alone, as `messages.ts`'s are, so a bundle drops the fix it never names (the size step after step 2).
|
|
99
|
+
*/
|
|
100
|
+
const pageEnding = (): string => {
|
|
101
|
+
if (DEV) return ": render the component that calls it inside one, or set the page up for it with no provider: importing `@wardic/solid/hooks` does, with `DomLive`, and `setupWard({ env })` gives it your own."
|
|
102
|
+
return "."
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** `pick` off the nearest provider's value, else the page's, or the coded error naming `name`, ending on Solid 2's ending. */
|
|
106
|
+
const fromScope = <A,>(name: string, pick: (value: WardicContextValue) => A): A => fromContext(contextValue(), name, pick, pageEnding(), misuse)
|
|
107
|
+
|
|
93
108
|
/**
|
|
94
109
|
* What a client provider fails with when its `env` waits as it builds (#746, ADR-0067 *Amendment
|
|
95
110
|
* (#746)*, decision 7): the fix in development, under Solid's `DEV`, and one line in a production
|
|
@@ -101,21 +116,29 @@ const waitingEnvMessage = (): string => {
|
|
|
101
116
|
return WAITING_ENV_LINE
|
|
102
117
|
}
|
|
103
118
|
|
|
119
|
+
/**
|
|
120
|
+
* `env`, with the binding's diagnostics reporter under it (solid-next): what core and dom report goes
|
|
121
|
+
* on Solid's channel, as the binding's own does, unless `env` gives a reporter of its own. Here, not in
|
|
122
|
+
* the runtime Solid 1's binding shares, which has no Solid 2 channel to report to.
|
|
123
|
+
*/
|
|
124
|
+
const reportingIn = (env: WardicEnv): WardicEnv => Layer.merge(reporterLayer, env)
|
|
125
|
+
|
|
104
126
|
/**
|
|
105
127
|
* A provider's context: a server render's, inert, or the client's. Decided by a plain `if`: a client
|
|
106
128
|
* build folds `isServer` and drops the server render's code, where `Bool.match` kept it (#518: 8.4 KB
|
|
107
129
|
* gzipped in every Solid 2 app). `env` and `appear` are read once, as the provider's docs say.
|
|
108
130
|
*/
|
|
109
131
|
const contextOf = (given: ScopeProps): WardicContextValue => {
|
|
110
|
-
if (isServer) return serverContext(given.env, WAITING_ENV_FIX, serverAppearOf(given.appear, given.reducedMotion, given.nonce), () => untrack(() => given.reducedMotion))
|
|
132
|
+
if (isServer) return serverContext(reportingIn(given.env), WAITING_ENV_FIX, serverAppearOf(given.appear, given.reducedMotion, given.nonce), () => untrack(() => given.reducedMotion), misuse)
|
|
111
133
|
return clientContext(
|
|
112
|
-
given.env,
|
|
134
|
+
reportingIn(given.env),
|
|
113
135
|
waitingEnvMessage(),
|
|
114
136
|
applyAndFlush,
|
|
115
137
|
() => untrack(() => given.reducedMotion),
|
|
116
138
|
// The provider's setting, tracked too: `createReducedMotionConfig` reads it where it tracks (#584).
|
|
117
139
|
() => given.reducedMotion,
|
|
118
140
|
untrack(() => given.scaleCorrectors),
|
|
141
|
+
misuse,
|
|
119
142
|
)
|
|
120
143
|
}
|
|
121
144
|
|
|
@@ -248,7 +271,7 @@ export function useElementFeatures(internal: Feature.ElementFeatures): Feature.F
|
|
|
248
271
|
const { brings, instance } = internal
|
|
249
272
|
const complete = internal.complete === true
|
|
250
273
|
const section = useFeatureSection()
|
|
251
|
-
if (DEV && complete && section.strict) throw
|
|
274
|
+
if (DEV && complete && section.strict) throw misuse("WARDIC_COMPLETE_UNDER_STRICT", Feature.strictMessage("wardic.*, wardic.create, ward()", "w.*, w.create, w.ward()", STRICT_UNDER))
|
|
252
275
|
// A Wardic instance's element (#516): its instance's Features, given at once or loaded, beside its section's;
|
|
253
276
|
// and what it brings besides, a hooks Reorder row's (the Reorder round's RF3), where it brings any.
|
|
254
277
|
if (Predicate.isNotUndefined(instance)) return broughtBeside(Feature.joinSections(section, useInstanceFeatures(instance)), brings)
|
|
@@ -270,7 +293,7 @@ const broughtBeside = (section: Feature.FeatureSection, brings: ReadonlyArray<Fe
|
|
|
270
293
|
* given built on first need, each load started the first time it's asked for, on the client. Internal.
|
|
271
294
|
*/
|
|
272
295
|
export function useInstanceFeatures(instance: Feature.InstanceFeatures): Feature.Own {
|
|
273
|
-
return
|
|
296
|
+
return fromScope("makeWard", (value) =>
|
|
274
297
|
instance.own(value.features, {
|
|
275
298
|
reactivity: reactivityIn(getOwner()),
|
|
276
299
|
server: isServer,
|
|
@@ -294,7 +317,7 @@ export function useInstanceBrought(instance: Feature.InstanceFeatures): void {
|
|
|
294
317
|
|
|
295
318
|
/** The provider's Features (#511). Internal. */
|
|
296
319
|
export function useFeatureRegistry(): Feature.FeatureRegistry {
|
|
297
|
-
return
|
|
320
|
+
return fromScope("useFeatureRegistry", (value) => value.features)
|
|
298
321
|
}
|
|
299
322
|
|
|
300
323
|
/**
|
|
@@ -328,7 +351,7 @@ export const pageContextOf = (props: ScopeProps): WardicContextValue => {
|
|
|
328
351
|
/** {@link pageContextOf}'s value: a plain `if`, so a client build drops the server's half (#518). */
|
|
329
352
|
const pageValueOf = (props: ScopeProps): WardicContextValue => {
|
|
330
353
|
// eslint-disable-next-line solid/reactivity -- a server renders once: its props read as its context is made
|
|
331
|
-
if (isServer) return serverContext(props.env, WAITING_ENV_FIX, AppearAnimations.serverAppearUnder(props.appear, props.reducedMotion, props.nonce), () => untrack(() => props.reducedMotion))
|
|
354
|
+
if (isServer) return serverContext(reportingIn(props.env), WAITING_ENV_FIX, AppearAnimations.serverAppearUnder(props.appear, props.reducedMotion, props.nonce), () => untrack(() => props.reducedMotion), misuse)
|
|
332
355
|
return contextOf(props)
|
|
333
356
|
}
|
|
334
357
|
|
|
@@ -382,7 +405,7 @@ export function useWardicAppear(): AppearAnimations.ServerAppear | undefined {
|
|
|
382
405
|
*/
|
|
383
406
|
// ADR-0021: a server builds no runtime, and DomLive refuses with its client-only error.
|
|
384
407
|
export function useWardicRuntime(): WardicRuntime {
|
|
385
|
-
return
|
|
408
|
+
return fromScope("useWardicRuntime", (value) => value.runtime)
|
|
386
409
|
}
|
|
387
410
|
|
|
388
411
|
/** The nearest provider's runtime, or none outside one: where a transform's failure is reported (#979). */
|
|
@@ -399,17 +422,17 @@ export function useProvidedRuntime(): WardicRuntime | undefined {
|
|
|
399
422
|
*/
|
|
400
423
|
// ADR-0006; inert on a server (ADR-0021, decision 9).
|
|
401
424
|
export function useWardicGate(): FlushGate.Shape {
|
|
402
|
-
return
|
|
425
|
+
return fromScope("useWardicGate", (value) => value.gate)
|
|
403
426
|
}
|
|
404
427
|
|
|
405
428
|
/** The Environment's Renderer (ADR-0003), read once by the provider: what an element and a presence project and commit through. Internal. */
|
|
406
429
|
export function useWardicRenderer(): Renderer.Renderer["Service"] {
|
|
407
|
-
return
|
|
430
|
+
return fromScope("useWardicRenderer", (value) => value.renderer)
|
|
408
431
|
}
|
|
409
432
|
|
|
410
433
|
/** The Environment's Positional keys (ADR-0036): which keys reduced motion Snaps. Internal. */
|
|
411
434
|
export function useWardicPositionalKeys(): ReducedMotion.PositionalKeys["Service"] {
|
|
412
|
-
return
|
|
435
|
+
return fromScope("useWardicPositionalKeys", (value) => value.positionalKeys)
|
|
413
436
|
}
|
|
414
437
|
|
|
415
438
|
/**
|
|
@@ -418,12 +441,12 @@ export function useWardicPositionalKeys(): ReducedMotion.PositionalKeys["Service
|
|
|
418
441
|
* DOM's). Internal.
|
|
419
442
|
*/
|
|
420
443
|
export function useWardicValueReads(): ElementSetup.ValueReads {
|
|
421
|
-
return
|
|
444
|
+
return fromScope("useWardicValueReads", (value) => value.valueReads)
|
|
422
445
|
}
|
|
423
446
|
|
|
424
447
|
/** The Environment's Default transition (ADR-0051): what a key with no transition of its own runs on. Internal. */
|
|
425
448
|
export function useWardicDefaultTransition(): DefaultTransition.DefaultTransition["Service"] {
|
|
426
|
-
return
|
|
449
|
+
return fromScope("useWardicDefaultTransition", (value) => value.defaultTransition)
|
|
427
450
|
}
|
|
428
451
|
|
|
429
452
|
/**
|
|
@@ -434,7 +457,7 @@ export function useWardicDefaultTransition(): DefaultTransition.DefaultTransitio
|
|
|
434
457
|
// a config's `reducedMotion={signal()}` was Solid 2's STRICT_READ_UNTRACKED.
|
|
435
458
|
export function useWardicReducedMotion(own?: WardicConfigValue.WardicConfigValue): () => boolean {
|
|
436
459
|
const config = configHere(own)
|
|
437
|
-
return
|
|
460
|
+
return fromScope("useWardicReducedMotion", (value) => untracked(reducedMotionWith(value, config)))
|
|
438
461
|
}
|
|
439
462
|
|
|
440
463
|
/** A ward's own config settings where it gives them (probe: behaviour-runes), else the nearest `WardicConfig`'s. */
|
|
@@ -470,7 +493,7 @@ export function useWardicSkipAnimations(own?: WardicConfigValue.WardicConfigValu
|
|
|
470
493
|
*/
|
|
471
494
|
// #443, as Solid 1's: an Instant change of the layout, the projection system's `instant`.
|
|
472
495
|
export function createInstantLayoutTransition(): (fn?: () => void) => void {
|
|
473
|
-
return
|
|
496
|
+
return fromScope("createInstantLayoutTransition", (value) => Instant.instantLayoutOf(() => value.projection))
|
|
474
497
|
}
|
|
475
498
|
|
|
476
499
|
/**
|
|
@@ -486,7 +509,7 @@ export function createInstantLayoutTransition(): (fn?: () => void) => void {
|
|
|
486
509
|
*/
|
|
487
510
|
// #443, as Solid 1's: an Instant change, each animation it covers a Skipped animation (#468).
|
|
488
511
|
export function createInstantTransition(): Instant.InstantTransition {
|
|
489
|
-
return
|
|
512
|
+
return fromScope("createInstantTransition", (value) => Instant.instantTransitionOf(() => value.projection, () => value.instant))
|
|
490
513
|
}
|
|
491
514
|
|
|
492
515
|
/**
|
|
@@ -505,7 +528,7 @@ export function createInstantTransition(): Instant.InstantTransition {
|
|
|
505
528
|
*/
|
|
506
529
|
// #443, as Solid 1's: a Projection reset, the projection system's `reset`: leavers and Switch seeds dropped.
|
|
507
530
|
export function createResetProjection(): () => void {
|
|
508
|
-
return
|
|
531
|
+
return fromScope("createResetProjection", (value) => Instant.resetOf(() => value.projection))
|
|
509
532
|
}
|
|
510
533
|
|
|
511
534
|
/**
|
|
@@ -514,14 +537,14 @@ export function createResetProjection(): () => void {
|
|
|
514
537
|
*/
|
|
515
538
|
export function useWardicReducedMotionSetting(): () => ReducedMotion.Config {
|
|
516
539
|
const config = useWardicConfig()
|
|
517
|
-
return
|
|
540
|
+
return fromScope("useWardicReducedMotionSetting", (value) => reducedMotionSettingWith(value, config))
|
|
518
541
|
}
|
|
519
542
|
|
|
520
543
|
/**
|
|
521
544
|
* `read` of the nearest provider's context value, named `name` in the error outside one: for a hook in
|
|
522
545
|
* a module of its own (#548), such as `useWardicProjection`, which brings `layout`.
|
|
523
546
|
*/
|
|
524
|
-
export const fromWardicContext = <A,>(name: string, read: (value: WardicContextValue) => A): A =>
|
|
547
|
+
export const fromWardicContext = <A,>(name: string, read: (value: WardicContextValue) => A): A => fromScope(name, read)
|
|
525
548
|
|
|
526
549
|
/**
|
|
527
550
|
* The provider's projection system once its `layout` Feature is built (#511), read as it's needed;
|
|
@@ -529,7 +552,7 @@ export const fromWardicContext = <A,>(name: string, read: (value: WardicContextV
|
|
|
529
552
|
* layout elements that are there: an element registering its values, a presence. Internal.
|
|
530
553
|
*/
|
|
531
554
|
export function useBuiltProjection(): () => ProjectionSystem.Shape | undefined {
|
|
532
|
-
return
|
|
555
|
+
return fromScope("useBuiltProjection", (value) => () => value.projection)
|
|
533
556
|
}
|
|
534
557
|
|
|
535
558
|
/**
|
|
@@ -556,7 +579,7 @@ export type AnimateLayout = <A>(fn: () => A) => Promise<Awaited<A>>
|
|
|
556
579
|
*/
|
|
557
580
|
export function useAnimateLayout(): AnimateLayout {
|
|
558
581
|
const value = contextValue()
|
|
559
|
-
const declare = animateLayoutOf(value)
|
|
582
|
+
const declare = animateLayoutOf(value, pageEnding(), misuse)
|
|
560
583
|
const disposed = UndefinedOr.match(value, { onUndefined: constUndefined, onDefined: (v) => disposals.get(v) })
|
|
561
584
|
return <A,>(fn: () => A): Promise<Awaited<A>> => {
|
|
562
585
|
// A server render has nothing to animate, and never settles.
|
package/src/reorder.tsx
CHANGED
|
@@ -67,6 +67,7 @@ import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures"
|
|
|
67
67
|
import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
|
|
68
68
|
import { watchItemInput } from "@wardic/dom/unstable/ReorderInput"
|
|
69
69
|
import { plainOrder } from "./reorder-values.ts"
|
|
70
|
+
import { misuse } from "./diagnostics.ts"
|
|
70
71
|
import { configView, type PerKey } from "./config-view.ts"
|
|
71
72
|
import { useBrought, useWardicRuntime } from "./provider.tsx"
|
|
72
73
|
import { useLayoutServices } from "./layout-projection.tsx"
|
|
@@ -268,10 +269,10 @@ const itemLayoutOf = (layout: unknown): ReorderItemLayout =>
|
|
|
268
269
|
|
|
269
270
|
/** A config given whole as an accessor, which the Solid 2 binding no longer reads (#259). */
|
|
270
271
|
const WHOLE_GROUP_ACCESSOR =
|
|
271
|
-
"reorderGroup(config) takes its config as an object, read per key
|
|
272
|
+
"reorderGroup(config) takes its config as an object, read per key: make a key reactive with an accessor " +
|
|
272
273
|
"(`reorderGroup({ values: items, onReorder: setItems })`), a getter, a store or a component's props."
|
|
273
274
|
const WHOLE_ITEM_ACCESSOR =
|
|
274
|
-
"reorderItem(list, config) takes its config as an object, read per key
|
|
275
|
+
"reorderItem(list, config) takes its config as an object, read per key: `reorderItem(list, { value })`, " +
|
|
275
276
|
"a key made reactive with an accessor, a getter, a store or a component's props."
|
|
276
277
|
|
|
277
278
|
/** Whether a call is Solid applying a ref. */
|
|
@@ -333,7 +334,7 @@ const refCarrying = <G,>(attach: (element: HTMLElement) => void, props: Property
|
|
|
333
334
|
// A `values` change re-measures. On a server it renders the element's style and nothing else: no
|
|
334
335
|
// controller, no runtime; its `group`, `move` and `controller` do nothing (ADR-0021).
|
|
335
336
|
export function reorderGroup<V>(config: ReorderGroupConfig<V>): ReorderGroup<V> {
|
|
336
|
-
if (Predicate.isFunction(config)) throw
|
|
337
|
+
if (Predicate.isFunction(config)) throw misuse("WARDIC_CONFIG_AS_ACCESSOR", WHOLE_GROUP_ACCESSOR)
|
|
337
338
|
const view = groupViewOf(config)
|
|
338
339
|
const cfg = (): ReorderGroupConfigValues<V> => view
|
|
339
340
|
const runtime = useWardicRuntime()
|
|
@@ -524,7 +525,7 @@ export type ReorderItem<V, C extends ReorderItemConfig<V> = ReorderItemConfig<V>
|
|
|
524
525
|
// The Reorder round's RF1: an item took its parent and its tag alone, so a hook row's function rune
|
|
525
526
|
// never heard its row, its lifecycle unshared.
|
|
526
527
|
export const reorderItemWith = <V,>(list: ReorderGroup<V>, config: ReorderItemConfig<V>, internal: WardInternals): Ward => {
|
|
527
|
-
if (Predicate.isFunction(config)) throw
|
|
528
|
+
if (Predicate.isFunction(config)) throw misuse("WARDIC_CONFIG_AS_ACCESSOR", WHOLE_ITEM_ACCESSOR)
|
|
528
529
|
// Its own keys read per key (#259); the rest are its ward's config, read by the ward. Its `layout`
|
|
529
530
|
// is its Layout mode, `true` or `"position"` whatever the config gives, read at each layout
|
|
530
531
|
// animation's start as any ward's is (ADR-0009, *Amendment (#42)*).
|
package/src/runtime.ts
CHANGED
|
@@ -12,6 +12,7 @@ import * as Probe from "@wardic/core/Probe"
|
|
|
12
12
|
import * as ReducedMotion from "@wardic/core/ReducedMotion"
|
|
13
13
|
import * as RefreshFrameSource from "@wardic/core/RefreshFrameSource"
|
|
14
14
|
import * as Renderer from "@wardic/core/Renderer"
|
|
15
|
+
import * as Diagnostic from "@wardic/core/unstable/Diagnostic"
|
|
15
16
|
import * as MeasuredPairs from "@wardic/core/unstable/MeasuredPairs"
|
|
16
17
|
import * as OwnValues from "@wardic/core/unstable/OwnValues"
|
|
17
18
|
import * as VariableValues from "@wardic/core/unstable/VariableValues"
|
|
@@ -53,16 +54,28 @@ import type * as ElementSetup from "@wardic/dom/unstable/ElementSetup"
|
|
|
53
54
|
// #672: core's `unstable/WardicServices` defines it; this alias keeps its reader docs here.
|
|
54
55
|
export type WardicEnv = CoreWardicServices.WardicEnv
|
|
55
56
|
|
|
57
|
+
/**
|
|
58
|
+
* How a binding makes the error a misuse throws, by its code and message (solid-next). By default core's
|
|
59
|
+
* coded line alone ({@link asLine}): Solid 1's binding shares this module and has no Solid 2 channel. Solid 2's
|
|
60
|
+
* gives its `misuse`, which puts the error on Solid's channel with its owner path and footer (the skill
|
|
61
|
+
* grill's Q17).
|
|
62
|
+
*/
|
|
63
|
+
export type Misuse = (code: Diagnostic.Code, message: string) => Error
|
|
64
|
+
|
|
65
|
+
/** A misuse's error as core's coded line alone, `[CODE] message`: Solid 1's. */
|
|
66
|
+
const asLine: Misuse = (code, message) => new Error(Diagnostic.line(code, message))
|
|
67
|
+
|
|
56
68
|
/**
|
|
57
69
|
* `env`, built at once, on the runtime's memo map and Scope as it would be unwrapped. A provider
|
|
58
70
|
* runs its services from a render, so a Layer that waits as it builds, such as `DevTools.layer()`
|
|
59
|
-
* waiting for its connection, fails the build with `waiting
|
|
71
|
+
* waiting for its connection, fails the build with `waiting`, made an error by `fail`; any other
|
|
72
|
+
* failure is its own.
|
|
60
73
|
*/
|
|
61
|
-
const builtAtOnce = (env: WardicEnv, waiting: string): WardicEnv =>
|
|
74
|
+
const builtAtOnce = (env: WardicEnv, waiting: string, fail: Misuse = asLine): WardicEnv =>
|
|
62
75
|
Layer.fromBuild((memoMap, scope) => {
|
|
63
76
|
const exit = Effect.runSyncExit(Layer.buildWithMemoMap(env, memoMap, scope))
|
|
64
77
|
return Bool.match(Option.exists(Result.getSuccess(Exit.findDefect(exit)), Cause.isAsyncFiberError), {
|
|
65
|
-
onTrue: () => Effect.die(
|
|
78
|
+
onTrue: () => Effect.die(fail("WARDIC_ENV_ASYNC", waiting)),
|
|
66
79
|
onFalse: () => exit,
|
|
67
80
|
})
|
|
68
81
|
})
|
|
@@ -194,6 +207,7 @@ export const clientContext = (
|
|
|
194
207
|
reducedMotion: () => ReducedMotion.Config | undefined,
|
|
195
208
|
reducedMotionSetting: () => ReducedMotion.Config | undefined,
|
|
196
209
|
scaleCorrectors?: ProjectionSystem.Options["scaleCorrectors"],
|
|
210
|
+
fail: Misuse = asLine,
|
|
197
211
|
): WardicContextValue => {
|
|
198
212
|
let built: Built | undefined
|
|
199
213
|
const build = (): Built => {
|
|
@@ -229,7 +243,7 @@ export const clientContext = (
|
|
|
229
243
|
// layout animation starts, and the app's scale correctors.
|
|
230
244
|
const projectionOptions: ProjectionSystem.Options = { reducedMotion: () => build().reducedMotion(), scaleCorrectors }
|
|
231
245
|
const runtime: ProviderRuntime = ManagedRuntime.make(
|
|
232
|
-
Layer.merge(FlushGate.layer({ batch }), Layer.succeed(Feature.ProjectionOptions)(projectionOptions)).pipe(Layer.provideMerge(builtAtOnce(env, waiting))),
|
|
246
|
+
Layer.merge(FlushGate.layer({ batch }), Layer.succeed(Feature.ProjectionOptions)(projectionOptions)).pipe(Layer.provideMerge(builtAtOnce(env, waiting, fail))),
|
|
233
247
|
)
|
|
234
248
|
const features = Feature.clientRegistry(runtime, () => disposeReported(runtime))
|
|
235
249
|
// Its Instant changes (#443), timed by its Environment's Refresh frames, found at the first.
|
|
@@ -300,8 +314,14 @@ const settingOf = (setting: ReducedMotion.Config | undefined, provider: () => Re
|
|
|
300
314
|
* working), an inert gate, no projection system, reduced motion never applying, and the render's
|
|
301
315
|
* Appear animations when it has them.
|
|
302
316
|
*/
|
|
303
|
-
export const serverContext = (
|
|
304
|
-
|
|
317
|
+
export const serverContext = (
|
|
318
|
+
env: WardicEnv,
|
|
319
|
+
waiting: string,
|
|
320
|
+
appear: AppearAnimations.ServerAppear | undefined,
|
|
321
|
+
reducedMotion: () => ReducedMotion.Config | undefined,
|
|
322
|
+
fail: Misuse = asLine,
|
|
323
|
+
): WardicContextValue => {
|
|
324
|
+
const runtime = ManagedRuntime.make(builtAtOnce(env, waiting, fail))
|
|
305
325
|
return {
|
|
306
326
|
runtime,
|
|
307
327
|
// A server render's elements take the lean path and never read it: read at each use if one does.
|
|
@@ -376,9 +396,17 @@ export const prepareIdle = (value: WardicContextValue, section: Feature.FeatureS
|
|
|
376
396
|
}
|
|
377
397
|
}
|
|
378
398
|
|
|
379
|
-
/**
|
|
380
|
-
|
|
381
|
-
|
|
399
|
+
/** How the error outside a provider ends, by default: Solid 1's fix, a provider above. */
|
|
400
|
+
const PROVIDER_FIX = ": render the component that calls it inside one, `<WardicProvider env={DomLive}>`."
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Reads `pick` off a provider's context value, or throws `name`'s clear error outside one, ending on
|
|
404
|
+
* `ending`: coded (solid-next), by core's line, as Solid 1's binding shares this module and has no
|
|
405
|
+
* Solid 2 channel. Solid 2's gives an ending of its own: the page its hooks set up, in development, and
|
|
406
|
+
* none in a production build (`"."`).
|
|
407
|
+
*/
|
|
408
|
+
export const fromContext = <A>(value: WardicContextValue | undefined, name: string, pick: (value: WardicContextValue) => A, ending: string = PROVIDER_FIX, fail: Misuse = asLine): A => {
|
|
409
|
+
if (Predicate.isUndefined(value)) throw fail("WARDIC_NO_PROVIDER", `${name} must be used within a <WardicProvider>${ending}`)
|
|
382
410
|
return pick(value)
|
|
383
411
|
}
|
|
384
412
|
|
|
@@ -404,22 +432,24 @@ const runOnly: AnimateLayout = (fn, options = NO_OPTIONS) => {
|
|
|
404
432
|
* just run until a section builds `layout`, as with no layout element there's nothing to animate, and
|
|
405
433
|
* during a server render.
|
|
406
434
|
*/
|
|
407
|
-
export const animateLayoutOf = (value: WardicContextValue | undefined): AnimateLayout =>
|
|
435
|
+
export const animateLayoutOf = (value: WardicContextValue | undefined, ending?: string, fail?: Misuse): AnimateLayout =>
|
|
408
436
|
fromContext(
|
|
409
437
|
value,
|
|
410
438
|
"useAnimateLayout",
|
|
411
439
|
(v): AnimateLayout =>
|
|
412
440
|
(fn, options) =>
|
|
413
441
|
UndefinedOr.match(v.projection, { onUndefined: () => runOnly(fn, options), onDefined: (projection) => projection.animateLayout(fn, options) }),
|
|
442
|
+
ending,
|
|
443
|
+
fail,
|
|
414
444
|
)
|
|
415
445
|
|
|
416
446
|
/**
|
|
417
|
-
* A fiber's effect as `runScoped` runs it: a failure logged at Error, `
|
|
418
|
-
* failed
|
|
447
|
+
* A fiber's effect as `runScoped` runs it: a failure logged at Error, `[WARDIC_CALLBACK_THREW]
|
|
448
|
+
* wardic.runScoped: a fiber failed` (the app's effect), with its cause, and reported to the Environment's `ErrorReporter`s (ADR-0030, decision
|
|
419
449
|
* 4); an interruption is neither. The fiber still fails with it.
|
|
420
450
|
*/
|
|
421
451
|
export const reported = <A, E>(effect: Effect.Effect<A, E, WardicServices>): Effect.Effect<A, E, WardicServices> =>
|
|
422
|
-
effect.pipe(Effect.tapCause((cause) => Report.
|
|
452
|
+
effect.pipe(Effect.tapCause((cause) => Report.callbackFailed("wardic.runScoped: a fiber failed", cause)))
|
|
423
453
|
|
|
424
454
|
/** A fiber that has already ended by interruption, on no Wardic runtime (1.1 µs): what a server render starts. */
|
|
425
455
|
export const interrupted = <A, E>(): Fiber.Fiber<A, E> => Effect.runFork(Effect.interrupt) as unknown as Fiber.Fiber<A, E>
|
package/src/spans-check.ts
CHANGED
|
@@ -7,18 +7,27 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import * as Spans from "@wardic/core/Spans"
|
|
10
|
+
import * as Diagnostic from "@wardic/core/unstable/Diagnostic"
|
|
10
11
|
import * as Bool from "effect/Boolean"
|
|
11
12
|
import * as Effect from "effect/Effect"
|
|
12
13
|
import type { WardicRuntime } from "./runtime.ts"
|
|
13
14
|
|
|
14
15
|
/** What development says. */
|
|
15
16
|
const MESSAGE =
|
|
16
|
-
"
|
|
17
|
+
"a tracer is installed, but Wardic opens no spans without WardicSpans. Merge it beside DomLive: Layer.mergeAll(DomLive, WardicSpans, …). See https://wardic.dev/guides/observability."
|
|
17
18
|
|
|
18
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Says, on `runtime`, that its tracer reads no Wardic span: run once a provider, at its idle build (#535).
|
|
21
|
+
* A coded diagnostic (solid-next), through the runtime's reporter: Solid's channel on Solid 2's, the
|
|
22
|
+
* app's logger on Solid 1's, which shares this module.
|
|
23
|
+
*/
|
|
19
24
|
export const warnWithoutSpans = (runtime: WardicRuntime): void => {
|
|
20
25
|
try {
|
|
21
|
-
runtime.runSync(
|
|
26
|
+
runtime.runSync(
|
|
27
|
+
Effect.flatMap(Spans.missing, (missing) =>
|
|
28
|
+
Bool.match(missing, { onTrue: () => Diagnostic.report("WARDIC_TRACER_WITHOUT_SPANS", MESSAGE), onFalse: () => Effect.void }),
|
|
29
|
+
),
|
|
30
|
+
)
|
|
22
31
|
} catch {
|
|
23
32
|
// An env that fails to build is the first element's to report.
|
|
24
33
|
}
|
package/src/v1/index.tsx
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @deprecated Solid 1's binding, deprecated and frozen: it goes at Wardic's next major. Solid 2's is `@wardic/solid` (#566).
|
|
19
19
|
*/
|
|
20
|
-
export const VERSION = "3.0.0-next.
|
|
20
|
+
export const VERSION = "3.0.0-next.1"
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* `WardicProvider` (one Effect runtime + `AtomRegistry` per ADR-0006), the
|