@nil-/xit 0.4.12 → 0.4.13

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/assets/bundler.js CHANGED
@@ -14,7 +14,7 @@ import Component from "${e.replace(/\\/g,"/")}";
14
14
  export const action = (target, context) => {
15
15
  const ref = mount(Component, { target, context });
16
16
  return { destroy: () => unmount(ref) };
17
- };`,ml=new Map,uS=/^(@[^/]*\/[^/]*)(?:\/(.*))?$/s,DS=/^([^/]*)(?:\/(.*))?$/s,dS=async(e,A)=>{if(A!=null){const t=new URL(A);return new URL(e,t).href}return e},Fn=async(e,A)=>e.endsWith("..")?(await fetch(new URL(`${e}/index.js`,A),{method:"HEAD"})).url:e.endsWith("/")?(await fetch(new URL(`${e}index.js`,A),{method:"HEAD"})).url:(await fetch(new URL(e,A),{method:"HEAD"})).url,pS=async e=>{const A=await fetch(e);if(A.ok)return JSON.parse(await A.text())},wS=async(e,A)=>{const[t,g,I=""]=e.split(e.startsWith("@")?uS:DS),Q=g=="@nil-/xit"?`${A}/${g}@0.4.12`:`${A}/${g}`,C=`${Q}/package.json`;if(ml.has(C))return{...ml.get(C),rest:I};const i=await pS(C);if(i!=null)return ml.set(C,{base:Q,json:i}),{base:Q,json:i,rest:I}},fS=(e,A)=>({input:t=>({resolved:t}),hook:async(t,g)=>{if(t.startsWith(Xd))return t;if(t.startsWith(".")){if(g!=null&&g.startsWith(Jn))return await dS(t,g);if(g!=null&&g.startsWith(uI))return`${uI}${await Fn(t,g.slice(uI.length))}`}if(t.startsWith("$")){const Q=t.indexOf("/"),C=t.slice(1,Q);return C in A?`${Jn}${A[C]}${t.slice(Q)}`:null}if(t.startsWith("https://"))return null;const I=await wS(t,e);if(I!=null){const Q=lS(I.json,I.rest,{browser:!0,conditions:["svelte","production"]});if(Q!=null){if(Array.isArray(Q)&&Q.length>0)return`${uI}${await Fn(`${I.base}/${Q[0]}`)}`;if(typeof Q=="string")return`${uI}${await Fn(`${I.base}/${Q}`)}`}else{const C=cS(I.json);if(C!=null)return`${uI}${await Fn(`${I.base}/${C}`)}`}}throw"unknown file, should be unreachable"}});function ZA(e,A,t){const g=t._;let I=!1;function Q(i,{next:B,state:s}){B(s)}function C(i,B,s){if(I||!i.type)return;let a;const n={},o={path:B,state:s,next:(f=s)=>{B.push(i);for(const d in i){if(d==="type")continue;const l=i[d];if(l&&typeof l=="object")if(Array.isArray(l)){const c={};l.forEach((h,w)=>{if(h&&typeof h=="object"){const N=C(h,B,f);N&&(c[w]=N)}}),Object.keys(c).length>0&&(n[d]=l.map((h,w)=>c[w]??h))}else{const c=C(l,B,f);c&&(n[d]=c)}}if(B.pop(),Object.keys(n).length>0)return zd(i,n)},stop:()=>{I=!0},visit:(f,d=s)=>{B.push(i);const l=C(f,B,d)??f;return B.pop(),l}};let D=t[i.type]??Q;if(g){let f;a=g(i,{...o,next:(d=s)=>(s=d,f=D(i,{...o,state:d}),f)}),!a&&f&&(a=f)}else a=D(i,o);if(a||Object.keys(n).length>0&&(a=zd(i,n)),a)return a}return C(e,[],A)??e}function zd(e,A){const t={},g=Object.getOwnPropertyDescriptors(e);for(const I in g)Object.defineProperty(t,I,g[I]);for(const I in A)t[I]=A[I];return t}const KQ=/\s/,Nl=/\s+/,Sn=/^\r?\n/,yS=/^\s/,TC=/^[ \t\r\n]+/,$d=/\s$/,_Q=/[ \t\r\n]+$/,PQ=/[^ \t\r\n]/,Ap=/[ \t\n\r\f]+/g,kS=/^[ \t\n\r\f]+$/,ep=/[^\n]/g,tp=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/,GS=/(^[^a-zA-Z_$]|[^a-zA-Z0-9_$])/g,mS=/^[aeiou]/,NS=/^h[1-6]$/,MS=/(^[0-9-.])|[\^$@%&#?!|()[\]{}^*+~;]/,Ln=/[\u202a\u202b\u202c\u202d\u202e\u2066\u2067\u2068\u2069]+/g,Ml=1,Yn=2,RS=4,JS=8,FS=16,SS=1,LS=2,YS=4,US=8,bS=16,qS=1,vS=2,xS=4,HS=1,gp=2,KS=4,_S=8,PS="[",TS="[!",jS="]",OS=1,Ip=2,Qp="http://www.w3.org/2000/svg",Cp="http://www.w3.org/1998/Math/MathML",ZS=["state_snapshot_uncloneable","binding_property_non_reactive","hydration_attribute_changed","hydration_html_changed","ownership_invalid_binding","ownership_invalid_mutation"];function Un(e,A){if(A.length===0)return null;const g=new $S(A).get(e);return g&&g[0][0]>.7?g[0][1]:null}const Rl=2,Jl=3;function VS(e,A){if(e===null&&A===null)throw"Trying to compare two null values";return e===null||A===null?0:(e=String(e),A=String(A),1-WS(e,A)/Math.max(e.length,A.length))}function WS(e,A){const t=[];let g=0,I=0;for(let Q=0;Q<=A.length;Q++)for(let C=0;C<=e.length;C++)Q&&C?e.charAt(C-1)===A.charAt(Q-1)?I=g:I=Math.min(t[C],t[C-1],g)+1:I=Q+C,g=t[C],t[C]=I;return t.pop()}const XS=/[^\w, ]+/;function zS(e,A=2){const t="-"+e.toLowerCase().replace(XS,"")+"-",g=A-t.length,I=[];if(g>0)for(let Q=0;Q<g;++Q)e+="-";for(let Q=0;Q<t.length-A+1;++Q)I.push(t.slice(Q,Q+A));return I}function ip(e,A=2){const t={},g=zS(e,A);let I=0;for(I;I<g.length;++I)g[I]in t?t[g[I]]+=1:t[g[I]]=1;return t}function Bp(e,A){return A[0]-e[0]}class $S{constructor(A){nA(this,"exact_set",{});nA(this,"match_dict",{});nA(this,"items",{});for(let t=Rl;t<Jl+1;++t)this.items[t]=[];for(let t=0;t<A.length;++t)this.add(A[t])}add(A){if(A.toLowerCase()in this.exact_set)return!1;let g=Rl;for(g;g<Jl+1;++g)this._add(A,g)}_add(A,t){const g=A.toLowerCase(),I=this.items[t]||[],Q=I.length;I.push(0);const C=ip(g,t);let i=0,B,s;for(B in C)s=C[B],i+=Math.pow(s,2),B in this.match_dict?this.match_dict[B].push([Q,s]):this.match_dict[B]=[[Q,s]];const a=Math.sqrt(i);I[Q]=[a,g],this.items[t]=I,this.exact_set[g]=A}get(A){const t=A.toLowerCase(),g=this.exact_set[t];if(g)return[[1,g]];for(let I=Jl;I>=Rl;--I){const Q=this.__get(A,I);if(Q.length>0)return Q}return null}__get(A,t){const g=A.toLowerCase(),I={},Q=ip(g,t),C=this.items[t];let i=0,B,s,a,n,o;for(B in Q)if(s=Q[B],i+=Math.pow(s,2),B in this.match_dict)for(a=0;a<this.match_dict[B].length;++a)n=this.match_dict[B][a][0],o=this.match_dict[B][a][1],n in I?I[n]+=s*o:I[n]=s*o;const D=Math.sqrt(i);let f=[],d;for(const h in I)d=I[h],f.push([d/(D*C[h][0]),C[h][1]]);f.sort(Bp);let l=[];const c=Math.min(50,f.length);for(let h=0;h<c;++h)l.push([VS(f[h][1],g),f[h][1]]);f=l,f.sort(Bp),l=[];for(let h=0;h<f.length;++h)f[h][0]===f[0][0]&&l.push([f[h][0],this.exact_set[f[h][1]]]);return l}}function AL(e,A){return e.start<=A&&A<e.end}function sp(e,A={}){const{offsetLine:t=0,offsetColumn:g=0}=A;let I=0;const Q=e.split(`
17
+ };`,ml=new Map,uS=/^(@[^/]*\/[^/]*)(?:\/(.*))?$/s,DS=/^([^/]*)(?:\/(.*))?$/s,dS=async(e,A)=>{if(A!=null){const t=new URL(A);return new URL(e,t).href}return e},Fn=async(e,A)=>e.endsWith("..")?(await fetch(new URL(`${e}/index.js`,A),{method:"HEAD"})).url:e.endsWith("/")?(await fetch(new URL(`${e}index.js`,A),{method:"HEAD"})).url:(await fetch(new URL(e,A),{method:"HEAD"})).url,pS=async e=>{const A=await fetch(e);if(A.ok)return JSON.parse(await A.text())},wS=async(e,A)=>{const[t,g,I=""]=e.split(e.startsWith("@")?uS:DS),Q=g=="@nil-/xit"?`${A}/${g}@0.4.13`:`${A}/${g}`,C=`${Q}/package.json`;if(ml.has(C))return{...ml.get(C),rest:I};const i=await pS(C);if(i!=null)return ml.set(C,{base:Q,json:i}),{base:Q,json:i,rest:I}},fS=(e,A)=>({input:t=>({resolved:t}),hook:async(t,g)=>{if(t.startsWith(Xd))return t;if(t.startsWith(".")){if(g!=null&&g.startsWith(Jn))return await dS(t,g);if(g!=null&&g.startsWith(uI))return`${uI}${await Fn(t,g.slice(uI.length))}`}if(t.startsWith("$")){const Q=t.indexOf("/"),C=t.slice(1,Q);return C in A?`${Jn}${A[C]}${t.slice(Q)}`:null}if(t.startsWith("https://"))return null;const I=await wS(t,e);if(I!=null){const Q=lS(I.json,I.rest,{browser:!0,conditions:["svelte","production"]});if(Q!=null){if(Array.isArray(Q)&&Q.length>0)return`${uI}${await Fn(`${I.base}/${Q[0]}`)}`;if(typeof Q=="string")return`${uI}${await Fn(`${I.base}/${Q}`)}`}else{const C=cS(I.json);if(C!=null)return`${uI}${await Fn(`${I.base}/${C}`)}`}}throw"unknown file, should be unreachable"}});function ZA(e,A,t){const g=t._;let I=!1;function Q(i,{next:B,state:s}){B(s)}function C(i,B,s){if(I||!i.type)return;let a;const n={},o={path:B,state:s,next:(f=s)=>{B.push(i);for(const d in i){if(d==="type")continue;const l=i[d];if(l&&typeof l=="object")if(Array.isArray(l)){const c={};l.forEach((h,w)=>{if(h&&typeof h=="object"){const N=C(h,B,f);N&&(c[w]=N)}}),Object.keys(c).length>0&&(n[d]=l.map((h,w)=>c[w]??h))}else{const c=C(l,B,f);c&&(n[d]=c)}}if(B.pop(),Object.keys(n).length>0)return zd(i,n)},stop:()=>{I=!0},visit:(f,d=s)=>{B.push(i);const l=C(f,B,d)??f;return B.pop(),l}};let D=t[i.type]??Q;if(g){let f;a=g(i,{...o,next:(d=s)=>(s=d,f=D(i,{...o,state:d}),f)}),!a&&f&&(a=f)}else a=D(i,o);if(a||Object.keys(n).length>0&&(a=zd(i,n)),a)return a}return C(e,[],A)??e}function zd(e,A){const t={},g=Object.getOwnPropertyDescriptors(e);for(const I in g)Object.defineProperty(t,I,g[I]);for(const I in A)t[I]=A[I];return t}const KQ=/\s/,Nl=/\s+/,Sn=/^\r?\n/,yS=/^\s/,TC=/^[ \t\r\n]+/,$d=/\s$/,_Q=/[ \t\r\n]+$/,PQ=/[^ \t\r\n]/,Ap=/[ \t\n\r\f]+/g,kS=/^[ \t\n\r\f]+$/,ep=/[^\n]/g,tp=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/,GS=/(^[^a-zA-Z_$]|[^a-zA-Z0-9_$])/g,mS=/^[aeiou]/,NS=/^h[1-6]$/,MS=/(^[0-9-.])|[\^$@%&#?!|()[\]{}^*+~;]/,Ln=/[\u202a\u202b\u202c\u202d\u202e\u2066\u2067\u2068\u2069]+/g,Ml=1,Yn=2,RS=4,JS=8,FS=16,SS=1,LS=2,YS=4,US=8,bS=16,qS=1,vS=2,xS=4,HS=1,gp=2,KS=4,_S=8,PS="[",TS="[!",jS="]",OS=1,Ip=2,Qp="http://www.w3.org/2000/svg",Cp="http://www.w3.org/1998/Math/MathML",ZS=["state_snapshot_uncloneable","binding_property_non_reactive","hydration_attribute_changed","hydration_html_changed","ownership_invalid_binding","ownership_invalid_mutation"];function Un(e,A){if(A.length===0)return null;const g=new $S(A).get(e);return g&&g[0][0]>.7?g[0][1]:null}const Rl=2,Jl=3;function VS(e,A){if(e===null&&A===null)throw"Trying to compare two null values";return e===null||A===null?0:(e=String(e),A=String(A),1-WS(e,A)/Math.max(e.length,A.length))}function WS(e,A){const t=[];let g=0,I=0;for(let Q=0;Q<=A.length;Q++)for(let C=0;C<=e.length;C++)Q&&C?e.charAt(C-1)===A.charAt(Q-1)?I=g:I=Math.min(t[C],t[C-1],g)+1:I=Q+C,g=t[C],t[C]=I;return t.pop()}const XS=/[^\w, ]+/;function zS(e,A=2){const t="-"+e.toLowerCase().replace(XS,"")+"-",g=A-t.length,I=[];if(g>0)for(let Q=0;Q<g;++Q)e+="-";for(let Q=0;Q<t.length-A+1;++Q)I.push(t.slice(Q,Q+A));return I}function ip(e,A=2){const t={},g=zS(e,A);let I=0;for(I;I<g.length;++I)g[I]in t?t[g[I]]+=1:t[g[I]]=1;return t}function Bp(e,A){return A[0]-e[0]}class $S{constructor(A){nA(this,"exact_set",{});nA(this,"match_dict",{});nA(this,"items",{});for(let t=Rl;t<Jl+1;++t)this.items[t]=[];for(let t=0;t<A.length;++t)this.add(A[t])}add(A){if(A.toLowerCase()in this.exact_set)return!1;let g=Rl;for(g;g<Jl+1;++g)this._add(A,g)}_add(A,t){const g=A.toLowerCase(),I=this.items[t]||[],Q=I.length;I.push(0);const C=ip(g,t);let i=0,B,s;for(B in C)s=C[B],i+=Math.pow(s,2),B in this.match_dict?this.match_dict[B].push([Q,s]):this.match_dict[B]=[[Q,s]];const a=Math.sqrt(i);I[Q]=[a,g],this.items[t]=I,this.exact_set[g]=A}get(A){const t=A.toLowerCase(),g=this.exact_set[t];if(g)return[[1,g]];for(let I=Jl;I>=Rl;--I){const Q=this.__get(A,I);if(Q.length>0)return Q}return null}__get(A,t){const g=A.toLowerCase(),I={},Q=ip(g,t),C=this.items[t];let i=0,B,s,a,n,o;for(B in Q)if(s=Q[B],i+=Math.pow(s,2),B in this.match_dict)for(a=0;a<this.match_dict[B].length;++a)n=this.match_dict[B][a][0],o=this.match_dict[B][a][1],n in I?I[n]+=s*o:I[n]=s*o;const D=Math.sqrt(i);let f=[],d;for(const h in I)d=I[h],f.push([d/(D*C[h][0]),C[h][1]]);f.sort(Bp);let l=[];const c=Math.min(50,f.length);for(let h=0;h<c;++h)l.push([VS(f[h][1],g),f[h][1]]);f=l,f.sort(Bp),l=[];for(let h=0;h<f.length;++h)f[h][0]===f[0][0]&&l.push([f[h][0],this.exact_set[f[h][1]]]);return l}}function AL(e,A){return e.start<=A&&A<e.end}function sp(e,A={}){const{offsetLine:t=0,offsetColumn:g=0}=A;let I=0;const Q=e.split(`
18
18
  `).map((B,s)=>{const a=I+B.length+1,n={start:I,end:a,line:s};return I=a,n});let C=0;function i(B,s){if(typeof B=="string"&&(B=e.indexOf(B,s??0)),B===-1)return;let a=Q[C];const n=B>=a.end?1:-1;for(;a;){if(AL(a,B))return{line:t+a.line,column:g+B-a.start,character:B};C+=n,a=Q[C]}}return i}const eL=/\r/g;function tL(e){e=e.replace(eL,"");let A=5381,t=e.length;for(;t--;)A=(A<<5)-A^e.charCodeAt(t);return(A>>>0).toString(36)}const gL=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];function jC(e){return gL.includes(e)||e.toLowerCase()==="!doctype"}const IL=["arguments","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","eval","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"];function Ep(e){return IL.includes(e)}function ap(e){return e.endsWith("capture")&&e!=="gotpointercapture"&&e!=="lostpointercapture"}const QL=["beforeinput","click","change","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"];function op(e){return QL.includes(e)}const np=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected","webkitdirectory","defer","disablepictureinpicture","disableremoteplayback"];function Fl(e){return np.includes(e)}const CL={formnovalidate:"formNoValidate",ismap:"isMap",nomodule:"noModule",playsinline:"playsInline",readonly:"readOnly",defaultvalue:"defaultValue",defaultchecked:"defaultChecked",srcobject:"srcObject",novalidate:"noValidate",allowfullscreen:"allowFullscreen",disablepictureinpicture:"disablePictureInPicture",disableremoteplayback:"disableRemotePlayback"};function iL(e){return e=e.toLowerCase(),CL[e]??e}const BL=[...np,"formNoValidate","isMap","noModule","playsInline","readOnly","value","volume","defaultValue","defaultChecked","srcObject","noValidate","allowFullscreen","disablePictureInPicture","disableRemotePlayback"];function sL(e){return BL.includes(e)}const EL=["autofocus","muted","defaultValue","defaultChecked"];function Sl(e){return EL.includes(e)}const aL=["touchstart","touchmove"];function oL(e){return aL.includes(e)}const nL=["textContent","innerHTML","innerText"];function Ll(e){return nL.includes(e)}const rL=["body","embed","iframe","img","link","object","script","style","track"];function bn(e){return rL.includes(e)}const cL=["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","discard","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hatch","hatchpath","hkern","image","line","linearGradient","marker","mask","mesh","meshgradient","meshpatch","meshrow","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","solidcolor","stop","svg","switch","symbol","text","textPath","tref","tspan","unknown","use","view","vkern"];function Yl(e){return cL.includes(e)}const lL=["annotation","annotation-xml","maction","math","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics"];function rp(e){return lL.includes(e)}const cp=["$state","$state.raw","$derived","$derived.by"],hL=[...cp,"$state.snapshot","$props","$props.id","$bindable","$effect","$effect.pre","$effect.tracking","$effect.root","$inspect","$inspect().with","$inspect.trace","$host"];function DI(e){return hL.includes(e)}function uL(e){return cp.includes(e)}function DL(e){return e==null?void 0:e.replace(/\//g,"/​")}let TQ=[],xt,qn,MA,Gt=sp("",{offsetLine:1});function lp(e){const A=Gt(e.start);return`${DL(xt)}:${A==null?void 0:A.line}:${A.column}`}let hp,ZI=[],vn=new Map;function dL(e){const A=new Set([...ZI.at(-1)||[],...e]);ZI.push(A)}function pL(){ZI.pop()}function up(e=()=>!0){hp=e}function vg(e,A){var t;return MA&&!!((t=vn.get(e))!=null&&t.some(g=>g.has(A)))}function Dp(e,A){var g;qn=e;const t=(g=A.rootDir)==null?void 0:g.replace(/\\/g,"/");xt=A.filename.replace(/\\/g,"/"),MA=!!A.dev,typeof t=="string"&&xt.startsWith(t)&&(xt=xt.replace(t,"").replace(/^[/\\]/,"")),Gt=sp(qn,{offsetLine:1}),TQ=[],ZI=[],vn.clear()}const wL=/^\t+/;function Ul(e){return e.replace(wL,A=>A.split(" ").join(" "))}function fL(e,A,t){const g=e.split(`
