wxt 0.19.24 → 0.19.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,6 +37,7 @@ export declare class ContentScriptContext implements AbortController {
|
|
|
37
37
|
private isTopFrame;
|
|
38
38
|
private abortController;
|
|
39
39
|
private locationWatcher;
|
|
40
|
+
private receivedMessageIds;
|
|
40
41
|
constructor(contentScriptName: string, options?: Omit<ContentScriptDefinition, "main"> | undefined);
|
|
41
42
|
get signal(): AbortSignal;
|
|
42
43
|
abort(reason?: any): void;
|
|
@@ -112,6 +113,7 @@ export declare class ContentScriptContext implements AbortController {
|
|
|
112
113
|
*/
|
|
113
114
|
notifyInvalidated(): void;
|
|
114
115
|
stopOldScripts(): void;
|
|
116
|
+
verifyScriptStartedEvent(event: MessageEvent): boolean;
|
|
115
117
|
listenForNewerScripts(options?: {
|
|
116
118
|
ignoreFirstEvent?: boolean;
|
|
117
119
|
}): void;
|
|
@@ -20,6 +20,7 @@ export class ContentScriptContext {
|
|
|
20
20
|
isTopFrame = window.self === window.top;
|
|
21
21
|
abortController;
|
|
22
22
|
locationWatcher = createLocationWatcher(this);
|
|
23
|
+
receivedMessageIds = /* @__PURE__ */ new Set();
|
|
23
24
|
get signal() {
|
|
24
25
|
return this.abortController.signal;
|
|
25
26
|
}
|
|
@@ -136,15 +137,23 @@ export class ContentScriptContext {
|
|
|
136
137
|
window.postMessage(
|
|
137
138
|
{
|
|
138
139
|
type: ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE,
|
|
139
|
-
contentScriptName: this.contentScriptName
|
|
140
|
+
contentScriptName: this.contentScriptName,
|
|
141
|
+
messageId: Math.random().toString(36).slice(2)
|
|
140
142
|
},
|
|
141
143
|
"*"
|
|
142
144
|
);
|
|
143
145
|
}
|
|
146
|
+
verifyScriptStartedEvent(event) {
|
|
147
|
+
const isScriptStartedEvent = event.data?.type === ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE;
|
|
148
|
+
const isSameContentScript = event.data?.contentScriptName === this.contentScriptName;
|
|
149
|
+
const isNotDuplicate = !this.receivedMessageIds.has(event.data?.messageId);
|
|
150
|
+
return isScriptStartedEvent && isSameContentScript && isNotDuplicate;
|
|
151
|
+
}
|
|
144
152
|
listenForNewerScripts(options) {
|
|
145
153
|
let isFirst = true;
|
|
146
154
|
const cb = (event) => {
|
|
147
|
-
if (
|
|
155
|
+
if (this.verifyScriptStartedEvent(event)) {
|
|
156
|
+
this.receivedMessageIds.add(event.data.messageId);
|
|
148
157
|
const wasFirst = isFirst;
|
|
149
158
|
isFirst = false;
|
|
150
159
|
if (wasFirst && options?.ignoreFirstEvent) return;
|
package/dist/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.19.
|
|
1
|
+
export const version = "0.19.26";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.26",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"publish-browser-extension": "^2.2.2",
|
|
113
113
|
"scule": "^1.3.0",
|
|
114
114
|
"unimport": "^3.13.1",
|
|
115
|
-
"vite": "^5.0.0 ||
|
|
115
|
+
"vite": "^5.0.0 || <=6.0.8",
|
|
116
116
|
"vite-node": "^2.1.4",
|
|
117
117
|
"web-ext-run": "^0.2.1",
|
|
118
118
|
"webextension-polyfill": "^0.12.0"
|