Skip to content

Commit 216798b

Browse files
authored
Merge branch 'develop' into feat/fail-dropped-jupiter-transactions
2 parents c0bbe9a + b6e5f6d commit 216798b

File tree

94 files changed

+1737
-1617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1737
-1617
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22.10.0
1+
v22.11.0

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:22.10-bookworm
1+
FROM node:22.11-bookworm
22
RUN apt-get update
33
RUN apt-get install build-essential zip -y
44
ENV HOME /home

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"devDependencies": {
3535
"@commitlint/cli": "^19.5.0",
3636
"@commitlint/config-conventional": "^19.5.0",
37-
"@swc/core": "^1.7.39",
38-
"concurrently": "^9.0.1",
37+
"@swc/core": "^1.9.2",
38+
"concurrently": "^9.1.0",
3939
"husky": "^9.1.6",
4040
"node-notifier": "^10.0.1",
4141
"nodemon": "^3.1.7",

packages/extension-bridge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ button.addEventListener("click", async () => {
3636
const res = await sendMessage(
3737
"get-selection",
3838
{ ignoreCasing: true },
39-
"content-script"
39+
"content-script",
4040
);
4141
console.log(res); // > "The brown fox is alive and well"
4242
});
@@ -57,7 +57,7 @@ onMessage("get-selection", async (message) => {
5757
const { selection } = await sendMessage(
5858
"get-preferences",
5959
{ sync: false },
60-
"background"
60+
"background",
6161
);
6262
return calculateSelection(data.ignoreCasing, selection);
6363
});

packages/extension-bridge/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@
4444
"webextension-polyfill": "^0.12.0"
4545
},
4646
"devDependencies": {
47-
"@types/node": "^22.7.8",
47+
"@types/node": "^22.9.0",
4848
"@types/webextension-polyfill": "^0.12.1",
4949
"@typescript-eslint/eslint-plugin": "^5.62.0",
5050
"@typescript-eslint/parser": "^5.62.0",
51-
"bumpp": "^9.7.1",
52-
"eslint": "^8.57.1",
51+
"bumpp": "^9.8.1",
52+
"eslint": "^9.14.0",
5353
"eslint-config-airbnb-base": "^15.0.0",
54-
"eslint-config-prettier": "^8.10.0",
54+
"eslint-config-prettier": "^9.1.0",
5555
"eslint-import-resolver-alias": "^1.1.2",
5656
"eslint-plugin-import": "^2.31.0",
5757
"eslint-plugin-module-resolver": "^1.5.0",
58-
"prettier": "^2.8.8",
58+
"prettier": "^3.3.3",
5959
"ts-node": "^10.9.2",
6060
"tsconfig-paths": "^4.2.0",
61-
"tsup": "^8.3.0",
61+
"tsup": "^8.3.5",
6262
"type-fest": "^4.26.1",
63-
"typescript": "^4.9.5",
64-
"typescript-eslint": "0.0.1-alpha.0"
63+
"typescript": "^5.6.3",
64+
"typescript-eslint": "8.14.0"
6565
}
6666
}

packages/extension-bridge/src/apis/onMessage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { onMessageListeners } from "../internal";
1010

1111
export function onMessage<
1212
Data extends JsonValue,
13-
K extends DataTypeKey | string
13+
K extends DataTypeKey | string,
1414
>(
1515
messageID: K,
16-
callback: OnMessageCallback<GetDataType<K, Data>, GetReturnType<K, any>>
16+
callback: OnMessageCallback<GetDataType<K, Data>, GetReturnType<K, any>>,
1717
): void {
1818
onMessageListeners.set(messageID, callback);
1919
}

