kashi 1.1.2 → 1.1.3
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.
- package/kashi.js +1 -1
- package/kashi.mjs +1 -1
- package/package.json +12 -2
package/kashi.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(self,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Kashi:()=>y});const r=/\[\d{2}:\d{2}.\d{2}\]/,i=/^\[\d{2}:\d{2}.\d{2}\](.*)$/;var n,s,o,a,f,
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(self,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Kashi:()=>y});const r=/\[\d{2}:\d{2}.\d{2}\]/,i=/^\[\d{2}:\d{2}.\d{2}\](.*)$/;var n,s,o,a,l,f,h,c,u,d,p=function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},w=function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};class y{constructor(e){if(n.add(this),s.set(this,null),o.set(this,null),a.set(this,[]),l.set(this,void 0),f.set(this,new Map),h.set(this,void 0),e.url&&e.file)throw new Error("Cannot specify both url and file.");if(!e.url&&!e.file)throw new Error("Must specify either url or file.");if(!(e.container&&e.container instanceof HTMLDivElement))throw new Error("Container must be an instance of HTMLDivElement.");e.emptyLineText&&this.setEmptyLineText(e.emptyLineText),p(this,l,e.container,"f"),this.subscribe("fileSet",w(this,n,"m",d).bind(this)),this.subscribe("emptyLineTextSet",w(this,n,"m",d).bind(this)),e.url?this.setUrl(e.url):e.file&&this.setFile(e.file)}get url(){return w(this,s,"f")}get file(){return w(this,o,"f")}get emptyLineText(){return w(this,h,"f")??"..."}async setUrl(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}.`);const r=t.headers.get("Content-Type");if(!r||!r.includes("text/plain"))throw new Error("Invalid content type. Expected text/plain.");const i=await t.blob();p(this,s,e,"f"),this.notify("urlSet",{url:e}),this.setFile(i)}catch(e){throw new Error((e instanceof Error&&e.message.length?e.message+" ":"")+"Failed to fetch the lyric file.")}}async setFile(e){const t=await w(this,n,"m",c).call(this,e);p(this,a,w(this,n,"m",u).call(this,t),"f"),p(this,o,e,"f"),this.notify("fileSet",{file:e})}setEmptyLineText(e){p(this,h,e,"f"),this.notify("emptyLineTextSet",{emptyLineText:e})}subscribe(e,t){w(this,f,"f").set(e,[...w(this,f,"f").get(e)??[],t])}unsubscribe(e,t){const r=w(this,f,"f").get(e);r&&r.length>1?w(this,f,"f").set(e,[...r.filter(e=>e!==t)]):w(this,f,"f").delete(e)}notify(e,t){[...w(this,f,"f").get(e)??[]].forEach(e=>{e(t)})}}return s=new WeakMap,o=new WeakMap,a=new WeakMap,l=new WeakMap,f=new WeakMap,h=new WeakMap,n=new WeakSet,c=async function(e){return new Promise((t,r)=>{const i=new FileReader;i.onload=e=>{"string"==typeof e.target?.result&&e.target?.result.trim().length?t(e.target.result):r(new Error("Failed to read file content."))},i.onerror=()=>r(new Error("Error reading file.")),i.readAsText(e)})},u=function(e){const t=e.split("\n").reduce((e,t)=>{const r=t.trim();return i.test(r)?[...e,r]:e},[]);if(0===t.length)throw new Error("No valid lyric lines found in the file.");return t},d=function(){w(this,l,"f").innerHTML=w(this,a,"f").map(e=>`<p>${e.replace(r,"")||(w(this,h,"f")??"...")}</p>`).join(""),this.notify("lyricLinesUpdated",{lyricLines:w(this,a,"f")})},t})());
|
package/kashi.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e=/\[\d{2}:\d{2}.\d{2}\]/,t=/^\[\d{2}:\d{2}.\d{2}\](.*)$/;var i,r,n,s,o,a,l,h,f,c,w=function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};class d{constructor(e){if(i.add(this),r.set(this,null),n.set(this,null),s.set(this,[]),o.set(this,void 0),a.set(this,new Map),l.set(this,void 0),e.url&&e.file)throw new Error("Cannot specify both url and file.");if(!e.url&&!e.file)throw new Error("Must specify either url or file.");if(!(e.container&&e.container instanceof HTMLDivElement))throw new Error("Container must be an instance of HTMLDivElement.");e.emptyLineText&&this.setEmptyLineText(e.emptyLineText),w(this,o,e.container,"f"),this.subscribe("fileSet",u(this,i,"m",c).bind(this)),this.subscribe("emptyLineTextSet",u(this,i,"m",c).bind(this)),e.url?this.setUrl(e.url):e.file&&this.setFile(e.file)}get url(){return u(this,r,"f")}get file(){return u(this,n,"f")}get emptyLineText(){return u(this,l,"f")??"..."}async setUrl(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}.`);const i=t.headers.get("Content-Type");if(!i||!i.includes("text/plain"))throw new Error("Invalid content type. Expected text/plain.");const n=await t.blob();w(this,r,e,"f"),this.notify("urlSet",{url:e}),this.setFile(n)}catch(e){throw new Error((e instanceof Error&&e.message.length?e.message+" ":"")+"Failed to fetch the lyric file.")}}async setFile(e){const t=await u(this,i,"m",h).call(this,e);w(this,s,u(this,i,"m",f).call(this,t),"f"),w(this,n,e,"f"),this.notify("fileSet",{file:e})}setEmptyLineText(e){w(this,l,e,"f"),this.notify("emptyLineTextSet",{emptyLineText:e})}subscribe(e,t){u(this,a,"f").set(e,[...u(this,a,"f").get(e)??[],t])}unsubscribe(e,t){const i=u(this,a,"f").get(e);i&&i.length>1?u(this,a,"f").set(e,[...i.filter(e=>e!==t)]):u(this,a,"f").delete(e)}notify(e,t){[...u(this,a,"f").get(e)??[]].forEach(e=>{e(t)})}}r=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,l=new WeakMap,i=new WeakSet,h=async function(e){return new Promise((t,i)=>{const r=new FileReader;r.onload=e=>{"string"==typeof e.target?.result&&e.target?.result.trim().length?t(e.target.result):i(new Error("Failed to read file content."))},r.onerror=()=>i(new Error("Error reading file.")),r.readAsText(e)})},f=function(e){const i=e.split("\n").reduce((e,i)=>{const r=i.trim();return t.test(r)?[...e,r]:e},[]);if(0===i.length)throw new Error("No valid lyric lines found in the file.");return i},c=function(){u(this,o,"f").innerHTML=u(this,s,"f").map(t=>`<p>${t.replace(e,"")||(u(this,l,"f")??"...")}</p>`).join(""),this.notify("lyricLinesUpdated",{lyricLines:u(this,s,"f")})};export{d as Kashi};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kashi",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Singing at the top of my lungs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "lucasmc64",
|
|
@@ -23,7 +23,17 @@
|
|
|
23
23
|
"music",
|
|
24
24
|
"kashi",
|
|
25
25
|
"karaoke",
|
|
26
|
-
"singer"
|
|
26
|
+
"singer",
|
|
27
|
+
"sing",
|
|
28
|
+
"walaoke",
|
|
29
|
+
"a2",
|
|
30
|
+
"lrc-parser",
|
|
31
|
+
"lyric-synchronization",
|
|
32
|
+
"timed-lyrics",
|
|
33
|
+
"music-player",
|
|
34
|
+
"audio-player",
|
|
35
|
+
"lrc-file",
|
|
36
|
+
"lyrics-formatter"
|
|
27
37
|
],
|
|
28
38
|
"scripts": {
|
|
29
39
|
"prestart": "npm run build",
|