From 5c8fcf1c03ee34091c42655c8d89b48ce815e1cc Mon Sep 17 00:00:00 2001 From: Dmitriy Shekhovtsov Date: Mon, 6 Jun 2016 17:51:01 +0300 Subject: [PATCH] feat(demo): new build process with ng2-webpack-config --- .gitignore | 1 + .ng2-config.js | 30 +++ .npmignore | 1 + components/rating/rating.component.ts | 2 +- components/rating/readme.md | 4 +- components/typeahead/readme.md | 2 +- demo/assets/css/prettify-angulario.css | 217 +++++++++++++++++++++ demo/assets/css/prism-okaidia.css | 119 ----------- demo/assets/css/style.css | 25 ++- demo/assets/js/prettify.min.js | 30 +++ demo/components/accordion-section.ts | 4 +- demo/components/alert-section.ts | 4 +- demo/components/buttons-section.ts | 4 +- demo/components/carousel-section.ts | 4 +- demo/components/collapse-section.ts | 4 +- demo/components/datepicker-section.ts | 4 +- demo/components/demo-section.template.html | 10 +- demo/components/dropdown-section.ts | 4 +- demo/components/modal-section.ts | 4 +- demo/components/pagination-section.ts | 4 +- demo/components/progressbar-section.ts | 6 +- demo/components/rating-section.ts | 4 +- demo/components/tabs-section.ts | 4 +- demo/components/timepicker-section.ts | 4 +- demo/components/tooltip-section.ts | 4 +- demo/components/typeahead-section.ts | 4 +- demo/custom-typings.d.ts | 3 + demo/index-bs4.html | 10 +- demo/index.html | 11 +- demo/index.ts | 33 +++- demo/polyfills.ts | 28 +++ demo/vendor.ts | 23 +++ karma.conf.js | 104 +--------- package.json | 32 +-- protractor.conf.js | 7 + spec-bundle.js | 64 ++++++ test.bundle.js | 47 ----- tsconfig.json | 11 +- tslint.json | 5 +- typedoc.js | 17 ++ typings.json | 2 +- webpack.config.js | 194 +++--------------- 42 files changed, 562 insertions(+), 532 deletions(-) create mode 100644 .ng2-config.js create mode 100644 demo/assets/css/prettify-angulario.css delete mode 100644 demo/assets/css/prism-okaidia.css create mode 100644 demo/assets/js/prettify.min.js create mode 100644 demo/custom-typings.d.ts create mode 100644 demo/polyfills.ts create mode 100644 demo/vendor.ts create mode 100644 protractor.conf.js create mode 100644 spec-bundle.js delete mode 100644 test.bundle.js create mode 100644 typedoc.js diff --git a/.gitignore b/.gitignore index 7050331aad..4efe9e642c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ npm-debug.log /dist /coverage /ts +/doc # ignore incline compiling /demo/**/*.js diff --git a/.ng2-config.js b/.ng2-config.js new file mode 100644 index 0000000000..8a78c02d54 --- /dev/null +++ b/.ng2-config.js @@ -0,0 +1,30 @@ +/* eslint no-var:0 */ +'use strict'; +var pkg = require('./package.json'); + +module.exports = { + // metadata + title: pkg.description, + baseUrl: '/', + // root folder name + src: 'demo', + dist: 'demo-build', + htmlIndexes: ['index.html', 'index-bs4.html'], + // karma bundle src + spec: './spec-bundle.js', + // webpack entry + entry: { + polyfills: './demo/polyfills.ts', + vendor: './demo/vendor.ts', + main: './demo/index.ts' + }, + commonChunks: { + name: ['polyfills', 'vendor'].reverse() + }, + // webpack alias + alias: {}, + copy: [ + {from: 'demo/favicon.ico', to: 'favicon.ico'}, + {from: 'demo/assets', to: 'assets'} + ] +}; diff --git a/.npmignore b/.npmignore index 818ee44588..27b70f34d8 100644 --- a/.npmignore +++ b/.npmignore @@ -11,6 +11,7 @@ test.bundle.js coverage # demo build +doc demo demo-build webpack.config.js diff --git a/components/rating/rating.component.ts b/components/rating/rating.component.ts index 9b5262797a..a19660c013 100644 --- a/components/rating/rating.component.ts +++ b/components/rating/rating.component.ts @@ -28,7 +28,7 @@ export class RatingComponent implements ControlValueAccessor, OnInit { @Input() public stateOff:string; @Input() public readonly:boolean; @Input() public titles:Array; - @Input() public ratingStates:Array<{stateOn:string, stateOff:string}>; + @Input() public ratingStates:{stateOn:string, stateOff:string}[]; @Output() public onHover:EventEmitter = new EventEmitter(false); @Output() public onLeave:EventEmitter = new EventEmitter(false); diff --git a/components/rating/readme.md b/components/rating/readme.md index 0132ef5dd8..9ab9be6e9a 100644 --- a/components/rating/readme.md +++ b/components/rating/readme.md @@ -18,7 +18,7 @@ export class RatingComponent implements ControlValueAccessor, OnInit { @Input() private stateOff:string; @Input() private readonly:boolean; @Input() private titles:Array; - @Input() private ratingStates:Array<{stateOn:string, stateOff:string}>; + @Input() private ratingStates:{stateOn:string, stateOff:string}[]; @Output() private onHover:EventEmitter = new EventEmitter(false); @Output() private onLeave:EventEmitter = new EventEmitter(false); @@ -31,7 +31,7 @@ export class RatingComponent implements ControlValueAccessor, OnInit { - `titles` (`?Array`) - array of icons titles, default: (`["one", "two", "three", "four", "five"]`) - `stateOn` (`?string='glyphicon-star'`) - selected icon class - `stateOff` (`?string='glyphicon-star-empty'`) - unselected icon class - - `ratingStates` (`?Array<{stateOn:string, stateOff:string}>`) - array of custom icons classes + - `ratingStates` (`?{stateOn:string, stateOff:string}[]`) - array of custom icons classes ### Rating events - `onHover` - fired when icon selected, `$event:number` equals to selected rating diff --git a/components/typeahead/readme.md b/components/typeahead/readme.md index 0028223bd2..5662c69fe1 100644 --- a/components/typeahead/readme.md +++ b/components/typeahead/readme.md @@ -14,7 +14,7 @@ import { TYPEAHEAD_DIRECTIVES } from 'ng2-bootstrap/components/typeahead'; export class TypeaheadDirective implements OnInit { @Output() public typeaheadLoading:EventEmitter; @Output() public typeaheadNoResults:EventEmitter; - @Output() public typeaheadOnSelect:EventEmitter<{item: any}>; + @Output() public typeaheadOnSelect:EventEmitter<{item: any}>; @Input() public typeahead:any; @Input() public typeaheadMinLength:number; diff --git a/demo/assets/css/prettify-angulario.css b/demo/assets/css/prettify-angulario.css new file mode 100644 index 0000000000..ce4d393583 --- /dev/null +++ b/demo/assets/css/prettify-angulario.css @@ -0,0 +1,217 @@ +.prettyprint { + white-space: pre-wrap; + background: #F5F6F7; + font-family: Monaco,"Lucida Console",monospace; + color: #5C707A; + width: auto; + overflow: auto; + position: relative; + padding: 0; + font-size: 13px; + line-height: 24px; + margin-bottom: 24px; + border-radius: 4px; + padding: 16px 32px +} + +.prettyprint.linenums,.prettyprint[class^="linenums:"],.prettyprint[class*=" linenums:"] { + padding: 0 +} + +.prettyprint.is-showcase { + border: 4px solid #0273D4 +} + +.prettyprint code { + background: none; + font-size: 13px; + padding: 0 +} + +.prettyprint ol { + background: #F5F6F7; + padding: 16px 32px 16px 56px; + margin: 0; + overflow: auto; + font-size: 13px +} + +.prettyprint ol li { + color: #7a8b94; + background: none; + margin-bottom: 5px; + line-height: normal; + list-style-type: decimal; + font-size: 12px +} + +.prettyprint ol li:last-child { + margin-bottom: 0 +} + +.prettyprint ol li code { + background: none; + font-size: 13px +} + +.prettyprint .pnk,.prettyprint .blk { + border-radius: 4px; + padding: 2px 4px +} + +.prettyprint .pnk { + background: #CFD8DC; + color: #5C707A +} + +.prettyprint .blk { + background: #E0E0E0 +} + +.prettyprint .otl { + outline: 1px solid rgba(169,169,169,0.56) +} + +.prettyprint .kwd { + color: #D43669 +} + +.prettyprint .typ,.prettyprint .tag { + color: #D43669 +} + +.prettyprint .str,.prettyprint .atv { + color: #647f11 +} + +.prettyprint .atn { + /*color: #647f11*/ + color: #31708f +} + +.prettyprint .com { + color: #647f11 +} + +.prettyprint .lit { + color: #647f11 +} + +.prettyprint .pun { + color: #7a8b94 +} + +.prettyprint .pln { + color: #5C707A + /*color: #8a6d3b*/ +} + +.prettyprint .dec { + color: #647f11 +} + +@media print { + .prettyprint { + background: #F5F6F7; + border: none; + box-shadow: none + } + + .prettyprint ol { + background: #F5F6F7 + } + + .prettyprint .kwd { + color: #D43669 + } + + .prettyprint .typ,.prettyprint .tag { + color: #D43669 + } + + .prettyprint .str,.prettyprint .atv { + color: #647f11 + } + + .prettyprint .atn { + /*color: #647f11*/ + color: #31708f + } + + .prettyprint .com { + color: #647f11 + } + + .prettyprint .lit { + color: #647f11 + } + + .prettyprint .pun { + color: #7a8b94 + } + + .prettyprint .pln { + color: #5C707A + } + + .prettyprint .dec { + color: #647f11 + } +} + +h1 .prettyprint,h2 .prettyprint,h3 .prettyprint,h4 .prettyprint { + background: none; + font-family: Monaco,"Lucida Console",monospace; + color: #253238; + overflow: hidden; + position: relative; + font-size: 15px; + font-weight: 600; + line-height: 24px; + margin: 0; + border: none; + box-shadow: none; + padding: 0 +} + +h1 .prettyprint code,h2 .prettyprint code,h3 .prettyprint code,h4 .prettyprint code { + background: none; + font-size: 15px; + padding: 0 +} + +h1 .prettyprint .kwd,h2 .prettyprint .kwd,h3 .prettyprint .kwd,h4 .prettyprint .kwd { + color: #253238 +} + +h1 .prettyprint .typ,h1 .prettyprint .tag,h2 .prettyprint .typ,h2 .prettyprint .tag,h3 .prettyprint .typ,h3 .prettyprint .tag,h4 .prettyprint .typ,h4 .prettyprint .tag { + color: #B52E31 +} + +h1 .prettyprint .str,h1 .prettyprint .atv,h2 .prettyprint .str,h2 .prettyprint .atv,h3 .prettyprint .str,h3 .prettyprint .atv,h4 .prettyprint .str,h4 .prettyprint .atv { + color: #9d8d00 +} + +h1 .prettyprint .atn,h2 .prettyprint .atn,h3 .prettyprint .atn,h4 .prettyprint .atn { + color: #71a436 +} + +h1 .prettyprint .com,h2 .prettyprint .com,h3 .prettyprint .com,h4 .prettyprint .com { + color: #AFBEC5 +} + +h1 .prettyprint .lit,h2 .prettyprint .lit,h3 .prettyprint .lit,h4 .prettyprint .lit { + color: #9d8d00 +} + +h1 .prettyprint .pun,h2 .prettyprint .pun,h3 .prettyprint .pun,h4 .prettyprint .pun { + color: #000 +} + +h1 .prettyprint .pln,h2 .prettyprint .pln,h3 .prettyprint .pln,h4 .prettyprint .pln { + color: #000 +} + +h1 .prettyprint .dec,h2 .prettyprint .dec,h3 .prettyprint .dec,h4 .prettyprint .dec { + color: #8762c6 +} diff --git a/demo/assets/css/prism-okaidia.css b/demo/assets/css/prism-okaidia.css deleted file mode 100644 index 0fac6828db..0000000000 --- a/demo/assets/css/prism-okaidia.css +++ /dev/null @@ -1,119 +0,0 @@ -/** - * okaidia theme for JavaScript, CSS and HTML - * Loosely based on Monokai textmate theme by http://www.monokai.nl/ - * @author ocodia - */ - -code[class*="language-"], -pre[class*="language-"] { - color: #f8f8f2; - text-shadow: 0 1px rgba(0, 0, 0, 0.3); - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; - direction: ltr; - text-align: left; - white-space: pre; - word-spacing: normal; - word-break: normal; - line-height: 1.5; - - -moz-tab-size: 4; - -o-tab-size: 4; - tab-size: 4; - - -webkit-hyphens: none; - -moz-hyphens: none; - -ms-hyphens: none; - hyphens: none; -} - -/* Code blocks */ -pre[class*="language-"] { - padding: 1em; - margin: .5em 0; - overflow: auto; - border-radius: 0.3em; -} - -:not(pre) > code[class*="language-"], -pre[class*="language-"] { - background: #272822; -} - -/* Inline code */ -:not(pre) > code[class*="language-"] { - padding: .1em; - border-radius: .3em; -} - -.token.comment, -.token.prolog, -.token.doctype, -.token.cdata { - color: slategray; -} - -.token.punctuation { - color: #f8f8f2; -} - -.namespace { - opacity: .7; -} - -.token.property, -.token.tag, -.token.constant, -.token.symbol, -.token.deleted { - color: #f92672; -} - -.token.boolean, -.token.number { - color: #ae81ff; -} - -.token.selector, -.token.attr-name, -.token.string, -.token.char, -.token.builtin, -.token.inserted { - color: #a6e22e; -} - -.token.operator, -.token.entity, -.token.url, -.language-css .token.string, -.style .token.string, -.token.variable { - color: #f8f8f2; -} - -.token.atrule, -.token.attr-value, -.token.function { - color: #e6db74; -} - -.token.keyword { - color: #66d9ef; -} - -.token.regex, -.token.important { - color: #fd971f; -} - -.token.important, -.token.bold { - font-weight: bold; -} -.token.italic { - font-style: italic; -} - -.token.entity { - cursor: help; -} diff --git a/demo/assets/css/style.css b/demo/assets/css/style.css index 9b22670594..3fe3510ea6 100644 --- a/demo/assets/css/style.css +++ b/demo/assets/css/style.css @@ -3,6 +3,16 @@ body { background-color: #f5f9fb; } +body,html { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + min-height: 100%; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale +} + .text-red { color: #cd151e; } @@ -262,7 +272,7 @@ body { font-size: 14px; padding: 0 0 0 12px; margin: 14px 0; - font-family: 'Source Code Pro'; + /*font-family: 'Source Code Pro';*/ border-left: 1px solid transparent; list-style: none; } @@ -337,7 +347,7 @@ body { /************* START CONTENT **************/ #content p, -#content li, +#content li:not([class^='L']) , #content .accordion h4 { font-weight: 300; font-size: 16px; @@ -349,11 +359,11 @@ body { } #content p, -#content li { +#content li:not([class^='L']) { line-height: 30px; } -#content li a, +#content li:not([class^='L']) a, #content p a { /*color: #0808df;*/ text-decoration: none; @@ -581,8 +591,9 @@ body { #main-menu { height: calc(100% - 55px); } +} - /*#main {*/ - /*margin-top: 105px;*/ - /*}*/ +pre { + word-wrap: normal; + word-break: normal; } diff --git a/demo/assets/js/prettify.min.js b/demo/assets/js/prettify.min.js new file mode 100644 index 0000000000..7b990496dd --- /dev/null +++ b/demo/assets/js/prettify.min.js @@ -0,0 +1,30 @@ +!function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function S(a){function d(e){var b=e.charCodeAt(0);if(b!==92)return b;var a=e.charAt(1);return(b=r[a])?b:"0"<=a&&a<="7"?parseInt(e.substring(1),8):a==="u"||a==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function g(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return e==="\\"||e==="-"||e==="]"||e==="^"?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a= +b[0]==="^",c=["["];a&&c.push("^");for(var a=a?1:0,f=b.length;a122||(l<65||h>90||e.push([Math.max(65,h)|32,Math.min(l,90)|32]),l<97||h>122||e.push([Math.max(97,h)&-33,Math.min(l,122)&-33]))}}e.sort(function(e,a){return e[0]-a[0]||a[1]-e[1]});b=[];f=[];for(a=0;ah[0]&&(h[1]+1>h[0]&&c.push("-"),c.push(g(h[1])));c.push("]");return c.join("")}function s(e){for(var a=e.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],f=0,h=0;f=2&&e==="["?a[f]=b(l):e!=="\\"&&(a[f]=l.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var x=0,m=!1,j=!1,k=0,c=a.length;k=5&&"lang-"===w.substring(0,5))&&!(t&&typeof t[1]==="string"))f=!1,w="src";f||(r[z]=w)}h=c;c+=z.length;if(f){f=t[1];var l=z.indexOf(f),B=l+f.length;t[2]&&(B=z.length-t[2].length,l=B-f.length);w=w.substring(5);H(j+h,z.substring(0,l),g,k);H(j+h+l,f,I(w,f),k);H(j+h+B,z.substring(B),g,k)}else k.push(j+h,w)}a.g=k}var b={},s;(function(){for(var g=a.concat(d),j=[],k={},c=0,i=g.length;c=0;)b[n.charAt(e)]=r;r=r[1];n=""+r;k.hasOwnProperty(n)||(j.push(r),k[n]=q)}j.push(/[\S\s]/);s=S(j)})();var x=d.length;return g}function v(a){var d=[],g=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&g.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),g.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,q])):d.push(["com", +/^#[^\n\r]*/,q,"#"]));a.cStyleComments&&(g.push(["com",/^\/\/[^\n\r]*/,q]),g.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));if(b=a.regexLiterals){var s=(b=b>1?"":"\n\r")?".":"[\\S\\s]";g.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+ +s+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&g.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&g.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),q]);d.push(["pln",/^\s+/,q," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");g.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/, +q],["pun",RegExp(b),q]);return C(d,g)}function J(a,d,g){function b(a){var c=a.nodeType;if(c==1&&!x.test(a.className))if("br"===a.nodeName)s(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&g){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(j.createTextNode(d),a.nextSibling),s(a),c||a.parentNode.removeChild(a)}}function s(a){function b(a,c){var d= +c?a.cloneNode(!1):a,e=a.parentNode;if(e){var e=b(e,1),g=a.nextSibling;e.appendChild(d);for(var i=g;i;i=g)g=i.nextSibling,e.appendChild(i)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var x=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,j=a.ownerDocument,k=j.createElement("li");a.firstChild;)k.appendChild(a.firstChild);for(var c=[k],i=0;i=0;){var b=d[g];F.hasOwnProperty(b)?D.console&&console.warn("cannot override language handler %s",b):F[b]=a}}function I(a,d){if(!a||!F.hasOwnProperty(a))a=/^\s*=l&&(b+=2);g>=B&&(r+=2)}}finally{if(f)f.style.display=h}}catch(u){D.console&&console.log(u&&u.stack||u)}}var D=window,y=["break,continue,do,else,for,if,return,while"],E=[[y,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],M=[E,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],N=[E,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"], +O=[N,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],E=[E,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],P=[y,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +Q=[y,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],W=[y,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],y=[y,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],R=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/, +V=/\S/,X=v({keywords:[M,O,E,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",P,Q,y],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),F={};p(X,["default-code"]);p(C([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-", +/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);p(C([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/], +["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);p(C([],[["atv",/^[\S\s]+/]]),["uq.val"]);p(v({keywords:M,hashComments:!0,cStyleComments:!0,types:R}),["c","cc","cpp","cxx","cyc","m"]);p(v({keywords:"null,true,false"}),["json"]);p(v({keywords:O,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:R}), +["cs"]);p(v({keywords:N,cStyleComments:!0}),["java"]);p(v({keywords:y,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);p(v({keywords:P,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);p(v({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);p(v({keywords:Q, +hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);p(v({keywords:E,cStyleComments:!0,regexLiterals:!0}),["javascript","js"]);p(v({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);p(v({keywords:W,cStyleComments:!0,multilineStrings:!0}),["rc","rs","rust"]); +p(C([],[["str",/^[\S\s]+/]]),["regex"]);var Y=D.PR={createSimpleLexer:C,registerLangHandler:p,sourceDecorator:v,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:D.prettyPrintOne=function(a,d,g){var b=document.createElement("div");b.innerHTML="
"+a+"
";b=b.firstChild;g&&J(b,g,!0);K({h:d,j:g,c:b,i:1}); +return b.innerHTML},prettyPrint:D.prettyPrint=function(a,d){function g(){for(var b=D.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;iMarkup
-
-            
-          
+
{{html}}
-
-            
-          
+
{{ts}}
@@ -39,6 +35,6 @@

