@joinezco/codeblock 0.0.8
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/LICENSE +661 -0
- package/dist/assets/clike-C8IJ2oj_.js +1 -0
- package/dist/assets/cmake-BQqOBYOt.js +1 -0
- package/dist/assets/dockerfile-C_y-rIpk.js +1 -0
- package/dist/assets/fs.worker-BwEqZcql.ts +109 -0
- package/dist/assets/go-CTD25R5P.js +1 -0
- package/dist/assets/haskell-BWDZoCOh.js +1 -0
- package/dist/assets/index-9HdhmM_Y.js +1 -0
- package/dist/assets/index-C-QhPFHP.js +3 -0
- package/dist/assets/index-C3BnE2cG.js +222 -0
- package/dist/assets/index-CGx5MZO7.js +6 -0
- package/dist/assets/index-CIuq3uTk.js +1 -0
- package/dist/assets/index-CXFONXS8.js +1 -0
- package/dist/assets/index-D5Z27j1C.js +1 -0
- package/dist/assets/index-DWOBdRjn.js +1 -0
- package/dist/assets/index-Dvu-FFzd.js +1 -0
- package/dist/assets/index-Dx_VuNNd.js +1 -0
- package/dist/assets/index-I0dlv-r3.js +1 -0
- package/dist/assets/index-MGle_v2x.js +1 -0
- package/dist/assets/index-N-GE7HTU.js +1 -0
- package/dist/assets/index-aEsF5o-7.js +2 -0
- package/dist/assets/index-as7ELo0J.js +1 -0
- package/dist/assets/index-gUUzXNuP.js +1 -0
- package/dist/assets/index-pGm0qkrJ.js +13 -0
- package/dist/assets/javascript.worker-C1zGArKk.js +527 -0
- package/dist/assets/lua-BgMRiT3U.js +1 -0
- package/dist/assets/perl-CdXCOZ3F.js +1 -0
- package/dist/assets/process-Dw9K5EnD.js +1357 -0
- package/dist/assets/properties-C78fOPTZ.js +1 -0
- package/dist/assets/ruby-B2Rjki9n.js +1 -0
- package/dist/assets/shell-CjFT_Tl9.js +1 -0
- package/dist/assets/swift-BzpIVaGY.js +1 -0
- package/dist/assets/toml-BXUEaScT.js +1 -0
- package/dist/assets/vb-CmGdzxic.js +1 -0
- package/dist/e2e/example.spec.d.ts +5 -0
- package/dist/e2e/example.spec.js +44 -0
- package/dist/editor.d.ts +53 -0
- package/dist/editor.js +248 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.html +16 -0
- package/dist/index.js +6 -0
- package/dist/lsps/index.d.ts +96 -0
- package/dist/lsps/index.js +198 -0
- package/dist/lsps/typescript.d.ts +55 -0
- package/dist/lsps/typescript.js +48 -0
- package/dist/panels/toolbar.d.ts +20 -0
- package/dist/panels/toolbar.js +453 -0
- package/dist/panels/toolbar.test.d.ts +1 -0
- package/dist/panels/toolbar.test.js +146 -0
- package/dist/resources/config.json +13 -0
- package/dist/rpc/serde.d.ts +11 -0
- package/dist/rpc/serde.js +49 -0
- package/dist/rpc/transport.d.ts +11 -0
- package/dist/rpc/transport.js +38 -0
- package/dist/snapshot.bin +0 -0
- package/dist/styles.css +7 -0
- package/dist/themes/index.d.ts +1 -0
- package/dist/themes/index.js +169 -0
- package/dist/themes/util.d.ts +24 -0
- package/dist/themes/util.js +63 -0
- package/dist/themes/vscode.d.ts +6 -0
- package/dist/themes/vscode.js +187 -0
- package/dist/types.d.ts +64 -0
- package/dist/types.js +1 -0
- package/dist/utils/fs.d.ts +29 -0
- package/dist/utils/fs.js +310 -0
- package/dist/utils/indent.d.ts +1 -0
- package/dist/utils/indent.js +38 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/lsp.d.ts +26 -0
- package/dist/utils/lsp.js +74 -0
- package/dist/utils/search.d.ts +30 -0
- package/dist/utils/search.js +68 -0
- package/dist/utils/snapshot.d.ts +60 -0
- package/dist/utils/snapshot.js +299 -0
- package/dist/workers/fs.worker.d.ts +11 -0
- package/dist/workers/fs.worker.js +93 -0
- package/dist/workers/javascript.worker.d.ts +1 -0
- package/dist/workers/javascript.worker.js +20 -0
- package/package.json +95 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const f={name:"properties",token:function(e,i){var o=e.sol()||i.afterSection,l=e.eol();if(i.afterSection=!1,o&&(i.nextMultiline?(i.inMultiline=!0,i.nextMultiline=!1):i.position="def"),l&&!i.nextMultiline&&(i.inMultiline=!1,i.position="def"),o)for(;e.eatSpace(););var n=e.next();return o&&(n==="#"||n==="!"||n===";")?(i.position="comment",e.skipToEnd(),"comment"):o&&n==="["?(i.afterSection=!0,e.skipTo("]"),e.eat("]"),"header"):n==="="||n===":"?(i.position="quote",null):(n==="\\"&&i.position==="quote"&&e.eol()&&(i.nextMultiline=!0),i.position)},startState:function(){return{position:"def",nextMultiline:!1,inMultiline:!1,afterSection:!1}}};export{f as properties};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function k(e){for(var i={},n=0,o=e.length;n<o;++n)i[e[n]]=!0;return i}var v=["alias","and","BEGIN","begin","break","case","class","def","defined?","do","else","elsif","END","end","ensure","false","for","if","in","module","next","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","nil","raise","throw","catch","fail","loop","callcc","caller","lambda","proc","public","protected","private","require","load","require_relative","extend","autoload","__END__","__FILE__","__LINE__","__dir__"],x=k(v),z=k(["def","class","case","for","while","until","module","catch","loop","proc","begin"]),b=k(["end","until"]),h={"[":"]","{":"}","(":")"},_={"]":"[","}":"{",")":"("},f;function c(e,i,n){return n.tokenize.push(e),e(i,n)}function p(e,i){if(e.sol()&&e.match("=begin")&&e.eol())return i.tokenize.push(w),"comment";if(e.eatSpace())return null;var n=e.next(),o;if(n=="`"||n=="'"||n=='"')return c(d(n,"string",n=='"'||n=="`"),e,i);if(n=="/")return g(e)?c(d(n,"string.special",!0),e,i):"operator";if(n=="%"){var l="string",r=!0;e.eat("s")?l="atom":e.eat(/[WQ]/)?l="string":e.eat(/[r]/)?l="string.special":e.eat(/[wxq]/)&&(l="string",r=!1);var u=e.eat(/[^\w\s=]/);return u?(h.propertyIsEnumerable(u)&&(u=h[u]),c(d(u,l,r,!0),e,i)):"operator"}else{if(n=="#")return e.skipToEnd(),"comment";if(n=="<"&&(o=e.match(/^<([-~])[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/)))return c(s(o[2],o[1]),e,i);if(n=="0")return e.eat("x")?e.eatWhile(/[\da-fA-F]/):e.eat("b")?e.eatWhile(/[01]/):e.eatWhile(/[0-7]/),"number";if(/\d/.test(n))return e.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/),"number";if(n=="?"){for(;e.match(/^\\[CM]-/););return e.eat("\\")?e.eatWhile(/\w/):e.next(),"string"}else{if(n==":")return e.eat("'")?c(d("'","atom",!1),e,i):e.eat('"')?c(d('"',"atom",!0),e,i):e.eat(/[\<\>]/)?(e.eat(/[\<\>]/),"atom"):e.eat(/[\+\-\*\/\&\|\:\!]/)?"atom":e.eat(/[a-zA-Z$@_\xa1-\uffff]/)?(e.eatWhile(/[\w$\xa1-\uffff]/),e.eat(/[\?\!\=]/),"atom"):"operator";if(n=="@"&&e.match(/^@?[a-zA-Z_\xa1-\uffff]/))return e.eat("@"),e.eatWhile(/[\w\xa1-\uffff]/),"propertyName";if(n=="$")return e.eat(/[a-zA-Z_]/)?e.eatWhile(/[\w]/):e.eat(/\d/)?e.eat(/\d/):e.next(),"variableName.special";if(/[a-zA-Z_\xa1-\uffff]/.test(n))return e.eatWhile(/[\w\xa1-\uffff]/),e.eat(/[\?\!]/),e.eat(":")?"atom":"variable";if(n=="|"&&(i.varList||i.lastTok=="{"||i.lastTok=="do"))return f="|",null;if(/[\(\)\[\]{}\\;]/.test(n))return f=n,null;if(n=="-"&&e.eat(">"))return"operator";if(/[=+\-\/*:\.^%<>~|]/.test(n)){var t=e.eatWhile(/[=+\-\/*:\.^%<>~|]/);return n=="."&&!t&&(f="."),"operator"}else return null}}}function g(e){for(var i=e.pos,n=0,o,l=!1,r=!1;(o=e.next())!=null;)if(r)r=!1;else{if("[{(".indexOf(o)>-1)n++;else if("]})".indexOf(o)>-1){if(n--,n<0)break}else if(o=="/"&&n==0){l=!0;break}r=o=="\\"}return e.backUp(e.pos-i),l}function a(e){return e||(e=1),function(i,n){if(i.peek()=="}"){if(e==1)return n.tokenize.pop(),n.tokenize[n.tokenize.length-1](i,n);n.tokenize[n.tokenize.length-1]=a(e-1)}else i.peek()=="{"&&(n.tokenize[n.tokenize.length-1]=a(e+1));return p(i,n)}}function y(){var e=!1;return function(i,n){return e?(n.tokenize.pop(),n.tokenize[n.tokenize.length-1](i,n)):(e=!0,p(i,n))}}function d(e,i,n,o){return function(l,r){var u=!1,t;for(r.context.type==="read-quoted-paused"&&(r.context=r.context.prev,l.eat("}"));(t=l.next())!=null;){if(t==e&&(o||!u)){r.tokenize.pop();break}if(n&&t=="#"&&!u){if(l.eat("{")){e=="}"&&(r.context={prev:r.context,type:"read-quoted-paused"}),r.tokenize.push(a());break}else if(/[@\$]/.test(l.peek())){r.tokenize.push(y());break}}u=!u&&t=="\\"}return i}}function s(e,i){return function(n,o){return i&&n.eatSpace(),n.match(e)?o.tokenize.pop():n.skipToEnd(),"string"}}function w(e,i){return e.sol()&&e.match("=end")&&e.eol()&&i.tokenize.pop(),e.skipToEnd(),"comment"}const E={name:"ruby",startState:function(e){return{tokenize:[p],indented:0,context:{type:"top",indented:-e},continuedLine:!1,lastTok:null,varList:!1}},token:function(e,i){f=null,e.sol()&&(i.indented=e.indentation());var n=i.tokenize[i.tokenize.length-1](e,i),o,l=f;if(n=="variable"){var r=e.current();n=i.lastTok=="."?"property":x.propertyIsEnumerable(e.current())?"keyword":/^[A-Z]/.test(r)?"tag":i.lastTok=="def"||i.lastTok=="class"||i.varList?"def":"variable",n=="keyword"&&(l=r,z.propertyIsEnumerable(r)?o="indent":b.propertyIsEnumerable(r)?o="dedent":((r=="if"||r=="unless")&&e.column()==e.indentation()||r=="do"&&i.context.indented<i.indented)&&(o="indent"))}return(f||n&&n!="comment")&&(i.lastTok=l),f=="|"&&(i.varList=!i.varList),o=="indent"||/[\(\[\{]/.test(f)?i.context={prev:i.context,type:f||n,indented:i.indented}:(o=="dedent"||/[\)\]\}]/.test(f))&&i.context.prev&&(i.context=i.context.prev),e.eol()&&(i.continuedLine=f=="\\"||n=="operator"),n},indent:function(e,i,n){if(e.tokenize[e.tokenize.length-1]!=p)return null;var o=i&&i.charAt(0),l=e.context,r=l.type==_[o]||l.type=="keyword"&&/^(?:end|until|else|elsif|when|rescue)\b/.test(i);return l.indented+(r?0:n.unit)+(e.continuedLine?n.unit:0)},languageData:{indentOnInput:/^\s*(?:end|rescue|elsif|else|\})$/,commentTokens:{line:"#"},autocomplete:v}};export{E as ruby};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c={};function s(n,e){for(var i=0;i<e.length;i++)c[e[i]]=n}var k=["true","false"],h=["if","then","do","else","elif","while","until","for","in","esac","fi","fin","fil","done","exit","set","unset","export","function"],p=["ab","awk","bash","beep","cat","cc","cd","chown","chmod","chroot","clear","cp","curl","cut","diff","echo","find","gawk","gcc","get","git","grep","hg","kill","killall","ln","ls","make","mkdir","openssl","mv","nc","nl","node","npm","ping","ps","restart","rm","rmdir","sed","service","sh","shopt","shred","source","sort","sleep","ssh","start","stop","su","sudo","svn","tee","telnet","top","touch","vi","vim","wall","wc","wget","who","write","yes","zsh"];s("atom",k);s("keyword",h);s("builtin",p);function d(n,e){if(n.eatSpace())return null;var i=n.sol(),t=n.next();if(t==="\\")return n.next(),null;if(t==="'"||t==='"'||t==="`")return e.tokens.unshift(l(t,t==="`"?"quote":"string")),u(n,e);if(t==="#")return i&&n.eat("!")?(n.skipToEnd(),"meta"):(n.skipToEnd(),"comment");if(t==="$")return e.tokens.unshift(a),u(n,e);if(t==="+"||t==="=")return"operator";if(t==="-")return n.eat("-"),n.eatWhile(/\w/),"attribute";if(t=="<"){if(n.match("<<"))return"operator";var o=n.match(/^<-?\s*(?:['"]([^'"]*)['"]|([^'"\s]*))/);if(o)return e.tokens.unshift(w(o[1]||o[2])),"string.special"}if(/\d/.test(t)&&(n.eatWhile(/\d/),n.eol()||!/\w/.test(n.peek())))return"number";n.eatWhile(/[\w-]/);var r=n.current();return n.peek()==="="&&/\w+/.test(r)?"def":c.hasOwnProperty(r)?c[r]:null}function l(n,e){var i=n=="("?")":n=="{"?"}":n;return function(t,o){for(var r,f=!1;(r=t.next())!=null;){if(r===i&&!f){o.tokens.shift();break}else if(r==="$"&&!f&&n!=="'"&&t.peek()!=i){f=!0,t.backUp(1),o.tokens.unshift(a);break}else{if(!f&&n!==i&&r===n)return o.tokens.unshift(l(n,e)),u(t,o);if(!f&&/['"]/.test(r)&&!/['"]/.test(n)){o.tokens.unshift(g(r,"string")),t.backUp(1);break}}f=!f&&r==="\\"}return e}}function g(n,e){return function(i,t){return t.tokens[0]=l(n,e),i.next(),u(i,t)}}var a=function(n,e){e.tokens.length>1&&n.eat("$");var i=n.next();return/['"({]/.test(i)?(e.tokens[0]=l(i,i=="("?"quote":i=="{"?"def":"string"),u(n,e)):(/\d/.test(i)||n.eatWhile(/\w/),e.tokens.shift(),"def")};function w(n){return function(e,i){return e.sol()&&e.string==n&&i.tokens.shift(),e.skipToEnd(),"string.special"}}function u(n,e){return(e.tokens[0]||d)(n,e)}const v={name:"shell",startState:function(){return{tokens:[]}},token:function(n,e){return u(n,e)},languageData:{autocomplete:k.concat(h,p),closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"#"}}};export{v as shell};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function c(n){for(var e={},t=0;t<n.length;t++)e[n[t]]=!0;return e}var l=c(["_","var","let","actor","class","enum","extension","import","protocol","struct","func","typealias","associatedtype","open","public","internal","fileprivate","private","deinit","init","new","override","self","subscript","super","convenience","dynamic","final","indirect","lazy","required","static","unowned","unowned(safe)","unowned(unsafe)","weak","as","is","break","case","continue","default","else","fallthrough","for","guard","if","in","repeat","switch","where","while","defer","return","inout","mutating","nonmutating","isolated","nonisolated","catch","do","rethrows","throw","throws","async","await","try","didSet","get","set","willSet","assignment","associativity","infix","left","none","operator","postfix","precedence","precedencegroup","prefix","right","Any","AnyObject","Type","dynamicType","Self","Protocol","__COLUMN__","__FILE__","__FUNCTION__","__LINE__"]),p=c(["var","let","actor","class","enum","extension","import","protocol","struct","func","typealias","associatedtype","for"]),d=c(["true","false","nil","self","super","_"]),v=c(["Array","Bool","Character","Dictionary","Double","Float","Int","Int8","Int16","Int32","Int64","Never","Optional","Set","String","UInt8","UInt16","UInt32","UInt64","Void"]),h="+-/*%=|&<>~^?!",_=":;,.(){}[]",s=/^\-?0b[01][01_]*/,k=/^\-?0o[0-7][0-7_]*/,x=/^\-?0x[\dA-Fa-f][\dA-Fa-f_]*(?:(?:\.[\dA-Fa-f][\dA-Fa-f_]*)?[Pp]\-?\d[\d_]*)?/,y=/^\-?\d[\d_]*(?:\.\d[\d_]*)?(?:[Ee]\-?\d[\d_]*)?/,g=/^\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1/,w=/^\.(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/,z=/^\#[A-Za-z]+/,b=/^@(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/;function f(n,e,t){if(n.sol()&&(e.indented=n.indentation()),n.eatSpace())return null;var i=n.peek();if(i=="/"){if(n.match("//"))return n.skipToEnd(),"comment";if(n.match("/*"))return e.tokenize.push(a),a(n,e)}if(n.match(z))return"builtin";if(n.match(b))return"attribute";if(n.match(s)||n.match(k)||n.match(x)||n.match(y))return"number";if(n.match(w))return"property";if(h.indexOf(i)>-1)return n.next(),"operator";if(_.indexOf(i)>-1)return n.next(),n.match(".."),"punctuation";var r;if(r=n.match(/("""|"|')/)){var o=I.bind(null,r[0]);return e.tokenize.push(o),o(n,e)}if(n.match(g)){var u=n.current();return v.hasOwnProperty(u)?"type":d.hasOwnProperty(u)?"atom":l.hasOwnProperty(u)?(p.hasOwnProperty(u)&&(e.prev="define"),"keyword"):t=="define"?"def":"variable"}return n.next(),null}function A(){var n=0;return function(e,t,i){var r=f(e,t,i);if(r=="punctuation"){if(e.current()=="(")++n;else if(e.current()==")"){if(n==0)return e.backUp(1),t.tokenize.pop(),t.tokenize[t.tokenize.length-1](e,t);--n}}return r}}function I(n,e,t){for(var i=n.length==1,r,o=!1;r=e.peek();)if(o){if(e.next(),r=="(")return t.tokenize.push(A()),"string";o=!1}else{if(e.match(n))return t.tokenize.pop(),"string";e.next(),o=r=="\\"}return i&&t.tokenize.pop(),"string"}function a(n,e){for(var t;t=n.next();)if(t==="/"&&n.eat("*"))e.tokenize.push(a);else if(t==="*"&&n.eat("/")){e.tokenize.pop();break}return"comment"}function O(n,e,t){this.prev=n,this.align=e,this.indented=t}function m(n,e){var t=e.match(/^\s*($|\/[\/\*]|[)}\]])/,!1)?null:e.column()+1;n.context=new O(n.context,t,n.indented)}function S(n){n.context&&(n.indented=n.context.indented,n.context=n.context.prev)}const C={name:"swift",startState:function(){return{prev:null,context:null,indented:0,tokenize:[]}},token:function(n,e){var t=e.prev;e.prev=null;var i=e.tokenize[e.tokenize.length-1]||f,r=i(n,e,t);if(!r||r=="comment"?e.prev=t:e.prev||(e.prev=r),r=="punctuation"){var o=/[\(\[\{]|([\]\)\}])/.exec(n.current());o&&(o[1]?S:m)(e,n)}return r},indent:function(n,e,t){var i=n.context;if(!i)return 0;var r=/^[\]\}\)]/.test(e);return i.align!=null?i.align-(r?1:0):i.indented+(r?0:t.unit)},languageData:{indentOnInput:/^\s*[\)\}\]]$/,commentTokens:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}};export{C as swift};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l={name:"toml",startState:function(){return{inString:!1,stringType:"",lhs:!0,inArray:0}},token:function(n,e){if(!e.inString&&(n.peek()=='"'||n.peek()=="'")&&(e.stringType=n.peek(),n.next(),e.inString=!0),n.sol()&&e.inArray===0&&(e.lhs=!0),e.inString){for(;e.inString&&!n.eol();)n.peek()===e.stringType?(n.next(),e.inString=!1):n.peek()==="\\"?(n.next(),n.next()):n.match(/^.[^\\\"\']*/);return e.lhs?"property":"string"}else{if(e.inArray&&n.peek()==="]")return n.next(),e.inArray--,"bracket";if(e.lhs&&n.peek()==="["&&n.skipTo("]"))return n.next(),n.peek()==="]"&&n.next(),"atom";if(n.peek()==="#")return n.skipToEnd(),"comment";if(n.eatSpace())return null;if(e.lhs&&n.eatWhile(function(i){return i!="="&&i!=" "}))return"property";if(e.lhs&&n.peek()==="=")return n.next(),e.lhs=!1,null;if(!e.lhs&&n.match(/^\d\d\d\d[\d\-\:\.T]*Z/))return"atom";if(!e.lhs&&(n.match("true")||n.match("false")))return"atom";if(!e.lhs&&n.peek()==="[")return e.inArray++,n.next(),"bracket";if(!e.lhs&&n.match(/^\-?\d+(?:\.\d+)?/))return"number";n.eatSpace()||n.next()}return null},languageData:{commentTokens:{line:"#"}}};export{l as toml};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u="error";function o(e){return new RegExp("^(("+e.join(")|(")+"))\\b","i")}var b=new RegExp("^[\\+\\-\\*/%&\\\\|\\^~<>!]"),k=new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]"),x=new RegExp("^((==)|(<>)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))"),m=new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"),I=new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))"),R=new RegExp("^[_A-Za-z][_A-Za-z0-9]*"),a=["class","module","sub","enum","select","while","if","function","get","set","property","try","structure","synclock","using","with"],f=["else","elseif","case","catch","finally"],h=["next","loop"],s=["and","andalso","or","orelse","xor","in","not","is","isnot","like"],O=o(s),v=["#const","#else","#elseif","#end","#if","#region","addhandler","addressof","alias","as","byref","byval","cbool","cbyte","cchar","cdate","cdbl","cdec","cint","clng","cobj","compare","const","continue","csbyte","cshort","csng","cstr","cuint","culng","cushort","declare","default","delegate","dim","directcast","each","erase","error","event","exit","explicit","false","for","friend","gettype","goto","handles","implements","imports","infer","inherits","interface","isfalse","istrue","lib","me","mod","mustinherit","mustoverride","my","mybase","myclass","namespace","narrowing","new","nothing","notinheritable","notoverridable","of","off","on","operator","option","optional","out","overloads","overridable","overrides","paramarray","partial","private","protected","public","raiseevent","readonly","redim","removehandler","resume","return","shadows","shared","static","step","stop","strict","then","throw","to","true","trycast","typeof","until","until","when","widening","withevents","writeonly"],p=["object","boolean","char","string","byte","sbyte","short","ushort","int16","uint16","integer","uinteger","int32","uint32","long","ulong","int64","uint64","decimal","single","double","float","date","datetime","intptr","uintptr"],z=o(v),E=o(p),C='"',S=o(a),g=o(f),y=o(h),w=o(["end"]),T=o(["do"]);function l(e,n){n.currentIndent++}function c(e,n){n.currentIndent--}function d(e,n){if(e.eatSpace())return null;var i=e.peek();if(i==="'")return e.skipToEnd(),"comment";if(e.match(/^((&H)|(&O))?[0-9\.a-f]/i,!1)){var r=!1;if((e.match(/^\d*\.\d+F?/i)||e.match(/^\d+\.\d*F?/)||e.match(/^\.\d+F?/))&&(r=!0),r)return e.eat(/J/i),"number";var t=!1;if(e.match(/^&H[0-9a-f]+/i)||e.match(/^&O[0-7]+/i)?t=!0:e.match(/^[1-9]\d*F?/)?(e.eat(/J/i),t=!0):e.match(/^0(?![\dx])/i)&&(t=!0),t)return e.eat(/L/i),"number"}return e.match(C)?(n.tokenize=F(e.current()),n.tokenize(e,n)):e.match(I)||e.match(m)?null:e.match(x)||e.match(b)||e.match(O)?"operator":e.match(k)?null:e.match(T)?(l(e,n),n.doInCurrentLine=!0,"keyword"):e.match(S)?(n.doInCurrentLine?n.doInCurrentLine=!1:l(e,n),"keyword"):e.match(g)?"keyword":e.match(w)?(c(e,n),c(e,n),"keyword"):e.match(y)?(c(e,n),"keyword"):e.match(E)||e.match(z)?"keyword":e.match(R)?"variable":(e.next(),u)}function F(e){var n=e.length==1,i="string";return function(r,t){for(;!r.eol();){if(r.eatWhile(/[^'"]/),r.match(e))return t.tokenize=d,i;r.eat(/['"]/)}return n&&(t.tokenize=d),i}}function K(e,n){var i=n.tokenize(e,n),r=e.current();if(r===".")return i=n.tokenize(e,n),i==="variable"?"variable":u;var t="[({".indexOf(r);return t!==-1&&l(e,n),t="])}".indexOf(r),t!==-1&&c(e,n)?u:i}const L={name:"vb",startState:function(){return{tokenize:d,lastToken:null,currentIndent:0,nextLineIndent:0,doInCurrentLine:!1}},token:function(e,n){e.sol()&&(n.currentIndent+=n.nextLineIndent,n.nextLineIndent=0,n.doInCurrentLine=0);var i=K(e,n);return n.lastToken={style:i,content:e.current()},i},indent:function(e,n,i){var r=n.replace(/^\s+|\s+$/g,"");return r.match(y)||r.match(w)||r.match(g)?i.unit*(e.currentIndent-1):e.currentIndent<0?0:e.currentIndent*i.unit},languageData:{closeBrackets:{brackets:["(","[","{",'"']},commentTokens:{line:"'"},autocomplete:a.concat(f).concat(h).concat(s).concat(v).concat(p)}};export{L as vb};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { test } from '@playwright/test';
|
|
2
|
+
import * as Comlink from "comlink";
|
|
3
|
+
import { watchOptionsTransferHandler, asyncGeneratorTransferHandler } from '../rpc/serde';
|
|
4
|
+
Comlink.transferHandlers.set('asyncGenerator', asyncGeneratorTransferHandler);
|
|
5
|
+
Comlink.transferHandlers.set('watchOptions', watchOptionsTransferHandler);
|
|
6
|
+
test.describe('workers/fs', async () => {
|
|
7
|
+
test('should initialize from existing buffer', async ({ page }) => {
|
|
8
|
+
page.on('worker', worker => {
|
|
9
|
+
console.log('Worker created: ' + worker.url());
|
|
10
|
+
// @ts-expect-error
|
|
11
|
+
worker.on('console', msg => {
|
|
12
|
+
console.log(`Worker console message: ${msg}`);
|
|
13
|
+
});
|
|
14
|
+
worker.on('close', worker => console.log('Worker destroyed: ' + worker.url()));
|
|
15
|
+
});
|
|
16
|
+
page.on('console', msg => console.log(msg.text()));
|
|
17
|
+
page.on('console', msg => {
|
|
18
|
+
if (msg.type() === 'error')
|
|
19
|
+
console.log(`Error text: "${msg.text()}"`);
|
|
20
|
+
});
|
|
21
|
+
await page.goto('http://localhost:5173');
|
|
22
|
+
await page.addScriptTag({ url: 'https://unpkg.com/comlink/dist/umd/comlink.js' });
|
|
23
|
+
// const content = await page.evaluate(async (workerUrl) => {
|
|
24
|
+
// const { asyncGeneratorTransferHandler, watchOptionsTransferHandler } = await import('../../src/rpc/serde.js');
|
|
25
|
+
// Comlink.transferHandlers.set('asyncGenerator', asyncGeneratorTransferHandler)
|
|
26
|
+
// Comlink.transferHandlers.set('watchOptions', watchOptionsTransferHandler)
|
|
27
|
+
// console.log('before worker??')
|
|
28
|
+
// console.log(window.location.origin, 'before worker');
|
|
29
|
+
// const worker = new SharedWorker(workerUrl, { type: 'module' });
|
|
30
|
+
// console.log({ port: worker.port })
|
|
31
|
+
// console.log('worker started');
|
|
32
|
+
// worker.port.start();
|
|
33
|
+
// const { mount } = Comlink.wrap<FsMountOptions>(worker.port);
|
|
34
|
+
// const { fs } = await mount({ fsBuffer: new ArrayBuffer(0x100000) });
|
|
35
|
+
// // window.fs = await fs;
|
|
36
|
+
// await fs.writeFile('/example.ts', 'console.log("Hello, world!")');
|
|
37
|
+
// return await fs.readFile('/example.ts', { encoding: 'utf-8' });
|
|
38
|
+
// }, workerUrl);
|
|
39
|
+
// const fileContent = await page.evaluate(async (proxy) => {
|
|
40
|
+
// return proxy.readFile('/some/path', 'utf-8');
|
|
41
|
+
// }, fsProxy);
|
|
42
|
+
// expect(fileContent).toBe('expected content');
|
|
43
|
+
});
|
|
44
|
+
});
|
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Compartment, Extension, Facet, StateField } from "@codemirror/state";
|
|
2
|
+
import { EditorView } from "@codemirror/view";
|
|
3
|
+
import { HighlightStyle } from "@codemirror/language";
|
|
4
|
+
import { VfsInterface } from "./types";
|
|
5
|
+
import { ExtensionOrLanguage } from "./lsps";
|
|
6
|
+
import { SearchIndex } from "./utils/search";
|
|
7
|
+
export type { CommandResult } from "./panels/toolbar";
|
|
8
|
+
export type CodeblockConfig = {
|
|
9
|
+
fs: VfsInterface;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
filepath?: string;
|
|
12
|
+
content?: string;
|
|
13
|
+
toolbar?: boolean;
|
|
14
|
+
index?: SearchIndex;
|
|
15
|
+
language?: ExtensionOrLanguage;
|
|
16
|
+
dark?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type CreateCodeblockArgs = CodeblockConfig & {
|
|
19
|
+
parent: HTMLElement;
|
|
20
|
+
content?: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const CodeblockFacet: Facet<CodeblockConfig, CodeblockConfig>;
|
|
23
|
+
export declare const configCompartment: Compartment;
|
|
24
|
+
export declare const languageSupportCompartment: Compartment;
|
|
25
|
+
export declare const languageServerCompartment: Compartment;
|
|
26
|
+
export declare const indentationCompartment: Compartment;
|
|
27
|
+
export declare const readOnlyCompartment: Compartment;
|
|
28
|
+
export declare const openFileEffect: import("@codemirror/state").StateEffectType<{
|
|
29
|
+
path: string;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const fileLoadedEffect: import("@codemirror/state").StateEffectType<{
|
|
32
|
+
path: string;
|
|
33
|
+
content: string;
|
|
34
|
+
language: ExtensionOrLanguage | null;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const setThemeEffect: import("@codemirror/state").StateEffectType<{
|
|
37
|
+
dark: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
export declare const currentFileField: StateField<{
|
|
40
|
+
path: string | null;
|
|
41
|
+
content: string;
|
|
42
|
+
language: ExtensionOrLanguage | null;
|
|
43
|
+
loading: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
export declare const renderMarkdownCode: (code: any, parser: any, highlighter: HighlightStyle) => string;
|
|
46
|
+
export declare const codeblock: ({ content, fs, cwd, filepath, language, toolbar, index }: CodeblockConfig) => (Extension | StateField<import("./panels/toolbar").SearchResult[]> | StateField<{
|
|
47
|
+
path: string | null;
|
|
48
|
+
content: string;
|
|
49
|
+
language: ExtensionOrLanguage | null;
|
|
50
|
+
loading: boolean;
|
|
51
|
+
}>)[];
|
|
52
|
+
export declare const basicSetup: Extension;
|
|
53
|
+
export declare function createCodeblock({ parent, fs, filepath, language, content, cwd, toolbar, index, dark }: CreateCodeblockArgs): EditorView;
|
package/dist/editor.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { Compartment, EditorState, Facet, StateEffect, StateField } from "@codemirror/state";
|
|
2
|
+
import { EditorView, ViewPlugin, keymap, showPanel, tooltips, lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, rectangularSelection, crosshairCursor, highlightActiveLine } from "@codemirror/view";
|
|
3
|
+
import { debounce } from "lodash";
|
|
4
|
+
import { codeblockTheme } from "./themes/index";
|
|
5
|
+
import { vscodeLightDark, vscodeStyleMod } from "./themes/vscode";
|
|
6
|
+
import { defaultKeymap, history, historyKeymap, indentWithTab } from "@codemirror/commands";
|
|
7
|
+
import { detectIndentationUnit } from "./utils";
|
|
8
|
+
import { completionKeymap, closeBrackets, closeBracketsKeymap } from "@codemirror/autocomplete";
|
|
9
|
+
import { bracketMatching, defaultHighlightStyle, foldGutter, foldKeymap, indentOnInput, indentUnit, syntaxHighlighting } from "@codemirror/language";
|
|
10
|
+
import { searchKeymap, highlightSelectionMatches } from "@codemirror/search";
|
|
11
|
+
import { extOrLanguageToLanguageId, getLanguageSupport } from "./lsps";
|
|
12
|
+
import { documentUri, languageId } from '@marimo-team/codemirror-languageserver';
|
|
13
|
+
import { lintKeymap } from "@codemirror/lint";
|
|
14
|
+
import { highlightCode } from "@lezer/highlight";
|
|
15
|
+
import { LSP } from "./utils/lsp";
|
|
16
|
+
import { toolbarPanel, searchResultsField } from "./panels/toolbar";
|
|
17
|
+
import { StyleModule } from "style-mod";
|
|
18
|
+
import { dirname } from "path-browserify";
|
|
19
|
+
export const CodeblockFacet = Facet.define({
|
|
20
|
+
combine: (values) => values[0]
|
|
21
|
+
});
|
|
22
|
+
// Compartments for dynamically reconfiguring extensions
|
|
23
|
+
export const configCompartment = new Compartment();
|
|
24
|
+
export const languageSupportCompartment = new Compartment();
|
|
25
|
+
export const languageServerCompartment = new Compartment();
|
|
26
|
+
export const indentationCompartment = new Compartment();
|
|
27
|
+
export const readOnlyCompartment = new Compartment();
|
|
28
|
+
// Effects + Fields for async file handling
|
|
29
|
+
export const openFileEffect = StateEffect.define();
|
|
30
|
+
export const fileLoadedEffect = StateEffect.define();
|
|
31
|
+
// Light mode/dark mode theme toggle
|
|
32
|
+
export const setThemeEffect = StateEffect.define();
|
|
33
|
+
// Holds the current file lifecycle
|
|
34
|
+
export const currentFileField = StateField.define({
|
|
35
|
+
create(state) {
|
|
36
|
+
const cfg = state.facet(CodeblockFacet);
|
|
37
|
+
if (cfg.filepath) {
|
|
38
|
+
// Seed an initial load; the plugin will react after init without dispatching during construction
|
|
39
|
+
return { path: cfg.filepath, content: "", language: null, loading: true };
|
|
40
|
+
}
|
|
41
|
+
// No initial file; start with provided content
|
|
42
|
+
return { path: null, content: cfg.content || "", language: cfg.language || null, loading: false };
|
|
43
|
+
},
|
|
44
|
+
update(value, tr) {
|
|
45
|
+
for (let e of tr.effects) {
|
|
46
|
+
if (e.is(openFileEffect)) {
|
|
47
|
+
return { path: e.value.path, content: "", language: null, loading: true };
|
|
48
|
+
}
|
|
49
|
+
if (e.is(fileLoadedEffect)) {
|
|
50
|
+
return { path: e.value.path, content: e.value.content, language: e.value.language, loading: false };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
// A safe dispatcher to avoid nested-update errors from UI events during CM updates
|
|
57
|
+
function safeDispatch(view, spec) {
|
|
58
|
+
// Always queue to a microtask so we never dispatch within an ongoing update cycle
|
|
59
|
+
queueMicrotask(() => {
|
|
60
|
+
try {
|
|
61
|
+
view.dispatch(spec);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
console.error(e);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const navigationKeymap = [{
|
|
69
|
+
key: "ArrowUp",
|
|
70
|
+
run: (view) => {
|
|
71
|
+
const cursor = view.state.selection.main;
|
|
72
|
+
const line = view.state.doc.lineAt(cursor.head);
|
|
73
|
+
const toolbarInput = view.dom.querySelector('.cm-toolbar-input');
|
|
74
|
+
if (line.number === 1 && toolbarInput) {
|
|
75
|
+
toolbarInput.focus();
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}];
|
|
81
|
+
export const renderMarkdownCode = (code, parser, highlighter) => {
|
|
82
|
+
let result = document.createElement("pre");
|
|
83
|
+
function emit(text, classes) {
|
|
84
|
+
let node = document.createTextNode(text);
|
|
85
|
+
if (classes) {
|
|
86
|
+
let span = document.createElement("span");
|
|
87
|
+
span.appendChild(node);
|
|
88
|
+
span.className = classes;
|
|
89
|
+
node = span;
|
|
90
|
+
}
|
|
91
|
+
result.appendChild(node);
|
|
92
|
+
}
|
|
93
|
+
function emitBreak() { result.appendChild(document.createTextNode("\n")); }
|
|
94
|
+
highlightCode(code, parser.parse(code), highlighter, emit, emitBreak);
|
|
95
|
+
return result.getHTML();
|
|
96
|
+
};
|
|
97
|
+
// Main codeblock factory
|
|
98
|
+
export const codeblock = ({ content, fs, cwd, filepath, language, toolbar = true, index }) => [
|
|
99
|
+
configCompartment.of(CodeblockFacet.of({ content, fs, filepath, cwd, language, toolbar, index })),
|
|
100
|
+
currentFileField,
|
|
101
|
+
languageSupportCompartment.of([]),
|
|
102
|
+
languageServerCompartment.of([]),
|
|
103
|
+
indentationCompartment.of(indentUnit.of(" ")),
|
|
104
|
+
readOnlyCompartment.of(EditorState.readOnly.of(false)),
|
|
105
|
+
tooltips({ position: "fixed" }),
|
|
106
|
+
showPanel.of(toolbar ? toolbarPanel : null),
|
|
107
|
+
codeblockTheme,
|
|
108
|
+
codeblockView,
|
|
109
|
+
keymap.of(navigationKeymap.concat([indentWithTab])),
|
|
110
|
+
vscodeLightDark,
|
|
111
|
+
searchResultsField,
|
|
112
|
+
];
|
|
113
|
+
// ViewPlugin reacts to field state & effects, with microtask scheduling to avoid nested updates
|
|
114
|
+
const codeblockView = ViewPlugin.define((view) => {
|
|
115
|
+
StyleModule.mount(document, vscodeStyleMod);
|
|
116
|
+
let { fs } = view.state.facet(CodeblockFacet);
|
|
117
|
+
// Debounced save
|
|
118
|
+
const save = debounce(async () => {
|
|
119
|
+
const fileState = view.state.field(currentFileField);
|
|
120
|
+
if (fileState.path) {
|
|
121
|
+
// confirm parent exists
|
|
122
|
+
const parent = dirname(fileState.path);
|
|
123
|
+
if (parent) {
|
|
124
|
+
await fs.mkdir(parent, { recursive: true }).catch(console.error);
|
|
125
|
+
}
|
|
126
|
+
await fs.writeFile(fileState.path, view.state.doc.toString()).catch(console.error);
|
|
127
|
+
}
|
|
128
|
+
}, 500);
|
|
129
|
+
// Guard to prevent duplicate opens for same path while loading
|
|
130
|
+
let opening = null;
|
|
131
|
+
async function setLanguageSupport(language) {
|
|
132
|
+
if (!language)
|
|
133
|
+
return;
|
|
134
|
+
const langSupport = await getLanguageSupport(extOrLanguageToLanguageId[language]);
|
|
135
|
+
safeDispatch(view, {
|
|
136
|
+
effects: [
|
|
137
|
+
languageSupportCompartment.reconfigure(langSupport || []),
|
|
138
|
+
]
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async function handleOpen(path) {
|
|
142
|
+
if (!path)
|
|
143
|
+
return;
|
|
144
|
+
if (opening === path)
|
|
145
|
+
return;
|
|
146
|
+
opening = path;
|
|
147
|
+
try {
|
|
148
|
+
const ext = path.split('.').pop()?.toLowerCase();
|
|
149
|
+
const lang = (ext ? (extOrLanguageToLanguageId)[ext] ?? null : language) || 'markdown';
|
|
150
|
+
let langSupport = lang ? await getLanguageSupport(lang) : null;
|
|
151
|
+
safeDispatch(view, {
|
|
152
|
+
effects: [
|
|
153
|
+
languageSupportCompartment.reconfigure(langSupport || []),
|
|
154
|
+
]
|
|
155
|
+
});
|
|
156
|
+
const exists = await fs.exists(path);
|
|
157
|
+
const content = exists ? await fs.readFile(path) : "";
|
|
158
|
+
const unit = detectIndentationUnit(content) || " ";
|
|
159
|
+
let lsp = lang ? await LSP.client({ view, language: lang, path, fs }) : null;
|
|
160
|
+
safeDispatch(view, {
|
|
161
|
+
changes: { from: 0, to: view.state.doc.length, insert: content },
|
|
162
|
+
effects: [
|
|
163
|
+
indentationCompartment.reconfigure(indentUnit.of(unit)),
|
|
164
|
+
fileLoadedEffect.of({ path, content, language: lang }),
|
|
165
|
+
languageServerCompartment.reconfigure([
|
|
166
|
+
documentUri.of(`file:///${path}`),
|
|
167
|
+
languageId.of(lang || ""),
|
|
168
|
+
...(lsp ? [lsp] : [])
|
|
169
|
+
]),
|
|
170
|
+
]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
console.error("Failed to open file", e);
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
opening = null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// On initial mount, if field indicates a pending load, kick it off *after* construction
|
|
181
|
+
const { path, loading, language } = view.state.field(currentFileField);
|
|
182
|
+
if (!path && language) {
|
|
183
|
+
setLanguageSupport(language);
|
|
184
|
+
}
|
|
185
|
+
if (path && loading) {
|
|
186
|
+
handleOpen(path);
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
update(u) {
|
|
190
|
+
// React to explicit openFileEffect requests
|
|
191
|
+
for (let e of u.transactions.flatMap(t => t.effects)) {
|
|
192
|
+
if (e.is(openFileEffect))
|
|
193
|
+
queueMicrotask(() => handleOpen(e.value.path));
|
|
194
|
+
if (e.is(setThemeEffect)) {
|
|
195
|
+
const dark = e.value.dark;
|
|
196
|
+
u.view.dom.setAttribute('data-theme', dark ? 'dark' : 'light');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Keep read-only in sync with loading state without dispatching new transactions
|
|
200
|
+
const prev = u.startState.field(currentFileField);
|
|
201
|
+
const next = u.state.field(currentFileField);
|
|
202
|
+
if (prev.loading !== next.loading) {
|
|
203
|
+
// Reconfigure readOnly via compartment inside the same update when possible
|
|
204
|
+
safeDispatch(view, { effects: readOnlyCompartment.reconfigure(EditorState.readOnly.of(next.loading)) });
|
|
205
|
+
}
|
|
206
|
+
if (u.docChanged)
|
|
207
|
+
save();
|
|
208
|
+
// If fs changed via facet reconfig, refresh handle references
|
|
209
|
+
const newFs = u.state.facet(CodeblockFacet).fs;
|
|
210
|
+
if (fs !== newFs)
|
|
211
|
+
fs = newFs;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
export const basicSetup = (() => [
|
|
216
|
+
lineNumbers(),
|
|
217
|
+
highlightActiveLineGutter(),
|
|
218
|
+
highlightSpecialChars(),
|
|
219
|
+
history(),
|
|
220
|
+
foldGutter(),
|
|
221
|
+
drawSelection(),
|
|
222
|
+
dropCursor(),
|
|
223
|
+
EditorState.allowMultipleSelections.of(true),
|
|
224
|
+
indentOnInput(),
|
|
225
|
+
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
226
|
+
bracketMatching(),
|
|
227
|
+
closeBrackets(),
|
|
228
|
+
rectangularSelection(),
|
|
229
|
+
crosshairCursor(),
|
|
230
|
+
highlightActiveLine(),
|
|
231
|
+
highlightSelectionMatches(),
|
|
232
|
+
keymap.of([
|
|
233
|
+
...closeBracketsKeymap,
|
|
234
|
+
...defaultKeymap,
|
|
235
|
+
...searchKeymap,
|
|
236
|
+
...historyKeymap,
|
|
237
|
+
...foldKeymap,
|
|
238
|
+
...completionKeymap,
|
|
239
|
+
...lintKeymap
|
|
240
|
+
])
|
|
241
|
+
])();
|
|
242
|
+
export function createCodeblock({ parent, fs, filepath, language, content = '', cwd = '/', toolbar = true, index, dark }) {
|
|
243
|
+
const state = EditorState.create({
|
|
244
|
+
doc: content,
|
|
245
|
+
extensions: [basicSetup, codeblock({ content, fs, filepath, cwd, language, toolbar, index, dark })]
|
|
246
|
+
});
|
|
247
|
+
return new EditorView({ state, parent });
|
|
248
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createCodeblock, codeblock, basicSetup, type CodeblockConfig, CodeblockFacet, setThemeEffect } from "./editor";
|
|
2
|
+
export { Vfs as CodeblockFS } from './utils/fs';
|
|
3
|
+
export * from './utils/snapshot';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './utils/search';
|
|
6
|
+
export * from './lsps';
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>@ezdevlol/codeblock</title>
|
|
8
|
+
<link rel="stylesheet" href="styles.css">
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-C3BnE2cG.js"></script>
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
<body>
|
|
13
|
+
<div id="editor"></div>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createCodeblock, codeblock, basicSetup, CodeblockFacet, setThemeEffect } from "./editor";
|
|
2
|
+
export { Vfs as CodeblockFS } from './utils/fs';
|
|
3
|
+
export * from './utils/snapshot';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './utils/search';
|
|
6
|
+
export * from './lsps';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { LanguageSupport } from '@codemirror/language';
|
|
2
|
+
import { StreamLanguage } from '@codemirror/language';
|
|
3
|
+
declare const languageSupportMap: {
|
|
4
|
+
javascript: () => Promise<LanguageSupport>;
|
|
5
|
+
python: () => Promise<LanguageSupport>;
|
|
6
|
+
rust: () => Promise<LanguageSupport>;
|
|
7
|
+
html: () => Promise<LanguageSupport>;
|
|
8
|
+
css: () => Promise<LanguageSupport>;
|
|
9
|
+
scss: () => Promise<LanguageSupport>;
|
|
10
|
+
less: () => Promise<LanguageSupport>;
|
|
11
|
+
json: () => Promise<LanguageSupport>;
|
|
12
|
+
xml: () => Promise<LanguageSupport>;
|
|
13
|
+
markdown: () => Promise<LanguageSupport>;
|
|
14
|
+
sql: () => Promise<LanguageSupport>;
|
|
15
|
+
php: () => Promise<LanguageSupport>;
|
|
16
|
+
java: () => Promise<LanguageSupport>;
|
|
17
|
+
cpp: () => Promise<LanguageSupport>;
|
|
18
|
+
c: () => Promise<LanguageSupport>;
|
|
19
|
+
yaml: () => Promise<LanguageSupport>;
|
|
20
|
+
ruby: () => Promise<StreamLanguage<unknown>>;
|
|
21
|
+
csharp: () => Promise<StreamLanguage<unknown>>;
|
|
22
|
+
go: () => Promise<StreamLanguage<unknown>>;
|
|
23
|
+
swift: () => Promise<StreamLanguage<unknown>>;
|
|
24
|
+
kotlin: () => Promise<StreamLanguage<unknown>>;
|
|
25
|
+
scala: () => Promise<StreamLanguage<unknown>>;
|
|
26
|
+
vb: () => Promise<StreamLanguage<unknown>>;
|
|
27
|
+
haskell: () => Promise<StreamLanguage<unknown>>;
|
|
28
|
+
lua: () => Promise<StreamLanguage<unknown>>;
|
|
29
|
+
perl: () => Promise<StreamLanguage<unknown>>;
|
|
30
|
+
bash: () => Promise<StreamLanguage<unknown>>;
|
|
31
|
+
toml: () => Promise<StreamLanguage<unknown>>;
|
|
32
|
+
ini: () => Promise<StreamLanguage<unknown>>;
|
|
33
|
+
dockerfile: () => Promise<StreamLanguage<unknown>>;
|
|
34
|
+
makefile: () => Promise<StreamLanguage<unknown>>;
|
|
35
|
+
gitignore: () => Promise<StreamLanguage<unknown>>;
|
|
36
|
+
};
|
|
37
|
+
export declare const getLanguageSupport: (language: keyof typeof languageSupportMap) => Promise<LanguageSupport | StreamLanguage<any>>;
|
|
38
|
+
export type SupportedLanguage = keyof typeof languageSupportMap;
|
|
39
|
+
export declare const extOrLanguageToLanguageId: {
|
|
40
|
+
readonly javascript: "javascript";
|
|
41
|
+
readonly js: "javascript";
|
|
42
|
+
readonly typescript: "javascript";
|
|
43
|
+
readonly ts: "javascript";
|
|
44
|
+
readonly jsx: "javascript";
|
|
45
|
+
readonly tsx: "javascript";
|
|
46
|
+
readonly python: "python";
|
|
47
|
+
readonly py: "python";
|
|
48
|
+
readonly ruby: "ruby";
|
|
49
|
+
readonly rb: "ruby";
|
|
50
|
+
readonly php: "php";
|
|
51
|
+
readonly java: "java";
|
|
52
|
+
readonly cpp: "cpp";
|
|
53
|
+
readonly c: "c";
|
|
54
|
+
readonly csharp: "csharp";
|
|
55
|
+
readonly cs: "csharp";
|
|
56
|
+
readonly go: "go";
|
|
57
|
+
readonly swift: "swift";
|
|
58
|
+
readonly kotlin: "kotlin";
|
|
59
|
+
readonly kt: "kotlin";
|
|
60
|
+
readonly rust: "rust";
|
|
61
|
+
readonly rs: "rust";
|
|
62
|
+
readonly scala: "scala";
|
|
63
|
+
readonly vb: "vb";
|
|
64
|
+
readonly haskell: "haskell";
|
|
65
|
+
readonly hs: "haskell";
|
|
66
|
+
readonly lua: "lua";
|
|
67
|
+
readonly perl: "perl";
|
|
68
|
+
readonly pl: "perl";
|
|
69
|
+
readonly bash: "bash";
|
|
70
|
+
readonly shell: "bash";
|
|
71
|
+
readonly sh: "bash";
|
|
72
|
+
readonly zsh: "bash";
|
|
73
|
+
readonly mysql: "sql";
|
|
74
|
+
readonly sql: "sql";
|
|
75
|
+
readonly html: "html";
|
|
76
|
+
readonly css: "css";
|
|
77
|
+
readonly scss: "scss";
|
|
78
|
+
readonly less: "less";
|
|
79
|
+
readonly json: "json";
|
|
80
|
+
readonly yaml: "yaml";
|
|
81
|
+
readonly yml: "yaml";
|
|
82
|
+
readonly xml: "xml";
|
|
83
|
+
readonly markdown: "markdown";
|
|
84
|
+
readonly md: "markdown";
|
|
85
|
+
readonly toml: "toml";
|
|
86
|
+
readonly ini: "ini";
|
|
87
|
+
readonly conf: "ini";
|
|
88
|
+
readonly log: "ini";
|
|
89
|
+
readonly env: "ini";
|
|
90
|
+
readonly dockerfile: "dockerfile";
|
|
91
|
+
readonly makefile: "makefile";
|
|
92
|
+
readonly dockerignore: "gitignore";
|
|
93
|
+
readonly gitignore: "gitignore";
|
|
94
|
+
};
|
|
95
|
+
export type ExtensionOrLanguage = keyof typeof extOrLanguageToLanguageId;
|
|
96
|
+
export {};
|