packages/extension-bridge/src/apis/sendMessage.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ import { parseEndpoint } from "../utils";
2424
*/
2525
export async function sendMessage<
2626
ReturnType extends JsonValue,
27-
K extends DataTypeKey | string
27+
K extends DataTypeKey | string,
2828
>(
2929
messageID: K,
3030
data: GetDataType<K, JsonValue>,
31-
destination: Destination = "background"
31+
destination: Destination = "background",
3232
) {
3333
const endpoint =
3434
typeof destination === "string" ? parseEndpoint(destination) : destination;
3535
const errFn = "Bridge#sendMessage ->";
3636

3737
if (!endpoint.context)
3838
throw new TypeError(
39-
`${errFn} Destination must be any one of known destinations`
39+
`${errFn} Destination must be any one of known destinations`,
4040
);
4141
if (context === "background") {
4242
const { context: dest, tabId: destTabId } = endpoint;
4343
if (dest !== "background" && !destTabId)
4444
throw new TypeError(
45-
`${errFn} When sending messages from background page, use @tabId syntax to target specific tab`
45+
`${errFn} When sending messages from background page, use @tabId syntax to target specific tab`,
4646
);
4747
}
4848

packages/extension-bridge/src/bridge.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ onMessage<{ channel: string; streamId: string }, string>(
3535
};
3636

3737
readyup();
38-
})
38+
}),
3939
);
4040

