@wardic/solid 3.0.0-next.0 → 3.0.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/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 +236 -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 +75 -18
- 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 +236 -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 +75 -18
- 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 +268 -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 +4 -3
- 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 +5 -3
- package/dist/solid/hooks/ward.d.ts.map +1 -1
- package/dist/solid/hooks/ward.js +85 -20
- 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 +553 -0
- package/skills/wardic-migrate/SKILL.md +252 -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 +112 -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 +280 -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 +6 -4
- package/src/hooks/reorder-elements.tsx +6 -4
- package/src/hooks/rune.ts +4 -3
- package/src/hooks/ward.ts +90 -21
- 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/element.tsx
CHANGED
|
@@ -29,6 +29,7 @@ import { identity } from "effect/Function"
|
|
|
29
29
|
import * as UndefinedOr from "effect/UndefinedOr"
|
|
30
30
|
import { type ComponentProps, dynamic, isServer, type JSX, type ValidComponent } from "@solidjs/web"
|
|
31
31
|
import { $PROXY, children, type Component, createEffect, createMemo, createRoot, DEV, omit, runWithOwner, untrack } from "solid-js"
|
|
32
|
+
import { misuse } from "./diagnostics.ts"
|
|
32
33
|
import { unforwardedRefFix, unforwardedRefLine } from "./messages.ts"
|
|
33
34
|
import { MOTION_PROPS_V2 as MOTION_PROPS, type WardicMotionPropsV2 as WardicMotionProps } from "./motion-props.ts"
|
|
34
35
|
import * as VariantTree from "@wardic/core/unstable/VariantTree"
|
|
@@ -215,17 +216,18 @@ export const besideOf = (name: string, props: object, share: WardShare, keys: Re
|
|
|
215
216
|
if (beside.length === 0) return beside
|
|
216
217
|
const twice = setKeysOf(share.config, beside)
|
|
217
218
|
if (twice.length > 0) {
|
|
218
|
-
throw
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
throw misuse(
|
|
220
|
+
"WARDIC_WARDREF_CONFLICT",
|
|
221
|
+
`${name}: ${listOf(twice)} set both in the ward given to wardRef and on the element. ` + "Set each key in one place: in ward({ … }), or on the element.",
|
|
221
222
|
)
|
|
222
223
|
}
|
|
223
224
|
if (share.carries) {
|
|
224
225
|
const carried = Arr.filter(beside, (key) => NODE_KEYS.has(key))
|
|
225
226
|
if (carried.length > 0) {
|
|
226
|
-
throw
|
|
227
|
+
throw misuse(
|
|
228
|
+
"WARDIC_WARDREF_CONFLICT",
|
|
227
229
|
`${name}: the ward given to wardRef carries its variants (\`variants\` or \`inherit\` in its ward({ … })), so ${listOf(carried)} ` +
|
|
228
|
-
"go there too: its variant node, made where the ward is made, reads them
|
|
230
|
+
"go there too: its variant node, made where the ward is made, reads them. Or leave the variants to the element: " +
|
|
229
231
|
"a ward with neither only listens, and its element's props set its motion.",
|
|
230
232
|
)
|
|
231
233
|
}
|
|
@@ -261,8 +263,9 @@ const checkParent = (name: string, share: WardShare): void => {
|
|
|
261
263
|
const here = useVariantContext()
|
|
262
264
|
if (Bool.or(here === share.parent, Predicate.isUndefined(here))) return
|
|
263
265
|
if (Bool.not(VariantTree.isVariantChild(share.setup))) return
|
|
264
|
-
throw
|
|
265
|
-
|
|
266
|
+
throw misuse(
|
|
267
|
+
"WARDIC_WARDREF_CONFLICT",
|
|
268
|
+
`${name}: the ward in wardRef was made outside its element's variant parent, so it wouldn't inherit from it. ` +
|
|
266
269
|
"Make it with ward(config, { parent }), naming the ward whose element it renders in, or give it `inherit: false` to stand alone.",
|
|
267
270
|
)
|
|
268
271
|
}
|
|
@@ -483,7 +486,7 @@ const tagComponent = (tag: string, routing: string | undefined, forward: boolean
|
|
|
483
486
|
const wardRef = untrack(() => own.wardRef)
|
|
484
487
|
const given = shareOf(wardRef)
|
|
485
488
|
if (Predicate.isNotUndefined(given)) {
|
|
486
|
-
if (madeByTheHooks(given)) throw
|
|
489
|
+
if (madeByTheHooks(given)) throw misuse("WARDIC_HOOK_WARD_IN_WARDREF", hookWardGiven(name))
|
|
487
490
|
const { ward: driving, setup } = drivenWard(name, own, given, { ...kind, tag: routing }, MOTION_PROPS)
|
|
488
491
|
return withProvider(driving, setup, () => <Element {...rest} {...driving.with({ style: own.style })} ref={refsOf(own, [driving])} />)
|
|
489
492
|
}
|
|
@@ -533,7 +536,7 @@ const wrapComponent = (Wrapped: Component<Record<string, unknown>>, routing: str
|
|
|
533
536
|
(elements) => {
|
|
534
537
|
if (Arr.isArrayEmpty(elements)) return
|
|
535
538
|
if (Arr.some(elements, (inside) => Predicate.isNotUndefined(reached) && inside.contains(reached))) return
|
|
536
|
-
throw
|
|
539
|
+
throw misuse("WARDIC_REF_NOT_FORWARDED", unforwardedRefMessage(name))
|
|
537
540
|
},
|
|
538
541
|
CLIENT_ONLY,
|
|
539
542
|
)
|
|
@@ -543,7 +546,7 @@ const wrapComponent = (Wrapped: Component<Record<string, unknown>>, routing: str
|
|
|
543
546
|
const wardRef = untrack(() => own.wardRef)
|
|
544
547
|
const given = shareOf(wardRef)
|
|
545
548
|
if (Predicate.isNotUndefined(given)) {
|
|
546
|
-
if (madeByTheHooks(given)) throw
|
|
549
|
+
if (madeByTheHooks(given)) throw misuse("WARDIC_HOOK_WARD_IN_WARDREF", hookWardGiven(name))
|
|
547
550
|
const { ward: driving, setup } = drivenWard(name, own, given, { ...kind, defaultsOnElement: true, tag: routing }, MOTION_PROPS)
|
|
548
551
|
return withProvider(driving, setup, () => checked(() => <Element {...rest} {...driving.with({ style: own.style })} ref={refsOf(own, [driving, seen])} />))
|
|
549
552
|
}
|
package/src/frame-effect.tsx
CHANGED
|
@@ -53,7 +53,7 @@ const slotOf = (runtime: WardicRuntime): Slot => {
|
|
|
53
53
|
const known = SLOTS.get(runtime)
|
|
54
54
|
if (Predicate.isNotUndefined(known)) return known
|
|
55
55
|
const scope = OwnerScope.open(runtime)
|
|
56
|
-
const report = (defect: unknown): void => void runtime.runFork(Report.
|
|
56
|
+
const report = (defect: unknown): void => void runtime.runFork(Report.callbackFailed("wardic.createFrameEffect: an apply failed", Cause.die(defect)))
|
|
57
57
|
const effects = runtime.runSync(FrameEffects.onFrameLoop(report).pipe(Scope.provide(scope)))
|
|
58
58
|
const made: Slot = { effects, scope, live: 0 }
|
|
59
59
|
SLOTS.set(runtime, made)
|
package/src/gesture-callbacks.ts
CHANGED
|
@@ -38,7 +38,7 @@ export const gestureCallbacksOf = (runtime: WardicRuntime, id: string, config: (
|
|
|
38
38
|
config,
|
|
39
39
|
invoke: (handler, args) => (handler as Called)(...args),
|
|
40
40
|
report: (name, defect) => {
|
|
41
|
-
runtime.runFork(Report.
|
|
41
|
+
runtime.runFork(Report.callbackFailed(`wardic.gesture: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })))
|
|
42
42
|
},
|
|
43
43
|
// `onDragEnd` and `onPanEnd` told how each ended (#1042).
|
|
44
44
|
tellsEndedBy: true,
|
package/src/hooks/drag.ts
CHANGED
|
@@ -25,6 +25,7 @@ import * as InputSource from "@wardic/core/InputSource"
|
|
|
25
25
|
import type * as Point from "@wardic/core/Point"
|
|
26
26
|
import type * as ProjectionSystem from "@wardic/dom/ProjectionSystem"
|
|
27
27
|
import * as Style from "@wardic/dom/Style"
|
|
28
|
+
import { report } from "../diagnostics.ts"
|
|
28
29
|
import type { WardicServices } from "../runtime.ts"
|
|
29
30
|
import * as Bool from "effect/Boolean"
|
|
30
31
|
import * as Effect from "effect/Effect"
|
|
@@ -550,7 +551,7 @@ export const createGrip = (row: DraggingWard): RuneConfig => {
|
|
|
550
551
|
|
|
551
552
|
/** A grip of a ward that doesn't drag: development says so, and it drives nothing (Q14, Q20). */
|
|
552
553
|
const notDragging = (): RuneConfig => {
|
|
553
|
-
if (DEV)
|
|
554
|
+
if (DEV) report("WARDIC_GRIP_ROW_DOESNT_DRAG", NOT_DRAGGING)
|
|
554
555
|
return NO_GRIP
|
|
555
556
|
}
|
|
556
557
|
|
|
@@ -593,7 +594,7 @@ export const GRIP_OUTSIDE = "createGrip(row): this grip isn't inside its row's e
|
|
|
593
594
|
const warnIfOutside = (site: Site, subject: HTMLElement): void => {
|
|
594
595
|
if (DEV) {
|
|
595
596
|
UndefinedOr.map(site.at, (at) => {
|
|
596
|
-
if (Bool.not(at.element.contains(subject)))
|
|
597
|
+
if (Bool.not(at.element.contains(subject))) report("WARDIC_GRIP_OUTSIDE_ROW", GRIP_OUTSIDE)
|
|
597
598
|
})
|
|
598
599
|
}
|
|
599
600
|
}
|
|
@@ -656,7 +657,7 @@ export const NO_DRAG = "createWard(...runes): a rune listens to `ward.drag`, but
|
|
|
656
657
|
export const warnIfUndragged = (site: Site, drags: boolean): void => {
|
|
657
658
|
if (Bool.or(warned, Bool.or(drags, Bool.not(site.listened)))) return
|
|
658
659
|
warned = true
|
|
659
|
-
|
|
660
|
+
report("WARDIC_DRAG_NOT_GIVEN", NO_DRAG)
|
|
660
661
|
}
|
|
661
662
|
|
|
662
663
|
/** A `drag` value as a drag's axis: `"x"`, `"y"`, or whether it drags freely. */
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
* `within(build)` builds what it's given under the scope, and keeps a child that leaves on the page
|
|
14
14
|
* until the exits of the wards inside it have landed. Each ward made there, at any depth, registers
|
|
15
15
|
* its exit with the scope as it mounts; once its child leaves, the scope runs that exit itself, from
|
|
16
|
-
* what the ward registered, so it runs after Solid has ended the child
|
|
17
|
-
*
|
|
18
|
-
* `
|
|
16
|
+
* what the ward registered, so it runs after Solid has ended the child. The scope hears each leave, by
|
|
17
|
+
* `exiting()` and its `"exitStart"` and `"exitComplete"`, and so does each ward inside, by a watch of its
|
|
18
|
+
* own (`watchedUnder`, `ward.ts`): its `next` and `each`, and its `hold()`. An effect the child made over a
|
|
19
|
+
* ward's `when` has ended with the child, before the leave is told.
|
|
19
20
|
*
|
|
20
21
|
* The value is a presence handle, so it can be a `<Presence>`'s own, or another's `ref`. It's
|
|
21
22
|
* today's presence controller as a hook: `within` is `<AnimatePresence>` round what it builds, its
|
|
@@ -29,6 +30,7 @@ import type { PopAnchors, PresenceMode } from "@wardic/dom/unstable/PresenceCont
|
|
|
29
30
|
import * as Predicate from "effect/Predicate"
|
|
30
31
|
import { DEV, getOwner, onCleanup } from "solid-js"
|
|
31
32
|
import { AnimatePresence } from "../presence.tsx"
|
|
33
|
+
import { report } from "../diagnostics.ts"
|
|
32
34
|
import { createPresence as makeRef, ownPresenceHandle, type Presence as Handle } from "../presence-handle.ts"
|
|
33
35
|
import type { PopCorner } from "./rune.ts"
|
|
34
36
|
import { popAnchorsOf } from "./ward.ts"
|
|
@@ -125,7 +127,7 @@ export const createPresenceScope = (options: PresenceScopeOptions = {}): Presenc
|
|
|
125
127
|
if (Predicate.isNotNull(getOwner())) onCleanup(() => void (live -= 1))
|
|
126
128
|
if (!DEV || warned || live < 2) return
|
|
127
129
|
warned = true
|
|
128
|
-
|
|
130
|
+
report("WARDIC_PRESENCE_SCOPE_REUSED", ONE_BOUNDARY)
|
|
129
131
|
}
|
|
130
132
|
// Read where the boundary reads each: `options` may be a component's props.
|
|
131
133
|
const within = (build: () => JSX.Element): JSX.Element => {
|
|
@@ -29,6 +29,7 @@ import { createGrip, type DraggingWard } from "./drag.ts"
|
|
|
29
29
|
import type { HookWardOf } from "./ward.ts"
|
|
30
30
|
import type { ReorderList, ReorderSource } from "./reorder.ts"
|
|
31
31
|
import type { Rune, RuneConfig } from "./rune.ts"
|
|
32
|
+
import { misuse } from "../diagnostics.ts"
|
|
32
33
|
|
|
33
34
|
/** What makes a group's list: `createReorder`, as an app has it. */
|
|
34
35
|
export type ListMaker = (source: ReorderSource<unknown>) => ListOf
|
|
@@ -255,7 +256,7 @@ export const reorderElementsOf = (elements: Readonly<Record<string, Component<Re
|
|
|
255
256
|
}
|
|
256
257
|
const list = listOf(source)
|
|
257
258
|
const groupRef = untrack(() => own.groupRef)
|
|
258
|
-
if (isGroup(groupRef)) throw
|
|
259
|
+
if (isGroup(groupRef)) throw misuse("WARDIC_REORDER_REF_NOT_FUNCTION", GIVEN_GROUP)
|
|
259
260
|
if (Predicate.isFunction(groupRef)) groupRef(list)
|
|
260
261
|
const Element = UndefinedOr.getOrThrow(elements[UndefinedOr.match(untrack(() => own.as), { onUndefined: () => "ul", onDefined: identity })])
|
|
261
262
|
const rest = omit(props, ...GROUP_KEPT)
|
|
@@ -268,14 +269,15 @@ export const reorderElementsOf = (elements: Readonly<Record<string, Component<Re
|
|
|
268
269
|
|
|
269
270
|
const Item = (props: Record<string, unknown>): JSX.Element => {
|
|
270
271
|
const list = useContext(ListContext)
|
|
271
|
-
if (Predicate.isNull(list))
|
|
272
|
+
if (Predicate.isNull(list))
|
|
273
|
+
throw misuse("WARDIC_REORDER_ITEM_OUTSIDE_GROUP", "Reorder.Item must be a child of Reorder.Group: render each item inside its group's children.")
|
|
272
274
|
const own = props as unknown as ItemProps
|
|
273
275
|
const Element = plainOf(UndefinedOr.match(untrack(() => own.as), { onUndefined: () => "li", onDefined: identity }))
|
|
274
276
|
// Its row a plain ward of its group's behaviour and its own props (probe: behaviour-runes, Q12): what
|
|
275
277
|
// an app writes, `createWard(list.item(value), ...)`.
|
|
276
278
|
const row = untrack(() => createWard(list.item(own.value), itemRuneOf(props) as RuneConfig)) as object
|
|
277
279
|
const wardRef = untrack(() => own.wardRef)
|
|
278
|
-
if (isWard(wardRef)) throw
|
|
280
|
+
if (isWard(wardRef)) throw misuse("WARDIC_REORDER_REF_NOT_FUNCTION", GIVEN_WARD)
|
|
279
281
|
if (Predicate.isFunction(wardRef)) wardRef(row)
|
|
280
282
|
// Its spread's props, as a spread of it reads them: called with nothing, as Solid's `merge` calls a
|
|
281
283
|
// ward it spreads (#495), for the keyboard attributes and the drag's style a row's binding gives
|
|
@@ -306,7 +308,7 @@ export const reorderElementsOf = (elements: Readonly<Record<string, Component<Re
|
|
|
306
308
|
*/
|
|
307
309
|
const Grip = (props: Record<string, unknown>): JSX.Element => {
|
|
308
310
|
const row = useContext(RowContext)
|
|
309
|
-
if (Predicate.isNull(row)) throw
|
|
311
|
+
if (Predicate.isNull(row)) throw misuse("WARDIC_REORDER_ITEM_OUTSIDE_GROUP", "Reorder.Grip must be inside a Reorder.Item: render it among its item's children.")
|
|
310
312
|
const own = props as unknown as { readonly as?: string | undefined; readonly ref?: unknown }
|
|
311
313
|
const tag = UndefinedOr.match(untrack(() => own.as), { onUndefined: () => "button", onDefined: identity })
|
|
312
314
|
const Element = plainOf(tag)
|
package/src/hooks/rune.ts
CHANGED
|
@@ -45,6 +45,7 @@ import * as UndefinedOr from "effect/UndefinedOr"
|
|
|
45
45
|
import { $PROXY, DEV, untrack } from "solid-js"
|
|
46
46
|
import type { Accessor } from "solid-js"
|
|
47
47
|
import type { AnyWard, WardConfig } from "../ward.tsx"
|
|
48
|
+
import { misuse } from "../diagnostics.ts"
|
|
48
49
|
import type { HookWard } from "./ward.ts"
|
|
49
50
|
import type { Drags, WardDrag } from "./drag.ts"
|
|
50
51
|
|
|
@@ -442,10 +443,10 @@ const isBareFunction = (rune: object): boolean => {
|
|
|
442
443
|
* or where the API would hide one of its keys.
|
|
443
444
|
*/
|
|
444
445
|
const refusedInDevelopment = (rune: object, api: object): void => {
|
|
445
|
-
if (RUNE_API in rune) throw
|
|
446
|
-
if (isBareFunction(rune)) throw
|
|
446
|
+
if (RUNE_API in rune) throw misuse("WARDIC_RUNE_WITH_INVALID", SECOND_API)
|
|
447
|
+
if (isBareFunction(rune)) throw misuse("WARDIC_RUNE_WITH_INVALID", BARE_FUNCTION)
|
|
447
448
|
const clash = Arr.findFirst(Object.keys(api), isOwnKeyOf(rune))
|
|
448
|
-
if (Option.isSome(clash)) throw
|
|
449
|
+
if (Option.isSome(clash)) throw misuse("WARDIC_RUNE_WITH_INVALID", clashOf(clash.value))
|
|
449
450
|
}
|
|
450
451
|
|
|
451
452
|
/**
|
package/src/hooks/ward.ts
CHANGED
|
@@ -50,6 +50,8 @@ 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 * as VariantTarget from "@wardic/core/unstable/VariantTarget"
|
|
54
|
+
import { misuse, report } from "../diagnostics.ts"
|
|
53
55
|
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
56
|
import { asking, type AutoFeature, colorsOnceLoaded, featureOfEvent, wantedBy } from "./auto.ts"
|
|
55
57
|
import { bothHandles, dragAccessorOf, dragAxisAt, dragAxisOf, givesDrag, isDragOnly, keysRuneOf, liftedOf, makeSite, raiseOf, runeWardOf, siteIfAny, siteInternalsOf, siteKeptFor, warnIfUndragged, withDrag, withGrips } from "./drag.ts"
|
|
@@ -72,7 +74,7 @@ export type ExitEvent = PresenceEvent
|
|
|
72
74
|
export type HookWard = Ward & WardReads & {
|
|
73
75
|
/**
|
|
74
76
|
* Whether it's leaving: true from the moment it starts to leave until it has gone, or is shown
|
|
75
|
-
* again. Always false for a ward no hook shows.
|
|
77
|
+
* again. Always false for a ward that never leaves: one no hook shows and no presence takes away.
|
|
76
78
|
*/
|
|
77
79
|
readonly exiting: Accessor<boolean>
|
|
78
80
|
/**
|
|
@@ -89,8 +91,10 @@ export type HookWard = Ward & WardReads & {
|
|
|
89
91
|
* createEffect(frame.when("exitComplete"), () => trigger.focus())
|
|
90
92
|
* ```
|
|
91
93
|
*
|
|
92
|
-
* A ward made inside what a presence component takes away
|
|
93
|
-
*
|
|
94
|
+
* A ward made inside what a presence component takes away hears its own too, after its component
|
|
95
|
+
* has ended (PW1): Solid ends it as its exit starts, before the leave is told. So listen with `next`
|
|
96
|
+
* or `each`, which outlive the component; an effect over `when`, made there, has ended with it (PW4),
|
|
97
|
+
* which development reports, `WARDIC_EXIT_WHEN_UNDER_PRESENCE`. Not told on a Stage in this probe.
|
|
94
98
|
*/
|
|
95
99
|
next<E extends ExitEvent>(name: E): Promise<ExitEvents[E]>
|
|
96
100
|
/** Every `name` of its exits from the call on, for a `for await`. */
|
|
@@ -614,6 +618,30 @@ export const showing =
|
|
|
614
618
|
state.counted(finish)
|
|
615
619
|
}
|
|
616
620
|
state.released = finish
|
|
621
|
+
// The change of `show` a mixed exit was last reported in: once a leave.
|
|
622
|
+
let mixedIn = -1
|
|
623
|
+
/**
|
|
624
|
+
* Where it goes as it leaves: its exit laid over the target it was shown at (the hook-exit grill), so a
|
|
625
|
+
* key its exit doesn't name keeps that target, as under `<Presence>` and in Motion. A name under a
|
|
626
|
+
* values map, or the other way round, can't be laid: it leaves by the exit alone, as it did, and in
|
|
627
|
+
* development its own exit is reported, once a leave. One leaving by its `initial` isn't.
|
|
628
|
+
*/
|
|
629
|
+
const laidOver = (shown: unknown, leaving: unknown): unknown => {
|
|
630
|
+
// With no `animate`, a key the exit doesn't name was never moved from its base: the exit as it is.
|
|
631
|
+
if (Predicate.isUndefined(shown)) return leaving
|
|
632
|
+
return Option.getOrElse(VariantTarget.exitOver(leaving as VariantTarget.Leave, shown as VariantTarget.Shown), () => {
|
|
633
|
+
if (DEV) warnsOfMixedExit()
|
|
634
|
+
return leaving
|
|
635
|
+
})
|
|
636
|
+
}
|
|
637
|
+
/** In development, a mixed exit of its own, once a leave: one leaving by its `initial` isn't reported. */
|
|
638
|
+
const warnsOfMixedExit = (): void => {
|
|
639
|
+
const now = turnsNow()
|
|
640
|
+
if (mixedIn === now) return
|
|
641
|
+
mixedIn = now
|
|
642
|
+
if (Predicate.isUndefined(runes.value("exit"))) return
|
|
643
|
+
report("WARDIC_EXIT_FORM_MIXED", EXIT_FORM_MIXED)
|
|
644
|
+
}
|
|
617
645
|
return {
|
|
618
646
|
animate: (shown) => {
|
|
619
647
|
if (show()) return shown
|
|
@@ -621,8 +649,8 @@ export const showing =
|
|
|
621
649
|
if (Predicate.isUndefined(leaving)) return shown
|
|
622
650
|
// A ward that ends as it goes has nowhere to rest: it stays where it left to, and whether
|
|
623
651
|
// it's mounted isn't read for it, so nothing is worked out again as it goes.
|
|
624
|
-
if (state.ends()) return leaving
|
|
625
|
-
if (mounted()) return leaving
|
|
652
|
+
if (state.ends()) return laidOver(shown, leaving)
|
|
653
|
+
if (mounted()) return laidOver(shown, leaving)
|
|
626
654
|
return rest(leaving)
|
|
627
655
|
},
|
|
628
656
|
style: (style) => {
|
|
@@ -744,24 +772,33 @@ export const HOOK_TOLD: Pick<WardInternals, "handed" | "madeUnder" | "styled" |
|
|
|
744
772
|
* an element by the time its owner has settled. Asked of the `ref` itself, not of the element it set: a
|
|
745
773
|
* hydrated page's writes, that one's among them, land after its owners settle (DW4). Today's
|
|
746
774
|
* `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
|
-
*
|
|
775
|
+
* say nothing. One whose `style` no element has read yet, a closed dialog's, isn't warned of. And the other
|
|
776
|
+
* way round (step 2 of the skill grill's order, Q20): its `ref` handed an element whose props read none of its
|
|
777
|
+
* `style`, a `style` beside the spread having replaced it. Nothing on a server, where no `ref` is called.
|
|
749
778
|
*/
|
|
750
|
-
const
|
|
779
|
+
const warnsOfItsSpread = (ward: Ward): void => {
|
|
751
780
|
if (Predicate.isNull(getOwner())) return
|
|
752
781
|
onSettledClientOnly(() => {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
782
|
+
const read = STYLE_READ.has(ward)
|
|
783
|
+
const handed = HANDED.has(ward)
|
|
784
|
+
if (Bool.and(read, Bool.not(handed))) report("WARDIC_REF_NOT_CALLED", UNFORWARDED)
|
|
785
|
+
// Its `ref` called and its `style` read by nothing: a `style` beside the spread replaced it (step 2, Q20).
|
|
786
|
+
if (Bool.and(handed, Bool.not(read))) report("WARDIC_STYLE_BESIDE_SPREAD", STYLE_BESIDE)
|
|
756
787
|
})
|
|
757
788
|
}
|
|
758
789
|
|
|
759
|
-
/** `ward`, made, with the
|
|
790
|
+
/** `ward`, made, with the warnings above for it in development, in a browser: every hook ward's make path ends here. */
|
|
760
791
|
const checked = (ward: Ward): Ward => {
|
|
761
|
-
if (DEV && !isServer)
|
|
792
|
+
if (DEV && !isServer) warnsOfItsSpread(ward)
|
|
762
793
|
return ward
|
|
763
794
|
}
|
|
764
795
|
|
|
796
|
+
const EXIT_FORM_MIXED =
|
|
797
|
+
"createWard: the ward's `exit` and its `animate` are written in different forms, a variant name and a values map, so its exit can't be laid over its `animate`: a key the exit doesn't name falls back to its `initial` as it leaves, and its followers are handed no name. Write the exit as its `animate` is: a variant (`exit: \"gone\"`, with `gone` in its variants) under a name, or a values map under a values map."
|
|
798
|
+
|
|
799
|
+
const STYLE_BESIDE =
|
|
800
|
+
"createWard: the ward was handed an element that never read its `style`: a `style` beside its spread (`<div {...ward} style={…}>`), a component that doesn't pass `props.style` on, or the ward called with the element (`ward(el)`) and not spread. Give the style through the ward, `{...ward.with({ style })}`, or as its own `style`; give an element the app doesn't render, the page's root, with a rune's `subject` (`createWard({ subject: () => el })`)."
|
|
801
|
+
|
|
765
802
|
const UNFORWARDED =
|
|
766
803
|
"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
804
|
|
|
@@ -969,7 +1006,7 @@ const elementIn = (subject: unknown): WardElement | undefined => {
|
|
|
969
1006
|
*/
|
|
970
1007
|
const subjectElementOf = (subject: unknown): WardElement => {
|
|
971
1008
|
const el = elementIn(subject)
|
|
972
|
-
if (Predicate.isUndefined(el)) throw
|
|
1009
|
+
if (Predicate.isUndefined(el)) throw misuse("WARDIC_SUBJECT_NOT_ONE_ELEMENT", NOT_ONE_ELEMENT)
|
|
973
1010
|
return el
|
|
974
1011
|
}
|
|
975
1012
|
|
|
@@ -1527,15 +1564,30 @@ const listening = (member: "when" | "next" | "each", kept: Kept, ask: (name: Aut
|
|
|
1527
1564
|
const EXIT_NAMES: ReadonlySet<string> = new Set<string>(["exitStart", "exitComplete"])
|
|
1528
1565
|
|
|
1529
1566
|
/** `member` of `watched`'s exits, for one of their names. */
|
|
1530
|
-
const watchedExit = (member: "when" | "next" | "each", watched: Watched, event: PresenceEvent): unknown => {
|
|
1567
|
+
const watchedExit = (member: "when" | "next" | "each", kept: Kept, watched: Watched, event: PresenceEvent): unknown => {
|
|
1531
1568
|
if (member === "next") return watched.waiters.wait(event)
|
|
1532
1569
|
if (member === "each") return eachOf<PresenceEvents, PresenceEvent>(watched.waiters, event)
|
|
1570
|
+
if (DEV) warnsOfExitWhen(kept, event)
|
|
1533
1571
|
return whenOf<PresenceEvents, PresenceEvent>(watched.waiters, event)
|
|
1534
1572
|
}
|
|
1535
1573
|
|
|
1574
|
+
/**
|
|
1575
|
+
* In development, a warning for `when` of an exit asked of a ward made under a presence: an effect over it,
|
|
1576
|
+
* made in the component the presence takes away, is ended with that component, which Solid ends as the exit
|
|
1577
|
+
* starts, before the presence tells it (PW4). Its `next` and `each` outlive the component. Not for one a
|
|
1578
|
+
* presence of the hooks' has taken by then: its leave is that presence's, told while the component lives.
|
|
1579
|
+
*/
|
|
1580
|
+
const warnsOfExitWhen = (kept: Kept, event: PresenceEvent): void => {
|
|
1581
|
+
if (takenNow(kept)) return
|
|
1582
|
+
report("WARDIC_EXIT_WHEN_UNDER_PRESENCE", exitWhen(event))
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
const exitWhen = (event: PresenceEvent): string =>
|
|
1586
|
+
`createWard: \`when("${event}")\` was asked of a ward made under a \`<Presence>\`. Solid ends its component as its exit starts, before the leave is told, so an effect over it never runs. Listen with \`next("${event}")\` or \`each("${event}")\`, which outlive the component, and take \`hold()\` there.`
|
|
1587
|
+
|
|
1536
1588
|
/** `base`, its exits heard of `watched` where the ward was made under a presence. */
|
|
1537
|
-
const watchedListening = (member: "when" | "next" | "each", watched: Watched, base: Listening): Listening => (event) => {
|
|
1538
|
-
if (EXIT_NAMES.has(event)) return watchedExit(member, watched, event as PresenceEvent)
|
|
1589
|
+
const watchedListening = (member: "when" | "next" | "each", kept: Kept, watched: Watched, base: Listening): Listening => (event) => {
|
|
1590
|
+
if (EXIT_NAMES.has(event)) return watchedExit(member, kept, watched, event as PresenceEvent)
|
|
1539
1591
|
return base(event)
|
|
1540
1592
|
}
|
|
1541
1593
|
|
|
@@ -1557,7 +1609,7 @@ const sharedListening = (member: "when" | "next" | "each"): PropertyDescriptor =
|
|
|
1557
1609
|
if (Predicate.isNotUndefined(ask) && Predicate.isNotUndefined(instance)) base = listening(member, kept, ask, instance, shared)
|
|
1558
1610
|
const watched = kept.watched
|
|
1559
1611
|
let own = base
|
|
1560
|
-
if (Predicate.isNotUndefined(watched)) own = watchedListening(member, watched, base)
|
|
1612
|
+
if (Predicate.isNotUndefined(watched)) own = watchedListening(member, kept, watched, base)
|
|
1561
1613
|
if (own === shared) return shared
|
|
1562
1614
|
kept[member] = own
|
|
1563
1615
|
return own
|
|
@@ -1764,7 +1816,7 @@ export interface Takeable {
|
|
|
1764
1816
|
export const takenOf = (ward: object): Taken | undefined => {
|
|
1765
1817
|
const take = keptElse(ward, (kept) => kept.take, () => (ward as { readonly [TAKE]?: Takeable })[TAKE])
|
|
1766
1818
|
if (Predicate.isUndefined(take)) return undefined
|
|
1767
|
-
if (take.taken) throw
|
|
1819
|
+
if (take.taken) throw misuse("WARDIC_PRESENCE_WARD_TAKEN", TAKEN_TWICE)
|
|
1768
1820
|
take.taken = true
|
|
1769
1821
|
return takenBy(take)
|
|
1770
1822
|
}
|
|
@@ -2207,6 +2259,7 @@ const throughOf = (begun: Begun, runes: ReadonlyArray<Rune>, anyFunction: boolea
|
|
|
2207
2259
|
const landingFailed =
|
|
2208
2260
|
(owner: Owner | null) =>
|
|
2209
2261
|
(error: unknown): void => {
|
|
2262
|
+
// Uncoded: a leg that failed is Wardic's own failure; an app's function that made it fail is coded where it ran.
|
|
2210
2263
|
runWithOwner(owner, () => void useWardicRuntime().runFork(Report.failure("wardic.createWard: a landing failed", Cause.die(error))))
|
|
2211
2264
|
}
|
|
2212
2265
|
|
|
@@ -2275,7 +2328,7 @@ const warnIfFollowingNothing = (leader: object | undefined): void => {
|
|
|
2275
2328
|
if (!NAMING_NOTHING.has(leader)) return
|
|
2276
2329
|
if (WARNED_OF.has(leader)) return
|
|
2277
2330
|
WARNED_OF.add(leader)
|
|
2278
|
-
|
|
2331
|
+
report("WARDIC_FOLLOW_LEADER_UNNAMED", FOLLOWS_NOTHING)
|
|
2279
2332
|
}
|
|
2280
2333
|
|
|
2281
2334
|
/**
|
|
@@ -2303,7 +2356,23 @@ const groupedIn = (internal: WardInternals, group: WardInternals["layoutGroup"])
|
|
|
2303
2356
|
}
|
|
2304
2357
|
|
|
2305
2358
|
/** `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))
|
|
2359
|
+
const wardOf = (begin: () => Begun, open: boolean): WardMaker => ownerChecked(warnsFollowingNothing(wardMakerOf(begin, open)))
|
|
2360
|
+
|
|
2361
|
+
/**
|
|
2362
|
+
* `make`, refusing in development a ward made with no owner, outside a component or a root (step 2 of the
|
|
2363
|
+
* skill grill's order, Q20): it fails then anyway, on Solid's own error, which names neither the call nor
|
|
2364
|
+
* the fix. In a production build, `make` as it is.
|
|
2365
|
+
*/
|
|
2366
|
+
const ownerChecked = (make: WardMaker): WardMaker => {
|
|
2367
|
+
if (!DEV) return make
|
|
2368
|
+
return ((...runes: ReadonlyArray<Rune>) => {
|
|
2369
|
+
if (Predicate.isNull(getOwner())) throw misuse("WARDIC_WARD_WITHOUT_OWNER", WITHOUT_OWNER)
|
|
2370
|
+
return (make as (...given: ReadonlyArray<Rune>) => HookWard)(...runes)
|
|
2371
|
+
}) as WardMaker
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
const WITHOUT_OWNER =
|
|
2375
|
+
"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
2376
|
|
|
2308
2377
|
/** {@link wardOf}'s maker, without development's word on a ward following one that names nothing. */
|
|
2309
2378
|
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
|