writetrack 0.8.0 → 0.9.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/README.md +35 -26
- package/dist/browser/index.js +1 -1
- package/dist/browser/pipes.js +1 -1
- package/dist/browser/viz.js +9 -9
- package/dist/browser/writetrack.wasm +0 -0
- package/dist/ckeditor/index.d.ts +2 -0
- package/dist/ckeditor/index.js +1 -1
- package/dist/esm/index.d.ts +68 -7
- package/dist/esm/index.js +1 -1
- package/dist/esm/pipes.d.ts +1 -1
- package/dist/esm/pipes.js +1 -1
- package/dist/esm/verify.d.ts +2 -2
- package/dist/esm/viz.d.ts +4 -2
- package/dist/esm/viz.js +9 -9
- package/dist/esm/writetrack.wasm +0 -0
- package/dist/index.cjs +1 -1
- package/dist/lexical/index.d.ts +5 -0
- package/dist/lexical/index.js +1 -1
- package/dist/pipes.cjs +1 -1
- package/dist/prosemirror/index.js +1 -1
- package/dist/quill/index.d.ts +8 -1
- package/dist/quill/index.js +1 -1
- package/dist/slate/index.d.ts +2 -0
- package/dist/slate/index.js +1 -1
- package/dist/tinymce/index.d.ts +2 -0
- package/dist/tinymce/index.js +1 -1
- package/dist/tiptap/index.d.ts +2 -0
- package/dist/tiptap/index.js +1 -1
- package/dist/viz.cjs +9 -9
- package/dist/writetrack.wasm +0 -0
- package/package.json +9 -4
package/dist/browser/pipes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function p(n){let{url:o,headers:i={},retries:t=0,backoffMs:e=100,maxBackoffMs:a=3e4,keepalive:c=!1}=n;return{async send(f){let u=null;for(let s=0;s<=t;s++){if(s>0){let r=Math.min(e*Math.pow(2,s-1),a);await new Promise(l=>setTimeout(l,r))}try{let r=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(f),keepalive:c});if(r.ok)return;u=new Error(`Webhook failed: ${r.status} ${r.statusText}`)}catch(r){u=r instanceof Error?r:new Error(String(r))}}throw u}}}function m(n){return n instanceof Error?n.message:String(n)}function d(n){let{client:o,actionName:i="writetrack_session",tags:t={}}=n;return{async send(e){let a={...t,duration:e.metadata.duration,keystrokeCount:e.session.events.length,qualityLevel:e.quality.qualityLevel,targetElement:e.metadata.targetElement,schemaVersion:e.version};e.metadata.userId&&(a.userId=e.metadata.userId),e.metadata.contentId&&(a.contentId=e.metadata.contentId),e.metadata.custom&&(a.custom=e.metadata.custom);try{o.addAction(i,a)}catch(c){throw new Error(`Datadog addAction failed: ${m(c)}`)}}}}function g(n){let{client:o,eventName:i="WriteTrack Session"}=n;return{async send(t){let e={duration:t.metadata.duration,keystrokeCount:t.session.events.length,qualityLevel:t.quality.qualityLevel,targetElement:t.metadata.targetElement,schemaVersion:t.version};t.metadata.userId&&(e.userId=t.metadata.userId),t.metadata.contentId&&(e.contentId=t.metadata.contentId),t.metadata.custom&&(e.custom=t.metadata.custom),o.track(i,e)}}}function v(n){let{tracer:o,spanName:i="writetrack.session"}=n;return{async send(t){let e=o.startSpan(i);try{e.setAttribute("writetrack.duration",t.metadata.duration),e.setAttribute("writetrack.keystroke_count",t.session.events.length),e.setAttribute("writetrack.quality_level",t.quality.qualityLevel),e.setAttribute("writetrack.target_element",t.metadata.targetElement),e.setAttribute("writetrack.schema_version",t.version),t.metadata.userId&&e.setAttribute("writetrack.user_id",t.metadata.userId),t.metadata.contentId&&e.setAttribute("writetrack.content_id",t.metadata.contentId),e.setStatus({code:1})}finally{e.end()}}}}export{d as datadog,v as opentelemetry,g as segment,p as webhook};
|
package/dist/browser/viz.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var yt=`:host {
|
|
2
2
|
--wt-color-primary: #fbbf24;
|
|
3
3
|
--wt-color-secondary: #22d3ee;
|
|
4
4
|
--wt-color-bg: #111113;
|
|
@@ -35,9 +35,9 @@ var ft=`:host {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/* Force light text on dark tooltips regardless of chart theme */
|
|
38
|
-
[aria-label="tip"] { color: #fafafa; }`,S={fill:"#1a1a1d",stroke:"#27272a",textPadding:6,fontSize:11,fontFamily:"'JetBrains Mono', ui-monospace, monospace"};var g=class extends HTMLElement{constructor(){super();this._data=null;this._resizeObserver=null;this._resizeRaf=null;this.e=null;this.s=!0;this.a=!1;this.o=!1;this.shadow=this.attachShadow({mode:"open"});let a=document.createElement("style");a.textContent=this.getStylesheet(),this.shadow.appendChild(a),this.container=document.createElement("div"),this.container.className="wt-chart",this.shadow.appendChild(this.container)}static get observedAttributes(){return["data","theme","label"]}getStylesheet(){return ft}connectedCallback(){typeof ResizeObserver<"u"&&(this.s=!0,this._resizeObserver=new ResizeObserver(()=>{if(this.s){this.s=!1;return}this._data&&(this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeRaf=requestAnimationFrame(()=>{this._resizeRaf=null,this.onResize()}))}),this._resizeObserver.observe(this.container)),this.i(),typeof MutationObserver<"u"&&(this.e=new MutationObserver(()=>{this.i()}),this.e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),document.body&&this.e.observe(document.body,{attributes:!0,attributeFilter:["data-theme"]}))}disconnectedCallback(){this.destroy()}attributeChangedCallback(a,r,t){if(a==="data"&&t)try{let s=JSON.parse(t);this.setData(s)}catch(s){console.warn("[WriteTrack] BaseChart: invalid JSON in data attribute:",s)}a==="theme"&&this._data&&this.a&&this.render()}setData(a){this._data=a,this.render()}getData(){return this._data}get hasRendered(){return this.a}replaceChart(...a){for(let r of a)if(r instanceof SVGElement){r.setAttribute("role","img");let t=this.getAttribute("label")??this.tagName.toLowerCase().replace("wt-","").replace(/-/g," ")+" chart";r.setAttribute("aria-label",t)}this.container.replaceChildren(...a),this.a=!0,this.dispatchEvent(new CustomEvent("wt-render",{bubbles:!1}))}showEmptyState(a="No data"){let r=document.createElement("div");r.className="wt-empty",r.textContent=a,r.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:11px;color:var(--wt-color-text-muted,#a1a1aa);",this.container.replaceChildren(r),this.a=!1}destroy(){this._resizeRaf&&(cancelAnimationFrame(this._resizeRaf),this._resizeRaf=null),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this.e&&(this.e.disconnect(),this.e=null),this.container.replaceChildren(),this._data=null,this.a=!1}onResize(){this.render()}static register(){customElements.get(this.tagName)||customElements.define(this.tagName,this)}i(){if(this.hasAttribute("theme")&&!this.o)return;let a=this.parentElement;for(;a;){let r=a.getAttribute("data-theme");if(r){this.shadow.host.setAttribute("theme",r),this.o=!0;return}a=a.parentElement}this.o&&(this.shadow.host.removeAttribute("theme"),this.o=!1)}};g.tagName="wt-base-chart";import*as $ from"@observablehq/plot";var Dt=5;function gt(o){var s;let e=(((s=o.session)==null?void 0:s.events)??[]).filter(n=>n.type==="keydown"&&n.flightTime!=null&&n.flightTime>0);if(e.length<2)return[[],[]];let a=o.session.sessionStartTime,r=[],t=[];for(let n=0;n<e.length;n++){let i=Math.max(0,n-Dt+1),c=0,l=0;for(let u=i;u<=n;u++)c+=e[u].flightTime,l++;let d=c/l,m=Math.round(6e4/d);r.push(Math.round((e[n].timestamp-a)/1e3*100)/100),t.push(m)}return[r,t]}var L=class L extends g{connectedCallback(){super.connectedCallback();let e=getComputedStyle(this);!this.style.display&&e.display==="inline"&&(this.style.display="inline-block"),!this.style.width&&(e.width==="auto"||e.width==="0px")&&(this.style.width="200px"),!this.style.height&&(e.height==="auto"||e.height==="0px")&&(this.style.height="40px")}render(){if(!this._data)return;let[e,a]=gt(this._data);if(e.length===0){this.showEmptyState("No data");return}let r=e.map((i,c)=>({time:i,speed:a[c]})),t=this.getBoundingClientRect(),s=Math.max(t.width||200,50),n=Math.max(t.height||40,20);try{let i=$.plot({width:s,height:n,axis:null,x:{axis:null},y:{axis:null},marks:[$.areaY(r,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.1}),$.lineY(r,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1.5})],style:{background:"transparent",overflow:"visible"},margin:0,marginTop:2,marginBottom:2,marginLeft:0,marginRight:0});this.replaceChart(i)}catch(i){console.warn("[WriteTrack] Sparkline render failed:",i)}}static create(e,a){L.register();let r=document.createElement(L.tagName);return e.appendChild(r),r.setData(a),r}};L.tagName="wt-sparkline";var lt=L;import*as C from"@observablehq/plot";function z(o){var t,s,n;let e=(s=(t=o.temporalPatterns)==null?void 0:t.metrics)==null?void 0:s.speedTimeline;if(!((n=e==null?void 0:e.timestamps)!=null&&n.length))return[];let a=Math.min(e.timestamps.length,e.values.length),r=[];for(let i=0;i<a;i++)r.push({time:e.timestamps[i]/1e3,speed:e.values[i]});return r}var F=class extends g{render(){if(!this._data)return;let e=z(this._data);if(e.length===0){this.showEmptyState("No speed data");return}let a=this.clientWidth||640,r=this.clientHeight||200;try{let t=C.plot({width:a,height:r,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Speed (CPM)",grid:!0},marks:[C.areaY(e,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.15,curve:"natural"}),C.lineY(e,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2,curve:"natural"}),C.ruleY([0],{stroke:"var(--wt-color-border, #27272a)"}),C.tip(e,C.pointerX({x:"time",y:"speed",title:s=>`${s.time.toFixed(1)}s \u2014 ${Math.round(s.speed)} CPM`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] SpeedTimeline render failed:",t)}}};F.tagName="wt-speed-timeline";import*as P from"@observablehq/plot";var ct={typing:"var(--wt-color-primary, #fbbf24)",paste:"var(--wt-color-secondary, #22d3ee)",pause:"var(--wt-color-text-muted, #a1a1aa)",tabAway:"#ef4444",autocomplete:"#a78bfa",navigating:"#34d399"};function H(o){let e=o.sessionTimeline;return e!=null&&e.length?e.map(a=>({start:a.startTime/1e3,end:a.endTime/1e3,type:a.type,color:ct[a.type]??"#666"})):[]}function yt(o){var a,r;return(((r=(a=o.contentOrigin)==null?void 0:a.metrics)==null?void 0:r.pasteEvents)??[]).map(t=>({time:t.timestamp/1e3,chars:t.characterCount,source:t.source}))}var G=class extends g{render(){if(!this._data)return;let e=H(this._data);if(e.length===0){this.showEmptyState("No session data");return}let a=yt(this._data),r=[P.barX(e,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5}),P.tip(e,P.pointer({x:n=>(n.start+n.end)/2,y:()=>"Activity",title:n=>`${n.type} \u2014 ${(n.end-n.start).toFixed(1)}s`,...S}))];a.length&&r.push(P.dot(a,{x:"time",y:()=>"Activity",r:"chars",fill:ct.paste,fillOpacity:.7,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1}));let t=this.clientWidth||640,s=this.clientHeight||80;try{let n=P.plot({width:t,height:s,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null,padding:.3},marks:r,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(n)}catch(n){console.warn("[WriteTrack] CompositionTimeline render failed:",n)}}};G.tagName="wt-composition-timeline";import*as j from"@observablehq/plot";var Ot=10;function Y(o){var n,i,c,l,d;let e=(i=(n=o.timingAuthenticity)==null?void 0:n.metrics)==null?void 0:i.timingOverTime;if(!((c=e==null?void 0:e.timestamps)!=null&&c.length))return[];let a=((l=e.series)==null?void 0:l.meanDwell)??[],r=((d=e.series)==null?void 0:d.meanFlight)??[];if(!a.length||!r.length)return[];let t=[],s=Math.min(e.timestamps.length,a.length,r.length);for(let m=0;m<s;m++)a[m]!=null&&r[m]!=null&&t.push({dwell:a[m],flight:r[m]});return t}var V=class extends g{render(){if(!this._data)return;let e=Y(this._data);if(e.length<Ot){this.showEmptyState("Insufficient timing data");return}let a=this.clientWidth||400,r=Math.min(a,this.clientHeight||400);try{let t=j.plot({width:a,height:r,marginLeft:50,marginBottom:35,x:{label:"Dwell (ms)",grid:!0},y:{label:"Flight (ms)",grid:!0},marks:[j.dot(e,{x:"dwell",y:"flight",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.35,r:3,stroke:"var(--wt-color-primary, #fbbf24)",strokeOpacity:.6,strokeWidth:.5})],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] RhythmHeatmap render failed:",t)}}};V.tagName="wt-rhythm-heatmap";import*as _ from"@observablehq/plot";function bt(o){var a,r,t;let e=(r=(a=o.temporalPatterns)==null?void 0:a.metrics)==null?void 0:r.pauseDistribution;return(t=e==null?void 0:e.histogram)!=null&&t.length?e.histogram.map(s=>({start:s.binStart,end:s.binEnd,count:s.count})):[]}var q=class extends g{render(){if(!this._data)return;let e=bt(this._data);if(e.length===0){this.showEmptyState("No pause data");return}let a=this.clientWidth||640,r=this.clientHeight||200;try{let t=_.plot({width:a,height:r,marginLeft:50,marginBottom:35,x:{label:"Pause Duration (ms)"},y:{label:"Count",grid:!0},marks:[_.rectY(e,{x1:"start",x2:"end",y:"count",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.8,inset:.5}),_.ruleY([0])],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] PauseDistribution render failed:",t)}}};q.tagName="wt-pause-distribution";import*as E from"@observablehq/plot";var U=/^.$/u;function v(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Q(o){var i,c;let e=(i=o.session)==null?void 0:i.events;if(!(e!=null&&e.length))return[];let a=e.filter(l=>l.type==="keydown");if(a.length===0)return[];let r=a[0].timestamp,t=[];for(let l of a)l.key==="Backspace"||l.key==="Delete"?t.push({timestamp:l.timestamp,type:"key",delta:-1}):U.test(l.key)&&t.push({timestamp:l.timestamp,type:"key",delta:1});for(let l of((c=o.session)==null?void 0:c.clipboardEvents)??[])l.type==="paste"?t.push({timestamp:l.timestamp,type:"paste",delta:l.length,pasteLength:l.length}):l.type==="cut"&&t.push({timestamp:l.timestamp,type:"cut",delta:-l.length,cutLength:l.length});t.sort((l,d)=>l.timestamp-d.timestamp);let s=[],n=0;for(let l of t){let d=(l.timestamp-r)/1e3;l.type==="paste"?(s.push({time:d,chars:n,isPaste:!1,isCut:!1}),n+=l.delta,s.push({time:d+.001,chars:n,isPaste:!0,isCut:!1,pasteLength:l.pasteLength})):l.type==="cut"?(s.push({time:d,chars:n,isPaste:!1,isCut:!1}),n=Math.max(0,n+l.delta),s.push({time:d+.001,chars:n,isPaste:!1,isCut:!0,cutLength:l.cutLength})):(n=Math.max(0,n+l.delta),s.push({time:d,chars:n,isPaste:!1,isCut:!1}))}return s}var K=class extends g{render(){if(!this._data)return;let e=Q(this._data);if(e.length===0){this.showEmptyState("No keystroke data");return}let a=e.filter(n=>n.isPaste),r=e.filter(n=>n.isCut),t=this.clientWidth||640,s=this.clientHeight||200;try{let n=[E.lineY(e,{x:"time",y:"chars",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2})];a.length>0&&n.push(E.text(a,{x:"time",y:"chars",text:c=>`+${c.pasteLength}`,fill:"var(--wt-color-secondary, #22d3ee)",fontSize:10,dy:-8})),r.length>0&&n.push(E.text(r,{x:"time",y:"chars",text:c=>`\u2212${c.cutLength}`,fill:"#ef4444",fontSize:10,dy:12})),n.push(E.tip(e,E.pointerX({x:"time",y:"chars",title:c=>{let l=`${c.time.toFixed(1)}s \u2014 ${c.chars} chars`;return c.isPaste?`${l}
|
|
39
|
-
+${
|
|
40
|
-
\u2212${
|
|
38
|
+
[aria-label="tip"] { color: #fafafa; }`,k={fill:"#1a1a1d",stroke:"#27272a",textPadding:6,fontSize:11,fontFamily:"'JetBrains Mono', ui-monospace, monospace"};function W(a){console.warn(`[WriteTrack] ${a}`)}function ct(a){return a instanceof Error?a.message:String(a)}var g=class extends HTMLElement{constructor(){super();this._data=null;this._resizeObserver=null;this._resizeRaf=null;this.e=null;this.i=!0;this.o=!1;this.a=!1;this.shadow=this.attachShadow({mode:"open"});let e=document.createElement("style");e.textContent=this.getStylesheet(),this.shadow.appendChild(e),this.container=document.createElement("div"),this.container.className="wt-chart",this.shadow.appendChild(this.container)}static get observedAttributes(){return["data","theme","label"]}getStylesheet(){return yt}connectedCallback(){typeof ResizeObserver<"u"&&(this.i=!0,this._resizeObserver=new ResizeObserver(()=>{if(this.i){this.i=!1;return}this._data&&(this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeRaf=requestAnimationFrame(()=>{this._resizeRaf=null,this.onResize()}))}),this._resizeObserver.observe(this.container)),this.s(),typeof MutationObserver<"u"&&(this.e=new MutationObserver(()=>{this.s()}),this.e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),document.body&&this.e.observe(document.body,{attributes:!0,attributeFilter:["data-theme"]}))}disconnectedCallback(){this.destroy()}attributeChangedCallback(e,n,r){if(e==="data"&&r)try{let o=JSON.parse(r);this.setData(o)}catch(o){W(`BaseChart: invalid JSON in data attribute: ${ct(o)}`)}e==="theme"&&this._data&&this.o&&this.safeRender()}setData(e){this._data=e,this.safeRender()}getData(){return this._data}get hasRendered(){return this.o}replaceChart(...e){for(let n of e)if(n instanceof SVGElement){n.setAttribute("role","img");let r=this.getAttribute("label")??this.tagName.toLowerCase().replace("wt-","").replace(/-/g," ")+" chart";n.setAttribute("aria-label",r)}this.container.replaceChildren(...e),this.o=!0,this.dispatchEvent(new CustomEvent("wt-render",{bubbles:!1}))}showEmptyState(e="No data"){let n=document.createElement("div");n.className="wt-empty",n.textContent=e,n.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:11px;color:var(--wt-color-text-muted,#a1a1aa);",this.container.replaceChildren(n),this.o=!1}destroy(){this._resizeRaf&&(cancelAnimationFrame(this._resizeRaf),this._resizeRaf=null),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this.e&&(this.e.disconnect(),this.e=null),this.container.replaceChildren(),this._data=null,this.o=!1}onResize(){this.safeRender()}safeRender(){try{this.render()}catch(e){W(`${this.constructor.name} render failed: ${ct(e)}`)}}static register(){customElements.get(this.tagName)||customElements.define(this.tagName,this)}s(){if(this.hasAttribute("theme")&&!this.a)return;let e=this.parentElement;for(;e;){let n=e.getAttribute("data-theme");if(n){this.shadow.host.setAttribute("theme",n),this.a=!0;return}e=e.parentElement}this.a&&(this.shadow.host.removeAttribute("theme"),this.a=!1)}};g.tagName="wt-base-chart";import*as _ from"@observablehq/plot";var Lt=5;function bt(a){var o;let t=(((o=a.session)==null?void 0:o.events)??[]).filter(i=>i.type==="keydown"&&i.flightTime!=null&&i.flightTime>0);if(t.length<2)return[[],[]];let e=a.session.sessionStartTime,n=[],r=[];for(let i=0;i<t.length;i++){let s=Math.max(0,i-Lt+1),l=0,c=0;for(let u=s;u<=i;u++)l+=t[u].flightTime,c++;let d=l/c,m=Math.round(6e4/d);n.push(Math.round((t[i].timestamp-e)/1e3*100)/100),r.push(m)}return[n,r]}var B=class B extends g{connectedCallback(){super.connectedCallback();let t=getComputedStyle(this);!this.style.display&&t.display==="inline"&&(this.style.display="inline-block"),!this.style.width&&(t.width==="auto"||t.width==="0px")&&(this.style.width="200px"),!this.style.height&&(t.height==="auto"||t.height==="0px")&&(this.style.height="40px")}render(){if(!this._data)return;let[t,e]=bt(this._data);if(t.length===0){this.showEmptyState("No data");return}let n=t.map((l,c)=>({time:l,speed:e[c]})),r=this.getBoundingClientRect(),o=Math.max(r.width||200,50),i=Math.max(r.height||40,20),s=_.plot({width:o,height:i,axis:null,x:{axis:null},y:{axis:null},marks:[_.areaY(n,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.1}),_.lineY(n,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1.5})],style:{background:"transparent",overflow:"visible"},margin:0,marginTop:2,marginBottom:2,marginLeft:0,marginRight:0});this.replaceChart(s)}static create(t,e){B.register();let n=document.createElement(B.tagName);return t.appendChild(n),n.setData(e),n}};B.tagName="wt-sparkline";var dt=B;import*as C from"@observablehq/plot";function G(a){var r,o,i;let t=(o=(r=a.temporalPatterns)==null?void 0:r.metrics)==null?void 0:o.speedTimeline;if(!((i=t==null?void 0:t.timestamps)!=null&&i.length))return[];let e=Math.min(t.timestamps.length,t.values.length),n=[];for(let s=0;s<e;s++)n.push({time:t.timestamps[s]/1e3,speed:t.values[s]});return n.sort((s,l)=>s.time-l.time),n}var z=class extends g{render(){if(!this._data)return;let t=G(this._data);if(t.length===0){this.showEmptyState("No speed data");return}let e=this.clientWidth||640,n=this.clientHeight||200,r=C.plot({width:e,height:n,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Speed (CPM)",grid:!0},marks:[C.areaY(t,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.15,curve:"monotone-x"}),C.lineY(t,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2,curve:"monotone-x"}),C.ruleY([0],{stroke:"var(--wt-color-border, #27272a)"}),C.tip(t,C.pointerX({x:"time",y:"speed",title:o=>`${o.time.toFixed(1)}s \u2014 ${Math.round(o.speed)} CPM`,...k}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(r)}};z.tagName="wt-speed-timeline";import*as P from"@observablehq/plot";var mt={typing:"var(--wt-color-primary, #fbbf24)",paste:"var(--wt-color-secondary, #22d3ee)",pause:"var(--wt-color-text-muted, #a1a1aa)",tabAway:"#ef4444",autocomplete:"#a78bfa",navigating:"#34d399"};function V(a){let t=a.sessionTimeline;return t!=null&&t.length?t.map(e=>({start:e.startTime/1e3,end:e.endTime/1e3,type:e.type,color:mt[e.type]??"#666"})):[]}function wt(a){var e,n;return(((n=(e=a.contentOrigin)==null?void 0:e.metrics)==null?void 0:n.pasteEvents)??[]).map(r=>({time:r.timestamp/1e3,chars:r.characterCount,source:r.source}))}var H=class extends g{render(){if(!this._data)return;let t=V(this._data);if(t.length===0){this.showEmptyState("No session data");return}let e=wt(this._data),n=[P.barX(t,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5}),P.tip(t,P.pointer({x:s=>(s.start+s.end)/2,y:()=>"Activity",title:s=>`${s.type} \u2014 ${(s.end-s.start).toFixed(1)}s`,...k}))];e.length&&n.push(P.dot(e,{x:"time",y:()=>"Activity",r:"chars",fill:mt.paste,fillOpacity:.7,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1}));let r=this.clientWidth||640,o=this.clientHeight||80,i=P.plot({width:r,height:o,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null,padding:.3},marks:n,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(i)}};H.tagName="wt-composition-timeline";import*as q from"@observablehq/plot";var Bt=10;function U(a){var i,s,l,c,d;let t=(s=(i=a.timingAuthenticity)==null?void 0:i.metrics)==null?void 0:s.timingOverTime;if(!((l=t==null?void 0:t.timestamps)!=null&&l.length))return[];let e=((c=t.series)==null?void 0:c.meanDwell)??[],n=((d=t.series)==null?void 0:d.meanFlight)??[];if(!e.length||!n.length)return[];let r=[],o=Math.min(t.timestamps.length,e.length,n.length);for(let m=0;m<o;m++)e[m]!=null&&n[m]!=null&&r.push({dwell:e[m],flight:n[m]});return r}var j=class extends g{render(){if(!this._data)return;let t=U(this._data);if(t.length<Bt){this.showEmptyState("Insufficient timing data");return}let e=this.clientWidth||400,n=Math.min(e,this.clientHeight||400),r=q.plot({width:e,height:n,marginLeft:50,marginBottom:35,x:{label:"Dwell (ms)",grid:!0},y:{label:"Flight (ms)",grid:!0},marks:[q.dot(t,{x:"dwell",y:"flight",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.35,r:3,stroke:"var(--wt-color-primary, #fbbf24)",strokeOpacity:.6,strokeWidth:.5})],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(r)}};j.tagName="wt-rhythm-heatmap";import*as D from"@observablehq/plot";function vt(a){var e,n,r;let t=(n=(e=a.temporalPatterns)==null?void 0:e.metrics)==null?void 0:n.pauseDistribution;return(r=t==null?void 0:t.histogram)!=null&&r.length?t.histogram.map(o=>({start:o.binStart,end:o.binEnd,count:o.count})):[]}var Y=class extends g{render(){if(!this._data)return;let t=vt(this._data);if(t.length===0){this.showEmptyState("No pause data");return}let e=this.clientWidth||640,n=this.clientHeight||200,r=D.plot({width:e,height:n,marginLeft:50,marginBottom:35,x:{label:"Pause Duration (ms)"},y:{label:"Count",grid:!0},marks:[D.rectY(t,{x1:"start",x2:"end",y:"count",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.8,inset:.5}),D.ruleY([0])],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(r)}};Y.tagName="wt-pause-distribution";import*as E from"@observablehq/plot";var K=/^.$/u;function v(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Nt(a){let t=[];for(let e of a)e.key==="Backspace"||e.key==="Delete"?t.push({timestamp:e.timestamp,type:"key",delta:-1}):K.test(e.key)&&t.push({timestamp:e.timestamp,type:"key",delta:1});return t}function It(a){let t=[];for(let e of a??[])e.type==="paste"?t.push({timestamp:e.timestamp,type:"paste",delta:e.length,pasteLength:e.length}):e.type==="cut"&&t.push({timestamp:e.timestamp,type:"cut",delta:-e.length,cutLength:e.length});return t}function Ft(a,t){let e=[],n=0;for(let r of a){let o=(r.timestamp-t)/1e3;r.type==="paste"?(e.push({time:o,chars:n,isPaste:!1,isCut:!1}),n+=r.delta,e.push({time:o+.001,chars:n,isPaste:!0,isCut:!1,pasteLength:r.pasteLength})):r.type==="cut"?(e.push({time:o,chars:n,isPaste:!1,isCut:!1}),n=Math.max(0,n+r.delta),e.push({time:o+.001,chars:n,isPaste:!1,isCut:!0,cutLength:r.cutLength})):(n=Math.max(0,n+r.delta),e.push({time:o,chars:n,isPaste:!1,isCut:!1}))}return e}function X(a){var o,i;let t=(o=a.session)==null?void 0:o.events;if(!(t!=null&&t.length))return[];let e=t.filter(s=>s.type==="keydown");if(e.length===0)return[];let n=e[0].timestamp,r=[...Nt(e),...It((i=a.session)==null?void 0:i.clipboardEvents)];return r.sort((s,l)=>s.timestamp-l.timestamp),Ft(r,n)}function zt(a,t,e){let n=[E.lineY(a,{x:"time",y:"chars",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2})];return t.length>0&&n.push(E.text(t,{x:"time",y:"chars",text:r=>`+${r.pasteLength}`,fill:"var(--wt-color-secondary, #22d3ee)",fontSize:10,dy:-8})),e.length>0&&n.push(E.text(e,{x:"time",y:"chars",text:r=>`\u2212${r.cutLength}`,fill:"#ef4444",fontSize:10,dy:12})),n.push(E.tip(a,E.pointerX({x:"time",y:"chars",title:r=>{let o=`${r.time.toFixed(1)}s \u2014 ${r.chars} chars`;return r.isPaste?`${o}
|
|
39
|
+
+${r.pasteLength} pasted`:r.isCut?`${o}
|
|
40
|
+
\u2212${r.cutLength} cut`:o},...k}))),n}var Q=class extends g{render(){if(!this._data)return;let t=X(this._data);if(t.length===0){this.showEmptyState("No keystroke data");return}let e=t.filter(i=>i.isPaste),n=t.filter(i=>i.isCut),r=this.clientWidth||640,o=this.clientHeight||200;try{let i=zt(t,e,n),s=E.plot({width:r,height:o,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Characters",grid:!0},marks:i,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(s)}catch(i){W(`DocumentGrowth render failed: ${i}`)}}};Q.tagName="wt-document-growth";import*as A from"@observablehq/plot";function xt(a){var o;let t=(o=a.session)==null?void 0:o.events;if(!(t!=null&&t.length))return[];let e=t.filter(i=>i.type==="keydown");if(e.length===0)return[];let n=e[0].timestamp,r=[];for(let i=0;i<e.length;i++){let s=e[i],l=(s.timestamp-n)/1e3,c=i<e.length-1?(e[i+1].timestamp-n)/1e3:l+(s.dwellTime??50)/1e3,d=s.flightTime??0;r.push({start:l,end:c,flight:d})}return r}var J=class extends g{render(){if(!this._data)return;let t=xt(this._data);if(t.length===0){this.showEmptyState("No keystroke data");return}let e=this.clientWidth||640,n=this.clientHeight||80,r=A.plot({width:e,height:n,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null},color:{type:"sequential",scheme:"YlOrRd",domain:[0,Math.max(1,t.reduce((o,i)=>i.flight>o?i.flight:o,0))],label:"Flight time (ms)"},marks:[A.rect(t,{x1:"start",x2:"end",y1:()=>0,y2:()=>1,fill:"flight",inset:.5}),A.tip(t,A.pointer({x:o=>(o.start+o.end)/2,y:()=>.5,title:o=>`${o.start.toFixed(1)}s \u2014 ${Math.round(o.flight)}ms flight time`,...k}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(r)}};J.tagName="wt-document-ribbon";import*as T from"@observablehq/plot";var Gt=null;function St(){return Gt}function kt(a,t,e,n){let r=a.length;if(r<=t||t<3)return a;let o=St();if(!o)return a;let i=new Float64Array(r),s=new Float64Array(r);for(let d=0;d<r;d++)i[d]=e(a[d]),s[d]=n(a[d]);let l=o.lttb_downsample(i,s,t);if(l.length===0)return a;let c=new Array(l.length);for(let d=0;d<l.length;d++)c[d]=a[l[d]];return c}var Ct=2e3;function Ht(a,t){let e=[],n=[];for(let r of a??[])r.type==="paste"?e.push({time:Math.max(0,(r.timestamp-t)/1e3),position:r.position}):r.type==="cut"&&n.push({time:Math.max(0,(r.timestamp-t)/1e3),position:r.position});return{pastes:e,cuts:n}}function tt(a){var s,l;let t=(s=a.session)==null?void 0:s.events;if(!(t!=null&&t.length))return{keystrokes:[],pastes:[],cuts:[]};let e=t.filter(c=>c.type==="keydown"&&c.cursorPosition!=null);if(e.length===0)return{keystrokes:[],pastes:[],cuts:[]};let n=e[0].timestamp,r=e.map(c=>({time:(c.timestamp-n)/1e3,position:c.cursorPosition})),{pastes:o,cuts:i}=Ht((l=a.session)==null?void 0:l.clipboardEvents,n);return{keystrokes:r,pastes:o,cuts:i}}function Vt(a,t,e){let n=[T.line(a,{x:"time",y:"position",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1,strokeOpacity:.5}),T.dot(a,{x:"time",y:"position",fill:"var(--wt-color-primary, #fbbf24)",r:2})];return t.length>0&&n.push(T.dot(t,{x:"time",y:"position",fill:"var(--wt-color-secondary, #22d3ee)",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),e.length>0&&n.push(T.dot(e,{x:"time",y:"position",fill:"#f97316",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),n.push(T.tip(a,T.pointerX({x:"time",y:"position",title:r=>`${r.time.toFixed(1)}s \u2014 position ${r.position}`,...k}))),n}var Z=class extends g{render(){if(!this._data)return;let t=tt(this._data);if(t.keystrokes.length===0){this.showEmptyState("No cursor position data");return}let e=kt(t.keystrokes,Ct,s=>s.time,s=>s.position),{pastes:n,cuts:r}=t,o=this.clientWidth||640,i=this.clientHeight||200;try{let s=Vt(e,n,r),l=T.plot({width:o,height:i,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Position",reverse:!0,grid:!0},marks:s,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(l)}catch(s){W(`EditWaterfall render failed: ${s}`)}}};Z.tagName="wt-edit-waterfall";import*as M from"@observablehq/plot";var Tt={insert:"#22c55e",delete:"#ef4444",paste:"var(--wt-color-secondary, #22d3ee)",cut:"#f97316"},Et={insert:.6,delete:-.6,paste:0,cut:0};function rt(a){var c,d;let t=(c=a.session)==null?void 0:c.events;if(!(t!=null&&t.length))return[];let e=t.filter(m=>m.type==="keydown");if(e.length===0)return[];let n=e[0].timestamp,r=[],o=null,i=0,s=0;function l(){o&&i>0&&r.push({time:s,chars:i,type:o,size:Math.max(4,Math.sqrt(i)*3)}),o=null,i=0}for(let m of e){let u=(m.timestamp-n)/1e3,p=null;m.key==="Backspace"||m.key==="Delete"?p="delete":K.test(m.key)&&(p="insert"),p!==null&&(p!==o&&(l(),o=p,s=u),i++)}l();for(let m of((d=a.session)==null?void 0:d.clipboardEvents)??[])if(m.type==="paste"||m.type==="cut"){let u=Math.max(0,(m.timestamp-n)/1e3),p=m.length;r.push({time:u,chars:p,type:m.type,size:Math.max(4,Math.sqrt(p)*3)})}return r.sort((m,u)=>m.time-u.time),r}var et=class extends g{render(){if(!this._data)return;let t=rt(this._data);if(t.length===0){this.showEmptyState("No edit data");return}let e=this.clientWidth||640,n=this.clientHeight||140,r=M.plot({width:e,height:n,marginLeft:50,marginBottom:35,marginTop:10,x:{label:"Time (s)"},y:{axis:null,domain:[-1.5,1.5]},marks:[M.dot(t,{x:"time",y:i=>Et[i.type],r:"size",fill:i=>Tt[i.type],fillOpacity:.65,stroke:i=>Tt[i.type],strokeWidth:1}),M.tip(t,M.pointer({x:"time",y:i=>Et[i.type],title:i=>`${i.time.toFixed(1)}s \u2014 ${i.type}, ${i.chars} chars`,...k}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(r);let o=document.createElement("div");o.className="wt-legend",o.style.cssText="display:flex;gap:12px;padding:6px 0 0;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:10px;color:var(--wt-color-text-muted,#a1a1aa);";for(let[i,s]of[["Insert","#22c55e"],["Delete","#ef4444"],["Paste","#22d3ee"],["Cut","#f97316"]]){let l=document.createElement("span");l.style.cssText="display:flex;align-items:center;gap:4px;";let c=document.createElement("span");c.style.cssText=`width:8px;height:8px;border-radius:50%;background:${s};`,l.appendChild(c),l.appendChild(document.createTextNode(i)),o.appendChild(l)}this.container.appendChild(o)}};et.tagName="wt-corrections-bubble";var N=`:host {
|
|
41
41
|
/* \u2500\u2500 Surface colors (light default) \u2500\u2500 */
|
|
42
42
|
--wt-scorecard-bg: #F7F6F2;
|
|
43
43
|
--wt-scorecard-bg-card: #FFFFFF;
|
|
@@ -102,7 +102,7 @@ var ft=`:host {
|
|
|
102
102
|
.wt-term:hover {
|
|
103
103
|
text-decoration-color: var(--wt-scorecard-text-secondary);
|
|
104
104
|
}
|
|
105
|
-
`,
|
|
105
|
+
`,hr=(()=>{try{let a=new CSSStyleSheet;return a.replaceSync(N),a}catch{return null}})();var jt={"--wt-color-bg":"var(--wt-scorecard-bg-card)","--wt-color-surface":"var(--wt-scorecard-bg-detail)","--wt-color-text":"var(--wt-scorecard-text)","--wt-color-text-muted":"var(--wt-scorecard-text-tertiary)","--wt-color-border":"var(--wt-scorecard-border)","--wt-color-primary":"var(--wt-scorecard-chart-accent)","--wt-color-secondary":"var(--wt-scorecard-chart-flagged)","--wt-font-data":"var(--wt-scorecard-font-data)","--wt-font-ui":"var(--wt-scorecard-font-body)"};function Pt(a){for(let[t,e]of Object.entries(jt))a.style.setProperty(t,e)}var I=new Uint8Array(256),ut=new Uint8Array(256);(function(){let a=1;for(let t=0;t<255;t++)I[t]=a,ut[a]=t,a=a<<1^(a>=128?285:0);I[255]=I[0]})();function Rt(a,t){return a===0||t===0?0:I[(ut[a]+ut[t])%255]}function qt(a){let t=[1];for(let e=0;e<a;e++){let n=new Array(t.length+1).fill(0);for(let r=0;r<t.length;r++)n[r]^=t[r],n[r+1]^=Rt(t[r],I[e]);t=n}return t}function Ut(a,t){let e=qt(t),n=new Uint8Array(a.length+t);n.set(a);for(let r=0;r<a.length;r++){let o=n[r];if(o!==0)for(let i=0;i<e.length;i++)n[r+i]^=Rt(e[i],o)}return n.slice(a.length)}var Yt=[{ver:1,size:21,dc:16,ec:10,blocks:1,cap:14},{ver:2,size:25,dc:28,ec:16,blocks:1,cap:26},{ver:3,size:29,dc:44,ec:26,blocks:1,cap:42},{ver:4,size:33,dc:64,ec:18,blocks:2,cap:62},{ver:5,size:37,dc:86,ec:24,blocks:2,cap:84},{ver:6,size:41,dc:108,ec:16,blocks:4,cap:106}],Kt=[[],[6,18],[6,22],[6,26],[6,30],[6,34]];function Qt(a){for(let t of Yt)if(a<=t.cap)return t;return null}function Xt(a,t){let e=[];function n(h,w){for(let b=w-1;b>=0;b--)e.push(h>>b&1)}n(4,4),n(a.length,8);for(let h of a)n(h,8);let r=t.dc*8;for(n(0,Math.min(4,r-e.length));e.length%8!==0;)e.push(0);let o=[236,17],i=0;for(;e.length<r;)n(o[i%2],8),i++;let s=[];for(let h=0;h<e.length;h+=8){let w=0;for(let b=0;b<8;b++)w=w<<1|e[h+b];s.push(w)}let l=Math.floor(t.dc/t.blocks),c=t.dc-l*t.blocks,d=[],m=[],u=0;for(let h=0;h<t.blocks;h++){let w=l+(h>=t.blocks-c?1:0),b=new Uint8Array(s.slice(u,u+w));d.push(b),m.push(Ut(b,t.ec)),u+=w}let p=[],y=0;for(let h of d)y=Math.max(y,h.length);for(let h=0;h<y;h++)for(let w of d)h<w.length&&p.push(w[h]);for(let h=0;h<t.ec;h++)for(let w of m)p.push(w[h]);return p}function Jt(a){let t=a.size,e=[],n=[];for(let s=0;s<t;s++)e.push(new Int8Array(t)),n.push(new Uint8Array(t));function r(s,l,c){e[l][s]=c?1:-1,n[l][s]=1}function o(s,l){for(let d=-3;d<=3;d++)for(let m=-3;m<=3;m++){let u=s+m,p=l+d;u<0||u>=t||p<0||p>=t||r(u,p,Math.max(Math.abs(m),Math.abs(d))!==2)}let c=[[-4,0],[4,0],[0,-4],[0,4]];for(let d=-4;d<=4;d++)for(let m of c){let u=s+(m[0]!==0?m[0]:d),p=l+(m[1]!==0?m[1]:d);u>=0&&u<t&&p>=0&&p<t&&r(u,p,!1)}}o(3,3),o(t-4,3),o(3,t-4);for(let s=8;s<t-8;s++)r(s,6,s%2===0),r(6,s,s%2===0);let i=Kt[a.ver-1];if(i.length>0)for(let s=0;s<i.length;s++)for(let l=0;l<i.length;l++){let c=i[s],d=i[l];if(!n[c][d])for(let m=-2;m<=2;m++)for(let u=-2;u<=2;u++)r(d+u,c+m,Math.max(Math.abs(u),Math.abs(m))!==1)}r(8,4*a.ver+9,!0);for(let s=0;s<8;s++)n[8][s]||(n[8][s]=1),n[8][t-1-s]||(n[8][t-1-s]=1),n[s][8]||(n[s][8]=1),n[t-1-s][8]||(n[t-1-s][8]=1);return n[8][8]=1,{grid:e,reserved:n,n:t}}function Zt(a,t){let{grid:e,reserved:n,n:r}=a,o=[];for(let c of t)for(let d=7;d>=0;d--)o.push(c>>d&1);let i=0,s=r-1,l=!0;for(;s>=0;){if(s===6){s--;continue}let c=l?r-1:0,d=l?-1:r,m=l?-1:1;for(let u=c;u!==d;u+=m)for(let p=0;p<2;p++){let y=s-p;y<0||n[u][y]||(e[u][y]=i<o.length&&o[i]?1:-1,i++)}s-=2,l=!l}}var te=[(a,t)=>(a+t)%2===0,(a,t)=>t%2===0,(a,t)=>a%3===0,(a,t)=>(a+t)%3===0,(a,t)=>(Math.floor(t/2)+Math.floor(a/3))%2===0,(a,t)=>a*t%2+a*t%3===0,(a,t)=>(a*t%2+a*t%3)%2===0,(a,t)=>((a+t)%2+a*t%3)%2===0];function At(a,t,e,n){let r=te[n],o=a.map(i=>Int8Array.from(i));for(let i=0;i<e;i++)for(let s=0;s<e;s++)!t[i][s]&&r(s,i)&&(o[i][s]=o[i][s]===1?-1:1);return o}var ee=[21522,20773,24188,23371,17913,16590,20375,19104];function Mt(a,t,e){let n=ee[e],r=[];for(let s=14;s>=0;s--)r.push(n>>s&1);let o=[[0,8],[1,8],[2,8],[3,8],[4,8],[5,8],[7,8],[8,8],[8,7],[8,5],[8,4],[8,3],[8,2],[8,1],[8,0]],i=[[8,t-1],[8,t-2],[8,t-3],[8,t-4],[8,t-5],[8,t-6],[8,t-7],[t-8,8],[t-7,8],[t-6,8],[t-5,8],[t-4,8],[t-3,8],[t-2,8],[t-1,8]];for(let s=0;s<15;s++){let l=r[s]?1:-1;a[o[s][1]][o[s][0]]=l,a[i[s][1]][i[s][0]]=l}}function re(a,t){let e=0;for(let n=0;n<t;n++){let r=1;for(let o=1;o<t;o++)a[n][o]>0==a[n][o-1]>0?r++:(r>=5&&(e+=r-2),r=1);r>=5&&(e+=r-2)}for(let n=0;n<t;n++){let r=1;for(let o=1;o<t;o++)a[o][n]>0==a[o-1][n]>0?r++:(r>=5&&(e+=r-2),r=1);r>=5&&(e+=r-2)}return e}function ne(a){let t=[];for(let l=0;l<a.length;l++){let c=a.charCodeAt(l);c<128?t.push(c):c<2048&&(t.push(192|c>>6),t.push(128|c&63))}let e=Qt(t.length);if(!e)return null;let n=Xt(t,e),r=Jt(e);Zt(r,n);let o=0,i=1/0;for(let l=0;l<8;l++){let c=At(r.grid,r.reserved,r.n,l);Mt(c,r.n,l);let d=re(c,r.n);d<i&&(i=d,o=l)}let s=At(r.grid,r.reserved,r.n,o);return Mt(s,r.n,o),{grid:s,size:r.n}}function ae(a,t,e){let n=a.size,r=Math.max(2,Math.floor(88/n)),o=n*r,i=r/2,s=i*.82,l=n/2,c=n*.18;function d(x,S){let L=Math.sin(x*31+S*17)*1e4;return .75+.25*(L-Math.floor(L))}let m="";for(let x=0;x<n;x++)for(let S=0;S<n;S++){if(a.grid[x][S]<=0)continue;let L=S-l,gt=x-l;if(Math.sqrt(L*L+gt*gt)<c)continue;if(S<7&&x<7||S>=n-7&&x<7||S<7&&x>=n-7)m+=`<rect x="${S*r}" y="${x*r}" width="${r}" height="${r}" rx="${r*.15}" fill="${t}"/>`;else{let Ot=s*d(S,x);m+=`<circle cx="${S*r+i}" cy="${x*r+i}" r="${Ot.toFixed(1)}" fill="${t}"/>`}}let u=l*r,p=l*r,y=c*r*.6,h=e||t,w=y*2/100,b=70*w,R=`<g transform="translate(${u-y},${p-b/2}) scale(${w.toFixed(4)})">`;return R+=`<path d="M86 2 L86 64" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,R+=`<path d="M7 12 L98 12" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,R+=`<path d="M7 18 C7 32, 16 64, 30 64 C44 64, 38 28, 52 28 C66 28, 62 64, 86 64" stroke="${t}" stroke-width="5" stroke-linecap="round" fill="none"/>`,R+=`<circle cx="7" cy="12" r="7" fill="${t}"/>`,R+=`<circle cx="86" cy="64" r="7" fill="${h}"/>`,R+="</g>",`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${o} ${o}" width="${o}" height="${o}">${m}${R}</svg>`}var oe=`.integrity-section {
|
|
106
106
|
margin-top: 2rem;
|
|
107
107
|
padding-top: 1.5rem;
|
|
108
108
|
border-top: 1px solid var(--wt-scorecard-border);
|
|
@@ -167,8 +167,8 @@ var ft=`:host {
|
|
|
167
167
|
color: var(--wt-scorecard-text-tertiary);
|
|
168
168
|
flex: 1;
|
|
169
169
|
}
|
|
170
|
-
`,
|
|
171
|
-
`+Xt}render(){if(!this._data)return;let{integrity:e,outputSignature:a}=this._data,r=document.createElement("div");r.className="integrity-section";let t=document.createElement("div");t.className="integrity-title",t.textContent="Integrity & Verification",r.appendChild(t);let s=document.createElement("div");s.className="integrity-stats",s.textContent=`${e.eventCount} events \xB7 ${e.checkpoints.length} checkpoints`,r.appendChild(s);let n=document.createElement("div");n.className="integrity-hash-block";let i=document.createElement("span");i.className="integrity-hash-label",i.textContent="Digest (SHA-256)";let c=document.createElement("code");c.className="hash",c.textContent=e.finalDigest,n.append(i,c),r.appendChild(n);let l=document.createElement("div");l.className="integrity-hash-block";let d=document.createElement("span");d.className="integrity-hash-label",d.textContent="Output Signature";let m=document.createElement("code");m.className="hash",m.textContent=a,l.append(d,m),r.appendChild(l);let u=document.createElement("div");u.className="integrity-bottom";let p=document.createElement("div");p.className="qr-container";let y=document.createElement("p");y.className="integrity-explainer",y.textContent="This scorecard includes cryptographic integrity verification. The digest covers all input events; the signature covers the analysis output. Compare against original session data or scan for verification.",u.appendChild(p),u.appendChild(y),r.appendChild(u),this.replaceChart(r),requestAnimationFrame(()=>this.renderQr(e.finalDigest))}renderQr(e){let a=this.shadow.querySelector(".qr-container");if(!a)return;let r=Kt(e);if(!r)return;let t=getComputedStyle(this),s=t.getPropertyValue("--wt-scorecard-text").trim()||"#E4E2DA",n=t.getPropertyValue("--wt-scorecard-status-clear").trim()||"#5EAE78";a.innerHTML=Qt(r,s,n)}};D.tagName="wt-integrity-footer";var Mt=new Set(["WT-104","WT-204","WT-302","WT-403","WT-503","WT-506","WT-509","WT-601","WT-602","WT-603"]);function Jt(o){return Mt.has(o)}function W(o){return o?Mt.has(o)?"pass":"flag":"unknown"}var I={contentOrigin:"Content Origin",timingAuthenticity:"Timing & Rhythm",revisionBehavior:"Revision Behavior",sessionContinuity:"Session Continuity",physicalPlausibility:"Physical Plausibility",temporalPatterns:"Temporal Patterns"},rt=["contentOrigin","timingAuthenticity","revisionBehavior","sessionContinuity","physicalPlausibility","temporalPatterns"],mt=["contentOrigin","timingAuthenticity","revisionBehavior"],ut=["sessionContinuity","physicalPlausibility","temporalPatterns"],Zt={"WT-100":()=>"No content was recorded during this session.","WT-101":o=>{let e=o.params.pct??0,a=100-e;return`Nearly all content (${e}%) was pasted from an external source. Only ${a}% of characters were typed directly.`},"WT-102":o=>`${o.params.pct??0}% of text was inserted via autocomplete, suggesting reliance on predictive input rather than original composition.`,"WT-103":o=>{let e=o.params.pct??0,a=100-e;return`${e}% of text was pasted from external sources. The remaining ${a}% was typed directly.`},"WT-104":()=>"All text was typed directly \u2014 no paste or autocomplete events were detected."},te={"WT-200":o=>{let e=(o.params.dwellMean??0).toFixed(1),a=(o.params.flightMean??0).toFixed(1);return`Keystroke timing magnitudes (dwell ${e}ms, flight ${a}ms) fall below plausible human ranges, consistent with programmatic input injection.`},"WT-201":o=>`Keystroke timing is mechanically uniform \u2014 the coefficient of variation (${(o.params.cv??0).toFixed(2)}) falls far below the human range of 0.3\u20130.8. This pattern is consistent with automated input.`,"WT-202":o=>`A highly periodic keystroke pattern was detected (score ${(o.params.score??0).toFixed(2)}). Human typing naturally varies; metronomic regularity suggests automation.`,"WT-203":o=>`Flight times between keystrokes are suspiciously uniform (CV ${(o.params.cv??0).toFixed(2)}), lacking the natural variability expected from human finger movement.`,"WT-204":()=>"Keystroke timing variability falls within normal human ranges. The rhythm is consistent with natural typing."},ee={"WT-500":(o,e)=>`Zero corrections across the entire session. Human writers make mistakes \u2014 a ${e.keydownCount}-keystroke session with no corrections is a strong signal content was not composed here.`,"WT-501":()=>"No keystrokes were recorded, so revision behavior could not be analyzed.","WT-502":o=>`Very low correction rate (${(o.params.pct??0).toFixed(1)}%). While some writers are precise, this level of accuracy across an entire session is unusual.`,"WT-503":o=>`Normal correction rate (${(o.params.pct??0).toFixed(1)}%). The writer made and fixed mistakes at a rate consistent with natural composition.`,"WT-504":o=>`No corrections, navigation, or undo in a ${o.params.count??0}-keystroke session \u2014 the text was entered linearly without any revision.`,"WT-505":()=>"Non-linear editing was detected despite a low correction rate, suggesting some revision activity.","WT-506":o=>`Authentic revision depth detected (product-process ratio ${(o.params.ratio??0).toFixed(2)}). The writing process shows genuine iterative refinement.`,"WT-507":o=>{let e=o.params.count??0,a=o.params.keydowns??0;return`Linear transcription pattern: only ${e} insertions in a ${a}-keystroke session, with minimal revision or restructuring.`},"WT-508":o=>`Forward-edge concentration: ${Math.round((o.params.ratio??0)*100)}% of keystrokes occurred at the end of the document with almost no in-document editing, consistent with copy-typing or automation.`,"WT-509":o=>`Multi-word restructuring detected (${Math.round((o.params.ratio??0)*100)}% of chars from multi-word pastes), suggesting authentic revision where the writer rearranged their own text.`},re={"WT-300":o=>{let e=Math.round(o.params.timestamp??0),a=(o.params.magnitude??0).toFixed(1);return`Typing rhythm changed abruptly at ${e}s (magnitude ${a}), suggesting a possible switch in input method or author.`},"WT-301":o=>`${o.params.count??0} tab-away events detected \u2014 the writer left and returned to this field multiple times during the session.`,"WT-302":()=>"Behavior was consistent throughout the session with no abrupt changes in typing rhythm or style."},ae={"WT-400":o=>`${o.params.pct??0}% of events lack browser trust indicators (isTrusted=false), suggesting synthetic event injection.`,"WT-401":o=>{let e=o.params.count??0,a=o.params.pct??0;return`${e} keydown events had no matching keyup (${a}% of keydowns). Automation tools often omit keyup events.`},"WT-402":o=>`${o.params.count??0} keystroke sequences exceed the maximum human typing speed, indicating programmatic input.`,"WT-403":()=>"All keystroke timing is physically plausible \u2014 no evidence of synthetic or injected events.","WT-404":o=>{let e=o.params.chars??0,a=o.params.pct??0;return`${e} characters (${a}%) were inserted programmatically, bypassing normal keystroke input. This is consistent with automated text injection.`},"WT-405":o=>{let e=o.params.count??0,a=o.params.pct??0;return`${e} events (${a}% of keydowns) have sub-millisecond dwell time. Human key press/release always takes 30\u2013150ms; zero-latency events indicate programmatic injection.`}},ne={"WT-600":o=>`No speed variation over a ${o.params.minutes??0}-minute session. Human typing naturally fluctuates; constant speed suggests automation.`,"WT-601":()=>"Natural warmup and fatigue pattern detected \u2014 the writer started slow, reached peak speed, then gradually slowed.","WT-602":()=>"Significant fatigue detected toward the end of the session, consistent with sustained human cognitive effort.","WT-603":()=>"Temporal patterns fall within normal range \u2014 typing pace varied naturally over the session.","WT-604":o=>`${o.params.ratio??0}% of keystrokes occurred in machine-like bursts, suggesting automated input segments.`,"WT-605":o=>`Uniform typing pace across the session (fluency SD ${(o.params.sd??0).toFixed(1)}). Human writers show more variation as they think, pause, and revise.`,"WT-606":o=>`Frequent revision interruptions detected (R-burst median ${(o.params.median??0).toFixed(1)}s), consistent with active editing behavior.`,"WT-607":o=>`No linguistic pause structure detected (sentence/word pause ratio ${(o.params.ratio??0).toFixed(2)}). Human writers pause longer before sentences than within words.`,"WT-608":o=>`Low cognitive pause rate (${(o.params.rate??0).toFixed(1)}% of keystrokes), suggesting text was transcribed rather than composed.`},oe={contentOrigin:Zt,timingAuthenticity:te,revisionBehavior:ee,sessionContinuity:re,physicalPlausibility:ae,temporalPatterns:ne};function at(o,e){let a=e[o];if(!(a!=null&&a.indicator))return"Analysis data not available.";let r=oe[o];if(!r)return Rt(a.indicator);let t=r[a.indicator.code];return t?t(a.indicator,e):Rt(a.indicator)}function Rt(o){return`Indicator ${o.code} detected.`}var se={contentOrigin:"In a typical session, you'd see a continuous band of typed content with occasional small paste events. A single bulk insertion is characteristic of copy-paste submission.",timingAuthenticity:"A human heatmap shows scattered clusters reflecting natural variation in finger movement. Tight single-point concentration indicates programmatic keystroke injection.",revisionBehavior:"Human writers produce clusters of corrections as they re-read and revise. Absence of corrections suggests transcription rather than composition.",sessionContinuity:"Steady growth with small plateaus (thinking pauses) is typical. A sudden vertical jump indicates bulk content insertion.",physicalPlausibility:"Human editing jumps around the document \u2014 revising earlier sections, appending new text. Strictly sequential cursor movement suggests automated input.",temporalPatterns:"Human typing shows varied pause durations \u2014 short pauses within words, longer pauses between sentences. Uniform pause lengths suggest automated pacing."};function pt(o){return se[o]??null}function nt(o,e){return({contentOrigin:r=>{let t=r.contentOrigin.metrics,s=Math.round(t.charactersByOrigin.pasted*100),n=Math.round(t.charactersByOrigin.typed*100),i=t.pasteEvents.length,c=t.pasteEvents.reduce((l,d)=>l+d.characterCount,0);return[{label:"pasted",value:`${s}%`,flagged:s>50},{label:"typed",value:`${n}%`,flagged:!1},{label:"paste events",value:String(i),flagged:!1},{label:"chars pasted",value:ie(c),flagged:!1}]},timingAuthenticity:r=>{let t=r.timingAuthenticity.metrics,s=t.flightTimeDistribution.cv,n=t.dwellTimeDistribution.mean;return[{label:"timing cv",value:s.toFixed(2),flagged:s<.2},{label:"mean dwell",value:`${Math.round(n)}ms`,flagged:n<20},{label:"periodicity",value:t.periodicityScore.toFixed(2),flagged:t.periodicityScore>.5},{label:"entropy",value:t.entropy.toFixed(1),flagged:t.entropy<1.5}]},revisionBehavior:r=>{let t=r.revisionBehavior.metrics;return[{label:"corrections",value:String(t.correctionCount),flagged:t.correctionCount===0},{label:"navigation",value:String(t.navigationCount),flagged:t.navigationCount===0},{label:"undo / redo",value:String(t.undoRedoCount),flagged:!1},{label:"product-process",value:t.productProcessRatio.toFixed(2),flagged:t.productProcessRatio===0}]},sessionContinuity:r=>{let t=r.sessionContinuity.metrics;return[{label:"change points",value:String(t.changePoints.length),flagged:t.changePoints.length>2},{label:"tab-away events",value:String(t.tabAwayEvents.length),flagged:!1}]},physicalPlausibility:r=>{let t=r.physicalPlausibility.metrics;return[{label:"synthetic ratio",value:`${Math.round(t.syntheticEventRatio*100)}%`,flagged:t.syntheticEventRatio>.05},{label:"impossible seq.",value:String(t.impossibleSequences.count),flagged:t.impossibleSequences.count>0},{label:"unmatched keydowns",value:String(t.unmatchedKeydownCount),flagged:t.unmatchedKeydownCount>5},{label:"zero-latency",value:String(t.zeroLatencyEventCount),flagged:t.zeroLatencyEventCount>0},{label:"Bulk Insert",value:String(t.bulkInsertCharCount),flagged:t.bulkInsertCharCount>0}]},temporalPatterns:r=>{let t=r.temporalPatterns.metrics;return[{label:"duration",value:ot(t.sessionDurationMs),flagged:!1},{label:"warmup ratio",value:t.warmupRatio.toFixed(2),flagged:!1},{label:"fatigue ratio",value:t.fatigueRatio.toFixed(2),flagged:!1},{label:"burst ratio",value:t.burstPattern.burstToTotalRatio.toFixed(2),flagged:t.burstPattern.burstToTotalRatio>.7}]}}[o]??(()=>[]))(e)}function ie(o){return o>=1e6?`${(o/1e6).toFixed(1)}m`:o>=1e3?`${(o/1e3).toFixed(1)}k`:String(o)}function ot(o){let e=Math.round(o/1e3);if(e<60)return`${e}s`;let a=Math.floor(e/60),r=e%60;return r===0?`${a}m`:`${a}m ${r}s`}var Wt={"coefficient of variation":{definition:"Standard deviation divided by the mean \u2014 measures how spread out values are relative to their average. Low CV means uniform timing.",docsPath:"/docs/analysis/timing/"},"dwell time":{definition:"How long a key is held down before being released.",docsPath:"/docs/analysis/timing/"},"flight time":{definition:"The gap between releasing one key and pressing the next.",docsPath:"/docs/analysis/timing/"},"product-process ratio":{definition:"The ratio of final text length to total characters typed. Low values suggest heavy revision; near 1.0 suggests linear transcription.",docsPath:"/docs/analysis/revision/"},periodicity:{definition:"How rhythmically regular the typing pattern is. High periodicity suggests metronomic (automated) input."},entropy:{definition:"A measure of randomness in timing. Low entropy means predictable, uniform intervals."},burst:{definition:"A rapid sequence of keystrokes between pauses. Human typing naturally occurs in bursts."},"synthetic event":{definition:"A keyboard event generated programmatically rather than by a real keypress. Browsers mark these with isTrusted=false."},"change point":{definition:"A moment where typing rhythm shifts abruptly, potentially indicating a switch in input method."}};function st(o,e){let a=v(o);for(let[r,t]of Object.entries(Wt)){let s=new RegExp(`\\b(${le(r)})\\b`,"gi");a=a.replace(s,n=>{let i=`title="${v(t.definition)}" class="wt-term"`,c=v(n);if(t.docsPath){let l=(e??"https://writetrack.dev")+t.docsPath;return`<a href="${v(l)}" target="_blank" rel="noopener"><abbr ${i}>${c}</abbr></a>`}return`<abbr ${i}>${c}</abbr>`})}return a}function le(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}import*as f from"@observablehq/plot";var ce={contentOrigin:[0,1],timingAuthenticity:[0,1],revisionBehavior:[0,3],sessionContinuity:[0,1],physicalPlausibility:[0,1],temporalPatterns:[1,2]},de={contentOrigin:{name:"Composition Timeline",desc:"Horizontal bar showing typing vs paste segments over time"},timingAuthenticity:{name:"Rhythm Heatmap",desc:"Dwell time vs flight time scatter showing keystroke timing distribution"},revisionBehavior:{name:"Corrections Timeline",desc:"Edit operations plotted over session time, sized by magnitude"},sessionContinuity:{name:"Document Growth Curve",desc:"Document length over session time, highlighting change points"},physicalPlausibility:{name:"Edit Waterfall",desc:"Cursor position over time, showing insertion and deletion patterns"},temporalPatterns:{name:"Speed Timeline",desc:"Words per minute over session duration, showing warmup, peak, and fatigue"}},$t={contentOrigin:1,timingAuthenticity:1,revisionBehavior:1,sessionContinuity:2,physicalPlausibility:2,temporalPatterns:2},me=`:host { display: block; overflow: hidden; }
|
|
170
|
+
`,O=class extends g{getStylesheet(){return N+`
|
|
171
|
+
`+oe}render(){if(!this._data)return;let{integrity:t,outputSignature:e}=this._data,n=document.createElement("div");n.className="integrity-section";let r=document.createElement("div");r.className="integrity-title",r.textContent="Integrity & Verification",n.appendChild(r);let o=document.createElement("div");o.className="integrity-stats",o.textContent=`${t.eventCount} events \xB7 ${t.checkpoints.length} checkpoints`,n.appendChild(o);let i=document.createElement("div");i.className="integrity-hash-block";let s=document.createElement("span");s.className="integrity-hash-label",s.textContent="Digest (SHA-256)";let l=document.createElement("code");l.className="hash",l.textContent=t.finalDigest,i.append(s,l),n.appendChild(i);let c=document.createElement("div");c.className="integrity-hash-block";let d=document.createElement("span");d.className="integrity-hash-label",d.textContent="Output Signature";let m=document.createElement("code");m.className="hash",m.textContent=e,c.append(d,m),n.appendChild(c);let u=document.createElement("div");u.className="integrity-bottom";let p=document.createElement("div");p.className="qr-container";let y=document.createElement("p");y.className="integrity-explainer",y.textContent="This scorecard includes cryptographic integrity verification. The digest covers all input events; the signature covers the analysis output. Compare against original session data or scan for verification.",u.appendChild(p),u.appendChild(y),n.appendChild(u),this.replaceChart(n),requestAnimationFrame(()=>this.renderQr(t.finalDigest))}renderQr(t){let e=this.shadow.querySelector(".qr-container");if(!e)return;let n=ne(t);if(!n)return;let r=getComputedStyle(this),o=r.getPropertyValue("--wt-scorecard-text").trim()||"#E4E2DA",i=r.getPropertyValue("--wt-scorecard-status-clear").trim()||"#5EAE78";e.innerHTML=ae(n,o,i)}};O.tagName="wt-integrity-footer";var $t=new Set(["WT-104","WT-106","WT-204","WT-302","WT-403","WT-503","WT-506","WT-509","WT-601","WT-602","WT-603"]);function ie(a){return $t.has(a)}function $(a){return a?$t.has(a)?"pass":"flag":"unknown"}var F={contentOrigin:"Content Origin",timingAuthenticity:"Timing & Rhythm",revisionBehavior:"Revision Behavior",sessionContinuity:"Session Continuity",physicalPlausibility:"Physical Plausibility",temporalPatterns:"Temporal Patterns"},nt=["contentOrigin","timingAuthenticity","revisionBehavior","sessionContinuity","physicalPlausibility","temporalPatterns"],pt=["contentOrigin","timingAuthenticity","revisionBehavior"],ht=["sessionContinuity","physicalPlausibility","temporalPatterns"],se={"WT-100":()=>"No content was recorded during this session.","WT-101":a=>{let t=a.params.pct??0,e=100-t;return`Nearly all content (${t}%) was pasted from an external source. Only ${e}% of characters were typed directly.`},"WT-102":a=>`${a.params.pct??0}% of text was inserted via autocomplete, suggesting reliance on predictive input rather than original composition.`,"WT-103":a=>{let t=a.params.pct??0,e=100-t;return`${t}% of text was pasted from external sources. The remaining ${e}% was typed directly.`},"WT-104":()=>"All text was typed directly \u2014 no paste or autocomplete events were detected.","WT-105":()=>"Unmodified external content detected \u2014 pasted text was not edited after insertion, suggesting pre-composed content.","WT-106":a=>`${a.params.rework??0}% of pasted content was subsequently reworked, indicating the writer integrated external material into their own composition.`,"WT-107":a=>{let t=a.params.pasteRatio??0,e=a.params.retentionPct??0;return`High paste volume (${t}% paste ratio) with ${e}% left unmodified \u2014 content was pasted in bulk without rework.`}},le={"WT-105":()=>"Unmodified external content detected \u2014 pasted text was not edited after insertion, suggesting pre-composed content.","WT-106":a=>`${a.params.rework??0}% of pasted content was subsequently reworked, indicating the writer integrated external material into their own composition.`,"WT-107":a=>{let t=a.params.pasteRatio??0,e=a.params.retentionPct??0;return`High paste volume (${t}% paste ratio) with ${e}% left unmodified \u2014 content was pasted in bulk without rework.`}},ce={"WT-200":a=>{let t=(a.params.dwellMean??0).toFixed(1),e=(a.params.flightMean??0).toFixed(1);return`Keystroke timing magnitudes (dwell ${t}ms, flight ${e}ms) fall below plausible human ranges, consistent with programmatic input injection.`},"WT-201":a=>`Keystroke timing is mechanically uniform \u2014 the coefficient of variation (${(a.params.cv??0).toFixed(2)}) falls far below the human range of 0.3\u20130.8. This pattern is consistent with automated input.`,"WT-202":a=>`A highly periodic keystroke pattern was detected (score ${(a.params.score??0).toFixed(2)}). Human typing naturally varies; metronomic regularity suggests automation.`,"WT-203":a=>`Flight times between keystrokes are suspiciously uniform (CV ${(a.params.cv??0).toFixed(2)}), lacking the natural variability expected from human finger movement.`,"WT-204":()=>"Keystroke timing variability falls within normal human ranges. The rhythm is consistent with natural typing."},de={"WT-500":(a,t)=>`Zero corrections across the entire session. Human writers make mistakes \u2014 a ${t.keydownCount}-keystroke session with no corrections is a strong signal content was not composed here.`,"WT-501":()=>"No keystrokes were recorded, so revision behavior could not be analyzed.","WT-502":a=>`Very low correction rate (${(a.params.pct??0).toFixed(1)}%). While some writers are precise, this level of accuracy across an entire session is unusual.`,"WT-503":a=>`Normal correction rate (${(a.params.pct??0).toFixed(1)}%). The writer made and fixed mistakes at a rate consistent with natural composition.`,"WT-504":a=>`No corrections, navigation, or undo in a ${a.params.count??0}-keystroke session \u2014 the text was entered linearly without any revision.`,"WT-505":()=>"Non-linear editing was detected despite a low correction rate, suggesting some revision activity.","WT-506":a=>`Authentic revision depth detected (product-process ratio ${(a.params.ratio??0).toFixed(2)}). The writing process shows genuine iterative refinement.`,"WT-507":a=>{let t=a.params.count??0,e=a.params.keydowns??0;return`Sequential typing pattern: ${t} mid-document insertions in a ${e}-keystroke session. Content was entered start-to-finish without returning to edit earlier sections.`},"WT-508":a=>`Forward-edge concentration: ${Math.round((a.params.ratio??0)*100)}% of keystrokes occurred at the end of the document with almost no in-document editing, consistent with copy-typing or automation.`,"WT-509":a=>`Multi-word restructuring detected (${Math.round((a.params.ratio??0)*100)}% of chars from multi-word pastes), suggesting authentic revision where the writer rearranged their own text.`},me={"WT-300":a=>{let t=Math.round(a.params.timestamp??0),e=(a.params.magnitude??0).toFixed(1);return`Typing rhythm changed abruptly at ${t}s (magnitude ${e}), suggesting a possible switch in input method or author.`},"WT-301":a=>`${a.params.count??0} tab-away events detected \u2014 the writer left and returned to this field multiple times during the session.`,"WT-302":()=>"Behavior was consistent throughout the session with no abrupt changes in typing rhythm or style."},ue={"WT-400":a=>`${a.params.pct??0}% of events lack browser trust indicators (isTrusted=false), suggesting synthetic event injection.`,"WT-401":a=>{let t=a.params.count??0,e=a.params.pct??0;return`${t} keydown events had no matching keyup (${e}% of keydowns). Automation tools often omit keyup events.`},"WT-402":a=>`${a.params.count??0} keystroke sequences exceed the maximum human typing speed, indicating programmatic input.`,"WT-403":()=>"All keystroke timing is physically plausible \u2014 no evidence of synthetic or injected events.","WT-404":a=>{let t=a.params.chars??0,e=a.params.pct??0;return`${t} characters (${e}%) were inserted via untrusted programmatic events rather than direct user input.`},"WT-405":a=>{let t=a.params.count??0,e=a.params.pct??0;return`${t} events (${e}% of keydowns) have sub-millisecond dwell time. Human key press/release always takes 30\u2013150ms; zero-latency events indicate programmatic injection.`}},pe={"WT-600":a=>`No speed variation over a ${a.params.minutes??0}-minute session. Human typing naturally fluctuates; constant speed suggests automation.`,"WT-601":()=>"Natural warmup and fatigue pattern detected \u2014 the writer started slow, reached peak speed, then gradually slowed.","WT-602":()=>"Significant fatigue detected toward the end of the session, consistent with sustained human cognitive effort.","WT-603":()=>"Temporal patterns fall within normal range \u2014 typing pace varied naturally over the session.","WT-604":a=>`${a.params.ratio??0}% of keystrokes occurred in machine-like bursts, suggesting automated input segments.`,"WT-605":a=>`Uniform typing pace across the session (fluency SD ${(a.params.sd??0).toFixed(1)}). Human writers show more variation as they think, pause, and revise.`,"WT-606":a=>`Frequent revision interruptions detected (R-burst median ${(a.params.median??0).toFixed(1)}s), consistent with active editing behavior.`,"WT-607":a=>`No linguistic pause structure detected (sentence/word pause ratio ${(a.params.ratio??0).toFixed(2)}). Human writers pause longer before sentences than within words.`,"WT-608":a=>`Low cognitive pause rate (${(a.params.rate??0).toFixed(1)}% of keystrokes), suggesting text was transcribed rather than composed.`},he={contentOrigin:se,timingAuthenticity:ce,revisionBehavior:de,sessionContinuity:me,physicalPlausibility:ue,temporalPatterns:pe};function at(a,t){let e=t[a];if(!(e!=null&&e.indicator))return"Analysis data not available.";let n=he[a];if(!n)return Wt(e.indicator);if(a==="contentOrigin"&&e.pasteReworkIndicator){let o=e.pasteReworkIndicator.code,i=le[o];if(i)return i(e.pasteReworkIndicator,t)}let r=n[e.indicator.code];return r?r(e.indicator,t):Wt(e.indicator)}function Wt(a){return`Indicator ${a.code} detected.`}var fe={contentOrigin:"Shows the mix of typed, pasted, and autocompleted content. Most writing sessions include some paste events \u2014 the balance and context matter more than presence alone.",timingAuthenticity:"A human heatmap shows scattered clusters reflecting natural variation in finger movement. Tight single-point concentration indicates programmatic keystroke injection.",revisionBehavior:"Human writers produce clusters of corrections as they re-read and revise. Absence of corrections suggests transcription rather than composition.",sessionContinuity:"Steady growth with small plateaus (thinking pauses) is typical. A sudden vertical jump indicates bulk content insertion.",physicalPlausibility:"Human editing jumps around the document \u2014 revising earlier sections, appending new text. Strictly sequential cursor movement suggests automated input.",temporalPatterns:"Human typing shows varied pause durations \u2014 short pauses within words, longer pauses between sentences. Uniform pause lengths suggest automated pacing."};function ft(a){return fe[a]??null}function ot(a,t){return({contentOrigin:ge,timingAuthenticity:ye,revisionBehavior:be,sessionContinuity:we,physicalPlausibility:ve,temporalPatterns:xe}[a]??(()=>[]))(t)}function ge(a){let t=a.contentOrigin.metrics,e=Math.round(t.charactersByOrigin.pasted*100),n=Math.round(t.charactersByOrigin.typed*100),r=t.pasteEvents.length,o=t.pasteEvents.reduce((i,s)=>i+s.characterCount,0);return[{label:"pasted",value:`${e}%`,flagged:e>50},{label:"typed",value:`${n}%`,flagged:!1},{label:"paste events",value:String(r),flagged:!1},{label:"chars pasted",value:Se(o),flagged:!1}]}function ye(a){let t=a.timingAuthenticity.metrics,e=t.flightTimeDistribution.cv,n=t.dwellTimeDistribution.mean;return[{label:"timing cv",value:e.toFixed(2),flagged:e<.2},{label:"mean dwell",value:`${Math.round(n)}ms`,flagged:n<20},{label:"periodicity",value:t.periodicityScore.toFixed(2),flagged:t.periodicityScore>.5},{label:"entropy",value:t.entropy.toFixed(1),flagged:t.entropy<1.5}]}function be(a){let t=a.revisionBehavior.metrics;return[{label:"corrections",value:String(t.correctionCount),flagged:t.correctionCount===0},{label:"navigation",value:String(t.navigationCount),flagged:t.navigationCount===0},{label:"undo / redo",value:String(t.undoRedoCount),flagged:!1},{label:"product-process",value:t.productProcessRatio.toFixed(2),flagged:t.productProcessRatio===0}]}function we(a){let t=a.sessionContinuity.metrics;return[{label:"change points",value:String(t.changePoints.length),flagged:t.changePoints.length>2},{label:"tab-away events",value:String(t.tabAwayEvents.length),flagged:!1}]}function ve(a){let t=a.physicalPlausibility.metrics;return[{label:"synthetic ratio",value:`${Math.round(t.syntheticEventRatio*100)}%`,flagged:t.syntheticEventRatio>.05},{label:"impossible seq.",value:String(t.impossibleSequences.count),flagged:t.impossibleSequences.count>0},{label:"unmatched keydowns",value:String(t.unmatchedKeydownCount),flagged:t.unmatchedKeydownCount>5},{label:"zero-latency",value:String(t.zeroLatencyEventCount),flagged:t.zeroLatencyEventCount>0},{label:"Bulk Insert",value:String(t.bulkInsertCharCount),flagged:t.bulkInsertCharCount>0}]}function xe(a){let t=a.temporalPatterns.metrics;return[{label:"duration",value:it(t.sessionDurationMs),flagged:!1},{label:"warmup ratio",value:t.warmupRatio.toFixed(2),flagged:!1},{label:"fatigue ratio",value:t.fatigueRatio.toFixed(2),flagged:!1},{label:"burst ratio",value:t.burstPattern.burstToTotalRatio.toFixed(2),flagged:t.burstPattern.burstToTotalRatio>.7}]}function Se(a){return a>=1e6?`${(a/1e6).toFixed(1)}m`:a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a)}function it(a){let t=Math.round(a/1e3);if(t<60)return`${t}s`;let e=Math.floor(t/60),n=t%60;return n===0?`${e}m`:`${e}m ${n}s`}var _t={"coefficient of variation":{definition:"Standard deviation divided by the mean \u2014 measures how spread out values are relative to their average. Low CV means uniform timing.",docsPath:"/docs/analysis/timing/"},"dwell time":{definition:"How long a key is held down before being released.",docsPath:"/docs/analysis/timing/"},"flight time":{definition:"The gap between releasing one key and pressing the next.",docsPath:"/docs/analysis/timing/"},"product-process ratio":{definition:"The ratio of final text length to total characters typed. Low values suggest heavy revision; near 1.0 suggests linear transcription.",docsPath:"/docs/analysis/revision/"},periodicity:{definition:"How rhythmically regular the typing pattern is. High periodicity suggests metronomic (automated) input."},entropy:{definition:"A measure of randomness in timing. Low entropy means predictable, uniform intervals."},burst:{definition:"A rapid sequence of keystrokes between pauses. Human typing naturally occurs in bursts."},"synthetic event":{definition:"A keyboard event generated programmatically rather than by a real keypress. Browsers mark these with isTrusted=false."},"change point":{definition:"A moment where typing rhythm shifts abruptly, potentially indicating a switch in input method."}};function st(a,t){let e=v(a);for(let[n,r]of Object.entries(_t)){let o=new RegExp(`\\b(${ke(n)})\\b`,"gi");e=e.replace(o,i=>{let s=`title="${v(r.definition)}" class="wt-term"`,l=v(i);if(r.docsPath){let c=(t??"https://writetrack.dev")+r.docsPath;return`<a href="${v(c)}" target="_blank" rel="noopener"><abbr ${s}>${l}</abbr></a>`}return`<abbr ${s}>${l}</abbr>`})}return e}function ke(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}import*as f from"@observablehq/plot";var Ce={contentOrigin:[0,1],timingAuthenticity:[0,1],revisionBehavior:[0,3],sessionContinuity:[0,1],physicalPlausibility:[0,1],temporalPatterns:[1,2]},Te={contentOrigin:{name:"Composition Timeline",desc:"Horizontal bar showing typing vs paste segments over time"},timingAuthenticity:{name:"Rhythm Heatmap",desc:"Dwell time vs flight time scatter showing keystroke timing distribution"},revisionBehavior:{name:"Corrections Timeline",desc:"Edit operations plotted over session time, sized by magnitude"},sessionContinuity:{name:"Document Growth Curve",desc:"Document length over session time, highlighting change points"},physicalPlausibility:{name:"Edit Waterfall",desc:"Cursor position over time, showing insertion and deletion patterns"},temporalPatterns:{name:"Speed Timeline",desc:"Words per minute over session duration, showing warmup, peak, and fatigue"}},Dt={contentOrigin:1,timingAuthenticity:1,revisionBehavior:1,sessionContinuity:2,physicalPlausibility:2,temporalPatterns:2},Ee=`:host { display: block; overflow: hidden; }
|
|
172
172
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
173
173
|
.page {
|
|
174
174
|
max-width: 100%;
|
|
@@ -355,5 +355,5 @@ var ft=`:host {
|
|
|
355
355
|
.page { padding: 1.25rem 1rem 2rem; }
|
|
356
356
|
.detail-inner { padding: 1rem; }
|
|
357
357
|
}
|
|
358
|
-
`,
|
|
359
|
-
`+me}attributeChangedCallback(a,r,t){if(a==="theme"&&this._data&&this.hasRendered){let s=this.shadow.querySelector(".theme-toggle");s&&(s.textContent=t==="dark"?"Light":"Dark");let n=this.shadow.querySelector("wt-integrity-footer");n&&t&&n.setAttribute("theme",t),requestAnimationFrame(()=>this.rerenderAllCharts());return}super.attributeChangedCallback(a,r,t)}render(){var m;if(!((m=this._data)!=null&&m.analysis))return;let{data:a,analysis:r}=this._data;this.t={1:null,2:null};let t=document.createElement("div");t.className="page",t.appendChild(this.buildHeader(r,a.metadata.sessionId??"")),t.appendChild(this.buildSummary(r)),t.appendChild(this.buildTierLabel("Primary Evidence"));let s=this.buildGrid(1,r);t.appendChild(s);let n=this.buildDetailPanel(1);t.appendChild(n),t.appendChild(this.buildTierLabel("Supporting Context"));let i=this.buildGrid(2,r);t.appendChild(i);let c=this.buildDetailPanel(2);t.appendChild(c);let l=document.createElement("wt-integrity-footer"),d=this.getAttribute("theme");d&&l.setAttribute("theme",d),Tt(l),l.setData({integrity:r.integrity,outputSignature:r.outputSignature,sessionId:a.metadata.sessionId??""}),t.appendChild(l),this.replaceChart(t),requestAnimationFrame(()=>{this.renderAllCharts()})}buildHeader(a,r){let t=document.createElement("header");t.className="header";let s=document.createElement("div");s.className="header-meta";let n=document.createElement("span");n.textContent=`WriteTrack v${a.version}`;let i=document.createElement("span");i.className="sep",i.innerHTML="·";let c=document.createElement("span"),l=new Date(a.analyzedAt);c.textContent=l.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"});let d=document.createElement("span");d.className="sep",d.innerHTML="·";let m=document.createElement("span");m.className="mono",m.textContent=r,s.append(n,i,c,d,m);let u=document.createElement("button");return u.className="theme-toggle",u.textContent=this.getAttribute("theme")==="dark"?"Light":"Dark",u.addEventListener("click",()=>{let y=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",y);try{localStorage.setItem("writetrack-v4-theme",y)}catch{}}),t.append(s,u),t}buildSummary(a){let r=document.createElement("section");r.className="summary";let t=document.createElement("div");t.className="summary-headline";let s=document.createElement("h1");s.textContent="Session Scorecard";let n=rt.filter(d=>W(this.getIndicatorCode(a,d))==="pass").length,i=document.createElement("span");i.className="tally",i.textContent=`${n} of ${rt.length} clear`,t.append(s,i),r.appendChild(t);let c=document.createElement("div");c.className="summary-stats";let l=ot(a.temporalPatterns.metrics.sessionDurationMs);c.innerHTML=`<span>${v(l)} duration</span><span class="sep">·</span><span>${a.keydownCount} keystrokes</span>`,r.appendChild(c);for(let d of rt)if(W(this.getIndicatorCode(a,d))==="flag"){let m=document.createElement("div");m.className="summary-flag";let u=at(d,a);m.innerHTML=`<strong>Flagged</strong> ${v(I[d]??d)}\u2009\u2014\u2009${v(u)}`,r.appendChild(m)}return r}buildTierLabel(a){let r=document.createElement("div");return r.className="tier-label",r.textContent=a,r}buildGrid(a,r){let t=document.createElement("div");t.className="indicator-grid",t.id=`grid-${a}`;let s=a===1?mt:ut;for(let n of s)t.appendChild(this.buildCell(n,r));return t}buildCell(a,r){let t=this.getIndicatorCode(r,a),n=W(t)==="flag",i=document.createElement("div");i.className="cell"+(n?" flagged":""),i.setAttribute("data-category",a),i.addEventListener("click",()=>this.selectCell(a));let c=document.createElement("div");c.className="cell-header";let l=document.createElement("div");l.className="cell-name-col";let d=document.createElement("span");d.className="cell-name",d.textContent=I[a]??a,l.appendChild(d);let m=document.createElement("span");m.className=`cell-status ${n?"flagged":"clear"}`,m.textContent=n?"flagged":"clear",c.append(l,m),i.appendChild(c);let u=document.createElement("div");u.className="cell-chart",i.appendChild(u);let p=nt(a,r),y=ce[a];if(a==="physicalPlausibility"&&!n)if(p.every(b=>b.value==="0"||b.value==="0%")){let b=document.createElement("div");b.className="cell-allclear",b.innerHTML='<span class="cell-allclear-dot"></span>No anomalies detected',i.appendChild(b)}else i.appendChild(this.buildCellMetrics(p,y));else i.appendChild(this.buildCellMetrics(p,y));let h=document.createElement("div");return h.className="cell-affordance",h.innerHTML='<span>Details</span><span class="cell-affordance-arrow">▸</span>',i.appendChild(h),i}buildCellMetrics(a,r){let t=document.createElement("div");t.className="cell-metrics";for(let s of r){let n=a[s];if(!n)continue;let i=document.createElement("div");i.className="cell-metric",i.innerHTML=`<span class="cell-metric-label">${v(n.label)}</span><span class="cell-metric-value">${v(n.value)}</span>`,t.appendChild(i)}return t}buildDetailPanel(a){let r=document.createElement("div");r.className="detail-panel",r.id=`detail-${a}`;let t=document.createElement("button");t.className="detail-close",t.setAttribute("aria-label","Close detail"),t.innerHTML="× Close",t.addEventListener("click",n=>{n.stopPropagation(),this.closeDetail(a)}),r.appendChild(t);let s=document.createElement("div");return s.className="detail-inner",s.id=`detail-${a}-inner`,r.appendChild(s),r}selectCell(a){var d;let r=(d=this._data)==null?void 0:d.analysis;if(!r)return;let t=$t[a],s=this.shadow.getElementById(`detail-${t}`),n=this.shadow.getElementById(`detail-${t}-inner`);if(!s||!n)return;let i=this.shadow.getElementById(`grid-${t}`);if(i==null||i.querySelectorAll(".cell").forEach(m=>m.classList.remove("selected")),this.t[t]===a){this.collapsePanel(s),this.t[t]=null;return}let c=this.t[t]!==null;this.t[t]=a;let l=i==null?void 0:i.querySelector(`[data-category="${a}"]`);l==null||l.classList.add("selected"),this.populateDetail(n,a,r),c?requestAnimationFrame(()=>{let m=n.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(a,!1);u&&m.replaceChildren(u)}}):this.expandPanel(s,()=>{let m=n.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(a,!1);u&&m.replaceChildren(u)}})}populateDetail(a,r,t){let s=this.getIndicatorCode(t,r),i=W(s)==="flag",c='<div class="detail-head">';c+=`<span class="detail-name">${v(I[r]??r)}</span>`,c+=`<span class="detail-code">${v(s??"")}</span>`,c+=`<span class="detail-status-label ${i?"flagged":"clear"}">${i?"flagged":"clear"}</span>`,c+="</div>";let l=at(r,t);c+=`<p class="detail-summary">${st(l)}</p>`,c+='<div class="detail-chart-area"></div>';let d=de[r];c+=`<div class="detail-chart-caption">${v(d.name)} \u2014 ${v(d.desc)}</div>`;let m=nt(r,t);c+='<div class="detail-metrics">';for(let p of m)c+=`<div class="detail-metric"><span class="detail-metric-value">${v(p.value)}</span><span class="detail-metric-label">${v(p.label)}</span></div>`;c+="</div>";let u=pt(r);u&&(c+=`<p class="detail-explainer">${st(u)}</p>`),a.innerHTML=c}closeDetail(a){let r=this.shadow.getElementById(`detail-${a}`);if(!r)return;let t=this.shadow.getElementById(`grid-${a}`);t==null||t.querySelectorAll(".cell").forEach(s=>s.classList.remove("selected")),this.collapsePanel(r),this.t[a]=null}expandPanel(a,r){let t=a.querySelector(".detail-inner");a.style.height="0px",a.style.display="block",a.offsetHeight,a.style.height=`${t.offsetHeight+40}px`;let s=()=>{a.style.height="auto",r==null||r()};a.addEventListener("transitionend",s,{once:!0})}collapsePanel(a){a.style.height=`${a.scrollHeight}px`,a.offsetHeight,a.style.height="0px";let r=()=>{a.style.display=""};a.addEventListener("transitionend",r,{once:!0})}getIndicatorCode(a,r){var s;let t=a[r];return(s=t==null?void 0:t.indicator)==null?void 0:s.code}getComputedColors(){let a=getComputedStyle(this);return{line:a.getPropertyValue("--wt-scorecard-chart-line").trim()||"#1C1B18",accent:a.getPropertyValue("--wt-scorecard-chart-accent").trim()||"#2B7A5D",flagged:a.getPropertyValue("--wt-scorecard-chart-flagged").trim()||"#B8412D",border:a.getPropertyValue("--wt-scorecard-border").trim()||"#E0DED6",tertiary:a.getPropertyValue("--wt-scorecard-text-tertiary").trim()||"#706E64"}}getChartWidth(a,r){var s;let t=r?`[data-category="${a}"] .cell-chart`:`#detail-${$t[a]}-inner .detail-chart-area`;return((s=this.shadow.querySelector(t))==null?void 0:s.getBoundingClientRect().width)??300}plotOpts(a,r,t,s,n){return{width:a,height:r?52:200,marginTop:r?4:36,marginRight:r?0:16,marginBottom:r?4:44,marginLeft:r?0:55,x:r?{axis:null,...s}:{...s},y:r?{axis:null,...n}:{...n},style:{background:"transparent",color:t.tertiary,fontFamily:"var(--wt-scorecard-font-data)",fontSize:"10px"}}}plotCategory(a,r){var d;if(!((d=this._data)!=null&&d.analysis))return null;let{data:t,analysis:s}=this._data,n=this.getComputedColors(),i=this.getIndicatorCode(s,a),l=W(i)==="flag"?n.flagged:n.accent;switch(a){case"contentOrigin":return this.plotContentOrigin(s,r,n);case"timingAuthenticity":return this.plotTimingAuthenticity(s,r,n,l);case"revisionBehavior":return this.plotRevisionBehavior(t,r,n);case"sessionContinuity":return this.plotSessionContinuity(t,s,r,n,l);case"physicalPlausibility":return this.plotPhysicalPlausibility(t,r,n);case"temporalPatterns":return this.plotTemporalPatterns(s,r,n,l)}}renderAllCharts(){this.shadow.querySelectorAll(".cell-chart").forEach(a=>{let r=a.closest(".cell"),t=r==null?void 0:r.getAttribute("data-category");if(!t)return;let s=this.plotCategory(t,!0);s&&a.replaceChildren(s)})}rerenderAllCharts(){this.renderAllCharts();for(let a of[1,2]){let r=this.t[a];if(r){let t=this.shadow.querySelector(`#detail-${a}-inner .detail-chart-area`);if(t){let s=this.plotCategory(r,!1);s&&t.replaceChildren(s)}}}}plotContentOrigin(a,r,t){let s=H(a);if(s.length===0)return null;let n={typing:t.accent,paste:t.flagged,pause:t.border,tabAway:t.tertiary,autocomplete:t.flagged,navigating:t.line},i=s.map(d=>({...d,color:n[d.type]??t.line})),c=this.getChartWidth("contentOrigin",r),l=this.plotOpts(c,r,t,{label:"Time (s)"},{padding:.2});return f.plot({...l,marginLeft:r?0:8,y:{axis:null,padding:.2},marks:[f.barX(i,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5})]})}plotTimingAuthenticity(a,r,t,s){let n=Y(a);if(n.length===0)return null;let i=this.getChartWidth("timingAuthenticity",r),c=[f.dot(n,{x:"dwell",y:"flight",fill:s,fillOpacity:r?.4:.5,r:r?2:3,stroke:"none"})];if(!r){let l=n.reduce((m,u)=>m+u.dwell,0)/n.length,d=n.reduce((m,u)=>m+u.flight,0)/n.length;c.push(f.ruleX([l],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}),f.ruleY([d],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}))}return f.plot({...this.plotOpts(i,r,t,{label:"Dwell (ms)"},{label:"Flight (ms)"}),marginRight:r?4:12,marks:c})}plotRevisionBehavior(a,r,t){let s=et(a);if(s.length===0)return null;let n={insert:t.accent,delete:t.flagged,paste:t.line,cut:t.tertiary},i=s.map(l=>({...l,color:n[l.type]??t.line})),c=this.getChartWidth("revisionBehavior",r);return r?f.plot({...this.plotOpts(c,r,t),marks:[f.dot(i,{x:"time",y:()=>0,fill:"color",fillOpacity:.6,r:Math.min(3,Math.max(2,c/i.length/4)),stroke:"none"})],style:{background:"transparent"}}):f.plot({...this.plotOpts(c,r,t,{label:"Time (s)"},{label:null,domain:["insert","delete","paste","cut"]}),marginLeft:70,r:{range:[3,12]},marks:[f.dot(i,{x:"time",y:"type",r:"chars",fill:"color",fillOpacity:.7,stroke:"none"})]})}plotSessionContinuity(a,r,t,s,n){var m,u;let i=Q(a);if(i.length===0)return null;let c=this.getChartWidth("sessionContinuity",t),l=[f.areaY(i,{x:"time",y:"chars",fill:n,fillOpacity:.1,curve:"step-after"}),f.lineY(i,{x:"time",y:"chars",stroke:n,strokeWidth:1.5,curve:"step-after"})],d=((u=(m=r.sessionContinuity)==null?void 0:m.metrics)==null?void 0:u.changePoints)??[];if(d.length>0){let p=d[0].timestamp/1e3;l.push(f.ruleX([p],{stroke:s.flagged,strokeDasharray:"4,3",strokeWidth:1}))}if(!t){let p=i.filter(h=>h.isPaste),y=i.filter(h=>h.isCut);p.length>0&&l.push(f.dot(p,{x:"time",y:"chars",fill:s.accent,r:4,stroke:"none"})),y.length>0&&l.push(f.dot(y,{x:"time",y:"chars",fill:s.flagged,r:4,symbol:"diamond",stroke:"none"}))}return f.plot({...this.plotOpts(c,t,s,{label:"Time (s)"},{label:"Characters",grid:!0}),marks:l})}plotPhysicalPlausibility(a,r,t){let s=Z(a);if(s.keystrokes.length===0)return null;let n=this.getChartWidth("physicalPlausibility",r),i=[f.line(s.keystrokes,{x:"time",y:"position",stroke:t.line,strokeWidth:r?1:1.5,strokeOpacity:r?.6:.8})];return r||(s.pastes.length>0&&i.push(f.dot(s.pastes,{x:"time",y:"position",fill:t.accent,r:4,stroke:"none"})),s.cuts.length>0&&i.push(f.dot(s.cuts,{x:"time",y:"position",fill:t.flagged,r:4,stroke:"none"}))),f.plot({...this.plotOpts(n,r,t,{label:"Time (s)"},{label:"Position",reverse:!0}),marks:i})}plotTemporalPatterns(a,r,t,s){let n=z(a);if(n.length===0)return null;let i=this.getChartWidth("temporalPatterns",r);return f.plot({...this.plotOpts(i,r,t,{label:"Time (s)"},{label:"Speed (CPM)",grid:!0}),marks:[f.areaY(n,{x:"time",y:"speed",fill:s,fillOpacity:.12,curve:"natural"}),f.lineY(n,{x:"time",y:"speed",stroke:s,strokeWidth:1.5,curve:"natural"})]})}};it.tagName="wt-scorecard";export{g as BaseChart,I as CATEGORY_NAMES,G as CompositionTimeline,tt as CorrectionsBubble,K as DocumentGrowth,X as DocumentRibbon,J as EditWaterfall,Wt as GLOSSARY,D as IntegrityFooter,q as PauseDistribution,V as RhythmHeatmap,ct as SEGMENT_COLORS,lt as Sparkline,F as SpeedTimeline,mt as TIER1_CATEGORIES,ut as TIER2_CATEGORIES,it as WtScorecard,et as extractCorrectionBubbles,Q as extractGrowthData,yt as extractPasteMarkers,bt as extractPauseHistogram,Y as extractRhythmPairs,wt as extractRibbonData,H as extractSegments,gt as extractSeries,z as extractSpeedData,Z as extractWaterfallData,ot as formatDuration,pt as generateCaption,at as generateSummary,nt as getMetrics,W as getStatus,Jt as isPass,st as wrapTerms};
|
|
358
|
+
`,lt=class extends g{constructor(){super();this.t={1:null,2:null};O.register()}onResize(){this.rerenderAllCharts()}getStylesheet(){return N+`
|
|
359
|
+
`+Ee}attributeChangedCallback(e,n,r){if(e==="theme"&&this._data&&this.hasRendered){let o=this.shadow.querySelector(".theme-toggle");o&&(o.textContent=r==="dark"?"Light":"Dark");let i=this.shadow.querySelector("wt-integrity-footer");i&&r&&i.setAttribute("theme",r),requestAnimationFrame(()=>this.rerenderAllCharts());return}super.attributeChangedCallback(e,n,r)}render(){var m;if(!((m=this._data)!=null&&m.analysis))return;let{data:e,analysis:n}=this._data;this.t={1:null,2:null};let r=document.createElement("div");r.className="page",r.appendChild(this.buildHeader(n,e.metadata.sessionId??"")),r.appendChild(this.buildSummary(n)),r.appendChild(this.buildTierLabel("Primary Evidence"));let o=this.buildGrid(1,n);r.appendChild(o);let i=this.buildDetailPanel(1);r.appendChild(i),r.appendChild(this.buildTierLabel("Supporting Context"));let s=this.buildGrid(2,n);r.appendChild(s);let l=this.buildDetailPanel(2);r.appendChild(l);let c=document.createElement("wt-integrity-footer"),d=this.getAttribute("theme");d&&c.setAttribute("theme",d),Pt(c),c.setData({integrity:n.integrity,outputSignature:n.outputSignature,sessionId:e.metadata.sessionId??""}),r.appendChild(c),this.replaceChart(r),requestAnimationFrame(()=>{this.renderAllCharts()})}buildHeader(e,n){let r=document.createElement("header");r.className="header";let o=document.createElement("div");o.className="header-meta";let i=document.createElement("span");i.textContent=`WriteTrack v${e.version}`;let s=document.createElement("span");s.className="sep",s.innerHTML="·";let l=document.createElement("span"),c=new Date(e.analyzedAt);l.textContent=c.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"});let d=document.createElement("span");d.className="sep",d.innerHTML="·";let m=document.createElement("span");if(m.className="mono",m.textContent=n,o.append(i,s,l,d,m),this.hasAttribute("no-toggle"))r.append(o);else{let u=document.createElement("button");u.className="theme-toggle",u.textContent=this.getAttribute("theme")==="dark"?"Light":"Dark",u.addEventListener("click",()=>{let y=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",y);try{localStorage.setItem("writetrack-v4-theme",y)}catch{}}),r.append(o,u)}return r}buildSummary(e){let n=document.createElement("section");n.className="summary";let r=document.createElement("div");r.className="summary-headline";let o=document.createElement("h1");o.textContent="Session Scorecard";let i=nt.filter(d=>$(this.getIndicatorCode(e,d))==="pass").length,s=document.createElement("span");s.className="tally",s.textContent=`${i} of ${nt.length} clear`,r.append(o,s),n.appendChild(r);let l=document.createElement("div");l.className="summary-stats";let c=it(e.temporalPatterns.metrics.sessionDurationMs);l.innerHTML=`<span>${v(c)} duration</span><span class="sep">·</span><span>${e.keydownCount} keystrokes</span>`,n.appendChild(l);for(let d of nt)if($(this.getIndicatorCode(e,d))==="flag"){let m=document.createElement("div");m.className="summary-flag";let u=at(d,e);m.innerHTML=`<strong>Flagged</strong> ${v(F[d]??d)}\u2009\u2014\u2009${v(u)}`,n.appendChild(m)}return n}buildTierLabel(e){let n=document.createElement("div");return n.className="tier-label",n.textContent=e,n}buildGrid(e,n){let r=document.createElement("div");r.className="indicator-grid",r.id=`grid-${e}`;let o=e===1?pt:ht;for(let i of o)r.appendChild(this.buildCell(i,n));return r}buildCell(e,n){let r=this.getIndicatorCode(n,e),i=$(r)==="flag",s=document.createElement("div");s.className="cell"+(i?" flagged":""),s.setAttribute("data-category",e),s.addEventListener("click",()=>this.selectCell(e));let l=document.createElement("div");l.className="cell-header";let c=document.createElement("div");c.className="cell-name-col";let d=document.createElement("span");d.className="cell-name",d.textContent=F[e]??e,c.appendChild(d);let m=document.createElement("span");m.className=`cell-status ${i?"flagged":"clear"}`,m.textContent=i?"flagged":"clear",l.append(c,m),s.appendChild(l);let u=document.createElement("div");u.className="cell-chart",s.appendChild(u);let p=ot(e,n),y=Ce[e];if(e==="physicalPlausibility"&&!i)if(p.every(b=>b.value==="0"||b.value==="0%")){let b=document.createElement("div");b.className="cell-allclear",b.innerHTML='<span class="cell-allclear-dot"></span>No anomalies detected',s.appendChild(b)}else s.appendChild(this.buildCellMetrics(p,y));else s.appendChild(this.buildCellMetrics(p,y));let h=document.createElement("div");return h.className="cell-affordance",h.innerHTML='<span>Details</span><span class="cell-affordance-arrow">▸</span>',s.appendChild(h),s}buildCellMetrics(e,n){let r=document.createElement("div");r.className="cell-metrics";for(let o of n){let i=e[o];if(!i)continue;let s=document.createElement("div");s.className="cell-metric",s.innerHTML=`<span class="cell-metric-label">${v(i.label)}</span><span class="cell-metric-value">${v(i.value)}</span>`,r.appendChild(s)}return r}buildDetailPanel(e){let n=document.createElement("div");n.className="detail-panel",n.id=`detail-${e}`;let r=document.createElement("button");r.className="detail-close",r.setAttribute("aria-label","Close detail"),r.innerHTML="× Close",r.addEventListener("click",i=>{i.stopPropagation(),this.closeDetail(e)}),n.appendChild(r);let o=document.createElement("div");return o.className="detail-inner",o.id=`detail-${e}-inner`,n.appendChild(o),n}selectCell(e){var d;let n=(d=this._data)==null?void 0:d.analysis;if(!n)return;let r=Dt[e],o=this.shadow.getElementById(`detail-${r}`),i=this.shadow.getElementById(`detail-${r}-inner`);if(!o||!i)return;let s=this.shadow.getElementById(`grid-${r}`);if(s==null||s.querySelectorAll(".cell").forEach(m=>m.classList.remove("selected")),this.t[r]===e){this.collapsePanel(o),this.t[r]=null;return}let l=this.t[r]!==null;this.t[r]=e;let c=s==null?void 0:s.querySelector(`[data-category="${e}"]`);c==null||c.classList.add("selected"),this.populateDetail(i,e,n),l?requestAnimationFrame(()=>{let m=i.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(e,!1);u&&m.replaceChildren(u)}}):this.expandPanel(o,()=>{let m=i.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(e,!1);u&&m.replaceChildren(u)}})}populateDetail(e,n,r){let o=this.getIndicatorCode(r,n),s=$(o)==="flag",l='<div class="detail-head">';l+=`<span class="detail-name">${v(F[n]??n)}</span>`,l+=`<span class="detail-code">${v(o??"")}</span>`,l+=`<span class="detail-status-label ${s?"flagged":"clear"}">${s?"flagged":"clear"}</span>`,l+="</div>";let c=at(n,r);l+=`<p class="detail-summary">${st(c)}</p>`,l+='<div class="detail-chart-area"></div>';let d=Te[n];l+=`<div class="detail-chart-caption">${v(d.name)} \u2014 ${v(d.desc)}</div>`;let m=ot(n,r);l+='<div class="detail-metrics">';for(let p of m)l+=`<div class="detail-metric"><span class="detail-metric-value">${v(p.value)}</span><span class="detail-metric-label">${v(p.label)}</span></div>`;l+="</div>";let u=ft(n);u&&(l+=`<p class="detail-explainer">${st(u)}</p>`),e.innerHTML=l}closeDetail(e){let n=this.shadow.getElementById(`detail-${e}`);if(!n)return;let r=this.shadow.getElementById(`grid-${e}`);r==null||r.querySelectorAll(".cell").forEach(o=>o.classList.remove("selected")),this.collapsePanel(n),this.t[e]=null}expandPanel(e,n){let r=e.querySelector(".detail-inner");e.style.height="0px",e.style.display="block",e.offsetHeight,e.style.height=`${r.offsetHeight+40}px`;let o=()=>{e.style.height="auto",n==null||n()};e.addEventListener("transitionend",o,{once:!0})}collapsePanel(e){e.style.height=`${e.scrollHeight}px`,e.offsetHeight,e.style.height="0px";let n=()=>{e.style.display=""};e.addEventListener("transitionend",n,{once:!0})}getIndicatorCode(e,n){var o;let r=e[n];return(o=r==null?void 0:r.indicator)==null?void 0:o.code}getComputedColors(){let e=getComputedStyle(this);return{line:e.getPropertyValue("--wt-scorecard-chart-line").trim()||"#1C1B18",accent:e.getPropertyValue("--wt-scorecard-chart-accent").trim()||"#2B7A5D",flagged:e.getPropertyValue("--wt-scorecard-chart-flagged").trim()||"#B8412D",border:e.getPropertyValue("--wt-scorecard-border").trim()||"#E0DED6",tertiary:e.getPropertyValue("--wt-scorecard-text-tertiary").trim()||"#706E64"}}getChartWidth(e,n){var o;let r=n?`[data-category="${e}"] .cell-chart`:`#detail-${Dt[e]}-inner .detail-chart-area`;return((o=this.shadow.querySelector(r))==null?void 0:o.getBoundingClientRect().width)??300}plotOpts(e,n,r,o,i){return{width:e,height:n?52:200,marginTop:n?4:36,marginRight:n?0:16,marginBottom:n?4:44,marginLeft:n?0:55,x:n?{axis:null,...o}:{...o},y:n?{axis:null,...i}:{...i},style:{background:"transparent",color:r.tertiary,fontFamily:"var(--wt-scorecard-font-data)",fontSize:"10px"}}}plotCategory(e,n){var d;if(!((d=this._data)!=null&&d.analysis))return null;let{data:r,analysis:o}=this._data,i=this.getComputedColors(),s=this.getIndicatorCode(o,e),c=$(s)==="flag"?i.flagged:i.accent;switch(e){case"contentOrigin":return this.plotContentOrigin(o,n,i);case"timingAuthenticity":return this.plotTimingAuthenticity(o,n,i,c);case"revisionBehavior":return this.plotRevisionBehavior(r,n,i);case"sessionContinuity":return this.plotSessionContinuity(r,o,n,i,c);case"physicalPlausibility":return this.plotPhysicalPlausibility(r,n,i);case"temporalPatterns":return this.plotTemporalPatterns(o,n,i,c)}}renderAllCharts(){this.shadow.querySelectorAll(".cell-chart").forEach(e=>{let n=e.closest(".cell"),r=n==null?void 0:n.getAttribute("data-category");if(!r)return;let o=this.plotCategory(r,!0);o&&e.replaceChildren(o)})}rerenderAllCharts(){this.renderAllCharts();for(let e of[1,2]){let n=this.t[e];if(n){let r=this.shadow.querySelector(`#detail-${e}-inner .detail-chart-area`);if(r){let o=this.plotCategory(n,!1);o&&r.replaceChildren(o)}}}}plotContentOrigin(e,n,r){let o=V(e);if(o.length===0)return null;let i={typing:r.accent,paste:r.flagged,pause:r.border,tabAway:r.tertiary,autocomplete:r.flagged,navigating:r.line},s=o.map(d=>({...d,color:i[d.type]??r.line})),l=this.getChartWidth("contentOrigin",n),c=this.plotOpts(l,n,r,{label:"Time (s)"},{padding:.2});return f.plot({...c,marginLeft:n?0:8,y:{axis:null,padding:.2},marks:[f.barX(s,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5})]})}plotTimingAuthenticity(e,n,r,o){let i=U(e);if(i.length===0)return null;let s=this.getChartWidth("timingAuthenticity",n),l=[f.dot(i,{x:"dwell",y:"flight",fill:o,fillOpacity:n?.4:.5,r:n?2:3,stroke:"none"})];if(!n){let c=i.reduce((m,u)=>m+u.dwell,0)/i.length,d=i.reduce((m,u)=>m+u.flight,0)/i.length;l.push(f.ruleX([c],{stroke:r.accent,strokeDasharray:"4,4",strokeWidth:1}),f.ruleY([d],{stroke:r.accent,strokeDasharray:"4,4",strokeWidth:1}))}return f.plot({...this.plotOpts(s,n,r,{label:"Dwell (ms)"},{label:"Flight (ms)"}),marginRight:n?4:12,marks:l})}plotRevisionBehavior(e,n,r){let o=rt(e);if(o.length===0)return null;let i={insert:r.accent,delete:r.flagged,paste:r.line,cut:r.tertiary},s=o.map(c=>({...c,color:i[c.type]??r.line})),l=this.getChartWidth("revisionBehavior",n);return n?f.plot({...this.plotOpts(l,n,r),marks:[f.dot(s,{x:"time",y:()=>0,fill:"color",fillOpacity:.6,r:Math.min(3,Math.max(2,l/s.length/4)),stroke:"none"})],style:{background:"transparent"}}):f.plot({...this.plotOpts(l,n,r,{label:"Time (s)"},{label:null,domain:["insert","delete","paste","cut"]}),marginLeft:70,r:{range:[3,12]},marks:[f.dot(s,{x:"time",y:"type",r:"chars",fill:"color",fillOpacity:.7,stroke:"none"})]})}plotSessionContinuity(e,n,r,o,i){var m,u;let s=X(e);if(s.length===0)return null;let l=this.getChartWidth("sessionContinuity",r),c=[f.areaY(s,{x:"time",y:"chars",fill:i,fillOpacity:.1,curve:"step-after"}),f.lineY(s,{x:"time",y:"chars",stroke:i,strokeWidth:1.5,curve:"step-after"})],d=((u=(m=n.sessionContinuity)==null?void 0:m.metrics)==null?void 0:u.changePoints)??[];if(d.length>0){let p=d[0].timestamp/1e3;c.push(f.ruleX([p],{stroke:o.flagged,strokeDasharray:"4,3",strokeWidth:1}))}if(!r){let p=s.filter(h=>h.isPaste),y=s.filter(h=>h.isCut);p.length>0&&c.push(f.dot(p,{x:"time",y:"chars",fill:o.accent,r:4,stroke:"none"})),y.length>0&&c.push(f.dot(y,{x:"time",y:"chars",fill:o.flagged,r:4,symbol:"diamond",stroke:"none"}))}return f.plot({...this.plotOpts(l,r,o,{label:"Time (s)"},{label:"Characters",grid:!0}),marks:c})}plotPhysicalPlausibility(e,n,r){let o=tt(e);if(o.keystrokes.length===0)return null;let i=this.getChartWidth("physicalPlausibility",n),s=[f.line(o.keystrokes,{x:"time",y:"position",stroke:r.line,strokeWidth:n?1:1.5,strokeOpacity:n?.6:.8})];return n||(o.pastes.length>0&&s.push(f.dot(o.pastes,{x:"time",y:"position",fill:r.accent,r:4,stroke:"none"})),o.cuts.length>0&&s.push(f.dot(o.cuts,{x:"time",y:"position",fill:r.flagged,r:4,stroke:"none"}))),f.plot({...this.plotOpts(i,n,r,{label:"Time (s)"},{label:"Position",reverse:!0}),marks:s})}plotTemporalPatterns(e,n,r,o){let i=G(e);if(i.length===0)return null;let s=this.getChartWidth("temporalPatterns",n);return f.plot({...this.plotOpts(s,n,r,{label:"Time (s)"},{label:"Speed (CPM)",grid:!0}),marks:[f.areaY(i,{x:"time",y:"speed",fill:o,fillOpacity:.12,curve:"monotone-x"}),f.lineY(i,{x:"time",y:"speed",stroke:o,strokeWidth:1.5,curve:"monotone-x"})]})}};lt.tagName="wt-scorecard";export{g as BaseChart,F as CATEGORY_NAMES,H as CompositionTimeline,et as CorrectionsBubble,Q as DocumentGrowth,J as DocumentRibbon,Z as EditWaterfall,_t as GLOSSARY,O as IntegrityFooter,Y as PauseDistribution,j as RhythmHeatmap,mt as SEGMENT_COLORS,dt as Sparkline,z as SpeedTimeline,pt as TIER1_CATEGORIES,ht as TIER2_CATEGORIES,lt as WtScorecard,rt as extractCorrectionBubbles,X as extractGrowthData,wt as extractPasteMarkers,vt as extractPauseHistogram,U as extractRhythmPairs,xt as extractRibbonData,V as extractSegments,bt as extractSeries,G as extractSpeedData,tt as extractWaterfallData,it as formatDuration,ft as generateCaption,at as generateSummary,ot as getMetrics,$ as getStatus,ie as isPass,st as wrapTerms};
|
|
Binary file
|
package/dist/ckeditor/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export interface WriteTrackPluginOptions {
|
|
|
16
16
|
wasmUrl?: string;
|
|
17
17
|
/** Enable IndexedDB session persistence and auto-resume. Requires contentId. */
|
|
18
18
|
persist?: boolean;
|
|
19
|
+
/** Callback fired every second with active session time. */
|
|
20
|
+
onTick?: (data: { activeTime: number; totalTime: number }) => void;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/**
|
package/dist/ckeditor/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Plugin as
|
|
1
|
+
import{Plugin as a}from"ckeditor5";import{WriteTrack as c}from"writetrack";var n=class extends a{constructor(){super(...arguments);this._tracker=null;this._isTracking=!1;this._destroyed=!1}static get pluginName(){return"WriteTrack"}get tracker(){return this._tracker}get isTracking(){return this._isTracking}init(){let e=this.editor,t=e.config.get("writetrack")||{},o=t.autoStart!==!1;e.ui.once("ready",()=>{if(this._destroyed)return;let s=e.ui.getEditableElement();s&&(e.model.document.on("change:data",(r,i)=>{i.isUndo?this._currentSource="undo":i.isTyping?this._currentSource="keyboard":this._currentSource!=="paste"&&this._currentSource!=="drop"&&(this._currentSource=void 0)}),e.editing.view.document.on("clipboardInput",(r,i)=>{this._currentSource=i.method==="drop"?"drop":"paste"}),this._tracker=new c({target:s,license:t.license,userId:t.userId,contentId:t.contentId,metadata:t.metadata,wasmUrl:t.wasmUrl,persist:t.persist,cursorPositionProvider:()=>{let r=e.model.document.selection.getFirstPosition();return r?r.offset:0},inputSourceProvider:()=>this._currentSource}),t.onTick&&this._tracker.on("tick",t.onTick),o&&(t.persist?this._tracker.ready.then(()=>{this._tracker&&(this._tracker.start(),this._isTracking=!0)}):(this._tracker.start(),this._isTracking=!0)))})}destroy(){this._destroyed=!0,this._tracker&&(this._tracker.stop(),this._tracker=null,this._isTracking=!1),super.destroy()}};export{n as WriteTrackPlugin};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { K as KeystrokeEvent, C as ClipboardEvent, U as UndoRedoEvent, S as SelectionEvent, P as ProgrammaticInsertionEvent, a as CompositionEvent, W as WriteTrackDataSchema } from './index-
|
|
2
|
-
export { D as DataQualityMetrics, M as ModifierState, b as SessionMetadata } from './index-
|
|
1
|
+
import { K as KeystrokeEvent, C as ClipboardEvent, U as UndoRedoEvent, S as SelectionEvent, P as ProgrammaticInsertionEvent, a as CompositionEvent, I as InputSource, W as WriteTrackDataSchema } from './index-Cy91q_po.js';
|
|
2
|
+
export { D as DataQualityMetrics, M as ModifierState, b as SessionMetadata } from './index-Cy91q_po.js';
|
|
3
3
|
import { WriteTrackSink } from './pipes.js';
|
|
4
4
|
export { DatadogClient, DatadogOptions, OTelSpan, OTelTracer, OpenTelemetryOptions, SegmentClient, SegmentOptions, WebhookOptions, datadog, opentelemetry, segment, webhook } from './pipes.js';
|
|
5
|
-
import { S as SessionAnalysis, a as SessionReport, I as IndicatorOutput } from './analysis-types-
|
|
6
|
-
export { C as ContentOriginAnalysis, P as PhysicalPlausibilityAnalysis, R as RevisionBehaviorAnalysis, b as SessionContinuityAnalysis, c as TemporalPatternsAnalysis, T as TimingAuthenticityAnalysis } from './analysis-types-
|
|
5
|
+
import { S as SessionAnalysis, a as SessionReport, I as IndicatorOutput } from './analysis-types-B9TlyYRD.js';
|
|
6
|
+
export { C as ContentOriginAnalysis, P as PhysicalPlausibilityAnalysis, R as RevisionBehaviorAnalysis, b as SessionContinuityAnalysis, c as TemporalPatternsAnalysis, T as TimingAuthenticityAnalysis } from './analysis-types-B9TlyYRD.js';
|
|
7
7
|
|
|
8
8
|
interface PersistedSessionInfo {
|
|
9
9
|
contentId: string;
|
|
@@ -31,6 +31,10 @@ interface WriteTrackOptions {
|
|
|
31
31
|
* model (e.g., ProseMirror, Quill, CKEditor). If not provided, falls back to
|
|
32
32
|
* selectionStart (input/textarea) or Range-based offset (contenteditable). */
|
|
33
33
|
cursorPositionProvider?: () => number;
|
|
34
|
+
/** Custom input source provider. When set, this is called before the built-in
|
|
35
|
+
* beforeinput classification. Rich text editors (TipTap, Lexical, etc.) can use
|
|
36
|
+
* this to supply definitive input source from their own transaction metadata. */
|
|
37
|
+
inputSourceProvider?: () => InputSource | undefined;
|
|
34
38
|
}
|
|
35
39
|
declare class WriteTrack {
|
|
36
40
|
/** @internal */ keystrokeEvents: KeystrokeEvent[];
|
|
@@ -51,6 +55,10 @@ declare class WriteTrack {
|
|
|
51
55
|
private keystrokesSinceLastInput;
|
|
52
56
|
private pendingPasteContent;
|
|
53
57
|
private pendingPasteTimestamp;
|
|
58
|
+
private pendingPasteBeforeText;
|
|
59
|
+
private hiddenTime;
|
|
60
|
+
private hiddenSince;
|
|
61
|
+
private tickInterval;
|
|
54
62
|
protected readonly CORRECTION_KEYS: Set<string>;
|
|
55
63
|
protected readonly target: HTMLElement;
|
|
56
64
|
/** @internal */ readonly license?: string;
|
|
@@ -63,15 +71,27 @@ declare class WriteTrack {
|
|
|
63
71
|
private _analysis;
|
|
64
72
|
private _persist;
|
|
65
73
|
private readonly cursorPositionProvider?;
|
|
74
|
+
private readonly inputSourceProvider?;
|
|
75
|
+
private pendingInputSource;
|
|
66
76
|
private _sinks;
|
|
67
77
|
private _listeners;
|
|
68
78
|
/**
|
|
69
79
|
* Create a WriteTrack instance
|
|
70
|
-
* @param optionsOrTarget - Either an HTMLElement (
|
|
80
|
+
* @param optionsOrTarget - Either an HTMLElement (localhost evaluation) or WriteTrackOptions object
|
|
71
81
|
*/
|
|
72
82
|
constructor(optionsOrTarget: WriteTrackOptions | HTMLElement);
|
|
83
|
+
/** Set initial license state — kick off async validation or mark unlicensed. */
|
|
84
|
+
private initLicenseState;
|
|
85
|
+
/** Initialize persistence manager if persist is enabled. */
|
|
86
|
+
private initPersistence;
|
|
73
87
|
private validateLicenseAsync;
|
|
74
88
|
private setupEventListeners;
|
|
89
|
+
private setupKeyboardListeners;
|
|
90
|
+
private setupMouseListeners;
|
|
91
|
+
private setupFocusListeners;
|
|
92
|
+
private setupClipboardListeners;
|
|
93
|
+
private setupInputListeners;
|
|
94
|
+
private setupSelectionListeners;
|
|
75
95
|
/**
|
|
76
96
|
* Technique 6: Observe target's parent for childList changes.
|
|
77
97
|
* If target is removed from DOM, stop recording.
|
|
@@ -85,7 +105,37 @@ declare class WriteTrack {
|
|
|
85
105
|
private recordWindowFocus;
|
|
86
106
|
private detectKeyboardShortcuts;
|
|
87
107
|
private recordClipboardEvent;
|
|
108
|
+
/** Extract paste text from clipboard data, with beforeinput fallback. */
|
|
109
|
+
private extractPasteText;
|
|
110
|
+
/**
|
|
111
|
+
* Resolve before-text for clipboard events.
|
|
112
|
+
* Uses pre-insertion snapshot from beforeinput if available (paste events),
|
|
113
|
+
* otherwise falls back to current text (copy/cut events).
|
|
114
|
+
*/
|
|
115
|
+
private resolveClipboardBeforeText;
|
|
116
|
+
/** Infer clipboard shortcut from platform (Mac uses Cmd, others use Ctrl). */
|
|
117
|
+
private inferClipboardShortcut;
|
|
118
|
+
/**
|
|
119
|
+
* Merge a new clipboard event with a recent duplicate, or add it to the array.
|
|
120
|
+
* Returns the event object that lives in the array (for async enrichment).
|
|
121
|
+
*/
|
|
122
|
+
private mergeOrAddClipboardEvent;
|
|
123
|
+
/** Schedule async after-state capture for paste events, then freeze. */
|
|
124
|
+
private scheduleAfterStateCapture;
|
|
125
|
+
/** Infer paste content from before/after text diff when clipboardData was unavailable. */
|
|
126
|
+
private inferPasteContent;
|
|
88
127
|
private recordSelection;
|
|
128
|
+
private static readonly INPUT_SOURCE_MAP;
|
|
129
|
+
/**
|
|
130
|
+
* Resolve the input source: prefer editor-provided, fall back to beforeinput classification.
|
|
131
|
+
*
|
|
132
|
+
* Note: pendingInputSource is consumed on first call (cleared after read).
|
|
133
|
+
* For the beforeinput-only path (no editor integration), keydown gets the
|
|
134
|
+
* source but keyup does not — this is intentional since keydown is the
|
|
135
|
+
* primary event used in WASM analysis. Editor integrations provide source
|
|
136
|
+
* for both via inputSourceProvider, which persists until the next transaction.
|
|
137
|
+
*/
|
|
138
|
+
private resolveInputSource;
|
|
89
139
|
private captureBeforeInput;
|
|
90
140
|
private detectProgrammaticInsertion;
|
|
91
141
|
private checkSelectionAfterMouse;
|
|
@@ -118,11 +168,17 @@ declare class WriteTrack {
|
|
|
118
168
|
pipe(sink: WriteTrackSink): this;
|
|
119
169
|
/**
|
|
120
170
|
* Register an event listener.
|
|
121
|
-
* Supported events: 'pipe:error'
|
|
171
|
+
* Supported events: 'pipe:error', 'tick'
|
|
172
|
+
*
|
|
173
|
+
* The `tick` event fires every ~1 second while the session is active and the
|
|
174
|
+
* tab is visible. The handler receives `{ activeTime: number, totalTime: number }`
|
|
175
|
+
* (both in milliseconds).
|
|
122
176
|
*/
|
|
123
177
|
on(event: string, handler: (...args: unknown[]) => void): this;
|
|
124
178
|
private _emit;
|
|
125
179
|
private _dispatchToSinks;
|
|
180
|
+
private startTickInterval;
|
|
181
|
+
private stopTickInterval;
|
|
126
182
|
getRawEvents(): KeystrokeEvent[];
|
|
127
183
|
getClipboardEvents(): ClipboardEvent[];
|
|
128
184
|
getUndoRedoEvents(): UndoRedoEvent[];
|
|
@@ -130,6 +186,11 @@ declare class WriteTrack {
|
|
|
130
186
|
getProgrammaticInsertionEvents(): ProgrammaticInsertionEvent[];
|
|
131
187
|
getCompositionEvents(): CompositionEvent[];
|
|
132
188
|
getSessionDuration(): number;
|
|
189
|
+
/**
|
|
190
|
+
* Returns the active (visible) session time in milliseconds.
|
|
191
|
+
* Subtracts time spent with the tab hidden from the total session duration.
|
|
192
|
+
*/
|
|
193
|
+
getActiveTime(): number;
|
|
133
194
|
getKeystrokeCount(): number;
|
|
134
195
|
/**
|
|
135
196
|
* Resolves when the tracker is ready for use.
|
|
@@ -217,4 +278,4 @@ declare function createSessionReport(rawData: unknown, options?: AnalyzeEventsOp
|
|
|
217
278
|
*/
|
|
218
279
|
declare function getHighResolutionTime(): number;
|
|
219
280
|
|
|
220
|
-
export { type AnalyzeEventsOptions, ClipboardEvent, CompositionEvent, IndicatorOutput, KeystrokeEvent, type PersistedSessionInfo, ProgrammaticInsertionEvent, SelectionEvent, SessionAnalysis, SessionReport, UndoRedoEvent, WriteTrack, WriteTrackDataSchema, type WriteTrackOptions, WriteTrackSink, analyzeEvents, createSessionReport, WriteTrack as default, formatIndicator, getHighResolutionTime };
|
|
281
|
+
export { type AnalyzeEventsOptions, ClipboardEvent, CompositionEvent, IndicatorOutput, InputSource, KeystrokeEvent, type PersistedSessionInfo, ProgrammaticInsertionEvent, SelectionEvent, SessionAnalysis, SessionReport, UndoRedoEvent, WriteTrack, WriteTrackDataSchema, type WriteTrackOptions, WriteTrackSink, analyzeEvents, createSessionReport, WriteTrack as default, formatIndicator, getHighResolutionTime };
|