@tracelane/report 0.1.0-alpha.12 → 0.1.0-alpha.13

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/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { buildReport } from './build-report.js';
2
2
  export type { BuildReportOptions } from './build-report.js';
3
3
  export type { ReportMeta, ReportStatus, Viewport } from './types.js';
4
+ export { reportFileName, slugify, specSlug, writeReport } from './report-writer.js';
5
+ export type { WriteReportInput } from './report-writer.js';
4
6
  export { decodeEventsBlob, encodeEventsBlob } from './embed.js';
5
7
  export { extractConsole, extractNetwork, CONSOLE_PLUGIN, NETWORK_EVENT_TAG, NETWORK_CONSOLE_PREFIX, } from './panels.js';
6
8
  export type { ConsoleEntry, NetworkEntry } from './panels.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG5D,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGhE,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACnG,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG5D,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAIrE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpF,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGhE,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACnG,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  // Public API surface for @tracelane/report.
2
2
  // The report builder: events + metadata -> self-contained offline HTML string.
3
3
  export { buildReport } from './build-report.js';
4
+ // Disk writer: build the HTML and write it under outDir with a parallel-safe,
5
+ // adapter-namespaced filename. Shared by the WDIO and Playwright adapters.
6
+ export { reportFileName, slugify, specSlug, writeReport } from './report-writer.js';
4
7
  // Events blob round-trip (Task 2.9) — useful for re-reading a report's events.
5
8
  export { decodeEventsBlob, encodeEventsBlob } from './embed.js';
