Skip to content

Commit

Permalink
chore: update generator and use @videojs/vhs-utils (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Aug 22, 2019
1 parent 3693768 commit 1238749
Show file tree
Hide file tree
Showing 15 changed files with 2,983 additions and 4,010 deletions.
6,508 changes: 2,727 additions & 3,781 deletions package-lock.json

Large diffs are not rendered by default.

64 changes: 25 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,22 @@
"scripts": {
"prenetlify": "npm run build",
"netlify": "node scripts/netlify.js",
"prebuild": "npm run clean",
"build": "npm-run-all -p build:*",
"build-test": "cross-env-shell TEST_BUNDLE_ONLY=1 'npm run build'",
"build-prod": "cross-env-shell NO_TEST_BUNDLE=1 'npm run build'",
"build": "npm-run-all -s clean -p build:*",
"build:js": "rollup -c scripts/rollup.config.js",
"clean": "shx rm -rf ./dist ./test/dist",
"postclean": "shx mkdir -p ./dist ./test/dist",
"docs": "npm-run-all docs:*",
"docs:api": "jsdoc src -g plugins/markdown -r -d docs/api",
"docs:toc": "doctoc README.md",
"clean": "shx rm -rf ./dist ./test/dist && shx mkdir -p ./dist ./test/dist",
"lint": "vjsstandard",
"server": "karma start scripts/karma.conf.js --singleRun=false --auto-watch",
"prepublishOnly": "npm-run-all build-prod && vjsverify --verbose",
"start": "npm-run-all -p server watch",
"pretest": "npm-run-all lint build",
"test": "karma start scripts/karma.conf.js",
"update-changelog": "conventional-changelog -p videojs -i CHANGELOG.md -s",
"server": "karma start scripts/karma.conf.js --singleRun=false --auto-watch",
"test": "npm-run-all lint build-test && karma start scripts/karma.conf.js",
"posttest": "shx cat test/dist/coverage/text.txt",
"preversion": "npm test",
"version": "is-prerelease || npm run update-changelog && git add CHANGELOG.md",
"update-changelog": "conventional-changelog -p videojs -i CHANGELOG.md -s",
"watch": "npm-run-all -p watch:*",
"watch:js": "npm run build:js -- -w",
"posttest": "shx cat test/dist/coverage/text.txt",
"prepublishOnly": "npm run build && vjsverify"
"watch:js": "npm run build:js -- -w"
},
"keywords": [
"videojs",
Expand All @@ -54,34 +50,24 @@
"src/",
"test/"
],
"dependencies": {
"@babel/runtime": "^7.5.5",
"@videojs/vhs-utils": "^1.0.0",
"global": "^4.3.2"
},
"devDependencies": {
"conventional-changelog-cli": "^2.0.1",
"conventional-changelog-videojs": "^3.0.0",
"doctoc": "^1.3.1",
"husky": "^1.0.0-rc.13",
"jsdoc": "https://github.com/BrandonOCasey/jsdoc#feat/plugin-from-cli",
"karma": "^3.0.0",
"lint-staged": "^7.2.2",
"not-prerelease": "^1.0.1",
"npm-merge-driver-install": "^1.0.0",
"npm-run-all": "^4.1.5",
"pkg-ok": "^2.2.0",
"rollup": "^0.66.0",
"@videojs/generator-helpers": "~1.2.0",
"karma": "^4.0.0",
"rollup": "^1.19.4",
"rollup-plugin-string": "^2.0.2",
"shelljs": "~0.8.2",
"shx": "^0.3.2",
"sinon": "^6.1.5",
"videojs-generate-karma-config": "~5.0.1",
"videojs-generate-rollup-config": "~2.3.0",
"videojs-generator-verify": "~1.0.4",
"videojs-standard": "~7.1.0"
"sinon": "^7.2.2",
"videojs-generate-karma-config": "~5.3.1",
"videojs-generate-rollup-config": "~5.0.1",
"videojs-generator-verify": "~2.0.0",
"videojs-standard": "^8.0.3"
},
"generator-videojs-plugin": {
"version": "7.3.2"
},
"dependencies": {
"global": "^4.3.2",
"url-toolkit": "^2.1.1"
"version": "7.7.3"
},
"browserslist": [
"defaults",
Expand All @@ -93,7 +79,7 @@
"git add"
],
"README.md": [
"npm run docs:toc",
"doctoc --notitle",
"git add"
]
},
Expand Down
4 changes: 4 additions & 0 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const options = {
primedPlugins(defaults) {
defaults.string = string({include: ['test/manifests/*.mpd']});

return defaults;
},
externals(defaults) {
defaults.module.push('@videojs/vhs-utils');
return defaults;
}
};
Expand Down
44 changes: 23 additions & 21 deletions src/inheritAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { flatten } from './utils/list';
import { merge } from './utils/object';
import { findChildren, getContent } from './utils/xml';
import { parseAttributes } from './parseAttributes';
import resolveUrl from './utils/resolveUrl';
import errors from './errors';
import decodeB64ToUint8Array from './utils/decodeB64ToUint8Array';
import resolveUrl from '@videojs/vhs-utils/dist/resolve-url';
import decodeB64ToUint8Array from '@videojs/vhs-utils/dist/decode-b64-to-uint8-array';

