Skip to content

Commit

Permalink
Merge pull request #834 from sliceofbytes/update-angular
Browse files Browse the repository at this point in the history
Update to Angular 8 and fix build scripts
  • Loading branch information
sliceofbytes authored Jul 9, 2019
2 parents cf7de7c + 8e435eb commit 3fd74e7
Show file tree
Hide file tree
Showing 47 changed files with 858 additions and 846 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ Thumbs.db

# Folder config file
Desktop.ini
.angulardoc.json


# VS Code
.vscode
4 changes: 2 additions & 2 deletions core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ export * from './src/core/core';
// CustomEvent polyfill for IE9/10/11
(function () {

if ( typeof window === "undefined" || typeof window['CustomEvent'] === "function" ) return false;
if ( typeof window === "undefined" || typeof window['CustomEvent'] === "function" ) { return false; }

function CustomEvent ( event, params ) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent( 'CustomEvent' );
let evt = document.createEvent( 'CustomEvent' );
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
return evt;
}
Expand Down
6 changes: 2 additions & 4 deletions karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function isSpecFile(path) {
}

function isBuiltFile(path) {
var builtPath = '/base/src/';
var builtPath = '/base/compiled/';
return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath);
}

Expand All @@ -41,7 +41,6 @@ System.config(
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

Expand All @@ -51,11 +50,10 @@ System.config(
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js',

'app': 'base/src'
'app': 'base/compiled/src'
},
packages: {
'rxjs/operators': { defaultExtension: 'js', main: 'index' },
Expand Down
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ module.exports = function(config) {

{pattern: 'karma-test-shim.js', included: true, watched: true},


// Our built application code
{pattern: 'src/**/*.js', included: false, watched: true},
{pattern: 'compiled/**/*.js', included: false, watched: true},

// paths loaded via Angular's component compiler
// (these paths need to be rewritten, see proxies section)
Expand Down
51 changes: 27 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,73 @@
"url": "https://github.com/videogular/videogular2"
},
"peerDependencies": {
"@angular/core": "^7.1.0",
"@angular/core": "^8.0.0",
"rxjs": "^6.3.0"
},
"devDependencies": {
"@angular/animations": "^7.1.4",
"@angular/common": "^7.1.4",
"@angular/compiler": "^7.1.4",
"@angular/compiler-cli": "^7.0.4",
"@angular/core": "^7.1.4",
"@angular/http": "^7.1.4",
"@angular/platform-browser": "^7.1.4",
"@angular/platform-browser-dynamic": "^7.1.4",
"@angular/platform-server": "^7.1.4",
"@angular/animations": "^8.0.0",
"@angular/cli": "8.0.1",
"@angular/common": "^8.0.0",
"@angular/compiler": "^8.0.0",
"@angular/compiler-cli": "^8.0.0",
"@angular/core": "^8.0.0",
"@angular/platform-browser": "^8.0.0",
"@angular/platform-browser-dynamic": "^8.0.0",
"@angular/platform-server": "^8.0.0",
"@types/bluebird": "^3.5.25",
"@types/core-js": "0.9.46",
"@types/jasmine": "^3.3.1",
"@types/node": "10.12.12",
"codelyzer": "^4.5.0",
"codelyzer": "5.1.0",
"commitizen": "2.9.6",
"core-js": "^2.6.0",
"cz-conventional-changelog": "2.0.0",
"es-module-loader": "2.3.0",
"http-server": "0.11.1",
"husky": "^1.3.0",
"husky": "^2.4.0",
"jasmine-core": "^3.3.0",
"karma": "^3.1.3",
"karma": "^4.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "^1.1.0",
"karma-coverage": "^1.1.2",
"karma-firefox-launcher": "^1.1.0",
"karma-jasmine": "^2.0.1",
"karma-spec-reporter": "^0.0.32",
"parallelshell": "2.0.0",
"npm-run-all": "4.1.5",
"reflect-metadata": "^0.1.10",
"remap-istanbul": "0.9.5",
"rimraf": "2.6.1",
"rxjs": "^6.3.0",
"rxjs": "6.5.2",
"semantic-release": "6.3.2",
"systemjs": "^0.20.19",
"tslint": "^5.11.0",
"typescript": "~3.1.1",
"tslint": "5.17.0",
"typescript": "~3.4.5",
"validate-commit-msg": "2.12.1",
"watch": "1.0.2",
"zone.js": "^0.8.26"
"zone.js": "0.9.1"
},
"scripts": {
"commitmsg": "validate-commit-msg",
"prebuild": "npm run clean",
"build": "ngc",
"postbuild": "npm test",
"build:travis": "ngc",
"postbuild:travis": "npm run test",
"clean": "rimraf -rf ./src/**/*.js && rimraf -rf ./src/**/*.d.ts && rimraf -rf ./compiled",
"precommit": "npm test",
"commit": "git-cz",
"coverage": "http-server -c-1 -o -s -p 9875 ./coverage",
"start": "parallelshell \"npm run watch:ts\" \"npm run start:coverage-server\"",
"start": "run-p \"watch:ts\" \"start:coverage-server\"",
"start:coverage-server": "http-server -c-1 -o -p 9875 ./coverage",
"test": "karma start karma.conf.js",
"posttest": "remap-istanbul -i ./coverage/coverage-final.json -o coverage -t html",
"report-coverage": "cat ./coverage/coverage-final.json | ./node_modules/.bin/remap-istanbul -o coverage-remapped.json",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"watch:ts": "watch \"npm run build\" src",
"parallelshell": "parallelshell",
"lint": "tslint '**/*.ts' -e 'node_modules/**/*' -e 'compiled/**/**' --fix --noUnusedParameters --noUnusedLocals"
"lint": "tslint -p tsconfig.json -c tslint.json --fix"
},
"husky": {
"hooks": {
"pre-commit": "npm test",
"commit-msg": "validate-commit-msg"
}
},
"engines": {
"node": ">=10.9.0 <11.0.0"
Expand Down
74 changes: 36 additions & 38 deletions src/buffering/vg-buffering.spec.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
import {VgBuffering} from "./vg-buffering";
import {VgAPI} from "../core/services/vg-api";
import {IPlayable} from "../core/vg-media/i-playable";
import {ElementRef} from "@angular/core";
import { VgStates } from "../core/states/vg-states";
import { VgBuffering } from './vg-buffering';
import { VgAPI } from '../core/services/vg-api';
import { ElementRef } from '@angular/core';

describe('Buffering', () => {
let vgBuffering:VgBuffering;
let ref:ElementRef;
let api:VgAPI;
let vgBuffering: VgBuffering;
let ref: ElementRef;
let api: VgAPI;

beforeEach(() => {
ref = {
nativeElement: {
getAttribute: (name) => {
return name;
}
}
};
beforeEach(() => {
ref = {
nativeElement: {
getAttribute: (name) => {
return name;
}
}
};

api = new VgAPI();
vgBuffering = new VgBuffering(ref, api);
});
api = new VgAPI();
vgBuffering = new VgBuffering(ref, api);
});

describe('onPlayerReady', ()=>{
it('should subscribe to bufferDetected media events', ()=>{
spyOn(api, 'getMediaById').and.returnValue({
subscriptions: {
bufferDetected: {subscribe: jasmine.createSpy('bufferDetected') }
}
});
vgBuffering.onPlayerReady();
expect(vgBuffering.target.subscriptions.bufferDetected.subscribe).toHaveBeenCalled();
});
describe('onPlayerReady', () => {
it('should subscribe to bufferDetected media events', () => {
spyOn(api, 'getMediaById').and.returnValue(<any>{
subscriptions: {
bufferDetected: { subscribe: jasmine.createSpy('bufferDetected') }
}
});
vgBuffering.onPlayerReady();
expect(vgBuffering.target.subscriptions.bufferDetected.subscribe).toHaveBeenCalled();
});
});

describe('isBuffering', ()=> {
it('should show if buffer is detected', () => {
vgBuffering.onUpdateBuffer(true);
expect(vgBuffering.isBuffering).toBe(true);
});
it('should hide if buffer is not detected', () => {
vgBuffering.onUpdateBuffer(false);
expect(vgBuffering.isBuffering).toBe(false);
});
describe('isBuffering', () => {
it('should show if buffer is detected', () => {
vgBuffering.onUpdateBuffer(true);
expect(vgBuffering.isBuffering).toBe(true);
});
it('should hide if buffer is not detected', () => {
vgBuffering.onUpdateBuffer(false);
expect(vgBuffering.isBuffering).toBe(false);
});
});
});
9 changes: 4 additions & 5 deletions src/buffering/vg-buffering.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, ElementRef, HostBinding, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { VgAPI } from '../core/services/vg-api';
import { IPlayable } from '../core/vg-media/i-playable';
import { VgStates } from '../core/states/vg-states';
import { Subscription } from 'rxjs';

@Component({
Expand Down Expand Up @@ -106,13 +105,13 @@ export class VgBuffering implements OnInit, OnDestroy {

elem: HTMLElement;
target: IPlayable;
checkInterval: number = 50;
currentPlayPos: number = 0;
lastPlayPos: number = 0;
checkInterval = 50;
currentPlayPos = 0;
lastPlayPos = 0;

subscriptions: Subscription[] = [];

@HostBinding('class.is-buffering') isBuffering: boolean = false;
@HostBinding('class.is-buffering') isBuffering = false;

constructor(ref: ElementRef, public API: VgAPI) {
this.elem = ref.nativeElement;
Expand Down
16 changes: 7 additions & 9 deletions src/controls/vg-controls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Component, Input, OnInit, ElementRef, HostBinding, AfterViewInit, ViewEncapsulation,
EventEmitter, Output, OnDestroy
Component, Input, OnInit, ElementRef, HostBinding, AfterViewInit, ViewEncapsulation, OnDestroy
} from '@angular/core';
import { Observable , Subscription } from 'rxjs';
import { VgAPI } from '../core/services/vg-api';
Expand Down Expand Up @@ -29,7 +28,7 @@ import {fromEvent} from 'rxjs';
transition: bottom 1s;
}
vg-controls.hide {
vg-controls.hide {
bottom: -50px;
}
`]
Expand All @@ -38,21 +37,20 @@ export class VgControls implements OnInit, AfterViewInit, OnDestroy {
elem: HTMLElement;
target: any;

@HostBinding('style.pointer-events') isAdsPlaying: string = 'initial';
@HostBinding('class.hide') hideControls: boolean = false;
@HostBinding('style.pointer-events') isAdsPlaying = 'initial';
@HostBinding('class.hide') hideControls = false;

@Input() vgFor: string;
@Input() vgAutohide: boolean = false;
@Input() vgAutohideTime: number = 3;
@Input() vgAutohide = false;
@Input() vgAutohideTime = 3;

private timer: any;
private hideTimer: any;

mouseMove$: Observable<any>;
touchStart$: Observable<any>;

subscriptions: Subscription[] = [];

// @ts-ignore
constructor(private API: VgAPI, private ref: ElementRef, private hidden: VgControlsHidden) {
this.elem = ref.nativeElement;
}
Expand Down
Loading

0 comments on commit 3fd74e7

Please sign in to comment.