19
19
  `),I=Math.max(0,A-2),Q=Math.min(A+3,g.length),C=String(Q+1).length;return g.slice(I,Q).map((i,B)=>{const s=I+B===A,a=String(B+I+1).padStart(C," ");if(s){const n=" ".repeat(C+2+Ul(i.slice(0,t)).length)+"^";return`${a}: ${Ul(i)}
20
20
  ${n}`}return`${a}: ${Ul(i)}`}).join(`
@@ -1,4 +1,6 @@
1
- <script lang="ts">let { children } = $props();
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ let { children }: { children: Snippet } = $props();
2
4
  </script>
3
5
 
4
6
  <div class="container">
@@ -1,4 +1,5 @@
1
- <script lang="ts">let { children } = $props();
1
+ <script lang="ts">
2
+ let { children } = $props();
2
3
  </script>
3
4
 
4
5
  <div>
@@ -1,47 +1,73 @@
1
- <script lang="ts">import Container from "./Container.svelte";
2
- import DividerOverlay from "../utilities/DividerOverlay.svelte";
3
- import { create } from "../utilities/draggable.js";
4
- let {
5
- min = 2,
6
- side_a,
7
- side_b,
8
- divider,
9
- offset = $bindable(0),
10
- vertical = false,
11
- alt = false
12
- } = $props();
13
- let active = $state(false);
14
- let width = $state(offset + min + 1);
15
- let height = $state(offset + min + 1);
16
- let max = $derived((vertical ? width : height) - min - 1);
17
- const clamped = $derived(Math.max(Math.min(offset, max), min));
18
- let last = null;
19
- const draggable = create({
20
- reset: () => $state.snapshot(clamped),
21
- move: (value) => {
22
- offset = value;
23
- },
24
- move_start: () => {
25
- active = true;
26
- },
27
- move_end: () => {
28
- active = false;
29
- },
30
- dbltap: () => {
31
- if (offset > min) {
32
- last = offset;
33
- offset = min;
34
- } else if (last != null) {
35
- offset = last;
36
- last = null;
37
- }
38
- },
39
- tap: () => {
40
- if (offset > min) {
41
- last = offset;
42
- }
43
- }
44
- });
1
+ <script lang="ts">
2
+ import Container from "./Container.svelte";
3
+ import DividerOverlay from "../utilities/DividerOverlay.svelte";
4
+
5
+ import type { Snippet } from "svelte";
6
+
7
+ import { create } from "../utilities/draggable.js";
8
+
9
+ type Props = {
10
+ min?: number;
11
+ side_a: Snippet;
12
+ side_b: Snippet;
13
+ divider?: Snippet<
14
+ [
15
+ {
16
+ active: boolean;
17
+ alt: boolean;
18
+ vertical: boolean;
19
+ }
20
+ ]
21
+ >;
22
+ offset?: number;
23
+ vertical?: boolean;
24
+ alt?: boolean;
25
+ };
26
+
27
+ let {
28
+ min = 2,
29
+ side_a,
30
+ side_b,
31
+ divider,
32
+ offset = $bindable(0),
33
+ vertical = false,
34
+ alt = false
35
+ }: Props = $props();
36
+
37
+ let active = $state(false);
38
+ let width = $state(offset + min + 1);
39
+ let height = $state(offset + min + 1);
40
+ let max = $derived((vertical ? width : height) - min - 1);
41
+
42
+ const clamped = $derived(Math.max(Math.min(offset, max), min));
43
+
44
+ let last: number | null = null;
45
+ const draggable = create({
46
+ reset: () => $state.snapshot(clamped),
47
+ move: (value) => {
48
+ offset = value;
49
+ },
50
+ move_start: () => {
51
+ active = true;
52
+ },
53
+ move_end: () => {
54
+ active = false;
55
+ },
56
+ dbltap: () => {
57
+ if (offset > min) {
58
+ last = offset;
59
+ offset = min;
60
+ } else if (last != null) {
61
+ offset = last;
62
+ last = null;
63
+ }
64
+ },
65
+ tap: () => {
66
+ if (offset > min) {
67
+ last = offset;
68
+ }
69
+ }
70
+ });
45
71
  </script>
