vzcode 0.40.0 → 0.42.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.
@@ -234,4 +234,4 @@ ${M.join(`
234
234
  `;P=P.replace(n,"").replace(r,"").replace(v,"$1");let E="";for(;E!==P;)E=P,P=P.replace(_,`${m}$1 $2${m}`);P=P.replace(u,"").trimRight();let R=Object.create(null),q=P.replace(f,"").replace(u,"").trimRight(),j;for(;j=f.exec(P);){let $=j[2].replace(o,"");typeof R[j[1]]=="string"||Array.isArray(R[j[1]])?R[j[1]]=g.concat(R[j[1]],$):R[j[1]]=$}return{comments:q,pragmas:R}}function C({comments:P="",pragmas:m={}}){let E=`
235
235
  `,R="/**",q=" *",j=" */",$=Object.keys(m),V=$.flatMap(X=>N(X,m[X])).map(X=>`${q} ${X}${E}`).join("");if(!P){if($.length===0)return"";if($.length===1&&!Array.isArray(m[$[0]])){let X=m[$[0]];return`${R} ${N($[0],X)[0]}${j}`}}let U=P.split(E).map(X=>`${q} ${X}`).join(E)+E;return R+E+(P?U:"")+(P&&$.length?q+E:"")+V+j}function N(P,m){return g.concat(m).map(E=>`@${P} ${E}`.trim())}}),eN={};ZT(eN,{parsers:()=>iC});var iC={};ZT(iC,{typescript:()=>$oe});var aoe=WP(noe(),1);function soe(t,r){let n=new SyntaxError(t+" ("+r.loc.start.line+":"+r.loc.start.column+")");return Object.assign(n,r)}var ooe=soe;function uoe(t){let r=[];for(let n of t)try{return n()}catch(a){r.push(a)}throw Object.assign(new Error("All combinations failed"),{errors:r})}var loe=uoe,tN=WP(ioe(),1);function coe(t){if(!t.startsWith("#!"))return"";let r=t.indexOf(`
236
236
  `);return r===-1?t:t.slice(0,r)}var _oe=coe;function poe(t){let r=_oe(t);r&&(t=t.slice(r.length+1));let n=(0,tN.extract)(t),{pragmas:a,comments:o}=(0,tN.parseWithComments)(n);return{shebang:r,text:t,pragmas:a,comments:o}}function doe(t){let{pragmas:r}=poe(t);return Object.prototype.hasOwnProperty.call(r,"prettier")||Object.prototype.hasOwnProperty.call(r,"format")}function foe(t){return Array.isArray(t)&&t.length>0}var rN=foe;function _o(t){var r;let n=t.range?t.range[0]:t.start,a=((r=t.declaration)==null?void 0:r.decorators)??t.decorators;return rN(a)?Math.min(_o(a[0]),n):n}function nc(t){return t.range?t.range[1]:t.end}function moe(t){return t=typeof t=="function"?{parse:t}:t,{astFormat:"estree",hasPragma:doe,locStart:_o,locEnd:nc,...t}}var hoe=moe;function yoe(t){return t.charAt(0)==="#"&&t.charAt(1)==="!"?"//"+t.slice(2):t}var goe=yoe,Doe=(t,r,n)=>{if(!(t&&r==null))return Array.isArray(r)||typeof r=="string"?r[n<0?r.length+n:n]:r.at(n)},nN=Doe;function boe(t){return t=new Set(t),r=>t.has(r==null?void 0:r.type)}var xoe=boe,voe=xoe(["Block","CommentBlock","MultiLine"]),aC=voe;function Toe(t){return aC(t)&&t.value[0]==="*"&&/@(?:type|satisfies)\b/.test(t.value)}var Coe=Toe;function Soe(t){let r=`*${t.value}*`.split(`
237
- `);return r.length>1&&r.every(n=>n.trimStart()[0]==="*")}var iN=Soe,Th=null;function Ch(t){if(Th!==null&&typeof Th.property){let r=Th;return Th=Ch.prototype=null,r}return Th=Ch.prototype=t??Object.create(null),new Ch}var Aoe=10;for(let t=0;t<=Aoe;t++)Ch();function Eoe(t){return Ch(t)}function woe(t,r="type"){Eoe(t);function n(a){let o=a[r],u=t[o];if(!Array.isArray(u))throw Object.assign(new Error(`Missing visitor keys for '${o}'.`),{node:a});return u}return n}var Foe=woe,koe={ArrayExpression:["elements"],AssignmentExpression:["left","right"],BinaryExpression:["left","right"],InterpreterDirective:[],Directive:["value"],DirectiveLiteral:[],BlockStatement:["directives","body"],BreakStatement:["label"],CallExpression:["callee","arguments","typeParameters","typeArguments"],CatchClause:["param","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DoWhileStatement:["test","body"],EmptyStatement:[],ExpressionStatement:["expression"],File:["program"],ForInStatement:["left","right","body"],ForStatement:["init","test","update","body"],FunctionDeclaration:["id","params","body","returnType","typeParameters","predicate"],FunctionExpression:["id","params","body","returnType","typeParameters"],Identifier:["typeAnnotation","decorators"],IfStatement:["test","consequent","alternate"],LabeledStatement:["label","body"],StringLiteral:[],NumericLiteral:[],NullLiteral:[],BooleanLiteral:[],RegExpLiteral:[],LogicalExpression:["left","right"],MemberExpression:["object","property"],NewExpression:["callee","arguments","typeParameters","typeArguments"],Program:["directives","body"],ObjectExpression:["properties"],ObjectMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectProperty:["key","value","decorators"],RestElement:["argument","typeAnnotation","decorators"],ReturnStatement:["argument"],SequenceExpression:["expressions"],ParenthesizedExpression:["expression"],SwitchCase:["test","consequent"],SwitchStatement:["discriminant","cases"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],AssignmentPattern:["left","right","decorators","typeAnnotation"],ArrayPattern:["elements","typeAnnotation","decorators"],ArrowFunctionExpression:["params","body","returnType","typeParameters","predicate"],ClassBody:["body"],ClassExpression:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ClassDeclaration:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ExportAllDeclaration:["source","attributes","assertions","exported"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source","attributes","assertions"],ExportSpecifier:["local","exported"],ForOfStatement:["left","right","body"],ImportDeclaration:["specifiers","source","attributes","assertions"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["local","imported"],ImportExpression:["source","options","attributes"],MetaProperty:["meta","property"],ClassMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectPattern:["properties","typeAnnotation","decorators"],SpreadElement:["argument"],Super:[],TaggedTemplateExpression:["tag","quasi","typeParameters","typeArguments"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],YieldExpression:["argument"],AwaitExpression:["argument"],Import:[],BigIntLiteral:[],ExportNamespaceSpecifier:["exported"],OptionalMemberExpression:["object","property"],OptionalCallExpression:["callee","arguments","typeParameters","typeArguments"],ClassProperty:["key","value","typeAnnotation","decorators","variance"],ClassAccessorProperty:["key","value","typeAnnotation","decorators"],ClassPrivateProperty:["key","value","decorators","typeAnnotation","variance"],ClassPrivateMethod:["key","params","body","decorators","returnType","typeParameters"],PrivateName:["id"],StaticBlock:["body"],AnyTypeAnnotation:[],ArrayTypeAnnotation:["elementType"],BooleanTypeAnnotation:[],BooleanLiteralTypeAnnotation:[],NullLiteralTypeAnnotation:[],ClassImplements:["id","typeParameters"],DeclareClass:["id","typeParameters","extends","mixins","implements","body"],DeclareFunction:["id","predicate"],DeclareInterface:["id","typeParameters","extends","body"],DeclareModule:["id","body"],DeclareModuleExports:["typeAnnotation"],DeclareTypeAlias:["id","typeParameters","right"],DeclareOpaqueType:["id","typeParameters","supertype"],DeclareVariable:["id"],DeclareExportDeclaration:["declaration","specifiers","source"],DeclareExportAllDeclaration:["source"],DeclaredPredicate:["value"],ExistsTypeAnnotation:[],FunctionTypeAnnotation:["typeParameters","params","rest","returnType","this"],FunctionTypeParam:["name","typeAnnotation"],GenericTypeAnnotation:["id","typeParameters"],InferredPredicate:[],InterfaceExtends:["id","typeParameters"],InterfaceDeclaration:["id","typeParameters","extends","body"],InterfaceTypeAnnotation:["extends","body"],IntersectionTypeAnnotation:["types"],MixedTypeAnnotation:[],EmptyTypeAnnotation:[],NullableTypeAnnotation:["typeAnnotation"],NumberLiteralTypeAnnotation:[],NumberTypeAnnotation:[],ObjectTypeAnnotation:["properties","indexers","callProperties","internalSlots"],ObjectTypeInternalSlot:["id","value","optional","static","method"],ObjectTypeCallProperty:["value"],ObjectTypeIndexer:["id","key","value","variance"],ObjectTypeProperty:["key","value","variance"],ObjectTypeSpreadProperty:["argument"],OpaqueType:["id","typeParameters","supertype","impltype"],QualifiedTypeIdentifier:["id","qualification"],StringLiteralTypeAnnotation:[],StringTypeAnnotation:[],SymbolTypeAnnotation:[],ThisTypeAnnotation:[],TupleTypeAnnotation:["types","elementTypes"],TypeofTypeAnnotation:["argument","typeArguments"],TypeAlias:["id","typeParameters","right"],TypeAnnotation:["typeAnnotation"],TypeCastExpression:["expression","typeAnnotation"],TypeParameter:["bound","default","variance"],TypeParameterDeclaration:["params"],TypeParameterInstantiation:["params"],UnionTypeAnnotation:["types"],Variance:[],VoidTypeAnnotation:[],EnumDeclaration:["id","body"],EnumBooleanBody:["members"],EnumNumberBody:["members"],EnumStringBody:["members"],EnumSymbolBody:["members"],EnumBooleanMember:["id","init"],EnumNumberMember:["id","init"],EnumStringMember:["id","init"],EnumDefaultedMember:["id"],IndexedAccessType:["objectType","indexType"],OptionalIndexedAccessType:["objectType","indexType"],JSXAttribute:["name","value"],JSXClosingElement:["name"],JSXElement:["openingElement","children","closingElement"],JSXEmptyExpression:[],JSXExpressionContainer:["expression"],JSXSpreadChild:["expression"],JSXIdentifier:[],JSXMemberExpression:["object","property"],JSXNamespacedName:["namespace","name"],JSXOpeningElement:["name","attributes","typeArguments","typeParameters"],JSXSpreadAttribute:["argument"],JSXText:[],JSXFragment:["openingFragment","children","closingFragment"],JSXOpeningFragment:[],JSXClosingFragment:[],Noop:[],Placeholder:[],V8IntrinsicIdentifier:[],ArgumentPlaceholder:[],BindExpression:["object","callee"],ImportAttribute:["key","value"],Decorator:["expression"],DoExpression:["body"],ExportDefaultSpecifier:["exported"],RecordExpression:["properties"],TupleExpression:["elements"],DecimalLiteral:[],ModuleExpression:["body"],TopicReference:[],PipelineTopicExpression:["expression"],PipelineBareFunction:["callee"],PipelinePrimaryTopicReference:[],TSParameterProperty:["parameter","decorators"],TSDeclareFunction:["id","typeParameters","params","returnType","body"],TSDeclareMethod:["decorators","key","typeParameters","params","returnType"],TSQualifiedName:["left","right"],TSCallSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSPropertySignature:["key","typeAnnotation"],TSMethodSignature:["key","typeParameters","parameters","typeAnnotation","params","returnType"],TSIndexSignature:["parameters","typeAnnotation"],TSAnyKeyword:[],TSBooleanKeyword:[],TSBigIntKeyword:[],TSIntrinsicKeyword:[],TSNeverKeyword:[],TSNullKeyword:[],TSNumberKeyword:[],TSObjectKeyword:[],TSStringKeyword:[],TSSymbolKeyword:[],TSUndefinedKeyword:[],TSUnknownKeyword:[],TSVoidKeyword:[],TSThisType:[],TSFunctionType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructorType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSTypeReference:["typeName","typeParameters","typeArguments"],TSTypePredicate:["parameterName","typeAnnotation"],TSTypeQuery:["exprName","typeParameters","typeArguments"],TSTypeLiteral:["members"],TSArrayType:["elementType"],TSTupleType:["elementTypes"],TSOptionalType:["typeAnnotation"],TSRestType:["typeAnnotation"],TSNamedTupleMember:["label","elementType"],TSUnionType:["types"],TSIntersectionType:["types"],TSConditionalType:["checkType","extendsType","trueType","falseType"],TSInferType:["typeParameter"],TSParenthesizedType:["typeAnnotation"],TSTypeOperator:["typeAnnotation"],TSIndexedAccessType:["objectType","indexType"],TSMappedType:["typeParameter","typeAnnotation","nameType"],TSLiteralType:["literal"],TSExpressionWithTypeArguments:["expression","typeParameters"],TSInterfaceDeclaration:["id","typeParameters","extends","body"],TSInterfaceBody:["body"],TSTypeAliasDeclaration:["id","typeParameters","typeAnnotation"],TSInstantiationExpression:["expression","typeParameters","typeArguments"],TSAsExpression:["expression","typeAnnotation"],TSSatisfiesExpression:["expression","typeAnnotation"],TSTypeAssertion:["typeAnnotation","expression"],TSEnumDeclaration:["id","members"],TSEnumMember:["id","initializer"],TSModuleDeclaration:["id","body"],TSModuleBlock:["body"],TSImportType:["argument","qualifier","typeParameters","typeArguments"],TSImportEqualsDeclaration:["id","moduleReference"],TSExternalModuleReference:["expression"],TSNonNullExpression:["expression"],TSExportAssignment:["expression"],TSNamespaceExportDeclaration:["id"],TSTypeAnnotation:["typeAnnotation"],TSTypeParameterInstantiation:["params"],TSTypeParameterDeclaration:["params"],TSTypeParameter:["constraint","default","name"],ChainExpression:["expression"],ExperimentalRestProperty:["argument"],ExperimentalSpreadProperty:["argument"],Literal:[],MethodDefinition:["decorators","key","value"],PrivateIdentifier:[],Property:["key","value"],PropertyDefinition:["decorators","key","typeAnnotation","value","variance"],AccessorProperty:["decorators","key","typeAnnotation","value"],TSAbstractAccessorProperty:["decorators","key","typeAnnotation"],TSAbstractKeyword:[],TSAbstractMethodDefinition:["key","value"],TSAbstractPropertyDefinition:["decorators","key","typeAnnotation"],TSAsyncKeyword:[],TSClassImplements:["expression","typeArguments","typeParameters"],TSDeclareKeyword:[],TSEmptyBodyFunctionExpression:["id","typeParameters","params","returnType"],TSExportKeyword:[],TSInterfaceHeritage:["expression","typeArguments","typeParameters"],TSPrivateKeyword:[],TSProtectedKeyword:[],TSPublicKeyword:[],TSReadonlyKeyword:[],TSStaticKeyword:[],TSTemplateLiteralType:["quasis","types"],AsExpression:["expression","typeAnnotation"],BigIntLiteralTypeAnnotation:[],BigIntTypeAnnotation:[],ConditionalTypeAnnotation:["checkType","extendsType","trueType","falseType"],DeclareEnum:["id","body"],InferTypeAnnotation:["typeParameter"],KeyofTypeAnnotation:["argument"],ObjectTypeMappedTypeProperty:["keyTparam","propType","sourceType","variance"],QualifiedTypeofIdentifier:["qualification","id"],TupleTypeLabeledElement:["label","elementType","variance"],TupleTypeSpreadElement:["label","typeAnnotation"],TypeOperator:["typeAnnotation"],TypePredicate:["parameterName","typeAnnotation","asserts"],NGRoot:["node"],NGPipeExpression:["left","right","arguments"],NGChainedExpression:["expressions"],NGEmptyExpression:[],NGMicrosyntax:["body"],NGMicrosyntaxKey:[],NGMicrosyntaxExpression:["expression","alias"],NGMicrosyntaxKeyedExpression:["key","expression"],NGMicrosyntaxLet:["key","value"],NGMicrosyntaxAs:["key","alias"],JsExpressionRoot:["node"],JsonRoot:["node"],TSJSDocAllType:[],TSJSDocUnknownType:[],TSJSDocNullableType:["typeAnnotation"],TSJSDocNonNullableType:["typeAnnotation"],NeverTypeAnnotation:[],UndefinedTypeAnnotation:[],UnknownTypeAnnotation:[],AsConstExpression:["expression"],SatisfiesExpression:["expression","typeAnnotation"]},Poe=Foe(koe),Noe=Poe;function sC(t,r){if(!(t!==null&&typeof t=="object"))return t;if(Array.isArray(t)){for(let a=0;a<t.length;a++)t[a]=sC(t[a],r);return t}let n=Noe(t);for(let a=0;a<n.length;a++)t[n[a]]=sC(t[n[a]],r);return r(t)||t}var oC=sC;function Ioe(t,r){let{parser:n,text:a}=r;if(t.type==="File"&&t.program.interpreter){let{program:{interpreter:u},comments:_}=t;delete t.program.interpreter,_.unshift(u)}if(n==="babel"){let u=new Set;t=oC(t,_=>{var f;(f=_.leadingComments)!=null&&f.some(Coe)&&u.add(_o(_))}),t=oC(t,_=>{if(_.type==="ParenthesizedExpression"){let{expression:f}=_;if(f.type==="TypeCastExpression")return f.range=_.range,f;let v=_o(_);if(!u.has(v))return f.extra={...f.extra,parenthesized:!0},f}})}if(t=oC(t,u=>{switch(u.type){case"LogicalExpression":if(aN(u))return uC(u);break;case"VariableDeclaration":{let _=nN(!1,u.declarations,-1);_!=null&&_.init&&o(u,_);break}case"TSParenthesizedType":return u.typeAnnotation;case"TSTypeParameter":if(typeof u.name=="string"){let _=_o(u);u.name={type:"Identifier",name:u.name,range:[_,_+u.name.length]}}break;case"TopicReference":t.extra={...t.extra,__isUsingHackPipeline:!0};break;case"ExportAllDeclaration":{let{exported:_}=u;if(n==="meriyah"&&(_==null?void 0:_.type)==="Identifier"){let f=a.slice(_o(_),nc(_));(f.startsWith('"')||f.startsWith("'"))&&(u.exported={...u.exported,type:"Literal",value:u.exported.name,raw:f})}break}case"TSUnionType":case"TSIntersectionType":if(u.types.length===1)return u.types[0];break}}),rN(t.comments)){let u=nN(!1,t.comments,-1);for(let _=t.comments.length-2;_>=0;_--){let f=t.comments[_];nc(f)===_o(u)&&aC(f)&&aC(u)&&iN(f)&&iN(u)&&(t.comments.splice(_+1,1),f.value+="*//*"+u.value,f.range=[_o(f),nc(u)]),u=f}}return t.type==="Program"&&(t.range=[0,a.length]),t;function o(u,_){a[nc(_)]!==";"&&(u.range=[_o(u),nc(_)])}}function aN(t){return t.type==="LogicalExpression"&&t.right.type==="LogicalExpression"&&t.operator===t.right.operator}function uC(t){return aN(t)?uC({type:"LogicalExpression",operator:t.operator,left:uC({type:"LogicalExpression",operator:t.operator,left:t.left,right:t.right.left,range:[_o(t.left),nc(t.right.left)]}),right:t.right.right,range:[_o(t),nc(t)]}):t}var Boe=Ioe,lC={loc:!0,range:!0,comment:!0,tokens:!0,loggerFn:!1,project:[],suppressDeprecatedPropertyWarnings:!0};function Ooe(t){let{message:r,location:n}=t;if(!n)return t;let{start:a,end:o}=n;return ooe(r,{loc:{start:{line:a.line,column:a.column+1},end:{line:o.line,column:o.column+1}},cause:t})}var Loe=t=>/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(t);function Moe(t,r){let n=r==null?void 0:r.filepath;if(n&&Loe(n))return[{...lC,filePath:n}];let a=Roe(t);return[{...lC,jsx:a},{...lC,jsx:!a}]}function joe(t,r){let n=goe(t),a=Moe(t,r),o;try{o=loe(a.map(u=>()=>(0,aoe.parse)(n,u)))}catch({errors:[u]}){throw Ooe(u)}return Boe(o,{text:t})}function Roe(t){return new RegExp(["(?:^[^\"'`]*</)","|","(?:^[^/]{2}.*/>)"].join(""),"m").test(t)}var $oe=hoe(joe),Joe=eN,qoe=Object.freeze({__proto__:null,default:Joe,parsers:iC});const Uoe={js:"babel",jsx:"babel",mjs:"babel",cjs:"babel",ts:"typescript",tsx:"typescript",css:"css",html:"html",json:"json",json5:"json5",md:"markdown",markdown:"markdown"},zoe=[OU,vG,dZ,Vre,qoe,wse];onmessage=async({data:t})=>{const{fileExtension:r,fileText:n,fileId:a}=t,o=Uoe[r];if(!o){postMessage({fileId:a,error:`Unsupported file extension for Prettier: ${r}`});return}try{const u=await gv(n,{parser:o,plugins:zoe});postMessage({fileId:a,fileTextPrettified:u})}catch(u){postMessage({fileId:a,error:u.toString()})}}})();
237
+ `);return r.length>1&&r.every(n=>n.trimStart()[0]==="*")}var iN=Soe,Th=null;function Ch(t){if(Th!==null&&typeof Th.property){let r=Th;return Th=Ch.prototype=null,r}return Th=Ch.prototype=t??Object.create(null),new Ch}var Aoe=10;for(let t=0;t<=Aoe;t++)Ch();function Eoe(t){return Ch(t)}function woe(t,r="type"){Eoe(t);function n(a){let o=a[r],u=t[o];if(!Array.isArray(u))throw Object.assign(new Error(`Missing visitor keys for '${o}'.`),{node:a});return u}return n}var Foe=woe,koe={ArrayExpression:["elements"],AssignmentExpression:["left","right"],BinaryExpression:["left","right"],InterpreterDirective:[],Directive:["value"],DirectiveLiteral:[],BlockStatement:["directives","body"],BreakStatement:["label"],CallExpression:["callee","arguments","typeParameters","typeArguments"],CatchClause:["param","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DoWhileStatement:["test","body"],EmptyStatement:[],ExpressionStatement:["expression"],File:["program"],ForInStatement:["left","right","body"],ForStatement:["init","test","update","body"],FunctionDeclaration:["id","params","body","returnType","typeParameters","predicate"],FunctionExpression:["id","params","body","returnType","typeParameters"],Identifier:["typeAnnotation","decorators"],IfStatement:["test","consequent","alternate"],LabeledStatement:["label","body"],StringLiteral:[],NumericLiteral:[],NullLiteral:[],BooleanLiteral:[],RegExpLiteral:[],LogicalExpression:["left","right"],MemberExpression:["object","property"],NewExpression:["callee","arguments","typeParameters","typeArguments"],Program:["directives","body"],ObjectExpression:["properties"],ObjectMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectProperty:["key","value","decorators"],RestElement:["argument","typeAnnotation","decorators"],ReturnStatement:["argument"],SequenceExpression:["expressions"],ParenthesizedExpression:["expression"],SwitchCase:["test","consequent"],SwitchStatement:["discriminant","cases"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],AssignmentPattern:["left","right","decorators","typeAnnotation"],ArrayPattern:["elements","typeAnnotation","decorators"],ArrowFunctionExpression:["params","body","returnType","typeParameters","predicate"],ClassBody:["body"],ClassExpression:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ClassDeclaration:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ExportAllDeclaration:["source","attributes","assertions","exported"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source","attributes","assertions"],ExportSpecifier:["local","exported"],ForOfStatement:["left","right","body"],ImportDeclaration:["specifiers","source","attributes","assertions"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["local","imported"],ImportExpression:["source","options","attributes"],MetaProperty:["meta","property"],ClassMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectPattern:["properties","typeAnnotation","decorators"],SpreadElement:["argument"],Super:[],TaggedTemplateExpression:["tag","quasi","typeParameters","typeArguments"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],YieldExpression:["argument"],AwaitExpression:["argument"],Import:[],BigIntLiteral:[],ExportNamespaceSpecifier:["exported"],OptionalMemberExpression:["object","property"],OptionalCallExpression:["callee","arguments","typeParameters","typeArguments"],ClassProperty:["key","value","typeAnnotation","decorators","variance"],ClassAccessorProperty:["key","value","typeAnnotation","decorators"],ClassPrivateProperty:["key","value","decorators","typeAnnotation","variance"],ClassPrivateMethod:["key","params","body","decorators","returnType","typeParameters"],PrivateName:["id"],StaticBlock:["body"],AnyTypeAnnotation:[],ArrayTypeAnnotation:["elementType"],BooleanTypeAnnotation:[],BooleanLiteralTypeAnnotation:[],NullLiteralTypeAnnotation:[],ClassImplements:["id","typeParameters"],DeclareClass:["id","typeParameters","extends","mixins","implements","body"],DeclareFunction:["id","predicate"],DeclareInterface:["id","typeParameters","extends","body"],DeclareModule:["id","body"],DeclareModuleExports:["typeAnnotation"],DeclareTypeAlias:["id","typeParameters","right"],DeclareOpaqueType:["id","typeParameters","supertype"],DeclareVariable:["id"],DeclareExportDeclaration:["declaration","specifiers","source"],DeclareExportAllDeclaration:["source"],DeclaredPredicate:["value"],ExistsTypeAnnotation:[],FunctionTypeAnnotation:["typeParameters","params","rest","returnType","this"],FunctionTypeParam:["name","typeAnnotation"],GenericTypeAnnotation:["id","typeParameters"],InferredPredicate:[],InterfaceExtends:["id","typeParameters"],InterfaceDeclaration:["id","typeParameters","extends","body"],InterfaceTypeAnnotation:["extends","body"],IntersectionTypeAnnotation:["types"],MixedTypeAnnotation:[],EmptyTypeAnnotation:[],NullableTypeAnnotation:["typeAnnotation"],NumberLiteralTypeAnnotation:[],NumberTypeAnnotation:[],ObjectTypeAnnotation:["properties","indexers","callProperties","internalSlots"],ObjectTypeInternalSlot:["id","value","optional","static","method"],ObjectTypeCallProperty:["value"],ObjectTypeIndexer:["id","key","value","variance"],ObjectTypeProperty:["key","value","variance"],ObjectTypeSpreadProperty:["argument"],OpaqueType:["id","typeParameters","supertype","impltype"],QualifiedTypeIdentifier:["id","qualification"],StringLiteralTypeAnnotation:[],StringTypeAnnotation:[],SymbolTypeAnnotation:[],ThisTypeAnnotation:[],TupleTypeAnnotation:["types","elementTypes"],TypeofTypeAnnotation:["argument","typeArguments"],TypeAlias:["id","typeParameters","right"],TypeAnnotation:["typeAnnotation"],TypeCastExpression:["expression","typeAnnotation"],TypeParameter:["bound","default","variance"],TypeParameterDeclaration:["params"],TypeParameterInstantiation:["params"],UnionTypeAnnotation:["types"],Variance:[],VoidTypeAnnotation:[],EnumDeclaration:["id","body"],EnumBooleanBody:["members"],EnumNumberBody:["members"],EnumStringBody:["members"],EnumSymbolBody:["members"],EnumBooleanMember:["id","init"],EnumNumberMember:["id","init"],EnumStringMember:["id","init"],EnumDefaultedMember:["id"],IndexedAccessType:["objectType","indexType"],OptionalIndexedAccessType:["objectType","indexType"],JSXAttribute:["name","value"],JSXClosingElement:["name"],JSXElement:["openingElement","children","closingElement"],JSXEmptyExpression:[],JSXExpressionContainer:["expression"],JSXSpreadChild:["expression"],JSXIdentifier:[],JSXMemberExpression:["object","property"],JSXNamespacedName:["namespace","name"],JSXOpeningElement:["name","attributes","typeArguments","typeParameters"],JSXSpreadAttribute:["argument"],JSXText:[],JSXFragment:["openingFragment","children","closingFragment"],JSXOpeningFragment:[],JSXClosingFragment:[],Noop:[],Placeholder:[],V8IntrinsicIdentifier:[],ArgumentPlaceholder:[],BindExpression:["object","callee"],ImportAttribute:["key","value"],Decorator:["expression"],DoExpression:["body"],ExportDefaultSpecifier:["exported"],RecordExpression:["properties"],TupleExpression:["elements"],DecimalLiteral:[],ModuleExpression:["body"],TopicReference:[],PipelineTopicExpression:["expression"],PipelineBareFunction:["callee"],PipelinePrimaryTopicReference:[],TSParameterProperty:["parameter","decorators"],TSDeclareFunction:["id","typeParameters","params","returnType","body"],TSDeclareMethod:["decorators","key","typeParameters","params","returnType"],TSQualifiedName:["left","right"],TSCallSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSPropertySignature:["key","typeAnnotation"],TSMethodSignature:["key","typeParameters","parameters","typeAnnotation","params","returnType"],TSIndexSignature:["parameters","typeAnnotation"],TSAnyKeyword:[],TSBooleanKeyword:[],TSBigIntKeyword:[],TSIntrinsicKeyword:[],TSNeverKeyword:[],TSNullKeyword:[],TSNumberKeyword:[],TSObjectKeyword:[],TSStringKeyword:[],TSSymbolKeyword:[],TSUndefinedKeyword:[],TSUnknownKeyword:[],TSVoidKeyword:[],TSThisType:[],TSFunctionType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructorType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSTypeReference:["typeName","typeParameters","typeArguments"],TSTypePredicate:["parameterName","typeAnnotation"],TSTypeQuery:["exprName","typeParameters","typeArguments"],TSTypeLiteral:["members"],TSArrayType:["elementType"],TSTupleType:["elementTypes"],TSOptionalType:["typeAnnotation"],TSRestType:["typeAnnotation"],TSNamedTupleMember:["label","elementType"],TSUnionType:["types"],TSIntersectionType:["types"],TSConditionalType:["checkType","extendsType","trueType","falseType"],TSInferType:["typeParameter"],TSParenthesizedType:["typeAnnotation"],TSTypeOperator:["typeAnnotation"],TSIndexedAccessType:["objectType","indexType"],TSMappedType:["typeParameter","typeAnnotation","nameType"],TSLiteralType:["literal"],TSExpressionWithTypeArguments:["expression","typeParameters"],TSInterfaceDeclaration:["id","typeParameters","extends","body"],TSInterfaceBody:["body"],TSTypeAliasDeclaration:["id","typeParameters","typeAnnotation"],TSInstantiationExpression:["expression","typeParameters","typeArguments"],TSAsExpression:["expression","typeAnnotation"],TSSatisfiesExpression:["expression","typeAnnotation"],TSTypeAssertion:["typeAnnotation","expression"],TSEnumDeclaration:["id","members"],TSEnumMember:["id","initializer"],TSModuleDeclaration:["id","body"],TSModuleBlock:["body"],TSImportType:["argument","qualifier","typeParameters","typeArguments"],TSImportEqualsDeclaration:["id","moduleReference"],TSExternalModuleReference:["expression"],TSNonNullExpression:["expression"],TSExportAssignment:["expression"],TSNamespaceExportDeclaration:["id"],TSTypeAnnotation:["typeAnnotation"],TSTypeParameterInstantiation:["params"],TSTypeParameterDeclaration:["params"],TSTypeParameter:["constraint","default","name"],ChainExpression:["expression"],ExperimentalRestProperty:["argument"],ExperimentalSpreadProperty:["argument"],Literal:[],MethodDefinition:["decorators","key","value"],PrivateIdentifier:[],Property:["key","value"],PropertyDefinition:["decorators","key","typeAnnotation","value","variance"],AccessorProperty:["decorators","key","typeAnnotation","value"],TSAbstractAccessorProperty:["decorators","key","typeAnnotation"],TSAbstractKeyword:[],TSAbstractMethodDefinition:["key","value"],TSAbstractPropertyDefinition:["decorators","key","typeAnnotation"],TSAsyncKeyword:[],TSClassImplements:["expression","typeArguments","typeParameters"],TSDeclareKeyword:[],TSEmptyBodyFunctionExpression:["id","typeParameters","params","returnType"],TSExportKeyword:[],TSInterfaceHeritage:["expression","typeArguments","typeParameters"],TSPrivateKeyword:[],TSProtectedKeyword:[],TSPublicKeyword:[],TSReadonlyKeyword:[],TSStaticKeyword:[],TSTemplateLiteralType:["quasis","types"],AsExpression:["expression","typeAnnotation"],BigIntLiteralTypeAnnotation:[],BigIntTypeAnnotation:[],ConditionalTypeAnnotation:["checkType","extendsType","trueType","falseType"],DeclareEnum:["id","body"],InferTypeAnnotation:["typeParameter"],KeyofTypeAnnotation:["argument"],ObjectTypeMappedTypeProperty:["keyTparam","propType","sourceType","variance"],QualifiedTypeofIdentifier:["qualification","id"],TupleTypeLabeledElement:["label","elementType","variance"],TupleTypeSpreadElement:["label","typeAnnotation"],TypeOperator:["typeAnnotation"],TypePredicate:["parameterName","typeAnnotation","asserts"],NGRoot:["node"],NGPipeExpression:["left","right","arguments"],NGChainedExpression:["expressions"],NGEmptyExpression:[],NGMicrosyntax:["body"],NGMicrosyntaxKey:[],NGMicrosyntaxExpression:["expression","alias"],NGMicrosyntaxKeyedExpression:["key","expression"],NGMicrosyntaxLet:["key","value"],NGMicrosyntaxAs:["key","alias"],JsExpressionRoot:["node"],JsonRoot:["node"],TSJSDocAllType:[],TSJSDocUnknownType:[],TSJSDocNullableType:["typeAnnotation"],TSJSDocNonNullableType:["typeAnnotation"],NeverTypeAnnotation:[],UndefinedTypeAnnotation:[],UnknownTypeAnnotation:[],AsConstExpression:["expression"],SatisfiesExpression:["expression","typeAnnotation"]},Poe=Foe(koe),Noe=Poe;function sC(t,r){if(!(t!==null&&typeof t=="object"))return t;if(Array.isArray(t)){for(let a=0;a<t.length;a++)t[a]=sC(t[a],r);return t}let n=Noe(t);for(let a=0;a<n.length;a++)t[n[a]]=sC(t[n[a]],r);return r(t)||t}var oC=sC;function Ioe(t,r){let{parser:n,text:a}=r;if(t.type==="File"&&t.program.interpreter){let{program:{interpreter:u},comments:_}=t;delete t.program.interpreter,_.unshift(u)}if(n==="babel"){let u=new Set;t=oC(t,_=>{var f;(f=_.leadingComments)!=null&&f.some(Coe)&&u.add(_o(_))}),t=oC(t,_=>{if(_.type==="ParenthesizedExpression"){let{expression:f}=_;if(f.type==="TypeCastExpression")return f.range=_.range,f;let v=_o(_);if(!u.has(v))return f.extra={...f.extra,parenthesized:!0},f}})}if(t=oC(t,u=>{switch(u.type){case"LogicalExpression":if(aN(u))return uC(u);break;case"VariableDeclaration":{let _=nN(!1,u.declarations,-1);_!=null&&_.init&&o(u,_);break}case"TSParenthesizedType":return u.typeAnnotation;case"TSTypeParameter":if(typeof u.name=="string"){let _=_o(u);u.name={type:"Identifier",name:u.name,range:[_,_+u.name.length]}}break;case"TopicReference":t.extra={...t.extra,__isUsingHackPipeline:!0};break;case"ExportAllDeclaration":{let{exported:_}=u;if(n==="meriyah"&&(_==null?void 0:_.type)==="Identifier"){let f=a.slice(_o(_),nc(_));(f.startsWith('"')||f.startsWith("'"))&&(u.exported={...u.exported,type:"Literal",value:u.exported.name,raw:f})}break}case"TSUnionType":case"TSIntersectionType":if(u.types.length===1)return u.types[0];break}}),rN(t.comments)){let u=nN(!1,t.comments,-1);for(let _=t.comments.length-2;_>=0;_--){let f=t.comments[_];nc(f)===_o(u)&&aC(f)&&aC(u)&&iN(f)&&iN(u)&&(t.comments.splice(_+1,1),f.value+="*//*"+u.value,f.range=[_o(f),nc(u)]),u=f}}return t.type==="Program"&&(t.range=[0,a.length]),t;function o(u,_){a[nc(_)]!==";"&&(u.range=[_o(u),nc(_)])}}function aN(t){return t.type==="LogicalExpression"&&t.right.type==="LogicalExpression"&&t.operator===t.right.operator}function uC(t){return aN(t)?uC({type:"LogicalExpression",operator:t.operator,left:uC({type:"LogicalExpression",operator:t.operator,left:t.left,right:t.right.left,range:[_o(t.left),nc(t.right.left)]}),right:t.right.right,range:[_o(t),nc(t)]}):t}var Boe=Ioe,lC={loc:!0,range:!0,comment:!0,tokens:!0,loggerFn:!1,project:[],suppressDeprecatedPropertyWarnings:!0};function Ooe(t){let{message:r,location:n}=t;if(!n)return t;let{start:a,end:o}=n;return ooe(r,{loc:{start:{line:a.line,column:a.column+1},end:{line:o.line,column:o.column+1}},cause:t})}var Loe=t=>/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(t);function Moe(t,r){let n=r==null?void 0:r.filepath;if(n&&Loe(n))return[{...lC,filePath:n}];let a=Roe(t);return[{...lC,jsx:a},{...lC,jsx:!a}]}function joe(t,r){let n=goe(t),a=Moe(t,r),o;try{o=loe(a.map(u=>()=>(0,aoe.parse)(n,u)))}catch({errors:[u]}){throw Ooe(u)}return Boe(o,{text:t})}function Roe(t){return new RegExp(["(?:^[^\"'`]*</)","|","(?:^[^/]{2}.*/>)"].join(""),"m").test(t)}var $oe=hoe(joe),Joe=eN,qoe=Object.freeze({__proto__:null,default:Joe,parsers:iC});const Uoe={js:"babel",jsx:"babel",mjs:"babel",cjs:"babel",ts:"typescript",tsx:"typescript",css:"css",html:"html",json:"json",json5:"json5",md:"markdown",markdown:"markdown"},zoe=[OU,vG,dZ,Vre,qoe,wse];onmessage=async({data:t})=>{const{fileExtension:r,fileText:n,fileId:a}=t,o=Uoe[r];if(!o){postMessage({fileId:a,error:`Unsupported file extension for Prettier: ${r}`});return}try{const u=await gv(n,{parser:o,plugins:zoe,proseWrap:"always",singleQuote:!0,printWidth:60});postMessage({fileId:a,fileTextPrettified:u})}catch(u){postMessage({fileId:a,error:u.toString()})}}})();
package/dist/index.html CHANGED
@@ -24,8 +24,8 @@
24
24
  href="https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css"
