@wardic/core 1.5.0-next.0 → 1.5.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/dist/InterpolatorRegistry.d.ts.map +1 -1
- package/dist/InterpolatorRegistry.js +12 -2
- package/dist/InterpolatorRegistry.js.map +1 -1
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +9 -7
- package/dist/LiveValue.js.map +1 -1
- package/dist/internal/diagnostic-codes.d.ts +10 -0
- package/dist/internal/diagnostic-codes.d.ts.map +1 -0
- package/dist/internal/diagnostic-codes.js +19 -0
- package/dist/internal/diagnostic-codes.js.map +1 -0
- package/dist/internal/guarded.js +1 -1
- package/dist/internal/guarded.js.map +1 -1
- package/dist/unstable/Diagnostic.d.ts +49 -0
- package/dist/unstable/Diagnostic.d.ts.map +1 -0
- package/dist/unstable/Diagnostic.js +26 -0
- package/dist/unstable/Diagnostic.js.map +1 -0
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +3 -2
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/Imperative.js +4 -4
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/Report.d.ts +15 -4
- package/dist/unstable/Report.d.ts.map +1 -1
- package/dist/unstable/Report.js +21 -6
- package/dist/unstable/Report.js.map +1 -1
- package/dist/unstable/Spine.js +2 -2
- package/dist/unstable/Spine.js.map +1 -1
- package/dist/unstable/VariantTree.js +2 -2
- package/dist/unstable/VariantTree.js.map +1 -1
- package/package.json +1 -1
- package/src/InterpolatorRegistry.ts +16 -2
- package/src/LiveValue.ts +11 -7
- package/src/internal/diagnostic-codes.ts +27 -0
- package/src/internal/guarded.ts +1 -1
- package/src/unstable/Diagnostic.ts +58 -0
- package/src/unstable/FlushGate.ts +3 -2
- package/src/unstable/Imperative.ts +4 -4
- package/src/unstable/Report.ts +33 -6
- package/src/unstable/Spine.ts +2 -2
- package/src/unstable/VariantTree.ts +2 -2
|
@@ -23,6 +23,7 @@ import * as Predicate from "effect/Predicate"
|
|
|
23
23
|
import * as Interpolator from "./Interpolator.ts"
|
|
24
24
|
import { dual } from "./internal/dual.ts"
|
|
25
25
|
import * as LerpsNumbers from "./internal/lerpsNumbers.ts"
|
|
26
|
+
import * as Diagnostic from "./unstable/Diagnostic.ts"
|
|
26
27
|
|
|
27
28
|
// The registry is heterogeneous by design: its entries are `Interpolator.Entry<any, any>`.
|
|
28
29
|
|
|
@@ -173,17 +174,30 @@ const decodedBy =
|
|
|
173
174
|
const select = (entries: ReadonlyArray<Interpolator.Entry<any, any>>, from: unknown, to: unknown): Option.Option<DecodedPair> =>
|
|
174
175
|
Arr.findFirst(entries, decodedBy(from, to))
|
|
175
176
|
|
|
177
|
+
/** A value written as text: a string, or a number. */
|
|
178
|
+
const isText: Predicate.Predicate<unknown> = /*#__PURE__*/ Predicate.or(Predicate.isString, Predicate.isNumber)
|
|
179
|
+
|
|
180
|
+
/** An endpoint as the blend warning writes it: a string's or a number's own text, else "an object". */
|
|
181
|
+
const asWritten = (value: unknown): string => {
|
|
182
|
+
if (isText(value)) return `\`${String(value)}\``
|
|
183
|
+
return "an object"
|
|
184
|
+
}
|
|
185
|
+
|
|
176
186
|
/**
|
|
177
187
|
* A pair's blend from the entry that decodes both endpoints. When the entry can't blend them
|
|
178
188
|
* (two units, two structures), the pair is a Discrete pair, and `resolve` warns: Motion warns on a
|
|
179
189
|
* pair "too different to mix" (ADR-0026, decision 4). A pair of strings warns once per registry,
|
|
180
|
-
* since the cache keeps it (decision 9).
|
|
190
|
+
* since the cache keeps it (decision 9). The warning is a coded diagnostic (solid-next), naming both
|
|
191
|
+
* values in its line as well as its annotations, for a reporter that keeps no annotations.
|
|
181
192
|
*/
|
|
182
193
|
const blendDecoded = <From, To>(decoded: DecodedPair, from: From, to: To): Effect.Effect<Blend<From, To>> =>
|
|
183
194
|
Option.match(decoded.entry.blend(decoded.from, decoded.to), {
|
|
184
195
|
onSome: (blend) => Effect.succeed(blend),
|
|
185
196
|
onNone: () =>
|
|
186
|
-
|
|
197
|
+
Diagnostic.report(
|
|
198
|
+
"WARDIC_CANT_BLEND",
|
|
199
|
+
`can't blend ${asWritten(from)} into ${asWritten(to)} (the ${decoded.entry.name} interpolator): their units or shapes differ, so the value switches to the target at the first frame. Give both ends one unit and the same shape.`,
|
|
200
|
+
).pipe(
|
|
187
201
|
Effect.annotateLogs({ interpolator: decoded.entry.name, from, to }),
|
|
188
202
|
Effect.as(discreteBlend(from, to)),
|
|
189
203
|
),
|
package/src/LiveValue.ts
CHANGED
|
@@ -192,7 +192,7 @@ export const transform: {
|
|
|
192
192
|
if (failing) failing = false
|
|
193
193
|
} catch (defect) {
|
|
194
194
|
if (!kept) throw defect
|
|
195
|
-
if (!failing)
|
|
195
|
+
if (!failing) appFailed(context, MIXER_FAILED, defect)
|
|
196
196
|
failing = true
|
|
197
197
|
}
|
|
198
198
|
return last as O
|
|
@@ -415,6 +415,10 @@ const SOURCE_FAILED = "wardic.liveValue: its source failed"
|
|
|
415
415
|
/** A transform's ranges that threw: an app's `mixer`. */
|
|
416
416
|
const MIXER_FAILED = "wardic.transform: its mixer failed"
|
|
417
417
|
|
|
418
|
+
/** An app's function that threw (its mixer, an Atom over or under a run), reported on `context` as an app's callback (solid-next). */
|
|
419
|
+
const appFailed = (context: Context.Context<never> | undefined, message: string, defect: unknown): void =>
|
|
420
|
+
Report.callbackFailedOn(context, message, Cause.die(defect))
|
|
421
|
+
|
|
418
422
|
const FOLLOW_SPAN: Machine.Span = { name: "wardic.follow", attributes: {} }
|
|
419
423
|
|
|
420
424
|
/**
|
|
@@ -474,7 +478,7 @@ export const follow: (
|
|
|
474
478
|
lastTarget = registry.get(source)
|
|
475
479
|
if (sourceFailing) sourceFailing = false
|
|
476
480
|
} catch (defect) {
|
|
477
|
-
if (!sourceFailing)
|
|
481
|
+
if (!sourceFailing) appFailed(context, SOURCE_FAILED, defect)
|
|
478
482
|
sourceFailing = true
|
|
479
483
|
}
|
|
480
484
|
return lastTarget
|
|
@@ -527,7 +531,7 @@ export const follow: (
|
|
|
527
531
|
registry.set(out, frame.value)
|
|
528
532
|
if (failing) failing = false
|
|
529
533
|
} catch (defect) {
|
|
530
|
-
if (!failing)
|
|
534
|
+
if (!failing) appFailed(context, DEPENDENT_FAILED, defect)
|
|
531
535
|
failing = true
|
|
532
536
|
}
|
|
533
537
|
velocity = velocityOfFrame(frame)
|
|
@@ -798,7 +802,7 @@ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<nu
|
|
|
798
802
|
previousTick = loop.tickCount()
|
|
799
803
|
if (sourceFailing) sourceFailing = false
|
|
800
804
|
} catch (defect) {
|
|
801
|
-
if (!sourceFailing)
|
|
805
|
+
if (!sourceFailing) appFailed(context, SOURCE_FAILED, defect)
|
|
802
806
|
sourceFailing = true
|
|
803
807
|
}
|
|
804
808
|
return undefined
|
|
@@ -845,7 +849,7 @@ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<nu
|
|
|
845
849
|
now = registry.get(source)
|
|
846
850
|
if (sourceFailing) sourceFailing = false
|
|
847
851
|
} catch (defect) {
|
|
848
|
-
if (!sourceFailing)
|
|
852
|
+
if (!sourceFailing) appFailed(context, SOURCE_FAILED, defect)
|
|
849
853
|
sourceFailing = true
|
|
850
854
|
}
|
|
851
855
|
const v = (now - before) / step
|
|
@@ -856,7 +860,7 @@ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<nu
|
|
|
856
860
|
registry.set(out, frame.value)
|
|
857
861
|
if (failing) failing = false
|
|
858
862
|
} catch (defect) {
|
|
859
|
-
if (!failing)
|
|
863
|
+
if (!failing) appFailed(context, DEPENDENT_FAILED, defect)
|
|
860
864
|
failing = true
|
|
861
865
|
}
|
|
862
866
|
if (frame.done) running = false
|
|
@@ -918,7 +922,7 @@ export const time: () => Effect.Effect<Atom.Atom<number>, never, FrameLoop.Frame
|
|
|
918
922
|
registry.set(out, frame.value)
|
|
919
923
|
if (failing) failing = false
|
|
920
924
|
} catch (defect) {
|
|
921
|
-
if (!failing)
|
|
925
|
+
if (!failing) appFailed(context, DEPENDENT_FAILED, defect)
|
|
922
926
|
failing = true
|
|
923
927
|
}
|
|
924
928
|
return undefined
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core's coded diagnostics (solid-next, the skill grill's Q12, Q18): each code core reports
|
|
3
|
+
* (`Diagnostic.report`), with what the docs and the `wardic-diagnostics` skill say of it, both generated
|
|
4
|
+
* from here by `scripts/diagnostics.ts`. Imported by nothing an app runs.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type * as Diagnostic from "../unstable/Diagnostic.ts"
|
|
9
|
+
|
|
10
|
+
export const CODES: ReadonlyArray<Diagnostic.Entry> = [
|
|
11
|
+
{
|
|
12
|
+
code: "WARDIC_CANT_BLEND",
|
|
13
|
+
group: "Style",
|
|
14
|
+
summary: "Two values an animation moves between can't be blended, so the value switches to the target at the first frame instead of moving.",
|
|
15
|
+
why: "An animation moves through the values between its two ends. `10px` and `2em`, or two lists of different lengths, are read by the same interpolator but have no values between them, so Wardic switches at the first frame, as Motion does for values too different to mix.",
|
|
16
|
+
repair: "Give both ends the same unit (`10px` to `20px`) and the same shape: as many numbers, in the same order.",
|
|
17
|
+
notes: ["ADR-0026 decision 4"],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
code: "WARDIC_CALLBACK_THREW",
|
|
21
|
+
group: "App callbacks",
|
|
22
|
+
summary: "A function the app gave Wardic threw: a callback (`onComplete`, `onExitComplete`, a gesture's), a function variant or delay, a Live value's mixer or dependent, an easing, or an effect run for the app.",
|
|
23
|
+
why: "Wardic catches it so the animation, and everything else, goes on. It logs it at Error with its cause and hands the cause to the app's `ErrorReporter`s. The label after the code names the function that threw; the cause under it is the app's own error. A function that throws on each call is reported once for the run of throws, and again after a call that returns.",
|
|
24
|
+
repair: "Fix the function the label names: the cause's stack points into the app's code.",
|
|
25
|
+
notes: ["ADR-0030 decision 4, ADR-0074 decision 3"],
|
|
26
|
+
},
|
|
27
|
+
]
|
package/src/internal/guarded.ts
CHANGED
|
@@ -36,7 +36,7 @@ export const contextFor = (onDefect: OnDefect | undefined): Effect.Effect<Contex
|
|
|
36
36
|
export const guarded = <A>(handle: (event: A) => void, onDefect: OnDefect | undefined, context: Context.Context<never> | undefined): ((event: A) => void) => {
|
|
37
37
|
const tell = UndefinedOr.match(onDefect, {
|
|
38
38
|
onDefined: (defect) => (error: unknown) => defect(Cause.die(error)),
|
|
39
|
-
onUndefined: () => (error: unknown) => Report.
|
|
39
|
+
onUndefined: () => (error: unknown) => Report.callbackFailedOn(context, HANDLER_FAILED, Cause.die(error)),
|
|
40
40
|
})
|
|
41
41
|
let failing = false
|
|
42
42
|
return (event: A): void => {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A coded diagnostic: a rule an app broke, reported with a stable code, `WARDIC_` and what happened
|
|
3
|
+
* (`WARDIC_FEATURE_MISSING`), so a binding can put it where its framework reports its own, and a reader
|
|
4
|
+
* or a coding agent can look the code up. Core gives the way to report one; each package keeps its own
|
|
5
|
+
* codes, and each binding provides a `Reporter` that forwards a report to its framework's channel. With
|
|
6
|
+
* none provided, a report is a warning in the log, its code first.
|
|
7
|
+
*
|
|
8
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
// solid-next: the skill grill's Q6, Q17, Q18 and Q21. A Context.Reference with its default, as
|
|
13
|
+
// `UnitScale` and `PressClaims` are, read from the runtime a report runs on, so no caller passes it.
|
|
14
|
+
import * as Context from "effect/Context"
|
|
15
|
+
import * as Effect from "effect/Effect"
|
|
16
|
+
|
|
17
|
+
/** A diagnostic's code: `WARDIC_` and what happened, in Solid's style (`WARDIC_FEATURE_MISSING`). */
|
|
18
|
+
export type Code = `WARDIC_${string}`
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A code's entry in its package's registry: what the docs and the `wardic-diagnostics` skill say of
|
|
22
|
+
* it, both generated from it. The message a report prints is the call site's own; the entry explains
|
|
23
|
+
* it.
|
|
24
|
+
*/
|
|
25
|
+
export interface Entry {
|
|
26
|
+
readonly code: Code
|
|
27
|
+
/** Its group on the docs' index: "Features", "Presence", … */
|
|
28
|
+
readonly group: string
|
|
29
|
+
/** What happened, in a line: the title the docs give it. */
|
|
30
|
+
readonly summary: string
|
|
31
|
+
/** Why it's a problem. */
|
|
32
|
+
readonly why: string
|
|
33
|
+
/** How to fix it. */
|
|
34
|
+
readonly repair: string
|
|
35
|
+
/** A small before and after, where one shows the repair better than words. */
|
|
36
|
+
readonly example?: { readonly before: string; readonly after: string } | undefined
|
|
37
|
+
/** Where it came from (issues, ADRs): kept here, out of the message a reader sees. */
|
|
38
|
+
readonly notes?: ReadonlyArray<string> | undefined
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Where a coded report goes: a binding's own forwards it to its framework's channel. */
|
|
42
|
+
export interface Reporter {
|
|
43
|
+
readonly report: (code: Code, message: string) => Effect.Effect<void>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A report's first line, and a thrown misuse's message: its code, then what happened and its fix. */
|
|
47
|
+
export const line = (code: Code, message: string): string => `[${code}] ${message}`
|
|
48
|
+
|
|
49
|
+
/** With no binding's: a warning in the log, its code first. */
|
|
50
|
+
const LOGGED: Reporter = { report: (code, message) => Effect.logWarning(line(code, message)) }
|
|
51
|
+
|
|
52
|
+
/** The Environment's reporter: the log's, unless a binding's Layer gives its own. */
|
|
53
|
+
export const Reporter: Context.Reference<Reporter> = /*#__PURE__*/ Context.Reference<Reporter>("@wardic/core/unstable/Diagnostic/Reporter", {
|
|
54
|
+
defaultValue: () => LOGGED,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
/** Reports `code` on the Environment's reporter, `message` saying what happened and how to fix it. */
|
|
58
|
+
export const report = (code: Code, message: string): Effect.Effect<void> => Effect.flatMap(Effect.service(Reporter), (reporter) => reporter.report(code, message))
|
|
@@ -544,7 +544,8 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
|
|
|
544
544
|
} catch (defect) {
|
|
545
545
|
if (entry.onCommitFailing) continue
|
|
546
546
|
entry.onCommitFailing = true
|
|
547
|
-
|
|
547
|
+
// An app's own function: a binding's sink commits through the app's `onUpdate` (`Spine.withOnUpdate`).
|
|
548
|
+
runtime.runFork(Report.callbackFailed("wardic.gate: an onCommit failed", Cause.die(defect)))
|
|
548
549
|
}
|
|
549
550
|
}
|
|
550
551
|
committedSince.clear()
|
|
@@ -578,7 +579,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
|
|
|
578
579
|
registry.set(output.atom, value)
|
|
579
580
|
if (output.failing) output.failing = false
|
|
580
581
|
} catch (defect) {
|
|
581
|
-
if (!output.failing) runtime.runFork(Effect.annotateLogs(Report.
|
|
582
|
+
if (!output.failing) runtime.runFork(Effect.annotateLogs(Report.callbackFailed("wardic.gate: an output failed", Cause.die(defect)), { id, key }))
|
|
582
583
|
output.failing = true
|
|
583
584
|
}
|
|
584
585
|
}
|
|
@@ -1014,7 +1014,7 @@ const controlsOf = (
|
|
|
1014
1014
|
try {
|
|
1015
1015
|
complete()
|
|
1016
1016
|
} catch (defect) {
|
|
1017
|
-
runtime.runFork(Report.
|
|
1017
|
+
runtime.runFork(Report.callbackFailed("wardic.animate: an onComplete failed", Cause.die(defect)))
|
|
1018
1018
|
}
|
|
1019
1019
|
})
|
|
1020
1020
|
}
|
|
@@ -1377,7 +1377,7 @@ const callbackTrackOf = (env: AnimateEnv, callback: Callback, animation: Sequenc
|
|
|
1377
1377
|
const landed = (exit: Exit.Exit<unknown>): Effect.Effect<void> =>
|
|
1378
1378
|
Exit.match(exit, {
|
|
1379
1379
|
onSuccess: () => Effect.sync(() => settled(true)),
|
|
1380
|
-
onFailure: (cause) => Bool.match(Cause.hasInterruptsOnly(cause), { onTrue: () => Effect.void, onFalse: () => Report.
|
|
1380
|
+
onFailure: (cause) => Bool.match(Cause.hasInterruptsOnly(cause), { onTrue: () => Effect.void, onFalse: () => Report.callbackFailed(SEGMENT_FAILED, cause) }),
|
|
1381
1381
|
})
|
|
1382
1382
|
const run = (): void => {
|
|
1383
1383
|
end()
|
|
@@ -1395,7 +1395,7 @@ const callbackTrackOf = (env: AnimateEnv, callback: Callback, animation: Sequenc
|
|
|
1395
1395
|
} catch (defect) {
|
|
1396
1396
|
if (!failing) {
|
|
1397
1397
|
failing = true
|
|
1398
|
-
env.runtime.runFork(Report.
|
|
1398
|
+
env.runtime.runFork(Report.callbackFailed(SEGMENT_FAILED, Cause.die(defect)))
|
|
1399
1399
|
}
|
|
1400
1400
|
}
|
|
1401
1401
|
return undefined
|
|
@@ -1414,7 +1414,7 @@ const callbackTrackOf = (env: AnimateEnv, callback: Callback, animation: Sequenc
|
|
|
1414
1414
|
try {
|
|
1415
1415
|
callback.call(first)
|
|
1416
1416
|
} catch (defect) {
|
|
1417
|
-
env.runtime.runFork(Report.
|
|
1417
|
+
env.runtime.runFork(Report.callbackFailed("wardic.animate: a function Segment's cancel failed", Cause.die(defect)))
|
|
1418
1418
|
}
|
|
1419
1419
|
},
|
|
1420
1420
|
duration: () => Machine.durationOf(env.runtime.runSync(machine)),
|
package/src/unstable/Report.ts
CHANGED
|
@@ -29,33 +29,60 @@ import * as LogLevel from "effect/LogLevel"
|
|
|
29
29
|
import * as Predicate from "effect/Predicate"
|
|
30
30
|
import * as References from "effect/References"
|
|
31
31
|
import * as UndefinedOr from "effect/UndefinedOr"
|
|
32
|
+
import * as Diagnostic from "./Diagnostic.ts"
|
|
33
|
+
|
|
34
|
+
/** `message`, with `code` before it when there's one (`Diagnostic.line`). */
|
|
35
|
+
const codedOrNot = (message: string, code: Diagnostic.Code | undefined): string =>
|
|
36
|
+
UndefinedOr.match(code, { onUndefined: () => message, onDefined: (given) => Diagnostic.line(given, message) })
|
|
32
37
|
|
|
33
38
|
/**
|
|
34
39
|
* `cause` logged at Error as `message`, with the cause, and handed to the Environment's
|
|
35
40
|
* `ErrorReporter`s. An interruption is neither: it's how a run is removed, by a retarget, an unmount or a
|
|
36
|
-
* dispose. Annotate the log by piping `Effect.annotateLogs` onto it.
|
|
41
|
+
* dispose. Annotate the log by piping `Effect.annotateLogs` onto it. With `code`, the message is logged
|
|
42
|
+
* after it, `[CODE] message` (solid-next): what an app's callback that threw is logged with.
|
|
37
43
|
*/
|
|
38
|
-
export const failure = (message: string, cause: Cause.Cause<unknown
|
|
44
|
+
export const failure = (message: string, cause: Cause.Cause<unknown>, code?: Diagnostic.Code): Effect.Effect<void> =>
|
|
39
45
|
Bool.match(Cause.hasInterruptsOnly(cause), {
|
|
40
46
|
onTrue: () => Effect.void,
|
|
41
|
-
onFalse: () => Effect.logError(message, cause).pipe(Effect.andThen(ErrorReporter.report(cause))),
|
|
47
|
+
onFalse: () => Effect.logError(codedOrNot(message, code), cause).pipe(Effect.andThen(ErrorReporter.report(cause))),
|
|
42
48
|
})
|
|
43
49
|
|
|
44
50
|
/**
|
|
45
51
|
* {@link failure}, run where no fiber of a binding's is there to see it: on `context`, what the failing
|
|
46
52
|
* code was built or started in, so an app's logger and reporters hear it, else on Effect's default
|
|
47
|
-
* runtime. Forked, off the path that failed, with `annotations` on its log when given
|
|
53
|
+
* runtime. Forked, off the path that failed, with `annotations` on its log when given, and its
|
|
54
|
+
* message after `code` when given, as {@link failure}'s.
|
|
48
55
|
*/
|
|
49
56
|
// #979 (ADR-0030, *Amendment (#979, groups D and G)*): a Live value's run, a scroll's reader, a pointer's
|
|
50
57
|
// value and a watch with no onDefect, each captured its context once and calls this only at a failure.
|
|
51
|
-
export const failureOn = (
|
|
52
|
-
|
|
58
|
+
export const failureOn = (
|
|
59
|
+
context: Context.Context<never> | undefined,
|
|
60
|
+
message: string,
|
|
61
|
+
cause: Cause.Cause<unknown>,
|
|
62
|
+
annotations?: Readonly<Record<string, unknown>>,
|
|
63
|
+
code?: Diagnostic.Code,
|
|
64
|
+
): void => {
|
|
65
|
+
const report = UndefinedOr.match(annotations, { onUndefined: () => failure(message, cause, code), onDefined: (given) => Effect.annotateLogs(failure(message, cause, code), given) })
|
|
53
66
|
UndefinedOr.match(context, {
|
|
54
67
|
onUndefined: () => void Effect.runFork(report),
|
|
55
68
|
onDefined: (given) => void Effect.runForkWith(given)(report),
|
|
56
69
|
})
|
|
57
70
|
}
|
|
58
71
|
|
|
72
|
+
/** The code of an app's function that threw (solid-next): its label is logged after it. */
|
|
73
|
+
const CALLBACK_THREW: Diagnostic.Code = "WARDIC_CALLBACK_THREW"
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* {@link failure} for a function the app gave Wardic that threw (a callback, a mixer, an easing, a
|
|
77
|
+
* function variant): logged as `[WARDIC_CALLBACK_THREW] message`, with its cause, and handed to the
|
|
78
|
+
* Environment's `ErrorReporter`s. Wardic's own failures are {@link failure}'s, uncoded.
|
|
79
|
+
*/
|
|
80
|
+
export const callbackFailed = (message: string, cause: Cause.Cause<unknown>): Effect.Effect<void> => failure(message, cause, CALLBACK_THREW)
|
|
81
|
+
|
|
82
|
+
/** {@link callbackFailed}, run where no fiber of a binding's is there to see it, as {@link failureOn} is. */
|
|
83
|
+
export const callbackFailedOn = (context: Context.Context<never> | undefined, message: string, cause: Cause.Cause<unknown>, annotations?: Readonly<Record<string, unknown>>): void =>
|
|
84
|
+
failureOn(context, message, cause, annotations, CALLBACK_THREW)
|
|
85
|
+
|
|
59
86
|
/**
|
|
60
87
|
* Whether a Debug log would be kept, as Effect's `MinimumLogLevel` says. Run it once (a runtime, a
|
|
61
88
|
* build) and keep the answer, not once a log.
|
package/src/unstable/Spine.ts
CHANGED
|
@@ -1441,7 +1441,7 @@ export const animationCallbacks = (runtime: WardicServices.Runner<WardicServices
|
|
|
1441
1441
|
callback(definition)
|
|
1442
1442
|
return false
|
|
1443
1443
|
} catch (defect) {
|
|
1444
|
-
if (!failing) runtime.runFork(Report.
|
|
1444
|
+
if (!failing) runtime.runFork(Report.callbackFailed(`wardic.spine: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })))
|
|
1445
1445
|
return true
|
|
1446
1446
|
}
|
|
1447
1447
|
}
|
|
@@ -1685,7 +1685,7 @@ const failedOn =
|
|
|
1685
1685
|
(message: string) =>
|
|
1686
1686
|
(runtime: Pick<WardicServices.Runner<never>, "runFork">) =>
|
|
1687
1687
|
(failure: VariantTarget.VariantFailure): void => {
|
|
1688
|
-
runtime.runFork(Effect.annotateLogs(Report.
|
|
1688
|
+
runtime.runFork(Effect.annotateLogs(Report.callbackFailed(message, Cause.die(failure.defect)), { variant: failure.name }))
|
|
1689
1689
|
}
|
|
1690
1690
|
|
|
1691
1691
|
/** How a Subject's variant that throws is reported, on its runtime. */
|
|
@@ -644,10 +644,10 @@ const calledDelayOf = (delayChildren: Config.WardicStagger, index: number, total
|
|
|
644
644
|
return delay
|
|
645
645
|
} catch (defect) {
|
|
646
646
|
if (Predicate.isUndefined(failures)) {
|
|
647
|
-
Report.
|
|
647
|
+
Report.callbackFailedOn(undefined, DELAY_FAILED, Cause.die(defect), { index })
|
|
648
648
|
return 0
|
|
649
649
|
}
|
|
650
|
-
if (!failures.delayFailing) failures.runtime.runFork(Report.
|
|
650
|
+
if (!failures.delayFailing) failures.runtime.runFork(Report.callbackFailed(DELAY_FAILED, Cause.die(defect)).pipe(Effect.annotateLogs({ index })))
|
|
651
651
|
failures.delayFailing = true
|
|
652
652
|
return 0
|
|
653
653
|
}
|