From cc2c794ad00abe624e92ad49f6dcc811ab72f58a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 4 Apr 2016 21:23:42 -0400 Subject: [PATCH] render ssa/ass subs in browser --- .../emby-webcomponents/.bower.json | 8 +- .../browserdeviceprofile.js | 4 +- .../iron-demo-helpers/.bower.json | 10 +- .../iron-demo-helpers/bower.json | 4 +- .../iron-demo-helpers/index.html | 2 +- .../iron-demo-helpers/url-bar.html | 9 + .../bower_components/iron-icon/.bower.json | 6 +- .../bower_components/iron-icons/.bower.json | 4 +- .../iron-overlay-behavior/.bower.json | 8 +- .../iron-overlay-behavior/bower.json | 2 +- .../iron-overlay-behavior.html | 73 +- .../iron-overlay-manager.html | 12 +- .../test/iron-overlay-behavior.html | 135 +- .../test/test-overlay.html | 71 +- .../bower_components/libjass/.bower.json | 15 + .../bower_components/libjass/CHANGELOG.md | 133 + dashboard-ui/bower_components/libjass/LICENSE | 202 + .../bower_components/libjass/libjass.css | 100 + .../bower_components/libjass/libjass.js | 9650 +++++++++++++++++ .../bower_components/libjass/libjass.js.map | 1 + .../bower_components/libjass/libjass.min.js | 24 + .../libjass/libjass.min.js.map | 1 + .../bower_components/libjass/package.json | 24 + dashboard-ui/scripts/htmlmediarenderer.js | 103 +- dashboard-ui/scripts/mediaplayer.js | 28 +- dashboard-ui/scripts/site.js | 2 + 26 files changed, 10493 insertions(+), 138 deletions(-) create mode 100644 dashboard-ui/bower_components/libjass/.bower.json create mode 100644 dashboard-ui/bower_components/libjass/CHANGELOG.md create mode 100644 dashboard-ui/bower_components/libjass/LICENSE create mode 100644 dashboard-ui/bower_components/libjass/libjass.css create mode 100644 dashboard-ui/bower_components/libjass/libjass.js create mode 100644 dashboard-ui/bower_components/libjass/libjass.js.map create mode 100644 dashboard-ui/bower_components/libjass/libjass.min.js create mode 100644 dashboard-ui/bower_components/libjass/libjass.min.js.map create mode 100644 dashboard-ui/bower_components/libjass/package.json diff --git a/dashboard-ui/bower_components/emby-webcomponents/.bower.json b/dashboard-ui/bower_components/emby-webcomponents/.bower.json index 6674fc2166..3ccead5bdf 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/.bower.json +++ b/dashboard-ui/bower_components/emby-webcomponents/.bower.json @@ -16,12 +16,12 @@ }, "devDependencies": {}, "ignore": [], - "version": "1.2.1", - "_release": "1.2.1", + "version": "1.2.2", + "_release": "1.2.2", "_resolution": { "type": "version", - "tag": "1.2.1", - "commit": "44c0d907dc06ccc317c008d78b06ae365358560a" + "tag": "1.2.2", + "commit": "090c43863857847e33055ba1d7ab278b17f76203" }, "_source": "git://github.com/MediaBrowser/emby-webcomponents.git", "_target": "^1.2.0", diff --git a/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js b/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js index f9d16c8c12..7d009394d2 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js +++ b/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js @@ -289,7 +289,7 @@ define(['browser'], function (browser) { }); // Can't use mkv on mobile because we have to use the native player controls and they won't be able to seek it - if (canPlayMkv && options.supportsAutoPlay) { + if (canPlayMkv && options.supportsCustomSeeking) { profile.TranscodingProfiles.push({ Container: 'mkv', Type: 'Video', @@ -320,7 +320,7 @@ define(['browser'], function (browser) { Context: 'Streaming', Protocol: 'hls', // Can't use this when autoplay is not supported - ForceLiveStream: options.supportsAutoPlay ? true : false + ForceLiveStream: options.supportsCustomSeeking ? true : false }); } diff --git a/dashboard-ui/bower_components/iron-demo-helpers/.bower.json b/dashboard-ui/bower_components/iron-demo-helpers/.bower.json index 40c9df6c87..294ff50528 100644 --- a/dashboard-ui/bower_components/iron-demo-helpers/.bower.json +++ b/dashboard-ui/bower_components/iron-demo-helpers/.bower.json @@ -1,6 +1,6 @@ { "name": "iron-demo-helpers", - "version": "1.2.2", + "version": "1.2.3", "description": "Utility classes to make building demo pages easier", "authors": [ "The Polymer Authors" @@ -30,7 +30,7 @@ "marked-element": "polymerelements/marked-element#^1.0.0", "prism-element": "PolymerElements/prism-element#^1.0.0", "iron-location": "PolymerElements/iron-location#^0.8.0", - "iron-flex-layout": "PolymerElements/iron-flex-layout#^1.3.1" + "iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0" }, "devDependencies": { "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0", @@ -41,11 +41,11 @@ "paper-styles": "PolymerElements/paper-styles#^1.1.0", "paper-checkbox": "PolymerElements/paper-checkbox#^1.0.0" }, - "_release": "1.2.2", + "_release": "1.2.3", "_resolution": { "type": "version", - "tag": "v1.2.2", - "commit": "2fc1d6901a555f76e1c12b17dedaa555d8d4d9a5" + "tag": "v1.2.3", + "commit": "8d2c2e6f49b3c414f2998e14330727e5195f2f3b" }, "_source": "git://github.com/polymerelements/iron-demo-helpers.git", "_target": "^1.0.0", diff --git a/dashboard-ui/bower_components/iron-demo-helpers/bower.json b/dashboard-ui/bower_components/iron-demo-helpers/bower.json index 14f5fc7bd8..d69d825c60 100644 --- a/dashboard-ui/bower_components/iron-demo-helpers/bower.json +++ b/dashboard-ui/bower_components/iron-demo-helpers/bower.json @@ -1,6 +1,6 @@ { "name": "iron-demo-helpers", - "version": "1.2.2", + "version": "1.2.3", "description": "Utility classes to make building demo pages easier", "authors": [ "The Polymer Authors" @@ -30,7 +30,7 @@ "marked-element": "polymerelements/marked-element#^1.0.0", "prism-element": "PolymerElements/prism-element#^1.0.0", "iron-location": "PolymerElements/iron-location#^0.8.0", - "iron-flex-layout": "PolymerElements/iron-flex-layout#^1.3.1" + "iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0" }, "devDependencies": { "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0", diff --git a/dashboard-ui/bower_components/iron-demo-helpers/index.html b/dashboard-ui/bower_components/iron-demo-helpers/index.html index c1076b4885..74ffffd627 100644 --- a/dashboard-ui/bower_components/iron-demo-helpers/index.html +++ b/dashboard-ui/bower_components/iron-demo-helpers/index.html @@ -14,7 +14,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN - paper-tooltip + iron-demo-helpers diff --git a/dashboard-ui/bower_components/iron-demo-helpers/url-bar.html b/dashboard-ui/bower_components/iron-demo-helpers/url-bar.html index 1bcf58b7bf..13f65680ca 100644 --- a/dashboard-ui/bower_components/iron-demo-helpers/url-bar.html +++ b/dashboard-ui/bower_components/iron-demo-helpers/url-bar.html @@ -1,3 +1,12 @@ + diff --git a/dashboard-ui/bower_components/iron-icon/.bower.json b/dashboard-ui/bower_components/iron-icon/.bower.json index 9784e3a3b7..f0167baf13 100644 --- a/dashboard-ui/bower_components/iron-icon/.bower.json +++ b/dashboard-ui/bower_components/iron-icon/.bower.json @@ -32,14 +32,14 @@ "web-component-tester": "^4.0.0", "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" }, - "homepage": "https://github.com/PolymerElements/iron-icon", + "homepage": "https://github.com/polymerelements/iron-icon", "_release": "1.0.8", "_resolution": { "type": "version", "tag": "v1.0.8", "commit": "f36b38928849ef3853db727faa8c9ef104d611eb" }, - "_source": "git://github.com/PolymerElements/iron-icon.git", + "_source": "git://github.com/polymerelements/iron-icon.git", "_target": "^1.0.0", - "_originalSource": "PolymerElements/iron-icon" + "_originalSource": "polymerelements/iron-icon" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/iron-icons/.bower.json b/dashboard-ui/bower_components/iron-icons/.bower.json index be52e7bfd2..3f0699241f 100644 --- a/dashboard-ui/bower_components/iron-icons/.bower.json +++ b/dashboard-ui/bower_components/iron-icons/.bower.json @@ -41,7 +41,7 @@ "tag": "v1.1.3", "commit": "c13869b57a9464dfc3a1f26e89858f8be37e7441" }, - "_source": "git://github.com/PolymerElements/iron-icons.git", + "_source": "git://github.com/polymerelements/iron-icons.git", "_target": "^1.0.0", - "_originalSource": "PolymerElements/iron-icons" + "_originalSource": "polymerelements/iron-icons" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json b/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json index 664fa6d850..507595d909 100644 --- a/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json +++ b/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json @@ -1,6 +1,6 @@ { "name": "iron-overlay-behavior", - "version": "1.6.1", + "version": "1.6.2", "license": "http://polymer.github.io/LICENSE.txt", "description": "Provides a behavior for making an element an overlay", "private": true, @@ -35,11 +35,11 @@ }, "ignore": [], "homepage": "https://github.com/polymerelements/iron-overlay-behavior", - "_release": "1.6.1", + "_release": "1.6.2", "_resolution": { "type": "version", - "tag": "v1.6.1", - "commit": "34f2ed86b2e46f2827dd09594ae99acff0f28029" + "tag": "v1.6.2", + "commit": "be4e703b6894af6d4013a8a9f514a384ee91e2db" }, "_source": "git://github.com/polymerelements/iron-overlay-behavior.git", "_target": "^1.0.0", diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/bower.json b/dashboard-ui/bower_components/iron-overlay-behavior/bower.json index defcba71e4..f23f3cf573 100644 --- a/dashboard-ui/bower_components/iron-overlay-behavior/bower.json +++ b/dashboard-ui/bower_components/iron-overlay-behavior/bower.json @@ -1,6 +1,6 @@ { "name": "iron-overlay-behavior", - "version": "1.6.1", + "version": "1.6.2", "license": "http://polymer.github.io/LICENSE.txt", "description": "Provides a behavior for making an element an overlay", "private": true, diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-behavior.html b/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-behavior.html index ce17424d73..f4b60cf4d3 100644 --- a/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-behavior.html +++ b/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-behavior.html @@ -15,6 +15,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-manager.html b/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-manager.html index 11a7a3bc67..df2cd04ab5 100644 --- a/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-manager.html +++ b/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-manager.html @@ -38,11 +38,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN */ this._backdropElement = null; - // Enable document-wide tap recognizer. - Polymer.Gestures.add(document, 'tap', null); - // We should be using only 'tap', but this would be a breaking change. - var tapEvent = ('ontouchstart' in window) ? 'tap' : 'click'; - document.addEventListener(tapEvent, this._onCaptureClick.bind(this), true); + // Listen to mousedown or touchstart to be sure to be the first to capture + // clicks outside the overlay. + var clickEvent = ('ontouchstart' in window) ? 'touchstart' : 'mousedown'; + document.addEventListener(clickEvent, this._onCaptureClick.bind(this), true); document.addEventListener('focus', this._onCaptureFocus.bind(this), true); document.addEventListener('keydown', this._onCaptureKeyDown.bind(this), true); }; @@ -167,7 +166,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN return; } this._overlays.splice(i, 1); - this._setZ(overlay, ''); var node = overlay.restoreFocusOnClose ? overlay.restoreFocusNode : null; overlay.restoreFocusNode = null; @@ -267,7 +265,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN _getZ: function(overlay) { var z = this._minimumZ; if (overlay) { - var z1 = Number(window.getComputedStyle(overlay).zIndex); + var z1 = Number(overlay.style.zIndex || window.getComputedStyle(overlay).zIndex); // Check if is a number // Number.isNaN not supported in IE 10+ if (z1 === z1) { diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/test/iron-overlay-behavior.html b/dashboard-ui/bower_components/iron-overlay-behavior/test/iron-overlay-behavior.html index 5c2408222d..4834a50eb6 100644 --- a/dashboard-ui/bower_components/iron-overlay-behavior/test/iron-overlay-behavior.html +++ b/dashboard-ui/bower_components/iron-overlay-behavior/test/iron-overlay-behavior.html @@ -127,10 +127,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN diff --git a/dashboard-ui/bower_components/libjass/.bower.json b/dashboard-ui/bower_components/libjass/.bower.json new file mode 100644 index 0000000000..8cb13bbd70 --- /dev/null +++ b/dashboard-ui/bower_components/libjass/.bower.json @@ -0,0 +1,15 @@ +{ + "name": "libjass", + "_cacheHeaders": { + "ETag": "\"fa735770625f92af7e5167367b2bce58\"", + "Last-Modified": "Sun, 24 Jan 2016 10:37:21 GMT", + "Content-Length": "260662", + "Content-Type": "application/octet-stream", + "Content-Disposition": "attachment; filename=libjass.zip" + }, + "_release": "e-tag:fa7357706", + "_source": "https://github.com/Arnavion/libjass/releases/download/v0.11.0/libjass.zip", + "_target": "*", + "_originalSource": "https://github.com/Arnavion/libjass/releases/download/v0.11.0/libjass.zip", + "_direct": true +} \ No newline at end of file diff --git a/dashboard-ui/bower_components/libjass/CHANGELOG.md b/dashboard-ui/bower_components/libjass/CHANGELOG.md new file mode 100644 index 0000000000..1fef252362 --- /dev/null +++ b/dashboard-ui/bower_components/libjass/CHANGELOG.md @@ -0,0 +1,133 @@ +### v0.11.0 - 2016/01/24 +- BREAKING CHANGE - WebRenderer.resize(width, height) used to have a broken implementation of letterboxing to move the subs div right or down. Now it's WebRenderer.resize(width, height, left, top) and expects the caller to calculate letterboxing itself and supply left and top accordingly. DefaultRenderer does it using the video resolution and users of WebRenderer can do the same. +- BREAKING CHANGE - DefaultRenderer.resize() now ignores its parameters and always resizes to its video element's dimensions. It had already stopped resizing the video element when it was renamed from resizeVideo in v0.6.0, so it doesn't make sense to let it take a completely different width and height. +- BREAKING CHANGE - Removed fullscreen support in DefaultRenderer. It started out as a hack using max z-index and works on even fewer browsers now. It probably didn't work for you anyway so it should be no big loss. +- Implemented experimental support for \t +- Added RendererSettings.fallbackFonts to set the fallback fonts for all styles. Defaults to 'Arial, Helvetica, sans-serif, "Segoe UI Symbol"'. +- Better compatibility with loose ASS scripts - assume unnamed first section is Script Info, fall back to Default style for missing styles, recognize arbitrary-case property names, normalize asterisks in style names, etc. +- Various font size improvements - faster calculation, fix for incorrect size when line-height is overridden by site CSS, fix for incorrect scaled sizes for letterboxed subs, fix for incorrect metrics for web fonts, etc. The last one requires that all web fonts be specified in RendererSettings.fontMap to be rendered accurately. +- WebRenderer now supports using local() URLs in addition to url() in CSS font-face rules. +- Added RendererSettings.useAttachedFonts. If true, TTF fonts attached to the script will be used in addition to fonts specified in RendererSettings.fontMap. This setting is false by default, and should only be enabled on trusted fonts since it uses a very naive base64 and TTF parser to extract the font names from the attachment. It also requires ES6 typed arrays - ArrayBuffer, DataView, Uint8Array, etc. in the environment. +- Various pre-render, SVG filter and DOM perf improvements. +- Fixed \fscx and \fscy to not scale shadows. +- Fixed \fscx and \fscy to have optional values. +- Fixed \fs+ and \fs- to have required values. +- Fixed \r to use the target style's alpha values instead of 1. +- Fixed \fad subs to not flash after the fade-out ends with low-resolution clocks. +- Fixed outlines to not be darker than they should be. +- Fixed styles to not ignore the ScaleX and ScaleY properties in the script. +- Fixed lack of sufficient space between normal and italic text. +- Fixed SVG filters to interpolate in sRGB space instead of RGB. +- Fixed ASS parser to complain if a script doesn't have a Script Info section at all. +- The promise returned from ASS.from*() is now properly rejected due to errors from loading the script, instead of just remaining unresolved forever. +- Fixed SRT parser to swallow UTF-8 BOM just like the ASS parser. +- Fixed all clocks to suppress redundant ticks if the current timestamp hasn't change from the last tick. +- Fixed {AutoClock, VideoClock}.{setEnabled, toggle} methods to actually enable / disable the high-resolution timer. + + +### v0.10.0 - 2015/05/05 +- Implemented libjass.renderers.AutoClock, a clock that automatically ticks and generates clock events according to the state of an external driver. +- Implemented \k +- libjass.{Set, Map, Promise} can now be set to null to force the use of the polyfills, even if it defaulted to a runtime-provided implementation. +- Added ASS.fromReadableStream(), a function that can be used to parse ASS from a readable stream such as the response of window.fetch(). +- ASS.fromUrl() now tries to use window.fetch() if available instead of XMLHttpRequest. +- Fixed constant pausing and playing on Firefox triggered by how slowly it updates video.currentTime (wasn't noticeable but still undesirable). +- Fixed a dialogue's animation state not getting updated while seeking if the start and end times of the seek were within its start and end times. +- Fixed wrapping mode 1 (end-of-line wrapping) to actually wrap. +- Fixed parser to parse the time components of karaoke tags as centiseconds instead of seconds. +- Fixed parser to swallow leading BOM, if any. +- Fixed errors reported by webworker API were empty objects without message and stack properties. + + +### v0.9.0 - 2014/11/27 +- BREAKING CHANGE - ASS.fromString() now returns a Promise of an ASS object, not an ASS object directly. The synchronous ASS parser used by ASS.fromString() is no more. +- BACKWARD-COMPATIBLE CHANGE - WebRenderer constructor parameters order has changed from (ass, clock, settings, libjassSubsWrapper) to (ass, clock, libjassSubsWrapper, settings). The constructor will detect the old order and reorder accordingly. +- Added ASS.fromStream and ASS.fromXhr that read a stream and an XMLHttpRequest object's response respectively and return (a Promise of) an ASS object. Both of these parse the script asynchronously. +- Added RendererSettings.enableSvg that can be used to toggle the use of SVG filter effects for outlines and blur. +- libjass.js now has an AMD wrapper so that it can be used with RequireJS, etc. +- Settings parameter is now optional for WebRenderer and DefaultRenderer. +- Added support for clock rates apart from 1 to clocks and renderers. +- Added a parameter to libjass.createWorker to specify the path to libjass.js that will run in the worker. +- Fixed Style and Dialogue constructors not setting defaults for missing properties. +- Fixed color and alpha parser to support more formats. +- Fixed SRT parser to replace all HTML tags it finds, instead of just the first one. +- Fixed font size calculation to use the vertical scale instead of horizontal. +- Fixed line-height on newlines. +- Fixed missing perspective on X and Y rotations. + + +### v0.8.0 - 2014/08/16 +- Added web worker support. libjass.parse can now be offloaded to a web worker. +- Implemented \fs+ and \fs- +- Added ASS.addEvent() to add dialogue lines to an ASS object. +- Renamed ClockEvent.TimeUpdate to ClockEvent.Tick, and added ClockEvent.Stop +- Clock.enable() and .disable() now return a boolean to indicate whether the function had any effect. +- Added Clock.setEnabled() to force the enabled-state to the given value. +- Renamed ManualClock.timeUpdate() to ManualClock.tick() +- Moved WebRenderer.enable(), .disable() and .enabled to NullRenderer +- Fixed not being able to parse tags with default values. +- Fixed font preloader downloading the same font multiple times because it didn't filter for duplicates. +- Fixed min-width value not taking separate left and right margins into account. +- Fixed absolutely positioned subs were always left-aligned even if they had an alignment tag. +- Fixed blur and outlines getting truncated. + + +### v0.7.0 - 2014/05/15 +- Implemented \be +- Split a new renderer, WebRenderer, off DefaultRenderer that doesn't rely on a video element. +- All renderers now require a Clock to generate time events. VideoClock is a Clock backed by a video element, while ManualClock is a clock that can be used to generate arbitrary time events. + + +### v0.6.0 - 2014/03/24 +- All script properties and style properties are now parsed and stored in the ASS and Style objects. +- Basic SRT support, by passing in a libjass.Format argument to ASS.fromString() +- \clip and \iclip now have their drawing instructions parsed as an array of libjass.parts.drawing.Instruction's instead of just a string. +- Added DefaultRenderer.enable(), DefaultRenderer.disable() and DefaultRenderer.toggle() to change whether the renderer is displaying subtitles or not. +- DefaultRenderer.resizeVideo is now called DefaultRenderer.resize. Now it only resizes the subtitle wrapper div, not the video element. +- Replaced the 41ms setInterval-bsed timer with a requestAnimationFrame-based timer to reduce load on minimized or hidden browser tabs. +- DefaultRenderer now renders dialogues in the correct order according to the script. +- Fixed incorrect font sizes. +- Replaced jake with gulp. + + +### v0.5.0 - 2014/01/26 +- Removed preLoadFonts renderer setting. It was redundant with the actual fontMap setting since the presence or absence of that setting is enough to signal whether the user wants to preload fonts or not. +- Multiple renderers can now be used on the same page without conflicting with each other. +- Implemented \shad, \xshad, \yshad +- Fixed ASS draw scale being used incorrectly. +- ASS.resolutionX and ASS.resolutionY are now properties of ASS.properties, a ScriptProperties object. + + +### v0.4.0 - 2013/12/27 +- All parts moved from the libjass.tags namespace to the libjass.parts namespace. +- Replaced PEG.js parser with a hand-written one. This allows for parsing lines that are strictly invalid grammar but are parsed successfully by VSFilter or libass. +- All ASS tags are now supported by the parser. +- Removed the useHighResolutionTimer setting for DefaultRenderer. DefaultRenderer always uses the 41ms timer now. +- Implemented \move +- Implemented ASS draw +- Fixed subs overflowing the video dimensions still being visible. +- SVG filters are now used for outlines and blur. +- Delay parsing of dialogue lines till they need to be pre-rendered. As a side-effect, all fonts in the font map are preloaded now, not just the ones used in the current script. + + +### v0.3.0 - 2013/10/28 +- Moved libjass.DefaultRenderer to libjass.renderers.DefaultRenderer +- Added libjass.renderers.NullRenderer, a renderer that doesn't render anything. +- DefaultRenderer's fontMap setting is now a Map instead of an Object. It now supports more than one URL for each font name. +- DefaultRenderer now generates the subtitle wrapper div itself. +- DefaultRenderer now takes video letterboxing into account when resizing the subtitles. +- DefaultRenderer has a new setting useHighResolutionTimer that makes it use a 41ms timer instead of video.timeUpdate's 250ms timer. +- div IDs and CSS class names are now prefixed with "libjass-" to avoid collisions with other elements on the page. +- All numeric CSS property values are now truncated to three decimal places. +- Added ```jake watch``` that rebuilds and runs tests on changes to the source. +- Added ```jake doc``` that builds API documentation. +- Added Travis CI build. + + +### v0.2.0 - 2013/09/11 +- Added libjass.DefaultRenderer, a class that handles initializing the layer div's, preloading fonts, and drawing Dialogues based on the current video time. +- libjass.js can now be loaded in node. Only the parser can be used. +- Tests can now be run with ```jake test``` or ```npm test``` using Mocha. + +### v0.1.0 - 2013/08/29 +- First npm release. diff --git a/dashboard-ui/bower_components/libjass/LICENSE b/dashboard-ui/bower_components/libjass/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/dashboard-ui/bower_components/libjass/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/dashboard-ui/bower_components/libjass/libjass.css b/dashboard-ui/bower_components/libjass/libjass.css new file mode 100644 index 0000000000..856eca4bf3 --- /dev/null +++ b/dashboard-ui/bower_components/libjass/libjass.css @@ -0,0 +1,100 @@ +/** + * libjass + * + * https://github.com/Arnavion/libjass + * + * Copyright 2013 Arnav Singh + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.libjass-wrapper { + position: relative; + overflow: hidden; +} + +.libjass-subs { + position: absolute; + overflow: hidden; +} + +.libjass-subs, .libjass-subs * { + pointer-events: none; + -webkit-animation-fill-mode: both !important; + animation-fill-mode: both !important; +} + +.libjass-subs.paused * { + -webkit-animation-play-state: paused !important; + animation-play-state: paused !important; +} + +.libjass-subs .an { + position: absolute; +} + +.libjass-subs .an1, .libjass-subs .an2, .libjass-subs .an3 { + bottom: 0; +} + +.libjass-subs .an4, .libjass-subs .an5, .libjass-subs .an6 { + display: table; + width: 100%; + height: 100%; +} + +.libjass-subs .an4 > *, .libjass-subs .an5 > *, .libjass-subs .an6 > * { + display: table-cell; + vertical-align: middle; +} + +.libjass-subs .an7, .libjass-subs .an8, .libjass-subs .an9 { + top: 0; +} + +.libjass-subs .an1, .libjass-subs .an4, .libjass-subs .an7 { + text-align: left; +} + +.libjass-subs .an2, .libjass-subs .an5, .libjass-subs .an8 { + text-align: center; +} + +.libjass-subs .an3, .libjass-subs .an6, .libjass-subs .an9 { + text-align: right; +} + +.libjass-subs { + line-height: 0; +} + +/* Filter wrapper span */ +.libjass-subs div[data-dialogue-id] > span { + -webkit-perspective-origin: center; + -webkit-perspective: 400px; + perspective-origin: center; + perspective: 400px; +} + +.libjass-font-measure { + position: absolute; + visibility: hidden; + border: 0; + margin: 0; + padding: 0; + line-height: normal; +} + +.libjass-filters { + display: block; +} diff --git a/dashboard-ui/bower_components/libjass/libjass.js b/dashboard-ui/bower_components/libjass/libjass.js new file mode 100644 index 0000000000..ddea430fd6 --- /dev/null +++ b/dashboard-ui/bower_components/libjass/libjass.js @@ -0,0 +1,9650 @@ +/** + * libjass + * + * https://github.com/Arnavion/libjass + * + * Copyright 2013 Arnav Singh + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function (root, factory) { + var global = this; + if (typeof define === "function" && define.amd) { + define([], function () { + return factory(global); + }); + } else if (typeof exports === "object" && typeof module === "object") { + module.exports = factory(global); + } else if (typeof exports === "object") { + exports.libjass = factory(global); + } else { + root.libjass = factory(global); + } +})(this, function (global) { + "use strict"; + return function (modules) { + var installedModules = Object.create(null); + function require(moduleId) { + if (installedModules[moduleId]) { + return installedModules[moduleId]; + } + var exports = installedModules[moduleId] = Object.create(null); + modules[moduleId](exports, require); + return exports; + } + return require(0); + }([ /* 0 ./index */ function (exports, require) { + var settings = require(23); + var settings_1 = require(23); + exports.debugMode = settings_1.debugMode; + exports.verboseMode = settings_1.verboseMode; + var set = require(33); + var set_1 = require(33); + exports.Set = set_1.Set; + var map = require(30); + var map_1 = require(30); + exports.Map = map_1.Map; + var promise = require(32); + var promise_1 = require(32); + exports.Promise = promise_1.Promise; + exports.DeferredPromise = promise_1.DeferredPromise; + var webworker = require(37); + exports.webworker = webworker; + var parts = require(8); + exports.parts = parts; + var parser = require(1); + exports.parser = parser; + var renderers = require(14); + exports.renderers = renderers; + var ass_1 = require(24); + exports.ASS = ass_1.ASS; + var attachment_1 = require(25); + exports.Attachment = attachment_1.Attachment; + exports.AttachmentType = attachment_1.AttachmentType; + var dialogue_1 = require(26); + exports.Dialogue = dialogue_1.Dialogue; + var script_properties_1 = require(28); + exports.ScriptProperties = script_properties_1.ScriptProperties; + var style_1 = require(29); + exports.Style = style_1.Style; + var misc_1 = require(27); + exports.BorderStyle = misc_1.BorderStyle; + exports.Format = misc_1.Format; + exports.WrappingStyle = misc_1.WrappingStyle; + Object.defineProperties(exports, { + debugMode: { + get: function () { + return settings.debugMode; + }, + set: settings.setDebugMode + }, + verboseMode: { + get: function () { + return settings.verboseMode; + }, + set: settings.setVerboseMode + }, + Set: { + get: function () { + return set.Set; + }, + set: set.setImplementation + }, + Map: { + get: function () { + return map.Map; + }, + set: map.setImplementation + }, + Promise: { + get: function () { + return promise.Promise; + }, + set: promise.setImplementation + } + }); + }, /* 1 ./parser/index */ function (exports, require) { + var parse_1 = require(3); + exports.parse = parse_1.parse; + var streams_1 = require(5); + exports.BrowserReadableStream = streams_1.BrowserReadableStream; + exports.StringStream = streams_1.StringStream; + exports.XhrStream = streams_1.XhrStream; + var stream_parsers_1 = require(4); + exports.StreamParser = stream_parsers_1.StreamParser; + exports.SrtStreamParser = stream_parsers_1.SrtStreamParser; + }, /* 2 ./parser/misc */ function (exports, require) { + var map_1 = require(30); + /** + * Parses a line into a {@link ./types/misc.Property}. + * + * @param {string} line + * @return {!Property} + */ + function parseLineIntoProperty(line) { + var colonPos = line.indexOf(":"); + if (colonPos === -1) { + return null; + } + var name = line.substr(0, colonPos); + var value = line.substr(colonPos + 1).replace(/^\s+/, ""); + return { + name: name, + value: value + }; + } + exports.parseLineIntoProperty = parseLineIntoProperty; + /** + * Parses a line into a {@link ./types/misc.TypedTemplate} according to the given format specifier. + * + * @param {string} line + * @param {!Array.} formatSpecifier + * @return {!TypedTemplate} + */ + function parseLineIntoTypedTemplate(line, formatSpecifier) { + var property = parseLineIntoProperty(line); + if (property === null) { + return null; + } + var value = property.value.split(","); + if (value.length > formatSpecifier.length) { + value[formatSpecifier.length - 1] = value.slice(formatSpecifier.length - 1).join(","); + } + var template = new map_1.Map(); + formatSpecifier.forEach(function (formatKey, index) { + template.set(formatKey, value[index]); + }); + return { + type: property.name, + template: template + }; + } + exports.parseLineIntoTypedTemplate = parseLineIntoTypedTemplate; + }, /* 3 ./parser/parse */ function (exports, require) { + var parts = require(8); + var settings_1 = require(23); + var map_1 = require(30); + var rules = new map_1.Map(); + /** + * Parses a given string with the specified rule. + * + * @param {string} input The string to be parsed. + * @param {string} rule The rule to parse the string with + * @return {*} The value returned depends on the rule used. + * + * @memberOf libjass.parser + */ + function parse(input, rule) { + var run = new ParserRun(input, rule); + if (run.result === null || run.result.end !== input.length) { + if (settings_1.debugMode) { + console.error("Parse failed. %s %s %o", rule, input, run.result); + } + throw new Error("Parse failed."); + } + return run.result.value; + } + exports.parse = parse; + /** + * This class represents a single run of the parser. + * + * @param {string} input + * @param {string} rule + * + * @constructor + * @private + */ + var ParserRun = function () { + function ParserRun(input, rule) { + this._input = input; + this._parseTree = new ParseNode(null); + this._result = rules.get(rule).call(this, this._parseTree); + } + Object.defineProperty(ParserRun.prototype, "result", { + /** + * @type {ParseNode} + */ + get: function () { + return this._result; + }, + enumerable: true, + configurable: true + }); + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_dialogueParts = function (parent) { + var _a; + var current = new ParseNode(parent); + current.value = []; + while (this._haveMore()) { + var enclosedTagsNode = this.parse_enclosedTags(current); + if (enclosedTagsNode !== null) { + (_a = current.value).push.apply(_a, enclosedTagsNode.value); + } else { + var whiteSpaceOrTextNode = this.parse_newline(current) || this.parse_hardspace(current) || this.parse_text(current); + if (whiteSpaceOrTextNode === null) { + parent.pop(); + return null; + } + if (whiteSpaceOrTextNode.value instanceof parts.Text && current.value[current.value.length - 1] instanceof parts.Text) { + // Merge consecutive text parts into one part + var previousTextPart = current.value[current.value.length - 1]; + current.value[current.value.length - 1] = new parts.Text(previousTextPart.value + whiteSpaceOrTextNode.value.value); + } else { + current.value.push(whiteSpaceOrTextNode.value); + } + } + } + var inDrawingMode = false; + current.value.forEach(function (part, i) { + if (part instanceof parts.DrawingMode) { + inDrawingMode = part.scale !== 0; + } else if (part instanceof parts.Text && inDrawingMode) { + current.value[i] = new parts.DrawingInstructions(parse(part.value, "drawingInstructions")); + } + }); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_enclosedTags = function (parent) { + var current = new ParseNode(parent); + current.value = []; + if (this.read(current, "{") === null) { + parent.pop(); + return null; + } + for (var next = this._peek(); this._haveMore() && next !== "}"; next = this._peek()) { + var childNode = null; + if (this.read(current, "\\") !== null) { + childNode = this.parse_tag_alpha(current) || this.parse_tag_iclip(current) || this.parse_tag_xbord(current) || this.parse_tag_ybord(current) || this.parse_tag_xshad(current) || this.parse_tag_yshad(current) || this.parse_tag_blur(current) || this.parse_tag_bord(current) || this.parse_tag_clip(current) || this.parse_tag_fade(current) || this.parse_tag_fscx(current) || this.parse_tag_fscy(current) || this.parse_tag_move(current) || this.parse_tag_shad(current) || this.parse_tag_fad(current) || this.parse_tag_fax(current) || this.parse_tag_fay(current) || this.parse_tag_frx(current) || this.parse_tag_fry(current) || this.parse_tag_frz(current) || this.parse_tag_fsp(current) || this.parse_tag_fsplus(current) || this.parse_tag_fsminus(current) || this.parse_tag_org(current) || this.parse_tag_pbo(current) || this.parse_tag_pos(current) || this.parse_tag_an(current) || this.parse_tag_be(current) || this.parse_tag_fn(current) || this.parse_tag_fr(current) || this.parse_tag_fs(current) || this.parse_tag_kf(current) || this.parse_tag_ko(current) || this.parse_tag_1a(current) || this.parse_tag_1c(current) || this.parse_tag_2a(current) || this.parse_tag_2c(current) || this.parse_tag_3a(current) || this.parse_tag_3c(current) || this.parse_tag_4a(current) || this.parse_tag_4c(current) || this.parse_tag_a(current) || this.parse_tag_b(current) || this.parse_tag_c(current) || this.parse_tag_i(current) || this.parse_tag_k(current) || this.parse_tag_K(current) || this.parse_tag_p(current) || this.parse_tag_q(current) || this.parse_tag_r(current) || this.parse_tag_s(current) || this.parse_tag_t(current) || this.parse_tag_u(current); + if (childNode === null) { + current.pop(); + } + } + if (childNode === null) { + childNode = this.parse_comment(current); + } + if (childNode !== null) { + if (childNode.value instanceof parts.Comment && current.value[current.value.length - 1] instanceof parts.Comment) { + // Merge consecutive comment parts into one part + current.value[current.value.length - 1] = new parts.Comment(current.value[current.value.length - 1].value + childNode.value.value); + } else { + current.value.push(childNode.value); + } + } else { + parent.pop(); + return null; + } + } + if (this.read(current, "}") === null) { + parent.pop(); + return null; + } + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_newline = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "\\N") === null) { + parent.pop(); + return null; + } + current.value = new parts.NewLine(); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_hardspace = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "\\h") === null) { + parent.pop(); + return null; + } + current.value = new parts.Text(" "); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_text = function (parent) { + var value = this._peek(); + var current = new ParseNode(parent); + var valueNode = new ParseNode(current, value); + current.value = new parts.Text(valueNode.value); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_comment = function (parent) { + var value = this._peek(); + var current = new ParseNode(parent); + var valueNode = new ParseNode(current, value); + current.value = new parts.Comment(valueNode.value); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_a = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "a") === null) { + parent.pop(); + return null; + } + var next = this._peek(); + switch (next) { + case "1": + var next2 = this._peek(2); + switch (next2) { + case "10": + case "11": + next = next2; + break; + } + break; + + case "2": + case "3": + case "5": + case "6": + case "7": + case "9": + break; + + default: + parent.pop(); + return null; + } + var valueNode = new ParseNode(current, next); + var value = null; + switch (valueNode.value) { + case "1": + value = 1; + break; + + case "2": + value = 2; + break; + + case "3": + value = 3; + break; + + case "5": + value = 7; + break; + + case "6": + value = 8; + break; + + case "7": + value = 9; + break; + + case "9": + value = 4; + break; + + case "10": + value = 5; + break; + + case "11": + value = 6; + break; + } + current.value = new parts.Alignment(value); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_alpha = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_an = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "an") === null) { + parent.pop(); + return null; + } + var next = this._peek(); + if (next < "1" || next > "9") { + parent.pop(); + return null; + } + var valueNode = new ParseNode(current, next); + current.value = new parts.Alignment(parseInt(valueNode.value)); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_b = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "b") === null) { + parent.pop(); + return null; + } + var valueNode = null; + var next = this._peek(); + if (next >= "1" && next <= "9") { + next = this._peek(3); + if (next.substr(1) === "00") { + valueNode = new ParseNode(current, next); + valueNode.value = parseInt(valueNode.value); + } + } + if (valueNode === null) { + valueNode = this.parse_enableDisable(current); + } + if (valueNode !== null) { + current.value = new parts.Bold(valueNode.value); + } else { + current.value = new parts.Bold(null); + } + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_be = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_blur = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_bord = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_c = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_clip = function (parent) { + return this._parse_tag_clip_or_iclip("clip", parent); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fad = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "fad") === null) { + parent.pop(); + return null; + } + if (this.read(current, "(") === null) { + parent.pop(); + return null; + } + var startNode = this.parse_decimal(current); + if (startNode === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var endNode = this.parse_decimal(current); + if (endNode === null) { + parent.pop(); + return null; + } + if (this.read(current, ")") === null) { + parent.pop(); + return null; + } + current.value = new parts.Fade(startNode.value / 1e3, endNode.value / 1e3); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fade = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "fade") === null) { + parent.pop(); + return null; + } + if (this.read(current, "(") === null) { + parent.pop(); + return null; + } + var a1Node = this.parse_decimal(current); + if (a1Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var a2Node = this.parse_decimal(current); + if (a2Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var a3Node = this.parse_decimal(current); + if (a3Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var t1Node = this.parse_decimal(current); + if (t1Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var t2Node = this.parse_decimal(current); + if (t2Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var t3Node = this.parse_decimal(current); + if (t3Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var t4Node = this.parse_decimal(current); + if (t4Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ")") === null) { + parent.pop(); + return null; + } + current.value = new parts.ComplexFade(1 - a1Node.value / 255, 1 - a2Node.value / 255, 1 - a3Node.value / 255, t1Node.value / 1e3, t2Node.value / 1e3, t3Node.value / 1e3, t4Node.value / 1e3); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fax = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fay = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fn = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "fn") === null) { + parent.pop(); + return null; + } + var valueNode = new ParseNode(current, ""); + for (var next = this._peek(); this._haveMore() && next !== "\\" && next !== "}"; next = this._peek()) { + valueNode.value += next; + } + if (valueNode.value.length > 0) { + current.value = new parts.FontName(valueNode.value); + } else { + current.value = new parts.FontName(null); + } + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fr = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_frx = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fry = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_frz = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fs = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fsplus = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "fs+") === null) { + parent.pop(); + return null; + } + var valueNode = this.parse_decimal(current); + if (valueNode === null) { + parent.pop(); + return null; + } + current.value = new parts.FontSizePlus(valueNode.value); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fsminus = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "fs-") === null) { + parent.pop(); + return null; + } + var valueNode = this.parse_decimal(current); + if (valueNode === null) { + parent.pop(); + return null; + } + current.value = new parts.FontSizeMinus(valueNode.value); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fscx = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "fscx") === null) { + parent.pop(); + return null; + } + var valueNode = this.parse_decimal(current); + if (valueNode !== null) { + current.value = new parts.FontScaleX(valueNode.value / 100); + } else { + current.value = new parts.FontScaleX(null); + } + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fscy = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "fscy") === null) { + parent.pop(); + return null; + } + var valueNode = this.parse_decimal(current); + if (valueNode !== null) { + current.value = new parts.FontScaleY(valueNode.value / 100); + } else { + current.value = new parts.FontScaleY(null); + } + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_fsp = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_i = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_iclip = function (parent) { + return this._parse_tag_clip_or_iclip("iclip", parent); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_k = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "k") === null) { + parent.pop(); + return null; + } + var valueNode = this.parse_decimal(current); + if (valueNode === null) { + parent.pop(); + return null; + } + current.value = new parts.ColorKaraoke(valueNode.value / 100); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_K = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "K") === null) { + parent.pop(); + return null; + } + var valueNode = this.parse_decimal(current); + if (valueNode === null) { + parent.pop(); + return null; + } + current.value = new parts.SweepingColorKaraoke(valueNode.value / 100); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_kf = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "kf") === null) { + parent.pop(); + return null; + } + var valueNode = this.parse_decimal(current); + if (valueNode === null) { + parent.pop(); + return null; + } + current.value = new parts.SweepingColorKaraoke(valueNode.value / 100); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_ko = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "ko") === null) { + parent.pop(); + return null; + } + var valueNode = this.parse_decimal(current); + if (valueNode === null) { + parent.pop(); + return null; + } + current.value = new parts.OutlineKaraoke(valueNode.value / 100); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_move = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "move") === null) { + parent.pop(); + return null; + } + if (this.read(current, "(") === null) { + parent.pop(); + return null; + } + var x1Node = this.parse_decimal(current); + if (x1Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var y1Node = this.parse_decimal(current); + if (y1Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var x2Node = this.parse_decimal(current); + if (x2Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var y2Node = this.parse_decimal(current); + if (y2Node === null) { + parent.pop(); + return null; + } + var t1Node = null; + var t2Node = null; + if (this.read(current, ",") !== null) { + t1Node = this.parse_decimal(current); + if (t1Node === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + t2Node = this.parse_decimal(current); + if (t2Node === null) { + parent.pop(); + return null; + } + } + if (this.read(current, ")") === null) { + parent.pop(); + return null; + } + current.value = new parts.Move(x1Node.value, y1Node.value, x2Node.value, y2Node.value, t1Node !== null ? t1Node.value / 1e3 : null, t2Node !== null ? t2Node.value / 1e3 : null); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_org = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "org") === null) { + parent.pop(); + return null; + } + if (this.read(current, "(") === null) { + parent.pop(); + return null; + } + var xNode = this.parse_decimal(current); + if (xNode === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var yNode = this.parse_decimal(current); + if (yNode === null) { + parent.pop(); + return null; + } + if (this.read(current, ")") === null) { + parent.pop(); + return null; + } + current.value = new parts.RotationOrigin(xNode.value, yNode.value); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_p = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_pbo = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_pos = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "pos") === null) { + parent.pop(); + return null; + } + if (this.read(current, "(") === null) { + parent.pop(); + return null; + } + var xNode = this.parse_decimal(current); + if (xNode === null) { + parent.pop(); + return null; + } + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var yNode = this.parse_decimal(current); + if (yNode === null) { + parent.pop(); + return null; + } + if (this.read(current, ")") === null) { + parent.pop(); + return null; + } + current.value = new parts.Position(xNode.value, yNode.value); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_q = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "q") === null) { + parent.pop(); + return null; + } + var next = this._peek(); + if (next < "0" || next > "3") { + parent.pop(); + return null; + } + var valueNode = new ParseNode(current, next); + current.value = new parts.WrappingStyle(parseInt(valueNode.value)); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_r = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "r") === null) { + parent.pop(); + return null; + } + var valueNode = new ParseNode(current, ""); + for (var next = this._peek(); this._haveMore() && next !== "\\" && next !== "}"; next = this._peek()) { + valueNode.value += next; + } + if (valueNode.value.length > 0) { + current.value = new parts.Reset(valueNode.value); + } else { + current.value = new parts.Reset(null); + } + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_s = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_shad = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_t = function (parent) { + var current = new ParseNode(parent); + if (this.read(current, "t") === null) { + parent.pop(); + return null; + } + if (this.read(current, "(") === null) { + parent.pop(); + return null; + } + var startNode = null; + var endNode = null; + var accelNode = null; + var firstNode = this.parse_decimal(current); + if (firstNode !== null) { + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var secondNode = this.parse_decimal(current); + if (secondNode !== null) { + startNode = firstNode; + endNode = secondNode; + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var thirdNode = this.parse_decimal(current); + if (thirdNode !== null) { + accelNode = thirdNode; + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + } + } else { + accelNode = firstNode; + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + } + } + var transformTags = []; + for (var next = this._peek(); this._haveMore() && next !== ")" && next !== "}"; next = this._peek()) { + var childNode = null; + if (this.read(current, "\\") !== null) { + childNode = this.parse_tag_alpha(current) || this.parse_tag_iclip(current) || this.parse_tag_xbord(current) || this.parse_tag_ybord(current) || this.parse_tag_xshad(current) || this.parse_tag_yshad(current) || this.parse_tag_blur(current) || this.parse_tag_bord(current) || this.parse_tag_clip(current) || this.parse_tag_fscx(current) || this.parse_tag_fscy(current) || this.parse_tag_shad(current) || this.parse_tag_fax(current) || this.parse_tag_fay(current) || this.parse_tag_frx(current) || this.parse_tag_fry(current) || this.parse_tag_frz(current) || this.parse_tag_fsp(current) || this.parse_tag_fsplus(current) || this.parse_tag_fsminus(current) || this.parse_tag_be(current) || this.parse_tag_fr(current) || this.parse_tag_fs(current) || this.parse_tag_1a(current) || this.parse_tag_1c(current) || this.parse_tag_2a(current) || this.parse_tag_2c(current) || this.parse_tag_3a(current) || this.parse_tag_3c(current) || this.parse_tag_4a(current) || this.parse_tag_4c(current) || this.parse_tag_c(current); + if (childNode === null) { + current.pop(); + } + } + if (childNode === null) { + childNode = this.parse_comment(current); + } + if (childNode !== null) { + if (childNode.value instanceof parts.Comment && transformTags[transformTags.length - 1] instanceof parts.Comment) { + // Merge consecutive comment parts into one part + transformTags[transformTags.length - 1] = new parts.Comment(transformTags[transformTags.length - 1].value + childNode.value.value); + } else { + transformTags.push(childNode.value); + } + } else { + parent.pop(); + return null; + } + } + this.read(current, ")"); + current.value = new parts.Transform(startNode !== null ? startNode.value / 1e3 : null, endNode !== null ? endNode.value / 1e3 : null, accelNode !== null ? accelNode.value / 1e3 : null, transformTags); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_u = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_xbord = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_xshad = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_ybord = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_yshad = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_1a = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_1c = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_2a = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_2c = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_3a = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_3c = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_4a = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_tag_4c = function () { + throw new Error("Method not implemented."); + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_drawingInstructions = function (parent) { + var current = new ParseNode(parent); + var currentType = null; + var numberParts = []; + current.value = []; + while (this._haveMore()) { + while (this.read(current, " ") !== null) {} + if (!this._haveMore()) { + break; + } + if (currentType !== null) { + var numberPart = this.parse_decimal(current); + if (numberPart !== null) { + numberParts.push(numberPart); + if (currentType === "m" && numberParts.length === 2) { + current.value.push(new parts.drawing.MoveInstruction(numberParts[0].value, numberParts[1].value)); + numberParts.splice(0, numberParts.length); + } else if (currentType === "l" && numberParts.length === 2) { + current.value.push(new parts.drawing.LineInstruction(numberParts[0].value, numberParts[1].value)); + numberParts.splice(0, numberParts.length); + } else if (currentType === "b" && numberParts.length === 6) { + current.value.push(new parts.drawing.CubicBezierCurveInstruction(numberParts[0].value, numberParts[1].value, numberParts[2].value, numberParts[3].value, numberParts[4].value, numberParts[5].value)); + numberParts.splice(0, numberParts.length); + } + continue; + } + } + var typePart = this.parse_text(current); + if (typePart === null) { + break; + } + var newType = typePart.value.value; + switch (newType) { + case "m": + case "l": + case "b": + currentType = newType; + numberParts.splice(0, numberParts.length); + break; + } + } + while (this.read(current, " ") !== null) {} + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_decimalInt32 = function (parent) { + var current = new ParseNode(parent); + var isNegative = this.read(current, "-") !== null; + var numberNode = new ParseNode(current, ""); + for (var next = this._peek(); this._haveMore() && next >= "0" && next <= "9"; next = this._peek()) { + numberNode.value += next; + } + if (numberNode.value.length === 0) { + parent.pop(); + return null; + } + var value = parseInt(numberNode.value); + if (value >= 4294967295) { + value = 4294967295; + } else if (isNegative) { + value = -value; + } + current.value = value; + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_hexInt32 = function (parent) { + var current = new ParseNode(parent); + var isNegative = this.read(current, "-") !== null; + var numberNode = new ParseNode(current, ""); + for (var next = this._peek(); this._haveMore() && (next >= "0" && next <= "9" || next >= "a" && next <= "f" || next >= "A" && next <= "F"); next = this._peek()) { + numberNode.value += next; + } + if (numberNode.value.length === 0) { + parent.pop(); + return null; + } + var value = parseInt(numberNode.value, 16); + if (value >= 4294967295) { + value = 4294967295; + } else if (isNegative) { + value = -value; + } + current.value = value; + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_decimalOrHexInt32 = function (parent) { + var current = new ParseNode(parent); + var valueNode = this.read(current, "&H") !== null || this.read(current, "&h") !== null ? this.parse_hexInt32(current) : this.parse_decimalInt32(current); + if (valueNode === null) { + parent.pop(); + return null; + } + current.value = valueNode.value; + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_decimal = function (parent) { + var current = new ParseNode(parent); + var negative = this.read(current, "-") !== null; + var numericalPart = this.parse_unsignedDecimal(current); + if (numericalPart === null) { + parent.pop(); + return null; + } + current.value = numericalPart.value; + if (negative) { + current.value = -current.value; + } + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_unsignedDecimal = function (parent) { + var current = new ParseNode(parent); + var characteristicNode = new ParseNode(current, ""); + var mantissaNode = null; + for (var next = this._peek(); this._haveMore() && next >= "0" && next <= "9"; next = this._peek()) { + characteristicNode.value += next; + } + if (characteristicNode.value.length === 0) { + parent.pop(); + return null; + } + if (this.read(current, ".") !== null) { + mantissaNode = new ParseNode(current, ""); + for (var next = this._peek(); this._haveMore() && next >= "0" && next <= "9"; next = this._peek()) { + mantissaNode.value += next; + } + if (mantissaNode.value.length === 0) { + parent.pop(); + return null; + } + } + current.value = parseFloat(characteristicNode.value + (mantissaNode !== null ? "." + mantissaNode.value : "")); + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_enableDisable = function (parent) { + var next = this._peek(); + if (next === "0" || next === "1") { + var result = new ParseNode(parent, next); + result.value = result.value === "1"; + return result; + } + return null; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_color = function (parent) { + var current = new ParseNode(parent); + while (this.read(current, "&") !== null || this.read(current, "H") !== null) {} + var valueNode = this.parse_hexInt32(current); + if (valueNode === null) { + parent.pop(); + return null; + } + var value = valueNode.value; + current.value = new parts.Color(value & 255, value >> 8 & 255, value >> 16 & 255); + while (this.read(current, "&") !== null || this.read(current, "H") !== null) {} + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_alpha = function (parent) { + var current = new ParseNode(parent); + while (this.read(current, "&") !== null || this.read(current, "H") !== null) {} + var valueNode = this.parse_hexInt32(current); + if (valueNode === null) { + parent.pop(); + return null; + } + var value = valueNode.value; + current.value = 1 - (value & 255) / 255; + while (this.read(current, "&") !== null || this.read(current, "H") !== null) {} + return current; + }; + /** + * @param {!ParseNode} parent + * @return {ParseNode} + */ + ParserRun.prototype.parse_colorWithAlpha = function (parent) { + var current = new ParseNode(parent); + var valueNode = this.parse_decimalOrHexInt32(current); + if (valueNode === null) { + parent.pop(); + return null; + } + var value = valueNode.value; + current.value = new parts.Color(value & 255, value >> 8 & 255, value >> 16 & 255, 1 - (value >> 24 & 255) / 255); + return current; + }; + /** + * @param {!ParseNode} parent + * @param {string} next + * @return {ParseNode} + */ + ParserRun.prototype.read = function (parent, next) { + if (this._peek(next.length) !== next) { + return null; + } + return new ParseNode(parent, next); + }; + /** + * @param {number=1} count + * @return {string} + * + * @private + */ + ParserRun.prototype._peek = function (count) { + if (count === void 0) { + count = 1; + } + // Fastpath for count === 1. http://jsperf.com/substr-vs-indexer + if (count === 1) { + return this._input[this._parseTree.end]; + } + return this._input.substr(this._parseTree.end, count); + }; + /** + * @return {boolean} + * + * @private + */ + ParserRun.prototype._haveMore = function () { + return this._parseTree.end < this._input.length; + }; + /** + * @param {string} tagName One of "clip" and "iclip" + * @param {!ParseNode} parent + * @return {ParseNode} + * + * @private + */ + ParserRun.prototype._parse_tag_clip_or_iclip = function (tagName, parent) { + var current = new ParseNode(parent); + if (this.read(current, tagName) === null) { + parent.pop(); + return null; + } + if (this.read(current, "(") === null) { + parent.pop(); + return null; + } + var x1Node = null; + var x2Node = null; + var y1Node = null; + var y2Node = null; + var scaleNode = null; + var commandsNode = null; + var firstNode = this.parse_decimal(current); + if (firstNode !== null) { + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + var secondNode = this.parse_decimal(current); + if (secondNode !== null) { + x1Node = firstNode; + y1Node = secondNode; + } else { + scaleNode = firstNode; + } + } + if (x1Node !== null && y1Node !== null) { + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + x2Node = this.parse_decimal(current); + if (this.read(current, ",") === null) { + parent.pop(); + return null; + } + y2Node = this.parse_decimal(current); + current.value = new parts.RectangularClip(x1Node.value, y1Node.value, x2Node.value, y2Node.value, tagName === "clip"); + } else { + commandsNode = new ParseNode(current, ""); + for (var next = this._peek(); this._haveMore() && next !== ")" && next !== "}"; next = this._peek()) { + commandsNode.value += next; + } + current.value = new parts.VectorClip(scaleNode !== null ? scaleNode.value : 1, parse(commandsNode.value, "drawingInstructions"), tagName === "clip"); + } + if (this.read(current, ")") === null) { + parent.pop(); + return null; + } + return current; + }; + return ParserRun; + }(); + /** + * Constructs a simple tag parser function and sets it on the prototype of the {@link ./parser/parse.ParserRun} class. + * + * @param {string} tagName The name of the tag to generate the parser function for + * @param {function(new: !libjass.parts.Part, *)} tagConstructor The type of tag to be returned by the generated parser function + * @param {function(!ParseNode): ParseNode} valueParser The parser for the tag's value + * @param {boolean} required Whether the tag's value is required or optional + * + * @private + */ + function makeTagParserFunction(tagName, tagConstructor, valueParser, required) { + ParserRun.prototype["parse_tag_" + tagName] = function (parent) { + var self = this; + var current = new ParseNode(parent); + if (self.read(current, tagName) === null) { + parent.pop(); + return null; + } + var valueNode = valueParser.call(self, current); + if (valueNode !== null) { + current.value = new tagConstructor(valueNode.value); + } else if (!required) { + current.value = new tagConstructor(null); + } else { + parent.pop(); + return null; + } + return current; + }; + } + makeTagParserFunction("alpha", parts.Alpha, ParserRun.prototype.parse_alpha, false); + makeTagParserFunction("be", parts.Blur, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("blur", parts.GaussianBlur, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("bord", parts.Border, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("c", parts.PrimaryColor, ParserRun.prototype.parse_color, false); + makeTagParserFunction("fax", parts.SkewX, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("fay", parts.SkewY, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("fr", parts.RotateZ, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("frx", parts.RotateX, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("fry", parts.RotateY, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("frz", parts.RotateZ, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("fs", parts.FontSize, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("fsp", parts.LetterSpacing, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("i", parts.Italic, ParserRun.prototype.parse_enableDisable, false); + makeTagParserFunction("p", parts.DrawingMode, ParserRun.prototype.parse_decimal, true); + makeTagParserFunction("pbo", parts.DrawingBaselineOffset, ParserRun.prototype.parse_decimal, true); + makeTagParserFunction("s", parts.StrikeThrough, ParserRun.prototype.parse_enableDisable, false); + makeTagParserFunction("shad", parts.Shadow, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("u", parts.Underline, ParserRun.prototype.parse_enableDisable, false); + makeTagParserFunction("xbord", parts.BorderX, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("xshad", parts.ShadowX, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("ybord", parts.BorderY, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("yshad", parts.ShadowY, ParserRun.prototype.parse_decimal, false); + makeTagParserFunction("1a", parts.PrimaryAlpha, ParserRun.prototype.parse_alpha, false); + makeTagParserFunction("1c", parts.PrimaryColor, ParserRun.prototype.parse_color, false); + makeTagParserFunction("2a", parts.SecondaryAlpha, ParserRun.prototype.parse_alpha, false); + makeTagParserFunction("2c", parts.SecondaryColor, ParserRun.prototype.parse_color, false); + makeTagParserFunction("3a", parts.OutlineAlpha, ParserRun.prototype.parse_alpha, false); + makeTagParserFunction("3c", parts.OutlineColor, ParserRun.prototype.parse_color, false); + makeTagParserFunction("4a", parts.ShadowAlpha, ParserRun.prototype.parse_alpha, false); + makeTagParserFunction("4c", parts.ShadowColor, ParserRun.prototype.parse_color, false); + for (var _i = 0, _a = Object.keys(ParserRun.prototype); _i < _a.length; _i++) { + var key = _a[_i]; + if (key.indexOf("parse_") === 0 && typeof ParserRun.prototype[key] === "function") { + rules.set(key.substr("parse_".length), ParserRun.prototype[key]); + } + } + /** + * This class represents a single parse node. It has a start and end position, and an optional value object. + * + * @param {ParseNode} parent The parent of this parse node. + * @param {*=null} value If provided, it is assigned as the value of the node. + * + * @constructor + * @private + */ + var ParseNode = function () { + function ParseNode(parent, value) { + if (value === void 0) { + value = null; + } + this._parent = parent; + this._children = []; + if (parent !== null) { + parent.children.push(this); + } + this._start = parent !== null ? parent.end : 0; + this._end = this._start; + this.value = value; + } + Object.defineProperty(ParseNode.prototype, "start", { + /** + * The start position of this parse node. + * + * @type {number} + */ + get: function () { + return this._start; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParseNode.prototype, "end", { + /** + * The end position of this parse node. + * + * @type {number} + */ + get: function () { + return this._end; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParseNode.prototype, "parent", { + /** + * @type {ParseNode} + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParseNode.prototype, "children", { + /** + * @type {!Array.} + */ + get: function () { + return this._children; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParseNode.prototype, "value", { + /** + * An optional object associated with this parse node. + * + * @type {*} + */ + get: function () { + return this._value; + }, + /** + * An optional object associated with this parse node. + * + * If the value is a string, then the end property is updated to be the length of the string. + * + * @type {*} + */ + set: function (newValue) { + this._value = newValue; + if (this._value !== null && this._value.constructor === String && this._children.length === 0) { + this._setEnd(this._start + this._value.length); + } + }, + enumerable: true, + configurable: true + }); + /** + * Removes the last child of this node and updates the end position to be end position of the new last child. + */ + ParseNode.prototype.pop = function () { + this._children.splice(this._children.length - 1, 1); + if (this._children.length > 0) { + this._setEnd(this._children[this._children.length - 1].end); + } else { + this._setEnd(this.start); + } + }; + /** + * Updates the end property of this node and its parent recursively to the root node. + * + * @param {number} newEnd + * + * @private + */ + ParseNode.prototype._setEnd = function (newEnd) { + this._end = newEnd; + if (this._parent !== null && this._parent.end !== this._end) { + this._parent._setEnd(this._end); + } + }; + return ParseNode; + }(); + var promise_1 = require(32); + var commands_1 = require(36); + var misc_1 = require(38); + misc_1.registerWorkerCommand(commands_1.WorkerCommands.Parse, function (parameters) { + return new promise_1.Promise(function (resolve) { + resolve(parse(parameters.input, parameters.rule)); + }); + }); + }, /* 4 ./parser/stream-parsers */ function (exports, require) { + var settings_1 = require(23); + var ass_1 = require(24); + var style_1 = require(29); + var dialogue_1 = require(26); + var attachment_1 = require(25); + var map_1 = require(30); + var promise_1 = require(32); + var misc_1 = require(2); + var Section; + (function (Section) { + Section[Section["ScriptInfo"] = 0] = "ScriptInfo"; + Section[Section["Styles"] = 1] = "Styles"; + Section[Section["Events"] = 2] = "Events"; + Section[Section["Fonts"] = 3] = "Fonts"; + Section[Section["Graphics"] = 4] = "Graphics"; + Section[Section["Other"] = 5] = "Other"; + Section[Section["EOF"] = 6] = "EOF"; + })(Section || (Section = {})); + /** + * A parser that parses an {@link libjass.ASS} object from a {@link libjass.parser.Stream}. + * + * @param {!libjass.parser.Stream} stream The {@link libjass.parser.Stream} to parse + * + * @constructor + * @memberOf libjass.parser + */ + var StreamParser = function () { + function StreamParser(stream) { + var _this = this; + this._stream = stream; + this._ass = new ass_1.ASS(); + this._minimalDeferred = new promise_1.DeferredPromise(); + this._deferred = new promise_1.DeferredPromise(); + this._shouldSwallowBom = true; + this._currentSection = Section.ScriptInfo; + this._currentAttachment = null; + this._stream.nextLine().then(function (line) { + return _this._onNextLine(line); + }, function (reason) { + _this._minimalDeferred.reject(reason); + _this._deferred.reject(reason); + }); + } + Object.defineProperty(StreamParser.prototype, "minimalASS", { + /** + * @type {!Promise.} A promise that will be resolved when the script properties of the ASS script have been parsed from the stream. Styles and events have not necessarily been + * parsed at the point this promise becomes resolved. + */ + get: function () { + return this._minimalDeferred.promise; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(StreamParser.prototype, "ass", { + /** + * @type {!Promise.} A promise that will be resolved when the entire stream has been parsed. + */ + get: function () { + return this._deferred.promise; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(StreamParser.prototype, "currentSection", { + /** + * @type {number} + */ + get: function () { + return this._currentSection; + }, + /** + * @type {number} + */ + set: function (value) { + if (this._currentAttachment !== null) { + this._ass.addAttachment(this._currentAttachment); + this._currentAttachment = null; + } + if (this._currentSection === Section.ScriptInfo && value !== Section.ScriptInfo) { + // Exiting script info section + this._minimalDeferred.resolve(this._ass); + } + if (value === Section.EOF) { + var scriptProperties = this._ass.properties; + if (scriptProperties.resolutionX === undefined || scriptProperties.resolutionY === undefined) { + // Malformed script. + this._minimalDeferred.reject("Malformed ASS script."); + this._deferred.reject("Malformed ASS script."); + } else { + this._minimalDeferred.resolve(this._ass); + this._deferred.resolve(this._ass); + } + } + this._currentSection = value; + }, + enumerable: true, + configurable: true + }); + /** + * @param {string} line + * + * @private + */ + StreamParser.prototype._onNextLine = function (line) { + var _this = this; + if (line === null) { + this.currentSection = Section.EOF; + return; + } + if (line[line.length - 1] === "\r") { + line = line.substr(0, line.length - 1); + } + if (line.charCodeAt(0) === 65279 && this._shouldSwallowBom) { + line = line.substr(1); + } + this._shouldSwallowBom = false; + if (line === "") {} else if (line[0] === ";" && this._currentAttachment === null) {} else if (line === "[Script Info]") { + this.currentSection = Section.ScriptInfo; + } else if (line === "[V4+ Styles]" || line === "[V4 Styles]") { + this.currentSection = Section.Styles; + } else if (line === "[Events]") { + this.currentSection = Section.Events; + } else if (line === "[Fonts]") { + this.currentSection = Section.Fonts; + } else if (line === "[Graphics]") { + this.currentSection = Section.Graphics; + } else { + if (this._currentAttachment === null && line[0] === "[" && line[line.length - 1] === "]") { + /* This looks like the start of a new section. The section name is unrecognized if it is. + * Since there's no current attachment being parsed it's definitely the start of a new section. + * If an attachment is being parsed, this might be part of the attachment. + */ + this.currentSection = Section.Other; + } + switch (this.currentSection) { + case Section.ScriptInfo: + var property = misc_1.parseLineIntoProperty(line); + if (property !== null) { + switch (property.name) { + case "PlayResX": + this._ass.properties.resolutionX = parseInt(property.value); + break; + + case "PlayResY": + this._ass.properties.resolutionY = parseInt(property.value); + break; + + case "WrapStyle": + this._ass.properties.wrappingStyle = parseInt(property.value); + break; + + case "ScaledBorderAndShadow": + this._ass.properties.scaleBorderAndShadow = property.value === "yes"; + break; + } + } + break; + + case Section.Styles: + if (this._ass.stylesFormatSpecifier === null) { + var property_1 = misc_1.parseLineIntoProperty(line); + if (property_1 !== null && property_1.name === "Format") { + this._ass.stylesFormatSpecifier = property_1.value.split(",").map(function (str) { + return str.trim(); + }); + } else {} + } else { + try { + this._ass.addStyle(line); + } catch (ex) { + if (settings_1.debugMode) { + console.error("Could not parse style from line " + line + " - " + (ex.stack || ex)); + } + } + } + break; + + case Section.Events: + if (this._ass.dialoguesFormatSpecifier === null) { + var property_2 = misc_1.parseLineIntoProperty(line); + if (property_2 !== null && property_2.name === "Format") { + this._ass.dialoguesFormatSpecifier = property_2.value.split(",").map(function (str) { + return str.trim(); + }); + } else {} + } else { + try { + this._ass.addEvent(line); + } catch (ex) { + if (settings_1.debugMode) { + console.error("Could not parse event from line " + line + " - " + (ex.stack || ex)); + } + } + } + break; + + case Section.Fonts: + case Section.Graphics: + var startOfNewAttachmentRegex = this.currentSection === Section.Fonts ? /^fontname:(.+)/ : /^filename:(.+)/; + var startOfNewAttachment = startOfNewAttachmentRegex.exec(line); + if (startOfNewAttachment !== null) { + // Start of new attachment + if (this._currentAttachment !== null) { + this._ass.addAttachment(this._currentAttachment); + this._currentAttachment = null; + } + this._currentAttachment = new attachment_1.Attachment(startOfNewAttachment[1].trim(), this.currentSection === Section.Fonts ? attachment_1.AttachmentType.Font : attachment_1.AttachmentType.Graphic); + } else if (this._currentAttachment !== null) { + try { + this._currentAttachment.contents += uuencodedToBase64(line); + } catch (ex) { + if (settings_1.debugMode) { + console.error("Encountered error while reading font " + this._currentAttachment.filename + ": %o", ex); + } + this._currentAttachment = null; + } + } else {} + break; + + case Section.Other: + // Ignore other sections. + break; + + default: + throw new Error("Unhandled state " + this.currentSection); + } + } + this._stream.nextLine().then(function (line) { + return _this._onNextLine(line); + }, function (reason) { + _this._minimalDeferred.reject(reason); + _this._deferred.reject(reason); + }); + }; + return StreamParser; + }(); + exports.StreamParser = StreamParser; + /** + * A parser that parses an {@link libjass.ASS} object from a {@link libjass.parser.Stream} of an SRT script. + * + * @param {!libjass.parser.Stream} stream The {@link libjass.parser.Stream} to parse + * + * @constructor + * @memberOf libjass.parser + */ + var SrtStreamParser = function () { + function SrtStreamParser(stream) { + var _this = this; + this._stream = stream; + this._ass = new ass_1.ASS(); + this._deferred = new promise_1.DeferredPromise(); + this._shouldSwallowBom = true; + this._currentDialogueNumber = null; + this._currentDialogueStart = null; + this._currentDialogueEnd = null; + this._currentDialogueText = null; + this._stream.nextLine().then(function (line) { + return _this._onNextLine(line); + }, function (reason) { + _this._deferred.reject(reason); + }); + this._ass.properties.resolutionX = 1280; + this._ass.properties.resolutionY = 720; + this._ass.properties.wrappingStyle = 1; + this._ass.properties.scaleBorderAndShadow = true; + var newStyle = new style_1.Style(new map_1.Map([ [ "Name", "Default" ], [ "FontSize", "36" ] ])); + this._ass.styles.set(newStyle.name, newStyle); + } + Object.defineProperty(SrtStreamParser.prototype, "ass", { + /** + * @type {!Promise.} A promise that will be resolved when the entire stream has been parsed. + */ + get: function () { + return this._deferred.promise; + }, + enumerable: true, + configurable: true + }); + /** + * @param {string} line + * + * @private + */ + SrtStreamParser.prototype._onNextLine = function (line) { + var _this = this; + if (line === null) { + if (this._currentDialogueNumber !== null && this._currentDialogueStart !== null && this._currentDialogueEnd !== null && this._currentDialogueText !== null) { + this._ass.dialogues.push(new dialogue_1.Dialogue(new map_1.Map([ [ "Style", "Default" ], [ "Start", this._currentDialogueStart ], [ "End", this._currentDialogueEnd ], [ "Text", this._currentDialogueText ] ]), this._ass)); + } + this._deferred.resolve(this._ass); + return; + } + if (line[line.length - 1] === "\r") { + line = line.substr(0, line.length - 1); + } + if (line.charCodeAt(0) === 65279 && this._shouldSwallowBom) { + line = line.substr(1); + } + this._shouldSwallowBom = false; + if (line === "") { + if (this._currentDialogueNumber !== null && this._currentDialogueStart !== null && this._currentDialogueEnd !== null && this._currentDialogueText !== null) { + this._ass.dialogues.push(new dialogue_1.Dialogue(new map_1.Map([ [ "Style", "Default" ], [ "Start", this._currentDialogueStart ], [ "End", this._currentDialogueEnd ], [ "Text", this._currentDialogueText ] ]), this._ass)); + } + this._currentDialogueNumber = this._currentDialogueStart = this._currentDialogueEnd = this._currentDialogueText = null; + } else { + if (this._currentDialogueNumber === null) { + if (/^\d+$/.test(line)) { + this._currentDialogueNumber = line; + } + } else if (this._currentDialogueStart === null && this._currentDialogueEnd === null) { + var match = /^(\d\d:\d\d:\d\d,\d\d\d) --> (\d\d:\d\d:\d\d,\d\d\d)/.exec(line); + if (match !== null) { + this._currentDialogueStart = match[1].replace(",", "."); + this._currentDialogueEnd = match[2].replace(",", "."); + } + } else { + line = line.replace(//g, "{\\b1}").replace(/\{b\}/g, "{\\b1}").replace(/<\/b>/g, "{\\b0}").replace(/\{\/b\}/g, "{\\b0}").replace(//g, "{\\i1}").replace(/\{i\}/g, "{\\i1}").replace(/<\/i>/g, "{\\i0}").replace(/\{\/i\}/g, "{\\i0}").replace(//g, "{\\u1}").replace(/\{u\}/g, "{\\u1}").replace(/<\/u>/g, "{\\u0}").replace(/\{\/u\}/g, "{\\u0}").replace(//g, function (/* ujs:unreferenced */ substring, red, green, blue) { + return "{c&H" + blue + green + red + "&}"; + }).replace(/<\/font>/g, "{\\c}"); + if (this._currentDialogueText !== null) { + this._currentDialogueText += "\\N" + line; + } else { + this._currentDialogueText = line; + } + } + } + this._stream.nextLine().then(function (line) { + return _this._onNextLine(line); + }, function (reason) { + _this._deferred.reject(reason); + }); + }; + return SrtStreamParser; + }(); + exports.SrtStreamParser = SrtStreamParser; + /** + * Converts a uuencoded string to a base64 string. + * + * @param {string} str + * @return {string} + * + * @private + */ + function uuencodedToBase64(str) { + var result = ""; + for (var i = 0; i < str.length; i++) { + var charCode = str.charCodeAt(i) - 33; + if (charCode < 0 || charCode > 63) { + throw new Error("Out-of-range character code " + charCode + " at index " + i + " in string " + str); + } + if (charCode < 26) { + result += String.fromCharCode("A".charCodeAt(0) + charCode); + } else if (charCode < 52) { + result += String.fromCharCode("a".charCodeAt(0) + charCode - 26); + } else if (charCode < 62) { + result += String.fromCharCode("0".charCodeAt(0) + charCode - 52); + } else if (charCode === 62) { + result += "+"; + } else { + result += "/"; + } + } + return result; + } + }, /* 5 ./parser/streams */ function (exports, require) { + var promise_1 = require(32); + /** + * A {@link libjass.parser.Stream} that reads from a string in memory. + * + * @param {string} str The string + * + * @constructor + * @implements {libjass.parser.Stream} + * @memberOf libjass.parser + */ + var StringStream = function () { + function StringStream(str) { + this._str = str; + this._readTill = 0; + } + /** + * @return {!Promise.} A promise that will be resolved with the next line, or null if the string has been completely read. + */ + StringStream.prototype.nextLine = function () { + var result = null; + if (this._readTill < this._str.length) { + var nextNewLinePos = this._str.indexOf("\n", this._readTill); + if (nextNewLinePos !== -1) { + result = promise_1.Promise.resolve(this._str.substring(this._readTill, nextNewLinePos)); + this._readTill = nextNewLinePos + 1; + } else { + result = promise_1.Promise.resolve(this._str.substr(this._readTill)); + this._readTill = this._str.length; + } + } else { + result = promise_1.Promise.resolve(null); + } + return result; + }; + return StringStream; + }(); + exports.StringStream = StringStream; + /** + * A {@link libjass.parser.Stream} that reads from an XMLHttpRequest object. + * + * @param {!XMLHttpRequest} xhr The XMLHttpRequest object. Make sure to not call .open() on this object before passing it in here, + * since event handlers cannot be registered after open() has been called. + * + * @constructor + * @implements {libjass.parser.Stream} + * @memberOf libjass.parser + */ + var XhrStream = function () { + function XhrStream(xhr) { + var _this = this; + this._xhr = xhr; + this._readTill = 0; + this._pendingDeferred = null; + this._failedError = null; + xhr.addEventListener("progress", function () { + return _this._onXhrProgress(); + }, false); + xhr.addEventListener("load", function () { + return _this._onXhrLoad(); + }, false); + xhr.addEventListener("error", function (event) { + return _this._onXhrError(event); + }, false); + } + /** + * @return {!Promise.} A promise that will be resolved with the next line, or null if the stream is exhausted. + */ + XhrStream.prototype.nextLine = function () { + if (this._pendingDeferred !== null) { + throw new Error("XhrStream only supports one pending unfulfilled read at a time."); + } + var deferred = this._pendingDeferred = new promise_1.DeferredPromise(); + this._tryResolveNextLine(); + return deferred.promise; + }; + /** + * @private + */ + XhrStream.prototype._onXhrProgress = function () { + if (this._pendingDeferred === null) { + return; + } + if (this._xhr.readyState === XMLHttpRequest.DONE) { + /* Suppress resolving next line here. Let the "load" or "error" event handlers do it. + * + * This is required because a failed XHR fires the progress event with readyState === DONE before it fires the error event. + * This would confuse _tryResolveNextLine() into thinking the request succeeded with no data if it was called here. + */ + return; + } + this._tryResolveNextLine(); + }; + /** + * @private + */ + XhrStream.prototype._onXhrLoad = function () { + if (this._pendingDeferred === null) { + return; + } + this._tryResolveNextLine(); + }; + /** + * @param {!ErrorEvent} event + * + * @private + */ + XhrStream.prototype._onXhrError = function (event) { + this._failedError = event; + if (this._pendingDeferred === null) { + return; + } + this._tryResolveNextLine(); + }; + /** + * @private + */ + XhrStream.prototype._tryResolveNextLine = function () { + if (this._failedError !== null) { + this._pendingDeferred.reject(this._failedError); + return; + } + var response = this._xhr.responseText; + var nextNewLinePos = response.indexOf("\n", this._readTill); + if (nextNewLinePos !== -1) { + this._pendingDeferred.resolve(response.substring(this._readTill, nextNewLinePos)); + this._readTill = nextNewLinePos + 1; + this._pendingDeferred = null; + } else if (this._xhr.readyState === XMLHttpRequest.DONE) { + if (this._failedError !== null) { + this._pendingDeferred.reject(this._failedError); + } else if (this._readTill < response.length) { + this._pendingDeferred.resolve(response.substr(this._readTill)); + this._readTill = response.length; + } else { + this._pendingDeferred.resolve(null); + } + this._pendingDeferred = null; + } + }; + return XhrStream; + }(); + exports.XhrStream = XhrStream; + /** + * A {@link libjass.parser.Stream} that reads from a ReadableStream object. + * + * @param {!ReadableStream} stream + * @param {string} encoding + * + * @constructor + * @implements {libjass.parser.Stream} + * @memberOf libjass.parser + */ + var BrowserReadableStream = function () { + function BrowserReadableStream(stream, encoding) { + this._buffer = ""; + this._pendingDeferred = null; + this._reader = stream.getReader(); + this._decoder = new global.TextDecoder(encoding, { + ignoreBOM: true + }); + } + /** + * @return {!Promise.} A promise that will be resolved with the next line, or null if the stream is exhausted. + */ + BrowserReadableStream.prototype.nextLine = function () { + if (this._pendingDeferred !== null) { + throw new Error("BrowserReadableStream only supports one pending unfulfilled read at a time."); + } + var deferred = this._pendingDeferred = new promise_1.DeferredPromise(); + this._tryResolveNextLine(); + return deferred.promise; + }; + /** + * @private + */ + BrowserReadableStream.prototype._tryResolveNextLine = function () { + var _this = this; + var nextNewLinePos = this._buffer.indexOf("\n"); + if (nextNewLinePos !== -1) { + this._pendingDeferred.resolve(this._buffer.substr(0, nextNewLinePos)); + this._buffer = this._buffer.substr(nextNewLinePos + 1); + this._pendingDeferred = null; + } else { + this._reader.read().then(function (next) { + var value = next.value; + var done = next.done; + if (!done) { + _this._buffer += _this._decoder.decode(value, { + stream: true + }); + _this._tryResolveNextLine(); + } else { + // No more data. + if (_this._buffer.length === 0) { + _this._pendingDeferred.resolve(null); + } else { + _this._pendingDeferred.resolve(_this._buffer); + _this._buffer = ""; + } + _this._pendingDeferred = null; + } + }); + } + }; + return BrowserReadableStream; + }(); + exports.BrowserReadableStream = BrowserReadableStream; + }, /* 6 ./parser/ttf */ function (exports, require) { + var __decorate = require(34).__decorate; + var map_1 = require(30); + var set_1 = require(33); + var DataType; + (function (DataType) { + DataType[DataType["Char"] = 0] = "Char"; + DataType[DataType["Uint16"] = 1] = "Uint16"; + DataType[DataType["Uint32"] = 2] = "Uint32"; + })(DataType || (DataType = {})); + var fieldDecorators = new map_1.Map(); + var OffsetTable = function () { + function OffsetTable() {} + __decorate([ field(DataType.Uint16) ], OffsetTable.prototype, "majorVersion", void 0); + __decorate([ field(DataType.Uint16) ], OffsetTable.prototype, "minorVersion", void 0); + __decorate([ field(DataType.Uint16) ], OffsetTable.prototype, "numTables", void 0); + __decorate([ field(DataType.Uint16) ], OffsetTable.prototype, "searchRange", void 0); + __decorate([ field(DataType.Uint16) ], OffsetTable.prototype, "entrySelector", void 0); + __decorate([ field(DataType.Uint16) ], OffsetTable.prototype, "rangeShift", void 0); + OffsetTable = __decorate([ struct ], OffsetTable); + return OffsetTable; + }(); + var TableRecord = function () { + function TableRecord() {} + __decorate([ field(DataType.Char) ], TableRecord.prototype, "c1", void 0); + __decorate([ field(DataType.Char) ], TableRecord.prototype, "c2", void 0); + __decorate([ field(DataType.Char) ], TableRecord.prototype, "c3", void 0); + __decorate([ field(DataType.Char) ], TableRecord.prototype, "c4", void 0); + __decorate([ field(DataType.Uint32) ], TableRecord.prototype, "checksum", void 0); + __decorate([ field(DataType.Uint32) ], TableRecord.prototype, "offset", void 0); + __decorate([ field(DataType.Uint32) ], TableRecord.prototype, "length", void 0); + TableRecord = __decorate([ struct ], TableRecord); + return TableRecord; + }(); + var NameTableHeader = function () { + function NameTableHeader() {} + __decorate([ field(DataType.Uint16) ], NameTableHeader.prototype, "formatSelector", void 0); + __decorate([ field(DataType.Uint16) ], NameTableHeader.prototype, "count", void 0); + __decorate([ field(DataType.Uint16) ], NameTableHeader.prototype, "stringOffset", void 0); + NameTableHeader = __decorate([ struct ], NameTableHeader); + return NameTableHeader; + }(); + var NameRecord = function () { + function NameRecord() {} + __decorate([ field(DataType.Uint16) ], NameRecord.prototype, "platformId", void 0); + __decorate([ field(DataType.Uint16) ], NameRecord.prototype, "encodingId", void 0); + __decorate([ field(DataType.Uint16) ], NameRecord.prototype, "languageId", void 0); + __decorate([ field(DataType.Uint16) ], NameRecord.prototype, "nameId", void 0); + __decorate([ field(DataType.Uint16) ], NameRecord.prototype, "length", void 0); + __decorate([ field(DataType.Uint16) ], NameRecord.prototype, "offset", void 0); + NameRecord = __decorate([ struct ], NameRecord); + return NameRecord; + }(); + /** + * Gets all the font names from the given font attachment. + * + * @param {!libjass.Attachment} attachment + * @return {!libjass.Set.} + */ + function getTtfNames(attachment) { + var decoded = atob(attachment.contents); + var bytes = new Uint8Array(new ArrayBuffer(decoded.length)); + for (var i = 0; i < decoded.length; i++) { + bytes[i] = decoded.charCodeAt(i); + } + var reader = { + dataView: new DataView(bytes.buffer), + position: 0 + }; + var offsetTable = OffsetTable.read(reader); + var nameTableRecord = null; + for (var i = 0; i < offsetTable.numTables; i++) { + var tableRecord = TableRecord.read(reader); + if (tableRecord.c1 + tableRecord.c2 + tableRecord.c3 + tableRecord.c4 === "name") { + nameTableRecord = tableRecord; + break; + } + } + reader.position = nameTableRecord.offset; + var nameTableHeader = NameTableHeader.read(reader); + var result = new set_1.Set(); + for (var i = 0; i < nameTableHeader.count; i++) { + var nameRecord = NameRecord.read(reader); + switch (nameRecord.nameId) { + case 1: + case 4: + case 6: + var recordOffset = nameTableRecord.offset + nameTableHeader.stringOffset + nameRecord.offset; + var nameBytes = bytes.subarray(recordOffset, recordOffset + nameRecord.length); + switch (nameRecord.platformId) { + case 1: + { + var name_1 = ""; + for (var j = 0; j < nameBytes.length; j++) { + name_1 += String.fromCharCode(nameBytes[j]); + } + result.add(name_1); + } + break; + + case 3: + { + var name_2 = ""; + for (var j = 0; j < nameBytes.length; j += 2) { + name_2 += String.fromCharCode((nameBytes[j] << 8) + nameBytes[j + 1]); + } + result.add(name_2); + } + break; + } + break; + + default: + break; + } + } + return result; + } + exports.getTtfNames = getTtfNames; + /** + * @param {!function(new(): T)} clazz + * @return {!function(new(): T)} + * + * @template T + * @private + */ + function struct(clazz) { + var fields = clazz.__fields; + clazz.read = function (reader) { + var result = new clazz(); + for (var _i = 0; _i < fields.length; _i++) { + var field_1 = fields[_i]; + var value = void 0; + switch (field_1.type) { + case DataType.Char: + value = String.fromCharCode(reader.dataView.getInt8(reader.position)); + reader.position += 1; + break; + + case DataType.Uint16: + value = reader.dataView.getUint16(reader.position); + reader.position += 2; + break; + + case DataType.Uint32: + value = reader.dataView.getUint32(reader.position); + reader.position += 4; + break; + } + result[field_1.field] = value; + } + return result; + }; + return clazz; + } + /** + * @param {number} type + * @return {function(T, string)} + * + * @template T + * @private + */ + function field(type) { + var existingDecorator = fieldDecorators.get(type); + if (existingDecorator === undefined) { + existingDecorator = function (proto, field) { + var ctor = proto.constructor; + if (ctor.__fields === undefined) { + ctor.__fields = []; + } + ctor.__fields.push({ + type: type, + field: field + }); + }; + fieldDecorators.set(type, existingDecorator); + } + return existingDecorator; + } + }, /* 7 ./parts/drawing */ function (exports) { + /** + * An instruction to move to a particular position. + * + * @param {number} x + * @param {number} y + * + * @constructor + * @implements {libjass.parts.drawing.Instruction} + * @memberOf libjass.parts.drawing + */ + var MoveInstruction = function () { + function MoveInstruction(x, y) { + this._x = x; + this._y = y; + } + Object.defineProperty(MoveInstruction.prototype, "x", { + /** + * The X position of this move instruction. + * + * @type {number} + */ + get: function () { + return this._x; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MoveInstruction.prototype, "y", { + /** + * The Y position of this move instruction. + * + * @type {number} + */ + get: function () { + return this._y; + }, + enumerable: true, + configurable: true + }); + return MoveInstruction; + }(); + exports.MoveInstruction = MoveInstruction; + /** + * An instruction to draw a line to a particular position. + * + * @param {number} x + * @param {number} y + * + * @constructor + * @implements {libjass.parts.drawing.Instruction} + * @memberOf libjass.parts.drawing + */ + var LineInstruction = function () { + function LineInstruction(x, y) { + this._x = x; + this._y = y; + } + Object.defineProperty(LineInstruction.prototype, "x", { + /** + * The X position of this line instruction. + * + * @type {number} + */ + get: function () { + return this._x; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LineInstruction.prototype, "y", { + /** + * The Y position of this line instruction. + * + * @type {number} + */ + get: function () { + return this._y; + }, + enumerable: true, + configurable: true + }); + return LineInstruction; + }(); + exports.LineInstruction = LineInstruction; + /** + * An instruction to draw a cubic bezier curve to a particular position, with two given control points. + * + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * + * @constructor + * @implements {libjass.parts.drawing.Instruction} + * @memberOf libjass.parts.drawing + */ + var CubicBezierCurveInstruction = function () { + function CubicBezierCurveInstruction(x1, y1, x2, y2, x3, y3) { + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + this._x3 = x3; + this._y3 = y3; + } + Object.defineProperty(CubicBezierCurveInstruction.prototype, "x1", { + /** + * The X position of the first control point of this cubic bezier curve instruction. + * + * @type {number} + */ + get: function () { + return this._x1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CubicBezierCurveInstruction.prototype, "y1", { + /** + * The Y position of the first control point of this cubic bezier curve instruction. + * + * @type {number} + */ + get: function () { + return this._y1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CubicBezierCurveInstruction.prototype, "x2", { + /** + * The X position of the second control point of this cubic bezier curve instruction. + * + * @type {number} + */ + get: function () { + return this._x2; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CubicBezierCurveInstruction.prototype, "y2", { + /** + * The Y position of the second control point of this cubic bezier curve instruction. + * + * @type {number} + */ + get: function () { + return this._y2; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CubicBezierCurveInstruction.prototype, "x3", { + /** + * The ending X position of this cubic bezier curve instruction. + * + * @type {number} + */ + get: function () { + return this._x3; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CubicBezierCurveInstruction.prototype, "y3", { + /** + * The ending Y position of this cubic bezier curve instruction. + * + * @type {number} + */ + get: function () { + return this._y3; + }, + enumerable: true, + configurable: true + }); + return CubicBezierCurveInstruction; + }(); + exports.CubicBezierCurveInstruction = CubicBezierCurveInstruction; + }, /* 8 ./parts/index */ function (exports, require) { + var drawing = require(7); + exports.drawing = drawing; + /** + * Represents a CSS color with red, green, blue and alpha components. + * + * Instances of this class are immutable. + * + * @param {number} red + * @param {number} green + * @param {number} blue + * @param {number=1} alpha + * + * @constructor + * @memberOf libjass.parts + */ + var Color = function () { + function Color(red, green, blue, alpha) { + if (alpha === void 0) { + alpha = 1; + } + this._red = red; + this._green = green; + this._blue = blue; + this._alpha = alpha; + } + Object.defineProperty(Color.prototype, "red", { + /** + * The red component of this color as a number between 0 and 255. + * + * @type {number} + */ + get: function () { + return this._red; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Color.prototype, "green", { + /** + * The green component of this color as a number between 0 and 255. + * + * @type {number} + */ + get: function () { + return this._green; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Color.prototype, "blue", { + /** + * The blue component of this color as a number between 0 and 255. + * + * @type {number} + */ + get: function () { + return this._blue; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Color.prototype, "alpha", { + /** + * The alpha component of this color as a number between 0 and 1, where 0 means transparent and 1 means opaque. + * + * @type {number} + */ + get: function () { + return this._alpha; + }, + enumerable: true, + configurable: true + }); + /** + * @param {?number} value The new alpha. If null, the existing alpha is used. + * @return {!libjass.parts.Color} Returns a new Color instance with the same color but the provided alpha. + */ + Color.prototype.withAlpha = function (value) { + if (value !== null) { + return new Color(this._red, this._green, this._blue, value); + } + return this; + }; + /** + * @return {string} The CSS representation "rgba(...)" of this color. + */ + Color.prototype.toString = function () { + return "rgba(" + this._red + ", " + this._green + ", " + this._blue + ", " + this._alpha.toFixed(3) + ")"; + }; + /** + * Returns a new Color by interpolating the current color to the final color by the given progression. + * + * @param {!libjass.parts.Color} final + * @param {number} progression + * @return {!libjass.parts.Color} + */ + Color.prototype.interpolate = function (final, progression) { + return new Color(this._red + progression * (final.red - this._red), this._green + progression * (final.green - this._green), this._blue + progression * (final.blue - this._blue), this._alpha + progression * (final.alpha - this._alpha)); + }; + return Color; + }(); + exports.Color = Color; + /** + * A comment, i.e., any text enclosed in {} that is not understood as an ASS tag. + * + * @param {string} value The text of this comment + * + * @constructor + * @memberOf libjass.parts + */ + var Comment = function () { + function Comment(value) { + this._value = value; + } + Object.defineProperty(Comment.prototype, "value", { + /** + * The value of this comment. + * + * @type {string} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Comment; + }(); + exports.Comment = Comment; + /** + * A block of text, i.e., any text not enclosed in {}. Also includes \h. + * + * @param {string} value The content of this block of text + * + * @constructor + * @memberOf libjass.parts + */ + var Text = function () { + function Text(value) { + this._value = value; + } + Object.defineProperty(Text.prototype, "value", { + /** + * The value of this text part. + * + * @type {string} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + /** + * @return {string} + */ + Text.prototype.toString = function () { + return "Text { value: " + this._value.replace(/\u00A0/g, "\\h") + " }"; + }; + return Text; + }(); + exports.Text = Text; + /** + * A newline character \N. + * + * @constructor + * @memberOf libjass.parts + */ + var NewLine = function () { + function NewLine() {} + return NewLine; + }(); + exports.NewLine = NewLine; + /** + * An italic tag {\i} + * + * @param {?boolean} value {\i1} -> true, {\i0} -> false, {\i} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var Italic = function () { + function Italic(value) { + this._value = value; + } + Object.defineProperty(Italic.prototype, "value", { + /** + * The value of this italic tag. + * + * @type {?boolean} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Italic; + }(); + exports.Italic = Italic; + /** + * A bold tag {\b} + * + * @param {*} value {\b1} -> true, {\b0} -> false, {\b###} -> weight of the bold (number), {\b} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var Bold = function () { + function Bold(value) { + this._value = value; + } + Object.defineProperty(Bold.prototype, "value", { + /** + * The value of this bold tag. + * + * @type {?boolean|?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Bold; + }(); + exports.Bold = Bold; + /** + * An underline tag {\u} + * + * @param {?boolean} value {\u1} -> true, {\u0} -> false, {\u} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var Underline = function () { + function Underline(value) { + this._value = value; + } + Object.defineProperty(Underline.prototype, "value", { + /** + * The value of this underline tag. + * + * @type {?boolean} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Underline; + }(); + exports.Underline = Underline; + /** + * A strike-through tag {\s} + * + * @param {?boolean} value {\s1} -> true, {\s0} -> false, {\s} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var StrikeThrough = function () { + function StrikeThrough(value) { + this._value = value; + } + Object.defineProperty(StrikeThrough.prototype, "value", { + /** + * The value of this strike-through tag. + * + * @type {?boolean} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return StrikeThrough; + }(); + exports.StrikeThrough = StrikeThrough; + /** + * A border tag {\bord} + * + * @param {?number} value {\bord###} -> width (number), {\bord} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var Border = function () { + function Border(value) { + this._value = value; + } + Object.defineProperty(Border.prototype, "value", { + /** + * The value of this border tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Border; + }(); + exports.Border = Border; + /** + * A horizontal border tag {\xbord} + * + * @param {?number} value {\xbord###} -> width (number), {\xbord} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var BorderX = function () { + function BorderX(value) { + this._value = value; + } + Object.defineProperty(BorderX.prototype, "value", { + /** + * The value of this horizontal border tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return BorderX; + }(); + exports.BorderX = BorderX; + /** + * A vertical border tag {\ybord} + * + * @param {?number} value {\ybord###} -> height (number), {\ybord} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var BorderY = function () { + function BorderY(value) { + this._value = value; + } + Object.defineProperty(BorderY.prototype, "value", { + /** + * The value of this vertical border tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return BorderY; + }(); + exports.BorderY = BorderY; + /** + * A shadow tag {\shad} + * + * @param {?number} value {\shad###} -> depth (number), {\shad} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var Shadow = function () { + function Shadow(value) { + this._value = value; + } + Object.defineProperty(Shadow.prototype, "value", { + /** + * The value of this shadow tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Shadow; + }(); + exports.Shadow = Shadow; + /** + * A horizontal shadow tag {\xshad} + * + * @param {?number} value {\xshad###} -> depth (number), {\xshad} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var ShadowX = function () { + function ShadowX(value) { + this._value = value; + } + Object.defineProperty(ShadowX.prototype, "value", { + /** + * The value of this horizontal shadow tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return ShadowX; + }(); + exports.ShadowX = ShadowX; + /** + * A vertical shadow tag {\yshad} + * + * @param {?number} value {\yshad###} -> depth (number), {\yshad} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var ShadowY = function () { + function ShadowY(value) { + this._value = value; + } + Object.defineProperty(ShadowY.prototype, "value", { + /** + * The value of this vertical shadow tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return ShadowY; + }(); + exports.ShadowY = ShadowY; + /** + * A blur tag {\be} + * + * @param {?number} value {\be###} -> strength (number), {\be} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var Blur = function () { + function Blur(value) { + this._value = value; + } + Object.defineProperty(Blur.prototype, "value", { + /** + * The value of this blur tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Blur; + }(); + exports.Blur = Blur; + /** + * A Gaussian blur tag {\blur} + * + * @param {?number} value {\blur###} -> strength (number), {\blur} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var GaussianBlur = function () { + function GaussianBlur(value) { + this._value = value; + } + Object.defineProperty(GaussianBlur.prototype, "value", { + /** + * The value of this Gaussian blur tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return GaussianBlur; + }(); + exports.GaussianBlur = GaussianBlur; + /** + * A font name tag {\fn} + * + * @param {?string} value {\fn###} -> name (string), {\fn} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var FontName = function () { + function FontName(value) { + this._value = value; + } + Object.defineProperty(FontName.prototype, "value", { + /** + * The value of this font name tag. + * + * @type {?string} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return FontName; + }(); + exports.FontName = FontName; + /** + * A font size tag {\fs} + * + * @param {?number} value {\fs###} -> size (number), {\fs} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var FontSize = function () { + function FontSize(value) { + this._value = value; + } + Object.defineProperty(FontSize.prototype, "value", { + /** + * The value of this font size tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return FontSize; + }(); + exports.FontSize = FontSize; + /** + * A font size increase tag {\fs+} + * + * @param {number} value {\fs+###} -> difference (number) + * + * @constructor + * @memberOf libjass.parts + */ + var FontSizePlus = function () { + function FontSizePlus(value) { + this._value = value; + } + Object.defineProperty(FontSizePlus.prototype, "value", { + /** + * The value of this font size increase tag. + * + * @type {number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return FontSizePlus; + }(); + exports.FontSizePlus = FontSizePlus; + /** + * A font size decrease tag {\fs-} + * + * @param {number} value {\fs-###} -> difference (number) + * + * @constructor + * @memberOf libjass.parts + */ + var FontSizeMinus = function () { + function FontSizeMinus(value) { + this._value = value; + } + Object.defineProperty(FontSizeMinus.prototype, "value", { + /** + * The value of this font size decrease tag. + * + * @type {number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return FontSizeMinus; + }(); + exports.FontSizeMinus = FontSizeMinus; + /** + * A horizontal font scaling tag {\fscx} + * + * @param {?number} value {\fscx###} -> scale (number), {\fscx} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var FontScaleX = function () { + function FontScaleX(value) { + this._value = value; + } + Object.defineProperty(FontScaleX.prototype, "value", { + /** + * The value of this horizontal font scaling tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return FontScaleX; + }(); + exports.FontScaleX = FontScaleX; + /** + * A vertical font scaling tag {\fscy} + * + * @param {?number} value {\fscy###} -> scale (number), {\fscy} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var FontScaleY = function () { + function FontScaleY(value) { + this._value = value; + } + Object.defineProperty(FontScaleY.prototype, "value", { + /** + * The value of this vertical font scaling tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return FontScaleY; + }(); + exports.FontScaleY = FontScaleY; + /** + * A letter-spacing tag {\fsp} + * + * @param {?number} value {\fsp###} -> spacing (number), {\fsp} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var LetterSpacing = function () { + function LetterSpacing(value) { + this._value = value; + } + Object.defineProperty(LetterSpacing.prototype, "value", { + /** + * The value of this letter-spacing tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return LetterSpacing; + }(); + exports.LetterSpacing = LetterSpacing; + /** + * An X-axis rotation tag {\frx} + * + * @param {?number} value {\frx###} -> angle (number), {\frx} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var RotateX = function () { + function RotateX(value) { + this._value = value; + } + Object.defineProperty(RotateX.prototype, "value", { + /** + * The value of this X-axis rotation tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return RotateX; + }(); + exports.RotateX = RotateX; + /** + * A Y-axis rotation tag {\fry} + * + * @param {?number} value {\fry###} -> angle (number), {\fry} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var RotateY = function () { + function RotateY(value) { + this._value = value; + } + Object.defineProperty(RotateY.prototype, "value", { + /** + * The value of this Y-axis rotation tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return RotateY; + }(); + exports.RotateY = RotateY; + /** + * A Z-axis rotation tag {\fr} or {\frz} + * + * @param {?number} value {\frz###} -> angle (number), {\frz} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var RotateZ = function () { + function RotateZ(value) { + this._value = value; + } + Object.defineProperty(RotateZ.prototype, "value", { + /** + * The value of this Z-axis rotation tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return RotateZ; + }(); + exports.RotateZ = RotateZ; + /** + * An X-axis shearing tag {\fax} + * + * @param {?number} value {\fax###} -> angle (number), {\fax} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var SkewX = function () { + function SkewX(value) { + this._value = value; + } + Object.defineProperty(SkewX.prototype, "value", { + /** + * The value of this X-axis shearing tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return SkewX; + }(); + exports.SkewX = SkewX; + /** + * A Y-axis shearing tag {\fay} + * + * @param {?number} value {\fay###} -> angle (number), {\fay} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var SkewY = function () { + function SkewY(value) { + this._value = value; + } + Object.defineProperty(SkewY.prototype, "value", { + /** + * The value of this Y-axis shearing tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return SkewY; + }(); + exports.SkewY = SkewY; + /** + * A primary color tag {\c} or {\1c} + * + * @param {libjass.parts.Color} value {\1c###} -> color (Color), {\1c} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var PrimaryColor = function () { + function PrimaryColor(value) { + this._value = value; + } + Object.defineProperty(PrimaryColor.prototype, "value", { + /** + * The value of this primary color tag. + * + * @type {libjass.parts.Color} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return PrimaryColor; + }(); + exports.PrimaryColor = PrimaryColor; + /** + * A secondary color tag {\2c} + * + * @param {libjass.parts.Color} value {\2c###} -> color (Color), {\2c} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var SecondaryColor = function () { + function SecondaryColor(value) { + this._value = value; + } + Object.defineProperty(SecondaryColor.prototype, "value", { + /** + * The value of this secondary color tag. + * + * @type {libjass.parts.Color} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return SecondaryColor; + }(); + exports.SecondaryColor = SecondaryColor; + /** + * An outline color tag {\3c} + * + * @param {libjass.parts.Color} value {\3c###} -> color (Color), {\3c} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var OutlineColor = function () { + function OutlineColor(value) { + this._value = value; + } + Object.defineProperty(OutlineColor.prototype, "value", { + /** + * The value of this outline color tag. + * + * @type {libjass.parts.Color} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return OutlineColor; + }(); + exports.OutlineColor = OutlineColor; + /** + * A shadow color tag {\4c} + * + * @param {libjass.parts.Color} value {\4c###} -> color (Color), {\4c} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var ShadowColor = function () { + function ShadowColor(value) { + this._value = value; + } + Object.defineProperty(ShadowColor.prototype, "value", { + /** + * The value of this shadow color tag. + * + * @type {libjass.parts.Color} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return ShadowColor; + }(); + exports.ShadowColor = ShadowColor; + /** + * An alpha tag {\alpha} + * + * @param {?number} value {\alpha###} -> alpha (number), {\alpha} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var Alpha = function () { + function Alpha(value) { + this._value = value; + } + Object.defineProperty(Alpha.prototype, "value", { + /** + * The value of this alpha tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Alpha; + }(); + exports.Alpha = Alpha; + /** + * A primary alpha tag {\1a} + * + * @param {?number} value {\1a###} -> alpha (number), {\1a} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var PrimaryAlpha = function () { + function PrimaryAlpha(value) { + this._value = value; + } + Object.defineProperty(PrimaryAlpha.prototype, "value", { + /** + * The value of this primary alpha tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return PrimaryAlpha; + }(); + exports.PrimaryAlpha = PrimaryAlpha; + /** + * A secondary alpha tag {\2a} + * + * @param {?number} value {\2a###} -> alpha (number), {\2a} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var SecondaryAlpha = function () { + function SecondaryAlpha(value) { + this._value = value; + } + Object.defineProperty(SecondaryAlpha.prototype, "value", { + /** + * The value of this secondary alpha tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return SecondaryAlpha; + }(); + exports.SecondaryAlpha = SecondaryAlpha; + /** + * An outline alpha tag {\3a} + * + * @param {?number} value {\3a###} -> alpha (number), {\3a} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var OutlineAlpha = function () { + function OutlineAlpha(value) { + this._value = value; + } + Object.defineProperty(OutlineAlpha.prototype, "value", { + /** + * The value of this outline alpha tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return OutlineAlpha; + }(); + exports.OutlineAlpha = OutlineAlpha; + /** + * A shadow alpha tag {\4a} + * + * @param {?number} value {\4a###} -> alpha (number), {\4a} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var ShadowAlpha = function () { + function ShadowAlpha(value) { + this._value = value; + } + Object.defineProperty(ShadowAlpha.prototype, "value", { + /** + * The value of this shadow alpha tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return ShadowAlpha; + }(); + exports.ShadowAlpha = ShadowAlpha; + /** + * An alignment tag {\an} or {\a} + * + * @param {number} value {\an###} -> alignment (number) + * + * @constructor + * @memberOf libjass.parts + */ + var Alignment = function () { + function Alignment(value) { + this._value = value; + } + Object.defineProperty(Alignment.prototype, "value", { + /** + * The value of this alignment tag. + * + * @type {?number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Alignment; + }(); + exports.Alignment = Alignment; + /** + * A color karaoke tag {\k} + * + * @param {number} duration {\k###} -> duration (number) + * + * @constructor + * @memberOf libjass.parts + */ + var ColorKaraoke = function () { + function ColorKaraoke(duration) { + this._duration = duration; + } + Object.defineProperty(ColorKaraoke.prototype, "duration", { + /** + * The duration of this color karaoke tag. + * + * @type {number} + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + return ColorKaraoke; + }(); + exports.ColorKaraoke = ColorKaraoke; + /** + * A sweeping color karaoke tag {\K} or {\kf} + * + * @param {number} duration {\kf###} -> duration (number) + * + * @constructor + * @memberOf libjass.parts + */ + var SweepingColorKaraoke = function () { + function SweepingColorKaraoke(duration) { + this._duration = duration; + } + Object.defineProperty(SweepingColorKaraoke.prototype, "duration", { + /** + * The duration of this sweeping color karaoke tag. + * + * @type {number} + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + return SweepingColorKaraoke; + }(); + exports.SweepingColorKaraoke = SweepingColorKaraoke; + /** + * An outline karaoke tag {\ko} + * + * @param {number} duration {\ko###} -> duration (number) + * + * @constructor + * @memberOf libjass.parts + */ + var OutlineKaraoke = function () { + function OutlineKaraoke(duration) { + this._duration = duration; + } + Object.defineProperty(OutlineKaraoke.prototype, "duration", { + /** + * The duration of this outline karaoke tag. + * + * @type {number} + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + return OutlineKaraoke; + }(); + exports.OutlineKaraoke = OutlineKaraoke; + /** + * A wrapping style tag {\q} + * + * @param {number} value {\q###} -> style (number) + * + * @constructor + * @memberOf libjass.parts + */ + var WrappingStyle = function () { + function WrappingStyle(value) { + this._value = value; + } + Object.defineProperty(WrappingStyle.prototype, "value", { + /** + * The value of this wrapping style tag. + * + * @type {number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return WrappingStyle; + }(); + exports.WrappingStyle = WrappingStyle; + /** + * A style reset tag {\r} + * + * @param {?string} value {\r###} -> style name (string), {\r} -> null + * + * @constructor + * @memberOf libjass.parts + */ + var Reset = function () { + function Reset(value) { + this._value = value; + } + Object.defineProperty(Reset.prototype, "value", { + /** + * The value of this style reset tag. + * + * @type {?string} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return Reset; + }(); + exports.Reset = Reset; + /** + * A position tag {\pos} + * + * @param {number} x + * @param {number} y + * + * @constructor + * @memberOf libjass.parts + */ + var Position = function () { + function Position(x, y) { + this._x = x; + this._y = y; + } + Object.defineProperty(Position.prototype, "x", { + /** + * The x value of this position tag. + * + * @type {number} + */ + get: function () { + return this._x; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Position.prototype, "y", { + /** + * The y value of this position tag. + * + * @type {number} + */ + get: function () { + return this._y; + }, + enumerable: true, + configurable: true + }); + return Position; + }(); + exports.Position = Position; + /** + * A movement tag {\move} + * + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} t1 + * @param {number} t2 + * + * @constructor + * @memberOf libjass.parts + */ + var Move = function () { + function Move(x1, y1, x2, y2, t1, t2) { + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + this._t1 = t1; + this._t2 = t2; + } + Object.defineProperty(Move.prototype, "x1", { + /** + * The starting x value of this move tag. + * + * @type {number} + */ + get: function () { + return this._x1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Move.prototype, "y1", { + /** + * The starting y value of this move tag. + * + * @type {number} + */ + get: function () { + return this._y1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Move.prototype, "x2", { + /** + * The ending x value of this move tag. + * + * @type {number} + */ + get: function () { + return this._x2; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Move.prototype, "y2", { + /** + * The ending y value of this move tag. + * + * @type {number} + */ + get: function () { + return this._y2; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Move.prototype, "t1", { + /** + * The start time of this move tag. + * + * @type {number} + */ + get: function () { + return this._t1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Move.prototype, "t2", { + /** + * The end time value of this move tag. + * + * @type {number} + */ + get: function () { + return this._t2; + }, + enumerable: true, + configurable: true + }); + return Move; + }(); + exports.Move = Move; + /** + * A rotation origin tag {\org} + * + * @param {number} x + * @param {number} y + * + * @constructor + * @memberOf libjass.parts + */ + var RotationOrigin = function () { + function RotationOrigin(x, y) { + this._x = x; + this._y = y; + } + Object.defineProperty(RotationOrigin.prototype, "x", { + /** + * The x value of this rotation origin tag. + * + * @type {number} + */ + get: function () { + return this._x; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RotationOrigin.prototype, "y", { + /** + * The y value of this rotation origin tag. + * + * @type {number} + */ + get: function () { + return this._y; + }, + enumerable: true, + configurable: true + }); + return RotationOrigin; + }(); + exports.RotationOrigin = RotationOrigin; + /** + * A simple fade tag {\fad} + * + * @param {number} start + * @param {number} end + * + * @constructor + * @memberOf libjass.parts + */ + var Fade = function () { + function Fade(start, end) { + this._start = start; + this._end = end; + } + Object.defineProperty(Fade.prototype, "start", { + /** + * The start time of this fade tag. + * + * @type {number} + */ + get: function () { + return this._start; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Fade.prototype, "end", { + /** + * The end time of this fade tag. + * + * @type {number} + */ + get: function () { + return this._end; + }, + enumerable: true, + configurable: true + }); + return Fade; + }(); + exports.Fade = Fade; + /** + * A complex fade tag {\fade} + * + * @param {number} a1 + * @param {number} a2 + * @param {number} a3 + * @param {number} t1 + * @param {number} t2 + * @param {number} t3 + * @param {number} t4 + * + * @constructor + * @memberOf libjass.parts + */ + var ComplexFade = function () { + function ComplexFade(a1, a2, a3, t1, t2, t3, t4) { + this._a1 = a1; + this._a2 = a2; + this._a3 = a3; + this._t1 = t1; + this._t2 = t2; + this._t3 = t3; + this._t4 = t4; + } + Object.defineProperty(ComplexFade.prototype, "a1", { + /** + * The alpha value of this complex fade tag at time t2. + * + * @type {number} + */ + get: function () { + return this._a1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ComplexFade.prototype, "a2", { + /** + * The alpha value of this complex fade tag at time t3. + * + * @type {number} + */ + get: function () { + return this._a2; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ComplexFade.prototype, "a3", { + /** + * The alpha value of this complex fade tag at time t4. + * + * @type {number} + */ + get: function () { + return this._a3; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ComplexFade.prototype, "t1", { + /** + * The starting time of this complex fade tag. + * + * @type {number} + */ + get: function () { + return this._t1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ComplexFade.prototype, "t2", { + /** + * The first intermediate time of this complex fade tag. + * + * @type {number} + */ + get: function () { + return this._t2; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ComplexFade.prototype, "t3", { + /** + * The second intermediate time of this complex fade tag. + * + * @type {number} + */ + get: function () { + return this._t3; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ComplexFade.prototype, "t4", { + /** + * The ending time of this complex fade tag. + * + * @type {number} + */ + get: function () { + return this._t4; + }, + enumerable: true, + configurable: true + }); + return ComplexFade; + }(); + exports.ComplexFade = ComplexFade; + /** + * A transform tag {\t} + * + * @param {number} start + * @param {number} end + * @param {number} accel + * @param {!Array.} tags + * + * @constructor + * @memberOf libjass.parts + */ + var Transform = function () { + function Transform(start, end, accel, tags) { + this._start = start; + this._end = end; + this._accel = accel; + this._tags = tags; + } + Object.defineProperty(Transform.prototype, "start", { + /** + * The starting time of this transform tag. + * + * @type {?number} + */ + get: function () { + return this._start; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Transform.prototype, "end", { + /** + * The ending time of this transform tag. + * + * @type {?number} + */ + get: function () { + return this._end; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Transform.prototype, "accel", { + /** + * The acceleration of this transform tag. + * + * @type {?number} + */ + get: function () { + return this._accel; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Transform.prototype, "tags", { + /** + * The tags animated by this transform tag. + * + * @type {!Array.} + */ + get: function () { + return this._tags; + }, + enumerable: true, + configurable: true + }); + return Transform; + }(); + exports.Transform = Transform; + /** + * A rectangular clip tag {\clip} or {\iclip} + * + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {boolean} inside + * + * @constructor + * @memberOf libjass.parts + */ + var RectangularClip = function () { + function RectangularClip(x1, y1, x2, y2, inside) { + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + this._inside = inside; + } + Object.defineProperty(RectangularClip.prototype, "x1", { + /** + * The X coordinate of the starting position of this rectangular clip tag. + * + * @type {number} + */ + get: function () { + return this._x1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RectangularClip.prototype, "y1", { + /** + * The Y coordinate of the starting position of this rectangular clip tag. + * + * @type {number} + */ + get: function () { + return this._y1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RectangularClip.prototype, "x2", { + /** + * The X coordinate of the ending position of this rectangular clip tag. + * + * @type {number} + */ + get: function () { + return this._x2; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RectangularClip.prototype, "y2", { + /** + * The Y coordinate of the ending position of this rectangular clip tag. + * + * @type {number} + */ + get: function () { + return this._y2; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RectangularClip.prototype, "inside", { + /** + * Whether this rectangular clip tag clips the region it encloses or the region it excludes. + * + * @type {boolean} + */ + get: function () { + return this._inside; + }, + enumerable: true, + configurable: true + }); + return RectangularClip; + }(); + exports.RectangularClip = RectangularClip; + /** + * A vector clip tag {\clip} or {\iclip} + * + * @param {number} scale + * @param {!Array.} instructions + * @param {boolean} inside + * + * @constructor + * @memberOf libjass.parts + */ + var VectorClip = function () { + function VectorClip(scale, instructions, inside) { + this._scale = scale; + this._instructions = instructions; + this._inside = inside; + } + Object.defineProperty(VectorClip.prototype, "scale", { + /** + * The scale of this vector clip tag. + * + * @type {number} + */ + get: function () { + return this._scale; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VectorClip.prototype, "instructions", { + /** + * The clip commands of this vector clip tag. + * + * @type {string} + */ + get: function () { + return this._instructions; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VectorClip.prototype, "inside", { + /** + * Whether this vector clip tag clips the region it encloses or the region it excludes. + * + * @type {boolean} + */ + get: function () { + return this._inside; + }, + enumerable: true, + configurable: true + }); + return VectorClip; + }(); + exports.VectorClip = VectorClip; + /** + * A drawing mode tag {\p} + * + * @param {number} scale + * + * @constructor + * @memberOf libjass.parts + */ + var DrawingMode = function () { + function DrawingMode(scale) { + this._scale = scale; + } + Object.defineProperty(DrawingMode.prototype, "scale", { + /** + * The scale of this drawing mode tag. + * + * @type {number} + */ + get: function () { + return this._scale; + }, + enumerable: true, + configurable: true + }); + return DrawingMode; + }(); + exports.DrawingMode = DrawingMode; + /** + * A drawing mode baseline offset tag {\pbo} + * + * @param {number} value + * + * @constructor + * @memberOf libjass.parts + */ + var DrawingBaselineOffset = function () { + function DrawingBaselineOffset(value) { + this._value = value; + } + Object.defineProperty(DrawingBaselineOffset.prototype, "value", { + /** + * The value of this drawing mode baseline offset tag. + * + * @type {number} + */ + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return DrawingBaselineOffset; + }(); + exports.DrawingBaselineOffset = DrawingBaselineOffset; + /** + * A pseudo-part representing text interpreted as drawing instructions + * + * @param {!Array.} instructions + * + * @constructor + * @memberOf libjass.parts + */ + var DrawingInstructions = function () { + function DrawingInstructions(instructions) { + this._instructions = instructions; + } + Object.defineProperty(DrawingInstructions.prototype, "instructions", { + /** + * The instructions contained in this drawing instructions part. + * + * @type {!Array.} + */ + get: function () { + return this._instructions; + }, + enumerable: true, + configurable: true + }); + return DrawingInstructions; + }(); + exports.DrawingInstructions = DrawingInstructions; + var addToString = function (ctor, ctorName) { + if (!ctor.prototype.hasOwnProperty("toString")) { + var propertyNames = Object.getOwnPropertyNames(ctor.prototype).filter(function (property) { + return property !== "constructor"; + }); + ctor.prototype.toString = function () { + var _this = this; + return ctorName + " { " + propertyNames.map(function (name) { + return name + ": " + _this[name]; + }).join(", ") + (propertyNames.length > 0 ? " " : "") + "}"; + }; + } + }; + var misc_1 = require(38); + for (var _i = 0, _a = Object.keys(exports); _i < _a.length; _i++) { + var key = _a[_i]; + var value = exports[key]; + if (value instanceof Function) { + addToString(value, key); + misc_1.registerClassPrototype(value.prototype); + } + } + for (var _b = 0, _c = Object.keys(drawing); _b < _c.length; _b++) { + var key = _c[_b]; + var value = drawing[key]; + if (value instanceof Function) { + addToString(value, "Drawing" + key); + misc_1.registerClassPrototype(value.prototype); + } + } + }, /* 9 ./renderers/clocks/auto */ function (exports, require) { + var settings_1 = require(23); + var manual_1 = require(11); + /** + * An implementation of {@link libjass.renderers.Clock} that automatically ticks and generates {@link libjass.renderers.ClockEvent}s according to the state of an external driver. + * + * For example, if you're using libjass to render subtitles on a canvas with your own video controls, these video controls will function as the driver to this AutoClock. + * It would call {@link libjass.renderers.AutoClock.play}, {@link libjass.renderers.AutoClock.pause}, etc. when the user pressed the corresponding video controls. + * + * The difference from ManualClock is that AutoClock does not require the driver to call something like {@link libjass.renderers.ManualClock.tick}. Instead it keeps its + * own time with a high-resolution requestAnimationFrame-based timer. + * + * If using libjass with a