@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/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.2"
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* `WardicProvider` (one Effect runtime + `AtomRegistry` per ADR-0006), the
|
package/src/ward.tsx
CHANGED
|
@@ -94,6 +94,7 @@ import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
|
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures"
|
|
97
|
+
import { misuse, report } from "./diagnostics.ts"
|
|
97
98
|
import { inViewOptionsOf } from "./gesture-callbacks.ts"
|
|
98
99
|
import type { WardicRuntime, WardicServices } from "./runtime.ts"
|
|
99
100
|
import * as Keys from "@wardic/dom/unstable/features/Keys"
|
|
@@ -162,6 +163,10 @@ const missingMessage = (feature: string, what: string): string =>
|
|
|
162
163
|
`which this element's WardicProvider doesn't have. Add it: \`import { ${feature} } from "${ENTRY}"\`, then \`<WardicProvider features={[${feature}]}>\`, or give it to \`makeWard({ features })\`.`,
|
|
163
164
|
)
|
|
164
165
|
|
|
166
|
+
/** Development's word on a missing Feature, once a provider, as its coded diagnostic (solid-next). */
|
|
167
|
+
const warnMissing = (registry: Feature.FeatureRegistry, feature: string, what: string): void =>
|
|
168
|
+
registry.warnOnce(feature, missingMessage(feature, what), "WARDIC_FEATURE_MISSING")
|
|
169
|
+
|
|
165
170
|
/** A ward's config values: the element's motion, and its `style`. */
|
|
166
171
|
export interface WardConfigValues extends Omit<DomWardConfig.WardConfig, SolidOneCallback> {
|
|
167
172
|
/**
|
|
@@ -265,7 +270,7 @@ export const wardConfigView = (config: WardConfig): WardConfigValues => WARD_VIE
|
|
|
265
270
|
|
|
266
271
|
/** A config given whole as an accessor, which the Solid 2 binding no longer reads (#259). */
|
|
267
272
|
const WHOLE_ACCESSOR =
|
|
268
|
-
"ward(config) takes its config as an object, read per key
|
|
273
|
+
"ward(config) takes its config as an object, read per key: make a key reactive with an accessor " +
|
|
269
274
|
"(`ward({ animate: () => ({ x: x() }) })`), a getter, a store or a component's props, not the whole config " +
|
|
270
275
|
"(`ward(() => ({ … }))`)."
|
|
271
276
|
|
|
@@ -957,7 +962,7 @@ const warnUnreadColors = (registry: Feature.FeatureRegistry, features: Feature.F
|
|
|
957
962
|
},
|
|
958
963
|
(unread) => {
|
|
959
964
|
if (Predicate.isUndefined(unread)) return
|
|
960
|
-
registry
|
|
965
|
+
warnMissing(registry, "colors", `The colour \`${unread}\``)
|
|
961
966
|
},
|
|
962
967
|
CLIENT_ONLY,
|
|
963
968
|
)
|
|
@@ -972,7 +977,7 @@ const carriesFor = (internal: WardInternals, config: WardConfigValues): boolean
|
|
|
972
977
|
/** A child made with `{ parent }` naming a Listening ward (#398's Q10). */
|
|
973
978
|
const LISTENING_PARENT =
|
|
974
979
|
"ward(config, { parent }): the parent given carries no variants (no `variants` or `inherit` in its ward({ … })): it only listens, " +
|
|
975
|
-
"and its element's props hold its variants, so a child can't join it by `{ parent }
|
|
980
|
+
"and its element's props hold its variants, so a child can't join it by `{ parent }`. Render the child inside that " +
|
|
976
981
|
"ward's element, where it joins through the tree, or put the variants in the parent's ward({ … })."
|
|
977
982
|
|
|
978
983
|
/** The **Layout group** a ward made here with `internal` is in: its maker's choice, else the one around it. */
|
|
@@ -1007,7 +1012,7 @@ const variantParentOf = (internal: WardInternals): VariantTree.WardicVariantCont
|
|
|
1007
1012
|
}
|
|
1008
1013
|
const parent = shareOf(internal.parent)
|
|
1009
1014
|
if (Predicate.isNotUndefined(parent)) {
|
|
1010
|
-
if (Bool.not(parent.carries)) throw
|
|
1015
|
+
if (Bool.not(parent.carries)) throw misuse("WARDIC_PARENT_WITHOUT_VARIANTS", LISTENING_PARENT)
|
|
1011
1016
|
return parent.provided
|
|
1012
1017
|
}
|
|
1013
1018
|
return useVariantContext()
|
|
@@ -1150,7 +1155,7 @@ const variantChildBy = <C extends WardConfigValues>(internal: WardInternals, con
|
|
|
1150
1155
|
export const configAtSetup = (setup: { readonly config: WardConfigValues; readonly pending: ReadonlyArray<string> }): WardConfigValues => {
|
|
1151
1156
|
if (setup.pending.length === 0) return setup.config
|
|
1152
1157
|
const fixed = Arr.findFirst(setup.pending, (key) => Bool.not(LOADS_AS_IT_GOES.has(key)))
|
|
1153
|
-
if (Option.isSome(fixed)) throw
|
|
1158
|
+
if (Option.isSome(fixed)) throw misuse("WARDIC_KEY_LOADING_AT_SETUP", loadingAtSetup(fixed.value))
|
|
1154
1159
|
const config = setup.config
|
|
1155
1160
|
if (Bool.and(Arr.contains(setup.pending, "animate"), Predicate.isNotUndefined(config.variants))) return { ...config, animate: LOADING_NAMES as NonNullable<WardConfigValues["animate"]> }
|
|
1156
1161
|
return config
|
|
@@ -1175,7 +1180,7 @@ const layoutArrivedIn = (arrive: ((projection: ProjectionSystem.Shape) => void)
|
|
|
1175
1180
|
|
|
1176
1181
|
|
|
1177
1182
|
export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
1178
|
-
if (Predicate.isFunction(config)) throw
|
|
1183
|
+
if (Predicate.isFunction(config)) throw misuse("WARDIC_CONFIG_AS_ACCESSOR", WHOLE_ACCESSOR)
|
|
1179
1184
|
const runtime = useWardicRuntime()
|
|
1180
1185
|
// Its Features (#511, ADR-0067), a Complete element's every one: what they register, a server
|
|
1181
1186
|
// render's elements read too (the `colors` Feature's spaces).
|
|
@@ -1249,7 +1254,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1249
1254
|
// The values it starts from, read once (ADR-0003): its `initial`, or the one it inherits, or its
|
|
1250
1255
|
// `animate` with `initial={false}` (its own, inherited, or its presence's first render, #134).
|
|
1251
1256
|
const presenceBlocks = PresenceRecord.presenceBlocksInitial(presence)
|
|
1252
|
-
if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(initialConfig, node.inherited, presenceBlocks))) throw
|
|
1257
|
+
if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(initialConfig, node.inherited, presenceBlocks))) throw misuse("WARDIC_KEY_LOADING_AT_SETUP", STARTS_AT_PENDING)
|
|
1253
1258
|
// Untracked as a whole: a target that's a store's (a store given as a hook's rune) is read here,
|
|
1254
1259
|
// in the component's body, for its values now.
|
|
1255
1260
|
const start = untrack(() => Spine.startOf(initialConfig, node.inherited, presenceBlocks, untrack))
|
|
@@ -1366,7 +1371,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1366
1371
|
return UndefinedOr.match(pending, { onUndefined: () => untrack(features.pending), onDefined: identity })
|
|
1367
1372
|
}
|
|
1368
1373
|
if (DEV && wantsNode && Predicate.isUndefined(layoutProjection) && Bool.not(untrack(features.pending))) {
|
|
1369
|
-
useFeatureRegistry()
|
|
1374
|
+
warnMissing(useFeatureRegistry(), "layout", Feature.LAYOUT_PROPS)
|
|
1370
1375
|
}
|
|
1371
1376
|
const layoutNodes = Bool.match(wantsNode, { onTrue: () => layoutProjection, onFalse: constUndefined })
|
|
1372
1377
|
const dragTransition = DragTransition.dragTransitionOf(initialConfig.dragElastic, initialConfig.dragTransition)
|
|
@@ -1437,9 +1442,12 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1437
1442
|
{ equals: sameTarget, transparent: true },
|
|
1438
1443
|
)
|
|
1439
1444
|
// A colour only the `colors` Feature reads, on a Slim element without it (#511, decision 7): said
|
|
1440
|
-
// once per provider, in development only, and not while a lazy load is on its way.
|
|
1445
|
+
// once per provider, in development only, and not while a lazy load is on its way. Not of a ward that
|
|
1446
|
+
// asks for its Features as it uses them (`targeted`, the hooks'): it asks for `colors` a microtask after
|
|
1447
|
+
// a colour shows, when this had already found none on its way, and said so wrongly (AS2, CL1; seen once
|
|
1448
|
+
// it was coded, where it had gone to Effect's log unread).
|
|
1441
1449
|
// eslint-disable-next-line solid/reactivity -- read inside the warning's effect, where it tracks
|
|
1442
|
-
if (DEV && internal.complete !== true) warnUnreadColors(useFeatureRegistry(), features, () => target().resolved)
|
|
1450
|
+
if (DEV && Bool.and(internal.complete !== true, Predicate.isUndefined(internal.targeted))) warnUnreadColors(useFeatureRegistry(), features, () => target().resolved)
|
|
1443
1451
|
// Its gesture states, for what its variant node hands down (#291): bound at setup, before its
|
|
1444
1452
|
// children read them. Read from the gestures themselves, not the target: a gesture whose layer
|
|
1445
1453
|
// resolves to nothing new leaves the target as it was (`sameResolution`), but is on all the same.
|
|
@@ -1520,7 +1528,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1520
1528
|
if (Bool.not(wanted)) return undefined
|
|
1521
1529
|
const service = GestureFeatures.serviceIn(services, key)
|
|
1522
1530
|
if (DEV && Predicate.isUndefined(service) && Bool.not(untrack(features.pending))) {
|
|
1523
|
-
featureRegistry
|
|
1531
|
+
warnMissing(featureRegistry, name, GestureFeatures.GESTURE_WORDS[name])
|
|
1524
1532
|
}
|
|
1525
1533
|
return service
|
|
1526
1534
|
}
|
|
@@ -1657,7 +1665,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1657
1665
|
})
|
|
1658
1666
|
|
|
1659
1667
|
const mount = (el: HTMLElement): Mounted => {
|
|
1660
|
-
if (justLeft.has(el)) throw
|
|
1668
|
+
if (justLeft.has(el)) throw misuse("WARDIC_WARD_MADE_IN_SPREAD", REMADE)
|
|
1661
1669
|
// The ward a component was given follows this element while it's mounted (#349): one at a time.
|
|
1662
1670
|
let undrive: (() => void) | undefined
|
|
1663
1671
|
if (Predicate.isNotUndefined(share)) {
|
|
@@ -1963,7 +1971,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1963
1971
|
// Its node reads its config's options (its `layoutId`, an accessor's): untracked, as at its mount, so said.
|
|
1964
1972
|
UndefinedOr.map(mounted, (m) => untrack(() => layoutArrivedIn(m.arriveLayout, services)))
|
|
1965
1973
|
if (DEV && Predicate.isUndefined(Keys.projectionIn(services)) && Bool.not(pending)) {
|
|
1966
|
-
featureRegistry
|
|
1974
|
+
warnMissing(featureRegistry, "layout", Feature.LAYOUT_PROPS)
|
|
1967
1975
|
}
|
|
1968
1976
|
},
|
|
1969
1977
|
CLIENT_ONLY_DEFERRED,
|
|
@@ -1989,7 +1997,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1989
1997
|
startRecognizers(m)
|
|
1990
1998
|
}),
|
|
1991
1999
|
onUndefined: () => {
|
|
1992
|
-
if (DEV && Bool.not(pending)) featureRegistry
|
|
2000
|
+
if (DEV && Bool.not(pending)) warnMissing(featureRegistry, "drag", GestureFeatures.GESTURE_WORDS.drag)
|
|
1993
2001
|
},
|
|
1994
2002
|
})
|
|
1995
2003
|
},
|
|
@@ -2035,7 +2043,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
2035
2043
|
if (Predicate.isUndefined(mounted) || mounted.element !== el) {
|
|
2036
2044
|
// Another element it was spread on, or the one it's on, still on the page: a ward drives one
|
|
2037
2045
|
// element at a time (#349's Q5). One the page has let go of is left behind.
|
|
2038
|
-
if (Bool.or(stillOn(refdBefore, el), stillOn(UndefinedOr.map(mounted, elementOfMount), el))) throw
|
|
2046
|
+
if (Bool.or(stillOn(refdBefore, el), stillOn(UndefinedOr.map(mounted, elementOfMount), el))) throw misuse("WARDIC_WARD_ON_TWO_SUBJECTS", secondElement("ward(config)"))
|
|
2039
2047
|
refdBefore = undefined
|
|
2040
2048
|
// Held off the page: nothing starts until it's on it.
|
|
2041
2049
|
if (heldBack(el)) return
|
|
@@ -2186,7 +2194,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
2186
2194
|
* element of its own (#349's Q5).
|
|
2187
2195
|
*/
|
|
2188
2196
|
const drive = (next: Driver, name: string): (() => void) => {
|
|
2189
|
-
if (Bool.or(Predicate.isNotUndefined(driver), stillOn(UndefinedOr.map(mounted, elementOfMount), undefined))) throw
|
|
2197
|
+
if (Bool.or(Predicate.isNotUndefined(driver), stillOn(UndefinedOr.map(mounted, elementOfMount), undefined))) throw misuse("WARDIC_WARD_ON_TWO_SUBJECTS", secondElement(name))
|
|
2190
2198
|
driver = next
|
|
2191
2199
|
UndefinedOr.map(driven, (atom) => registry().set(atom, next))
|
|
2192
2200
|
return () => {
|
|
@@ -2411,7 +2419,7 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
|
|
|
2411
2419
|
// Where it's made, its given parent's, or its given ward's (#349).
|
|
2412
2420
|
const parent = variantParentOf(internal)
|
|
2413
2421
|
const presenceBlocks = PresenceRecord.presenceBlocksInitial(usePresenceContext())
|
|
2414
|
-
if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(atSetup, VariantTree.inheritedContext(atSetup, parent), presenceBlocks))) throw
|
|
2422
|
+
if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(atSetup, VariantTree.inheritedContext(atSetup, parent), presenceBlocks))) throw misuse("WARDIC_KEY_LOADING_AT_SETUP", STARTS_AT_PENDING)
|
|
2415
2423
|
const c = variantChildBy(internal, AnimationControls.uncontrolledOf(WARD_VIEW.snapshotOf(view)))
|
|
2416
2424
|
const node = VariantTree.serverVariantNode(c, parent)
|
|
2417
2425
|
const serverStart = Spine.startOf(c, node.inherited, presenceBlocks, untrack)
|
|
@@ -2539,7 +2547,7 @@ const sayEarly = (member: HandedOn): void => {
|
|
|
2539
2547
|
if (Predicate.isUndefined(DEV)) return
|
|
2540
2548
|
if (SAID_EARLY.has(member)) return
|
|
2541
2549
|
SAID_EARLY.add(member)
|
|
2542
|
-
|
|
2550
|
+
report("WARDIC_RUNE_READ_TOO_EARLY", usedEarly(member))
|
|
2543
2551
|
}
|
|
2544
2552
|
|
|
2545
2553
|
/** The finished ward each function rune's ward hands on to, told it by {@link holderFinished}. */
|
|
@@ -2616,7 +2624,7 @@ const clientHolder = (internal: WardInternals, parent: VariantTree.WardicVariant
|
|
|
2616
2624
|
}
|
|
2617
2625
|
// Followed by one finished ward at a time (#349's Q5).
|
|
2618
2626
|
const drive = (next: Driver, name: string): (() => void) => {
|
|
2619
|
-
if (Predicate.isNotUndefined(driver)) throw
|
|
2627
|
+
if (Predicate.isNotUndefined(driver)) throw misuse("WARDIC_WARD_ON_TWO_SUBJECTS", secondElement(name))
|
|
2620
2628
|
driver = next
|
|
2621
2629
|
UndefinedOr.map(driven, (atom) => registry().set(atom, next))
|
|
2622
2630
|
return () => {
|