diff --git a/.travis.yml b/.travis.yml index 894a9f2..cd9794d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ install: script: - npm test - npm run build:prod - - npm run docs +# - npm run docs # excluded until support for ts 2.0 for typedoc is released after_success: - chmod -R a+x scripts diff --git a/README.md b/README.md index 9e5affb..7b35bfa 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,10 @@ This is an Angular 2 [fullPage.js](https://github.com/alvarotrigo/fullPage.js) p [![devDependency Status](https://david-dm.org/meiblorn/ng2-fullpage/dev-status.svg)](https://david-dm.org/meiblorn/ng2-fullpage#info=devDependencies) [![Test Coverage](https://codeclimate.com/github/meiblorn/ng2-fullpage/badges/coverage.svg)](https://codeclimate.com/github/meiblorn/ng2-fullpage/coverage) [![Code Climate](https://codeclimate.com/github/meiblorn/ng2-fullpage/badges/gpa.svg)](https://codeclimate.com/github/meiblorn/ng2-fullpage) -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/meiblorn/ng2-fullpage/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + +----------------------------------- +NEW RELEASE 2.0.0: ANGULAR 2 FINAL +----------------------------------- ## Demo @@ -61,12 +64,12 @@ export class AppComponent { // no additional config is required } ``` -Update webpack vendors entry file (src/vendor.ts) with 'jquery' import: +Update webpack vendors entry file (src/vendor.browser.ts) with 'jquery' import: ```typescript /** * -* File: vendor.ts +* File: vendor.browser.ts * * Just add 'jquery' module import statement. * diff --git a/components/polyfills.browser.ts b/components/polyfills.browser.ts new file mode 100644 index 0000000..d220b7b --- /dev/null +++ b/components/polyfills.browser.ts @@ -0,0 +1,26 @@ +/** + * @author Meiblorn (Vadim Fedorenko) on 12/05/16. + */ + +import 'core-js/es6/symbol'; +import 'core-js/es6/object'; +import 'core-js/es6/function'; +import 'core-js/es6/parse-int'; +import 'core-js/es6/parse-float'; +import 'core-js/es6/number'; +import 'core-js/es6/math'; +import 'core-js/es6/string'; +import 'core-js/es6/date'; +import 'core-js/es6/array'; +import 'core-js/es6/regexp'; +import 'core-js/es6/map'; +import 'core-js/es6/set'; +import 'core-js/es6/weak-map'; +import 'core-js/es6/weak-set'; +import 'core-js/es6/typed'; +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; + +import 'zone.js/dist/zone'; + +import 'ts-helpers'; diff --git a/components/polyfills.ts b/components/polyfills.ts deleted file mode 100644 index 1dc7736..0000000 --- a/components/polyfills.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @author Meiblorn (Vadim Fedorenko) on 12/05/16. - */ - -import 'core-js/es6'; -import 'core-js/es7/reflect'; -import 'zone.js/dist/zone'; -import 'ts-helpers'; diff --git a/components/typings/reflect.d.ts b/components/typings/reflect.d.ts deleted file mode 100644 index b8182e2..0000000 --- a/components/typings/reflect.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -declare namespace Reflect { - function decorate(decorators: ClassDecorator[], target: Function): Function; - function decorate( - decorators: (PropertyDecorator | MethodDecorator)[], - target: Object, - targetKey: string | symbol, - descriptor?: PropertyDescriptor): PropertyDescriptor; - - function metadata(metadataKey: any, metadataValue: any): { - (target: Function): void; - (target: Object, propertyKey: string | symbol): void; - }; - function defineMetadata(metadataKey: any, metadataValue: any, target: Object): void; - function defineMetadata( - metadataKey: any, - metadataValue: any, - target: Object, - targetKey: string | symbol): void; - function hasMetadata(metadataKey: any, target: Object): boolean; - function hasMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean; - function hasOwnMetadata(metadataKey: any, target: Object): boolean; - function hasOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean; - function getMetadata(metadataKey: any, target: Object): any; - function getMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any; - function getOwnMetadata(metadataKey: any, target: Object): any; - function getOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any; - function getMetadataKeys(target: Object): any[]; - function getMetadataKeys(target: Object, targetKey: string | symbol): any[]; - function getOwnMetadataKeys(target: Object): any[]; - function getOwnMetadataKeys(target: Object, targetKey: string | symbol): any[]; - function deleteMetadata(metadataKey: any, target: Object): boolean; - function deleteMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean; -} diff --git a/components/typings/webpack.d.ts b/components/typings/webpack.d.ts deleted file mode 100644 index 2e113ec..0000000 --- a/components/typings/webpack.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -interface WebpackRequire { - context(file: string, flag?: boolean, exp?: RegExp): any; -} - -interface ErrorStackTraceLimit { - stackTraceLimit: number; -} - -// Extend typings -interface NodeRequire extends WebpackRequire {} -interface ErrorConstructor extends ErrorStackTraceLimit {} diff --git a/components/typings/zone.d.ts b/components/typings/zone.d.ts deleted file mode 100644 index c45bff8..0000000 --- a/components/typings/zone.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// We need this here since there is a problem with Zone.js typings -interface Thenable { - then( - onFulfilled?: (value: T) => U | Thenable, - onRejected?: (error: any) => U | Thenable): Thenable; - then( - onFulfilled?: (value: T) => U | Thenable, - onRejected?: (error: any) => void): Thenable; - catch(onRejected?: (error: any) => U | Thenable): Thenable; -} diff --git a/components/vendor.ts b/components/vendor.browser.ts similarity index 100% rename from components/vendor.ts rename to components/vendor.browser.ts diff --git a/config/build.config.js b/config/build.config.js index 2051dff..1fa7af8 100644 --- a/config/build.config.js +++ b/config/build.config.js @@ -6,9 +6,7 @@ export default { common: { sources: { directory: '.', - extensions: [ - '', '.ts', '.js' - ], + extensions: ['', '.ts', '.js', '.json'], entries: { directories: { src: './components', @@ -16,9 +14,9 @@ export default { }, list: { 'ng2-fullpage': './index.ts', - 'polyfills': '<%= common.sources.entries.directories.src %>/polyfills.ts', - 'vendor': '<%= common.sources.entries.directories.src %>/vendor.ts', - 'demo': '<%= common.sources.entries.directories.demo %>/app/main.ts' + 'polyfills': '<%= common.sources.entries.directories.src %>/polyfills.browser.ts', + 'vendor': '<%= common.sources.entries.directories.src %>/vendor.browser.ts', + 'demo': '<%= common.sources.entries.directories.demo %>/app/main.browser.ts' }, chunks: { commons: { diff --git a/config/helpers/utils.js b/config/helpers/utils.js index 93a4893..7ef46d7 100644 --- a/config/helpers/utils.js +++ b/config/helpers/utils.js @@ -2,6 +2,7 @@ * @author Meiblorn (Vadim Fedorenko) on 12/05/16. */ +import fs from 'fs'; import path from 'path'; import traverse from 'traverse'; import loDashTemplate from 'lodash.template'; @@ -50,18 +51,21 @@ export default class Utils { return childProcess.exec(cmd); } - static packageSort(packages) { - var len = packages.length - 1; - return function sort(a, b) { - if (a.names[0] === packages[0]) { - return -1; - } + static getFiles(dir, subdirFiles) { + var result = subdirFiles || []; + + var files = fs.readdirSync(dir); - if (a.names[0] === packages[len]) { - return 1; + for (var file in files) { + var name = dir + '/' + files[file]; + if (fs.statSync(name).isDirectory()) { + this.getFiles(name, result); + } else { + result.push(name); } - - return 0; } + + return result; } + } diff --git a/config/karma/karma.conf.babel.js b/config/karma/karma.conf.babel.js index 1ad6154..48ff87c 100644 --- a/config/karma/karma.conf.babel.js +++ b/config/karma/karma.conf.babel.js @@ -5,7 +5,8 @@ import config from './../helpers/config'; const SPEC_BUNDLE_PATH = config('test.spec.bundle.filename'); export default karma => { - karma.set({ + + const configuration = { basePath: '', frameworks: ['jasmine'], exclude: [], @@ -15,7 +16,7 @@ export default karma => { result[SPEC_BUNDLE_PATH] = ['webpack', 'sourcemap']; return result; })(), - webpack: WebpackTest, + webpack: WebpackTest({env: 'test'}), coverageReporter: { dir: config('test.reports.coverage.directory'), reporters: [ @@ -32,6 +33,14 @@ export default karma => { autoWatch: false, reporters: ['progress', 'mocha', 'coverage'], browsers: ['PhantomJS'], - singleRun: true - }); + singleRun: true, + customLaunchers: { + ChromeTravisCi: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + }; + + karma.set(configuration); }; diff --git a/config/webpack/webpack.common.babel.js b/config/webpack/webpack.common.babel.js index 415d3b8..e0d7a36 100644 --- a/config/webpack/webpack.common.babel.js +++ b/config/webpack/webpack.common.babel.js @@ -3,7 +3,6 @@ */ import CleanWebpackPlugin from 'clean-webpack-plugin'; -import OccurenceOrderPlugin from 'webpack/lib/optimize/OccurenceOrderPlugin'; import CommonsChunkPlugin from 'webpack/lib/optimize/CommonsChunkPlugin'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import * as AwesomeTypescriptLoader from 'awesome-typescript-loader'; @@ -11,65 +10,85 @@ import * as AwesomeTypescriptLoader from 'awesome-typescript-loader'; import config from './../helpers/config'; import utils from './../helpers/utils'; -export default { - entry: config('common.sources.entries.list'), - resolve: { - extensions: config('common.sources.extensions'), - root: utils.root(config('common.sources.directory')), - modulesDirectories: config('common.sources.modules.directories') - }, - module: { - preLoaders: [ - { - test: /\.js$/, - loader: 'source-map-loader', - exclude: [ - // these packages have problems with their sourcemaps - utils.root('node_modules/rxjs'), - utils.root('node_modules/@angular') - ] - } - ], - loaders: [ - { - test: /\.ts$/, loader: 'awesome-typescript-loader', - exclude: [/\.(spec|e2e)\.ts$/], - query: { - declaration: false, - sourceMap: false +export default options => { + + return { + entry: config('common.sources.entries.list'), + resolve: { + extensions: config('common.sources.extensions'), + root: utils.root(config('common.sources.directory')), + modulesDirectories: config('common.sources.modules.directories') + }, + module: { + preLoaders: [ + { + test: /\.ts$/, + loader: 'string-replace-loader', + query: { + search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)', + replace: '$1.import($3).then(mod => (mod.__esModule && mod.default) ? mod.default : mod)', + flags: 'g' + }, + include: [utils.root()] + }, + ], + loaders: [ + { + test: /\.ts$/, + loaders: [ + 'awesome-typescript-loader' + ], + exclude: [/\.(spec|e2e)\.ts$/], + query: { + declaration: false, + sourceMap: false + } + }, + {test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/}, + {test: /\.html$/, loader: 'raw-loader'}, + {test: /\.css$/, loaders: ['to-string-loader', 'css-loader']}, + {test: /\.scss$/, loaders: ['raw-loader', 'sass-loader']}, + {test: /\.json$/, loader: 'json-loader'}, + {test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/, loader: 'file-loader'} + ], + postLoaders: [ + { + test: /\.js$/, + loader: 'string-replace-loader', + query: { + search: 'var sourceMappingUrl = extractSourceMappingUrl\\(cssText\\);', + replace: 'var sourceMappingUrl = "";', + flags: 'g' + } } - }, - {test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/}, - {test: /\.html$/, loader: 'html-loader'}, - {test: /\.css$/, loaders: ['raw-loader']}, - {test: /\.scss$/, loaders: ['raw-loader', 'sass-loader']}, - {test: /\.json$/, loader: 'json-loader'}, - {test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/, loader: 'file-loader'} - ] - }, - plugins: [ - new CleanWebpackPlugin([config('common.build.directory')], {root: utils.root(), dry: false, verbose: true}), - new AwesomeTypescriptLoader.ForkCheckerPlugin(), - new OccurenceOrderPlugin(true), - new CommonsChunkPlugin({ - name: config('common.sources.entries.chunks.commons.list'), - minChunks: Infinity - }), - new HtmlWebpackPlugin({ - template: utils.root(config('common.build.html.src')), - filename: utils.relative( - utils.root(config('common.build.scripts.directory')), - utils.root(config('common.build.html.dist')) - ), - excludeChunks: ['ng2-fullpage'], - chunksSortMode: utils.packageSort(['polyfills', 'vendor', 'demo']) - }) - ], - node: { - global: 'window', - crypto: 'empty', - module: false, - clearImmediate: false, - setImmediate: false - } + ] + }, + plugins: [ + new CleanWebpackPlugin([config('common.build.directory')], { + root: utils.root(), dry: false, verbose: true + }), + new AwesomeTypescriptLoader.ForkCheckerPlugin(), + new CommonsChunkPlugin({ + name: config('common.sources.entries.chunks.commons.list'), + minChunks: Infinity + }), + new HtmlWebpackPlugin({ + template: utils.root(config('common.build.html.src')), + filename: utils.relative( + utils.root(config('common.build.scripts.directory')), + utils.root(config('common.build.html.dist')) + ), + excludeChunks: ['ng2-fullpage'] + }) + ], + node: { + global: 'window', + crypto: 'empty', + process: true, + module: false, + clearImmediate: false, + setImmediate: false + } + }; + }; diff --git a/config/webpack/webpack.dev.babel.js b/config/webpack/webpack.dev.babel.js index 2ce7544..5c22340 100644 --- a/config/webpack/webpack.dev.babel.js +++ b/config/webpack/webpack.dev.babel.js @@ -6,27 +6,36 @@ import WebpackMerge from 'webpack-merge'; import CommonWebpackConfig from './webpack.common.babel'; +const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin'); + import config from './../helpers/config'; import utils from './../helpers/utils'; -export default WebpackMerge(CommonWebpackConfig, { - debug: true, - devtool: 'cheap-module-source-map', - output: { - path: utils.root(config('common.build.scripts.directory')), - filename: config('dev.build.bundles.filename'), - sourceMapFilename: config('dev.build.bundles.sourceMap.filename'), - chunkFilename: config('dev.build.bundles.chunk.filename') - }, - devServer: { - host: 'localhost', - port: 3000, - historyApiFallback: true, - watchOptions: { - aggregateTimeout: 300, - poll: 1000 +export default options => { + + return WebpackMerge(CommonWebpackConfig({env: 'development'}), { + debug: true, + devtool: 'cheap-module-source-map', + output: { + path: utils.root(config('common.build.scripts.directory')), + filename: config('dev.build.bundles.filename'), + sourceMapFilename: config('dev.build.bundles.sourceMap.filename'), + chunkFilename: config('dev.build.bundles.chunk.filename'), }, - outputPath: utils.root(config('common.build.directory')) - }, - node: WebpackMerge(CommonWebpackConfig.node, {process: true}) -}); + plugins: [ + new NamedModulesPlugin(), + ], + devServer: { + host: 'localhost', + port: 3000, + historyApiFallback: true, + watchOptions: { + aggregateTimeout: 300, + poll: 1000 + }, + outputPath: utils.root(config('common.build.directory')) + }, + node: {process: true} + }); + +}; diff --git a/config/webpack/webpack.prod.babel.js b/config/webpack/webpack.prod.babel.js index 66b1954..c3e53c5 100644 --- a/config/webpack/webpack.prod.babel.js +++ b/config/webpack/webpack.prod.babel.js @@ -13,36 +13,40 @@ import CommonWebpackConfig from './webpack.common.babel'; import config from './../helpers/config'; import utils from './../helpers/utils'; -export default WebpackMerge(CommonWebpackConfig, { - debug: false, - devtool: 'source-map', - output: { - path: utils.root(config('common.build.scripts.directory')), - filename: config('prod.build.bundles.filename'), - sourceMapFilename: config('prod.build.bundles.sourceMap.filename'), - chunkFilename: config('prod.build.bundles.chunk.filename') - }, - plugins: [ - new WebpackMd5Hash(), - new UnminifiedWebpackPlugin(), - new UglifyJsPlugin({ - beautify: false, - mangle: {screw_ie8 : true, keep_fnames: true}, - compress: {screw_ie8: true}, - comments: false - }), - new CompressionPlugin({regExp: /\.css$|\.html$|\.js$|\.map$/, threshold: 2 * 1024}) - ], - htmlLoader: { - minimize: true, - removeAttributeQuotes: false, - caseSensitive: true, - customAttrSurround: [ - [/#/, /(?:)/], - [/\*/, /(?:)/], - [/\[?\(?/, /(?:)/] +export default options => { + + return WebpackMerge(CommonWebpackConfig({env: 'production'}), { + debug: false, + devtool: 'source-map', + output: { + path: utils.root(config('common.build.scripts.directory')), + filename: config('prod.build.bundles.filename'), + sourceMapFilename: config('prod.build.bundles.sourceMap.filename'), + chunkFilename: config('prod.build.bundles.chunk.filename') + }, + plugins: [ + new WebpackMd5Hash(), + new UnminifiedWebpackPlugin(), + new UglifyJsPlugin({ + beautify: false, + mangle: {screw_ie8 : true, keep_fnames: true}, + compress: {screw_ie8: true}, + comments: false + }), + new CompressionPlugin({regExp: /\.css$|\.html$|\.js$|\.map$/, threshold: 2 * 1024}) ], - customAttrAssign: [/\)?\]?=/] - }, - node: WebpackMerge(CommonWebpackConfig.node, {process: false}) -}); + htmlLoader: { + minimize: true, + removeAttributeQuotes: false, + caseSensitive: true, + customAttrSurround: [ + [/#/, /(?:)/], + [/\*/, /(?:)/], + [/\[?\(?/, /(?:)/] + ], + customAttrAssign: [/\)?\]?=/] + }, + node: {process: false} + }); + +}; diff --git a/config/webpack/webpack.test.babel.js b/config/webpack/webpack.test.babel.js index e74c6cf..07f4d59 100644 --- a/config/webpack/webpack.test.babel.js +++ b/config/webpack/webpack.test.babel.js @@ -9,48 +9,58 @@ import CommonWebpackConfig from './webpack.common.babel'; import config from './../helpers/config'; import utils from './../helpers/utils'; -export default { - metadata: {}, - debug: false, - devtool: 'inline-source-map', - resolve: { - extensions: config('common.sources.extensions'), - root: utils.root(config('common.sources.directory')) - }, - module: { - preLoaders: [ - {test: /\.ts$/, loader: 'tslint-loader', exclude: /node_modules/}, - {test: /\.js$/, loader: 'source-map-loader'} - ], - loaders: [ - { - test: /\.ts$/, loader: 'awesome-typescript-loader', - query: { - compilerOptions: { - // Remove TypeScript helpers to be injected - // below by DefinePlugin - removeComments: true - } - }, - exclude: [/\.e2e\.ts$/] - }, - {test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/}, - {test: /\.html$/, loader: 'raw-loader'}, - {test: /\.css$/, loader: 'raw-loader'}, - {test: /\.scss$/, loaders: ['raw-loader', 'sass-loader']}, - {test: /\.json$/, loader: 'json-loader'}, - {test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/, loader: 'file-loader'} - ], - postLoaders: [ - { - test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader', - include: utils.root(config('common.sources.directory')), - exclude: [ - /\.(e2e|spec)\.ts$/, - /node_modules/ - ] +export default options => { + + return { + metadata: {}, + debug: false, + devtool: 'inline-source-map', + resolve: { + extensions: config('common.sources.extensions'), + root: utils.root(config('common.sources.directory')), + alias: { + "ng2-fullpage": utils.root('ng2-fullpage') } - ] - }, - node: WebpackMerge(CommonWebpackConfig.node, {process: false}) + }, + module: { + preLoaders: [ + {test: /\.ts$/, loader: 'tslint-loader', exclude: /node_modules/}, + {test: /\.js$/, loader: 'source-map-loader', exclude: [ + utils.root('node_modules/rxjs'), + utils.root('node_modules/@angular') + ]} + ], + loaders: [ + { + test: /\.ts$/, loader: 'awesome-typescript-loader', + query: { + compilerOptions: { + // Remove TypeScript helpers to be injected + // below by DefinePlugin + removeComments: true + } + }, + exclude: [/\.e2e\.ts$/] + }, + {test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/}, + {test: /\.html$/, loader: 'raw-loader'}, + {test: /\.css$/, loaders: ['to-string-loader', 'css-loader']}, + {test: /\.scss$/, loaders: ['raw-loader', 'sass-loader']}, + {test: /\.json$/, loader: 'json-loader'}, + {test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/, loader: 'file-loader'} + ], + postLoaders: [ + { + test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader', + include: utils.root(config('common.sources.directory')), + exclude: [ + /\.(e2e|spec)\.ts$/, + /node_modules/ + ] + } + ] + }, + node: WebpackMerge(CommonWebpackConfig.node, {process: false}) + }; + }; diff --git a/demo/app/app.component.html b/demo/app/app.component.html index b74bb05..3b960f7 100644 --- a/demo/app/app.component.html +++ b/demo/app/app.component.html @@ -19,69 +19,81 @@ [mnFullpageSlidesNavPosition]="bottom">
-

Angular 2 fullPage.js

-

Create Beautiful Fullscreen Scrolling Websites (now with Angular 2)!

- +
+

Angular 2 fullPage.js

+

Create Beautiful Fullscreen Scrolling Websites (now with Angular 2)!

+ +
-

Easy to install !

-
+
+

Easy to install !

+
                 {{templates.install}}
             
+
-

Easy to use !

-
+
+

Easy to use !

+
                 {{templates.usage}}
             
+
-
-

Many ways to configure!

-

Use keyboard arrows or navigation below to slide right

-
-
-

Configure it via attributes

-
+
+
+

Many ways to configure!

+

Use keyboard arrows or navigation below to slide right

+
+
+

Configure it via attributes

+
                     {{templates.slides.attributes}}
                 
+
-
-
-

Use configuration object instead

-
+
+

Use configuration object instead

+
                     {{templates.slides.classOptions}}
                 
+
-
-
-

Or MIX IT !

-
+
+

Or MIX IT !

+
                     {{templates.slides.mix}}
                 
+
-

Get full control on the page !

-
+
+

Get full control on the page !

+
                 {{templates.service}}
             
+
-

Start use it now!

-

- Return to GitHub - or start reading docs -

+
+

Start use it now!

+

+ Return to GitHub + or start reading docs +

