Repository navigation
feat(grab): knobs:grab event and a grab send target - #117
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
knobs:grabwindow event (detail: the grab payload) as the copy starts, on both paths (grab mode andgrab()).grabSend(anddata-grab-sendon the script tag): a URL gets each grab POSTed as{ type: "knobs.grab", payload }, a function gets the payload. Only the page's own origin or http(s) on localhost, 127.0.0.1 and *.localhost are allowed. The clipboard copy always runs first; sends time out after 10 s.Proof
<script src="/index.global.js" data-grab-send="/grab">, ⇧G then a click on a button. The page listener got the event once; the local server logged oneapplication/jsonPOST with{"type":"knobs.grab","payload":{content, entries}}; the toast said "Copied · Sent".bun testin packages/devknobs: 4716 pass, 0 fail (new tests: event once per grab on both paths, URL POST body, non-local and opaque-origin URLs refused with one warning, function target, failing and hanging targets still copy, failed copy toasts at once, URL and function send timeouts).AbortSignal.timeoutand passes with it.bun run typecheck,bun run build,pnpm lint,pnpm format:check,pnpm --filter @knobs/web buildand test (71 pass), extension typecheck and tests (82 pass).Weakened checks
None. One existing test ("toast says Sent") waited 3 microtask ticks; it now uses the 5-tick loop its neighbor tests use, same assertions.
Risk
Tier: normal. Area: grab send path (client-side POST to same-origin or localhost URLs only). Not released: CHANGELOG has it under Unreleased; ships with the next tested batch.
How to revert
Revert the merge commit. Nothing is released, so no npm or store rollback.
Test plan