webext-messenger 0.27.0 → 0.28.0

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.
@@ -2,6 +2,7 @@ import { getContextName, isBackground, isExtensionContext, } from "webext-detect
2
2
  import { messenger } from "./sender.js";
3
3
  import { registerMethods } from "./receiver.js";
4
4
  import { MessengerError, once } from "./shared.js";
5
+ import { pEvent } from "p-event";
5
6
  /**
6
7
  * @file This file exists because `runtime.sendMessage` acts as a broadcast to
7
8
  * all open extension pages, so the receiver needs a way to figure out if the
@@ -47,6 +48,11 @@ const storeTabData = once(async () => {
47
48
  if (tabDataStatus !== "needed") {
48
49
  return;
49
50
  }
51
+ // If the page is prerendering, wait for the change to be able to get the tab data so the frameId is correct
52
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/prerenderingchange_event
53
+ if ("prerendering" in document && Boolean(document.prerendering)) {
54
+ await pEvent(document, 'prerenderingchange');
55
+ }
50
56
  try {
51
57
  tabDataStatus = "pending";
52
58
  Object.assign(thisTarget, await messenger("__getTabData", {}, { page: "any" }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webext-messenger",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "Browser Extension component messaging framework",
5
5
  "keywords": [],
6
6
  "repository": "pixiebrix/webext-messenger",
@@ -26,9 +26,10 @@
26
26
  "watch": "tsc --watch"
27
27
  },
28
28
  "dependencies": {
29
+ "p-event": "^6.0.1",
29
30
  "p-retry": "^6.2.0",
30
31
  "serialize-error": "^11.0.3",
31
- "type-fest": "^4.13.0",
32
+ "type-fest": "^4.18.3",
32
33
  "webext-detect-page": "^5.0.1"
33
34
  },
34
35
  "@parcel/resolver-default": {
@@ -37,12 +38,12 @@
37
38
  "devDependencies": {
38
39
  "@parcel/config-webextension": "^2.11.0",
39
40
  "@sindresorhus/tsconfig": "^5.0.0",
40
- "@types/chrome": "^0.0.263",
41
+ "@types/chrome": "^0.0.268",
41
42
  "@types/tape": "^5.6.4",
42
43
  "@types/webextension-polyfill": "^0.10.7",
43
44
  "buffer": "^6.0.3",
44
45
  "eslint": "^8.57.0",
45
- "eslint-config-pixiebrix": "^0.37.2",
46
+ "eslint-config-pixiebrix": "^0.39.0",
46
47
  "events": "^3.3.0",
47
48
  "npm-run-all": "^4.1.5",
48
49
  "parcel": "^2.11.0",
@@ -50,10 +51,10 @@
50
51
  "process": "^0.11.10",
51
52
  "stream-browserify": "^3.0.0",
52
53
  "tape": "^5.7.5",
53
- "typescript": "^5.4.2",
54
- "vitest": "^1.4.0",
54
+ "typescript": "^5.4.5",
55
+ "vitest": "^1.6.0",
55
56
  "webext-content-scripts": "^2.6.1",
56
- "webextension-polyfill": "^0.10.0"
57
+ "webextension-polyfill": "^0.12.0"
57
58
  },
58
59
  "targets": {
59
60
  "main": false,
package/readme.md CHANGED
@@ -17,7 +17,7 @@ import messenger from "webext-messenger";
17
17
 
18
18
  ## Context
19
19
 
20
- - [Initial considertions for this library](https://github.com/pixiebrix/webext-messenger/issues/1)
20
+ - [Initial considerations for this library](https://github.com/pixiebrix/webext-messenger/issues/1)
21
21
 
22
22
 
23
23
  ## npm publishing