@effect-tui/react 0.9.2 → 0.9.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-tui/react",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "React bindings for @effect-tui/core",
5
5
  "type": "module",
6
6
  "files": [
@@ -83,7 +83,7 @@
83
83
  "prepublishOnly": "bun run typecheck && bun run build"
84
84
  },
85
85
  "dependencies": {
86
- "@effect-tui/core": "^0.9.2",
86
+ "@effect-tui/core": "^0.9.3",
87
87
  "@effect/platform": "^0.94.0",
88
88
  "@effect/platform-bun": "^0.87.0",
89
89
  "@effect/rpc": "^0.73.0",
package/src/dev.tsx CHANGED
@@ -309,7 +309,7 @@ function ScreenshotHandler() {
309
309
  const tmpPath = `/tmp/tui-screenshot-${Date.now()}.txt`
310
310
  Bun.write(tmpPath, ansiOutput)
311
311
 
312
- show("Screenshot copied!", "success", 1500)
312
+ show("Screenshot copied!", "screenshot", 2500)
313
313
  key.preventDefault?.()
314
314
  }
315
315
  })
@@ -336,26 +336,31 @@ function StatsOverlay({ sampleMs, title }: { sampleMs?: number; title?: string }
336
336
  )
337
337
  }
338
338
 
339
+ export interface DevWrapperProps {
340
+ children?: React.ReactNode
341
+ showStats?: boolean
342
+ statsSampleMs?: number
343
+ statsTitle?: string
344
+ mode?: "fullscreen" | "inline"
345
+ }
346
+
339
347
  /**
340
- * Internal wrapper component that provides dev mode features:
348
+ * Wrapper component that provides dev mode features:
341
349
  * - Debug console panel (` backtick to toggle)
342
350
  * - Screenshot support (~ tilde) with toast notification
343
351
  * - Auto-show console on errors
344
352
  * - Optional renderer stats overlay (showStats)
353
+ *
354
+ * Use this to wrap your app when you need dev features but can't use devRender
355
+ * (e.g., when you need to pass props to your App component).
345
356
  */
346
- function DevWrapper({
357
+ export function DevWrapper({
347
358
  children,
348
359
  showStats,
349
360
  statsSampleMs,
350
361
  statsTitle,
351
362
  mode,
352
- }: {
353
- children?: React.ReactNode
354
- showStats?: boolean
355
- statsSampleMs?: number
356
- statsTitle?: string
357
- mode?: "fullscreen" | "inline"
358
- }) {
363
+ }: DevWrapperProps) {
359
364
  const { visible } = useConsole({ autoShowOnError: true, initiallyVisible: false })
360
365
 
361
366
  // Inline mode: content flows naturally in vstack
@@ -289,6 +289,7 @@ export function useScroll(options: UseScrollOptions = {}): UseScrollReturn {
289
289
  const handleViewportSize = useCallback(
290
290
  (width: number, height: number) => {
291
291
  const newSize = axis === "vertical" ? height : width
292
+ console.log("[useScroll] viewport size reported", { width, height, axis, newSize })
292
293
  // Sync ref immediately so scrollToVisible uses correct size
293
294
  viewportSizeRef.current = newSize
294
295
  setViewportSize(newSize)
@@ -362,13 +363,22 @@ export function useScroll(options: UseScrollOptions = {}): UseScrollReturn {
362
363
  const itemEnd = itemStart + itemSize
363
364
  // Use provided totalSize if available (more accurate than potentially stale contentSize)
364
365
  const effectiveContentSize = totalSize ?? contentSize
366
+ const isAbove = itemStart < currentOffset + padding
367
+ const isBelow = itemEnd > currentOffset + currentViewportSize - padding
368
+ console.log("[useScroll] scrollToVisible", {
369
+ currentViewportSize,
370
+ itemEnd,
371
+ currentOffset,
372
+ isAbove,
373
+ isBelow,
374
+ })
365
375
 
366
376
  // If item is above viewport, scroll up to show it
367
- if (itemStart < currentOffset + padding) {
377
+ if (isAbove) {
368
378
  setOffset(Math.max(0, itemStart - padding))
369
379
  }
370
380
  // If item is below viewport, scroll down to show it
371
- else if (itemEnd > currentOffset + currentViewportSize - padding) {
381
+ else if (isBelow) {
372
382
  const currentMaxOffset = Math.max(0, effectiveContentSize - currentViewportSize)
373
383
  setOffset(Math.min(currentMaxOffset, itemEnd - currentViewportSize + padding))
374
384
  }
@@ -103,6 +103,7 @@ export class ScrollHost extends SingleChildHost {
103
103
 
104
104
  override layout(rect: Rect): void {
105
105
  super.layout(rect)
106
+ console.log("[ScrollHost] layout rect", { x: rect.x, y: rect.y, w: rect.w, h: rect.h })
106
107
 
107
108
  // Report content size if changed (deferred from measure() to keep it pure)
108
109
  if (this.contentWidth !== this.lastReportedContentW || this.contentHeight !== this.lastReportedContentH) {
package/src/index.ts CHANGED
@@ -33,6 +33,8 @@ export {
33
33
  type DevRenderResult,
34
34
  devMain,
35
35
  devRender,
36
+ DevWrapper,
37
+ type DevWrapperProps,
36
38
  hmr,
37
39
  hmrState,
38
40
  } from "./dev.js"