@lemoncat7/dsh-knowledge 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";var DshKnowledgeReview=(()=>{var g=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var I=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},R=(e,t,r,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of C(t))!K.call(e,n)&&n!==r&&g(e,n,{get:()=>t[n],enumerable:!(f=v(t,n))||f.enumerable});return e};var A=e=>R(g({},"__esModule",{value:!0}),e);var F={};I(F,{compactDiffLines:()=>y,createLineDiff:()=>w,createReviewChange:()=>$});function D(e,t){let r=L(e),f=L(t);return r===f||r.includes(f)?e.trim():f.includes(r)?t.trim():`${e.trim()}
1
+ "use strict";var DshKnowledgeReview=(()=>{var g=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},$=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of K(t))!C.call(e,n)&&n!==r&&g(e,n,{get:()=>t[n],enumerable:!(o=M(t,n))||o.enumerable});return e};var T=e=>$(g({},"__esModule",{value:!0}),e);var O={};R(O,{compactDiffLines:()=>y,createLineDiff:()=>w,createReviewChange:()=>A});function D(e,t){let r=L(e),o=L(t);return r===o||r.includes(o)?e.trim():o.includes(r)?t.trim():`${e.trim()}
2
2
 
3
- ${t.trim()}`}function L(e){return e.normalize("NFKC").toLocaleLowerCase().replace(/\s+/gu," ").trim()}var _=6e5;function $(e,t,r){let f=e==="create"?"":t,n=e==="create"?r:D(t,r),i=w(f,n);return{before:f,after:n,diff:i,displayLines:y(i.lines)}}function w(e,t){let r=b(e),f=b(t),n=0;for(;n<r.length&&n<f.length&&r[n]===f[n];)n+=1;let i=0;for(;i<r.length-n&&i<f.length-n&&r[r.length-1-i]===f[f.length-1-i];)i+=1;let o=r.slice(n,r.length-i),l=f.slice(n,f.length-i),c=(o.length+1)*(l.length+1)>_,u=c?E(o,l,n+1,n+1):B(o,l,n+1,n+1),a=[];for(let d=0;d<n;d+=1)a.push({kind:"context",text:r[d]??"",oldLine:d+1,newLine:d+1});a.push(...u);for(let d=0;d<i;d+=1){let x=r.length-i+d,M=f.length-i+d;a.push({kind:"context",text:r[x]??"",oldLine:x+1,newLine:M+1})}let h=0,m=0,p=0;for(let d of a)d.kind==="add"?h+=1:d.kind==="remove"?m+=1:p+=1;return{lines:a,additions:h,deletions:m,unchanged:p,simplified:c}}function y(e,t=3){if(e.length===0)return[];let r=e.flatMap((i,o)=>i.kind==="context"?[]:[o]);if(r.length===0)return k(e,[[0,Math.min(e.length,t)],[Math.max(0,e.length-t),e.length]]);let f=r.map(i=>[Math.max(0,i-t),Math.min(e.length,i+t+1)]),n=[];for(let i of f){let o=n.at(-1);o!==void 0&&i[0]<=o[1]?o[1]=Math.max(o[1],i[1]):n.push(i)}return k(e,n)}function b(e){let t=e.replace(/\r\n?/g,`
3
+ ${t.trim()}`}function L(e){return e.normalize("NFKC").toLocaleLowerCase().replace(/\s+/gu," ").trim()}var I=6e5;function A(e,t,r,o="append"){let n=e==="create"?"":t,i=e==="create"||o==="revise"?r.trim():D(t,r),s=w(n,i);return{before:n,after:i,diff:s,displayLines:y(s.lines)}}function w(e,t){let r=k(e),o=k(t),n=0;for(;n<r.length&&n<o.length&&r[n]===o[n];)n+=1;let i=0;for(;i<r.length-n&&i<o.length-n&&r[r.length-1-i]===o[o.length-1-i];)i+=1;let s=r.slice(n,r.length-i),l=o.slice(n,o.length-i),a=(s.length+1)*(l.length+1)>I,c=a?_(s,l,n+1,n+1):E(s,l,n+1,n+1),u=[];for(let d=0;d<n;d+=1)u.push({kind:"context",text:r[d]??"",oldLine:d+1,newLine:d+1});u.push(...c);for(let d=0;d<i;d+=1){let x=r.length-i+d,v=o.length-i+d;u.push({kind:"context",text:r[x]??"",oldLine:x+1,newLine:v+1})}let h=0,m=0,p=0;for(let d of u)d.kind==="add"?h+=1:d.kind==="remove"?m+=1:p+=1;return{lines:u,additions:h,deletions:m,unchanged:p,simplified:a}}function y(e,t=3){if(e.length===0)return[];let r=e.flatMap((i,s)=>i.kind==="context"?[]:[s]);if(r.length===0)return b(e,[[0,Math.min(e.length,t)],[Math.max(0,e.length-t),e.length]]);let o=r.map(i=>[Math.max(0,i-t),Math.min(e.length,i+t+1)]),n=[];for(let i of o){let s=n.at(-1);s!==void 0&&i[0]<=s[1]?s[1]=Math.max(s[1],i[1]):n.push(i)}return b(e,n)}function k(e){let t=e.replace(/\r\n?/g,`
4
4
  `);return t.length===0?[]:t.split(`
5
- `)}function B(e,t,r,f){let n=t.length+1,i=new Uint32Array((e.length+1)*n);for(let c=e.length-1;c>=0;c-=1)for(let u=t.length-1;u>=0;u-=1){let a=c*n+u;i[a]=e[c]===t[u]?(i[(c+1)*n+u+1]??0)+1:Math.max(i[(c+1)*n+u]??0,i[a+1]??0)}let o=[],l=0,s=0;for(;l<e.length&&s<t.length;)e[l]===t[s]?(o.push({kind:"context",text:e[l]??"",oldLine:r+l,newLine:f+s}),l+=1,s+=1):(i[(l+1)*n+s]??0)>=(i[l*n+s+1]??0)?(o.push({kind:"remove",text:e[l]??"",oldLine:r+l}),l+=1):(o.push({kind:"add",text:t[s]??"",newLine:f+s}),s+=1);for(;l<e.length;)o.push({kind:"remove",text:e[l]??"",oldLine:r+l}),l+=1;for(;s<t.length;)o.push({kind:"add",text:t[s]??"",newLine:f+s}),s+=1;return o}function E(e,t,r,f){return[...e.map((n,i)=>({kind:"remove",text:n,oldLine:r+i})),...t.map((n,i)=>({kind:"add",text:n,newLine:f+i}))]}function k(e,t){let r=[],f=0;for(let[n,i]of t){if(i<=f)continue;let o=Math.max(n,f);o>f&&r.push({kind:"omitted",count:o-f}),r.push(...e.slice(o,i)),f=i}return f<e.length&&r.push({kind:"omitted",count:e.length-f}),r}return A(F);})();
5
+ `)}function E(e,t,r,o){let n=t.length+1,i=new Uint32Array((e.length+1)*n);for(let a=e.length-1;a>=0;a-=1)for(let c=t.length-1;c>=0;c-=1){let u=a*n+c;i[u]=e[a]===t[c]?(i[(a+1)*n+c+1]??0)+1:Math.max(i[(a+1)*n+c]??0,i[u+1]??0)}let s=[],l=0,f=0;for(;l<e.length&&f<t.length;)e[l]===t[f]?(s.push({kind:"context",text:e[l]??"",oldLine:r+l,newLine:o+f}),l+=1,f+=1):(i[(l+1)*n+f]??0)>=(i[l*n+f+1]??0)?(s.push({kind:"remove",text:e[l]??"",oldLine:r+l}),l+=1):(s.push({kind:"add",text:t[f]??"",newLine:o+f}),f+=1);for(;l<e.length;)s.push({kind:"remove",text:e[l]??"",oldLine:r+l}),l+=1;for(;f<t.length;)s.push({kind:"add",text:t[f]??"",newLine:o+f}),f+=1;return s}function _(e,t,r,o){return[...e.map((n,i)=>({kind:"remove",text:n,oldLine:r+i})),...t.map((n,i)=>({kind:"add",text:n,newLine:o+i}))]}function b(e,t){let r=[],o=0;for(let[n,i]of t){if(i<=o)continue;let s=Math.max(n,o);s>o&&r.push({kind:"omitted",count:s-o}),r.push(...e.slice(s,i)),o=i}return o<e.length&&r.push({kind:"omitted",count:e.length-o}),r}return T(O);})();