4141
async function openStream(
4242
channel: string,
43-
destination: RuntimeContext | Endpoint | string
43+
destination: RuntimeContext | Endpoint | string,
4444
): Promise<Stream> {
4545
if (openStreams.has(channel))
4646
throw new Error("webext-bridge: A Stream is already open at this channel");
@@ -58,11 +58,11 @@ async function openStream(
5858

5959
function onOpenStreamChannel(
6060
channel: string,
61-
callback: (stream: Stream) => void
61+
callback: (stream: Stream) => void,
6262
): void {
6363
if (onOpenStreamCallbacks.has(channel))
6464
throw new Error(
65-
"webext-bridge: This channel has already been claimed. Stream allows only one-on-one communication"
65+
"webext-bridge: This channel has already been claimed. Stream allows only one-on-one communication",
6666
);
6767

6868
onOpenStreamCallbacks.set(channel, callback);

packages/extension-bridge/src/internal.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import { hasAPI, parseEndpoint, getBackgroundPageType } from "./utils";
1414
export const context: RuntimeContext = hasAPI("devtools")
1515
? "devtools"
1616
: hasAPI("tabs")
17-
? getBackgroundPageType()
18-
: hasAPI("extension")
19-
? "content-script"
20-
: typeof document !== "undefined"
21-
? "window"
22-
: null;
17+
? getBackgroundPageType()
18+
: hasAPI("extension")
19+
? "content-script"
20+
: typeof document !== "undefined"
21+
? "window"
22+
: null;
2323

2424
const runtimeId: string = uuid();
2525
export const openTransactions = new Map<
@@ -51,7 +51,7 @@ export const allowWindowMessaging = (nsps: string): void => {
5151
namespace = nsps;
5252
};
5353
const handleInboundMessage = async (
54-
message: IInternalMessage
54+
message: IInternalMessage,
5555
): Promise<void> => {
5656
const { transactionId, messageID, messageType } = message;
5757

@@ -63,7 +63,7 @@ const handleInboundMessage = async (
6363
const dehydratedErr = err as Record<string, string>;
6464
const errCtr = self[dehydratedErr.name] as any;
6565
const hydratedErr = new (typeof errCtr === "function" ? errCtr : Error)(
66-
dehydratedErr.message
66+
dehydratedErr.message,
6767
);
6868
Object.keys(dehydratedErr).forEach((prop) => {
6969
hydratedErr[prop] = dehydratedErr[prop];
@@ -93,7 +93,7 @@ const handleInboundMessage = async (
9393
} else {
9494
noHandlerFoundError = true;
9595
throw new Error(
96-
`[webext-bridge] No handler registered in '${context}' to accept messages with id '${messageID}'`
96+
`[webext-bridge] No handler registered in '${context}' to accept messages with id '${messageID}'`,
9797
);
9898
}
9999
} catch (error) {
@@ -128,7 +128,7 @@ const handleInboundMessage = async (
128128
const initIntercoms = () => {
129129
if (context === null)
130130
throw new Error(
131-
"Unable to detect runtime context i.e webext-bridge can't figure out what to do"
131+
"Unable to detect runtime context i.e webext-bridge can't figure out what to do",
132132
);
133133

134134
if (context === "window" || context === "content-script")
@@ -245,7 +245,7 @@ const initIntercoms = () => {
245245

246246
initIntercoms();
247247
export const routeMessage = (
248-
message: IInternalMessage
248+
message: IInternalMessage,
249249
): void | Promise<void> => {
250250
const { origin, destination } = message;
251251
if (message.hops.includes(runtimeId)) return;
@@ -275,7 +275,7 @@ export const routeMessage = (
275275
routeMessageThroughWindow(window, message);
276276
} else if (
277277
["devtools", "content-script", "popup", "options", "new-window"].includes(
278-
context
278+
context,
279279
)
280280
) {
281281
if (destination.context === "background") message.destination = null;
@@ -320,7 +320,7 @@ export const routeMessage = (
320320

321321
// eslint-disable-next-line @typescript-eslint/no-empty-function
322322
const assertInternalMessage: (x: unknown) => asserts x = (
323-
_msg: any
323+
_msg: any,
324324
): asserts _msg is IInternalMessage => {
325325
// todo
326326
};
@@ -373,7 +373,7 @@ const routeMessageThroughWindow = (win: Window, msg: IInternalMessage) => {
373373
context,
374374
payload: msg,
375375
},
376-
"*"
376+
"*",
377377
);
378378
};
379379
win.postMessage(
@@ -383,7 +383,7 @@ const routeMessageThroughWindow = (win: Window, msg: IInternalMessage) => {
383383
context,
384384
},
385385
"*",
386-
[channel.port2]
386+
[channel.port2],
387387
);
388388
};
389389

@@ -393,7 +393,7 @@ function ensureNamespaceSet() {
393393
'webext-bridge uses window.postMessage to talk with other "window"(s), for message routing and stuff,' +
394394
"which is global/conflicting operation in case there are other scripts using webext-bridge. " +
395395
"Call Bridge#setNamespace(nsps) to isolate your app. Example: setNamespace('com.facebook.react-devtools'). " +
396-
"Make sure to use same namespace across all your scripts whereever window.postMessage is likely to be used`"
396+
"Make sure to use same namespace across all your scripts whereever window.postMessage is likely to be used`",
397397
);
398398
}
399399
}

packages/extension-bridge/src/stream.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Stream {
7474
public send(msg?: JsonValue): void {
7575
if (this.isClosed)
7676
throw new Error(
77-
"Attempting to send a message over closed stream. Use stream.onClose(<callback>) to keep an eye on stream status"
77+
"Attempting to send a message over closed stream. Use stream.onClose(<callback>) to keep an eye on stream status",
7878
);
7979

8080
sendMessage(
@@ -84,7 +84,7 @@ class Stream {
8484
streamTransfer: msg,
8585
action: "transfer",
8686
},
87-
this.internalInfo.endpoint
87+
this.internalInfo.endpoint,
8888
);
8989
}
9090

@@ -106,7 +106,7 @@ class Stream {
106106
streamTransfer: null,
107107
action: "close",
108108
},
109-
this.internalInfo.endpoint
109+
this.internalInfo.endpoint,
110110
);
111111
}
112112

@@ -115,7 +115,7 @@ class Stream {
115115
* @param callback
116116
*/
117117
public onMessage<T extends JsonValue>(
118-
callback: (msg?: T) => void
118+
callback: (msg?: T) => void,
119119
): HybridUnsubscriber {
120120
return this.getDisposable("message", callback);
121121
}
@@ -125,7 +125,7 @@ class Stream {
125125
* @param callback
126126
*/
127127
public onClose<T extends JsonValue>(
128-
callback: (msg?: T) => void
128+
callback: (msg?: T) => void,
129129
): HybridUnsubscriber {
130130
return this.getDisposable("closed", callback);
131131
}
@@ -140,7 +140,7 @@ class Stream {
140140

141141
private getDisposable(
142142
event: string,
143-
callback: () => void
143+
callback: () => void,
144144
): HybridUnsubscriber {
145145
const off = this.emitter.on(event, callback);
146146

0 commit comments

Comments
 (0)