@techdocs/cli 0.8.17-next.0 → 0.8.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ "use strict";(()=>{var he=Object.defineProperty;var fe=(S,g,c)=>g in S?he(S,g,{enumerable:!0,configurable:!0,writable:!0,value:c}):S[g]=c;var k=(S,g,c)=>(fe(S,typeof g!="symbol"?g+"":g,c),c);(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[8718],{98718:function(S,g,c){c.r(g),c.d(g,{RealLogViewer:function(){return de}});var a=c(2784),U=c(10289),v=c(61837),W=c(19353),w=c(7688),D=c(8301),G=c(4903);const E=(0,G.Z)(),I=/\n\r?/g,b=Object.fromEntries(Object.entries({1:e=>({...e,bold:!0}),3:e=>({...e,italic:!0}),4:e=>({...e,underline:!0}),22:({bold:e,...t})=>t,23:({italic:e,...t})=>t,24:({underline:e,...t})=>t,30:e=>({...e,foreground:"black"}),31:e=>({...e,foreground:"red"}),32:e=>({...e,foreground:"green"}),33:e=>({...e,foreground:"yellow"}),34:e=>({...e,foreground:"blue"}),35:e=>({...e,foreground:"magenta"}),36:e=>({...e,foreground:"cyan"}),37:e=>({...e,foreground:"white"}),39:({foreground:e,...t})=>t,90:e=>({...e,foreground:"grey"}),40:e=>({...e,background:"black"}),41:e=>({...e,background:"red"}),42:e=>({...e,background:"green"}),43:e=>({...e,background:"yellow"}),44:e=>({...e,background:"blue"}),45:e=>({...e,background:"magenta"}),46:e=>({...e,background:"cyan"}),47:e=>({...e,background:"white"}),49:({background:e,...t})=>t}).map(([e,t])=>[`\x1B[${e}m`,t]));class L{constructor(t=1,n=[]){k(this,"text");this.lineNumber=t,this.chunks=n,this.text=n.map(s=>s.text).join("").toLocaleLowerCase("en-US")}lastChunk(){return this.chunks[this.chunks.length-1]}replaceLastChunk(t){t&&(this.chunks.splice(this.chunks.length-1,1,...t),this.text=this.chunks.map(n=>n.text).join("").toLocaleLowerCase("en-US"))}}class P{constructor(){k(this,"text","");k(this,"lines",[]);k(this,"processLines",(t,n={},s=1)=>{var l;const o=[];let i=n,r=s,u=0;for(I.lastIndex=0;;){const h=I.exec(t);if(!h){const f=this.processText(t.slice(u),i);return o.push(new L(r,f)),o}const d=t.slice(u,h.index);u=h.index+h[0].length;const p=this.processText(d,i);o.push(new L(r,p)),i=(l=p[p.length-1].modifiers)!=null?l:i,r+=1}});k(this,"processText",(t,n)=>{const s=[];let o=n,i=0;for(E.lastIndex=0;;){const r=E.exec(t);if(!r)return s.push({text:t.slice(i),modifiers:o}),s;const u=t.slice(i,r.index);s.push({text:u,modifiers:o}),i=r.index+r[0].length,o=this.processCode(r[0],o)}});k(this,"processCode",(t,n)=>{var s,o;return(o=(s=b[t])==null?void 0:s.call(b,n))!=null?o:n})}process(t){var n,s,o;if(this.text===t)return this.lines;if(t.startsWith(this.text)){const i=this.lines.length>0?this.lines.length-1:0,r=(n=this.lines[i])!=null?n:new L,u=r.lastChunk(),l=this.processLines(((s=u==null?void 0:u.text)!=null?s:"")+t.slice(this.text.length),u==null?void 0:u.modifiers,r==null?void 0:r.lineNumber);r.replaceLastChunk((o=l[0])==null?void 0:o.chunks),this.lines[i]=r,this.lines.push(...l.slice(1))}else this.lines=this.processLines(t);return this.text=t,this.lines}}var $=c(79692),B=c(41128),C=c(31754),F=c(66054),R=c(81463),M=c(34505),N=c(57186),T=c(32720),A=c(92901),j=c(45410);const z=40,Y=(0,$.Z)(e=>({root:{background:e.palette.background.paper},header:{height:z,display:"flex",alignItems:"center",justifyContent:"flex-end"},log:{fontFamily:'"Monaco", monospace',fontSize:e.typography.pxToRem(12)},line:{position:"relative",whiteSpace:"pre","&:hover":{background:e.palette.action.hover}},lineSelected:{background:e.palette.action.selected,"&:hover":{background:e.palette.action.selected}},lineCopyButton:{position:"absolute",paddingTop:0,paddingBottom:0},lineNumber:{display:"inline-block",textAlign:"end",width:60,marginRight:e.spacing(1),cursor:"pointer"},textHighlight:{background:(0,B.Fq)(e.palette.info.main,.15)},textSelectedHighlight:{background:(0,B.Fq)(e.palette.info.main,.4)},modifierBold:{fontWeight:e.typography.fontWeightBold},modifierItalic:{fontStyle:"italic"},modifierUnderline:{textDecoration:"underline"},modifierForegroundBlack:{color:C.Z.black},modifierForegroundRed:{color:F.Z[500]},modifierForegroundGreen:{color:R.Z[500]},modifierForegroundYellow:{color:M.Z[500]},modifierForegroundBlue:{color:N.Z[500]},modifierForegroundMagenta:{color:T.Z[500]},modifierForegroundCyan:{color:A.Z[500]},modifierForegroundWhite:{color:C.Z.white},modifierForegroundGrey:{color:j.Z[500]},modifierBackgroundBlack:{background:C.Z.black},modifierBackgroundRed:{background:F.Z[500]},modifierBackgroundGreen:{background:R.Z[500]},modifierBackgroundYellow:{background:M.Z[500]},modifierBackgroundBlue:{background:N.Z[500]},modifierBackgroundMagenta:{background:T.Z[500]},modifierBackgroundCyan:{background:A.Z[500]},modifierBackgroundWhite:{background:C.Z.white},modifierBackgroundGrey:{background:j.Z[500]}}),{name:"BackstageLogViewer"});var J=c(72779),K=c.n(J),Q=c(74600),H=c.n(Q);function X(e,t){const n=new Array;if(t.bold&&n.push(e.modifierBold),t.italic&&n.push(e.modifierItalic),t.underline&&n.push(e.modifierUnderline),t.foreground){const s=`modifierForeground${H()(t.foreground)}`;n.push(e[s])}if(t.background){const s=`modifierBackground${H()(t.background)}`;n.push(e[s])}return n.length>0?n.join(" "):void 0}function q(e,t){if(!t||!e.includes(t))return;const n=new Array;let s=0;for(;;){const o=e.indexOf(t,s);if(o===-1)break;const i=o+t.length;n.push({start:o,end:i}),s=i}return n}function _(e,t){const n=q(e.text,t);if(!n)return e.chunks;const s=new Array;let o=0,i=0,r=n[i];for(const u of e.chunks){const{text:l,modifiers:h}=u;if(!r||o+l.length<r.start){s.push(u),o+=l.length;continue}let d=0;for(;r;){const f=Math.max(r.start-o,0);if(f>l.length)break;const x=Math.min(r.end-o,l.length);if(f>d&&s.push({text:l.slice(d,f),modifiers:h}),x>f&&s.push({modifiers:h,highlight:i,text:l.slice(f,x)}),d=x,r.end-o===x)i+=1,r=n[i];else break}d<l.length&&s.push({text:l.slice(d),modifiers:h}),o+=l.length}return s}function ee({line:e,classes:t,searchText:n,highlightResultIndex:s}){const o=(0,a.useMemo)(()=>_(e,n),[e,n]),i=(0,a.useMemo)(()=>o.map(({text:r,modifiers:u,highlight:l},h)=>a.createElement("span",{key:h,className:K()(X(t,u),l!==void 0&&(l===s?t.textSelectedHighlight:t.textHighlight))},r)),[o,s,t]);return a.createElement(a.Fragment,null,i)}var te=c(86619),ne=c(90436),oe=c(48049),se=c(51209),O=c(36444);function re(e){var r;const{resultCount:t,resultIndexStep:n,toggleShouldFilter:s}=e,o=(r=e.resultIndex)!=null?r:0,i=u=>{u.key==="Enter"&&(u.metaKey||u.ctrlKey||u.altKey?s():n(u.shiftKey))};return a.createElement(a.Fragment,null,t!==void 0&&a.createElement(a.Fragment,null,a.createElement(v.Z,{size:"small",onClick:()=>n(!0)},a.createElement(oe.Z,null)),a.createElement(ne.Z,null,Math.min(o+1,t),"/",t),a.createElement(v.Z,{size:"small",onClick:()=>n()},a.createElement(se.Z,null))),a.createElement(te.Z,{size:"small",variant:"standard",placeholder:"Search",value:e.searchInput,onKeyPress:i,onChange:u=>e.setSearchInput(u.target.value)}),a.createElement(v.Z,{size:"small",onClick:s},e.shouldFilter?a.createElement(O.Z,{color:"primary"}):a.createElement(O.Z,{color:"disabled"})))}var le=c(3509);function ie(e,t){if(!t)return{lines:e};const n=[],s=[];for(const o of e)if(o.text.includes(t)){n.push(o);let i=0,r=0;for(;;){const u=o.text.indexOf(t,i);if(u===-1)break;s.push({lineNumber:o.lineNumber,lineIndex:r++}),i=u+t.length}}return{lines:n,results:s}}function ce(e){var f;const[t,n]=(0,a.useState)(""),s=t.toLocaleLowerCase("en-US"),[o,i]=(0,a.useState)(0),[r,u]=(0,le.O)(!1),l=(0,a.useMemo)(()=>ie(e,s),[e,s]),h=l.results?l.results[Math.min(o,l.results.length-1)]:void 0,d=(f=l.results)==null?void 0:f.length,p=x=>{if(x){if(d!==void 0){const m=Math.min(o-1,d-2);i(m<0?d-1:m)}}else if(d!==void 0){const m=o+1;i(m>=d?0:m)}};return{lines:r?l.lines:e,searchText:s,searchInput:t,setSearchInput:n,shouldFilter:r,toggleShouldFilter:u,resultCount:d,resultIndex:o,resultIndexStep:p,resultLine:h==null?void 0:h.lineNumber,resultLineIndex:h==null?void 0:h.lineIndex}}var V=c(36964),ae=c(55295);function ue(e){const t=(0,V.useApi)(V.errorApiRef),[n,s]=(0,a.useState)(),o=n?Math.min(n.start,n.end):void 0,i=n?Math.max(n.start,n.end):void 0,[{error:r},u]=(0,ae.Z)();return(0,a.useEffect)(()=>{r&&t.post(r)},[r,t]),{shouldShowButton(l){return o===l||i===l},isSelected(l){return n?o<=l&&l<=i:!1},setSelection(l,h){s(h?d=>d?{start:d.start,end:l}:{start:l,end:l}:d=>(d==null?void 0:d.start)===l&&(d==null?void 0:d.end)===l?void 0:{start:l,end:l})},copySelection(){if(n){const l=e.slice(Math.min(n.start,n.end)-1,Math.max(n.start,n.end)).map(h=>h.chunks.map(d=>d.text).join("")).join(`
2
+ `);u(l),s(void 0)}}}}function de(e){const t=Y({classes:e.classes}),n=(0,a.useRef)(null),o=(0,a.useMemo)(()=>new P,[]).process(e.text),i=ce(o),r=ue(o),u=(0,U.TH)();(0,a.useEffect)(()=>{i.resultLine!==void 0&&n.current&&n.current.scrollToItem(i.resultLine-1,"center")},[i.resultLine]),(0,a.useEffect)(()=>{if(u.hash){const h=parseInt(u.hash.replace(/\D/g,""),10);r.setSelection(h,!1)}},[]);const l=(h,d)=>{r.setSelection(h,d.shiftKey)};return a.createElement(w.Z,null,({height:h,width:d})=>a.createElement("div",{style:{width:d,height:h},className:t.root},a.createElement("div",{className:t.header},a.createElement(re,{...i})),a.createElement(D.t7,{ref:n,className:t.log,height:h-z,width:d,itemData:i.lines,itemSize:20,itemCount:i.lines.length},({index:p,style:f,data:x})=>{const m=x[p],{lineNumber:y}=m;return a.createElement("div",{style:{...f},className:K()(t.line,{[t.lineSelected]:r.isSelected(y)})},r.shouldShowButton(y)&&a.createElement(v.Z,{"data-testid":"copy-button",size:"small",className:t.lineCopyButton,onClick:()=>r.copySelection()},a.createElement(W.Z,{fontSize:"inherit"})),a.createElement("a",{role:"row",target:"_self",href:`#line-${y}`,className:t.lineNumber,onClick:Z=>l(y,Z),onKeyPress:Z=>l(y,Z)},y),a.createElement(ee,{line:m,classes:t,searchText:i.searchText,highlightResultIndex:i.resultLine===y?i.resultLineIndex:void 0}))})))}}}]);})();
3
+
4
+ //# sourceMappingURL=8718.8a863f87.chunk.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/AnsiProcessor.ts","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/styles.ts","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/LogLine.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/LogViewerControls.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/useLogViewerSearch.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/useLogViewerSelection.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/RealLogViewer.tsx"],"names":[],"mappings":"icAkBA,KAAM,GAAY,UACZ,EAAe,SAGf,EAAgB,OAAO,YAC3B,OAAO,QAAQ,CACb,EAAG,GAAM,KAAK,EAAG,KAAM,KACvB,EAAG,GAAM,KAAK,EAAG,OAAQ,KACzB,EAAG,GAAM,KAAK,EAAG,UAAW,KAC5B,GAAI,CAAC,CAAE,KAAM,KAAM,KAAQ,EAC3B,GAAI,CAAC,CAAE,OAAQ,KAAM,KAAQ,EAC7B,GAAI,CAAC,CAAE,UAAW,KAAM,KAAQ,EAChC,GAAI,GAAM,KAAK,EAAG,WAAY,UAC9B,GAAI,GAAM,KAA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EjB,KAAM,GAAO,SAAS,EAAS,KAAK,QAAQ,MAAO,IAAK,IACxD,EAAU,aAAa,EAAM,MAE9B,IAEH,KAAM,GAAmB,CACvB,EACA,IACG,CACH,EAAU,aAAa,EAAM,EAAM,WAGrC,MACE,iBAAoB,IAAW,KAC3B,CAAC,CAAE,SAAQ,WACX,gBAAoB,MAAO,CAAE,MAAO,CAAE,QAAO,UAAU,UAAW,EAAQ,MACtE,gBAAoB,MAAO,CAAE,UAAW,EAAQ,QAC9C,gBAAoB,GAAmB,IAAK,KAE9C,gBAAoB,KAAe,CACnC,IAAK,EACL,UAAW,EAAQ,IACnB,OAAQ,EAAS,EACjB,MAAO,EACP,SAAU,EAAO,MACjB,SAAU,GACV,UAAW,EAAO,MAAM,QAEtB,CAAC,CAAE,QAAO,QAAO,UAAW,CAC5B,KAAM,GAAO,EAAK,GACZ,CAAE,cAAe,EACvB,MACE,iBAAoB,MAAO,CACzB,MAAO,IAAK,GACZ,UAAW,IAAW,EAAQ,KAAM,EACjC,EAAQ,cAAe,EAAU,WAAW,MAG7C,EAAU,iBAAiB,IAC3B,gBAAoB,IAAY,CAC9B,cAAe,cACf,KAAM,QACN,UAAW,EAAQ,eACnB,QAAS,IAAM,EAAU,iBAEvB,gBAAoB,IAAU,CAAE,SAAU,aAG9C,gBAAoB,IAAK,CACzB,KAAM,MACN,OAAQ,QACR,KAAM,SAAS,IACf,UAAW,EAAQ,WACnB,QAAS,GAAS,EAAiB,EAAY,GAC/C,WAAY,GAAS,EAAiB,EAAY,IAEhD,GAEF,gBAAoB,GAAS,CAC7B,KAAM,EACN,QAAS,EACT,WAAY,EAAO,WACnB,qBACE,EAAO,aAAe,EAClB,EAAO,gBACP","file":"static/8718.71563d4c.chunk.js","sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport ansiRegexMaker from 'ansi-regex';\n\nconst ansiRegex = ansiRegexMaker();\nconst newlineRegex = /\\n\\r?/g;\n\n// A mapping of how each escape code changes the modifiers\nconst codeModifiers = Object.fromEntries(\n Object.entries({\n 1: m => ({ ...m, bold: true }),\n 3: m => ({ ...m, italic: true }),\n 4: m => ({ ...m, underline: true }),\n 22: ({ bold: _, ...m }) => m,\n 23: ({ italic: _, ...m }) => m,\n 24: ({ underline: _, ...m }) => m,\n 30: m => ({ ...m, foreground: 'black' }),\n 31: m => ({ ...m, foreground: 'red' }),\n 32: m => ({ ...m, foreground: 'green' }),\n 33: m => ({ ...m, foreground: 'yellow' }),\n 34: m => ({ ...m, foreground: 'blue' }),\n 35: m => ({ ...m, foreground: 'magenta' }),\n 36: m => ({ ...m, foreground: 'cyan' }),\n 37: m => ({ ...m, foreground: 'white' }),\n 39: ({ foreground: _, ...m }) => m,\n 90: m => ({ ...m, foreground: 'grey' }),\n 40: m => ({ ...m, background: 'black' }),\n 41: m => ({ ...m, background: 'red' }),\n 42: m => ({ ...m, background: 'green' }),\n 43: m => ({ ...m, background: 'yellow' }),\n 44: m => ({ ...m, background: 'blue' }),\n 45: m => ({ ...m, background: 'magenta' }),\n 46: m => ({ ...m, background: 'cyan' }),\n 47: m => ({ ...m, background: 'white' }),\n 49: ({ background: _, ...m }) => m,\n } ).map(\n ([code, modifier]) => [`\\x1b[${code}m`, modifier],\n ),\n);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport class AnsiLine {\n text;\n\n constructor(\n lineNumber = 1,\n chunks = [],\n ) {;this.lineNumber = lineNumber;this.chunks = chunks;\n this.text = chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n\n lastChunk() {\n return this.chunks[this.chunks.length - 1];\n }\n\n replaceLastChunk(newChunks) {\n if (newChunks) {\n this.chunks.splice(this.chunks.length - 1, 1, ...newChunks);\n this.text = this.chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n }\n}\n\nexport class AnsiProcessor {\n text = '';\n lines = [];\n\n /**\n * Processes a chunk of text while keeping internal state that optimizes\n * subsequent processing that appends to the text.\n */\n process(text) {\n if (this.text === text) {\n return this.lines;\n }\n\n if (text.startsWith(this.text)) {\n const lastLineIndex = this.lines.length > 0 ? this.lines.length - 1 : 0;\n const lastLine = this.lines[lastLineIndex] ?? new AnsiLine();\n const lastChunk = lastLine.lastChunk();\n\n const newLines = this.processLines(\n (lastChunk?.text ?? '') + text.slice(this.text.length),\n lastChunk?.modifiers,\n lastLine?.lineNumber,\n );\n lastLine.replaceLastChunk(newLines[0]?.chunks);\n\n this.lines[lastLineIndex] = lastLine;\n this.lines.push(...newLines.slice(1));\n } else {\n this.lines = this.processLines(text);\n }\n this.text = text;\n\n return this.lines;\n }\n\n // Split a chunk of text up into lines and process each line individually\n processLines = (\n text,\n modifiers = {},\n startingLineNumber = 1,\n ) => {\n const lines = [];\n\n let currentModifiers = modifiers;\n let currentLineNumber = startingLineNumber;\n\n let prevIndex = 0;\n newlineRegex.lastIndex = 0;\n for (;;) {\n const match = newlineRegex.exec(text);\n if (!match) {\n const chunks = this.processText(\n text.slice(prevIndex),\n currentModifiers,\n );\n lines.push(new AnsiLine(currentLineNumber, chunks));\n return lines;\n }\n\n const line = text.slice(prevIndex, match.index);\n prevIndex = match.index + match[0].length;\n\n const chunks = this.processText(line, currentModifiers);\n lines.push(new AnsiLine(currentLineNumber, chunks));\n\n // Modifiers that are active in the last chunk are carried over to the next line\n currentModifiers =\n chunks[chunks.length - 1].modifiers ?? currentModifiers;\n currentLineNumber += 1;\n }\n };\n\n // Processing of a one individual text chunk\n processText = (\n fullText,\n modifiers,\n ) => {\n const chunks = [];\n\n let currentModifiers = modifiers;\n\n let prevIndex = 0;\n ansiRegex.lastIndex = 0;\n for (;;) {\n const match = ansiRegex.exec(fullText);\n if (!match) {\n chunks.push({\n text: fullText.slice(prevIndex),\n modifiers: currentModifiers,\n });\n return chunks;\n }\n\n const text = fullText.slice(prevIndex, match.index);\n chunks.push({ text, modifiers: currentModifiers });\n\n // For every escape code that we encounter we keep track of where the\n // next chunk of text starts, and what modifiers it has\n prevIndex = match.index + match[0].length;\n currentModifiers = this.processCode(match[0], currentModifiers);\n }\n };\n\n processCode = (\n code,\n modifiers,\n ) => {\n return codeModifiers[code]?.(modifiers) ?? modifiers;\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { alpha, makeStyles } from '@material-ui/core/styles';\nimport * as colors from '@material-ui/core/colors';\n\nexport const HEADER_SIZE = 40;\n\n/** @public Class keys for overriding LogViewer styles */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport const useStyles = makeStyles(\n theme => ({\n root: {\n background: theme.palette.background.paper,\n },\n header: {\n height: HEADER_SIZE,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n log: {\n fontFamily: '\"Monaco\", monospace',\n fontSize: theme.typography.pxToRem(12),\n },\n line: {\n position: 'relative',\n whiteSpace: 'pre',\n\n '&:hover': {\n background: theme.palette.action.hover,\n },\n },\n lineSelected: {\n background: theme.palette.action.selected,\n\n '&:hover': {\n background: theme.palette.action.selected,\n },\n },\n lineCopyButton: {\n position: 'absolute',\n paddingTop: 0,\n paddingBottom: 0,\n },\n lineNumber: {\n display: 'inline-block',\n textAlign: 'end',\n width: 60,\n marginRight: theme.spacing(1),\n cursor: 'pointer',\n },\n textHighlight: {\n background: alpha(theme.palette.info.main, 0.15),\n },\n textSelectedHighlight: {\n background: alpha(theme.palette.info.main, 0.4),\n },\n modifierBold: {\n fontWeight: theme.typography.fontWeightBold,\n },\n modifierItalic: {\n fontStyle: 'italic',\n },\n modifierUnderline: {\n textDecoration: 'underline',\n },\n modifierForegroundBlack: {\n color: colors.common.black,\n },\n modifierForegroundRed: {\n color: colors.red[500],\n },\n modifierForegroundGreen: {\n color: colors.green[500],\n },\n modifierForegroundYellow: {\n color: colors.yellow[500],\n },\n modifierForegroundBlue: {\n color: colors.blue[500],\n },\n modifierForegroundMagenta: {\n color: colors.purple[500],\n },\n modifierForegroundCyan: {\n color: colors.cyan[500],\n },\n modifierForegroundWhite: {\n color: colors.common.white,\n },\n modifierForegroundGrey: {\n color: colors.grey[500],\n },\n modifierBackgroundBlack: {\n background: colors.common.black,\n },\n modifierBackgroundRed: {\n background: colors.red[500],\n },\n modifierBackgroundGreen: {\n background: colors.green[500],\n },\n modifierBackgroundYellow: {\n background: colors.yellow[500],\n },\n modifierBackgroundBlue: {\n background: colors.blue[500],\n },\n modifierBackgroundMagenta: {\n background: colors.purple[500],\n },\n modifierBackgroundCyan: {\n background: colors.cyan[500],\n },\n modifierBackgroundWhite: {\n background: colors.common.white,\n },\n modifierBackgroundGrey: {\n background: colors.grey[500],\n },\n }),\n { name: 'BackstageLogViewer' },\n);\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\n\nimport startCase from 'lodash/startCase';\nimport classnames from 'classnames';\n\n\nexport function getModifierClasses(\n classes,\n modifiers,\n) {\n const classNames = new Array();\n if (modifiers.bold) {\n classNames.push(classes.modifierBold);\n }\n if (modifiers.italic) {\n classNames.push(classes.modifierItalic);\n }\n if (modifiers.underline) {\n classNames.push(classes.modifierUnderline);\n }\n if (modifiers.foreground) {\n const key = `modifierForeground${startCase(\n modifiers.foreground,\n )}` ;\n classNames.push(classes[key]);\n }\n if (modifiers.background) {\n const key = `modifierBackground${startCase(\n modifiers.background,\n )}` ;\n classNames.push(classes[key]);\n }\n return classNames.length > 0 ? classNames.join(' ') : undefined;\n}\n\nexport function findSearchResults(text, searchText) {\n if (!searchText || !text.includes(searchText)) {\n return undefined;\n }\n const searchResults = new Array();\n let offset = 0;\n for (;;) {\n const start = text.indexOf(searchText, offset);\n if (start === -1) {\n break;\n }\n const end = start + searchText.length;\n searchResults.push({ start, end });\n offset = end;\n }\n return searchResults;\n}\n\n\n\n\n\nexport function calculateHighlightedChunks(\n line,\n searchText,\n) {\n const results = findSearchResults(line.text, searchText);\n if (!results) {\n return line.chunks;\n }\n\n const chunks = new Array();\n\n let lineOffset = 0;\n let resultIndex = 0;\n let result = results[resultIndex];\n for (const chunk of line.chunks) {\n const { text, modifiers } = chunk;\n if (!result || lineOffset + text.length < result.start) {\n chunks.push(chunk);\n lineOffset += text.length;\n continue;\n }\n\n let localOffset = 0;\n while (result) {\n const localStart = Math.max(result.start - lineOffset, 0);\n if (localStart > text.length) {\n break; // The next result is not in this chunk\n }\n\n const localEnd = Math.min(result.end - lineOffset, text.length);\n\n const hasTextBeforeResult = localStart > localOffset;\n if (hasTextBeforeResult) {\n chunks.push({ text: text.slice(localOffset, localStart), modifiers });\n }\n const hasResultText = localEnd > localStart;\n if (hasResultText) {\n chunks.push({\n modifiers,\n highlight: resultIndex,\n text: text.slice(localStart, localEnd),\n });\n }\n\n localOffset = localEnd;\n\n const foundCompleteResult = result.end - lineOffset === localEnd;\n if (foundCompleteResult) {\n resultIndex += 1;\n result = results[resultIndex];\n } else {\n break; // The rest of the result is in the following chunks\n }\n }\n\n const hasTextAfterResult = localOffset < text.length;\n if (hasTextAfterResult) {\n chunks.push({ text: text.slice(localOffset), modifiers });\n }\n\n lineOffset += text.length;\n }\n\n return chunks;\n}\n\n\n\n\n\n\n\n\nexport function LogLine({\n line,\n classes,\n searchText,\n highlightResultIndex,\n}) {\n const chunks = useMemo(\n () => calculateHighlightedChunks(line, searchText),\n [line, searchText],\n );\n\n const elements = useMemo(\n () =>\n chunks.map(({ text, modifiers, highlight }, index) => (\n React.createElement('span', {\n key: index,\n className: classnames(\n getModifierClasses(classes, modifiers),\n highlight !== undefined &&\n (highlight === highlightResultIndex\n ? classes.textSelectedHighlight\n : classes.textHighlight),\n ),}\n \n , text\n )\n )),\n [chunks, highlightResultIndex, classes],\n );\n\n return React.createElement(React.Fragment, null, elements);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport IconButton from '@material-ui/core/IconButton';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport ChevronLeftIcon from '@material-ui/icons/ChevronLeft';\nimport ChevronRightIcon from '@material-ui/icons/ChevronRight';\nimport FilterListIcon from '@material-ui/icons/FilterList';\n\n\n\n\nexport function LogViewerControls(props) {\n const { resultCount, resultIndexStep, toggleShouldFilter } = props;\n const resultIndex = props.resultIndex ?? 0;\n\n const handleKeyPress = (event) => {\n if (event.key === 'Enter') {\n if (event.metaKey || event.ctrlKey || event.altKey) {\n toggleShouldFilter();\n } else {\n resultIndexStep(event.shiftKey);\n }\n }\n };\n\n return (\n React.createElement(React.Fragment, null\n , resultCount !== undefined && (\n React.createElement(React.Fragment, null\n , React.createElement(IconButton, { size: \"small\", onClick: () => resultIndexStep(true),}\n , React.createElement(ChevronLeftIcon, null )\n )\n , React.createElement(Typography, null\n , Math.min(resultIndex + 1, resultCount), \"/\", resultCount\n )\n , React.createElement(IconButton, { size: \"small\", onClick: () => resultIndexStep(),}\n , React.createElement(ChevronRightIcon, null )\n )\n )\n )\n , React.createElement(TextField, {\n size: \"small\",\n variant: \"standard\",\n placeholder: \"Search\",\n value: props.searchInput,\n onKeyPress: handleKeyPress,\n onChange: e => props.setSearchInput(e.target.value),}\n )\n , React.createElement(IconButton, { size: \"small\", onClick: toggleShouldFilter,}\n , props.shouldFilter ? (\n React.createElement(FilterListIcon, { color: \"primary\",} )\n ) : (\n React.createElement(FilterListIcon, { color: \"disabled\",} )\n )\n )\n )\n );\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useMemo, useState } from 'react';\nimport { useToggle } from '@react-hookz/web';\n\n\nexport function applySearchFilter(lines, searchText) {\n if (!searchText) {\n return { lines };\n }\n\n const matchingLines = [];\n const searchResults = [];\n for (const line of lines) {\n if (line.text.includes(searchText)) {\n matchingLines.push(line);\n\n let offset = 0;\n let lineResultIndex = 0;\n for (;;) {\n const start = line.text.indexOf(searchText, offset);\n if (start === -1) {\n break;\n }\n searchResults.push({\n lineNumber: line.lineNumber,\n lineIndex: lineResultIndex++,\n });\n offset = start + searchText.length;\n }\n }\n }\n\n return {\n lines: matchingLines,\n results: searchResults,\n };\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport function useLogViewerSearch(lines) {\n const [searchInput, setSearchInput] = useState('');\n const searchText = searchInput.toLocaleLowerCase('en-US');\n\n const [resultIndex, setResultIndex] = useState(0);\n\n const [shouldFilter, toggleShouldFilter] = useToggle(false);\n\n const filter = useMemo(\n () => applySearchFilter(lines, searchText),\n [lines, searchText],\n );\n\n const searchResult = filter.results\n ? filter.results[Math.min(resultIndex, filter.results.length - 1)]\n : undefined;\n const resultCount = filter.results?.length;\n\n const resultIndexStep = (decrement) => {\n if (decrement) {\n if (resultCount !== undefined) {\n const next = Math.min(resultIndex - 1, resultCount - 2);\n setResultIndex(next < 0 ? resultCount - 1 : next);\n }\n } else {\n if (resultCount !== undefined) {\n const next = resultIndex + 1;\n setResultIndex(next >= resultCount ? 0 : next);\n }\n }\n };\n\n return {\n lines: shouldFilter ? filter.lines : lines,\n searchText,\n searchInput,\n setSearchInput,\n shouldFilter,\n toggleShouldFilter,\n resultCount,\n resultIndex,\n resultIndexStep,\n resultLine: searchResult?.lineNumber,\n resultLineIndex: searchResult?.lineIndex,\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEffect, useState } from 'react';\nimport useCopyToClipboard from 'react-use/lib/useCopyToClipboard';\n\n\nexport function useLogViewerSelection(lines) {\n const errorApi = useApi(errorApiRef);\n const [sel, setSelection] = useState();\n const start = sel ? Math.min(sel.start, sel.end) : undefined;\n const end = sel ? Math.max(sel.start, sel.end) : undefined;\n\n const [{ error }, copyToClipboard] = useCopyToClipboard();\n\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [error, errorApi]);\n\n return {\n shouldShowButton(line) {\n return start === line || end === line;\n },\n isSelected(line) {\n if (!sel) {\n return false;\n }\n return start <= line && line <= end;\n },\n setSelection(line, add) {\n if (add) {\n setSelection(s =>\n s ? { start: s.start, end: line } : { start: line, end: line },\n );\n } else {\n setSelection(s =>\n s?.start === line && s?.end === line\n ? undefined\n : { start: line, end: line },\n );\n }\n },\n copySelection() {\n if (sel) {\n const copyText = lines\n .slice(Math.min(sel.start, sel.end) - 1, Math.max(sel.start, sel.end))\n .map(l => l.chunks.map(c => c.text).join(''))\n .join('\\n');\n copyToClipboard(copyText);\n setSelection(undefined);\n }\n },\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useMemo, useRef } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport IconButton from '@material-ui/core/IconButton';\nimport CopyIcon from '@material-ui/icons/FileCopy';\nimport AutoSizer from 'react-virtualized-auto-sizer';\nimport { FixedSizeList } from 'react-window';\nimport { AnsiProcessor } from './AnsiProcessor';\nimport { HEADER_SIZE, useStyles } from './styles';\nimport classnames from 'classnames';\nimport { LogLine } from './LogLine';\nimport { LogViewerControls } from './LogViewerControls';\nimport { useLogViewerSearch } from './useLogViewerSearch';\nimport { useLogViewerSelection } from './useLogViewerSelection';\n\n\n\n\n\n\nexport function RealLogViewer(props) {\n const classes = useStyles({ classes: props.classes });\n const listRef = useRef(null);\n\n // The processor keeps state that optimizes appending to the text\n const processor = useMemo(() => new AnsiProcessor(), []);\n const lines = processor.process(props.text);\n\n const search = useLogViewerSearch(lines);\n const selection = useLogViewerSelection(lines);\n const location = useLocation();\n\n useEffect(() => {\n if (search.resultLine !== undefined && listRef.current) {\n listRef.current.scrollToItem(search.resultLine - 1, 'center');\n }\n }, [search.resultLine]);\n\n useEffect(() => {\n if (location.hash) {\n // #line-6 -> 6\n const line = parseInt(location.hash.replace(/\\D/g, ''), 10);\n selection.setSelection(line, false);\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleSelectLine = (\n line,\n event,\n ) => {\n selection.setSelection(line, event.shiftKey);\n };\n\n return (\n React.createElement(AutoSizer, null\n , ({ height, width }) => (\n React.createElement('div', { style: { width, height }, className: classes.root,}\n , React.createElement('div', { className: classes.header,}\n , React.createElement(LogViewerControls, { ...search,} )\n )\n , React.createElement(FixedSizeList, {\n ref: listRef,\n className: classes.log,\n height: height - HEADER_SIZE,\n width: width,\n itemData: search.lines,\n itemSize: 20,\n itemCount: search.lines.length,}\n \n , ({ index, style, data }) => {\n const line = data[index];\n const { lineNumber } = line;\n return (\n React.createElement('div', {\n style: { ...style },\n className: classnames(classes.line, {\n [classes.lineSelected]: selection.isSelected(lineNumber),\n }),}\n \n , selection.shouldShowButton(lineNumber) && (\n React.createElement(IconButton, {\n 'data-testid': \"copy-button\",\n size: \"small\",\n className: classes.lineCopyButton,\n onClick: () => selection.copySelection(),}\n \n , React.createElement(CopyIcon, { fontSize: \"inherit\",} )\n )\n )\n , React.createElement('a', {\n role: \"row\",\n target: \"_self\",\n href: `#line-${lineNumber}`,\n className: classes.lineNumber,\n onClick: event => handleSelectLine(lineNumber, event),\n onKeyPress: event => handleSelectLine(lineNumber, event),}\n \n , lineNumber\n )\n , React.createElement(LogLine, {\n line: line,\n classes: classes,\n searchText: search.searchText,\n highlightResultIndex: \n search.resultLine === lineNumber\n ? search.resultLineIndex\n : undefined\n ,}\n )\n )\n );\n }\n )\n )\n )\n )\n );\n}\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/AnsiProcessor.ts","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/styles.ts","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/LogLine.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/LogViewerControls.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/useLogViewerSearch.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/useLogViewerSelection.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/RealLogViewer.tsx"],"names":[],"mappings":"gcAkBA,KAAM,GAAY,UACZ,EAAe,SAGf,EAAgB,OAAO,YAC3B,OAAO,QAAQ,CACb,EAAG,GAAM,KAAK,EAAG,KAAM,KACvB,EAAG,GAAM,KAAK,EAAG,OAAQ,KACzB,EAAG,GAAM,KAAK,EAAG,UAAW,KAC5B,GAAI,CAAC,CAAE,KAAM,KAAM,KAAQ,EAC3B,GAAI,CAAC,CAAE,OAAQ,KAAM,KAAQ,EAC7B,GAAI,CAAC,CAAE,UAAW,KAAM,KAAQ,EAChC,GAAI,GAAM,KAAK,EAAG,WAAY,UAC9B,GAAI,GAAM,KAAK,EAAG,WAAY,QAC9B,GAAI,GAAM,KAAK,EAAG,WAAY,UAC9B,GAAI,GAAM,KAAK,EAAG,WAAY,WAC9B,GAAI,GAAM,KAAK,EAAG,WAAY,SAC9B,GAAI,GAAM,KAAK,EAAG,WAAY,YAC9B,GAAI,GAAM,KAAK,EAAG,WAAY,SAC9B,GAAI,GAAM,KAAK,EAAG,WAAY,UAC9B,GAAI,CAAC,CAAE,WAAY,KAAM,KAAQ,EACjC,GAAI,GAAM,KAAK,EAAG,WAAY,SAC9B,GAAI,GAAM,KAA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BAAoB,KAAe,CACnC,IAAK,EACL,UAAW,EAAQ,IACnB,OAAQ,EAAS,EACjB,MAAO,EACP,SAAU,EAAO,MACjB,SAAU,GACV,UAAW,EAAO,MAAM,QAEtB,CAAC,CAAE,QAAO,QAAO,UAAW,CAC5B,KAAM,GAAO,EAAK,GACZ,CAAE,cAAe,EACvB,MACE,iBAAoB,MAAO,CACzB,MAAO,IAAK,GACZ,UAAW,IAAW,EAAQ,KAAM,EACjC,EAAQ,cAAe,EAAU,WAAW,MAG7C,EAAU,iBAAiB,IAC3B,gBAAoB,IAAY,CAC9B,cAAe,cACf,KAAM,QACN,UAAW,EAAQ,eACnB,QAAS,IAAM,EAAU,iBAEvB,gBAAoB,IAAU,CAAE,SAAU,aAG9C,gBAAoB,IAAK,CACzB,KAAM,MACN,OAAQ,QACR,KAAM,SAAS,IACf,UAAW,EAAQ,WACnB,QAAS,GAAS,EAAiB,EAAY,GAC/C,WAAY,GAAS,EAAiB,EAAY,IAEhD,GAEF,gBAAoB,GAAS,CAC7B,KAAM,EACN,QAAS,EACT,WAAY,EAAO,WACnB,qBACE,EAAO,aAAe,EAClB,EAAO,gBACP","file":"static/8718.8a863f87.chunk.js","sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport ansiRegexMaker from 'ansi-regex';\n\nconst ansiRegex = ansiRegexMaker();\nconst newlineRegex = /\\n\\r?/g;\n\n// A mapping of how each escape code changes the modifiers\nconst codeModifiers = Object.fromEntries(\n Object.entries({\n 1: m => ({ ...m, bold: true }),\n 3: m => ({ ...m, italic: true }),\n 4: m => ({ ...m, underline: true }),\n 22: ({ bold: _, ...m }) => m,\n 23: ({ italic: _, ...m }) => m,\n 24: ({ underline: _, ...m }) => m,\n 30: m => ({ ...m, foreground: 'black' }),\n 31: m => ({ ...m, foreground: 'red' }),\n 32: m => ({ ...m, foreground: 'green' }),\n 33: m => ({ ...m, foreground: 'yellow' }),\n 34: m => ({ ...m, foreground: 'blue' }),\n 35: m => ({ ...m, foreground: 'magenta' }),\n 36: m => ({ ...m, foreground: 'cyan' }),\n 37: m => ({ ...m, foreground: 'white' }),\n 39: ({ foreground: _, ...m }) => m,\n 90: m => ({ ...m, foreground: 'grey' }),\n 40: m => ({ ...m, background: 'black' }),\n 41: m => ({ ...m, background: 'red' }),\n 42: m => ({ ...m, background: 'green' }),\n 43: m => ({ ...m, background: 'yellow' }),\n 44: m => ({ ...m, background: 'blue' }),\n 45: m => ({ ...m, background: 'magenta' }),\n 46: m => ({ ...m, background: 'cyan' }),\n 47: m => ({ ...m, background: 'white' }),\n 49: ({ background: _, ...m }) => m,\n } ).map(\n ([code, modifier]) => [`\\x1b[${code}m`, modifier],\n ),\n);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport class AnsiLine {\n text;\n\n constructor(\n lineNumber = 1,\n chunks = [],\n ) {;this.lineNumber = lineNumber;this.chunks = chunks;\n this.text = chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n\n lastChunk() {\n return this.chunks[this.chunks.length - 1];\n }\n\n replaceLastChunk(newChunks) {\n if (newChunks) {\n this.chunks.splice(this.chunks.length - 1, 1, ...newChunks);\n this.text = this.chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n }\n}\n\nexport class AnsiProcessor {\n text = '';\n lines = [];\n\n /**\n * Processes a chunk of text while keeping internal state that optimizes\n * subsequent processing that appends to the text.\n */\n process(text) {\n if (this.text === text) {\n return this.lines;\n }\n\n if (text.startsWith(this.text)) {\n const lastLineIndex = this.lines.length > 0 ? this.lines.length - 1 : 0;\n const lastLine = this.lines[lastLineIndex] ?? new AnsiLine();\n const lastChunk = lastLine.lastChunk();\n\n const newLines = this.processLines(\n (lastChunk?.text ?? '') + text.slice(this.text.length),\n lastChunk?.modifiers,\n lastLine?.lineNumber,\n );\n lastLine.replaceLastChunk(newLines[0]?.chunks);\n\n this.lines[lastLineIndex] = lastLine;\n this.lines.push(...newLines.slice(1));\n } else {\n this.lines = this.processLines(text);\n }\n this.text = text;\n\n return this.lines;\n }\n\n // Split a chunk of text up into lines and process each line individually\n processLines = (\n text,\n modifiers = {},\n startingLineNumber = 1,\n ) => {\n const lines = [];\n\n let currentModifiers = modifiers;\n let currentLineNumber = startingLineNumber;\n\n let prevIndex = 0;\n newlineRegex.lastIndex = 0;\n for (;;) {\n const match = newlineRegex.exec(text);\n if (!match) {\n const chunks = this.processText(\n text.slice(prevIndex),\n currentModifiers,\n );\n lines.push(new AnsiLine(currentLineNumber, chunks));\n return lines;\n }\n\n const line = text.slice(prevIndex, match.index);\n prevIndex = match.index + match[0].length;\n\n const chunks = this.processText(line, currentModifiers);\n lines.push(new AnsiLine(currentLineNumber, chunks));\n\n // Modifiers that are active in the last chunk are carried over to the next line\n currentModifiers =\n chunks[chunks.length - 1].modifiers ?? currentModifiers;\n currentLineNumber += 1;\n }\n };\n\n // Processing of a one individual text chunk\n processText = (\n fullText,\n modifiers,\n ) => {\n const chunks = [];\n\n let currentModifiers = modifiers;\n\n let prevIndex = 0;\n ansiRegex.lastIndex = 0;\n for (;;) {\n const match = ansiRegex.exec(fullText);\n if (!match) {\n chunks.push({\n text: fullText.slice(prevIndex),\n modifiers: currentModifiers,\n });\n return chunks;\n }\n\n const text = fullText.slice(prevIndex, match.index);\n chunks.push({ text, modifiers: currentModifiers });\n\n // For every escape code that we encounter we keep track of where the\n // next chunk of text starts, and what modifiers it has\n prevIndex = match.index + match[0].length;\n currentModifiers = this.processCode(match[0], currentModifiers);\n }\n };\n\n processCode = (\n code,\n modifiers,\n ) => {\n return codeModifiers[code]?.(modifiers) ?? modifiers;\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { alpha, makeStyles } from '@material-ui/core/styles';\nimport * as colors from '@material-ui/core/colors';\n\nexport const HEADER_SIZE = 40;\n\n/** @public Class keys for overriding LogViewer styles */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport const useStyles = makeStyles(\n theme => ({\n root: {\n background: theme.palette.background.paper,\n },\n header: {\n height: HEADER_SIZE,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n log: {\n fontFamily: '\"Monaco\", monospace',\n fontSize: theme.typography.pxToRem(12),\n },\n line: {\n position: 'relative',\n whiteSpace: 'pre',\n\n '&:hover': {\n background: theme.palette.action.hover,\n },\n },\n lineSelected: {\n background: theme.palette.action.selected,\n\n '&:hover': {\n background: theme.palette.action.selected,\n },\n },\n lineCopyButton: {\n position: 'absolute',\n paddingTop: 0,\n paddingBottom: 0,\n },\n lineNumber: {\n display: 'inline-block',\n textAlign: 'end',\n width: 60,\n marginRight: theme.spacing(1),\n cursor: 'pointer',\n },\n textHighlight: {\n background: alpha(theme.palette.info.main, 0.15),\n },\n textSelectedHighlight: {\n background: alpha(theme.palette.info.main, 0.4),\n },\n modifierBold: {\n fontWeight: theme.typography.fontWeightBold,\n },\n modifierItalic: {\n fontStyle: 'italic',\n },\n modifierUnderline: {\n textDecoration: 'underline',\n },\n modifierForegroundBlack: {\n color: colors.common.black,\n },\n modifierForegroundRed: {\n color: colors.red[500],\n },\n modifierForegroundGreen: {\n color: colors.green[500],\n },\n modifierForegroundYellow: {\n color: colors.yellow[500],\n },\n modifierForegroundBlue: {\n color: colors.blue[500],\n },\n modifierForegroundMagenta: {\n color: colors.purple[500],\n },\n modifierForegroundCyan: {\n color: colors.cyan[500],\n },\n modifierForegroundWhite: {\n color: colors.common.white,\n },\n modifierForegroundGrey: {\n color: colors.grey[500],\n },\n modifierBackgroundBlack: {\n background: colors.common.black,\n },\n modifierBackgroundRed: {\n background: colors.red[500],\n },\n modifierBackgroundGreen: {\n background: colors.green[500],\n },\n modifierBackgroundYellow: {\n background: colors.yellow[500],\n },\n modifierBackgroundBlue: {\n background: colors.blue[500],\n },\n modifierBackgroundMagenta: {\n background: colors.purple[500],\n },\n modifierBackgroundCyan: {\n background: colors.cyan[500],\n },\n modifierBackgroundWhite: {\n background: colors.common.white,\n },\n modifierBackgroundGrey: {\n background: colors.grey[500],\n },\n }),\n { name: 'BackstageLogViewer' },\n);\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\n\nimport startCase from 'lodash/startCase';\nimport classnames from 'classnames';\n\n\nexport function getModifierClasses(\n classes,\n modifiers,\n) {\n const classNames = new Array();\n if (modifiers.bold) {\n classNames.push(classes.modifierBold);\n }\n if (modifiers.italic) {\n classNames.push(classes.modifierItalic);\n }\n if (modifiers.underline) {\n classNames.push(classes.modifierUnderline);\n }\n if (modifiers.foreground) {\n const key = `modifierForeground${startCase(\n modifiers.foreground,\n )}` ;\n classNames.push(classes[key]);\n }\n if (modifiers.background) {\n const key = `modifierBackground${startCase(\n modifiers.background,\n )}` ;\n classNames.push(classes[key]);\n }\n return classNames.length > 0 ? classNames.join(' ') : undefined;\n}\n\nexport function findSearchResults(text, searchText) {\n if (!searchText || !text.includes(searchText)) {\n return undefined;\n }\n const searchResults = new Array();\n let offset = 0;\n for (;;) {\n const start = text.indexOf(searchText, offset);\n if (start === -1) {\n break;\n }\n const end = start + searchText.length;\n searchResults.push({ start, end });\n offset = end;\n }\n return searchResults;\n}\n\n\n\n\n\nexport function calculateHighlightedChunks(\n line,\n searchText,\n) {\n const results = findSearchResults(line.text, searchText);\n if (!results) {\n return line.chunks;\n }\n\n const chunks = new Array();\n\n let lineOffset = 0;\n let resultIndex = 0;\n let result = results[resultIndex];\n for (const chunk of line.chunks) {\n const { text, modifiers } = chunk;\n if (!result || lineOffset + text.length < result.start) {\n chunks.push(chunk);\n lineOffset += text.length;\n continue;\n }\n\n let localOffset = 0;\n while (result) {\n const localStart = Math.max(result.start - lineOffset, 0);\n if (localStart > text.length) {\n break; // The next result is not in this chunk\n }\n\n const localEnd = Math.min(result.end - lineOffset, text.length);\n\n const hasTextBeforeResult = localStart > localOffset;\n if (hasTextBeforeResult) {\n chunks.push({ text: text.slice(localOffset, localStart), modifiers });\n }\n const hasResultText = localEnd > localStart;\n if (hasResultText) {\n chunks.push({\n modifiers,\n highlight: resultIndex,\n text: text.slice(localStart, localEnd),\n });\n }\n\n localOffset = localEnd;\n\n const foundCompleteResult = result.end - lineOffset === localEnd;\n if (foundCompleteResult) {\n resultIndex += 1;\n result = results[resultIndex];\n } else {\n break; // The rest of the result is in the following chunks\n }\n }\n\n const hasTextAfterResult = localOffset < text.length;\n if (hasTextAfterResult) {\n chunks.push({ text: text.slice(localOffset), modifiers });\n }\n\n lineOffset += text.length;\n }\n\n return chunks;\n}\n\n\n\n\n\n\n\n\nexport function LogLine({\n line,\n classes,\n searchText,\n highlightResultIndex,\n}) {\n const chunks = useMemo(\n () => calculateHighlightedChunks(line, searchText),\n [line, searchText],\n );\n\n const elements = useMemo(\n () =>\n chunks.map(({ text, modifiers, highlight }, index) => (\n React.createElement('span', {\n key: index,\n className: classnames(\n getModifierClasses(classes, modifiers),\n highlight !== undefined &&\n (highlight === highlightResultIndex\n ? classes.textSelectedHighlight\n : classes.textHighlight),\n ),}\n \n , text\n )\n )),\n [chunks, highlightResultIndex, classes],\n );\n\n return React.createElement(React.Fragment, null, elements);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport IconButton from '@material-ui/core/IconButton';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport ChevronLeftIcon from '@material-ui/icons/ChevronLeft';\nimport ChevronRightIcon from '@material-ui/icons/ChevronRight';\nimport FilterListIcon from '@material-ui/icons/FilterList';\n\n\n\n\nexport function LogViewerControls(props) {\n const { resultCount, resultIndexStep, toggleShouldFilter } = props;\n const resultIndex = props.resultIndex ?? 0;\n\n const handleKeyPress = (event) => {\n if (event.key === 'Enter') {\n if (event.metaKey || event.ctrlKey || event.altKey) {\n toggleShouldFilter();\n } else {\n resultIndexStep(event.shiftKey);\n }\n }\n };\n\n return (\n React.createElement(React.Fragment, null\n , resultCount !== undefined && (\n React.createElement(React.Fragment, null\n , React.createElement(IconButton, { size: \"small\", onClick: () => resultIndexStep(true),}\n , React.createElement(ChevronLeftIcon, null )\n )\n , React.createElement(Typography, null\n , Math.min(resultIndex + 1, resultCount), \"/\", resultCount\n )\n , React.createElement(IconButton, { size: \"small\", onClick: () => resultIndexStep(),}\n , React.createElement(ChevronRightIcon, null )\n )\n )\n )\n , React.createElement(TextField, {\n size: \"small\",\n variant: \"standard\",\n placeholder: \"Search\",\n value: props.searchInput,\n onKeyPress: handleKeyPress,\n onChange: e => props.setSearchInput(e.target.value),}\n )\n , React.createElement(IconButton, { size: \"small\", onClick: toggleShouldFilter,}\n , props.shouldFilter ? (\n React.createElement(FilterListIcon, { color: \"primary\",} )\n ) : (\n React.createElement(FilterListIcon, { color: \"disabled\",} )\n )\n )\n )\n );\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useMemo, useState } from 'react';\nimport { useToggle } from '@react-hookz/web';\n\n\nexport function applySearchFilter(lines, searchText) {\n if (!searchText) {\n return { lines };\n }\n\n const matchingLines = [];\n const searchResults = [];\n for (const line of lines) {\n if (line.text.includes(searchText)) {\n matchingLines.push(line);\n\n let offset = 0;\n let lineResultIndex = 0;\n for (;;) {\n const start = line.text.indexOf(searchText, offset);\n if (start === -1) {\n break;\n }\n searchResults.push({\n lineNumber: line.lineNumber,\n lineIndex: lineResultIndex++,\n });\n offset = start + searchText.length;\n }\n }\n }\n\n return {\n lines: matchingLines,\n results: searchResults,\n };\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport function useLogViewerSearch(lines) {\n const [searchInput, setSearchInput] = useState('');\n const searchText = searchInput.toLocaleLowerCase('en-US');\n\n const [resultIndex, setResultIndex] = useState(0);\n\n const [shouldFilter, toggleShouldFilter] = useToggle(false);\n\n const filter = useMemo(\n () => applySearchFilter(lines, searchText),\n [lines, searchText],\n );\n\n const searchResult = filter.results\n ? filter.results[Math.min(resultIndex, filter.results.length - 1)]\n : undefined;\n const resultCount = filter.results?.length;\n\n const resultIndexStep = (decrement) => {\n if (decrement) {\n if (resultCount !== undefined) {\n const next = Math.min(resultIndex - 1, resultCount - 2);\n setResultIndex(next < 0 ? resultCount - 1 : next);\n }\n } else {\n if (resultCount !== undefined) {\n const next = resultIndex + 1;\n setResultIndex(next >= resultCount ? 0 : next);\n }\n }\n };\n\n return {\n lines: shouldFilter ? filter.lines : lines,\n searchText,\n searchInput,\n setSearchInput,\n shouldFilter,\n toggleShouldFilter,\n resultCount,\n resultIndex,\n resultIndexStep,\n resultLine: searchResult?.lineNumber,\n resultLineIndex: searchResult?.lineIndex,\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEffect, useState } from 'react';\nimport useCopyToClipboard from 'react-use/lib/useCopyToClipboard';\n\n\nexport function useLogViewerSelection(lines) {\n const errorApi = useApi(errorApiRef);\n const [sel, setSelection] = useState();\n const start = sel ? Math.min(sel.start, sel.end) : undefined;\n const end = sel ? Math.max(sel.start, sel.end) : undefined;\n\n const [{ error }, copyToClipboard] = useCopyToClipboard();\n\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [error, errorApi]);\n\n return {\n shouldShowButton(line) {\n return start === line || end === line;\n },\n isSelected(line) {\n if (!sel) {\n return false;\n }\n return start <= line && line <= end;\n },\n setSelection(line, add) {\n if (add) {\n setSelection(s =>\n s ? { start: s.start, end: line } : { start: line, end: line },\n );\n } else {\n setSelection(s =>\n s?.start === line && s?.end === line\n ? undefined\n : { start: line, end: line },\n );\n }\n },\n copySelection() {\n if (sel) {\n const copyText = lines\n .slice(Math.min(sel.start, sel.end) - 1, Math.max(sel.start, sel.end))\n .map(l => l.chunks.map(c => c.text).join(''))\n .join('\\n');\n copyToClipboard(copyText);\n setSelection(undefined);\n }\n },\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useMemo, useRef } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport IconButton from '@material-ui/core/IconButton';\nimport CopyIcon from '@material-ui/icons/FileCopy';\nimport AutoSizer from 'react-virtualized-auto-sizer';\nimport { FixedSizeList } from 'react-window';\nimport { AnsiProcessor } from './AnsiProcessor';\nimport { HEADER_SIZE, useStyles } from './styles';\nimport classnames from 'classnames';\nimport { LogLine } from './LogLine';\nimport { LogViewerControls } from './LogViewerControls';\nimport { useLogViewerSearch } from './useLogViewerSearch';\nimport { useLogViewerSelection } from './useLogViewerSelection';\n\n\n\n\n\n\nexport function RealLogViewer(props) {\n const classes = useStyles({ classes: props.classes });\n const listRef = useRef(null);\n\n // The processor keeps state that optimizes appending to the text\n const processor = useMemo(() => new AnsiProcessor(), []);\n const lines = processor.process(props.text);\n\n const search = useLogViewerSearch(lines);\n const selection = useLogViewerSelection(lines);\n const location = useLocation();\n\n useEffect(() => {\n if (search.resultLine !== undefined && listRef.current) {\n listRef.current.scrollToItem(search.resultLine - 1, 'center');\n }\n }, [search.resultLine]);\n\n useEffect(() => {\n if (location.hash) {\n // #line-6 -> 6\n const line = parseInt(location.hash.replace(/\\D/g, ''), 10);\n selection.setSelection(line, false);\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleSelectLine = (\n line,\n event,\n ) => {\n selection.setSelection(line, event.shiftKey);\n };\n\n return (\n React.createElement(AutoSizer, null\n , ({ height, width }) => (\n React.createElement('div', { style: { width, height }, className: classes.root,}\n , React.createElement('div', { className: classes.header,}\n , React.createElement(LogViewerControls, { ...search,} )\n )\n , React.createElement(FixedSizeList, {\n ref: listRef,\n className: classes.log,\n height: height - HEADER_SIZE,\n width: width,\n itemData: search.lines,\n itemSize: 20,\n itemCount: search.lines.length,}\n \n , ({ index, style, data }) => {\n const line = data[index];\n const { lineNumber } = line;\n return (\n React.createElement('div', {\n style: { ...style },\n className: classnames(classes.line, {\n [classes.lineSelected]: selection.isSelected(lineNumber),\n }),}\n \n , selection.shouldShowButton(lineNumber) && (\n React.createElement(IconButton, {\n 'data-testid': \"copy-button\",\n size: \"small\",\n className: classes.lineCopyButton,\n onClick: () => selection.copySelection(),}\n \n , React.createElement(CopyIcon, { fontSize: \"inherit\",} )\n )\n )\n , React.createElement('a', {\n role: \"row\",\n target: \"_self\",\n href: `#line-${lineNumber}`,\n className: classes.lineNumber,\n onClick: event => handleSelectLine(lineNumber, event),\n onKeyPress: event => handleSelectLine(lineNumber, event),}\n \n , lineNumber\n )\n , React.createElement(LogLine, {\n line: line,\n classes: classes,\n searchText: search.searchText,\n highlightResultIndex: \n search.resultLine === lineNumber\n ? search.resultLineIndex\n : undefined\n ,}\n )\n )\n );\n }\n )\n )\n )\n )\n );\n}\n"],"sourceRoot":""}