@sabre-js/sabre
Version:
A gpu accelerated ecmascript renderer for Advanced Substation Alpha (ASS) subtitles. Renders .ass and .ssa files over video in the browser.
12 lines (10 loc) • 4.41 kB
JavaScript
(function(global,external){var window=null;var self=null;var sabre=external.$;{function e(a,b,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""}var g="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
function h(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var k=h(this);function l(a,b){if(b)a:{var c=k;a=a.split(".");for(var d=0;d<a.length-1;d++){var f=a[d];if(!(f in c))break a;c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&g(c,a,{configurable:!0,writable:!0,value:b})}}
l("String.prototype.endsWith",function(a){return a?a:function(b,c){var d=e(this,b,"endsWith");void 0===c&&(c=d.length);c=Math.max(0,Math.min(c|0,d.length));for(var f=b.length;0<f&&0<c;)if(d[--c]!=b[--f])return!1;return 0>=f}});l("String.prototype.startsWith",function(a){return a?a:function(b,c){var d=e(this,b,"startsWith"),f=d.length,r=b.length;c=Math.max(0,Math.min(c|0,d.length));for(var m=0;m<r&&c<f;)if(d[c++]!=b[m++])return!1;return m>=r}});var n="",p;
if("undefined"!==typeof global.document)try{"undefined"!==typeof global.document.currentScript?p=global.document.currentScript.src:p=(new Function("return import.meta.url;"))()}catch(a){p="./dummy.js";for(var q=global.document.getElementsByTagName("script"),t=0;t<q.length;t++){var u=q[t].getAttribute("src");if(null!==u&&""!==u&&(u.endsWith("sabre.js")||u.endsWith("sabre.min.js"))){p=u;break}}}else p="./dummy.js";var v=p.startsWith("."),w=p.startsWith("/"),x=p.startsWith("http"),y=new URL(global.location.href);
if(v||w||!x)if(p.startsWith("//"))n=y.protocol+p;else if(v||!x&&!w){var z;n=y.protocol+"//"+y.host+":"+y.port+y.pathname.match(/^(.*\/).*?$/)[1]+(null!=(z=p.match(/^(.*\/).*?$/)[1])?z:"/")}else{var A;n=y.protocol+"//"+y.host+":"+y.port+(null!=(A=p.match(/^(.*\/).*?$/)[1])?A:"/")}else{var B;n=null!=(B=p.match(/^(.*\/).*?$/)[1])?B:"/"}
if("function"!==typeof require){var C=Object.create(Object,{});sabre["import"]=function(a,b){a+=".min.js";if("undefined"===typeof b||null===b)b=function(){};if("undefined"===typeof C[a]||!0!==C[a])if("function"===typeof global.importScripts&&"undefined"===typeof global.document){try{global.importScripts(n+a)}catch(f){b(!1);return}b(!0);C[a]=!0}else{var c=global.document.head,d=global.document.createElement("script");d.setAttribute("type","application/ecmascript");d.setAttribute("src",n+a);d.setAttribute("async",
"");d.addEventListener("load",function(){console.log("Finished Importing: "+a);b(!0)});d.addEventListener("error",function(){console.log("Failed Importing: "+a);b(!1)});C[a]=!0;c.appendChild(d)}};sabre.include=function(a,b){a+=".min.js";if("undefined"===typeof b||null===b)b=function(){};if("undefined"===typeof C[a]||!0!==C[a])if("function"===typeof global.importScripts&&"undefined"===typeof global.document){try{global.importScripts(n+a)}catch(f){b(!1);return}b(!0);C[a]=!0}else{var c=global.document.head,
d=global.document.createElement("script");d.setAttribute("type","application/ecmascript");d.setAttribute("src",n+a);d.addEventListener("load",function(){console.log("Finished Including: "+a);b(!0)});d.addEventListener("error",function(){console.log("Failed Including: "+a);b(!1)});C[a]=!0;c.appendChild(d)}};sabre.getScriptPath=function(){return n};sabre.include("util",function(a){a&&sabre.include("global-constants",function(b){b&&sabre.include("renderer-main")})})}else require("./util.min.js"),require("./global-constants.min.js"),
require("./renderer-main.min.js"),sabre.getScriptPath=function(){return n},module.exports=external;}if(++sabre.$===19){external.$=null;sabre.$=null}})(((function(){try{return globalThis||self||window;}catch(e){try{return self;}catch(f){return window;}}})()),((function(){try{return globalThis||global||self||window;}catch(e){try{return self;}catch(f){return window;}}})()).sabre=(((function(){try{return globalThis||global||self||window;}catch(e){try{return self;}catch(f){return window;}}})()).sabre||{$:{$:0}}));
//# sourceMappingURL=sabre.map