Skip to content

Commit

Permalink
minify std-min!?!?
Browse files Browse the repository at this point in the history
  • Loading branch information
TodePond committed Jan 27, 2025
1 parent 0ea14ea commit 2ba6088
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*-min.js
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ <h1>🍝 welcome to nudel</h1>
(we use them all in nudel)
</p>
<p>
<button id="about-yes-button">play</button>
<button id="about-yes-button" disabled>play</button>
</p>
</form>
</dialog>
Expand Down
15 changes: 15 additions & 0 deletions public/assets/std-min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function spag(name){return'https://spag.cc/'+name}
function listToArray(stringList){if(Array.isArray(stringList)){return stringList.map(listToArray).flat()}
return stringList.replaceAll(' ',',').split(',').map((v)=>v.trim()).filter((v)=>v)}
async function spagda(nameList){const names=listToArray(nameList);if(names.length===0){return}
const map={};for(const name of names){map[name]=spag(name)}
samples(map)}
async function speechda(wordList='',locale='en-GB',gender='f',){if(wordList.includes(':')){const[localeArg,wordsArg]=wordList.split(':');if(localeArg.includes('-')){locale=localeArg}else{gender=localeArg}
wordList=wordsArg}
if(locale.includes('/')){const[localeArg,genderArg]=locale.split('/');locale=localeArg;gender=genderArg}
const words=listToArray(wordList);if(words.length===0){return}
samples('shabda/speech/'+locale+'/'+gender+':'+words.join(','))}
async function hubda(orgList,repoList=''){const orgs=listToArray(orgList);const orgRepos=[];const orgChoices=[];for(const org of orgs){if(org.includes('/')){const[orgName,repoName]=org.split('/');orgRepos.push({org:orgName,repo:repoName})}else{orgChoices.push(org)}}
const repoChoices=listToArray(repoList);for(const orgChoice of orgChoices){for(const repoChoice of repoChoices){orgRepos.push({org:orgChoice,repo:repoChoice})}}
const addresses=orgRepos.map(({org,repo})=>'github:'+org+'/'+repo);for(const address of addresses){samples(address)}}
window.speechda=speechda;window.spagda=spagda;window.spag=spag;window.hubda=hubda
8 changes: 6 additions & 2 deletions public/assets/std.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
//=== NUDEL STANDARD LIBRARY ===//
// If you edit this file, please also minify it
// and place the minified version in std-min.js

// For example, you can paste this file into https://minifier.org/
// and then copy the output into std-min.js

function spag(name) {
return 'https://spag.cc/' + name;
}
Expand Down Expand Up @@ -87,4 +92,3 @@ window.speechda = speechda;
window.spagda = spagda;
window.spag = spag;
window.hubda = hubda;
//=== END OF NUDEL STANDARD LIBRARY ===//
2 changes: 1 addition & 1 deletion src/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exportButton.addEventListener('click', () => {
});

let stdSource = '';
fetch('assets/std.js').then(async (response) => {
fetch('assets/std-min.js').then(async (response) => {
if (!response.ok) {
console.error('Failed to load stdSource');
return;
Expand Down
4 changes: 4 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ window.session = session;

/* session.on("change", (...args) => console.log("change", ...args));
session.on("message", (msg) => console.log("message", msg)); */
session.on('open', () => {
console.log('open');
// clearGlobalError();
});

session.on('sync', () => {
// If session is empty, create two documents
Expand Down

0 comments on commit 2ba6088

Please sign in to comment.