@libo11y/webext 0.3.0 → 0.4.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.
package/dist/content.js CHANGED
@@ -4,6 +4,7 @@
4
4
  import { createTelemetryWith, setupWith, } from "@libo11y/core";
5
5
  import { installXhrInstrumentation, recordDocumentLoad, } from "@libo11y/web";
6
6
  import { activeConsent, createConsentController, createDelivery, createMemoryQueue, installFetchInstrumentation, installFlushOnHide, setActiveConsent, webPlatform, } from "@libo11y/web/internal";
7
+ import { flushInBackground } from "@libo11y/web/portable";
7
8
  import { diag } from "@opentelemetry/api";
8
9
  import { getChrome } from "./chrome.js";
9
10
  import { readStoredConsent, syncConsent } from "./consent-sync.js";
@@ -121,10 +122,17 @@ export async function setupContentScriptWith(options, deps, install = true) {
121
122
  const core = telemetry;
122
123
  const doc = deps.document;
123
124
  if (doc !== undefined)
124
- steps.unshift(deps.installFlushOnHide(doc, deps.window, () => core.forceFlush()));
125
- steps.unshift(controller.onRevoke(async () => {
126
- await core.forceFlush();
127
- await delivery.clear();
125
+ steps.unshift(deps.installFlushOnHide(doc, deps.window, () => flushInBackground(core, "flush on hide")));
126
+ steps.unshift(
127
+ // The queue is emptied first, whatever the flush does, as on a page.
128
+ controller.onRevoke(async () => {
129
+ const cleared = delivery.clear();
130
+ try {
131
+ await core.forceFlush();
132
+ }
133
+ finally {
134
+ await cleared;
135
+ }
128
136
  }));
129
137
  const messaging = createTracedMessaging(chrome, core.propagator);
130
138
  const uninstalls = [];
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The @libo11y/webext package version. scripts/release.ts keeps it equal to package.json. */
2
- export declare const VERSION = "0.3.0";
2
+ export declare const VERSION = "0.4.0";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The @libo11y/webext package version. scripts/release.ts keeps it equal to package.json. */
2
- export const VERSION = "0.3.0";
2
+ export const VERSION = "0.4.0";
package/dist/worker.js CHANGED
@@ -283,9 +283,16 @@ export async function setupWorkerWith(options, deps) {
283
283
  }
284
284
  const { controller, queue, delivery, endpoints } = built;
285
285
  const telemetry = core;
286
+ // The queue is emptied first, whatever the flush does: a flush waits for exports in flight, up to
287
+ // its deadline, and a worker stopped in that time would otherwise keep the queue for a later grant.
286
288
  const unregisterRevoke = controller.onRevoke(async () => {
287
- await telemetry.forceFlush();
288
- await delivery.clear();
289
+ const cleared = delivery.clear();
290
+ try {
291
+ await telemetry.forceFlush();
292
+ }
293
+ finally {
294
+ await cleared;
295
+ }
289
296
  });
290
297
  const messaging = createTracedMessaging(chrome, telemetry.propagator);
291
298
  const uninstalls = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libo11y/webext",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "The libo11y Manifest V3 extension platform for TypeScript: setup for the service worker with a queue persisted to IndexedDB on every batch, setup for content scripts and extension pages that forward their records to the worker by runtime messaging, and trace context that crosses with every message.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -21,16 +21,16 @@
21
21
  "directory": "ts/packages/webext"
22
22
  },
23
23
  "dependencies": {
24
- "@libo11y/core": "0.3.0",
25
- "@libo11y/spec": "0.3.0",
26
- "@libo11y/web": "0.3.0",
24
+ "@libo11y/core": "0.4.0",
25
+ "@libo11y/spec": "0.4.0",
26
+ "@libo11y/web": "0.4.0",
27
27
  "@opentelemetry/api": "1.10.0",
28
28
  "@opentelemetry/sdk-logs": "3.1.1",
29
29
  "@opentelemetry/sdk-metrics": "3.1.1",
30
30
  "@opentelemetry/sdk-trace": "3.1.1"
31
31
  },
32
32
  "devDependencies": {
33
- "@libo11y/test": "0.3.0",
33
+ "@libo11y/test": "0.4.0",
34
34
  "fake-indexeddb": "6.2.7"
35
35
  },
36
36
  "files": [