├── examples ├── src │ ├── img │ │ └── bower2requirejs.png │ ├── js │ │ ├── auto.js │ │ ├── bootstrap.js │ │ └── main.js │ ├── bower.json │ └── index.html ├── dist │ ├── img │ │ └── bower2requirejs.png │ ├── build.txt │ ├── js │ │ ├── bootstrap.js │ │ ├── main.js │ │ └── auto.js │ └── index.html └── build │ ├── build.js │ └── require-build.js ├── .gitignore ├── dist ├── build.txt ├── bower.js └── bower-bundle.js ├── package.json ├── bower.json ├── LICENSE ├── README.md └── src └── bower.js /examples/src/img/bower2requirejs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodneyEbanks/requirejs-plugin-bower/HEAD/examples/src/img/bower2requirejs.png -------------------------------------------------------------------------------- /examples/dist/img/bower2requirejs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodneyEbanks/requirejs-plugin-bower/HEAD/examples/dist/img/bower2requirejs.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # https://git-scm.com/docs/gitignore 2 | # https://help.github.com/articles/ignoring-files 3 | # Example .gitignore files: https://github.com/github/gitignore 4 | node_modules 5 | bower_components 6 | -------------------------------------------------------------------------------- /examples/src/js/auto.js: -------------------------------------------------------------------------------- 1 | define(['bower!../bower.json'], function(bowerConfig) { 2 | 3 | // requirejs.config(bowerConfig); // optional if bower: {auto: true} 4 | requirejs(['bootstrap']); 5 | 6 | }); 7 | -------------------------------------------------------------------------------- /examples/dist/build.txt: -------------------------------------------------------------------------------- 1 | 2 | js/auto.js 3 | ---------------- 4 | bower_components/requirejs-text/text.js 5 | bower_components/requirejs-plugins/src/json.js 6 | bower_components/requirejs-plugin-bower/src/bower.js 7 | bower!../bower.json 8 | js/auto.js 9 | -------------------------------------------------------------------------------- /dist/build.txt: -------------------------------------------------------------------------------- 1 | 2 | bower.js 3 | ---------------- 4 | bower.js 5 | 6 | bower-bundle.js 7 | ---------------- 8 | /home/rodney/Dropbox/Projects/Applications/requirejs-plugin-bower/bower_components/requirejs-text/text.js 9 | /home/rodney/Dropbox/Projects/Applications/requirejs-plugin-bower/bower_components/requirejs-plugins/src/json.js 10 | bower.js 11 | -------------------------------------------------------------------------------- /examples/dist/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | define(["image"],function(image){requirejs(["image!img/bower2requirejs.png"],function(requirejs2bower){var wrapper=document.getElementById("wrapper");requirejs2bower&&(wrapper.innerHTML='

Success

Bower.json available in src, deleted in dist after build

',wrapper.appendChild(requirejs2bower))})}); 2 | -------------------------------------------------------------------------------- /examples/build/build.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | var exec = require('child_process').exec; 4 | 5 | console.log('Executing: r.js -o require-build.js'); 6 | 7 | exec('r.js -o require-build.js', function (error, stdout, stderr) { 8 | if (error) { 9 | console.log(error); 10 | } 11 | if (stdout) { 12 | console.log(stdout); 13 | } 14 | if (stderr) { 15 | console.log(stderr); 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /examples/dist/js/main.js: -------------------------------------------------------------------------------- 1 | requirejs.config({baseUrl:"js",bower:{baseUrl:"../bower_components",extensions:"js|css",ignore:"requirejs|requirejs-domready|requirejs-text",auto:!0,deps:["dependencies"]},paths:{text:"../bower_components/requirejs-text/text",json:"../bower_components/requirejs-plugins/src/json",bower:"../bower_components/requirejs-plugin-bower/src/bower"},deps:[]}),define(["bower!../bower.json"],function(bowerConfig){requirejs(["bootstrap"])}); 2 | -------------------------------------------------------------------------------- /examples/src/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | define(['image'], function(image) { 2 | 3 | requirejs(['image!img/bower2requirejs.png'], function(requirejs2bower) { 4 | 5 | var wrapper = document.getElementById('wrapper'); 6 | 7 | if (requirejs2bower) { 8 | wrapper.innerHTML = '

Success

Bower.json available in src, deleted in dist after build

'; 9 | wrapper.appendChild(requirejs2bower); 10 | } 11 | 12 | }); 13 | 14 | }); 15 | 16 | -------------------------------------------------------------------------------- /examples/src/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "requirejs-plugin-bower-examples", 3 | "version": "0.0.6", 4 | "homepage": "https://github.com/RodneyEbanks/requirejs-plugin-bower", 5 | "authors": [ 6 | "rodneyebanks " 7 | ], 8 | "main": "index.html", 9 | "license": "MIT", 10 | "private": true, 11 | "ignore": [ 12 | "**/.*", 13 | "node_modules", 14 | "bower_components", 15 | "test", 16 | "tests" 17 | ], 18 | "dependencies": { 19 | "requirejs": "~2.1.15", 20 | "requirejs-plugin-bower": "*", 21 | "requirejs-plugins": "~1.0.3" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | RequireJS Plugin Bower 7 | 8 | 9 | 10 | 11 |
12 | 13 |

RequireJS Bower Plugin

14 |
15 | Something went wrong! 16 |
17 | Did you execute bower install in the examples/src folder? 18 |
19 |
Open console.log and reload page for errors. 20 |
21 |

22 | 23 |
24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | RequireJS Plugin Bower 7 | 8 | 9 | 10 | 11 |
12 | 13 |

RequireJS Bower Plugin

14 |
15 | Something went wrong! 16 |
17 | Did you execute bower install in the examples/src folder? 18 |
19 |
Open console.log and reload page for errors. 20 |
21 |

