kaizen-agent 1.45.0 → 1.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/pty.test.ts +7 -0
- package/cli/pty.ts +12 -2
- package/package.json +3 -1
- package/web/board/api.ts +34 -2
- package/web/board/cards.ts +5 -2
- package/web/board/dom.ts +9 -0
- package/web/board/settings.ts +2 -0
- package/web/board/store.ts +2 -0
- package/web/board/terms.ts +35 -1
- package/web/board/toast.ts +3 -2
- package/web/board/views.ts +4 -4
- package/web/board.html +14 -3
- package/web/board.js +36 -34
- package/web/notebook.js +2 -2
- package/web/notebook.ts +2 -1
- package/web/notes.html +8 -1
- package/web/term.js +61 -35
- package/web/term.ts +59 -0
package/web/notebook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen notebook
|
|
1
|
+
/* kaizen notebook 6f7e7ca97d5f80c0 -- generated by bun run build:web from web/notebook.ts; do not edit */
|
|
2
2
|
var Ss=[],ua=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map((t)=>t?parseInt(t,36):1);for(let t=0,i=0;t<e.length;t++)(t%2?ua:Ss).push(i=i+e[t])})();function op(e){if(e<768)return!1;for(let t=0,i=Ss.length;;){let n=t+i>>1;if(e<Ss[n])i=n;else if(e>=ua[n])t=n+1;else return!0;if(t==i)return!1}}function ha(e){return e>=127462&&e<=127487}var fa=8205;function da(e,t,i=!0,n=!0){return(i?Oa:lp)(e,t,n)}function Oa(e,t,i){if(t==e.length)return t;if(t&&pa(e.charCodeAt(t))&&ma(e.charCodeAt(t-1)))t--;let n=bs(e,t);t+=ca(n);while(t<e.length){let r=bs(e,t);if(n==fa||r==fa||i&&op(r))t+=ca(r),n=r;else if(ha(r)){let s=0,o=t-2;while(o>=0&&ha(bs(e,o)))s++,o-=2;if(s%2==0)break;else t+=2}else break}return t}function lp(e,t,i){while(t>1){let n=Oa(e,t-2,i);if(n<t)return n;t--}return 0}function bs(e,t){let i=e.charCodeAt(t);if(!ma(i)||t+1==e.length)return i;let n=e.charCodeAt(t+1);if(!pa(n))return i;return(i-55296<<10)+(n-56320)+65536}function pa(e){return e>=56320&&e<57344}function ma(e){return e>=55296&&e<56320}function ca(e){return e<65536?1:2}class _{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=vi(this,e,t);let n=[];if(this.decompose(0,e,n,2),i.length)i.decompose(0,i.length,n,3);return this.decompose(t,this.length,n,1),ft.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=vi(this,e,t);let i=[];return this.decompose(e,t,i,0),ft.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new wi(this),r=new wi(e);for(let s=t,o=t;;){if(n.next(s),r.next(s),s=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(e=1){return new wi(this,e)}iterRange(e,t=this.length){return new Ts(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{if(t==null)t=this.lines+1;let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new As(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw RangeError("A document must have at least one line");if(e.length==1&&!e[0])return _.empty;return e.length<=32?new oe(e):ft.from(oe.split(e,[]))}}class oe extends _{constructor(e,t=ap(e)){super();this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.text[r],o=n+s.length;if((t?i:o)>=e)return new ka(n,o,i,s);n=o+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new oe(ga(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let s=i.pop(),o=cr(r.text,s.text.slice(),0,r.length);if(o.length<=32)i.push(new oe(o,s.length+r.length));else{let l=o.length>>1;i.push(new oe(o.slice(0,l)),new oe(o.slice(l)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof oe))return super.replace(e,t,i);[e,t]=vi(this,e,t);let n=cr(this.text,cr(i.text,ga(this.text,0,e)),t),r=this.length+i.length-(t-e);if(n.length<=32)return new oe(n,r);return ft.from(oe.split(n,[]),r)}sliceString(e,t=this.length,i=`
|
|
3
3
|
`){[e,t]=vi(this,e,t);let n="";for(let r=0,s=0;r<=t&&s<this.text.length;s++){let o=this.text[s],l=r+o.length;if(r>e&&s)n+=i;if(e<l&&t>r)n+=o.slice(Math.max(0,e-r),t-r);r=l+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)if(i.push(r),n+=r.length+1,i.length==32)t.push(new oe(i,n)),i=[],n=-1;if(n>-1)t.push(new oe(i,n));return t}}class ft extends _{constructor(e,t){super();this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.children[r],o=n+s.length,l=i+s.lines-1;if((t?l:o)>=e)return s.lineInner(e,t,i,n);n=o+1,i=l+1}}decompose(e,t,i,n){for(let r=0,s=0;s<=t&&r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e<=l&&t>=s){let a=n&((s<=e?1:0)|(l>=t?2:0));if(s>=e&&l<=t&&!a)i.push(o);else o.decompose(e-s,t-s,i,a)}s=l+1}}replace(e,t,i){if([e,t]=vi(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],o=r+s.length;if(e>=r&&t<=o){let l=s.replace(e-r,t-r,i),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let h=this.children.slice();return h[n]=l,new ft(h,this.length-(t-e)+i.length)}return super.replace(r,o,l)}r=o+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
4
4
|
`){[e,t]=vi(this,e,t);let n="";for(let r=0,s=0;r<this.children.length&&s<=t;r++){let o=this.children[r],l=s+o.length;if(s>e&&r)n+=i;if(e<l&&t>s)n+=o.sliceString(e-s,t-s,i);s=l+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof ft))return 0;let i=0,[n,r,s,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==s||r==o)return i;let l=this.children[n],a=e.children[r];if(l!=a)return i+l.scanIdentical(a,t);i+=l.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let u of e)i+=u.lines;if(i<32){let u=[];for(let d of e)d.flatten(u);return new oe(u,t)}let n=Math.max(32,i>>5),r=n<<1,s=n>>1,o=[],l=0,a=-1,h=[];function f(u){let d;if(u.lines>r&&u instanceof ft)for(let O of u.children)f(O);else if(u.lines>s&&(l>s||!l))c(),o.push(u);else if(u instanceof oe&&l&&(d=h[h.length-1])instanceof oe&&u.lines+d.lines<=32)l+=u.lines,a+=u.length+1,h[h.length-1]=new oe(d.text.concat(u.text),d.length+1+u.length);else{if(l+u.lines>n)c();l+=u.lines,a+=u.length+1,h.push(u)}}function c(){if(l==0)return;o.push(h.length==1?h[0]:ft.from(h,a)),a=-1,l=h.length=0}for(let u of e)f(u);return c(),o.length==1?o[0]:new ft(o,t)}}_.empty=new oe([""],0);function ap(e){let t=-1;for(let i of e)t+=i.length+1;return t}function cr(e,t,i=0,n=1e9){for(let r=0,s=0,o=!0;s<e.length&&r<=n;s++){let l=e[s],a=r+l.length;if(a>=i){if(a>n)l=l.slice(0,n-r);if(r<i)l=l.slice(i-r);if(o)t[t.length-1]+=l,o=!1;else t.push(l)}r=a+1}return t}function ga(e,t,i){return cr(e,[""],t,i)}class wi{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof oe?e.text.length:e.children.length)<<1]}nextInner(e,t){this.done=this.lineBreak=!1;for(;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],s=r>>1,o=n instanceof oe?n.text.length:n.children.length;if(s==(t>0?o:0)){if(i==0)return this.done=!0,this.value="",this;if(t>0)this.offsets[i-1]++;this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
@@ -33,4 +33,4 @@ var Ss=[],ua=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,
|
|
|
33
33
|
| | |`,"rows"],["Link to note","[[|]]","[[ ]]"],["Link to run","[[run:|]]","board"],["Tag","#|","#"]];function ay(e){let t=e.matchBefore(/^[ \t]*\/[\w ]*$/);if(!t)return null;return{from:t.from+t.text.indexOf("/"),filter:!0,validFor:/^\/[\w ]*$/,options:ly.map(([n,r,s],o)=>({label:"/"+n.toLowerCase(),displayLabel:n,detail:s,boost:50-o,apply:(l,a,h,f)=>{let c=l.state.doc.lineAt(h),u=(n==="Divider"||n==="Table")&&c.number>1&&l.state.doc.line(c.number-1).text.trim()?`
|
|
34
34
|
`:"",d=u+r.replace("|",""),O=h+u.length+r.indexOf("|");if(l.dispatch({changes:{from:h,to:f,insert:d},selection:{anchor:O},userEvent:"input.complete"}),n.startsWith("Link to"))setTimeout(()=>zn(l))}}))}}function hy(e){let t=e.matchBefore(/\[\[[^\]\n|]*$/);if(!t)return null;let i=t.text.slice(2),n=e.state.sliceDoc(e.pos,e.pos+2)==="]]",r=(o,l)=>(a,h,f,c)=>{a.dispatch({changes:{from:f,to:c,insert:o+(n?"":"]]")},selection:{anchor:f+o.length+(l?0:2)},userEvent:"input.complete"})},s=/^run:\s*([\w.-]+)#([\w-]*)$/i.exec(i);if(s){let o=ea(s[1],Zt.runs.map((h)=>h.id)),l=Zt.runs.find((h)=>h.id===o);if(!l)return null;let a=(h)=>h.length>60?h.slice(0,59)+"…":h;return{from:e.pos-s[2].length,validFor:/^[\w-]*$/,options:[...Jl.map((h,f)=>({label:h,detail:"tab",boost:20-f,apply:r(h,!1)})),...l.findings.map((h)=>({label:`finding-${h.n}`,detail:a(h.text)+(h.done?" (closed)":""),apply:r(`finding-${h.n}`,!1)})),...l.backlog.map((h)=>({label:`backlog-${h.n}`,detail:`${h.status}: ${a(h.text)}`,apply:r(`backlog-${h.n}`,!1)}))]}}return{from:t.from+2,validFor:/^[^\]\n|#]*$/,options:[...J.map((o)=>({label:o.name,detail:"note",apply:r(o.name,!1)})),...[...Zt.runs].sort((o,l)=>l.id.localeCompare(o.id)).map((o,l)=>({label:"run:"+o.id,displayLabel:o.short,detail:o.id.slice(0,10)+" · "+o.title,boost:Math.max(-99,60-l),apply:r("run:"+o.id,!0)})),...Zt.ideas.map((o)=>({label:"idea:"+o.text,detail:"idea",apply:r("idea:"+o.text,!1)}))]}}var tp=(e)=>[Qu({override:[ay,hy],icons:!1}),wc(),Dt.of([...Hl,...iu,...Cc,nu,{key:"Mod-s",run:()=>(Si(),!0)}]),LO({base:Ki}),cc(sy),C.lineWrapping,C.contentAttributes.of({"aria-label":"Note",spellcheck:"true"}),KO,C.focusChangeEffect.of((t,i)=>ra.of(i)),ty,ry,oy,C.updateListener.of((t)=>{if(t.docChanged&&!na)ze=!0,Fe=null,bi(),clearTimeout(nn),nn=setTimeout(()=>void Si(),600)}),e?L.lineSeparator.of(`\r
|
|
35
35
|
`):[]],na=!1,Rt=new C({parent:V("editor"),state:L.create({doc:"",extensions:tp(!1)})});function sa(e,t){if(na=!0,t)Rt.setState(L.create({doc:e,extensions:tp(e.includes(`\r
|
|
36
|
-
`))}));else Rt.dispatch({changes:{from:0,to:Rt.state.doc.length,insert:e},selection:{anchor:Math.min(Rt.state.selection.main.head,e.length)}});na=!1}async function Si(){if(clearTimeout(nn),Ji)await Ji;if(!B||!ze||Fe)return;let e=B,t=Rt.state.sliceDoc(),i=!1;if(Ji=(async()=>{bi("Saving…");let n=await gs({op:"save",name:e,text:t,base:St});if(B!==e)return;if(n.ok){if(i=!0,St=n.mtime,Rt.state.sliceDoc()===t)ze=!1;ip({name:e,mtime:n.mtime,text:t})}else if(n.status===409)Fe={text:n.text??"",mtime:n.mtime??0};else Ye(n.error||"Not saved")})(),await Ji,Ji=null,bi(),i&&ze&&!Fe&&B===e)clearTimeout(nn),nn=setTimeout(()=>void Si(),600)}function ip(e){J=[e,...J.filter((t)=>t.name!==e.name)],sn(),oa()}async function sr(){let e;try{e=await(await fetch("/vault?dir="+encodeURIComponent(Ee))).json()}catch{Ye("The board is not running");return}if(!e.notes){Ye(e.error||"Could not read notes");return}J=e.notes;try{let i=await(await fetch("/links?dir="+encodeURIComponent(Ee))).json();if(Array.isArray(i.runs))Zt=i}catch{}let t=B&&J.find((i)=>i.name===B);if(t&&t.mtime!==St&&!ze&&!Ji)St=t.mtime,sa(t.text,!1);Rt.dispatch({effects:ep.of(null)}),sn(),oa(),rn()}var ta={duration:260,easing:"cubic-bezier(.22,.61,.36,1)"};function fy(){let e=document.querySelector(".main");if(matchMedia("(prefers-reduced-motion: reduce)").matches)return null;let
|
|
36
|
+
`))}));else Rt.dispatch({changes:{from:0,to:Rt.state.doc.length,insert:e},selection:{anchor:Math.min(Rt.state.selection.main.head,e.length)}});na=!1}async function Si(){if(clearTimeout(nn),Ji)await Ji;if(!B||!ze||Fe)return;let e=B,t=Rt.state.sliceDoc(),i=!1;if(Ji=(async()=>{bi("Saving…");let n=await gs({op:"save",name:e,text:t,base:St});if(B!==e)return;if(n.ok){if(i=!0,St=n.mtime,Rt.state.sliceDoc()===t)ze=!1;ip({name:e,mtime:n.mtime,text:t})}else if(n.status===409)Fe={text:n.text??"",mtime:n.mtime??0};else Ye(n.error||"Not saved")})(),await Ji,Ji=null,bi(),i&&ze&&!Fe&&B===e)clearTimeout(nn),nn=setTimeout(()=>void Si(),600)}function ip(e){J=[e,...J.filter((t)=>t.name!==e.name)],sn(),oa()}async function sr(){let e;try{e=await(await fetch("/vault?dir="+encodeURIComponent(Ee))).json()}catch{Ye("The board is not running");return}if(!e.notes){Ye(e.error||"Could not read notes");return}J=e.notes;try{let i=await(await fetch("/links?dir="+encodeURIComponent(Ee))).json();if(Array.isArray(i.runs))Zt=i}catch{}let t=B&&J.find((i)=>i.name===B);if(t&&t.mtime!==St&&!ze&&!Ji)St=t.mtime,sa(t.text,!1);Rt.dispatch({effects:ep.of(null)}),sn(),oa(),rn()}var ta={duration:260,easing:"cubic-bezier(.22,.61,.36,1)"};function fy(){let e=document.querySelector(".main"),t=document.documentElement.dataset.motion;if(t?t==="reduce":matchMedia("(prefers-reduced-motion: reduce)").matches)return null;let i=e.getBoundingClientRect(),n=e.scrollTop,r=e.cloneNode(!0);return r.classList.add("sheet"),r.setAttribute("aria-hidden","true"),r.inert=!0,Object.assign(r.style,{left:i.left+"px",top:i.top+"px",width:i.width+"px",height:i.height+"px"}),r.append(Object.assign(document.createElement("i"),{className:"shade"})),document.body.append(r),r.scrollTop=n,r}function cy(e){if(!e)return;let t=document.querySelector(".main");t.classList.add("dealt");let i=()=>{t.classList.remove("dealt"),e.remove()};t.animate([{transform:"translateX(56px)",opacity:0},{transform:"none",opacity:1}],ta).finished.then(i,i),e.animate([{transform:"none",opacity:1},{transform:"translateX(-24px)",opacity:0,offset:0.6},{transform:"translateX(-24px)",opacity:0}],{...ta,fill:"forwards"}),e.querySelector(".shade").animate([{opacity:0},{opacity:1}],{...ta,fill:"forwards"})}async function yi(e){if(e===B)return!0;if(await Si(),ze)return Ye(Fe?"Choose Keep mine or Load theirs first":"This note is not saved yet"),!1;let t=fy();B=e,Fe=null,nr=!1,ze=!1;let i=e?J.find((n)=>n.name===e):null;St=i?.mtime??0,sa(i?.text??"",!0);try{e?sessionStorage.setItem("kz-note:"+Ee,e):sessionStorage.removeItem("kz-note:"+Ee)}catch{}return document.body.classList.remove("side-open"),sn(),rn(),oa(),cy(t),!0}async function np(e){let t=await gs({op:"save",name:e,text:"",base:0});if(!t.ok)return Ye(t.status===409?"A note with that name exists":t.error||"Could not create the note"),!1;return ip({name:t.name,mtime:t.mtime,text:""}),yi(t.name)}async function uy(e){let t=ir(e,J.map((i)=>i.name));if(t)return void yi(t);if(await np(e))Rt.focus()}async function rp(){if(await np(WO(J.map((e)=>e.name),B?Mt(B):""))){let e=V("title");e.focus(),e.select()}}async function dy(e){if(!B||!e.trim()||e.trim()===B){rn();return}let t=B;await Si();let i=await gs({op:"rename",name:t,to:e});if(!i.ok){Ye(i.error||"Could not rename"),rn();return}if(B!==t){await sr();return}B=e.trim().replace(/\.md$/i,"").split("/").map((n)=>n.trim()).join("/"),await sr(),St=J.find((n)=>n.name===B)?.mtime??St,Ye(Mt(t)===Mt(B)?"Renamed":`Moved to ${Mt(B)||"the top"}`)}async function Oy(){if(!B)return;clearTimeout(nn);let e=await gs({op:"delete",name:B});if(!e.ok){Ye(e.error||"Could not delete");return}Ye("Moved to notes/.trash"),ze=!1,J=J.filter((t)=>t.name!==B),await yi(null)}function sn(){let e=V("q").value.trim().toLowerCase(),t=new Map;for(let s of J)for(let o of new Set(ps(s.text).map((l)=>l.tag)))t.set(o,(t.get(o)??0)+1);let i=e.startsWith("#")?e.slice(1):null;V("tags").innerHTML=[...t].sort((s,o)=>o[1]-s[1]||s[0].localeCompare(o[0])).map(([s,o])=>`<button class="chip${s===i?" on":""}" data-tag="${_e(s)}" aria-pressed="${s===i}">#${_e(s)} <span>${o}</span></button>`).join(""),V("tagsh").hidden=!t.size;let n=(s,o=!1)=>{let l=J.find((a)=>a.name===s);return`<li><button class="nt${s===B?" cur":""}" data-open="${_e(s)}"${s===B?' aria-current="true"':""}><span class="nm">${_e(UO(s))}</span>${o&&Mt(s)?`<span class="fd">${_e(Mt(s))}</span>`:""}<span class="age">${l?my(l.mtime):""}</span></button></li>`};if(e){let s=J.filter((o)=>i!==null?ps(o.text).some((l)=>l.tag===i||l.tag.startsWith(i+"/")):o.name.toLowerCase().includes(e)||o.text.toLowerCase().includes(e));V("tree").innerHTML=s.length?`<ul>${s.map((o)=>n(o.name,!0)).join("")}</ul>`:'<p class="none">No note matches.</p>';return}let r=(s,o)=>`<ul>${[...s.folders].map(([l,a])=>{let h=o+l;return`<li><details data-folder="${_e(h)}"${ia.has(h)?"":" open"}><summary><i class="chev">${rr("chev")}</i>${rr("folder")}<span>${_e(l)}</span></summary>${r(a,h+"/")}</details></li>`}).join("")}${s.notes.map((l)=>n(l)).join("")}</ul>`;V("tree").innerHTML=J.length?r(YO(J.map((s)=>s.name)),""):""}var en=!1;function sp(e){en=e,rn()}var Jt=!1;try{Jt=localStorage.getItem("kz-note-wide")==="1"}catch{}function py(e){Jt=e;try{localStorage.setItem("kz-note-wide",e?"1":"0")}catch{}rn()}function rn(){let e=!!B;if(document.body.classList.toggle("full",e&&en),document.body.classList.toggle("wide",Jt),V("pane").hidden=!e,V("empty").hidden=e||J.length>0,V("pick").hidden=e||!J.length,!e)return;let t=V("title");if(document.activeElement!==t)t.value=B;bi()}function bi(e){let t=V("meta");if(!B)return;if(Fe){t.innerHTML='<span class="warnw">This note changed somewhere else since you opened it.</span><span class="acts"><button class="btn ghost" id="theirs">Load theirs</button><button class="btn pri" id="mine">Keep mine</button></span>',V("theirs").onclick=()=>{let n=Fe;Fe=null,ze=!1,St=n.mtime,sa(n.text,!1),bi()},V("mine").onclick=()=>{St=Fe.mtime,Fe=null,Si()};return}if(nr){t.innerHTML='<span>Move this note to <code>notes/.trash</code>?</span><span class="acts"><button class="btn ghost" id="cancel">Cancel</button><button class="btn danger" id="del">Delete</button></span>',V("cancel").onclick=()=>{nr=!1,bi()},V("del").onclick=()=>{nr=!1,Oy()};return}let i=Mt(B);t.innerHTML=`<span>${i?_e(i):"Notes"}</span><span>·</span><span id="saved">${e??(ze?"Not saved yet":"Saved")}</span><span class="sp"></span><button class="ib" id="wide" title="${Jt?"Boxed width":"Full width"}" aria-label="${Jt?"Boxed width":"Full width"}" aria-pressed="${Jt}">${rr(Jt?"box":"wide")}</button><button class="ib" id="full" title="${en?"Exit full screen (Esc)":"Full screen"}" aria-label="${en?"Exit full screen":"Full screen"}">${rr(en?"min":"max")}</button><button class="ib" id="trash" title="Delete note" aria-label="Delete note">${rr("trash")}</button>`,V("trash").onclick=()=>{nr=!0,bi()},V("full").onclick=()=>sp(!en),V("wide").onclick=()=>py(!Jt)}function oa(){let e=V("links");if(!B){e.hidden=!0;return}let t=J.map((n)=>n.name),i=J.filter((n)=>n.name!==B&&Kl(n.text).some((r)=>ir(r.name,t)===B));e.hidden=!i.length,e.innerHTML=`<h3>Linked from</h3><ul>${i.map((n)=>`<li><button class="nt" data-open="${_e(n.name)}"><span class="nm">${_e(UO(n.name))}</span>${Mt(n.name)?`<span class="fd">${_e(Mt(n.name))}</span>`:""}</button></li>`).join("")}</ul>`}function my(e){let t=(Date.now()-e)/1000;return t<60?"now":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}document.addEventListener("click",(e)=>{let t=e.target;if(document.body.classList.contains("side-open")&&!t.closest?.(".side,#side"))document.body.classList.remove("side-open");let i=e.target.closest?.("[data-open],[data-tag]");if(!i||i.closest(".cm-editor"))return;if(i.dataset.open)yi(i.dataset.open);else if(i.dataset.tag){let n=V("q");n.value=n.value==="#"+i.dataset.tag?"":"#"+i.dataset.tag,sn()}});V("tree").addEventListener("toggle",(e)=>{let t=e.target;if(t.dataset.folder)t.open?ia.delete(t.dataset.folder):ia.add(t.dataset.folder)},!0);V("q").addEventListener("input",sn);V("new").onclick=()=>void rp();V("new2").onclick=()=>void rp();V("side").onclick=()=>document.body.classList.toggle("side-open");var tn=V("title");tn.addEventListener("keydown",(e)=>{if(e.key==="Enter")e.preventDefault(),tn.blur();if(e.key==="Escape")tn.value=B??"",tn.blur()});tn.addEventListener("blur",()=>void dy(tn.value));document.addEventListener("keydown",(e)=>{if(e.key!=="Escape"||e.target.matches?.("input"))return;if(document.body.classList.remove("side-open"),document.body.classList.contains("full"))sp(!1)});addEventListener("beforeunload",(e)=>{if(ze)e.preventDefault()});addEventListener("pagehide",()=>{if(B&&ze&&!Fe)fetch("/vault",{method:"POST",keepalive:!0,headers:{"content-type":"application/json"},body:JSON.stringify({dir:Ee,op:"save",name:B,text:Rt.state.sliceDoc(),base:St})})});(async()=>{try{let a=localStorage.getItem("kz-theme");if(a)document.documentElement.dataset.theme=a}catch{}let e;try{e=await(await fetch("/state")).json()}catch{Ye("The board is not running");return}let t=null;try{t=localStorage.getItem("kz-proj")}catch{}let i=new URLSearchParams(location.search).get("dir"),n=(a)=>!!a&&e.projects.some((h)=>h.dir===a);Ee=[i,t,e.dir].find(n)??e.projects[0]?.dir??"";let r=V("proj");r.innerHTML=e.projects.map((a)=>`<option value="${_e(a.dir)}"${a.dir===Ee?" selected":""}>${_e(a.label)}</option>`).join(""),r.onchange=async()=>{if(!await yi(null)){r.value=Ee;return}Ee=r.value;let a=new URL(location.href);a.searchParams.set("dir",Ee),window.history.replaceState(null,"",a),await sr()},await sr();let s=null;try{s=sessionStorage.getItem("kz-note:"+Ee)}catch{}let o=new URLSearchParams(location.search).get("note");if(o&&J.some((a)=>a.name===o))s=o;if(s&&J.some((a)=>a.name===s))await yi(s);let l=()=>{let a=new EventSource("/events");a.onmessage=(h)=>{if(h.data==="changed")sr()},a.onerror=()=>{a.close(),setTimeout(l,3000)}};l()})();
|
package/web/notebook.ts
CHANGED
|
@@ -819,7 +819,8 @@ async function load() {
|
|
|
819
819
|
const DEAL = { duration: 260, easing: "cubic-bezier(.22,.61,.36,1)" };
|
|
820
820
|
function lift(): HTMLElement | null {
|
|
821
821
|
const main = document.querySelector<HTMLElement>(".main")!;
|
|
822
|
-
|
|
822
|
+
const m = document.documentElement.dataset.motion;
|
|
823
|
+
if (m ? m === "reduce" : matchMedia("(prefers-reduced-motion: reduce)").matches) return null;
|
|
823
824
|
const r = main.getBoundingClientRect(),
|
|
824
825
|
top = main.scrollTop;
|
|
825
826
|
const sheet = main.cloneNode(true) as HTMLElement;
|
package/web/notes.html
CHANGED
|
@@ -200,7 +200,11 @@ select.sel{cursor:pointer;appearance:none;padding-right:30px;max-width:min(320px
|
|
|
200
200
|
}
|
|
201
201
|
@media(min-width:901px){#side{display:none}}
|
|
202
202
|
.skel{display:block;border-radius:6px;background:linear-gradient(90deg,var(--line) 25%,color-mix(in srgb,var(--line) 45%,transparent) 50%,var(--line) 75%);background-size:200% 100%;animation:skel 1.2s ease-in-out infinite}@keyframes skel{from{background-position:200% 0}to{background-position:-200% 0}}
|
|
203
|
-
|
|
203
|
+
/* motion: data-motion (Settings) wins over the system's reduced-motion */
|
|
204
|
+
@view-transition{navigation:auto}
|
|
205
|
+
::view-transition-group(*){animation-duration:.2s}
|
|
206
|
+
@media(prefers-reduced-motion:reduce){:root:not([data-motion=full]) *,:root:not([data-motion=full]) *::before,:root:not([data-motion=full]) *::after,:root:not([data-motion=full])::view-transition-group(*),:root:not([data-motion=full])::view-transition-old(*),:root:not([data-motion=full])::view-transition-new(*){transition:none!important;animation:none!important}}
|
|
207
|
+
:root[data-motion=reduce] *,:root[data-motion=reduce] *::before,:root[data-motion=reduce] *::after,:root[data-motion=reduce]::view-transition-group(*),:root[data-motion=reduce]::view-transition-old(*),:root[data-motion=reduce]::view-transition-new(*){transition:none!important;animation:none!important}
|
|
204
208
|
</style>
|
|
205
209
|
</head>
|
|
206
210
|
<body>
|
|
@@ -256,6 +260,9 @@ select.sel{cursor:pointer;appearance:none;padding-right:30px;max-width:min(320px
|
|
|
256
260
|
const paint=()=>{const d=r.dataset.theme?r.dataset.theme==="dark":os.matches;document.querySelectorAll(".theme button").forEach(b=>b.setAttribute("aria-pressed",(b.dataset.t==="dark")===d))};
|
|
257
261
|
window.setTheme=t=>{if(t==="system")delete r.dataset.theme;else r.dataset.theme=t;try{t==="system"?localStorage.removeItem("kz-theme"):localStorage.setItem("kz-theme",t)}catch(e){}paint();dispatchEvent(new Event("kz-theme"))};
|
|
258
262
|
try{const t=localStorage.getItem("kz-theme");if(t)r.dataset.theme=t}catch(e){}
|
|
263
|
+
// Motion: full, reduce, or unset to follow the system's reduced-motion, in kz-motion.
|
|
264
|
+
window.setMotion=m=>{if(m==="system")delete r.dataset.motion;else r.dataset.motion=m;try{m==="system"?localStorage.removeItem("kz-motion"):localStorage.setItem("kz-motion",m)}catch(e){}};
|
|
265
|
+
try{const m=localStorage.getItem("kz-motion");if(m)r.dataset.motion=m}catch(e){}
|
|
259
266
|
os.addEventListener("change",paint);paint();
|
|
260
267
|
document.querySelectorAll(".theme button").forEach(b=>b.onclick=()=>setTheme(b.dataset.t))})();
|
|
261
268
|
</script>
|