46
72
 
47
73
  <div
@@ -1,6 +1,6 @@
1
1
  import type { Writable } from "svelte/store";
2
2
  import type { CoDec } from "../..";
3
- export type MapType = {
3
+ type MapType = {
4
4
  boolean: boolean;
5
5
  number: number;
6
6
  double: number;
@@ -8,20 +8,20 @@ export type MapType = {
8
8
  buffer: Uint8Array;
9
9
  json: any;
10
10
  };
11
- export type Prettify<T> = {
11
+ type Prettify<T> = {
12
12
  [K in keyof T]: T[K];
13
13
  } & {};
14
- export interface ToType {
14
+ interface ToType {
15
15
  output: this extends {
16
16
  type: infer T extends keyof MapType;
17
17
  } ? MapType[T] : never;
18
18
  }
19
- export interface ToWritableType {
19
+ interface ToWritableType {
20
20
  output: this extends {
21
21
  type: infer T extends keyof MapType;
22
22
  } ? Writable<MapType[T]> : never;
23
23
  }
24
- export interface ExtractItem {
24
+ interface ExtractItem {
25
25
  output: this extends {
26
26
  mask: infer Mask extends {
27
27
  output: any;
@@ -36,7 +36,7 @@ export interface ExtractItem {
36
36
  })["output"];
37
37
  } : never;
38
38
  }
39
- export interface ExtractItems {
39
+ interface ExtractItems {
40
40
  output: this extends {
41
41
  mask: infer Mask;
42
42
  items: infer Items;
@@ -48,7 +48,7 @@ export interface ExtractItems {
48
48
  mask: Mask;
49
49
  })["output"] : Items extends readonly [] ? {} : never : never;
50
50
  }
51
- export interface ExtractFrames {
51
+ interface ExtractFrames {
52
52
  output: this extends {
53
53
  mask: infer Mask;
54
54
  frames: infer Frames;
@@ -65,7 +65,7 @@ export interface ExtractFrames {
65
65
  })["output"]
66
66
  ] : Frames extends readonly [] ? [] : never : never;
67
67
  }
68
- export type ItemDetail<T extends keyof MapType> = T extends "json" ? {
68
+ type ItemDetail<T extends keyof MapType> = T extends "json" ? {
69
69
  key: string;
70
70
  type: T;
71
71
  default: MapType[T];
@@ -89,3 +89,4 @@ export type ReadOnlyFrames<T> = (ExtractFrames & {
89
89
  frames: T;
90
90
  mask: ToType;
91
91
  })["output"];
92
+ export {};
@@ -1,43 +1,57 @@
1
- <script lang="ts" module></script>
2
-
3
- <script lang="ts" generics="const T extends readonly FrameDetails[]">import { onDestroy } from "svelte";
4
- import { xit } from "../..";
5
- const { frames, loaded_data } = $props();
6
- const { load_frame_data } = xit();
7
- let unmounted = false;
8
- const unsubs = [];
9
- let data = $state(frames.map((v) => ({})));
10
- const load = async (frame, index) => {
11
- const frame_data = await load_frame_data(frame.id, frame.tag);
12
- if (unmounted) {
13
- frame_data.unsub();
14
- } else {
15
- unsubs.push(frame_data.unsub);
16
- for (const item of frame.items) {
17
- if (item.type == "boolean") {
18
- data[index][item.key] = frame_data.values.boolean(item.key, item.default);
19
- } else if (item.type == "double") {
20
- data[index][item.key] = frame_data.values.double(item.key, item.default);
21
- } else if (item.type == "number") {
22
- data[index][item.key] = frame_data.values.number(item.key, item.default);
23
- } else if (item.type == "string") {
24
- data[index][item.key] = frame_data.values.string(item.key, item.default);
25
- } else if (item.type == "buffer") {
26
- data[index][item.key] = frame_data.values.buffer(item.key, item.default);
27
- } else if (item.type == "json") {
28
- data[index][item.key] = frame_data.values.json(
29
- item.key,
30
- item.default,
31
- item.codec
32
- );
33
- }
34
- }
35
- }
36
- };
37
- onDestroy(() => {
38
- unmounted = true;
39
- unsubs.forEach((c) => c());
40
- });
1
+ <script lang="ts" module>
2
+ import type { FrameDetails, ReactiveFrames, Prettify } from "./Helpers";
3
+ </script>
4
+
5
+ <script lang="ts" generics="const T extends readonly FrameDetails[]">
6
+ import { onDestroy } from "svelte";
7
+ import type { Snippet } from "svelte";
8
+
9
+ import { xit } from "../..";
10
+
11
+ type Props = {
12
+ frames: T;
13
+ loaded_data?: Snippet<[ReactiveFrames<T>]>;
14
+ };
15
+
16
+ const { frames, loaded_data }: Props = $props();
17
+
18
+ const { load_frame_data } = xit();
19
+
20
+ let unmounted = false;
21
+ const unsubs: (() => void)[] = [];
22
+ let data = $state(frames.map((v) => ({}))) as any;
23
+ const load = async (frame: FrameDetails, index: number) => {
24
+ const frame_data = await load_frame_data(frame.id, frame.tag);
25
+ if (unmounted) {
26
+ frame_data.unsub();
27
+ } else {
28
+ unsubs.push(frame_data.unsub);
29
+ for (const item of frame.items) {
30
+ if (item.type == "boolean") {
31
+ data[index][item.key] = frame_data.values.boolean(item.key, item.default);
32
+ } else if (item.type == "double") {
33
+ data[index][item.key] = frame_data.values.double(item.key, item.default);
34
+ } else if (item.type == "number") {
35
+ data[index][item.key] = frame_data.values.number(item.key, item.default);
36
+ } else if (item.type == "string") {
37
+ data[index][item.key] = frame_data.values.string(item.key, item.default);
38
+ } else if (item.type == "buffer") {
39
+ data[index][item.key] = frame_data.values.buffer(item.key, item.default);
40
+ } else if (item.type == "json") {
41
+ data[index][item.key] = frame_data.values.json(
42
+ item.key,
43
+ item.default,
44
+ item.codec
45
+ );
46
+ }
47
+ }
48
+ }
49
+ };
50
+
51
+ onDestroy(() => {
52
+ unmounted = true;
53
+ unsubs.forEach((c) => c());
54
+ });
41
55
  </script>
42
56
 
43
57
  {#if loaded_data != null}
@@ -1,52 +1,78 @@
1
- <script lang="ts" module></script>
2
-
3
- <script lang="ts" generics="const T extends readonly FrameDetails[]">import { onDestroy } from "svelte";
4
- import { xit } from "../..";
5
- const { frames, loaded_data } = $props();
6
- const { load_frame_data } = xit();
7
- let unmounted = false;
8
- const unsubs = [];
9
- let data = $state(frames.map((v) => ({})));
10
- const load = async (frame, index) => {
11
- const frame_data = await load_frame_data(frame.id, frame.tag);
12
- if (unmounted) {
13
- frame_data.unsub();
14
- } else {
15
- unsubs.push(frame_data.unsub);
16
- for (const item of frame.items) {
17
- const { key } = item;
18
- if (item.type == "boolean") {
19
- unsubs.push(
20
- frame_data.values.boolean(item.key, item.default).subscribe((v) => data[index][key] = v)
21
- );
22
- } else if (item.type == "double") {
23
- unsubs.push(
24
- frame_data.values.double(item.key, item.default).subscribe((v) => data[index][key] = v)
25
- );
26
- } else if (item.type == "number") {
27
- unsubs.push(
28
- frame_data.values.number(item.key, item.default).subscribe((v) => data[index][key] = v)
29
- );
30
- } else if (item.type == "string") {
31
- unsubs.push(
32
- frame_data.values.string(item.key, item.default).subscribe((v) => data[index][key] = v)
33
- );
34
- } else if (item.type == "buffer") {
35
- unsubs.push(
36
- frame_data.values.buffer(item.key, item.default).subscribe((v) => data[index] = v)
37
- );
38
- } else if (item.type == "json") {
39
- unsubs.push(
40
- frame_data.values.json(item.key, item.default, item.codec).subscribe((v) => data[index][key] = v)
41
- );
42
- }
43
- }
44
- }
45
- };
46
- onDestroy(() => {
47
- unmounted = true;
48
- unsubs.forEach((c) => c());
49
- });
1
+ <script lang="ts" module>
2
+ import type { FrameDetails, ReadOnlyFrames } from "./Helpers";
3
+ </script>
4
+
5
+ <script lang="ts" generics="const T extends readonly FrameDetails[]">
6
+ import { onDestroy } from "svelte";
7
+ import type { Snippet } from "svelte";
8
+
9
+ import { xit } from "../..";
10
+
11
+ type Props = {
12
+ frames: T;
13
+ loaded_data?: Snippet<[ReadOnlyFrames<T>]>;
14
+ };
15
+
16
+ const { frames, loaded_data }: Props = $props();
17
+
18
+ const { load_frame_data } = xit();
19
+
20
+ let unmounted = false;
21
+ const unsubs: (() => void)[] = [];
22
+ let data = $state(frames.map((v) => ({}))) as any;
23
+ const load = async (frame: FrameDetails, index: number) => {
24
+ const frame_data = await load_frame_data(frame.id, frame.tag);
25
+ if (unmounted) {
26
+ frame_data.unsub();
27
+ } else {
28
+ unsubs.push(frame_data.unsub);
29
+ for (const item of frame.items) {
30
+ const { key } = item;
31
+ if (item.type == "boolean") {
32
+ unsubs.push(
33
+ frame_data.values
34
+ .boolean(item.key, item.default)
35
+ .subscribe((v) => (data[index][key] = v))
36
+ );
37
+ } else if (item.type == "double") {
38
+ unsubs.push(
39
+ frame_data.values
40
+ .double(item.key, item.default)
41
+ .subscribe((v) => (data[index][key] = v))
42
+ );
43
+ } else if (item.type == "number") {
44
+ unsubs.push(
45
+ frame_data.values
46
+ .number(item.key, item.default)
47
+ .subscribe((v) => (data[index][key] = v))
48
+ );
49
+ } else if (item.type == "string") {
50
+ unsubs.push(
51
+ frame_data.values
52
+ .string(item.key, item.default)
53
+ .subscribe((v) => (data[index][key] = v))
54
+ );
55
+ } else if (item.type == "buffer") {
56
+ unsubs.push(
57
+ frame_data.values
58
+ .buffer(item.key, item.default)
59
+ .subscribe((v) => (data[index] = v))
60
+ );
61
+ } else if (item.type == "json") {
62
+ unsubs.push(
63
+ frame_data.values
64
+ .json(item.key, item.default, item.codec)
65
+ .subscribe((v) => (data[index][key] = v))
66
+ );
67
+ }
68
+ }
69
+ }
70
+ };
71
+
72
+ onDestroy(() => {
73
+ unmounted = true;
74
+ unsubs.forEach((c) => c());
75
+ });
50
76
  </script>
51
77
 
52
78
  {#if loaded_data != null}
@@ -1,7 +1,10 @@
1
- <script lang="ts">let { vertical, alt, active } = $props();
2
- const title = $derived(
3
- `Collapse ${vertical ? alt ? "left" : "right" : alt ? "top" : "bottom"}`
4
- );
1
+ <script lang="ts">
2
+ type Props = { vertical: boolean; alt: boolean; active: boolean };
3
+ let { vertical, alt, active }: Props = $props();
4
+
5
+ const title = $derived(
6
+ `Collapse ${vertical ? (alt ? "left" : "right") : alt ? "top" : "bottom"}`
7
+ );
5
8
  </script>
6
9
 
7
10
  <div
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nil-/xit",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "peerDependencies": {
5
5
  "svelte": "^5.7.1"
6
6
  },
@@ -12,7 +12,6 @@
12
12
  "default": "./index.js"
13
13
  },
14
14
  "./*.svelte": {
15
- "types": "./*.svelte.d.ts",
16
15
  "svelte": "./*.svelte"
17
16
  }
18
17
  }