UNPKG

@anoki/fse-ui

Version:

FSE UI components library

3 lines (2 loc) 7.49 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index.cjs687.js"),A=require("./index.cjs690.js"),D=require("./index.cjs708.js"),T=require("./index.cjs696.js"),V=require("./index.cjs698.js"),k=require("./index.cjs699.js"),N=require("./index.cjs701.js"),j=require("./index.cjs703.js"),z=require("./index.cjs709.js");var g,v;function $(){if(v)return g;v=1;let E=L.__require(),x=A.__require(),S=D.__require(),P=T.__require(),m=V.__require(),R=k.__require(),_=N.__require(),{isClean:l,my:O}=j.__require(),q=z.__require();const I={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},b={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},C={Once:!0,postcssPlugin:!0,prepare:!0},a=0;function c(n){return typeof n=="object"&&typeof n.then=="function"}function d(n){let e=!1,t=I[n.type];return n.type==="decl"?e=n.prop.toLowerCase():n.type==="atrule"&&(e=n.name.toLowerCase()),e&&n.append?[t,t+"-"+e,a,t+"Exit",t+"Exit-"+e]:e?[t,t+"-"+e,t+"Exit",t+"Exit-"+e]:n.append?[t,a,t+"Exit"]:[t,t+"Exit"]}function w(n){let e;return n.type==="document"?e=["Document",a,"DocumentExit"]:n.type==="root"?e=["Root",a,"RootExit"]:e=d(n),{eventIndex:0,events:e,iterator:0,node:n,visitorIndex:0,visitors:[]}}function p(n){return n[l]=!1,n.nodes&&n.nodes.forEach(e=>p(e)),n}let y={};class h{get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}constructor(e,t,r){this.stringified=!1,this.processed=!1;let s;if(typeof t=="object"&&t!==null&&(t.type==="root"||t.type==="document"))s=p(t);else if(t instanceof h||t instanceof m)s=p(t.root),t.map&&(typeof r.map>"u"&&(r.map={}),r.map.inline||(r.map.inline=!1),r.map.prev=t.map);else{let i=P;r.syntax&&(i=r.syntax.parse),r.parser&&(i=r.parser),i.parse&&(i=i.parse);try{s=i(t,r)}catch(o){this.processed=!0,this.error=o}s&&!s[O]&&E.rebuild(s)}this.result=new m(e,s,r),this.helpers={...y,postcss:y,result:this.result},this.plugins=this.processor.plugins.map(i=>typeof i=="object"&&i.prepare?{...i,...i.prepare(this.result)}:i)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,t){let r=this.result.lastPlugin;try{if(t&&t.addToError(e),this.error=e,e.name==="CssSyntaxError"&&!e.plugin)e.plugin=r.postcssPlugin,e.setMessage();else if(r.postcssVersion&&process.env.NODE_ENV!=="production"){let s=r.postcssPlugin,i=r.postcssVersion,o=this.result.processor.version,u=i.split("."),f=o.split(".");(u[0]!==f[0]||parseInt(u[1])>parseInt(f[1]))&&console.error("Unknown error from PostCSS plugin. Your current PostCSS version is "+o+", but "+s+" uses "+i+". Perhaps this is the source of the error below.")}}catch(s){console&&console.error&&console.error(s)}return e}prepareVisitors(){this.listeners={};let e=(t,r,s)=>{this.listeners[r]||(this.listeners[r]=[]),this.listeners[r].push([t,s])};for(let t of this.plugins)if(typeof t=="object")for(let r in t){if(!b[r]&&/^[A-Z]/.test(r))throw new Error(`Unknown event ${r} in ${t.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!C[r])if(typeof t[r]=="object")for(let s in t[r])s==="*"?e(t,r,t[r][s]):e(t,r+"-"+s.toLowerCase(),t[r][s]);else typeof t[r]=="function"&&e(t,r,t[r])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let e=0;e<this.plugins.length;e++){let t=this.plugins[e],r=this.runOnRoot(t);if(c(r))try{await r}catch(s){throw this.handleError(s)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[l];){e[l]=!0;let t=[w(e)];for(;t.length>0;){let r=this.visitTick(t);if(c(r))try{await r}catch(s){let i=t[t.length-1].node;throw this.handleError(s,i)}}}if(this.listeners.OnceExit)for(let[t,r]of this.listeners.OnceExit){this.result.lastPlugin=t;try{if(e.type==="document"){let s=e.nodes.map(i=>r(i,this.helpers));await Promise.all(s)}else await r(e,this.helpers)}catch(s){throw this.handleError(s)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if(typeof e=="object"&&e.Once){if(this.result.root.type==="document"){let t=this.result.root.nodes.map(r=>e.Once(r,this.helpers));return c(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}else if(typeof e=="function")return e(this.result.root,this.result)}catch(t){throw this.handleError(t)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,t=_;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);let s=new S(t,this.result.root,this.result.opts).generate();return this.result.css=s[0],this.result.map=s[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins){let t=this.runOnRoot(e);if(c(t))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[l];)e[l]=!0,this.walkSync(e);if(this.listeners.OnceExit)if(e.type==="document")for(let t of e.nodes)this.visitSync(this.listeners.OnceExit,t);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,t){return process.env.NODE_ENV!=="production"&&("from"in this.opts||q("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(e,t)}toString(){return this.css}visitSync(e,t){for(let[r,s]of e){this.result.lastPlugin=r;let i;try{i=s(t,this.helpers)}catch(o){throw this.handleError(o,t.proxyOf)}if(t.type!=="root"&&t.type!=="document"&&!t.parent)return!0;if(c(i))throw this.getAsyncError()}}visitTick(e){let t=e[e.length-1],{node:r,visitors:s}=t;if(r.type!=="root"&&r.type!=="document"&&!r.parent){e.pop();return}if(s.length>0&&t.visitorIndex<s.length){let[o,u]=s[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===s.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=o;try{return u(r.toProxy(),this.helpers)}catch(f){throw this.handleError(f,r)}}if(t.iterator!==0){let o=t.iterator,u;for(;u=r.nodes[r.indexes[o]];)if(r.indexes[o]+=1,!u[l]){u[l]=!0,e.push(w(u));return}t.iterator=0,delete r.indexes[o]}let i=t.events;for(;t.eventIndex<i.length;){let o=i[t.eventIndex];if(t.eventIndex+=1,o===a){r.nodes&&r.nodes.length&&(r[l]=!0,t.iterator=r.getIterator());return}else if(this.listeners[o]){t.visitors=this.listeners[o];return}}e.pop()}walkSync(e){e[l]=!0;let t=d(e);for(let r of t)if(r===a)e.nodes&&e.each(s=>{s[l]||this.walkSync(s)});else{let s=this.listeners[r];if(s&&this.visitSync(s,e.toProxy()))return}}warnings(){return this.sync().warnings()}}return h.registerPostcss=n=>{y=n},g=h,h.default=h,R.registerLazyResult(h),x.registerLazyResult(h),g}exports.__require=$; //# sourceMappingURL=index.cjs693.js.map