@libo11y/webext 0.2.1 → 0.3.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/README.md CHANGED
@@ -10,7 +10,8 @@ contexts never post to the collector. They forward their batches to the
10
10
  worker by runtime messaging. Trace context crosses with every traced
11
11
  message, and consent is one state for the whole extension.
12
12
 
13
- It has no RUM features. Those belong to `@libo11y/rum`.
13
+ It has no RUM features. Those belong to `@libo11y/rum`, whose
14
+ `@libo11y/rum/webext` entry point builds on this package.
14
15
 
15
16
  ```sh
16
17
  npm install @libo11y/webext
package/dist/content.d.ts CHANGED
@@ -51,5 +51,9 @@ export declare function defaultContentDeps(): ContentDeps;
51
51
  * worker stores "denied", and this context revokes, clearing its buffers.
52
52
  */
53
53
  export declare function setupContentScript(options?: ContentScriptSetupOptions): Promise<ContentScriptTelemetry>;
54
- /** setupContentScript over deps. Internal: the seam the unit tests use. */
55
- export declare function setupContentScriptWith(options: ContentScriptSetupOptions, deps: ContentDeps): Promise<ContentScriptTelemetry>;
54
+ /**
55
+ * setupContentScript over deps. Internal: the seam the unit tests and @libo11y/rum use. With install
56
+ * false it builds the telemetry as web's createTelemetry does: no globals, no instrumentation and
57
+ * no active consent, still flushing on hide (tests that run two contexts in one process).
58
+ */
59
+ export declare function setupContentScriptWith(options: ContentScriptSetupOptions, deps: ContentDeps, install?: boolean): Promise<ContentScriptTelemetry>;
package/dist/content.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WP5 (webext). setupContentScript for content scripts and extension pages.
3
3
  */
4
- import { setupWith } from "@libo11y/core";
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
7
  import { diag } from "@opentelemetry/api";
@@ -65,8 +65,12 @@ async function cleanup(steps) {
65
65
  }
66
66
  }
67
67
  }
68
- /** setupContentScript over deps. Internal: the seam the unit tests use. */
69
- export async function setupContentScriptWith(options, deps) {
68
+ /**
69
+ * setupContentScript over deps. Internal: the seam the unit tests and @libo11y/rum use. With install
70
+ * false it builds the telemetry as web's createTelemetry does: no globals, no instrumentation and
71
+ * no active consent, still flushing on hide (tests that run two contexts in one process).
72
+ */
73
+ export async function setupContentScriptWith(options, deps, install = true) {
70
74
  const chrome = deps.chrome;
71
75
  if (chrome === undefined) {
72
76
  throw new Error("o11y: setupContentScript needs the extension API (chrome.runtime)");
@@ -106,7 +110,9 @@ export async function setupContentScriptWith(options, deps) {
106
110
  ...(options.contextManager === undefined ? {} : { contextManager: options.contextManager }),
107
111
  });
108
112
  const coreOptions = { ...options, console: options.console ?? false };
109
- telemetry = await setupWith(coreOptions, platform);
113
+ telemetry = install
114
+ ? await setupWith(coreOptions, platform)
115
+ : await createTelemetryWith(coreOptions, platform);
110
116
  }
111
117
  catch (err) {
112
118
  await cleanup(steps);
@@ -143,6 +149,8 @@ export async function setupContentScriptWith(options, deps) {
143
149
  })();
144
150
  return shutdownPromise;
145
151
  };
152
+ if (!install)
153
+ return handle;
146
154
  try {
147
155
  setActiveConsent(controller.consent);
148
156
  const instr = options.instrumentations ?? {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @libo11y/webext/internal: the seams @libo11y/rum composes. For libo11y packages only; it follows
3
+ * the package version but carries no compatibility promise and has no API report.
4
+ */
5
+ export type { ChromeLike } from "./chrome.ts";
6
+ export { type ContentDeps, defaultContentDeps, setupContentScriptWith, WORKER_ENDPOINT } from "./content.ts";
7
+ export { defaultWorkerDeps, setupWorkerWith, type WorkerDeps } from "./worker.ts";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @libo11y/webext/internal: the seams @libo11y/rum composes. For libo11y packages only; it follows
3
+ * the package version but carries no compatibility promise and has no API report.
4
+ */
5
+ export { defaultContentDeps, setupContentScriptWith, WORKER_ENDPOINT } from "./content.js";
6
+ export { defaultWorkerDeps, setupWorkerWith } from "./worker.js";
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.2.1";
2
+ export declare const VERSION = "0.3.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.2.1";
2
+ export const VERSION = "0.3.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libo11y/webext",
3
- "version": "0.2.1",
3
+ "version": "0.3.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",
@@ -9,6 +9,10 @@
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
11
  "default": "./dist/index.js"
12
+ },
13
+ "./internal": {
14
+ "types": "./dist/internal.d.ts",
15
+ "default": "./dist/internal.js"
12
16
  }
13
17
  },
14
18
  "repository": {
@@ -17,16 +21,16 @@
17
21
  "directory": "ts/packages/webext"
18
22
  },
19
23
  "dependencies": {
20
- "@libo11y/core": "0.2.1",
21
- "@libo11y/spec": "0.2.1",
22
- "@libo11y/web": "0.2.1",
24
+ "@libo11y/core": "0.3.0",
25
+ "@libo11y/spec": "0.3.0",
26
+ "@libo11y/web": "0.3.0",
23
27
  "@opentelemetry/api": "1.10.0",
24
28
  "@opentelemetry/sdk-logs": "3.1.1",
25
29
  "@opentelemetry/sdk-metrics": "3.1.1",
26
30
  "@opentelemetry/sdk-trace": "3.1.1"
27
31
  },
28
32
  "devDependencies": {
29
- "@libo11y/test": "0.2.1",
33
+ "@libo11y/test": "0.3.0",
30
34
  "fake-indexeddb": "6.2.7"
31
35
  },
32
36
  "files": [