Skip to content
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

fix: avoid using deprecated jQuery functions to prepare for jQuery 4 … #780

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea
node_modules
**/*~
**/.#*
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

## Version 1.1.13

- Drop bundled jQuery, support jQuery 4, support explicit no-jQuery mode
- Fix reply button selector to support Gmail in text labels mode

## Version 1.1.12
Expand Down
22 changes: 2 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@
"gmail chrome extension",
"gmail firefox extension"
],
"dependencies": {
"jquery": "^3.6.1"
},
"devDependencies": {
"@types/jquery": "^3.5.14",
"eslint": "^8.23.1",
"gmail-js": "^1.1.0",
"jest": "^29.5.0",
"jest-junit": "^16.0.0",
"jsdom": "^20.0.0",
Expand Down
29 changes: 16 additions & 13 deletions src/gmail.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ declare type StringDict = {
//
////////////////////////////////////////////////////////////////////////////////

interface GmailTracker {
interface GmailTracker<T extends string = never> {
dom_observers: { [observer in GmailDomObserver | T]?: DomObserverConfig };
globals: any[];
view_data: any[];
ik: string;
hangouts: any;
events: {}[];
actions: {}[];
watchdog: {
before: {},
on: {},
after: {},
dom: {}
before: { [action in GmailBindAction | T]?: Function[] };
on: { [action in GmailBindAction | T]?: Function[] };
after: { [action in GmailBindAction | T]?: Function[] };
dom: { [observer in GmailDomObserver | T]?: Function[] };
};
}

Expand Down Expand Up @@ -671,7 +672,7 @@ interface GmailTools {
observes every element inserted into the DOM by Gmail and looks at the classes on those elements,
checking for any configured observers related to those classes
*/
insertion_observer(target: HTMLElement | string, dom_observers: any, dom_observer_map: any, sub: any): void;
insertion_observer(target: HTMLElement | string, dom_observers: { [observer: string]: DomObserverConfig }, dom_observer_map: { [className: string]: string[] }, sub?: string): void;

make_request(link: string, method: GmailHttpRequestMethod, disable_cache: boolean): string;
make_request_async(link: string, method: GmailHttpRequestMethod, callback: (data: string) => void, disable_cache: boolean): void;
Expand Down Expand Up @@ -764,6 +765,8 @@ declare type GmailBindAction =
| 'new_email' | 'refresh' | 'open_email' | 'upload_attachment' | 'compose'
| 'compose_cancelled' | 'recipient_change' | 'view_thread' | 'view_email'
| 'load_email_menu';
declare type GmailDomObserver =
'view_thread' | 'view_email' | 'load_email_menu' | 'recipient_change' | 'compose'

interface HttpEventRequestParams {
url: object,
Expand All @@ -780,7 +783,7 @@ interface DomObserverConfig {
handler?: Function;
}

interface GmailObserve<T extends string=never> {
interface GmailObserve<T extends string = never> {
/**
After an observer has been bound through gmail.observe.bind() (via a
call to events gmail.observe.before(), gmail.observe.on(), or
Expand All @@ -798,7 +801,7 @@ interface GmailObserve<T extends string=never> {
/**
Bind a specified callback to an array of callbacks against a specified type & action
*/
bind(type: GmailBindType, action: Function, callback: Function): void;
bind(type: GmailBindType, action: GmailBindAction | T, callback: Function): void;

/**
an on event is observed just after gmail sends an xhr request
Expand Down Expand Up @@ -850,11 +853,11 @@ interface GmailObserve<T extends string=never> {
Trigger any specified events bound to the passed type
Returns true or false depending if any events were fired
*/
trigger(type: GmailBindType, events: any, xhr: XMLHttpRequest): boolean;
trigger(type: GmailBindType, events: { [action in GmailBindAction | T]?: any[] }, xhr: XMLHttpRequest): boolean;
/**
Trigger any specified DOM events passing a specified element & optional handler
*/
trigger_dom(observer: any, element: HTMLElement, handler?: Function): void;
trigger_dom(observer: GmailDomObserver | T, element: HTMLElement, handler?: Function): void;

initialize_dom_observers(): void;

Expand All @@ -867,7 +870,7 @@ interface GmailObserve<T extends string=never> {
className / args - for a simple observer, this arg can simply be the class on an inserted DOM element that identifies this event should be
triggered. For a more complicated observer, this can be an object containing properties for each of the supported DOM observer config arguments
*/
register(action: string, args: string | DomObserverConfig): void;
register(action: T, args: string | DomObserverConfig): void;
/**
Observe DOM nodes being inserted. When a node with a class defined in api.tracker.dom_observers is inserted,
trigger the related event and fire off any relevant bound callbacks
Expand Down Expand Up @@ -1031,14 +1034,14 @@ interface GmailCache {
////////////////////////////////////////////////////////////////////////////////

declare class Gmail<T extends string=never> {
constructor(localJQuery?: JQueryStatic);
constructor(localJQuery?: JQueryStatic | false);
josteink marked this conversation as resolved.
Show resolved Hide resolved

version: string;
/**
These are some of the variables that are tracked and kept in
memory while the rest of the methods are in use.
*/
tracker: GmailTracker;
tracker: GmailTracker<T>;
get: GmailGet;
check: GmailCheck;
/**
Expand Down
Loading
Loading