UNPKG

16.7 kBSource Map (JSON)View Raw
1{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./packages/export-adapters/txt/index.js","webpack:///./packages/export-adapters/txt-speakers-timecodes/index.js","webpack:///./packages/export-adapters/draftjs-to-digital-paper-edit/index.js","webpack:///./packages/export-adapters/index.js","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","txt","blockData","blocks","map","x","text","join","txt_speakers_timecodes","block","concat","data","speaker","shortTimecode","start","draftjs_to_digital_paper_edit","result","words","paragraphs","forEach","index","tmpParagraph","id","end","length","push","tmpWords","word","tmpWord","punct","exportAdapter","exportFormat","ext","draftToTxt","draftToTxtSpeakersTimecodes","draftToDigitalPaperEdit","console","error","secondsToTimecode","seconds","framePerSeconds","_padZero","parseInt","fps","normalisedSeconds","Math","floor","toPrecision","toFixed","normalisePlayerTime","wholeSeconds","frames","timecodeToSecondsHelper","tc","split","timecodeToFrames","isOneDigit","str","padTimeToTimecode","time","timecode","includes","includesFullStop","replace","__webpack_exports__","timecode_converter_timecodeToSeconds","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,E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KAAA5C,OAK6CiD,EAAKL,MAAM,KAAK,GAL7D,aAAA5C,OAQkBiD,EAAKI,QAAQ,IAAK,KARpC,OAaMP,EAAWG,GAbjB,UAAAjD,OAcsBiD,EAdtB,gBAAAjD,OAiBmBiD,EAjBnB,SCvBJ9F,EAAAU,EAAAyF,EAAA,sCAAAC,IAAApG,EAAAU,EAAAyF,EAAA,kCAAAnD,IAAAhD,EAAAU,EAAAyF,EAAA,sCAAAE,QAkBMC,EAAoB,SAACR,GACzB,GAAoB,iBAATA,EAAmB,KACtBS,EAAeV,EAAkBC,GAGvC,OAFwBP,EAAwBgB,GAMlD,OAAOC,WAAWV,IAGd9C,EAAgB,SAAC8C,GAGrB,OAFiBrB,EAAkBqB,GAEnBW,MAAM,GAAI","file":"exportAdapter.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 = 52);\n","/**\n * Convert DraftJS to plain text without timecodes or speaker names\n */\nexport default (blockData) => {\n const lines = blockData.blocks.map(x => x.text);\n\n return lines.join('\\n\\n');\n};\n","/**\n * Convert DraftJS to plain text with timecodes and speaker names\n *\n * Example:\n ```\n F_S12 \t [00:00:13] \t There is a day. About ten years ago when I asked a friend to hold a baby dinosaur robot upside down. It was a toy called plea. All\n ```\n *\n */\nimport { shortTimecode } from '../../util/timecode-converter/index.js';\n\nexport default (blockData) => {\n const lines = blockData.blocks.map((block) => {\n return `${ block.data.speaker } \\t [${ shortTimecode(block.data.start) }] \\t ${ block.text }`;\n });\n\n return lines.join('\\n\\n');\n};\n","/**\n * Convert DraftJS to Digital Paper Edit format\n * More details see\n * https://github.com/bbc/digital-paper-edit\n */\nexport default (blockData) => {\n const result = { words: [], paragraphs: [] };\n\n blockData.blocks.forEach((block, index) => {\n if (block.data.words !== undefined) {\n // TODO: make sure that when restoring timecodes text attribute in block word data\n // should be updated as well\n const tmpParagraph = {\n id: index,\n start: block.data.words[0].start, //block.data.start,\n end: block.data.words[block.data.words.length - 1].end,\n speaker: block.data.speaker\n };\n result.paragraphs.push(tmpParagraph);\n // using data within a block to get words info\n const tmpWords = block.data.words.map((word) => {\n const tmpWord = {\n id: word.index,\n start: word.start,\n end: word.end,\n text: null\n };\n // TODO: need to normalise various stt adapters\n // so that when they create draftJs json, word text attribute\n // has got consistent naming. `text` and not `punct` or `word`.\n if (word.text) {\n tmpWord.text = word.punct;\n }\n else if (word.punct) {\n tmpWord.text = word.punct;\n }\n else if (word.word) {\n tmpWord.text = word.punct;\n }\n\n return tmpWord;\n });\n // flattening the list of words\n result.words = result.words.concat(tmpWords);\n }\n });\n\n return result;\n};\n","import draftToTxt from './txt/index';\nimport draftToTxtSpeakersTimecodes from './txt-speakers-timecodes/index';\nimport draftToDigitalPaperEdit from './draftjs-to-digital-paper-edit/index.js';\n/**\n * Adapters for Draft.js conversion\n * @param {json} blockData - Draft.js blocks\n * @param {string} exportFormat - the type of file supported by the available adapters\n */\n\nconst exportAdapter = (blockData, exportFormat) => {\n switch (exportFormat) {\n case 'draftjs':\n return { data: blockData, ext: 'json' };\n case 'txt':\n return { data: draftToTxt(blockData), ext: 'txt' };\n case 'txtspeakertimecodes':\n return { data: draftToTxtSpeakersTimecodes(blockData), ext: 'txt' };\n case 'digitalpaperedit':\n return { data: draftToDigitalPaperEdit(blockData), ext: 'json' };\n default:\n // code block\n console.error('Did not recognise the export format');\n }\n};\n\nexport default exportAdapter;\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