25
25
  rel="stylesheet"
26
26
  />
27
- <script type="module" crossorigin src="/assets/index-oU3BPloT.js"></script>
28
- <link rel="stylesheet" crossorigin href="/assets/index-ZDmwFqlb.css">
27
+ <script type="module" crossorigin src="/assets/index-EvjpKQwB.js"></script>
28
+ <link rel="stylesheet" crossorigin href="/assets/index-vD_kE3p2.css">
29
29
  </head>
30
30
  <body>
31
31
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "0.40.0",
3
+ "version": "0.42.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -36,8 +36,14 @@
36
36
  "Visualization"
37
37
  ],
38
38
  "contributors": [
39
- "Curran Kelleher",
40
- "Anooj Pai"
39
+ {
40
+ "name": "Curran Kelleher",
41
+ "url": "https://github.com/curran"
42
+ },
43
+ {
44
+ "name": "Anooj Pai",
45
+ "url": "https://github.com/Anooj-Pai"
46
+ }
41
47
  ],
42
48
  "license": "MIT",
43
49
  "bugs": {
@@ -51,11 +57,14 @@
51
57
  "@codemirror/lang-javascript": "^6.2.1",
52
58
  "@codemirror/lang-json": "^6.0.1",
53
59
  "@codemirror/lang-markdown": "^6.2.3",
54
- "@codemirror/state": "^6.3.2",
60
+ "@codemirror/state": "^6.3.3",
55
61
  "@codemirror/theme-one-dark": "^6.1.2",
56
62
  "@codemirror/view": "^6.22.1",
57
63
  "@lezer/highlight": "^1.2.0",
64
+ "@replit/codemirror-indentation-markers": "^6.5.0",
58
65
  "@replit/codemirror-interact": "^6.3.0",
66
+ "@replit/codemirror-minimap": "^0.5.1",
67
+ "@replit/codemirror-vscode-keymap": "^6.0.2",
59
68
  "@teamwork/websocket-json-stream": "^2.0.0",
60
69
  "@typescript/vfs": "^1.5.0",
61
70
  "@uiw/codemirror-theme-abcdef": "^4.21.21",
@@ -82,19 +91,19 @@
82
91
  "react": "^18.2.0",
83
92
  "react-bootstrap": "^2.9.1",
84
93
  "react-dom": "^18.2.0",
85
- "sharedb": "^4.1.1",
94
+ "sharedb": "^4.1.2",
86
95
  "sharedb-client-browser": "^4.4.0",
87
- "vizhub-ui": "^3.8.0",
96
+ "vizhub-ui": "^3.10.0",
88
97
  "ws": "^8.14.2"
89
98
  },
