@describe-me/core 0.1.0 → 0.1.1
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/recorder.js +15 -1
- package/package.json +3 -2
package/dist/recorder.js
CHANGED
|
@@ -66,4 +66,18 @@ class Recorder {
|
|
|
66
66
|
return { frames: this.frames, component: this.component };
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
const RECORDER_KEY = Symbol.for('describe-me.recorder');
|
|
70
|
+
/**
|
|
71
|
+
* The adapter and the setup file may receive two copies of this module: Vite
|
|
72
|
+
* pre-bundles the adapter together with its own copy of core, while a linked
|
|
73
|
+
* workspace serves the setup file's import from source. A module-level
|
|
74
|
+
* singleton would then split into an active recorder and a silent one, and
|
|
75
|
+
* every render frame would go missing. Anchoring it on `globalThis` keeps one
|
|
76
|
+
* recorder per page no matter how the code was bundled.
|
|
77
|
+
*/
|
|
78
|
+
function sharedRecorder() {
|
|
79
|
+
const scope = globalThis;
|
|
80
|
+
scope[RECORDER_KEY] ??= new Recorder();
|
|
81
|
+
return scope[RECORDER_KEY];
|
|
82
|
+
}
|
|
83
|
+
export const recorder = sharedRecorder();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@describe-me/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Recorder and manifest types for describe-me: living component docs from your tests",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vitest",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
|
-
"access": "public"
|
|
26
|
+
"access": "public",
|
|
27
|
+
"provenance": true
|
|
27
28
|
},
|
|
28
29
|
"exports": {
|
|
29
30
|
".": {
|