22 | 23 |
24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/src/js/main.js: -------------------------------------------------------------------------------- 1 | requirejs.config({ 2 | baseUrl: 'js', 3 | bower: { 4 | baseUrl: '../bower_components', 5 | extensions: 'js|css', 6 | ignore: 'requirejs|requirejs-domready|requirejs-text', 7 | auto: true, 8 | deps: ['dependencies'] // can add 'devDependencies' as well 9 | }, 10 | paths: { 11 | 'text': '../bower_components/requirejs-text/text', 12 | 'json': '../bower_components/requirejs-plugins/src/json', 13 | 'bower': '../bower_components/requirejs-plugin-bower/src/bower' 14 | }, 15 | deps: [] 16 | }); 17 | 18 | define(['bower!../bower.json'], function (bowerConfig) { 19 | 20 | // requirejs.config(bowerConfig); // optional if bower: {auto: true} 21 | requirejs(['bootstrap']); 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /examples/build/require-build.js: -------------------------------------------------------------------------------- 1 | ({ 2 | appDir: "../src", 3 | baseUrl: "./js", 4 | dir: "../dist", 5 | keepBuildDir: false, 6 | fileExclusionRegExp: /^\.|^(node_modules|gruntfile|gulpfile|grunt|doc|example|build|gulp|api|LICENSE|package\.json|bower\.json)|component\.json|\.(md|gzip|map|zip|eot|svg|woff)|\.min\.(js)/i, 7 | findNestedDependencies: false, 8 | removeCombined: true, 9 | optimize: "uglify", 10 | uglify: { 11 | toplevel: true, 12 | ascii_only: true, 13 | beautify: false, 14 | max_line_length: 1000, 15 | no_mangle: true 16 | }, 17 | inlineText: true, 18 | preserveLicenseComments: true, 19 | wrap: false, 20 | mainConfigFile: '../src/js/main.js', 21 | modules: [{ 22 | name: 'auto' 23 | }] 24 | }) 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "requirejs-plugin-bower", 3 | "version": "0.1.0", 4 | "description": "Automatically configure Requirejs paths and shim settings for installed Bower components (InBrowser & InBuild)", 5 | "main": "dist/bower.js", 6 | "directories": { 7 | "example": "examples" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/RodneyEbanks/requirejs-plugin-bower.git" 15 | }, 16 | "keywords": [ 17 | "requirejs", 18 | "require", 19 | "bower", 20 | "components", 21 | "config" 22 | ], 23 | "author": "Rodney Robert Ebanks ", 24 | "license": ["New BSD", "MIT"], 25 | "bugs": { 26 | "url": "https://github.com/RodneyEbanks/requirejs-plugin-bower/issues" 27 | }, 28 | "homepage": "https://github.com/RodneyEbanks/requirejs-plugin-bower", 29 | "dependencies": { 30 | "requirejs": ">2.0.0" 31 | }, 32 | "devDependencies": { 33 | "requirejs": ">2.0.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "requirejs-plugin-bower", 3 | "version": "0.1.0", 4 | "description": "Automatically configure Requirejs paths and shim settings for installed Bower components (InBrowser & InBuild)", 5 | "authors": [ 6 | "Rodney Robert Ebanks " 7 | ], 8 | "homepage": "https://github.com/RodneyEbanks/requirejs-plugin-bower", 9 | "repository": { 10 | "type": "git", 11 | "url": "git://github.com/RodneyEbanks/requirejs-plugin-bower" 12 | }, 13 | "main": ["dist/bower.js", "dist/bower-bundle.js"], 14 | "keywords": ["requirejs", "require", "bower", "config"], 15 | "license": [{ 16 | "type": "MIT", 17 | "url": "http://www.opensource.org/licenses/MIT" 18 | }, { 19 | "type": "BSD", 20 | "url": "http://www.opensource.org/licenses/BSD-3-Clause" 21 | }], 22 | "private": false, 23 | "ignore": [ 24 | "**/.*", 25 | "node_modules", 26 | "bower_components", 27 | "test", 28 | "tests" 29 | ], 30 | "dependencies": { 31 | "requirejs-text": "~2.0.13", 32 | "requirejs-plugins": "~1.0.3" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | requirejs-plugin-bower is released under two licenses: new BSD, and MIT. You may pick the 2 | license that best suits your development needs. The text of both licenses are 3 | provided below. 4 | 5 | 6 | The MIT License (MIT) 7 | ---------------------- 8 | 9 | Copyright (c) 2014 Rodney Robert Ebanks foss@rodneyebanks.com 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE. 28 | 29 | http://www.opensource.org/licenses/MIT 30 | 31 | The "New" BSD License: 32 | ---------------------- 33 | 34 | Copyright (c) 2014, Rodney Robert Ebanks foss@rodneyebanks.com 35 | All rights reserved. 36 | 37 | Redistribution and use in source and binary forms, with or without 38 | modification, are permitted provided that the following conditions are met: 39 | 40 | * Redistributions of source code must retain the above copyright notice, this 41 | list of conditions and the following disclaimer. 42 | * Redistributions in binary form must reproduce the above copyright notice, 43 | this list of conditions and the following disclaimer in the documentation 44 | and/or other materials provided with the distribution. 45 | * Neither the name of Rodney Robert Ebanks nor the names of its contributors 46 | may be used to endorse or promote products derived from this software 47 | without specific prior written permission. 48 | 49 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 50 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 51 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 52 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 53 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 54 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 55 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 56 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 57 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 58 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 | 60 | http://www.opensource.org/licenses/BSD-3-Clause -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # What if RequireJS could read bower.json files for module paths and dependencies? 2 | 3 | This Bower plugin for [RequireJS](http://requirejs.org) reads your root bower.json parsing your projects dependencies and their dependencies (TIAB). It then constructs a requirejs.config object ({"paths": {}, shim: {}}) with an auto load option. 4 | 5 | This plugin works both InBrowser (dependencies reread each page load) & InBuild (config object saved to disk, so you can dump your bower.json files). 6 | 7 | May also work on other AMD loaders (never tested it). 8 | 9 | ## Install 10 | 11 | You can use [bower](http://bower.io/) to install it easily: 12 | 13 | ``` 14 | bower install --save requirejs-plugin-bower 15 | ``` 16 | 17 | ## Plugins 18 | 19 | - **bower** : For creating requirejs.config({paths:{},shim:{}}) settings automatically. 20 | 21 | 22 | ## Documentation 23 | 24 | check the `examples` folder. All the info you probably need will be inside 25 | comments or on the example code itself. 26 | 27 | 28 | ## Basic usage 29 | 30 | Put the plugins inside the `baseUrl` folder (usually same folder as the main.js 31 | file) or create an alias to the plugin location: 32 | 33 | main.js 34 | ```main.js 35 | requirejs.config({ 36 | baseUrl:'/js', 37 | paths : { 38 | //create alias to plugins (not needed if plugins are on the baseUrl) 39 | bower: '../bower_components/requirejs-plugin-bower/src/bower', 40 | json: '../bower_components/requirejs-plugins/src/json', 41 | text: '../bower_components/requirejs-text/text' 42 | }, 43 | bower: { 44 | baseUrl: '../bower_components', 45 | extensions: 'js|css', 46 | ignore: 'requirejs|requirejs-domready|requirejs-text', 47 | auto: true, 48 | deps: ['dependencies', 'devDependencies'], 49 | loader: { 50 | css: 'css' 51 | } 52 | } 53 | }); 54 | 55 | // use plugin 56 | define(['bower!../bower.json'], function(bowerConfig) { 57 | 58 | // requirejs.config(bowerConfig); // optional if bower: {auto: true} 59 | requirejs(['bootstrap']); 60 | 61 | }); 62 | ``` 63 | bootstrap.js 64 | ```bootstrap.js 65 | // use other modules using name without location path 66 | define(['image'], function(image) { 67 | 68 | requirejs(['image!img/bower2requirejs.png'], function(requirejs2bower) { 69 | 70 | var wrapper = document.getElementById('wrapper'); 71 | 72 | if (requirejs2bower) { 73 | wrapper.innerHTML = '

Success


'; 74 | wrapper.appendChild(requirejs2bower); 75 | } 76 | 77 | }); 78 | 79 | }); 80 | ``` 81 | 82 | ## Removing plugin code after build 83 | 84 | [r.js](https://github.com/jrburke/r.js/blob/master/build/example.build.js) 85 | nowadays have the `stubModules` setting which can be used to remove the whole 86 | plugin code: 87 | 88 | ```js 89 | ({ 90 | // will remove whole source code of "json" and "text" plugins during build 91 | // JSON/text files that are bundled during build will still work fine but 92 | // you won't be able to load JSON/text files dynamically after build 93 | stubModules : ['json', 'text', 'requirejs-plugin-bower'] 94 | }) 95 | ``` 96 | 97 | For more plugins check [RequireJS Wiki](https://github.com/jrburke/requirejs/wiki/Plugins). 98 | 99 | ## Writing your own plugins 100 | 101 | Check [RequireJS documentation](http://requirejs.org/docs/plugins.html) for 102 | a basic reference and use other plugins as reference. RequireJS official 103 | plugins are a good source for learning. 104 | 105 | Also be sure to check [RequireJS Wiki](https://github.com/jrburke/requirejs/wiki/Plugins). 106 | 107 | ## License 108 | 109 | requirejs-plugin-bower is released under two licenses: new BSD, and MIT. You may pick the 110 | license that best suits your development needs. 111 | 112 | Copyright (c) 2014 Rodney Robert Ebanks foss@rodneyebanks.com 113 | -------------------------------------------------------------------------------- /dist/bower.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @license requirejs - plugin - bower 0.1.0 3 | * Copyright(c) 2014, Rodney Robert Ebanks foss@rodneyebanks.com All Rights Reserved. 4 | * Available via the MIT or new BSD license. 5 | */ 6 | 7 | (function(requirejs){"use strict";define("bower",["module","json"],function(module,json){var defaults={root:"/bower.json",manifest:"bower.json",baseUrl:"../bower_components",extensions:"js|css",ignore:"requirejs|requirejs-domready|requirejs-text",auto:!0,deps:["dependencies"],loader:{css:"css"}},request={parent:null,config:{}},store={count:0,processed:{},json:{},modules:{},config:{paths:{},shim:{}}},REGEX_PATH_RELATIVE=/^([^a-z|0-9]*)/,REGEX_PATH_SPLIT=/^(.*?)([^/\\]*?)(?:\.([^ :\\/.]*))?$/;function objectExtend(destination,source){return typeof source=="object"&&Object.keys(source).forEach(function(value){destination[value]=source[value]}),destination}function formatManifestPath(name){return name=defaults.baseUrl+"/"+name+"/"+defaults.manifest,name}function processManifest(name,req,onProcess,config,root){var jsonFileName;req=req||request.parent,config=config||request.config,onProcess=onProcess||function(){},store.count=store.count+1;function finished(config){store.count=store.count-1,store 8 | .count<1&&request.onLoad(config)}root&&(request.onLoad=onProcess),request.config.isBuild?jsonFileName=name.replace(REGEX_PATH_RELATIVE,request.config.appDir):jsonFileName=name,store.processed[name]!==!0?(store.processed[name]=!0,json.load(jsonFileName,req,function(jsonFile){jsonFile?(typeof jsonFile!="object"&&(jsonFile=JSON.parse(jsonFile)),parseManifest(name,jsonFile,finished,root)):onProcess(store.config)},config)):finished(store.config)}function parseManifest(file,manifestJson,onParse,root){var baseUrl,baseName,shimModules=[],shimDeps=[],localDeps=[],parseManifestPath=new RegExp(REGEX_PATH_SPLIT),parseRelativePath=new RegExp(REGEX_PATH_RELATIVE),validExt=new RegExp("^("+defaults.extensions+")$"),ignoreFile=new RegExp("^("+defaults.ignore+")$");if(!manifestJson){onParse(store.config);return}manifestJson.main=[].concat(manifestJson.main||file),defaults.deps.forEach(function(depsPath){manifestJson[depsPath]=Object.keys(manifestJson[depsPath]||{})}),baseUrl=parseManifestPath.exec(file)[1 9 | ],baseName=manifestJson.name,manifestJson.main.forEach(function(moduleName){var name,file,path,ext,filePath=parseManifestPath.exec(moduleName);name=manifestJson.name,path=filePath[1].replace(parseRelativePath,""),file=filePath[2],ext=filePath[3],validExt.test(ext)&&!ignoreFile.test(baseName)&&(name=name.replace(".","-"),ext!=="js"?(name=name+"-"+ext,defaults.loader[ext]&&localDeps.push(defaults.loader[ext]+"!"+name)):file!==name&&manifestJson.main.length>1?(name=file,shimModules.push(name)):(name=name,shimModules.push(name)),store.config.paths[name]=baseUrl+path+file,store.config.shim[name]={},store.config.shim[name].exports=name)}),manifestJson.dependencies.forEach(function(value){shimDeps.push(value.replace(".","-"))}),shimModules.forEach(function(moduleName){if(manifestJson.dependencies.length>0||localDeps.length>0)store.config.shim[moduleName].deps=[].concat(localDeps,shimDeps)}),defaults.deps.forEach(function(bowerDependencies){manifestJson[bowerDependencies]&&manifestJson[bowerDependencies 10 | ].length>0&&manifestJson[bowerDependencies].forEach(function(dependency){ignoreFile.test(dependency)||processManifest(formatManifestPath(dependency))})}),onParse(store.config)}function pluginLoad(name,req,onLoad,config){request.parent=req,request.config=config,defaults=objectExtend(defaults,request.config.bower||{}),processManifest(defaults.root,req,function(config){defaults.auto&&!request.config.isBuild&&requirejs.config(config),onLoad(config)},config,!0),config&&config.isBuild&&onLoad(store.config)}function pluginNormalize(name){return defaults.root=name||defaults.root,defaults.root}function pluginWrite(pluginName,moduleName,write){var content=JSON.stringify(store.config);defaults.auto?content='define("'+pluginName+"!"+moduleName+'", function(){var bowerConfig='+content+";\nrequirejs.config(bowerConfig);\nreturn bowerConfig;\n});\n":content='define("'+pluginName+"!"+moduleName+'", function(){\nreturn '+content+";\n});\n",write(content)}return{load:pluginLoad,normalize:pluginNormalize, 11 | write:pluginWrite}})})(requirejs); 12 | -------------------------------------------------------------------------------- /src/bower.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @license requirejs - plugin - bower 0.1.0 3 | * Copyright(c) 2014, Rodney Robert Ebanks foss@rodneyebanks.com All Rights Reserved. 4 | * Available via the MIT or new BSD license. 5 | */ 6 | 7 | (function (requirejs) { 8 | 'use strict'; 9 | define(['module', 'json'], function (module, json) { 10 | var defaults = { 11 | root: '/bower.json', 12 | manifest: 'bower.json', 13 | baseUrl: '../bower_components', 14 | extensions: 'js|css', 15 | ignore: 'requirejs|requirejs-domready|requirejs-text', 16 | auto: true, 17 | deps: ['dependencies'], 18 | loader: { 19 | css: 'css' 20 | } 21 | }; 22 | var request = { 23 | parent: null, 24 | config: {} 25 | }; 26 | var store = { 27 | count: 0, 28 | processed: {}, 29 | json: {}, 30 | modules: {}, 31 | config: { 32 | paths: {}, 33 | shim: {} 34 | } 35 | }; 36 | var REGEX_PATH_RELATIVE = /^([^a-z|0-9]*)/, 37 | REGEX_PATH_SPLIT = /^(.*?)([^/\\]*?)(?:\.([^ :\\/.]*))?$/; 38 | 39 | function objectExtend(destination, source) { 40 | if (typeof source === 'object') { 41 | Object.keys(source).forEach(function (value) { 42 | destination[value] = source[value]; 43 | }); 44 | } 45 | return destination; 46 | } 47 | 48 | function formatManifestPath(name) { 49 | name = defaults.baseUrl + '/' + name + '/' + defaults.manifest; 50 | return name; 51 | } 52 | 53 | function processManifest(name, req, onProcess, config, root) { 54 | var jsonFileName; 55 | req = req || request.parent; 56 | config = config || request.config; 57 | onProcess = onProcess || function () {}; 58 | 59 | store.count = store.count + 1; 60 | 61 | function finished(config) { 62 | store.count = store.count - 1; 63 | 64 | if (store.count < 1) { 65 | request.onLoad(config); 66 | } 67 | } 68 | 69 | if (root) { 70 | request.onLoad = onProcess; 71 | } 72 | 73 | // Fixme: Build require not working with paths relative to baseUrl from browser config e.g. '../bower.json'. 74 | if (request.config.isBuild) { 75 | jsonFileName = name.replace(REGEX_PATH_RELATIVE, request.config.appDir); 76 | } else { 77 | jsonFileName = name; 78 | } 79 | 80 | if (store.processed[name] !== true) { 81 | store.processed[name] = true; 82 | 83 | json.load(jsonFileName, req, function (jsonFile) { 84 | if (jsonFile) { 85 | if (typeof jsonFile !== 'object') { 86 | jsonFile = JSON.parse(jsonFile); 87 | } 88 | parseManifest(name, jsonFile, finished, root); 89 | } else { 90 | onProcess(store.config); 91 | } 92 | }, config); 93 | } else { 94 | finished(store.config); 95 | } 96 | } 97 | 98 | function parseManifest(file, manifestJson, onParse, root) { 99 | var baseUrl, baseName, shimModules = [], 100 | shimDeps = [], 101 | localDeps = [], 102 | parseManifestPath = new RegExp(REGEX_PATH_SPLIT), 103 | parseRelativePath = new RegExp(REGEX_PATH_RELATIVE), 104 | validExt = new RegExp('^(' + defaults.extensions + ')$'), 105 | ignoreFile = new RegExp('^(' + defaults.ignore + ')$'); 106 | 107 | // Check to make sure we actually have a manifestJson, otherwise, just call the onParse with a return. 108 | if (!manifestJson) { 109 | onParse(store.config); 110 | return; 111 | } 112 | 113 | // Format manifest to required standard. 114 | manifestJson.main = [].concat(manifestJson.main || file); 115 | defaults.deps.forEach(function (depsPath) { 116 | manifestJson[depsPath] = Object.keys(manifestJson[depsPath] || {}); 117 | }); 118 | 119 | // Top level for all mains in module 120 | baseUrl = parseManifestPath.exec(file)[1]; 121 | baseName = manifestJson.name; 122 | 123 | // Process each module in main 124 | manifestJson.main.forEach(function (moduleName) { 125 | var name, file, path, ext, filePath = parseManifestPath.exec(moduleName); 126 | 127 | name = manifestJson.name; 128 | path = filePath[1].replace(parseRelativePath, ''); 129 | file = filePath[2]; 130 | ext = filePath[3]; 131 | 132 | if (validExt.test(ext) && !ignoreFile.test(baseName)) { 133 | // Fix issue where name contains .js or other file extension 134 | name = name.replace('.', '-'); 135 | 136 | if (ext !== 'js') { 137 | // Stop overwites when module contains main with same name and different extensions ionic.js > ionic, ionic.css > ionic-css 138 | name = name + '-' + ext; 139 | 140 | if (defaults.loader[ext]) { 141 | localDeps.push(defaults.loader[ext] + '!' + name); 142 | } 143 | } else if (file !== name && manifestJson.main.length > 1) { 144 | // Multiple main modules possible. 145 | name = file; 146 | shimModules.push(name); 147 | } else { 148 | name = name; 149 | shimModules.push(name); 150 | } 151 | 152 | store.config.paths[name] = baseUrl + path + file; 153 | store.config.shim[name] = {}; 154 | store.config.shim[name].exports = name; 155 | 156 | } 157 | }); 158 | 159 | manifestJson.dependencies.forEach(function (value) { 160 | shimDeps.push(value.replace('.', '-')); 161 | }); 162 | 163 | // Add module shims with dependencies. 164 | shimModules.forEach(function (moduleName) { 165 | if (manifestJson.dependencies.length > 0 || localDeps.length > 0) { 166 | store.config.shim[moduleName].deps = [].concat(localDeps, shimDeps); 167 | } 168 | }); 169 | 170 | 171 | // Process modules dependencies (any included in defaults/settings dependencies:[]) 172 | defaults.deps.forEach(function (bowerDependencies) { 173 | if (manifestJson[bowerDependencies] && manifestJson[bowerDependencies].length > 0) { 174 | manifestJson[bowerDependencies].forEach(function (dependency) { 175 | if (!ignoreFile.test(dependency)) { 176 | processManifest(formatManifestPath(dependency)); 177 | } 178 | }); 179 | } 180 | }); 181 | 182 | // Return 183 | onParse(store.config); 184 | } 185 | 186 | function pluginLoad(name, req, onLoad, config) { 187 | request.parent = req; 188 | request.config = config; 189 | 190 | defaults = objectExtend(defaults, request.config.bower || {}); 191 | 192 | processManifest(defaults.root, req, function (config) { 193 | if (defaults.auto && !request.config.isBuild) { 194 | requirejs.config(config); 195 | } 196 | onLoad(config); 197 | }, config, true); 198 | 199 | if (config && config.isBuild) { 200 | onLoad(store.config); 201 | } 202 | } 203 | 204 | function pluginNormalize(name) { 205 | defaults.root = name || defaults.root; 206 | 207 | return defaults.root; 208 | } 209 | 210 | function pluginWrite(pluginName, moduleName, write) { 211 | var content = JSON.stringify(store.config); 212 | 213 | if (defaults.auto) { 214 | content = 'define("' + pluginName + '!' + moduleName + '", function(){var bowerConfig=' + content + ';\nrequirejs.config(bowerConfig);\nreturn bowerConfig;\n});\n'; 215 | } else { 216 | content = 'define("' + pluginName + '!' + moduleName + '", function(){\nreturn ' + content + ';\n});\n'; 217 | } 218 | 219 | write(content); 220 | } 221 | 222 | return { 223 | load: pluginLoad, 224 | normalize: pluginNormalize, 225 | write: pluginWrite 226 | }; 227 | }); 228 | }(requirejs)); 229 | -------------------------------------------------------------------------------- /dist/bower-bundle.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license RequireJS text 2.0.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. 3 | * Available via the MIT or new BSD license. 4 | * see: http://github.com/requirejs/text for details 5 | */ 6 | 7 | /** @license 8 | * RequireJS plugin for loading JSON files 9 | * - depends on Text plugin and it was HEAVILY "inspired" by it as well. 10 | * Author: Miller Medeiros 11 | * Version: 0.4.0 (2014/04/10) 12 | * Released under the MIT license 13 | */ 14 | 15 | /* 16 | * @license requirejs - plugin - bower 0.1.0 17 | * Copyright(c) 2014, Rodney Robert Ebanks foss@rodneyebanks.com All Rights Reserved. 18 | * Available via the MIT or new BSD license. 19 | */ 20 | 21 | define("text",["module"],function(module){"use strict";var text,fs,Cc,Ci,xpcIsWindows,progIds=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],xmlRegExp=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,bodyRegExp=/]*>\s*([\s\S]+)\s*<\/body>/im,hasLocation=typeof location!="undefined"&&location.href,defaultProtocol=hasLocation&&location.protocol&&location.protocol.replace(/\:/,""),defaultHostName=hasLocation&&location.hostname,defaultPort=hasLocation&&(location.port||undefined),buildMap={},masterConfig=module.config&&module.config()||{};text={version:"2.0.13",strip:function(content){if(content){content=content.replace(xmlRegExp,"");var matches=content.match(bodyRegExp);matches&&(content=matches[1])}else content="";return content},jsEscape:function(content){return content.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g 22 | ,"\\u2029")},createXhr:masterConfig.createXhr||function(){var xhr,i,progId;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")for(i=0;i<3;i+=1){progId=progIds[i];try{xhr=new ActiveXObject(progId)}catch(e){}if(xhr){progIds=[progId];break}}return xhr},parseName:function(name){var modName,ext,temp,strip=!1,index=name.lastIndexOf("."),isRelative=name.indexOf("./")===0||name.indexOf("../")===0;return index!==-1&&(!isRelative||index>1)?(modName=name.substring(0,index),ext=name.substring(index+1)):modName=name,temp=ext||modName,index=temp.indexOf("!"),index!==-1&&(strip=temp.substring(index+1)==="strip",temp=temp.substring(0,index),ext?ext=temp:modName=temp),{moduleName:modName,ext:ext,strip:strip}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(url,protocol,hostname,port){var uProtocol,uHostName,uPort,match=text.xdRegExp.exec(url);return match?(uProtocol=match[2],uHostName=match[3],uHostName=uHostName.split(":"),uPort=uHostName[1],uHostName= 23 | uHostName[0],(!uProtocol||uProtocol===protocol)&&(!uHostName||uHostName.toLowerCase()===hostname.toLowerCase())&&(!uPort&&!uHostName||uPort===port)):!0},finishLoad:function(name,strip,content,onLoad){content=strip?text.strip(content):content,masterConfig.isBuild&&(buildMap[name]=content),onLoad(content)},load:function(name,req,onLoad,config){if(config&&config.isBuild&&!config.inlineText){onLoad();return}masterConfig.isBuild=config&&config.isBuild;var parsed=text.parseName(name),nonStripName=parsed.moduleName+(parsed.ext?"."+parsed.ext:""),url=req.toUrl(nonStripName),useXhr=masterConfig.useXhr||text.useXhr;if(url.indexOf("empty:")===0){onLoad();return}!hasLocation||useXhr(url,defaultProtocol,defaultHostName,defaultPort)?text.get(url,function(content){text.finishLoad(name,parsed.strip,content,onLoad)},function(err){onLoad.error&&onLoad.error(err)}):req([nonStripName],function(content){text.finishLoad(parsed.moduleName+"."+parsed.ext,parsed.strip,content,onLoad)})},write:function(pluginName 24 | ,moduleName,write,config){if(buildMap.hasOwnProperty(moduleName)){var content=text.jsEscape(buildMap[moduleName]);write.asModule(pluginName+"!"+moduleName,"define(function () { return '"+content+"';});\n")}},writeFile:function(pluginName,moduleName,req,write,config){var parsed=text.parseName(moduleName),extPart=parsed.ext?"."+parsed.ext:"",nonStripName=parsed.moduleName+extPart,fileName=req.toUrl(parsed.moduleName+extPart)+".js";text.load(nonStripName,req,function(value){var textWrite=function(contents){return write(fileName,contents)};textWrite.asModule=function(moduleName,contents){return write.asModule(moduleName,fileName,contents)},text.write(pluginName,nonStripName,textWrite,config)},config)}};if(masterConfig.env==="node"||!masterConfig.env&&typeof process!="undefined"&&process.versions&&!!process.versions.node&&!process.versions["node-webkit"])fs=require.nodeRequire("fs"),text.get=function(url,callback,errback){try{var file=fs.readFileSync(url,"utf8");file[0]==="\ufeff"&&(file=file 25 | .substring(1)),callback(file)}catch(e){errback&&errback(e)}};else if(masterConfig.env==="xhr"||!masterConfig.env&&text.createXhr())text.get=function(url,callback,errback,headers){var xhr=text.createXhr(),header;xhr.open("GET",url,!0);if(headers)for(header in headers)headers.hasOwnProperty(header)&&xhr.setRequestHeader(header.toLowerCase(),headers[header]);masterConfig.onXhr&&masterConfig.onXhr(xhr,url),xhr.onreadystatechange=function(evt){var status,err;xhr.readyState===4&&(status=xhr.status||0,status>399&&status<600?(err=new Error(url+" HTTP status: "+status),err.xhr=xhr,errback&&errback(err)):callback(xhr.responseText),masterConfig.onXhrComplete&&masterConfig.onXhrComplete(xhr,url))},xhr.send(null)};else if(masterConfig.env==="rhino"||!masterConfig.env&&typeof Packages!="undefined"&&typeof java!="undefined")text.get=function(url,callback){var stringBuffer,line,encoding="utf-8",file=new java.io.File(url),lineSeparator=java.lang.System.getProperty("line.separator"),input=new java.io.BufferedReader 26 | (new java.io.InputStreamReader(new java.io.FileInputStream(file),encoding)),content="";try{stringBuffer=new java.lang.StringBuffer,line=input.readLine(),line&&line.length()&&line.charAt(0)===65279&&(line=line.substring(1)),line!==null&&stringBuffer.append(line);while((line=input.readLine())!==null)stringBuffer.append(lineSeparator),stringBuffer.append(line);content=String(stringBuffer.toString())}finally{input.close()}callback(content)};else if(masterConfig.env==="xpconnect"||!masterConfig.env&&typeof Components!="undefined"&&Components.classes&&Components.interfaces)Cc=Components.classes,Ci=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),xpcIsWindows="@mozilla.org/windows-registry-key;1"in Cc,text.get=function(url,callback){var inStream,convertStream,fileObj,readData={};xpcIsWindows&&(url=url.replace(/\//g,"\\")),fileObj=new FileUtils.File(url);try{inStream=Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream),inStream 27 | .init(fileObj,1,0,!1),convertStream=Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream),convertStream.init(inStream,"utf-8",inStream.available(),Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),convertStream.readString(inStream.available(),readData),convertStream.close(),inStream.close(),callback(readData.value)}catch(e){throw new Error((fileObj&&fileObj.path||"")+": "+e)}};return text}),define("json",["text"],function(text){var CACHE_BUST_QUERY_PARAM="bust",CACHE_BUST_FLAG="!bust",jsonParse=typeof JSON!="undefined"&&typeof JSON.parse=="function"?JSON.parse:function(val){return eval("("+val+")")},buildMap={};function cacheBust(url){return url=url.replace(CACHE_BUST_FLAG,""),url+=url.indexOf("?")<0?"?":"&",url+CACHE_BUST_QUERY_PARAM+"="+Math.round(2147483647*Math.random())}return{load:function(name,req,onLoad,config){config.isBuild&&(config.inlineJSON===!1||name.indexOf(CACHE_BUST_QUERY_PARAM+"=")!==-1)||req.toUrl(name).indexOf("empty:")===0? 28 | onLoad(null):text.get(req.toUrl(name),function(data){config.isBuild?(buildMap[name]=data,onLoad(data)):onLoad(jsonParse(data))},onLoad.error,{accept:"application/json"})},normalize:function(name,normalize){return name.indexOf(CACHE_BUST_FLAG)!==-1&&(name=cacheBust(name)),normalize(name)},write:function(pluginName,moduleName,write){if(moduleName in buildMap){var content=buildMap[moduleName];write('define("'+pluginName+"!"+moduleName+'", function(){ return '+content+";});\n")}}}}),function(requirejs){"use strict";define("bower",["module","json"],function(module,json){var defaults={root:"/bower.json",manifest:"bower.json",baseUrl:"../bower_components",extensions:"js|css",ignore:"requirejs|requirejs-domready|requirejs-text",auto:!0,deps:["dependencies"],loader:{css:"css"}},request={parent:null,config:{}},store={count:0,processed:{},json:{},modules:{},config:{paths:{},shim:{}}},REGEX_PATH_RELATIVE=/^([^a-z|0-9]*)/,REGEX_PATH_SPLIT=/^(.*?)([^/\\]*?)(?:\.([^ :\\/.]*))?$/;function objectExtend( 29 | destination,source){return typeof source=="object"&&Object.keys(source).forEach(function(value){destination[value]=source[value]}),destination}function formatManifestPath(name){return name=defaults.baseUrl+"/"+name+"/"+defaults.manifest,name}function processManifest(name,req,onProcess,config,root){var jsonFileName;req=req||request.parent,config=config||request.config,onProcess=onProcess||function(){},store.count=store.count+1;function finished(config){store.count=store.count-1,store.count<1&&request.onLoad(config)}root&&(request.onLoad=onProcess),request.config.isBuild?jsonFileName=name.replace(REGEX_PATH_RELATIVE,request.config.appDir):jsonFileName=name,store.processed[name]!==!0?(store.processed[name]=!0,json.load(jsonFileName,req,function(jsonFile){jsonFile?(typeof jsonFile!="object"&&(jsonFile=JSON.parse(jsonFile)),parseManifest(name,jsonFile,finished,root)):onProcess(store.config)},config)):finished(store.config)}function parseManifest(file,manifestJson,onParse,root){var baseUrl,baseName 30 | ,shimModules=[],shimDeps=[],localDeps=[],parseManifestPath=new RegExp(REGEX_PATH_SPLIT),parseRelativePath=new RegExp(REGEX_PATH_RELATIVE),validExt=new RegExp("^("+defaults.extensions+")$"),ignoreFile=new RegExp("^("+defaults.ignore+")$");if(!manifestJson){onParse(store.config);return}manifestJson.main=[].concat(manifestJson.main||file),defaults.deps.forEach(function(depsPath){manifestJson[depsPath]=Object.keys(manifestJson[depsPath]||{})}),baseUrl=parseManifestPath.exec(file)[1],baseName=manifestJson.name,manifestJson.main.forEach(function(moduleName){var name,file,path,ext,filePath=parseManifestPath.exec(moduleName);name=manifestJson.name,path=filePath[1].replace(parseRelativePath,""),file=filePath[2],ext=filePath[3],validExt.test(ext)&&!ignoreFile.test(baseName)&&(name=name.replace(".","-"),ext!=="js"?(name=name+"-"+ext,defaults.loader[ext]&&localDeps.push(defaults.loader[ext]+"!"+name)):file!==name&&manifestJson.main.length>1?(name=file,shimModules.push(name)):(name=name,shimModules. 31 | push(name)),store.config.paths[name]=baseUrl+path+file,store.config.shim[name]={},store.config.shim[name].exports=name)}),manifestJson.dependencies.forEach(function(value){shimDeps.push(value.replace(".","-"))}),shimModules.forEach(function(moduleName){if(manifestJson.dependencies.length>0||localDeps.length>0)store.config.shim[moduleName].deps=[].concat(localDeps,shimDeps)}),defaults.deps.forEach(function(bowerDependencies){manifestJson[bowerDependencies]&&manifestJson[bowerDependencies].length>0&&manifestJson[bowerDependencies].forEach(function(dependency){ignoreFile.test(dependency)||processManifest(formatManifestPath(dependency))})}),onParse(store.config)}function pluginLoad(name,req,onLoad,config){request.parent=req,request.config=config,defaults=objectExtend(defaults,request.config.bower||{}),processManifest(defaults.root,req,function(config){defaults.auto&&!request.config.isBuild&&requirejs.config(config),onLoad(config)},config,!0),config&&config.isBuild&&onLoad(store.config)}function pluginNormalize 32 | (name){return defaults.root=name||defaults.root,defaults.root}function pluginWrite(pluginName,moduleName,write){var content=JSON.stringify(store.config);defaults.auto?content='define("'+pluginName+"!"+moduleName+'", function(){var bowerConfig='+content+";\nrequirejs.config(bowerConfig);\nreturn bowerConfig;\n});\n":content='define("'+pluginName+"!"+moduleName+'", function(){\nreturn '+content+";\n});\n",write(content)}return{load:pluginLoad,normalize:pluginNormalize,write:pluginWrite}})}(requirejs),define("bower-bundle",function(){}); 33 | -------------------------------------------------------------------------------- /examples/dist/js/auto.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license RequireJS text 2.0.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. 3 | * Available via the MIT or new BSD license. 4 | * see: http://github.com/requirejs/text for details 5 | */ 6 | 7 | /** @license 8 | * RequireJS plugin for loading JSON files 9 | * - depends on Text plugin and it was HEAVILY "inspired" by it as well. 10 | * Author: Miller Medeiros 11 | * Version: 0.4.0 (2014/04/10) 12 | * Released under the MIT license 13 | */ 14 | 15 | /* 16 | * @license requirejs - plugin - bower 0.1.0 17 | * Copyright(c) 2014, Rodney Robert Ebanks foss@rodneyebanks.com All Rights Reserved. 18 | * Available via the MIT or new BSD license. 19 | */ 20 | 21 | define("text",["module"],function(module){var text,fs,Cc,Ci,xpcIsWindows,progIds=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],xmlRegExp=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,bodyRegExp=/]*>\s*([\s\S]+)\s*<\/body>/im,hasLocation=typeof location!="undefined"&&location.href,defaultProtocol=hasLocation&&location.protocol&&location.protocol.replace(/\:/,""),defaultHostName=hasLocation&&location.hostname,defaultPort=hasLocation&&(location.port||undefined),buildMap={},masterConfig=module.config&&module.config()||{};text={version:"2.0.13",strip:function(content){if(content){content=content.replace(xmlRegExp,"");var matches=content.match(bodyRegExp);matches&&(content=matches[1])}else content="";return content},jsEscape:function(content){return content.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")} 22 | ,createXhr:masterConfig.createXhr||function(){var xhr,i,progId;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")for(i=0;i<3;i+=1){progId=progIds[i];try{xhr=new ActiveXObject(progId)}catch(e){}if(xhr){progIds=[progId];break}}return xhr},parseName:function(name){var modName,ext,temp,strip=!1,index=name.lastIndexOf("."),isRelative=name.indexOf("./")===0||name.indexOf("../")===0;return index!==-1&&(!isRelative||index>1)?(modName=name.substring(0,index),ext=name.substring(index+1)):modName=name,temp=ext||modName,index=temp.indexOf("!"),index!==-1&&(strip=temp.substring(index+1)==="strip",temp=temp.substring(0,index),ext?ext=temp:modName=temp),{moduleName:modName,ext:ext,strip:strip}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(url,protocol,hostname,port){var uProtocol,uHostName,uPort,match=text.xdRegExp.exec(url);return match?(uProtocol=match[2],uHostName=match[3],uHostName=uHostName.split(":"),uPort=uHostName[1],uHostName=uHostName 23 | [0],(!uProtocol||uProtocol===protocol)&&(!uHostName||uHostName.toLowerCase()===hostname.toLowerCase())&&(!uPort&&!uHostName||uPort===port)):!0},finishLoad:function(name,strip,content,onLoad){content=strip?text.strip(content):content,masterConfig.isBuild&&(buildMap[name]=content),onLoad(content)},load:function(name,req,onLoad,config){if(config&&config.isBuild&&!config.inlineText){onLoad();return}masterConfig.isBuild=config&&config.isBuild;var parsed=text.parseName(name),nonStripName=parsed.moduleName+(parsed.ext?"."+parsed.ext:""),url=req.toUrl(nonStripName),useXhr=masterConfig.useXhr||text.useXhr;if(url.indexOf("empty:")===0){onLoad();return}!hasLocation||useXhr(url,defaultProtocol,defaultHostName,defaultPort)?text.get(url,function(content){text.finishLoad(name,parsed.strip,content,onLoad)},function(err){onLoad.error&&onLoad.error(err)}):req([nonStripName],function(content){text.finishLoad(parsed.moduleName+"."+parsed.ext,parsed.strip,content,onLoad)})},write:function(pluginName,moduleName 24 | ,write,config){if(buildMap.hasOwnProperty(moduleName)){var content=text.jsEscape(buildMap[moduleName]);write.asModule(pluginName+"!"+moduleName,"define(function () { return '"+content+"';});\n")}},writeFile:function(pluginName,moduleName,req,write,config){var parsed=text.parseName(moduleName),extPart=parsed.ext?"."+parsed.ext:"",nonStripName=parsed.moduleName+extPart,fileName=req.toUrl(parsed.moduleName+extPart)+".js";text.load(nonStripName,req,function(value){var textWrite=function(contents){return write(fileName,contents)};textWrite.asModule=function(moduleName,contents){return write.asModule(moduleName,fileName,contents)},text.write(pluginName,nonStripName,textWrite,config)},config)}};if(masterConfig.env==="node"||!masterConfig.env&&typeof process!="undefined"&&process.versions&&!!process.versions.node&&!process.versions["node-webkit"])fs=require.nodeRequire("fs"),text.get=function(url,callback,errback){try{var file=fs.readFileSync(url,"utf8");file[0]==="\ufeff"&&(file=file.substring 25 | (1)),callback(file)}catch(e){errback&&errback(e)}};else if(masterConfig.env==="xhr"||!masterConfig.env&&text.createXhr())text.get=function(url,callback,errback,headers){var xhr=text.createXhr(),header;xhr.open("GET",url,!0);if(headers)for(header in headers)headers.hasOwnProperty(header)&&xhr.setRequestHeader(header.toLowerCase(),headers[header]);masterConfig.onXhr&&masterConfig.onXhr(xhr,url),xhr.onreadystatechange=function(evt){var status,err;xhr.readyState===4&&(status=xhr.status||0,status>399&&status<600?(err=new Error(url+" HTTP status: "+status),err.xhr=xhr,errback&&errback(err)):callback(xhr.responseText),masterConfig.onXhrComplete&&masterConfig.onXhrComplete(xhr,url))},xhr.send(null)};else if(masterConfig.env==="rhino"||!masterConfig.env&&typeof Packages!="undefined"&&typeof java!="undefined")text.get=function(url,callback){var stringBuffer,line,encoding="utf-8",file=new java.io.File(url),lineSeparator=java.lang.System.getProperty("line.separator"),input=new java.io.BufferedReader 26 | (new java.io.InputStreamReader(new java.io.FileInputStream(file),encoding)),content="";try{stringBuffer=new java.lang.StringBuffer,line=input.readLine(),line&&line.length()&&line.charAt(0)===65279&&(line=line.substring(1)),line!==null&&stringBuffer.append(line);while((line=input.readLine())!==null)stringBuffer.append(lineSeparator),stringBuffer.append(line);content=String(stringBuffer.toString())}finally{input.close()}callback(content)};else if(masterConfig.env==="xpconnect"||!masterConfig.env&&typeof Components!="undefined"&&Components.classes&&Components.interfaces)Cc=Components.classes,Ci=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),xpcIsWindows="@mozilla.org/windows-registry-key;1"in Cc,text.get=function(url,callback){var inStream,convertStream,fileObj,readData={};xpcIsWindows&&(url=url.replace(/\//g,"\\")),fileObj=new FileUtils.File(url);try{inStream=Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream),inStream 27 | .init(fileObj,1,0,!1),convertStream=Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream),convertStream.init(inStream,"utf-8",inStream.available(),Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),convertStream.readString(inStream.available(),readData),convertStream.close(),inStream.close(),callback(readData.value)}catch(e){throw new Error((fileObj&&fileObj.path||"")+": "+e)}};return text}),define("json",["text"],function(text){var CACHE_BUST_QUERY_PARAM="bust",CACHE_BUST_FLAG="!bust",jsonParse=typeof JSON!="undefined"&&typeof JSON.parse=="function"?JSON.parse:function(val){return eval("("+val+")")},buildMap={};function cacheBust(url){return url=url.replace(CACHE_BUST_FLAG,""),url+=url.indexOf("?")<0?"?":"&",url+CACHE_BUST_QUERY_PARAM+"="+Math.round(2147483647*Math.random())}return{load:function(name,req,onLoad,config){config.isBuild&&(config.inlineJSON===!1||name.indexOf(CACHE_BUST_QUERY_PARAM+"=")!==-1)||req.toUrl(name).indexOf("empty:")===0? 28 | onLoad(null):text.get(req.toUrl(name),function(data){config.isBuild?(buildMap[name]=data,onLoad(data)):onLoad(jsonParse(data))},onLoad.error,{accept:"application/json"})},normalize:function(name,normalize){return name.indexOf(CACHE_BUST_FLAG)!==-1&&(name=cacheBust(name)),normalize(name)},write:function(pluginName,moduleName,write){if(moduleName in buildMap){var content=buildMap[moduleName];write('define("'+pluginName+"!"+moduleName+'", function(){ return '+content+";});\n")}}}}),function(requirejs){define("bower",["module","json"],function(module,json){var defaults={root:"/bower.json",manifest:"bower.json",baseUrl:"../bower_components",extensions:"js|css",ignore:"requirejs|requirejs-domready|requirejs-text",auto:!0,deps:["dependencies"],loader:{css:"css"}},request={parent:null,config:{}},store={count:0,processed:{},json:{},modules:{},config:{paths:{},shim:{}}},REGEX_PATH_RELATIVE=/^([^a-z|0-9]*)/,REGEX_PATH_SPLIT=/^(.*?)([^/\\]*?)(?:\.([^ :\\/.]*))?$/;function objectExtend(destination,source 29 | ){return typeof source=="object"&&Object.keys(source).forEach(function(value){destination[value]=source[value]}),destination}function formatManifestPath(name){return name=defaults.baseUrl+"/"+name+"/"+defaults.manifest,name}function processManifest(name,req,onProcess,config,root){var jsonFileName;req=req||request.parent,config=config||request.config,onProcess=onProcess||function(){},store.count=store.count+1;function finished(config){store.count=store.count-1,store.count<1&&request.onLoad(config)}root&&(request.onLoad=onProcess),request.config.isBuild?jsonFileName=name.replace(REGEX_PATH_RELATIVE,request.config.appDir):jsonFileName=name,store.processed[name]!==!0?(store.processed[name]=!0,json.load(jsonFileName,req,function(jsonFile){jsonFile?(typeof jsonFile!="object"&&(jsonFile=JSON.parse(jsonFile)),parseManifest(name,jsonFile,finished,root)):onProcess(store.config)},config)):finished(store.config)}function parseManifest(file,manifestJson,onParse,root){var baseUrl,baseName,shimModules= 30 | [],shimDeps=[],localDeps=[],parseManifestPath=new RegExp(REGEX_PATH_SPLIT),parseRelativePath=new RegExp(REGEX_PATH_RELATIVE),validExt=new RegExp("^("+defaults.extensions+")$"),ignoreFile=new RegExp("^("+defaults.ignore+")$");if(!manifestJson){onParse(store.config);return}manifestJson.main=[].concat(manifestJson.main||file),defaults.deps.forEach(function(depsPath){manifestJson[depsPath]=Object.keys(manifestJson[depsPath]||{})}),baseUrl=parseManifestPath.exec(file)[1],baseName=manifestJson.name,manifestJson.main.forEach(function(moduleName){var name,file,path,ext,filePath=parseManifestPath.exec(moduleName);name=manifestJson.name,path=filePath[1].replace(parseRelativePath,""),file=filePath[2],ext=filePath[3],validExt.test(ext)&&!ignoreFile.test(baseName)&&(name=name.replace(".","-"),ext!=="js"?(name=name+"-"+ext,defaults.loader[ext]&&localDeps.push(defaults.loader[ext]+"!"+name)):file!==name&&manifestJson.main.length>1?(name=file,shimModules.push(name)):(name=name,shimModules.push(name)),store 31 | .config.paths[name]=baseUrl+path+file,store.config.shim[name]={},store.config.shim[name].exports=name)}),manifestJson.dependencies.forEach(function(value){shimDeps.push(value.replace(".","-"))}),shimModules.forEach(function(moduleName){if(manifestJson.dependencies.length>0||localDeps.length>0)store.config.shim[moduleName].deps=[].concat(localDeps,shimDeps)}),defaults.deps.forEach(function(bowerDependencies){manifestJson[bowerDependencies]&&manifestJson[bowerDependencies].length>0&&manifestJson[bowerDependencies].forEach(function(dependency){ignoreFile.test(dependency)||processManifest(formatManifestPath(dependency))})}),onParse(store.config)}function pluginLoad(name,req,onLoad,config){request.parent=req,request.config=config,defaults=objectExtend(defaults,request.config.bower||{}),processManifest(defaults.root,req,function(config){defaults.auto&&!request.config.isBuild&&requirejs.config(config),onLoad(config)},config,!0),config&&config.isBuild&&onLoad(store.config)}function pluginNormalize 32 | (name){return defaults.root=name||defaults.root,defaults.root}function pluginWrite(pluginName,moduleName,write){var content=JSON.stringify(store.config);defaults.auto?content='define("'+pluginName+"!"+moduleName+'", function(){var bowerConfig='+content+";\nrequirejs.config(bowerConfig);\nreturn bowerConfig;\n});\n":content='define("'+pluginName+"!"+moduleName+'", function(){\nreturn '+content+";\n});\n",write(content)}return{load:pluginLoad,normalize:pluginNormalize,write:pluginWrite}})}(requirejs),define("bower!../bower.json",function(){var bowerConfig={paths:{bower:"../bower_components/requirejs-plugin-bower/dist/bower","bower-bundle":"../bower_components/requirejs-plugin-bower/dist/bower-bundle",async:"../bower_components/requirejs-plugins/src/async",depend:"../bower_components/requirejs-plugins/src/depend",font:"../bower_components/requirejs-plugins/src/font",goog:"../bower_components/requirejs-plugins/src/goog",image:"../bower_components/requirejs-plugins/src/image",json:"../bower_components/requirejs-plugins/src/json" 33 | ,mdown:"../bower_components/requirejs-plugins/src/mdown",noext:"../bower_components/requirejs-plugins/src/noext",propertyParser:"../bower_components/requirejs-plugins/src/propertyParser","Markdown.Converter":"../bower_components/requirejs-plugins/lib/Markdown.Converter",text:"../bower_components/requirejs-plugins/lib/text"},shim:{bower:{exports:"bower",deps:["requirejs-text","requirejs-plugins"]},"bower-bundle":{exports:"bower-bundle",deps:["requirejs-text","requirejs-plugins"]},async:{exports:"async"},depend:{exports:"depend"},font:{exports:"font"},goog:{exports:"goog"},image:{exports:"image"},json:{exports:"json"},mdown:{exports:"mdown"},noext:{exports:"noext"},propertyParser:{exports:"propertyParser"},"Markdown.Converter":{exports:"Markdown.Converter"},text:{exports:"text"}}};return requirejs.config(bowerConfig),bowerConfig}),define("auto",["bower!../bower.json"],function(bowerConfig){requirejs(["bootstrap"])}); 34 | --------------------------------------------------------------------------------