@lmjs/core 1.0.7 → 2.0.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.
@@ -0,0 +1 @@
1
+ let _w=self;var commentre=/\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;function parseMe(t,e){e=e||{};var i=1,n=1;function s(t){var e=t.match(/\\n/g);e&&(i+=e.length);var s=t.lastIndexOf("\\n");n=~s?t.length-s:n+t.length}function r(){var t={line:i,column:n};return function(e){return e.position=new o(t),f(),e}}function o(t){this.start=t,this.end={line:i,column:n},this.source=e.source}o.prototype.content=t;var a=[];function p(s){var r=new Error(e.source+":"+i+":"+n+": "+s);if(r.reason=s,r.filename=e.source,r.line=i,r.column=n,r.source=t,!e.silent)throw r;a.push(r)}function m(){return h(/^{\\s*/)}function u(){return h(/^}/)}function c(){var e,i=[];for(f(),l(i);t.length&&"}"!=t.charAt(0)&&(e=A()||b());)!1!==e&&(i.push(e),l(i));return i}function h(e){var i=e.exec(t);if(i){var n=i[0];return s(n),t=t.slice(n.length),i}}function f(){h(/^\\s*/)}function l(t){var e;for(t=t||[];e=d();)!1!==e&&t.push(e);return t}function d(){var e=r();if("/"==t.charAt(0)&&"*"==t.charAt(1)){for(var i=2;""!=t.charAt(i)&&("*"!=t.charAt(i)||"/"!=t.charAt(i+1));)++i;if(i+=2,""===t.charAt(i-1))return p("End of comment missing");var o=t.slice(2,i-2);return n+=2,s(o),t=t.slice(i),n+=2,e({type:"comment",comment:o})}}function y(){var t=h(/^([^{]+)/);if(t)return trim(t[0]).replace(/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*\\/+/g,"").replace(/"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'/g,(function(t){return t.replace(/,/g,"‌")})).split(/\\s*(?![^(]*\\)),\\s*/).map((function(t){return t.replace(/\\u200C/g,",")}))}function v(){var t=r(),e=h(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);if(e){if(e=trim(e[0]),!h(/^:\\s*/))return p("property missing ':'");var i=h(/^((?:'(?:\\\\'|.)*?'|"(?:\\\\"|.)*?"|\\([^\\)]*?\\)|[^};])+)/),n=t({type:"declaration",property:e.replace(commentre,""),value:i?trim(i[0]).replace(commentre,""):""});return h(/^[;\\s]*/),n}}function g(){var t,e=[];if(!m())return p("missing '{'");for(l(e);t=v();)!1!==t&&(e.push(t),l(e));return u()?e:p("missing '}'")}function I(){for(var t,e=[],i=r();t=h(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/);)e.push(t[1]),h(/^,\\s*/);if(e.length)return i({type:"keyframe",values:e,declarations:g()})}var C,V=j("import"),k=j("charset"),w=j("namespace");function j(t){var e=new RegExp("^@"+t+"\\\\s*([^;]+);");return function(){var i=r(),n=h(e);if(n){var s={type:t};return s[t]=n[1].trim(),i(s)}}}function A(){if("@"==t[0])return function(){var t=r();if(e=h(/^@([-\\w]+)?keyframes\\s*/)){var e,i=e[1];if(!(e=h(/^([-\\w]+)\\s*/)))return p("@keyframes missing name");var n,s=e[1];if(!m())return p("@keyframes missing '{'");for(var o=l();n=I();)o.push(n),o=o.concat(l());return u()?t({type:"keyframes",name:s,vendor:i,keyframes:o}):p("@keyframes missing '}'")}}()||function(){var t=r(),e=h(/^@media *([^{]+)/);if(e){var i=trim(e[1]);if(!m())return p("@media missing '{'");var n=l().concat(c());return u()?t({type:"media",media:i,rules:n}):p("@media missing '}'")}}()||function(){var t=r(),e=h(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);if(e)return t({type:"custom-media",name:trim(e[1]),media:trim(e[2])})}()||function(){var t=r(),e=h(/^@supports *([^{]+)/);if(e){var i=trim(e[1]);if(!m())return p("@supports missing '{'");var n=l().concat(c());return u()?t({type:"supports",supports:i,rules:n}):p("@supports missing '}'")}}()||V()||k()||w()||function(){var t=r(),e=h(/^@([-\\w]+)?document *([^{]+)/);if(e){var i=trim(e[1]),n=trim(e[2]);if(!m())return p("@document missing '{'");var s=l().concat(c());return u()?t({type:"document",document:n,vendor:i,rules:s}):p("@document missing '}'")}}()||function(){var t=r();if(h(/^@page */)){var e=y()||[];if(!m())return p("@page missing '{'");for(var i,n=l();i=v();)n.push(i),n=n.concat(l());return u()?t({type:"page",selectors:e,declarations:n}):p("@page missing '}'")}}()||function(){var t=r();if(h(/^@host\\s*/)){if(!m())return p("@host missing '{'");var e=l().concat(c());return u()?t({type:"host",rules:e}):p("@host missing '}'")}}()||function(){var t=r();if(h(/^@font-face\\s*/)){if(!m())return p("@font-face missing '{'");for(var e,i=l();e=v();)i.push(e),i=i.concat(l());return u()?t({type:"font-face",declarations:i}):p("@font-face missing '}'")}}()}function b(){var t=r(),e=y();return e?(l(),t({type:"rule",selectors:e,declarations:g()})):p("selector missing")}return addParent((C=c(),{type:"stylesheet",stylesheet:{source:e.source,rules:C,parsingErrors:a}}))}function trim(t){return t?t.replace(/^\\s+|\\s+$/g,""):""}function addParent(t,e){var i=t&&"string"==typeof t.type,n=i?t:e;for(var s in t){var r=t[s];Array.isArray(r)?r.forEach((function(t){addParent(t,n)})):r&&"object"==typeof r&&addParent(r,n)}return i&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:e||null}),t}class Compress{options={};indentation=null;constructor(t){this.options=t??{},this.indentation=t?.indent??null}}Compress.prototype.emit=function(t){return t},Compress.prototype.visit=function(t){return this[t.type](t)},Compress.prototype.mapVisit=function(t,e){var i="";e=e||"";for(var n=0,s=t.length;n<s;n++)i+=this.visit(t[n]),e&&n<s-1&&(i+=this.emit(e));return i},Compress.prototype.compile=function(t){return t.stylesheet.rules.map(this.visit,this).join("")},Compress.prototype.comment=function(t){return this.emit("",t.position)},Compress.prototype.import=function(t){return this.emit("@import "+t.import+";",t.position)},Compress.prototype.media=function(t){return this.emit("@media "+t.media,t.position)+this.emit("{")+this.mapVisit(t.rules)+this.emit("}")},Compress.prototype.document=function(t){var e="@"+(t.vendor||"")+"document "+t.document;return this.emit(e,t.position)+this.emit("{")+this.mapVisit(t.rules)+this.emit("}")},Compress.prototype.charset=function(t){return this.emit("@charset "+t.charset+";",t.position)},Compress.prototype.namespace=function(t){return this.emit("@namespace "+t.namespace+";",t.position)},Compress.prototype.supports=function(t){return this.emit("@supports "+t.supports,t.position)+this.emit("{")+this.mapVisit(t.rules)+this.emit("}")},Compress.prototype.keyframes=function(t){return this.emit("@"+(t.vendor||"")+"keyframes "+t.name,t.position)+this.emit("{")+this.mapVisit(t.keyframes)+this.emit("}")},Compress.prototype.keyframe=function(t){var e=t.declarations;return this.emit(t.values.join(","),t.position)+this.emit("{")+this.mapVisit(e)+this.emit("}")},Compress.prototype.page=function(t){var e=t.selectors.length?t.selectors.join(", "):"";return this.emit("@page "+e,t.position)+this.emit("{")+this.mapVisit(t.declarations)+this.emit("}")},Compress.prototype["font-face"]=function(t){return this.emit("@font-face",t.position)+this.emit("{")+this.mapVisit(t.declarations)+this.emit("}")},Compress.prototype.host=function(t){return this.emit("@host",t.position)+this.emit("{")+this.mapVisit(t.rules)+this.emit("}")},Compress.prototype["custom-media"]=function(t){return this.emit("@custom-media "+t.name+" "+t.media+";",t.position)},Compress.prototype.rule=function(t){var e=t.declarations;return e.length?this.emit(t.selectors.join(","),t.position)+this.emit("{")+this.mapVisit(e)+this.emit("}"):""},Compress.prototype.declaration=function(t){return this.emit(t.property+":"+t.value,t.position)+this.emit(";")};class Identity{options={};indentation=null;constructor(t){this.options=t??{},this.indentation=t?.indent??null}}function stringifyMe(t,e){var i=(e=e||{}).compress?new Compress(e):new Identity(e);if(e.sourcemap){require("./source-map-support")(i);var n=i.compile(t);return i.applySourceMaps(),{code:n,map:"generator"===e.sourcemap?i.map:i.map.toJSON()}}return n=i.compile(t)}Identity.prototype.emit=function(t){return t},Identity.prototype.visit=function(t){return this[t.type](t)},Identity.prototype.mapVisit=function(t,e){var i="";e=e||"";for(var n=0,s=t.length;n<s;n++)i+=this.visit(t[n]),e&&n<s-1&&(i+=this.emit(e));return i},Identity.prototype.compile=function(t){return this.stylesheet(t)},Identity.prototype.stylesheet=function(t){return this.mapVisit(t.stylesheet.rules,"\\n\\n")},Identity.prototype.comment=function(t){return this.emit(this.indent()+"/*"+t.comment+"*/",t.position)},Identity.prototype.import=function(t){return this.emit("@import "+t.import+";",t.position)},Identity.prototype.media=function(t){return this.emit("@media "+t.media,t.position)+this.emit(" {\\n"+this.indent(1))+this.mapVisit(t.rules,"\\n\\n")+this.emit(this.indent(-1)+"\\n}")},Identity.prototype.document=function(t){var e="@"+(t.vendor||"")+"document "+t.document;return this.emit(e,t.position)+this.emit(" {\\n"+this.indent(1))+this.mapVisit(t.rules,"\\n\\n")+this.emit(this.indent(-1)+"\\n}")},Identity.prototype.charset=function(t){return this.emit("@charset "+t.charset+";",t.position)},Identity.prototype.namespace=function(t){return this.emit("@namespace "+t.namespace+";",t.position)},Identity.prototype.supports=function(t){return this.emit("@supports "+t.supports,t.position)+this.emit(" {\\n"+this.indent(1))+this.mapVisit(t.rules,"\\n\\n")+this.emit(this.indent(-1)+"\\n}")},Identity.prototype.keyframes=function(t){return this.emit("@"+(t.vendor||"")+"keyframes "+t.name,t.position)+this.emit(" {\\n"+this.indent(1))+this.mapVisit(t.keyframes,"\\n")+this.emit(this.indent(-1)+"}")},Identity.prototype.keyframe=function(t){var e=t.declarations;return this.emit(this.indent())+this.emit(t.values.join(", "),t.position)+this.emit(" {\\n"+this.indent(1))+this.mapVisit(e,"\\n")+this.emit(this.indent(-1)+"\\n"+this.indent()+"}\\n")},Identity.prototype.page=function(t){var e=t.selectors.length?t.selectors.join(", ")+" ":"";return this.emit("@page "+e,t.position)+this.emit("{\\n")+this.emit(this.indent(1))+this.mapVisit(t.declarations,"\\n")+this.emit(this.indent(-1))+this.emit("\\n}")},Identity.prototype["font-face"]=function(t){return this.emit("@font-face ",t.position)+this.emit("{\\n")+this.emit(this.indent(1))+this.mapVisit(t.declarations,"\\n")+this.emit(this.indent(-1))+this.emit("\\n}")},Identity.prototype.host=function(t){return this.emit("@host",t.position)+this.emit(" {\\n"+this.indent(1))+this.mapVisit(t.rules,"\\n\\n")+this.emit(this.indent(-1)+"\\n}")},Identity.prototype["custom-media"]=function(t){return this.emit("@custom-media "+t.name+" "+t.media+";",t.position)},Identity.prototype.rule=function(t){var e=this.indent(),i=t.declarations;return i.length?this.emit(t.selectors.map((function(t){return e+t})).join(",\\n"),t.position)+this.emit(" {\\n")+this.emit(this.indent(1))+this.mapVisit(i,"\\n")+this.emit(this.indent(-1))+this.emit("\\n"+this.indent()+"}"):""},Identity.prototype.declaration=function(t){return this.emit(this.indent())+this.emit(t.property+": "+t.value,t.position)+this.emit(";")},Identity.prototype.indent=function(t){return this.level=this.level||1,null!=t?(this.level+=t,""):Array(this.level).join(this.indentation||" ")},function(){"use strict";_w.on("css-ready",(function(t){var e=t.data.csses,i=t.data.key,n=t.data.pre;for(let t=0;t<e.length;t++){var s=parseMe(e[t],{silent:!0});for(let t=0;t<s?.stylesheet?.rules?.length;t++)for(let e=0;e<s?.stylesheet?.rules[t].selectors.length;e++)"*"==s?.stylesheet?.rules[t].selectors[e]?s.stylesheet.rules[t].selectors[e]=n+", "+n+" "+s?.stylesheet?.rules[t].selectors[e]:s.stylesheet.rules[t].selectors[e]=n+" "+s?.stylesheet?.rules[t].selectors[e];var r=stringifyMe(s,{compress:!0});e[t]=r}_w.trigger("css-ready",{csses:e,key:i})}))}();