UNPKG

11.5 kBSource Map (JSON)View Raw
1{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./packages/util/timecode-converter/src/secondsToTimecode.js","webpack:///./packages/util/timecode-converter/src/timecodeToSeconds.js","webpack:///./packages/util/timecode-converter/src/padTimeToTimecode.js","webpack:///./packages/util/timecode-converter/index.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","secondsToTimecode","seconds","framePerSeconds","_padZero","parseInt","fps","normalisedSeconds","Math","floor","toPrecision","toFixed","normalisePlayerTime","wholeSeconds","frames","timecodeToSecondsHelper","tc","split","timecodeToFrames","isOneDigit","str","length","padTimeToTimecode","time","timecode","includes","includesFullStop","replace","timecodeToSeconds","resultPadded","parseFloat","shortTimecode","slice"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EA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1B,YAMET,EAASU,KCjBEC,EAViB,SAAUC,EAAIb,GAC5C,IAAIG,EAAM,GAMV,YALmB,IAAfH,IACFG,EAAMH,MApBe,SAAUa,EAAIV,GAAK,IAGpCN,EAAIgB,EAAGC,MAAM,KACfH,EAAST,SAASL,EAAE,IAKxB,OAJAc,GAAUT,SAASL,EAAE,IAAMM,EAC3BQ,GAAUT,SAASL,EAAE,KAAa,GAANM,GAC5BQ,GAAUT,SAASL,EAAE,KAAa,GAANM,EAAW,IAexBY,CAAiBF,EAAIV,GAENA,GAAKK,QAAQ,ICzBvCQ,EAAa,SAAAC,GAAG,OAAmB,IAAfA,EAAIC,QA6CfC,EA3CW,SAACC,GACzB,GAAoB,iBAATA,EAsCT,OAAOA,EArCP,OAAmBA,EARiBN,MAAM,KAAKI,QAS/C,KAAK,EAGH,OAAOE,EACT,KAAK,EAAL,OAEMJ,EAAWI,EAAKN,MAAM,KAAK,IAFjC,cAGmBM,EAHnB,oBAMgBA,EANhB,OAOA,KAAK,EAEH,MAAM,GAAN,OAAWA,EAAX,OACF,eArBqB,SAAAC,GAAQ,OAAIA,EAASC,SAAS,KAuB7CC,CAAiBH,GAEfJ,EAAWI,EAAKN,MAAM,KAAK,IAJnC,cAKqBM,EAAKN,MAAM,KAAK,GALrC,YAK6CM,EAAKN,MAAM,KAAK,GAL7D,oBAQkBM,EAAKI,QAAQ,IAAK,KARpC,OAaMR,EAAWI,GAbjB,iBAcsBA,EAdtB,uBAiBmBA,EAjBnB,SCLEK,EAAoB,SAACL,GACzB,GAAoB,iBAATA,EAAmB,CAAC,IACvBM,EAAeP,EAAkBC,GAGvC,OAFwBR,EAAwBc,GAMlD,OAAOC,WAAWP,IAGdQ,EAAgB,SAACR,GAGrB,OAFiBtB,EAAkBsB,GAEnBS,MAAM,GAAI","file":"timecodeConverter.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 8);\n","/**\n* Raised in this comment https://github.com/bbc/react-transcript-editor/pull/9\n* abstracted from https://github.com/bbc/newslabs-cdn/blob/master/js/20-bbcnpf.utils.js\n* In broadcast VIDEO, timecode is NOT hh:mm:ss:ms, it's hh:mm:ss:ff where ff is frames,\n* dependent on the framerate of the media concerned.\n* `hh:mm:ss:ff`\n*/\n\n/**\n * Helper function\n * Rounds to the 14milliseconds boundaries\n * Time in video can only \"exist in\" 14milliseconds boundaries.\n * This makes it possible for the HTML5 player to be frame accurate.\n * @param {*} seconds\n * @param {*} fps\n */\nconst normalisePlayerTime = function (seconds, fps) {\n return Number((1.0 / fps * Math.floor(Number((fps * seconds).toPrecision(12)))).toFixed(2));\n};\n\n/*\n* @param {*} seconds\n* @param {*} fps\n*/\nconst secondsToTimecode = function (seconds, framePerSeconds) {\n // written for PAL non-drop timecode\n let fps = 25;\n if (framePerSeconds !== undefined) {\n fps = framePerSeconds;\n }\n\n const normalisedSeconds = normalisePlayerTime(seconds, fps);\n\n const wholeSeconds = Math.floor(normalisedSeconds);\n const frames = ((normalisedSeconds - wholeSeconds) * fps).toFixed(2);\n\n // prepends zero - example pads 3 to 03\n function _padZero(n) {\n if (n < 10) return `0${ parseInt(n) }`;\n\n return parseInt(n);\n }\n\n return `${ _padZero((wholeSeconds / 60 / 60) % 60)\n }:${\n _padZero((wholeSeconds / 60) % 60)\n }:${\n _padZero(wholeSeconds % 60)\n }:${\n _padZero(frames) }`;\n};\n\nexport default secondsToTimecode;\n","/**\n * Helperf unction\n * @param {*} tc\n * @param {*} fps\n */\nconst timecodeToFrames = function (tc, fps) {\n // TODO make 29.97 fps drop-frame aware - works for 25 only.\n\n const s = tc.split(':');\n let frames = parseInt(s[3]);\n frames += parseInt(s[2]) * fps;\n frames += parseInt(s[1]) * (fps * 60);\n frames += parseInt(s[0]) * (fps * 60 * 60);\n\n return frames;\n};\n\n/**\n * Convert broadcast timecodes to seconds\n * @param {*} tc - `hh:mm:ss:ff`\n * @param {*} framePerSeconds - defaults to 25 if not provided\n */\nconst timecodeToSecondsHelper = function (tc, framePerSeconds) {\n let fps = 25;\n if (framePerSeconds !== undefined) {\n fps = framePerSeconds;\n }\n const frames = timecodeToFrames(tc, fps);\n\n return Number(Number(frames / fps).toFixed(2));\n};\n\nexport default timecodeToSecondsHelper;\n","const countColon = timecode => timecode.split(':').length;\n\nconst includesFullStop = timecode => timecode.includes('.');\n\nconst isOneDigit = str => str.length === 1;\n\nconst padTimeToTimecode = (time) => {\n if (typeof time === 'string') {\n switch (countColon(time)) {\n case 4:\n // is already in timecode format\n // hh:mm:ss:ff\n return time;\n case 2:\n // m:ss\n if (isOneDigit(time.split(':')[0])) {\n return `00:0${ time }:00`;\n }\n\n return `00:${ time }:00`;\n case 3:\n // hh:mm:ss\n return `${ time }:00`;\n default:\n // mm.ss\n if (includesFullStop(time)) {\n // m.ss\n if (isOneDigit(time.split('.')[0])) {\n return `00:0${ time.split('.')[0] }:${ time.split('.')[1] }:00`;\n }\n\n return `00:${ time.replace('.', ':') }:00`;\n }\n\n // if just int, then it's seconds\n // s\n if (isOneDigit(time)) {\n return `00:00:0${ time }:00`;\n }\n\n return `00:00:${ time }:00`;\n }\n // edge case if it's number return a number coz cannot refactor\n // TODO: might need to refactor and move this elsewhere\n } else {\n return time;\n }\n};\n\nexport default padTimeToTimecode;\n","/**\n * Wrapping around \"time stamps\" and timecode conversion modules\n * To provide more support for variety of formats.\n */\nimport secondsToTimecode from './src/secondsToTimecode';\nimport timecodeToSecondsHelper from './src/timecodeToSeconds';\nimport padTimeToTimecode from './src/padTimeToTimecode';\n\n/**\n * @param {*} time\n * Can take as input timecodes in the following formats\n * - hh:mm:ss:ff\n * - mm:ss\n * - m:ss\n * - ss - seconds --> if it's already in seconds then it just returns seconds\n * - hh:mm:ff\n * @todo could be refactored with some helper functions for clarity\n */\nconst timecodeToSeconds = (time) => {\n if (typeof time === 'string') {\n const resultPadded = padTimeToTimecode(time);\n const resultConverted = timecodeToSecondsHelper(resultPadded);\n\n return resultConverted;\n }\n\n // assuming it receive timecode as seconds as string '600'\n return parseFloat(time);\n};\n\nconst shortTimecode = (time) => {\n const timecode = secondsToTimecode(time);\n\n return timecode.slice(0, -3);\n};\n\nexport { secondsToTimecode, timecodeToSeconds, shortTimecode };\n"],"sourceRoot":""}
\No newline at end of file