@wardic/dom 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.
Files changed (45) hide show
  1. package/dist/Report.d.ts +1 -1
  2. package/dist/Report.d.ts.map +1 -1
  3. package/dist/Report.js +1 -1
  4. package/dist/Report.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/internal/diagnostic-codes.d.ts +10 -0
  8. package/dist/internal/diagnostic-codes.d.ts.map +1 -0
  9. package/dist/internal/diagnostic-codes.js +38 -0
  10. package/dist/internal/diagnostic-codes.js.map +1 -0
  11. package/dist/internal/projection.d.ts.map +1 -1
  12. package/dist/internal/projection.js +8 -7
  13. package/dist/internal/projection.js.map +1 -1
  14. package/dist/internal/reorder.d.ts.map +1 -1
  15. package/dist/internal/reorder.js +2 -1
  16. package/dist/internal/reorder.js.map +1 -1
  17. package/dist/internal/scroll.js +1 -1
  18. package/dist/internal/scroll.js.map +1 -1
  19. package/dist/unstable/DragTrack.d.ts.map +1 -1
  20. package/dist/unstable/DragTrack.js +2 -1
  21. package/dist/unstable/DragTrack.js.map +1 -1
  22. package/dist/unstable/ElementSetup.d.ts +4 -1
  23. package/dist/unstable/ElementSetup.d.ts.map +1 -1
  24. package/dist/unstable/ElementSetup.js +6 -2
  25. package/dist/unstable/ElementSetup.js.map +1 -1
  26. package/dist/unstable/Feature.d.ts +6 -2
  27. package/dist/unstable/Feature.d.ts.map +1 -1
  28. package/dist/unstable/Feature.js +5 -4
  29. package/dist/unstable/Feature.js.map +1 -1
  30. package/dist/unstable/PointerValues.js +1 -1
  31. package/dist/unstable/PointerValues.js.map +1 -1
  32. package/dist/unstable/PresenceController.js +2 -2
  33. package/dist/unstable/PresenceController.js.map +1 -1
  34. package/package.json +3 -3
  35. package/src/Report.ts +1 -1
  36. package/src/index.ts +1 -1
  37. package/src/internal/diagnostic-codes.ts +46 -0
  38. package/src/internal/projection.ts +13 -7
  39. package/src/internal/reorder.ts +4 -2
  40. package/src/internal/scroll.ts +1 -1
  41. package/src/unstable/DragTrack.ts +5 -1
  42. package/src/unstable/ElementSetup.ts +8 -3
  43. package/src/unstable/Feature.ts +11 -7
  44. package/src/unstable/PointerValues.ts +1 -1
  45. package/src/unstable/PresenceController.ts +2 -2
@@ -363,7 +363,7 @@ const readerOf = (registry: AtomRegistry.AtomRegistry, containers: (element: Ele
363
363
  registry.set(atom, next)
364
364
  if (failing) failing = false
365
365
  } catch (defect) {
366
- if (!failing) Report.failureOn(context, DEPENDENT_FAILED, Cause.die(defect))
366
+ if (!failing) Report.callbackFailedOn(context, DEPENDENT_FAILED, Cause.die(defect))
367
367
  failing = true
368
368
  }
369
369
  }
@@ -85,6 +85,7 @@ import * as Stream from "effect/Stream"
85
85
  import * as UndefinedOr from "effect/UndefinedOr"
86
86
  import type * as DragConstraints from "./DragConstraints.ts"
87
87
  import type * as WardicServices from "@wardic/core/unstable/WardicServices"
88
+ import * as Diagnostic from "@wardic/core/unstable/Diagnostic"
88
89
  import type * as WardConfig from "./WardConfig.ts"
89
90
  import * as DragControls from "./DragControls.ts"
90
91
  import * as DragTransition from "./DragTransition.ts"
@@ -822,7 +823,10 @@ export const driveDragTrack = (opts: DragTrackOptions): DragTrack => {
822
823
  onTrue: () => Effect.void,
823
824
  onFalse: () => {
824
825
  warned = true
825
- return Effect.logWarning("wardic.drag: dragConstraints' container isn't there at a drag's start, so it drags unconstrained")
826
+ return Diagnostic.report(
827
+ "WARDIC_DRAG_CONTAINER_MISSING",
828
+ "`dragConstraints`' container isn't on the page at a drag's start, so the element drags unconstrained. Render the container before the element can be dragged, or give `dragConstraints` a box of numbers.",
829
+ )
826
830
  },
827
831
  })),
828
832
  ),
@@ -14,6 +14,7 @@
14
14
  // since PR 2, moved to dom for every DOM binding's elements, with the value reads its provider holds.
15
15
  import * as BaseValue from "@wardic/core/BaseValue"
16
16
  import * as Projection from "@wardic/core/Projection"
17
+ import * as Diagnostic from "@wardic/core/unstable/Diagnostic"
17
18
  import type * as ReducedMotion from "@wardic/core/ReducedMotion"
18
19
  import type * as Renderer from "@wardic/core/Renderer"
19
20
  import type * as Values from "@wardic/core/Values"
@@ -288,11 +289,15 @@ export const writeUnderStyle = (element: HTMLElement, style: Readonly<Record<str
288
289
  })
289
290
  }
290
291
 
