playwright-performance-regression 1.0.1 → 1.1.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.
@@ -1,68 +0,0 @@
1
- // src/registry/index.ts
2
- var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("pw-perf.registry");
3
- function slot() {
4
- const global = globalThis;
5
- let current = global[REGISTRY_KEY];
6
- if (current === void 0) {
7
- current = {
8
- state: void 0,
9
- wrappedTests: /* @__PURE__ */ new WeakSet(),
10
- trackedContexts: /* @__PURE__ */ new Set(),
11
- activeCollector: void 0
12
- };
13
- global[REGISTRY_KEY] = current;
14
- }
15
- return current;
16
- }
17
- function fingerprint(state) {
18
- return JSON.stringify([
19
- state.snapshot,
20
- state.mode,
21
- state.packageVersion,
22
- state.measuredProjects,
23
- state.runConditions
24
- ]);
25
- }
26
- function setRegistered(state) {
27
- const registry = slot();
28
- const previous = registry.state;
29
- if (previous !== void 0 && fingerprint(previous) === fingerprint(state)) return void 0;
30
- registry.state = state;
31
- if (previous === void 0) return void 0;
32
- const warning = {
33
- code: "CONFIG_CHANGED_IN_PROCESS",
34
- message: "config: withPerf() was called again in this process with a different package config; the last one is used",
35
- hint: "Apply withPerf() once, to the Playwright config that is run, with one package config."
36
- };
37
- state.warnings.push(warning);
38
- return warning;
39
- }
40
- function getRegistered() {
41
- return slot().state;
42
- }
43
- function notWrappedWarning() {
44
- return {
45
- code: "NOT_WRAPPED_WITH_PERF",
46
- message: "config: withPerf() was not applied to the Playwright config in this process, so the default package config is used",
47
- hint: 'Wrap the Playwright config: export default withPerf(defineConfig({ ... }), perfConfig) with withPerf from "playwright-performance-regression/config".'
48
- };
49
- }
50
- function wrappedTests() {
51
- return slot().wrappedTests;
52
- }
53
- function trackedContexts() {
54
- return slot().trackedContexts;
55
- }
56
- function wrappedRequestContexts() {
57
- const registry = slot();
58
- registry.wrappedRequestContexts ??= /* @__PURE__ */ new WeakSet();
59
- return registry.wrappedRequestContexts;
60
- }
61
- function activeCollector() {
62
- return slot().activeCollector;
63
- }
64
- function setActiveCollector(collector) {
65
- slot().activeCollector = collector;
66
- }
67
-
68
- export { activeCollector, getRegistered, notWrappedWarning, setActiveCollector, setRegistered, trackedContexts, wrappedRequestContexts, wrappedTests };