UNPKG

@anoki/fse-ui

Version:

FSE UI components library

5 lines (4 loc) 5.22 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./index.cjs688.js"),O=require("./index.cjs710.js"),S=require("./index.cjs701.js"),b=require("./index.cjs703.js");var d,m;function I(){if(m)return d;m=1;let y=g.__require(),p=O.__require(),x=S.__require(),{isClean:c,my:w}=b.__require();function a(u,e){let t=new u.constructor;for(let n in u){if(!Object.prototype.hasOwnProperty.call(u,n)||n==="proxyCache")continue;let i=u[n],r=typeof i;n==="parent"&&r==="object"?e&&(t[n]=e):n==="source"?t[n]=i:Array.isArray(i)?t[n]=i.map(s=>a(s,t)):(r==="object"&&i!==null&&(i=a(i)),t[n]=i)}return t}function l(u,e){if(e&&typeof e.offset<"u")return e.offset;let t=1,n=1,i=0;for(let r=0;r<u.length;r++){if(n===e.line&&t===e.column){i=r;break}u[r]===` `?(t=1,n+=1):t+=1}return i}class h{get proxyOf(){return this}constructor(e={}){this.raws={},this[c]=!1,this[w]=!0;for(let t in e)if(t==="nodes"){this.nodes=[];for(let n of e[t])typeof n.clone=="function"?this.append(n.clone()):this.append(n)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=a(this);for(let n in e)t[n]=e[n];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:n,start:i}=this.rangeBy(t);return this.source.input.error(e,{column:i.column,line:i.line},{column:n.column,line:n.line},t)}return new y(e)}getProxyProcessor(){return{get(e,t){return t==="proxyOf"?e:t==="root"?()=>e.root().toProxy():e[t]},set(e,t,n){return e[t]===n||(e[t]=n,(t==="prop"||t==="value"||t==="name"||t==="params"||t==="important"||t==="text")&&e.markDirty()),!0}}}markClean(){this[c]=!0}markDirty(){if(this[c]){this[c]=!1;let e=this;for(;e=e.parent;)e[c]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e={}){let t=this.source.start;if(e.index)t=this.positionInside(e.index);else if(e.word){let n="document"in this.source.input?this.source.input.document:this.source.input.css,r=n.slice(l(n,this.source.start),l(n,this.source.end)).indexOf(e.word);r!==-1&&(t=this.positionInside(r))}return t}positionInside(e){let t=this.source.start.column,n=this.source.start.line,i="document"in this.source.input?this.source.input.document:this.source.input.css,r=l(i,this.source.start),s=r+e;for(let o=r;o<s;o++)i[o]===` `?(t=1,n+=1):t+=1;return{column:t,line:n,offset:s}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e={}){let t="document"in this.source.input?this.source.input.document:this.source.input.css,n={column:this.source.start.column,line:this.source.start.line,offset:l(t,this.source.start)},i=this.source.end?{column:this.source.end.column+1,line:this.source.end.line,offset:typeof this.source.end.offset=="number"?this.source.end.offset:l(t,this.source.end)+1}:{column:n.column+1,line:n.line,offset:n.offset+1};if(e.word){let s=t.slice(l(t,this.source.start),l(t,this.source.end)).indexOf(e.word);s!==-1&&(n=this.positionInside(s),i=this.positionInside(s+e.word.length))}else e.start?n={column:e.start.column,line:e.start.line,offset:l(t,e.start)}:e.index&&(n=this.positionInside(e.index)),e.end?i={column:e.end.column,line:e.end.line,offset:l(t,e.end)}:typeof e.endIndex=="number"?i=this.positionInside(e.endIndex):e.index&&(i=this.positionInside(e.index+1));return(i.line<n.line||i.line===n.line&&i.column<=n.column)&&(i={column:n.column+1,line:n.line,offset:n.offset+1}),{end:i,start:n}}raw(e,t){return new p().raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let i of e)i===this?n=!0:n?(this.parent.insertAfter(t,i),t=i):this.parent.insertBefore(t,i);n||this.remove()}return this}root(){let e=this;for(;e.parent&&e.parent.type!=="document";)e=e.parent;return e}toJSON(e,t){let n={},i=t==null;t=t||new Map;let r=0;for(let s in this){if(!Object.prototype.hasOwnProperty.call(this,s)||s==="parent"||s==="proxyCache")continue;let o=this[s];if(Array.isArray(o))n[s]=o.map(f=>typeof f=="object"&&f.toJSON?f.toJSON(null,t):f);else if(typeof o=="object"&&o.toJSON)n[s]=o.toJSON(null,t);else if(s==="source"){if(o==null)continue;let f=t.get(o.input);f==null&&(f=r,t.set(o.input,r),r++),n[s]={end:o.end,inputId:f,start:o.start}}else n[s]=o}return i&&(n.inputs=[...t.keys()].map(s=>s.toJSON())),n}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(e=x){e.stringify&&(e=e.stringify);let t="";return e(this,n=>{t+=n}),t}warn(e,t,n={}){let i={node:this};for(let r in n)i[r]=n[r];return e.warn(t,i)}}return d=h,h.default=h,d}exports.__require=I; //# sourceMappingURL=index.cjs695.js.map