Skip to content

Drop unmaintained micro-deps in favor of Hoist-owned utils#4397

Merged
lbwexler merged 10 commits into
developfrom
packageCleanup
Jun 5, 2026
Merged

Drop unmaintained micro-deps in favor of Hoist-owned utils#4397
lbwexler merged 10 commits into
developfrom
packageCleanup

Conversation

@lbwexler

@lbwexler lbwexler commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

Sweep to remove small, unmaintained transitive deps in favor of Hoist-owned utilities. Behavior preserved at every callsite; original packages credited in source comments under their MIT licenses.

  • @seznam/compose-react-refs (last published 2022) → composeRefs in utils/react/ComposeRefs.ts. Faithful port: variadic, pairwise WeakMap-cached for ref-identity stability across renders. 17 callsites migrated. TODO left in source noting the React 19 upgrade path (forward cleanup returns + add a useComposedRefs hook variant).
  • clipboard-copy (last published 2022) → copyToClipboard in utils/js/ClipboardUtils.ts. Async Clipboard API with execCommand fallback retained for non-secure contexts and secure-context permission/focus failures. 4 callsites migrated. TODO left noting the fallback can be dropped once Hoist requires a secure context.
  • debounce-promise (last published 2022) → debouncePromise in @xh/hoist/promise. Trimmed to the only mode Hoist uses: trailing-edge debouncer where all calls in a quiet window share a single Promise that resolves with the result of one invocation using the most recent args. Leading-edge and accumulate modes omitted. 2 callsites migrated (desktop and mobile Select).

Test plan

  • npx tsc --noEmit clean
  • yarn lint (code + styles) clean
  • Manual smoke in Toolbox: composed-ref consumers still mount/unmount cleanly (charts, treemap, tile frame, grids, dash containers, tab switchers, form inputs)
  • Manual smoke in Toolbox: copy-to-clipboard works (ClipboardButton, About dialog, grid copy-cell menu, admin badge double-click)
  • Manual smoke in Toolbox: Select with queryFn still debounces queries correctly while typing

🤖 Generated with Claude Code

lbwexler and others added 2 commits May 27, 2026 07:23
The seznam package was last published in 2022. Drop the dep and inline a faithful
behavior-preserving `composeRefs` in `utils/react/`, with pairwise WeakMap caching
for ref-identity stability across renders.

All 17 callsites migrated to a named import from `@xh/hoist/utils/react`. No behavior
change. TODO left in source noting the React 19 upgrade path (cleanup forwarding +
`useComposedRefs` hook).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The clipboard-copy package was last published in 2022. Drop the dep and inline a
faithful behavior-preserving `copyToClipboard` in `utils/js/ClipboardUtils.ts`,
using the async Clipboard API with the legacy execCommand fallback intact.

All 4 callsites migrated to a named import from `@xh/hoist/utils/js`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lbwexler lbwexler changed the title Replace unmaintained @seznam/compose-react-refs with Hoist-owned util Drop unmaintained micro-deps in favor of Hoist-owned utils May 27, 2026
lbwexler and others added 7 commits May 27, 2026 07:30
The execCommand fallback has no concrete removal trigger - browsers have shown no
urgency in actually removing the deprecated API. The "why" comment above already
explains the fallback's purpose; the TODO added nothing actionable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment narrows to the actual reason for the fallback (non-secure context), drops
the misleading "older browsers" framing. Restores a terse TODO with a concrete
trigger - drop the fallback once Hoist requires a secure context.

Switches the internal NotAllowedError construction from raw `DOMException` to
`XH.exception` for consistency with the rest of the framework.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The nested catch's `|| apiErr || notAllowed()` was dead code - `cmdErr` is always
truthy when entering the catch (we only get there because something threw).
Inherited from the original `clipboard-copy` source, which was being paranoid
about `throw null` / `throw undefined`. Collapse to a single try/catch and let
the execCommand fallback's own throw propagate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
XH.exception() accepts a bare message string, so the helper and the explicit
name field add nothing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Expand the doc comment to mention that the execCommand fallback also catches
secure-context writeText() rejections (no user activation, unfocused document,
Permissions Policy denial) - not just non-secure contexts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Left dead after the writeText call was inlined into copyToClipboard.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The debounce-promise package was last published in 2022. Drop the dep and inline a
trailing-edge promise debouncer in `@xh/hoist/promise`, matching the only mode
Hoist callsites use (shared promise across coalesced calls, resolved with the
result of the underlying fn called with the most recent args). Leading-edge and
accumulate modes were not used and have been omitted.

Both callsites (desktop and mobile `Select`) migrated to the named import.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lbwexler lbwexler marked this pull request as ready for review May 27, 2026 13:54
Comment thread utils/js/ClipboardUtils.ts
Comment thread utils/react/ComposeRefs.ts
@TomTirapani

Copy link
Copy Markdown
Member

Looks good! We should remember to add lines to the upgrade notes to help agents migrate the imports

@lbwexler lbwexler merged commit d7c45d0 into develop Jun 5, 2026
3 checks passed
@lbwexler lbwexler deleted the packageCleanup branch June 5, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants