From 4c8cf1e66eb51d445bc4dca3f02e37a414c7047e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christophe=20No=C3=ABl?= Date: Thu, 29 Feb 2024 23:42:13 +0100 Subject: [PATCH] use relative path for js files --- .../{index-C5Goj58V.js => index-BeOzSnWz.js} | 2 +- packages/chord-chart-studio/build/index.html | 18 +++++++++--------- .../chord-chart-studio/build/registerSW.js | 2 +- packages/chord-chart-studio/build/sw.js | 2 +- packages/chord-chart-studio/vite.config.js | 1 + 5 files changed, 13 insertions(+), 12 deletions(-) rename packages/chord-chart-studio/build/assets/{index-C5Goj58V.js => index-BeOzSnWz.js} (77%) diff --git a/packages/chord-chart-studio/build/assets/index-C5Goj58V.js b/packages/chord-chart-studio/build/assets/index-BeOzSnWz.js similarity index 77% rename from packages/chord-chart-studio/build/assets/index-C5Goj58V.js rename to packages/chord-chart-studio/build/assets/index-BeOzSnWz.js index e7e513a..e2bbcf4 100644 --- a/packages/chord-chart-studio/build/assets/index-C5Goj58V.js +++ b/packages/chord-chart-studio/build/assets/index-BeOzSnWz.js @@ -50,7 +50,7 @@ She _broke your throne and she _cut your hair And _from your lips she _drew the halle_lujah #c -`;function Kn(){const e=W(),t=e.getState();Z(t).length===0&&(e.dispatch(U("Hallelujah - Leonard Cohen",Un)),e.dispatch(U("Getting started",Vn)))}class ze extends C.Component{constructor(t){super(t),this.state={error:null,errorInfo:null}}componentDidCatch(t,n){this.setState({error:t,errorInfo:n})}render(){return this.state.errorInfo?r.jsxs("div",{className:"ErrorBoundary",children:[r.jsx("h2",{children:"Something went wrong"}),r.jsxs("details",{style:{whiteSpace:"pre-wrap"},open:!0,children:[this.state.error&&this.state.error.toString(),r.jsx("br",{}),this.state.errorInfo.componentStack]})]}):this.props.children}}ze.propTypes={children:i.any};let z;function Yn(e,t){const n=document.getElementById("app");z||(z=Pe(n)),z.render(r.jsx(It,{store:W(),children:r.jsx(C.StrictMode,{children:r.jsx(ze,{children:r.jsx(e,{...t})})})}))}let K,Ve;const Jn={init(e){const t=e.map(n=>({...n,action:s=>({Controller:n.action,params:s.params})}));K=new Mt(t,{errorHandler(n,s){console.error(`Error: Cannot find route for path: ${s.pathname}`)}}),Ve=Ot(K,{stringifyQueryParams:Ie.stringify})}};function G(e,t=!0){const n=new URL(e,window.location.origin);return K.resolve(n.pathname).then(({Controller:s,params:o}={})=>{if(s){t&&Qn(e);const a=Ie.parse(n.search,{ignoreQueryPrefix:!0});Yn(s,{...o,...a})}})}function Ue(e,t){try{return Ve(e,t)}catch(n){console.error(n.toString())}}function Qn(e){window.history.pushState({url:e},null,e)}window.addEventListener("popstate",()=>{const e=window.location.pathname+window.location.search;G(e,!1)});function Xn(){const t=Me(Z).map(n=>r.jsx(Zn,{song:n},n.id));return r.jsxs("div",{children:["Full Library",r.jsx("ul",{children:t})]})}const Zn=({song:e})=>{const t=n=>{n.preventDefault(),G(Ue("songView",{songId:e.id}))};return r.jsx("li",{children:r.jsx("a",{href:`/song/${e.id}`,onClick:t,children:e.title})})},er=[{name:"library",path:"/library",action:Xn}];function tr({songId:e}){const t=Me(s=>ee(s,e)),n=s=>{s.preventDefault(),G(Ue("library"))};return r.jsxs("div",{children:[r.jsx("a",{href:"",onClick:n,children:"Go back to list"}),r.jsx("br",{}),r.jsx("b",{children:t.title}),r.jsx("p",{children:t.content})]})}const nr=[{name:"songView",path:"/songView/:songId",action:tr}],Ke=e=>v(D,{mode:e}),rr=()=>v(Le),sr=()=>v(ke),ir="/assets/logo-D2B3txiq.svg";function or(){return r.jsx("div",{className:"logo",children:r.jsx("div",{className:"logo-isExpanded",children:r.jsx("div",{className:"logo-img",children:r.jsxs("svg",{className:"stacked",children:[r.jsx("title",{children:"Chord Chart Studio"}),r.jsx("use",{href:ir+"#stacked"})]})})})})}const ar=C.memo(or);function Ye(e){const{iconName:t}=e,n=["icon","material-icons"];return r.jsx("i",{className:n.join(" "),children:t})}Ye.propTypes={iconName:i.string.isRequired};const x=C.memo(Ye);function Je(e){const{label:t,icon:n,editorMode:s,setEditorMode:o,isActive:a,isDisabled:l}=e,c=["mainNavEntry"];a&&c.push("mainNavEntry-isActive"),l&&c.push("mainNavEntry-isDisabled");function d(){l||o(s)}return r.jsxs("li",{className:c.join(" "),onClick:d,children:[r.jsx("span",{className:"mainNavEntry-icon",children:r.jsx(x,{iconName:n})}),t]})}Je.propTypes={label:i.string.isRequired,icon:i.string.isRequired,editorMode:i.string.isRequired,setEditorMode:i.func.isRequired,isActive:i.bool.isRequired,isDisabled:i.bool.isRequired};const lr=C.memo(Je);function Qe(e){const{currentMode:t,allEntries:n,setEditorMode:s,selectedId:o}=e;return r.jsx("nav",{className:"mainNav",children:r.jsx("ul",{className:"mainNav-entries",children:n.map((a,l)=>r.jsx(lr,{isActive:!!o&&a.editorMode===t,isDisabled:!o,setEditorMode:s,...a},l))})})}Qe.propTypes={currentMode:i.string.isRequired,setEditorMode:i.func.isRequired,selectedId:i.string,allEntries:i.arrayOf(i.shape({id:i.string.isRequired,label:i.string.isRequired,icon:i.string.isRequired,editorMode:i.string.isRequired}))};const cr=C.memo(Qe),E=({children:e,isDisabled:t,buttonName:n,onClick:s,type:o})=>{const a=["Button"];return o==="primary"&&a.push("Button-primary"),o==="secondary"&&a.push("Button-secondary"),t&&a.push("Button-isDisabled"),r.jsx("button",{className:a.join(" "),disabled:t,type:"button",name:n,onClick:s,children:e})};E.propTypes={children:i.string.isRequired,isDisabled:i.bool,buttonName:i.string.isRequired,type:i.string.isRequired,onClick:i.func.isRequired};E.defaultProps={isDisabled:!1};const dr="https://chord-chart-studio.netlify.app",ie=()=>{const e=()=>{window.open(dr,"_blank").focus()};return r.jsxs("div",{className:"userGuide",children:[r.jsx("div",{className:"userGuide-isCollapsed",children:r.jsx(x,{iconName:"help_outline"})}),r.jsx("div",{className:"userGuide-isExpanded",children:r.jsx(E,{buttonName:"userGuide",type:"primary",onClick:e,children:"User Guide"})})]})};ie.propTypes={};ie.defaultProps={};const ur=C.memo(ie),pr=()=>({"chord-chart-studio":"v0.14.0","chord-symbol":"v4.0.0","chord-mark":"v0.16.2"});function mr(){const e=pr();return r.jsx("div",{className:"versions",children:r.jsxs("div",{className:"versions-isExpanded",children:["Chord Chart Studio ",e["chord-chart-studio"],r.jsx("br",{}),"ChordMark ",e["chord-mark"]," ",r.jsx("br",{}),"ChordSymbol ",e["chord-symbol"]," ",r.jsx("br",{}),"Logo by"," ",r.jsx("a",{href:"https://spelling-bee-assistant.app/",target:"_blank",rel:"noreferrer",children:"Dieter Raber"})]})})}const hr=C.memo(mr),gr=e=>e.songImporter.content,fr=e=>e.songImporter.inputFormat,yr=e=>e.songImporter.title,br=e=>e.songImporter.isImporting,xr=e=>e.songImporter.isFromWeb;function oe(e){const{children:t,closeModal:n}=e;return R.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keyup",s),()=>{window.removeEventListener("keyup",s)}}),r.jsxs("section",{className:"mod-ModalContainer",children:[r.jsx("div",{className:"mod-Overlay",onClick:n,"data-testid":"modal-overlay"}),r.jsx("div",{className:"mod-ContentContainer",children:t})]})}oe.propTypes={children:i.element.isRequired,closeModal:i.func.isRequired};const Xe=({cancelImport:e,chordMarkContent:t,importFile:n,title:s,content:o,error:a})=>{const l=s?'Import "'+s+'"':"Import song",c=()=>{n(s||"[untitled]",t)};return r.jsxs("div",{className:"sim-Header_Container",children:[r.jsx("div",{className:"sim-Header_Title",children:l}),r.jsxs("div",{className:"sim-Header_Actions",children:[r.jsx(E,{onClick:e,buttonName:"cancel",type:"secondary",children:"CANCEL"}),r.jsx(E,{onClick:c,buttonName:"import",type:"primary",isDisabled:o===""||a!=="",children:"IMPORT"})]})]})};Xe.propTypes={cancelImport:i.func.isRequired,chordMarkContent:i.string,content:i.string,error:i.string,importFile:i.func.isRequired,title:i.string};const Ze=50*1024,Cr=e=>new Promise((t,n)=>{if(e.length){const s=e[0];Rr(s)?n(Fr(s.size)):vr(s)?s.text().then(o=>{t({content:o,title:jr(s)})}).catch(o=>{n(o)}):n(Tr(s))}else n(Nr())}),jr=e=>e.name.substr(0,e.name.lastIndexOf(".")),Rr=e=>e.size>Ze,vr=e=>e.type.indexOf("text")===0||e.type.length===0,Fr=e=>"The selected file is too big: "+ve(e,{round:0})+" (maximum allowed file size is "+ve(Ze,{round:0})+").",Tr=e=>"Cannot import file of type "+e.type+".",Nr=()=>"No file selected.",Sr="text/*,.cho,.crd,.chopro,.chord,.pro,.txt,.md",et=({setContent:e})=>{const t=n=>{Cr(n.target.files).then(s=>{e(s.content,s.title)}).catch(s=>{e(s)})};return r.jsxs("div",{children:[r.jsx("label",{htmlFor:"importSong-Input",className:"Button Button-primary",children:"Select File"}),r.jsx("input",{id:"importSong-Input",name:"importSong-Input",type:"file",className:"sim-InputFile_Input",onChange:t,accept:Sr})]})};et.propTypes={setContent:i.func.isRequired};function ae(e){const{content:t,setContent:n,isDisabled:s}=e,o=l=>{n(l.target.value)},a=["sim-Input_Textarea"];return s&&a.push("sim-Input_Textarea-Disabled"),r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"sim-Input_Header",children:[r.jsx(x,{iconName:"arrow_drop_down"}),"Copy/paste below",r.jsx(x,{iconName:"arrow_drop_down"})]}),r.jsx("textarea",{className:a.join(" "),onChange:o,value:t,disabled:s,"data-testid":"sim-input"})]})}ae.propTypes={content:i.string.isRequired,isDisabled:i.bool.isRequired,setContent:i.func.isRequired};ae.defaultProps={};function le(e){const{inputFormat:t,error:n}=e;return r.jsxs("div",{className:"sim-Preview_Error",children:[r.jsxs("p",{children:["There was an error when trying to parse the song in the specified input format (",t,").",r.jsx("br",{}),"Please correct the input or try another format.",r.jsx("br",{}),"The error was:"]}),r.jsxs("p",{children:['"',n,'"']}),r.jsx("p",{children:'Hint: most of the time, this is related to an unclosed "[" or "{" or an unsupported ChordPro directive'})]})}le.propTypes={error:i.string,inputFormat:i.string.isRequired};le.defaultProps={};function ce(e){const{setInputFormat:t,inputFormat:n,id:s,label:o,isDisabled:a}=e,l=u=>{a||t(u.target.value)},c=["sim-InputFormat_Entry"],d=["sim-InputFormat_Label"];return a&&(c.push("sim-InputFormat_Entry-Disabled"),d.push("sim-InputFormat_Label-Disabled")),r.jsxs(r.Fragment,{children:[r.jsx("input",{className:c.join(" "),type:"radio",name:"inputFormat",id:s,value:s,onChange:l,checked:n===s}),r.jsx("label",{className:d.join(" "),htmlFor:s,children:o})]})}ce.propTypes={setInputFormat:i.func.isRequired,inputFormat:i.string.isRequired,id:i.string.isRequired,label:i.string.isRequired,isDisabled:i.bool.isRequired};ce.defaultProps={};const wr=[{id:"auto",label:"Detect"},{id:"chordPro",label:"Bracketed chords (ChordPro)"},{id:"chordsOverLyrics",label:"Chords over lyrics (Ultimate Guitar...)"}];function de(e){const{setInputFormat:t,inputFormat:n,disableAll:s}=e,o=wr.map(a=>r.jsx(ce,{setInputFormat:t,id:a.id,label:a.label,inputFormat:n,isDisabled:s},a.id));return r.jsxs("div",{className:"sim-InputFormat",children:["Input format:",o]})}de.propTypes={disableAll:i.bool.isRequired,setInputFormat:i.func.isRequired,inputFormat:i.string.isRequired};de.defaultProps={};function ue(e){const{cancelImport:t,content:n,importFile:s,isFromWeb:o,isImporting:a,setContent:l,setInputFormat:c,inputFormat:d,title:u}=e;if(!a)return null;let h="",m="";try{h=Lt(n,{inputFormat:d})}catch(f){m=f.message}return r.jsx(oe,{closeModal:t,children:r.jsxs("div",{className:"sim-SongImporterModal_Container","data-testid":"song-importer",children:[r.jsx(Xe,{cancelImport:t,chordMarkContent:h,content:n,error:m,importFile:s,title:u}),r.jsxs("div",{className:"sim-TwoColumns_Container",children:[r.jsx("div",{className:"sim-Column_Container",children:r.jsx(et,{setContent:l})}),r.jsx("div",{className:"sim-Column_Container",children:r.jsx(de,{inputFormat:d,setInputFormat:c,disableAll:o===!0})})]}),r.jsxs("div",{className:"sim-TwoColumns_Container sim-TwoColumns_Container-autoHeight",children:[r.jsx("div",{className:"sim-Column_Container",children:r.jsx(ae,{content:n,setContent:l,isDisabled:o})}),r.jsxs("div",{className:"sim-Column_Container",children:[r.jsxs("div",{className:"sim-Input_Header",children:[r.jsx(x,{iconName:"arrow_drop_down"}),"ChordMark preview",r.jsx(x,{iconName:"arrow_drop_down"})]}),r.jsx("div",{className:"sim-Preview_Container","data-testid":"sim-preview",children:m?r.jsx(le,{inputFormat:d,error:m}):h})]})]})]})})}ue.propTypes={cancelImport:i.func.isRequired,content:i.string.isRequired,importFile:i.func.isRequired,isFromWeb:i.bool.isRequired,isImporting:i.bool.isRequired,setContent:i.func.isRequired,setInputFormat:i.func.isRequired,inputFormat:i.string.isRequired,title:i.string};ue.defaultProps={};const Er=N(e=>({content:gr(e),isFromWeb:xr(e),isImporting:br(e),inputFormat:fr(e),title:yr(e)}),{setContent:Mn,setInputFormat:On,cancelImport:Bn,importFile:U})(ue),_r=[{id:"edit",label:"Edit",icon:"create",editorMode:"edit"},{id:"play",label:"Screen view",icon:"music_note",editorMode:"play"},{id:"print",label:"Print/PDF Preview",icon:"print",editorMode:"print"},{id:"export",label:"Export Preview",icon:"save_alt",editorMode:"export"}];function pe(e){const{editorMode:t,isLeftBarCollapsed:n,isRightBarCollapsed:s,toggleLeftBar:o,toggleRightBar:a,setEditorMode:l,selectedId:c,leftBar:d,rightBar:u}=e,h=["leftBar"];n&&h.push("leftBar-isCollapsed");const m=["rightBar"];return s&&m.push("rightBar-isCollapsed"),r.jsxs("div",{className:"appLayout-wrapper",children:[r.jsx(Er,{}),r.jsxs("section",{className:h.join(" "),children:[r.jsxs("div",{className:"leftBar-content",onClick:n?o:null,children:[r.jsx(ar,{}),d]}),r.jsx("div",{className:"leftBar-collapser",onClick:o,"data-testid":"leftBar-collapser",children:r.jsx("span",{className:"leftBar-collapserIcon",children:r.jsx(x,{iconName:"keyboard_arrow_left"})})})]}),r.jsxs("section",{className:"appLayout-main",children:[r.jsx("section",{className:"appLayout-header",children:r.jsx(cr,{allEntries:_r,currentMode:t,setEditorMode:l,selectedId:c})}),r.jsx("section",{className:"appLayout-content",children:e.children})]}),r.jsxs("section",{className:m.join(" "),children:[r.jsx("div",{className:"rightBar-collapser",onClick:a,"data-testid":"rightBar-collapser",children:r.jsx("span",{className:"rightBar-collapserIcon",children:r.jsx(x,{iconName:"keyboard_arrow_right"})})}),r.jsxs("div",{className:"rightBar-content",onClick:s?a:null,children:[r.jsx(ur,{}),u,r.jsx(hr,{})]})]})]})}pe.propTypes={children:i.element,isLeftBarCollapsed:i.bool,isRightBarCollapsed:i.bool,selectedId:i.string,toggleLeftBar:i.func.isRequired,toggleRightBar:i.func.isRequired,editorMode:i.string.isRequired,setEditorMode:i.func.isRequired,leftBar:i.element.isRequired,rightBar:i.element.isRequired};pe.defaultProps={isLeftBarCollapsed:!1,isRightBarCollapsed:!1};const qr=N(e=>({editorMode:_(e),isLeftBarCollapsed:tn(e),isRightBarCollapsed:nn(e),selectedId:S(e)}),{toggleLeftBar:rr,toggleRightBar:sr,setEditorMode:Ke})(pe),Pr=e=>v(re,{id:e}),Ir=e=>v(Ae,{id:e});function Mr(e,t={},n=!1){return nt(e,t,n,"text")}function tt(e,t={},n=!1){return nt(e,t,n,"html")}function nt(e,t,n,s){if(n)switch(t.chartFormat){case"chordmark":{const a=M(e,t);return s==="html"?a:Se(a)}case"chordmarkSrc":return s==="html"?V(e):e;case"chordpro":{t.customRenderer=At();const a=M(e,t);return s==="html"?V(a):a}case"ultimateGuitar":{t.customRenderer=Fe();const a=M(e,{...t,customRenderer:Fe(),printBarSeparators:"grids",printChordsDuration:"never",printSubBeatDelimiters:!1,printInlineTimeSignatures:!1,chordSymbolRenderer:kt({customFilters:[Bt()],useShortNamings:!0,accidentalsType:t.accidentalsType==="auto"?"original":t.accidentalsType,...t})})+` +`;function Kn(){const e=W(),t=e.getState();Z(t).length===0&&(e.dispatch(U("Hallelujah - Leonard Cohen",Un)),e.dispatch(U("Getting started",Vn)))}class ze extends C.Component{constructor(t){super(t),this.state={error:null,errorInfo:null}}componentDidCatch(t,n){this.setState({error:t,errorInfo:n})}render(){return this.state.errorInfo?r.jsxs("div",{className:"ErrorBoundary",children:[r.jsx("h2",{children:"Something went wrong"}),r.jsxs("details",{style:{whiteSpace:"pre-wrap"},open:!0,children:[this.state.error&&this.state.error.toString(),r.jsx("br",{}),this.state.errorInfo.componentStack]})]}):this.props.children}}ze.propTypes={children:i.any};let z;function Yn(e,t){const n=document.getElementById("app");z||(z=Pe(n)),z.render(r.jsx(It,{store:W(),children:r.jsx(C.StrictMode,{children:r.jsx(ze,{children:r.jsx(e,{...t})})})}))}let K,Ve;const Jn={init(e){const t=e.map(n=>({...n,action:s=>({Controller:n.action,params:s.params})}));K=new Mt(t,{errorHandler(n,s){console.error(`Error: Cannot find route for path: ${s.pathname}`)}}),Ve=Ot(K,{stringifyQueryParams:Ie.stringify})}};function G(e,t=!0){const n=new URL(e,window.location.origin);return K.resolve(n.pathname).then(({Controller:s,params:o}={})=>{if(s){t&&Qn(e);const a=Ie.parse(n.search,{ignoreQueryPrefix:!0});Yn(s,{...o,...a})}})}function Ue(e,t){try{return Ve(e,t)}catch(n){console.error(n.toString())}}function Qn(e){window.history.pushState({url:e},null,e)}window.addEventListener("popstate",()=>{const e=window.location.pathname+window.location.search;G(e,!1)});function Xn(){const t=Me(Z).map(n=>r.jsx(Zn,{song:n},n.id));return r.jsxs("div",{children:["Full Library",r.jsx("ul",{children:t})]})}const Zn=({song:e})=>{const t=n=>{n.preventDefault(),G(Ue("songView",{songId:e.id}))};return r.jsx("li",{children:r.jsx("a",{href:`/song/${e.id}`,onClick:t,children:e.title})})},er=[{name:"library",path:"/library",action:Xn}];function tr({songId:e}){const t=Me(s=>ee(s,e)),n=s=>{s.preventDefault(),G(Ue("library"))};return r.jsxs("div",{children:[r.jsx("a",{href:"",onClick:n,children:"Go back to list"}),r.jsx("br",{}),r.jsx("b",{children:t.title}),r.jsx("p",{children:t.content})]})}const nr=[{name:"songView",path:"/songView/:songId",action:tr}],Ke=e=>v(D,{mode:e}),rr=()=>v(Le),sr=()=>v(ke),ir=""+new URL("logo-D2B3txiq.svg",import.meta.url).href;function or(){return r.jsx("div",{className:"logo",children:r.jsx("div",{className:"logo-isExpanded",children:r.jsx("div",{className:"logo-img",children:r.jsxs("svg",{className:"stacked",children:[r.jsx("title",{children:"Chord Chart Studio"}),r.jsx("use",{href:ir+"#stacked"})]})})})})}const ar=C.memo(or);function Ye(e){const{iconName:t}=e,n=["icon","material-icons"];return r.jsx("i",{className:n.join(" "),children:t})}Ye.propTypes={iconName:i.string.isRequired};const x=C.memo(Ye);function Je(e){const{label:t,icon:n,editorMode:s,setEditorMode:o,isActive:a,isDisabled:l}=e,c=["mainNavEntry"];a&&c.push("mainNavEntry-isActive"),l&&c.push("mainNavEntry-isDisabled");function d(){l||o(s)}return r.jsxs("li",{className:c.join(" "),onClick:d,children:[r.jsx("span",{className:"mainNavEntry-icon",children:r.jsx(x,{iconName:n})}),t]})}Je.propTypes={label:i.string.isRequired,icon:i.string.isRequired,editorMode:i.string.isRequired,setEditorMode:i.func.isRequired,isActive:i.bool.isRequired,isDisabled:i.bool.isRequired};const lr=C.memo(Je);function Qe(e){const{currentMode:t,allEntries:n,setEditorMode:s,selectedId:o}=e;return r.jsx("nav",{className:"mainNav",children:r.jsx("ul",{className:"mainNav-entries",children:n.map((a,l)=>r.jsx(lr,{isActive:!!o&&a.editorMode===t,isDisabled:!o,setEditorMode:s,...a},l))})})}Qe.propTypes={currentMode:i.string.isRequired,setEditorMode:i.func.isRequired,selectedId:i.string,allEntries:i.arrayOf(i.shape({id:i.string.isRequired,label:i.string.isRequired,icon:i.string.isRequired,editorMode:i.string.isRequired}))};const cr=C.memo(Qe),E=({children:e,isDisabled:t,buttonName:n,onClick:s,type:o})=>{const a=["Button"];return o==="primary"&&a.push("Button-primary"),o==="secondary"&&a.push("Button-secondary"),t&&a.push("Button-isDisabled"),r.jsx("button",{className:a.join(" "),disabled:t,type:"button",name:n,onClick:s,children:e})};E.propTypes={children:i.string.isRequired,isDisabled:i.bool,buttonName:i.string.isRequired,type:i.string.isRequired,onClick:i.func.isRequired};E.defaultProps={isDisabled:!1};const dr="https://chord-chart-studio.netlify.app",ie=()=>{const e=()=>{window.open(dr,"_blank").focus()};return r.jsxs("div",{className:"userGuide",children:[r.jsx("div",{className:"userGuide-isCollapsed",children:r.jsx(x,{iconName:"help_outline"})}),r.jsx("div",{className:"userGuide-isExpanded",children:r.jsx(E,{buttonName:"userGuide",type:"primary",onClick:e,children:"User Guide"})})]})};ie.propTypes={};ie.defaultProps={};const ur=C.memo(ie),pr=()=>({"chord-chart-studio":"v0.14.0","chord-symbol":"v4.0.0","chord-mark":"v0.16.2"});function mr(){const e=pr();return r.jsx("div",{className:"versions",children:r.jsxs("div",{className:"versions-isExpanded",children:["Chord Chart Studio ",e["chord-chart-studio"],r.jsx("br",{}),"ChordMark ",e["chord-mark"]," ",r.jsx("br",{}),"ChordSymbol ",e["chord-symbol"]," ",r.jsx("br",{}),"Logo by"," ",r.jsx("a",{href:"https://spelling-bee-assistant.app/",target:"_blank",rel:"noreferrer",children:"Dieter Raber"})]})})}const hr=C.memo(mr),gr=e=>e.songImporter.content,fr=e=>e.songImporter.inputFormat,yr=e=>e.songImporter.title,br=e=>e.songImporter.isImporting,xr=e=>e.songImporter.isFromWeb;function oe(e){const{children:t,closeModal:n}=e;return R.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keyup",s),()=>{window.removeEventListener("keyup",s)}}),r.jsxs("section",{className:"mod-ModalContainer",children:[r.jsx("div",{className:"mod-Overlay",onClick:n,"data-testid":"modal-overlay"}),r.jsx("div",{className:"mod-ContentContainer",children:t})]})}oe.propTypes={children:i.element.isRequired,closeModal:i.func.isRequired};const Xe=({cancelImport:e,chordMarkContent:t,importFile:n,title:s,content:o,error:a})=>{const l=s?'Import "'+s+'"':"Import song",c=()=>{n(s||"[untitled]",t)};return r.jsxs("div",{className:"sim-Header_Container",children:[r.jsx("div",{className:"sim-Header_Title",children:l}),r.jsxs("div",{className:"sim-Header_Actions",children:[r.jsx(E,{onClick:e,buttonName:"cancel",type:"secondary",children:"CANCEL"}),r.jsx(E,{onClick:c,buttonName:"import",type:"primary",isDisabled:o===""||a!=="",children:"IMPORT"})]})]})};Xe.propTypes={cancelImport:i.func.isRequired,chordMarkContent:i.string,content:i.string,error:i.string,importFile:i.func.isRequired,title:i.string};const Ze=50*1024,Cr=e=>new Promise((t,n)=>{if(e.length){const s=e[0];Rr(s)?n(Fr(s.size)):vr(s)?s.text().then(o=>{t({content:o,title:jr(s)})}).catch(o=>{n(o)}):n(Tr(s))}else n(Nr())}),jr=e=>e.name.substr(0,e.name.lastIndexOf(".")),Rr=e=>e.size>Ze,vr=e=>e.type.indexOf("text")===0||e.type.length===0,Fr=e=>"The selected file is too big: "+ve(e,{round:0})+" (maximum allowed file size is "+ve(Ze,{round:0})+").",Tr=e=>"Cannot import file of type "+e.type+".",Nr=()=>"No file selected.",Sr="text/*,.cho,.crd,.chopro,.chord,.pro,.txt,.md",et=({setContent:e})=>{const t=n=>{Cr(n.target.files).then(s=>{e(s.content,s.title)}).catch(s=>{e(s)})};return r.jsxs("div",{children:[r.jsx("label",{htmlFor:"importSong-Input",className:"Button Button-primary",children:"Select File"}),r.jsx("input",{id:"importSong-Input",name:"importSong-Input",type:"file",className:"sim-InputFile_Input",onChange:t,accept:Sr})]})};et.propTypes={setContent:i.func.isRequired};function ae(e){const{content:t,setContent:n,isDisabled:s}=e,o=l=>{n(l.target.value)},a=["sim-Input_Textarea"];return s&&a.push("sim-Input_Textarea-Disabled"),r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"sim-Input_Header",children:[r.jsx(x,{iconName:"arrow_drop_down"}),"Copy/paste below",r.jsx(x,{iconName:"arrow_drop_down"})]}),r.jsx("textarea",{className:a.join(" "),onChange:o,value:t,disabled:s,"data-testid":"sim-input"})]})}ae.propTypes={content:i.string.isRequired,isDisabled:i.bool.isRequired,setContent:i.func.isRequired};ae.defaultProps={};function le(e){const{inputFormat:t,error:n}=e;return r.jsxs("div",{className:"sim-Preview_Error",children:[r.jsxs("p",{children:["There was an error when trying to parse the song in the specified input format (",t,").",r.jsx("br",{}),"Please correct the input or try another format.",r.jsx("br",{}),"The error was:"]}),r.jsxs("p",{children:['"',n,'"']}),r.jsx("p",{children:'Hint: most of the time, this is related to an unclosed "[" or "{" or an unsupported ChordPro directive'})]})}le.propTypes={error:i.string,inputFormat:i.string.isRequired};le.defaultProps={};function ce(e){const{setInputFormat:t,inputFormat:n,id:s,label:o,isDisabled:a}=e,l=u=>{a||t(u.target.value)},c=["sim-InputFormat_Entry"],d=["sim-InputFormat_Label"];return a&&(c.push("sim-InputFormat_Entry-Disabled"),d.push("sim-InputFormat_Label-Disabled")),r.jsxs(r.Fragment,{children:[r.jsx("input",{className:c.join(" "),type:"radio",name:"inputFormat",id:s,value:s,onChange:l,checked:n===s}),r.jsx("label",{className:d.join(" "),htmlFor:s,children:o})]})}ce.propTypes={setInputFormat:i.func.isRequired,inputFormat:i.string.isRequired,id:i.string.isRequired,label:i.string.isRequired,isDisabled:i.bool.isRequired};ce.defaultProps={};const wr=[{id:"auto",label:"Detect"},{id:"chordPro",label:"Bracketed chords (ChordPro)"},{id:"chordsOverLyrics",label:"Chords over lyrics (Ultimate Guitar...)"}];function de(e){const{setInputFormat:t,inputFormat:n,disableAll:s}=e,o=wr.map(a=>r.jsx(ce,{setInputFormat:t,id:a.id,label:a.label,inputFormat:n,isDisabled:s},a.id));return r.jsxs("div",{className:"sim-InputFormat",children:["Input format:",o]})}de.propTypes={disableAll:i.bool.isRequired,setInputFormat:i.func.isRequired,inputFormat:i.string.isRequired};de.defaultProps={};function ue(e){const{cancelImport:t,content:n,importFile:s,isFromWeb:o,isImporting:a,setContent:l,setInputFormat:c,inputFormat:d,title:u}=e;if(!a)return null;let h="",m="";try{h=Lt(n,{inputFormat:d})}catch(f){m=f.message}return r.jsx(oe,{closeModal:t,children:r.jsxs("div",{className:"sim-SongImporterModal_Container","data-testid":"song-importer",children:[r.jsx(Xe,{cancelImport:t,chordMarkContent:h,content:n,error:m,importFile:s,title:u}),r.jsxs("div",{className:"sim-TwoColumns_Container",children:[r.jsx("div",{className:"sim-Column_Container",children:r.jsx(et,{setContent:l})}),r.jsx("div",{className:"sim-Column_Container",children:r.jsx(de,{inputFormat:d,setInputFormat:c,disableAll:o===!0})})]}),r.jsxs("div",{className:"sim-TwoColumns_Container sim-TwoColumns_Container-autoHeight",children:[r.jsx("div",{className:"sim-Column_Container",children:r.jsx(ae,{content:n,setContent:l,isDisabled:o})}),r.jsxs("div",{className:"sim-Column_Container",children:[r.jsxs("div",{className:"sim-Input_Header",children:[r.jsx(x,{iconName:"arrow_drop_down"}),"ChordMark preview",r.jsx(x,{iconName:"arrow_drop_down"})]}),r.jsx("div",{className:"sim-Preview_Container","data-testid":"sim-preview",children:m?r.jsx(le,{inputFormat:d,error:m}):h})]})]})]})})}ue.propTypes={cancelImport:i.func.isRequired,content:i.string.isRequired,importFile:i.func.isRequired,isFromWeb:i.bool.isRequired,isImporting:i.bool.isRequired,setContent:i.func.isRequired,setInputFormat:i.func.isRequired,inputFormat:i.string.isRequired,title:i.string};ue.defaultProps={};const Er=N(e=>({content:gr(e),isFromWeb:xr(e),isImporting:br(e),inputFormat:fr(e),title:yr(e)}),{setContent:Mn,setInputFormat:On,cancelImport:Bn,importFile:U})(ue),_r=[{id:"edit",label:"Edit",icon:"create",editorMode:"edit"},{id:"play",label:"Screen view",icon:"music_note",editorMode:"play"},{id:"print",label:"Print/PDF Preview",icon:"print",editorMode:"print"},{id:"export",label:"Export Preview",icon:"save_alt",editorMode:"export"}];function pe(e){const{editorMode:t,isLeftBarCollapsed:n,isRightBarCollapsed:s,toggleLeftBar:o,toggleRightBar:a,setEditorMode:l,selectedId:c,leftBar:d,rightBar:u}=e,h=["leftBar"];n&&h.push("leftBar-isCollapsed");const m=["rightBar"];return s&&m.push("rightBar-isCollapsed"),r.jsxs("div",{className:"appLayout-wrapper",children:[r.jsx(Er,{}),r.jsxs("section",{className:h.join(" "),children:[r.jsxs("div",{className:"leftBar-content",onClick:n?o:null,children:[r.jsx(ar,{}),d]}),r.jsx("div",{className:"leftBar-collapser",onClick:o,"data-testid":"leftBar-collapser",children:r.jsx("span",{className:"leftBar-collapserIcon",children:r.jsx(x,{iconName:"keyboard_arrow_left"})})})]}),r.jsxs("section",{className:"appLayout-main",children:[r.jsx("section",{className:"appLayout-header",children:r.jsx(cr,{allEntries:_r,currentMode:t,setEditorMode:l,selectedId:c})}),r.jsx("section",{className:"appLayout-content",children:e.children})]}),r.jsxs("section",{className:m.join(" "),children:[r.jsx("div",{className:"rightBar-collapser",onClick:a,"data-testid":"rightBar-collapser",children:r.jsx("span",{className:"rightBar-collapserIcon",children:r.jsx(x,{iconName:"keyboard_arrow_right"})})}),r.jsxs("div",{className:"rightBar-content",onClick:s?a:null,children:[r.jsx(ur,{}),u,r.jsx(hr,{})]})]})]})}pe.propTypes={children:i.element,isLeftBarCollapsed:i.bool,isRightBarCollapsed:i.bool,selectedId:i.string,toggleLeftBar:i.func.isRequired,toggleRightBar:i.func.isRequired,editorMode:i.string.isRequired,setEditorMode:i.func.isRequired,leftBar:i.element.isRequired,rightBar:i.element.isRequired};pe.defaultProps={isLeftBarCollapsed:!1,isRightBarCollapsed:!1};const qr=N(e=>({editorMode:_(e),isLeftBarCollapsed:tn(e),isRightBarCollapsed:nn(e),selectedId:S(e)}),{toggleLeftBar:rr,toggleRightBar:sr,setEditorMode:Ke})(pe),Pr=e=>v(re,{id:e}),Ir=e=>v(Ae,{id:e});function Mr(e,t={},n=!1){return nt(e,t,n,"text")}function tt(e,t={},n=!1){return nt(e,t,n,"html")}function nt(e,t,n,s){if(n)switch(t.chartFormat){case"chordmark":{const a=M(e,t);return s==="html"?a:Se(a)}case"chordmarkSrc":return s==="html"?V(e):e;case"chordpro":{t.customRenderer=At();const a=M(e,t);return s==="html"?V(a):a}case"ultimateGuitar":{t.customRenderer=Fe();const a=M(e,{...t,customRenderer:Fe(),printBarSeparators:"grids",printChordsDuration:"never",printSubBeatDelimiters:!1,printInlineTimeSignatures:!1,chordSymbolRenderer:kt({customFilters:[Bt()],useShortNamings:!0,accidentalsType:t.accidentalsType==="auto"?"original":t.accidentalsType,...t})})+` Created with Chord Chart Studio (https://chord-chart-studio.netlify.app)`;return s==="html"?V(a):a}}const o=M(e,{...t,wrapChordLyricLines:!0});return s==="html"?o:Se(o)}function M(e,t){try{const n=Dt(e);return Wt(n,{...t})}catch(n){return n.message}}function V(e){return e.split(` `).map(t=>t===""?" ":t).map(t=>`${t}`).join("")}function Se(e){return e.match(/(.*?<\/p>)/gm).map(n=>q(n)).map(n=>n===" "?"":n).join(` diff --git a/packages/chord-chart-studio/build/index.html b/packages/chord-chart-studio/build/index.html index 68f2e42..82166a4 100644 --- a/packages/chord-chart-studio/build/index.html +++ b/packages/chord-chart-studio/build/index.html @@ -20,10 +20,10 @@ href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" /> - - - - + + + + - - - - + + + + +
diff --git a/packages/chord-chart-studio/build/registerSW.js b/packages/chord-chart-studio/build/registerSW.js index d42ac9e..179c13c 100644 --- a/packages/chord-chart-studio/build/registerSW.js +++ b/packages/chord-chart-studio/build/registerSW.js @@ -1 +1 @@ -if('serviceWorker' in navigator) {window.addEventListener('load', () => {navigator.serviceWorker.register('/sw.js', { scope: '/' })})} \ No newline at end of file +if('serviceWorker' in navigator) {window.addEventListener('load', () => {navigator.serviceWorker.register('./sw.js', { scope: './' })})} \ No newline at end of file diff --git a/packages/chord-chart-studio/build/sw.js b/packages/chord-chart-studio/build/sw.js index e8c763a..9211e2b 100644 --- a/packages/chord-chart-studio/build/sw.js +++ b/packages/chord-chart-studio/build/sw.js @@ -1 +1 @@ -if(!self.define){let e,s={};const n=(n,o)=>(n=new URL(n+".js",o).href,s[n]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()})).then((()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(o,t)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(s[i])return;let r={};const l=e=>n(e,i),c={module:{uri:i},exports:r,require:l};s[i]=Promise.all(o.map((e=>c[e]||l(e)))).then((e=>(t(...e),r)))}}define(["./workbox-f6d27052"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-1ovoJZ2z.css",revision:null},{url:"assets/index-C5Goj58V.js",revision:null},{url:"assets/logo-D2B3txiq.svg",revision:null},{url:"assets/vendor-BPGk5lTF.js",revision:null},{url:"assets/vendor-D780UWrd.css",revision:null},{url:"icon.svg",revision:"22be856a58b037f4d448a78f2fc6dee6"},{url:"index.html",revision:"902e81129e199dccf925ff42aa2675eb"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"))),e.registerRoute(/^https:\/\/fonts\.googleapis\.com/,new e.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[]}),"GET"),e.registerRoute(/^https:\/\/fonts\.gstatic\.com/,new e.StaleWhileRevalidate({cacheName:"google-fonts-webfonts",plugins:[new e.CacheableResponsePlugin({statuses:[0,200]}),new e.ExpirationPlugin({maxAgeSeconds:31536e3,maxEntries:30})]}),"GET")})); +if(!self.define){let e,s={};const n=(n,o)=>(n=new URL(n+".js",o).href,s[n]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()})).then((()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(o,t)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(s[i])return;let r={};const l=e=>n(e,i),u={module:{uri:i},exports:r,require:l};s[i]=Promise.all(o.map((e=>u[e]||l(e)))).then((e=>(t(...e),r)))}}define(["./workbox-f6d27052"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-1ovoJZ2z.css",revision:null},{url:"assets/index-BeOzSnWz.js",revision:null},{url:"assets/logo-D2B3txiq.svg",revision:null},{url:"assets/vendor-BPGk5lTF.js",revision:null},{url:"assets/vendor-D780UWrd.css",revision:null},{url:"icon.svg",revision:"22be856a58b037f4d448a78f2fc6dee6"},{url:"index.html",revision:"bb308b44aa4a03022bd9fc3556499ab0"},{url:"registerSW.js",revision:"402b66900e731ca748771b6fc5e7a068"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"))),e.registerRoute(/^https:\/\/fonts\.googleapis\.com/,new e.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[]}),"GET"),e.registerRoute(/^https:\/\/fonts\.gstatic\.com/,new e.StaleWhileRevalidate({cacheName:"google-fonts-webfonts",plugins:[new e.CacheableResponsePlugin({statuses:[0,200]}),new e.ExpirationPlugin({maxAgeSeconds:31536e3,maxEntries:30})]}),"GET")})); diff --git a/packages/chord-chart-studio/vite.config.js b/packages/chord-chart-studio/vite.config.js index 6311d40..da00a3c 100644 --- a/packages/chord-chart-studio/vite.config.js +++ b/packages/chord-chart-studio/vite.config.js @@ -5,6 +5,7 @@ import { VitePWA } from 'vite-plugin-pwa'; export default defineConfig({ root: 'src', publicDir: '../public', + base: './', build: { outDir: '../build', emptyOutDir: true,