UNPKG

11.6 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","concat","parseInt","fps","normalisedSeconds","Math","floor","toPrecision","toFixed","normalisePlayerTime","wholeSeconds","frames","timecodeToSecondsHelper","tc","split","timecodeToFrames","isOneDigit","str","length","padTimeToTimecode","time","timecode","includes","includesFullStop","replace","__webpack_exports__","timecode_converter_timecodeToSeconds","shortTimecode","src_secondsToTimecode","timecodeToSeconds","resultPadded","parseFloat","slice"],"mappings":"2BACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QA0DA,OArDAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CZ,EAAAkB,EAAA,SAAAhB,GACA,oBAAAiB,eAAAC,aACAN,OAAAC,eAAAb,EAAAiB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAb,EAAA,cAAiDmB,OAAA,KAQjDrB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,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