@open-qa/qa-replay 0.0.0-stage → 0.1.0-alpha.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/LICENSE +204 -0
- package/NOTICE +7 -0
- package/THIRD_PARTY.md +13 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/package.json +61 -4
- package/src/cursor.css +8 -0
- package/src/index.d.ts +25 -0
- package/src/index.js +30 -0
- package/src/isolated-surface.d.ts +4 -0
- package/src/isolated-surface.js +55 -0
- package/src/multi-view.d.ts +41 -0
- package/src/multi-view.js +85 -0
- package/src/player.d.ts +21 -0
- package/src/player.js +145 -0
- package/src/resources.d.ts +10 -0
- package/src/resources.js +33 -0
- package/src/selection.d.ts +7 -0
- package/src/selection.js +33 -0
- package/src/style.d.ts +2 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Copyright 2026 Corvo AI (酷沃科技股份有限公司)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Apache License
|
|
5
|
+
Version 2.0, January 2004
|
|
6
|
+
http://www.apache.org/licenses/
|
|
7
|
+
|
|
8
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
9
|
+
|
|
10
|
+
1. Definitions.
|
|
11
|
+
|
|
12
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
13
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
14
|
+
|
|
15
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
16
|
+
the copyright owner that is granting the License.
|
|
17
|
+
|
|
18
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
19
|
+
other entities that control, are controlled by, or are under common
|
|
20
|
+
control with that entity. For the purposes of this definition,
|
|
21
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
22
|
+
direction or management of such entity, whether by contract or
|
|
23
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
24
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
25
|
+
|
|
26
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
27
|
+
exercising permissions granted by this License.
|
|
28
|
+
|
|
29
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
30
|
+
including but not limited to software source code, documentation
|
|
31
|
+
source, and configuration files.
|
|
32
|
+
|
|
33
|
+
"Object" form shall mean any form resulting from mechanical
|
|
34
|
+
transformation or translation of a Source form, including but
|
|
35
|
+
not limited to compiled object code, generated documentation,
|
|
36
|
+
and conversions to other media types.
|
|
37
|
+
|
|
38
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
39
|
+
Object form, made available under the License, as indicated by a
|
|
40
|
+
copyright notice that is included in or attached to the work
|
|
41
|
+
(an example is provided in the Appendix below).
|
|
42
|
+
|
|
43
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
44
|
+
form, that is based on (or derived from) the Work and for which the
|
|
45
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
46
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
47
|
+
of this License, Derivative Works shall not include works that remain
|
|
48
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
49
|
+
the Work and Derivative Works thereof.
|
|
50
|
+
|
|
51
|
+
"Contribution" shall mean any work of authorship, including
|
|
52
|
+
the original version of the Work and any modifications or additions
|
|
53
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
54
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
55
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
56
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
57
|
+
means any form of electronic, verbal, or written communication sent
|
|
58
|
+
to the Licensor or its representatives, including but not limited to
|
|
59
|
+
communication on electronic mailing lists, source code control systems,
|
|
60
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
61
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
62
|
+
excluding communication that is conspicuously marked or otherwise
|
|
63
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
64
|
+
|
|
65
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
66
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
67
|
+
subsequently incorporated within the Work.
|
|
68
|
+
|
|
69
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
70
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
71
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
72
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
73
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
74
|
+
Work and such Derivative Works in Source or Object form.
|
|
75
|
+
|
|
76
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
77
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
78
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
79
|
+
(except as stated in this section) patent license to make, have made,
|
|
80
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
81
|
+
where such license applies only to those patent claims licensable
|
|
82
|
+
by such Contributor that are necessarily infringed by their
|
|
83
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
84
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
85
|
+
institute patent litigation against any entity (including a
|
|
86
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
87
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
88
|
+
or contributory patent infringement, then any patent licenses
|
|
89
|
+
granted to You under this License for that Work shall terminate
|
|
90
|
+
as of the date such litigation is filed.
|
|
91
|
+
|
|
92
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
93
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
94
|
+
modifications, and in Source or Object form, provided that You
|
|
95
|
+
meet the following conditions:
|
|
96
|
+
|
|
97
|
+
(a) You must give any other recipients of the Work or
|
|
98
|
+
Derivative Works a copy of this License; and
|
|
99
|
+
|
|
100
|
+
(b) You must cause any modified files to carry prominent notices
|
|
101
|
+
stating that You changed the files; and
|
|
102
|
+
|
|
103
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
104
|
+
that You distribute, all copyright, patent, trademark, and
|
|
105
|
+
attribution notices from the Source form of the Work,
|
|
106
|
+
excluding those notices that do not pertain to any part of
|
|
107
|
+
the Derivative Works; and
|
|
108
|
+
|
|
109
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
110
|
+
distribution, then any Derivative Works that You distribute must
|
|
111
|
+
include a readable copy of the attribution notices contained
|
|
112
|
+
within such NOTICE file, excluding those notices that do not
|
|
113
|
+
pertain to any part of the Derivative Works, in at least one
|
|
114
|
+
of the following places: within a NOTICE text file distributed
|
|
115
|
+
as part of the Derivative Works; within the Source form or
|
|
116
|
+
documentation, if provided along with the Derivative Works; or,
|
|
117
|
+
within a display generated by the Derivative Works, if and
|
|
118
|
+
wherever such third-party notices normally appear. The contents
|
|
119
|
+
of the NOTICE file are for informational purposes only and
|
|
120
|
+
do not modify the License. You may add Your own attribution
|
|
121
|
+
notices within Derivative Works that You distribute, alongside
|
|
122
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
123
|
+
that such additional attribution notices cannot be construed
|
|
124
|
+
as modifying the License.
|
|
125
|
+
|
|
126
|
+
You may add Your own copyright statement to Your modifications and
|
|
127
|
+
may provide additional or different license terms and conditions
|
|
128
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
129
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
130
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
131
|
+
the conditions stated in this License.
|
|
132
|
+
|
|
133
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
134
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
135
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
136
|
+
this License, without any additional terms or conditions.
|
|
137
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
138
|
+
the terms of any separate license agreement you may have executed
|
|
139
|
+
with Licensor regarding such Contributions.
|
|
140
|
+
|
|
141
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
142
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
143
|
+
except as required for reasonable and customary use in describing the
|
|
144
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
145
|
+
|
|
146
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
147
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
148
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
149
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
150
|
+
implied, including, without limitation, any warranties or conditions
|
|
151
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
152
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
153
|
+
appropriateness of using or redistributing the Work and assume any
|
|
154
|
+
risks associated with Your exercise of permissions under this License.
|
|
155
|
+
|
|
156
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
157
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
158
|
+
unless required by applicable law (such as deliberate and grossly
|
|
159
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
160
|
+
liable to You for damages, including any direct, indirect, special,
|
|
161
|
+
incidental, or consequential damages of any character arising as a
|
|
162
|
+
result of this License or out of the use or inability to use the
|
|
163
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
164
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
165
|
+
other commercial damages or losses), even if such Contributor
|
|
166
|
+
has been advised of the possibility of such damages.
|
|
167
|
+
|
|
168
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
169
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
170
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
171
|
+
or other liability obligations and/or rights consistent with this
|
|
172
|
+
License. However, in accepting such obligations, You may act only
|
|
173
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
174
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
175
|
+
defend, and hold each Contributor harmless for any liability
|
|
176
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
177
|
+
of your accepting any such warranty or additional liability.
|
|
178
|
+
|
|
179
|
+
END OF TERMS AND CONDITIONS
|
|
180
|
+
|
|
181
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
182
|
+
|
|
183
|
+
To apply the Apache License to your work, attach the following
|
|
184
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
185
|
+
replaced with your own identifying information. (Don't include
|
|
186
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
187
|
+
comment syntax for the file format. We also recommend that a
|
|
188
|
+
file or class name and description of purpose be included on the
|
|
189
|
+
same "printed page" as the copyright notice for easier
|
|
190
|
+
identification within third-party archives.
|
|
191
|
+
|
|
192
|
+
Copyright [yyyy] [name of copyright owner]
|
|
193
|
+
|
|
194
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
195
|
+
you may not use this file except in compliance with the License.
|
|
196
|
+
You may obtain a copy of the License at
|
|
197
|
+
|
|
198
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
199
|
+
|
|
200
|
+
Unless required by applicable law or agreed to in writing, software
|
|
201
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
202
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
203
|
+
See the License for the specific language governing permissions and
|
|
204
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
open-qa
|
|
2
|
+
Copyright 2026 Corvo AI (酷沃科技股份有限公司)
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0.
|
|
5
|
+
Third-party components retain their own copyright and license notices.
|
|
6
|
+
See THIRD_PARTY.md and THIRD_PARTY_NOTICES.md in package distributions,
|
|
7
|
+
and apps/qa/scripts/distribution-notices.md in source distributions.
|
package/THIRD_PARTY.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
| Material | Retained notice |
|
|
4
|
+
| -------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
5
|
+
| Studio UI primitives (shadcn/ui) | apps/qa-studio/src/ui/SHADCN-LICENSE.txt (MIT); src/ui/SHADCN-LICENSE.txt in the Studio package |
|
|
6
|
+
| Geist test fonts | Adjacent LICENSE.txt (SIL OFL) |
|
|
7
|
+
| Bundled dependencies and runtime fonts | Dependency package LICENSE/NOTICE files inside the Studio runtime archive |
|
|
8
|
+
| rrweb report runtime | Inline legal notices in the generated report bundle |
|
|
9
|
+
|
|
10
|
+
Registry dependencies retain their respective licenses. Source provenance and
|
|
11
|
+
synthetic media reproduction steps are recorded in SOURCE.json and
|
|
12
|
+
apps/qa/docs/public-fixtures.md. Installed dependency inventory is provided as
|
|
13
|
+
CycloneDX SBOM evidence alongside release artifacts.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# open-qa distribution sources and notices
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Corvo AI (酷沃科技股份有限公司). Licensed under Apache-2.0.
|
|
4
|
+
The Gmail adapter and QA status vocabulary originate in the Corvo project.
|
|
5
|
+
Each host maintains its own copy to preserve the stage/CLI boundary.
|
|
6
|
+
|
|
7
|
+
Studio includes shadcn/ui primitives under MIT, with the full notice in
|
|
8
|
+
src/ui/SHADCN-LICENSE.txt. Its standalone archive retains dependency package
|
|
9
|
+
metadata, licenses and Geist font assets selected by Next's tracer. Registry
|
|
10
|
+
dependencies retain their own licenses. Report bundling preserves inline legal
|
|
11
|
+
notices from rrweb. See LICENSE, NOTICE and THIRD_PARTY.md.
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-qa/qa-replay",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": false,
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.23.4 <23"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"scripts",
|
|
13
|
+
"drizzle",
|
|
14
|
+
"problem-matcher.json",
|
|
15
|
+
"runtime",
|
|
16
|
+
"studio-manifest.json",
|
|
17
|
+
"THIRD_PARTY_NOTICES.md",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"NOTICE",
|
|
20
|
+
"THIRD_PARTY.md"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
"./isolated-surface": {
|
|
24
|
+
"types": "./src/isolated-surface.d.ts",
|
|
25
|
+
"import": "./src/isolated-surface.js",
|
|
26
|
+
"default": "./src/isolated-surface.js"
|
|
27
|
+
},
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./src/index.d.ts",
|
|
30
|
+
"import": "./src/index.js",
|
|
31
|
+
"default": "./src/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./player": {
|
|
34
|
+
"types": "./src/player.d.ts",
|
|
35
|
+
"import": "./src/player.js",
|
|
36
|
+
"default": "./src/player.js"
|
|
37
|
+
},
|
|
38
|
+
"./resources": {
|
|
39
|
+
"types": "./src/resources.d.ts",
|
|
40
|
+
"import": "./src/resources.js",
|
|
41
|
+
"default": "./src/resources.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@open-qa/qa-engine": "0.1.0-alpha.0",
|
|
46
|
+
"@rrweb/replay": "2.1.7"
|
|
47
|
+
},
|
|
48
|
+
"os": [
|
|
49
|
+
"linux"
|
|
50
|
+
],
|
|
51
|
+
"cpu": [
|
|
52
|
+
"x64"
|
|
53
|
+
],
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/Corvo-hq/open-qa.git"
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public",
|
|
60
|
+
"registry": "https://registry.npmjs.org/",
|
|
61
|
+
"provenance": true
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/cursor.css
ADDED
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReplayEvent, ReplayIndex, ReplayManifest } from "@open-qa/qa-engine/protocol";
|
|
2
|
+
import type { ViewTimeline } from "./multi-view.js";
|
|
3
|
+
export * from "./multi-view.js";
|
|
4
|
+
export interface ReplayView {
|
|
5
|
+
timeline?: ViewTimeline;
|
|
6
|
+
index: ReplayIndex;
|
|
7
|
+
blocks: Record<string, ReplayEvent[]>;
|
|
8
|
+
offset: number;
|
|
9
|
+
viewport: {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ReplayBundle {
|
|
15
|
+
manifest: ReplayManifest | null;
|
|
16
|
+
views: ReplayView[];
|
|
17
|
+
warnings: string[];
|
|
18
|
+
}
|
|
19
|
+
export declare function runTime(view: ReplayView, row: ReplayEvent): number;
|
|
20
|
+
export declare function replayWindow(view: ReplayView, t: number, playing?: boolean): {
|
|
21
|
+
timestamp: number;
|
|
22
|
+
type: number;
|
|
23
|
+
data: import("zod").JSONType;
|
|
24
|
+
}[];
|
|
25
|
+
export { replaySelection, REPLAY_BUDGET } from "./selection.js";
|
package/src/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export * from "./multi-view.js";
|
|
2
|
+
function runTime(view, row) {
|
|
3
|
+
const calibration = view.index.calibrations.findLast((entry) => entry.seq <= row.seq);
|
|
4
|
+
return view.offset + (calibration ? row.event.timestamp - calibration.browserTime + calibration.t : row.t);
|
|
5
|
+
}
|
|
6
|
+
function replayWindow(view, t, playing = false) {
|
|
7
|
+
const checkpoints = view.index.checkpoints.filter((checkpoint2) => {
|
|
8
|
+
const row = view.blocks[checkpoint2.snapshot.block]?.find(
|
|
9
|
+
(row2) => row2.seq === checkpoint2.snapshot.seq
|
|
10
|
+
);
|
|
11
|
+
return row && runTime(view, row) <= t;
|
|
12
|
+
});
|
|
13
|
+
const checkpoint = checkpoints.at(-1);
|
|
14
|
+
if (!checkpoint) return [];
|
|
15
|
+
const first = view.index.blocks.findIndex((block) => block.path === checkpoint.meta.block);
|
|
16
|
+
const rows = [];
|
|
17
|
+
for (const block of view.index.blocks.slice(first)) {
|
|
18
|
+
const entries = view.blocks[block.path] ?? [];
|
|
19
|
+
rows.push(...entries.filter((row) => row.seq >= checkpoint.meta.seq));
|
|
20
|
+
if (!playing && entries.some((row) => runTime(view, row) >= t)) break;
|
|
21
|
+
}
|
|
22
|
+
return rows.map((row) => ({ ...row.event, timestamp: Math.max(0, runTime(view, row)) }));
|
|
23
|
+
}
|
|
24
|
+
import { replaySelection, REPLAY_BUDGET } from "./selection.js";
|
|
25
|
+
export {
|
|
26
|
+
REPLAY_BUDGET,
|
|
27
|
+
replaySelection,
|
|
28
|
+
replayWindow,
|
|
29
|
+
runTime
|
|
30
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** rrweb's nested iframe cannot be read from an opaque-origin sandbox. Use a
|
|
2
|
+
* detached document facade backed by a shadow root inside that sandbox instead.
|
|
3
|
+
* No recorded node enters the host application document. */
|
|
4
|
+
export declare function inIsolatedSurface<T>(operation: () => T): T;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function inIsolatedSurface(operation) {
|
|
2
|
+
const create = document.createElement.bind(document);
|
|
3
|
+
let used = false;
|
|
4
|
+
document.createElement = ((tag, options) => {
|
|
5
|
+
if (tag.toLowerCase() !== "iframe" || used) return create(tag, options);
|
|
6
|
+
used = true;
|
|
7
|
+
const surface = create("div"), shadow = surface.attachShadow({ mode: "open" });
|
|
8
|
+
surface.dataset.rrwebSurface = "";
|
|
9
|
+
surface.style.overflow = "hidden";
|
|
10
|
+
const detached = document.implementation.createHTMLDocument("");
|
|
11
|
+
shadow.appendChild(detached.documentElement.cloneNode(true));
|
|
12
|
+
const doc = new Proxy(detached, {
|
|
13
|
+
get(target, key) {
|
|
14
|
+
if (key === "defaultView") return null;
|
|
15
|
+
if (key === "documentElement") return shadow.querySelector("html");
|
|
16
|
+
if (key === "head" || key === "body") return shadow.querySelector(key);
|
|
17
|
+
if (key === "childNodes" || key === "firstChild" || key === "lastChild") return shadow[key];
|
|
18
|
+
if (key === "scrollingElement") return surface;
|
|
19
|
+
if (key === "open") return () => shadow.replaceChildren();
|
|
20
|
+
if (key === "close" || key === "write") return () => {
|
|
21
|
+
};
|
|
22
|
+
if (key === "appendChild")
|
|
23
|
+
return (node) => node.nodeType === 10 ? node : shadow.appendChild(node);
|
|
24
|
+
if (key === "removeChild") return shadow.removeChild.bind(shadow);
|
|
25
|
+
if (key === "getElementById") return shadow.getElementById.bind(shadow);
|
|
26
|
+
if (key === "getElementsByTagName") return (tag2) => shadow.querySelectorAll(tag2);
|
|
27
|
+
if (key === "querySelector" || key === "querySelectorAll" || key === "contains")
|
|
28
|
+
return shadow[key].bind(shadow);
|
|
29
|
+
const value = Reflect.get(target, key, target);
|
|
30
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const localWindow = new Proxy(window, {
|
|
34
|
+
get(target, key) {
|
|
35
|
+
if (key === "document") return doc;
|
|
36
|
+
if (key === "scrollTo") return surface.scrollTo.bind(surface);
|
|
37
|
+
const value = Reflect.get(target, key, target);
|
|
38
|
+
return typeof value === "function" && !/^[A-Z]/.test(String(key)) ? value.bind(target) : value;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperties(surface, {
|
|
42
|
+
contentDocument: { value: doc },
|
|
43
|
+
contentWindow: { value: localWindow }
|
|
44
|
+
});
|
|
45
|
+
return surface;
|
|
46
|
+
});
|
|
47
|
+
try {
|
|
48
|
+
return operation();
|
|
49
|
+
} finally {
|
|
50
|
+
document.createElement = create;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
inIsolatedSurface
|
|
55
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RunEvent } from "@open-qa/qa-engine/protocol";
|
|
2
|
+
export interface CursorPoint {
|
|
3
|
+
t: number;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
click: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ViewTimeline {
|
|
9
|
+
actor: string | null;
|
|
10
|
+
type: "page" | "rendered" | null;
|
|
11
|
+
openedAt: number;
|
|
12
|
+
closedAt: number | null;
|
|
13
|
+
cursors: CursorPoint[];
|
|
14
|
+
}
|
|
15
|
+
export declare function viewTimeline(events: readonly RunEvent[], view: string): ViewTimeline;
|
|
16
|
+
export declare function actorRows<T extends {
|
|
17
|
+
actor: string | null;
|
|
18
|
+
}>(views: readonly T[]): T[][];
|
|
19
|
+
export declare function cursorAt(points: readonly CursorPoint[], t: number): {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
click: boolean;
|
|
23
|
+
} | null;
|
|
24
|
+
export interface ReplayAdapter {
|
|
25
|
+
seek(t: number, playing?: boolean): void;
|
|
26
|
+
advance(t: number): void;
|
|
27
|
+
setSpeed(speed: number): void;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class ReplayGroup implements ReplayAdapter {
|
|
31
|
+
private readonly players;
|
|
32
|
+
private readonly onError;
|
|
33
|
+
private readonly failed;
|
|
34
|
+
private speed;
|
|
35
|
+
constructor(players: readonly ReplayAdapter[], onError: (index: number) => void);
|
|
36
|
+
private each;
|
|
37
|
+
seek(t: number, playing?: boolean): void;
|
|
38
|
+
advance(t: number): void;
|
|
39
|
+
setSpeed(speed: number): void;
|
|
40
|
+
destroy(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function viewTimeline(events, view) {
|
|
2
|
+
const rows = events.filter((e) => e.view === view);
|
|
3
|
+
const opened = rows.find((e) => e.kind === "view_opened");
|
|
4
|
+
return {
|
|
5
|
+
actor: opened?.actor ?? rows.find((e) => e.actor)?.actor ?? null,
|
|
6
|
+
type: opened?.type ?? null,
|
|
7
|
+
openedAt: opened?.t ?? 0,
|
|
8
|
+
closedAt: rows.find((e) => e.kind === "view_closed")?.t ?? null,
|
|
9
|
+
cursors: rows.flatMap((e) => {
|
|
10
|
+
if (e.kind !== "action" || !e.target) return [];
|
|
11
|
+
const target = e.target;
|
|
12
|
+
const point = target.point ?? (target.layer === "pixel" ? {
|
|
13
|
+
x: target.x * target.viewport.width / target.image.width,
|
|
14
|
+
y: target.y * target.viewport.height / target.image.height
|
|
15
|
+
} : void 0);
|
|
16
|
+
return point ? [{ t: e.t, ...point, click: /click|tap|press/i.test(e.tool) }] : [];
|
|
17
|
+
})
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function actorRows(views) {
|
|
21
|
+
const rows = /* @__PURE__ */ new Map();
|
|
22
|
+
for (const view of views) rows.set(view.actor, [...rows.get(view.actor) ?? [], view]);
|
|
23
|
+
const observers = rows.get(null);
|
|
24
|
+
rows.delete(null);
|
|
25
|
+
return [...rows.values(), ...observers ? [observers] : []];
|
|
26
|
+
}
|
|
27
|
+
function cursorAt(points, t) {
|
|
28
|
+
const i = points.findLastIndex((p) => p.t <= t);
|
|
29
|
+
if (i < 0) return null;
|
|
30
|
+
const previous = points[i], next = points[i + 1];
|
|
31
|
+
const fraction = next ? Math.min(1, Math.max(0, (t - previous.t) / (next.t - previous.t))) : 0;
|
|
32
|
+
return {
|
|
33
|
+
x: previous.x + ((next?.x ?? previous.x) - previous.x) * fraction,
|
|
34
|
+
y: previous.y + ((next?.y ?? previous.y) - previous.y) * fraction,
|
|
35
|
+
click: previous.click && t - previous.t < 250
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
class ReplayGroup {
|
|
39
|
+
constructor(players, onError) {
|
|
40
|
+
this.players = players;
|
|
41
|
+
this.onError = onError;
|
|
42
|
+
}
|
|
43
|
+
players;
|
|
44
|
+
onError;
|
|
45
|
+
failed = /* @__PURE__ */ new Set();
|
|
46
|
+
speed = 1;
|
|
47
|
+
each(action) {
|
|
48
|
+
this.players.forEach((player, i) => {
|
|
49
|
+
if (this.failed.has(player)) return;
|
|
50
|
+
try {
|
|
51
|
+
action(player);
|
|
52
|
+
} catch {
|
|
53
|
+
this.failed.add(player);
|
|
54
|
+
try {
|
|
55
|
+
player.destroy();
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
this.onError(i);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
seek(t, playing = false) {
|
|
63
|
+
this.failed.clear();
|
|
64
|
+
this.each((p) => {
|
|
65
|
+
p.setSpeed(this.speed);
|
|
66
|
+
p.seek(t, playing);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
advance(t) {
|
|
70
|
+
this.each((p) => p.advance(t));
|
|
71
|
+
}
|
|
72
|
+
setSpeed(speed) {
|
|
73
|
+
this.speed = speed;
|
|
74
|
+
this.each((p) => p.setSpeed(speed));
|
|
75
|
+
}
|
|
76
|
+
destroy() {
|
|
77
|
+
this.each((p) => p.destroy());
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
ReplayGroup,
|
|
82
|
+
actorRows,
|
|
83
|
+
cursorAt,
|
|
84
|
+
viewTimeline
|
|
85
|
+
};
|
package/src/player.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "@rrweb/replay/dist/style.css";
|
|
2
|
+
import "./cursor.css";
|
|
3
|
+
import { type ReplayView } from "./index.js";
|
|
4
|
+
export declare class ViewPlayer {
|
|
5
|
+
private readonly root;
|
|
6
|
+
private readonly view;
|
|
7
|
+
private player?;
|
|
8
|
+
private speed;
|
|
9
|
+
private resize;
|
|
10
|
+
private firstTime;
|
|
11
|
+
private closed;
|
|
12
|
+
private readonly points;
|
|
13
|
+
private cursor?;
|
|
14
|
+
constructor(root: HTMLElement, view: ReplayView);
|
|
15
|
+
seek(t: number, playing?: boolean): void;
|
|
16
|
+
advance(t: number): void;
|
|
17
|
+
private drawCursor;
|
|
18
|
+
setSpeed(speed: number): void;
|
|
19
|
+
private fit;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
}
|
package/src/player.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Replayer } from "@rrweb/replay";
|
|
2
|
+
import "@rrweb/replay/dist/style.css";
|
|
3
|
+
import "./cursor.css";
|
|
4
|
+
import { replayWindow, runTime, cursorAt } from "./index.js";
|
|
5
|
+
class ViewPlayer {
|
|
6
|
+
constructor(root, view) {
|
|
7
|
+
this.root = root;
|
|
8
|
+
this.view = view;
|
|
9
|
+
const native = Object.values(view.blocks).flat().flatMap((row) => {
|
|
10
|
+
const d = row.event.data;
|
|
11
|
+
if (row.event.type !== 3 || !d || typeof d !== "object" || Array.isArray(d)) return [];
|
|
12
|
+
if (d.source === 1 && Array.isArray(d.positions))
|
|
13
|
+
return d.positions.flatMap(
|
|
14
|
+
(p) => p && typeof p === "object" && !Array.isArray(p) && typeof p.x === "number" && typeof p.y === "number" && typeof p.timeOffset === "number" ? [{ t: runTime(view, row) + p.timeOffset, x: p.x, y: p.y, click: false }] : []
|
|
15
|
+
);
|
|
16
|
+
if (d.source === 2 && typeof d.x === "number" && typeof d.y === "number")
|
|
17
|
+
return [{ t: runTime(view, row), x: d.x, y: d.y, click: d.type === 2 }];
|
|
18
|
+
return [];
|
|
19
|
+
}).sort((a, b) => a.t - b.t);
|
|
20
|
+
this.points = [
|
|
21
|
+
...native,
|
|
22
|
+
...(view.timeline?.cursors ?? []).filter(
|
|
23
|
+
(p, i, points) => !native.some((n) => n.t >= (points[i - 1]?.t ?? p.t - 250) && n.t <= p.t)
|
|
24
|
+
)
|
|
25
|
+
].sort((a, b) => a.t - b.t);
|
|
26
|
+
this.resize = new ResizeObserver(() => this.fit());
|
|
27
|
+
this.resize.observe(root);
|
|
28
|
+
}
|
|
29
|
+
root;
|
|
30
|
+
view;
|
|
31
|
+
player;
|
|
32
|
+
speed = 1;
|
|
33
|
+
resize;
|
|
34
|
+
firstTime = 0;
|
|
35
|
+
closed = false;
|
|
36
|
+
points;
|
|
37
|
+
cursor;
|
|
38
|
+
seek(t, playing = false) {
|
|
39
|
+
this.resize.observe(this.root);
|
|
40
|
+
const timeline = this.view.timeline;
|
|
41
|
+
if (timeline && t < timeline.openedAt) {
|
|
42
|
+
this.player?.destroy();
|
|
43
|
+
this.player = void 0;
|
|
44
|
+
this.root.textContent = "Not opened yet";
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this.closed = timeline?.closedAt != null && t >= timeline.closedAt;
|
|
48
|
+
if (this.closed) {
|
|
49
|
+
t = timeline.closedAt;
|
|
50
|
+
playing = false;
|
|
51
|
+
}
|
|
52
|
+
this.player?.destroy();
|
|
53
|
+
this.player = void 0;
|
|
54
|
+
this.root.replaceChildren();
|
|
55
|
+
this.cursor = void 0;
|
|
56
|
+
const events = replayWindow(this.view, t, playing);
|
|
57
|
+
if (events.length < 2) {
|
|
58
|
+
this.root.textContent = "Waiting for recording";
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.player = new Replayer(events, {
|
|
62
|
+
root: this.root,
|
|
63
|
+
useVirtualDom: false,
|
|
64
|
+
showWarning: false,
|
|
65
|
+
showDebug: false,
|
|
66
|
+
UNSAFE_replayCanvas: false,
|
|
67
|
+
mouseTail: true,
|
|
68
|
+
skipInactive: false,
|
|
69
|
+
loadTimeout: 0,
|
|
70
|
+
speed: this.speed
|
|
71
|
+
});
|
|
72
|
+
const offset = Math.max(0, t - events[0].timestamp) + 0.01;
|
|
73
|
+
this.firstTime = events[0].timestamp;
|
|
74
|
+
if (playing) this.player.play(offset);
|
|
75
|
+
else this.player.pause(offset);
|
|
76
|
+
this.fit();
|
|
77
|
+
const wrapper = this.root.querySelector(".replayer-wrapper");
|
|
78
|
+
if (wrapper) {
|
|
79
|
+
for (const mouse of wrapper.querySelectorAll(".replayer-mouse"))
|
|
80
|
+
mouse.style.visibility = "hidden";
|
|
81
|
+
this.cursor = document.createElement("div");
|
|
82
|
+
this.cursor.className = "replayer-mouse open-qa-cursor";
|
|
83
|
+
this.cursor.setAttribute("aria-hidden", "true");
|
|
84
|
+
wrapper.append(this.cursor);
|
|
85
|
+
this.drawCursor(t);
|
|
86
|
+
}
|
|
87
|
+
if (this.closed) {
|
|
88
|
+
const label = document.createElement("p");
|
|
89
|
+
label.textContent = "View ended";
|
|
90
|
+
label.style.cssText = "position:absolute;bottom:0;left:0;margin:0;padding:4px 8px;background:Canvas;color:CanvasText";
|
|
91
|
+
this.root.style.position = "relative";
|
|
92
|
+
this.root.append(label);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
advance(t) {
|
|
96
|
+
if (this.view.timeline?.closedAt != null && t >= this.view.timeline.closedAt) {
|
|
97
|
+
if (!this.closed) this.seek(this.view.timeline.closedAt, false);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (!this.player) this.seek(t, true);
|
|
101
|
+
else if (Math.abs(this.firstTime + this.player.getCurrentTime() - t) > 100) this.seek(t, true);
|
|
102
|
+
this.drawCursor(t);
|
|
103
|
+
}
|
|
104
|
+
drawCursor(t) {
|
|
105
|
+
if (!this.cursor) return;
|
|
106
|
+
const point = cursorAt(this.points, t);
|
|
107
|
+
this.cursor.hidden = !point;
|
|
108
|
+
if (point) {
|
|
109
|
+
this.cursor.style.left = `${point.x}px`;
|
|
110
|
+
this.cursor.style.top = `${point.y}px`;
|
|
111
|
+
this.cursor.classList.toggle("active", point.click);
|
|
112
|
+
this.cursor.dataset.click = String(point.click);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
setSpeed(speed) {
|
|
116
|
+
this.speed = speed;
|
|
117
|
+
this.player?.setConfig({ speed });
|
|
118
|
+
}
|
|
119
|
+
fit() {
|
|
120
|
+
const wrapper = this.root.querySelector(".replayer-wrapper");
|
|
121
|
+
const frame = this.root.querySelector("iframe, [data-rrweb-surface]");
|
|
122
|
+
if (!wrapper || !frame) return;
|
|
123
|
+
const width = Number(frame.width) || this.view.viewport.width;
|
|
124
|
+
const height = Number(frame.height) || this.view.viewport.height;
|
|
125
|
+
if (frame.hasAttribute("data-rrweb-surface")) {
|
|
126
|
+
frame.style.width = `${width}px`;
|
|
127
|
+
frame.style.height = `${height}px`;
|
|
128
|
+
}
|
|
129
|
+
const scale = Math.min(1, this.root.clientWidth / width);
|
|
130
|
+
wrapper.style.transformOrigin = "top left";
|
|
131
|
+
wrapper.style.transform = `scale(${scale})`;
|
|
132
|
+
this.root.style.height = `${height * scale}px`;
|
|
133
|
+
}
|
|
134
|
+
destroy() {
|
|
135
|
+
try {
|
|
136
|
+
this.player?.destroy();
|
|
137
|
+
} finally {
|
|
138
|
+
this.player = void 0;
|
|
139
|
+
this.resize.disconnect();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export {
|
|
144
|
+
ViewPlayer
|
|
145
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RrwebEvent } from "@open-qa/qa-engine/protocol";
|
|
2
|
+
export type ReportAssets = Record<string, {
|
|
3
|
+
mime: string;
|
|
4
|
+
content: string;
|
|
5
|
+
css: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function materializeResources(resources: ReportAssets): {
|
|
8
|
+
rewrite: (event: RrwebEvent) => RrwebEvent;
|
|
9
|
+
destroy: () => void;
|
|
10
|
+
};
|
package/src/resources.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function materializeResources(resources) {
|
|
2
|
+
const urls = /* @__PURE__ */ new Map();
|
|
3
|
+
const active = /* @__PURE__ */ new Set();
|
|
4
|
+
const replace = (value) => value.replace(/open-qa-asset:\d+/g, address);
|
|
5
|
+
function address(key) {
|
|
6
|
+
const cached = urls.get(key);
|
|
7
|
+
if (cached) return cached;
|
|
8
|
+
const resource = resources[key];
|
|
9
|
+
if (!resource || active.has(key)) return "data:,";
|
|
10
|
+
active.add(key);
|
|
11
|
+
const body = resource.css ? replace(resource.content) : Uint8Array.from(atob(resource.content), (char) => char.charCodeAt(0));
|
|
12
|
+
const url = URL.createObjectURL(new Blob([body], { type: resource.mime }));
|
|
13
|
+
urls.set(key, url);
|
|
14
|
+
active.delete(key);
|
|
15
|
+
return url;
|
|
16
|
+
}
|
|
17
|
+
function visit(value) {
|
|
18
|
+
if (typeof value === "string") return replace(value);
|
|
19
|
+
if (Array.isArray(value)) return value.map(visit);
|
|
20
|
+
if (value && typeof value === "object")
|
|
21
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, visit(entry)]));
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
rewrite: (event) => visit(event),
|
|
26
|
+
destroy: () => {
|
|
27
|
+
for (const url of urls.values()) URL.revokeObjectURL(url);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
materializeResources
|
|
33
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReplayIndex } from "@open-qa/qa-engine/protocol";
|
|
2
|
+
export declare const REPLAY_BUDGET: number;
|
|
3
|
+
type SelectionIndex = Pick<ReplayIndex, "calibrations" | "checkpoints"> & {
|
|
4
|
+
blocks: Pick<ReplayIndex["blocks"][number], "path" | "t" | "seq" | "rawBytes" | "timestamp">[];
|
|
5
|
+
};
|
|
6
|
+
export declare function replaySelection(index: SelectionIndex, t: number, offset: number, playing: boolean): number[];
|
|
7
|
+
export {};
|
package/src/selection.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const REPLAY_BUDGET = 32 * 1024 * 1024;
|
|
2
|
+
function replaySelection(index, t, offset, playing) {
|
|
3
|
+
const stage = t - offset;
|
|
4
|
+
const upper = (block) => {
|
|
5
|
+
const calibrations = index.calibrations.filter((c) => c.seq <= block.seq.last);
|
|
6
|
+
const active = calibrations.findLast((c) => c.seq <= block.seq.first);
|
|
7
|
+
const relevant = [
|
|
8
|
+
...active ? [active] : [],
|
|
9
|
+
...calibrations.filter((c) => c.seq > block.seq.first)
|
|
10
|
+
];
|
|
11
|
+
return relevant.length ? Math.max(...relevant.map((c) => block.timestamp.last - c.browserTime + c.t)) : block.t.last;
|
|
12
|
+
};
|
|
13
|
+
const checkpoint = index.checkpoints.findLast((p) => {
|
|
14
|
+
const block = index.blocks.find((b) => b.path === p.snapshot.block);
|
|
15
|
+
return block && upper(block) <= stage;
|
|
16
|
+
}) ?? index.checkpoints[0];
|
|
17
|
+
if (!checkpoint) return [];
|
|
18
|
+
const first = index.blocks.findIndex((b) => b.path === checkpoint.meta.block);
|
|
19
|
+
if (first < 0) throw new Error("Recording unavailable");
|
|
20
|
+
const through = index.blocks.findIndex((b, n) => n >= first && upper(b) >= stage);
|
|
21
|
+
const last = Math.min(
|
|
22
|
+
index.blocks.length - 1,
|
|
23
|
+
(through < 0 ? index.blocks.length - 1 : Math.max(first, through)) + (playing ? 1 : 0)
|
|
24
|
+
);
|
|
25
|
+
const selected = index.blocks.slice(first, last + 1);
|
|
26
|
+
if (selected.reduce((n, b) => n + b.rawBytes, 0) > REPLAY_BUDGET)
|
|
27
|
+
throw new Error("Recording too large");
|
|
28
|
+
return selected.map((_, n) => n + first);
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
REPLAY_BUDGET,
|
|
32
|
+
replaySelection
|
|
33
|
+
};
|
package/src/style.d.ts
ADDED
package/README.md
DELETED