@seven.io/counter
Advanced tools
Comparing version 1.6.1 to 1.6.4
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SevenCounter={})}(this,(function(t){"use strict";var e=function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},e.apply(this,arguments)};function r(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function n(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function o(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var i,a=function(t,e){var r=t.offsetWidth-e.offsetWidth;e.style.left="".concat(r,"px");var n=t.offsetHeight-e.offsetHeight;e.style.top="".concat(n,"px")},c=Object.freeze(["0","1","2","3","4","5","6","7","8","9","@","Δ"," ","s","\n","¡","P","¿","p","£","_","!","A","Q","a","q","$","Φ",'"',"B","R","b","r","¥","Γ","#","C","S","c","s","è","Λ","¤","D","T","d","t","é","Ω","%","E","U","e","u","ù","Π","&","F","V","f","v","ì","Ψ","'","G","W","g","w","ò","Σ","(","H","X","h","x","Ç","Θ",")","I","Y","i","y","Ξ","*",":","J","Z","j","z","Ø","+",";","K","Ä","k","ä","ø","Æ",",","<","L","Ö","l","ö","æ","-","=","M","Ñ","m","ñ","Å","ß",".",">","N","Ü","n","ü","å","É","/","?","O","§","o","à"]),u=Object.freeze(["^","|","€","{","}","[","]","~","\\"]),l=Object.freeze(o(o([],n(c),!1),n(u),!1));t.CharLimit=void 0,(i=t.CharLimit||(t.CharLimit={}))[i.GSM7=160]="GSM7",i[i.GSM7_REDUCED=153]="GSM7_REDUCED",i[i.UCS2=70]="UCS2",i[i.UCS2_REDUCED=67]="UCS2_REDUCED";var f=function(t,e){var r=1;return"GSM7"===t&&u.includes(e)&&r++,r},s=function(t){return l.includes(t)},d=function(t,e,i,a,c){var d,v,y,h,p,C=[],S=0,m=!1;try{for(var E=r(Array(a).entries()),g=E.next();!g.done;g=E.next()){var U=n(g.value,2),b=U[0],D=U[1];D=[];var M=1,x=S+c,G=(p=b,["05","00","03","CC","0".concat(a),"0".concat(p)]),L=G.length,w=i.slice(S,x);try{for(var _=(y=void 0,r(w)),O=_.next();!O.done;O=_.next()){var R=O.value,j=L-1+M;m||(l.includes(R)?u.includes(R)&&(D[j-1]="ESC"):m=!0),D[j]=R,M++}}catch(t){y={error:t}}finally{try{O&&!O.done&&(h=_.return)&&h.call(_)}finally{if(y)throw y.error}}S=x,e&&D.splice.apply(D,o([0,L],n(G),!1)),C.push(o([],n(D.filter((function(t){return t})).map((function(e){var r,n=e.length>1&&"ESC"!==e;return{character:e,encoding:n?"GSM7":(r=f(t,e),1===r?"GSM7":"UCS2"),escape:!n&&"ESC"===e,gsm7:!!n||s(e),length:1,udh:n,unicode:!n&&m}}))),!1))}}catch(t){d={error:t}}finally{try{g&&!g.done&&(v=E.return)&&v.call(E)}finally{if(d)throw d.error}}return C},v=function(e){var n=("string"==typeof e?e:e.value).split(""),o=function(t){var e,n;try{for(var o=r(t),i=o.next();!i.done;i=o.next()){var a=i.value;if(!l.includes(a))return"UCS2"}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return"GSM7"}(n),i=function(t,e){var n,o,i=0;try{for(var a=r(e),c=a.next();!c.done;c=a.next()){var u=c.value;i+=f(t,u)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}return i}(o,n),a=function(e,r){var n={GSM7:t.CharLimit.GSM7,UCS2:t.CharLimit.UCS2};return n[e]<r&&(n.GSM7=t.CharLimit.GSM7_REDUCED,n.UCS2=t.CharLimit.UCS2_REDUCED),n}(o,i),c=function(t,e,r){var n=t/e[r];return 1>=n?n=1:(n=Number.parseFloat(String(n)),n=Math.floor(n),n++),n}(i,a,o),u=c>1,s=function(e,r){return"GSM7"===r?e?t.CharLimit.GSM7_REDUCED:t.CharLimit.GSM7:e?t.CharLimit.UCS2_REDUCED:t.CharLimit.UCS2}(u,o);return{charCount:i,charLimit:s,encoding:o,messages:d(o,u,n,c,s),msgCount:c}},y=function(t,e){return t.textContent=(n=(r=e).charCount,o=r.encoding,i=r.msgCount,"".concat(n,"/").concat(i," [").concat(o,"]"));var r,n,o,i},h=function(t){Array.from(document.querySelectorAll(t.selector)).forEach((function(e){var r,n=!1;!1!==t.stats&&(!0===t.stats?((r=document.createElement("span")).style.position="absolute",e.insertAdjacentElement(t.position,r),n=!0,a(e,r)):(r="string"==typeof t.stats?document.querySelector(t.stats):t.stats,n=!1),r&&y(r,v(e))),e.addEventListener("input",(function(){return function(t,e,r){var n=v(t);e&&(y(e,n),r&&a(t,e)),document.dispatchEvent(new CustomEvent("seven_counter_input",{detail:n}))}(e,r,n)}))}))},p="window"in globalThis,C=e({initEvent:"DOMContentLoaded",position:"afterend",selector:"*[data-seven-sms]",standalone:!1,stats:!0},p&&window.SEVEN_COUNTER_OPTIONS||{});p&&!C.standalone&&function(t){document.addEventListener(t.initEvent,(function(){return h(t)}),{once:!0})}(C),t.getCounterStats=v})); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).SevenCounter={})}(this,(function(t){"use strict";var n=function(){return n=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},n.apply(this,arguments)};function e(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function r(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}function o(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var i,a=function(t,n){var e=t.offsetWidth-n.offsetWidth;n.style.left="".concat(e,"px");var r=t.offsetHeight-n.offsetHeight;n.style.top="".concat(r,"px")},c=Object.freeze(["0","1","2","3","4","5","6","7","8","9","@","Δ"," ","s","\n","¡","P","¿","p","£","_","!","A","Q","a","q","$","Φ",'"',"B","R","b","r","¥","Γ","#","C","S","c","s","è","Λ","¤","D","T","d","t","é","Ω","%","E","U","e","u","ù","Π","&","F","V","f","v","ì","Ψ","'","G","W","g","w","ò","Σ","(","H","X","h","x","Ç","Θ",")","I","Y","i","y","Ξ","*",":","J","Z","j","z","Ø","+",";","K","Ä","k","ä","ø","Æ",",","<","L","Ö","l","ö","æ","-","=","M","Ñ","m","ñ","Å","ß",".",">","N","Ü","n","ü","å","É","/","?","O","§","o","à"]),u=Object.freeze(["^","|","€","{","}","[","]","~","\\"]),l=Object.freeze(o(o([],r(c),!1),r(u),!1));t.CharLimit=void 0,(i=t.CharLimit||(t.CharLimit={}))[i.GSM7=160]="GSM7",i[i.GSM7_REDUCED=153]="GSM7_REDUCED",i[i.UCS2=70]="UCS2",i[i.UCS2_REDUCED=67]="UCS2_REDUCED";var s=function(t,n){var e=1;return"GSM7"===t&&u.includes(n)&&e++,e},f=function(t){return l.includes(t)},d="ESC";var h=function(t){var n,i,a=t.charLimit,c=t.encoding,h=t.isMulti,v=t.letters,C=t.msgCount,p=[],y=0,S=!1,m=function(t,n){var e,i=1,m=y+a,E=(e=t,["05","00","03","CC","0".concat(C),"0".concat(e)]),g=E.length;v.slice(y,m).forEach((function(t){var e,r,o=g-1+i;S||(e=t,l.includes(e))||(S=!0),S||(r=t,u.includes(r)&&(console.log("extension character in a non-unicode message, ADDING ESCAPE CHARACTER",{charIndex:o,char:t,msg:n}),n.push(d))),n.push(t),i++})),y=m,h&&n.splice.apply(n,o([0,0],r(E),!1)),p.push(o([],r(n.filter((function(t){return t})).map((function(t){var n,e=t.length>1&&d!==t;return{character:t,encoding:e?"GSM7":(n=s(c,t),1===n?"GSM7":"UCS2"),escape:!e&&d===t,gsm7:!!e||f(t),length:1,udh:e,unicode:!e&&S}}))),!1))};try{for(var E=e(Array(C).entries()),g=E.next();!g.done;g=E.next()){var U=r(g.value,2),b=U[0],D=U[1];m(b,void 0===D?[]:D)}}catch(t){n={error:t}}finally{try{g&&!g.done&&(i=E.return)&&i.call(E)}finally{if(n)throw n.error}}return p};var v=function(n){var r=("string"==typeof n?n:n.value).split(""),o=function(t){var n,r;try{for(var o=e(t),i=o.next();!i.done;i=o.next()){var a=i.value;if(!l.includes(a))return"UCS2"}}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return"GSM7"}(r),i=function(t,n){var r,o,i=0;try{for(var a=e(n),c=a.next();!c.done;c=a.next()){var u=c.value;i+=s(t,u)}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return i}(o,r),a=function(n,e){var r={GSM7:t.CharLimit.GSM7,UCS2:t.CharLimit.UCS2};return r[n]<e&&(r.GSM7=t.CharLimit.GSM7_REDUCED,r.UCS2=t.CharLimit.UCS2_REDUCED),r}(o,i),c=function(t,n,e){var r=t/n[e];return 1>=r?r=1:(r=Number.parseFloat(String(r)),r=Math.floor(r),r++),r}(i,a,o),u=c>1,f=function(n,e){return"GSM7"===e?n?t.CharLimit.GSM7_REDUCED:t.CharLimit.GSM7:n?t.CharLimit.UCS2_REDUCED:t.CharLimit.UCS2}(u,o);return{charCount:i,charLimit:f,encoding:o,messages:h({encoding:o,isMulti:u,letters:r,msgCount:c,charLimit:f}),msgCount:c}},C=function(t,n){return t.textContent=(r=(e=n).charCount,o=e.encoding,i=e.msgCount,"".concat(r,"/").concat(i," [").concat(o,"]"));var e,r,o,i},p=function(t){Array.from(document.querySelectorAll(t.selector)).forEach((function(n){var e,r=!1;!1!==t.stats&&(!0===t.stats?((e=document.createElement("span")).style.position="absolute",n.insertAdjacentElement(t.position,e),r=!0,a(n,e)):(e="string"==typeof t.stats?document.querySelector(t.stats):t.stats,r=!1),e&&C(e,v(n))),n.addEventListener("input",(function(){return function(t,n,e){var r=v(t);n&&(C(n,r),e&&a(t,n)),document.dispatchEvent(new CustomEvent("seven_counter_input",{detail:r}))}(n,e,r)}))}))},y="window"in globalThis,S=n({initEvent:"DOMContentLoaded",position:"afterend",selector:"*[data-seven-sms]",standalone:!1,stats:!0},y&&window.SEVEN_COUNTER_OPTIONS||{});y&&!S.standalone&&function(t){document.addEventListener(t.initEvent,(function(){return p(t)}),{once:!0})}(S),t.getCounterStats=v})); |
@@ -1,2 +0,2 @@ | ||
import { CounterStats, SourceElement } from './types'; | ||
import type { CounterStats, SourceElement } from './types'; | ||
export declare const getCounterStats: (source: SourceElement | string) => CounterStats; |
@@ -13,15 +13,17 @@ { | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.22.20", | ||
"@babel/preset-env": "^7.24.4", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "^25.0.5", | ||
"@rollup/plugin-commonjs": "^25.0.7", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"@rollup/plugin-typescript": "^11.1.5", | ||
"@types/jest": "^29.5.5", | ||
"@rollup/plugin-typescript": "^11.1.6", | ||
"@types/jest": "^29.5.12", | ||
"cross-env": "^7.0.3", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"jest-runner-groups": "^2.2.0", | ||
"rollup": "^4.0.2", | ||
"ts-jest": "^29.1.1", | ||
"rimraf": "^5.0.5", | ||
"rollup": "^4.14.1", | ||
"ts-jest": "^29.1.2", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.2.2" | ||
"typescript": "^5.4.4" | ||
}, | ||
@@ -39,4 +41,5 @@ "license": "MIT", | ||
"scripts": { | ||
"build": "rm -rf dist && NODE_ENV=prod rollup -c --bundleConfigAsCjs", | ||
"dev": "rollup -c -w", | ||
"build": "cross-env rimraf dist && npm run bundle", | ||
"bundle": "cross-env NODE_ENV=prod rollup -c --bundleConfigAsCjs", | ||
"dev": "rollup -c -w --bundleConfigAsCjs", | ||
"prepublishOnly": "npm run build", | ||
@@ -46,3 +49,3 @@ "test": "npx jest" | ||
"types": "dist/index.d.ts", | ||
"version": "1.6.1" | ||
"version": "1.6.4" | ||
} |
@@ -1,2 +0,2 @@ | ||
![](https://www.seven.io/wp-content/uploads/Logo.svg "seven Logo") | ||
<img src="https://www.seven.io/wp-content/uploads/Logo.svg" width="250" /> | ||
@@ -3,0 +3,0 @@ # SMS Counter by seven |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11570
9
72
15