6
9
  // Console + network panel extraction (Task 2.10).
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAE5C,+EAA+E;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhD,+EAA+E;AAC/E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEhE,kDAAkD;AAClD,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAGrB,sCAAsC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,wCAAwC;AACxC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAE5C,+EAA+E;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhD,8EAA8E;AAC9E,2EAA2E;AAC3E,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGpF,+EAA+E;AAC/E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEhE,kDAAkD;AAClD,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAGrB,sCAAsC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,wCAAwC;AACxC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { eventWithTime } from '@cubenest/rrweb-core';
2
+ import type { ReportMeta } from './types.js';
3
+ /** Inputs for {@link writeReport}. */
4
+ export interface WriteReportInput {
5
+ /** Output directory (created if missing). */
6
+ outDir: string;
7
+ /** Worker/project id (e.g. WDIO `0-0` or a Playwright project name); namespaces the filename for parallel safety. */
8
+ cid?: string | undefined;
9
+ /** Captured rrweb event stream. */
10
+ events: eventWithTime[];
11
+ /** Report metadata (spec, title, status, error, browser, ...). */
12
+ meta: ReportMeta;
13
+ /** Render the report's "Generated by tracelane" footer. Default true. */
14
+ footer?: boolean | undefined;
15
+ }
16
+ /**
17
+ * Turn an arbitrary spec path / test title into a filesystem-safe slug:
18
+ * lowercase, non-alphanumerics collapsed to single dashes, trimmed, capped.
19
+ */
20
+ export declare function slugify(input: string): string;
21
+ /**
22
+ * Build a unique-ish report filename: `<spec>--<title>--<cid>-<ts>.html`. The
23
+ * timestamp + cid keep retries and parallel workers from overwriting each other.
24
+ */
25
+ export declare function reportFileName(meta: ReportMeta, cid?: string): string;
26
+ /**
27
+ * Slug for the spec segment: take the file's basename (so an absolute path like
28
+ * `/repo/test/login.spec.ts` doesn't bloat the filename), then strip the common
29
+ * test-file suffixes (`.spec.ts`, `.test.mts`, `.e2e.js`, …) so it slugifies to
30
+ * a clean `login`, not `login-spec`.
31
+ */
32
+ export declare function specSlug(spec: string): string;
33
+ /**
34
+ * Build the report HTML and write it under `outDir`, namespaced by `cid`.
35
+ * Returns the absolute-or-relative path written (as `join` produced it).
36
+ */
37
+ export declare function writeReport(input: WriteReportInput): string;
38
+ //# sourceMappingURL=report-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-writer.d.ts","sourceRoot":"","sources":["../src/report-writer.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,qHAAqH;IACrH,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,mCAAmC;IACnC,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,kEAAkE;IAClE,IAAI,EAAE,UAAU,CAAC;IACjB,yEAAyE;IACzE,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO7C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAS3D"}
@@ -0,0 +1,58 @@
1
+ // Write a self-contained HTML report to disk (ADR-0005 / ADR-0006).
2
+ //
3
+ // Given the captured event stream + metadata, call buildReport to produce the
4
+ // offline HTML string, then write it under `outDir`. Files are namespaced by
5
+ // `cid` (the adapter's worker/project id — e.g. the WDIO capability id or the
6
+ // Playwright project name) so parallel workers never collide (ADR-0006 action
7
+ // item #6). Lives in @tracelane/report so every adapter (WDIO, Playwright)
8
+ // shares one write path.
9
+ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
10
+ import { join } from 'node:path';
11
+ import { buildReport } from './build-report.js';
12
+ /**
13
+ * Turn an arbitrary spec path / test title into a filesystem-safe slug:
14
+ * lowercase, non-alphanumerics collapsed to single dashes, trimmed, capped.
15
+ */
16
+ export function slugify(input) {
17
+ const slug = input
18
+ .toLowerCase()
19
+ .replace(/[^a-z0-9]+/g, '-')
20
+ .replace(/^-+|-+$/g, '');
21
+ // Cap length so deeply-nested titles don't blow past filesystem name limits.
22
+ return (slug || 'report').slice(0, 120);
23
+ }
24
+ /**
25
+ * Build a unique-ish report filename: `<spec>--<title>--<cid>-<ts>.html`. The
26
+ * timestamp + cid keep retries and parallel workers from overwriting each other.
27
+ */
28
+ export function reportFileName(meta, cid) {
29
+ const specPart = meta.spec ? specSlug(meta.spec) : 'spec';
30
+ const titlePart = slugify(meta.title);
31
+ const cidPart = cid ? `${slugify(cid)}-` : '';
32
+ return `${specPart}--${titlePart}--${cidPart}${Date.now()}.html`;
33
+ }
34
+ /**
35
+ * Slug for the spec segment: take the file's basename (so an absolute path like
36
+ * `/repo/test/login.spec.ts` doesn't bloat the filename), then strip the common
37
+ * test-file suffixes (`.spec.ts`, `.test.mts`, `.e2e.js`, …) so it slugifies to
38
+ * a clean `login`, not `login-spec`.
39
+ */
40
+ export function specSlug(spec) {
41
+ const base = spec.replace(/^.*[/\\]/, '');
42
+ return slugify(base.replace(/(\.(spec|test|e2e|cy))?\.[cm]?[jt]sx?$/, ''));
43
+ }
44
+ /**
45
+ * Build the report HTML and write it under `outDir`, namespaced by `cid`.
46
+ * Returns the absolute-or-relative path written (as `join` produced it).
47
+ */
48
+ export function writeReport(input) {
49
+ const { outDir, cid, events, meta, footer } = input;
50
+ const html = buildReport(events, meta, footer === false ? { footer: false } : {});
51
+ if (!existsSync(outDir)) {
52
+ mkdirSync(outDir, { recursive: true });
53
+ }
54
+ const filePath = join(outDir, reportFileName(meta, cid));
55
+ writeFileSync(filePath, html);
56
+ return filePath;
57
+ }
58
+ //# sourceMappingURL=report-writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-writer.js","sourceRoot":"","sources":["../src/report-writer.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,yBAAyB;AAEzB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiBhD;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa;IACn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AE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAClF,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IACzD,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC9B,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tracelane/report",
3
- "version": "0.1.0-alpha.12",
3
+ "version": "0.1.0-alpha.13",
4
4
  "description": "Self-contained, offline HTML report builder for tracelane. Embeds the rrweb player and a gzipped event blob into a single .html file.",
5
5
  "keywords": [
6
6
  "tracelane",
@@ -35,7 +35,7 @@
35
35
  "fflate": "^0.8.2",
36
36
  "rrweb-player": "1.0.0-alpha.4",
37
37
  "@cubenest/rrweb-core": "0.1.0-alpha.5",
38
- "@tracelane/core": "0.1.0-alpha.10"
38
+ "@tracelane/core": "0.1.0-alpha.11"
39
39
  },
40
40
  "devDependencies": {
41
41
  "jsdom": "^25.0.1"