Markup

Api

-
+
diff --git a/demo/components/dropdown-section.ts b/demo/components/dropdown-section.ts index 113cd481d7..19cdb8210b 100644 --- a/demo/components/dropdown-section.ts +++ b/demo/components/dropdown-section.ts @@ -8,8 +8,8 @@ import {DemoSectionComponent} from './demo-section'; let doc = require('../../components/dropdown/readme.md'); let titleDoc = require('../../components/dropdown/title.md'); -let ts = require('!!prismjs?lang=typescript!./dropdown/dropdown-demo.ts'); -let html = require('!!prismjs?lang=markup!./dropdown/dropdown-demo.html'); +let ts = require('!!raw?lang=typescript!./dropdown/dropdown-demo.ts'); +let html = require('!!raw?lang=markup!./dropdown/dropdown-demo.html'); @Component({ selector: 'dropdown-section', diff --git a/demo/components/modal-section.ts b/demo/components/modal-section.ts index e1910a2d1f..2c74230735 100644 --- a/demo/components/modal-section.ts +++ b/demo/components/modal-section.ts @@ -8,8 +8,8 @@ import {DemoSectionComponent} from './demo-section'; let doc = require('../../components/modal/readme.md'); let titleDoc = require('../../components/modal/title.md'); -let ts = require('!!prismjs?lang=typescript!./modal/modal-demo.ts'); -let html = require('!!prismjs?lang=markup!./modal/modal-demo.html'); +let ts = require('!!raw?lang=typescript!./modal/modal-demo.ts'); +let html = require('!!raw?lang=markup!./modal/modal-demo.html'); @Component({ selector: 'modal-section', diff --git a/demo/components/pagination-section.ts b/demo/components/pagination-section.ts index 889c8c56cf..c55ee3746a 100644 --- a/demo/components/pagination-section.ts +++ b/demo/components/pagination-section.ts @@ -8,8 +8,8 @@ import {DemoSectionComponent} from './demo-section'; let doc = require('../../components/pagination/readme.md'); let titleDoc = require('../../components/pagination/title.md'); -let ts = require('!!prismjs?lang=typescript!./pagination/pagination-demo.ts'); -let html = require('!!prismjs?lang=markup!./pagination/pagination-demo.html'); +let ts = require('!!raw?lang=typescript!./pagination/pagination-demo.ts'); +let html = require('!!raw?lang=markup!./pagination/pagination-demo.html'); @Component({ selector: 'pagination-section', diff --git a/demo/components/progressbar-section.ts b/demo/components/progressbar-section.ts index 4ccbb867e2..c7a756af75 100644 --- a/demo/components/progressbar-section.ts +++ b/demo/components/progressbar-section.ts @@ -9,11 +9,11 @@ import {DemoSectionComponent} from './demo-section'; let doc = require('../../components/progressbar/readme.md'); let titleDoc = require('../../components/progressbar/title.md'); -let ts = require('!!prismjs?lang=typescript!./progressbar/progressbar-demo.ts'); +let ts = require('!!raw?lang=typescript!./progressbar/progressbar-demo.ts'); let templates:any = { - [Ng2BootstrapTheme.BS3]: require('!!prismjs?lang=markup!./progressbar/progressbar-demo.html'), - [Ng2BootstrapTheme.BS4]: require('!!prismjs?lang=markup!./progressbar/progressbar-demo-bs4.html') + [Ng2BootstrapTheme.BS3]: require('!!raw?lang=markup!./progressbar/progressbar-demo.html'), + [Ng2BootstrapTheme.BS4]: require('!!raw?lang=markup!./progressbar/progressbar-demo-bs4.html') }; let html = templates[Ng2BootstrapConfig.theme]; diff --git a/demo/components/rating-section.ts b/demo/components/rating-section.ts index fb5c57ac6c..9c71c9ad0e 100644 --- a/demo/components/rating-section.ts +++ b/demo/components/rating-section.ts @@ -8,8 +8,8 @@ import {DemoSectionComponent} from './demo-section'; let doc = require('../../components/rating/readme.md'); let titleDoc = require('../../components/rating/title.md'); -let ts = require('!!prismjs?lang=typescript!./rating/rating-demo.ts'); -let html = require('!!prismjs?lang=markup!./rating/rating-demo.html'); +let ts = require('!!raw?lang=typescript!./rating/rating-demo.ts'); +let html = require('!!raw?lang=markup!./rating/rating-demo.html'); @Component({ selector: 'rating-section', diff --git a/demo/components/tabs-section.ts b/demo/components/tabs-section.ts index dfccdf4a8b..1894f687bb 100644 --- a/demo/components/tabs-section.ts +++ b/demo/components/tabs-section.ts @@ -8,8 +8,8 @@ import {DemoSectionComponent} from './demo-section'; let doc = require('../../components/tabs/readme.md'); let titleDoc = require('../../components/tabs/title.md'); -let ts = require('!!prismjs?lang=typescript!./tabs/tabs-demo.ts'); -let html = require('!!prismjs?lang=markup!./tabs/tabs-demo.html'); +let ts = require('!!raw?lang=typescript!./tabs/tabs-demo.ts'); +let html = require('!!raw?lang=markup!./tabs/tabs-demo.html'); @Component({ selector: 'tabs-section', diff --git a/demo/components/timepicker-section.ts b/demo/components/timepicker-section.ts index 8eca6f5755..982a2ae611 100644 --- a/demo/components/timepicker-section.ts +++ b/demo/components/timepicker-section.ts @@ -8,8 +8,8 @@ import {DemoSectionComponent} from './demo-section'; let doc = require('../../components/timepicker/readme.md'); let titleDoc = require('../../components/timepicker/title.md'); -let ts = require('!!prismjs?lang=typescript!./timepicker/timepicker-demo.ts'); -let html = require('!!prismjs?lang=markup!./timepicker/timepicker-demo.html'); +let ts = require('!!raw?lang=typescript!./timepicker/timepicker-demo.ts'); +let html = require('!!raw?lang=markup!./timepicker/timepicker-demo.html'); @Component({ selector: 'timepicker-section', diff --git a/demo/components/tooltip-section.ts b/demo/components/tooltip-section.ts index 0c5a547177..4b0a32693b 100644 --- a/demo/components/tooltip-section.ts +++ b/demo/components/tooltip-section.ts @@ -8,8 +8,8 @@ import {DemoSectionComponent} from './demo-section'; let doc = require('../../components/tooltip/readme.md'); let titleDoc = require('../../components/tooltip/title.md'); -let ts = require('!!prismjs?lang=typescript!./tooltip/tooltip-demo.ts'); -let html = require('!!prismjs?lang=markup!./tooltip/tooltip-demo.html'); +let ts = require('!!raw?lang=typescript!./tooltip/tooltip-demo.ts'); +let html = require('!!raw?lang=markup!./tooltip/tooltip-demo.html'); @Component({ selector: 'tooltip-section', diff --git a/demo/components/typeahead-section.ts b/demo/components/typeahead-section.ts index 2db5ce50be..fd007e0168 100644 --- a/demo/components/typeahead-section.ts +++ b/demo/components/typeahead-section.ts @@ -8,8 +8,8 @@ import {DemoSectionComponent} from './demo-section'; let doc = require('../../components/typeahead/readme.md'); let titleDoc = require('../../components/typeahead/title.md'); -let ts = require('!!prismjs?lang=typescript!./typeahead/typeahead-demo.ts'); -let html = require('!!prismjs?lang=markup!./typeahead/typeahead-demo.html'); +let ts = require('!!raw?lang=typescript!./typeahead/typeahead-demo.ts'); +let html = require('!!raw?lang=markup!./typeahead/typeahead-demo.html'); @Component({ selector: 'typeahead-section', diff --git a/demo/custom-typings.d.ts b/demo/custom-typings.d.ts new file mode 100644 index 0000000000..8f07bc1e77 --- /dev/null +++ b/demo/custom-typings.d.ts @@ -0,0 +1,3 @@ +declare var NAME: string; +declare var VERSION: string; +declare var ENV: string; diff --git a/demo/index-bs4.html b/demo/index-bs4.html index e94440353a..0a6ccb4ad9 100644 --- a/demo/index-bs4.html +++ b/demo/index-bs4.html @@ -9,15 +9,18 @@ + + + - - + + - Loading... + Loading... + diff --git a/demo/index.html b/demo/index.html index 083e20c13e..f883e92e88 100644 --- a/demo/index.html +++ b/demo/index.html @@ -13,18 +13,17 @@ - + - - + - + Loading... - + - + diff --git a/demo/index.ts b/demo/index.ts index f5841bb354..ff4a16e260 100644 --- a/demo/index.ts +++ b/demo/index.ts @@ -1,5 +1,9 @@ -import {Component, enableProdMode, ViewContainerRef} from '@angular/core'; -import {RouterOutlet, RouteConfig, ROUTER_PROVIDERS} from '@angular/router-deprecated'; +import { + Component, enableProdMode, ViewContainerRef, AfterContentInit +} from '@angular/core'; +import { + RouterOutlet, RouteConfig, ROUTER_PROVIDERS, Router +} from '@angular/router-deprecated'; import {Ng2BootstrapConfig, Ng2BootstrapTheme} from '../ng2-bootstrap'; import {MainMenuComponent} from './components/main-menu/main-menu.component'; import {TopMenuComponent} from './components/top-menu/top-menu.component'; @@ -7,10 +11,13 @@ import {routes} from './config'; import {bootstrap} from '@angular/platform-browser-dynamic'; import {APP_BASE_HREF, HashLocationStrategy, LocationStrategy} from '@angular/common'; +// google code-prettify +declare const PR:any; + // todo: enable prod mod only for prod build -// if (false) { +if (ENV) { enableProdMode(); -// } +} let w:any = window; @@ -21,18 +28,30 @@ if (w && w.__theme === 'bs4') { let tmp = require('./demo.template.html'); @Component({ - selector: 'app', + selector: 'demo', template: tmp, directives: [RouterOutlet, TopMenuComponent, MainMenuComponent] }) @RouteConfig(routes) -export class DemoComponent { +export class DemoComponent implements AfterContentInit { public isBs3:boolean = Ng2BootstrapConfig.theme === Ng2BootstrapTheme.BS3; private viewContainerRef:ViewContainerRef; + private router: Router; - public constructor(viewContainerRef:ViewContainerRef) { + public constructor(viewContainerRef:ViewContainerRef, router: Router) { // You need this small hack in order to catch application root view container ref this.viewContainerRef = viewContainerRef; + + this.router = router; + } + + public ngAfterContentInit():any { + this.router.subscribe(() => { + if (typeof PR !== 'undefined') { + // google code-prettify + setTimeout(PR.prettyPrint, 50); + } + }); } } diff --git a/demo/polyfills.ts b/demo/polyfills.ts new file mode 100644 index 0000000000..d27ff360cd --- /dev/null +++ b/demo/polyfills.ts @@ -0,0 +1,28 @@ +// Polyfills +// (these modules are what are in 'angular2/bundles/angular2-polyfills' so don't use that here) + +// import 'ie-shim'; // Internet Explorer +// import 'es6-shim'; +// import 'es6-promise'; +// import 'es7-reflect-metadata'; + +// Prefer CoreJS over the polyfills above +import 'core-js/es6'; +import 'core-js/es7/reflect'; +require('zone.js/dist/zone'); +require('reflect-metadata'); + +// Typescript emit helpers polyfill +import 'ts-helpers'; + +if ('production' === ENV) { + // Production + +} else { + // Development + + (Error as any).stackTraceLimit = Infinity; + + require('zone.js/dist/long-stack-trace-zone'); + +} diff --git a/demo/vendor.ts b/demo/vendor.ts new file mode 100644 index 0000000000..e4dd7bc146 --- /dev/null +++ b/demo/vendor.ts @@ -0,0 +1,23 @@ +// For vendors for example jQuery, Lodash, angular2-jwt just import them here unless you plan on +// chunking vendors files for async loading. You would need to import the async loaded vendors +// at the entry point of the async loaded file. Also see custom-typings.d.ts as you also need to +// run `typings install x` where `x` is your module + +// Angular 2 +import '@angular/platform-browser'; +import '@angular/platform-browser-dynamic'; +import '@angular/core'; +import '@angular/common'; +import '@angular/router-deprecated'; + +// RxJS +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/mergeMap'; + +if ('production' === ENV) { + // Production + +} else { + // Development + +} diff --git a/karma.conf.js b/karma.conf.js index 31fec667d7..5f385b2e13 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,101 +1,9 @@ +/** + * @author: @AngularClass + */ 'use strict'; -const path = require('path'); -const cwd = process.cwd(); +// Look in ./config for karma.conf.js +const config = require('./.ng2-config'); -module.exports = config => { - config.set({ - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['jasmine'], - - // list of files / patterns to load in the browser - files: [ - {pattern: 'test.bundle.js', watched: false} - ], - - // list of files to exclude - exclude: [], - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - 'test.bundle.js': ['coverage', 'webpack', 'sourcemap'] - }, - - webpack: { - resolve: { - root: [path.resolve(cwd)], - modulesDirectories: ['node_modules', 'demo', 'components', 'test', '.'], - extensions: ['', '.ts', '.js', '.css'] - }, - module: { - loaders: [ - {test: /\.ts$/, loader: 'ts-loader', exclude: [/node_modules/]} - ], - postLoaders: [ - // instrument only testing sources with Istanbul - { - test: /\.(js|ts)$/, - include: root('components'), - loader: 'istanbul-instrumenter-loader', - exclude: [ - /\.e2e\.ts$/, - /node_modules/ - ] - } - ] - }, - stats: { - colors: true, - reasons: true - }, - watch: true, - debug: true - }, - - coverageReporter: { - dir: 'coverage/', - reporters: [ - {type: 'text'}, - {type: 'json'}, - {type: 'html'} - ] - }, - webpackServer: {noInfo: true}, - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['spec', 'coverage'], - - // web server port - port: 9876, - - // enable / disable colors in the output (reporters and logs) - colors: true, - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || - // config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: true - }); -}; - -function root(partialPath) { - return path.join(__dirname, partialPath); -} +module.exports = require('ng2-webpack-config').karma(config); diff --git a/package.json b/package.json index 2efc0303fa..9a2d0c0bf0 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,11 @@ "version": "1.0.17", "description": "angular2 bootstrap components", "scripts": { + "typedoc": "typedoc", + "flow.docs": "npm run typedoc -- --exclude '**/*.spec.ts' ./components/", "flow.install:typings": "./node_modules/.bin/typings install", "flow.compile": "npm run flow.install:typings && npm run flow.compile:common && npm run flow.compile:system ", - "flow.compile:common": "./node_modules/.bin/tsc", + "flow.compile:common": "./node_modules/.bin/tsc -d", "flow.compile:system": "./.config/bundle-system.js", "flow.copy:src": "./node_modules/.bin/cpy ng2-bootstrap.ts \"components/*.ts\" ts --parents", "flow.clean": "./node_modules/.bin/del bundles coverage demo-build typings \"components/**/*.+(js|d.ts|js.map)\" dist \"ng2-bootstrap.+(js|d.ts|js.map)\"", @@ -64,55 +66,33 @@ "async": "1.5.2", "bootstrap": "3.3.6", "codecov": "1.0.1", - "compression-webpack-plugin": "0.3.1", "conventional-changelog-cli": "1.2.0", "conventional-github-releaser": "1.1.3", - "copy-webpack-plugin": "3.0.1", "cpy-cli": "1.0.1", "del-cli": "0.2.0", "es6-promise": "3.2.1", "es6-shim": "0.35.1", "es7-reflect-metadata": "1.6.0", "eslint-config-valorsoft": "0.0.16", - "exports-loader": "0.6.3", "file-loader": "0.9.0", "gh-pages": "0.11.0", "gitignore-to-glob": "0.2.1", + "google-code-prettify": "1.0.1", "gulp": "3.9.1", "gulp-size": "2.1.0", "gulp-tslint": "5.0.0", - "html-loader": "0.4.3", - "html-webpack-plugin": "2.21.0", - "istanbul-instrumenter-loader": "0.2.0", - "jasmine": "2.4.1", - "karma": "0.13.22", - "karma-chrome-launcher": "1.0.1", - "karma-coverage": "1.0.0", - "karma-jasmine": "1.0.2", - "karma-phantomjs-launcher": "1.0.0", - "karma-sourcemap-loader": "0.3.7", - "karma-spec-reporter": "0.0.26", - "karma-webpack": "1.7.0", "lite-server": "2.2.0", - "markdown-loader": "0.1.7", "marked": "0.3.5", - "phantomjs-polyfill": "0.0.2", - "phantomjs-prebuilt": "2.1.7", + "ng2-webpack-config": "github:valor-software/ng2-webpack-config", "pre-commit": "1.1.3", - "prismjs": "1.5.0", - "prismjs-loader": "0.0.3", - "raw-loader": "0.5.1", "reflect-metadata": "0.1.2", "require-dir": "0.3.0", "rxjs": "5.0.0-beta.6", - "source-map-loader": "0.1.5", "systemjs-builder": "0.15.23", - "ts-loader": "0.8.2", "tslint-config-valorsoft": "1.0.3", + "typedoc": "0.4.1", "typescript": "1.8.10", "typings": "1.3.0", - "webpack": "1.13.1", - "webpack-dev-server": "1.14.1", "zone.js": "0.6.12" } } diff --git a/protractor.conf.js b/protractor.conf.js new file mode 100644 index 0000000000..285e0e6ce9 --- /dev/null +++ b/protractor.conf.js @@ -0,0 +1,7 @@ +/** + * @author: @AngularClass + */ +'use strict'; + +// look in ./config for protractor.conf.js +module.exports.config = require('./config/protractor.conf.js').config; diff --git a/spec-bundle.js b/spec-bundle.js new file mode 100644 index 0000000000..5f5997aec7 --- /dev/null +++ b/spec-bundle.js @@ -0,0 +1,64 @@ +/* eslint no-var: 0, vars-on-top: 0 */ +/** + * @author: @AngularClass + */ + +/* + * When testing with webpack and ES6, we have to do some extra + * things to get testing to work right. Because we are gonna write tests + * in ES6 too, we have to compile those as well. That's handled in + * karma.conf.js with the karma-webpack plugin. This is the entry + * file for webpack test. Just like webpack will create a bundle.js + * file for our client, when we run test, it will compile and bundle them + * all here! Crazy huh. So we need to do some setup + */ +'use strict'; +Error.stackTraceLimit = Infinity; + +require('core-js'); + +// Typescript emit helpers polyfill +require('ts-helpers'); + +require('zone.js/dist/zone'); +require('zone.js/dist/long-stack-trace-zone'); +require('zone.js/dist/jasmine-patch'); +require('zone.js/dist/async-test'); +require('zone.js/dist/fake-async-test'); +require('zone.js/dist/sync-test'); + +// RxJS +require('rxjs/Rx'); + +var testing = require('@angular/core/testing'); +var browser = require('@angular/platform-browser-dynamic/testing'); + +testing.setBaseTestProviders( + browser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + browser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS +); + +Object.assign(global, testing); + +/* + * Ok, this is kinda crazy. We can use the the context method on + * require that webpack created in order to tell webpack + * what files we actually want to require or import. + * Below, context will be an function/object with file names as keys. + * using that regex we are saying look in ./src/app and ./test then find + * any file that ends with spec.js and get its path. By passing in true + * we say do this recursively + */ +var testContext = require.context('./components', true, /\.spec\.ts/); + +/* + * get all the files, for each file, call the context function + * that will require the file and load it up here. Context will + * loop and require those spec files here + */ +function requireAll(requireContext) { + return requireContext.keys().map(requireContext); +} + +// requires and returns all modules that match +requireAll(testContext); diff --git a/test.bundle.js b/test.bundle.js deleted file mode 100644 index 9ade85794b..0000000000 --- a/test.bundle.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -/* eslint vars-on-top:0 no-var:0 */ -// @AngularClass -/* - * When testing with webpack and ES6, we have to do some extra - * things get testing to work right. Because we are gonna write test - * in ES6 to, we have to compile those as well. That's handled in - * karma.conf.js with the karma-webpack plugin. This is the entry - * file for webpack test. Just like webpack will create a bundle.js - * file for our client, when we run test, it well compile and bundle them - * all here! Crazy huh. So we need to do some setup - */ -Error.stackTraceLimit = Infinity; -require('phantomjs-polyfill'); -require('es6-promise'); -require('es6-shim'); -require('es7-reflect-metadata/dist/browser'); - -// require('zone.js'); -require('zone.js/dist/zone.js'); -require('zone.js/dist/long-stack-trace-zone.js'); -require('zone.js/dist/jasmine-patch.js'); -require('zone.js/dist/async-test.js'); - -var testing = require('@angular/core/testing'); -var browser = require('@angular/platform-browser-dynamic/testing'); - -testing.setBaseTestProviders( - browser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, - browser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); - -/* - Ok, this is kinda crazy. We can use the the context method on - require that webpack created in order to tell webpack - what files we actually want to require or import. - Below, context will be an function/object with file names as keys. - using that regex we are saying look in ./src/app and ./test then find - any file that ends with spec.js and get its path. By passing in true - we say do this recursively - */ -var testContext = require.context('./components', true, /\.spec\.ts/); - -// get all the files, for each file, call the context function -// that will require the file and load it up here. Context will -// loop and require those spec files here -testContext.keys().forEach(testContext); diff --git a/tsconfig.json b/tsconfig.json index 258ae6b89c..fbadd1df30 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,20 +3,19 @@ "target": "es5", "module": "commonjs", "moduleResolution": "node", - "sourceMap": false, - "declaration": true, - "removeComments": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, + "sourceMap": true, + "noEmitHelpers": true, "noImplicitAny": true, - "listFiles": false, - "noLib": false + "declaration": false }, "exclude": [ "node_modules" ], "files": [ - "./typings/browser.d.ts", + "./typings/index.d.ts", + "./demo/custom-typings.d.ts", "./ng2-bootstrap.ts" ] } diff --git a/tslint.json b/tslint.json index ea3f776042..b669aa8a3f 100644 --- a/tslint.json +++ b/tslint.json @@ -1,4 +1,7 @@ { "extends": "tslint-config-valorsoft", - "rulesDirectory": "./node_modules/codelyzer" + "rulesDirectory": "./node_modules/codelyzer", + "rules": { + "component-selector-name": [false, ""] + } } diff --git a/typedoc.js b/typedoc.js new file mode 100644 index 0000000000..5d8fec733d --- /dev/null +++ b/typedoc.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = { + mode: 'modules', + out: 'doc', + theme: 'default', + ignoreCompilerErrors: 'true', + experimentalDecorators: 'true', + emitDecoratorMetadata: 'true', + target: 'ES5', + moduleResolution: 'node', + preserveConstEnums: 'true', + stripInternal: 'true', + suppressExcessPropertyErrors: 'true', + suppressImplicitAnyIndexErrors: 'true', + module: 'commonjs' +}; diff --git a/typings.json b/typings.json index 592b524e73..6a38338fbb 100644 --- a/typings.json +++ b/typings.json @@ -4,7 +4,7 @@ "webpack": "registry:npm/webpack#1.12.9+20160219013405" }, "devDependencies": {}, - "ambientDependencies": { + "globalDependencies": { "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654", "jasmine": "registry:dt/jasmine#2.2.0+20160317120654", "require": "registry:dt/require#2.1.20+20160316155526" diff --git a/webpack.config.js b/webpack.config.js index db93d7437f..387516041e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,181 +1,37 @@ -/* eslint global-require: 0 */ +/* eslint no-process-env: 0, global-require:0 */ +/** + * @author: @AngularClass + */ 'use strict'; -const path = require('path'); -const marked = require('marked'); -const webpack = require('webpack'); -const reqPrism = require('prismjs'); -const CompressionPlugin = require('compression-webpack-plugin'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); +// Look in ./config folder for webpack.dev.js +const conf = getWebpackConfig(process.env.NODE_ENV, require('./.ng2-config')); // marked renderer hack +const marked = require('marked'); + marked.Renderer.prototype.code = function renderCode(code, lang) { - const out = this.options.highlight(code, lang); - const classMap = this.options.langPrefix + lang; + const escCode = code.replace(//g, '>'); if (!lang) { - return `
${out}\n
`; + return `
${escCode}
`; } - return `
${out}\n
\n`; + return `
${escCode}
`; }; -/*eslint no-process-env:0, camelcase:0*/ -const isProduction = (process.env.NODE_ENV || 'development') === 'production'; -const devtool = process.env.NODE_ENV === 'test' ? 'inline-source-map' : 'source-map'; -const dest = 'demo-build'; -const absDest = root(dest); - -const config = { - // isProduction ? 'source-map' : 'evale', - devtool, - debug: false, - - verbose: true, - displayErrorDetails: true, - context: __dirname, - stats: { - colors: true, - reasons: true - }, - - resolve: { - cache: false, - root: __dirname, - extensions: ['', '.ts', '.js', '.json'] - }, - - entry: { - angular2: [ - // Angular 2 Deps - 'es6-shim', - 'es6-promise', - 'zone.js', - 'reflect-metadata' - // '@angular/common', - // '@angular/core' - ], - 'angular2-bootstrap-demo': 'demo' - }, - - output: { - path: absDest, - filename: '[name].js', - sourceMapFilename: '[name].js.map', - chunkFilename: '[id].chunk.js' - }, - - // our Development Server configs - devServer: { - inline: true, - colors: true, - historyApiFallback: true, - contentBase: dest, - //publicPath: dest, - outputPath: dest, - watchOptions: {aggregateTimeout: 300, poll: 1000} - }, - - markdownLoader: { - langPrefix: 'language-', - highlight(code, lang) { - const language = !lang || lang === 'html' ? 'markup' : lang; - const Prism = global.Prism || reqPrism; - - if (!Prism.languages[language]) { - require(`prismjs/components/prism-${language}.js`); - } - return Prism.highlight(code, Prism.languages[language]); - } - }, - module: { - loaders: [ - // support markdown - {test: /\.md$/, loader: 'html?minimize=false!markdown'}, - // Support for *.json files. - {test: /\.json$/, loader: 'json'}, - // Support for CSS as raw text - {test: /\.css$/, loader: 'raw'}, - // support for .html as raw text - {test: /\.html$/, loader: 'raw'}, - // Support for .ts files. - { - test: /\.ts$/, - loader: 'ts', - query: { - compilerOptions: { - removeComments: true, - noEmitHelpers: false - } - }, - exclude: [/\.(spec|e2e)\.ts$/] - } - ], - noParse: [ - /rtts_assert\/src\/rtts_assert/, - /reflect-metadata/, - /zone\.js\/dist\/zone-microtask/ - ] - }, - - plugins: [ - //new Clean([dest]), - new webpack.optimize.DedupePlugin(), - new webpack.optimize.OccurenceOrderPlugin(true), - new webpack.optimize.CommonsChunkPlugin({ - name: 'angular2', - minChunks: Infinity, - filename: 'angular2.js' - }), - // static assets - new CopyWebpackPlugin([{from: 'demo/favicon.ico', to: 'favicon.ico'}]), - new CopyWebpackPlugin([{from: 'demo/assets', to: 'assets'}]), - // generating html - new HtmlWebpackPlugin({template: 'demo/index.html'}), - new HtmlWebpackPlugin({ - template: 'demo/index-bs4.html', - filename: 'index-bs4.html' - }) - ], - pushPlugins() { - if (!isProduction) { - return; - } - const plugins = [ - //production only - new webpack.optimize.UglifyJsPlugin({ - beautify: false, - mangle: false, - comments: false, - compress: { - screw_ie8: true - //warnings: false, - //drop_debugger: false - } - //verbose: true, - //beautify: false, - //quote_style: 3 - }), - new CompressionPlugin({ - asset: '{file}.gz', - algorithm: 'gzip', - regExp: /\.js$|\.html|\.css|.map$/, - threshold: 10240, - minRatio: 0.8 - }) - ]; - - this - .plugins - .push - .apply(plugins); +module.exports = conf; + +function getWebpackConfig(env, config) { + switch (env) { + case 'prod': + case 'production': + return require('ng2-webpack-config').webpack.prod(config); + case 'test': + case 'testing': + return require('ng2-webpack-config').webpack.test(config); + case 'dev': + case 'development': + default: + return require('ng2-webpack-config').webpack.dev(config); } -}; - -config.pushPlugins(); - -module.exports = config; - -function root(partialPath) { - return path.join(__dirname, partialPath); }