90
99
  "devDependencies": {
91
- "@types/react": "^18.2.41",
100
+ "@types/react": "^18.2.42",
92
101
  "@types/react-dom": "^18.2.17",
93
- "@vitejs/plugin-react": "^4.2.0",
102
+ "@vitejs/plugin-react": "^4.2.1",
94
103
  "prettier": "^3.1.0",
95
104
  "sass": "^1.69.5",
96
- "typescript": "^5.3.2",
97
- "vite": "^5.0.4",
98
- "vitest": "^0.34.6"
105
+ "typescript": "^5.3.3",
106
+ "vite": "^5.0.6",
107
+ "vitest": "^1.0.1"
99
108
  }
100
109
  }
@@ -2,7 +2,7 @@
2
2
  // --vzcode-font-family: ui-monospace, SFMono-Regular,
3
3
  // 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace !important;
4
4
 
5
- --vzcode-font-family: 'Inconsolata', monospace !important;
5
+ --vzcode-font-family: 'Roboto Mono', monospace !important;
6
6
  --vzcode-font-size: 16px;
7
7
 
8
8
  /* Variable for the background color */
@@ -0,0 +1,73 @@
1
+ // Customized "basic setup" for CodeMirror.
2
+ // Mainly customized to remove keymaps, for compatibility with
3
+ // codemirror-vscode-keymap.
4
+ //
5
+ // Inspired by
6
+ // https://github.com/codemirror/basic-setup/blob/main/src/codemirror.ts
7
+ // https://github.com/replit/codemirror-vscode-keymap/blob/master/dev/basicSetupNoKeymap.ts
8
+ import {
9
+ highlightSpecialChars,
10
+ drawSelection,
11
+ highlightActiveLine,
12
+ dropCursor,
13
+ rectangularSelection,
14
+ crosshairCursor,
15
+ lineNumbers,
16
+ highlightActiveLineGutter,
17
+ } from '@codemirror/view';
18
+ import { Extension, EditorState } from '@codemirror/state';
19
+ import {
20
+ defaultHighlightStyle,
21
+ syntaxHighlighting,
22
+ indentOnInput,
23
+ bracketMatching,
24
+ } from '@codemirror/language';
25
+ import { history } from '@codemirror/commands';
26
+ import { highlightSelectionMatches } from '@codemirror/search';
27
+ import {
28
+ autocompletion,
29
+ closeBrackets,
30
+ } from '@codemirror/autocomplete';
31
+
32
+ export const basicSetup: Extension = (() => [
33
+ lineNumbers(),
34
+ highlightActiveLineGutter(),
35
+ highlightSpecialChars(),
36
+ history(),
37
+
38
+ // Not really a fan of foldGutter.
39
+ // Unclear if it's really useful.
40
+ // If we ever want to use it, we should
41
+ // make sure the styling is decent.
42
+ // foldGutter(),
43
+ drawSelection(),
44
+ dropCursor(),
45
+ EditorState.allowMultipleSelections.of(true),
46
+ indentOnInput(),
47
+ syntaxHighlighting(defaultHighlightStyle, {
48
+ fallback: true,
49
+ }),
50
+ bracketMatching(),
51
+ closeBrackets(),
52
+ // We set this to `false` because that is prescribed by
53
+ // https://github.com/replit/codemirror-vscode-keymap
54
+ autocompletion({ defaultKeymap: false }),
55
+
56
+ rectangularSelection(),
57
+ crosshairCursor(),
58
+ highlightActiveLine(),
59
+ highlightSelectionMatches(),
60
+
61
+ // All of these keymaps are disabled because we use
62
+ // codemirror-vscode-keymap, which provides its own
63
+ // keymaps for all of these things.
64
+ // keymap.of([
65
+ // ...closeBracketsKeymap,
66
+ // ...defaultKeymap,
67
+ // ...searchKeymap,
68
+ // ...historyKeymap,
69
+ // // ...foldKeymap,
70
+ // ...completionKeymap,
71
+ // ...lintKeymap,
72
+ // ]),
73
+ ])();
@@ -1,4 +1,4 @@
1
- import { EditorView, basicSetup } from 'codemirror';
1
+ import { EditorView } from 'codemirror';
2
2
  import {
3
3
  Compartment,
4
4
  EditorState,
@@ -10,6 +10,9 @@ import { html } from '@codemirror/lang-html';
10
10
  import { css } from '@codemirror/lang-css';
11
11
  import { json1Sync } from 'codemirror-ot';
12
12
  import { autocompletion } from '@codemirror/autocomplete';
13
+ import { indentationMarkers } from '@replit/codemirror-indentation-markers';
14
+ import { showMinimap } from '@replit/codemirror-minimap';
15
+ import { vscodeKeymap } from '@replit/codemirror-vscode-keymap';
13
16
  import { Diagnostic, linter } from '@codemirror/lint';
14
17
  import { json1Presence, textUnicode } from '../../ot';
15
18
  import {
@@ -35,6 +38,8 @@ import { AIAssist } from '../AIAssist';
35
38
  import { typeScriptCompletions } from './typeScriptCompletions';
36
39
  import { typeScriptLinter } from './typeScriptLinter';
37
40
  import { TabState } from '../vzReducer';
41
+ import { keymap } from '@codemirror/view';
42
+ import { basicSetup } from './basicSetup';
38
43
 
39
44
  // Feature flag to enable TypeScript completions & TypeScript Linter.
40
45
  const enableTypeScriptCompletions = true;
@@ -263,6 +268,34 @@ export const getOrCreateEditor = ({
263
268
  );
264
269
  }
265
270
 
271
+ // Add the extension that provides indentation markers.
272
+ extensions.push(
273
+ indentationMarkers({
274
+ // thickness: 2,
275
+ colors: {
276
+ light: '#4d586b',
277
+ dark: '#4d586b',
278
+ activeLight: '#8e949f',
279
+ activeDark: '#8e949f',
280
+ },
281
+ }),
282
+ );
283
+
284
+ // Show the minimap
285
+ // See https://github.com/replit/codemirror-minimap#usage
286
+ extensions.push(
287
+ showMinimap.compute(['doc'], () => ({
288
+ create: () => ({
289
+ dom: document.createElement('div'),
290
+ }),
291
+ // displayText: 'blocks',
292
+ })),
293
+ );
294
+
295
+ // VSCode keybindings
296
+ // See https://github.com/replit/codemirror-vscode-keymap#usage
297
+ extensions.push(keymap.of(vscodeKeymap));
298
+
266
299
  const editor = new EditorView({
267
300
  state: EditorState.create({
268
301
  doc: text,
@@ -47,44 +47,58 @@ export const json1PresenceDisplay = ({
47
47
  }
48
48
  // Update decorations to reflect new presence state.
49
49
  // TODO consider mutating this rather than recomputing it on each change.
50
+
51
+ const presenceDecorations = [];
52
+
53
+ // Object.keys(presenceState).map((id) => {
54
+ for (const id of Object.keys(presenceState)) {
55
+ const presence = presenceState[id];
56
+ const { start, end } = presence;
57
+ const from = start[start.length - 1];
58
+ const to = end[end.length - 1];
59
+ const userColor = new ColorHash().rgb(id);
60
+ const { username } = presence;
61
+
62
+ presenceDecorations.push({
63
+ from,
64
+ to: from,
65
+ value: Decoration.widget({
66
+ side: -1,
67
+ block: false,
68
+ widget: new PresenceWidget(
69
+ // TODO see if we can figure out why
70
+ // updateDOM was not being called when passing
71
+ // the presence id as the id
72
+ // id,
73
+ '' + Math.random(),
74
+ userColor,
75
+ username,
76
+ ),
77
+ }),
78
+ });
79
+
80
+ // This is `true` when the presence is a cursor,
81
+ // with no selection.
82
+ if (from !== to) {
83
+ // This is the case when the presence is a selection.
84
+ presenceDecorations.push({
85
+ from,
86
+ to,
87
+ value: Decoration.mark({
88
+ class: 'cm-json1-presence',
89
+ attributes: {
90
+ style: `
91
+ background-color: rgba(${userColor}, 0.75);
92
+ mix-blend-mode: luminosity;
93
+ `,
94
+ },
95
+ }),
96
+ });
97
+ }
98
+ }
99
+
50
100
  this.decorations = Decoration.set(
51
- Object.keys(presenceState).map((id) => {
52
- const presence = presenceState[id];
53
- const { start, end } = presence;
54
- const from = start[start.length - 1];
55
- const to = end[end.length - 1];
56
- const userColor = new ColorHash().rgb(id);
57
- const { username } = presence;
58
- if (from === to) {
59
- return {
60
- from,
61
- to,
62
- value: Decoration.widget({
63
- side: -1,
64
- block: false,
65
- widget: new PresenceWidget(
66
- id,
67
- userColor,
68
- username,
69
- ),
70
- }),
71
- };
72
- } else {
73
- return {
74
- from,
75
- to,
76
- value: Decoration.mark({
77
- class: 'cm-json1-presence',
78
- attributes: {
79
- style: `
80
- background-color: rgba(${userColor}, 0.75);
81
- mix-blend-mode: luminosity;
82
- `,
83
- },
84
- }),
85
- };
86
- }
87
- }),
101
+ presenceDecorations,
88
102
  // Without this argument, we get the following error:
89
103
  // Uncaught Error: Ranges must be added sorted by `from` position and `startSide`
90
104
  true,
@@ -131,6 +145,7 @@ class PresenceWidget extends WidgetType {
131
145
  id: string;
132
146
  color: string;
133
147
  username: Username;
148
+ timeout: number;
134
149
  constructor(
135
150
  id: string,
136
151
  color: string,
@@ -144,9 +159,11 @@ class PresenceWidget extends WidgetType {
144
159
 
145
160
  eq(other: PresenceWidget) {
146
161
  return other.id === this.id;
162
+ // return false;
147
163
  }
148
164
 
149
165
  toDOM() {
166
+ // console.log('inside toDOM');
150
167
  const span = document.createElement('span');
151
168
  span.setAttribute('aria-hidden', 'true');
152
169
  span.className = 'cm-json1-presence';
@@ -165,24 +182,40 @@ class PresenceWidget extends WidgetType {
165
182
  userDiv.className = 'remote-cursor-username';
166
183
  userDiv.style.top = `-20px`;
167
184
  userDiv.style.height = `20px`;
168
- userDiv.style.width = `${this.username.length * 11}px`;
185
+ userDiv.style.width = `${this.username.length * 12}px`;
169
186
  userDiv.style.backgroundColor = `rgba(${this.color})`;
170
187
  userDiv.style.color = `black`;
171
- userDiv.style.textAlign = `center`;
188
+ // userDiv.style.textAlign = `center`;
172
189
  userDiv.appendChild(
173
190
  document.createTextNode(this.username),
174
191
  );
175
192
  span.appendChild(userDiv);
176
193
 
177
194
  // after 2 seconds of inactivity, username is made less visible
178
- setTimeout(() => {
179
- userDiv.style.backgroundColor = `rgba(${this.color}, 0.2)`;
180
- userDiv.style.color = 'rgba(0,0,0,0.2)';
195
+ this.timeout = window.setTimeout(() => {
196
+ // userDiv.style.backgroundColor = `rgba(${this.color}, 0.2)`;
197
+ // userDiv.style.color = 'rgba(0,0,0,0.2)';
198
+ userDiv.style.opacity = '0.3';
181
199
  }, 2000);
182
200
 
183
201
  return span;
184
202
  }
185
203
 
204
+ // TODO try to use this instead of toDOM
205
+ // updateDOM(dom: HTMLElement, view: EditorView) {
206
+ // console.log('inside updateDOM');
207
+ // dom.style.opacity = '1';
208
+ // window.clearTimeout(this.timeout);
209
+
210
+ // // after 2 seconds of inactivity, username is made less visible
211
+ // this.timeout = window.setTimeout(() => {
212
+ // // userDiv.style.backgroundColor = `rgba(${this.color}, 0.2)`;
213
+ // // userDiv.style.color = 'rgba(0,0,0,0.2)';
214
+ // dom.style.opacity = '0.3';
215
+ // }, 2000);
216
+
217
+ // return false;
218
+ // }
186
219
  ignoreEvent() {
187
220
  return false;
188
221
  }
@@ -12,4 +12,12 @@
12
12
  font-family: var(--vzcode-font-family);
13
13
  font-size: var(--vzcode-font-size);
14
14
  }
15
+
16
+ .remote-cursor-username {
17
+ transition: opacity 1s ease-in-out;
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ border-radius: 4px;
22
+ }
15
23
  }
@@ -96,7 +96,6 @@ export const typeScriptCompletions = ({
96
96
  completion.name.startsWith(lastWord),
97
97
  );
98
98
  }
99
-
100
99
  return {
101
100
  from: completionContext.pos,
102
101
  // @ts-ignore
@@ -104,12 +103,22 @@ export const typeScriptCompletions = ({
104
103
  label: completion.name,
105
104
  // Applies autocompletions to be seen in the code Editor
106
105
  apply: (view) => {
106
+ //Calculation to get the new cursor position after the autocompletion
107
+ const newPosition =
108
+ completionContext.pos +
109
+ completion.name.length -
110
+ lastWord.length;
107
111
  view.dispatch({
108
112
  changes: {
109
113
  from,
110
114
  to: completionContext.pos,
111
115
  insert: completion.name,
112
116
  },
117
+ // Move the cursor to the end of the autocompletion
118
+ selection: {
119
+ anchor: newPosition,
120
+ head: newPosition,
121
+ },
113
122
  });
114
123
  },
115
124
  })),
@@ -8,6 +8,7 @@
8
8
  // background: #47546b;
9
9
  color: #fff;
10
10
  font-family: var(--vzcode-font-family);
11
+ font-weight: 500;
11
12
  align-items: center;
12
13
  display: flex;
13
14
  padding-top: 2px;
@@ -29,6 +29,8 @@
29
29
  cursor: pointer;
30
30
  margin: 0 10px;
31
31
  border-radius: 4px;
32
+ font-family: var(--vzcode-font-family);
33
+ font-weight: 500;
32
34
  }
33
35
 
34
36
  .sidebar-section-hint {
@@ -30,6 +30,12 @@ import {
30
30
  PANIC,
31
31
  } from './colors';
32
32
 
33
+ // Use semi-bold weight for keywords and other important things
34
+ // const boldWeight = 'bold';
35
+
36
+ // This looks way better as we are pulling in the semi-bold font from Google Fonts
37
+ const boldWeight = '500';
38
+
33
39
  const defaultSettingsVizhubTheme: CreateThemeOptions['settings'] =
34
40
  {
35
41
  background: backgroundColor,
@@ -97,7 +103,7 @@ function vizhubThemeInit(
97
103
  },
98
104
  {
99
105
  tag: t.heading,
100
- fontWeight: 'bold',
106
+ fontWeight: boldWeight,
101
107
  color: SKY,
102
108
  },
103
109
  {
@@ -145,7 +151,7 @@ function vizhubThemeInit(
145
151
  color: AQUA,
146
152
  },
147
153
  { tag: [t.angleBracket], color: AQUA },
148
- { tag: t.strong, fontWeight: 'bold' },
154
+ { tag: t.strong, fontWeight: boldWeight },
149
155
  { tag: t.emphasis, fontStyle: 'italic' },
150
156
  {
151
157
  tag: t.strikethrough,
@@ -81,6 +81,13 @@ onmessage = async ({
81
81
  const fileTextPrettified = await format(fileText, {
82
82
  parser,
83
83
  plugins,
84
+
85
+ // This helps with Markdown files
86
+ proseWrap: 'always',
87
+
88
+ // Opinionated code style for JavaScript
89
+ singleQuote: true,
90
+ printWidth: 60,
84
91
  });
85
92
 
86
93
  postMessage({