wxt 0.19.2 → 0.19.3-alpha1

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.
@@ -8,11 +8,11 @@ export class ContentScriptContext {
8
8
  this.options = options;
9
9
  this.#abortController = new AbortController();
10
10
  if (this.#isTopFrame) {
11
+ this.#listenForNewerScripts({ ignoreFirstEvent: true });
11
12
  this.#stopOldScripts();
12
- }
13
- this.setTimeout(() => {
13
+ } else {
14
14
  this.#listenForNewerScripts();
15
- });
15
+ }
16
16
  }
17
17
  static SCRIPT_STARTED_MESSAGE_TYPE = "wxt:content-script-started";
18
18
  #isTopFrame = window.self === window.top;
@@ -157,9 +157,12 @@ export class ContentScriptContext {
157
157
  "*"
158
158
  );
159
159
  }
160
- #listenForNewerScripts() {
160
+ #listenForNewerScripts(options) {
161
+ let isFirst = true;
161
162
  const cb = (event) => {
162
163
  if (event.data?.type === ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE && event.data?.contentScriptName === this.contentScriptName) {
164
+ if (isFirst && options?.ignoreFirstEvent) return;
165
+ isFirst = false;
163
166
  this.notifyInvalidated();
164
167
  }
165
168
  };