vzcode 0.41.0 → 0.43.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-APrkOjkE.js"></script>
28
- <link rel="stylesheet" crossorigin href="/assets/index-7TYVtsYX.css">
27
+ <script type="module" crossorigin src="/assets/index-WNLp-4Rf.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.41.0",
3
+ "version": "0.43.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -36,8 +36,26 @@
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
+ },
47
+ {
48
+ "name": "Jack Hankin",
49
+ "url": "https://github.com/Darmin-Geek"
50
+ },
51
+ {
52
+ "name": "Amanda Ruan",
53
+ "url": "https://github.com/aruan20"
54
+ },
55
+ {
56
+ "name": "Evan Whymark",
57
+ "url": "https://github.com/EvWhymark"
58
+ }
41
59
  ],
42
60
  "license": "MIT",
43
61
  "bugs": {
@@ -51,9 +69,9 @@
51
69
  "@codemirror/lang-javascript": "^6.2.1",
52
70
  "@codemirror/lang-json": "^6.0.1",
53
71
  "@codemirror/lang-markdown": "^6.2.3",
54
- "@codemirror/state": "^6.3.2",
72
+ "@codemirror/state": "^6.3.3",
55
73
  "@codemirror/theme-one-dark": "^6.1.2",
56
- "@codemirror/view": "^6.22.1",
74
+ "@codemirror/view": "^6.22.2",
57
75
  "@lezer/highlight": "^1.2.0",
58
76
  "@replit/codemirror-indentation-markers": "^6.5.0",
59
77
  "@replit/codemirror-interact": "^6.3.0",
@@ -85,19 +103,19 @@
85
103
  "react": "^18.2.0",
86
104
  "react-bootstrap": "^2.9.1",
87
105
  "react-dom": "^18.2.0",
88
- "sharedb": "^4.1.1",
106
+ "sharedb": "^4.1.2",
89
107
  "sharedb-client-browser": "^4.4.0",
90
108
  "vizhub-ui": "^3.10.0",
91
- "ws": "^8.14.2"
109
+ "ws": "^8.15.0"
92
110
  },
93
111
  "devDependencies": {
94
- "@types/react": "^18.2.42",
112
+ "@types/react": "^18.2.43",
95
113
  "@types/react-dom": "^18.2.17",
96
114
  "@vitejs/plugin-react": "^4.2.1",
97
- "prettier": "^3.1.0",
115
+ "prettier": "^3.1.1",
98
116
  "sass": "^1.69.5",
99
- "typescript": "^5.3.2",
100
- "vite": "^5.0.5",
101
- "vitest": "^1.0.1"
117
+ "typescript": "^5.3.3",
118
+ "vite": "^5.0.7",
119
+ "vitest": "^1.0.4"
102
120
  }
103
121
  }
@@ -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
  })),
@@ -4,7 +4,6 @@ import {
4
4
  ViewPlugin,
5
5
  Decoration,
6
6
  WidgetType,
7
- keymap,
8
7
  } from '@codemirror/view';
