-
Notifications
You must be signed in to change notification settings - Fork 153
refactor: convert to class #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d97a533 to
a4e765c
Compare
|
We can do this, but it's a big breaking change that requires a major version bump, and honestly I don't really see much added value (other than that it's cleaner, which I agree with). |
|
@Niek No worries! I agree not worth a major version bump for a refactor/style change. I may pull some of the non-breaking style-only changes in here into another PR, and then this will only have the breaking changes, and you can keep it unmerged in case you ever have another reason to make a major version change. |
|
You can keep function /**
* @deprecated
*/
export const createCursor = (
page: Page,
start: Vector = origin,
performRandomMoves: boolean = false,
defaultOptions: DefaultOptions = {}
): GhostCursor => new GhostCursor(page, { start, performRandomMoves, defaultOptions }); |
Good call! I have a couple style changes in this PR that I split into other PRs first so we can make the diff look simpler in this one. @Niek |
|
@Niek Ready for review! My recent PRs being merged has made this a lot more review-able. And now, it should be non-breaking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the ghost cursor implementation from a factory function pattern to a class-based pattern. The main purpose is to modernize the code structure while maintaining backward compatibility through a deprecated factory function.
Key changes:
- Converts
createCursorfactory function toGhostCursorclass constructor - Makes all cursor methods public class methods instead of object properties
- Maintains backward compatibility with a deprecated
createCursorwrapper function
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/spoof.ts | Main refactor converting factory function to class, adding constructor with options object parameter |
| src/test/spoof.spec.ts | Updates test to use new class constructor instead of factory function |
| src/debug/browser-debug.ts | Updates debug code to use new class constructor with proper options structure |
| README.md | Updates documentation to reflect new class-based API |
Comments suppressed due to low confidence (1)
src/spoof.ts:646
- The variable
elemis typed asElementHandle<Element>fromgetElement, butscrollIntoViewmethod signature expectsselector: string | ElementHandle. The types don't align properly - should either pass the originalselectorparameter or updatescrollIntoViewto acceptElementHandle<Element>.
const elem = await this.getElement(selector, optionsResolved)
0657807 to
78f9108
Compare
78f9108 to
ab3df49
Compare
|
Awesome! Let me know when you think it's ready to be merged, @bvandercar-vt BTW we should probably auto-gen the docs (in README.md). |
|
@Niek ready to go! |
|
Sorry that this took forever! Merged now! Thanks again @bvandercar-vt! |
No description provided.