MCPcopy Index your code
hub / github.com/google/adk-python / addNote

Method addNote

src/google/adk/cli/browser/chunk-T2UY75BD.js:10–10  ·  view source on GitHub ↗
(e,t,a)

Source from the content-addressed store, hash-verified

8`:h=`{
9`+i+`
10}`,c=Qe(h,{schema:Je})}r=c?.type??r,c?.alias&&(!a||a.text===t)&&(a={text:c.alias,wrap:a?.wrap,type:r});let l=this.state.records.actors.get(e);if(l){if(this.state.records.currentBox&&l.box&&this.state.records.currentBox!==l.box)throw new Error(`A same participant should only be defined in one Box: ${l.name} can't be in '${l.box.name}' and in '${this.state.records.currentBox.name}' at the same time.`);if(n=l.box?l.box:this.state.records.currentBox,l.box=n,l&&t===l.name&&a==null)return}if(a?.text==null&&(a={text:t,type:r}),(r==null||a.text==null)&&(a={text:t,type:r}),this.state.records.actors.set(e,{box:n,name:t,description:a.text,wrap:a.wrap??this.autoWrap(),prevActor:this.state.records.prevActor,links:{},properties:{},actorCnt:null,rectData:null,type:r??"participant"}),this.state.records.prevActor){let h=this.state.records.actors.get(this.state.records.prevActor);h&&(h.nextActor=e)}this.state.records.currentBox&&this.state.records.currentBox.actorKeys.push(e),this.state.records.prevActor=e}activationCount(e){let t,a=0;if(!e)return 0;for(t=0;t<this.state.records.messages.length;t++)this.state.records.messages[t].type===this.LINETYPE.ACTIVE_START&&this.state.records.messages[t].from===e&&a++,this.state.records.messages[t].type===this.LINETYPE.ACTIVE_END&&this.state.records.messages[t].from===e&&a--;return a}addMessage(e,t,a,r){this.state.records.messages.push({id:this.state.records.messages.length.toString(),from:e,to:t,message:a.text,wrap:a.wrap??this.autoWrap(),answer:r})}addSignal(e,t,a,r,i=!1,n){if(r===this.LINETYPE.ACTIVE_END&&this.activationCount(e??"")<1){let l=new Error("Trying to inactivate an inactive participant ("+e+")");throw l.hash={text:"->>-",token:"->>-",line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["'ACTIVE_PARTICIPANT'"]},l}return this.state.records.messages.push({id:this.state.records.messages.length.toString(),from:e,to:t,message:a?.text??"",wrap:a?.wrap??this.autoWrap(),type:r,activate:i,centralConnection:n??0}),!0}hasAtLeastOneBox(){return this.state.records.boxes.length>0}hasAtLeastOneBoxWithTitle(){return this.state.records.boxes.some(e=>e.name)}getMessages(){return this.state.records.messages}getBoxes(){return this.state.records.boxes}getActors(){return this.state.records.actors}getCreatedActors(){return this.state.records.createdActors}getDestroyedActors(){return this.state.records.destroyedActors}getActor(e){return this.state.records.actors.get(e)}getActorKeys(){return[...this.state.records.actors.keys()]}enableSequenceNumbers(){this.state.records.sequenceNumbersEnabled=!0}disableSequenceNumbers(){this.state.records.sequenceNumbersEnabled=!1}showSequenceNumbers(){return this.state.records.sequenceNumbersEnabled}setWrap(e){this.state.records.wrapEnabled=e}extractWrap(e){if(e===void 0)return{};e=e.trim();let t=/^:?wrap:/.exec(e)!==null?!0:/^:?nowrap:/.exec(e)!==null?!1:void 0;return{cleanedText:(t===void 0?e:e.replace(/^:?(?:no)?wrap:/,"")).trim(),wrap:t}}autoWrap(){return this.state.records.wrapEnabled!==void 0?this.state.records.wrapEnabled:j().sequence?.wrap??!1}clear(){this.state.reset(),Fe()}parseMessage(e){let t=e.trim(),{wrap:a,cleanedText:r}=this.extractWrap(t),i={text:r,wrap:a};return Q.debug(`parseMessage: ${JSON.stringify(i)}`),i}parseBoxData(e){let t=/^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/.exec(e),a=t?.[1]?t[1].trim():"transparent",r=t?.[2]?t[2].trim():void 0;if(window?.CSS)window.CSS.supports("color",a)||(a="transparent",r=e.trim());else{let c=new Option().style;c.color=a,c.color!==a&&(a="transparent",r=e.trim())}let{wrap:i,cleanedText:n}=this.extractWrap(r);return{text:n?Nt(n,j()):void 0,color:a,wrap:i}}addNote(e,t,a){let r={actor:e,placement:t,message:a.text,wrap:a.wrap??this.autoWrap()},i=[].concat(e,e);this.state.records.notes.push(r),this.state.records.messages.push({id:this.state.records.messages.length.toString(),from:i[0],to:i[1],message:a.text,wrap:a.wrap??this.autoWrap(),type:this.LINETYPE.NOTE,placement:t})}addLinks(e,t){let a=this.getActor(e);try{let r=Nt(t.text,j());r=r.replace(/&equals;/g,"="),r=r.replace(/&amp;/g,"&");let i=JSON.parse(r);this.insertLinks(a,i)}catch(r){Q.error("error while parsing actor link text",r)}}addALink(e,t){let a=this.getActor(e);try{let r={},i=Nt(t.text,j()),n=i.indexOf("@");i=i.replace(/&equals;/g,"="),i=i.replace(/&amp;/g,"&");let c=i.slice(0,n-1).trim(),l=i.slice(n+1).trim();r[c]=l,this.insertLinks(a,r)}catch(r){Q.error("error while parsing actor link text",r)}}insertLinks(e,t){if(e.links==null)e.links=t;else for(let a in t)e.links[a]=t[a]}addProperties(e,t){let a=this.getActor(e);try{let r=Nt(t.text,j()),i=JSON.parse(r);this.insertProperties(a,i)}catch(r){Q.error("error while parsing actor properties text",r)}}insertProperties(e,t){if(e.properties==null)e.properties=t;else for(let a in t)e.properties[a]=t[a]}boxEnd(){this.state.records.currentBox=void 0}addDetails(e,t){let a=this.getActor(e),r=document.getElementById(t.text);try{let i=r.innerHTML,n=JSON.parse(i);n.properties&&this.insertProperties(a,n.properties),n.links&&this.insertLinks(a,n.links)}catch(i){Q.error("error while parsing actor details text",i)}}getActorProperty(e,t){if(e?.properties!==void 0)return e.properties[t]}apply(e){if(Array.isArray(e))e.forEach(t=>{this.apply(t)});else switch(e.type){case"sequenceIndex":this.state.records.messages.push({id:this.state.records.messages.length.toString(),from:void 0,to:void 0,message:{start:e.sequenceIndex,step:e.sequenceIndexStep,visible:e.sequenceVisible},wrap:!1,type:e.signalType});break;case"addParticipant":this.addActor(e.actor,e.actor,e.description,e.draw,e.config);break;case"createParticipant":if(this.state.records.actors.has(e.actor))throw new Error("It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior");this.state.records.lastCreated=e.actor,this.addActor(e.actor,e.actor,e.description,e.draw,e.config),this.state.records.createdActors.set(e.actor,this.state.records.messages.length);break;case"destroyParticipant":this.state.records.lastDestroyed=e.actor,this.state.records.destroyedActors.set(e.actor,this.state.records.messages.length);break;case"activeStart":this.addSignal(e.actor,void 0,void 0,e.signalType);break;case"centralConnection":this.addSignal(e.actor,void 0,void 0,e.signalType);break;case"centralConnectionReverse":this.addSignal(e.actor,void 0,void 0,e.signalType);break;case"activeEnd":this.addSignal(e.actor,void 0,void 0,e.signalType);break;case"addNote":this.addNote(e.actor,e.placement,e.text);break;case"addLinks":this.addLinks(e.actor,e.text);break;case"addALink":this.addALink(e.actor,e.text);break;case"addProperties":this.addProperties(e.actor,e.text);break;case"addDetails":this.addDetails(e.actor,e.text);break;case"addMessage":if(this.state.records.lastCreated){if(e.to!==this.state.records.lastCreated)throw new Error("The created participant "+this.state.records.lastCreated.name+" does not have an associated creating message after its declaration. Please check the sequence diagram.");this.state.records.lastCreated=void 0}else if(this.state.records.lastDestroyed){if(e.to!==this.state.records.lastDestroyed&&e.from!==this.state.records.lastDestroyed)throw new Error("The destroyed participant "+this.state.records.lastDestroyed.name+" does not have an associated destroying message after its declaration. Please check the sequence diagram.");this.state.records.lastDestroyed=void 0}this.addSignal(e.from,e.to,e.msg,e.signalType,e.activate,e.centralConnection);break;case"boxStart":this.addBox(e.boxData);break;case"boxEnd":this.boxEnd();break;case"loopStart":this.addSignal(void 0,void 0,e.loopText,e.signalType);break;case"loopEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break;case"rectStart":this.addSignal(void 0,void 0,e.color,e.signalType);break;case"rectEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break;case"optStart":this.addSignal(void 0,void 0,e.optText,e.signalType);break;case"optEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break;case"altStart":this.addSignal(void 0,void 0,e.altText,e.signalType);break;case"else":this.addSignal(void 0,void 0,e.altText,e.signalType);break;case"altEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break;case"setAccTitle":jt(e.text);break;case"parStart":this.addSignal(void 0,void 0,e.parText,e.signalType);break;case"and":this.addSignal(void 0,void 0,e.parText,e.signalType);break;case"parEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break;case"criticalStart":this.addSignal(void 0,void 0,e.criticalText,e.signalType);break;case"option":this.addSignal(void 0,void 0,e.optionText,e.signalType);break;case"criticalEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break;case"breakStart":this.addSignal(void 0,void 0,e.breakText,e.signalType);break;case"breakEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break}}getConfig(){return j().sequence}},Sr=_(e=>`.actor {
11 stroke: ${e.actorBorder};
12 fill: ${e.actorBkg};
13 }

Callers 2

applyMethod · 0.45
chunk-T2UY75BD.jsFile · 0.45

Calls 4

autoWrapMethod · 0.80
concatMethod · 0.80
pushMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected