|
|
@ -4,6 +4,7 @@ const pMap = require('p-map'); |
|
|
const { basename, join } = require('path'); |
|
|
const { basename, join } = require('path'); |
|
|
const flatMap = require('lodash/flatMap'); |
|
|
const flatMap = require('lodash/flatMap'); |
|
|
const JSON5 = require('json5'); |
|
|
const JSON5 = require('json5'); |
|
|
|
|
|
const fs = require('fs-extra'); |
|
|
|
|
|
|
|
|
const { parseFps, readFileInfo, multipleOf2 } = require('./util'); |
|
|
const { parseFps, readFileInfo, multipleOf2 } = require('./util'); |
|
|
const { registerFont } = require('./sources/fabricFrameSource'); |
|
|
const { registerFont } = require('./sources/fabricFrameSource'); |
|
|
@ -18,6 +19,8 @@ const loadedFonts = []; |
|
|
// See #16
|
|
|
// See #16
|
|
|
const checkTransition = (transition) => assert(transition == null || typeof transition === 'object', 'Transition must be an object'); |
|
|
const checkTransition = (transition) => assert(transition == null || typeof transition === 'object', 'Transition must be an object'); |
|
|
|
|
|
|
|
|
|
|
|
const assertFileExists = async (path) => assert(await fs.exists(path), `File does not exist ${path}`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = async (config = {}) => { |
|
|
module.exports = async (config = {}) => { |
|
|
const { |
|
|
const { |
|
|
@ -42,6 +45,8 @@ module.exports = async (config = {}) => { |
|
|
|
|
|
|
|
|
const audioFilePath = isGif ? undefined : audioFilePathIn; |
|
|
const audioFilePath = isGif ? undefined : audioFilePathIn; |
|
|
|
|
|
|
|
|
|
|
|
if (audioFilePath) await assertFileExists(audioFilePath); |
|
|
|
|
|
|
|
|
checkTransition(defaultsIn.transition); |
|
|
checkTransition(defaultsIn.transition); |
|
|
|
|
|
|
|
|
const defaults = { |
|
|
const defaults = { |
|
|
@ -62,6 +67,13 @@ module.exports = async (config = {}) => { |
|
|
async function handleLayer(layer) { |
|
|
async function handleLayer(layer) { |
|
|
const { type, ...restLayer } = layer; |
|
|
const { type, ...restLayer } = layer; |
|
|
|
|
|
|
|
|
|
|
|
// https://github.com/mifi/editly/issues/39
|
|
|
|
|
|
if (type === 'image') { |
|
|
|
|
|
await assertFileExists(restLayer.path); |
|
|
|
|
|
} else if (type === 'gl') { |
|
|
|
|
|
await assertFileExists(restLayer.fragmentPath); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (['fabric', 'canvas'].includes(type)) assert(typeof layer.func === 'function', '"func" must be a function'); |
|
|
if (['fabric', 'canvas'].includes(type)) assert(typeof layer.func === 'function', '"func" must be a function'); |
|
|
|
|
|
|
|
|
if (['image', 'fabric', 'canvas', 'gl', 'radial-gradient', 'linear-gradient', 'fill-color'].includes(type)) return layer; |
|
|
if (['image', 'fabric', 'canvas', 'gl', 'radial-gradient', 'linear-gradient', 'fill-color'].includes(type)) return layer; |
|
|
|