9
8
  import {
10
9
  Annotation,
@@ -30,15 +29,17 @@ export const widgets = ({
30
29
  rules: [
31
30
  // hex color picker
32
31
  // Inspired by https://github.com/replit/codemirror-interact/blob/master/dev/index.ts#L71
32
+ // Extended to support single and double quotes
33
33
  {
34
- regexp: /\"\#([0-9]|[A-F]|[a-f]){6}\"/g,
34
+ regexp: /["']\#([0-9]|[A-F]|[a-f]){6}["']/g,
35
35
  cursor: 'pointer',
36
36
  onClick(text, setText, e) {
37
37
  const res =
38
- /\"(?<hex>\#([0-9]|[A-F]|[a-f]){6})\"/.exec(
38
+ /(?<quote>["'])(?<hex>\#([0-9]|[A-F]|[a-f]){6})\k<quote>/.exec(
39
39
  text,
40
40
  );
41
41
  const startingColor = res.groups?.hex;
42
+ const quoteType = res.groups?.quote;
42
43
 
43
44
  const sel = document.createElement('input');
44
45
  sel.type = 'color';
@@ -54,11 +55,11 @@ export const widgets = ({
54
55
  if (onInteract) onInteract();
55
56
  if (el.value) {
56
57
  setText(
57
- `"${
58
+ `${quoteType}${
58
59
  valueIsUpper
59
60
  ? el.value.toUpperCase()
60
61
  : el.value
61
- }"`,
62
+ }${quoteType}`,
62
63
  );
63
64
  }
64
65
  };
@@ -210,11 +211,12 @@ const rgb2Hex = (r: number, g: number, b: number): string =>
210
211
  '#' + r.toString(16) + g.toString(16) + b.toString(16);
211
212
 
212
213
  const colorCircleTheme = EditorView.baseTheme({
213
- '.color-circle-parent': { display: 'inline-block' },
214
+ '.color-circle-parent': {
215
+ display: 'inline-block',
216
+ cursor: 'inherit',
217
+ },
214
218
  });
215
219
 
216
- const colorCircleAnnotation = Annotation.define();
217
-
218
220
  export const colorsInTextPlugin: Extension = [
219
221
  ViewPlugin.fromClass(
220
222
  class {
@@ -232,7 +234,8 @@ export const colorsInTextPlugin: Extension = [
232
234
  const lines = v.view.state.doc.iter();
233
235
  let line = lines.next();
234
236
 
235
- //Offset is the number of characters before the hex so the circle can be placed properly.
237
+ // Offset is the number of characters before the hex
238
+ // so the circle can be placed properly.
236
239
  let offset = 0;
237
240
  while (!line.done) {
238
241
  if (line.value === '\n') {
@@ -240,15 +243,16 @@ export const colorsInTextPlugin: Extension = [
240
243
  line = lines.next();
241
244
  continue;
242
245
  }
243
- const hexColorOccurances = line.value.matchAll(
244
- /\"\#([0-9]|[A-F]|[a-f]){6}\"/g,
246
+ const hexColorOccurences = line.value.matchAll(
247
+ // /\"\#([0-9]|[A-F]|[a-f]){6}\"/g,
248
+ /["']\#([0-9]|[A-F]|[a-f]){6}["']/g,
245
249
  );
246
- let hexOccurance = hexColorOccurances.next();
250
+ let hexOccurance = hexColorOccurences.next();
247
251
  while (!hexOccurance.done) {
248
252
  const offsetColorInfo = hexOccurance.value;
249
253
  offsetColorInfo.index += offset;
250
254
  colorInfos.push(offsetColorInfo);
251
- hexOccurance = hexColorOccurances.next();
255
+ hexOccurance = hexColorOccurences.next();
252
256
  }
253
257
  offset += line.value.length;
254
258
  line = lines.next();
@@ -257,7 +261,7 @@ export const colorsInTextPlugin: Extension = [
257
261
  return Decoration.set(
258
262
  colorInfos.map((colorInfo) => {
259
263
  return {
260
- //9 is the length of the hex color string including quotation marks
264
+ // 9 is the length of the hex color string including quotation marks
261
265
  from: colorInfo.index + 9,
262
266
  to: colorInfo.index + 9,
263
267
  value: Decoration.widget({
@@ -287,8 +291,13 @@ class ColorWidget extends WidgetType {
287
291
 
288
292
  toDOM(view: EditorView): HTMLElement {
289
293
  const parent = document.createElement('div');
294
+ const size = 20;
295
+ const innerSize = 16;
290
296
 
291
- parent.setAttribute('style', 'width:10px;height:10px');
297
+ parent.setAttribute(
298
+ 'style',
299
+ `width:${size}px;height:${size}px`,
300
+ );
292
301
  parent.className = 'color-circle-parent';
293
302
  const svg = document.createElementNS(
294
303
  'http://www.w3.org/2000/svg',
@@ -301,15 +310,23 @@ class ColorWidget extends WidgetType {
301
310
  colorCircle.setAttributeNS(
302
311
  null,
303
312
  'fill',
304
- this.color.replace(/\"/g, ''),
313
+ this.color.replace(/["']/g, ''),
314
+ );
315
+ colorCircle.setAttributeNS(null, 'stroke', 'black');
316
+ colorCircle.setAttributeNS(
317
+ null,
318
+ 'r',
319
+ '' + innerSize / 2,
320
+ );
321
+ colorCircle.setAttributeNS(null, 'cx', '' + size / 2);
322
+ colorCircle.setAttributeNS(
323
+ null,
324
+ 'cy',
325
+ '' + (size / 2 - 1),
305
326
  );
306
- colorCircle.setAttributeNS(null, 'r', '5');
307
- colorCircle.setAttributeNS(null, 'cx', '5');
308
- colorCircle.setAttributeNS(null, 'cy', '5');
309
327
 
310
- svg.setAttributeNS(null, 'viewBox', '0 0 10 10');
311
- svg.setAttributeNS(null, 'width', '10');
312
- svg.setAttributeNS(null, 'height', '10');
328
+ svg.setAttributeNS(null, 'width', '' + size);
329
+ svg.setAttributeNS(null, 'height', '' + size);
313
330
 
314
331
  svg.appendChild(colorCircle);
315
332
 
@@ -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({
@@ -244,4 +244,24 @@ onmessage = async ({ data }) => {
244
244
  };
245
245
  postMessage(linterResponse);
246
246
  }
247
+
248
+ // Handle the transpile-request event, which
249
+ // transpiles TypeScript to JavaScript.
250
+ if (data.event === 'transpile-request') {
251
+ const tsCode = data.tsCode;
252
+
253
+ const compilerOptions = {
254
+ jsx: ts.JsxEmit.React,
255
+ };
256
+
257
+ const jsCode = ts.transpileModule(tsCode, {
258
+ compilerOptions,
259
+ }).outputText;
260
+
261
+ postMessage({
262
+ event: 'transpile-response',
263
+ jsCode,
264
+ fileId: data.fileId,
265
+ });
266
+ }
247
267
  };