const keySystemsMap = {
'urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b': 'org.w3.clearkey',
Expand All @@ -29,10 +29,11 @@ export const buildBaseUrls = (referenceUrls, baseUrlElements) => {
return referenceUrls;
}

return flatten(
referenceUrls.map(
reference => baseUrlElements.map(
baseUrlElement => resolveUrl(reference, getContent(baseUrlElement)))));
return flatten(referenceUrls.map(function(reference) {
return baseUrlElements.map(function(baseUrlElement) {
return resolveUrl(reference, getContent(baseUrlElement));
});
}));
};

/**
Expand Down Expand Up @@ -96,11 +97,11 @@ export const getSegmentInformation = (adaptationSet) => {
{
segmentUrls,
initialization: parseAttributes(segmentInitialization)
}),
base: segmentBase && merge(
parseAttributes(segmentBase), {
initialization: parseAttributes(segmentInitialization)
})
}
),
base: segmentBase && merge(parseAttributes(segmentBase), {
initialization: parseAttributes(segmentInitialization)
})
};

Object.keys(segmentInfo).forEach(key => {
Expand Down Expand Up @@ -221,17 +222,20 @@ const generateKeySystemInformation = (contentProtectionNodes) => {
export const toRepresentations =
(periodAttributes, periodBaseUrls, periodSegmentInfo) => (adaptationSet) => {
const adaptationSetAttributes = parseAttributes(adaptationSet);
const adaptationSetBaseUrls = buildBaseUrls(periodBaseUrls,
findChildren(adaptationSet, 'BaseURL'));
const adaptationSetBaseUrls = buildBaseUrls(
periodBaseUrls,
findChildren(adaptationSet, 'BaseURL')
);
const role = findChildren(adaptationSet, 'Role')[0];
const roleAttributes = { role: parseAttributes(role) };

let attrs = merge(periodAttributes,
let attrs = merge(
periodAttributes,
adaptationSetAttributes,
roleAttributes);
roleAttributes
);

const contentProtection = generateKeySystemInformation(
findChildren(adaptationSet, 'ContentProtection'));
const contentProtection = generateKeySystemInformation(findChildren(adaptationSet, 'ContentProtection'));

if (Object.keys(contentProtection).length) {
attrs = merge(attrs, { contentProtection });
Expand All @@ -241,8 +245,7 @@ export const toRepresentations =
const representations = findChildren(adaptationSet, 'Representation');
const adaptationSetSegmentInfo = merge(periodSegmentInfo, segmentInfo);

return flatten(representations.map(
inheritBaseUrls(attrs, adaptationSetBaseUrls, adaptationSetSegmentInfo)));
return flatten(representations.map(inheritBaseUrls(attrs, adaptationSetBaseUrls, adaptationSetSegmentInfo)));
};

/**
Expand Down Expand Up @@ -280,8 +283,7 @@ export const toAdaptationSets = (mpdAttributes, mpdBaseUrls) => (period, index)
const adaptationSets = findChildren(period, 'AdaptationSet');
const periodSegmentInfo = getSegmentInformation(period);

return flatten(adaptationSets.map(
toRepresentations(periodAttributes, periodBaseUrls, periodSegmentInfo)));
return flatten(adaptationSets.map(toRepresentations(periodAttributes, periodBaseUrls, periodSegmentInfo)));
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/segment/segmentTemplate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import resolveUrl from '../utils/resolveUrl';
import resolveUrl from '@videojs/vhs-utils/dist/resolve-url';
import urlTypeToSegment from './urlType';
import { parseByTimeline } from './timelineTimeParser';
import { parseByDuration } from './durationTimeParser';
Expand Down
2 changes: 1 addition & 1 deletion src/segment/urlType.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import resolveUrl from '../utils/resolveUrl';
import resolveUrl from '@videojs/vhs-utils/dist/resolve-url';

/**
* @typedef {Object} SingleUri
Expand Down
4 changes: 1 addition & 3 deletions src/toM3u8.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ export const toM3u8 = (dashPlaylists, sidxMapping = {}) => {
const vttOnly = ({ attributes }) =>
attributes.mimeType === 'text/vtt' || attributes.contentType === 'text';

const videoPlaylists = mergeDiscontiguousPlaylists(
dashPlaylists.filter(videoOnly)
).map(formatVideoPlaylist);
const videoPlaylists = mergeDiscontiguousPlaylists(dashPlaylists.filter(videoOnly)).map(formatVideoPlaylist);
const audioPlaylists = mergeDiscontiguousPlaylists(dashPlaylists.filter(audioOnly));
const vttPlaylists = dashPlaylists.filter(vttOnly);

Expand Down
11 changes: 0 additions & 11 deletions src/utils/decodeB64ToUint8Array.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/utils/resolveUrl.js

This file was deleted.

Loading

0 comments on commit 1238749

Please sign in to comment.