@wardic/core 1.5.0-next.0 → 1.5.0-next.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/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/Recognizer.d.ts +3 -2
- package/dist/Recognizer.d.ts.map +1 -1
- package/dist/Recognizer.js +45 -16
- package/dist/Recognizer.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/VariantTarget.d.ts +26 -10
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +46 -0
- package/dist/unstable/VariantTarget.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/Recognizer.ts +64 -33
- 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/VariantTarget.ts +41 -0
- package/src/unstable/VariantTree.ts +2 -2
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. */
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
// Unstable: ADR-0071, decision 5. #672: solid's `variant-target.ts`, moved for the spine and the
|
|
12
12
|
// variant tree to resolve targets in core.
|
|
13
|
+
import { dual } from "../internal/dual.ts"
|
|
13
14
|
import type * as Values from "../Values.ts"
|
|
15
|
+
import * as AnimationControls from "./AnimationControls.ts"
|
|
14
16
|
import * as Stops from "./Stops.ts"
|
|
15
17
|
import * as Arr from "effect/Array"
|
|
16
18
|
import * as Bool from "effect/Boolean"
|
|
@@ -67,6 +69,45 @@ export type Entry = Config.WardicVariant | Config.WardicVariantLabels | undefine
|
|
|
67
69
|
*/
|
|
68
70
|
export const isLabels = (entry: unknown): entry is Config.WardicVariantLabels => Bool.or(Predicate.isString(entry), Arr.isArray(entry))
|
|
69
71
|
|
|
72
|
+
/** What a ward leaves by: its `exit`, or what its binding has it leave by where it gives none (its `initial`). */
|
|
73
|
+
export type Leave = Config.WardicVariant | Config.WardicVariantLabels
|
|
74
|
+
|
|
75
|
+
/** The target a ward was shown at, its `animate`, which a leave is laid over: a binding with none leaves by its exit as it is. */
|
|
76
|
+
export type Shown = Config.WardicVariant | Config.WardicVariantLabels | Config.WardicAnimationControls
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A ward's exit laid over the target it was shown at, for a ward that leaves while it's still alive (the
|
|
80
|
+
* hook-exit grill's Q1 and Q8): a key the exit doesn't name keeps that target, as Motion's exit, the last of
|
|
81
|
+
* its priority order, leaves it. A binding plays it as the ward's `animate` while the ward leaves; a
|
|
82
|
+
* presence's child, played from its snapshot after its ward has ended, leaves by its exit alone.
|
|
83
|
+
*
|
|
84
|
+
* - **Names over names** are one list, the shown names first, so a later name wins a key both set, as a
|
|
85
|
+
* list's does, each key on the transition of the name that sets it, and each name reaches the ward's
|
|
86
|
+
* followers, which lay their own variants the same way.
|
|
87
|
+
* - **A values map over a values map** is one map, the exit's keys winning. The shown target's
|
|
88
|
+
* `transition` and `transitionEnd` are its arrival's, left out; the exit's are kept.
|
|
89
|
+
* - **A target its binding's controls drive:** the exit as it is.
|
|
90
|
+
* - **A name and a values map,** either way round, can't be laid over each other without resolving the
|
|
91
|
+
* name: none, and the binding leaves by the exit alone.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* pipe("faded", VariantTarget.exitOver("shown")) // Option.some(["shown", "faded"])
|
|
95
|
+
*/
|
|
96
|
+
// `dual`, the exit first, the top layer (pipeable.md's pure helpers). Once a leave, per ward: statements.
|
|
97
|
+
export const exitOver: {
|
|
98
|
+
(shown: Shown): (self: Leave) => Option.Option<Leave>
|
|
99
|
+
(self: Leave, shown: Shown): Option.Option<Leave>
|
|
100
|
+
} = dual(2, (self: Leave, shown: Shown): Option.Option<Leave> => {
|
|
101
|
+
if (AnimationControls.isAnimationControls(shown)) return Option.some(self)
|
|
102
|
+
if (isLabels(shown)) {
|
|
103
|
+
if (isLabels(self)) return Option.some(Arr.appendAll(Arr.ensure(shown), Arr.ensure(self)))
|
|
104
|
+
return Option.none()
|
|
105
|
+
}
|
|
106
|
+
if (isLabels(self)) return Option.none()
|
|
107
|
+
const arrival = Rec.remove(Rec.remove(shown as Readonly<Record<string, unknown>>, "transition"), "transitionEnd")
|
|
108
|
+
return Option.some({ ...arrival, ...self } as Config.WardicVariant)
|
|
109
|
+
})
|
|
110
|
+
|
|
70
111
|
/** An entry's names, in order (#297): one for a name, a list's own, none for a values map or nothing. */
|
|
71
112
|
export const labelsOf = (entry: unknown): ReadonlyArray<string> => {
|
|
72
113
|
if (Predicate.isString(entry)) return [entry]
|
|
@@ -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
|
}
|