aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-13 12:16:00 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-13 12:16:00 +0100
commitc16ce1de8e8c21ad2136335d3b0b7d230e6d2f24 (patch)
treee5177a26dae755833122c4ef73744c2a7f9b53fc /client/src
parent80deae8d198f6a376b477d780e76966f8fbb72ce (diff)
downloadPeerTube-c16ce1de8e8c21ad2136335d3b0b7d230e6d2f24.tar.gz
PeerTube-c16ce1de8e8c21ad2136335d3b0b7d230e6d2f24.tar.zst
PeerTube-c16ce1de8e8c21ad2136335d3b0b7d230e6d2f24.zip
Client: add basic aot support
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/account/account.service.ts2
-rw-r--r--client/src/app/admin/friends/shared/friend.service.ts2
-rw-r--r--client/src/app/admin/requests/request-stats/request-stats.component.ts1
-rw-r--r--client/src/app/admin/requests/shared/request.service.ts2
-rw-r--r--client/src/app/admin/users/shared/user.service.ts2
-rw-r--r--client/src/app/app.component.ts2
-rw-r--r--client/src/app/app.module.ts3
-rw-r--r--client/src/app/app.service.ts20
-rw-r--r--client/src/app/core/auth/auth.service.ts2
-rw-r--r--client/src/app/environment.ts13
-rw-r--r--client/src/app/shared/auth/auth-http.service.ts8
-rw-r--r--client/src/app/videos/shared/video.service.ts2
-rw-r--r--client/src/app/videos/video-watch/video-magnet.component.html2
-rw-r--r--client/src/app/videos/video-watch/video-share.component.html2
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.ts3
-rw-r--r--client/src/custom-typings.d.ts17
-rw-r--r--client/src/main.browser.aot.ts23
-rw-r--r--client/src/main.browser.ts (renamed from client/src/main.ts)0
-rw-r--r--client/src/polyfills.browser.ts (renamed from client/src/polyfills.ts)0
-rw-r--r--client/src/sass/application.scss2
-rw-r--r--client/src/vendor.ts35
21 files changed, 80 insertions, 63 deletions
diff --git a/client/src/app/account/account.service.ts b/client/src/app/account/account.service.ts
index 0635c2533..046690347 100644
--- a/client/src/app/account/account.service.ts
+++ b/client/src/app/account/account.service.ts
@@ -1,4 +1,6 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import 'rxjs/add/operator/catch';
3import 'rxjs/add/operator/map';
2 4
3import { AuthService } from '../core'; 5import { AuthService } from '../core';
4import { AuthHttp, RestExtractor } from '../shared'; 6import { AuthHttp, RestExtractor } from '../shared';
diff --git a/client/src/app/admin/friends/shared/friend.service.ts b/client/src/app/admin/friends/shared/friend.service.ts
index 85ac04ba0..e97459385 100644
--- a/client/src/app/admin/friends/shared/friend.service.ts
+++ b/client/src/app/admin/friends/shared/friend.service.ts
@@ -1,5 +1,7 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Observable } from 'rxjs/Observable'; 2import { Observable } from 'rxjs/Observable';
3import 'rxjs/add/operator/catch';
4import 'rxjs/add/operator/map';
3 5
4import { Friend } from './friend.model'; 6import { Friend } from './friend.model';
5import { AuthHttp, RestExtractor, ResultList } from '../../../shared'; 7import { AuthHttp, RestExtractor, ResultList } from '../../../shared';
diff --git a/client/src/app/admin/requests/request-stats/request-stats.component.ts b/client/src/app/admin/requests/request-stats/request-stats.component.ts
index 9e2af219c..66075e4b5 100644
--- a/client/src/app/admin/requests/request-stats/request-stats.component.ts
+++ b/client/src/app/admin/requests/request-stats/request-stats.component.ts
@@ -1,3 +1,4 @@
1import { setInterval } from 'timers'
1import { Component, OnInit, OnDestroy } from '@angular/core'; 2import { Component, OnInit, OnDestroy } from '@angular/core';
2 3
3import { RequestService, RequestStats } from '../shared'; 4import { RequestService, RequestStats } from '../shared';
diff --git a/client/src/app/admin/requests/shared/request.service.ts b/client/src/app/admin/requests/shared/request.service.ts
index aeec37448..55b28bcfc 100644
--- a/client/src/app/admin/requests/shared/request.service.ts
+++ b/client/src/app/admin/requests/shared/request.service.ts
@@ -1,5 +1,7 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Observable } from 'rxjs/Observable'; 2import { Observable } from 'rxjs/Observable';
3import 'rxjs/add/operator/catch';
4import 'rxjs/add/operator/map';
3 5
4import { RequestStats } from './request-stats.model'; 6import { RequestStats } from './request-stats.model';
5import { AuthHttp, RestExtractor } from '../../../shared'; 7import { AuthHttp, RestExtractor } from '../../../shared';
diff --git a/client/src/app/admin/users/shared/user.service.ts b/client/src/app/admin/users/shared/user.service.ts
index 13be553c0..d9005b213 100644
--- a/client/src/app/admin/users/shared/user.service.ts
+++ b/client/src/app/admin/users/shared/user.service.ts
@@ -1,4 +1,6 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import 'rxjs/add/operator/catch';
3import 'rxjs/add/operator/map';
2 4
3import { AuthHttp, RestExtractor, ResultList, User } from '../../../shared'; 5import { AuthHttp, RestExtractor, ResultList, User } from '../../../shared';
4 6
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index ce4fc04ff..3f2f1ace0 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -1,7 +1,7 @@
1import { Component, ViewContainerRef } from '@angular/core'; 1import { Component, ViewContainerRef } from '@angular/core';
2import { Router } from '@angular/router'; 2import { Router } from '@angular/router';
3 3
4import { MetaService } from 'ng2-meta'; 4import { MetaService } from 'ng2-meta/src';
5@Component({ 5@Component({
6 selector: 'my-app', 6 selector: 'my-app',
7 templateUrl: './app.component.html', 7 templateUrl: './app.component.html',
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index e9bb800f4..fb71787c4 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -2,7 +2,8 @@ import { ApplicationRef, NgModule } from '@angular/core';
2import { BrowserModule } from '@angular/platform-browser'; 2import { BrowserModule } from '@angular/platform-browser';
3import { removeNgStyles, createNewHosts } from '@angularclass/hmr'; 3import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
4 4
5import { MetaModule, MetaConfig } from 'ng2-meta'; 5import { MetaModule, MetaConfig } from 'ng2-meta/src';
6import 'bootstrap-loader';
6 7
7import { ENV_PROVIDERS } from './environment'; 8import { ENV_PROVIDERS } from './environment';
8import { AppRoutingModule } from './app-routing.module'; 9import { AppRoutingModule } from './app-routing.module';
diff --git a/client/src/app/app.service.ts b/client/src/app/app.service.ts
index 033c21900..9b582e472 100644
--- a/client/src/app/app.service.ts
+++ b/client/src/app/app.service.ts
@@ -1,35 +1,35 @@
1
2import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
3 2
3export type InternalStateType = {
4 [key: string]: any
5};
6
4@Injectable() 7@Injectable()
5export class AppState { 8export class AppState {
6 _state = { };
7 9
8 constructor() { ; } 10 public _state: InternalStateType = { };
9 11
10 // already return a clone of the current state 12 // already return a clone of the current state
11 get state() { 13 public get state() {
12 return this._state = this._clone(this._state); 14 return this._state = this._clone(this._state);
13 } 15 }
14 // never allow mutation 16 // never allow mutation
15 set state(value) { 17 public set state(value) {
16 throw new Error('do not mutate the `.state` directly'); 18 throw new Error('do not mutate the `.state` directly');
17 } 19 }
18 20
19 21 public get(prop?: any) {
20 get(prop?: any) {
21 // use our state getter for the clone 22 // use our state getter for the clone
22 const state = this.state; 23 const state = this.state;
23 return state.hasOwnProperty(prop) ? state[prop] : state; 24 return state.hasOwnProperty(prop) ? state[prop] : state;
24 } 25 }
25 26
26 set(prop: string, value: any) { 27 public set(prop: string, value: any) {
27 // internally mutate our state 28 // internally mutate our state
28 return this._state[prop] = value; 29 return this._state[prop] = value;
29 } 30 }
30 31
31 32 private _clone(object: InternalStateType) {
32 _clone(object) {
33 // simple object clone 33 // simple object clone
34 return JSON.parse(JSON.stringify( object )); 34 return JSON.parse(JSON.stringify( object ));
35 } 35 }
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index 1f0e322a9..bc276ed99 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -3,6 +3,8 @@ import { Headers, Http, Response, URLSearchParams } from '@angular/http';
3import { Router } from '@angular/router'; 3import { Router } from '@angular/router';
4import { Observable } from 'rxjs/Observable'; 4import { Observable } from 'rxjs/Observable';
5import { Subject } from 'rxjs/Subject'; 5import { Subject } from 'rxjs/Subject';
6import 'rxjs/add/operator/map';
7import 'rxjs/add/operator/mergeMap';
6 8
7// Do not use the barrel (dependency loop) 9// Do not use the barrel (dependency loop)
8import { AuthStatus } from '../../shared/auth/auth-status.model'; 10import { AuthStatus } from '../../shared/auth/auth-status.model';
diff --git a/client/src/app/environment.ts b/client/src/app/environment.ts
index 8bba89c4e..929e09490 100644
--- a/client/src/app/environment.ts
+++ b/client/src/app/environment.ts
@@ -4,19 +4,24 @@
4import { enableDebugTools, disableDebugTools } from '@angular/platform-browser'; 4import { enableDebugTools, disableDebugTools } from '@angular/platform-browser';
5import { enableProdMode, ApplicationRef } from '@angular/core'; 5import { enableProdMode, ApplicationRef } from '@angular/core';
6// Environment Providers 6// Environment Providers
7let PROVIDERS = [ 7let PROVIDERS: any[] = [
8 // common env directives 8 // common env directives
9]; 9];
10 10
11// Angular debug tools in the dev console 11// Angular debug tools in the dev console
12// https://github.com/angular/angular/blob/86405345b781a9dc2438c0fbe3e9409245647019/TOOLS_JS.md 12// https://github.com/angular/angular/blob/86405345b781a9dc2438c0fbe3e9409245647019/TOOLS_JS.md
13let _decorateModuleRef = function identity(value) { return value; }; 13let _decorateModuleRef = function identity<T>(value: T): T { return value; };
14 14
15if ('production' === ENV) { 15if ('production' === ENV) {
16 // Production
17 disableDebugTools();
18 enableProdMode(); 16 enableProdMode();
19 17
18 // Production
19 _decorateModuleRef = (modRef: any) => {
20 disableDebugTools();
21
22 return modRef;
23 };
24
20 PROVIDERS = [ 25 PROVIDERS = [
21 ...PROVIDERS, 26 ...PROVIDERS,
22 // custom providers in production 27 // custom providers in production
diff --git a/client/src/app/shared/auth/auth-http.service.ts b/client/src/app/shared/auth/auth-http.service.ts
index 602726570..c4114aa02 100644
--- a/client/src/app/shared/auth/auth-http.service.ts
+++ b/client/src/app/shared/auth/auth-http.service.ts
@@ -80,12 +80,14 @@ export class AuthHttp extends Http {
80 } 80 }
81} 81}
82 82
83export function useFactory(backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) {
84 return new AuthHttp(backend, defaultOptions, authService);
85}
86
83export const AUTH_HTTP_PROVIDERS = [ 87export const AUTH_HTTP_PROVIDERS = [
84 { 88 {
85 provide: AuthHttp, 89 provide: AuthHttp,
86 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => { 90 useFactory,
87 return new AuthHttp(backend, defaultOptions, authService);
88 },
89 deps: [ XHRBackend, RequestOptions, AuthService ] 91 deps: [ XHRBackend, RequestOptions, AuthService ]
90 }, 92 },
91]; 93];
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index f173ef06b..9d79b2f5e 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -1,6 +1,8 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Http } from '@angular/http'; 2import { Http } from '@angular/http';
3import { Observable } from 'rxjs/Observable'; 3import { Observable } from 'rxjs/Observable';
4import 'rxjs/add/operator/catch';
5import 'rxjs/add/operator/map';
4 6
5import { Search } from '../../shared'; 7import { Search } from '../../shared';
6import { SortField } from './sort-field.type'; 8import { SortField } from './sort-field.type';
diff --git a/client/src/app/videos/video-watch/video-magnet.component.html b/client/src/app/videos/video-watch/video-magnet.component.html
index 9108c7258..3fa82f1be 100644
--- a/client/src/app/videos/video-watch/video-magnet.component.html
+++ b/client/src/app/videos/video-watch/video-magnet.component.html
@@ -3,7 +3,7 @@
3 <div class="modal-content modal-lg"> 3 <div class="modal-content modal-lg">
4 4
5 <div class="modal-header"> 5 <div class="modal-header">
6 <button type="button" class="close" aria-label="Close" (click)="hideModal()"> 6 <button type="button" class="close" aria-label="Close" (click)="hide()">
7 <span aria-hidden="true">&times;</span> 7 <span aria-hidden="true">&times;</span>
8 </button> 8 </button>
9 <h4 class="modal-title">Magnet Uri</h4> 9 <h4 class="modal-title">Magnet Uri</h4>
diff --git a/client/src/app/videos/video-watch/video-share.component.html b/client/src/app/videos/video-watch/video-share.component.html
index 1c2fac1d7..88f59c063 100644
--- a/client/src/app/videos/video-watch/video-share.component.html
+++ b/client/src/app/videos/video-watch/video-share.component.html
@@ -3,7 +3,7 @@
3 <div class="modal-content"> 3 <div class="modal-content">
4 4
5 <div class="modal-header"> 5 <div class="modal-header">
6 <button type="button" class="close" aria-label="Close" (click)="hideModal()"> 6 <button type="button" class="close" aria-label="Close" (click)="hide()">
7 <span aria-hidden="true">&times;</span> 7 <span aria-hidden="true">&times;</span>
8 </button> 8 </button>
9 <h4 class="modal-title">Share</h4> 9 <h4 class="modal-title">Share</h4>
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts
index afc6fe01c..14aae9895 100644
--- a/client/src/app/videos/video-watch/video-watch.component.ts
+++ b/client/src/app/videos/video-watch/video-watch.component.ts
@@ -1,7 +1,8 @@
1import { setInterval, setTimeout } from 'timers'
1import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'; 2import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
2import { ActivatedRoute } from '@angular/router'; 3import { ActivatedRoute } from '@angular/router';
3 4
4import { MetaService } from 'ng2-meta'; 5import { MetaService } from 'ng2-meta/src';
5import * as videojs from 'video.js'; 6import * as videojs from 'video.js';
6 7
7import { VideoMagnetComponent } from './video-magnet.component'; 8import { VideoMagnetComponent } from './video-magnet.component';
diff --git a/client/src/custom-typings.d.ts b/client/src/custom-typings.d.ts
index 95787181f..7cb57b62b 100644
--- a/client/src/custom-typings.d.ts
+++ b/client/src/custom-typings.d.ts
@@ -46,6 +46,16 @@ import * as _ from 'lodash'
46// support NodeJS modules without type definitions 46// support NodeJS modules without type definitions
47declare module '*'; 47declare module '*';
48 48
49/*
50// for legacy tslint etc to understand rename 'modern-lru' with your package
51// then comment out `declare module '*';`. For each new module copy/paste
52// this method of creating an `any` module type definition
53declare module 'modern-lru' {
54 let x: any;
55 export = x;
56}
57*/
58
49// Extra variables that live on Global that will be replaced by webpack DefinePlugin 59// Extra variables that live on Global that will be replaced by webpack DefinePlugin
50declare var ENV: string; 60declare var ENV: string;
51declare var HMR: boolean; 61declare var HMR: boolean;
@@ -56,8 +66,8 @@ interface SystemJS {
56} 66}
57 67
58interface GlobalEnvironment { 68interface GlobalEnvironment {
59 ENV; 69 ENV: string;
60 HMR; 70 HMR: boolean;
61 SystemJS: SystemJS; 71 SystemJS: SystemJS;
62 System: SystemJS; 72 System: SystemJS;
63} 73}
@@ -76,7 +86,6 @@ type AsyncRoutes = {
76 FactoryPromise 86 FactoryPromise
77}; 87};
78 88
79
80type IdleCallbacks = Es6PromiseLoader | 89type IdleCallbacks = Es6PromiseLoader |
81 Function | 90 Function |
82 FactoryEs6PromiseLoader | 91 FactoryEs6PromiseLoader |
@@ -98,7 +107,6 @@ interface WebpackModule {
98 }; 107 };
99} 108}
100 109
101
102interface WebpackRequire { 110interface WebpackRequire {
103 (id: string): any; 111 (id: string): any;
104 (paths: string[], callback: (...modules: any[]) => void): void; 112 (paths: string[], callback: (...modules: any[]) => void): void;
@@ -114,7 +122,6 @@ interface ErrorStackTraceLimit {
114 stackTraceLimit: number; 122 stackTraceLimit: number;
115} 123}
116 124
117
118// Extend typings 125// Extend typings
119interface NodeRequire extends WebpackRequire {} 126interface NodeRequire extends WebpackRequire {}
120interface ErrorConstructor extends ErrorStackTraceLimit {} 127interface ErrorConstructor extends ErrorStackTraceLimit {}
diff --git a/client/src/main.browser.aot.ts b/client/src/main.browser.aot.ts
new file mode 100644
index 000000000..29ecf7349
--- /dev/null
+++ b/client/src/main.browser.aot.ts
@@ -0,0 +1,23 @@
1import { platformBrowser } from '@angular/platform-browser';
2import { decorateModuleRef } from './app/environment';
3/*
4 * App Module
5 * our top level module that holds all of our components
6 */
7import { AppModuleNgFactory } from '../compiled/src/app/app.module.ngfactory';
8
9/*
10 * Bootstrap our Angular app with a top level NgModule
11 */
12export function main(): Promise<any> {
13 return platformBrowser()
14 .bootstrapModuleFactory(AppModuleNgFactory)
15 .then(decorateModuleRef)
16 .catch((err) => console.error(err));
17}
18
19export function bootstrapDomReady() {
20 document.addEventListener('DOMContentLoaded', main);
21}
22
23bootstrapDomReady();
diff --git a/client/src/main.ts b/client/src/main.browser.ts
index 70bf48537..70bf48537 100644
--- a/client/src/main.ts
+++ b/client/src/main.browser.ts
diff --git a/client/src/polyfills.ts b/client/src/polyfills.browser.ts
index 65e211459..65e211459 100644
--- a/client/src/polyfills.ts
+++ b/client/src/polyfills.browser.ts
diff --git a/client/src/sass/application.scss b/client/src/sass/application.scss
index cdb486557..30588067f 100644
--- a/client/src/sass/application.scss
+++ b/client/src/sass/application.scss
@@ -1,4 +1,4 @@
1@import '../video.js/dist/video-js.css'; 1@import '../../node_modules/video.js/dist/video-js.css';
2 2
3body { 3body {
4 padding: 20px; 4 padding: 20px;
diff --git a/client/src/vendor.ts b/client/src/vendor.ts
deleted file mode 100644
index 436c58f48..000000000
--- a/client/src/vendor.ts
+++ /dev/null
@@ -1,35 +0,0 @@
1// For vendors for example jQuery, Lodash, angular2-jwt just import them here unless you plan on
2// chunking vendors files for async loading. You would need to import the async loaded vendors
3// at the entry point of the async loaded file. Also see custom-typings.d.ts as you also need to
4// run `typings install x` where `x` is your module
5
6// Angular 2
7import '@angular/platform-browser';
8import '@angular/platform-browser-dynamic';
9import '@angular/core';
10import '@angular/common';
11import '@angular/forms';
12import '@angular/http';
13import '@angular/router';
14
15import '@angularclass/hmr';
16
17// RxJS
18import 'rxjs/Observable';
19import 'rxjs/Subject';
20import 'rxjs/ReplaySubject';
21import 'rxjs/add/operator/catch';
22import 'rxjs/add/operator/mergeMap';
23import 'rxjs/add/operator/map';
24import 'rxjs/add/observable/throw';
25
26import 'bootstrap-loader';
27
28import 'angular-pipes/src/math/bytes.pipe';
29import 'ng2-file-upload';
30import 'video.js';
31import 'ng2-meta';
32import 'ng2-bootstrap/pagination';
33import 'ng2-bootstrap/dropdown';
34import 'ng2-bootstrap/progressbar';
35import 'ng2-bootstrap/modal';