+
diff --git a/demo/app/app.component.ts b/demo/app/app.component.ts index 44735b2..5ba2aad 100644 --- a/demo/app/app.component.ts +++ b/demo/app/app.component.ts @@ -2,23 +2,21 @@ * @author Meiblorn (Vadim Fedorenko) on 12/05/16. */ -import {Component, Input, Output, ViewEncapsulation, provide} from '@angular/core'; -import {MnFullpageDirective, MnFullpageOptions, MnFullpageService} from "../../components"; +import { Component, Input, Output, ViewEncapsulation } from '@angular/core'; +import { MnFullpageService, MnFullpageOptions } from "../../components"; @Component({ selector: 'app', - providers: [provide(MnFullpageService, {useClass: MnFullpageService})], - directives: [MnFullpageDirective], + encapsulation: ViewEncapsulation.None, styles: [ require('fullpage.js/jquery.fullPage.css'), require('./app.component.scss') ], - encapsulation: ViewEncapsulation.None, template: require('./app.component.html') }) export class AppComponent { - @Input() public options:MnFullpageOptions = new MnFullpageOptions({ + @Input() public options: MnFullpageOptions = new MnFullpageOptions({ controlArrows: false, scrollingSpeed: 1000, @@ -41,7 +39,7 @@ export class AppComponent { service: require('raw!./templates/service.tempalte.txt') }; - constructor(private fullpageService:MnFullpageService) { + constructor(private fullpageService: MnFullpageService) { } } diff --git a/demo/app/app.module.ts b/demo/app/app.module.ts new file mode 100644 index 0000000..9f14802 --- /dev/null +++ b/demo/app/app.module.ts @@ -0,0 +1,23 @@ +import { NgModule } from "@angular/core"; +import { BrowserModule } from "@angular/platform-browser"; + +import { AppComponent } from "./app.component"; +import { MnFullpageDirective, MnFullpageService } from "../../components"; + +@NgModule({ + bootstrap: [ AppComponent ], + declarations: [ + AppComponent, + + MnFullpageDirective + ], + imports: [ + BrowserModule, + ], + providers: [ + MnFullpageService + ] +}) +export class AppModule { + +} diff --git a/demo/app/index.ts b/demo/app/index.ts new file mode 100644 index 0000000..da53f6a --- /dev/null +++ b/demo/app/index.ts @@ -0,0 +1 @@ +export * from './app.module'; diff --git a/demo/app/main.browser.ts b/demo/app/main.browser.ts new file mode 100644 index 0000000..9922147 --- /dev/null +++ b/demo/app/main.browser.ts @@ -0,0 +1,17 @@ +/** + * @author Meiblorn (Vadim Fedorenko) on 12/05/16. + */ + +import { enableProdMode } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app.module'; + +enableProdMode(); + +document.addEventListener('DOMContentLoaded', () => { + platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch(err => console.error(err)); +}); + diff --git a/demo/app/main.ts b/demo/app/main.ts deleted file mode 100644 index d93d8aa..0000000 --- a/demo/app/main.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @author Meiblorn (Vadim Fedorenko) on 12/05/16. - */ - -import {enableProdMode} from '@angular/core'; -import {bootstrap} from '@angular/platform-browser-dynamic'; -import {AppComponent} from './app.component'; - -enableProdMode(); - -document.addEventListener('DOMContentLoaded', () => { - bootstrap(AppComponent, []).catch(err => console.error(err)); -}); - diff --git a/package.json b/package.json index edf5f6a..4c2c7a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ng2-fullpage", - "version": "1.6.0", + "version": "2.0.1", "author": "Meiblorn (Vadim Fedorenko) ", "description": "Angular 2 fullpage scrolling", "license": "MIT", @@ -23,71 +23,97 @@ }, "main": "ng2-fullpage.js", "dependencies": { - "@angular/common": "^2.0.0-rc.4", - "@angular/compiler": "^2.0.0-rc.4", - "@angular/core": "^2.0.0-rc.4", - "@angular/platform-browser": "^2.0.0-rc.4", - "@angular/platform-browser-dynamic": "^2.0.0-rc.4", - "jquery": "^3.0.0", - "fullpage.js": "^2.8.0" + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/core": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "@angular/platform-server": "2.0.0", + "jquery": "^3.1.0", + "fullpage.js": "^2.8.6" }, "devDependencies": { - "awesome-typescript-loader": "^1.0.0", - "babel-core": "^6.9.0", - "babel-loader": "^6.2.4", - "babel-preset-es2015": "^6.9.0", - "babel-register": "^6.9.0", + "@angular/forms": "^2.0.0", + "@angular/http": "2.0.0", + "@types/core-js": "^0.9.32", + "@types/hammerjs": "^2.0.32", + "@types/jasmine": "^2.2.33", + "@types/jquery": "^1.10.31", + "@types/node": "^6.0.38", + "@types/webpack": "^1.12.34", + "angular2-template-loader": "^0.5.0", + "awesome-typescript-loader": "^2.2.4", + "babel-core": "^6.14.0", + "babel-loader": "^6.2.5", + "babel-preset-es2015": "^6.14.0", + "babel-register": "^6.14.0", "changelog": "^1.0.7", - "clean-webpack-plugin": "^0.1.9", - "codeclimate-test-reporter": "^0.3.1", + "clean-webpack-plugin": "^0.1.10", + "codeclimate-test-reporter": "^0.3.3", + "codelyzer": "~0.0.28", "compression-webpack-plugin": "^0.3.1", - "concurrently": "^2.1.0", - "core-js": "^2.4.0", - "css-loader": "^0.23.1", - "es6-promise": "^3.2.1", - "es6-promise-loader": "^1.0.1", + "concurrently": "^2.2.0", + "copy-webpack-plugin": "^3.0.1", + "core-js": "^2.4.1", + "css-loader": "^0.25.0", + "es6-promise": "^3.3.1", + "es6-promise-loader": "^1.0.2", "es6-shim": "^0.35.1", "es7-reflect-metadata": "^1.6.0", "exports-loader": "^0.6.3", "expose-loader": "^0.7.1", + "file-loader": "^0.9.0", "getobject": "^0.1.0", - "html-loader": "^0.4.3", - "html-webpack-plugin": "^2.20.0", + "gh-pages": "^0.11.0", + "html-loader": "^0.4.4", + "html-webpack-plugin": "^2.22.0", "http-server": "^0.9.0", - "istanbul-instrumenter-loader": "^0.2.0", - "jasmine-core": "^2.4.1", - "karma": "^1.1.0", - "karma-chrome-launcher": "^1.0.1", - "karma-coverage": "^1.0.0", + "ie-shim": "^0.1.0", + "imports-loader": "^0.6.5", + "istanbul-instrumenter-loader": "^1.0.0", + "jasmine-core": "^2.5.2", + "json-loader": "^0.5.4", + "karma": "^1.3.0", + "karma-chrome-launcher": "^2.0.0 ", + "karma-coverage": "^1.1.1", "karma-jasmine": "^1.0.2", - "karma-mocha-reporter": "^2.0.3", - "karma-phantomjs-launcher": "^1.0.0", + "karma-mocha-reporter": "^2.2.0", + "karma-phantomjs-launcher": "^1.0.2", "karma-sourcemap-loader": "^0.3.7", "karma-spec-reporter": "0.0.26", - "karma-webpack": "^1.7.0", - "lodash.template": "^4.2.5", - "mocha": "^3.0.0", - "node-sass": "^3.7.0", - "npm-check-updates": "^2.6.5", - "phantomjs-prebuilt": "^2.1.7", - "raw-loader": "^0.5.1", - "rxjs": "5.0.0-beta.6", - "sass-loader": "^4.0.0", + "karma-webpack": "1.8.0", + "lodash.template": "^4.4.0", + "mocha": "^3.0.2", + "node-sass": "^3.10.0", + "npm-check-updates": "^2.8.0", + "parse5": "^2.2.1", + "phantomjs-prebuilt": "^2.1.12", + "protractor": "^4.0.8", + "raw-loader": "0.5.1", + "remap-istanbul": "^0.6.4", + "rimraf": "^2.5.4", + "rxjs": "5.0.0-beta.12", + "sass-loader": "^4.0.2", "source-map-loader": "^0.1.5", + "string-replace-loader": "github:gdi2290/string-replace-loader", "style-loader": "^0.13.1", + "to-string-loader": "^1.1.5", "traverse": "^0.6.6", - "ts-helpers": "^1.1.1", - "tslint": "^3.10.2", - "tslint-loader": "^2.1.4", - "typedoc": "^0.4.4", - "typescript": "^1.8.10", - "typings": "^1.0.4", - "unminified-webpack-plugin": "^1.0.0", - "webpack": "^1.13.1", - "webpack-dev-server": "^1.14.1", - "webpack-md5-hash": "0.0.5", - "webpack-merge": "^0.14.0", - "zone.js": "^0.6.12" + "ts-helpers": "1.1.1", + "ts-node": "^1.3.0", + "tslint": "3.15.1", + "tslint-loader": "^2.1.5", + "typedoc": "^0.4.5", + "typescript": "2.0.0", + "typings": "^1.3.3", + "unminified-webpack-plugin": "^1.1.0", + "url-loader": "^0.5.7", + "webpack": "^2.1.0-beta.21", + "webpack-dev-middleware": "^1.8.1", + "webpack-dev-server": "^2.1.0-beta.2", + "webpack-md5-hash": "^0.0.5", + "webpack-merge": "^0.14.1", + "zone.js": "~0.6.23" }, "keywords": [ "fullpage", @@ -106,12 +132,13 @@ "webpack": "webpack", "tslint": "tslint", "npm-check-updates": "npm-check-updates -a", - "ncu": "ncu -a", + "ncu": "ncu -u", + "webpack-dev-server": "webpack-dev-server", "build": "npm run build:dev", "build:dev": "webpack --config ./config/webpack/webpack.dev.babel.js --progress --profile --colors --display-error-details --display-cached && tsc", "build:prod": "webpack --config ./config/webpack/webpack.prod.babel.js --progress --profile --colors --display-error-details --display-cached --bail && tsc", "server": "npm run server:dev", - "server:dev": "webpack-dev-server --config config/webpack/webpack.dev.babel.js --inline --progress --profile --colors --watch --display-error-details --display-cached --content-base demo/", + "server:dev": "webpack-dev-server --config config/webpack/webpack.dev.babel.js --progress --profile --watch --content-base demo/", "server:prod": "npm run build:prod && http-server build --cors", "start": "npm run server:dev", "start:prod": "npm run server:prod", @@ -123,7 +150,6 @@ "tests": "npm run test", "test:watch": "npm run watch:test", "codeclimate": "codeclimate-test-reporter < build/reports/lcov-report/lcov.info", - "postinstall": "npm run typings -- install", "docs": "npm run typedoc -- --options typedoc.json --exclude '**/*.spec.ts' ./components/" } } diff --git a/test/spec.bundle.js b/test/spec.bundle.js index 08e3717..1c42533 100644 --- a/test/spec.bundle.js +++ b/test/spec.bundle.js @@ -2,25 +2,30 @@ * @author Meiblorn (Vadim Fedorenko) on 11/05/16. */ -import 'core-js'; -import 'ts-helpers'; +Error.stackTraceLimit = Infinity; -import 'zone.js/dist/zone'; -import 'zone.js/dist/long-stack-trace-zone'; -import 'zone.js/dist/jasmine-patch'; -import 'zone.js/dist/async-test'; +require('core-js/es6'); +require('core-js/es7/reflect'); -import 'rxjs/Rx'; +require('ts-helpers'); -import * as testing from '@angular/core/testing'; -import * as browser from '@angular/platform-browser-dynamic/testing'; +require('zone.js/dist/zone'); +require('zone.js/dist/long-stack-trace-zone'); +require('zone.js/dist/proxy'); // since zone.js 0.6.15 +require('zone.js/dist/sync-test'); +require('zone.js/dist/jasmine-patch'); // put here since zone.js 0.6.14 +require('zone.js/dist/async-test'); +require('zone.js/dist/fake-async-test'); -testing.setBaseTestProviders( - browser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, - browser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS -); +require('rxjs/Rx'); + +var testing = require('@angular/core/testing'); +var browser = require('@angular/platform-browser-dynamic/testing'); -Object.assign(global, testing); +testing.TestBed.initTestEnvironment( + browser.BrowserDynamicTestingModule, + browser.platformBrowserDynamicTesting() +); var testContext = require.context('./spec/', true, /\.spec\.ts/); diff --git a/test/spec/fullpage/fullpage.directive.spec.ts b/test/spec/fullpage/fullpage.directive.spec.ts index be6edaf..bb3457c 100644 --- a/test/spec/fullpage/fullpage.directive.spec.ts +++ b/test/spec/fullpage/fullpage.directive.spec.ts @@ -2,16 +2,19 @@ * @author Meiblorn (Vadim Fedorenko) on 15/05/16. */ -import {TestComponentBuilder, async, describe, inject, it} from '@angular/core/testing'; +import { + fakeAsync, + tick, + TestBed +} from '@angular/core/testing'; -import {Component, Input} from '@angular/core'; -import {MnFullpageDirective, MnFullpageOptions} from 'ng2-fullpage'; +import { Component, Input } from '@angular/core'; +import { MnFullpageDirective, MnFullpageOptions } from 'ng2-fullpage'; describe('mnFullpage directive spec', () => { - // Create a test component to test directives + @Component({ - template: '', - directives: [MnFullpageDirective] + template: '
Content
', }) class TestComponent { @@ -23,23 +26,27 @@ describe('mnFullpage directive spec', () => { } - function createComponentAndTest(tcb: TestComponentBuilder, expectations: Function) { - return tcb.overrideTemplate(TestComponent, '
Content
') - .createAsync(TestComponent).then((fixture: any) => { - fixture.detectChanges(); + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + MnFullpageDirective, + TestComponent + ] + }); + }); - expectations(fixture); - }); - } + it('compiled element should have fullpage-wrapper class, 100% height style', fakeAsync(() => { + TestBed.compileComponents().then(() => { - it('compiled element should have fullpage-wrapper class, 100% height style', - async(inject([TestComponentBuilder], - (tcb: TestComponentBuilder) => { - return createComponentAndTest(tcb, (fixture) => { - let compiled = fixture.debugElement.nativeElement.children[0]; + const fixture = TestBed.createComponent(TestComponent); + fixture.detectChanges(); + tick(); - expect(compiled.classList.contains('fullpage-wrapper')).toBe(true); - expect(compiled.style.height).toBe('100%'); - }); - }))); + let compiled = fixture.debugElement.nativeElement.children[ 0 ]; + + expect(compiled.classList.contains('fullpage-wrapper')).toBe(true); + expect(compiled.style.height).toBe('100%'); + + }); + })); }); diff --git a/tsconfig.json b/tsconfig.json index 7a3e971..7758cdb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,30 +6,37 @@ "declaration": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "strictNullChecks": false, "sourceMap": false, "listFiles": true, "removeComments": false, "noEmitHelpers": false, "outDir": "build", - "noLib": false + "noLib": false, + "baseUrl": ".", + "lib": [ + "dom", + "es6" + ], + "types": [ + "hammerjs", + "jasmine", + "node", + "webpack", + "jquery" + ] }, "exclude": [ - "demo", - "test", - "node_modules" - ], - "filesGlob": [ - "./components/fullpage/**/*.ts", - - "!./node_modules/**", - - "./components/typings", - "./typings/index.d.ts" + "node_modules", + "build", + "test", + "demo" ], "awesomeTypescriptLoaderOptions": { - "resolveGlobs": true, - "forkChecker": true + "forkChecker": true, + "useWebpackText": true }, "compileOnSave": false, "buildOnSave": false, diff --git a/tslint.json b/tslint.json index 5aa5965..d710e9f 100644 --- a/tslint.json +++ b/tslint.json @@ -1,4 +1,7 @@ { + "rulesDirectory": [ + "node_modules/codelyzer" + ], "rules": { "member-access": false, "member-ordering": [ @@ -51,9 +54,9 @@ "no-duplicate-variable": true, "no-empty": false, "no-eval": true, - "no-null-keyword": true, + "no-null-keyword": false, "no-shadowed-variable": true, - "no-string-literal": true, + "no-string-literal": false, "no-switch-case-fall-through": true, "no-unreachable": true, "no-unused-expression": true, @@ -85,7 +88,7 @@ "trailing-comma": [ true, { - "multiline": "never", + "multiline": false, "singleline": "never" } ], @@ -129,6 +132,7 @@ "check-operator", "check-separator", "check-type" - ] + ], + "import-destructuring-spacing": true } } diff --git a/typedoc.json b/typedoc.json index c44a411..ce83d45 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,15 +1,15 @@ { "mode": "modules", - "module": "commonjs", - "moduleResolution": "node", - "target": "ES5", - "theme": "node_modules/typedoc-default-themes/bin/default", + "theme": "minimal", "ignoreCompilerErrors": "true", "experimentalDecorators": "true", "emitDecoratorMetadata": "true", + "target": "ES5", + "moduleResolution": "node", "preserveConstEnums": "true", "stripInternal": "true", "suppressExcessPropertyErrors": "true", "suppressImplicitAnyIndexErrors": "true", + "module": "commonjs", "out": "build/docs" } diff --git a/typings.json b/typings.json deleted file mode 100644 index 1ab1558..0000000 --- a/typings.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160317120654", - "jasmine": "registry:dt/jasmine#2.2.0+20160505161446", - "jquery": "registry:dt/jquery#1.10.0+20160417213236", - "hammerjs": "registry:dt/hammerjs#2.0.4+20160417130828", - "node": "registry:dt/node#6.0.0+20160524002506", - "zone.js": "registry:dt/zone.js#0.0.0+20160316155526", - "source-map": "registry:dt/source-map#0.0.0+20160317120654", - "uglify-js": "registry:dt/uglify-js#2.6.1+20160316155526", - "webpack": "registry:dt/webpack#1.12.9+20160523035535" - } -} diff --git a/webpack.config.js b/webpack.config.js index b077c03..4dc1e4e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,14 +7,14 @@ require('babel-register'); switch (process.env.NODE_ENV) { case 'prod': case 'production': - module.exports = require('./config/webpack/webpack.prod.babel'); + module.exports = require('./config/webpack/webpack.prod.babel')({env: 'production'}); break; case 'test': case 'testing': - module.exports = require('./config/webpack/webpack.test.babel'); + module.exports = require('./config/webpack/webpack.test.babel')({env: 'test'}); break; case 'dev': case 'development': default: - module.exports = require('./config/webpack/webpack.dev.babel'); + module.exports = require('./config/webpack/webpack.dev.babel')({env: 'development'}); }