First release

This commit is contained in:
Owen Quinlan 2021-07-02 19:29:34 +10:00
commit fa6c85266e
2339 changed files with 761050 additions and 0 deletions

View file

@ -0,0 +1,96 @@
const fs = require('fs');
const path = require('path');
const baseDir = path.join(__dirname, '..');
const formatDir = path.join(baseDir, 'test', 'fixtures', 'formats');
const parsingDir = path.join(baseDir, 'test', 'fixtures', 'parsing');
const getFiles = (dir) => (fs.readdirSync(dir) || []).reduce((acc, d) => {
d = path.resolve(dir, d);
const stat = fs.statSync(d);
if (!stat.isDirectory()) {
return acc;
}
const subfiles = fs.readdirSync(d).map((f) => path.resolve(d, f));
return acc.concat(subfiles);
}, []);
const buildDataString = function(files, id) {
const data = {};
files.forEach((file) => {
// read the file directly as a buffer before converting to base64
const base64 = fs.readFileSync(file).toString('base64');
data[path.basename(file)] = base64;
});
const dataExportStrings = Object.keys(data).reduce((acc, key) => {
// use a function since the segment may be cleared out on usage
acc.push(`${id}Files['${key}'] = () => {
cache['${key}'] = cache['${key}'] || base64ToUint8Array('${data[key]}');
const dest = new Uint8Array(cache['${key}'].byteLength);
dest.set(cache['${key}']);
return dest;
};`);
return acc;
}, []);
const file =
'/* istanbul ignore file */\n' +
'\n' +
`import base64ToUint8Array from "${path.resolve(baseDir, 'src/decode-b64-to-uint8-array.js')}";\n` +
'const cache = {};\n' +
`const ${id}Files = {};\n` +
dataExportStrings.join('\n') +
`export default ${id}Files`;
return file;
};
/* we refer to them as .js, so that babel and other plugins can work on them */
const formatsKey = 'create-test-data!formats.js';
const parsingKey = 'create-test-data!parsing.js';
module.exports = function() {
return {
name: 'createTestData',
buildStart() {
this.addWatchFile(formatDir);
this.addWatchFile(parsingDir);
getFiles(formatDir).forEach((file) => this.addWatchFile(file));
getFiles(parsingDir).forEach((file) => this.addWatchFile(file));
},
resolveId(importee, importer) {
// if this is not an id we can resolve return
if (importee.indexOf('create-test-data!') !== 0) {
return;
}
const name = importee.split('!')[1];
if (name.indexOf('formats') !== -1) {
return formatsKey;
}
if (name.indexOf('parsing') !== -1) {
return parsingKey;
}
return null;
},
load(id) {
if (id === formatsKey) {
return buildDataString.call(this, getFiles(formatDir), 'format');
}
if (id === parsingKey) {
return buildDataString.call(this, getFiles(parsingDir), 'parsing');
}
}
};
};

16
node_modules/@videojs/vhs-utils/scripts/karma.conf.js generated vendored Normal file
View file

@ -0,0 +1,16 @@
const generate = require('videojs-generate-karma-config');
module.exports = function(config) {
// see https://github.com/videojs/videojs-generate-karma-config
// for options
const options = {
serverBrowsers() {
return [];
}
};
config = generate(config, options);
// any other custom stuff not supported by options here!
};

View file

@ -0,0 +1,28 @@
const createTestData = require('./create-test-data.js');
const generate = require('videojs-generate-rollup-config');
// see https://github.com/videojs/videojs-generate-rollup-config
// for options
const options = {
input: 'src/index.js',
exportName: 'vhsUtils',
distName: 'vhs-utils',
primedPlugins(defaults) {
return Object.assign(defaults, {
createTestData: createTestData()
});
},
plugins(defaults) {
defaults.test.splice(0, 0, 'createTestData');
return defaults;
}
};
const config = generate(options);
if (config.builds.module) {
delete config.builds.module;
}
// Add additonal builds/customization here!
// export the builds to rollup
export default Object.values(config.builds);