291
- /** Log, once per element, that a `transform` string gave way to the transform keys in its `style` (#130). */
292
+ /**
293
+ * Report, once per element, that a `transform` string gave way to the transform keys in its `style`
294
+ * (#130): `WARDIC_TRANSFORM_STRING_DROPPED`, on the Environment's reporter (`Diagnostic`).
295
+ */
292
296
  export const warnDroppedTransform = (runtime: WardicServices.Runner<WardicServices.WardicServices>, id: string): void => {
293
297
  runtime.runFork(
294
- Effect.logWarning(
295
- "wardic.style: a `transform` string is dropped while `style` sets a transform key (x, scale, rotate…); " +
298
+ Diagnostic.report(
299
+ "WARDIC_TRANSFORM_STRING_DROPPED",
300
+ "a `transform` string is dropped while `style` sets a transform key (x, scale, rotate…); " +
296
301
  "the keys win, as Motion's do. Give the transform as keys, or drop them",
297
302
  ).pipe(Effect.annotateLogs({ id })),
298
303
  )
@@ -29,6 +29,7 @@ import * as Predicate from "effect/Predicate"
29
29
  import * as UndefinedOr from "effect/UndefinedOr"
30
30
  import * as OwnerScope from "./OwnerScope.ts"
31
31
  import type * as WardConfig from "./WardConfig.ts"
32
+ import * as Diagnostic from "@wardic/core/unstable/Diagnostic"
32
33
  import type * as Reactivity from "@wardic/core/unstable/Reactivity"
33
34
  import type * as WardicServices from "@wardic/core/unstable/WardicServices"
34
35
 
@@ -317,8 +318,11 @@ export interface FeatureRegistry {
317
318
  * that brings no Feature works with when one is there (the projection system, for a presence).
318
319
  */
319
320
  readonly built: () => Context.Context<never>
320
- /** Logs `message` at Warning the first time `feature` is named: development's word on a missing Feature. */
321
- readonly warnOnce: (feature: string, message: string) => void
321
+ /**
322
+ * Logs `message` at Warning the first time `feature` is named: development's word on a missing Feature.
323
+ * With `code`, reports it as that coded diagnostic instead (`Diagnostic.report`, solid-next).
324
+ */
325
+ readonly warnOnce: (feature: string, message: string, code?: Diagnostic.Code) => void
322
326
  /** Runs `end` as the provider ends, before its Features: what a Wardic instance's loads stop by (#516). */
323
327
  readonly onEnd: (end: () => void) => void
324
328
  /** Ends every Feature built, the provider's runtime after (a Feature's Layer may stand on it). */
@@ -337,7 +341,7 @@ export interface InstanceHost extends Omit<SectionHost, "onCleanup"> {
337
341
  * A registry's sections of exactly a list, one per list; what runs as it ends (`onEnd`, run by `end`);
338
342
  * and its warnings, one per Feature.
339
343
  */
340
- const sectionsAndWarnings = (build: Build, warn: (message: string) => void) => {
344
+ const sectionsAndWarnings = (build: Build, warn: (message: string, code: Diagnostic.Code | undefined) => void) => {
341
345
  const sections = new WeakMap<ReadonlyArray<Feature>, FeatureSection>()
342
346
  const ends: Array<() => void> = []
343
347
  const warned = new Set<string>()
@@ -356,10 +360,10 @@ const sectionsAndWarnings = (build: Build, warn: (message: string) => void) => {
356
360
  return section
357
361
  },
358
362
  }),
359
- warnOnce: (feature: string, message: string): void => {
363
+ warnOnce: (feature: string, message: string, code?: Diagnostic.Code): void => {
360
364
  if (warned.has(feature)) return
361
365
  warned.add(feature)
362
- warn(message)
366
+ warn(message, code)
363
367
  },
364
368
  }
365
369
  }
@@ -411,8 +415,8 @@ export const clientRegistry = (runtime: FeatureRuntime, dispose: () => Promise<v
411
415
  return services
412
416
  },
413
417
  })
414
- const { end, ...rest } = sectionsAndWarnings(build, (message) => {
415
- runtime.runFork(Effect.logWarning(message))
418
+ const { end, ...rest } = sectionsAndWarnings(build, (message, code) => {
419
+ runtime.runFork(UndefinedOr.match(code, { onUndefined: () => Effect.logWarning(message), onDefined: (given) => Diagnostic.report(given, message) }))
416
420
  })
417
421
  return {
418
422
  build,
@@ -96,7 +96,7 @@ export const pointer: (element: Element, options?: Options) => Effect.Effect<Poi
96
96
  let eventThrew = false
97
97
  /** The value `key`'s set threw: reported at a run's first throw. Its failure path alone. */
98
98
  const valueFailed = (key: string, defect: unknown): void => {
99
- if (Bool.not(Bool.or(eventThrew, failing))) Report.failureOn(context, DEPENDENT_FAILED, Cause.die(defect), { key })
99
+ if (Bool.not(Bool.or(eventThrew, failing))) Report.callbackFailedOn(context, DEPENDENT_FAILED, Cause.die(defect), { key })
100
100
  eventThrew = true
101
101
  }
102
102
  const place = (event: Event): void => {
@@ -707,7 +707,7 @@ export const exitCompleteEvents = (runtime: WardicServices.Runner<WardicServices
707
707
  } catch (defect) {
708
708
  if (failing) return
709
709
  failing = true
710
- runtime.runFork(Report.failure("wardic.presence: onExitComplete failed", Cause.die(defect)))
710
+ runtime.runFork(Report.callbackFailed("wardic.presence: onExitComplete failed", Cause.die(defect)))
711
711
  }
712
712
  },
713
713
  }
@@ -1536,7 +1536,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
1536
1536
  try {
1537
1537
  watch.leave(custom, release, () => holdLate(el, counted))
1538
1538
  } catch (defect) {
1539
- runtime.runFork(Report.failure("wardic.presence: a usePresence callback failed", Cause.die(defect)))
1539
+ runtime.runFork(Report.callbackFailed("wardic.presence: a usePresence callback failed", Cause.die(defect)))
1540
1540
  release()
1541
1541
  }
1542
1542
  })