title-switcher 2.2.0 → 2.2.2

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.
@@ -1 +1 @@
1
- "use strict";var titleSwitcher=(()=>{var e,t,r,n=Object.getOwnPropertyNames,o=(e,t)=>function(){try{return t||(0,e[n(e)[0]])((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}},s=(e={"js-build-tools-inject:process"(){}},function(){if(r)throw r[0];try{return e&&(t=(0,e[n(e)[0]])(e=0)),t}catch(e){throw r=[e],e}}),i=o({"node_modules/core-js/internals/global-this.js"(e,t){s();var r=function(e){return e&&e.Math===Math&&e};t.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof globalThis&&globalThis)||r("object"==typeof e&&e)||function(){return this}()||Function("return this")()}}),a=o({"node_modules/core-js/internals/fails.js"(e,t){s(),t.exports=function(e){try{return!!e()}catch(e){return!0}}}}),c=o({"node_modules/core-js/internals/descriptors.js"(e,t){s();var r=a();t.exports=!r((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}}),l=o({"node_modules/core-js/internals/function-bind-native.js"(e,t){s();var r=a();t.exports=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))}}),u=o({"node_modules/core-js/internals/function-call.js"(e,t){s();var r=l(),n=Function.prototype.call;t.exports=r?n.bind(n):function(){return n.apply(n,arguments)}}}),f=o({"node_modules/core-js/internals/object-property-is-enumerable.js"(e){s();var t={}.propertyIsEnumerable,r=Object.getOwnPropertyDescriptor,n=r&&!t.call({1:2},1);e.f=n?function(e){var t=r(this,e);return!!t&&t.enumerable}:t}}),p=o({"node_modules/core-js/internals/create-property-descriptor.js"(e,t){s(),t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}}}),d=o({"node_modules/core-js/internals/function-uncurry-this.js"(e,t){s();var r=l(),n=Function.prototype,o=n.call,i=r&&n.bind.bind(o,o);t.exports=r?i:function(e){return function(){return o.apply(e,arguments)}}}}),h=o({"node_modules/core-js/internals/classof-raw.js"(e,t){s();var r=d(),n=r({}.toString),o=r("".slice);t.exports=function(e){return o(n(e),8,-1)}}}),m=o({"node_modules/core-js/internals/indexed-object.js"(e,t){s();var r=d(),n=a(),o=h(),i=Object,c=r("".split);t.exports=n((function(){return!i("z").propertyIsEnumerable(0)}))?function(e){return"String"===o(e)?c(e,""):i(e)}:i}}),y=o({"node_modules/core-js/internals/is-null-or-undefined.js"(e,t){s(),t.exports=function(e){return null==e}}}),j=o({"node_modules/core-js/internals/require-object-coercible.js"(e,t){s();var r=y(),n=TypeError;t.exports=function(e){if(r(e))throw new n("Can't call method on "+e);return e}}}),v=o({"node_modules/core-js/internals/to-indexed-object.js"(e,t){s();var r=m(),n=j();t.exports=function(e){return r(n(e))}}}),b=o({"node_modules/core-js/internals/is-callable.js"(e,t){s();var r="object"==typeof document&&document.all;t.exports=void 0===r&&void 0!==r?function(e){return"function"==typeof e||e===r}:function(e){return"function"==typeof e}}}),g=o({"node_modules/core-js/internals/is-object.js"(e,t){s();var r=b();t.exports=function(e){return"object"==typeof e?null!==e:r(e)}}}),w=o({"node_modules/core-js/internals/get-built-in.js"(e,t){s();var r=i(),n=b();t.exports=function(e,t){return arguments.length<2?(o=r[e],n(o)?o:void 0):r[e]&&r[e][t];var o}}}),x=o({"node_modules/core-js/internals/object-is-prototype-of.js"(e,t){s();var r=d();t.exports=r({}.isPrototypeOf)}}),_=o({"node_modules/core-js/internals/environment-user-agent.js"(e,t){s();var r=i().navigator,n=r&&r.userAgent;t.exports=n?String(n):""}}),S=o({"node_modules/core-js/internals/environment-v8-version.js"(e,t){s();var r,n,o=i(),a=_(),c=o.process,l=o.Deno,u=c&&c.versions||l&&l.version,f=u&&u.v8;f&&(n=(r=f.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!n&&a&&(!(r=a.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=a.match(/Chrome\/(\d+)/))&&(n=+r[1]),t.exports=n}}),T=o({"node_modules/core-js/internals/symbol-constructor-detection.js"(e,t){s();var r=S(),n=a(),o=i().String;t.exports=!!Object.getOwnPropertySymbols&&!n((function(){var e=Symbol("symbol detection");return!o(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41}))}}),k=o({"node_modules/core-js/internals/use-symbol-as-uid.js"(e,t){s();var r=T();t.exports=r&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}}),O=o({"node_modules/core-js/internals/is-symbol.js"(e,t){s();var r=w(),n=b(),o=x(),i=k(),a=Object;t.exports=i?function(e){return"symbol"==typeof e}:function(e){var t=r("Symbol");return n(t)&&o(t.prototype,a(e))}}}),M=o({"node_modules/core-js/internals/try-to-string.js"(e,t){s();var r=String;t.exports=function(e){try{return r(e)}catch(e){return"Object"}}}}),E=o({"node_modules/core-js/internals/a-callable.js"(e,t){s();var r=b(),n=M(),o=TypeError;t.exports=function(e){if(r(e))return e;throw new o(n(e)+" is not a function")}}}),L=o({"node_modules/core-js/internals/get-method.js"(e,t){s();var r=E(),n=y();t.exports=function(e,t){var o=e[t];return n(o)?void 0:r(o)}}}),P=o({"node_modules/core-js/internals/ordinary-to-primitive.js"(e,t){s();var r=u(),n=b(),o=g(),i=TypeError;t.exports=function(e,t){var s,a;if("string"===t&&n(s=e.toString)&&!o(a=r(s,e)))return a;if(n(s=e.valueOf)&&!o(a=r(s,e)))return a;if("string"!==t&&n(s=e.toString)&&!o(a=r(s,e)))return a;throw new i("Can't convert object to primitive value")}}}),C=o({"node_modules/core-js/internals/is-pure.js"(e,t){s(),t.exports=!1}}),N=o({"node_modules/core-js/internals/define-global-property.js"(e,t){s();var r=i(),n=Object.defineProperty;t.exports=function(e,t){try{n(r,e,{value:t,configurable:!0,writable:!0})}catch(n){r[e]=t}return t}}}),A=o({"node_modules/core-js/internals/shared-store.js"(e,t){s();var r=C(),n=i(),o=N(),a="__core-js_shared__",c=t.exports=n[a]||o(a,{});(c.versions||(c.versions=[])).push({version:"3.51.0",mode:r?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.51.0/LICENSE",source:"https://github.com/zloirock/core-js"})}}),W=o({"node_modules/core-js/internals/shared.js"(e,t){s();var r=A(),n=Object.create||Object;t.exports=function(e,t){return r[e]||(r[e]=t||n(null))}}}),H=o({"node_modules/core-js/internals/to-object.js"(e,t){s();var r=j(),n=Object;t.exports=function(e){return n(r(e))}}}),I=o({"node_modules/core-js/internals/has-own-property.js"(e,t){s();var r=d(),n=H(),o=r({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return o(n(e),t)}}}),F=o({"node_modules/core-js/internals/uid.js"(e,t){s();var r=d(),n=0,o=Math.random(),i=r(1.1.toString);t.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+i(++n+o,36)}}}),$=o({"node_modules/core-js/internals/well-known-symbol.js"(e,t){s();var r=i(),n=W(),o=I(),a=F(),c=T(),l=k(),u=r.Symbol,f=n("wks"),p=l?u.for||u:u&&u.withoutSetter||a;t.exports=function(e){return o(f,e)||(f[e]=c&&o(u,e)?u[e]:p("Symbol."+e)),f[e]}}}),R=o({"node_modules/core-js/internals/to-primitive.js"(e,t){s();var r=u(),n=g(),o=O(),i=L(),a=P(),c=$(),l=TypeError,f=c("toPrimitive");t.exports=function(e,t){if(!n(e)||o(e))return e;var s,c=i(e,f);if(c){if(void 0===t&&(t="default"),s=r(c,e,t),!n(s)||o(s))return s;throw new l("Can't convert object to primitive value")}return void 0===t&&(t="number"),a(e,t)}}}),B=o({"node_modules/core-js/internals/to-property-key.js"(e,t){s();var r=R(),n=O();t.exports=function(e){var t=r(e,"string");return n(t)?t:t+""}}}),z=o({"node_modules/core-js/internals/document-create-element.js"(e,t){s();var r=i(),n=g(),o=r.document,a=n(o)&&n(o.createElement);t.exports=function(e){return a?o.createElement(e):{}}}}),D=o({"node_modules/core-js/internals/ie8-dom-define.js"(e,t){s();var r=c(),n=a(),o=z();t.exports=!r&&!n((function(){return 7!==Object.defineProperty(o("div"),"a",{get:function(){return 7}}).a}))}}),q=o({"node_modules/core-js/internals/object-get-own-property-descriptor.js"(e){s();var t=c(),r=u(),n=f(),o=p(),i=v(),a=B(),l=I(),d=D(),h=Object.getOwnPropertyDescriptor;e.f=t?h:function(e,t){if(e=i(e),t=a(t),d)try{return h(e,t)}catch(e){}if(l(e,t))return o(!r(n.f,e,t),e[t])}}}),G=o({"node_modules/core-js/internals/v8-prototype-define-bug.js"(e,t){s();var r=c(),n=a();t.exports=r&&n((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}}),U=o({"node_modules/core-js/internals/an-object.js"(e,t){s();var r=g(),n=String,o=TypeError;t.exports=function(e){if(r(e))return e;throw new o(n(e)+" is not an object")}}}),J=o({"node_modules/core-js/internals/object-define-property.js"(e){s();var t=c(),r=D(),n=G(),o=U(),i=B(),a=TypeError,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,f="enumerable",p="configurable",d="writable";e.f=t?n?function(e,t,r){if(o(e),t=i(t),o(r),"function"==typeof e&&"prototype"===t&&"value"in r&&d in r&&!r[d]){var n=u(e,t);n&&n[d]&&(e[t]=r.value,r={configurable:p in r?r[p]:n[p],enumerable:f in r?r[f]:n[f],writable:!1})}return l(e,t,r)}:l:function(e,t,n){if(o(e),t=i(t),o(n),r)try{return l(e,t,n)}catch(e){}if("get"in n||"set"in n)throw new a("Accessors not supported");return"value"in n&&(e[t]=n.value),e}}}),K=o({"node_modules/core-js/internals/create-non-enumerable-property.js"(e,t){s();var r=c(),n=J(),o=p();t.exports=r?function(e,t,r){return n.f(e,t,o(1,r))}:function(e,t,r){return e[t]=r,e}}}),V=o({"node_modules/core-js/internals/function-name.js"(e,t){s();var r=c(),n=I(),o=Function.prototype,i=r&&Object.getOwnPropertyDescriptor,a=n(o,"name"),l=a&&"something"===function(){}.name,u=a&&(!r||r&&i(o,"name").configurable);t.exports={EXISTS:a,PROPER:l,CONFIGURABLE:u}}}),X=o({"node_modules/core-js/internals/inspect-source.js"(e,t){s();var r=d(),n=b(),o=A(),i=r(Function.toString);n(o.inspectSource)||(o.inspectSource=function(e){return i(e)}),t.exports=o.inspectSource}}),Y=o({"node_modules/core-js/internals/weak-map-basic-detection.js"(e,t){s();var r=i(),n=b(),o=r.WeakMap;t.exports=n(o)&&/native code/.test(String(o))}}),Q=o({"node_modules/core-js/internals/shared-key.js"(e,t){s();var r=W(),n=F(),o=r("keys");t.exports=function(e){return o[e]||(o[e]=n(e))}}}),Z=o({"node_modules/core-js/internals/hidden-keys.js"(e,t){s(),t.exports={}}}),ee=o({"node_modules/core-js/internals/internal-state.js"(e,t){s();var r,n,o,a,c,l=Y(),u=i(),f=g(),p=K(),d=I(),h=A(),m=Q(),y=Z(),j="Object already initialized",v=u.TypeError,b=u.WeakMap;l||h.state?((a=h.state||(h.state=new b)).get=a.get,a.has=a.has,a.set=a.set,r=function(e,t){if(a.has(e))throw new v(j);return t.facade=e,a.set(e,t),t},n=function(e){return a.get(e)||{}},o=function(e){return a.has(e)}):(y[c=m("state")]=!0,r=function(e,t){if(d(e,c))throw new v(j);return t.facade=e,p(e,c,t),t},n=function(e){return d(e,c)?e[c]:{}},o=function(e){return d(e,c)}),t.exports={set:r,get:n,has:o,enforce:function(e){return o(e)?n(e):r(e,{})},getterFor:function(e){return function(t){var r;if(!f(t)||(r=n(t)).type!==e)throw new v("Incompatible receiver, "+e+" required");return r}}}}}),te=o({"node_modules/core-js/internals/make-built-in.js"(e,t){s();var r=d(),n=a(),o=b(),i=I(),l=c(),u=V().CONFIGURABLE,f=X(),p=ee(),h=p.enforce,m=p.get,y=String,j=Object.defineProperty,v=r("".slice),g=r("".replace),w=r([].join),x=l&&!n((function(){return 8!==j((function(){}),"length",{value:8}).length})),_=String(String).split("String"),S=t.exports=function(e,t,r){"Symbol("===v(y(t),0,7)&&(t="["+g(y(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!i(e,"name")||u&&e.name!==t)&&(l?j(e,"name",{value:t,configurable:!0}):e.name=t),x&&r&&i(r,"arity")&&e.length!==r.arity&&j(e,"length",{value:r.arity});try{r&&i(r,"constructor")&&r.constructor?l&&j(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var n=h(e);return i(n,"source")||(n.source=w(_,"string"==typeof t?t:"")),e};Function.prototype.toString=S((function(){return o(this)&&m(this).source||f(this)}),"toString")}}),re=o({"node_modules/core-js/internals/define-built-in.js"(e,t){s();var r=b(),n=J(),o=te(),i=N();t.exports=function(e,t,s,a){a||(a={});var c=a.enumerable,l=void 0!==a.name?a.name:t;if(r(s)&&o(s,l,a),a.global)c?e[t]=s:i(t,s);else{try{a.unsafe?e[t]&&(c=!0):delete e[t]}catch(e){}c?e[t]=s:n.f(e,t,{value:s,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return e}}}),ne=o({"node_modules/core-js/internals/math-trunc.js"(e,t){s();var r=Math.ceil,n=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?n:r)(t)}}}),oe=o({"node_modules/core-js/internals/to-integer-or-infinity.js"(e,t){s();var r=ne();t.exports=function(e){var t=+e;return t!=t||0===t?0:r(t)}}}),se=o({"node_modules/core-js/internals/to-absolute-index.js"(e,t){s();var r=oe(),n=Math.max,o=Math.min;t.exports=function(e,t){var s=r(e);return s<0?n(s+t,0):o(s,t)}}}),ie=o({"node_modules/core-js/internals/to-length.js"(e,t){s();var r=oe(),n=Math.min;t.exports=function(e){var t=r(e);return t>0?n(t,9007199254740991):0}}}),ae=o({"node_modules/core-js/internals/length-of-array-like.js"(e,t){s();var r=ie();t.exports=function(e){return r(e.length)}}}),ce=o({"node_modules/core-js/internals/array-includes.js"(e,t){s();var r=v(),n=se(),o=ae(),i=function(e){return function(t,s,i){var a=r(t),c=o(a);if(0===c)return!e&&-1;var l,u=n(i,c);if(e&&s!=s){for(;c>u;)if((l=a[u++])!=l)return!0}else for(;c>u;u++)if((e||u in a)&&a[u]===s)return e||u||0;return!e&&-1}};t.exports={includes:i(!0),indexOf:i(!1)}}}),le=o({"node_modules/core-js/internals/object-keys-internal.js"(e,t){s();var r=d(),n=I(),o=v(),i=ce().indexOf,a=Z(),c=r([].push);t.exports=function(e,t){var r,s=o(e),l=0,u=[];for(r in s)!n(a,r)&&n(s,r)&&c(u,r);for(;t.length>l;)n(s,r=t[l++])&&(~i(u,r)||c(u,r));return u}}}),ue=o({"node_modules/core-js/internals/enum-bug-keys.js"(e,t){s(),t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]}}),fe=o({"node_modules/core-js/internals/object-get-own-property-names.js"(e){s();var t=le(),r=ue().concat("length","prototype");e.f=Object.getOwnPropertyNames||function(e){return t(e,r)}}}),pe=o({"node_modules/core-js/internals/object-get-own-property-symbols.js"(e){s(),e.f=Object.getOwnPropertySymbols}}),de=o({"node_modules/core-js/internals/own-keys.js"(e,t){s();var r=w(),n=d(),o=fe(),i=pe(),a=U(),c=n([].concat);t.exports=r("Reflect","ownKeys")||function(e){var t=o.f(a(e)),r=i.f;return r?c(t,r(e)):t}}}),he=o({"node_modules/core-js/internals/copy-constructor-properties.js"(e,t){s();var r=I(),n=de(),o=q(),i=J();t.exports=function(e,t,s){for(var a=n(t),c=i.f,l=o.f,u=0;u<a.length;u++){var f=a[u];r(e,f)||s&&r(s,f)||c(e,f,l(t,f))}}}}),me=o({"node_modules/core-js/internals/is-forced.js"(e,t){s();var r=a(),n=b(),o=/#|\.prototype\./,i=function(e,t){var o=l[c(e)];return o===f||o!==u&&(n(t)?r(t):!!t)},c=i.normalize=function(e){return String(e).replace(o,".").toLowerCase()},l=i.data={},u=i.NATIVE="N",f=i.POLYFILL="P";t.exports=i}}),ye=o({"node_modules/core-js/internals/export.js"(e,t){s();var r=i(),n=q().f,o=K(),a=re(),c=N(),l=he(),u=me();t.exports=function(e,t){var s,i,f,p,d,h=e.target,m=e.global,y=e.stat;if(s=m?r:y?r[h]||c(h,{}):r[h]&&r[h].prototype)for(i in t){if(p=t[i],f=e.dontCallGetSet?(d=n(s,i))&&d.value:s[i],!u(m?i:h+(y?".":"#")+i,e.forced)&&void 0!==f){if(typeof p==typeof f)continue;l(p,f)}(e.sham||f&&f.sham)&&o(p,"sham",!0),a(s,i,p,e)}}}}),je=o({"node_modules/core-js/internals/weak-map-helpers.js"(e,t){s();var r=d(),n=WeakMap.prototype;t.exports={WeakMap:WeakMap,set:r(n.set),get:r(n.get),has:r(n.has),remove:r(n.delete)}}}),ve=o({"node_modules/core-js/internals/a-weak-map.js"(e,t){s();var r=je().has;t.exports=function(e){return r(e),e}}}),be=o({"node_modules/core-js/modules/esnext.weak-map.delete-all.js"(){s();var e=ye(),t=ve(),r=je().remove;e({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,n=t(this),o=!0,s=0,i=arguments.length;s<i;s++)e=r(n,arguments[s]),o=o&&e;return!!o}})}});return o({"dist/main.js"(e){s(),be();var t,r,n,o,i,a,c,l,u,f,p=function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},d=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(e,"__esModule",{value:!0});var h=class{constructor(e="",s="typingEffect"){t.set(this,!1),r.set(this,"displayTitle"),n.set(this,0),o.set(this,200),i.set(this,400),a.set(this,!1),c.set(this,[]),l.set(this,""),u.set(this,void 0),f.set(this,void 0),p(this,r,"displayTitle","f"),p(this,u,"string"==typeof s?"function"==typeof this[s]?this[s]:this.typingEffect:s,"f"),p(this,l,e,"f"),p(this,c,[],"f");const d=e?document.querySelectorAll(e):[];d&&d[0]&&(p(this,l,d[0],"f"),p(this,c,d[0].children,"f"))}get active(){return d(this,t,"f")}get currentClass(){return d(this,r,"f")}get currentIndex(){return d(this,n,"f")}get delayEffect(){return d(this,o,"f")}get delaySwitch(){return d(this,i,"f")}get switchStyle(){return d(this,u,"f")}get titles(){return d(this,c,"f")}get typeSurface(){return d(this,f,"f")}startTitles({delaySwitch:e=400,delayEffect:s=200,isRandom:h=!1,immediatePause:m=!1}={}){const y="typeSurface";if(p(this,i,e,"f"),p(this,o,s,"f"),p(this,a,h,"f"),p(this,t,!m,"f"),d(this,n,"f")>=d(this,c,"f").length||"string"==typeof d(this,l,"f"))return p(this,t,!1,"f"),console.warn(`No titles found for '${d(this,l,"f")}'`),this;d(this,a,"f")&&p(this,n,Math.round(Math.random()*(d(this,c,"f").length-2))+1,"f");const j=d(this,c,"f")[d(this,n,"f")];j.classList?j.classList.add(d(this,r,"f")):j.className+=" "+d(this,r,"f");const v=d(this,c,"f")[0].cloneNode(!0);return v.classList?v.classList.add(y):v.className+=" "+y,v.classList?v.classList.remove(d(this,r,"f")):v.className=v.className.replace(new RegExp("(^|\\b)"+v.className.split(" ").join("|")+"(\\b|$)","gi")," "),d(this,l,"f").insertBefore(v,d(this,l,"f").firstChild),p(this,f,d(this,l,"f").querySelectorAll("."+y)[0],"f"),d(this,f,"f").innerHTML="",d(this,f,"f").style.display="block",Array.prototype.forEach.call(d(this,c,"f"),(function(e){e.style.display="none"})),this.switchTitle(j,d(this,u,"f"),this)}pause(){p(this,t,!1,"f")}resume(){d(this,t,"f")||(p(this,t,!0,"f"),this.switchTitle(d(this,c,"f")[d(this,n,"f")],d(this,u,"f"),this))}switchTitle(e,r,o,s=!1){let i=1;const l=d(o=o||this,c,"f").length;for(let t=1;t<l;++t)if(d(o,c,"f")[t]===e){i=t;break}if(!d(o,t,"f"))return p(o,n,i,"f"),o;const u=d(o,c,"f").length-1;let f=1;if(1===u)return r(e,s?()=>o:o.switchTitle,o,s);if(d(o,a,"f")){o.typeSurface.textContent.trim()||(i=-1);do{f=Math.round(Math.random()*(u-1))+1}while(f===i)}else o.typeSurface.textContent.trim()||(i=u),f=i<u?i+1:1;const h=d(o,c,"f")[f];return e.classList?e.classList.remove(o.currentClass):e.className=e.className.replace(new RegExp("(^|\\b)"+e.className.split(" ").join("|")+"(\\b|$)","gi")," "),h.classList?h.classList.add(o.currentClass):h.className+=" "+o.currentClass,r(h,s?()=>o:o.switchTitle,o,s)}};t=new WeakMap,r=new WeakMap,n=new WeakMap,o=new WeakMap,i=new WeakMap,a=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,f=new WeakMap,h.prototype.cursorBlink=(e,t)=>(t=t||void 0,e?(t.typeSurface.innerHTML=t.typeSurface.innerHTML.replace(/\||&nbsp;*(<\/span>)?$/,"$1").trim(),t.typeSurface.innerHTML=t.typeSurface.innerHTML+'<span style="display: inline-block;font-weight: normal; color: black; text-decoration: none">&#124;</span>'):t.typeSurface.innerHTML=t.typeSurface.innerHTML.replace(/\|(<\/span>)$/,"&nbsp;$1"),t);var m=e=>{let t=0;return Array.prototype.forEach.call(e.childNodes,(e=>{if(3===e.nodeType){const r=e.textContent||"";let n=0;for(;n<r.length;){if(/\s/.test(r[n]))for(;n<r.length&&/\s/.test(r[n]);)++n;else++n;++t}}else 1===e.nodeType&&(t+=m(e))})),t},y=(e,t)=>{let r="";const n=Array.prototype.slice.call(e.childNodes);for(let e=0;e<n.length&&t>0;++e){const o=n[e];if(3===o.nodeType){const e=o.textContent||"";let n=0,s="";for(;n<e.length&&t>0;){if(/\s/.test(e[n])){const t=n;for(;n<e.length&&/\s/.test(e[n]);)++n;s+=e.slice(t,n)}else s+=e[n],++n;--t}r+=s}else if(1===o.nodeType){const e=y(o,t);if(e.html){const t=o.cloneNode(!1);t.innerHTML=e.html,r+=t.outerHTML}t=e.remaining}}return{html:r,remaining:t}};h.prototype.typingEffect=(e,t,r,n=!1)=>{const o=(r=r||void 0).titles.length;let s=0;for(let t=1;t<o;++t)if(r.titles[t]===e){s=t;break}e=e||r.titles[s+1];let i=!0;r.typeSurface.hasAttribute("style")&&r.typeSurface.removeAttribute("style"),e.hasAttribute("style")&&r.typeSurface.setAttribute("style",e.getAttribute("style")),r.typeSurface.innerHTML="",r.typeSurface.style.display="block";for(let e=0;e<4;++e)setTimeout((()=>{r.cursorBlink(i,r),i=!i}),e*r.delaySwitch);return setTimeout((()=>{r.typeSurface.innerHTML="",r.cursorBlink(!0,r);const o=m(e);for(let s=0;s<o;++s)setTimeout((()=>{if(r.typeSurface.innerHTML=y(e,s+1).html+'<span style="font-weight: normal; color: black; text-decoration: none">&#124;</span>',e.textContent+"|"===r.typeSurface.textContent){r.typeSurface.innerHTML=e.innerHTML+'<span style="font-weight: normal; color: black; text-decoration: none">&#124;</span>';for(let o=0;o<8;++o)setTimeout((()=>{--o,r.cursorBlink(i,r),0===o&&t(e,n?()=>r:r.switchStyle,r,n)}),o*r.delaySwitch)}}),s*r.delayEffect)}),4*r.delaySwitch),r},e.default=h,"undefined"!=typeof window&&(window.TitleSwitcher=h)}})()})();"object"==typeof module&&module&&module.exports&&(module.exports=titleSwitcher);
1
+ "use strict";var titleSwitcher=(()=>{var t,e,s,i,r,n=Object.getOwnPropertyNames,o=(t={"js-build-tools-inject:process"(){}},function(){if(s)throw s[0];try{return t&&(e=(0,t[n(t)[0]])(t=0)),e}catch(t){throw s=[t],t}});return(i={"dist/main.js"(t){o();var e,s,i,r,n,a,l,c,f,h,u=function(t,e,s,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,s):r?r.value=s:e.set(t,s),s},p=function(t,e,s,i){if("a"===s&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?i:"a"===s?i.call(t):i?i.value:e.get(t)};Object.defineProperty(t,"__esModule",{value:!0});var d=class{constructor(t="",o="typingEffect"){e.set(this,!1),s.set(this,"displayTitle"),i.set(this,0),r.set(this,200),n.set(this,400),a.set(this,!1),l.set(this,[]),c.set(this,""),f.set(this,void 0),h.set(this,void 0),u(this,s,"displayTitle","f"),u(this,f,"string"==typeof o?"function"==typeof this[o]?this[o]:this.typingEffect:o,"f"),u(this,c,t,"f"),u(this,l,[],"f");const p=t?document.querySelectorAll(t):[];p&&p[0]&&(u(this,c,p[0],"f"),u(this,l,p[0].children,"f"))}get active(){return p(this,e,"f")}get currentClass(){return p(this,s,"f")}get currentIndex(){return p(this,i,"f")}get delayEffect(){return p(this,r,"f")}get delaySwitch(){return p(this,n,"f")}get switchStyle(){return p(this,f,"f")}get titles(){return p(this,l,"f")}get typeSurface(){return p(this,h,"f")}startTitles({delaySwitch:t=400,delayEffect:o=200,isRandom:d=!1,immediatePause:y=!1}={}){const w="typeSurface";if(u(this,n,t,"f"),u(this,r,o,"f"),u(this,a,d,"f"),u(this,e,!y,"f"),p(this,i,"f")>=p(this,l,"f").length||"string"==typeof p(this,c,"f"))return u(this,e,!1,"f"),console.warn(`No titles found for '${p(this,c,"f")}'`),this;p(this,a,"f")&&u(this,i,Math.round(Math.random()*(p(this,l,"f").length-2))+1,"f");const m=p(this,l,"f")[p(this,i,"f")];m.classList?m.classList.add(p(this,s,"f")):m.className+=" "+p(this,s,"f");const g=p(this,l,"f")[0].cloneNode(!0);return g.classList?g.classList.add(w):g.className+=" "+w,g.classList?g.classList.remove(p(this,s,"f")):g.className=g.className.replace(new RegExp("(^|\\b)"+g.className.split(" ").join("|")+"(\\b|$)","gi")," "),p(this,c,"f").insertBefore(g,p(this,c,"f").firstChild),u(this,h,p(this,c,"f").querySelectorAll("."+w)[0],"f"),p(this,h,"f").innerHTML="",p(this,h,"f").style.display="block",Array.prototype.forEach.call(p(this,l,"f"),(function(t){t.style.display="none"})),this.switchTitle(m,p(this,f,"f"),this)}pause(){u(this,e,!1,"f")}resume(){p(this,e,"f")||(u(this,e,!0,"f"),this.switchTitle(p(this,l,"f")[p(this,i,"f")],p(this,f,"f"),this))}switchTitle(t,s,r,n=!1){let o=1;const c=p(r=r||this,l,"f").length;for(let e=1;e<c;++e)if(p(r,l,"f")[e]===t){o=e;break}if(!p(r,e,"f"))return u(r,i,o,"f"),r;const f=p(r,l,"f").length-1;let h=1;if(1===f)return s(t,n?()=>r:r.switchTitle,r,n);if(p(r,a,"f")){r.typeSurface.textContent.trim()||(o=-1);do{h=Math.round(Math.random()*(f-1))+1}while(h===o)}else r.typeSurface.textContent.trim()||(o=f),h=o<f?o+1:1;const d=p(r,l,"f")[h];return t.classList?t.classList.remove(r.currentClass):t.className=t.className.replace(new RegExp("(^|\\b)"+t.className.split(" ").join("|")+"(\\b|$)","gi")," "),d.classList?d.classList.add(r.currentClass):d.className+=" "+r.currentClass,s(d,n?()=>r:r.switchTitle,r,n)}};e=new WeakMap,s=new WeakMap,i=new WeakMap,r=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,f=new WeakMap,h=new WeakMap;var y=t=>`<span data-cursor style="display: inline-block; font-weight: normal; color: inherit; text-decoration: none">${t?"&#124;":"&nbsp;"}</span>`;d.prototype.cursorBlink=(t,e)=>{const s=(e=e||void 0).typeSurface.querySelectorAll("[data-cursor]");return Array.prototype.forEach.call(s,(t=>t.parentNode&&t.parentNode.removeChild(t))),(t||s.length)&&e.typeSurface.insertAdjacentHTML("beforeend",y(t)),e};var w=t=>{let e=0;return Array.prototype.forEach.call(t.childNodes,(t=>{if(3===t.nodeType){const s=t.textContent||"";let i=0;for(;i<s.length;){if(/\s/.test(s[i]))for(;i<s.length&&/\s/.test(s[i]);)++i;else++i;++e}}else 1===t.nodeType&&(e+=w(t))})),e},m=(t,e)=>{let s="";const i=Array.prototype.slice.call(t.childNodes);for(let t=0;t<i.length&&e>0;++t){const r=i[t];if(3===r.nodeType){const t=r.textContent||"";let i=0,n="";for(;i<t.length&&e>0;){if(/\s/.test(t[i])){const e=i;for(;i<t.length&&/\s/.test(t[i]);)++i;n+=t.slice(e,i)}else n+=t[i],++i;--e}s+=n}else if(1===r.nodeType){const t=m(r,e);if(t.html){const e=r.cloneNode(!1);e.innerHTML=t.html,s+=e.outerHTML}e=t.remaining}}return{html:s,remaining:e}};d.prototype.typingEffect=(t,e,s,i=!1)=>{const r=(s=s||void 0).titles.length;let n=0;for(let e=1;e<r;++e)if(s.titles[e]===t){n=e;break}t=t||s.titles[n+1];let o=!0;s.typeSurface.hasAttribute("style")&&s.typeSurface.removeAttribute("style"),t.hasAttribute("style")&&s.typeSurface.setAttribute("style",t.getAttribute("style")),s.typeSurface.innerHTML="",s.typeSurface.style.display="block";for(let t=0;t<4;++t)setTimeout((()=>{s.cursorBlink(o,s),o=!o}),t*s.delaySwitch);return setTimeout((()=>{s.typeSurface.innerHTML="",s.cursorBlink(!0,s);const r=w(t);for(let n=0;n<r;++n)setTimeout((()=>{if(s.typeSurface.innerHTML=m(t,n+1).html+y(!0),t.textContent+"|"===s.typeSurface.textContent){s.typeSurface.innerHTML=t.innerHTML+y(!0);for(let r=0;r<8;++r)setTimeout((()=>{--r,s.cursorBlink(o,s),0===r&&e(t,i?()=>s:s.switchStyle,s,i)}),r*s.delaySwitch)}}),n*s.delayEffect)}),4*s.delaySwitch),s},t.default=d,"undefined"!=typeof window&&(window.TitleSwitcher=d)}},function(){try{return r||(0,i[n(i)[0]])((r={exports:{}}).exports,r),r.exports}catch(t){throw r=0,t}})()})();"object"==typeof module&&module&&module.exports&&(module.exports=titleSwitcher);
package/dist/main.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- require("core-js/modules/esnext.weak-map.delete-all.js");
4
3
  var __classPrivateFieldSet = void 0 && (void 0).__classPrivateFieldSet || function (receiver, state, value, kind, f) {
5
4
  if (kind === "m") throw new TypeError("Private method is not writable");
6
5
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -230,14 +229,21 @@ _TitleSwitcher_active = new WeakMap(), _TitleSwitcher_currentClass = new WeakMap
230
229
  * @param blinkOn
231
230
  * @param self
232
231
  */
232
+ /**
233
+ * The cursor's markup: a bar while it's on, a non-breaking space of the same box while it's off (so the line
234
+ * doesn't shift). `color: inherit` lets it match the text it follows, on light and dark pages alike, and
235
+ * `data-cursor` marks it so a blink replaces it instead of adding another one.
236
+ * @param visible - Show the bar (true) or the blank (false).
237
+ */
238
+ const cursorHtml = visible => `<span data-cursor style="display: inline-block; font-weight: normal; color: inherit; text-decoration: none">${visible ? '&#124;' : '&nbsp;'}</span>`;
233
239
  TitleSwitcher.prototype.cursorBlink = (blinkOn, self) => {
234
- // display cursor effect
240
+ // display cursor effect: swap the one cursor for its other state (there's only ever one; earlier versions added
241
+ // a new span on every blink and left the old ones behind, empty)
235
242
  self = self || void 0;
236
- if (blinkOn) {
237
- self.typeSurface.innerHTML = self.typeSurface.innerHTML.replace(/\||&nbsp;*(<\/span>)?$/, '$1').trim();
238
- self.typeSurface.innerHTML = self.typeSurface.innerHTML + '<span style="display: inline-block;font-weight: normal; color: black; text-decoration: none">&#124;</span>';
239
- } else {
240
- self.typeSurface.innerHTML = self.typeSurface.innerHTML.replace(/\|(<\/span>)$/, '&nbsp;$1');
243
+ const cursors = self.typeSurface.querySelectorAll('[data-cursor]');
244
+ Array.prototype.forEach.call(cursors, cursor => cursor.parentNode && cursor.parentNode.removeChild(cursor));
245
+ if (blinkOn || cursors.length) {
246
+ self.typeSurface.insertAdjacentHTML('beforeend', cursorHtml(blinkOn));
241
247
  }
242
248
  return self;
243
249
  };
@@ -366,11 +372,11 @@ TitleSwitcher.prototype.typingEffect = (domObject, callBackFunction, self, runOn
366
372
  setTimeout(() => {
367
373
  // Reveal one more character, wrapped in whatever tags its position in the title falls under,
368
374
  // then append a formatted cursor on the end
369
- self.typeSurface.innerHTML = typedPartialHtml(domObject, i + 1).html + '<span style="font-weight: normal; color: black; text-decoration: none">&#124;</span>';
375
+ self.typeSurface.innerHTML = typedPartialHtml(domObject, i + 1).html + cursorHtml(true);
370
376
  // If the text content equals the title content with a cursor appended then we reached the end.
371
377
  if (domObject.textContent + '|' === self.typeSurface.textContent) {
372
378
  // Replace html with old html on last letter, so we get all the html formatting applied
373
- self.typeSurface.innerHTML = domObject.innerHTML + '<span style="font-weight: normal; color: black; text-decoration: none">&#124;</span>';
379
+ self.typeSurface.innerHTML = domObject.innerHTML + cursorHtml(true);
374
380
  // Run the blinking cursor two times the regular time in order to let the text be readable before switching
375
381
  for (let j = 0; j < numBlinks * 2; ++j) {
376
382
  setTimeout(() => {
package/dist/main.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";require("core-js/modules/esnext.weak-map.delete-all.js");var _TitleSwitcher_active,_TitleSwitcher_currentClass,_TitleSwitcher_currentIndex,_TitleSwitcher_delayEffect,_TitleSwitcher_delaySwitch,_TitleSwitcher_isRandom,_TitleSwitcher_titles,_TitleSwitcher_titlesContainer,_TitleSwitcher_switchStyle,_TitleSwitcher_typeSurface,__classPrivateFieldSet=function(e,t,i,s,l){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!l)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!l:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?l.call(e,i):l?l.value=i:t.set(e,i),i},__classPrivateFieldGet=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};Object.defineProperty(exports,"__esModule",{value:!0});class TitleSwitcher{constructor(e="",t="typingEffect"){_TitleSwitcher_active.set(this,!1),_TitleSwitcher_currentClass.set(this,"displayTitle"),_TitleSwitcher_currentIndex.set(this,0),_TitleSwitcher_delayEffect.set(this,200),_TitleSwitcher_delaySwitch.set(this,400),_TitleSwitcher_isRandom.set(this,!1),_TitleSwitcher_titles.set(this,[]),_TitleSwitcher_titlesContainer.set(this,""),_TitleSwitcher_switchStyle.set(this,void 0),_TitleSwitcher_typeSurface.set(this,void 0),__classPrivateFieldSet(this,_TitleSwitcher_currentClass,"displayTitle","f"),__classPrivateFieldSet(this,_TitleSwitcher_switchStyle,"string"==typeof t?"function"==typeof this[t]?this[t]:this.typingEffect:t,"f"),__classPrivateFieldSet(this,_TitleSwitcher_titlesContainer,e,"f"),__classPrivateFieldSet(this,_TitleSwitcher_titles,[],"f");const i=e?document.querySelectorAll(e):[];i&&i[0]&&(__classPrivateFieldSet(this,_TitleSwitcher_titlesContainer,i[0],"f"),__classPrivateFieldSet(this,_TitleSwitcher_titles,i[0].children,"f"))}get active(){return __classPrivateFieldGet(this,_TitleSwitcher_active,"f")}get currentClass(){return __classPrivateFieldGet(this,_TitleSwitcher_currentClass,"f")}get currentIndex(){return __classPrivateFieldGet(this,_TitleSwitcher_currentIndex,"f")}get delayEffect(){return __classPrivateFieldGet(this,_TitleSwitcher_delayEffect,"f")}get delaySwitch(){return __classPrivateFieldGet(this,_TitleSwitcher_delaySwitch,"f")}get switchStyle(){return __classPrivateFieldGet(this,_TitleSwitcher_switchStyle,"f")}get titles(){return __classPrivateFieldGet(this,_TitleSwitcher_titles,"f")}get typeSurface(){return __classPrivateFieldGet(this,_TitleSwitcher_typeSurface,"f")}startTitles({delaySwitch:e=400,delayEffect:t=200,isRandom:i=!1,immediatePause:s=!1}={}){const l="typeSurface";if(__classPrivateFieldSet(this,_TitleSwitcher_delaySwitch,e,"f"),__classPrivateFieldSet(this,_TitleSwitcher_delayEffect,t,"f"),__classPrivateFieldSet(this,_TitleSwitcher_isRandom,i,"f"),__classPrivateFieldSet(this,_TitleSwitcher_active,!s,"f"),__classPrivateFieldGet(this,_TitleSwitcher_currentIndex,"f")>=__classPrivateFieldGet(this,_TitleSwitcher_titles,"f").length||"string"==typeof __classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f"))return __classPrivateFieldSet(this,_TitleSwitcher_active,!1,"f"),console.warn(`No titles found for '${__classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f")}'`),this;__classPrivateFieldGet(this,_TitleSwitcher_isRandom,"f")&&__classPrivateFieldSet(this,_TitleSwitcher_currentIndex,Math.round(Math.random()*(__classPrivateFieldGet(this,_TitleSwitcher_titles,"f").length-2))+1,"f");const r=__classPrivateFieldGet(this,_TitleSwitcher_titles,"f")[__classPrivateFieldGet(this,_TitleSwitcher_currentIndex,"f")];r.classList?r.classList.add(__classPrivateFieldGet(this,_TitleSwitcher_currentClass,"f")):r.className+=" "+__classPrivateFieldGet(this,_TitleSwitcher_currentClass,"f");const a=__classPrivateFieldGet(this,_TitleSwitcher_titles,"f")[0].cloneNode(!0);return a.classList?a.classList.add(l):a.className+=" "+l,a.classList?a.classList.remove(__classPrivateFieldGet(this,_TitleSwitcher_currentClass,"f")):a.className=a.className.replace(new RegExp("(^|\\b)"+a.className.split(" ").join("|")+"(\\b|$)","gi")," "),__classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f").insertBefore(a,__classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f").firstChild),__classPrivateFieldSet(this,_TitleSwitcher_typeSurface,__classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f").querySelectorAll("."+l)[0],"f"),__classPrivateFieldGet(this,_TitleSwitcher_typeSurface,"f").innerHTML="",__classPrivateFieldGet(this,_TitleSwitcher_typeSurface,"f").style.display="block",Array.prototype.forEach.call(__classPrivateFieldGet(this,_TitleSwitcher_titles,"f"),(function(e){e.style.display="none"})),this.switchTitle(r,__classPrivateFieldGet(this,_TitleSwitcher_switchStyle,"f"),this)}pause(){__classPrivateFieldSet(this,_TitleSwitcher_active,!1,"f")}resume(){__classPrivateFieldGet(this,_TitleSwitcher_active,"f")||(__classPrivateFieldSet(this,_TitleSwitcher_active,!0,"f"),this.switchTitle(__classPrivateFieldGet(this,_TitleSwitcher_titles,"f")[__classPrivateFieldGet(this,_TitleSwitcher_currentIndex,"f")],__classPrivateFieldGet(this,_TitleSwitcher_switchStyle,"f"),this))}switchTitle(e,t,i,s=!1){let l=1;const r=__classPrivateFieldGet(i=i||this,_TitleSwitcher_titles,"f").length;for(let t=1;t<r;++t)if(__classPrivateFieldGet(i,_TitleSwitcher_titles,"f")[t]===e){l=t;break}if(!__classPrivateFieldGet(i,_TitleSwitcher_active,"f"))return __classPrivateFieldSet(i,_TitleSwitcher_currentIndex,l,"f"),i;const a=__classPrivateFieldGet(i,_TitleSwitcher_titles,"f").length-1;let c=1;if(1===a)return t(e,s?()=>i:i.switchTitle,i,s);if(__classPrivateFieldGet(i,_TitleSwitcher_isRandom,"f")){i.typeSurface.textContent.trim()||(l=-1);do{c=Math.round(Math.random()*(a-1))+1}while(c===l)}else i.typeSurface.textContent.trim()||(l=a),c=l<a?l+1:1;const _=__classPrivateFieldGet(i,_TitleSwitcher_titles,"f")[c];return e.classList?e.classList.remove(i.currentClass):e.className=e.className.replace(new RegExp("(^|\\b)"+e.className.split(" ").join("|")+"(\\b|$)","gi")," "),_.classList?_.classList.add(i.currentClass):_.className+=" "+i.currentClass,t(_,s?()=>i:i.switchTitle,i,s)}}_TitleSwitcher_active=new WeakMap,_TitleSwitcher_currentClass=new WeakMap,_TitleSwitcher_currentIndex=new WeakMap,_TitleSwitcher_delayEffect=new WeakMap,_TitleSwitcher_delaySwitch=new WeakMap,_TitleSwitcher_isRandom=new WeakMap,_TitleSwitcher_titles=new WeakMap,_TitleSwitcher_titlesContainer=new WeakMap,_TitleSwitcher_switchStyle=new WeakMap,_TitleSwitcher_typeSurface=new WeakMap,TitleSwitcher.prototype.cursorBlink=(e,t)=>(t=t||void 0,e?(t.typeSurface.innerHTML=t.typeSurface.innerHTML.replace(/\||&nbsp;*(<\/span>)?$/,"$1").trim(),t.typeSurface.innerHTML=t.typeSurface.innerHTML+'<span style="display: inline-block;font-weight: normal; color: black; text-decoration: none">&#124;</span>'):t.typeSurface.innerHTML=t.typeSurface.innerHTML.replace(/\|(<\/span>)$/,"&nbsp;$1"),t);const typedLength=e=>{let t=0;return Array.prototype.forEach.call(e.childNodes,(e=>{if(3===e.nodeType){const i=e.textContent||"";let s=0;for(;s<i.length;){if(/\s/.test(i[s]))for(;s<i.length&&/\s/.test(i[s]);)++s;else++s;++t}}else 1===e.nodeType&&(t+=typedLength(e))})),t},typedPartialHtml=(e,t)=>{let i="";const s=Array.prototype.slice.call(e.childNodes);for(let e=0;e<s.length&&t>0;++e){const l=s[e];if(3===l.nodeType){const e=l.textContent||"";let s=0,r="";for(;s<e.length&&t>0;){if(/\s/.test(e[s])){const t=s;for(;s<e.length&&/\s/.test(e[s]);)++s;r+=e.slice(t,s)}else r+=e[s],++s;--t}i+=r}else if(1===l.nodeType){const e=typedPartialHtml(l,t);if(e.html){const t=l.cloneNode(!1);t.innerHTML=e.html,i+=t.outerHTML}t=e.remaining}}return{html:i,remaining:t}};TitleSwitcher.prototype.typingEffect=(e,t,i,s=!1)=>{const l=(i=i||void 0).titles.length;let r=0;for(let t=1;t<l;++t)if(i.titles[t]===e){r=t;break}e=e||i.titles[r+1];let a=!0;i.typeSurface.hasAttribute("style")&&i.typeSurface.removeAttribute("style"),e.hasAttribute("style")&&i.typeSurface.setAttribute("style",e.getAttribute("style")),i.typeSurface.innerHTML="",i.typeSurface.style.display="block";for(let e=0;e<4;++e)setTimeout((()=>{i.cursorBlink(a,i),a=!a}),e*i.delaySwitch);return setTimeout((()=>{i.typeSurface.innerHTML="",i.cursorBlink(!0,i);const l=typedLength(e);for(let r=0;r<l;++r)setTimeout((()=>{if(i.typeSurface.innerHTML=typedPartialHtml(e,r+1).html+'<span style="font-weight: normal; color: black; text-decoration: none">&#124;</span>',e.textContent+"|"===i.typeSurface.textContent){i.typeSurface.innerHTML=e.innerHTML+'<span style="font-weight: normal; color: black; text-decoration: none">&#124;</span>';for(let l=0;l<8;++l)setTimeout((()=>{--l,i.cursorBlink(a,i),0===l&&t(e,s?()=>i:i.switchStyle,i,s)}),l*i.delaySwitch)}}),r*i.delayEffect)}),4*i.delaySwitch),i},exports.default=TitleSwitcher,"undefined"!=typeof window&&(window.TitleSwitcher=TitleSwitcher);
1
+ "use strict";var _TitleSwitcher_active,_TitleSwitcher_currentClass,_TitleSwitcher_currentIndex,_TitleSwitcher_delayEffect,_TitleSwitcher_delaySwitch,_TitleSwitcher_isRandom,_TitleSwitcher_titles,_TitleSwitcher_titlesContainer,_TitleSwitcher_switchStyle,_TitleSwitcher_typeSurface,__classPrivateFieldSet=function(e,t,i,s,l){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!l)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!l:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?l.call(e,i):l?l.value=i:t.set(e,i),i},__classPrivateFieldGet=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};Object.defineProperty(exports,"__esModule",{value:!0});class TitleSwitcher{constructor(e="",t="typingEffect"){_TitleSwitcher_active.set(this,!1),_TitleSwitcher_currentClass.set(this,"displayTitle"),_TitleSwitcher_currentIndex.set(this,0),_TitleSwitcher_delayEffect.set(this,200),_TitleSwitcher_delaySwitch.set(this,400),_TitleSwitcher_isRandom.set(this,!1),_TitleSwitcher_titles.set(this,[]),_TitleSwitcher_titlesContainer.set(this,""),_TitleSwitcher_switchStyle.set(this,void 0),_TitleSwitcher_typeSurface.set(this,void 0),__classPrivateFieldSet(this,_TitleSwitcher_currentClass,"displayTitle","f"),__classPrivateFieldSet(this,_TitleSwitcher_switchStyle,"string"==typeof t?"function"==typeof this[t]?this[t]:this.typingEffect:t,"f"),__classPrivateFieldSet(this,_TitleSwitcher_titlesContainer,e,"f"),__classPrivateFieldSet(this,_TitleSwitcher_titles,[],"f");const i=e?document.querySelectorAll(e):[];i&&i[0]&&(__classPrivateFieldSet(this,_TitleSwitcher_titlesContainer,i[0],"f"),__classPrivateFieldSet(this,_TitleSwitcher_titles,i[0].children,"f"))}get active(){return __classPrivateFieldGet(this,_TitleSwitcher_active,"f")}get currentClass(){return __classPrivateFieldGet(this,_TitleSwitcher_currentClass,"f")}get currentIndex(){return __classPrivateFieldGet(this,_TitleSwitcher_currentIndex,"f")}get delayEffect(){return __classPrivateFieldGet(this,_TitleSwitcher_delayEffect,"f")}get delaySwitch(){return __classPrivateFieldGet(this,_TitleSwitcher_delaySwitch,"f")}get switchStyle(){return __classPrivateFieldGet(this,_TitleSwitcher_switchStyle,"f")}get titles(){return __classPrivateFieldGet(this,_TitleSwitcher_titles,"f")}get typeSurface(){return __classPrivateFieldGet(this,_TitleSwitcher_typeSurface,"f")}startTitles({delaySwitch:e=400,delayEffect:t=200,isRandom:i=!1,immediatePause:s=!1}={}){const l="typeSurface";if(__classPrivateFieldSet(this,_TitleSwitcher_delaySwitch,e,"f"),__classPrivateFieldSet(this,_TitleSwitcher_delayEffect,t,"f"),__classPrivateFieldSet(this,_TitleSwitcher_isRandom,i,"f"),__classPrivateFieldSet(this,_TitleSwitcher_active,!s,"f"),__classPrivateFieldGet(this,_TitleSwitcher_currentIndex,"f")>=__classPrivateFieldGet(this,_TitleSwitcher_titles,"f").length||"string"==typeof __classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f"))return __classPrivateFieldSet(this,_TitleSwitcher_active,!1,"f"),console.warn(`No titles found for '${__classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f")}'`),this;__classPrivateFieldGet(this,_TitleSwitcher_isRandom,"f")&&__classPrivateFieldSet(this,_TitleSwitcher_currentIndex,Math.round(Math.random()*(__classPrivateFieldGet(this,_TitleSwitcher_titles,"f").length-2))+1,"f");const r=__classPrivateFieldGet(this,_TitleSwitcher_titles,"f")[__classPrivateFieldGet(this,_TitleSwitcher_currentIndex,"f")];r.classList?r.classList.add(__classPrivateFieldGet(this,_TitleSwitcher_currentClass,"f")):r.className+=" "+__classPrivateFieldGet(this,_TitleSwitcher_currentClass,"f");const c=__classPrivateFieldGet(this,_TitleSwitcher_titles,"f")[0].cloneNode(!0);return c.classList?c.classList.add(l):c.className+=" "+l,c.classList?c.classList.remove(__classPrivateFieldGet(this,_TitleSwitcher_currentClass,"f")):c.className=c.className.replace(new RegExp("(^|\\b)"+c.className.split(" ").join("|")+"(\\b|$)","gi")," "),__classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f").insertBefore(c,__classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f").firstChild),__classPrivateFieldSet(this,_TitleSwitcher_typeSurface,__classPrivateFieldGet(this,_TitleSwitcher_titlesContainer,"f").querySelectorAll("."+l)[0],"f"),__classPrivateFieldGet(this,_TitleSwitcher_typeSurface,"f").innerHTML="",__classPrivateFieldGet(this,_TitleSwitcher_typeSurface,"f").style.display="block",Array.prototype.forEach.call(__classPrivateFieldGet(this,_TitleSwitcher_titles,"f"),(function(e){e.style.display="none"})),this.switchTitle(r,__classPrivateFieldGet(this,_TitleSwitcher_switchStyle,"f"),this)}pause(){__classPrivateFieldSet(this,_TitleSwitcher_active,!1,"f")}resume(){__classPrivateFieldGet(this,_TitleSwitcher_active,"f")||(__classPrivateFieldSet(this,_TitleSwitcher_active,!0,"f"),this.switchTitle(__classPrivateFieldGet(this,_TitleSwitcher_titles,"f")[__classPrivateFieldGet(this,_TitleSwitcher_currentIndex,"f")],__classPrivateFieldGet(this,_TitleSwitcher_switchStyle,"f"),this))}switchTitle(e,t,i,s=!1){let l=1;const r=__classPrivateFieldGet(i=i||this,_TitleSwitcher_titles,"f").length;for(let t=1;t<r;++t)if(__classPrivateFieldGet(i,_TitleSwitcher_titles,"f")[t]===e){l=t;break}if(!__classPrivateFieldGet(i,_TitleSwitcher_active,"f"))return __classPrivateFieldSet(i,_TitleSwitcher_currentIndex,l,"f"),i;const c=__classPrivateFieldGet(i,_TitleSwitcher_titles,"f").length-1;let a=1;if(1===c)return t(e,s?()=>i:i.switchTitle,i,s);if(__classPrivateFieldGet(i,_TitleSwitcher_isRandom,"f")){i.typeSurface.textContent.trim()||(l=-1);do{a=Math.round(Math.random()*(c-1))+1}while(a===l)}else i.typeSurface.textContent.trim()||(l=c),a=l<c?l+1:1;const _=__classPrivateFieldGet(i,_TitleSwitcher_titles,"f")[a];return e.classList?e.classList.remove(i.currentClass):e.className=e.className.replace(new RegExp("(^|\\b)"+e.className.split(" ").join("|")+"(\\b|$)","gi")," "),_.classList?_.classList.add(i.currentClass):_.className+=" "+i.currentClass,t(_,s?()=>i:i.switchTitle,i,s)}}_TitleSwitcher_active=new WeakMap,_TitleSwitcher_currentClass=new WeakMap,_TitleSwitcher_currentIndex=new WeakMap,_TitleSwitcher_delayEffect=new WeakMap,_TitleSwitcher_delaySwitch=new WeakMap,_TitleSwitcher_isRandom=new WeakMap,_TitleSwitcher_titles=new WeakMap,_TitleSwitcher_titlesContainer=new WeakMap,_TitleSwitcher_switchStyle=new WeakMap,_TitleSwitcher_typeSurface=new WeakMap;const cursorHtml=e=>`<span data-cursor style="display: inline-block; font-weight: normal; color: inherit; text-decoration: none">${e?"&#124;":"&nbsp;"}</span>`;TitleSwitcher.prototype.cursorBlink=(e,t)=>{const i=(t=t||void 0).typeSurface.querySelectorAll("[data-cursor]");return Array.prototype.forEach.call(i,(e=>e.parentNode&&e.parentNode.removeChild(e))),(e||i.length)&&t.typeSurface.insertAdjacentHTML("beforeend",cursorHtml(e)),t};const typedLength=e=>{let t=0;return Array.prototype.forEach.call(e.childNodes,(e=>{if(3===e.nodeType){const i=e.textContent||"";let s=0;for(;s<i.length;){if(/\s/.test(i[s]))for(;s<i.length&&/\s/.test(i[s]);)++s;else++s;++t}}else 1===e.nodeType&&(t+=typedLength(e))})),t},typedPartialHtml=(e,t)=>{let i="";const s=Array.prototype.slice.call(e.childNodes);for(let e=0;e<s.length&&t>0;++e){const l=s[e];if(3===l.nodeType){const e=l.textContent||"";let s=0,r="";for(;s<e.length&&t>0;){if(/\s/.test(e[s])){const t=s;for(;s<e.length&&/\s/.test(e[s]);)++s;r+=e.slice(t,s)}else r+=e[s],++s;--t}i+=r}else if(1===l.nodeType){const e=typedPartialHtml(l,t);if(e.html){const t=l.cloneNode(!1);t.innerHTML=e.html,i+=t.outerHTML}t=e.remaining}}return{html:i,remaining:t}};TitleSwitcher.prototype.typingEffect=(e,t,i,s=!1)=>{const l=(i=i||void 0).titles.length;let r=0;for(let t=1;t<l;++t)if(i.titles[t]===e){r=t;break}e=e||i.titles[r+1];let c=!0;i.typeSurface.hasAttribute("style")&&i.typeSurface.removeAttribute("style"),e.hasAttribute("style")&&i.typeSurface.setAttribute("style",e.getAttribute("style")),i.typeSurface.innerHTML="",i.typeSurface.style.display="block";for(let e=0;e<4;++e)setTimeout((()=>{i.cursorBlink(c,i),c=!c}),e*i.delaySwitch);return setTimeout((()=>{i.typeSurface.innerHTML="",i.cursorBlink(!0,i);const l=typedLength(e);for(let r=0;r<l;++r)setTimeout((()=>{if(i.typeSurface.innerHTML=typedPartialHtml(e,r+1).html+cursorHtml(!0),e.textContent+"|"===i.typeSurface.textContent){i.typeSurface.innerHTML=e.innerHTML+cursorHtml(!0);for(let l=0;l<8;++l)setTimeout((()=>{--l,i.cursorBlink(c,i),0===l&&t(e,s?()=>i:i.switchStyle,i,s)}),l*i.delaySwitch)}}),r*i.delayEffect)}),4*i.delaySwitch),i},exports.default=TitleSwitcher,"undefined"!=typeof window&&(window.TitleSwitcher=TitleSwitcher);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "title-switcher",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Add typing effect to titles and also switch through several titles.",
5
5
  "main": "dist/main.min.js",
6
6
  "types": "dist/main.d.ts",
@@ -30,17 +30,17 @@
30
30
  ],
31
31
  "repository": {
32
32
  "type": "git",
33
- "url": "git+https://github.com/jheagle/title-switcher-v2.git"
33
+ "url": "git+https://github.com/jheagle/title-switcher.git"
34
34
  },
35
35
  "author": "Joshua Heagle",
36
36
  "license": "MIT",
37
37
  "bugs": {
38
- "url": "https://github.com/jheagle/title-switcher-v2/issues"
38
+ "url": "https://github.com/jheagle/title-switcher/issues"
39
39
  },
40
- "homepage": "https://github.com/jheagle/title-switcher-v2#readme",
40
+ "homepage": "https://github.com/jheagle/title-switcher#readme",
41
41
  "devDependencies": {
42
42
  "@babel/core": "^8.1.0",
43
- "js-build-tools": "^8.0.0",
43
+ "js-build-tools": "^8.1.0",
44
44
  "release-it": "^21.1.1",
45
45
  "typedoc": "^0.28.20"
46
46
  },
@@ -59,8 +59,5 @@
59
59
  "@parcel/watcher": false,
60
60
  "unrs-resolver": false,
61
61
  "esbuild": false
62
- },
63
- "dependencies": {
64
- "core-js": "^3.51.0"
65
62
  }
66
63
  }